indusagi-coding-agent 0.2.4 → 0.2.5
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/LICENSE +661 -0
- package/README.md +95 -1
- package/dist/entry.js +1559 -1100
- package/dist/guardrails.js +26 -509
- package/dist/index.js +1581 -1155
- 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,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Capability catalog — the deck's single source of truth.
|
|
3
|
-
*
|
|
4
|
-
* This module owns {@link CAPABILITY_CARDS}: the one hand-maintained-in-one-place
|
|
5
|
-
* list of {@link CapabilityCard} rows the rest of the deck reads from. Every
|
|
6
|
-
* index, lookup, and profile-membership query is *derived* from this array, so
|
|
7
|
-
* there is never a second parallel map to keep in sync.
|
|
8
|
-
*
|
|
9
|
-
* Right now the catalog is exactly the framework built-ins — read/write/edit/
|
|
10
|
-
* ls/grep/find/bash/process/the checklist pair/web search & fetch — projected
|
|
11
|
-
* out of the single {@link BUILTIN_BRIDGE} table in `builtin-bridge.ts`. As the
|
|
12
|
-
* novel provisioners land (delegate, checklist ledger, daemon proxy, recall,
|
|
13
|
-
* SaaS actions, and the MCP bridge network) their cards are appended here too,
|
|
14
|
-
* so the catalog stays the one place the deck enumerates what tools exist.
|
|
15
|
-
*
|
|
16
|
-
* A {@link CapabilityCard} is metadata plus a builder: the wire-facing id, the
|
|
17
|
-
* deck-side title/summary prose, and a `build(ctx)` that mints the live
|
|
18
|
-
* {@link Capability}. The card does not carry profile membership — that lives in
|
|
19
|
-
* the profile table the provisioner consults — so the card shape stays the small
|
|
20
|
-
* catalog row the contract froze.
|
|
21
|
-
*/
|
|
22
|
-
import type { CapabilityCard, CapabilityId, CardProfiles } from "./contract";
|
|
23
|
-
/**
|
|
24
|
-
* The static capability catalog — the deck's single source of truth.
|
|
25
|
-
*
|
|
26
|
-
* One ordered array of catalog rows. Today every row is a framework built-in,
|
|
27
|
-
* projected from the bridge table; novel-provisioner cards are appended here as
|
|
28
|
-
* they land. Consumers never hand-build a parallel list — they read this array
|
|
29
|
-
* (or the derived {@link CAPABILITY_INDEX} / {@link CARD_PROFILES} below).
|
|
30
|
-
*/
|
|
31
|
-
export declare const CAPABILITY_CARDS: readonly CapabilityCard[];
|
|
32
|
-
/**
|
|
33
|
-
* The catalog keyed by wire-facing {@link CapabilityId}, derived from
|
|
34
|
-
* {@link CAPABILITY_CARDS}. Resolves a `--tools name1,name2` selection or a
|
|
35
|
-
* model-named tool to its card in O(1) without a second hand-maintained map.
|
|
36
|
-
*/
|
|
37
|
-
export declare const CAPABILITY_INDEX: ReadonlyMap<CapabilityId, CapabilityCard>;
|
|
38
|
-
/**
|
|
39
|
-
* Profile membership for every catalog row, keyed by id and derived from the
|
|
40
|
-
* bridge table. The data-driven provisioner intersects this with a requested
|
|
41
|
-
* profile to assemble a session's capability set — no per-profile build
|
|
42
|
-
* functions, just a table walk.
|
|
43
|
-
*/
|
|
44
|
-
export declare const CARD_PROFILES: ReadonlyMap<CapabilityId, CardProfiles>;
|
|
45
|
-
/** The wire-facing ids of every catalog row, in catalog order. */
|
|
46
|
-
export declare function capabilityIds(): CapabilityId[];
|
|
47
|
-
/** True when a catalog row exists under this id. */
|
|
48
|
-
export declare function hasCapability(id: CapabilityId): boolean;
|
|
49
|
-
/** Fetch a catalog row by id, or `undefined` when the id is unknown. */
|
|
50
|
-
export declare function findCard(id: CapabilityId): CapabilityCard | undefined;
|
|
51
|
-
/**
|
|
52
|
-
* The catalog rows that participate in a profile, in catalog order.
|
|
53
|
-
*
|
|
54
|
-
* `all` returns every row; a named profile keeps only the rows whose membership
|
|
55
|
-
* (read from {@link CARD_PROFILES}) admits it. The single place profile
|
|
56
|
-
* filtering happens, so the provisioner stays a thin walk over this result.
|
|
57
|
-
*
|
|
58
|
-
* @param profile the requested deck profile
|
|
59
|
-
*/
|
|
60
|
-
export declare function cardsForProfile(profile: "authoring" | "survey" | "all"): CapabilityCard[];
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deck provisioning — the single data-driven assembler.
|
|
3
|
-
*
|
|
4
|
-
* One function, {@link provisionDeck}, turns a {@link DeckProfile} plus a
|
|
5
|
-
* {@link DeckContext} into an assembled {@link ToolDeck}. It replaces what would
|
|
6
|
-
* otherwise be a trio of near-identical `buildAuthoringTools` / `buildSurveyTools`
|
|
7
|
-
* / `buildAllTools` functions with a single walk over a {@link PROFILE_TABLE}: the
|
|
8
|
-
* table says which catalog rows each profile draws from, the assembler builds
|
|
9
|
-
* exactly those rows against the context, and the result exposes the two reads the
|
|
10
|
-
* conductor needs — {@link ToolDeck.tools} (the flat capability list) and
|
|
11
|
-
* {@link ToolDeck.box} (the consumable `AgentTool[]` it wires in as
|
|
12
|
-
* `options.tools`).
|
|
13
|
-
*
|
|
14
|
-
* Why a table rather than three functions:
|
|
15
|
-
* - The catalog is already the single source of truth (`CAPABILITY_CARDS` plus
|
|
16
|
-
* the app-novel cards). A profile is just a *selection policy* over that
|
|
17
|
-
* catalog, so it is data — a small row per profile — not control flow.
|
|
18
|
-
* - Adding a profile, or moving a card between profiles, is a one-line table
|
|
19
|
-
* edit with no new branch to keep in sync.
|
|
20
|
-
*
|
|
21
|
-
* Breadth runs `authoring` (narrowest, read-only) -> `survey` (all built-ins) ->
|
|
22
|
-
* `all` (built-ins + app cards), spelled out per profile below.
|
|
23
|
-
*
|
|
24
|
-
* The three profiles, in increasing breadth:
|
|
25
|
-
* - `authoring` — the read-only built-in subset: the observe-only tools the
|
|
26
|
-
* framework exposes (read/ls/grep/find/web search & fetch/checklist-read). No
|
|
27
|
-
* filesystem mutation, no shell, no app-novel cards. The safe selection for a
|
|
28
|
-
* session that must inspect a workspace without changing it.
|
|
29
|
-
* - `survey` — the wider built-in subset: every framework built-in,
|
|
30
|
-
* including the mutating ones (write/edit/bash/process/checklist-write). Still
|
|
31
|
-
* no app-novel cards — just the full native tool set.
|
|
32
|
-
* - `all` — everything: every framework built-in plus every app-novel
|
|
33
|
-
* card (the checklist, the background-process proxy, the delegate/sub-agent
|
|
34
|
-
* action, the SaaS connector, working memory).
|
|
35
|
-
*
|
|
36
|
-
* The built-in catalog tags each native tool with the profiles it belongs to
|
|
37
|
-
* (`read` etc. are observe-only; `bash`/`write` are mutating); this table maps the
|
|
38
|
-
* deck profiles onto those membership selections, so the read-only/wider split is
|
|
39
|
-
* a table lookup rather than a hand-maintained second tool list.
|
|
40
|
-
*
|
|
41
|
-
* Bridge (MCP) capabilities are *not* selected here — they are grafted at runtime
|
|
42
|
-
* through the bridge ledger and concatenated by the host onto a deck's
|
|
43
|
-
* {@link ToolDeck.tools}; provisioning only assembles the static catalog.
|
|
44
|
-
*/
|
|
45
|
-
import type { CapabilityCard, DeckContext, DeckProfile, ToolDeck } from "./contract";
|
|
46
|
-
/**
|
|
47
|
-
* The catalog rows a profile selects, in catalog order: the built-in subset the
|
|
48
|
-
* policy names, followed by the app-novel cards when the policy grants them.
|
|
49
|
-
*
|
|
50
|
-
* Derived purely from {@link PROFILE_TABLE} + the catalog — no per-profile
|
|
51
|
-
* branching beyond the table lookup.
|
|
52
|
-
*
|
|
53
|
-
* @param profile the requested deck profile
|
|
54
|
-
*/
|
|
55
|
-
export declare function cardsForDeckProfile(profile: DeckProfile): CapabilityCard[];
|
|
56
|
-
/**
|
|
57
|
-
* Provision a {@link ToolDeck} for a profile and working context.
|
|
58
|
-
*
|
|
59
|
-
* Looks the profile up in {@link PROFILE_TABLE}, selects its catalog rows,
|
|
60
|
-
* builds each against `ctx`, and returns a deck that hands the resulting
|
|
61
|
-
* capabilities out two ways:
|
|
62
|
-
* - {@link ToolDeck.tools} — the flat `AnyCapability[]` for inspection,
|
|
63
|
-
* naming, and `--tools` style selection.
|
|
64
|
-
* - {@link ToolDeck.box} — the same `AnyCapability[]` (= the framework
|
|
65
|
-
* `AgentTool[]`) the conductor consumes verbatim as
|
|
66
|
-
* `SessionConductorOptions.tools`.
|
|
67
|
-
*
|
|
68
|
-
* The capabilities are built once, at provision time, and the same list backs
|
|
69
|
-
* both reads (returned as fresh copies so a caller cannot mutate the deck's
|
|
70
|
-
* backing array). Bridge/MCP tools are concatenated onto `tools()` by the host
|
|
71
|
-
* after provisioning; they are not part of the static selection.
|
|
72
|
-
*
|
|
73
|
-
* @param profile the requested capability set (`authoring` | `survey` | `all`)
|
|
74
|
-
* @param ctx the working context (cwd + injectable backends) to bind cards to
|
|
75
|
-
*/
|
|
76
|
-
export declare function provisionDeck(profile: DeckProfile, ctx: DeckContext): ToolDeck;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Read-before-edit gate — PRODUCT integration test (read-edit-gate, #11).
|
|
3
|
-
*
|
|
4
|
-
* This proves the gate fires through the ACTUAL wired path the product uses:
|
|
5
|
-
*
|
|
6
|
-
* 1. We provision a real deck via {@link provisionDeck} with a `framework` bag
|
|
7
|
-
* that carries a real per-session {@link ReadStateStore} under the same
|
|
8
|
-
* `readState` handle key `session.ts` injects (`READ_STATE_HANDLE_KEY`).
|
|
9
|
-
* 2. We pull the WIRED `read` and `edit` capabilities out of that deck — the
|
|
10
|
-
* same `AgentTool` objects the conductor would run — and exercise them.
|
|
11
|
-
*
|
|
12
|
-
* The framework's edit tool consults `ctx.framework['readState']` to enforce the
|
|
13
|
-
* gate. If the bridge failed to thread the store into `createEditTool`, the
|
|
14
|
-
* handle would be `undefined` and the gate would no-op — so an edit of an unread
|
|
15
|
-
* file would succeed instead of being refused. These assertions therefore only
|
|
16
|
-
* pass when the store reaches the tool through the real wiring.
|
|
17
|
-
*
|
|
18
|
-
* The refusal message is byte-stable (the framework's `READ_BEFORE_EDIT_MESSAGE`)
|
|
19
|
-
* and asserted verbatim, so a wording drift on either side is caught.
|
|
20
|
-
*/
|
|
21
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Phase 8 channels — behavioral tests.
|
|
3
|
-
*
|
|
4
|
-
* Three independent surfaces, all driven over in-memory pipes with a scripted
|
|
5
|
-
* conductor and zero real stdio:
|
|
6
|
-
*
|
|
7
|
-
* 1. the NDJSON framer round-trips a value carrying the two Unicode line
|
|
8
|
-
* separators (the regression), and `decodeLines` reassembles a payload split
|
|
9
|
-
* across arbitrary chunk boundaries;
|
|
10
|
-
* 2. the oneshot channel produces the expected text and NDJSON output from a
|
|
11
|
-
* scripted conductor (two strategy objects, one runner);
|
|
12
|
-
* 3. the link server and the generated driver round-trip a request over a pipe
|
|
13
|
-
* pair, and an unknown method yields a JSON-RPC error reply.
|
|
14
|
-
*/
|
|
15
|
-
export {};
|
|
@@ -1,489 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Channels contract — the FROZEN type surface of Phase 8 (non-interactive
|
|
3
|
-
* drivers).
|
|
4
|
-
*
|
|
5
|
-
* A *channel* is a way to talk to a {@link SessionConductor} from outside the
|
|
6
|
-
* interactive terminal. Two channels share this contract:
|
|
7
|
-
*
|
|
8
|
-
* - the **oneshot** channel runs a single request to settlement and writes the
|
|
9
|
-
* result to a stream (clean text, or a streamed NDJSON event log);
|
|
10
|
-
* - the **link** channel is a long-lived, bidirectional JSON-RPC 2.0 server
|
|
11
|
-
* plus a typed driver (client) that drives a child process over NDJSON.
|
|
12
|
-
*
|
|
13
|
-
* This module declares *only* shapes and a handful of inert, pure helpers — no
|
|
14
|
-
* I/O, no process plumbing, no dispatch. The server, the driver, the framer, and
|
|
15
|
-
* the oneshot runner are each written against the names declared here, so the
|
|
16
|
-
* file is intentionally small, append-mostly, and stable.
|
|
17
|
-
*
|
|
18
|
-
* Design stance:
|
|
19
|
-
* - The protocol is **one declarative operation registry**, not a
|
|
20
|
-
* hand-written dispatch ladder mirrored by hand-written client methods. An
|
|
21
|
-
* {@link Op} pairs a wire `method` name with a typed `handle`; an
|
|
22
|
-
* {@link OpRegistry} (the result of {@link defineOps}) is consumed by *both*
|
|
23
|
-
* the server (data-driven dispatch) and the {@link LinkDriver} (a generated
|
|
24
|
-
* client whose method set is derived from the same registry).
|
|
25
|
-
* - The wire envelope is **JSON-RPC 2.0**: a request carries `{ id?, method,
|
|
26
|
-
* params }`, a reply carries `{ id, result }` or `{ id, error }`. The
|
|
27
|
-
* {@link Reply} / {@link OpError} types pin that envelope.
|
|
28
|
-
* - Framing is **NDJSON**, one JSON value per line. The framer
|
|
29
|
-
* ({@link encodeLine} / {@link decodeLines}) is correct by construction: it
|
|
30
|
-
* escapes the two line separators (U+2028, U+2029) that are valid inside a
|
|
31
|
-
* JSON string but break a naive line splitter, and it pulls lines with an
|
|
32
|
-
* async generator rather than an event callback.
|
|
33
|
-
* - The transport is **injectable**. A {@link ChannelContext} carries the
|
|
34
|
-
* conductor plus the streams and the dialog primitives, so tests drive the
|
|
35
|
-
* channels over in-memory pipes with no real stdio.
|
|
36
|
-
*
|
|
37
|
-
* Conductor anchor: {@link SessionConductor} and its {@link ConductorState} come
|
|
38
|
-
* from the sibling Phase-2 conductor contract; the channels never re-declare
|
|
39
|
-
* them, they compose them.
|
|
40
|
-
*/
|
|
41
|
-
import type { ImageContent } from "indusagi/ai";
|
|
42
|
-
import type { ConductorState, SessionConductor, ThinkingLevel, Usage } from "../conductor/contract";
|
|
43
|
-
/** Re-exported anchors that channel consumers routinely need. */
|
|
44
|
-
export type { ImageContent, SessionConductor, ConductorState, ThinkingLevel, Usage };
|
|
45
|
-
/** The protocol version literal stamped on every framed envelope. */
|
|
46
|
-
export declare const PROTOCOL_VERSION: "2.0";
|
|
47
|
-
/** The literal type of {@link PROTOCOL_VERSION}. */
|
|
48
|
-
export type ProtocolVersion = typeof PROTOCOL_VERSION;
|
|
49
|
-
/**
|
|
50
|
-
* The id correlating a request to its reply.
|
|
51
|
-
*
|
|
52
|
-
* A request with an id expects exactly one reply bearing the same id; a request
|
|
53
|
-
* without an id is a notification and is never replied to. Numeric ids are
|
|
54
|
-
* accepted on the wire but the driver mints string ids.
|
|
55
|
-
*/
|
|
56
|
-
export type RequestId = string | number;
|
|
57
|
-
/**
|
|
58
|
-
* A request frame: a single operation invocation.
|
|
59
|
-
*
|
|
60
|
-
* `method` selects the {@link Op} by its wire name; `params` carries its typed
|
|
61
|
-
* payload (absent when the op takes none). When `id` is present the sender
|
|
62
|
-
* expects a correlated {@link Reply}; when it is absent the request is a
|
|
63
|
-
* fire-and-forget notification.
|
|
64
|
-
*/
|
|
65
|
-
export interface OpRequest<P = unknown> {
|
|
66
|
-
/** Envelope version; always {@link PROTOCOL_VERSION}. */
|
|
67
|
-
readonly jsonrpc: ProtocolVersion;
|
|
68
|
-
/** Correlation id, or absent for a notification. */
|
|
69
|
-
readonly id?: RequestId;
|
|
70
|
-
/** Wire name of the operation to invoke. */
|
|
71
|
-
readonly method: string;
|
|
72
|
-
/** Operation payload, when the operation takes one. */
|
|
73
|
-
readonly params?: P;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* A typed error returned by a failed operation.
|
|
77
|
-
*
|
|
78
|
-
* The `code` is a small integer category (negative values follow the JSON-RPC
|
|
79
|
-
* reserved ranges); `message` is a single-line human summary; the optional
|
|
80
|
-
* `data` carries structured detail for logging without parsing the message.
|
|
81
|
-
*/
|
|
82
|
-
export interface OpError {
|
|
83
|
-
/** Numeric error category. */
|
|
84
|
-
readonly code: number;
|
|
85
|
-
/** Human-readable, single-line summary. */
|
|
86
|
-
readonly message: string;
|
|
87
|
-
/** Optional structured detail. */
|
|
88
|
-
readonly data?: unknown;
|
|
89
|
-
}
|
|
90
|
-
/** A successful reply: the correlated result for one request. */
|
|
91
|
-
export interface ReplyOk<R = unknown> {
|
|
92
|
-
/** Envelope version; always {@link PROTOCOL_VERSION}. */
|
|
93
|
-
readonly jsonrpc: ProtocolVersion;
|
|
94
|
-
/** The id of the request this reply settles. */
|
|
95
|
-
readonly id: RequestId;
|
|
96
|
-
/** The operation result payload. */
|
|
97
|
-
readonly result: R;
|
|
98
|
-
}
|
|
99
|
-
/** A failed reply: the correlated error for one request. */
|
|
100
|
-
export interface ReplyErr {
|
|
101
|
-
/** Envelope version; always {@link PROTOCOL_VERSION}. */
|
|
102
|
-
readonly jsonrpc: ProtocolVersion;
|
|
103
|
-
/** The id of the request this reply settles. */
|
|
104
|
-
readonly id: RequestId;
|
|
105
|
-
/** The typed failure. */
|
|
106
|
-
readonly error: OpError;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* The reply envelope: either a result or an error, correlated by id.
|
|
110
|
-
*
|
|
111
|
-
* Discriminate by presence of the `result` / `error` key (see
|
|
112
|
-
* {@link isReplyOk}). This is the only shape the driver waits on for a pending
|
|
113
|
-
* request and the only shape the server emits in response to a request frame.
|
|
114
|
-
*/
|
|
115
|
-
export type Reply<R = unknown> = ReplyOk<R> | ReplyErr;
|
|
116
|
-
/** Narrow a {@link Reply} to its success arm. */
|
|
117
|
-
export declare function isReplyOk<R>(reply: Reply<R>): reply is ReplyOk<R>;
|
|
118
|
-
/** The closed set of error codes the channels mint. */
|
|
119
|
-
export declare const OP_ERROR: Readonly<{
|
|
120
|
-
/** The framed line was not valid JSON. */
|
|
121
|
-
parse: -32700;
|
|
122
|
-
/** The frame was not a well-formed request. */
|
|
123
|
-
invalidRequest: -32600;
|
|
124
|
-
/** No operation is registered under the requested `method`. */
|
|
125
|
-
unknownOp: -32601;
|
|
126
|
-
/** The `params` failed the operation schema. */
|
|
127
|
-
invalidParams: -32602;
|
|
128
|
-
/** The operation handler threw. */
|
|
129
|
-
handlerFailed: -32000;
|
|
130
|
-
}>;
|
|
131
|
-
/**
|
|
132
|
-
* The minimal writable surface a channel emits onto.
|
|
133
|
-
*
|
|
134
|
-
* Pinning the dependency to this one method (rather than a Node `Writable`) is
|
|
135
|
-
* what lets a test capture output into an array while production passes the real
|
|
136
|
-
* `process.stdout`. The optional `cb` mirrors Node so a caller can await drain.
|
|
137
|
-
*/
|
|
138
|
-
export interface WritableLine {
|
|
139
|
-
/** Write one already-framed chunk; the optional callback fires when flushed. */
|
|
140
|
-
write(chunk: string, cb?: (error?: Error | null) => void): boolean;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* The minimal readable surface a channel consumes.
|
|
144
|
-
*
|
|
145
|
-
* An async-iterable of string or byte chunks — exactly what `process.stdin` and
|
|
146
|
-
* an in-memory pipe both satisfy. The framer turns this chunk stream into a line
|
|
147
|
-
* stream; nothing else reads it directly.
|
|
148
|
-
*/
|
|
149
|
-
export type ReadableChunks = AsyncIterable<string | Uint8Array>;
|
|
150
|
-
/**
|
|
151
|
-
* Encode one value as a single NDJSON line.
|
|
152
|
-
*
|
|
153
|
-
* Serializes `value` to JSON and appends a newline. Crucially it escapes the two
|
|
154
|
-
* Unicode line separators U+2028 and U+2029 to their `
|
|
155
|
-
` / `
|
|
156
|
-
` forms:
|
|
157
|
-
* both are legal *inside* a JSON string but a downstream splitter that treats
|
|
158
|
-
* them as line boundaries would corrupt the frame. Escaping them keeps the
|
|
159
|
-
* framing strictly newline-delimited regardless of payload content.
|
|
160
|
-
*
|
|
161
|
-
* @param value any JSON-serializable value (a request, a reply, or a signal)
|
|
162
|
-
* @returns the encoded line, terminated by a single `\n`
|
|
163
|
-
*/
|
|
164
|
-
export type EncodeLine = (value: unknown) => string;
|
|
165
|
-
/**
|
|
166
|
-
* Decode a chunk stream into a stream of parsed JSON values.
|
|
167
|
-
*
|
|
168
|
-
* An async generator (pull model): it buffers incoming chunks, splits strictly
|
|
169
|
-
* on `\n`, parses each complete line, and yields the parsed value. Partial
|
|
170
|
-
* trailing data is held until its newline arrives; a blank line is skipped. It
|
|
171
|
-
* never splits on U+2028/U+2029, so a value encoded by {@link EncodeLine}
|
|
172
|
-
* round-trips exactly.
|
|
173
|
-
*
|
|
174
|
-
* @param stream the raw chunk stream (e.g. stdin or an in-memory pipe)
|
|
175
|
-
*/
|
|
176
|
-
export type DecodeLines = (stream: ReadableChunks) => AsyncGenerator<unknown, void, unknown>;
|
|
177
|
-
/**
|
|
178
|
-
* The NDJSON framer pair: the two halves of the line transport.
|
|
179
|
-
*
|
|
180
|
-
* Bundled so the server, the driver, and the oneshot channel all share one
|
|
181
|
-
* correct implementation rather than re-deriving framing at each call site.
|
|
182
|
-
*/
|
|
183
|
-
export interface NdjsonFramer {
|
|
184
|
-
/** Serialize one value to a newline-terminated, separator-safe line. */
|
|
185
|
-
readonly encodeLine: EncodeLine;
|
|
186
|
-
/** Pull parsed values from a chunk stream, one per `\n`. */
|
|
187
|
-
readonly decodeLines: DecodeLines;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* A blocking request from the agent to whoever is driving the channel.
|
|
191
|
-
*
|
|
192
|
-
* `ask` is the round-trip dialog primitive: the server emits an `Ask` frame and
|
|
193
|
-
* suspends until a matching answer arrives (or the deadline lapses). The `kind`
|
|
194
|
-
* names the interaction (a choice, a confirm, a free-text prompt, an editor
|
|
195
|
-
* session); `payload` carries the kind-specific options; the `id` correlates the
|
|
196
|
-
* eventual answer.
|
|
197
|
-
*/
|
|
198
|
-
export interface Ask {
|
|
199
|
-
/** Frame discriminant on the wire. */
|
|
200
|
-
readonly type: "ask";
|
|
201
|
-
/** Correlation id for the answer. */
|
|
202
|
-
readonly id: string;
|
|
203
|
-
/** The interaction kind (e.g. `"select"`, `"confirm"`, `"input"`, `"editor"`). */
|
|
204
|
-
readonly kind: string;
|
|
205
|
-
/** Kind-specific options for the interaction. */
|
|
206
|
-
readonly payload?: unknown;
|
|
207
|
-
}
|
|
208
|
-
/** The answer to an {@link Ask}, correlated by its `id`. */
|
|
209
|
-
export interface AskAnswer {
|
|
210
|
-
/** Frame discriminant on the wire. */
|
|
211
|
-
readonly type: "answer";
|
|
212
|
-
/** The id of the {@link Ask} this answers. */
|
|
213
|
-
readonly id: string;
|
|
214
|
-
/** The supplied value (kind-specific; `null` when dismissed). */
|
|
215
|
-
readonly value: unknown;
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* A one-way notice from the agent to the driver — no answer expected.
|
|
219
|
-
*
|
|
220
|
-
* `tell` is the fire-and-forget dialog primitive: status updates, a flashed
|
|
221
|
-
* notification, a title change. The `kind` names the notice; `payload` carries
|
|
222
|
-
* its detail.
|
|
223
|
-
*/
|
|
224
|
-
export interface Tell {
|
|
225
|
-
/** Frame discriminant on the wire. */
|
|
226
|
-
readonly type: "tell";
|
|
227
|
-
/** The notice kind (e.g. `"notify"`, `"status"`, `"title"`). */
|
|
228
|
-
readonly kind: string;
|
|
229
|
-
/** Kind-specific detail. */
|
|
230
|
-
readonly payload?: unknown;
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* The dialog seam a channel exposes to the agent/extension layer.
|
|
234
|
-
*
|
|
235
|
-
* One generic round-trip primitive ({@link ask}) plus one fire-and-forget
|
|
236
|
-
* primitive ({@link tell}); every concrete dialog method (select, confirm,
|
|
237
|
-
* input, notify, set-status, …) is expressed in terms of these two, so there is
|
|
238
|
-
* no per-method choreography to repeat.
|
|
239
|
-
*/
|
|
240
|
-
export interface DialogBridge {
|
|
241
|
-
/**
|
|
242
|
-
* Emit an {@link Ask} and resolve with the matching {@link AskAnswer} value.
|
|
243
|
-
*
|
|
244
|
-
* Resolves with `fallback` if no answer arrives before the deadline, so a
|
|
245
|
-
* disconnected or non-interactive driver never wedges the agent.
|
|
246
|
-
*
|
|
247
|
-
* @param kind the interaction kind
|
|
248
|
-
* @param payload kind-specific options
|
|
249
|
-
* @param fallback value to resolve with on timeout / dismissal
|
|
250
|
-
*/
|
|
251
|
-
ask<T>(kind: string, payload: unknown, fallback: T): Promise<T>;
|
|
252
|
-
/**
|
|
253
|
-
* Emit a {@link Tell} and return immediately.
|
|
254
|
-
*
|
|
255
|
-
* @param kind the notice kind
|
|
256
|
-
* @param payload kind-specific detail
|
|
257
|
-
*/
|
|
258
|
-
tell(kind: string, payload?: unknown): void;
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* The execution context handed to every {@link Op.handle} and shared by both
|
|
262
|
-
* channels.
|
|
263
|
-
*
|
|
264
|
-
* It bundles the {@link SessionConductor} an operation delegates to, the framed
|
|
265
|
-
* transport (`out` to emit, `framer` to encode), and the {@link DialogBridge}
|
|
266
|
-
* for blocking/fire-and-forget interaction. Everything is injected, so a test
|
|
267
|
-
* supplies a fake conductor, an array-backed {@link WritableLine}, and an
|
|
268
|
-
* in-memory dialog bridge with no real process attached.
|
|
269
|
-
*/
|
|
270
|
-
export interface ChannelContext {
|
|
271
|
-
/** The session this channel drives; every op delegates to it. */
|
|
272
|
-
readonly conductor: SessionConductor;
|
|
273
|
-
/** The framed output sink for replies, signals, and dialog frames. */
|
|
274
|
-
readonly out: WritableLine;
|
|
275
|
-
/** The shared NDJSON framer. */
|
|
276
|
-
readonly framer: NdjsonFramer;
|
|
277
|
-
/** The dialog round-trip / notice bridge. */
|
|
278
|
-
readonly dialog: DialogBridge;
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* A single named operation in the link protocol.
|
|
282
|
-
*
|
|
283
|
-
* An op binds a wire `method` name to a typed `handle`: given the request
|
|
284
|
-
* `params` of type `P` and the {@link ChannelContext}, it produces a result of
|
|
285
|
-
* type `R`. The server invokes `handle` on a matching request and frames its
|
|
286
|
-
* resolved value into a {@link Reply}; the {@link LinkDriver} exposes a method of
|
|
287
|
-
* the same name that round-trips `P` to `R`. One declaration drives both halves.
|
|
288
|
-
*
|
|
289
|
-
* @typeParam P the operation's parameter shape (`void` when it takes none)
|
|
290
|
-
* @typeParam R the operation's result shape
|
|
291
|
-
*/
|
|
292
|
-
export interface Op<P = void, R = unknown> {
|
|
293
|
-
/** The wire method name; the registry key and the driver method name. */
|
|
294
|
-
readonly method: string;
|
|
295
|
-
/**
|
|
296
|
-
* Run the operation against the live session.
|
|
297
|
-
*
|
|
298
|
-
* @param params the validated request payload
|
|
299
|
-
* @param ctx the shared channel context (conductor, transport, dialog)
|
|
300
|
-
*/
|
|
301
|
-
handle(params: P, ctx: ChannelContext): Promise<R>;
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* A map of operation name to its {@link Op} declaration — what {@link defineOps}
|
|
305
|
-
* produces and what both the server and the {@link LinkDriver} consume.
|
|
306
|
-
*
|
|
307
|
-
* The map is keyed by the same string used as each op's `method`, so dispatch is
|
|
308
|
-
* a single lookup and the driver's method set is exactly `keyof` this map.
|
|
309
|
-
*/
|
|
310
|
-
export type OpRegistry = Readonly<Record<string, Op<any, any>>>;
|
|
311
|
-
/**
|
|
312
|
-
* Freeze a set of operation declarations into an {@link OpRegistry}.
|
|
313
|
-
*
|
|
314
|
-
* The lone sanctioned way to mint a registry, so the dispatch map and the driver
|
|
315
|
-
* type always derive from one frozen source. Each entry's key becomes the wire
|
|
316
|
-
* method name; the value is the {@link Op}. The result is frozen so neither half
|
|
317
|
-
* can mutate the protocol at runtime.
|
|
318
|
-
*
|
|
319
|
-
* @param ops a record of method-name → {@link Op}
|
|
320
|
-
* @returns the frozen registry, with the input record's exact key/value types
|
|
321
|
-
* preserved for the generated driver
|
|
322
|
-
*/
|
|
323
|
-
export declare function defineOps<T extends Record<string, Op<any, any>>>(ops: T): Readonly<T>;
|
|
324
|
-
/** Extract the parameter type of an {@link Op}. */
|
|
325
|
-
export type OpParams<O> = O extends Op<infer P, any> ? P : never;
|
|
326
|
-
/** Extract the result type of an {@link Op}. */
|
|
327
|
-
export type OpResult<O> = O extends Op<any, infer R> ? R : never;
|
|
328
|
-
/**
|
|
329
|
-
* The generated client type: one method per operation in a registry.
|
|
330
|
-
*
|
|
331
|
-
* For every op `k` in `Ops`, the driver exposes `k(params): Promise<result>` —
|
|
332
|
-
* with the parameter dropped entirely when the op takes `void`. The concrete
|
|
333
|
-
* driver builds these methods from the registry (a proxy / generated thunks), so
|
|
334
|
-
* there are no hand-written parallel method bodies; this type is the static face
|
|
335
|
-
* the registry projects.
|
|
336
|
-
*
|
|
337
|
-
* @typeParam Ops the {@link OpRegistry} the driver is generated from
|
|
338
|
-
*/
|
|
339
|
-
export type LinkDriver<Ops extends OpRegistry> = {
|
|
340
|
-
[K in keyof Ops]: OpParams<Ops[K]> extends void ? () => Promise<OpResult<Ops[K]>> : (params: OpParams<Ops[K]>) => Promise<OpResult<Ops[K]>>;
|
|
341
|
-
};
|
|
342
|
-
/**
|
|
343
|
-
* The session-state projection sent over the link.
|
|
344
|
-
*
|
|
345
|
-
* A flat, serializable snapshot of everything a driver needs to mirror the
|
|
346
|
-
* session without holding a live conductor: which model is bound, the reasoning
|
|
347
|
-
* effort, the busy flags, the persisted location, and the queue depth. It is the
|
|
348
|
-
* link's own vocabulary — derived from the conductor's {@link ConductorState}
|
|
349
|
-
* but shaped for the wire, not a passthrough of the internal state object.
|
|
350
|
-
*/
|
|
351
|
-
export interface LinkSnapshot {
|
|
352
|
-
/** Canonical id of the model currently bound to the session. */
|
|
353
|
-
readonly model: string;
|
|
354
|
-
/** Active reasoning effort. */
|
|
355
|
-
readonly thinking: ThinkingLevel;
|
|
356
|
-
/** Whether an assistant turn is producing output right now. */
|
|
357
|
-
readonly streaming: boolean;
|
|
358
|
-
/** Whether the transcript is being condensed right now. */
|
|
359
|
-
readonly condensing: boolean;
|
|
360
|
-
/** Whether the session has faulted on its most recent turn. */
|
|
361
|
-
readonly faulted: boolean;
|
|
362
|
-
/** Stable identifier of the active session. */
|
|
363
|
-
readonly sessionId: string;
|
|
364
|
-
/** On-disk transcript file backing the session, when persisted. */
|
|
365
|
-
readonly sessionFile?: string;
|
|
366
|
-
/** Whether auto-condense is engaged. */
|
|
367
|
-
readonly autoCondense: boolean;
|
|
368
|
-
/** Number of nodes on the active transcript branch. */
|
|
369
|
-
readonly messageCount: number;
|
|
370
|
-
/** Number of inputs queued behind the in-flight turn. */
|
|
371
|
-
readonly queuedCount: number;
|
|
372
|
-
/** Cumulative token/cost spend across the session so far. */
|
|
373
|
-
readonly usage: Usage;
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* An uncorrelated event frame streamed from server to driver.
|
|
377
|
-
*
|
|
378
|
-
* Distinct from a {@link Reply} (which answers a specific request): a signal is
|
|
379
|
-
* pushed as the turn progresses and carries no `id`. The driver fans signals out
|
|
380
|
-
* to its listeners; the oneshot NDJSON shape writes them straight to the sink.
|
|
381
|
-
*/
|
|
382
|
-
export interface Signal {
|
|
383
|
-
/** Frame discriminant on the wire. */
|
|
384
|
-
readonly type: "signal";
|
|
385
|
-
/** The signal name (the conductor signal kind, projected to the wire). */
|
|
386
|
-
readonly name: string;
|
|
387
|
-
/** The signal's payload. */
|
|
388
|
-
readonly body: unknown;
|
|
389
|
-
}
|
|
390
|
-
/** The two output shapes the oneshot channel can produce. */
|
|
391
|
-
export type OneshotShape = "text" | "ndjson";
|
|
392
|
-
/**
|
|
393
|
-
* The request the oneshot channel runs.
|
|
394
|
-
*
|
|
395
|
-
* One or more prompts run sequentially to settlement; `images` ride along with
|
|
396
|
-
* the first. `shape` selects between clean final text and a streamed NDJSON
|
|
397
|
-
* event log.
|
|
398
|
-
*/
|
|
399
|
-
export interface OneshotRequest {
|
|
400
|
-
/** Output shape: clean final text, or a streamed NDJSON event log. */
|
|
401
|
-
readonly shape: OneshotShape;
|
|
402
|
-
/** The prompts to run, in order. */
|
|
403
|
-
readonly prompts: readonly string[];
|
|
404
|
-
/** Images attached to the first prompt, if any. */
|
|
405
|
-
readonly images?: readonly ImageContent[];
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* A pluggable per-shape strategy for the oneshot channel.
|
|
409
|
-
*
|
|
410
|
-
* Each shape ({@link OneshotShape}) supplies one of these: `onStart` runs once
|
|
411
|
-
* before the prompts (e.g. emit a header line for NDJSON), `onSignal` reacts to
|
|
412
|
-
* each conductor signal (NDJSON emits; text ignores), and `finish` turns the
|
|
413
|
-
* settled state into the process exit code (0 ok, 1 on fault). Selecting a shape
|
|
414
|
-
* is choosing a strategy object — there are no shape branches sprinkled through
|
|
415
|
-
* the runner body.
|
|
416
|
-
*/
|
|
417
|
-
export interface OneshotStrategy {
|
|
418
|
-
/** Run once before any prompt is submitted. */
|
|
419
|
-
onStart?(ctx: ChannelContext): void | Promise<void>;
|
|
420
|
-
/** React to one streamed signal as the turn progresses. */
|
|
421
|
-
onSignal?(signal: unknown, ctx: ChannelContext): void;
|
|
422
|
-
/**
|
|
423
|
-
* Produce the exit code from the settled state once all prompts resolve.
|
|
424
|
-
*
|
|
425
|
-
* @param state the conductor state after the final prompt
|
|
426
|
-
* @param ctx the channel context
|
|
427
|
-
*/
|
|
428
|
-
finish(state: ConductorState, ctx: ChannelContext): number | Promise<number>;
|
|
429
|
-
}
|
|
430
|
-
/** The request-id prefix the driver stamps on outgoing requests. */
|
|
431
|
-
export declare const REQUEST_ID_PREFIX: "lnk-";
|
|
432
|
-
/**
|
|
433
|
-
* Timeouts and intervals the channels need, sourced from config rather than
|
|
434
|
-
* hard-coded at the call sites.
|
|
435
|
-
*
|
|
436
|
-
* Every duration is in milliseconds. Defaults are supplied by
|
|
437
|
-
* {@link DEFAULT_CHANNEL_TIMINGS}; an embedder may override any of them when it
|
|
438
|
-
* constructs a driver or server.
|
|
439
|
-
*/
|
|
440
|
-
export interface ChannelTimings {
|
|
441
|
-
/** How long to wait for a spawned child to report ready before failing. */
|
|
442
|
-
readonly startupMs: number;
|
|
443
|
-
/** Grace period after a soft terminate before a hard kill. */
|
|
444
|
-
readonly shutdownMs: number;
|
|
445
|
-
/** How long a sent request waits for its {@link Reply} before rejecting. */
|
|
446
|
-
readonly requestMs: number;
|
|
447
|
-
/** How long {@link DialogBridge.ask} waits before resolving with its fallback. */
|
|
448
|
-
readonly dialogMs: number;
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* The default {@link ChannelTimings}.
|
|
452
|
-
*
|
|
453
|
-
* Deliberately distinct values, owned here and overridable — not a copied
|
|
454
|
-
* constant set scattered across the runners.
|
|
455
|
-
*/
|
|
456
|
-
export declare const DEFAULT_CHANNEL_TIMINGS: ChannelTimings;
|
|
457
|
-
/**
|
|
458
|
-
* Options for constructing the {@link LinkDriver} concrete client.
|
|
459
|
-
*
|
|
460
|
-
* The transport is injectable (`out`/`in` streams), so a test drives the link
|
|
461
|
-
* over in-memory pipes with no spawned process; `timings` overrides any default
|
|
462
|
-
* duration; `framer` overrides the default NDJSON framer.
|
|
463
|
-
*/
|
|
464
|
-
export interface DriverOptions {
|
|
465
|
-
/** Sink the driver writes framed requests to (defaults to the child stdin). */
|
|
466
|
-
readonly out?: WritableLine;
|
|
467
|
-
/** Source the driver reads framed replies/signals from (defaults to child stdout). */
|
|
468
|
-
readonly in?: ReadableChunks;
|
|
469
|
-
/** Override any subset of the timings. */
|
|
470
|
-
readonly timings?: Partial<ChannelTimings>;
|
|
471
|
-
/** Override the NDJSON framer. */
|
|
472
|
-
readonly framer?: NdjsonFramer;
|
|
473
|
-
}
|
|
474
|
-
/**
|
|
475
|
-
* Options for constructing the link {@link Op}-dispatch server.
|
|
476
|
-
*
|
|
477
|
-
* The streams are injectable for the same reason: tests serve the link over an
|
|
478
|
-
* in-memory pipe pair instead of real stdio.
|
|
479
|
-
*/
|
|
480
|
-
export interface ServerOptions {
|
|
481
|
-
/** Source of framed request lines (defaults to stdin). */
|
|
482
|
-
readonly in?: ReadableChunks;
|
|
483
|
-
/** Sink for framed replies, signals, and dialog frames (defaults to stdout). */
|
|
484
|
-
readonly out?: WritableLine;
|
|
485
|
-
/** Override any subset of the timings. */
|
|
486
|
-
readonly timings?: Partial<ChannelTimings>;
|
|
487
|
-
/** Override the NDJSON framer. */
|
|
488
|
-
readonly framer?: NdjsonFramer;
|
|
489
|
-
}
|