@sema-agent/client-core 0.91.0 → 0.92.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/CHANGELOG.md +172 -0
  2. package/README.md +31 -21
  3. package/dist/adapt/arms.js +4 -12
  4. package/dist/adapt/panelTasks.d.ts +0 -2
  5. package/dist/adapt/panelTasks.js +6 -26
  6. package/dist/adapt.js +2 -2
  7. package/dist/adapter/activeRunSelfHeal.d.ts +0 -2
  8. package/dist/adapter/activeRunSelfHeal.js +5 -27
  9. package/dist/adapter/downstream/terminalToSdkResult.js +16 -7
  10. package/dist/adapter/runStream.js +3 -1
  11. package/dist/askSurvivesStandingAnswer.d.ts +4 -1
  12. package/dist/askSurvivesStandingAnswer.js +13 -0
  13. package/dist/autoModeUnavailable.js +3 -2
  14. package/dist/cloudConfigWireCaps.js +5 -4
  15. package/dist/compensations.js +5 -5
  16. package/dist/controlRouter.d.ts +23 -23
  17. package/dist/controlRouter.js +114 -49
  18. package/dist/coreValuePorts.d.ts +4 -2
  19. package/dist/coreValuePorts.js +5 -0
  20. package/dist/decideFailureNote.js +4 -2
  21. package/dist/decideReceipt.d.ts +9 -0
  22. package/dist/decideReceipt.js +62 -1
  23. package/dist/displayUntrusted.js +2 -1
  24. package/dist/effectiveFacts.d.ts +14 -4
  25. package/dist/effectiveFacts.js +45 -5
  26. package/dist/engineAgentAbsence.js +2 -1
  27. package/dist/engineCapReader.js +16 -10
  28. package/dist/engineCapsCache.d.ts +2 -0
  29. package/dist/engineCapsCache.js +13 -2
  30. package/dist/engineErrorCodes.d.ts +14 -0
  31. package/dist/engineErrorCodes.js +37 -0
  32. package/dist/engineNoticeCodes.d.ts +14 -0
  33. package/dist/engineNoticeCodes.js +71 -0
  34. package/dist/executionLaneCapability.js +2 -0
  35. package/dist/gateOutcome.js +2 -17
  36. package/dist/gateVocabulary.d.ts +2 -4
  37. package/dist/gateVocabulary.js +3 -11
  38. package/dist/generated/engineFactTables.d.ts +16 -1
  39. package/dist/generated/engineFactTables.js +81 -0
  40. package/dist/generated/engineNoticeTables.js +3 -0
  41. package/dist/generated/settingsSchemaTables.d.ts +8 -0
  42. package/dist/generated/settingsSchemaTables.js +40 -0
  43. package/dist/hitl/allowRuleShadow.d.ts +21 -0
  44. package/dist/hitl/allowRuleShadow.js +167 -0
  45. package/dist/hitl/askClassPair.d.ts +14 -0
  46. package/dist/hitl/askClassPair.js +42 -0
  47. package/dist/hitl/askGateWire.js +1 -0
  48. package/dist/hitl/askSurvivesPosture.d.ts +5 -0
  49. package/dist/hitl/askSurvivesPosture.js +17 -0
  50. package/dist/hitl/automaticAnswerVerdict.d.ts +21 -0
  51. package/dist/hitl/automaticAnswerVerdict.js +143 -0
  52. package/dist/hitl/crashConverged.d.ts +1 -0
  53. package/dist/hitl/crashConverged.js +1 -1
  54. package/dist/hitl/frameRouter.d.ts +2 -0
  55. package/dist/hitl/frameRouter.js +66 -14
  56. package/dist/hitl/gateLedger.d.ts +6 -0
  57. package/dist/hitl/gateLedger.js +34 -5
  58. package/dist/hitl/hitlHostSurface.d.ts +2 -0
  59. package/dist/hitl/hitlHostSurface.js +7 -0
  60. package/dist/hitl/livePendingAsk.js +24 -5
  61. package/dist/hitl/parkResolver.js +3 -1
  62. package/dist/hitl/persistedRulesWire.d.ts +4 -1
  63. package/dist/hitl/persistedRulesWire.js +9 -2
  64. package/dist/hitl/planReviewWire.js +2 -2
  65. package/dist/hitl/replayedApproval.d.ts +21 -0
  66. package/dist/hitl/replayedApproval.js +89 -0
  67. package/dist/hitl/sessionPolicyDeliverable.js +20 -2
  68. package/dist/hitl/sessionPolicyWire.d.ts +8 -0
  69. package/dist/hitl/sessionPolicyWire.js +12 -2
  70. package/dist/hitl/toolApprovalWire.d.ts +6 -1
  71. package/dist/hitl/toolApprovalWire.js +20 -40
  72. package/dist/hookMatcherVerdict.js +2 -1
  73. package/dist/humanTurn.js +3 -4
  74. package/dist/index.d.ts +15 -5
  75. package/dist/index.js +12 -3
  76. package/dist/inheritEnvWire.js +3 -4
  77. package/dist/mcpLiveness.js +2 -1
  78. package/dist/memoryVerbsWire.d.ts +1 -1
  79. package/dist/memoryVerbsWire.js +3 -0
  80. package/dist/model/catalog.js +2 -1
  81. package/dist/model/providerPresets.d.ts +3 -1
  82. package/dist/model/tierVocabulary.d.ts +2 -1
  83. package/dist/model/tierVocabulary.js +3 -8
  84. package/dist/peerFrames.js +2 -2
  85. package/dist/permissionRuleIssue.js +9 -6
  86. package/dist/permissionsDeclaration.d.ts +7 -1
  87. package/dist/permissionsDeclaration.js +29 -20
  88. package/dist/pluginHooksWire.js +2 -11
  89. package/dist/promptProfileWireCaps.d.ts +2 -1
  90. package/dist/protocolSegment.d.ts +9 -0
  91. package/dist/protocolSegment.js +28 -0
  92. package/dist/request/taskRequest.js +1 -15
  93. package/dist/ruleCompileVerdict.d.ts +2 -0
  94. package/dist/ruleCompileVerdict.js +13 -0
  95. package/dist/ruleRemovalConsequence.d.ts +2 -1
  96. package/dist/runCancelContext.d.ts +12 -0
  97. package/dist/runCancelContext.js +83 -1
  98. package/dist/seam.js +1 -1
  99. package/dist/seatContract.d.ts +2 -1
  100. package/dist/sessionMemoryStatus.d.ts +2 -4
  101. package/dist/sessionSyncFileHistoryCapability.d.ts +18 -0
  102. package/dist/sessionSyncFileHistoryCapability.js +50 -0
  103. package/dist/skillToolListsCapability.d.ts +18 -0
  104. package/dist/skillToolListsCapability.js +50 -0
  105. package/dist/sqlEngineCapability.js +1 -8
  106. package/dist/steerPriorityCapability.d.ts +18 -0
  107. package/dist/steerPriorityCapability.js +80 -0
  108. package/dist/steerReceipt.d.ts +9 -0
  109. package/dist/steerReceipt.js +25 -0
  110. package/dist/subagent/engineSubagentSteer.js +2 -9
  111. package/dist/supportFloor.js +2 -2
  112. package/dist/toolResult.d.ts +8 -0
  113. package/dist/toolResult.js +47 -3
  114. package/dist/types/engineState.d.ts +2 -12
  115. package/dist/userInvokedSkillsCapability.d.ts +18 -0
  116. package/dist/userInvokedSkillsCapability.js +50 -0
  117. package/dist/wireFailureShape.d.ts +2 -0
  118. package/dist/wireFailureShape.js +4 -0
  119. package/dist/workflowsJournalCapability.d.ts +18 -0
  120. package/dist/workflowsJournalCapability.js +50 -0
  121. package/dist/writeProtectionCapability.d.ts +2 -4
  122. package/docs/INTEGRATION-CLIENTS.md +624 -12
  123. package/package.json +2 -2
@@ -15,6 +15,8 @@ export declare const PROTOCOL_MARKERS: {
15
15
  readonly delegationTrailerFork: "Verify this result before concluding. If it leaves more to do, continue the work yourself or fork again.";
16
16
  readonly taskOutputLabel: RegExp;
17
17
  readonly taskOutputStatus: RegExp;
18
+ readonly taskOutputHeadSlots: RegExp;
19
+ readonly taskOutputResultNote: RegExp;
18
20
  readonly taskOutputNoneSentinel: "(none)";
19
21
  readonly taskOutputStdoutLine: RegExp;
20
22
  readonly taskOutputStderrLine: RegExp;
@@ -62,10 +64,16 @@ export type ModelFacingTaskOutput = {
62
64
  taskId?: string | undefined;
63
65
  status?: string | undefined;
64
66
  output: string;
67
+ state?: string;
68
+ error?: string;
69
+ resultNote?: string;
70
+ headRest?: string;
65
71
  } | {
66
72
  kind: 'unknown';
67
73
  taskId?: string | undefined;
68
74
  status?: string | undefined;
75
+ state?: string;
76
+ error?: string;
69
77
  };
70
78
  export declare function parseModelFacingTaskOutput(text: string): ModelFacingTaskOutput;
71
79
  export declare function backgroundReceiptParseCalls(): number;
@@ -30,6 +30,8 @@ export const PROTOCOL_MARKERS = {
30
30
  delegationTrailerFork: 'Verify this result before concluding. If it leaves more to do, continue the work yourself or fork again.',
31
31
  taskOutputLabel: /^TaskOutput\s+(\S+)$/,
32
32
  taskOutputStatus: /^status:\s*(.+)$/m,
33
+ taskOutputHeadSlots: /^(\r?\n)(?:(state: ([^\r\n\u2028\u2029\u0085]*)(?:\r?\n|$)))?(?:(error: ([^\r\n\u2028\u2029\u0085]*)(?:\r?\n|$)))?/,
34
+ taskOutputResultNote: /^--- result \(([^)\n]*)\) ---/,
33
35
  taskOutputNoneSentinel: '(none)',
34
36
  taskOutputStdoutLine: /^--- (?:new )?stdout[^\n]*---\n?/m,
35
37
  taskOutputStderrLine: /^--- (?:new )?stderr[^\n]*---\n?/m,
@@ -140,7 +142,8 @@ export function parseModelFacingTaskOutput(text) {
140
142
  const fence = stripUntrustedFence(text);
141
143
  const body = fence ? fence.body : text;
142
144
  const taskId = fence ? PROTOCOL_MARKERS.taskOutputLabel.exec(fence.label)?.[1] : undefined;
143
- const status = PROTOCOL_MARKERS.taskOutputStatus.exec(body)?.[1]?.trim();
145
+ const mStatus = PROTOCOL_MARKERS.taskOutputStatus.exec(body);
146
+ const status = mStatus?.[1]?.trim();
144
147
  const none = (s) => {
145
148
  const t = s.replace(/\n$/, '');
146
149
  return t === PROTOCOL_MARKERS.taskOutputNoneSentinel ? '' : t;
@@ -159,9 +162,50 @@ export function parseModelFacingTaskOutput(text) {
159
162
  }
160
163
  const mRes = PROTOCOL_MARKERS.taskOutputResultLine.exec(body);
161
164
  if (mRes) {
162
- return { kind: 'agent', taskId, status, output: body.slice(mRes.index + mRes[0].length).trimEnd() };
165
+ const lead = taskOutputHeadOf(body, mStatus, mRes.index);
166
+ const statusEnd = lead === null || mStatus === null ? 0 : mStatus[0].length;
167
+ const rest = lead === null ? body.slice(0, mRes.index) : body.slice(statusEnd + lead.consumed, mRes.index);
168
+ const resultNote = PROTOCOL_MARKERS.taskOutputResultNote.exec(mRes[0])?.[1];
169
+ return {
170
+ kind: 'agent',
171
+ taskId,
172
+ status,
173
+ output: body.slice(mRes.index + mRes[0].length).trimEnd(),
174
+ ...(lead?.state !== undefined ? { state: lead.state } : {}),
175
+ ...(lead?.error !== undefined ? { error: lead.error } : {}),
176
+ ...(resultNote !== undefined ? { resultNote } : {}),
177
+ ...(rest !== '' ? { headRest: rest } : {}),
178
+ };
163
179
  }
164
- return { kind: 'unknown', taskId, status };
180
+ const lead = taskOutputHeadOf(body, mStatus, body.length);
181
+ return {
182
+ kind: 'unknown',
183
+ taskId,
184
+ status,
185
+ ...(lead?.state !== undefined ? { state: lead.state } : {}),
186
+ ...(lead?.error !== undefined ? { error: lead.error } : {}),
187
+ };
188
+ }
189
+ function taskOutputHeadOf(body, status, limit) {
190
+ if (status === null || status.index !== 0 || /[^\S \t]/.test(status[0]))
191
+ return null;
192
+ const head = PROTOCOL_MARKERS.taskOutputHeadSlots.exec(body.slice(status.index + status[0].length, limit));
193
+ if (head === null)
194
+ return null;
195
+ let consumed = head[1]?.length ?? 0;
196
+ let state;
197
+ let error;
198
+ if (head[2] !== undefined) {
199
+ if ((head[3] ?? '').trim() === '')
200
+ return { consumed };
201
+ state = head[3];
202
+ consumed += head[2].length;
203
+ }
204
+ if (head[4] !== undefined && (head[5] ?? '').trim() !== '') {
205
+ error = head[5];
206
+ consumed += head[4].length;
207
+ }
208
+ return { ...(state !== undefined ? { state } : {}), ...(error !== undefined ? { error } : {}), consumed };
165
209
  }
166
210
  const THREE_GEN_BG_RECEIPT_RE = /^(?:Started in background|Command running in background|Command moved to background); task_id=([A-Za-z0-9_-]+)/;
167
211
  const MONITOR_BG_RECEIPT_RE = /^Monitoring in background; task_id=([A-Za-z0-9_-]+)/;
@@ -1,15 +1,5 @@
1
- export interface HealthResponse {
2
- status: string;
3
- model?: string;
4
- sessionBackend?: string;
5
- sessions?: number;
6
- instanceId?: string;
7
- dataRoot?: string;
8
- configHash?: string;
9
- pid?: number;
10
- port?: number;
11
- restartRequired?: boolean;
12
- version?: string;
1
+ import type { EngineHealth } from '@sema-agent/sdk';
2
+ export interface HealthResponse extends Pick<EngineHealth, 'status' | 'model' | 'sessionBackend' | 'sessions' | 'instanceId' | 'dataRoot' | 'configHash' | 'pid' | 'port' | 'restartRequired' | 'version'> {
13
3
  }
14
4
  export interface EnginePortFile {
15
5
  port: number;
@@ -0,0 +1,18 @@
1
+ export type UserInvokedSkillsReading = {
2
+ kind: 'unobserved';
3
+ } | {
4
+ kind: 'not_reported';
5
+ } | {
6
+ kind: 'absent';
7
+ } | {
8
+ kind: 'present';
9
+ };
10
+ export declare function projectUserInvokedSkillsCapability(caps: unknown): UserInvokedSkillsReading | undefined;
11
+ export declare function noteEngineCapsForUserInvokedSkills(baseUrl: string, caps: unknown, opts?: {
12
+ generation?: number;
13
+ }): void;
14
+ export declare function observedUserInvokedSkills(baseUrl?: string | undefined): UserInvokedSkillsReading;
15
+ export declare function userInvokedSkillsAvailable(reading: UserInvokedSkillsReading): 'yes' | 'no' | 'unknown';
16
+ export declare function userInvokedSkillsDoctorDetail(reading: UserInvokedSkillsReading): string;
17
+ export declare function forgetUserInvokedSkillsReading(baseUrl: string | undefined): void;
18
+ export declare function __resetUserInvokedSkillsReadingsForTests(): void;
@@ -0,0 +1,50 @@
1
+ import { engineWireTarget } from './engineWireTarget.js';
2
+ import { createEngineCapReader } from './engineCapReader.js';
3
+ export function projectUserInvokedSkillsCapability(caps) {
4
+ if (caps === null || typeof caps !== 'object' || Array.isArray(caps))
5
+ return undefined;
6
+ if (!Object.hasOwn(caps, 'userInvokedSkills'))
7
+ return { kind: 'not_reported' };
8
+ const v = caps.userInvokedSkills;
9
+ if (v === undefined)
10
+ return { kind: 'not_reported' };
11
+ if (typeof v !== 'boolean')
12
+ return undefined;
13
+ return v ? { kind: 'present' } : { kind: 'absent' };
14
+ }
15
+ const reader = createEngineCapReader({
16
+ name: 'userInvokedSkills',
17
+ project: projectUserInvokedSkillsCapability,
18
+ makeUnobserved: () => ({ kind: 'unobserved' }),
19
+ });
20
+ export function noteEngineCapsForUserInvokedSkills(baseUrl, caps, opts) {
21
+ reader.note(baseUrl, caps, opts);
22
+ }
23
+ export function observedUserInvokedSkills(baseUrl = engineWireTarget()?.baseUrl) {
24
+ return reader.observed(baseUrl);
25
+ }
26
+ export function userInvokedSkillsAvailable(reading) {
27
+ if (reading.kind === 'present')
28
+ return 'yes';
29
+ if (reading.kind === 'absent' || reading.kind === 'not_reported')
30
+ return 'no';
31
+ return 'unknown';
32
+ }
33
+ export function userInvokedSkillsDoctorDetail(reading) {
34
+ switch (reading.kind) {
35
+ case 'unobserved':
36
+ return 'user-invoked skills not observed — the engine reports it on /v1/capabilities (userInvokedSkills); this process has no usable capabilities reading cached for it (none received, or the last one was unreadable)';
37
+ case 'not_reported':
38
+ return 'user-invoked skills not reported by this engine — the engine predates it, so naming skills on a request is refused (do not send the key)';
39
+ case 'absent':
40
+ return 'user-invoked skills off on this deployment — naming skills on a request is not accepted';
41
+ case 'present':
42
+ return 'user-invoked skills on — skills the user names on a request take effect when the run starts';
43
+ }
44
+ }
45
+ export function forgetUserInvokedSkillsReading(baseUrl) {
46
+ reader.forget(baseUrl);
47
+ }
48
+ export function __resetUserInvokedSkillsReadingsForTests() {
49
+ reader.__resetForTests();
50
+ }
@@ -5,6 +5,8 @@ interface WireFailureShape {
5
5
  committed?: 'no' | 'unknown' | 'unreadable';
6
6
  bodyField?: string;
7
7
  bodyName?: string;
8
+ bodyVerdict?: string;
9
+ bodyCurrentName?: string;
8
10
  message: string;
9
11
  }
10
12
  export declare function readErrorNumber(o: object, key: string): number | undefined;
@@ -131,6 +131,8 @@ export function wireFailureShapeOf(e) {
131
131
  };
132
132
  const bodyField = ownString('field');
133
133
  const bodyName = ownString('name');
134
+ const bodyVerdict = ownString('verdict');
135
+ const bodyCurrentName = ownString('currentName');
134
136
  let message;
135
137
  try {
136
138
  message = typeof rawMessage === 'string' && rawMessage !== '' ? rawMessage : String(e);
@@ -155,6 +157,8 @@ export function wireFailureShapeOf(e) {
155
157
  ...(committed !== undefined ? { committed } : {}),
156
158
  ...(bodyField !== undefined ? { bodyField } : {}),
157
159
  ...(bodyName !== undefined ? { bodyName } : {}),
160
+ ...(bodyVerdict !== undefined ? { bodyVerdict } : {}),
161
+ ...(bodyCurrentName !== undefined ? { bodyCurrentName } : {}),
158
162
  message,
159
163
  };
160
164
  }
@@ -0,0 +1,18 @@
1
+ export type WorkflowsJournalReading = {
2
+ kind: 'unobserved';
3
+ } | {
4
+ kind: 'not_reported';
5
+ } | {
6
+ kind: 'absent';
7
+ } | {
8
+ kind: 'present';
9
+ };
10
+ export declare function projectWorkflowsJournalCapability(caps: unknown): WorkflowsJournalReading | undefined;
11
+ export declare function noteEngineCapsForWorkflowsJournal(baseUrl: string, caps: unknown, opts?: {
12
+ generation?: number;
13
+ }): void;
14
+ export declare function observedWorkflowsJournal(baseUrl?: string | undefined): WorkflowsJournalReading;
15
+ export declare function workflowsJournalAvailable(reading: WorkflowsJournalReading): 'yes' | 'no' | 'unknown';
16
+ export declare function workflowsJournalDoctorDetail(reading: WorkflowsJournalReading): string;
17
+ export declare function forgetWorkflowsJournalReading(baseUrl: string | undefined): void;
18
+ export declare function __resetWorkflowsJournalReadingsForTests(): void;
@@ -0,0 +1,50 @@
1
+ import { engineWireTarget } from './engineWireTarget.js';
2
+ import { createEngineCapReader } from './engineCapReader.js';
3
+ export function projectWorkflowsJournalCapability(caps) {
4
+ if (caps === null || typeof caps !== 'object' || Array.isArray(caps))
5
+ return undefined;
6
+ if (!Object.hasOwn(caps, 'workflowsJournal'))
7
+ return { kind: 'not_reported' };
8
+ const v = caps.workflowsJournal;
9
+ if (v === undefined)
10
+ return { kind: 'not_reported' };
11
+ if (typeof v !== 'boolean')
12
+ return undefined;
13
+ return v ? { kind: 'present' } : { kind: 'absent' };
14
+ }
15
+ const reader = createEngineCapReader({
16
+ name: 'workflowsJournal',
17
+ project: projectWorkflowsJournalCapability,
18
+ makeUnobserved: () => ({ kind: 'unobserved' }),
19
+ });
20
+ export function noteEngineCapsForWorkflowsJournal(baseUrl, caps, opts) {
21
+ reader.note(baseUrl, caps, opts);
22
+ }
23
+ export function observedWorkflowsJournal(baseUrl = engineWireTarget()?.baseUrl) {
24
+ return reader.observed(baseUrl);
25
+ }
26
+ export function workflowsJournalAvailable(reading) {
27
+ if (reading.kind === 'present')
28
+ return 'yes';
29
+ if (reading.kind === 'absent')
30
+ return 'no';
31
+ return 'unknown';
32
+ }
33
+ export function workflowsJournalDoctorDetail(reading) {
34
+ switch (reading.kind) {
35
+ case 'unobserved':
36
+ return 'workflow journal not observed — the engine reports it on /v1/capabilities (workflowsJournal); this process has no usable capabilities reading cached for it (none received, or the last one was unreadable)';
37
+ case 'not_reported':
38
+ return 'workflow journal not reported by this engine — the engine predates the separate flag, so the workflow listing flag still covers the journal';
39
+ case 'absent':
40
+ return 'no workflow journal on this deployment — workflows can be listed and followed, but their execution journal cannot be read';
41
+ case 'present':
42
+ return 'workflow journal on — a workflow’s execution journal can be read';
43
+ }
44
+ }
45
+ export function forgetWorkflowsJournalReading(baseUrl) {
46
+ reader.forget(baseUrl);
47
+ }
48
+ export function __resetWorkflowsJournalReadingsForTests() {
49
+ reader.__resetForTests();
50
+ }
@@ -1,7 +1,5 @@
1
- export interface WriteProtectionCapabilityView {
2
- armed: boolean;
3
- rows: number;
4
- replaced: boolean;
1
+ import type { WriteProtectionCapability } from '@sema-agent/sdk';
2
+ export interface WriteProtectionCapabilityView extends Pick<WriteProtectionCapability, 'armed' | 'rows' | 'replaced'> {
5
3
  }
6
4
  export type WriteProtectionReading = {
7
5
  kind: 'unobserved';