@sema-agent/client-core 0.107.0 → 0.108.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 (98) hide show
  1. package/CHANGELOG.md +118 -0
  2. package/README.md +19 -14
  3. package/dist/adapter/activeRunSelfHeal.d.ts +2 -0
  4. package/dist/adapter/activeRunSelfHeal.js +20 -3
  5. package/dist/checkpointRowVerdict.d.ts +5 -0
  6. package/dist/checkpointRowVerdict.js +26 -0
  7. package/dist/cloudConfigWireCaps.d.ts +10 -0
  8. package/dist/cloudConfigWireCaps.js +33 -0
  9. package/dist/coreValuePorts.d.ts +17 -1
  10. package/dist/coreValuePorts.js +5 -0
  11. package/dist/decideReceipt.js +2 -1
  12. package/dist/engineErrorCodes.d.ts +5 -0
  13. package/dist/engineErrorCodes.js +5 -0
  14. package/dist/engineNoticeCodes.d.ts +19 -1
  15. package/dist/engineNoticeCodes.js +65 -3
  16. package/dist/engineTargetSeat.js +1 -0
  17. package/dist/errorSupplementRoles.js +2 -0
  18. package/dist/eventLeg.js +1 -1
  19. package/dist/executionLaneWords.js +2 -1
  20. package/dist/gateOutcome.d.ts +10 -1
  21. package/dist/gateOutcome.js +48 -1
  22. package/dist/generated/engineFactTables.d.ts +1 -0
  23. package/dist/generated/engineFactTables.js +5 -0
  24. package/dist/generated/engineNoticeTables.js +3 -0
  25. package/dist/generated/settingsSchemaFns.d.ts +4 -2
  26. package/dist/generated/settingsSchemaFns.js +9 -3
  27. package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -1
  28. package/dist/generated/settingsSchemaMcpRequestEntry.js +9 -18
  29. package/dist/generated/settingsSchemaReservedMemberName.d.ts +1 -0
  30. package/dist/generated/settingsSchemaReservedMemberName.js +7 -0
  31. package/dist/generated/settingsSchemaTables.d.ts +2 -0
  32. package/dist/generated/settingsSchemaTables.js +10 -0
  33. package/dist/generated/settingsSchemaWireName.d.ts +1 -0
  34. package/dist/generated/settingsSchemaWireName.js +8 -0
  35. package/dist/headlessReconnectWire.js +12 -7
  36. package/dist/hitl/approvalAskers.d.ts +13 -0
  37. package/dist/hitl/approvalAskers.js +79 -0
  38. package/dist/hitl/approvalResolution.d.ts +3 -0
  39. package/dist/hitl/approvalResolution.js +22 -4
  40. package/dist/hitl/approvalsFeed.js +3 -12
  41. package/dist/hitl/askParkRowRouting.js +5 -1
  42. package/dist/hitl/decisionRefusal.d.ts +1 -0
  43. package/dist/hitl/decisionRefusal.js +5 -2
  44. package/dist/hitl/decisionSend.js +2 -6
  45. package/dist/hitl/frameRouter.d.ts +3 -2
  46. package/dist/hitl/frameRouter.js +28 -6
  47. package/dist/hitl/gateLedger.d.ts +2 -0
  48. package/dist/hitl/gateLedger.js +3 -1
  49. package/dist/hitl/hitlBridge.js +2 -3
  50. package/dist/hitl/parkResolver.js +32 -23
  51. package/dist/hitl/parkRowBirthWait.d.ts +2 -0
  52. package/dist/hitl/parkRowBirthWait.js +8 -1
  53. package/dist/hitl/persistedRulesWire.d.ts +5 -1
  54. package/dist/hitl/persistedRulesWire.js +20 -4
  55. package/dist/hitl/planReviewWire.js +12 -16
  56. package/dist/hitl/policyDenyCause.d.ts +3 -0
  57. package/dist/hitl/policyDenyCause.js +16 -0
  58. package/dist/hitl/sessionPolicyDeliverable.js +1 -1
  59. package/dist/hitl/toolApprovalWire.d.ts +8 -2
  60. package/dist/hitl/toolApprovalWire.js +22 -3
  61. package/dist/hooksReaderGenerations.d.ts +1 -0
  62. package/dist/hooksReaderGenerations.js +12 -0
  63. package/dist/hooksWireCaps.js +8 -4
  64. package/dist/i18n/messages.en.d.ts +38 -1
  65. package/dist/i18n/messages.en.js +40 -3
  66. package/dist/i18n/messages.zh.js +45 -3
  67. package/dist/index.d.ts +6 -1
  68. package/dist/index.js +4 -1
  69. package/dist/liveModelCatalog.d.ts +4 -2
  70. package/dist/liveModelCatalog.js +164 -26
  71. package/dist/model/catalogDefault.d.ts +25 -0
  72. package/dist/model/catalogDefault.js +44 -0
  73. package/dist/permissionWireCaps.d.ts +1 -0
  74. package/dist/permissionWireCaps.js +11 -0
  75. package/dist/pluginHooksWire.d.ts +5 -3
  76. package/dist/pluginHooksWire.js +116 -7
  77. package/dist/queuedDelivery.d.ts +1 -0
  78. package/dist/queuedDelivery.js +12 -0
  79. package/dist/resultFrameKeys.js +4 -2
  80. package/dist/resumeRefusalCopy.js +15 -8
  81. package/dist/runPermissionModeSwitch.d.ts +2 -1
  82. package/dist/runPermissionModeSwitch.js +16 -6
  83. package/dist/seatContract.d.ts +63 -10
  84. package/dist/seatContract.js +164 -11
  85. package/dist/sessionEngine.d.ts +2 -1
  86. package/dist/sessionEngine.js +5 -0
  87. package/dist/settingsHooksSalvage.d.ts +5 -0
  88. package/dist/settingsHooksSalvage.js +54 -0
  89. package/dist/subagentContentStore.js +1 -1
  90. package/dist/supportFloor.js +2 -0
  91. package/dist/taskNotificationAdmission.d.ts +19 -0
  92. package/dist/taskNotificationAdmission.js +84 -0
  93. package/dist/toolResult.js +2 -1
  94. package/dist/webSearchWireCaps.js +9 -4
  95. package/dist/wireRefusalCopy.d.ts +2 -1
  96. package/dist/wireRefusalCopy.js +2 -2
  97. package/docs/INTEGRATION-CLIENTS.md +816 -14
  98. package/package.json +4 -4
@@ -1,3 +1,4 @@
1
+ import { type UiLanguage } from './env/uiLanguage.js';
1
2
  export type CheckpointRowVerdictReading = {
2
3
  readonly kind: 'ok';
3
4
  } | {
@@ -27,3 +28,7 @@ export type CheckpointRowBar = Exclude<CheckpointRowVerdictReading, {
27
28
  export declare function checkpointRowBarOf(row: object | null | undefined): CheckpointRowBar | undefined;
28
29
  export declare const CHECKPOINT_ROW_BAR_SENTENCE: string;
29
30
  export declare function checkpointRowBarSentence(bar: CheckpointRowBar): string;
31
+ export type CheckpointDeadlineState = 'armed' | 'none' | 'unknown';
32
+ export declare function checkpointDeadlineStateOf(row: object | null | undefined): CheckpointDeadlineState;
33
+ export declare function unboundWayOutContent(state: CheckpointDeadlineState, lang?: UiLanguage | (string & {})): string;
34
+ export declare function rowBarWayOutContent(bar: CheckpointRowBar, state: CheckpointDeadlineState, lang?: UiLanguage | (string & {})): string;
@@ -1,5 +1,6 @@
1
1
  import { readErrorString, slotReadOf } from './wireFailureShape.js';
2
2
  import { msg, renderMessage } from './i18n/translate.js';
3
+ import { isUiLanguage } from './env/uiLanguage.js';
3
4
  const UNREADABLE = Object.freeze({ kind: 'unreadable' });
4
5
  const OK = Object.freeze({ kind: 'ok' });
5
6
  function ownNonEmptyString(o, key) {
@@ -96,3 +97,28 @@ export const CHECKPOINT_ROW_BAR_SENTENCE = renderMessage(msg('approval.rowUnresu
96
97
  export function checkpointRowBarSentence(bar) {
97
98
  return bar.kind !== 'unreadable' && typeof bar.sentence === 'string' && bar.sentence !== '' ? bar.sentence : CHECKPOINT_ROW_BAR_SENTENCE;
98
99
  }
100
+ export function checkpointDeadlineStateOf(row) {
101
+ try {
102
+ if (typeof row !== 'object' || row === null)
103
+ return 'unknown';
104
+ const r = slotReadOf(row, 'deadline');
105
+ if (r.presence !== 'present')
106
+ return 'unknown';
107
+ const v = r.value;
108
+ if (v === null)
109
+ return 'none';
110
+ return typeof v === 'number' && Number.isFinite(v) && v >= 0 ? 'armed' : 'unknown';
111
+ }
112
+ catch {
113
+ return 'unknown';
114
+ }
115
+ }
116
+ export function unboundWayOutContent(state, lang) {
117
+ const key = state === 'armed' ? 'approval.decide.unboundWayOut.armed' : state === 'none' ? 'approval.decide.unboundWayOut.none' : 'approval.decide.unboundWayOut.unknown';
118
+ return renderMessage(msg(key), isUiLanguage(lang) ? lang : undefined);
119
+ }
120
+ export function rowBarWayOutContent(bar, state, lang) {
121
+ if (bar.kind === 'lacking')
122
+ return renderMessage(msg('approval.rowUnresumable.lackingWayOut'), isUiLanguage(lang) ? lang : undefined);
123
+ return unboundWayOutContent(state, lang);
124
+ }
@@ -63,6 +63,15 @@ export interface CloudExecutionProjection {
63
63
  }
64
64
  export declare function cloudExecutionToPolicy(execution: unknown): CloudExecutionProjection;
65
65
  export declare function cloudRosterNames(rostersValue: unknown): string[];
66
+ export type CloudA2aReading = {
67
+ readonly kind: 'present';
68
+ readonly peerNames: readonly string[];
69
+ readonly unreadableRows: number;
70
+ } | {
71
+ readonly kind: 'absent';
72
+ } | {
73
+ readonly kind: 'unreadable';
74
+ };
66
75
  export interface CloudEffectiveWarning {
67
76
  readonly kind: string;
68
77
  readonly domain?: string;
@@ -137,6 +146,7 @@ export interface CloudProjection {
137
146
  budget: CloudBudgetReading;
138
147
  runtimeCaps: CloudRuntimeCapsReading;
139
148
  modelRefIssues: CloudModelRefIssue[];
149
+ a2a: CloudA2aReading;
140
150
  }
141
151
  export declare function projectEffectiveBody(body: unknown, skillBodies: Record<string, string>, env: EnvLike, rostersValue?: unknown, opts?: CloudModelsDocOptions, skills?: CloudSkillsOptions): CloudProjection;
142
152
  export interface CloudEffectiveNotice {
@@ -1,6 +1,7 @@
1
1
  import { mcpAllowToolsVerdict, mcpAssertionHeaderNotSentNotice, mcpElicitationVerdict, mcpToolAxesVerdict, mcpToolFacesVerdict, readMcpHttpIdentityHeaders } from './mcpWireCaps.js';
2
2
  import { skillToolListsVerdict, toCappedSpec } from './skillsWireCaps.js';
3
3
  import { SETTINGS_DESCRIBE_BAD_MCP_SERVER_NAME, SETTINGS_IS_USABLE_MCP_SERVER_NAME, SETTINGS_READ_REQUEST_MCP_TRANSPORT } from './generated/settingsSchemaFns.js';
4
+ import { SETTINGS_IS_USABLE_WIRE_NAME } from './generated/settingsSchemaFns.js';
4
5
  import { snapshotArgs, wireTransportOf } from './mcpWireTransport.js';
5
6
  import { msg, renderMessage } from './i18n/translate.js';
6
7
  import { TIER_ORDER } from './model/tierVocabulary.js';
@@ -8,6 +9,7 @@ import { SETTINGS_NARROW_AT_MENTION } from './generated/settingsSchemaFns.js';
8
9
  import { modelsPolicyOf } from './model/modelsPolicy.js';
9
10
  import { normalizeEngineBaseUrl } from './engineUrl.js';
10
11
  import { guardedRead, readOwnDataNonEmptyString, readOwnDataValue } from './ownKey.js';
12
+ import { slotReadOf } from './wireFailureShape.js';
11
13
  import { capForDisplay } from './fleetTaskDesc.js';
12
14
  import { SETTINGS_BUDGET_NUMBER_KEYS, SETTINGS_BUDGET_PER_MODEL_NUMBER_KEYS, SETTINGS_BUDGET_STRING_KEYS, SETTINGS_TIER_GROUP_NAME_RE, } from './generated/settingsSchemaTables.js';
13
15
  const asRec = (v) => (typeof v === 'object' && v !== null && !Array.isArray(v) ? v : undefined);
@@ -535,6 +537,36 @@ export function cloudRosterNames(rostersValue) {
535
537
  .map((e) => asStr(asRec(e)?.name))
536
538
  .filter((n) => !!n);
537
539
  }
540
+ function cloudA2aOf(body) {
541
+ const cfg = slotReadOf(body, 'config');
542
+ const config = cfg.presence === 'present' ? guardedRead(() => asRec(cfg.value)) : undefined;
543
+ if (config === undefined)
544
+ return { kind: 'unreadable' };
545
+ const slot = slotReadOf(config, 'a2a');
546
+ if (slot.presence === 'absent')
547
+ return { kind: 'absent' };
548
+ const domain = slot.presence === 'present' ? guardedRead(() => asRec(slot.value)) : undefined;
549
+ if (domain === undefined)
550
+ return { kind: 'unreadable' };
551
+ const peersSlot = slotReadOf(domain, 'peers');
552
+ if (peersSlot.presence === 'absent')
553
+ return { kind: 'present', peerNames: [], unreadableRows: 0 };
554
+ const peers = peersSlot.presence === 'present' ? guardedRead(() => (Array.isArray(peersSlot.value) ? peersSlot.value : undefined)) : undefined;
555
+ const count = peers === undefined ? undefined : guardedRead(() => readOwnDataValue(peers, 'length'));
556
+ if (peers === undefined || typeof count !== 'number' || !Number.isSafeInteger(count) || count < 0)
557
+ return { kind: 'unreadable' };
558
+ const peerNames = [];
559
+ let unreadableRows = 0;
560
+ for (let i = 0; i < count; i++) {
561
+ const row = guardedRead(() => readOwnDataValue(peers, String(i)));
562
+ const name = typeof row === 'object' && row !== null ? guardedRead(() => readOwnDataValue(row, 'name')) : undefined;
563
+ if (typeof name === 'string' && SETTINGS_IS_USABLE_WIRE_NAME(name))
564
+ peerNames.push(name);
565
+ else
566
+ unreadableRows += 1;
567
+ }
568
+ return { kind: 'present', peerNames, unreadableRows };
569
+ }
538
570
  const BUDGET_NUMBER_KEYS = SETTINGS_BUDGET_NUMBER_KEYS;
539
571
  const BUDGET_STRING_KEYS = SETTINGS_BUDGET_STRING_KEYS;
540
572
  const PER_MODEL_NUMBER_KEYS = SETTINGS_BUDGET_PER_MODEL_NUMBER_KEYS;
@@ -702,6 +734,7 @@ export function projectEffectiveBody(body, skillBodies, env, rostersValue, opts,
702
734
  budget: budgetOf(b, view),
703
735
  runtimeCaps: runtimeCapsOf(b, view),
704
736
  modelRefIssues,
737
+ a2a: cloudA2aOf(b),
705
738
  };
706
739
  }
707
740
  const quoted = (s, fallback) => (s === undefined ? fallback : `the "${s}" settings`);
@@ -153,6 +153,7 @@ export interface CoreValuePorts {
153
153
  IMPORTED_SETTINGS_LAYERS: readonly ['userSettings', 'projectSettings', 'localSettings'];
154
154
  runParkedOf(run: WorkflowRunParkedInputView): boolean;
155
155
  parkedAgentsOf(agents: ReadonlyArray<WorkflowAgentStatusView>): WorkflowAgentStatusView[];
156
+ modelFaceResolvable(face: object, options?: ModelFaceOptionsView): ModelFaceVerdictView;
156
157
  }
157
158
  export interface WorkflowAgentStatusView {
158
159
  readonly status: string;
@@ -161,7 +162,21 @@ export interface WorkflowRunParkedInputView {
161
162
  readonly status: string;
162
163
  readonly agents: ReadonlyArray<WorkflowAgentStatusView>;
163
164
  }
164
- export declare const CORE_VALUE_PORT_NAMES: readonly ["resolveAutonomousLoopPrompt", "loosenReasons", "combinePolicies", "createAllowDenyPolicy", "MCP_NAMESPACE", "protocolOf", "ruleToolGrammarOf", "validatePermissionRules", "mintNamespacePrefix", "compileAllowList", "routeKeyOf", "joinRequestUrl", "resolveRouteCredential", "adjudicateModelRoute", "routePairingStatus", "judgeRuleToolName", "readRuleEntry", "readMcpToolAxes", "ANTHROPIC_DEFAULT_BASE_URL", "readToolFaces", "ruleNameCovers", "IMPORTED_SETTINGS_LAYERS", "runParkedOf", "parkedAgentsOf"];
165
+ export interface ModelFaceOptionsView {
166
+ readonly spec?: {
167
+ readonly model?: string | object;
168
+ readonly modelRole?: string;
169
+ };
170
+ readonly when?: readonly ('per-task' | 'deployment')[];
171
+ }
172
+ export type ModelFaceVerdictView = {
173
+ readonly ok: true;
174
+ } | {
175
+ readonly ok: false;
176
+ readonly role: string;
177
+ readonly code: string;
178
+ };
179
+ export declare const CORE_VALUE_PORT_NAMES: readonly ["resolveAutonomousLoopPrompt", "loosenReasons", "combinePolicies", "createAllowDenyPolicy", "MCP_NAMESPACE", "protocolOf", "ruleToolGrammarOf", "validatePermissionRules", "mintNamespacePrefix", "compileAllowList", "routeKeyOf", "joinRequestUrl", "resolveRouteCredential", "adjudicateModelRoute", "routePairingStatus", "judgeRuleToolName", "readRuleEntry", "readMcpToolAxes", "ANTHROPIC_DEFAULT_BASE_URL", "readToolFaces", "ruleNameCovers", "IMPORTED_SETTINGS_LAYERS", "runParkedOf", "parkedAgentsOf", "modelFaceResolvable"];
165
180
  export type CoreValuePortName = (typeof CORE_VALUE_PORT_NAMES)[number];
166
181
  export declare function installCoreValuePorts(ports: Partial<CoreValuePorts> | null): () => void;
167
182
  export declare function hasCoreValuePorts(): boolean;
@@ -195,3 +210,4 @@ export declare function ruleNameCovers(ruleName: string, toolName: string): bool
195
210
  export declare function importedSettingsLayers(): CoreValuePorts['IMPORTED_SETTINGS_LAYERS'] | undefined;
196
211
  export declare function runParkedOf(run: WorkflowRunParkedInputView): boolean | undefined;
197
212
  export declare function parkedAgentsOf(agents: ReadonlyArray<WorkflowAgentStatusView>): WorkflowAgentStatusView[] | undefined;
213
+ export declare function modelFaceResolvable(face: object, options?: ModelFaceOptionsView): ModelFaceVerdictView | undefined;
@@ -23,6 +23,7 @@ export const CORE_VALUE_PORT_NAMES = Object.freeze([
23
23
  'IMPORTED_SETTINGS_LAYERS',
24
24
  'runParkedOf',
25
25
  'parkedAgentsOf',
26
+ 'modelFaceResolvable',
26
27
  ]);
27
28
  let installed = null;
28
29
  export function installCoreValuePorts(ports) {
@@ -137,3 +138,7 @@ export function parkedAgentsOf(agents) {
137
138
  const fn = port('parkedAgentsOf');
138
139
  return fn === undefined ? undefined : fn(agents);
139
140
  }
141
+ export function modelFaceResolvable(face, options) {
142
+ const fn = port('modelFaceResolvable');
143
+ return fn === undefined ? undefined : fn(face, options);
144
+ }
@@ -9,6 +9,7 @@ import { askRowEndingCauseFor } from './hitl/approvalEndingCause.js';
9
9
  import { SDK_DECIDE_BINDING_KEYS } from './generated/sdkFactTables.js';
10
10
  import { isUiLanguage } from './env/uiLanguage.js';
11
11
  import { msg, renderMessage } from './i18n/translate.js';
12
+ import { unboundWayOutContent } from './checkpointRowVerdict.js';
12
13
  const STATUS_RESUMING = 'resuming';
13
14
  function str(v) {
14
15
  return typeof v === 'string' && v.length > 0 ? v : undefined;
@@ -162,7 +163,7 @@ export function decideRequiresBindingFromError(e) {
162
163
  }
163
164
  }
164
165
  export function decideRequiresBindingContent(_detail, lang) {
165
- return renderMessage(msg('approval.decide.requiresBinding', { wayOut: msg('approval.decide.unboundWayOut') }), isUiLanguage(lang) ? lang : undefined);
166
+ return renderMessage(msg('approval.decide.requiresBinding', { wayOut: unboundWayOutContent('unknown', lang) }), isUiLanguage(lang) ? lang : undefined);
166
167
  }
167
168
  function askGoneRawCause(e) {
168
169
  let top;
@@ -99,6 +99,11 @@ export declare function refusalSaysStillPending(err: object): boolean;
99
99
  export declare function refusalRetriableReading(err: object): boolean | undefined;
100
100
  export type StatusDerivedCoarseCode = (typeof SDK_STATUS_DERIVED_COARSE_CODES)[number];
101
101
  export declare const RESUME_PLACEMENT_MISMATCH = "resume.placement_mismatch";
102
+ export declare const RESUME_PRINCIPAL_MISMATCH = "resume.principal_mismatch";
103
+ export declare const RESUME_COMPOSITION_MISMATCH = "resume.composition_mismatch";
104
+ export declare const RESUME_PARENT_CONSTRAINT_MISSING = "resume.parent_constraint_missing";
105
+ export declare const RESUME_PARENT_CONSTRAINT_MISMATCH = "resume.parent_constraint_mismatch";
106
+ export declare const RESUME_CONSTRAINT_UNPROJECTABLE = "resume.constraint_unprojectable";
102
107
  export declare const RESUME_CONTEXT_UNAVAILABLE = "conflict.resume_context_unavailable";
103
108
  export declare const RESUME_RETRY_LATER_CODES: readonly string[];
104
109
  export declare const RESUME_ENV_FAILED = "resume.env_failed";
@@ -177,6 +177,11 @@ export function refusalRetriableReading(err) {
177
177
  }
178
178
  }
179
179
  export const RESUME_PLACEMENT_MISMATCH = 'resume.placement_mismatch';
180
+ export const RESUME_PRINCIPAL_MISMATCH = 'resume.principal_mismatch';
181
+ export const RESUME_COMPOSITION_MISMATCH = 'resume.composition_mismatch';
182
+ export const RESUME_PARENT_CONSTRAINT_MISSING = 'resume.parent_constraint_missing';
183
+ export const RESUME_PARENT_CONSTRAINT_MISMATCH = 'resume.parent_constraint_mismatch';
184
+ export const RESUME_CONSTRAINT_UNPROJECTABLE = 'resume.constraint_unprojectable';
180
185
  export const RESUME_CONTEXT_UNAVAILABLE = 'conflict.resume_context_unavailable';
181
186
  export const RESUME_RETRY_LATER_CODES = Object.freeze([
182
187
  RESUME_USAGE_WINDOW_EXHAUSTED,
@@ -14,9 +14,23 @@ export interface McpInjectionDropFactsView {
14
14
  field?: string;
15
15
  }
16
16
  export declare function readMcpInjectionDrop(notice: unknown): McpInjectionDropFactsView | undefined;
17
+ export type NoticeLegView = {
18
+ readonly kind: 'self';
19
+ } | {
20
+ readonly kind: 'delegated';
21
+ readonly sourceSessionId: string;
22
+ readonly agentId?: string;
23
+ } | {
24
+ readonly kind: 'unreadable';
25
+ };
26
+ export declare function noticeCallSessionOf(facts: {
27
+ readonly sessionId?: string | undefined;
28
+ readonly leg: NoticeLegView;
29
+ }): string | undefined;
17
30
  export declare const ASK_UNRESOLVABLE_CAUSES: readonly string[];
18
31
  export interface AskUnresolvableFactsView {
19
32
  sessionId: string;
33
+ leg: NoticeLegView;
20
34
  toolName: string;
21
35
  toolCallId: string;
22
36
  cause: string;
@@ -108,6 +122,7 @@ export interface ClassifierUnavailableFactsView {
108
122
  disposition: ClassifierUnavailableDispositionWord;
109
123
  sessionId?: string;
110
124
  runId?: string;
125
+ leg: NoticeLegView;
111
126
  }
112
127
  export declare function readClassifierUnavailable(notice: unknown): ClassifierUnavailableFactsView | undefined;
113
128
  export declare const PERMISSION_MODE_FOLD_REASONS: readonly string[];
@@ -129,6 +144,7 @@ export interface AskReleasedByModeFactsView {
129
144
  firstToolCallId: string;
130
145
  sessionId?: string;
131
146
  runId?: string;
147
+ leg: NoticeLegView;
132
148
  }
133
149
  export declare function readAskReleasedByMode(notice: unknown): AskReleasedByModeFactsView | undefined;
134
150
  export interface ReadDenyUnappliedFactsView {
@@ -139,6 +155,7 @@ export interface ReadDenyUnappliedFactsView {
139
155
  rowCount: number;
140
156
  sessionId: string;
141
157
  runId: string;
158
+ leg: NoticeLegView;
142
159
  }
143
160
  export declare function readReadDenyUnapplied(notice: unknown): ReadDenyUnappliedFactsView | undefined;
144
161
  export interface ToolTurnRepairView {
@@ -198,6 +215,7 @@ export interface UserInputUndrainedFactsView {
198
215
  runId?: string;
199
216
  childSessionId?: string;
200
217
  inputIds?: readonly string[];
218
+ inputKind?: 'steer' | 'approval_feedback';
201
219
  }
202
220
  export declare function readUserInputUndrained(notice: unknown): UserInputUndrainedFactsView | undefined;
203
221
  export interface UndrainedInputsLedger {
@@ -210,7 +228,7 @@ export interface UndrainedInputsVerdict {
210
228
  readonly unattributed: number;
211
229
  }
212
230
  export declare function undrainedInputsVerdict(facts: Pick<UserInputUndrainedFactsView, 'count' | 'cause' | 'inputIds' | 'childSessionId'> | null | undefined, ledger: UndrainedInputsLedger | null | undefined): UndrainedInputsVerdict | undefined;
213
- export declare function userInputUndrainedNotice(facts: Pick<UserInputUndrainedFactsView, 'kind' | 'count' | 'cause' | 'childSessionId'>): string | undefined;
231
+ export declare function userInputUndrainedNotice(facts: Pick<UserInputUndrainedFactsView, 'kind' | 'count' | 'cause' | 'childSessionId' | 'inputKind'>, lang?: UiLanguage): string | undefined;
214
232
  export interface TurnInterruptedFactsView {
215
233
  lane: 'input_now' | 'user_halt' | 'unrecognized';
216
234
  inputId?: string;
@@ -4,6 +4,7 @@ import { CORE_ENGINE_NOTICE_CODES, CORE_MCP_INJECTION_DROP_REASONS, CORE_NOTICE_
4
4
  import { CORE_APPROVAL_REMEDY_KINDS, CORE_ASK_UNRESOLVABLE_CAUSES, CORE_DURABLE_MANDATE_SOURCES, CORE_PERMISSION_MODE_FOLD_REASONS, } from './generated/engineFactTables.js';
5
5
  import { msg, renderMessage } from './i18n/translate.js';
6
6
  import { ownDataField, readOwnDataValue } from './ownKey.js';
7
+ import { slotReadOf } from './wireFailureShape.js';
7
8
  export const ENGINE_NOTICE_CODES = CORE_ENGINE_NOTICE_CODES;
8
9
  const CATALOG = new Set(ENGINE_NOTICE_CODES);
9
10
  function audienceRow(table, code) {
@@ -43,6 +44,46 @@ export function readMcpInjectionDrop(notice) {
43
44
  const field = typeof fieldIn === 'string' && fieldIn.length > 0 ? fieldIn : undefined;
44
45
  return { sessionId, server, reason, ...(field !== undefined ? { field } : {}) };
45
46
  }
47
+ const LEG_SELF = Object.freeze({ kind: 'self' });
48
+ const LEG_UNREADABLE = Object.freeze({ kind: 'unreadable' });
49
+ function readNoticeLeg(detail) {
50
+ try {
51
+ const source = slotReadOf(detail, 'sourceSessionId');
52
+ const agent = slotReadOf(detail, 'agentId');
53
+ if (source.presence === 'absent')
54
+ return agent.presence === 'absent' ? LEG_SELF : LEG_UNREADABLE;
55
+ if (source.presence !== 'present' || typeof source.value !== 'string' || source.value.length === 0)
56
+ return LEG_UNREADABLE;
57
+ const agentId = agent.presence === 'present' && typeof agent.value === 'string' && agent.value.length > 0 ? agent.value : undefined;
58
+ return Object.freeze({ kind: 'delegated', sourceSessionId: source.value, ...(agentId !== undefined ? { agentId } : {}) });
59
+ }
60
+ catch {
61
+ return LEG_UNREADABLE;
62
+ }
63
+ }
64
+ export function noticeCallSessionOf(facts) {
65
+ const str = (o, key) => {
66
+ const s = slotReadOf(o, key);
67
+ return s.presence === 'present' && typeof s.value === 'string' && s.value.length > 0 ? s.value : undefined;
68
+ };
69
+ try {
70
+ if (typeof facts !== 'object' || facts === null)
71
+ return undefined;
72
+ const legSlot = slotReadOf(facts, 'leg');
73
+ const leg = legSlot.presence === 'present' ? legSlot.value : undefined;
74
+ if (typeof leg !== 'object' || leg === null)
75
+ return undefined;
76
+ const kind = str(leg, 'kind');
77
+ if (kind === 'delegated')
78
+ return str(leg, 'sourceSessionId');
79
+ if (kind !== 'self')
80
+ return undefined;
81
+ return str(facts, 'sessionId');
82
+ }
83
+ catch {
84
+ return undefined;
85
+ }
86
+ }
46
87
  export const ASK_UNRESOLVABLE_CAUSES = CORE_ASK_UNRESOLVABLE_CAUSES;
47
88
  const ASK_UNRESOLVABLE_CAUSE_SET = new Set(ASK_UNRESOLVABLE_CAUSES);
48
89
  function optionalSeat(o, key) {
@@ -111,6 +152,9 @@ export function askUnresolvableRemedyContent(remedy, lang) {
111
152
  return renderMessage(msg('notice.askUnresolvable.remedy.permissionMode', { mode: displayUntrusted(r.value, { max: 64 }) }), lang);
112
153
  }
113
154
  export function readAskUnresolvable(notice) {
155
+ return guardedRead(notice, readAskUnresolvableOf);
156
+ }
157
+ function readAskUnresolvableOf(notice) {
114
158
  if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
115
159
  return undefined;
116
160
  const n = notice;
@@ -131,7 +175,7 @@ export function readAskUnresolvable(notice) {
131
175
  if (sessionId === undefined || toolName === undefined || toolCallId === undefined || cause === undefined) {
132
176
  return undefined;
133
177
  }
134
- const parkIn = o.parkLaneExisted;
178
+ const parkIn = optionalSeat(o, 'parkLaneExisted');
135
179
  const remedyIn = optionalSeat(o, 'remedy');
136
180
  let remedies;
137
181
  try {
@@ -148,6 +192,7 @@ export function readAskUnresolvable(notice) {
148
192
  ...(typeof parkIn === 'boolean' ? { parkLaneExisted: parkIn } : {}),
149
193
  ...(typeof remedyIn === 'string' && remedyIn.length > 0 ? { remedy: remedyIn } : {}),
150
194
  ...(remedies !== undefined ? { remedies } : {}),
195
+ leg: readNoticeLeg(o),
151
196
  };
152
197
  }
153
198
  export const DURABLE_MANDATE_SOURCES = CORE_DURABLE_MANDATE_SOURCES;
@@ -433,6 +478,7 @@ function readClassifierUnavailableOf(notice) {
433
478
  disposition,
434
479
  ...(sessionId !== undefined ? { sessionId } : {}),
435
480
  ...(runId !== undefined ? { runId } : {}),
481
+ leg: readNoticeLeg(o),
436
482
  };
437
483
  }
438
484
  export const PERMISSION_MODE_FOLD_REASONS = CORE_PERMISSION_MODE_FOLD_REASONS;
@@ -495,6 +541,7 @@ function readAskReleasedByModeOf(notice) {
495
541
  firstToolCallId,
496
542
  ...(sessionId !== undefined ? { sessionId } : {}),
497
543
  ...(runId !== undefined ? { runId } : {}),
544
+ leg: readNoticeLeg(o),
498
545
  };
499
546
  }
500
547
  export function readReadDenyUnapplied(notice) {
@@ -521,7 +568,7 @@ function readReadDenyUnappliedOf(notice) {
521
568
  rowCount === undefined || sessionId === undefined || runId === undefined) {
522
569
  return undefined;
523
570
  }
524
- return { mode, toolCallId, tiers, rows, rowCount, sessionId, runId };
571
+ return { mode, toolCallId, tiers, rows, rowCount, sessionId, runId, leg: readNoticeLeg(o) };
525
572
  }
526
573
  export function readToolTurnRepaired(notice) {
527
574
  return guardedRead(notice, readToolTurnRepairedOf);
@@ -695,6 +742,9 @@ function optionalNonEmpty(o, key) {
695
742
  return undefined;
696
743
  }
697
744
  }
745
+ function undrainedInputKindOf(v) {
746
+ return v === 'steer' || v === 'approval_feedback' ? v : undefined;
747
+ }
698
748
  export function readUserInputUndrained(notice) {
699
749
  return guardedRead(notice, readUserInputUndrainedOf);
700
750
  }
@@ -726,6 +776,7 @@ function readUserInputUndrainedOf(notice) {
726
776
  const taskId = nonEmpty(optionalOwnSeat(o, 'taskId'));
727
777
  const sessionId = nonEmpty(optionalOwnSeat(o, 'sessionId'));
728
778
  const runId = nonEmpty(optionalOwnSeat(o, 'runId'));
779
+ const inputKind = kind === 'steer' ? undrainedInputKindOf(optionalOwnSeat(o, 'kind')) : undefined;
729
780
  const childSeat = ownSeatOrUnreadable(o, 'childSessionId');
730
781
  const childSessionId = nonEmpty(childSeat);
731
782
  const childSeatProven = childSeat === undefined || childSessionId !== undefined;
@@ -739,6 +790,7 @@ function readUserInputUndrainedOf(notice) {
739
790
  ...(runId !== undefined ? { runId } : {}),
740
791
  ...(childSessionId !== undefined ? { childSessionId } : {}),
741
792
  ...(inputIds !== undefined ? { inputIds } : {}),
793
+ ...(inputKind !== undefined ? { inputKind } : {}),
742
794
  };
743
795
  }
744
796
  function exactInputIdList(v, count) {
@@ -849,11 +901,12 @@ const subagentFollowUpUndrainedSentence = (n) => `${messagesPhrase(n, 'follow-up
849
901
  `Send ${itThem(n)} again if you still need ${itThem(n)}.`;
850
902
  const unrecognizedUndrainedSentence = (n, kind) => `${kind === 'followUp' ? `${messagesPhrase(n, 'follow-up message')} you queued` : `${messagesPhrase(n, 'message')} you sent during a run`} may not have been used, ` +
851
903
  `and the reason was not reported in a form this version recognizes. Check the run's transcript before sending ${itThem(n)} again.`;
852
- export function userInputUndrainedNotice(facts) {
904
+ export function userInputUndrainedNotice(facts, lang) {
853
905
  let kind;
854
906
  let count;
855
907
  let cause;
856
908
  let child;
909
+ let inputKind;
857
910
  try {
858
911
  if (facts === null || typeof facts !== 'object' || Array.isArray(facts))
859
912
  return undefined;
@@ -871,6 +924,12 @@ export function userInputUndrainedNotice(facts) {
871
924
  child = undefined;
872
925
  }
873
926
  const fromSubagent = typeof child === 'string' && child.length > 0;
927
+ try {
928
+ inputKind = Object.hasOwn(facts, 'inputKind') ? facts.inputKind : undefined;
929
+ }
930
+ catch {
931
+ inputKind = undefined;
932
+ }
874
933
  const n = positiveInt(count);
875
934
  if (n === undefined || !isUndrainedLane(kind))
876
935
  return undefined;
@@ -879,6 +938,9 @@ export function userInputUndrainedNotice(facts) {
879
938
  return fromSubagent ? subagentFollowUpUndrainedSentence(n) : followUpUndrainedSentence(n);
880
939
  return unrecognizedUndrainedSentence(n, kind);
881
940
  }
941
+ if (cause === 'leg_end' && inputKind === 'approval_feedback') {
942
+ return renderMessage(msg(n === 1 ? 'notice.userInputUndrained.approvalFeedback.one' : 'notice.userInputUndrained.approvalFeedback.other', { count: n }), lang);
943
+ }
882
944
  if (cause === 'leg_end' && fromSubagent)
883
945
  return subagentSteerUndrainedSentence(n);
884
946
  if (typeof cause === 'string' && Object.hasOwn(STEER_UNDRAINED_SENTENCE, cause)) {
@@ -58,6 +58,7 @@ const REFUSAL_KEYS = {
58
58
  not_configured: 'config.engineTarget.notConfigured',
59
59
  not_signed_in: 'config.engineTarget.notSignedIn',
60
60
  probe_failed: 'config.engineTarget.probeFailed',
61
+ cloud_unreachable: 'config.engineTarget.cloudUnreachable',
61
62
  org_policy: 'config.engineTarget.orgPolicy',
62
63
  url_refused: 'config.engineTarget.urlRefused',
63
64
  login_failed: 'config.engineTarget.loginFailed',
@@ -6,6 +6,7 @@ import { idempotencyPayloadMismatchContent } from './engineErrorCodes.js';
6
6
  import { inheritEnvRefusalContent } from './inheritEnvWire.js';
7
7
  import { projectSeedRefusalContent } from './projectSeed.js';
8
8
  import { usageWindowExhaustedContent, fleetLeaseUnavailableContent, settingsPermissionBucketRefusalContent, fieldLimitRefusalContent, autonomyLaneRefusalContent, sessionArchiveStampedContent, unsupportedRuleRefusalContent, admissionWallRefusalContent, hostPostureRefusalContent, toolDeclarationRefusalContent, } from './wireRefusalCopy.js';
9
+ import { catalogDefaultRefusalContent } from './model/catalogDefault.js';
9
10
  const ROLE_BY_READER = new Map([
10
11
  [corruptSessionContent, 'replacement'],
11
12
  [corruptStoredRowContent, 'replacement'],
@@ -23,6 +24,7 @@ const ROLE_BY_READER = new Map([
23
24
  [idempotencyPayloadMismatchContent, 'replacement'],
24
25
  [unsupportedRuleRefusalContent, 'replacement'],
25
26
  [projectSeedRefusalContent, 'replacement'],
27
+ [catalogDefaultRefusalContent, 'replacement'],
26
28
  [admissionWallRefusalContent, 'supplement'],
27
29
  [hostPostureRefusalContent, 'supplement'],
28
30
  [toolDeclarationRefusalContent, 'supplement'],
package/dist/eventLeg.js CHANGED
@@ -21,7 +21,7 @@ function makeFrameStageDomains(domains) {
21
21
  }
22
22
  const FRAME_STAGE_DOMAINS = makeFrameStageDomains({
23
23
  bindRun: Object.freeze(['meta', 'done', 'failed']),
24
- stampOwner: Object.freeze(['task_progress']),
24
+ stampOwner: Object.freeze(['task_progress', 'task_started']),
25
25
  hitlFrames: Object.freeze(['question', 'question_complete', 'elicitation', 'elicitation_complete', 'tool_approval', 'tool_approval_complete', 'approval_request', 'approval_complete', 'approval_revoke']),
26
26
  });
27
27
  const HITL_FRAMES_PROJECTED = Object.freeze(['human_input']);
@@ -1,3 +1,4 @@
1
+ import { SETTINGS_NO_EXECUTION_TARGET_LANES } from './generated/settingsSchemaTables.js';
1
2
  export function executionLaneWordIsNone(provider) {
2
- return provider === 'none' || provider === 'in-process';
3
+ return SETTINGS_NO_EXECUTION_TARGET_LANES.some((w) => w === provider) || provider === 'in-process';
3
4
  }
@@ -1,6 +1,6 @@
1
1
  import type { DeniedBy, Settlement } from '@sema-agent/sdk';
2
2
  import { type CcToolDenialKind } from './gateVocabulary.js';
3
- import { CORE_MODE_RELEASE_REASONS } from './generated/engineFactTables.js';
3
+ import { CORE_MODE_RELEASE_REASONS, CORE_REFUSAL_ECHO_KINDS } from './generated/engineFactTables.js';
4
4
  export type GateDispositionView = {
5
5
  kind: 'allowed';
6
6
  classifier?: GateClassifierRoundView;
@@ -14,7 +14,16 @@ export type GateDispositionView = {
14
14
  deniedBy: DeniedBy | (string & {});
15
15
  cause?: string;
16
16
  extension?: string;
17
+ echoed?: readonly GateRefusalEchoView[];
17
18
  };
19
+ export interface GateRefusalEchoView {
20
+ readonly kind: string;
21
+ readonly value: string;
22
+ readonly canonical?: string;
23
+ }
24
+ export declare const GATE_REFUSAL_ECHO_KIND_WORDS: readonly ["path", "command", "pattern"];
25
+ export type GateRefusalEchoKindWord = (typeof CORE_REFUSAL_ECHO_KINDS)[number];
26
+ export declare function isGateRefusalEchoKindWord(v: string): v is GateRefusalEchoKindWord;
18
27
  export interface GateClassifierRoundView {
19
28
  modelRequested: string;
20
29
  modelUsed: string;
@@ -1,10 +1,14 @@
1
1
  import { ccToolDenialKindForSettledBy, isCcToolDenialKind, isGateDeniedByWord } from './gateVocabulary.js';
2
2
  import { GATE_PARKED_ERROR_CODE } from './engineErrorCodes.js';
3
- import { CORE_MODE_RELEASE_REASONS, CORE_SETTLEMENT_KINDS } from './generated/engineFactTables.js';
3
+ import { CORE_MODE_RELEASE_REASONS, CORE_REFUSAL_ECHO_KINDS, CORE_SETTLEMENT_KINDS } from './generated/engineFactTables.js';
4
4
  import { readAskOrigin, readOwnDataNonEmptyString, readOwnDataValue } from './ownKey.js';
5
5
  function str(v) {
6
6
  return typeof v === 'string' && v.length > 0 ? v : undefined;
7
7
  }
8
+ export const GATE_REFUSAL_ECHO_KIND_WORDS = CORE_REFUSAL_ECHO_KINDS;
9
+ export function isGateRefusalEchoKindWord(v) {
10
+ return typeof v === 'string' && CORE_REFUSAL_ECHO_KINDS.includes(v);
11
+ }
8
12
  export const GATE_MODE_RELEASE_REASON_WORDS = CORE_MODE_RELEASE_REASONS;
9
13
  export function isGateModeReleaseReasonWord(v) {
10
14
  return typeof v === 'string' && CORE_MODE_RELEASE_REASONS.includes(v);
@@ -112,6 +116,46 @@ function nonEmptyStringList(v) {
112
116
  }
113
117
  return Object.freeze(out);
114
118
  }
119
+ function ownDataOf(o, key) {
120
+ try {
121
+ const d = Object.getOwnPropertyDescriptor(o, key);
122
+ return d === undefined || !Object.hasOwn(d, 'value') ? { ok: false } : { ok: true, value: d.value };
123
+ }
124
+ catch {
125
+ return { ok: false };
126
+ }
127
+ }
128
+ function readRefusalEchoes(raw) {
129
+ try {
130
+ if (!Array.isArray(raw))
131
+ return undefined;
132
+ const len = ownDataOf(raw, 'length');
133
+ if (!len.ok || typeof len.value !== 'number' || !Number.isInteger(len.value) || len.value <= 0)
134
+ return undefined;
135
+ const out = [];
136
+ for (let i = 0; i < len.value; i += 1) {
137
+ const slot = ownDataOf(raw, String(i));
138
+ if (!slot.ok)
139
+ return undefined;
140
+ const e = slot.value;
141
+ if (typeof e !== 'object' || e === null || Array.isArray(e))
142
+ return undefined;
143
+ const kind = ownDataOf(e, 'kind');
144
+ const value = ownDataOf(e, 'value');
145
+ if (!kind.ok || typeof kind.value !== 'string' || kind.value.length === 0)
146
+ return undefined;
147
+ if (!value.ok || typeof value.value !== 'string' || value.value.length === 0)
148
+ return undefined;
149
+ const canonical = ownDataOf(e, 'canonical');
150
+ const canon = canonical.ok && typeof canonical.value === 'string' && canonical.value.length > 0 ? canonical.value : undefined;
151
+ out.push(Object.freeze({ kind: kind.value, value: value.value, ...(canon !== undefined ? { canonical: canon } : {}) }));
152
+ }
153
+ return Object.freeze(out);
154
+ }
155
+ catch {
156
+ return undefined;
157
+ }
158
+ }
115
159
  function readModeRelease(raw) {
116
160
  if (typeof raw !== 'object' || raw === null || Array.isArray(raw))
117
161
  return undefined;
@@ -198,6 +242,8 @@ function readGateRecord(frame) {
198
242
  const askClass = str(dr.askClass);
199
243
  const classes = nonEmptyStringList(dr.classes);
200
244
  const extension = str(dr.extension);
245
+ const echoedSeat = ownDataOf(dr, 'echoed');
246
+ const echoed = echoedSeat.ok ? readRefusalEchoes(echoedSeat.value) : undefined;
201
247
  disposition = {
202
248
  kind: 'denied',
203
249
  deniedBy,
@@ -207,6 +253,7 @@ function readGateRecord(frame) {
207
253
  ...(askClass !== undefined ? { askClass } : {}),
208
254
  ...(classes !== undefined ? { classes } : {}),
209
255
  ...(extension !== undefined ? { extension } : {}),
256
+ ...(echoed !== undefined ? { echoed } : {}),
210
257
  };
211
258
  }
212
259
  else {
@@ -73,3 +73,4 @@ export declare const CORE_USER_ATTACHMENTS_MAX: number;
73
73
  export declare const CORE_USER_ATTACHMENT_LABEL_MAX: number;
74
74
  export declare const CORE_PRESENT_PLAN_TOOL_NAME: "ExitPlanMode";
75
75
  export declare const CORE_WORKFLOW_AGENT_PARKED_ERROR_CODE: "workflow.agent_parked";
76
+ export declare const CORE_REFUSAL_ECHO_KINDS: readonly ["path", "command", "pattern"];
@@ -466,3 +466,8 @@ export const CORE_USER_ATTACHMENTS_MAX = 20;
466
466
  export const CORE_USER_ATTACHMENT_LABEL_MAX = 4096;
467
467
  export const CORE_PRESENT_PLAN_TOOL_NAME = "ExitPlanMode";
468
468
  export const CORE_WORKFLOW_AGENT_PARKED_ERROR_CODE = "workflow.agent_parked";
469
+ export const CORE_REFUSAL_ECHO_KINDS = Object.freeze([
470
+ "path",
471
+ "command",
472
+ "pattern",
473
+ ]);
@@ -52,6 +52,7 @@ export const CORE_ENGINE_NOTICE_CODES = Object.freeze([
52
52
  "delegation.transcript_integrity",
53
53
  "delegation.ask_unresolvable",
54
54
  "delegation.resume_lane_missing",
55
+ "delegation.delivery_discarded",
55
56
  "mcp.injection_dropped",
56
57
  "mcp.revocation_probe_failed",
57
58
  "mcp.server_redialed",
@@ -171,6 +172,7 @@ export const CORE_NOTICE_AUDIENCE = Object.freeze({
171
172
  "delegation.transcript_integrity": "operator",
172
173
  "delegation.ask_unresolvable": "user",
173
174
  "delegation.resume_lane_missing": "operator",
175
+ "delegation.delivery_discarded": "operator",
174
176
  "mcp.injection_dropped": "user",
175
177
  "mcp.revocation_probe_failed": "operator",
176
178
  "mcp.server_redialed": "operator",
@@ -296,6 +298,7 @@ export const CORE_NOTICE_MINTER = Object.freeze({
296
298
  "delegation.transcript_integrity": "engine",
297
299
  "delegation.ask_unresolvable": "engine",
298
300
  "delegation.resume_lane_missing": "engine",
301
+ "delegation.delivery_discarded": "engine",
299
302
  "mcp.injection_dropped": "engine",
300
303
  "mcp.revocation_probe_failed": "engine",
301
304
  "mcp.server_redialed": "engine",