@happyvertical/smrt-app-cli 0.51.31 → 0.51.33

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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mcp-stdio-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-stdio-bridge.d.ts","sourceRoot":"","sources":["../../../src/__tests__/fixtures/mcp-stdio-bridge.ts"],"names":[],"mappings":""}
@@ -1 +1,8 @@
1
- export {}
1
+ /**
2
+ * `smrt-app` — configuration-driven executable for a published SMRT app CLI.
3
+ *
4
+ * The wrapper accepts non-secret identity before `--`; everything after `--`
5
+ * is forwarded unchanged to the canonical `createAppCli` command dispatcher.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=smrt-app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smrt-app.d.ts","sourceRoot":"","sources":["../../src/bin/smrt-app.ts"],"names":[],"mappings":"AACA;;;;;GAKG"}
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { i as runAppCliExecutable } from "../src-DCo67mp8.js";
2
+ import { i as runAppCliExecutable } from "../src-DRNQCkh6.js";
3
3
  //#region src/bin/smrt-app.ts
4
4
  /**
5
5
  * `smrt-app` — configuration-driven executable for a published SMRT app CLI.
@@ -1 +1,24 @@
1
- export {}
1
+ /**
2
+ * `smrt-mcp-bridge` — generic stdio MCP bridge.
3
+ *
4
+ * Usage:
5
+ *
6
+ * ```
7
+ * smrt-mcp-bridge --env-prefix=WILLGRIFFIN \
8
+ * --name=willgriffin-mcp --version=0.1.0
9
+ * ```
10
+ *
11
+ * All options can also be passed as env vars:
12
+ *
13
+ * - `SMRT_MCP_ENV_PREFIX` — env-prefix the bridge uses to look up the app's
14
+ * server URL/token/config file.
15
+ * - `SMRT_MCP_APP_SLUG` — directory name under `~/.config`.
16
+ * - `SMRT_MCP_SERVER_NAME` / `SMRT_MCP_SERVER_VERSION` — local server identity.
17
+ * - `SMRT_MCP_DEFAULT_SERVER_URL` — fallback server URL.
18
+ *
19
+ * Apps that want their own branded bin should call `runMcpStdioBridge`
20
+ * directly from `@happyvertical/smrt-app-cli` — this package's root export —
21
+ * instead of going through this generic entrypoint.
22
+ */
23
+ export {};
24
+ //# sourceMappingURL=smrt-mcp-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smrt-mcp-bridge.d.ts","sourceRoot":"","sources":["../../src/bin/smrt-mcp-bridge.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;GAqBG"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Stdio MCP bridge — pipes a remote SMRT app's HTTP MCP surface
3
+ * (`/api/mcp/tools` + `/api/mcp/call`) to a local stdio MCP server so that
4
+ * editors and AI clients can connect to it.
5
+ *
6
+ * Apps wire this up by providing their own bin script:
7
+ *
8
+ * ```ts
9
+ * #!/usr/bin/env node
10
+ * import { runMcpStdioBridge } from '@happyvertical/smrt-app-cli';
11
+ * await runMcpStdioBridge({
12
+ * envPrefix: 'WILLGRIFFIN',
13
+ * serverInfo: { name: 'willgriffin-mcp', version: '0.1.0' },
14
+ * });
15
+ * ```
16
+ *
17
+ * The package also ships a `smrt-mcp-bridge` bin (see `bin/smrt-mcp-bridge`)
18
+ * that reads `--env-prefix=…` from argv for ad-hoc use without writing a
19
+ * package-specific entry point.
20
+ *
21
+ * @packageDocumentation
22
+ */
23
+ import { type CallToolResult, ProtocolError, Server } from '@modelcontextprotocol/server';
24
+ import { type AppCliResultMetadata, type CliConfigContext, type RequestJsonResult } from './config.js';
25
+ /** Namespace shared with the published SMRT app-result contract. */
26
+ export { SMRT_MCP_RESULT_METADATA_KEY } from '@happyvertical/smrt-users/app-contract';
27
+ /**
28
+ * Configuration for the bridge.
29
+ *
30
+ * Combines the {@link CliConfigContext} (env var + config file resolution)
31
+ * with the local MCP server identity the bridge advertises to clients.
32
+ */
33
+ export interface McpStdioBridgeOptions extends CliConfigContext {
34
+ /** MCP server identity advertised to local clients. */
35
+ serverInfo: {
36
+ name: string;
37
+ version: string;
38
+ };
39
+ /** Override the tools endpoint path. Defaults to `/api/mcp/tools`. */
40
+ toolsPath?: string;
41
+ /** Override the call endpoint path. Defaults to `/api/mcp/call`. */
42
+ callPath?: string;
43
+ /**
44
+ * Override fetch implementation (used by tests so we never hit the network).
45
+ */
46
+ fetch?: typeof fetch;
47
+ }
48
+ /**
49
+ * Wire up the stdio server. Use `runMcpStdioBridge` for a one-call entry
50
+ * point in `bin/` scripts; this lower-level form is exposed for tests.
51
+ */
52
+ export declare function createMcpStdioBridge(options: McpStdioBridgeOptions): {
53
+ server: Server;
54
+ connect: () => Promise<void>;
55
+ };
56
+ /**
57
+ * Preserve the HTTP result/error envelope in protocol-permitted MCP metadata.
58
+ * This deliberately does not create `structuredContent`; #2149 owns declared
59
+ * output schema semantics for generated tools.
60
+ */
61
+ export declare function formatMcpCallResult(outcome: RequestJsonResult<CallToolResult>): CallToolResult;
62
+ /** Convert an HTTP transport failure into an MCP JSON-RPC error safely. */
63
+ export declare function toMcpTransportError(metadata: AppCliResultMetadata): ProtocolError;
64
+ /**
65
+ * One-call entry point — start the factory-owned stdio bridge. The returned
66
+ * promise resolves once the stdio listener is installed.
67
+ */
68
+ export declare function runMcpStdioBridge(options: McpStdioBridgeOptions): Promise<void>;
69
+ //# sourceMappingURL=bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAEL,KAAK,cAAc,EAGnB,aAAa,EAEb,MAAM,EACP,MAAM,8BAA8B,CAAC;AAKtC,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAGvB,MAAM,aAAa,CAAC;AAErB,oEAAoE;AACpE,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AAYtF;;;;;GAKG;AACH,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D,uDAAuD;IACvD,UAAU,EAAE;QACV,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG;IACpE,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B,CAmDA;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,iBAAiB,CAAC,cAAc,CAAC,GACzC,cAAc,CAiChB;AAuCD,2EAA2E;AAC3E,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,oBAAoB,GAC7B,aAAa,CAOf;AAiCD;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAEf"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * `<name> auth login | status | logout` — terminal device-code flow against
3
+ * `/api/cli/auth/start` and `/api/cli/auth/token` (shipped by smrt-users).
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+ import { type CliConfigContext } from '../config.js';
8
+ export interface AuthCommandsOptions {
9
+ context: CliConfigContext;
10
+ stdout?: NodeJS.WriteStream;
11
+ stderr?: NodeJS.WriteStream;
12
+ /** Skip auto-opening the browser; tests pass true. */
13
+ noOpenDefault?: boolean;
14
+ /** Override the polling sleep (tests pass 0). */
15
+ sleepMs?: (ms: number) => Promise<void>;
16
+ }
17
+ export declare function runAuthLogin(options: AuthCommandsOptions, args: string[]): Promise<void>;
18
+ export declare function runAuthStatus(options: AuthCommandsOptions): Promise<void>;
19
+ export declare function runAuthLogout(options: AuthCommandsOptions): Promise<void>;
20
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,KAAK,gBAAgB,EAOtB,MAAM,cAAc,CAAC;AAuBtB,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,gBAAgB,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC;IAC5B,sDAAsD;IACtD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iDAAiD;IACjD,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACzC;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,mBAAmB,EAC5B,IAAI,EAAE,MAAM,EAAE,GACb,OAAO,CAAC,IAAI,CAAC,CAyEf;AA6BD,wBAAsB,aAAa,CACjC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAgCf;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAWf"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * `<name> mcp tools` / `<name> mcp call <tool> '<json>'` — thin HTTP proxy
3
+ * to `/api/mcp/tools` and `/api/mcp/call`. The stdio bridge lives in
4
+ * `bin/smrt-mcp-bridge` and `bridge.ts`; these are the equivalent
5
+ * one-shot HTTP commands for ad-hoc inspection.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ import type { CliConfigContext } from '../config.js';
10
+ export interface McpCommandOptions {
11
+ context: CliConfigContext;
12
+ stdout?: NodeJS.WriteStream;
13
+ stderr?: NodeJS.WriteStream;
14
+ fetch?: typeof fetch;
15
+ }
16
+ export declare function runMcpCommand(options: McpCommandOptions, args: string[]): Promise<boolean>;
17
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/commands/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGrD,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,gBAAgB,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC;IAC5B,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,iBAAiB,EAC1B,IAAI,EAAE,MAAM,EAAE,GACb,OAAO,CAAC,OAAO,CAAC,CA8ClB"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * `<name> resources [--json] [--debug]` — print the discovered resource
3
+ * list. Default mode is a compact human-readable summary; `--json` dumps
4
+ * the raw discovery payload; `--debug` adds the full warnings list.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ import type { CliConfigContext } from '../config.js';
9
+ import type { ResourceListResponse } from '../discovery.js';
10
+ export interface ResourcesCommandOptions {
11
+ context: CliConfigContext;
12
+ stdout?: NodeJS.WriteStream;
13
+ stderr?: NodeJS.WriteStream;
14
+ /** Tests: pre-supplied response, skips network. */
15
+ injectResponse?: ResourceListResponse;
16
+ /** Tests: custom fetch. */
17
+ fetch?: typeof fetch;
18
+ }
19
+ export declare function runResourcesCommand(options: ResourcesCommandOptions, args: string[]): Promise<void>;
20
+ //# sourceMappingURL=resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../src/commands/resources.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAe,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAGzE,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,gBAAgB,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC;IAC5B,mDAAmD;IACnD,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,uBAAuB,EAChC,IAAI,EAAE,MAAM,EAAE,GACb,OAAO,CAAC,IAAI,CAAC,CA+Cf"}
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Shared CLI helpers for SMRT apps: a small config file format, env var
3
+ * resolution with a configurable prefix, and a minimal JSON HTTP client
4
+ * that knows how to bear the stored CLI token.
5
+ *
6
+ * The same helpers back the stdio bridge (`smrt-mcp-bridge`) and any
7
+ * app-specific `data`-style commands that talk to the app's HTTP API.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ import type { AppResultMetadata, DeclaredActionField } from '@happyvertical/smrt-users/app-contract';
12
+ /** Shape stored on disk in the app's CLI config file. */
13
+ export interface CliConfig {
14
+ /** Issuer selected for the currently configured server. */
15
+ credentialIssuer?: string;
16
+ serverUrl?: string;
17
+ /** Legacy single-token field. Read only when its stored server still matches. */
18
+ token?: string;
19
+ /** Bearer credentials keyed by their exact issuer identifier. */
20
+ tokensByIssuer?: Record<string, string>;
21
+ }
22
+ /**
23
+ * Configuration for the env-var/config-file resolution chain.
24
+ *
25
+ * Env vars derived from `envPrefix`:
26
+ *
27
+ * - `${PREFIX}_SERVER_URL`
28
+ * - `${PREFIX}_TOKEN`
29
+ * - `${PREFIX}_CLI_CONFIG` (overrides config file path)
30
+ */
31
+ export interface CliConfigContext {
32
+ /**
33
+ * Uppercase prefix for env vars and the app's namespaced config dir.
34
+ * Example: `WILLGRIFFIN` → reads `WILLGRIFFIN_SERVER_URL`, defaults the
35
+ * config file to `~/.config/willgriffin/config.json` unless `appSlug`
36
+ * overrides the directory name.
37
+ */
38
+ envPrefix: string;
39
+ /** Directory name under `~/.config`. Defaults to lowercased `envPrefix`. */
40
+ appSlug?: string;
41
+ /** Fallback server URL if neither env nor config sets one. */
42
+ defaultServerUrl?: string;
43
+ /**
44
+ * Require HTTPS for every resolved or request-level server URL, while still
45
+ * permitting loopback HTTP for local development.
46
+ */
47
+ requireSecureServerUrl?: boolean;
48
+ }
49
+ /** Enforce the executable-safe server URL policy without echoing URL values. */
50
+ export declare function assertSecureServerUrl(value: string): void;
51
+ /** Read the CLI config file. Missing file → empty config. */
52
+ export declare function loadCliConfig(context: CliConfigContext): Promise<CliConfig>;
53
+ /**
54
+ * Write the CLI config to disk with 0600 permissions (the token is a bearer
55
+ * credential — anyone who can read the file can impersonate the user).
56
+ */
57
+ export declare function saveCliConfig(context: CliConfigContext, config: CliConfig): Promise<void>;
58
+ /** Resolve the server URL: env var → config file → `defaultServerUrl`. */
59
+ export declare function getServerUrl(context: CliConfigContext, config?: CliConfig): Promise<string>;
60
+ /** Resolve a bearer token only when it is bound to the exact target server. */
61
+ export declare function getStoredToken(context: CliConfigContext, config?: CliConfig, serverUrl?: string): Promise<string | undefined>;
62
+ /** Remove the token from the config file (e.g. on logout). */
63
+ export declare function clearStoredToken(context: CliConfigContext): Promise<void>;
64
+ /** Persist a login with the bearer token keyed by its exact issuer. */
65
+ export declare function saveAuth(context: CliConfigContext, serverUrl: string, token: string, issuer?: string): Promise<void>;
66
+ /** Options for `requestJson`. */
67
+ export interface RequestJsonOptions {
68
+ /**
69
+ * When false, skip sending the Authorization header even if a token is
70
+ * present. Defaults to true.
71
+ */
72
+ auth?: boolean;
73
+ /**
74
+ * When true, throw if no token is available and `auth` is not false.
75
+ * Defaults to false.
76
+ */
77
+ requireAuth?: boolean;
78
+ /** Override the server URL for this request. */
79
+ serverUrl?: string;
80
+ /** Override the fetch implementation (tests). */
81
+ fetch?: typeof fetch;
82
+ /**
83
+ * Cap on response body size in bytes. The CLI buffers the full body
84
+ * before JSON-parsing, so without this cap a misbehaving or malicious
85
+ * server could OOM the CLI process with a multi-GB payload (auth and
86
+ * discovery both use this code path). Defaults to 10MB — large enough
87
+ * for any sensible discovery response, small enough that overflow is
88
+ * a clear signal something's wrong. Pass `Infinity` to disable.
89
+ * (#1311 review A4.)
90
+ */
91
+ maxResponseBytes?: number;
92
+ /**
93
+ * Pre-loaded config to avoid re-reading from disk. Set by callers that
94
+ * already have it (e.g. `buildAppContext`); leave undefined for the
95
+ * default behavior of loading per-call. (#1311 review P2.)
96
+ */
97
+ loadedConfig?: CliConfig;
98
+ }
99
+ /** Structured metadata preserved for CLI JSON and MCP bridge consumers. */
100
+ export type AppCliResultMetadata = AppResultMetadata;
101
+ export type { DeclaredActionField };
102
+ export interface RequestJsonSuccess<T> {
103
+ ok: true;
104
+ result: T;
105
+ metadata: AppCliResultMetadata;
106
+ }
107
+ export interface RequestJsonFailure {
108
+ ok: false;
109
+ status: number;
110
+ error: AppCliResultMetadata;
111
+ }
112
+ /** Generic result/error envelope for a JSON request. */
113
+ export type RequestJsonResult<T> = RequestJsonSuccess<T> | RequestJsonFailure;
114
+ /** Error compatibility wrapper returned by the legacy throwing helper. */
115
+ export declare class AppCliRequestError extends Error {
116
+ readonly status: number;
117
+ readonly metadata: AppCliResultMetadata;
118
+ constructor(status: number, metadata: AppCliResultMetadata);
119
+ }
120
+ /**
121
+ * JSON request helper that injects the stored bearer token. Returns the
122
+ * parsed JSON body on success; throws an `Error` with the server's `error`
123
+ * field (or `HTTP <status>`) on failure.
124
+ */
125
+ export declare function requestJson<T = unknown>(context: CliConfigContext, path: string, init?: RequestInit, options?: RequestJsonOptions): Promise<T>;
126
+ /**
127
+ * Issue a JSON request without flattening a failure to an Error message.
128
+ *
129
+ * Metadata is deliberately copied only from conventional result/error fields
130
+ * and response headers. Every value crossing this boundary is redacted before
131
+ * a CLI or MCP client can observe it.
132
+ */
133
+ export declare function requestJsonResult<T = unknown>(context: CliConfigContext, path: string, init?: RequestInit, options?: RequestJsonOptions): Promise<RequestJsonResult<T>>;
134
+ /** Redact conventional credential fields before emitting transport metadata. */
135
+ export declare function redactTransportValue(value: unknown): unknown;
136
+ export { createMcpStdioBridge, type McpStdioBridgeOptions, runMcpStdioBridge, } from './bridge.js';
137
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAaH,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EAEpB,MAAM,wCAAwC,CAAC;AAGhD,yDAAyD;AACzD,MAAM,WAAW,SAAS;IACxB,2DAA2D;IAC3D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iFAAiF;IACjF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAID,gFAAgF;AAChF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAoBzD;AAeD,6DAA6D;AAC7D,wBAAsB,aAAa,CACjC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,SAAS,CAAC,CAgBpB;AAED;;;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AAC;IACV,QAAQ,EAAE,oBAAoB,CAAC;CAChC;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,KAAK,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,oBAAoB,CAAC;CAC7B;AAED,wDAAwD;AACxD,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,kBAAkB,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC;AAE9E,0EAA0E;AAC1E,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;gBAE5B,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB;CAM3D;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,CAAC,GAAG,OAAO,EAC3C,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,WAAgB,EACtB,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,CAAC,CAAC,CAMZ;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,GAAG,OAAO,EACjD,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,WAAgB,EACtB,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAmG/B;AAED,gFAAgF;AAChF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAW5D;AAqKD,OAAO,EACL,oBAAoB,EACpB,KAAK,qBAAqB,EAC1B,iBAAiB,GAClB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Fetches the resource list from `GET /api/_resources` and re-exports the
3
+ * wire types so consumers can build typed extensions on top of the discovery
4
+ * output.
5
+ *
6
+ * Types are imported type-only from `@happyvertical/smrt-users/sveltekit`
7
+ * — the single source of truth for the wire contract. The CLI does not
8
+ * depend on smrt-users at runtime (the peer dep is `optional` in the
9
+ * package.json) so importing types is free of bundle cost.
10
+ *
11
+ * Importing type-only means a new field added to `CommandDefinition` /
12
+ * `CliResource` on the handler side automatically propagates to the CLI's
13
+ * typecheck — no manual mirror-update required. (#1311 review D-1.)
14
+ *
15
+ * @packageDocumentation
16
+ */
17
+ import type { CliResource as HandlerCliResource, CommandDefinition as HandlerCommandDefinition, CommandKind as HandlerCommandKind, CommandScope as HandlerCommandScope, ResourceListResponseBody } from '@happyvertical/smrt-users/sveltekit';
18
+ import type { CliConfigContext } from './config.js';
19
+ export type CommandKind = HandlerCommandKind;
20
+ export type CommandScope = HandlerCommandScope;
21
+ export type CommandDefinition = HandlerCommandDefinition;
22
+ export type CliResource = HandlerCliResource;
23
+ export type ResourceListResponse = ResourceListResponseBody;
24
+ export interface FetchResourceListOptions {
25
+ /** Endpoint path on the server. Default `/api/_resources`. */
26
+ path?: string;
27
+ /** Custom fetch (tests). */
28
+ fetch?: typeof fetch;
29
+ /** When true, the request fails if no token is available. */
30
+ requireAuth?: boolean;
31
+ /**
32
+ * Pre-loaded config to avoid re-reading from disk. Set by
33
+ * `buildAppContext`, which has already loaded it. (#1311 review P2.)
34
+ */
35
+ loadedConfig?: import('./config.js').CliConfig;
36
+ }
37
+ /**
38
+ * Fetch the discovery payload.
39
+ *
40
+ * Translates a 401 into a friendlier error so the CLI can prompt the
41
+ * user to log in rather than dumping a raw HTTP error.
42
+ */
43
+ export declare function fetchResourceList(context: CliConfigContext, options?: FetchResourceListOptions): Promise<ResourceListResponse>;
44
+ /**
45
+ * Find a resource by slug in the discovery payload. Returns `undefined`
46
+ * if the slug isn't present.
47
+ */
48
+ export declare function findResourceBySlug(response: ResourceListResponse, slug: string): CliResource | undefined;
49
+ /**
50
+ * Find a command on a resource by its CLI-facing name. Returns
51
+ * `undefined` if not found.
52
+ */
53
+ export declare function findCommand(resource: CliResource, commandName: string): CommandDefinition | undefined;
54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@ -0,0 +1,29 @@
1
+ /**
2
+ * Configuration-driven executable support for published SMRT app CLIs.
3
+ *
4
+ * This adapter deliberately owns no command schemas or transport behavior. It
5
+ * validates non-secret application identity, creates the canonical app CLI,
6
+ * and forwards the remaining argv unchanged.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ import { type AppCli, type CreateAppCliOptions } from './index.js';
11
+ export interface AppCliExecutableConfig {
12
+ cliOptions: Pick<CreateAppCliOptions, 'name' | 'envPrefix' | 'configDir' | 'defaultServerUrl' | 'requireSecureServerUrl'>;
13
+ argv: string[];
14
+ mcp?: {
15
+ name: string;
16
+ version: string;
17
+ };
18
+ stdioMcp: boolean;
19
+ }
20
+ export interface RunAppCliExecutableOptions {
21
+ argv?: string[];
22
+ env?: NodeJS.ProcessEnv;
23
+ createCli?: (options: CreateAppCliOptions) => AppCli;
24
+ }
25
+ /** Parse and validate the generic executable's non-secret configuration. */
26
+ export declare function parseAppCliExecutableConfig(argv: string[], env?: NodeJS.ProcessEnv): AppCliExecutableConfig;
27
+ /** Create the canonical app CLI and execute its forwarded command or bridge. */
28
+ export declare function runAppCliExecutable(options?: RunAppCliExecutableOptions): Promise<void>;
29
+ //# sourceMappingURL=executable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executable.d.ts","sourceRoot":"","sources":["../src/executable.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EACL,KAAK,MAAM,EACX,KAAK,mBAAmB,EAEzB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,IAAI,CACd,mBAAmB,EACjB,MAAM,GACN,WAAW,GACX,WAAW,GACX,kBAAkB,GAClB,wBAAwB,CAC3B,CAAC;IACF,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,CAAC,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,MAAM,CAAC;CACtD;AA2BD,4EAA4E;AAC5E,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,sBAAsB,CAqFxB;AAED,gFAAgF;AAChF,wBAAsB,mBAAmB,CACvC,OAAO,GAAE,0BAA+B,GACvC,OAAO,CAAC,IAAI,CAAC,CAWf"}