@noodleseed/one 0.7.0 → 0.10.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/dist/banner.d.ts +11 -0
- package/dist/banner.d.ts.map +1 -0
- package/dist/banner.js +183 -0
- package/dist/banner.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +6 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/author-loop.d.ts.map +1 -1
- package/dist/commands/author-loop.js +78 -3
- package/dist/commands/author-loop.js.map +1 -1
- package/dist/commands/deploy-ops.d.ts +1 -30
- package/dist/commands/deploy-ops.d.ts.map +1 -1
- package/dist/commands/deploy-ops.js +79 -88
- package/dist/commands/deploy-ops.js.map +1 -1
- package/dist/commands/deploy-output.d.ts +31 -0
- package/dist/commands/deploy-output.d.ts.map +1 -0
- package/dist/commands/deploy-output.js +86 -0
- package/dist/commands/deploy-output.js.map +1 -0
- package/dist/commands/deploy-version-resolution.d.ts +20 -0
- package/dist/commands/deploy-version-resolution.d.ts.map +1 -0
- package/dist/commands/deploy-version-resolution.js +77 -0
- package/dist/commands/deploy-version-resolution.js.map +1 -0
- package/dist/commands/docs-mcp.d.ts +32 -0
- package/dist/commands/docs-mcp.d.ts.map +1 -0
- package/dist/commands/docs-mcp.js +66 -0
- package/dist/commands/docs-mcp.js.map +1 -0
- package/dist/commands/mcp-apps.d.ts.map +1 -1
- package/dist/commands/mcp-apps.js +38 -37
- package/dist/commands/mcp-apps.js.map +1 -1
- package/dist/commands/project-setup.d.ts +1 -1
- package/dist/commands/project-setup.d.ts.map +1 -1
- package/dist/commands/project-setup.js +36 -2
- package/dist/commands/project-setup.js.map +1 -1
- package/dist/commands/shared.d.ts +1 -0
- package/dist/commands/shared.d.ts.map +1 -1
- package/dist/commands/shared.js +10 -4
- package/dist/commands/shared.js.map +1 -1
- package/dist/deploy-version.d.ts +3 -0
- package/dist/deploy-version.d.ts.map +1 -0
- package/dist/deploy-version.js +28 -0
- package/dist/deploy-version.js.map +1 -0
- package/dist/deploy.d.ts +5 -1
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +27 -3
- package/dist/deploy.js.map +1 -1
- package/dist/dev.d.ts.map +1 -1
- package/dist/dev.js +9 -1
- package/dist/dev.js.map +1 -1
- package/dist/devtools-chat.d.ts +76 -0
- package/dist/devtools-chat.d.ts.map +1 -0
- package/dist/devtools-chat.js +114 -0
- package/dist/devtools-chat.js.map +1 -0
- package/dist/devtools-env.d.ts +16 -0
- package/dist/devtools-env.d.ts.map +1 -0
- package/dist/devtools-env.js +71 -0
- package/dist/devtools-env.js.map +1 -0
- package/dist/devtools-harness.d.ts +28 -0
- package/dist/devtools-harness.d.ts.map +1 -0
- package/dist/devtools-harness.js +387 -0
- package/dist/devtools-harness.js.map +1 -0
- package/dist/devtools-preview.d.ts +42 -0
- package/dist/devtools-preview.d.ts.map +1 -0
- package/dist/devtools-preview.js +394 -0
- package/dist/devtools-preview.js.map +1 -0
- package/dist/first-run-entry.d.ts +2 -0
- package/dist/first-run-entry.d.ts.map +1 -0
- package/dist/first-run-entry.js +36 -0
- package/dist/first-run-entry.js.map +1 -0
- package/dist/first-run.d.ts +26 -0
- package/dist/first-run.d.ts.map +1 -0
- package/dist/first-run.js +439 -0
- package/dist/first-run.js.map +1 -0
- package/dist/gradient.d.ts +46 -0
- package/dist/gradient.d.ts.map +1 -0
- package/dist/gradient.js +87 -0
- package/dist/gradient.js.map +1 -0
- package/dist/openapi-import.d.ts.map +1 -1
- package/dist/openapi-import.js +47 -8
- package/dist/openapi-import.js.map +1 -1
- package/dist/preview-session.d.ts +46 -0
- package/dist/preview-session.d.ts.map +1 -0
- package/dist/preview-session.js +132 -0
- package/dist/preview-session.js.map +1 -0
- package/dist/project.d.ts +2 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +2 -0
- package/dist/project.js.map +1 -1
- package/dist/prompts.d.ts +61 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +209 -0
- package/dist/prompts.js.map +1 -0
- package/dist/react-widget-build.js +3 -1
- package/dist/react-widget-build.js.map +1 -1
- package/dist/status.d.ts +58 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +106 -0
- package/dist/status.js.map +1 -0
- package/node_modules/@noodle-borg/agent-kit/dist/curated/command-groups.d.ts.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/curated/command-groups.js +4 -0
- package/node_modules/@noodle-borg/agent-kit/dist/curated/command-groups.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.d.ts.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.js +1 -0
- package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
- package/node_modules/@noodle-borg/connector-defs/dist/compile-expr.d.ts +23 -0
- package/node_modules/@noodle-borg/connector-defs/dist/compile-expr.d.ts.map +1 -0
- package/node_modules/@noodle-borg/connector-defs/dist/compile-expr.js +41 -0
- package/node_modules/@noodle-borg/connector-defs/dist/compile-expr.js.map +1 -0
- package/node_modules/@noodle-borg/connector-defs/dist/compile.d.ts +2 -6
- package/node_modules/@noodle-borg/connector-defs/dist/compile.d.ts.map +1 -1
- package/node_modules/@noodle-borg/connector-defs/dist/compile.js +10 -32
- package/node_modules/@noodle-borg/connector-defs/dist/compile.js.map +1 -1
- package/node_modules/@noodle-borg/connector-defs/dist/schema.d.ts +16 -0
- package/node_modules/@noodle-borg/connector-defs/dist/schema.d.ts.map +1 -1
- package/node_modules/@noodle-borg/connector-defs/dist/schema.js +6 -0
- package/node_modules/@noodle-borg/connector-defs/dist/schema.js.map +1 -1
- package/node_modules/@noodle-borg/connector-http/dist/http-connector.d.ts +7 -0
- package/node_modules/@noodle-borg/connector-http/dist/http-connector.d.ts.map +1 -1
- package/node_modules/@noodle-borg/connector-http/dist/http-connector.js +14 -5
- package/node_modules/@noodle-borg/connector-http/dist/http-connector.js.map +1 -1
- package/node_modules/@noodle-borg/module/dist/contract.d.ts +12 -0
- package/node_modules/@noodle-borg/module/dist/contract.d.ts.map +1 -1
- package/node_modules/@noodle-borg/module/dist/contract.js +41 -0
- package/node_modules/@noodle-borg/module/dist/contract.js.map +1 -1
- package/node_modules/@noodle-borg/openapi-import/dist/index.d.ts +4 -0
- package/node_modules/@noodle-borg/openapi-import/dist/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/openapi-import/dist/index.js +27 -1
- package/node_modules/@noodle-borg/openapi-import/dist/index.js.map +1 -1
- package/node_modules/@noodle-borg/openapi-import/dist/response-schema.d.ts +50 -0
- package/node_modules/@noodle-borg/openapi-import/dist/response-schema.d.ts.map +1 -0
- package/node_modules/@noodle-borg/openapi-import/dist/response-schema.js +227 -0
- package/node_modules/@noodle-borg/openapi-import/dist/response-schema.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/auth/deploy-gate.d.ts +20 -2
- package/node_modules/@noodle-borg/service/dist/auth/deploy-gate.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/auth/deploy-gate.js +37 -2
- package/node_modules/@noodle-borg/service/dist/auth/deploy-gate.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/deployment-versioning.d.ts +18 -0
- package/node_modules/@noodle-borg/service/dist/deployment-versioning.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/deployment-versioning.js +29 -0
- package/node_modules/@noodle-borg/service/dist/deployment-versioning.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/main.js +7 -0
- package/node_modules/@noodle-borg/service/dist/main.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/app.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/app.js +2 -1
- package/node_modules/@noodle-borg/service/dist/oauth/app.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/branding.d.ts +30 -0
- package/node_modules/@noodle-borg/service/dist/oauth/branding.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/oauth/branding.js +224 -0
- package/node_modules/@noodle-borg/service/dist/oauth/branding.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/oauth/consent.d.ts +0 -6
- package/node_modules/@noodle-borg/service/dist/oauth/consent.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/consent.js +23 -34
- package/node_modules/@noodle-borg/service/dist/oauth/consent.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/customer-bridge.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/oauth/customer-bridge.js +13 -28
- package/node_modules/@noodle-borg/service/dist/oauth/customer-bridge.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry-helpers.d.ts +1 -1
- package/node_modules/@noodle-borg/service/dist/registry-helpers.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry-helpers.js +5 -3
- package/node_modules/@noodle-borg/service/dist/registry-helpers.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry-targets.d.ts +1 -0
- package/node_modules/@noodle-borg/service/dist/registry-targets.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry-targets.js +4 -0
- package/node_modules/@noodle-borg/service/dist/registry-targets.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry-types.d.ts +59 -0
- package/node_modules/@noodle-borg/service/dist/registry-types.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/registry-types.js +2 -0
- package/node_modules/@noodle-borg/service/dist/registry-types.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/registry.d.ts +8 -65
- package/node_modules/@noodle-borg/service/dist/registry.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/registry.js +100 -82
- package/node_modules/@noodle-borg/service/dist/registry.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/access-mode.d.ts +4 -0
- package/node_modules/@noodle-borg/service/dist/routes/access-mode.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/access-mode.js +15 -0
- package/node_modules/@noodle-borg/service/dist/routes/access-mode.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/routes/control-plane.d.ts +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/control-plane.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/control-plane.js +34 -21
- package/node_modules/@noodle-borg/service/dist/routes/control-plane.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/rollback.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/routes/rollback.js +4 -6
- package/node_modules/@noodle-borg/service/dist/routes/rollback.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/serve.d.ts +6 -0
- package/node_modules/@noodle-borg/service/dist/serve.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/serve.js +72 -32
- package/node_modules/@noodle-borg/service/dist/serve.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/server-auth-bindings.d.ts +7 -0
- package/node_modules/@noodle-borg/service/dist/server-auth-bindings.d.ts.map +1 -0
- package/node_modules/@noodle-borg/service/dist/server-auth-bindings.js +14 -0
- package/node_modules/@noodle-borg/service/dist/server-auth-bindings.js.map +1 -0
- package/node_modules/@noodle-borg/service/dist/service.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/service.js +32 -3
- package/node_modules/@noodle-borg/service/dist/service.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-schema.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres-schema.js +13 -2
- package/node_modules/@noodle-borg/service/dist/store/postgres-schema.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres.d.ts +3 -2
- package/node_modules/@noodle-borg/service/dist/store/postgres.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store/postgres.js +41 -9
- package/node_modules/@noodle-borg/service/dist/store/postgres.js.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store.d.ts +9 -3
- package/node_modules/@noodle-borg/service/dist/store.d.ts.map +1 -1
- package/node_modules/@noodle-borg/service/dist/store.js +29 -27
- package/node_modules/@noodle-borg/service/dist/store.js.map +1 -1
- package/node_modules/@noodle-borg/transport-http/dist/handler.d.ts +1 -0
- package/node_modules/@noodle-borg/transport-http/dist/handler.d.ts.map +1 -1
- package/node_modules/@noodle-borg/transport-http/dist/handler.js +37 -0
- package/node_modules/@noodle-borg/transport-http/dist/handler.js.map +1 -1
- package/node_modules/@noodle-borg/transport-http/dist/index.d.ts +1 -1
- package/node_modules/@noodle-borg/transport-http/dist/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/transport-http/dist/index.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import { createServer } from 'node:http';
|
|
2
|
+
import { DEFAULT_CHAT_MODEL, runChatTurn, } from './devtools-chat.js';
|
|
3
|
+
import { harnessHtml, openAiShimScript, wrapWidgetHtml, } from './devtools-harness.js';
|
|
4
|
+
// Re-exported so `devtools-preview` stays the single import surface for the command and tests.
|
|
5
|
+
export { harnessHtml, openAiShimScript, wrapWidgetHtml };
|
|
6
|
+
const CHAT_SYSTEM_PROMPT = 'You are an assistant embedded in the Noodle Seed devtools playground. You can call the MCP tools ' +
|
|
7
|
+
'exposed by the local server the developer is previewing. Call a tool whenever it can answer the ' +
|
|
8
|
+
'request or render a widget, then explain the result briefly. Keep answers concise.';
|
|
9
|
+
const DEFAULT_PROTOCOL_VERSION = '2025-11-25';
|
|
10
|
+
/** Parse the `/widget?args=` query param (a JSON object) into tool-call arguments; `{}` on absent/invalid. */
|
|
11
|
+
function parseArgsParam(raw) {
|
|
12
|
+
if (!raw)
|
|
13
|
+
return {};
|
|
14
|
+
try {
|
|
15
|
+
const parsed = JSON.parse(raw);
|
|
16
|
+
return parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
17
|
+
? parsed
|
|
18
|
+
: {};
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** Cap a value for the inspector log so a huge tool result does not flood the SSE stream. */
|
|
25
|
+
function capForLog(value, max = 20000) {
|
|
26
|
+
if (value === undefined)
|
|
27
|
+
return undefined;
|
|
28
|
+
try {
|
|
29
|
+
const serialized = JSON.stringify(value);
|
|
30
|
+
if (serialized.length > max) {
|
|
31
|
+
return `${serialized.slice(0, max)}… (truncated ${serialized.length - max} chars)`;
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return '[unserializable]';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function summarize(method, result) {
|
|
40
|
+
if (result === undefined)
|
|
41
|
+
return method;
|
|
42
|
+
if (method === 'tools/list') {
|
|
43
|
+
const tools = Array.isArray(result.tools) ? result.tools : [];
|
|
44
|
+
return `${tools.length} tool(s)`;
|
|
45
|
+
}
|
|
46
|
+
if (method === 'tools/call') {
|
|
47
|
+
return result.isError ? 'tool error' : 'ok';
|
|
48
|
+
}
|
|
49
|
+
if (method === 'resources/read') {
|
|
50
|
+
const contents = Array.isArray(result.contents) ? result.contents : [];
|
|
51
|
+
return `${contents.length} content block(s)`;
|
|
52
|
+
}
|
|
53
|
+
return 'ok';
|
|
54
|
+
}
|
|
55
|
+
function toolName(body) {
|
|
56
|
+
if (body.method === 'tools/call' && body.params && typeof body.params.name === 'string') {
|
|
57
|
+
return body.params.name;
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
/** One JSON-RPC value from a dev-endpoint response body (JSON, or an SSE `data:` frame as a fallback). */
|
|
62
|
+
function parseRpcBody(text) {
|
|
63
|
+
try {
|
|
64
|
+
return JSON.parse(text);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
for (const line of text.split(/\r?\n/)) {
|
|
68
|
+
const trimmed = line.trim();
|
|
69
|
+
if (trimmed.startsWith('data:')) {
|
|
70
|
+
try {
|
|
71
|
+
return JSON.parse(trimmed.slice(5).trim());
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// keep scanning
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export async function startPreview(options) {
|
|
82
|
+
const protocolVersion = options.protocolVersion ?? DEFAULT_PROTOCOL_VERSION;
|
|
83
|
+
const initialTheme = options.theme === 'dark' ? 'dark' : 'light';
|
|
84
|
+
const log = [];
|
|
85
|
+
const subscribers = new Set();
|
|
86
|
+
const reloadSubscribers = new Set();
|
|
87
|
+
// The OpenAI key lives ONLY in this server process (session) or the env — never in the browser. The
|
|
88
|
+
// /widget iframes are same-origin and unsandboxed, so anything the page holds (localStorage or a JS var)
|
|
89
|
+
// is readable by widget scripts and could be exfiltrated. The browser sets it via POST /chat/key and then
|
|
90
|
+
// drops it; the gate state comes from GET /chat/status. The key is never logged or sent back to the page.
|
|
91
|
+
let sessionApiKey;
|
|
92
|
+
function resolveApiKey() {
|
|
93
|
+
return sessionApiKey ?? process.env.OPENAI_API_KEY;
|
|
94
|
+
}
|
|
95
|
+
function apiKeySource() {
|
|
96
|
+
if (sessionApiKey)
|
|
97
|
+
return 'session';
|
|
98
|
+
if (process.env.OPENAI_API_KEY)
|
|
99
|
+
return 'env';
|
|
100
|
+
return 'none';
|
|
101
|
+
}
|
|
102
|
+
function record(entry) {
|
|
103
|
+
log.push(entry);
|
|
104
|
+
if (log.length > 500)
|
|
105
|
+
log.shift();
|
|
106
|
+
const line = `data: ${JSON.stringify(entry)}\n\n`;
|
|
107
|
+
for (const res of subscribers)
|
|
108
|
+
res.write(line);
|
|
109
|
+
}
|
|
110
|
+
function signalReload() {
|
|
111
|
+
for (const res of reloadSubscribers)
|
|
112
|
+
res.write('data: reload\n\n');
|
|
113
|
+
}
|
|
114
|
+
async function forward(body) {
|
|
115
|
+
const start = Date.now();
|
|
116
|
+
const name = toolName(body);
|
|
117
|
+
try {
|
|
118
|
+
const res = await fetch(options.mcpUrl, {
|
|
119
|
+
method: 'POST',
|
|
120
|
+
headers: {
|
|
121
|
+
'content-type': 'application/json',
|
|
122
|
+
accept: 'application/json, text/event-stream',
|
|
123
|
+
'mcp-protocol-version': protocolVersion,
|
|
124
|
+
},
|
|
125
|
+
// Always send a well-formed JSON-RPC envelope. Internal calls (readWidget) build the body without
|
|
126
|
+
// `jsonrpc`; the browser's /rpc calls already include it (the spread keeps the same value).
|
|
127
|
+
body: JSON.stringify({ jsonrpc: '2.0', ...body }),
|
|
128
|
+
});
|
|
129
|
+
const json = parseRpcBody(await res.text());
|
|
130
|
+
const status = json?.error ? 'error' : 'ok';
|
|
131
|
+
record({
|
|
132
|
+
time: start,
|
|
133
|
+
method: body.method,
|
|
134
|
+
...(name !== undefined ? { name } : {}),
|
|
135
|
+
status,
|
|
136
|
+
durationMs: Date.now() - start,
|
|
137
|
+
summary: json?.error?.message ?? summarize(body.method, json?.result),
|
|
138
|
+
...(body.params !== undefined ? { request: capForLog(body.params) } : {}),
|
|
139
|
+
...(json !== undefined ? { response: capForLog(json.error ?? json.result) } : {}),
|
|
140
|
+
});
|
|
141
|
+
return { httpStatus: res.status, json };
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
record({
|
|
145
|
+
time: start,
|
|
146
|
+
method: body.method,
|
|
147
|
+
...(name !== undefined ? { name } : {}),
|
|
148
|
+
status: 'error',
|
|
149
|
+
durationMs: Date.now() - start,
|
|
150
|
+
summary: error instanceof Error ? error.message : String(error),
|
|
151
|
+
...(body.params !== undefined ? { request: capForLog(body.params) } : {}),
|
|
152
|
+
});
|
|
153
|
+
throw error;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
async function readWidget(toolNameParam, toolArguments = {}) {
|
|
157
|
+
const list = await forward({ method: 'tools/list', id: 'list', params: {} });
|
|
158
|
+
const tools = list.json?.result?.tools ?? [];
|
|
159
|
+
const tool = tools.find((t) => t.name === toolNameParam);
|
|
160
|
+
const uri = tool?._meta?.ui?.resourceUri;
|
|
161
|
+
if (uri === undefined)
|
|
162
|
+
return '<!doctype html><p>No widget resource for this tool.</p>';
|
|
163
|
+
const read = await forward({ method: 'resources/read', id: 'read', params: { uri } });
|
|
164
|
+
const contents = read.json?.result?.contents ?? [];
|
|
165
|
+
const widgetHtml = typeof contents[0]?.text === 'string' ? contents[0].text : '';
|
|
166
|
+
const call = await forward({
|
|
167
|
+
method: 'tools/call',
|
|
168
|
+
id: 'call',
|
|
169
|
+
params: { name: toolNameParam, arguments: toolArguments },
|
|
170
|
+
});
|
|
171
|
+
const toolOutput = call.json?.result?.structuredContent ?? null;
|
|
172
|
+
const toolResponseMetadata = call.json?.result?._meta ?? null;
|
|
173
|
+
const shim = openAiShimScript({
|
|
174
|
+
toolInput: toolArguments,
|
|
175
|
+
toolOutput,
|
|
176
|
+
toolResponseMetadata,
|
|
177
|
+
theme: initialTheme,
|
|
178
|
+
});
|
|
179
|
+
return wrapWidgetHtml(widgetHtml, shim);
|
|
180
|
+
}
|
|
181
|
+
/** Project the live tool list into chat tool defs (carrying widget resourceUri for inline rendering). */
|
|
182
|
+
async function chatToolDefs() {
|
|
183
|
+
const list = await forward({ method: 'tools/list', id: 'chat-list', params: {} });
|
|
184
|
+
const tools = list.json?.result?.tools ?? [];
|
|
185
|
+
return tools.map((t) => {
|
|
186
|
+
const resourceUri = t._meta?.ui
|
|
187
|
+
?.resourceUri;
|
|
188
|
+
return {
|
|
189
|
+
name: String(t.name),
|
|
190
|
+
...(typeof t.description === 'string' ? { description: t.description } : {}),
|
|
191
|
+
...(t.inputSchema && typeof t.inputSchema === 'object'
|
|
192
|
+
? { inputSchema: t.inputSchema }
|
|
193
|
+
: {}),
|
|
194
|
+
...(typeof resourceUri === 'string' ? { resourceUri } : {}),
|
|
195
|
+
};
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
/** Run one chat-playground turn against the local tools; the API key is read fresh and never logged. */
|
|
199
|
+
async function handleChat(incoming, apiKey) {
|
|
200
|
+
const messages = incoming[0]?.role === 'system'
|
|
201
|
+
? incoming
|
|
202
|
+
: [{ role: 'system', content: CHAT_SYSTEM_PROMPT }, ...incoming];
|
|
203
|
+
return runChatTurn({
|
|
204
|
+
messages,
|
|
205
|
+
tools: await chatToolDefs(),
|
|
206
|
+
apiKey,
|
|
207
|
+
model: options.openaiModel ?? process.env.OPENAI_MODEL ?? DEFAULT_CHAT_MODEL,
|
|
208
|
+
...(process.env.OPENAI_BASE_URL ? { baseUrl: process.env.OPENAI_BASE_URL } : {}),
|
|
209
|
+
callTool: async (name, args) => {
|
|
210
|
+
const call = await forward({
|
|
211
|
+
method: 'tools/call',
|
|
212
|
+
id: 'chat-call',
|
|
213
|
+
params: { name, arguments: args ?? {} },
|
|
214
|
+
});
|
|
215
|
+
const result = call.json?.result ?? call.json?.error ?? null;
|
|
216
|
+
const isError = call.json?.error !== undefined ||
|
|
217
|
+
call.json?.result?.isError === true;
|
|
218
|
+
return { result, isError };
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
const server = createServer((req, res) => {
|
|
223
|
+
const url = new URL(req.url ?? '/', 'http://localhost');
|
|
224
|
+
if (req.method === 'GET' && url.pathname === '/') {
|
|
225
|
+
res.writeHead(200, { 'content-type': 'text/html; charset=utf-8' });
|
|
226
|
+
res.end(harnessHtml({ ...options, hasServerKey: Boolean(resolveApiKey()) }));
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (req.method === 'GET' && url.pathname === '/widget') {
|
|
230
|
+
const name = url.searchParams.get('name') ?? '';
|
|
231
|
+
readWidget(name, parseArgsParam(url.searchParams.get('args')))
|
|
232
|
+
.then((html) => {
|
|
233
|
+
res.writeHead(200, { 'content-type': 'text/html; charset=utf-8' });
|
|
234
|
+
res.end(html);
|
|
235
|
+
})
|
|
236
|
+
.catch(() => {
|
|
237
|
+
res.writeHead(502, { 'content-type': 'text/html; charset=utf-8' });
|
|
238
|
+
res.end('<!doctype html><p>Failed to load widget.</p>');
|
|
239
|
+
});
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (req.method === 'GET' && url.pathname === '/rpc/log') {
|
|
243
|
+
res.writeHead(200, {
|
|
244
|
+
'content-type': 'text/event-stream',
|
|
245
|
+
'cache-control': 'no-cache',
|
|
246
|
+
connection: 'keep-alive',
|
|
247
|
+
});
|
|
248
|
+
res.flushHeaders(); // open the stream immediately (headers otherwise wait for the first write)
|
|
249
|
+
for (const entry of log)
|
|
250
|
+
res.write(`data: ${JSON.stringify(entry)}\n\n`);
|
|
251
|
+
subscribers.add(res);
|
|
252
|
+
req.on('close', () => subscribers.delete(res));
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
if (req.method === 'GET' && url.pathname === '/reload') {
|
|
256
|
+
res.writeHead(200, {
|
|
257
|
+
'content-type': 'text/event-stream',
|
|
258
|
+
'cache-control': 'no-cache',
|
|
259
|
+
connection: 'keep-alive',
|
|
260
|
+
});
|
|
261
|
+
res.flushHeaders(); // open the stream immediately so the client connects before the first event
|
|
262
|
+
reloadSubscribers.add(res);
|
|
263
|
+
req.on('close', () => reloadSubscribers.delete(res));
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (req.method === 'GET' && url.pathname === '/chat/status') {
|
|
267
|
+
// Report only whether a key is available (and its source) — never the value.
|
|
268
|
+
res.writeHead(200, { 'content-type': 'application/json' });
|
|
269
|
+
res.end(JSON.stringify({ hasKey: Boolean(resolveApiKey()), source: apiKeySource() }));
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (req.method === 'POST' && url.pathname === '/chat/key') {
|
|
273
|
+
// Store the browser-supplied key in this process only (loopback). Set '' to clear it. Never logged.
|
|
274
|
+
const chunks = [];
|
|
275
|
+
req.on('data', (c) => chunks.push(c));
|
|
276
|
+
req.on('end', () => {
|
|
277
|
+
let key = '';
|
|
278
|
+
try {
|
|
279
|
+
key = String(JSON.parse(Buffer.concat(chunks).toString('utf8')).key ?? '');
|
|
280
|
+
}
|
|
281
|
+
catch {
|
|
282
|
+
res.writeHead(400, { 'content-type': 'application/json' });
|
|
283
|
+
res.end(JSON.stringify({ error: { code: 'invalid_json', message: 'invalid JSON' } }));
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
const trimmed = key.trim();
|
|
287
|
+
sessionApiKey = trimmed === '' ? undefined : trimmed;
|
|
288
|
+
res.writeHead(200, { 'content-type': 'application/json' });
|
|
289
|
+
res.end(JSON.stringify({ ok: true, hasKey: Boolean(resolveApiKey()), source: apiKeySource() }));
|
|
290
|
+
});
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
if (req.method === 'POST' && url.pathname === '/chat') {
|
|
294
|
+
// The key lives server-side (session key set via /chat/key, or the env). The browser never sends it.
|
|
295
|
+
const apiKey = resolveApiKey();
|
|
296
|
+
if (!apiKey) {
|
|
297
|
+
res.writeHead(200, { 'content-type': 'application/json' });
|
|
298
|
+
res.end(JSON.stringify({
|
|
299
|
+
error: {
|
|
300
|
+
code: 'no_api_key',
|
|
301
|
+
message: 'No OpenAI key set. Add one in the Chat tab or set OPENAI_API_KEY.',
|
|
302
|
+
},
|
|
303
|
+
}));
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
const chunks = [];
|
|
307
|
+
req.on('data', (c) => chunks.push(c));
|
|
308
|
+
req.on('end', () => {
|
|
309
|
+
let body;
|
|
310
|
+
try {
|
|
311
|
+
body = JSON.parse(Buffer.concat(chunks).toString('utf8'));
|
|
312
|
+
}
|
|
313
|
+
catch {
|
|
314
|
+
res.writeHead(400, { 'content-type': 'application/json' });
|
|
315
|
+
res.end(JSON.stringify({ error: { code: 'invalid_json', message: 'invalid JSON' } }));
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
handleChat(Array.isArray(body.messages) ? body.messages : [], apiKey)
|
|
319
|
+
.then((result) => {
|
|
320
|
+
res.writeHead(200, { 'content-type': 'application/json' });
|
|
321
|
+
res.end(JSON.stringify(result));
|
|
322
|
+
})
|
|
323
|
+
.catch((error) => {
|
|
324
|
+
res.writeHead(200, { 'content-type': 'application/json' });
|
|
325
|
+
res.end(JSON.stringify({
|
|
326
|
+
error: {
|
|
327
|
+
code: 'chat_failed',
|
|
328
|
+
message: error instanceof Error ? error.message : 'chat failed',
|
|
329
|
+
},
|
|
330
|
+
}));
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
if (req.method === 'POST' && url.pathname === '/rpc') {
|
|
336
|
+
const chunks = [];
|
|
337
|
+
req.on('data', (c) => chunks.push(c));
|
|
338
|
+
req.on('end', () => {
|
|
339
|
+
let body;
|
|
340
|
+
try {
|
|
341
|
+
body = JSON.parse(Buffer.concat(chunks).toString('utf8'));
|
|
342
|
+
}
|
|
343
|
+
catch {
|
|
344
|
+
res.writeHead(400, { 'content-type': 'application/json' });
|
|
345
|
+
res.end(JSON.stringify({ error: 'invalid JSON' }));
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
forward(body)
|
|
349
|
+
.then(({ httpStatus, json }) => {
|
|
350
|
+
res.writeHead(httpStatus, { 'content-type': 'application/json' });
|
|
351
|
+
res.end(JSON.stringify(json ?? { error: 'empty response' }));
|
|
352
|
+
})
|
|
353
|
+
.catch((error) => {
|
|
354
|
+
res.writeHead(502, { 'content-type': 'application/json' });
|
|
355
|
+
res.end(JSON.stringify({
|
|
356
|
+
jsonrpc: '2.0',
|
|
357
|
+
id: body.id,
|
|
358
|
+
error: { message: error instanceof Error ? error.message : 'proxy error' },
|
|
359
|
+
}));
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
res.writeHead(404, { 'content-type': 'text/plain' });
|
|
365
|
+
res.end('not found');
|
|
366
|
+
});
|
|
367
|
+
await new Promise((resolve, reject) => {
|
|
368
|
+
// Reject on a bind failure (port in use, permission) so it surfaces as a catchable error instead of an
|
|
369
|
+
// unhandled 'error' event that crashes the CLI and leaves this promise pending. Drop the listener on bind.
|
|
370
|
+
const onError = (error) => reject(error);
|
|
371
|
+
server.once('error', onError);
|
|
372
|
+
server.listen(options.port ?? 0, '127.0.0.1', () => {
|
|
373
|
+
server.removeListener('error', onError);
|
|
374
|
+
resolve();
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
const address = server.address();
|
|
378
|
+
const port = typeof address === 'object' && address !== null ? address.port : options.port;
|
|
379
|
+
return {
|
|
380
|
+
url: `http://127.0.0.1:${port}/`,
|
|
381
|
+
log,
|
|
382
|
+
signalReload,
|
|
383
|
+
close: () => new Promise((resolve, reject) => {
|
|
384
|
+
for (const res of subscribers)
|
|
385
|
+
res.end();
|
|
386
|
+
for (const res of reloadSubscribers)
|
|
387
|
+
res.end();
|
|
388
|
+
subscribers.clear();
|
|
389
|
+
reloadSubscribers.clear();
|
|
390
|
+
server.close((error) => (error ? reject(error) : resolve()));
|
|
391
|
+
}),
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
//# sourceMappingURL=devtools-preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devtools-preview.js","sourceRoot":"","sources":["../src/devtools-preview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA0D,MAAM,WAAW,CAAC;AACjG,OAAO,EAGL,kBAAkB,EAClB,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,WAAW,EACX,gBAAgB,EAGhB,cAAc,GACf,MAAM,uBAAuB,CAAC;AAa/B,+FAA+F;AAC/F,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,CAAC;AAYzD,MAAM,kBAAkB,GACtB,mGAAmG;IACnG,kGAAkG;IAClG,oFAAoF,CAAC;AAuBvF,MAAM,wBAAwB,GAAG,YAAY,CAAC;AAO9C,8GAA8G;AAC9G,SAAS,cAAc,CAAC,GAAkB;IACxC,IAAI,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C;YACxC,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IACjC,MAAM,IAAI,GAAG,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3F,OAAO;QACL,GAAG,EAAE,oBAAoB,IAAI,GAAG;QAChC,GAAG;QACH,YAAY;QACZ,KAAK,EAAE,GAAG,EAAE,CACV,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACpC,KAAK,MAAM,GAAG,IAAI,WAAW;gBAAE,GAAG,CAAC,GAAG,EAAE,CAAC;YACzC,KAAK,MAAM,GAAG,IAAI,iBAAiB;gBAAE,GAAG,CAAC,GAAG,EAAE,CAAC;YAC/C,WAAW,CAAC,KAAK,EAAE,CAAC;YACpB,iBAAiB,CAAC,KAAK,EAAE,CAAC;YAC1B,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC/D,CAAC,CAAC;KACL,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"first-run-entry.d.ts","sourceRoot":"","sources":["../src/first-run-entry.ts"],"names":[],"mappings":"AAcA,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAqBzF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bare-`noodle` first-run detection, kept out of the dispatch-only `cli.ts`.
|
|
3
|
+
*
|
|
4
|
+
* On an interactive TTY for a genuine first-run (no saved account and no project in
|
|
5
|
+
* this directory), offer the guided `noodle start` walkthrough. Everything else —
|
|
6
|
+
* pipes, CI, agents, a configured user, or an existing project — gets plain usage.
|
|
7
|
+
* The wizard is never forced on a non-interactive caller.
|
|
8
|
+
*/
|
|
9
|
+
import { usage } from './commands/shared.js';
|
|
10
|
+
import { readConfig } from './config.js';
|
|
11
|
+
import { runStart } from './first-run.js';
|
|
12
|
+
import { resolveLocalEntrypoint } from './project.js';
|
|
13
|
+
import { confirm, isInteractive } from './prompts.js';
|
|
14
|
+
export async function offerFirstRun(env, home) {
|
|
15
|
+
const config = readConfig(home);
|
|
16
|
+
const configured = config.identity !== undefined || config.authToken !== undefined;
|
|
17
|
+
const hasProject = resolveLocalEntrypoint(process.cwd()) !== undefined;
|
|
18
|
+
if (isInteractive() && !configured && !hasProject) {
|
|
19
|
+
let wants = false;
|
|
20
|
+
try {
|
|
21
|
+
wants = await confirm('New here? Set up your first server with a guided walkthrough?', {
|
|
22
|
+
initial: true,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
wants = false; // Esc/Ctrl+C on the offer → just show usage
|
|
27
|
+
}
|
|
28
|
+
if (wants)
|
|
29
|
+
return runStart([], env, home);
|
|
30
|
+
usage(console.log);
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
usage();
|
|
34
|
+
return 1;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=first-run-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"first-run-entry.js","sourceRoot":"","sources":["../src/first-run-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEtD,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,GAAsB,EAAE,IAAY;IACtE,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,KAAK,SAAS,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,CAAC;IACnF,MAAM,UAAU,GAAG,sBAAsB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,KAAK,SAAS,CAAC;IAEvE,IAAI,aAAa,EAAE,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,EAAE,CAAC;QAClD,IAAI,KAAK,GAAG,KAAK,CAAC;QAClB,IAAI,CAAC;YACH,KAAK,GAAG,MAAM,OAAO,CAAC,+DAA+D,EAAE;gBACrF,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,KAAK,GAAG,KAAK,CAAC,CAAC,4CAA4C;QAC7D,CAAC;QACD,IAAI,KAAK;YAAE,OAAO,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QAC1C,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACnB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,KAAK,EAAE,CAAC;IACR,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface StartFlags {
|
|
2
|
+
json: boolean;
|
|
3
|
+
name?: string | undefined;
|
|
4
|
+
template?: string | undefined;
|
|
5
|
+
where?: 'deploy' | 'local' | undefined;
|
|
6
|
+
org?: string | undefined;
|
|
7
|
+
app?: string | undefined;
|
|
8
|
+
env?: string | undefined;
|
|
9
|
+
access?: string | undefined;
|
|
10
|
+
yes: boolean;
|
|
11
|
+
serviceFlag?: string | undefined;
|
|
12
|
+
authFlag?: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
export declare function parseFlags(rest: readonly string[]): StartFlags;
|
|
15
|
+
export interface StartResult {
|
|
16
|
+
ok: boolean;
|
|
17
|
+
deploymentId?: string;
|
|
18
|
+
url?: string;
|
|
19
|
+
verified?: boolean;
|
|
20
|
+
error?: {
|
|
21
|
+
message: string;
|
|
22
|
+
next?: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export declare function runStart(rest: readonly string[], env: NodeJS.ProcessEnv | undefined, home: string): Promise<number>;
|
|
26
|
+
//# sourceMappingURL=first-run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"first-run.d.ts","sourceRoot":"","sources":["../src/first-run.ts"],"names":[],"mappings":"AA0DA,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,KAAK,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;IACvC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,GAAG,EAAE,OAAO,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAYD,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,CAkB9D;AAgLD,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,OAAO,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5C;AAkPD,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,GAAG,EAAE,MAAM,CAAC,UAAU,YAAc,EACpC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,CA0EjB"}
|