devframe 0.8.2 → 0.9.0-beta.10
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/_shared-BPmX9fqK.d.mts +41 -0
- package/dist/_shared-CbZ_yhbz.mjs +68 -0
- package/dist/adapters/build.d.mts +10 -12
- package/dist/adapters/build.mjs +26 -29
- package/dist/adapters/cac.d.mts +1 -1
- package/dist/adapters/cac.mjs +156 -1
- package/dist/adapters/dev.d.mts +38 -46
- package/dist/adapters/dev.mjs +2 -1
- package/dist/adapters/embedded.d.mts +1 -1
- package/dist/adapters/initiate.d.mts +224 -0
- package/dist/adapters/initiate.mjs +2 -0
- package/dist/adapters/mcp.d.mts +24 -7
- package/dist/adapters/mcp.mjs +2 -2
- package/dist/{agent-tool-name-C3b5vEwJ.mjs → agent-tool-name-EgfoFO8C.mjs} +0 -3
- package/dist/cli/main.d.mts +0 -2
- package/dist/cli/main.mjs +4 -8
- package/dist/client/index.d.mts +71 -7
- package/dist/client/index.mjs +720 -1540
- package/dist/constants.d.mts +28 -7
- package/dist/constants.mjs +28 -7
- package/dist/{context-DoSozfvx.d.mts → context-B3YUu_95.d.mts} +19 -1
- package/dist/{host-h3-D2hYZvDK.mjs → context-CEe4PBz1.mjs} +25 -557
- package/dist/{context-CBg8iRbQ.mjs → context-xdynGSLP.mjs} +10 -1
- package/dist/dev--rAPzbvO.mjs +239 -0
- package/dist/{devframe-mQ4qZAuo.d.mts → devframe-DJMg0WLe.d.mts} +181 -134
- package/dist/{diagnostics-hwjXp_UV.mjs → diagnostics-CD8nlgll.mjs} +1 -3
- package/dist/{diagnostics-D7wM2cwM.mjs → diagnostics-DOQPnQmX.mjs} +51 -5
- package/dist/dist-eNI9qM_I.mjs +228 -0
- package/dist/host-agent-xLCSe65D.mjs +264 -0
- package/dist/host-h3-Crkzm42q.mjs +26 -0
- package/dist/{fetch-BKaD0Vb3.mjs → http-DYpK0cUi.mjs} +42 -11
- package/dist/{index-b64Uuhy2.d.mts → index-CB-fSUyn.d.mts} +2 -2
- package/dist/{index-Dbw1p5ch.d.mts → index-tdrk1bzV.d.mts} +3 -32
- package/dist/index.d.mts +12 -5
- package/dist/index.mjs +8 -1
- package/dist/{instance-registry-BnnA2Eoh.mjs → instance-registry-WvQkt42E.mjs} +9 -8
- package/dist/instance-shell-CMFyszWJ.mjs +486 -0
- package/dist/instance-shell-CljiKq1c.d.mts +255 -0
- package/dist/internal/index.d.mts +397 -0
- package/dist/internal/index.mjs +9 -0
- package/dist/node/auth.d.mts +2 -2
- package/dist/node/auth.mjs +1 -1
- package/dist/node/hub-internals.d.mts +2 -14
- package/dist/node/hub-internals.mjs +2 -2
- package/dist/node/index.d.mts +4 -268
- package/dist/node/index.mjs +3 -5
- package/dist/nostics-CzECRXpE.mjs +59 -0
- package/dist/nostics-SPGDgHEP.d.mts +33 -0
- package/dist/recipes/common-rpc-functions.d.mts +4 -4
- package/dist/recipes/interactive-auth.d.mts +3 -3
- package/dist/recipes/interactive-auth.mjs +8 -8
- package/dist/remote-assets-Bg4gCUZ_.d.mts +123 -0
- package/dist/remote-assets-nTTxY2MU.mjs +636 -0
- package/dist/rolldown-runtime-JspESFgx.mjs +35 -0
- package/dist/rpc/dump.d.mts +77 -1
- package/dist/rpc/dump.mjs +1 -1
- package/dist/rpc/index.d.mts +3 -3
- package/dist/rpc/index.mjs +4 -18
- package/dist/rpc/transports/sse-client.d.mts +2 -0
- package/dist/rpc/transports/sse-client.mjs +142 -0
- package/dist/rpc/transports/sse-server.d.mts +61 -0
- package/dist/rpc/transports/sse-server.mjs +209 -0
- package/dist/rpc/transports/ws-bun.d.mts +35 -0
- package/dist/rpc/transports/ws-bun.mjs +31 -0
- package/dist/rpc/transports/ws-client.d.mts +1 -1
- package/dist/rpc/transports/ws-client.mjs +10 -18
- package/dist/rpc/transports/ws-server.d.mts +2 -2
- package/dist/rpc/transports/ws-server.mjs +2 -235
- package/dist/rpc-core-Cc4lucI0.d.mts +48 -0
- package/dist/rpc-core-DMTe-hLo.mjs +81 -0
- package/dist/{serialization-C8Mnw9hK.mjs → serialization-BGzEwAdr.mjs} +2 -2
- package/dist/{shared-state-6kHolYZy.mjs → shared-state-fRRbRUtD.mjs} +1 -1
- package/dist/sse-client-CFBOIaUi.d.mts +37 -0
- package/dist/state-Cc1IeSmQ.mjs +1291 -0
- package/dist/{dump-CgZShDRB.mjs → static-BPZ1_OPA.mjs} +3 -266
- package/dist/storage-CYye7P7L.mjs +137 -0
- package/dist/types/index.d.mts +6 -4
- package/dist/types/index.mjs +1 -6
- package/dist/{types-CnJSgRVa.d.mts → types-Djq7CBXh.d.mts} +0 -7
- package/dist/utils/agent-tool-name.d.mts +0 -3
- package/dist/utils/agent-tool-name.mjs +0 -3
- package/dist/utils/events.d.mts +1 -1
- package/dist/utils/get-port.d.mts +17 -0
- package/dist/utils/get-port.mjs +2 -0
- package/dist/utils/launch-editor.mjs +1 -25
- package/dist/utils/nostics.d.mts +2 -0
- package/dist/utils/nostics.mjs +2 -0
- package/dist/utils/open.d.mts +2 -10
- package/dist/utils/open.mjs +56 -1
- package/dist/utils/remote-assets.d.mts +15 -0
- package/dist/utils/remote-assets.mjs +2 -0
- package/dist/utils/serve-static.d.mts +13 -5
- package/dist/utils/serve-static.mjs +119 -9
- package/dist/utils/shared-state.d.mts +1 -1
- package/dist/utils/shared-state.mjs +1 -1
- package/dist/utils/simple-schema.d.mts +101 -1
- package/dist/utils/streaming-channel.d.mts +1 -1
- package/dist/validation-CpXFB6Dz.mjs +266 -0
- package/dist/wire-codec-0K-o5MYW.mjs +56 -0
- package/dist/{ws-client-B6Tnr0ic.d.mts → ws-client-DhjNyQo3.d.mts} +7 -2
- package/dist/ws-server-BdSLrhxE.mjs +267 -0
- package/dist/{ws-server-uKQcClcJ.d.mts → ws-server-D1d3QM9f.d.mts} +90 -9
- package/package.json +13 -12
- package/skills/devframe/SKILL.md +91 -93
- package/dist/_shared-bWRzeSa0.mjs +0 -19
- package/dist/adapters/cli.d.mts +0 -11
- package/dist/adapters/cli.mjs +0 -6
- package/dist/cac-D4_9ok0z.mjs +0 -157
- package/dist/dev-Bc49u3qg.mjs +0 -439
- package/dist/diagnostics-reporter-CsIG85Q5.mjs +0 -38
- package/dist/helpers/vite.d.mts +0 -100
- package/dist/helpers/vite.mjs +0 -105
- package/dist/http-C4T68YV6.mjs +0 -38
- package/dist/index-vAX6bYuc.d.mts +0 -78
- package/dist/open-Deb5xmIT.mjs +0 -547
- package/dist/recipes/open-helpers.d.mts +0 -6
- package/dist/recipes/open-helpers.mjs +0 -6
- package/dist/server-CD8XmBXl.mjs +0 -167
- package/dist/server-UHWae43Q.d.mts +0 -149
- package/dist/simple-schema-BDzLeJDk.d.mts +0 -102
- package/dist/state-BeUHDDjk.mjs +0 -108
- package/dist/storage-CTNVbuFB.mjs +0 -1122
- package/dist/utils/promise.d.mts +0 -8
- package/dist/utils/promise.mjs +0 -15
- package/dist/utils/scope.d.mts +0 -11
- package/dist/utils/scope.mjs +0 -15
- package/skills/devframe/templates/spa-devframe.ts +0 -38
|
@@ -1,254 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as diagnostics } from "./diagnostics-
|
|
1
|
+
import { i as defineDiagnostics } from "./nostics-CzECRXpE.mjs";
|
|
2
|
+
import { t as diagnostics } from "./diagnostics-CD8nlgll.mjs";
|
|
3
3
|
import { RpcFunctionsCollectorBase } from "./rpc/index.mjs";
|
|
4
4
|
import { defineRpcFunction } from "./index.mjs";
|
|
5
|
-
import { t as diagnostics$1 } from "./diagnostics-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
5
|
+
import { t as diagnostics$1 } from "./diagnostics-DOQPnQmX.mjs";
|
|
6
|
+
import { r as createEventEmitter, t as DevframeAgentHost } from "./host-agent-xLCSe65D.mjs";
|
|
7
|
+
import { n as createDebug, t as resolveStaticAssetsSource } from "./remote-assets-nTTxY2MU.mjs";
|
|
8
|
+
import { t as createStorage } from "./storage-CYye7P7L.mjs";
|
|
9
|
+
import { createSharedState } from "devframe/utils/shared-state";
|
|
10
10
|
import { existsSync } from "node:fs";
|
|
11
11
|
import { join } from "pathe";
|
|
12
|
-
import process$1 from "node:process";
|
|
13
|
-
import { homedir } from "node:os";
|
|
14
|
-
//#region src/node/agent-args.ts
|
|
15
|
-
/**
|
|
16
|
-
* Map the args payload an agent surface receives (MCP sends an object
|
|
17
|
-
* keyed `arg0`/`arg1`/…, matching the schema the adapter advertises) onto
|
|
18
|
-
* a handler's positional parameters. Shared by the agent host's RPC
|
|
19
|
-
* bridge and the hub's command-derived tools so the coercion cannot
|
|
20
|
-
* drift between them.
|
|
21
|
-
*
|
|
22
|
-
* - an array passes through as-is
|
|
23
|
-
* - `null`/`undefined` become a zero-argument call
|
|
24
|
-
* - with declared schemas, each schema reads its own `argN` key, in order
|
|
25
|
-
* - without schemas, `arg0`/`arg1`/… keys are collected when present
|
|
26
|
-
* - an empty object becomes a zero-argument call
|
|
27
|
-
* - anything else follows the {@link AgentArgsFallback}
|
|
28
|
-
*
|
|
29
|
-
* @experimental
|
|
30
|
-
*/
|
|
31
|
-
function coerceAgentPositionalArgs(args, schemas, fallback = "wrap") {
|
|
32
|
-
if (Array.isArray(args)) return args;
|
|
33
|
-
if (args === void 0 || args === null) return [];
|
|
34
|
-
if (typeof args === "object") {
|
|
35
|
-
const obj = args;
|
|
36
|
-
if (schemas && schemas.length) return schemas.map((_, i) => obj[`arg${i}`]);
|
|
37
|
-
if ("arg0" in obj) {
|
|
38
|
-
const out = [];
|
|
39
|
-
let i = 0;
|
|
40
|
-
while (`arg${i}` in obj) {
|
|
41
|
-
out.push(obj[`arg${i}`]);
|
|
42
|
-
i++;
|
|
43
|
-
}
|
|
44
|
-
return out;
|
|
45
|
-
}
|
|
46
|
-
if (Object.keys(obj).length === 0) return [];
|
|
47
|
-
}
|
|
48
|
-
return fallback === "drop" ? [] : [args];
|
|
49
|
-
}
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/node/host-agent.ts
|
|
52
|
-
/**
|
|
53
|
-
* Framework-neutral host aggregating the agent-exposed surface of a
|
|
54
|
-
* devframe. Auto-discovers RPC functions with an `agent` field from
|
|
55
|
-
* `ctx.rpc.definitions`, and accepts plugin-registered tools /
|
|
56
|
-
* resources via `registerTool` / `registerResource`.
|
|
57
|
-
*
|
|
58
|
-
* @experimental
|
|
59
|
-
*/
|
|
60
|
-
var DevframeAgentHost = class {
|
|
61
|
-
context;
|
|
62
|
-
events = createEventEmitter();
|
|
63
|
-
tools = /* @__PURE__ */ new Map();
|
|
64
|
-
resources = /* @__PURE__ */ new Map();
|
|
65
|
-
providers = /* @__PURE__ */ new Set();
|
|
66
|
-
_rpcUnsubscribe;
|
|
67
|
-
constructor(context) {
|
|
68
|
-
this.context = context;
|
|
69
|
-
this._rpcUnsubscribe = context.rpc.onChanged(() => {
|
|
70
|
-
this.events.emit("agent:manifest:changed");
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
registerTool(input) {
|
|
74
|
-
this._validateToolId(input.id);
|
|
75
|
-
const tool = this._projectTool(input);
|
|
76
|
-
this.tools.set(tool.id, {
|
|
77
|
-
tool,
|
|
78
|
-
handler: input.handler
|
|
79
|
-
});
|
|
80
|
-
this.events.emit("agent:tool:registered", tool);
|
|
81
|
-
this.events.emit("agent:manifest:changed");
|
|
82
|
-
return { unregister: () => this.unregisterTool(tool.id) };
|
|
83
|
-
}
|
|
84
|
-
unregisterTool(id) {
|
|
85
|
-
const existed = this.tools.delete(id);
|
|
86
|
-
if (existed) {
|
|
87
|
-
this.events.emit("agent:tool:unregistered", id);
|
|
88
|
-
this.events.emit("agent:manifest:changed");
|
|
89
|
-
}
|
|
90
|
-
return existed;
|
|
91
|
-
}
|
|
92
|
-
registerToolProvider(provider) {
|
|
93
|
-
this.providers.add(provider);
|
|
94
|
-
this.events.emit("agent:manifest:changed");
|
|
95
|
-
const notifyChanged = () => {
|
|
96
|
-
if (this.providers.has(provider)) this.events.emit("agent:manifest:changed");
|
|
97
|
-
};
|
|
98
|
-
return {
|
|
99
|
-
notifyChanged,
|
|
100
|
-
unregister: () => {
|
|
101
|
-
if (this.providers.delete(provider)) this.events.emit("agent:manifest:changed");
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
registerResource(input) {
|
|
106
|
-
if (this.resources.has(input.id)) throw diagnostics$1.DF0016({ id: input.id });
|
|
107
|
-
const resource = {
|
|
108
|
-
id: input.id,
|
|
109
|
-
name: input.name,
|
|
110
|
-
description: input.description,
|
|
111
|
-
mimeType: input.mimeType ?? "application/json",
|
|
112
|
-
uri: input.uri ?? `devframe://resource/${encodeURIComponent(input.id)}`
|
|
113
|
-
};
|
|
114
|
-
this.resources.set(resource.id, {
|
|
115
|
-
resource,
|
|
116
|
-
read: input.read
|
|
117
|
-
});
|
|
118
|
-
this.events.emit("agent:resource:registered", resource);
|
|
119
|
-
this.events.emit("agent:manifest:changed");
|
|
120
|
-
return { unregister: () => this.unregisterResource(resource.id) };
|
|
121
|
-
}
|
|
122
|
-
unregisterResource(id) {
|
|
123
|
-
const existed = this.resources.delete(id);
|
|
124
|
-
if (existed) {
|
|
125
|
-
this.events.emit("agent:resource:unregistered", id);
|
|
126
|
-
this.events.emit("agent:manifest:changed");
|
|
127
|
-
}
|
|
128
|
-
return existed;
|
|
129
|
-
}
|
|
130
|
-
list() {
|
|
131
|
-
const rpcTools = this._collectRpcTools();
|
|
132
|
-
const plainTools = Array.from(this.tools.values()).map((t) => t.tool);
|
|
133
|
-
const resources = Array.from(this.resources.values()).map((r) => r.resource);
|
|
134
|
-
const seen = new Set([...rpcTools, ...plainTools].map((t) => t.id));
|
|
135
|
-
const providerTools = [];
|
|
136
|
-
for (const { tool } of this._collectProviderTools()) {
|
|
137
|
-
if (seen.has(tool.id)) continue;
|
|
138
|
-
seen.add(tool.id);
|
|
139
|
-
providerTools.push(tool);
|
|
140
|
-
}
|
|
141
|
-
return {
|
|
142
|
-
tools: [
|
|
143
|
-
...rpcTools,
|
|
144
|
-
...plainTools,
|
|
145
|
-
...providerTools
|
|
146
|
-
],
|
|
147
|
-
resources
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
getTool(id) {
|
|
151
|
-
const plain = this.tools.get(id);
|
|
152
|
-
if (plain) return plain.tool;
|
|
153
|
-
const rpc = this._collectRpcTools().find((t) => t.id === id);
|
|
154
|
-
if (rpc) return rpc;
|
|
155
|
-
return this._collectProviderTools().find((t) => t.tool.id === id)?.tool;
|
|
156
|
-
}
|
|
157
|
-
getResource(id) {
|
|
158
|
-
return this.resources.get(id)?.resource;
|
|
159
|
-
}
|
|
160
|
-
async invoke(id, args) {
|
|
161
|
-
const plain = this.tools.get(id);
|
|
162
|
-
if (plain?.handler) return await plain.handler(args);
|
|
163
|
-
const rpcDef = this._findRpcDefinition(id);
|
|
164
|
-
if (rpcDef) {
|
|
165
|
-
const positional = coerceAgentPositionalArgs(args, rpcDef.args, "wrap");
|
|
166
|
-
return await this.context.rpc.invokeLocal(id, ...positional);
|
|
167
|
-
}
|
|
168
|
-
const provided = this._collectProviderTools().find((t) => t.tool.id === id);
|
|
169
|
-
if (provided) return await provided.input.handler(args);
|
|
170
|
-
throw new Error(`[devframe/agent] tool "${id}" not found`);
|
|
171
|
-
}
|
|
172
|
-
async read(id) {
|
|
173
|
-
const entry = this.resources.get(id);
|
|
174
|
-
if (!entry) throw new Error(`[devframe/agent] resource "${id}" not found`);
|
|
175
|
-
return await entry.read();
|
|
176
|
-
}
|
|
177
|
-
/** @internal */
|
|
178
|
-
_dispose() {
|
|
179
|
-
this._rpcUnsubscribe?.();
|
|
180
|
-
this._rpcUnsubscribe = void 0;
|
|
181
|
-
}
|
|
182
|
-
_validateToolId(id) {
|
|
183
|
-
if (this.tools.has(id)) throw diagnostics$1.DF0015({ id });
|
|
184
|
-
if (this.context.rpc.definitions.get(id)?.agent) throw diagnostics$1.DF0015({ id });
|
|
185
|
-
}
|
|
186
|
-
_projectTool(input) {
|
|
187
|
-
if (!input.description || typeof input.description !== "string") throw diagnostics$1.DF0014({ name: input.id });
|
|
188
|
-
return {
|
|
189
|
-
id: input.id,
|
|
190
|
-
kind: "tool",
|
|
191
|
-
title: input.title ?? input.id,
|
|
192
|
-
description: input.description,
|
|
193
|
-
safety: input.safety ?? "action",
|
|
194
|
-
tags: input.tags,
|
|
195
|
-
args: input.args,
|
|
196
|
-
inputSchema: input.inputSchema,
|
|
197
|
-
outputSchema: input.outputSchema,
|
|
198
|
-
examples: input.examples
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
/** Query every registered provider, projecting inputs to serializable tools. */
|
|
202
|
-
_collectProviderTools() {
|
|
203
|
-
const out = [];
|
|
204
|
-
for (const provider of this.providers) for (const input of provider()) out.push({
|
|
205
|
-
input,
|
|
206
|
-
tool: this._projectTool(input)
|
|
207
|
-
});
|
|
208
|
-
return out;
|
|
209
|
-
}
|
|
210
|
-
_collectRpcTools() {
|
|
211
|
-
const out = [];
|
|
212
|
-
for (const [name, def] of this.context.rpc.definitions) {
|
|
213
|
-
const agent = def.agent;
|
|
214
|
-
if (!agent) continue;
|
|
215
|
-
if (!agent.description || typeof agent.description !== "string") throw diagnostics$1.DF0014({ name });
|
|
216
|
-
const type = def.type ?? "query";
|
|
217
|
-
const safety = agent.safety ?? inferSafety(type);
|
|
218
|
-
out.push({
|
|
219
|
-
id: name,
|
|
220
|
-
kind: "rpc",
|
|
221
|
-
title: agent.title ?? name,
|
|
222
|
-
description: agent.description,
|
|
223
|
-
safety,
|
|
224
|
-
tags: agent.tags,
|
|
225
|
-
rpcName: name,
|
|
226
|
-
examples: agent.examples
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
return out;
|
|
230
|
-
}
|
|
231
|
-
_findRpcDefinition(id) {
|
|
232
|
-
const def = this.context.rpc.definitions.get(id);
|
|
233
|
-
if (def?.agent) return def;
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
|
-
function inferSafety(type) {
|
|
237
|
-
if (type === "static" || type === "query") return "read";
|
|
238
|
-
return "action";
|
|
239
|
-
}
|
|
240
|
-
//#endregion
|
|
241
12
|
//#region src/node/host-diagnostics.ts
|
|
242
13
|
var DevframeDiagnosticsHost = class {
|
|
243
14
|
context;
|
|
244
15
|
_registry = {};
|
|
245
16
|
logger = new Proxy({}, { get: (_, code) => this._registry[code] });
|
|
246
|
-
defineDiagnostics =
|
|
247
|
-
return defineDiagnostics({
|
|
248
|
-
...opts,
|
|
249
|
-
reporters: [devframeReporter, ...opts.reporters ?? []]
|
|
250
|
-
});
|
|
251
|
-
};
|
|
17
|
+
defineDiagnostics = defineDiagnostics;
|
|
252
18
|
constructor(context, initialDefinitions = []) {
|
|
253
19
|
this.context = context;
|
|
254
20
|
for (const d of initialDefinitions) this.register(d);
|
|
@@ -258,291 +24,6 @@ var DevframeDiagnosticsHost = class {
|
|
|
258
24
|
}
|
|
259
25
|
};
|
|
260
26
|
//#endregion
|
|
261
|
-
//#region ../../node_modules/.pnpm/obug@2.1.4/node_modules/obug/dist/core.js
|
|
262
|
-
/**
|
|
263
|
-
* Coerce `value`.
|
|
264
|
-
*/
|
|
265
|
-
function coerce(value) {
|
|
266
|
-
if (value instanceof Error) return value.stack || value.message;
|
|
267
|
-
return value;
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Selects a color for a debug namespace
|
|
271
|
-
* @return An ANSI color code for the given namespace
|
|
272
|
-
*/
|
|
273
|
-
function selectColor(colors, namespace) {
|
|
274
|
-
let hash = 0;
|
|
275
|
-
for (let i = 0; i < namespace.length; i++) {
|
|
276
|
-
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
277
|
-
hash |= 0;
|
|
278
|
-
}
|
|
279
|
-
return colors[Math.abs(hash) % colors.length];
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Checks if the given string matches a namespace template, honoring
|
|
283
|
-
* asterisks as wildcards.
|
|
284
|
-
*/
|
|
285
|
-
function matchesTemplate(search, template) {
|
|
286
|
-
let searchIndex = 0;
|
|
287
|
-
let templateIndex = 0;
|
|
288
|
-
let starIndex = -1;
|
|
289
|
-
let matchIndex = 0;
|
|
290
|
-
while (searchIndex < search.length) if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) if (template[templateIndex] === "*") {
|
|
291
|
-
starIndex = templateIndex;
|
|
292
|
-
matchIndex = searchIndex;
|
|
293
|
-
templateIndex++;
|
|
294
|
-
} else {
|
|
295
|
-
searchIndex++;
|
|
296
|
-
templateIndex++;
|
|
297
|
-
}
|
|
298
|
-
else if (starIndex !== -1) {
|
|
299
|
-
templateIndex = starIndex + 1;
|
|
300
|
-
matchIndex++;
|
|
301
|
-
searchIndex = matchIndex;
|
|
302
|
-
} else return false;
|
|
303
|
-
while (templateIndex < template.length && template[templateIndex] === "*") templateIndex++;
|
|
304
|
-
return templateIndex === template.length;
|
|
305
|
-
}
|
|
306
|
-
function humanize(value) {
|
|
307
|
-
if (value >= 1e3) return `${(value / 1e3).toFixed(1)}s`;
|
|
308
|
-
return `${value}ms`;
|
|
309
|
-
}
|
|
310
|
-
let globalNamespaces = "";
|
|
311
|
-
function createDebug$1(namespace, options) {
|
|
312
|
-
let prevTime;
|
|
313
|
-
let enableOverride;
|
|
314
|
-
let namespacesCache;
|
|
315
|
-
let enabledCache;
|
|
316
|
-
const debug = (...args) => {
|
|
317
|
-
if (!debug.enabled) return;
|
|
318
|
-
const curr = Date.now();
|
|
319
|
-
const diff = curr - (prevTime || curr);
|
|
320
|
-
prevTime = curr;
|
|
321
|
-
args[0] = coerce(args[0]);
|
|
322
|
-
if (typeof args[0] !== "string") args.unshift("%O");
|
|
323
|
-
let index = 0;
|
|
324
|
-
args[0] = args[0].replace(/%([a-z%])/gi, (match, format) => {
|
|
325
|
-
if (match === "%%") return "%";
|
|
326
|
-
index++;
|
|
327
|
-
const formatter = options.formatters[format];
|
|
328
|
-
if (typeof formatter === "function") {
|
|
329
|
-
const value = args[index];
|
|
330
|
-
match = formatter.call(debug, value);
|
|
331
|
-
args.splice(index, 1);
|
|
332
|
-
index--;
|
|
333
|
-
}
|
|
334
|
-
return match;
|
|
335
|
-
});
|
|
336
|
-
options.formatArgs.call(debug, diff, args);
|
|
337
|
-
debug.log(...args);
|
|
338
|
-
};
|
|
339
|
-
debug.extend = function(namespace, delimiter = ":") {
|
|
340
|
-
return createDebug$1(this.namespace + delimiter + namespace, {
|
|
341
|
-
useColors: this.useColors,
|
|
342
|
-
color: this.color,
|
|
343
|
-
formatArgs: this.formatArgs,
|
|
344
|
-
formatters: this.formatters,
|
|
345
|
-
inspectOpts: this.inspectOpts,
|
|
346
|
-
log: this.log,
|
|
347
|
-
humanize: this.humanize
|
|
348
|
-
});
|
|
349
|
-
};
|
|
350
|
-
Object.assign(debug, options);
|
|
351
|
-
debug.namespace = namespace;
|
|
352
|
-
Object.defineProperty(debug, "enabled", {
|
|
353
|
-
enumerable: true,
|
|
354
|
-
configurable: false,
|
|
355
|
-
get: () => {
|
|
356
|
-
if (enableOverride != null) return enableOverride;
|
|
357
|
-
if (namespacesCache !== globalNamespaces) {
|
|
358
|
-
namespacesCache = globalNamespaces;
|
|
359
|
-
enabledCache = enabled(namespace);
|
|
360
|
-
}
|
|
361
|
-
return enabledCache;
|
|
362
|
-
},
|
|
363
|
-
set: (v) => {
|
|
364
|
-
enableOverride = v;
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
return debug;
|
|
368
|
-
}
|
|
369
|
-
let names = [];
|
|
370
|
-
let skips = [];
|
|
371
|
-
function enable(namespaces) {
|
|
372
|
-
globalNamespaces = namespaces;
|
|
373
|
-
names = [];
|
|
374
|
-
skips = [];
|
|
375
|
-
const split = globalNamespaces.trim().replace(/\s+/g, ",").split(",").filter(Boolean);
|
|
376
|
-
for (const ns of split) if (ns[0] === "-") skips.push(ns.slice(1));
|
|
377
|
-
else names.push(ns);
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* Returns true if the given mode name is enabled, false otherwise.
|
|
381
|
-
*/
|
|
382
|
-
function enabled(name) {
|
|
383
|
-
for (const skip of skips) if (matchesTemplate(name, skip)) return false;
|
|
384
|
-
for (const ns of names) if (matchesTemplate(name, ns)) return true;
|
|
385
|
-
return false;
|
|
386
|
-
}
|
|
387
|
-
//#endregion
|
|
388
|
-
//#region ../../node_modules/.pnpm/obug@2.1.4/node_modules/obug/dist/node.js
|
|
389
|
-
let env = {};
|
|
390
|
-
try {
|
|
391
|
-
process.env.DEBUG;
|
|
392
|
-
env = process.env;
|
|
393
|
-
} catch (_unused) {}
|
|
394
|
-
const colors = process.stderr.getColorDepth && process.stderr.getColorDepth(env) > 2 ? [
|
|
395
|
-
20,
|
|
396
|
-
21,
|
|
397
|
-
26,
|
|
398
|
-
27,
|
|
399
|
-
32,
|
|
400
|
-
33,
|
|
401
|
-
38,
|
|
402
|
-
39,
|
|
403
|
-
40,
|
|
404
|
-
41,
|
|
405
|
-
42,
|
|
406
|
-
43,
|
|
407
|
-
44,
|
|
408
|
-
45,
|
|
409
|
-
56,
|
|
410
|
-
57,
|
|
411
|
-
62,
|
|
412
|
-
63,
|
|
413
|
-
68,
|
|
414
|
-
69,
|
|
415
|
-
74,
|
|
416
|
-
75,
|
|
417
|
-
76,
|
|
418
|
-
77,
|
|
419
|
-
78,
|
|
420
|
-
79,
|
|
421
|
-
80,
|
|
422
|
-
81,
|
|
423
|
-
92,
|
|
424
|
-
93,
|
|
425
|
-
98,
|
|
426
|
-
99,
|
|
427
|
-
112,
|
|
428
|
-
113,
|
|
429
|
-
128,
|
|
430
|
-
129,
|
|
431
|
-
134,
|
|
432
|
-
135,
|
|
433
|
-
148,
|
|
434
|
-
149,
|
|
435
|
-
160,
|
|
436
|
-
161,
|
|
437
|
-
162,
|
|
438
|
-
163,
|
|
439
|
-
164,
|
|
440
|
-
165,
|
|
441
|
-
166,
|
|
442
|
-
167,
|
|
443
|
-
168,
|
|
444
|
-
169,
|
|
445
|
-
170,
|
|
446
|
-
171,
|
|
447
|
-
172,
|
|
448
|
-
173,
|
|
449
|
-
178,
|
|
450
|
-
179,
|
|
451
|
-
184,
|
|
452
|
-
185,
|
|
453
|
-
196,
|
|
454
|
-
197,
|
|
455
|
-
198,
|
|
456
|
-
199,
|
|
457
|
-
200,
|
|
458
|
-
201,
|
|
459
|
-
202,
|
|
460
|
-
203,
|
|
461
|
-
204,
|
|
462
|
-
205,
|
|
463
|
-
206,
|
|
464
|
-
207,
|
|
465
|
-
208,
|
|
466
|
-
209,
|
|
467
|
-
214,
|
|
468
|
-
215,
|
|
469
|
-
220,
|
|
470
|
-
221
|
|
471
|
-
] : [
|
|
472
|
-
6,
|
|
473
|
-
2,
|
|
474
|
-
3,
|
|
475
|
-
4,
|
|
476
|
-
5,
|
|
477
|
-
1
|
|
478
|
-
];
|
|
479
|
-
const inspectOpts = Object.keys(env).filter((key) => /^debug_/i.test(key)).reduce((obj, key) => {
|
|
480
|
-
const prop = key.slice(6).toLowerCase().replace(/_([a-z])/g, (_, k) => k.toUpperCase());
|
|
481
|
-
let value = env[key];
|
|
482
|
-
const lowerCase = typeof value === "string" && value.toLowerCase();
|
|
483
|
-
if (value === "null") value = null;
|
|
484
|
-
else if (lowerCase === "yes" || lowerCase === "on" || lowerCase === "true" || lowerCase === "enabled") value = true;
|
|
485
|
-
else if (lowerCase === "no" || lowerCase === "off" || lowerCase === "false" || lowerCase === "disabled") value = false;
|
|
486
|
-
else value = Number(value);
|
|
487
|
-
obj[prop] = value;
|
|
488
|
-
return obj;
|
|
489
|
-
}, Object.create(null));
|
|
490
|
-
/**
|
|
491
|
-
* Is stdout a TTY? Colored output is enabled when `true`.
|
|
492
|
-
*/
|
|
493
|
-
function useColors() {
|
|
494
|
-
return "colors" in inspectOpts ? Boolean(inspectOpts.colors) : isatty(process.stderr.fd);
|
|
495
|
-
}
|
|
496
|
-
function getDate() {
|
|
497
|
-
if (inspectOpts.hideDate) return "";
|
|
498
|
-
return `${(/* @__PURE__ */ new Date()).toISOString()} `;
|
|
499
|
-
}
|
|
500
|
-
/**
|
|
501
|
-
* Adds ANSI color escape codes if enabled.
|
|
502
|
-
*/
|
|
503
|
-
function formatArgs(diff, args) {
|
|
504
|
-
const { namespace: name, useColors } = this;
|
|
505
|
-
if (useColors) {
|
|
506
|
-
const c = this.color;
|
|
507
|
-
const colorCode = `\u001B[3${c < 8 ? c : `8;5;${c}`}`;
|
|
508
|
-
const prefix = ` ${colorCode};1m${name} \u001B[0m`;
|
|
509
|
-
args[0] = prefix + args[0].split("\n").join(`\n${prefix}`);
|
|
510
|
-
args.push(`${colorCode}m+${this.humanize(diff)}\u001B[0m`);
|
|
511
|
-
} else args[0] = `${getDate()}${name} ${args[0]}`;
|
|
512
|
-
}
|
|
513
|
-
function log(...args) {
|
|
514
|
-
process.stderr.write(`${formatWithOptions(this.inspectOpts, ...args)}\n`);
|
|
515
|
-
}
|
|
516
|
-
const defaultOptions = {
|
|
517
|
-
useColors: useColors(),
|
|
518
|
-
formatArgs,
|
|
519
|
-
formatters: {
|
|
520
|
-
/**
|
|
521
|
-
* Map %o to `util.inspect()`, all on a single line.
|
|
522
|
-
*/
|
|
523
|
-
o(v) {
|
|
524
|
-
this.inspectOpts.colors = this.useColors;
|
|
525
|
-
return inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
|
|
526
|
-
},
|
|
527
|
-
/**
|
|
528
|
-
* Map %O to `util.inspect()`, allowing multiple lines if needed.
|
|
529
|
-
*/
|
|
530
|
-
O(v) {
|
|
531
|
-
this.inspectOpts.colors = this.useColors;
|
|
532
|
-
return inspect(v, this.inspectOpts);
|
|
533
|
-
}
|
|
534
|
-
},
|
|
535
|
-
inspectOpts,
|
|
536
|
-
log,
|
|
537
|
-
humanize
|
|
538
|
-
};
|
|
539
|
-
function createDebug(namespace, options) {
|
|
540
|
-
var _ref;
|
|
541
|
-
const color = (_ref = options && options.color) !== null && _ref !== void 0 ? _ref : selectColor(colors, namespace);
|
|
542
|
-
return createDebug$1(namespace, Object.assign(defaultOptions, { color }, options));
|
|
543
|
-
}
|
|
544
|
-
enable(env.DEBUG || "");
|
|
545
|
-
//#endregion
|
|
546
27
|
//#region src/node/rpc-shared-state.ts
|
|
547
28
|
const debug$1 = createDebug("devframe:rpc:state:changed");
|
|
548
29
|
const debugSubscribe = createDebug("devframe:rpc:state:subscribe");
|
|
@@ -659,6 +140,15 @@ function createRpcSharedStateServerHost(rpc) {
|
|
|
659
140
|
return host;
|
|
660
141
|
}
|
|
661
142
|
//#endregion
|
|
143
|
+
//#region src/utils/nanoid.ts
|
|
144
|
+
const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
145
|
+
function nanoid(size = 21) {
|
|
146
|
+
let id = "";
|
|
147
|
+
let i = size;
|
|
148
|
+
while (i--) id += urlAlphabet[Math.random() * 64 | 0];
|
|
149
|
+
return id;
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
662
152
|
//#region src/utils/streaming-channel.ts
|
|
663
153
|
const DEFAULT_HIGH_WATER_MARK = 256;
|
|
664
154
|
var StreamClosedError = class extends Error {
|
|
@@ -1217,7 +707,7 @@ const debugBroadcast = createDebug("devframe:rpc:broadcast");
|
|
|
1217
707
|
* Concrete implementation backing `ctx.rpc`. Internal: consumers should
|
|
1218
708
|
* depend on the structural {@link RpcFunctionsHost} type, never this class.
|
|
1219
709
|
* Its `@internal` members (`_rpcGroup`, `_asyncStorage`,
|
|
1220
|
-
* `_emitSessionDisconnected`) are wired by `
|
|
710
|
+
* `_emitSessionDisconnected`) are wired by `createContextRpcServer` and must not
|
|
1221
711
|
* widen the public surface.
|
|
1222
712
|
*
|
|
1223
713
|
* @internal
|
|
@@ -1321,13 +811,14 @@ var DevframeViewHost = class {
|
|
|
1321
811
|
constructor(context) {
|
|
1322
812
|
this.context = context;
|
|
1323
813
|
}
|
|
1324
|
-
hostStatic(baseUrl,
|
|
1325
|
-
|
|
814
|
+
hostStatic(baseUrl, source) {
|
|
815
|
+
const resolved = resolveStaticAssetsSource(source, this.context.host.getStorageDir("project"));
|
|
816
|
+
if (typeof resolved === "string" && !existsSync(resolved)) throw diagnostics$1.DF0008({ distDir: resolved });
|
|
1326
817
|
this.buildStaticDirs.push({
|
|
1327
818
|
baseUrl,
|
|
1328
|
-
|
|
819
|
+
source
|
|
1329
820
|
});
|
|
1330
|
-
this.context.host.mountStatic(baseUrl,
|
|
821
|
+
this.context.host.mountStatic(baseUrl, resolved);
|
|
1331
822
|
}
|
|
1332
823
|
};
|
|
1333
824
|
//#endregion
|
|
@@ -1359,8 +850,6 @@ const agentListResources = defineRpcFunction({
|
|
|
1359
850
|
* Built-in agent introspection RPC functions. Registered automatically
|
|
1360
851
|
* by `createHostContext`. Not themselves agent-exposed (no `agent`
|
|
1361
852
|
* field) — they power the MCP adapter and any future agent CLI.
|
|
1362
|
-
*
|
|
1363
|
-
* @experimental
|
|
1364
853
|
*/
|
|
1365
854
|
const BUILTIN_AGENT_RPC = [
|
|
1366
855
|
defineRpcFunction({
|
|
@@ -1525,6 +1014,7 @@ async function createHostContext(options) {
|
|
|
1525
1014
|
diagnostics: void 0,
|
|
1526
1015
|
agent: void 0,
|
|
1527
1016
|
services: void 0,
|
|
1017
|
+
staticConfig: {},
|
|
1528
1018
|
scope: void 0
|
|
1529
1019
|
};
|
|
1530
1020
|
const rpcHost = new RpcFunctionsHostImpl(context);
|
|
@@ -1550,26 +1040,4 @@ async function createHostContext(options) {
|
|
|
1550
1040
|
return context;
|
|
1551
1041
|
}
|
|
1552
1042
|
//#endregion
|
|
1553
|
-
|
|
1554
|
-
/**
|
|
1555
|
-
* h3-backed {@link DevframeHost} — used by the standalone CLI adapter.
|
|
1556
|
-
*/
|
|
1557
|
-
function createH3DevframeHost(options) {
|
|
1558
|
-
const workspaceRoot = options.workspaceRoot ?? process$1.cwd();
|
|
1559
|
-
return {
|
|
1560
|
-
mountStatic(base, distDir) {
|
|
1561
|
-
return options.mount?.(base, distDir);
|
|
1562
|
-
},
|
|
1563
|
-
resolveOrigin() {
|
|
1564
|
-
return options.origin;
|
|
1565
|
-
},
|
|
1566
|
-
getStorageDir(scope) {
|
|
1567
|
-
const namespace = `.${options.appName}/devframe`;
|
|
1568
|
-
if (scope === "workspace") return join(workspaceRoot, ".devframe");
|
|
1569
|
-
if (scope === "project") return join(workspaceRoot, "node_modules", namespace);
|
|
1570
|
-
return join(homedir(), namespace);
|
|
1571
|
-
}
|
|
1572
|
-
};
|
|
1573
|
-
}
|
|
1574
|
-
//#endregion
|
|
1575
|
-
export { DevframeViewHost as a, createRpcSharedStateServerHost as c, coerceAgentPositionalArgs as d, createNodeSettings as i, DevframeDiagnosticsHost as l, createHostContext as n, DevframeServicesHostImpl as o, createScopedNodeContext as r, createRpcStreamingServerHost as s, createH3DevframeHost as t, DevframeAgentHost as u };
|
|
1043
|
+
export { createHostContext as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as randomToken } from "./crypto-token-XCqTSMg9.mjs";
|
|
2
|
-
import { t as createStorage } from "./storage-
|
|
2
|
+
import { t as createStorage } from "./storage-CYye7P7L.mjs";
|
|
3
3
|
import { n as revokeAuthToken, t as revokeActiveConnectionsForToken } from "./revoke-DZbJ7Cl0.mjs";
|
|
4
4
|
import { join } from "pathe";
|
|
5
5
|
//#region src/node/hub-internals/context.ts
|
|
@@ -11,6 +11,7 @@ function getInternalContext(context) {
|
|
|
11
11
|
initialValue: { trusted: {} }
|
|
12
12
|
});
|
|
13
13
|
const remoteTokens = /* @__PURE__ */ new Map();
|
|
14
|
+
const wsEndpointListeners = /* @__PURE__ */ new Set();
|
|
14
15
|
function revokeRemoteToken(token) {
|
|
15
16
|
if (!remoteTokens.delete(token)) return;
|
|
16
17
|
revokeActiveConnectionsForToken(context, token);
|
|
@@ -18,6 +19,14 @@ function getInternalContext(context) {
|
|
|
18
19
|
const internalContext = {
|
|
19
20
|
storage: { auth: storage },
|
|
20
21
|
revokeAuthToken: (token) => revokeAuthToken(context, storage, token),
|
|
22
|
+
setWsEndpoint(endpoint) {
|
|
23
|
+
internalContext.wsEndpoint = endpoint;
|
|
24
|
+
for (const listener of wsEndpointListeners) listener();
|
|
25
|
+
},
|
|
26
|
+
onWsEndpointChange(cb) {
|
|
27
|
+
wsEndpointListeners.add(cb);
|
|
28
|
+
return () => wsEndpointListeners.delete(cb);
|
|
29
|
+
},
|
|
21
30
|
remoteTokens,
|
|
22
31
|
allocateRemoteToken(dockId, origin, originLock) {
|
|
23
32
|
const token = randomToken();
|