@guuey/config 0.1.0 → 0.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guuey/config",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Open-source schemas + loaders for the three guuey config files: agent.json (declarative agent definition), guuey.json (hosted-deploy overlay), and the helper types around them. Consumed by @guuey/cli, the guuey backend, and devs writing their own agent or MCP server.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,65 +0,0 @@
1
- import { AgentJsonV1 } from './agent.js';
2
- /**
3
- * Walk up from `startDir` (default: `process.cwd()`) looking for an
4
- * `agent.json`. Returns the absolute path to the first match, or
5
- * `null` if no file is found within `maxDepth` levels.
6
- *
7
- * Stops at the filesystem root regardless of `maxDepth`. Never throws —
8
- * a missing file is a valid result ("this repo is code-mode only"),
9
- * not an error.
10
- */
11
- export declare function findAgentJson(startDir?: string, maxDepth?: number): string | null;
12
- /**
13
- * Error thrown when an `agent.json` fails to load — missing file,
14
- * malformed JSON, schema validation failure, or an unresolvable
15
- * `systemPrompt.file` reference. Wraps the underlying cause
16
- * (`SyntaxError` / `ZodError` / filesystem error) on `.cause`.
17
- */
18
- export declare class AgentJsonLoadError extends Error {
19
- readonly path: string;
20
- constructor(message: string, path: string, options?: {
21
- cause?: unknown;
22
- });
23
- }
24
- /**
25
- * The inlined, ready-to-snapshot form of `agent.json`. Identical
26
- * shape to {@link AgentJsonV1} EXCEPT `systemPrompt` is always
27
- * `string | undefined` — file references are resolved and inlined
28
- * during load. The pod runtime never reads the filesystem; it sees
29
- * only this resolved shape.
30
- *
31
- * `undefined` system prompt means "fall through to the platform
32
- * default" (see `GUUEY_DEFAULT_SYSTEM_PROMPT` in `./system-prompt`).
33
- */
34
- export type ResolvedAgentJson = Omit<AgentJsonV1, 'systemPrompt'> & {
35
- systemPrompt?: string;
36
- };
37
- /**
38
- * Read `agent.json` at `path`, parse JSON, validate against v1, and
39
- * inline any `systemPrompt.file` reference (resolved relative to the
40
- * `agent.json` directory). Returns the fully-resolved snapshot.
41
- *
42
- * Throws {@link AgentJsonLoadError} if:
43
- * - the file does not exist,
44
- * - the file is not valid JSON,
45
- * - the document fails schema validation (cause = `ZodError`),
46
- * - `systemPrompt.file` points outside the project directory or
47
- * does not exist on disk.
48
- */
49
- export declare function loadAgentJson(path: string): ResolvedAgentJson;
50
- /**
51
- * Non-throwing variant of {@link loadAgentJson}. Returns a
52
- * discriminated result mirroring `z.safeParse` for ergonomics in CLI
53
- * surfaces that render the error inline.
54
- */
55
- export type SafeLoadAgentResult = {
56
- success: true;
57
- data: ResolvedAgentJson;
58
- } | {
59
- success: false;
60
- error: AgentJsonLoadError;
61
- };
62
- export declare function safeLoadAgentJson(path: string): SafeLoadAgentResult;
63
- export { AGENT_JSON_FILENAME, AgentJsonV1, parseAgentJson, safeParseAgentJson, DEFAULT_AGENT_MCP_SERVERS, } from './agent.js';
64
- export type { AgentJsonMcpServer, AgentJsonRuntime, AgentJsonSystemPrompt, AgentJsonToolGates, } from './agent.js';
65
- //# sourceMappingURL=agent-loader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent-loader.d.ts","sourceRoot":"","sources":["../src/agent-loader.ts"],"names":[],"mappings":"AAoBA,OAAO,EAEL,WAAW,EAEZ,MAAM,YAAY,CAAC;AAUpB;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,GAAE,MAAsB,EAChC,QAAQ,GAAE,MAA+B,GACxC,MAAM,GAAG,IAAI,CAUf;AAED;;;;;GAKG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAKzE;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,CA8C7D;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAC3B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,iBAAiB,CAAA;CAAE,GAC1C;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAElD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,CASnE;AAoDD,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,YAAY,CAAC"}
@@ -1,155 +0,0 @@
1
- /**
2
- * Node-only filesystem helpers for `agent.json`.
3
- *
4
- * Pure-parse helpers (`parseAgentJson` / `safeParseAgentJson`) live in
5
- * `./agent.ts` and are safe to import from non-Node contexts. This
6
- * module adds the file-resolution layer: reading `agent.json` off
7
- * disk, inlining `systemPrompt.file` references, and producing the
8
- * snapshot the deploy upload + pod boot both read.
9
- *
10
- * Intended callers:
11
- *
12
- * - `guuey` CLI: `guuey deploy --config agent.json` reads the file,
13
- * inlines the system prompt, and POSTs the resulting snapshot to
14
- * the control plane as the no-tarball declarative deploy body.
15
- * - Guuey control-plane services that re-validate the submitted
16
- * snapshot server-side before persisting to AgentDeployment.
17
- * - Stock nocode-runtime pod: reads the snapshot back at boot.
18
- */
19
- import { existsSync, readFileSync } from 'node:fs';
20
- import { dirname, isAbsolute, join, resolve } from 'node:path';
21
- import { AGENT_JSON_FILENAME, parseAgentJson, } from './agent.js';
22
- /**
23
- * How many parent directories `findAgentJson` will walk by default.
24
- * Internal — the public-facing constant of the same name on
25
- * `./loader.ts` is the one re-exported on the package barrel; the
26
- * two values are kept in sync intentionally.
27
- */
28
- const DEFAULT_FIND_MAX_DEPTH = 8;
29
- /**
30
- * Walk up from `startDir` (default: `process.cwd()`) looking for an
31
- * `agent.json`. Returns the absolute path to the first match, or
32
- * `null` if no file is found within `maxDepth` levels.
33
- *
34
- * Stops at the filesystem root regardless of `maxDepth`. Never throws —
35
- * a missing file is a valid result ("this repo is code-mode only"),
36
- * not an error.
37
- */
38
- export function findAgentJson(startDir = process.cwd(), maxDepth = DEFAULT_FIND_MAX_DEPTH) {
39
- let dir = resolve(startDir);
40
- for (let i = 0; i <= maxDepth; i++) {
41
- const candidate = join(dir, AGENT_JSON_FILENAME);
42
- if (existsSync(candidate))
43
- return candidate;
44
- const parent = dirname(dir);
45
- if (parent === dir)
46
- return null;
47
- dir = parent;
48
- }
49
- return null;
50
- }
51
- /**
52
- * Error thrown when an `agent.json` fails to load — missing file,
53
- * malformed JSON, schema validation failure, or an unresolvable
54
- * `systemPrompt.file` reference. Wraps the underlying cause
55
- * (`SyntaxError` / `ZodError` / filesystem error) on `.cause`.
56
- */
57
- export class AgentJsonLoadError extends Error {
58
- path;
59
- constructor(message, path, options) {
60
- super(message, options);
61
- this.name = 'AgentJsonLoadError';
62
- this.path = path;
63
- }
64
- }
65
- /**
66
- * Read `agent.json` at `path`, parse JSON, validate against v1, and
67
- * inline any `systemPrompt.file` reference (resolved relative to the
68
- * `agent.json` directory). Returns the fully-resolved snapshot.
69
- *
70
- * Throws {@link AgentJsonLoadError} if:
71
- * - the file does not exist,
72
- * - the file is not valid JSON,
73
- * - the document fails schema validation (cause = `ZodError`),
74
- * - `systemPrompt.file` points outside the project directory or
75
- * does not exist on disk.
76
- */
77
- export function loadAgentJson(path) {
78
- if (!existsSync(path)) {
79
- throw new AgentJsonLoadError(`agent.json not found at ${path}`, path);
80
- }
81
- let raw;
82
- try {
83
- raw = readFileSync(path, 'utf-8');
84
- }
85
- catch (cause) {
86
- throw new AgentJsonLoadError(`Failed to read agent.json at ${path}`, path, { cause });
87
- }
88
- let decoded;
89
- try {
90
- decoded = JSON.parse(raw);
91
- }
92
- catch (cause) {
93
- throw new AgentJsonLoadError(`agent.json at ${path} is not valid JSON`, path, { cause });
94
- }
95
- let parsed;
96
- try {
97
- parsed = parseAgentJson(decoded);
98
- }
99
- catch (cause) {
100
- throw new AgentJsonLoadError(`agent.json at ${path} failed schema validation`, path, { cause });
101
- }
102
- const baseDir = dirname(path);
103
- const resolvedPrompt = resolveSystemPrompt(parsed, baseDir, path);
104
- const out = { ...parsed, systemPrompt: resolvedPrompt };
105
- if (resolvedPrompt === undefined) {
106
- delete out.systemPrompt;
107
- }
108
- return out;
109
- }
110
- export function safeLoadAgentJson(path) {
111
- try {
112
- return { success: true, data: loadAgentJson(path) };
113
- }
114
- catch (error) {
115
- if (error instanceof AgentJsonLoadError) {
116
- return { success: false, error };
117
- }
118
- throw error;
119
- }
120
- }
121
- /**
122
- * Resolve the `systemPrompt` field on a parsed `agent.json`. Returns
123
- * `undefined` when the field is absent (caller falls through to the
124
- * platform default). Inlines `{ file }` references relative to
125
- * `baseDir`; rejects absolute paths and parent-directory escapes so
126
- * the snapshot can't pull arbitrary host files into the deploy.
127
- */
128
- function resolveSystemPrompt(doc, baseDir, agentJsonPath) {
129
- const sp = doc.systemPrompt;
130
- if (sp === undefined)
131
- return undefined;
132
- if (typeof sp === 'string')
133
- return sp;
134
- const relPath = sp.file;
135
- if (isAbsolute(relPath)) {
136
- throw new AgentJsonLoadError(`systemPrompt.file "${relPath}" must be a relative path, not absolute`, agentJsonPath);
137
- }
138
- const resolved = resolve(baseDir, relPath);
139
- const baseResolved = resolve(baseDir);
140
- if (!resolved.startsWith(baseResolved + '/') && resolved !== baseResolved) {
141
- throw new AgentJsonLoadError(`systemPrompt.file "${relPath}" resolves outside the project directory`, agentJsonPath);
142
- }
143
- if (!existsSync(resolved)) {
144
- throw new AgentJsonLoadError(`systemPrompt.file "${relPath}" does not exist (looked at ${resolved})`, agentJsonPath);
145
- }
146
- try {
147
- return readFileSync(resolved, 'utf-8').trim();
148
- }
149
- catch (cause) {
150
- throw new AgentJsonLoadError(`Failed to read systemPrompt.file "${relPath}"`, agentJsonPath, { cause });
151
- }
152
- }
153
- // Re-export pure schema + types from the same subpath so Node callers
154
- // can do one import.
155
- export { AGENT_JSON_FILENAME, AgentJsonV1, parseAgentJson, safeParseAgentJson, DEFAULT_AGENT_MCP_SERVERS, } from './agent.js';
@@ -1,123 +0,0 @@
1
- /**
2
- * `mcpProxies` — Guuey hosted overlay shape for managed MCP relays.
3
- *
4
- * Relocated 2026-04-21 from `@ggui-ai/protocol/types/mcp-proxy.ts` as
5
- * part of the OSS split §8.2 classification fix. These types describe
6
- * a GUUEY HOSTING CONCEPT (a managed proxy that relays MCP calls with
7
- * upstream OAuth linking), not a vendor-neutral protocol shape, and
8
- * therefore belong in the closed `@guuey/config`
9
- * package alongside the rest of `guuey.json`.
10
- *
11
- * ## The classification decision
12
- *
13
- * `mcpProxies` is the declaration block a developer adds to
14
- * `guuey.json` to tell Guuey hosting: *"on behalf of this project,
15
- * relay these external MCP providers, using this OAuth linking
16
- * config, exposing these discovered servers."* That is
17
- * platform-layer plumbing — Guuey runs the relay, handles the
18
- * credential storage, dispatches the discovery — and it does not
19
- * describe anything an OSS-only `ggui` deployment emits or consumes.
20
- *
21
- * Per §8.2: the OSS `ggui` server does NOT read `guuey.json`.
22
- * Consumers that need overlay values (the closed `guuey` CLI,
23
- * Guuey-hosted Lambdas, the Guuey-internal control-plane UI) are
24
- * the only call sites allowed to import from this package. Open
25
- * packages that historically read `mcpProxies` (`@ggui-ai/server`'s
26
- * Claude-passthrough feature) retain their feature code but inline
27
- * the minimal structural shape they actually use — it stays a
28
- * Guuey-platform plumbing path, not a protocol contract.
29
- *
30
- * ## Scope of this module
31
- *
32
- * - {@link McpProxyLinkingConfig} — upstream OAuth config for
33
- * proxies that relay calls on behalf of an external account
34
- * (e.g. Claude.ai). Keys surface in the Guuey control plane's
35
- * credential-linking UI.
36
- * - {@link McpProxyConfig} — a single proxy's discovery + proxy
37
- * URL pattern + optional server filter + optional linking block.
38
- * - {@link McpProxiesConfig} — the top-level record keyed by
39
- * proxy id (`claude_ai`, `guuey`, future `omo`...). Exactly the
40
- * shape `guuey.json#mcpProxies` carries.
41
- *
42
- * ## Vendor-neutral constants stay in `@ggui-ai/protocol`
43
- *
44
- * Claude.ai-specific constants and discovery-response wire types
45
- * (`CLAUDE_AI_*`, `DiscoveredMcpServer`, `ClaudeAiDiscoveryResponse`)
46
- * remain in `@ggui-ai/protocol/types/mcp-proxy.ts` — those describe
47
- * Anthropic's public API, not Guuey-overlay config.
48
- *
49
- * ## Strictness
50
- *
51
- * Zod validation matches the rest of `guuey.json`: strict objects,
52
- * non-empty strings, URL validation on linking endpoints. Unknown
53
- * keys on nested objects fail parse (prevents silent drift toward
54
- * a "what else can we stuff into guuey.json" shape).
55
- */
56
- import { z } from 'zod';
57
- /**
58
- * OAuth linking config for proxies that relay on behalf of an
59
- * external account. Omit for proxies where Guuey session auth is
60
- * the only identity needed (e.g. a Guuey-native proxy).
61
- */
62
- declare const McpProxyLinkingSchema: z.ZodObject<{
63
- authUrl: z.ZodURL;
64
- tokenUrl: z.ZodURL;
65
- scopes: z.ZodArray<z.ZodString>;
66
- clientId: z.ZodOptional<z.ZodString>;
67
- manualRedirectUrl: z.ZodOptional<z.ZodURL>;
68
- }, z.core.$strict>;
69
- /**
70
- * Configuration for a single MCP proxy in `guuey.json#mcpProxies`.
71
- *
72
- * `discovery` + `proxy` are both URL-valued, but `proxy` is a URL
73
- * PATTERN (contains `{server_id}` which is substituted at call
74
- * time). Both are validated as URLs — `{server_id}` is accepted
75
- * by URL parsers as opaque path segment.
76
- */
77
- declare const McpProxyConfigSchema: z.ZodObject<{
78
- discovery: z.ZodURL;
79
- proxy: z.ZodURL;
80
- linking: z.ZodOptional<z.ZodObject<{
81
- authUrl: z.ZodURL;
82
- tokenUrl: z.ZodURL;
83
- scopes: z.ZodArray<z.ZodString>;
84
- clientId: z.ZodOptional<z.ZodString>;
85
- manualRedirectUrl: z.ZodOptional<z.ZodURL>;
86
- }, z.core.$strict>>;
87
- servers: z.ZodOptional<z.ZodArray<z.ZodString>>;
88
- }, z.core.$strict>;
89
- /**
90
- * The `mcpProxies` section of `guuey.json`. Keys are proxy
91
- * identifiers (`claude_ai`, `guuey`, future `omo`, …).
92
- *
93
- * Record shape intentionally — new proxy ids are additive; a fixed
94
- * literal union here would force a schema change every time a new
95
- * hosted-relay integration lands.
96
- */
97
- export declare const McpProxiesSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
98
- discovery: z.ZodURL;
99
- proxy: z.ZodURL;
100
- linking: z.ZodOptional<z.ZodObject<{
101
- authUrl: z.ZodURL;
102
- tokenUrl: z.ZodURL;
103
- scopes: z.ZodArray<z.ZodString>;
104
- clientId: z.ZodOptional<z.ZodString>;
105
- manualRedirectUrl: z.ZodOptional<z.ZodURL>;
106
- }, z.core.$strict>>;
107
- servers: z.ZodOptional<z.ZodArray<z.ZodString>>;
108
- }, z.core.$strict>>;
109
- /** Linking block type derived from the zod schema. */
110
- export type McpProxyLinkingConfig = z.infer<typeof McpProxyLinkingSchema>;
111
- /** Single-proxy config type derived from the zod schema. */
112
- export type McpProxyConfig = z.infer<typeof McpProxyConfigSchema>;
113
- /** Full `mcpProxies` overlay type derived from the zod schema. */
114
- export type McpProxiesConfig = z.infer<typeof McpProxiesSchema>;
115
- /**
116
- * Parse a raw JSON value into a validated {@link McpProxiesConfig}.
117
- * Throws a `ZodError` on invalid input.
118
- */
119
- export declare function parseMcpProxies(raw: unknown): McpProxiesConfig;
120
- /** Safe-parse variant — see {@link parseMcpProxies}. */
121
- export declare function safeParseMcpProxies(raw: unknown): ReturnType<typeof McpProxiesSchema.safeParse>;
122
- export {};
123
- //# sourceMappingURL=mcp-proxy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mcp-proxy.d.ts","sourceRoot":"","sources":["../src/mcp-proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,QAAA,MAAM,qBAAqB;;;;;;kBAuBzB,CAAC;AAEH;;;;;;;GAOG;AACH,QAAA,MAAM,oBAAoB;;;;;;;;;;;kBAmBxB,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;mBAG5B,CAAC;AAEF,sDAAsD;AACtD,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E,4DAA4D;AAC5D,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,kEAAkE;AAClE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,CAE9D;AAED,wDAAwD;AACxD,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,OAAO,GACX,UAAU,CAAC,OAAO,gBAAgB,CAAC,SAAS,CAAC,CAE/C"}
package/dist/mcp-proxy.js DELETED
@@ -1,133 +0,0 @@
1
- /**
2
- * `mcpProxies` — Guuey hosted overlay shape for managed MCP relays.
3
- *
4
- * Relocated 2026-04-21 from `@ggui-ai/protocol/types/mcp-proxy.ts` as
5
- * part of the OSS split §8.2 classification fix. These types describe
6
- * a GUUEY HOSTING CONCEPT (a managed proxy that relays MCP calls with
7
- * upstream OAuth linking), not a vendor-neutral protocol shape, and
8
- * therefore belong in the closed `@guuey/config`
9
- * package alongside the rest of `guuey.json`.
10
- *
11
- * ## The classification decision
12
- *
13
- * `mcpProxies` is the declaration block a developer adds to
14
- * `guuey.json` to tell Guuey hosting: *"on behalf of this project,
15
- * relay these external MCP providers, using this OAuth linking
16
- * config, exposing these discovered servers."* That is
17
- * platform-layer plumbing — Guuey runs the relay, handles the
18
- * credential storage, dispatches the discovery — and it does not
19
- * describe anything an OSS-only `ggui` deployment emits or consumes.
20
- *
21
- * Per §8.2: the OSS `ggui` server does NOT read `guuey.json`.
22
- * Consumers that need overlay values (the closed `guuey` CLI,
23
- * Guuey-hosted Lambdas, the Guuey-internal control-plane UI) are
24
- * the only call sites allowed to import from this package. Open
25
- * packages that historically read `mcpProxies` (`@ggui-ai/server`'s
26
- * Claude-passthrough feature) retain their feature code but inline
27
- * the minimal structural shape they actually use — it stays a
28
- * Guuey-platform plumbing path, not a protocol contract.
29
- *
30
- * ## Scope of this module
31
- *
32
- * - {@link McpProxyLinkingConfig} — upstream OAuth config for
33
- * proxies that relay calls on behalf of an external account
34
- * (e.g. Claude.ai). Keys surface in the Guuey control plane's
35
- * credential-linking UI.
36
- * - {@link McpProxyConfig} — a single proxy's discovery + proxy
37
- * URL pattern + optional server filter + optional linking block.
38
- * - {@link McpProxiesConfig} — the top-level record keyed by
39
- * proxy id (`claude_ai`, `guuey`, future `omo`...). Exactly the
40
- * shape `guuey.json#mcpProxies` carries.
41
- *
42
- * ## Vendor-neutral constants stay in `@ggui-ai/protocol`
43
- *
44
- * Claude.ai-specific constants and discovery-response wire types
45
- * (`CLAUDE_AI_*`, `DiscoveredMcpServer`, `ClaudeAiDiscoveryResponse`)
46
- * remain in `@ggui-ai/protocol/types/mcp-proxy.ts` — those describe
47
- * Anthropic's public API, not Guuey-overlay config.
48
- *
49
- * ## Strictness
50
- *
51
- * Zod validation matches the rest of `guuey.json`: strict objects,
52
- * non-empty strings, URL validation on linking endpoints. Unknown
53
- * keys on nested objects fail parse (prevents silent drift toward
54
- * a "what else can we stuff into guuey.json" shape).
55
- */
56
- import { z } from 'zod';
57
- /**
58
- * OAuth linking config for proxies that relay on behalf of an
59
- * external account. Omit for proxies where Guuey session auth is
60
- * the only identity needed (e.g. a Guuey-native proxy).
61
- */
62
- const McpProxyLinkingSchema = z.strictObject({
63
- /** OAuth authorize endpoint. */
64
- authUrl: z.url(),
65
- /** OAuth token endpoint. */
66
- tokenUrl: z.url(),
67
- /**
68
- * OAuth scopes to request. Empty array means "use the upstream's
69
- * default scope set"; it does NOT mean "no scopes at all."
70
- */
71
- scopes: z.array(z.string().min(1)),
72
- /**
73
- * OAuth client_id to use. When omitted, the proxy uses a
74
- * well-known public client_id (e.g. Claude Code's registered
75
- * client for Claude.ai).
76
- */
77
- clientId: z.string().min(1).optional(),
78
- /**
79
- * Manual redirect URL for environments without a localhost
80
- * callback. The upstream AS redirects here and renders the
81
- * authorization code for the user to copy-paste. Used by
82
- * production web flows.
83
- */
84
- manualRedirectUrl: z.url().optional(),
85
- });
86
- /**
87
- * Configuration for a single MCP proxy in `guuey.json#mcpProxies`.
88
- *
89
- * `discovery` + `proxy` are both URL-valued, but `proxy` is a URL
90
- * PATTERN (contains `{server_id}` which is substituted at call
91
- * time). Both are validated as URLs — `{server_id}` is accepted
92
- * by URL parsers as opaque path segment.
93
- */
94
- const McpProxyConfigSchema = z.strictObject({
95
- /** Discovery URL — fetches available MCP servers for this proxy. */
96
- discovery: z.url(),
97
- /**
98
- * Proxy URL pattern — `{server_id}` is substituted with the
99
- * discovered server id at relay time. Validated as URL; the
100
- * placeholder survives URL parsing as an opaque path segment.
101
- */
102
- proxy: z.url(),
103
- /**
104
- * OAuth linking config for upstream account linking. Omit for
105
- * Guuey-native proxies where the session token is sufficient.
106
- */
107
- linking: McpProxyLinkingSchema.optional(),
108
- /**
109
- * Filter which discovered servers to expose, matched by display
110
- * name. When omitted, all discovered servers are exposed.
111
- */
112
- servers: z.array(z.string().min(1)).optional(),
113
- });
114
- /**
115
- * The `mcpProxies` section of `guuey.json`. Keys are proxy
116
- * identifiers (`claude_ai`, `guuey`, future `omo`, …).
117
- *
118
- * Record shape intentionally — new proxy ids are additive; a fixed
119
- * literal union here would force a schema change every time a new
120
- * hosted-relay integration lands.
121
- */
122
- export const McpProxiesSchema = z.record(z.string().min(1), McpProxyConfigSchema);
123
- /**
124
- * Parse a raw JSON value into a validated {@link McpProxiesConfig}.
125
- * Throws a `ZodError` on invalid input.
126
- */
127
- export function parseMcpProxies(raw) {
128
- return McpProxiesSchema.parse(raw);
129
- }
130
- /** Safe-parse variant — see {@link parseMcpProxies}. */
131
- export function safeParseMcpProxies(raw) {
132
- return McpProxiesSchema.safeParse(raw);
133
- }
@@ -1,173 +0,0 @@
1
- /**
2
- * `mcpServers` — Guuey hosted overlay shape for relayed MCP server
3
- * declarations.
4
- *
5
- * Relocated 2026-04-21 from `@ggui-ai/protocol/types/credential.ts`
6
- * as part of the OSS split §8.2 classification fix (mirror of the
7
- * 2026-04-21 `mcp-proxy` split). The `McpServerAuthConfig` type
8
- * previously lived in the open protocol package with a docstring
9
- * that said "Auth config in guuey.json mcpServers entries" — an
10
- * overlay-shape type in an open package, exactly the pattern the
11
- * mcp-proxy split closed.
12
- *
13
- * ## The classification decision
14
- *
15
- * `mcpServers` is the declaration block a developer adds to
16
- * `guuey.json` to tell Guuey hosting: *"for this project, relay
17
- * these HTTP MCP servers through the Guuey bridge, authenticating
18
- * each via the credential stored under this `serviceId`."* That is
19
- * platform-layer plumbing — the Guuey bridge registers the
20
- * declaration with the Guuey-hosted WebSocket gateway, and the
21
- * Guuey mcp-proxy Lambda resolves `auth.serviceId` against the
22
- * platform's UserCredential store. An OSS-only `ggui serve`
23
- * deployment has no analog for `auth.serviceId` because there is no
24
- * Guuey credential store.
25
- *
26
- * Per §8.2: the OSS `ggui` server does NOT read `guuey.json`.
27
- * Consumers that need this overlay value (the closed `guuey` CLI's
28
- * `guuey dev` command, the closed `@guuey/bridge` package, Guuey-
29
- * hosted Lambdas) are the only call sites allowed to import from
30
- * this package. Open packages that historically read
31
- * `McpServerAuthConfig` (`@ggui-ai/server`'s auth-relay code) now
32
- * inline the minimal structural shape they actually use.
33
- *
34
- * ## Scope of this module
35
- *
36
- * - {@link CredentialInjection} + {@link CredentialInjectionConfig}
37
- * — runtime injection-mode descriptors, used here as
38
- * `McpServerAuth.injection` and also exported from
39
- * `@ggui-ai/protocol/types/credential.ts` for cloud-side runtime
40
- * consumers. The overlap is intentional and minor (10 lines of
41
- * literal-union type) — duplicating inline keeps this private
42
- * package dep-minimal (zod-only). If the two ever drift, the
43
- * consolidation fix is to add `@ggui-ai/protocol` as a workspace
44
- * dep here; today the duplication is cheaper than that cross-
45
- * boundary edge.
46
- * - {@link McpServerAuthConfig} — auth block on a single
47
- * `mcpServers` entry. `serviceId` references the Guuey
48
- * credential store; `preInject` + `injection` tune how the relay
49
- * writes the placeholder.
50
- * - {@link McpServerEntryConfig} — a single mcpServers entry
51
- * (`{ url, auth? }`). `url` is the HTTP MCP server endpoint.
52
- * - {@link McpServersConfig} — the top-level record keyed by MCP
53
- * server name (`gmail`, `calendar`, future `slack`, …). Exactly
54
- * the shape `guuey.json#mcpServers` carries.
55
- *
56
- * ## Strictness
57
- *
58
- * Zod validation matches the rest of `guuey.json`: strict objects,
59
- * non-empty strings, URL validation on `url`. Unknown keys on
60
- * nested objects fail parse (prevents silent drift toward a "what
61
- * else can we stuff into guuey.json" shape).
62
- */
63
- import { z } from 'zod';
64
- /**
65
- * Injection mode — how the Guuey mcp-proxy splices the resolved
66
- * credential into the outbound HTTP request to the upstream MCP
67
- * server. Duplicated minor from
68
- * `@ggui-ai/protocol/types/credential.ts#CredentialInjection`; see
69
- * module docstring for the duplication rationale.
70
- */
71
- declare const CredentialInjectionSchema: z.ZodEnum<{
72
- bearer_header: "bearer_header";
73
- api_key_header: "api_key_header";
74
- query_param: "query_param";
75
- custom_header: "custom_header";
76
- }>;
77
- /** Full injection config — `mode` + per-mode tunables. */
78
- declare const CredentialInjectionConfigSchema: z.ZodObject<{
79
- mode: z.ZodEnum<{
80
- bearer_header: "bearer_header";
81
- api_key_header: "api_key_header";
82
- query_param: "query_param";
83
- custom_header: "custom_header";
84
- }>;
85
- headerName: z.ZodOptional<z.ZodString>;
86
- paramName: z.ZodOptional<z.ZodString>;
87
- }, z.core.$strict>;
88
- /**
89
- * Auth block on a single `mcpServers` entry. All fields are
90
- * optional at the block level — a server without `auth` is relayed
91
- * without credential injection (public MCP endpoint).
92
- */
93
- declare const McpServerAuthSchema: z.ZodObject<{
94
- serviceId: z.ZodString;
95
- preInject: z.ZodOptional<z.ZodBoolean>;
96
- injection: z.ZodOptional<z.ZodObject<{
97
- mode: z.ZodEnum<{
98
- bearer_header: "bearer_header";
99
- api_key_header: "api_key_header";
100
- query_param: "query_param";
101
- custom_header: "custom_header";
102
- }>;
103
- headerName: z.ZodOptional<z.ZodString>;
104
- paramName: z.ZodOptional<z.ZodString>;
105
- }, z.core.$strict>>;
106
- scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
107
- }, z.core.$strict>;
108
- /**
109
- * A single `mcpServers` entry. `url` is the HTTP MCP server
110
- * endpoint; `auth` scopes the credential injection.
111
- */
112
- declare const McpServerEntrySchema: z.ZodObject<{
113
- url: z.ZodURL;
114
- auth: z.ZodOptional<z.ZodObject<{
115
- serviceId: z.ZodString;
116
- preInject: z.ZodOptional<z.ZodBoolean>;
117
- injection: z.ZodOptional<z.ZodObject<{
118
- mode: z.ZodEnum<{
119
- bearer_header: "bearer_header";
120
- api_key_header: "api_key_header";
121
- query_param: "query_param";
122
- custom_header: "custom_header";
123
- }>;
124
- headerName: z.ZodOptional<z.ZodString>;
125
- paramName: z.ZodOptional<z.ZodString>;
126
- }, z.core.$strict>>;
127
- scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
128
- }, z.core.$strict>>;
129
- }, z.core.$strict>;
130
- /**
131
- * The `mcpServers` section of `guuey.json`. Keys are MCP server
132
- * display names (`gmail`, `calendar`, future `slack`, …) —
133
- * arbitrary strings, by design. New servers are additive; a fixed
134
- * literal union would force a schema change every time a new MCP
135
- * server integration lands.
136
- */
137
- export declare const McpServersSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
138
- url: z.ZodURL;
139
- auth: z.ZodOptional<z.ZodObject<{
140
- serviceId: z.ZodString;
141
- preInject: z.ZodOptional<z.ZodBoolean>;
142
- injection: z.ZodOptional<z.ZodObject<{
143
- mode: z.ZodEnum<{
144
- bearer_header: "bearer_header";
145
- api_key_header: "api_key_header";
146
- query_param: "query_param";
147
- custom_header: "custom_header";
148
- }>;
149
- headerName: z.ZodOptional<z.ZodString>;
150
- paramName: z.ZodOptional<z.ZodString>;
151
- }, z.core.$strict>>;
152
- scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
153
- }, z.core.$strict>>;
154
- }, z.core.$strict>>;
155
- /** Runtime injection-mode descriptor type. */
156
- export type CredentialInjection = z.infer<typeof CredentialInjectionSchema>;
157
- /** Injection-config block type. */
158
- export type CredentialInjectionConfig = z.infer<typeof CredentialInjectionConfigSchema>;
159
- /** Auth-block type on an `mcpServers` entry. */
160
- export type McpServerAuthConfig = z.infer<typeof McpServerAuthSchema>;
161
- /** Single-entry type inside the `mcpServers` record. */
162
- export type McpServerEntryConfig = z.infer<typeof McpServerEntrySchema>;
163
- /** Full `mcpServers` overlay type derived from the zod schema. */
164
- export type McpServersConfig = z.infer<typeof McpServersSchema>;
165
- /**
166
- * Parse a raw JSON value into a validated {@link McpServersConfig}.
167
- * Throws a `ZodError` on invalid input.
168
- */
169
- export declare function parseMcpServers(raw: unknown): McpServersConfig;
170
- /** Safe-parse variant — see {@link parseMcpServers}. */
171
- export declare function safeParseMcpServers(raw: unknown): ReturnType<typeof McpServersSchema.safeParse>;
172
- export {};
173
- //# sourceMappingURL=mcp-servers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mcp-servers.d.ts","sourceRoot":"","sources":["../src/mcp-servers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;GAMG;AACH,QAAA,MAAM,yBAAyB;;;;;EAK7B,CAAC;AAEH,0DAA0D;AAC1D,QAAA,MAAM,+BAA+B;;;;;;;;;kBAMnC,CAAC;AAEH;;;;GAIG;AACH,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;kBA4BvB,CAAC;AAEH;;;GAGG;AACH,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;kBAKxB,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;mBAG5B,CAAC;AAEF,8CAA8C;AAC9C,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,mCAAmC;AACnC,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,+BAA+B,CACvC,CAAC;AAEF,gDAAgD;AAChD,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEtE,wDAAwD;AACxD,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE,kEAAkE;AAClE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,CAE9D;AAED,wDAAwD;AACxD,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,OAAO,GACX,UAAU,CAAC,OAAO,gBAAgB,CAAC,SAAS,CAAC,CAE/C"}
@@ -1,147 +0,0 @@
1
- /**
2
- * `mcpServers` — Guuey hosted overlay shape for relayed MCP server
3
- * declarations.
4
- *
5
- * Relocated 2026-04-21 from `@ggui-ai/protocol/types/credential.ts`
6
- * as part of the OSS split §8.2 classification fix (mirror of the
7
- * 2026-04-21 `mcp-proxy` split). The `McpServerAuthConfig` type
8
- * previously lived in the open protocol package with a docstring
9
- * that said "Auth config in guuey.json mcpServers entries" — an
10
- * overlay-shape type in an open package, exactly the pattern the
11
- * mcp-proxy split closed.
12
- *
13
- * ## The classification decision
14
- *
15
- * `mcpServers` is the declaration block a developer adds to
16
- * `guuey.json` to tell Guuey hosting: *"for this project, relay
17
- * these HTTP MCP servers through the Guuey bridge, authenticating
18
- * each via the credential stored under this `serviceId`."* That is
19
- * platform-layer plumbing — the Guuey bridge registers the
20
- * declaration with the Guuey-hosted WebSocket gateway, and the
21
- * Guuey mcp-proxy Lambda resolves `auth.serviceId` against the
22
- * platform's UserCredential store. An OSS-only `ggui serve`
23
- * deployment has no analog for `auth.serviceId` because there is no
24
- * Guuey credential store.
25
- *
26
- * Per §8.2: the OSS `ggui` server does NOT read `guuey.json`.
27
- * Consumers that need this overlay value (the closed `guuey` CLI's
28
- * `guuey dev` command, the closed `@guuey/bridge` package, Guuey-
29
- * hosted Lambdas) are the only call sites allowed to import from
30
- * this package. Open packages that historically read
31
- * `McpServerAuthConfig` (`@ggui-ai/server`'s auth-relay code) now
32
- * inline the minimal structural shape they actually use.
33
- *
34
- * ## Scope of this module
35
- *
36
- * - {@link CredentialInjection} + {@link CredentialInjectionConfig}
37
- * — runtime injection-mode descriptors, used here as
38
- * `McpServerAuth.injection` and also exported from
39
- * `@ggui-ai/protocol/types/credential.ts` for cloud-side runtime
40
- * consumers. The overlap is intentional and minor (10 lines of
41
- * literal-union type) — duplicating inline keeps this private
42
- * package dep-minimal (zod-only). If the two ever drift, the
43
- * consolidation fix is to add `@ggui-ai/protocol` as a workspace
44
- * dep here; today the duplication is cheaper than that cross-
45
- * boundary edge.
46
- * - {@link McpServerAuthConfig} — auth block on a single
47
- * `mcpServers` entry. `serviceId` references the Guuey
48
- * credential store; `preInject` + `injection` tune how the relay
49
- * writes the placeholder.
50
- * - {@link McpServerEntryConfig} — a single mcpServers entry
51
- * (`{ url, auth? }`). `url` is the HTTP MCP server endpoint.
52
- * - {@link McpServersConfig} — the top-level record keyed by MCP
53
- * server name (`gmail`, `calendar`, future `slack`, …). Exactly
54
- * the shape `guuey.json#mcpServers` carries.
55
- *
56
- * ## Strictness
57
- *
58
- * Zod validation matches the rest of `guuey.json`: strict objects,
59
- * non-empty strings, URL validation on `url`. Unknown keys on
60
- * nested objects fail parse (prevents silent drift toward a "what
61
- * else can we stuff into guuey.json" shape).
62
- */
63
- import { z } from 'zod';
64
- /**
65
- * Injection mode — how the Guuey mcp-proxy splices the resolved
66
- * credential into the outbound HTTP request to the upstream MCP
67
- * server. Duplicated minor from
68
- * `@ggui-ai/protocol/types/credential.ts#CredentialInjection`; see
69
- * module docstring for the duplication rationale.
70
- */
71
- const CredentialInjectionSchema = z.enum([
72
- 'bearer_header',
73
- 'api_key_header',
74
- 'query_param',
75
- 'custom_header',
76
- ]);
77
- /** Full injection config — `mode` + per-mode tunables. */
78
- const CredentialInjectionConfigSchema = z.strictObject({
79
- mode: CredentialInjectionSchema,
80
- /** Header name for `api_key_header` / `custom_header`. Default: `X-API-Key`. */
81
- headerName: z.string().min(1).optional(),
82
- /** Query param name for `query_param`. Default: `api_key`. */
83
- paramName: z.string().min(1).optional(),
84
- });
85
- /**
86
- * Auth block on a single `mcpServers` entry. All fields are
87
- * optional at the block level — a server without `auth` is relayed
88
- * without credential injection (public MCP endpoint).
89
- */
90
- const McpServerAuthSchema = z.strictObject({
91
- /**
92
- * Service ID referenced against the Guuey platform's
93
- * UserCredential store. This is a Guuey-platform concept — an
94
- * OSS-only deployment has no equivalent lookup.
95
- */
96
- serviceId: z.string().min(1),
97
- /**
98
- * Pre-inject placeholder before the first upstream request
99
- * (skips the 401 → consent → retry dance for cases where the
100
- * user has already linked the credential). Default: `false`.
101
- */
102
- preInject: z.boolean().optional(),
103
- /**
104
- * Override the injection mode. Falls back to the
105
- * `McpServiceConfig` table entry keyed by `serviceId`, which
106
- * defaults to `bearer_header`.
107
- */
108
- injection: CredentialInjectionConfigSchema.optional(),
109
- /**
110
- * Optional OAuth scope hint forwarded to the hosted bridge at
111
- * connect time. The platform consumes this when minting tokens
112
- * against the upstream MCP server. Preserved here (2026-04-21)
113
- * for wire-compat with `@guuey/bridge`'s existing inline shape,
114
- * which flows `auth.scopes` through the bridge WebSocket config
115
- * message.
116
- */
117
- scopes: z.array(z.string().min(1)).optional(),
118
- });
119
- /**
120
- * A single `mcpServers` entry. `url` is the HTTP MCP server
121
- * endpoint; `auth` scopes the credential injection.
122
- */
123
- const McpServerEntrySchema = z.strictObject({
124
- /** HTTP MCP server endpoint. */
125
- url: z.url(),
126
- /** Optional auth block — omit for public endpoints. */
127
- auth: McpServerAuthSchema.optional(),
128
- });
129
- /**
130
- * The `mcpServers` section of `guuey.json`. Keys are MCP server
131
- * display names (`gmail`, `calendar`, future `slack`, …) —
132
- * arbitrary strings, by design. New servers are additive; a fixed
133
- * literal union would force a schema change every time a new MCP
134
- * server integration lands.
135
- */
136
- export const McpServersSchema = z.record(z.string().min(1), McpServerEntrySchema);
137
- /**
138
- * Parse a raw JSON value into a validated {@link McpServersConfig}.
139
- * Throws a `ZodError` on invalid input.
140
- */
141
- export function parseMcpServers(raw) {
142
- return McpServersSchema.parse(raw);
143
- }
144
- /** Safe-parse variant — see {@link parseMcpServers}. */
145
- export function safeParseMcpServers(raw) {
146
- return McpServersSchema.safeParse(raw);
147
- }