@genesislcap/ai-assistant 14.437.0 → 14.437.2
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 +242 -19
- package/dist/ai-assistant.d.ts +104 -20
- package/dist/dts/components/chat-driver/chat-driver.d.ts +31 -3
- package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
- package/dist/dts/config/config.d.ts +30 -2
- package/dist/dts/config/config.d.ts.map +1 -1
- package/dist/dts/config/define-stateful-agent.d.ts +38 -14
- package/dist/dts/config/define-stateful-agent.d.ts.map +1 -1
- package/dist/dts/main/main.d.ts +4 -2
- package/dist/dts/main/main.d.ts.map +1 -1
- package/dist/esm/components/chat-driver/chat-driver.js +45 -3
- package/dist/esm/config/define-stateful-agent.js +32 -45
- package/dist/esm/main/main.js +20 -9
- package/dist/esm/main/main.template.js +8 -5
- package/package.json +16 -16
- package/src/components/chat-driver/chat-driver.ts +79 -4
- package/src/config/config.ts +33 -2
- package/src/config/define-stateful-agent.ts +72 -57
- package/src/main/main.template.ts +1 -1
- package/src/main/main.ts +21 -7
|
@@ -2430,8 +2430,8 @@
|
|
|
2430
2430
|
},
|
|
2431
2431
|
{
|
|
2432
2432
|
"kind": "Reference",
|
|
2433
|
-
"text": "
|
|
2434
|
-
"canonicalReference": "@genesislcap/
|
|
2433
|
+
"text": "ToolHandlersInput",
|
|
2434
|
+
"canonicalReference": "@genesislcap/ai-assistant!ToolHandlersInput:type"
|
|
2435
2435
|
},
|
|
2436
2436
|
{
|
|
2437
2437
|
"kind": "Content",
|
|
@@ -4711,16 +4711,25 @@
|
|
|
4711
4711
|
},
|
|
4712
4712
|
{
|
|
4713
4713
|
"kind": "Content",
|
|
4714
|
-
"text": "[];\n meta: {\n timestamp: string;\n host: string;\n agentSummary: ({\n toolDefinitions: string | import(\"
|
|
4714
|
+
"text": "[];\n meta: {\n timestamp: string;\n host: string;\n agentSummary: ({\n toolDefinitions: string | import(\"@genesislcap/foundation-ai\")."
|
|
4715
4715
|
},
|
|
4716
4716
|
{
|
|
4717
4717
|
"kind": "Reference",
|
|
4718
|
-
"text": "
|
|
4719
|
-
"canonicalReference": "@genesislcap/ai
|
|
4718
|
+
"text": "ChatToolDefinition",
|
|
4719
|
+
"canonicalReference": "@genesislcap/foundation-ai!ChatToolDefinition:interface"
|
|
4720
|
+
},
|
|
4721
|
+
{
|
|
4722
|
+
"kind": "Content",
|
|
4723
|
+
"text": "[];\n toolHandlers: any;\n onActivate: any;\n onDeactivate: any;\n getDebugSnapshot: any;\n description: string;\n fallback?: never;\n excludeFromClassifier?: boolean;\n name: string;\n displayName?: import(\"../config/config\")."
|
|
4724
|
+
},
|
|
4725
|
+
{
|
|
4726
|
+
"kind": "Reference",
|
|
4727
|
+
"text": "SystemPromptInput",
|
|
4728
|
+
"canonicalReference": "@genesislcap/ai-assistant!SystemPromptInput:type"
|
|
4720
4729
|
},
|
|
4721
4730
|
{
|
|
4722
4731
|
"kind": "Content",
|
|
4723
|
-
"text": "
|
|
4732
|
+
"text": ";\n systemPrompt?: import(\"../config/config\")."
|
|
4724
4733
|
},
|
|
4725
4734
|
{
|
|
4726
4735
|
"kind": "Reference",
|
|
@@ -4765,16 +4774,25 @@
|
|
|
4765
4774
|
},
|
|
4766
4775
|
{
|
|
4767
4776
|
"kind": "Content",
|
|
4768
|
-
"text": ";\n } | {\n toolDefinitions: string | import(\"
|
|
4777
|
+
"text": ";\n } | {\n toolDefinitions: string | import(\"@genesislcap/foundation-ai\")."
|
|
4769
4778
|
},
|
|
4770
4779
|
{
|
|
4771
4780
|
"kind": "Reference",
|
|
4772
|
-
"text": "
|
|
4773
|
-
"canonicalReference": "@genesislcap/ai
|
|
4781
|
+
"text": "ChatToolDefinition",
|
|
4782
|
+
"canonicalReference": "@genesislcap/foundation-ai!ChatToolDefinition:interface"
|
|
4774
4783
|
},
|
|
4775
4784
|
{
|
|
4776
4785
|
"kind": "Content",
|
|
4777
|
-
"text": "[];\n toolHandlers: any;\n onActivate: any;\n onDeactivate: any;\n getDebugSnapshot: any;\n fallback: true;\n description?: never;\n name: string;\n
|
|
4786
|
+
"text": "[];\n toolHandlers: any;\n onActivate: any;\n onDeactivate: any;\n getDebugSnapshot: any;\n fallback: true;\n description?: never;\n name: string;\n displayName?: import(\"../config/config\")."
|
|
4787
|
+
},
|
|
4788
|
+
{
|
|
4789
|
+
"kind": "Reference",
|
|
4790
|
+
"text": "SystemPromptInput",
|
|
4791
|
+
"canonicalReference": "@genesislcap/ai-assistant!SystemPromptInput:type"
|
|
4792
|
+
},
|
|
4793
|
+
{
|
|
4794
|
+
"kind": "Content",
|
|
4795
|
+
"text": ";\n systemPrompt?: import(\"../config/config\")."
|
|
4778
4796
|
},
|
|
4779
4797
|
{
|
|
4780
4798
|
"kind": "Reference",
|
|
@@ -4847,7 +4865,7 @@
|
|
|
4847
4865
|
"isStatic": false,
|
|
4848
4866
|
"returnTypeTokenRange": {
|
|
4849
4867
|
"startIndex": 1,
|
|
4850
|
-
"endIndex":
|
|
4868
|
+
"endIndex": 36
|
|
4851
4869
|
},
|
|
4852
4870
|
"releaseTag": "Beta",
|
|
4853
4871
|
"isProtected": false,
|
|
@@ -7749,6 +7767,50 @@
|
|
|
7749
7767
|
}
|
|
7750
7768
|
]
|
|
7751
7769
|
},
|
|
7770
|
+
{
|
|
7771
|
+
"kind": "TypeAlias",
|
|
7772
|
+
"canonicalReference": "@genesislcap/ai-assistant!StatefulAgentContext:type",
|
|
7773
|
+
"docComment": "/**\n * Context passed to per-turn resolvers on a stateful agent — the standard {@link SystemPromptContext} plus the live `state` value. Used by `systemPrompt`, `displayName`, and the function form of `toolDefinitions`.\n *\n * Exported so consumers can lift resolvers into separate files without re-deriving the shape.\n *\n * @beta\n */\n",
|
|
7774
|
+
"excerptTokens": [
|
|
7775
|
+
{
|
|
7776
|
+
"kind": "Content",
|
|
7777
|
+
"text": "export type StatefulAgentContext<S> = "
|
|
7778
|
+
},
|
|
7779
|
+
{
|
|
7780
|
+
"kind": "Reference",
|
|
7781
|
+
"text": "SystemPromptContext",
|
|
7782
|
+
"canonicalReference": "@genesislcap/ai-assistant!SystemPromptContext:interface"
|
|
7783
|
+
},
|
|
7784
|
+
{
|
|
7785
|
+
"kind": "Content",
|
|
7786
|
+
"text": " & {\n state: S;\n}"
|
|
7787
|
+
},
|
|
7788
|
+
{
|
|
7789
|
+
"kind": "Content",
|
|
7790
|
+
"text": ";"
|
|
7791
|
+
}
|
|
7792
|
+
],
|
|
7793
|
+
"fileUrlPath": "src/config/define-stateful-agent.ts",
|
|
7794
|
+
"releaseTag": "Beta",
|
|
7795
|
+
"name": "StatefulAgentContext",
|
|
7796
|
+
"typeParameters": [
|
|
7797
|
+
{
|
|
7798
|
+
"typeParameterName": "S",
|
|
7799
|
+
"constraintTokenRange": {
|
|
7800
|
+
"startIndex": 0,
|
|
7801
|
+
"endIndex": 0
|
|
7802
|
+
},
|
|
7803
|
+
"defaultTypeTokenRange": {
|
|
7804
|
+
"startIndex": 0,
|
|
7805
|
+
"endIndex": 0
|
|
7806
|
+
}
|
|
7807
|
+
}
|
|
7808
|
+
],
|
|
7809
|
+
"typeTokenRange": {
|
|
7810
|
+
"startIndex": 1,
|
|
7811
|
+
"endIndex": 3
|
|
7812
|
+
}
|
|
7813
|
+
},
|
|
7752
7814
|
{
|
|
7753
7815
|
"kind": "Interface",
|
|
7754
7816
|
"canonicalReference": "@genesislcap/ai-assistant!StatefulAgentInit:interface",
|
|
@@ -7832,6 +7894,51 @@
|
|
|
7832
7894
|
"endIndex": 2
|
|
7833
7895
|
}
|
|
7834
7896
|
},
|
|
7897
|
+
{
|
|
7898
|
+
"kind": "PropertySignature",
|
|
7899
|
+
"canonicalReference": "@genesislcap/ai-assistant!StatefulAgentInit#displayName:member",
|
|
7900
|
+
"docComment": "/**\n * Per-turn display label, e.g. \"Guided Booking (Counterparties)\". Resolved each tool-loop iteration and stamped onto outgoing messages and the debug-log timeline — display only. The agent's `name` stays as the canonical identity used for routing/history filtering.\n */\n",
|
|
7901
|
+
"excerptTokens": [
|
|
7902
|
+
{
|
|
7903
|
+
"kind": "Content",
|
|
7904
|
+
"text": "displayName?: "
|
|
7905
|
+
},
|
|
7906
|
+
{
|
|
7907
|
+
"kind": "Content",
|
|
7908
|
+
"text": "(ctx: "
|
|
7909
|
+
},
|
|
7910
|
+
{
|
|
7911
|
+
"kind": "Reference",
|
|
7912
|
+
"text": "StatefulAgentContext",
|
|
7913
|
+
"canonicalReference": "@genesislcap/ai-assistant!StatefulAgentContext:type"
|
|
7914
|
+
},
|
|
7915
|
+
{
|
|
7916
|
+
"kind": "Content",
|
|
7917
|
+
"text": "<S>) => string | "
|
|
7918
|
+
},
|
|
7919
|
+
{
|
|
7920
|
+
"kind": "Reference",
|
|
7921
|
+
"text": "Promise",
|
|
7922
|
+
"canonicalReference": "!Promise:interface"
|
|
7923
|
+
},
|
|
7924
|
+
{
|
|
7925
|
+
"kind": "Content",
|
|
7926
|
+
"text": "<string>"
|
|
7927
|
+
},
|
|
7928
|
+
{
|
|
7929
|
+
"kind": "Content",
|
|
7930
|
+
"text": ";"
|
|
7931
|
+
}
|
|
7932
|
+
],
|
|
7933
|
+
"isReadonly": false,
|
|
7934
|
+
"isOptional": true,
|
|
7935
|
+
"releaseTag": "Beta",
|
|
7936
|
+
"name": "displayName",
|
|
7937
|
+
"propertyTypeTokenRange": {
|
|
7938
|
+
"startIndex": 1,
|
|
7939
|
+
"endIndex": 6
|
|
7940
|
+
}
|
|
7941
|
+
},
|
|
7835
7942
|
{
|
|
7836
7943
|
"kind": "PropertySignature",
|
|
7837
7944
|
"canonicalReference": "@genesislcap/ai-assistant!StatefulAgentInit#dispose:member",
|
|
@@ -8110,12 +8217,12 @@
|
|
|
8110
8217
|
},
|
|
8111
8218
|
{
|
|
8112
8219
|
"kind": "Reference",
|
|
8113
|
-
"text": "
|
|
8114
|
-
"canonicalReference": "@genesislcap/ai-assistant!
|
|
8220
|
+
"text": "StatefulAgentContext",
|
|
8221
|
+
"canonicalReference": "@genesislcap/ai-assistant!StatefulAgentContext:type"
|
|
8115
8222
|
},
|
|
8116
8223
|
{
|
|
8117
8224
|
"kind": "Content",
|
|
8118
|
-
"text": "
|
|
8225
|
+
"text": "<S>) => string | "
|
|
8119
8226
|
},
|
|
8120
8227
|
{
|
|
8121
8228
|
"kind": "Reference",
|
|
@@ -8160,12 +8267,12 @@
|
|
|
8160
8267
|
},
|
|
8161
8268
|
{
|
|
8162
8269
|
"kind": "Reference",
|
|
8163
|
-
"text": "
|
|
8164
|
-
"canonicalReference": "@genesislcap/ai-assistant!
|
|
8270
|
+
"text": "StatefulAgentContext",
|
|
8271
|
+
"canonicalReference": "@genesislcap/ai-assistant!StatefulAgentContext:type"
|
|
8165
8272
|
},
|
|
8166
8273
|
{
|
|
8167
8274
|
"kind": "Content",
|
|
8168
|
-
"text": "
|
|
8275
|
+
"text": "<S>) => "
|
|
8169
8276
|
},
|
|
8170
8277
|
{
|
|
8171
8278
|
"kind": "Reference",
|
|
@@ -8211,7 +8318,7 @@
|
|
|
8211
8318
|
{
|
|
8212
8319
|
"kind": "PropertySignature",
|
|
8213
8320
|
"canonicalReference": "@genesislcap/ai-assistant!StatefulAgentInit#toolHandlers:member",
|
|
8214
|
-
"docComment": "/**\n * Factory returning the
|
|
8321
|
+
"docComment": "/**\n * Factory returning the handler map for the **current state**. Called each tool-loop iteration with the live `state` value, so the handler set the driver dispatches against matches what `toolDefinitions` exposes to the LLM that turn. Return only the handlers valid right now — no need to advertise every handler the agent might ever expose, and no defensive `if (!machine.matches(...))` guards inside each handler.\n *\n * Pair with the function form of `toolDefinitions` so the visible tools and the dispatchable handlers stay in lockstep.\n *\n * **Constraint:** resolved handlers must not include fold facades. Folds and state-machine-driven tool filtering both try to control the LLM's tool view — pick one. Helper samples once on activation (init state) and throws if a fold-tagged handler is detected; subsequent resolves also validate, so misuse on a non-init state surfaces when that state is reached.\n */\n",
|
|
8215
8322
|
"excerptTokens": [
|
|
8216
8323
|
{
|
|
8217
8324
|
"kind": "Content",
|
|
@@ -8226,6 +8333,28 @@
|
|
|
8226
8333
|
"text": "ChatToolHandlers",
|
|
8227
8334
|
"canonicalReference": "@genesislcap/foundation-ai!ChatToolHandlers:type"
|
|
8228
8335
|
},
|
|
8336
|
+
{
|
|
8337
|
+
"kind": "Content",
|
|
8338
|
+
"text": " | "
|
|
8339
|
+
},
|
|
8340
|
+
{
|
|
8341
|
+
"kind": "Reference",
|
|
8342
|
+
"text": "Promise",
|
|
8343
|
+
"canonicalReference": "!Promise:interface"
|
|
8344
|
+
},
|
|
8345
|
+
{
|
|
8346
|
+
"kind": "Content",
|
|
8347
|
+
"text": "<"
|
|
8348
|
+
},
|
|
8349
|
+
{
|
|
8350
|
+
"kind": "Reference",
|
|
8351
|
+
"text": "ChatToolHandlers",
|
|
8352
|
+
"canonicalReference": "@genesislcap/foundation-ai!ChatToolHandlers:type"
|
|
8353
|
+
},
|
|
8354
|
+
{
|
|
8355
|
+
"kind": "Content",
|
|
8356
|
+
"text": ">"
|
|
8357
|
+
},
|
|
8229
8358
|
{
|
|
8230
8359
|
"kind": "Content",
|
|
8231
8360
|
"text": ";"
|
|
@@ -8237,7 +8366,7 @@
|
|
|
8237
8366
|
"name": "toolHandlers",
|
|
8238
8367
|
"propertyTypeTokenRange": {
|
|
8239
8368
|
"startIndex": 1,
|
|
8240
|
-
"endIndex":
|
|
8369
|
+
"endIndex": 8
|
|
8241
8370
|
}
|
|
8242
8371
|
}
|
|
8243
8372
|
],
|
|
@@ -8619,6 +8748,73 @@
|
|
|
8619
8748
|
],
|
|
8620
8749
|
"extendsTokenRanges": []
|
|
8621
8750
|
},
|
|
8751
|
+
{
|
|
8752
|
+
"kind": "TypeAlias",
|
|
8753
|
+
"canonicalReference": "@genesislcap/ai-assistant!ToolHandlersInput:type",
|
|
8754
|
+
"docComment": "/**\n * Tool handlers for an agent. Either a static map (the conventional shape) or a function resolved each tool-loop iteration. The function form lets the agent narrow the dispatchable handler set per turn — pair it with the function form of `toolDefinitions` so the LLM-visible tools and the dispatchable handlers stay in lockstep, and handlers don't have to defend themselves against being dispatched in states where their tool isn't advertised.\n *\n * @beta\n */\n",
|
|
8755
|
+
"excerptTokens": [
|
|
8756
|
+
{
|
|
8757
|
+
"kind": "Content",
|
|
8758
|
+
"text": "export type ToolHandlersInput = "
|
|
8759
|
+
},
|
|
8760
|
+
{
|
|
8761
|
+
"kind": "Reference",
|
|
8762
|
+
"text": "ChatToolHandlers",
|
|
8763
|
+
"canonicalReference": "@genesislcap/foundation-ai!ChatToolHandlers:type"
|
|
8764
|
+
},
|
|
8765
|
+
{
|
|
8766
|
+
"kind": "Content",
|
|
8767
|
+
"text": " | ((ctx: "
|
|
8768
|
+
},
|
|
8769
|
+
{
|
|
8770
|
+
"kind": "Reference",
|
|
8771
|
+
"text": "SystemPromptContext",
|
|
8772
|
+
"canonicalReference": "@genesislcap/ai-assistant!SystemPromptContext:interface"
|
|
8773
|
+
},
|
|
8774
|
+
{
|
|
8775
|
+
"kind": "Content",
|
|
8776
|
+
"text": ") => "
|
|
8777
|
+
},
|
|
8778
|
+
{
|
|
8779
|
+
"kind": "Reference",
|
|
8780
|
+
"text": "ChatToolHandlers",
|
|
8781
|
+
"canonicalReference": "@genesislcap/foundation-ai!ChatToolHandlers:type"
|
|
8782
|
+
},
|
|
8783
|
+
{
|
|
8784
|
+
"kind": "Content",
|
|
8785
|
+
"text": " | "
|
|
8786
|
+
},
|
|
8787
|
+
{
|
|
8788
|
+
"kind": "Reference",
|
|
8789
|
+
"text": "Promise",
|
|
8790
|
+
"canonicalReference": "!Promise:interface"
|
|
8791
|
+
},
|
|
8792
|
+
{
|
|
8793
|
+
"kind": "Content",
|
|
8794
|
+
"text": "<"
|
|
8795
|
+
},
|
|
8796
|
+
{
|
|
8797
|
+
"kind": "Reference",
|
|
8798
|
+
"text": "ChatToolHandlers",
|
|
8799
|
+
"canonicalReference": "@genesislcap/foundation-ai!ChatToolHandlers:type"
|
|
8800
|
+
},
|
|
8801
|
+
{
|
|
8802
|
+
"kind": "Content",
|
|
8803
|
+
"text": ">)"
|
|
8804
|
+
},
|
|
8805
|
+
{
|
|
8806
|
+
"kind": "Content",
|
|
8807
|
+
"text": ";"
|
|
8808
|
+
}
|
|
8809
|
+
],
|
|
8810
|
+
"fileUrlPath": "src/config/config.ts",
|
|
8811
|
+
"releaseTag": "Beta",
|
|
8812
|
+
"name": "ToolHandlersInput",
|
|
8813
|
+
"typeTokenRange": {
|
|
8814
|
+
"startIndex": 1,
|
|
8815
|
+
"endIndex": 11
|
|
8816
|
+
}
|
|
8817
|
+
},
|
|
8622
8818
|
{
|
|
8623
8819
|
"kind": "Interface",
|
|
8624
8820
|
"canonicalReference": "@genesislcap/ai-assistant!ToolTreeNode:interface",
|
|
@@ -8698,6 +8894,33 @@
|
|
|
8698
8894
|
"name": "TurnSnapshot",
|
|
8699
8895
|
"preserveMemberOrder": false,
|
|
8700
8896
|
"members": [
|
|
8897
|
+
{
|
|
8898
|
+
"kind": "PropertySignature",
|
|
8899
|
+
"canonicalReference": "@genesislcap/ai-assistant!TurnSnapshot#agentLabel:member",
|
|
8900
|
+
"docComment": "/**\n * Per-turn display label resolved from the agent's `displayName`, e.g. \"Guided Booking (Counterparties)\". `agentName` stays as the canonical identity used for routing/filtering.\n */\n",
|
|
8901
|
+
"excerptTokens": [
|
|
8902
|
+
{
|
|
8903
|
+
"kind": "Content",
|
|
8904
|
+
"text": "agentLabel?: "
|
|
8905
|
+
},
|
|
8906
|
+
{
|
|
8907
|
+
"kind": "Content",
|
|
8908
|
+
"text": "string"
|
|
8909
|
+
},
|
|
8910
|
+
{
|
|
8911
|
+
"kind": "Content",
|
|
8912
|
+
"text": ";"
|
|
8913
|
+
}
|
|
8914
|
+
],
|
|
8915
|
+
"isReadonly": false,
|
|
8916
|
+
"isOptional": true,
|
|
8917
|
+
"releaseTag": "Beta",
|
|
8918
|
+
"name": "agentLabel",
|
|
8919
|
+
"propertyTypeTokenRange": {
|
|
8920
|
+
"startIndex": 1,
|
|
8921
|
+
"endIndex": 2
|
|
8922
|
+
}
|
|
8923
|
+
},
|
|
8701
8924
|
{
|
|
8702
8925
|
"kind": "PropertySignature",
|
|
8703
8926
|
"canonicalReference": "@genesislcap/ai-assistant!TurnSnapshot#agentName:member",
|
package/dist/ai-assistant.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { ChatConfig } from '@genesislcap/foundation-ai';
|
|
|
5
5
|
import type { ChatDriverResult } from '@genesislcap/foundation-ai';
|
|
6
6
|
import type { ChatInputDuringExecutionMode } from '@genesislcap/foundation-ai';
|
|
7
7
|
import type { ChatMessage } from '@genesislcap/foundation-ai';
|
|
8
|
-
import
|
|
8
|
+
import { ChatToolDefinition } from '@genesislcap/foundation-ai';
|
|
9
9
|
import type { ChatToolHandlers } from '@genesislcap/foundation-ai';
|
|
10
10
|
import { GenesisElement } from '@genesislcap/web-core';
|
|
11
11
|
import type { InteractionRequestOptions } from '@genesislcap/foundation-ai';
|
|
@@ -376,9 +376,21 @@ export declare const ANIMATION_DEFS: {
|
|
|
376
376
|
|
|
377
377
|
declare interface BaseAgentConfig {
|
|
378
378
|
/**
|
|
379
|
-
*
|
|
379
|
+
* Stable identity for this agent. Used for classifier routing, manual
|
|
380
|
+
* pinning, and history filtering — must not vary per turn. For a per-turn
|
|
381
|
+
* display label (e.g. "Guided Booking (Counterparties)"), supply
|
|
382
|
+
* {@link BaseAgentConfig.displayName}.
|
|
380
383
|
*/
|
|
381
384
|
name: string;
|
|
385
|
+
/**
|
|
386
|
+
* Optional per-turn display label. Resolved each tool-loop iteration and
|
|
387
|
+
* stamped onto outgoing messages (`agentLabel`) and the debug-log timeline.
|
|
388
|
+
* Renderers fall back to `name` when this is unset. Use the function form
|
|
389
|
+
* to vary the label by current state (e.g. a state machine's step).
|
|
390
|
+
*
|
|
391
|
+
* Identity stays on `name` — this is for UX only.
|
|
392
|
+
*/
|
|
393
|
+
displayName?: SystemPromptInput;
|
|
382
394
|
/**
|
|
383
395
|
* System prompt injected into every conversation turn for this agent.
|
|
384
396
|
*
|
|
@@ -398,8 +410,13 @@ declare interface BaseAgentConfig {
|
|
|
398
410
|
toolDefinitions?: ToolDefinitionsInput;
|
|
399
411
|
/**
|
|
400
412
|
* Tool handler implementations for this agent.
|
|
413
|
+
*
|
|
414
|
+
* Either a static map or a function resolved each tool-loop iteration —
|
|
415
|
+
* pick the function form to narrow the dispatchable handler set per turn,
|
|
416
|
+
* matching the function form of `toolDefinitions`.
|
|
417
|
+
* See {@link ToolHandlersInput}.
|
|
401
418
|
*/
|
|
402
|
-
toolHandlers?:
|
|
419
|
+
toolHandlers?: ToolHandlersInput;
|
|
403
420
|
/**
|
|
404
421
|
* Optional primer history prepended to every call (not visible to the user).
|
|
405
422
|
* Used to establish agent identity and behavioural rules.
|
|
@@ -486,9 +503,31 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
486
503
|
* in that case.
|
|
487
504
|
*/
|
|
488
505
|
private toolDefinitionsFactory?;
|
|
506
|
+
/**
|
|
507
|
+
* Resolved tool handler map used for dispatch. When `toolHandlersFactory` is
|
|
508
|
+
* set, this is overwritten each tool-loop iteration with the factory's output
|
|
509
|
+
* — keeping it in lockstep with `toolDefinitions` so handlers don't have to
|
|
510
|
+
* defend themselves against being dispatched in states where their tool
|
|
511
|
+
* isn't advertised. Folds mutate this in place; `defineStatefulAgent`
|
|
512
|
+
* forbids folds when a factory is set, so the fold-mutation path is
|
|
513
|
+
* unreachable in that case.
|
|
514
|
+
*/
|
|
489
515
|
private toolHandlers;
|
|
516
|
+
/**
|
|
517
|
+
* Optional per-turn handler-map source. Mirrors `toolDefinitionsFactory` so
|
|
518
|
+
* the LLM-visible tools and the dispatchable handlers can be narrowed in
|
|
519
|
+
* lockstep. Resolved each tool-loop iteration before the LLM call.
|
|
520
|
+
*/
|
|
521
|
+
private toolHandlersFactory?;
|
|
490
522
|
private primerHistory?;
|
|
491
523
|
private activeAgentName?;
|
|
524
|
+
/**
|
|
525
|
+
* Per-turn display label resolved from the agent's `displayName`. Stamped
|
|
526
|
+
* onto outgoing messages and turn snapshots for UX; `activeAgentName` stays
|
|
527
|
+
* stable for routing/history-transform identity matching.
|
|
528
|
+
*/
|
|
529
|
+
private activeAgentLabel?;
|
|
530
|
+
private displayName?;
|
|
492
531
|
/**
|
|
493
532
|
* When set, `requestInteraction` delegates to this callback instead of using
|
|
494
533
|
* this driver's own pending map. Wired by `invokeSubAgent` so a sub-agent's
|
|
@@ -538,7 +577,7 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
538
577
|
/** Captured from `applyAgent` so we don't store the whole `AgentConfig`. */
|
|
539
578
|
private debugSnapshotter?;
|
|
540
579
|
private readonly maxTurnSnapshots;
|
|
541
|
-
constructor(aiProvider: AIProvider, toolHandlers?:
|
|
580
|
+
constructor(aiProvider: AIProvider, toolHandlers?: ToolHandlersInput, toolDefinitions?: ToolDefinitionsInput, systemPrompt?: SystemPromptInput, primerHistory?: ChatMessage[], maxToolIterations?: number, maxFoldOperations?: number, maxTurnSnapshots?: number);
|
|
542
581
|
/**
|
|
543
582
|
* Swap in a new agent's configuration. Called by OrchestratingDriver before
|
|
544
583
|
* each specialist turn so the shared driver runs with the right tools and prompt.
|
|
@@ -1084,7 +1123,7 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
1084
1123
|
timestamp: string;
|
|
1085
1124
|
host: string;
|
|
1086
1125
|
agentSummary: ({
|
|
1087
|
-
toolDefinitions: string |
|
|
1126
|
+
toolDefinitions: string | ChatToolDefinition[];
|
|
1088
1127
|
toolHandlers: any;
|
|
1089
1128
|
onActivate: any;
|
|
1090
1129
|
onDeactivate: any;
|
|
@@ -1093,13 +1132,14 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
1093
1132
|
fallback?: never;
|
|
1094
1133
|
excludeFromClassifier?: boolean;
|
|
1095
1134
|
name: string;
|
|
1135
|
+
displayName?: SystemPromptInput;
|
|
1096
1136
|
systemPrompt?: SystemPromptInput;
|
|
1097
1137
|
primerHistory?: ChatMessage[];
|
|
1098
1138
|
subAgents?: AgentConfig[];
|
|
1099
1139
|
chatInputDuringExecution?: ChatInputDuringExecutionMode;
|
|
1100
1140
|
manualSelection?: ManualSelectionConfig;
|
|
1101
1141
|
} | {
|
|
1102
|
-
toolDefinitions: string |
|
|
1142
|
+
toolDefinitions: string | ChatToolDefinition[];
|
|
1103
1143
|
toolHandlers: any;
|
|
1104
1144
|
onActivate: any;
|
|
1105
1145
|
onDeactivate: any;
|
|
@@ -1107,6 +1147,7 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
1107
1147
|
fallback: true;
|
|
1108
1148
|
description?: never;
|
|
1109
1149
|
name: string;
|
|
1150
|
+
displayName?: SystemPromptInput;
|
|
1110
1151
|
systemPrompt?: SystemPromptInput;
|
|
1111
1152
|
primerHistory?: ChatMessage[];
|
|
1112
1153
|
subAgents?: AgentConfig[];
|
|
@@ -1352,6 +1393,20 @@ export declare interface SpecialistAgentConfig extends BaseAgentConfig {
|
|
|
1352
1393
|
excludeFromClassifier?: boolean;
|
|
1353
1394
|
}
|
|
1354
1395
|
|
|
1396
|
+
/**
|
|
1397
|
+
* Context passed to per-turn resolvers on a stateful agent — the standard
|
|
1398
|
+
* {@link SystemPromptContext} plus the live `state` value. Used by
|
|
1399
|
+
* `systemPrompt`, `displayName`, and the function form of `toolDefinitions`.
|
|
1400
|
+
*
|
|
1401
|
+
* Exported so consumers can lift resolvers into separate files without
|
|
1402
|
+
* re-deriving the shape.
|
|
1403
|
+
*
|
|
1404
|
+
* @beta
|
|
1405
|
+
*/
|
|
1406
|
+
export declare type StatefulAgentContext<S> = SystemPromptContext & {
|
|
1407
|
+
state: S;
|
|
1408
|
+
};
|
|
1409
|
+
|
|
1355
1410
|
/**
|
|
1356
1411
|
* Init options for {@link defineStatefulAgent}. Generic over the state shape `S`
|
|
1357
1412
|
* the agent owns (a state machine, an observable controller, anything).
|
|
@@ -1399,9 +1454,14 @@ export declare interface StatefulAgentInit<S> {
|
|
|
1399
1454
|
* iteration. Use this to feed the LLM whatever the current state implies
|
|
1400
1455
|
* (e.g. a state machine's `meta.systemPrompt` plus captured context).
|
|
1401
1456
|
*/
|
|
1402
|
-
systemPrompt?: (ctx:
|
|
1403
|
-
|
|
1404
|
-
|
|
1457
|
+
systemPrompt?: (ctx: StatefulAgentContext<S>) => string | Promise<string>;
|
|
1458
|
+
/**
|
|
1459
|
+
* Per-turn display label, e.g. "Guided Booking (Counterparties)". Resolved
|
|
1460
|
+
* each tool-loop iteration and stamped onto outgoing messages and the
|
|
1461
|
+
* debug-log timeline — display only. The agent's `name` stays as the
|
|
1462
|
+
* canonical identity used for routing/history filtering.
|
|
1463
|
+
*/
|
|
1464
|
+
displayName?: (ctx: StatefulAgentContext<S>) => string | Promise<string>;
|
|
1405
1465
|
/**
|
|
1406
1466
|
* Tool definitions the LLM sees. Either a static array (resolved once) or a
|
|
1407
1467
|
* function resolved each tool-loop iteration. The function form is how a
|
|
@@ -1413,20 +1473,26 @@ export declare interface StatefulAgentInit<S> {
|
|
|
1413
1473
|
* has to be in charge. Helper throws at init time if a fold-tagged handler
|
|
1414
1474
|
* is detected.
|
|
1415
1475
|
*/
|
|
1416
|
-
toolDefinitions?: ChatToolDefinition[] | ((ctx:
|
|
1417
|
-
state: S;
|
|
1418
|
-
}) => ChatToolDefinition[] | Promise<ChatToolDefinition[]>);
|
|
1476
|
+
toolDefinitions?: ChatToolDefinition[] | ((ctx: StatefulAgentContext<S>) => ChatToolDefinition[] | Promise<ChatToolDefinition[]>);
|
|
1419
1477
|
/**
|
|
1420
|
-
* Factory returning the
|
|
1421
|
-
*
|
|
1422
|
-
*
|
|
1423
|
-
*
|
|
1478
|
+
* Factory returning the handler map for the **current state**. Called each
|
|
1479
|
+
* tool-loop iteration with the live `state` value, so the handler set the
|
|
1480
|
+
* driver dispatches against matches what `toolDefinitions` exposes to the
|
|
1481
|
+
* LLM that turn. Return only the handlers valid right now — no need to
|
|
1482
|
+
* advertise every handler the agent might ever expose, and no defensive
|
|
1483
|
+
* `if (!machine.matches(...))` guards inside each handler.
|
|
1484
|
+
*
|
|
1485
|
+
* Pair with the function form of `toolDefinitions` so the visible tools and
|
|
1486
|
+
* the dispatchable handlers stay in lockstep.
|
|
1424
1487
|
*
|
|
1425
|
-
*
|
|
1426
|
-
*
|
|
1427
|
-
*
|
|
1488
|
+
* **Constraint:** resolved handlers must not include fold facades. Folds and
|
|
1489
|
+
* state-machine-driven tool filtering both try to control the LLM's tool
|
|
1490
|
+
* view — pick one. Helper samples once on activation (init state) and
|
|
1491
|
+
* throws if a fold-tagged handler is detected; subsequent resolves also
|
|
1492
|
+
* validate, so misuse on a non-init state surfaces when that state is
|
|
1493
|
+
* reached.
|
|
1428
1494
|
*/
|
|
1429
|
-
toolHandlers?: (state: S) => ChatToolHandlers
|
|
1495
|
+
toolHandlers?: (state: S) => ChatToolHandlers | Promise<ChatToolHandlers>;
|
|
1430
1496
|
/**
|
|
1431
1497
|
* Optional getter for the debug-log snapshot. Defaults to auto-snapshotting
|
|
1432
1498
|
* any property on `state` that looks like a foundation-state-machine
|
|
@@ -1553,6 +1619,18 @@ export declare interface ToolFoldResult {
|
|
|
1553
1619
|
handler: ChatToolHandlers;
|
|
1554
1620
|
}
|
|
1555
1621
|
|
|
1622
|
+
/**
|
|
1623
|
+
* Tool handlers for an agent. Either a static map (the conventional shape) or a
|
|
1624
|
+
* function resolved each tool-loop iteration. The function form lets the agent
|
|
1625
|
+
* narrow the dispatchable handler set per turn — pair it with the function form
|
|
1626
|
+
* of `toolDefinitions` so the LLM-visible tools and the dispatchable handlers
|
|
1627
|
+
* stay in lockstep, and handlers don't have to defend themselves against being
|
|
1628
|
+
* dispatched in states where their tool isn't advertised.
|
|
1629
|
+
*
|
|
1630
|
+
* @beta
|
|
1631
|
+
*/
|
|
1632
|
+
export declare type ToolHandlersInput = ChatToolHandlers | ((ctx: SystemPromptContext) => ChatToolHandlers | Promise<ChatToolHandlers>);
|
|
1633
|
+
|
|
1556
1634
|
/**
|
|
1557
1635
|
* A tool entry in the expanded debug tree.
|
|
1558
1636
|
* Folds are represented as nodes with a `tools` array; regular tools have none.
|
|
@@ -1585,6 +1663,12 @@ export declare interface TurnSnapshot {
|
|
|
1585
1663
|
systemPrompt?: string;
|
|
1586
1664
|
/** Tool names sent to the LLM, in order — definitions are static per name so names alone suffice. */
|
|
1587
1665
|
toolNames: string[];
|
|
1666
|
+
/**
|
|
1667
|
+
* Per-turn display label resolved from the agent's `displayName`, e.g.
|
|
1668
|
+
* "Guided Booking (Counterparties)". `agentName` stays as the canonical
|
|
1669
|
+
* identity used for routing/filtering.
|
|
1670
|
+
*/
|
|
1671
|
+
agentLabel?: string;
|
|
1588
1672
|
/** Agent-supplied snapshot — machine state/context for stateful agents, undefined otherwise. */
|
|
1589
1673
|
agentSnapshot?: unknown;
|
|
1590
1674
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AIProvider, ChatAttachment, ChatDriverResult, ChatMessage,
|
|
2
|
-
import type { AgentConfig, SystemPromptInput, ToolDefinitionsInput } from '../../config/config';
|
|
1
|
+
import type { AIProvider, ChatAttachment, ChatDriverResult, ChatMessage, InteractionRequestOptions } from '@genesislcap/foundation-ai';
|
|
2
|
+
import type { AgentConfig, SystemPromptInput, ToolDefinitionsInput, ToolHandlersInput } from '../../config/config';
|
|
3
3
|
import type { AiDriver, AllAgentSummary } from '../ai-driver/ai-driver';
|
|
4
4
|
/** Name reserved for the cross-agent handoff tool — injected by OrchestratingDriver. */
|
|
5
5
|
export declare const REQUEST_CONTINUATION_TOOL = "request_continuation";
|
|
@@ -30,6 +30,12 @@ export interface TurnSnapshot {
|
|
|
30
30
|
systemPrompt?: string;
|
|
31
31
|
/** Tool names sent to the LLM, in order — definitions are static per name so names alone suffice. */
|
|
32
32
|
toolNames: string[];
|
|
33
|
+
/**
|
|
34
|
+
* Per-turn display label resolved from the agent's `displayName`, e.g.
|
|
35
|
+
* "Guided Booking (Counterparties)". `agentName` stays as the canonical
|
|
36
|
+
* identity used for routing/filtering.
|
|
37
|
+
*/
|
|
38
|
+
agentLabel?: string;
|
|
33
39
|
/** Agent-supplied snapshot — machine state/context for stateful agents, undefined otherwise. */
|
|
34
40
|
agentSnapshot?: unknown;
|
|
35
41
|
}
|
|
@@ -63,9 +69,31 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
63
69
|
* in that case.
|
|
64
70
|
*/
|
|
65
71
|
private toolDefinitionsFactory?;
|
|
72
|
+
/**
|
|
73
|
+
* Resolved tool handler map used for dispatch. When `toolHandlersFactory` is
|
|
74
|
+
* set, this is overwritten each tool-loop iteration with the factory's output
|
|
75
|
+
* — keeping it in lockstep with `toolDefinitions` so handlers don't have to
|
|
76
|
+
* defend themselves against being dispatched in states where their tool
|
|
77
|
+
* isn't advertised. Folds mutate this in place; `defineStatefulAgent`
|
|
78
|
+
* forbids folds when a factory is set, so the fold-mutation path is
|
|
79
|
+
* unreachable in that case.
|
|
80
|
+
*/
|
|
66
81
|
private toolHandlers;
|
|
82
|
+
/**
|
|
83
|
+
* Optional per-turn handler-map source. Mirrors `toolDefinitionsFactory` so
|
|
84
|
+
* the LLM-visible tools and the dispatchable handlers can be narrowed in
|
|
85
|
+
* lockstep. Resolved each tool-loop iteration before the LLM call.
|
|
86
|
+
*/
|
|
87
|
+
private toolHandlersFactory?;
|
|
67
88
|
private primerHistory?;
|
|
68
89
|
private activeAgentName?;
|
|
90
|
+
/**
|
|
91
|
+
* Per-turn display label resolved from the agent's `displayName`. Stamped
|
|
92
|
+
* onto outgoing messages and turn snapshots for UX; `activeAgentName` stays
|
|
93
|
+
* stable for routing/history-transform identity matching.
|
|
94
|
+
*/
|
|
95
|
+
private activeAgentLabel?;
|
|
96
|
+
private displayName?;
|
|
69
97
|
/**
|
|
70
98
|
* When set, `requestInteraction` delegates to this callback instead of using
|
|
71
99
|
* this driver's own pending map. Wired by `invokeSubAgent` so a sub-agent's
|
|
@@ -115,7 +143,7 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
115
143
|
/** Captured from `applyAgent` so we don't store the whole `AgentConfig`. */
|
|
116
144
|
private debugSnapshotter?;
|
|
117
145
|
private readonly maxTurnSnapshots;
|
|
118
|
-
constructor(aiProvider: AIProvider, toolHandlers?:
|
|
146
|
+
constructor(aiProvider: AIProvider, toolHandlers?: ToolHandlersInput, toolDefinitions?: ToolDefinitionsInput, systemPrompt?: SystemPromptInput, primerHistory?: ChatMessage[], maxToolIterations?: number, maxFoldOperations?: number, maxTurnSnapshots?: number);
|
|
119
147
|
/**
|
|
120
148
|
* Swap in a new agent's configuration. Called by OrchestratingDriver before
|
|
121
149
|
* each specialist turn so the shared driver runs with the right tools and prompt.
|