@copilotkit/runtime 1.73.3 → 1.74.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.
Files changed (68) hide show
  1. package/README.md +28 -0
  2. package/dist/agent/learned-skills.cjs.map +1 -1
  3. package/dist/agent/learned-skills.d.cts +1 -1
  4. package/dist/agent/learned-skills.d.mts +1 -1
  5. package/dist/agent/learned-skills.mjs.map +1 -1
  6. package/dist/internal/learned-skills.d.cts +2 -2
  7. package/dist/internal/learned-skills.d.mts +2 -2
  8. package/dist/package.cjs +1 -1
  9. package/dist/package.mjs +1 -1
  10. package/dist/v2/index.d.cts +2 -2
  11. package/dist/v2/index.d.mts +2 -2
  12. package/dist/v2/runtime/handlers/intelligence/memories.cjs +4 -1
  13. package/dist/v2/runtime/handlers/intelligence/memories.cjs.map +1 -1
  14. package/dist/v2/runtime/handlers/intelligence/memories.mjs +5 -2
  15. package/dist/v2/runtime/handlers/intelligence/memories.mjs.map +1 -1
  16. package/dist/v2/runtime/handlers/intelligence/thread-names.cjs +16 -2
  17. package/dist/v2/runtime/handlers/intelligence/thread-names.cjs.map +1 -1
  18. package/dist/v2/runtime/handlers/intelligence/thread-names.mjs +16 -2
  19. package/dist/v2/runtime/handlers/intelligence/thread-names.mjs.map +1 -1
  20. package/dist/v2/runtime/handlers/shared/agent-utils.cjs +17 -4
  21. package/dist/v2/runtime/handlers/shared/agent-utils.cjs.map +1 -1
  22. package/dist/v2/runtime/handlers/shared/agent-utils.mjs +18 -5
  23. package/dist/v2/runtime/handlers/shared/agent-utils.mjs.map +1 -1
  24. package/dist/v2/runtime/handlers/shared/memory-policy.cjs +43 -5
  25. package/dist/v2/runtime/handlers/shared/memory-policy.cjs.map +1 -1
  26. package/dist/v2/runtime/handlers/shared/memory-policy.mjs +43 -6
  27. package/dist/v2/runtime/handlers/shared/memory-policy.mjs.map +1 -1
  28. package/dist/v2/runtime/index.d.cts +1 -1
  29. package/dist/v2/runtime/index.d.cts.map +1 -1
  30. package/dist/v2/runtime/index.d.mts +1 -1
  31. package/dist/v2/runtime/index.d.mts.map +1 -1
  32. package/dist/v2/runtime/intelligence-platform/client.cjs +80 -0
  33. package/dist/v2/runtime/intelligence-platform/client.cjs.map +1 -1
  34. package/dist/v2/runtime/intelligence-platform/client.d.cts +3 -1
  35. package/dist/v2/runtime/intelligence-platform/client.d.cts.map +1 -1
  36. package/dist/v2/runtime/intelligence-platform/client.d.mts +3 -1
  37. package/dist/v2/runtime/intelligence-platform/client.d.mts.map +1 -1
  38. package/dist/v2/runtime/intelligence-platform/client.mjs +81 -1
  39. package/dist/v2/runtime/intelligence-platform/client.mjs.map +1 -1
  40. package/dist/v2/runtime/intelligence-platform/index.d.cts +1 -1
  41. package/dist/v2/runtime/intelligence-platform/index.d.mts +1 -1
  42. package/dist/v2/runtime/intelligence-platform/learned-skills.cjs +53 -0
  43. package/dist/v2/runtime/intelligence-platform/learned-skills.cjs.map +1 -1
  44. package/dist/v2/runtime/intelligence-platform/learned-skills.d.cts +11 -1
  45. package/dist/v2/runtime/intelligence-platform/learned-skills.d.cts.map +1 -1
  46. package/dist/v2/runtime/intelligence-platform/learned-skills.d.mts +11 -1
  47. package/dist/v2/runtime/intelligence-platform/learned-skills.d.mts.map +1 -1
  48. package/dist/v2/runtime/intelligence-platform/learned-skills.mjs +53 -1
  49. package/dist/v2/runtime/intelligence-platform/learned-skills.mjs.map +1 -1
  50. package/dist/v2/runtime/intelligence-platform/skill-registry/config.cjs +24 -6
  51. package/dist/v2/runtime/intelligence-platform/skill-registry/config.cjs.map +1 -1
  52. package/dist/v2/runtime/intelligence-platform/skill-registry/config.d.cts +28 -7
  53. package/dist/v2/runtime/intelligence-platform/skill-registry/config.d.cts.map +1 -1
  54. package/dist/v2/runtime/intelligence-platform/skill-registry/config.d.mts +28 -7
  55. package/dist/v2/runtime/intelligence-platform/skill-registry/config.d.mts.map +1 -1
  56. package/dist/v2/runtime/intelligence-platform/skill-registry/config.mjs +24 -6
  57. package/dist/v2/runtime/intelligence-platform/skill-registry/config.mjs.map +1 -1
  58. package/dist/v2/runtime/intelligence-platform/skill-registry/index.d.cts +1 -1
  59. package/dist/v2/runtime/intelligence-platform/skill-registry/index.d.mts +1 -1
  60. package/dist/v2/runtime/intelligence-platform/skill-registry/registry.cjs +120 -4
  61. package/dist/v2/runtime/intelligence-platform/skill-registry/registry.cjs.map +1 -1
  62. package/dist/v2/runtime/intelligence-platform/skill-registry/registry.d.cts +8 -2
  63. package/dist/v2/runtime/intelligence-platform/skill-registry/registry.d.cts.map +1 -1
  64. package/dist/v2/runtime/intelligence-platform/skill-registry/registry.d.mts +8 -2
  65. package/dist/v2/runtime/intelligence-platform/skill-registry/registry.d.mts.map +1 -1
  66. package/dist/v2/runtime/intelligence-platform/skill-registry/registry.mjs +119 -4
  67. package/dist/v2/runtime/intelligence-platform/skill-registry/registry.mjs.map +1 -1
  68. package/package.json +5 -5
@@ -1,8 +1,10 @@
1
1
  require("reflect-metadata");
2
+ const require_runtime = require('../../../../_virtual/_rolldown/runtime.cjs');
2
3
  const require_learned_skills = require('../learned-skills.cjs');
3
4
  const require_errors = require('./errors.cjs');
4
5
  const require_config = require('./config.cjs');
5
6
  const require_snapshot = require('./snapshot.cjs');
7
+ let node_crypto = require("node:crypto");
6
8
 
7
9
  //#region src/v2/runtime/intelligence-platform/skill-registry/registry.ts
8
10
  function transient(error) {
@@ -18,7 +20,7 @@ function deliveryError(error) {
18
20
  return new require_learned_skills.LearnedSkillsError(error instanceof Error && error.name === "TimeoutError" ? "TIMEOUT" : "NETWORK_ERROR", true, error);
19
21
  }
20
22
  /** Internal registry shared by framework adapters; public API is framework-native. */
21
- var SkillRegistry = class {
23
+ var SingleContainerRegistry = class {
22
24
  #config;
23
25
  #snapshot;
24
26
  #inFlight;
@@ -26,8 +28,9 @@ var SkillRegistry = class {
26
28
  #stale = false;
27
29
  #lastError;
28
30
  #blocked;
29
- constructor(options = {}) {
30
- this.#config = require_config.resolveRegistryConfig(options);
31
+ constructor(config, fetchSnapshot = (request) => config.client.getLearnedSkillsSnapshot(request)) {
32
+ this.fetchSnapshot = fetchSnapshot;
33
+ this.#config = config;
31
34
  }
32
35
  async initialize() {
33
36
  await this.acquireSnapshot();
@@ -68,7 +71,7 @@ var SkillRegistry = class {
68
71
  }, this.#config.requestTimeoutMs);
69
72
  });
70
73
  const replacement = async () => {
71
- const response = await this.#config.client.getLearnedSkillsSnapshot({
74
+ const response = await this.fetchSnapshot({
72
75
  containerId: this.#config.containerId,
73
76
  ...this.#config.revision !== void 0 ? { revision: this.#config.revision } : {},
74
77
  ...this.#snapshot ? { ifNoneMatch: this.#snapshot.etag } : {},
@@ -126,6 +129,119 @@ var SkillRegistry = class {
126
129
  });
127
130
  }
128
131
  };
132
+ /** Coalesce refreshes from this registry into one request in the next microtask. */
133
+ function batchLoader(client) {
134
+ let pending = [];
135
+ return (request) => new Promise((resolve, reject) => {
136
+ pending.push({
137
+ request,
138
+ resolve,
139
+ reject
140
+ });
141
+ if (pending.length !== 1) return;
142
+ queueMicrotask(async () => {
143
+ const batch = pending;
144
+ pending = [];
145
+ try {
146
+ const results = await client.getLearnedSkillsSnapshots({
147
+ containers: batch.map(({ request: { signal: _signal, ...source } }) => source),
148
+ signal: batch[0].request.signal
149
+ });
150
+ if (!Array.isArray(results) || results.length !== batch.length || results.some((result, index) => result?.containerId !== batch[index].request.containerId)) throw require_errors.invalidSnapshot();
151
+ for (let index = 0; index < batch.length; index++) {
152
+ const result = results[index];
153
+ if (result.status === "error") batch[index].reject(result.error);
154
+ else batch[index].resolve(result);
155
+ }
156
+ } catch (error) {
157
+ for (const item of batch) item.reject(error);
158
+ }
159
+ });
160
+ });
161
+ }
162
+ /** Compose independent container caches into one immutable invocation snapshot. */
163
+ var SkillRegistry = class {
164
+ #sources;
165
+ #multiple;
166
+ #snapshot;
167
+ #parts;
168
+ #inFlight;
169
+ constructor(options = {}) {
170
+ const config = require_config.resolveRegistryConfig(options);
171
+ this.#multiple = config.containers !== void 0;
172
+ const fetchBatch = batchLoader(config.client);
173
+ this.#sources = config.containers !== void 0 ? config.containers.map(({ id, revision }) => ({
174
+ id,
175
+ registry: new SingleContainerRegistry(Object.freeze({
176
+ client: config.client,
177
+ freshnessWindowMs: config.freshnessWindowMs,
178
+ requestTimeoutMs: config.requestTimeoutMs,
179
+ debug: config.debug,
180
+ containerId: id,
181
+ ...revision !== void 0 ? { revision } : {}
182
+ }), fetchBatch)
183
+ })) : [{
184
+ id: config.containerId,
185
+ registry: new SingleContainerRegistry({
186
+ client: config.client,
187
+ containerId: config.containerId,
188
+ revision: config.revision,
189
+ freshnessWindowMs: config.freshnessWindowMs,
190
+ requestTimeoutMs: config.requestTimeoutMs,
191
+ debug: config.debug
192
+ })
193
+ }];
194
+ }
195
+ /** Load every configured container before agent initialization completes. */
196
+ async initialize() {
197
+ await this.acquireSnapshot();
198
+ }
199
+ /** Capture every container once; a failed source cannot yield a partial catalog. */
200
+ acquireSnapshot() {
201
+ if (!this.#multiple) return this.#sources[0].registry.acquireSnapshot();
202
+ if (this.#inFlight) return this.#inFlight;
203
+ this.#inFlight = Promise.all(this.#sources.map(({ registry }) => registry.acquireSnapshot())).then((parts) => {
204
+ if (this.#snapshot && parts.every((part, index) => part === this.#parts?.[index])) return this.#snapshot;
205
+ const identity = (0, node_crypto.createHash)("sha256").update(JSON.stringify(parts.map((part, index) => [
206
+ this.#sources[index].id,
207
+ part.revision,
208
+ part.etag
209
+ ]))).digest("hex");
210
+ const skills = Object.freeze(parts.flatMap((part, index) => part.skills.map((skill) => Object.freeze({
211
+ ...skill,
212
+ name: `${encodeURIComponent(this.#sources[index].id)}/${skill.name}`
213
+ }))));
214
+ this.#parts = parts;
215
+ this.#snapshot = Object.freeze({
216
+ revision: `multi:${identity}`,
217
+ etag: `"${identity}"`,
218
+ skills
219
+ });
220
+ return this.#snapshot;
221
+ }).finally(() => {
222
+ this.#inFlight = void 0;
223
+ });
224
+ return this.#inFlight;
225
+ }
226
+ /** Report each container's real revision; no aggregate server revision exists. */
227
+ get status() {
228
+ if (!this.#multiple) return this.#sources[0].registry.status;
229
+ const containers = Object.freeze(this.#sources.map(({ id, registry }) => Object.freeze({
230
+ id,
231
+ ...registry.status
232
+ })));
233
+ const error = containers.find((source) => source.lastError && !source.lastError.retryable)?.lastError ?? containers.find((source) => source.lastError)?.lastError;
234
+ const timestamps = containers.map((source) => source.lastCheckedAt);
235
+ return Object.freeze({
236
+ initialized: this.#snapshot !== void 0,
237
+ mode: containers.every((source) => source.mode === "pinned") ? "pinned" : "latest",
238
+ stale: containers.some((source) => source.stale),
239
+ ...timestamps.every((timestamp) => timestamp !== void 0) ? { lastCheckedAt: [...timestamps].sort()[0] } : {},
240
+ ...error ? { lastError: error } : {},
241
+ containers
242
+ });
243
+ }
244
+ };
129
245
 
130
246
  //#endregion
131
247
  exports.SkillRegistry = SkillRegistry;
@@ -1 +1 @@
1
- {"version":3,"file":"registry.cjs","names":["SkillDeliveryError","#config","resolveRegistryConfig","#inFlight","#snapshot","#blocked","#lastCheckedAt","#refresh","#lastError","#stale","invalidSnapshot","validateSnapshot","#debug"],"sources":["../../../../../src/v2/runtime/intelligence-platform/skill-registry/registry.ts"],"sourcesContent":["import { resolveRegistryConfig } from \"./config\";\nimport type { RegistryConfig, SkillRegistryOptions } from \"./config\";\nimport { SkillDeliveryError, invalidSnapshot } from \"./errors\";\nimport type { SkillDeliveryErrorCode } from \"./errors\";\nimport { validateSnapshot } from \"./snapshot\";\nimport type { VerifiedSnapshot } from \"./snapshot\";\n\nexport interface SkillRegistryStatus {\n readonly initialized: boolean;\n readonly revision?: string;\n readonly mode: \"latest\" | \"pinned\";\n /** ISO 8601 timestamp of the last successful 200 or matching 304 check. */\n readonly lastCheckedAt?: string;\n readonly stale: boolean;\n readonly lastError?: Readonly<{\n code: SkillDeliveryErrorCode;\n message: string;\n retryable: boolean;\n }>;\n}\n\nfunction transient(error: SkillDeliveryError): boolean {\n return [\n \"NETWORK_ERROR\",\n \"TIMEOUT\",\n \"INVALID_SNAPSHOT\",\n \"UNSUPPORTED_SERVER\",\n ].includes(error.code);\n}\nfunction deliveryError(error: unknown): SkillDeliveryError {\n if (error instanceof SkillDeliveryError) return error;\n return new SkillDeliveryError(\n error instanceof Error && error.name === \"TimeoutError\"\n ? \"TIMEOUT\"\n : \"NETWORK_ERROR\",\n true,\n error,\n );\n}\n\n/** Internal registry shared by framework adapters; public API is framework-native. */\nexport class SkillRegistry {\n readonly #config: RegistryConfig;\n #snapshot?: VerifiedSnapshot;\n #inFlight?: Promise<VerifiedSnapshot>;\n #lastCheckedAt?: number;\n #stale = false;\n #lastError?: SkillDeliveryError;\n #blocked?: SkillDeliveryError;\n\n constructor(options: SkillRegistryOptions = {}) {\n this.#config = resolveRegistryConfig(options);\n }\n\n async initialize(): Promise<void> {\n await this.acquireSnapshot();\n }\n\n /** Capture exactly one immutable snapshot before model work begins. */\n acquireSnapshot(): Promise<VerifiedSnapshot> {\n if (this.#inFlight) return this.#inFlight;\n if (\n this.#snapshot &&\n !this.#blocked &&\n this.#lastCheckedAt !== undefined &&\n Date.now() - this.#lastCheckedAt < this.#config.freshnessWindowMs\n ) {\n return Promise.resolve(this.#snapshot);\n }\n // Defer work one microtask so reentrant and concurrent callers observe the\n // same promise before an injected client can start its request.\n this.#inFlight = Promise.resolve()\n .then(() => this.#refresh())\n .finally(() => {\n this.#inFlight = undefined;\n });\n return this.#inFlight;\n }\n\n get status(): SkillRegistryStatus {\n const error = this.#lastError;\n return Object.freeze({\n initialized: this.#snapshot !== undefined,\n ...(this.#snapshot ? { revision: this.#snapshot.revision } : {}),\n mode: this.#config.revision === undefined ? \"latest\" : \"pinned\",\n ...(this.#lastCheckedAt !== undefined\n ? { lastCheckedAt: new Date(this.#lastCheckedAt).toISOString() }\n : {}),\n stale: this.#stale,\n ...(error\n ? {\n lastError: Object.freeze({\n code: error.code,\n message: error.message,\n retryable: error.retryable,\n }),\n }\n : {}),\n });\n }\n\n async #refresh(): Promise<VerifiedSnapshot> {\n const startedAt = Date.now();\n const controller = new AbortController();\n let timer: ReturnType<typeof setTimeout> | undefined;\n const deadline = new Promise<never>((_, reject) => {\n timer = setTimeout(() => {\n const error = new SkillDeliveryError(\"TIMEOUT\", true);\n controller.abort(error);\n // Give a canonical client that already received denial headers one\n // event-loop turn to report that denial before the watchdog wins.\n timer = setTimeout(() => reject(error), 0);\n }, this.#config.requestTimeoutMs);\n });\n const replacement = async (): Promise<VerifiedSnapshot> => {\n const response = await this.#config.client.getLearnedSkillsSnapshot({\n containerId: this.#config.containerId,\n ...(this.#config.revision !== undefined\n ? { revision: this.#config.revision }\n : {}),\n ...(this.#snapshot ? { ifNoneMatch: this.#snapshot.etag } : {}),\n signal: controller.signal,\n });\n controller.signal.throwIfAborted();\n if (!response || typeof response !== \"object\") throw invalidSnapshot();\n if (response.status === \"unchanged\") {\n if (\n !this.#snapshot ||\n response.etag !== this.#snapshot.etag ||\n response.revision !== this.#snapshot.revision\n )\n throw invalidSnapshot();\n return this.#snapshot;\n }\n if (\n this.#config.revision !== undefined &&\n response.revision !== this.#config.revision\n )\n throw invalidSnapshot();\n return validateSnapshot(response, controller.signal);\n };\n try {\n const snapshot = await Promise.race([replacement(), deadline]);\n // An abandoned parse never writes registry state: only the winning\n // complete replacement reaches this assignment.\n this.#snapshot = snapshot;\n this.#lastCheckedAt = Date.now();\n this.#stale = false;\n this.#lastError = undefined;\n this.#blocked = undefined;\n this.#debug(\"refresh-success\", startedAt);\n return snapshot;\n } catch (cause) {\n const error = deliveryError(cause);\n if (!transient(error)) {\n this.#blocked = error;\n this.#stale = false;\n this.#lastError = error;\n this.#debug(\"refresh-denied\", startedAt, error.code);\n throw error;\n }\n // A later unreachable server cannot undo an already confirmed denial.\n if (this.#blocked) {\n this.#lastError = this.#blocked;\n this.#debug(\"refresh-failed\", startedAt, error.code);\n throw this.#blocked;\n }\n this.#lastError = error;\n this.#stale = this.#snapshot !== undefined;\n this.#debug(\"refresh-failed\", startedAt, error.code);\n if (this.#snapshot) return this.#snapshot;\n throw error;\n } finally {\n if (timer !== undefined) clearTimeout(timer);\n }\n }\n\n #debug(\n event: string,\n startedAt: number,\n errorCode?: SkillDeliveryErrorCode,\n ): void {\n if (!this.#config.debug) return;\n console.debug(\"CopilotKit learned skills\", {\n event,\n containerId: this.#config.containerId,\n revision: this.#snapshot?.revision,\n durationMs: Date.now() - startedAt,\n ...(errorCode ? { errorCode } : {}),\n });\n }\n}\n"],"mappings":";;;;;;;AAqBA,SAAS,UAAU,OAAoC;AACrD,QAAO;EACL;EACA;EACA;EACA;EACD,CAAC,SAAS,MAAM,KAAK;;AAExB,SAAS,cAAc,OAAoC;AACzD,KAAI,iBAAiBA,0CAAoB,QAAO;AAChD,QAAO,IAAIA,0CACT,iBAAiB,SAAS,MAAM,SAAS,iBACrC,YACA,iBACJ,MACA,MACD;;;AAIH,IAAa,gBAAb,MAA2B;CACzB,CAASC;CACT;CACA;CACA;CACA,SAAS;CACT;CACA;CAEA,YAAY,UAAgC,EAAE,EAAE;AAC9C,QAAKA,SAAUC,qCAAsB,QAAQ;;CAG/C,MAAM,aAA4B;AAChC,QAAM,KAAK,iBAAiB;;;CAI9B,kBAA6C;AAC3C,MAAI,MAAKC,SAAW,QAAO,MAAKA;AAChC,MACE,MAAKC,YACL,CAAC,MAAKC,WACN,MAAKC,kBAAmB,UACxB,KAAK,KAAK,GAAG,MAAKA,gBAAiB,MAAKL,OAAQ,kBAEhD,QAAO,QAAQ,QAAQ,MAAKG,SAAU;AAIxC,QAAKD,WAAY,QAAQ,SAAS,CAC/B,WAAW,MAAKI,SAAU,CAAC,CAC3B,cAAc;AACb,SAAKJ,WAAY;IACjB;AACJ,SAAO,MAAKA;;CAGd,IAAI,SAA8B;EAChC,MAAM,QAAQ,MAAKK;AACnB,SAAO,OAAO,OAAO;GACnB,aAAa,MAAKJ,aAAc;GAChC,GAAI,MAAKA,WAAY,EAAE,UAAU,MAAKA,SAAU,UAAU,GAAG,EAAE;GAC/D,MAAM,MAAK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iB,UAAU,WAAW,OAAO;;AAEtD,MAAI;GACF,MAAM,WAAW,MAAM,QAAQ,KAAK,CAAC,aAAa,EAAE,SAAS,CAAC;AAG9D,SAAKP,WAAY;AACjB,SAAKE,gBAAiB,KAAK,KAAK;AAChC,SAAKG,QAAS;AACd,SAAKD,YAAa;AAClB,SAAKH,UAAW;AAChB,SAAKO,MAAO,mBAAmB,UAAU;AACzC,UAAO;WACA,OAAO;GACd,MAAM,QAAQ,cAAc,MAAM;AAClC,OAAI,CAAC,UAAU,MAAM,EAAE;AACrB,UAAKP,UAAW;AAChB,UAAKI,QAAS;AACd,UAAKD,YAAa;AAClB,UAAKI,MAAO,kBAAkB,WAAW,MAAM,KAAK;AACpD,UAAM;;AAGR,OAAI,MAAKP,SAAU;AACjB,UAAKG,YAAa,MAAKH;AACvB,UAAKO,MAAO,kBAAkB,WAAW,MAAM,KAAK;AACpD,UAAM,MAAKP;;AAEb,SAAKG,YAAa;AAClB,SAAKC,QAAS,MAAKL,aAAc;AACjC,SAAKQ,MAAO,kBAAkB,WAAW,MAAM,KAAK;AACpD,OAAI,MAAKR,SAAW,QAAO,MAAKA;AAChC,SAAM;YACE;AACR,OAAI,UAAU,OAAW,cAAa,MAAM;;;CAIhD,OACE,OACA,WACA,WACM;AACN,MAAI,CAAC,MAAKH,OAAQ,MAAO;AACzB,UAAQ,MAAM,6BAA6B;GACzC;GACA,aAAa,MAAKA,OAAQ;GAC1B,UAAU,MAAKG,UAAW;GAC1B,YAAY,KAAK,KAAK,GAAG;GACzB,GAAI,YAAY,EAAE,WAAW,GAAG,EAAE;GACnC,CAAC"}
1
+ {"version":3,"file":"registry.cjs","names":["SkillDeliveryError","#config","#inFlight","#snapshot","#blocked","#lastCheckedAt","#refresh","#lastError","#stale","invalidSnapshot","validateSnapshot","#debug","#sources","#multiple","resolveRegistryConfig","#parts"],"sources":["../../../../../src/v2/runtime/intelligence-platform/skill-registry/registry.ts"],"sourcesContent":["import type { CopilotKitIntelligence } from \"../client\";\nimport type {\n GetLearnedSkillsSnapshotRequest,\n LearnedSkillsSnapshotResult,\n} from \"../learned-skills\";\nimport { createHash } from \"node:crypto\";\nimport { resolveRegistryConfig } from \"./config\";\nimport type { SingleContainerConfig, SkillRegistryOptions } from \"./config\";\nimport { SkillDeliveryError, invalidSnapshot } from \"./errors\";\nimport type { SkillDeliveryErrorCode } from \"./errors\";\nimport { validateSnapshot } from \"./snapshot\";\nimport type { VerifiedSnapshot } from \"./snapshot\";\n\nexport interface SkillRegistryStatus {\n /** Present only for the explicit containers interface. */\n readonly containers?: readonly (SkillRegistryStatus & {\n readonly id: string;\n })[];\n readonly initialized: boolean;\n readonly revision?: string;\n readonly mode: \"latest\" | \"pinned\";\n /** ISO 8601 timestamp of the last successful 200 or matching 304 check. */\n readonly lastCheckedAt?: string;\n readonly stale: boolean;\n readonly lastError?: Readonly<{\n code: SkillDeliveryErrorCode;\n message: string;\n retryable: boolean;\n }>;\n}\n\nfunction transient(error: SkillDeliveryError): boolean {\n return [\n \"NETWORK_ERROR\",\n \"TIMEOUT\",\n \"INVALID_SNAPSHOT\",\n \"UNSUPPORTED_SERVER\",\n ].includes(error.code);\n}\nfunction deliveryError(error: unknown): SkillDeliveryError {\n if (error instanceof SkillDeliveryError) return error;\n return new SkillDeliveryError(\n error instanceof Error && error.name === \"TimeoutError\"\n ? \"TIMEOUT\"\n : \"NETWORK_ERROR\",\n true,\n error,\n );\n}\n\n/** Internal registry shared by framework adapters; public API is framework-native. */\nclass SingleContainerRegistry {\n readonly #config: SingleContainerConfig;\n #snapshot?: VerifiedSnapshot;\n #inFlight?: Promise<VerifiedSnapshot>;\n #lastCheckedAt?: number;\n #stale = false;\n #lastError?: SkillDeliveryError;\n #blocked?: SkillDeliveryError;\n\n constructor(\n config: SingleContainerConfig,\n private readonly fetchSnapshot = (\n request: GetLearnedSkillsSnapshotRequest,\n ) => config.client.getLearnedSkillsSnapshot(request),\n ) {\n this.#config = config;\n }\n\n async initialize(): Promise<void> {\n await this.acquireSnapshot();\n }\n\n /** Capture exactly one immutable snapshot before model work begins. */\n acquireSnapshot(): Promise<VerifiedSnapshot> {\n if (this.#inFlight) return this.#inFlight;\n if (\n this.#snapshot &&\n !this.#blocked &&\n this.#lastCheckedAt !== undefined &&\n Date.now() - this.#lastCheckedAt < this.#config.freshnessWindowMs\n ) {\n return Promise.resolve(this.#snapshot);\n }\n // Defer work one microtask so reentrant and concurrent callers observe the\n // same promise before an injected client can start its request.\n this.#inFlight = Promise.resolve()\n .then(() => this.#refresh())\n .finally(() => {\n this.#inFlight = undefined;\n });\n return this.#inFlight;\n }\n\n get status(): SkillRegistryStatus {\n const error = this.#lastError;\n return Object.freeze({\n initialized: this.#snapshot !== undefined,\n ...(this.#snapshot ? { revision: this.#snapshot.revision } : {}),\n mode: this.#config.revision === undefined ? \"latest\" : \"pinned\",\n ...(this.#lastCheckedAt !== undefined\n ? { lastCheckedAt: new Date(this.#lastCheckedAt).toISOString() }\n : {}),\n stale: this.#stale,\n ...(error\n ? {\n lastError: Object.freeze({\n code: error.code,\n message: error.message,\n retryable: error.retryable,\n }),\n }\n : {}),\n });\n }\n\n async #refresh(): Promise<VerifiedSnapshot> {\n const startedAt = Date.now();\n const controller = new AbortController();\n let timer: ReturnType<typeof setTimeout> | undefined;\n const deadline = new Promise<never>((_, reject) => {\n timer = setTimeout(() => {\n const error = new SkillDeliveryError(\"TIMEOUT\", true);\n controller.abort(error);\n // Give a canonical client that already received denial headers one\n // event-loop turn to report that denial before the watchdog wins.\n timer = setTimeout(() => reject(error), 0);\n }, this.#config.requestTimeoutMs);\n });\n const replacement = async (): Promise<VerifiedSnapshot> => {\n const response = await this.fetchSnapshot({\n containerId: this.#config.containerId,\n ...(this.#config.revision !== undefined\n ? { revision: this.#config.revision }\n : {}),\n ...(this.#snapshot ? { ifNoneMatch: this.#snapshot.etag } : {}),\n signal: controller.signal,\n });\n controller.signal.throwIfAborted();\n if (!response || typeof response !== \"object\") throw invalidSnapshot();\n if (response.status === \"unchanged\") {\n if (\n !this.#snapshot ||\n response.etag !== this.#snapshot.etag ||\n response.revision !== this.#snapshot.revision\n )\n throw invalidSnapshot();\n return this.#snapshot;\n }\n if (\n this.#config.revision !== undefined &&\n response.revision !== this.#config.revision\n )\n throw invalidSnapshot();\n return validateSnapshot(response, controller.signal);\n };\n try {\n const snapshot = await Promise.race([replacement(), deadline]);\n // An abandoned parse never writes registry state: only the winning\n // complete replacement reaches this assignment.\n this.#snapshot = snapshot;\n this.#lastCheckedAt = Date.now();\n this.#stale = false;\n this.#lastError = undefined;\n this.#blocked = undefined;\n this.#debug(\"refresh-success\", startedAt);\n return snapshot;\n } catch (cause) {\n const error = deliveryError(cause);\n if (!transient(error)) {\n this.#blocked = error;\n this.#stale = false;\n this.#lastError = error;\n this.#debug(\"refresh-denied\", startedAt, error.code);\n throw error;\n }\n // A later unreachable server cannot undo an already confirmed denial.\n if (this.#blocked) {\n this.#lastError = this.#blocked;\n this.#debug(\"refresh-failed\", startedAt, error.code);\n throw this.#blocked;\n }\n this.#lastError = error;\n this.#stale = this.#snapshot !== undefined;\n this.#debug(\"refresh-failed\", startedAt, error.code);\n if (this.#snapshot) return this.#snapshot;\n throw error;\n } finally {\n if (timer !== undefined) clearTimeout(timer);\n }\n }\n\n #debug(\n event: string,\n startedAt: number,\n errorCode?: SkillDeliveryErrorCode,\n ): void {\n if (!this.#config.debug) return;\n console.debug(\"CopilotKit learned skills\", {\n event,\n containerId: this.#config.containerId,\n revision: this.#snapshot?.revision,\n durationMs: Date.now() - startedAt,\n ...(errorCode ? { errorCode } : {}),\n });\n }\n}\n\n/** Coalesce refreshes from this registry into one request in the next microtask. */\nfunction batchLoader(client: CopilotKitIntelligence) {\n let pending: {\n request: GetLearnedSkillsSnapshotRequest;\n resolve: (value: LearnedSkillsSnapshotResult) => void;\n reject: (error: unknown) => void;\n }[] = [];\n return (\n request: GetLearnedSkillsSnapshotRequest,\n ): Promise<LearnedSkillsSnapshotResult> =>\n new Promise((resolve, reject) => {\n pending.push({ request, resolve, reject });\n if (pending.length !== 1) return;\n queueMicrotask(async () => {\n const batch = pending;\n pending = [];\n try {\n const results = await client.getLearnedSkillsSnapshots({\n containers: batch.map(\n ({ request: { signal: _signal, ...source } }) => source,\n ),\n signal: batch[0].request.signal,\n });\n if (\n !Array.isArray(results) ||\n results.length !== batch.length ||\n results.some(\n (result, index) =>\n result?.containerId !== batch[index].request.containerId,\n )\n )\n throw invalidSnapshot();\n for (let index = 0; index < batch.length; index++) {\n const result = results[index];\n if (result.status === \"error\") batch[index].reject(result.error);\n else batch[index].resolve(result);\n }\n } catch (error) {\n for (const item of batch) item.reject(error);\n }\n });\n });\n}\n\n/** Compose independent container caches into one immutable invocation snapshot. */\nexport class SkillRegistry {\n readonly #sources: readonly {\n readonly id: string;\n readonly registry: SingleContainerRegistry;\n }[];\n readonly #multiple: boolean;\n #snapshot?: VerifiedSnapshot;\n #parts?: readonly VerifiedSnapshot[];\n #inFlight?: Promise<VerifiedSnapshot>;\n\n constructor(options: SkillRegistryOptions = {}) {\n const config = resolveRegistryConfig(options);\n this.#multiple = config.containers !== undefined;\n const fetchBatch = batchLoader(config.client);\n this.#sources =\n config.containers !== undefined\n ? config.containers.map(({ id, revision }) => ({\n id,\n registry: new SingleContainerRegistry(\n Object.freeze({\n client: config.client,\n freshnessWindowMs: config.freshnessWindowMs,\n requestTimeoutMs: config.requestTimeoutMs,\n debug: config.debug,\n containerId: id,\n ...(revision !== undefined ? { revision } : {}),\n }),\n fetchBatch,\n ),\n }))\n : [\n {\n id: config.containerId!,\n registry: new SingleContainerRegistry({\n client: config.client,\n containerId: config.containerId!,\n revision: config.revision,\n freshnessWindowMs: config.freshnessWindowMs,\n requestTimeoutMs: config.requestTimeoutMs,\n debug: config.debug,\n }),\n },\n ];\n }\n\n /** Load every configured container before agent initialization completes. */\n async initialize(): Promise<void> {\n await this.acquireSnapshot();\n }\n\n /** Capture every container once; a failed source cannot yield a partial catalog. */\n acquireSnapshot(): Promise<VerifiedSnapshot> {\n if (!this.#multiple) return this.#sources[0].registry.acquireSnapshot();\n if (this.#inFlight) return this.#inFlight;\n this.#inFlight = Promise.all(\n this.#sources.map(({ registry }) => registry.acquireSnapshot()),\n )\n .then((parts) => {\n if (\n this.#snapshot &&\n parts.every((part, index) => part === this.#parts?.[index])\n ) {\n return this.#snapshot;\n }\n const identity = createHash(\"sha256\")\n .update(\n JSON.stringify(\n parts.map((part, index) => [\n this.#sources[index].id,\n part.revision,\n part.etag,\n ]),\n ),\n )\n .digest(\"hex\");\n const skills = Object.freeze(\n parts.flatMap((part, index) =>\n part.skills.map((skill) =>\n Object.freeze({\n ...skill,\n name: `${encodeURIComponent(this.#sources[index].id)}/${skill.name}`,\n }),\n ),\n ),\n );\n this.#parts = parts;\n this.#snapshot = Object.freeze({\n revision: `multi:${identity}`,\n etag: `\"${identity}\"`,\n skills,\n });\n return this.#snapshot;\n })\n .finally(() => {\n this.#inFlight = undefined;\n });\n return this.#inFlight;\n }\n\n /** Report each container's real revision; no aggregate server revision exists. */\n get status(): SkillRegistryStatus {\n if (!this.#multiple) return this.#sources[0].registry.status;\n const containers = Object.freeze(\n this.#sources.map(({ id, registry }) =>\n Object.freeze({ id, ...registry.status }),\n ),\n );\n const error =\n containers.find(\n (source) => source.lastError && !source.lastError.retryable,\n )?.lastError ?? containers.find((source) => source.lastError)?.lastError;\n const timestamps = containers.map((source) => source.lastCheckedAt);\n return Object.freeze({\n initialized: this.#snapshot !== undefined,\n mode: containers.every((source) => source.mode === \"pinned\")\n ? \"pinned\"\n : \"latest\",\n stale: containers.some((source) => source.stale),\n ...(timestamps.every((timestamp) => timestamp !== undefined)\n ? { lastCheckedAt: [...timestamps].sort()[0] }\n : {}),\n ...(error ? { lastError: error } : {}),\n containers,\n });\n }\n}\n"],"mappings":";;;;;;;;;AA+BA,SAAS,UAAU,OAAoC;AACrD,QAAO;EACL;EACA;EACA;EACA;EACD,CAAC,SAAS,MAAM,KAAK;;AAExB,SAAS,cAAc,OAAoC;AACz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C;GACD,CAAC"}
@@ -5,6 +5,10 @@ import { VerifiedSnapshot } from "./snapshot.cjs";
5
5
 
6
6
  //#region src/v2/runtime/intelligence-platform/skill-registry/registry.d.ts
7
7
  interface SkillRegistryStatus {
8
+ /** Present only for the explicit containers interface. */
9
+ readonly containers?: readonly (SkillRegistryStatus & {
10
+ readonly id: string;
11
+ })[];
8
12
  readonly initialized: boolean;
9
13
  readonly revision?: string;
10
14
  readonly mode: "latest" | "pinned";
@@ -17,13 +21,15 @@ interface SkillRegistryStatus {
17
21
  retryable: boolean;
18
22
  }>;
19
23
  }
20
- /** Internal registry shared by framework adapters; public API is framework-native. */
24
+ /** Compose independent container caches into one immutable invocation snapshot. */
21
25
  declare class SkillRegistry {
22
26
  #private;
23
27
  constructor(options?: SkillRegistryOptions);
28
+ /** Load every configured container before agent initialization completes. */
24
29
  initialize(): Promise<void>;
25
- /** Capture exactly one immutable snapshot before model work begins. */
30
+ /** Capture every container once; a failed source cannot yield a partial catalog. */
26
31
  acquireSnapshot(): Promise<VerifiedSnapshot>;
32
+ /** Report each container's real revision; no aggregate server revision exists. */
27
33
  get status(): SkillRegistryStatus;
28
34
  }
29
35
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.cts","names":[],"sources":["../../../../../src/v2/runtime/intelligence-platform/skill-registry/registry.ts"],"mappings":";;;;;;UAOiB,mBAAA;EAAA,SACN,WAAA;EAAA,SACA,QAAA;EAAA,SACA,IAAA;;WAEA,aAAA;EAAA,SACA,KAAA;EAAA,SACA,SAAA,GAAY,QAAA;IACnB,IAAA,EAAM,sBAAA;IACN,OAAA;IACA,SAAA;EAAA;AAAA;;cAwBS,aAAA;EAAA;cASC,OAAA,GAAS,oBAAA;EAIf,UAAA,CAAA,GAAc,OAAA;EArCT;EA0CX,eAAA,CAAA,GAAmB,OAAA,CAAQ,gBAAA;EAAA,IAoBvB,MAAA,CAAA,GAAU,mBAAA;AAAA"}
1
+ {"version":3,"file":"registry.d.cts","names":[],"sources":["../../../../../src/v2/runtime/intelligence-platform/skill-registry/registry.ts"],"mappings":";;;;;;UAaiB,mBAAA;;WAEN,UAAA,aAAuB,mBAAA;IAAA,SACrB,EAAA;EAAA;EAAA,SAEF,WAAA;EAAA,SACA,QAAA;EAAA,SACA,IAAA;EAIoB;EAAA,SAFpB,aAAA;EAAA,SACA,KAAA;EAAA,SACA,SAAA,GAAY,QAAA;IACnB,IAAA,EAAM,sBAAA;IACN,OAAA;IACA,SAAA;EAAA;AAAA;;cAkOS,aAAA;EAAA;cAUC,OAAA,GAAS,oBAAA;EA9Ob;EAkRF,UAAA,CAAA,GAAc,OAAA;EAhRlB;EAqRF,eAAA,CAAA,GAAmB,OAAA,CAAQ,gBAAA;EArRhB;EAAA,IAsUP,MAAA,CAAA,GAAU,mBAAA;AAAA"}
@@ -5,6 +5,10 @@ import { VerifiedSnapshot } from "./snapshot.mjs";
5
5
 
6
6
  //#region src/v2/runtime/intelligence-platform/skill-registry/registry.d.ts
7
7
  interface SkillRegistryStatus {
8
+ /** Present only for the explicit containers interface. */
9
+ readonly containers?: readonly (SkillRegistryStatus & {
10
+ readonly id: string;
11
+ })[];
8
12
  readonly initialized: boolean;
9
13
  readonly revision?: string;
10
14
  readonly mode: "latest" | "pinned";
@@ -17,13 +21,15 @@ interface SkillRegistryStatus {
17
21
  retryable: boolean;
18
22
  }>;
19
23
  }
20
- /** Internal registry shared by framework adapters; public API is framework-native. */
24
+ /** Compose independent container caches into one immutable invocation snapshot. */
21
25
  declare class SkillRegistry {
22
26
  #private;
23
27
  constructor(options?: SkillRegistryOptions);
28
+ /** Load every configured container before agent initialization completes. */
24
29
  initialize(): Promise<void>;
25
- /** Capture exactly one immutable snapshot before model work begins. */
30
+ /** Capture every container once; a failed source cannot yield a partial catalog. */
26
31
  acquireSnapshot(): Promise<VerifiedSnapshot>;
32
+ /** Report each container's real revision; no aggregate server revision exists. */
27
33
  get status(): SkillRegistryStatus;
28
34
  }
29
35
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.mts","names":[],"sources":["../../../../../src/v2/runtime/intelligence-platform/skill-registry/registry.ts"],"mappings":";;;;;;UAOiB,mBAAA;EAAA,SACN,WAAA;EAAA,SACA,QAAA;EAAA,SACA,IAAA;;WAEA,aAAA;EAAA,SACA,KAAA;EAAA,SACA,SAAA,GAAY,QAAA;IACnB,IAAA,EAAM,sBAAA;IACN,OAAA;IACA,SAAA;EAAA;AAAA;;cAwBS,aAAA;EAAA;cASC,OAAA,GAAS,oBAAA;EAIf,UAAA,CAAA,GAAc,OAAA;EArCT;EA0CX,eAAA,CAAA,GAAmB,OAAA,CAAQ,gBAAA;EAAA,IAoBvB,MAAA,CAAA,GAAU,mBAAA;AAAA"}
1
+ {"version":3,"file":"registry.d.mts","names":[],"sources":["../../../../../src/v2/runtime/intelligence-platform/skill-registry/registry.ts"],"mappings":";;;;;;UAaiB,mBAAA;;WAEN,UAAA,aAAuB,mBAAA;IAAA,SACrB,EAAA;EAAA;EAAA,SAEF,WAAA;EAAA,SACA,QAAA;EAAA,SACA,IAAA;EAIoB;EAAA,SAFpB,aAAA;EAAA,SACA,KAAA;EAAA,SACA,SAAA,GAAY,QAAA;IACnB,IAAA,EAAM,sBAAA;IACN,OAAA;IACA,SAAA;EAAA;AAAA;;cAkOS,aAAA;EAAA;cAUC,OAAA,GAAS,oBAAA;EA9Ob;EAkRF,UAAA,CAAA,GAAc,OAAA;EAhRlB;EAqRF,eAAA,CAAA,GAAmB,OAAA,CAAQ,gBAAA;EArRhB;EAAA,IAsUP,MAAA,CAAA,GAAU,mBAAA;AAAA"}
@@ -3,6 +3,7 @@ import { LearnedSkillsError } from "../learned-skills.mjs";
3
3
  import { invalidSnapshot } from "./errors.mjs";
4
4
  import { resolveRegistryConfig } from "./config.mjs";
5
5
  import { validateSnapshot } from "./snapshot.mjs";
6
+ import { createHash } from "node:crypto";
6
7
 
7
8
  //#region src/v2/runtime/intelligence-platform/skill-registry/registry.ts
8
9
  function transient(error) {
@@ -18,7 +19,7 @@ function deliveryError(error) {
18
19
  return new LearnedSkillsError(error instanceof Error && error.name === "TimeoutError" ? "TIMEOUT" : "NETWORK_ERROR", true, error);
19
20
  }
20
21
  /** Internal registry shared by framework adapters; public API is framework-native. */
21
- var SkillRegistry = class {
22
+ var SingleContainerRegistry = class {
22
23
  #config;
23
24
  #snapshot;
24
25
  #inFlight;
@@ -26,8 +27,9 @@ var SkillRegistry = class {
26
27
  #stale = false;
27
28
  #lastError;
28
29
  #blocked;
29
- constructor(options = {}) {
30
- this.#config = resolveRegistryConfig(options);
30
+ constructor(config, fetchSnapshot = (request) => config.client.getLearnedSkillsSnapshot(request)) {
31
+ this.fetchSnapshot = fetchSnapshot;
32
+ this.#config = config;
31
33
  }
32
34
  async initialize() {
33
35
  await this.acquireSnapshot();
@@ -68,7 +70,7 @@ var SkillRegistry = class {
68
70
  }, this.#config.requestTimeoutMs);
69
71
  });
70
72
  const replacement = async () => {
71
- const response = await this.#config.client.getLearnedSkillsSnapshot({
73
+ const response = await this.fetchSnapshot({
72
74
  containerId: this.#config.containerId,
73
75
  ...this.#config.revision !== void 0 ? { revision: this.#config.revision } : {},
74
76
  ...this.#snapshot ? { ifNoneMatch: this.#snapshot.etag } : {},
@@ -126,6 +128,119 @@ var SkillRegistry = class {
126
128
  });
127
129
  }
128
130
  };
131
+ /** Coalesce refreshes from this registry into one request in the next microtask. */
132
+ function batchLoader(client) {
133
+ let pending = [];
134
+ return (request) => new Promise((resolve, reject) => {
135
+ pending.push({
136
+ request,
137
+ resolve,
138
+ reject
139
+ });
140
+ if (pending.length !== 1) return;
141
+ queueMicrotask(async () => {
142
+ const batch = pending;
143
+ pending = [];
144
+ try {
145
+ const results = await client.getLearnedSkillsSnapshots({
146
+ containers: batch.map(({ request: { signal: _signal, ...source } }) => source),
147
+ signal: batch[0].request.signal
148
+ });
149
+ if (!Array.isArray(results) || results.length !== batch.length || results.some((result, index) => result?.containerId !== batch[index].request.containerId)) throw invalidSnapshot();
150
+ for (let index = 0; index < batch.length; index++) {
151
+ const result = results[index];
152
+ if (result.status === "error") batch[index].reject(result.error);
153
+ else batch[index].resolve(result);
154
+ }
155
+ } catch (error) {
156
+ for (const item of batch) item.reject(error);
157
+ }
158
+ });
159
+ });
160
+ }
161
+ /** Compose independent container caches into one immutable invocation snapshot. */
162
+ var SkillRegistry = class {
163
+ #sources;
164
+ #multiple;
165
+ #snapshot;
166
+ #parts;
167
+ #inFlight;
168
+ constructor(options = {}) {
169
+ const config = resolveRegistryConfig(options);
170
+ this.#multiple = config.containers !== void 0;
171
+ const fetchBatch = batchLoader(config.client);
172
+ this.#sources = config.containers !== void 0 ? config.containers.map(({ id, revision }) => ({
173
+ id,
174
+ registry: new SingleContainerRegistry(Object.freeze({
175
+ client: config.client,
176
+ freshnessWindowMs: config.freshnessWindowMs,
177
+ requestTimeoutMs: config.requestTimeoutMs,
178
+ debug: config.debug,
179
+ containerId: id,
180
+ ...revision !== void 0 ? { revision } : {}
181
+ }), fetchBatch)
182
+ })) : [{
183
+ id: config.containerId,
184
+ registry: new SingleContainerRegistry({
185
+ client: config.client,
186
+ containerId: config.containerId,
187
+ revision: config.revision,
188
+ freshnessWindowMs: config.freshnessWindowMs,
189
+ requestTimeoutMs: config.requestTimeoutMs,
190
+ debug: config.debug
191
+ })
192
+ }];
193
+ }
194
+ /** Load every configured container before agent initialization completes. */
195
+ async initialize() {
196
+ await this.acquireSnapshot();
197
+ }
198
+ /** Capture every container once; a failed source cannot yield a partial catalog. */
199
+ acquireSnapshot() {
200
+ if (!this.#multiple) return this.#sources[0].registry.acquireSnapshot();
201
+ if (this.#inFlight) return this.#inFlight;
202
+ this.#inFlight = Promise.all(this.#sources.map(({ registry }) => registry.acquireSnapshot())).then((parts) => {
203
+ if (this.#snapshot && parts.every((part, index) => part === this.#parts?.[index])) return this.#snapshot;
204
+ const identity = createHash("sha256").update(JSON.stringify(parts.map((part, index) => [
205
+ this.#sources[index].id,
206
+ part.revision,
207
+ part.etag
208
+ ]))).digest("hex");
209
+ const skills = Object.freeze(parts.flatMap((part, index) => part.skills.map((skill) => Object.freeze({
210
+ ...skill,
211
+ name: `${encodeURIComponent(this.#sources[index].id)}/${skill.name}`
212
+ }))));
213
+ this.#parts = parts;
214
+ this.#snapshot = Object.freeze({
215
+ revision: `multi:${identity}`,
216
+ etag: `"${identity}"`,
217
+ skills
218
+ });
219
+ return this.#snapshot;
220
+ }).finally(() => {
221
+ this.#inFlight = void 0;
222
+ });
223
+ return this.#inFlight;
224
+ }
225
+ /** Report each container's real revision; no aggregate server revision exists. */
226
+ get status() {
227
+ if (!this.#multiple) return this.#sources[0].registry.status;
228
+ const containers = Object.freeze(this.#sources.map(({ id, registry }) => Object.freeze({
229
+ id,
230
+ ...registry.status
231
+ })));
232
+ const error = containers.find((source) => source.lastError && !source.lastError.retryable)?.lastError ?? containers.find((source) => source.lastError)?.lastError;
233
+ const timestamps = containers.map((source) => source.lastCheckedAt);
234
+ return Object.freeze({
235
+ initialized: this.#snapshot !== void 0,
236
+ mode: containers.every((source) => source.mode === "pinned") ? "pinned" : "latest",
237
+ stale: containers.some((source) => source.stale),
238
+ ...timestamps.every((timestamp) => timestamp !== void 0) ? { lastCheckedAt: [...timestamps].sort()[0] } : {},
239
+ ...error ? { lastError: error } : {},
240
+ containers
241
+ });
242
+ }
243
+ };
129
244
 
130
245
  //#endregion
131
246
  export { SkillRegistry };
@@ -1 +1 @@
1
- {"version":3,"file":"registry.mjs","names":["SkillDeliveryError","#config","#inFlight","#snapshot","#blocked","#lastCheckedAt","#refresh","#lastError","#stale","#debug"],"sources":["../../../../../src/v2/runtime/intelligence-platform/skill-registry/registry.ts"],"sourcesContent":["import { resolveRegistryConfig } from \"./config\";\nimport type { RegistryConfig, SkillRegistryOptions } from \"./config\";\nimport { SkillDeliveryError, invalidSnapshot } from \"./errors\";\nimport type { SkillDeliveryErrorCode } from \"./errors\";\nimport { validateSnapshot } from \"./snapshot\";\nimport type { VerifiedSnapshot } from \"./snapshot\";\n\nexport interface SkillRegistryStatus {\n readonly initialized: boolean;\n readonly revision?: string;\n readonly mode: \"latest\" | \"pinned\";\n /** ISO 8601 timestamp of the last successful 200 or matching 304 check. */\n readonly lastCheckedAt?: string;\n readonly stale: boolean;\n readonly lastError?: Readonly<{\n code: SkillDeliveryErrorCode;\n message: string;\n retryable: boolean;\n }>;\n}\n\nfunction transient(error: SkillDeliveryError): boolean {\n return [\n \"NETWORK_ERROR\",\n \"TIMEOUT\",\n \"INVALID_SNAPSHOT\",\n \"UNSUPPORTED_SERVER\",\n ].includes(error.code);\n}\nfunction deliveryError(error: unknown): SkillDeliveryError {\n if (error instanceof SkillDeliveryError) return error;\n return new SkillDeliveryError(\n error instanceof Error && error.name === \"TimeoutError\"\n ? \"TIMEOUT\"\n : \"NETWORK_ERROR\",\n true,\n error,\n );\n}\n\n/** Internal registry shared by framework adapters; public API is framework-native. */\nexport class SkillRegistry {\n readonly #config: RegistryConfig;\n #snapshot?: VerifiedSnapshot;\n #inFlight?: Promise<VerifiedSnapshot>;\n #lastCheckedAt?: number;\n #stale = false;\n #lastError?: SkillDeliveryError;\n #blocked?: SkillDeliveryError;\n\n constructor(options: SkillRegistryOptions = {}) {\n this.#config = resolveRegistryConfig(options);\n }\n\n async initialize(): Promise<void> {\n await this.acquireSnapshot();\n }\n\n /** Capture exactly one immutable snapshot before model work begins. */\n acquireSnapshot(): Promise<VerifiedSnapshot> {\n if (this.#inFlight) return this.#inFlight;\n if (\n this.#snapshot &&\n !this.#blocked &&\n this.#lastCheckedAt !== undefined &&\n Date.now() - this.#lastCheckedAt < this.#config.freshnessWindowMs\n ) {\n return Promise.resolve(this.#snapshot);\n }\n // Defer work one microtask so reentrant and concurrent callers observe the\n // same promise before an injected client can start its request.\n this.#inFlight = Promise.resolve()\n .then(() => this.#refresh())\n .finally(() => {\n this.#inFlight = undefined;\n });\n return this.#inFlight;\n }\n\n get status(): SkillRegistryStatus {\n const error = this.#lastError;\n return Object.freeze({\n initialized: this.#snapshot !== undefined,\n ...(this.#snapshot ? { revision: this.#snapshot.revision } : {}),\n mode: this.#config.revision === undefined ? \"latest\" : \"pinned\",\n ...(this.#lastCheckedAt !== undefined\n ? { lastCheckedAt: new Date(this.#lastCheckedAt).toISOString() }\n : {}),\n stale: this.#stale,\n ...(error\n ? {\n lastError: Object.freeze({\n code: error.code,\n message: error.message,\n retryable: error.retryable,\n }),\n }\n : {}),\n });\n }\n\n async #refresh(): Promise<VerifiedSnapshot> {\n const startedAt = Date.now();\n const controller = new AbortController();\n let timer: ReturnType<typeof setTimeout> | undefined;\n const deadline = new Promise<never>((_, reject) => {\n timer = setTimeout(() => {\n const error = new SkillDeliveryError(\"TIMEOUT\", true);\n controller.abort(error);\n // Give a canonical client that already received denial headers one\n // event-loop turn to report that denial before the watchdog wins.\n timer = setTimeout(() => reject(error), 0);\n }, this.#config.requestTimeoutMs);\n });\n const replacement = async (): Promise<VerifiedSnapshot> => {\n const response = await this.#config.client.getLearnedSkillsSnapshot({\n containerId: this.#config.containerId,\n ...(this.#config.revision !== undefined\n ? { revision: this.#config.revision }\n : {}),\n ...(this.#snapshot ? { ifNoneMatch: this.#snapshot.etag } : {}),\n signal: controller.signal,\n });\n controller.signal.throwIfAborted();\n if (!response || typeof response !== \"object\") throw invalidSnapshot();\n if (response.status === \"unchanged\") {\n if (\n !this.#snapshot ||\n response.etag !== this.#snapshot.etag ||\n response.revision !== this.#snapshot.revision\n )\n throw invalidSnapshot();\n return this.#snapshot;\n }\n if (\n this.#config.revision !== undefined &&\n response.revision !== this.#config.revision\n )\n throw invalidSnapshot();\n return validateSnapshot(response, controller.signal);\n };\n try {\n const snapshot = await Promise.race([replacement(), deadline]);\n // An abandoned parse never writes registry state: only the winning\n // complete replacement reaches this assignment.\n this.#snapshot = snapshot;\n this.#lastCheckedAt = Date.now();\n this.#stale = false;\n this.#lastError = undefined;\n this.#blocked = undefined;\n this.#debug(\"refresh-success\", startedAt);\n return snapshot;\n } catch (cause) {\n const error = deliveryError(cause);\n if (!transient(error)) {\n this.#blocked = error;\n this.#stale = false;\n this.#lastError = error;\n this.#debug(\"refresh-denied\", startedAt, error.code);\n throw error;\n }\n // A later unreachable server cannot undo an already confirmed denial.\n if (this.#blocked) {\n this.#lastError = this.#blocked;\n this.#debug(\"refresh-failed\", startedAt, error.code);\n throw this.#blocked;\n }\n this.#lastError = error;\n this.#stale = this.#snapshot !== undefined;\n this.#debug(\"refresh-failed\", startedAt, error.code);\n if (this.#snapshot) return this.#snapshot;\n throw error;\n } finally {\n if (timer !== undefined) clearTimeout(timer);\n }\n }\n\n #debug(\n event: string,\n startedAt: number,\n errorCode?: SkillDeliveryErrorCode,\n ): void {\n if (!this.#config.debug) return;\n console.debug(\"CopilotKit learned skills\", {\n event,\n containerId: this.#config.containerId,\n revision: this.#snapshot?.revision,\n durationMs: Date.now() - startedAt,\n ...(errorCode ? { errorCode } : {}),\n });\n }\n}\n"],"mappings":";;;;;;;AAqBA,SAAS,UAAU,OAAoC;AACrD,QAAO;EACL;EACA;EACA;EACA;EACD,CAAC,SAAS,MAAM,KAAK;;AAExB,SAAS,cAAc,OAAoC;AACzD,KAAI,iBAAiBA,mBAAoB,QAAO;AAChD,QAAO,IAAIA,mBACT,iBAAiB,SAAS,MAAM,SAAS,iBACrC,YACA,iBACJ,MACA,MACD;;;AAIH,IAAa,gBAAb,MAA2B;CACzB,CAASC;CACT;CACA;CACA;CACA,SAAS;CACT;CACA;CAEA,YAAY,UAAgC,EAAE,EAAE;AAC9C,QAAKA,SAAU,sBAAsB,QAAQ;;CAG/C,MAAM,aAA4B;AAChC,QAAM,KAAK,iBAAiB;;;CAI9B,kBAA6C;AAC3C,MAAI,MAAKC,SAAW,QAAO,MAAKA;AAChC,MACE,MAAKC,YACL,CAAC,MAAKC,WACN,MAAKC,kBAAmB,UACxB,KAAK,KAAK,GAAG,MAAKA,gBAAiB,MAAKJ,OAAQ,kBAEhD,QAAO,QAAQ,QAAQ,MAAKE,SAAU;AAIxC,QAAKD,WAAY,QAAQ,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,EAAE,WAAW,GAAG,EAAE;GACnC,CAAC"}
1
+ {"version":3,"file":"registry.mjs","names":["SkillDeliveryError","#config","#inFlight","#snapshot","#blocked","#lastCheckedAt","#refresh","#lastError","#stale","#debug","#sources","#multiple","#parts"],"sources":["../../../../../src/v2/runtime/intelligence-platform/skill-registry/registry.ts"],"sourcesContent":["import type { CopilotKitIntelligence } from \"../client\";\nimport type {\n GetLearnedSkillsSnapshotRequest,\n LearnedSkillsSnapshotResult,\n} from \"../learned-skills\";\nimport { createHash } from \"node:crypto\";\nimport { resolveRegistryConfig } from \"./config\";\nimport type { SingleContainerConfig, SkillRegistryOptions } from \"./config\";\nimport { SkillDeliveryError, invalidSnapshot } from \"./errors\";\nimport type { SkillDeliveryErrorCode } from \"./errors\";\nimport { validateSnapshot } from \"./snapshot\";\nimport type { VerifiedSnapshot } from \"./snapshot\";\n\nexport interface SkillRegistryStatus {\n /** Present only for the explicit containers interface. */\n readonly containers?: readonly (SkillRegistryStatus & {\n readonly id: string;\n })[];\n readonly initialized: boolean;\n readonly revision?: string;\n readonly mode: \"latest\" | \"pinned\";\n /** ISO 8601 timestamp of the last successful 200 or matching 304 check. */\n readonly lastCheckedAt?: string;\n readonly stale: boolean;\n readonly lastError?: Readonly<{\n code: SkillDeliveryErrorCode;\n message: string;\n retryable: boolean;\n }>;\n}\n\nfunction transient(error: SkillDeliveryError): boolean {\n return [\n \"NETWORK_ERROR\",\n \"TIMEOUT\",\n \"INVALID_SNAPSHOT\",\n \"UNSUPPORTED_SERVER\",\n ].includes(error.code);\n}\nfunction deliveryError(error: unknown): SkillDeliveryError {\n if (error instanceof SkillDeliveryError) return error;\n return new SkillDeliveryError(\n error instanceof Error && error.name === \"TimeoutError\"\n ? \"TIMEOUT\"\n : \"NETWORK_ERROR\",\n true,\n error,\n );\n}\n\n/** Internal registry shared by framework adapters; public API is framework-native. */\nclass SingleContainerRegistry {\n readonly #config: SingleContainerConfig;\n #snapshot?: VerifiedSnapshot;\n #inFlight?: Promise<VerifiedSnapshot>;\n #lastCheckedAt?: number;\n #stale = false;\n #lastError?: SkillDeliveryError;\n #blocked?: SkillDeliveryError;\n\n constructor(\n config: SingleContainerConfig,\n private readonly fetchSnapshot = (\n request: GetLearnedSkillsSnapshotRequest,\n ) => config.client.getLearnedSkillsSnapshot(request),\n ) {\n this.#config = config;\n }\n\n async initialize(): Promise<void> {\n await this.acquireSnapshot();\n }\n\n /** Capture exactly one immutable snapshot before model work begins. */\n acquireSnapshot(): Promise<VerifiedSnapshot> {\n if (this.#inFlight) return this.#inFlight;\n if (\n this.#snapshot &&\n !this.#blocked &&\n this.#lastCheckedAt !== undefined &&\n Date.now() - this.#lastCheckedAt < this.#config.freshnessWindowMs\n ) {\n return Promise.resolve(this.#snapshot);\n }\n // Defer work one microtask so reentrant and concurrent callers observe the\n // same promise before an injected client can start its request.\n this.#inFlight = Promise.resolve()\n .then(() => this.#refresh())\n .finally(() => {\n this.#inFlight = undefined;\n });\n return this.#inFlight;\n }\n\n get status(): SkillRegistryStatus {\n const error = this.#lastError;\n return Object.freeze({\n initialized: this.#snapshot !== undefined,\n ...(this.#snapshot ? { revision: this.#snapshot.revision } : {}),\n mode: this.#config.revision === undefined ? \"latest\" : \"pinned\",\n ...(this.#lastCheckedAt !== undefined\n ? { lastCheckedAt: new Date(this.#lastCheckedAt).toISOString() }\n : {}),\n stale: this.#stale,\n ...(error\n ? {\n lastError: Object.freeze({\n code: error.code,\n message: error.message,\n retryable: error.retryable,\n }),\n }\n : {}),\n });\n }\n\n async #refresh(): Promise<VerifiedSnapshot> {\n const startedAt = Date.now();\n const controller = new AbortController();\n let timer: ReturnType<typeof setTimeout> | undefined;\n const deadline = new Promise<never>((_, reject) => {\n timer = setTimeout(() => {\n const error = new SkillDeliveryError(\"TIMEOUT\", true);\n controller.abort(error);\n // Give a canonical client that already received denial headers one\n // event-loop turn to report that denial before the watchdog wins.\n timer = setTimeout(() => reject(error), 0);\n }, this.#config.requestTimeoutMs);\n });\n const replacement = async (): Promise<VerifiedSnapshot> => {\n const response = await this.fetchSnapshot({\n containerId: this.#config.containerId,\n ...(this.#config.revision !== undefined\n ? { revision: this.#config.revision }\n : {}),\n ...(this.#snapshot ? { ifNoneMatch: this.#snapshot.etag } : {}),\n signal: controller.signal,\n });\n controller.signal.throwIfAborted();\n if (!response || typeof response !== \"object\") throw invalidSnapshot();\n if (response.status === \"unchanged\") {\n if (\n !this.#snapshot ||\n response.etag !== this.#snapshot.etag ||\n response.revision !== this.#snapshot.revision\n )\n throw invalidSnapshot();\n return this.#snapshot;\n }\n if (\n this.#config.revision !== undefined &&\n response.revision !== this.#config.revision\n )\n throw invalidSnapshot();\n return validateSnapshot(response, controller.signal);\n };\n try {\n const snapshot = await Promise.race([replacement(), deadline]);\n // An abandoned parse never writes registry state: only the winning\n // complete replacement reaches this assignment.\n this.#snapshot = snapshot;\n this.#lastCheckedAt = Date.now();\n this.#stale = false;\n this.#lastError = undefined;\n this.#blocked = undefined;\n this.#debug(\"refresh-success\", startedAt);\n return snapshot;\n } catch (cause) {\n const error = deliveryError(cause);\n if (!transient(error)) {\n this.#blocked = error;\n this.#stale = false;\n this.#lastError = error;\n this.#debug(\"refresh-denied\", startedAt, error.code);\n throw error;\n }\n // A later unreachable server cannot undo an already confirmed denial.\n if (this.#blocked) {\n this.#lastError = this.#blocked;\n this.#debug(\"refresh-failed\", startedAt, error.code);\n throw this.#blocked;\n }\n this.#lastError = error;\n this.#stale = this.#snapshot !== undefined;\n this.#debug(\"refresh-failed\", startedAt, error.code);\n if (this.#snapshot) return this.#snapshot;\n throw error;\n } finally {\n if (timer !== undefined) clearTimeout(timer);\n }\n }\n\n #debug(\n event: string,\n startedAt: number,\n errorCode?: SkillDeliveryErrorCode,\n ): void {\n if (!this.#config.debug) return;\n console.debug(\"CopilotKit learned skills\", {\n event,\n containerId: this.#config.containerId,\n revision: this.#snapshot?.revision,\n durationMs: Date.now() - startedAt,\n ...(errorCode ? { errorCode } : {}),\n });\n }\n}\n\n/** Coalesce refreshes from this registry into one request in the next microtask. */\nfunction batchLoader(client: CopilotKitIntelligence) {\n let pending: {\n request: GetLearnedSkillsSnapshotRequest;\n resolve: (value: LearnedSkillsSnapshotResult) => void;\n reject: (error: unknown) => void;\n }[] = [];\n return (\n request: GetLearnedSkillsSnapshotRequest,\n ): Promise<LearnedSkillsSnapshotResult> =>\n new Promise((resolve, reject) => {\n pending.push({ request, resolve, reject });\n if (pending.length !== 1) return;\n queueMicrotask(async () => {\n const batch = pending;\n pending = [];\n try {\n const results = await client.getLearnedSkillsSnapshots({\n containers: batch.map(\n ({ request: { signal: _signal, ...source } }) => source,\n ),\n signal: batch[0].request.signal,\n });\n if (\n !Array.isArray(results) ||\n results.length !== batch.length ||\n results.some(\n (result, index) =>\n result?.containerId !== batch[index].request.containerId,\n )\n )\n throw invalidSnapshot();\n for (let index = 0; index < batch.length; index++) {\n const result = results[index];\n if (result.status === \"error\") batch[index].reject(result.error);\n else batch[index].resolve(result);\n }\n } catch (error) {\n for (const item of batch) item.reject(error);\n }\n });\n });\n}\n\n/** Compose independent container caches into one immutable invocation snapshot. */\nexport class SkillRegistry {\n readonly #sources: readonly {\n readonly id: string;\n readonly registry: SingleContainerRegistry;\n }[];\n readonly #multiple: boolean;\n #snapshot?: VerifiedSnapshot;\n #parts?: readonly VerifiedSnapshot[];\n #inFlight?: Promise<VerifiedSnapshot>;\n\n constructor(options: SkillRegistryOptions = {}) {\n const config = resolveRegistryConfig(options);\n this.#multiple = config.containers !== undefined;\n const fetchBatch = batchLoader(config.client);\n this.#sources =\n config.containers !== undefined\n ? config.containers.map(({ id, revision }) => ({\n id,\n registry: new SingleContainerRegistry(\n Object.freeze({\n client: config.client,\n freshnessWindowMs: config.freshnessWindowMs,\n requestTimeoutMs: config.requestTimeoutMs,\n debug: config.debug,\n containerId: id,\n ...(revision !== undefined ? { revision } : {}),\n }),\n fetchBatch,\n ),\n }))\n : [\n {\n id: config.containerId!,\n registry: new SingleContainerRegistry({\n client: config.client,\n containerId: config.containerId!,\n revision: config.revision,\n freshnessWindowMs: config.freshnessWindowMs,\n requestTimeoutMs: config.requestTimeoutMs,\n debug: config.debug,\n }),\n },\n ];\n }\n\n /** Load every configured container before agent initialization completes. */\n async initialize(): Promise<void> {\n await this.acquireSnapshot();\n }\n\n /** Capture every container once; a failed source cannot yield a partial catalog. */\n acquireSnapshot(): Promise<VerifiedSnapshot> {\n if (!this.#multiple) return this.#sources[0].registry.acquireSnapshot();\n if (this.#inFlight) return this.#inFlight;\n this.#inFlight = Promise.all(\n this.#sources.map(({ registry }) => registry.acquireSnapshot()),\n )\n .then((parts) => {\n if (\n this.#snapshot &&\n parts.every((part, index) => part === this.#parts?.[index])\n ) {\n return this.#snapshot;\n }\n const identity = createHash(\"sha256\")\n .update(\n JSON.stringify(\n parts.map((part, index) => [\n this.#sources[index].id,\n part.revision,\n part.etag,\n ]),\n ),\n )\n .digest(\"hex\");\n const skills = Object.freeze(\n parts.flatMap((part, index) =>\n part.skills.map((skill) =>\n Object.freeze({\n ...skill,\n name: `${encodeURIComponent(this.#sources[index].id)}/${skill.name}`,\n }),\n ),\n ),\n );\n this.#parts = parts;\n this.#snapshot = Object.freeze({\n revision: `multi:${identity}`,\n etag: `\"${identity}\"`,\n skills,\n });\n return this.#snapshot;\n })\n .finally(() => {\n this.#inFlight = undefined;\n });\n return this.#inFlight;\n }\n\n /** Report each container's real revision; no aggregate server revision exists. */\n get status(): SkillRegistryStatus {\n if (!this.#multiple) return this.#sources[0].registry.status;\n const containers = Object.freeze(\n this.#sources.map(({ id, registry }) =>\n Object.freeze({ id, ...registry.status }),\n ),\n );\n const error =\n containers.find(\n (source) => source.lastError && !source.lastError.retryable,\n )?.lastError ?? containers.find((source) => source.lastError)?.lastError;\n const timestamps = containers.map((source) => source.lastCheckedAt);\n return Object.freeze({\n initialized: this.#snapshot !== undefined,\n mode: containers.every((source) => source.mode === \"pinned\")\n ? \"pinned\"\n : \"latest\",\n stale: containers.some((source) => source.stale),\n ...(timestamps.every((timestamp) => timestamp !== undefined)\n ? { lastCheckedAt: [...timestamps].sort()[0] }\n : {}),\n ...(error ? { lastError: error } : {}),\n containers,\n });\n }\n}\n"],"mappings":";;;;;;;;AA+BA,SAAS,UAAU,OAAoC;AACrD,QAAO;EACL;EACA;EACA;EACA;EACD,CAAC,SAAS,MAAM,KAAK;;AAExB,SAAS,cAAc,OAAoC;AACzD,KAAI,iBAAiBA,mBAAoB,QAAO;AAChD,QAAO,IAAIA,mBACT,iBAAiB,SAAS,MAAM,SAAS,iBACrC,YACA,iBACJ,MACA,MACD;;;AAIH,IAAM,0BAAN,MAA8B;CAC5B,CAASC;CACT;CACA;CACA;CACA,SAAS;CACT;CACA;CAEA,YACE,QACA,AAAiB,iBACf,YACG,OAAO,OAAO,yBAAyB,QAAQ,EACpD;EAHiB;AAIjB,QAAKA,SAAU;;CAGjB,MAAM,aAA4B;AAChC,QAAM,KAAK,iBAAiB;;;CAI9B,kBAA6C;AAC3C,MAAI,MAAKC,SAAW,QAAO,MAAKA;AAChC,MACE,MAAKC,YACL,CAAC,MAAKC,WACN,MAAKC,kBAAmB,UACxB,KAAK,KAAK,GAAG,MAAKA,gBAAiB,MAAKJ,OAAQ,kBAEhD,QAAO,QAAQ,QAAQ,MAAKE,SAAU;AAIxC,QAAKD,WAAY,QAAQ,SAAS,CAC/B,WAAW,MAAKI,SAAU,CAAC,CAC3B,cAAc;AACb,SAAKJ,WAAY;IACjB;AACJ,SAAO,MAAKA;;CAGd,IAAI,SAA8B;EAChC,MAAM,QAAQ,MAAKK;AACnB,SAAO,OAAO,OAAO;GACnB,aAAa,MAAKJ,aAAc;GAChC,GAAI,MAAKA,WAAY,EAAE,UAAU,MAAKA,SAAU,UAAU,GAAG,EAAE;GAC/D,MAAM,MAAKF,OAAQ,aAAa,SAAY,WAAW;GACvD,GAAI,MAAKI,kBAAmB,SACxB,EAAE,eAAe,IAAI,KAAK,MAAKA,cAAe,CAAC,aAAa,EAAE,GAC9D,EAAE;GACN,OAAO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,SAAS,SAAS,GACxD,WACA;GACJ,OAAO,WAAW,MAAM,WAAW,OAAO,MAAM;GAChD,GAAI,WAAW,OAAO,cAAc,cAAc,OAAU,GACxD,EAAE,eAAe,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,GAC5C,EAAE;GACN,GAAI,QAAQ,EAAE,WAAW,OAAO,GAAG,EAAE;GACrC;GACD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copilotkit/runtime",
3
- "version": "1.73.3",
3
+ "version": "1.74.0",
4
4
  "private": false,
5
5
  "keywords": [
6
6
  "ai",
@@ -110,8 +110,8 @@
110
110
  "zod": "^3.23.3",
111
111
  "yauzl": "2.10.0",
112
112
  "@copilotkit/channels-core": "^0.11.0",
113
- "@copilotkit/channels-intelligence": "0.11.0",
114
- "@copilotkit/shared": "1.73.3"
113
+ "@copilotkit/shared": "1.74.0",
114
+ "@copilotkit/channels-intelligence": "0.11.0"
115
115
  },
116
116
  "devDependencies": {
117
117
  "@copilotkit/aimock": "latest",
@@ -136,8 +136,8 @@
136
136
  "valibot": "^1.2.0",
137
137
  "vitest": "^3.2.4",
138
138
  "@types/yauzl": "2.10.3",
139
- "@copilotkit/channels": "0.11.0",
140
- "tsconfig": "1.4.12"
139
+ "tsconfig": "1.4.12",
140
+ "@copilotkit/channels": "0.11.0"
141
141
  },
142
142
  "peerDependencies": {
143
143
  "@anthropic-ai/sdk": ">=0.57.0",