@sema-agent/client-core 0.94.0 → 0.95.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 (255) hide show
  1. package/CHANGELOG.md +341 -0
  2. package/README.md +70 -47
  3. package/dist/adapt/arms.js +5 -6
  4. package/dist/adapt/panelTasks.js +4 -10
  5. package/dist/adapt/toolCards.js +2 -2
  6. package/dist/adapt/wireShapes.js +3 -8
  7. package/dist/adapter/activeRunSelfHeal.d.ts +8 -3
  8. package/dist/adapter/activeRunSelfHeal.js +20 -12
  9. package/dist/adapter/downstream/eventToSdkMessage.js +24 -17
  10. package/dist/adapter/downstream/terminalToSdkResult.js +11 -3
  11. package/dist/adapter/runStream.js +2 -1
  12. package/dist/adapter/types.d.ts +7 -0
  13. package/dist/adapter/types.js +15 -0
  14. package/dist/agentSession/backgroundView.js +5 -1
  15. package/dist/agentSession/engineAgentRegistryRead.js +2 -1
  16. package/dist/agentSession/engineSessionBackgroundStop.js +3 -2
  17. package/dist/agentsWireCaps.d.ts +2 -0
  18. package/dist/approvalDecidedByCapability.d.ts +0 -1
  19. package/dist/approvalDecidedByCapability.js +2 -7
  20. package/dist/approvalsStreamLiveCapability.d.ts +0 -1
  21. package/dist/approvalsStreamLiveCapability.js +2 -6
  22. package/dist/atMostOnce.d.ts +8 -0
  23. package/dist/atMostOnce.js +36 -0
  24. package/dist/attachmentSeatCapability.d.ts +0 -1
  25. package/dist/attachmentSeatCapability.js +0 -3
  26. package/dist/attachmentsWireCaps.js +11 -6
  27. package/dist/bashExitReading.d.ts +10 -0
  28. package/dist/bashExitReading.js +12 -0
  29. package/dist/callerCwdCapability.d.ts +0 -1
  30. package/dist/callerCwdCapability.js +2 -7
  31. package/dist/centerWiringCapability.d.ts +1 -3
  32. package/dist/centerWiringCapability.js +18 -21
  33. package/dist/classifierStatus.js +4 -4
  34. package/dist/cloudConfigWireCaps.js +43 -21
  35. package/dist/compensations.js +1 -1
  36. package/dist/cycleOrder.d.ts +15 -0
  37. package/dist/cycleOrder.js +45 -0
  38. package/dist/decideFailureNote.js +4 -1
  39. package/dist/decideReceipt.d.ts +2 -1
  40. package/dist/decideReceipt.js +41 -13
  41. package/dist/declared/supportFloorDeclared.d.ts +1 -0
  42. package/dist/declared/supportFloorDeclared.js +5 -0
  43. package/dist/deviceExecutorManagementCapability.d.ts +0 -1
  44. package/dist/deviceExecutorManagementCapability.js +7 -16
  45. package/dist/deviceRebind.d.ts +88 -0
  46. package/dist/deviceRebind.js +242 -0
  47. package/dist/displayUntrusted.d.ts +1 -0
  48. package/dist/displayUntrusted.js +313 -11
  49. package/dist/engineAgentAbsence.d.ts +2 -2
  50. package/dist/engineAgentPanelStore.d.ts +8 -18
  51. package/dist/engineAgentPanelStore.js +19 -537
  52. package/dist/engineCapReader.d.ts +6 -6
  53. package/dist/engineCapReader.js +30 -43
  54. package/dist/engineCapsCache.d.ts +7 -2
  55. package/dist/engineCapsCache.js +64 -26
  56. package/dist/engineCredentialRequirement.d.ts +9 -0
  57. package/dist/engineCredentialRequirement.js +23 -0
  58. package/dist/engineEnvSourcing.d.ts +53 -0
  59. package/dist/engineEnvSourcing.js +81 -0
  60. package/dist/engineErrorCodes.d.ts +14 -3
  61. package/dist/engineErrorCodes.js +31 -10
  62. package/dist/engineIdentity.js +2 -0
  63. package/dist/engineWireSdk.js +2 -2
  64. package/dist/executionLaneCapability.d.ts +2 -3
  65. package/dist/executionLaneCapability.js +18 -23
  66. package/dist/fileHistoryCaptureCapability.d.ts +0 -1
  67. package/dist/fileHistoryCaptureCapability.js +2 -6
  68. package/dist/fileHistoryLegNotice.d.ts +3 -2
  69. package/dist/fileHistoryLegNotice.js +51 -2
  70. package/dist/fleet/fleetLedger.d.ts +2 -0
  71. package/dist/fleet/fleetLedger.js +69 -52
  72. package/dist/fleet/fleetProjection.d.ts +0 -3
  73. package/dist/fleet/fleetProjection.js +9 -16
  74. package/dist/fleetAgentPanelProjection.d.ts +4 -17
  75. package/dist/fleetAgentPanelProjection.js +7 -197
  76. package/dist/fleetAgentRowLike.d.ts +16 -0
  77. package/dist/fleetAgentRowLike.js +1 -0
  78. package/dist/gateOutcome.js +30 -18
  79. package/dist/generated/sdkFactTables.d.ts +2 -0
  80. package/dist/generated/sdkFactTables.js +17 -0
  81. package/dist/generated/settingsSchemaFns.d.ts +10 -0
  82. package/dist/generated/settingsSchemaFns.js +22 -0
  83. package/dist/headlessPermissionModeWire.d.ts +1 -1
  84. package/dist/headlessPermissionModeWire.js +1 -1
  85. package/dist/headlessReconnectWire.js +49 -20
  86. package/dist/hitl/allowRuleShadow.d.ts +1 -1
  87. package/dist/hitl/allowRuleShadow.js +49 -8
  88. package/dist/hitl/approvalCompleteParked.d.ts +1 -0
  89. package/dist/hitl/approvalCompleteParked.js +14 -0
  90. package/dist/hitl/approvalEndingCause.d.ts +5 -0
  91. package/dist/hitl/approvalEndingCause.js +61 -0
  92. package/dist/hitl/approvalHolds.d.ts +12 -2
  93. package/dist/hitl/approvalHolds.js +53 -2
  94. package/dist/hitl/approvalsFeed.js +23 -11
  95. package/dist/hitl/askGateWire.d.ts +2 -1
  96. package/dist/hitl/askGateWire.js +26 -1
  97. package/dist/hitl/automaticAnswerVerdict.js +2 -2
  98. package/dist/hitl/crashConverged.js +2 -0
  99. package/dist/hitl/decisionConflict.d.ts +3 -0
  100. package/dist/hitl/decisionConflict.js +43 -0
  101. package/dist/hitl/decisionRefusal.d.ts +4 -0
  102. package/dist/hitl/decisionRefusal.js +26 -1
  103. package/dist/hitl/frameRouter.js +26 -43
  104. package/dist/hitl/gateLedger.d.ts +5 -0
  105. package/dist/hitl/gateLedger.js +21 -0
  106. package/dist/hitl/hitlBridge.d.ts +12 -1
  107. package/dist/hitl/hitlBridge.js +68 -53
  108. package/dist/hitl/hitlHostSurface.js +3 -11
  109. package/dist/hitl/livePendingAsk.d.ts +16 -6
  110. package/dist/hitl/livePendingAsk.js +36 -4
  111. package/dist/hitl/parkExpiryJudgements.d.ts +19 -0
  112. package/dist/hitl/parkExpiryJudgements.js +46 -0
  113. package/dist/hitl/parkResolver.d.ts +3 -7
  114. package/dist/hitl/parkResolver.js +50 -26
  115. package/dist/hitl/persistedRulesWire.js +5 -1
  116. package/dist/hitl/planReviewWire.d.ts +2 -2
  117. package/dist/hitl/planReviewWire.js +56 -30
  118. package/dist/hitl/replayedApproval.d.ts +8 -0
  119. package/dist/hitl/replayedApproval.js +125 -10
  120. package/dist/hitl/resumeRunningCard.d.ts +2 -0
  121. package/dist/hitl/resumeRunningCard.js +15 -4
  122. package/dist/hitl/toolApprovalWire.d.ts +24 -4
  123. package/dist/hitl/toolApprovalWire.js +115 -38
  124. package/dist/hooksWireCaps.js +38 -6
  125. package/dist/host.d.ts +5 -0
  126. package/dist/host.js +3 -1
  127. package/dist/hostCallbackGuard.d.ts +1 -0
  128. package/dist/hostCallbackGuard.js +25 -0
  129. package/dist/index.d.ts +30 -11
  130. package/dist/index.js +20 -8
  131. package/dist/interactiveInterrupt.d.ts +8 -0
  132. package/dist/interactiveInterrupt.js +54 -0
  133. package/dist/limitsWire.d.ts +5 -0
  134. package/dist/limitsWire.js +49 -3
  135. package/dist/liveModelCatalog.d.ts +95 -0
  136. package/dist/liveModelCatalog.js +297 -32
  137. package/dist/mcpEngineLeg.d.ts +25 -0
  138. package/dist/mcpEngineLeg.js +71 -15
  139. package/dist/mcpPanel.js +2 -1
  140. package/dist/mcpProbeCapability.d.ts +0 -1
  141. package/dist/mcpProbeCapability.js +2 -6
  142. package/dist/mcpReconnect.d.ts +1 -3
  143. package/dist/mcpReconnect.js +10 -5
  144. package/dist/memoryComplianceCapability.d.ts +0 -1
  145. package/dist/memoryComplianceCapability.js +2 -6
  146. package/dist/memoryOriginCapability.d.ts +0 -1
  147. package/dist/memoryOriginCapability.js +2 -6
  148. package/dist/memoryVerbsWire.d.ts +1 -1
  149. package/dist/memoryVerbsWire.js +4 -0
  150. package/dist/model/liveCatalogShape.d.ts +14 -0
  151. package/dist/model/liveCatalogShape.js +71 -0
  152. package/dist/model/modelSupplyRules.d.ts +1 -0
  153. package/dist/model/modelSupplyRules.js +30 -9
  154. package/dist/model/modelsPolicy.d.ts +21 -0
  155. package/dist/model/modelsPolicy.js +90 -0
  156. package/dist/modelIdentityResolvability.d.ts +1 -1
  157. package/dist/modelIdentityResolvability.js +5 -12
  158. package/dist/modelSwitchFallback.d.ts +69 -0
  159. package/dist/modelSwitchFallback.js +206 -0
  160. package/dist/notifications.js +12 -11
  161. package/dist/outputStyleSeatCapability.d.ts +0 -1
  162. package/dist/outputStyleSeatCapability.js +2 -7
  163. package/dist/ownKey.d.ts +6 -0
  164. package/dist/ownKey.js +48 -0
  165. package/dist/panelReduce.d.ts +114 -0
  166. package/dist/panelReduce.js +1135 -0
  167. package/dist/panelStateHolder.d.ts +17 -0
  168. package/dist/panelStateHolder.js +201 -0
  169. package/dist/peerLaneCapability.d.ts +0 -1
  170. package/dist/peerLaneCapability.js +2 -6
  171. package/dist/permissionModesCapability.d.ts +0 -1
  172. package/dist/permissionModesCapability.js +5 -10
  173. package/dist/permissionRulesWriteCapability.d.ts +0 -1
  174. package/dist/permissionRulesWriteCapability.js +2 -6
  175. package/dist/permissionsAllowGrantCapability.d.ts +0 -1
  176. package/dist/permissionsAllowGrantCapability.js +3 -9
  177. package/dist/permissionsDeclaration.d.ts +6 -0
  178. package/dist/permissionsDeclaration.js +45 -0
  179. package/dist/printToolResultFrame.js +2 -10
  180. package/dist/promptDelivery.js +0 -8
  181. package/dist/resumeRefusalCopy.d.ts +18 -1
  182. package/dist/resumeRefusalCopy.js +126 -15
  183. package/dist/rewindArchiveCapability.d.ts +2 -1
  184. package/dist/rewindArchiveCapability.js +15 -7
  185. package/dist/rewindEngineAction.d.ts +21 -0
  186. package/dist/rewindEngineAction.js +36 -0
  187. package/dist/rewindWireCaps.d.ts +2 -1
  188. package/dist/rewindWireCaps.js +1 -0
  189. package/dist/runTerminal.d.ts +0 -11
  190. package/dist/runTerminal.js +4 -27
  191. package/dist/sdkRegistryTransit.d.ts +2 -1
  192. package/dist/sdkRegistryTransit.js +1 -0
  193. package/dist/sealedKeyCapability.d.ts +0 -1
  194. package/dist/sealedKeyCapability.js +3 -9
  195. package/dist/seatContract.d.ts +54 -25
  196. package/dist/seatContract.js +394 -171
  197. package/dist/sessionIdSegment.d.ts +1 -0
  198. package/dist/sessionIdSegment.js +11 -0
  199. package/dist/sessionMemoryErase.d.ts +1 -1
  200. package/dist/sessionMemoryErase.js +6 -1
  201. package/dist/sessionMemoryStatus.js +3 -2
  202. package/dist/sessionPolicyCapability.d.ts +0 -1
  203. package/dist/sessionPolicyCapability.js +2 -6
  204. package/dist/sessionReadRedactionCapability.d.ts +0 -1
  205. package/dist/sessionReadRedactionCapability.js +2 -7
  206. package/dist/sessionSyncFileHistoryCapability.d.ts +0 -1
  207. package/dist/sessionSyncFileHistoryCapability.js +2 -6
  208. package/dist/skillToolListsCapability.d.ts +0 -1
  209. package/dist/skillToolListsCapability.js +2 -6
  210. package/dist/skillsWireCaps.d.ts +4 -0
  211. package/dist/skillsWireCaps.js +66 -1
  212. package/dist/sqlEngineCapability.d.ts +0 -1
  213. package/dist/sqlEngineCapability.js +9 -14
  214. package/dist/steerPriorityCapability.d.ts +0 -1
  215. package/dist/steerPriorityCapability.js +3 -9
  216. package/dist/storePostureCapability.d.ts +1 -1
  217. package/dist/storePostureCapability.js +16 -16
  218. package/dist/streamDrainingLegs.d.ts +6 -0
  219. package/dist/streamDrainingLegs.js +23 -0
  220. package/dist/subagent/engineCompactWire.js +13 -38
  221. package/dist/subagent/engineDelegatedPrompt.js +10 -6
  222. package/dist/subagent/engineSubagentOutput.d.ts +0 -1
  223. package/dist/subagent/engineSubagentOutput.js +5 -20
  224. package/dist/subagent/engineSubagentTail.d.ts +0 -1
  225. package/dist/subagent/engineSubagentTail.js +7 -32
  226. package/dist/subagentContentStore.js +3 -3
  227. package/dist/supportFloor.js +2 -5
  228. package/dist/terminalStatuses.d.ts +30 -0
  229. package/dist/terminalStatuses.js +67 -0
  230. package/dist/toolResult.d.ts +5 -0
  231. package/dist/toolResult.js +88 -36
  232. package/dist/types/engineState.d.ts +2 -1
  233. package/dist/usageAnalytics.d.ts +146 -0
  234. package/dist/usageAnalytics.js +311 -0
  235. package/dist/userInvokedSkillsCapability.d.ts +0 -1
  236. package/dist/userInvokedSkillsCapability.js +2 -6
  237. package/dist/webSearchBackendCapability.d.ts +0 -1
  238. package/dist/webSearchBackendCapability.js +3 -7
  239. package/dist/webSearchWireCaps.js +3 -11
  240. package/dist/wireFailureShape.d.ts +4 -0
  241. package/dist/wireFailureShape.js +42 -2
  242. package/dist/wireRefusalCopy.js +2 -18
  243. package/dist/workflowClient.js +7 -11
  244. package/dist/workflowsJournalCapability.d.ts +0 -1
  245. package/dist/workflowsJournalCapability.js +2 -6
  246. package/dist/writeProtectionCapability.d.ts +0 -1
  247. package/dist/writeProtectionCapability.js +5 -10
  248. package/docs/INTEGRATION-CLIENTS.md +1033 -26
  249. package/package.json +5 -5
  250. package/dist/engineCapsGenerationGuard.d.ts +0 -4
  251. package/dist/engineCapsGenerationGuard.js +0 -19
  252. package/dist/panelRunningHistory.d.ts +0 -22
  253. package/dist/panelRunningHistory.js +0 -82
  254. package/dist/registryConflict.d.ts +0 -3
  255. package/dist/registryConflict.js +0 -44
@@ -1,5 +1,5 @@
1
- import { snapshotCapsGeneration, capsGenerationStillCurrent } from './engineCapsGenerationGuard.js';
2
- import { capsGenerationMarkOf, retainCapsGenerationMark } from './engineCapsCache.js';
1
+ import { engineCapsLandingOf } from './engineCapsCache.js';
2
+ import { ownDataField } from './ownKey.js';
3
3
  function freezeReading(reading, seen = new Set()) {
4
4
  if (reading === null || typeof reading !== 'object' || seen.has(reading))
5
5
  return reading;
@@ -11,67 +11,54 @@ function freezeReading(reading, seen = new Set()) {
11
11
  }
12
12
  return reading;
13
13
  }
14
+ const PROJECTING = Symbol('projecting');
14
15
  export function createEngineCapReader(spec) {
15
- const cellByBase = new Map();
16
+ let memo = new WeakMap();
16
17
  return {
17
- note(baseUrl, caps, opts) {
18
+ note(_baseUrl, _caps, _opts) { },
19
+ observed(baseUrl) {
18
20
  if (typeof baseUrl !== 'string' || baseUrl === '')
19
- return;
20
- const gen = snapshotCapsGeneration(opts);
21
- if (gen === null)
22
- return;
23
- if (!capsGenerationStillCurrent(baseUrl, gen))
24
- return;
25
- const mark = retainCapsGenerationMark(baseUrl);
21
+ return spec.makeUnobserved();
22
+ const landing = engineCapsLandingOf(baseUrl);
23
+ if (landing === undefined)
24
+ return spec.makeUnobserved();
25
+ const hit = memo.get(landing);
26
+ if (hit === PROJECTING)
27
+ return spec.makeUnobserved();
28
+ if (hit !== undefined)
29
+ return hit.reading === undefined ? spec.makeUnobserved() : hit.reading;
30
+ const mine = memo;
31
+ mine.set(landing, PROJECTING);
26
32
  let reading;
27
33
  try {
28
- reading = spec.project(caps);
34
+ reading = spec.project(landing.caps);
29
35
  }
30
36
  catch {
31
37
  reading = undefined;
32
38
  }
33
- if (capsGenerationMarkOf(baseUrl) !== mark)
34
- return;
35
- if (reading === undefined) {
36
- cellByBase.delete(baseUrl);
37
- return;
38
- }
39
- cellByBase.set(baseUrl, { reading: freezeReading(reading), mark });
40
- },
41
- observed(baseUrl) {
42
- if (typeof baseUrl !== 'string' || baseUrl === '')
43
- return spec.makeUnobserved();
44
- const cell = cellByBase.get(baseUrl);
45
- if (cell === undefined)
46
- return spec.makeUnobserved();
47
- if (cell.mark !== capsGenerationMarkOf(baseUrl)) {
48
- cellByBase.delete(baseUrl);
39
+ if (engineCapsLandingOf(baseUrl) !== landing) {
40
+ mine.delete(landing);
49
41
  return spec.makeUnobserved();
50
42
  }
51
- return cell.reading;
52
- },
53
- forget(baseUrl) {
54
- if (typeof baseUrl !== 'string' || baseUrl === '')
55
- return;
56
- cellByBase.delete(baseUrl);
43
+ const done = { reading: reading === undefined ? undefined : freezeReading(reading) };
44
+ mine.set(landing, done);
45
+ return done.reading === undefined ? spec.makeUnobserved() : done.reading;
57
46
  },
58
47
  __resetForTests() {
59
- cellByBase.clear();
48
+ memo = new WeakMap();
60
49
  },
61
50
  };
62
51
  }
63
- export function capsGenerationOf(caps) {
52
+ export function storeSeatOf(caps) {
64
53
  try {
65
- if (!Object.hasOwn(caps, 'store'))
66
- return { generation: 'old', store: 'absent' };
67
- const store = caps.store;
54
+ const store = ownDataField(caps, 'store');
68
55
  if (store === undefined)
69
- return { generation: 'old', store: 'absent' };
56
+ return { kind: 'absent' };
70
57
  if (typeof store !== 'object' || store === null || Array.isArray(store))
71
- return { generation: 'old', store: 'malformed' };
72
- return { generation: 'new', store };
58
+ return { kind: 'malformed' };
59
+ return { kind: 'object', store };
73
60
  }
74
61
  catch {
75
- return { generation: 'old', store: 'malformed' };
62
+ return { kind: 'malformed' };
76
63
  }
77
64
  }
@@ -1,12 +1,17 @@
1
1
  export declare function engineCapsGeneration(baseUrl: string): number;
2
- export declare function capsGenerationMarkOf(baseUrl: string): object | undefined;
3
- export declare function retainCapsGenerationMark(baseUrl: string): object;
2
+ export declare function engineCapsLandingOf(baseUrl: string): {
3
+ readonly caps: object;
4
+ } | undefined;
4
5
  export declare function kickEngineCapsProbe(baseUrl: string, probe: () => Promise<unknown>): void;
5
6
  export declare function engineCapsSettled(baseUrl: string | undefined, opts?: {
6
7
  withinMs?: number;
7
8
  }): Promise<'settled' | 'timed_out'>;
8
9
  export type EngineCapState = 'true' | 'false' | 'unprobed' | 'absent' | 'non_boolean';
9
10
  export declare function engineCapState(baseUrl: string | undefined, key: string): EngineCapState;
11
+ export declare function engineCapStateVia(baseUrl: string | undefined, key: string, probe: (signal?: AbortSignal) => Promise<unknown>, opts?: {
12
+ withinMs?: number;
13
+ signal?: AbortSignal;
14
+ }): Promise<EngineCapState>;
10
15
  export declare function engineCapTrue(baseUrl: string | undefined, key: string): boolean;
11
16
  export declare function engineCapNestedTrue(baseUrl: string | undefined, parentKey: string, key: string): boolean;
12
17
  export type EngineCapValueState = {
@@ -3,21 +3,13 @@ const inFlight = new Set();
3
3
  const settleByBase = new Map();
4
4
  const genByBase = new Map();
5
5
  function capsGeneration(baseUrl) {
6
- return genByBase.get(baseUrl)?.n ?? 0;
6
+ return genByBase.get(baseUrl) ?? 0;
7
7
  }
8
8
  export function engineCapsGeneration(baseUrl) {
9
9
  return capsGeneration(baseUrl);
10
10
  }
11
- export function capsGenerationMarkOf(baseUrl) {
12
- return genByBase.get(baseUrl);
13
- }
14
- export function retainCapsGenerationMark(baseUrl) {
15
- let mark = genByBase.get(baseUrl);
16
- if (mark === undefined) {
17
- mark = Object.freeze({ n: 0 });
18
- genByBase.set(baseUrl, mark);
19
- }
20
- return mark;
11
+ export function engineCapsLandingOf(baseUrl) {
12
+ return capsByBase.get(baseUrl);
21
13
  }
22
14
  export function kickEngineCapsProbe(baseUrl, probe) {
23
15
  if (!baseUrl || capsByBase.has(baseUrl) || inFlight.has(baseUrl))
@@ -39,7 +31,7 @@ export function kickEngineCapsProbe(baseUrl, probe) {
39
31
  if (gen !== capsGeneration(baseUrl))
40
32
  return;
41
33
  if (caps && typeof caps === 'object') {
42
- capsByBase.set(baseUrl, caps);
34
+ capsByBase.set(baseUrl, Object.freeze({ caps: caps }));
43
35
  }
44
36
  }
45
37
  catch {
@@ -124,17 +116,63 @@ export async function engineCapsSettled(baseUrl, opts) {
124
116
  export function engineCapState(baseUrl, key) {
125
117
  if (!baseUrl)
126
118
  return 'unprobed';
127
- const caps = capsByBase.get(baseUrl);
128
- if (caps === undefined)
119
+ return capStateIn(capsByBase.get(baseUrl)?.caps, key);
120
+ }
121
+ function capStateIn(caps, key) {
122
+ if (caps === undefined || caps === null || typeof caps !== 'object')
129
123
  return 'unprobed';
130
- if (!(key in caps))
131
- return 'absent';
132
- const v = caps[key];
133
- if (v === true)
134
- return 'true';
135
- if (v === false)
136
- return 'false';
137
- return 'non_boolean';
124
+ try {
125
+ if (!(key in caps))
126
+ return 'absent';
127
+ const v = caps[key];
128
+ if (v === true)
129
+ return 'true';
130
+ if (v === false)
131
+ return 'false';
132
+ return 'non_boolean';
133
+ }
134
+ catch {
135
+ return 'unprobed';
136
+ }
137
+ }
138
+ async function untilSettledOrAborted(p, signal) {
139
+ if (signal === undefined) {
140
+ await p.catch(() => undefined);
141
+ return;
142
+ }
143
+ if (signal.aborted)
144
+ return;
145
+ let onAbort;
146
+ const aborted = new Promise((resolve) => {
147
+ onAbort = () => resolve();
148
+ signal.addEventListener('abort', onAbort, { once: true });
149
+ });
150
+ try {
151
+ await Promise.race([p.then(() => undefined, () => undefined), aborted]);
152
+ }
153
+ finally {
154
+ if (onAbort !== undefined)
155
+ signal.removeEventListener('abort', onAbort);
156
+ }
157
+ }
158
+ export async function engineCapStateVia(baseUrl, key, probe, opts) {
159
+ const signal = opts?.signal;
160
+ if (!baseUrl) {
161
+ try {
162
+ if (signal?.aborted)
163
+ return 'unprobed';
164
+ return capStateIn(await probe(signal), key);
165
+ }
166
+ catch {
167
+ return 'unprobed';
168
+ }
169
+ }
170
+ const now = engineCapState(baseUrl, key);
171
+ if (now !== 'unprobed')
172
+ return now;
173
+ kickEngineCapsProbe(baseUrl, () => probe());
174
+ await untilSettledOrAborted(engineCapsSettled(baseUrl, opts?.withinMs !== undefined ? { withinMs: opts.withinMs } : undefined), signal);
175
+ return engineCapState(baseUrl, key);
138
176
  }
139
177
  export function engineCapTrue(baseUrl, key) {
140
178
  return engineCapState(baseUrl, key) === 'true';
@@ -142,7 +180,7 @@ export function engineCapTrue(baseUrl, key) {
142
180
  export function engineCapNestedTrue(baseUrl, parentKey, key) {
143
181
  if (!baseUrl)
144
182
  return false;
145
- const parent = capsByBase.get(baseUrl)?.[parentKey];
183
+ const parent = capsByBase.get(baseUrl)?.caps[parentKey];
146
184
  if (parent === null || typeof parent !== 'object')
147
185
  return false;
148
186
  return parent[key] === true;
@@ -150,7 +188,7 @@ export function engineCapNestedTrue(baseUrl, parentKey, key) {
150
188
  export function engineCapValue(baseUrl, key) {
151
189
  if (!baseUrl)
152
190
  return { kind: 'unobserved' };
153
- const caps = capsByBase.get(baseUrl);
191
+ const caps = capsByBase.get(baseUrl)?.caps;
154
192
  if (caps === undefined)
155
193
  return { kind: 'unobserved' };
156
194
  if (!(key in caps))
@@ -165,7 +203,7 @@ export function engineCapValue(baseUrl, key) {
165
203
  export function engineCapString(baseUrl, key) {
166
204
  if (!baseUrl)
167
205
  return undefined;
168
- const v = capsByBase.get(baseUrl)?.[key];
206
+ const v = capsByBase.get(baseUrl)?.caps[key];
169
207
  return typeof v === 'string' && v.length > 0 ? v : undefined;
170
208
  }
171
209
  export function invalidateEngineCaps(baseUrl, probe) {
@@ -176,7 +214,7 @@ export function invalidateEngineCaps(baseUrl, probe) {
176
214
  settleByBase.has(baseUrl) ||
177
215
  genByBase.has(baseUrl);
178
216
  if (hadState) {
179
- genByBase.set(baseUrl, Object.freeze({ n: capsGeneration(baseUrl) + 1 }));
217
+ genByBase.set(baseUrl, capsGeneration(baseUrl) + 1);
180
218
  capsByBase.delete(baseUrl);
181
219
  inFlight.delete(baseUrl);
182
220
  settleByBase.get(baseUrl)?.wake();
@@ -0,0 +1,9 @@
1
+ export type EngineProbeAnswer = {
2
+ readonly ok: true;
3
+ } | {
4
+ readonly status: number;
5
+ } | {
6
+ readonly transport: true;
7
+ };
8
+ export type EngineCredentialNeed = 'open' | 'requires' | 'undetermined';
9
+ export declare function engineCredentialRequirementOf(answer: EngineProbeAnswer): EngineCredentialNeed;
@@ -0,0 +1,23 @@
1
+ export function engineCredentialRequirementOf(answer) {
2
+ try {
3
+ const a = answer;
4
+ if (typeof a !== 'object' || a === null || Array.isArray(a))
5
+ return 'undetermined';
6
+ const ok = Object.getOwnPropertyDescriptor(a, 'ok');
7
+ const status = Object.getOwnPropertyDescriptor(a, 'status');
8
+ const transport = Object.getOwnPropertyDescriptor(a, 'transport');
9
+ const arms = (ok !== undefined ? 1 : 0) + (status !== undefined ? 1 : 0) + (transport !== undefined ? 1 : 0);
10
+ if (arms !== 1)
11
+ return 'undetermined';
12
+ if (ok !== undefined)
13
+ return Object.hasOwn(ok, 'value') && ok.value === true ? 'open' : 'undetermined';
14
+ if (status !== undefined) {
15
+ const value = Object.hasOwn(status, 'value') ? status.value : undefined;
16
+ return value === 401 || value === 403 ? 'requires' : 'undetermined';
17
+ }
18
+ return 'undetermined';
19
+ }
20
+ catch {
21
+ return 'undetermined';
22
+ }
23
+ }
@@ -0,0 +1,53 @@
1
+ export interface EngineEnvView {
2
+ raw(key: string): string | undefined;
3
+ get(key: string): string | undefined;
4
+ }
5
+ export interface EngineEnvGroupDecl {
6
+ readonly id: string;
7
+ readonly safety: boolean;
8
+ readonly keys: readonly string[];
9
+ readonly dropKeys: readonly string[];
10
+ refuses(view: EngineEnvView): boolean;
11
+ readonly skippable?: boolean;
12
+ }
13
+ export interface EngineEnvSourcingInput {
14
+ readonly env: Readonly<Record<string, string | undefined>>;
15
+ readonly caseInsensitive: boolean;
16
+ readonly sources: ReadonlyArray<{
17
+ readonly source: string;
18
+ readonly keys: readonly string[];
19
+ }>;
20
+ ignored(key: string, source: string): boolean;
21
+ readonly aliases?: ReadonlyArray<readonly [from: string, to: string]>;
22
+ readonly groups: readonly EngineEnvGroupDecl[];
23
+ }
24
+ export interface EngineEnvTouchedKey {
25
+ readonly key: string;
26
+ readonly written: string;
27
+ readonly source: string;
28
+ }
29
+ export interface EngineEnvGroupReading {
30
+ readonly id: string;
31
+ readonly touched: readonly EngineEnvTouchedKey[];
32
+ readonly refuses: boolean;
33
+ readonly action: 'none' | 'skip' | 'refuse-explained';
34
+ readonly own: readonly string[];
35
+ }
36
+ export type EngineEnvKeyReason = {
37
+ readonly key: string;
38
+ readonly reason: 'repo-half-ignored';
39
+ readonly written: string;
40
+ readonly source: string;
41
+ readonly groups: readonly string[];
42
+ } | {
43
+ readonly key: string;
44
+ readonly reason: 'dropped-with-group';
45
+ readonly groups: readonly string[];
46
+ };
47
+ export interface EngineEnvSourcingVerdict {
48
+ readonly drop: readonly string[];
49
+ readonly groups: readonly EngineEnvGroupReading[];
50
+ readonly keys: readonly EngineEnvKeyReason[];
51
+ }
52
+ export declare function engineEnvView(env: Readonly<Record<string, string | undefined>>, caseInsensitive: boolean): EngineEnvView;
53
+ export declare function resolveEngineEnvSourcing(input: EngineEnvSourcingInput): EngineEnvSourcingVerdict;
@@ -0,0 +1,81 @@
1
+ export function engineEnvView(env, caseInsensitive) {
2
+ const raw = (key) => {
3
+ const direct = env[key];
4
+ if (direct !== undefined || !caseInsensitive)
5
+ return direct;
6
+ const upper = key.toUpperCase();
7
+ for (const [k, v] of Object.entries(env))
8
+ if (k.toUpperCase() === upper)
9
+ return v;
10
+ return undefined;
11
+ };
12
+ return { raw, get: (key) => { const v = raw(key); return v === undefined || v === '' ? undefined : v; } };
13
+ }
14
+ function safely(f) {
15
+ try {
16
+ return f() === true;
17
+ }
18
+ catch {
19
+ return false;
20
+ }
21
+ }
22
+ export function resolveEngineEnvSourcing(input) {
23
+ const view = engineEnvView(input.env, input.caseInsensitive === true);
24
+ const alias = new Map((input.aliases ?? []).map(([from, to]) => [from.toUpperCase(), to.toUpperCase()]));
25
+ const repo = new Map();
26
+ for (const { source, keys } of input.sources) {
27
+ for (const k of keys) {
28
+ if (!safely(() => input.ignored(k, source)))
29
+ continue;
30
+ const upper = k.toUpperCase();
31
+ repo.set(upper, { source, written: k });
32
+ const target = alias.get(upper);
33
+ if (target !== undefined && !repo.has(target))
34
+ repo.set(target, { source, written: k });
35
+ }
36
+ }
37
+ const drop = [];
38
+ const groups = [];
39
+ const halfRows = new Map();
40
+ const dropRows = new Map();
41
+ for (const g of input.groups) {
42
+ const touched = [];
43
+ for (const k of g.keys) {
44
+ const hit = repo.get(k);
45
+ if (hit !== undefined && view.get(k) === undefined)
46
+ touched.push({ key: k, written: hit.written, source: hit.source });
47
+ }
48
+ const refuses = touched.length > 0 && safely(() => g.refuses(view));
49
+ let action = 'none';
50
+ let own = [];
51
+ if (refuses) {
52
+ own = g.dropKeys.filter((k) => view.raw(k) !== undefined);
53
+ if (g.safety || g.skippable === false)
54
+ action = 'refuse-explained';
55
+ else {
56
+ action = 'skip';
57
+ drop.push(...g.dropKeys);
58
+ for (const k of g.dropKeys) {
59
+ const row = dropRows.get(k);
60
+ if (row === undefined)
61
+ dropRows.set(k, { key: k, groups: [g.id] });
62
+ else if (!row.groups.includes(g.id))
63
+ row.groups.push(g.id);
64
+ }
65
+ }
66
+ for (const t of touched) {
67
+ const row = halfRows.get(t.key);
68
+ if (row === undefined)
69
+ halfRows.set(t.key, { ...t, groups: [g.id] });
70
+ else if (!row.groups.includes(g.id))
71
+ row.groups.push(g.id);
72
+ }
73
+ }
74
+ groups.push({ id: g.id, touched, refuses, action, own });
75
+ }
76
+ const keys = [
77
+ ...[...halfRows.values()].map((r) => ({ key: r.key, reason: 'repo-half-ignored', written: r.written, source: r.source, groups: r.groups })),
78
+ ...[...dropRows.values()].map((r) => ({ key: r.key, reason: 'dropped-with-group', groups: r.groups })),
79
+ ];
80
+ return { drop, groups, keys };
81
+ }
@@ -56,7 +56,10 @@ export declare const RESUME_SESSION_NOT_FOUND = "resume.session_not_found";
56
56
  export declare const REQUEST_FIELD_CONFLICT = "request.field_conflict";
57
57
  export declare const REQUEST_AUTONOMY_LANE_REFUSED = "request.autonomy_lane_refused";
58
58
  export declare const CHECKPOINT_UNSUPPORTED_VERSION = "checkpoint.unsupported_version";
59
+ export declare const CHECKPOINT_WALLTIME_AXIS_RETIRED = "checkpoint.walltime_axis_retired";
60
+ export declare const CHECKPOINT_CONFIG_REFUSED = "checkpoint.config_refused";
59
61
  export declare function refusalSaysStillPending(err: object): boolean;
62
+ export declare function refusalRetriableReading(err: object): boolean | undefined;
60
63
  export type StatusDerivedCoarseCode = (typeof STATUS_DERIVED_COARSE_CODES)[number];
61
64
  export declare const RESUME_PLACEMENT_MISMATCH = "resume.placement_mismatch";
62
65
  export declare const RESUME_CONTEXT_UNAVAILABLE = "conflict.resume_context_unavailable";
@@ -76,13 +79,21 @@ export declare const DECIDE_GATE_MOVED = "decide.gate_moved";
76
79
  export declare const DECIDE_CLAIM_LOST = "decide.claim_lost";
77
80
  export declare const DECIDE_PARK_MOVED_CODES: readonly string[];
78
81
  export declare function isDecideParkMovedCode(code: string | null | undefined): boolean;
82
+ export declare const APPROVAL_STALE = "approval_stale";
83
+ export declare const APPROVAL_BINDING_MISMATCH = "approval_binding_mismatch";
84
+ export declare const RESUME_OUTCOME_INVALID = "resume_outcome_invalid";
85
+ export declare const CHECKPOINT_ALREADY_RESOLVED = "checkpoint.already_resolved";
86
+ export declare const NOT_FOUND_APPROVAL = "not_found.approval";
87
+ export declare const NOT_FOUND_CHECKPOINT = "not_found.checkpoint";
88
+ export declare const DECIDE_ALREADY_RESOLVED_CODES: readonly string[];
89
+ export declare function isDecideAlreadyResolvedCode(code: string | null | undefined): boolean;
79
90
  export declare const ASK_GONE = "gone.ask";
80
91
  export declare const ASK_GONE_DENIED_WORD: "routing_failure_fail_closed";
81
- export declare const RUN_STALLED = "run.stalled";
82
- export declare const RUN_ORPHANED = "run.orphaned";
83
- export declare const APPROVAL_EXPIRED = "approval.expired";
84
92
  export declare const RUN_DEATH_VERDICT_CODES: readonly ["run.stalled", "run.orphaned", "approval.expired"];
85
93
  export type RunDeathVerdictCode = (typeof RUN_DEATH_VERDICT_CODES)[number];
94
+ export declare const RUN_STALLED: "run.stalled";
95
+ export declare const RUN_ORPHANED: "run.orphaned";
96
+ export declare const APPROVAL_EXPIRED: "approval.expired";
86
97
  export declare function runDeathVerdictNoteOf(code: string | undefined): string | undefined;
87
98
  export declare const CAPABILITY_OPERATOR_PRINCIPALS_REQUIRED = "capability.operator_principals_required";
88
99
  export declare const COMPACT_NOT_RUNNING = "compact.not_running";
@@ -1,6 +1,6 @@
1
1
  import { frozenSet } from './frozenSet.js';
2
2
  import { CORE_TOOL_DECLARATION_CODES } from './generated/engineFactTables.js';
3
- import { SDK_DENY_REASON_ROUTING_FAILURE, SDK_STATUS_DERIVED_COARSE_CODES } from './generated/sdkFactTables.js';
3
+ import { SDK_DENY_REASON_ROUTING_FAILURE, SDK_RUN_DEATH_VERDICT_CODES, SDK_STATUS_DERIVED_COARSE_CODES } from './generated/sdkFactTables.js';
4
4
  export const LIMITS_MAX_TOKENS_EXCEEDED = 'limits.max_tokens_exceeded';
5
5
  export const LIMITS_MAX_COST_EXCEEDED = 'limits.max_cost_exceeded';
6
6
  export const LIMITS_MAX_TURNS_EXCEEDED = 'limits.max_turns_exceeded';
@@ -112,12 +112,17 @@ export const RESUME_SESSION_NOT_FOUND = 'resume.session_not_found';
112
112
  export const REQUEST_FIELD_CONFLICT = 'request.field_conflict';
113
113
  export const REQUEST_AUTONOMY_LANE_REFUSED = 'request.autonomy_lane_refused';
114
114
  export const CHECKPOINT_UNSUPPORTED_VERSION = 'checkpoint.unsupported_version';
115
+ export const CHECKPOINT_WALLTIME_AXIS_RETIRED = 'checkpoint.walltime_axis_retired';
116
+ export const CHECKPOINT_CONFIG_REFUSED = 'checkpoint.config_refused';
115
117
  export function refusalSaysStillPending(err) {
118
+ return refusalRetriableReading(err) === true;
119
+ }
120
+ export function refusalRetriableReading(err) {
116
121
  try {
117
122
  return Object.hasOwn(err, 'retriable') && err.retriable === true;
118
123
  }
119
124
  catch {
120
- return false;
125
+ return undefined;
121
126
  }
122
127
  }
123
128
  export const RESUME_PLACEMENT_MISMATCH = 'resume.placement_mismatch';
@@ -156,25 +161,41 @@ export const DECIDE_PARK_MOVED_CODES = Object.freeze([
156
161
  export function isDecideParkMovedCode(code) {
157
162
  return typeof code === 'string' && DECIDE_PARK_MOVED_CODES.includes(code);
158
163
  }
164
+ export const APPROVAL_STALE = 'approval_stale';
165
+ export const APPROVAL_BINDING_MISMATCH = 'approval_binding_mismatch';
166
+ export const RESUME_OUTCOME_INVALID = 'resume_outcome_invalid';
167
+ export const CHECKPOINT_ALREADY_RESOLVED = 'checkpoint.already_resolved';
168
+ export const NOT_FOUND_APPROVAL = 'not_found.approval';
169
+ export const NOT_FOUND_CHECKPOINT = 'not_found.checkpoint';
170
+ export const DECIDE_ALREADY_RESOLVED_CODES = Object.freeze([
171
+ APPROVAL_STALE,
172
+ CHECKPOINT_ALREADY_RESOLVED,
173
+ NOT_FOUND_APPROVAL,
174
+ NOT_FOUND_CHECKPOINT,
175
+ ]);
176
+ export function isDecideAlreadyResolvedCode(code) {
177
+ return typeof code === 'string' && DECIDE_ALREADY_RESOLVED_CODES.includes(code);
178
+ }
159
179
  export const ASK_GONE = 'gone.ask';
160
180
  export const ASK_GONE_DENIED_WORD = SDK_DENY_REASON_ROUTING_FAILURE;
181
+ export const RUN_DEATH_VERDICT_CODES = SDK_RUN_DEATH_VERDICT_CODES;
182
+ const _runDeathVerdictCodePin = true;
183
+ void _runDeathVerdictCodePin;
161
184
  export const RUN_STALLED = 'run.stalled';
162
185
  export const RUN_ORPHANED = 'run.orphaned';
163
186
  export const APPROVAL_EXPIRED = 'approval.expired';
164
- export const RUN_DEATH_VERDICT_CODES = Object.freeze([RUN_STALLED, RUN_ORPHANED, APPROVAL_EXPIRED]);
165
187
  const RUN_HOLDER_LOST_OUTLET = 'The request itself was not at fault, but this run cannot be picked up again; submit the work again as a new task.';
166
188
  const RUN_ORPHANED_NOTE = 'This run ended because the engine process that was running it went away (it was restarted) before the run finished. ' + RUN_HOLDER_LOST_OUTLET;
167
189
  const RUN_STALLED_NOTE = 'This run ended because the engine process that was running it stopped reporting in before the run finished. ' + RUN_HOLDER_LOST_OUTLET;
168
190
  const RUN_APPROVAL_EXPIRED_NOTE = 'This run ended because it was waiting on an approval for too long and the engine retired it. ' +
169
191
  'The request itself was not at fault, but this run cannot be picked up again; submit the work again as a new task, and it will ask for the approval again.';
192
+ const RUN_DEATH_VERDICT_NOTES = Object.freeze({
193
+ [RUN_STALLED]: RUN_STALLED_NOTE,
194
+ [RUN_ORPHANED]: RUN_ORPHANED_NOTE,
195
+ [APPROVAL_EXPIRED]: RUN_APPROVAL_EXPIRED_NOTE,
196
+ });
170
197
  export function runDeathVerdictNoteOf(code) {
171
- if (code === RUN_ORPHANED)
172
- return RUN_ORPHANED_NOTE;
173
- if (code === RUN_STALLED)
174
- return RUN_STALLED_NOTE;
175
- if (code === APPROVAL_EXPIRED)
176
- return RUN_APPROVAL_EXPIRED_NOTE;
177
- return undefined;
198
+ return typeof code === 'string' && Object.hasOwn(RUN_DEATH_VERDICT_NOTES, code) ? RUN_DEATH_VERDICT_NOTES[code] : undefined;
178
199
  }
179
200
  export const CAPABILITY_OPERATOR_PRINCIPALS_REQUIRED = 'capability.operator_principals_required';
180
201
  export const COMPACT_NOT_RUNNING = 'compact.not_running';
@@ -1,3 +1,5 @@
1
+ const _startedAtIsOneQuantity = [true, true, true, true];
2
+ void _startedAtIsOneQuantity;
1
3
  export const ENGINE_IDENTITY_ANCHORS = Object.freeze([
2
4
  'startedAt',
3
5
  'instanceId',
@@ -1,9 +1,9 @@
1
1
  import { AgentClient } from '@sema-agent/sdk';
2
+ import { SETTINGS_IS_LOOPBACK_AUTH_HOST } from './generated/settingsSchemaFns.js';
2
3
  import { normalizeWirePrincipal } from './principalWire.js';
3
4
  export function isLoopbackWireUrl(url) {
4
5
  try {
5
- const h = new URL(url).hostname;
6
- return h === '127.0.0.1' || h === 'localhost' || h === '::1' || h === '[::1]';
6
+ return SETTINGS_IS_LOOPBACK_AUTH_HOST(new URL(url).hostname);
7
7
  }
8
8
  catch {
9
9
  return false;
@@ -1,4 +1,4 @@
1
- export type ExecutionLaneIsolatedAbsence = 'no_hands' | 'not_reported' | 'unreadable';
1
+ export type ExecutionLaneIsolatedAbsence = 'no_hands' | 'unreadable';
2
2
  export interface ExecutionLaneCapabilityView {
3
3
  provider: string;
4
4
  toolsOnThisHost: boolean;
@@ -19,9 +19,8 @@ export declare function noteEngineCapsForExecutionLane(baseUrl: string, caps: un
19
19
  generation?: number;
20
20
  }): void;
21
21
  export declare function observedExecutionLane(baseUrl?: string | undefined): ExecutionLaneReading;
22
- export declare function toolsRunHereFromExecutionLane(reading: ExecutionLaneReading, legacyInference: boolean): boolean;
22
+ export declare function toolsRunHereFromExecutionLane(reading: ExecutionLaneReading): boolean;
23
23
  export declare function noOsSandboxOnThisHost(reading: ExecutionLaneReading): 'yes' | 'no' | 'unknown';
24
24
  export declare function noOsSandboxContent(): string;
25
25
  export declare function executionLaneDoctorDetail(reading: ExecutionLaneReading): string;
26
- export declare function forgetExecutionLaneReading(baseUrl: string | undefined): void;
27
26
  export declare function __resetExecutionLaneReadingsForTests(): void;