indusagi-coding-agent 0.2.4 → 0.2.8
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/CHANGELOG.md +9 -0
- package/LICENSE +661 -0
- package/README.md +99 -1
- package/dist/entry.js +13551 -23107
- package/dist/guardrails.js +822 -8248
- package/dist/index.js +12547 -22190
- package/package.json +8 -7
- package/dist/types/addons/addons.test.d.ts +0 -21
- package/dist/types/addons/contract.d.ts +0 -640
- package/dist/types/addons/dispatch/event-dispatcher.d.ts +0 -140
- package/dist/types/addons/dispatch/index.d.ts +0 -23
- package/dist/types/addons/dispatch/tool-interceptor.d.ts +0 -128
- package/dist/types/addons/host.d.ts +0 -246
- package/dist/types/addons/index.d.ts +0 -51
- package/dist/types/addons/manifest.d.ts +0 -56
- package/dist/types/addons/sandbox.d.ts +0 -103
- package/dist/types/addons/surface.d.ts +0 -42
- package/dist/types/boot/auth-vault.d.ts +0 -29
- package/dist/types/boot/boot.d.ts +0 -26
- package/dist/types/boot/boot.test.d.ts +0 -15
- package/dist/types/boot/contract.d.ts +0 -236
- package/dist/types/boot/heap.d.ts +0 -31
- package/dist/types/boot/index.d.ts +0 -20
- package/dist/types/boot/invocation.d.ts +0 -40
- package/dist/types/boot/invocation.test.d.ts +0 -8
- package/dist/types/boot/runners/addon-wiring.d.ts +0 -103
- package/dist/types/boot/runners/addon-wiring.test.d.ts +0 -19
- package/dist/types/boot/runners/checkpoint.d.ts +0 -133
- package/dist/types/boot/runners/checkpoint.test.d.ts +0 -12
- package/dist/types/boot/runners/delegate-runner.d.ts +0 -109
- package/dist/types/boot/runners/delegate-runner.test.d.ts +0 -13
- package/dist/types/boot/runners/index.d.ts +0 -13
- package/dist/types/boot/runners/link-runner.d.ts +0 -20
- package/dist/types/boot/runners/memdir.d.ts +0 -103
- package/dist/types/boot/runners/memdir.test.d.ts +0 -12
- package/dist/types/boot/runners/oneshot-runner.d.ts +0 -19
- package/dist/types/boot/runners/read-state.d.ts +0 -82
- package/dist/types/boot/runners/read-state.test.d.ts +0 -10
- package/dist/types/boot/runners/registry.d.ts +0 -30
- package/dist/types/boot/runners/repl-runner.d.ts +0 -19
- package/dist/types/boot/runners/server-mode.d.ts +0 -71
- package/dist/types/boot/runners/session-persist.test.d.ts +0 -10
- package/dist/types/boot/runners/session.d.ts +0 -88
- package/dist/types/boot/runners/session.test.d.ts +0 -15
- package/dist/types/boot/server-token.d.ts +0 -97
- package/dist/types/boot/stages.d.ts +0 -92
- package/dist/types/boot/upgrade/apply.d.ts +0 -45
- package/dist/types/boot/upgrade/index.d.ts +0 -13
- package/dist/types/boot/upgrade/upgrades.d.ts +0 -126
- package/dist/types/briefing/briefing.test.d.ts +0 -15
- package/dist/types/briefing/compose.d.ts +0 -37
- package/dist/types/briefing/context-docs.d.ts +0 -38
- package/dist/types/briefing/context-docs.test.d.ts +0 -18
- package/dist/types/briefing/contract.d.ts +0 -686
- package/dist/types/briefing/index.d.ts +0 -29
- package/dist/types/briefing/macros.d.ts +0 -206
- package/dist/types/briefing/skills.d.ts +0 -67
- package/dist/types/capability-deck/bridge-ledger/index.d.ts +0 -25
- package/dist/types/capability-deck/bridge-ledger/key.d.ts +0 -65
- package/dist/types/capability-deck/bridge-ledger/ledger.d.ts +0 -129
- package/dist/types/capability-deck/bridge-ledger/network.d.ts +0 -115
- package/dist/types/capability-deck/builtin-bridge.d.ts +0 -114
- package/dist/types/capability-deck/capability-deck.test.d.ts +0 -18
- package/dist/types/capability-deck/cards/bg-process-card.d.ts +0 -99
- package/dist/types/capability-deck/cards/index.d.ts +0 -37
- package/dist/types/capability-deck/cards/memory-card.d.ts +0 -68
- package/dist/types/capability-deck/cards/plan-file.d.ts +0 -56
- package/dist/types/capability-deck/cards/plan-tools.d.ts +0 -97
- package/dist/types/capability-deck/cards/plan-tools.test.d.ts +0 -9
- package/dist/types/capability-deck/cards/saas-card.d.ts +0 -78
- package/dist/types/capability-deck/cards/task-card.d.ts +0 -106
- package/dist/types/capability-deck/cards/todo-card.d.ts +0 -78
- package/dist/types/capability-deck/cards/workflow-card.d.ts +0 -55
- package/dist/types/capability-deck/cards/workflow-card.test.d.ts +0 -12
- package/dist/types/capability-deck/checkpoint.int.test.d.ts +0 -25
- package/dist/types/capability-deck/contract.d.ts +0 -318
- package/dist/types/capability-deck/index.d.ts +0 -46
- package/dist/types/capability-deck/manifest.d.ts +0 -60
- package/dist/types/capability-deck/provision.d.ts +0 -76
- package/dist/types/capability-deck/read-edit-gate.int.test.d.ts +0 -21
- package/dist/types/channels/channels.test.d.ts +0 -15
- package/dist/types/channels/contract.d.ts +0 -489
- package/dist/types/channels/framer.d.ts +0 -49
- package/dist/types/channels/index.d.ts +0 -24
- package/dist/types/channels/link/dialog.d.ts +0 -138
- package/dist/types/channels/link/driver.d.ts +0 -81
- package/dist/types/channels/link/index.d.ts +0 -13
- package/dist/types/channels/link/server.d.ts +0 -70
- package/dist/types/channels/oneshot.d.ts +0 -37
- package/dist/types/channels/ops.d.ts +0 -89
- package/dist/types/channels/session-ops.d.ts +0 -80
- package/dist/types/conductor/bash-guard.d.ts +0 -106
- package/dist/types/conductor/bash-guard.test.d.ts +0 -17
- package/dist/types/conductor/catalog/catalog.d.ts +0 -87
- package/dist/types/conductor/catalog/index.d.ts +0 -14
- package/dist/types/conductor/catalog/matcher.d.ts +0 -47
- package/dist/types/conductor/conductor.d.ts +0 -213
- package/dist/types/conductor/conductor.test.d.ts +0 -10
- package/dist/types/conductor/contract.d.ts +0 -838
- package/dist/types/conductor/diagnostics.d.ts +0 -183
- package/dist/types/conductor/diagnostics.test.d.ts +0 -10
- package/dist/types/conductor/index.d.ts +0 -26
- package/dist/types/conductor/permission-gate.integration.test.d.ts +0 -22
- package/dist/types/conductor/permission-wiring.test.d.ts +0 -14
- package/dist/types/conductor/permissions.d.ts +0 -287
- package/dist/types/conductor/permissions.test.d.ts +0 -12
- package/dist/types/conductor/plan-mode.integration.test.d.ts +0 -23
- package/dist/types/conductor/post-edit-diagnostics.test.d.ts +0 -18
- package/dist/types/conductor/quota-error.d.ts +0 -35
- package/dist/types/conductor/signal-hub/hub.d.ts +0 -83
- package/dist/types/conductor/signal-hub/index.d.ts +0 -19
- package/dist/types/conductor/signal-hub/translate.d.ts +0 -77
- package/dist/types/conductor/skill-parse/index.d.ts +0 -10
- package/dist/types/conductor/skill-parse/parse.d.ts +0 -67
- package/dist/types/conductor/submit.test.d.ts +0 -28
- package/dist/types/conductor/transcript-store/index.d.ts +0 -16
- package/dist/types/conductor/transcript-store/serialize.d.ts +0 -106
- package/dist/types/conductor/transcript-store/serialize.test.d.ts +0 -10
- package/dist/types/conductor/transcript-store/store.d.ts +0 -188
- package/dist/types/console/auth-status.d.ts +0 -28
- package/dist/types/console/components/AgentsView.d.ts +0 -41
- package/dist/types/console/components/BackgroundAgents.d.ts +0 -63
- package/dist/types/console/components/BackgroundAgents.test.d.ts +0 -8
- package/dist/types/console/components/Banner.d.ts +0 -110
- package/dist/types/console/components/Composer.d.ts +0 -37
- package/dist/types/console/components/StatusBar.d.ts +0 -42
- package/dist/types/console/components/TerminalConsole.d.ts +0 -27
- package/dist/types/console/components/WorkingIndicator.d.ts +0 -44
- package/dist/types/console/components/WorkingIndicator.test.d.ts +0 -9
- package/dist/types/console/components/banner-sweep.d.ts +0 -55
- package/dist/types/console/components/banner.test.d.ts +0 -9
- package/dist/types/console/components/welcome.d.ts +0 -115
- package/dist/types/console/components/welcome.test.d.ts +0 -9
- package/dist/types/console/console.test.d.ts +0 -19
- package/dist/types/console/contract.d.ts +0 -611
- package/dist/types/console/index.d.ts +0 -34
- package/dist/types/console/input/complete.d.ts +0 -120
- package/dist/types/console/input/dir-reader.d.ts +0 -28
- package/dist/types/console/input/index.d.ts +0 -24
- package/dist/types/console/input/input.test.d.ts +0 -14
- package/dist/types/console/input/keymap.d.ts +0 -193
- package/dist/types/console/input/paste.d.ts +0 -183
- package/dist/types/console/mount.d.ts +0 -53
- package/dist/types/console/overlays/approval-queue.d.ts +0 -88
- package/dist/types/console/overlays/approval.d.ts +0 -104
- package/dist/types/console/overlays/approval.test.d.ts +0 -17
- package/dist/types/console/overlays/auth.d.ts +0 -31
- package/dist/types/console/overlays/boards.d.ts +0 -55
- package/dist/types/console/overlays/host.d.ts +0 -45
- package/dist/types/console/overlays/index.d.ts +0 -15
- package/dist/types/console/overlays/pickers.d.ts +0 -37
- package/dist/types/console/overlays/sessions.d.ts +0 -29
- package/dist/types/console/reducer.d.ts +0 -51
- package/dist/types/console/slash/builtins.d.ts +0 -33
- package/dist/types/console/slash/commands/dynamic.d.ts +0 -57
- package/dist/types/console/slash/commands/dynamic.test.d.ts +0 -9
- package/dist/types/console/slash/commands/integrations.d.ts +0 -28
- package/dist/types/console/slash/commands/integrations.test.d.ts +0 -18
- package/dist/types/console/slash/commands/shared.d.ts +0 -72
- package/dist/types/console/slash/commands/transcript.d.ts +0 -24
- package/dist/types/console/slash/commands/transcript.test.d.ts +0 -10
- package/dist/types/console/slash/commands/workbench.d.ts +0 -21
- package/dist/types/console/slash/commands/workbench.test.d.ts +0 -10
- package/dist/types/console/slash/index.d.ts +0 -34
- package/dist/types/console/slash/registry.d.ts +0 -90
- package/dist/types/console/slash/resolve.d.ts +0 -109
- package/dist/types/console/slash/slash.test.d.ts +0 -18
- package/dist/types/console/startup.d.ts +0 -119
- package/dist/types/console/theme/adapter.d.ts +0 -79
- package/dist/types/console/theme/index.d.ts +0 -18
- package/dist/types/console/theme/palette.d.ts +0 -77
- package/dist/types/console/theme/resolve.d.ts +0 -45
- package/dist/types/console/theme/theme.test.d.ts +0 -16
- package/dist/types/console/theme/tokens.d.ts +0 -62
- package/dist/types/entry.d.ts +0 -17
- package/dist/types/guardrails.d.ts +0 -33
- package/dist/types/index.d.ts +0 -24
- package/dist/types/insight/channel.d.ts +0 -45
- package/dist/types/insight/contract.d.ts +0 -411
- package/dist/types/insight/index.d.ts +0 -26
- package/dist/types/insight/insight.test.d.ts +0 -17
- package/dist/types/insight/recorder.d.ts +0 -63
- package/dist/types/insight/redaction.d.ts +0 -44
- package/dist/types/insight/replay.d.ts +0 -77
- package/dist/types/insight/sampling.d.ts +0 -84
- package/dist/types/insight/serialize.d.ts +0 -54
- package/dist/types/insight/sinks/console.d.ts +0 -36
- package/dist/types/insight/sinks/file.d.ts +0 -37
- package/dist/types/insight/sinks/index.d.ts +0 -16
- package/dist/types/insight/sinks/stream.d.ts +0 -53
- package/dist/types/kit/clipboard-image.d.ts +0 -40
- package/dist/types/kit/external-editor.d.ts +0 -35
- package/dist/types/kit/image.d.ts +0 -102
- package/dist/types/kit/index.d.ts +0 -29
- package/dist/types/kit/kit.test.d.ts +0 -13
- package/dist/types/kit/shell.d.ts +0 -50
- package/dist/types/kit/tool-fetch.d.ts +0 -165
- package/dist/types/launch/catalog.d.ts +0 -51
- package/dist/types/launch/contract.d.ts +0 -387
- package/dist/types/launch/credentials.d.ts +0 -112
- package/dist/types/launch/index.d.ts +0 -28
- package/dist/types/launch/invocation/attachments.d.ts +0 -72
- package/dist/types/launch/invocation/flags.d.ts +0 -59
- package/dist/types/launch/invocation/index.d.ts +0 -23
- package/dist/types/launch/invocation/read.d.ts +0 -52
- package/dist/types/launch/invocation/usage.d.ts +0 -25
- package/dist/types/launch/launch.test.d.ts +0 -20
- package/dist/types/launch/login.d.ts +0 -68
- package/dist/types/launch/oauth.d.ts +0 -101
- package/dist/types/launch/oauth.test.d.ts +0 -20
- package/dist/types/launch/packages.d.ts +0 -75
- package/dist/types/launch/packages.test.d.ts +0 -15
- package/dist/types/launch/pickers.d.ts +0 -97
- package/dist/types/runtime-bridge/bridges/_drive.d.ts +0 -74
- package/dist/types/runtime-bridge/bridges/builtins.d.ts +0 -77
- package/dist/types/runtime-bridge/bridges/claude-cli.d.ts +0 -37
- package/dist/types/runtime-bridge/bridges/codex-cli.d.ts +0 -27
- package/dist/types/runtime-bridge/bridges/index.d.ts +0 -15
- package/dist/types/runtime-bridge/bridges/indusagi-cli.d.ts +0 -36
- package/dist/types/runtime-bridge/broker.d.ts +0 -182
- package/dist/types/runtime-bridge/contract.d.ts +0 -436
- package/dist/types/runtime-bridge/index.d.ts +0 -21
- package/dist/types/runtime-bridge/runtime-bridge.test.d.ts +0 -17
- package/dist/types/runtime-bridge/sink.d.ts +0 -59
- package/dist/types/sessions/contract.d.ts +0 -79
- package/dist/types/sessions/index.d.ts +0 -11
- package/dist/types/sessions/library.d.ts +0 -95
- package/dist/types/sessions/sessions.test.d.ts +0 -11
- package/dist/types/settings/contract.d.ts +0 -175
- package/dist/types/settings/index.d.ts +0 -13
- package/dist/types/settings/manager.d.ts +0 -109
- package/dist/types/settings/settings.test.d.ts +0 -16
- package/dist/types/transcript-export/index.d.ts +0 -20
- package/dist/types/transcript-export/publish.d.ts +0 -81
- package/dist/types/transcript-export/sgr.d.ts +0 -90
- package/dist/types/transcript-export/template.d.ts +0 -64
- package/dist/types/transcript-export/theme-bridge.d.ts +0 -99
- package/dist/types/transcript-export/transcript-export.test.d.ts +0 -16
- package/dist/types/window-budget/budget/estimate.d.ts +0 -47
- package/dist/types/window-budget/budget/gate.d.ts +0 -37
- package/dist/types/window-budget/budget/index.d.ts +0 -14
- package/dist/types/window-budget/budget/slice.d.ts +0 -38
- package/dist/types/window-budget/condenser.d.ts +0 -73
- package/dist/types/window-budget/contract.d.ts +0 -182
- package/dist/types/window-budget/index.d.ts +0 -17
- package/dist/types/window-budget/microcompact.d.ts +0 -68
- package/dist/types/window-budget/microcompact.test.d.ts +0 -16
- package/dist/types/window-budget/rehydrate.d.ts +0 -56
- package/dist/types/window-budget/summarize/condense.d.ts +0 -76
- package/dist/types/window-budget/summarize/index.d.ts +0 -12
- package/dist/types/window-budget/summarize/prompt.d.ts +0 -56
- package/dist/types/window-budget/window-budget.test.d.ts +0 -18
- package/dist/types/workflow-engine/agent-runner.d.ts +0 -124
- package/dist/types/workflow-engine/agent-runner.test.d.ts +0 -8
- package/dist/types/workflow-engine/display.d.ts +0 -148
- package/dist/types/workflow-engine/display.test.d.ts +0 -1
- package/dist/types/workflow-engine/engine.d.ts +0 -183
- package/dist/types/workflow-engine/engine.test.d.ts +0 -1
- package/dist/types/workflow-engine/index.d.ts +0 -21
- package/dist/types/workflow-engine/parse.d.ts +0 -64
- package/dist/types/workflow-engine/parse.test.d.ts +0 -1
- package/dist/types/workflow-engine/structured-output.d.ts +0 -51
- package/dist/types/workflow-engine/structured-output.test.d.ts +0 -1
- package/dist/types/workspace/brand.d.ts +0 -26
- package/dist/types/workspace/index.d.ts +0 -11
- package/dist/types/workspace/locator.d.ts +0 -50
- package/dist/types/workspace/runtime-detect.d.ts +0 -56
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SignalHub — the conductor's product-event fan-out.
|
|
3
|
-
*
|
|
4
|
-
* A tiny, synchronous publish/subscribe bus over the {@link SessionSignal}
|
|
5
|
-
* stream. The conductor owns one hub per session: behavior modules (the turn
|
|
6
|
-
* loop, the persistence layer, the auto-condense pass) push signals in via
|
|
7
|
-
* {@link SignalHub.emit}, and every registered consumer handler receives them in
|
|
8
|
-
* registration order.
|
|
9
|
-
*
|
|
10
|
-
* Design (deliberately the conductor's own, not the framework's loop emitter):
|
|
11
|
-
* - Handlers live in an insertion-ordered `Set`, so registration order is the
|
|
12
|
-
* delivery order and duplicate handler identities collapse to one slot.
|
|
13
|
-
* - {@link SignalHub.subscribe} returns an unsubscribe thunk; calling it (even
|
|
14
|
-
* during a dispatch, even more than once) is safe and idempotent.
|
|
15
|
-
* - {@link SignalHub.emit} fans out over a *snapshot* of the handler set, so a
|
|
16
|
-
* handler that subscribes or unsubscribes mid-dispatch never corrupts the
|
|
17
|
-
* in-progress iteration — the change takes effect on the next emit.
|
|
18
|
-
* - A throwing handler is isolated: its error is routed to the optional
|
|
19
|
-
* {@link SignalHubOptions.onHandlerError} sink and the remaining handlers
|
|
20
|
-
* still run. One bad consumer never silences the others.
|
|
21
|
-
*
|
|
22
|
-
* The hub is transport-agnostic: it knows nothing about the framework `Agent`,
|
|
23
|
-
* persistence, or how signals are produced. The {@link module:translate}
|
|
24
|
-
* translator is what turns raw framework events into the {@link SessionSignal}s
|
|
25
|
-
* that flow through here.
|
|
26
|
-
*/
|
|
27
|
-
import type { SessionSignal, SignalHandler } from "../contract";
|
|
28
|
-
/** Tuning hooks for a {@link SignalHub}. All optional. */
|
|
29
|
-
export interface SignalHubOptions {
|
|
30
|
-
/**
|
|
31
|
-
* Invoked when a subscribed handler throws during {@link SignalHub.emit}.
|
|
32
|
-
*
|
|
33
|
-
* Lets the owner observe/log faults in consumer code without aborting the
|
|
34
|
-
* fan-out. If omitted, handler errors are swallowed so a misbehaving consumer
|
|
35
|
-
* cannot break signal delivery to the others. This sink is itself guarded —
|
|
36
|
-
* if it throws, the throw is ignored.
|
|
37
|
-
*
|
|
38
|
-
* @param error the value the handler threw
|
|
39
|
-
* @param signal the signal that was being delivered when it threw
|
|
40
|
-
*/
|
|
41
|
-
readonly onHandlerError?: (error: unknown, signal: SessionSignal) => void;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* A synchronous fan-out bus for {@link SessionSignal}s.
|
|
45
|
-
*
|
|
46
|
-
* Construct one per session; subscribe consumers; emit signals. Not a framework
|
|
47
|
-
* type and not wired to one — purely the conductor's own event surface.
|
|
48
|
-
*/
|
|
49
|
-
export declare class SignalHub {
|
|
50
|
-
/** Insertion-ordered live set of subscribed handlers. */
|
|
51
|
-
private readonly handlers;
|
|
52
|
-
private readonly onHandlerError?;
|
|
53
|
-
constructor(options?: SignalHubOptions);
|
|
54
|
-
/**
|
|
55
|
-
* Register a handler to receive every subsequently emitted signal.
|
|
56
|
-
*
|
|
57
|
-
* Registering the same function reference twice is a no-op (the `Set`
|
|
58
|
-
* collapses it). The returned thunk removes the handler; it is idempotent and
|
|
59
|
-
* safe to call during a dispatch.
|
|
60
|
-
*
|
|
61
|
-
* @param handler the consumer callback
|
|
62
|
-
* @returns an unsubscribe function
|
|
63
|
-
*/
|
|
64
|
-
subscribe(handler: SignalHandler): () => void;
|
|
65
|
-
/**
|
|
66
|
-
* Fan a signal out to every currently-subscribed handler, in registration
|
|
67
|
-
* order.
|
|
68
|
-
*
|
|
69
|
-
* Iterates a snapshot of the handler set, so subscribe/unsubscribe performed
|
|
70
|
-
* by a handler mid-dispatch affects only later emits. A throwing handler is
|
|
71
|
-
* isolated via {@link SignalHubOptions.onHandlerError}; the remaining handlers
|
|
72
|
-
* still run.
|
|
73
|
-
*
|
|
74
|
-
* @param signal the signal to deliver
|
|
75
|
-
*/
|
|
76
|
-
emit(signal: SessionSignal): void;
|
|
77
|
-
/** Number of currently-subscribed handlers. */
|
|
78
|
-
get size(): number;
|
|
79
|
-
/** Remove every handler. Subsequent {@link emit} calls deliver to no one. */
|
|
80
|
-
clear(): void;
|
|
81
|
-
/** Route a handler error to the sink, guarding the sink itself. */
|
|
82
|
-
private report;
|
|
83
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* signal-hub — the conductor's product-event hub + framework-event translator.
|
|
3
|
-
*
|
|
4
|
-
* Two cooperating pieces sitting between the framework `Agent` loop and the
|
|
5
|
-
* conductor's consumers:
|
|
6
|
-
*
|
|
7
|
-
* - {@link SignalHub} — a synchronous, insertion-ordered fan-out bus over the
|
|
8
|
-
* {@link SessionSignal} stream. Behavior modules emit into it; UI/print/RPC
|
|
9
|
-
* consumers subscribe to it.
|
|
10
|
-
* - {@link translateAgentEvent} — the pure projection that turns a single
|
|
11
|
-
* framework {@link AgentEvent} into the zero-or-more {@link SessionSignal}s
|
|
12
|
-
* that flow through the hub. {@link TRANSLATOR_TABLE} is the underlying,
|
|
13
|
-
* exhaustiveness-checked dispatch table (exported for inspection/testing).
|
|
14
|
-
*
|
|
15
|
-
* Typical wiring: subscribe the framework loop, run each raw event through
|
|
16
|
-
* `translateAgentEvent`, and `emit` the results on a `SignalHub`.
|
|
17
|
-
*/
|
|
18
|
-
export { SignalHub, type SignalHubOptions } from "./hub";
|
|
19
|
-
export { translateAgentEvent, TRANSLATOR_TABLE } from "./translate";
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* translateAgentEvent — the framework-event → {@link SessionSignal} projector.
|
|
3
|
-
*
|
|
4
|
-
* The framework `Agent` emits a fine-grained {@link AgentEvent} stream for its
|
|
5
|
-
* own loop (lifecycle, per-turn, per-message, per-tool). The conductor does not
|
|
6
|
-
* leak that union to consumers; it projects each framework event down to zero or
|
|
7
|
-
* more *product-level* {@link SessionSignal}s, which then flow through the
|
|
8
|
-
* {@link SignalHub}. This module is that projection — and nothing else: it is a
|
|
9
|
-
* pure, side-effect-free function over a single event.
|
|
10
|
-
*
|
|
11
|
-
* Why a table, not a `switch`:
|
|
12
|
-
* - The mapping is keyed on the framework event's `type` discriminant, so it is
|
|
13
|
-
* expressed as a {@link TranslatorTable} — one entry per `AgentEventType`.
|
|
14
|
-
* The table type is `{ [K in AgentEventType]: (ev) => SessionSignal[] }`, so
|
|
15
|
-
* adding a framework event variant is a compile error until a rule exists for
|
|
16
|
-
* it. Exhaustiveness is enforced by the type system, not by a `default` arm.
|
|
17
|
-
* - Each rule receives the precisely-narrowed event member (via
|
|
18
|
-
* {@link ExtractAgentEvent}) and returns the signals it produces.
|
|
19
|
-
*
|
|
20
|
-
* Mapping rules (framework `type` → product signals):
|
|
21
|
-
* - `agent_start` / `turn_start` / `message_start` / `agent_end`
|
|
22
|
-
* → `[]` (loop bookkeeping; not product-visible)
|
|
23
|
-
* - `message_end` → one `prompt` { text } for a *user* message
|
|
24
|
-
* (the turn is now committed), one `fault` for
|
|
25
|
-
* an errored *assistant* message, else `[]`
|
|
26
|
-
* - `tool_execution_start` → one `tool_start` { id, name }
|
|
27
|
-
* - `tool_execution_update` → one `tool_update` { id, name, details } — the
|
|
28
|
-
* running tool's partial-result detail (e.g. the
|
|
29
|
-
* live `◆ Workflow` snapshot) re-projected so the
|
|
30
|
-
* console can update the transcript in place
|
|
31
|
-
* - `tool_execution_end` → one `tool_end` { id, ok: !isError }
|
|
32
|
-
* - `turn_end` → one `turn_end` { usage }
|
|
33
|
-
* - `message_update` → delegated to the inner streaming dispatch on
|
|
34
|
-
* `assistantMessageEvent.type`:
|
|
35
|
-
* · `text_delta` → one `text` { delta }
|
|
36
|
-
* · `thinking_delta` → one `thinking` { delta }
|
|
37
|
-
* · `error` → one `fault` { model fault }
|
|
38
|
-
* · everything else → `[]`
|
|
39
|
-
*
|
|
40
|
-
* Faults: a streaming `error` sub-event becomes a typed `model` fault. The
|
|
41
|
-
* conductor layers its own `aborted` / `tool` / `persistence` / `overflow`
|
|
42
|
-
* faults elsewhere; the translator only mints the one fault the framework
|
|
43
|
-
* stream actually carries.
|
|
44
|
-
*/
|
|
45
|
-
import type { AgentEvent, AgentEventType, ExtractAgentEvent } from "indusagi/agent";
|
|
46
|
-
import { type SessionSignal } from "../contract";
|
|
47
|
-
/** A rule mapping one narrowed framework event member to product signals. */
|
|
48
|
-
type TranslatorRule<TType extends AgentEventType> = (event: ExtractAgentEvent<TType>) => SessionSignal[];
|
|
49
|
-
/**
|
|
50
|
-
* The dispatch table: exactly one rule per framework {@link AgentEventType}.
|
|
51
|
-
*
|
|
52
|
-
* Declaring it as a full mapped type means the compiler rejects the module until
|
|
53
|
-
* every framework event variant has a rule — the exhaustiveness guarantee.
|
|
54
|
-
*/
|
|
55
|
-
type TranslatorTable = {
|
|
56
|
-
[K in AgentEventType]: TranslatorRule<K>;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* The frozen mapping from each framework event variant to product signals.
|
|
60
|
-
*
|
|
61
|
-
* Exported for testing/inspection; production code calls
|
|
62
|
-
* {@link translateAgentEvent}, which is the table applied.
|
|
63
|
-
*/
|
|
64
|
-
export declare const TRANSLATOR_TABLE: TranslatorTable;
|
|
65
|
-
/**
|
|
66
|
-
* Translate a single framework {@link AgentEvent} into the product-level
|
|
67
|
-
* {@link SessionSignal}s it produces (zero, one, or — for future fan-out — many).
|
|
68
|
-
*
|
|
69
|
-
* Pure and total: every framework event variant has a rule (enforced by
|
|
70
|
-
* {@link TranslatorTable}), so this never throws on a known event and returns
|
|
71
|
-
* `[]` for events that carry no product meaning.
|
|
72
|
-
*
|
|
73
|
-
* @param event a framework agent loop event
|
|
74
|
-
* @returns the ordered product signals derived from it
|
|
75
|
-
*/
|
|
76
|
-
export declare function translateAgentEvent(event: AgentEvent): SessionSignal[];
|
|
77
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skill-parse subsystem — public barrel.
|
|
3
|
-
*
|
|
4
|
-
* Re-exports the re-derived skill-invocation block parser: the attribute-scanning
|
|
5
|
-
* {@link parseSkillInvocation} hand parser and its structured {@link SkillInvocation}
|
|
6
|
-
* result. Consumers (the conductor's submit path) import from
|
|
7
|
-
* `src/conductor/skill-parse` rather than reaching into `parse`.
|
|
8
|
-
*/
|
|
9
|
-
export { parseSkillInvocation } from "./parse";
|
|
10
|
-
export type { SkillInvocation } from "./parse";
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skill-invocation block parser — an attribute-scanning hand parser.
|
|
3
|
-
*
|
|
4
|
-
* The coding agent lets a turn carry a *skill invocation*: an XML-ish opener tag
|
|
5
|
-
* that names a capability card to run, optionally locates its on-disk file, and
|
|
6
|
-
* wraps a trailing user message (the body) the skill should act on. The shape is
|
|
7
|
-
* the framework Agent-Skills convention:
|
|
8
|
-
*
|
|
9
|
-
* ```
|
|
10
|
-
* <skill name="commit-helper" location="/abs/path/SKILL.md">
|
|
11
|
-
* please tidy the staged diff and write a message
|
|
12
|
-
* </skill>
|
|
13
|
-
* ```
|
|
14
|
-
*
|
|
15
|
-
* This module re-derives that parse from the *format spec*, deliberately NOT as
|
|
16
|
-
* one monolithic capture regex. It is a small hand-written scanner: it walks the
|
|
17
|
-
* input, finds the opener, scans `key=value` attributes one at a time (handling
|
|
18
|
-
* single- or double-quoted and bare values, with `&`/`<`/`>`/`"`/
|
|
19
|
-
* `'` entity decoding), then captures the body up to the matching close tag.
|
|
20
|
-
* Reading attributes incrementally — rather than matching the whole block in a
|
|
21
|
-
* single pattern — is what makes this an independent implementation and lets the
|
|
22
|
-
* parser keep *every* attribute the author wrote, not just a fixed `name`/
|
|
23
|
-
* `location` pair.
|
|
24
|
-
*
|
|
25
|
-
* Block grammar (informal):
|
|
26
|
-
* block := WS? '<' TAG WS attrs? WS? '>' body '</' TAG WS? '>'
|
|
27
|
-
* TAG := 'skill' (case-insensitive)
|
|
28
|
-
* attrs := (attr WS?)*
|
|
29
|
-
* attr := key ('=' value)?
|
|
30
|
-
* key := [A-Za-z_][A-Za-z0-9_:.-]*
|
|
31
|
-
* value := '"' ... '"' | '\'' ... '\'' | bare (bare stops at WS / '>')
|
|
32
|
-
* body := any text, captured verbatim up to the close tag
|
|
33
|
-
*
|
|
34
|
-
* A valid block must (a) be the leading content of the text (only leading
|
|
35
|
-
* whitespace may precede the opener), (b) name the `skill` tag, (c) carry a
|
|
36
|
-
* non-empty `name` attribute, and (d) be closed by `</skill>`. Anything else
|
|
37
|
-
* yields `null`, signalling "this turn is ordinary text, not a skill call".
|
|
38
|
-
*/
|
|
39
|
-
/**
|
|
40
|
-
* The structured result of a successful parse.
|
|
41
|
-
*
|
|
42
|
-
* - `name` — the value of the required `name` attribute (the skill to run).
|
|
43
|
-
* - `args` — every attribute the opener carried, keyed by (lower-cased) name,
|
|
44
|
-
* including `name` itself and any `location`/custom keys. A bare attribute
|
|
45
|
-
* with no `=value` maps to the empty string.
|
|
46
|
-
* - `body` — the verbatim text between the opener and the `</skill>` close,
|
|
47
|
-
* with a single leading and trailing newline trimmed (the common case where
|
|
48
|
-
* the opener/closer sit on their own lines) but inner whitespace preserved.
|
|
49
|
-
*/
|
|
50
|
-
export interface SkillInvocation {
|
|
51
|
-
readonly name: string;
|
|
52
|
-
readonly args: Record<string, string>;
|
|
53
|
-
readonly body: string;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Parse a skill-invocation block out of `text`.
|
|
57
|
-
*
|
|
58
|
-
* Walks the string by hand: skips leading whitespace, confirms a `<skill …>`
|
|
59
|
-
* opener, scans each attribute into an `args` record, captures the body up to the
|
|
60
|
-
* matching `</skill>`, and decodes entities. Returns the structured invocation,
|
|
61
|
-
* or `null` when the text is not a well-formed leading skill block (ordinary
|
|
62
|
-
* turns simply parse to `null`).
|
|
63
|
-
*
|
|
64
|
-
* @param text the raw turn text that may begin with a skill block
|
|
65
|
-
* @returns the parsed `{ name, args, body }`, or `null` if not a skill block
|
|
66
|
-
*/
|
|
67
|
-
export declare function parseSkillInvocation(text: string): SkillInvocation | null;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Phase 2 conductor — submit()/resume() BEHAVIORAL tests.
|
|
3
|
-
*
|
|
4
|
-
* These exercise the live turn loop of {@link createSessionConductor} end-to-end,
|
|
5
|
-
* but with zero network and zero disk. Everything heavy is injected:
|
|
6
|
-
*
|
|
7
|
-
* - a scripted fake {@link AgentLike} whose `prompt()` drives a pre-recorded
|
|
8
|
-
* sequence of framework {@link AgentEvent}s through the conductor's stored
|
|
9
|
-
* subscriber and mutates its own `state.messages` (so `#persistTail` has a
|
|
10
|
-
* tail to commit);
|
|
11
|
-
* - an in-memory {@link TranscriptStore} (default {@link memoryBackend}, no disk);
|
|
12
|
-
* - a fresh {@link SignalHub};
|
|
13
|
-
* - a {@link ModelMatcher} over a {@link ModelCatalog} built from a stub
|
|
14
|
-
* {@link CatalogSource} so `options.modelId` resolves;
|
|
15
|
-
* - `deps.sleep` stubbed to a no-op so retry backoff never actually waits.
|
|
16
|
-
*
|
|
17
|
-
* The four behaviors covered (per the Phase 2 plan):
|
|
18
|
-
* 1. multi-turn tool loop — ordered text/tool_start/tool_end/turn_end signals,
|
|
19
|
-
* settled `idle` state with accumulated usage, persisted transcript nodes.
|
|
20
|
-
* 2. fault + retry — transient streaming error auto-retries then settles;
|
|
21
|
-
* a hard model fault lands `faulted` with a typed {@link ConductorFault} and a
|
|
22
|
-
* `{ kind: "fault" }` signal.
|
|
23
|
-
* 3. branch / resume — a second conductor over the same store resumes the
|
|
24
|
-
* session and reconstructs the persisted branch (head/leaf).
|
|
25
|
-
* 4. compaction — autoCompact + a tiny compactAt + a scripted condense
|
|
26
|
-
* fn fire a `{ kind: "compacted" }` signal and invoke condense.
|
|
27
|
-
*/
|
|
28
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* transcript-store — the conductor's persistent, branchable transcript.
|
|
3
|
-
*
|
|
4
|
-
* Two cooperating pieces:
|
|
5
|
-
* - {@link TranscriptStore} — the append-only node tree bound to one session:
|
|
6
|
-
* `append`, `branchAt`, `pathTo`, `load`, with a pluggable storage backend.
|
|
7
|
-
* - the serialization bridge (re-exported below) — encode/decode the
|
|
8
|
-
* `indus/transcript@1` NDJSON line shape and project a branch down to the
|
|
9
|
-
* framework `AgentMessage[]` / LLM `Message[]`.
|
|
10
|
-
*
|
|
11
|
-
* Consumers (the conductor's submit/resume path) import the store and the
|
|
12
|
-
* serialization helpers from `src/conductor/transcript-store` rather than reaching
|
|
13
|
-
* into the individual modules.
|
|
14
|
-
*/
|
|
15
|
-
export { TranscriptStore, memoryBackend, fsBackend, replay, type TranscriptBackend, type TranscriptState, type TranscriptClock, type TranscriptStoreOptions, } from "./store";
|
|
16
|
-
export { roleForMessage, encodeEntry, encodeHead, parseSessionText, branchToMessages, branchToLlmMessages, importLegacyFile, importLegacyText, resolveLegacyMessages, type ParsedSessionFile, } from "./serialize";
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Transcript serialization — the bridge between the conductor's on-disk
|
|
3
|
-
* {@link TranscriptEntry} vocabulary and the framework's {@link AgentMessage}
|
|
4
|
-
* shapes.
|
|
5
|
-
*
|
|
6
|
-
* Two distinct directions live here, and the split is deliberate:
|
|
7
|
-
*
|
|
8
|
-
* 1. **Conductor ⇄ conductor** — encoding a {@link TranscriptEntry} to/from a
|
|
9
|
-
* single NDJSON line in the `indus/transcript@1` format. This is the
|
|
10
|
-
* conductor's *own* envelope (`schema`/`id`/`prev`/`role`/`message`/`at`/
|
|
11
|
-
* `meta`). The store owns these field names; they are our own, not any
|
|
12
|
-
* framework-internal session schema.
|
|
13
|
-
*
|
|
14
|
-
* 2. **Conductor ⇄ framework** — projecting a transcript branch down to the
|
|
15
|
-
* `AgentMessage[]` the agent loop consumes, and (for migration) lifting a
|
|
16
|
-
* legacy framework session file *up* into transcript entries. Here we
|
|
17
|
-
* **delegate the actual message serialization to the framework**: the
|
|
18
|
-
* framework's published loader/context helpers know how to parse and resolve
|
|
19
|
-
* the legacy on-disk schema, and we keep those internal schema literals
|
|
20
|
-
* inside the framework package rather than re-declaring them in the app.
|
|
21
|
-
*
|
|
22
|
-
* The role discriminant on a {@link TranscriptEntry} is the conductor's own —
|
|
23
|
-
* `role` here labels the *node*, not the LLM message. We derive it from the
|
|
24
|
-
* carried {@link AgentMessage}'s `role` field so a round-trip is faithful, but
|
|
25
|
-
* the transcript can also hold conductor-only nodes (`condense`, `note`) that the
|
|
26
|
-
* framework message union has no direct counterpart for.
|
|
27
|
-
*/
|
|
28
|
-
import type { AgentMessage } from "indusagi/agent";
|
|
29
|
-
import type { Message } from "indusagi/ai";
|
|
30
|
-
import type { SessionHead, TranscriptEntry, TranscriptRole } from "../contract";
|
|
31
|
-
/**
|
|
32
|
-
* Derive the conductor's node {@link TranscriptRole} from a framework
|
|
33
|
-
* {@link AgentMessage}.
|
|
34
|
-
*
|
|
35
|
-
* The framework message union uses `role` values (`user`/`assistant`/`toolResult`
|
|
36
|
-
* plus the custom app messages). We fold those onto the transcript's own role
|
|
37
|
-
* vocabulary. Anything we don't recognize (custom/notification-style messages)
|
|
38
|
-
* is filed as a `note` node so it persists without claiming an LLM turn role.
|
|
39
|
-
*/
|
|
40
|
-
export declare function roleForMessage(message: AgentMessage): TranscriptRole;
|
|
41
|
-
/** Encode one {@link TranscriptEntry} to its NDJSON entry line (no newline). */
|
|
42
|
-
export declare function encodeEntry(entry: TranscriptEntry): string;
|
|
43
|
-
/** Encode the {@link SessionHead} to its NDJSON head line (no newline). */
|
|
44
|
-
export declare function encodeHead(head: SessionHead): string;
|
|
45
|
-
/** The result of parsing a whole session file: its head plus its entries. */
|
|
46
|
-
export interface ParsedSessionFile {
|
|
47
|
-
readonly head: SessionHead | null;
|
|
48
|
-
readonly entries: TranscriptEntry[];
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Parse the raw text of a conductor session file into a head + entries.
|
|
52
|
-
*
|
|
53
|
-
* Tolerant by design: blank lines are skipped, malformed lines are dropped, and
|
|
54
|
-
* lines whose `schema` does not match `indus/transcript@1` are ignored. The last
|
|
55
|
-
* head line wins (a file should carry exactly one, written first and rewritten on
|
|
56
|
-
* branch). Entries keep file order.
|
|
57
|
-
*/
|
|
58
|
-
export declare function parseSessionText(sessionId: string, text: string): ParsedSessionFile;
|
|
59
|
-
/**
|
|
60
|
-
* Project a resolved transcript branch down to the framework `AgentMessage[]`
|
|
61
|
-
* the agent loop consumes.
|
|
62
|
-
*
|
|
63
|
-
* The branch is the root→leaf node list (the store's reducer produces it). We
|
|
64
|
-
* pull the carried `content` payloads and hand them straight to the agent; they
|
|
65
|
-
* are already framework messages. Conductor-only nodes whose payload is not a
|
|
66
|
-
* real message would be filtered by the framework's own `convertToLlm` at call
|
|
67
|
-
* time, so we keep them here and let the loop's converter decide.
|
|
68
|
-
*/
|
|
69
|
-
export declare function branchToMessages(branch: readonly TranscriptEntry[]): AgentMessage[];
|
|
70
|
-
/**
|
|
71
|
-
* Convert a transcript branch to *LLM-ready* `Message[]`, delegating entirely to
|
|
72
|
-
* the framework's {@link convertToLlm}.
|
|
73
|
-
*
|
|
74
|
-
* This is the one place that must understand how each `AgentMessage` variant
|
|
75
|
-
* (including the framework's custom `bashExecution`/`branchSummary`/… messages)
|
|
76
|
-
* collapses into a plain LLM message — and that knowledge stays in the framework.
|
|
77
|
-
* The conductor never re-implements it.
|
|
78
|
-
*/
|
|
79
|
-
export declare function branchToLlmMessages(branch: readonly TranscriptEntry[]): Message[];
|
|
80
|
-
/**
|
|
81
|
-
* Lift a *legacy framework session file* into conductor {@link TranscriptEntry}
|
|
82
|
-
* nodes, for one-way migration/import.
|
|
83
|
-
*
|
|
84
|
-
* The legacy file is the framework's own internal JSONL format. We do **not**
|
|
85
|
-
* parse its schema ourselves — we call the framework's published loader (or its
|
|
86
|
-
* in-memory text parser), then map only the message-bearing entries onto our
|
|
87
|
-
* envelope. Every framework-internal schema literal stays behind that call.
|
|
88
|
-
*
|
|
89
|
-
* Non-message bookkeeping entries (model/thinking changes, labels, raw
|
|
90
|
-
* compaction markers) are dropped from the imported transcript: their effect is
|
|
91
|
-
* already folded into the resolved messages we keep, and the conductor tracks
|
|
92
|
-
* model/thinking in its own state rather than as transcript nodes.
|
|
93
|
-
*/
|
|
94
|
-
export declare function importLegacyFile(filePath: string): TranscriptEntry[];
|
|
95
|
-
/** As {@link importLegacyFile}, but from already-loaded text (testing/import). */
|
|
96
|
-
export declare function importLegacyText(text: string): TranscriptEntry[];
|
|
97
|
-
/**
|
|
98
|
-
* Resolve a legacy framework file straight to the `AgentMessage[]` of its active
|
|
99
|
-
* branch, delegating to the framework's {@link buildSessionContext}.
|
|
100
|
-
*
|
|
101
|
-
* Useful when the goal is to *seed* a fresh conductor session from a legacy one
|
|
102
|
-
* without reproducing its tree: the framework walks its own parent links and
|
|
103
|
-
* applies its own compaction/branch-summary resolution, and we receive a flat
|
|
104
|
-
* message list to re-append as new transcript nodes.
|
|
105
|
-
*/
|
|
106
|
-
export declare function resolveLegacyMessages(filePath: string): AgentMessage[];
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Transcript serialization — head usage round-trip.
|
|
3
|
-
*
|
|
4
|
-
* Focused coverage for the cost-cmd durability seam: the head line now carries
|
|
5
|
-
* the session's cumulative {@link Usage}, and {@link encodeHead} →
|
|
6
|
-
* {@link parseSessionText} must round-trip it faithfully so resume can restore the
|
|
7
|
-
* running token/cost total instead of seeding zero. Heads without usage (legacy
|
|
8
|
-
* files, fresh sessions) must still parse cleanly with `usage` absent.
|
|
9
|
-
*/
|
|
10
|
-
export {};
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TranscriptStore — the conductor's persistent, branchable transcript.
|
|
3
|
-
*
|
|
4
|
-
* Replaces pi's `SessionManager`, but with the conductor's own vocabulary and a
|
|
5
|
-
* deliberately different internal model. The transcript is an append-only **tree**
|
|
6
|
-
* of {@link TranscriptEntry} nodes: every node names its `parent`, a single
|
|
7
|
-
* {@link SessionHead} tracks the active `leaf`, and the active conversation is the
|
|
8
|
-
* `parent`-chain walked from that leaf back to a root.
|
|
9
|
-
*
|
|
10
|
-
* Design stance (an independent persistence model):
|
|
11
|
-
* - **Reducer-friendly.** The on-disk form is a flat NDJSON log; the in-memory
|
|
12
|
-
* view is rebuilt by a pure {@link replay} reducer over that log. State is a
|
|
13
|
-
* value derived from the log, never mutated in place behind the scenes.
|
|
14
|
-
* - **Fresh envelope.** Lines carry the `indus/transcript@1` schema with our own
|
|
15
|
-
* field names (`prev`, `at`, `kind`), delegated to {@link module:serialize} —
|
|
16
|
-
* not any framework-internal session-manager schema.
|
|
17
|
-
* - **Branch = move the head.** {@link branchAt} repoints the leaf at an earlier
|
|
18
|
-
* node; the next {@link append} becomes that node's child, forking a new path
|
|
19
|
-
* without rewriting history.
|
|
20
|
-
* - **`pathTo` is the read primitive.** {@link pathTo} resolves the root→leaf
|
|
21
|
-
* branch (the message list the agent replays); the conductor's `resume` calls
|
|
22
|
-
* it to rehydrate.
|
|
23
|
-
*
|
|
24
|
-
* The store is storage-pluggable: a {@link TranscriptBackend} abstracts where bytes
|
|
25
|
-
* live, so tests inject an in-memory backend and the conductor binds a filesystem
|
|
26
|
-
* one. Construction is synchronous and empty; {@link load} hydrates from a backend.
|
|
27
|
-
*/
|
|
28
|
-
import type { AgentMessage, SessionHead, TranscriptEntry, TranscriptRole } from "../contract";
|
|
29
|
-
import { TRANSCRIPT_SCHEMA } from "../contract";
|
|
30
|
-
import type { Usage } from "indusagi/ai";
|
|
31
|
-
/**
|
|
32
|
-
* Where a transcript's NDJSON log lives. The store appends lines and, on branch,
|
|
33
|
-
* rewrites the whole file; a backend supplies those three primitives plus a way
|
|
34
|
-
* to resolve a session id to its location. All methods may be async.
|
|
35
|
-
*
|
|
36
|
-
* The default {@link fsBackend} maps a session id to `<dir>/<sessionId>.ndjson`;
|
|
37
|
-
* tests pass an in-memory backend so no disk is touched.
|
|
38
|
-
*/
|
|
39
|
-
export interface TranscriptBackend {
|
|
40
|
-
/** Absolute location (path/key) a session id persists to. */
|
|
41
|
-
locate(sessionId: string): string;
|
|
42
|
-
/** Read the full NDJSON text for a session, or `null` if absent. */
|
|
43
|
-
read(sessionId: string): Promise<string | null>;
|
|
44
|
-
/** Append one already-encoded NDJSON line (no trailing newline) to a session. */
|
|
45
|
-
append(sessionId: string, line: string): Promise<void>;
|
|
46
|
-
/** Replace the whole NDJSON text for a session (used after a branch). */
|
|
47
|
-
rewrite(sessionId: string, text: string): Promise<void>;
|
|
48
|
-
}
|
|
49
|
-
/** An in-memory backend — the default when no persistence is wired. */
|
|
50
|
-
export declare function memoryBackend(): TranscriptBackend;
|
|
51
|
-
/**
|
|
52
|
-
* A filesystem backend rooted at `dir`. Lazily imports `node:fs`/`node:path` so
|
|
53
|
-
* the module stays usable in non-Node test contexts that pass {@link memoryBackend}.
|
|
54
|
-
*/
|
|
55
|
-
export declare function fsBackend(dir: string): TranscriptBackend;
|
|
56
|
-
/**
|
|
57
|
-
* The immutable derived state of a transcript: the node table keyed by id, plus
|
|
58
|
-
* the current head. A pure value produced by {@link replay}; the store holds one
|
|
59
|
-
* and swaps it wholesale on each mutation rather than mutating fields.
|
|
60
|
-
*/
|
|
61
|
-
export interface TranscriptState {
|
|
62
|
-
/** Every node, keyed by id, in insertion order. */
|
|
63
|
-
readonly nodes: ReadonlyMap<string, TranscriptEntry>;
|
|
64
|
-
/** The active head (session id + current leaf). */
|
|
65
|
-
readonly head: SessionHead;
|
|
66
|
-
}
|
|
67
|
-
/** A clock + id seam so tests get deterministic ids/timestamps. */
|
|
68
|
-
export interface TranscriptClock {
|
|
69
|
-
/** Mint a fresh, sortable node id. */
|
|
70
|
-
readonly id: () => string;
|
|
71
|
-
/** The current instant as an ISO-8601 string. */
|
|
72
|
-
readonly now: () => string;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Rebuild a {@link TranscriptState} from an ordered entry list and a leaf.
|
|
76
|
-
*
|
|
77
|
-
* Pure and total: the same inputs always yield the same state. The reducer just
|
|
78
|
-
* indexes the entries by id (later ids overwrite earlier — append-only logs never
|
|
79
|
-
* collide, but a rewrite stays idempotent) and pins the head. Replacing pi's
|
|
80
|
-
* mutate-in-place index with an explicit reducer is the divergence.
|
|
81
|
-
*/
|
|
82
|
-
export declare function replay(sessionId: string, entries: readonly TranscriptEntry[], leaf: string | null): TranscriptState;
|
|
83
|
-
/** Tuning seams for a {@link TranscriptStore}. All optional. */
|
|
84
|
-
export interface TranscriptStoreOptions {
|
|
85
|
-
/** Where bytes live; defaults to {@link memoryBackend}. */
|
|
86
|
-
readonly backend?: TranscriptBackend;
|
|
87
|
-
/** Id/timestamp source; defaults to ULID + wall clock. */
|
|
88
|
-
readonly clock?: TranscriptClock;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* An append-only, branchable transcript bound to one session id.
|
|
92
|
-
*
|
|
93
|
-
* Construct (empty), then either {@link append} fresh nodes or {@link load} a
|
|
94
|
-
* persisted session. Every mutation appends to the backend and swaps the derived
|
|
95
|
-
* {@link TranscriptState}. Reads (`pathTo`, `messages`, `head`) are O(branch
|
|
96
|
-
* depth) walks over the in-memory node table.
|
|
97
|
-
*/
|
|
98
|
-
export declare class TranscriptStore {
|
|
99
|
-
#private;
|
|
100
|
-
constructor(sessionId: string, options?: TranscriptStoreOptions);
|
|
101
|
-
/** The session id this store is bound to. */
|
|
102
|
-
get sessionId(): string;
|
|
103
|
-
/** The current head (session id + active leaf). */
|
|
104
|
-
get head(): SessionHead;
|
|
105
|
-
/**
|
|
106
|
-
* The cumulative session usage last persisted onto the head, or `undefined`
|
|
107
|
-
* when none has been written (a fresh session, or a legacy file without a
|
|
108
|
-
* usage-bearing head). `resume` reads this to restore the running token/cost
|
|
109
|
-
* total instead of seeding zero.
|
|
110
|
-
*/
|
|
111
|
-
get usage(): Usage | undefined;
|
|
112
|
-
/** Number of nodes currently in the transcript. */
|
|
113
|
-
get size(): number;
|
|
114
|
-
/** Backend location this session persists to (for diagnostics/UI). */
|
|
115
|
-
locate(sessionId?: string): string;
|
|
116
|
-
/** Look up a single node by id. */
|
|
117
|
-
get(id: string): TranscriptEntry | undefined;
|
|
118
|
-
/**
|
|
119
|
-
* Append a framework {@link AgentMessage} as a child of the current leaf and
|
|
120
|
-
* advance the head onto it. The node role is derived from the message (or
|
|
121
|
-
* overridden via `role`). Persists the new line, then returns the new node.
|
|
122
|
-
*
|
|
123
|
-
* This is the conductor's per-message write: one call per produced message in
|
|
124
|
-
* a settled turn.
|
|
125
|
-
*/
|
|
126
|
-
append(content: AgentMessage, role?: TranscriptRole, meta?: Readonly<Record<string, unknown>>): Promise<TranscriptEntry>;
|
|
127
|
-
/**
|
|
128
|
-
* Persist the session's cumulative usage onto the head and rewrite the backing
|
|
129
|
-
* file so the running token/cost total survives a reload. Distinct from
|
|
130
|
-
* {@link append}, which only appends an entry line and never rewrites the head:
|
|
131
|
-
* usage durability MUST flow through here so the re-emitted head line carries
|
|
132
|
-
* the latest tally. Leaves the node tree and active leaf untouched.
|
|
133
|
-
*
|
|
134
|
-
* @param usage the cumulative usage to pin on the head
|
|
135
|
-
*/
|
|
136
|
-
persistUsage(usage: Usage): Promise<void>;
|
|
137
|
-
/**
|
|
138
|
-
* Repoint the head at an earlier node, forking a branch. The next {@link append}
|
|
139
|
-
* becomes a child of `id`; existing nodes are untouched. Rewrites the head line.
|
|
140
|
-
*
|
|
141
|
-
* @throws if `id` is not a known node.
|
|
142
|
-
*/
|
|
143
|
-
branchAt(id: string): Promise<void>;
|
|
144
|
-
/**
|
|
145
|
-
* Reset the head to before any node; the next {@link append} starts a new root.
|
|
146
|
-
* Used when re-editing the very first turn.
|
|
147
|
-
*/
|
|
148
|
-
reset(): Promise<void>;
|
|
149
|
-
/**
|
|
150
|
-
* Abandon the current conversation and begin a fresh, empty session under a new
|
|
151
|
-
* id. All nodes are dropped and the leaf is reset to null, so {@link messages}
|
|
152
|
-
* is empty and the next {@link append} starts a new root; subsequent writes
|
|
153
|
-
* persist to the new session's backing file (the old one is left intact on
|
|
154
|
-
* disk). This is the `/clear` (new-session) primitive — distinct from
|
|
155
|
-
* {@link reset}, which keeps the nodes and id and only rewinds the head.
|
|
156
|
-
*/
|
|
157
|
-
startNewSession(sessionId: string): void;
|
|
158
|
-
/**
|
|
159
|
-
* Resolve the active branch: the root→leaf node list reached by walking
|
|
160
|
-
* `parent` links up from `leaf` (or from `from` when given), reversed to
|
|
161
|
-
* chronological order.
|
|
162
|
-
*
|
|
163
|
-
* This is the conductor's read primitive — `resume` rehydrates the agent from
|
|
164
|
-
* `pathTo()`, and the turn loop projects it to messages via {@link messages}.
|
|
165
|
-
* Returns `[]` for an empty transcript or a dangling leaf.
|
|
166
|
-
*/
|
|
167
|
-
pathTo(from?: string): TranscriptEntry[];
|
|
168
|
-
/** The active branch projected to the framework {@link AgentMessage} list. */
|
|
169
|
-
messages(from?: string): AgentMessage[];
|
|
170
|
-
/**
|
|
171
|
-
* Hydrate this store from a persisted session, replacing its current state.
|
|
172
|
-
*
|
|
173
|
-
* Reads the backend, parses it with {@link parseSessionText}, and rebuilds state
|
|
174
|
-
* via the {@link replay} reducer. If the file carried no head line, the head is
|
|
175
|
-
* pinned to the deepest leaf reachable from the entries. Returns `true` when a
|
|
176
|
-
* session was found and loaded, `false` when the backend had nothing.
|
|
177
|
-
*/
|
|
178
|
-
load(sessionId?: string): Promise<boolean>;
|
|
179
|
-
/**
|
|
180
|
-
* Open a persisted session by id, returning a hydrated store (or `null` if the
|
|
181
|
-
* backend has no such session). The static counterpart to {@link load}.
|
|
182
|
-
*/
|
|
183
|
-
static open(sessionId: string, options?: TranscriptStoreOptions): Promise<TranscriptStore | null>;
|
|
184
|
-
/** A point-in-time copy of the derived state (for inspection/testing). */
|
|
185
|
-
state(): TranscriptState;
|
|
186
|
-
}
|
|
187
|
-
/** Re-export the schema literal for callers building stores directly. */
|
|
188
|
-
export { TRANSCRIPT_SCHEMA };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared "does the user have a usable credential for this provider" probe.
|
|
3
|
-
*
|
|
4
|
-
* Used anywhere the console needs to know which providers are actually
|
|
5
|
-
* callable — the `/model` picker (only list authenticated providers) and the
|
|
6
|
-
* banner's Session panel (don't display an unauthenticated model as if it were
|
|
7
|
-
* ready to use) both need the exact same answer, so it lives here once.
|
|
8
|
-
*/
|
|
9
|
-
import type { OverlayServices } from "./contract";
|
|
10
|
-
/**
|
|
11
|
-
* Load the set of provider ids the user has USABLE credentials for, live, so a
|
|
12
|
-
* mid-session `/login` (either a local vault sign-in or the "Indus Server"
|
|
13
|
-
* server-tier device flow) is reflected without a restart.
|
|
14
|
-
*
|
|
15
|
-
* Two independent sources count: (1) any saved account in the local vault for a
|
|
16
|
-
* provider `listLoginProviders()` names, and (2) a valid server session token,
|
|
17
|
-
* which makes every gateway-eligible provider (`serverTierProviders()` —
|
|
18
|
-
* minimax, sarvam) usable even though the server tier never writes into the
|
|
19
|
-
* vault. Returns `null` until the asynchronous probe settles.
|
|
20
|
-
*
|
|
21
|
-
* `refreshKey` re-runs the probe whenever it changes by reference/value — a
|
|
22
|
-
* short-lived overlay (the `/model` picker) can leave it at its default since
|
|
23
|
-
* it remounts fresh on every open anyway, but a component mounted once for the
|
|
24
|
-
* whole session (the banner, the status bar) MUST pass something that changes
|
|
25
|
-
* right when a sign-in completes (e.g. the console's current status toast),
|
|
26
|
-
* otherwise this only ever reflects whatever was true at session start.
|
|
27
|
-
*/
|
|
28
|
-
export declare function useAuthenticatedProviders(services: OverlayServices | undefined, refreshKey?: unknown): Set<string> | null;
|