@intentic/sandbox-contract 1.364.0 → 1.365.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/README.md +3 -0
  2. package/dist/contracts/agents.contract.d.ts +253 -0
  3. package/dist/contracts/agents.contract.d.ts.map +1 -1
  4. package/dist/contracts/agents.contract.js +18 -0
  5. package/dist/contracts/agents.contract.js.map +1 -1
  6. package/dist/contracts/needs.contract.d.ts +232 -0
  7. package/dist/contracts/needs.contract.d.ts.map +1 -1
  8. package/dist/contracts/needs.contract.js +11 -1
  9. package/dist/contracts/needs.contract.js.map +1 -1
  10. package/dist/contracts/runner.contract.d.ts +32 -0
  11. package/dist/contracts/runner.contract.d.ts.map +1 -1
  12. package/dist/contracts/settings.contract.d.ts +2 -0
  13. package/dist/contracts/settings.contract.d.ts.map +1 -1
  14. package/dist/contracts/system.contract.d.ts +33 -0
  15. package/dist/contracts/system.contract.d.ts.map +1 -1
  16. package/dist/contracts/workspace.contract.d.ts +232 -0
  17. package/dist/contracts/workspace.contract.d.ts.map +1 -1
  18. package/dist/contracts/workspace.contract.js +12 -1
  19. package/dist/contracts/workspace.contract.js.map +1 -1
  20. package/dist/events/agent-events.d.ts +14 -0
  21. package/dist/events/agent-events.d.ts.map +1 -1
  22. package/dist/events/agent-events.js +5 -1
  23. package/dist/events/agent-events.js.map +1 -1
  24. package/dist/events/sandbox-notice.d.ts +14 -0
  25. package/dist/events/sandbox-notice.d.ts.map +1 -1
  26. package/dist/events/sandbox-notice.js +13 -1
  27. package/dist/events/sandbox-notice.js.map +1 -1
  28. package/dist/events/system-events.d.ts +26 -0
  29. package/dist/events/system-events.d.ts.map +1 -1
  30. package/dist/events/tool-update.d.ts +6 -0
  31. package/dist/events/tool-update.d.ts.map +1 -0
  32. package/dist/events/tool-update.js +12 -0
  33. package/dist/events/tool-update.js.map +1 -0
  34. package/dist/events/transcript.d.ts +1 -0
  35. package/dist/events/transcript.d.ts.map +1 -1
  36. package/dist/events/transcript.js +4 -0
  37. package/dist/events/transcript.js.map +1 -1
  38. package/dist/index.d.ts +752 -0
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/models/device-deadlines.d.ts +34 -0
  41. package/dist/models/device-deadlines.d.ts.map +1 -0
  42. package/dist/models/device-deadlines.js +28 -0
  43. package/dist/models/device-deadlines.js.map +1 -0
  44. package/dist/protocol/member-reach.d.ts +18 -0
  45. package/dist/protocol/member-reach.d.ts.map +1 -0
  46. package/dist/protocol/member-reach.js +31 -0
  47. package/dist/protocol/member-reach.js.map +1 -0
  48. package/dist/protocol/raw/raw-json-routes.d.ts +114 -0
  49. package/dist/protocol/raw/raw-json-routes.d.ts.map +1 -1
  50. package/dist/protocol/raw/raw-json-routes.js +4 -1
  51. package/dist/protocol/raw/raw-json-routes.js.map +1 -1
  52. package/dist/protocol/raw/raw-routes.d.ts +16 -0
  53. package/dist/protocol/raw/raw-routes.d.ts.map +1 -1
  54. package/dist/protocol/raw/raw-routes.js +6 -3
  55. package/dist/protocol/raw/raw-routes.js.map +1 -1
  56. package/dist/schemas/agents-list.d.ts +26 -0
  57. package/dist/schemas/agents-list.d.ts.map +1 -1
  58. package/dist/schemas/agents.d.ts +50 -0
  59. package/dist/schemas/agents.d.ts.map +1 -1
  60. package/dist/schemas/agents.js +17 -0
  61. package/dist/schemas/agents.js.map +1 -1
  62. package/dist/schemas/environment.d.ts +5 -0
  63. package/dist/schemas/environment.d.ts.map +1 -1
  64. package/dist/schemas/environment.js +3 -0
  65. package/dist/schemas/environment.js.map +1 -1
  66. package/dist/schemas/members.d.ts +52 -0
  67. package/dist/schemas/members.d.ts.map +1 -1
  68. package/dist/schemas/members.js +15 -0
  69. package/dist/schemas/members.js.map +1 -1
  70. package/dist/schemas/needs.d.ts +7 -0
  71. package/dist/schemas/needs.d.ts.map +1 -1
  72. package/dist/schemas/needs.js +3 -0
  73. package/dist/schemas/needs.js.map +1 -1
  74. package/dist/schemas/providers/handoff.d.ts +24 -0
  75. package/dist/schemas/providers/handoff.d.ts.map +1 -1
  76. package/dist/schemas/providers/handoff.js +32 -0
  77. package/dist/schemas/providers/handoff.js.map +1 -1
  78. package/dist/schemas/providers/usage.d.ts +6 -0
  79. package/dist/schemas/providers/usage.d.ts.map +1 -1
  80. package/dist/schemas/providers/usage.js +2 -0
  81. package/dist/schemas/providers/usage.js.map +1 -1
  82. package/dist/schemas/settings-experiments.d.ts.map +1 -1
  83. package/dist/schemas/settings-experiments.js +1 -1
  84. package/dist/schemas/settings-experiments.js.map +1 -1
  85. package/dist/schemas/settings.d.ts +2 -0
  86. package/dist/schemas/settings.d.ts.map +1 -1
  87. package/dist/schemas/settings.js +6 -0
  88. package/dist/schemas/settings.js.map +1 -1
  89. package/dist/schemas/workspace/workspace-search.d.ts +93 -0
  90. package/dist/schemas/workspace/workspace-search.d.ts.map +1 -1
  91. package/dist/schemas/workspace/workspace-search.js +10 -0
  92. package/dist/schemas/workspace/workspace-search.js.map +1 -1
  93. package/dist/state/definition.d.ts +4 -0
  94. package/dist/state/definition.d.ts.map +1 -1
  95. package/dist/state/runtime-state.d.ts +3 -0
  96. package/dist/state/runtime-state.d.ts.map +1 -1
  97. package/dist/state/runtime-state.js +1 -0
  98. package/dist/state/runtime-state.js.map +1 -1
  99. package/dist/text/land-rows.d.ts.map +1 -1
  100. package/dist/text/land-rows.js +5 -2
  101. package/dist/text/land-rows.js.map +1 -1
  102. package/dist/text/notice-rows.d.ts +8 -0
  103. package/dist/text/notice-rows.d.ts.map +1 -0
  104. package/dist/text/notice-rows.js +14 -0
  105. package/dist/text/notice-rows.js.map +1 -0
  106. package/dist/text/transcript-fold.d.ts.map +1 -1
  107. package/dist/text/transcript-fold.js +25 -26
  108. package/dist/text/transcript-fold.js.map +1 -1
  109. package/package.json +5 -5
  110. package/src/contracts/agents.contract.ts +21 -0
  111. package/src/contracts/needs.contract.ts +14 -0
  112. package/src/contracts/workspace.contract.ts +15 -1
  113. package/src/events/agent-events.ts +11 -1
  114. package/src/events/sandbox-notice.ts +17 -1
  115. package/src/events/tool-update.ts +18 -0
  116. package/src/events/transcript.ts +5 -0
  117. package/src/models/device-deadlines.ts +62 -0
  118. package/src/protocol/member-reach.test.ts +221 -0
  119. package/src/protocol/member-reach.ts +78 -0
  120. package/src/protocol/raw/raw-json-routes.ts +12 -1
  121. package/src/protocol/raw/raw-routes.ts +10 -4
  122. package/src/schemas/agents.ts +30 -0
  123. package/src/schemas/environment.ts +9 -0
  124. package/src/schemas/members.ts +30 -0
  125. package/src/schemas/needs.ts +4 -0
  126. package/src/schemas/providers/handoff.test.ts +23 -1
  127. package/src/schemas/providers/handoff.ts +49 -0
  128. package/src/schemas/providers/usage.ts +4 -0
  129. package/src/schemas/settings-experiments.ts +5 -1
  130. package/src/schemas/settings.ts +12 -0
  131. package/src/schemas/shared.ts +1 -1
  132. package/src/schemas/workspace/workspace-search.ts +16 -0
  133. package/src/state/runtime-state.ts +5 -0
  134. package/src/state/workspace-state.ts +1 -1
  135. package/src/text/land-rows.ts +6 -2
  136. package/src/text/notice-rows.ts +21 -0
  137. package/src/text/transcript-fold.test.ts +102 -2
  138. package/src/text/transcript-fold.ts +29 -30
@@ -11,14 +11,14 @@ import {
11
11
  type TranscriptSubagent,
12
12
  type TranscriptTool,
13
13
  } from "../events/transcript.js";
14
- import { contextTrimLine, contextTrimNotice } from "../schemas/context-trim.js";
15
14
  import { keptWarmLine, keptWarmNotice } from "../schemas/keep-warm.js";
16
- import { handedOffLine, handedOffNotice } from "../schemas/providers/handoff.js";
15
+ import { startingRow } from "./notice-rows.js";
17
16
  import { isLandConflict } from "../events/land-conflict.js";
18
17
  import { turnedAwayCode } from "../policy/turned-away.js";
19
18
  import { errorRow, RENEWAL_WITHDRAWN, RENEWING } from "../events/failure-rows.js";
20
19
  import { mentionedPathTokens } from "./mentions.js";
21
20
  import { unspokenPromptRow } from "../events/agent-words.js";
21
+ import { takeToolUpdate } from "../events/tool-update.js";
22
22
  import { needRowText } from "../events/need-wake.js";
23
23
  import { noticeCode, sandboxNoticeOf } from "../events/sandbox-notice.js";
24
24
  import { installRow, landedRow, syncLine } from "./land-rows.js";
@@ -73,6 +73,7 @@ const cardOf = (event: Extract<AgentEvent, { kind: "tool_call" }>, at: number |
73
73
  ...(event.locations !== undefined ? { locations: event.locations } : {}),
74
74
  ...(event.content !== undefined ? { content: event.content } : {}),
75
75
  ...(event.input !== undefined ? { input: event.input } : {}),
76
+ ...(event.server !== undefined ? { server: event.server } : {}),
76
77
  ...(at !== undefined ? { startedAt: at, ...(ended(event.status) ? { endedAt: at } : {}) } : {}),
77
78
  });
78
79
 
@@ -191,16 +192,11 @@ export class TranscriptFold {
191
192
  tool.endedAt = this.now();
192
193
  }
193
194
  }
194
- if (event.exitCode !== undefined) {
195
- tool.exitCode = event.exitCode;
196
- }
195
+ takeToolUpdate(tool, event);
197
196
  if (event.content !== undefined) {
198
197
  tool.content = event.content;
199
198
  this.claimByResult(tool);
200
199
  }
201
- if (event.locations !== undefined) {
202
- tool.locations = event.locations;
203
- }
204
200
  });
205
201
  case "subagent":
206
202
  return this.subagentBorn(event);
@@ -247,12 +243,12 @@ export class TranscriptFold {
247
243
  const notice = keptWarmNotice(event);
248
244
  return line === undefined || notice === undefined ? [] : this.pushRow({ role: "notice", text: line, noticeCode: noticeCode(notice) });
249
245
  }
246
+ // Each a row of its own rather than a stamp on the message: what was left out is not part of what was sent, and
247
+ // the fold beside the message only ever lists notes that actually rode.
250
248
  case "context_trim":
251
- // A row of its own rather than a stamp on the message: what was left out is not part of what was sent,
252
- // and the fold beside the message only ever lists notes that actually rode.
253
- return this.pushRow({ role: "notice", text: contextTrimLine(event), noticeCode: noticeCode(contextTrimNotice(event)) });
254
249
  case "handoff":
255
- return this.pushRow({ role: "notice", text: handedOffLine(event), noticeCode: noticeCode(handedOffNotice(event)) });
250
+ case "fresh_start":
251
+ return this.pushRow(startingRow(event));
256
252
  case "worktree":
257
253
  return this.synced(event.sync);
258
254
  case "landed":
@@ -737,14 +733,18 @@ export const patchedRow = <R extends TranscriptRow>(row: R, patch: RowPatch): R
737
733
 
738
734
  /** Applies one patch to a row list; only what the patch names moves (patchedRow). */
739
735
  export const applyTranscriptPatch = (rows: readonly TranscriptRow[], patch: TranscriptPatch): TranscriptRow[] => {
740
- switch (patch.op) {
741
- case "append":
742
- return [...rows, patch.row];
743
- case "drop":
744
- return rows.filter((_row, index) => index !== patch.index);
745
- default:
746
- return rows.map((row, index) => (index === patch.index ? patchedRow(row, patch) : row));
736
+ if (patch.op === "append") {
737
+ return [...rows, patch.row];
747
738
  }
739
+ if (patch.op === "drop") {
740
+ return rows.filter((_row, index) => index !== patch.index);
741
+ }
742
+ const next = [...rows];
743
+ const row = next[patch.index];
744
+ if (row !== undefined) {
745
+ next[patch.index] = patchedRow(row, patch);
746
+ }
747
+ return next;
748
748
  };
749
749
 
750
750
  // Appends a delegated subagent's reasoning onto the card with this id, wherever it nests.
@@ -771,25 +771,24 @@ const upsertTool = (tools: readonly TranscriptTool[], tool: TranscriptTool, pare
771
771
  return [...tools, tool];
772
772
  };
773
773
 
774
- // Applies `fn` to the tool with `id` anywhere in the tree; returns the same array when absent, so an unrelated row's
775
- // identity is unchanged.
774
+ // Applies `fn` to the tool with `id` anywhere in the tree; copies only arrays on a changed branch, so an unrelated
775
+ // subtree keeps its identity without allocating an array for every streamed update.
776
776
  export const mapTool = (tools: readonly TranscriptTool[], id: string, fn: (tool: TranscriptTool) => TranscriptTool): readonly TranscriptTool[] => {
777
- let changed = false;
778
- const next = tools.map((tool) => {
777
+ let next: TranscriptTool[] | undefined;
778
+ for (let index = 0; index < tools.length; index += 1) {
779
+ const tool = tools[index]!;
779
780
  if (tool.id === id) {
780
- changed = true;
781
- return fn(tool);
781
+ (next ??= [...tools])[index] = fn(tool);
782
+ continue;
782
783
  }
783
784
  if (tool.children !== undefined) {
784
785
  const children = mapTool(tool.children, id, fn);
785
786
  if (children !== tool.children) {
786
- changed = true;
787
- return { ...tool, children: [...children] };
787
+ (next ??= [...tools])[index] = { ...tool, children: [...children] };
788
788
  }
789
789
  }
790
- return tool;
791
- });
792
- return changed ? next : tools;
790
+ }
791
+ return next ?? tools;
793
792
  };
794
793
 
795
794
  // Which row fields are cards, exported for readers that count rows by them.