@sema-agent/client-core 0.88.0 → 0.90.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 (61) hide show
  1. package/CHANGELOG.md +208 -0
  2. package/README.md +27 -21
  3. package/dist/adapter/activeRunSelfHeal.js +4 -2
  4. package/dist/adapter/downstream/eventToSdkMessage.js +4 -2
  5. package/dist/adapter/downstream/wiringManifestView.d.ts +9 -0
  6. package/dist/adapter/downstream/wiringManifestView.js +27 -0
  7. package/dist/adapter/runStream.d.ts +2 -0
  8. package/dist/adapter/runStream.js +157 -32
  9. package/dist/attachmentsWireCaps.d.ts +13 -2
  10. package/dist/attachmentsWireCaps.js +25 -5
  11. package/dist/controlRouter.d.ts +7 -1
  12. package/dist/controlRouter.js +43 -1
  13. package/dist/coreValuePorts.d.ts +1 -0
  14. package/dist/disableSkillsWire.d.ts +17 -0
  15. package/dist/disableSkillsWire.js +52 -0
  16. package/dist/displayUntrusted.js +122 -55
  17. package/dist/engineCapReader.js +12 -1
  18. package/dist/engineNoticeCodes.d.ts +25 -9
  19. package/dist/engineNoticeCodes.js +161 -68
  20. package/dist/fileHistoryLegNotice.d.ts +20 -0
  21. package/dist/fileHistoryLegNotice.js +122 -0
  22. package/dist/gateOutcome.d.ts +1 -1
  23. package/dist/gateOutcome.js +1 -0
  24. package/dist/generated/engineFactTables.d.ts +1 -0
  25. package/dist/generated/engineFactTables.js +3 -0
  26. package/dist/generated/engineNoticeTables.d.ts +3 -0
  27. package/dist/generated/engineNoticeTables.js +107 -2
  28. package/dist/hitl/toolApprovalWire.d.ts +6 -2
  29. package/dist/hitl/toolApprovalWire.js +30 -0
  30. package/dist/hookToolAliases.d.ts +3 -0
  31. package/dist/hookToolAliases.js +10 -0
  32. package/dist/hooksWireCaps.js +80 -12
  33. package/dist/index.d.ts +14 -3
  34. package/dist/index.js +10 -3
  35. package/dist/permissionsAllowGrantCapability.d.ts +17 -0
  36. package/dist/permissionsAllowGrantCapability.js +75 -0
  37. package/dist/permissionsDeclaration.d.ts +25 -0
  38. package/dist/permissionsDeclaration.js +227 -0
  39. package/dist/pluginHooksWire.d.ts +46 -4
  40. package/dist/pluginHooksWire.js +277 -24
  41. package/dist/promptDelivery.d.ts +5 -2
  42. package/dist/promptDelivery.js +8 -3
  43. package/dist/providerRejection.d.ts +7 -0
  44. package/dist/providerRejection.js +58 -0
  45. package/dist/request/taskRequest.d.ts +2 -0
  46. package/dist/request/taskRequest.js +67 -9
  47. package/dist/runTerminal.d.ts +6 -0
  48. package/dist/runTerminal.js +23 -0
  49. package/dist/sdkRegistryTransit.d.ts +1 -0
  50. package/dist/sdkRegistryTransit.js +1 -0
  51. package/dist/seam.d.ts +3 -0
  52. package/dist/seatContract.d.ts +9 -1
  53. package/dist/seatContract.js +10 -0
  54. package/dist/subagent/engineSubagentSteer.d.ts +8 -1
  55. package/dist/subagent/engineSubagentSteer.js +26 -3
  56. package/dist/supportFloor.d.ts +10 -0
  57. package/dist/supportFloor.js +42 -0
  58. package/dist/taskRequestWords.d.ts +1 -0
  59. package/dist/taskRequestWords.js +14 -0
  60. package/docs/INTEGRATION-CLIENTS.md +896 -14
  61. package/package.json +3 -3
@@ -28,7 +28,6 @@ export const CORE_ENGINE_NOTICE_CODES = Object.freeze([
28
28
  "permission.ask_released_by_mode",
29
29
  "permission.read_deny_unapplied",
30
30
  "permission.rule_store_unavailable",
31
- "resume.legacy_mode_seed_migrated",
32
31
  "peer.inbound_disposition",
33
32
  "peer.held_settled",
34
33
  "peer.idle_subscription",
@@ -73,6 +72,7 @@ export const CORE_ENGINE_NOTICE_CODES = Object.freeze([
73
72
  "task.halt_unconsumed",
74
73
  "task.late_approval",
75
74
  "task.interrupt_unconsumed",
75
+ "task.tool_turn_incomplete",
76
76
  "approval.read_root_granted",
77
77
  "approval.read_root_grant_rejected",
78
78
  "memory.capture_opted_out",
@@ -80,6 +80,10 @@ export const CORE_ENGINE_NOTICE_CODES = Object.freeze([
80
80
  "skills.listing_truncated",
81
81
  "agents.listing_truncated",
82
82
  "tool_result.offload_put_failed",
83
+ "instructions.source_changed",
84
+ "session.records_skipped",
85
+ "memory.layer_locked_legacy",
86
+ "server.model_unreachable",
83
87
  ]);
84
88
  export const CORE_NOTICE_AUDIENCE = Object.freeze({
85
89
  "config.autocompact_window_clamped": "operator",
@@ -111,7 +115,6 @@ export const CORE_NOTICE_AUDIENCE = Object.freeze({
111
115
  "permission.ask_released_by_mode": "user",
112
116
  "permission.read_deny_unapplied": "user",
113
117
  "permission.rule_store_unavailable": "user",
114
- "resume.legacy_mode_seed_migrated": "operator",
115
118
  "peer.inbound_disposition": "user",
116
119
  "peer.held_settled": "user",
117
120
  "peer.idle_subscription": "user",
@@ -156,6 +159,7 @@ export const CORE_NOTICE_AUDIENCE = Object.freeze({
156
159
  "task.halt_unconsumed": "user",
157
160
  "task.late_approval": "user",
158
161
  "task.interrupt_unconsumed": "user",
162
+ "task.tool_turn_incomplete": "user",
159
163
  "approval.read_root_granted": "user",
160
164
  "approval.read_root_grant_rejected": "user",
161
165
  "memory.capture_opted_out": "user",
@@ -163,6 +167,10 @@ export const CORE_NOTICE_AUDIENCE = Object.freeze({
163
167
  "skills.listing_truncated": "operator",
164
168
  "agents.listing_truncated": "operator",
165
169
  "tool_result.offload_put_failed": "operator",
170
+ "instructions.source_changed": "user",
171
+ "session.records_skipped": "user",
172
+ "memory.layer_locked_legacy": "operator",
173
+ "server.model_unreachable": "user",
166
174
  });
167
175
  export const CORE_MCP_INJECTION_DROP_REASONS = Object.freeze([
168
176
  "malformed_entry",
@@ -170,3 +178,100 @@ export const CORE_MCP_INJECTION_DROP_REASONS = Object.freeze([
170
178
  "gate_closed",
171
179
  "over_cap",
172
180
  ]);
181
+ export const CORE_NOTICE_MINTER = Object.freeze({
182
+ "config.autocompact_window_clamped": "engine",
183
+ "config.env_timeout_discarded": "engine",
184
+ "config.materialize_env_discarded": "engine",
185
+ "config.models_swapped": "engine",
186
+ "config.context_settings_swapped": "engine",
187
+ "config.read_face_swapped": "engine",
188
+ "config.read_face_deployment_clamped": "engine",
189
+ "config.write_face_swapped": "engine",
190
+ "config.write_face_deployment_clamped": "engine",
191
+ "config.tool_model_gate_removed": "engine",
192
+ "config.tool_model_gate_unknown_class": "engine",
193
+ "config.tool_model_gate_env_invalid": "engine",
194
+ "config.artifact_host_invalid": "engine",
195
+ "config.task_root_not_canonical": "engine",
196
+ "config.write_protection_target_view_absent": "engine",
197
+ "config.write_protection_unresolved": "engine",
198
+ "config.execution_env_capability_invalid": "engine",
199
+ "config.tool_card_undeclared": "engine",
200
+ "config.tool_face_undeclared": "engine",
201
+ "config.tool_face_invalid": "engine",
202
+ "config.forward_sink_failed": "engine",
203
+ "config.durable_gate_unavailable": "engine",
204
+ "config.peer_admission_out_of_range": "engine",
205
+ "config.peer_lane_unmounted": "engine",
206
+ "config.secret_env_scrubbed": "engine",
207
+ "config.permission_mode_unavailable": "engine",
208
+ "permission.ask_released_by_mode": "engine",
209
+ "permission.read_deny_unapplied": "engine",
210
+ "permission.rule_store_unavailable": "engine",
211
+ "peer.inbound_disposition": "engine",
212
+ "peer.held_settled": "engine",
213
+ "peer.idle_subscription": "engine",
214
+ "classifier.denial_limit": "engine",
215
+ "classifier.fallback": "engine",
216
+ "classifier.role_defaulted": "engine",
217
+ "classifier.contract_broken": "engine",
218
+ "classifier.unavailable": "engine",
219
+ "checkpoint.execution_outcome_unrecorded": "engine",
220
+ "delegation.transcript_integrity": "engine",
221
+ "delegation.ask_unresolvable": "engine",
222
+ "mcp.injection_dropped": "engine",
223
+ "mcp.revocation_probe_failed": "engine",
224
+ "mcp.server_redialed": "engine",
225
+ "workflow.governance_key_stripped": "engine",
226
+ "workflow.agent_option_ignored": "engine",
227
+ "memory.session_polluted": "engine",
228
+ "memory.harvest_quarantined": "engine",
229
+ "memory.delegation_static_mark_waived": "engine",
230
+ "memory.content_class_declared": "engine",
231
+ "memory.hold_opened": "engine",
232
+ "memory.hold_released": "engine",
233
+ "memory.hold_disposed": "engine",
234
+ "memory.consolidation_recommended": "engine",
235
+ "memory.consolidation_committed": "engine",
236
+ "memory.consolidation_conflict": "engine",
237
+ "memory.consolidation_incomplete": "engine",
238
+ "memory.consolidation_refused": "engine",
239
+ "memory.consolidation_withheld": "engine",
240
+ "memory.restore_withheld": "engine",
241
+ "memory.project_scope_absent": "engine",
242
+ "route.fallback_to_primary": "engine",
243
+ "route.classifier_unroutable": "engine",
244
+ "route.base_url_changed_key_unchanged": "engine",
245
+ "route.response_model_mismatch": "engine",
246
+ "route.tool_call_id_folded": "engine",
247
+ "context.tool_turn_repaired": "engine",
248
+ "task.user_steer_undrained": "engine",
249
+ "task.user_followup_undrained": "engine",
250
+ "steering.parked_input_blocked": "engine",
251
+ "task.turn_interrupted": "engine",
252
+ "task.halt_unconsumed": "engine",
253
+ "task.late_approval": "engine",
254
+ "task.interrupt_unconsumed": "engine",
255
+ "task.tool_turn_incomplete": "engine",
256
+ "approval.read_root_granted": "engine",
257
+ "approval.read_root_grant_rejected": "engine",
258
+ "memory.capture_opted_out": "engine",
259
+ "memory.capture_optout_unpersisted": "engine",
260
+ "skills.listing_truncated": "engine",
261
+ "agents.listing_truncated": "engine",
262
+ "tool_result.offload_put_failed": "engine",
263
+ "instructions.source_changed": "server",
264
+ "session.records_skipped": "server",
265
+ "memory.layer_locked_legacy": "server",
266
+ "server.model_unreachable": "server",
267
+ });
268
+ export const CORE_USER_STEER_UNDRAINED_CAUSES = Object.freeze([
269
+ "leg_end",
270
+ "crashed",
271
+ ]);
272
+ export const CORE_TOOL_TURN_INCOMPLETE_CAUSES = Object.freeze([
273
+ "truncated",
274
+ "unnamed",
275
+ "bad_frame",
276
+ "missing_result_synthesized",
277
+ ]);
@@ -144,6 +144,8 @@ export interface ApprovalCardRequest {
144
144
  mandate?: ApprovalMandateWord;
145
145
  denialLimitFallback?: DenialLimitFallback;
146
146
  origin?: string;
147
+ askClass?: string;
148
+ classes?: readonly string[];
147
149
  ruleStoreUnreadable?: RuleStoreUnreadableKind;
148
150
  }
149
151
  export type ApprovalCardPort = (req: ApprovalCardRequest) => Promise<ApprovalCardDecision>;
@@ -183,6 +185,8 @@ export interface ToolApprovalFrame {
183
185
  mandated?: true;
184
186
  mandate?: string;
185
187
  origin?: string;
188
+ askClass?: string;
189
+ classes?: readonly string[];
186
190
  inputHasBidi?: true;
187
191
  parked?: true;
188
192
  expiresInMs?: number;
@@ -200,7 +204,7 @@ export interface ToolApprovalDelegation {
200
204
  depth: number;
201
205
  agentName?: string;
202
206
  }
203
- export declare const TOOL_APPROVAL_FRAME_KEYS_MIRROR: readonly ["type", "approvalId", "toolCallId", "toolName", "sourceTaskId", "fromSubagent", "sourceAgentName", "message", "args", "argsOmitted", "governanceForced", "ruleSuggestions", "ruleOffers", "ruleOffersAbsence", "denialLimitFallback", "ruleStoreUnreadable", "readRootCandidate", "mandated", "mandate", "origin", "inputHasBidi", "parked", "persistedRuleShadowed", "probeCause", "ruleEvidence", "requiresRealApproval", "expiresInMs", "expiresAtMs", "serverNowMs", "delegation", "outcome"];
207
+ export declare const TOOL_APPROVAL_FRAME_KEYS_MIRROR: readonly ["type", "approvalId", "toolCallId", "toolName", "sourceTaskId", "fromSubagent", "sourceAgentName", "message", "args", "argsOmitted", "governanceForced", "ruleSuggestions", "ruleOffers", "ruleOffersAbsence", "denialLimitFallback", "ruleStoreUnreadable", "readRootCandidate", "mandated", "mandate", "origin", "askClass", "classes", "inputHasBidi", "parked", "persistedRuleShadowed", "probeCause", "ruleEvidence", "requiresRealApproval", "expiresInMs", "expiresAtMs", "serverNowMs", "delegation", "outcome"];
204
208
  export interface ApprovalMandatedFacts {
205
209
  readonly mandated?: true;
206
210
  readonly ruleOffersAbsence?: string;
@@ -210,7 +214,7 @@ export declare function approvalIsMandated(v: ApprovalMandatedFacts | undefined
210
214
  export declare function readApprovalMandate(v: {
211
215
  readonly mandate?: string;
212
216
  } | undefined | null): ApprovalMandateWord | undefined;
213
- export declare function toolPermissionRequestAskBits(card: object | null | undefined): Pick<ToolPermissionRequest, 'mandated' | 'mandate' | 'origin' | 'ruleOffersAbsence'>;
217
+ export declare function toolPermissionRequestAskBits(card: object | null | undefined): Pick<ToolPermissionRequest, 'mandated' | 'mandate' | 'origin' | 'ruleOffersAbsence' | 'askClass' | 'classes'>;
214
218
  export declare function isFromSubagent(frame: ToolApprovalFrame): boolean;
215
219
  export type ToolApprovalRespondDecision = 'allow' | 'allow_session' | 'deny';
216
220
  export interface RespondToolApprovalOpts {
@@ -210,6 +210,7 @@ export async function surfaceFsApprovalAndDecide(deps, taskId, argsByCall, signa
210
210
  ...(hasOwnStrictTrue(pending, 'mandated') ? { mandated: true } : {}),
211
211
  ...((w) => (w !== undefined ? { mandate: w } : {}))(readApprovalMandate(pending)),
212
212
  ...((o) => (o !== undefined ? { origin: o } : {}))(readOwnNonEmptyString(pending, 'origin')),
213
+ ...(readAskClassPair(pending) ?? {}),
213
214
  ...(pending.gateKind === 'irreversible_ask' ? { irreversibleParkGate: true } : {}),
214
215
  ...(pending.hasBidiControls === true ? { hasBidiControls: true } : {}),
215
216
  ...(ruleOffersReadOnly !== undefined ? { ruleOffersReadOnly } : {}),
@@ -386,6 +387,8 @@ export const TOOL_APPROVAL_FRAME_KEYS_MIRROR = [
386
387
  'mandated',
387
388
  'mandate',
388
389
  'origin',
390
+ 'askClass',
391
+ 'classes',
389
392
  'inputHasBidi',
390
393
  'parked',
391
394
  'persistedRuleShadowed',
@@ -425,13 +428,39 @@ export function toolPermissionRequestAskBits(card) {
425
428
  const mandate = readApprovalMandate(card);
426
429
  const origin = readOwnNonEmptyString(card, 'origin');
427
430
  const ruleOffersAbsence = readOwnNonEmptyString(card, 'ruleOffersAbsence');
431
+ const askClassPair = readAskClassPair(card);
428
432
  return {
429
433
  ...(mandated ? { mandated: true } : {}),
430
434
  ...(mandate !== undefined ? { mandate } : {}),
431
435
  ...(origin !== undefined ? { origin } : {}),
432
436
  ...(ruleOffersAbsence !== undefined ? { ruleOffersAbsence } : {}),
437
+ ...(askClassPair ?? {}),
433
438
  };
434
439
  }
440
+ function readAskClassPair(v) {
441
+ if (typeof v !== 'object' || v === null)
442
+ return undefined;
443
+ const askClass = readOwnNonEmptyString(v, 'askClass');
444
+ if (askClass === undefined || !Object.hasOwn(v, 'classes'))
445
+ return undefined;
446
+ const raw = v.classes;
447
+ if (!Array.isArray(raw) || raw.length === 0)
448
+ return undefined;
449
+ const classes = [];
450
+ const seen = new Set();
451
+ for (let i = 0; i < raw.length; i++) {
452
+ if (!Object.hasOwn(raw, i))
453
+ return undefined;
454
+ const c = raw[i];
455
+ if (typeof c !== 'string' || c === '' || seen.has(c))
456
+ return undefined;
457
+ seen.add(c);
458
+ classes.push(c);
459
+ }
460
+ if (classes[0] !== askClass)
461
+ return undefined;
462
+ return { askClass, classes: Object.freeze(classes) };
463
+ }
435
464
  function hasOwnStrictTrue(v, key) {
436
465
  return Object.hasOwn(v, key) && v[key] === true;
437
466
  }
@@ -870,6 +899,7 @@ export async function surfaceToolApprovalFrameAndRespond(frame, respond, streamA
870
899
  ...(denialLimitFallback !== undefined ? { denialLimitFallback } : {}),
871
900
  ...((k) => (k !== undefined ? { ruleStoreUnreadable: k } : {}))(readRuleStoreUnreadable(frame.ruleStoreUnreadable)),
872
901
  ...((o) => (o !== undefined ? { origin: o } : {}))(readOwnNonEmptyString(frame, 'origin')),
902
+ ...(readAskClassPair(frame) ?? {}),
873
903
  });
874
904
  if (argsNotRealInput && card.kind === 'allow' && card.updatedInput !== undefined) {
875
905
  hostLog('error', `liveToolApprovalWire: ${approvalId} card returned an edited approval on a card whose arguments are not the tool's real input (${lane?.argsUnavailable === true ? 'args-unavailable ask' : 'arguments omitted or absent on the frame'}) — nothing sent (the ask stays pending)`);
@@ -0,0 +1,3 @@
1
+ export declare const HOOK_TOOL_ALIASES: Readonly<Record<string, string>>;
2
+ export declare function hookToolAliasesOf(): Readonly<Record<string, string>>;
3
+ export declare function canonicalHookToolName(name: string): string;
@@ -0,0 +1,10 @@
1
+ import { CORE_HOOK_TOOL_ALIASES } from './generated/engineFactTables.js';
2
+ export const HOOK_TOOL_ALIASES = CORE_HOOK_TOOL_ALIASES;
3
+ export function hookToolAliasesOf() {
4
+ return HOOK_TOOL_ALIASES;
5
+ }
6
+ export function canonicalHookToolName(name) {
7
+ if (typeof name !== 'string')
8
+ return name;
9
+ return Object.hasOwn(HOOK_TOOL_ALIASES, name) ? (HOOK_TOOL_ALIASES[name] ?? name) : name;
10
+ }
@@ -1,8 +1,8 @@
1
- import { engineCapNestedTrue, engineCapState } from './engineCapsCache.js';
1
+ import { engineCapNestedTrue, engineCapState, engineCapValue } from './engineCapsCache.js';
2
2
  import { displayUntrusted } from './displayUntrusted.js';
3
3
  import { collapseLabel } from './fleetTaskDesc.js';
4
4
  import { hostLog, hostSettings } from './host.js';
5
- import { decidePluginHooks, dedupeSettingsHookGroups, filterSettingsHookGroups, occupancyOf, settingsHookDropText, } from './pluginHooksWire.js';
5
+ import { createSettingsHookJudge, decidePluginHooks, dedupeSettingsHookGroups, filterSettingsHookGroups, occupancyOf, settingsHookDropText, } from './pluginHooksWire.js';
6
6
  import { MAX_HOOK_NOTICE_TEXT_CHARS } from './notifications.js';
7
7
  import { goalStopHookMatcher, __resetGoalStopHookForTests } from './goalStopHook.js';
8
8
  export { GOAL_STOP_HOOK_WIRE_ENV, CC_STOP_SEMANTICS_MIN_SERVER, ccStopSemanticsFromVersion, engineCcStopSemantics, isGoalStopHookWireArmed, setWireSessionStopHook, getWireSessionStopHook, getWireSessionStopHookCcSemantics, buildGoalStopHookPrompt, } from './goalStopHook.js';
@@ -121,7 +121,7 @@ function readPluginHooks(settings, warnIfAbsent) {
121
121
  }
122
122
  return { state: 'absent' };
123
123
  }
124
- const NO_PLAN_ENGINE = { ownedByThisShell: null, pluginHooksCapable: null };
124
+ const NO_PLAN_ENGINE = { ownedByThisShell: null, pluginHooksCapable: null, hooksCapable: null };
125
125
  export function hooksForWire(opts = {}) {
126
126
  const given = opts?.plan;
127
127
  if (isHooksWirePlan(given))
@@ -131,7 +131,7 @@ export function hooksForWire(opts = {}) {
131
131
  }
132
132
  if (isHooksWirePlan(opts))
133
133
  return opts.wire;
134
- return buildHooksWirePlan(NO_PLAN_ENGINE, new Set(), false).wire;
134
+ return buildHooksWirePlan(NO_PLAN_ENGINE, () => false, false, true).wire;
135
135
  }
136
136
  function isHooksWirePlan(v) {
137
137
  try {
@@ -139,14 +139,17 @@ function isHooksWirePlan(v) {
139
139
  return false;
140
140
  const o = v;
141
141
  for (const k of PLAN_KEYS)
142
- if (!Object.hasOwn(o, k))
142
+ if (!Object.hasOwn(o, k) && k !== 'settingsVerdicts' && k !== 'settingsExcluded')
143
143
  return false;
144
144
  const reader = o.pluginReader;
145
145
  const engineFacts = o.engine;
146
146
  const wire = o.wire;
147
+ const arrayOrAbsent = (k) => !Object.hasOwn(o, k) || Array.isArray(o[k]);
147
148
  return (Array.isArray(o.verdicts) &&
148
149
  Array.isArray(o.excluded) &&
149
150
  Array.isArray(o.settingsDropped) &&
151
+ arrayOrAbsent('settingsVerdicts') &&
152
+ arrayOrAbsent('settingsExcluded') &&
150
153
  (reader === 'present' || reader === 'absent' || reader === 'failed') &&
151
154
  typeof engineFacts === 'object' &&
152
155
  engineFacts !== null &&
@@ -157,7 +160,7 @@ function isHooksWirePlan(v) {
157
160
  return false;
158
161
  }
159
162
  }
160
- const PLAN_KEYS = ['engine', 'pluginReader', 'verdicts', 'excluded', 'settingsDropped', 'wire'];
163
+ const PLAN_KEYS = ['engine', 'pluginReader', 'verdicts', 'excluded', 'settingsDropped', 'settingsVerdicts', 'settingsExcluded', 'wire'];
161
164
  const _planKeysPin = [true, true];
162
165
  void _planKeysPin;
163
166
  export function hooksWirePlan(opts = {}) {
@@ -168,6 +171,7 @@ export function hooksWirePlan(opts = {}) {
168
171
  pluginHooksCapable: engineCapState(o.baseUrl, 'taskSettings') === 'unprobed'
169
172
  ? null
170
173
  : engineCapNestedTrue(o.baseUrl, 'taskSettings', 'pluginHooks'),
174
+ hooksCapable: taskHooksCapability(o.baseUrl),
171
175
  };
172
176
  const shellEvents = new Set();
173
177
  if (Array.isArray(o.shellHookEvents)) {
@@ -175,12 +179,72 @@ export function hooksWirePlan(opts = {}) {
175
179
  if (typeof e === 'string')
176
180
  shellEvents.add(e);
177
181
  }
178
- return buildHooksWirePlan(engine, shellEvents, true);
182
+ const typesByEvent = shellHookTypesOf(o);
183
+ const shellRuns = (event, type) => {
184
+ if (!shellEvents.has(event))
185
+ return false;
186
+ const types = typesByEvent?.get(event);
187
+ return types === undefined || (typeof type === 'string' && types.has(type));
188
+ };
189
+ const settingsShellRuns = typesByEvent !== undefined ? shellRuns : (event, type) => type !== 'prompt' && type !== 'agent' && shellRuns(event, type);
190
+ return buildHooksWirePlan(engine, shellRuns, true, promptAuthoredByUserOf(o), settingsShellRuns);
191
+ }
192
+ function taskHooksCapability(baseUrl) {
193
+ const v = engineCapValue(baseUrl, 'taskSettings');
194
+ if (v.kind !== 'value')
195
+ return null;
196
+ if (v.value === false)
197
+ return false;
198
+ if (typeof v.value !== 'object' || v.value === null || Array.isArray(v.value))
199
+ return null;
200
+ const hooks = v.value.hooks;
201
+ return hooks === true ? true : hooks === false ? false : null;
202
+ }
203
+ function shellHookTypesOf(o) {
204
+ let raw;
205
+ try {
206
+ raw = o.shellHookTypesByEvent;
207
+ if (raw === undefined)
208
+ return undefined;
209
+ if (typeof raw !== 'object' || raw === null || Array.isArray(raw))
210
+ throw new TypeError('not a plain object');
211
+ const out = new Map();
212
+ for (const key of Object.keys(raw)) {
213
+ const types = raw[key];
214
+ if (!Array.isArray(types) || !types.every((t) => typeof t === 'string'))
215
+ throw new TypeError(`value for one event is not an array of strings`);
216
+ out.set(key, new Set(types));
217
+ }
218
+ return out;
219
+ }
220
+ catch (err) {
221
+ hostLog('debug', `hooksWirePlan: shellHookTypesByEvent is malformed — treated as absent (command and http hooks count as running on every reported event; prompt and agent hooks from settings stay with the engine): ${String(err)}`);
222
+ return undefined;
223
+ }
224
+ }
225
+ function promptAuthoredByUserOf(o) {
226
+ let v;
227
+ try {
228
+ v = o.promptAuthoredByUser;
229
+ }
230
+ catch (err) {
231
+ hostLog('debug', `hooksWirePlan: promptAuthoredByUser threw while being read — treated as written by the user: ${String(err)}`);
232
+ return true;
233
+ }
234
+ if (v === false)
235
+ return false;
236
+ if (v !== undefined && v !== true) {
237
+ hostLog('debug', 'hooksWirePlan: promptAuthoredByUser is not a boolean — treated as written by the user');
238
+ }
239
+ return true;
179
240
  }
180
- function buildHooksWirePlan(engine, shellEvents, withPlugins) {
241
+ function buildHooksWirePlan(engine, shellRuns, withPlugins, promptAuthoredByUser, settingsShellRuns = shellRuns) {
181
242
  const settingsDropped = [];
243
+ const settingsVerdicts = [];
244
+ const settingsExcluded = [];
245
+ const judge = withPlugins ? createSettingsHookJudge(engine, settingsShellRuns, promptAuthoredByUser) : undefined;
182
246
  let settingsStripped = 0;
183
- const planOf = (pluginReader, wire, verdicts = [], excluded = []) => ({ engine, pluginReader, verdicts, excluded, settingsDropped, wire });
247
+ const planOf = (pluginReader, wire, verdicts = [], excluded = []) => ({ engine, pluginReader, verdicts, excluded, settingsDropped, settingsVerdicts, settingsExcluded, wire });
184
248
  const closedPlan = (settings, reason) => {
185
249
  if (!withPlugins)
186
250
  return planOf('absent', undefined);
@@ -193,7 +257,8 @@ function buildHooksWirePlan(engine, shellEvents, withPlugins) {
193
257
  exclusion: reason,
194
258
  managedOnly: false,
195
259
  engine,
196
- shellHookEvents: shellEvents,
260
+ shellRuns,
261
+ promptAuthoredByUser,
197
262
  occupied: new Map(),
198
263
  }));
199
264
  if (d === undefined)
@@ -265,8 +330,10 @@ function buildHooksWirePlan(engine, shellEvents, withPlugins) {
265
330
  for (const [event, groups] of Object.entries(hooks)) {
266
331
  if (!Array.isArray(groups) || groups.length === 0)
267
332
  continue;
268
- const kept = filterSettingsHookGroups(source, event, groups, engine.pluginHooksCapable === true, shellEvents.has(event), !withPlugins);
333
+ const kept = filterSettingsHookGroups(source, event, groups, engine.pluginHooksCapable === true, (type) => shellRuns(event, type), !withPlugins, judge);
269
334
  settingsDropped.push(...kept.drops);
335
+ settingsVerdicts.push(...kept.verdicts);
336
+ settingsExcluded.push(...kept.excluded);
270
337
  settingsStripped += kept.stripped;
271
338
  if (kept.groups.length === 0)
272
339
  continue;
@@ -334,7 +401,8 @@ function buildHooksWirePlan(engine, shellEvents, withPlugins) {
334
401
  exclusion: startup ? 'startup_mode' : undefined,
335
402
  managedOnly: managedOnlyPlugins,
336
403
  engine,
337
- shellHookEvents: shellEvents,
404
+ shellRuns,
405
+ promptAuthoredByUser,
338
406
  occupied,
339
407
  });
340
408
  });
package/dist/index.d.ts CHANGED
@@ -31,6 +31,7 @@ export * from './executionLaneCapability.js';
31
31
  export * from './approvalsStreamLiveCapability.js';
32
32
  export * from './peerLaneCapability.js';
33
33
  export * from './permissionRulesWriteCapability.js';
34
+ export * from './permissionsAllowGrantCapability.js';
34
35
  export * from './sessionPolicyCapability.js';
35
36
  export * from './memoryComplianceCapability.js';
36
37
  export * from './memoryOriginCapability.js';
@@ -40,6 +41,7 @@ export * from './deviceExecutorManagementCapability.js';
40
41
  export * from './mcpReconnect.js';
41
42
  export * from './leaderConflict.js';
42
43
  export * from './runTerminal.js';
44
+ export { providerRejectionResend, type ProviderRejectionResend } from './providerRejection.js';
43
45
  export * from './runCancelContext.js';
44
46
  export * from './argvFlagValue.js';
45
47
  export * from './readFacePosture.js';
@@ -66,7 +68,7 @@ export type { DisplayUntrustedOptions, DisplayMark, DisplayMarkSpan, DisplayUntr
66
68
  export type * from './types/engineState.js';
67
69
  export * from './hostEnv.js';
68
70
  export * from './unrefTimer.js';
69
- export * from './controlRouter.js';
71
+ export { ControlRouter, ControlSafetyError, errCodes, type ControlClientLike, type ControlRouterOptions, type ControlSafetyCode, type ErrCodes, type QueuedCommand, type QueuePriority, type RunsResourceLike, } from './controlRouter.js';
70
72
  export * from './sseIdleTriage.js';
71
73
  export * from './engineWireSdk.js';
72
74
  export * from './classifierVerdictWire.js';
@@ -89,6 +91,8 @@ export * from './oneShotWireCaps.js';
89
91
  export * from './rewindWireCaps.js';
90
92
  export * from './rewindArchiveCapability.js';
91
93
  export * from './fileHistoryCaptureCapability.js';
94
+ export { FILE_HISTORY_LEG_VERDICTS, fileHistoryLegNoticeVerdict, fileHistoryLegNoticeSentence, fileHistoryDeclarationOfBody, createFileHistoryDeclarationLedger, } from './fileHistoryLegNotice.js';
95
+ export type { FileHistoryDeclarationFact, FileHistoryLegNoticeVerdict, FileHistoryLegNoticeInput, FileHistoryDeclarationLedger } from './fileHistoryLegNotice.js';
92
96
  export * from './sealedKeyCapability.js';
93
97
  export * from './storePostureCapability.js';
94
98
  export * from './centerWiringCapability.js';
@@ -111,6 +115,10 @@ export * from './adapter/downstream/terminalToSdkResult.js';
111
115
  export * from './adapter/runStream.js';
112
116
  export * from './adapter/activeRunSelfHeal.js';
113
117
  export * from './request/taskRequest.js';
118
+ export { disableSkillsDeclaration } from './disableSkillsWire.js';
119
+ export type { DisableSkillsDeclaration } from './disableSkillsWire.js';
120
+ export { permissionsDeclaration } from './permissionsDeclaration.js';
121
+ export type { PermissionsDeclaration, PermissionsDeclarationBuckets, PermissionsDeclarationInput, WireRuleOrigin, WireRuleOrigins } from './permissionsDeclaration.js';
114
122
  export * from './clientSlice.js';
115
123
  export * from './host.js';
116
124
  export { DEFAULT_SESSION_KEY } from './sessionSlot.js';
@@ -153,13 +161,16 @@ export type { PromptDeliveryLedger, PromptDeliveryRecord } from './promptDeliver
153
161
  export * from './resumeRefusalCopy.js';
154
162
  export * from './wireRefusalCopy.js';
155
163
  export * from './inheritEnvWire.js';
164
+ export { SUPPORT_FLOOR, supportFloorOf, engineVersionTier } from './supportFloor.js';
165
+ export type { SupportFloor, SupportFloorComponent, EngineVersionTier } from './supportFloor.js';
156
166
  export * from './decideReceipt.js';
157
167
  export * from './sessionMap.js';
158
168
  export * from './detachWire.js';
159
169
  export * from './workflowMonitor.js';
160
170
  export * from './workflowClient.js';
161
171
  export * from './hooksWireCaps.js';
162
- export { ENGINE_FIRED_HOOK_EVENTS, PLUGIN_HOOK_DISPOSITIONS, PLUGIN_HOOK_REASONS, PLUGIN_HOOK_EXCLUSION_REASONS, SETTINGS_HOOK_DROP_REASONS, isEngineFiredHookEvent, pluginHookVerdictOf, pluginHookReasonText, settingsHookDropText, pluginHookExecutorLabel, hooksNotRunNotice, type EngineFiredHookEvent, type PluginHookDisposition, type PluginHookReason, type PluginHookExclusionReason, type SettingsHookDropReason, type HookSettingsSource, type PluginHookKey, type PluginHookVerdict, type PluginHookExclusion, type SettingsHookDrop, type HooksWireEngineFacts, type PluginHookReaderState, type HooksWirePlan, type HooksWirePlanOptions, } from './pluginHooksWire.js';
172
+ export { ENGINE_FIRED_HOOK_EVENTS, PLUGIN_HOOK_DISPOSITIONS, PLUGIN_HOOK_REASONS, PLUGIN_HOOK_EXCLUSION_REASONS, SETTINGS_HOOK_DROP_REASONS, isEngineFiredHookEvent, pluginHookVerdictOf, pluginHookReasonText, settingsHookDropText, pluginHookExecutorLabel, hooksNotRunNotice, settingsHooksKeptLocally, type EngineFiredHookEvent, type PluginHookDisposition, type PluginHookReason, type PluginHookExclusionReason, type SettingsHookDropReason, type HookSettingsSource, type PluginHookKey, type PluginHookVerdict, type PluginHookExclusion, type SettingsHookDrop, type SettingsHookVerdict, type SettingsHookExclusion, type HooksWireEngineFacts, type PluginHookReaderState, type HooksWirePlan, type HooksWirePlanOptions, } from './pluginHooksWire.js';
173
+ export { hookToolAliasesOf, canonicalHookToolName } from './hookToolAliases.js';
163
174
  export * from './liveInitToolFace.js';
164
175
  export * from './printInitToolFace.js';
165
176
  export * from './model/providerPresets.js';
@@ -197,7 +208,7 @@ export * from './request/printNotification.js';
197
208
  export * from './seatContract.js';
198
209
  export * from './agentSession/contract.js';
199
210
  export * from './agentSession/backgroundView.js';
200
- export { READ_CREDENTIAL_NOT_ACCEPTED_NOTICE } from './readCredentialRefusal.js';
211
+ export { READ_CREDENTIAL_NOT_ACCEPTED_NOTICE, isReadCredentialRefusal } from './readCredentialRefusal.js';
201
212
  export { readEngineAgentRegistry, isEngineAgentRegistryListingSuperseded } from './agentSession/engineAgentRegistryRead.js';
202
213
  export type { EngineAgentRegistryClient } from './agentSession/engineAgentRegistryRead.js';
203
214
  export { stopEngineSessionBackground, engineSessionBackgroundReceiptReadingOf, ENGINE_SESSION_BACKGROUND_RECEIPT_STATES, } from './agentSession/engineSessionBackgroundStop.js';
package/dist/index.js CHANGED
@@ -26,6 +26,7 @@ export * from './executionLaneCapability.js';
26
26
  export * from './approvalsStreamLiveCapability.js';
27
27
  export * from './peerLaneCapability.js';
28
28
  export * from './permissionRulesWriteCapability.js';
29
+ export * from './permissionsAllowGrantCapability.js';
29
30
  export * from './sessionPolicyCapability.js';
30
31
  export * from './memoryComplianceCapability.js';
31
32
  export * from './memoryOriginCapability.js';
@@ -35,6 +36,7 @@ export * from './deviceExecutorManagementCapability.js';
35
36
  export * from './mcpReconnect.js';
36
37
  export * from './leaderConflict.js';
37
38
  export * from './runTerminal.js';
39
+ export { providerRejectionResend } from './providerRejection.js';
38
40
  export * from './runCancelContext.js';
39
41
  export * from './argvFlagValue.js';
40
42
  export * from './readFacePosture.js';
@@ -59,7 +61,7 @@ export * from './fleetTaskDesc.js';
59
61
  export { displayUntrusted, displayUntrustedMarks } from './displayUntrusted.js';
60
62
  export * from './hostEnv.js';
61
63
  export * from './unrefTimer.js';
62
- export * from './controlRouter.js';
64
+ export { ControlRouter, ControlSafetyError, errCodes, } from './controlRouter.js';
63
65
  export * from './sseIdleTriage.js';
64
66
  export * from './engineWireSdk.js';
65
67
  export * from './classifierVerdictWire.js';
@@ -81,6 +83,7 @@ export * from './oneShotWireCaps.js';
81
83
  export * from './rewindWireCaps.js';
82
84
  export * from './rewindArchiveCapability.js';
83
85
  export * from './fileHistoryCaptureCapability.js';
86
+ export { FILE_HISTORY_LEG_VERDICTS, fileHistoryLegNoticeVerdict, fileHistoryLegNoticeSentence, fileHistoryDeclarationOfBody, createFileHistoryDeclarationLedger, } from './fileHistoryLegNotice.js';
84
87
  export * from './sealedKeyCapability.js';
85
88
  export * from './storePostureCapability.js';
86
89
  export * from './centerWiringCapability.js';
@@ -102,6 +105,8 @@ export * from './adapter/downstream/terminalToSdkResult.js';
102
105
  export * from './adapter/runStream.js';
103
106
  export * from './adapter/activeRunSelfHeal.js';
104
107
  export * from './request/taskRequest.js';
108
+ export { disableSkillsDeclaration } from './disableSkillsWire.js';
109
+ export { permissionsDeclaration } from './permissionsDeclaration.js';
105
110
  export * from './clientSlice.js';
106
111
  export * from './host.js';
107
112
  export { DEFAULT_SESSION_KEY } from './sessionSlot.js';
@@ -139,13 +144,15 @@ export { createPromptDeliveryLedger, promptKnownUndelivered, withoutUndeliveredP
139
144
  export * from './resumeRefusalCopy.js';
140
145
  export * from './wireRefusalCopy.js';
141
146
  export * from './inheritEnvWire.js';
147
+ export { SUPPORT_FLOOR, supportFloorOf, engineVersionTier } from './supportFloor.js';
142
148
  export * from './decideReceipt.js';
143
149
  export * from './sessionMap.js';
144
150
  export * from './detachWire.js';
145
151
  export * from './workflowMonitor.js';
146
152
  export * from './workflowClient.js';
147
153
  export * from './hooksWireCaps.js';
148
- export { ENGINE_FIRED_HOOK_EVENTS, PLUGIN_HOOK_DISPOSITIONS, PLUGIN_HOOK_REASONS, PLUGIN_HOOK_EXCLUSION_REASONS, SETTINGS_HOOK_DROP_REASONS, isEngineFiredHookEvent, pluginHookVerdictOf, pluginHookReasonText, settingsHookDropText, pluginHookExecutorLabel, hooksNotRunNotice, } from './pluginHooksWire.js';
154
+ export { ENGINE_FIRED_HOOK_EVENTS, PLUGIN_HOOK_DISPOSITIONS, PLUGIN_HOOK_REASONS, PLUGIN_HOOK_EXCLUSION_REASONS, SETTINGS_HOOK_DROP_REASONS, isEngineFiredHookEvent, pluginHookVerdictOf, pluginHookReasonText, settingsHookDropText, pluginHookExecutorLabel, hooksNotRunNotice, settingsHooksKeptLocally, } from './pluginHooksWire.js';
155
+ export { hookToolAliasesOf, canonicalHookToolName } from './hookToolAliases.js';
149
156
  export * from './liveInitToolFace.js';
150
157
  export * from './printInitToolFace.js';
151
158
  export * from './model/providerPresets.js';
@@ -181,7 +188,7 @@ export * from './request/printNotification.js';
181
188
  export * from './seatContract.js';
182
189
  export * from './agentSession/contract.js';
183
190
  export * from './agentSession/backgroundView.js';
184
- export { READ_CREDENTIAL_NOT_ACCEPTED_NOTICE } from './readCredentialRefusal.js';
191
+ export { READ_CREDENTIAL_NOT_ACCEPTED_NOTICE, isReadCredentialRefusal } from './readCredentialRefusal.js';
185
192
  export { readEngineAgentRegistry, isEngineAgentRegistryListingSuperseded } from './agentSession/engineAgentRegistryRead.js';
186
193
  export { stopEngineSessionBackground, engineSessionBackgroundReceiptReadingOf, ENGINE_SESSION_BACKGROUND_RECEIPT_STATES, } from './agentSession/engineSessionBackgroundStop.js';
187
194
  export { eraseSessionMemory, sessionMemoryEraseOutcome, SESSION_MEMORY_ERASE_REFUSAL_REASONS, SESSION_MEMORY_ERASE_UNCONFIRMED_WHYS, SESSION_MEMORY_ERASE_RETRIES, } from './sessionMemoryErase.js';
@@ -0,0 +1,17 @@
1
+ export type PermissionsAllowGrantReading = {
2
+ kind: 'unobserved';
3
+ } | {
4
+ kind: 'not_reported';
5
+ } | {
6
+ kind: 'present';
7
+ grants: boolean;
8
+ };
9
+ export declare function projectPermissionsAllowGrantCapability(caps: unknown): PermissionsAllowGrantReading | undefined;
10
+ export declare function noteEngineCapsForPermissionsAllowGrant(baseUrl: string, caps: unknown, opts?: {
11
+ generation?: number;
12
+ }): void;
13
+ export declare function observedPermissionsAllowGrant(baseUrl?: string | undefined): PermissionsAllowGrantReading;
14
+ export declare function permissionsAllowGrantAvailable(reading: PermissionsAllowGrantReading): boolean;
15
+ export declare function permissionsAllowGrantDoctorDetail(reading: PermissionsAllowGrantReading): string;
16
+ export declare function forgetPermissionsAllowGrantReading(baseUrl: string | undefined): void;
17
+ export declare function __resetPermissionsAllowGrantReadingsForTests(): void;