@inupedia/spotlight-client 0.2.14 → 0.2.15

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,40 +0,0 @@
1
- const ROUTE_PREFIX = "/@spotlight/capability-artifacts/";
2
- const DIGEST_PATTERN = /^sha256:[a-f0-9]{64}$/;
3
- export function createCapabilityDevMiddlewareV1(currentResult) {
4
- return (request, response, next) => {
5
- const url = request.url ?? "";
6
- if (!url.startsWith(ROUTE_PREFIX)) {
7
- next();
8
- return;
9
- }
10
- const requestedDigest = url.slice(ROUTE_PREFIX.length);
11
- if (!DIGEST_PATTERN.test(requestedDigest)) {
12
- response.statusCode = 404;
13
- response.end();
14
- return;
15
- }
16
- const method = request.method ?? "GET";
17
- if (method !== "GET" && method !== "HEAD") {
18
- response.statusCode = 405;
19
- response.setHeader("Allow", "GET, HEAD");
20
- response.end();
21
- return;
22
- }
23
- const result = currentResult();
24
- if (requestedDigest !== result.buildInfo.artifactDigest) {
25
- response.statusCode = 404;
26
- response.end();
27
- return;
28
- }
29
- response.statusCode = 200;
30
- response.setHeader("Content-Type", "application/gzip");
31
- response.setHeader("Content-Length", String(result.archive.byteLength));
32
- response.setHeader("Cache-Control", "no-store");
33
- response.setHeader("X-Content-Type-Options", "nosniff");
34
- if (method === "HEAD") {
35
- response.end();
36
- return;
37
- }
38
- response.end(Buffer.from(result.archive.buffer, result.archive.byteOffset, result.archive.byteLength));
39
- };
40
- }
@@ -1,11 +0,0 @@
1
- import type { CapabilityBuildInfoV1 } from "./capabilityBuildTypes.js";
2
- export declare const SPOTLIGHT_CAPABILITIES_MODULE_ID: "virtual:spotlight/capabilities";
3
- export declare const RESOLVED_SPOTLIGHT_CAPABILITIES_MODULE_ID: "\0virtual:spotlight/capabilities";
4
- export interface CapabilityVirtualModuleV1 {
5
- canonicalBuildInfoJson: string;
6
- source: string;
7
- }
8
- export declare function buildCapabilityVirtualModuleV1(buildInfo: Readonly<CapabilityBuildInfoV1>, options?: Readonly<{
9
- runtimeUpload?: boolean;
10
- }>): Readonly<CapabilityVirtualModuleV1>;
11
- //# sourceMappingURL=capabilityVirtualModule.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"capabilityVirtualModule.d.ts","sourceRoot":"","sources":["../../src/vite/capabilityVirtualModule.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAEvE,eAAO,MAAM,gCAAgC,EAC3C,gCAAyC,CAAC;AAC5C,eAAO,MAAM,yCAAyC,EACpD,kCAA2C,CAAC;AAE9C,MAAM,WAAW,yBAAyB;IACxC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;CAChB;AAyCD,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,QAAQ,CAAC,qBAAqB,CAAC,EAC1C,OAAO,GAAE,QAAQ,CAAC;IAAE,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE,CAAM,GAClD,QAAQ,CAAC,yBAAyB,CAAC,CAQrC"}
@@ -1,43 +0,0 @@
1
- import { canonicalizeJson } from "../node/capabilities/canonicalJson.js";
2
- export const SPOTLIGHT_CAPABILITIES_MODULE_ID = "virtual:spotlight/capabilities";
3
- export const RESOLVED_SPOTLIGHT_CAPABILITIES_MODULE_ID = "\0virtual:spotlight/capabilities";
4
- function disabledProviderSource() {
5
- return `export async function openUploadStream() {
6
- const error = new Error("Runtime capability Artifact upload is disabled.");
7
- Object.defineProperty(error, "code", {
8
- value: "ARTIFACT_RUNTIME_UPLOAD_DISABLED",
9
- enumerable: true,
10
- });
11
- throw error;
12
- }`;
13
- }
14
- function developmentProviderSource(buildInfo) {
15
- const digest = JSON.stringify(buildInfo.artifactDigest);
16
- const path = JSON.stringify(`/@spotlight/capability-artifacts/${buildInfo.artifactDigest}`);
17
- return `export async function openUploadStream() {
18
- const response = await fetch(${path}, {
19
- method: "GET",
20
- cache: "no-store",
21
- credentials: "same-origin",
22
- });
23
- if (!response.ok) {
24
- throw new Error("Unable to open capability Artifact stream.");
25
- }
26
- if (response.body == null) {
27
- throw new Error("Capability Artifact response has no stream body.");
28
- }
29
- return {
30
- digest: ${digest},
31
- byteLength: capabilityBuildInfo.byteLength,
32
- contentType: "application/gzip",
33
- stream: response.body,
34
- };
35
- }`;
36
- }
37
- export function buildCapabilityVirtualModuleV1(buildInfo, options = {}) {
38
- const canonicalBuildInfoJson = new TextDecoder().decode(canonicalizeJson(buildInfo));
39
- return Object.freeze({
40
- canonicalBuildInfoJson,
41
- source: `export const capabilityBuildInfo = Object.freeze(${canonicalBuildInfoJson});\n\n${options.runtimeUpload === true ? developmentProviderSource(buildInfo) : disabledProviderSource()}\n`,
42
- });
43
- }
@@ -1,12 +0,0 @@
1
- declare module "virtual:spotlight/capabilities" {
2
- import type { CapabilityBuildInfoV1 } from "@inupedia/spotlight-client/vite";
3
- interface ArtifactUploadStreamV1 {
4
- digest: string;
5
- byteLength: number;
6
- contentType: "application/gzip";
7
- stream: ReadableStream<Uint8Array>;
8
- }
9
- const capabilityBuildInfo: Readonly<CapabilityBuildInfoV1>;
10
- function openUploadStream(): Promise<ArtifactUploadStreamV1>;
11
- }
12
- //# sourceMappingURL=capabilityVirtualModuleTypes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"capabilityVirtualModuleTypes.d.ts","sourceRoot":"","sources":["../../src/vite/capabilityVirtualModuleTypes.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,gCAAgC,CAAC;IAC9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;IAE7E,UAAiB,sBAAsB;QACrC,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,kBAAkB,CAAC;QAChC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;KACpC;IAEM,MAAM,mBAAmB,EAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC;IAElE,SAAgB,gBAAgB,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACrE"}
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,4 +0,0 @@
1
- import type { Plugin } from "vite";
2
- import { type SpotlightCapabilitiesOptionsV1, type SpotlightCapabilityProjectBuildV1 } from "./capabilityBuild.js";
3
- export declare function spotlightCapabilities(project: SpotlightCapabilityProjectBuildV1, options?: SpotlightCapabilitiesOptionsV1): Plugin;
4
- //# sourceMappingURL=spotlightCapabilities.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"spotlightCapabilities.d.ts","sourceRoot":"","sources":["../../src/vite/spotlightCapabilities.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAiC,MAAM,MAAM,CAAC;AAKlE,OAAO,EAGL,KAAK,8BAA8B,EACnC,KAAK,iCAAiC,EACvC,MAAM,sBAAsB,CAAC;AAuB9B,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,iCAAiC,EAC1C,OAAO,CAAC,EAAE,8BAA8B,GACvC,MAAM,CAoKR"}
@@ -1,165 +0,0 @@
1
- import { isAbsolute, relative, resolve, sep } from "node:path";
2
- import { DEFAULT_SKILL_ROOTS } from "../node/index.js";
3
- import { createCapabilityDevMiddlewareV1 } from "./capabilityDevMiddleware.js";
4
- import { buildViteCapabilitiesV1, } from "./capabilityBuild.js";
5
- import { buildCapabilityVirtualModuleV1, RESOLVED_SPOTLIGHT_CAPABILITIES_MODULE_ID, SPOTLIGHT_CAPABILITIES_MODULE_ID, } from "./capabilityVirtualModule.js";
6
- function isAtOrBelow(candidate, directory) {
7
- const relativePath = relative(directory, candidate);
8
- return (relativePath === "" ||
9
- (!relativePath.startsWith(`..${sep}`) &&
10
- relativePath !== ".." &&
11
- !isAbsolute(relativePath)));
12
- }
13
- export function spotlightCapabilities(project, options) {
14
- let root;
15
- let command;
16
- let state;
17
- let server;
18
- let rebuildChain = Promise.resolve();
19
- let relevantRoots = [];
20
- let removeServerListeners;
21
- let finishInitialization;
22
- const initialization = new Promise((resolveInitialization) => {
23
- finishInitialization = resolveInitialization;
24
- });
25
- const currentState = () => {
26
- if (state === undefined) {
27
- throw new Error("Spotlight capabilities were not built.");
28
- }
29
- return state;
30
- };
31
- const createState = (result) => Object.freeze({
32
- result: Object.freeze(result),
33
- virtualModule: buildCapabilityVirtualModuleV1(result.buildInfo, {
34
- runtimeUpload: command === "serve" && options?.devRuntimeUpload !== false,
35
- }),
36
- });
37
- const isRelevantFile = (file) => {
38
- const absoluteFile = resolve(file);
39
- const current = state;
40
- return (current?.result.watchedFiles.some((watchedFile) => resolve(watchedFile) === absoluteFile) === true ||
41
- relevantRoots.some((skillRoot) => isAtOrBelow(absoluteFile, skillRoot)));
42
- };
43
- const enqueueRebuild = (file) => {
44
- if (command !== "serve" || root === undefined || !isRelevantFile(file)) {
45
- return Promise.resolve();
46
- }
47
- const projectRoot = root;
48
- const task = rebuildChain.then(async () => {
49
- await initialization;
50
- if (state === undefined)
51
- return;
52
- try {
53
- const result = await buildViteCapabilitiesV1({
54
- root: projectRoot,
55
- command: "serve",
56
- project,
57
- options,
58
- });
59
- const nextState = createState(result);
60
- server?.watcher.add([...result.watchedFiles]);
61
- const moduleNode = server?.moduleGraph.getModuleById(RESOLVED_SPOTLIGHT_CAPABILITIES_MODULE_ID);
62
- const previousState = state;
63
- state = nextState;
64
- try {
65
- if (moduleNode !== undefined) {
66
- server?.moduleGraph.invalidateModule(moduleNode);
67
- }
68
- }
69
- catch (error) {
70
- state = previousState;
71
- throw error;
72
- }
73
- }
74
- catch {
75
- try {
76
- server?.config.logger.error("[CAPABILITY_DEV_REBUILD_FAILED] Capability development rebuild failed.");
77
- }
78
- catch {
79
- // A development logger failure must not poison later rebuilds.
80
- }
81
- }
82
- });
83
- rebuildChain = task.catch(() => undefined);
84
- return task;
85
- };
86
- return {
87
- name: "spotlight-capabilities",
88
- configResolved(config) {
89
- root = config.root;
90
- command = config.command;
91
- const roots = options?.skillRoots ?? DEFAULT_SKILL_ROOTS;
92
- relevantRoots = Object.freeze(roots.map((entry) => {
93
- const path = typeof entry === "string" ? entry : entry.path;
94
- return resolve(config.root, path);
95
- }));
96
- },
97
- async buildStart() {
98
- if (root === undefined || command === undefined) {
99
- throw new Error("Spotlight capabilities require resolved Vite config.");
100
- }
101
- try {
102
- const result = await buildViteCapabilitiesV1({
103
- root,
104
- command,
105
- project,
106
- options,
107
- });
108
- state = createState(result);
109
- for (const file of result.watchedFiles)
110
- this.addWatchFile(file);
111
- }
112
- finally {
113
- finishInitialization();
114
- }
115
- },
116
- configureServer(viteServer) {
117
- removeServerListeners?.();
118
- server = viteServer;
119
- viteServer.watcher.add([...relevantRoots]);
120
- const add = (file) => enqueueRebuild(file);
121
- const change = (file) => enqueueRebuild(file);
122
- const unlink = (file) => enqueueRebuild(file);
123
- viteServer.watcher.on("add", add);
124
- viteServer.watcher.on("change", change);
125
- viteServer.watcher.on("unlink", unlink);
126
- const cleanup = () => {
127
- viteServer.watcher.off("add", add);
128
- viteServer.watcher.off("change", change);
129
- viteServer.watcher.off("unlink", unlink);
130
- viteServer.httpServer?.off("close", cleanup);
131
- if (removeServerListeners === cleanup) {
132
- removeServerListeners = undefined;
133
- }
134
- };
135
- removeServerListeners = cleanup;
136
- viteServer.httpServer?.once("close", cleanup);
137
- if (options?.devRuntimeUpload === false)
138
- return;
139
- viteServer.middlewares.use(createCapabilityDevMiddlewareV1(() => currentState().result));
140
- },
141
- resolveId(id) {
142
- return id === SPOTLIGHT_CAPABILITIES_MODULE_ID
143
- ? RESOLVED_SPOTLIGHT_CAPABILITIES_MODULE_ID
144
- : null;
145
- },
146
- load(id) {
147
- if (id !== RESOLVED_SPOTLIGHT_CAPABILITIES_MODULE_ID)
148
- return null;
149
- return currentState().virtualModule.source;
150
- },
151
- closeBundle() {
152
- removeServerListeners?.();
153
- },
154
- generateBundle() {
155
- if (command !== "build")
156
- return;
157
- const current = currentState();
158
- this.emitFile({
159
- type: "asset",
160
- fileName: "capability-build-info.json",
161
- source: `${current.virtualModule.canonicalBuildInfoJson}\n`,
162
- });
163
- },
164
- };
165
- }