@genesislcap/ai-assistant 15.43.0 → 15.45.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 +34 -19
- package/dist/ai-assistant.d.ts +36 -2
- package/dist/chat-driver.cjs +89 -10
- package/dist/chat-driver.cjs.map +2 -2
- package/dist/chat-driver.mjs +89 -10
- package/dist/chat-driver.mjs.map +2 -2
- package/dist/custom-elements.json +466 -285
- package/dist/dts/components/chat-driver/chat-driver.d.ts +15 -2
- package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
- package/dist/dts/components/chat-driver/interaction-controller.d.ts +26 -3
- package/dist/dts/components/chat-driver/interaction-controller.d.ts.map +1 -1
- package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.d.ts +6 -0
- package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.d.ts.map +1 -1
- package/dist/dts/genesis/config.d.ts +28 -1
- package/dist/dts/genesis/config.d.ts.map +1 -1
- package/dist/dts/genesis/consumes.d.ts.map +1 -1
- package/dist/dts/genesis/index.d.ts +2 -1
- package/dist/dts/genesis/index.d.ts.map +1 -1
- package/dist/dts/genesis/register-genesis-assistant.d.ts.map +1 -1
- package/dist/dts/genesis/review-model.d.ts +72 -1
- package/dist/dts/genesis/review-model.d.ts.map +1 -1
- package/dist/dts/genesis/types.d.ts +32 -0
- package/dist/dts/genesis/types.d.ts.map +1 -1
- package/dist/dts/genesis/write-review/write-review.d.ts +22 -1
- package/dist/dts/genesis/write-review/write-review.d.ts.map +1 -1
- package/dist/dts/genesis/write-review/write-review.styles.d.ts.map +1 -1
- package/dist/dts/genesis/write-review/write-review.template.d.ts.map +1 -1
- package/dist/dts/genesis/write-tools.d.ts +6 -1
- package/dist/dts/genesis/write-tools.d.ts.map +1 -1
- package/dist/dts/main/main.template.d.ts +8 -0
- package/dist/dts/main/main.template.d.ts.map +1 -1
- package/dist/dts/state/debug-event-log.d.ts +1 -1
- package/dist/dts/state/debug-event-log.d.ts.map +1 -1
- package/dist/dts/types/ai-chat-widget.d.ts +7 -0
- package/dist/dts/types/ai-chat-widget.d.ts.map +1 -1
- package/dist/esm/components/chat-driver/chat-driver.js +39 -6
- package/dist/esm/components/chat-driver/interaction-controller.js +50 -4
- package/dist/esm/components/chat-interaction-wrapper/chat-interaction-wrapper.js +17 -6
- package/dist/esm/genesis/config.js +108 -7
- package/dist/esm/genesis/consumes.js +8 -1
- package/dist/esm/genesis/index.js +1 -0
- package/dist/esm/genesis/register-genesis-assistant.js +7 -0
- package/dist/esm/genesis/review-model.js +115 -7
- package/dist/esm/genesis/write-review/write-review.js +80 -19
- package/dist/esm/genesis/write-review/write-review.styles.js +5 -2
- package/dist/esm/genesis/write-review/write-review.template.js +19 -2
- package/dist/esm/genesis/write-tools.js +49 -13
- package/dist/esm/main/main.template.js +19 -10
- package/dist/esm/state/debug-event-log.js +4 -0
- package/dist/genesis-consumes.cjs +8 -1
- package/dist/genesis-consumes.cjs.map +2 -2
- package/dist/genesis-consumes.mjs +8 -1
- package/dist/genesis-consumes.mjs.map +2 -2
- package/docs/genesis.md +60 -2
- package/package.json +18 -18
- package/scripts/smoke-genesis-consumes-node.mjs +1 -1
package/dist/chat-driver.mjs
CHANGED
|
@@ -3950,6 +3950,10 @@ var META_EVENT_IMPORTANCE = {
|
|
|
3950
3950
|
// the value was not real spend). 'high': it is the one way the session total goes quietly
|
|
3951
3951
|
// wrong, so it must stand out when reconciling.
|
|
3952
3952
|
"interaction.external-cost-dropped": "high",
|
|
3953
|
+
// What came of an answer, recorded by the tool that asked (see recordInteractionOutcome).
|
|
3954
|
+
"interaction.outcome": "normal",
|
|
3955
|
+
// An outcome that could not be recorded: the widget goes on showing only the answer.
|
|
3956
|
+
"interaction.outcome-dropped": "high",
|
|
3953
3957
|
"external-diagnostics.folded": "normal",
|
|
3954
3958
|
"session.cleared": "normal",
|
|
3955
3959
|
"session.switched": "low",
|
|
@@ -5156,13 +5160,17 @@ var InteractionController = class {
|
|
|
5156
5160
|
this.contexts = /* @__PURE__ */ new Map();
|
|
5157
5161
|
}
|
|
5158
5162
|
/** See `ChatDriver.setHostInteractionRequester`. */
|
|
5159
|
-
setHostRequester(fn) {
|
|
5163
|
+
setHostRequester(fn, recordOutcome) {
|
|
5160
5164
|
this.hostRequester = fn;
|
|
5165
|
+
this.hostOutcome = recordOutcome;
|
|
5161
5166
|
}
|
|
5162
|
-
/**
|
|
5163
|
-
|
|
5167
|
+
/**
|
|
5168
|
+
* See `ChatDriver.requestInteraction`. `onOpened` is told the id of the interaction this call
|
|
5169
|
+
* opens, wherever it opens it, so the caller can later record its outcome and no other's.
|
|
5170
|
+
*/
|
|
5171
|
+
request(componentName, data, options, onOpened) {
|
|
5164
5172
|
if (this.hostRequester) {
|
|
5165
|
-
return this.hostRequester(componentName, data, options);
|
|
5173
|
+
return this.hostRequester(componentName, data, options, onOpened);
|
|
5166
5174
|
}
|
|
5167
5175
|
if (this.pending.size > 0) {
|
|
5168
5176
|
throw new Error(
|
|
@@ -5170,6 +5178,7 @@ var InteractionController = class {
|
|
|
5170
5178
|
);
|
|
5171
5179
|
}
|
|
5172
5180
|
const interactionId = crypto.randomUUID();
|
|
5181
|
+
onOpened?.(interactionId);
|
|
5173
5182
|
const chatInputDuringExecution = options?.chatInputDuringExecution;
|
|
5174
5183
|
const timeoutMs = options?.timeoutMs;
|
|
5175
5184
|
const presentation = options?.presentation;
|
|
@@ -5306,6 +5315,45 @@ var InteractionController = class {
|
|
|
5306
5315
|
);
|
|
5307
5316
|
return true;
|
|
5308
5317
|
}
|
|
5318
|
+
/**
|
|
5319
|
+
* See `ChatDriver.recordInteractionOutcome`.
|
|
5320
|
+
*
|
|
5321
|
+
* @remarks
|
|
5322
|
+
* Only once the interaction has resolved: an outcome is what came of an answer. The message is
|
|
5323
|
+
* REPLACED, as `resolve` replaces it, never changed in place — the host's store freezes what it
|
|
5324
|
+
* holds. The value is copied as JSON, the form it is persisted in, so what the widget shows now
|
|
5325
|
+
* is what a reload shows, and nothing the caller keeps can change it afterwards.
|
|
5326
|
+
*
|
|
5327
|
+
* Announced on `history-updated`, unlike `recordExternalCost`: the outcome changes what the
|
|
5328
|
+
* widget shows, so the resolved widget has to be rebuilt with it.
|
|
5329
|
+
*/
|
|
5330
|
+
recordOutcome(interactionId, outcome) {
|
|
5331
|
+
if (this.hostOutcome) return this.hostOutcome(interactionId, outcome);
|
|
5332
|
+
const drop = (reason) => {
|
|
5333
|
+
recordMetaEvent(this.deps.sessionKey, "interaction.outcome-dropped", {
|
|
5334
|
+
interactionId,
|
|
5335
|
+
reason
|
|
5336
|
+
});
|
|
5337
|
+
return false;
|
|
5338
|
+
};
|
|
5339
|
+
if (this.pending.has(interactionId)) return drop("interaction not resolved");
|
|
5340
|
+
let copy;
|
|
5341
|
+
try {
|
|
5342
|
+
const json = JSON.stringify(outcome);
|
|
5343
|
+
if (json === void 0) return drop("no value to store");
|
|
5344
|
+
copy = JSON.parse(json);
|
|
5345
|
+
} catch {
|
|
5346
|
+
return drop("not storable as JSON");
|
|
5347
|
+
}
|
|
5348
|
+
const patched = this.deps.patchInteractionMessage(interactionId, (message) => ({
|
|
5349
|
+
...message,
|
|
5350
|
+
interaction: { ...message.interaction, outcome: copy }
|
|
5351
|
+
}));
|
|
5352
|
+
if (!patched) return drop("interaction message no longer in history");
|
|
5353
|
+
recordMetaEvent(this.deps.sessionKey, "interaction.outcome", { interactionId });
|
|
5354
|
+
this.deps.notifyHistoryUpdated();
|
|
5355
|
+
return true;
|
|
5356
|
+
}
|
|
5309
5357
|
/** See `ChatDriver.getInteractionContext`. */
|
|
5310
5358
|
context(interactionId) {
|
|
5311
5359
|
return this.contexts.get(interactionId)?.context;
|
|
@@ -6903,8 +6951,8 @@ var ChatDriver = class _ChatDriver extends EventTarget {
|
|
|
6903
6951
|
* resolves through) the parent's history and pending map. Calls chain
|
|
6904
6952
|
* naturally: a grandchild → child → root.
|
|
6905
6953
|
*/
|
|
6906
|
-
setHostInteractionRequester(fn) {
|
|
6907
|
-
this.interactions.setHostRequester(fn);
|
|
6954
|
+
setHostInteractionRequester(fn, recordOutcome) {
|
|
6955
|
+
this.interactions.setHostRequester(fn, recordOutcome);
|
|
6908
6956
|
}
|
|
6909
6957
|
/**
|
|
6910
6958
|
* Request a custom UI interaction. Emits a new message with the interaction.
|
|
@@ -6925,8 +6973,22 @@ var ChatDriver = class _ChatDriver extends EventTarget {
|
|
|
6925
6973
|
* and `presentation` to control whether the host wraps the widget in a chat
|
|
6926
6974
|
* bubble and/or shows the "Assistant" label.
|
|
6927
6975
|
*/
|
|
6928
|
-
async requestInteraction(componentName, data, options) {
|
|
6929
|
-
return this.interactions.request(componentName, data, options);
|
|
6976
|
+
async requestInteraction(componentName, data, options, onOpened) {
|
|
6977
|
+
return this.interactions.request(componentName, data, options, onOpened);
|
|
6978
|
+
}
|
|
6979
|
+
/**
|
|
6980
|
+
* Record what came of an interaction, after it resolved, on its history message
|
|
6981
|
+
* (`interaction.outcome`): handed to its widget and persisted with the session, never sent to a
|
|
6982
|
+
* model. Routed to the host driver when the interaction lives there (a sub-agent's). `false`,
|
|
6983
|
+
* changing nothing, when it is unknown, still pending, or the value cannot be stored as JSON.
|
|
6984
|
+
*
|
|
6985
|
+
* Tool handlers reach this through `recordInteractionOutcome` on their context, which binds it
|
|
6986
|
+
* to the interaction that call opened: see `buildHandlerContext`.
|
|
6987
|
+
*
|
|
6988
|
+
* @internal
|
|
6989
|
+
*/
|
|
6990
|
+
recordInteractionOutcome(interactionId, outcome) {
|
|
6991
|
+
return this.interactions.recordOutcome(interactionId, outcome);
|
|
6930
6992
|
}
|
|
6931
6993
|
/**
|
|
6932
6994
|
* Add external (non-LLM) spend to an interaction's message AFTER it has resolved — for a widget
|
|
@@ -7065,8 +7127,23 @@ var ChatDriver = class _ChatDriver extends EventTarget {
|
|
|
7065
7127
|
* error growing as the fan-out widens.
|
|
7066
7128
|
*/
|
|
7067
7129
|
buildHandlerContext(activeToolCallId, traceCapture) {
|
|
7130
|
+
let opened;
|
|
7131
|
+
let recorded = false;
|
|
7068
7132
|
return {
|
|
7069
|
-
requestInteraction: (componentName, data, options) => this.requestInteraction(componentName, data, options)
|
|
7133
|
+
requestInteraction: (componentName, data, options) => this.requestInteraction(componentName, data, options, (interactionId) => {
|
|
7134
|
+
opened = interactionId;
|
|
7135
|
+
}),
|
|
7136
|
+
recordInteractionOutcome: (outcome) => {
|
|
7137
|
+
if (!opened) return false;
|
|
7138
|
+
if (recorded) {
|
|
7139
|
+
logger2.warn(
|
|
7140
|
+
`ChatDriver(${this.activeAgentName ?? "unknown"}): recordInteractionOutcome called more than once in one tool call \u2014 ignoring`
|
|
7141
|
+
);
|
|
7142
|
+
return false;
|
|
7143
|
+
}
|
|
7144
|
+
recorded = true;
|
|
7145
|
+
return this.recordInteractionOutcome(opened, outcome);
|
|
7146
|
+
},
|
|
7070
7147
|
// The MESSAGE's scope: one object per `sendMessage`, kept across a handoff's continuation
|
|
7071
7148
|
// and handed to a sub-agent, and aborted by `cancel()` as well as a dispose. Not the
|
|
7072
7149
|
// per-request `turnController`, which every continuation replaces.
|
|
@@ -7174,7 +7251,9 @@ var ChatDriver = class _ChatDriver extends EventTarget {
|
|
|
7174
7251
|
}
|
|
7175
7252
|
child.installAgent({ ...subConfig, primerHistory: effectivePrimer });
|
|
7176
7253
|
child.setHostInteractionRequester(
|
|
7177
|
-
(componentName, data, opts) => this.requestInteraction(componentName, data, opts)
|
|
7254
|
+
(componentName, data, opts, onOpened) => this.requestInteraction(componentName, data, opts, onOpened),
|
|
7255
|
+
// An outcome goes where its interaction went.
|
|
7256
|
+
(interactionId, outcome) => this.recordInteractionOutcome(interactionId, outcome)
|
|
7178
7257
|
);
|
|
7179
7258
|
child.hostAIServiceNotice = (code) => this.noticeAIServiceRefusal(code);
|
|
7180
7259
|
const forwardTrace = (e) => {
|