@sema-agent/client-core 0.89.0 → 0.91.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 (104) hide show
  1. package/CHANGELOG.md +297 -0
  2. package/README.md +35 -24
  3. package/dist/adapt/arms.js +9 -0
  4. package/dist/adapter/downstream/eventToSdkMessage.js +4 -2
  5. package/dist/adapter/downstream/wiringManifestView.d.ts +6 -0
  6. package/dist/adapter/downstream/wiringManifestView.js +16 -0
  7. package/dist/adapter/runStream.d.ts +2 -0
  8. package/dist/adapter/runStream.js +180 -38
  9. package/dist/askSurvivesStandingAnswer.d.ts +10 -0
  10. package/dist/askSurvivesStandingAnswer.js +40 -0
  11. package/dist/attachmentSeatCapability.d.ts +11 -0
  12. package/dist/attachmentSeatCapability.js +27 -0
  13. package/dist/attachmentsWireCaps.d.ts +22 -2
  14. package/dist/attachmentsWireCaps.js +95 -22
  15. package/dist/compensations.js +10 -14
  16. package/dist/controlRouter.d.ts +9 -2
  17. package/dist/controlRouter.js +66 -28
  18. package/dist/coreValuePorts.d.ts +1 -0
  19. package/dist/decideFailureNote.js +4 -2
  20. package/dist/disableSkillsWire.d.ts +1 -0
  21. package/dist/disableSkillsWire.js +8 -1
  22. package/dist/displayUntrusted.js +153 -4
  23. package/dist/engineCapReader.js +12 -1
  24. package/dist/engineCapsCache.d.ts +3 -1
  25. package/dist/engineCapsCache.js +56 -6
  26. package/dist/engineClosedSets.d.ts +2 -0
  27. package/dist/engineClosedSets.js +3 -0
  28. package/dist/engineErrorCodes.d.ts +3 -0
  29. package/dist/engineErrorCodes.js +10 -0
  30. package/dist/engineNoticeCodes.d.ts +2 -9
  31. package/dist/engineNoticeCodes.js +19 -27
  32. package/dist/fileHistoryLegNotice.d.ts +20 -0
  33. package/dist/fileHistoryLegNotice.js +122 -0
  34. package/dist/gateOutcome.d.ts +1 -1
  35. package/dist/gateOutcome.js +1 -0
  36. package/dist/generated/engineFactTables.d.ts +13 -0
  37. package/dist/generated/engineFactTables.js +50 -0
  38. package/dist/generated/engineNoticeTables.js +0 -3
  39. package/dist/hitl/askGateWire.d.ts +1 -1
  40. package/dist/hitl/askGateWire.js +1 -1
  41. package/dist/hitl/crashConverged.d.ts +7 -0
  42. package/dist/hitl/crashConverged.js +57 -0
  43. package/dist/hitl/crashConvergedNotice.d.ts +4 -0
  44. package/dist/hitl/crashConvergedNotice.js +57 -0
  45. package/dist/hitl/hitlBridge.d.ts +7 -4
  46. package/dist/hitl/parkResolver.d.ts +7 -2
  47. package/dist/hitl/parkResolver.js +19 -7
  48. package/dist/hitl/planReviewWire.d.ts +1 -1
  49. package/dist/hitl/planReviewWire.js +18 -4
  50. package/dist/hitl/sessionPolicyWire.d.ts +5 -0
  51. package/dist/hitl/sessionPolicyWire.js +63 -0
  52. package/dist/hitl/suspendedReopen.js +2 -2
  53. package/dist/hitl/toolApprovalWire.d.ts +4 -1
  54. package/dist/hitl/toolApprovalWire.js +20 -0
  55. package/dist/hookMatcherVerdict.d.ts +29 -0
  56. package/dist/hookMatcherVerdict.js +265 -0
  57. package/dist/hookToolAliases.d.ts +3 -0
  58. package/dist/hookToolAliases.js +10 -0
  59. package/dist/humanTurn.d.ts +91 -0
  60. package/dist/humanTurn.js +253 -0
  61. package/dist/humanTurnRead.d.ts +105 -0
  62. package/dist/humanTurnRead.js +331 -0
  63. package/dist/index.d.ts +30 -5
  64. package/dist/index.js +19 -4
  65. package/dist/inheritEnvWire.js +1 -1
  66. package/dist/liveModelCatalog.d.ts +2 -0
  67. package/dist/liveModelCatalog.js +51 -3
  68. package/dist/permissionRuleIssue.d.ts +1 -1
  69. package/dist/permissionRuleIssue.js +22 -3
  70. package/dist/permissionsAllowGrantCapability.d.ts +18 -0
  71. package/dist/permissionsAllowGrantCapability.js +84 -0
  72. package/dist/permissionsDeclaration.d.ts +48 -0
  73. package/dist/permissionsDeclaration.js +307 -0
  74. package/dist/promptDelivery.d.ts +16 -5
  75. package/dist/promptDelivery.js +172 -32
  76. package/dist/providerRejection.d.ts +3 -1
  77. package/dist/providerRejection.js +27 -1
  78. package/dist/readDenyTiers.d.ts +10 -0
  79. package/dist/readDenyTiers.js +29 -0
  80. package/dist/request/taskRequest.js +27 -1
  81. package/dist/resumeRefusalCopy.d.ts +11 -0
  82. package/dist/resumeRefusalCopy.js +61 -4
  83. package/dist/rewindArchiveCapability.js +4 -4
  84. package/dist/rewindWireCaps.d.ts +2 -1
  85. package/dist/rewindWireCaps.js +19 -2
  86. package/dist/sdkRegistryTransit.d.ts +1 -0
  87. package/dist/sdkRegistryTransit.js +1 -0
  88. package/dist/seam.d.ts +2 -0
  89. package/dist/supportFloor.d.ts +10 -0
  90. package/dist/supportFloor.js +42 -0
  91. package/dist/taskRequestWords.d.ts +7 -0
  92. package/dist/taskRequestWords.js +24 -0
  93. package/dist/toolHistoryBadTurn.d.ts +1 -0
  94. package/dist/toolHistoryBadTurn.js +89 -0
  95. package/dist/toolHistoryMismatch.d.ts +2 -1
  96. package/dist/toolHistoryMismatch.js +19 -6
  97. package/dist/userAttachmentEnvelope.d.ts +61 -0
  98. package/dist/userAttachmentEnvelope.js +204 -0
  99. package/dist/wireFailureShape.d.ts +1 -0
  100. package/dist/wireFailureShape.js +4 -0
  101. package/dist/wireRefusalCopy.d.ts +6 -0
  102. package/dist/wireRefusalCopy.js +26 -3
  103. package/docs/INTEGRATION-CLIENTS.md +1369 -18
  104. package/package.json +3 -3
@@ -10,6 +10,7 @@ import { isRuleStoreUnreadableKind } from '../gateVocabulary.js';
10
10
  import { isApprovalMandateWord } from '../gateVocabulary.js';
11
11
  import { denyAttributionRefusalFromError } from '../wireRefusalCopy.js';
12
12
  import { decideFailureNote } from '../decideFailureNote.js';
13
+ import { refusalSaysStillPending } from '../engineErrorCodes.js';
13
14
  import { readDecideReceipt } from '../decideReceipt.js';
14
15
  import { RULE_OFFER_MATCHES, RULE_OFFER_BATCH_MEMBER_KINDS, RULE_OFFER_UNCOVERED_REASONS, RULE_OFFERS_ABSENCE_REASONS, ASK_ORIGINS, PERSISTED_RULE_MANDATES, } from '@sema-agent/sdk';
15
16
  export function isFsApprovalGate(gate) {
@@ -190,6 +191,7 @@ export async function surfaceFsApprovalAndDecide(deps, taskId, argsByCall, signa
190
191
  const callKey = approvalCallKey(gatedCallId, taskId);
191
192
  const ruleOffersReadOnly = readRuleOfferSupply(pending.ruleOffers, pending.ruleSuggestions);
192
193
  const durableProbeCause = pending.riskDescriptor?.probeCause;
194
+ const durableProbeReason = readProbeReason(pending.riskDescriptor);
193
195
  const durableShadowedRule = pending.riskDescriptor?.shadowedRule;
194
196
  const durableRuleOffersAbsence = pending.ruleOffersAbsence;
195
197
  const durableRuleStoreUnreadable = readRuleStoreUnreadable(pending.ruleStoreUnreadable);
@@ -215,6 +217,7 @@ export async function surfaceFsApprovalAndDecide(deps, taskId, argsByCall, signa
215
217
  ...(pending.hasBidiControls === true ? { hasBidiControls: true } : {}),
216
218
  ...(ruleOffersReadOnly !== undefined ? { ruleOffersReadOnly } : {}),
217
219
  ...(isWireRecordCarrier(durableProbeCause) ? { probeCause: durableProbeCause } : {}),
220
+ ...(durableProbeReason !== undefined ? { probeReason: durableProbeReason } : {}),
218
221
  ...(durableRuleStoreUnreadable !== undefined
219
222
  ? { ruleStoreUnreadable: durableRuleStoreUnreadable }
220
223
  : {}),
@@ -279,6 +282,7 @@ export async function surfaceFsApprovalAndDecide(deps, taskId, argsByCall, signa
279
282
  catch (e) {
280
283
  const currentPending = readDecideCurrentPending(e);
281
284
  const wireCode = readWireErrorCode(e);
285
+ const wireRetriable = typeof e === 'object' && e !== null && refusalSaysStillPending(e);
282
286
  const safetyCode = e instanceof HitlSafetyError ? e.code : undefined;
283
287
  return {
284
288
  kind: 'failed',
@@ -288,6 +292,7 @@ export async function surfaceFsApprovalAndDecide(deps, taskId, argsByCall, signa
288
292
  ...(e instanceof DecideTransportRetryExhaustedError ? { retryExhausted: true } : {}),
289
293
  ...(currentPending !== undefined ? { currentPending } : {}),
290
294
  ...(wireCode !== undefined ? { errorCode: wireCode } : {}),
295
+ ...(wireRetriable ? { retriable: true } : {}),
291
296
  ...(safetyCode !== undefined ? { safetyCode } : {}),
292
297
  };
293
298
  }
@@ -335,6 +340,7 @@ export async function surfaceFsApprovalAndDecide(deps, taskId, argsByCall, signa
335
340
  catch (e) {
336
341
  const currentPending = readDecideCurrentPending(e);
337
342
  const wireCode = readWireErrorCode(e);
343
+ const wireRetriable = typeof e === 'object' && e !== null && refusalSaysStillPending(e);
338
344
  const safetyCode = e instanceof HitlSafetyError ? e.code : undefined;
339
345
  const attributionRefusal = denyAttributionRefusalFromError(e, lastSendCarriedAttribution);
340
346
  return {
@@ -345,6 +351,7 @@ export async function surfaceFsApprovalAndDecide(deps, taskId, argsByCall, signa
345
351
  ...(e instanceof DecideTransportRetryExhaustedError ? { retryExhausted: true } : {}),
346
352
  ...(currentPending !== undefined ? { currentPending } : {}),
347
353
  ...(wireCode !== undefined ? { errorCode: wireCode } : {}),
354
+ ...(wireRetriable ? { retriable: true } : {}),
348
355
  ...(safetyCode !== undefined ? { safetyCode } : {}),
349
356
  ...(attributionRefusal !== null ? { denyAttributionRefusal: attributionRefusal } : {}),
350
357
  };
@@ -393,6 +400,7 @@ export const TOOL_APPROVAL_FRAME_KEYS_MIRROR = [
393
400
  'parked',
394
401
  'persistedRuleShadowed',
395
402
  'probeCause',
403
+ 'probeReason',
396
404
  'ruleEvidence',
397
405
  'requiresRealApproval',
398
406
  'expiresInMs',
@@ -644,6 +652,17 @@ function pathFromGateMessage(message) {
644
652
  return undefined;
645
653
  return body.slice(0, close);
646
654
  }
655
+ function readProbeReason(v) {
656
+ try {
657
+ if (typeof v !== 'object' || v === null || !Object.hasOwn(v, 'probeReason'))
658
+ return undefined;
659
+ const raw = v.probeReason;
660
+ return typeof raw === 'string' && raw.trim() !== '' ? raw : undefined;
661
+ }
662
+ catch {
663
+ return undefined;
664
+ }
665
+ }
647
666
  function isNonNegativeFinite(v) {
648
667
  return typeof v === 'number' && Number.isFinite(v) && v >= 0;
649
668
  }
@@ -887,6 +906,7 @@ export async function surfaceToolApprovalFrameAndRespond(frame, respond, streamA
887
906
  ? { persistedRuleShadowed: frame.persistedRuleShadowed }
888
907
  : {}),
889
908
  ...(isWireRecordCarrier(frame.probeCause) ? { probeCause: frame.probeCause } : {}),
909
+ ...((r) => (r !== undefined ? { probeReason: r } : {}))(readProbeReason(frame)),
890
910
  ...(isWireRecordCarrier(frame.ruleEvidence) ? { ruleEvidence: frame.ruleEvidence } : {}),
891
911
  ...(frame.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
892
912
  ...(hasOwnStrictTrue(frame, 'mandated') ? { mandated: true } : {}),
@@ -0,0 +1,29 @@
1
+ export type HookMatcherUnjudgedReason = 'event_out_of_scope' | 'not_a_string' | 'oversize' | 'invalid_pattern' | 'pattern_unsupported' | 'over_budget';
2
+ export type HookMatcherVerdict = {
3
+ readonly kind: 'matchesAll';
4
+ } | {
5
+ readonly kind: 'accepted';
6
+ readonly reading: 'names';
7
+ readonly names: readonly string[];
8
+ readonly aliases: readonly {
9
+ readonly alias: string;
10
+ readonly canonical: string;
11
+ }[];
12
+ } | {
13
+ readonly kind: 'accepted';
14
+ readonly reading: 'pattern';
15
+ readonly aliases: readonly {
16
+ readonly alias: string;
17
+ readonly canonical: string;
18
+ }[];
19
+ } | {
20
+ readonly kind: 'refused';
21
+ readonly reason: 'alias_without_canonical';
22
+ readonly reading: 'names' | 'pattern';
23
+ readonly alias: string;
24
+ readonly canonical: string;
25
+ } | {
26
+ readonly kind: 'unjudged';
27
+ readonly reason: HookMatcherUnjudgedReason;
28
+ };
29
+ export declare function hookMatcherVerdict(event: string, matcher: unknown): HookMatcherVerdict;
@@ -0,0 +1,265 @@
1
+ import { HOOK_TOOL_ALIASES } from './hookToolAliases.js';
2
+ const TOOL_NAME_MATCHER_EVENTS = new Set(['PreToolUse', 'PostToolUse', 'PostToolUseFailure']);
3
+ const MATCHER_MAX_CHARS = 8192;
4
+ const PATTERN_WORK_BUDGET = 10_000_000;
5
+ const PATTERN_MAX_DEPTH = 32;
6
+ const COUNTED_REPEAT_MAX = 1000;
7
+ function unjudged(reason) {
8
+ return Object.freeze({ kind: 'unjudged', reason });
9
+ }
10
+ function refused(reading, p) {
11
+ return Object.freeze({ kind: 'refused', reason: 'alias_without_canonical', reading, alias: p.alias, canonical: p.canonical });
12
+ }
13
+ function aliasPairs() {
14
+ return Object.entries(HOOK_TOOL_ALIASES).map(([alias, canonical]) => ({ alias, canonical }));
15
+ }
16
+ function literalNames(matcher) {
17
+ const names = [];
18
+ let first = -1;
19
+ let last = -1;
20
+ for (let i = 0; i <= matcher.length; i++) {
21
+ const c = i < matcher.length ? matcher.charCodeAt(i) : 0x7c;
22
+ if (c === 0x7c || c === 0x2c) {
23
+ if (first !== -1)
24
+ names.push(matcher.slice(first, last + 1));
25
+ first = -1;
26
+ last = -1;
27
+ continue;
28
+ }
29
+ if (c === 0x20)
30
+ continue;
31
+ const nameChar = (c >= 0x30 && c <= 0x39) || (c >= 0x41 && c <= 0x5a) || (c >= 0x61 && c <= 0x7a) || c === 0x5f || c === 0x2d;
32
+ if (!nameChar)
33
+ return undefined;
34
+ if (first === -1)
35
+ first = i;
36
+ last = i;
37
+ }
38
+ return names;
39
+ }
40
+ const UNSUPPORTED = Symbol('unsupported');
41
+ const SINGLE_CHAR_ESCAPES = 'dDwWsStnrfv^$\\.*+?()[]{}|/-';
42
+ function patternBound(src, n) {
43
+ let i = 0;
44
+ let depth = 0;
45
+ const fail = () => {
46
+ throw UNSUPPORTED;
47
+ };
48
+ const quantifier = () => {
49
+ const c = src[i];
50
+ let lo;
51
+ let hi;
52
+ if (c === '*') {
53
+ lo = 0;
54
+ hi = Infinity;
55
+ i++;
56
+ }
57
+ else if (c === '+') {
58
+ lo = 1;
59
+ hi = Infinity;
60
+ i++;
61
+ }
62
+ else if (c === '?') {
63
+ lo = 0;
64
+ hi = 1;
65
+ i++;
66
+ }
67
+ else if (c === '{') {
68
+ const q = /^\{(\d{1,4})(?:(,)(\d{0,4}))?\}/.exec(src.slice(i, i + 12));
69
+ if (q === null)
70
+ return fail();
71
+ lo = Number(q[1]);
72
+ hi = q[2] === undefined ? lo : q[3] === '' || q[3] === undefined ? Infinity : Number(q[3]);
73
+ if (lo > COUNTED_REPEAT_MAX || (hi !== Infinity && hi > COUNTED_REPEAT_MAX) || hi < lo)
74
+ fail();
75
+ i += q[0].length;
76
+ }
77
+ else
78
+ return undefined;
79
+ if (src[i] === '?')
80
+ i++;
81
+ return { lo, hi };
82
+ };
83
+ const term = () => {
84
+ const c = src[i];
85
+ if (c === '^' || c === '$') {
86
+ i++;
87
+ if (quantifier() !== undefined)
88
+ fail();
89
+ return [1, 1];
90
+ }
91
+ if (c === '\\' && (src[i + 1] === 'b' || src[i + 1] === 'B')) {
92
+ i += 2;
93
+ if (quantifier() !== undefined)
94
+ fail();
95
+ return [1, 1];
96
+ }
97
+ let paths = 1;
98
+ let steps = 1;
99
+ let single = true;
100
+ if (c === '(') {
101
+ i++;
102
+ if (src[i] === '?') {
103
+ if (src[i + 1] === ':')
104
+ i += 2;
105
+ else {
106
+ const named = /^\?<([A-Za-z_$][A-Za-z0-9_$]*)>/.exec(src.slice(i, i + 80));
107
+ if (named === null)
108
+ fail();
109
+ else
110
+ i += named[0].length;
111
+ }
112
+ }
113
+ if (++depth > PATTERN_MAX_DEPTH)
114
+ fail();
115
+ [paths, steps] = disjunction();
116
+ if (src[i] !== ')')
117
+ fail();
118
+ i++;
119
+ depth--;
120
+ single = false;
121
+ }
122
+ else if (c === '[') {
123
+ i++;
124
+ if (src[i] === '^')
125
+ i++;
126
+ for (;;) {
127
+ if (i >= src.length)
128
+ fail();
129
+ const d = src[i];
130
+ if (d === ']') {
131
+ i++;
132
+ break;
133
+ }
134
+ i += d === '\\' ? 2 : 1;
135
+ }
136
+ }
137
+ else if (c === '.')
138
+ i++;
139
+ else if (c === '\\') {
140
+ const e = src[i + 1];
141
+ if (e === undefined || !SINGLE_CHAR_ESCAPES.includes(e))
142
+ fail();
143
+ i += 2;
144
+ }
145
+ else if (c === undefined || '*+?{}]|)'.includes(c))
146
+ fail();
147
+ else
148
+ i++;
149
+ const q = quantifier();
150
+ if (q === undefined)
151
+ return [paths, steps];
152
+ if (single) {
153
+ if (q.lo > n)
154
+ return [1, n + 1];
155
+ const top = Math.min(q.hi, n);
156
+ return [top - q.lo + 1, top + 1];
157
+ }
158
+ const hiEff = Math.min(q.hi, Math.max(q.lo, n + 1));
159
+ if (q.lo > hiEff)
160
+ return [1, 1];
161
+ let sum = 0;
162
+ for (let k = q.lo; k <= hiEff; k++) {
163
+ sum += paths ** k;
164
+ if (sum === Infinity)
165
+ break;
166
+ }
167
+ return [sum, hiEff * steps + 1];
168
+ };
169
+ const alternative = () => {
170
+ let paths = 1;
171
+ let steps = 0;
172
+ while (i < src.length && src[i] !== '|' && src[i] !== ')') {
173
+ const [p, s] = term();
174
+ paths *= p;
175
+ steps += s;
176
+ }
177
+ return [paths, steps];
178
+ };
179
+ const disjunction = () => {
180
+ let [paths, steps] = alternative();
181
+ while (src[i] === '|') {
182
+ i++;
183
+ const [p, s] = alternative();
184
+ paths += p;
185
+ steps = Math.max(steps, s);
186
+ }
187
+ return [paths, steps];
188
+ };
189
+ try {
190
+ const r = disjunction();
191
+ if (i !== src.length)
192
+ fail();
193
+ return r;
194
+ }
195
+ catch (e) {
196
+ if (e === UNSUPPORTED)
197
+ return undefined;
198
+ throw e;
199
+ }
200
+ }
201
+ export function hookMatcherVerdict(event, matcher) {
202
+ if (typeof event !== 'string' || !TOOL_NAME_MATCHER_EVENTS.has(event))
203
+ return unjudged('event_out_of_scope');
204
+ if (matcher === undefined)
205
+ return Object.freeze({ kind: 'matchesAll' });
206
+ if (typeof matcher !== 'string')
207
+ return unjudged('not_a_string');
208
+ if (matcher.length > MATCHER_MAX_CHARS)
209
+ return unjudged('oversize');
210
+ if (matcher === '' || matcher === '*')
211
+ return Object.freeze({ kind: 'matchesAll' });
212
+ const pairs = aliasPairs();
213
+ const names = literalNames(matcher);
214
+ if (names !== undefined) {
215
+ const dead = pairs.find((p) => names.includes(p.alias) && !names.includes(p.canonical));
216
+ if (dead !== undefined)
217
+ return refused('names', dead);
218
+ return Object.freeze({
219
+ kind: 'accepted',
220
+ reading: 'names',
221
+ names: Object.freeze([...names]),
222
+ aliases: Object.freeze(pairs.filter((p) => names.includes(p.alias)).map((p) => Object.freeze({ ...p }))),
223
+ });
224
+ }
225
+ const src = `^(?:${matcher})$`;
226
+ let re;
227
+ try {
228
+ re = new RegExp(src);
229
+ }
230
+ catch {
231
+ return unjudged('invalid_pattern');
232
+ }
233
+ const subjects = pairs.flatMap((p) => [p.alias, p.canonical]);
234
+ const n = subjects.reduce((a, s) => Math.max(a, s.length), 0);
235
+ const bound = patternBound(src, n);
236
+ if (bound === undefined)
237
+ return unjudged('pattern_unsupported');
238
+ if (bound[0] * bound[1] * (n + 1) * subjects.length > PATTERN_WORK_BUDGET)
239
+ return unjudged('over_budget');
240
+ const selects = (name) => {
241
+ if (matcher === name)
242
+ return true;
243
+ try {
244
+ return re.test(name);
245
+ }
246
+ catch {
247
+ return undefined;
248
+ }
249
+ };
250
+ const selected = [];
251
+ for (const p of pairs) {
252
+ const a = selects(p.alias);
253
+ if (a === undefined)
254
+ return unjudged('invalid_pattern');
255
+ if (!a)
256
+ continue;
257
+ const c = selects(p.canonical);
258
+ if (c === undefined)
259
+ return unjudged('invalid_pattern');
260
+ if (!c)
261
+ return refused('pattern', p);
262
+ selected.push(p);
263
+ }
264
+ return Object.freeze({ kind: 'accepted', reading: 'pattern', aliases: Object.freeze(selected.map((p) => Object.freeze({ ...p }))) });
265
+ }
@@ -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
+ }
@@ -0,0 +1,91 @@
1
+ import type { ImageInput } from './imagesWireCaps.js';
2
+ import type { ImageVision } from './liveModelCatalog.js';
3
+ import { type UserAttachmentDescriptor } from './userAttachmentEnvelope.js';
4
+ export interface HumanTurnRider {
5
+ readonly uuid: string;
6
+ readonly role: 'image_meta' | 'attachment' | 'skill_body' | (string & {});
7
+ readonly textIncluded: boolean;
8
+ }
9
+ export interface HumanTurnMissing {
10
+ readonly kind: 'rider_text' | 'image' | 'attachment_ref' | 'non_text';
11
+ readonly ref?: string;
12
+ readonly reason: 'not_persisted' | 'not_found' | 'non_text_filtered' | 'projection_failed';
13
+ }
14
+ export interface HumanTurnAttachment {
15
+ readonly uuid: string;
16
+ readonly descriptor: Exclude<UserAttachmentDescriptor, {
17
+ kind: 'image';
18
+ }> | Omit<Extract<UserAttachmentDescriptor, {
19
+ kind: 'image';
20
+ }>, 'delivery'>;
21
+ readonly pixels?: {
22
+ readonly data: string;
23
+ readonly mimeType: string;
24
+ };
25
+ }
26
+ export interface HumanTurnItem {
27
+ readonly uuid: string;
28
+ readonly text: string;
29
+ readonly images?: readonly ImageInput[];
30
+ readonly attachments?: readonly HumanTurnAttachment[];
31
+ readonly attachmentIds?: readonly string[];
32
+ readonly riders?: readonly HumanTurnRider[];
33
+ readonly missing?: readonly HumanTurnMissing[];
34
+ }
35
+ export interface HumanTurnCaps {
36
+ readonly vision?: ImageVision;
37
+ }
38
+ export interface HumanTurnInput {
39
+ readonly items: readonly HumanTurnItem[];
40
+ readonly lane: 'objective' | 'steer';
41
+ readonly caps: HumanTurnCaps;
42
+ readonly otherBodyBytes?: number;
43
+ }
44
+ type EncoderShortfall = 'body_budget' | 'steer_admission' | 'vision_no' | 'vision_unknown' | 'image_too_large' | 'seat_count' | 'seat_total' | 'lane_has_no_image_seat' | 'lane_has_no_attachment_id_seat';
45
+ export interface HumanTurnSharePart {
46
+ readonly kind: 'text' | 'image' | 'attachment_ref' | 'attachment_id' | 'rider_text' | 'non_text';
47
+ readonly ref?: string | number;
48
+ readonly status: 'full' | 'none';
49
+ readonly why?: EncoderShortfall | 'text_not_included' | HumanTurnMissing['reason'];
50
+ }
51
+ export interface HumanTurnShare {
52
+ readonly uuid: string;
53
+ readonly riderUuids: readonly string[];
54
+ readonly level: 'full' | 'partial' | 'none';
55
+ readonly parts: readonly HumanTurnSharePart[];
56
+ }
57
+ export interface HumanTurnDegraded {
58
+ readonly uuid: string;
59
+ readonly kind: HumanTurnSharePart['kind'];
60
+ readonly ref?: string | number;
61
+ readonly why: EncoderShortfall;
62
+ }
63
+ export type HumanTurnEncoding = {
64
+ readonly ok: true;
65
+ readonly lane: 'objective';
66
+ readonly text: string;
67
+ readonly images: readonly ImageInput[];
68
+ readonly attachmentIds: readonly string[];
69
+ readonly shares: readonly HumanTurnShare[];
70
+ readonly degraded: readonly HumanTurnDegraded[];
71
+ } | {
72
+ readonly ok: true;
73
+ readonly lane: 'steer';
74
+ readonly text: string;
75
+ readonly shares: readonly HumanTurnShare[];
76
+ readonly degraded: readonly HumanTurnDegraded[];
77
+ } | {
78
+ readonly ok: false;
79
+ readonly reason: 'steer_hold';
80
+ readonly why: 'no_text' | 'reminder_tag' | 'control_char' | 'too_long';
81
+ } | {
82
+ readonly ok: false;
83
+ readonly reason: 'empty' | 'malformed_input' | 'malformed_item' | 'duplicate_uuid' | 'rider_collides_primary' | 'oversize';
84
+ };
85
+ export interface HumanTurnDelivered {
86
+ readonly full: readonly string[];
87
+ readonly partial: readonly string[];
88
+ }
89
+ export declare function encodeHumanTurn(input: HumanTurnInput): HumanTurnEncoding;
90
+ export declare function deliveredUuidsOf(encoding: HumanTurnEncoding): HumanTurnDelivered;
91
+ export {};