@genesislcap/ai-assistant 14.494.0 → 14.495.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.
- package/dist/ai-assistant.api.json +12 -3
- package/dist/ai-assistant.d.ts +29 -1
- package/dist/custom-elements.json +265 -189
- package/dist/dts/channel/ai-activity-channel.d.ts +10 -1
- package/dist/dts/channel/ai-activity-channel.d.ts.map +1 -1
- package/dist/dts/components/chat-driver/chat-driver.d.ts +17 -0
- package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
- package/dist/dts/components/chat-driver/chat-driver.test.d.ts.map +1 -1
- package/dist/dts/index.d.ts +1 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/state/debug-event-log.d.ts +8 -12
- package/dist/dts/state/debug-event-log.d.ts.map +1 -1
- package/dist/esm/components/chat-driver/chat-driver.js +51 -13
- package/dist/esm/components/chat-driver/chat-driver.test.js +133 -1
- package/package.json +17 -17
- package/src/channel/ai-activity-channel.ts +9 -1
- package/src/components/chat-driver/chat-driver.test.ts +214 -1
- package/src/components/chat-driver/chat-driver.ts +57 -13
- package/src/index.ts +1 -0
- package/src/state/debug-event-log.ts +9 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-driver.d.ts","sourceRoot":"","sources":["../../../../src/components/chat-driver/chat-driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAGlB,cAAc,EACd,gBAAgB,EAChB,WAAW,EAGX,cAAc,EAKd,yBAAyB,EAEzB,qBAAqB,
|
|
1
|
+
{"version":3,"file":"chat-driver.d.ts","sourceRoot":"","sources":["../../../../src/components/chat-driver/chat-driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAGlB,cAAc,EACd,gBAAgB,EAChB,WAAW,EAGX,cAAc,EAKd,yBAAyB,EAEzB,qBAAqB,EAGtB,MAAM,4BAA4B,CAAC;AAOpC,OAAO,KAA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M,EAAE,GAAG,GAAG,IAAI;IA2DnE;;;;OAIG;IACI,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAInF;;;;;;;OAOG;IACH,OAAO,CAAC,yBAAyB;IASjC;;;OAGG;IACI,WAAW,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI;IAS3C,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAmD/F;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,mBAAmB;IA8F3B;;;;;OAKG;YACW,cAAc;IAoN5B;;;OAGG;IACG,mBAAmB,CAAC,eAAe,CAAC,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAiDrF,wFAAwF;IACxF,OAAO,CAAC,OAAO;IAKf;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAc1B;;;;;;;;;OASG;IACH,OAAO,CAAC,cAAc;IAMtB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IA+BxB,uFAAuF;IACvF,OAAO,CAAC,QAAQ;IAsChB,OAAO,CAAC,aAAa;IAQrB,8EAA8E;IAC9E,OAAO,CAAC,SAAS;IAWjB,mFAAmF;IACnF,OAAO,CAAC,2BAA2B;YAkCrB,WAAW;IAyyBzB,OAAO,CAAC,eAAe;CAoBxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-driver.test.d.ts","sourceRoot":"","sources":["../../../../src/components/chat-driver/chat-driver.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chat-driver.test.d.ts","sourceRoot":"","sources":["../../../../src/components/chat-driver/chat-driver.test.ts"],"names":[],"mappings":"AA4BA,OAAO,uBAAuB,CAAC"}
|
package/dist/dts/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * from './state/persistence';
|
|
|
16
16
|
export * from './provider/ai-provider-switcher';
|
|
17
17
|
export * from './provider/assistant-app-settings';
|
|
18
18
|
export * from './utils/tool-fold';
|
|
19
|
+
export type { TurnFailureReason } from './state/debug-event-log';
|
|
19
20
|
export type { TimelineMessage } from './utils/flatten-sub-agent-messages';
|
|
20
21
|
export type { CostSessionModelEntry, CostSessionRecord } from './utils/cost-session-history';
|
|
21
22
|
export type { ModelTagAppearance } from '@genesislcap/foundation-ai';
|
package/dist/dts/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,YAAY,EAAE,+BAA+B,EAAE,MAAM,gEAAgE,CAAC;AACtH,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mBAAmB,CAAC;AAClC,YAAY,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC7F,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC9E,YAAY,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,YAAY,EAAE,+BAA+B,EAAE,MAAM,gEAAgE,CAAC;AACtH,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mBAAmB,CAAC;AAClC,YAAY,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,YAAY,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC7F,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC9E,YAAY,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC"}
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
*
|
|
24
24
|
* @internal
|
|
25
25
|
*/
|
|
26
|
+
import type { TurnFailureReason } from '@genesislcap/foundation-ai';
|
|
26
27
|
/**
|
|
27
28
|
* Catalogue of meta event names. This is the documented surface — extend it as
|
|
28
29
|
* new events are wired in (Tier 2/3 lifecycle, interaction, provider events).
|
|
@@ -68,19 +69,14 @@ export interface MetaEvent {
|
|
|
68
69
|
export declare function recordMetaEvent(key: string, type: MetaEventType, detail?: Record<string, unknown>): void;
|
|
69
70
|
/**
|
|
70
71
|
* Why a turn failed or was retried — stamped as `detail.reason` on `turn.error`
|
|
71
|
-
* and `turn.retry` events
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* - `unknown-tool-limit` — the model repeatedly called tools it couldn't dispatch,
|
|
78
|
-
* whether hallucinated or stale (real earlier, retired now).
|
|
79
|
-
* - `max-iterations` — the tool loop hit its iteration cap.
|
|
80
|
-
* - `response-truncated` — a turn stopped at the provider's output-token cap with an
|
|
81
|
-
* incomplete tool call; deterministic, so it bails without retry.
|
|
72
|
+
* and `turn.retry` events, and (since PTC-0) surfaced at the driver's loop
|
|
73
|
+
* boundary via {@link ChatDriverResult.failureReason}. Re-exported from
|
|
74
|
+
* `@genesislcap/foundation-ai` — where it lives alongside `ChatDriverResult` so
|
|
75
|
+
* the boundary field and this log surface can never drift apart — under its
|
|
76
|
+
* historical name so existing importers are unaffected. Enumerated so the set
|
|
77
|
+
* stays in sync with the README and call sites can't drift to ad-hoc strings.
|
|
82
78
|
*/
|
|
83
|
-
export type TurnFailureReason
|
|
79
|
+
export type { TurnFailureReason };
|
|
84
80
|
/**
|
|
85
81
|
* Record a turn-ending failure (`turn.error`, importance `high`). The `reason`
|
|
86
82
|
* is typed so the high-importance triage surface stays consistent; pass any
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug-event-log.d.ts","sourceRoot":"","sources":["../../../src/state/debug-event-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;GAGG;AACH,MAAM,MAAM,aAAa,GAErB,qBAAqB,GACrB,wBAAwB,GACxB,kBAAkB,GAClB,iBAAiB,GAEjB,gBAAgB,GAChB,cAAc,GACd,gBAAgB,GAEhB,eAAe,GACf,YAAY,GACZ,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,iBAAiB,GACjB,kBAAkB,GAClB,oBAAoB,GACpB,iBAAiB,GAEjB,eAAe,GACf,cAAc,GACd,gBAAgB,GAChB,mBAAmB,GAEnB,uBAAuB,GACvB,sBAAsB,GAEtB,iBAAiB,GACjB,2BAA2B,GAC3B,mBAAmB,GACnB,mBAAmB,GAEnB,eAAe,GACf,kBAAkB,GAClB,kBAAkB,GAClB,oBAAoB,GAEpB,iBAAiB,GACjB,kBAAkB,GAClB,yBAAyB,GACzB,qBAAqB,GACrB,mBAAmB,GACnB,wBAAwB,GACxB,2BAA2B,GAC3B,sBAAsB,GACtB,4BAA4B,CAAC;AAEjC;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE5D;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,aAAa,EAAE,mBAAmB,CA2C5E,CAAC;AAEF,4CAA4C;AAC5C,MAAM,WAAW,SAAS;IACxB,0FAA0F;IAC1F,KAAK,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,IAAI,EAAE,aAAa,CAAC;IACpB,6EAA6E;IAC7E,UAAU,EAAE,mBAAmB,CAAC;IAChC,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAmBD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,aAAa,EACnB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,IAAI,CAyBN;AAED
|
|
1
|
+
{"version":3,"file":"debug-event-log.d.ts","sourceRoot":"","sources":["../../../src/state/debug-event-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAE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aAAa,EACnB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,IAAI,CAyBN;AAED;;;;;;;;GAQG;AACH,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAElC;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,iBAAiB,EACzB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,IAAI,CAEN;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,iBAAiB,EACzB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,IAAI,CAEN;AAED,qFAAqF;AACrF,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,CAEnE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,SAAS,EAAE,GAAG,IAAI,CA0BrF;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAc7C,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
|
|
@@ -337,6 +337,30 @@ export class ChatDriver extends EventTarget {
|
|
|
337
337
|
}
|
|
338
338
|
return { reason: 'done' };
|
|
339
339
|
}
|
|
340
|
+
/**
|
|
341
|
+
* Build the `done` loop result, carrying the typed failure reason when the turn
|
|
342
|
+
* bailed (PTC-0). The discriminant stays `'done'` either way — the same value a
|
|
343
|
+
* clean turn returns — so consumers matching on `reason === 'done'` are unchanged;
|
|
344
|
+
* `failureReason` is simply present on a failure and absent on success. Omitted
|
|
345
|
+
* (rather than set to `undefined`) so a happy-path result stays byte-identical to
|
|
346
|
+
* the historical `{ reason: 'done' }`.
|
|
347
|
+
*/
|
|
348
|
+
turnDone(failureReason) {
|
|
349
|
+
return failureReason ? { reason: 'done', failureReason } : { reason: 'done' };
|
|
350
|
+
}
|
|
351
|
+
/** The typed failure reason on a loop result, or `undefined` for a clean turn / handoff. */
|
|
352
|
+
static failureReasonOf(result) {
|
|
353
|
+
return result.reason === 'done' ? result.failureReason : undefined;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Build the `tool-loop-end` event detail for a turn's result. A failure carries a
|
|
357
|
+
* `{ failureReason }` detail; a clean turn emits `undefined` — the historical shape,
|
|
358
|
+
* kept byte-identical so subscribers see exactly what they always have.
|
|
359
|
+
*/
|
|
360
|
+
static loopEndDetail(result) {
|
|
361
|
+
const failureReason = ChatDriver.failureReasonOf(result);
|
|
362
|
+
return failureReason ? { failureReason } : undefined;
|
|
363
|
+
}
|
|
340
364
|
/**
|
|
341
365
|
* Swap in a new agent's configuration. Called by OrchestratingDriver before
|
|
342
366
|
* each specialist turn so the shared driver runs with the right tools and prompt.
|
|
@@ -1062,8 +1086,11 @@ export class ChatDriver extends EventTarget {
|
|
|
1062
1086
|
agent: this.activeAgentName,
|
|
1063
1087
|
});
|
|
1064
1088
|
agenticActivityBus.publish('tool-loop-start', undefined);
|
|
1089
|
+
// Captured so the `finally` can carry the turn's outcome onto `tool-loop-end`.
|
|
1090
|
+
let result = { reason: 'done' };
|
|
1065
1091
|
try {
|
|
1066
|
-
|
|
1092
|
+
result = yield this.runToolLoop(userInput, attachments);
|
|
1093
|
+
return result;
|
|
1067
1094
|
}
|
|
1068
1095
|
catch (e) {
|
|
1069
1096
|
logger.error('ChatDriver error:', e);
|
|
@@ -1078,7 +1105,8 @@ export class ChatDriver extends EventTarget {
|
|
|
1078
1105
|
role: 'assistant',
|
|
1079
1106
|
content: 'Sorry, something went wrong on my end. Please try again in a moment.',
|
|
1080
1107
|
});
|
|
1081
|
-
|
|
1108
|
+
result = this.turnDone('exception');
|
|
1109
|
+
return result;
|
|
1082
1110
|
}
|
|
1083
1111
|
finally {
|
|
1084
1112
|
recordMetaEvent(this.sessionKey, 'turn.end', {
|
|
@@ -1088,7 +1116,7 @@ export class ChatDriver extends EventTarget {
|
|
|
1088
1116
|
});
|
|
1089
1117
|
this.busy = false;
|
|
1090
1118
|
this.endTurn();
|
|
1091
|
-
agenticActivityBus.publish('tool-loop-end',
|
|
1119
|
+
agenticActivityBus.publish('tool-loop-end', ChatDriver.loopEndDetail(result));
|
|
1092
1120
|
}
|
|
1093
1121
|
});
|
|
1094
1122
|
}
|
|
@@ -1373,8 +1401,11 @@ export class ChatDriver extends EventTarget {
|
|
|
1373
1401
|
agent: this.activeAgentName,
|
|
1374
1402
|
});
|
|
1375
1403
|
agenticActivityBus.publish('tool-loop-start', undefined);
|
|
1404
|
+
// Captured so the `finally` can carry the turn's outcome onto `tool-loop-end`.
|
|
1405
|
+
let result = { reason: 'done' };
|
|
1376
1406
|
try {
|
|
1377
|
-
|
|
1407
|
+
result = yield this.runToolLoop('', undefined, transientPrimer);
|
|
1408
|
+
return result;
|
|
1378
1409
|
}
|
|
1379
1410
|
catch (e) {
|
|
1380
1411
|
logger.error('ChatDriver error:', e);
|
|
@@ -1389,7 +1420,8 @@ export class ChatDriver extends EventTarget {
|
|
|
1389
1420
|
role: 'assistant',
|
|
1390
1421
|
content: 'Sorry, something went wrong on my end. Please try again in a moment.',
|
|
1391
1422
|
});
|
|
1392
|
-
|
|
1423
|
+
result = this.turnDone('exception');
|
|
1424
|
+
return result;
|
|
1393
1425
|
}
|
|
1394
1426
|
finally {
|
|
1395
1427
|
recordMetaEvent(this.sessionKey, 'turn.end', {
|
|
@@ -1399,7 +1431,7 @@ export class ChatDriver extends EventTarget {
|
|
|
1399
1431
|
});
|
|
1400
1432
|
this.busy = false;
|
|
1401
1433
|
this.endTurn();
|
|
1402
|
-
agenticActivityBus.publish('tool-loop-end',
|
|
1434
|
+
agenticActivityBus.publish('tool-loop-end', ChatDriver.loopEndDetail(result));
|
|
1403
1435
|
}
|
|
1404
1436
|
});
|
|
1405
1437
|
}
|
|
@@ -1784,7 +1816,7 @@ export class ChatDriver extends EventTarget {
|
|
|
1784
1816
|
content: 'While working on your request, I repeatedly called my tools incorrectly. This often works on a second try — would you like me to try again? If it happens again, try breaking your request into smaller steps.',
|
|
1785
1817
|
});
|
|
1786
1818
|
}
|
|
1787
|
-
return
|
|
1819
|
+
return this.turnDone('malformed-function-call');
|
|
1788
1820
|
}
|
|
1789
1821
|
// The response was truncated at the provider's output-token cap while it
|
|
1790
1822
|
// still carried a tool call — its arguments are incomplete and unusable.
|
|
@@ -1813,7 +1845,7 @@ export class ChatDriver extends EventTarget {
|
|
|
1813
1845
|
content: 'My response was cut off because a single step reached the model output limit. This usually means one step tried to produce too much at once — try breaking your request into smaller steps.',
|
|
1814
1846
|
});
|
|
1815
1847
|
}
|
|
1816
|
-
return
|
|
1848
|
+
return this.turnDone('response-truncated');
|
|
1817
1849
|
}
|
|
1818
1850
|
// A request timeout from the transport (tagged `TimeoutError`) is not a
|
|
1819
1851
|
// bug on our end — surface it distinctly instead of letting it fall
|
|
@@ -1839,7 +1871,9 @@ export class ChatDriver extends EventTarget {
|
|
|
1839
1871
|
content: 'The request timed out. You can ask me to try again, or break this into a smaller step.',
|
|
1840
1872
|
});
|
|
1841
1873
|
}
|
|
1842
|
-
|
|
1874
|
+
// Recorded as `exception` above (there is no separate `timeout` member of
|
|
1875
|
+
// TurnFailureReason for the main turn); surface the same reason here.
|
|
1876
|
+
return this.turnDone('exception');
|
|
1843
1877
|
}
|
|
1844
1878
|
// The request was aborted: either a user cancel (turnController) or a
|
|
1845
1879
|
// driver dispose (lifecycleController, chained into the turn). A user
|
|
@@ -1899,7 +1933,7 @@ export class ChatDriver extends EventTarget {
|
|
|
1899
1933
|
content: 'While working on your request, I repeatedly generated a blank response. This often works on a second try — would you like me to try again? If it happens again, try breaking your request into smaller steps.',
|
|
1900
1934
|
});
|
|
1901
1935
|
}
|
|
1902
|
-
return
|
|
1936
|
+
return this.turnDone('empty-response');
|
|
1903
1937
|
}
|
|
1904
1938
|
else {
|
|
1905
1939
|
// Split one model response into separate, individually-toggleable messages so each has its
|
|
@@ -2213,7 +2247,7 @@ export class ChatDriver extends EventTarget {
|
|
|
2213
2247
|
content: "I'm sorry, I repeatedly tried to use tools that aren't available to me, so I couldn't complete that. If a 'Download agent log' option appears in the Settings (cog) menu, you can download the log and share it with whoever set up this assistant to help fix the issue.",
|
|
2214
2248
|
});
|
|
2215
2249
|
}
|
|
2216
|
-
return
|
|
2250
|
+
return this.turnDone('unknown-tool-limit');
|
|
2217
2251
|
}
|
|
2218
2252
|
const firstContinuation = systemCalls[0];
|
|
2219
2253
|
if (firstContinuation) {
|
|
@@ -2223,9 +2257,12 @@ export class ChatDriver extends EventTarget {
|
|
|
2223
2257
|
// Sub-agent early exit — checked here so the exit point mirrors the
|
|
2224
2258
|
// system-call pattern above. Set by completeSubAgent() in a tool handler.
|
|
2225
2259
|
if (this.subAgentCompletion) {
|
|
2226
|
-
return
|
|
2260
|
+
return this.turnDone();
|
|
2227
2261
|
}
|
|
2228
2262
|
}
|
|
2263
|
+
// The loop fell through: either it hit the iteration cap (a failure) or it
|
|
2264
|
+
// broke on a clean final answer (success). Only the former carries a reason.
|
|
2265
|
+
let failureReason;
|
|
2229
2266
|
if (iterations >= this.maxToolIterations) {
|
|
2230
2267
|
logger.warn('ChatDriver: reached max tool iterations, stopping');
|
|
2231
2268
|
recordTurnError(this.sessionKey, 'max-iterations', {
|
|
@@ -2244,8 +2281,9 @@ export class ChatDriver extends EventTarget {
|
|
|
2244
2281
|
content: "I've reached my limit for this response. You can ask me to continue and I'll pick up where I left off.",
|
|
2245
2282
|
});
|
|
2246
2283
|
}
|
|
2284
|
+
failureReason = 'max-iterations';
|
|
2247
2285
|
}
|
|
2248
|
-
return
|
|
2286
|
+
return this.turnDone(failureReason);
|
|
2249
2287
|
});
|
|
2250
2288
|
}
|
|
2251
2289
|
appendToHistory(message) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import { isChatToolCallUnknown } from '@genesislcap/foundation-ai';
|
|
2
|
+
import { isChatToolCallUnknown, MalformedFunctionCallError, ResponseTruncatedError, } from '@genesislcap/foundation-ai';
|
|
3
3
|
import { assert, createLogicSuite } from '@genesislcap/foundation-testing';
|
|
4
4
|
import { agenticActivityBus } from '../../channel/ai-activity-bus';
|
|
5
5
|
import { clearMetaEventRegistry, getMetaEvents } from '../../state/debug-event-log';
|
|
@@ -1621,3 +1621,135 @@ condense('phaseEnd: collapses at endPhase() while the agent keeps running', () =
|
|
|
1621
1621
|
assert.is((_a = events[0].detail) === null || _a === void 0 ? void 0 : _a.trigger, 'phaseEnd');
|
|
1622
1622
|
}));
|
|
1623
1623
|
condense.run();
|
|
1624
|
+
// ---------------------------------------------------------------------------
|
|
1625
|
+
// turn-outcome surfacing (PTC-0) — the typed failure reason must reach BOTH
|
|
1626
|
+
// the loop-boundary result (`ChatDriverResult.failureReason`) and the
|
|
1627
|
+
// `tool-loop-end` activity-bus event detail. Historically every exit flattened
|
|
1628
|
+
// to `{ reason: 'done' }` and the bus detail was `undefined`; these lock the
|
|
1629
|
+
// two seams together, one per `TurnFailureReason`, plus a happy-path compat
|
|
1630
|
+
// check that the legacy shape is byte-unchanged.
|
|
1631
|
+
// ---------------------------------------------------------------------------
|
|
1632
|
+
const outcome = createLogicSuite('ChatDriver turn-outcome surfacing');
|
|
1633
|
+
outcome.after(() => {
|
|
1634
|
+
agenticActivityBus.close();
|
|
1635
|
+
});
|
|
1636
|
+
/**
|
|
1637
|
+
* Subscribe to `tool-loop-end` and expose the most recent detail seen. `fired()` reports
|
|
1638
|
+
* whether the event was seen at all — distinct from `detail()`, which is `undefined` both
|
|
1639
|
+
* when no event fired and when a clean turn fired with the historical `undefined` detail.
|
|
1640
|
+
*/
|
|
1641
|
+
const captureLoopEnd = () => {
|
|
1642
|
+
let last;
|
|
1643
|
+
let seen = false;
|
|
1644
|
+
const stop = agenticActivityBus.subscribe('tool-loop-end', (d) => {
|
|
1645
|
+
last = d;
|
|
1646
|
+
seen = true;
|
|
1647
|
+
});
|
|
1648
|
+
return { detail: () => (seen ? last : undefined), fired: () => seen, stop };
|
|
1649
|
+
};
|
|
1650
|
+
/** A ChatDriver with an explicit (small) tool-iteration cap. */
|
|
1651
|
+
const makeCappedDriver = (config, provider, maxIterations, sessionKey = '') => {
|
|
1652
|
+
const driver = new ChatDriver(makeRegistry(provider), {}, [], undefined, undefined, maxIterations, 5, undefined, sessionKey);
|
|
1653
|
+
driver.applyAgent(config);
|
|
1654
|
+
return driver;
|
|
1655
|
+
};
|
|
1656
|
+
/**
|
|
1657
|
+
* Assert that a turn driven by `provider` surfaces `expected` at BOTH seams.
|
|
1658
|
+
* `driverFor` lets the max-iterations case swap in a low cap.
|
|
1659
|
+
*/
|
|
1660
|
+
const assertSurfacesReason = (label_1, provider_1, expected_1, ...args_1) => __awaiter(void 0, [label_1, provider_1, expected_1, ...args_1], void 0, function* (label, provider, expected, driverFor = (c, p, k) => makeDriver(c, p, k)) {
|
|
1661
|
+
var _a;
|
|
1662
|
+
clearMetaEventRegistry();
|
|
1663
|
+
const sessionKey = `outcome-${label}`;
|
|
1664
|
+
const config = agent({
|
|
1665
|
+
name: 'Static',
|
|
1666
|
+
toolDefinitions: [def('noop')],
|
|
1667
|
+
toolHandlers: { noop: () => __awaiter(void 0, void 0, void 0, function* () { return 'ok'; }) },
|
|
1668
|
+
});
|
|
1669
|
+
const driver = driverFor(config, provider, sessionKey);
|
|
1670
|
+
const cap = captureLoopEnd();
|
|
1671
|
+
const result = yield driver.sendMessage('go');
|
|
1672
|
+
// Seam 1 — the loop-boundary result. Discriminant stays 'done' (compat).
|
|
1673
|
+
assert.is(result.reason, 'done', `[${label}] discriminant stays 'done'`);
|
|
1674
|
+
assert.is(result.reason === 'done' ? result.failureReason : undefined, expected, `[${label}] result.failureReason surfaces the typed reason`);
|
|
1675
|
+
// Seam 2 — the activity-bus tool-loop-end detail.
|
|
1676
|
+
assert.ok(cap.detail(), `[${label}] a tool-loop-end event fired`);
|
|
1677
|
+
assert.is(cap.detail().failureReason, expected, `[${label}] the bus detail carries the same reason`);
|
|
1678
|
+
// Consistency: the debug-log turn.error records the same taxonomy.
|
|
1679
|
+
const err = getMetaEvents(sessionKey).find((e) => e.type === 'turn.error');
|
|
1680
|
+
assert.ok(err, `[${label}] a turn.error is recorded`);
|
|
1681
|
+
assert.is((_a = err.detail) === null || _a === void 0 ? void 0 : _a.reason, expected, `[${label}] the debug-log reason matches`);
|
|
1682
|
+
cap.stop();
|
|
1683
|
+
});
|
|
1684
|
+
/** A provider that returns a MALFORMED_FUNCTION_CALL on every call. */
|
|
1685
|
+
const malformedProvider = () => ({
|
|
1686
|
+
chat: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1687
|
+
throw new MalformedFunctionCallError('bad call');
|
|
1688
|
+
}),
|
|
1689
|
+
});
|
|
1690
|
+
/** A provider that returns an empty response on every call. */
|
|
1691
|
+
const emptyProvider = () => ({
|
|
1692
|
+
chat: () => __awaiter(void 0, void 0, void 0, function* () { return ({ role: 'assistant', content: '' }); }),
|
|
1693
|
+
});
|
|
1694
|
+
/** A provider that throws a ResponseTruncatedError (deterministic, no retry). */
|
|
1695
|
+
const truncatedProvider = () => ({
|
|
1696
|
+
chat: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1697
|
+
throw new ResponseTruncatedError('test-model', 1024, 1024, ['noop']);
|
|
1698
|
+
}),
|
|
1699
|
+
});
|
|
1700
|
+
/** A provider that throws a generic error (the sendMessage catch-all → 'exception'). */
|
|
1701
|
+
const throwingProvider = () => ({
|
|
1702
|
+
chat: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1703
|
+
throw new Error('boom');
|
|
1704
|
+
}),
|
|
1705
|
+
});
|
|
1706
|
+
/** A provider that never stops calling a valid tool (drives the iteration cap). */
|
|
1707
|
+
const neverStopsProvider = () => {
|
|
1708
|
+
let n = 0;
|
|
1709
|
+
return {
|
|
1710
|
+
chat: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1711
|
+
const id = `noop-${n}`;
|
|
1712
|
+
n += 1;
|
|
1713
|
+
return { role: 'assistant', content: '', toolCalls: [{ id, name: 'noop', args: {} }] };
|
|
1714
|
+
}),
|
|
1715
|
+
};
|
|
1716
|
+
};
|
|
1717
|
+
/** A provider that keeps calling a tool with no handler (hallucinated → limit). */
|
|
1718
|
+
const hallucinatedProvider = () => scriptedProvider(Array.from({ length: 6 }, (_u, i) => callsTool('ghost', `ghost-${i}`)));
|
|
1719
|
+
outcome('malformed-function-call surfaces at both seams', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1720
|
+
yield assertSurfacesReason('malformed', malformedProvider(), 'malformed-function-call');
|
|
1721
|
+
}));
|
|
1722
|
+
outcome('empty-response surfaces at both seams', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1723
|
+
yield assertSurfacesReason('empty', emptyProvider(), 'empty-response');
|
|
1724
|
+
}));
|
|
1725
|
+
outcome('response-truncated surfaces at both seams', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1726
|
+
yield assertSurfacesReason('truncated', truncatedProvider(), 'response-truncated');
|
|
1727
|
+
}));
|
|
1728
|
+
outcome('exception surfaces at both seams', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1729
|
+
yield assertSurfacesReason('exception', throwingProvider(), 'exception');
|
|
1730
|
+
}));
|
|
1731
|
+
outcome('unknown-tool-limit surfaces at both seams', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1732
|
+
yield assertSurfacesReason('unknown-tool', hallucinatedProvider(), 'unknown-tool-limit');
|
|
1733
|
+
}));
|
|
1734
|
+
outcome('max-iterations surfaces at both seams', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1735
|
+
yield assertSurfacesReason('max-iter', neverStopsProvider(), 'max-iterations', (c, p, k) => makeCappedDriver(c, p, 2, k));
|
|
1736
|
+
}));
|
|
1737
|
+
outcome('a clean turn leaves the legacy shape byte-unchanged (no failureReason)', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1738
|
+
clearMetaEventRegistry();
|
|
1739
|
+
const config = agent({ name: 'Static' });
|
|
1740
|
+
// Plain-text reply ends the turn cleanly on the first call.
|
|
1741
|
+
const driver = makeDriver(config, scriptedProvider([{ role: 'assistant', content: 'hi' }]), 'outcome-ok');
|
|
1742
|
+
const cap = captureLoopEnd();
|
|
1743
|
+
const result = yield driver.sendMessage('go');
|
|
1744
|
+
// The result is exactly `{ reason: 'done' }` — no `failureReason` key added.
|
|
1745
|
+
assert.equal(result, { reason: 'done' }, 'happy-path result is the historical shape');
|
|
1746
|
+
assert.not.ok('failureReason' in result, 'no failureReason key is present on a clean turn');
|
|
1747
|
+
// The bus event still fires, and its detail is the historical `undefined` — a clean
|
|
1748
|
+
// turn emits no detail object at all (byte-shape compat), not `{ failureReason: undefined }`.
|
|
1749
|
+
assert.ok(cap.fired(), 'a tool-loop-end event fired');
|
|
1750
|
+
assert.is(cap.detail(), undefined, 'a clean turn emits the historical undefined detail');
|
|
1751
|
+
// And no turn.error was recorded.
|
|
1752
|
+
assert.not.ok(getMetaEvents('outcome-ok').some((e) => e.type === 'turn.error'), 'a clean turn records no turn.error');
|
|
1753
|
+
cap.stop();
|
|
1754
|
+
}));
|
|
1755
|
+
outcome.run();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/ai-assistant",
|
|
3
3
|
"description": "Genesis AI Assistant micro-frontend",
|
|
4
|
-
"version": "14.
|
|
4
|
+
"version": "14.495.0",
|
|
5
5
|
"license": "SEE LICENSE IN license.txt",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/ai-assistant.d.ts",
|
|
@@ -64,25 +64,25 @@
|
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@genesislcap/foundation-testing": "14.
|
|
68
|
-
"@genesislcap/genx": "14.
|
|
69
|
-
"@genesislcap/rollup-builder": "14.
|
|
70
|
-
"@genesislcap/ts-builder": "14.
|
|
71
|
-
"@genesislcap/uvu-playwright-builder": "14.
|
|
72
|
-
"@genesislcap/vite-builder": "14.
|
|
73
|
-
"@genesislcap/webpack-builder": "14.
|
|
67
|
+
"@genesislcap/foundation-testing": "14.495.0",
|
|
68
|
+
"@genesislcap/genx": "14.495.0",
|
|
69
|
+
"@genesislcap/rollup-builder": "14.495.0",
|
|
70
|
+
"@genesislcap/ts-builder": "14.495.0",
|
|
71
|
+
"@genesislcap/uvu-playwright-builder": "14.495.0",
|
|
72
|
+
"@genesislcap/vite-builder": "14.495.0",
|
|
73
|
+
"@genesislcap/webpack-builder": "14.495.0",
|
|
74
74
|
"@types/dompurify": "^3.0.5",
|
|
75
75
|
"@types/marked": "^5.0.2"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@genesislcap/foundation-ai": "14.
|
|
79
|
-
"@genesislcap/foundation-logger": "14.
|
|
80
|
-
"@genesislcap/foundation-notifications": "14.
|
|
81
|
-
"@genesislcap/foundation-redux": "14.
|
|
82
|
-
"@genesislcap/foundation-ui": "14.
|
|
83
|
-
"@genesislcap/foundation-utils": "14.
|
|
84
|
-
"@genesislcap/rapid-design-system": "14.
|
|
85
|
-
"@genesislcap/web-core": "14.
|
|
78
|
+
"@genesislcap/foundation-ai": "14.495.0",
|
|
79
|
+
"@genesislcap/foundation-logger": "14.495.0",
|
|
80
|
+
"@genesislcap/foundation-notifications": "14.495.0",
|
|
81
|
+
"@genesislcap/foundation-redux": "14.495.0",
|
|
82
|
+
"@genesislcap/foundation-ui": "14.495.0",
|
|
83
|
+
"@genesislcap/foundation-utils": "14.495.0",
|
|
84
|
+
"@genesislcap/rapid-design-system": "14.495.0",
|
|
85
|
+
"@genesislcap/web-core": "14.495.0",
|
|
86
86
|
"dompurify": "^3.3.1",
|
|
87
87
|
"marked": "^17.0.3"
|
|
88
88
|
},
|
|
@@ -95,5 +95,5 @@
|
|
|
95
95
|
"access": "public"
|
|
96
96
|
},
|
|
97
97
|
"customElements": "dist/custom-elements.json",
|
|
98
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "24d26a75271717d40c0b6168b983bd8536a3db7f"
|
|
99
99
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { TurnFailureReason } from '@genesislcap/foundation-ai';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Event map for the AI activity bus.
|
|
3
5
|
*
|
|
@@ -59,8 +61,14 @@ export interface AgenticActivityEvents {
|
|
|
59
61
|
* spinner animation lifecycle (which can flap mid-turn as tool calls resolve), whereas
|
|
60
62
|
* this event is a one-shot per turn boundary. Use this for hooks tied to a turn ending
|
|
61
63
|
* (telemetry flushes, post-turn workspace transitions, deferred state recomputation).
|
|
64
|
+
*
|
|
65
|
+
* The detail carries the turn's outcome (PTC-0): on a failure it is `{ failureReason }`
|
|
66
|
+
* with the typed `TurnFailureReason`; on a clean completion, a user cancel, a
|
|
67
|
+
* driver dispose, and an agent handoff the detail is `undefined` — the historical shape,
|
|
68
|
+
* kept byte-identical so subscribers that only care about the boundary can keep ignoring
|
|
69
|
+
* it. Structured-cloneable so it survives the cross-tab BroadcastChannel hop.
|
|
62
70
|
*/
|
|
63
|
-
'tool-loop-end': undefined;
|
|
71
|
+
'tool-loop-end': { failureReason?: TurnFailureReason } | undefined;
|
|
64
72
|
/**
|
|
65
73
|
* Fired when a tool handler hands a widget to the user mid-loop and parks awaiting it
|
|
66
74
|
* (`requestInteraction`) — the turn is suspended between provider calls, with no request
|