@inupedia/spotlight-client 0.3.6 → 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.
- package/README.md +14 -123
- package/dist/clientTool.d.ts +42 -0
- package/dist/clientTool.d.ts.map +1 -0
- package/dist/clientTool.js +97 -0
- package/dist/index.d.ts +2 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -18
- package/dist/node/capabilities/skillFileValidator.d.ts +0 -8
- package/dist/node/capabilities/skillFileValidator.d.ts.map +1 -1
- package/dist/node/capabilities/skillFileValidator.js +26 -46
- package/dist/node/index.d.ts +0 -10
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +0 -9
- package/dist/vite/index.d.ts +1 -7
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +1 -4
- package/dist/vite/spotlightClientTools.d.ts +27 -0
- package/dist/vite/spotlightClientTools.d.ts.map +1 -0
- package/dist/vite/spotlightClientTools.js +424 -0
- package/package.json +6 -20
- package/dist/capabilities/channel.d.ts +0 -28
- package/dist/capabilities/channel.d.ts.map +0 -1
- package/dist/capabilities/channel.js +0 -194
- package/dist/capabilities/errors.d.ts +0 -9
- package/dist/capabilities/errors.d.ts.map +0 -1
- package/dist/capabilities/errors.js +0 -19
- package/dist/capabilities/handshake.d.ts +0 -38
- package/dist/capabilities/handshake.d.ts.map +0 -1
- package/dist/capabilities/handshake.js +0 -139
- package/dist/capabilities/hostActionExecutor.d.ts +0 -22
- package/dist/capabilities/hostActionExecutor.d.ts.map +0 -1
- package/dist/capabilities/hostActionExecutor.js +0 -56
- package/dist/capabilities/jsonSchema.d.ts +0 -2
- package/dist/capabilities/jsonSchema.d.ts.map +0 -1
- package/dist/capabilities/jsonSchema.js +0 -73
- package/dist/capabilities/runtimeCapabilities.d.ts +0 -25
- package/dist/capabilities/runtimeCapabilities.d.ts.map +0 -1
- package/dist/capabilities/runtimeCapabilities.js +0 -53
- package/dist/node/capabilities/archivePath.d.ts +0 -4
- package/dist/node/capabilities/archivePath.d.ts.map +0 -1
- package/dist/node/capabilities/archivePath.js +0 -22
- package/dist/node/capabilities/canonicalJson.d.ts +0 -7
- package/dist/node/capabilities/canonicalJson.d.ts.map +0 -1
- package/dist/node/capabilities/canonicalJson.js +0 -122
- package/dist/node/capabilities/capabilityArtifact.d.ts +0 -15
- package/dist/node/capabilities/capabilityArtifact.d.ts.map +0 -1
- package/dist/node/capabilities/capabilityArtifact.js +0 -37
- package/dist/node/capabilities/capabilityArtifactError.d.ts +0 -7
- package/dist/node/capabilities/capabilityArtifactError.d.ts.map +0 -1
- package/dist/node/capabilities/capabilityArtifactError.js +0 -19
- package/dist/node/capabilities/capabilityArtifactTypes.d.ts +0 -32
- package/dist/node/capabilities/capabilityArtifactTypes.d.ts.map +0 -1
- package/dist/node/capabilities/capabilityArtifactTypes.js +0 -1
- package/dist/node/capabilities/capabilityFileMap.d.ts +0 -19
- package/dist/node/capabilities/capabilityFileMap.d.ts.map +0 -1
- package/dist/node/capabilities/capabilityFileMap.js +0 -234
- package/dist/node/capabilities/deterministicGzip.d.ts +0 -2
- package/dist/node/capabilities/deterministicGzip.d.ts.map +0 -1
- package/dist/node/capabilities/deterministicGzip.js +0 -51
- package/dist/node/capabilities/deterministicTar.d.ts +0 -6
- package/dist/node/capabilities/deterministicTar.d.ts.map +0 -1
- package/dist/node/capabilities/deterministicTar.js +0 -128
- package/dist/node/capabilities/skillDirectoryLoader.d.ts +0 -24
- package/dist/node/capabilities/skillDirectoryLoader.d.ts.map +0 -1
- package/dist/node/capabilities/skillDirectoryLoader.js +0 -308
- package/dist/node/capabilities/skillManifest.d.ts +0 -16
- package/dist/node/capabilities/skillManifest.d.ts.map +0 -1
- package/dist/node/capabilities/skillManifest.js +0 -22
- package/dist/node/capabilities/toolManifest.d.ts +0 -12
- package/dist/node/capabilities/toolManifest.d.ts.map +0 -1
- package/dist/node/capabilities/toolManifest.js +0 -111
- package/dist/node/capabilityPublishCli.d.ts +0 -2
- package/dist/node/capabilityPublishCli.d.ts.map +0 -1
- package/dist/node/capabilityPublishCli.js +0 -115
- package/dist/node/cli/spotlightCapabilitiesPublish.d.ts +0 -3
- package/dist/node/cli/spotlightCapabilitiesPublish.d.ts.map +0 -1
- package/dist/node/cli/spotlightCapabilitiesPublish.js +0 -3
- package/dist/node/publishCapabilitiesCli.d.ts +0 -3
- package/dist/node/publishCapabilitiesCli.d.ts.map +0 -1
- package/dist/node/publishCapabilitiesCli.js +0 -36
- package/dist/node/publishCapabilityArtifact.d.ts +0 -12
- package/dist/node/publishCapabilityArtifact.d.ts.map +0 -1
- package/dist/node/publishCapabilityArtifact.js +0 -25
- package/dist/runtimeId.d.ts +0 -3
- package/dist/runtimeId.d.ts.map +0 -1
- package/dist/runtimeId.js +0 -29
- package/dist/tools/frontendTool.d.ts +0 -39
- package/dist/tools/frontendTool.d.ts.map +0 -1
- package/dist/tools/frontendTool.js +0 -51
- package/dist/vite/capabilityBuild.d.ts +0 -9
- package/dist/vite/capabilityBuild.d.ts.map +0 -1
- package/dist/vite/capabilityBuild.js +0 -169
- package/dist/vite/capabilityBuildTypes.d.ts +0 -32
- package/dist/vite/capabilityBuildTypes.d.ts.map +0 -1
- package/dist/vite/capabilityBuildTypes.js +0 -1
- package/dist/vite/capabilityDevMiddleware.d.ts +0 -5
- package/dist/vite/capabilityDevMiddleware.d.ts.map +0 -1
- package/dist/vite/capabilityDevMiddleware.js +0 -42
- package/dist/vite/capabilityVirtualModule.d.ts +0 -11
- package/dist/vite/capabilityVirtualModule.d.ts.map +0 -1
- package/dist/vite/capabilityVirtualModule.js +0 -60
- package/dist/vite/capabilityVirtualModuleTypes.d.ts +0 -12
- package/dist/vite/capabilityVirtualModuleTypes.d.ts.map +0 -1
- package/dist/vite/capabilityVirtualModuleTypes.js +0 -1
- package/dist/vite/spotlightAgentIoc.d.ts +0 -11
- package/dist/vite/spotlightAgentIoc.d.ts.map +0 -1
- package/dist/vite/spotlightAgentIoc.js +0 -331
- package/dist/vite/spotlightCapabilities.d.ts +0 -4
- package/dist/vite/spotlightCapabilities.d.ts.map +0 -1
- package/dist/vite/spotlightCapabilities.js +0 -187
- package/src/agentDecorator.d.ts +0 -17
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { FrontendToolDescriptorV1 } from "@inupedia/spotlight-protocol";
|
|
2
|
-
import type { FrontendToolDefinitionV1 } from "../tools/frontendTool.js";
|
|
3
|
-
import type { SkillRootInput, SkillScanDiagnostic } from "../node/capabilities/skillScanner.js";
|
|
4
|
-
import type { AgentSkillDiagnostic } from "../node/capabilities/skillValidator.js";
|
|
5
|
-
export interface SpotlightCapabilityProjectBuildV1 {
|
|
6
|
-
projectId: string;
|
|
7
|
-
skillRoots?: readonly SkillRootInput[];
|
|
8
|
-
tools: readonly (FrontendToolDescriptorV1 | FrontendToolDefinitionV1)[];
|
|
9
|
-
}
|
|
10
|
-
export interface SpotlightCapabilitiesOptionsV1 {
|
|
11
|
-
skillRoots?: readonly SkillRootInput[];
|
|
12
|
-
frontendBuildId?: string;
|
|
13
|
-
devRuntimeUpload?: boolean;
|
|
14
|
-
}
|
|
15
|
-
export interface CapabilityBuildInfoV1 {
|
|
16
|
-
schemaVersion: "spotlight.capability-build-info/1";
|
|
17
|
-
projectId: string;
|
|
18
|
-
frontendBuildId: string;
|
|
19
|
-
artifactVersion: "spotlight.capability-artifact/1";
|
|
20
|
-
artifactDigest: string;
|
|
21
|
-
manifestDigest: string;
|
|
22
|
-
skillManifestDigest: string;
|
|
23
|
-
toolManifestDigest: string;
|
|
24
|
-
byteLength: number;
|
|
25
|
-
}
|
|
26
|
-
export interface CapabilityPluginBuildResultV1 {
|
|
27
|
-
buildInfo: Readonly<CapabilityBuildInfoV1>;
|
|
28
|
-
archive: Uint8Array;
|
|
29
|
-
watchedFiles: readonly string[];
|
|
30
|
-
diagnostics: readonly (SkillScanDiagnostic | AgentSkillDiagnostic)[];
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=capabilityBuildTypes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"capabilityBuildTypes.d.ts","sourceRoot":"","sources":["../../src/vite/capabilityBuildTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEzE,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAChG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAEnF,MAAM,WAAW,iCAAiC;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IACvC,KAAK,EAAE,SAAS,CAAC,wBAAwB,GAAG,wBAAwB,CAAC,EAAE,CAAC;CACzE;AAED,MAAM,WAAW,8BAA8B;IAC7C,UAAU,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IACvC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,mCAAmC,CAAC;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,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;CACpB;AAED,MAAM,WAAW,6BAA6B;IAC5C,SAAS,EAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC;IAC3C,OAAO,EAAE,UAAU,CAAC;IACpB,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,WAAW,EAAE,SAAS,CAAC,mBAAmB,GAAG,oBAAoB,CAAC,EAAE,CAAC;CACtE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
-
import type { CapabilityPluginBuildResultV1 } from "./capabilityBuildTypes.js";
|
|
3
|
-
export type CapabilityDevMiddlewareV1 = (request: IncomingMessage, response: ServerResponse, next: () => void) => void;
|
|
4
|
-
export declare function createCapabilityDevMiddlewareV1(currentResult: () => Readonly<CapabilityPluginBuildResultV1>, base?: string): CapabilityDevMiddlewareV1;
|
|
5
|
-
//# sourceMappingURL=capabilityDevMiddleware.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"capabilityDevMiddleware.d.ts","sourceRoot":"","sources":["../../src/vite/capabilityDevMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEjE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAK/E,MAAM,MAAM,yBAAyB,GAAG,CACtC,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,MAAM,IAAI,KACb,IAAI,CAAC;AAEV,wBAAgB,+BAA+B,CAC7C,aAAa,EAAE,MAAM,QAAQ,CAAC,6BAA6B,CAAC,EAC5D,IAAI,SAAM,GACT,yBAAyB,CAkD3B"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const ROUTE_SUFFIX = "@spotlight/capability-artifacts/";
|
|
2
|
-
const DIGEST_PATTERN = /^sha256:[a-f0-9]{64}$/;
|
|
3
|
-
export function createCapabilityDevMiddlewareV1(currentResult, base = "/") {
|
|
4
|
-
const normalizedBase = `/${base}`.replace(/\/+/g, "/").replace(/\/?$/, "/");
|
|
5
|
-
const routePrefix = `${normalizedBase}${ROUTE_SUFFIX}`;
|
|
6
|
-
return (request, response, next) => {
|
|
7
|
-
const url = request.url ?? "";
|
|
8
|
-
if (!url.startsWith(routePrefix)) {
|
|
9
|
-
next();
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const requestedDigest = url.slice(routePrefix.length);
|
|
13
|
-
if (!DIGEST_PATTERN.test(requestedDigest)) {
|
|
14
|
-
response.statusCode = 404;
|
|
15
|
-
response.end();
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
const method = request.method ?? "GET";
|
|
19
|
-
if (method !== "GET" && method !== "HEAD") {
|
|
20
|
-
response.statusCode = 405;
|
|
21
|
-
response.setHeader("Allow", "GET, HEAD");
|
|
22
|
-
response.end();
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const result = currentResult();
|
|
26
|
-
if (requestedDigest !== result.buildInfo.artifactDigest) {
|
|
27
|
-
response.statusCode = 404;
|
|
28
|
-
response.end();
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
response.statusCode = 200;
|
|
32
|
-
response.setHeader("Content-Type", "application/gzip");
|
|
33
|
-
response.setHeader("Content-Length", String(result.archive.byteLength));
|
|
34
|
-
response.setHeader("Cache-Control", "no-store");
|
|
35
|
-
response.setHeader("X-Content-Type-Options", "nosniff");
|
|
36
|
-
if (method === "HEAD") {
|
|
37
|
-
response.end();
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
response.end(Buffer.from(result.archive.buffer, result.archive.byteOffset, result.archive.byteLength));
|
|
41
|
-
};
|
|
42
|
-
}
|
|
@@ -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;AA2CD,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,CAuBrC"}
|
|
@@ -1,60 +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 relativePath = JSON.stringify(`capability-artifacts/${buildInfo.artifactDigest}`);
|
|
17
|
-
return `export async function openUploadStream() {
|
|
18
|
-
const runtimeModuleUrl = import.meta.url;
|
|
19
|
-
const artifactUrl = new URL(${relativePath}, runtimeModuleUrl).href;
|
|
20
|
-
const response = await fetch(artifactUrl, {
|
|
21
|
-
method: "GET",
|
|
22
|
-
cache: "no-store",
|
|
23
|
-
credentials: "same-origin",
|
|
24
|
-
});
|
|
25
|
-
if (!response.ok) {
|
|
26
|
-
throw new Error("Unable to open capability Artifact stream.");
|
|
27
|
-
}
|
|
28
|
-
if (response.body == null) {
|
|
29
|
-
throw new Error("Capability Artifact response has no stream body.");
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
digest: ${digest},
|
|
33
|
-
byteLength: capabilityBuildInfo.byteLength,
|
|
34
|
-
contentType: "application/gzip",
|
|
35
|
-
stream: response.body,
|
|
36
|
-
};
|
|
37
|
-
}`;
|
|
38
|
-
}
|
|
39
|
-
export function buildCapabilityVirtualModuleV1(buildInfo, options = {}) {
|
|
40
|
-
const canonicalBuildInfoJson = new TextDecoder().decode(canonicalizeJson(buildInfo));
|
|
41
|
-
const registrationSource = `const __spotlightRuntimeKey = Symbol.for("inupedia.spotlight.capability-runtime/1");
|
|
42
|
-
function registerCapabilityRuntimeV1(runtime) {
|
|
43
|
-
const store = globalThis[__spotlightRuntimeKey] ??= { providers: new Map(), listeners: new Map() };
|
|
44
|
-
store.providers.set(runtime.capabilityBuildInfo.projectId, runtime);
|
|
45
|
-
for (const listener of store.listeners.get(runtime.capabilityBuildInfo.projectId) ?? []) listener(runtime.capabilityBuildInfo);
|
|
46
|
-
}
|
|
47
|
-
registerCapabilityRuntimeV1({ capabilityBuildInfo, openUploadStream });
|
|
48
|
-
if (import.meta.hot) {
|
|
49
|
-
import.meta.hot.on("spotlight:capability-build", (event) => {
|
|
50
|
-
if (event?.buildInfo?.projectId === capabilityBuildInfo.projectId) {
|
|
51
|
-
const store = globalThis[__spotlightRuntimeKey];
|
|
52
|
-
for (const listener of store?.listeners.get(capabilityBuildInfo.projectId) ?? []) listener(Object.freeze(event.buildInfo));
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}`;
|
|
56
|
-
return Object.freeze({
|
|
57
|
-
canonicalBuildInfoJson,
|
|
58
|
-
source: `export const capabilityBuildInfo = Object.freeze(${canonicalBuildInfoJson});\n\n${options.runtimeUpload === true ? developmentProviderSource(buildInfo) : disabledProviderSource()}\n\n${registrationSource}\n`,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
@@ -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,11 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from "vite";
|
|
2
|
-
export type SpotlightAgentIocOptions = {
|
|
3
|
-
includePath?: string | RegExp;
|
|
4
|
-
agentPreset?: string;
|
|
5
|
-
};
|
|
6
|
-
export declare function transformSpotlightAgentIoc(code: string, id: string, options?: Pick<SpotlightAgentIocOptions, "agentPreset">): {
|
|
7
|
-
code: string;
|
|
8
|
-
map: import("magic-string").SourceMap | null;
|
|
9
|
-
} | null;
|
|
10
|
-
export default function spotlightAgentIoc(options?: SpotlightAgentIocOptions): Plugin;
|
|
11
|
-
//# sourceMappingURL=spotlightAgentIoc.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spotlightAgentIoc.d.ts","sourceRoot":"","sources":["../../src/vite/spotlightAgentIoc.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAYnC,MAAM,MAAM,wBAAwB,GAAG;IACrC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AA0TF,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,IAAI,CAAC,wBAAwB,EAAE,aAAa,CAAM,GAC1D;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,OAAO,cAAc,EAAE,SAAS,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,CAkBvE;AASD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,OAAO,GAAE,wBAA6B,GACrC,MAAM,CAeR"}
|
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compile-time IoC: strip @agent and inject resolveAgentMeta registration (AST-based).
|
|
3
|
-
*/
|
|
4
|
-
import { parse } from "@babel/parser";
|
|
5
|
-
import traverse from "@babel/traverse";
|
|
6
|
-
import * as t from "@babel/types";
|
|
7
|
-
import MagicString from "magic-string";
|
|
8
|
-
function getDecorators(node) {
|
|
9
|
-
const decorators = node.decorators;
|
|
10
|
-
return decorators ?? [];
|
|
11
|
-
}
|
|
12
|
-
const REGISTER_IMPORT = 'import { registerAgentCapability } from "@inupedia/spotlight-client";\n';
|
|
13
|
-
function parseModule(source, sourceFilename) {
|
|
14
|
-
return parse(source, {
|
|
15
|
-
sourceType: "module",
|
|
16
|
-
plugins: ["typescript", "decorators-legacy"],
|
|
17
|
-
sourceFilename,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
function collectAgentMatches(source, sourceFilename) {
|
|
21
|
-
const ast = parseModule(source, sourceFilename);
|
|
22
|
-
const matches = [];
|
|
23
|
-
function pushMatch(decorator, identifier, insertAfter) {
|
|
24
|
-
const expr = decorator.expression;
|
|
25
|
-
if (!t.isCallExpression(expr))
|
|
26
|
-
return;
|
|
27
|
-
if (!t.isIdentifier(expr.callee, { name: "agent" }))
|
|
28
|
-
return;
|
|
29
|
-
if (expr.arguments.length !== 1)
|
|
30
|
-
return;
|
|
31
|
-
const metaArg = expr.arguments[0];
|
|
32
|
-
const metaSource = source.slice(metaArg.start, metaArg.end);
|
|
33
|
-
const decoratorStart = decorator.start;
|
|
34
|
-
let removeEnd = decorator.end;
|
|
35
|
-
if (source[removeEnd] === "\n")
|
|
36
|
-
removeEnd += 1;
|
|
37
|
-
matches.push({
|
|
38
|
-
metaSource,
|
|
39
|
-
identifier,
|
|
40
|
-
insertAfter,
|
|
41
|
-
removeStart: decoratorStart,
|
|
42
|
-
removeEnd,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
traverse(ast, {
|
|
46
|
-
ExportNamedDeclaration(path) {
|
|
47
|
-
const decl = path.node.declaration;
|
|
48
|
-
if (!t.isFunctionDeclaration(decl) || !decl.id?.name)
|
|
49
|
-
return;
|
|
50
|
-
for (const decorator of getDecorators(decl)) {
|
|
51
|
-
pushMatch(decorator, decl.id.name, path.node.end);
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
ExportDefaultDeclaration(path) {
|
|
55
|
-
const decl = path.node.declaration;
|
|
56
|
-
if (!t.isFunctionDeclaration(decl) || !decl.id?.name)
|
|
57
|
-
return;
|
|
58
|
-
for (const decorator of getDecorators(decl)) {
|
|
59
|
-
pushMatch(decorator, decl.id.name, path.node.end);
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
FunctionDeclaration(path) {
|
|
63
|
-
for (const decorator of getDecorators(path.node)) {
|
|
64
|
-
if (!path.node.id?.name)
|
|
65
|
-
continue;
|
|
66
|
-
const exportPath = path.parentPath?.isExportNamedDeclaration()
|
|
67
|
-
? path.parentPath
|
|
68
|
-
: path;
|
|
69
|
-
pushMatch(decorator, path.node.id.name, exportPath.node.end ?? path.node.end);
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
VariableDeclarator(path) {
|
|
73
|
-
if (!t.isIdentifier(path.node.id) || !path.node.init)
|
|
74
|
-
return;
|
|
75
|
-
if (!t.isFunctionExpression(path.node.init))
|
|
76
|
-
return;
|
|
77
|
-
for (const decorator of getDecorators(path.node.init)) {
|
|
78
|
-
const stmt = path.parentPath?.parentPath;
|
|
79
|
-
pushMatch(decorator, path.node.id.name, stmt?.node.end ?? path.node.end);
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
ClassMethod(path) {
|
|
83
|
-
if (!t.isIdentifier(path.node.key))
|
|
84
|
-
return;
|
|
85
|
-
for (const decorator of getDecorators(path.node)) {
|
|
86
|
-
pushMatch(decorator, path.node.key.name, path.node.end);
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
return matches.sort((a, b) => b.removeStart - a.removeStart);
|
|
91
|
-
}
|
|
92
|
-
function findMatchingParen(source, openIndex) {
|
|
93
|
-
let depth = 0;
|
|
94
|
-
for (let i = openIndex; i < source.length; i += 1) {
|
|
95
|
-
const ch = source[i];
|
|
96
|
-
if (ch === "(")
|
|
97
|
-
depth += 1;
|
|
98
|
-
else if (ch === ")") {
|
|
99
|
-
depth -= 1;
|
|
100
|
-
if (depth === 0)
|
|
101
|
-
return i;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return -1;
|
|
105
|
-
}
|
|
106
|
-
function skipLeadingWhitespaceAndComments(source, fromIndex) {
|
|
107
|
-
let i = fromIndex;
|
|
108
|
-
while (i < source.length) {
|
|
109
|
-
const ch = source[i] ?? "";
|
|
110
|
-
if (/\s/.test(ch)) {
|
|
111
|
-
i += 1;
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
if (source.slice(i, i + 2) === "//") {
|
|
115
|
-
const nl = source.indexOf("\n", i);
|
|
116
|
-
i = nl === -1 ? source.length : nl + 1;
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
if (source.slice(i, i + 2) === "/*") {
|
|
120
|
-
const end = source.indexOf("*/", i + 2);
|
|
121
|
-
i = end === -1 ? source.length : end + 2;
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
return i;
|
|
127
|
-
}
|
|
128
|
-
function findFunctionBodyEnd(source, bodyStart) {
|
|
129
|
-
if (source[bodyStart] !== "{")
|
|
130
|
-
return null;
|
|
131
|
-
let depth = 0;
|
|
132
|
-
for (let i = bodyStart; i < source.length; i += 1) {
|
|
133
|
-
if (source[i] === "{")
|
|
134
|
-
depth += 1;
|
|
135
|
-
else if (source[i] === "}") {
|
|
136
|
-
depth -= 1;
|
|
137
|
-
if (depth === 0)
|
|
138
|
-
return i + 1;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return null;
|
|
142
|
-
}
|
|
143
|
-
function findDeclarationAfter(source, fromIndex) {
|
|
144
|
-
const start = skipLeadingWhitespaceAndComments(source, fromIndex);
|
|
145
|
-
const slice = source.slice(start);
|
|
146
|
-
const defaultFnMatch = /^export\s+default\s+(?:async\s+)?function\s+(\w+)/.exec(slice);
|
|
147
|
-
if (defaultFnMatch) {
|
|
148
|
-
const identifier = defaultFnMatch[1];
|
|
149
|
-
const paramOpen = source.indexOf("(", start + defaultFnMatch.index + defaultFnMatch[0].length);
|
|
150
|
-
if (paramOpen === -1)
|
|
151
|
-
return null;
|
|
152
|
-
const paramClose = findMatchingParen(source, paramOpen);
|
|
153
|
-
if (paramClose === -1)
|
|
154
|
-
return null;
|
|
155
|
-
const bodyStart = source.indexOf("{", paramClose);
|
|
156
|
-
if (bodyStart === -1)
|
|
157
|
-
return null;
|
|
158
|
-
const bodyEnd = findFunctionBodyEnd(source, bodyStart);
|
|
159
|
-
return bodyEnd ? { identifier, insertAfter: bodyEnd } : null;
|
|
160
|
-
}
|
|
161
|
-
const fnMatch = /^(export\s+async\s+function\s+(\w+)|export\s+function\s+(\w+)|async\s+function\s+(\w+)|function\s+(\w+))/.exec(slice);
|
|
162
|
-
if (fnMatch) {
|
|
163
|
-
const identifier = fnMatch[2] ?? fnMatch[3] ?? fnMatch[4] ?? fnMatch[5];
|
|
164
|
-
const declStart = start + (fnMatch.index ?? 0);
|
|
165
|
-
const paramOpen = source.indexOf("(", declStart);
|
|
166
|
-
if (paramOpen === -1)
|
|
167
|
-
return null;
|
|
168
|
-
const paramClose = findMatchingParen(source, paramOpen);
|
|
169
|
-
if (paramClose === -1)
|
|
170
|
-
return null;
|
|
171
|
-
const bodyStart = source.indexOf("{", paramClose);
|
|
172
|
-
if (bodyStart === -1)
|
|
173
|
-
return null;
|
|
174
|
-
const bodyEnd = findFunctionBodyEnd(source, bodyStart);
|
|
175
|
-
return bodyEnd ? { identifier, insertAfter: bodyEnd } : null;
|
|
176
|
-
}
|
|
177
|
-
const constMatch = /^export\s+const\s+(\w+)\s*=/.exec(slice);
|
|
178
|
-
if (constMatch) {
|
|
179
|
-
const identifier = constMatch[1];
|
|
180
|
-
let i = start + constMatch.index + constMatch[0].length;
|
|
181
|
-
i = skipLeadingWhitespaceAndComments(source, i);
|
|
182
|
-
if (source[i] === "(") {
|
|
183
|
-
const close = findMatchingParen(source, i);
|
|
184
|
-
if (close === -1)
|
|
185
|
-
return null;
|
|
186
|
-
let end = close + 1;
|
|
187
|
-
while (end < source.length && source[end] !== ";" && source[end] !== "\n") {
|
|
188
|
-
end += 1;
|
|
189
|
-
}
|
|
190
|
-
if (source[end] === ";")
|
|
191
|
-
end += 1;
|
|
192
|
-
return { identifier, insertAfter: end };
|
|
193
|
-
}
|
|
194
|
-
const asyncFnMatch = /^async\s+function\s+(\w+)/.exec(source.slice(i));
|
|
195
|
-
if (asyncFnMatch) {
|
|
196
|
-
const fnStart = i + asyncFnMatch.index + asyncFnMatch[0].length;
|
|
197
|
-
const paramOpen = source.indexOf("(", fnStart - 1);
|
|
198
|
-
if (paramOpen === -1)
|
|
199
|
-
return null;
|
|
200
|
-
const paramClose = findMatchingParen(source, paramOpen);
|
|
201
|
-
if (paramClose === -1)
|
|
202
|
-
return null;
|
|
203
|
-
const bodyStart = source.indexOf("{", paramClose);
|
|
204
|
-
if (bodyStart === -1)
|
|
205
|
-
return null;
|
|
206
|
-
const bodyEnd = findFunctionBodyEnd(source, bodyStart);
|
|
207
|
-
if (!bodyEnd)
|
|
208
|
-
return null;
|
|
209
|
-
let end = bodyEnd;
|
|
210
|
-
while (end < source.length && source[end] !== ";" && source[end] !== "\n") {
|
|
211
|
-
end += 1;
|
|
212
|
-
}
|
|
213
|
-
if (source[end] === ";")
|
|
214
|
-
end += 1;
|
|
215
|
-
return { identifier, insertAfter: end };
|
|
216
|
-
}
|
|
217
|
-
if (source.slice(i, i + 6) === "async ") {
|
|
218
|
-
i += 6;
|
|
219
|
-
i = skipLeadingWhitespaceAndComments(source, i);
|
|
220
|
-
}
|
|
221
|
-
if (source[i] === "(") {
|
|
222
|
-
const close = findMatchingParen(source, i);
|
|
223
|
-
if (close === -1)
|
|
224
|
-
return null;
|
|
225
|
-
let end = close + 1;
|
|
226
|
-
if (source[end] === ";")
|
|
227
|
-
end += 1;
|
|
228
|
-
return { identifier, insertAfter: end };
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return null;
|
|
232
|
-
}
|
|
233
|
-
/** Legacy string scanner when Babel cannot parse decorated exports. */
|
|
234
|
-
function collectAgentMatchesLegacy(source) {
|
|
235
|
-
const matches = [];
|
|
236
|
-
const kind = "@agent";
|
|
237
|
-
let searchFrom = 0;
|
|
238
|
-
while (searchFrom < source.length) {
|
|
239
|
-
const at = source.indexOf(kind + "(", searchFrom);
|
|
240
|
-
if (at === -1)
|
|
241
|
-
break;
|
|
242
|
-
const metaOpen = at + kind.length;
|
|
243
|
-
const metaClose = findMatchingParen(source, metaOpen);
|
|
244
|
-
if (metaClose === -1)
|
|
245
|
-
break;
|
|
246
|
-
const metaSource = source.slice(metaOpen + 1, metaClose).trim();
|
|
247
|
-
let removeTo = metaClose + 1;
|
|
248
|
-
while (removeTo < source.length && /\s/.test(source[removeTo] ?? "")) {
|
|
249
|
-
removeTo += 1;
|
|
250
|
-
}
|
|
251
|
-
const decl = findDeclarationAfter(source, removeTo);
|
|
252
|
-
if (decl) {
|
|
253
|
-
matches.push({
|
|
254
|
-
metaSource,
|
|
255
|
-
identifier: decl.identifier,
|
|
256
|
-
removeStart: at,
|
|
257
|
-
removeEnd: removeTo,
|
|
258
|
-
insertAfter: decl.insertAfter,
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
searchFrom = metaClose + 1;
|
|
262
|
-
}
|
|
263
|
-
return matches.sort((a, b) => b.removeStart - a.removeStart);
|
|
264
|
-
}
|
|
265
|
-
function applyAgentMatches(code, id, matches, agentPreset) {
|
|
266
|
-
const s = new MagicString(code);
|
|
267
|
-
for (const match of matches) {
|
|
268
|
-
s.remove(match.removeStart, match.removeEnd);
|
|
269
|
-
s.appendLeft(match.insertAfter, `\n${registrationLine(match.metaSource, match.identifier, id)}\n`);
|
|
270
|
-
}
|
|
271
|
-
let output = s.toString();
|
|
272
|
-
const presetImport = `import { resolveAgentMeta } from "${agentPreset}";\n`;
|
|
273
|
-
if (!/import\s+{[^}]*\bregisterAgentCapability\b/.test(output)) {
|
|
274
|
-
output = REGISTER_IMPORT + output;
|
|
275
|
-
}
|
|
276
|
-
if (!/import\s+{[^}]*\bresolveAgentMeta\b/.test(output)) {
|
|
277
|
-
output = presetImport + output;
|
|
278
|
-
}
|
|
279
|
-
return {
|
|
280
|
-
code: output,
|
|
281
|
-
map: s.generateMap({ hires: true, source: id, includeContent: true }),
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
function registrationLine(metaSource, identifier, fileId) {
|
|
285
|
-
const fileLiteral = JSON.stringify(fileId);
|
|
286
|
-
return `registerAgentCapability(resolveAgentMeta(${metaSource}, ${fileLiteral}), ${identifier});`;
|
|
287
|
-
}
|
|
288
|
-
export function transformSpotlightAgentIoc(code, id, options = {}) {
|
|
289
|
-
const agentPreset = options.agentPreset ?? "@/service/agent/presets/resolveAgentMeta";
|
|
290
|
-
if (!code.includes("@agent") && !code.includes("@Agent"))
|
|
291
|
-
return null;
|
|
292
|
-
let matches = [];
|
|
293
|
-
try {
|
|
294
|
-
matches = collectAgentMatches(code, id);
|
|
295
|
-
}
|
|
296
|
-
catch {
|
|
297
|
-
matches = [];
|
|
298
|
-
}
|
|
299
|
-
if (matches.length === 0) {
|
|
300
|
-
matches = collectAgentMatchesLegacy(code);
|
|
301
|
-
}
|
|
302
|
-
if (matches.length === 0)
|
|
303
|
-
return null;
|
|
304
|
-
return applyAgentMatches(code, id, matches, agentPreset);
|
|
305
|
-
}
|
|
306
|
-
function shouldTransform(id, includePath) {
|
|
307
|
-
if (id.includes(".test."))
|
|
308
|
-
return false;
|
|
309
|
-
if (id.includes("/_shared/"))
|
|
310
|
-
return false;
|
|
311
|
-
if (typeof includePath === "string")
|
|
312
|
-
return id.includes(includePath);
|
|
313
|
-
return includePath.test(id);
|
|
314
|
-
}
|
|
315
|
-
export default function spotlightAgentIoc(options = {}) {
|
|
316
|
-
const includePath = options.includePath ?? "/capabilities/";
|
|
317
|
-
return {
|
|
318
|
-
name: "spotlight-agent-ioc",
|
|
319
|
-
enforce: "pre",
|
|
320
|
-
transform(code, id) {
|
|
321
|
-
if (!shouldTransform(id, includePath))
|
|
322
|
-
return null;
|
|
323
|
-
const result = transformSpotlightAgentIoc(code, id, {
|
|
324
|
-
agentPreset: options.agentPreset,
|
|
325
|
-
});
|
|
326
|
-
if (!result)
|
|
327
|
-
return null;
|
|
328
|
-
return result;
|
|
329
|
-
},
|
|
330
|
-
};
|
|
331
|
-
}
|
|
@@ -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;AA0B9B,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,iCAAiC,EAC1C,OAAO,CAAC,EAAE,8BAA8B,GACvC,MAAM,CA4LR"}
|