indusagi-coding-agent 0.2.4 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/LICENSE +661 -0
- package/README.md +99 -1
- package/dist/entry.js +13551 -23107
- package/dist/guardrails.js +822 -8248
- package/dist/index.js +12547 -22190
- package/package.json +8 -7
- package/dist/types/addons/addons.test.d.ts +0 -21
- package/dist/types/addons/contract.d.ts +0 -640
- package/dist/types/addons/dispatch/event-dispatcher.d.ts +0 -140
- package/dist/types/addons/dispatch/index.d.ts +0 -23
- package/dist/types/addons/dispatch/tool-interceptor.d.ts +0 -128
- package/dist/types/addons/host.d.ts +0 -246
- package/dist/types/addons/index.d.ts +0 -51
- package/dist/types/addons/manifest.d.ts +0 -56
- package/dist/types/addons/sandbox.d.ts +0 -103
- package/dist/types/addons/surface.d.ts +0 -42
- package/dist/types/boot/auth-vault.d.ts +0 -29
- package/dist/types/boot/boot.d.ts +0 -26
- package/dist/types/boot/boot.test.d.ts +0 -15
- package/dist/types/boot/contract.d.ts +0 -236
- package/dist/types/boot/heap.d.ts +0 -31
- package/dist/types/boot/index.d.ts +0 -20
- package/dist/types/boot/invocation.d.ts +0 -40
- package/dist/types/boot/invocation.test.d.ts +0 -8
- package/dist/types/boot/runners/addon-wiring.d.ts +0 -103
- package/dist/types/boot/runners/addon-wiring.test.d.ts +0 -19
- package/dist/types/boot/runners/checkpoint.d.ts +0 -133
- package/dist/types/boot/runners/checkpoint.test.d.ts +0 -12
- package/dist/types/boot/runners/delegate-runner.d.ts +0 -109
- package/dist/types/boot/runners/delegate-runner.test.d.ts +0 -13
- package/dist/types/boot/runners/index.d.ts +0 -13
- package/dist/types/boot/runners/link-runner.d.ts +0 -20
- package/dist/types/boot/runners/memdir.d.ts +0 -103
- package/dist/types/boot/runners/memdir.test.d.ts +0 -12
- package/dist/types/boot/runners/oneshot-runner.d.ts +0 -19
- package/dist/types/boot/runners/read-state.d.ts +0 -82
- package/dist/types/boot/runners/read-state.test.d.ts +0 -10
- package/dist/types/boot/runners/registry.d.ts +0 -30
- package/dist/types/boot/runners/repl-runner.d.ts +0 -19
- package/dist/types/boot/runners/server-mode.d.ts +0 -71
- package/dist/types/boot/runners/session-persist.test.d.ts +0 -10
- package/dist/types/boot/runners/session.d.ts +0 -88
- package/dist/types/boot/runners/session.test.d.ts +0 -15
- package/dist/types/boot/server-token.d.ts +0 -97
- package/dist/types/boot/stages.d.ts +0 -92
- package/dist/types/boot/upgrade/apply.d.ts +0 -45
- package/dist/types/boot/upgrade/index.d.ts +0 -13
- package/dist/types/boot/upgrade/upgrades.d.ts +0 -126
- package/dist/types/briefing/briefing.test.d.ts +0 -15
- package/dist/types/briefing/compose.d.ts +0 -37
- package/dist/types/briefing/context-docs.d.ts +0 -38
- package/dist/types/briefing/context-docs.test.d.ts +0 -18
- package/dist/types/briefing/contract.d.ts +0 -686
- package/dist/types/briefing/index.d.ts +0 -29
- package/dist/types/briefing/macros.d.ts +0 -206
- package/dist/types/briefing/skills.d.ts +0 -67
- package/dist/types/capability-deck/bridge-ledger/index.d.ts +0 -25
- package/dist/types/capability-deck/bridge-ledger/key.d.ts +0 -65
- package/dist/types/capability-deck/bridge-ledger/ledger.d.ts +0 -129
- package/dist/types/capability-deck/bridge-ledger/network.d.ts +0 -115
- package/dist/types/capability-deck/builtin-bridge.d.ts +0 -114
- package/dist/types/capability-deck/capability-deck.test.d.ts +0 -18
- package/dist/types/capability-deck/cards/bg-process-card.d.ts +0 -99
- package/dist/types/capability-deck/cards/index.d.ts +0 -37
- package/dist/types/capability-deck/cards/memory-card.d.ts +0 -68
- package/dist/types/capability-deck/cards/plan-file.d.ts +0 -56
- package/dist/types/capability-deck/cards/plan-tools.d.ts +0 -97
- package/dist/types/capability-deck/cards/plan-tools.test.d.ts +0 -9
- package/dist/types/capability-deck/cards/saas-card.d.ts +0 -78
- package/dist/types/capability-deck/cards/task-card.d.ts +0 -106
- package/dist/types/capability-deck/cards/todo-card.d.ts +0 -78
- package/dist/types/capability-deck/cards/workflow-card.d.ts +0 -55
- package/dist/types/capability-deck/cards/workflow-card.test.d.ts +0 -12
- package/dist/types/capability-deck/checkpoint.int.test.d.ts +0 -25
- package/dist/types/capability-deck/contract.d.ts +0 -318
- package/dist/types/capability-deck/index.d.ts +0 -46
- package/dist/types/capability-deck/manifest.d.ts +0 -60
- package/dist/types/capability-deck/provision.d.ts +0 -76
- package/dist/types/capability-deck/read-edit-gate.int.test.d.ts +0 -21
- package/dist/types/channels/channels.test.d.ts +0 -15
- package/dist/types/channels/contract.d.ts +0 -489
- package/dist/types/channels/framer.d.ts +0 -49
- package/dist/types/channels/index.d.ts +0 -24
- package/dist/types/channels/link/dialog.d.ts +0 -138
- package/dist/types/channels/link/driver.d.ts +0 -81
- package/dist/types/channels/link/index.d.ts +0 -13
- package/dist/types/channels/link/server.d.ts +0 -70
- package/dist/types/channels/oneshot.d.ts +0 -37
- package/dist/types/channels/ops.d.ts +0 -89
- package/dist/types/channels/session-ops.d.ts +0 -80
- package/dist/types/conductor/bash-guard.d.ts +0 -106
- package/dist/types/conductor/bash-guard.test.d.ts +0 -17
- package/dist/types/conductor/catalog/catalog.d.ts +0 -87
- package/dist/types/conductor/catalog/index.d.ts +0 -14
- package/dist/types/conductor/catalog/matcher.d.ts +0 -47
- package/dist/types/conductor/conductor.d.ts +0 -213
- package/dist/types/conductor/conductor.test.d.ts +0 -10
- package/dist/types/conductor/contract.d.ts +0 -838
- package/dist/types/conductor/diagnostics.d.ts +0 -183
- package/dist/types/conductor/diagnostics.test.d.ts +0 -10
- package/dist/types/conductor/index.d.ts +0 -26
- package/dist/types/conductor/permission-gate.integration.test.d.ts +0 -22
- package/dist/types/conductor/permission-wiring.test.d.ts +0 -14
- package/dist/types/conductor/permissions.d.ts +0 -287
- package/dist/types/conductor/permissions.test.d.ts +0 -12
- package/dist/types/conductor/plan-mode.integration.test.d.ts +0 -23
- package/dist/types/conductor/post-edit-diagnostics.test.d.ts +0 -18
- package/dist/types/conductor/quota-error.d.ts +0 -35
- package/dist/types/conductor/signal-hub/hub.d.ts +0 -83
- package/dist/types/conductor/signal-hub/index.d.ts +0 -19
- package/dist/types/conductor/signal-hub/translate.d.ts +0 -77
- package/dist/types/conductor/skill-parse/index.d.ts +0 -10
- package/dist/types/conductor/skill-parse/parse.d.ts +0 -67
- package/dist/types/conductor/submit.test.d.ts +0 -28
- package/dist/types/conductor/transcript-store/index.d.ts +0 -16
- package/dist/types/conductor/transcript-store/serialize.d.ts +0 -106
- package/dist/types/conductor/transcript-store/serialize.test.d.ts +0 -10
- package/dist/types/conductor/transcript-store/store.d.ts +0 -188
- package/dist/types/console/auth-status.d.ts +0 -28
- package/dist/types/console/components/AgentsView.d.ts +0 -41
- package/dist/types/console/components/BackgroundAgents.d.ts +0 -63
- package/dist/types/console/components/BackgroundAgents.test.d.ts +0 -8
- package/dist/types/console/components/Banner.d.ts +0 -110
- package/dist/types/console/components/Composer.d.ts +0 -37
- package/dist/types/console/components/StatusBar.d.ts +0 -42
- package/dist/types/console/components/TerminalConsole.d.ts +0 -27
- package/dist/types/console/components/WorkingIndicator.d.ts +0 -44
- package/dist/types/console/components/WorkingIndicator.test.d.ts +0 -9
- package/dist/types/console/components/banner-sweep.d.ts +0 -55
- package/dist/types/console/components/banner.test.d.ts +0 -9
- package/dist/types/console/components/welcome.d.ts +0 -115
- package/dist/types/console/components/welcome.test.d.ts +0 -9
- package/dist/types/console/console.test.d.ts +0 -19
- package/dist/types/console/contract.d.ts +0 -611
- package/dist/types/console/index.d.ts +0 -34
- package/dist/types/console/input/complete.d.ts +0 -120
- package/dist/types/console/input/dir-reader.d.ts +0 -28
- package/dist/types/console/input/index.d.ts +0 -24
- package/dist/types/console/input/input.test.d.ts +0 -14
- package/dist/types/console/input/keymap.d.ts +0 -193
- package/dist/types/console/input/paste.d.ts +0 -183
- package/dist/types/console/mount.d.ts +0 -53
- package/dist/types/console/overlays/approval-queue.d.ts +0 -88
- package/dist/types/console/overlays/approval.d.ts +0 -104
- package/dist/types/console/overlays/approval.test.d.ts +0 -17
- package/dist/types/console/overlays/auth.d.ts +0 -31
- package/dist/types/console/overlays/boards.d.ts +0 -55
- package/dist/types/console/overlays/host.d.ts +0 -45
- package/dist/types/console/overlays/index.d.ts +0 -15
- package/dist/types/console/overlays/pickers.d.ts +0 -37
- package/dist/types/console/overlays/sessions.d.ts +0 -29
- package/dist/types/console/reducer.d.ts +0 -51
- package/dist/types/console/slash/builtins.d.ts +0 -33
- package/dist/types/console/slash/commands/dynamic.d.ts +0 -57
- package/dist/types/console/slash/commands/dynamic.test.d.ts +0 -9
- package/dist/types/console/slash/commands/integrations.d.ts +0 -28
- package/dist/types/console/slash/commands/integrations.test.d.ts +0 -18
- package/dist/types/console/slash/commands/shared.d.ts +0 -72
- package/dist/types/console/slash/commands/transcript.d.ts +0 -24
- package/dist/types/console/slash/commands/transcript.test.d.ts +0 -10
- package/dist/types/console/slash/commands/workbench.d.ts +0 -21
- package/dist/types/console/slash/commands/workbench.test.d.ts +0 -10
- package/dist/types/console/slash/index.d.ts +0 -34
- package/dist/types/console/slash/registry.d.ts +0 -90
- package/dist/types/console/slash/resolve.d.ts +0 -109
- package/dist/types/console/slash/slash.test.d.ts +0 -18
- package/dist/types/console/startup.d.ts +0 -119
- package/dist/types/console/theme/adapter.d.ts +0 -79
- package/dist/types/console/theme/index.d.ts +0 -18
- package/dist/types/console/theme/palette.d.ts +0 -77
- package/dist/types/console/theme/resolve.d.ts +0 -45
- package/dist/types/console/theme/theme.test.d.ts +0 -16
- package/dist/types/console/theme/tokens.d.ts +0 -62
- package/dist/types/entry.d.ts +0 -17
- package/dist/types/guardrails.d.ts +0 -33
- package/dist/types/index.d.ts +0 -24
- package/dist/types/insight/channel.d.ts +0 -45
- package/dist/types/insight/contract.d.ts +0 -411
- package/dist/types/insight/index.d.ts +0 -26
- package/dist/types/insight/insight.test.d.ts +0 -17
- package/dist/types/insight/recorder.d.ts +0 -63
- package/dist/types/insight/redaction.d.ts +0 -44
- package/dist/types/insight/replay.d.ts +0 -77
- package/dist/types/insight/sampling.d.ts +0 -84
- package/dist/types/insight/serialize.d.ts +0 -54
- package/dist/types/insight/sinks/console.d.ts +0 -36
- package/dist/types/insight/sinks/file.d.ts +0 -37
- package/dist/types/insight/sinks/index.d.ts +0 -16
- package/dist/types/insight/sinks/stream.d.ts +0 -53
- package/dist/types/kit/clipboard-image.d.ts +0 -40
- package/dist/types/kit/external-editor.d.ts +0 -35
- package/dist/types/kit/image.d.ts +0 -102
- package/dist/types/kit/index.d.ts +0 -29
- package/dist/types/kit/kit.test.d.ts +0 -13
- package/dist/types/kit/shell.d.ts +0 -50
- package/dist/types/kit/tool-fetch.d.ts +0 -165
- package/dist/types/launch/catalog.d.ts +0 -51
- package/dist/types/launch/contract.d.ts +0 -387
- package/dist/types/launch/credentials.d.ts +0 -112
- package/dist/types/launch/index.d.ts +0 -28
- package/dist/types/launch/invocation/attachments.d.ts +0 -72
- package/dist/types/launch/invocation/flags.d.ts +0 -59
- package/dist/types/launch/invocation/index.d.ts +0 -23
- package/dist/types/launch/invocation/read.d.ts +0 -52
- package/dist/types/launch/invocation/usage.d.ts +0 -25
- package/dist/types/launch/launch.test.d.ts +0 -20
- package/dist/types/launch/login.d.ts +0 -68
- package/dist/types/launch/oauth.d.ts +0 -101
- package/dist/types/launch/oauth.test.d.ts +0 -20
- package/dist/types/launch/packages.d.ts +0 -75
- package/dist/types/launch/packages.test.d.ts +0 -15
- package/dist/types/launch/pickers.d.ts +0 -97
- package/dist/types/runtime-bridge/bridges/_drive.d.ts +0 -74
- package/dist/types/runtime-bridge/bridges/builtins.d.ts +0 -77
- package/dist/types/runtime-bridge/bridges/claude-cli.d.ts +0 -37
- package/dist/types/runtime-bridge/bridges/codex-cli.d.ts +0 -27
- package/dist/types/runtime-bridge/bridges/index.d.ts +0 -15
- package/dist/types/runtime-bridge/bridges/indusagi-cli.d.ts +0 -36
- package/dist/types/runtime-bridge/broker.d.ts +0 -182
- package/dist/types/runtime-bridge/contract.d.ts +0 -436
- package/dist/types/runtime-bridge/index.d.ts +0 -21
- package/dist/types/runtime-bridge/runtime-bridge.test.d.ts +0 -17
- package/dist/types/runtime-bridge/sink.d.ts +0 -59
- package/dist/types/sessions/contract.d.ts +0 -79
- package/dist/types/sessions/index.d.ts +0 -11
- package/dist/types/sessions/library.d.ts +0 -95
- package/dist/types/sessions/sessions.test.d.ts +0 -11
- package/dist/types/settings/contract.d.ts +0 -175
- package/dist/types/settings/index.d.ts +0 -13
- package/dist/types/settings/manager.d.ts +0 -109
- package/dist/types/settings/settings.test.d.ts +0 -16
- package/dist/types/transcript-export/index.d.ts +0 -20
- package/dist/types/transcript-export/publish.d.ts +0 -81
- package/dist/types/transcript-export/sgr.d.ts +0 -90
- package/dist/types/transcript-export/template.d.ts +0 -64
- package/dist/types/transcript-export/theme-bridge.d.ts +0 -99
- package/dist/types/transcript-export/transcript-export.test.d.ts +0 -16
- package/dist/types/window-budget/budget/estimate.d.ts +0 -47
- package/dist/types/window-budget/budget/gate.d.ts +0 -37
- package/dist/types/window-budget/budget/index.d.ts +0 -14
- package/dist/types/window-budget/budget/slice.d.ts +0 -38
- package/dist/types/window-budget/condenser.d.ts +0 -73
- package/dist/types/window-budget/contract.d.ts +0 -182
- package/dist/types/window-budget/index.d.ts +0 -17
- package/dist/types/window-budget/microcompact.d.ts +0 -68
- package/dist/types/window-budget/microcompact.test.d.ts +0 -16
- package/dist/types/window-budget/rehydrate.d.ts +0 -56
- package/dist/types/window-budget/summarize/condense.d.ts +0 -76
- package/dist/types/window-budget/summarize/index.d.ts +0 -12
- package/dist/types/window-budget/summarize/prompt.d.ts +0 -56
- package/dist/types/window-budget/window-budget.test.d.ts +0 -18
- package/dist/types/workflow-engine/agent-runner.d.ts +0 -124
- package/dist/types/workflow-engine/agent-runner.test.d.ts +0 -8
- package/dist/types/workflow-engine/display.d.ts +0 -148
- package/dist/types/workflow-engine/display.test.d.ts +0 -1
- package/dist/types/workflow-engine/engine.d.ts +0 -183
- package/dist/types/workflow-engine/engine.test.d.ts +0 -1
- package/dist/types/workflow-engine/index.d.ts +0 -21
- package/dist/types/workflow-engine/parse.d.ts +0 -64
- package/dist/types/workflow-engine/parse.test.d.ts +0 -1
- package/dist/types/workflow-engine/structured-output.d.ts +0 -51
- package/dist/types/workflow-engine/structured-output.test.d.ts +0 -1
- package/dist/types/workspace/brand.d.ts +0 -26
- package/dist/types/workspace/index.d.ts +0 -11
- package/dist/types/workspace/locator.d.ts +0 -50
- package/dist/types/workspace/runtime-detect.d.ts +0 -56
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Credential command — `runCredentialCommand`.
|
|
3
|
-
*
|
|
4
|
-
* The top-level `signin` / `signout` surface. Sign-in supports two methods: a
|
|
5
|
-
* browser sign-in (OAuth) for the providers the framework registry exposes, and
|
|
6
|
-
* an api-key flow for every provider in the directory. When a provider is
|
|
7
|
-
* sign-in-capable the command prefers the browser flow but still lets the user
|
|
8
|
-
* pick an api key; for the rest it stores a key directly. The env-var override is
|
|
9
|
-
* consulted first via the framework {@link getEnvApiKey}, so a user who already
|
|
10
|
-
* exported (e.g.) `ANTHROPIC_API_KEY` can sign in without re-typing the secret.
|
|
11
|
-
*
|
|
12
|
-
* The command owns the first positional token only: it returns `handled: false`
|
|
13
|
-
* when that token is neither {@link CredentialVerb} so the caller falls through
|
|
14
|
-
* to a normal launch. Every failure is a typed {@link CredentialFault}; nothing
|
|
15
|
-
* is signalled by a string sentinel or a bare `process.exit`.
|
|
16
|
-
*
|
|
17
|
-
* I/O is injected. The default {@link CredentialIo} wraps `process.stdout` plus a
|
|
18
|
-
* `node:readline/promises` interface, but tests drive the whole flow over an
|
|
19
|
-
* in-memory stand-in with no real terminal and an in-memory vault.
|
|
20
|
-
*/
|
|
21
|
-
import { type CredentialCommandOptions, type CredentialFault, type CredentialVerb, type ProviderEntry } from "./contract";
|
|
22
|
-
/**
|
|
23
|
-
* The console seam the credential command reads and writes through.
|
|
24
|
-
*
|
|
25
|
-
* Pinned to the three operations the flow actually needs — emit a line, read a
|
|
26
|
-
* line of input, and read a secret line — so a test can capture output into an
|
|
27
|
-
* array and feed scripted answers without a real TTY.
|
|
28
|
-
*/
|
|
29
|
-
export interface CredentialIo {
|
|
30
|
-
/** Emit one line of human-facing text. */
|
|
31
|
-
print(line: string): void;
|
|
32
|
-
/** Prompt for and read one line of visible input. */
|
|
33
|
-
ask(prompt: string): Promise<string>;
|
|
34
|
-
/** Prompt for and read one line of secret input (key entry). */
|
|
35
|
-
askSecret(prompt: string): Promise<string>;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* The default {@link CredentialIo} backed by `process.stdout` and a
|
|
39
|
-
* `node:readline/promises` interface. Secret entry mutes echo while the line is
|
|
40
|
-
* typed by suppressing the terminal write of each keystroke.
|
|
41
|
-
*/
|
|
42
|
-
export declare function defaultCredentialIo(): CredentialIo;
|
|
43
|
-
/**
|
|
44
|
-
* The api-key provider directory: every provider the sign-in surface can store a
|
|
45
|
-
* key for, with its conventional env var and the page a user obtains a key from.
|
|
46
|
-
* These are external provider facts; {@link envKey} is the variable
|
|
47
|
-
* {@link getEnvApiKey} reads for the env-first shortcut.
|
|
48
|
-
*/
|
|
49
|
-
export declare const PROVIDER_DIRECTORY: readonly ProviderEntry[];
|
|
50
|
-
/** Look up a provider entry by id (case-insensitive over the directory). */
|
|
51
|
-
export declare function findProvider(id: string): ProviderEntry | undefined;
|
|
52
|
-
/**
|
|
53
|
-
* The two ways a provider can be signed in to.
|
|
54
|
-
*
|
|
55
|
-
* - `oauth` — a browser sign-in driven by the framework registry.
|
|
56
|
-
* - `api-key` — paste / store a provider api key.
|
|
57
|
-
*/
|
|
58
|
-
export type SigninMethod = "oauth" | "api-key";
|
|
59
|
-
/** Narrow a `--method` value to a {@link SigninMethod}. */
|
|
60
|
-
export declare function asSigninMethod(value: string | undefined): SigninMethod | undefined;
|
|
61
|
-
/** Whether a provider id can be signed in to through the browser registry. */
|
|
62
|
-
export declare function isOAuthCapable(id: string): boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Validate an api key against the format rules: non-empty, at least
|
|
65
|
-
* {@link MIN_KEY_LENGTH} characters, and free of placeholder markers. Returns a
|
|
66
|
-
* typed {@link CredentialFault} on rejection, or `undefined` when the key passes.
|
|
67
|
-
*/
|
|
68
|
-
export declare function validateApiKey(key: string): CredentialFault | undefined;
|
|
69
|
-
/**
|
|
70
|
-
* Validate an account name: at most {@link MAX_ACCOUNT_LENGTH} characters and
|
|
71
|
-
* matching {@link ACCOUNT_PATTERN}. Returns a typed fault on rejection, or
|
|
72
|
-
* `undefined` when the name is acceptable.
|
|
73
|
-
*/
|
|
74
|
-
export declare function validateAccountName(name: string): CredentialFault | undefined;
|
|
75
|
-
/**
|
|
76
|
-
* The outcome of {@link runCredentialCommand}.
|
|
77
|
-
*
|
|
78
|
-
* {@link handled} reports whether the first positional token was a recognised
|
|
79
|
-
* {@link CredentialVerb}; when `false`, the caller proceeds to a normal launch
|
|
80
|
-
* unchanged. {@link fault} carries a typed failure when the command was handled
|
|
81
|
-
* but did not complete.
|
|
82
|
-
*/
|
|
83
|
-
export interface CredentialResult {
|
|
84
|
-
/** Whether this invocation was a `signin` / `signout` command. */
|
|
85
|
-
readonly handled: boolean;
|
|
86
|
-
/** The verb that ran, when {@link handled} is true. */
|
|
87
|
-
readonly verb?: CredentialVerb;
|
|
88
|
-
/** The provider id the verb acted on, when one was resolved. */
|
|
89
|
-
readonly provider?: string;
|
|
90
|
-
/** A typed failure, present only when the handled command did not complete. */
|
|
91
|
-
readonly fault?: CredentialFault;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Run the api-key sign-in / sign-out command.
|
|
95
|
-
*
|
|
96
|
-
* Returns `{ handled: false }` immediately when `argv[0]` is neither verb, so the
|
|
97
|
-
* orchestrator can call this first and fall through on a miss. Otherwise it
|
|
98
|
-
* resolves the provider (prompting from the directory when none is named), runs
|
|
99
|
-
* the verb, and resolves a {@link CredentialResult} — never throwing for an
|
|
100
|
-
* expected failure, which surfaces as {@link CredentialResult.fault}.
|
|
101
|
-
*
|
|
102
|
-
* @param argv the raw token list following the program name
|
|
103
|
-
* @param opts the injected vault, profile directory, and (optionally) the io seam
|
|
104
|
-
*/
|
|
105
|
-
export declare function runCredentialCommand(argv: readonly string[], opts: CredentialCommandOptions & {
|
|
106
|
-
io?: CredentialIo;
|
|
107
|
-
}): Promise<CredentialResult>;
|
|
108
|
-
/**
|
|
109
|
-
* Render a {@link CredentialFault} as the single human-facing message the caller
|
|
110
|
-
* prints before exiting non-zero. Pure; no I/O.
|
|
111
|
-
*/
|
|
112
|
-
export declare function formatCredentialFault(fault: CredentialFault): string;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Launch subsystem — public barrel.
|
|
3
|
-
*
|
|
4
|
-
* Re-exports the frozen Phase-10 contract surface: the parsed
|
|
5
|
-
* {@link Invocation} and its {@link OutputMode} / {@link ThinkingEffort} /
|
|
6
|
-
* {@link ToolName} vocabularies, the declarative {@link FlagSpec} table types,
|
|
7
|
-
* the gathered {@link Attachments} shape, the typed {@link CredentialFault}
|
|
8
|
-
* union and its {@link AuthVault} seam, the model-catalog filter, and the resume
|
|
9
|
-
* / settings-browser option shapes. Behavior modules (the reader, the usage
|
|
10
|
-
* renderer, the credential command, the attachment gatherer, the catalog
|
|
11
|
-
* printer, the resume picker, the settings browser) attach their exports here as
|
|
12
|
-
* they land, so consumers import the launch surface from `src/launch` rather
|
|
13
|
-
* than reaching into individual modules.
|
|
14
|
-
*/
|
|
15
|
-
export type { OutputMode, ThinkingEffort, ToolName, FlagKind, FlagDefault, FlagSpec, Invocation, FlagValue, Attachments, AttachmentOptions, CredentialVerb, ProviderEntry, CredentialFaultKind, CredentialFault, AuthVault, CredentialCommandOptions, CatalogFilter, SessionLoader, ResumeFault, SettingsBrowseOptions, ResumeRef, ThinkingLevel, SessionListProgress, ImageContent, KnownProvider, ModelRegistry, OAuthCredentials, Settings, RunnerId, } from "./contract";
|
|
16
|
-
export { THINKING_EFFORTS, TOOL_NAMES, isThinkingEffort, isOutputMode, isToolName, credentialFault, } from "./contract";
|
|
17
|
-
export { FLAG_SPECS, FLAG_GROUPS, readInvocation, readFileReferences, renderUsage, gatherAttachments, AttachmentError, } from "./invocation";
|
|
18
|
-
export type { FlagGroup, GroupedFlagSpec, AttachmentErrorKind, } from "./invocation";
|
|
19
|
-
export { runPackageCommand, defaultPackageIo, PACKAGE_COMMANDS, } from "./packages";
|
|
20
|
-
export type { PackageCommand, PackageIo, PackageCommandOptions, PackageResult, } from "./packages";
|
|
21
|
-
export { runCredentialCommand, defaultCredentialIo, formatCredentialFault, validateApiKey, validateAccountName, findProvider, isOAuthCapable, asSigninMethod, PROVIDER_DIRECTORY, } from "./credentials";
|
|
22
|
-
export type { CredentialIo, CredentialResult, SigninMethod } from "./credentials";
|
|
23
|
-
export { registerBuiltInOAuthProviders, listLoginProviders, startOAuthLogin, openLoginUrl, hasRegisteredOAuthClientId, } from "./oauth";
|
|
24
|
-
export type { AuthKind, LoginProvider, OAuthLoginResult, } from "./oauth";
|
|
25
|
-
export { printModelCatalog, defaultCatalogIo, registrySource } from "./catalog";
|
|
26
|
-
export type { CatalogIo, CatalogModelSource } from "./catalog";
|
|
27
|
-
export { pickResumeTarget, browseSettings, mergeSessions, renderSettingsListing, defaultResumeDeps, defaultSettingsBrowseIo, } from "./pickers";
|
|
28
|
-
export type { ResumeDeps, ResumeOutcome, SettingsBrowseIo, } from "./pickers";
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The attachment gatherer — expands `@file` references into one
|
|
3
|
-
* {@link Attachments} value.
|
|
4
|
-
*
|
|
5
|
-
* Each `@file` token collected by the reader is resolved through the framework
|
|
6
|
-
* path resolver ({@link resolveReadPath}, which handles `~` expansion and the
|
|
7
|
-
* cwd), classified by extension, and folded into the result:
|
|
8
|
-
*
|
|
9
|
-
* - **text files** are read as UTF-8 and inlined into {@link Attachments.prose}
|
|
10
|
-
* wrapped in a delimited block keyed by the resolved path, so the model sees
|
|
11
|
-
* which file each block came from;
|
|
12
|
-
* - **image files** are read as bytes, base64-encoded, and collected as
|
|
13
|
-
* framework {@link ImageContent} in {@link Attachments.media}.
|
|
14
|
-
*
|
|
15
|
-
* Guard rails:
|
|
16
|
-
* - an unknown extension, an oversized file, a missing file, or a read error
|
|
17
|
-
* raises a typed {@link AttachmentError} (with a {@link AttachmentErrorKind}
|
|
18
|
-
* discriminant) rather than a string or a process exit;
|
|
19
|
-
* - size caps bound the inlined text and the decoded image before either is
|
|
20
|
-
* materialised onto the message;
|
|
21
|
-
* - an empty file is skipped silently — it contributes neither prose nor media.
|
|
22
|
-
*
|
|
23
|
-
* The `@file` syntax, the extension classification, and base64 image attachment
|
|
24
|
-
* are kept behaviours; only the typed-error model and the explicit caps are
|
|
25
|
-
* owned here.
|
|
26
|
-
*/
|
|
27
|
-
import type { Attachments, AttachmentOptions } from "../contract";
|
|
28
|
-
/**
|
|
29
|
-
* The closed set of attachment failure categories. A consumer switches on
|
|
30
|
-
* {@link AttachmentError.kind}, never on message text:
|
|
31
|
-
*
|
|
32
|
-
* - `unsupported` — the file extension is neither text nor image.
|
|
33
|
-
* - `too-large` — the file exceeds its kind's size cap.
|
|
34
|
-
* - `not-found` — the resolved path does not exist.
|
|
35
|
-
* - `read-failed` — the file could not be read or stat-ed.
|
|
36
|
-
*/
|
|
37
|
-
export type AttachmentErrorKind = "unsupported" | "too-large" | "not-found" | "read-failed";
|
|
38
|
-
/**
|
|
39
|
-
* A typed `@file` expansion failure. Carries the offending reference and the
|
|
40
|
-
* resolved path for diagnostics; {@link cause} preserves any wrapped error.
|
|
41
|
-
*/
|
|
42
|
-
export declare class AttachmentError extends Error {
|
|
43
|
-
/** The failure category (the discriminant). */
|
|
44
|
-
readonly kind: AttachmentErrorKind;
|
|
45
|
-
/** The raw `@file` reference as supplied on the command line. */
|
|
46
|
-
readonly reference: string;
|
|
47
|
-
/** The resolved absolute path, when resolution succeeded. */
|
|
48
|
-
readonly resolvedPath?: string;
|
|
49
|
-
/** The wrapped underlying error, if any. */
|
|
50
|
-
readonly cause?: unknown;
|
|
51
|
-
constructor(kind: AttachmentErrorKind, message: string, detail: {
|
|
52
|
-
reference: string;
|
|
53
|
-
resolvedPath?: string;
|
|
54
|
-
cause?: unknown;
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Expand the `@file` references into a single {@link Attachments} value.
|
|
59
|
-
*
|
|
60
|
-
* Resolves each reference against {@link AttachmentOptions.cwd} via the framework
|
|
61
|
-
* resolver, classifies it by extension, enforces the per-kind size cap, and
|
|
62
|
-
* appends either a text block to the prose or an {@link ImageContent} to the
|
|
63
|
-
* media. References list is taken in order; the prose blocks are joined with a
|
|
64
|
-
* blank line between them. An empty references list yields an empty
|
|
65
|
-
* {@link Attachments} (the caller decides whether to attach it at all).
|
|
66
|
-
*
|
|
67
|
-
* @param references the raw `@file` paths (without the leading `@`)
|
|
68
|
-
* @param options the cwd the references resolve against
|
|
69
|
-
* @throws AttachmentError on an unsupported extension, an oversized file, a
|
|
70
|
-
* missing file, or a read failure
|
|
71
|
-
*/
|
|
72
|
-
export declare function gatherAttachments(references: readonly string[], options: AttachmentOptions): Promise<Attachments>;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The single declarative flag table.
|
|
3
|
-
*
|
|
4
|
-
* Every recognised command-line option is described here exactly once, as one
|
|
5
|
-
* {@link FlagSpec} row. Two consumers walk this same table:
|
|
6
|
-
*
|
|
7
|
-
* - the reader ({@link readInvocation}) indexes it by canonical name and alias
|
|
8
|
-
* to bind raw tokens into the parsed {@link Invocation}; and
|
|
9
|
-
* - the usage generator ({@link renderUsage}) enumerates it to render the
|
|
10
|
-
* option reference — there is no second, hand-maintained help string for it
|
|
11
|
-
* to drift against.
|
|
12
|
-
*
|
|
13
|
-
* Because both sides read the same rows, the help text and the parser cannot
|
|
14
|
-
* disagree about which flags exist, what they take, or what they mean. The order
|
|
15
|
-
* of the rows is the order options appear in the generated usage, grouped by the
|
|
16
|
-
* {@link FlagGroup} sidecar map below; keeping that order intentional is the only
|
|
17
|
-
* editorial concern when a row is added.
|
|
18
|
-
*
|
|
19
|
-
* Flag names and their semantics are a stable product contract (and largely an
|
|
20
|
-
* industry convention), so they are kept as-is; only the table that declares
|
|
21
|
-
* them and the code that reads it are owned here.
|
|
22
|
-
*/
|
|
23
|
-
import type { FlagSpec } from "../contract";
|
|
24
|
-
/**
|
|
25
|
-
* The heading a flag is filed under in the generated usage. Purely an editorial
|
|
26
|
-
* grouping for {@link renderUsage}; it has no effect on parsing.
|
|
27
|
-
*/
|
|
28
|
-
export type FlagGroup = "output" | "model" | "context" | "tools" | "meta";
|
|
29
|
-
/**
|
|
30
|
-
* A {@link FlagSpec} carrying its usage section. The extra {@link group} field is
|
|
31
|
-
* inert at parse time; the reader ignores it and only the renderer reads it.
|
|
32
|
-
*/
|
|
33
|
-
export interface GroupedFlagSpec extends FlagSpec {
|
|
34
|
-
/** The usage section this row is rendered under. */
|
|
35
|
-
readonly group: FlagGroup;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Human-readable titles for each {@link FlagGroup}, in render order. The usage
|
|
39
|
-
* generator walks this list, then within each group emits the matching rows from
|
|
40
|
-
* {@link FLAG_SPECS} in declaration order.
|
|
41
|
-
*/
|
|
42
|
-
export declare const FLAG_GROUPS: readonly {
|
|
43
|
-
readonly id: FlagGroup;
|
|
44
|
-
readonly title: string;
|
|
45
|
-
}[];
|
|
46
|
-
/**
|
|
47
|
-
* The one declarative option table. Every recognised flag is one row; the reader
|
|
48
|
-
* and the usage generator both index this and nothing else.
|
|
49
|
-
*
|
|
50
|
-
* Conventions:
|
|
51
|
-
* - {@link FlagSpec.name} is the canonical long spelling (leading dashes
|
|
52
|
-
* included) and also the key the parsed value lands under in
|
|
53
|
-
* {@link Invocation.flags} (sans the dashes).
|
|
54
|
-
* - {@link FlagSpec.aliases} hold short forms and synonyms; every alias hit
|
|
55
|
-
* normalises to {@link FlagSpec.name}.
|
|
56
|
-
* - {@link FlagSpec.kind} fixes the value vocabulary: `boolean` switches,
|
|
57
|
-
* `string` / `number` value flags, and accumulating `list` flags.
|
|
58
|
-
*/
|
|
59
|
-
export declare const FLAG_SPECS: readonly GroupedFlagSpec[];
|
|
@@ -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,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Login command — `runLogin`.
|
|
3
|
-
*
|
|
4
|
-
* The top-level `login` / `logout` / `whoami` surface that authenticates the CLI
|
|
5
|
-
* against the indus-server so a user with **no local provider key** can still run
|
|
6
|
-
* model turns through the server gateway (the session token is vended as the
|
|
7
|
-
* provider key downstream — see `src/boot/runners/server-mode.ts`).
|
|
8
|
-
*
|
|
9
|
-
* `login` drives the OAuth 2.0 **device-authorization** flow (RFC 8628) against
|
|
10
|
-
* the server's better-auth endpoints under `${INDUS_SERVER_URL}/api/auth`:
|
|
11
|
-
*
|
|
12
|
-
* 1. POST `/api/auth/device/code` → a `user_code` + verification URL.
|
|
13
|
-
* 2. The user opens the URL in a browser and approves the device.
|
|
14
|
-
* 3. We poll POST `/api/auth/device/token` until it returns an `access_token`.
|
|
15
|
-
* 4. The token is persisted via {@link storeServerToken} (A1's token store).
|
|
16
|
-
*
|
|
17
|
-
* This is a **pre-pipeline router**, not a runner: a no-key user cannot build a
|
|
18
|
-
* session, so login must short-circuit before the stage pipeline. {@link runLogin}
|
|
19
|
-
* therefore mirrors `runCredential` in `boot.ts` — it owns the first positional
|
|
20
|
-
* token only and returns `undefined` (fall through to a normal launch) when that
|
|
21
|
-
* token is not one of its verbs.
|
|
22
|
-
*
|
|
23
|
-
* The app does not depend on `better-auth/client`, `open`, or a spinner library,
|
|
24
|
-
* so the device flow is implemented over raw `fetch` and the console is driven
|
|
25
|
-
* with `chalk` to match the rest of the launch surface. `--server-url` and
|
|
26
|
-
* `--client-id` are parsed from the argv tail here (the declarative flag table is
|
|
27
|
-
* for the launch invocation, not these auth-only verbs).
|
|
28
|
-
*/
|
|
29
|
-
import type { OAuthLoginCallbacks } from "indusagi/ai";
|
|
30
|
-
import type { BootContext } from "../boot/contract";
|
|
31
|
-
/**
|
|
32
|
-
* The sign-in directory id for the indus-server session (as opposed to a
|
|
33
|
-
* per-model-provider credential). Used by `src/launch/oauth.ts` to special-case
|
|
34
|
-
* this entry in `listLoginProviders` / `startOAuthLogin` so the interactive
|
|
35
|
-
* `/login` picker can drive the same device-authorization flow as the `indus
|
|
36
|
-
* login` CLI verb.
|
|
37
|
-
*/
|
|
38
|
-
export declare const SERVER_TIER_PROVIDER_ID = "indus-server";
|
|
39
|
-
/**
|
|
40
|
-
* Drive the indus-server device-authorization flow through the framework's
|
|
41
|
-
* generic {@link OAuthLoginCallbacks} shape, so the interactive `/login` picker
|
|
42
|
-
* (`src/console/overlays/auth.tsx`'s `OAuthFlowDialog`) can establish a
|
|
43
|
-
* server-tier session the same way the `indus login` CLI verb does.
|
|
44
|
-
*
|
|
45
|
-
* Reuses the private {@link requestDeviceCode} / {@link pollForToken} helpers
|
|
46
|
-
* above rather than duplicating the request+poll sequence, and reports the
|
|
47
|
-
* verification URL / code through `callbacks.onAuth` exactly once, mirroring
|
|
48
|
-
* how `doLogin` renders them to the console. On success the token is persisted
|
|
49
|
-
* via {@link storeServerToken}; any thrown error (network failure, denial,
|
|
50
|
-
* expiry, timeout) propagates to the caller unchanged — `startOAuthLogin`'s
|
|
51
|
-
* caller (the dialog's try/catch) already renders a generic failure state.
|
|
52
|
-
*
|
|
53
|
-
* @param callbacks the framework's OAuth login callbacks (url + progress)
|
|
54
|
-
* @param serverUrl the indus-server base url (defaults to {@link INDUS_SERVER_URL})
|
|
55
|
-
* @param clientId the device-flow client id (defaults to {@link INDUS_CLIENT_ID})
|
|
56
|
-
*/
|
|
57
|
-
export declare function runServerTierLogin(callbacks: OAuthLoginCallbacks, serverUrl?: string, clientId?: string): Promise<void>;
|
|
58
|
-
/**
|
|
59
|
-
* Route a `login` / `logout` / `whoami` verb, if this invocation is one.
|
|
60
|
-
*
|
|
61
|
-
* Inspects `ctx.argv[0]`: returns a numeric exit code when it handled one of the
|
|
62
|
-
* auth verbs, or `undefined` when the leading token is something else so the
|
|
63
|
-
* caller falls through to a normal launch. Modeled on `runCredential` in
|
|
64
|
-
* `boot.ts`; `--server-url` / `--client-id` are parsed from the argv tail.
|
|
65
|
-
*
|
|
66
|
-
* @param ctx the seeded boot context (carries the raw argv)
|
|
67
|
-
*/
|
|
68
|
-
export declare function runLogin(ctx: BootContext): Promise<number | undefined>;
|
|
@@ -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,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `src/launch/oauth.ts` — unit tests for the indus-server bridge added to the
|
|
3
|
-
* merged sign-in directory and `startOAuthLogin`.
|
|
4
|
-
*
|
|
5
|
-
* Covers:
|
|
6
|
-
* 1. {@link listLoginProviders} includes the `indus-server` entry
|
|
7
|
-
* (`SERVER_TIER_PROVIDER_ID`, `authKind: "oauth"`).
|
|
8
|
-
* 2. {@link startOAuthLogin} for `SERVER_TIER_PROVIDER_ID` drives the device
|
|
9
|
-
* flow over a mocked `fetch`, reports `onAuth` exactly once with the right
|
|
10
|
-
* shape, reports progress, never touches the vault, and resolves.
|
|
11
|
-
* 3. {@link startOAuthLogin} for an unregistered id still throws the
|
|
12
|
-
* pre-existing "No browser sign-in is available" error (regression check).
|
|
13
|
-
* 4. A device/token failure (`access_denied`) propagates out of
|
|
14
|
-
* `startOAuthLogin` unchanged rather than being swallowed.
|
|
15
|
-
*
|
|
16
|
-
* `storeServerToken` is mocked (partial mock of `../boot/server-token`) so the
|
|
17
|
-
* success-path test never touches the real `~/.indusagi/agent/server-token.json`
|
|
18
|
-
* file on the machine running the suite.
|
|
19
|
-
*/
|
|
20
|
-
export {};
|