@sema-agent/client-core 0.83.6 → 0.84.1
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.
- package/CHANGELOG.md +176 -0
- package/README.md +20 -13
- package/dist/abortableSleep.d.ts +10 -0
- package/dist/abortableSleep.js +37 -0
- package/dist/adapt/wireShapes.js +3 -2
- package/dist/adapter/activeRunSelfHeal.js +7 -7
- package/dist/adapter/downstream/eventToSdkMessage.js +6 -2
- package/dist/adapter/downstream/terminalToSdkResult.d.ts +1 -0
- package/dist/adapter/downstream/terminalToSdkResult.js +10 -5
- package/dist/adapter/downstream/wiringManifestView.d.ts +3 -1
- package/dist/adapter/downstream/wiringManifestView.js +1 -0
- package/dist/agentSession/engineAgentRegistryRead.d.ts +18 -0
- package/dist/agentSession/engineAgentRegistryRead.js +167 -0
- package/dist/agentsWireCaps.js +10 -1
- package/dist/attachmentsWireCaps.js +2 -2
- package/dist/controlRouter.js +1 -1
- package/dist/decideFailureNote.d.ts +2 -1
- package/dist/decideFailureNote.js +5 -3
- package/dist/detachWire.d.ts +1 -0
- package/dist/detachWire.js +13 -5
- package/dist/displayUntrusted.js +114 -18
- package/dist/engineAgentAbsence.d.ts +37 -0
- package/dist/engineAgentAbsence.js +142 -0
- package/dist/engineErrorCodes.d.ts +2 -0
- package/dist/engineErrorCodes.js +9 -5
- package/dist/engineNoticeCodes.d.ts +43 -0
- package/dist/engineNoticeCodes.js +118 -5
- package/dist/engineWireSdk.d.ts +2 -0
- package/dist/fleet/fleetProjection.js +3 -2
- package/dist/frozenSet.d.ts +1 -0
- package/dist/frozenSet.js +20 -0
- package/dist/handsSeam.d.ts +3 -0
- package/dist/handsSeam.js +19 -0
- package/dist/hitl/askGateWire.d.ts +1 -1
- package/dist/hitl/askGateWire.js +1 -1
- package/dist/hitl/hitlHostSurface.js +1 -1
- package/dist/hitl/parkResolver.d.ts +1 -0
- package/dist/hitl/parkResolver.js +9 -3
- package/dist/hitl/planReviewWire.d.ts +30 -3
- package/dist/hitl/planReviewWire.js +139 -32
- package/dist/hitl/sessionPolicyDeliverable.d.ts +2 -0
- package/dist/hitl/sessionPolicyDeliverable.js +14 -3
- package/dist/hitl/sessionPolicyWire.d.ts +40 -0
- package/dist/hitl/sessionPolicyWire.js +210 -0
- package/dist/hitl/toolApprovalWire.js +2 -2
- package/dist/index.d.ts +24 -13
- package/dist/index.js +13 -13
- package/dist/liveInitToolFace.js +28 -10
- package/dist/model/catalogLoader.js +3 -3
- package/dist/model/tierVocabulary.js +1 -1
- package/dist/request/taskRequest.js +15 -5
- package/dist/resumeRefusalCopy.d.ts +11 -0
- package/dist/resumeRefusalCopy.js +39 -1
- package/dist/rewindWireCaps.d.ts +0 -1
- package/dist/seam.d.ts +2 -1
- package/dist/seatContract.js +2 -2
- package/dist/systemReminderTag.d.ts +5 -0
- package/dist/systemReminderTag.js +20 -9
- package/dist/toolResult.js +2 -6
- package/dist/toolRoster.d.ts +16 -0
- package/dist/toolRoster.js +46 -5
- package/dist/wireErrorTriage.js +1 -11
- package/dist/workflowClient.js +4 -3
- package/dist/workflowMonitor.d.ts +1 -1
- package/docs/INTEGRATION-CLIENTS.md +701 -37
- package/package.json +3 -3
package/dist/displayUntrusted.js
CHANGED
|
@@ -23,6 +23,10 @@ function pushEdit(edits, src, start, end, text) {
|
|
|
23
23
|
return;
|
|
24
24
|
edits.push({ start: a, end: b, text });
|
|
25
25
|
}
|
|
26
|
+
const UNIT_NONE = 0;
|
|
27
|
+
const UNIT_SEQUENCE = 1;
|
|
28
|
+
const UNIT_SINGLE = 2;
|
|
29
|
+
const NO_UNITS = () => UNIT_NONE;
|
|
26
30
|
function applyEdits(text, edits) {
|
|
27
31
|
if (edits.length === 0)
|
|
28
32
|
return text;
|
|
@@ -48,6 +52,9 @@ class PlainTarget {
|
|
|
48
52
|
this.origin = editedOrigin(this.origin, this.text.length, edits);
|
|
49
53
|
this.text = applyEdits(this.text, edits);
|
|
50
54
|
}
|
|
55
|
+
unitAt() {
|
|
56
|
+
return UNIT_NONE;
|
|
57
|
+
}
|
|
51
58
|
}
|
|
52
59
|
const traced = (text, origin) => (origin === undefined ? { text } : { text, origin });
|
|
53
60
|
function editedOrigin(prev, length, edits) {
|
|
@@ -87,13 +94,19 @@ class TrackedTarget {
|
|
|
87
94
|
src;
|
|
88
95
|
spans = [];
|
|
89
96
|
viewLength;
|
|
90
|
-
|
|
97
|
+
units;
|
|
98
|
+
constructor(text, viewLength, units) {
|
|
91
99
|
this.text = text;
|
|
92
100
|
this.viewLength = viewLength;
|
|
101
|
+
this.units = units;
|
|
93
102
|
this.src = new Int32Array(text.length);
|
|
94
103
|
for (let k = 0; k < text.length; k++)
|
|
95
104
|
this.src[k] = k;
|
|
96
105
|
}
|
|
106
|
+
unitAt(k) {
|
|
107
|
+
const s = this.src[k] ?? -1;
|
|
108
|
+
return s >= 0 && this.units !== undefined ? (this.units[s] ?? UNIT_NONE) : UNIT_NONE;
|
|
109
|
+
}
|
|
97
110
|
rangeStart(k) {
|
|
98
111
|
const s = this.src[k] ?? 0;
|
|
99
112
|
return s >= 0 ? s : (this.spans[2 * (-1 - s)] ?? 0);
|
|
@@ -344,17 +357,20 @@ function markerSpans(text) {
|
|
|
344
357
|
spans.push(hit.index, hit.index + hit[0].length);
|
|
345
358
|
return spans;
|
|
346
359
|
}
|
|
347
|
-
function schemelessUserinfoEdits(text) {
|
|
360
|
+
function schemelessUserinfoEdits(text, unitAt = NO_UNITS) {
|
|
348
361
|
const edits = [];
|
|
349
362
|
const markers = markerSpans(text);
|
|
350
363
|
let m = 0;
|
|
351
364
|
let floor = 0;
|
|
352
|
-
for (let at = text.indexOf('@'); at !== -1; at = text.indexOf('@', at + 1)) {
|
|
353
|
-
|
|
365
|
+
for (let at = text.indexOf('@'), prevAt = -1; at !== -1; prevAt = at, at = text.indexOf('@', at + 1)) {
|
|
366
|
+
let hostEnd = schemelessHostEnd(text, at + 1);
|
|
367
|
+
const hidden = hostEnd === -1;
|
|
368
|
+
if (hidden)
|
|
369
|
+
hostEnd = hiddenHostEnd(text, at + 1, unitAt);
|
|
354
370
|
if (hostEnd === -1)
|
|
355
371
|
continue;
|
|
356
372
|
let runStart = at;
|
|
357
|
-
while (runStart > floor && !breaksUserinfo(text.charCodeAt(runStart - 1)))
|
|
373
|
+
while (runStart > floor && (!breaksUserinfo(text.charCodeAt(runStart - 1)) || (hidden && unitAt(runStart - 1) !== UNIT_NONE)))
|
|
358
374
|
runStart--;
|
|
359
375
|
if (text.charCodeAt(runStart) === 0x3a && runStart > floor && text[runStart - 1] === VIEW_SEPARATOR) {
|
|
360
376
|
while (runStart > floor && text[runStart - 1] === VIEW_SEPARATOR)
|
|
@@ -391,16 +407,63 @@ function schemelessUserinfoEdits(text) {
|
|
|
391
407
|
}
|
|
392
408
|
if (found === -1)
|
|
393
409
|
continue;
|
|
410
|
+
if (hidden && credentialWordAttached(text, prevAt + 1, found, at, unitAt))
|
|
411
|
+
continue;
|
|
394
412
|
pushEdit(edits, text, found, at, REDACTED_USERINFO);
|
|
395
413
|
floor = hostEnd;
|
|
396
414
|
}
|
|
397
415
|
return edits;
|
|
398
416
|
}
|
|
417
|
+
function credentialWordAttached(text, lo, found, at, unitAt) {
|
|
418
|
+
if (credentialWordEndsFrom(text.slice(lo, at), found - lo))
|
|
419
|
+
return true;
|
|
420
|
+
const kept = [];
|
|
421
|
+
let joinedFound = -1;
|
|
422
|
+
for (let k = lo; k < at; k++) {
|
|
423
|
+
if (k === found)
|
|
424
|
+
joinedFound = kept.length;
|
|
425
|
+
if (unitAt(k) === UNIT_NONE)
|
|
426
|
+
kept.push(text.charAt(k));
|
|
427
|
+
}
|
|
428
|
+
return joinedFound !== -1 && credentialWordEndsFrom(kept.join(''), joinedFound);
|
|
429
|
+
}
|
|
430
|
+
function credentialWordEndsFrom(seg, from) {
|
|
431
|
+
for (const word of [SECRET_LABELLED_WORD, SECRET_SCHEME_WORD]) {
|
|
432
|
+
const re = new RegExp(word.source, 'gi');
|
|
433
|
+
for (let hit = re.exec(seg); hit !== null; hit = re.exec(seg)) {
|
|
434
|
+
if (hit.index + hit[0].length >= from)
|
|
435
|
+
return true;
|
|
436
|
+
if (hit[0].length === 0)
|
|
437
|
+
re.lastIndex++;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return false;
|
|
441
|
+
}
|
|
442
|
+
function unitRunEnd(text, from, unitAt) {
|
|
443
|
+
let k = from;
|
|
444
|
+
while (k < text.length && unitAt(k) !== UNIT_NONE)
|
|
445
|
+
k++;
|
|
446
|
+
return k > from ? k : -1;
|
|
447
|
+
}
|
|
448
|
+
function hiddenHostEnd(text, from, unitAt) {
|
|
449
|
+
let k = unitRunEnd(text, from, unitAt);
|
|
450
|
+
if (k === -1)
|
|
451
|
+
return -1;
|
|
452
|
+
if (text.charCodeAt(k) === 0x3a) {
|
|
453
|
+
let d = k + 1;
|
|
454
|
+
while (d < text.length && text.charCodeAt(d) >= 0x30 && text.charCodeAt(d) <= 0x39)
|
|
455
|
+
d++;
|
|
456
|
+
if (d > k + 1)
|
|
457
|
+
k = d;
|
|
458
|
+
}
|
|
459
|
+
const c = text.charCodeAt(k);
|
|
460
|
+
return endsSchemelessHost(c) || c === 0x40 ? k : -1;
|
|
461
|
+
}
|
|
399
462
|
const MAX_URL_WASH_PASSES = 4;
|
|
400
463
|
function washUrlNets(target) {
|
|
401
464
|
for (let pass = 0; pass < MAX_URL_WASH_PASSES; pass++) {
|
|
402
465
|
target.apply(urlTokenEdits(target.text));
|
|
403
|
-
const handedOff = schemelessUserinfoEdits(target.text);
|
|
466
|
+
const handedOff = schemelessUserinfoEdits(target.text, (k) => target.unitAt(k));
|
|
404
467
|
target.apply(handedOff);
|
|
405
468
|
if (handedOff.length === 0)
|
|
406
469
|
return;
|
|
@@ -735,6 +798,24 @@ function exemptAddressEdits(src, from, to, edits) {
|
|
|
735
798
|
function isAddressShaped(value, raw = value) {
|
|
736
799
|
return value.startsWith(`${REDACTED_USERINFO}@`) || ADDRESS_SCHEME_RE.test(raw);
|
|
737
800
|
}
|
|
801
|
+
function gluedToSingleUnit(at, floor, unitAt) {
|
|
802
|
+
for (let k = at - 1; k >= floor; k--) {
|
|
803
|
+
const u = unitAt(k);
|
|
804
|
+
if (u === UNIT_SINGLE)
|
|
805
|
+
return true;
|
|
806
|
+
if (u === UNIT_NONE)
|
|
807
|
+
return false;
|
|
808
|
+
}
|
|
809
|
+
return false;
|
|
810
|
+
}
|
|
811
|
+
function userinfoHostHidden(text, at, unitAt) {
|
|
812
|
+
if (!text.startsWith(REDACTED_USERINFO, at))
|
|
813
|
+
return false;
|
|
814
|
+
let k = at + REDACTED_USERINFO.length;
|
|
815
|
+
while (text[k] === VIEW_SEPARATOR)
|
|
816
|
+
k++;
|
|
817
|
+
return text[k] === '@' && unitRunEnd(text, k + 1, unitAt) !== -1;
|
|
818
|
+
}
|
|
738
819
|
function addressExtentEnd(text, from) {
|
|
739
820
|
let end = from;
|
|
740
821
|
while (end < text.length) {
|
|
@@ -800,7 +881,7 @@ function trailingLabelStart(text, from, end) {
|
|
|
800
881
|
}
|
|
801
882
|
const withoutSeparators = (s) => (s.includes(VIEW_SEPARATOR) ? s.split(VIEW_SEPARATOR).join('') : s);
|
|
802
883
|
const isHorizontalSpace = (ch) => ch === ' ' || ch === '\t' || ch === '\u00a0' || ch === VIEW_SEPARATOR;
|
|
803
|
-
function labelEdits(text, re, literalBlanks = false) {
|
|
884
|
+
function labelEdits(text, re, literalBlanks = false, unitAt = NO_UNITS) {
|
|
804
885
|
const edits = [];
|
|
805
886
|
const schemePass = re === SECRET_SCHEME_WORD;
|
|
806
887
|
const idx = new InnerWordIndex(text);
|
|
@@ -864,6 +945,18 @@ function labelEdits(text, re, literalBlanks = false) {
|
|
|
864
945
|
const trailing = trailingLabelStart(text, v.start, end);
|
|
865
946
|
if (trailing !== -1)
|
|
866
947
|
end = v.start + trailing;
|
|
948
|
+
if (gluedToSingleUnit(v.start, hit.index, unitAt) || userinfoHostHidden(text, v.start, unitAt)) {
|
|
949
|
+
const cut = trailing !== -1 ? end : Math.max(end, v.end);
|
|
950
|
+
const keep = ADDRESS_SCHEME_RE.exec(text.slice(v.start, v.start + 20))?.[0].length ?? 0;
|
|
951
|
+
const q = text.slice(v.start, cut).search(/[?#]/);
|
|
952
|
+
const bodyEnd = q === -1 ? cut : v.start + q;
|
|
953
|
+
if (withoutSeparators(text.slice(v.start + keep, bodyEnd)) !== '')
|
|
954
|
+
pushEdit(edits, text, v.start + keep, bodyEnd, REDACTED_SECRET);
|
|
955
|
+
if (q !== -1 && v.start + q + 1 < cut)
|
|
956
|
+
pushEdit(edits, text, v.start + q + 1, cut, text.charAt(v.start + q) === '#' ? REDACTED_FRAGMENT : REDACTED_QUERY);
|
|
957
|
+
re.lastIndex = cut;
|
|
958
|
+
continue;
|
|
959
|
+
}
|
|
867
960
|
exemptAddressEdits(text, v.start, end, edits);
|
|
868
961
|
re.lastIndex = end;
|
|
869
962
|
continue;
|
|
@@ -1096,9 +1189,10 @@ function proseLiteralEdits(text) {
|
|
|
1096
1189
|
return edits;
|
|
1097
1190
|
}
|
|
1098
1191
|
function washWordNets(target, literalBlanks = false) {
|
|
1192
|
+
const unitAt = (k) => target.unitAt(k);
|
|
1099
1193
|
target.apply(pemEdits(target.text));
|
|
1100
|
-
target.apply(labelEdits(target.text, SECRET_SCHEME_WORD, literalBlanks));
|
|
1101
|
-
target.apply(labelEdits(target.text, SECRET_LABELLED_WORD, literalBlanks));
|
|
1194
|
+
target.apply(labelEdits(target.text, SECRET_SCHEME_WORD, literalBlanks, unitAt));
|
|
1195
|
+
target.apply(labelEdits(target.text, SECRET_LABELLED_WORD, literalBlanks, unitAt));
|
|
1102
1196
|
target.apply(authParamEdits(target.text));
|
|
1103
1197
|
target.apply(proseLiteralEdits(target.text));
|
|
1104
1198
|
}
|
|
@@ -1264,35 +1358,37 @@ function buildCredentialView(text, separated, wordLetters = false, blankTokens =
|
|
|
1264
1358
|
const chars = [];
|
|
1265
1359
|
const starts = [];
|
|
1266
1360
|
const ends = [];
|
|
1361
|
+
const units = [];
|
|
1267
1362
|
let changed = false;
|
|
1268
1363
|
let splitAny = false;
|
|
1269
1364
|
const seq = new SequenceReader(text, blankTokens === 'blank' || blankTokens === 'fold' ? 'all' : blankTokens === 'foldlit' ? 'folded' : 'none', folding);
|
|
1270
|
-
const keep = (ch, s, e) => {
|
|
1365
|
+
const keep = (ch, s, e, unit = UNIT_NONE) => {
|
|
1271
1366
|
chars.push(ch);
|
|
1272
1367
|
starts.push(s);
|
|
1273
1368
|
ends.push(e);
|
|
1369
|
+
units.push(unit);
|
|
1274
1370
|
};
|
|
1275
|
-
const drop = (s, e, placeholder = VIEW_SEPARATOR) => {
|
|
1371
|
+
const drop = (s, e, placeholder = VIEW_SEPARATOR, unit = UNIT_SINGLE) => {
|
|
1276
1372
|
changed = true;
|
|
1277
1373
|
if (separated)
|
|
1278
|
-
keep(placeholder, s, e);
|
|
1374
|
+
keep(placeholder, s, e, unit);
|
|
1279
1375
|
};
|
|
1280
1376
|
const dropUnit = (s, unit) => {
|
|
1281
1377
|
const last = unit.end - 1;
|
|
1282
1378
|
if ((blankTokens === 'literal' || blankTokens === 'foldlit') && last > s && text.charCodeAt(last) === 0x5c && nameBlankTokenAt(text, last) !== -1) {
|
|
1283
|
-
drop(s, last);
|
|
1379
|
+
drop(s, last, VIEW_SEPARATOR, UNIT_SEQUENCE);
|
|
1284
1380
|
keep(text.charAt(last + 1), last, last + 6);
|
|
1285
1381
|
for (let u = 2; u < 6; u++)
|
|
1286
1382
|
keep(text.charAt(last + u), last + 6, last + 6);
|
|
1287
1383
|
return last + 6;
|
|
1288
1384
|
}
|
|
1289
1385
|
if (wordLetters && unit.content === undefined && last > s && (credentialWordBeginsWith(text, last) || finalIsStructural(text, last))) {
|
|
1290
|
-
drop(s, last);
|
|
1386
|
+
drop(s, last, VIEW_SEPARATOR, UNIT_SEQUENCE);
|
|
1291
1387
|
keep(text.charAt(last), last, unit.end);
|
|
1292
1388
|
splitAny = true;
|
|
1293
1389
|
return unit.end;
|
|
1294
1390
|
}
|
|
1295
|
-
drop(s, unit.end);
|
|
1391
|
+
drop(s, unit.end, VIEW_SEPARATOR, UNIT_SEQUENCE);
|
|
1296
1392
|
return unit.end;
|
|
1297
1393
|
};
|
|
1298
1394
|
let i = 0;
|
|
@@ -1326,7 +1422,7 @@ function buildCredentialView(text, separated, wordLetters = false, blankTokens =
|
|
|
1326
1422
|
i = dropUnit(i, unit);
|
|
1327
1423
|
continue;
|
|
1328
1424
|
}
|
|
1329
|
-
drop(i, tok.end, ' ');
|
|
1425
|
+
drop(i, tok.end, ' ', isRegexSpace(tok.cp) && tok.cp !== 0xfeff ? UNIT_NONE : UNIT_SINGLE);
|
|
1330
1426
|
i = tok.end;
|
|
1331
1427
|
continue;
|
|
1332
1428
|
}
|
|
@@ -1373,7 +1469,7 @@ function buildCredentialView(text, separated, wordLetters = false, blankTokens =
|
|
|
1373
1469
|
}
|
|
1374
1470
|
if (!changed || (wordLetters && !splitAny))
|
|
1375
1471
|
return null;
|
|
1376
|
-
return { view: chars.join(''), starts: Int32Array.from(starts), ends: Int32Array.from(ends) };
|
|
1472
|
+
return { view: chars.join(''), starts: Int32Array.from(starts), ends: Int32Array.from(ends), units: Uint8Array.from(units) };
|
|
1377
1473
|
}
|
|
1378
1474
|
function finalIsStructural(text, at) {
|
|
1379
1475
|
if (text.charCodeAt(at) !== 0x5c)
|
|
@@ -1460,7 +1556,7 @@ function rebuildFromView(original, view, target, trace = false) {
|
|
|
1460
1556
|
return origin === null ? { text: rebuilt } : { text: rebuilt, origin: Int32Array.from(origin) };
|
|
1461
1557
|
}
|
|
1462
1558
|
function washThroughView(original, view, urls, words, trace = false, literalBlanks = false) {
|
|
1463
|
-
const target = new TrackedTarget(view.view, view.view.length);
|
|
1559
|
+
const target = new TrackedTarget(view.view, view.view.length, view.units);
|
|
1464
1560
|
runCredentialNets(target, urls, words, literalBlanks);
|
|
1465
1561
|
return target.text === view.view ? { text: original } : rebuildFromView(original, view, target, trace);
|
|
1466
1562
|
}
|
|
@@ -49,4 +49,41 @@ export interface EngineAgentAbsenceReapOptions {
|
|
|
49
49
|
export declare function reapEngineAgentAbsentRows(rows: Readonly<Record<string, EngineAgentAbsenceReapRow | null | undefined>>, opts: EngineAgentAbsenceReapOptions): EngineAgentAbsenceReap;
|
|
50
50
|
export declare function engineAgentAbsenceDroppedLine(label: string, ttlMs?: number, removeReason?: string | null): string;
|
|
51
51
|
export declare function engineAgentTerminalAfterDropLine(label: string, status: RunTerminalStatus, hasReport: boolean): string;
|
|
52
|
+
export interface EngineAgentRegistryRowView {
|
|
53
|
+
readonly id: string;
|
|
54
|
+
readonly type: string;
|
|
55
|
+
readonly status: string;
|
|
56
|
+
readonly description?: string;
|
|
57
|
+
readonly createdAt?: number;
|
|
58
|
+
}
|
|
59
|
+
export type EngineAgentRegistryUnavailableWhy = 'no_list_face' | 'route_absent' | 'ownership_required' | 'read_failed';
|
|
60
|
+
export type EngineAgentRegistryListing = {
|
|
61
|
+
readonly kind: 'rows';
|
|
62
|
+
readonly rows: readonly EngineAgentRegistryRowView[];
|
|
63
|
+
readonly sessionId: string;
|
|
64
|
+
readonly seq: number;
|
|
65
|
+
} | {
|
|
66
|
+
readonly kind: 'unavailable';
|
|
67
|
+
readonly why: EngineAgentRegistryUnavailableWhy;
|
|
68
|
+
readonly status?: number;
|
|
69
|
+
readonly errorCode?: string;
|
|
70
|
+
};
|
|
71
|
+
export declare function engineAgentRegistryKeyOf(ev: Pick<EngineAgentPanelAbsence, 'taskId' | 'wireTaskId'> | null | undefined): string | undefined;
|
|
72
|
+
export interface EngineAgentRegistryReadingOptions {
|
|
73
|
+
readonly singleReplica?: true;
|
|
74
|
+
readonly sessionId?: string;
|
|
75
|
+
}
|
|
76
|
+
export declare function engineAgentRegistryReadingOf(listing: EngineAgentRegistryListing | null | undefined, registryKey: string | null | undefined, opts?: EngineAgentRegistryReadingOptions | null): EngineAgentRegistryReading;
|
|
77
|
+
export interface EngineAgentRegistryMissingRow {
|
|
78
|
+
readonly id: string;
|
|
79
|
+
readonly status: string;
|
|
80
|
+
readonly description?: string;
|
|
81
|
+
readonly createdAt: number;
|
|
82
|
+
}
|
|
83
|
+
export interface EngineAgentRegistryFillOptions {
|
|
84
|
+
readonly nowMs?: number;
|
|
85
|
+
readonly goneSinceRead?: ReadonlySet<string> | readonly string[];
|
|
86
|
+
readonly sessionId?: string;
|
|
87
|
+
}
|
|
88
|
+
export declare function engineAgentRegistryRowsMissingFromHost(listing: EngineAgentRegistryListing | null | undefined, hostRegistryKeys: ReadonlySet<string> | readonly string[], opts?: EngineAgentRegistryFillOptions | null): readonly EngineAgentRegistryMissingRow[];
|
|
52
89
|
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { registryClockNowMs, registryListingProvenanceOf } from './agentSession/engineAgentRegistryRead.js';
|
|
1
2
|
import { displayUntrusted } from './displayUntrusted.js';
|
|
3
|
+
import { ABSENT_SETTLE_MS } from './fleetAgentPanelProjection.js';
|
|
2
4
|
import { isEnginePanelTaskResident, isStaleEngineAgentPanelEnd, } from './engineAgentPanelStore.js';
|
|
3
5
|
export const ENGINE_AGENT_ABSENT_ROW_TEXT = 'engine no longer reports this agent · it may still be running';
|
|
4
6
|
export const ENGINE_AGENT_ABSENCE_TTL_MS = 30 * 60_000;
|
|
@@ -129,3 +131,143 @@ export function engineAgentTerminalAfterDropLine(label, status, hasReport) {
|
|
|
129
131
|
const tail = hasReport ? ' · its final report arrived too late to keep in the panel' : '';
|
|
130
132
|
return `${displayUntrusted(label)} reported ${displayUntrusted(status)} after it was dropped from the task panel${tail}`;
|
|
131
133
|
}
|
|
134
|
+
const REGISTRY_LIST_LIMIT = 500;
|
|
135
|
+
const REGISTRY_AGENT_HANDLE_RE = /^a[0-9a-f]{6,32}$/;
|
|
136
|
+
const REGISTRY_AGENT_TYPE = 'background_agent';
|
|
137
|
+
function registryStatusReading(status) {
|
|
138
|
+
const s = status;
|
|
139
|
+
switch (s) {
|
|
140
|
+
case 'pending':
|
|
141
|
+
case 'running':
|
|
142
|
+
case 'parked':
|
|
143
|
+
return 'running';
|
|
144
|
+
case 'completed':
|
|
145
|
+
case 'failed':
|
|
146
|
+
case 'killed':
|
|
147
|
+
case 'cancelled':
|
|
148
|
+
return 'ended';
|
|
149
|
+
default: {
|
|
150
|
+
const unhandled = s;
|
|
151
|
+
void unhandled;
|
|
152
|
+
return 'unknown';
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
export function engineAgentRegistryKeyOf(ev) {
|
|
157
|
+
if (typeof ev !== 'object' || ev === null)
|
|
158
|
+
return undefined;
|
|
159
|
+
const w = ev.wireTaskId;
|
|
160
|
+
const t = ev.taskId;
|
|
161
|
+
const wire = typeof w === 'string' && w.length > 0 ? w : undefined;
|
|
162
|
+
const task = typeof t === 'string' && t.length > 0 ? t : undefined;
|
|
163
|
+
if (wire !== undefined && REGISTRY_AGENT_HANDLE_RE.test(wire))
|
|
164
|
+
return wire;
|
|
165
|
+
if (task !== undefined && REGISTRY_AGENT_HANDLE_RE.test(task))
|
|
166
|
+
return task;
|
|
167
|
+
return wire ?? task;
|
|
168
|
+
}
|
|
169
|
+
function ownOpt(opts, key) {
|
|
170
|
+
if (typeof opts !== 'object' || opts === null || !Object.hasOwn(opts, key))
|
|
171
|
+
return { given: false, value: undefined };
|
|
172
|
+
const value = opts[key];
|
|
173
|
+
return { given: value !== undefined, value };
|
|
174
|
+
}
|
|
175
|
+
function sessionMismatch(readSessionId, opts) {
|
|
176
|
+
const { given, value } = ownOpt(opts, 'sessionId');
|
|
177
|
+
if (!given)
|
|
178
|
+
return false;
|
|
179
|
+
return typeof value !== 'string' || value.length === 0 || readSessionId !== value;
|
|
180
|
+
}
|
|
181
|
+
export function engineAgentRegistryReadingOf(listing, registryKey, opts) {
|
|
182
|
+
try {
|
|
183
|
+
return readingOf(listing, registryKey, opts);
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
return 'unknown';
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function readingOf(listing, registryKey, opts) {
|
|
190
|
+
const rec = registryListingProvenanceOf(listing);
|
|
191
|
+
if (rec === undefined || rec.superseded)
|
|
192
|
+
return 'unknown';
|
|
193
|
+
if (sessionMismatch(rec.sessionId, opts))
|
|
194
|
+
return 'unknown';
|
|
195
|
+
return readingFromRecord(rec, registryKey, opts);
|
|
196
|
+
}
|
|
197
|
+
function readingFromRecord(rec, registryKey, opts) {
|
|
198
|
+
if (typeof registryKey !== 'string' || registryKey.length === 0)
|
|
199
|
+
return 'unknown';
|
|
200
|
+
let reading;
|
|
201
|
+
for (const r of rec.rows) {
|
|
202
|
+
if (r.id !== registryKey)
|
|
203
|
+
continue;
|
|
204
|
+
const here = r.type === REGISTRY_AGENT_TYPE ? registryStatusReading(r.status) : 'unknown';
|
|
205
|
+
reading = reading === undefined || reading === here ? here : 'unknown';
|
|
206
|
+
}
|
|
207
|
+
if (reading !== undefined)
|
|
208
|
+
return reading;
|
|
209
|
+
if (rec.rawRowCount >= REGISTRY_LIST_LIMIT)
|
|
210
|
+
return 'unknown';
|
|
211
|
+
if (!ownOpt(opts, 'sessionId').given)
|
|
212
|
+
return 'unknown';
|
|
213
|
+
const single = ownOpt(opts, 'singleReplica');
|
|
214
|
+
return single.given && single.value === true && REGISTRY_AGENT_HANDLE_RE.test(registryKey) ? 'not_listed' : 'unknown';
|
|
215
|
+
}
|
|
216
|
+
function keySetOf(v) {
|
|
217
|
+
if (v instanceof Set)
|
|
218
|
+
return (k) => v.has(k);
|
|
219
|
+
if (Array.isArray(v))
|
|
220
|
+
return (k) => v.includes(k);
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
export function engineAgentRegistryRowsMissingFromHost(listing, hostRegistryKeys, opts) {
|
|
224
|
+
try {
|
|
225
|
+
return rowsMissingFromHost(listing, hostRegistryKeys, opts);
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
return [];
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function rowsMissingFromHost(listing, hostRegistryKeys, opts) {
|
|
232
|
+
const rec = registryListingProvenanceOf(listing);
|
|
233
|
+
if (rec === undefined || rec.superseded)
|
|
234
|
+
return [];
|
|
235
|
+
if (sessionMismatch(rec.sessionId, opts))
|
|
236
|
+
return [];
|
|
237
|
+
const has = keySetOf(hostRegistryKeys);
|
|
238
|
+
if (has === undefined)
|
|
239
|
+
return [];
|
|
240
|
+
const goneOpt = ownOpt(opts, 'goneSinceRead');
|
|
241
|
+
const gone = goneOpt.given ? keySetOf(goneOpt.value) : () => false;
|
|
242
|
+
if (gone === undefined)
|
|
243
|
+
return [];
|
|
244
|
+
const nowOpt = ownOpt(opts, 'nowMs');
|
|
245
|
+
const now = nowOpt.given ? nowOpt.value : registryClockNowMs();
|
|
246
|
+
if (typeof now !== 'number' || !Number.isFinite(now))
|
|
247
|
+
return [];
|
|
248
|
+
const out = [];
|
|
249
|
+
const seen = new Set();
|
|
250
|
+
for (const r of rec.rows) {
|
|
251
|
+
if (r.type !== REGISTRY_AGENT_TYPE)
|
|
252
|
+
continue;
|
|
253
|
+
if (seen.has(r.id))
|
|
254
|
+
continue;
|
|
255
|
+
if (readingFromRecord(rec, r.id, undefined) !== 'running')
|
|
256
|
+
continue;
|
|
257
|
+
seen.add(r.id);
|
|
258
|
+
if (has(r.id) || gone(r.id))
|
|
259
|
+
continue;
|
|
260
|
+
const firstSeen = rec.firstSeenAtMs(r.id);
|
|
261
|
+
if (firstSeen === undefined || now - firstSeen <= ABSENT_SETTLE_MS)
|
|
262
|
+
continue;
|
|
263
|
+
if (typeof r.createdAt !== 'number' || !Number.isFinite(r.createdAt))
|
|
264
|
+
continue;
|
|
265
|
+
out.push({
|
|
266
|
+
id: r.id,
|
|
267
|
+
status: r.status,
|
|
268
|
+
...(typeof r.description === 'string' && r.description.length > 0 ? { description: r.description } : {}),
|
|
269
|
+
createdAt: r.createdAt,
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
return out;
|
|
273
|
+
}
|
|
@@ -12,6 +12,7 @@ export declare const CONFIG_LIMIT_UNKNOWN_KEY = "config.limit_unknown_key";
|
|
|
12
12
|
export declare const CONFIG_DELEGATION_ENTRY_CAPS = "config.delegation_entry_caps";
|
|
13
13
|
export declare const CONFIG_MEMORY_PROJECT_KEY_SPELLING = "config.memory_project_key_spelling";
|
|
14
14
|
export declare const CONFIG_MEMORY_WRITE_SCOPE_MISMATCH = "config.memory_write_scope_mismatch";
|
|
15
|
+
export declare const CONFIG_LEGACY_TOOL_NAME = "config.legacy_tool_name";
|
|
15
16
|
export declare const CONFIG_REFUSAL_CODES: ReadonlySet<string>;
|
|
16
17
|
export declare const DELEGATION_CONCURRENCY_CAP = "delegation.concurrency_cap";
|
|
17
18
|
export declare const DELEGATION_SESSION_CAP = "delegation.session_cap";
|
|
@@ -47,6 +48,7 @@ export declare const RESUME_ENV_FAILED = "resume.env_failed";
|
|
|
47
48
|
export declare const RESUME_TOOL_UNAVAILABLE = "resume.tool_unavailable";
|
|
48
49
|
export declare const RESUME_TOOL_CONTRACT_MISMATCH = "resume.tool_contract_mismatch";
|
|
49
50
|
export declare const RESUME_REOPEN_CODES: readonly string[];
|
|
51
|
+
export declare const PARKED_RESUME_STARTUP_FAILED = "parked_resume.startup_failed";
|
|
50
52
|
export declare const DECIDE_WORKFLOW_HOST_UNKNOWN = "decide.workflow_host_unknown";
|
|
51
53
|
export declare const DECIDE_WORKFLOW_REMEMBER_UNSUPPORTED = "decide.workflow_remember_unsupported";
|
|
52
54
|
export declare const DECIDE_WORKFLOW_LANE_CODES: readonly string[];
|
package/dist/engineErrorCodes.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { frozenSet } from './frozenSet.js';
|
|
1
2
|
export const LIMITS_MAX_TOKENS_EXCEEDED = 'limits.max_tokens_exceeded';
|
|
2
3
|
export const LIMITS_MAX_COST_EXCEEDED = 'limits.max_cost_exceeded';
|
|
3
4
|
export const LIMITS_MAX_TURNS_EXCEEDED = 'limits.max_turns_exceeded';
|
|
@@ -15,7 +16,8 @@ export const CONFIG_LIMIT_UNKNOWN_KEY = 'config.limit_unknown_key';
|
|
|
15
16
|
export const CONFIG_DELEGATION_ENTRY_CAPS = 'config.delegation_entry_caps';
|
|
16
17
|
export const CONFIG_MEMORY_PROJECT_KEY_SPELLING = 'config.memory_project_key_spelling';
|
|
17
18
|
export const CONFIG_MEMORY_WRITE_SCOPE_MISMATCH = 'config.memory_write_scope_mismatch';
|
|
18
|
-
export const
|
|
19
|
+
export const CONFIG_LEGACY_TOOL_NAME = 'config.legacy_tool_name';
|
|
20
|
+
export const CONFIG_REFUSAL_CODES = frozenSet([
|
|
19
21
|
CONFIG_LIMIT_INVALID,
|
|
20
22
|
CONFIG_STRATEGY_FIND_LIMIT_INVALID,
|
|
21
23
|
CONFIG_STRATEGY_MAX_SIZE_INVALID,
|
|
@@ -23,10 +25,11 @@ export const CONFIG_REFUSAL_CODES = new Set([
|
|
|
23
25
|
CONFIG_DELEGATION_ENTRY_CAPS,
|
|
24
26
|
CONFIG_MEMORY_PROJECT_KEY_SPELLING,
|
|
25
27
|
CONFIG_MEMORY_WRITE_SCOPE_MISMATCH,
|
|
28
|
+
CONFIG_LEGACY_TOOL_NAME,
|
|
26
29
|
]);
|
|
27
30
|
export const DELEGATION_CONCURRENCY_CAP = 'delegation.concurrency_cap';
|
|
28
31
|
export const DELEGATION_SESSION_CAP = 'delegation.session_cap';
|
|
29
|
-
export const DELEGATION_CAP_CODES =
|
|
32
|
+
export const DELEGATION_CAP_CODES = frozenSet([
|
|
30
33
|
DELEGATION_CONCURRENCY_CAP,
|
|
31
34
|
DELEGATION_SESSION_CAP,
|
|
32
35
|
]);
|
|
@@ -61,17 +64,17 @@ export const STOP_PARK_RESUME_WON = 'stop.park_resume_won';
|
|
|
61
64
|
export const STOP_NOT_LANDED = 'stop.not_landed';
|
|
62
65
|
export const STOP_NOT_LOCAL = 'stop.not_local';
|
|
63
66
|
export const STOP_PARKED = 'stop.parked';
|
|
64
|
-
export const STOP_CONFLICT_CODES = [
|
|
67
|
+
export const STOP_CONFLICT_CODES = Object.freeze([
|
|
65
68
|
STOP_PARK_ARBITER_UNREACHABLE,
|
|
66
69
|
STOP_PARK_RESUME_WON,
|
|
67
70
|
STOP_NOT_LANDED,
|
|
68
71
|
STOP_NOT_LOCAL,
|
|
69
72
|
STOP_PARKED,
|
|
70
|
-
];
|
|
73
|
+
]);
|
|
71
74
|
export const OUTPUT_INVALID = 'output.invalid';
|
|
72
75
|
export const RESUME_POLICY_FOLD_CODE = 'resume_blocked_by_policy';
|
|
73
76
|
export const RESUME_AT_ERROR_CODE_PREFIX = 'resume_at.';
|
|
74
|
-
export const REWIND_ERROR_CODE_PREFIXES = [RESUME_AT_ERROR_CODE_PREFIX, 'rewind_snapshot.'];
|
|
77
|
+
export const REWIND_ERROR_CODE_PREFIXES = Object.freeze([RESUME_AT_ERROR_CODE_PREFIX, 'rewind_snapshot.']);
|
|
75
78
|
export function isRewindFamilyCode(code) {
|
|
76
79
|
return typeof code === 'string' && REWIND_ERROR_CODE_PREFIXES.some((p) => code.startsWith(p));
|
|
77
80
|
}
|
|
@@ -91,6 +94,7 @@ export const RESUME_REOPEN_CODES = Object.freeze([
|
|
|
91
94
|
RESUME_TOOL_UNAVAILABLE,
|
|
92
95
|
RESUME_TOOL_CONTRACT_MISMATCH,
|
|
93
96
|
]);
|
|
97
|
+
export const PARKED_RESUME_STARTUP_FAILED = 'parked_resume.startup_failed';
|
|
94
98
|
export const DECIDE_WORKFLOW_HOST_UNKNOWN = 'decide.workflow_host_unknown';
|
|
95
99
|
export const DECIDE_WORKFLOW_REMEMBER_UNSUPPORTED = 'decide.workflow_remember_unsupported';
|
|
96
100
|
export const DECIDE_WORKFLOW_LANE_CODES = Object.freeze([
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type NoticeAudience = 'user' | 'operator';
|
|
2
2
|
export declare const ENGINE_NOTICE_CODES: readonly string[];
|
|
3
|
+
export declare const SERVER_NOTICE_AUDIENCE: Readonly<Record<string, NoticeAudience>>;
|
|
3
4
|
export declare function engineNoticeInCatalog(code: unknown): boolean;
|
|
4
5
|
export declare const ENGINE_NOTICE_AUDIENCE: Readonly<Record<string, NoticeAudience>>;
|
|
5
6
|
export declare function noticeAudienceOf(code: unknown): NoticeAudience;
|
|
@@ -52,3 +53,45 @@ export interface McpServerRedialedFactsView {
|
|
|
52
53
|
runId: string;
|
|
53
54
|
}
|
|
54
55
|
export declare function readMcpServerRedialed(notice: unknown): McpServerRedialedFactsView | undefined;
|
|
56
|
+
export type ReadRootGrantNoticeFactsView = {
|
|
57
|
+
outcome: 'granted';
|
|
58
|
+
toolCallId: string;
|
|
59
|
+
dir: string;
|
|
60
|
+
root: string;
|
|
61
|
+
covers?: 'exact';
|
|
62
|
+
sessionId?: string;
|
|
63
|
+
} | {
|
|
64
|
+
outcome: 'rejected';
|
|
65
|
+
toolCallId: string;
|
|
66
|
+
reason?: string;
|
|
67
|
+
sessionId?: string;
|
|
68
|
+
};
|
|
69
|
+
export declare function readReadRootGrantNotice(notice: unknown): ReadRootGrantNoticeFactsView | undefined;
|
|
70
|
+
export interface InstructionsSourceChangedFactsView {
|
|
71
|
+
previous: string | null;
|
|
72
|
+
current: string | null;
|
|
73
|
+
sessionId: string;
|
|
74
|
+
}
|
|
75
|
+
export declare function readInstructionsSourceChanged(notice: unknown): InstructionsSourceChangedFactsView | undefined;
|
|
76
|
+
export declare const ENGINE_NOTICE_FACT_READERS: Readonly<{
|
|
77
|
+
readonly 'mcp.injection_dropped': typeof readMcpInjectionDrop;
|
|
78
|
+
readonly 'delegation.ask_unresolvable': typeof readAskUnresolvable;
|
|
79
|
+
readonly 'config.durable_gate_unavailable': typeof readDurableGateUnavailable;
|
|
80
|
+
readonly 'skills.listing_truncated': typeof readSkillsListingTruncated;
|
|
81
|
+
readonly 'mcp.server_redialed': typeof readMcpServerRedialed;
|
|
82
|
+
readonly 'instructions.source_changed': typeof readInstructionsSourceChanged;
|
|
83
|
+
readonly 'approval.read_root_granted': typeof readReadRootGrantNotice;
|
|
84
|
+
readonly 'approval.read_root_grant_rejected': typeof readReadRootGrantNotice;
|
|
85
|
+
}>;
|
|
86
|
+
type FactReaderTable = typeof ENGINE_NOTICE_FACT_READERS;
|
|
87
|
+
export type EngineNoticeFactsCode = keyof FactReaderTable;
|
|
88
|
+
export interface EngineNoticeFactsOf<K extends EngineNoticeFactsCode> {
|
|
89
|
+
code: K;
|
|
90
|
+
audience: NoticeAudience;
|
|
91
|
+
facts: Exclude<ReturnType<FactReaderTable[K]>, undefined>;
|
|
92
|
+
}
|
|
93
|
+
export type EngineNoticeFacts = {
|
|
94
|
+
[K in EngineNoticeFactsCode]: EngineNoticeFactsOf<K>;
|
|
95
|
+
}[EngineNoticeFactsCode];
|
|
96
|
+
export declare function readEngineNoticeFacts(notice: unknown): EngineNoticeFacts | undefined;
|
|
97
|
+
export {};
|