devframe 0.9.0 → 0.9.2

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.
Files changed (79) hide show
  1. package/dist/{_shared-BPmX9fqK.d.mts → _shared-BAGBgTUO.d.mts} +1 -1
  2. package/dist/{_shared-CbZ_yhbz.mjs → _shared-BM3PdYli.mjs} +1 -1
  3. package/dist/adapters/build.d.mts +1 -1
  4. package/dist/adapters/build.mjs +12 -9
  5. package/dist/adapters/cac.d.mts +1 -1
  6. package/dist/adapters/cac.mjs +4 -3
  7. package/dist/adapters/dev.d.mts +3 -3
  8. package/dist/adapters/dev.mjs +2 -2
  9. package/dist/adapters/embedded.d.mts +1 -1
  10. package/dist/adapters/embedded.mjs +2 -0
  11. package/dist/adapters/initiate.d.mts +2 -2
  12. package/dist/adapters/initiate.mjs +1 -1
  13. package/dist/adapters/mcp.d.mts +1 -1
  14. package/dist/adapters/mcp.mjs +1 -1
  15. package/dist/cli/main.mjs +2 -2
  16. package/dist/client/index.d.mts +48 -2
  17. package/dist/client/index.mjs +133 -23
  18. package/dist/constants.d.mts +74 -2
  19. package/dist/constants.mjs +9 -2
  20. package/dist/{context-xdynGSLP.mjs → context-af2w_F0_.mjs} +2 -2
  21. package/dist/{context-B3YUu_95.d.mts → context-al99DDJ8.d.mts} +1 -1
  22. package/dist/{context-CEe4PBz1.mjs → context-riPPHGiu.mjs} +339 -26
  23. package/dist/{dev--rAPzbvO.mjs → dev-BKm_HisC.mjs} +15 -11
  24. package/dist/{devframe-DJMg0WLe.d.mts → devframe-mbfgpQQC.d.mts} +774 -587
  25. package/dist/{diagnostics-DOQPnQmX.mjs → diagnostics-DI1HGj2I.mjs} +20 -0
  26. package/dist/{dist-eNI9qM_I.mjs → dist-CZXfGEkd.mjs} +1 -1
  27. package/dist/events-DKfSmoTj.mjs +65 -0
  28. package/dist/hash-DdPnc4k3.mjs +360 -0
  29. package/dist/{host-agent-xLCSe65D.mjs → host-agent-DVDLqjvj.mjs} +14 -13
  30. package/dist/{http-DYpK0cUi.mjs → http-POepPnaQ.mjs} +10 -6
  31. package/dist/{index-CB-fSUyn.d.mts → index-Dipgo9ji.d.mts} +2 -2
  32. package/dist/index.d.mts +2 -2
  33. package/dist/{instance-registry-WvQkt42E.mjs → instance-registry-Dy28drtm.mjs} +4 -4
  34. package/dist/{instance-shell-CMFyszWJ.mjs → instance-shell-GqTY93gC.mjs} +5 -5
  35. package/dist/{instance-shell-CljiKq1c.d.mts → instance-shell-mU5j5xWn.d.mts} +2 -2
  36. package/dist/internal/index.d.mts +40 -4
  37. package/dist/internal/index.mjs +7 -7
  38. package/dist/node/auth.d.mts +2 -2
  39. package/dist/node/auth.mjs +2 -2
  40. package/dist/node/hub-internals.d.mts +2 -2
  41. package/dist/node/hub-internals.mjs +2 -2
  42. package/dist/node/index.d.mts +10 -1
  43. package/dist/node/index.mjs +2 -2
  44. package/dist/recipes/common-rpc-functions.d.mts +11 -1
  45. package/dist/recipes/common-rpc-functions.mjs +10 -0
  46. package/dist/recipes/interactive-auth.d.mts +2 -2
  47. package/dist/recipes/interactive-auth.mjs +2 -2
  48. package/dist/{remote-assets-nTTxY2MU.mjs → remote-assets-CqxiyltC.mjs} +18 -7
  49. package/dist/{revoke-DZbJ7Cl0.mjs → revoke-3Q6aDKWk.mjs} +2 -1
  50. package/dist/{rolldown-runtime-JspESFgx.mjs → rolldown-runtime-B4iAMlE-.mjs} +1 -1
  51. package/dist/rpc/dump.mjs +1 -1
  52. package/dist/rpc/index.mjs +1 -1
  53. package/dist/rpc/transports/ws-bun.d.mts +1 -1
  54. package/dist/rpc/transports/ws-deno.d.mts +26 -0
  55. package/dist/rpc/transports/ws-deno.mjs +30 -0
  56. package/dist/{rpc-core-DMTe-hLo.mjs → rpc-core-DRYnbxdD.mjs} +2 -2
  57. package/dist/{rpc-core-Cc4lucI0.d.mts → rpc-core-dV69u4lY.d.mts} +2 -2
  58. package/dist/{shared-state-fRRbRUtD.mjs → shared-state-DoXutg_U.mjs} +1 -1
  59. package/dist/{state-Cc1IeSmQ.mjs → state-CK9LjrnT.mjs} +1 -1
  60. package/dist/{static-BPZ1_OPA.mjs → static-DV_qUSRS.mjs} +1 -1
  61. package/dist/{storage-CYye7P7L.mjs → storage-BNqSAOxA.mjs} +3 -3
  62. package/dist/types/index.d.mts +2 -2
  63. package/dist/utils/events.d.mts +1 -1
  64. package/dist/utils/get-port.mjs +1 -1
  65. package/dist/utils/hash.mjs +1 -1
  66. package/dist/utils/launch-editor.mjs +12 -11
  67. package/dist/utils/open.mjs +1 -1
  68. package/dist/utils/remote-assets.d.mts +7 -1
  69. package/dist/utils/remote-assets.mjs +1 -1
  70. package/dist/utils/serve-static.mjs +6 -5
  71. package/dist/utils/shared-state.d.mts +1 -1
  72. package/dist/utils/shared-state.mjs +1 -1
  73. package/dist/utils/streaming-channel.d.mts +1 -1
  74. package/dist/validation-YrZH6atx.mjs +311 -0
  75. package/package.json +4 -3
  76. package/skills/devframe/SKILL.md +1 -1
  77. package/dist/hash-KtDZYXDN.mjs +0 -266
  78. package/dist/validation-CpXFB6Dz.mjs +0 -266
  79. package/dist/{host-h3-Crkzm42q.mjs → host-h3-fRbF9yor.mjs} +1 -1
@@ -137,6 +137,26 @@ const diagnostics = defineDiagnostics({
137
137
  DF0065: {
138
138
  why: (p) => `Invalid remote-assets ${p.field} "${p.value}".`,
139
139
  fix: "A remote-assets `package` must be a valid npm package name and `version` an exact semver version (e.g. `1.2.3`) — they are interpolated into CDN URLs and the cache path."
140
+ },
141
+ DF0066: {
142
+ why: (p) => `Service "${p.package}" is already installed — keeping the first installation and ignoring this one's options.`,
143
+ fix: "Option sets only merge before `ctx.services.ready()` fires. Install the service (or declare it in `DevframeDefinition.services`) before the barrier so its options join the merge."
144
+ },
145
+ DF0067: {
146
+ why: (p) => `Failed to import the required service package "${p.package}": ${p.reason}`,
147
+ fix: "Install the service package next to whoever declares it (a plugin declaring it in `services` should list it in its own dependencies), or drop `required: true` to degrade gracefully when it is absent."
148
+ },
149
+ DF0068: {
150
+ why: (p) => `The installed service "${p.package}@${p.installed}" does not satisfy the required range "${p.required}".`,
151
+ fix: "Align the installed service package with the range its declarer requires, or drop `required: true` to downgrade the mismatch to a warning."
152
+ },
153
+ DF0069: {
154
+ why: (p) => `The installed service "${p.package}@${p.installed}" does not satisfy the declared range "${p.required}" — installing it anyway.`,
155
+ fix: "The advertised meta carries the real version, so clients can gate on it. Align the installed service package with the declared range to silence this warning."
156
+ },
157
+ DF0070: {
158
+ why: (p) => `Invalid service "${p.package}": ${p.reason}`,
159
+ fix: "A service package's default export must be a factory returning a `DevframeServiceDefinition` — an object with `package`, `version`, `scope`, and a `setup` function."
140
160
  }
141
161
  }
142
162
  });
@@ -1,4 +1,4 @@
1
- import { n as __exportAll } from "./rolldown-runtime-JspESFgx.mjs";
1
+ import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.mjs";
2
2
  import "node:fs/promises";
3
3
  import { createServer } from "node:net";
4
4
  import { networkInterfaces } from "node:os";
@@ -0,0 +1,65 @@
1
+ //#region src/events.ts
2
+ /**
3
+ * Centralized registry of the core devframe event names — the node-side host
4
+ * bus events, the client RPC connection events, and the server→client
5
+ * broadcast notifications — so these names live in one place instead of
6
+ * scattered string literals.
7
+ *
8
+ * **Keep this in sync with [`docs/guide/events.md`](../../../docs/guide/events.md)**
9
+ * (the "Core devframe events" section): every name here appears in that page's
10
+ * tables, and every name there resolves to an entry here. Add, rename, or
11
+ * remove a name in both places in the same change, and reference
12
+ * `DEVFRAME_EVENTS.*` from call sites instead of re-typing a literal.
13
+ *
14
+ * This map covers **notifications** (events, broadcasts). The request/response
15
+ * RPC endpoints of the shared-state, streaming, and auth-handshake protocols
16
+ * (`devframe:rpc:server-state:*`, `devframe:streaming:subscribe`,
17
+ * `anonymous:devframe:auth`, …) are defined at their handlers and typed in
18
+ * `types/rpc-augments.ts`; they aren't events and stay out of this map.
19
+ *
20
+ * The `EventEmitter` maps (`RpcClientEvents`, `DevframeAgentHostEvents`) and the
21
+ * `DevframeRpcClientFunctions` augmentation declare these names as type-level
22
+ * keys (a literal is unavoidable in a type position); those declarations mirror
23
+ * this map and move with it.
24
+ */
25
+ const DEVFRAME_EVENTS = {
26
+ /**
27
+ * Node-side host `EventEmitter` events. The agent host (`ctx.agent.events`)
28
+ * emits these as its tool/resource surface changes; protocol adapters (e.g.
29
+ * MCP) subscribe to re-publish their manifest.
30
+ */
31
+ bus: {
32
+ agentManifestChanged: "agent:manifest:changed",
33
+ agentToolRegistered: "agent:tool:registered",
34
+ agentToolUnregistered: "agent:tool:unregistered",
35
+ agentResourceRegistered: "agent:resource:registered",
36
+ agentResourceUnregistered: "agent:resource:unregistered"
37
+ },
38
+ /**
39
+ * Client-side RPC connection `EventEmitter` events (`rpc.events`) a UI
40
+ * subscribes to for connection lifecycle and error surfacing.
41
+ */
42
+ client: {
43
+ isTrustedUpdated: "rpc:is-trusted:updated",
44
+ error: "rpc:error",
45
+ connectionStatus: "connection:status",
46
+ connectionError: "connection:error"
47
+ },
48
+ /**
49
+ * Broadcast notifications the server pushes to clients (server → client),
50
+ * `devframe:` prefix. The paired request methods (subscribe/get/set/…) are
51
+ * RPC endpoints, not events, and are omitted deliberately.
52
+ */
53
+ broadcast: {
54
+ authRevoked: "devframe:auth:revoked",
55
+ clientStateUpdated: "devframe:rpc:client-state:updated",
56
+ clientStatePatch: "devframe:rpc:client-state:patch",
57
+ streamingChunk: "devframe:streaming:chunk",
58
+ streamingEnd: "devframe:streaming:end",
59
+ streamingUploadCancel: "devframe:streaming:upload-cancel"
60
+ },
61
+ /** `postMessage` channels the runtime posts across window boundaries. */
62
+ postMessage: { remoteAssetsError: "devframe:remote-assets-error" }
63
+ };
64
+ //#endregion
65
+ export { DEVFRAME_EVENTS as t };
@@ -0,0 +1,360 @@
1
+ //#region ../../node_modules/.pnpm/ohash@2.0.12/node_modules/ohash/dist/_chunks/is-equal.mjs
2
+ function serialize(input) {
3
+ if (typeof input === "string") return `'${input}'`;
4
+ return new Serializer().serialize(input);
5
+ }
6
+ const asciiOrder = " _-,;:!?.'\"()[]{}@*/\\&#%`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz";
7
+ const asciiWeights = /*@__PURE__*/ (function() {
8
+ const weights = /* @__PURE__ */ new Uint8Array(128);
9
+ for (let i = 0; i < 69; i++) weights[asciiOrder.charCodeAt(i)] = i + 1;
10
+ for (let code = 65; code <= 90; code++) weights[code] = weights[code + 32];
11
+ return weights;
12
+ })();
13
+ function compareStrings(a, b) {
14
+ if (a === b) return 0;
15
+ const length = Math.min(a.length, b.length);
16
+ let tieBreaker = 0;
17
+ for (let i = 0; i < length; i++) {
18
+ const codeA = a.charCodeAt(i);
19
+ const codeB = b.charCodeAt(i);
20
+ if (codeA === codeB) continue;
21
+ const weightA = codeA < 128 && asciiWeights[codeA] ? asciiWeights[codeA] : codeA + 128;
22
+ const weightB = codeB < 128 && asciiWeights[codeB] ? asciiWeights[codeB] : codeB + 128;
23
+ if (weightA !== weightB) return weightA < weightB ? -1 : 1;
24
+ if (tieBreaker === 0) tieBreaker = codeA > codeB ? -1 : 1;
25
+ }
26
+ if (a.length !== b.length) return a.length < b.length ? -1 : 1;
27
+ return tieBreaker;
28
+ }
29
+ const Serializer = /*@__PURE__*/ (function() {
30
+ class Serializer {
31
+ #context = /* @__PURE__ */ new Map();
32
+ compare(a, b) {
33
+ const typeA = typeof a;
34
+ const typeB = typeof b;
35
+ if (typeA === "string" && typeB === "string") return compareStrings(a, b);
36
+ if (typeA === "number" && typeB === "number") return a - b;
37
+ return compareStrings(this.serialize(a, true), this.serialize(b, true));
38
+ }
39
+ serialize(value, noQuotes) {
40
+ if (value === null) return "null";
41
+ switch (typeof value) {
42
+ case "string": return noQuotes ? value : `'${value}'`;
43
+ case "bigint": return `${value}n`;
44
+ case "object": return this.$object(value);
45
+ case "function": return this.$function(value);
46
+ }
47
+ return String(value);
48
+ }
49
+ serializeObject(object) {
50
+ const objString = Object.prototype.toString.call(object);
51
+ if (objString !== "[object Object]") return this.serializeBuiltInType(objString.length < 10 ? `unknown:${objString}` : objString.slice(8, -1), object);
52
+ const constructor = object.constructor;
53
+ const objName = constructor === Object || constructor === void 0 ? "" : constructor.name;
54
+ if (objName !== "" && globalThis[objName] === constructor) return this.serializeBuiltInType(objName, object);
55
+ if ("toJSON" in object && typeof object.toJSON === "function") {
56
+ const json = object.toJSON();
57
+ return objName + (json !== null && typeof json === "object" ? this.$object(json) : `(${this.serialize(json)})`);
58
+ }
59
+ const keys = Object.keys(object).sort(compareStrings);
60
+ let content = `${objName}{`;
61
+ for (let i = 0; i < keys.length; i++) {
62
+ const key = keys[i];
63
+ content += `${key}:${this.serialize(object[key])}`;
64
+ if (i < keys.length - 1) content += ",";
65
+ }
66
+ return content + "}";
67
+ }
68
+ serializeBuiltInType(type, object) {
69
+ const handler = this["$" + type];
70
+ if (handler) return handler.call(this, object);
71
+ if (typeof object.entries === "function") return this.serializeObjectEntries(type, object.entries());
72
+ throw new Error(`Cannot serialize ${type}`);
73
+ }
74
+ serializeObjectEntries(type, entries) {
75
+ const sortedEntries = Array.from(entries).sort((a, b) => this.compare(a[0], b[0]));
76
+ let content = `${type}{`;
77
+ for (let i = 0; i < sortedEntries.length; i++) {
78
+ const [key, value] = sortedEntries[i];
79
+ content += `${this.serialize(key, true)}:${this.serialize(value)}`;
80
+ if (i < sortedEntries.length - 1) content += ",";
81
+ }
82
+ return content + "}";
83
+ }
84
+ $object(object) {
85
+ let content = this.#context.get(object);
86
+ if (content === void 0) {
87
+ this.#context.set(object, `#${this.#context.size}`);
88
+ content = this.serializeObject(object);
89
+ this.#context.set(object, content);
90
+ }
91
+ return content;
92
+ }
93
+ $function(fn) {
94
+ const fnStr = Function.prototype.toString.call(fn);
95
+ if (fnStr.slice(-15) === "[native code] }") return `${fn.name || ""}()[native]`;
96
+ return `${fn.name}(${fn.length})${fnStr.replace(/\s*\n\s*/g, "")}`;
97
+ }
98
+ $Array(arr) {
99
+ let content = "[";
100
+ for (let i = 0; i < arr.length; i++) {
101
+ content += this.serialize(arr[i]);
102
+ if (i < arr.length - 1) content += ",";
103
+ }
104
+ return content + "]";
105
+ }
106
+ $Date(date) {
107
+ try {
108
+ return `Date(${date.toISOString()})`;
109
+ } catch {
110
+ return `Date(null)`;
111
+ }
112
+ }
113
+ $ArrayBuffer(arr) {
114
+ return `ArrayBuffer[${new Uint8Array(arr).join(",")}]`;
115
+ }
116
+ $Set(set) {
117
+ return `Set${this.$Array(Array.from(set).sort((a, b) => this.compare(a, b)))}`;
118
+ }
119
+ $Map(map) {
120
+ return this.serializeObjectEntries("Map", map.entries());
121
+ }
122
+ }
123
+ for (const type of [
124
+ "Error",
125
+ "RegExp",
126
+ "URL"
127
+ ]) Serializer.prototype["$" + type] = function(val) {
128
+ return `${type}(${val})`;
129
+ };
130
+ for (const type of [
131
+ "Int8Array",
132
+ "Uint8Array",
133
+ "Uint8ClampedArray",
134
+ "Int16Array",
135
+ "Uint16Array",
136
+ "Int32Array",
137
+ "Uint32Array",
138
+ "Float32Array",
139
+ "Float64Array"
140
+ ]) Serializer.prototype["$" + type] = function(arr) {
141
+ return `${type}[${arr.join(",")}]`;
142
+ };
143
+ for (const type of ["BigInt64Array", "BigUint64Array"]) Serializer.prototype["$" + type] = function(arr) {
144
+ return `${type}[${arr.join("n,")}${arr.length > 0 ? "n" : ""}]`;
145
+ };
146
+ return Serializer;
147
+ })();
148
+ //#endregion
149
+ //#region ../../node_modules/.pnpm/ohash@2.0.12/node_modules/ohash/dist/crypto/js/index.mjs
150
+ const H = [
151
+ 1779033703,
152
+ -1150833019,
153
+ 1013904242,
154
+ -1521486534,
155
+ 1359893119,
156
+ -1694144372,
157
+ 528734635,
158
+ 1541459225
159
+ ];
160
+ const K = [
161
+ 1116352408,
162
+ 1899447441,
163
+ -1245643825,
164
+ -373957723,
165
+ 961987163,
166
+ 1508970993,
167
+ -1841331548,
168
+ -1424204075,
169
+ -670586216,
170
+ 310598401,
171
+ 607225278,
172
+ 1426881987,
173
+ 1925078388,
174
+ -2132889090,
175
+ -1680079193,
176
+ -1046744716,
177
+ -459576895,
178
+ -272742522,
179
+ 264347078,
180
+ 604807628,
181
+ 770255983,
182
+ 1249150122,
183
+ 1555081692,
184
+ 1996064986,
185
+ -1740746414,
186
+ -1473132947,
187
+ -1341970488,
188
+ -1084653625,
189
+ -958395405,
190
+ -710438585,
191
+ 113926993,
192
+ 338241895,
193
+ 666307205,
194
+ 773529912,
195
+ 1294757372,
196
+ 1396182291,
197
+ 1695183700,
198
+ 1986661051,
199
+ -2117940946,
200
+ -1838011259,
201
+ -1564481375,
202
+ -1474664885,
203
+ -1035236496,
204
+ -949202525,
205
+ -778901479,
206
+ -694614492,
207
+ -200395387,
208
+ 275423344,
209
+ 430227734,
210
+ 506948616,
211
+ 659060556,
212
+ 883997877,
213
+ 958139571,
214
+ 1322822218,
215
+ 1537002063,
216
+ 1747873779,
217
+ 1955562222,
218
+ 2024104815,
219
+ -2067236844,
220
+ -1933114872,
221
+ -1866530822,
222
+ -1538233109,
223
+ -1090935817,
224
+ -965641998
225
+ ];
226
+ const base64KeyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
227
+ const W = [];
228
+ var SHA256 = class {
229
+ _data = new WordArray();
230
+ _hash = new WordArray([...H]);
231
+ _nDataBytes = 0;
232
+ _minBufferSize = 0;
233
+ finalize(messageUpdate) {
234
+ if (messageUpdate) this._append(messageUpdate);
235
+ const nBitsTotal = this._nDataBytes * 8;
236
+ const nBitsLeft = this._data.sigBytes * 8;
237
+ this._data.words[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32;
238
+ this._data.words[(nBitsLeft + 64 >>> 9 << 4) + 14] = Math.floor(nBitsTotal / 4294967296);
239
+ this._data.words[(nBitsLeft + 64 >>> 9 << 4) + 15] = nBitsTotal;
240
+ this._data.sigBytes = this._data.words.length * 4;
241
+ this._process();
242
+ return this._hash;
243
+ }
244
+ _doProcessBlock(M, offset) {
245
+ const H = this._hash.words;
246
+ let a = H[0];
247
+ let b = H[1];
248
+ let c = H[2];
249
+ let d = H[3];
250
+ let e = H[4];
251
+ let f = H[5];
252
+ let g = H[6];
253
+ let h = H[7];
254
+ for (let i = 0; i < 64; i++) {
255
+ if (i < 16) W[i] = M[offset + i] | 0;
256
+ else {
257
+ const gamma0x = W[i - 15];
258
+ const gamma0 = (gamma0x << 25 | gamma0x >>> 7) ^ (gamma0x << 14 | gamma0x >>> 18) ^ gamma0x >>> 3;
259
+ const gamma1x = W[i - 2];
260
+ const gamma1 = (gamma1x << 15 | gamma1x >>> 17) ^ (gamma1x << 13 | gamma1x >>> 19) ^ gamma1x >>> 10;
261
+ W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
262
+ }
263
+ const ch = e & f ^ ~e & g;
264
+ const maj = a & b ^ a & c ^ b & c;
265
+ const sigma0 = (a << 30 | a >>> 2) ^ (a << 19 | a >>> 13) ^ (a << 10 | a >>> 22);
266
+ const sigma1 = (e << 26 | e >>> 6) ^ (e << 21 | e >>> 11) ^ (e << 7 | e >>> 25);
267
+ const t1 = h + sigma1 + ch + K[i] + W[i];
268
+ const t2 = sigma0 + maj;
269
+ h = g;
270
+ g = f;
271
+ f = e;
272
+ e = d + t1 | 0;
273
+ d = c;
274
+ c = b;
275
+ b = a;
276
+ a = t1 + t2 | 0;
277
+ }
278
+ H[0] = H[0] + a | 0;
279
+ H[1] = H[1] + b | 0;
280
+ H[2] = H[2] + c | 0;
281
+ H[3] = H[3] + d | 0;
282
+ H[4] = H[4] + e | 0;
283
+ H[5] = H[5] + f | 0;
284
+ H[6] = H[6] + g | 0;
285
+ H[7] = H[7] + h | 0;
286
+ }
287
+ _append(data) {
288
+ if (typeof data === "string") data = WordArray.fromUtf8(data);
289
+ this._data.concat(data);
290
+ this._nDataBytes += data.sigBytes;
291
+ }
292
+ _process(doFlush) {
293
+ let processedWords;
294
+ let nBlocksReady = this._data.sigBytes / 64;
295
+ if (doFlush) nBlocksReady = Math.ceil(nBlocksReady);
296
+ else nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
297
+ const nWordsReady = nBlocksReady * 16;
298
+ const nBytesReady = Math.min(nWordsReady * 4, this._data.sigBytes);
299
+ if (nWordsReady) {
300
+ for (let offset = 0; offset < nWordsReady; offset += 16) this._doProcessBlock(this._data.words, offset);
301
+ processedWords = this._data.words.splice(0, nWordsReady);
302
+ this._data.sigBytes -= nBytesReady;
303
+ }
304
+ return new WordArray(processedWords, nBytesReady);
305
+ }
306
+ };
307
+ var WordArray = class WordArray {
308
+ words;
309
+ sigBytes;
310
+ constructor(words, sigBytes) {
311
+ words = this.words = words || [];
312
+ this.sigBytes = sigBytes === void 0 ? words.length * 4 : sigBytes;
313
+ }
314
+ static fromUtf8(input) {
315
+ const str = unescape(encodeURIComponent(input));
316
+ const strlen = str.length;
317
+ const words = [];
318
+ for (let i = 0; i < strlen; i++) words[i >>> 2] |= (str.charCodeAt(i) & 255) << 24 - i % 4 * 8;
319
+ return new WordArray(words, strlen);
320
+ }
321
+ toBase64() {
322
+ const base64Chars = [];
323
+ for (let i = 0; i < this.sigBytes; i += 3) {
324
+ const byte1 = this.words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
325
+ const byte2 = this.words[i + 1 >>> 2] >>> 24 - (i + 1) % 4 * 8 & 255;
326
+ const byte3 = this.words[i + 2 >>> 2] >>> 24 - (i + 2) % 4 * 8 & 255;
327
+ const triplet = byte1 << 16 | byte2 << 8 | byte3;
328
+ for (let j = 0; j < 4 && i * 8 + j * 6 < this.sigBytes * 8; j++) base64Chars.push(base64KeyStr.charAt(triplet >>> 6 * (3 - j) & 63));
329
+ }
330
+ return base64Chars.join("");
331
+ }
332
+ concat(wordArray) {
333
+ this.words[this.sigBytes >>> 2] &= 4294967295 << 32 - this.sigBytes % 4 * 8;
334
+ this.words.length = Math.ceil(this.sigBytes / 4);
335
+ if (this.sigBytes % 4) for (let i = 0; i < wordArray.sigBytes; i++) {
336
+ const thatByte = wordArray.words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
337
+ this.words[this.sigBytes + i >>> 2] |= thatByte << 24 - (this.sigBytes + i) % 4 * 8;
338
+ }
339
+ else for (let j = 0; j < wordArray.sigBytes; j += 4) this.words[this.sigBytes + j >>> 2] = wordArray.words[j >>> 2];
340
+ this.sigBytes += wordArray.sigBytes;
341
+ }
342
+ };
343
+ function digest(message) {
344
+ return new SHA256().finalize(message).toBase64();
345
+ }
346
+ //#endregion
347
+ //#region ../../node_modules/.pnpm/ohash@2.0.12/node_modules/ohash/dist/index.mjs
348
+ function hash$1(input) {
349
+ return digest(serialize(input));
350
+ }
351
+ //#endregion
352
+ //#region src/utils/hash.ts
353
+ /**
354
+ * Stable, deterministic hash of any structured-cloneable value.
355
+ */
356
+ function hash(value) {
357
+ return hash$1(value);
358
+ }
359
+ //#endregion
360
+ export { hash as t };
@@ -1,4 +1,5 @@
1
- import { t as diagnostics } from "./diagnostics-DOQPnQmX.mjs";
1
+ import { t as DEVFRAME_EVENTS } from "./events-DKfSmoTj.mjs";
2
+ import { t as diagnostics } from "./diagnostics-DI1HGj2I.mjs";
2
3
  //#region src/utils/events.ts
3
4
  /**
4
5
  * Create event emitter.
@@ -90,7 +91,7 @@ var DevframeAgentHost = class {
90
91
  constructor(context) {
91
92
  this.context = context;
92
93
  this._rpcUnsubscribe = context.rpc.onChanged(() => {
93
- this.events.emit("agent:manifest:changed");
94
+ this.events.emit(DEVFRAME_EVENTS.bus.agentManifestChanged);
94
95
  });
95
96
  }
96
97
  registerTool(input) {
@@ -100,28 +101,28 @@ var DevframeAgentHost = class {
100
101
  tool,
101
102
  handler: input.handler
102
103
  });
103
- this.events.emit("agent:tool:registered", tool);
104
- this.events.emit("agent:manifest:changed");
104
+ this.events.emit(DEVFRAME_EVENTS.bus.agentToolRegistered, tool);
105
+ this.events.emit(DEVFRAME_EVENTS.bus.agentManifestChanged);
105
106
  return { unregister: () => this.unregisterTool(tool.id) };
106
107
  }
107
108
  unregisterTool(id) {
108
109
  const existed = this.tools.delete(id);
109
110
  if (existed) {
110
- this.events.emit("agent:tool:unregistered", id);
111
- this.events.emit("agent:manifest:changed");
111
+ this.events.emit(DEVFRAME_EVENTS.bus.agentToolUnregistered, id);
112
+ this.events.emit(DEVFRAME_EVENTS.bus.agentManifestChanged);
112
113
  }
113
114
  return existed;
114
115
  }
115
116
  registerToolProvider(provider) {
116
117
  this.providers.add(provider);
117
- this.events.emit("agent:manifest:changed");
118
+ this.events.emit(DEVFRAME_EVENTS.bus.agentManifestChanged);
118
119
  const notifyChanged = () => {
119
- if (this.providers.has(provider)) this.events.emit("agent:manifest:changed");
120
+ if (this.providers.has(provider)) this.events.emit(DEVFRAME_EVENTS.bus.agentManifestChanged);
120
121
  };
121
122
  return {
122
123
  notifyChanged,
123
124
  unregister: () => {
124
- if (this.providers.delete(provider)) this.events.emit("agent:manifest:changed");
125
+ if (this.providers.delete(provider)) this.events.emit(DEVFRAME_EVENTS.bus.agentManifestChanged);
125
126
  }
126
127
  };
127
128
  }
@@ -138,15 +139,15 @@ var DevframeAgentHost = class {
138
139
  resource,
139
140
  read: input.read
140
141
  });
141
- this.events.emit("agent:resource:registered", resource);
142
- this.events.emit("agent:manifest:changed");
142
+ this.events.emit(DEVFRAME_EVENTS.bus.agentResourceRegistered, resource);
143
+ this.events.emit(DEVFRAME_EVENTS.bus.agentManifestChanged);
143
144
  return { unregister: () => this.unregisterResource(resource.id) };
144
145
  }
145
146
  unregisterResource(id) {
146
147
  const existed = this.resources.delete(id);
147
148
  if (existed) {
148
- this.events.emit("agent:resource:unregistered", id);
149
- this.events.emit("agent:manifest:changed");
149
+ this.events.emit(DEVFRAME_EVENTS.bus.agentResourceUnregistered, id);
150
+ this.events.emit(DEVFRAME_EVENTS.bus.agentManifestChanged);
150
151
  }
151
152
  return existed;
152
153
  }
@@ -1,12 +1,13 @@
1
- import { n as __exportAll } from "./rolldown-runtime-JspESFgx.mjs";
1
+ import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.mjs";
2
2
  import { t as Diagnostic } from "./nostics-CzECRXpE.mjs";
3
+ import { t as DEVFRAME_EVENTS } from "./events-DKfSmoTj.mjs";
3
4
  import { i as isAllowedOrigin } from "./ws-server-BdSLrhxE.mjs";
4
- import { t as diagnostics } from "./diagnostics-DOQPnQmX.mjs";
5
- import { t as createHostContext } from "./context-CEe4PBz1.mjs";
5
+ import { t as diagnostics } from "./diagnostics-DI1HGj2I.mjs";
6
+ import { t as createHostContext } from "./context-riPPHGiu.mjs";
6
7
  import { t as toAgentToolName } from "./agent-tool-name-EgfoFO8C.mjs";
7
8
  import { randomUUID } from "node:crypto";
8
- import { join } from "pathe";
9
9
  import process from "node:process";
10
+ import { join } from "pathe";
10
11
  import { homedir } from "node:os";
11
12
  import { defineHandler } from "h3";
12
13
  import { Server, WebStandardStreamableHTTPServerTransport, isInitializeRequest } from "@modelcontextprotocol/server";
@@ -172,7 +173,7 @@ function buildMcpServerFromContext(ctx, options) {
172
173
  const notify = (method) => {
173
174
  server.notification({ method }).catch(() => {});
174
175
  };
175
- const offManifest = ctx.agent.events.on("agent:manifest:changed", () => {
176
+ const offManifest = ctx.agent.events.on(DEVFRAME_EVENTS.bus.agentManifestChanged, () => {
176
177
  notify("notifications/tools/list_changed");
177
178
  notify("notifications/resources/list_changed");
178
179
  });
@@ -208,8 +209,11 @@ async function createMcpServer(definition, options = {}) {
208
209
  if (scope === "project") return join(process.cwd(), `node_modules/.${definition.id}/devframe`);
209
210
  return join(homedir(), `.${definition.id}/devframe`);
210
211
  }
211
- }
212
+ },
213
+ importMetaUrl: definition.importMetaUrl
212
214
  });
215
+ for (const input of definition.services ?? []) ctx.services.install(input, { resolveFrom: definition.importMetaUrl });
216
+ await ctx.services.ready();
213
217
  await definition.setup(ctx);
214
218
  const { server, dispose } = buildMcpServerFromContext(ctx, {
215
219
  serverName: options.serverName ?? `${definition.id} (devframe)`,
@@ -1,5 +1,5 @@
1
- import { R as DevframeNodeRpcSession, g as DevframeNodeContext, lt as SharedState } from "./devframe-DJMg0WLe.mjs";
2
- import { n as InternalAnonymousAuthStorage } from "./context-B3YUu_95.mjs";
1
+ import { _ as DevframeNodeRpcSession, g as DevframeNodeContext, gt as SharedState } from "./devframe-mbfgpQQC.mjs";
2
+ import { n as InternalAnonymousAuthStorage } from "./context-al99DDJ8.mjs";
3
3
  //#region src/node/auth/revoke.d.ts
4
4
  /**
5
5
  * Flip `isTrusted` to false on any live WS clients connected with `token`
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as ScopedServerFunctions, B as RpcFunctionsHost, C as DevframeScopedStreamingHost, Ct as DevframeAgentHost, D as ScopedBroadcastOptions, Dt as EventsMap, E as DevframeSettingsStore, Et as EventUnsubscribe, F as DevframeStorageScope, G as RpcStreamingHost, H as RpcSharedStateHost, I as DevframeDiagnosticsHost, J as DevframeRpcSharedStates, K as DevframeRpcClientFunctions, L as DevframeDiagnosticsLogger, M as SettingsForNamespace, N as DevframeViewHost, O as ScopedClientFunctions, P as DevframeHost, R as DevframeNodeRpcSession, S as DevframeScopedNodeRpc, St as AgentToolProviderHandle, T as DevframeSettingsRegistry, Tt as EventEmitter, U as RpcStreamingChannel, V as RpcSharedStateGetOptions, W as RpcStreamingChannelOptions, _ as DevframeServiceId, _t as AgentResourceContent, a as DevframeDuplicationStrategy, b as DevframeServicesRegistry, bt as AgentToolInput, c as DevframeWsOptions, d as ConnectionMeta, f as ConnectionMetaSse, g as DevframeNodeContext, gt as AgentResource, h as DevframeConnectionConfigsRegistry, ht as AgentManifest, i as DevframeDockDefaults, j as ScopedSharedStates, k as ScopedRpcFn, l as McpRouteOptions, m as DevframeCapabilities, mt as AgentHandle, n as DevframeDefinition, o as DevframeSetupInfo, p as ConnectionMetaWebsocket, q as DevframeRpcServerFunctions, r as DevframeDeploymentKind, s as DevframeSseOptions, t as DevframeCliOptions, v as DevframeServiceOf, vt as AgentResourceInput, w as DevframeSettings, wt as DevframeAgentHostEvents, x as DevframeScopedNodeContext, xt as AgentToolProvider, y as DevframeServicesHost, yt as AgentTool, z as RpcBroadcastOptions } from "./devframe-DJMg0WLe.mjs";
1
+ import { $ as DevframeStorageScope, A as DevframeServiceId, At as DevframeAgentHost, B as DevframeScopedNodeRpc, C as RpcStreamingChannelOptions, Ct as AgentResource, D as DevframeRpcSharedStates, Dt as AgentToolInput, E as DevframeRpcServerFunctions, Et as AgentTool, F as DevframeServicesHost, G as ScopedBroadcastOptions, H as DevframeSettings, I as DevframeServicesRegistry, J as ScopedServerFunctions, K as ScopedClientFunctions, L as DevframeServicesScopeRegistry, M as DevframeServiceMeta, Mt as EventEmitter, N as DevframeServiceOf, Nt as EventUnsubscribe, O as DevframeServiceDefinition, Ot as AgentToolProvider, P as DevframeServiceScopeOf, Pt as EventsMap, Q as DevframeHost, R as DevframeServicesState, S as RpcStreamingChannel, St as AgentManifest, T as DevframeRpcClientFunctions, Tt as AgentResourceInput, U as DevframeSettingsRegistry, V as DevframeScopedStreamingHost, W as DevframeSettingsStore, X as SettingsForNamespace, Y as ScopedSharedStates, Z as DevframeViewHost, _ as DevframeNodeRpcSession, a as DevframeDuplicationStrategy, b as RpcSharedStateGetOptions, c as DevframeWsOptions, d as ConnectionMeta, et as DevframeDiagnosticsHost, f as ConnectionMetaSse, g as DevframeNodeContext, h as DevframeConnectionConfigsRegistry, i as DevframeDockDefaults, j as DevframeServiceInput, jt as DevframeAgentHostEvents, k as DevframeServiceDescriptor, kt as AgentToolProviderHandle, l as McpRouteOptions, m as DevframeCapabilities, n as DevframeDefinition, o as DevframeSetupInfo, p as ConnectionMetaWebsocket, q as ScopedRpcFn, r as DevframeDeploymentKind, s as DevframeSseOptions, t as DevframeCliOptions, tt as DevframeDiagnosticsLogger, v as RpcBroadcastOptions, w as RpcStreamingHost, wt as AgentResourceContent, x as RpcSharedStateHost, xt as AgentHandle, y as RpcFunctionsHost, z as DevframeScopedNodeContext } from "./devframe-mbfgpQQC.mjs";
2
2
  import "./index-tdrk1bzV.mjs";
3
3
  import { C as RpcFunctionType, T as RpcReturnSchema, _ as RpcFunctionDefinition, g as RpcFunctionAgentOptions, i as RpcArgsSchema } from "./types-Djq7CBXh.mjs";
4
4
  import { d as DevframeRpcConnection, f as DevframeRpcConnectionRequest, p as DevframeRpcTransportKind, u as DevframeNodeRpcSessionMeta } from "./ws-server-D1d3QM9f.mjs";
@@ -12,4 +12,4 @@ declare const defineRpcFunction: <NAME extends string, TYPE extends RpcFunctionT
12
12
  */
13
13
  declare function defineDevframe(d: DevframeDefinition): DevframeDefinition;
14
14
  //#endregion
15
- export { type AgentHandle, type AgentManifest, type AgentResource, type AgentResourceContent, type AgentResourceInput, type AgentTool, type AgentToolInput, type AgentToolProvider, type AgentToolProviderHandle, type ConnectionMeta, type ConnectionMetaSse, type ConnectionMetaWebsocket, type DevframeAgentHost, type DevframeAgentHostEvents, type DevframeCapabilities, type DevframeCliOptions, type DevframeConnectionConfigsRegistry, type DevframeDefineDiagnosticsOptions, type DevframeDefinition, type DevframeDeploymentKind, type DevframeDiagnosticsHost, type DevframeDiagnosticsLogger, type DevframeDockDefaults, type DevframeDuplicationStrategy, type DevframeHost, type DevframeNodeContext, type DevframeNodeRpcSession, type DevframeNodeRpcSessionMeta, type DevframeRpcClientFunctions, type DevframeRpcConnection, type DevframeRpcConnectionRequest, type DevframeRpcServerFunctions, type DevframeRpcSharedStates, type DevframeRpcTransportKind, type DevframeScopedNodeContext, type DevframeScopedNodeRpc, type DevframeScopedStreamingHost, type DevframeServiceId, type DevframeServiceOf, type DevframeServicesHost, type DevframeServicesRegistry, type DevframeSettings, type DevframeSettingsRegistry, type DevframeSettingsStore, type DevframeSetupInfo, type DevframeSseOptions, type DevframeStorageScope, type DevframeViewHost, type DevframeWsOptions, type EventEmitter, type EventUnsubscribe, type EventsMap, type McpRouteOptions, type RemoteAssets, type RemoteAssetsErrorMessage, type RemoteAssetsProvider, type RemoteAssetsProviderCustom, type RemoteAssetsStore, type RpcBroadcastOptions, type RpcFunctionAgentOptions, type RpcFunctionsHost, type RpcSharedStateGetOptions, type RpcSharedStateHost, type RpcStreamingChannel, type RpcStreamingChannelOptions, type RpcStreamingHost, type ScopedBroadcastOptions, type ScopedClientFunctions, type ScopedRpcFn, type ScopedServerFunctions, type ScopedSharedStates, type SettingsForNamespace, type StaticAssetsSource, defineDevframe, defineRpcFunction };
15
+ export { type AgentHandle, type AgentManifest, type AgentResource, type AgentResourceContent, type AgentResourceInput, type AgentTool, type AgentToolInput, type AgentToolProvider, type AgentToolProviderHandle, type ConnectionMeta, type ConnectionMetaSse, type ConnectionMetaWebsocket, type DevframeAgentHost, type DevframeAgentHostEvents, type DevframeCapabilities, type DevframeCliOptions, type DevframeConnectionConfigsRegistry, type DevframeDefineDiagnosticsOptions, type DevframeDefinition, type DevframeDeploymentKind, type DevframeDiagnosticsHost, type DevframeDiagnosticsLogger, type DevframeDockDefaults, type DevframeDuplicationStrategy, type DevframeHost, type DevframeNodeContext, type DevframeNodeRpcSession, type DevframeNodeRpcSessionMeta, type DevframeRpcClientFunctions, type DevframeRpcConnection, type DevframeRpcConnectionRequest, type DevframeRpcServerFunctions, type DevframeRpcSharedStates, type DevframeRpcTransportKind, type DevframeScopedNodeContext, type DevframeScopedNodeRpc, type DevframeScopedStreamingHost, type DevframeServiceDefinition, type DevframeServiceDescriptor, type DevframeServiceId, type DevframeServiceInput, type DevframeServiceMeta, type DevframeServiceOf, type DevframeServiceScopeOf, type DevframeServicesHost, type DevframeServicesRegistry, type DevframeServicesScopeRegistry, type DevframeServicesState, type DevframeSettings, type DevframeSettingsRegistry, type DevframeSettingsStore, type DevframeSetupInfo, type DevframeSseOptions, type DevframeStorageScope, type DevframeViewHost, type DevframeWsOptions, type EventEmitter, type EventUnsubscribe, type EventsMap, type McpRouteOptions, type RemoteAssets, type RemoteAssetsErrorMessage, type RemoteAssetsProvider, type RemoteAssetsProviderCustom, type RemoteAssetsStore, type RpcBroadcastOptions, type RpcFunctionAgentOptions, type RpcFunctionsHost, type RpcSharedStateGetOptions, type RpcSharedStateHost, type RpcStreamingChannel, type RpcStreamingChannelOptions, type RpcStreamingHost, type ScopedBroadcastOptions, type ScopedClientFunctions, type ScopedRpcFn, type ScopedServerFunctions, type ScopedSharedStates, type SettingsForNamespace, type StaticAssetsSource, defineDevframe, defineRpcFunction };
@@ -1,8 +1,8 @@
1
- import { n as __exportAll } from "./rolldown-runtime-JspESFgx.mjs";
2
- import { t as diagnostics } from "./diagnostics-DOQPnQmX.mjs";
3
- import { mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
4
- import { join } from "pathe";
1
+ import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.mjs";
2
+ import { t as diagnostics } from "./diagnostics-DI1HGj2I.mjs";
5
3
  import process from "node:process";
4
+ import { join } from "pathe";
5
+ import { mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
6
6
  import { homedir } from "node:os";
7
7
  //#region src/node/instance-registry.ts
8
8
  var instance_registry_exports = /* @__PURE__ */ __exportAll({
@@ -1,6 +1,6 @@
1
1
  import "./constants.mjs";
2
- import { t as diagnostics } from "./diagnostics-DOQPnQmX.mjs";
3
- import { t as getInternalContext } from "./context-xdynGSLP.mjs";
2
+ import { t as diagnostics } from "./diagnostics-DI1HGj2I.mjs";
3
+ import { t as getInternalContext } from "./context-af2w_F0_.mjs";
4
4
  import { createInteractiveAuth } from "./recipes/interactive-auth.mjs";
5
5
  import { createServer } from "node:http";
6
6
  import process from "node:process";
@@ -197,7 +197,7 @@ function createInstanceShell(options) {
197
197
  const origin = currentOrigin();
198
198
  if (!cfg || registerPromise || !origin || !meta) return;
199
199
  const resolvedMeta = meta;
200
- registerPromise = import("./instance-registry-WvQkt42E.mjs").then((n) => n.t).then(({ registerDevframeInstance }) => {
200
+ registerPromise = import("./instance-registry-Dy28drtm.mjs").then((n) => n.t).then(({ registerDevframeInstance }) => {
201
201
  let port = 0;
202
202
  try {
203
203
  const url = new URL(origin);
@@ -257,7 +257,7 @@ function createInstanceShell(options) {
257
257
  let resolvedAuth = false;
258
258
  let corePromise;
259
259
  function ensureCore() {
260
- corePromise ??= import("./rpc-core-DMTe-hLo.mjs").then((n) => n.n).then(({ createContextRpcServer }) => createContextRpcServer({
260
+ corePromise ??= import("./rpc-core-DRYnbxdD.mjs").then((n) => n.n).then(({ createContextRpcServer }) => createContextRpcServer({
261
261
  context: ctx,
262
262
  auth: resolvedAuth,
263
263
  onPeerConnect: options.onPeerConnect,
@@ -298,7 +298,7 @@ function createInstanceShell(options) {
298
298
  allowedOrigins: options.allowedOrigins
299
299
  });
300
300
  if (ws.port != null) return await start(ws.port);
301
- const { getPort } = await import("./dist-eNI9qM_I.mjs").then((n) => n.t);
301
+ const { getPort } = await import("./dist-CZXfGEkd.mjs").then((n) => n.t);
302
302
  let lastError;
303
303
  for (let attempt = 0; attempt < 3; attempt++) {
304
304
  const port = attempt === 0 && options.resolveSidecarPort ? await options.resolveSidecarPort(sidecarHost) : await getPort({
@@ -1,6 +1,6 @@
1
- import { K as DevframeRpcClientFunctions, R as DevframeNodeRpcSession, c as DevframeWsOptions, d as ConnectionMeta, g as DevframeNodeContext, q as DevframeRpcServerFunctions, s as DevframeSseOptions, u as DevframeAuthHandler } from "./devframe-DJMg0WLe.mjs";
1
+ import { E as DevframeRpcServerFunctions, T as DevframeRpcClientFunctions, _ as DevframeNodeRpcSession, c as DevframeWsOptions, d as ConnectionMeta, g as DevframeNodeContext, s as DevframeSseOptions, u as DevframeAuthHandler } from "./devframe-mbfgpQQC.mjs";
2
2
  import { d as DevframeRpcConnection, n as WsOriginRegistry, u as DevframeNodeRpcSessionMeta } from "./ws-server-D1d3QM9f.mjs";
3
- import "./index-CB-fSUyn.mjs";
3
+ import "./index-Dipgo9ji.mjs";
4
4
  import { BirpcGroup } from "birpc";
5
5
  import { NodeAdapter } from "crossws/adapters/node";
6
6
  import { Buffer } from "node:buffer";