@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
|
@@ -856,7 +856,7 @@
|
|
|
856
856
|
{
|
|
857
857
|
"kind": "PropertySignature",
|
|
858
858
|
"canonicalReference": "@genesislcap/ai-assistant!AgenticActivityEvents#\"tool-loop-end\":member",
|
|
859
|
-
"docComment": "/**\n * Fired when the tool loop completes for the current turn and control returns to the user on the **main chat prompt** (i.e. the next free-form user message can now be accepted).\n *\n * Boundary: this is the moment the user regains control of the main chat input. It is **not** fired when a tool handler hands a widget to the user mid-loop (e.g. while a planning widget is awaiting a click) — widget pauses are still inside the loop, the assistant still owns the turn, and the main chat input may be hidden during them. Wait for this event when you need to know that the assistant is fully idle and the user can type freely again.\n *\n * Emitted from the finally block of each `ChatDriver`'s `sendMessage` and `continueFromHistory`, so a multi-agent handoff fires this event once per agent.\n *\n * Distinct from {@link AgenticActivityEvents.'halo-stop'} — the halo event tracks the spinner animation lifecycle (which can flap mid-turn as tool calls resolve), whereas this event is a one-shot per turn boundary. Use this for hooks tied to a turn ending (telemetry flushes, post-turn workspace transitions, deferred state recomputation).\n */\n",
|
|
859
|
+
"docComment": "/**\n * Fired when the tool loop completes for the current turn and control returns to the user on the **main chat prompt** (i.e. the next free-form user message can now be accepted).\n *\n * Boundary: this is the moment the user regains control of the main chat input. It is **not** fired when a tool handler hands a widget to the user mid-loop (e.g. while a planning widget is awaiting a click) — widget pauses are still inside the loop, the assistant still owns the turn, and the main chat input may be hidden during them. Wait for this event when you need to know that the assistant is fully idle and the user can type freely again.\n *\n * Emitted from the finally block of each `ChatDriver`'s `sendMessage` and `continueFromHistory`, so a multi-agent handoff fires this event once per agent.\n *\n * Distinct from {@link AgenticActivityEvents.'halo-stop'} — the halo event tracks the spinner animation lifecycle (which can flap mid-turn as tool calls resolve), whereas this event is a one-shot per turn boundary. Use this for hooks tied to a turn ending (telemetry flushes, post-turn workspace transitions, deferred state recomputation).\n *\n * The detail carries the turn's outcome (PTC-0): on a failure it is `{ failureReason }` with the typed `TurnFailureReason`; on a clean completion, a user cancel, a driver dispose, and an agent handoff the detail is `undefined` — the historical shape, kept byte-identical so subscribers that only care about the boundary can keep ignoring it. Structured-cloneable so it survives the cross-tab BroadcastChannel hop.\n */\n",
|
|
860
860
|
"excerptTokens": [
|
|
861
861
|
{
|
|
862
862
|
"kind": "Content",
|
|
@@ -864,7 +864,16 @@
|
|
|
864
864
|
},
|
|
865
865
|
{
|
|
866
866
|
"kind": "Content",
|
|
867
|
-
"text": "
|
|
867
|
+
"text": "{\n failureReason?: "
|
|
868
|
+
},
|
|
869
|
+
{
|
|
870
|
+
"kind": "Reference",
|
|
871
|
+
"text": "TurnFailureReason",
|
|
872
|
+
"canonicalReference": "@genesislcap/foundation-ai!TurnFailureReason:type"
|
|
873
|
+
},
|
|
874
|
+
{
|
|
875
|
+
"kind": "Content",
|
|
876
|
+
"text": ";\n } | undefined"
|
|
868
877
|
},
|
|
869
878
|
{
|
|
870
879
|
"kind": "Content",
|
|
@@ -877,7 +886,7 @@
|
|
|
877
886
|
"name": "\"tool-loop-end\"",
|
|
878
887
|
"propertyTypeTokenRange": {
|
|
879
888
|
"startIndex": 1,
|
|
880
|
-
"endIndex":
|
|
889
|
+
"endIndex": 4
|
|
881
890
|
}
|
|
882
891
|
},
|
|
883
892
|
{
|
package/dist/ai-assistant.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { InterfaceSymbol } from '@microsoft/fast-foundation';
|
|
|
18
18
|
import type { Modal } from '@genesislcap/rapid-design-system';
|
|
19
19
|
import { ModelTagAppearance } from '@genesislcap/foundation-ai';
|
|
20
20
|
import type { SubAgentFailureReason } from '@genesislcap/foundation-ai';
|
|
21
|
+
import type { TurnFailureReason } from '@genesislcap/foundation-ai';
|
|
21
22
|
import { ViewTemplate } from '@genesislcap/web-core';
|
|
22
23
|
|
|
23
24
|
/** Sentinel value used by the segmented control / select to represent "Auto". */
|
|
@@ -179,8 +180,16 @@ export declare interface AgenticActivityEvents {
|
|
|
179
180
|
* spinner animation lifecycle (which can flap mid-turn as tool calls resolve), whereas
|
|
180
181
|
* this event is a one-shot per turn boundary. Use this for hooks tied to a turn ending
|
|
181
182
|
* (telemetry flushes, post-turn workspace transitions, deferred state recomputation).
|
|
183
|
+
*
|
|
184
|
+
* The detail carries the turn's outcome (PTC-0): on a failure it is `{ failureReason }`
|
|
185
|
+
* with the typed `TurnFailureReason`; on a clean completion, a user cancel, a
|
|
186
|
+
* driver dispose, and an agent handoff the detail is `undefined` — the historical shape,
|
|
187
|
+
* kept byte-identical so subscribers that only care about the boundary can keep ignoring
|
|
188
|
+
* it. Structured-cloneable so it survives the cross-tab BroadcastChannel hop.
|
|
182
189
|
*/
|
|
183
|
-
'tool-loop-end':
|
|
190
|
+
'tool-loop-end': {
|
|
191
|
+
failureReason?: TurnFailureReason;
|
|
192
|
+
} | undefined;
|
|
184
193
|
/**
|
|
185
194
|
* Fired when a tool handler hands a widget to the user mid-loop and parks awaiting it
|
|
186
195
|
* (`requestInteraction`) — the turn is suspended between provider calls, with no request
|
|
@@ -1268,6 +1277,23 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
1268
1277
|
* cached history would otherwise gain a stray marker on remount).
|
|
1269
1278
|
*/
|
|
1270
1279
|
private completeAbortedTurn;
|
|
1280
|
+
/**
|
|
1281
|
+
* Build the `done` loop result, carrying the typed failure reason when the turn
|
|
1282
|
+
* bailed (PTC-0). The discriminant stays `'done'` either way — the same value a
|
|
1283
|
+
* clean turn returns — so consumers matching on `reason === 'done'` are unchanged;
|
|
1284
|
+
* `failureReason` is simply present on a failure and absent on success. Omitted
|
|
1285
|
+
* (rather than set to `undefined`) so a happy-path result stays byte-identical to
|
|
1286
|
+
* the historical `{ reason: 'done' }`.
|
|
1287
|
+
*/
|
|
1288
|
+
private turnDone;
|
|
1289
|
+
/** The typed failure reason on a loop result, or `undefined` for a clean turn / handoff. */
|
|
1290
|
+
private static failureReasonOf;
|
|
1291
|
+
/**
|
|
1292
|
+
* Build the `tool-loop-end` event detail for a turn's result. A failure carries a
|
|
1293
|
+
* `{ failureReason }` detail; a clean turn emits `undefined` — the historical shape,
|
|
1294
|
+
* kept byte-identical so subscribers see exactly what they always have.
|
|
1295
|
+
*/
|
|
1296
|
+
private static loopEndDetail;
|
|
1271
1297
|
/**
|
|
1272
1298
|
* Swap in a new agent's configuration. Called by OrchestratingDriver before
|
|
1273
1299
|
* each specialist turn so the shared driver runs with the right tools and prompt.
|
|
@@ -3698,6 +3724,8 @@ export declare interface ToolTreeNode extends ChatToolDefinition {
|
|
|
3698
3724
|
tools?: ToolTreeNode[];
|
|
3699
3725
|
}
|
|
3700
3726
|
|
|
3727
|
+
export { TurnFailureReason }
|
|
3728
|
+
|
|
3701
3729
|
/**
|
|
3702
3730
|
* One captured frame of what the LLM saw on a single tool-loop iteration.
|
|
3703
3731
|
* The driver records these as a ring buffer (cap: configurable via
|
|
@@ -151,6 +151,14 @@
|
|
|
151
151
|
"package": "./utils/tool-fold"
|
|
152
152
|
}
|
|
153
153
|
},
|
|
154
|
+
{
|
|
155
|
+
"kind": "js",
|
|
156
|
+
"name": "TurnFailureReason",
|
|
157
|
+
"declaration": {
|
|
158
|
+
"name": "TurnFailureReason",
|
|
159
|
+
"module": "./state/debug-event-log"
|
|
160
|
+
}
|
|
161
|
+
},
|
|
154
162
|
{
|
|
155
163
|
"kind": "js",
|
|
156
164
|
"name": "TimelineMessage",
|
|
@@ -865,6 +873,195 @@
|
|
|
865
873
|
}
|
|
866
874
|
]
|
|
867
875
|
},
|
|
876
|
+
{
|
|
877
|
+
"kind": "javascript-module",
|
|
878
|
+
"path": "src/config/config.ts",
|
|
879
|
+
"declarations": [
|
|
880
|
+
{
|
|
881
|
+
"kind": "function",
|
|
882
|
+
"name": "defineAgent",
|
|
883
|
+
"description": "Identity helper that infers the narrowest possible type for an agent config,\npreserving string literal types (including `name`) without requiring `as const`.\n\nUse this when you need `typeof myAgent` to carry the literal `name` type —\nfor example, when wiring `ChatToolHandlers<typeof myAgent>`.\n\n```ts\nconst myAgent = defineAgent({ name: 'my_agent', ... });\ntype Handlers = ChatToolHandlers<typeof myAgent>;\n// requestSubAgent name param is now typed as 'my_agent'\n```"
|
|
884
|
+
}
|
|
885
|
+
],
|
|
886
|
+
"exports": [
|
|
887
|
+
{
|
|
888
|
+
"kind": "js",
|
|
889
|
+
"name": "CachePolicy",
|
|
890
|
+
"declaration": {
|
|
891
|
+
"name": "CachePolicy",
|
|
892
|
+
"module": "src/config/config.ts"
|
|
893
|
+
}
|
|
894
|
+
},
|
|
895
|
+
{
|
|
896
|
+
"kind": "js",
|
|
897
|
+
"name": "ChatInputDuringExecutionMode",
|
|
898
|
+
"declaration": {
|
|
899
|
+
"name": "ChatInputDuringExecutionMode",
|
|
900
|
+
"module": "src/config/config.ts"
|
|
901
|
+
}
|
|
902
|
+
},
|
|
903
|
+
{
|
|
904
|
+
"kind": "js",
|
|
905
|
+
"name": "ChatToolChoice",
|
|
906
|
+
"declaration": {
|
|
907
|
+
"name": "ChatToolChoice",
|
|
908
|
+
"module": "src/config/config.ts"
|
|
909
|
+
}
|
|
910
|
+
},
|
|
911
|
+
{
|
|
912
|
+
"kind": "js",
|
|
913
|
+
"name": "defineAgent",
|
|
914
|
+
"declaration": {
|
|
915
|
+
"name": "defineAgent",
|
|
916
|
+
"module": "src/config/config.ts"
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
]
|
|
920
|
+
},
|
|
921
|
+
{
|
|
922
|
+
"kind": "javascript-module",
|
|
923
|
+
"path": "src/config/define-stateful-agent.ts",
|
|
924
|
+
"declarations": [
|
|
925
|
+
{
|
|
926
|
+
"kind": "function",
|
|
927
|
+
"name": "restoreMachine",
|
|
928
|
+
"return": {
|
|
929
|
+
"type": {
|
|
930
|
+
"text": "void"
|
|
931
|
+
}
|
|
932
|
+
},
|
|
933
|
+
"parameters": [
|
|
934
|
+
{
|
|
935
|
+
"name": "machine",
|
|
936
|
+
"type": {
|
|
937
|
+
"text": "{ stop: () => void; start: (options?: { state?: unknown }) => void }"
|
|
938
|
+
},
|
|
939
|
+
"description": "the machine to restore (already constructed/started)."
|
|
940
|
+
},
|
|
941
|
+
{
|
|
942
|
+
"name": "restored",
|
|
943
|
+
"type": {
|
|
944
|
+
"text": "unknown"
|
|
945
|
+
},
|
|
946
|
+
"description": "the agent's serialized image (`ctx.restored` in `init`)."
|
|
947
|
+
},
|
|
948
|
+
{
|
|
949
|
+
"name": "key",
|
|
950
|
+
"default": "'machine'",
|
|
951
|
+
"description": "the property the machine occupies in the snapshot; defaults to\n`'machine'` to match the conventional `{ machine }` state bag."
|
|
952
|
+
}
|
|
953
|
+
],
|
|
954
|
+
"description": "Restore a foundation-state-machine instance from a snapshot produced by the\ndefault serializer (or `machine.getPersistedSnapshot()`). Call inside a\nstateful agent's `init` to resume the machine in its exact prior place:\n\n```ts\ninit: ({ restored }) => {\n const machine = new MyMachine();\n restoreMachine(machine, restored); // resume, or no-op on a fresh start\n return { machine };\n}\n```\n\nNo-ops when there is nothing to restore (a fresh session), leaving the\nfreshly-constructed machine in its initial state."
|
|
955
|
+
},
|
|
956
|
+
{
|
|
957
|
+
"kind": "function",
|
|
958
|
+
"name": "defineStatefulAgent",
|
|
959
|
+
"return": {
|
|
960
|
+
"type": {
|
|
961
|
+
"text": "AgentConfig"
|
|
962
|
+
}
|
|
963
|
+
},
|
|
964
|
+
"parameters": [
|
|
965
|
+
{
|
|
966
|
+
"name": "opts",
|
|
967
|
+
"type": {
|
|
968
|
+
"text": "StatefulAgentInit<S>"
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
],
|
|
972
|
+
"description": "Build an `AgentConfig` whose `systemPrompt`, `toolDefinitions`, and tool\nhandlers all close over a long-lived state object created on activation.\n\nThe framework wires the lifecycle: `init` on `onActivate`, `dispose` on\n`onDeactivate`. State is held inside the helper's closure — never exposed on\nthe resulting `AgentConfig` — so the redux serializer doesn't see it."
|
|
973
|
+
}
|
|
974
|
+
],
|
|
975
|
+
"exports": [
|
|
976
|
+
{
|
|
977
|
+
"kind": "js",
|
|
978
|
+
"name": "restoreMachine",
|
|
979
|
+
"declaration": {
|
|
980
|
+
"name": "restoreMachine",
|
|
981
|
+
"module": "src/config/define-stateful-agent.ts"
|
|
982
|
+
}
|
|
983
|
+
},
|
|
984
|
+
{
|
|
985
|
+
"kind": "js",
|
|
986
|
+
"name": "defineStatefulAgent",
|
|
987
|
+
"declaration": {
|
|
988
|
+
"name": "defineStatefulAgent",
|
|
989
|
+
"module": "src/config/define-stateful-agent.ts"
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
]
|
|
993
|
+
},
|
|
994
|
+
{
|
|
995
|
+
"kind": "javascript-module",
|
|
996
|
+
"path": "src/config/fallback-agents.ts",
|
|
997
|
+
"declarations": [
|
|
998
|
+
{
|
|
999
|
+
"kind": "variable",
|
|
1000
|
+
"name": "friendlyFallbackAgent",
|
|
1001
|
+
"type": {
|
|
1002
|
+
"text": "FallbackAgentConfig"
|
|
1003
|
+
},
|
|
1004
|
+
"default": "{\n name: 'Assistant',\n fallback: true,\n systemPrompt: `You are a warm, friendly assistant. For general conversation like \"Hi\" or \"How are you\", you can have a friendly chat. For anything more complex, you cannot directly help, but you can explain what specialists are available. The available specialists are:\\n\\n{{agents}}\\n\\nPolitely let the user know what you can help with and invite them to rephrase their request if it is outside your scope.`,\n}",
|
|
1005
|
+
"description": "A warm, conversational fallback agent. Acknowledges it can't help directly,\nexplains what the available specialists can do, and invites the user to retry.\n\nThe system prompt is generated at runtime by `OrchestratingDriver` from the\nspecialist list — no manual authoring required."
|
|
1006
|
+
},
|
|
1007
|
+
{
|
|
1008
|
+
"kind": "variable",
|
|
1009
|
+
"name": "strictFallbackAgent",
|
|
1010
|
+
"type": {
|
|
1011
|
+
"text": "FallbackAgentConfig"
|
|
1012
|
+
},
|
|
1013
|
+
"default": "{\n name: 'Assistant',\n fallback: true,\n systemPrompt: `You are a concise assistant. The user's request is outside your scope. Respond with a single short sentence stating what you can assist with. Do not elaborate. The available specialists are: {{agents}}.`,\n}",
|
|
1014
|
+
"description": "A brief, professional fallback agent. States what is available without\nelaboration. The `{{agents}}` placeholder is replaced at runtime by\n`OrchestratingDriver` with the generated specialist list."
|
|
1015
|
+
}
|
|
1016
|
+
],
|
|
1017
|
+
"exports": [
|
|
1018
|
+
{
|
|
1019
|
+
"kind": "js",
|
|
1020
|
+
"name": "friendlyFallbackAgent",
|
|
1021
|
+
"declaration": {
|
|
1022
|
+
"name": "friendlyFallbackAgent",
|
|
1023
|
+
"module": "src/config/fallback-agents.ts"
|
|
1024
|
+
}
|
|
1025
|
+
},
|
|
1026
|
+
{
|
|
1027
|
+
"kind": "js",
|
|
1028
|
+
"name": "strictFallbackAgent",
|
|
1029
|
+
"declaration": {
|
|
1030
|
+
"name": "strictFallbackAgent",
|
|
1031
|
+
"module": "src/config/fallback-agents.ts"
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
]
|
|
1035
|
+
},
|
|
1036
|
+
{
|
|
1037
|
+
"kind": "javascript-module",
|
|
1038
|
+
"path": "src/config/index.ts",
|
|
1039
|
+
"declarations": [],
|
|
1040
|
+
"exports": [
|
|
1041
|
+
{
|
|
1042
|
+
"kind": "js",
|
|
1043
|
+
"name": "*",
|
|
1044
|
+
"declaration": {
|
|
1045
|
+
"name": "*",
|
|
1046
|
+
"package": "./config"
|
|
1047
|
+
}
|
|
1048
|
+
},
|
|
1049
|
+
{
|
|
1050
|
+
"kind": "js",
|
|
1051
|
+
"name": "*",
|
|
1052
|
+
"declaration": {
|
|
1053
|
+
"name": "*",
|
|
1054
|
+
"package": "./fallback-agents"
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
]
|
|
1058
|
+
},
|
|
1059
|
+
{
|
|
1060
|
+
"kind": "javascript-module",
|
|
1061
|
+
"path": "src/config/validate-providers.ts",
|
|
1062
|
+
"declarations": [],
|
|
1063
|
+
"exports": []
|
|
1064
|
+
},
|
|
868
1065
|
{
|
|
869
1066
|
"kind": "javascript-module",
|
|
870
1067
|
"path": "src/main/index.ts",
|
|
@@ -3536,195 +3733,6 @@
|
|
|
3536
3733
|
}
|
|
3537
3734
|
]
|
|
3538
3735
|
},
|
|
3539
|
-
{
|
|
3540
|
-
"kind": "javascript-module",
|
|
3541
|
-
"path": "src/config/config.ts",
|
|
3542
|
-
"declarations": [
|
|
3543
|
-
{
|
|
3544
|
-
"kind": "function",
|
|
3545
|
-
"name": "defineAgent",
|
|
3546
|
-
"description": "Identity helper that infers the narrowest possible type for an agent config,\npreserving string literal types (including `name`) without requiring `as const`.\n\nUse this when you need `typeof myAgent` to carry the literal `name` type —\nfor example, when wiring `ChatToolHandlers<typeof myAgent>`.\n\n```ts\nconst myAgent = defineAgent({ name: 'my_agent', ... });\ntype Handlers = ChatToolHandlers<typeof myAgent>;\n// requestSubAgent name param is now typed as 'my_agent'\n```"
|
|
3547
|
-
}
|
|
3548
|
-
],
|
|
3549
|
-
"exports": [
|
|
3550
|
-
{
|
|
3551
|
-
"kind": "js",
|
|
3552
|
-
"name": "CachePolicy",
|
|
3553
|
-
"declaration": {
|
|
3554
|
-
"name": "CachePolicy",
|
|
3555
|
-
"module": "src/config/config.ts"
|
|
3556
|
-
}
|
|
3557
|
-
},
|
|
3558
|
-
{
|
|
3559
|
-
"kind": "js",
|
|
3560
|
-
"name": "ChatInputDuringExecutionMode",
|
|
3561
|
-
"declaration": {
|
|
3562
|
-
"name": "ChatInputDuringExecutionMode",
|
|
3563
|
-
"module": "src/config/config.ts"
|
|
3564
|
-
}
|
|
3565
|
-
},
|
|
3566
|
-
{
|
|
3567
|
-
"kind": "js",
|
|
3568
|
-
"name": "ChatToolChoice",
|
|
3569
|
-
"declaration": {
|
|
3570
|
-
"name": "ChatToolChoice",
|
|
3571
|
-
"module": "src/config/config.ts"
|
|
3572
|
-
}
|
|
3573
|
-
},
|
|
3574
|
-
{
|
|
3575
|
-
"kind": "js",
|
|
3576
|
-
"name": "defineAgent",
|
|
3577
|
-
"declaration": {
|
|
3578
|
-
"name": "defineAgent",
|
|
3579
|
-
"module": "src/config/config.ts"
|
|
3580
|
-
}
|
|
3581
|
-
}
|
|
3582
|
-
]
|
|
3583
|
-
},
|
|
3584
|
-
{
|
|
3585
|
-
"kind": "javascript-module",
|
|
3586
|
-
"path": "src/config/define-stateful-agent.ts",
|
|
3587
|
-
"declarations": [
|
|
3588
|
-
{
|
|
3589
|
-
"kind": "function",
|
|
3590
|
-
"name": "restoreMachine",
|
|
3591
|
-
"return": {
|
|
3592
|
-
"type": {
|
|
3593
|
-
"text": "void"
|
|
3594
|
-
}
|
|
3595
|
-
},
|
|
3596
|
-
"parameters": [
|
|
3597
|
-
{
|
|
3598
|
-
"name": "machine",
|
|
3599
|
-
"type": {
|
|
3600
|
-
"text": "{ stop: () => void; start: (options?: { state?: unknown }) => void }"
|
|
3601
|
-
},
|
|
3602
|
-
"description": "the machine to restore (already constructed/started)."
|
|
3603
|
-
},
|
|
3604
|
-
{
|
|
3605
|
-
"name": "restored",
|
|
3606
|
-
"type": {
|
|
3607
|
-
"text": "unknown"
|
|
3608
|
-
},
|
|
3609
|
-
"description": "the agent's serialized image (`ctx.restored` in `init`)."
|
|
3610
|
-
},
|
|
3611
|
-
{
|
|
3612
|
-
"name": "key",
|
|
3613
|
-
"default": "'machine'",
|
|
3614
|
-
"description": "the property the machine occupies in the snapshot; defaults to\n`'machine'` to match the conventional `{ machine }` state bag."
|
|
3615
|
-
}
|
|
3616
|
-
],
|
|
3617
|
-
"description": "Restore a foundation-state-machine instance from a snapshot produced by the\ndefault serializer (or `machine.getPersistedSnapshot()`). Call inside a\nstateful agent's `init` to resume the machine in its exact prior place:\n\n```ts\ninit: ({ restored }) => {\n const machine = new MyMachine();\n restoreMachine(machine, restored); // resume, or no-op on a fresh start\n return { machine };\n}\n```\n\nNo-ops when there is nothing to restore (a fresh session), leaving the\nfreshly-constructed machine in its initial state."
|
|
3618
|
-
},
|
|
3619
|
-
{
|
|
3620
|
-
"kind": "function",
|
|
3621
|
-
"name": "defineStatefulAgent",
|
|
3622
|
-
"return": {
|
|
3623
|
-
"type": {
|
|
3624
|
-
"text": "AgentConfig"
|
|
3625
|
-
}
|
|
3626
|
-
},
|
|
3627
|
-
"parameters": [
|
|
3628
|
-
{
|
|
3629
|
-
"name": "opts",
|
|
3630
|
-
"type": {
|
|
3631
|
-
"text": "StatefulAgentInit<S>"
|
|
3632
|
-
}
|
|
3633
|
-
}
|
|
3634
|
-
],
|
|
3635
|
-
"description": "Build an `AgentConfig` whose `systemPrompt`, `toolDefinitions`, and tool\nhandlers all close over a long-lived state object created on activation.\n\nThe framework wires the lifecycle: `init` on `onActivate`, `dispose` on\n`onDeactivate`. State is held inside the helper's closure — never exposed on\nthe resulting `AgentConfig` — so the redux serializer doesn't see it."
|
|
3636
|
-
}
|
|
3637
|
-
],
|
|
3638
|
-
"exports": [
|
|
3639
|
-
{
|
|
3640
|
-
"kind": "js",
|
|
3641
|
-
"name": "restoreMachine",
|
|
3642
|
-
"declaration": {
|
|
3643
|
-
"name": "restoreMachine",
|
|
3644
|
-
"module": "src/config/define-stateful-agent.ts"
|
|
3645
|
-
}
|
|
3646
|
-
},
|
|
3647
|
-
{
|
|
3648
|
-
"kind": "js",
|
|
3649
|
-
"name": "defineStatefulAgent",
|
|
3650
|
-
"declaration": {
|
|
3651
|
-
"name": "defineStatefulAgent",
|
|
3652
|
-
"module": "src/config/define-stateful-agent.ts"
|
|
3653
|
-
}
|
|
3654
|
-
}
|
|
3655
|
-
]
|
|
3656
|
-
},
|
|
3657
|
-
{
|
|
3658
|
-
"kind": "javascript-module",
|
|
3659
|
-
"path": "src/config/fallback-agents.ts",
|
|
3660
|
-
"declarations": [
|
|
3661
|
-
{
|
|
3662
|
-
"kind": "variable",
|
|
3663
|
-
"name": "friendlyFallbackAgent",
|
|
3664
|
-
"type": {
|
|
3665
|
-
"text": "FallbackAgentConfig"
|
|
3666
|
-
},
|
|
3667
|
-
"default": "{\n name: 'Assistant',\n fallback: true,\n systemPrompt: `You are a warm, friendly assistant. For general conversation like \"Hi\" or \"How are you\", you can have a friendly chat. For anything more complex, you cannot directly help, but you can explain what specialists are available. The available specialists are:\\n\\n{{agents}}\\n\\nPolitely let the user know what you can help with and invite them to rephrase their request if it is outside your scope.`,\n}",
|
|
3668
|
-
"description": "A warm, conversational fallback agent. Acknowledges it can't help directly,\nexplains what the available specialists can do, and invites the user to retry.\n\nThe system prompt is generated at runtime by `OrchestratingDriver` from the\nspecialist list — no manual authoring required."
|
|
3669
|
-
},
|
|
3670
|
-
{
|
|
3671
|
-
"kind": "variable",
|
|
3672
|
-
"name": "strictFallbackAgent",
|
|
3673
|
-
"type": {
|
|
3674
|
-
"text": "FallbackAgentConfig"
|
|
3675
|
-
},
|
|
3676
|
-
"default": "{\n name: 'Assistant',\n fallback: true,\n systemPrompt: `You are a concise assistant. The user's request is outside your scope. Respond with a single short sentence stating what you can assist with. Do not elaborate. The available specialists are: {{agents}}.`,\n}",
|
|
3677
|
-
"description": "A brief, professional fallback agent. States what is available without\nelaboration. The `{{agents}}` placeholder is replaced at runtime by\n`OrchestratingDriver` with the generated specialist list."
|
|
3678
|
-
}
|
|
3679
|
-
],
|
|
3680
|
-
"exports": [
|
|
3681
|
-
{
|
|
3682
|
-
"kind": "js",
|
|
3683
|
-
"name": "friendlyFallbackAgent",
|
|
3684
|
-
"declaration": {
|
|
3685
|
-
"name": "friendlyFallbackAgent",
|
|
3686
|
-
"module": "src/config/fallback-agents.ts"
|
|
3687
|
-
}
|
|
3688
|
-
},
|
|
3689
|
-
{
|
|
3690
|
-
"kind": "js",
|
|
3691
|
-
"name": "strictFallbackAgent",
|
|
3692
|
-
"declaration": {
|
|
3693
|
-
"name": "strictFallbackAgent",
|
|
3694
|
-
"module": "src/config/fallback-agents.ts"
|
|
3695
|
-
}
|
|
3696
|
-
}
|
|
3697
|
-
]
|
|
3698
|
-
},
|
|
3699
|
-
{
|
|
3700
|
-
"kind": "javascript-module",
|
|
3701
|
-
"path": "src/config/index.ts",
|
|
3702
|
-
"declarations": [],
|
|
3703
|
-
"exports": [
|
|
3704
|
-
{
|
|
3705
|
-
"kind": "js",
|
|
3706
|
-
"name": "*",
|
|
3707
|
-
"declaration": {
|
|
3708
|
-
"name": "*",
|
|
3709
|
-
"package": "./config"
|
|
3710
|
-
}
|
|
3711
|
-
},
|
|
3712
|
-
{
|
|
3713
|
-
"kind": "js",
|
|
3714
|
-
"name": "*",
|
|
3715
|
-
"declaration": {
|
|
3716
|
-
"name": "*",
|
|
3717
|
-
"package": "./fallback-agents"
|
|
3718
|
-
}
|
|
3719
|
-
}
|
|
3720
|
-
]
|
|
3721
|
-
},
|
|
3722
|
-
{
|
|
3723
|
-
"kind": "javascript-module",
|
|
3724
|
-
"path": "src/config/validate-providers.ts",
|
|
3725
|
-
"declarations": [],
|
|
3726
|
-
"exports": []
|
|
3727
|
-
},
|
|
3728
3736
|
{
|
|
3729
3737
|
"kind": "javascript-module",
|
|
3730
3738
|
"path": "src/state/ai-assistant-slice.ts",
|
|
@@ -3971,6 +3979,14 @@
|
|
|
3971
3979
|
"module": "src/state/debug-event-log.ts"
|
|
3972
3980
|
}
|
|
3973
3981
|
},
|
|
3982
|
+
{
|
|
3983
|
+
"kind": "js",
|
|
3984
|
+
"name": "TurnFailureReason",
|
|
3985
|
+
"declaration": {
|
|
3986
|
+
"name": "TurnFailureReason",
|
|
3987
|
+
"module": "src/state/debug-event-log.ts"
|
|
3988
|
+
}
|
|
3989
|
+
},
|
|
3974
3990
|
{
|
|
3975
3991
|
"kind": "js",
|
|
3976
3992
|
"name": "recordTurnError",
|
|
@@ -6892,6 +6908,66 @@
|
|
|
6892
6908
|
},
|
|
6893
6909
|
"description": "Finish a turn whose signal aborted. A user cancel adds a subtle \"Stopped.\"\nmarker; a dispose-driven abort stops quietly (the widget is gone and the\ncached history would otherwise gain a stray marker on remount)."
|
|
6894
6910
|
},
|
|
6911
|
+
{
|
|
6912
|
+
"kind": "method",
|
|
6913
|
+
"name": "turnDone",
|
|
6914
|
+
"privacy": "private",
|
|
6915
|
+
"return": {
|
|
6916
|
+
"type": {
|
|
6917
|
+
"text": "ChatDriverResult"
|
|
6918
|
+
}
|
|
6919
|
+
},
|
|
6920
|
+
"parameters": [
|
|
6921
|
+
{
|
|
6922
|
+
"name": "failureReason",
|
|
6923
|
+
"optional": true,
|
|
6924
|
+
"type": {
|
|
6925
|
+
"text": "TurnFailureReason"
|
|
6926
|
+
}
|
|
6927
|
+
}
|
|
6928
|
+
],
|
|
6929
|
+
"description": "Build the `done` loop result, carrying the typed failure reason when the turn\nbailed (PTC-0). The discriminant stays `'done'` either way — the same value a\nclean turn returns — so consumers matching on `reason === 'done'` are unchanged;\n`failureReason` is simply present on a failure and absent on success. Omitted\n(rather than set to `undefined`) so a happy-path result stays byte-identical to\nthe historical `{ reason: 'done' }`."
|
|
6930
|
+
},
|
|
6931
|
+
{
|
|
6932
|
+
"kind": "method",
|
|
6933
|
+
"name": "failureReasonOf",
|
|
6934
|
+
"privacy": "private",
|
|
6935
|
+
"static": true,
|
|
6936
|
+
"return": {
|
|
6937
|
+
"type": {
|
|
6938
|
+
"text": "TurnFailureReason | undefined"
|
|
6939
|
+
}
|
|
6940
|
+
},
|
|
6941
|
+
"parameters": [
|
|
6942
|
+
{
|
|
6943
|
+
"name": "result",
|
|
6944
|
+
"type": {
|
|
6945
|
+
"text": "ChatDriverResult"
|
|
6946
|
+
}
|
|
6947
|
+
}
|
|
6948
|
+
],
|
|
6949
|
+
"description": "The typed failure reason on a loop result, or `undefined` for a clean turn / handoff."
|
|
6950
|
+
},
|
|
6951
|
+
{
|
|
6952
|
+
"kind": "method",
|
|
6953
|
+
"name": "loopEndDetail",
|
|
6954
|
+
"privacy": "private",
|
|
6955
|
+
"static": true,
|
|
6956
|
+
"return": {
|
|
6957
|
+
"type": {
|
|
6958
|
+
"text": "{ failureReason: TurnFailureReason } | undefined"
|
|
6959
|
+
}
|
|
6960
|
+
},
|
|
6961
|
+
"parameters": [
|
|
6962
|
+
{
|
|
6963
|
+
"name": "result",
|
|
6964
|
+
"type": {
|
|
6965
|
+
"text": "ChatDriverResult"
|
|
6966
|
+
}
|
|
6967
|
+
}
|
|
6968
|
+
],
|
|
6969
|
+
"description": "Build the `tool-loop-end` event detail for a turn's result. A failure carries a\n`{ failureReason }` detail; a clean turn emits `undefined` — the historical shape,\nkept byte-identical so subscribers see exactly what they always have."
|
|
6970
|
+
},
|
|
6895
6971
|
{
|
|
6896
6972
|
"kind": "method",
|
|
6897
6973
|
"name": "applyAgent",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TurnFailureReason } from '@genesislcap/foundation-ai';
|
|
1
2
|
/**
|
|
2
3
|
* Event map for the AI activity bus.
|
|
3
4
|
*
|
|
@@ -61,8 +62,16 @@ export interface AgenticActivityEvents {
|
|
|
61
62
|
* spinner animation lifecycle (which can flap mid-turn as tool calls resolve), whereas
|
|
62
63
|
* this event is a one-shot per turn boundary. Use this for hooks tied to a turn ending
|
|
63
64
|
* (telemetry flushes, post-turn workspace transitions, deferred state recomputation).
|
|
65
|
+
*
|
|
66
|
+
* The detail carries the turn's outcome (PTC-0): on a failure it is `{ failureReason }`
|
|
67
|
+
* with the typed `TurnFailureReason`; on a clean completion, a user cancel, a
|
|
68
|
+
* driver dispose, and an agent handoff the detail is `undefined` — the historical shape,
|
|
69
|
+
* kept byte-identical so subscribers that only care about the boundary can keep ignoring
|
|
70
|
+
* it. Structured-cloneable so it survives the cross-tab BroadcastChannel hop.
|
|
64
71
|
*/
|
|
65
|
-
'tool-loop-end':
|
|
72
|
+
'tool-loop-end': {
|
|
73
|
+
failureReason?: TurnFailureReason;
|
|
74
|
+
} | undefined;
|
|
66
75
|
/**
|
|
67
76
|
* Fired when a tool handler hands a widget to the user mid-loop and parks awaiting it
|
|
68
77
|
* (`requestInteraction`) — the turn is suspended between provider calls, with no request
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-activity-channel.d.ts","sourceRoot":"","sources":["../../../src/channel/ai-activity-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,qBAAqB;IACpC,2FAA2F;IAC3F,YAAY,EAAE;QAAE,SAAS,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IACtC,iFAAiF;IACjF,WAAW,EAAE,SAAS,CAAC;IACvB,mJAAmJ;IACnJ,aAAa,EAAE,SAAS,CAAC;IACzB,wJAAwJ;IACxJ,YAAY,EAAE,SAAS,CAAC;IACxB;;;;;;;;;;;;;;;;;;OAkBG;IACH,iBAAiB,EAAE,SAAS,CAAC;IAC7B
|
|
1
|
+
{"version":3,"file":"ai-activity-channel.d.ts","sourceRoot":"","sources":["../../../src/channel/ai-activity-channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,qBAAqB;IACpC,2FAA2F;IAC3F,YAAY,EAAE;QAAE,SAAS,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IACtC,iFAAiF;IACjF,WAAW,EAAE,SAAS,CAAC;IACvB,mJAAmJ;IACnJ,aAAa,EAAE,SAAS,CAAC;IACzB,wJAAwJ;IACxJ,YAAY,EAAE,SAAS,CAAC;IACxB;;;;;;;;;;;;;;;;;;OAkBG;IACH,iBAAiB,EAAE,SAAS,CAAC;IAC7B;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,eAAe,EAAE;QAAE,aAAa,CAAC,EAAE,iBAAiB,CAAA;KAAE,GAAG,SAAS,CAAC;IACnE;;;;;;;;;;;OAWG;IACH,uBAAuB,EAAE,SAAS,CAAC;IACnC;;;;;OAKG;IACH,sBAAsB,EAAE,SAAS,CAAC;CACnC"}
|
|
@@ -398,6 +398,23 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
398
398
|
* cached history would otherwise gain a stray marker on remount).
|
|
399
399
|
*/
|
|
400
400
|
private completeAbortedTurn;
|
|
401
|
+
/**
|
|
402
|
+
* Build the `done` loop result, carrying the typed failure reason when the turn
|
|
403
|
+
* bailed (PTC-0). The discriminant stays `'done'` either way — the same value a
|
|
404
|
+
* clean turn returns — so consumers matching on `reason === 'done'` are unchanged;
|
|
405
|
+
* `failureReason` is simply present on a failure and absent on success. Omitted
|
|
406
|
+
* (rather than set to `undefined`) so a happy-path result stays byte-identical to
|
|
407
|
+
* the historical `{ reason: 'done' }`.
|
|
408
|
+
*/
|
|
409
|
+
private turnDone;
|
|
410
|
+
/** The typed failure reason on a loop result, or `undefined` for a clean turn / handoff. */
|
|
411
|
+
private static failureReasonOf;
|
|
412
|
+
/**
|
|
413
|
+
* Build the `tool-loop-end` event detail for a turn's result. A failure carries a
|
|
414
|
+
* `{ failureReason }` detail; a clean turn emits `undefined` — the historical shape,
|
|
415
|
+
* kept byte-identical so subscribers see exactly what they always have.
|
|
416
|
+
*/
|
|
417
|
+
private static loopEndDetail;
|
|
401
418
|
/**
|
|
402
419
|
* Swap in a new agent's configuration. Called by OrchestratingDriver before
|
|
403
420
|
* each specialist turn so the shared driver runs with the right tools and prompt.
|