@sema-agent/client-core 0.92.0 → 0.93.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 (123) hide show
  1. package/CHANGELOG.md +179 -0
  2. package/README.md +23 -16
  3. package/dist/adapt/arms.js +2 -0
  4. package/dist/adapt/toolCards.js +6 -4
  5. package/dist/adapt.d.ts +1 -1
  6. package/dist/adapt.js +1 -1
  7. package/dist/adapter/runStream.js +3 -1
  8. package/dist/agentsWireCaps.js +1 -1
  9. package/dist/approvalDecidedByCapability.d.ts +16 -0
  10. package/dist/approvalDecidedByCapability.js +47 -0
  11. package/dist/approvalsStreamLiveCapability.js +3 -3
  12. package/dist/askSurvivesStandingAnswer.d.ts +1 -1
  13. package/dist/centerWiringCapability.js +1 -1
  14. package/dist/cloudConfigWireCaps.js +5 -5
  15. package/dist/compensations.js +2 -2
  16. package/dist/decideReceipt.d.ts +2 -0
  17. package/dist/decideReceipt.js +34 -9
  18. package/dist/detachWire.d.ts +2 -14
  19. package/dist/detachWire.js +1 -47
  20. package/dist/deviceExecutorManagementCapability.d.ts +6 -2
  21. package/dist/deviceExecutorManagementCapability.js +61 -15
  22. package/dist/engineConfigDrift.d.ts +20 -0
  23. package/dist/engineConfigDrift.js +54 -0
  24. package/dist/engineErrorCodes.d.ts +3 -0
  25. package/dist/engineErrorCodes.js +12 -4
  26. package/dist/engineInlineTaskStats.d.ts +1 -0
  27. package/dist/engineNoticeCodes.d.ts +2 -2
  28. package/dist/engineWireFor.d.ts +22 -0
  29. package/dist/engineWireFor.js +154 -9
  30. package/dist/engineWireSdk.d.ts +0 -1
  31. package/dist/engineWireSdk.js +0 -3
  32. package/dist/executionLaneCapability.js +2 -2
  33. package/dist/fileHistoryCaptureCapability.d.ts +1 -1
  34. package/dist/fileHistoryCaptureCapability.js +1 -6
  35. package/dist/fileHistoryLegNotice.d.ts +1 -1
  36. package/dist/fileHistoryLegNotice.js +1 -6
  37. package/dist/gateVocabulary.d.ts +1 -5
  38. package/dist/gateVocabulary.js +4 -22
  39. package/dist/generated/engineFactTables.d.ts +4 -3
  40. package/dist/generated/engineFactTables.js +10 -0
  41. package/dist/generated/engineNoticeTables.d.ts +1 -1
  42. package/dist/generated/engineNoticeTables.js +1 -1
  43. package/dist/goalStopHook.d.ts +1 -8
  44. package/dist/goalStopHook.js +2 -58
  45. package/dist/headlessPermissionModeWire.d.ts +3 -2
  46. package/dist/headlessPermissionModeWire.js +46 -5
  47. package/dist/hitl/askParkRowRouting.js +2 -2
  48. package/dist/hitl/frameRouter.js +7 -2
  49. package/dist/hitl/gateLedger.d.ts +1 -0
  50. package/dist/hitl/gateLedger.js +3 -0
  51. package/dist/hitl/hitlBridge.d.ts +1 -0
  52. package/dist/hitl/hitlBridge.js +6 -1
  53. package/dist/hitl/hitlHostSurface.d.ts +3 -2
  54. package/dist/hitl/hitlHostSurface.js +18 -3
  55. package/dist/hitl/parkResolver.js +22 -4
  56. package/dist/hitl/persistedRulesWire.js +29 -17
  57. package/dist/hitl/planReviewWire.d.ts +0 -2
  58. package/dist/hitl/planReviewWire.js +1 -18
  59. package/dist/hitl/sessionPolicyDeliverable.js +3 -3
  60. package/dist/hitl/sessionPolicyWire.d.ts +2 -0
  61. package/dist/hitl/sessionPolicyWire.js +7 -4
  62. package/dist/hitl/toolApprovalWire.d.ts +22 -7
  63. package/dist/hitl/toolApprovalWire.js +133 -54
  64. package/dist/hooksWireCaps.d.ts +1 -1
  65. package/dist/hooksWireCaps.js +1 -1
  66. package/dist/index.d.ts +7 -2
  67. package/dist/index.js +6 -2
  68. package/dist/inheritEnvWire.d.ts +1 -4
  69. package/dist/inheritEnvWire.js +0 -18
  70. package/dist/limitsWire.d.ts +0 -6
  71. package/dist/limitsWire.js +0 -38
  72. package/dist/mcpProbeCapability.js +1 -1
  73. package/dist/mcpProbeWire.js +10 -12
  74. package/dist/mcpReconnect.d.ts +5 -0
  75. package/dist/mcpReconnect.js +28 -0
  76. package/dist/memoryComplianceCapability.js +2 -2
  77. package/dist/memoryOriginCapability.js +2 -2
  78. package/dist/memoryVerbsWire.js +14 -13
  79. package/dist/ownKey.d.ts +2 -0
  80. package/dist/ownKey.js +15 -0
  81. package/dist/peerLaneCapability.js +2 -2
  82. package/dist/permissionModesCapability.d.ts +16 -0
  83. package/dist/permissionModesCapability.js +71 -0
  84. package/dist/permissionRuleIssue.js +1 -1
  85. package/dist/permissionRulesWriteCapability.js +2 -2
  86. package/dist/permissionWireCaps.d.ts +2 -0
  87. package/dist/permissionWireCaps.js +8 -1
  88. package/dist/permissionsAllowGrantCapability.js +7 -2
  89. package/dist/postureKnob.js +1 -1
  90. package/dist/protocolSegment.d.ts +2 -0
  91. package/dist/protocolSegment.js +3 -0
  92. package/dist/readFacePosture.js +1 -1
  93. package/dist/resumeRefusalCopy.d.ts +1 -0
  94. package/dist/resumeRefusalCopy.js +26 -3
  95. package/dist/retryStatus.js +2 -1
  96. package/dist/rewindArchiveCapability.js +2 -2
  97. package/dist/runTerminal.d.ts +16 -0
  98. package/dist/runTerminal.js +32 -3
  99. package/dist/seam.d.ts +1 -0
  100. package/dist/sessionPolicyCapability.js +1 -1
  101. package/dist/sessionSyncFileHistoryCapability.js +2 -2
  102. package/dist/skillToolListsCapability.js +1 -1
  103. package/dist/sqlEngineCapability.js +1 -1
  104. package/dist/steerPriorityCapability.js +1 -1
  105. package/dist/storePostureCapability.js +2 -2
  106. package/dist/supportFloor.d.ts +1 -0
  107. package/dist/supportFloor.js +13 -3
  108. package/dist/taskRequestWords.d.ts +4 -2
  109. package/dist/taskRequestWords.js +1 -1
  110. package/dist/toolHistoryBadTurn.js +1 -2
  111. package/dist/toolResult.d.ts +2 -1
  112. package/dist/toolResult.js +33 -3
  113. package/dist/userInvokedSkillsCapability.js +1 -1
  114. package/dist/webSearchBackendCapability.js +2 -2
  115. package/dist/webSearchWireCaps.d.ts +1 -1
  116. package/dist/webSearchWireCaps.js +40 -2
  117. package/dist/wireFailureShape.js +2 -2
  118. package/dist/wireRefusalCopy.d.ts +9 -3
  119. package/dist/wireRefusalCopy.js +41 -4
  120. package/dist/workflowsJournalCapability.js +1 -1
  121. package/dist/writeProtectionCapability.js +1 -1
  122. package/docs/INTEGRATION-CLIENTS.md +901 -15
  123. package/package.json +2 -2
@@ -0,0 +1,54 @@
1
+ function countOf(v) {
2
+ return typeof v === 'number' && Number.isInteger(v) && v >= 0 ? v : undefined;
3
+ }
4
+ function ownValue(o, key) {
5
+ const d = Object.getOwnPropertyDescriptor(o, key);
6
+ return d !== undefined && 'value' in d ? d.value : undefined;
7
+ }
8
+ export function readEngineConfigApplyState(health) {
9
+ try {
10
+ if (typeof health !== 'object' || health === null || Array.isArray(health))
11
+ return null;
12
+ const configTargetOrdinal = countOf(ownValue(health, 'configTargetOrdinal'));
13
+ const configAppliedOrdinal = countOf(ownValue(health, 'configAppliedOrdinal'));
14
+ if (configTargetOrdinal === undefined || configAppliedOrdinal === undefined)
15
+ return null;
16
+ const configTargetVersion = countOf(ownValue(health, 'configTargetVersion'));
17
+ const configAppliedVersion = countOf(ownValue(health, 'configAppliedVersion'));
18
+ const configApplyStaleMs = countOf(ownValue(health, 'configApplyStaleMs'));
19
+ return {
20
+ configTargetOrdinal,
21
+ configAppliedOrdinal,
22
+ ...(configTargetVersion !== undefined && configAppliedVersion !== undefined ? { configTargetVersion, configAppliedVersion } : {}),
23
+ ...(configApplyStaleMs !== undefined ? { configApplyStaleMs } : {}),
24
+ };
25
+ }
26
+ catch {
27
+ return null;
28
+ }
29
+ }
30
+ export function configDriftVerdict(input) {
31
+ try {
32
+ const { baselineConfigHash, baselineInstanceId, health } = input;
33
+ const view = typeof health === 'object' && health !== null ? health : undefined;
34
+ if (view !== undefined && ownValue(view, 'restartRequired') === true)
35
+ return 'ask';
36
+ const hashRaw = view === undefined ? undefined : ownValue(view, 'configHash');
37
+ const nowHash = typeof hashRaw === 'string' ? hashRaw : undefined;
38
+ if (!baselineConfigHash || !nowHash)
39
+ return 'skip';
40
+ if (nowHash === baselineConfigHash)
41
+ return 'in-sync';
42
+ const instanceRaw = view === undefined ? undefined : ownValue(view, 'instanceId');
43
+ const nowInstance = typeof instanceRaw === 'string' ? instanceRaw : undefined;
44
+ if (!baselineInstanceId || !nowInstance || nowInstance !== baselineInstanceId)
45
+ return 'ask';
46
+ const apply = readEngineConfigApplyState(view);
47
+ if (apply === null)
48
+ return 'ask';
49
+ return apply.configTargetOrdinal === apply.configAppliedOrdinal ? 'advance-baseline' : 'ask';
50
+ }
51
+ catch {
52
+ return 'ask';
53
+ }
54
+ }
@@ -65,6 +65,8 @@ export declare const RESUME_REOPEN_CODES: readonly string[];
65
65
  export declare const PARKED_RESUME_STARTUP_FAILED = "parked_resume.startup_failed";
66
66
  export declare const DECIDE_WORKFLOW_HOST_UNKNOWN = "decide.workflow_host_unknown";
67
67
  export declare const DECIDE_WORKFLOW_REMEMBER_UNSUPPORTED = "decide.workflow_remember_unsupported";
68
+ export declare const DECIDE_WORKFLOW_PARK_FORKED = "decide.workflow_park_forked";
69
+ export declare const DECIDE_WORKFLOW_PARKS_UNREADABLE = "decide.workflow_parks_unreadable";
68
70
  export declare const DECIDE_WORKFLOW_LANE_CODES: readonly string[];
69
71
  export declare const DECIDE_NOT_PARKED = "decide.not_parked";
70
72
  export declare const DECIDE_GATE_MOVED = "decide.gate_moved";
@@ -87,6 +89,7 @@ export declare const WORKFLOW_PARK_REFUSAL_CODES: readonly string[];
87
89
  export declare function isWorkflowParkRefusalCode(code: unknown): boolean;
88
90
  export declare const DRAINING_ERROR_CODE = "draining";
89
91
  export declare const SCENARIO_NOT_ALLOWED_ERROR_CODE = "scenario_not_allowed";
92
+ export declare const SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE = "state.scenario_assignment_unknown";
90
93
  export declare const STREAM_MAX_DURATION = "STREAM_MAX_DURATION";
91
94
  export type ModelFallbackReason = 'inherit_no_tier_binding';
92
95
  export declare const MODEL_FALLBACK_INHERIT_NO_TIER_BINDING: ModelFallbackReason;
@@ -141,9 +141,13 @@ export const RESUME_REOPEN_CODES = Object.freeze([
141
141
  export const PARKED_RESUME_STARTUP_FAILED = 'parked_resume.startup_failed';
142
142
  export const DECIDE_WORKFLOW_HOST_UNKNOWN = 'decide.workflow_host_unknown';
143
143
  export const DECIDE_WORKFLOW_REMEMBER_UNSUPPORTED = 'decide.workflow_remember_unsupported';
144
+ export const DECIDE_WORKFLOW_PARK_FORKED = 'decide.workflow_park_forked';
145
+ export const DECIDE_WORKFLOW_PARKS_UNREADABLE = 'decide.workflow_parks_unreadable';
144
146
  export const DECIDE_WORKFLOW_LANE_CODES = Object.freeze([
145
147
  DECIDE_WORKFLOW_HOST_UNKNOWN,
146
148
  DECIDE_WORKFLOW_REMEMBER_UNSUPPORTED,
149
+ DECIDE_WORKFLOW_PARKS_UNREADABLE,
150
+ DECIDE_WORKFLOW_PARK_FORKED,
147
151
  ]);
148
152
  export const DECIDE_NOT_PARKED = 'decide.not_parked';
149
153
  export const DECIDE_GATE_MOVED = 'decide.gate_moved';
@@ -162,13 +166,16 @@ export const RUN_STALLED = 'run.stalled';
162
166
  export const RUN_ORPHANED = 'run.orphaned';
163
167
  export const APPROVAL_EXPIRED = 'approval.expired';
164
168
  export const RUN_DEATH_VERDICT_CODES = Object.freeze([RUN_STALLED, RUN_ORPHANED, APPROVAL_EXPIRED]);
165
- const RUN_HOLDER_LOST_NOTE = 'This run ended because the engine process that was running it went away (it was restarted, or stopped answering) before the run finished. ' +
166
- 'The request itself was not at fault, but this run cannot be picked up again; submit the work again as a new task.';
169
+ 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.';
170
+ 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;
171
+ 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;
167
172
  const RUN_APPROVAL_EXPIRED_NOTE = 'This run ended because it was waiting on an approval for too long and the engine retired it. ' +
168
173
  '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.';
169
174
  export function runDeathVerdictNoteOf(code) {
170
- if (code === RUN_STALLED || code === RUN_ORPHANED)
171
- return RUN_HOLDER_LOST_NOTE;
175
+ if (code === RUN_ORPHANED)
176
+ return RUN_ORPHANED_NOTE;
177
+ if (code === RUN_STALLED)
178
+ return RUN_STALLED_NOTE;
172
179
  if (code === APPROVAL_EXPIRED)
173
180
  return RUN_APPROVAL_EXPIRED_NOTE;
174
181
  return undefined;
@@ -202,6 +209,7 @@ export function isWorkflowParkRefusalCode(code) {
202
209
  }
203
210
  export const DRAINING_ERROR_CODE = 'draining';
204
211
  export const SCENARIO_NOT_ALLOWED_ERROR_CODE = 'scenario_not_allowed';
212
+ export const SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE = 'state.scenario_assignment_unknown';
205
213
  export const STREAM_MAX_DURATION = 'STREAM_MAX_DURATION';
206
214
  export const MODEL_FALLBACK_INHERIT_NO_TIER_BINDING = 'inherit_no_tier_binding';
207
215
  export function asModelFallbackReason(v) {
@@ -4,6 +4,7 @@ export interface EngineInlineTaskStats {
4
4
  totalTokens: number;
5
5
  durationMs: number;
6
6
  currentAction?: string;
7
+ model?: string;
7
8
  done: boolean;
8
9
  isError: boolean;
9
10
  }
@@ -1,4 +1,4 @@
1
- import { CORE_TOOL_TURN_INCOMPLETE_CAUSES, CORE_USER_STEER_UNDRAINED_CAUSES } from './generated/engineNoticeTables.js';
1
+ import { CORE_TOOL_TURN_INCOMPLETE_CAUSES, CORE_USER_INPUT_UNDRAINED_CAUSES } from './generated/engineNoticeTables.js';
2
2
  export type NoticeAudience = 'user' | 'operator';
3
3
  export declare const ENGINE_NOTICE_CODES: readonly string[];
4
4
  export declare function engineNoticeInCatalog(code: unknown): boolean;
@@ -157,7 +157,7 @@ export interface ToolTurnIncompleteFactsView {
157
157
  runId: string;
158
158
  }
159
159
  export declare function readToolTurnIncomplete(notice: unknown): ToolTurnIncompleteFactsView | undefined;
160
- export type UserSteerUndrainedCause = (typeof CORE_USER_STEER_UNDRAINED_CAUSES)[number];
160
+ export type UserSteerUndrainedCause = (typeof CORE_USER_INPUT_UNDRAINED_CAUSES)[number];
161
161
  export interface UserInputUndrainedFactsView {
162
162
  kind: 'steer' | 'followUp';
163
163
  count: number;
@@ -41,4 +41,26 @@ export declare function noAnswerKindOf(e: object | null | undefined): EngineWire
41
41
  export declare function noAnswerDetailFrom(e: object | null | undefined): string | null;
42
42
  export declare function sendOnce<T>(signal: AbortSignal | null | undefined, run: () => Promise<T>): Promise<T>;
43
43
  export declare function provablyNotSent(e: object | null | undefined): boolean;
44
+ export interface TransportFailureSocket {
45
+ readonly localPort?: number;
46
+ readonly remotePort?: number;
47
+ readonly bytesWritten?: number;
48
+ readonly bytesRead?: number;
49
+ }
50
+ export interface TransportFailureLayer {
51
+ readonly name?: string;
52
+ readonly code?: string;
53
+ readonly errno?: number;
54
+ readonly syscall?: string;
55
+ readonly socket?: TransportFailureSocket;
56
+ }
57
+ export type TransportFailureChainEnd = 'complete' | 'depth_cap' | 'cycle' | 'unreadable';
58
+ export interface TransportFailureScene {
59
+ readonly layers: ReadonlyArray<TransportFailureLayer>;
60
+ readonly end: TransportFailureChainEnd;
61
+ readonly status?: number;
62
+ readonly provablyNotSent: boolean;
63
+ readonly noAnswer: EngineWireNoAnswerKind | null;
64
+ }
65
+ export declare function transportFailureScene(error: unknown): TransportFailureScene;
44
66
  export declare function settleInjected<T>(ms: number, signal: AbortSignal | null | undefined, run: (signal: AbortSignal) => Promise<T>): Promise<T>;
@@ -206,19 +206,33 @@ function allAttemptsFailedBeforeSend(errors) {
206
206
  return false;
207
207
  return errors.every((x) => x !== null && typeof x === 'object' && isPreSendCode(x.code, x.syscall));
208
208
  }
209
- function failedBeforeSend(e) {
209
+ const CAUSE_CHAIN_MAX_LAYERS = 4;
210
+ function walkCauseChain(e, visit) {
210
211
  let cur = e;
211
- for (let depth = 0; depth < 4 && cur !== null && typeof cur === 'object'; depth++) {
212
- const o = cur;
213
- if (isPreSendCode(o.code, o.syscall))
214
- return true;
215
- if (allAttemptsFailedBeforeSend(o.errors))
216
- return true;
212
+ for (let depth = 0; depth < CAUSE_CHAIN_MAX_LAYERS && cur !== null && typeof cur === 'object'; depth++) {
213
+ if (visit(cur, depth) === 'stop')
214
+ return { stopped: true };
217
215
  cur = cur.cause;
218
216
  }
219
- return false;
217
+ return { stopped: false, end: cur !== null && typeof cur === 'object' ? 'depth_cap' : 'complete' };
218
+ }
219
+ function readLayerEvidence(layer) {
220
+ const o = layer;
221
+ const code = o.code;
222
+ const syscall = o.syscall;
223
+ if (isPreSendCode(code, syscall))
224
+ return { proof: 'code', code, syscall };
225
+ if (allAttemptsFailedBeforeSend(o.errors))
226
+ return { proof: 'attempts', code, syscall };
227
+ return { proof: null, code, syscall };
228
+ }
229
+ function failedBeforeSend(e) {
230
+ return walkCauseChain(e, (layer) => (readLayerEvidence(layer).proof !== null ? 'stop' : undefined)).stopped;
220
231
  }
221
232
  export function noAnswerKindOf(e) {
233
+ return noAnswerKindWith(e, () => failedBeforeSend(e));
234
+ }
235
+ function noAnswerKindWith(e, chainProof) {
222
236
  try {
223
237
  if (e === null || typeof e !== 'object')
224
238
  return null;
@@ -231,7 +245,7 @@ export function noAnswerKindOf(e) {
231
245
  const name = e.name;
232
246
  if (name === 'TimeoutError')
233
247
  return 'time-limit';
234
- if ((e instanceof TypeError || name === 'TypeError') && !failedBeforeSend(e))
248
+ if ((e instanceof TypeError || name === 'TypeError') && !chainProof())
235
249
  return 'connection-lost';
236
250
  return null;
237
251
  }
@@ -339,6 +353,137 @@ export function provablyNotSent(e) {
339
353
  return false;
340
354
  }
341
355
  }
356
+ const TRANSPORT_BIT_STRING = /^[A-Za-z0-9_.:-]{1,64}$/;
357
+ function bitString(v) {
358
+ return typeof v === 'string' && TRANSPORT_BIT_STRING.test(v) ? v : undefined;
359
+ }
360
+ function bitNumber(v) {
361
+ return typeof v === 'number' && Number.isFinite(v) ? v : undefined;
362
+ }
363
+ function layerBitsOf(layer, onUnreadable, known) {
364
+ const read = (target, key) => {
365
+ try {
366
+ return target[key];
367
+ }
368
+ catch {
369
+ onUnreadable();
370
+ return undefined;
371
+ }
372
+ };
373
+ const name = bitString(read(layer, 'name'));
374
+ const code = bitString(known !== undefined ? known.code : read(layer, 'code'));
375
+ const errno = bitNumber(read(layer, 'errno'));
376
+ const syscall = bitString(known !== undefined ? known.syscall : read(layer, 'syscall'));
377
+ const sock = read(layer, 'socket');
378
+ let socket;
379
+ if (sock !== null && typeof sock === 'object') {
380
+ const localPort = bitNumber(read(sock, 'localPort'));
381
+ const remotePort = bitNumber(read(sock, 'remotePort'));
382
+ const bytesWritten = bitNumber(read(sock, 'bytesWritten'));
383
+ const bytesRead = bitNumber(read(sock, 'bytesRead'));
384
+ const counters = {
385
+ ...(localPort !== undefined ? { localPort } : {}),
386
+ ...(remotePort !== undefined ? { remotePort } : {}),
387
+ ...(bytesWritten !== undefined ? { bytesWritten } : {}),
388
+ ...(bytesRead !== undefined ? { bytesRead } : {}),
389
+ };
390
+ if (Object.keys(counters).length > 0)
391
+ socket = Object.freeze(counters);
392
+ }
393
+ return Object.freeze({
394
+ ...(name !== undefined ? { name } : {}),
395
+ ...(code !== undefined ? { code } : {}),
396
+ ...(errno !== undefined ? { errno } : {}),
397
+ ...(syscall !== undefined ? { syscall } : {}),
398
+ ...(socket !== undefined ? { socket } : {}),
399
+ });
400
+ }
401
+ export function transportFailureScene(error) {
402
+ const layers = [];
403
+ const seen = [];
404
+ let unreadable = false;
405
+ const markUnreadable = () => {
406
+ unreadable = true;
407
+ };
408
+ let cycleSeen = false;
409
+ let marked = false;
410
+ let blocked = false;
411
+ let proven = false;
412
+ let aborted = false;
413
+ let end = 'complete';
414
+ let walked = false;
415
+ const walk = () => {
416
+ if (walked)
417
+ return;
418
+ walked = true;
419
+ try {
420
+ const result = walkCauseChain(error, (layer) => {
421
+ const revisit = seen.includes(layer);
422
+ if (revisit)
423
+ cycleSeen = true;
424
+ else
425
+ seen.push(layer);
426
+ let known;
427
+ if (!proven) {
428
+ try {
429
+ const evidence = readLayerEvidence(layer);
430
+ known = { code: evidence.code, syscall: evidence.syscall };
431
+ if (evidence.proof !== null)
432
+ proven = true;
433
+ }
434
+ catch {
435
+ unreadable = true;
436
+ aborted = true;
437
+ if (!revisit)
438
+ layers.push(layerBitsOf(layer, markUnreadable, undefined));
439
+ return 'stop';
440
+ }
441
+ }
442
+ if (!revisit)
443
+ layers.push(layerBitsOf(layer, markUnreadable, known));
444
+ return undefined;
445
+ });
446
+ if (!result.stopped)
447
+ end = result.end;
448
+ }
449
+ catch {
450
+ unreadable = true;
451
+ aborted = true;
452
+ }
453
+ };
454
+ const failedBefore = () => {
455
+ walk();
456
+ if (aborted && !proven)
457
+ throw new Error('cause chain unreadable');
458
+ return proven;
459
+ };
460
+ let status;
461
+ let noAnswer = null;
462
+ if (error !== null && typeof error === 'object') {
463
+ try {
464
+ marked = markedNotSent(error);
465
+ }
466
+ catch {
467
+ blocked = true;
468
+ unreadable = true;
469
+ }
470
+ noAnswer = noAnswerKindWith(error, failedBefore);
471
+ walk();
472
+ try {
473
+ status = bitNumber(error.status);
474
+ }
475
+ catch {
476
+ unreadable = true;
477
+ }
478
+ }
479
+ return Object.freeze({
480
+ layers: Object.freeze(layers),
481
+ end: unreadable ? 'unreadable' : cycleSeen ? 'cycle' : end,
482
+ ...(status !== undefined ? { status } : {}),
483
+ provablyNotSent: !blocked && (marked || proven),
484
+ noAnswer,
485
+ });
486
+ }
342
487
  export function settleInjected(ms, signal, run) {
343
488
  const settled = settleInjectedOnce(ms, signal, run);
344
489
  Object.defineProperty(settled, SETTLED_BY_PACKAGE_BRAND, { value: true, enumerable: false });
@@ -5,7 +5,6 @@ export type WireAuthToken = string | {
5
5
  export type WireAuthTokenSource = string | (() => string | undefined);
6
6
  export declare function isLoopbackWireUrl(url: string): boolean;
7
7
  export declare function resolveWireAuth(baseUrl: string | undefined, token?: string): WireAuthToken;
8
- export declare function wireAuthTokenFor(baseUrl: string, token?: string): WireAuthToken;
9
8
  export type EngineProbeClient = Pick<AgentClient, 'capabilities' | 'scenarioCapabilities'>;
10
9
  export interface EngineWireInjection<C> {
11
10
  client: C;
@@ -16,9 +16,6 @@ export function resolveWireAuth(baseUrl, token) {
16
16
  return { mode: 'loopback-unauthed' };
17
17
  return 'anon';
18
18
  }
19
- export function wireAuthTokenFor(baseUrl, token) {
20
- return resolveWireAuth(baseUrl, token);
21
- }
22
19
  function headersToRecord(init) {
23
20
  const out = {};
24
21
  if (init === undefined)
@@ -97,9 +97,9 @@ export function executionLaneDoctorDetail(reading) {
97
97
  switch (reading.kind) {
98
98
  case 'unobserved':
99
99
  return ('execution lane not observed — the engine reports it on /v1/capabilities; ' +
100
- 'this process has no usable capabilities reading cached for it (none received, or the last one was unreadable)');
100
+ 'this process has no usable capabilities reading cached for it (none received, the last one was unreadable, or the last one was discarded when the engine connection was reset; this process cannot tell which)');
101
101
  case 'not_reported':
102
- return ('execution lane not reported by this engine — only newer engines advertise it; ' +
102
+ return ('execution lane not reported by this engine; ' +
103
103
  'this does not say where tools run, so the client keeps inferring it the way it did before');
104
104
  case 'present': {
105
105
  const lane = capForDisplay(reading.view.provider, LANE_DETAIL_MAX);
@@ -6,7 +6,7 @@ export type FileHistoryCaptureReading = {
6
6
  kind: 'present';
7
7
  word: string;
8
8
  };
9
- export type FileHistoryCaptureMode = 'off' | 'on-always' | 'on-optional' | 'unknown';
9
+ export type FileHistoryCaptureMode = 'off' | 'on-optional' | 'unknown';
10
10
  export declare function projectFileHistoryCaptureCapability(caps: unknown): FileHistoryCaptureReading | undefined;
11
11
  export declare function noteEngineCapsForFileHistoryCapture(baseUrl: string, caps: unknown, opts?: {
12
12
  generation?: number;
@@ -43,8 +43,6 @@ export function fileHistoryCaptureMode(reading) {
43
43
  return 'off';
44
44
  if (word === 'on-optional')
45
45
  return 'on-optional';
46
- if (word === 'on-always')
47
- return 'on-always';
48
46
  return 'unknown';
49
47
  }
50
48
  export function fileHistoryDeclarationField(reading, captureOff) {
@@ -66,7 +64,7 @@ export function fileHistoryCaptureDoctorDetail(reading) {
66
64
  }
67
65
  switch (kind) {
68
66
  case 'not_reported':
69
- return 'file history capture not reported by this engine — only newer engines advertise it; this does not say whether file history is captured here';
67
+ return 'file history capture not reported by this engine; this does not say whether file history is captured here';
70
68
  case 'present':
71
69
  if (typeof word !== 'string' || word.length === 0)
72
70
  return unobserved;
@@ -76,9 +74,6 @@ export function fileHistoryCaptureDoctorDetail(reading) {
76
74
  if (word === 'on-optional') {
77
75
  return 'file history capture on — the engine snapshots files before changing them, and a session on this deployment can opt out of capture for its own runs';
78
76
  }
79
- if (word === 'on-always') {
80
- return 'file history capture always on — the engine snapshots files before changing them in every session, and it cannot be turned off for a single session here';
81
- }
82
77
  return `file history capture reported as "${capForDisplay(word, WORD_DETAIL_MAX)}" — a mode this client does not know yet, so whether it captures is shown as unknown`;
83
78
  default:
84
79
  return unobserved;
@@ -1,7 +1,7 @@
1
1
  import type { AgentEvent } from '@sema-agent/sdk';
2
2
  import { type FileHistoryCaptureReading } from './fileHistoryCaptureCapability.js';
3
3
  export type FileHistoryDeclarationFact = 'sent' | 'not_sent' | 'unknown';
4
- export declare const FILE_HISTORY_LEG_VERDICTS: readonly ["not_honored", "not_offered", "honored", "not_declared", "unknown"];
4
+ export declare const FILE_HISTORY_LEG_VERDICTS: readonly ["not_honored", "honored", "not_declared", "unknown"];
5
5
  export type FileHistoryLegNoticeVerdict = (typeof FILE_HISTORY_LEG_VERDICTS)[number];
6
6
  export interface FileHistoryLegNoticeInput {
7
7
  readonly capability: FileHistoryCaptureReading;
@@ -1,7 +1,7 @@
1
1
  import { fileHistoryCaptureMode } from './fileHistoryCaptureCapability.js';
2
2
  import { frameProvesDelivery } from './promptDelivery.js';
3
3
  import { FILE_HISTORY_DISABLED } from './request/taskRequest.js';
4
- export const FILE_HISTORY_LEG_VERDICTS = Object.freeze(['not_honored', 'not_offered', 'honored', 'not_declared', 'unknown']);
4
+ export const FILE_HISTORY_LEG_VERDICTS = Object.freeze(['not_honored', 'honored', 'not_declared', 'unknown']);
5
5
  function ownRead(o, key) {
6
6
  return Object.hasOwn(o, key) ? o[key] : undefined;
7
7
  }
@@ -31,19 +31,14 @@ export function fileHistoryLegNoticeVerdict(input) {
31
31
  if (!offByUser)
32
32
  return 'not_declared';
33
33
  const mode = fileHistoryCaptureMode(capability);
34
- if (legWord === 'on' && mode === 'on-always')
35
- return 'not_offered';
36
34
  if (declaration === 'not_sent' && (legWord === FILE_HISTORY_DISABLED || mode === 'on-optional'))
37
35
  return 'not_declared';
38
36
  return 'unknown';
39
37
  }
40
38
  const NOT_HONORED_SENTENCE = 'The engine is still capturing file history for this session, though your settings asked it not to.';
41
- const NOT_OFFERED_SENTENCE = 'This engine always captures file history and cannot turn it off per session, even though file checkpoints are off in your settings.';
42
39
  export function fileHistoryLegNoticeSentence(verdict) {
43
40
  if (verdict === 'not_honored')
44
41
  return NOT_HONORED_SENTENCE;
45
- if (verdict === 'not_offered')
46
- return NOT_OFFERED_SENTENCE;
47
42
  return null;
48
43
  }
49
44
  export function fileHistoryDeclarationOfBody(body) {
@@ -9,11 +9,7 @@ export type GateDeniedByWord = (typeof CORE_DENIED_BY_VALUES)[number];
9
9
  export declare const GATE_DENIED_BY_WORDS: readonly GateDeniedByWord[];
10
10
  export declare function isGateDeniedByWord(v: unknown): v is GateDeniedByWord;
11
11
  export declare function gateDeniedByDetail(deniedBy: unknown): string;
12
- export declare function askOriginDetail(origin: unknown, _message?: unknown): string;
13
- export declare const RULE_STORE_UNREADABLE_KINDS: readonly ["store", "call"];
14
- export type RuleStoreUnreadableKind = (typeof RULE_STORE_UNREADABLE_KINDS)[number];
15
- export declare function isRuleStoreUnreadableKind(v: unknown): v is RuleStoreUnreadableKind;
16
- export declare function ruleStoreUnreadableDetail(kind: RuleStoreUnreadableKind): string;
12
+ export declare function askOriginDetail(origin: unknown): string;
17
13
  export declare function mandatedApprovalDetail(): string;
18
14
  export type ApprovalMandateWord = (typeof APPROVAL_MANDATE_WORDS)[number];
19
15
  export declare function isApprovalMandateWord(v: unknown): v is ApprovalMandateWord;
@@ -48,7 +48,7 @@ export function gateDeniedByDetail(deniedBy) {
48
48
  }
49
49
  const ASK_ORIGIN_SENTENCES = Object.freeze({
50
50
  content_question: 'the tool itself asked you a question',
51
- ancestor_marked: 'an ancestor marked this call (an inherited approver-unavailable float, or a durable mandate): it must reach the park with no synchronous decision-maker in between',
51
+ ancestor_marked: 'an ancestor marked this call (an inherited approver-unavailable float, or a durable mandate; this client cannot tell which from the origin alone): it must reach the park with no synchronous decision-maker in between',
52
52
  org_unavailable: 'the organization policy was unavailable, so this call asks',
53
53
  org_rule: 'an organization rule asks about this call',
54
54
  rule_store_unavailable: 'this call could not be checked against your standing deny/ask rules, so it asks',
@@ -56,10 +56,10 @@ const ASK_ORIGIN_SENTENCES = Object.freeze({
56
56
  ask_rule: 'a persisted ask rule matches this call',
57
57
  denial_limit_fallback: 'the auto-mode classifier hit its denial limit and handed this call back to you',
58
58
  shell_gate_tighten: 'the coarse shell check rates this command above the tier it lets through, so it asks',
59
- safety_tighten: 'the gate tightened on this call’s own facts (network egress, irreversibility, or a protected write)',
59
+ safety_tighten: 'the gate tightened on this call’s own facts (network egress, irreversibility, or a protected write; this client cannot tell which from the origin alone)',
60
60
  policy: 'this deployment’s permission policy asks about this call',
61
61
  });
62
- export function askOriginDetail(origin, _message) {
62
+ export function askOriginDetail(origin) {
63
63
  const known = typeof origin === 'string' && Object.hasOwn(ASK_ORIGIN_SENTENCES, origin)
64
64
  ? ASK_ORIGIN_SENTENCES[origin]
65
65
  : undefined;
@@ -68,24 +68,6 @@ export function askOriginDetail(origin, _message) {
68
68
  const word = typeof origin === 'string' && origin.length > 0 ? origin : '(none)';
69
69
  return `this call asks; its origin ${word} is a word newer than this client, so answer it as usual`;
70
70
  }
71
- export const RULE_STORE_UNREADABLE_KINDS = Object.freeze(['store', 'call']);
72
- const RULE_STORE_UNREADABLE_SET = new Set(RULE_STORE_UNREADABLE_KINDS);
73
- export function isRuleStoreUnreadableKind(v) {
74
- return typeof v === 'string' && RULE_STORE_UNREADABLE_SET.has(v);
75
- }
76
- const RULE_STORE_UNREADABLE_SENTENCES = Object.freeze({
77
- store: 'your standing deny/ask rules could not be read at all (the rule store did not answer), so this call asks',
78
- call: 'this command could not be read against your standing deny/ask rules (the engine’s own sentence is on this ask), so it asks',
79
- });
80
- export function ruleStoreUnreadableDetail(kind) {
81
- const known = Object.hasOwn(RULE_STORE_UNREADABLE_SENTENCES, kind)
82
- ? RULE_STORE_UNREADABLE_SENTENCES[kind]
83
- : undefined;
84
- if (typeof known === 'string')
85
- return known;
86
- const word = typeof kind === 'string' && kind.length > 0 ? kind : '(none)';
87
- return `your standing deny/ask rules could not be applied to this call; the reported reason ${word} is not one of the mechanisms this client's closed set knows, so answer this ask as usual`;
88
- }
89
71
  export function mandatedApprovalDetail() {
90
72
  return 'no saved allow rule and no remembered answer can retire this question; each call is settled on its own — by you here, by a hook, or by an automatic check the deployment runs — and an answer covers only that call';
91
73
  }
@@ -98,7 +80,7 @@ const APPROVAL_MANDATE_SENTENCES = Object.freeze({
98
80
  operator_always: 'this deployment requires a separate confirmation for each shell command, and this call is one of them',
99
81
  tool_marks: 'this tool declares that it reaches outside this machine or makes changes that cannot be undone',
100
82
  probe_mandate: 'the check run on this call marked it as needing its own confirmation (the built-in shell check does so for a read outside the directories allowed for this session)',
101
- probe_unanswered: 'the check run on this call did not answer (it timed out or failed), so whether the call stays inside the directories allowed for this session is unknown',
83
+ probe_unanswered: 'the check run on this call did not answer (it timed out or failed; this client cannot tell which), so whether the call stays inside the directories allowed for this session is unknown',
102
84
  write_protection: "this change lands on a protected location (the agent's own configuration), which is confirmed one change at a time",
103
85
  write_protection_unresolved: 'the protected-location check could not tell where this change lands, so whether it touches a protected location is unknown',
104
86
  });
@@ -21,11 +21,11 @@ export interface CoreModeArbitrationRow {
21
21
  readonly ruleMayClear: boolean;
22
22
  readonly hookAskFloor: boolean;
23
23
  }
24
- export declare const CORE_MODE_ARBITRATION: Readonly<Record<"content_question" | "hook" | "ancestor" | "unverifiable_delete" | "transcript_write" | "org_rule" | "governance_unavailable" | "rule_unreadable" | "ask_rule" | "denial_limit_fallback" | "requires_user_interaction" | "operator_forced" | "shell_floor" | "write_protection_unresolved" | "probe" | "write_protection" | "tool_marks_mcp" | "tool_marks_a2a" | "policy_rra" | "artifact_shared_read" | "mode" | "unstated" | "ordinary", CoreModeArbitrationRow>>;
24
+ export declare const CORE_MODE_ARBITRATION: Readonly<Record<"content_question" | "hook" | "ancestor" | "unverifiable_delete" | "transcript_write" | "org_rule" | "governance_unavailable" | "rule_unreadable" | "ask_rule" | "denial_limit_fallback" | "classifier_no_ruling" | "requires_user_interaction" | "operator_forced" | "shell_floor" | "write_protection_unresolved" | "probe" | "write_protection" | "tool_marks_mcp" | "tool_marks_a2a" | "policy_rra" | "artifact_shared_read" | "mode" | "unstated" | "ordinary", CoreModeArbitrationRow>>;
25
25
  export declare const CORE_SKILL_GRANT_ORIGINS: readonly ["model", "user", "inherited"];
26
- export declare const CORE_ALLOW_ENTRY_INERT_REASONS: readonly ["wildcard_all", "namespace_wildcard", "path_pattern", "domain", "content_unsupported", "grammar"];
26
+ export declare const CORE_ALLOW_ENTRY_INERT_REASONS: readonly ["wildcard_all", "namespace_wildcard", "path_pattern", "domain", "content_unsupported", "grammar", "tool_name", "near_miss"];
27
27
  export declare const CORE_ALLOW_RULE_MEMBERS: readonly ["hook", "deployment", "persisted", "skill", "request"];
28
- export declare const CORE_RULE_TOOL_NAME_VERDICTS: readonly ["current", "retired", "unprefixed_namespace"];
28
+ export declare const CORE_RULE_TOOL_NAME_VERDICTS: readonly ["current", "retired", "unprefixed_namespace", "unmintable_segment"];
29
29
  export declare const CORE_SETTLEMENT_KINDS: readonly ["human_allowed", "human_refused", "approval_window_expired", "denial_limit_window_expired", "park_sla_expired", "no_approver", "approver_unavailable", "approver_error", "approver_contract", "presentation_failed", "blanket_allow_refused", "policy_allowed", "policy_refused", "task_aborted"];
30
30
  export declare const CORE_CLASSIFIER_DENY_CAUSES: readonly ["unavailable", "parse_error"];
31
31
  export declare const CORE_AUTO_MODE_UNAVAILABLE_CAUSES: readonly ["error", "timeout"];
@@ -37,3 +37,4 @@ export declare const CORE_MCP_LIVENESS_STATES: readonly ["reachable", "unreachab
37
37
  export declare const CORE_RULE_BEHAVIORS: readonly ["deny", "ask", "allow"];
38
38
  export declare const CORE_MCP_IMAGE_MAX_BASE64: number;
39
39
  export declare const CORE_MAX_PENDING_STEER_CHARS: number;
40
+ export declare const CORE_PROMPT_BLOCK_CAUSES: readonly ["block", "crashed", "timeout", "cancelled"];
@@ -151,6 +151,7 @@ export const CORE_MODE_ARBITRATION = Object.freeze({
151
151
  "rule_unreadable": Object.freeze({ bypassImmune: false, classifierEligible: false, sandboxAdmission: false, ruleMayClear: false, hookAskFloor: false }),
152
152
  "ask_rule": Object.freeze({ bypassImmune: true, classifierEligible: false, sandboxAdmission: false, ruleMayClear: false, hookAskFloor: true }),
153
153
  "denial_limit_fallback": Object.freeze({ bypassImmune: true, classifierEligible: false, sandboxAdmission: false, ruleMayClear: false, hookAskFloor: false }),
154
+ "classifier_no_ruling": Object.freeze({ bypassImmune: true, classifierEligible: false, sandboxAdmission: false, ruleMayClear: false, hookAskFloor: false }),
154
155
  "requires_user_interaction": Object.freeze({ bypassImmune: true, classifierEligible: false, sandboxAdmission: false, ruleMayClear: false, hookAskFloor: true }),
155
156
  "operator_forced": Object.freeze({ bypassImmune: true, classifierEligible: true, sandboxAdmission: true, ruleMayClear: false, hookAskFloor: false }),
156
157
  "shell_floor": Object.freeze({ bypassImmune: true, classifierEligible: true, sandboxAdmission: true, ruleMayClear: false, hookAskFloor: false }),
@@ -177,6 +178,8 @@ export const CORE_ALLOW_ENTRY_INERT_REASONS = Object.freeze([
177
178
  "domain",
178
179
  "content_unsupported",
179
180
  "grammar",
181
+ "tool_name",
182
+ "near_miss",
180
183
  ]);
181
184
  export const CORE_ALLOW_RULE_MEMBERS = Object.freeze([
182
185
  "hook",
@@ -189,6 +192,7 @@ export const CORE_RULE_TOOL_NAME_VERDICTS = Object.freeze([
189
192
  "current",
190
193
  "retired",
191
194
  "unprefixed_namespace",
195
+ "unmintable_segment",
192
196
  ]);
193
197
  export const CORE_SETTLEMENT_KINDS = Object.freeze([
194
198
  "human_allowed",
@@ -245,3 +249,9 @@ export const CORE_RULE_BEHAVIORS = Object.freeze([
245
249
  ]);
246
250
  export const CORE_MCP_IMAGE_MAX_BASE64 = 5242880;
247
251
  export const CORE_MAX_PENDING_STEER_CHARS = 16000;
252
+ export const CORE_PROMPT_BLOCK_CAUSES = Object.freeze([
253
+ "block",
254
+ "crashed",
255
+ "timeout",
256
+ "cancelled",
257
+ ]);
@@ -2,5 +2,5 @@ export declare const CORE_ENGINE_NOTICE_CODES: readonly string[];
2
2
  export declare const CORE_NOTICE_AUDIENCE: Readonly<Record<string, 'user' | 'operator'>>;
3
3
  export declare const CORE_MCP_INJECTION_DROP_REASONS: readonly string[];
4
4
  export declare const CORE_NOTICE_MINTER: Readonly<Record<string, 'engine' | 'server'>>;
5
- export declare const CORE_USER_STEER_UNDRAINED_CAUSES: readonly ["leg_end", "crashed"];
5
+ export declare const CORE_USER_INPUT_UNDRAINED_CAUSES: readonly ["leg_end", "crashed"];
6
6
  export declare const CORE_TOOL_TURN_INCOMPLETE_CAUSES: readonly ["truncated", "unnamed", "bad_frame", "missing_result_synthesized"];
@@ -268,7 +268,7 @@ export const CORE_NOTICE_MINTER = Object.freeze({
268
268
  "memory.layer_locked_legacy": "server",
269
269
  "server.model_unreachable": "server",
270
270
  });
271
- export const CORE_USER_STEER_UNDRAINED_CAUSES = Object.freeze([
271
+ export const CORE_USER_INPUT_UNDRAINED_CAUSES = Object.freeze([
272
272
  "leg_end",
273
273
  "crashed",
274
274
  ]);
@@ -1,15 +1,8 @@
1
1
  import { type EnvLike } from './hostEnv.js';
2
2
  import type { WireHooksConfig } from './finalVerifyWire.js';
3
3
  export declare const GOAL_STOP_HOOK_WIRE_ENV = "SEMA_GOAL_STOP_HOOK_WIRE";
4
- export declare const CC_STOP_SEMANTICS_MIN_SERVER = "1.279.3";
5
- export declare function ccStopSemanticsFromVersion(version: string | undefined | null): boolean;
6
- export declare function engineCcStopSemantics(env?: EnvLike): boolean;
7
4
  export declare function isGoalStopHookWireArmed(env?: EnvLike): boolean;
8
- export declare function setWireSessionStopHook(prompt: string | null, opts?: {
9
- ccSemantics?: boolean;
10
- }): void;
5
+ export declare function setWireSessionStopHook(prompt: string | null): void;
11
6
  export declare function getWireSessionStopHook(): string | null;
12
- export declare function getWireSessionStopHookCcSemantics(): boolean;
13
- export declare function buildGoalStopHookPrompt(condition: string): string;
14
7
  export declare function goalStopHookMatcher(managedOnly: boolean): NonNullable<WireHooksConfig[string]>[number] | null;
15
8
  export declare function __resetGoalStopHookForTests(): void;