@sema-agent/client-core 0.85.2 → 0.87.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 (79) hide show
  1. package/CHANGELOG.md +263 -0
  2. package/README.md +25 -16
  3. package/dist/adapt/arms.js +14 -1
  4. package/dist/adapter/downstream/terminalToSdkResult.d.ts +3 -3
  5. package/dist/adapter/downstream/terminalToSdkResult.js +4 -1
  6. package/dist/adapter/runStream.js +75 -2
  7. package/dist/adapter/types.d.ts +3 -0
  8. package/dist/agentSession/backgroundView.js +7 -1
  9. package/dist/agentSession/contract.d.ts +1 -1
  10. package/dist/centerWiringCapability.d.ts +38 -0
  11. package/dist/centerWiringCapability.js +202 -0
  12. package/dist/decideFailureNote.js +3 -0
  13. package/dist/decideReceipt.d.ts +1 -1
  14. package/dist/decideReceipt.js +1 -1
  15. package/dist/detachWire.d.ts +6 -1
  16. package/dist/detachWire.js +22 -1
  17. package/dist/engineCapReader.d.ts +8 -0
  18. package/dist/engineCapReader.js +15 -0
  19. package/dist/engineErrorCodes.d.ts +3 -0
  20. package/dist/engineErrorCodes.js +8 -0
  21. package/dist/engineNoticeCodes.d.ts +62 -0
  22. package/dist/engineNoticeCodes.js +247 -29
  23. package/dist/executionLaneCapability.d.ts +6 -0
  24. package/dist/executionLaneCapability.js +55 -2
  25. package/dist/fleet/fleetProjection.js +6 -8
  26. package/dist/fleet/workflowSizeWarning.js +2 -5
  27. package/dist/gateOutcome.d.ts +13 -0
  28. package/dist/gateOutcome.js +48 -1
  29. package/dist/gateVocabulary.d.ts +6 -3
  30. package/dist/gateVocabulary.js +7 -15
  31. package/dist/generated/engineFactTables.d.ts +10 -0
  32. package/dist/generated/engineFactTables.js +113 -0
  33. package/dist/generated/engineNoticeTables.js +14 -0
  34. package/dist/hitl/crashConverged.d.ts +1 -0
  35. package/dist/hitl/crashConverged.js +17 -2
  36. package/dist/hitl/hitlBridge.d.ts +4 -0
  37. package/dist/hitl/hitlBridge.js +6 -0
  38. package/dist/hitl/parkResolver.js +17 -12
  39. package/dist/hitl/refusedToolNameProse.d.ts +4 -0
  40. package/dist/hitl/refusedToolNameProse.js +7 -0
  41. package/dist/hitl/sessionPolicyDeliverable.js +9 -5
  42. package/dist/hitl/sessionPolicyWire.d.ts +16 -0
  43. package/dist/hitl/sessionPolicyWire.js +49 -1
  44. package/dist/hitl/suspendedReopen.d.ts +7 -0
  45. package/dist/hitl/suspendedReopen.js +38 -7
  46. package/dist/hitl/toolApprovalWire.js +4 -5
  47. package/dist/index.d.ts +6 -1
  48. package/dist/index.js +6 -1
  49. package/dist/inheritEnvWire.d.ts +22 -0
  50. package/dist/inheritEnvWire.js +84 -0
  51. package/dist/peerFrames.js +2 -10
  52. package/dist/printInitToolFace.d.ts +6 -0
  53. package/dist/printInitToolFace.js +115 -2
  54. package/dist/readCredentialRefusal.d.ts +2 -0
  55. package/dist/readCredentialRefusal.js +7 -0
  56. package/dist/request/taskRequest.d.ts +4 -5
  57. package/dist/request/taskRequest.js +33 -23
  58. package/dist/resumeRefusalCopy.d.ts +2 -7
  59. package/dist/resumeRefusalCopy.js +2 -24
  60. package/dist/rewindArchiveCapability.js +5 -0
  61. package/dist/runTerminal.js +2 -6
  62. package/dist/seam.d.ts +11 -1
  63. package/dist/seam.js +7 -0
  64. package/dist/sqlEngineCapability.js +15 -2
  65. package/dist/storePostureCapability.d.ts +25 -0
  66. package/dist/storePostureCapability.js +132 -0
  67. package/dist/toolHistoryMismatch.d.ts +63 -0
  68. package/dist/toolHistoryMismatch.js +425 -0
  69. package/dist/toolResult.js +2 -47
  70. package/dist/wireErrorTriage.d.ts +1 -0
  71. package/dist/wireErrorTriage.js +3 -0
  72. package/dist/wireFailureShape.d.ts +3 -0
  73. package/dist/wireFailureShape.js +44 -0
  74. package/dist/wireRefusalCopy.d.ts +39 -1
  75. package/dist/wireRefusalCopy.js +350 -2
  76. package/dist/workflowClient.d.ts +7 -2
  77. package/dist/workflowClient.js +15 -7
  78. package/docs/INTEGRATION-CLIENTS.md +942 -16
  79. package/package.json +2 -2
@@ -1,4 +1,5 @@
1
1
  import { frozenSet } from './frozenSet.js';
2
+ import { CORE_TOOL_DECLARATION_CODES } from './generated/engineFactTables.js';
2
3
  export const LIMITS_MAX_TOKENS_EXCEEDED = 'limits.max_tokens_exceeded';
3
4
  export const LIMITS_MAX_COST_EXCEEDED = 'limits.max_cost_exceeded';
4
5
  export const LIMITS_MAX_TURNS_EXCEEDED = 'limits.max_turns_exceeded';
@@ -9,6 +10,7 @@ export function isLimitsExceededCode(code) {
9
10
  }
10
11
  export const USAGE_WINDOW_EXHAUSTED = 'usage.window_exhausted';
11
12
  export const ENV_LIFETIME_EXPIRED = 'env.lifetime_expired';
13
+ export const FLEET_LEASE_UNAVAILABLE = 'fleet.lease_unavailable';
12
14
  export const CONFIG_LIMIT_INVALID = 'config.limit_invalid';
13
15
  export const CONFIG_STRATEGY_FIND_LIMIT_INVALID = 'config.strategy_find_limit_invalid';
14
16
  export const CONFIG_STRATEGY_MAX_SIZE_INVALID = 'config.strategy_max_size_invalid';
@@ -26,7 +28,13 @@ export const CONFIG_REFUSAL_CODES = frozenSet([
26
28
  CONFIG_MEMORY_PROJECT_KEY_SPELLING,
27
29
  CONFIG_MEMORY_WRITE_SCOPE_MISMATCH,
28
30
  CONFIG_LEGACY_TOOL_NAME,
31
+ ...CORE_TOOL_DECLARATION_CODES,
29
32
  ]);
33
+ export const RULES_LEGACY_TOOL_NAME = 'rules.legacy_tool_name';
34
+ const RULES_ERROR_CODE_PREFIX = 'rules.';
35
+ export function isRulesRefusalCode(code) {
36
+ return typeof code === 'string' && code.startsWith(RULES_ERROR_CODE_PREFIX);
37
+ }
30
38
  export const DELEGATION_CONCURRENCY_CAP = 'delegation.concurrency_cap';
31
39
  export const DELEGATION_SESSION_CAP = 'delegation.session_cap';
32
40
  export const DELEGATION_CAP_CODES = frozenSet([
@@ -19,6 +19,7 @@ export interface AskUnresolvableFactsView {
19
19
  toolCallId: string;
20
20
  cause: string;
21
21
  parkLaneExisted?: boolean;
22
+ remedy?: string;
22
23
  }
23
24
  export declare function readAskUnresolvable(notice: unknown): AskUnresolvableFactsView | undefined;
24
25
  export declare const DURABLE_MANDATE_SOURCES: readonly string[];
@@ -81,6 +82,61 @@ export interface SessionRecordsSkippedFactsView {
81
82
  }
82
83
  export declare function readSessionRecordsSkipped(notice: unknown): SessionRecordsSkippedFactsView | undefined;
83
84
  export declare function sessionRecordsSkippedNote(facts: Pick<SessionRecordsSkippedFactsView, 'entriesKept'>): string | undefined;
85
+ export interface RuleStoreUnavailableFactsView {
86
+ at: string;
87
+ sessionId: string;
88
+ runId: string;
89
+ }
90
+ export declare function readRuleStoreUnavailable(notice: unknown): RuleStoreUnavailableFactsView | undefined;
91
+ declare const CLASSIFIER_UNAVAILABLE_DISPOSITIONS: readonly ["asked", "denied"];
92
+ type ClassifierUnavailableDispositionWord = (typeof CLASSIFIER_UNAVAILABLE_DISPOSITIONS)[number];
93
+ export interface ClassifierUnavailableFactsView {
94
+ toolName: string;
95
+ toolCallId: string;
96
+ cause: string;
97
+ disposition: ClassifierUnavailableDispositionWord;
98
+ sessionId?: string;
99
+ runId?: string;
100
+ }
101
+ export declare function readClassifierUnavailable(notice: unknown): ClassifierUnavailableFactsView | undefined;
102
+ export declare const PERMISSION_MODE_FOLD_REASONS: readonly string[];
103
+ export interface PermissionModeUnavailableFactsView {
104
+ requested: string;
105
+ effective: string;
106
+ by: string;
107
+ sessionId: string;
108
+ runId: string;
109
+ childSessionId?: string;
110
+ }
111
+ export declare function readPermissionModeUnavailable(notice: unknown): PermissionModeUnavailableFactsView | undefined;
112
+ export interface AskReleasedByModeFactsView {
113
+ mode: string;
114
+ askClass: string;
115
+ origin?: string;
116
+ mandate?: string;
117
+ count: number;
118
+ firstToolCallId: string;
119
+ sessionId?: string;
120
+ runId?: string;
121
+ }
122
+ export declare function readAskReleasedByMode(notice: unknown): AskReleasedByModeFactsView | undefined;
123
+ export interface ReadDenyUnappliedFactsView {
124
+ mode: string;
125
+ toolCallId: string;
126
+ tiers: readonly string[];
127
+ rows: readonly string[];
128
+ rowCount: number;
129
+ sessionId: string;
130
+ runId: string;
131
+ }
132
+ export declare function readReadDenyUnapplied(notice: unknown): ReadDenyUnappliedFactsView | undefined;
133
+ export interface LegacyModeSeedMigratedFactsView {
134
+ permissionMode?: string;
135
+ droppedKeys: readonly string[];
136
+ sessionId: string;
137
+ runId: string;
138
+ }
139
+ export declare function readLegacyModeSeedMigrated(notice: unknown): LegacyModeSeedMigratedFactsView | undefined;
84
140
  export declare const ENGINE_NOTICE_FACT_READERS: Readonly<{
85
141
  readonly 'mcp.injection_dropped': typeof readMcpInjectionDrop;
86
142
  readonly 'delegation.ask_unresolvable': typeof readAskUnresolvable;
@@ -91,6 +147,12 @@ export declare const ENGINE_NOTICE_FACT_READERS: Readonly<{
91
147
  readonly 'approval.read_root_granted': typeof readReadRootGrantNotice;
92
148
  readonly 'approval.read_root_grant_rejected': typeof readReadRootGrantNotice;
93
149
  readonly 'session.records_skipped': typeof readSessionRecordsSkipped;
150
+ readonly 'permission.rule_store_unavailable': typeof readRuleStoreUnavailable;
151
+ readonly 'classifier.unavailable': typeof readClassifierUnavailable;
152
+ readonly 'config.permission_mode_unavailable': typeof readPermissionModeUnavailable;
153
+ readonly 'permission.ask_released_by_mode': typeof readAskReleasedByMode;
154
+ readonly 'permission.read_deny_unapplied': typeof readReadDenyUnapplied;
155
+ readonly 'resume.legacy_mode_seed_migrated': typeof readLegacyModeSeedMigrated;
94
156
  }>;
95
157
  type FactReaderTable = typeof ENGINE_NOTICE_FACT_READERS;
96
158
  export type EngineNoticeFactsCode = keyof FactReaderTable;
@@ -1,4 +1,6 @@
1
+ import { AUTO_MODE_UNAVAILABLE_CAUSES } from './autoModeUnavailable.js';
1
2
  import { CORE_ENGINE_NOTICE_CODES, CORE_MCP_INJECTION_DROP_REASONS, CORE_NOTICE_AUDIENCE } from './generated/engineNoticeTables.js';
3
+ import { CORE_ASK_UNRESOLVABLE_CAUSES, CORE_DURABLE_MANDATE_SOURCES, CORE_PERMISSION_MODE_FOLD_REASONS, } from './generated/engineFactTables.js';
2
4
  export const ENGINE_NOTICE_CODES = CORE_ENGINE_NOTICE_CODES;
3
5
  const CATALOG = new Set(ENGINE_NOTICE_CODES);
4
6
  export const SERVER_NOTICE_AUDIENCE = Object.freeze({
@@ -30,20 +32,28 @@ export function readMcpInjectionDrop(notice) {
30
32
  if (typeof d !== 'object' || d === null || Array.isArray(d))
31
33
  return undefined;
32
34
  const o = d;
33
- const sessionId = typeof o.sessionId === 'string' && o.sessionId.length > 0 ? o.sessionId : undefined;
34
- const server = typeof o.server === 'string' && o.server.length > 0 ? o.server : undefined;
35
- const reason = typeof o.reason === 'string' && DROP_REASONS.has(o.reason) ? o.reason : undefined;
35
+ const sessionIdIn = o.sessionId;
36
+ const serverIn = o.server;
37
+ const reasonIn = o.reason;
38
+ const sessionId = typeof sessionIdIn === 'string' && sessionIdIn.length > 0 ? sessionIdIn : undefined;
39
+ const server = typeof serverIn === 'string' && serverIn.length > 0 ? serverIn : undefined;
40
+ const reason = typeof reasonIn === 'string' && DROP_REASONS.has(reasonIn) ? reasonIn : undefined;
36
41
  if (sessionId === undefined || server === undefined || reason === undefined)
37
42
  return undefined;
38
- const field = typeof o.field === 'string' && o.field.length > 0 ? o.field : undefined;
43
+ const fieldIn = o.field;
44
+ const field = typeof fieldIn === 'string' && fieldIn.length > 0 ? fieldIn : undefined;
39
45
  return { sessionId, server, reason, ...(field !== undefined ? { field } : {}) };
40
46
  }
41
- export const ASK_UNRESOLVABLE_CAUSES = Object.freeze([
42
- 'approver_unavailable',
43
- 'no_approver_wired',
44
- 'mandate_unreconstructible',
45
- ]);
47
+ export const ASK_UNRESOLVABLE_CAUSES = CORE_ASK_UNRESOLVABLE_CAUSES;
46
48
  const ASK_UNRESOLVABLE_CAUSE_SET = new Set(ASK_UNRESOLVABLE_CAUSES);
49
+ function optionalSeat(o, key) {
50
+ try {
51
+ return o[key];
52
+ }
53
+ catch {
54
+ return undefined;
55
+ }
56
+ }
47
57
  export function readAskUnresolvable(notice) {
48
58
  if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
49
59
  return undefined;
@@ -54,25 +64,29 @@ export function readAskUnresolvable(notice) {
54
64
  if (typeof d !== 'object' || d === null || Array.isArray(d))
55
65
  return undefined;
56
66
  const o = d;
57
- const sessionId = typeof o.sessionId === 'string' && o.sessionId.length > 0 ? o.sessionId : undefined;
58
- const toolName = typeof o.toolName === 'string' && o.toolName.length > 0 ? o.toolName : undefined;
59
- const toolCallId = typeof o.toolCallId === 'string' && o.toolCallId.length > 0 ? o.toolCallId : undefined;
60
- const cause = typeof o.cause === 'string' && ASK_UNRESOLVABLE_CAUSE_SET.has(o.cause) ? o.cause : undefined;
67
+ const sessionIdIn = o.sessionId;
68
+ const toolNameIn = o.toolName;
69
+ const toolCallIdIn = o.toolCallId;
70
+ const causeIn = o.cause;
71
+ const sessionId = typeof sessionIdIn === 'string' && sessionIdIn.length > 0 ? sessionIdIn : undefined;
72
+ const toolName = typeof toolNameIn === 'string' && toolNameIn.length > 0 ? toolNameIn : undefined;
73
+ const toolCallId = typeof toolCallIdIn === 'string' && toolCallIdIn.length > 0 ? toolCallIdIn : undefined;
74
+ const cause = typeof causeIn === 'string' && ASK_UNRESOLVABLE_CAUSE_SET.has(causeIn) ? causeIn : undefined;
61
75
  if (sessionId === undefined || toolName === undefined || toolCallId === undefined || cause === undefined) {
62
76
  return undefined;
63
77
  }
78
+ const parkIn = o.parkLaneExisted;
79
+ const remedyIn = optionalSeat(o, 'remedy');
64
80
  return {
65
81
  sessionId,
66
82
  toolName,
67
83
  toolCallId,
68
84
  cause,
69
- ...(typeof o.parkLaneExisted === 'boolean' ? { parkLaneExisted: o.parkLaneExisted } : {}),
85
+ ...(typeof parkIn === 'boolean' ? { parkLaneExisted: parkIn } : {}),
86
+ ...(typeof remedyIn === 'string' && remedyIn.length > 0 ? { remedy: remedyIn } : {}),
70
87
  };
71
88
  }
72
- export const DURABLE_MANDATE_SOURCES = Object.freeze([
73
- 'force_durable_gate',
74
- 'durable_approval',
75
- ]);
89
+ export const DURABLE_MANDATE_SOURCES = CORE_DURABLE_MANDATE_SOURCES;
76
90
  const DURABLE_MANDATE_SOURCE_SET = new Set(DURABLE_MANDATE_SOURCES);
77
91
  export function readDurableGateUnavailable(notice) {
78
92
  if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
@@ -84,26 +98,41 @@ export function readDurableGateUnavailable(notice) {
84
98
  if (typeof d !== 'object' || d === null || Array.isArray(d))
85
99
  return undefined;
86
100
  const o = d;
87
- const sessionId = typeof o.sessionId === 'string' && o.sessionId.length > 0 ? o.sessionId : undefined;
88
- const runId = typeof o.runId === 'string' && o.runId.length > 0 ? o.runId : undefined;
89
- const source = typeof o.source === 'string' && DURABLE_MANDATE_SOURCE_SET.has(o.source) ? o.source : undefined;
90
- const cause = typeof o.cause === 'string' && o.cause.length > 0 ? o.cause : undefined;
101
+ const sessionIdIn = o.sessionId;
102
+ const runIdIn = o.runId;
103
+ const sourceIn = o.source;
104
+ const causeIn = o.cause;
105
+ const sessionId = typeof sessionIdIn === 'string' && sessionIdIn.length > 0 ? sessionIdIn : undefined;
106
+ const runId = typeof runIdIn === 'string' && runIdIn.length > 0 ? runIdIn : undefined;
107
+ const source = typeof sourceIn === 'string' && DURABLE_MANDATE_SOURCE_SET.has(sourceIn) ? sourceIn : undefined;
108
+ const cause = typeof causeIn === 'string' && causeIn.length > 0 ? causeIn : undefined;
91
109
  if (sessionId === undefined || runId === undefined || source === undefined || cause === undefined) {
92
110
  return undefined;
93
111
  }
94
- const principal = typeof o.principal === 'string' && o.principal.length > 0 ? o.principal : undefined;
112
+ const principalIn = o.principal;
113
+ const principal = typeof principalIn === 'string' && principalIn.length > 0 ? principalIn : undefined;
114
+ const liveApprover = o.liveApprover;
115
+ const liveQuestionFace = o.liveQuestionFace;
95
116
  return {
96
117
  sessionId,
97
118
  runId,
98
119
  ...(principal !== undefined ? { principal } : {}),
99
120
  source,
100
121
  cause,
101
- ...(typeof o.liveApprover === 'boolean' ? { liveApprover: o.liveApprover } : {}),
102
- ...(typeof o.liveQuestionFace === 'boolean' ? { liveQuestionFace: o.liveQuestionFace } : {}),
122
+ ...(typeof liveApprover === 'boolean' ? { liveApprover } : {}),
123
+ ...(typeof liveQuestionFace === 'boolean' ? { liveQuestionFace } : {}),
103
124
  };
104
125
  }
105
126
  const nonNegInt = (v) => typeof v === 'number' && Number.isInteger(v) && v >= 0 ? v : undefined;
106
- const nameList = (v) => Array.isArray(v) && v.every((x) => typeof x === 'string' && x.length > 0) ? Object.freeze([...v]) : undefined;
127
+ const nameList = (v) => {
128
+ if (!Array.isArray(v))
129
+ return undefined;
130
+ const n = v.length;
131
+ const copy = [];
132
+ for (let i = 0; i < n; i++)
133
+ copy.push(v[i]);
134
+ return copy.every((x) => typeof x === 'string' && x.length > 0) ? Object.freeze(copy) : undefined;
135
+ };
107
136
  export function readSkillsListingTruncated(notice) {
108
137
  if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
109
138
  return undefined;
@@ -123,7 +152,8 @@ export function readSkillsListingTruncated(notice) {
123
152
  return undefined;
124
153
  }
125
154
  const descMaxChars = nonNegInt(o.descMaxChars);
126
- const sessionId = typeof o.sessionId === 'string' && o.sessionId.length > 0 ? o.sessionId : undefined;
155
+ const sessionIdIn = o.sessionId;
156
+ const sessionId = typeof sessionIdIn === 'string' && sessionIdIn.length > 0 ? sessionIdIn : undefined;
127
157
  return {
128
158
  budgetBytes,
129
159
  ...(descMaxChars !== undefined ? { descMaxChars } : {}),
@@ -148,7 +178,8 @@ export function readMcpServerRedialed(notice) {
148
178
  const str = (v) => (typeof v === 'string' && v.length > 0 ? v : undefined);
149
179
  const count = (v) => (typeof v === 'number' && Number.isInteger(v) && v >= 0 ? v : undefined);
150
180
  const server = str(o.server);
151
- const outcome = typeof o.outcome === 'string' && MCP_REDIAL_OUTCOMES.includes(o.outcome) ? o.outcome : undefined;
181
+ const outcomeIn = o.outcome;
182
+ const outcome = typeof outcomeIn === 'string' && MCP_REDIAL_OUTCOMES.includes(outcomeIn) ? outcomeIn : undefined;
152
183
  const added = count(o.added);
153
184
  const removed = count(o.removed);
154
185
  const sessionId = str(o.sessionId);
@@ -224,7 +255,8 @@ export function readInstructionsSourceChanged(notice) {
224
255
  const o = d;
225
256
  const previous = ownPathOrNull(o, 'previous');
226
257
  const current = ownPathOrNull(o, 'current');
227
- const sessionId = typeof o.sessionId === 'string' && o.sessionId.length > 0 ? o.sessionId : undefined;
258
+ const sessionIdIn = o.sessionId;
259
+ const sessionId = typeof sessionIdIn === 'string' && sessionIdIn.length > 0 ? sessionIdIn : undefined;
228
260
  if (previous === undefined || current === undefined || sessionId === undefined)
229
261
  return undefined;
230
262
  return { previous, current, sessionId };
@@ -271,6 +303,186 @@ export function sessionRecordsSkippedNote(facts) {
271
303
  return ("None of this session's earlier entries could be read, so this turn runs with an empty context — the model sees nothing of the earlier conversation. " +
272
304
  'If that history matters, whoever operates this engine has to repair the stored log of this session.');
273
305
  }
306
+ const nonEmpty = (v) => (typeof v === 'string' && v.length > 0 ? v : undefined);
307
+ function guardedRead(notice, read) {
308
+ try {
309
+ return read(notice);
310
+ }
311
+ catch {
312
+ return undefined;
313
+ }
314
+ }
315
+ export function readRuleStoreUnavailable(notice) {
316
+ return guardedRead(notice, readRuleStoreUnavailableOf);
317
+ }
318
+ function readRuleStoreUnavailableOf(notice) {
319
+ if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
320
+ return undefined;
321
+ const n = notice;
322
+ if (n.code !== 'permission.rule_store_unavailable')
323
+ return undefined;
324
+ const d = n.detail;
325
+ if (typeof d !== 'object' || d === null || Array.isArray(d))
326
+ return undefined;
327
+ const o = d;
328
+ const at = nonEmpty(o.at);
329
+ const sessionId = nonEmpty(o.sessionId);
330
+ const runId = nonEmpty(o.runId);
331
+ if (at === undefined || sessionId === undefined || runId === undefined)
332
+ return undefined;
333
+ return { at, sessionId, runId };
334
+ }
335
+ const CLASSIFIER_UNAVAILABLE_DISPOSITIONS = Object.freeze(['asked', 'denied']);
336
+ const _classifierDispositionPin = true;
337
+ void _classifierDispositionPin;
338
+ const AUTO_MODE_UNAVAILABLE_CAUSE_SET = new Set(AUTO_MODE_UNAVAILABLE_CAUSES);
339
+ export function readClassifierUnavailable(notice) {
340
+ return guardedRead(notice, readClassifierUnavailableOf);
341
+ }
342
+ function readClassifierUnavailableOf(notice) {
343
+ if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
344
+ return undefined;
345
+ const n = notice;
346
+ if (n.code !== 'classifier.unavailable')
347
+ return undefined;
348
+ const d = n.detail;
349
+ if (typeof d !== 'object' || d === null || Array.isArray(d))
350
+ return undefined;
351
+ const o = d;
352
+ const toolName = nonEmpty(o.toolName);
353
+ const toolCallId = nonEmpty(o.toolCallId);
354
+ const causeIn = o.cause;
355
+ const dispositionIn = o.disposition;
356
+ const cause = typeof causeIn === 'string' && AUTO_MODE_UNAVAILABLE_CAUSE_SET.has(causeIn) ? causeIn : undefined;
357
+ const disposition = CLASSIFIER_UNAVAILABLE_DISPOSITIONS.includes(dispositionIn)
358
+ ? dispositionIn
359
+ : undefined;
360
+ if (toolName === undefined || toolCallId === undefined || cause === undefined || disposition === undefined)
361
+ return undefined;
362
+ const sessionId = nonEmpty(optionalSeat(o, 'sessionId'));
363
+ const runId = nonEmpty(optionalSeat(o, 'runId'));
364
+ return {
365
+ toolName,
366
+ toolCallId,
367
+ cause,
368
+ disposition,
369
+ ...(sessionId !== undefined ? { sessionId } : {}),
370
+ ...(runId !== undefined ? { runId } : {}),
371
+ };
372
+ }
373
+ export const PERMISSION_MODE_FOLD_REASONS = CORE_PERMISSION_MODE_FOLD_REASONS;
374
+ const PERMISSION_MODE_FOLD_REASON_SET = new Set(PERMISSION_MODE_FOLD_REASONS);
375
+ export function readPermissionModeUnavailable(notice) {
376
+ return guardedRead(notice, readPermissionModeUnavailableOf);
377
+ }
378
+ function readPermissionModeUnavailableOf(notice) {
379
+ if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
380
+ return undefined;
381
+ const n = notice;
382
+ if (n.code !== 'config.permission_mode_unavailable')
383
+ return undefined;
384
+ const d = n.detail;
385
+ if (typeof d !== 'object' || d === null || Array.isArray(d))
386
+ return undefined;
387
+ const o = d;
388
+ const requested = nonEmpty(o.requested);
389
+ const effective = nonEmpty(o.effective);
390
+ const byIn = o.by;
391
+ const by = typeof byIn === 'string' && PERMISSION_MODE_FOLD_REASON_SET.has(byIn) ? byIn : undefined;
392
+ const sessionId = nonEmpty(o.sessionId);
393
+ const runId = nonEmpty(o.runId);
394
+ if (requested === undefined || effective === undefined || by === undefined || sessionId === undefined || runId === undefined) {
395
+ return undefined;
396
+ }
397
+ const childSessionId = nonEmpty(optionalSeat(o, 'childSessionId'));
398
+ return { requested, effective, by, sessionId, runId, ...(childSessionId !== undefined ? { childSessionId } : {}) };
399
+ }
400
+ export function readAskReleasedByMode(notice) {
401
+ return guardedRead(notice, readAskReleasedByModeOf);
402
+ }
403
+ function readAskReleasedByModeOf(notice) {
404
+ if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
405
+ return undefined;
406
+ const n = notice;
407
+ if (n.code !== 'permission.ask_released_by_mode')
408
+ return undefined;
409
+ const d = n.detail;
410
+ if (typeof d !== 'object' || d === null || Array.isArray(d))
411
+ return undefined;
412
+ const o = d;
413
+ const mode = nonEmpty(o.mode);
414
+ const askClass = nonEmpty(o.askClass);
415
+ const count = nonNegInt(o.count);
416
+ const firstToolCallId = nonEmpty(o.firstToolCallId);
417
+ if (mode === undefined || askClass === undefined || count === undefined || count < 1 || firstToolCallId === undefined) {
418
+ return undefined;
419
+ }
420
+ const origin = nonEmpty(optionalSeat(o, 'origin'));
421
+ const mandate = nonEmpty(optionalSeat(o, 'mandate'));
422
+ const sessionId = nonEmpty(optionalSeat(o, 'sessionId'));
423
+ const runId = nonEmpty(optionalSeat(o, 'runId'));
424
+ return {
425
+ mode,
426
+ askClass,
427
+ ...(origin !== undefined ? { origin } : {}),
428
+ ...(mandate !== undefined ? { mandate } : {}),
429
+ count,
430
+ firstToolCallId,
431
+ ...(sessionId !== undefined ? { sessionId } : {}),
432
+ ...(runId !== undefined ? { runId } : {}),
433
+ };
434
+ }
435
+ export function readReadDenyUnapplied(notice) {
436
+ return guardedRead(notice, readReadDenyUnappliedOf);
437
+ }
438
+ function readReadDenyUnappliedOf(notice) {
439
+ if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
440
+ return undefined;
441
+ const n = notice;
442
+ if (n.code !== 'permission.read_deny_unapplied')
443
+ return undefined;
444
+ const d = n.detail;
445
+ if (typeof d !== 'object' || d === null || Array.isArray(d))
446
+ return undefined;
447
+ const o = d;
448
+ const mode = nonEmpty(o.mode);
449
+ const toolCallId = nonEmpty(o.toolCallId);
450
+ const tiers = nameList(o.tiers);
451
+ const rows = nameList(o.rows);
452
+ const rowCount = nonNegInt(o.rowCount);
453
+ const sessionId = nonEmpty(o.sessionId);
454
+ const runId = nonEmpty(o.runId);
455
+ if (mode === undefined || toolCallId === undefined || tiers === undefined || rows === undefined ||
456
+ rowCount === undefined || sessionId === undefined || runId === undefined) {
457
+ return undefined;
458
+ }
459
+ return { mode, toolCallId, tiers, rows, rowCount, sessionId, runId };
460
+ }
461
+ export function readLegacyModeSeedMigrated(notice) {
462
+ return guardedRead(notice, readLegacyModeSeedMigratedOf);
463
+ }
464
+ function readLegacyModeSeedMigratedOf(notice) {
465
+ if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
466
+ return undefined;
467
+ const n = notice;
468
+ if (n.code !== 'resume.legacy_mode_seed_migrated')
469
+ return undefined;
470
+ const d = n.detail;
471
+ if (typeof d !== 'object' || d === null || Array.isArray(d))
472
+ return undefined;
473
+ const o = d;
474
+ const m = o.migrated;
475
+ if (typeof m !== 'object' || m === null || Array.isArray(m))
476
+ return undefined;
477
+ const mo = m;
478
+ const droppedKeys = nameList(mo.droppedKeys);
479
+ const sessionId = nonEmpty(o.sessionId);
480
+ const runId = nonEmpty(o.runId);
481
+ if (droppedKeys === undefined || sessionId === undefined || runId === undefined)
482
+ return undefined;
483
+ const permissionMode = nonEmpty(optionalSeat(mo, 'permissionMode'));
484
+ return { ...(permissionMode !== undefined ? { permissionMode } : {}), droppedKeys, sessionId, runId };
485
+ }
274
486
  export const ENGINE_NOTICE_FACT_READERS = Object.freeze({
275
487
  'mcp.injection_dropped': readMcpInjectionDrop,
276
488
  'delegation.ask_unresolvable': readAskUnresolvable,
@@ -281,6 +493,12 @@ export const ENGINE_NOTICE_FACT_READERS = Object.freeze({
281
493
  'approval.read_root_granted': readReadRootGrantNotice,
282
494
  'approval.read_root_grant_rejected': readReadRootGrantNotice,
283
495
  'session.records_skipped': readSessionRecordsSkipped,
496
+ 'permission.rule_store_unavailable': readRuleStoreUnavailable,
497
+ 'classifier.unavailable': readClassifierUnavailable,
498
+ 'config.permission_mode_unavailable': readPermissionModeUnavailable,
499
+ 'permission.ask_released_by_mode': readAskReleasedByMode,
500
+ 'permission.read_deny_unapplied': readReadDenyUnapplied,
501
+ 'resume.legacy_mode_seed_migrated': readLegacyModeSeedMigrated,
284
502
  });
285
503
  const _factReaderTablePin = true;
286
504
  void _factReaderTablePin;
@@ -1,6 +1,9 @@
1
+ export type ExecutionLaneIsolatedAbsence = 'no_hands' | 'not_reported' | 'unreadable';
1
2
  export interface ExecutionLaneCapabilityView {
2
3
  provider: string;
3
4
  toolsOnThisHost: boolean;
5
+ isolated?: boolean;
6
+ isolatedAbsent?: ExecutionLaneIsolatedAbsence;
4
7
  }
5
8
  export type ExecutionLaneReading = {
6
9
  kind: 'unobserved';
@@ -11,11 +14,14 @@ export type ExecutionLaneReading = {
11
14
  view: ExecutionLaneCapabilityView;
12
15
  };
13
16
  export declare function projectExecutionLaneCapability(caps: unknown): ExecutionLaneReading | undefined;
17
+ export declare function projectExecutionLaneWiring(wiring: unknown): ExecutionLaneReading | undefined;
14
18
  export declare function noteEngineCapsForExecutionLane(baseUrl: string, caps: unknown, opts?: {
15
19
  generation?: number;
16
20
  }): void;
17
21
  export declare function observedExecutionLane(baseUrl?: string | undefined): ExecutionLaneReading;
18
22
  export declare function toolsRunHereFromExecutionLane(reading: ExecutionLaneReading, legacyInference: boolean): boolean;
23
+ export declare function noOsSandboxOnThisHost(reading: ExecutionLaneReading): 'yes' | 'no' | 'unknown';
24
+ export declare function noOsSandboxContent(): string;
19
25
  export declare function executionLaneDoctorDetail(reading: ExecutionLaneReading): string;
20
26
  export declare function forgetExecutionLaneReading(baseUrl: string | undefined): void;
21
27
  export declare function __resetExecutionLaneReadingsForTests(): void;
@@ -1,6 +1,6 @@
1
1
  import { capForDisplay } from './fleetTaskDesc.js';
2
2
  import { engineWireTarget } from './engineWireTarget.js';
3
- import { createEngineCapReader } from './engineCapReader.js';
3
+ import { capsGenerationOf, createEngineCapReader } from './engineCapReader.js';
4
4
  export function projectExecutionLaneCapability(caps) {
5
5
  if (caps === null || typeof caps !== 'object')
6
6
  return undefined;
@@ -11,6 +11,9 @@ export function projectExecutionLaneCapability(caps) {
11
11
  const lane = caps.executionLane;
12
12
  if (lane === undefined)
13
13
  return { kind: 'not_reported' };
14
+ return projectExecutionLaneObject(lane, () => capsGenerationOf(caps).generation === 'new');
15
+ }
16
+ function projectExecutionLaneObject(lane, newGeneration) {
14
17
  if (lane === null || typeof lane !== 'object' || Array.isArray(lane))
15
18
  return undefined;
16
19
  const provider = lane.provider;
@@ -19,7 +22,33 @@ export function projectExecutionLaneCapability(caps) {
19
22
  return undefined;
20
23
  if (typeof toolsOnThisHost !== 'boolean')
21
24
  return undefined;
22
- return { kind: 'present', view: { provider, toolsOnThisHost } };
25
+ let isolated;
26
+ let isolatedThrew = false;
27
+ try {
28
+ isolated = Object.hasOwn(lane, 'isolated') ? lane.isolated : undefined;
29
+ }
30
+ catch {
31
+ isolatedThrew = true;
32
+ }
33
+ if (!isolatedThrew && typeof isolated === 'boolean')
34
+ return { kind: 'present', view: { provider, toolsOnThisHost, isolated } };
35
+ const isolatedAbsent = isolatedThrew || isolated !== undefined ? 'unreadable' : !newGeneration() ? 'not_reported' : toolsOnThisHost ? 'unreadable' : 'no_hands';
36
+ return { kind: 'present', view: { provider, toolsOnThisHost, isolatedAbsent } };
37
+ }
38
+ export function projectExecutionLaneWiring(wiring) {
39
+ try {
40
+ if (wiring === null || typeof wiring !== 'object' || Array.isArray(wiring))
41
+ return undefined;
42
+ if (!Object.hasOwn(wiring, 'executionLane'))
43
+ return { kind: 'not_reported' };
44
+ const lane = wiring.executionLane;
45
+ if (lane === undefined)
46
+ return { kind: 'not_reported' };
47
+ return projectExecutionLaneObject(lane, () => true);
48
+ }
49
+ catch {
50
+ return undefined;
51
+ }
23
52
  }
24
53
  const reader = createEngineCapReader({
25
54
  name: 'executionLane',
@@ -37,6 +66,30 @@ export function toolsRunHereFromExecutionLane(reading, legacyInference) {
37
66
  return reading.view.toolsOnThisHost;
38
67
  return legacyInference;
39
68
  }
69
+ export function noOsSandboxOnThisHost(reading) {
70
+ if (typeof reading !== 'object' || reading === null)
71
+ return 'unknown';
72
+ try {
73
+ if (reading.kind !== 'present')
74
+ return 'unknown';
75
+ const view = reading.view;
76
+ if (typeof view !== 'object' || view === null)
77
+ return 'unknown';
78
+ const tools = view.toolsOnThisHost;
79
+ const isolated = view.isolated;
80
+ if (tools === false || isolated === true)
81
+ return 'no';
82
+ if (tools === true && isolated === false)
83
+ return 'yes';
84
+ return 'unknown';
85
+ }
86
+ catch {
87
+ return 'unknown';
88
+ }
89
+ }
90
+ export function noOsSandboxContent() {
91
+ return 'Tools run directly on this machine with no OS sandbox — files and commands they change here are changed for real, so permission rules and approvals are the only guard';
92
+ }
40
93
  const LANE_DETAIL_MAX = 40;
41
94
  export function executionLaneDoctorDetail(reading) {
42
95
  switch (reading.kind) {
@@ -1,6 +1,7 @@
1
1
  import { collapseLabel, escapeDisplayControlChars, taskDescFromName } from '../fleetTaskDesc.js';
2
2
  import { rowIdTail } from '../workflow.js';
3
3
  import { frozenSet } from '../frozenSet.js';
4
+ import { CORE_RESERVED_AGENT_NAMES } from '../generated/engineFactTables.js';
4
5
  export const TERMINAL_FLEET_TASK_STATUSES = frozenSet([
5
6
  'completed',
6
7
  'failed',
@@ -52,15 +53,12 @@ function deriveAgentLabel(agentType, agentName, name, id) {
52
53
  const tail = rowIdTail(id).slice(-8);
53
54
  return tail ? `agent ${tail}` : 'agent';
54
55
  }
56
+ const CONTROL_VERB_LEGACY_NAMES = ['Task', 'Fork'];
57
+ const CONTROL_VERB_GOAL_NAMES = ['DeclareDone'];
55
58
  export const CONTROL_TOOL_VERBS = frozenSet([
56
- 'Agent',
57
- 'Task',
58
- 'Fork',
59
- 'StructuredOutput',
60
- 'ReportBlocked',
61
- 'ReadToolResult',
62
- 'ToolSearch',
63
- 'DeclareDone',
59
+ ...CORE_RESERVED_AGENT_NAMES,
60
+ ...CONTROL_VERB_LEGACY_NAMES,
61
+ ...CONTROL_VERB_GOAL_NAMES,
64
62
  ]);
65
63
  export function projectDescription(description) {
66
64
  const d = description ?? '';
@@ -1,11 +1,8 @@
1
+ import { CORE_WORKFLOW_SIZE_GUIDELINE_AGENT_CAPS } from '../generated/engineFactTables.js';
1
2
  export const WORKFLOW_SIZE_WARNING_AGENT_CAP = 25;
2
3
  export const WORKFLOW_SIZE_WARNING_TOKEN_CAP = 1_500_000;
3
4
  export const WORKFLOW_SIZE_WARNING_TOKENS_PER_AGENT = 70_000;
4
- export const WORKFLOW_SIZE_GUIDELINE_AGENT_CAPS = Object.freeze({
5
- small: 5,
6
- medium: 15,
7
- large: 50,
8
- });
5
+ export const WORKFLOW_SIZE_GUIDELINE_AGENT_CAPS = CORE_WORKFLOW_SIZE_GUIDELINE_AGENT_CAPS;
9
6
  export const WORKFLOW_SIZE_WARNING_ENV_NAMES = Object.freeze({
10
7
  agents: Object.freeze(['SEMA_CODE_WORKFLOW_SIZE_WARNING_AGENTS', 'CLAUDE_CODE_WORKFLOW_SIZE_WARNING_AGENTS']),
11
8
  tokens: Object.freeze(['SEMA_CODE_WORKFLOW_SIZE_WARNING_TOKENS', 'CLAUDE_CODE_WORKFLOW_SIZE_WARNING_TOKENS']),
@@ -3,9 +3,13 @@ import { type CcToolDenialKind } from './gateVocabulary.js';
3
3
  export type GateDispositionView = {
4
4
  kind: 'allowed';
5
5
  classifier?: GateClassifierRoundView;
6
+ released?: GateModeReleaseView;
6
7
  } | {
7
8
  kind: 'denied';
8
9
  classifier?: GateClassifierRoundView;
10
+ mode?: string;
11
+ askClass?: string;
12
+ classes?: readonly string[];
9
13
  deniedBy: DeniedBy | (string & {});
10
14
  cause?: string;
11
15
  };
@@ -19,6 +23,14 @@ export interface GateClassifierFallbackView {
19
23
  to: string;
20
24
  cause: string;
21
25
  }
26
+ export interface GateModeReleaseView {
27
+ mode: string;
28
+ askClass: string;
29
+ classes: readonly string[];
30
+ origin?: string;
31
+ mandate?: string;
32
+ reason?: string;
33
+ }
22
34
  export interface SettlementWhoView {
23
35
  party: string;
24
36
  approver?: string;
@@ -38,6 +50,7 @@ export interface GateOutcomeView {
38
50
  }
39
51
  export declare function gateOutcomeOf(frame: unknown): GateOutcomeView | undefined;
40
52
  export declare function isGateParkedToolEnd(frame: unknown): boolean;
53
+ export declare function gateModeRelease(g: GateOutcomeView | undefined): GateModeReleaseView | undefined;
41
54
  export declare function isDeniedGate(g: GateOutcomeView | undefined): boolean;
42
55
  export declare function gateDeniedBy(g: GateOutcomeView | undefined): string | undefined;
43
56
  export declare function gateApprover(g: GateOutcomeView | undefined): string | undefined;