@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
@@ -36,8 +36,61 @@ function learnedSkillsResponseError(body) {
36
36
  }
37
37
  return new LearnedSkillsError("UNSUPPORTED_SERVER", false);
38
38
  }
39
+ /** Validate the entire envelope before exposing any individual result. */
40
+ function parseLearnedSkillsBatch(body, requests) {
41
+ const invalid = () => {
42
+ if (body && typeof body === "object" && "containers" in body && Array.isArray(body.containers)) {
43
+ const denial = body.containers.find((entry) => entry && requests.some((request) => request.containerId === entry.containerId) && entry.status === "error" && [
44
+ "AUTHENTICATION_FAILED",
45
+ "AUTHORIZATION_FAILED",
46
+ "ENTITLEMENT_REQUIRED",
47
+ "DELIVERY_DISABLED",
48
+ "CONTAINER_NOT_FOUND",
49
+ "REVISION_NOT_FOUND",
50
+ "REVISION_REVOKED"
51
+ ].includes(entry.error?.code));
52
+ if (denial) return new LearnedSkillsError(denial.error.code, false);
53
+ }
54
+ return new LearnedSkillsError("INVALID_SNAPSHOT", false);
55
+ };
56
+ if (!body || typeof body !== "object" || !("containers" in body) || !Array.isArray(body.containers) || body.containers.length !== requests.length) throw invalid();
57
+ return body.containers.map((entry, index) => {
58
+ const request = requests[index];
59
+ if (!entry || typeof entry !== "object" || entry.containerId !== request.containerId) throw invalid();
60
+ if (entry.status === "error") {
61
+ if (!entry.error || typeof entry.error !== "object" || !Object.prototype.hasOwnProperty.call(messages, entry.error.code) || typeof entry.error.retryable !== "boolean") throw invalid();
62
+ return {
63
+ containerId: entry.containerId,
64
+ status: "error",
65
+ error: new LearnedSkillsError(entry.error.code, entry.error.retryable)
66
+ };
67
+ }
68
+ if (typeof entry.revision !== "string" || !entry.revision.trim() || typeof entry.etag !== "string" || !/^"[a-f0-9]{64}"$/.test(entry.etag) || request.revision !== void 0 && entry.revision !== request.revision) throw invalid();
69
+ if (entry.status === "unchanged") {
70
+ if (request.ifNoneMatch !== entry.etag || "bytesBase64" in entry || "contentType" in entry) throw invalid();
71
+ return {
72
+ containerId: entry.containerId,
73
+ status: "unchanged",
74
+ revision: entry.revision,
75
+ etag: entry.etag
76
+ };
77
+ }
78
+ if (entry.status !== "snapshot" || entry.contentType !== "application/zip" || typeof entry.bytesBase64 !== "string" || !entry.bytesBase64.length || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(entry.bytesBase64)) throw invalid();
79
+ const bytes = Buffer.from(entry.bytesBase64, "base64");
80
+ if (bytes.toString("base64") !== entry.bytesBase64) throw invalid();
81
+ return {
82
+ containerId: entry.containerId,
83
+ status: "snapshot",
84
+ revision: entry.revision,
85
+ etag: entry.etag,
86
+ contentType: entry.contentType,
87
+ bytes: new Uint8Array(bytes)
88
+ };
89
+ });
90
+ }
39
91
 
40
92
  //#endregion
41
93
  exports.LearnedSkillsError = LearnedSkillsError;
42
94
  exports.learnedSkillsResponseError = learnedSkillsResponseError;
95
+ exports.parseLearnedSkillsBatch = parseLearnedSkillsBatch;
43
96
  //# sourceMappingURL=learned-skills.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"learned-skills.cjs","names":[],"sources":["../../../../src/v2/runtime/intelligence-platform/learned-skills.ts"],"sourcesContent":["/** Stable failure codes shared by learned-skill delivery and its consumers. */\nexport type LearnedSkillsErrorCode =\n | \"INVALID_CONFIG\"\n | \"AUTHENTICATION_FAILED\"\n | \"AUTHORIZATION_FAILED\"\n | \"ENTITLEMENT_REQUIRED\"\n | \"DELIVERY_DISABLED\"\n | \"CONTAINER_NOT_FOUND\"\n | \"REVISION_NOT_FOUND\"\n | \"REVISION_REVOKED\"\n | \"NETWORK_ERROR\"\n | \"TIMEOUT\"\n | \"INVALID_SNAPSHOT\"\n | \"UNSUPPORTED_SERVER\";\n\nconst messages: Record<LearnedSkillsErrorCode, string> = {\n INVALID_CONFIG: \"Invalid learned-skills request configuration.\",\n AUTHENTICATION_FAILED: \"Learned-skills authentication failed.\",\n AUTHORIZATION_FAILED: \"Learned-skills access was denied.\",\n ENTITLEMENT_REQUIRED: \"Learned-skills delivery requires an entitlement.\",\n DELIVERY_DISABLED: \"Learned-skills delivery is disabled.\",\n CONTAINER_NOT_FOUND: \"The learning container was not found.\",\n REVISION_NOT_FOUND: \"The learned-skills revision was not found.\",\n REVISION_REVOKED: \"The learned-skills revision was revoked.\",\n NETWORK_ERROR: \"The learned-skills request failed during transport.\",\n TIMEOUT: \"The learned-skills request timed out.\",\n INVALID_SNAPSHOT: \"The learned-skills response metadata is invalid.\",\n UNSUPPORTED_SERVER:\n \"The server returned an unsupported learned-skills response.\",\n};\n\n/** Safe message and stable code; server response bodies are never retained. */\nexport class LearnedSkillsError extends Error {\n readonly cause?: unknown;\n\n constructor(\n public readonly code: LearnedSkillsErrorCode,\n public readonly retryable: boolean,\n cause?: unknown,\n ) {\n super(messages[code]);\n this.name = \"LearnedSkillsError\";\n // Preserve the original exception for explicit diagnostics without including\n // it in ordinary JSON serialization of this safe error envelope.\n Object.defineProperty(this, \"cause\", { value: cause, configurable: true });\n }\n}\n\nexport interface GetLearnedSkillsSnapshotRequest {\n containerId: string;\n /** Opaque exact revision. Omit to request the latest authorized revision. */\n revision?: string;\n /** ETag from a previous snapshot. The client owns no cache. */\n ifNoneMatch?: string;\n /** Caller-owned cancellation or deadline, including AbortSignal.timeout(). */\n signal?: AbortSignal;\n}\n\nexport type LearnedSkillsSnapshotResult =\n | {\n status: \"snapshot\";\n /** Raw ZIP bytes. The client does not parse or extract the archive. */\n bytes: Uint8Array;\n revision: string;\n etag: string;\n contentType: string;\n }\n | { status: \"unchanged\"; revision: string; etag: string };\n\n/** @internal */\nexport function learnedSkillsResponseError(body: unknown): LearnedSkillsError {\n if (typeof body === \"object\" && body !== null && \"error\" in body) {\n const error = body.error;\n if (\n typeof error === \"object\" &&\n error !== null &&\n \"code\" in error &&\n typeof error.code === \"string\" &&\n Object.prototype.hasOwnProperty.call(messages, error.code) &&\n \"message\" in error &&\n typeof error.message === \"string\" &&\n \"category\" in error &&\n typeof error.category === \"string\" &&\n \"retryable\" in error &&\n typeof error.retryable === \"boolean\"\n ) {\n return new LearnedSkillsError(\n error.code as LearnedSkillsErrorCode,\n error.retryable,\n );\n }\n }\n return new LearnedSkillsError(\"UNSUPPORTED_SERVER\", false);\n}\n"],"mappings":";;;AAeA,MAAM,WAAmD;CACvD,gBAAgB;CAChB,uBAAuB;CACvB,sBAAsB;CACtB,sBAAsB;CACtB,mBAAmB;CACnB,qBAAqB;CACrB,oBAAoB;CACpB,kBAAkB;CAClB,eAAe;CACf,SAAS;CACT,kBAAkB;CAClB,oBACE;CACH;;AAGD,IAAa,qBAAb,cAAwC,MAAM;CAG5C,YACE,AAAgB,MAChB,AAAgB,WAChB,OACA;AACA,QAAM,SAAS,MAAM;EAJL;EACA;AAIhB,OAAK,OAAO;AAGZ,SAAO,eAAe,MAAM,SAAS;GAAE,OAAO;GAAO,cAAc;GAAM,CAAC;;;;AA0B9E,SAAgB,2BAA2B,MAAmC;AAC5E,KAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,WAAW,MAAM;EAChE,MAAM,QAAQ,KAAK;AACnB,MACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,OAAO,MAAM,SAAS,YACtB,OAAO,UAAU,eAAe,KAAK,UAAU,MAAM,KAAK,IAC1D,aAAa,SACb,OAAO,MAAM,YAAY,YACzB,cAAc,SACd,OAAO,MAAM,aAAa,YAC1B,eAAe,SACf,OAAO,MAAM,cAAc,UAE3B,QAAO,IAAI,mBACT,MAAM,MACN,MAAM,UACP;;AAGL,QAAO,IAAI,mBAAmB,sBAAsB,MAAM"}
1
+ {"version":3,"file":"learned-skills.cjs","names":[],"sources":["../../../../src/v2/runtime/intelligence-platform/learned-skills.ts"],"sourcesContent":["/** Stable failure codes shared by learned-skill delivery and its consumers. */\nexport type LearnedSkillsErrorCode =\n | \"INVALID_CONFIG\"\n | \"AUTHENTICATION_FAILED\"\n | \"AUTHORIZATION_FAILED\"\n | \"ENTITLEMENT_REQUIRED\"\n | \"DELIVERY_DISABLED\"\n | \"CONTAINER_NOT_FOUND\"\n | \"REVISION_NOT_FOUND\"\n | \"REVISION_REVOKED\"\n | \"NETWORK_ERROR\"\n | \"TIMEOUT\"\n | \"INVALID_SNAPSHOT\"\n | \"UNSUPPORTED_SERVER\";\n\nconst messages: Record<LearnedSkillsErrorCode, string> = {\n INVALID_CONFIG: \"Invalid learned-skills request configuration.\",\n AUTHENTICATION_FAILED: \"Learned-skills authentication failed.\",\n AUTHORIZATION_FAILED: \"Learned-skills access was denied.\",\n ENTITLEMENT_REQUIRED: \"Learned-skills delivery requires an entitlement.\",\n DELIVERY_DISABLED: \"Learned-skills delivery is disabled.\",\n CONTAINER_NOT_FOUND: \"The learning container was not found.\",\n REVISION_NOT_FOUND: \"The learned-skills revision was not found.\",\n REVISION_REVOKED: \"The learned-skills revision was revoked.\",\n NETWORK_ERROR: \"The learned-skills request failed during transport.\",\n TIMEOUT: \"The learned-skills request timed out.\",\n INVALID_SNAPSHOT: \"The learned-skills response metadata is invalid.\",\n UNSUPPORTED_SERVER:\n \"The server returned an unsupported learned-skills response.\",\n};\n\n/** Safe message and stable code; server response bodies are never retained. */\nexport class LearnedSkillsError extends Error {\n readonly cause?: unknown;\n\n constructor(\n public readonly code: LearnedSkillsErrorCode,\n public readonly retryable: boolean,\n cause?: unknown,\n ) {\n super(messages[code]);\n this.name = \"LearnedSkillsError\";\n // Preserve the original exception for explicit diagnostics without including\n // it in ordinary JSON serialization of this safe error envelope.\n Object.defineProperty(this, \"cause\", { value: cause, configurable: true });\n }\n}\n\nexport interface GetLearnedSkillsSnapshotRequest {\n containerId: string;\n /** Opaque exact revision. Omit to request the latest authorized revision. */\n revision?: string;\n /** ETag from a previous snapshot. The client owns no cache. */\n ifNoneMatch?: string;\n /** Caller-owned cancellation or deadline, including AbortSignal.timeout(). */\n signal?: AbortSignal;\n}\n\nexport type LearnedSkillsSnapshotResult =\n | {\n status: \"snapshot\";\n /** Raw ZIP bytes. The client does not parse or extract the archive. */\n bytes: Uint8Array;\n revision: string;\n etag: string;\n contentType: string;\n }\n | { status: \"unchanged\"; revision: string; etag: string };\n\n/** @internal */\nexport function learnedSkillsResponseError(body: unknown): LearnedSkillsError {\n if (typeof body === \"object\" && body !== null && \"error\" in body) {\n const error = body.error;\n if (\n typeof error === \"object\" &&\n error !== null &&\n \"code\" in error &&\n typeof error.code === \"string\" &&\n Object.prototype.hasOwnProperty.call(messages, error.code) &&\n \"message\" in error &&\n typeof error.message === \"string\" &&\n \"category\" in error &&\n typeof error.category === \"string\" &&\n \"retryable\" in error &&\n typeof error.retryable === \"boolean\"\n ) {\n return new LearnedSkillsError(\n error.code as LearnedSkillsErrorCode,\n error.retryable,\n );\n }\n }\n return new LearnedSkillsError(\"UNSUPPORTED_SERVER\", false);\n}\n\nexport interface GetLearnedSkillsSnapshotsRequest {\n containers: readonly Omit<GetLearnedSkillsSnapshotRequest, \"signal\">[];\n signal?: AbortSignal;\n}\nexport type LearnedSkillsBatchResult = { containerId: string } & (\n | LearnedSkillsSnapshotResult\n | { status: \"error\"; error: LearnedSkillsError }\n);\n\n/** Validate the entire envelope before exposing any individual result. */\nexport function parseLearnedSkillsBatch(\n body: unknown,\n requests: GetLearnedSkillsSnapshotsRequest[\"containers\"],\n): LearnedSkillsBatchResult[] {\n const invalid = () => {\n if (\n body &&\n typeof body === \"object\" &&\n \"containers\" in body &&\n Array.isArray(body.containers)\n ) {\n const denial = body.containers.find(\n (entry) =>\n entry &&\n requests.some(\n (request) => request.containerId === entry.containerId,\n ) &&\n entry.status === \"error\" &&\n [\n \"AUTHENTICATION_FAILED\",\n \"AUTHORIZATION_FAILED\",\n \"ENTITLEMENT_REQUIRED\",\n \"DELIVERY_DISABLED\",\n \"CONTAINER_NOT_FOUND\",\n \"REVISION_NOT_FOUND\",\n \"REVISION_REVOKED\",\n ].includes(entry.error?.code),\n );\n if (denial) return new LearnedSkillsError(denial.error.code, false);\n }\n return new LearnedSkillsError(\"INVALID_SNAPSHOT\", false);\n };\n if (\n !body ||\n typeof body !== \"object\" ||\n !(\"containers\" in body) ||\n !Array.isArray(body.containers) ||\n body.containers.length !== requests.length\n )\n throw invalid();\n return body.containers.map((entry, index) => {\n const request = requests[index];\n if (\n !entry ||\n typeof entry !== \"object\" ||\n entry.containerId !== request.containerId\n )\n throw invalid();\n if (entry.status === \"error\") {\n if (\n !entry.error ||\n typeof entry.error !== \"object\" ||\n !Object.prototype.hasOwnProperty.call(messages, entry.error.code) ||\n typeof entry.error.retryable !== \"boolean\"\n )\n throw invalid();\n return {\n containerId: entry.containerId,\n status: \"error\",\n error: new LearnedSkillsError(entry.error.code, entry.error.retryable),\n };\n }\n if (\n typeof entry.revision !== \"string\" ||\n !entry.revision.trim() ||\n typeof entry.etag !== \"string\" ||\n !/^\"[a-f0-9]{64}\"$/.test(entry.etag) ||\n (request.revision !== undefined && entry.revision !== request.revision)\n )\n throw invalid();\n if (entry.status === \"unchanged\") {\n if (\n request.ifNoneMatch !== entry.etag ||\n \"bytesBase64\" in entry ||\n \"contentType\" in entry\n )\n throw invalid();\n return {\n containerId: entry.containerId,\n status: \"unchanged\",\n revision: entry.revision,\n etag: entry.etag,\n };\n }\n if (\n entry.status !== \"snapshot\" ||\n entry.contentType !== \"application/zip\" ||\n typeof entry.bytesBase64 !== \"string\" ||\n !entry.bytesBase64.length ||\n !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(\n entry.bytesBase64,\n )\n )\n throw invalid();\n const bytes = Buffer.from(entry.bytesBase64, \"base64\");\n if (bytes.toString(\"base64\") !== entry.bytesBase64) throw invalid();\n return {\n containerId: entry.containerId,\n status: \"snapshot\",\n revision: entry.revision,\n etag: entry.etag,\n contentType: entry.contentType,\n bytes: new Uint8Array(bytes),\n };\n });\n}\n"],"mappings":"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"}
@@ -29,6 +29,16 @@ type LearnedSkillsSnapshotResult = {
29
29
  revision: string;
30
30
  etag: string;
31
31
  };
32
+ interface GetLearnedSkillsSnapshotsRequest {
33
+ containers: readonly Omit<GetLearnedSkillsSnapshotRequest, "signal">[];
34
+ signal?: AbortSignal;
35
+ }
36
+ type LearnedSkillsBatchResult = {
37
+ containerId: string;
38
+ } & (LearnedSkillsSnapshotResult | {
39
+ status: "error";
40
+ error: LearnedSkillsError;
41
+ });
32
42
  //#endregion
33
- export { GetLearnedSkillsSnapshotRequest, LearnedSkillsError, LearnedSkillsErrorCode, LearnedSkillsSnapshotResult };
43
+ export { GetLearnedSkillsSnapshotRequest, GetLearnedSkillsSnapshotsRequest, LearnedSkillsBatchResult, LearnedSkillsError, LearnedSkillsErrorCode, LearnedSkillsSnapshotResult };
34
44
  //# sourceMappingURL=learned-skills.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"learned-skills.d.cts","names":[],"sources":["../../../../src/v2/runtime/intelligence-platform/learned-skills.ts"],"mappings":";;;KACY,sBAAA;;cA+BC,kBAAA,SAA2B,KAAA;EAAA,SAIpB,IAAA,EAAM,sBAAA;EAAA,SACN,SAAA;EAAA,SAJT,KAAA;cAGS,IAAA,EAAM,sBAAA,EACN,SAAA,WAChB,KAAA;AAAA;AAAA,UAUa,+BAAA;EACf,WAAA;EAjBsC;EAmBtC,QAAA;EAnB2C;EAqB3C,WAAA;EAjBkB;EAmBlB,MAAA,GAAS,WAAA;AAAA;AAAA,KAGC,2BAAA;EAEN,MAAA,cAxBoB;EA0BpB,KAAA,EAAO,UAAA;EACP,QAAA;EACA,IAAA;EACA,WAAA;AAAA;EAEA,MAAA;EAAqB,QAAA;EAAkB,IAAA;AAAA"}
1
+ {"version":3,"file":"learned-skills.d.cts","names":[],"sources":["../../../../src/v2/runtime/intelligence-platform/learned-skills.ts"],"mappings":";;;KACY,sBAAA;;cA+BC,kBAAA,SAA2B,KAAA;EAAA,SAIpB,IAAA,EAAM,sBAAA;EAAA,SACN,SAAA;EAAA,SAJT,KAAA;cAGS,IAAA,EAAM,sBAAA,EACN,SAAA,WAChB,KAAA;AAAA;AAAA,UAUa,+BAAA;EACf,WAAA;EAjBsC;EAmBtC,QAAA;EAnB2C;EAqB3C,WAAA;EAjBkB;EAmBlB,MAAA,GAAS,WAAA;AAAA;AAAA,KAGC,2BAAA;EAEN,MAAA,cAxBoB;EA0BpB,KAAA,EAAO,UAAA;EACP,QAAA;EACA,IAAA;EACA,WAAA;AAAA;EAEA,MAAA;EAAqB,QAAA;EAAkB,IAAA;AAAA;AAAA,UA4B5B,gCAAA;EACf,UAAA,WAAqB,IAAA,CAAK,+BAAA;EAC1B,MAAA,GAAS,WAAA;AAAA;AAAA,KAEC,wBAAA;EAA6B,WAAA;AAAA,KACrC,2BAAA;EACE,MAAA;EAAiB,KAAA,EAAO,kBAAA;AAAA"}
@@ -29,6 +29,16 @@ type LearnedSkillsSnapshotResult = {
29
29
  revision: string;
30
30
  etag: string;
31
31
  };
32
+ interface GetLearnedSkillsSnapshotsRequest {
33
+ containers: readonly Omit<GetLearnedSkillsSnapshotRequest, "signal">[];
34
+ signal?: AbortSignal;
35
+ }
36
+ type LearnedSkillsBatchResult = {
37
+ containerId: string;
38
+ } & (LearnedSkillsSnapshotResult | {
39
+ status: "error";
40
+ error: LearnedSkillsError;
41
+ });
32
42
  //#endregion
33
- export { GetLearnedSkillsSnapshotRequest, LearnedSkillsError, LearnedSkillsErrorCode, LearnedSkillsSnapshotResult };
43
+ export { GetLearnedSkillsSnapshotRequest, GetLearnedSkillsSnapshotsRequest, LearnedSkillsBatchResult, LearnedSkillsError, LearnedSkillsErrorCode, LearnedSkillsSnapshotResult };
34
44
  //# sourceMappingURL=learned-skills.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"learned-skills.d.mts","names":[],"sources":["../../../../src/v2/runtime/intelligence-platform/learned-skills.ts"],"mappings":";;;KACY,sBAAA;;cA+BC,kBAAA,SAA2B,KAAA;EAAA,SAIpB,IAAA,EAAM,sBAAA;EAAA,SACN,SAAA;EAAA,SAJT,KAAA;cAGS,IAAA,EAAM,sBAAA,EACN,SAAA,WAChB,KAAA;AAAA;AAAA,UAUa,+BAAA;EACf,WAAA;EAjBsC;EAmBtC,QAAA;EAnB2C;EAqB3C,WAAA;EAjBkB;EAmBlB,MAAA,GAAS,WAAA;AAAA;AAAA,KAGC,2BAAA;EAEN,MAAA,cAxBoB;EA0BpB,KAAA,EAAO,UAAA;EACP,QAAA;EACA,IAAA;EACA,WAAA;AAAA;EAEA,MAAA;EAAqB,QAAA;EAAkB,IAAA;AAAA"}
1
+ {"version":3,"file":"learned-skills.d.mts","names":[],"sources":["../../../../src/v2/runtime/intelligence-platform/learned-skills.ts"],"mappings":";;;KACY,sBAAA;;cA+BC,kBAAA,SAA2B,KAAA;EAAA,SAIpB,IAAA,EAAM,sBAAA;EAAA,SACN,SAAA;EAAA,SAJT,KAAA;cAGS,IAAA,EAAM,sBAAA,EACN,SAAA,WAChB,KAAA;AAAA;AAAA,UAUa,+BAAA;EACf,WAAA;EAjBsC;EAmBtC,QAAA;EAnB2C;EAqB3C,WAAA;EAjBkB;EAmBlB,MAAA,GAAS,WAAA;AAAA;AAAA,KAGC,2BAAA;EAEN,MAAA,cAxBoB;EA0BpB,KAAA,EAAO,UAAA;EACP,QAAA;EACA,IAAA;EACA,WAAA;AAAA;EAEA,MAAA;EAAqB,QAAA;EAAkB,IAAA;AAAA;AAAA,UA4B5B,gCAAA;EACf,UAAA,WAAqB,IAAA,CAAK,+BAAA;EAC1B,MAAA,GAAS,WAAA;AAAA;AAAA,KAEC,wBAAA;EAA6B,WAAA;AAAA,KACrC,2BAAA;EACE,MAAA;EAAiB,KAAA,EAAO,kBAAA;AAAA"}
@@ -35,7 +35,59 @@ function learnedSkillsResponseError(body) {
35
35
  }
36
36
  return new LearnedSkillsError("UNSUPPORTED_SERVER", false);
37
37
  }
38
+ /** Validate the entire envelope before exposing any individual result. */
39
+ function parseLearnedSkillsBatch(body, requests) {
40
+ const invalid = () => {
41
+ if (body && typeof body === "object" && "containers" in body && Array.isArray(body.containers)) {
42
+ const denial = body.containers.find((entry) => entry && requests.some((request) => request.containerId === entry.containerId) && entry.status === "error" && [
43
+ "AUTHENTICATION_FAILED",
44
+ "AUTHORIZATION_FAILED",
45
+ "ENTITLEMENT_REQUIRED",
46
+ "DELIVERY_DISABLED",
47
+ "CONTAINER_NOT_FOUND",
48
+ "REVISION_NOT_FOUND",
49
+ "REVISION_REVOKED"
50
+ ].includes(entry.error?.code));
51
+ if (denial) return new LearnedSkillsError(denial.error.code, false);
52
+ }
53
+ return new LearnedSkillsError("INVALID_SNAPSHOT", false);
54
+ };
55
+ if (!body || typeof body !== "object" || !("containers" in body) || !Array.isArray(body.containers) || body.containers.length !== requests.length) throw invalid();
56
+ return body.containers.map((entry, index) => {
57
+ const request = requests[index];
58
+ if (!entry || typeof entry !== "object" || entry.containerId !== request.containerId) throw invalid();
59
+ if (entry.status === "error") {
60
+ if (!entry.error || typeof entry.error !== "object" || !Object.prototype.hasOwnProperty.call(messages, entry.error.code) || typeof entry.error.retryable !== "boolean") throw invalid();
61
+ return {
62
+ containerId: entry.containerId,
63
+ status: "error",
64
+ error: new LearnedSkillsError(entry.error.code, entry.error.retryable)
65
+ };
66
+ }
67
+ if (typeof entry.revision !== "string" || !entry.revision.trim() || typeof entry.etag !== "string" || !/^"[a-f0-9]{64}"$/.test(entry.etag) || request.revision !== void 0 && entry.revision !== request.revision) throw invalid();
68
+ if (entry.status === "unchanged") {
69
+ if (request.ifNoneMatch !== entry.etag || "bytesBase64" in entry || "contentType" in entry) throw invalid();
70
+ return {
71
+ containerId: entry.containerId,
72
+ status: "unchanged",
73
+ revision: entry.revision,
74
+ etag: entry.etag
75
+ };
76
+ }
77
+ if (entry.status !== "snapshot" || entry.contentType !== "application/zip" || typeof entry.bytesBase64 !== "string" || !entry.bytesBase64.length || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(entry.bytesBase64)) throw invalid();
78
+ const bytes = Buffer.from(entry.bytesBase64, "base64");
79
+ if (bytes.toString("base64") !== entry.bytesBase64) throw invalid();
80
+ return {
81
+ containerId: entry.containerId,
82
+ status: "snapshot",
83
+ revision: entry.revision,
84
+ etag: entry.etag,
85
+ contentType: entry.contentType,
86
+ bytes: new Uint8Array(bytes)
87
+ };
88
+ });
89
+ }
38
90
 
39
91
  //#endregion
40
- export { LearnedSkillsError, learnedSkillsResponseError };
92
+ export { LearnedSkillsError, learnedSkillsResponseError, parseLearnedSkillsBatch };
41
93
  //# sourceMappingURL=learned-skills.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"learned-skills.mjs","names":[],"sources":["../../../../src/v2/runtime/intelligence-platform/learned-skills.ts"],"sourcesContent":["/** Stable failure codes shared by learned-skill delivery and its consumers. */\nexport type LearnedSkillsErrorCode =\n | \"INVALID_CONFIG\"\n | \"AUTHENTICATION_FAILED\"\n | \"AUTHORIZATION_FAILED\"\n | \"ENTITLEMENT_REQUIRED\"\n | \"DELIVERY_DISABLED\"\n | \"CONTAINER_NOT_FOUND\"\n | \"REVISION_NOT_FOUND\"\n | \"REVISION_REVOKED\"\n | \"NETWORK_ERROR\"\n | \"TIMEOUT\"\n | \"INVALID_SNAPSHOT\"\n | \"UNSUPPORTED_SERVER\";\n\nconst messages: Record<LearnedSkillsErrorCode, string> = {\n INVALID_CONFIG: \"Invalid learned-skills request configuration.\",\n AUTHENTICATION_FAILED: \"Learned-skills authentication failed.\",\n AUTHORIZATION_FAILED: \"Learned-skills access was denied.\",\n ENTITLEMENT_REQUIRED: \"Learned-skills delivery requires an entitlement.\",\n DELIVERY_DISABLED: \"Learned-skills delivery is disabled.\",\n CONTAINER_NOT_FOUND: \"The learning container was not found.\",\n REVISION_NOT_FOUND: \"The learned-skills revision was not found.\",\n REVISION_REVOKED: \"The learned-skills revision was revoked.\",\n NETWORK_ERROR: \"The learned-skills request failed during transport.\",\n TIMEOUT: \"The learned-skills request timed out.\",\n INVALID_SNAPSHOT: \"The learned-skills response metadata is invalid.\",\n UNSUPPORTED_SERVER:\n \"The server returned an unsupported learned-skills response.\",\n};\n\n/** Safe message and stable code; server response bodies are never retained. */\nexport class LearnedSkillsError extends Error {\n readonly cause?: unknown;\n\n constructor(\n public readonly code: LearnedSkillsErrorCode,\n public readonly retryable: boolean,\n cause?: unknown,\n ) {\n super(messages[code]);\n this.name = \"LearnedSkillsError\";\n // Preserve the original exception for explicit diagnostics without including\n // it in ordinary JSON serialization of this safe error envelope.\n Object.defineProperty(this, \"cause\", { value: cause, configurable: true });\n }\n}\n\nexport interface GetLearnedSkillsSnapshotRequest {\n containerId: string;\n /** Opaque exact revision. Omit to request the latest authorized revision. */\n revision?: string;\n /** ETag from a previous snapshot. The client owns no cache. */\n ifNoneMatch?: string;\n /** Caller-owned cancellation or deadline, including AbortSignal.timeout(). */\n signal?: AbortSignal;\n}\n\nexport type LearnedSkillsSnapshotResult =\n | {\n status: \"snapshot\";\n /** Raw ZIP bytes. The client does not parse or extract the archive. */\n bytes: Uint8Array;\n revision: string;\n etag: string;\n contentType: string;\n }\n | { status: \"unchanged\"; revision: string; etag: string };\n\n/** @internal */\nexport function learnedSkillsResponseError(body: unknown): LearnedSkillsError {\n if (typeof body === \"object\" && body !== null && \"error\" in body) {\n const error = body.error;\n if (\n typeof error === \"object\" &&\n error !== null &&\n \"code\" in error &&\n typeof error.code === \"string\" &&\n Object.prototype.hasOwnProperty.call(messages, error.code) &&\n \"message\" in error &&\n typeof error.message === \"string\" &&\n \"category\" in error &&\n typeof error.category === \"string\" &&\n \"retryable\" in error &&\n typeof error.retryable === \"boolean\"\n ) {\n return new LearnedSkillsError(\n error.code as LearnedSkillsErrorCode,\n error.retryable,\n );\n }\n }\n return new LearnedSkillsError(\"UNSUPPORTED_SERVER\", false);\n}\n"],"mappings":";;AAeA,MAAM,WAAmD;CACvD,gBAAgB;CAChB,uBAAuB;CACvB,sBAAsB;CACtB,sBAAsB;CACtB,mBAAmB;CACnB,qBAAqB;CACrB,oBAAoB;CACpB,kBAAkB;CAClB,eAAe;CACf,SAAS;CACT,kBAAkB;CAClB,oBACE;CACH;;AAGD,IAAa,qBAAb,cAAwC,MAAM;CAG5C,YACE,AAAgB,MAChB,AAAgB,WAChB,OACA;AACA,QAAM,SAAS,MAAM;EAJL;EACA;AAIhB,OAAK,OAAO;AAGZ,SAAO,eAAe,MAAM,SAAS;GAAE,OAAO;GAAO,cAAc;GAAM,CAAC;;;;AA0B9E,SAAgB,2BAA2B,MAAmC;AAC5E,KAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,WAAW,MAAM;EAChE,MAAM,QAAQ,KAAK;AACnB,MACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,OAAO,MAAM,SAAS,YACtB,OAAO,UAAU,eAAe,KAAK,UAAU,MAAM,KAAK,IAC1D,aAAa,SACb,OAAO,MAAM,YAAY,YACzB,cAAc,SACd,OAAO,MAAM,aAAa,YAC1B,eAAe,SACf,OAAO,MAAM,cAAc,UAE3B,QAAO,IAAI,mBACT,MAAM,MACN,MAAM,UACP;;AAGL,QAAO,IAAI,mBAAmB,sBAAsB,MAAM"}
1
+ {"version":3,"file":"learned-skills.mjs","names":[],"sources":["../../../../src/v2/runtime/intelligence-platform/learned-skills.ts"],"sourcesContent":["/** Stable failure codes shared by learned-skill delivery and its consumers. */\nexport type LearnedSkillsErrorCode =\n | \"INVALID_CONFIG\"\n | \"AUTHENTICATION_FAILED\"\n | \"AUTHORIZATION_FAILED\"\n | \"ENTITLEMENT_REQUIRED\"\n | \"DELIVERY_DISABLED\"\n | \"CONTAINER_NOT_FOUND\"\n | \"REVISION_NOT_FOUND\"\n | \"REVISION_REVOKED\"\n | \"NETWORK_ERROR\"\n | \"TIMEOUT\"\n | \"INVALID_SNAPSHOT\"\n | \"UNSUPPORTED_SERVER\";\n\nconst messages: Record<LearnedSkillsErrorCode, string> = {\n INVALID_CONFIG: \"Invalid learned-skills request configuration.\",\n AUTHENTICATION_FAILED: \"Learned-skills authentication failed.\",\n AUTHORIZATION_FAILED: \"Learned-skills access was denied.\",\n ENTITLEMENT_REQUIRED: \"Learned-skills delivery requires an entitlement.\",\n DELIVERY_DISABLED: \"Learned-skills delivery is disabled.\",\n CONTAINER_NOT_FOUND: \"The learning container was not found.\",\n REVISION_NOT_FOUND: \"The learned-skills revision was not found.\",\n REVISION_REVOKED: \"The learned-skills revision was revoked.\",\n NETWORK_ERROR: \"The learned-skills request failed during transport.\",\n TIMEOUT: \"The learned-skills request timed out.\",\n INVALID_SNAPSHOT: \"The learned-skills response metadata is invalid.\",\n UNSUPPORTED_SERVER:\n \"The server returned an unsupported learned-skills response.\",\n};\n\n/** Safe message and stable code; server response bodies are never retained. */\nexport class LearnedSkillsError extends Error {\n readonly cause?: unknown;\n\n constructor(\n public readonly code: LearnedSkillsErrorCode,\n public readonly retryable: boolean,\n cause?: unknown,\n ) {\n super(messages[code]);\n this.name = \"LearnedSkillsError\";\n // Preserve the original exception for explicit diagnostics without including\n // it in ordinary JSON serialization of this safe error envelope.\n Object.defineProperty(this, \"cause\", { value: cause, configurable: true });\n }\n}\n\nexport interface GetLearnedSkillsSnapshotRequest {\n containerId: string;\n /** Opaque exact revision. Omit to request the latest authorized revision. */\n revision?: string;\n /** ETag from a previous snapshot. The client owns no cache. */\n ifNoneMatch?: string;\n /** Caller-owned cancellation or deadline, including AbortSignal.timeout(). */\n signal?: AbortSignal;\n}\n\nexport type LearnedSkillsSnapshotResult =\n | {\n status: \"snapshot\";\n /** Raw ZIP bytes. The client does not parse or extract the archive. */\n bytes: Uint8Array;\n revision: string;\n etag: string;\n contentType: string;\n }\n | { status: \"unchanged\"; revision: string; etag: string };\n\n/** @internal */\nexport function learnedSkillsResponseError(body: unknown): LearnedSkillsError {\n if (typeof body === \"object\" && body !== null && \"error\" in body) {\n const error = body.error;\n if (\n typeof error === \"object\" &&\n error !== null &&\n \"code\" in error &&\n typeof error.code === \"string\" &&\n Object.prototype.hasOwnProperty.call(messages, error.code) &&\n \"message\" in error &&\n typeof error.message === \"string\" &&\n \"category\" in error &&\n typeof error.category === \"string\" &&\n \"retryable\" in error &&\n typeof error.retryable === \"boolean\"\n ) {\n return new LearnedSkillsError(\n error.code as LearnedSkillsErrorCode,\n error.retryable,\n );\n }\n }\n return new LearnedSkillsError(\"UNSUPPORTED_SERVER\", false);\n}\n\nexport interface GetLearnedSkillsSnapshotsRequest {\n containers: readonly Omit<GetLearnedSkillsSnapshotRequest, \"signal\">[];\n signal?: AbortSignal;\n}\nexport type LearnedSkillsBatchResult = { containerId: string } & (\n | LearnedSkillsSnapshotResult\n | { status: \"error\"; error: LearnedSkillsError }\n);\n\n/** Validate the entire envelope before exposing any individual result. */\nexport function parseLearnedSkillsBatch(\n body: unknown,\n requests: GetLearnedSkillsSnapshotsRequest[\"containers\"],\n): LearnedSkillsBatchResult[] {\n const invalid = () => {\n if (\n body &&\n typeof body === \"object\" &&\n \"containers\" in body &&\n Array.isArray(body.containers)\n ) {\n const denial = body.containers.find(\n (entry) =>\n entry &&\n requests.some(\n (request) => request.containerId === entry.containerId,\n ) &&\n entry.status === \"error\" &&\n [\n \"AUTHENTICATION_FAILED\",\n \"AUTHORIZATION_FAILED\",\n \"ENTITLEMENT_REQUIRED\",\n \"DELIVERY_DISABLED\",\n \"CONTAINER_NOT_FOUND\",\n \"REVISION_NOT_FOUND\",\n \"REVISION_REVOKED\",\n ].includes(entry.error?.code),\n );\n if (denial) return new LearnedSkillsError(denial.error.code, false);\n }\n return new LearnedSkillsError(\"INVALID_SNAPSHOT\", false);\n };\n if (\n !body ||\n typeof body !== \"object\" ||\n !(\"containers\" in body) ||\n !Array.isArray(body.containers) ||\n body.containers.length !== requests.length\n )\n throw invalid();\n return body.containers.map((entry, index) => {\n const request = requests[index];\n if (\n !entry ||\n typeof entry !== \"object\" ||\n entry.containerId !== request.containerId\n )\n throw invalid();\n if (entry.status === \"error\") {\n if (\n !entry.error ||\n typeof entry.error !== \"object\" ||\n !Object.prototype.hasOwnProperty.call(messages, entry.error.code) ||\n typeof entry.error.retryable !== \"boolean\"\n )\n throw invalid();\n return {\n containerId: entry.containerId,\n status: \"error\",\n error: new LearnedSkillsError(entry.error.code, entry.error.retryable),\n };\n }\n if (\n typeof entry.revision !== \"string\" ||\n !entry.revision.trim() ||\n typeof entry.etag !== \"string\" ||\n !/^\"[a-f0-9]{64}\"$/.test(entry.etag) ||\n (request.revision !== undefined && entry.revision !== request.revision)\n )\n throw invalid();\n if (entry.status === \"unchanged\") {\n if (\n request.ifNoneMatch !== entry.etag ||\n \"bytesBase64\" in entry ||\n \"contentType\" in entry\n )\n throw invalid();\n return {\n containerId: entry.containerId,\n status: \"unchanged\",\n revision: entry.revision,\n etag: entry.etag,\n };\n }\n if (\n entry.status !== \"snapshot\" ||\n entry.contentType !== \"application/zip\" ||\n typeof entry.bytesBase64 !== \"string\" ||\n !entry.bytesBase64.length ||\n !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(\n entry.bytesBase64,\n )\n )\n throw invalid();\n const bytes = Buffer.from(entry.bytesBase64, \"base64\");\n if (bytes.toString(\"base64\") !== entry.bytesBase64) throw invalid();\n return {\n containerId: entry.containerId,\n status: \"snapshot\",\n revision: entry.revision,\n etag: entry.etag,\n contentType: entry.contentType,\n bytes: new Uint8Array(bytes),\n };\n });\n}\n"],"mappings":"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"}
@@ -6,15 +6,31 @@ const require_client = require('../client.cjs');
6
6
  /** Resolve once. Never retain the options object, environment, or a second key. */
7
7
  function resolveRegistryConfig(options = {}, environment = process.env) {
8
8
  try {
9
- const containerId = options.containerId ?? environment.CPK_INTELLIGENCE_LEARNING_CONTAINER_ID;
10
- const revision = options.revision ?? environment.CPK_INTELLIGENCE_SKILLS_REVISION;
9
+ const multiple = options.containers !== void 0;
10
+ if (multiple && (options.containerId !== void 0 || options.revision !== void 0)) throw new require_learned_skills.LearnedSkillsError("INVALID_CONFIG", false);
11
+ const containerId = multiple ? void 0 : options.containerId ?? environment.CPK_INTELLIGENCE_LEARNING_CONTAINER_ID;
12
+ const revision = multiple ? void 0 : options.revision ?? environment.CPK_INTELLIGENCE_SKILLS_REVISION;
13
+ let containers;
14
+ if (multiple) {
15
+ if (!Array.isArray(options.containers) || options.containers.length === 0 || options.containers.length > 50) throw new require_learned_skills.LearnedSkillsError("INVALID_CONFIG", false);
16
+ const seen = /* @__PURE__ */ new Set();
17
+ containers = Object.freeze(options.containers.map((source) => {
18
+ if (!source || typeof source.id !== "string" || !source.id.trim() || /[\u0000-\u001f\u007f]/.test(source.id) || seen.has(source.id) || source.revision !== void 0 && (typeof source.revision !== "string" || !source.revision.trim())) throw new require_learned_skills.LearnedSkillsError("INVALID_CONFIG", false);
19
+ encodeURIComponent(source.id);
20
+ seen.add(source.id);
21
+ return Object.freeze({
22
+ id: source.id,
23
+ ...source.revision !== void 0 ? { revision: source.revision } : {}
24
+ });
25
+ }));
26
+ }
11
27
  const freshnessWindowMs = options.freshnessWindowMs ?? 5e3;
12
28
  const requestTimeoutMs = options.requestTimeoutMs ?? 5e3;
13
29
  const debug = options.debug ?? false;
14
- if (typeof containerId !== "string" || !containerId.trim() || revision !== void 0 && (typeof revision !== "string" || revision.length === 0) || !Number.isSafeInteger(freshnessWindowMs) || freshnessWindowMs < 0 || !Number.isSafeInteger(requestTimeoutMs) || requestTimeoutMs < 1 || requestTimeoutMs > 2147483647 || typeof debug !== "boolean") throw new require_learned_skills.LearnedSkillsError("INVALID_CONFIG", false);
30
+ if (!multiple && (typeof containerId !== "string" || !containerId.trim()) || revision !== void 0 && (typeof revision !== "string" || revision.length === 0) || !Number.isSafeInteger(freshnessWindowMs) || freshnessWindowMs < 0 || !Number.isSafeInteger(requestTimeoutMs) || requestTimeoutMs < 1 || requestTimeoutMs > 2147483647 || typeof debug !== "boolean") throw new require_learned_skills.LearnedSkillsError("INVALID_CONFIG", false);
15
31
  let client = options.client;
16
32
  if (client !== void 0) {
17
- if (!client || typeof client.getLearnedSkillsSnapshot !== "function") throw new require_learned_skills.LearnedSkillsError("INVALID_CONFIG", false);
33
+ if (!client || typeof (multiple ? client.getLearnedSkillsSnapshots : client.getLearnedSkillsSnapshot) !== "function") throw new require_learned_skills.LearnedSkillsError("INVALID_CONFIG", false);
18
34
  } else {
19
35
  const apiKey = options.apiKey ?? environment.CPK_INTELLIGENCE_API_KEY;
20
36
  const apiUrl = options.apiUrl ?? environment.INTELLIGENCE_API_URL;
@@ -31,8 +47,10 @@ function resolveRegistryConfig(options = {}, environment = process.env) {
31
47
  }
32
48
  return Object.freeze({
33
49
  client,
34
- containerId,
35
- ...revision !== void 0 ? { revision } : {},
50
+ ...containers ? { containers } : {
51
+ containerId,
52
+ ...revision !== void 0 ? { revision } : {}
53
+ },
36
54
  freshnessWindowMs,
37
55
  requestTimeoutMs,
38
56
  debug
@@ -1 +1 @@
1
- {"version":3,"file":"config.cjs","names":["SkillDeliveryError","CopilotKitIntelligence"],"sources":["../../../../../src/v2/runtime/intelligence-platform/skill-registry/config.ts"],"sourcesContent":["import { CopilotKitIntelligence } from \"../client\";\nimport { SkillDeliveryError } from \"./errors\";\n\nexport interface SkillRegistryOptions {\n client?: CopilotKitIntelligence;\n apiKey?: string;\n apiUrl?: string;\n containerId?: string;\n revision?: string;\n freshnessWindowMs?: number;\n requestTimeoutMs?: number;\n debug?: boolean;\n}\nexport interface RegistryConfig {\n readonly client: CopilotKitIntelligence;\n readonly containerId: string;\n readonly revision?: string;\n readonly freshnessWindowMs: number;\n readonly requestTimeoutMs: number;\n readonly debug: boolean;\n}\n\n/** Resolve once. Never retain the options object, environment, or a second key. */\nexport function resolveRegistryConfig(\n options: SkillRegistryOptions = {},\n environment: NodeJS.ProcessEnv = process.env,\n): RegistryConfig {\n try {\n const containerId =\n options.containerId ?? environment.CPK_INTELLIGENCE_LEARNING_CONTAINER_ID;\n const revision =\n options.revision ?? environment.CPK_INTELLIGENCE_SKILLS_REVISION;\n const freshnessWindowMs = options.freshnessWindowMs ?? 5_000;\n const requestTimeoutMs = options.requestTimeoutMs ?? 5_000;\n const debug = options.debug ?? false;\n if (\n typeof containerId !== \"string\" ||\n !containerId.trim() ||\n (revision !== undefined &&\n (typeof revision !== \"string\" || revision.length === 0)) ||\n !Number.isSafeInteger(freshnessWindowMs) ||\n freshnessWindowMs < 0 ||\n !Number.isSafeInteger(requestTimeoutMs) ||\n requestTimeoutMs < 1 ||\n requestTimeoutMs > 2_147_483_647 ||\n typeof debug !== \"boolean\"\n )\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n let client = options.client;\n if (client !== undefined) {\n if (!client || typeof client.getLearnedSkillsSnapshot !== \"function\")\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n } else {\n const apiKey = options.apiKey ?? environment.CPK_INTELLIGENCE_API_KEY;\n const apiUrl = options.apiUrl ?? environment.INTELLIGENCE_API_URL;\n if (typeof apiKey !== \"string\" || !apiKey.trim())\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n if (apiUrl?.trim()) {\n const url = new URL(apiUrl);\n if (\n ![\"http:\", \"https:\"].includes(url.protocol) ||\n url.username ||\n url.password ||\n url.search ||\n url.hash\n )\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n }\n client = new CopilotKitIntelligence({\n apiKey,\n ...(apiUrl !== undefined ? { apiUrl } : {}),\n // This private helper client uses REST only. Explicitly retain the\n // canonical websocket default to prevent an irrelevant host warning.\n ...(apiUrl?.trim()\n ? { wsUrl: \"wss://realtime.intelligence.copilotkit.ai\" }\n : {}),\n });\n }\n return Object.freeze({\n client,\n containerId,\n ...(revision !== undefined ? { revision } : {}),\n freshnessWindowMs,\n requestTimeoutMs,\n debug,\n });\n } catch (error) {\n if (error instanceof SkillDeliveryError) throw error;\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false, error);\n }\n}\n"],"mappings":";;;;;;AAuBA,SAAgB,sBACd,UAAgC,EAAE,EAClC,cAAiC,QAAQ,KACzB;AAChB,KAAI;EACF,MAAM,cACJ,QAAQ,eAAe,YAAY;EACrC,MAAM,WACJ,QAAQ,YAAY,YAAY;EAClC,MAAM,oBAAoB,QAAQ,qBAAqB;EACvD,MAAM,mBAAmB,QAAQ,oBAAoB;EACrD,MAAM,QAAQ,QAAQ,SAAS;AAC/B,MACE,OAAO,gBAAgB,YACvB,CAAC,YAAY,MAAM,IAClB,aAAa,WACX,OAAO,aAAa,YAAY,SAAS,WAAW,MACvD,CAAC,OAAO,cAAc,kBAAkB,IACxC,oBAAoB,KACpB,CAAC,OAAO,cAAc,iBAAiB,IACvC,mBAAmB,KACnB,mBAAmB,cACnB,OAAO,UAAU,UAEjB,OAAM,IAAIA,0CAAmB,kBAAkB,MAAM;EACvD,IAAI,SAAS,QAAQ;AACrB,MAAI,WAAW,QACb;OAAI,CAAC,UAAU,OAAO,OAAO,6BAA6B,WACxD,OAAM,IAAIA,0CAAmB,kBAAkB,MAAM;SAClD;GACL,MAAM,SAAS,QAAQ,UAAU,YAAY;GAC7C,MAAM,SAAS,QAAQ,UAAU,YAAY;AAC7C,OAAI,OAAO,WAAW,YAAY,CAAC,OAAO,MAAM,CAC9C,OAAM,IAAIA,0CAAmB,kBAAkB,MAAM;AACvD,OAAI,QAAQ,MAAM,EAAE;IAClB,MAAM,MAAM,IAAI,IAAI,OAAO;AAC3B,QACE,CAAC,CAAC,SAAS,SAAS,CAAC,SAAS,IAAI,SAAS,IAC3C,IAAI,YACJ,IAAI,YACJ,IAAI,UACJ,IAAI,KAEJ,OAAM,IAAIA,0CAAmB,kBAAkB,MAAM;;AAEzD,YAAS,IAAIC,sCAAuB;IAClC;IACA,GAAI,WAAW,SAAY,EAAE,QAAQ,GAAG,EAAE;IAG1C,GAAI,QAAQ,MAAM,GACd,EAAE,OAAO,6CAA6C,GACtD,EAAE;IACP,CAAC;;AAEJ,SAAO,OAAO,OAAO;GACnB;GACA;GACA,GAAI,aAAa,SAAY,EAAE,UAAU,GAAG,EAAE;GAC9C;GACA;GACA;GACD,CAAC;UACK,OAAO;AACd,MAAI,iBAAiBD,0CAAoB,OAAM;AAC/C,QAAM,IAAIA,0CAAmB,kBAAkB,OAAO,MAAM"}
1
+ {"version":3,"file":"config.cjs","names":["SkillDeliveryError","CopilotKitIntelligence"],"sources":["../../../../../src/v2/runtime/intelligence-platform/skill-registry/config.ts"],"sourcesContent":["import { CopilotKitIntelligence } from \"../client\";\nimport { SkillDeliveryError } from \"./errors\";\n\nexport interface SkillRegistryCommonOptions {\n client?: CopilotKitIntelligence;\n apiKey?: string;\n apiUrl?: string;\n freshnessWindowMs?: number;\n requestTimeoutMs?: number;\n debug?: boolean;\n}\n/** One published container and an optional exact revision pin. */\nexport interface SkillRegistryContainer {\n readonly id: string;\n readonly revision?: string;\n}\n\n/** Legacy selection and explicit multi-container selection cannot be combined. */\nexport type SkillRegistryOptions = SkillRegistryCommonOptions &\n (\n | { containerId?: string; revision?: string; containers?: never }\n | {\n containers: readonly SkillRegistryContainer[];\n containerId?: never;\n revision?: never;\n }\n );\n\ninterface RegistryCommonConfig {\n readonly client: CopilotKitIntelligence;\n readonly freshnessWindowMs: number;\n readonly requestTimeoutMs: number;\n readonly debug: boolean;\n}\n\nexport type SingleContainerConfig = RegistryCommonConfig & {\n readonly containerId: string;\n readonly revision?: string;\n readonly containers?: never;\n};\n\nexport type RegistryConfig =\n | SingleContainerConfig\n | (RegistryCommonConfig & {\n readonly containers: readonly SkillRegistryContainer[];\n readonly containerId?: never;\n readonly revision?: never;\n });\n\n/** Resolve once. Never retain the options object, environment, or a second key. */\nexport function resolveRegistryConfig(\n options: SkillRegistryOptions = {},\n environment: NodeJS.ProcessEnv = process.env,\n): RegistryConfig {\n try {\n const multiple = options.containers !== undefined;\n if (\n multiple &&\n (options.containerId !== undefined || options.revision !== undefined)\n ) {\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n }\n const containerId = multiple\n ? undefined\n : (options.containerId ??\n environment.CPK_INTELLIGENCE_LEARNING_CONTAINER_ID);\n const revision = multiple\n ? undefined\n : (options.revision ?? environment.CPK_INTELLIGENCE_SKILLS_REVISION);\n let containers: readonly SkillRegistryContainer[] | undefined;\n if (multiple) {\n if (\n !Array.isArray(options.containers) ||\n options.containers.length === 0 ||\n options.containers.length > 50\n ) {\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n }\n const seen = new Set<string>();\n containers = Object.freeze(\n options.containers.map((source) => {\n if (\n !source ||\n typeof source.id !== \"string\" ||\n !source.id.trim() ||\n // Reject control characters in caller-provided container IDs.\n // eslint-disable-next-line no-control-regex\n /[\\u0000-\\u001f\\u007f]/.test(source.id) ||\n seen.has(source.id) ||\n (source.revision !== undefined &&\n (typeof source.revision !== \"string\" || !source.revision.trim()))\n ) {\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n }\n // Reject malformed Unicode before constructing a qualified tool name.\n encodeURIComponent(source.id);\n seen.add(source.id);\n return Object.freeze({\n id: source.id,\n ...(source.revision !== undefined\n ? { revision: source.revision }\n : {}),\n });\n }),\n );\n }\n const freshnessWindowMs = options.freshnessWindowMs ?? 5_000;\n const requestTimeoutMs = options.requestTimeoutMs ?? 5_000;\n const debug = options.debug ?? false;\n if (\n (!multiple && (typeof containerId !== \"string\" || !containerId.trim())) ||\n (revision !== undefined &&\n (typeof revision !== \"string\" || revision.length === 0)) ||\n !Number.isSafeInteger(freshnessWindowMs) ||\n freshnessWindowMs < 0 ||\n !Number.isSafeInteger(requestTimeoutMs) ||\n requestTimeoutMs < 1 ||\n requestTimeoutMs > 2_147_483_647 ||\n typeof debug !== \"boolean\"\n )\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n let client = options.client;\n if (client !== undefined) {\n if (\n !client ||\n typeof (multiple\n ? client.getLearnedSkillsSnapshots\n : client.getLearnedSkillsSnapshot) !== \"function\"\n )\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n } else {\n const apiKey = options.apiKey ?? environment.CPK_INTELLIGENCE_API_KEY;\n const apiUrl = options.apiUrl ?? environment.INTELLIGENCE_API_URL;\n if (typeof apiKey !== \"string\" || !apiKey.trim())\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n if (apiUrl?.trim()) {\n const url = new URL(apiUrl);\n if (\n ![\"http:\", \"https:\"].includes(url.protocol) ||\n url.username ||\n url.password ||\n url.search ||\n url.hash\n )\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n }\n client = new CopilotKitIntelligence({\n apiKey,\n ...(apiUrl !== undefined ? { apiUrl } : {}),\n // This private helper client uses REST only. Explicitly retain the\n // canonical websocket default to prevent an irrelevant host warning.\n ...(apiUrl?.trim()\n ? { wsUrl: \"wss://realtime.intelligence.copilotkit.ai\" }\n : {}),\n });\n }\n return Object.freeze({\n client,\n ...(containers\n ? { containers }\n : {\n containerId: containerId!,\n ...(revision !== undefined ? { revision } : {}),\n }),\n freshnessWindowMs,\n requestTimeoutMs,\n debug,\n });\n } catch (error) {\n if (error instanceof SkillDeliveryError) throw error;\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false, error);\n }\n}\n"],"mappings":";;;;;;AAkDA,SAAgB,sBACd,UAAgC,EAAE,EAClC,cAAiC,QAAQ,KACzB;AAChB,KAAI;EACF,MAAM,WAAW,QAAQ,eAAe;AACxC,MACE,aACC,QAAQ,gBAAgB,UAAa,QAAQ,aAAa,QAE3D,OAAM,IAAIA,0CAAmB,kBAAkB,MAAM;EAEvD,MAAM,cAAc,WAChB,SACC,QAAQ,eACT,YAAY;EAChB,MAAM,WAAW,WACb,SACC,QAAQ,YAAY,YAAY;EACrC,IAAI;AACJ,MAAI,UAAU;AACZ,OACE,CAAC,MAAM,QAAQ,QAAQ,WAAW,IAClC,QAAQ,WAAW,WAAW,KAC9B,QAAQ,WAAW,SAAS,GAE5B,OAAM,IAAIA,0CAAmB,kBAAkB,MAAM;GAEvD,MAAM,uBAAO,IAAI,KAAa;AAC9B,gBAAa,OAAO,OAClB,QAAQ,WAAW,KAAK,WAAW;AACjC,QACE,CAAC,UACD,OAAO,OAAO,OAAO,YACrB,CAAC,OAAO,GAAG,MAAM,IAGjB,wBAAwB,KAAK,OAAO,GAAG,IACvC,KAAK,IAAI,OAAO,GAAG,IAClB,OAAO,aAAa,WAClB,OAAO,OAAO,aAAa,YAAY,CAAC,OAAO,SAAS,MAAM,EAEjE,OAAM,IAAIA,0CAAmB,kBAAkB,MAAM;AAGvD,uBAAmB,OAAO,GAAG;AAC7B,SAAK,IAAI,OAAO,GAAG;AACnB,WAAO,OAAO,OAAO;KACnB,IAAI,OAAO;KACX,GAAI,OAAO,aAAa,SACpB,EAAE,UAAU,OAAO,UAAU,GAC7B,EAAE;KACP,CAAC;KACF,CACH;;EAEH,MAAM,oBAAoB,QAAQ,qBAAqB;EACvD,MAAM,mBAAmB,QAAQ,oBAAoB;EACrD,MAAM,QAAQ,QAAQ,SAAS;AAC/B,MACG,CAAC,aAAa,OAAO,gBAAgB,YAAY,CAAC,YAAY,MAAM,KACpE,aAAa,WACX,OAAO,aAAa,YAAY,SAAS,WAAW,MACvD,CAAC,OAAO,cAAc,kBAAkB,IACxC,oBAAoB,KACpB,CAAC,OAAO,cAAc,iBAAiB,IACvC,mBAAmB,KACnB,mBAAmB,cACnB,OAAO,UAAU,UAEjB,OAAM,IAAIA,0CAAmB,kBAAkB,MAAM;EACvD,IAAI,SAAS,QAAQ;AACrB,MAAI,WAAW,QACb;OACE,CAAC,UACD,QAAQ,WACJ,OAAO,4BACP,OAAO,8BAA8B,WAEzC,OAAM,IAAIA,0CAAmB,kBAAkB,MAAM;SAClD;GACL,MAAM,SAAS,QAAQ,UAAU,YAAY;GAC7C,MAAM,SAAS,QAAQ,UAAU,YAAY;AAC7C,OAAI,OAAO,WAAW,YAAY,CAAC,OAAO,MAAM,CAC9C,OAAM,IAAIA,0CAAmB,kBAAkB,MAAM;AACvD,OAAI,QAAQ,MAAM,EAAE;IAClB,MAAM,MAAM,IAAI,IAAI,OAAO;AAC3B,QACE,CAAC,CAAC,SAAS,SAAS,CAAC,SAAS,IAAI,SAAS,IAC3C,IAAI,YACJ,IAAI,YACJ,IAAI,UACJ,IAAI,KAEJ,OAAM,IAAIA,0CAAmB,kBAAkB,MAAM;;AAEzD,YAAS,IAAIC,sCAAuB;IAClC;IACA,GAAI,WAAW,SAAY,EAAE,QAAQ,GAAG,EAAE;IAG1C,GAAI,QAAQ,MAAM,GACd,EAAE,OAAO,6CAA6C,GACtD,EAAE;IACP,CAAC;;AAEJ,SAAO,OAAO,OAAO;GACnB;GACA,GAAI,aACA,EAAE,YAAY,GACd;IACe;IACb,GAAI,aAAa,SAAY,EAAE,UAAU,GAAG,EAAE;IAC/C;GACL;GACA;GACA;GACD,CAAC;UACK,OAAO;AACd,MAAI,iBAAiBD,0CAAoB,OAAM;AAC/C,QAAM,IAAIA,0CAAmB,kBAAkB,OAAO,MAAM"}
@@ -2,26 +2,47 @@
2
2
  import { CopilotKitIntelligence } from "../client.cjs";
3
3
 
4
4
  //#region src/v2/runtime/intelligence-platform/skill-registry/config.d.ts
5
- interface SkillRegistryOptions {
5
+ interface SkillRegistryCommonOptions {
6
6
  client?: CopilotKitIntelligence;
7
7
  apiKey?: string;
8
8
  apiUrl?: string;
9
- containerId?: string;
10
- revision?: string;
11
9
  freshnessWindowMs?: number;
12
10
  requestTimeoutMs?: number;
13
11
  debug?: boolean;
14
12
  }
15
- interface RegistryConfig {
16
- readonly client: CopilotKitIntelligence;
17
- readonly containerId: string;
13
+ /** One published container and an optional exact revision pin. */
14
+ interface SkillRegistryContainer {
15
+ readonly id: string;
18
16
  readonly revision?: string;
17
+ }
18
+ /** Legacy selection and explicit multi-container selection cannot be combined. */
19
+ type SkillRegistryOptions = SkillRegistryCommonOptions & ({
20
+ containerId?: string;
21
+ revision?: string;
22
+ containers?: never;
23
+ } | {
24
+ containers: readonly SkillRegistryContainer[];
25
+ containerId?: never;
26
+ revision?: never;
27
+ });
28
+ interface RegistryCommonConfig {
29
+ readonly client: CopilotKitIntelligence;
19
30
  readonly freshnessWindowMs: number;
20
31
  readonly requestTimeoutMs: number;
21
32
  readonly debug: boolean;
22
33
  }
34
+ type SingleContainerConfig = RegistryCommonConfig & {
35
+ readonly containerId: string;
36
+ readonly revision?: string;
37
+ readonly containers?: never;
38
+ };
39
+ type RegistryConfig = SingleContainerConfig | (RegistryCommonConfig & {
40
+ readonly containers: readonly SkillRegistryContainer[];
41
+ readonly containerId?: never;
42
+ readonly revision?: never;
43
+ });
23
44
  /** Resolve once. Never retain the options object, environment, or a second key. */
24
45
  declare function resolveRegistryConfig(options?: SkillRegistryOptions, environment?: NodeJS.ProcessEnv): RegistryConfig;
25
46
  //#endregion
26
- export { RegistryConfig, SkillRegistryOptions, resolveRegistryConfig };
47
+ export { RegistryConfig, SingleContainerConfig, SkillRegistryCommonOptions, SkillRegistryContainer, SkillRegistryOptions, resolveRegistryConfig };
27
48
  //# sourceMappingURL=config.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.cts","names":[],"sources":["../../../../../src/v2/runtime/intelligence-platform/skill-registry/config.ts"],"mappings":";;;;UAGiB,oBAAA;EACf,MAAA,GAAS,sBAAA;EACT,MAAA;EACA,MAAA;EACA,WAAA;EACA,QAAA;EACA,iBAAA;EACA,gBAAA;EACA,KAAA;AAAA;AAAA,UAEe,cAAA;EAAA,SACN,MAAA,EAAQ,sBAAA;EAAA,SACR,WAAA;EAAA,SACA,QAAA;EAAA,SACA,iBAAA;EAAA,SACA,gBAAA;EAAA,SACA,KAAA;AAAA;;iBAIK,qBAAA,CACd,OAAA,GAAS,oBAAA,EACT,WAAA,GAAa,MAAA,CAAO,UAAA,GACnB,cAAA"}
1
+ {"version":3,"file":"config.d.cts","names":[],"sources":["../../../../../src/v2/runtime/intelligence-platform/skill-registry/config.ts"],"mappings":";;;;UAGiB,0BAAA;EACf,MAAA,GAAS,sBAAA;EACT,MAAA;EACA,MAAA;EACA,iBAAA;EACA,gBAAA;EACA,KAAA;AAAA;;UAGe,sBAAA;EAAA,SACN,EAAA;EAAA,SACA,QAAA;AAAA;;KAIC,oBAAA,GAAuB,0BAAA;EAE3B,WAAA;EAAsB,QAAA;EAAmB,UAAA;AAAA;EAEzC,UAAA,WAAqB,sBAAA;EACrB,WAAA;EACA,QAAA;AAAA;AAAA,UAIE,oBAAA;EAAA,SACC,MAAA,EAAQ,sBAAA;EAAA,SACR,iBAAA;EAAA,SACA,gBAAA;EAAA,SACA,KAAA;AAAA;AAAA,KAGC,qBAAA,GAAwB,oBAAA;EAAA,SACzB,WAAA;EAAA,SACA,QAAA;EAAA,SACA,UAAA;AAAA;AAAA,KAGC,cAAA,GACR,qBAAA,IACC,oBAAA;EAAA,SACU,UAAA,WAAqB,sBAAA;EAAA,SACrB,WAAA;EAAA,SACA,QAAA;AAAA;;iBAIC,qBAAA,CACd,OAAA,GAAS,oBAAA,EACT,WAAA,GAAa,MAAA,CAAO,UAAA,GACnB,cAAA"}
@@ -2,26 +2,47 @@
2
2
  import { CopilotKitIntelligence } from "../client.mjs";
3
3
 
4
4
  //#region src/v2/runtime/intelligence-platform/skill-registry/config.d.ts
5
- interface SkillRegistryOptions {
5
+ interface SkillRegistryCommonOptions {
6
6
  client?: CopilotKitIntelligence;
7
7
  apiKey?: string;
8
8
  apiUrl?: string;
9
- containerId?: string;
10
- revision?: string;
11
9
  freshnessWindowMs?: number;
12
10
  requestTimeoutMs?: number;
13
11
  debug?: boolean;
14
12
  }
15
- interface RegistryConfig {
16
- readonly client: CopilotKitIntelligence;
17
- readonly containerId: string;
13
+ /** One published container and an optional exact revision pin. */
14
+ interface SkillRegistryContainer {
15
+ readonly id: string;
18
16
  readonly revision?: string;
17
+ }
18
+ /** Legacy selection and explicit multi-container selection cannot be combined. */
19
+ type SkillRegistryOptions = SkillRegistryCommonOptions & ({
20
+ containerId?: string;
21
+ revision?: string;
22
+ containers?: never;
23
+ } | {
24
+ containers: readonly SkillRegistryContainer[];
25
+ containerId?: never;
26
+ revision?: never;
27
+ });
28
+ interface RegistryCommonConfig {
29
+ readonly client: CopilotKitIntelligence;
19
30
  readonly freshnessWindowMs: number;
20
31
  readonly requestTimeoutMs: number;
21
32
  readonly debug: boolean;
22
33
  }
34
+ type SingleContainerConfig = RegistryCommonConfig & {
35
+ readonly containerId: string;
36
+ readonly revision?: string;
37
+ readonly containers?: never;
38
+ };
39
+ type RegistryConfig = SingleContainerConfig | (RegistryCommonConfig & {
40
+ readonly containers: readonly SkillRegistryContainer[];
41
+ readonly containerId?: never;
42
+ readonly revision?: never;
43
+ });
23
44
  /** Resolve once. Never retain the options object, environment, or a second key. */
24
45
  declare function resolveRegistryConfig(options?: SkillRegistryOptions, environment?: NodeJS.ProcessEnv): RegistryConfig;
25
46
  //#endregion
26
- export { RegistryConfig, SkillRegistryOptions, resolveRegistryConfig };
47
+ export { RegistryConfig, SingleContainerConfig, SkillRegistryCommonOptions, SkillRegistryContainer, SkillRegistryOptions, resolveRegistryConfig };
27
48
  //# sourceMappingURL=config.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.mts","names":[],"sources":["../../../../../src/v2/runtime/intelligence-platform/skill-registry/config.ts"],"mappings":";;;;UAGiB,oBAAA;EACf,MAAA,GAAS,sBAAA;EACT,MAAA;EACA,MAAA;EACA,WAAA;EACA,QAAA;EACA,iBAAA;EACA,gBAAA;EACA,KAAA;AAAA;AAAA,UAEe,cAAA;EAAA,SACN,MAAA,EAAQ,sBAAA;EAAA,SACR,WAAA;EAAA,SACA,QAAA;EAAA,SACA,iBAAA;EAAA,SACA,gBAAA;EAAA,SACA,KAAA;AAAA;;iBAIK,qBAAA,CACd,OAAA,GAAS,oBAAA,EACT,WAAA,GAAa,MAAA,CAAO,UAAA,GACnB,cAAA"}
1
+ {"version":3,"file":"config.d.mts","names":[],"sources":["../../../../../src/v2/runtime/intelligence-platform/skill-registry/config.ts"],"mappings":";;;;UAGiB,0BAAA;EACf,MAAA,GAAS,sBAAA;EACT,MAAA;EACA,MAAA;EACA,iBAAA;EACA,gBAAA;EACA,KAAA;AAAA;;UAGe,sBAAA;EAAA,SACN,EAAA;EAAA,SACA,QAAA;AAAA;;KAIC,oBAAA,GAAuB,0BAAA;EAE3B,WAAA;EAAsB,QAAA;EAAmB,UAAA;AAAA;EAEzC,UAAA,WAAqB,sBAAA;EACrB,WAAA;EACA,QAAA;AAAA;AAAA,UAIE,oBAAA;EAAA,SACC,MAAA,EAAQ,sBAAA;EAAA,SACR,iBAAA;EAAA,SACA,gBAAA;EAAA,SACA,KAAA;AAAA;AAAA,KAGC,qBAAA,GAAwB,oBAAA;EAAA,SACzB,WAAA;EAAA,SACA,QAAA;EAAA,SACA,UAAA;AAAA;AAAA,KAGC,cAAA,GACR,qBAAA,IACC,oBAAA;EAAA,SACU,UAAA,WAAqB,sBAAA;EAAA,SACrB,WAAA;EAAA,SACA,QAAA;AAAA;;iBAIC,qBAAA,CACd,OAAA,GAAS,oBAAA,EACT,WAAA,GAAa,MAAA,CAAO,UAAA,GACnB,cAAA"}
@@ -6,15 +6,31 @@ import { CopilotKitIntelligence } from "../client.mjs";
6
6
  /** Resolve once. Never retain the options object, environment, or a second key. */
7
7
  function resolveRegistryConfig(options = {}, environment = process.env) {
8
8
  try {
9
- const containerId = options.containerId ?? environment.CPK_INTELLIGENCE_LEARNING_CONTAINER_ID;
10
- const revision = options.revision ?? environment.CPK_INTELLIGENCE_SKILLS_REVISION;
9
+ const multiple = options.containers !== void 0;
10
+ if (multiple && (options.containerId !== void 0 || options.revision !== void 0)) throw new LearnedSkillsError("INVALID_CONFIG", false);
11
+ const containerId = multiple ? void 0 : options.containerId ?? environment.CPK_INTELLIGENCE_LEARNING_CONTAINER_ID;
12
+ const revision = multiple ? void 0 : options.revision ?? environment.CPK_INTELLIGENCE_SKILLS_REVISION;
13
+ let containers;
14
+ if (multiple) {
15
+ if (!Array.isArray(options.containers) || options.containers.length === 0 || options.containers.length > 50) throw new LearnedSkillsError("INVALID_CONFIG", false);
16
+ const seen = /* @__PURE__ */ new Set();
17
+ containers = Object.freeze(options.containers.map((source) => {
18
+ if (!source || typeof source.id !== "string" || !source.id.trim() || /[\u0000-\u001f\u007f]/.test(source.id) || seen.has(source.id) || source.revision !== void 0 && (typeof source.revision !== "string" || !source.revision.trim())) throw new LearnedSkillsError("INVALID_CONFIG", false);
19
+ encodeURIComponent(source.id);
20
+ seen.add(source.id);
21
+ return Object.freeze({
22
+ id: source.id,
23
+ ...source.revision !== void 0 ? { revision: source.revision } : {}
24
+ });
25
+ }));
26
+ }
11
27
  const freshnessWindowMs = options.freshnessWindowMs ?? 5e3;
12
28
  const requestTimeoutMs = options.requestTimeoutMs ?? 5e3;
13
29
  const debug = options.debug ?? false;
14
- if (typeof containerId !== "string" || !containerId.trim() || revision !== void 0 && (typeof revision !== "string" || revision.length === 0) || !Number.isSafeInteger(freshnessWindowMs) || freshnessWindowMs < 0 || !Number.isSafeInteger(requestTimeoutMs) || requestTimeoutMs < 1 || requestTimeoutMs > 2147483647 || typeof debug !== "boolean") throw new LearnedSkillsError("INVALID_CONFIG", false);
30
+ if (!multiple && (typeof containerId !== "string" || !containerId.trim()) || revision !== void 0 && (typeof revision !== "string" || revision.length === 0) || !Number.isSafeInteger(freshnessWindowMs) || freshnessWindowMs < 0 || !Number.isSafeInteger(requestTimeoutMs) || requestTimeoutMs < 1 || requestTimeoutMs > 2147483647 || typeof debug !== "boolean") throw new LearnedSkillsError("INVALID_CONFIG", false);
15
31
  let client = options.client;
16
32
  if (client !== void 0) {
17
- if (!client || typeof client.getLearnedSkillsSnapshot !== "function") throw new LearnedSkillsError("INVALID_CONFIG", false);
33
+ if (!client || typeof (multiple ? client.getLearnedSkillsSnapshots : client.getLearnedSkillsSnapshot) !== "function") throw new LearnedSkillsError("INVALID_CONFIG", false);
18
34
  } else {
19
35
  const apiKey = options.apiKey ?? environment.CPK_INTELLIGENCE_API_KEY;
20
36
  const apiUrl = options.apiUrl ?? environment.INTELLIGENCE_API_URL;
@@ -31,8 +47,10 @@ function resolveRegistryConfig(options = {}, environment = process.env) {
31
47
  }
32
48
  return Object.freeze({
33
49
  client,
34
- containerId,
35
- ...revision !== void 0 ? { revision } : {},
50
+ ...containers ? { containers } : {
51
+ containerId,
52
+ ...revision !== void 0 ? { revision } : {}
53
+ },
36
54
  freshnessWindowMs,
37
55
  requestTimeoutMs,
38
56
  debug
@@ -1 +1 @@
1
- {"version":3,"file":"config.mjs","names":["SkillDeliveryError"],"sources":["../../../../../src/v2/runtime/intelligence-platform/skill-registry/config.ts"],"sourcesContent":["import { CopilotKitIntelligence } from \"../client\";\nimport { SkillDeliveryError } from \"./errors\";\n\nexport interface SkillRegistryOptions {\n client?: CopilotKitIntelligence;\n apiKey?: string;\n apiUrl?: string;\n containerId?: string;\n revision?: string;\n freshnessWindowMs?: number;\n requestTimeoutMs?: number;\n debug?: boolean;\n}\nexport interface RegistryConfig {\n readonly client: CopilotKitIntelligence;\n readonly containerId: string;\n readonly revision?: string;\n readonly freshnessWindowMs: number;\n readonly requestTimeoutMs: number;\n readonly debug: boolean;\n}\n\n/** Resolve once. Never retain the options object, environment, or a second key. */\nexport function resolveRegistryConfig(\n options: SkillRegistryOptions = {},\n environment: NodeJS.ProcessEnv = process.env,\n): RegistryConfig {\n try {\n const containerId =\n options.containerId ?? environment.CPK_INTELLIGENCE_LEARNING_CONTAINER_ID;\n const revision =\n options.revision ?? environment.CPK_INTELLIGENCE_SKILLS_REVISION;\n const freshnessWindowMs = options.freshnessWindowMs ?? 5_000;\n const requestTimeoutMs = options.requestTimeoutMs ?? 5_000;\n const debug = options.debug ?? false;\n if (\n typeof containerId !== \"string\" ||\n !containerId.trim() ||\n (revision !== undefined &&\n (typeof revision !== \"string\" || revision.length === 0)) ||\n !Number.isSafeInteger(freshnessWindowMs) ||\n freshnessWindowMs < 0 ||\n !Number.isSafeInteger(requestTimeoutMs) ||\n requestTimeoutMs < 1 ||\n requestTimeoutMs > 2_147_483_647 ||\n typeof debug !== \"boolean\"\n )\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n let client = options.client;\n if (client !== undefined) {\n if (!client || typeof client.getLearnedSkillsSnapshot !== \"function\")\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n } else {\n const apiKey = options.apiKey ?? environment.CPK_INTELLIGENCE_API_KEY;\n const apiUrl = options.apiUrl ?? environment.INTELLIGENCE_API_URL;\n if (typeof apiKey !== \"string\" || !apiKey.trim())\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n if (apiUrl?.trim()) {\n const url = new URL(apiUrl);\n if (\n ![\"http:\", \"https:\"].includes(url.protocol) ||\n url.username ||\n url.password ||\n url.search ||\n url.hash\n )\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n }\n client = new CopilotKitIntelligence({\n apiKey,\n ...(apiUrl !== undefined ? { apiUrl } : {}),\n // This private helper client uses REST only. Explicitly retain the\n // canonical websocket default to prevent an irrelevant host warning.\n ...(apiUrl?.trim()\n ? { wsUrl: \"wss://realtime.intelligence.copilotkit.ai\" }\n : {}),\n });\n }\n return Object.freeze({\n client,\n containerId,\n ...(revision !== undefined ? { revision } : {}),\n freshnessWindowMs,\n requestTimeoutMs,\n debug,\n });\n } catch (error) {\n if (error instanceof SkillDeliveryError) throw error;\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false, error);\n }\n}\n"],"mappings":";;;;;;AAuBA,SAAgB,sBACd,UAAgC,EAAE,EAClC,cAAiC,QAAQ,KACzB;AAChB,KAAI;EACF,MAAM,cACJ,QAAQ,eAAe,YAAY;EACrC,MAAM,WACJ,QAAQ,YAAY,YAAY;EAClC,MAAM,oBAAoB,QAAQ,qBAAqB;EACvD,MAAM,mBAAmB,QAAQ,oBAAoB;EACrD,MAAM,QAAQ,QAAQ,SAAS;AAC/B,MACE,OAAO,gBAAgB,YACvB,CAAC,YAAY,MAAM,IAClB,aAAa,WACX,OAAO,aAAa,YAAY,SAAS,WAAW,MACvD,CAAC,OAAO,cAAc,kBAAkB,IACxC,oBAAoB,KACpB,CAAC,OAAO,cAAc,iBAAiB,IACvC,mBAAmB,KACnB,mBAAmB,cACnB,OAAO,UAAU,UAEjB,OAAM,IAAIA,mBAAmB,kBAAkB,MAAM;EACvD,IAAI,SAAS,QAAQ;AACrB,MAAI,WAAW,QACb;OAAI,CAAC,UAAU,OAAO,OAAO,6BAA6B,WACxD,OAAM,IAAIA,mBAAmB,kBAAkB,MAAM;SAClD;GACL,MAAM,SAAS,QAAQ,UAAU,YAAY;GAC7C,MAAM,SAAS,QAAQ,UAAU,YAAY;AAC7C,OAAI,OAAO,WAAW,YAAY,CAAC,OAAO,MAAM,CAC9C,OAAM,IAAIA,mBAAmB,kBAAkB,MAAM;AACvD,OAAI,QAAQ,MAAM,EAAE;IAClB,MAAM,MAAM,IAAI,IAAI,OAAO;AAC3B,QACE,CAAC,CAAC,SAAS,SAAS,CAAC,SAAS,IAAI,SAAS,IAC3C,IAAI,YACJ,IAAI,YACJ,IAAI,UACJ,IAAI,KAEJ,OAAM,IAAIA,mBAAmB,kBAAkB,MAAM;;AAEzD,YAAS,IAAI,uBAAuB;IAClC;IACA,GAAI,WAAW,SAAY,EAAE,QAAQ,GAAG,EAAE;IAG1C,GAAI,QAAQ,MAAM,GACd,EAAE,OAAO,6CAA6C,GACtD,EAAE;IACP,CAAC;;AAEJ,SAAO,OAAO,OAAO;GACnB;GACA;GACA,GAAI,aAAa,SAAY,EAAE,UAAU,GAAG,EAAE;GAC9C;GACA;GACA;GACD,CAAC;UACK,OAAO;AACd,MAAI,iBAAiBA,mBAAoB,OAAM;AAC/C,QAAM,IAAIA,mBAAmB,kBAAkB,OAAO,MAAM"}
1
+ {"version":3,"file":"config.mjs","names":["SkillDeliveryError"],"sources":["../../../../../src/v2/runtime/intelligence-platform/skill-registry/config.ts"],"sourcesContent":["import { CopilotKitIntelligence } from \"../client\";\nimport { SkillDeliveryError } from \"./errors\";\n\nexport interface SkillRegistryCommonOptions {\n client?: CopilotKitIntelligence;\n apiKey?: string;\n apiUrl?: string;\n freshnessWindowMs?: number;\n requestTimeoutMs?: number;\n debug?: boolean;\n}\n/** One published container and an optional exact revision pin. */\nexport interface SkillRegistryContainer {\n readonly id: string;\n readonly revision?: string;\n}\n\n/** Legacy selection and explicit multi-container selection cannot be combined. */\nexport type SkillRegistryOptions = SkillRegistryCommonOptions &\n (\n | { containerId?: string; revision?: string; containers?: never }\n | {\n containers: readonly SkillRegistryContainer[];\n containerId?: never;\n revision?: never;\n }\n );\n\ninterface RegistryCommonConfig {\n readonly client: CopilotKitIntelligence;\n readonly freshnessWindowMs: number;\n readonly requestTimeoutMs: number;\n readonly debug: boolean;\n}\n\nexport type SingleContainerConfig = RegistryCommonConfig & {\n readonly containerId: string;\n readonly revision?: string;\n readonly containers?: never;\n};\n\nexport type RegistryConfig =\n | SingleContainerConfig\n | (RegistryCommonConfig & {\n readonly containers: readonly SkillRegistryContainer[];\n readonly containerId?: never;\n readonly revision?: never;\n });\n\n/** Resolve once. Never retain the options object, environment, or a second key. */\nexport function resolveRegistryConfig(\n options: SkillRegistryOptions = {},\n environment: NodeJS.ProcessEnv = process.env,\n): RegistryConfig {\n try {\n const multiple = options.containers !== undefined;\n if (\n multiple &&\n (options.containerId !== undefined || options.revision !== undefined)\n ) {\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n }\n const containerId = multiple\n ? undefined\n : (options.containerId ??\n environment.CPK_INTELLIGENCE_LEARNING_CONTAINER_ID);\n const revision = multiple\n ? undefined\n : (options.revision ?? environment.CPK_INTELLIGENCE_SKILLS_REVISION);\n let containers: readonly SkillRegistryContainer[] | undefined;\n if (multiple) {\n if (\n !Array.isArray(options.containers) ||\n options.containers.length === 0 ||\n options.containers.length > 50\n ) {\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n }\n const seen = new Set<string>();\n containers = Object.freeze(\n options.containers.map((source) => {\n if (\n !source ||\n typeof source.id !== \"string\" ||\n !source.id.trim() ||\n // Reject control characters in caller-provided container IDs.\n // eslint-disable-next-line no-control-regex\n /[\\u0000-\\u001f\\u007f]/.test(source.id) ||\n seen.has(source.id) ||\n (source.revision !== undefined &&\n (typeof source.revision !== \"string\" || !source.revision.trim()))\n ) {\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n }\n // Reject malformed Unicode before constructing a qualified tool name.\n encodeURIComponent(source.id);\n seen.add(source.id);\n return Object.freeze({\n id: source.id,\n ...(source.revision !== undefined\n ? { revision: source.revision }\n : {}),\n });\n }),\n );\n }\n const freshnessWindowMs = options.freshnessWindowMs ?? 5_000;\n const requestTimeoutMs = options.requestTimeoutMs ?? 5_000;\n const debug = options.debug ?? false;\n if (\n (!multiple && (typeof containerId !== \"string\" || !containerId.trim())) ||\n (revision !== undefined &&\n (typeof revision !== \"string\" || revision.length === 0)) ||\n !Number.isSafeInteger(freshnessWindowMs) ||\n freshnessWindowMs < 0 ||\n !Number.isSafeInteger(requestTimeoutMs) ||\n requestTimeoutMs < 1 ||\n requestTimeoutMs > 2_147_483_647 ||\n typeof debug !== \"boolean\"\n )\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n let client = options.client;\n if (client !== undefined) {\n if (\n !client ||\n typeof (multiple\n ? client.getLearnedSkillsSnapshots\n : client.getLearnedSkillsSnapshot) !== \"function\"\n )\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n } else {\n const apiKey = options.apiKey ?? environment.CPK_INTELLIGENCE_API_KEY;\n const apiUrl = options.apiUrl ?? environment.INTELLIGENCE_API_URL;\n if (typeof apiKey !== \"string\" || !apiKey.trim())\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n if (apiUrl?.trim()) {\n const url = new URL(apiUrl);\n if (\n ![\"http:\", \"https:\"].includes(url.protocol) ||\n url.username ||\n url.password ||\n url.search ||\n url.hash\n )\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false);\n }\n client = new CopilotKitIntelligence({\n apiKey,\n ...(apiUrl !== undefined ? { apiUrl } : {}),\n // This private helper client uses REST only. Explicitly retain the\n // canonical websocket default to prevent an irrelevant host warning.\n ...(apiUrl?.trim()\n ? { wsUrl: \"wss://realtime.intelligence.copilotkit.ai\" }\n : {}),\n });\n }\n return Object.freeze({\n client,\n ...(containers\n ? { containers }\n : {\n containerId: containerId!,\n ...(revision !== undefined ? { revision } : {}),\n }),\n freshnessWindowMs,\n requestTimeoutMs,\n debug,\n });\n } catch (error) {\n if (error instanceof SkillDeliveryError) throw error;\n throw new SkillDeliveryError(\"INVALID_CONFIG\", false, error);\n }\n}\n"],"mappings":";;;;;;AAkDA,SAAgB,sBACd,UAAgC,EAAE,EAClC,cAAiC,QAAQ,KACzB;AAChB,KAAI;EACF,MAAM,WAAW,QAAQ,eAAe;AACxC,MACE,aACC,QAAQ,gBAAgB,UAAa,QAAQ,aAAa,QAE3D,OAAM,IAAIA,mBAAmB,kBAAkB,MAAM;EAEvD,MAAM,cAAc,WAChB,SACC,QAAQ,eACT,YAAY;EAChB,MAAM,WAAW,WACb,SACC,QAAQ,YAAY,YAAY;EACrC,IAAI;AACJ,MAAI,UAAU;AACZ,OACE,CAAC,MAAM,QAAQ,QAAQ,WAAW,IAClC,QAAQ,WAAW,WAAW,KAC9B,QAAQ,WAAW,SAAS,GAE5B,OAAM,IAAIA,mBAAmB,kBAAkB,MAAM;GAEvD,MAAM,uBAAO,IAAI,KAAa;AAC9B,gBAAa,OAAO,OAClB,QAAQ,WAAW,KAAK,WAAW;AACjC,QACE,CAAC,UACD,OAAO,OAAO,OAAO,YACrB,CAAC,OAAO,GAAG,MAAM,IAGjB,wBAAwB,KAAK,OAAO,GAAG,IACvC,KAAK,IAAI,OAAO,GAAG,IAClB,OAAO,aAAa,WAClB,OAAO,OAAO,aAAa,YAAY,CAAC,OAAO,SAAS,MAAM,EAEjE,OAAM,IAAIA,mBAAmB,kBAAkB,MAAM;AAGvD,uBAAmB,OAAO,GAAG;AAC7B,SAAK,IAAI,OAAO,GAAG;AACnB,WAAO,OAAO,OAAO;KACnB,IAAI,OAAO;KACX,GAAI,OAAO,aAAa,SACpB,EAAE,UAAU,OAAO,UAAU,GAC7B,EAAE;KACP,CAAC;KACF,CACH;;EAEH,MAAM,oBAAoB,QAAQ,qBAAqB;EACvD,MAAM,mBAAmB,QAAQ,oBAAoB;EACrD,MAAM,QAAQ,QAAQ,SAAS;AAC/B,MACG,CAAC,aAAa,OAAO,gBAAgB,YAAY,CAAC,YAAY,MAAM,KACpE,aAAa,WACX,OAAO,aAAa,YAAY,SAAS,WAAW,MACvD,CAAC,OAAO,cAAc,kBAAkB,IACxC,oBAAoB,KACpB,CAAC,OAAO,cAAc,iBAAiB,IACvC,mBAAmB,KACnB,mBAAmB,cACnB,OAAO,UAAU,UAEjB,OAAM,IAAIA,mBAAmB,kBAAkB,MAAM;EACvD,IAAI,SAAS,QAAQ;AACrB,MAAI,WAAW,QACb;OACE,CAAC,UACD,QAAQ,WACJ,OAAO,4BACP,OAAO,8BAA8B,WAEzC,OAAM,IAAIA,mBAAmB,kBAAkB,MAAM;SAClD;GACL,MAAM,SAAS,QAAQ,UAAU,YAAY;GAC7C,MAAM,SAAS,QAAQ,UAAU,YAAY;AAC7C,OAAI,OAAO,WAAW,YAAY,CAAC,OAAO,MAAM,CAC9C,OAAM,IAAIA,mBAAmB,kBAAkB,MAAM;AACvD,OAAI,QAAQ,MAAM,EAAE;IAClB,MAAM,MAAM,IAAI,IAAI,OAAO;AAC3B,QACE,CAAC,CAAC,SAAS,SAAS,CAAC,SAAS,IAAI,SAAS,IAC3C,IAAI,YACJ,IAAI,YACJ,IAAI,UACJ,IAAI,KAEJ,OAAM,IAAIA,mBAAmB,kBAAkB,MAAM;;AAEzD,YAAS,IAAI,uBAAuB;IAClC;IACA,GAAI,WAAW,SAAY,EAAE,QAAQ,GAAG,EAAE;IAG1C,GAAI,QAAQ,MAAM,GACd,EAAE,OAAO,6CAA6C,GACtD,EAAE;IACP,CAAC;;AAEJ,SAAO,OAAO,OAAO;GACnB;GACA,GAAI,aACA,EAAE,YAAY,GACd;IACe;IACb,GAAI,aAAa,SAAY,EAAE,UAAU,GAAG,EAAE;IAC/C;GACL;GACA;GACA;GACD,CAAC;UACK,OAAO;AACd,MAAI,iBAAiBA,mBAAoB,OAAM;AAC/C,QAAM,IAAIA,mBAAmB,kBAAkB,OAAO,MAAM"}
@@ -1,7 +1,7 @@
1
1
 
2
2
  import { MAX_ARCHIVE_ENTRIES, MAX_SNAPSHOT_BYTES, readArchive, safeRelativePath } from "./archive.cjs";
3
3
  import { LearnedSkillsError, LearnedSkillsErrorCode } from "../learned-skills.cjs";
4
- import { RegistryConfig, SkillRegistryOptions, resolveRegistryConfig } from "./config.cjs";
4
+ import { RegistryConfig, SingleContainerConfig, SkillRegistryCommonOptions, SkillRegistryContainer, SkillRegistryOptions, resolveRegistryConfig } from "./config.cjs";
5
5
  import { invalidSnapshot } from "./errors.cjs";
6
6
  import { SnapshotFile, SnapshotSkill, VerifiedSnapshot, validateSnapshot } from "./snapshot.cjs";
7
7
  import { SkillRegistry, SkillRegistryStatus } from "./registry.cjs";
@@ -1,7 +1,7 @@
1
1
 
2
2
  import { MAX_ARCHIVE_ENTRIES, MAX_SNAPSHOT_BYTES, readArchive, safeRelativePath } from "./archive.mjs";
3
3
  import { LearnedSkillsError, LearnedSkillsErrorCode } from "../learned-skills.mjs";
4
- import { RegistryConfig, SkillRegistryOptions, resolveRegistryConfig } from "./config.mjs";
4
+ import { RegistryConfig, SingleContainerConfig, SkillRegistryCommonOptions, SkillRegistryContainer, SkillRegistryOptions, resolveRegistryConfig } from "./config.mjs";
5
5
  import { invalidSnapshot } from "./errors.mjs";
6
6
  import { SnapshotFile, SnapshotSkill, VerifiedSnapshot, validateSnapshot } from "./snapshot.mjs";
7
7
  import { SkillRegistry, SkillRegistryStatus } from "./registry.mjs";