@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,28 @@
1
+ import { type CapabilityHandshakeResultV1, type RenewCapabilityLeaseResultV1 } from "@inupedia/spotlight-protocol";
2
+ import type { FrontendToolRegistryV1 } from "../tools/frontendTool.js";
3
+ import { type CapabilityExecutionFenceV1 } from "./hostActionExecutor.js";
4
+ type AcceptedHandshake = Extract<CapabilityHandshakeResultV1, {
5
+ status: "accepted";
6
+ }>;
7
+ export interface CapabilityChannelV1 {
8
+ open(): void;
9
+ close(): void;
10
+ renew(): Promise<RenewCapabilityLeaseResultV1>;
11
+ reconnect(): Promise<void>;
12
+ fence(): Readonly<CapabilityExecutionFenceV1>;
13
+ }
14
+ export declare function createCapabilityChannel(options: {
15
+ endpoint: string;
16
+ handshake: AcceptedHandshake;
17
+ identity: {
18
+ sessionId: string;
19
+ browserInstanceId: string;
20
+ tabInstanceId: string;
21
+ signal?: AbortSignal;
22
+ };
23
+ registry: FrontendToolRegistryV1;
24
+ fetch: typeof globalThis.fetch;
25
+ createWebSocket?: (url: string) => WebSocket;
26
+ }): CapabilityChannelV1;
27
+ export {};
28
+ //# sourceMappingURL=channel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../src/capabilities/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EAElC,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEvE,OAAO,EAA4B,KAAK,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAEpG,KAAK,iBAAiB,GAAG,OAAO,CAAC,2BAA2B,EAAE;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC,CAAC;AAEtF,MAAM,WAAW,mBAAmB;IAClC,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,IAAI,IAAI,CAAC;IACd,KAAK,IAAI,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAC/C,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,KAAK,IAAI,QAAQ,CAAC,0BAA0B,CAAC,CAAC;CAC/C;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,iBAAiB,CAAC;IAC7B,QAAQ,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,iBAAiB,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,CAAC;IACxG,QAAQ,EAAE,sBAAsB,CAAC;IACjC,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAC/B,eAAe,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,SAAS,CAAC;CAC9C,GAAG,mBAAmB,CA4JtB"}
@@ -0,0 +1,166 @@
1
+ import { SPOTLIGHT_CAPABILITY_PROTOCOL_V1, } from "@inupedia/spotlight-protocol";
2
+ import { capabilityResponseJson, SpotlightCapabilityError } from "./errors.js";
3
+ import { createHostActionExecutor } from "./hostActionExecutor.js";
4
+ export function createCapabilityChannel(options) {
5
+ let leaseVersion = options.handshake.leaseVersion;
6
+ let connectionId = options.handshake.connectionId;
7
+ let connectionEpoch = options.handshake.connectionEpoch;
8
+ let channelToken = options.handshake.capabilityChannelToken;
9
+ let socket;
10
+ let heartbeat;
11
+ let renewal;
12
+ let renewalPendingGeneration;
13
+ let reconnectTimer;
14
+ let reconnectAttempt = 0;
15
+ let generation = 0;
16
+ let reservationSerial = 0;
17
+ let closed = false;
18
+ let reserveAndOpen;
19
+ const scheduleReconnect = () => {
20
+ if (closed || reconnectTimer)
21
+ return;
22
+ const delay = Math.min(250 * 2 ** reconnectAttempt, 5_000);
23
+ reconnectAttempt += 1;
24
+ reconnectTimer = setTimeout(() => {
25
+ reconnectTimer = undefined;
26
+ void reserveAndOpen().catch(scheduleReconnect);
27
+ }, delay);
28
+ };
29
+ const fence = () => Object.freeze({
30
+ sessionId: options.identity.sessionId,
31
+ capabilitySnapshotId: options.handshake.capabilitySnapshotId,
32
+ leaseId: options.handshake.leaseId,
33
+ leaseVersion,
34
+ connectionId,
35
+ connectionEpoch,
36
+ browserInstanceId: options.identity.browserInstanceId,
37
+ tabInstanceId: options.identity.tabInstanceId,
38
+ });
39
+ const executor = createHostActionExecutor({ registry: options.registry, fence });
40
+ const close = () => {
41
+ closed = true;
42
+ if (heartbeat)
43
+ clearInterval(heartbeat);
44
+ if (renewal)
45
+ clearInterval(renewal);
46
+ if (reconnectTimer)
47
+ clearTimeout(reconnectTimer);
48
+ heartbeat = undefined;
49
+ renewal = undefined;
50
+ if (socket)
51
+ socket.onclose = null;
52
+ socket?.close();
53
+ socket = undefined;
54
+ };
55
+ const open = () => {
56
+ if (closed)
57
+ throw new SpotlightCapabilityError("CAPABILITY_LEASE_FENCED", "Capability channel is closed.");
58
+ if (socket)
59
+ socket.onclose = null;
60
+ socket?.close();
61
+ const create = options.createWebSocket ?? ((url) => new WebSocket(url));
62
+ const origin = typeof location === "undefined" ? "http://localhost" : location.origin;
63
+ const base = new URL(options.endpoint.replace(/\/$/, "") + "/", origin);
64
+ const channelPath = options.handshake.capabilityChannelUrl.replace(/^\//, "");
65
+ const url = new URL(channelPath, base);
66
+ url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
67
+ const localSocket = create(url.toString());
68
+ const localGeneration = ++generation;
69
+ socket = localSocket;
70
+ const sendLocal = (message) => { if (!closed && socket === localSocket && generation === localGeneration && localSocket.readyState === 1)
71
+ localSocket.send(JSON.stringify(message)); };
72
+ localSocket.onopen = () => {
73
+ if (socket !== localSocket || generation !== localGeneration || closed)
74
+ return;
75
+ reconnectAttempt = 0;
76
+ sendLocal({
77
+ type: "client_hello",
78
+ protocolVersion: SPOTLIGHT_CAPABILITY_PROTOCOL_V1,
79
+ capabilityChannelToken: channelToken,
80
+ browserInstanceId: options.identity.browserInstanceId,
81
+ tabInstanceId: options.identity.tabInstanceId,
82
+ });
83
+ if (heartbeat)
84
+ clearInterval(heartbeat);
85
+ heartbeat = setInterval(() => sendLocal({ type: "heartbeat", ...fence(), sentAt: new Date().toISOString() }), 5_000);
86
+ if (renewal)
87
+ clearInterval(renewal);
88
+ renewal = setInterval(() => {
89
+ if (renewalPendingGeneration === localGeneration)
90
+ return;
91
+ renewalPendingGeneration = localGeneration;
92
+ void renew().catch(scheduleReconnect).finally(() => { if (renewalPendingGeneration === localGeneration)
93
+ renewalPendingGeneration = undefined; });
94
+ }, 5_000);
95
+ };
96
+ localSocket.onmessage = (event) => {
97
+ if (socket !== localSocket || generation !== localGeneration || closed)
98
+ return;
99
+ void (async () => {
100
+ const message = JSON.parse(String(event.data));
101
+ if (message.type === "host_action_request") {
102
+ await executor.executeStreaming(message, sendLocal);
103
+ }
104
+ else if (message.type === "channel_fenced") {
105
+ close();
106
+ }
107
+ })();
108
+ };
109
+ localSocket.onclose = () => {
110
+ if (socket !== localSocket || generation !== localGeneration || closed)
111
+ return;
112
+ if (heartbeat)
113
+ clearInterval(heartbeat);
114
+ if (renewal)
115
+ clearInterval(renewal);
116
+ heartbeat = undefined;
117
+ renewal = undefined;
118
+ scheduleReconnect();
119
+ };
120
+ };
121
+ const post = async (path, body) => capabilityResponseJson(await options.fetch(`${options.endpoint.replace(/\/$/, "")}${path}`, {
122
+ method: "POST",
123
+ headers: { "Content-Type": "application/json" },
124
+ body: JSON.stringify(body),
125
+ signal: options.identity.signal,
126
+ }));
127
+ const renew = async () => {
128
+ const current = fence();
129
+ const startedGeneration = generation;
130
+ const result = await post(`/v1/capabilities/leases/${encodeURIComponent(current.leaseId)}/renew`, { ...current, expectedLeaseVersion: current.leaseVersion, liveTools: options.registry.liveTools() });
131
+ if (startedGeneration !== generation || closed)
132
+ return result;
133
+ if (result.status === "revoked") {
134
+ close();
135
+ throw new SpotlightCapabilityError("CAPABILITY_LEASE_REVOKED", result.reason);
136
+ }
137
+ leaseVersion = result.leaseVersion;
138
+ return result;
139
+ };
140
+ reserveAndOpen = async () => {
141
+ const current = fence();
142
+ const startedGeneration = generation;
143
+ const serial = ++reservationSerial;
144
+ const reserved = await post(`/v1/capabilities/leases/${encodeURIComponent(current.leaseId)}/connections`, {
145
+ expectedConnectionId: current.connectionId,
146
+ expectedConnectionEpoch: current.connectionEpoch,
147
+ expectedLeaseVersion: current.leaseVersion,
148
+ browserInstanceId: current.browserInstanceId,
149
+ tabInstanceId: current.tabInstanceId,
150
+ });
151
+ if (closed || startedGeneration !== generation || serial !== reservationSerial)
152
+ return;
153
+ leaseVersion = reserved.leaseVersion;
154
+ connectionId = reserved.connectionId;
155
+ connectionEpoch = reserved.connectionEpoch;
156
+ channelToken = reserved.capabilityChannelToken;
157
+ open();
158
+ };
159
+ return Object.freeze({
160
+ open,
161
+ close,
162
+ fence,
163
+ renew,
164
+ reconnect: reserveAndOpen,
165
+ });
166
+ }
@@ -0,0 +1,9 @@
1
+ import type { CapabilityErrorCodeV1 } from "@inupedia/spotlight-protocol";
2
+ export declare class SpotlightCapabilityError extends Error {
3
+ readonly code: CapabilityErrorCodeV1;
4
+ readonly retryable: boolean;
5
+ readonly details?: Record<string, unknown> | undefined;
6
+ constructor(code: CapabilityErrorCodeV1, message: string, retryable?: boolean, details?: Record<string, unknown> | undefined);
7
+ }
8
+ export declare function capabilityResponseJson<T>(response: Response): Promise<T>;
9
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/capabilities/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAA6B,MAAM,8BAA8B,CAAC;AAErG,qBAAa,wBAAyB,SAAQ,KAAK;IAE/C,QAAQ,CAAC,IAAI,EAAE,qBAAqB;IAEpC,QAAQ,CAAC,SAAS;IAClB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBAHjC,IAAI,EAAE,qBAAqB,EACpC,OAAO,EAAE,MAAM,EACN,SAAS,UAAQ,EACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA;CAK7C;AAED,wBAAsB,sBAAsB,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAU9E"}
@@ -0,0 +1,19 @@
1
+ export class SpotlightCapabilityError extends Error {
2
+ code;
3
+ retryable;
4
+ details;
5
+ constructor(code, message, retryable = false, details) {
6
+ super(message);
7
+ this.code = code;
8
+ this.retryable = retryable;
9
+ this.details = details;
10
+ this.name = "SpotlightCapabilityError";
11
+ }
12
+ }
13
+ export async function capabilityResponseJson(response) {
14
+ const body = await response.json().catch(() => undefined);
15
+ if (response.ok)
16
+ return body;
17
+ const error = body && typeof body === "object" && "error" in body ? body.error : undefined;
18
+ throw new SpotlightCapabilityError(error?.code ?? "HANDSHAKE_STATE_CONFLICT", error?.message ?? `Capability request failed with HTTP ${response.status}.`, error?.retryable ?? false, error?.details);
19
+ }
@@ -0,0 +1,36 @@
1
+ import { type CapabilityHandshakeResultV1 } from "@inupedia/spotlight-protocol";
2
+ import type { CapabilityBuildInfoV1 } from "../vite/capabilityBuildTypes.js";
3
+ import type { FrontendToolRegistryV1, SpotlightProjectV1 } from "../tools/frontendTool.js";
4
+ import { type CapabilityChannelV1 } from "./channel.js";
5
+ export interface CapabilityConnectInputV1 {
6
+ sessionId: string;
7
+ browserInstanceId: string;
8
+ tabInstanceId: string;
9
+ signal?: AbortSignal;
10
+ openChannel?: boolean;
11
+ }
12
+ export interface CapabilityConnectResultV1 {
13
+ handshake: Extract<CapabilityHandshakeResultV1, {
14
+ status: "accepted";
15
+ }>;
16
+ channel?: CapabilityChannelV1;
17
+ }
18
+ export interface CreateCapabilityClientOptionsV1 {
19
+ endpoint: string;
20
+ project: SpotlightProjectV1;
21
+ registry: FrontendToolRegistryV1;
22
+ buildInfo: Readonly<CapabilityBuildInfoV1>;
23
+ openUploadStream: () => Promise<{
24
+ digest: string;
25
+ byteLength: number;
26
+ contentType: "application/gzip";
27
+ stream: ReadableStream<Uint8Array>;
28
+ }>;
29
+ fetch?: typeof globalThis.fetch;
30
+ createOfferId?: () => string;
31
+ createWebSocket?: (url: string) => WebSocket;
32
+ }
33
+ export declare function createCapabilityClient(options: CreateCapabilityClientOptionsV1): Readonly<{
34
+ connect(input: CapabilityConnectInputV1): Promise<CapabilityConnectResultV1>;
35
+ }>;
36
+ //# sourceMappingURL=handshake.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handshake.d.ts","sourceRoot":"","sources":["../../src/capabilities/handshake.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,2BAA2B,EAEjC,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC3F,OAAO,EAA2B,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGjF,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,OAAO,CAAC,2BAA2B,EAAE;QAAE,MAAM,EAAE,UAAU,CAAA;KAAE,CAAC,CAAC;IACxE,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC/B;AAED,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,QAAQ,EAAE,sBAAsB,CAAC;IACjC,SAAS,EAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC;IAC3C,gBAAgB,EAAE,MAAM,OAAO,CAAC;QAC9B,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,kBAAkB,CAAC;QAChC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;KACpC,CAAC,CAAC;IACH,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,MAAM,CAAC;IAC7B,eAAe,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,SAAS,CAAC;CAC9C;AAMD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,+BAA+B;mBAqBtD,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC;GAqDrF"}
@@ -0,0 +1,78 @@
1
+ import { SPOTLIGHT_CAPABILITY_PROTOCOL_V1, } from "@inupedia/spotlight-protocol";
2
+ import { createCapabilityChannel } from "./channel.js";
3
+ import { capabilityResponseJson } from "./errors.js";
4
+ function endpoint(base, path) {
5
+ return `${base.replace(/\/$/, "")}${path}`;
6
+ }
7
+ export function createCapabilityClient(options) {
8
+ const fetcher = options.fetch ?? globalThis.fetch.bind(globalThis);
9
+ const offerIds = new Map();
10
+ const offerIdFor = (key) => {
11
+ const existing = offerIds.get(key);
12
+ if (existing)
13
+ return existing;
14
+ const created = options.createOfferId?.() ?? globalThis.crypto.randomUUID();
15
+ offerIds.set(key, created);
16
+ return created;
17
+ };
18
+ async function post(path, body, signal) {
19
+ return capabilityResponseJson(await fetcher(endpoint(options.endpoint, path), {
20
+ method: "POST",
21
+ headers: { "Content-Type": "application/json" },
22
+ body: JSON.stringify(body),
23
+ signal,
24
+ }));
25
+ }
26
+ return Object.freeze({
27
+ async connect(input) {
28
+ const key = [input.sessionId, options.buildInfo.frontendBuildId, options.buildInfo.artifactDigest, input.browserInstanceId, input.tabInstanceId].join("\u0000");
29
+ const offer = {
30
+ protocolVersion: SPOTLIGHT_CAPABILITY_PROTOCOL_V1,
31
+ offerId: offerIdFor(key),
32
+ projectId: options.project.projectId,
33
+ sessionId: input.sessionId,
34
+ frontendBuildId: options.buildInfo.frontendBuildId,
35
+ browserInstanceId: input.browserInstanceId,
36
+ tabInstanceId: input.tabInstanceId,
37
+ capabilityArtifact: {
38
+ digest: options.buildInfo.artifactDigest,
39
+ manifestDigest: options.buildInfo.manifestDigest,
40
+ skillManifestDigest: options.buildInfo.skillManifestDigest,
41
+ toolManifestDigest: options.buildInfo.toolManifestDigest,
42
+ byteLength: options.buildInfo.byteLength,
43
+ },
44
+ liveTools: options.registry.liveTools(),
45
+ };
46
+ let handshake = await post("/v1/capabilities/handshakes", offer, input.signal);
47
+ if (handshake.status === "upload_required") {
48
+ const upload = await options.openUploadStream();
49
+ const uploadRequest = {
50
+ method: "PUT",
51
+ headers: {
52
+ Authorization: `Bearer ${handshake.uploadToken}`,
53
+ "Content-Type": upload.contentType,
54
+ "Content-Length": String(upload.byteLength),
55
+ },
56
+ body: upload.stream,
57
+ signal: input.signal,
58
+ duplex: "half",
59
+ };
60
+ await capabilityResponseJson(await fetcher(endpoint(options.endpoint, handshake.uploadUrl), uploadRequest));
61
+ handshake = await post(`/v1/capabilities/handshakes/${encodeURIComponent(handshake.handshakeId)}/resume`, { resumeToken: handshake.resumeToken }, input.signal);
62
+ }
63
+ if (handshake.status !== "accepted")
64
+ throw new Error("Capability Handshake did not reach a terminal accepted state.");
65
+ const channel = input.openChannel === false ? undefined : createCapabilityChannel({
66
+ endpoint: options.endpoint,
67
+ handshake,
68
+ identity: input,
69
+ registry: options.registry,
70
+ fetch: fetcher,
71
+ createWebSocket: options.createWebSocket,
72
+ });
73
+ if (channel)
74
+ channel.open();
75
+ return { handshake, ...(channel ? { channel } : {}) };
76
+ },
77
+ });
78
+ }
@@ -0,0 +1,22 @@
1
+ import type { HostActionAckV2, HostActionNackV2, HostActionRequestV2, HostActionResultV2 } from "@inupedia/spotlight-protocol";
2
+ import type { FrontendToolRegistryV1 } from "../tools/frontendTool.js";
3
+ export interface CapabilityExecutionFenceV1 {
4
+ sessionId: string;
5
+ capabilitySnapshotId: string;
6
+ leaseId: string;
7
+ leaseVersion: number;
8
+ connectionId: string;
9
+ connectionEpoch: number;
10
+ browserInstanceId: string;
11
+ tabInstanceId: string;
12
+ }
13
+ type HostMessage = HostActionAckV2 | HostActionNackV2 | HostActionResultV2;
14
+ export declare function createHostActionExecutor(options: {
15
+ registry: FrontendToolRegistryV1;
16
+ fence: CapabilityExecutionFenceV1 | (() => CapabilityExecutionFenceV1);
17
+ }): Readonly<{
18
+ executeStreaming: (request: HostActionRequestV2, emit: (message: HostMessage) => void) => Promise<void>;
19
+ execute(request: HostActionRequestV2): Promise<HostMessage[]>;
20
+ }>;
21
+ export {};
22
+ //# sourceMappingURL=hostActionExecutor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hostActionExecutor.d.ts","sourceRoot":"","sources":["../../src/capabilities/hostActionExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAC/H,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGvE,MAAM,WAAW,0BAA0B;IAAG,SAAS,EAAE,MAAM,CAAC;IAAC,oBAAoB,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE;AACvO,KAAK,WAAW,GAAG,eAAe,GAAG,gBAAgB,GAAG,kBAAkB,CAAC;AAI3E,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAAE,QAAQ,EAAE,sBAAsB,CAAC;IAAC,KAAK,EAAE,0BAA0B,GAAG,CAAC,MAAM,0BAA0B,CAAC,CAAA;CAAE;gCACnH,mBAAmB,QAAQ,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,KAAG,OAAO,CAAC,IAAI,CAAC;qBA8BzF,mBAAmB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;GAEtE"}
@@ -0,0 +1,56 @@
1
+ import { validateJsonSchemaV1 } from "./jsonSchema.js";
2
+ const FENCE_FIELDS = ["sessionId", "capabilitySnapshotId", "leaseId", "leaseVersion", "connectionId", "connectionEpoch", "browserInstanceId", "tabInstanceId"];
3
+ function nack(request, code, message) { const { type: _t, input: _i, deadlineAt: _d, idempotencyKey: _k, confirmationGrantId: _g, maxAttempts: _m, ...fence } = request; return { ...fence, type: "host_action_nack", status: "nack", handlerStarted: false, error: { code, message } }; }
4
+ export function createHostActionExecutor(options) {
5
+ const executeStreaming = async (request, emit) => {
6
+ const current = typeof options.fence === "function" ? options.fence() : options.fence;
7
+ const reject = (code, message) => { emit(nack(request, code, message)); };
8
+ if (FENCE_FIELDS.some((field) => request[field] !== current[field]))
9
+ return reject("CAPABILITY_LEASE_FENCED", "Host action fence is stale.");
10
+ const tool = options.registry.get(request.tool.name, request.tool.version);
11
+ if (!tool || request.tool.target !== "browser")
12
+ return reject("TOOL_NOT_REGISTERED", "Frontend Tool is not registered.");
13
+ if (!options.registry.liveTools().some((entry) => entry.name === tool.name && entry.version === tool.version))
14
+ return reject("HOST_OFFLINE", "Frontend Tool handler is not live.");
15
+ const inputError = validateJsonSchemaV1(tool.inputSchema, request.input);
16
+ if (inputError)
17
+ return reject("TOOL_INPUT_INVALID", inputError);
18
+ const deadlineAt = Date.parse(request.deadlineAt);
19
+ const delay = deadlineAt - Date.now();
20
+ if (!Number.isFinite(deadlineAt) || delay <= 0)
21
+ return reject("HOST_ACTION_TIMEOUT", "Host action deadline is invalid or elapsed.");
22
+ const { type: _t, input: _i, deadlineAt: _d, idempotencyKey: _k, confirmationGrantId: _g, maxAttempts: _m, ...fence } = request;
23
+ emit({ ...fence, type: "host_action_ack", status: "ack" });
24
+ const controller = new AbortController();
25
+ let timer;
26
+ const deadline = new Promise((_, rejectDeadline) => { const schedule = () => { const remaining = deadlineAt - Date.now(); if (remaining <= 0) {
27
+ controller.abort("deadline");
28
+ rejectDeadline(new SpotlightDeadlineError());
29
+ return;
30
+ } timer = setTimeout(schedule, Math.min(remaining, 0x7fffffff)); }; schedule(); });
31
+ try {
32
+ const output = await Promise.race([Promise.resolve(tool.execute(request.input, { projectId: options.registry.projectId, sessionId: request.sessionId, callId: request.callId, attempt: request.attempt, fence, ...(request.idempotencyKey ? { idempotencyKey: request.idempotencyKey } : {}), signal: controller.signal })), deadline]);
33
+ const outputError = tool.outputSchema ? validateJsonSchemaV1(tool.outputSchema, output) : undefined;
34
+ if (outputError)
35
+ return emit({ ...fence, type: "host_action_result", outcome: "threw", error: { code: "TOOL_OUTPUT_INVALID", message: outputError } });
36
+ const bytes = new TextEncoder().encode(JSON.stringify(output ?? null)).byteLength;
37
+ if (bytes > (tool.maxOutputBytes ?? 1024 * 1024))
38
+ return emit({ ...fence, type: "host_action_result", outcome: "threw", error: { code: "TOOL_OUTPUT_INVALID", message: "Frontend Tool output exceeds maxOutputBytes." } });
39
+ emit({ ...fence, type: "host_action_result", outcome: "returned", output });
40
+ }
41
+ catch (error) {
42
+ emit({ ...fence, type: "host_action_result", outcome: "threw", error: { code: error instanceof SpotlightDeadlineError ? "UNKNOWN_OUTCOME" : "TOOL_RUN_FAILED", message: error instanceof Error ? error.message : "Frontend Tool failed." } });
43
+ }
44
+ finally {
45
+ if (timer)
46
+ clearTimeout(timer);
47
+ }
48
+ };
49
+ return Object.freeze({
50
+ executeStreaming,
51
+ async execute(request) { const messages = []; await executeStreaming(request, (message) => messages.push(message)); return messages; },
52
+ });
53
+ }
54
+ class SpotlightDeadlineError extends Error {
55
+ constructor() { super("Frontend Tool deadline elapsed."); }
56
+ }
@@ -0,0 +1,2 @@
1
+ export declare function validateJsonSchemaV1(schema: Record<string, unknown>, value: unknown, path?: string): string | undefined;
2
+ //# sourceMappingURL=jsonSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonSchema.d.ts","sourceRoot":"","sources":["../../src/capabilities/jsonSchema.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,SAAM,GAAI,MAAM,GAAG,SAAS,CA+CrH"}
@@ -0,0 +1,73 @@
1
+ export function validateJsonSchemaV1(schema, value, path = "$") {
2
+ const type = schema.type;
3
+ if (typeof type === "string") {
4
+ const valid = type === "object" ? value !== null && typeof value === "object" && !Array.isArray(value)
5
+ : type === "array" ? Array.isArray(value)
6
+ : type === "integer" ? Number.isInteger(value)
7
+ : type === "number" ? typeof value === "number" && Number.isFinite(value)
8
+ : type === "string" ? typeof value === "string"
9
+ : type === "boolean" ? typeof value === "boolean"
10
+ : type === "null" ? value === null : true;
11
+ if (!valid)
12
+ return `${path} must be ${type}`;
13
+ }
14
+ if (Array.isArray(schema.enum) && !schema.enum.some((entry) => jsonEqual(entry, value)))
15
+ return `${path} is not an allowed value`;
16
+ if ("const" in schema && !jsonEqual(schema.const, value))
17
+ return `${path} must equal const`;
18
+ if (typeof value === "string") {
19
+ if (typeof schema.minLength === "number" && value.length < schema.minLength)
20
+ return `${path} is shorter than minLength`;
21
+ if (typeof schema.maxLength === "number" && value.length > schema.maxLength)
22
+ return `${path} is longer than maxLength`;
23
+ if (typeof schema.pattern === "string" && !new RegExp(schema.pattern).test(value))
24
+ return `${path} does not match pattern`;
25
+ }
26
+ if (typeof value === "number") {
27
+ if (typeof schema.minimum === "number" && value < schema.minimum)
28
+ return `${path} is below minimum`;
29
+ if (typeof schema.maximum === "number" && value > schema.maximum)
30
+ return `${path} is above maximum`;
31
+ }
32
+ if (schema.type === "object" && value !== null && typeof value === "object" && !Array.isArray(value)) {
33
+ const record = value;
34
+ for (const required of Array.isArray(schema.required) ? schema.required : []) {
35
+ if (typeof required === "string" && !(required in record))
36
+ return `${path}.${required} is required`;
37
+ }
38
+ const properties = schema.properties && typeof schema.properties === "object" ? schema.properties : {};
39
+ if (schema.additionalProperties === false) {
40
+ const unknown = Object.keys(record).find((key) => !(key in properties));
41
+ if (unknown)
42
+ return `${path}.${unknown} is not allowed`;
43
+ }
44
+ for (const [key, child] of Object.entries(properties)) {
45
+ if (key in record && child && typeof child === "object" && !Array.isArray(child)) {
46
+ const error = validateJsonSchemaV1(child, record[key], `${path}.${key}`);
47
+ if (error)
48
+ return error;
49
+ }
50
+ }
51
+ }
52
+ if (schema.type === "array" && Array.isArray(value) && schema.items && typeof schema.items === "object" && !Array.isArray(schema.items)) {
53
+ for (let index = 0; index < value.length; index += 1) {
54
+ const error = validateJsonSchemaV1(schema.items, value[index], `${path}[${index}]`);
55
+ if (error)
56
+ return error;
57
+ }
58
+ }
59
+ return undefined;
60
+ }
61
+ function jsonEqual(left, right) {
62
+ if (Object.is(left, right))
63
+ return true;
64
+ if (Array.isArray(left) || Array.isArray(right))
65
+ return Array.isArray(left) && Array.isArray(right) && left.length === right.length && left.every((entry, index) => jsonEqual(entry, right[index]));
66
+ if (left && right && typeof left === "object" && typeof right === "object") {
67
+ const a = left;
68
+ const b = right;
69
+ const keys = Object.keys(a);
70
+ return keys.length === Object.keys(b).length && keys.every((key) => key in b && jsonEqual(a[key], b[key]));
71
+ }
72
+ return false;
73
+ }
@@ -0,0 +1,25 @@
1
+ import type { CapabilityBuildInfoV1 } from "../vite/capabilityBuildTypes.js";
2
+ export interface RegisteredCapabilityRuntimeV1 {
3
+ capabilityBuildInfo: Readonly<CapabilityBuildInfoV1>;
4
+ openUploadStream: () => Promise<{
5
+ digest: string;
6
+ byteLength: number;
7
+ contentType: "application/gzip";
8
+ stream: ReadableStream<Uint8Array>;
9
+ }>;
10
+ }
11
+ export declare const CAPABILITY_RUNTIME_SYMBOL_V1 = "inupedia.spotlight.capability-runtime/1";
12
+ export declare function registerCapabilityRuntimeV1(runtime: RegisteredCapabilityRuntimeV1): void;
13
+ export declare function getCapabilityRuntimeV1(projectId: string): Readonly<{
14
+ subscribe(listener: (info: Readonly<CapabilityBuildInfoV1>) => void): () => boolean;
15
+ capabilityBuildInfo: Readonly<CapabilityBuildInfoV1>;
16
+ openUploadStream: () => Promise<{
17
+ digest: string;
18
+ byteLength: number;
19
+ contentType: "application/gzip";
20
+ stream: ReadableStream<Uint8Array>;
21
+ }>;
22
+ }> | undefined;
23
+ export declare function subscribeCapabilityRuntimeV1(projectId: string, listener: (info: Readonly<CapabilityBuildInfoV1>) => void): () => void;
24
+ export declare function waitForCapabilityRuntimeV1(projectId: string, signal?: AbortSignal): Promise<RegisteredCapabilityRuntimeV1>;
25
+ //# sourceMappingURL=runtimeCapabilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeCapabilities.d.ts","sourceRoot":"","sources":["../../src/capabilities/runtimeCapabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAE7E,MAAM,WAAW,6BAA6B;IAC5C,mBAAmB,EAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC;IACrD,gBAAgB,EAAE,MAAM,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,kBAAkB,CAAC;QAAC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;KAAE,CAAC,CAAC;CAC9I;AAOD,eAAO,MAAM,4BAA4B,4CAA4C,CAAC;AAQtF,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,6BAA6B,GAAG,IAAI,CAIxF;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM;wBAMhC,CAAC,IAAI,EAAE,QAAQ,CAAC,qBAAqB,CAAC,KAAK,IAAI;yBA7BhD,QAAQ,CAAC,qBAAqB,CAAC;sBAClC,MAAM,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,kBAAkB,CAAC;QAAC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;KAAE,CAAC;eAmC7I;AAED,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,qBAAqB,CAAC,KAAK,IAAI,GACxD,MAAM,IAAI,CAMZ;AAED,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,6BAA6B,CAAC,CAexC"}
@@ -0,0 +1,53 @@
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
+ }
package/dist/index.d.ts CHANGED
@@ -15,4 +15,10 @@ export { substituteSkillPlaceholders, executeInlineShellInMarkdown, prepareSkill
15
15
  export { registerSkillScriptTool, type RegisterSkillScriptToolOptions, type SkillScriptRunner, } from "./skillScriptTool.js";
16
16
  export { joinSkillScriptPath, type SkillScriptRunResult, } from "./skillScriptPath.js";
17
17
  export type { AgentDef } from "./agentDecoratorTypes.js";
18
+ export { createFrontendToolRegistry, defineFrontendTool, defineSpotlightProject, projectToolDescriptors, type FrontendToolDefinitionV1, type FrontendToolHandlerContextV1, type FrontendToolRegistryV1, type SpotlightProjectV1, } from "./tools/frontendTool.js";
19
+ export { createCapabilityClient, type CapabilityConnectInputV1, type CapabilityConnectResultV1, type CreateCapabilityClientOptionsV1, } from "./capabilities/handshake.js";
20
+ export { createCapabilityChannel, type CapabilityChannelV1, } from "./capabilities/channel.js";
21
+ export { createHostActionExecutor, type CapabilityExecutionFenceV1, } from "./capabilities/hostActionExecutor.js";
22
+ export { SpotlightCapabilityError } from "./capabilities/errors.js";
23
+ export { getCapabilityRuntimeV1, registerCapabilityRuntimeV1, subscribeCapabilityRuntimeV1, waitForCapabilityRuntimeV1, type RegisteredCapabilityRuntimeV1, } from "./capabilities/runtimeCapabilities.js";
18
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,qBAAqB,EA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AK,mBAAmB,GACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,wBAAwB,EACxB,KAAK,0BAA0B,GAChC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EACL,sBAAsB,EACtB,2BAA2B,EAC3B,4BAA4B,EAC5B,0BAA0B,EAC1B,KAAK,6BAA6B,GACnC,MAAM,uCAAuC,CAAC"}
package/dist/index.js CHANGED
@@ -13,3 +13,9 @@ export { validateSkillFrontmatter, describeCapabilitySurface, SPOTLIGHT_LAYOUT,
13
13
  export { substituteSkillPlaceholders, executeInlineShellInMarkdown, prepareSkillMarkdownContent, } from "./skillPrompt.js";
14
14
  export { registerSkillScriptTool, } from "./skillScriptTool.js";
15
15
  export { joinSkillScriptPath, } from "./skillScriptPath.js";
16
+ export { createFrontendToolRegistry, defineFrontendTool, defineSpotlightProject, projectToolDescriptors, } from "./tools/frontendTool.js";
17
+ export { createCapabilityClient, } from "./capabilities/handshake.js";
18
+ export { createCapabilityChannel, } from "./capabilities/channel.js";
19
+ export { createHostActionExecutor, } from "./capabilities/hostActionExecutor.js";
20
+ export { SpotlightCapabilityError } from "./capabilities/errors.js";
21
+ export { getCapabilityRuntimeV1, registerCapabilityRuntimeV1, subscribeCapabilityRuntimeV1, waitForCapabilityRuntimeV1, } from "./capabilities/runtimeCapabilities.js";