remote-task-open.fixture.mjs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import { conversationTopicWireFrameSchema } from "@zcode/shared/zcode-protocol-v4";
  2. // 只提供已完成历史,不产生模型请求;快照经真实协议 schema 校验后送入 renderer。
  3. export function taskSnapshotFrame(sessionId, subscriptionId) {
  4. const topic = `conversation/${sessionId}`;
  5. return conversationTopicWireFrameSchema.parse({
  6. wireVersion: 3,
  7. kind: "complete",
  8. deliveryKind: "initial",
  9. logicalFrameId: `frame-${subscriptionId}`,
  10. logicalFrameOrdinal: 1,
  11. topic,
  12. subscriptionId,
  13. frame: {
  14. topic,
  15. subscriptionId,
  16. fromSeq: 0,
  17. toSeq: 1,
  18. sentAt: 1,
  19. payload: {
  20. kind: "snapshot",
  21. snapshot: {
  22. protocolVersion: 1,
  23. sessionId,
  24. logEpoch: "e2e",
  25. seq: 1,
  26. revision: 1,
  27. control: {
  28. phase: "completedSuccess",
  29. sessionEnded: false,
  30. canStop: false,
  31. stopState: "idle",
  32. stopTargetKind: "unknown",
  33. activeWorks: [],
  34. lastError: null,
  35. apiRetry: null,
  36. },
  37. availability: {
  38. fork: { allowed: true },
  39. compact: { allowed: false, reasonCode: "idleCannotCompact" },
  40. switchModelConfig: { allowed: true },
  41. setFollowupMode: { allowed: true },
  42. queueEdit: { allowed: true },
  43. sendQueuedNow: { allowed: false, reasonCode: "sendQueuedNowRequiresRunning" },
  44. pauseGoal: { allowed: false, reasonCode: "noGoalToPause" },
  45. resumeGoal: { allowed: false, reasonCode: "noGoalToResume" },
  46. },
  47. inputRouting: { mode: "startNow" },
  48. meta: { title: `E2E_MRO01_${sessionId}`, titleSource: "custom" },
  49. config: { provider: "", model: "", thought: "", followupMode: "queue" },
  50. usage: {
  51. contextWindow: null,
  52. cumulative: {
  53. inputTokens: 0,
  54. outputTokens: 0,
  55. cacheReadTokens: 0,
  56. cacheWriteTokens: 0,
  57. },
  58. },
  59. queue: { items: [], autoDrain: true },
  60. pendingInteractions: [],
  61. pendingCommands: [],
  62. backgroundWorks: [],
  63. goal: null,
  64. plan: null,
  65. rows: {
  66. totalCount: 1,
  67. firstRowId: 1,
  68. window: [
  69. {
  70. rowId: 1,
  71. turnId: "turn-1",
  72. createdAt: 1,
  73. createdAtSeq: 1,
  74. kind: "assistantText",
  75. text: `E2E_MRO01_${sessionId}_HISTORY`,
  76. state: "complete",
  77. },
  78. ],
  79. },
  80. },
  81. },
  82. },
  83. });
  84. }