@ggui-ai/cli 0.2.0-alpha.3 → 0.3.0-rc.0
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/README.md +38 -7
- package/dist/api-client.d.ts +42 -1
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +30 -2
- package/dist/auth-keys.d.ts +1 -1
- package/dist/auth-keys.d.ts.map +1 -1
- package/dist/auth-keys.js +22 -7
- package/dist/auth-store.d.ts +1 -1
- package/dist/auth-store.d.ts.map +1 -1
- package/dist/cli.js +112 -30
- package/dist/config-push.d.ts +79 -0
- package/dist/config-push.d.ts.map +1 -0
- package/dist/config-push.js +301 -0
- package/dist/create-app-command.d.ts +17 -0
- package/dist/create-app-command.d.ts.map +1 -0
- package/dist/create-app-command.js +58 -0
- package/dist/deploy-command.d.ts +67 -0
- package/dist/deploy-command.d.ts.map +1 -0
- package/dist/deploy-command.js +386 -0
- package/dist/dev-command.d.ts +5 -1
- package/dist/dev-command.d.ts.map +1 -1
- package/dist/dev-command.js +31 -1
- package/dist/export-pool-command.d.ts +25 -0
- package/dist/export-pool-command.d.ts.map +1 -0
- package/dist/export-pool-command.js +116 -0
- package/dist/filesystem-seed-pool-source.d.ts +13 -0
- package/dist/filesystem-seed-pool-source.d.ts.map +1 -0
- package/dist/filesystem-seed-pool-source.js +22 -0
- package/dist/generation-probe.d.ts +53 -7
- package/dist/generation-probe.d.ts.map +1 -1
- package/dist/generation-probe.js +37 -1
- package/dist/internal/artifact-install.d.ts +4 -2
- package/dist/internal/artifact-install.d.ts.map +1 -1
- package/dist/internal/artifact-install.js +11 -10
- package/dist/internal/artifact-publish.d.ts +34 -31
- package/dist/internal/artifact-publish.d.ts.map +1 -1
- package/dist/internal/artifact-publish.js +133 -241
- package/dist/internal/artifact-search.d.ts +2 -28
- package/dist/internal/artifact-search.d.ts.map +1 -1
- package/dist/internal/artifact-search.js +5 -4
- package/dist/internal/auth-strategy.d.ts +21 -31
- package/dist/internal/auth-strategy.d.ts.map +1 -1
- package/dist/internal/auth-strategy.js +15 -23
- package/dist/internal/register-author-key.d.ts +7 -1
- package/dist/internal/register-author-key.d.ts.map +1 -1
- package/dist/internal/register-author-key.js +56 -19
- package/dist/mcp-backend.d.ts +25 -25
- package/dist/mcp-backend.d.ts.map +1 -1
- package/dist/mcp-backend.js +65 -61
- package/dist/paths.d.ts +3 -3
- package/dist/paths.js +3 -3
- package/dist/persistent-secrets.js +1 -1
- package/dist/persistent-stores.d.ts +2 -2
- package/dist/persistent-stores.d.ts.map +1 -1
- package/dist/persistent-stores.js +5 -5
- package/dist/pool-artifact.d.ts +19 -0
- package/dist/pool-artifact.d.ts.map +1 -0
- package/dist/pool-artifact.js +59 -0
- package/dist/provider-key-command.d.ts +51 -0
- package/dist/provider-key-command.d.ts.map +1 -0
- package/dist/provider-key-command.js +222 -0
- package/dist/push-command.d.ts +47 -0
- package/dist/push-command.d.ts.map +1 -0
- package/dist/push-command.js +230 -0
- package/dist/serve-command.d.ts +23 -19
- package/dist/serve-command.d.ts.map +1 -1
- package/dist/serve-command.js +13 -26
- package/dist/theme-command.js +0 -2
- package/dist/tunnel-provider.d.ts +8 -7
- package/dist/tunnel-provider.d.ts.map +1 -1
- package/package.json +25 -21
- package/dist/internal/auth-cache.d.ts +0 -40
- package/dist/internal/auth-cache.d.ts.map +0 -1
- package/dist/internal/auth-cache.js +0 -133
- package/dist/persistent-short-code-index.d.ts +0 -14
- package/dist/persistent-short-code-index.d.ts.map +0 -1
- package/dist/persistent-short-code-index.js +0 -39
- package/dist/spawn-cloudflared.d.ts +0 -61
- package/dist/spawn-cloudflared.d.ts.map +0 -1
- package/dist/spawn-cloudflared.js +0 -167
|
@@ -1,48 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Auth strategy for marketplace CLI verbs
|
|
3
3
|
* (`ggui {gadget,blueprint} publish`).
|
|
4
4
|
*
|
|
5
5
|
* Two strategies — explicit `--auth=bearer` for self-hosted and local
|
|
6
|
-
* registries, and the (default)
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* The public surface (this file, its consumers, and the CLI help
|
|
13
|
-
* text) stays vendor-neutral.
|
|
6
|
+
* registries, and the (default) `ggui login` session: the CLI reuses
|
|
7
|
+
* the credential the device flow stored at `~/.ggui/auth.json`,
|
|
8
|
+
* refreshing it when expired. The session acquisition itself lives in
|
|
9
|
+
* `artifact-publish` (`acquireLoginSessionToken`) and is injected here
|
|
10
|
+
* as a callback so this router stays IO-free.
|
|
14
11
|
*
|
|
15
12
|
* @example
|
|
16
13
|
* ```ts
|
|
17
14
|
* import { parseAuthFlags, acquireAuthToken } from './internal/auth-strategy.js';
|
|
18
15
|
*
|
|
19
16
|
* const authFlags = parseAuthFlags(args);
|
|
20
|
-
* const
|
|
17
|
+
* const token = await acquireAuthToken({
|
|
21
18
|
* flags: authFlags,
|
|
22
19
|
* env: process.env,
|
|
23
|
-
*
|
|
24
|
-
* acquireHostedAuthJwt,
|
|
20
|
+
* acquireSessionToken,
|
|
25
21
|
* });
|
|
26
22
|
* ```
|
|
27
23
|
*/
|
|
28
24
|
/**
|
|
29
|
-
* Parsed `--auth=<mode>` + `--token <token>` flags.
|
|
25
|
+
* Parsed `--auth=<mode>` + `--token <token>` flags.
|
|
30
26
|
*
|
|
31
|
-
* `auth: undefined` means "use the default (
|
|
32
|
-
*
|
|
27
|
+
* `auth: undefined` means "use the default (the stored `ggui login`
|
|
28
|
+
* session)". The only public flag value is `'bearer'`.
|
|
33
29
|
*/
|
|
34
30
|
export interface AuthFlags {
|
|
35
31
|
/** Auth mode. Only `'bearer'` is admitted as a public value; absent
|
|
36
|
-
* means "default =
|
|
32
|
+
* means "default = the stored `ggui login` session". */
|
|
37
33
|
readonly auth?: 'bearer';
|
|
38
34
|
/** Explicit bearer token. Used only when `auth === 'bearer'`. */
|
|
39
35
|
readonly token?: string;
|
|
40
36
|
}
|
|
41
37
|
/**
|
|
42
38
|
* Help-text fragment for the auth flags, inlined into each subcommand's
|
|
43
|
-
* help block.
|
|
39
|
+
* help block.
|
|
44
40
|
*/
|
|
45
|
-
export declare const AUTH_HELP_FRAGMENT = "Auth:\n --auth=bearer Use a bearer token (for self-hosted or local\n registries). Pair with --token <token> or set\n GGUI_REGISTRY_TOKEN in the environment.\n --token <token> Bearer token (paired with --auth=bearer).\n (default)
|
|
41
|
+
export declare const AUTH_HELP_FRAGMENT = "Auth:\n --auth=bearer Use a bearer token (for self-hosted or local\n registries). Pair with --token <token> or set\n GGUI_REGISTRY_TOKEN in the environment.\n --token <token> Bearer token (paired with --auth=bearer).\n (default) Your `ggui login` session \u2014 the CLI reads\n ~/.ggui/auth.json and refreshes the token\n automatically when it has expired. Run\n `ggui login` first.\n";
|
|
46
42
|
/**
|
|
47
43
|
* Pop the auth-related flags out of an argv-like list, returning the
|
|
48
44
|
* parsed flags + the residual args (so subcommand parsers can keep
|
|
@@ -58,22 +54,18 @@ export declare function parseAuthFlags(args: readonly string[]): {
|
|
|
58
54
|
error: string;
|
|
59
55
|
};
|
|
60
56
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
57
|
+
* Login-session callback shape. The caller injects the actual
|
|
58
|
+
* implementation (`acquireLoginSessionToken` in `artifact-publish`,
|
|
59
|
+
* which reads `~/.ggui/auth.json` + refreshes when expired).
|
|
64
60
|
*
|
|
65
|
-
* Returns the bearer
|
|
61
|
+
* Returns the bearer token the CLI sends as `Authorization: Bearer <token>`.
|
|
66
62
|
*/
|
|
67
|
-
export type
|
|
68
|
-
readonly registryUrl: string;
|
|
69
|
-
readonly env: NodeJS.ProcessEnv;
|
|
70
|
-
readonly cwd: string;
|
|
71
|
-
}) => Promise<string>;
|
|
63
|
+
export type SessionTokenAcquirer = () => Promise<string>;
|
|
72
64
|
/**
|
|
73
65
|
* Acquire the auth token to send to the registry. Routes:
|
|
74
66
|
*
|
|
75
67
|
* - `flags.auth === 'bearer'` → use `flags.token` || `GGUI_REGISTRY_TOKEN`
|
|
76
|
-
* - otherwise → call `
|
|
68
|
+
* - otherwise → call `acquireSessionToken` (the stored `ggui login` session)
|
|
77
69
|
*
|
|
78
70
|
* Throws (with an operator-readable message) when bearer auth is
|
|
79
71
|
* selected but no token is supplied; the message names the env var so
|
|
@@ -82,8 +74,6 @@ export type HostedAuthAcquirer = (deps: {
|
|
|
82
74
|
export declare function acquireAuthToken(deps: {
|
|
83
75
|
readonly flags: AuthFlags;
|
|
84
76
|
readonly env: NodeJS.ProcessEnv;
|
|
85
|
-
readonly
|
|
86
|
-
readonly registryUrl: string;
|
|
87
|
-
readonly acquireHostedAuthJwt: HostedAuthAcquirer;
|
|
77
|
+
readonly acquireSessionToken: SessionTokenAcquirer;
|
|
88
78
|
}): Promise<string>;
|
|
89
79
|
//# sourceMappingURL=auth-strategy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-strategy.d.ts","sourceRoot":"","sources":["../../src/internal/auth-strategy.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"auth-strategy.d.ts","sourceRoot":"","sources":["../../src/internal/auth-strategy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB;4DACwD;IACxD,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IACzB,iEAAiE;IACjE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,6gBAS9B,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAuDnE;AAED;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;AAEzD;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE;IAC3C,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IAChC,QAAQ,CAAC,mBAAmB,EAAE,oBAAoB,CAAC;CACpD,GAAG,OAAO,CAAC,MAAM,CAAC,CAkBlB"}
|
|
@@ -1,43 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Auth strategy for marketplace CLI verbs
|
|
3
3
|
* (`ggui {gadget,blueprint} publish`).
|
|
4
4
|
*
|
|
5
5
|
* Two strategies — explicit `--auth=bearer` for self-hosted and local
|
|
6
|
-
* registries, and the (default)
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* The public surface (this file, its consumers, and the CLI help
|
|
13
|
-
* text) stays vendor-neutral.
|
|
6
|
+
* registries, and the (default) `ggui login` session: the CLI reuses
|
|
7
|
+
* the credential the device flow stored at `~/.ggui/auth.json`,
|
|
8
|
+
* refreshing it when expired. The session acquisition itself lives in
|
|
9
|
+
* `artifact-publish` (`acquireLoginSessionToken`) and is injected here
|
|
10
|
+
* as a callback so this router stays IO-free.
|
|
14
11
|
*
|
|
15
12
|
* @example
|
|
16
13
|
* ```ts
|
|
17
14
|
* import { parseAuthFlags, acquireAuthToken } from './internal/auth-strategy.js';
|
|
18
15
|
*
|
|
19
16
|
* const authFlags = parseAuthFlags(args);
|
|
20
|
-
* const
|
|
17
|
+
* const token = await acquireAuthToken({
|
|
21
18
|
* flags: authFlags,
|
|
22
19
|
* env: process.env,
|
|
23
|
-
*
|
|
24
|
-
* acquireHostedAuthJwt,
|
|
20
|
+
* acquireSessionToken,
|
|
25
21
|
* });
|
|
26
22
|
* ```
|
|
27
23
|
*/
|
|
28
24
|
/**
|
|
29
25
|
* Help-text fragment for the auth flags, inlined into each subcommand's
|
|
30
|
-
* help block.
|
|
26
|
+
* help block.
|
|
31
27
|
*/
|
|
32
28
|
export const AUTH_HELP_FRAGMENT = `Auth:
|
|
33
29
|
--auth=bearer Use a bearer token (for self-hosted or local
|
|
34
30
|
registries). Pair with --token <token> or set
|
|
35
31
|
GGUI_REGISTRY_TOKEN in the environment.
|
|
36
32
|
--token <token> Bearer token (paired with --auth=bearer).
|
|
37
|
-
(default)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
(default) Your \`ggui login\` session — the CLI reads
|
|
34
|
+
~/.ggui/auth.json and refreshes the token
|
|
35
|
+
automatically when it has expired. Run
|
|
36
|
+
\`ggui login\` first.
|
|
41
37
|
`;
|
|
42
38
|
/**
|
|
43
39
|
* Pop the auth-related flags out of an argv-like list, returning the
|
|
@@ -104,7 +100,7 @@ export function parseAuthFlags(args) {
|
|
|
104
100
|
* Acquire the auth token to send to the registry. Routes:
|
|
105
101
|
*
|
|
106
102
|
* - `flags.auth === 'bearer'` → use `flags.token` || `GGUI_REGISTRY_TOKEN`
|
|
107
|
-
* - otherwise → call `
|
|
103
|
+
* - otherwise → call `acquireSessionToken` (the stored `ggui login` session)
|
|
108
104
|
*
|
|
109
105
|
* Throws (with an operator-readable message) when bearer auth is
|
|
110
106
|
* selected but no token is supplied; the message names the env var so
|
|
@@ -124,9 +120,5 @@ export async function acquireAuthToken(deps) {
|
|
|
124
120
|
}
|
|
125
121
|
return token;
|
|
126
122
|
}
|
|
127
|
-
return deps.
|
|
128
|
-
registryUrl: deps.registryUrl,
|
|
129
|
-
env: deps.env,
|
|
130
|
-
cwd: deps.cwd,
|
|
131
|
-
});
|
|
123
|
+
return deps.acquireSessionToken();
|
|
132
124
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { type AuthFlags } from './auth-strategy.js';
|
|
1
2
|
/**
|
|
2
3
|
* Outcome discriminator. The `ok: false` `code` union surfaces specific
|
|
3
4
|
* HTTP failure modes so callers (notably a future `--json` flag) can
|
|
4
5
|
* branch on the registry's closed error set without parsing the human-
|
|
5
6
|
* readable message:
|
|
6
7
|
*
|
|
7
|
-
* - `unauthorized` ← HTTP 401 (missing/invalid
|
|
8
|
+
* - `unauthorized` ← HTTP 401 (missing/invalid bearer credential).
|
|
8
9
|
* - `invalid_request` ← HTTP 400 (malformed body or wrong key length).
|
|
9
10
|
* - `key_conflict` ← HTTP 409 (collision against an existing row).
|
|
10
11
|
* - `http-error` ← any other non-2xx (5xx or unexpected status).
|
|
@@ -29,6 +30,11 @@ export type RegisterKeyOutcome = {
|
|
|
29
30
|
export interface RunRegisterKeyFlags {
|
|
30
31
|
readonly scope: string;
|
|
31
32
|
readonly registry?: string;
|
|
33
|
+
/** Auth strategy + bearer token. `undefined` → the stored `ggui
|
|
34
|
+
* login` session; `{ auth: 'bearer', token? }` → explicit bearer
|
|
35
|
+
* (self-hosted registries), token from the flag or
|
|
36
|
+
* `GGUI_REGISTRY_TOKEN`. Mirrors the publish flow's `AuthFlags`. */
|
|
37
|
+
readonly auth?: AuthFlags;
|
|
32
38
|
}
|
|
33
39
|
export interface RunRegisterKeyDeps {
|
|
34
40
|
readonly cwd: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-author-key.d.ts","sourceRoot":"","sources":["../../src/internal/register-author-key.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"register-author-key.d.ts","sourceRoot":"","sources":["../../src/internal/register-author-key.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGtE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,kBAAkB,GAC1B;IACE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,GACD;IACE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,IAAI,EACT,aAAa,GACb,kBAAkB,GAClB,YAAY,GACZ,aAAa,GACb,qBAAqB,GACrB,eAAe,GACf,cAAc,GACd,iBAAiB,GACjB,cAAc,GACd,YAAY,GACZ,cAAc,CAAC;IACnB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEN,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;yEAGqE;IACrE,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,MAAM,CAAC;CAC5B;AAcD;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,mBAAmB,EAC1B,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,kBAAkB,CAAC,CA6K7B"}
|
|
@@ -6,20 +6,36 @@
|
|
|
6
6
|
* `aws dynamodb put-item` workflow that previously required raw IAM
|
|
7
7
|
* credentials + registry table knowledge.
|
|
8
8
|
*
|
|
9
|
-
* The publisher's identity is
|
|
10
|
-
* the body carries only `publicKeyBase64`. `keyId`
|
|
11
|
-
* public-key bytes on the server, so re-running
|
|
12
|
-
* idempotent (200 OK).
|
|
9
|
+
* The publisher's identity is derived server-side from the verified
|
|
10
|
+
* bearer credential; the body carries only `publicKeyBase64`. `keyId`
|
|
11
|
+
* is derived from the public-key bytes on the server, so re-running
|
|
12
|
+
* with the same key is idempotent (200 OK).
|
|
13
13
|
*
|
|
14
|
-
* Auth + registry-URL resolution match the publish flow (
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* Auth + registry-URL resolution match the publish flow (the stored
|
|
15
|
+
* `ggui login` session by default, `--auth=bearer --token <token>` /
|
|
16
|
+
* `GGUI_REGISTRY_TOKEN` for self-hosted registries; `GGUI_REGISTRY`
|
|
17
|
+
* env / `ggui.json#registry` URL chain works the same way operators
|
|
18
|
+
* are used to).
|
|
17
19
|
*/
|
|
18
20
|
import { readFileSync } from 'node:fs';
|
|
19
21
|
import { REGISTER_AUTHOR_KEY_ERROR_CODES } from '@ggui-ai/registry-core';
|
|
20
|
-
import {
|
|
22
|
+
import { acquireLoginSessionToken, } from './artifact-publish.js';
|
|
21
23
|
import { resolveRegistryUrl } from './artifact-search.js';
|
|
24
|
+
import { acquireAuthToken } from './auth-strategy.js';
|
|
22
25
|
import { getPublicKeyPath, hasKeypair } from './key-store.js';
|
|
26
|
+
/**
|
|
27
|
+
* Sentinel that carries the structured {@link AuthFailed} payload
|
|
28
|
+
* through `acquireAuthToken`'s throwing session callback — the
|
|
29
|
+
* register flow's never-throws contract maps it back to an outcome.
|
|
30
|
+
* Mirrors `SessionAuthError` in `artifact-publish.ts`.
|
|
31
|
+
*/
|
|
32
|
+
class SessionOutcomeError extends Error {
|
|
33
|
+
payload;
|
|
34
|
+
constructor(payload) {
|
|
35
|
+
super(payload.error.message);
|
|
36
|
+
this.payload = payload;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
23
39
|
/**
|
|
24
40
|
* Run the register flow end-to-end. Never throws — every error path
|
|
25
41
|
* returns a structured outcome.
|
|
@@ -75,18 +91,39 @@ export async function runRegisterAuthorKey(flags, deps) {
|
|
|
75
91
|
};
|
|
76
92
|
}
|
|
77
93
|
const publicKeyBase64 = publicKeyBytes.toString('base64');
|
|
78
|
-
// 3.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
94
|
+
// 3. Credential — same two-path strategy as publish:
|
|
95
|
+
// --auth=bearer → token from the flag or GGUI_REGISTRY_TOKEN
|
|
96
|
+
// default → the stored `ggui login` session.
|
|
97
|
+
let accessToken;
|
|
98
|
+
try {
|
|
99
|
+
accessToken = await acquireAuthToken({
|
|
100
|
+
flags: flags.auth ?? {},
|
|
101
|
+
env: deps.env,
|
|
102
|
+
acquireSessionToken: async () => {
|
|
103
|
+
const auth = await acquireLoginSessionToken({
|
|
104
|
+
now: deps.now,
|
|
105
|
+
fetchImpl: deps.fetch,
|
|
106
|
+
});
|
|
107
|
+
if (!auth.ok)
|
|
108
|
+
throw new SessionOutcomeError(auth);
|
|
109
|
+
return auth.accessToken;
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
if (err instanceof SessionOutcomeError) {
|
|
115
|
+
return {
|
|
116
|
+
ok: false,
|
|
117
|
+
code: err.payload.error.code,
|
|
118
|
+
message: err.payload.error.message,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
// Bearer selected but no token supplied — `acquireAuthToken`
|
|
122
|
+
// throws with an operator-readable message naming the env var.
|
|
86
123
|
return {
|
|
87
124
|
ok: false,
|
|
88
|
-
code:
|
|
89
|
-
message:
|
|
125
|
+
code: 'auth_config_missing',
|
|
126
|
+
message: err instanceof Error ? err.message : String(err),
|
|
90
127
|
};
|
|
91
128
|
}
|
|
92
129
|
// 4. POST /author-keys
|
|
@@ -97,7 +134,7 @@ export async function runRegisterAuthorKey(flags, deps) {
|
|
|
97
134
|
method: 'POST',
|
|
98
135
|
headers: {
|
|
99
136
|
'content-type': 'application/json',
|
|
100
|
-
authorization: `Bearer ${
|
|
137
|
+
authorization: `Bearer ${accessToken}`,
|
|
101
138
|
},
|
|
102
139
|
body: JSON.stringify({ publicKeyBase64 }),
|
|
103
140
|
});
|
package/dist/mcp-backend.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type BlueprintProvider, type DiscoveredPrimitiveCatalog, type GadgetDescriptor, type GenerationDeps, type LoadedTheme, type McpServerMount, type McpUiDisplayMode, type OperatorConfig, type ResolvedStorageStores, type ShortCodeIndex, type ThemeWriter } from "@ggui-ai/mcp-server";
|
|
2
|
-
import type
|
|
2
|
+
import { type BlueprintPool } from "@ggui-ai/mcp-server-handlers/renders";
|
|
3
|
+
import type { ThemeConfig, UiManifest } from "@ggui-ai/project-config";
|
|
3
4
|
import type { UiRegistry } from "@ggui-ai/ui-registry";
|
|
4
5
|
import type { ServeBackend } from "./serve-command.js";
|
|
5
6
|
export interface BuildMcpServerBackendOptions {
|
|
@@ -94,21 +95,15 @@ export interface BuildMcpServerBackendOptions {
|
|
|
94
95
|
* Optional change notifier — fires from
|
|
95
96
|
* `mountDevtoolThemeRoutes`'s POST handlers when the operator
|
|
96
97
|
* saves a new theme via the picker. Pair with `themeProvider` so
|
|
97
|
-
* the
|
|
98
|
+
* the render handler reads the live theme on every call.
|
|
99
|
+
* `null` = cleared.
|
|
98
100
|
*/
|
|
99
|
-
readonly onThemeConfigChange?: (next:
|
|
100
|
-
preset: string;
|
|
101
|
-
mode?: "light" | "dark";
|
|
102
|
-
overrides?: Record<string, string>;
|
|
103
|
-
} | {
|
|
104
|
-
file: string;
|
|
105
|
-
mode?: "light" | "dark";
|
|
106
|
-
} | null) => void;
|
|
101
|
+
readonly onThemeConfigChange?: (next: ThemeConfig | null) => void;
|
|
107
102
|
/**
|
|
108
103
|
* Generation wiring for `ggui_render`. When present, the OSS render
|
|
109
104
|
* handler invokes the bound `UiGenerator` on every story-path
|
|
110
|
-
* call and commits real componentCode as a `
|
|
111
|
-
* placeholder mode: render mints
|
|
105
|
+
* call and commits real componentCode as a `GguiSession`. Absent =
|
|
106
|
+
* placeholder mode: render mints sessionIds + shortCodes but does
|
|
112
107
|
* not produce componentCode.
|
|
113
108
|
*
|
|
114
109
|
* The CLI resolves this from the operator's BYOK state at boot via
|
|
@@ -119,6 +114,12 @@ export interface BuildMcpServerBackendOptions {
|
|
|
119
114
|
* setting, a test double, etc.).
|
|
120
115
|
*/
|
|
121
116
|
readonly generation?: GenerationDeps;
|
|
117
|
+
/**
|
|
118
|
+
* Read-only shared/seed blueprint pools for cross-deployment reuse.
|
|
119
|
+
* Threaded into the handshake negotiator's `seedPools`. Built by the
|
|
120
|
+
* CLI from `--seed-pool` artifacts; absent ⇒ no shared pool.
|
|
121
|
+
*/
|
|
122
|
+
readonly seedPools?: readonly BlueprintPool[];
|
|
122
123
|
/**
|
|
123
124
|
* Marketplace-install bridge data. When set, the backend
|
|
124
125
|
* constructs an
|
|
@@ -127,8 +128,9 @@ export interface BuildMcpServerBackendOptions {
|
|
|
127
128
|
* into `generation.installedBlueprints`. On the first
|
|
128
129
|
* `matchBlueprint` call per scope, every entry with a contract is
|
|
129
130
|
* compiled (esbuild) and registered into the cache with
|
|
130
|
-
* `
|
|
131
|
-
* render the way
|
|
131
|
+
* `source: {kind: 'user'}` + the `installed` lifecycle marker — so
|
|
132
|
+
* installed blueprints accelerate render the way cold-gen-cached
|
|
133
|
+
* ones do.
|
|
132
134
|
*
|
|
133
135
|
* Caller is responsible for filtering `entries` to actual
|
|
134
136
|
* marketplace installs (typically: discovered UIs whose
|
|
@@ -258,17 +260,15 @@ export interface BuildMcpServerBackendOptions {
|
|
|
258
260
|
readonly persistentDir?: string;
|
|
259
261
|
/**
|
|
260
262
|
* Pre-resolved `ShortCodeIndex` implementation. When set, replaces
|
|
261
|
-
* the default `InMemoryShortCodeIndex` —
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
263
|
+
* the default `InMemoryShortCodeIndex` — e.g. a `SqliteShortCodeIndex`
|
|
264
|
+
* rooted under `persistentDir` so cached `/api/bootstrap/<code>` URLs
|
|
265
|
+
* keep resolving after a `ggui serve` restart. With the in-memory
|
|
266
|
+
* default the index is process-local and every restart turns prior
|
|
267
|
+
* shortCodes into 404s — defeating the bootstrap-secret persistence
|
|
268
|
+
* above.
|
|
267
269
|
*
|
|
268
|
-
* Absent = `InMemoryShortCodeIndex` (the
|
|
269
|
-
*
|
|
270
|
-
* `createPersistentShortCodeIndex(persistentDir)` in cli.ts so the
|
|
271
|
-
* sqlite peer-dep loads lazily.
|
|
270
|
+
* Absent = `InMemoryShortCodeIndex` (the default, fine for tests +
|
|
271
|
+
* `--ephemeral`).
|
|
272
272
|
*/
|
|
273
273
|
readonly shortCodeIndex?: ShortCodeIndex;
|
|
274
274
|
/**
|
|
@@ -299,7 +299,7 @@ export interface BuildMcpServerBackendOptions {
|
|
|
299
299
|
* Per-app gadget catalog from `ggui.json#app.gadgets`.
|
|
300
300
|
* Gadgets (Leaflet, Mapbox, …) declared
|
|
301
301
|
* here populate `App.gadgets` so the
|
|
302
|
-
* `assertGadgetsRegistered` validator (
|
|
302
|
+
* `assertGadgetsRegistered` validator (render, ops_register,
|
|
303
303
|
* ops_generate) accepts contracts that reference them.
|
|
304
304
|
*
|
|
305
305
|
* Omitted ⇒ `STDLIB_GADGETS` defaults from
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-backend.d.ts","sourceRoot":"","sources":["../src/mcp-backend.ts"],"names":[],"mappings":"AA0CA,OAAO,
|
|
1
|
+
{"version":3,"file":"mcp-backend.d.ts","sourceRoot":"","sources":["../src/mcp-backend.ts"],"names":[],"mappings":"AA0CA,OAAO,EAQL,KAAK,iBAAiB,EACtB,KAAK,0BAA0B,EAE/B,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,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