@genesislcap/ai-assistant 15.108.0 → 15.109.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/dist/ai-assistant.api.json +410 -4
- package/dist/ai-assistant.d.ts +121 -2
- package/dist/chat-driver.cjs +33 -15
- package/dist/chat-driver.cjs.map +2 -2
- package/dist/chat-driver.mjs +33 -15
- package/dist/chat-driver.mjs.map +2 -2
- package/dist/custom-elements.json +891 -690
- package/dist/dts/components/chat-driver/chat-driver.d.ts +9 -0
- package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts +2 -0
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts.map +1 -1
- package/dist/dts/components/settings-modal/settings-modal.d.ts +2 -0
- package/dist/dts/components/settings-modal/settings-modal.d.ts.map +1 -1
- package/dist/dts/components/settings-modal/settings-modal.styles.d.ts.map +1 -1
- package/dist/dts/components/settings-modal/settings-modal.template.d.ts +1 -0
- package/dist/dts/components/settings-modal/settings-modal.template.d.ts.map +1 -1
- package/dist/dts/genesis/register-genesis-assistant.d.ts +24 -0
- package/dist/dts/genesis/register-genesis-assistant.d.ts.map +1 -1
- package/dist/dts/genesis/types.d.ts +8 -2
- package/dist/dts/genesis/types.d.ts.map +1 -1
- package/dist/dts/genesis/vendor-follower.d.ts +86 -0
- package/dist/dts/genesis/vendor-follower.d.ts.map +1 -0
- package/dist/dts/genesis/vendor-pick.d.ts +36 -0
- package/dist/dts/genesis/vendor-pick.d.ts.map +1 -0
- package/dist/dts/index.d.ts +1 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/main/budget-controller.d.ts +6 -0
- package/dist/dts/main/budget-controller.d.ts.map +1 -1
- package/dist/dts/main/main.d.ts +30 -0
- package/dist/dts/main/main.d.ts.map +1 -1
- package/dist/dts/main/vendor-picker-controller.d.ts +89 -0
- package/dist/dts/main/vendor-picker-controller.d.ts.map +1 -0
- package/dist/dts/provider/ai-provider-switcher.d.ts +22 -1
- package/dist/dts/provider/ai-provider-switcher.d.ts.map +1 -1
- package/dist/dts/provider/tiered-provider-switcher.d.ts +39 -2
- package/dist/dts/provider/tiered-provider-switcher.d.ts.map +1 -1
- package/dist/esm/chat-driver-node.js +1 -1
- package/dist/esm/components/chat-driver/chat-driver.js +3 -2
- package/dist/esm/components/orchestrating-driver/orchestrating-driver.js +1 -0
- package/dist/esm/components/settings-modal/settings-modal.js +4 -1
- package/dist/esm/components/settings-modal/settings-modal.styles.js +59 -0
- package/dist/esm/components/settings-modal/settings-modal.template.js +54 -1
- package/dist/esm/genesis/register-genesis-assistant.js +72 -7
- package/dist/esm/genesis/vendor-follower.js +149 -0
- package/dist/esm/genesis/vendor-pick.js +67 -0
- package/dist/esm/main/budget-controller.js +11 -9
- package/dist/esm/main/main.js +57 -0
- package/dist/esm/main/vendor-picker-controller.js +141 -0
- package/dist/esm/provider/tiered-provider-switcher.js +54 -1
- package/docs/genesis.md +35 -1
- package/package.json +17 -17
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { AIProviderSwitcher, AIVendorChoice } from '../provider/ai-provider-switcher';
|
|
2
|
+
/**
|
|
3
|
+
* One card in the settings' vendor picker.
|
|
4
|
+
*
|
|
5
|
+
* @beta
|
|
6
|
+
*/
|
|
7
|
+
export interface VendorPickerOption {
|
|
8
|
+
vendor: string;
|
|
9
|
+
label: string;
|
|
10
|
+
checked: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The active vendor, when something outside the app chooses it.
|
|
14
|
+
*
|
|
15
|
+
* @beta
|
|
16
|
+
*/
|
|
17
|
+
export interface VendorSelectedElsewhere {
|
|
18
|
+
label: string;
|
|
19
|
+
where: string;
|
|
20
|
+
}
|
|
21
|
+
/** @internal */
|
|
22
|
+
export interface VendorPickerDeps {
|
|
23
|
+
/** The registered switcher; the platform's no-op one when the app registered none. */
|
|
24
|
+
switcher: () => AIProviderSwitcher | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Whether a turn is computing: busy and not parked on the person. A switch then would move the
|
|
27
|
+
* registry under a request in flight; a parked turn has none, and its next request resolves
|
|
28
|
+
* the provider afresh, so the picker stays usable through a long wait on a widget.
|
|
29
|
+
*/
|
|
30
|
+
computing: () => boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the host slotted a control of its own into `settings-model`, as Genesis Create does
|
|
33
|
+
* (`gc-assistant-settings-model`). The picker is that slot's fallback, so it then shows nothing.
|
|
34
|
+
* Optional: none slotted.
|
|
35
|
+
*/
|
|
36
|
+
hostControl?: () => boolean;
|
|
37
|
+
}
|
|
38
|
+
/** What a vendor is called in the settings: the platform's label, else the vendor id. */
|
|
39
|
+
export declare const vendorLabel: (vendor: string) => string;
|
|
40
|
+
/**
|
|
41
|
+
* The vendor control in the settings' AI model section.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* It is the fallback content of the `settings-model` slot, so a host that slots its own control
|
|
45
|
+
* there (Genesis Create) keeps only its own. And it shows only what the switcher asks for through
|
|
46
|
+
* its `vendorChoice`, so a host with a control elsewhere (the showcase's header button) gets none
|
|
47
|
+
* either. With `in-app`, a card per vendor while there are two or more; with `elsewhere`, the
|
|
48
|
+
* active vendor read-only, naming where it is chosen.
|
|
49
|
+
*
|
|
50
|
+
* The switcher announces a vendor change but not a change to its list of vendors, so the host
|
|
51
|
+
* calls {@link VendorPickerController.refresh} whenever the provider registry changes too: every
|
|
52
|
+
* change to either rebuilds the registry.
|
|
53
|
+
*
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
export declare class VendorPickerController {
|
|
57
|
+
private readonly deps;
|
|
58
|
+
/** Bumped on every switcher or registry change, so the getters below re-evaluate. */
|
|
59
|
+
revision: number;
|
|
60
|
+
private unsubscribe?;
|
|
61
|
+
constructor(deps: VendorPickerDeps);
|
|
62
|
+
/** Follow the switcher's vendor. Call on connect; balanced by {@link VendorPickerController.unwire}. */
|
|
63
|
+
wire(): void;
|
|
64
|
+
unwire(): void;
|
|
65
|
+
refresh(): void;
|
|
66
|
+
get choice(): AIVendorChoice | undefined;
|
|
67
|
+
/** An `in-app` choice with two or more vendors: something to pick, wherever the control is. */
|
|
68
|
+
private get choosable();
|
|
69
|
+
/** The host's own control in `settings-model` replaces this one. */
|
|
70
|
+
private get replaced();
|
|
71
|
+
/** Cards to pick from: something to pick, and no control of the host's own in the slot. */
|
|
72
|
+
get pickerVisible(): boolean;
|
|
73
|
+
get options(): VendorPickerOption[];
|
|
74
|
+
/** The active vendor read-only, when it is chosen outside the app. */
|
|
75
|
+
get selectedElsewhere(): VendorSelectedElsewhere | undefined;
|
|
76
|
+
/** Whether the section has a vendor block to show at all. */
|
|
77
|
+
get visible(): boolean;
|
|
78
|
+
get disabled(): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Where the user switches vendor, as a phrase completing "Switch to Gemini …": `'in Settings'`
|
|
81
|
+
* when the user picks there (these cards, or a control the host slotted in their place),
|
|
82
|
+
* `'in <where>'` when the vendor is chosen elsewhere, otherwise `undefined` (the copy then
|
|
83
|
+
* names no place, as it always has).
|
|
84
|
+
*/
|
|
85
|
+
get switchPlace(): string | undefined;
|
|
86
|
+
/** A card was picked. Ignored while a turn computes or when the cards are not showing. */
|
|
87
|
+
select(vendor: string): void;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=vendor-picker-controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vendor-picker-controller.d.ts","sourceRoot":"","sources":["../../../src/main/vendor-picker-controller.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAE3F;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;G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|
2
|
+
* Who chooses the vendor, for the assistant's settings to show.
|
|
3
|
+
*
|
|
4
|
+
* - `in-app`: the user, in the assistant's Settings. The AI model section shows a card per vendor
|
|
5
|
+
* while there are two or more, and the budget wall says to switch there.
|
|
6
|
+
* - `elsewhere`: something outside the app, named by `where` (for example `'Genesis Create'`). The
|
|
7
|
+
* section shows the active vendor read-only, and the wall says to switch there.
|
|
8
|
+
*
|
|
9
|
+
* @beta
|
|
10
|
+
*/
|
|
11
|
+
export type AIVendorChoice = {
|
|
12
|
+
kind: 'in-app';
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'elsewhere';
|
|
15
|
+
where: string;
|
|
16
|
+
};
|
|
1
17
|
/**
|
|
2
18
|
* Optional app-registered policy for which cloud vendor backs the tier-shaped
|
|
3
19
|
* provider registry slots (`low` / `high` / …). Apps inject a concrete
|
|
4
20
|
* implementation on this DI token at bootstrap; consumers include the
|
|
5
21
|
* slotted `settings-model` component or a header vendor control.
|
|
6
|
-
* The platform settings modal does not render vendor UI itself.
|
|
7
22
|
*
|
|
8
23
|
* @beta
|
|
9
24
|
*/
|
|
10
25
|
export interface AIProviderSwitcher {
|
|
11
26
|
readonly vendor: string;
|
|
12
27
|
readonly vendors: readonly string[];
|
|
28
|
+
/**
|
|
29
|
+
* Who chooses the vendor. Unset, the assistant's settings show no vendor control at all, which
|
|
30
|
+
* is right for a host with a control of its own (slotted into `settings-model`, or in its
|
|
31
|
+
* header) and for one with nothing to choose.
|
|
32
|
+
*/
|
|
33
|
+
readonly vendorChoice?: AIVendorChoice;
|
|
13
34
|
switchTo(vendor: string): void;
|
|
14
35
|
subscribe(listener: (vendor: string) => void): () => void;
|
|
15
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-provider-switcher.d.ts","sourceRoot":"","sources":["../../../src/provider/ai-provider-switcher.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"ai-provider-switcher.d.ts","sourceRoot":"","sources":["../../../src/provider/ai-provider-switcher.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvF;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,cAAc,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,SAAS,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAC3D;AAeD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,0EAE9B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type AITierId, type AITiers, type AITierVendor } from '@genesislcap/foundation-ai';
|
|
2
2
|
import { type Container } from '@genesislcap/web-core';
|
|
3
|
-
import { AIProviderSwitcher } from './ai-provider-switcher';
|
|
3
|
+
import { AIProviderSwitcher, type AIVendorChoice } from './ai-provider-switcher';
|
|
4
4
|
/**
|
|
5
5
|
* Options for {@link TieredAIProviderSwitcher}.
|
|
6
6
|
*
|
|
@@ -57,6 +57,11 @@ export interface TieredAIProviderSwitcherOptions {
|
|
|
57
57
|
* may still be loading, so "confirm what I can see" and "leave it alone" are different acts.
|
|
58
58
|
*/
|
|
59
59
|
onSwitch?: (vendor: AITierVendor) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Who chooses the vendor, for the assistant's settings: see {@link AIVendorChoice}. Unset, the
|
|
62
|
+
* settings show no vendor control, as before this option existed.
|
|
63
|
+
*/
|
|
64
|
+
vendorChoice?: AIVendorChoice;
|
|
60
65
|
}
|
|
61
66
|
/**
|
|
62
67
|
* Which cloud vendor backs the tier-shaped provider registry, plus the means to move it at
|
|
@@ -75,14 +80,46 @@ export interface TieredAIProviderSwitcherOptions {
|
|
|
75
80
|
* @beta
|
|
76
81
|
*/
|
|
77
82
|
export declare class TieredAIProviderSwitcher implements AIProviderSwitcher {
|
|
78
|
-
|
|
83
|
+
/**
|
|
84
|
+
* The vendors it was constructed with: {@link TieredAIProviderSwitcher.setAvailableVendors}
|
|
85
|
+
* chooses among these and never adds one.
|
|
86
|
+
*/
|
|
87
|
+
private readonly builtVendors;
|
|
88
|
+
private _vendors;
|
|
79
89
|
private readonly options;
|
|
80
90
|
private readonly defaultTier;
|
|
81
91
|
private readonly registry;
|
|
82
92
|
private readonly listeners;
|
|
83
93
|
private _vendor;
|
|
94
|
+
/** Who chooses the vendor, as the options said. */
|
|
95
|
+
readonly vendorChoice?: AIVendorChoice;
|
|
84
96
|
constructor(options: TieredAIProviderSwitcherOptions);
|
|
85
97
|
get vendor(): AITierVendor;
|
|
98
|
+
/**
|
|
99
|
+
* The vendors it can switch between now: `vendors` as constructed, unless
|
|
100
|
+
* {@link TieredAIProviderSwitcher.setAvailableVendors} has narrowed them since.
|
|
101
|
+
*/
|
|
102
|
+
get vendors(): readonly AITierVendor[];
|
|
103
|
+
/**
|
|
104
|
+
* Change which vendors are available, within the ones it was constructed with, and optionally
|
|
105
|
+
* which one is active — in one registry rebuild.
|
|
106
|
+
*
|
|
107
|
+
* @remarks
|
|
108
|
+
* For a host that learns at runtime which vendors its proxy can serve. Genesis Create's preview
|
|
109
|
+
* is the one today: the app is built before the user picks a vendor there, so it registers every
|
|
110
|
+
* vendor and narrows to the ones Create offers once it has asked. The standby entries follow
|
|
111
|
+
* the list, so the assistant's budget-wall banner offers a switch only to a vendor that can
|
|
112
|
+
* answer.
|
|
113
|
+
*
|
|
114
|
+
* `active` is adopted the way {@link TieredAIProviderSwitcher.adoptPersistedVendor} adopts a
|
|
115
|
+
* vendor: subscribers hear of a change, `onSwitch` does not fire. Left out, the active vendor
|
|
116
|
+
* stays when the new list keeps it and becomes the list's first when it does not.
|
|
117
|
+
*
|
|
118
|
+
* Ignored as a whole — nothing changes — when no listed vendor is one it was constructed with,
|
|
119
|
+
* or when `active` is not in the list. A call that changes neither the list nor the vendor
|
|
120
|
+
* leaves the registry alone, so a host may repeat it as often as it asks.
|
|
121
|
+
*/
|
|
122
|
+
setAvailableVendors(vendors: readonly string[], active?: string): void;
|
|
86
123
|
/**
|
|
87
124
|
* A user-driven switch: move the registry, then tell the app so it can persist the choice.
|
|
88
125
|
* An unknown vendor is ignored.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiered-provider-switcher.d.ts","sourceRoot":"","sources":["../../../src/provider/tiered-provider-switcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,YAAY,EAElB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"tiered-provider-switcher.d.ts","sourceRoot":"","sources":["../../../src/provider/tiered-provider-switcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,YAAY,EAElB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEjF;;;;GAIG;AACH,MAAM,WAAW,+BAA+B;IAC9C,2DAA2D;IAC3D,SAAS,EAAE,SAAS,CAAC;IACrB;;;;;;;;;;OAUG;IACH,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,MAAM,CAAC;IACjD;;;;OAIG;IACH,aAAa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,IAAI;IAQzD,mEAAmE;IACnE,OAAO,CAAC,KAAK;IAOb,OAAO,CAAC,KAAK;IAyBb,OAAO,CAAC,aAAa;CAGtB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,IAAI,CAAC,+BAA+B,EAAE,WAAW,CAAC,GAC1D,wBAAwB,CAI1B"}
|
|
@@ -71,7 +71,7 @@ ANTHROPIC_CACHE_READ_MULTIPLIER, ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER, ANTHROPIC_
|
|
|
71
71
|
// between the two cost functions above without maintaining its own model→vendor map.
|
|
72
72
|
vendorOfModel,
|
|
73
73
|
// The platform tier table (GENC-1610). Here for the same anti-drift reason as the model
|
|
74
|
-
// lists: a server-side host that pins its own `claude-sonnet-5` string is a second copy of
|
|
74
|
+
// lists: a server-side host that pins its own `claude-sonnet-5-5` string is a second copy of
|
|
75
75
|
// a decision that gets re-benched, and the two only disagree once the table moves.
|
|
76
76
|
//
|
|
77
77
|
// The DATA half only. `buildTierProviders` is deliberately absent and must stay absent: it
|
|
@@ -430,13 +430,14 @@ export class ChatDriver extends EventTarget {
|
|
|
430
430
|
* Reset per turn alongside `budgetWallDetail`.
|
|
431
431
|
*/
|
|
432
432
|
this.budgetWallViaSubAgent = false;
|
|
433
|
-
const { toolHandlers = {}, toolDefinitions = [], systemPrompt, primerHistory, maxToolIterations = DEFAULT_MAX_TOOL_ITERATIONS, maxFoldOperations = DEFAULT_MAX_FOLD_OPERATIONS, condenseBatchCalls = 1, maxTurnSnapshots = DEFAULT_MAX_TURN_SNAPSHOTS, sessionKey = '', deferAgentRelease = false, activityBus = NOOP_ACTIVITY_BUS, budgetExhaustedMessage, providerRefusedMessage, aiServiceErrorMessages, } = config;
|
|
433
|
+
const { toolHandlers = {}, toolDefinitions = [], systemPrompt, primerHistory, maxToolIterations = DEFAULT_MAX_TOOL_ITERATIONS, maxFoldOperations = DEFAULT_MAX_FOLD_OPERATIONS, condenseBatchCalls = 1, maxTurnSnapshots = DEFAULT_MAX_TURN_SNAPSHOTS, sessionKey = '', deferAgentRelease = false, activityBus = NOOP_ACTIVITY_BUS, budgetExhaustedMessage, vendorSwitchPlace = 'in Settings', providerRefusedMessage, aiServiceErrorMessages, } = config;
|
|
434
434
|
this.maxToolIterations = maxToolIterations;
|
|
435
435
|
this.condenseBatchCalls = condenseBatchCalls;
|
|
436
436
|
this.sessionKey = sessionKey;
|
|
437
437
|
this.deferAgentRelease = deferAgentRelease;
|
|
438
438
|
this.activityBus = activityBus;
|
|
439
439
|
this.budgetExhaustedMessageOverride = budgetExhaustedMessage;
|
|
440
|
+
this.vendorSwitchPlace = vendorSwitchPlace;
|
|
440
441
|
this.providerRefusedMessageOverride = providerRefusedMessage;
|
|
441
442
|
this.aiServiceErrorMessagesOverride = aiServiceErrorMessages;
|
|
442
443
|
if (typeof toolHandlers === 'function') {
|
|
@@ -688,7 +689,7 @@ export class ChatDriver extends EventTarget {
|
|
|
688
689
|
const subject = (wall === null || wall === void 0 ? void 0 : wall.vendorLabel)
|
|
689
690
|
? `${wall.vendorLabel}'s AI usage limit`
|
|
690
691
|
: 'your AI usage limit';
|
|
691
|
-
return `You've reached ${subject}. Switch to another AI provider
|
|
692
|
+
return `You've reached ${subject}. Switch to another AI provider ${this.vendorSwitchPlace} to keep going, or contact your administrator to raise it.`;
|
|
692
693
|
}
|
|
693
694
|
/**
|
|
694
695
|
* Record a message the user sent and then stopped before any turn took it: during an
|
|
@@ -248,6 +248,7 @@ export class OrchestratingDriver extends BaseDriverDecorator {
|
|
|
248
248
|
sessionKey: (_a = options.sessionKey) !== null && _a !== void 0 ? _a : '',
|
|
249
249
|
activityBus: options.activityBus,
|
|
250
250
|
budgetExhaustedMessage: options.budgetExhaustedMessage,
|
|
251
|
+
vendorSwitchPlace: options.vendorSwitchPlace,
|
|
251
252
|
aiServiceErrorMessages: options.aiServiceErrorMessages,
|
|
252
253
|
// A release can hand back to a waiting caller, so this driver acts on the flag itself.
|
|
253
254
|
deferAgentRelease: true,
|
|
@@ -45,7 +45,10 @@ export class SettingsModalController {
|
|
|
45
45
|
// ─── AI Model section ───────────────────────────────────────────────────────
|
|
46
46
|
/** Whether the AI Model section has slotted content, context usage or budget figures. */
|
|
47
47
|
get modelSectionVisible() {
|
|
48
|
-
return (this.modelSlotted.length > 0 ||
|
|
48
|
+
return (this.modelSlotted.length > 0 ||
|
|
49
|
+
this.contextUsageVisible ||
|
|
50
|
+
this.deps.budgetUsageVisible() ||
|
|
51
|
+
this.deps.vendorPickerVisible());
|
|
49
52
|
}
|
|
50
53
|
/** Built-in context window indicator (generic platform concern). */
|
|
51
54
|
get contextUsageVisible() {
|
|
@@ -420,6 +420,65 @@ export const settingsModalStyles = css `
|
|
|
420
420
|
* does — see settingsUsageMetersTemplate for why an always-on one would cost
|
|
421
421
|
* a stray gap.
|
|
422
422
|
*/
|
|
423
|
+
/* The vendor picker: one card per vendor, a native radio in each. */
|
|
424
|
+
.settings-vendor-picker {
|
|
425
|
+
margin: 0;
|
|
426
|
+
padding: 0;
|
|
427
|
+
border: none;
|
|
428
|
+
min-width: 0;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
.settings-vendor-legend {
|
|
432
|
+
padding: 0;
|
|
433
|
+
margin-bottom: calc(var(--design-unit) * 2px);
|
|
434
|
+
font-weight: 600;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
.settings-vendor-cards {
|
|
438
|
+
display: grid;
|
|
439
|
+
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
|
|
440
|
+
gap: calc(var(--design-unit) * 2px);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
.settings-vendor-card {
|
|
444
|
+
display: flex;
|
|
445
|
+
align-items: center;
|
|
446
|
+
gap: calc(var(--design-unit) * 2px);
|
|
447
|
+
padding: calc(var(--design-unit) * 3px);
|
|
448
|
+
background: var(--neutral-layer-2);
|
|
449
|
+
border: 1px solid var(--neutral-stroke-rest);
|
|
450
|
+
border-radius: calc(var(--control-corner-radius) * 1.5px);
|
|
451
|
+
cursor: pointer;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
.settings-vendor-card:hover {
|
|
455
|
+
border-color: var(--neutral-stroke-hover);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
.settings-vendor-card.is-selected {
|
|
459
|
+
border-color: var(--accent-fill-rest);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
.settings-vendor-card:focus-within {
|
|
463
|
+
outline: calc(var(--focus-stroke-width) * 1px) solid var(--focus-stroke-outer);
|
|
464
|
+
outline-offset: 1px;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
.settings-vendor-picker:disabled .settings-vendor-card {
|
|
468
|
+
cursor: not-allowed;
|
|
469
|
+
opacity: 0.6;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
.settings-vendor-card input {
|
|
473
|
+
margin: 0;
|
|
474
|
+
accent-color: var(--accent-fill-rest);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
.settings-vendor-elsewhere {
|
|
478
|
+
margin: 0;
|
|
479
|
+
color: var(--neutral-foreground-hint);
|
|
480
|
+
}
|
|
481
|
+
|
|
423
482
|
.settings-usage-meters,
|
|
424
483
|
.settings-budget-usage {
|
|
425
484
|
display: flex;
|
|
@@ -771,6 +771,52 @@ export const agentLogSectionTemplate = (buttonTag, textareaTag) => html `
|
|
|
771
771
|
</section>
|
|
772
772
|
`)}
|
|
773
773
|
`;
|
|
774
|
+
/**
|
|
775
|
+
* The vendor control in the AI model section, as the `settings-model` slot's fallback: a card per
|
|
776
|
+
* vendor to pick from, or the active vendor read-only when it is chosen outside the app. Native radios in a fieldset, so the
|
|
777
|
+
* group, its label and arrow-key movement come from the browser; the fieldset's `disabled` turns
|
|
778
|
+
* every card off while a turn computes.
|
|
779
|
+
*
|
|
780
|
+
* @internal
|
|
781
|
+
*/
|
|
782
|
+
/**
|
|
783
|
+
* The read-only vendor line, as one string: split across markup, a formatter's line break
|
|
784
|
+
* renders as a space before the comma.
|
|
785
|
+
*/
|
|
786
|
+
const vendorElsewhereLine = (elsewhere) => elsewhere ? `AI vendor: ${elsewhere.label}, selected in ${elsewhere.where}.` : '';
|
|
787
|
+
export const settingsVendorTemplate = html `
|
|
788
|
+
${when((x) => x.settingsVendorPickerVisible, html `
|
|
789
|
+
<fieldset
|
|
790
|
+
class="settings-vendor-picker"
|
|
791
|
+
part="settings-vendor-picker"
|
|
792
|
+
?disabled=${(x) => x.settingsVendorPickerDisabled}
|
|
793
|
+
>
|
|
794
|
+
<legend class="settings-vendor-legend">AI vendor</legend>
|
|
795
|
+
<div class="settings-vendor-cards">
|
|
796
|
+
${repeat((x) => x.settingsVendorOptions, html `
|
|
797
|
+
<label
|
|
798
|
+
class="settings-vendor-card ${(o) => (o.checked ? 'is-selected' : '')}"
|
|
799
|
+
part="settings-vendor-card"
|
|
800
|
+
>
|
|
801
|
+
<input
|
|
802
|
+
type="radio"
|
|
803
|
+
name="settings-ai-vendor"
|
|
804
|
+
value=${(o) => o.vendor}
|
|
805
|
+
:checked=${(o) => o.checked}
|
|
806
|
+
@change=${(o, c) => c.parent.selectSettingsVendor(o.vendor)}
|
|
807
|
+
/>
|
|
808
|
+
<span class="settings-vendor-card-label">${(o) => o.label}</span>
|
|
809
|
+
</label>
|
|
810
|
+
`)}
|
|
811
|
+
</div>
|
|
812
|
+
</fieldset>
|
|
813
|
+
`)}
|
|
814
|
+
${when((x) => x.settingsVendorSelectedElsewhere, html `
|
|
815
|
+
<p class="settings-vendor-elsewhere" part="settings-vendor-elsewhere">
|
|
816
|
+
${(x) => vendorElsewhereLine(x.settingsVendorSelectedElsewhere)}
|
|
817
|
+
</p>
|
|
818
|
+
`)}
|
|
819
|
+
`;
|
|
774
820
|
/**
|
|
775
821
|
* Modal shell for assistant settings — Configuration and Usage tabs, section slots for
|
|
776
822
|
* app-specific UI, and built-in chat-bot toggles.
|
|
@@ -803,7 +849,14 @@ export const SettingsModalTemplate = (designSystemPrefix) => {
|
|
|
803
849
|
<${iconTag} name="microchip"></${iconTag}> AI Model Settings
|
|
804
850
|
</h3>
|
|
805
851
|
<div class="settings-modal-section-body">
|
|
806
|
-
|
|
852
|
+
<!--
|
|
853
|
+
The vendor picker is this slot's fallback: a host that slots its own model settings
|
|
854
|
+
(Genesis Create's gc-assistant-settings-model) keeps only its own. The template also
|
|
855
|
+
checks settingsModelSlotted, so the rule holds without relying on slot rendering.
|
|
856
|
+
-->
|
|
857
|
+
<slot name="settings-model" ${slotted('settingsModelSlotted')}>
|
|
858
|
+
${settingsVendorTemplate}
|
|
859
|
+
</slot>
|
|
807
860
|
${settingsUsageMetersTemplate(progressTag, buttonTag, iconTag)}
|
|
808
861
|
</div>
|
|
809
862
|
</section>
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import { isAIFeatureEnabled, resolveAITiers } from '@genesislcap/foundation-ai';
|
|
2
|
+
import { AI_TIER_VENDORS, isAIFeatureEnabled, resolveAITiers, } from '@genesislcap/foundation-ai';
|
|
3
|
+
import { User } from '@genesislcap/foundation-comms';
|
|
3
4
|
import { PUBLIC_PATH } from '@genesislcap/foundation-utils';
|
|
4
5
|
import { DI } from '@genesislcap/web-core';
|
|
6
|
+
import { agenticActivityBus } from '../channel/ai-activity-bus';
|
|
5
7
|
import { registerTieredAIProviders, } from '../provider/tiered-provider-switcher';
|
|
6
8
|
import { logger } from '../utils/logger';
|
|
7
9
|
import { toolNameOf, validateGenesisAiConfig } from './config';
|
|
8
10
|
import { createGenesisResourceTools } from './resource-tools';
|
|
11
|
+
import { followServerVendor } from './vendor-follower';
|
|
12
|
+
import { vendorPickStore } from './vendor-pick';
|
|
9
13
|
import { createGenesisWriteTools, mintFeedbackKey } from './write-tools';
|
|
10
14
|
/**
|
|
11
15
|
* The name of the agent {@link registerGenesisAssistant} builds.
|
|
@@ -137,6 +141,38 @@ export function defaultEndpointBase(publicPath = PUBLIC_PATH) {
|
|
|
137
141
|
* what lets a test set it.
|
|
138
142
|
*/
|
|
139
143
|
const buildChatBase = () => typeof GENX_AI_CHAT_BASE !== 'undefined' ? String(GENX_AI_CHAT_BASE).trim() : '';
|
|
144
|
+
/**
|
|
145
|
+
* The base the chat posts to as `<base>/<vendor>/chat`, and asks `<base>/vendor` at: the app's
|
|
146
|
+
* own `endpointBase`, else {@link defaultEndpointBase}. Trailing slashes trimmed.
|
|
147
|
+
*
|
|
148
|
+
* @internal
|
|
149
|
+
*/
|
|
150
|
+
export function chatEndpointBase(options = {}) {
|
|
151
|
+
var _a;
|
|
152
|
+
return ((_a = options.endpointBase) !== null && _a !== void 0 ? _a : defaultEndpointBase()).replace(/\/+$/, '');
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Whether the app is running in Genesis Create's preview: a build-time `GENX_AI_CHAT_BASE`, which
|
|
156
|
+
* only the preview sets, that the app has not replaced with an `endpointBase` of its own. Create
|
|
157
|
+
* chooses the vendor there, so the assistant's settings show it read-only.
|
|
158
|
+
*
|
|
159
|
+
* @internal
|
|
160
|
+
*/
|
|
161
|
+
export function inCreatePreview(options = {}) {
|
|
162
|
+
const ownBase = options.endpointBase !== undefined && options.endpointBase !== null;
|
|
163
|
+
return !ownBase && buildChatBase() !== '';
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* The vendors the chat offers before its AI proxy has said which it can serve, and for good when
|
|
167
|
+
* the proxy cannot say: the app's own `vendors`, else the configured vendor alone. Exactly what
|
|
168
|
+
* the bridge registered before it asked the proxy at all.
|
|
169
|
+
*
|
|
170
|
+
* @internal
|
|
171
|
+
*/
|
|
172
|
+
export function startingVendors(config, options = {}) {
|
|
173
|
+
var _a, _b;
|
|
174
|
+
return (_a = options.vendors) !== null && _a !== void 0 ? _a : [(_b = config.vendor) !== null && _b !== void 0 ? _b : 'gemini'];
|
|
175
|
+
}
|
|
140
176
|
/**
|
|
141
177
|
* The provider options {@link registerGenesisAssistant} registers — split out so the choice of
|
|
142
178
|
* vendor, tier and endpoint can be checked without building providers.
|
|
@@ -149,13 +185,20 @@ const buildChatBase = () => typeof GENX_AI_CHAT_BASE !== 'undefined' ? String(GE
|
|
|
149
185
|
* @internal
|
|
150
186
|
*/
|
|
151
187
|
export function genesisProviderOptions(config, options = {}) {
|
|
152
|
-
var _a, _b, _c
|
|
188
|
+
var _a, _b, _c;
|
|
153
189
|
const vendor = (_a = config.vendor) !== null && _a !== void 0 ? _a : 'gemini';
|
|
154
|
-
const base = (
|
|
190
|
+
const base = chatEndpointBase(options);
|
|
155
191
|
return {
|
|
156
192
|
initialVendor: vendor,
|
|
157
|
-
|
|
158
|
-
|
|
193
|
+
// In Create's preview the user picks the vendor in Create; anywhere else, in the assistant's
|
|
194
|
+
// settings, which show a card per vendor once the proxy offers two or more.
|
|
195
|
+
vendorChoice: inCreatePreview(options)
|
|
196
|
+
? { kind: 'elsewhere', where: 'Genesis Create' }
|
|
197
|
+
: { kind: 'in-app' },
|
|
198
|
+
// Every vendor the chat might be told it can use. registerGenesisAssistant narrows to
|
|
199
|
+
// startingVendors straight away, and the proxy's answer chooses among these.
|
|
200
|
+
vendors: (_b = options.vendors) !== null && _b !== void 0 ? _b : AI_TIER_VENDORS,
|
|
201
|
+
defaultTier: (_c = config.tier) !== null && _c !== void 0 ? _c : 'high',
|
|
159
202
|
tiers: resolveAITiers(),
|
|
160
203
|
serverEndpoint: (v) => `${base}/${v}/chat`,
|
|
161
204
|
};
|
|
@@ -184,7 +227,7 @@ export function genesisProviderOptions(config, options = {}) {
|
|
|
184
227
|
* @beta
|
|
185
228
|
*/
|
|
186
229
|
export function registerGenesisAssistant(options) {
|
|
187
|
-
var _a, _b, _c, _d;
|
|
230
|
+
var _a, _b, _c, _d, _e, _f;
|
|
188
231
|
/**
|
|
189
232
|
* `off` is a choice (AI switched off in the build or the config), `fault` is anything else.
|
|
190
233
|
* Named at every call rather than defaulted: which sentence the user reads, and whether the
|
|
@@ -302,12 +345,34 @@ export function registerGenesisAssistant(options) {
|
|
|
302
345
|
return blocked('fault', 'rowSources must be an object of event name to request resource name.');
|
|
303
346
|
}
|
|
304
347
|
let switcher;
|
|
348
|
+
const providerOptions = genesisProviderOptions(config, options);
|
|
349
|
+
const container = (_d = options.container) !== null && _d !== void 0 ? _d : DI.getOrCreateDOMContainer();
|
|
350
|
+
const base = chatEndpointBase(options);
|
|
351
|
+
// A pick made in the settings, remembered per user and app. Only where the user picks: in
|
|
352
|
+
// Create's preview, Create does, and the proxy's answer is followed as it is.
|
|
353
|
+
const picks = ((_e = providerOptions.vendorChoice) === null || _e === void 0 ? void 0 : _e.kind) === 'in-app'
|
|
354
|
+
? vendorPickStore({ base, user: () => { var _a; return (_a = container.get(User)) === null || _a === void 0 ? void 0 : _a.userName; } })
|
|
355
|
+
: undefined;
|
|
305
356
|
try {
|
|
306
|
-
switcher = registerTieredAIProviders((
|
|
357
|
+
switcher = registerTieredAIProviders(container, Object.assign(Object.assign({}, providerOptions), { onSwitch: picks ? (vendor) => picks.write(vendor) : undefined }));
|
|
307
358
|
}
|
|
308
359
|
catch (error) {
|
|
309
360
|
return blocked('fault', `The AI providers could not be registered: ${error.message}`);
|
|
310
361
|
}
|
|
362
|
+
// Starts as the bridge always has, on the configured vendor alone (or the app's own list), and
|
|
363
|
+
// stays there unless the proxy answers which vendors it can serve: in Create's preview, the one
|
|
364
|
+
// the user selected there; in an exported app, the ones whose key its server holds. Still
|
|
365
|
+
// synchronous, before the element can resolve a provider. Lives as long as the page does.
|
|
366
|
+
const starting = startingVendors(config, options);
|
|
367
|
+
switcher.setAvailableVendors(starting);
|
|
368
|
+
followServerVendor({
|
|
369
|
+
base,
|
|
370
|
+
switcher,
|
|
371
|
+
vendors: (_f = providerOptions.vendors) !== null && _f !== void 0 ? _f : AI_TIER_VENDORS,
|
|
372
|
+
fallback: { vendors: starting, vendor: providerOptions.initialVendor },
|
|
373
|
+
picked: picks ? () => picks.read() : undefined,
|
|
374
|
+
bus: agenticActivityBus,
|
|
375
|
+
});
|
|
311
376
|
// The last check that can block is behind us.
|
|
312
377
|
for (const line of leftOut)
|
|
313
378
|
logger.warn(`Genesis assistant: ${line}`);
|