@sema-agent/client-core 0.101.0 → 0.103.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 (125) hide show
  1. package/CHANGELOG.md +153 -0
  2. package/README.md +19 -11
  3. package/dist/adapt/toolCards.d.ts +4 -2
  4. package/dist/adapt/toolCards.js +22 -6
  5. package/dist/adapt.d.ts +1 -1
  6. package/dist/adapt.js +1 -1
  7. package/dist/adapter/downstream/eventToSdkMessage.d.ts +5 -1
  8. package/dist/adapter/downstream/eventToSdkMessage.js +26 -70
  9. package/dist/adapter/downstream/terminalToSdkResult.js +0 -1
  10. package/dist/adapter/downstream/wiringManifestView.d.ts +1 -0
  11. package/dist/adapter/downstream/wiringManifestView.js +141 -0
  12. package/dist/cloudConfigWireCaps.js +6 -3
  13. package/dist/compensations.js +1 -1
  14. package/dist/credentialPlaneCapability.d.ts +22 -0
  15. package/dist/credentialPlaneCapability.js +75 -0
  16. package/dist/deviceExecutorManagementCapability.d.ts +1 -0
  17. package/dist/deviceExecutorManagementCapability.js +3 -1
  18. package/dist/displayUntrusted.d.ts +8 -4
  19. package/dist/displayUntrusted.js +769 -96
  20. package/dist/engineErrorCodes.d.ts +1 -0
  21. package/dist/engineErrorCodes.js +3 -1
  22. package/dist/engineNoticeCodes.d.ts +26 -0
  23. package/dist/engineNoticeCodes.js +121 -12
  24. package/dist/engineRowRef.js +2 -0
  25. package/dist/errorSupplementRoles.js +1 -3
  26. package/dist/eventLeg.js +2 -1
  27. package/dist/fleet/fleetProjection.js +16 -10
  28. package/dist/gateOutcome.d.ts +20 -0
  29. package/dist/gateOutcome.js +89 -0
  30. package/dist/generated/engineAskFaceTables.js +2 -2
  31. package/dist/generated/engineFactTables.d.ts +6 -2
  32. package/dist/generated/engineFactTables.js +41 -1
  33. package/dist/generated/engineNoticeTables.js +18 -0
  34. package/dist/generated/settingsSchemaDefaultModel.d.ts +1 -1
  35. package/dist/generated/settingsSchemaDefaultModel.js +2 -2
  36. package/dist/generated/settingsSchemaFns.d.ts +15 -0
  37. package/dist/generated/settingsSchemaFns.js +25 -2
  38. package/dist/generated/settingsSchemaHooksClassifier.js +109 -29
  39. package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -1
  40. package/dist/generated/settingsSchemaMcpRequestEntry.js +213 -93
  41. package/dist/generated/settingsSchemaMcpServerName.d.ts +1 -0
  42. package/dist/generated/settingsSchemaMcpServerName.js +8 -0
  43. package/dist/generated/settingsSchemaOwnKeyRead.d.ts +1 -0
  44. package/dist/generated/settingsSchemaOwnKeyRead.js +172 -0
  45. package/dist/generated/settingsSchemaPlainJsonObject.d.ts +1 -0
  46. package/dist/generated/settingsSchemaPlainJsonObject.js +28 -0
  47. package/dist/generated/settingsSchemaSafetyMergeSpec.js +10 -7
  48. package/dist/generated/settingsSchemaTierWords.d.ts +1 -0
  49. package/dist/generated/settingsSchemaTierWords.js +7 -0
  50. package/dist/generated/settingsSchemaTypes.d.ts +3 -1
  51. package/dist/hitl/automaticAnswerVerdict.d.ts +1 -1
  52. package/dist/hitl/decisionConflict.js +11 -11
  53. package/dist/hitl/decisionRefusal.d.ts +1 -0
  54. package/dist/hitl/decisionRefusal.js +4 -2
  55. package/dist/hitl/editedRuleTextPrecheck.d.ts +1 -0
  56. package/dist/hitl/editedRuleTextPrecheck.js +26 -1
  57. package/dist/hitl/persistedRulesWire.js +1 -0
  58. package/dist/hitl/planReviewWire.d.ts +2 -1
  59. package/dist/hitl/planReviewWire.js +8 -12
  60. package/dist/hitl/sessionPolicyDeliverable.d.ts +0 -1
  61. package/dist/hitl/sessionPolicyDeliverable.js +0 -5
  62. package/dist/hitl/sessionPolicyWire.js +1 -1
  63. package/dist/hitl/toolApprovalWire.d.ts +18 -6
  64. package/dist/hitl/toolApprovalWire.js +9 -4
  65. package/dist/i18n/messages.en.d.ts +43 -0
  66. package/dist/i18n/messages.en.js +44 -1
  67. package/dist/i18n/messages.zh.js +46 -1
  68. package/dist/index.d.ts +11 -2
  69. package/dist/index.js +7 -1
  70. package/dist/inheritEnvWire.d.ts +1 -0
  71. package/dist/inheritEnvWire.js +8 -5
  72. package/dist/interactiveHalt.d.ts +3 -1
  73. package/dist/interactiveHalt.js +2 -0
  74. package/dist/interactiveInterrupt.d.ts +2 -0
  75. package/dist/interactiveInterrupt.js +15 -0
  76. package/dist/mcpEngineLeg.d.ts +3 -0
  77. package/dist/mcpEngineLeg.js +4 -1
  78. package/dist/mcpLiveness.d.ts +18 -0
  79. package/dist/mcpLiveness.js +48 -1
  80. package/dist/mcpReconnect.d.ts +3 -0
  81. package/dist/mcpReconnect.js +6 -0
  82. package/dist/mcpStatusSupersetKeys.js +24 -1
  83. package/dist/mcpWireCaps.d.ts +2 -3
  84. package/dist/mcpWireCaps.js +9 -8
  85. package/dist/memoryEntriesWire.d.ts +35 -1
  86. package/dist/memoryEntriesWire.js +110 -14
  87. package/dist/modsFace.d.ts +8 -0
  88. package/dist/modsFace.js +63 -0
  89. package/dist/ownKey.d.ts +1 -0
  90. package/dist/ownKey.js +15 -0
  91. package/dist/postureKnob.js +1 -1
  92. package/dist/prepareRefusal.d.ts +0 -1
  93. package/dist/prepareRefusal.js +0 -3
  94. package/dist/printToolResultFrame.js +1 -1
  95. package/dist/promptProfileWireCaps.d.ts +1 -3
  96. package/dist/promptProfileWireCaps.js +2 -2
  97. package/dist/request/printNotification.js +1 -1
  98. package/dist/request/taskRequest.d.ts +22 -1
  99. package/dist/request/taskRequest.js +126 -10
  100. package/dist/retryStatus.d.ts +13 -1
  101. package/dist/retryStatus.js +20 -5
  102. package/dist/seam.js +1 -1
  103. package/dist/seatContract.d.ts +22 -6
  104. package/dist/seatContract.js +45 -6
  105. package/dist/sessionBackground.d.ts +165 -0
  106. package/dist/sessionBackground.js +781 -0
  107. package/dist/sessionBackgroundHandoff.d.ts +54 -0
  108. package/dist/sessionBackgroundHandoff.js +321 -0
  109. package/dist/sessionMap.js +4 -1
  110. package/dist/sessionMemoryErase.js +24 -2
  111. package/dist/settingsCredentialKeyPaths.js +2 -17
  112. package/dist/thinkingLatch.d.ts +69 -0
  113. package/dist/thinkingLatch.js +255 -0
  114. package/dist/thinkingLatchWords.d.ts +7 -0
  115. package/dist/thinkingLatchWords.js +4 -0
  116. package/dist/toolResult.js +2 -24
  117. package/dist/turnFailurePresentation.js +8 -1
  118. package/dist/wireFailureShape.d.ts +12 -1
  119. package/dist/wireFailureShape.js +58 -24
  120. package/dist/wireRefusalCopy.d.ts +0 -3
  121. package/dist/wireRefusalCopy.js +0 -17
  122. package/docs/INTEGRATION-CLIENTS.md +458 -14
  123. package/package.json +5 -5
  124. package/dist/argvFlagValue.d.ts +0 -8
  125. package/dist/argvFlagValue.js +0 -37
@@ -0,0 +1,255 @@
1
+ import { readOwnDataValue } from './ownKey.js';
2
+ import { msg, renderMessage } from './i18n/translate.js';
3
+ import { quoteUntrustedForSentence } from './displayUntrusted.js';
4
+ import { seatCapabilityUnavailableDetail } from './seatContract.js';
5
+ import { THINKING_LATCH_EVENTS, } from './thinkingLatchWords.js';
6
+ const UNSET_WHYS = Object.freeze(['no_port', 'never_set', 'unreadable', 'malformed']);
7
+ const THINKING_LATCH_TRANSITIONS = Object.freeze({
8
+ on: Object.freeze({ on: 'on', off: 'off', toggle: 'off', clear: 'unset' }),
9
+ off: Object.freeze({ on: 'on', off: 'off', toggle: 'on', clear: 'unset' }),
10
+ unset: Object.freeze({ on: 'on', off: 'off', toggle: 'off', clear: 'unset' }),
11
+ });
12
+ const storedOf = (state) => (state === 'on' ? true : state === 'off' ? false : undefined);
13
+ const setReading = (state) => Object.freeze({ state });
14
+ const unsetReading = (why) => Object.freeze({ state: 'unset', why });
15
+ function normalizedReading(v) {
16
+ try {
17
+ if (typeof v !== 'object' || v === null)
18
+ return unsetReading('malformed');
19
+ const state = readOwnDataValue(v, 'state');
20
+ if (state === 'on' || state === 'off')
21
+ return setReading(state);
22
+ if (state !== 'unset')
23
+ return unsetReading('malformed');
24
+ const why = readOwnDataValue(v, 'why');
25
+ return typeof why === 'string' && UNSET_WHYS.includes(why) ? unsetReading(why) : unsetReading('malformed');
26
+ }
27
+ catch {
28
+ return unsetReading('malformed');
29
+ }
30
+ }
31
+ export function readThinkingLatch(port) {
32
+ if (port === undefined || port === null)
33
+ return unsetReading('no_port');
34
+ let stored;
35
+ try {
36
+ const read = port.read;
37
+ if (typeof read !== 'function')
38
+ return unsetReading('unreadable');
39
+ stored = Reflect.apply(read, port, []);
40
+ }
41
+ catch {
42
+ return unsetReading('unreadable');
43
+ }
44
+ if (stored === true)
45
+ return setReading('on');
46
+ if (stored === false)
47
+ return setReading('off');
48
+ if (stored === undefined)
49
+ return unsetReading('never_set');
50
+ return unsetReading('malformed');
51
+ }
52
+ export function writeThinkingLatch(port, event) {
53
+ if (port === undefined || port === null)
54
+ return Object.freeze({ kind: 'not_saved', why: 'no_port', previous: unsetReading('no_port') });
55
+ const previous = readThinkingLatch(port);
56
+ const ev = event;
57
+ if (typeof ev !== 'string' || !THINKING_LATCH_EVENTS.includes(ev)) {
58
+ return Object.freeze({ kind: 'not_saved', why: 'bad_event', previous });
59
+ }
60
+ const target = THINKING_LATCH_TRANSITIONS[previous.state][ev];
61
+ const clean = previous.why === undefined || previous.why === 'never_set';
62
+ if (clean && target === previous.state)
63
+ return Object.freeze({ kind: 'unchanged', state: target });
64
+ let wrote = false;
65
+ try {
66
+ const write = port.write;
67
+ if (typeof write === 'function') {
68
+ Reflect.apply(write, port, [storedOf(target)]);
69
+ wrote = true;
70
+ }
71
+ }
72
+ catch {
73
+ wrote = false;
74
+ }
75
+ if (!wrote)
76
+ return Object.freeze({ kind: 'not_saved', why: 'write_failed', attempted: target, now: readThinkingLatch(port) });
77
+ return Object.freeze({ kind: 'saved', previous, state: target });
78
+ }
79
+ const ownSlotOf = (v, key) => {
80
+ try {
81
+ const d = Object.getOwnPropertyDescriptor(v, key);
82
+ if (d === undefined)
83
+ return { kind: 'absent' };
84
+ return Object.hasOwn(d, 'value') ? { kind: 'data', value: d.value } : { kind: 'unreadable' };
85
+ }
86
+ catch {
87
+ return { kind: 'unreadable' };
88
+ }
89
+ };
90
+ function capabilityReadingOf(capability) {
91
+ if (typeof capability !== 'object' || capability === null)
92
+ return Object.freeze({ kind: 'malformed' });
93
+ const kind = ownSlotOf(capability, 'kind');
94
+ if (kind.kind !== 'data')
95
+ return Object.freeze({ kind: 'malformed' });
96
+ if (kind.value === 'not_reported')
97
+ return Object.freeze({ kind: 'not_reported' });
98
+ if (kind.value === 'reported') {
99
+ const available = ownSlotOf(capability, 'available');
100
+ return available.kind === 'data' && typeof available.value === 'boolean'
101
+ ? Object.freeze({ kind: 'reported', available: available.value })
102
+ : Object.freeze({ kind: 'malformed' });
103
+ }
104
+ return Object.freeze({ kind: 'malformed' });
105
+ }
106
+ const seatCarries = (capability) => {
107
+ try {
108
+ return seatCapabilityUnavailableDetail('thinkingLatch', capabilityReadingOf(capability)) === undefined;
109
+ }
110
+ catch {
111
+ return false;
112
+ }
113
+ };
114
+ const carrierBlocks = (carrier) => {
115
+ if (carrier.kind === 'absent')
116
+ return false;
117
+ if (carrier.kind === 'unreadable')
118
+ return true;
119
+ const c = carrier.value;
120
+ if (c === undefined)
121
+ return false;
122
+ if (typeof c !== 'object' || c === null)
123
+ return true;
124
+ const kind = ownSlotOf(c, 'kind');
125
+ if (kind.kind !== 'data')
126
+ return true;
127
+ if (kind.value === 'engine')
128
+ return false;
129
+ if (kind.value === 'seat') {
130
+ const capability = ownSlotOf(c, 'capability');
131
+ return capability.kind !== 'data' || !seatCarries(capability.value);
132
+ }
133
+ return true;
134
+ };
135
+ export function thinkingLatchView(reading, ctx) {
136
+ const r = normalizedReading(reading);
137
+ let carrier = { kind: 'absent' };
138
+ let modelSaysNoThinking = false;
139
+ if (ctx !== undefined && ctx !== null) {
140
+ if (typeof ctx !== 'object')
141
+ carrier = { kind: 'unreadable' };
142
+ else {
143
+ carrier = ownSlotOf(ctx, 'carrier');
144
+ const model = ownSlotOf(ctx, 'model');
145
+ if (model.kind === 'data' && typeof model.value === 'object' && model.value !== null) {
146
+ const mk = ownSlotOf(model.value, 'kind');
147
+ modelSaysNoThinking = mk.kind === 'data' && mk.value === 'not_applicable';
148
+ }
149
+ }
150
+ }
151
+ const conflict = carrierBlocks(carrier) ? 'seat_cannot_carry' : r.state === 'on' && modelSaysNoThinking ? 'model_cannot_think' : undefined;
152
+ return Object.freeze({ state: r.state, ...(r.why !== undefined ? { why: r.why } : {}), ...(conflict !== undefined ? { conflict } : {}) });
153
+ }
154
+ const MODEL_NAME_MAX = 120;
155
+ const stateSentence = (state, lang) => state === 'on'
156
+ ? renderMessage(msg('session.thinking.state.on'), lang)
157
+ : state === 'off'
158
+ ? renderMessage(msg('session.thinking.state.off'), lang)
159
+ : state === 'unset'
160
+ ? renderMessage(msg('session.thinking.state.unset'), lang)
161
+ : undefined;
162
+ export function thinkingLatchSentence(subject, lang) {
163
+ try {
164
+ if (typeof subject !== 'object' || subject === null)
165
+ return undefined;
166
+ const kind = readOwnDataValue(subject, 'kind');
167
+ if (kind === 'state')
168
+ return stateSentence(readOwnDataValue(subject, 'state'), lang);
169
+ if (kind === 'turn') {
170
+ const p = readOwnDataValue(subject, 'projection');
171
+ if (typeof p !== 'object' || p === null)
172
+ return undefined;
173
+ return readOwnDataValue(p, 'verdict') === 'off' && readOwnDataValue(p, 'ultracodeStamped') === true
174
+ ? renderMessage(msg('session.thinking.offWithUltracodeOnBody'), lang)
175
+ : undefined;
176
+ }
177
+ if (kind === 'view') {
178
+ const view = readOwnDataValue(subject, 'view');
179
+ if (typeof view !== 'object' || view === null)
180
+ return undefined;
181
+ const conflict = readOwnDataValue(view, 'conflict');
182
+ if (conflict === 'seat_cannot_carry') {
183
+ const carrier = readOwnDataValue(subject, 'carrier');
184
+ const capability = typeof carrier === 'object' && carrier !== null && readOwnDataValue(carrier, 'kind') === 'seat'
185
+ ? readOwnDataValue(carrier, 'capability')
186
+ : undefined;
187
+ return seatCapabilityUnavailableDetail('thinkingLatch', capabilityReadingOf(capability));
188
+ }
189
+ if (conflict === 'model_cannot_think') {
190
+ const model = readOwnDataValue(subject, 'model');
191
+ const shown = typeof model === 'string' && model.length > 0 ? quoteUntrustedForSentence(model, MODEL_NAME_MAX) : undefined;
192
+ return shown === undefined ? undefined : renderMessage(msg('session.thinking.modelCannotThink', { model: shown }), lang);
193
+ }
194
+ if (conflict !== undefined)
195
+ return undefined;
196
+ const r = normalizedReading(view);
197
+ if (r.why === 'unreadable' || r.why === 'malformed')
198
+ return renderMessage(msg('session.thinking.storeUnreadable'), lang);
199
+ return stateSentence(r.state, lang);
200
+ }
201
+ if (kind === 'write') {
202
+ const outcome = readOwnDataValue(subject, 'outcome');
203
+ if (typeof outcome !== 'object' || outcome === null)
204
+ return undefined;
205
+ return readOwnDataValue(outcome, 'kind') === 'not_saved' ? renderMessage(msg('session.thinking.notSaved'), lang) : undefined;
206
+ }
207
+ if (kind === 'seat_ack') {
208
+ const ack = readOwnDataValue(subject, 'ack');
209
+ if (typeof ack !== 'object' || ack === null)
210
+ return undefined;
211
+ return readOwnDataValue(ack, 'ok') === false ? renderMessage(msg('session.thinking.notSaved'), lang) : undefined;
212
+ }
213
+ return undefined;
214
+ }
215
+ catch {
216
+ return undefined;
217
+ }
218
+ }
219
+ export function thinkingLatchRowWordOf(reading) {
220
+ const r = normalizedReading(reading);
221
+ if (r.state === 'on' || r.state === 'off')
222
+ return r.state;
223
+ if (r.why === 'unreadable')
224
+ return 'unreadable';
225
+ if (r.why === 'malformed')
226
+ return 'malformed';
227
+ return undefined;
228
+ }
229
+ export function readSeatThinkingLatch(record, capability) {
230
+ if (!seatCarries(capability))
231
+ return unsetReading('no_port');
232
+ const row = record;
233
+ if (row === undefined || row === null)
234
+ return unsetReading('no_port');
235
+ try {
236
+ if (typeof row !== 'object')
237
+ return unsetReading('malformed');
238
+ const d = Object.getOwnPropertyDescriptor(row, 'thinkingLatch');
239
+ if (d === undefined)
240
+ return unsetReading('never_set');
241
+ if (!Object.hasOwn(d, 'value'))
242
+ return unsetReading('malformed');
243
+ const w = d.value;
244
+ if (w === undefined)
245
+ return unsetReading('never_set');
246
+ if (w === 'on' || w === 'off')
247
+ return setReading(w);
248
+ if (w === 'unreadable')
249
+ return unsetReading('unreadable');
250
+ return unsetReading('malformed');
251
+ }
252
+ catch {
253
+ return unsetReading('unreadable');
254
+ }
255
+ }
@@ -0,0 +1,7 @@
1
+ export declare const THINKING_LATCH_STATES: readonly ["on", "off", "unset"];
2
+ export type ThinkingLatchState = (typeof THINKING_LATCH_STATES)[number];
3
+ export declare const THINKING_LATCH_SET_STATES: readonly ["on", "off"];
4
+ export declare const THINKING_LATCH_EVENTS: readonly ["on", "off", "toggle", "clear"];
5
+ export type ThinkingLatchEvent = (typeof THINKING_LATCH_EVENTS)[number];
6
+ export declare const THINKING_LATCH_ROW_WORDS: readonly ["on", "off", "unreadable", "malformed"];
7
+ export type ThinkingLatchRowWord = (typeof THINKING_LATCH_ROW_WORDS)[number];
@@ -0,0 +1,4 @@
1
+ export const THINKING_LATCH_STATES = Object.freeze(['on', 'off', 'unset']);
2
+ export const THINKING_LATCH_SET_STATES = Object.freeze(['on', 'off']);
3
+ export const THINKING_LATCH_EVENTS = Object.freeze(['on', 'off', 'toggle', 'clear']);
4
+ export const THINKING_LATCH_ROW_WORDS = Object.freeze(['on', 'off', 'unreadable', 'malformed']);
@@ -4,7 +4,7 @@ import { parseWorkflowPollEnvelope, projectWorkflowTaskOutput } from './workflow
4
4
  import { asModelFallbackReason } from './engineErrorCodes.js';
5
5
  import { frozenSet } from './frozenSet.js';
6
6
  import { bashExitOf, bashExitReadingFailed } from './bashExitReading.js';
7
- import { guardedRead, ownSnapshotWhenTyped, readFrameTrueMark, readFrameTrueMarkReading, readOwnDataFiniteNumber, readOwnDataNonEmptyString, readOwnDataValue, } from './ownKey.js';
7
+ import { guardedRead, ownDataField, ownSnapshotWhenTyped, readFrameTrueMark, readFrameTrueMarkReading, readOwnDataFiniteNumber, readOwnDataNonEmptyString, readOwnDataValue, toolResultBlockOf, } from './ownKey.js';
8
8
  import { displayUntrusted } from './displayUntrusted.js';
9
9
  import { isCoreSemaTaskTerminal } from './terminalStatuses.js';
10
10
  import { CORE_ENGINE_CARD_TYPES } from './generated/engineFactTables.js';
@@ -285,29 +285,7 @@ const TOOL_CARD_DEGRADED_TEXT = {
285
285
  unrecognised: 'This tool call carries a result marker this client does not recognise, so no result is shown for it.',
286
286
  };
287
287
  const cardDegraded = (cause) => ({ kind: 'degraded', cause, text: TOOL_CARD_DEGRADED_TEXT[cause] });
288
- function cardOwnData(o, key) {
289
- const d = Object.getOwnPropertyDescriptor(o, key);
290
- if (d === undefined)
291
- return undefined;
292
- if (!Object.hasOwn(d, 'value'))
293
- throw new TypeError(`own property "${key}" is an accessor`);
294
- return d.value;
295
- }
296
288
  const isCardRecordObject = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
297
- function toolResultBlockOf(record) {
298
- const message = cardOwnData(record, 'message');
299
- if (!isCardRecordObject(message))
300
- return undefined;
301
- const content = cardOwnData(message, 'content');
302
- if (!Array.isArray(content))
303
- return undefined;
304
- for (let i = 0; i < content.length; i++) {
305
- const block = cardOwnData(content, String(i));
306
- if (isCardRecordObject(block) && cardOwnData(block, 'type') === 'tool_result')
307
- return block;
308
- }
309
- return undefined;
310
- }
311
289
  export function readToolCardOutcome(record) {
312
290
  try {
313
291
  if (!isCardRecordObject(record))
@@ -327,7 +305,7 @@ export function readToolCardOutcome(record) {
327
305
  return { kind: 'unreadable' };
328
306
  if (markerDesc.value !== TOOL_RESULT_DEGRADED_WIRE_NO_OUTPUT)
329
307
  return cardDegraded('unrecognised');
330
- return cardDegraded(cardOwnData(block, 'is_error') === true ? 'error-without-detail' : 'no-result');
308
+ return cardDegraded(ownDataField(block, 'is_error') === true ? 'error-without-detail' : 'no-result');
331
309
  }
332
310
  catch {
333
311
  return { kind: 'unreadable' };
@@ -60,7 +60,14 @@ function isIdleWatchdog(err) {
60
60
  return false;
61
61
  }
62
62
  }
63
- const DETERMINISTIC_SERVER_CODES = new Set([CORRUPT_SESSION_ERROR_CODE, CORRUPT_ROW_ERROR_CODE, SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE, MEMORY_CONTROL_PLANE_CORRUPT]);
63
+ const DETERMINISTIC_SERVER_CODES = new Set([
64
+ CORRUPT_SESSION_ERROR_CODE,
65
+ CORRUPT_ROW_ERROR_CODE,
66
+ SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE,
67
+ MEMORY_CONTROL_PLANE_CORRUPT,
68
+ 'approvals.read_corrupt',
69
+ 'workflow.journal_incompatible',
70
+ ]);
64
71
  const BROWSER_FETCH_FAILURE = /\bfailed to fetch\b|\bnetworkerror\b|\bnetwork error\b|\bload failed\b/i;
65
72
  function httpShapeOf(verdict, code) {
66
73
  const status = verdict.status;
@@ -23,6 +23,11 @@ export type ThrownExtraReading = {
23
23
  readonly state: 'unreadable';
24
24
  };
25
25
  export declare function readThrownExtra(o: {} | null | undefined): ThrownExtraReading;
26
+ export interface ThrownExtraSnapshot {
27
+ readonly sdkInstance: boolean;
28
+ readonly bag: ThrownExtraReading;
29
+ }
30
+ export declare function readThrownExtraSnapshot(o: {} | null | undefined): ThrownExtraSnapshot;
26
31
  export declare const PROTOCOL_ERROR_NAME: Readonly<{
27
32
  readonly ApprovalBindingMismatchError: "ApprovalBindingMismatchError";
28
33
  readonly ApprovalStaleError: "ApprovalStaleError";
@@ -53,7 +58,7 @@ export type ProtocolErrorNameReading = {
53
58
  } | {
54
59
  readonly state: 'unreadable';
55
60
  };
56
- export declare function protocolErrorNameReading(e: object): ProtocolErrorNameReading;
61
+ export declare function protocolErrorNameReading(e: object, extra?: ThrownExtraSnapshot): ProtocolErrorNameReading;
57
62
  export declare function protocolErrorNameOf(e: object): ProtocolErrorName | undefined;
58
63
  export type ThrownStatusReading = number | undefined | typeof THROWN_SLOT_UNREADABLE;
59
64
  export declare function readThrownStatusSlot(o: object, notePresence?: (presence: SlotPresence) => void): ThrownStatusReading;
@@ -66,6 +71,7 @@ export declare function slotPresenceOf(o: object, key: string): SlotPresence;
66
71
  export declare function slotReadOf(o: object, key: string): OwnSlotRead;
67
72
  export declare function readErrorNumber(o: object, key: string): number | undefined;
68
73
  export declare function readErrorRecord(o: object, key: string): object | undefined;
74
+ export declare function readErrorPresent(o: object, key: string): {} | null | undefined;
69
75
  export declare function readErrorString(o: object, key: string): string | undefined;
70
76
  export declare function readErrorStringList(o: object, key: string): readonly string[] | undefined;
71
77
  export declare function readErrorStrictStringList(o: object, key: string): readonly string[] | undefined;
@@ -106,6 +112,11 @@ export declare function ownFoldedCodeBitsOf(wire: {
106
112
  readonly blockedBy?: string;
107
113
  } | undefined): FoldedCodeBits;
108
114
  export declare function readRefusalField(o: object): string | undefined;
115
+ export interface RefusalSlotReading {
116
+ readonly word: string | undefined;
117
+ readonly present: boolean;
118
+ }
119
+ export declare function readRefusalSlots<K extends string>(o: object, keys: readonly K[], bag?: ThrownExtraReading): Readonly<Record<K, RefusalSlotReading>>;
109
120
  export declare const REFUSAL_PROBLEMS_READ_MAX = 1000;
110
121
  export declare function readRefusalNamedFields(o: object): readonly string[];
111
122
  export declare function isDisplayableWireCode(s: string): boolean;
@@ -87,28 +87,38 @@ function isBuiltinErrorPrototype(node) {
87
87
  return ['message', 'name', 'toString'].every((k) => Object.getOwnPropertyDescriptor(node, k) !== undefined);
88
88
  }
89
89
  export function readThrownExtra(o) {
90
+ return readThrownExtraSnapshot(o).bag;
91
+ }
92
+ export function readThrownExtraSnapshot(o) {
90
93
  if (o === null || o === undefined || (typeof o !== 'object' && typeof o !== 'function'))
91
- return { state: 'absent' };
94
+ return { sdkInstance: false, bag: { state: 'absent' } };
95
+ let at;
96
+ try {
97
+ at = extraSlotOf(o);
98
+ }
99
+ catch {
100
+ return { sdkInstance: false, bag: { state: 'unreadable' } };
101
+ }
102
+ const sdkInstance = at.kind === 'sdk-class';
103
+ if (at.kind === 'own-accessor')
104
+ return { sdkInstance, bag: { state: 'unreadable' } };
105
+ if (at.kind === 'none')
106
+ return { sdkInstance, bag: { state: 'absent' } };
92
107
  let slot;
93
108
  try {
94
- const at = extraSlotOf(o);
95
- if (at.kind === 'own-accessor')
96
- return { state: 'unreadable' };
97
- if (at.kind === 'none')
98
- return { state: 'absent' };
99
109
  slot = at.kind === 'own-data' ? at.value : Reflect.get(o, EXTRA_KEY);
100
110
  }
101
111
  catch {
102
- return { state: 'unreadable' };
112
+ return { sdkInstance, bag: { state: 'unreadable' } };
103
113
  }
104
114
  try {
105
115
  if (typeof slot !== 'object' || slot === null || Array.isArray(slot))
106
- return { state: 'absent' };
116
+ return { sdkInstance, bag: { state: 'absent' } };
107
117
  }
108
118
  catch {
109
- return { state: 'unreadable' };
119
+ return { sdkInstance, bag: { state: 'unreadable' } };
110
120
  }
111
- return { state: 'object', value: slot };
121
+ return { sdkInstance, bag: { state: 'object', value: slot } };
112
122
  }
113
123
  export const PROTOCOL_ERROR_NAME = Object.freeze({
114
124
  ApprovalBindingMismatchError: 'ApprovalBindingMismatchError',
@@ -137,11 +147,11 @@ export function isSdkErrorInstance(o) {
137
147
  return false;
138
148
  }
139
149
  }
140
- export function protocolErrorNameReading(e) {
150
+ export function protocolErrorNameReading(e, extra) {
141
151
  if (typeof e !== 'object' || e === null)
142
152
  return { state: 'absent' };
143
153
  try {
144
- if (isSdkErrorInstance(e))
154
+ if (extra !== undefined ? extra.sdkInstance : isSdkErrorInstance(e))
145
155
  return { state: 'sdk-instance' };
146
156
  const name = ownDataField(e, 'name');
147
157
  return typeof name === 'string' && PROTOCOL_ERROR_NAMES.has(name) ? { state: 'named', name: name } : { state: 'absent' };
@@ -221,6 +231,10 @@ export function readErrorRecord(o, key) {
221
231
  const v = readErrorSlot(o, key, (x) => typeof x === 'object' && x !== null && !Array.isArray(x));
222
232
  return typeof v === 'object' && v !== null && !Array.isArray(v) ? v : undefined;
223
233
  }
234
+ export function readErrorPresent(o, key) {
235
+ const v = readErrorSlot(o, key, (x) => x !== undefined);
236
+ return v === undefined ? undefined : v;
237
+ }
224
238
  export function readErrorString(o, key) {
225
239
  const v = readErrorSlot(o, key, (x) => typeof x === 'string');
226
240
  return typeof v === 'string' ? v : undefined;
@@ -396,18 +410,38 @@ export function ownFoldedCodeBitsOf(wire) {
396
410
  return Object.freeze({ errorCode: bit('errorCode'), blockedBy: bit('blockedBy') });
397
411
  }
398
412
  export function readRefusalField(o) {
399
- const str = (rec) => {
400
- const v = guardedRead(() => readOwnDataValue(rec, 'field'));
401
- return typeof v === 'string' && v !== '' ? v : undefined;
402
- };
403
- const reading = readThrownExtra(o);
404
- if (reading.state === 'object') {
405
- const fromExtra = str(reading.value);
406
- if (fromExtra !== undefined)
407
- return fromExtra;
408
- }
409
- const top = readThrownSlot(o, 'field', 'data');
410
- return typeof top === 'string' && top !== '' ? top : undefined;
413
+ return readRefusalSlots(o, REFUSAL_FIELD_ONLY).field.word;
414
+ }
415
+ const REFUSAL_SLOT_ABSENT = Object.freeze({ word: undefined, present: false });
416
+ const REFUSAL_SLOT_HELD_UNREADABLE = Object.freeze({ word: undefined, present: true });
417
+ const REFUSAL_FIELD_ONLY = Object.freeze(['field']);
418
+ function refusalSlotOf(container, key) {
419
+ try {
420
+ const d = Object.getOwnPropertyDescriptor(container, key);
421
+ if (d === undefined)
422
+ return REFUSAL_SLOT_ABSENT;
423
+ if (!Object.hasOwn(d, 'value'))
424
+ return REFUSAL_SLOT_HELD_UNREADABLE;
425
+ const v = d.value;
426
+ if (v === undefined)
427
+ return REFUSAL_SLOT_ABSENT;
428
+ return typeof v === 'string' && v !== '' ? Object.freeze({ word: v, present: true }) : REFUSAL_SLOT_HELD_UNREADABLE;
429
+ }
430
+ catch {
431
+ return REFUSAL_SLOT_HELD_UNREADABLE;
432
+ }
433
+ }
434
+ export function readRefusalSlots(o, keys, bag = readThrownExtra(o)) {
435
+ const carrier = isSlotCarrier(o);
436
+ const out = Object.create(null);
437
+ for (const key of keys) {
438
+ const fromBag = bag.state === 'object' ? refusalSlotOf(bag.value, key) : REFUSAL_SLOT_ABSENT;
439
+ const top = carrier ? refusalSlotOf(o, key) : REFUSAL_SLOT_ABSENT;
440
+ const word = fromBag.word ?? top.word;
441
+ const present = bag.state === 'unreadable' || fromBag.present || top.present;
442
+ out[key] = word === undefined && !present ? REFUSAL_SLOT_ABSENT : Object.freeze({ word, present });
443
+ }
444
+ return Object.freeze(out);
411
445
  }
412
446
  export const REFUSAL_PROBLEMS_READ_MAX = 1000;
413
447
  export function readRefusalNamedFields(o) {
@@ -126,7 +126,6 @@ export type HookMatcherRefusal = {
126
126
  readonly totalMs?: number;
127
127
  readonly path?: readonly (string | number)[];
128
128
  };
129
- export declare function hookMatcherRefusalFromError(err: unknown): HookMatcherRefusal | undefined;
130
129
  export interface SettingsHooksRefusal {
131
130
  readonly reason: string;
132
131
  readonly path?: readonly (string | number)[];
@@ -159,11 +158,9 @@ export interface UserAttachmentRefusalDetail {
159
158
  readonly path?: string;
160
159
  }
161
160
  export declare function userAttachmentRefusalFromError(err: {} | null | undefined): UserAttachmentRefusalDetail | null;
162
- export declare function userAttachmentRefusalContent(detail?: Pick<UserAttachmentRefusalDetail, 'index'>): string;
163
161
  export interface UserInvokedSkillRefusalDetail {
164
162
  readonly code: typeof USER_INVOKED_SKILL_UNKNOWN_ERROR_CODE;
165
163
  readonly retryable: false;
166
164
  }
167
165
  export declare function userInvokedSkillRefusalFromError(err: {} | null | undefined): UserInvokedSkillRefusalDetail | null;
168
- export declare function userInvokedSkillRefusalContent(): string;
169
166
  export {};
@@ -4,7 +4,6 @@ import { ACTIVE_RUN_BUSY_ERROR_CODE, FLEET_LEASE_UNAVAILABLE, REQUEST_AUTONOMY_L
4
4
  import { capForDisplay } from './fleetTaskDesc.js';
5
5
  import { effectiveWireErrorCode } from './wireErrorTriage.js';
6
6
  import { CORE_TOOL_DECLARATION_CODES } from './generated/engineFactTables.js';
7
- import { prepareRefusalNoteOf } from './prepareRefusal.js';
8
7
  import { PERMISSION_RULE_ISSUE_CODES, permissionRuleIssueDetail } from './permissionRuleIssue.js';
9
8
  import { ruleRefusalListText } from './ruleRefusalSentence.js';
10
9
  import { msg, renderMessage } from './i18n/translate.js';
@@ -734,9 +733,6 @@ export function hostPostureRefusalContent(detail, lang) {
734
733
  }
735
734
  }
736
735
  const HOOK_MATCHER_REFUSAL_FIELD = 'settings.hooks';
737
- export function hookMatcherRefusalFromError(err) {
738
- return settingsHooksRefusalFromError(err)?.matcher;
739
- }
740
736
  function hooksRefusalPathOf(detail) {
741
737
  try {
742
738
  const raw = readOwnDataValue(detail, 'path');
@@ -979,19 +975,6 @@ export function userAttachmentRefusalFromError(err) {
979
975
  return null;
980
976
  }
981
977
  }
982
- export function userAttachmentRefusalContent(detail) {
983
- let index;
984
- try {
985
- index = detail === undefined || detail === null ? undefined : detail.index;
986
- }
987
- catch {
988
- index = undefined;
989
- }
990
- return prepareRefusalNoteOf(USER_ATTACHMENT_INVALID_ERROR_CODE, typeof index === 'number' ? { index } : undefined);
991
- }
992
978
  export function userInvokedSkillRefusalFromError(err) {
993
979
  return effectiveWireErrorCode(err) === USER_INVOKED_SKILL_UNKNOWN_ERROR_CODE ? { code: USER_INVOKED_SKILL_UNKNOWN_ERROR_CODE, retryable: false } : null;
994
980
  }
995
- export function userInvokedSkillRefusalContent() {
996
- return prepareRefusalNoteOf(USER_INVOKED_SKILL_UNKNOWN_ERROR_CODE);
997
- }