@genesislcap/ai-assistant 15.61.0 → 15.62.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 +18231 -11171
- package/dist/ai-assistant.d.ts +1235 -9
- package/dist/chat-driver.cjs +658 -50
- package/dist/chat-driver.cjs.map +4 -4
- package/dist/chat-driver.mjs +657 -50
- package/dist/chat-driver.mjs.map +4 -4
- package/dist/custom-elements.json +6169 -2127
- package/dist/dts/autopilot/autopilot-driver.d.ts +278 -0
- package/dist/dts/autopilot/autopilot-driver.d.ts.map +1 -0
- package/dist/dts/autopilot/autopilot-session.d.ts +163 -0
- package/dist/dts/autopilot/autopilot-session.d.ts.map +1 -0
- package/dist/dts/autopilot/autopilot-tools.d.ts +15 -0
- package/dist/dts/autopilot/autopilot-tools.d.ts.map +1 -0
- package/dist/dts/autopilot/decision-message.d.ts +62 -0
- package/dist/dts/autopilot/decision-message.d.ts.map +1 -0
- package/dist/dts/autopilot/hand-back/hand-back.controller.d.ts +69 -0
- package/dist/dts/autopilot/hand-back/hand-back.controller.d.ts.map +1 -0
- package/dist/dts/autopilot/hand-back/hand-back.d.ts +22 -0
- package/dist/dts/autopilot/hand-back/hand-back.d.ts.map +1 -0
- package/dist/dts/autopilot/index.d.ts +4 -0
- package/dist/dts/autopilot/index.d.ts.map +1 -0
- package/dist/dts/channel/ai-activity-bus.d.ts.map +1 -1
- package/dist/dts/channel/ai-activity-channel.d.ts +17 -0
- package/dist/dts/channel/ai-activity-channel.d.ts.map +1 -1
- package/dist/dts/channel/autopilot-needs-user.d.ts +8 -0
- package/dist/dts/channel/autopilot-needs-user.d.ts.map +1 -0
- package/dist/dts/components/agent-picker/agent-picker.constants.d.ts +10 -0
- package/dist/dts/components/agent-picker/agent-picker.constants.d.ts.map +1 -1
- package/dist/dts/components/agent-picker/agent-picker.d.ts +4 -0
- package/dist/dts/components/agent-picker/agent-picker.d.ts.map +1 -1
- package/dist/dts/components/agent-picker/agent-picker.template.d.ts.map +1 -1
- package/dist/dts/components/ai-driver/ai-driver.d.ts +34 -1
- package/dist/dts/components/ai-driver/ai-driver.d.ts.map +1 -1
- package/dist/dts/components/ai-driver/base-driver-decorator.d.ts +3 -1
- package/dist/dts/components/ai-driver/base-driver-decorator.d.ts.map +1 -1
- package/dist/dts/components/chat-bubble/chat-bubble.d.ts +21 -0
- package/dist/dts/components/chat-bubble/chat-bubble.d.ts.map +1 -1
- package/dist/dts/components/chat-bubble/chat-bubble.styles.d.ts.map +1 -1
- package/dist/dts/components/chat-bubble/chat-bubble.template.d.ts.map +1 -1
- package/dist/dts/components/chat-driver/chat-driver.d.ts +5 -1
- package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
- package/dist/dts/components/chat-driver/interaction-controller.d.ts +27 -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 +10 -2
- package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.d.ts.map +1 -1
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts +9 -1
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts.map +1 -1
- package/dist/dts/config/config.d.ts +183 -0
- package/dist/dts/config/config.d.ts.map +1 -1
- package/dist/dts/config/define-stateful-agent.d.ts +31 -1
- package/dist/dts/config/define-stateful-agent.d.ts.map +1 -1
- package/dist/dts/index.d.ts +7 -3
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/main/main.d.ts +128 -5
- package/dist/dts/main/main.d.ts.map +1 -1
- package/dist/dts/main/main.styles.d.ts.map +1 -1
- package/dist/dts/main/main.template.d.ts +2 -2
- package/dist/dts/main/main.template.d.ts.map +1 -1
- package/dist/dts/react.d.ts +10 -0
- 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/state/decision-surface.d.ts +46 -0
- package/dist/dts/state/decision-surface.d.ts.map +1 -0
- package/dist/dts/state/interaction-context.d.ts +21 -1
- package/dist/dts/state/interaction-context.d.ts.map +1 -1
- package/dist/dts/state/interaction-registry.d.ts +63 -0
- package/dist/dts/state/interaction-registry.d.ts.map +1 -0
- package/dist/dts/state/persistence/session-persister.d.ts.map +1 -1
- package/dist/dts/state/persistence/session-snapshot.d.ts +21 -0
- package/dist/dts/state/persistence/session-snapshot.d.ts.map +1 -1
- package/dist/dts/state/run-steps.d.ts +66 -0
- package/dist/dts/state/run-steps.d.ts.map +1 -0
- package/dist/dts/types/ai-chat-widget.d.ts +7 -1
- package/dist/dts/types/ai-chat-widget.d.ts.map +1 -1
- package/dist/dts/types/interaction-context.d.ts +66 -1
- package/dist/dts/types/interaction-context.d.ts.map +1 -1
- package/dist/dts/types/interaction-interceptor.d.ts +60 -2
- package/dist/dts/types/interaction-interceptor.d.ts.map +1 -1
- package/dist/dts/types/interaction-surface.d.ts +195 -0
- package/dist/dts/types/interaction-surface.d.ts.map +1 -0
- package/dist/dts/utils/context-tokens.d.ts +6 -0
- package/dist/dts/utils/context-tokens.d.ts.map +1 -1
- package/dist/dts/utils/delegated-message.d.ts +13 -0
- package/dist/dts/utils/delegated-message.d.ts.map +1 -1
- package/dist/dts/utils/history-transform.d.ts.map +1 -1
- package/dist/dts/utils/preserved-user-messages.d.ts +21 -0
- package/dist/dts/utils/preserved-user-messages.d.ts.map +1 -0
- package/dist/esm/autopilot/autopilot-driver.js +906 -0
- package/dist/esm/autopilot/autopilot-session.js +449 -0
- package/dist/esm/autopilot/autopilot-tools.js +68 -0
- package/dist/esm/autopilot/decision-message.js +206 -0
- package/dist/esm/autopilot/hand-back/hand-back.controller.js +47 -0
- package/dist/esm/autopilot/hand-back/hand-back.js +129 -0
- package/dist/esm/autopilot/index.js +4 -0
- package/dist/esm/channel/ai-activity-bus.js +7 -0
- package/dist/esm/channel/autopilot-needs-user.js +26 -0
- package/dist/esm/components/agent-picker/agent-picker.constants.js +10 -0
- package/dist/esm/components/agent-picker/agent-picker.js +11 -1
- package/dist/esm/components/agent-picker/agent-picker.template.js +2 -4
- package/dist/esm/components/ai-driver/ai-driver.js +2 -0
- package/dist/esm/components/ai-driver/base-driver-decorator.js +8 -0
- package/dist/esm/components/chat-bubble/chat-bubble.js +45 -0
- package/dist/esm/components/chat-bubble/chat-bubble.styles.js +26 -0
- package/dist/esm/components/chat-bubble/chat-bubble.template.js +13 -0
- package/dist/esm/components/chat-driver/chat-driver.js +53 -18
- package/dist/esm/components/chat-driver/interaction-controller.js +297 -12
- package/dist/esm/components/chat-interaction-wrapper/chat-interaction-wrapper.js +16 -2
- package/dist/esm/components/orchestrating-driver/orchestrating-driver.js +28 -11
- package/dist/esm/config/define-stateful-agent.js +34 -29
- package/dist/esm/index.js +3 -0
- package/dist/esm/main/main.js +334 -15
- package/dist/esm/main/main.styles.js +126 -0
- package/dist/esm/main/main.template.js +116 -11
- package/dist/esm/state/debug-event-log.js +28 -1
- package/dist/esm/state/decision-surface.js +209 -0
- package/dist/esm/state/interaction-context.js +89 -1
- package/dist/esm/state/interaction-registry.js +33 -0
- package/dist/esm/state/persistence/session-persister.js +23 -11
- package/dist/esm/state/persistence/session-snapshot.js +1 -1
- package/dist/esm/state/run-steps.js +77 -0
- package/dist/esm/types/interaction-surface.js +1 -0
- package/dist/esm/utils/context-tokens.js +23 -9
- package/dist/esm/utils/delegated-message.js +15 -0
- package/dist/esm/utils/history-transform.js +18 -7
- package/dist/esm/utils/preserved-user-messages.js +31 -0
- package/dist/react.cjs +7 -0
- package/dist/react.mjs +6 -0
- package/docs/styling.md +1 -1
- package/package.json +17 -17
- package/sandbox/README.md +38 -2
- package/sandbox/autopilot.ts +358 -0
- package/sandbox/controls.ts +24 -1
- package/sandbox/fixtures.ts +2 -0
- package/sandbox/sandbox.ts +188 -1
|
@@ -3,12 +3,12 @@ import { AIServiceError, BudgetExhaustedError } from '@genesislcap/foundation-ai
|
|
|
3
3
|
import { validateStaticAgentProviders } from '../../config/validate-providers';
|
|
4
4
|
import { recordMetaEvent } from '../../state/debug-event-log';
|
|
5
5
|
import { reachesProvider } from '../../utils/context-tokens';
|
|
6
|
-
import {
|
|
6
|
+
import { delegatedFields, frameDelegatedContent, } from '../../utils/delegated-message';
|
|
7
7
|
import { transformHistoryForAgent } from '../../utils/history-transform';
|
|
8
8
|
import { logger } from '../../utils/logger';
|
|
9
9
|
import { messageUsage } from '../../utils/sum-usage';
|
|
10
10
|
import { BaseDriverDecorator } from '../ai-driver/base-driver-decorator';
|
|
11
|
-
import { ChatDriver, REQUEST_CONTINUATION_TOOL } from '../chat-driver/chat-driver';
|
|
11
|
+
import { ChatDriver, REQUEST_CONTINUATION_TOOL, } from '../chat-driver/chat-driver';
|
|
12
12
|
const DEFAULT_MAX_HANDOFFS = 3;
|
|
13
13
|
const DEFAULT_CLASSIFIER_HISTORY_LENGTH = 4;
|
|
14
14
|
const DEFAULT_CLASSIFIER_RETRIES = 2;
|
|
@@ -262,14 +262,9 @@ export class OrchestratingDriver extends BaseDriverDecorator {
|
|
|
262
262
|
}
|
|
263
263
|
sendMessage(input, attachments, options) {
|
|
264
264
|
return __awaiter(this, void 0, void 0, function* () {
|
|
265
|
-
|
|
266
|
-
//
|
|
267
|
-
const delegated = (options
|
|
268
|
-
? {
|
|
269
|
-
delegate: options.delegate,
|
|
270
|
-
delegateFraming: (_a = options.delegateFraming) !== null && _a !== void 0 ? _a : DEFAULT_DELEGATE_FRAMING,
|
|
271
|
-
}
|
|
272
|
-
: {};
|
|
265
|
+
// Who it is from, and what writing it cost, travel with every copy of the message this method
|
|
266
|
+
// makes (GENC-1660).
|
|
267
|
+
const delegated = delegatedFields(options);
|
|
273
268
|
try {
|
|
274
269
|
return yield this.runOrchestratedTurn(input, attachments, options, delegated);
|
|
275
270
|
}
|
|
@@ -490,7 +485,29 @@ export class OrchestratingDriver extends BaseDriverDecorator {
|
|
|
490
485
|
yield this.installAgent(agent);
|
|
491
486
|
if (!resumeNote || agent.resumeOnRestore === false || this.cancelled)
|
|
492
487
|
return undefined;
|
|
493
|
-
|
|
488
|
+
const result = yield this.chatDriver.continueFromHistory(undefined, { tailNote: resumeNote });
|
|
489
|
+
yield this.releaseIfRequested();
|
|
490
|
+
return result;
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* A continuation outside a routed turn — a decorator carrying the agent on, say — can finish the
|
|
495
|
+
* flow as surely as a turn can, so a release it requests is acted on here too. Before
|
|
496
|
+
* (GENC-1660), only `sendMessage` checked, and a flow finished by a continuation stayed locked.
|
|
497
|
+
*/
|
|
498
|
+
continueFromHistory(transientPrimer, options) {
|
|
499
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
500
|
+
const result = yield this.chatDriver.continueFromHistory(transientPrimer, options);
|
|
501
|
+
yield this.releaseIfRequested();
|
|
502
|
+
return result;
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
/** Release the flow if the turn that just ended asked to, and an agent is still active to release. */
|
|
506
|
+
releaseIfRequested() {
|
|
507
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
508
|
+
if (this.chatDriver.getAgentReleaseRequested() && this.agentSession.getActive()) {
|
|
509
|
+
yield this.releaseActiveAgent();
|
|
510
|
+
}
|
|
494
511
|
});
|
|
495
512
|
}
|
|
496
513
|
/**
|
|
@@ -246,27 +246,12 @@ export function defineStatefulAgent(opts) {
|
|
|
246
246
|
});
|
|
247
247
|
})
|
|
248
248
|
: undefined;
|
|
249
|
-
const base = {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
chatInputDuringExecution: opts.chatInputDuringExecution,
|
|
256
|
-
toolDefinitions: wrappedTools,
|
|
257
|
-
toolHandlers: wrappedHandlers,
|
|
258
|
-
provider: wrappedProvider,
|
|
259
|
-
temperature: wrappedTemperature,
|
|
260
|
-
toolChoice: wrappedToolChoice,
|
|
261
|
-
cachePolicy: wrappedCachePolicy,
|
|
262
|
-
thinkingPolicy: wrappedThinkingPolicy,
|
|
263
|
-
tailContext: wrappedTailContext,
|
|
264
|
-
onUnresolvedTool: wrappedOnUnresolvedTool,
|
|
265
|
-
resumable: wrappedResumable,
|
|
266
|
-
notResumableMessage: opts.notResumableMessage,
|
|
267
|
-
resumeOnRestore: opts.resumeOnRestore,
|
|
268
|
-
contextReserve: opts.contextReserve,
|
|
269
|
-
onActivate: (ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
249
|
+
const base = Object.assign(Object.assign({ name: opts.name, displayName: wrappedDisplayName, primerHistory: opts.primerHistory, subAgents: opts.subAgents, manualSelection: opts.manualSelection, chatInputDuringExecution: opts.chatInputDuringExecution, toolDefinitions: wrappedTools, toolHandlers: wrappedHandlers, provider: wrappedProvider, temperature: wrappedTemperature, toolChoice: wrappedToolChoice, cachePolicy: wrappedCachePolicy, thinkingPolicy: wrappedThinkingPolicy, tailContext: wrappedTailContext, onUnresolvedTool: wrappedOnUnresolvedTool, resumable: wrappedResumable, notResumableMessage: opts.notResumableMessage, resumeOnRestore: opts.resumeOnRestore, contextReserve: opts.contextReserve }, (opts.autopilot && {
|
|
250
|
+
autopilot: {
|
|
251
|
+
config: opts.autopilot,
|
|
252
|
+
state: () => state,
|
|
253
|
+
},
|
|
254
|
+
})), { onActivate: (ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
270
255
|
state = yield opts.init(ctx);
|
|
271
256
|
// Sample once with the init state to fail loud on fold misuse at the
|
|
272
257
|
// agent-switch boundary instead of waiting for the first tool call.
|
|
@@ -277,8 +262,7 @@ export function defineStatefulAgent(opts) {
|
|
|
277
262
|
const sampled = yield opts.toolHandlers(state);
|
|
278
263
|
assertNoFolds(sampled);
|
|
279
264
|
}
|
|
280
|
-
}),
|
|
281
|
-
onDeactivate: (ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
265
|
+
}), onDeactivate: (ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
282
266
|
if (state !== undefined && opts.dispose) {
|
|
283
267
|
yield opts.dispose(Object.assign(Object.assign({}, ctx), { state }));
|
|
284
268
|
}
|
|
@@ -286,15 +270,14 @@ export function defineStatefulAgent(opts) {
|
|
|
286
270
|
// cannot interleave the read-then-write of `state`.
|
|
287
271
|
// eslint-disable-next-line require-atomic-updates
|
|
288
272
|
state = undefined;
|
|
289
|
-
}),
|
|
290
|
-
systemPrompt: opts.systemPrompt
|
|
273
|
+
}), systemPrompt: opts.systemPrompt
|
|
291
274
|
? (ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
292
275
|
if (!state) {
|
|
293
276
|
throw new Error(`Stateful agent "${opts.name}" systemPrompt called before init`);
|
|
294
277
|
}
|
|
295
278
|
return opts.systemPrompt(Object.assign(Object.assign({}, ctx), { state }));
|
|
296
279
|
})
|
|
297
|
-
: undefined,
|
|
280
|
+
: undefined,
|
|
298
281
|
// Called per LLM call by ChatDriver, and once at debug-log export time.
|
|
299
282
|
// Returns `undefined` before activation (state hasn't been built yet) and
|
|
300
283
|
// after deactivation (state was disposed) — the snapshotter is best-effort
|
|
@@ -305,14 +288,36 @@ export function defineStatefulAgent(opts) {
|
|
|
305
288
|
return opts.getDebugSnapshot
|
|
306
289
|
? opts.getDebugSnapshot(state)
|
|
307
290
|
: defaultStatefulDebugSnapshot(state);
|
|
308
|
-
},
|
|
291
|
+
},
|
|
309
292
|
// Lossless restore image for session persistence (see `serialize` on the
|
|
310
293
|
// config). Returns undefined before activation / after disposal.
|
|
311
294
|
serialize: () => {
|
|
312
295
|
if (state === undefined)
|
|
313
296
|
return undefined;
|
|
314
297
|
return opts.serialize ? opts.serialize(state) : defaultStatefulSerialize(state);
|
|
315
|
-
}
|
|
316
|
-
};
|
|
298
|
+
} });
|
|
317
299
|
return Object.assign(Object.assign({}, base), { description: opts.description, excludeFromClassifier: opts.excludeFromClassifier });
|
|
318
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Define an autopilot for a stateful agent whose state is `S` (GENC-1660). An identity function
|
|
303
|
+
* that exists for its type: the resolvers get `S`, and the result goes on `defineStatefulAgent`'s
|
|
304
|
+
* `autopilot` option.
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* ```ts
|
|
308
|
+
* defineStatefulAgent<BootstrapState>({
|
|
309
|
+
* name: 'bootstrap',
|
|
310
|
+
* …,
|
|
311
|
+
* autopilot: defineAutopilot<BootstrapState>({
|
|
312
|
+
* availableWhen: ({ state }) => briefApproved(state.machine),
|
|
313
|
+
* widgetPolicy: { 'planning-question': 'allowed' },
|
|
314
|
+
* systemPrompt: ({ state }) => `${AUTOPILOT_BASE}\n<brief>${frozenBrief(state)}</brief>`,
|
|
315
|
+
* }),
|
|
316
|
+
* });
|
|
317
|
+
* ```
|
|
318
|
+
*
|
|
319
|
+
* @beta
|
|
320
|
+
*/
|
|
321
|
+
export function defineAutopilot(config) {
|
|
322
|
+
return config;
|
|
323
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export * from './main/main.types';
|
|
|
3
3
|
export * from './main/main.template';
|
|
4
4
|
export * from './components/agent-picker';
|
|
5
5
|
export * from './components/agent-session';
|
|
6
|
+
export * from './autopilot';
|
|
6
7
|
export * from './components/ai-driver';
|
|
7
8
|
export * from './components/chat-driver';
|
|
8
9
|
export * from './components/orchestrating-driver';
|
|
@@ -19,6 +20,8 @@ export * from './provider/assistant-app-settings';
|
|
|
19
20
|
export * from './utils/tool-fold';
|
|
20
21
|
export { DEFAULT_DELEGATE_FRAMING, isDelegated, } from './utils/delegated-message';
|
|
21
22
|
export { assistantSettingsSectionTitleStyles } from './styles/settings-section';
|
|
23
|
+
export { runSteps } from './state/run-steps';
|
|
24
|
+
export { getInteractionRegistration, registerInteraction, } from './state/interaction-registry';
|
|
22
25
|
// MARKDOWN_EXPORTPARTS travels with the component: a host rendering `<ai-chat-markdown>` in its
|
|
23
26
|
// own shadow root has to forward its parts, and hand-copying the list is how it drifts.
|
|
24
27
|
export { AiChatMarkdown, MARKDOWN_EXPORTPARTS } from './components/chat-markdown/chat-markdown';
|