@ggui-ai/protocol 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 +16 -16
- package/dist/envelope-adapters.d.ts +6 -5
- package/dist/envelope-adapters.d.ts.map +1 -1
- package/dist/envelope-adapters.js +3 -3
- package/dist/envelopes/builders.d.ts +6 -32
- package/dist/envelopes/builders.d.ts.map +1 -1
- package/dist/envelopes/builders.js +3 -25
- package/dist/errors/version-mismatch.d.ts +1 -1
- package/dist/errors/version-mismatch.js +1 -1
- package/dist/gadgets/resolve-app-gadgets.d.ts +10 -0
- package/dist/gadgets/resolve-app-gadgets.d.ts.map +1 -0
- package/dist/gadgets/resolve-app-gadgets.js +19 -0
- package/dist/gadgets/resolve-contract-gadgets.d.ts +6 -6
- package/dist/gadgets/resolve-contract-gadgets.js +5 -5
- package/dist/gadgets/stdlib-gadgets.d.ts +1 -1
- package/dist/gadgets/stdlib-gadgets.d.ts.map +1 -1
- package/dist/gadgets/stdlib-gadgets.js +43 -22
- package/dist/iframe-bridge.d.ts +4 -43
- package/dist/iframe-bridge.d.ts.map +1 -1
- package/dist/iframe-bridge.js +4 -141
- package/dist/index.d.ts +60 -62
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +66 -61
- package/dist/integrations/mcp-apps.d.ts +83 -38
- package/dist/integrations/mcp-apps.d.ts.map +1 -1
- package/dist/integrations/mcp-apps.js +98 -52
- package/dist/recommended-prompts.d.ts +1 -1
- package/dist/recommended-prompts.js +1 -1
- package/dist/registry/blueprint-key.d.ts +3 -0
- package/dist/registry/blueprint-key.d.ts.map +1 -1
- package/dist/registry/blueprint-key.js +9 -0
- package/dist/registry/blueprint-stamp.d.ts +12 -0
- package/dist/registry/blueprint-stamp.d.ts.map +1 -0
- package/dist/registry/blueprint-stamp.js +12 -0
- package/dist/registry/canonicalize-contract.d.ts +31 -2
- package/dist/registry/canonicalize-contract.d.ts.map +1 -1
- package/dist/registry/canonicalize-contract.js +125 -13
- package/dist/registry/portable-blueprint.d.ts +64 -0
- package/dist/registry/portable-blueprint.d.ts.map +1 -0
- package/dist/registry/portable-blueprint.js +103 -0
- package/dist/registry/summarize-contract.d.ts +7 -2
- package/dist/registry/summarize-contract.d.ts.map +1 -1
- package/dist/registry/summarize-contract.js +12 -3
- package/dist/registry/variant-key.d.ts +17 -0
- package/dist/registry/variant-key.d.ts.map +1 -0
- package/dist/registry/variant-key.js +22 -0
- package/dist/schema-learning/derive-contract.d.ts +2 -2
- package/dist/schema-learning/derive-contract.js +2 -2
- package/dist/schema-learning/merge.d.ts.map +1 -1
- package/dist/schema-learning/merge.js +3 -2
- package/dist/schemas/app-theme.d.ts +38 -0
- package/dist/schemas/app-theme.d.ts.map +1 -0
- package/dist/schemas/app-theme.js +43 -0
- package/dist/schemas/blueprint.d.ts +30 -11
- package/dist/schemas/blueprint.d.ts.map +1 -1
- package/dist/schemas/blueprint.js +62 -26
- package/dist/schemas/data-contract.d.ts +28 -30
- package/dist/schemas/data-contract.d.ts.map +1 -1
- package/dist/schemas/data-contract.js +26 -26
- package/dist/schemas/handshake-suggestion.d.ts +2 -4
- package/dist/schemas/handshake-suggestion.d.ts.map +1 -1
- package/dist/schemas/handshake-suggestion.js +5 -14
- package/dist/schemas/mcp.d.ts +240 -58
- package/dist/schemas/mcp.d.ts.map +1 -1
- package/dist/schemas/mcp.js +285 -93
- package/dist/schemas/ops-blueprint.d.ts +12 -12
- package/dist/schemas/ops-blueprint.d.ts.map +1 -1
- package/dist/schemas/ops-blueprint.js +14 -24
- package/dist/screen-blueprints/define.d.ts +2 -2
- package/dist/screen-blueprints/match.d.ts +12 -7
- package/dist/screen-blueprints/match.d.ts.map +1 -1
- package/dist/screen-blueprints/match.js +7 -5
- package/dist/screen-blueprints/types.d.ts +14 -18
- package/dist/screen-blueprints/types.d.ts.map +1 -1
- package/dist/transport/websocket.d.ts +5 -26
- package/dist/transport/websocket.d.ts.map +1 -1
- package/dist/types/app-config.d.ts +0 -1
- package/dist/types/app-config.d.ts.map +1 -1
- package/dist/types/auth.d.ts +1 -46
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/types/blueprint-source.d.ts +123 -0
- package/dist/types/blueprint-source.d.ts.map +1 -0
- package/dist/types/blueprint-source.js +126 -0
- package/dist/types/blueprint.d.ts +25 -18
- package/dist/types/blueprint.d.ts.map +1 -1
- package/dist/types/contract-inference.d.ts +2 -43
- package/dist/types/contract-inference.d.ts.map +1 -1
- package/dist/types/data-contract.d.ts +59 -344
- package/dist/types/data-contract.d.ts.map +1 -1
- package/dist/types/data-contract.js +5 -12
- package/dist/types/events.d.ts +31 -69
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/{render-event.d.ts → ggui-session-event.d.ts} +15 -15
- package/dist/types/ggui-session-event.d.ts.map +1 -0
- package/dist/types/{render-event.js → ggui-session-event.js} +5 -5
- package/dist/types/handshake-suggestion.d.ts +60 -40
- package/dist/types/handshake-suggestion.d.ts.map +1 -1
- package/dist/types/host-context.d.ts +8 -8
- package/dist/types/host-context.d.ts.map +1 -1
- package/dist/types/host-context.js +5 -5
- package/dist/types/invoke.d.ts +1 -13
- package/dist/types/invoke.d.ts.map +1 -1
- package/dist/types/{canvas-lifecycle.d.ts → lifecycle.d.ts} +35 -37
- package/dist/types/lifecycle.d.ts.map +1 -0
- package/dist/types/{canvas-lifecycle.js → lifecycle.js} +12 -14
- package/dist/types/live-channel.d.ts +48 -104
- package/dist/types/live-channel.d.ts.map +1 -1
- package/dist/types/llm.d.ts +13 -24
- package/dist/types/llm.d.ts.map +1 -1
- package/dist/types/llm.js +23 -53
- package/dist/types/mcp.d.ts +55 -176
- package/dist/types/mcp.d.ts.map +1 -1
- package/dist/types/mcp.js +2 -2
- package/dist/types/oauth-user-id.d.ts +12 -0
- package/dist/types/oauth-user-id.d.ts.map +1 -0
- package/dist/types/oauth-user-id.js +10 -0
- package/dist/types/portable-blueprint.d.ts +53 -0
- package/dist/types/portable-blueprint.d.ts.map +1 -0
- package/dist/types/portable-blueprint.js +8 -0
- package/dist/types/{session.d.ts → render.d.ts} +51 -53
- package/dist/types/render.d.ts.map +1 -0
- package/dist/types/thread.d.ts.map +1 -1
- package/dist/types/thread.js +3 -3
- package/dist/types/ui-generator.d.ts +5 -46
- package/dist/types/ui-generator.d.ts.map +1 -1
- package/dist/types/ui-generator.js +1 -53
- package/dist/validation/ajv-runtime.d.ts +3 -3
- package/dist/validation/ajv-runtime.d.ts.map +1 -1
- package/dist/validation/ajv-runtime.js +6 -5
- package/dist/validation/contract-validator.d.ts +23 -22
- package/dist/validation/contract-validator.d.ts.map +1 -1
- package/dist/validation/contract-validator.js +28 -26
- package/dist/validation/cross-references.d.ts +3 -3
- package/dist/validation/cross-references.js +3 -3
- package/dist/validation/hygiene-rules.d.ts +13 -10
- package/dist/validation/hygiene-rules.d.ts.map +1 -1
- package/dist/validation/hygiene-rules.js +20 -14
- package/dist/validation/is-record.d.ts +17 -0
- package/dist/validation/is-record.d.ts.map +1 -0
- package/dist/validation/is-record.js +18 -0
- package/dist/validation/lint-contract.d.ts +9 -8
- package/dist/validation/lint-contract.d.ts.map +1 -1
- package/dist/validation/lint-contract.js +89 -26
- package/dist/validation/name-invariants.d.ts +4 -4
- package/dist/validation/name-invariants.js +4 -4
- package/dist/validation/reserved-channels.d.ts +43 -46
- package/dist/validation/reserved-channels.d.ts.map +1 -1
- package/dist/validation/reserved-channels.js +14 -177
- package/dist/validation/resolve-stream-channel.d.ts +3 -9
- package/dist/validation/resolve-stream-channel.d.ts.map +1 -1
- package/dist/validation/resolve-stream-channel.js +3 -4
- package/dist/validation/sanitize-error.d.ts +10 -9
- package/dist/validation/sanitize-error.d.ts.map +1 -1
- package/dist/validation/sanitize-error.js +19 -18
- package/dist/validation/schema-compat-invariants.d.ts +1 -1
- package/dist/validation/schema-compat-invariants.js +3 -3
- package/dist/validation/schema-meta-validation.d.ts +21 -8
- package/dist/validation/schema-meta-validation.d.ts.map +1 -1
- package/dist/validation/schema-meta-validation.js +28 -14
- package/dist/validation/schema-subset.d.ts +9 -8
- package/dist/validation/schema-subset.d.ts.map +1 -1
- package/dist/validation/ui-security.d.ts +0 -17
- package/dist/validation/ui-security.d.ts.map +1 -1
- package/dist/validation/ui-security.js +17 -22
- package/dist/validation/zod-to-json-schema.d.ts +1 -1
- package/dist/validation/zod-to-json-schema.d.ts.map +1 -1
- package/dist/validation/zod-to-json-schema.js +4 -3
- package/dist/version.d.ts +783 -9
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +782 -8
- package/package.json +2 -2
- package/dist/bridge/invoke-agent.d.ts +0 -65
- package/dist/bridge/invoke-agent.d.ts.map +0 -1
- package/dist/bridge/invoke-agent.js +0 -113
- package/dist/stream/stream-parser.d.ts +0 -62
- package/dist/stream/stream-parser.d.ts.map +0 -1
- package/dist/stream/stream-parser.js +0 -199
- package/dist/types/canvas-lifecycle.d.ts.map +0 -1
- package/dist/types/credential.d.ts +0 -41
- package/dist/types/credential.d.ts.map +0 -1
- package/dist/types/credential.js +0 -32
- package/dist/types/data-bindings.d.ts +0 -322
- package/dist/types/data-bindings.d.ts.map +0 -1
- package/dist/types/data-bindings.js +0 -29
- package/dist/types/feedback.d.ts +0 -22
- package/dist/types/feedback.d.ts.map +0 -1
- package/dist/types/feedback.js +0 -7
- package/dist/types/mcp-proxy.d.ts +0 -67
- package/dist/types/mcp-proxy.d.ts.map +0 -1
- package/dist/types/mcp-proxy.js +0 -46
- package/dist/types/openrouter-models.d.ts +0 -23
- package/dist/types/openrouter-models.d.ts.map +0 -1
- package/dist/types/openrouter-models.js +0 -4843
- package/dist/types/region.d.ts +0 -26
- package/dist/types/region.d.ts.map +0 -1
- package/dist/types/region.js +0 -36
- package/dist/types/render-event.d.ts.map +0 -1
- package/dist/types/session.d.ts.map +0 -1
- /package/dist/types/{session.js → render.js} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ggui-ai/protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-rc.0",
|
|
4
4
|
"description": "ggui protocol types — events, renders, WebSocket, MCP, LLM models",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
},
|
|
105
105
|
"author": "ggui contributors <hello@ggui.ai>",
|
|
106
106
|
"scripts": {
|
|
107
|
-
"build": "tsc && node ../scripts/fix-esm-imports.mjs dist",
|
|
107
|
+
"build": "rm -rf dist && tsc && node ../scripts/fix-esm-imports.mjs dist",
|
|
108
108
|
"dev": "tsc --watch",
|
|
109
109
|
"typecheck": "tsc --noEmit",
|
|
110
110
|
"sync-check": "tsx src/schemas/sync-check.ts",
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent invocation helper for the bridge agent pattern.
|
|
3
|
-
*
|
|
4
|
-
* Cloud-provider agnostic — uses standard fetch API. Can be used by any
|
|
5
|
-
* platform implementation (serverless function, self-hosted server, etc.) that needs
|
|
6
|
-
* to forward messages to an agent's HTTP endpoint.
|
|
7
|
-
*
|
|
8
|
-
* Handles both JSON and SSE streaming responses using stream-parser.
|
|
9
|
-
*/
|
|
10
|
-
import type { InterfaceContext } from '../types/interface-context';
|
|
11
|
-
import type { ConversationTurn } from '../types/session';
|
|
12
|
-
export interface InvokeAgentOptions {
|
|
13
|
-
/** The agent's HTTP endpoint URL */
|
|
14
|
-
connectorEndpointUrl: string;
|
|
15
|
-
/** Conversation envelope id (omit for 'start' flow — agent mints one) */
|
|
16
|
-
hostSessionId?: string;
|
|
17
|
-
/** Invocation type: 'start' begins a fresh conversation, 'message' continues one */
|
|
18
|
-
type: 'start' | 'message';
|
|
19
|
-
/** User message text */
|
|
20
|
-
message?: string;
|
|
21
|
-
/** App ID to include in the request */
|
|
22
|
-
appId: string;
|
|
23
|
-
/** Client interface context (device, viewport, shell type) */
|
|
24
|
-
interfaceContext?: InterfaceContext;
|
|
25
|
-
/** Conversation history for multi-turn context */
|
|
26
|
-
conversationHistory?: ConversationTurn[];
|
|
27
|
-
/** Callback to forward streaming text chunks to the user */
|
|
28
|
-
onStreamChunk?: (text: string) => Promise<void>;
|
|
29
|
-
/** Callback when the stream is done */
|
|
30
|
-
onStreamDone?: () => Promise<void>;
|
|
31
|
-
/** Callback when the agent returns a hostSessionId (start flow, SSE) */
|
|
32
|
-
onHostSessionId?: (hostSessionId: string) => Promise<void>;
|
|
33
|
-
/** Callback for structured agent events (stream, push, etc.) from the events array */
|
|
34
|
-
onAgentEvent?: (event: {
|
|
35
|
-
type: string;
|
|
36
|
-
payload: unknown;
|
|
37
|
-
}) => Promise<void>;
|
|
38
|
-
/** Request timeout in milliseconds (default: 90000) */
|
|
39
|
-
timeoutMs?: number;
|
|
40
|
-
}
|
|
41
|
-
export interface InvokeAgentResult {
|
|
42
|
-
/** Conversation envelope id returned by the agent (start flow) */
|
|
43
|
-
hostSessionId?: string;
|
|
44
|
-
/** Full text response (JSON responses only — streaming uses callbacks) */
|
|
45
|
-
text?: string;
|
|
46
|
-
/** Whether the response was streamed via SSE */
|
|
47
|
-
streamed: boolean;
|
|
48
|
-
/** Outcome status */
|
|
49
|
-
status: 'ok' | 'error';
|
|
50
|
-
/** Error message if status is 'error' */
|
|
51
|
-
error?: string;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Invoke an agent's HTTP endpoint and handle the response.
|
|
55
|
-
*
|
|
56
|
-
* Supports two response formats:
|
|
57
|
-
* 1. JSON — returns the parsed body as InvokeAgentResult
|
|
58
|
-
* 2. SSE stream — forwards chunks via callbacks, returns when stream ends
|
|
59
|
-
*
|
|
60
|
-
* The request body shape follows the ggui bridge protocol:
|
|
61
|
-
* - start: { type: 'start', message, appId, interfaceContext }
|
|
62
|
-
* - message: { type: 'message', hostSessionId, appId, message, conversationHistory, interfaceContext }
|
|
63
|
-
*/
|
|
64
|
-
export declare function invokeAgentEndpoint(options: InvokeAgentOptions): Promise<InvokeAgentResult>;
|
|
65
|
-
//# sourceMappingURL=invoke-agent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invoke-agent.d.ts","sourceRoot":"","sources":["../../src/bridge/invoke-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAgBzD,MAAM,WAAW,kBAAkB;IACjC,oCAAoC;IACpC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,yEAAyE;IACzE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oFAAoF;IACpF,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1B,wBAAwB;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,kDAAkD;IAClD,mBAAmB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACzC,4DAA4D;IAC5D,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,wEAAwE;IACxE,eAAe,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D,sFAAsF;IACtF,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,QAAQ,EAAE,OAAO,CAAC;IAClB,qBAAqB;IACrB,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC;IACvB,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAID;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CA4G5B"}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { isStreamingContentType } from '../stream/stream-parser.js';
|
|
3
|
-
/** Schema for agent HTTP response data — validates untrusted external input. */
|
|
4
|
-
const agentResponseSchema = z.object({
|
|
5
|
-
hostSessionId: z.string().optional(),
|
|
6
|
-
text: z.string().optional(),
|
|
7
|
-
events: z.array(z.object({
|
|
8
|
-
type: z.string(),
|
|
9
|
-
payload: z.unknown(),
|
|
10
|
-
}).passthrough()).optional(),
|
|
11
|
-
}).passthrough();
|
|
12
|
-
// ── Implementation ──
|
|
13
|
-
/**
|
|
14
|
-
* Invoke an agent's HTTP endpoint and handle the response.
|
|
15
|
-
*
|
|
16
|
-
* Supports two response formats:
|
|
17
|
-
* 1. JSON — returns the parsed body as InvokeAgentResult
|
|
18
|
-
* 2. SSE stream — forwards chunks via callbacks, returns when stream ends
|
|
19
|
-
*
|
|
20
|
-
* The request body shape follows the ggui bridge protocol:
|
|
21
|
-
* - start: { type: 'start', message, appId, interfaceContext }
|
|
22
|
-
* - message: { type: 'message', hostSessionId, appId, message, conversationHistory, interfaceContext }
|
|
23
|
-
*/
|
|
24
|
-
export async function invokeAgentEndpoint(options) {
|
|
25
|
-
const { connectorEndpointUrl, type, appId, hostSessionId, message, interfaceContext, conversationHistory, onStreamChunk, onStreamDone, onHostSessionId, timeoutMs = 90_000, } = options;
|
|
26
|
-
// Build request body based on invocation type
|
|
27
|
-
const body = { type, appId };
|
|
28
|
-
if (type === 'start') {
|
|
29
|
-
if (hostSessionId)
|
|
30
|
-
body.hostSessionId = hostSessionId;
|
|
31
|
-
body.message = message || 'Start a new session';
|
|
32
|
-
if (interfaceContext)
|
|
33
|
-
body.interfaceContext = interfaceContext;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
body.hostSessionId = hostSessionId;
|
|
37
|
-
body.message = message;
|
|
38
|
-
if (interfaceContext)
|
|
39
|
-
body.interfaceContext = interfaceContext;
|
|
40
|
-
if (conversationHistory && conversationHistory.length > 0) {
|
|
41
|
-
body.conversationHistory = conversationHistory;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
// Build headers
|
|
45
|
-
const headers = {
|
|
46
|
-
'Content-Type': 'application/json',
|
|
47
|
-
'X-Ggui-App-Id': appId,
|
|
48
|
-
};
|
|
49
|
-
if (hostSessionId) {
|
|
50
|
-
headers['X-Ggui-Host-Session-Id'] = hostSessionId;
|
|
51
|
-
}
|
|
52
|
-
// POST to agent endpoint
|
|
53
|
-
let response;
|
|
54
|
-
try {
|
|
55
|
-
response = await fetch(connectorEndpointUrl, {
|
|
56
|
-
method: 'POST',
|
|
57
|
-
headers,
|
|
58
|
-
body: JSON.stringify(body),
|
|
59
|
-
signal: AbortSignal.timeout(timeoutMs),
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
catch (err) {
|
|
63
|
-
const errMsg = err instanceof Error ? err.message : 'Agent invocation failed';
|
|
64
|
-
return { status: 'error', error: errMsg, streamed: false };
|
|
65
|
-
}
|
|
66
|
-
if (!response.ok) {
|
|
67
|
-
return {
|
|
68
|
-
status: 'error',
|
|
69
|
-
error: `Agent returned ${response.status}`,
|
|
70
|
-
streamed: false,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
// Determine response format
|
|
74
|
-
const contentType = response.headers.get('content-type') || '';
|
|
75
|
-
const transferEncoding = response.headers.get('transfer-encoding') || '';
|
|
76
|
-
// Read the full response body (SSE or JSON)
|
|
77
|
-
const responseText = await response.text();
|
|
78
|
-
// Parse the response — handle SSE format (strip `data: ` prefix)
|
|
79
|
-
let agentData;
|
|
80
|
-
try {
|
|
81
|
-
// SSE responses have `data: {...}` lines
|
|
82
|
-
const lines = responseText.split('\n').filter(l => l.startsWith('data: '));
|
|
83
|
-
const raw = lines.length > 0
|
|
84
|
-
? JSON.parse(lines[lines.length - 1].slice(6).trim())
|
|
85
|
-
: JSON.parse(responseText);
|
|
86
|
-
agentData = agentResponseSchema.parse(raw);
|
|
87
|
-
}
|
|
88
|
-
catch {
|
|
89
|
-
// Couldn't parse or validate — forward raw text
|
|
90
|
-
await onStreamChunk?.(responseText);
|
|
91
|
-
await onStreamDone?.();
|
|
92
|
-
return { status: 'ok', streamed: true };
|
|
93
|
-
}
|
|
94
|
-
// Extract hostSessionId
|
|
95
|
-
if (agentData.hostSessionId) {
|
|
96
|
-
await onHostSessionId?.(agentData.hostSessionId);
|
|
97
|
-
}
|
|
98
|
-
// Forward structured agent events
|
|
99
|
-
if (agentData.events && options.onAgentEvent) {
|
|
100
|
-
for (const event of agentData.events) {
|
|
101
|
-
await options.onAgentEvent(event);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
// Extract text for conversation history
|
|
105
|
-
const resultText = agentData.text;
|
|
106
|
-
await onStreamDone?.();
|
|
107
|
-
return {
|
|
108
|
-
hostSessionId: agentData.hostSessionId,
|
|
109
|
-
text: resultText,
|
|
110
|
-
status: 'ok',
|
|
111
|
-
streamed: isStreamingContentType(contentType, transferEncoding),
|
|
112
|
-
};
|
|
113
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Universal stream parser for agent responses.
|
|
3
|
-
*
|
|
4
|
-
* Extracts text from any LLM provider's streaming format (Anthropic, OpenAI,
|
|
5
|
-
* Gemini, Cohere, Mistral, etc.) without hardcoding provider schemas.
|
|
6
|
-
* Uses depth-first search on well-known field names and container structures.
|
|
7
|
-
*
|
|
8
|
-
* Decoupled from any transport (WebSocket, HTTP, etc.) — callers provide
|
|
9
|
-
* callbacks for chunk delivery.
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Detect whether a response should be treated as a stream based on headers.
|
|
13
|
-
* Accepts raw header strings so callers aren't coupled to the fetch API.
|
|
14
|
-
*/
|
|
15
|
-
export declare function isStreamingContentType(contentType: string, transferEncoding?: string): boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Depth-first search for a text string in a JSON structure.
|
|
18
|
-
*
|
|
19
|
-
* Search strategy:
|
|
20
|
-
* 1. Check TEXT_FIELDS at current level (string values only)
|
|
21
|
-
* 2. Recurse into CONTAINER_FIELDS
|
|
22
|
-
*
|
|
23
|
-
* Works with any provider because it searches by field-name patterns,
|
|
24
|
-
* not by provider-specific schemas.
|
|
25
|
-
*/
|
|
26
|
-
export declare function deepFindText(obj: unknown, depth?: number): string;
|
|
27
|
-
/**
|
|
28
|
-
* Detect if a streaming JSON event signals end-of-stream.
|
|
29
|
-
*
|
|
30
|
-
* Recognized signals:
|
|
31
|
-
* - type: "done" / "message_stop"
|
|
32
|
-
* - choices[0].finish_reason !== null
|
|
33
|
-
* - (HTTP stream close is handled by the reader, not here)
|
|
34
|
-
*/
|
|
35
|
-
export declare function isStreamDone(data: Record<string, unknown>): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Extract hostSessionId (conversation envelope id) from a streaming event.
|
|
38
|
-
* Checks for a top-level `hostSessionId` string — no envelope format required.
|
|
39
|
-
*/
|
|
40
|
-
export declare function extractHostSessionId(data: Record<string, unknown>): string | undefined;
|
|
41
|
-
/**
|
|
42
|
-
* Callbacks for stream consumers. Transport-agnostic — works with WebSocket,
|
|
43
|
-
* HTTP response streaming, file output, or anything else.
|
|
44
|
-
*/
|
|
45
|
-
export interface StreamCallbacks {
|
|
46
|
-
onChunk: (text: string) => Promise<void>;
|
|
47
|
-
onDone: () => Promise<void>;
|
|
48
|
-
onHostSessionId?: (hostSessionId: string) => Promise<void>;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Read a streaming HTTP response and invoke callbacks for each text chunk.
|
|
52
|
-
*
|
|
53
|
-
* Supports three wire formats:
|
|
54
|
-
* 1. text/event-stream (SSE) — parses `data:` lines
|
|
55
|
-
* 2. application/x-ndjson — one JSON object per line
|
|
56
|
-
* 3. Any other — forwards raw text chunks
|
|
57
|
-
*
|
|
58
|
-
* JSON events (SSE and NDJSON) are parsed with deepFindText for universal
|
|
59
|
-
* text extraction. Non-JSON content is forwarded as raw text.
|
|
60
|
-
*/
|
|
61
|
-
export declare function readStream(body: ReadableStream<Uint8Array>, contentType: string, callbacks: StreamCallbacks): Promise<void>;
|
|
62
|
-
//# sourceMappingURL=stream-parser.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stream-parser.d.ts","sourceRoot":"","sources":["../../src/stream/stream-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,EACnB,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAKT;AAUD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,SAAI,GAAG,MAAM,CA0B5D;AAID;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAUnE;AAID;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS,CAKtF;AAID;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,eAAe,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5D;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,EAChC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,eAAe,GACzB,OAAO,CAAC,IAAI,CAAC,CAkFf"}
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Universal stream parser for agent responses.
|
|
3
|
-
*
|
|
4
|
-
* Extracts text from any LLM provider's streaming format (Anthropic, OpenAI,
|
|
5
|
-
* Gemini, Cohere, Mistral, etc.) without hardcoding provider schemas.
|
|
6
|
-
* Uses depth-first search on well-known field names and container structures.
|
|
7
|
-
*
|
|
8
|
-
* Decoupled from any transport (WebSocket, HTTP, etc.) — callers provide
|
|
9
|
-
* callbacks for chunk delivery.
|
|
10
|
-
*/
|
|
11
|
-
// ── Detection ──
|
|
12
|
-
/**
|
|
13
|
-
* Detect whether a response should be treated as a stream based on headers.
|
|
14
|
-
* Accepts raw header strings so callers aren't coupled to the fetch API.
|
|
15
|
-
*/
|
|
16
|
-
export function isStreamingContentType(contentType, transferEncoding) {
|
|
17
|
-
if (contentType.includes('text/event-stream'))
|
|
18
|
-
return true;
|
|
19
|
-
if (contentType.includes('application/x-ndjson'))
|
|
20
|
-
return true;
|
|
21
|
-
if (contentType.includes('text/plain') && transferEncoding?.includes('chunked'))
|
|
22
|
-
return true;
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
// ── Text extraction ──
|
|
26
|
-
/** Well-known field names that carry streaming text across LLM providers. */
|
|
27
|
-
const TEXT_FIELDS = ['text', 'content', 'chunk', 'message', 'output', 'response'];
|
|
28
|
-
/** Well-known container fields that wrap text in nested structures. */
|
|
29
|
-
const CONTAINER_FIELDS = ['delta', 'choices', 'candidates', 'parts', 'content_block', 'data', 'body'];
|
|
30
|
-
/**
|
|
31
|
-
* Depth-first search for a text string in a JSON structure.
|
|
32
|
-
*
|
|
33
|
-
* Search strategy:
|
|
34
|
-
* 1. Check TEXT_FIELDS at current level (string values only)
|
|
35
|
-
* 2. Recurse into CONTAINER_FIELDS
|
|
36
|
-
*
|
|
37
|
-
* Works with any provider because it searches by field-name patterns,
|
|
38
|
-
* not by provider-specific schemas.
|
|
39
|
-
*/
|
|
40
|
-
export function deepFindText(obj, depth = 0) {
|
|
41
|
-
if (depth > 6)
|
|
42
|
-
return '';
|
|
43
|
-
if (!obj || typeof obj !== 'object')
|
|
44
|
-
return '';
|
|
45
|
-
const record = obj;
|
|
46
|
-
for (const key of TEXT_FIELDS) {
|
|
47
|
-
const val = record[key];
|
|
48
|
-
if (typeof val === 'string' && val.length > 0)
|
|
49
|
-
return val;
|
|
50
|
-
}
|
|
51
|
-
for (const key of CONTAINER_FIELDS) {
|
|
52
|
-
if (!(key in record))
|
|
53
|
-
continue;
|
|
54
|
-
const val = record[key];
|
|
55
|
-
if (Array.isArray(val)) {
|
|
56
|
-
for (const item of val) {
|
|
57
|
-
const found = deepFindText(item, depth + 1);
|
|
58
|
-
if (found)
|
|
59
|
-
return found;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
const found = deepFindText(val, depth + 1);
|
|
64
|
-
if (found)
|
|
65
|
-
return found;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return '';
|
|
69
|
-
}
|
|
70
|
-
// ── Done detection ──
|
|
71
|
-
/**
|
|
72
|
-
* Detect if a streaming JSON event signals end-of-stream.
|
|
73
|
-
*
|
|
74
|
-
* Recognized signals:
|
|
75
|
-
* - type: "done" / "message_stop"
|
|
76
|
-
* - choices[0].finish_reason !== null
|
|
77
|
-
* - (HTTP stream close is handled by the reader, not here)
|
|
78
|
-
*/
|
|
79
|
-
export function isStreamDone(data) {
|
|
80
|
-
const t = data.type;
|
|
81
|
-
if (t === 'done' || t === 'message_stop')
|
|
82
|
-
return true;
|
|
83
|
-
if (Array.isArray(data.choices)) {
|
|
84
|
-
const first = data.choices[0];
|
|
85
|
-
if (first?.finish_reason != null)
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
// ── HostSessionId extraction ──
|
|
91
|
-
/**
|
|
92
|
-
* Extract hostSessionId (conversation envelope id) from a streaming event.
|
|
93
|
-
* Checks for a top-level `hostSessionId` string — no envelope format required.
|
|
94
|
-
*/
|
|
95
|
-
export function extractHostSessionId(data) {
|
|
96
|
-
if (typeof data.hostSessionId === 'string' && data.hostSessionId) {
|
|
97
|
-
return data.hostSessionId;
|
|
98
|
-
}
|
|
99
|
-
return undefined;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Read a streaming HTTP response and invoke callbacks for each text chunk.
|
|
103
|
-
*
|
|
104
|
-
* Supports three wire formats:
|
|
105
|
-
* 1. text/event-stream (SSE) — parses `data:` lines
|
|
106
|
-
* 2. application/x-ndjson — one JSON object per line
|
|
107
|
-
* 3. Any other — forwards raw text chunks
|
|
108
|
-
*
|
|
109
|
-
* JSON events (SSE and NDJSON) are parsed with deepFindText for universal
|
|
110
|
-
* text extraction. Non-JSON content is forwarded as raw text.
|
|
111
|
-
*/
|
|
112
|
-
export async function readStream(body, contentType, callbacks) {
|
|
113
|
-
const reader = body.getReader();
|
|
114
|
-
const decoder = new TextDecoder();
|
|
115
|
-
const isSSE = contentType.includes('text/event-stream');
|
|
116
|
-
const isNDJSON = contentType.includes('application/x-ndjson');
|
|
117
|
-
let buffer = '';
|
|
118
|
-
let doneSent = false;
|
|
119
|
-
const emitDone = async () => {
|
|
120
|
-
if (doneSent)
|
|
121
|
-
return;
|
|
122
|
-
doneSent = true;
|
|
123
|
-
await callbacks.onDone();
|
|
124
|
-
};
|
|
125
|
-
const processJsonEvent = async (data) => {
|
|
126
|
-
const hsid = extractHostSessionId(data);
|
|
127
|
-
if (hsid)
|
|
128
|
-
await callbacks.onHostSessionId?.(hsid);
|
|
129
|
-
if (isStreamDone(data)) {
|
|
130
|
-
await emitDone();
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
const text = deepFindText(data);
|
|
134
|
-
if (text)
|
|
135
|
-
await callbacks.onChunk(text);
|
|
136
|
-
};
|
|
137
|
-
try {
|
|
138
|
-
for (;;) {
|
|
139
|
-
const { done, value } = await reader.read();
|
|
140
|
-
if (done)
|
|
141
|
-
break;
|
|
142
|
-
buffer += decoder.decode(value, { stream: true });
|
|
143
|
-
if (isSSE) {
|
|
144
|
-
const lines = buffer.split('\n');
|
|
145
|
-
buffer = lines.pop() || '';
|
|
146
|
-
for (const line of lines) {
|
|
147
|
-
if (!line || line.startsWith(':'))
|
|
148
|
-
continue;
|
|
149
|
-
if (!line.startsWith('data: '))
|
|
150
|
-
continue;
|
|
151
|
-
const payload = line.slice(6).trim();
|
|
152
|
-
if (!payload)
|
|
153
|
-
continue;
|
|
154
|
-
if (payload === '[DONE]') {
|
|
155
|
-
await emitDone();
|
|
156
|
-
continue;
|
|
157
|
-
}
|
|
158
|
-
try {
|
|
159
|
-
await processJsonEvent(JSON.parse(payload));
|
|
160
|
-
}
|
|
161
|
-
catch {
|
|
162
|
-
// Not valid JSON — forward as raw text chunk
|
|
163
|
-
await callbacks.onChunk(payload);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
else if (isNDJSON) {
|
|
168
|
-
const lines = buffer.split('\n');
|
|
169
|
-
buffer = lines.pop() || '';
|
|
170
|
-
for (const line of lines) {
|
|
171
|
-
const trimmed = line.trim();
|
|
172
|
-
if (!trimmed)
|
|
173
|
-
continue;
|
|
174
|
-
try {
|
|
175
|
-
await processJsonEvent(JSON.parse(trimmed));
|
|
176
|
-
}
|
|
177
|
-
catch {
|
|
178
|
-
// Not valid JSON — forward as raw text chunk
|
|
179
|
-
await callbacks.onChunk(trimmed);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
const chunk = buffer;
|
|
185
|
-
buffer = '';
|
|
186
|
-
if (chunk)
|
|
187
|
-
await callbacks.onChunk(chunk);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
await emitDone();
|
|
191
|
-
}
|
|
192
|
-
catch (err) {
|
|
193
|
-
console.error('Stream reading error:', err);
|
|
194
|
-
await emitDone().catch(() => { });
|
|
195
|
-
}
|
|
196
|
-
finally {
|
|
197
|
-
reader.releaseLock();
|
|
198
|
-
}
|
|
199
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"canvas-lifecycle.d.ts","sourceRoot":"","sources":["../../src/types/canvas-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,UAAU;IACzD,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,oEAAoE;IACpE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,MAAM,WAAW,yBAA0B,SAAQ,UAAU;IAC3D,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,gEAAgE;IAChE,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;IACjE;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAqB,SAAQ,UAAU;IACtD,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAsB,SAAQ,UAAU;IACvD,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC;;;;;;;OAOG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,mDAAmD;IACnD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAC9B,uBAAuB,GACvB,yBAAyB,GACzB,oBAAoB,GACpB,qBAAqB,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Credential injection — cross-process wire protocol between the
|
|
3
|
-
* open @ggui-ai/server auth relay (which writes placeholders) and
|
|
4
|
-
* the closed cloud mcp-proxy service (which resolves them).
|
|
5
|
-
*
|
|
6
|
-
* Shared between:
|
|
7
|
-
* - packages/server/src/mcp-auth-middleware.ts (writes placeholders)
|
|
8
|
-
* - cloud/amplify/functions/rest-api/mcp-proxy/handler.ts (resolves placeholders)
|
|
9
|
-
* - cloud/services/mcp-proxy/src/* (resolves placeholders)
|
|
10
|
-
*
|
|
11
|
-
* Hosted-overlay shapes for the `auth` block inside per-app
|
|
12
|
-
* config files are a hosting concept and not a portable wire
|
|
13
|
-
* protocol. What remains here is the runtime placeholder /
|
|
14
|
-
* injection-mode protocol, which is legitimately cross-process.
|
|
15
|
-
*/
|
|
16
|
-
/** How the proxy injects a credential into the outbound request. */
|
|
17
|
-
export type CredentialInjection = 'bearer_header' | 'api_key_header' | 'query_param' | 'custom_header';
|
|
18
|
-
/** Full injection config — resolved from app config or McpServiceConfig. */
|
|
19
|
-
export interface CredentialInjectionConfig {
|
|
20
|
-
mode: CredentialInjection;
|
|
21
|
-
/** Header name for api_key_header / custom_header. Default: 'X-API-Key'. */
|
|
22
|
-
headerName?: string;
|
|
23
|
-
/** Query param name for query_param. Default: 'api_key'. */
|
|
24
|
-
paramName?: string;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Placeholder regex — matches `<ggui:credential:{serviceId}>`.
|
|
28
|
-
* The placeholder is always the raw credential slot value.
|
|
29
|
-
* The proxy applies injection formatting (Bearer prefix, header name, etc.).
|
|
30
|
-
*/
|
|
31
|
-
export declare const CREDENTIAL_PLACEHOLDER_RE: RegExp;
|
|
32
|
-
/**
|
|
33
|
-
* Internal control header for placeholder pre-injection.
|
|
34
|
-
* - Writer: auth relay middleware only
|
|
35
|
-
* - Consumer: proxy only (reads, resolves, strips before forwarding)
|
|
36
|
-
* - Never forwarded upstream
|
|
37
|
-
*/
|
|
38
|
-
export declare const CREDENTIAL_HEADER = "x-ggui-credential";
|
|
39
|
-
/** Build a placeholder string for a given serviceId. */
|
|
40
|
-
export declare function credentialPlaceholder(serviceId: string): string;
|
|
41
|
-
//# sourceMappingURL=credential.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"credential.d.ts","sourceRoot":"","sources":["../../src/types/credential.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,oEAAoE;AACpE,MAAM,MAAM,mBAAmB,GAC3B,eAAe,GACf,gBAAgB,GAChB,aAAa,GACb,eAAe,CAAC;AAEpB,4EAA4E;AAC5E,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,QAAyC,CAAC;AAEhF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAErD,wDAAwD;AACxD,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE/D"}
|
package/dist/types/credential.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Credential injection — cross-process wire protocol between the
|
|
3
|
-
* open @ggui-ai/server auth relay (which writes placeholders) and
|
|
4
|
-
* the closed cloud mcp-proxy service (which resolves them).
|
|
5
|
-
*
|
|
6
|
-
* Shared between:
|
|
7
|
-
* - packages/server/src/mcp-auth-middleware.ts (writes placeholders)
|
|
8
|
-
* - cloud/amplify/functions/rest-api/mcp-proxy/handler.ts (resolves placeholders)
|
|
9
|
-
* - cloud/services/mcp-proxy/src/* (resolves placeholders)
|
|
10
|
-
*
|
|
11
|
-
* Hosted-overlay shapes for the `auth` block inside per-app
|
|
12
|
-
* config files are a hosting concept and not a portable wire
|
|
13
|
-
* protocol. What remains here is the runtime placeholder /
|
|
14
|
-
* injection-mode protocol, which is legitimately cross-process.
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* Placeholder regex — matches `<ggui:credential:{serviceId}>`.
|
|
18
|
-
* The placeholder is always the raw credential slot value.
|
|
19
|
-
* The proxy applies injection formatting (Bearer prefix, header name, etc.).
|
|
20
|
-
*/
|
|
21
|
-
export const CREDENTIAL_PLACEHOLDER_RE = /^<ggui:credential:([a-zA-Z0-9_-]+)>$/;
|
|
22
|
-
/**
|
|
23
|
-
* Internal control header for placeholder pre-injection.
|
|
24
|
-
* - Writer: auth relay middleware only
|
|
25
|
-
* - Consumer: proxy only (reads, resolves, strips before forwarding)
|
|
26
|
-
* - Never forwarded upstream
|
|
27
|
-
*/
|
|
28
|
-
export const CREDENTIAL_HEADER = 'x-ggui-credential';
|
|
29
|
-
/** Build a placeholder string for a given serviceId. */
|
|
30
|
-
export function credentialPlaceholder(serviceId) {
|
|
31
|
-
return `<ggui:credential:${serviceId}>`;
|
|
32
|
-
}
|