@sema-agent/client-core 0.98.0 → 0.99.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 (192) hide show
  1. package/CHANGELOG.md +199 -0
  2. package/README.md +35 -22
  3. package/dist/adapt/arms.js +61 -20
  4. package/dist/adapt/panelTasks.d.ts +1 -1
  5. package/dist/adapt/panelTasks.js +2 -2
  6. package/dist/adapter/activeRunSelfHeal.d.ts +4 -3
  7. package/dist/adapter/activeRunSelfHeal.js +162 -293
  8. package/dist/adapter/downstream/eventToSdkMessage.js +52 -4
  9. package/dist/adapter/runStream.js +52 -37
  10. package/dist/adapter/types.js +2 -1
  11. package/dist/agentSession/engineSessionBackgroundStop.js +16 -8
  12. package/dist/agentsWireCaps.d.ts +0 -3
  13. package/dist/agentsWireCaps.js +33 -24
  14. package/dist/cloudConfigWireCaps.d.ts +1 -1
  15. package/dist/cloudConfigWireCaps.js +26 -4
  16. package/dist/controlRouter.d.ts +4 -2
  17. package/dist/controlRouter.js +39 -51
  18. package/dist/coreValuePorts.d.ts +26 -1
  19. package/dist/coreValuePorts.js +10 -0
  20. package/dist/corruptSessionCopy.d.ts +2 -1
  21. package/dist/corruptSessionCopy.js +3 -3
  22. package/dist/declared/supportFloorDeclared.js +1 -1
  23. package/dist/detachWire.js +3 -2
  24. package/dist/devicesFace.d.ts +34 -0
  25. package/dist/devicesFace.js +90 -0
  26. package/dist/displayUntrusted.d.ts +1 -0
  27. package/dist/displayUntrusted.js +3 -0
  28. package/dist/engineAgentPanelStore.d.ts +7 -0
  29. package/dist/engineAgentPanelStore.js +14 -0
  30. package/dist/engineCapReader.d.ts +2 -1
  31. package/dist/engineCapReader.js +7 -5
  32. package/dist/engineCapsCache.d.ts +8 -0
  33. package/dist/engineCapsCache.js +59 -6
  34. package/dist/engineCapsChange.d.ts +2 -0
  35. package/dist/engineCapsChange.js +9 -0
  36. package/dist/engineErrorCodes.d.ts +2 -1
  37. package/dist/engineErrorCodes.js +2 -7
  38. package/dist/engineRowRef.js +3 -0
  39. package/dist/engineSessionMessages.d.ts +1 -0
  40. package/dist/engineSessionMessages.js +7 -1
  41. package/dist/engineTargetSeat.d.ts +27 -0
  42. package/dist/engineTargetSeat.js +199 -0
  43. package/dist/engineWireFor.js +3 -8
  44. package/dist/env/uiLanguage.d.ts +2 -1
  45. package/dist/env/uiLanguage.js +3 -2
  46. package/dist/eventLeg.d.ts +8 -0
  47. package/dist/eventLeg.js +61 -41
  48. package/dist/fileHistoryCaptureCapability.d.ts +2 -1
  49. package/dist/fileHistoryCaptureCapability.js +12 -18
  50. package/dist/fileHistoryLegNotice.d.ts +2 -1
  51. package/dist/fileHistoryLegNotice.js +3 -3
  52. package/dist/frameBinding.d.ts +3 -0
  53. package/dist/frameBinding.js +12 -0
  54. package/dist/gateOutcome.js +16 -2
  55. package/dist/gateVocabulary.d.ts +8 -7
  56. package/dist/gateVocabulary.js +71 -73
  57. package/dist/generated/engineFactTables.d.ts +17 -1
  58. package/dist/generated/engineFactTables.js +29 -0
  59. package/dist/generated/engineNoticeTables.js +9 -3
  60. package/dist/generated/settingsSchemaFns.d.ts +6 -0
  61. package/dist/generated/settingsSchemaFns.js +57 -0
  62. package/dist/generated/settingsSchemaHooksClassifier.d.ts +2 -0
  63. package/dist/generated/settingsSchemaHooksClassifier.js +254 -0
  64. package/dist/generated/settingsSchemaTables.d.ts +1 -0
  65. package/dist/generated/settingsSchemaTables.js +4 -0
  66. package/dist/generated/settingsSchemaTypes.d.ts +105 -0
  67. package/dist/generated/settingsSchemaTypes.js +1 -0
  68. package/dist/hitl/allowRuleShadow.d.ts +2 -1
  69. package/dist/hitl/allowRuleShadow.js +17 -14
  70. package/dist/hitl/approvalCardReasons.d.ts +3 -2
  71. package/dist/hitl/approvalCardReasons.js +27 -28
  72. package/dist/hitl/approvalHolds.d.ts +3 -0
  73. package/dist/hitl/approvalHolds.js +73 -29
  74. package/dist/hitl/askClassPair.d.ts +1 -1
  75. package/dist/hitl/askClassPair.js +16 -0
  76. package/dist/hitl/askGateWire.js +2 -1
  77. package/dist/hitl/askSettlementLine.d.ts +14 -4
  78. package/dist/hitl/askSettlementLine.js +67 -47
  79. package/dist/hitl/automaticAnswerVerdict.d.ts +2 -1
  80. package/dist/hitl/automaticAnswerVerdict.js +8 -8
  81. package/dist/hitl/crashConvergedNotice.d.ts +5 -4
  82. package/dist/hitl/crashConvergedNotice.js +28 -41
  83. package/dist/hitl/frameRouter.js +7 -8
  84. package/dist/hitl/hitlBridge.d.ts +1 -0
  85. package/dist/hitl/hitlBridge.js +3 -3
  86. package/dist/hitl/persistedRulesWire.d.ts +6 -5
  87. package/dist/hitl/persistedRulesWire.js +55 -73
  88. package/dist/hitl/planReviewWire.d.ts +5 -0
  89. package/dist/hitl/planReviewWire.js +8 -0
  90. package/dist/hitl/sessionPolicyDeliverable.d.ts +2 -0
  91. package/dist/hitl/sessionPolicyDeliverable.js +46 -3
  92. package/dist/hitl/sessionPolicyWire.d.ts +2 -1
  93. package/dist/hitl/sessionPolicyWire.js +23 -24
  94. package/dist/hitl/suspendedReopen.d.ts +2 -1
  95. package/dist/hitl/suspendedReopen.js +7 -10
  96. package/dist/hitl/toolApprovalWire.d.ts +17 -5
  97. package/dist/hitl/toolApprovalWire.js +79 -40
  98. package/dist/hooksWireCaps.js +145 -56
  99. package/dist/host.d.ts +21 -0
  100. package/dist/hostTurnSettings.d.ts +71 -0
  101. package/dist/hostTurnSettings.js +291 -0
  102. package/dist/humanTurn.d.ts +14 -1
  103. package/dist/humanTurn.js +100 -12
  104. package/dist/humanTurnRead.d.ts +2 -0
  105. package/dist/humanTurnRead.js +22 -1
  106. package/dist/i18n/messages.en.d.ts +582 -0
  107. package/dist/i18n/messages.en.js +582 -0
  108. package/dist/i18n/messages.zh.js +718 -1
  109. package/dist/index.d.ts +29 -13
  110. package/dist/index.js +18 -9
  111. package/dist/inheritEnvCapability.d.ts +3 -2
  112. package/dist/inheritEnvCapability.js +3 -3
  113. package/dist/inheritEnvWire.d.ts +3 -2
  114. package/dist/inheritEnvWire.js +12 -14
  115. package/dist/interactiveHalt.js +17 -6
  116. package/dist/liveModelCatalog.d.ts +2 -1
  117. package/dist/liveModelCatalog.js +14 -8
  118. package/dist/mcpPanel.d.ts +10 -1
  119. package/dist/mcpPanel.js +40 -13
  120. package/dist/mcpProbeCapability.d.ts +2 -1
  121. package/dist/mcpProbeCapability.js +7 -11
  122. package/dist/mcpProbeWire.d.ts +3 -1
  123. package/dist/mcpProbeWire.js +5 -0
  124. package/dist/mcpWireCaps.d.ts +34 -0
  125. package/dist/mcpWireCaps.js +117 -17
  126. package/dist/memoryEntriesWire.js +5 -10
  127. package/dist/model/onboardJudgement.d.ts +93 -0
  128. package/dist/model/onboardJudgement.js +415 -0
  129. package/dist/model/tierVocabulary.d.ts +2 -0
  130. package/dist/model/tierVocabulary.js +17 -5
  131. package/dist/modelCapabilityProbe.d.ts +64 -0
  132. package/dist/modelCapabilityProbe.js +600 -0
  133. package/dist/modelIdentityResolvability.d.ts +3 -0
  134. package/dist/modelIdentityResolvability.js +26 -17
  135. package/dist/ownKey.d.ts +7 -0
  136. package/dist/ownKey.js +34 -0
  137. package/dist/panelReduce.d.ts +6 -1
  138. package/dist/panelReduce.js +50 -3
  139. package/dist/permissionRuleIssue.js +2 -0
  140. package/dist/permissionRulesWriteCapability.d.ts +2 -1
  141. package/dist/permissionRulesWriteCapability.js +8 -6
  142. package/dist/pluginHooksWire.d.ts +46 -3
  143. package/dist/pluginHooksWire.js +217 -11
  144. package/dist/printModelStatus.d.ts +63 -0
  145. package/dist/printModelStatus.js +155 -0
  146. package/dist/request/taskRequest.d.ts +11 -5
  147. package/dist/request/taskRequest.js +112 -16
  148. package/dist/resumeRefusalCopy.d.ts +12 -9
  149. package/dist/resumeRefusalCopy.js +70 -143
  150. package/dist/retryStatus.d.ts +37 -0
  151. package/dist/retryStatus.js +79 -0
  152. package/dist/scenarioRefusal.d.ts +9 -0
  153. package/dist/scenarioRefusal.js +111 -0
  154. package/dist/seam.d.ts +25 -1
  155. package/dist/seam.js +10 -1
  156. package/dist/seatContract.d.ts +260 -10
  157. package/dist/seatContract.js +692 -19
  158. package/dist/selfOrchestrationDenial.js +7 -19
  159. package/dist/sessionIdSegment.d.ts +6 -0
  160. package/dist/sessionIdSegment.js +24 -0
  161. package/dist/sessionMemoryStatus.js +6 -11
  162. package/dist/sessionPolicyCapability.d.ts +2 -1
  163. package/dist/sessionPolicyCapability.js +8 -6
  164. package/dist/settingsHooksSalvage.d.ts +44 -0
  165. package/dist/settingsHooksSalvage.js +211 -0
  166. package/dist/skillToolListsCapability.d.ts +2 -1
  167. package/dist/skillToolListsCapability.js +8 -6
  168. package/dist/sseIdleTriage.js +3 -2
  169. package/dist/subagent/engineSubagentResume.js +15 -9
  170. package/dist/subagentContentStore.d.ts +3 -0
  171. package/dist/subagentContentStore.js +22 -0
  172. package/dist/toolHistoryMismatch.js +3 -2
  173. package/dist/toolRoster.d.ts +3 -2
  174. package/dist/toolRoster.js +21 -20
  175. package/dist/turnFailurePresentation.d.ts +12 -1
  176. package/dist/turnFailurePresentation.js +212 -15
  177. package/dist/usageAnalytics.js +6 -11
  178. package/dist/userAttachmentEnvelope.d.ts +1 -0
  179. package/dist/userAttachmentEnvelope.js +37 -7
  180. package/dist/userAttachmentSeat.d.ts +21 -0
  181. package/dist/userAttachmentSeat.js +75 -0
  182. package/dist/userInvokedSkillsCapability.d.ts +11 -1
  183. package/dist/userInvokedSkillsCapability.js +31 -7
  184. package/dist/wireErrorTriage.d.ts +7 -0
  185. package/dist/wireErrorTriage.js +23 -1
  186. package/dist/wireFailureShape.js +2 -1
  187. package/dist/wireRefusalCopy.d.ts +13 -1
  188. package/dist/wireRefusalCopy.js +24 -28
  189. package/dist/workflowsJournalCapability.d.ts +2 -1
  190. package/dist/workflowsJournalCapability.js +8 -6
  191. package/docs/INTEGRATION-CLIENTS.md +542 -30
  192. package/package.json +5 -5
@@ -1,5 +1,6 @@
1
1
  import { displayUntrusted } from './displayUntrusted.js';
2
2
  import { SETTINGS_ENGINE_OWNED_HOOK_EVENTS } from './generated/settingsSchemaTables.js';
3
+ import { HOOK_SETTINGS_SOURCE_TEXT, hooksSalvageMaskOf, salvageSettingsHooksEntries, } from './settingsHooksSalvage.js';
3
4
  export const ENGINE_FIRED_HOOK_EVENTS = SETTINGS_ENGINE_OWNED_HOOK_EVENTS;
4
5
  export const PLUGIN_HOOK_DISPOSITIONS = ['engine', 'shell', 'not_run'];
5
6
  export const PLUGIN_HOOK_REASONS = [
@@ -22,6 +23,9 @@ export const PLUGIN_HOOK_REASONS = [
22
23
  'engine_llm_limit',
23
24
  'engine_unconfirmed',
24
25
  'engine_elsewhere',
26
+ 'hooks_module',
27
+ 'scope_unsupported',
28
+ 'source_incomplete',
25
29
  ];
26
30
  export const PLUGIN_HOOK_EXCLUSION_REASONS = [
27
31
  'workspace_untrusted',
@@ -32,6 +36,43 @@ export const PLUGIN_HOOK_EXCLUSION_REASONS = [
32
36
  'prompt_not_user_authored',
33
37
  ];
34
38
  export const SETTINGS_HOOK_DROP_REASONS = ['exec_form_unsupported', 'mcp_tool_unsupported'];
39
+ export function hooksWirePlanShapeOf(v) {
40
+ try {
41
+ if (typeof v !== 'object' || v === null || Array.isArray(v))
42
+ return 'not';
43
+ const o = v;
44
+ for (const k of PLAN_KEYS)
45
+ if (!Object.hasOwn(o, k) && !LATER_PLAN_KEYS.has(k))
46
+ return 'not';
47
+ const reader = o.pluginReader;
48
+ const engineFacts = o.engine;
49
+ const wire = o.wire;
50
+ const arrayOrAbsent = (k) => !Object.hasOwn(o, k) || Array.isArray(o[k]);
51
+ return Array.isArray(o.verdicts) &&
52
+ Array.isArray(o.excluded) &&
53
+ Array.isArray(o.settingsDropped) &&
54
+ arrayOrAbsent('settingsVerdicts') &&
55
+ arrayOrAbsent('settingsExcluded') &&
56
+ arrayOrAbsent('settingsSalvage') &&
57
+ arrayOrAbsent('moduleVerdicts') &&
58
+ arrayOrAbsent('sessionVerdicts') &&
59
+ (!Object.hasOwn(o, 'sessionReader') || o.sessionReader === 'present' || o.sessionReader === 'absent' || o.sessionReader === 'failed') &&
60
+ (!Object.hasOwn(o, 'closedBy') || o.closedBy === null || o.closedBy === 'workspace_untrusted' || o.closedBy === 'governance_unreadable' || o.closedBy === 'policy_disable_all') &&
61
+ (reader === 'present' || reader === 'absent' || reader === 'failed') &&
62
+ typeof engineFacts === 'object' &&
63
+ engineFacts !== null &&
64
+ (wire === undefined || (typeof wire === 'object' && wire !== null && !Array.isArray(wire)))
65
+ ? 'plan'
66
+ : 'not';
67
+ }
68
+ catch {
69
+ return 'threw';
70
+ }
71
+ }
72
+ const PLAN_KEYS = ['engine', 'pluginReader', 'verdicts', 'excluded', 'settingsDropped', 'settingsVerdicts', 'settingsExcluded', 'settingsSalvage', 'moduleVerdicts', 'sessionVerdicts', 'sessionReader', 'closedBy', 'wire'];
73
+ const LATER_PLAN_KEYS = new Set(['settingsVerdicts', 'settingsExcluded', 'settingsSalvage', 'moduleVerdicts', 'sessionVerdicts', 'sessionReader', 'closedBy']);
74
+ const _planKeysPin = [true, true];
75
+ void _planKeysPin;
35
76
  export const ENGINE_HOOK_LIMITS = { maxGroupsPerEvent: 16, maxEntriesPerEvent: 32, maxCommandChars: 8192, maxLlmEntriesPerEvent: 4 };
36
77
  const ENGINE_HOOK_TYPE_RUNS = new Set(['command', 'http', 'prompt', 'agent']);
37
78
  const COMPACTION_EVENTS = new Set(['PreCompact', 'PostCompact']);
@@ -39,6 +80,8 @@ const judged = (disposition, reason) => ({ kind: 'judged', disposition, reason }
39
80
  function hookExecutorOf(x) {
40
81
  if (x.event === 'UserPromptSubmit' && !x.promptAuthoredByUser)
41
82
  return { kind: 'excluded', reason: 'prompt_not_user_authored' };
83
+ if (x.source === 'session')
84
+ return judged(x.shellRuns ? 'shell' : 'not_run', 'scope_unsupported');
42
85
  if (x.source === 'settings') {
43
86
  const why = x.powershell
44
87
  ? { reason: 'engine_type_skipped', certain: true }
@@ -172,15 +215,25 @@ export function occupancyOf(wire) {
172
215
  export function decidePluginHooks(input) {
173
216
  const verdicts = [];
174
217
  const excluded = [];
218
+ const modules = [];
175
219
  const candidates = new Map();
176
220
  let unreadable = 0;
177
221
  const fallback = (event, type, reason) => input.shellRuns(event, typeof type === 'string' ? type : undefined) ? { disposition: 'shell', reason } : { disposition: 'not_run', reason };
178
222
  input.plugins.forEach((p, pluginIndex) => {
179
- if (!isRecord(p) || !isRecord(p.hooks)) {
223
+ if (!isRecord(p)) {
224
+ unreadable++;
225
+ return;
226
+ }
227
+ if (p.hooksModule === true && input.exclusion === undefined && !(input.managedOnly && p.managed !== true)) {
228
+ modules.push({ pluginId: typeof p.id === 'string' ? p.id : '', pluginName: typeof p.name === 'string' ? p.name : '', disposition: 'not_run', reason: 'hooks_module' });
229
+ }
230
+ if (!isRecord(p.hooks)) {
180
231
  unreadable++;
181
232
  return;
182
233
  }
183
234
  const src = p;
235
+ const sv = salvageSettingsHooksEntries({ hooks: p.hooks });
236
+ const pieceMask = hooksSalvageMaskOf(sv.outcome === 'loaded-partial' ? sv.dropped : []);
184
237
  const sourceOk = nonEmptyString(p.id) && nonEmptyString(p.name) && nonEmptyString(p.root) && nonEmptyString(p.dataDir);
185
238
  const pluginId = typeof p.id === 'string' ? p.id : '';
186
239
  const pluginName = typeof p.name === 'string' ? p.name : '';
@@ -207,7 +260,15 @@ export function decidePluginHooks(input) {
207
260
  return;
208
261
  }
209
262
  const entryType = isRecord(entry) && typeof entry.type === 'string' ? entry.type : undefined;
210
- const shape = sourceOk ? classifyEntry(entry, src.options) : { kind: 'malformed' };
263
+ if (!sourceOk) {
264
+ verdicts.push({ ...key, disposition: 'not_run', reason: 'source_incomplete' });
265
+ return;
266
+ }
267
+ if (!pieceMask.eventDropped(event) && pieceMask.entryDropped(event, groupIndex, hookIndex)) {
268
+ verdicts.push({ ...key, disposition: 'not_run', reason: 'malformed_entry' });
269
+ return;
270
+ }
271
+ const shape = classifyEntry(entry, src.options);
211
272
  if (shape.kind === 'malformed') {
212
273
  verdicts.push({ ...key, disposition: 'not_run', reason: 'malformed_entry' });
213
274
  return;
@@ -299,7 +360,79 @@ export function decidePluginHooks(input) {
299
360
  }
300
361
  projected.set(event, groupsOut);
301
362
  }
302
- return { verdicts, excluded, projected, unreadable };
363
+ const suppressed = input.suppressedLocally;
364
+ if (suppressed !== undefined && suppressed.size > 0) {
365
+ for (const v of verdicts) {
366
+ if (v.disposition !== 'shell' || !suppressed.has(v.pluginId))
367
+ continue;
368
+ v.disposition = 'not_run';
369
+ if (!ENGINE_EVENTS.has(v.event))
370
+ v.reason = 'no_executor';
371
+ }
372
+ }
373
+ return { verdicts, excluded, modules, projected, unreadable };
374
+ }
375
+ const SESSION_HOOK_ORIGINS = new Set(['skill', 'agent', 'sdk_host']);
376
+ const LOCAL_REGISTRATION_TYPES = new Set(['callback', 'function']);
377
+ const isLocalRegistration = (e) => isRecord(e) && typeof e.type === 'string' && LOCAL_REGISTRATION_TYPES.has(e.type);
378
+ const JUDGE_STAND_IN = Object.freeze({ type: 'command', command: 'true' });
379
+ function sessionHooksForJudge(hooks) {
380
+ const out = {};
381
+ for (const [event, groups] of Object.entries(hooks)) {
382
+ out[event] = Array.isArray(groups)
383
+ ? groups.map((g) => isRecord(g) && Array.isArray(g.hooks) && g.hooks.some(isLocalRegistration)
384
+ ? { ...g, hooks: g.hooks.map((e) => (isLocalRegistration(e) ? JUDGE_STAND_IN : e)) }
385
+ : g)
386
+ : groups;
387
+ }
388
+ return out;
389
+ }
390
+ export function decideSessionHooks(input) {
391
+ const out = [];
392
+ let unreadable = 0;
393
+ for (const src of input.sources) {
394
+ if (!isRecord(src) || typeof src.origin !== 'string' || !SESSION_HOOK_ORIGINS.has(src.origin) || !isRecord(src.hooks)) {
395
+ unreadable++;
396
+ continue;
397
+ }
398
+ const origin = src.origin;
399
+ const name = typeof src.name === 'string' ? src.name : '';
400
+ const sv = salvageSettingsHooksEntries({ hooks: sessionHooksForJudge(src.hooks) });
401
+ const rejectedWhole = sv.outcome === 'rejected';
402
+ const mask = hooksSalvageMaskOf(sv.outcome === 'loaded-partial' ? sv.dropped : []);
403
+ for (const [event, groups] of Object.entries(src.hooks)) {
404
+ if (!Array.isArray(groups)) {
405
+ unreadable++;
406
+ continue;
407
+ }
408
+ ;
409
+ groups.forEach((group, groupIndex) => {
410
+ if (!isRecord(group) || !Array.isArray(group.hooks)) {
411
+ unreadable++;
412
+ return;
413
+ }
414
+ ;
415
+ group.hooks.forEach((entry, hookIndex) => {
416
+ const key = { origin, name, event, groupIndex, hookIndex };
417
+ const type = isRecord(entry) && typeof entry.type === 'string' ? entry.type : undefined;
418
+ if (rejectedWhole || (!mask.eventDropped(event) && mask.entryDropped(event, groupIndex, hookIndex)) || type === undefined) {
419
+ out.push({ ...key, disposition: 'not_run', reason: 'malformed_entry' });
420
+ return;
421
+ }
422
+ const shellRuns = input.shellRuns(event, type);
423
+ if (!ENGINE_EVENTS.has(event)) {
424
+ out.push({ ...key, ...(shellRuns ? { disposition: 'shell', reason: 'shell_event' } : { disposition: 'not_run', reason: 'no_executor' }) });
425
+ return;
426
+ }
427
+ const ex = hookExecutorOf({ source: 'session', event, powershell: false, llmPosition: 0, engine: input.engine, shellRuns, promptAuthoredByUser: input.promptAuthoredByUser });
428
+ if (ex.kind === 'excluded')
429
+ return;
430
+ out.push({ ...key, disposition: ex.disposition, reason: ex.reason });
431
+ });
432
+ });
433
+ }
434
+ }
435
+ return { verdicts: out, unreadable };
303
436
  }
304
437
  const SHELL_INERT_COMMAND = /^[A-Za-z0-9_./:+-]+$/;
305
438
  function carriesArgs(entry) {
@@ -312,7 +445,7 @@ function carriesArgs(entry) {
312
445
  }
313
446
  return true;
314
447
  }
315
- export function filterSettingsHookGroups(source, event, groups, execFormCapable, shellRunsType, judge) {
448
+ export function filterSettingsHookGroups(source, event, groups, execFormCapable, shellRunsType, judge, mask) {
316
449
  const drops = [];
317
450
  const verdicts = [];
318
451
  const excluded = [];
@@ -320,6 +453,8 @@ export function filterSettingsHookGroups(source, event, groups, execFormCapable,
320
453
  let stripped = 0;
321
454
  const engineEvent = ENGINE_EVENTS.has(event);
322
455
  groups.forEach((group, groupIndex) => {
456
+ if (mask !== undefined && mask.groupDropped(event, groupIndex))
457
+ return;
323
458
  if (!isRecord(group) || !Array.isArray(group.hooks)) {
324
459
  out.push(group);
325
460
  return;
@@ -327,6 +462,10 @@ export function filterSettingsHookGroups(source, event, groups, execFormCapable,
327
462
  const kept = [];
328
463
  let changed = false;
329
464
  group.hooks.forEach((entry, hookIndex) => {
465
+ if (mask !== undefined && mask.entryDropped(event, groupIndex, hookIndex)) {
466
+ changed = true;
467
+ return;
468
+ }
330
469
  const reason = !isRecord(entry)
331
470
  ? undefined
332
471
  : entry.type === 'mcp_tool'
@@ -665,18 +804,15 @@ const REASON_TEXT = {
665
804
  engine_llm_limit: 'the engine may skip prompt or agent hooks after the first four on one event',
666
805
  engine_unconfirmed: 'it is sent to the engine, which is expected to run it, but this client cannot confirm that',
667
806
  engine_elsewhere: 'it is not confirmed that the engine was started by this client on this machine, so this client runs it itself',
807
+ hooks_module: 'hooks registered in code by a plugin module run neither in the engine nor in this client',
808
+ scope_unsupported: 'hooks registered for a skill, an agent or by the host application are not sent to the engine, and this client does not run this event',
809
+ source_incomplete: 'the plugin was reported without its id, name, root folder or data folder',
668
810
  };
669
811
  const DROP_TEXT = {
670
812
  exec_form_unsupported: 'exec-form hooks (with "args") are sent to the engine only once it reports support for them',
671
813
  mcp_tool_unsupported: 'MCP tool hooks are not supported by the engine',
672
814
  };
673
- const SOURCE_TEXT = {
674
- policySettings: 'Managed settings',
675
- userSettings: 'User settings',
676
- projectSettings: 'Project settings',
677
- localSettings: 'Local settings',
678
- flagSettings: 'Flag settings',
679
- };
815
+ const SOURCE_TEXT = HOOK_SETTINGS_SOURCE_TEXT;
680
816
  export function pluginHookReasonText(reason) {
681
817
  return REASON_TEXT[reason];
682
818
  }
@@ -786,5 +922,75 @@ export function hooksNotRunNotice(plan) {
786
922
  const events = row.events.map((e) => noticeLabel(e)).join(', ');
787
923
  lines.push(`${SOURCE_TEXT[row.source]}: ${events} ${row.count === 1 ? 'hook' : 'hooks'} will not run — ${pluginHookReasonText(row.reason)}.`);
788
924
  }
925
+ const moduleRows = plan.moduleVerdicts;
926
+ for (const raw of Array.isArray(moduleRows) ? moduleRows : []) {
927
+ if (!isRecord(raw) || ownField(raw, 'disposition') !== 'not_run')
928
+ continue;
929
+ const reason = ownField(raw, 'reason');
930
+ const name = ownField(raw, 'pluginName');
931
+ if (typeof reason !== 'string' || !REASON_SET.has(reason))
932
+ continue;
933
+ lines.push(`Plugin "${noticeLabel(typeof name === 'string' ? name : '') || '(unnamed)'}": hooks module will not run — ${pluginHookReasonText(reason)}.`);
934
+ }
935
+ const sessionRows = plan.sessionVerdicts;
936
+ const bySession = new Map();
937
+ for (const raw of Array.isArray(sessionRows) ? sessionRows : []) {
938
+ if (!isRecord(raw) || ownField(raw, 'disposition') !== 'not_run')
939
+ continue;
940
+ const origin = ownField(raw, 'origin');
941
+ const name = ownField(raw, 'name');
942
+ const reason = ownField(raw, 'reason');
943
+ const event = ownField(raw, 'event');
944
+ if (typeof origin !== 'string' || !SESSION_HOOK_ORIGINS.has(origin) || typeof reason !== 'string' || !REASON_SET.has(reason) || typeof event !== 'string')
945
+ continue;
946
+ const nm = typeof name === 'string' ? name : '';
947
+ const k = `${origin}\u0000${nm}\u0000${reason}`;
948
+ const row = bySession.get(k) ?? { origin: origin, name: nm, reason: reason, events: [], count: 0 };
949
+ if (!row.events.includes(event))
950
+ row.events.push(event);
951
+ row.count++;
952
+ bySession.set(k, row);
953
+ }
954
+ for (const row of bySession.values()) {
955
+ const events = row.events.map((e) => noticeLabel(e)).join(', ');
956
+ const who = row.origin === 'sdk_host' ? 'Host application hooks' : `${row.origin === 'skill' ? 'Skill' : 'Agent'} "${noticeLabel(row.name) || '(unnamed)'}"`;
957
+ lines.push(`${who}: ${events} ${row.count === 1 ? 'hook' : 'hooks'} will not run — ${pluginHookReasonText(row.reason)}.`);
958
+ }
959
+ const salvageRows = plan.settingsSalvage;
960
+ for (const row of Array.isArray(salvageRows) ? salvageRows : []) {
961
+ const notice = isRecord(row) ? ownField(row, 'notice') : undefined;
962
+ if (typeof notice === 'string' && notice.length > 0)
963
+ lines.push(notice);
964
+ }
789
965
  return lines;
790
966
  }
967
+ export function userPromptSubmitExecutorOf(plan) {
968
+ try {
969
+ const p = plan;
970
+ if (!isRecord(p))
971
+ return 'unknown';
972
+ const verdicts = ownField(p, 'verdicts');
973
+ if (!Array.isArray(verdicts))
974
+ return 'unknown';
975
+ const rows = [...verdicts];
976
+ for (const k of ['settingsVerdicts', 'sessionVerdicts']) {
977
+ const v = ownField(p, k);
978
+ if (v === undefined)
979
+ continue;
980
+ if (!Array.isArray(v))
981
+ return 'unknown';
982
+ rows.push(...v);
983
+ }
984
+ const ups = rows.filter((r) => isRecord(r) && ownField(r, 'event') === 'UserPromptSubmit').map((r) => ownField(r, 'disposition'));
985
+ if (ups.length === 0)
986
+ return 'none';
987
+ if (ups.some((d) => d === 'engine'))
988
+ return 'engine';
989
+ if (ups.every((d) => d === 'shell'))
990
+ return 'shell';
991
+ return 'unknown';
992
+ }
993
+ catch {
994
+ return 'unknown';
995
+ }
996
+ }
@@ -0,0 +1,63 @@
1
+ import type { SDKAssistantMessageError } from '@sema-agent/agent-types';
2
+ import { type RetryStatus, type RetryStatusArmLike, type RetryStatusNotice } from './retryStatus.js';
3
+ export declare const PRINT_MODEL_STATUS_SUBTYPE = "_sema_model_status";
4
+ export declare const PRINT_LAST_MODEL_STATUS_KEY = "_sema_last_model_status";
5
+ export interface PrintModelStatusCtx {
6
+ readonly sessionId: string;
7
+ readonly nowMs: number;
8
+ readonly mintUuid: () => string;
9
+ readonly model?: string;
10
+ }
11
+ export interface PrintModelStatusPayload {
12
+ readonly kind: RetryStatus['kind'];
13
+ readonly terminal?: true;
14
+ readonly attempt?: number;
15
+ readonly max_retries?: number;
16
+ readonly retry_delay_ms?: number;
17
+ readonly error_status?: number;
18
+ readonly provider_condition?: string;
19
+ readonly err_class?: string;
20
+ readonly elapsed_ms?: number;
21
+ readonly timeout_ms?: number;
22
+ readonly model?: string;
23
+ readonly phase: RetryStatusNotice['phase'];
24
+ readonly recourse?: NonNullable<RetryStatusNotice['recourse']>;
25
+ readonly message: string;
26
+ }
27
+ export interface PrintApiRetryFrame {
28
+ readonly type: 'system';
29
+ readonly subtype: 'api_retry';
30
+ readonly attempt: number;
31
+ readonly max_retries: number;
32
+ readonly retry_delay_ms: number;
33
+ readonly error_status: number | null;
34
+ readonly error: SDKAssistantMessageError;
35
+ readonly _sema_provider_condition?: string;
36
+ readonly _sema_model?: string;
37
+ readonly _sema_message: string;
38
+ readonly uuid: string;
39
+ readonly session_id: string;
40
+ }
41
+ export interface PrintModelStatusSupersetFrame {
42
+ readonly type: 'system';
43
+ readonly subtype: typeof PRINT_MODEL_STATUS_SUBTYPE;
44
+ readonly _sema_model_status: PrintModelStatusPayload & {
45
+ readonly refresh?: true;
46
+ };
47
+ readonly uuid: string;
48
+ readonly session_id: string;
49
+ }
50
+ export type PrintModelStatusFrame = PrintApiRetryFrame | PrintModelStatusSupersetFrame;
51
+ export interface PrintModelStatusResultFields {
52
+ readonly _sema_last_model_status?: PrintModelStatusPayload;
53
+ }
54
+ export interface PrintLaneArmLike extends RetryStatusArmLike {
55
+ readonly type?: string;
56
+ readonly event?: RetryStatusArmLike;
57
+ }
58
+ export interface PrintModelStatusTracker {
59
+ take(msg: PrintLaneArmLike | null | undefined, ctx: PrintModelStatusCtx): PrintModelStatusFrame | null;
60
+ beginTurn(): void;
61
+ resultFields(nowMs: number): PrintModelStatusResultFields;
62
+ }
63
+ export declare function createPrintModelStatusTracker(): PrintModelStatusTracker;
@@ -0,0 +1,155 @@
1
+ import { retryStatusFromArm, retryStatusNotice } from './retryStatus.js';
2
+ import { guardedRead, readOwnDataFiniteNumber, readOwnDataNonEmptyString, readOwnDataValue } from './ownKey.js';
3
+ export const PRINT_MODEL_STATUS_SUBTYPE = '_sema_model_status';
4
+ export const PRINT_LAST_MODEL_STATUS_KEY = '_sema_last_model_status';
5
+ function httpStatusOf(v) {
6
+ return typeof v === 'number' && Number.isInteger(v) && v > 0 && v <= 999 ? v : undefined;
7
+ }
8
+ function ccRetryErrorCategory(status) {
9
+ const code = httpStatusOf(status.errorStatus);
10
+ if (code === 529 || status.providerCondition === 'overloaded')
11
+ return 'overloaded';
12
+ if (code === 429)
13
+ return 'rate_limit';
14
+ if (code === 401 || code === 403)
15
+ return 'authentication_failed';
16
+ if (code !== undefined && code >= 408)
17
+ return 'server_error';
18
+ return 'unknown';
19
+ }
20
+ function modelStatusPayload(status, ctx) {
21
+ const code = httpStatusOf(status.errorStatus);
22
+ const terminal = 'terminal' in status && status.terminal === true;
23
+ const sane = (v) => (typeof v === 'number' && Number.isFinite(v) && v >= 0 ? v : undefined);
24
+ const count = (v) => (typeof v === 'number' && Number.isInteger(v) && v >= 0 ? v : undefined);
25
+ const retryDelayMs = status.kind !== 'waiting' && !terminal ? sane(Math.max(0, status.deadline - ctx.nowMs)) : undefined;
26
+ const attempt = count(status.attempt);
27
+ const maxRetries = count(status.maxRetries);
28
+ const elapsed = sane(status.elapsedMs);
29
+ const ceiling = sane(status.timeoutMs);
30
+ const model = ctx.model !== undefined && ctx.model.length > 0 ? ctx.model : undefined;
31
+ const notice = retryStatusNotice(status, model !== undefined ? { modelName: model } : undefined);
32
+ return {
33
+ kind: status.kind,
34
+ ...(terminal ? { terminal: true } : {}),
35
+ ...(attempt !== undefined ? { attempt } : {}),
36
+ ...(maxRetries !== undefined ? { max_retries: maxRetries } : {}),
37
+ ...(retryDelayMs !== undefined ? { retry_delay_ms: retryDelayMs } : {}),
38
+ ...(code !== undefined ? { error_status: code } : {}),
39
+ ...(typeof status.providerCondition === 'string' ? { provider_condition: status.providerCondition } : {}),
40
+ ...(typeof status.errClass === 'string' ? { err_class: status.errClass } : {}),
41
+ ...(elapsed !== undefined ? { elapsed_ms: elapsed } : {}),
42
+ ...(ceiling !== undefined ? { timeout_ms: ceiling } : {}),
43
+ ...(model !== undefined ? { model } : {}),
44
+ phase: notice.phase,
45
+ ...(notice.recourse !== undefined ? { recourse: notice.recourse } : {}),
46
+ message: notice.line,
47
+ };
48
+ }
49
+ function apiRetryKeyOf(status) {
50
+ const terminal = 'terminal' in status && status.terminal === true;
51
+ const ok = (v) => typeof v === 'number' && Number.isInteger(v) && v >= 0;
52
+ if (status.kind === 'waiting' || terminal || !ok(status.attempt) || !ok(status.maxRetries))
53
+ return null;
54
+ return `${String(status.attempt)}/${String(status.maxRetries)}/${String(status.errClass ?? '')}/${String(status.errorStatus ?? '')}`;
55
+ }
56
+ function statusFrameOf(status, ctx, uuid, refresh) {
57
+ const payload = modelStatusPayload(status, ctx);
58
+ if (apiRetryKeyOf(status) !== null && !refresh) {
59
+ return {
60
+ type: 'system',
61
+ subtype: 'api_retry',
62
+ attempt: status.attempt ?? 0,
63
+ max_retries: status.maxRetries ?? 0,
64
+ retry_delay_ms: payload.retry_delay_ms ?? 0,
65
+ error_status: payload.error_status ?? null,
66
+ error: ccRetryErrorCategory(status),
67
+ ...(payload.provider_condition !== undefined ? { _sema_provider_condition: payload.provider_condition } : {}),
68
+ ...(payload.model !== undefined ? { _sema_model: payload.model } : {}),
69
+ _sema_message: payload.message,
70
+ uuid,
71
+ session_id: ctx.sessionId,
72
+ };
73
+ }
74
+ return { type: 'system', subtype: PRINT_MODEL_STATUS_SUBTYPE, _sema_model_status: { ...payload, ...(refresh ? { refresh: true } : {}) }, uuid, session_id: ctx.sessionId };
75
+ }
76
+ function isMainLaneArm(msg) {
77
+ const tri = (o, key) => {
78
+ try {
79
+ const d = Object.getOwnPropertyDescriptor(o, key);
80
+ if (d !== undefined && !('value' in d))
81
+ return { ok: false };
82
+ return { ok: true, v: readOwnDataValue(o, key) };
83
+ }
84
+ catch {
85
+ return { ok: false };
86
+ }
87
+ };
88
+ const top = tri(msg, 'parentToolCallId');
89
+ if (!top.ok)
90
+ return false;
91
+ const event = tri(msg, 'event');
92
+ if (!event.ok)
93
+ return false;
94
+ const nested = typeof event.v === 'object' && event.v !== null ? tri(event.v, 'parentToolCallId') : { ok: true, v: undefined };
95
+ if (!nested.ok)
96
+ return false;
97
+ return typeof top.v !== 'string' && typeof nested.v !== 'string';
98
+ }
99
+ export function createPrintModelStatusTracker() {
100
+ let last = null;
101
+ let lastApiRetryKey = null;
102
+ const clear = () => {
103
+ last = null;
104
+ lastApiRetryKey = null;
105
+ };
106
+ return {
107
+ take(msg, ctx) {
108
+ try {
109
+ const type = guardedRead(() => readOwnDataValue(msg, 'type'));
110
+ if (type === 'stream_event' || type === 'tool_end_result') {
111
+ if (msg !== null && msg !== undefined && isMainLaneArm(msg))
112
+ clear();
113
+ return null;
114
+ }
115
+ if (type !== 'retry_status')
116
+ return null;
117
+ const sessionId = readOwnDataNonEmptyString(ctx, 'sessionId');
118
+ const mintUuid = readOwnDataValue(ctx, 'mintUuid');
119
+ const nowMs = readOwnDataFiniteNumber(ctx, 'nowMs');
120
+ if (sessionId === undefined || typeof mintUuid !== 'function' || nowMs === undefined)
121
+ return null;
122
+ const status = retryStatusFromArm(msg, nowMs);
123
+ if (status === undefined)
124
+ return null;
125
+ if (status === null) {
126
+ clear();
127
+ return null;
128
+ }
129
+ const model = readOwnDataNonEmptyString(ctx, 'model');
130
+ const key = apiRetryKeyOf(status);
131
+ const refresh = key !== null && key === lastApiRetryKey;
132
+ const safeCtx = { sessionId, nowMs, mintUuid, ...(model !== undefined ? { model } : {}) };
133
+ const frame = statusFrameOf(status, safeCtx, mintUuid(), refresh);
134
+ lastApiRetryKey = key;
135
+ last = { status, model };
136
+ return frame;
137
+ }
138
+ catch {
139
+ return null;
140
+ }
141
+ },
142
+ beginTurn: clear,
143
+ resultFields(nowMs) {
144
+ try {
145
+ if (last === null)
146
+ return {};
147
+ const now = typeof nowMs === 'number' && Number.isFinite(nowMs) ? nowMs : 0;
148
+ return { _sema_last_model_status: modelStatusPayload(last.status, { ...(last.model !== undefined ? { model: last.model } : {}), nowMs: now }) };
149
+ }
150
+ catch {
151
+ return {};
152
+ }
153
+ },
154
+ };
155
+ }
@@ -1,6 +1,7 @@
1
- import type { TaskRequest } from '@sema-agent/sdk';
1
+ import type { TaskRequest, UserAttachment } from '@sema-agent/sdk';
2
2
  import { type OutputStyleSeatReading } from '../outputStyleSeatCapability.js';
3
3
  import { type ApprovalReachWord } from '../approvalReachWire.js';
4
+ import { type HostTurnSettings, type HostTurnSettingsInput } from '../hostTurnSettings.js';
4
5
  export type RequestLane = 'interactive' | 'print' | 'utility';
5
6
  export type TaskRequestLike = Record<string, unknown>;
6
7
  export interface RequestFieldSpec {
@@ -22,7 +23,9 @@ export interface TaskRequestInput {
22
23
  reasoningEffort?: string;
23
24
  model?: string;
24
25
  images?: readonly unknown[];
26
+ userAttachments?: readonly UserAttachment[];
25
27
  skills?: unknown;
28
+ userInvokedSkills?: readonly string[];
26
29
  mcpServers?: unknown;
27
30
  clientContext?: Record<string, unknown>;
28
31
  scratchpadDir?: string;
@@ -58,12 +61,13 @@ export interface TaskRequestInput {
58
61
  disableSkills?: TaskRequest['disableSkills'];
59
62
  rewind?: Record<string, unknown>;
60
63
  repo?: string;
64
+ hostSettings: HostTurnSettings;
61
65
  settings?: {
62
- resolved?: Record<string, unknown>;
63
- webSearch?: Record<string, unknown>;
66
+ resolved?: never;
67
+ webSearch?: never;
64
68
  ultracode?: boolean;
65
- hooks?: Record<string, unknown>;
66
- outputStyle?: string;
69
+ hooks?: never;
70
+ outputStyle?: never;
67
71
  };
68
72
  }
69
73
  export declare const TASK_REQUEST_OMISSION_CAUSES: readonly ["upstream_absent", "other_channel", "off_lane", "not_live"];
@@ -78,6 +82,7 @@ export declare function taskRequestOmissionCauseNotice(cause: unknown): string;
78
82
  export interface TaskRequestAssembly {
79
83
  readonly request: TaskRequestLike;
80
84
  readonly omitted: readonly TaskRequestOmission[];
85
+ readonly host: HostTurnSettings;
81
86
  }
82
87
  export type TaskRequestSeatReading = {
83
88
  readonly seat: 'seated';
@@ -95,6 +100,7 @@ export interface UpstreamAbsentRequestIntent {
95
100
  export declare const UPSTREAM_ABSENT_REQUEST_INTENTS: readonly UpstreamAbsentRequestIntent[];
96
101
  export declare const REQUEST_LANES: readonly RequestLane[];
97
102
  export declare function taskRequestSeatOf(key: string, lane: RequestLane): TaskRequestSeatReading;
103
+ export declare function hostTurnSettings(input: HostTurnSettingsInput): HostTurnSettings;
98
104
  export declare const MEMORY_CAPTURE_OFF: "off";
99
105
  export declare function memoryCaptureDeclarationField(declared: boolean): {
100
106
  memoryCapture: 'off';