@inupedia/spotlight-client 0.2.14 → 0.3.1

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 (62) hide show
  1. package/dist/capabilities/channel.d.ts +28 -0
  2. package/dist/capabilities/channel.d.ts.map +1 -0
  3. package/dist/capabilities/channel.js +166 -0
  4. package/dist/capabilities/errors.d.ts +9 -0
  5. package/dist/capabilities/errors.d.ts.map +1 -0
  6. package/dist/capabilities/errors.js +19 -0
  7. package/dist/capabilities/handshake.d.ts +36 -0
  8. package/dist/capabilities/handshake.d.ts.map +1 -0
  9. package/dist/capabilities/handshake.js +78 -0
  10. package/dist/capabilities/hostActionExecutor.d.ts +22 -0
  11. package/dist/capabilities/hostActionExecutor.d.ts.map +1 -0
  12. package/dist/capabilities/hostActionExecutor.js +56 -0
  13. package/dist/capabilities/jsonSchema.d.ts +2 -0
  14. package/dist/capabilities/jsonSchema.d.ts.map +1 -0
  15. package/dist/capabilities/jsonSchema.js +73 -0
  16. package/dist/capabilities/runtimeCapabilities.d.ts +25 -0
  17. package/dist/capabilities/runtimeCapabilities.d.ts.map +1 -0
  18. package/dist/capabilities/runtimeCapabilities.js +53 -0
  19. package/dist/index.d.ts +6 -0
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +6 -0
  22. package/dist/node/capabilities/archivePath.d.ts +4 -0
  23. package/dist/node/capabilities/archivePath.d.ts.map +1 -0
  24. package/dist/node/capabilities/archivePath.js +22 -0
  25. package/dist/node/capabilities/capabilityArtifact.d.ts +2 -0
  26. package/dist/node/capabilities/capabilityArtifact.d.ts.map +1 -1
  27. package/dist/node/capabilities/capabilityArtifact.js +6 -0
  28. package/dist/node/capabilities/capabilityFileMap.d.ts +2 -0
  29. package/dist/node/capabilities/capabilityFileMap.d.ts.map +1 -1
  30. package/dist/node/capabilities/capabilityFileMap.js +13 -14
  31. package/dist/node/capabilities/deterministicTar.d.ts.map +1 -1
  32. package/dist/node/capabilities/deterministicTar.js +3 -12
  33. package/dist/node/capabilities/skillManifest.d.ts +16 -0
  34. package/dist/node/capabilities/skillManifest.d.ts.map +1 -0
  35. package/dist/node/capabilities/skillManifest.js +22 -0
  36. package/dist/node/capabilityPublishCli.d.ts +2 -0
  37. package/dist/node/capabilityPublishCli.d.ts.map +1 -0
  38. package/dist/node/capabilityPublishCli.js +115 -0
  39. package/dist/node/cli/spotlightCapabilitiesPublish.d.ts +3 -0
  40. package/dist/node/cli/spotlightCapabilitiesPublish.d.ts.map +1 -0
  41. package/dist/node/cli/spotlightCapabilitiesPublish.js +3 -0
  42. package/dist/node/index.d.ts +3 -0
  43. package/dist/node/index.d.ts.map +1 -1
  44. package/dist/node/index.js +3 -0
  45. package/dist/node/publishCapabilitiesCli.d.ts +3 -0
  46. package/dist/node/publishCapabilitiesCli.d.ts.map +1 -0
  47. package/dist/node/publishCapabilitiesCli.js +36 -0
  48. package/dist/node/publishCapabilityArtifact.d.ts +12 -0
  49. package/dist/node/publishCapabilityArtifact.d.ts.map +1 -0
  50. package/dist/node/publishCapabilityArtifact.js +25 -0
  51. package/dist/tools/frontendTool.d.ts +39 -0
  52. package/dist/tools/frontendTool.d.ts.map +1 -0
  53. package/dist/tools/frontendTool.js +51 -0
  54. package/dist/vite/capabilityBuild.d.ts.map +1 -1
  55. package/dist/vite/capabilityBuild.js +33 -5
  56. package/dist/vite/capabilityBuildTypes.d.ts +4 -1
  57. package/dist/vite/capabilityBuildTypes.d.ts.map +1 -1
  58. package/dist/vite/capabilityVirtualModule.d.ts.map +1 -1
  59. package/dist/vite/capabilityVirtualModule.js +16 -1
  60. package/dist/vite/spotlightCapabilities.d.ts.map +1 -1
  61. package/dist/vite/spotlightCapabilities.js +17 -1
  62. package/package.json +6 -2
@@ -0,0 +1,4 @@
1
+ export declare function canonicalArchivePathProblem(path: string, options?: {
2
+ directory?: boolean;
3
+ }): string | undefined;
4
+ //# sourceMappingURL=archivePath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archivePath.d.ts","sourceRoot":"","sources":["../../../src/node/capabilities/archivePath.ts"],"names":[],"mappings":"AAEA,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,GACpC,MAAM,GAAG,SAAS,CAYpB"}
@@ -0,0 +1,22 @@
1
+ import { containsLoneSurrogate } from "./canonicalJson.js";
2
+ export function canonicalArchivePathProblem(path, options = {}) {
3
+ const directory = options.directory === true;
4
+ const normalized = directory && path.endsWith("/") ? path.slice(0, -1) : path;
5
+ if (!normalized)
6
+ return "path is empty";
7
+ if (normalized.startsWith("/"))
8
+ return "path is absolute";
9
+ if (/^[A-Za-z]:/.test(normalized))
10
+ return "path has a Windows drive prefix";
11
+ if (normalized.includes("\\"))
12
+ return "path contains a backslash";
13
+ if (normalized.includes("\0"))
14
+ return "path contains NUL";
15
+ if (containsLoneSurrogate(normalized))
16
+ return "path contains a lone surrogate";
17
+ if (!directory && path.endsWith("/"))
18
+ return "file path has a trailing slash";
19
+ if (normalized.split("/").some((segment) => segment === "" || segment === "." || segment === ".."))
20
+ return "path contains an empty or dot segment";
21
+ return undefined;
22
+ }
@@ -3,10 +3,12 @@ export interface CapabilityArtifactBuildV1 {
3
3
  artifactVersion: "spotlight.capability-artifact/1";
4
4
  artifactDigest: string;
5
5
  manifestDigest: string;
6
+ skillManifestDigest: string;
6
7
  toolManifestDigest: string;
7
8
  byteLength: number;
8
9
  archive: Uint8Array;
9
10
  manifestBytes: Uint8Array;
11
+ skillManifestBytes: Uint8Array;
10
12
  toolManifestBytes: Uint8Array;
11
13
  }
12
14
  export declare function buildCapabilityArtifactV1(input: CapabilityArtifactInputV1): CapabilityArtifactBuildV1;
@@ -1 +1 @@
1
- {"version":3,"file":"capabilityArtifact.d.ts","sourceRoot":"","sources":["../../../src/node/capabilities/capabilityArtifact.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAK9E,MAAM,WAAW,yBAAyB;IACxC,eAAe,EAAE,iCAAiC,CAAC;IACnD,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,UAAU,CAAC;IACpB,aAAa,EAAE,UAAU,CAAC;IAC1B,iBAAiB,EAAE,UAAU,CAAC;CAC/B;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,yBAAyB,GAC/B,yBAAyB,CA2B3B"}
1
+ {"version":3,"file":"capabilityArtifact.d.ts","sourceRoot":"","sources":["../../../src/node/capabilities/capabilityArtifact.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAM9E,MAAM,WAAW,yBAAyB;IACxC,eAAe,EAAE,iCAAiC,CAAC;IACnD,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,UAAU,CAAC;IACpB,aAAa,EAAE,UAAU,CAAC;IAC1B,kBAAkB,EAAE,UAAU,CAAC;IAC/B,iBAAiB,EAAE,UAAU,CAAC;CAC/B;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,yBAAyB,GAC/B,yBAAyB,CAgC3B"}
@@ -1,15 +1,19 @@
1
1
  import { buildCapabilityFileMapV1, computeArtifactDigestV1, } from "./capabilityFileMap.js";
2
2
  import { encodeDeterministicGzipV1 } from "./deterministicGzip.js";
3
3
  import { encodeDeterministicUstarV1 } from "./deterministicTar.js";
4
+ import { buildSkillManifestV1 } from "./skillManifest.js";
4
5
  import { buildToolManifestV1 } from "./toolManifest.js";
5
6
  export function buildCapabilityArtifactV1(input) {
6
7
  const toolManifest = buildToolManifestV1(input.tools);
8
+ const skillManifest = buildSkillManifestV1(input.skills);
7
9
  const fileMap = buildCapabilityFileMapV1({
8
10
  skills: input.skills,
11
+ skillManifestBytes: skillManifest.bytes,
9
12
  toolManifestBytes: toolManifest.bytes,
10
13
  });
11
14
  const artifactDigest = computeArtifactDigestV1({
12
15
  manifestDigest: fileMap.manifestDigest,
16
+ skillManifestDigest: skillManifest.digest,
13
17
  toolManifestDigest: toolManifest.digest,
14
18
  payloads: fileMap.payloads,
15
19
  });
@@ -22,10 +26,12 @@ export function buildCapabilityArtifactV1(input) {
22
26
  artifactVersion: "spotlight.capability-artifact/1",
23
27
  artifactDigest,
24
28
  manifestDigest: fileMap.manifestDigest,
29
+ skillManifestDigest: skillManifest.digest,
25
30
  toolManifestDigest: toolManifest.digest,
26
31
  byteLength: archive.byteLength,
27
32
  archive,
28
33
  manifestBytes: Uint8Array.from(fileMap.manifestBytes),
34
+ skillManifestBytes: Uint8Array.from(skillManifest.bytes),
29
35
  toolManifestBytes: Uint8Array.from(toolManifest.bytes),
30
36
  };
31
37
  }
@@ -7,10 +7,12 @@ export interface BuiltCapabilityFileMapV1 {
7
7
  }
8
8
  export declare function buildCapabilityFileMapV1(input: {
9
9
  skills: CanonicalSkillInputV1[];
10
+ skillManifestBytes?: Uint8Array;
10
11
  toolManifestBytes: Uint8Array;
11
12
  }): BuiltCapabilityFileMapV1;
12
13
  export declare function computeArtifactDigestV1(input: {
13
14
  manifestDigest: string;
15
+ skillManifestDigest?: string;
14
16
  toolManifestDigest: string;
15
17
  payloads: Array<Pick<CapabilityPayloadFileV1, "path" | "sha256">>;
16
18
  }): string;
@@ -1 +1 @@
1
- {"version":3,"file":"capabilityFileMap.d.ts","sourceRoot":"","sources":["../../../src/node/capabilities/capabilityFileMap.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,8BAA8B,CAAC;AA+BtC,MAAM,WAA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AI,CAAC,uBAAuB,EAAE,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC;CACnE,GAAG,MAAM,CA4BT"}
@@ -1,7 +1,8 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { isProxy } from "node:util/types";
3
- import { canonicalizeJson, compareUtf16, containsLoneSurrogate, } from "./canonicalJson.js";
3
+ import { canonicalizeJson, compareUtf16, } from "./canonicalJson.js";
4
4
  import { CapabilityArtifactError } from "./capabilityArtifactError.js";
5
+ import { canonicalArchivePathProblem } from "./archivePath.js";
5
6
  const CANONICAL_SKILL_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
6
7
  const SHA256_DIGEST = /^sha256:[a-f0-9]{64}$/;
7
8
  const textEncoder = new TextEncoder();
@@ -119,19 +120,9 @@ function validateRelativePath(relativePath) {
119
120
  if (typeof relativePath !== "string") {
120
121
  invalidInput("Skill relativePath must be a string");
121
122
  }
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("/")) {
123
+ if (canonicalArchivePathProblem(relativePath)) {
129
124
  throw new CapabilityArtifactError("ARTIFACT_PATH_INVALID", `Invalid Skill relative path: ${relativePath}`);
130
125
  }
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
126
  }
136
127
  function ensureUstarPath(path) {
137
128
  if (!canRepresentUstarPath(path)) {
@@ -165,7 +156,11 @@ function addPayload(payloads, seenPaths, payload) {
165
156
  payloads.push(payload);
166
157
  }
167
158
  export function buildCapabilityFileMapV1(input) {
168
- const root = readDataRecord(input, "Capability file-map input", new Set(["skills", "toolManifestBytes"]));
159
+ const root = readDataRecord(input, "Capability file-map input", new Set(["skills", "skillManifestBytes", "toolManifestBytes"]));
160
+ if (root.skillManifestBytes !== undefined && (isProxy(root.skillManifestBytes) ||
161
+ !(root.skillManifestBytes instanceof Uint8Array))) {
162
+ invalidInput("skillManifestBytes must be a Uint8Array");
163
+ }
169
164
  if (isProxy(root.toolManifestBytes) ||
170
165
  !(root.toolManifestBytes instanceof Uint8Array)) {
171
166
  invalidInput("toolManifestBytes must be a Uint8Array");
@@ -173,6 +168,9 @@ export function buildCapabilityFileMapV1(input) {
173
168
  const skills = readDenseDataArray(root.skills, "skills");
174
169
  const payloads = [];
175
170
  const seenPaths = new Set();
171
+ if (root.skillManifestBytes instanceof Uint8Array) {
172
+ addPayload(payloads, seenPaths, createPayload("skill-manifest.json", root.skillManifestBytes, "application/json"));
173
+ }
176
174
  addPayload(payloads, seenPaths, createPayload("tool-manifest.json", root.toolManifestBytes, "application/json"));
177
175
  for (const [skillIndex, skillValue] of skills.entries()) {
178
176
  const skill = readDataRecord(skillValue, `skills[${skillIndex}]`, new Set(["name", "files"]));
@@ -215,7 +213,7 @@ export function buildCapabilityFileMapV1(input) {
215
213
  };
216
214
  }
217
215
  export function computeArtifactDigestV1(input) {
218
- if (!SHA256_DIGEST.test(input.manifestDigest) || !SHA256_DIGEST.test(input.toolManifestDigest)) {
216
+ if (!SHA256_DIGEST.test(input.manifestDigest) || (input.skillManifestDigest !== undefined && !SHA256_DIGEST.test(input.skillManifestDigest)) || !SHA256_DIGEST.test(input.toolManifestDigest)) {
219
217
  throw new CapabilityArtifactError("ARTIFACT_JSON_NOT_IJSON", "Artifact preimage contains an invalid manifest digest");
220
218
  }
221
219
  const payloadDigests = input.payloads
@@ -229,6 +227,7 @@ export function computeArtifactDigestV1(input) {
229
227
  return sha256(canonicalizeJson({
230
228
  artifactVersion: "spotlight.capability-artifact/1",
231
229
  manifestDigest: input.manifestDigest,
230
+ ...(input.skillManifestDigest ? { skillManifestDigest: input.skillManifestDigest } : {}),
232
231
  toolManifestDigest: input.toolManifestDigest,
233
232
  payloadDigests,
234
233
  }));
@@ -1 +1 @@
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
+ {"version":3,"file":"deterministicTar.d.ts","sourceRoot":"","sources":["../../../src/node/capabilities/deterministicTar.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,UAAU,CAAC;CACnB;AAwJD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,UAAU,CA2B9E"}
@@ -1,4 +1,5 @@
1
- import { compareUtf16, containsLoneSurrogate } from "./canonicalJson.js";
1
+ import { compareUtf16 } from "./canonicalJson.js";
2
+ import { canonicalArchivePathProblem } from "./archivePath.js";
2
3
  import { CapabilityArtifactError } from "./capabilityArtifactError.js";
3
4
  const TAR_BLOCK_SIZE = 512;
4
5
  const textEncoder = new TextEncoder();
@@ -6,18 +7,8 @@ function failInvalidPath(path) {
6
7
  throw new CapabilityArtifactError("ARTIFACT_PATH_INVALID", `Invalid USTAR file path: ${path}`);
7
8
  }
8
9
  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("/")) {
10
+ if (canonicalArchivePathProblem(path))
16
11
  failInvalidPath(path);
17
- }
18
- if (path.split("/").some((segment) => segment === "" || segment === "." || segment === "..")) {
19
- failInvalidPath(path);
20
- }
21
12
  }
22
13
  function byteLength(value) {
23
14
  return textEncoder.encode(value).byteLength;
@@ -0,0 +1,16 @@
1
+ import type { CanonicalSkillInputV1 } from "./capabilityArtifactTypes.js";
2
+ export interface CapabilitySkillManifestEntryV1 {
3
+ name: string;
4
+ entrypoint: string;
5
+ files: string[];
6
+ }
7
+ export interface CapabilitySkillManifestV1 {
8
+ schemaVersion: "spotlight.skill-manifest/1";
9
+ skills: CapabilitySkillManifestEntryV1[];
10
+ }
11
+ export declare function buildSkillManifestV1(skills: CanonicalSkillInputV1[]): {
12
+ manifest: CapabilitySkillManifestV1;
13
+ bytes: Uint8Array<ArrayBufferLike>;
14
+ digest: string;
15
+ };
16
+ //# sourceMappingURL=skillManifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skillManifest.d.ts","sourceRoot":"","sources":["../../../src/node/capabilities/skillManifest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE1E,MAAM,WAAW,8BAA8B;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,yBAAyB;IACxC,aAAa,EAAE,4BAA4B,CAAC;IAC5C,MAAM,EAAE,8BAA8B,EAAE,CAAC;CAC1C;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,qBAAqB,EAAE;cAeP,yBAAyB;;;EAIrF"}
@@ -0,0 +1,22 @@
1
+ import { createHash } from "node:crypto";
2
+ import { canonicalizeJson, compareUtf16 } from "./canonicalJson.js";
3
+ export function buildSkillManifestV1(skills) {
4
+ const manifest = {
5
+ schemaVersion: "spotlight.skill-manifest/1",
6
+ skills: skills
7
+ .map((skill) => ({
8
+ name: skill.name,
9
+ entrypoint: `skills/${skill.name}/SKILL.md`,
10
+ files: skill.files
11
+ .map((file) => `skills/${skill.name}/${file.relativePath}`)
12
+ .sort(compareUtf16),
13
+ }))
14
+ .sort((left, right) => compareUtf16(left.name, right.name)),
15
+ };
16
+ const bytes = canonicalizeJson(manifest);
17
+ return {
18
+ manifest: JSON.parse(new TextDecoder().decode(bytes)),
19
+ bytes,
20
+ digest: `sha256:${createHash("sha256").update(bytes).digest("hex")}`,
21
+ };
22
+ }
@@ -0,0 +1,2 @@
1
+ export declare function runCapabilityPublishCliV1(argv: readonly string[]): Promise<number>;
2
+ //# sourceMappingURL=capabilityPublishCli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilityPublishCli.d.ts","sourceRoot":"","sources":["../../src/node/capabilityPublishCli.ts"],"names":[],"mappings":"AAsCA,wBAAsB,yBAAyB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CASxF"}
@@ -0,0 +1,115 @@
1
+ import { createHash } from "node:crypto";
2
+ import { access, mkdir, mkdtemp, readFile, rename, rm, writeFile } from "node:fs/promises";
3
+ import { basename, dirname, join } from "node:path";
4
+ import { gunzipSync } from "node:zlib";
5
+ import { canonicalizeJson } from "./capabilities/canonicalJson.js";
6
+ import { computeArtifactDigestV1 } from "./capabilities/capabilityFileMap.js";
7
+ import { canonicalArchivePathProblem } from "./capabilities/archivePath.js";
8
+ function args(argv) { const parsed = {}; for (let i = 0; i < argv.length; i += 2) {
9
+ const k = argv[i], v = argv[i + 1];
10
+ if (!k?.startsWith("--") || !v)
11
+ throw new TypeError("Capability publish CLI expects --key value arguments.");
12
+ parsed[k.slice(2)] = v;
13
+ } return parsed; }
14
+ const sha256 = (bytes) => `sha256:${createHash("sha256").update(bytes).digest("hex")}`;
15
+ function tarFiles(archive) {
16
+ const tar = Uint8Array.from(gunzipSync(archive));
17
+ const files = new Map();
18
+ const seenPaths = new Set();
19
+ let offset = 0;
20
+ const text = (bytes) => new TextDecoder().decode(bytes.subarray(0, bytes.indexOf(0) < 0 ? bytes.length : bytes.indexOf(0)));
21
+ while (offset + 512 <= tar.length) {
22
+ const h = tar.subarray(offset, offset + 512);
23
+ if (h.every((b) => b === 0)) {
24
+ const second = tar.subarray(offset + 512, offset + 1024);
25
+ if (second.length < 512 || !second.every((b) => b === 0) || !tar.subarray(offset + 1024).every((b) => b === 0))
26
+ throw new TypeError("Invalid USTAR trailing content.");
27
+ return files;
28
+ }
29
+ const storedText = text(h.subarray(148, 156)).trim();
30
+ if (!/^[0-7]+$/.test(storedText))
31
+ throw new TypeError("Invalid USTAR header checksum field.");
32
+ const stored = Number.parseInt(storedText, 8);
33
+ let sum = 0;
34
+ for (let i = 0; i < 512; i++)
35
+ sum += i >= 148 && i < 156 ? 32 : (h[i] ?? 0);
36
+ if (sum !== stored)
37
+ throw new TypeError("Invalid USTAR header checksum.");
38
+ if (text(h.subarray(257, 263)) !== "ustar" || text(h.subarray(263, 265)) !== "00")
39
+ throw new TypeError("Invalid USTAR header magic.");
40
+ const type = h[156];
41
+ if (type !== 48 && type !== 0 && type !== 53)
42
+ throw new TypeError("Artifact contains an unsupported USTAR entry.");
43
+ const name = text(h.subarray(0, 100));
44
+ const prefix = text(h.subarray(345, 500));
45
+ const rawPath = prefix ? `${prefix}/${name}` : name;
46
+ const isDirectory = type === 53;
47
+ const path = isDirectory ? rawPath.replace(/\/$/, "") : rawPath;
48
+ if (canonicalArchivePathProblem(rawPath, { directory: isDirectory }) || seenPaths.has(path))
49
+ throw new TypeError("Invalid or duplicate USTAR path.");
50
+ seenPaths.add(path);
51
+ const sizeText = text(h.subarray(124, 136)).trim();
52
+ if (!/^[0-7]+$/.test(sizeText))
53
+ throw new TypeError("Invalid USTAR size field.");
54
+ const size = Number.parseInt(sizeText, 8);
55
+ if (isDirectory && size !== 0)
56
+ throw new TypeError("USTAR directory must be zero length.");
57
+ const start = offset + 512, end = start + size, padded = start + Math.ceil(size / 512) * 512;
58
+ if (end > tar.length || !tar.subarray(end, padded).every((b) => b === 0))
59
+ throw new TypeError("Invalid USTAR payload padding.");
60
+ if (!isDirectory)
61
+ files.set(path, tar.slice(start, end));
62
+ offset = padded;
63
+ }
64
+ throw new TypeError("USTAR archive is missing terminal zero blocks.");
65
+ }
66
+ function verify(archive, info) {
67
+ const files = tarFiles(archive);
68
+ const manifestBytes = files.get("manifest.json"), skillBytes = files.get("skill-manifest.json"), toolBytes = files.get("tool-manifest.json");
69
+ if (!manifestBytes || !skillBytes || !toolBytes)
70
+ throw new TypeError("Artifact is missing required manifests.");
71
+ const manifest = JSON.parse(new TextDecoder().decode(manifestBytes));
72
+ const manifestPaths = manifest.files.map((entry) => entry.path);
73
+ if (new Set(manifestPaths).size !== manifestPaths.length)
74
+ throw new TypeError("Artifact manifest contains duplicate file declarations.");
75
+ const declared = new Set(["manifest.json", ...manifestPaths]);
76
+ if (files.size !== declared.size || [...files.keys()].some((path) => !declared.has(path)))
77
+ throw new TypeError("Artifact contains undeclared regular files.");
78
+ for (const entry of manifest.files) {
79
+ const bytes = files.get(entry.path);
80
+ if (!bytes || bytes.byteLength !== entry.byteLength || sha256(bytes) !== entry.sha256)
81
+ throw new TypeError(`Artifact payload mismatch: ${entry.path}`);
82
+ }
83
+ const manifestDigest = sha256(manifestBytes), skillManifestDigest = sha256(skillBytes), toolManifestDigest = sha256(toolBytes);
84
+ const artifactDigest = computeArtifactDigestV1({ manifestDigest, skillManifestDigest, toolManifestDigest, payloads: manifest.files });
85
+ const actual = { digest: artifactDigest, manifestDigest, skillManifestDigest, toolManifestDigest, byteLength: archive.byteLength };
86
+ const expected = { digest: info.artifactDigest, manifestDigest: info.manifestDigest, skillManifestDigest: info.skillManifestDigest, toolManifestDigest: info.toolManifestDigest, byteLength: info.byteLength };
87
+ if (JSON.stringify(actual) !== JSON.stringify(expected))
88
+ throw new TypeError("Artifact digests do not match build info.");
89
+ return actual;
90
+ }
91
+ export async function runCapabilityPublishCliV1(argv) {
92
+ const input = args(argv);
93
+ if (!input.artifact || !input["build-info"] || !input["out-dir"])
94
+ throw new TypeError("Required: --artifact --build-info --out-dir");
95
+ const [archive, infoText] = await Promise.all([readFile(input.artifact), readFile(input["build-info"], "utf8")]);
96
+ const info = JSON.parse(infoText);
97
+ for (const field of ["projectId", "frontendBuildId"])
98
+ if (typeof info[field] !== "string" || !info[field])
99
+ throw new TypeError(`Invalid build info field: ${field}`);
100
+ const artifact = verify(archive, info);
101
+ const attestation = { schemaVersion: "spotlight.capability-attestation/1", projectId: info.projectId, frontendBuildId: info.frontendBuildId, artifact, createdAt: input["created-at"] ?? new Date().toISOString() };
102
+ const out = input["out-dir"];
103
+ await mkdir(dirname(out), { recursive: true });
104
+ await access(out).then(() => { throw new TypeError("Publish output already exists."); }, () => undefined);
105
+ const staging = await mkdtemp(join(dirname(out), `.${basename(out)}.tmp-`));
106
+ try {
107
+ await Promise.all([writeFile(join(staging, `${artifact.digest}.tgz`), archive, { flag: "wx" }), writeFile(join(staging, "capability-attestation.json"), `${new TextDecoder().decode(canonicalizeJson(attestation))}\n`, { flag: "wx", encoding: "utf8" })]);
108
+ await rename(staging, out);
109
+ }
110
+ catch (error) {
111
+ await rm(staging, { recursive: true, force: true });
112
+ throw error;
113
+ }
114
+ return 0;
115
+ }
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=spotlightCapabilitiesPublish.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spotlightCapabilitiesPublish.d.ts","sourceRoot":"","sources":["../../../src/node/cli/spotlightCapabilitiesPublish.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { runCapabilityPublishCliV1 } from "../capabilityPublishCli.js";
3
+ runCapabilityPublishCliV1(process.argv.slice(2)).then((code) => { process.exitCode = code; }, (error) => { console.error(error instanceof Error ? error.message : error); process.exitCode = 1; });
@@ -10,4 +10,7 @@ export { CAPABILITY_ARTIFACT_ERROR_CODES, CapabilityArtifactError, type Capabili
10
10
  export type { CanonicalSkillFileInputV1, CanonicalSkillInputV1, CapabilityArtifactInputV1, CapabilityFileManifestEntryV1, CapabilityFileManifestV1, CapabilityPayloadFileV1, } from "./capabilities/capabilityArtifactTypes.js";
11
11
  export { canonicalizeJson, compareUtf16, type CanonicalJsonValue, } from "./capabilities/canonicalJson.js";
12
12
  export { buildToolManifestV1, type BuiltToolManifestV1, type ToolManifestV1, } from "./capabilities/toolManifest.js";
13
+ export { buildSkillManifestV1, type CapabilitySkillManifestEntryV1, type CapabilitySkillManifestV1, } from "./capabilities/skillManifest.js";
14
+ export { publishCapabilityArtifactV1 } from "./publishCapabilityArtifact.js";
15
+ export { runCapabilityPublishCliV1 } from "./capabilityPublishCli.js";
13
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,KAAK,oBAAoB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,eAAe,GACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,qBAAqB,EACrB,KAAK,8BAA8B,EACnC,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,GAC7B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,0BAA0B,EAC1B,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EACjC,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,+BAA+B,GACrC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,oBAAoB,EACpB,KAAK,yBAAyB,GAC/B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,yBAAyB,EACzB,KAAK,yBAAyB,GAC/B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,wBA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C;AAC9C,OAAO,EACL,yBAAyB,EACzB,KAAK,yBAAyB,GAC/B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,KAAK,wBAAwB,GAC9B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,+BAA+B,EAC/B,uBAAuB,EACvB,KAAK,2BAA2B,GACjC,MAAM,2CAA2C,CAAC;AACnD,YAAY,EACV,yBAAyB,EACzB,qBAAqB,EACrB,yBAAyB,EACzB,6BAA6B,EAC7B,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,KAAK,kBAAkB,GACxB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,KAAK,cAAc,GACpB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,oBAAoB,EACpB,KAAK,8BAA8B,EACnC,KAAK,yBAAyB,GAC/B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC"}
@@ -9,3 +9,6 @@ export { buildCapabilityFileMapV1, computeArtifactDigestV1, } from "./capabiliti
9
9
  export { CAPABILITY_ARTIFACT_ERROR_CODES, CapabilityArtifactError, } from "./capabilities/capabilityArtifactError.js";
10
10
  export { canonicalizeJson, compareUtf16, } from "./capabilities/canonicalJson.js";
11
11
  export { buildToolManifestV1, } from "./capabilities/toolManifest.js";
12
+ export { buildSkillManifestV1, } from "./capabilities/skillManifest.js";
13
+ export { publishCapabilityArtifactV1 } from "./publishCapabilityArtifact.js";
14
+ export { runCapabilityPublishCliV1 } from "./capabilityPublishCli.js";
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=publishCapabilitiesCli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publishCapabilitiesCli.d.ts","sourceRoot":"","sources":["../../src/node/publishCapabilitiesCli.ts"],"names":[],"mappings":""}
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+ import { readFile } from "node:fs/promises";
3
+ import { resolve } from "node:path";
4
+ function argument(name) {
5
+ const index = process.argv.indexOf(`--${name}`);
6
+ const value = index >= 0 ? process.argv[index + 1] : undefined;
7
+ if (!value)
8
+ throw new Error(`Missing --${name}`);
9
+ return value;
10
+ }
11
+ async function main() {
12
+ const endpoint = argument("endpoint").replace(/\/$/, "");
13
+ const info = JSON.parse(await readFile(resolve(argument("build-info")), "utf8"));
14
+ const archive = await readFile(resolve(argument("artifact")));
15
+ const apiKey = process.env.SPOTLIGHT_API_KEY;
16
+ const response = await fetch(`${endpoint}/v1/capability-artifacts/${encodeURIComponent(info.artifactDigest)}/published`, {
17
+ method: "PUT",
18
+ headers: {
19
+ "Content-Type": "application/gzip",
20
+ ...(apiKey ? { "X-Spotlight-Api-Key": apiKey } : {}),
21
+ "X-Spotlight-Project-Id": info.projectId,
22
+ "X-Spotlight-Frontend-Build-Id": info.frontendBuildId,
23
+ "X-Spotlight-Manifest-Digest": info.manifestDigest,
24
+ "X-Spotlight-Skill-Manifest-Digest": info.skillManifestDigest,
25
+ "X-Spotlight-Tool-Manifest-Digest": info.toolManifestDigest,
26
+ },
27
+ body: archive,
28
+ });
29
+ if (!response.ok)
30
+ throw new Error(`Artifact publish failed (${response.status}): ${await response.text()}`);
31
+ process.stdout.write(`${await response.text()}\n`);
32
+ }
33
+ main().catch((error) => {
34
+ process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
35
+ process.exitCode = 1;
36
+ });
@@ -0,0 +1,12 @@
1
+ import type { CapabilityArtifactBuildV1 } from "./capabilities/capabilityArtifact.js";
2
+ export declare function publishCapabilityArtifactV1(input: {
3
+ outDir: string;
4
+ projectId: string;
5
+ frontendBuildId: string;
6
+ build: CapabilityArtifactBuildV1;
7
+ createdAt?: string;
8
+ }): Promise<{
9
+ artifactPath: string;
10
+ attestationPath: string;
11
+ }>;
12
+ //# sourceMappingURL=publishCapabilityArtifact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publishCapabilityArtifact.d.ts","sourceRoot":"","sources":["../../src/node/publishCapabilityArtifact.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAGtF,wBAAsB,2BAA2B,CAAC,KAAK,EAAE;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,yBAAyB,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,CAAC,CAqB7D"}
@@ -0,0 +1,25 @@
1
+ import { mkdir, writeFile } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { canonicalizeJson } from "./capabilities/canonicalJson.js";
4
+ export async function publishCapabilityArtifactV1(input) {
5
+ await mkdir(input.outDir, { recursive: true });
6
+ const artifactPath = join(input.outDir, `${input.build.artifactDigest}.tgz`);
7
+ const attestationPath = join(input.outDir, "capability-attestation.json");
8
+ const artifact = {
9
+ digest: input.build.artifactDigest,
10
+ manifestDigest: input.build.manifestDigest,
11
+ skillManifestDigest: input.build.skillManifestDigest,
12
+ toolManifestDigest: input.build.toolManifestDigest,
13
+ byteLength: input.build.byteLength,
14
+ };
15
+ const attestation = {
16
+ schemaVersion: "spotlight.capability-attestation/1",
17
+ projectId: input.projectId,
18
+ frontendBuildId: input.frontendBuildId,
19
+ artifact,
20
+ createdAt: input.createdAt ?? new Date().toISOString(),
21
+ };
22
+ await writeFile(artifactPath, input.build.archive, { flag: "wx" });
23
+ await writeFile(attestationPath, `${new TextDecoder().decode(canonicalizeJson(attestation))}\n`, { flag: "wx", encoding: "utf8" });
24
+ return { artifactPath, attestationPath };
25
+ }
@@ -0,0 +1,39 @@
1
+ import type { FrontendToolDescriptorV1, HostActionFenceV2 } from "@inupedia/spotlight-protocol";
2
+ export interface FrontendToolHandlerContextV1 {
3
+ projectId: string;
4
+ sessionId: string;
5
+ callId: string;
6
+ attempt: number;
7
+ fence: Readonly<HostActionFenceV2>;
8
+ idempotencyKey?: string;
9
+ signal: AbortSignal;
10
+ }
11
+ export interface FrontendToolDefinitionV1<TInput extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> extends FrontendToolDescriptorV1 {
12
+ execute: (input: TInput, context: FrontendToolHandlerContextV1) => TOutput | Promise<TOutput>;
13
+ }
14
+ /** Heterogeneous project registry erases handler generics only at the collection boundary. */
15
+ export type AnyFrontendToolDefinitionV1 = FrontendToolDefinitionV1<any, any>;
16
+ export interface SpotlightProjectV1 {
17
+ readonly projectId: string;
18
+ readonly skillRoots?: readonly string[];
19
+ readonly tools: readonly AnyFrontendToolDefinitionV1[];
20
+ }
21
+ export declare function defineFrontendTool<TInput extends Record<string, unknown>, TOutput = unknown>(definition: FrontendToolDefinitionV1<TInput, TOutput>): FrontendToolDefinitionV1<TInput, TOutput>;
22
+ export declare function defineSpotlightProject(input: {
23
+ projectId: string;
24
+ skillRoots?: readonly string[];
25
+ tools: readonly AnyFrontendToolDefinitionV1[];
26
+ }): SpotlightProjectV1;
27
+ export declare function projectToolDescriptors(project: Pick<SpotlightProjectV1, "tools">): FrontendToolDescriptorV1[];
28
+ export interface FrontendToolRegistryV1 {
29
+ readonly projectId: string;
30
+ get(name: string, version: string): AnyFrontendToolDefinitionV1 | undefined;
31
+ setLive(name: string, version: string, live: boolean): void;
32
+ liveTools(): Array<{
33
+ name: string;
34
+ version: string;
35
+ }>;
36
+ descriptors(): FrontendToolDescriptorV1[];
37
+ }
38
+ export declare function createFrontendToolRegistry(project: SpotlightProjectV1): FrontendToolRegistryV1;
39
+ //# sourceMappingURL=frontendT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lG;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,KAAK,EAAE,SAAS,2BAA2B,EAAE,CAAC;CAC/C,GAAG,kBAAkB,CAgBrB;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,IAAI,CAAC,kBAAkB,EAAE,OAAO,CAAC,GACzC,wBAAwB,EAAE,CAI5B;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,2BAA2B,GAAG,SAAS,CAAC;IAC5E,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5D,SAAS,IAAI,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtD,WAAW,IAAI,wBAAwB,EAAE,CAAC;CAC3C;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,kBAAkB,GAAG,sBAAsB,CAqB9F"}
@@ -0,0 +1,51 @@
1
+ export function defineFrontendTool(definition) {
2
+ if (typeof definition.execute !== "function") {
3
+ throw new TypeError("Frontend Tool execute must be a function.");
4
+ }
5
+ return Object.freeze({ ...definition });
6
+ }
7
+ export function defineSpotlightProject(input) {
8
+ const projectId = input.projectId.trim();
9
+ if (!projectId)
10
+ throw new TypeError("Spotlight projectId must be non-empty.");
11
+ const identities = new Set();
12
+ for (const tool of input.tools) {
13
+ const identity = `${tool.name}@${tool.version}`;
14
+ if (identities.has(identity))
15
+ throw new TypeError(`Duplicate Frontend Tool: ${identity}`);
16
+ identities.add(identity);
17
+ }
18
+ return Object.freeze({
19
+ projectId,
20
+ ...(input.skillRoots
21
+ ? { skillRoots: Object.freeze([...input.skillRoots]) }
22
+ : {}),
23
+ tools: Object.freeze([...input.tools]),
24
+ });
25
+ }
26
+ export function projectToolDescriptors(project) {
27
+ return project.tools.map(({ execute: _execute, ...descriptor }) => JSON.parse(JSON.stringify(descriptor)));
28
+ }
29
+ export function createFrontendToolRegistry(project) {
30
+ const definitions = new Map(project.tools.map((tool) => [`${tool.name}@${tool.version}`, tool]));
31
+ const live = new Set(definitions.keys());
32
+ const key = (name, version) => `${name}@${version}`;
33
+ return Object.freeze({
34
+ projectId: project.projectId,
35
+ get: (name, version) => definitions.get(key(name, version)),
36
+ setLive(name, version, value) {
37
+ const identity = key(name, version);
38
+ if (!definitions.has(identity))
39
+ throw new TypeError(`Unknown Frontend Tool: ${identity}`);
40
+ if (value)
41
+ live.add(identity);
42
+ else
43
+ live.delete(identity);
44
+ },
45
+ liveTools: () => [...live].sort().map((identity) => {
46
+ const tool = definitions.get(identity);
47
+ return { name: tool.name, version: tool.version };
48
+ }),
49
+ descriptors: () => projectToolDescriptors(project),
50
+ });
51
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"capabilityBuild.d.ts","sourceRoot":"","sources":["../../src/vite/capabilityBuild.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAEV,6BAA6B,EAC7B,8BAA8B,EAC9B,iCAAiC,EAClC,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EACV,qBAAqB,EACrB,6BAA6B,EAC7B,8BAA8B,EAC9B,iCAAiC,GAClC,MAAM,2BAA2B,CAAC;AAyFnC,wBAAsB,uBAAuB,CAAC,KAAK,EAAE;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;IAC3B,OAAO,EAAE,iCAAiC,CAAC;IAC3C,OAAO,CAAC,EAAE,8BAA8B,CAAC;CAC1C,GAAG,OAAO,CAAC,6BAA6B,CAAC,CA6FzC"}
1
+ {"version":3,"file":"capabilityBuild.d.ts","sourceRoot":"","sources":["../../src/vite/capabilityBuild.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAEV,6BAA6B,EAC7B,8BAA8B,EAC9B,iCAAiC,EAClC,MAAM,2BAA2B,CAAC;AAGnC,YAAY,EACV,qBAAqB,EACrB,6BAA6B,EAC7B,8BAA8B,EAC9B,iCAAiC,GAClC,MAAM,2BAA2B,CAAC;AA2HnC,wBAAsB,uBAAuB,CAAC,KAAK,EAAE;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;IAC3B,OAAO,EAAE,iCAAiC,CAAC;IAC3C,OAAO,CAAC,EAAE,8BAA8B,CAAC;CAC1C,GAAG,OAAO,CAAC,6BAA6B,CAAC,CA8FzC"}