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,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NDJSON framer — the concrete, separator-safe line transport.
|
|
3
|
-
*
|
|
4
|
-
* Implements the {@link NdjsonFramer} surface declared in the contract: a pure
|
|
5
|
-
* encoder ({@link encodeLine}) and a pull-model async-generator decoder
|
|
6
|
-
* ({@link decodeLines}). Both halves are I/O-free seams over an injected stream,
|
|
7
|
-
* so the server, the driver, and the oneshot channel share one correct framing
|
|
8
|
-
* implementation.
|
|
9
|
-
*
|
|
10
|
-
* The correctness pin: U+2028 (LINE SEPARATOR) and U+2029 (PARAGRAPH SEPARATOR)
|
|
11
|
-
* are legal inside a JSON string but a downstream splitter that treats them as
|
|
12
|
-
* line boundaries corrupts the frame. {@link encodeLine} escapes both to their
|
|
13
|
-
* backslash-u forms, and {@link decodeLines} splits strictly on the line feed
|
|
14
|
-
* (U+000A) only — so any value the encoder emits round-trips through the decoder
|
|
15
|
-
* unchanged regardless of payload content.
|
|
16
|
-
*/
|
|
17
|
-
import type { DecodeLines, EncodeLine, NdjsonFramer } from "./contract";
|
|
18
|
-
/**
|
|
19
|
-
* Encode one value as a single, separator-safe NDJSON line.
|
|
20
|
-
*
|
|
21
|
-
* Serializes `value` with `JSON.stringify`, escapes the two Unicode line
|
|
22
|
-
* separators, and appends exactly one line feed. The result contains no raw
|
|
23
|
-
* U+2028 / U+2029 and exactly one terminating `\n`, so a strictly-newline
|
|
24
|
-
* splitter recovers it intact.
|
|
25
|
-
*
|
|
26
|
-
* @param value any JSON-serializable value (a request, a reply, or a signal)
|
|
27
|
-
* @returns the encoded line, terminated by a single `\n`
|
|
28
|
-
*/
|
|
29
|
-
export declare const encodeLine: EncodeLine;
|
|
30
|
-
/**
|
|
31
|
-
* Decode a chunk stream into a stream of parsed JSON values.
|
|
32
|
-
*
|
|
33
|
-
* Pull model: buffers incoming text, splits on `\n` only, parses each complete
|
|
34
|
-
* line, and yields the parsed value. A partial trailing line is held until its
|
|
35
|
-
* newline arrives; an empty (or whitespace-only) line is skipped. A trailing
|
|
36
|
-
* unterminated line at end-of-stream is parsed if it carries content, so a
|
|
37
|
-
* non-newline-terminated final frame is not silently dropped.
|
|
38
|
-
*
|
|
39
|
-
* @param stream the raw chunk stream (stdin, a child pipe, or an in-memory pipe)
|
|
40
|
-
*/
|
|
41
|
-
export declare const decodeLines: DecodeLines;
|
|
42
|
-
/**
|
|
43
|
-
* The bundled framer pair: the canonical {@link NdjsonFramer} instance.
|
|
44
|
-
*
|
|
45
|
-
* Frozen so consumers share one implementation by reference rather than
|
|
46
|
-
* re-deriving framing at each call site; an embedder may still inject an
|
|
47
|
-
* alternate framer via the driver / server options.
|
|
48
|
-
*/
|
|
49
|
-
export declare const ndjsonFramer: NdjsonFramer;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Channels subsystem — public barrel.
|
|
3
|
-
*
|
|
4
|
-
* Re-exports the FROZEN Phase-8 contract: the JSON-RPC 2.0 envelope
|
|
5
|
-
* ({@link OpRequest}, {@link Reply}, {@link OpError}), the declarative operation
|
|
6
|
-
* registry ({@link Op}, {@link OpRegistry}, {@link defineOps}) and the type that
|
|
7
|
-
* the typed client is generated from ({@link LinkDriver}), the NDJSON framer
|
|
8
|
-
* surface ({@link NdjsonFramer} / {@link EncodeLine} / {@link DecodeLines}), the
|
|
9
|
-
* dialog primitives ({@link Ask} / {@link Tell} / {@link DialogBridge}), the
|
|
10
|
-
* {@link ChannelContext}, the wire session projection ({@link LinkSnapshot}), and
|
|
11
|
-
* the oneshot channel shapes ({@link OneshotRequest} / {@link OneshotStrategy}).
|
|
12
|
-
*
|
|
13
|
-
* Behavior modules (the oneshot runner, the link server, the generated driver,
|
|
14
|
-
* the NDJSON framer, and the dialog bridge) are added to this barrel as they
|
|
15
|
-
* land; consumers import the channel surface from `src/channels` rather than
|
|
16
|
-
* reaching into individual modules.
|
|
17
|
-
*/
|
|
18
|
-
export type { ProtocolVersion, RequestId, OpRequest, OpError, ReplyOk, ReplyErr, Reply, WritableLine, ReadableChunks, EncodeLine, DecodeLines, NdjsonFramer, Ask, AskAnswer, Tell, DialogBridge, ChannelContext, Op, OpRegistry, OpParams, OpResult, LinkDriver, LinkSnapshot, Signal, OneshotShape, OneshotRequest, OneshotStrategy, ChannelTimings, DriverOptions, ServerOptions, ImageContent, SessionConductor, ConductorState, ThinkingLevel, Usage, } from "./contract";
|
|
19
|
-
export { PROTOCOL_VERSION, OP_ERROR, REQUEST_ID_PREFIX, DEFAULT_CHANNEL_TIMINGS, isReplyOk, defineOps, } from "./contract";
|
|
20
|
-
export { encodeLine, decodeLines, ndjsonFramer } from "./framer";
|
|
21
|
-
export { dispatch, hasOp, methodsOf, buildOps, UnknownOpError, type OpRegistryHandle, } from "./ops";
|
|
22
|
-
export { runOneshot, inertDialog } from "./oneshot";
|
|
23
|
-
export { SESSION_OPS, projectSnapshot, type SessionOps, type SubmitParams, type ResumeParams, type CycleModelParams, type ModelEntry, } from "./session-ops";
|
|
24
|
-
export { createLinkServer, createLinkDriver, createDialogBridge, makeDialogMethods, DIALOG_TABLE, LinkRequestError, type LinkServer, type LinkServerIo, type LinkServerConfig, type LinkDriverHandle, type LinkDriverIo, type LinkDriverConfig, type LinkedDialogBridge, type DialogBridgeDeps, type DialogSpec, type DialogMethods, } from "./link";
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dialog bridge — the ask / tell seam over the link transport.
|
|
3
|
-
*
|
|
4
|
-
* The agent (and the extensions it hosts) needs to interact with whoever drives
|
|
5
|
-
* the channel: ask a multiple-choice question, confirm a destructive action,
|
|
6
|
-
* prompt for free text, flash a notice, set a status line. Rather than a
|
|
7
|
-
* per-interaction handler ladder, the whole surface reduces to two primitives:
|
|
8
|
-
*
|
|
9
|
-
* - {@link DialogBridge.ask} — one generic round-trip: emit an {@link Ask}
|
|
10
|
-
* frame, suspend until a correlated {@link AskAnswer} arrives, and resolve
|
|
11
|
-
* with its value (or a caller-supplied fallback when the deadline lapses or
|
|
12
|
-
* the driver dismisses the request).
|
|
13
|
-
* - {@link DialogBridge.tell} — one generic fire-and-forget: emit a {@link Tell}
|
|
14
|
-
* frame and return immediately.
|
|
15
|
-
*
|
|
16
|
-
* Concrete dialog methods (select / confirm / input / notify / status / title)
|
|
17
|
-
* are expressed as a *data table* of named entries keyed by interaction kind, not
|
|
18
|
-
* as bespoke method bodies. {@link makeDialogMethods} closes that table over a
|
|
19
|
-
* single bridge so a caller gets typed conveniences while the bridge keeps the
|
|
20
|
-
* lone round-trip / fire-and-forget implementation.
|
|
21
|
-
*/
|
|
22
|
-
import type { AskAnswer, ChannelTimings, DialogBridge, NdjsonFramer, WritableLine } from "../contract";
|
|
23
|
-
/** Everything {@link createDialogBridge} needs to emit frames and time out. */
|
|
24
|
-
export interface DialogBridgeDeps {
|
|
25
|
-
/** Sink the ask/tell frames are written to (already framed). */
|
|
26
|
-
readonly out: WritableLine;
|
|
27
|
-
/** Framer used to encode each frame to a line. */
|
|
28
|
-
readonly framer: NdjsonFramer;
|
|
29
|
-
/** Timings; only {@link ChannelTimings.dialogMs} is consulted here. */
|
|
30
|
-
readonly timings: ChannelTimings;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* A {@link DialogBridge} whose pending answers are fed by an external reader.
|
|
34
|
-
*
|
|
35
|
-
* The bridge itself does not read the stream — the server owns the single
|
|
36
|
-
* decode loop and routes any inbound {@link AskAnswer} frame to
|
|
37
|
-
* {@link LinkedDialogBridge.deliver}. This keeps one reader over the transport
|
|
38
|
-
* (the server) rather than competing consumers.
|
|
39
|
-
*/
|
|
40
|
-
export interface LinkedDialogBridge extends DialogBridge {
|
|
41
|
-
/**
|
|
42
|
-
* Resolve the pending {@link DialogBridge.ask} that minted `answer.id`.
|
|
43
|
-
*
|
|
44
|
-
* A no-op when no ask is pending under that id (a late or duplicate answer),
|
|
45
|
-
* so a misbehaving driver cannot throw into the read loop.
|
|
46
|
-
*
|
|
47
|
-
* @param answer the inbound answer frame
|
|
48
|
-
* @returns whether a pending ask was settled by this answer
|
|
49
|
-
*/
|
|
50
|
-
deliver(answer: AskAnswer): boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Reject every still-pending ask with its fallback (used on shutdown), so no
|
|
53
|
-
* awaiting handler is left suspended when the link closes.
|
|
54
|
-
*/
|
|
55
|
-
drain(): void;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Construct a {@link LinkedDialogBridge} over an injected sink + framer.
|
|
59
|
-
*
|
|
60
|
-
* `ask` writes an {@link Ask} frame, registers the pending resolver under a
|
|
61
|
-
* fresh id, and arms a fallback timer; `deliver` settles the matching pending
|
|
62
|
-
* resolver when the answer returns. `tell` writes a {@link Tell} frame and
|
|
63
|
-
* returns at once. No stdio, no global state — every dependency is injected.
|
|
64
|
-
*/
|
|
65
|
-
export declare function createDialogBridge(deps: DialogBridgeDeps): LinkedDialogBridge;
|
|
66
|
-
/**
|
|
67
|
-
* One concrete dialog method expressed as data, not code.
|
|
68
|
-
*
|
|
69
|
-
* `kind` is the wire interaction kind; `mode` selects which primitive carries
|
|
70
|
-
* it (a round-trip `ask` or a fire-and-forget `tell`); `fallback` is the value a
|
|
71
|
-
* round-trip resolves with on timeout / dismissal (unused for `tell`). The whole
|
|
72
|
-
* dialog surface is this table — adding an interaction is adding a row.
|
|
73
|
-
*/
|
|
74
|
-
export interface DialogSpec {
|
|
75
|
-
/** The wire interaction kind (the `Ask.kind` / `Tell.kind`). */
|
|
76
|
-
readonly kind: string;
|
|
77
|
-
/** Whether the method round-trips for an answer or is fire-and-forget. */
|
|
78
|
-
readonly mode: "ask" | "tell";
|
|
79
|
-
/** The value an `ask` resolves with when no answer arrives in time. */
|
|
80
|
-
readonly fallback?: unknown;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* The canonical dialog table: every concrete interaction the channel exposes,
|
|
84
|
-
* each one row of data over the two primitives.
|
|
85
|
-
*
|
|
86
|
-
* Replaces a copied switch of bespoke UI-context methods: the bridge has exactly
|
|
87
|
-
* one round-trip and one fire-and-forget body, and this table names the kinds.
|
|
88
|
-
*/
|
|
89
|
-
export declare const DIALOG_TABLE: Readonly<{
|
|
90
|
-
select: {
|
|
91
|
-
kind: string;
|
|
92
|
-
mode: "ask";
|
|
93
|
-
fallback: null;
|
|
94
|
-
};
|
|
95
|
-
confirm: {
|
|
96
|
-
kind: string;
|
|
97
|
-
mode: "ask";
|
|
98
|
-
fallback: boolean;
|
|
99
|
-
};
|
|
100
|
-
input: {
|
|
101
|
-
kind: string;
|
|
102
|
-
mode: "ask";
|
|
103
|
-
fallback: null;
|
|
104
|
-
};
|
|
105
|
-
editor: {
|
|
106
|
-
kind: string;
|
|
107
|
-
mode: "ask";
|
|
108
|
-
fallback: null;
|
|
109
|
-
};
|
|
110
|
-
notify: {
|
|
111
|
-
kind: string;
|
|
112
|
-
mode: "tell";
|
|
113
|
-
};
|
|
114
|
-
status: {
|
|
115
|
-
kind: string;
|
|
116
|
-
mode: "tell";
|
|
117
|
-
};
|
|
118
|
-
title: {
|
|
119
|
-
kind: string;
|
|
120
|
-
mode: "tell";
|
|
121
|
-
};
|
|
122
|
-
}>;
|
|
123
|
-
/** The set of named dialog methods derived from {@link DIALOG_TABLE}. */
|
|
124
|
-
export type DialogMethods = {
|
|
125
|
-
[K in keyof typeof DIALOG_TABLE]: (typeof DIALOG_TABLE)[K]["mode"] extends "ask" ? (payload?: unknown) => Promise<unknown> : (payload?: unknown) => void;
|
|
126
|
-
};
|
|
127
|
-
/**
|
|
128
|
-
* Close the {@link DIALOG_TABLE} over one {@link DialogBridge} into typed,
|
|
129
|
-
* named convenience methods.
|
|
130
|
-
*
|
|
131
|
-
* Each `ask` row becomes a thunk that round-trips through `bridge.ask` with the
|
|
132
|
-
* row fallback; each `tell` row becomes a thunk that fires through `bridge.tell`.
|
|
133
|
-
* There is no per-method choreography — the bodies are generated from the table.
|
|
134
|
-
*
|
|
135
|
-
* @param bridge the round-trip / fire-and-forget primitive pair
|
|
136
|
-
* @returns the named method object projected from the table
|
|
137
|
-
*/
|
|
138
|
-
export declare function makeDialogMethods(bridge: DialogBridge): DialogMethods;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Link driver — the generated client over the JSON-RPC link.
|
|
3
|
-
*
|
|
4
|
-
* The driver is the mirror of the server: it writes framed requests and reads
|
|
5
|
-
* framed replies. Crucially it is *generated*, not hand-written — there is no
|
|
6
|
-
* per-op client method. A {@link Proxy} turns any property access into a thunk
|
|
7
|
-
* that frames `{ id, method, params } -> awaits { id, result | error }`, so the
|
|
8
|
-
* driver satisfies the {@link LinkDriver} type projected from a registry with a
|
|
9
|
-
* single body. Adding an op to the registry adds a callable method to the driver
|
|
10
|
-
* for free.
|
|
11
|
-
*
|
|
12
|
-
* The driver owns the single reader over the inbound stream. Every decoded frame
|
|
13
|
-
* is one of: a correlated {@link Reply} (settles the pending request under its
|
|
14
|
-
* id), an uncorrelated {@link Signal} (fanned out to subscribers), or an
|
|
15
|
-
* {@link Ask} (handed to an answerer that posts an {@link AskAnswer} back). One
|
|
16
|
-
* reader, three routes — no competing consumers of the transport.
|
|
17
|
-
*/
|
|
18
|
-
import { type Ask, type ChannelTimings, type LinkDriver, type NdjsonFramer, type OpError, type OpRegistry, type ReadableChunks, type Signal, type WritableLine } from "../contract";
|
|
19
|
-
/** The injectable transport pair the driver writes to and reads from. */
|
|
20
|
-
export interface LinkDriverIo {
|
|
21
|
-
/** Sink the driver writes framed requests to (defaults to the child stdin). */
|
|
22
|
-
readonly out: WritableLine;
|
|
23
|
-
/** Source the driver reads framed replies / signals from (defaults to child stdout). */
|
|
24
|
-
readonly in: ReadableChunks;
|
|
25
|
-
}
|
|
26
|
-
/** Optional overrides for a driver: a framer, the timings, and hooks. */
|
|
27
|
-
export interface LinkDriverConfig {
|
|
28
|
-
/** Override the NDJSON framer (defaults to the shared one). */
|
|
29
|
-
readonly framer?: NdjsonFramer;
|
|
30
|
-
/** Override any subset of the channel timings. */
|
|
31
|
-
readonly timings?: Partial<ChannelTimings>;
|
|
32
|
-
/** Invoked for every uncorrelated {@link Signal} the server streams. */
|
|
33
|
-
readonly onSignal?: (signal: Signal) => void;
|
|
34
|
-
/**
|
|
35
|
-
* Invoked when the server asks a question; returns the answer value. When
|
|
36
|
-
* omitted the driver dismisses every ask (posts `null`), so a non-interactive
|
|
37
|
-
* driver never wedges the server.
|
|
38
|
-
*/
|
|
39
|
-
readonly onAsk?: (ask: Ask) => unknown | Promise<unknown>;
|
|
40
|
-
}
|
|
41
|
-
/** A failed reply turned into a throwable error that carries the wire code. */
|
|
42
|
-
export declare class LinkRequestError extends Error {
|
|
43
|
-
/** The JSON-RPC error code from the {@link OpError}. */
|
|
44
|
-
readonly code: number;
|
|
45
|
-
/** The structured detail, when the server supplied any. */
|
|
46
|
-
readonly data: unknown;
|
|
47
|
-
constructor(error: OpError);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* A live driver: the generated client plus its lifecycle.
|
|
51
|
-
*
|
|
52
|
-
* `client` is the {@link Proxy} typed as a {@link LinkDriver} for the registry
|
|
53
|
-
* `Ops`; `done` resolves when the inbound stream ends; `close` rejects every
|
|
54
|
-
* still-pending request and stops the reader.
|
|
55
|
-
*
|
|
56
|
-
* @typeParam Ops the {@link OpRegistry} the client type is projected from
|
|
57
|
-
*/
|
|
58
|
-
export interface LinkDriverHandle<Ops extends OpRegistry> {
|
|
59
|
-
/** The generated, registry-typed client. */
|
|
60
|
-
readonly client: LinkDriver<Ops>;
|
|
61
|
-
/** Resolves when the reader loop drains (the inbound stream ended). */
|
|
62
|
-
readonly done: Promise<void>;
|
|
63
|
-
/** Reject all pending requests with `reason` and stop accepting replies. */
|
|
64
|
-
close(reason?: string): void;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Build a {@link LinkDriverHandle} over an injected transport.
|
|
68
|
-
*
|
|
69
|
-
* The returned `client` is a {@link Proxy}: reading property `m` yields a thunk
|
|
70
|
-
* `(params?) => Promise<result>` that mints an id (prefixed with
|
|
71
|
-
* {@link REQUEST_ID_PREFIX}), writes the framed request, and resolves when the
|
|
72
|
-
* matching {@link Reply} arrives (or rejects on a {@link ReplyErr} or timeout).
|
|
73
|
-
* No method is hand-written; the registry type parameter only shapes the static
|
|
74
|
-
* face. The reader loop classifies inbound frames into replies, signals, and
|
|
75
|
-
* asks and routes each.
|
|
76
|
-
*
|
|
77
|
-
* @typeParam Ops the registry whose method set types the client
|
|
78
|
-
* @param io the injected request sink + reply source
|
|
79
|
-
* @param config optional framer / timing / hook overrides
|
|
80
|
-
*/
|
|
81
|
-
export declare function createLinkDriver<Ops extends OpRegistry = OpRegistry>(io: LinkDriverIo, config?: LinkDriverConfig): LinkDriverHandle<Ops>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Link channel — public barrel.
|
|
3
|
-
*
|
|
4
|
-
* The link channel is the long-lived, bidirectional half of the channels
|
|
5
|
-
* subsystem: a JSON-RPC 2.0 server that dispatches framed requests through an
|
|
6
|
-
* {@link OpRegistry} (`server.ts`), a generated {@link LinkDriver} client built
|
|
7
|
-
* from a {@link Proxy} rather than hand-written methods (`driver.ts`), and the
|
|
8
|
-
* ask / tell dialog bridge that both ends share (`dialog.ts`). Consumers import
|
|
9
|
-
* the link surface from `src/channels/link` rather than the individual modules.
|
|
10
|
-
*/
|
|
11
|
-
export { createLinkServer, type LinkServer, type LinkServerIo, type LinkServerConfig, } from "./server";
|
|
12
|
-
export { createLinkDriver, LinkRequestError, type LinkDriverHandle, type LinkDriverIo, type LinkDriverConfig, } from "./driver";
|
|
13
|
-
export { createDialogBridge, makeDialogMethods, DIALOG_TABLE, type LinkedDialogBridge, type DialogBridgeDeps, type DialogSpec, type DialogMethods, } from "./dialog";
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Link server — the data-driven JSON-RPC 2.0 dispatch loop.
|
|
3
|
-
*
|
|
4
|
-
* The server owns the single reader over the inbound stream. For each framed
|
|
5
|
-
* line it decides what the frame is and routes it: a request frame is dispatched
|
|
6
|
-
* through the {@link OpRegistry} (a map lookup, not a command switch) and its
|
|
7
|
-
* outcome is framed back as a {@link Reply}; an inbound {@link AskAnswer} frame
|
|
8
|
-
* is routed to the {@link DialogBridge} to settle a suspended `ask`. One round of
|
|
9
|
-
* the protocol is `{ id, method, params } -> { id, result | error }`.
|
|
10
|
-
*
|
|
11
|
-
* Everything that touches the outside world is injected: the request source, the
|
|
12
|
-
* reply sink, the framer, and the conductor all arrive through the context and
|
|
13
|
-
* options, so a test serves the link over an in-memory pipe pair with no stdio.
|
|
14
|
-
* The dispatch itself is delegated to {@link dispatch} from the ops module, so
|
|
15
|
-
* the server holds no per-method knowledge.
|
|
16
|
-
*/
|
|
17
|
-
import { type ChannelTimings, type NdjsonFramer, type OpRegistry, type ReadableChunks, type SessionConductor, type WritableLine } from "../contract";
|
|
18
|
-
import { type LinkedDialogBridge } from "./dialog";
|
|
19
|
-
/**
|
|
20
|
-
* The injectable transport pair the server reads from and writes to.
|
|
21
|
-
*
|
|
22
|
-
* Named `io` at the call site; bundles the inbound request source and the
|
|
23
|
-
* outbound reply/signal sink so tests pass in-memory pipes and production passes
|
|
24
|
-
* stdin / stdout.
|
|
25
|
-
*/
|
|
26
|
-
export interface LinkServerIo {
|
|
27
|
-
/** Framed inbound request / answer lines (defaults to stdin). */
|
|
28
|
-
readonly in: ReadableChunks;
|
|
29
|
-
/** Framed outbound reply / signal / dialog sink (defaults to stdout). */
|
|
30
|
-
readonly out: WritableLine;
|
|
31
|
-
}
|
|
32
|
-
/** Optional overrides for a server: a framer and the timings. */
|
|
33
|
-
export interface LinkServerConfig {
|
|
34
|
-
/** Override the NDJSON framer (defaults to the shared one). */
|
|
35
|
-
readonly framer?: NdjsonFramer;
|
|
36
|
-
/** Override any subset of the channel timings. */
|
|
37
|
-
readonly timings?: Partial<ChannelTimings>;
|
|
38
|
-
}
|
|
39
|
-
/** A running server: a promise that settles when the inbound stream ends. */
|
|
40
|
-
export interface LinkServer {
|
|
41
|
-
/** Resolves when the request stream is exhausted and the loop has drained. */
|
|
42
|
-
readonly done: Promise<void>;
|
|
43
|
-
/** The dialog bridge the running server feeds inbound answers to. */
|
|
44
|
-
readonly dialog: LinkedDialogBridge;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Start a link server over an op registry, a conductor, and an injected
|
|
48
|
-
* transport.
|
|
49
|
-
*
|
|
50
|
-
* Builds the shared {@link ChannelContext} (conductor + framer + the freshly
|
|
51
|
-
* wired {@link DialogBridge}), then consumes the inbound stream with a single
|
|
52
|
-
* `for await` loop. Each frame is classified:
|
|
53
|
-
*
|
|
54
|
-
* - an answer frame is delivered to the dialog bridge;
|
|
55
|
-
* - a request frame is dispatched through `registry`; a request carrying an
|
|
56
|
-
* `id` gets exactly one correlated reply (result or error); a notification
|
|
57
|
-
* (no `id`) is dispatched for its effect and never replied to;
|
|
58
|
-
* - any other frame is ignored (a forward-compatible no-op).
|
|
59
|
-
*
|
|
60
|
-
* Parse failures from the framer surface as a thrown error in the loop and are
|
|
61
|
-
* framed as a {@link OP_ERROR.parse} reply with no id (the offending frame had
|
|
62
|
-
* none to correlate).
|
|
63
|
-
*
|
|
64
|
-
* @param registry the frozen {@link OpRegistry} that drives dispatch
|
|
65
|
-
* @param conductor the session every op delegates to
|
|
66
|
-
* @param io the injected request source + reply sink
|
|
67
|
-
* @param config optional framer / timing overrides
|
|
68
|
-
* @returns a handle whose `done` resolves when the inbound stream ends
|
|
69
|
-
*/
|
|
70
|
-
export declare function createLinkServer(registry: OpRegistry, conductor: SessionConductor, io: LinkServerIo, config?: LinkServerConfig): LinkServer;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Oneshot channel — a single non-interactive run to settlement.
|
|
3
|
-
*
|
|
4
|
-
* Replaces the print mode. Given a {@link ChannelContext} and an
|
|
5
|
-
* {@link OneshotRequest}, it submits every prompt to the conductor in order,
|
|
6
|
-
* streams the answer to the channel sink, and resolves a process exit code.
|
|
7
|
-
*
|
|
8
|
-
* The shape (clean final text vs a streamed NDJSON event log) is chosen by
|
|
9
|
-
* selecting an {@link OneshotStrategy} object rather than branching on a flag
|
|
10
|
-
* through the runner body: each strategy supplies an optional `onStart`, an
|
|
11
|
-
* optional `onSignal`, and a mandatory `finish` that turns the settled state
|
|
12
|
-
* into the exit code. The runner itself is shape-agnostic — it subscribes the
|
|
13
|
-
* strategy to the conductor signal stream, runs the prompts, and hands the final
|
|
14
|
-
* state to `finish`.
|
|
15
|
-
*/
|
|
16
|
-
import type { ChannelContext, DialogBridge, OneshotRequest } from "./contract";
|
|
17
|
-
/**
|
|
18
|
-
* A dialog bridge for a non-interactive oneshot run: no driver is attached to
|
|
19
|
-
* answer a question, so every `ask` resolves immediately with its caller-supplied
|
|
20
|
-
* fallback and every `tell` is dropped. Keeps the agent from wedging on a prompt
|
|
21
|
-
* during a headless single run while never writing dialog frames to the sink.
|
|
22
|
-
*/
|
|
23
|
-
export declare const inertDialog: DialogBridge;
|
|
24
|
-
/**
|
|
25
|
-
* Run one non-interactive request to settlement.
|
|
26
|
-
*
|
|
27
|
-
* Selects the {@link OneshotStrategy} for `opts.shape`, subscribes it to the
|
|
28
|
-
* conductor signal stream, runs `onStart`, then submits each prompt in order and
|
|
29
|
-
* awaits its settlement. The state from the final prompt is handed to the
|
|
30
|
-
* strategy's `finish`, whose return value is the resolved exit code. The
|
|
31
|
-
* subscription is always torn down before returning.
|
|
32
|
-
*
|
|
33
|
-
* @param ctx the channel context (conductor, sink, framer, dialog) — fully injected
|
|
34
|
-
* @param opts the request: output shape, the prompts to run, and any images
|
|
35
|
-
* @returns the process exit code (0 on a clean settlement, 1 on a fault)
|
|
36
|
-
*/
|
|
37
|
-
export declare function runOneshot(ctx: ChannelContext, opts: OneshotRequest): Promise<number>;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Operation registry — the single declarative source both halves of the link
|
|
3
|
-
* consume.
|
|
4
|
-
*
|
|
5
|
-
* The contract defines {@link defineOps} (freeze a record of {@link Op}s into an
|
|
6
|
-
* {@link OpRegistry}) and the {@link LinkDriver} type projected from a registry.
|
|
7
|
-
* This module adds the runtime face the server needs and the driver leans on: a
|
|
8
|
-
* built registry carries its `methods` list (so a {@link LinkDriver} can be
|
|
9
|
-
* generated by walking the keys, never hand-written) and a `dispatch` seam that
|
|
10
|
-
* looks an op up by `method` and runs its `handle` — the data-driven replacement
|
|
11
|
-
* for a copied command switch.
|
|
12
|
-
*
|
|
13
|
-
* Nothing here knows about transport or framing: dispatch takes the already
|
|
14
|
-
* parsed `method`/`params` and the shared {@link ChannelContext}, runs the op,
|
|
15
|
-
* and returns its resolved result (or throws {@link UnknownOpError} when no op is
|
|
16
|
-
* registered). The server frames the outcome into a {@link Reply}; the driver
|
|
17
|
-
* uses `methods` to build its thunks. One frozen registry drives both.
|
|
18
|
-
*/
|
|
19
|
-
import { defineOps } from "./contract";
|
|
20
|
-
import type { ChannelContext, Op, OpRegistry } from "./contract";
|
|
21
|
-
/** Re-exported so consumers mint registries from one module. */
|
|
22
|
-
export { defineOps };
|
|
23
|
-
/**
|
|
24
|
-
* Thrown by {@link dispatch} (and {@link OpRegistryHandle.dispatch}) when the
|
|
25
|
-
* requested `method` has no registered {@link Op}.
|
|
26
|
-
*
|
|
27
|
-
* Carries the frozen {@link OP_ERROR.unknownOp} code so the server can frame it
|
|
28
|
-
* into a {@link ReplyErr} without re-deriving the category, and records the
|
|
29
|
-
* offending `method` for logging.
|
|
30
|
-
*/
|
|
31
|
-
export declare class UnknownOpError extends Error {
|
|
32
|
-
/** The JSON-RPC error category for an unregistered method. */
|
|
33
|
-
readonly code: number;
|
|
34
|
-
/** The method name that resolved to no operation. */
|
|
35
|
-
readonly method: string;
|
|
36
|
-
constructor(method: string);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Run one operation by name against the shared context.
|
|
40
|
-
*
|
|
41
|
-
* Looks `method` up in `registry`, then awaits its `handle(params, ctx)`. The
|
|
42
|
-
* lone dispatch path for the server: there is no per-method branch, only a map
|
|
43
|
-
* lookup. Throws {@link UnknownOpError} when the method is not registered and
|
|
44
|
-
* propagates whatever the handler throws (the server maps that to a
|
|
45
|
-
* {@link ReplyErr}).
|
|
46
|
-
*
|
|
47
|
-
* @param registry the frozen {@link OpRegistry} to dispatch within
|
|
48
|
-
* @param method the wire method name to invoke
|
|
49
|
-
* @param params the already-parsed request payload (passed through verbatim)
|
|
50
|
-
* @param ctx the shared {@link ChannelContext}
|
|
51
|
-
* @returns the operation result
|
|
52
|
-
*/
|
|
53
|
-
export declare function dispatch(registry: OpRegistry, method: string, params: unknown, ctx: ChannelContext): Promise<unknown>;
|
|
54
|
-
/** Whether `method` resolves to a registered {@link Op} in `registry`. */
|
|
55
|
-
export declare function hasOp(registry: OpRegistry, method: string): boolean;
|
|
56
|
-
/** The sorted wire method names a registry exposes — the driver's method set. */
|
|
57
|
-
export declare function methodsOf<T extends OpRegistry>(registry: T): ReadonlyArray<keyof T & string>;
|
|
58
|
-
/**
|
|
59
|
-
* A built registry plus its runtime face: the method list and a bound
|
|
60
|
-
* `dispatch`.
|
|
61
|
-
*
|
|
62
|
-
* `methods` is what a generated {@link LinkDriver} walks to build its thunks;
|
|
63
|
-
* `dispatch` is what the server calls per request. Both are bound to the one
|
|
64
|
-
* frozen `registry`, so the server-side dispatch and the client-side method set
|
|
65
|
-
* can never drift from each other.
|
|
66
|
-
*
|
|
67
|
-
* @typeParam T the concrete registry shape (preserved for the generated driver)
|
|
68
|
-
*/
|
|
69
|
-
export interface OpRegistryHandle<T extends OpRegistry> {
|
|
70
|
-
/** The frozen registry — the single source of truth. */
|
|
71
|
-
readonly registry: T;
|
|
72
|
-
/** The sorted method names this registry exposes. */
|
|
73
|
-
readonly methods: ReadonlyArray<keyof T & string>;
|
|
74
|
-
/** Invoke an op by name against `ctx`; see {@link dispatch}. */
|
|
75
|
-
dispatch(method: string, params: unknown, ctx: ChannelContext): Promise<unknown>;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Build an {@link OpRegistryHandle} from a record of operation declarations.
|
|
79
|
-
*
|
|
80
|
-
* Freezes the input with {@link defineOps}, then bundles it with its derived
|
|
81
|
-
* method list and a `dispatch` bound to that frozen registry. This is the lone
|
|
82
|
-
* sanctioned way to produce the object the server and the driver both consume,
|
|
83
|
-
* so the dispatch map and the driver method set always derive from one source.
|
|
84
|
-
*
|
|
85
|
-
* @param ops a record of method-name → {@link Op}
|
|
86
|
-
* @returns the frozen registry handle, with the input's exact key/value types
|
|
87
|
-
* preserved for the generated {@link LinkDriver}
|
|
88
|
-
*/
|
|
89
|
-
export declare function buildOps<T extends Record<string, Op<any, any>>>(ops: T): OpRegistryHandle<Readonly<T>>;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Session ops — the concrete operation registry that drives the link.
|
|
3
|
-
*
|
|
4
|
-
* This is the single declarative source of every operation the link server
|
|
5
|
-
* dispatches and the {@link LinkDriver} client is generated from. Each op binds a
|
|
6
|
-
* wire `method` name to a `handle` that delegates to the {@link SessionConductor}
|
|
7
|
-
* carried on the {@link ChannelContext}; there is no per-method dispatch ladder
|
|
8
|
-
* and no hand-written parallel client method. Adding a row here adds both a
|
|
9
|
-
* server-handled method and a callable driver method.
|
|
10
|
-
*
|
|
11
|
-
* The ops also own the {@link LinkSnapshot} projection: the conductor exposes its
|
|
12
|
-
* internal {@link ConductorState}, and {@link projectSnapshot} reshapes that into
|
|
13
|
-
* the flat, serializable wire vocabulary a remote driver mirrors without holding
|
|
14
|
-
* a live conductor.
|
|
15
|
-
*/
|
|
16
|
-
import type { ConductorState, LinkSnapshot, Op, ThinkingLevel } from "./contract";
|
|
17
|
-
/**
|
|
18
|
-
* Project a conductor {@link ConductorState} onto the wire {@link LinkSnapshot}.
|
|
19
|
-
*
|
|
20
|
-
* The snapshot is the link vocabulary: flat, serializable, and derived from — not
|
|
21
|
-
* a passthrough of — the conductor state. Busy flags are read off the coarse
|
|
22
|
-
* phase, the model and session identity off the state and its head, and the
|
|
23
|
-
* cumulative usage carried straight through.
|
|
24
|
-
*
|
|
25
|
-
* @param state the immutable conductor state
|
|
26
|
-
* @param extra optional fields the conductor does not surface on its state
|
|
27
|
-
*/
|
|
28
|
-
export declare function projectSnapshot(state: ConductorState, extra?: {
|
|
29
|
-
readonly thinking?: ThinkingLevel;
|
|
30
|
-
readonly sessionFile?: string;
|
|
31
|
-
readonly autoCondense?: boolean;
|
|
32
|
-
readonly messageCount?: number;
|
|
33
|
-
readonly queuedCount?: number;
|
|
34
|
-
}): LinkSnapshot;
|
|
35
|
-
/** Parameters for the {@link sessionOps.submit} op. */
|
|
36
|
-
export interface SubmitParams {
|
|
37
|
-
/** The user message text for this turn. */
|
|
38
|
-
readonly input: string;
|
|
39
|
-
}
|
|
40
|
-
/** Parameters for the {@link sessionOps.resume} op. */
|
|
41
|
-
export interface ResumeParams {
|
|
42
|
-
/** The persisted session to restore. */
|
|
43
|
-
readonly sessionId: string;
|
|
44
|
-
}
|
|
45
|
-
/** Parameters for the {@link sessionOps.cycleModel} op. */
|
|
46
|
-
export interface CycleModelParams {
|
|
47
|
-
/** Canonical id of the model to switch to. */
|
|
48
|
-
readonly modelId: string;
|
|
49
|
-
}
|
|
50
|
-
/** One model entry returned by the {@link sessionOps.listModels} op. */
|
|
51
|
-
export interface ModelEntry {
|
|
52
|
-
/** Canonical model id. */
|
|
53
|
-
readonly id: string;
|
|
54
|
-
/** Whether this is the model currently bound to the session. */
|
|
55
|
-
readonly active: boolean;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* The frozen link op set: every operation a driver can invoke, each delegating
|
|
59
|
-
* to the conductor on the context.
|
|
60
|
-
*
|
|
61
|
-
* - `submit` — run a user turn to settlement and reply with a snapshot.
|
|
62
|
-
* - `abort` — cancel the in-flight turn and reply with a snapshot.
|
|
63
|
-
* - `snapshot` — read the current state, projected to a {@link LinkSnapshot}.
|
|
64
|
-
* - `resume` — restore a persisted session and reply with a snapshot.
|
|
65
|
-
* - `listModels` — list the model bound to the session (the active entry).
|
|
66
|
-
* - `cycleModel` — rotate the active model and reply with a snapshot.
|
|
67
|
-
*
|
|
68
|
-
* The map is consumed verbatim by the server (data-driven dispatch) and by the
|
|
69
|
-
* generated {@link LinkDriver} (its method set is exactly these keys).
|
|
70
|
-
*/
|
|
71
|
-
export declare const SESSION_OPS: Readonly<{
|
|
72
|
-
submit: Op<SubmitParams, LinkSnapshot>;
|
|
73
|
-
abort: Op<void, LinkSnapshot>;
|
|
74
|
-
snapshot: Op<void, LinkSnapshot>;
|
|
75
|
-
resume: Op<ResumeParams, LinkSnapshot>;
|
|
76
|
-
listModels: Op<void, readonly ModelEntry[]>;
|
|
77
|
-
cycleModel: Op<CycleModelParams, LinkSnapshot>;
|
|
78
|
-
}>;
|
|
79
|
-
/** The concrete op-set type, for typing a {@link LinkDriver} over this surface. */
|
|
80
|
-
export type SessionOps = typeof SESSION_OPS;
|