@genesislcap/ai-assistant 15.19.0 → 15.19.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/package.json +17 -18
- package/api-extractor.json +0 -11
- package/dist/dts/components/chat-driver/chat-driver.compact.test.d.ts +0 -2
- package/dist/dts/components/chat-driver/chat-driver.compact.test.d.ts.map +0 -1
- package/dist/dts/components/chat-driver/chat-driver.invocation-scope.test.d.ts +0 -2
- package/dist/dts/components/chat-driver/chat-driver.invocation-scope.test.d.ts.map +0 -1
- package/dist/dts/components/chat-driver/chat-driver.test.d.ts +0 -2
- package/dist/dts/components/chat-driver/chat-driver.test.d.ts.map +0 -1
- package/dist/dts/components/chat-driver/chat-driver.thinking-policy.test.d.ts +0 -2
- package/dist/dts/components/chat-driver/chat-driver.thinking-policy.test.d.ts.map +0 -1
- package/dist/dts/components/chat-driver/chat-driver.trace-capture.test.d.ts +0 -2
- package/dist/dts/components/chat-driver/chat-driver.trace-capture.test.d.ts.map +0 -1
- package/dist/dts/components/chat-driver/chat-driver.turn-usage.test.d.ts +0 -2
- package/dist/dts/components/chat-driver/chat-driver.turn-usage.test.d.ts.map +0 -1
- package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.test.d.ts +0 -2
- package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.test.d.ts.map +0 -1
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.budget.test.d.ts +0 -2
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.budget.test.d.ts.map +0 -1
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.cost.test.d.ts +0 -2
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.cost.test.d.ts.map +0 -1
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.pin.test.d.ts +0 -2
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.pin.test.d.ts.map +0 -1
- package/dist/dts/components/settings-modal/settings-modal.styles.test.d.ts +0 -2
- package/dist/dts/components/settings-modal/settings-modal.styles.test.d.ts.map +0 -1
- package/dist/dts/components/settings-modal/settings-modal.template.test.d.ts +0 -2
- package/dist/dts/components/settings-modal/settings-modal.template.test.d.ts.map +0 -1
- package/dist/dts/config/define-stateful-agent.test.d.ts +0 -2
- package/dist/dts/config/define-stateful-agent.test.d.ts.map +0 -1
- package/dist/dts/config/validate-providers.test.d.ts +0 -2
- package/dist/dts/config/validate-providers.test.d.ts.map +0 -1
- package/dist/dts/main/blocked-state.test.d.ts +0 -2
- package/dist/dts/main/blocked-state.test.d.ts.map +0 -1
- package/dist/dts/main/budget-meter.test.d.ts +0 -2
- package/dist/dts/main/budget-meter.test.d.ts.map +0 -1
- package/dist/dts/main/cost-session-banking.test.d.ts +0 -2
- package/dist/dts/main/cost-session-banking.test.d.ts.map +0 -1
- package/dist/dts/main/file-attachments.test.d.ts +0 -2
- package/dist/dts/main/file-attachments.test.d.ts.map +0 -1
- package/dist/dts/main/interaction-cost.test.d.ts +0 -2
- package/dist/dts/main/interaction-cost.test.d.ts.map +0 -1
- package/dist/dts/main/main.styles.test.d.ts +0 -2
- package/dist/dts/main/main.styles.test.d.ts.map +0 -1
- package/dist/dts/main/persistence-broken-sources.test.d.ts +0 -2
- package/dist/dts/main/persistence-broken-sources.test.d.ts.map +0 -1
- package/dist/dts/main/popout-interaction-gate.test.d.ts +0 -2
- package/dist/dts/main/popout-interaction-gate.test.d.ts.map +0 -1
- package/dist/dts/state/ai-assistant-slice.test.d.ts +0 -2
- package/dist/dts/state/ai-assistant-slice.test.d.ts.map +0 -1
- package/dist/dts/state/debug-event-log.test.d.ts +0 -2
- package/dist/dts/state/debug-event-log.test.d.ts.map +0 -1
- package/dist/dts/state/driver-registry.test.d.ts +0 -2
- package/dist/dts/state/driver-registry.test.d.ts.map +0 -1
- package/dist/dts/state/interaction-context.test.d.ts +0 -2
- package/dist/dts/state/interaction-context.test.d.ts.map +0 -1
- package/dist/dts/state/persistence/diagnostics-cursors.test.d.ts +0 -2
- package/dist/dts/state/persistence/diagnostics-cursors.test.d.ts.map +0 -1
- package/dist/dts/state/persistence/diagnostics.test.d.ts +0 -2
- package/dist/dts/state/persistence/diagnostics.test.d.ts.map +0 -1
- package/dist/dts/state/persistence/session-persistence-provider.test.d.ts +0 -2
- package/dist/dts/state/persistence/session-persistence-provider.test.d.ts.map +0 -1
- package/dist/dts/state/persistence/session-persistence.integration.test.d.ts +0 -2
- package/dist/dts/state/persistence/session-persistence.integration.test.d.ts.map +0 -1
- package/dist/dts/state/persistence/session-persister.test.d.ts +0 -2
- package/dist/dts/state/persistence/session-persister.test.d.ts.map +0 -1
- package/dist/dts/state/persistence/session-snapshot.test.d.ts +0 -2
- package/dist/dts/state/persistence/session-snapshot.test.d.ts.map +0 -1
- package/dist/dts/state/persistence/stateful-restore.e2e.test.d.ts +0 -2
- package/dist/dts/state/persistence/stateful-restore.e2e.test.d.ts.map +0 -1
- package/dist/dts/utils/animation-exclusivity.test.d.ts +0 -2
- package/dist/dts/utils/animation-exclusivity.test.d.ts.map +0 -1
- package/dist/dts/utils/collect-session-models.test.d.ts +0 -2
- package/dist/dts/utils/collect-session-models.test.d.ts.map +0 -1
- package/dist/dts/utils/condense-history.test.d.ts +0 -2
- package/dist/dts/utils/condense-history.test.d.ts.map +0 -1
- package/dist/dts/utils/cost-session-history.test.d.ts +0 -2
- package/dist/dts/utils/cost-session-history.test.d.ts.map +0 -1
- package/dist/dts/utils/derive-cost-session-title.test.d.ts +0 -2
- package/dist/dts/utils/derive-cost-session-title.test.d.ts.map +0 -1
- package/dist/dts/utils/flatten-sub-agent-messages.test.d.ts +0 -2
- package/dist/dts/utils/flatten-sub-agent-messages.test.d.ts.map +0 -1
- package/dist/dts/utils/history-transform.test.d.ts +0 -2
- package/dist/dts/utils/history-transform.test.d.ts.map +0 -1
- package/dist/dts/utils/message-partition.test.d.ts +0 -2
- package/dist/dts/utils/message-partition.test.d.ts.map +0 -1
- package/dist/dts/utils/resolve-cost-history-config.test.d.ts +0 -2
- package/dist/dts/utils/resolve-cost-history-config.test.d.ts.map +0 -1
- package/dist/dts/utils/resolve-preference-baseline.test.d.ts +0 -2
- package/dist/dts/utils/resolve-preference-baseline.test.d.ts.map +0 -1
- package/dist/dts/utils/strip-agent-handlers.test.d.ts +0 -2
- package/dist/dts/utils/strip-agent-handlers.test.d.ts.map +0 -1
- package/dist/dts/utils/sum-costs.test.d.ts +0 -2
- package/dist/dts/utils/sum-costs.test.d.ts.map +0 -1
- package/dist/dts/utils/sum-tokens.test.d.ts +0 -2
- package/dist/dts/utils/sum-tokens.test.d.ts.map +0 -1
- package/dist/dts/utils/sum-usage.test.d.ts +0 -2
- package/dist/dts/utils/sum-usage.test.d.ts.map +0 -1
- package/dist/dts/utils/usage-rows.test.d.ts +0 -2
- package/dist/dts/utils/usage-rows.test.d.ts.map +0 -1
- package/dist/esm/components/chat-driver/chat-driver.compact.test.js +0 -93
- package/dist/esm/components/chat-driver/chat-driver.invocation-scope.test.js +0 -238
- package/dist/esm/components/chat-driver/chat-driver.test.js +0 -2770
- package/dist/esm/components/chat-driver/chat-driver.thinking-policy.test.js +0 -137
- package/dist/esm/components/chat-driver/chat-driver.trace-capture.test.js +0 -200
- package/dist/esm/components/chat-driver/chat-driver.turn-usage.test.js +0 -268
- package/dist/esm/components/chat-interaction-wrapper/chat-interaction-wrapper.test.js +0 -104
- package/dist/esm/components/orchestrating-driver/orchestrating-driver.budget.test.js +0 -312
- package/dist/esm/components/orchestrating-driver/orchestrating-driver.cost.test.js +0 -76
- package/dist/esm/components/orchestrating-driver/orchestrating-driver.pin.test.js +0 -61
- package/dist/esm/components/settings-modal/settings-modal.styles.test.js +0 -80
- package/dist/esm/components/settings-modal/settings-modal.template.test.js +0 -91
- package/dist/esm/config/define-stateful-agent.test.js +0 -53
- package/dist/esm/config/validate-providers.test.js +0 -100
- package/dist/esm/main/blocked-state.test.js +0 -1065
- package/dist/esm/main/budget-meter.test.js +0 -359
- package/dist/esm/main/cost-session-banking.test.js +0 -538
- package/dist/esm/main/file-attachments.test.js +0 -164
- package/dist/esm/main/interaction-cost.test.js +0 -107
- package/dist/esm/main/main.styles.test.js +0 -161
- package/dist/esm/main/persistence-broken-sources.test.js +0 -180
- package/dist/esm/main/popout-interaction-gate.test.js +0 -54
- package/dist/esm/state/ai-assistant-slice.test.js +0 -229
- package/dist/esm/state/debug-event-log.test.js +0 -117
- package/dist/esm/state/driver-registry.test.js +0 -55
- package/dist/esm/state/interaction-context.test.js +0 -78
- package/dist/esm/state/persistence/diagnostics-cursors.test.js +0 -30
- package/dist/esm/state/persistence/diagnostics.test.js +0 -280
- package/dist/esm/state/persistence/session-persistence-provider.test.js +0 -110
- package/dist/esm/state/persistence/session-persistence.integration.test.js +0 -113
- package/dist/esm/state/persistence/session-persister.test.js +0 -613
- package/dist/esm/state/persistence/session-snapshot.test.js +0 -256
- package/dist/esm/state/persistence/stateful-restore.e2e.test.js +0 -158
- package/dist/esm/utils/animation-exclusivity.test.js +0 -52
- package/dist/esm/utils/collect-session-models.test.js +0 -53
- package/dist/esm/utils/condense-history.test.js +0 -547
- package/dist/esm/utils/cost-session-history.test.js +0 -174
- package/dist/esm/utils/derive-cost-session-title.test.js +0 -37
- package/dist/esm/utils/flatten-sub-agent-messages.test.js +0 -139
- package/dist/esm/utils/history-transform.test.js +0 -158
- package/dist/esm/utils/message-partition.test.js +0 -90
- package/dist/esm/utils/resolve-cost-history-config.test.js +0 -32
- package/dist/esm/utils/resolve-preference-baseline.test.js +0 -69
- package/dist/esm/utils/strip-agent-handlers.test.js +0 -81
- package/dist/esm/utils/sum-costs.test.js +0 -114
- package/dist/esm/utils/sum-tokens.test.js +0 -51
- package/dist/esm/utils/sum-usage.test.js +0 -164
- package/dist/esm/utils/usage-rows.test.js +0 -189
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/license.txt +0 -46
- package/sandbox/tsconfig.json +0 -8
- package/src/channel/ai-activity-bus.ts +0 -209
- package/src/channel/ai-activity-channel.ts +0 -146
- package/src/chat-driver-node.ts +0 -159
- package/src/components/activity-halo/activity-halo.ts +0 -106
- package/src/components/agent-picker/agent-picker.constants.ts +0 -2
- package/src/components/agent-picker/agent-picker.styles.ts +0 -24
- package/src/components/agent-picker/agent-picker.template.ts +0 -54
- package/src/components/agent-picker/agent-picker.ts +0 -99
- package/src/components/agent-picker/index.ts +0 -1
- package/src/components/ai-driver/ai-driver.ts +0 -166
- package/src/components/ai-driver/index.ts +0 -1
- package/src/components/chat-bubble/chat-bubble.styles.ts +0 -194
- package/src/components/chat-bubble/chat-bubble.template.ts +0 -67
- package/src/components/chat-bubble/chat-bubble.ts +0 -436
- package/src/components/chat-bubble/index.ts +0 -1
- package/src/components/chat-driver/align-event-globals.ts +0 -23
- package/src/components/chat-driver/chat-driver.compact.test.ts +0 -131
- package/src/components/chat-driver/chat-driver.invocation-scope.test.ts +0 -285
- package/src/components/chat-driver/chat-driver.test.ts +0 -3679
- package/src/components/chat-driver/chat-driver.thinking-policy.test.ts +0 -185
- package/src/components/chat-driver/chat-driver.trace-capture.test.ts +0 -251
- package/src/components/chat-driver/chat-driver.ts +0 -3925
- package/src/components/chat-driver/chat-driver.turn-usage.test.ts +0 -362
- package/src/components/chat-driver/index.ts +0 -1
- package/src/components/chat-interaction-wrapper/chat-interaction-wrapper.styles.ts +0 -7
- package/src/components/chat-interaction-wrapper/chat-interaction-wrapper.template.ts +0 -6
- package/src/components/chat-interaction-wrapper/chat-interaction-wrapper.test.ts +0 -144
- package/src/components/chat-interaction-wrapper/chat-interaction-wrapper.ts +0 -243
- package/src/components/chat-interaction-wrapper/index.ts +0 -3
- package/src/components/chat-markdown/chat-markdown.ts +0 -89
- package/src/components/chat-markdown/index.ts +0 -1
- package/src/components/flowing-waves-indicator.ts +0 -286
- package/src/components/halo-overlay.ts +0 -184
- package/src/components/orchestrating-driver/index.ts +0 -1
- package/src/components/orchestrating-driver/orchestrating-driver.budget.test.ts +0 -438
- package/src/components/orchestrating-driver/orchestrating-driver.cost.test.ts +0 -107
- package/src/components/orchestrating-driver/orchestrating-driver.pin.test.ts +0 -96
- package/src/components/orchestrating-driver/orchestrating-driver.ts +0 -813
- package/src/components/plasma-orb-indicator.ts +0 -281
- package/src/components/popout-manager/index.ts +0 -1
- package/src/components/popout-manager/popout-manager.ts +0 -212
- package/src/components/settings-modal/index.ts +0 -2
- package/src/components/settings-modal/settings-modal.styles.test.ts +0 -94
- package/src/components/settings-modal/settings-modal.styles.ts +0 -853
- package/src/components/settings-modal/settings-modal.template.test.ts +0 -124
- package/src/components/settings-modal/settings-modal.template.ts +0 -943
- package/src/components/waves-indicator.ts +0 -241
- package/src/config/config.ts +0 -608
- package/src/config/define-stateful-agent.test.ts +0 -64
- package/src/config/define-stateful-agent.ts +0 -642
- package/src/config/fallback-agents.ts +0 -29
- package/src/config/index.ts +0 -2
- package/src/config/validate-providers.test.ts +0 -148
- package/src/config/validate-providers.ts +0 -58
- package/src/index.ts +0 -29
- package/src/main/blocked-state.test.ts +0 -1444
- package/src/main/budget-meter.test.ts +0 -477
- package/src/main/cost-session-banking.test.ts +0 -679
- package/src/main/file-attachments.test.ts +0 -215
- package/src/main/index.ts +0 -3
- package/src/main/interaction-cost.test.ts +0 -140
- package/src/main/main.styles.test.ts +0 -216
- package/src/main/main.styles.ts +0 -995
- package/src/main/main.template.ts +0 -1119
- package/src/main/main.ts +0 -5432
- package/src/main/main.types.ts +0 -225
- package/src/main/persistence-broken-sources.test.ts +0 -219
- package/src/main/popout-interaction-gate.test.ts +0 -87
- package/src/provider/ai-provider-switcher.ts +0 -40
- package/src/provider/assistant-app-settings.ts +0 -84
- package/src/state/ai-assistant-slice.test.ts +0 -336
- package/src/state/ai-assistant-slice.ts +0 -604
- package/src/state/debug-event-log.test.ts +0 -154
- package/src/state/debug-event-log.ts +0 -358
- package/src/state/driver-registry.test.ts +0 -70
- package/src/state/driver-registry.ts +0 -79
- package/src/state/interaction-context.test.ts +0 -90
- package/src/state/interaction-context.ts +0 -101
- package/src/state/persistence/build-timeline-entries.ts +0 -66
- package/src/state/persistence/diagnostics-cursors.test.ts +0 -53
- package/src/state/persistence/diagnostics-cursors.ts +0 -80
- package/src/state/persistence/diagnostics.test.ts +0 -346
- package/src/state/persistence/diagnostics.ts +0 -220
- package/src/state/persistence/index.ts +0 -10
- package/src/state/persistence/persister-registry.ts +0 -55
- package/src/state/persistence/session-persistence-provider.test.ts +0 -136
- package/src/state/persistence/session-persistence-provider.ts +0 -226
- package/src/state/persistence/session-persistence.integration.test.ts +0 -141
- package/src/state/persistence/session-persister.test.ts +0 -787
- package/src/state/persistence/session-persister.ts +0 -917
- package/src/state/persistence/session-snapshot.test.ts +0 -352
- package/src/state/persistence/session-snapshot.ts +0 -344
- package/src/state/persistence/stateful-restore.e2e.test.ts +0 -229
- package/src/state/session-store.ts +0 -56
- package/src/styles/ai-colours.ts +0 -30
- package/src/styles/menu.ts +0 -187
- package/src/styles/settings-section.ts +0 -40
- package/src/suggestions/chat-suggestions.ts +0 -186
- package/src/tags/index.ts +0 -1
- package/src/types/ai-chat-widget.ts +0 -67
- package/src/types/interaction-context.ts +0 -82
- package/src/utils/animated-panel-toggle.ts +0 -62
- package/src/utils/animation-exclusivity.test.ts +0 -72
- package/src/utils/animation-exclusivity.ts +0 -40
- package/src/utils/banked-usage-baselines.ts +0 -90
- package/src/utils/collect-session-models.test.ts +0 -82
- package/src/utils/collect-session-models.ts +0 -65
- package/src/utils/condense-history.test.ts +0 -746
- package/src/utils/condense-history.ts +0 -448
- package/src/utils/cost-session-history.test.ts +0 -226
- package/src/utils/cost-session-history.ts +0 -218
- package/src/utils/derive-cost-session-title.test.ts +0 -63
- package/src/utils/derive-cost-session-title.ts +0 -76
- package/src/utils/flatten-sub-agent-messages.test.ts +0 -163
- package/src/utils/flatten-sub-agent-messages.ts +0 -88
- package/src/utils/format-usd.ts +0 -26
- package/src/utils/history-transform.test.ts +0 -228
- package/src/utils/history-transform.ts +0 -163
- package/src/utils/index.ts +0 -3
- package/src/utils/logger.ts +0 -3
- package/src/utils/message-partition.test.ts +0 -129
- package/src/utils/message-partition.ts +0 -115
- package/src/utils/resolve-cost-history-config.test.ts +0 -38
- package/src/utils/resolve-cost-history-config.ts +0 -38
- package/src/utils/resolve-preference-baseline.test.ts +0 -84
- package/src/utils/resolve-preference-baseline.ts +0 -80
- package/src/utils/strip-agent-handlers.test.ts +0 -99
- package/src/utils/strip-agent-handlers.ts +0 -53
- package/src/utils/sum-costs.test.ts +0 -136
- package/src/utils/sum-costs.ts +0 -18
- package/src/utils/sum-tokens.test.ts +0 -93
- package/src/utils/sum-tokens.ts +0 -68
- package/src/utils/sum-usage.test.ts +0 -191
- package/src/utils/sum-usage.ts +0 -208
- package/src/utils/tool-fold.ts +0 -181
- package/src/utils/usage-rows.test.ts +0 -237
- package/src/utils/usage-rows.ts +0 -187
- package/src/utils/with-timeout.ts +0 -24
- package/tsconfig.json +0 -9
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import { assert, createLogicSuite } from '@genesislcap/foundation-testing';
|
|
3
|
-
import { defineStatefulAgent } from '../../config/define-stateful-agent';
|
|
4
|
-
// Side-effect import — MUST come before `./chat-driver` so the driver subclasses
|
|
5
|
-
// jsdom's EventTarget rather than Node's native one. Mirrors chat-driver.test.ts.
|
|
6
|
-
import './align-event-globals';
|
|
7
|
-
import { ChatDriver } from './chat-driver';
|
|
8
|
-
// ---------------------------------------------------------------------------
|
|
9
|
-
// Sub-agent state scoping.
|
|
10
|
-
//
|
|
11
|
-
// A sub-agent config lives in the parent's `subAgentsMap`, keyed by NAME — one
|
|
12
|
-
// config object, reused for every invocation. Anything a handler closes over is
|
|
13
|
-
// therefore scoped to the *config*, not to the invocation.
|
|
14
|
-
//
|
|
15
|
-
// These tests PIN that behaviour; they do not wish it away. Per-conversation
|
|
16
|
-
// registration is deliberate, so a closure in a sub-agent config will always be
|
|
17
|
-
// config-scoped — no planned platform change (F8 included) alters it. F8 adds a
|
|
18
|
-
// separate invocation-scoped store to write to instead; it does not re-scope
|
|
19
|
-
// closures. Consumers that accumulate across a child's turns must use that store
|
|
20
|
-
// (today: a WeakMap keyed on `promptCtx.signal`), never a closure.
|
|
21
|
-
//
|
|
22
|
-
// ⚠ TO WHOEVER IMPLEMENTS THE PER-ACTIVATION-STATE TICKET
|
|
23
|
-
// (`defineStatefulAgent`: per-activation state and headless execution)
|
|
24
|
-
//
|
|
25
|
-
// Its acceptance criterion 2 — "two concurrent activations of the same config
|
|
26
|
-
// hold independent state, with a test that fails against today's shared closure
|
|
27
|
-
// variable" — reads almost word-for-word like the first two tests below. It is
|
|
28
|
-
// not the same subject, and they must be treated differently:
|
|
29
|
-
//
|
|
30
|
-
// • Criterion 2 concerns FRAMEWORK-owned state: `defineStatefulAgent`'s single
|
|
31
|
-
// `let state` (define-stateful-agent.ts:374). That is the bug it fixes, and
|
|
32
|
-
// it needs a NEW test of its own.
|
|
33
|
-
// • The first two tests below concern CONSUMER-owned closures in a plain
|
|
34
|
-
// `AgentConfig`. The platform cannot re-scope a closure someone wrote in
|
|
35
|
-
// their own factory, so these stay true afterwards. Do not delete or invert
|
|
36
|
-
// them to make criterion 2 look satisfied.
|
|
37
|
-
// • The third test — "a defineStatefulAgent config cannot be used as a
|
|
38
|
-
// sub-agent" — IS invalidated by that ticket (its criteria 1 and 3), and
|
|
39
|
-
// must be rewritten when it lands, not before.
|
|
40
|
-
//
|
|
41
|
-
// The provider here answers by rule rather than by scripted queue: sub-agent
|
|
42
|
-
// invocations dispatched from one assistant turn run concurrently under
|
|
43
|
-
// `Promise.all`, so a shared FIFO queue would make ordering — and the test —
|
|
44
|
-
// nondeterministic.
|
|
45
|
-
// ---------------------------------------------------------------------------
|
|
46
|
-
/**
|
|
47
|
-
* Answers by rule, not by scripted queue: sub-agent invocations dispatched from
|
|
48
|
-
* one assistant turn run concurrently under `Promise.all`, so a shared FIFO
|
|
49
|
-
* would make ordering — and the test — nondeterministic.
|
|
50
|
-
*
|
|
51
|
-
* `fanOut` controls how many `delegate` calls the parent emits in its single
|
|
52
|
-
* delegating turn. Parent turns after the first return plain text so the loop
|
|
53
|
-
* terminates.
|
|
54
|
-
*/
|
|
55
|
-
const ruleProvider = (fanOut) => {
|
|
56
|
-
let parentTurns = 0;
|
|
57
|
-
return {
|
|
58
|
-
chat: (_history, _userMessage, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
-
var _a;
|
|
60
|
-
const tools = ((_a = options === null || options === void 0 ? void 0 : options.tools) !== null && _a !== void 0 ? _a : []).map((t) => t.name);
|
|
61
|
-
// Child turn: it can only finish via its completion tool.
|
|
62
|
-
if (tools.includes('work')) {
|
|
63
|
-
return {
|
|
64
|
-
role: 'assistant',
|
|
65
|
-
content: '',
|
|
66
|
-
toolCalls: [{ id: 'w1', name: 'work', args: {} }],
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
// Parent turn — delegate once, then wrap up.
|
|
70
|
-
if (tools.includes('delegate') && parentTurns === 0) {
|
|
71
|
-
parentTurns += 1;
|
|
72
|
-
return {
|
|
73
|
-
role: 'assistant',
|
|
74
|
-
content: '',
|
|
75
|
-
toolCalls: Array.from({ length: fanOut }, (_, i) => ({
|
|
76
|
-
id: `d${i}`,
|
|
77
|
-
name: 'delegate',
|
|
78
|
-
args: {},
|
|
79
|
-
})),
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
return { role: 'assistant', content: 'done' };
|
|
83
|
-
}),
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
const makeRegistry = (provider) => ({
|
|
87
|
-
get: () => provider,
|
|
88
|
-
default: () => provider,
|
|
89
|
-
defaultName: () => 'test',
|
|
90
|
-
names: () => ['test'],
|
|
91
|
-
getStatus: () => __awaiter(void 0, void 0, void 0, function* () { return null; }),
|
|
92
|
-
listStatuses: () => __awaiter(void 0, void 0, void 0, function* () { return []; }),
|
|
93
|
-
});
|
|
94
|
-
const agent = (overrides) => (Object.assign({ description: 'test agent' }, overrides));
|
|
95
|
-
const makeDriver = (config, provider) => {
|
|
96
|
-
const driver = new ChatDriver(makeRegistry(provider), {
|
|
97
|
-
maxToolIterations: 20,
|
|
98
|
-
maxFoldOperations: 5,
|
|
99
|
-
sessionKey: '',
|
|
100
|
-
});
|
|
101
|
-
driver.applyAgent(config);
|
|
102
|
-
return driver;
|
|
103
|
-
};
|
|
104
|
-
const scope = createLogicSuite('ChatDriver sub-agent invocation scope');
|
|
105
|
-
// ---------------------------------------------------------------------------
|
|
106
|
-
scope('closure state is config-scoped, so concurrent invocations contaminate each other', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
107
|
-
// The natural-looking way to accumulate across a sub-agent's turns — a closure
|
|
108
|
-
// in the config factory — is created once, with the config, and shared by every
|
|
109
|
-
// invocation. This is the trap; the assertion records it rather than wanting it.
|
|
110
|
-
const collected = [];
|
|
111
|
-
const worker = agent({
|
|
112
|
-
name: 'worker',
|
|
113
|
-
toolDefinitions: [
|
|
114
|
-
{ name: 'work', description: 'work', parameters: { type: 'object', properties: {} } },
|
|
115
|
-
],
|
|
116
|
-
toolHandlers: {
|
|
117
|
-
work: (_args, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
118
|
-
var _a;
|
|
119
|
-
collected.push('item');
|
|
120
|
-
// Report what THIS invocation believes it has accumulated.
|
|
121
|
-
(_a = ctx.completeSubAgent) === null || _a === void 0 ? void 0 : _a.call(ctx, { seen: collected.length });
|
|
122
|
-
return 'worked';
|
|
123
|
-
}),
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
const outcomes = [];
|
|
127
|
-
const parent = agent({
|
|
128
|
-
name: 'boss',
|
|
129
|
-
subAgents: [worker],
|
|
130
|
-
toolDefinitions: [
|
|
131
|
-
{
|
|
132
|
-
name: 'delegate',
|
|
133
|
-
description: 'delegate',
|
|
134
|
-
parameters: { type: 'object', properties: {} },
|
|
135
|
-
},
|
|
136
|
-
],
|
|
137
|
-
toolHandlers: {
|
|
138
|
-
delegate: (_args, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
139
|
-
const outcome = yield ctx.requestSubAgent('worker', { task: 'go' });
|
|
140
|
-
outcomes.push(outcome);
|
|
141
|
-
return 'delegated';
|
|
142
|
-
}),
|
|
143
|
-
},
|
|
144
|
-
});
|
|
145
|
-
yield makeDriver(parent, ruleProvider(2)).sendMessage('go');
|
|
146
|
-
assert.is(outcomes.length, 2, 'both delegations should have resolved');
|
|
147
|
-
// Each invocation did exactly one unit of work, so an invocation-scoped
|
|
148
|
-
// accumulator would report 1 from both. A config-scoped one reports 1 and 2.
|
|
149
|
-
// Deterministic despite the concurrency: the handler pushes and reads with no
|
|
150
|
-
// await between, so two invocations cannot interleave mid-body.
|
|
151
|
-
const seen = outcomes.map((o) => { var _a; return (_a = o === null || o === void 0 ? void 0 : o.result) === null || _a === void 0 ? void 0 : _a.seen; }).sort();
|
|
152
|
-
assert.equal(seen, [1, 2], "the second invocation sees the first's work — if this ever reports [1,1], closures " +
|
|
153
|
-
'have become invocation-scoped and this test should be rewritten, not deleted');
|
|
154
|
-
}));
|
|
155
|
-
// ---------------------------------------------------------------------------
|
|
156
|
-
scope('closure state is config-scoped, so a later invocation resumes the earlier one', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
157
|
-
// The sequential form of the same trap: nothing resets the closure between
|
|
158
|
-
// invocations, so a second delegation resumes where the first left off. This is
|
|
159
|
-
// the failure CG8 describes — a retried child whose cursor is already exhausted
|
|
160
|
-
// emits nothing and completes silently.
|
|
161
|
-
const collected = [];
|
|
162
|
-
const worker = agent({
|
|
163
|
-
name: 'worker',
|
|
164
|
-
toolDefinitions: [
|
|
165
|
-
{ name: 'work', description: 'work', parameters: { type: 'object', properties: {} } },
|
|
166
|
-
],
|
|
167
|
-
toolHandlers: {
|
|
168
|
-
work: (_args, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
169
|
-
var _a;
|
|
170
|
-
collected.push('item');
|
|
171
|
-
(_a = ctx.completeSubAgent) === null || _a === void 0 ? void 0 : _a.call(ctx, { seen: collected.length });
|
|
172
|
-
return 'worked';
|
|
173
|
-
}),
|
|
174
|
-
},
|
|
175
|
-
});
|
|
176
|
-
const outcomes = [];
|
|
177
|
-
const parent = agent({
|
|
178
|
-
name: 'boss',
|
|
179
|
-
subAgents: [worker],
|
|
180
|
-
toolDefinitions: [
|
|
181
|
-
{ name: 'delegate', description: 'delegate', parameters: { type: 'object', properties: {} } },
|
|
182
|
-
],
|
|
183
|
-
toolHandlers: {
|
|
184
|
-
// Await them one after the other — no concurrency involved.
|
|
185
|
-
delegate: (_args, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
186
|
-
outcomes.push(yield ctx.requestSubAgent('worker', { task: 'first' }));
|
|
187
|
-
outcomes.push(yield ctx.requestSubAgent('worker', { task: 'second' }));
|
|
188
|
-
return 'delegated';
|
|
189
|
-
}),
|
|
190
|
-
},
|
|
191
|
-
});
|
|
192
|
-
yield makeDriver(parent, ruleProvider(1)).sendMessage('go');
|
|
193
|
-
const seen = outcomes.map((o) => { var _a; return (_a = o === null || o === void 0 ? void 0 : o.result) === null || _a === void 0 ? void 0 : _a.seen; });
|
|
194
|
-
assert.equal(seen, [1, 2], "a second invocation does NOT start from zero — it resumes the first's accumulator");
|
|
195
|
-
}));
|
|
196
|
-
// ---------------------------------------------------------------------------
|
|
197
|
-
scope('a defineStatefulAgent config cannot be used as a sub-agent', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
198
|
-
// `init` runs from `onActivate`, which only OrchestratingDriver fires on an
|
|
199
|
-
// agent switch. `invokeSubAgent` builds a raw ChatDriver and calls
|
|
200
|
-
// `applyAgent` directly, so a stateful sub-agent never initialises. This test
|
|
201
|
-
// pins that boundary — it is a documented-by-behaviour constraint, not a bug,
|
|
202
|
-
// and the failure is loud rather than silent.
|
|
203
|
-
const stateful = defineStatefulAgent({
|
|
204
|
-
name: 'worker',
|
|
205
|
-
description: 'stateful worker',
|
|
206
|
-
init: () => ({ count: 0 }),
|
|
207
|
-
systemPrompt: ({ state }) => `count=${state.count}`,
|
|
208
|
-
toolDefinitions: [
|
|
209
|
-
{ name: 'work', description: 'work', parameters: { type: 'object', properties: {} } },
|
|
210
|
-
],
|
|
211
|
-
toolHandlers: () => ({
|
|
212
|
-
work: (_args, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
213
|
-
var _a;
|
|
214
|
-
(_a = ctx.completeSubAgent) === null || _a === void 0 ? void 0 : _a.call(ctx, { ok: true });
|
|
215
|
-
return 'worked';
|
|
216
|
-
}),
|
|
217
|
-
}),
|
|
218
|
-
});
|
|
219
|
-
let outcome;
|
|
220
|
-
const parent = agent({
|
|
221
|
-
name: 'boss',
|
|
222
|
-
subAgents: [stateful],
|
|
223
|
-
toolDefinitions: [
|
|
224
|
-
{ name: 'delegate', description: 'delegate', parameters: { type: 'object', properties: {} } },
|
|
225
|
-
],
|
|
226
|
-
toolHandlers: {
|
|
227
|
-
delegate: (_args, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
228
|
-
outcome = yield ctx.requestSubAgent('worker', { task: 'go' });
|
|
229
|
-
return 'delegated';
|
|
230
|
-
}),
|
|
231
|
-
},
|
|
232
|
-
});
|
|
233
|
-
yield makeDriver(parent, ruleProvider(1)).sendMessage('go');
|
|
234
|
-
assert.ok(outcome, 'the delegation should have resolved rather than hanging');
|
|
235
|
-
assert.is(outcome.ok, false, `a stateful sub-agent never runs init (onActivate is orchestrator-only), so the ` +
|
|
236
|
-
`invocation must fail rather than silently run with undefined state — got ${JSON.stringify(outcome)}`);
|
|
237
|
-
}));
|
|
238
|
-
scope.run();
|