@histoire/devframe 0.0.0-stage → 1.0.0-beta.2
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/LICENSE +21 -0
- package/README.md +36 -2
- package/dist/client/attach.d.ts +15 -0
- package/dist/client/attach.d.ts.map +1 -0
- package/dist/client/attach.js +238 -0
- package/dist/client/diagnostics.d.ts +14 -0
- package/dist/client/diagnostics.d.ts.map +1 -0
- package/dist/client/diagnostics.js +31 -0
- package/dist/client/events.d.ts +11 -0
- package/dist/client/events.d.ts.map +1 -0
- package/dist/client/events.js +52 -0
- package/dist/client/highlight-operations.d.ts +14 -0
- package/dist/client/highlight-operations.d.ts.map +1 -0
- package/dist/client/highlight-operations.js +74 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +2 -0
- package/dist/client/inspection.d.ts +9 -0
- package/dist/client/inspection.d.ts.map +1 -0
- package/dist/client/inspection.js +32 -0
- package/dist/client/pairing-budget.d.ts +3 -0
- package/dist/client/pairing-budget.d.ts.map +1 -0
- package/dist/client/pairing-budget.js +36 -0
- package/dist/host/index.d.ts +35 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +86 -0
- package/dist/node/broker.d.ts +37 -0
- package/dist/node/broker.d.ts.map +1 -0
- package/dist/node/broker.js +349 -0
- package/dist/node/devframe.d.ts +64 -0
- package/dist/node/devframe.d.ts.map +1 -0
- package/dist/node/devframe.js +193 -0
- package/dist/node/grants.d.ts +24 -0
- package/dist/node/grants.d.ts.map +1 -0
- package/dist/node/grants.js +58 -0
- package/dist/node/index.d.ts +8 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +4 -0
- package/dist/node/mcp.d.ts +10 -0
- package/dist/node/mcp.d.ts.map +1 -0
- package/dist/node/mcp.js +150 -0
- package/dist/node/retirements.d.ts +8 -0
- package/dist/node/retirements.d.ts.map +1 -0
- package/dist/node/retirements.js +34 -0
- package/dist/node/rpc-budget.d.ts +6 -0
- package/dist/node/rpc-budget.d.ts.map +1 -0
- package/dist/node/rpc-budget.js +26 -0
- package/dist/node/types.d.ts +65 -0
- package/dist/node/types.d.ts.map +1 -0
- package/dist/node/types.js +1 -0
- package/dist/node/validation.d.ts +10 -0
- package/dist/node/validation.d.ts.map +1 -0
- package/dist/node/validation.js +50 -0
- package/dist/report/content.d.ts +33 -0
- package/dist/report/content.d.ts.map +1 -0
- package/dist/report/content.js +64 -0
- package/dist/report/index.d.ts +60 -0
- package/dist/report/index.d.ts.map +1 -0
- package/dist/report/index.js +78 -0
- package/dist/shared/diagnostics.d.ts +9 -0
- package/dist/shared/diagnostics.d.ts.map +1 -0
- package/dist/shared/diagnostics.js +20 -0
- package/dist/shared/events.d.ts +27 -0
- package/dist/shared/events.d.ts.map +1 -0
- package/dist/shared/events.js +49 -0
- package/dist/shared/services.d.ts +413 -0
- package/dist/shared/services.d.ts.map +1 -0
- package/dist/shared/services.js +113 -0
- package/package.json +53 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Guillaume Chau
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Histoire Devframe adapter
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This package provides opt-in, authenticated access to an already mounted Histoire session. Importing it starts no listener, connection, event observation or diagnostic instrumentation. The host owns its Histoire session, Devframe instance, HTTP server, credentials and authorization policy.
|
|
4
|
+
|
|
5
|
+
Start with the [live-inspection guide](../../docs/guide/devframe.md) for installation, source configuration, browser pairing, and MCP calls. See the [adapter reference](../../docs/reference/devframe.md) for API defaults, tool inputs, reports, and troubleshooting.
|
|
6
|
+
|
|
7
|
+
Packed-consumer and compatibility gates remain part of release verification; no publication is implied by these APIs.
|
|
8
|
+
|
|
9
|
+
## Host contract
|
|
10
|
+
|
|
11
|
+
`createDevframeBridge` creates a Devframe definition and a bounded broker. The host installs the definition in a Devframe instance with automatic MCP and shared-state exposure disabled. Pass the Devframe disconnect hook to `bridge.onPeerDisconnect(meta)`; await `bridge.dispose()` when finished. For a cross-origin browser host, explicitly allow that origin for the Devframe transport and allow it to fetch the Devframe `__connection.json` metadata route through the host CORS policy. Disposal joins owned peer retirement acknowledgements and rejects with a generic error if one fails or times out; it never closes the caller's server or connection.
|
|
12
|
+
|
|
13
|
+
A host must supply all of these callbacks:
|
|
14
|
+
|
|
15
|
+
- `identifyPeer`: derive a stable browser principal from verified transport credentials. A peer ID, origin, trust flag or browser-provided value alone does not establish identity.
|
|
16
|
+
- `verifyAttachment`: authorize the canonical source and resolve the exact document metadata and permitted scopes. Browser claims and project IDs are untrusted inputs, not authority.
|
|
17
|
+
- `isCurrent`: check that the captured attachment and its source are still authorized and current.
|
|
18
|
+
- `allowSource`: constrain allowed canonical book URLs.
|
|
19
|
+
- `authorize`: authorize discovery and each finite scope for the separately authenticated agent principal.
|
|
20
|
+
- `authorityVersion`: return a monotonic host-owned revision. Increment it synchronously on every policy, source or runtime authority change, then call `bridge.invalidate(attachmentId)` for a specific attachment or `bridge.invalidate()` for a global change. Invalidation aborts work and retires the browser attachment. Mutable callbacks without revision and invalidation cannot enforce timely revocation.
|
|
21
|
+
|
|
22
|
+
Create a short-lived one-use grant through `bridge.broker.createGrant`, bound to the browser principal, canonical source and maximum scopes. Deliver its token to the browser through a confidential host channel; do not put it in a URL, discovery metadata or logs. The browser calls `attachDevframe` with its existing connected session and authenticated Devframe client. The SDK must have a ready mounted target; no story is mounted automatically. Await the returned `dispose()` before considering attachment cleanup complete.
|
|
23
|
+
|
|
24
|
+
`createMcpEndpoint` creates a fetch-shaped handler. The host must route an explicitly configured endpoint to it and authenticate **every** request through the required callback. Return a stable agent principal only after verifying credentials; never derive it from tool arguments. The host owns HTTP origin policy, listener and path routing. Call `endpoint.close()` independently of the host server. Browser and agent authentication are separate.
|
|
25
|
+
|
|
26
|
+
## Scopes and limits
|
|
27
|
+
|
|
28
|
+
- `inspection`: finite variant and DOM reads of the exact paired owner. SDK capability and target checks still apply.
|
|
29
|
+
- `events`: current SDK-owned component event history, with exact target and runtime attribution. A nonzero cursor needs the returned `eventLifetime`; clearing history invalidates older lifetimes. `droppedCount` and `gap` describe the SDK session history, including events outside the selected target. An events-only attachment does not start diagnostic observation.
|
|
30
|
+
- `components`: finite component trees, exact instance details and selector-to-owner lookup when the mounted runtime supports them.
|
|
31
|
+
- `accessibility`: bounded axe audit when the mounted runtime supports it.
|
|
32
|
+
- `highlight`: temporary selector highlight when source and mounted runtime support highlight and highlight leases. Component-ID highlight additionally requires the `components` scope, authorization for both scopes, and the `componentHighlight` capability. Authorization is checked before and after the action. Neither action changes selection.
|
|
33
|
+
- `diagnostics`: starts a shared SDK debug subscription after the grant is accepted. It ends on attachment retirement or disposal. Console and error entries are document-wide observations, not proof that the selected component caused them. Common credential patterns are redacted by the SDK; arbitrary unlabelled secrets may remain.
|
|
34
|
+
|
|
35
|
+
Inputs, results, pending requests, grants, attachments and leases are bounded. An attachment retains up to 128 highlight leases until their overlay expires, and clears its own leases on retirement. Cleanup is bounded to three seconds; disposal reports incomplete cleanup if it fails or times out. The adapter limits unresolved Devframe operation calls to 64 and unresolved retirement calls to 64 per bridge, retaining each slot until the upstream promise settles. Browser pairing is capped at 32 unresolved attempts per connection; a client timeout retains its slot for an additional 60 seconds because Devframe may still hold the underlying call. Cancellation is sent as a targeted one-way RPC event. Devframe 1.2.2 birpc retains an unanswered RPC internally for its 60-second default timeout; adapter disposal stops waiting at its configured timeout and never closes a caller-owned connection to force that internal state away. Only finite service names are exposed. Existing isolated Histoire MCP services retain their own lifecycle and behavior.
|
|
36
|
+
|
|
37
|
+
`mountDevframeHost` from `@histoire/devframe/host` optionally mounts the bridge on a caller-owned HTTP or HTTPS server. It requires explicit transport auth, host policy, origin and a dedicated base; install its returned `nodeMiddleware` without stripping that base, and await `dispose()`. Its owned Devframe instance disables automatic MCP, SSE, discovery registration and static assets. Remove the caller's own middleware layer separately if needed. Distinct helpers reject overlapping bases on the same server; external mounts remain the host's responsibility. When creating a Devframe client for this adapter, pass `webmcp: false`: generic WebMCP registration lacks the authenticated agent-principal and per-call authorization seam needed here. A DevTools dock is not advertised without a verified owner-bound host integration.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { HistoireSession } from '@histoire/sdk';
|
|
2
|
+
import type { DevframeRpcClient } from 'devframe/client';
|
|
3
|
+
/** Explicitly pair an already-mounted session with a caller-owned connection. */
|
|
4
|
+
export declare function attachDevframe(options: {
|
|
5
|
+
session: HistoireSession;
|
|
6
|
+
connection: DevframeRpcClient;
|
|
7
|
+
grant: string;
|
|
8
|
+
projectId: string;
|
|
9
|
+
scopes?: readonly ('inspection' | 'events' | 'diagnostics' | 'components' | 'accessibility' | 'highlight')[];
|
|
10
|
+
id?: string;
|
|
11
|
+
}): Promise<{
|
|
12
|
+
attachment: any;
|
|
13
|
+
dispose: (remote?: boolean) => Promise<void>;
|
|
14
|
+
}>;
|
|
15
|
+
//# sourceMappingURL=attach.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attach.d.ts","sourceRoot":"","sources":["../../src/client/attach.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AASxD,iFAAiF;AACjF,wBAAsB,cAAc,CAAC,OAAO,EAAE;IAAE,OAAO,EAAE,eAAe,CAAC;IAAC,UAAU,EAAE,iBAAiB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,SAAS,CAAC,YAAY,GAAG,QAAQ,GAAG,aAAa,GAAG,YAAY,GAAG,eAAe,GAAG,WAAW,CAAC,EAAE,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE;;;GAgMrQ"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { measureWireValue, sameInspectionOwner, validateInspectionOwner } from '@histoire/protocol';
|
|
2
|
+
import { assertServiceOperation, LIVE_SERVICES, serviceScopes } from '../shared/services.js';
|
|
3
|
+
import { createDiagnosticReader } from './diagnostics.js';
|
|
4
|
+
import { createEventReader } from './events.js';
|
|
5
|
+
import { createHighlightOperations } from './highlight-operations.js';
|
|
6
|
+
import { createInspectionDispatcher } from './inspection.js';
|
|
7
|
+
import { startPairing } from './pairing-budget.js';
|
|
8
|
+
/** Explicitly pair an already-mounted session with a caller-owned connection. */
|
|
9
|
+
export async function attachDevframe(options) {
|
|
10
|
+
const { session, connection } = options;
|
|
11
|
+
const id = options.id ?? 'histoire';
|
|
12
|
+
let scopes = options.scopes ?? ['inspection'];
|
|
13
|
+
if (!scopes.length || scopes.length > 6 || new Set(scopes).size !== scopes.length || scopes.some(scope => !['inspection', 'events', 'diagnostics', 'components', 'accessibility', 'highlight'].includes(scope)))
|
|
14
|
+
throw new Error('Invalid attachment options');
|
|
15
|
+
if (!/^[a-z][a-z0-9-]{0,63}$/.test(id) || !options.projectId)
|
|
16
|
+
throw new Error('Invalid attachment options');
|
|
17
|
+
const snapshot = session.getSnapshot();
|
|
18
|
+
const { source, selection, runtime } = snapshot;
|
|
19
|
+
scopes = scopes.filter(scope => scope === 'events' || (scope === 'inspection' && (snapshot.inspection?.variant?.available || snapshot.inspection?.dom?.available)) || (scope === 'diagnostics' && snapshot.inspection?.diagnostics?.available) || (scope === 'components' && (snapshot.inspection?.components?.available || snapshot.inspection?.componentDetails?.available)) || (scope === 'accessibility' && snapshot.inspection?.accessibilityAudit?.available) || (scope === 'highlight' && snapshot.inspection?.highlight?.available && snapshot.inspection?.highlightLease?.available));
|
|
20
|
+
if (!scopes.length)
|
|
21
|
+
throw new Error('Live capability unavailable');
|
|
22
|
+
if (!source || !selection || !selection.variantId || runtime.status !== 'ready' || !runtime.mountId || !runtime.runtimeId || connection.isTrusted !== true)
|
|
23
|
+
throw new Error('Live session unavailable');
|
|
24
|
+
const identity = { projectId: options.projectId, sourceId: source.sourceId, epoch: source.epoch, revision: source.revision, mountId: runtime.mountId, runtimeId: runtime.runtimeId, target: { storyId: selection.storyId, variantId: selection.variantId } };
|
|
25
|
+
const owner = { sourceId: identity.sourceId, epoch: identity.epoch, revision: identity.revision, runtimeId: identity.runtimeId, target: identity.target };
|
|
26
|
+
const inspect = createInspectionDispatcher(session, owner);
|
|
27
|
+
const highlights = createHighlightOperations(session, owner);
|
|
28
|
+
let events;
|
|
29
|
+
let diagnostics;
|
|
30
|
+
let closing;
|
|
31
|
+
const method = `${id}:attachment:${crypto.randomUUID()}`;
|
|
32
|
+
const pending = new Map();
|
|
33
|
+
const pendingCompletion = new Set();
|
|
34
|
+
const cancelled = new Map();
|
|
35
|
+
let attachmentId;
|
|
36
|
+
let disposed = false;
|
|
37
|
+
let timer;
|
|
38
|
+
let unsubscribe = () => { };
|
|
39
|
+
let disconnect = () => { };
|
|
40
|
+
const call = connection.call;
|
|
41
|
+
const collector = connection.client;
|
|
42
|
+
if (collector.definitions.has(method))
|
|
43
|
+
throw new Error('Attachment already registered');
|
|
44
|
+
collector.register({ name: method, type: 'action', jsonSerializable: true, setup: () => ({ handler: async (request) => {
|
|
45
|
+
if (disposed || !request || typeof request.operationId !== 'string' || request.operationId.length > 128)
|
|
46
|
+
throw new Error('Session unavailable');
|
|
47
|
+
if (request.action === 'retire') {
|
|
48
|
+
await release(true);
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
if (request.action === 'commit' || request.action === 'cancel') {
|
|
52
|
+
const controller = pending.get(request.operationId);
|
|
53
|
+
if (request.action === 'cancel') {
|
|
54
|
+
if (controller)
|
|
55
|
+
controller.abort();
|
|
56
|
+
else if (!cancelled.has(request.operationId) && cancelled.size < 128)
|
|
57
|
+
cancelled.set(request.operationId, setTimeout(() => cancelled.delete(request.operationId), 10_000));
|
|
58
|
+
}
|
|
59
|
+
await highlights.finish(request.operationId, request.action === 'commit');
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
if (cancelled.has(request.operationId)) {
|
|
63
|
+
clearTimeout(cancelled.get(request.operationId));
|
|
64
|
+
cancelled.delete(request.operationId);
|
|
65
|
+
throw new Error('Session unavailable');
|
|
66
|
+
}
|
|
67
|
+
if (request.action !== 'call' || !request.name || !Object.hasOwn(LIVE_SERVICES, request.name) || !attachmentId || pending.has(request.operationId) || pending.size >= 4)
|
|
68
|
+
throw new Error('Session unavailable');
|
|
69
|
+
const controller = new AbortController();
|
|
70
|
+
const completion = Promise.withResolvers();
|
|
71
|
+
pendingCompletion.add(completion.promise);
|
|
72
|
+
pending.set(request.operationId, controller);
|
|
73
|
+
try {
|
|
74
|
+
if (request.name === 'histoire_get_session_diagnostics') {
|
|
75
|
+
if (!diagnostics) {
|
|
76
|
+
throw new Error('Session unavailable');
|
|
77
|
+
}
|
|
78
|
+
return diagnostics.read(request.input);
|
|
79
|
+
}
|
|
80
|
+
if (request.name === 'histoire_get_session_events') {
|
|
81
|
+
if (!events) {
|
|
82
|
+
throw new Error('Session unavailable');
|
|
83
|
+
}
|
|
84
|
+
return events.read(request.input);
|
|
85
|
+
}
|
|
86
|
+
assertServiceOperation(request.name, request.input);
|
|
87
|
+
const requiredScopes = serviceScopes(request.name, request.input);
|
|
88
|
+
if (requiredScopes.some(scope => !scopes.includes(scope)))
|
|
89
|
+
throw new Error('Session unavailable');
|
|
90
|
+
const isHighlight = request.name === 'histoire_highlight_element';
|
|
91
|
+
if (isHighlight && !highlights.hasCapacity(pending.size))
|
|
92
|
+
throw new Error('Session unavailable');
|
|
93
|
+
const result = await inspect(request.input, controller.signal);
|
|
94
|
+
if (isHighlight) {
|
|
95
|
+
const lease = result;
|
|
96
|
+
highlights.retain(request.operationId, lease);
|
|
97
|
+
if (controller.signal.aborted || requiredScopes.some(scope => !scopes.includes(scope))) {
|
|
98
|
+
await highlights.finish(request.operationId, false);
|
|
99
|
+
throw new Error('Session unavailable');
|
|
100
|
+
}
|
|
101
|
+
return { owner: lease.owner, observedAt: lease.observedAt };
|
|
102
|
+
}
|
|
103
|
+
if (requiredScopes.some(scope => !scopes.includes(scope)))
|
|
104
|
+
throw new Error('Session unavailable');
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
pending.delete(request.operationId);
|
|
109
|
+
pendingCompletion.delete(completion.promise);
|
|
110
|
+
completion.resolve();
|
|
111
|
+
}
|
|
112
|
+
} }) });
|
|
113
|
+
const ownedDefinition = collector.definitions.get(method);
|
|
114
|
+
/** Drop only this attachment's callback, subscriptions and pending work. */
|
|
115
|
+
function release(remote = false) {
|
|
116
|
+
if (disposed)
|
|
117
|
+
return closing ?? Promise.resolve();
|
|
118
|
+
disposed = true;
|
|
119
|
+
const completion = Promise.withResolvers();
|
|
120
|
+
closing = completion.promise;
|
|
121
|
+
if (timer)
|
|
122
|
+
clearInterval(timer);
|
|
123
|
+
for (const controller of pending.values())
|
|
124
|
+
controller.abort();
|
|
125
|
+
pending.clear();
|
|
126
|
+
for (const timer of cancelled.values())
|
|
127
|
+
clearTimeout(timer);
|
|
128
|
+
cancelled.clear();
|
|
129
|
+
let failed = false;
|
|
130
|
+
try {
|
|
131
|
+
unsubscribe();
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
failed = true;
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
events?.dispose();
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
failed = true;
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
disconnect();
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
failed = true;
|
|
147
|
+
}
|
|
148
|
+
if (collector.definitions.get(method) === ownedDefinition)
|
|
149
|
+
collector.definitions.delete(method);
|
|
150
|
+
const cleanupHighlights = (async () => {
|
|
151
|
+
let cleanupTimer;
|
|
152
|
+
const timeout = new Promise((_resolve, reject) => {
|
|
153
|
+
cleanupTimer = setTimeout(() => reject(new Error('Highlight cleanup incomplete')), 3000);
|
|
154
|
+
});
|
|
155
|
+
try {
|
|
156
|
+
await Promise.race([(async () => {
|
|
157
|
+
await Promise.all([...pendingCompletion]);
|
|
158
|
+
await highlights.dispose();
|
|
159
|
+
})(), timeout]);
|
|
160
|
+
}
|
|
161
|
+
finally {
|
|
162
|
+
clearTimeout(cleanupTimer);
|
|
163
|
+
}
|
|
164
|
+
})();
|
|
165
|
+
const observation = diagnostics ? Promise.resolve().then(() => diagnostics.dispose()) : Promise.resolve();
|
|
166
|
+
const detachment = attachmentId && !remote ? Promise.resolve().then(() => call(`${id}:detach`, attachmentId)) : Promise.resolve();
|
|
167
|
+
void Promise.allSettled([observation, detachment, cleanupHighlights]).then((results) => {
|
|
168
|
+
if (failed || results.some(result => result.status === 'rejected'))
|
|
169
|
+
completion.reject(new Error('Attachment cleanup incomplete'));
|
|
170
|
+
else
|
|
171
|
+
completion.resolve();
|
|
172
|
+
});
|
|
173
|
+
return closing;
|
|
174
|
+
}
|
|
175
|
+
try {
|
|
176
|
+
events = scopes.includes('events') ? createEventReader(session, owner) : undefined;
|
|
177
|
+
/** Public snapshot transitions retire this lifetime, including temporary deselection. */
|
|
178
|
+
const stopSnapshots = session.subscribe((value) => {
|
|
179
|
+
if (!value.source || value.source.sourceId !== identity.sourceId || value.source.epoch !== identity.epoch || value.source.revision !== identity.revision || value.source.url !== source.url || value.runtime.status !== 'ready' || value.runtime.mountId !== identity.mountId || value.runtime.runtimeId !== identity.runtimeId || value.selection?.storyId !== identity.target.storyId || value.selection?.variantId !== identity.target.variantId || (scopes.includes('inspection') && !value.inspection?.variant?.available && !value.inspection?.dom?.available) || (scopes.includes('diagnostics') && !value.inspection?.diagnostics?.available) || (scopes.includes('components') && !value.inspection?.components?.available && !value.inspection?.componentDetails?.available) || (scopes.includes('accessibility') && !value.inspection?.accessibilityAudit?.available) || (scopes.includes('highlight') && (!value.inspection?.highlight?.available || !value.inspection?.highlightLease?.available)))
|
|
180
|
+
void release().catch(() => { });
|
|
181
|
+
});
|
|
182
|
+
if (disposed) {
|
|
183
|
+
stopSnapshots();
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
unsubscribe = stopSnapshots;
|
|
187
|
+
}
|
|
188
|
+
const stopConnection = connection.events.on('connection:status', (status) => {
|
|
189
|
+
if (status !== 'connected') {
|
|
190
|
+
void release().catch(() => { });
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
if (disposed) {
|
|
194
|
+
stopConnection();
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
disconnect = stopConnection;
|
|
198
|
+
}
|
|
199
|
+
if (disposed)
|
|
200
|
+
throw new Error('Session unavailable');
|
|
201
|
+
const pairing = startPairing(connection, () => call(`${id}:pair`, { grant: options.grant, sourceUrl: source.url, identity, scopes, method }));
|
|
202
|
+
void pairing.then((value) => {
|
|
203
|
+
if (disposed && typeof value?.attachmentId === 'string') {
|
|
204
|
+
void call(`${id}:detach`, value.attachmentId).catch(() => { });
|
|
205
|
+
}
|
|
206
|
+
}, () => { });
|
|
207
|
+
let timeoutId;
|
|
208
|
+
const timeout = new Promise((_resolve, reject) => {
|
|
209
|
+
timeoutId = setTimeout(() => reject(new Error('Pairing timed out')), 5000);
|
|
210
|
+
});
|
|
211
|
+
const result = await Promise.race([pairing, timeout]).finally(() => clearTimeout(timeoutId));
|
|
212
|
+
if (typeof result?.attachmentId === 'string')
|
|
213
|
+
attachmentId = result.attachmentId;
|
|
214
|
+
measureWireValue(result, { maxBytes: 16 * 1024, maxDepth: 16 });
|
|
215
|
+
if (disposed || !attachmentId || !/^[a-f0-9-]{36}$/.test(attachmentId) || !result || typeof result !== 'object' || Object.keys(result).some(key => !['attachmentId', 'sourceUrl', 'owner', 'scopes'].includes(key)) || result.sourceUrl !== source.url || !sameInspectionOwner(validateInspectionOwner(result.owner), owner) || !Array.isArray(result.scopes) || result.scopes.length > scopes.length || new Set(result.scopes).size !== result.scopes.length || result.scopes.some((scope) => !scopes.includes(scope)))
|
|
216
|
+
throw new Error('Session unavailable');
|
|
217
|
+
scopes = result.scopes;
|
|
218
|
+
if (result.scopes.includes('diagnostics')) {
|
|
219
|
+
if (!session.getSnapshot().inspection?.diagnostics?.available)
|
|
220
|
+
throw new Error('Diagnostics unavailable');
|
|
221
|
+
diagnostics = createDiagnosticReader(session, owner);
|
|
222
|
+
void diagnostics.closed.then(() => release()).catch(() => { });
|
|
223
|
+
await diagnostics.ready;
|
|
224
|
+
if (disposed)
|
|
225
|
+
throw new Error('Session unavailable');
|
|
226
|
+
}
|
|
227
|
+
timer = setInterval(() => {
|
|
228
|
+
void call(`${id}:heartbeat`, attachmentId).catch(() => {
|
|
229
|
+
void release().catch(() => { });
|
|
230
|
+
});
|
|
231
|
+
}, 5000);
|
|
232
|
+
return { attachment: result, dispose: release };
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
await release();
|
|
236
|
+
throw error;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HistoireInspectionOwner } from '@histoire/protocol';
|
|
2
|
+
import type { HistoireSession } from '@histoire/sdk';
|
|
3
|
+
/** Explicitly start one scoped SDK diagnostic observation for an attachment. */
|
|
4
|
+
export declare function createDiagnosticReader(session: Pick<HistoireSession, 'debug'>, owner: HistoireInspectionOwner): {
|
|
5
|
+
/** Resolves when observation ends, including a failed poll. */
|
|
6
|
+
closed: Promise<void>;
|
|
7
|
+
/** Resolves only when the runtime accepts the observation. */
|
|
8
|
+
ready: Promise<void>;
|
|
9
|
+
/** Read bounded, already-observed entries attributed to the captured owner. */
|
|
10
|
+
read(value: unknown): import("@histoire/protocol").HistoireInspectionResult;
|
|
11
|
+
/** Release the caller-owned observation without closing the SDK session. */
|
|
12
|
+
dispose: () => Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/client/diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAIpD,gFAAgF;AAChF,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,uBAAuB;IAS1G,+DAA+D;;IAE/D,8DAA8D;;IAE9D,+EAA+E;gBACnE,OAAO;IAQnB,4EAA4E;;EAG/E"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { sameInspectionOwner, validateInspectionResult } from '@histoire/protocol';
|
|
2
|
+
import { parseDiagnosticRequest } from '../shared/diagnostics.js';
|
|
3
|
+
/** Explicitly start one scoped SDK diagnostic observation for an attachment. */
|
|
4
|
+
export function createDiagnosticReader(session, owner) {
|
|
5
|
+
const observation = session.debug.subscribe(() => { });
|
|
6
|
+
let active = true;
|
|
7
|
+
const closed = observation.closed.then(() => {
|
|
8
|
+
active = false;
|
|
9
|
+
}, () => {
|
|
10
|
+
active = false;
|
|
11
|
+
});
|
|
12
|
+
return {
|
|
13
|
+
/** Resolves when observation ends, including a failed poll. */
|
|
14
|
+
closed,
|
|
15
|
+
/** Resolves only when the runtime accepts the observation. */
|
|
16
|
+
ready: observation.ready,
|
|
17
|
+
/** Read bounded, already-observed entries attributed to the captured owner. */
|
|
18
|
+
read(value) {
|
|
19
|
+
if (!active)
|
|
20
|
+
throw new Error('Diagnostic observation unavailable');
|
|
21
|
+
const input = parseDiagnosticRequest(value);
|
|
22
|
+
if (!sameInspectionOwner(input.expectedOwner, owner))
|
|
23
|
+
throw new Error('Diagnostic owner changed');
|
|
24
|
+
const page = session.debug.getSnapshot({ afterSequence: input.afterSequence, limit: input.limit });
|
|
25
|
+
const items = page.items.filter(item => item.owner && sameInspectionOwner(item.owner, owner));
|
|
26
|
+
return validateInspectionResult({ mode: 'live', inspection: 'debug', owner, observedAt: new Date().toISOString(), durationMs: 0, truncated: page.gap || page.droppedCount > 0, ...page, items });
|
|
27
|
+
},
|
|
28
|
+
/** Release the caller-owned observation without closing the SDK session. */
|
|
29
|
+
dispose: observation.unsubscribe,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HistoireInspectionOwner } from '@histoire/protocol';
|
|
2
|
+
import type { HistoireSession } from '@histoire/sdk';
|
|
3
|
+
import type { EventPage } from '../shared/events.js';
|
|
4
|
+
/** Project SDK-owned event history without starting diagnostics instrumentation. */
|
|
5
|
+
export declare function createEventReader(session: Pick<HistoireSession, 'getSnapshot' | 'subscribe'>, owner: HistoireInspectionOwner): {
|
|
6
|
+
/** Paginate only events attributed to the captured runtime and exact target. */
|
|
7
|
+
read(input: unknown): EventPage;
|
|
8
|
+
/** Stop only this reader's snapshot listener. */
|
|
9
|
+
dispose(): void;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/client/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAIpD,oFAAoF;AACpF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,aAAa,GAAG,WAAW,CAAC,EAAE,KAAK,EAAE,uBAAuB;IAUzH,gFAAgF;IAChF,IAAI,QAAQ,OAAO,GAAG,SAAS;IA8B/B,iDAAiD;IACjD,OAAO;EAEV"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { measureWireValue, sameInspectionOwner } from '@histoire/protocol';
|
|
2
|
+
import { parseEventRequest, validateEventPage } from '../shared/events.js';
|
|
3
|
+
/** Project SDK-owned event history without starting diagnostics instrumentation. */
|
|
4
|
+
export function createEventReader(session, owner) {
|
|
5
|
+
let eventLifetime = crypto.randomUUID();
|
|
6
|
+
let previous = session.getSnapshot().events;
|
|
7
|
+
/** Clearing history or resetting loss accounting invalidates previous cursors. */
|
|
8
|
+
const unsubscribe = session.subscribe((snapshot) => {
|
|
9
|
+
const next = snapshot.events;
|
|
10
|
+
if ((previous.items.length > 0 && next.items.length === 0) || next.droppedCount < previous.droppedCount)
|
|
11
|
+
eventLifetime = crypto.randomUUID();
|
|
12
|
+
previous = next;
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
/** Paginate only events attributed to the captured runtime and exact target. */
|
|
16
|
+
read(input) {
|
|
17
|
+
const request = parseEventRequest(input);
|
|
18
|
+
if (!sameInspectionOwner(request.expectedOwner, owner))
|
|
19
|
+
throw new Error('Event lifetime unavailable');
|
|
20
|
+
if (request.eventLifetime !== undefined && request.eventLifetime !== eventLifetime)
|
|
21
|
+
throw new Error('Event lifetime unavailable');
|
|
22
|
+
const snapshot = session.getSnapshot();
|
|
23
|
+
const after = request.afterSequence ?? 0;
|
|
24
|
+
const oldest = snapshot.events.items[0]?.sequence ?? null;
|
|
25
|
+
const matching = snapshot.events.items.filter(item => item.sequence > after && item.runtimeId === owner.runtimeId && item.target.storyId === owner.target.storyId && item.target.variantId === owner.target.variantId);
|
|
26
|
+
const page = { mode: 'live', owner: structuredClone(owner), eventLifetime, items: [], nextSequence: after, oldestSequence: oldest, droppedCount: snapshot.events.droppedCount, gap: snapshot.events.droppedCount > 0 && (after === 0 || (oldest !== null && after < oldest - 1)), truncated: false, omittedCount: 0 };
|
|
27
|
+
for (const item of matching) {
|
|
28
|
+
if (page.items.length >= (request.limit ?? 50)) {
|
|
29
|
+
page.truncated = true;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
const candidate = structuredClone(item);
|
|
33
|
+
try {
|
|
34
|
+
measureWireValue({ ...page, items: [...page.items, candidate], nextSequence: candidate.sequence }, { maxBytes: 60 * 1024, maxDepth: 32 });
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
page.truncated = true;
|
|
38
|
+
if (page.items.length)
|
|
39
|
+
break;
|
|
40
|
+
page.omittedCount++;
|
|
41
|
+
page.nextSequence = candidate.sequence;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
page.items.push(candidate);
|
|
45
|
+
page.nextSequence = candidate.sequence;
|
|
46
|
+
}
|
|
47
|
+
return validateEventPage(page, owner, request);
|
|
48
|
+
},
|
|
49
|
+
/** Stop only this reader's snapshot listener. */
|
|
50
|
+
dispose() { unsubscribe(); },
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HistoireHighlightLease, HistoireInspectionOwner } from '@histoire/protocol';
|
|
2
|
+
import type { HistoireSession } from '@histoire/sdk';
|
|
3
|
+
/** Retain exact leases until attachment retirement or natural overlay expiry. */
|
|
4
|
+
export declare function createHighlightOperations(session: Pick<HistoireSession, 'inspect'>, owner: HistoireInspectionOwner): {
|
|
5
|
+
/** Bound in-flight authority confirmations independently of SDK request concurrency. */
|
|
6
|
+
hasCapacity(pending: number): boolean;
|
|
7
|
+
/** Keep the runtime-issued identity private to this attachment. */
|
|
8
|
+
retain(id: string, lease: HistoireHighlightLease): void;
|
|
9
|
+
/** Clear only the captured lease; a newer overlay is never affected. */
|
|
10
|
+
finish(id: string, accepted: boolean, signal?: AbortSignal): Promise<void>;
|
|
11
|
+
/** Retire retained effects when attachment authority ends. */
|
|
12
|
+
dispose(): Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=highlight-operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlight-operations.d.ts","sourceRoot":"","sources":["../../src/client/highlight-operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AACzF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAEpD,iFAAiF;AACjF,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,uBAAuB;IAK/G,wFAAwF;IACxF,WAAW,UAAU,MAAM;IAC3B,mEAAmE;IACnE,MAAM,KAAK,MAAM,SAAS,sBAAsB;IAKhD,wEAAwE;IAClE,MAAM,KAAK,MAAM,YAAY,OAAO;IAkB1C,8DAA8D;IACxD,OAAO;EA4BhB"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/** Retain exact leases until attachment retirement or natural overlay expiry. */
|
|
2
|
+
export function createHighlightOperations(session, owner) {
|
|
3
|
+
let cleanupFailed = false;
|
|
4
|
+
const finishing = new Map();
|
|
5
|
+
const leases = new Map();
|
|
6
|
+
return {
|
|
7
|
+
/** Bound in-flight authority confirmations independently of SDK request concurrency. */
|
|
8
|
+
hasCapacity(pending) { return leases.size + pending <= 128; },
|
|
9
|
+
/** Keep the runtime-issued identity private to this attachment. */
|
|
10
|
+
retain(id, lease) {
|
|
11
|
+
if (leases.size >= 128 || leases.has(id))
|
|
12
|
+
throw new Error('Session unavailable');
|
|
13
|
+
const timer = setTimeout(() => leases.delete(id), 5500);
|
|
14
|
+
leases.set(id, { lease, timer });
|
|
15
|
+
},
|
|
16
|
+
/** Clear only the captured lease; a newer overlay is never affected. */
|
|
17
|
+
async finish(id, accepted, signal = AbortSignal.timeout(3000)) {
|
|
18
|
+
const existing = finishing.get(id);
|
|
19
|
+
if (existing)
|
|
20
|
+
return existing;
|
|
21
|
+
const entry = leases.get(id);
|
|
22
|
+
if (!entry || accepted)
|
|
23
|
+
return;
|
|
24
|
+
leases.delete(id);
|
|
25
|
+
clearTimeout(entry.timer);
|
|
26
|
+
const cleanup = session.inspect.clearHighlight({ target: owner.target, expectedOwner: owner, leaseId: entry.lease.leaseId, signal }).then(() => { });
|
|
27
|
+
finishing.set(id, cleanup);
|
|
28
|
+
try {
|
|
29
|
+
await cleanup;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
cleanupFailed = true;
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
finishing.delete(id);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
/** Retire retained effects when attachment authority ends. */
|
|
40
|
+
async dispose() {
|
|
41
|
+
const controller = new AbortController();
|
|
42
|
+
let timer;
|
|
43
|
+
const timeout = new Promise((_resolve, reject) => {
|
|
44
|
+
timer = setTimeout(() => {
|
|
45
|
+
controller.abort();
|
|
46
|
+
reject(new Error('Highlight cleanup incomplete'));
|
|
47
|
+
}, 3000);
|
|
48
|
+
});
|
|
49
|
+
const cleanup = async () => {
|
|
50
|
+
let failed = cleanupFailed;
|
|
51
|
+
// Prioritize recent leases without exhausting the SDK's request capacity.
|
|
52
|
+
for (const id of [...leases.keys()].reverse()) {
|
|
53
|
+
controller.signal.throwIfAborted();
|
|
54
|
+
try {
|
|
55
|
+
await this.finish(id, false, controller.signal);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
failed = true;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if ((await Promise.allSettled(finishing.values())).some(result => result.status === 'rejected'))
|
|
62
|
+
failed = true;
|
|
63
|
+
if (failed || cleanupFailed)
|
|
64
|
+
throw new Error('Highlight cleanup incomplete');
|
|
65
|
+
};
|
|
66
|
+
try {
|
|
67
|
+
await Promise.race([cleanup(), timeout]);
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
clearTimeout(timer);
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HistoireInspectionOwner } from '@histoire/protocol';
|
|
2
|
+
import type { HistoireSession } from '@histoire/sdk';
|
|
3
|
+
/** Dispatch finite reads against the caller-owned mounted session. */
|
|
4
|
+
export declare function createInspectionDispatcher(session: Pick<HistoireSession, 'inspect'>, expected: HistoireInspectionOwner): (value: unknown, signal: AbortSignal) => Promise<{
|
|
5
|
+
owner: HistoireInspectionOwner;
|
|
6
|
+
observedAt: string;
|
|
7
|
+
leaseId: string;
|
|
8
|
+
} | import("@histoire/protocol").HistoireInspectionResult>;
|
|
9
|
+
//# sourceMappingURL=inspection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspection.d.ts","sourceRoot":"","sources":["../../src/client/inspection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAGpD,sEAAsE;AACtE,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,EAAE,QAAQ,EAAE,uBAAuB,WAEhG,OAAO,UAAU,WAAW;WAaF,uBAAuB;gBAAc,MAAM;aAAW,MAAM;2DAS5G"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { measureWireValue, sameInspectionOwner, validateBridgeResult, validateInspectionInput, validateInspectionOwner, validateInspectionResult } from '@histoire/protocol';
|
|
2
|
+
/** Dispatch finite reads against the caller-owned mounted session. */
|
|
3
|
+
export function createInspectionDispatcher(session, expected) {
|
|
4
|
+
const owner = structuredClone(validateInspectionOwner(expected));
|
|
5
|
+
return async (value, signal) => {
|
|
6
|
+
measureWireValue(value, { maxBytes: 16 * 1024, maxDepth: 32 });
|
|
7
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
8
|
+
throw new Error('Invalid inspection request');
|
|
9
|
+
const { kind, ...options } = value;
|
|
10
|
+
if (typeof kind !== 'string' || !['variant', 'dom', 'components', 'component', 'componentForElement', 'accessibility', 'highlight'].includes(kind))
|
|
11
|
+
throw new Error('Invalid inspection request');
|
|
12
|
+
validateInspectionInput(kind, options);
|
|
13
|
+
const captured = validateInspectionOwner(options.expectedOwner);
|
|
14
|
+
if (!sameInspectionOwner(captured, owner) || !options.target || options.target.storyId !== owner.target.storyId || options.target.variantId !== owner.target.variantId)
|
|
15
|
+
throw new Error('Inspection owner changed');
|
|
16
|
+
signal.throwIfAborted();
|
|
17
|
+
const method = session.inspect[kind === 'highlight' ? 'highlightLease' : kind];
|
|
18
|
+
const result = await method({ ...options, signal });
|
|
19
|
+
if (kind === 'highlight') {
|
|
20
|
+
validateBridgeResult('inspection.highlightLease', result);
|
|
21
|
+
const acknowledgement = result;
|
|
22
|
+
if (!sameInspectionOwner(acknowledgement.owner, owner))
|
|
23
|
+
throw new Error('Inspection owner changed');
|
|
24
|
+
return structuredClone(acknowledgement);
|
|
25
|
+
}
|
|
26
|
+
signal.throwIfAborted();
|
|
27
|
+
const verified = validateInspectionResult(result);
|
|
28
|
+
if (verified.mode !== 'live' || verified.inspection !== kind || !sameInspectionOwner(verified.owner, owner))
|
|
29
|
+
throw new Error('Inspection owner changed');
|
|
30
|
+
return structuredClone(verified);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairing-budget.d.ts","sourceRoot":"","sources":["../../src/client/pairing-budget.ts"],"names":[],"mappings":"AAGA,+EAA+E;AAC/E,wBAAgB,YAAY,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,kBAAkB,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,CA6BxH"}
|