@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,194 +0,0 @@
|
|
|
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 renewPending;
|
|
14
|
-
let reconnectTimer;
|
|
15
|
-
let reconnectAttempt = 0;
|
|
16
|
-
let generation = 0;
|
|
17
|
-
let reservationSerial = 0;
|
|
18
|
-
let closed = false;
|
|
19
|
-
let mutationTail = Promise.resolve();
|
|
20
|
-
const lifecycle = new AbortController();
|
|
21
|
-
let reserveAndOpen;
|
|
22
|
-
const scheduleReconnect = () => {
|
|
23
|
-
if (closed || reconnectTimer)
|
|
24
|
-
return;
|
|
25
|
-
const delay = Math.min(250 * 2 ** reconnectAttempt, 5_000);
|
|
26
|
-
reconnectAttempt += 1;
|
|
27
|
-
reconnectTimer = setTimeout(() => {
|
|
28
|
-
reconnectTimer = undefined;
|
|
29
|
-
void reserveAndOpen().catch((error) => {
|
|
30
|
-
if (error instanceof SpotlightCapabilityError &&
|
|
31
|
-
["HOST_OFFLINE", "CAPABILITY_LEASE_REVOKED", "CAPABILITY_LEASE_FENCED"].includes(error.code)) {
|
|
32
|
-
close();
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
scheduleReconnect();
|
|
36
|
-
});
|
|
37
|
-
}, delay);
|
|
38
|
-
};
|
|
39
|
-
const fence = () => Object.freeze({
|
|
40
|
-
sessionId: options.identity.sessionId,
|
|
41
|
-
capabilitySnapshotId: options.handshake.capabilitySnapshotId,
|
|
42
|
-
leaseId: options.handshake.leaseId,
|
|
43
|
-
leaseVersion,
|
|
44
|
-
connectionId,
|
|
45
|
-
connectionEpoch,
|
|
46
|
-
browserInstanceId: options.identity.browserInstanceId,
|
|
47
|
-
tabInstanceId: options.identity.tabInstanceId,
|
|
48
|
-
});
|
|
49
|
-
const executor = createHostActionExecutor({ registry: options.registry, fence });
|
|
50
|
-
const close = () => {
|
|
51
|
-
closed = true;
|
|
52
|
-
lifecycle.abort(new DOMException("Capability channel closed.", "AbortError"));
|
|
53
|
-
if (heartbeat)
|
|
54
|
-
clearInterval(heartbeat);
|
|
55
|
-
if (renewal)
|
|
56
|
-
clearInterval(renewal);
|
|
57
|
-
if (reconnectTimer)
|
|
58
|
-
clearTimeout(reconnectTimer);
|
|
59
|
-
heartbeat = undefined;
|
|
60
|
-
renewal = undefined;
|
|
61
|
-
if (socket)
|
|
62
|
-
socket.onclose = null;
|
|
63
|
-
socket?.close();
|
|
64
|
-
socket = undefined;
|
|
65
|
-
};
|
|
66
|
-
const open = () => {
|
|
67
|
-
if (closed)
|
|
68
|
-
throw new SpotlightCapabilityError("CAPABILITY_LEASE_FENCED", "Capability channel is closed.");
|
|
69
|
-
if (socket)
|
|
70
|
-
socket.onclose = null;
|
|
71
|
-
socket?.close();
|
|
72
|
-
const create = options.createWebSocket ?? ((url) => new WebSocket(url));
|
|
73
|
-
const origin = typeof location === "undefined" ? "http://localhost" : location.origin;
|
|
74
|
-
const base = new URL(options.endpoint.replace(/\/$/, "") + "/", origin);
|
|
75
|
-
const channelPath = options.handshake.capabilityChannelUrl.replace(/^\//, "");
|
|
76
|
-
const url = new URL(channelPath, base);
|
|
77
|
-
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
78
|
-
const localSocket = create(url.toString());
|
|
79
|
-
const localGeneration = ++generation;
|
|
80
|
-
socket = localSocket;
|
|
81
|
-
const sendLocal = (message) => { if (!closed && socket === localSocket && generation === localGeneration && localSocket.readyState === 1)
|
|
82
|
-
localSocket.send(JSON.stringify(message)); };
|
|
83
|
-
localSocket.onopen = () => {
|
|
84
|
-
if (socket !== localSocket || generation !== localGeneration || closed)
|
|
85
|
-
return;
|
|
86
|
-
reconnectAttempt = 0;
|
|
87
|
-
sendLocal({
|
|
88
|
-
type: "client_hello",
|
|
89
|
-
protocolVersion: SPOTLIGHT_CAPABILITY_PROTOCOL_V1,
|
|
90
|
-
capabilityChannelToken: channelToken,
|
|
91
|
-
browserInstanceId: options.identity.browserInstanceId,
|
|
92
|
-
tabInstanceId: options.identity.tabInstanceId,
|
|
93
|
-
});
|
|
94
|
-
if (heartbeat)
|
|
95
|
-
clearInterval(heartbeat);
|
|
96
|
-
heartbeat = setInterval(() => sendLocal({ type: "heartbeat", ...fence(), sentAt: new Date().toISOString() }), 5_000);
|
|
97
|
-
if (renewal)
|
|
98
|
-
clearInterval(renewal);
|
|
99
|
-
renewal = setInterval(() => {
|
|
100
|
-
if (renewalPendingGeneration === localGeneration)
|
|
101
|
-
return;
|
|
102
|
-
renewalPendingGeneration = localGeneration;
|
|
103
|
-
void renew().catch(scheduleReconnect).finally(() => { if (renewalPendingGeneration === localGeneration)
|
|
104
|
-
renewalPendingGeneration = undefined; });
|
|
105
|
-
}, 5_000);
|
|
106
|
-
};
|
|
107
|
-
localSocket.onmessage = (event) => {
|
|
108
|
-
if (socket !== localSocket || generation !== localGeneration || closed)
|
|
109
|
-
return;
|
|
110
|
-
void (async () => {
|
|
111
|
-
const message = JSON.parse(String(event.data));
|
|
112
|
-
if (message.type === "host_action_request") {
|
|
113
|
-
await executor.executeStreaming(message, sendLocal);
|
|
114
|
-
}
|
|
115
|
-
else if (message.type === "channel_fenced") {
|
|
116
|
-
close();
|
|
117
|
-
}
|
|
118
|
-
})();
|
|
119
|
-
};
|
|
120
|
-
localSocket.onclose = () => {
|
|
121
|
-
if (socket !== localSocket || generation !== localGeneration || closed)
|
|
122
|
-
return;
|
|
123
|
-
if (heartbeat)
|
|
124
|
-
clearInterval(heartbeat);
|
|
125
|
-
if (renewal)
|
|
126
|
-
clearInterval(renewal);
|
|
127
|
-
heartbeat = undefined;
|
|
128
|
-
renewal = undefined;
|
|
129
|
-
scheduleReconnect();
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
|
-
const post = async (path, body) => capabilityResponseJson(await options.fetch(`${options.endpoint.replace(/\/$/, "")}${path}`, {
|
|
133
|
-
method: "POST",
|
|
134
|
-
headers: { "Content-Type": "application/json" },
|
|
135
|
-
body: JSON.stringify(body),
|
|
136
|
-
signal: lifecycle.signal,
|
|
137
|
-
}));
|
|
138
|
-
const mutate = (operation) => {
|
|
139
|
-
const task = mutationTail.then(operation, operation);
|
|
140
|
-
mutationTail = task.then(() => undefined, () => undefined);
|
|
141
|
-
return task;
|
|
142
|
-
};
|
|
143
|
-
const performRenew = () => mutate(async () => {
|
|
144
|
-
const current = fence();
|
|
145
|
-
const startedGeneration = generation;
|
|
146
|
-
const result = await post(`/v1/capabilities/leases/${encodeURIComponent(current.leaseId)}/renew`, { ...current, expectedLeaseVersion: current.leaseVersion, liveTools: options.registry.liveTools() });
|
|
147
|
-
if (startedGeneration !== generation || closed)
|
|
148
|
-
return result;
|
|
149
|
-
if (result.status === "revoked") {
|
|
150
|
-
close();
|
|
151
|
-
throw new SpotlightCapabilityError("CAPABILITY_LEASE_REVOKED", result.reason);
|
|
152
|
-
}
|
|
153
|
-
leaseVersion = result.leaseVersion;
|
|
154
|
-
return result;
|
|
155
|
-
});
|
|
156
|
-
const renew = () => {
|
|
157
|
-
if (renewPending)
|
|
158
|
-
return renewPending;
|
|
159
|
-
const task = performRenew();
|
|
160
|
-
renewPending = task;
|
|
161
|
-
const clear = () => {
|
|
162
|
-
if (renewPending === task)
|
|
163
|
-
renewPending = undefined;
|
|
164
|
-
};
|
|
165
|
-
void task.then(clear, clear);
|
|
166
|
-
return task;
|
|
167
|
-
};
|
|
168
|
-
reserveAndOpen = () => mutate(async () => {
|
|
169
|
-
const current = fence();
|
|
170
|
-
const startedGeneration = generation;
|
|
171
|
-
const serial = ++reservationSerial;
|
|
172
|
-
const reserved = await post(`/v1/capabilities/leases/${encodeURIComponent(current.leaseId)}/connections`, {
|
|
173
|
-
expectedConnectionId: current.connectionId,
|
|
174
|
-
expectedConnectionEpoch: current.connectionEpoch,
|
|
175
|
-
expectedLeaseVersion: current.leaseVersion,
|
|
176
|
-
browserInstanceId: current.browserInstanceId,
|
|
177
|
-
tabInstanceId: current.tabInstanceId,
|
|
178
|
-
});
|
|
179
|
-
if (closed || startedGeneration !== generation || serial !== reservationSerial)
|
|
180
|
-
return;
|
|
181
|
-
leaseVersion = reserved.leaseVersion;
|
|
182
|
-
connectionId = reserved.connectionId;
|
|
183
|
-
connectionEpoch = reserved.connectionEpoch;
|
|
184
|
-
channelToken = reserved.capabilityChannelToken;
|
|
185
|
-
open();
|
|
186
|
-
});
|
|
187
|
-
return Object.freeze({
|
|
188
|
-
open,
|
|
189
|
-
close,
|
|
190
|
-
fence,
|
|
191
|
-
renew,
|
|
192
|
-
reconnect: reserveAndOpen,
|
|
193
|
-
});
|
|
194
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
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
|
-
/** API key applied to all Capability HTTP requests. */
|
|
21
|
-
apiKey?: string;
|
|
22
|
-
project: SpotlightProjectV1;
|
|
23
|
-
registry: FrontendToolRegistryV1;
|
|
24
|
-
buildInfo: Readonly<CapabilityBuildInfoV1>;
|
|
25
|
-
openUploadStream: () => Promise<{
|
|
26
|
-
digest: string;
|
|
27
|
-
byteLength: number;
|
|
28
|
-
contentType: "application/gzip";
|
|
29
|
-
stream: ReadableStream<Uint8Array>;
|
|
30
|
-
}>;
|
|
31
|
-
fetch?: typeof globalThis.fetch;
|
|
32
|
-
createOfferId?: () => string;
|
|
33
|
-
createWebSocket?: (url: string) => WebSocket;
|
|
34
|
-
}
|
|
35
|
-
export declare function createCapabilityClient(options: CreateCapabilityClientOptionsV1): Readonly<{
|
|
36
|
-
connect(input: CapabilityConnectInputV1): Promise<CapabilityConnectResultV1>;
|
|
37
|
-
}>;
|
|
38
|
-
//# sourceMappingURL=handshake.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AAIjF,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,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,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;AAiDD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,+BAA+B;mBA+BtD,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC;GA+DrF"}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { SPOTLIGHT_CAPABILITY_PROTOCOL_V1, } from "@inupedia/spotlight-protocol";
|
|
2
|
-
import { createCapabilityChannel } from "./channel.js";
|
|
3
|
-
import { capabilityResponseJson } from "./errors.js";
|
|
4
|
-
import { createRuntimeId } from "../runtimeId.js";
|
|
5
|
-
function endpoint(base, path) {
|
|
6
|
-
return `${base.replace(/\/$/, "")}${path}`;
|
|
7
|
-
}
|
|
8
|
-
async function readUploadBody(stream, byteLength, signal) {
|
|
9
|
-
if (!Number.isSafeInteger(byteLength) || byteLength < 0) {
|
|
10
|
-
throw new Error("Capability Artifact upload byte length is invalid.");
|
|
11
|
-
}
|
|
12
|
-
const body = new Uint8Array(byteLength);
|
|
13
|
-
const reader = stream.getReader();
|
|
14
|
-
let offset = 0;
|
|
15
|
-
const abortReason = () => signal?.reason instanceof Error
|
|
16
|
-
? signal.reason
|
|
17
|
-
: new DOMException("Capability upload aborted.", "AbortError");
|
|
18
|
-
const cancelReader = () => {
|
|
19
|
-
void reader.cancel(abortReason()).catch(() => undefined);
|
|
20
|
-
};
|
|
21
|
-
signal?.addEventListener("abort", cancelReader, { once: true });
|
|
22
|
-
if (signal?.aborted)
|
|
23
|
-
cancelReader();
|
|
24
|
-
try {
|
|
25
|
-
while (true) {
|
|
26
|
-
if (signal?.aborted) {
|
|
27
|
-
throw abortReason();
|
|
28
|
-
}
|
|
29
|
-
const { done, value } = await reader.read();
|
|
30
|
-
if (signal?.aborted)
|
|
31
|
-
throw abortReason();
|
|
32
|
-
if (done)
|
|
33
|
-
break;
|
|
34
|
-
if (offset + value.byteLength > byteLength) {
|
|
35
|
-
throw new Error("Capability Artifact upload exceeded its declared byte length.");
|
|
36
|
-
}
|
|
37
|
-
body.set(value, offset);
|
|
38
|
-
offset += value.byteLength;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
finally {
|
|
42
|
-
signal?.removeEventListener("abort", cancelReader);
|
|
43
|
-
reader.releaseLock();
|
|
44
|
-
}
|
|
45
|
-
if (offset !== byteLength) {
|
|
46
|
-
throw new Error("Capability Artifact upload did not match its declared byte length.");
|
|
47
|
-
}
|
|
48
|
-
return body;
|
|
49
|
-
}
|
|
50
|
-
export function createCapabilityClient(options) {
|
|
51
|
-
const rawFetcher = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
52
|
-
const apiKey = options.apiKey?.trim();
|
|
53
|
-
const fetcher = apiKey
|
|
54
|
-
? (input, init = {}) => {
|
|
55
|
-
const headers = new Headers(init.headers);
|
|
56
|
-
if (!headers.has("X-Spotlight-Api-Key")) {
|
|
57
|
-
headers.set("X-Spotlight-Api-Key", apiKey);
|
|
58
|
-
}
|
|
59
|
-
return rawFetcher(input, { ...init, headers });
|
|
60
|
-
}
|
|
61
|
-
: rawFetcher;
|
|
62
|
-
const offerIds = new Map();
|
|
63
|
-
const offerIdFor = (key) => {
|
|
64
|
-
const existing = offerIds.get(key);
|
|
65
|
-
if (existing)
|
|
66
|
-
return existing;
|
|
67
|
-
const created = options.createOfferId?.() ?? createRuntimeId();
|
|
68
|
-
offerIds.set(key, created);
|
|
69
|
-
return created;
|
|
70
|
-
};
|
|
71
|
-
async function post(path, body, signal) {
|
|
72
|
-
return capabilityResponseJson(await fetcher(endpoint(options.endpoint, path), {
|
|
73
|
-
method: "POST",
|
|
74
|
-
headers: { "Content-Type": "application/json" },
|
|
75
|
-
body: JSON.stringify(body),
|
|
76
|
-
signal,
|
|
77
|
-
}));
|
|
78
|
-
}
|
|
79
|
-
return Object.freeze({
|
|
80
|
-
async connect(input) {
|
|
81
|
-
const key = [input.sessionId, options.buildInfo.frontendBuildId, options.buildInfo.artifactDigest, input.browserInstanceId, input.tabInstanceId].join("\u0000");
|
|
82
|
-
const offer = {
|
|
83
|
-
protocolVersion: SPOTLIGHT_CAPABILITY_PROTOCOL_V1,
|
|
84
|
-
offerId: offerIdFor(key),
|
|
85
|
-
projectId: options.project.projectId,
|
|
86
|
-
sessionId: input.sessionId,
|
|
87
|
-
frontendBuildId: options.buildInfo.frontendBuildId,
|
|
88
|
-
browserInstanceId: input.browserInstanceId,
|
|
89
|
-
tabInstanceId: input.tabInstanceId,
|
|
90
|
-
capabilityArtifact: {
|
|
91
|
-
digest: options.buildInfo.artifactDigest,
|
|
92
|
-
manifestDigest: options.buildInfo.manifestDigest,
|
|
93
|
-
skillManifestDigest: options.buildInfo.skillManifestDigest,
|
|
94
|
-
toolManifestDigest: options.buildInfo.toolManifestDigest,
|
|
95
|
-
byteLength: options.buildInfo.byteLength,
|
|
96
|
-
},
|
|
97
|
-
liveTools: options.registry.liveTools(),
|
|
98
|
-
};
|
|
99
|
-
let handshake = await post("/v1/capabilities/handshakes", offer, input.signal);
|
|
100
|
-
if (handshake.status === "upload_required") {
|
|
101
|
-
const upload = await options.openUploadStream();
|
|
102
|
-
const uploadBody = await readUploadBody(upload.stream, upload.byteLength, input.signal);
|
|
103
|
-
const uploadRequest = {
|
|
104
|
-
method: "PUT",
|
|
105
|
-
headers: {
|
|
106
|
-
Authorization: `Bearer ${handshake.uploadToken}`,
|
|
107
|
-
"Content-Type": upload.contentType,
|
|
108
|
-
},
|
|
109
|
-
body: uploadBody,
|
|
110
|
-
signal: input.signal,
|
|
111
|
-
};
|
|
112
|
-
const uploadUrl = endpoint(options.endpoint, handshake.uploadUrl);
|
|
113
|
-
let uploadResponse;
|
|
114
|
-
try {
|
|
115
|
-
uploadResponse = await fetcher(uploadUrl, uploadRequest);
|
|
116
|
-
}
|
|
117
|
-
catch (error) {
|
|
118
|
-
const detail = error instanceof Error ? error.message : String(error);
|
|
119
|
-
throw new Error(`Capability Artifact upload request failed (${uploadUrl}): ${detail}`, { cause: error });
|
|
120
|
-
}
|
|
121
|
-
await capabilityResponseJson(uploadResponse);
|
|
122
|
-
handshake = await post(`/v1/capabilities/handshakes/${encodeURIComponent(handshake.handshakeId)}/resume`, { resumeToken: handshake.resumeToken }, input.signal);
|
|
123
|
-
}
|
|
124
|
-
if (handshake.status !== "accepted")
|
|
125
|
-
throw new Error("Capability Handshake did not reach a terminal accepted state.");
|
|
126
|
-
const channel = input.openChannel === false ? undefined : createCapabilityChannel({
|
|
127
|
-
endpoint: options.endpoint,
|
|
128
|
-
handshake,
|
|
129
|
-
identity: input,
|
|
130
|
-
registry: options.registry,
|
|
131
|
-
fetch: fetcher,
|
|
132
|
-
createWebSocket: options.createWebSocket,
|
|
133
|
-
});
|
|
134
|
-
if (channel)
|
|
135
|
-
channel.open();
|
|
136
|
-
return { handshake, ...(channel ? { channel } : {}) };
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,56 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,73 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|