@inupedia/spotlight-client 0.2.14 → 0.2.16

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 (55) hide show
  1. package/dist/node/capabilities/skillFileValidator.d.ts +0 -8
  2. package/dist/node/capabilities/skillFileValidator.d.ts.map +1 -1
  3. package/dist/node/capabilities/skillFileValidator.js +26 -46
  4. package/dist/node/index.d.ts +0 -7
  5. package/dist/node/index.d.ts.map +1 -1
  6. package/dist/node/index.js +0 -6
  7. package/dist/vite/index.d.ts +0 -4
  8. package/dist/vite/index.d.ts.map +1 -1
  9. package/dist/vite/index.js +0 -3
  10. package/package.json +6 -8
  11. package/dist/node/capabilities/canonicalJson.d.ts +0 -7
  12. package/dist/node/capabilities/canonicalJson.d.ts.map +0 -1
  13. package/dist/node/capabilities/canonicalJson.js +0 -122
  14. package/dist/node/capabilities/capabilityArtifact.d.ts +0 -13
  15. package/dist/node/capabilities/capabilityArtifact.d.ts.map +0 -1
  16. package/dist/node/capabilities/capabilityArtifact.js +0 -31
  17. package/dist/node/capabilities/capabilityArtifactError.d.ts +0 -7
  18. package/dist/node/capabilities/capabilityArtifactError.d.ts.map +0 -1
  19. package/dist/node/capabilities/capabilityArtifactError.js +0 -19
  20. package/dist/node/capabilities/capabilityArtifactTypes.d.ts +0 -32
  21. package/dist/node/capabilities/capabilityArtifactTypes.d.ts.map +0 -1
  22. package/dist/node/capabilities/capabilityArtifactTypes.js +0 -1
  23. package/dist/node/capabilities/capabilityFileMap.d.ts +0 -17
  24. package/dist/node/capabilities/capabilityFileMap.d.ts.map +0 -1
  25. package/dist/node/capabilities/capabilityFileMap.js +0 -235
  26. package/dist/node/capabilities/deterministicGzip.d.ts +0 -2
  27. package/dist/node/capabilities/deterministicGzip.d.ts.map +0 -1
  28. package/dist/node/capabilities/deterministicGzip.js +0 -51
  29. package/dist/node/capabilities/deterministicTar.d.ts +0 -6
  30. package/dist/node/capabilities/deterministicTar.d.ts.map +0 -1
  31. package/dist/node/capabilities/deterministicTar.js +0 -137
  32. package/dist/node/capabilities/skillDirectoryLoader.d.ts +0 -24
  33. package/dist/node/capabilities/skillDirectoryLoader.d.ts.map +0 -1
  34. package/dist/node/capabilities/skillDirectoryLoader.js +0 -308
  35. package/dist/node/capabilities/toolManifest.d.ts +0 -12
  36. package/dist/node/capabilities/toolManifest.d.ts.map +0 -1
  37. package/dist/node/capabilities/toolManifest.js +0 -111
  38. package/dist/vite/capabilityBuild.d.ts +0 -9
  39. package/dist/vite/capabilityBuild.d.ts.map +0 -1
  40. package/dist/vite/capabilityBuild.js +0 -141
  41. package/dist/vite/capabilityBuildTypes.d.ts +0 -29
  42. package/dist/vite/capabilityBuildTypes.d.ts.map +0 -1
  43. package/dist/vite/capabilityBuildTypes.js +0 -1
  44. package/dist/vite/capabilityDevMiddleware.d.ts +0 -5
  45. package/dist/vite/capabilityDevMiddleware.d.ts.map +0 -1
  46. package/dist/vite/capabilityDevMiddleware.js +0 -40
  47. package/dist/vite/capabilityVirtualModule.d.ts +0 -11
  48. package/dist/vite/capabilityVirtualModule.d.ts.map +0 -1
  49. package/dist/vite/capabilityVirtualModule.js +0 -43
  50. package/dist/vite/capabilityVirtualModuleTypes.d.ts +0 -12
  51. package/dist/vite/capabilityVirtualModuleTypes.d.ts.map +0 -1
  52. package/dist/vite/capabilityVirtualModuleTypes.js +0 -1
  53. package/dist/vite/spotlightCapabilities.d.ts +0 -4
  54. package/dist/vite/spotlightCapabilities.d.ts.map +0 -1
  55. package/dist/vite/spotlightCapabilities.js +0 -165
@@ -1,235 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { isProxy } from "node:util/types";
3
- import { canonicalizeJson, compareUtf16, containsLoneSurrogate, } from "./canonicalJson.js";
4
- import { CapabilityArtifactError } from "./capabilityArtifactError.js";
5
- const CANONICAL_SKILL_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
6
- const SHA256_DIGEST = /^sha256:[a-f0-9]{64}$/;
7
- const textEncoder = new TextEncoder();
8
- const MEDIA_TYPES = {
9
- ".md": "text/markdown; charset=utf-8",
10
- ".txt": "text/plain; charset=utf-8",
11
- ".json": "application/json",
12
- ".yaml": "application/yaml",
13
- ".yml": "application/yaml",
14
- ".js": "text/javascript; charset=utf-8",
15
- ".mjs": "text/javascript; charset=utf-8",
16
- ".cjs": "text/javascript; charset=utf-8",
17
- ".ts": "text/typescript; charset=utf-8",
18
- ".tsx": "text/tsx; charset=utf-8",
19
- ".css": "text/css; charset=utf-8",
20
- ".html": "text/html; charset=utf-8",
21
- ".svg": "image/svg+xml",
22
- ".png": "image/png",
23
- ".jpg": "image/jpeg",
24
- ".jpeg": "image/jpeg",
25
- ".webp": "image/webp",
26
- ".gif": "image/gif",
27
- ".pdf": "application/pdf",
28
- ".mp4": "video/mp4",
29
- ".webm": "video/webm",
30
- ".wasm": "application/wasm",
31
- };
32
- function invalidInput(message) {
33
- throw new CapabilityArtifactError("ARTIFACT_INPUT_INVALID", message);
34
- }
35
- function isCanonicalArrayIndex(key) {
36
- if (!/^(?:0|[1-9]\d*)$/.test(key))
37
- return false;
38
- const index = Number(key);
39
- return (Number.isInteger(index) &&
40
- index >= 0 &&
41
- index <= 0xfffffffe &&
42
- String(index) === key);
43
- }
44
- function readDenseDataArray(value, label) {
45
- if (isProxy(value))
46
- invalidInput(`${label} must not be a Proxy`);
47
- if (!Array.isArray(value))
48
- invalidInput(`${label} must be an array`);
49
- const keys = [];
50
- for (const key of Reflect.ownKeys(value)) {
51
- if (key === "length")
52
- continue;
53
- if (typeof key !== "string" || !isCanonicalArrayIndex(key)) {
54
- invalidInput(`${label} contains a non-index property`);
55
- }
56
- keys.push(key);
57
- }
58
- if (keys.length !== value.length)
59
- invalidInput(`${label} must be dense`);
60
- keys.sort((left, right) => Number(left) - Number(right));
61
- return keys.map((key) => {
62
- const descriptor = Object.getOwnPropertyDescriptor(value, key);
63
- if (!descriptor?.enumerable || !("value" in descriptor)) {
64
- invalidInput(`${label}[${key}] must be an enumerable data property`);
65
- }
66
- return descriptor.value;
67
- });
68
- }
69
- function readDataRecord(value, label, allowedFields) {
70
- if (isProxy(value))
71
- invalidInput(`${label} must not be a Proxy`);
72
- if (value === null || typeof value !== "object" || Array.isArray(value)) {
73
- invalidInput(`${label} must be a plain object`);
74
- }
75
- const prototype = Object.getPrototypeOf(value);
76
- if (prototype !== Object.prototype && prototype !== null) {
77
- invalidInput(`${label} must be a plain object`);
78
- }
79
- const record = {};
80
- for (const key of Reflect.ownKeys(value)) {
81
- if (typeof key !== "string" || !allowedFields.has(key)) {
82
- invalidInput(`${label} contains an unknown field`);
83
- }
84
- const descriptor = Object.getOwnPropertyDescriptor(value, key);
85
- if (!descriptor?.enumerable || !("value" in descriptor)) {
86
- invalidInput(`${label}.${key} must be an enumerable data property`);
87
- }
88
- record[key] = descriptor.value;
89
- }
90
- return record;
91
- }
92
- function sha256(bytes) {
93
- return `sha256:${createHash("sha256").update(bytes).digest("hex")}`;
94
- }
95
- function byteLength(value) {
96
- return textEncoder.encode(value).byteLength;
97
- }
98
- function canRepresentUstarPath(path) {
99
- if (byteLength(path) <= 100)
100
- return true;
101
- for (let index = path.lastIndexOf("/"); index > 0; index = path.lastIndexOf("/", index - 1)) {
102
- const prefix = path.slice(0, index);
103
- const name = path.slice(index + 1);
104
- if (name.length > 0 && byteLength(prefix) <= 155 && byteLength(name) <= 100) {
105
- return true;
106
- }
107
- }
108
- return false;
109
- }
110
- function validateSkillName(name) {
111
- if (typeof name !== "string") {
112
- invalidInput("Skill name must be a string");
113
- }
114
- if (!CANONICAL_SKILL_NAME.test(name) || name.length > 64) {
115
- throw new CapabilityArtifactError("ARTIFACT_PATH_INVALID", `Invalid canonical Skill name: ${name}`);
116
- }
117
- }
118
- function validateRelativePath(relativePath) {
119
- if (typeof relativePath !== "string") {
120
- invalidInput("Skill relativePath must be a string");
121
- }
122
- if (relativePath.length === 0 ||
123
- relativePath.startsWith("/") ||
124
- /^[A-Za-z]:/.test(relativePath) ||
125
- relativePath.includes("\\") ||
126
- relativePath.includes("\0") ||
127
- containsLoneSurrogate(relativePath) ||
128
- relativePath.endsWith("/")) {
129
- throw new CapabilityArtifactError("ARTIFACT_PATH_INVALID", `Invalid Skill relative path: ${relativePath}`);
130
- }
131
- const segments = relativePath.split("/");
132
- if (segments.some((segment) => segment === "" || segment === "." || segment === "..")) {
133
- throw new CapabilityArtifactError("ARTIFACT_PATH_INVALID", `Invalid Skill relative path segment: ${relativePath}`);
134
- }
135
- }
136
- function ensureUstarPath(path) {
137
- if (!canRepresentUstarPath(path)) {
138
- throw new CapabilityArtifactError("ARTIFACT_PATH_USTAR_UNREPRESENTABLE", `Path cannot be represented by POSIX USTAR: ${path}`);
139
- }
140
- }
141
- function inferMediaType(path) {
142
- const filename = path.slice(path.lastIndexOf("/") + 1);
143
- const dot = filename.lastIndexOf(".");
144
- const extension = dot >= 0 ? filename.slice(dot).toLowerCase() : "";
145
- return MEDIA_TYPES[extension] ?? "application/octet-stream";
146
- }
147
- function createPayload(path, sourceBytes, mediaType) {
148
- const bytes = Uint8Array.from(sourceBytes);
149
- if (!Number.isSafeInteger(bytes.byteLength)) {
150
- throw new CapabilityArtifactError("ARTIFACT_SIZE_OVERFLOW", `Payload byte length exceeds safe integer range: ${path}`);
151
- }
152
- return {
153
- path,
154
- bytes,
155
- sha256: sha256(bytes),
156
- byteLength: bytes.byteLength,
157
- mediaType,
158
- };
159
- }
160
- function addPayload(payloads, seenPaths, payload) {
161
- if (seenPaths.has(payload.path)) {
162
- throw new CapabilityArtifactError("ARTIFACT_PATH_DUPLICATE", `Duplicate Artifact payload path: ${payload.path}`);
163
- }
164
- seenPaths.add(payload.path);
165
- payloads.push(payload);
166
- }
167
- export function buildCapabilityFileMapV1(input) {
168
- const root = readDataRecord(input, "Capability file-map input", new Set(["skills", "toolManifestBytes"]));
169
- if (isProxy(root.toolManifestBytes) ||
170
- !(root.toolManifestBytes instanceof Uint8Array)) {
171
- invalidInput("toolManifestBytes must be a Uint8Array");
172
- }
173
- const skills = readDenseDataArray(root.skills, "skills");
174
- const payloads = [];
175
- const seenPaths = new Set();
176
- addPayload(payloads, seenPaths, createPayload("tool-manifest.json", root.toolManifestBytes, "application/json"));
177
- for (const [skillIndex, skillValue] of skills.entries()) {
178
- const skill = readDataRecord(skillValue, `skills[${skillIndex}]`, new Set(["name", "files"]));
179
- validateSkillName(skill.name);
180
- const files = readDenseDataArray(skill.files, `skills[${skillIndex}].files`);
181
- for (const [fileIndex, fileValue] of files.entries()) {
182
- const file = readDataRecord(fileValue, `skills[${skillIndex}].files[${fileIndex}]`, new Set(["relativePath", "bytes", "mediaType"]));
183
- validateRelativePath(file.relativePath);
184
- if (isProxy(file.bytes) || !(file.bytes instanceof Uint8Array)) {
185
- invalidInput(`skills[${skillIndex}].files[${fileIndex}].bytes must be a Uint8Array`);
186
- }
187
- if (file.mediaType !== undefined &&
188
- (typeof file.mediaType !== "string" || file.mediaType.trim().length === 0)) {
189
- invalidInput(`skills[${skillIndex}].files[${fileIndex}].mediaType must be a non-empty string`);
190
- }
191
- const path = `skills/${skill.name}/${file.relativePath}`;
192
- ensureUstarPath(path);
193
- addPayload(payloads, seenPaths, createPayload(path, file.bytes, typeof file.mediaType === "string"
194
- ? file.mediaType
195
- : inferMediaType(path)));
196
- }
197
- }
198
- payloads.sort((left, right) => compareUtf16(left.path, right.path));
199
- const candidate = {
200
- schemaVersion: "spotlight.capability-manifest/1",
201
- files: payloads.map(({ path, sha256: digest, byteLength: length, mediaType }) => ({
202
- path,
203
- sha256: digest,
204
- byteLength: length,
205
- mediaType,
206
- })),
207
- };
208
- const manifestBytes = canonicalizeJson(candidate);
209
- const manifest = JSON.parse(new TextDecoder().decode(manifestBytes));
210
- return {
211
- payloads,
212
- manifest,
213
- manifestBytes,
214
- manifestDigest: sha256(manifestBytes),
215
- };
216
- }
217
- export function computeArtifactDigestV1(input) {
218
- if (!SHA256_DIGEST.test(input.manifestDigest) || !SHA256_DIGEST.test(input.toolManifestDigest)) {
219
- throw new CapabilityArtifactError("ARTIFACT_JSON_NOT_IJSON", "Artifact preimage contains an invalid manifest digest");
220
- }
221
- const payloadDigests = input.payloads
222
- .map(({ path, sha256: digest }) => {
223
- if (!SHA256_DIGEST.test(digest)) {
224
- throw new CapabilityArtifactError("ARTIFACT_JSON_NOT_IJSON", `Artifact preimage contains an invalid payload digest: ${path}`);
225
- }
226
- return { path, sha256: digest };
227
- })
228
- .sort((left, right) => compareUtf16(left.path, right.path));
229
- return sha256(canonicalizeJson({
230
- artifactVersion: "spotlight.capability-artifact/1",
231
- manifestDigest: input.manifestDigest,
232
- toolManifestDigest: input.toolManifestDigest,
233
- payloadDigests,
234
- }));
235
- }
@@ -1,2 +0,0 @@
1
- export declare function encodeDeterministicGzipV1(input: Uint8Array): Uint8Array;
2
- //# sourceMappingURL=deterministicGzip.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deterministicGzip.d.ts","sourceRoot":"","sources":["../../../src/node/capabilities/deterministicGzip.ts"],"names":[],"mappings":"AAuCA,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CA0BvE"}
@@ -1,51 +0,0 @@
1
- import { deflateSync } from "fflate";
2
- import { CapabilityArtifactError } from "./capabilityArtifactError.js";
3
- const GZIP_HEADER = Uint8Array.from([
4
- 0x1f,
5
- 0x8b,
6
- 8,
7
- 0,
8
- 0,
9
- 0,
10
- 0,
11
- 0,
12
- 2,
13
- 255,
14
- ]);
15
- const GZIP_FOOTER_SIZE = 8;
16
- const CRC32_TABLE = createCrc32Table();
17
- function createCrc32Table() {
18
- const table = new Uint32Array(256);
19
- for (let value = 0; value < table.length; value += 1) {
20
- let crc = value;
21
- for (let bit = 0; bit < 8; bit += 1) {
22
- crc = (crc >>> 1) ^ (crc & 1 ? 0xedb88320 : 0);
23
- }
24
- table[value] = crc >>> 0;
25
- }
26
- return table;
27
- }
28
- function crc32(bytes) {
29
- let crc = 0xffffffff;
30
- for (const byte of bytes) {
31
- crc = (crc >>> 8) ^ (CRC32_TABLE[(crc ^ byte) & 0xff] ?? 0);
32
- }
33
- return (crc ^ 0xffffffff) >>> 0;
34
- }
35
- export function encodeDeterministicGzipV1(input) {
36
- const compressed = Uint8Array.from(deflateSync(input, {
37
- level: 9,
38
- mem: 8,
39
- }));
40
- const totalLength = GZIP_HEADER.byteLength + compressed.byteLength + GZIP_FOOTER_SIZE;
41
- if (!Number.isSafeInteger(totalLength)) {
42
- throw new CapabilityArtifactError("ARTIFACT_SIZE_OVERFLOW", "gzip output exceeds the safe integer range");
43
- }
44
- const output = new Uint8Array(totalLength);
45
- output.set(GZIP_HEADER, 0);
46
- output.set(compressed, GZIP_HEADER.byteLength);
47
- const footer = new DataView(output.buffer, output.byteOffset + output.byteLength - GZIP_FOOTER_SIZE, GZIP_FOOTER_SIZE);
48
- footer.setUint32(0, crc32(input), true);
49
- footer.setUint32(4, input.byteLength >>> 0, true);
50
- return output;
51
- }
@@ -1,6 +0,0 @@
1
- export interface TarFileEntryV1 {
2
- path: string;
3
- bytes: Uint8Array;
4
- }
5
- export declare function encodeDeterministicUstarV1(files: TarFileEntryV1[]): Uint8Array;
6
- //# sourceMappingURL=deterministicTar.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deterministicTar.d.ts","sourceRoot":"","sources":["../../../src/node/capabilities/deterministicTar.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,UAAU,CAAC;CACnB;AAqKD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,UAAU,CA2B9E"}
@@ -1,137 +0,0 @@
1
- import { compareUtf16, containsLoneSurrogate } from "./canonicalJson.js";
2
- import { CapabilityArtifactError } from "./capabilityArtifactError.js";
3
- const TAR_BLOCK_SIZE = 512;
4
- const textEncoder = new TextEncoder();
5
- function failInvalidPath(path) {
6
- throw new CapabilityArtifactError("ARTIFACT_PATH_INVALID", `Invalid USTAR file path: ${path}`);
7
- }
8
- function validateFilePath(path) {
9
- if (path.length === 0 ||
10
- path.startsWith("/") ||
11
- /^[A-Za-z]:/.test(path) ||
12
- path.includes("\\") ||
13
- path.includes("\0") ||
14
- containsLoneSurrogate(path) ||
15
- path.endsWith("/")) {
16
- failInvalidPath(path);
17
- }
18
- if (path.split("/").some((segment) => segment === "" || segment === "." || segment === "..")) {
19
- failInvalidPath(path);
20
- }
21
- }
22
- function byteLength(value) {
23
- return textEncoder.encode(value).byteLength;
24
- }
25
- function splitUstarPath(path) {
26
- if (byteLength(path) <= 100)
27
- return { name: path, prefix: "" };
28
- for (let index = path.lastIndexOf("/"); index > 0; index = path.lastIndexOf("/", index - 1)) {
29
- const prefix = path.slice(0, index);
30
- const name = path.slice(index + 1);
31
- if (name.length > 0 && byteLength(prefix) <= 155 && byteLength(name) <= 100) {
32
- return { name, prefix };
33
- }
34
- }
35
- throw new CapabilityArtifactError("ARTIFACT_PATH_USTAR_UNREPRESENTABLE", `Path cannot be represented by POSIX USTAR: ${path}`);
36
- }
37
- function writeAscii(block, offset, length, value) {
38
- const bytes = textEncoder.encode(value);
39
- if (bytes.byteLength > length) {
40
- throw new CapabilityArtifactError("ARTIFACT_PATH_USTAR_UNREPRESENTABLE", `USTAR field exceeds ${length} bytes: ${value}`);
41
- }
42
- block.set(bytes, offset);
43
- }
44
- function writeOctal(block, offset, length, value) {
45
- if (!Number.isSafeInteger(value) || value < 0) {
46
- throw new CapabilityArtifactError("ARTIFACT_SIZE_OVERFLOW", `USTAR numeric field is outside the safe integer range: ${value}`);
47
- }
48
- const octal = value.toString(8);
49
- if (octal.length > length - 1) {
50
- throw new CapabilityArtifactError("ARTIFACT_SIZE_OVERFLOW", `USTAR numeric field exceeds ${length - 1} octal digits: ${value}`);
51
- }
52
- writeAscii(block, offset, length, `${octal.padStart(length - 1, "0")}\0`);
53
- }
54
- function writeChecksum(block, checksum) {
55
- const octal = checksum.toString(8);
56
- if (octal.length > 6) {
57
- throw new CapabilityArtifactError("ARTIFACT_SIZE_OVERFLOW", `USTAR checksum exceeds six octal digits: ${checksum}`);
58
- }
59
- writeAscii(block, 148, 8, `${octal.padStart(6, "0")}\0 `);
60
- }
61
- function createHeader(entry) {
62
- const block = new Uint8Array(TAR_BLOCK_SIZE);
63
- const { name, prefix } = splitUstarPath(entry.path);
64
- writeAscii(block, 0, 100, name);
65
- writeOctal(block, 100, 8, entry.type === "directory" ? 0o755 : 0o644);
66
- writeOctal(block, 108, 8, 0);
67
- writeOctal(block, 116, 8, 0);
68
- writeOctal(block, 124, 12, entry.type === "directory" ? 0 : entry.bytes.byteLength);
69
- writeOctal(block, 136, 12, 0);
70
- block.fill(0x20, 148, 156);
71
- block[156] = (entry.type === "directory" ? "5" : "0").charCodeAt(0);
72
- writeAscii(block, 257, 6, "ustar\0");
73
- writeAscii(block, 263, 2, "00");
74
- writeOctal(block, 329, 8, 0);
75
- writeOctal(block, 337, 8, 0);
76
- writeAscii(block, 345, 155, prefix);
77
- let checksum = 0;
78
- for (const byte of block)
79
- checksum += byte;
80
- writeChecksum(block, checksum);
81
- return block;
82
- }
83
- function collectEntries(files) {
84
- const filePaths = new Set();
85
- const directoryPaths = new Set();
86
- const fileEntries = [];
87
- for (const file of files) {
88
- validateFilePath(file.path);
89
- splitUstarPath(file.path);
90
- if (filePaths.has(file.path)) {
91
- throw new CapabilityArtifactError("ARTIFACT_PATH_DUPLICATE", `Duplicate USTAR file path: ${file.path}`);
92
- }
93
- filePaths.add(file.path);
94
- fileEntries.push({ path: file.path, type: "file", bytes: file.bytes });
95
- const segments = file.path.split("/");
96
- for (let index = 1; index < segments.length; index += 1) {
97
- const directory = `${segments.slice(0, index).join("/")}/`;
98
- splitUstarPath(directory);
99
- directoryPaths.add(directory);
100
- }
101
- }
102
- for (const directory of directoryPaths) {
103
- if (filePaths.has(directory.slice(0, -1))) {
104
- throw new CapabilityArtifactError("ARTIFACT_PATH_DUPLICATE", `USTAR path is both a file and directory: ${directory}`);
105
- }
106
- }
107
- const entries = [
108
- ...[...directoryPaths].map((path) => ({ path, type: "directory" })),
109
- ...fileEntries,
110
- ];
111
- entries.sort((left, right) => compareUtf16(left.path, right.path));
112
- return entries;
113
- }
114
- export function encodeDeterministicUstarV1(files) {
115
- const entries = collectEntries(files);
116
- let totalLength = TAR_BLOCK_SIZE * 2;
117
- for (const entry of entries) {
118
- totalLength += TAR_BLOCK_SIZE;
119
- if (entry.type === "file") {
120
- totalLength += Math.ceil(entry.bytes.byteLength / TAR_BLOCK_SIZE) * TAR_BLOCK_SIZE;
121
- }
122
- if (!Number.isSafeInteger(totalLength)) {
123
- throw new CapabilityArtifactError("ARTIFACT_SIZE_OVERFLOW", "USTAR archive size exceeds the safe integer range");
124
- }
125
- }
126
- const archive = new Uint8Array(totalLength);
127
- let offset = 0;
128
- for (const entry of entries) {
129
- archive.set(createHeader(entry), offset);
130
- offset += TAR_BLOCK_SIZE;
131
- if (entry.type === "file") {
132
- archive.set(entry.bytes, offset);
133
- offset += Math.ceil(entry.bytes.byteLength / TAR_BLOCK_SIZE) * TAR_BLOCK_SIZE;
134
- }
135
- }
136
- return archive;
137
- }
@@ -1,24 +0,0 @@
1
- import type { CanonicalSkillInputV1 } from "./capabilityArtifactTypes.js";
2
- import type { ScannedSkill } from "./skillScanner.js";
3
- export declare const CAPABILITY_SKILL_LIMITS_V1: {
4
- readonly maxSkills: 200;
5
- readonly maxFiles: 2000;
6
- readonly maxExpandedBytes: number;
7
- };
8
- export type CapabilitySkillLoadErrorCodeV1 = "CAPABILITY_SKILL_ENTRY_UNSAFE" | "CAPABILITY_SKILL_LIMIT_EXCEEDED" | "CAPABILITY_FILE_LIMIT_EXCEEDED" | "CAPABILITY_EXPANDED_SIZE_EXCEEDED";
9
- export declare class CapabilitySkillLoadErrorV1 extends Error {
10
- readonly code: CapabilitySkillLoadErrorCodeV1;
11
- constructor(code: CapabilitySkillLoadErrorCodeV1, message: string);
12
- }
13
- export interface LoadCanonicalSkillsInputV1 {
14
- projectRoot: string;
15
- skills: readonly ScannedSkill[];
16
- }
17
- export interface LoadedCanonicalSkillsV1 {
18
- skills: CanonicalSkillInputV1[];
19
- watchedFiles: string[];
20
- fileCount: number;
21
- expandedBytes: number;
22
- }
23
- export declare function loadCanonicalSkillsV1(input: LoadCanonicalSkillsInputV1): Promise<LoadedCanonicalSkillsV1>;
24
- //# sourceMappingURL=skillDirectoryLoader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"skillDirectoryLoader.d.ts","sourceRoot":"","sources":["../../../src/node/capabilities/skillDirectoryLoader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,eAAO,MAAM,0BAA0B;;;;CAI7B,CAAC;AAEX,MAAM,MAAM,8BAA8B,GACtC,+BAA+B,GAC/B,iCAAiC,GACjC,gCAAgC,GAChC,mCAAmC,CAAC;AAExC,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,QAAQ,CAAC,IAAI,EAAE,8BAA8B,CAAC;gBAElC,IAAI,EAAE,8BAA8B,EAAE,OAAO,EAAE,MAAM;CAKlE;AAED,MAAM,WAAW,0BAA0B;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,SAAS,YAAY,EAAE,CAAC;CACjC;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,qBAAqB,EAAE,CAAC;IAChC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB;AA4PD,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,0BAA0B,GAChC,OAAO,CAAC,uBAAuB,CAAC,CAiJlC"}