@inupedia/spotlight-client 0.3.5 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +14 -123
  2. package/dist/clientTool.d.ts +42 -0
  3. package/dist/clientTool.d.ts.map +1 -0
  4. package/dist/clientTool.js +97 -0
  5. package/dist/index.d.ts +2 -19
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +2 -18
  8. package/dist/node/capabilities/skillFileValidator.d.ts +0 -8
  9. package/dist/node/capabilities/skillFileValidator.d.ts.map +1 -1
  10. package/dist/node/capabilities/skillFileValidator.js +26 -46
  11. package/dist/node/index.d.ts +0 -10
  12. package/dist/node/index.d.ts.map +1 -1
  13. package/dist/node/index.js +0 -9
  14. package/dist/vite/index.d.ts +1 -7
  15. package/dist/vite/index.d.ts.map +1 -1
  16. package/dist/vite/index.js +1 -4
  17. package/dist/vite/spotlightClientTools.d.ts +27 -0
  18. package/dist/vite/spotlightClientTools.d.ts.map +1 -0
  19. package/dist/vite/spotlightClientTools.js +424 -0
  20. package/package.json +6 -20
  21. package/dist/capabilities/channel.d.ts +0 -28
  22. package/dist/capabilities/channel.d.ts.map +0 -1
  23. package/dist/capabilities/channel.js +0 -194
  24. package/dist/capabilities/errors.d.ts +0 -9
  25. package/dist/capabilities/errors.d.ts.map +0 -1
  26. package/dist/capabilities/errors.js +0 -19
  27. package/dist/capabilities/handshake.d.ts +0 -38
  28. package/dist/capabilities/handshake.d.ts.map +0 -1
  29. package/dist/capabilities/handshake.js +0 -139
  30. package/dist/capabilities/hostActionExecutor.d.ts +0 -22
  31. package/dist/capabilities/hostActionExecutor.d.ts.map +0 -1
  32. package/dist/capabilities/hostActionExecutor.js +0 -56
  33. package/dist/capabilities/jsonSchema.d.ts +0 -2
  34. package/dist/capabilities/jsonSchema.d.ts.map +0 -1
  35. package/dist/capabilities/jsonSchema.js +0 -73
  36. package/dist/capabilities/runtimeCapabilities.d.ts +0 -25
  37. package/dist/capabilities/runtimeCapabilities.d.ts.map +0 -1
  38. package/dist/capabilities/runtimeCapabilities.js +0 -53
  39. package/dist/node/capabilities/archivePath.d.ts +0 -4
  40. package/dist/node/capabilities/archivePath.d.ts.map +0 -1
  41. package/dist/node/capabilities/archivePath.js +0 -22
  42. package/dist/node/capabilities/canonicalJson.d.ts +0 -7
  43. package/dist/node/capabilities/canonicalJson.d.ts.map +0 -1
  44. package/dist/node/capabilities/canonicalJson.js +0 -122
  45. package/dist/node/capabilities/capabilityArtifact.d.ts +0 -15
  46. package/dist/node/capabilities/capabilityArtifact.d.ts.map +0 -1
  47. package/dist/node/capabilities/capabilityArtifact.js +0 -37
  48. package/dist/node/capabilities/capabilityArtifactError.d.ts +0 -7
  49. package/dist/node/capabilities/capabilityArtifactError.d.ts.map +0 -1
  50. package/dist/node/capabilities/capabilityArtifactError.js +0 -19
  51. package/dist/node/capabilities/capabilityArtifactTypes.d.ts +0 -32
  52. package/dist/node/capabilities/capabilityArtifactTypes.d.ts.map +0 -1
  53. package/dist/node/capabilities/capabilityArtifactTypes.js +0 -1
  54. package/dist/node/capabilities/capabilityFileMap.d.ts +0 -19
  55. package/dist/node/capabilities/capabilityFileMap.d.ts.map +0 -1
  56. package/dist/node/capabilities/capabilityFileMap.js +0 -234
  57. package/dist/node/capabilities/deterministicGzip.d.ts +0 -2
  58. package/dist/node/capabilities/deterministicGzip.d.ts.map +0 -1
  59. package/dist/node/capabilities/deterministicGzip.js +0 -51
  60. package/dist/node/capabilities/deterministicTar.d.ts +0 -6
  61. package/dist/node/capabilities/deterministicTar.d.ts.map +0 -1
  62. package/dist/node/capabilities/deterministicTar.js +0 -128
  63. package/dist/node/capabilities/skillDirectoryLoader.d.ts +0 -24
  64. package/dist/node/capabilities/skillDirectoryLoader.d.ts.map +0 -1
  65. package/dist/node/capabilities/skillDirectoryLoader.js +0 -308
  66. package/dist/node/capabilities/skillManifest.d.ts +0 -16
  67. package/dist/node/capabilities/skillManifest.d.ts.map +0 -1
  68. package/dist/node/capabilities/skillManifest.js +0 -22
  69. package/dist/node/capabilities/toolManifest.d.ts +0 -12
  70. package/dist/node/capabilities/toolManifest.d.ts.map +0 -1
  71. package/dist/node/capabilities/toolManifest.js +0 -111
  72. package/dist/node/capabilityPublishCli.d.ts +0 -2
  73. package/dist/node/capabilityPublishCli.d.ts.map +0 -1
  74. package/dist/node/capabilityPublishCli.js +0 -115
  75. package/dist/node/cli/spotlightCapabilitiesPublish.d.ts +0 -3
  76. package/dist/node/cli/spotlightCapabilitiesPublish.d.ts.map +0 -1
  77. package/dist/node/cli/spotlightCapabilitiesPublish.js +0 -3
  78. package/dist/node/publishCapabilitiesCli.d.ts +0 -3
  79. package/dist/node/publishCapabilitiesCli.d.ts.map +0 -1
  80. package/dist/node/publishCapabilitiesCli.js +0 -36
  81. package/dist/node/publishCapabilityArtifact.d.ts +0 -12
  82. package/dist/node/publishCapabilityArtifact.d.ts.map +0 -1
  83. package/dist/node/publishCapabilityArtifact.js +0 -25
  84. package/dist/runtimeId.d.ts +0 -3
  85. package/dist/runtimeId.d.ts.map +0 -1
  86. package/dist/runtimeId.js +0 -29
  87. package/dist/tools/frontendTool.d.ts +0 -39
  88. package/dist/tools/frontendTool.d.ts.map +0 -1
  89. package/dist/tools/frontendTool.js +0 -51
  90. package/dist/vite/capabilityBuild.d.ts +0 -9
  91. package/dist/vite/capabilityBuild.d.ts.map +0 -1
  92. package/dist/vite/capabilityBuild.js +0 -169
  93. package/dist/vite/capabilityBuildTypes.d.ts +0 -32
  94. package/dist/vite/capabilityBuildTypes.d.ts.map +0 -1
  95. package/dist/vite/capabilityBuildTypes.js +0 -1
  96. package/dist/vite/capabilityDevMiddleware.d.ts +0 -5
  97. package/dist/vite/capabilityDevMiddleware.d.ts.map +0 -1
  98. package/dist/vite/capabilityDevMiddleware.js +0 -42
  99. package/dist/vite/capabilityVirtualModule.d.ts +0 -11
  100. package/dist/vite/capabilityVirtualModule.d.ts.map +0 -1
  101. package/dist/vite/capabilityVirtualModule.js +0 -60
  102. package/dist/vite/capabilityVirtualModuleTypes.d.ts +0 -12
  103. package/dist/vite/capabilityVirtualModuleTypes.d.ts.map +0 -1
  104. package/dist/vite/capabilityVirtualModuleTypes.js +0 -1
  105. package/dist/vite/spotlightAgentIoc.d.ts +0 -11
  106. package/dist/vite/spotlightAgentIoc.d.ts.map +0 -1
  107. package/dist/vite/spotlightAgentIoc.js +0 -331
  108. package/dist/vite/spotlightCapabilities.d.ts +0 -4
  109. package/dist/vite/spotlightCapabilities.d.ts.map +0 -1
  110. package/dist/vite/spotlightCapabilities.js +0 -187
  111. package/src/agentDecorator.d.ts +0 -17
@@ -1,53 +0,0 @@
1
- export const CAPABILITY_RUNTIME_SYMBOL_V1 = "inupedia.spotlight.capability-runtime/1";
2
- function store() {
3
- const root = globalThis;
4
- const key = Symbol.for(CAPABILITY_RUNTIME_SYMBOL_V1);
5
- return root[key] ??= { providers: new Map(), listeners: new Map() };
6
- }
7
- export function registerCapabilityRuntimeV1(runtime) {
8
- const state = store();
9
- state.providers.set(runtime.capabilityBuildInfo.projectId, runtime);
10
- for (const listener of state.listeners.get(runtime.capabilityBuildInfo.projectId) ?? [])
11
- listener(runtime.capabilityBuildInfo);
12
- }
13
- export function getCapabilityRuntimeV1(projectId) {
14
- const state = store();
15
- const provider = state.providers.get(projectId);
16
- if (!provider)
17
- return undefined;
18
- return Object.freeze({
19
- ...provider,
20
- subscribe(listener) {
21
- const listeners = state.listeners.get(projectId) ?? new Set();
22
- listeners.add(listener);
23
- state.listeners.set(projectId, listeners);
24
- return () => listeners.delete(listener);
25
- },
26
- });
27
- }
28
- export function subscribeCapabilityRuntimeV1(projectId, listener) {
29
- const state = store();
30
- const listeners = state.listeners.get(projectId) ?? new Set();
31
- listeners.add(listener);
32
- state.listeners.set(projectId, listeners);
33
- return () => listeners.delete(listener);
34
- }
35
- export function waitForCapabilityRuntimeV1(projectId, signal) {
36
- if (signal?.aborted)
37
- return Promise.reject(signal.reason ?? new DOMException("Aborted", "AbortError"));
38
- const existing = getCapabilityRuntimeV1(projectId);
39
- if (existing)
40
- return Promise.resolve(existing);
41
- return new Promise((resolve, reject) => {
42
- const onAbort = () => { unsubscribe(); reject(signal?.reason ?? new DOMException("Aborted", "AbortError")); };
43
- const unsubscribe = subscribeCapabilityRuntimeV1(projectId, () => {
44
- const registered = getCapabilityRuntimeV1(projectId);
45
- if (!registered)
46
- return;
47
- unsubscribe();
48
- signal?.removeEventListener("abort", onAbort);
49
- resolve(registered);
50
- });
51
- signal?.addEventListener("abort", onAbort, { once: true });
52
- });
53
- }
@@ -1,4 +0,0 @@
1
- export declare function canonicalArchivePathProblem(path: string, options?: {
2
- directory?: boolean;
3
- }): string | undefined;
4
- //# sourceMappingURL=archivePath.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,22 +0,0 @@
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
- }
@@ -1,7 +0,0 @@
1
- export type CanonicalJsonValue = null | boolean | number | string | CanonicalJsonValue[] | {
2
- [key: string]: CanonicalJsonValue;
3
- };
4
- export declare function compareUtf16(left: string, right: string): number;
5
- export declare function containsLoneSurrogate(value: string): boolean;
6
- export declare function canonicalizeJson(value: unknown): Uint8Array;
7
- //# sourceMappingURL=canonicalJson.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"canonicalJson.d.ts","sourceRoot":"","sources":["../../../src/node/capabilities/canonicalJson.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,kBAAkB,GAC1B,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,kBAAkB,EAAE,GACpB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAAA;CAAE,CAAC;AAI1C,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAa5D;AAkJD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAW3D"}
@@ -1,122 +0,0 @@
1
- import canonicalize from "canonicalize";
2
- import { isProxy } from "node:util/types";
3
- import { CapabilityArtifactError } from "./capabilityArtifactError.js";
4
- const textEncoder = new TextEncoder();
5
- export function compareUtf16(left, right) {
6
- if (left === right)
7
- return 0;
8
- return left < right ? -1 : 1;
9
- }
10
- export function containsLoneSurrogate(value) {
11
- for (let index = 0; index < value.length; index += 1) {
12
- const code = value.charCodeAt(index);
13
- if (code >= 0xd800 && code <= 0xdbff) {
14
- if (index + 1 >= value.length)
15
- return true;
16
- const next = value.charCodeAt(index + 1);
17
- if (next < 0xdc00 || next > 0xdfff)
18
- return true;
19
- index += 1;
20
- continue;
21
- }
22
- if (code >= 0xdc00 && code <= 0xdfff)
23
- return true;
24
- }
25
- return false;
26
- }
27
- function fail(code, path, reason) {
28
- throw new CapabilityArtifactError(code, `${path}: ${reason}`);
29
- }
30
- function validateString(value, path) {
31
- if (containsLoneSurrogate(value)) {
32
- fail("ARTIFACT_JSON_NOT_IJSON", path, "contains a lone surrogate");
33
- }
34
- }
35
- function validateArray(value, path, stack) {
36
- const ownKeys = Reflect.ownKeys(value);
37
- const indexedKeys = [];
38
- for (const key of ownKeys) {
39
- if (key === "length")
40
- continue;
41
- const index = typeof key === "string" ? Number(key) : Number.NaN;
42
- if (typeof key !== "string" ||
43
- !/^(?:0|[1-9]\d*)$/.test(key) ||
44
- !Number.isInteger(index) ||
45
- index < 0 ||
46
- index > 0xfffffffe ||
47
- String(index) !== key) {
48
- fail("ARTIFACT_JSON_UNSUPPORTED_VALUE", path, "array contains a non-index property");
49
- }
50
- indexedKeys.push(key);
51
- }
52
- if (indexedKeys.length !== value.length) {
53
- fail("ARTIFACT_JSON_UNSUPPORTED_VALUE", path, "sparse array entries are not supported");
54
- }
55
- for (const key of indexedKeys) {
56
- const descriptor = Object.getOwnPropertyDescriptor(value, key);
57
- if (!descriptor?.enumerable || !("value" in descriptor)) {
58
- fail("ARTIFACT_JSON_UNSUPPORTED_VALUE", `${path}[${key}]`, "accessor and non-enumerable array entries are not supported");
59
- }
60
- validateJsonValue(descriptor.value, `${path}[${key}]`, stack);
61
- }
62
- }
63
- function validateObject(value, path, stack) {
64
- const prototype = Object.getPrototypeOf(value);
65
- if (prototype !== Object.prototype && prototype !== null) {
66
- fail("ARTIFACT_JSON_UNSUPPORTED_VALUE", path, "only plain JSON objects are supported");
67
- }
68
- for (const key of Reflect.ownKeys(value)) {
69
- if (typeof key !== "string") {
70
- fail("ARTIFACT_JSON_UNSUPPORTED_VALUE", path, "symbol-keyed properties are not supported");
71
- }
72
- validateString(key, `${path} property name`);
73
- const descriptor = Object.getOwnPropertyDescriptor(value, key);
74
- if (!descriptor?.enumerable || !("value" in descriptor)) {
75
- fail("ARTIFACT_JSON_UNSUPPORTED_VALUE", `${path}.${key}`, "accessor and non-enumerable properties are not supported");
76
- }
77
- validateJsonValue(descriptor.value, `${path}.${key}`, stack);
78
- }
79
- }
80
- function validateJsonValue(value, path, stack) {
81
- if (value === null || typeof value === "boolean")
82
- return;
83
- if (typeof value === "string") {
84
- validateString(value, path);
85
- return;
86
- }
87
- if (typeof value === "number") {
88
- if (!Number.isFinite(value)) {
89
- fail("ARTIFACT_JSON_NOT_IJSON", path, "number must be finite");
90
- }
91
- return;
92
- }
93
- if (typeof value !== "object") {
94
- fail("ARTIFACT_JSON_UNSUPPORTED_VALUE", path, `unsupported value type ${typeof value}`);
95
- }
96
- if (isProxy(value)) {
97
- fail("ARTIFACT_JSON_UNSUPPORTED_VALUE", path, "Proxy values are not supported");
98
- }
99
- if (stack.has(value)) {
100
- fail("ARTIFACT_JSON_UNSUPPORTED_VALUE", path, "cyclic value graph");
101
- }
102
- stack.add(value);
103
- try {
104
- if (Array.isArray(value)) {
105
- validateArray(value, path, stack);
106
- }
107
- else {
108
- validateObject(value, path, stack);
109
- }
110
- }
111
- finally {
112
- stack.delete(value);
113
- }
114
- }
115
- export function canonicalizeJson(value) {
116
- validateJsonValue(value, "$", new WeakSet());
117
- const serialized = canonicalize(value);
118
- if (serialized === undefined) {
119
- fail("ARTIFACT_JSON_UNSUPPORTED_VALUE", "$", "canonicalizer returned no JSON output");
120
- }
121
- return textEncoder.encode(serialized);
122
- }
@@ -1,15 +0,0 @@
1
- import type { CapabilityArtifactInputV1 } from "./capabilityArtifactTypes.js";
2
- export interface CapabilityArtifactBuildV1 {
3
- artifactVersion: "spotlight.capability-artifact/1";
4
- artifactDigest: string;
5
- manifestDigest: string;
6
- skillManifestDigest: string;
7
- toolManifestDigest: string;
8
- byteLength: number;
9
- archive: Uint8Array;
10
- manifestBytes: Uint8Array;
11
- skillManifestBytes: Uint8Array;
12
- toolManifestBytes: Uint8Array;
13
- }
14
- export declare function buildCapabilityArtifactV1(input: CapabilityArtifactInputV1): CapabilityArtifactBuildV1;
15
- //# sourceMappingURL=capabilityArtifact.d.ts.map
@@ -1 +0,0 @@
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,37 +0,0 @@
1
- import { buildCapabilityFileMapV1, computeArtifactDigestV1, } from "./capabilityFileMap.js";
2
- import { encodeDeterministicGzipV1 } from "./deterministicGzip.js";
3
- import { encodeDeterministicUstarV1 } from "./deterministicTar.js";
4
- import { buildSkillManifestV1 } from "./skillManifest.js";
5
- import { buildToolManifestV1 } from "./toolManifest.js";
6
- export function buildCapabilityArtifactV1(input) {
7
- const toolManifest = buildToolManifestV1(input.tools);
8
- const skillManifest = buildSkillManifestV1(input.skills);
9
- const fileMap = buildCapabilityFileMapV1({
10
- skills: input.skills,
11
- skillManifestBytes: skillManifest.bytes,
12
- toolManifestBytes: toolManifest.bytes,
13
- });
14
- const artifactDigest = computeArtifactDigestV1({
15
- manifestDigest: fileMap.manifestDigest,
16
- skillManifestDigest: skillManifest.digest,
17
- toolManifestDigest: toolManifest.digest,
18
- payloads: fileMap.payloads,
19
- });
20
- const tar = encodeDeterministicUstarV1([
21
- { path: "manifest.json", bytes: fileMap.manifestBytes },
22
- ...fileMap.payloads.map(({ path, bytes }) => ({ path, bytes })),
23
- ]);
24
- const archive = encodeDeterministicGzipV1(tar);
25
- return {
26
- artifactVersion: "spotlight.capability-artifact/1",
27
- artifactDigest,
28
- manifestDigest: fileMap.manifestDigest,
29
- skillManifestDigest: skillManifest.digest,
30
- toolManifestDigest: toolManifest.digest,
31
- byteLength: archive.byteLength,
32
- archive,
33
- manifestBytes: Uint8Array.from(fileMap.manifestBytes),
34
- skillManifestBytes: Uint8Array.from(skillManifest.bytes),
35
- toolManifestBytes: Uint8Array.from(toolManifest.bytes),
36
- };
37
- }
@@ -1,7 +0,0 @@
1
- export declare const CAPABILITY_ARTIFACT_ERROR_CODES: readonly ["ARTIFACT_JSON_NOT_IJSON", "ARTIFACT_JSON_UNSUPPORTED_VALUE", "ARTIFACT_INPUT_INVALID", "ARTIFACT_TOOL_DUPLICATE", "ARTIFACT_TOOL_INVALID", "ARTIFACT_PATH_INVALID", "ARTIFACT_PATH_DUPLICATE", "ARTIFACT_PATH_USTAR_UNREPRESENTABLE", "ARTIFACT_SIZE_OVERFLOW"];
2
- export type CapabilityArtifactErrorCode = (typeof CAPABILITY_ARTIFACT_ERROR_CODES)[number];
3
- export declare class CapabilityArtifactError extends Error {
4
- readonly code: CapabilityArtifactErrorCode;
5
- constructor(code: CapabilityArtifactErrorCode, message: string);
6
- }
7
- //# sourceMappingURL=capabilityArtifactError.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"capabilityArtifactError.d.ts","sourceRoot":"","sources":["../../../src/node/capabilities/capabilityArtifactError.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,+BAA+B,4QAUlC,CAAC;AAEX,MAAM,MAAM,2BAA2B,GACrC,CAAC,OAAO,+BAA+B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnD,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,IAAI,EAAE,2BAA2B,CAAC;gBAE/B,IAAI,EAAE,2BAA2B,EAAE,OAAO,EAAE,MAAM;CAK/D"}
@@ -1,19 +0,0 @@
1
- export const CAPABILITY_ARTIFACT_ERROR_CODES = [
2
- "ARTIFACT_JSON_NOT_IJSON",
3
- "ARTIFACT_JSON_UNSUPPORTED_VALUE",
4
- "ARTIFACT_INPUT_INVALID",
5
- "ARTIFACT_TOOL_DUPLICATE",
6
- "ARTIFACT_TOOL_INVALID",
7
- "ARTIFACT_PATH_INVALID",
8
- "ARTIFACT_PATH_DUPLICATE",
9
- "ARTIFACT_PATH_USTAR_UNREPRESENTABLE",
10
- "ARTIFACT_SIZE_OVERFLOW",
11
- ];
12
- export class CapabilityArtifactError extends Error {
13
- code;
14
- constructor(code, message) {
15
- super(message);
16
- this.name = "CapabilityArtifactError";
17
- this.code = code;
18
- }
19
- }
@@ -1,32 +0,0 @@
1
- import type { FrontendToolDescriptorV1 } from "@inupedia/spotlight-protocol";
2
- export interface CanonicalSkillFileInputV1 {
3
- relativePath: string;
4
- bytes: Uint8Array;
5
- mediaType?: string;
6
- }
7
- export interface CanonicalSkillInputV1 {
8
- name: string;
9
- files: CanonicalSkillFileInputV1[];
10
- }
11
- export interface CapabilityArtifactInputV1 {
12
- skills: CanonicalSkillInputV1[];
13
- tools: FrontendToolDescriptorV1[];
14
- }
15
- export interface CapabilityPayloadFileV1 {
16
- path: string;
17
- bytes: Uint8Array;
18
- sha256: string;
19
- byteLength: number;
20
- mediaType: string;
21
- }
22
- export interface CapabilityFileManifestEntryV1 {
23
- path: string;
24
- sha256: string;
25
- byteLength: number;
26
- mediaType: string;
27
- }
28
- export interface CapabilityFileManifestV1 {
29
- schemaVersion: "spotlight.capability-manifest/1";
30
- files: CapabilityFileManifestEntryV1[];
31
- }
32
- //# sourceMappingURL=capabilityArtifactTypes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"capabilityArtifactTypes.d.ts","sourceRoot":"","sources":["../../../src/node/capabilities/capabilityArtifactTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAE7E,MAAM,WAAW,yBAAyB;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,UAAU,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,yBAAyB,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,qBAAqB,EAAE,CAAC;IAChC,KAAK,EAAE,wBAAwB,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,6BAA6B;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,wBAAwB;IACvC,aAAa,EAAE,iCAAiC,CAAC;IACjD,KAAK,EAAE,6BAA6B,EAAE,CAAC;CACxC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- import type { CanonicalSkillInputV1, CapabilityFileManifestV1, CapabilityPayloadFileV1 } from "./capabilityArtifactTypes.js";
2
- export interface BuiltCapabilityFileMapV1 {
3
- payloads: CapabilityPayloadFileV1[];
4
- manifest: CapabilityFileManifestV1;
5
- manifestBytes: Uint8Array;
6
- manifestDigest: string;
7
- }
8
- export declare function buildCapabilityFileMapV1(input: {
9
- skills: CanonicalSkillInputV1[];
10
- skillManifestBytes?: Uint8Array;
11
- toolManifestBytes: Uint8Array;
12
- }): BuiltCapabilityFileMapV1;
13
- export declare function computeArtifactDigestV1(input: {
14
- manifestDigest: string;
15
- skillManifestDigest?: string;
16
- toolManifestDigest: string;
17
- payloads: Array<Pick<CapabilityPayloadFileV1, "path" | "sha256">>;
18
- }): string;
19
- //# sourceMappingURL=capabilityFileMap.d.ts.map
@@ -1 +0,0 @@
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,WAAW,wBAAwB;IACvC,QAAQ,EAAE,uBAAuB,EAAE,CAAC;IACpC,QAAQ,EAAE,wBAAwB,CAAC;IACnC,aAAa,EAAE,UAAU,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;CACxB;AAqKD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE;IAC9C,MAAM,EAAE,qBAAqB,EAAE,CAAC;IAChC,kBAAkB,CAAC,EAAE,UAAU,CAAC;IAChC,iBAAiB,EAAE,UAAU,CAAC;CAC/B,GAAG,wBAAwB,CAmG3B;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE;IAC7C,cAAc,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,uBAAuB,EAAE,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC;CACnE,GAAG,MAAM,CA4BT"}
@@ -1,234 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { isProxy } from "node:util/types";
3
- import { canonicalizeJson, compareUtf16, } from "./canonicalJson.js";
4
- import { CapabilityArtifactError } from "./capabilityArtifactError.js";
5
- import { canonicalArchivePathProblem } from "./archivePath.js";
6
- const CANONICAL_SKILL_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
7
- const SHA256_DIGEST = /^sha256:[a-f0-9]{64}$/;
8
- const textEncoder = new TextEncoder();
9
- const MEDIA_TYPES = {
10
- ".md": "text/markdown; charset=utf-8",
11
- ".txt": "text/plain; charset=utf-8",
12
- ".json": "application/json",
13
- ".yaml": "application/yaml",
14
- ".yml": "application/yaml",
15
- ".js": "text/javascript; charset=utf-8",
16
- ".mjs": "text/javascript; charset=utf-8",
17
- ".cjs": "text/javascript; charset=utf-8",
18
- ".ts": "text/typescript; charset=utf-8",
19
- ".tsx": "text/tsx; charset=utf-8",
20
- ".css": "text/css; charset=utf-8",
21
- ".html": "text/html; charset=utf-8",
22
- ".svg": "image/svg+xml",
23
- ".png": "image/png",
24
- ".jpg": "image/jpeg",
25
- ".jpeg": "image/jpeg",
26
- ".webp": "image/webp",
27
- ".gif": "image/gif",
28
- ".pdf": "application/pdf",
29
- ".mp4": "video/mp4",
30
- ".webm": "video/webm",
31
- ".wasm": "application/wasm",
32
- };
33
- function invalidInput(message) {
34
- throw new CapabilityArtifactError("ARTIFACT_INPUT_INVALID", message);
35
- }
36
- function isCanonicalArrayIndex(key) {
37
- if (!/^(?:0|[1-9]\d*)$/.test(key))
38
- return false;
39
- const index = Number(key);
40
- return (Number.isInteger(index) &&
41
- index >= 0 &&
42
- index <= 0xfffffffe &&
43
- String(index) === key);
44
- }
45
- function readDenseDataArray(value, label) {
46
- if (isProxy(value))
47
- invalidInput(`${label} must not be a Proxy`);
48
- if (!Array.isArray(value))
49
- invalidInput(`${label} must be an array`);
50
- const keys = [];
51
- for (const key of Reflect.ownKeys(value)) {
52
- if (key === "length")
53
- continue;
54
- if (typeof key !== "string" || !isCanonicalArrayIndex(key)) {
55
- invalidInput(`${label} contains a non-index property`);
56
- }
57
- keys.push(key);
58
- }
59
- if (keys.length !== value.length)
60
- invalidInput(`${label} must be dense`);
61
- keys.sort((left, right) => Number(left) - Number(right));
62
- return keys.map((key) => {
63
- const descriptor = Object.getOwnPropertyDescriptor(value, key);
64
- if (!descriptor?.enumerable || !("value" in descriptor)) {
65
- invalidInput(`${label}[${key}] must be an enumerable data property`);
66
- }
67
- return descriptor.value;
68
- });
69
- }
70
- function readDataRecord(value, label, allowedFields) {
71
- if (isProxy(value))
72
- invalidInput(`${label} must not be a Proxy`);
73
- if (value === null || typeof value !== "object" || Array.isArray(value)) {
74
- invalidInput(`${label} must be a plain object`);
75
- }
76
- const prototype = Object.getPrototypeOf(value);
77
- if (prototype !== Object.prototype && prototype !== null) {
78
- invalidInput(`${label} must be a plain object`);
79
- }
80
- const record = {};
81
- for (const key of Reflect.ownKeys(value)) {
82
- if (typeof key !== "string" || !allowedFields.has(key)) {
83
- invalidInput(`${label} contains an unknown field`);
84
- }
85
- const descriptor = Object.getOwnPropertyDescriptor(value, key);
86
- if (!descriptor?.enumerable || !("value" in descriptor)) {
87
- invalidInput(`${label}.${key} must be an enumerable data property`);
88
- }
89
- record[key] = descriptor.value;
90
- }
91
- return record;
92
- }
93
- function sha256(bytes) {
94
- return `sha256:${createHash("sha256").update(bytes).digest("hex")}`;
95
- }
96
- function byteLength(value) {
97
- return textEncoder.encode(value).byteLength;
98
- }
99
- function canRepresentUstarPath(path) {
100
- if (byteLength(path) <= 100)
101
- return true;
102
- for (let index = path.lastIndexOf("/"); index > 0; index = path.lastIndexOf("/", index - 1)) {
103
- const prefix = path.slice(0, index);
104
- const name = path.slice(index + 1);
105
- if (name.length > 0 && byteLength(prefix) <= 155 && byteLength(name) <= 100) {
106
- return true;
107
- }
108
- }
109
- return false;
110
- }
111
- function validateSkillName(name) {
112
- if (typeof name !== "string") {
113
- invalidInput("Skill name must be a string");
114
- }
115
- if (!CANONICAL_SKILL_NAME.test(name) || name.length > 64) {
116
- throw new CapabilityArtifactError("ARTIFACT_PATH_INVALID", `Invalid canonical Skill name: ${name}`);
117
- }
118
- }
119
- function validateRelativePath(relativePath) {
120
- if (typeof relativePath !== "string") {
121
- invalidInput("Skill relativePath must be a string");
122
- }
123
- if (canonicalArchivePathProblem(relativePath)) {
124
- throw new CapabilityArtifactError("ARTIFACT_PATH_INVALID", `Invalid Skill relative path: ${relativePath}`);
125
- }
126
- }
127
- function ensureUstarPath(path) {
128
- if (!canRepresentUstarPath(path)) {
129
- throw new CapabilityArtifactError("ARTIFACT_PATH_USTAR_UNREPRESENTABLE", `Path cannot be represented by POSIX USTAR: ${path}`);
130
- }
131
- }
132
- function inferMediaType(path) {
133
- const filename = path.slice(path.lastIndexOf("/") + 1);
134
- const dot = filename.lastIndexOf(".");
135
- const extension = dot >= 0 ? filename.slice(dot).toLowerCase() : "";
136
- return MEDIA_TYPES[extension] ?? "application/octet-stream";
137
- }
138
- function createPayload(path, sourceBytes, mediaType) {
139
- const bytes = Uint8Array.from(sourceBytes);
140
- if (!Number.isSafeInteger(bytes.byteLength)) {
141
- throw new CapabilityArtifactError("ARTIFACT_SIZE_OVERFLOW", `Payload byte length exceeds safe integer range: ${path}`);
142
- }
143
- return {
144
- path,
145
- bytes,
146
- sha256: sha256(bytes),
147
- byteLength: bytes.byteLength,
148
- mediaType,
149
- };
150
- }
151
- function addPayload(payloads, seenPaths, payload) {
152
- if (seenPaths.has(payload.path)) {
153
- throw new CapabilityArtifactError("ARTIFACT_PATH_DUPLICATE", `Duplicate Artifact payload path: ${payload.path}`);
154
- }
155
- seenPaths.add(payload.path);
156
- payloads.push(payload);
157
- }
158
- export function buildCapabilityFileMapV1(input) {
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
- }
164
- if (isProxy(root.toolManifestBytes) ||
165
- !(root.toolManifestBytes instanceof Uint8Array)) {
166
- invalidInput("toolManifestBytes must be a Uint8Array");
167
- }
168
- const skills = readDenseDataArray(root.skills, "skills");
169
- const payloads = [];
170
- const seenPaths = new Set();
171
- if (root.skillManifestBytes instanceof Uint8Array) {
172
- addPayload(payloads, seenPaths, createPayload("skill-manifest.json", root.skillManifestBytes, "application/json"));
173
- }
174
- addPayload(payloads, seenPaths, createPayload("tool-manifest.json", root.toolManifestBytes, "application/json"));
175
- for (const [skillIndex, skillValue] of skills.entries()) {
176
- const skill = readDataRecord(skillValue, `skills[${skillIndex}]`, new Set(["name", "files"]));
177
- validateSkillName(skill.name);
178
- const files = readDenseDataArray(skill.files, `skills[${skillIndex}].files`);
179
- for (const [fileIndex, fileValue] of files.entries()) {
180
- const file = readDataRecord(fileValue, `skills[${skillIndex}].files[${fileIndex}]`, new Set(["relativePath", "bytes", "mediaType"]));
181
- validateRelativePath(file.relativePath);
182
- if (isProxy(file.bytes) || !(file.bytes instanceof Uint8Array)) {
183
- invalidInput(`skills[${skillIndex}].files[${fileIndex}].bytes must be a Uint8Array`);
184
- }
185
- if (file.mediaType !== undefined &&
186
- (typeof file.mediaType !== "string" || file.mediaType.trim().length === 0)) {
187
- invalidInput(`skills[${skillIndex}].files[${fileIndex}].mediaType must be a non-empty string`);
188
- }
189
- const path = `skills/${skill.name}/${file.relativePath}`;
190
- ensureUstarPath(path);
191
- addPayload(payloads, seenPaths, createPayload(path, file.bytes, typeof file.mediaType === "string"
192
- ? file.mediaType
193
- : inferMediaType(path)));
194
- }
195
- }
196
- payloads.sort((left, right) => compareUtf16(left.path, right.path));
197
- const candidate = {
198
- schemaVersion: "spotlight.capability-manifest/1",
199
- files: payloads.map(({ path, sha256: digest, byteLength: length, mediaType }) => ({
200
- path,
201
- sha256: digest,
202
- byteLength: length,
203
- mediaType,
204
- })),
205
- };
206
- const manifestBytes = canonicalizeJson(candidate);
207
- const manifest = JSON.parse(new TextDecoder().decode(manifestBytes));
208
- return {
209
- payloads,
210
- manifest,
211
- manifestBytes,
212
- manifestDigest: sha256(manifestBytes),
213
- };
214
- }
215
- export function computeArtifactDigestV1(input) {
216
- if (!SHA256_DIGEST.test(input.manifestDigest) || (input.skillManifestDigest !== undefined && !SHA256_DIGEST.test(input.skillManifestDigest)) || !SHA256_DIGEST.test(input.toolManifestDigest)) {
217
- throw new CapabilityArtifactError("ARTIFACT_JSON_NOT_IJSON", "Artifact preimage contains an invalid manifest digest");
218
- }
219
- const payloadDigests = input.payloads
220
- .map(({ path, sha256: digest }) => {
221
- if (!SHA256_DIGEST.test(digest)) {
222
- throw new CapabilityArtifactError("ARTIFACT_JSON_NOT_IJSON", `Artifact preimage contains an invalid payload digest: ${path}`);
223
- }
224
- return { path, sha256: digest };
225
- })
226
- .sort((left, right) => compareUtf16(left.path, right.path));
227
- return sha256(canonicalizeJson({
228
- artifactVersion: "spotlight.capability-artifact/1",
229
- manifestDigest: input.manifestDigest,
230
- ...(input.skillManifestDigest ? { skillManifestDigest: input.skillManifestDigest } : {}),
231
- toolManifestDigest: input.toolManifestDigest,
232
- payloadDigests,
233
- }));
234
- }
@@ -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"}