indusagi-coding-agent 0.2.3 → 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/CHANGELOG.md +25 -0
- package/LICENSE +661 -0
- package/README.md +95 -1
- package/dist/entry.js +3205 -1585
- package/dist/guardrails.js +47 -515
- package/dist/index.js +3232 -1671
- 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/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 -89
- 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/session-persist.test.d.ts +0 -10
- package/dist/types/boot/runners/session.d.ts +0 -65
- package/dist/types/boot/runners/session.test.d.ts +0 -10
- 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 -317
- 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 -189
- package/dist/types/conductor/conductor.test.d.ts +0 -10
- package/dist/types/conductor/contract.d.ts +0 -774
- 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 -217
- 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 -13
- 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/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 -32
- 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 -598
- 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 -131
- package/dist/types/console/mount.d.ts +0 -53
- package/dist/types/console/overlays/approval-queue.d.ts +0 -71
- 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/oauth.d.ts +0 -101
- 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 -70
- 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 -105
- 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,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Invocation subsystem — public barrel.
|
|
3
|
-
*
|
|
4
|
-
* Bundles the command-line behavior modules that all read the single
|
|
5
|
-
* declarative {@link FLAG_SPECS} table:
|
|
6
|
-
*
|
|
7
|
-
* - {@link readInvocation} — the generic, table-driven argv parser that folds
|
|
8
|
-
* a sliced argument vector into a typed {@link Invocation};
|
|
9
|
-
* - {@link renderUsage} — the `--help` banner generated from that same table,
|
|
10
|
-
* so help and parsing share one source of truth;
|
|
11
|
-
* - {@link gatherAttachments} — the `@file` expander that resolves references
|
|
12
|
-
* through the framework path resolver into inlined prose plus base64 media,
|
|
13
|
-
* raising a typed {@link AttachmentError} on failure.
|
|
14
|
-
*
|
|
15
|
-
* Consumers import the invocation surface from `src/launch/invocation` rather
|
|
16
|
-
* than reaching into the individual modules.
|
|
17
|
-
*/
|
|
18
|
-
export { FLAG_SPECS, FLAG_GROUPS } from "./flags";
|
|
19
|
-
export type { FlagGroup, GroupedFlagSpec } from "./flags";
|
|
20
|
-
export { readInvocation, readFileReferences } from "./read";
|
|
21
|
-
export { renderUsage } from "./usage";
|
|
22
|
-
export { gatherAttachments, AttachmentError } from "./attachments";
|
|
23
|
-
export type { AttachmentErrorKind } from "./attachments";
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The invocation reader — a generic, table-driven argv parser over
|
|
3
|
-
* {@link FLAG_SPECS}.
|
|
4
|
-
*
|
|
5
|
-
* This is the application's full command-line grammar (the boot layer carries
|
|
6
|
-
* only a thin routing parser). It walks a sliced `argv` once and folds every
|
|
7
|
-
* token into a fully-typed {@link Invocation}: recognised flags bind through the
|
|
8
|
-
* declarative {@link FlagSpec} table, `@file` references collect for the
|
|
9
|
-
* attachment gatherer, and remaining positionals become the prompt and the
|
|
10
|
-
* positional tail.
|
|
11
|
-
*
|
|
12
|
-
* The grammar is deliberately textbook and entirely data-driven — there is no
|
|
13
|
-
* per-flag branch. One index over {@link FLAG_SPECS} maps every canonical name
|
|
14
|
-
* and alias to its row; the loop applies whichever row a token resolves to:
|
|
15
|
-
*
|
|
16
|
-
* - **`--name=value`** and **`--name value`** both bind a `string` / `number`
|
|
17
|
-
* / `list` flag; an inline `=value` wins, otherwise the following token is
|
|
18
|
-
* consumed (unless it is itself a flag, in which case the value is empty).
|
|
19
|
-
* - **longest-alias match** resolves the canonical name, so a longer spelling
|
|
20
|
-
* is never shadowed by a shorter prefix.
|
|
21
|
-
* - **`--`** terminates option parsing; every subsequent token is positional.
|
|
22
|
-
* - **clustered short booleans** (`-pi`) expand to each single-letter switch.
|
|
23
|
-
* - **`list` flags accumulate** across repetition and split a single
|
|
24
|
-
* comma-separated token into elements.
|
|
25
|
-
* - **`@file`** tokens are recorded as attachment references rather than
|
|
26
|
-
* positionals.
|
|
27
|
-
*
|
|
28
|
-
* The parse is total: an unrecognised `--flag` is tolerated as a boolean switch
|
|
29
|
-
* in the loose {@link Invocation.flags} bag (the extension-flag escape hatch)
|
|
30
|
-
* rather than rejected, so nothing is silently dropped. Strong typing of the
|
|
31
|
-
* named fields, and mode derivation, happen in one final fold.
|
|
32
|
-
*/
|
|
33
|
-
import { type Invocation } from "../contract";
|
|
34
|
-
/**
|
|
35
|
-
* Read a sliced `argv` into the fully-parsed {@link Invocation}.
|
|
36
|
-
*
|
|
37
|
-
* Walks the tokens once via the {@link FLAG_SPECS} index, accumulates into a
|
|
38
|
-
* {@link ParseState}, then folds that into the strongly-typed result: the loose
|
|
39
|
-
* {@link Invocation.flags} bag is retained for round-tripping and extension
|
|
40
|
-
* flags, and the named fields are derived from it with per-kind coercion and
|
|
41
|
-
* validation. The `attachments` field is left unset here — the file references
|
|
42
|
-
* are surfaced for the attachment gatherer to expand separately.
|
|
43
|
-
*
|
|
44
|
-
* @param argv the already-sliced argument vector (no node / executable path)
|
|
45
|
-
*/
|
|
46
|
-
export declare function readInvocation(argv: readonly string[]): Invocation;
|
|
47
|
-
/**
|
|
48
|
-
* The `@file` references collected from an argv, exposed for the attachment
|
|
49
|
-
* gatherer. A thin re-walk of the reader so the file references can be obtained
|
|
50
|
-
* without re-deriving the whole parse where only attachments are needed.
|
|
51
|
-
*/
|
|
52
|
-
export declare function readFileReferences(argv: readonly string[]): string[];
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The usage renderer — generated entirely from {@link FLAG_SPECS}.
|
|
3
|
-
*
|
|
4
|
-
* {@link renderUsage} produces the `--help` banner by walking the same
|
|
5
|
-
* declarative flag table the reader parses against. There is no second,
|
|
6
|
-
* hand-maintained help string; every option line is synthesised from its
|
|
7
|
-
* {@link FlagSpec} (its canonical name, its aliases, its value placeholder, and
|
|
8
|
-
* its one-line description), grouped by the editorial {@link FLAG_GROUPS}
|
|
9
|
-
* sections. Adding a flag to the table therefore adds it to the help with no
|
|
10
|
-
* further edit, and the two can never disagree about what exists.
|
|
11
|
-
*
|
|
12
|
-
* The renderer is pure and total: it reads only the table and returns a string.
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* Render the full usage banner.
|
|
16
|
-
*
|
|
17
|
-
* Emits a synopsis line, then one section per {@link FLAG_GROUPS} entry that has
|
|
18
|
-
* any rows, then a short note on the two positional conventions the reader
|
|
19
|
-
* honours but that are not flags: the `@file` attachment syntax and the `--`
|
|
20
|
-
* option terminator. Every option line is derived from {@link FLAG_SPECS}; this
|
|
21
|
-
* function holds no per-flag knowledge of its own.
|
|
22
|
-
*
|
|
23
|
-
* @returns the complete multi-line usage string (no trailing newline)
|
|
24
|
-
*/
|
|
25
|
-
export declare function renderUsage(): string;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Phase-10 launch subsystem — unit tests.
|
|
3
|
-
*
|
|
4
|
-
* No network and no real terminal: every effectful seam is injected. The tests
|
|
5
|
-
* pin the public launch surface assembled from the contract:
|
|
6
|
-
*
|
|
7
|
-
* 1. {@link readInvocation} parses a representative argv into the right
|
|
8
|
-
* {@link Invocation} (mode, prompt, model, mcp list, thinking, no-tools).
|
|
9
|
-
* 2. {@link renderUsage} is generated from {@link FLAG_SPECS} alone — every
|
|
10
|
-
* flag description appears, proving the one-source-of-truth invariant.
|
|
11
|
-
* 3. {@link gatherAttachments} resolves an `@file` in a tmpdir and raises a
|
|
12
|
-
* typed {@link AttachmentError} for a missing and an oversized file.
|
|
13
|
-
* 4. {@link runCredentialCommand} stores an api key through an injected fake
|
|
14
|
-
* vault for the api-key path, and drives the framework browser sign-in for
|
|
15
|
-
* an OAuth-capable provider (persisting the returned credentials).
|
|
16
|
-
* 5. {@link printModelCatalog} lists models from an injected source.
|
|
17
|
-
* 6. {@link registerBuiltInOAuthProviders} primes the framework registry and
|
|
18
|
-
* {@link listLoginProviders} surfaces both kinds.
|
|
19
|
-
*/
|
|
20
|
-
export {};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OAuth integration — the browser-sign-in counterpart to the api-key flow.
|
|
3
|
-
*
|
|
4
|
-
* The framework ships working sign-in machinery for a handful of providers but
|
|
5
|
-
* leaves its registry empty by default (api-key-only mode). This module turns
|
|
6
|
-
* that on: {@link registerBuiltInOAuthProviders} populates the registry with the
|
|
7
|
-
* three framework providers, and runs once as a side effect of importing the
|
|
8
|
-
* module so that the moment the launch layer loads, the OAuth-capable providers
|
|
9
|
-
* are live.
|
|
10
|
-
*
|
|
11
|
-
* On top of registration it offers three things the credential command needs:
|
|
12
|
-
* - {@link listLoginProviders} — the merged sign-in directory, every entry
|
|
13
|
-
* tagged with whether it authenticates by browser sign-in or by api key.
|
|
14
|
-
* - {@link startOAuthLogin} — drives a framework provider's login flow and
|
|
15
|
-
* persists the resulting credentials through the {@link AuthVault}.
|
|
16
|
-
* - {@link openLoginUrl} — a default-browser launcher (per platform) the login
|
|
17
|
-
* callback uses to send the user to the provider's consent page.
|
|
18
|
-
*
|
|
19
|
-
* No state is held here beyond the framework registry itself; the module is a
|
|
20
|
-
* thin, testable seam over the framework API plus the app's vault.
|
|
21
|
-
*/
|
|
22
|
-
import { type OAuthLoginCallbacks } from "indusagi/ai";
|
|
23
|
-
import type { AuthVault } from "./contract";
|
|
24
|
-
/**
|
|
25
|
-
* Register the framework's built-in sign-in providers, idempotently.
|
|
26
|
-
*
|
|
27
|
-
* Each provider is registered only when its id is not already present, so
|
|
28
|
-
* repeated calls (or a re-import) leave the registry unchanged. Returns the ids
|
|
29
|
-
* that are registered after the call, for callers that want to confirm the set.
|
|
30
|
-
*/
|
|
31
|
-
export declare function registerBuiltInOAuthProviders(): string[];
|
|
32
|
-
/**
|
|
33
|
-
* Whether a registered sign-in provider has a *real* OAuth client id wired in
|
|
34
|
-
* (its env var is set to something other than the framework's sentinel), so its
|
|
35
|
-
* browser sign-in can actually complete.
|
|
36
|
-
*
|
|
37
|
-
* Reads the env var live (not at import time) so a deployer that exports the id
|
|
38
|
-
* before launching `/login` is honored. A provider with no known client-id
|
|
39
|
-
* wiring (i.e. not one of the three sentinel-shipped framework providers) is
|
|
40
|
-
* treated as registered — we only gate the providers we know ship a sentinel.
|
|
41
|
-
*
|
|
42
|
-
* @param providerId the registered sign-in provider id
|
|
43
|
-
*/
|
|
44
|
-
export declare function hasRegisteredOAuthClientId(providerId: string): boolean;
|
|
45
|
-
/** How a provider authenticates in the merged sign-in directory. */
|
|
46
|
-
export type AuthKind = "oauth" | "apiKey";
|
|
47
|
-
/** One row of the merged sign-in directory. */
|
|
48
|
-
export interface LoginProvider {
|
|
49
|
-
/** Stable provider id (framework registry id or api-key directory id). */
|
|
50
|
-
readonly id: string;
|
|
51
|
-
/** Human-facing label for menus and prompts. */
|
|
52
|
-
readonly label: string;
|
|
53
|
-
/** Whether this entry signs in via the browser or stores an api key. */
|
|
54
|
-
readonly authKind: AuthKind;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* The merged sign-in directory: every registered browser-sign-in provider plus
|
|
58
|
-
* every api-key provider the app knows, each tagged with its {@link AuthKind}.
|
|
59
|
-
*
|
|
60
|
-
* Browser-sign-in providers lead the list (they are the preferred path for the
|
|
61
|
-
* providers that support them); an api-key provider that shares an id with a
|
|
62
|
-
* registered sign-in provider is still listed, so a user can choose either path
|
|
63
|
-
* for the same underlying account.
|
|
64
|
-
*/
|
|
65
|
-
export declare function listLoginProviders(): LoginProvider[];
|
|
66
|
-
/**
|
|
67
|
-
* Open a sign-in url in the user's default browser.
|
|
68
|
-
*
|
|
69
|
-
* Refuses anything that is not an `http`/`https` url and resolves `false`, so a
|
|
70
|
-
* provider that hands back a non-web redirect never spawns a process. Each
|
|
71
|
-
* strategy is tried in turn; the first one that spawns without an immediate
|
|
72
|
-
* error wins. Resolves `true` if a browser was launched, `false` otherwise.
|
|
73
|
-
*/
|
|
74
|
-
export declare function openLoginUrl(url: string): Promise<boolean>;
|
|
75
|
-
/**
|
|
76
|
-
* The outcome of {@link startOAuthLogin}: the provider and account the
|
|
77
|
-
* credentials were stored under, and whether this account became the default.
|
|
78
|
-
*/
|
|
79
|
-
export interface OAuthLoginResult {
|
|
80
|
-
/** The provider id the sign-in completed for. */
|
|
81
|
-
readonly provider: string;
|
|
82
|
-
/** The account name the credentials were stored under. */
|
|
83
|
-
readonly account: string;
|
|
84
|
-
/** Whether the new account was stored as the provider default. */
|
|
85
|
-
readonly madeDefault: boolean;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Drive a framework provider's browser sign-in and persist the result.
|
|
89
|
-
*
|
|
90
|
-
* Looks the provider up in the (now populated) framework registry, runs its
|
|
91
|
-
* login flow with the supplied {@link OAuthLoginCallbacks}, and writes the
|
|
92
|
-
* returned credentials into the {@link AuthVault} under `account`. The first
|
|
93
|
-
* account stored for a provider becomes its default. Throws when the provider id
|
|
94
|
-
* is not registered or the framework login flow rejects.
|
|
95
|
-
*
|
|
96
|
-
* @param providerId the registered sign-in provider id (e.g. the framework id)
|
|
97
|
-
* @param callbacks the framework login callbacks (url open, prompt, progress)
|
|
98
|
-
* @param vault the credential store the result is persisted through
|
|
99
|
-
* @param account the account name to store under (defaults to `"default"`)
|
|
100
|
-
*/
|
|
101
|
-
export declare function startOAuthLogin(providerId: string, callbacks: OAuthLoginCallbacks, vault: AuthVault, account?: string): Promise<OAuthLoginResult>;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Package command — `runPackageCommand`.
|
|
3
|
-
*
|
|
4
|
-
* The top-level `install` / `remove` / `update` / `list` / `config` surface that
|
|
5
|
-
* manages the extension-package sources the launcher loads. A source is a plain
|
|
6
|
-
* string the loader understands — an `npm:` spec, a `git:` / `https:` repo, or a
|
|
7
|
-
* bare local path — and the configured set lives in the user settings under the
|
|
8
|
-
* `extensionPackages` key, persisted through the {@link PreferenceStore}.
|
|
9
|
-
*
|
|
10
|
-
* The command owns the first positional token only: it returns
|
|
11
|
-
* `{ handled: false }` when that token is not one of the recognised subcommands,
|
|
12
|
-
* so the orchestrator can call this first and fall through to a normal launch on
|
|
13
|
-
* a miss. It never throws for an expected failure — a bad argument is reported as
|
|
14
|
-
* a printed line and a non-zero {@link PackageResult.code}.
|
|
15
|
-
*
|
|
16
|
-
* I/O is injected. The default {@link PackageIo} wraps `process.stdout` /
|
|
17
|
-
* `process.stderr`, but tests drive the whole flow over an in-memory stand-in and
|
|
18
|
-
* a store pinned to a temp directory, so the real home is never touched.
|
|
19
|
-
*/
|
|
20
|
-
import { PreferenceStore } from "../settings";
|
|
21
|
-
/** The five subcommands the package command recognises as the first token. */
|
|
22
|
-
export type PackageCommand = "install" | "remove" | "update" | "list" | "config";
|
|
23
|
-
/** Every {@link PackageCommand}, as a frozen tuple for membership tests. */
|
|
24
|
-
export declare const PACKAGE_COMMANDS: readonly PackageCommand[];
|
|
25
|
-
/**
|
|
26
|
-
* The console seam the package command writes through. Pinned to a normal line
|
|
27
|
-
* and an error line so a test can capture both streams without a real terminal.
|
|
28
|
-
*/
|
|
29
|
-
export interface PackageIo {
|
|
30
|
-
/** Emit one line of human-facing text to the standard stream. */
|
|
31
|
-
print(line: string): void;
|
|
32
|
-
/** Emit one line to the error stream. */
|
|
33
|
-
printError(line: string): void;
|
|
34
|
-
}
|
|
35
|
-
/** The default {@link PackageIo} backed by `process.stdout` / `process.stderr`. */
|
|
36
|
-
export declare function defaultPackageIo(): PackageIo;
|
|
37
|
-
/**
|
|
38
|
-
* Options for {@link runPackageCommand}: the injected settings store the sources
|
|
39
|
-
* persist through and the optional io seam. The store is injected so tests pin it
|
|
40
|
-
* to a temp directory; boot resolves it from the workspace.
|
|
41
|
-
*/
|
|
42
|
-
export interface PackageCommandOptions {
|
|
43
|
-
/** The settings store the package sources read from and write to. */
|
|
44
|
-
readonly store: PreferenceStore;
|
|
45
|
-
/** The console seam; defaults to {@link defaultPackageIo}. */
|
|
46
|
-
readonly io?: PackageIo;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* The outcome of {@link runPackageCommand}.
|
|
50
|
-
*
|
|
51
|
-
* {@link handled} reports whether the first token was a recognised subcommand;
|
|
52
|
-
* when `false`, the caller proceeds to a normal launch unchanged. {@link code}
|
|
53
|
-
* is the process exit code for a handled command — zero on success, non-zero when
|
|
54
|
-
* a required argument was missing or invalid.
|
|
55
|
-
*/
|
|
56
|
-
export interface PackageResult {
|
|
57
|
-
/** Whether this invocation was a package subcommand. */
|
|
58
|
-
readonly handled: boolean;
|
|
59
|
-
/** The subcommand that ran, when {@link handled} is true. */
|
|
60
|
-
readonly command?: PackageCommand;
|
|
61
|
-
/** Process exit code for a handled command (zero on success). */
|
|
62
|
-
readonly code?: number;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Run the package command.
|
|
66
|
-
*
|
|
67
|
-
* Returns `{ handled: false }` immediately when `argv[0]` is not a recognised
|
|
68
|
-
* subcommand, so the orchestrator can call this first and fall through on a miss.
|
|
69
|
-
* Otherwise it performs the subcommand against the injected store and resolves a
|
|
70
|
-
* {@link PackageResult} — never throwing for an expected failure.
|
|
71
|
-
*
|
|
72
|
-
* @param argv the raw token list following the program name
|
|
73
|
-
* @param opts the injected settings store and (optionally) the io seam
|
|
74
|
-
*/
|
|
75
|
-
export declare function runPackageCommand(argv: readonly string[], opts: PackageCommandOptions): Promise<PackageResult>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Package command — unit tests.
|
|
3
|
-
*
|
|
4
|
-
* Everything runs against a {@link PreferenceStore} pinned to a temp directory
|
|
5
|
-
* through {@link PreferenceStore.atPaths}; the real home is never read or
|
|
6
|
-
* written. The io seam is an in-memory capture, so there is no real terminal. The
|
|
7
|
-
* tests pin the public behaviour of {@link runPackageCommand}:
|
|
8
|
-
*
|
|
9
|
-
* 1. A non-package leading token falls through (`handled: false`).
|
|
10
|
-
* 2. `install` persists a source, is idempotent under equivalent spellings, and
|
|
11
|
-
* `list` reads it back; `remove` clears it again.
|
|
12
|
-
* 3. A missing source argument is a non-zero, non-throwing failure.
|
|
13
|
-
* 4. `config` prints the resolved settings paths and contents.
|
|
14
|
-
*/
|
|
15
|
-
export {};
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Launch pickers — `pickResumeTarget` and `browseSettings`.
|
|
3
|
-
*
|
|
4
|
-
* Two thin, injectable selection surfaces:
|
|
5
|
-
*
|
|
6
|
-
* - {@link pickResumeTarget} loads the resumable sessions (current cwd plus
|
|
7
|
-
* every directory), de-duplicates by path, sorts newest-first, and lets the
|
|
8
|
-
* user choose one through the framework React-Ink `StartupSessionPicker`. On a
|
|
9
|
-
* non-interactive stdin it skips the picker and resolves the newest session,
|
|
10
|
-
* so a piped invocation still resumes deterministically.
|
|
11
|
-
*
|
|
12
|
-
* - {@link browseSettings} prints a plain readline listing of the resolved
|
|
13
|
-
* settings and the discovered user resources, then waits for a keypress. No
|
|
14
|
-
* TUI — a flat console dump the user reads and dismisses.
|
|
15
|
-
*
|
|
16
|
-
* Both keep their effectful pieces (the Ink mount, the readline pause, the TTY
|
|
17
|
-
* probe) behind injectable seams so the selection logic is unit-testable without
|
|
18
|
-
* a terminal.
|
|
19
|
-
*/
|
|
20
|
-
import type { ResumeFault, ResumeRef, SessionLoader, SettingsBrowseOptions } from "./contract";
|
|
21
|
-
/**
|
|
22
|
-
* The effectful seams {@link pickResumeTarget} depends on. Injected so a test can
|
|
23
|
-
* report a non-interactive terminal and stub the picker mount.
|
|
24
|
-
*/
|
|
25
|
-
export interface ResumeDeps {
|
|
26
|
-
/** Whether stdin is an interactive terminal (drives the non-TTY fast-path). */
|
|
27
|
-
isInteractive(): boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Mount the picker over the session list and resolve with the chosen session,
|
|
30
|
-
* or `null` when the user dismisses it.
|
|
31
|
-
*/
|
|
32
|
-
mountPicker(sessions: readonly ResumeRef[], totalCount: number): Promise<ResumeRef | null>;
|
|
33
|
-
}
|
|
34
|
-
/** The live {@link ResumeDeps}: a real TTY probe and the Ink picker mount. */
|
|
35
|
-
export declare function defaultResumeDeps(): ResumeDeps;
|
|
36
|
-
/**
|
|
37
|
-
* Merge two session lists into one newest-first list de-duplicated by path.
|
|
38
|
-
*
|
|
39
|
-
* Earlier entries win the path key, then the merged set is sorted by
|
|
40
|
-
* `lastModified` descending. Pure; the picker and the fast-path both consume it.
|
|
41
|
-
*/
|
|
42
|
-
export declare function mergeSessions(current: readonly ResumeRef[], all: readonly ResumeRef[]): ResumeRef[];
|
|
43
|
-
/**
|
|
44
|
-
* The outcome of {@link pickResumeTarget}: the chosen session path, or `null`
|
|
45
|
-
* when there was nothing to resume or the user dismissed the picker. A typed
|
|
46
|
-
* {@link ResumeFault} is returned (never thrown) when the load or mount failed.
|
|
47
|
-
*/
|
|
48
|
-
export interface ResumeOutcome {
|
|
49
|
-
/** The selected session file path, or `null` for none. */
|
|
50
|
-
readonly path: string | null;
|
|
51
|
-
/** A typed failure, present only when the resume flow could not run. */
|
|
52
|
-
readonly fault?: ResumeFault;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Choose a session to resume.
|
|
56
|
-
*
|
|
57
|
-
* Loads the current-directory and all-directory session lists, merges them
|
|
58
|
-
* (de-dupe by path, newest first), and either mounts the React-Ink picker or —
|
|
59
|
-
* on a non-interactive stdin — resolves the newest session directly. An empty
|
|
60
|
-
* merged list resolves to `{ path: null }`.
|
|
61
|
-
*
|
|
62
|
-
* @param loadCurrent loader for sessions started in the active cwd
|
|
63
|
-
* @param loadAll loader for sessions across every directory
|
|
64
|
-
* @param deps injectable TTY probe and picker mount (defaults to live)
|
|
65
|
-
*/
|
|
66
|
-
export declare function pickResumeTarget(loadCurrent: SessionLoader, loadAll: SessionLoader, deps?: ResumeDeps): Promise<ResumeOutcome>;
|
|
67
|
-
/**
|
|
68
|
-
* The effectful seams {@link browseSettings} depends on: a line sink and a pause
|
|
69
|
-
* that waits for the user to press a key. Injected so a test captures the listing
|
|
70
|
-
* and resolves the pause immediately.
|
|
71
|
-
*/
|
|
72
|
-
export interface SettingsBrowseIo {
|
|
73
|
-
/** Emit one line of the listing. */
|
|
74
|
-
print(line: string): void;
|
|
75
|
-
/** Wait for the user to dismiss the listing (e.g. press Enter). */
|
|
76
|
-
pause(prompt: string): Promise<void>;
|
|
77
|
-
}
|
|
78
|
-
/** The live {@link SettingsBrowseIo}: stdout plus a readline pause. */
|
|
79
|
-
export declare function defaultSettingsBrowseIo(): SettingsBrowseIo;
|
|
80
|
-
/**
|
|
81
|
-
* Build the entire settings listing as an array of lines. Pure — it consumes the
|
|
82
|
-
* resolved settings, the active cwd, the profile directory, and the grouped
|
|
83
|
-
* resource paths, and produces the flat dump {@link browseSettings} prints. Kept
|
|
84
|
-
* separate so a test can assert the content without an io seam.
|
|
85
|
-
*/
|
|
86
|
-
export declare function renderSettingsListing(opts: SettingsBrowseOptions): string[];
|
|
87
|
-
/**
|
|
88
|
-
* Print the settings / resource listing and wait for the user to dismiss it.
|
|
89
|
-
*
|
|
90
|
-
* A plain console dump — no TUI. It renders the resolved settings summary and the
|
|
91
|
-
* discovered resources grouped by category, then pauses for a keypress so the
|
|
92
|
-
* listing stays on screen.
|
|
93
|
-
*
|
|
94
|
-
* @param opts the resolved settings, resource paths, cwd, and profile directory
|
|
95
|
-
* @param io the injectable line sink and pause (defaults to stdout + readline)
|
|
96
|
-
*/
|
|
97
|
-
export declare function browseSettings(opts: SettingsBrowseOptions, io?: SettingsBrowseIo): Promise<void>;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared exchange driver — the transport-wiring half every bridge reuses.
|
|
3
|
-
*
|
|
4
|
-
* A bridge is meant to be *only* a per-dialect parser. Two concerns are common
|
|
5
|
-
* to all three shipped bridges and are factored here so a bridge never repeats
|
|
6
|
-
* them:
|
|
7
|
-
*
|
|
8
|
-
* 1. The lifecycle wiring: subscribe to the {@link ChildTransport}, forward
|
|
9
|
-
* each inbound {@link ChildMessage} to the bridge's parser, settle the sink
|
|
10
|
-
* on a terminal parser result, honour the caller's {@link AbortSignal}, and
|
|
11
|
-
* always dispose the subscription + transport on the way out.
|
|
12
|
-
* 2. The seed: deriving the {@link BridgeMessageSeed} the sink stamps onto the
|
|
13
|
-
* accumulated message from the bound {@link Model}.
|
|
14
|
-
*
|
|
15
|
-
* A bridge supplies a {@link ChildParser} (pure: child payload -> parser result)
|
|
16
|
-
* and an opening {@link ChildRequest}; {@link driveExchange} does the rest and
|
|
17
|
-
* returns the populated {@link AssistantMessageEventStream}.
|
|
18
|
-
*
|
|
19
|
-
* Crucially this module touches the transport only through the injected
|
|
20
|
-
* interface — no `child_process`, no `spawn`. A test hands a fake transport and
|
|
21
|
-
* drives the parser end-to-end with zero real binaries.
|
|
22
|
-
*/
|
|
23
|
-
import type { AssistantMessageEventStream, BridgeEventSink, ChildMessage, ChildRequest, ChildTransport, ExchangeOptions, Model, Api } from "../contract";
|
|
24
|
-
import { type BridgeMessageSeed } from "../sink";
|
|
25
|
-
/**
|
|
26
|
-
* The outcome a parser reports for one inbound child payload. A parser maps a
|
|
27
|
-
* single {@link ChildMessage} payload to the normalized events it produced and
|
|
28
|
-
* whether that payload terminated the exchange.
|
|
29
|
-
*
|
|
30
|
-
* - `continue` — zero or more events were emitted; the stream stays open.
|
|
31
|
-
* - `done` — the exchange settled (the parser already emitted the
|
|
32
|
-
* `finish` / `failed` event, or the driver should finish with
|
|
33
|
-
* the default reason). No further payloads are processed.
|
|
34
|
-
*/
|
|
35
|
-
export type ParseStep = {
|
|
36
|
-
readonly status: "continue";
|
|
37
|
-
} | {
|
|
38
|
-
readonly status: "done";
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* A per-dialect parser: interpret one inbound child payload, drive the sink with
|
|
42
|
-
* whatever normalized events it yields, and report whether the exchange is over.
|
|
43
|
-
*
|
|
44
|
-
* The parser owns *interpretation* only; it never touches the framework stream
|
|
45
|
-
* directly — it calls sink methods (`text` / `thinking` / `toolCall` / `emit` /
|
|
46
|
-
* `finishSuccess` / `finishError`). Returning `{ status: "done" }` tells the
|
|
47
|
-
* driver to stop and (if the sink is not already settled) finish successfully.
|
|
48
|
-
*/
|
|
49
|
-
export type ChildParser = (message: ChildMessage, sink: BridgeEventSink) => ParseStep;
|
|
50
|
-
/** Derive the message seed the sink stamps onto its accumulated message. */
|
|
51
|
-
export declare function seedFromModel(model: Model<Api>): BridgeMessageSeed;
|
|
52
|
-
/**
|
|
53
|
-
* Drive a full exchange over an injected transport.
|
|
54
|
-
*
|
|
55
|
-
* Returns the sink's {@link AssistantMessageEventStream} synchronously; the
|
|
56
|
-
* stream is populated asynchronously as the child emits. The driver:
|
|
57
|
-
* - subscribes the parser to inbound messages;
|
|
58
|
-
* - sends the opening request;
|
|
59
|
-
* - settles + tears down on a terminal parse step, transport closure, abort,
|
|
60
|
-
* or thrown parser error.
|
|
61
|
-
*
|
|
62
|
-
* @param model the bound model (seeds the sink identity)
|
|
63
|
-
* @param opts per-exchange options (only `signal` is consulted here)
|
|
64
|
-
* @param transport the injected child boundary
|
|
65
|
-
* @param request the opening request to send once subscribed
|
|
66
|
-
* @param parse the per-dialect parser
|
|
67
|
-
*/
|
|
68
|
-
export declare function driveExchange(model: Model<Api>, opts: ExchangeOptions, transport: ChildTransport, request: ChildRequest, parse: ChildParser): AssistantMessageEventStream;
|
|
69
|
-
/** Best-effort single-line message for an unknown thrown value. */
|
|
70
|
-
export declare function errorText(cause: unknown): string;
|
|
71
|
-
/** Narrow an opaque payload to a string-keyed record (or `undefined`). */
|
|
72
|
-
export declare function asRecord(value: unknown): Record<string, unknown> | undefined;
|
|
73
|
-
/** Read a string field off a record, or `undefined` when absent/non-string. */
|
|
74
|
-
export declare function strField(record: Record<string, unknown>, key: string): string | undefined;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Built-in external-runtime catalog — the shipped {@link ExternalRuntimeSpec}
|
|
3
|
-
* entries and the helper that *annotates* a model with one.
|
|
4
|
-
*
|
|
5
|
-
* The model catalog (Phase 2, `src/conductor/catalog`) owns the {@link Model}
|
|
6
|
-
* list; this layer never re-catalogues. Instead it carries a small table of the
|
|
7
|
-
* three runtimes this build ships and a single sanctioned way to stamp a runtime
|
|
8
|
-
* onto a model: rewrite the model's `baseUrl` to the synthetic
|
|
9
|
-
* `bridge:<adapter>` endpoint (so a card has a stable, non-HTTP address) and
|
|
10
|
-
* return the runtime annotation alongside it.
|
|
11
|
-
*
|
|
12
|
-
* Why a `baseUrl` rewrite rather than a new field on the card: the catalog card
|
|
13
|
-
* shape is frozen by Phase 2 and the framework {@link Model} has a fixed shape;
|
|
14
|
-
* the `bridge:<adapter>` convention lets a routing consumer recognize a
|
|
15
|
-
* runtime-backed model purely from its address (`baseUrl.startsWith(scheme)`),
|
|
16
|
-
* with the full spec resolved from this table — no schema change to the catalog.
|
|
17
|
-
*/
|
|
18
|
-
import type { CatalogCard } from "../../conductor/catalog";
|
|
19
|
-
import { type Api, type ExternalRuntimeSpec, type Model, type RuntimeAdapterId } from "../contract";
|
|
20
|
-
/**
|
|
21
|
-
* The three runtimes this build ships, keyed by adapter id.
|
|
22
|
-
*
|
|
23
|
-
* Each is `external-cli` (the spawned child owns its own login), so a model
|
|
24
|
-
* bound to one is offered as available with an empty credential vault. The
|
|
25
|
-
* `binaryPath` names the default executable the broker launches when a model's
|
|
26
|
-
* spec does not override it; `args` are extra flags prepended ahead of the
|
|
27
|
-
* bridge's own protocol flags.
|
|
28
|
-
*/
|
|
29
|
-
export declare const BUILTIN_RUNTIME_SPECS: Readonly<Record<RuntimeAdapterId, ExternalRuntimeSpec>>;
|
|
30
|
-
/** The shipped adapter ids, in catalog order. */
|
|
31
|
-
export declare const BUILTIN_ADAPTERS: readonly RuntimeAdapterId[];
|
|
32
|
-
/** Look up a shipped {@link ExternalRuntimeSpec} by adapter id (`undefined` if none). */
|
|
33
|
-
export declare function builtinRuntimeSpec(adapter: RuntimeAdapterId): ExternalRuntimeSpec | undefined;
|
|
34
|
-
/**
|
|
35
|
-
* A model annotated with its external runtime: the rewritten framework model
|
|
36
|
-
* (its `baseUrl` now the `bridge:<adapter>` synthetic endpoint) paired with the
|
|
37
|
-
* resolved {@link ExternalRuntimeSpec}. This is the value a routing consumer
|
|
38
|
-
* stores in its side table keyed by canonical id.
|
|
39
|
-
*/
|
|
40
|
-
export interface RuntimeAnnotatedModel {
|
|
41
|
-
/** The framework model with its `baseUrl` rewritten to the synthetic endpoint. */
|
|
42
|
-
readonly model: Model<Api>;
|
|
43
|
-
/** The runtime spec the {@link RuntimeBroker} drives this model through. */
|
|
44
|
-
readonly spec: ExternalRuntimeSpec;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Rewrite a framework {@link Model}'s `baseUrl` to the synthetic
|
|
48
|
-
* `bridge:<adapter>` endpoint for `spec.adapter`. Returns a fresh model; the
|
|
49
|
-
* input is never mutated.
|
|
50
|
-
*/
|
|
51
|
-
export declare function withRuntimeEndpoint(model: Model<Api>, spec: ExternalRuntimeSpec): Model<Api>;
|
|
52
|
-
/**
|
|
53
|
-
* Annotate one {@link CatalogCard} with a runtime spec.
|
|
54
|
-
*
|
|
55
|
-
* Resolves the spec from `spec` when given explicitly, else from the shipped
|
|
56
|
-
* table by `adapter`. Returns the card's framework model rewritten to the
|
|
57
|
-
* synthetic endpoint plus the resolved spec, or `undefined` when no spec is
|
|
58
|
-
* known for `adapter` (so a caller can skip non-runtime adapters).
|
|
59
|
-
*
|
|
60
|
-
* @param card the catalog card whose model to annotate
|
|
61
|
-
* @param adapter the runtime adapter to bind the model to
|
|
62
|
-
* @param spec an explicit spec override; defaults to the shipped one
|
|
63
|
-
*/
|
|
64
|
-
export declare function annotateCard(card: CatalogCard, adapter: RuntimeAdapterId, spec?: ExternalRuntimeSpec): RuntimeAnnotatedModel | undefined;
|
|
65
|
-
/**
|
|
66
|
-
* Decode the runtime annotation off a framework {@link Model}, the inverse of
|
|
67
|
-
* {@link withRuntimeEndpoint}. Returns the shipped {@link ExternalRuntimeSpec}
|
|
68
|
-
* for the adapter named in a `bridge:<adapter>` `baseUrl`, or `undefined` when
|
|
69
|
-
* the model is a plain HTTP-provider model (its `baseUrl` is a real URL) or the
|
|
70
|
-
* named adapter is not a shipped runtime.
|
|
71
|
-
*
|
|
72
|
-
* This is the lookup a {@link RuntimeBroker} uses to recognize a runtime-backed
|
|
73
|
-
* model purely from its address.
|
|
74
|
-
*
|
|
75
|
-
* @param model the model whose `baseUrl` to inspect
|
|
76
|
-
*/
|
|
77
|
-
export declare function specFromModel(model: Model<Api>): ExternalRuntimeSpec | undefined;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `claude-cli` bridge — drives an Anthropic-flavoured CLI that emits
|
|
3
|
-
* line-delimited stream-json content blocks.
|
|
4
|
-
*
|
|
5
|
-
* Wire dialect (each inbound {@link ChildMessage.payload} is one parsed JSON
|
|
6
|
-
* line of the CLI's NDJSON stdout):
|
|
7
|
-
* - `{ type: "system", subtype: "init", session_id }` — the CLI announces the
|
|
8
|
-
* session id it allocated; surfaced as a `resume` event so the broker can
|
|
9
|
-
* persist it and reattach the same CLI session later.
|
|
10
|
-
* - `{ type: "content_block_start", content_block: { type } }` — a block opens;
|
|
11
|
-
* a `tool_use` block carries `{ id, name, input }` which becomes a fully
|
|
12
|
-
* formed tool call immediately (the CLI batches the input).
|
|
13
|
-
* - `{ type: "content_block_delta", delta: { type, text | thinking } }` — a
|
|
14
|
-
* `text_delta` / `thinking_delta` chunk; mapped to a `text` / `thinking`
|
|
15
|
-
* normalized event. `input_json_delta` chunks (streamed tool arguments) are
|
|
16
|
-
* ignored here because the bridge emits the tool call from the terminal
|
|
17
|
-
* `content_block_stop` snapshot.
|
|
18
|
-
* - `{ type: "message_delta", delta: { stop_reason } }` — carries the final
|
|
19
|
-
* stop reason, recorded for the eventual `finish`.
|
|
20
|
-
* - `{ type: "message_stop" }` / `{ type: "result" }` — the turn is over;
|
|
21
|
-
* finish with the recorded reason.
|
|
22
|
-
* - `{ type: "error", error: { message } }` — a runtime fault.
|
|
23
|
-
*
|
|
24
|
-
* The opening request is the user turn forwarded as the CLI's prompt body; the
|
|
25
|
-
* spec's binary/args/env are the {@link RuntimeBroker}'s concern when it builds
|
|
26
|
-
* the transport, so this bridge only formats the protocol body.
|
|
27
|
-
*
|
|
28
|
-
* The child process is reached exclusively through the injected
|
|
29
|
-
* {@link ChildTransport}; no `claude` binary is spawned here.
|
|
30
|
-
*/
|
|
31
|
-
import type { RuntimeBridge } from "../contract";
|
|
32
|
-
/**
|
|
33
|
-
* The `claude-cli` {@link RuntimeBridge}. Stateless on the contract surface: it
|
|
34
|
-
* parses the injected transport's stream-json into the sink and returns the
|
|
35
|
-
* framework push stream.
|
|
36
|
-
*/
|
|
37
|
-
export declare const claudeCliBridge: RuntimeBridge;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `codex-cli` bridge — drives an OpenAI-flavoured CLI emitting `--json`
|
|
3
|
-
* turn/item events.
|
|
4
|
-
*
|
|
5
|
-
* Wire dialect (each inbound {@link ChildMessage.payload} is one parsed `--json`
|
|
6
|
-
* event object):
|
|
7
|
-
* - `{ type: "thread.started", thread_id }` — the CLI opened a thread;
|
|
8
|
-
* surfaced as a `resume` event so the broker can persist the thread id and
|
|
9
|
-
* continue it on a later exchange.
|
|
10
|
-
* - `{ type: "response.output_text.delta", delta }` — a chunk of answer text.
|
|
11
|
-
* - `{ type: "response.reasoning_text.delta" | "response.reasoning.delta",
|
|
12
|
-
* delta }` — a chunk of reasoning text.
|
|
13
|
-
* - `{ type: "response.output_item.done", item }` /
|
|
14
|
-
* `{ type: "item.completed", item }` — a completed item; a
|
|
15
|
-
* `function_call` / `tool_call` item becomes a fully-formed tool call (its
|
|
16
|
-
* `arguments` string is parsed into an object).
|
|
17
|
-
* - `{ type: "turn.completed" | "response.completed" }` — the turn settled;
|
|
18
|
-
* finish (tool-bearing turns settle as `toolUse`, else `stop`).
|
|
19
|
-
* - `{ type: "error" | "turn.failed", error | message }` — a runtime fault.
|
|
20
|
-
*
|
|
21
|
-
* Item-level `*.delta` text is preferred; if a CLI variant only emits whole
|
|
22
|
-
* items, the completed-item handler still surfaces the text. The injected
|
|
23
|
-
* {@link ChildTransport} carries the events — no `codex` binary is spawned here.
|
|
24
|
-
*/
|
|
25
|
-
import type { RuntimeBridge } from "../contract";
|
|
26
|
-
/** The `codex-cli` {@link RuntimeBridge}. */
|
|
27
|
-
export declare const codexCliBridge: RuntimeBridge;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bridges subsystem — public barrel.
|
|
3
|
-
*
|
|
4
|
-
* Bundles the three shipped external-runtime {@link RuntimeBridge}s — the
|
|
5
|
-
* Anthropic-flavoured `claude-cli`, the OpenAI-flavoured `codex-cli`, and the
|
|
6
|
-
* peer JSON-RPC `indusagi-cli` — plus the built-in runtime spec catalog and the
|
|
7
|
-
* model-annotation helpers. Consumers register the bridges with a
|
|
8
|
-
* {@link RuntimeBroker} and annotate catalog cards via this barrel rather than
|
|
9
|
-
* reaching into the individual modules.
|
|
10
|
-
*/
|
|
11
|
-
export { claudeCliBridge } from "./claude-cli";
|
|
12
|
-
export { codexCliBridge } from "./codex-cli";
|
|
13
|
-
export { indusagiCliBridge, makeIndusagiCliBridge } from "./indusagi-cli";
|
|
14
|
-
export { BUILTIN_RUNTIME_SPECS, BUILTIN_ADAPTERS, builtinRuntimeSpec, annotateCard, withRuntimeEndpoint, specFromModel, type RuntimeAnnotatedModel, } from "./builtins";
|
|
15
|
-
export { driveExchange, seedFromModel, asRecord, strField, errorText, type ChildParser, type ParseStep, } from "./_drive";
|