@fungi.computer/oyster 0.8.1 → 0.9.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 +21 -17
- package/dist/agents.d.ts +0 -8
- package/dist/agents.js +24 -15
- package/dist/apps/catalog.d.ts +11 -0
- package/dist/apps/catalog.js +1 -0
- package/dist/apps/gate.d.ts +2 -2
- package/dist/apps/installation.d.ts +7 -7
- package/dist/apps/permissions.d.ts +5 -5
- package/dist/boot-host-script.js +1 -1
- package/dist/build/candidate-cli.mjs +1 -0
- package/dist/host.d.ts +4 -1
- package/dist/host.js +20 -4
- package/dist/installation-client.d.ts +6 -5
- package/dist/installation-client.js +21 -17
- package/dist/installation-execution.js +41 -8
- package/dist/installation-operations.d.ts +30 -8
- package/dist/installation-operations.js +122 -24
- package/dist/instance-refusal.d.ts +4 -2
- package/dist/instance-refusal.js +5 -1
- package/dist/mcp.d.ts +4 -2
- package/dist/page/mount.d.ts +8 -1
- package/dist/page/mount.js +72 -6
- package/dist/page-script.js +3 -3
- package/dist/standalone/app-set.js +6 -7
- package/dist/standalone/computer-fleet.d.ts +8 -2
- package/dist/standalone/computer-fleet.js +21 -17
- package/dist/standalone/registry.js +9 -0
- package/dist/standalone/workflow-host.d.ts +5 -5
- package/dist/standalone/workflow-trigger-host.d.ts +1 -1
- package/docs/api/apps.md +31 -31
- package/docs/api/host.md +158 -1
- package/docs/api/mcp.md +6 -4
- package/docs/api/page/mount.md +6 -1
- package/docs/api/workers.md +3 -3
- package/docs/site/agent-quickstart.mdx +4 -2
- package/package.json +17 -17
|
@@ -7,6 +7,7 @@ import { hostActorSchema } from "@fungi.computer/puffball/app-method-runtime";
|
|
|
7
7
|
import { installationIdSchema, installationSchema, isCommittedInstallation, ownerCodec, } from "./apps/installation.js";
|
|
8
8
|
import { instanceIds, instanceIdSchema } from "./instance-id.js";
|
|
9
9
|
import { tenantIdSchema, tenantScope } from "./tenant.js";
|
|
10
|
+
import { failureDiagnostic } from "./cause-class.js";
|
|
10
11
|
import { uiBootCheckOutcomeSchema, } from "./boot-gate.js";
|
|
11
12
|
// Request identity has Watchdog's public job-key bound; it is not a retry cap.
|
|
12
13
|
export const installationRequestIdSchema = z.string().min(1).max(256);
|
|
@@ -132,6 +133,18 @@ const storedCommandSchema = z.union([
|
|
|
132
133
|
const inputDigest = (input) => createHash("sha256")
|
|
133
134
|
.update(JSON.stringify(installationAdmissionSchema.parse(input)))
|
|
134
135
|
.digest("hex");
|
|
136
|
+
/**
|
|
137
|
+
* One owner wait's bound, under ordinary HTTP idle timeouts; an observer that
|
|
138
|
+
* needs longer simply waits again.
|
|
139
|
+
*/
|
|
140
|
+
export const maxSettlementWaitMs = 25_000;
|
|
141
|
+
/** The status door's optional `waitMs` query: whole milliseconds, bounded. */
|
|
142
|
+
export const installationWaitQuerySchema = z
|
|
143
|
+
.string()
|
|
144
|
+
.regex(/^\d{1,5}$/u)
|
|
145
|
+
.transform(Number)
|
|
146
|
+
.pipe(z.number().int().max(maxSettlementWaitMs))
|
|
147
|
+
.optional();
|
|
135
148
|
const installationOperationRequestSchema = z.discriminatedUnion("action", [
|
|
136
149
|
z.strictObject({
|
|
137
150
|
action: z.literal("admit"),
|
|
@@ -144,6 +157,13 @@ const installationOperationRequestSchema = z.discriminatedUnion("action", [
|
|
|
144
157
|
requestId: installationRequestIdSchema,
|
|
145
158
|
installationId: installationIdSchema,
|
|
146
159
|
}),
|
|
160
|
+
z.strictObject({
|
|
161
|
+
action: z.literal("await"),
|
|
162
|
+
scope: scopeSchema,
|
|
163
|
+
requestId: installationRequestIdSchema,
|
|
164
|
+
installationId: installationIdSchema,
|
|
165
|
+
waitMs: z.number().int().min(0).max(maxSettlementWaitMs),
|
|
166
|
+
}),
|
|
147
167
|
z.strictObject({
|
|
148
168
|
action: z.literal("load"),
|
|
149
169
|
scope: scopeSchema,
|
|
@@ -228,6 +248,18 @@ export function installationOperationsPort(send, scope) {
|
|
|
228
248
|
throw new InstallationOperationError("unavailable");
|
|
229
249
|
return reply.operation;
|
|
230
250
|
},
|
|
251
|
+
async awaitSettled(requestId, installationId, waitMs) {
|
|
252
|
+
const reply = await call({
|
|
253
|
+
action: "await",
|
|
254
|
+
scope,
|
|
255
|
+
requestId,
|
|
256
|
+
installationId,
|
|
257
|
+
waitMs,
|
|
258
|
+
});
|
|
259
|
+
if (reply.kind !== "operation")
|
|
260
|
+
throw new InstallationOperationError("unavailable");
|
|
261
|
+
return reply.operation;
|
|
262
|
+
},
|
|
231
263
|
async load(requestId) {
|
|
232
264
|
const reply = await call({ action: "load", scope, requestId });
|
|
233
265
|
if (reply.kind !== "command")
|
|
@@ -403,6 +435,19 @@ export async function createInstallationOperations(ports) {
|
|
|
403
435
|
? null
|
|
404
436
|
: readStored(installationOutcomeSchema, encoded);
|
|
405
437
|
};
|
|
438
|
+
// Callers waiting for one command to leave pending (or to be admitted). The
|
|
439
|
+
// settlement is projected inside Watchdog's transaction, so waiters are woken
|
|
440
|
+
// only after the tick that ran it has returned, and re-read committed state.
|
|
441
|
+
const waiters = new Map();
|
|
442
|
+
const settledInTick = new Set();
|
|
443
|
+
const wake = (requestId) => {
|
|
444
|
+
const waiting = waiters.get(requestId);
|
|
445
|
+
if (waiting === undefined)
|
|
446
|
+
return;
|
|
447
|
+
waiters.delete(requestId);
|
|
448
|
+
for (const resume of waiting)
|
|
449
|
+
resume();
|
|
450
|
+
};
|
|
406
451
|
const watchdog = await Watchdog.make({
|
|
407
452
|
owner,
|
|
408
453
|
isAlive: () => Promise.resolve(false),
|
|
@@ -420,15 +465,23 @@ export async function createInstallationOperations(ports) {
|
|
|
420
465
|
ports.generation() === command.generation &&
|
|
421
466
|
same(ports.get(command.installationId), proposed.installation)) ||
|
|
422
467
|
(proposed?.state === "refused" && settled.outcome === "failed");
|
|
468
|
+
const stopped = settled.outcome === "interrupted" || settled.outcome === "cancelled";
|
|
469
|
+
// The commit marks the plan prepared in this owner before its
|
|
470
|
+
// compare-and-put, and a settled command can never commit later. An
|
|
471
|
+
// unprepared plan whose target is not the current row therefore proves
|
|
472
|
+
// this request changed nothing: the previous release is still selected.
|
|
473
|
+
const neverCommitted = !stopped &&
|
|
474
|
+
command.plan?.prepared !== true &&
|
|
475
|
+
(command.plan === null ||
|
|
476
|
+
!same(ports.get(command.installationId), command.plan.installation));
|
|
423
477
|
const result = definitive
|
|
424
478
|
? proposed
|
|
425
|
-
:
|
|
426
|
-
state: "
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
? settled.outcome
|
|
430
|
-
|
|
431
|
-
};
|
|
479
|
+
: neverCommitted
|
|
480
|
+
? { state: "refused", status: 503, code: "installation_not_applied" }
|
|
481
|
+
: {
|
|
482
|
+
state: "unconfirmed",
|
|
483
|
+
outcome: stopped ? settled.outcome : "outcome_unknown",
|
|
484
|
+
};
|
|
432
485
|
const operation = terminalOperationSchema.parse(result.state === "succeeded"
|
|
433
486
|
? {
|
|
434
487
|
...command.operation,
|
|
@@ -453,6 +506,7 @@ export async function createInstallationOperations(ports) {
|
|
|
453
506
|
operation,
|
|
454
507
|
});
|
|
455
508
|
owner.sql.exec("UPDATE installation_commands SET provisional_outcome=NULL WHERE request_id=?", payload);
|
|
509
|
+
settledInTick.add(payload);
|
|
456
510
|
},
|
|
457
511
|
execute: async (job) => {
|
|
458
512
|
const command = load(installationRequestIdSchema.parse(job.payload));
|
|
@@ -460,7 +514,19 @@ export async function createInstallationOperations(ports) {
|
|
|
460
514
|
return { kind: "outcome_unknown" };
|
|
461
515
|
// Persist the wake handoff before awaiting work in another execution context.
|
|
462
516
|
await ports.scheduleWake(Date.now());
|
|
463
|
-
|
|
517
|
+
let executed;
|
|
518
|
+
try {
|
|
519
|
+
executed = await ports.execute(command);
|
|
520
|
+
}
|
|
521
|
+
catch (cause) {
|
|
522
|
+
// Watchdog keeps only a closed failure reason; keep the cause here.
|
|
523
|
+
console.error("Installation execution failed", {
|
|
524
|
+
requestId: command.admission.requestId,
|
|
525
|
+
...failureDiagnostic(cause),
|
|
526
|
+
});
|
|
527
|
+
throw cause;
|
|
528
|
+
}
|
|
529
|
+
const result = installationOutcomeSchema.parse(executed);
|
|
464
530
|
const latest = load(command.admission.requestId);
|
|
465
531
|
if (latest === null || !("admission" in latest))
|
|
466
532
|
throw new InstallationOperationError("stale_authority");
|
|
@@ -489,6 +555,16 @@ export async function createInstallationOperations(ports) {
|
|
|
489
555
|
throw new InstallationOperationError("stale_authority");
|
|
490
556
|
return command;
|
|
491
557
|
};
|
|
558
|
+
/** The caller's operation, when it names this installation in its scope. */
|
|
559
|
+
const observed = (request) => {
|
|
560
|
+
const command = load(request.requestId);
|
|
561
|
+
return command !== null &&
|
|
562
|
+
same(command.scope, request.scope) &&
|
|
563
|
+
(command.operation.installationId === request.installationId ||
|
|
564
|
+
command.operation.requestedInstallationId === request.installationId)
|
|
565
|
+
? operationOf(command)
|
|
566
|
+
: null;
|
|
567
|
+
};
|
|
492
568
|
const dispatch = async (raw) => {
|
|
493
569
|
const request = installationOperationRequestSchema.parse(raw);
|
|
494
570
|
const scope = tenantScope(request.scope.tenantId, request.scope.origin);
|
|
@@ -501,7 +577,7 @@ export async function createInstallationOperations(ports) {
|
|
|
501
577
|
// An orphan wake is harmless; an accepted row with no wake is not.
|
|
502
578
|
// No external await separates this persisted wake from atomic admission.
|
|
503
579
|
await ports.scheduleWake(Date.now());
|
|
504
|
-
|
|
580
|
+
const admitted = owner.transactionSync(() => {
|
|
505
581
|
const prior = load(request.input.requestId);
|
|
506
582
|
if (prior !== null) {
|
|
507
583
|
if (("admission" in prior
|
|
@@ -560,24 +636,41 @@ export async function createInstallationOperations(ports) {
|
|
|
560
636
|
});
|
|
561
637
|
return { kind: "operation", operation };
|
|
562
638
|
});
|
|
639
|
+
// A waiter whose admission acknowledgement was lost learns of it now.
|
|
640
|
+
wake(request.input.requestId);
|
|
641
|
+
return admitted;
|
|
563
642
|
}
|
|
564
|
-
if (request.action === "
|
|
643
|
+
if (request.action === "load") {
|
|
565
644
|
const command = load(request.requestId);
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
645
|
+
return {
|
|
646
|
+
kind: "command",
|
|
647
|
+
command: command !== null &&
|
|
648
|
+
same(command.scope, request.scope) &&
|
|
649
|
+
"admission" in command
|
|
650
|
+
? command
|
|
651
|
+
: null,
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
if (request.action === "read")
|
|
655
|
+
return { kind: "operation", operation: observed(request) };
|
|
656
|
+
if (request.action === "await") {
|
|
657
|
+
const current = observed(request);
|
|
658
|
+
if (current !== null && current.state !== "pending")
|
|
659
|
+
return { kind: "operation", operation: current };
|
|
660
|
+
await new Promise((resolve) => {
|
|
661
|
+
const waiting = waiters.get(request.requestId) ?? new Set();
|
|
662
|
+
const resume = () => {
|
|
663
|
+
clearTimeout(timer);
|
|
664
|
+
waiting.delete(resume);
|
|
665
|
+
if (waiting.size === 0 && waiters.get(request.requestId) === waiting)
|
|
666
|
+
waiters.delete(request.requestId);
|
|
667
|
+
resolve();
|
|
580
668
|
};
|
|
669
|
+
const timer = setTimeout(resume, request.waitMs);
|
|
670
|
+
waiting.add(resume);
|
|
671
|
+
waiters.set(request.requestId, waiting);
|
|
672
|
+
});
|
|
673
|
+
return { kind: "operation", operation: observed(request) };
|
|
581
674
|
}
|
|
582
675
|
const command = requireCommand(request.requestId, request.scope);
|
|
583
676
|
if (request.action === "plan") {
|
|
@@ -647,6 +740,11 @@ export async function createInstallationOperations(ports) {
|
|
|
647
740
|
return await watchdog.tick();
|
|
648
741
|
}
|
|
649
742
|
finally {
|
|
743
|
+
// After the tick, never inside its transaction. A rolled-back
|
|
744
|
+
// settlement wakes a waiter that re-reads pending and waits again.
|
|
745
|
+
for (const requestId of settledInTick)
|
|
746
|
+
wake(requestId);
|
|
747
|
+
settledInTick.clear();
|
|
650
748
|
if (await watchdog.hasPendingWork())
|
|
651
749
|
await ports.scheduleWake(Date.now());
|
|
652
750
|
else {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { AppInstanceErrorCode } from "./index.js";
|
|
2
2
|
/** The retained HTTP meaning of a known Instance refusal, never generic failed. */
|
|
3
3
|
export declare function instanceRefusalStatus(code: AppInstanceErrorCode): number;
|
|
4
|
-
/**
|
|
4
|
+
/** The host-authored settlement for an installation that changed nothing. */
|
|
5
|
+
export declare const installationNotAppliedMessage = "The new release was not applied: Oyster could not prepare it. The previous release is still installed; install again to retry.";
|
|
6
|
+
/** Only closed host-authored reasons produce a caller-facing message. */
|
|
5
7
|
export declare function instanceRefusalBody(code: string): {
|
|
6
|
-
error:
|
|
8
|
+
error: string;
|
|
7
9
|
message: string;
|
|
8
10
|
} | {
|
|
9
11
|
error: string;
|
package/dist/instance-refusal.js
CHANGED
|
@@ -12,8 +12,12 @@ export function instanceRefusalStatus(code) {
|
|
|
12
12
|
return 422;
|
|
13
13
|
return conflicts.has(code) ? 409 : 403;
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
15
|
+
/** The host-authored settlement for an installation that changed nothing. */
|
|
16
|
+
export const installationNotAppliedMessage = "The new release was not applied: Oyster could not prepare it. The previous release is still installed; install again to retry.";
|
|
17
|
+
/** Only closed host-authored reasons produce a caller-facing message. */
|
|
16
18
|
export function instanceRefusalBody(code) {
|
|
19
|
+
if (code === "installation_not_applied")
|
|
20
|
+
return { error: code, message: installationNotAppliedMessage };
|
|
17
21
|
const boot = bootFailureSchema.safeParse(code);
|
|
18
22
|
return boot.success
|
|
19
23
|
? { error: boot.data, message: new BootGateError(boot.data).message }
|
package/dist/mcp.d.ts
CHANGED
|
@@ -83,6 +83,7 @@ export declare function computerControlSpecs(port: ComputerControlPort): {
|
|
|
83
83
|
running: "running";
|
|
84
84
|
sleeping: "sleeping";
|
|
85
85
|
starting: "starting";
|
|
86
|
+
start_failed: "start_failed";
|
|
86
87
|
}>;
|
|
87
88
|
}, z.core.$strict>, z.ZodObject<{
|
|
88
89
|
state: z.ZodLiteral<"queued">;
|
|
@@ -90,7 +91,7 @@ export declare function computerControlSpecs(port: ComputerControlPort): {
|
|
|
90
91
|
}, z.core.$strict>], "state">;
|
|
91
92
|
/** Return liveness without waking the runtime. */
|
|
92
93
|
execute: (input: z.output<typeof fleetComputerId>, context: InvocationContext) => Promise<{
|
|
93
|
-
state: "running" | "sleeping" | "starting";
|
|
94
|
+
state: "running" | "sleeping" | "starting" | "start_failed";
|
|
94
95
|
} | {
|
|
95
96
|
state: "queued";
|
|
96
97
|
position: number;
|
|
@@ -107,6 +108,7 @@ export declare function computerControlSpecs(port: ComputerControlPort): {
|
|
|
107
108
|
running: "running";
|
|
108
109
|
sleeping: "sleeping";
|
|
109
110
|
starting: "starting";
|
|
111
|
+
start_failed: "start_failed";
|
|
110
112
|
}>;
|
|
111
113
|
}, z.core.$strict>, z.ZodObject<{
|
|
112
114
|
state: z.ZodLiteral<"queued">;
|
|
@@ -114,7 +116,7 @@ export declare function computerControlSpecs(port: ComputerControlPort): {
|
|
|
114
116
|
}, z.core.$strict>], "state">;
|
|
115
117
|
/** Admit and start this Computer. */
|
|
116
118
|
execute: (input: z.output<typeof fleetComputerId>, context: InvocationContext) => Promise<{
|
|
117
|
-
state: "running" | "sleeping" | "starting";
|
|
119
|
+
state: "running" | "sleeping" | "starting" | "start_failed";
|
|
118
120
|
} | {
|
|
119
121
|
state: "queued";
|
|
120
122
|
position: number;
|
package/dist/page/mount.d.ts
CHANGED
|
@@ -160,7 +160,14 @@ export type OysterAppConnectionOptions = Readonly<{
|
|
|
160
160
|
reservedChords: readonly import("@fungi.computer/agar/host").AppHostReservedChord[];
|
|
161
161
|
theme: string;
|
|
162
162
|
}>;
|
|
163
|
-
/**
|
|
163
|
+
/**
|
|
164
|
+
* Connect a child or home App using the same admitted Oyster slot handles.
|
|
165
|
+
* The host navigates the App's frame (`config.uiUrl`) only once it listens for
|
|
166
|
+
* the App's ready signal, so slow capability resolution on a cold Oyster can
|
|
167
|
+
* never outlast that signal. Opening is bounded: the capabilities and the
|
|
168
|
+
* document get the shared cold-document budget, and the handshake after the
|
|
169
|
+
* document loads gets the App's own ready window.
|
|
170
|
+
*/
|
|
164
171
|
export declare function connectOysterApp(options: OysterAppConnectionOptions): Promise<AppHost>;
|
|
165
172
|
export { oysterStorageHandle } from "./storage.js";
|
|
166
173
|
export { appSandbox } from "../app-sandbox.js";
|
package/dist/page/mount.js
CHANGED
|
@@ -2,6 +2,7 @@ import { appOpenInputSchema, appsCall, appsOpen, } from "@fungi.computer/agar/ap
|
|
|
2
2
|
import { appApiMethodNameSchema } from "@fungi.computer/puffball/app";
|
|
3
3
|
import { appIdSchema } from "@fungi.computer/puffball/effect";
|
|
4
4
|
import { createBrowserActionHandler } from "@fungi.computer/nacre";
|
|
5
|
+
import { APP_SURFACE_DOCUMENT_TIMEOUT_MS } from "@fungi.computer/nacre/window-manager";
|
|
5
6
|
import { createAppSurfaceCommandHost } from "@fungi.computer/nacre/command-host";
|
|
6
7
|
// App page: mounts one installed App's sandboxed frame and gives it the
|
|
7
8
|
// capabilities this Oyster host provides. Bundled into `shellScript`.
|
|
@@ -251,20 +252,83 @@ export async function mountOysterPage() {
|
|
|
251
252
|
},
|
|
252
253
|
});
|
|
253
254
|
}
|
|
254
|
-
/**
|
|
255
|
+
/** The App's own ready window: once its document loads, it announces itself for 10 s. */
|
|
256
|
+
const APP_CONNECT_TIMEOUT_MS = 10_000;
|
|
257
|
+
/** Resolve `work`, or reject with the signal's reason once it aborts. */
|
|
258
|
+
function untilAborted(work, signal) {
|
|
259
|
+
const stopped = () => signal.reason instanceof Error
|
|
260
|
+
? signal.reason
|
|
261
|
+
: new Error("App open was stopped", { cause: signal.reason });
|
|
262
|
+
if (signal.aborted)
|
|
263
|
+
return Promise.reject(stopped());
|
|
264
|
+
return new Promise((resolve, reject) => {
|
|
265
|
+
const stop = () => {
|
|
266
|
+
reject(stopped());
|
|
267
|
+
};
|
|
268
|
+
signal.addEventListener("abort", stop, { once: true });
|
|
269
|
+
work.then((value) => {
|
|
270
|
+
signal.removeEventListener("abort", stop);
|
|
271
|
+
resolve(value);
|
|
272
|
+
}, (cause) => {
|
|
273
|
+
signal.removeEventListener("abort", stop);
|
|
274
|
+
reject(cause instanceof Error
|
|
275
|
+
? cause
|
|
276
|
+
: new Error("App open failed", { cause }));
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Connect a child or home App using the same admitted Oyster slot handles.
|
|
282
|
+
* The host navigates the App's frame (`config.uiUrl`) only once it listens for
|
|
283
|
+
* the App's ready signal, so slow capability resolution on a cold Oyster can
|
|
284
|
+
* never outlast that signal. Opening is bounded: the capabilities and the
|
|
285
|
+
* document get the shared cold-document budget, and the handshake after the
|
|
286
|
+
* document loads gets the App's own ready window.
|
|
287
|
+
*/
|
|
255
288
|
export async function connectOysterApp(options) {
|
|
256
289
|
const { config, frame } = options;
|
|
257
290
|
if (frame.contentWindow === null)
|
|
258
291
|
throw new Error("App frame is unavailable");
|
|
259
|
-
const
|
|
292
|
+
const deadline = new AbortController();
|
|
293
|
+
const expire = () => {
|
|
294
|
+
deadline.abort();
|
|
295
|
+
};
|
|
296
|
+
let timer = setTimeout(expire, APP_SURFACE_DOCUMENT_TIMEOUT_MS);
|
|
297
|
+
const opening = AbortSignal.any([options.signal, deadline.signal]);
|
|
298
|
+
const documentLoaded = () => {
|
|
299
|
+
clearTimeout(timer);
|
|
300
|
+
timer = setTimeout(expire, APP_CONNECT_TIMEOUT_MS);
|
|
301
|
+
};
|
|
302
|
+
try {
|
|
303
|
+
return await openOysterApp(options, frame.contentWindow, opening, () => {
|
|
304
|
+
frame.addEventListener("load", documentLoaded, { once: true });
|
|
305
|
+
frame.src = config.uiUrl;
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
catch (cause) {
|
|
309
|
+
if (deadline.signal.aborted && !options.signal.aborted)
|
|
310
|
+
throw new AppError("App did not open in time", {
|
|
311
|
+
code: "TIMEOUT",
|
|
312
|
+
retryable: true,
|
|
313
|
+
});
|
|
314
|
+
throw cause;
|
|
315
|
+
}
|
|
316
|
+
finally {
|
|
317
|
+
clearTimeout(timer);
|
|
318
|
+
frame.removeEventListener("load", documentLoaded);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
async function openOysterApp(options, appWindow, opening, navigate) {
|
|
322
|
+
const { config, frame } = options;
|
|
323
|
+
const capabilities = await untilAborted(oysterAppCapabilities(options), opening);
|
|
260
324
|
const agents = agentDirectory(capabilities);
|
|
261
325
|
const releaseBrowser = options.agentBrowser.mount(frame, options.agentCommands);
|
|
262
326
|
options.signal.addEventListener("abort", releaseBrowser, { once: true });
|
|
263
|
-
const
|
|
264
|
-
appWindow
|
|
327
|
+
const connecting = connectAppHost({
|
|
328
|
+
appWindow,
|
|
265
329
|
expectedAppOrigin: "null",
|
|
266
330
|
hostWindow: window,
|
|
267
|
-
signal:
|
|
331
|
+
signal: opening,
|
|
268
332
|
launch: {
|
|
269
333
|
identity: {
|
|
270
334
|
appId: config.appId,
|
|
@@ -301,7 +365,9 @@ export async function connectOysterApp(options) {
|
|
|
301
365
|
signal: options.signal,
|
|
302
366
|
}),
|
|
303
367
|
},
|
|
304
|
-
})
|
|
368
|
+
});
|
|
369
|
+
navigate();
|
|
370
|
+
const host = await connecting.catch((cause) => {
|
|
305
371
|
releaseBrowser();
|
|
306
372
|
throw cause;
|
|
307
373
|
});
|