@copilotkit/intelligence-langgraph 0.1.0 → 1.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -1
- package/dist/index.cjs +3 -4
- package/dist/index.d.cts +2 -4
- package/dist/index.d.mts +2 -5
- package/dist/index.mjs +1 -3
- package/dist/intelligence-delivery-core/dist/index.cjs +1 -7
- package/dist/intelligence-delivery-core/dist/index.d.cts +2 -0
- package/dist/intelligence-delivery-core/dist/index.d.mts +2 -5
- package/dist/intelligence-delivery-core/dist/index.mjs +2 -7
- package/dist/invocation.cjs +5 -5
- package/dist/invocation.cjs.map +1 -1
- package/dist/invocation.mjs +1 -2
- package/dist/invocation.mjs.map +1 -1
- package/dist/middleware.cjs +3 -4
- package/dist/middleware.cjs.map +1 -1
- package/dist/middleware.d.cts +1 -1
- package/dist/middleware.d.mts +1 -2
- package/dist/middleware.d.mts.map +1 -1
- package/dist/middleware.mjs +1 -3
- package/dist/middleware.mjs.map +1 -1
- package/dist/skill-tools.cjs +3 -3
- package/dist/skill-tools.cjs.map +1 -1
- package/dist/skill-tools.mjs +1 -2
- package/dist/skill-tools.mjs.map +1 -1
- package/package.json +2 -3
- package/dist/intelligence-delivery-core/dist/archive.cjs +0 -130
- package/dist/intelligence-delivery-core/dist/archive.cjs.map +0 -1
- package/dist/intelligence-delivery-core/dist/archive.mjs +0 -127
- package/dist/intelligence-delivery-core/dist/archive.mjs.map +0 -1
- package/dist/intelligence-delivery-core/dist/config.cjs +0 -47
- package/dist/intelligence-delivery-core/dist/config.cjs.map +0 -1
- package/dist/intelligence-delivery-core/dist/config.d.cts +0 -17
- package/dist/intelligence-delivery-core/dist/config.d.cts.map +0 -1
- package/dist/intelligence-delivery-core/dist/config.d.mts +0 -17
- package/dist/intelligence-delivery-core/dist/config.d.mts.map +0 -1
- package/dist/intelligence-delivery-core/dist/config.mjs +0 -47
- package/dist/intelligence-delivery-core/dist/config.mjs.map +0 -1
- package/dist/intelligence-delivery-core/dist/errors.cjs +0 -10
- package/dist/intelligence-delivery-core/dist/errors.cjs.map +0 -1
- package/dist/intelligence-delivery-core/dist/errors.d.cts +0 -2
- package/dist/intelligence-delivery-core/dist/errors.d.mts +0 -2
- package/dist/intelligence-delivery-core/dist/errors.mjs +0 -10
- package/dist/intelligence-delivery-core/dist/errors.mjs.map +0 -1
- package/dist/intelligence-delivery-core/dist/registry.cjs +0 -131
- package/dist/intelligence-delivery-core/dist/registry.cjs.map +0 -1
- package/dist/intelligence-delivery-core/dist/registry.d.cts +0 -31
- package/dist/intelligence-delivery-core/dist/registry.d.cts.map +0 -1
- package/dist/intelligence-delivery-core/dist/registry.d.mts +0 -31
- package/dist/intelligence-delivery-core/dist/registry.d.mts.map +0 -1
- package/dist/intelligence-delivery-core/dist/registry.mjs +0 -130
- package/dist/intelligence-delivery-core/dist/registry.mjs.map +0 -1
- package/dist/intelligence-delivery-core/dist/skill-content.cjs +0 -41
- package/dist/intelligence-delivery-core/dist/skill-content.cjs.map +0 -1
- package/dist/intelligence-delivery-core/dist/skill-content.d.mts +0 -1
- package/dist/intelligence-delivery-core/dist/skill-content.mjs +0 -38
- package/dist/intelligence-delivery-core/dist/skill-content.mjs.map +0 -1
- package/dist/intelligence-delivery-core/dist/snapshot.cjs +0 -91
- package/dist/intelligence-delivery-core/dist/snapshot.cjs.map +0 -1
- package/dist/intelligence-delivery-core/dist/snapshot.d.cts +0 -23
- package/dist/intelligence-delivery-core/dist/snapshot.d.cts.map +0 -1
- package/dist/intelligence-delivery-core/dist/snapshot.d.mts +0 -25
- package/dist/intelligence-delivery-core/dist/snapshot.d.mts.map +0 -1
- package/dist/intelligence-delivery-core/dist/snapshot.mjs +0 -90
- package/dist/intelligence-delivery-core/dist/snapshot.mjs.map +0 -1
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { SkillDeliveryError, invalidSnapshot } from "./errors.mjs";
|
|
2
|
-
import { resolveRegistryConfig } from "./config.mjs";
|
|
3
|
-
import { validateSnapshot } from "./snapshot.mjs";
|
|
4
|
-
|
|
5
|
-
//#region ../intelligence-delivery-core/dist/registry.mjs
|
|
6
|
-
function transient(error) {
|
|
7
|
-
return [
|
|
8
|
-
"NETWORK_ERROR",
|
|
9
|
-
"TIMEOUT",
|
|
10
|
-
"INVALID_SNAPSHOT",
|
|
11
|
-
"UNSUPPORTED_SERVER"
|
|
12
|
-
].includes(error.code);
|
|
13
|
-
}
|
|
14
|
-
function deliveryError(error) {
|
|
15
|
-
if (error instanceof SkillDeliveryError) return error;
|
|
16
|
-
return new SkillDeliveryError(error instanceof Error && error.name === "TimeoutError" ? "TIMEOUT" : "NETWORK_ERROR", true, error);
|
|
17
|
-
}
|
|
18
|
-
/** Internal registry shared by framework adapters; public API is framework-native. */
|
|
19
|
-
var SkillRegistry = class {
|
|
20
|
-
#config;
|
|
21
|
-
#snapshot;
|
|
22
|
-
#inFlight;
|
|
23
|
-
#lastCheckedAt;
|
|
24
|
-
#stale = false;
|
|
25
|
-
#lastError;
|
|
26
|
-
#blocked;
|
|
27
|
-
constructor(options = {}) {
|
|
28
|
-
this.#config = resolveRegistryConfig(options);
|
|
29
|
-
}
|
|
30
|
-
async initialize() {
|
|
31
|
-
await this.acquireSnapshot();
|
|
32
|
-
}
|
|
33
|
-
/** Capture exactly one immutable snapshot before model work begins. */
|
|
34
|
-
acquireSnapshot() {
|
|
35
|
-
if (this.#inFlight) return this.#inFlight;
|
|
36
|
-
if (this.#snapshot && !this.#blocked && this.#lastCheckedAt !== void 0 && Date.now() - this.#lastCheckedAt < this.#config.freshnessWindowMs) return Promise.resolve(this.#snapshot);
|
|
37
|
-
this.#inFlight = Promise.resolve().then(() => this.#refresh()).finally(() => {
|
|
38
|
-
this.#inFlight = void 0;
|
|
39
|
-
});
|
|
40
|
-
return this.#inFlight;
|
|
41
|
-
}
|
|
42
|
-
get status() {
|
|
43
|
-
const error = this.#lastError;
|
|
44
|
-
return Object.freeze({
|
|
45
|
-
initialized: this.#snapshot !== void 0,
|
|
46
|
-
...this.#snapshot ? { revision: this.#snapshot.revision } : {},
|
|
47
|
-
mode: this.#config.revision === void 0 ? "latest" : "pinned",
|
|
48
|
-
...this.#lastCheckedAt !== void 0 ? { lastCheckedAt: new Date(this.#lastCheckedAt).toISOString() } : {},
|
|
49
|
-
stale: this.#stale,
|
|
50
|
-
...error ? { lastError: Object.freeze({
|
|
51
|
-
code: error.code,
|
|
52
|
-
message: error.message,
|
|
53
|
-
retryable: error.retryable
|
|
54
|
-
}) } : {}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
async #refresh() {
|
|
58
|
-
const startedAt = Date.now();
|
|
59
|
-
const controller = new AbortController();
|
|
60
|
-
let timer;
|
|
61
|
-
const deadline = new Promise((_, reject) => {
|
|
62
|
-
timer = setTimeout(() => {
|
|
63
|
-
const error = new SkillDeliveryError("TIMEOUT", true);
|
|
64
|
-
controller.abort(error);
|
|
65
|
-
timer = setTimeout(() => reject(error), 0);
|
|
66
|
-
}, this.#config.requestTimeoutMs);
|
|
67
|
-
});
|
|
68
|
-
const replacement = async () => {
|
|
69
|
-
const response = await this.#config.client.getLearnedSkillsSnapshot({
|
|
70
|
-
containerId: this.#config.containerId,
|
|
71
|
-
...this.#config.revision !== void 0 ? { revision: this.#config.revision } : {},
|
|
72
|
-
...this.#snapshot ? { ifNoneMatch: this.#snapshot.etag } : {},
|
|
73
|
-
signal: controller.signal
|
|
74
|
-
});
|
|
75
|
-
controller.signal.throwIfAborted();
|
|
76
|
-
if (!response || typeof response !== "object") throw invalidSnapshot();
|
|
77
|
-
if (response.status === "unchanged") {
|
|
78
|
-
if (!this.#snapshot || response.etag !== this.#snapshot.etag || response.revision !== this.#snapshot.revision) throw invalidSnapshot();
|
|
79
|
-
return this.#snapshot;
|
|
80
|
-
}
|
|
81
|
-
if (this.#config.revision !== void 0 && response.revision !== this.#config.revision) throw invalidSnapshot();
|
|
82
|
-
return validateSnapshot(response, controller.signal);
|
|
83
|
-
};
|
|
84
|
-
try {
|
|
85
|
-
const snapshot = await Promise.race([replacement(), deadline]);
|
|
86
|
-
this.#snapshot = snapshot;
|
|
87
|
-
this.#lastCheckedAt = Date.now();
|
|
88
|
-
this.#stale = false;
|
|
89
|
-
this.#lastError = void 0;
|
|
90
|
-
this.#blocked = void 0;
|
|
91
|
-
this.#debug("refresh-success", startedAt);
|
|
92
|
-
return snapshot;
|
|
93
|
-
} catch (cause) {
|
|
94
|
-
const error = deliveryError(cause);
|
|
95
|
-
if (!transient(error)) {
|
|
96
|
-
this.#blocked = error;
|
|
97
|
-
this.#stale = false;
|
|
98
|
-
this.#lastError = error;
|
|
99
|
-
this.#debug("refresh-denied", startedAt, error.code);
|
|
100
|
-
throw error;
|
|
101
|
-
}
|
|
102
|
-
if (this.#blocked) {
|
|
103
|
-
this.#lastError = this.#blocked;
|
|
104
|
-
this.#debug("refresh-failed", startedAt, error.code);
|
|
105
|
-
throw this.#blocked;
|
|
106
|
-
}
|
|
107
|
-
this.#lastError = error;
|
|
108
|
-
this.#stale = this.#snapshot !== void 0;
|
|
109
|
-
this.#debug("refresh-failed", startedAt, error.code);
|
|
110
|
-
if (this.#snapshot) return this.#snapshot;
|
|
111
|
-
throw error;
|
|
112
|
-
} finally {
|
|
113
|
-
if (timer !== void 0) clearTimeout(timer);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
#debug(event, startedAt, errorCode) {
|
|
117
|
-
if (!this.#config.debug) return;
|
|
118
|
-
console.debug("CopilotKit learned skills", {
|
|
119
|
-
event,
|
|
120
|
-
containerId: this.#config.containerId,
|
|
121
|
-
revision: this.#snapshot?.revision,
|
|
122
|
-
durationMs: Date.now() - startedAt,
|
|
123
|
-
...errorCode ? { errorCode } : {}
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
//#endregion
|
|
129
|
-
export { SkillRegistry };
|
|
130
|
-
//# sourceMappingURL=registry.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.mjs","names":["#config","#inFlight","#snapshot","#blocked","#lastCheckedAt","#refresh","#lastError","#stale","#debug"],"sources":["../../../../intelligence-delivery-core/dist/registry.mjs"],"sourcesContent":["import { SkillDeliveryError, invalidSnapshot } from \"./errors.mjs\";\nimport { resolveRegistryConfig } from \"./config.mjs\";\nimport { validateSnapshot } from \"./snapshot.mjs\";\n\n//#region src/registry.ts\nfunction transient(error) {\n\treturn [\n\t\t\"NETWORK_ERROR\",\n\t\t\"TIMEOUT\",\n\t\t\"INVALID_SNAPSHOT\",\n\t\t\"UNSUPPORTED_SERVER\"\n\t].includes(error.code);\n}\nfunction deliveryError(error) {\n\tif (error instanceof SkillDeliveryError) return error;\n\treturn new SkillDeliveryError(error instanceof Error && error.name === \"TimeoutError\" ? \"TIMEOUT\" : \"NETWORK_ERROR\", true, error);\n}\n/** Internal registry shared by framework adapters; public API is framework-native. */\nvar SkillRegistry = class {\n\t#config;\n\t#snapshot;\n\t#inFlight;\n\t#lastCheckedAt;\n\t#stale = false;\n\t#lastError;\n\t#blocked;\n\tconstructor(options = {}) {\n\t\tthis.#config = resolveRegistryConfig(options);\n\t}\n\tasync initialize() {\n\t\tawait this.acquireSnapshot();\n\t}\n\t/** Capture exactly one immutable snapshot before model work begins. */\n\tacquireSnapshot() {\n\t\tif (this.#inFlight) return this.#inFlight;\n\t\tif (this.#snapshot && !this.#blocked && this.#lastCheckedAt !== void 0 && Date.now() - this.#lastCheckedAt < this.#config.freshnessWindowMs) return Promise.resolve(this.#snapshot);\n\t\tthis.#inFlight = Promise.resolve().then(() => this.#refresh()).finally(() => {\n\t\t\tthis.#inFlight = void 0;\n\t\t});\n\t\treturn this.#inFlight;\n\t}\n\tget status() {\n\t\tconst error = this.#lastError;\n\t\treturn Object.freeze({\n\t\t\tinitialized: this.#snapshot !== void 0,\n\t\t\t...this.#snapshot ? { revision: this.#snapshot.revision } : {},\n\t\t\tmode: this.#config.revision === void 0 ? \"latest\" : \"pinned\",\n\t\t\t...this.#lastCheckedAt !== void 0 ? { lastCheckedAt: new Date(this.#lastCheckedAt).toISOString() } : {},\n\t\t\tstale: this.#stale,\n\t\t\t...error ? { lastError: Object.freeze({\n\t\t\t\tcode: error.code,\n\t\t\t\tmessage: error.message,\n\t\t\t\tretryable: error.retryable\n\t\t\t}) } : {}\n\t\t});\n\t}\n\tasync #refresh() {\n\t\tconst startedAt = Date.now();\n\t\tconst controller = new AbortController();\n\t\tlet timer;\n\t\tconst deadline = new Promise((_, reject) => {\n\t\t\ttimer = setTimeout(() => {\n\t\t\t\tconst error = new SkillDeliveryError(\"TIMEOUT\", true);\n\t\t\t\tcontroller.abort(error);\n\t\t\t\ttimer = setTimeout(() => reject(error), 0);\n\t\t\t}, this.#config.requestTimeoutMs);\n\t\t});\n\t\tconst replacement = async () => {\n\t\t\tconst response = await this.#config.client.getLearnedSkillsSnapshot({\n\t\t\t\tcontainerId: this.#config.containerId,\n\t\t\t\t...this.#config.revision !== void 0 ? { revision: this.#config.revision } : {},\n\t\t\t\t...this.#snapshot ? { ifNoneMatch: this.#snapshot.etag } : {},\n\t\t\t\tsignal: controller.signal\n\t\t\t});\n\t\t\tcontroller.signal.throwIfAborted();\n\t\t\tif (!response || typeof response !== \"object\") throw invalidSnapshot();\n\t\t\tif (response.status === \"unchanged\") {\n\t\t\t\tif (!this.#snapshot || response.etag !== this.#snapshot.etag || response.revision !== this.#snapshot.revision) throw invalidSnapshot();\n\t\t\t\treturn this.#snapshot;\n\t\t\t}\n\t\t\tif (this.#config.revision !== void 0 && response.revision !== this.#config.revision) throw invalidSnapshot();\n\t\t\treturn validateSnapshot(response, controller.signal);\n\t\t};\n\t\ttry {\n\t\t\tconst snapshot = await Promise.race([replacement(), deadline]);\n\t\t\tthis.#snapshot = snapshot;\n\t\t\tthis.#lastCheckedAt = Date.now();\n\t\t\tthis.#stale = false;\n\t\t\tthis.#lastError = void 0;\n\t\t\tthis.#blocked = void 0;\n\t\t\tthis.#debug(\"refresh-success\", startedAt);\n\t\t\treturn snapshot;\n\t\t} catch (cause) {\n\t\t\tconst error = deliveryError(cause);\n\t\t\tif (!transient(error)) {\n\t\t\t\tthis.#blocked = error;\n\t\t\t\tthis.#stale = false;\n\t\t\t\tthis.#lastError = error;\n\t\t\t\tthis.#debug(\"refresh-denied\", startedAt, error.code);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tif (this.#blocked) {\n\t\t\t\tthis.#lastError = this.#blocked;\n\t\t\t\tthis.#debug(\"refresh-failed\", startedAt, error.code);\n\t\t\t\tthrow this.#blocked;\n\t\t\t}\n\t\t\tthis.#lastError = error;\n\t\t\tthis.#stale = this.#snapshot !== void 0;\n\t\t\tthis.#debug(\"refresh-failed\", startedAt, error.code);\n\t\t\tif (this.#snapshot) return this.#snapshot;\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tif (timer !== void 0) clearTimeout(timer);\n\t\t}\n\t}\n\t#debug(event, startedAt, errorCode) {\n\t\tif (!this.#config.debug) return;\n\t\tconsole.debug(\"CopilotKit learned skills\", {\n\t\t\tevent,\n\t\t\tcontainerId: this.#config.containerId,\n\t\t\trevision: this.#snapshot?.revision,\n\t\t\tdurationMs: Date.now() - startedAt,\n\t\t\t...errorCode ? { errorCode } : {}\n\t\t});\n\t}\n};\n\n//#endregion\nexport { SkillRegistry };\n//# sourceMappingURL=registry.mjs.map"],"mappings":";;;;;AAKA,SAAS,UAAU,OAAO;AACzB,QAAO;EACN;EACA;EACA;EACA;EACA,CAAC,SAAS,MAAM,KAAK;;AAEvB,SAAS,cAAc,OAAO;AAC7B,KAAI,iBAAiB,mBAAoB,QAAO;AAChD,QAAO,IAAI,mBAAmB,iBAAiB,SAAS,MAAM,SAAS,iBAAiB,YAAY,iBAAiB,MAAM,MAAM;;;AAGlI,IAAI,gBAAgB,MAAM;CACzB;CACA;CACA;CACA;CACA,SAAS;CACT;CACA;CACA,YAAY,UAAU,EAAE,EAAE;AACzB,QAAKA,SAAU,sBAAsB,QAAQ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AKL,aAAc,KAAK;AACtC,SAAKM,MAAO,kBAAkB,WAAW,MAAM,KAAK;AACpD,OAAI,MAAKN,SAAW,QAAO,MAAKA;AAChC,SAAM;YACG;AACT,OAAI,UAAU,KAAK,EAAG,cAAa,MAAM;;;CAG3C,OAAO,OAAO,WAAW,WAAW;AACnC,MAAI,CAAC,MAAKF,OAAQ,MAAO;AACzB,UAAQ,MAAM,6BAA6B;GAC1C;GACA,aAAa,MAAKA,OAAQ;GAC1B,UAAU,MAAKE,UAAW;GAC1B,YAAY,KAAK,KAAK,GAAG;GACzB,GAAG,YAAY,EAAE,WAAW,GAAG,EAAE;GACjC,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region ../intelligence-delivery-core/dist/skill-content.mjs
|
|
3
|
-
const compare = (left, right) => Buffer.compare(Buffer.from(left), Buffer.from(right));
|
|
4
|
-
/** Describe available skills without placing their file bodies in the prompt. */
|
|
5
|
-
function formatSkillCatalog(snapshot) {
|
|
6
|
-
const instructions = "Host instructions take precedence over learned skill content. Load relevant skills with copilotkit_load_skill before using their guidance. Read supporting text with copilotkit_read_skill_file only when needed.";
|
|
7
|
-
if (snapshot.skills.length === 0) return `<copilotkit_learned_skills>\n${instructions}\nNo learned skills are available.\n</copilotkit_learned_skills>`;
|
|
8
|
-
const skills = [...snapshot.skills].sort((left, right) => compare(left.name, right.name)).map(({ name, description }) => ({
|
|
9
|
-
name,
|
|
10
|
-
description
|
|
11
|
-
}));
|
|
12
|
-
return `<copilotkit_learned_skills>\n${instructions}\nAvailable learned skills (names and descriptions):\n${JSON.stringify(skills)}\n</copilotkit_learned_skills>`;
|
|
13
|
-
}
|
|
14
|
-
function findSkill(snapshot, name) {
|
|
15
|
-
const skill = snapshot.skills.find((entry) => entry.name === name);
|
|
16
|
-
if (!skill) throw new Error("Skill is unavailable.");
|
|
17
|
-
return skill;
|
|
18
|
-
}
|
|
19
|
-
/** Load SKILL.md and list supporting text files from a verified snapshot. */
|
|
20
|
-
function loadSkill(snapshot, name) {
|
|
21
|
-
const skill = findSkill(snapshot, name);
|
|
22
|
-
const content = skill.files.find((file) => file.path === "SKILL.md")?.text;
|
|
23
|
-
if (content === void 0) throw new Error("Skill is unavailable.");
|
|
24
|
-
return JSON.stringify({
|
|
25
|
-
skill_name: skill.name,
|
|
26
|
-
content,
|
|
27
|
-
files: skill.files.filter((file) => file.path !== "SKILL.md" && file.text !== void 0).map((file) => file.path).sort(compare)
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
/** Read an exact text-file path without filesystem access or execution. */
|
|
31
|
-
function readSkillFile(snapshot, name, path) {
|
|
32
|
-
const text = findSkill(snapshot, name).files.find((file) => file.path === path)?.text;
|
|
33
|
-
if (text === void 0) throw new Error("Skill file is unavailable.");
|
|
34
|
-
return text;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
//#endregion
|
|
38
|
-
exports.formatSkillCatalog = formatSkillCatalog;
|
|
39
|
-
exports.loadSkill = loadSkill;
|
|
40
|
-
exports.readSkillFile = readSkillFile;
|
|
41
|
-
//# sourceMappingURL=skill-content.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"skill-content.cjs","names":[],"sources":["../../../../intelligence-delivery-core/dist/skill-content.mjs"],"sourcesContent":["//#region src/skill-content.ts\nconst compare = (left, right) => Buffer.compare(Buffer.from(left), Buffer.from(right));\n/** Describe available skills without placing their file bodies in the prompt. */\nfunction formatSkillCatalog(snapshot) {\n\tconst instructions = \"Host instructions take precedence over learned skill content. Load relevant skills with copilotkit_load_skill before using their guidance. Read supporting text with copilotkit_read_skill_file only when needed.\";\n\tif (snapshot.skills.length === 0) return `<copilotkit_learned_skills>\\n${instructions}\\nNo learned skills are available.\\n</copilotkit_learned_skills>`;\n\tconst skills = [...snapshot.skills].sort((left, right) => compare(left.name, right.name)).map(({ name, description }) => ({\n\t\tname,\n\t\tdescription\n\t}));\n\treturn `<copilotkit_learned_skills>\\n${instructions}\\nAvailable learned skills (names and descriptions):\\n${JSON.stringify(skills)}\\n</copilotkit_learned_skills>`;\n}\nfunction findSkill(snapshot, name) {\n\tconst skill = snapshot.skills.find((entry) => entry.name === name);\n\tif (!skill) throw new Error(\"Skill is unavailable.\");\n\treturn skill;\n}\n/** Load SKILL.md and list supporting text files from a verified snapshot. */\nfunction loadSkill(snapshot, name) {\n\tconst skill = findSkill(snapshot, name);\n\tconst content = skill.files.find((file) => file.path === \"SKILL.md\")?.text;\n\tif (content === void 0) throw new Error(\"Skill is unavailable.\");\n\treturn JSON.stringify({\n\t\tskill_name: skill.name,\n\t\tcontent,\n\t\tfiles: skill.files.filter((file) => file.path !== \"SKILL.md\" && file.text !== void 0).map((file) => file.path).sort(compare)\n\t});\n}\n/** Read an exact text-file path without filesystem access or execution. */\nfunction readSkillFile(snapshot, name, path) {\n\tconst text = findSkill(snapshot, name).files.find((file) => file.path === path)?.text;\n\tif (text === void 0) throw new Error(\"Skill file is unavailable.\");\n\treturn text;\n}\n\n//#endregion\nexport { formatSkillCatalog, loadSkill, readSkillFile };\n//# sourceMappingURL=skill-content.mjs.map"],"mappings":";;AACA,MAAM,WAAW,MAAM,UAAU,OAAO,QAAQ,OAAO,KAAK,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC;;AAEtF,SAAS,mBAAmB,UAAU;CACrC,MAAM,eAAe;AACrB,KAAI,SAAS,OAAO,WAAW,EAAG,QAAO,gCAAgC,aAAa;CACtF,MAAM,SAAS,CAAC,GAAG,SAAS,OAAO,CAAC,MAAM,MAAM,UAAU,QAAQ,KAAK,MAAM,MAAM,KAAK,CAAC,CAAC,KAAK,EAAE,MAAM,mBAAmB;EACzH;EACA;EACA,EAAE;AACH,QAAO,gCAAgC,aAAa,wDAAwD,KAAK,UAAU,OAAO,CAAC;;AAEpI,SAAS,UAAU,UAAU,MAAM;CAClC,MAAM,QAAQ,SAAS,OAAO,MAAM,UAAU,MAAM,SAAS,KAAK;AAClE,KAAI,CAAC,MAAO,OAAM,IAAI,MAAM,wBAAwB;AACpD,QAAO;;;AAGR,SAAS,UAAU,UAAU,MAAM;CAClC,MAAM,QAAQ,UAAU,UAAU,KAAK;CACvC,MAAM,UAAU,MAAM,MAAM,MAAM,SAAS,KAAK,SAAS,WAAW,EAAE;AACtE,KAAI,YAAY,KAAK,EAAG,OAAM,IAAI,MAAM,wBAAwB;AAChE,QAAO,KAAK,UAAU;EACrB,YAAY,MAAM;EAClB;EACA,OAAO,MAAM,MAAM,QAAQ,SAAS,KAAK,SAAS,cAAc,KAAK,SAAS,KAAK,EAAE,CAAC,KAAK,SAAS,KAAK,KAAK,CAAC,KAAK,QAAQ;EAC5H,CAAC;;;AAGH,SAAS,cAAc,UAAU,MAAM,MAAM;CAC5C,MAAM,OAAO,UAAU,UAAU,KAAK,CAAC,MAAM,MAAM,SAAS,KAAK,SAAS,KAAK,EAAE;AACjF,KAAI,SAAS,KAAK,EAAG,OAAM,IAAI,MAAM,6BAA6B;AAClE,QAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./snapshot.mjs";
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
//#region ../intelligence-delivery-core/dist/skill-content.mjs
|
|
2
|
-
const compare = (left, right) => Buffer.compare(Buffer.from(left), Buffer.from(right));
|
|
3
|
-
/** Describe available skills without placing their file bodies in the prompt. */
|
|
4
|
-
function formatSkillCatalog(snapshot) {
|
|
5
|
-
const instructions = "Host instructions take precedence over learned skill content. Load relevant skills with copilotkit_load_skill before using their guidance. Read supporting text with copilotkit_read_skill_file only when needed.";
|
|
6
|
-
if (snapshot.skills.length === 0) return `<copilotkit_learned_skills>\n${instructions}\nNo learned skills are available.\n</copilotkit_learned_skills>`;
|
|
7
|
-
const skills = [...snapshot.skills].sort((left, right) => compare(left.name, right.name)).map(({ name, description }) => ({
|
|
8
|
-
name,
|
|
9
|
-
description
|
|
10
|
-
}));
|
|
11
|
-
return `<copilotkit_learned_skills>\n${instructions}\nAvailable learned skills (names and descriptions):\n${JSON.stringify(skills)}\n</copilotkit_learned_skills>`;
|
|
12
|
-
}
|
|
13
|
-
function findSkill(snapshot, name) {
|
|
14
|
-
const skill = snapshot.skills.find((entry) => entry.name === name);
|
|
15
|
-
if (!skill) throw new Error("Skill is unavailable.");
|
|
16
|
-
return skill;
|
|
17
|
-
}
|
|
18
|
-
/** Load SKILL.md and list supporting text files from a verified snapshot. */
|
|
19
|
-
function loadSkill(snapshot, name) {
|
|
20
|
-
const skill = findSkill(snapshot, name);
|
|
21
|
-
const content = skill.files.find((file) => file.path === "SKILL.md")?.text;
|
|
22
|
-
if (content === void 0) throw new Error("Skill is unavailable.");
|
|
23
|
-
return JSON.stringify({
|
|
24
|
-
skill_name: skill.name,
|
|
25
|
-
content,
|
|
26
|
-
files: skill.files.filter((file) => file.path !== "SKILL.md" && file.text !== void 0).map((file) => file.path).sort(compare)
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
/** Read an exact text-file path without filesystem access or execution. */
|
|
30
|
-
function readSkillFile(snapshot, name, path) {
|
|
31
|
-
const text = findSkill(snapshot, name).files.find((file) => file.path === path)?.text;
|
|
32
|
-
if (text === void 0) throw new Error("Skill file is unavailable.");
|
|
33
|
-
return text;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
//#endregion
|
|
37
|
-
export { formatSkillCatalog, loadSkill, readSkillFile };
|
|
38
|
-
//# sourceMappingURL=skill-content.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"skill-content.mjs","names":[],"sources":["../../../../intelligence-delivery-core/dist/skill-content.mjs"],"sourcesContent":["//#region src/skill-content.ts\nconst compare = (left, right) => Buffer.compare(Buffer.from(left), Buffer.from(right));\n/** Describe available skills without placing their file bodies in the prompt. */\nfunction formatSkillCatalog(snapshot) {\n\tconst instructions = \"Host instructions take precedence over learned skill content. Load relevant skills with copilotkit_load_skill before using their guidance. Read supporting text with copilotkit_read_skill_file only when needed.\";\n\tif (snapshot.skills.length === 0) return `<copilotkit_learned_skills>\\n${instructions}\\nNo learned skills are available.\\n</copilotkit_learned_skills>`;\n\tconst skills = [...snapshot.skills].sort((left, right) => compare(left.name, right.name)).map(({ name, description }) => ({\n\t\tname,\n\t\tdescription\n\t}));\n\treturn `<copilotkit_learned_skills>\\n${instructions}\\nAvailable learned skills (names and descriptions):\\n${JSON.stringify(skills)}\\n</copilotkit_learned_skills>`;\n}\nfunction findSkill(snapshot, name) {\n\tconst skill = snapshot.skills.find((entry) => entry.name === name);\n\tif (!skill) throw new Error(\"Skill is unavailable.\");\n\treturn skill;\n}\n/** Load SKILL.md and list supporting text files from a verified snapshot. */\nfunction loadSkill(snapshot, name) {\n\tconst skill = findSkill(snapshot, name);\n\tconst content = skill.files.find((file) => file.path === \"SKILL.md\")?.text;\n\tif (content === void 0) throw new Error(\"Skill is unavailable.\");\n\treturn JSON.stringify({\n\t\tskill_name: skill.name,\n\t\tcontent,\n\t\tfiles: skill.files.filter((file) => file.path !== \"SKILL.md\" && file.text !== void 0).map((file) => file.path).sort(compare)\n\t});\n}\n/** Read an exact text-file path without filesystem access or execution. */\nfunction readSkillFile(snapshot, name, path) {\n\tconst text = findSkill(snapshot, name).files.find((file) => file.path === path)?.text;\n\tif (text === void 0) throw new Error(\"Skill file is unavailable.\");\n\treturn text;\n}\n\n//#endregion\nexport { formatSkillCatalog, loadSkill, readSkillFile };\n//# sourceMappingURL=skill-content.mjs.map"],"mappings":";AACA,MAAM,WAAW,MAAM,UAAU,OAAO,QAAQ,OAAO,KAAK,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC;;AAEtF,SAAS,mBAAmB,UAAU;CACrC,MAAM,eAAe;AACrB,KAAI,SAAS,OAAO,WAAW,EAAG,QAAO,gCAAgC,aAAa;CACtF,MAAM,SAAS,CAAC,GAAG,SAAS,OAAO,CAAC,MAAM,MAAM,UAAU,QAAQ,KAAK,MAAM,MAAM,KAAK,CAAC,CAAC,KAAK,EAAE,MAAM,mBAAmB;EACzH;EACA;EACA,EAAE;AACH,QAAO,gCAAgC,aAAa,wDAAwD,KAAK,UAAU,OAAO,CAAC;;AAEpI,SAAS,UAAU,UAAU,MAAM;CAClC,MAAM,QAAQ,SAAS,OAAO,MAAM,UAAU,MAAM,SAAS,KAAK;AAClE,KAAI,CAAC,MAAO,OAAM,IAAI,MAAM,wBAAwB;AACpD,QAAO;;;AAGR,SAAS,UAAU,UAAU,MAAM;CAClC,MAAM,QAAQ,UAAU,UAAU,KAAK;CACvC,MAAM,UAAU,MAAM,MAAM,MAAM,SAAS,KAAK,SAAS,WAAW,EAAE;AACtE,KAAI,YAAY,KAAK,EAAG,OAAM,IAAI,MAAM,wBAAwB;AAChE,QAAO,KAAK,UAAU;EACrB,YAAY,MAAM;EAClB;EACA,OAAO,MAAM,MAAM,QAAQ,SAAS,KAAK,SAAS,cAAc,KAAK,SAAS,KAAK,EAAE,CAAC,KAAK,SAAS,KAAK,KAAK,CAAC,KAAK,QAAQ;EAC5H,CAAC;;;AAGH,SAAS,cAAc,UAAU,MAAM,MAAM;CAC5C,MAAM,OAAO,UAAU,UAAU,KAAK,CAAC,MAAM,MAAM,SAAS,KAAK,SAAS,KAAK,EAAE;AACjF,KAAI,SAAS,KAAK,EAAG,OAAM,IAAI,MAAM,6BAA6B;AAClE,QAAO"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
const require_errors = require('./errors.cjs');
|
|
2
|
-
const require_archive = require('./archive.cjs');
|
|
3
|
-
let node_crypto = require("node:crypto");
|
|
4
|
-
let _copilotkit_runtime_v2 = require("@copilotkit/runtime/v2");
|
|
5
|
-
|
|
6
|
-
//#region ../intelligence-delivery-core/dist/snapshot.mjs
|
|
7
|
-
function object(value) {
|
|
8
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
9
|
-
}
|
|
10
|
-
function sha256(bytes) {
|
|
11
|
-
return (0, node_crypto.createHash)("sha256").update(bytes).digest("hex");
|
|
12
|
-
}
|
|
13
|
-
function utf8(bytes) {
|
|
14
|
-
try {
|
|
15
|
-
return new TextDecoder("utf-8", {
|
|
16
|
-
fatal: true,
|
|
17
|
-
ignoreBOM: true
|
|
18
|
-
}).decode(bytes);
|
|
19
|
-
} catch {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/** Validate a replacement fully before it can become an invocation snapshot. */
|
|
24
|
-
async function validateSnapshot(response, signal) {
|
|
25
|
-
try {
|
|
26
|
-
if (!object(response) || !(response.bytes instanceof Uint8Array) || typeof response.revision !== "string" || typeof response.etag !== "string" || typeof response.contentType !== "string") throw require_errors.invalidSnapshot();
|
|
27
|
-
const { revision, etag, contentType } = response;
|
|
28
|
-
if (response.status !== "snapshot" || response.bytes.byteLength > require_archive.MAX_SNAPSHOT_BYTES || contentType.split(";", 1)[0]?.trim().toLowerCase() !== "application/zip" || !revision || !/^"[a-f0-9]{64}"$/.test(etag)) throw require_errors.invalidSnapshot();
|
|
29
|
-
const bytes = Buffer.from(response.bytes);
|
|
30
|
-
if (`"${sha256(bytes)}"` !== etag) throw require_errors.invalidSnapshot();
|
|
31
|
-
const archive = await require_archive.readArchive(bytes, signal);
|
|
32
|
-
const manifestBytes = archive.get("manifest.json");
|
|
33
|
-
if (!manifestBytes) throw require_errors.invalidSnapshot();
|
|
34
|
-
const decoded = utf8(manifestBytes);
|
|
35
|
-
if (decoded === void 0) throw require_errors.invalidSnapshot();
|
|
36
|
-
const manifest = JSON.parse(decoded);
|
|
37
|
-
if (!object(manifest)) throw require_errors.invalidSnapshot();
|
|
38
|
-
if (typeof manifest.schemaVersion === "number" && manifest.schemaVersion !== 1) throw new _copilotkit_runtime_v2.LearnedSkillsError("UNSUPPORTED_SERVER", false);
|
|
39
|
-
if (manifest.schemaVersion !== 1 || manifest.revision !== revision || !Array.isArray(manifest.skills)) throw require_errors.invalidSnapshot();
|
|
40
|
-
const expected = new Set(["manifest.json"]);
|
|
41
|
-
let previousName;
|
|
42
|
-
const skills = [];
|
|
43
|
-
for (const skill of manifest.skills) {
|
|
44
|
-
if (!object(skill) || typeof skill.name !== "string" || !require_archive.safeRelativePath(skill.name) || skill.name.includes("/") || previousName !== void 0 && Buffer.compare(Buffer.from(previousName), Buffer.from(skill.name)) >= 0 || typeof skill.description !== "string" || !Array.isArray(skill.files)) throw require_errors.invalidSnapshot();
|
|
45
|
-
previousName = skill.name;
|
|
46
|
-
let previousPath;
|
|
47
|
-
let hasSkill = false;
|
|
48
|
-
const files = [];
|
|
49
|
-
for (const file of skill.files) {
|
|
50
|
-
if (!object(file) || typeof file.path !== "string" || !require_archive.safeRelativePath(file.path) || previousPath !== void 0 && Buffer.compare(Buffer.from(previousPath), Buffer.from(file.path)) >= 0 || typeof file.size !== "number" || !Number.isSafeInteger(file.size) || file.size < 0 || typeof file.sha256 !== "string" || !/^[a-f0-9]{64}$/.test(file.sha256)) throw require_errors.invalidSnapshot();
|
|
51
|
-
previousPath = file.path;
|
|
52
|
-
const path = `${skill.name}/${file.path}`;
|
|
53
|
-
if (expected.has(path)) throw require_errors.invalidSnapshot();
|
|
54
|
-
expected.add(path);
|
|
55
|
-
const content = archive.get(path);
|
|
56
|
-
if (!content || content.length !== file.size || sha256(content) !== file.sha256) throw require_errors.invalidSnapshot();
|
|
57
|
-
const text = utf8(content);
|
|
58
|
-
if (file.path === "SKILL.md") {
|
|
59
|
-
if (text === void 0) throw require_errors.invalidSnapshot();
|
|
60
|
-
hasSkill = true;
|
|
61
|
-
}
|
|
62
|
-
files.push(Object.freeze({
|
|
63
|
-
path: file.path,
|
|
64
|
-
size: file.size,
|
|
65
|
-
sha256: file.sha256,
|
|
66
|
-
...text !== void 0 ? { text } : {}
|
|
67
|
-
}));
|
|
68
|
-
}
|
|
69
|
-
if (!hasSkill) throw require_errors.invalidSnapshot();
|
|
70
|
-
skills.push(Object.freeze({
|
|
71
|
-
name: skill.name,
|
|
72
|
-
description: skill.description,
|
|
73
|
-
files: Object.freeze(files)
|
|
74
|
-
}));
|
|
75
|
-
}
|
|
76
|
-
if (expected.size !== archive.size || [...archive.keys()].some((path) => !expected.has(path))) throw require_errors.invalidSnapshot();
|
|
77
|
-
return Object.freeze({
|
|
78
|
-
revision,
|
|
79
|
-
etag,
|
|
80
|
-
skills: Object.freeze(skills)
|
|
81
|
-
});
|
|
82
|
-
} catch (error) {
|
|
83
|
-
if (signal?.aborted) throw signal.reason;
|
|
84
|
-
if (error instanceof _copilotkit_runtime_v2.LearnedSkillsError) throw error;
|
|
85
|
-
throw require_errors.invalidSnapshot(error);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
//#endregion
|
|
90
|
-
exports.validateSnapshot = validateSnapshot;
|
|
91
|
-
//# sourceMappingURL=snapshot.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.cjs","names":["invalidSnapshot","MAX_SNAPSHOT_BYTES","readArchive","SkillDeliveryError","safeRelativePath"],"sources":["../../../../intelligence-delivery-core/dist/snapshot.mjs"],"sourcesContent":["import { SkillDeliveryError, invalidSnapshot } from \"./errors.mjs\";\nimport { MAX_SNAPSHOT_BYTES, readArchive, safeRelativePath } from \"./archive.mjs\";\nimport { createHash } from \"node:crypto\";\n\n//#region src/snapshot.ts\nfunction object(value) {\n\treturn value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\nfunction sha256(bytes) {\n\treturn createHash(\"sha256\").update(bytes).digest(\"hex\");\n}\nfunction utf8(bytes) {\n\ttry {\n\t\treturn new TextDecoder(\"utf-8\", {\n\t\t\tfatal: true,\n\t\t\tignoreBOM: true\n\t\t}).decode(bytes);\n\t} catch {\n\t\treturn;\n\t}\n}\n/** Validate a replacement fully before it can become an invocation snapshot. */\nasync function validateSnapshot(response, signal) {\n\ttry {\n\t\tif (!object(response) || !(response.bytes instanceof Uint8Array) || typeof response.revision !== \"string\" || typeof response.etag !== \"string\" || typeof response.contentType !== \"string\") throw invalidSnapshot();\n\t\tconst { revision, etag, contentType } = response;\n\t\tif (response.status !== \"snapshot\" || response.bytes.byteLength > MAX_SNAPSHOT_BYTES || contentType.split(\";\", 1)[0]?.trim().toLowerCase() !== \"application/zip\" || !revision || !/^\"[a-f0-9]{64}\"$/.test(etag)) throw invalidSnapshot();\n\t\tconst bytes = Buffer.from(response.bytes);\n\t\tif (`\"${sha256(bytes)}\"` !== etag) throw invalidSnapshot();\n\t\tconst archive = await readArchive(bytes, signal);\n\t\tconst manifestBytes = archive.get(\"manifest.json\");\n\t\tif (!manifestBytes) throw invalidSnapshot();\n\t\tconst decoded = utf8(manifestBytes);\n\t\tif (decoded === void 0) throw invalidSnapshot();\n\t\tconst manifest = JSON.parse(decoded);\n\t\tif (!object(manifest)) throw invalidSnapshot();\n\t\tif (typeof manifest.schemaVersion === \"number\" && manifest.schemaVersion !== 1) throw new SkillDeliveryError(\"UNSUPPORTED_SERVER\", false);\n\t\tif (manifest.schemaVersion !== 1 || manifest.revision !== revision || !Array.isArray(manifest.skills)) throw invalidSnapshot();\n\t\tconst expected = new Set([\"manifest.json\"]);\n\t\tlet previousName;\n\t\tconst skills = [];\n\t\tfor (const skill of manifest.skills) {\n\t\t\tif (!object(skill) || typeof skill.name !== \"string\" || !safeRelativePath(skill.name) || skill.name.includes(\"/\") || previousName !== void 0 && Buffer.compare(Buffer.from(previousName), Buffer.from(skill.name)) >= 0 || typeof skill.description !== \"string\" || !Array.isArray(skill.files)) throw invalidSnapshot();\n\t\t\tpreviousName = skill.name;\n\t\t\tlet previousPath;\n\t\t\tlet hasSkill = false;\n\t\t\tconst files = [];\n\t\t\tfor (const file of skill.files) {\n\t\t\t\tif (!object(file) || typeof file.path !== \"string\" || !safeRelativePath(file.path) || previousPath !== void 0 && Buffer.compare(Buffer.from(previousPath), Buffer.from(file.path)) >= 0 || typeof file.size !== \"number\" || !Number.isSafeInteger(file.size) || file.size < 0 || typeof file.sha256 !== \"string\" || !/^[a-f0-9]{64}$/.test(file.sha256)) throw invalidSnapshot();\n\t\t\t\tpreviousPath = file.path;\n\t\t\t\tconst path = `${skill.name}/${file.path}`;\n\t\t\t\tif (expected.has(path)) throw invalidSnapshot();\n\t\t\t\texpected.add(path);\n\t\t\t\tconst content = archive.get(path);\n\t\t\t\tif (!content || content.length !== file.size || sha256(content) !== file.sha256) throw invalidSnapshot();\n\t\t\t\tconst text = utf8(content);\n\t\t\t\tif (file.path === \"SKILL.md\") {\n\t\t\t\t\tif (text === void 0) throw invalidSnapshot();\n\t\t\t\t\thasSkill = true;\n\t\t\t\t}\n\t\t\t\tfiles.push(Object.freeze({\n\t\t\t\t\tpath: file.path,\n\t\t\t\t\tsize: file.size,\n\t\t\t\t\tsha256: file.sha256,\n\t\t\t\t\t...text !== void 0 ? { text } : {}\n\t\t\t\t}));\n\t\t\t}\n\t\t\tif (!hasSkill) throw invalidSnapshot();\n\t\t\tskills.push(Object.freeze({\n\t\t\t\tname: skill.name,\n\t\t\t\tdescription: skill.description,\n\t\t\t\tfiles: Object.freeze(files)\n\t\t\t}));\n\t\t}\n\t\tif (expected.size !== archive.size || [...archive.keys()].some((path) => !expected.has(path))) throw invalidSnapshot();\n\t\treturn Object.freeze({\n\t\t\trevision,\n\t\t\tetag,\n\t\t\tskills: Object.freeze(skills)\n\t\t});\n\t} catch (error) {\n\t\tif (signal?.aborted) throw signal.reason;\n\t\tif (error instanceof SkillDeliveryError) throw error;\n\t\tthrow invalidSnapshot(error);\n\t}\n}\n\n//#endregion\nexport { validateSnapshot };\n//# sourceMappingURL=snapshot.mjs.map"],"mappings":";;;;;;AAKA,SAAS,OAAO,OAAO;AACtB,QAAO,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,MAAM;;AAE5E,SAAS,OAAO,OAAO;AACtB,oCAAkB,SAAS,CAAC,OAAO,MAAM,CAAC,OAAO,MAAM;;AAExD,SAAS,KAAK,OAAO;AACpB,KAAI;AACH,SAAO,IAAI,YAAY,SAAS;GAC/B,OAAO;GACP,WAAW;GACX,CAAC,CAAC,OAAO,MAAM;SACT;AACP;;;;AAI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,CAAC;;AAEJ,OAAI,CAAC,SAAU,OAAMA,gCAAiB;AACtC,UAAO,KAAK,OAAO,OAAO;IACzB,MAAM,MAAM;IACZ,aAAa,MAAM;IACnB,OAAO,OAAO,OAAO,MAAM;IAC3B,CAAC,CAAC;;AAEJ,MAAI,SAAS,SAAS,QAAQ,QAAQ,CAAC,GAAG,QAAQ,MAAM,CAAC,CAAC,MAAM,SAAS,CAAC,SAAS,IAAI,KAAK,CAAC,CAAE,OAAMA,gCAAiB;AACtH,SAAO,OAAO,OAAO;GACpB;GACA;GACA,QAAQ,OAAO,OAAO,OAAO;GAC7B,CAAC;UACM,OAAO;AACf,MAAI,QAAQ,QAAS,OAAM,OAAO;AAClC,MAAI,iBAAiBG,0CAAoB,OAAM;AAC/C,QAAMH,+BAAgB,MAAM"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//#region ../intelligence-delivery-core/dist/snapshot.d.mts
|
|
2
|
-
//#region src/snapshot.d.ts
|
|
3
|
-
interface SnapshotFile {
|
|
4
|
-
readonly path: string;
|
|
5
|
-
readonly size: number;
|
|
6
|
-
readonly sha256: string;
|
|
7
|
-
/** Absent for supporting resources that cannot be decoded as UTF-8 text. */
|
|
8
|
-
readonly text?: string;
|
|
9
|
-
}
|
|
10
|
-
interface SnapshotSkill {
|
|
11
|
-
readonly name: string;
|
|
12
|
-
readonly description: string;
|
|
13
|
-
readonly files: readonly SnapshotFile[];
|
|
14
|
-
}
|
|
15
|
-
interface VerifiedSnapshot {
|
|
16
|
-
readonly revision: string;
|
|
17
|
-
readonly etag: string;
|
|
18
|
-
readonly skills: readonly SnapshotSkill[];
|
|
19
|
-
}
|
|
20
|
-
/** Validate a replacement fully before it can become an invocation snapshot. */
|
|
21
|
-
//#endregion
|
|
22
|
-
export { VerifiedSnapshot };
|
|
23
|
-
//# sourceMappingURL=snapshot.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.d.cts","names":["LearnedSkillsSnapshotResult","SnapshotFile","path","size","sha256","text","SnapshotSkill","name","description","files","VerifiedSnapshot","revision","etag","skills","validateSnapshot","Extract","AbortSignal","Promise","status","response","signal"],"sources":["../../../../intelligence-delivery-core/dist/snapshot.d.mts"],"mappings":";;UAGUC,YAAAA;EAAAA,SACCC,IAAAA;EAAAA,SACAC,IAAAA;EAAAA,SACAC,MAAAA;EAAAA;EAAAA,SAEAC,IAAAA;AAAAA;AAAAA,UAEDC,aAAAA;EAAAA,SACCC,IAAAA;EAAAA,SACAC,WAAAA;EAAAA,SACAC,KAAAA,WAAgBR,YAAAA;AAAAA;AAAAA,UAEjBS,gBAAAA;EAAAA,SACCC,QAAAA;EAAAA,SACAC,IAAAA;EAAAA,SACAC,MAAAA,WAAiBP,aAAAA;AAAAA"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import "@copilotkit/runtime/v2";
|
|
2
|
-
|
|
3
|
-
//#region ../intelligence-delivery-core/dist/snapshot.d.mts
|
|
4
|
-
//#region src/snapshot.d.ts
|
|
5
|
-
interface SnapshotFile {
|
|
6
|
-
readonly path: string;
|
|
7
|
-
readonly size: number;
|
|
8
|
-
readonly sha256: string;
|
|
9
|
-
/** Absent for supporting resources that cannot be decoded as UTF-8 text. */
|
|
10
|
-
readonly text?: string;
|
|
11
|
-
}
|
|
12
|
-
interface SnapshotSkill {
|
|
13
|
-
readonly name: string;
|
|
14
|
-
readonly description: string;
|
|
15
|
-
readonly files: readonly SnapshotFile[];
|
|
16
|
-
}
|
|
17
|
-
interface VerifiedSnapshot {
|
|
18
|
-
readonly revision: string;
|
|
19
|
-
readonly etag: string;
|
|
20
|
-
readonly skills: readonly SnapshotSkill[];
|
|
21
|
-
}
|
|
22
|
-
/** Validate a replacement fully before it can become an invocation snapshot. */
|
|
23
|
-
//#endregion
|
|
24
|
-
export { SnapshotFile, SnapshotSkill, VerifiedSnapshot };
|
|
25
|
-
//# sourceMappingURL=snapshot.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.d.mts","names":["LearnedSkillsSnapshotResult","SnapshotFile","path","size","sha256","text","SnapshotSkill","name","description","files","VerifiedSnapshot","revision","etag","skills","validateSnapshot","Extract","AbortSignal","Promise","status","response","signal"],"sources":["../../../../intelligence-delivery-core/dist/snapshot.d.mts"],"mappings":";;;;UAGUC,YAAAA;EAAAA,SACCC,IAAAA;EAAAA,SACAC,IAAAA;EAAAA,SACAC,MAAAA;EAFAF;EAAAA,SAIAG,IAAAA;AAAAA;AAAAA,UAEDC,aAAAA;EAAAA,SACCC,IAAAA;EAAAA,SACAC,WAAAA;EAAAA,SACAC,KAAAA,WAAgBR,YAAAA;AAAAA;AAAAA,UAEjBS,gBAAAA;EAAAA,SACCC,QAAAA;EAAAA,SACAC,IAAAA;EAAAA,SACAC,MAAAA,WAAiBP,aAAAA;AAAAA"}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { SkillDeliveryError, invalidSnapshot } from "./errors.mjs";
|
|
2
|
-
import { MAX_SNAPSHOT_BYTES, readArchive, safeRelativePath } from "./archive.mjs";
|
|
3
|
-
import { createHash } from "node:crypto";
|
|
4
|
-
|
|
5
|
-
//#region ../intelligence-delivery-core/dist/snapshot.mjs
|
|
6
|
-
function object(value) {
|
|
7
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
8
|
-
}
|
|
9
|
-
function sha256(bytes) {
|
|
10
|
-
return createHash("sha256").update(bytes).digest("hex");
|
|
11
|
-
}
|
|
12
|
-
function utf8(bytes) {
|
|
13
|
-
try {
|
|
14
|
-
return new TextDecoder("utf-8", {
|
|
15
|
-
fatal: true,
|
|
16
|
-
ignoreBOM: true
|
|
17
|
-
}).decode(bytes);
|
|
18
|
-
} catch {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/** Validate a replacement fully before it can become an invocation snapshot. */
|
|
23
|
-
async function validateSnapshot(response, signal) {
|
|
24
|
-
try {
|
|
25
|
-
if (!object(response) || !(response.bytes instanceof Uint8Array) || typeof response.revision !== "string" || typeof response.etag !== "string" || typeof response.contentType !== "string") throw invalidSnapshot();
|
|
26
|
-
const { revision, etag, contentType } = response;
|
|
27
|
-
if (response.status !== "snapshot" || response.bytes.byteLength > MAX_SNAPSHOT_BYTES || contentType.split(";", 1)[0]?.trim().toLowerCase() !== "application/zip" || !revision || !/^"[a-f0-9]{64}"$/.test(etag)) throw invalidSnapshot();
|
|
28
|
-
const bytes = Buffer.from(response.bytes);
|
|
29
|
-
if (`"${sha256(bytes)}"` !== etag) throw invalidSnapshot();
|
|
30
|
-
const archive = await readArchive(bytes, signal);
|
|
31
|
-
const manifestBytes = archive.get("manifest.json");
|
|
32
|
-
if (!manifestBytes) throw invalidSnapshot();
|
|
33
|
-
const decoded = utf8(manifestBytes);
|
|
34
|
-
if (decoded === void 0) throw invalidSnapshot();
|
|
35
|
-
const manifest = JSON.parse(decoded);
|
|
36
|
-
if (!object(manifest)) throw invalidSnapshot();
|
|
37
|
-
if (typeof manifest.schemaVersion === "number" && manifest.schemaVersion !== 1) throw new SkillDeliveryError("UNSUPPORTED_SERVER", false);
|
|
38
|
-
if (manifest.schemaVersion !== 1 || manifest.revision !== revision || !Array.isArray(manifest.skills)) throw invalidSnapshot();
|
|
39
|
-
const expected = new Set(["manifest.json"]);
|
|
40
|
-
let previousName;
|
|
41
|
-
const skills = [];
|
|
42
|
-
for (const skill of manifest.skills) {
|
|
43
|
-
if (!object(skill) || typeof skill.name !== "string" || !safeRelativePath(skill.name) || skill.name.includes("/") || previousName !== void 0 && Buffer.compare(Buffer.from(previousName), Buffer.from(skill.name)) >= 0 || typeof skill.description !== "string" || !Array.isArray(skill.files)) throw invalidSnapshot();
|
|
44
|
-
previousName = skill.name;
|
|
45
|
-
let previousPath;
|
|
46
|
-
let hasSkill = false;
|
|
47
|
-
const files = [];
|
|
48
|
-
for (const file of skill.files) {
|
|
49
|
-
if (!object(file) || typeof file.path !== "string" || !safeRelativePath(file.path) || previousPath !== void 0 && Buffer.compare(Buffer.from(previousPath), Buffer.from(file.path)) >= 0 || typeof file.size !== "number" || !Number.isSafeInteger(file.size) || file.size < 0 || typeof file.sha256 !== "string" || !/^[a-f0-9]{64}$/.test(file.sha256)) throw invalidSnapshot();
|
|
50
|
-
previousPath = file.path;
|
|
51
|
-
const path = `${skill.name}/${file.path}`;
|
|
52
|
-
if (expected.has(path)) throw invalidSnapshot();
|
|
53
|
-
expected.add(path);
|
|
54
|
-
const content = archive.get(path);
|
|
55
|
-
if (!content || content.length !== file.size || sha256(content) !== file.sha256) throw invalidSnapshot();
|
|
56
|
-
const text = utf8(content);
|
|
57
|
-
if (file.path === "SKILL.md") {
|
|
58
|
-
if (text === void 0) throw invalidSnapshot();
|
|
59
|
-
hasSkill = true;
|
|
60
|
-
}
|
|
61
|
-
files.push(Object.freeze({
|
|
62
|
-
path: file.path,
|
|
63
|
-
size: file.size,
|
|
64
|
-
sha256: file.sha256,
|
|
65
|
-
...text !== void 0 ? { text } : {}
|
|
66
|
-
}));
|
|
67
|
-
}
|
|
68
|
-
if (!hasSkill) throw invalidSnapshot();
|
|
69
|
-
skills.push(Object.freeze({
|
|
70
|
-
name: skill.name,
|
|
71
|
-
description: skill.description,
|
|
72
|
-
files: Object.freeze(files)
|
|
73
|
-
}));
|
|
74
|
-
}
|
|
75
|
-
if (expected.size !== archive.size || [...archive.keys()].some((path) => !expected.has(path))) throw invalidSnapshot();
|
|
76
|
-
return Object.freeze({
|
|
77
|
-
revision,
|
|
78
|
-
etag,
|
|
79
|
-
skills: Object.freeze(skills)
|
|
80
|
-
});
|
|
81
|
-
} catch (error) {
|
|
82
|
-
if (signal?.aborted) throw signal.reason;
|
|
83
|
-
if (error instanceof SkillDeliveryError) throw error;
|
|
84
|
-
throw invalidSnapshot(error);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
//#endregion
|
|
89
|
-
export { validateSnapshot };
|
|
90
|
-
//# sourceMappingURL=snapshot.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.mjs","names":[],"sources":["../../../../intelligence-delivery-core/dist/snapshot.mjs"],"sourcesContent":["import { SkillDeliveryError, invalidSnapshot } from \"./errors.mjs\";\nimport { MAX_SNAPSHOT_BYTES, readArchive, safeRelativePath } from \"./archive.mjs\";\nimport { createHash } from \"node:crypto\";\n\n//#region src/snapshot.ts\nfunction object(value) {\n\treturn value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\nfunction sha256(bytes) {\n\treturn createHash(\"sha256\").update(bytes).digest(\"hex\");\n}\nfunction utf8(bytes) {\n\ttry {\n\t\treturn new TextDecoder(\"utf-8\", {\n\t\t\tfatal: true,\n\t\t\tignoreBOM: true\n\t\t}).decode(bytes);\n\t} catch {\n\t\treturn;\n\t}\n}\n/** Validate a replacement fully before it can become an invocation snapshot. */\nasync function validateSnapshot(response, signal) {\n\ttry {\n\t\tif (!object(response) || !(response.bytes instanceof Uint8Array) || typeof response.revision !== \"string\" || typeof response.etag !== \"string\" || typeof response.contentType !== \"string\") throw invalidSnapshot();\n\t\tconst { revision, etag, contentType } = response;\n\t\tif (response.status !== \"snapshot\" || response.bytes.byteLength > MAX_SNAPSHOT_BYTES || contentType.split(\";\", 1)[0]?.trim().toLowerCase() !== \"application/zip\" || !revision || !/^\"[a-f0-9]{64}\"$/.test(etag)) throw invalidSnapshot();\n\t\tconst bytes = Buffer.from(response.bytes);\n\t\tif (`\"${sha256(bytes)}\"` !== etag) throw invalidSnapshot();\n\t\tconst archive = await readArchive(bytes, signal);\n\t\tconst manifestBytes = archive.get(\"manifest.json\");\n\t\tif (!manifestBytes) throw invalidSnapshot();\n\t\tconst decoded = utf8(manifestBytes);\n\t\tif (decoded === void 0) throw invalidSnapshot();\n\t\tconst manifest = JSON.parse(decoded);\n\t\tif (!object(manifest)) throw invalidSnapshot();\n\t\tif (typeof manifest.schemaVersion === \"number\" && manifest.schemaVersion !== 1) throw new SkillDeliveryError(\"UNSUPPORTED_SERVER\", false);\n\t\tif (manifest.schemaVersion !== 1 || manifest.revision !== revision || !Array.isArray(manifest.skills)) throw invalidSnapshot();\n\t\tconst expected = new Set([\"manifest.json\"]);\n\t\tlet previousName;\n\t\tconst skills = [];\n\t\tfor (const skill of manifest.skills) {\n\t\t\tif (!object(skill) || typeof skill.name !== \"string\" || !safeRelativePath(skill.name) || skill.name.includes(\"/\") || previousName !== void 0 && Buffer.compare(Buffer.from(previousName), Buffer.from(skill.name)) >= 0 || typeof skill.description !== \"string\" || !Array.isArray(skill.files)) throw invalidSnapshot();\n\t\t\tpreviousName = skill.name;\n\t\t\tlet previousPath;\n\t\t\tlet hasSkill = false;\n\t\t\tconst files = [];\n\t\t\tfor (const file of skill.files) {\n\t\t\t\tif (!object(file) || typeof file.path !== \"string\" || !safeRelativePath(file.path) || previousPath !== void 0 && Buffer.compare(Buffer.from(previousPath), Buffer.from(file.path)) >= 0 || typeof file.size !== \"number\" || !Number.isSafeInteger(file.size) || file.size < 0 || typeof file.sha256 !== \"string\" || !/^[a-f0-9]{64}$/.test(file.sha256)) throw invalidSnapshot();\n\t\t\t\tpreviousPath = file.path;\n\t\t\t\tconst path = `${skill.name}/${file.path}`;\n\t\t\t\tif (expected.has(path)) throw invalidSnapshot();\n\t\t\t\texpected.add(path);\n\t\t\t\tconst content = archive.get(path);\n\t\t\t\tif (!content || content.length !== file.size || sha256(content) !== file.sha256) throw invalidSnapshot();\n\t\t\t\tconst text = utf8(content);\n\t\t\t\tif (file.path === \"SKILL.md\") {\n\t\t\t\t\tif (text === void 0) throw invalidSnapshot();\n\t\t\t\t\thasSkill = true;\n\t\t\t\t}\n\t\t\t\tfiles.push(Object.freeze({\n\t\t\t\t\tpath: file.path,\n\t\t\t\t\tsize: file.size,\n\t\t\t\t\tsha256: file.sha256,\n\t\t\t\t\t...text !== void 0 ? { text } : {}\n\t\t\t\t}));\n\t\t\t}\n\t\t\tif (!hasSkill) throw invalidSnapshot();\n\t\t\tskills.push(Object.freeze({\n\t\t\t\tname: skill.name,\n\t\t\t\tdescription: skill.description,\n\t\t\t\tfiles: Object.freeze(files)\n\t\t\t}));\n\t\t}\n\t\tif (expected.size !== archive.size || [...archive.keys()].some((path) => !expected.has(path))) throw invalidSnapshot();\n\t\treturn Object.freeze({\n\t\t\trevision,\n\t\t\tetag,\n\t\t\tskills: Object.freeze(skills)\n\t\t});\n\t} catch (error) {\n\t\tif (signal?.aborted) throw signal.reason;\n\t\tif (error instanceof SkillDeliveryError) throw error;\n\t\tthrow invalidSnapshot(error);\n\t}\n}\n\n//#endregion\nexport { validateSnapshot };\n//# sourceMappingURL=snapshot.mjs.map"],"mappings":";;;;;AAKA,SAAS,OAAO,OAAO;AACtB,QAAO,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,MAAM;;AAE5E,SAAS,OAAO,OAAO;AACtB,QAAO,WAAW,SAAS,CAAC,OAAO,MAAM,CAAC,OAAO,MAAM;;AAExD,SAAS,KAAK,OAAO;AACpB,KAAI;AACH,SAAO,IAAI,YAAY,SAAS;GAC/B,OAAO;GACP,WAAW;GACX,CAAC,CAAC,OAAO,MAAM;SACT;AACP;;;;AAIF,eAAe,iBAAiB,UAAU,QAAQ;AACjD,KAAI;AACH,MAAI,CAAC,OAAO,SAAS,IAAI,EAAE,SAAS,iBAAiB,eAAe,OAAO,SAAS,aAAa,YAAY,OAAO,SAAS,SAAS,YAAY,OAAO,SAAS,gBAAgB,SAAU,OAAM,iBAAiB;EACnN,MAAM,EAAE,UAAU,MAAM,gBAAgB;AACxC,MAAI,SAAS,WAAW,cAAc,SAAS,MAAM,aAAa,sBAAsB,YAAY,MAAM,KAAK,EAAE,CAAC,IAAI,MAAM,CAAC,aAAa,KAAK,qBAAqB,CAAC,YAAY,CAAC,mBAAmB,KAAK,KAAK,CAAE,OAAM,iBAAiB;EACxO,MAAM,QAAQ,OAAO,KAAK,SAAS,MAAM;AACzC,MAAI,IAAI,OAAO,MAAM,CAAC,O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