@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
@@ -1473,7 +1473,7 @@ function quotedAddressEnd(S, from, to) {
1473
1473
  }
1474
1474
  return to;
1475
1475
  }
1476
- function labelCandidates(S, pass, regions, out) {
1476
+ function labelCandidates(S, pass, regions, out, blocks) {
1477
1477
  const text = S.text;
1478
1478
  const unitAt = (k) => S.unitAt(k);
1479
1479
  const re = pass === 'label' ? SECRET_LABELLED_WORD : SECRET_SCHEME_WORD;
@@ -1642,6 +1642,11 @@ function labelCandidates(S, pass, regions, out) {
1642
1642
  if (schemePass && labelStartsAt(text, hit.index))
1643
1643
  continue;
1644
1644
  const from = hit.index + hit[0].length;
1645
+ if (blocks !== undefined && (text.charCodeAt(from) === 0x7c || text.charCodeAt(from) === 0x3e) && isColonSeparator(hit[0].slice((hit[1] ?? '').length))) {
1646
+ const blk = blockScalarExtent(blocks, S.rawStart(from), S.rawStart(hit.index));
1647
+ if (blk !== null)
1648
+ blocks.out.push({ start: blk.start, end: blk.end, kind: 'secret', cls: 'word', tokenEnd: blk.end, pretrimmed: true });
1649
+ }
1645
1650
  if (credentialWordStartsAt(text, from, idx.tokenInner)) {
1646
1651
  pushInnerRemainder(from);
1647
1652
  re.lastIndex = from;
@@ -1886,6 +1891,149 @@ function lineBreakLengthBefore(text, at) {
1886
1891
  return 2;
1887
1892
  return 0;
1888
1893
  }
1894
+ const isRawBlank = (c) => (isRegexSpace(c) && c !== 0xfeff) || isNameBlank(c);
1895
+ function isColonSeparator(sep) {
1896
+ let colon = false;
1897
+ for (let k = 0; k < sep.length; k++) {
1898
+ const c = sep.charCodeAt(k);
1899
+ if (c === 0x3d || c === 0xff1d)
1900
+ return false;
1901
+ if (c === 0x3a || c === 0xff1a)
1902
+ colon = true;
1903
+ }
1904
+ return colon;
1905
+ }
1906
+ function blockBreakAt(raw, at, escaped) {
1907
+ const n = lineBreakLengthAt(raw, at);
1908
+ return n > 0 && (raw.charCodeAt(at) === 0x5c) === escaped ? n : 0;
1909
+ }
1910
+ function blockMarks(scan) {
1911
+ if (scan.marks !== null)
1912
+ return scan.marks;
1913
+ const V = scan.view;
1914
+ const seq = new Uint8Array(scan.raw.length);
1915
+ const payload = new Uint8Array(scan.raw.length);
1916
+ for (let k = 0; k < V.view.length; k++) {
1917
+ if (V.dropped[k] !== 1 || V.units[k] !== UNIT_SEQUENCE)
1918
+ continue;
1919
+ for (let x = V.starts[k] ?? 0; x < (V.ends[k] ?? 0); x++)
1920
+ seq[x] = 1;
1921
+ }
1922
+ for (const [a, b] of V.contents)
1923
+ for (let x = a; x < b; x++)
1924
+ payload[x] = 1;
1925
+ scan.marks = { seq, payload };
1926
+ return scan.marks;
1927
+ }
1928
+ function blockLines(scan, escaped) {
1929
+ const slot = escaped ? 1 : 0;
1930
+ const have = scan.lines[slot];
1931
+ if (have !== null)
1932
+ return have;
1933
+ const raw = scan.raw;
1934
+ const unit = scan.view.rawUnit;
1935
+ const { seq, payload } = blockMarks(scan);
1936
+ const starts = [];
1937
+ const ends = [];
1938
+ const indent = [];
1939
+ let pos = 0;
1940
+ for (;;) {
1941
+ let k = pos;
1942
+ let n = 0;
1943
+ let width = 0;
1944
+ let lead = true;
1945
+ let visible = false;
1946
+ while (k < raw.length && (n = blockBreakAt(raw, k, escaped)) === 0) {
1947
+ if (lead) {
1948
+ const c = raw.charCodeAt(k);
1949
+ if (payload[k] === 1)
1950
+ visible = true;
1951
+ if (seq[k] === 1) {
1952
+ }
1953
+ else if (isRawBlank(c))
1954
+ width++;
1955
+ else if (unit[k] !== 1) {
1956
+ visible = true;
1957
+ lead = false;
1958
+ }
1959
+ }
1960
+ k++;
1961
+ }
1962
+ starts.push(pos);
1963
+ ends.push(k);
1964
+ indent.push(visible ? width : -1);
1965
+ if (k >= raw.length)
1966
+ break;
1967
+ pos = k + n;
1968
+ }
1969
+ const nextContent = new Int32Array(starts.length + 1);
1970
+ nextContent[starts.length] = starts.length;
1971
+ for (let i = starts.length - 1; i >= 0; i--)
1972
+ nextContent[i] = (indent[i] ?? -1) !== -1 ? i : (nextContent[i + 1] ?? starts.length);
1973
+ const built = { starts, ends, indent, nextContent, memo: new Map() };
1974
+ scan.lines[slot] = built;
1975
+ return built;
1976
+ }
1977
+ function blockLineOf(lines, p) {
1978
+ let lo = 0;
1979
+ let hi = lines.starts.length - 1;
1980
+ while (lo < hi) {
1981
+ const mid = (lo + hi + 1) >> 1;
1982
+ if ((lines.starts[mid] ?? 0) <= p)
1983
+ lo = mid;
1984
+ else
1985
+ hi = mid - 1;
1986
+ }
1987
+ return lo;
1988
+ }
1989
+ function blockScalarExtent(scan, at, labelAt) {
1990
+ const raw = scan.raw;
1991
+ const mark = raw.charCodeAt(at);
1992
+ if (mark !== 0x7c && mark !== 0x3e)
1993
+ return null;
1994
+ const unit = scan.view.rawUnit;
1995
+ let k = at + 1;
1996
+ while (k < raw.length && lineBreakLengthAt(raw, k) === 0) {
1997
+ const c = raw.charCodeAt(k);
1998
+ if (c === 0x2d || c === 0x2b || (c >= 0x30 && c <= 0x39) || (unit[k] === 1 && !isRawBlank(c)))
1999
+ k++;
2000
+ else
2001
+ break;
2002
+ }
2003
+ while (k < raw.length && lineBreakLengthAt(raw, k) === 0 && (isRawBlank(raw.charCodeAt(k)) || unit[k] === 1))
2004
+ k++;
2005
+ if (k >= raw.length)
2006
+ return null;
2007
+ let escaped;
2008
+ if (lineBreakLengthAt(raw, k) > 0)
2009
+ escaped = raw.charCodeAt(k) === 0x5c;
2010
+ else if (raw.charCodeAt(k) === 0x23) {
2011
+ const real = blockLines(scan, false);
2012
+ if ((real.ends[blockLineOf(real, k)] ?? raw.length) < raw.length)
2013
+ escaped = false;
2014
+ else {
2015
+ const lit = blockLines(scan, true);
2016
+ if ((lit.ends[blockLineOf(lit, k)] ?? raw.length) >= raw.length)
2017
+ return null;
2018
+ escaped = true;
2019
+ }
2020
+ }
2021
+ else
2022
+ return null;
2023
+ const lines = blockLines(scan, escaped);
2024
+ const head = blockLineOf(lines, at);
2025
+ const limit = Math.max(0, lines.indent[blockLineOf(lines, labelAt)] ?? 0);
2026
+ const key = head * (raw.length + 1) + limit;
2027
+ let end = lines.memo.get(key);
2028
+ if (end === undefined) {
2029
+ end = lines.ends[head] ?? raw.length;
2030
+ for (let i = lines.nextContent[head + 1] ?? lines.starts.length; i < lines.starts.length && (lines.indent[i] ?? -1) > limit; i = lines.nextContent[i + 1] ?? lines.starts.length) {
2031
+ end = lines.ends[i] ?? end;
2032
+ }
2033
+ lines.memo.set(key, end);
2034
+ }
2035
+ return { start: at, end };
2036
+ }
1889
2037
  function pemBodyEndWithoutTrailer(text, from) {
1890
2038
  let pos = from;
1891
2039
  let inBody = false;
@@ -2779,6 +2927,7 @@ function collectCandidates(text, o, nested) {
2779
2927
  const screen = screenSurfaces(text, o);
2780
2928
  surfaces.push(...screen.surfaces);
2781
2929
  const raw = [];
2930
+ const blocks = { raw: text, view: V, out: raw, lines: [null, null], marks: null };
2782
2931
  const regionSurface = screen.surfaces[0] ?? separated;
2783
2932
  const pemBlocksSeen = [];
2784
2933
  for (const S of surfaces) {
@@ -2792,9 +2941,9 @@ function collectCandidates(text, o, nested) {
2792
2941
  if (o.words) {
2793
2942
  editsToCandidates(pemEdits(S, (blk) => { if (S === regionSurface)
2794
2943
  pemBlocksSeen.push(pemBlockToRaw(S, blk)); }), 'pem', cands);
2795
- labelCandidates(S, 'scheme', regions, cands);
2796
- labelCandidates(S, 'token', regions, cands);
2797
- labelCandidates(S, 'label', regions, cands);
2944
+ labelCandidates(S, 'scheme', regions, cands, blocks);
2945
+ labelCandidates(S, 'token', regions, cands, blocks);
2946
+ labelCandidates(S, 'label', regions, cands, blocks);
2798
2947
  editsToCandidates(authParamEdits(S.text), 'param', cands);
2799
2948
  editsToCandidates(proseLiteralEdits(S.text), 'prose', cands);
2800
2949
  }
@@ -1,4 +1,15 @@
1
1
  import { snapshotCapsGeneration, capsGenerationStillCurrent } from './engineCapsGenerationGuard.js';
2
+ function freezeReading(reading, seen = new Set()) {
3
+ if (reading === null || typeof reading !== 'object' || seen.has(reading))
4
+ return reading;
5
+ seen.add(reading);
6
+ Object.freeze(reading);
7
+ for (const d of Object.values(Object.getOwnPropertyDescriptors(reading))) {
8
+ if ('value' in d)
9
+ freezeReading(d.value, seen);
10
+ }
11
+ return reading;
12
+ }
2
13
  export function createEngineCapReader(spec) {
3
14
  const readingByBase = new Map();
4
15
  return {
@@ -23,7 +34,7 @@ export function createEngineCapReader(spec) {
23
34
  readingByBase.delete(baseUrl);
24
35
  return;
25
36
  }
26
- readingByBase.set(baseUrl, reading);
37
+ readingByBase.set(baseUrl, freezeReading(reading));
27
38
  },
28
39
  observed(baseUrl) {
29
40
  if (typeof baseUrl !== 'string' || baseUrl === '')
@@ -1,6 +1,8 @@
1
1
  export declare function engineCapsGeneration(baseUrl: string): number;
2
2
  export declare function kickEngineCapsProbe(baseUrl: string, probe: () => Promise<unknown>): void;
3
- export declare function engineCapsSettled(baseUrl: string | undefined): Promise<void>;
3
+ export declare function engineCapsSettled(baseUrl: string | undefined, opts?: {
4
+ withinMs?: number;
5
+ }): Promise<'settled' | 'timed_out'>;
4
6
  export type EngineCapState = 'true' | 'false' | 'unprobed' | 'absent' | 'non_boolean';
5
7
  export declare function engineCapState(baseUrl: string | undefined, key: string): EngineCapState;
6
8
  export declare function engineCapTrue(baseUrl: string | undefined, key: string): boolean;
@@ -43,21 +43,71 @@ export function kickEngineCapsProbe(baseUrl, probe) {
43
43
  }
44
44
  })();
45
45
  }
46
- export async function engineCapsSettled(baseUrl) {
47
- if (!baseUrl)
48
- return;
46
+ const MAX_WITHIN_MS = 2_147_483_647;
47
+ function waitBudgetOf(opts) {
48
+ try {
49
+ if (opts === undefined || opts === null)
50
+ return undefined;
51
+ if (typeof opts !== 'object')
52
+ return 0;
53
+ const v = opts.withinMs;
54
+ if (v === undefined)
55
+ return undefined;
56
+ if (typeof v !== 'number' || !Number.isFinite(v) || !(v > 0))
57
+ return 0;
58
+ return v > MAX_WITHIN_MS ? MAX_WITHIN_MS : v;
59
+ }
60
+ catch {
61
+ return 0;
62
+ }
63
+ }
64
+ async function relaySettled(baseUrl, deadline) {
49
65
  for (;;) {
50
66
  const entry = settleByBase.get(baseUrl);
51
67
  if (entry === undefined)
52
- return;
68
+ return 'settled';
53
69
  const awaitedGen = entry.gen;
54
- await Promise.race([
70
+ const landed = Promise.race([
55
71
  entry.promise.then(() => undefined, () => undefined),
56
72
  entry.superseded,
57
73
  ]);
74
+ if (deadline === undefined) {
75
+ await landed;
76
+ }
77
+ else {
78
+ const first = await Promise.race([landed.then(() => 'landed'), deadline]);
79
+ if (first === 'timed_out')
80
+ return 'timed_out';
81
+ }
58
82
  const next = settleByBase.get(baseUrl);
59
83
  if (next === undefined || next.gen <= awaitedGen)
60
- return;
84
+ return 'settled';
85
+ }
86
+ }
87
+ export async function engineCapsSettled(baseUrl, opts) {
88
+ const budget = waitBudgetOf(opts);
89
+ if (!baseUrl)
90
+ return 'settled';
91
+ if (budget === undefined)
92
+ return relaySettled(baseUrl, undefined);
93
+ if (settleByBase.get(baseUrl) === undefined)
94
+ return 'settled';
95
+ if (budget === 0)
96
+ return 'timed_out';
97
+ let timer;
98
+ try {
99
+ const deadline = new Promise((resolve) => {
100
+ timer = setTimeout(() => resolve('timed_out'), budget);
101
+ });
102
+ deadline.catch(() => undefined);
103
+ return await relaySettled(baseUrl, deadline);
104
+ }
105
+ catch {
106
+ return 'timed_out';
107
+ }
108
+ finally {
109
+ if (timer !== undefined)
110
+ clearTimeout(timer);
61
111
  }
62
112
  }
63
113
  export function engineCapState(baseUrl, key) {
@@ -0,0 +1,2 @@
1
+ export declare const ASK_EVIDENCE_ABSENCE_VALUES: readonly ["not_wired", "not_adjudicated", "unavailable", "no_match", "not_reported"];
2
+ export declare const SYSTEM_INJECTION_PRIORITIES: readonly ["now", "next", "later"];
@@ -0,0 +1,3 @@
1
+ import { CORE_ASK_EVIDENCE_ABSENCE_VALUES, CORE_SYSTEM_INJECTION_PRIORITIES } from './generated/engineFactTables.js';
2
+ export const ASK_EVIDENCE_ABSENCE_VALUES = CORE_ASK_EVIDENCE_ABSENCE_VALUES;
3
+ export const SYSTEM_INJECTION_PRIORITIES = CORE_SYSTEM_INJECTION_PRIORITIES;
@@ -49,6 +49,9 @@ export declare function isRewindFamilyCode(code: string | undefined): boolean;
49
49
  export declare const RESUME_USAGE_WINDOW_EXHAUSTED = "resume.usage_window_exhausted";
50
50
  export declare const RESUME_PREFLIGHT_REJECTED = "resume.preflight_rejected";
51
51
  export declare const RESUME_SESSION_NOT_FOUND = "resume.session_not_found";
52
+ export declare const REQUEST_FIELD_CONFLICT = "request.field_conflict";
53
+ export declare const CHECKPOINT_UNSUPPORTED_VERSION = "checkpoint.unsupported_version";
54
+ export declare function refusalSaysStillPending(err: object): boolean;
52
55
  export type StatusDerivedCoarseCode = (typeof STATUS_DERIVED_COARSE_CODES)[number];
53
56
  export declare const RESUME_PLACEMENT_MISMATCH = "resume.placement_mismatch";
54
57
  export declare const RESUME_CONTEXT_UNAVAILABLE = "conflict.resume_context_unavailable";
@@ -107,6 +107,16 @@ export function isRewindFamilyCode(code) {
107
107
  export const RESUME_USAGE_WINDOW_EXHAUSTED = 'resume.usage_window_exhausted';
108
108
  export const RESUME_PREFLIGHT_REJECTED = 'resume.preflight_rejected';
109
109
  export const RESUME_SESSION_NOT_FOUND = 'resume.session_not_found';
110
+ export const REQUEST_FIELD_CONFLICT = 'request.field_conflict';
111
+ export const CHECKPOINT_UNSUPPORTED_VERSION = 'checkpoint.unsupported_version';
112
+ export function refusalSaysStillPending(err) {
113
+ try {
114
+ return Object.hasOwn(err, 'retriable') && err.retriable === true;
115
+ }
116
+ catch {
117
+ return false;
118
+ }
119
+ }
110
120
  export const RESUME_PLACEMENT_MISMATCH = 'resume.placement_mismatch';
111
121
  export const RESUME_CONTEXT_UNAVAILABLE = 'conflict.resume_context_unavailable';
112
122
  export const RESUME_RETRY_LATER_CODES = Object.freeze([
@@ -130,13 +130,6 @@ export interface ReadDenyUnappliedFactsView {
130
130
  runId: string;
131
131
  }
132
132
  export declare function readReadDenyUnapplied(notice: unknown): ReadDenyUnappliedFactsView | undefined;
133
- export interface LegacyModeSeedMigratedFactsView {
134
- permissionMode?: string;
135
- droppedKeys: readonly string[];
136
- sessionId: string;
137
- runId: string;
138
- }
139
- export declare function readLegacyModeSeedMigrated(notice: unknown): LegacyModeSeedMigratedFactsView | undefined;
140
133
  export interface ToolTurnRepairView {
141
134
  form: string;
142
135
  toolCallIds: readonly string[];
@@ -172,9 +165,10 @@ export interface UserInputUndrainedFactsView {
172
165
  taskId?: string;
173
166
  sessionId?: string;
174
167
  runId?: string;
168
+ childSessionId?: string;
175
169
  }
176
170
  export declare function readUserInputUndrained(notice: unknown): UserInputUndrainedFactsView | undefined;
177
- export declare function userInputUndrainedNotice(facts: Pick<UserInputUndrainedFactsView, 'kind' | 'count' | 'cause'>): string | undefined;
171
+ export declare function userInputUndrainedNotice(facts: Pick<UserInputUndrainedFactsView, 'kind' | 'count' | 'cause' | 'childSessionId'>): string | undefined;
178
172
  export declare const ENGINE_NOTICE_FACT_READERS: Readonly<{
179
173
  readonly 'mcp.injection_dropped': typeof readMcpInjectionDrop;
180
174
  readonly 'delegation.ask_unresolvable': typeof readAskUnresolvable;
@@ -190,7 +184,6 @@ export declare const ENGINE_NOTICE_FACT_READERS: Readonly<{
190
184
  readonly 'config.permission_mode_unavailable': typeof readPermissionModeUnavailable;
191
185
  readonly 'permission.ask_released_by_mode': typeof readAskReleasedByMode;
192
186
  readonly 'permission.read_deny_unapplied': typeof readReadDenyUnapplied;
193
- readonly 'resume.legacy_mode_seed_migrated': typeof readLegacyModeSeedMigrated;
194
187
  readonly 'context.tool_turn_repaired': typeof readToolTurnRepaired;
195
188
  readonly 'server.model_unreachable': typeof readModelUnreachable;
196
189
  readonly 'task.tool_turn_incomplete': typeof readToolTurnIncomplete;
@@ -454,31 +454,6 @@ function readReadDenyUnappliedOf(notice) {
454
454
  }
455
455
  return { mode, toolCallId, tiers, rows, rowCount, sessionId, runId };
456
456
  }
457
- export function readLegacyModeSeedMigrated(notice) {
458
- return guardedRead(notice, readLegacyModeSeedMigratedOf);
459
- }
460
- function readLegacyModeSeedMigratedOf(notice) {
461
- if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
462
- return undefined;
463
- const n = notice;
464
- if (ownSeat(n, 'code') !== 'resume.legacy_mode_seed_migrated')
465
- return undefined;
466
- const d = ownSeat(n, 'detail');
467
- if (typeof d !== 'object' || d === null || Array.isArray(d))
468
- return undefined;
469
- const o = d;
470
- const m = o.migrated;
471
- if (typeof m !== 'object' || m === null || Array.isArray(m))
472
- return undefined;
473
- const mo = m;
474
- const droppedKeys = nameList(mo.droppedKeys);
475
- const sessionId = nonEmpty(o.sessionId);
476
- const runId = nonEmpty(o.runId);
477
- if (droppedKeys === undefined || sessionId === undefined || runId === undefined)
478
- return undefined;
479
- const permissionMode = nonEmpty(optionalSeat(mo, 'permissionMode'));
480
- return { ...(permissionMode !== undefined ? { permissionMode } : {}), droppedKeys, sessionId, runId };
481
- }
482
457
  export function readToolTurnRepaired(notice) {
483
458
  return guardedRead(notice, readToolTurnRepairedOf);
484
459
  }
@@ -601,6 +576,7 @@ function readUserInputUndrainedOf(notice) {
601
576
  const taskId = nonEmpty(optionalOwnSeat(o, 'taskId'));
602
577
  const sessionId = nonEmpty(optionalOwnSeat(o, 'sessionId'));
603
578
  const runId = nonEmpty(optionalOwnSeat(o, 'runId'));
579
+ const childSessionId = nonEmpty(optionalOwnSeat(o, 'childSessionId'));
604
580
  return {
605
581
  kind,
606
582
  count,
@@ -608,6 +584,7 @@ function readUserInputUndrainedOf(notice) {
608
584
  ...(taskId !== undefined ? { taskId } : {}),
609
585
  ...(sessionId !== undefined ? { sessionId } : {}),
610
586
  ...(runId !== undefined ? { runId } : {}),
587
+ ...(childSessionId !== undefined ? { childSessionId } : {}),
611
588
  };
612
589
  }
613
590
  const messagesPhrase = (n, noun) => `${n} ${noun}${n === 1 ? '' : 's'}`;
@@ -623,12 +600,17 @@ const _steerSentencePin = true;
623
600
  void _steerSentencePin;
624
601
  const followUpUndrainedSentence = (n) => `${messagesPhrase(n, 'follow-up message')} you queued ${verbBe(n)} not used before the run ended and will not be delivered. ` +
625
602
  `Send ${itThem(n)} again if you still need ${itThem(n)}.`;
603
+ const subagentSteerUndrainedSentence = (n) => `${messagesPhrase(n, 'message')} you sent while the run was in progress ${verbBe(n)} not used before a sub-agent's run ended and will not be delivered. ` +
604
+ `Send ${itThem(n)} again if you still need ${itThem(n)}.`;
605
+ const subagentFollowUpUndrainedSentence = (n) => `${messagesPhrase(n, 'follow-up message')} you queued ${verbBe(n)} not used before a sub-agent's run ended and will not be delivered. ` +
606
+ `Send ${itThem(n)} again if you still need ${itThem(n)}.`;
626
607
  const unrecognizedUndrainedSentence = (n, kind) => `${kind === 'followUp' ? `${messagesPhrase(n, 'follow-up message')} you queued` : `${messagesPhrase(n, 'message')} you sent during a run`} may not have been used, ` +
627
608
  `and the reason was not reported in a form this version recognizes. Check the run's transcript before sending ${itThem(n)} again.`;
628
609
  export function userInputUndrainedNotice(facts) {
629
610
  let kind;
630
611
  let count;
631
612
  let cause;
613
+ let child;
632
614
  try {
633
615
  if (facts === null || typeof facts !== 'object' || Array.isArray(facts))
634
616
  return undefined;
@@ -639,12 +621,23 @@ export function userInputUndrainedNotice(facts) {
639
621
  catch {
640
622
  return undefined;
641
623
  }
624
+ try {
625
+ child = Object.hasOwn(facts, 'childSessionId') ? facts.childSessionId : undefined;
626
+ }
627
+ catch {
628
+ child = undefined;
629
+ }
630
+ const fromSubagent = typeof child === 'string' && child.length > 0;
642
631
  const n = positiveInt(count);
643
632
  if (n === undefined || (kind !== 'steer' && kind !== 'followUp'))
644
633
  return undefined;
645
634
  if (kind === 'followUp') {
646
- return cause === undefined || cause === 'leg_end' ? followUpUndrainedSentence(n) : unrecognizedUndrainedSentence(n, kind);
635
+ if (cause === undefined || cause === 'leg_end')
636
+ return fromSubagent ? subagentFollowUpUndrainedSentence(n) : followUpUndrainedSentence(n);
637
+ return unrecognizedUndrainedSentence(n, kind);
647
638
  }
639
+ if (cause === 'leg_end' && fromSubagent)
640
+ return subagentSteerUndrainedSentence(n);
648
641
  if (typeof cause === 'string' && Object.hasOwn(STEER_UNDRAINED_SENTENCE, cause)) {
649
642
  return STEER_UNDRAINED_SENTENCE[cause](n);
650
643
  }
@@ -665,7 +658,6 @@ export const ENGINE_NOTICE_FACT_READERS = Object.freeze({
665
658
  'config.permission_mode_unavailable': readPermissionModeUnavailable,
666
659
  'permission.ask_released_by_mode': readAskReleasedByMode,
667
660
  'permission.read_deny_unapplied': readReadDenyUnapplied,
668
- 'resume.legacy_mode_seed_migrated': readLegacyModeSeedMigrated,
669
661
  'context.tool_turn_repaired': readToolTurnRepaired,
670
662
  'server.model_unreachable': readModelUnreachable,
671
663
  'task.tool_turn_incomplete': readToolTurnIncomplete,
@@ -0,0 +1,20 @@
1
+ import type { AgentEvent } from '@sema-agent/sdk';
2
+ import { type FileHistoryCaptureReading } from './fileHistoryCaptureCapability.js';
3
+ export type FileHistoryDeclarationFact = 'sent' | 'not_sent' | 'unknown';
4
+ export declare const FILE_HISTORY_LEG_VERDICTS: readonly ["not_honored", "not_offered", "honored", "not_declared", "unknown"];
5
+ export type FileHistoryLegNoticeVerdict = (typeof FILE_HISTORY_LEG_VERDICTS)[number];
6
+ export interface FileHistoryLegNoticeInput {
7
+ readonly capability: FileHistoryCaptureReading;
8
+ readonly declaration: FileHistoryDeclarationFact;
9
+ readonly captureOffByUser: boolean;
10
+ readonly legWord: string | undefined;
11
+ }
12
+ export declare function fileHistoryLegNoticeVerdict(input: FileHistoryLegNoticeInput): FileHistoryLegNoticeVerdict;
13
+ export declare function fileHistoryLegNoticeSentence(verdict: FileHistoryLegNoticeVerdict): string | null;
14
+ export declare function fileHistoryDeclarationOfBody(body: object | null | undefined): FileHistoryDeclarationFact;
15
+ export interface FileHistoryDeclarationLedger {
16
+ declared(requestKey: string, fact: FileHistoryDeclarationFact): boolean;
17
+ boundToRun(requestKey: string, runId: string, event: AgentEvent): boolean;
18
+ declarationOf(runId: string): FileHistoryDeclarationFact;
19
+ }
20
+ export declare function createFileHistoryDeclarationLedger(): FileHistoryDeclarationLedger;
@@ -0,0 +1,122 @@
1
+ import { fileHistoryCaptureMode } from './fileHistoryCaptureCapability.js';
2
+ import { frameProvesDelivery } from './promptDelivery.js';
3
+ import { FILE_HISTORY_DISABLED } from './request/taskRequest.js';
4
+ export const FILE_HISTORY_LEG_VERDICTS = Object.freeze(['not_honored', 'not_offered', 'honored', 'not_declared', 'unknown']);
5
+ function ownRead(o, key) {
6
+ return Object.hasOwn(o, key) ? o[key] : undefined;
7
+ }
8
+ function declarationOfInput(v) {
9
+ return v === 'sent' || v === 'not_sent' ? v : 'unknown';
10
+ }
11
+ export function fileHistoryLegNoticeVerdict(input) {
12
+ if (typeof input !== 'object' || input === null)
13
+ return 'unknown';
14
+ let capability;
15
+ let declaration;
16
+ let offByUser;
17
+ let legWord;
18
+ try {
19
+ capability = ownRead(input, 'capability');
20
+ declaration = declarationOfInput(ownRead(input, 'declaration'));
21
+ offByUser = ownRead(input, 'captureOffByUser') === true;
22
+ legWord = ownRead(input, 'legWord');
23
+ }
24
+ catch {
25
+ return 'unknown';
26
+ }
27
+ if (legWord !== 'on' && legWord !== FILE_HISTORY_DISABLED)
28
+ return 'unknown';
29
+ if (declaration === 'sent')
30
+ return legWord === 'on' ? 'not_honored' : 'honored';
31
+ if (!offByUser)
32
+ return 'not_declared';
33
+ const mode = fileHistoryCaptureMode(capability);
34
+ if (legWord === 'on' && mode === 'on-always')
35
+ return 'not_offered';
36
+ if (declaration === 'not_sent' && (legWord === FILE_HISTORY_DISABLED || mode === 'on-optional'))
37
+ return 'not_declared';
38
+ return 'unknown';
39
+ }
40
+ const NOT_HONORED_SENTENCE = 'The engine is still capturing file history for this session, though your settings asked it not to.';
41
+ const NOT_OFFERED_SENTENCE = 'This engine always captures file history and cannot turn it off per session, even though file checkpoints are off in your settings.';
42
+ export function fileHistoryLegNoticeSentence(verdict) {
43
+ if (verdict === 'not_honored')
44
+ return NOT_HONORED_SENTENCE;
45
+ if (verdict === 'not_offered')
46
+ return NOT_OFFERED_SENTENCE;
47
+ return null;
48
+ }
49
+ export function fileHistoryDeclarationOfBody(body) {
50
+ if (typeof body !== 'object' || body === null)
51
+ return 'unknown';
52
+ try {
53
+ if (Array.isArray(body))
54
+ return 'unknown';
55
+ if (typeof body.toJSON === 'function')
56
+ return 'unknown';
57
+ const d = Object.getOwnPropertyDescriptor(body, 'fileHistory');
58
+ const all = Object.getOwnPropertyDescriptors(body);
59
+ for (const k of Reflect.ownKeys(all)) {
60
+ const x = all[k];
61
+ if (x !== undefined && x.enumerable === true && !Object.hasOwn(x, 'value'))
62
+ return 'unknown';
63
+ }
64
+ const listed = Object.hasOwn(all, 'fileHistory') ? all.fileHistory : undefined;
65
+ const listedOn = listed !== undefined && listed.enumerable === true;
66
+ if (d === undefined || d.enumerable !== true)
67
+ return listedOn ? 'unknown' : 'not_sent';
68
+ if (!Object.hasOwn(d, 'value') || !listedOn || !Object.hasOwn(listed, 'value') || !Object.is(listed.value, d.value))
69
+ return 'unknown';
70
+ if (!Object.is(body.fileHistory, d.value))
71
+ return 'unknown';
72
+ if (typeof d.value === 'object' && d.value !== null)
73
+ return 'unknown';
74
+ return d.value === FILE_HISTORY_DISABLED ? 'sent' : 'not_sent';
75
+ }
76
+ catch {
77
+ return 'unknown';
78
+ }
79
+ }
80
+ const idOk = (v) => typeof v === 'string' && v.length > 0;
81
+ export function createFileHistoryDeclarationLedger() {
82
+ const factsByKey = new Map();
83
+ const keysByRun = new Map();
84
+ return Object.freeze({
85
+ declared(requestKey, fact) {
86
+ if (!idOk(requestKey) || (fact !== 'sent' && fact !== 'not_sent'))
87
+ return false;
88
+ let set = factsByKey.get(requestKey);
89
+ if (set === undefined)
90
+ factsByKey.set(requestKey, (set = new Set()));
91
+ set.add(fact);
92
+ return true;
93
+ },
94
+ boundToRun(requestKey, runId, event) {
95
+ if (!idOk(requestKey) || !idOk(runId) || !frameProvesDelivery(event))
96
+ return false;
97
+ let set = keysByRun.get(runId);
98
+ if (set === undefined)
99
+ keysByRun.set(runId, (set = new Set()));
100
+ set.add(requestKey);
101
+ return true;
102
+ },
103
+ declarationOf(runId) {
104
+ if (!idOk(runId))
105
+ return 'unknown';
106
+ const keys = keysByRun.get(runId);
107
+ if (keys === undefined)
108
+ return 'unknown';
109
+ let agreed;
110
+ for (const k of keys) {
111
+ const facts = factsByKey.get(k);
112
+ if (facts === undefined || facts.size !== 1)
113
+ return 'unknown';
114
+ const [only] = facts;
115
+ if (only === undefined || (agreed !== undefined && agreed !== only))
116
+ return 'unknown';
117
+ agreed = only;
118
+ }
119
+ return agreed ?? 'unknown';
120
+ },
121
+ });
122
+ }
@@ -40,7 +40,7 @@ export interface SettlementWhoView {
40
40
  approver?: string;
41
41
  window?: string;
42
42
  }
43
- export declare const SETTLEMENT_KIND_WORDS: readonly ["human_allowed", "human_refused", "approval_window_expired", "denial_limit_window_expired", "park_sla_expired", "no_approver", "approver_unavailable", "approver_error", "approver_contract", "presentation_failed", "blanket_allow_refused", "policy_refused", "task_aborted"];
43
+ export declare const SETTLEMENT_KIND_WORDS: readonly ["human_allowed", "human_refused", "approval_window_expired", "denial_limit_window_expired", "park_sla_expired", "no_approver", "approver_unavailable", "approver_error", "approver_contract", "presentation_failed", "blanket_allow_refused", "policy_allowed", "policy_refused", "task_aborted"];
44
44
  export interface SettlementView {
45
45
  kind: Settlement['kind'] | (string & {});
46
46
  who: SettlementWhoView;
@@ -20,6 +20,7 @@ export const SETTLEMENT_KIND_WORDS = Object.freeze([
20
20
  'approver_contract',
21
21
  'presentation_failed',
22
22
  'blanket_allow_refused',
23
+ 'policy_allowed',
23
24
  'policy_refused',
24
25
  'task_aborted',
25
26
  ]);
@@ -9,3 +9,16 @@ export declare const CORE_PERMISSION_MODE_FOLD_REASONS: readonly string[];
9
9
  export declare const CORE_ENGINE_CARD_TYPES: readonly string[];
10
10
  export declare const CORE_TOOL_DECLARATION_CODES: readonly string[];
11
11
  export declare const CORE_MODE_RELEASE_REASONS: readonly ["rule_unreadable"];
12
+ export declare const CORE_HOOK_TOOL_ALIASES: Readonly<Record<string, string>>;
13
+ export declare const CORE_ASK_EVIDENCE_ABSENCE_VALUES: readonly ["not_wired", "not_adjudicated", "unavailable", "no_match", "not_reported"];
14
+ export declare const CORE_SYSTEM_INJECTION_PRIORITIES: readonly ["now", "next", "later"];
15
+ export declare const CORE_READ_DENY_BUILTIN_TIERS: readonly ["credentials", "shell-history", "browser", "wallet", "agent-config"];
16
+ export declare const CORE_READ_DENY_DEFAULT_TIERS: readonly ["credentials", "agent-config"];
17
+ export interface CoreModeArbitrationRow {
18
+ readonly bypassImmune: boolean;
19
+ readonly classifierEligible: boolean;
20
+ readonly sandboxAdmission: boolean;
21
+ readonly ruleMayClear: boolean;
22
+ readonly hookAskFloor: boolean;
23
+ }
24
+ export declare const CORE_MODE_ARBITRATION: Readonly<Record<"content_question" | "hook" | "ancestor" | "unverifiable_delete" | "transcript_write" | "org_rule" | "governance_unavailable" | "rule_unreadable" | "ask_rule" | "denial_limit_fallback" | "operator_forced" | "shell_floor" | "write_protection_unresolved" | "probe" | "write_protection" | "tool_marks_mcp" | "tool_marks_a2a" | "policy_rra" | "artifact_shared_read" | "mode" | "unstated" | "ordinary", CoreModeArbitrationRow>>;