apps 0.0.1-beta.14 → 0.0.1-beta.140
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 +60 -42
- package/framework-reference.json +1 -1
- package/js/{chunk-M3B3DE4K.js → chunk-2XDCAXAR.js} +612 -246
- package/js/{chunk-IPI4MFSN.js → chunk-34RH47V5.js} +2 -2
- package/js/chunk-5JBDHSLK.js +449 -0
- package/js/{chunk-KUMBKVJD.js → chunk-6QZVXLF2.js} +2 -2
- package/js/chunk-7MPPHKRW.js +5418 -0
- package/js/chunk-DQ6FIDC3.js +335 -0
- package/js/{chunk-5T57N25Q.js → chunk-EKXBHVMR.js} +697 -70
- package/js/chunk-EYZHR4UA.js +1945 -0
- package/js/chunk-GJG5G6CH.js +1022 -0
- package/js/chunk-H2K7OZ47.js +90 -0
- package/js/chunk-I6QAWNUM.js +161 -0
- package/js/{chunk-ODEIDRGW.js → chunk-JH3MOQZR.js} +1166 -504
- package/js/{chunk-QS6CAHKC.js → chunk-JHAHT26O.js} +4 -3
- package/js/{chunk-RFVIONFX.js → chunk-JIXIOWZP.js} +136 -45
- package/js/chunk-LSOHA2RH.js +88 -0
- package/js/{chunk-UK573G7W.js → chunk-MB6L5YZE.js} +1817 -632
- package/js/chunk-OBT33ZDK.js +95 -0
- package/js/{chunk-JU7VHODU.js → chunk-QTX7OUFH.js} +65 -10
- package/js/chunk-RBSXSRPU.js +175 -0
- package/js/chunk-SB2DNKDL.js +593 -0
- package/js/{chunk-VFZKSM3T.js → chunk-VX36SA7Y.js} +3 -3
- package/js/chunk-YF7TYPDS.js +49 -0
- package/js/{chunk-CDL5PM2Q.js → chunk-YFSOSNF3.js} +17265 -12477
- package/js/{chunk-IJX4CYZO.js → chunk-YVN2AMAU.js} +976 -447
- package/js/chunk-Z6DSU4VL.js +724 -0
- package/js/client.js +333 -98
- package/js/contracts.js +154 -21
- package/js/effect.js +18 -19
- package/js/graphql.js +231 -188
- package/js/host.js +138 -80
- package/js/index.js +153 -300
- package/js/mcp/effect.js +21 -21
- package/js/mcp.js +91 -57
- package/js/openapi.js +4950 -4201
- package/js/react.js +2 -3
- package/js/skills/effect.js +6 -3
- package/js/skills.js +220 -81
- package/js/storage/facet.js +1 -540
- package/js/ui/auth/contracts.js +2 -2
- package/js/ui/auth.js +5 -5
- package/js/ui/contracts.js +9 -8
- package/js/ui/serving.js +8618 -235
- package/package.json +3 -8
- package/runtime.json +1 -1
- package/types/app-cache/src/contracts/cache.d.ts +18 -0
- package/types/app-cache/src/index.d.ts +34 -2
- package/types/apps/src/contracts/api-response-error.d.ts +4 -0
- package/types/apps/src/contracts/app.d.ts +56 -11
- package/types/apps/src/contracts/cache.d.ts +20 -0
- package/types/apps/src/contracts/context.d.ts +60 -17
- package/types/apps/src/contracts/elicitation.d.ts +23 -7
- package/types/apps/src/contracts/events.d.ts +94 -0
- package/types/apps/src/contracts/failure.d.ts +30 -1
- package/types/apps/src/contracts/graphql.d.ts +40 -2
- package/types/apps/src/contracts/help-text.d.ts +31 -0
- package/types/apps/src/contracts/host.d.ts +1493 -20
- package/types/apps/src/contracts/icons.d.ts +28 -0
- package/types/apps/src/contracts/live.d.ts +2 -0
- package/types/apps/src/contracts/mcp.d.ts +81 -20
- package/types/apps/src/contracts/network.d.ts +120 -0
- package/types/apps/src/contracts/openapi-compile.d.ts +82 -3
- package/types/apps/src/contracts/openapi-document.d.ts +1 -1
- package/types/apps/src/contracts/openapi.d.ts +47 -8
- package/types/apps/src/contracts/operations.d.ts +14 -7
- package/types/apps/src/contracts/placement.d.ts +102 -0
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/1.d.ts +513 -15
- package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
- package/types/apps/src/contracts/protocols/11.d.ts +1149 -0
- package/types/apps/src/contracts/protocols/12.d.ts +3310 -0
- package/types/apps/src/contracts/protocols/13.d.ts +6001 -0
- package/types/apps/src/contracts/protocols/2.d.ts +9 -8
- package/types/apps/src/contracts/protocols/3.d.ts +73 -15
- package/types/apps/src/contracts/protocols/4.d.ts +22 -15
- package/types/apps/src/contracts/protocols/5.d.ts +37 -11
- package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
- package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
- package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
- package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
- package/types/apps/src/contracts/protocols/current.d.ts +7114 -0
- package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
- package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
- package/types/apps/src/contracts/provider-error.d.ts +9 -0
- package/types/apps/src/contracts/provider.d.ts +56 -0
- package/types/apps/src/contracts/router.d.ts +2 -1
- package/types/apps/src/contracts/schedules.d.ts +7 -1
- package/types/apps/src/contracts/schema.d.ts +21 -0
- package/types/apps/src/contracts/shared-catalog.d.ts +11 -0
- package/types/apps/src/contracts/skills.d.ts +50 -13
- package/types/apps/src/contracts/sql.d.ts +63 -0
- package/types/apps/src/contracts/ui.d.ts +70 -30
- package/types/apps/src/contracts/webhooks.d.ts +24 -7
- package/types/apps/src/contracts/workflows.d.ts +56 -34
- package/types/apps/src/facet.d.ts +4 -5
- package/types/apps/src/host.d.ts +5 -0
- package/types/apps/src/implementation/account-router.d.ts +20 -3
- package/types/apps/src/implementation/app.d.ts +41 -14
- package/types/apps/src/implementation/authoring.d.ts +25 -5
- package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
- package/types/apps/src/implementation/cache.d.ts +29 -2
- package/types/apps/src/implementation/catalog-cache.d.ts +35 -4
- package/types/apps/src/implementation/elicitation.d.ts +16 -13
- package/types/apps/src/implementation/events.d.ts +64 -0
- package/types/apps/src/implementation/failure-detail.d.ts +28 -5
- package/types/apps/src/implementation/graphql-catalog.d.ts +3 -3
- package/types/apps/src/implementation/graphql.d.ts +4 -3
- package/types/apps/src/implementation/help-text.d.ts +5 -0
- package/types/apps/src/implementation/input-problems.d.ts +6 -2
- package/types/apps/src/implementation/invocation-timing.d.ts +18 -0
- package/types/apps/src/implementation/live.d.ts +2 -2
- package/types/apps/src/implementation/mcp-call.d.ts +6 -5
- package/types/apps/src/implementation/mcp-catalog.d.ts +6 -4
- package/types/apps/src/implementation/mcp-client.d.ts +17 -9
- package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
- package/types/apps/src/implementation/mcp.d.ts +20 -9
- package/types/apps/src/implementation/network.d.ts +16 -0
- package/types/apps/src/implementation/openapi-compile.d.ts +33 -5
- package/types/apps/src/implementation/openapi-document.d.ts +35 -18
- package/types/apps/src/implementation/openapi-names.d.ts +9 -4
- package/types/apps/src/implementation/openapi-request.d.ts +2 -1
- package/types/apps/src/implementation/openapi-source.d.ts +23 -1
- package/types/apps/src/implementation/operations.d.ts +58 -7
- package/types/apps/src/implementation/optimistic.d.ts +1 -1
- package/types/apps/src/implementation/placement.d.ts +60 -0
- package/types/apps/src/implementation/protocol-operations.d.ts +3 -0
- package/types/apps/src/implementation/provider-error.d.ts +28 -1
- package/types/apps/src/implementation/provider.d.ts +20 -4
- package/types/apps/src/implementation/query-commit.d.ts +1 -1
- package/types/apps/src/implementation/router-catalog.d.ts +22 -97
- package/types/apps/src/implementation/router.d.ts +26 -6
- package/types/apps/src/implementation/schedules.d.ts +39 -8
- package/types/apps/src/implementation/schema.d.ts +148 -17
- package/types/apps/src/implementation/skills.d.ts +18 -24
- package/types/apps/src/implementation/sql.d.ts +71 -0
- package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
- package/types/apps/src/implementation/ui-auth.d.ts +1 -1
- package/types/apps/src/implementation/ui-client.d.ts +3 -3
- package/types/apps/src/implementation/ui-document.d.ts +5 -0
- package/types/apps/src/implementation/ui-errors.d.ts +1 -1
- package/types/apps/src/implementation/ui-serving.d.ts +38 -12
- package/types/apps/src/implementation/upstream-error.d.ts +17 -0
- package/types/apps/src/implementation/webhooks.d.ts +15 -6
- package/types/apps/src/implementation/workflow-context.d.ts +6 -2
- package/types/apps/src/implementation/workflows.d.ts +11 -4
- package/types/apps/src/index.d.ts +67 -17
- package/types/apps/src/mcp.d.ts +20 -1
- package/types/apps/src/openapi.d.ts +22 -1
- package/types/apps/src/react.d.ts +1 -1
- package/types/apps/src/skills.d.ts +10 -8
- package/types/apps/src/ui-serving.d.ts +1 -2
- package/types/telemetry/src/app-records.d.ts +42 -0
- package/types/telemetry/src/browser-operations.d.ts +2 -2
- package/types/telemetry/src/browser.d.ts +8 -3
- package/types/telemetry/src/config.d.ts +2 -2
- package/types/telemetry/src/index.d.ts +3 -2
- package/types/telemetry/src/keepalive.d.ts +53 -0
- package/types/telemetry/src/layer.d.ts +10 -4
- package/types/telemetry/src/measurements.d.ts +6 -2
- package/types/telemetry/src/ownership.d.ts +60 -0
- package/types/telemetry/src/recorded-failure.d.ts +29 -0
- package/types/telemetry/src/relay.d.ts +32 -7
- package/types/telemetry/src/span-attributes.d.ts +22 -3
- package/types/telemetry/src/transport.d.ts +10 -1
- package/types/utils/src/api-error.d.ts +55 -0
- package/types/utils/src/connection-failure.d.ts +33 -0
- package/types/utils/src/legacy-keys.d.ts +20 -0
- package/types/utils/src/random-uuid.d.ts +6 -0
- package/types/utils/src/recorded-message.d.ts +18 -0
- package/types/utils/src/schema-definitions.d.ts +13 -0
- package/types/utils/src/user-facing-error.d.ts +83 -0
- package/js/chunk-27F7W2LG.js +0 -34
- package/js/chunk-4ASNKGCV.js +0 -242
- package/js/chunk-4DWF4ZWI.js +0 -1280
- package/js/chunk-57RKNWL2.js +0 -75
- package/js/chunk-6HSH75OI.js +0 -2688
- package/js/chunk-G4FT53I7.js +0 -224
- package/js/chunk-MKWZPDR6.js +0 -63
- package/js/chunk-N7YDVXYJ.js +0 -186
- package/js/chunk-NKLWZJLE.js +0 -172
- package/js/chunk-PJJ24GU7.js +0 -877
- package/js/chunk-PZB6T6KU.js +0 -19
- package/js/chunk-R3EV5FTO.js +0 -97
- package/js/chunk-S73JGVR5.js +0 -507
- package/js/chunk-TG6DOCRO.js +0 -299
- package/js/chunk-YPKG2QO5.js +0 -209
- package/js/chunk-ZQINWV4W.js +0 -630
- package/js/mcp/stdio.js +0 -128
- package/types/app-data/src/implementation/cursor.d.ts +0 -10
- package/types/app-data/src/implementation/index-key.d.ts +0 -7
- package/types/app-data/src/implementation/promise.d.ts +0 -68
- package/types/app-data/src/implementation/range.d.ts +0 -8
- package/types/app-data/src/implementation/schema.d.ts +0 -18
- package/types/app-data/src/implementation/sqlite.d.ts +0 -11
- package/types/app-data/src/index.d.ts +0 -4
- package/types/apps/src/contracts/storage.d.ts +0 -68
- package/types/apps/src/implementation/mcp-stdio.d.ts +0 -4
- package/types/apps/src/implementation/storage.d.ts +0 -15
- package/types/apps/src/implementation/ui-watch.d.ts +0 -2
- package/types/apps/src/mcp-stdio.d.ts +0 -5
package/js/client.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AppUiApi,
|
|
3
|
-
HttpApiClient_exports,
|
|
4
3
|
UiContext,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "./chunk-
|
|
4
|
+
UiFailed,
|
|
5
|
+
UiVersionChanged
|
|
6
|
+
} from "./chunk-OBT33ZDK.js";
|
|
8
7
|
import {
|
|
9
8
|
AsyncResult_exports,
|
|
10
9
|
AtomRegistry_exports,
|
|
11
10
|
Atom_exports,
|
|
12
11
|
queryResult
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import
|
|
12
|
+
} from "./chunk-2XDCAXAR.js";
|
|
13
|
+
import {
|
|
14
|
+
decoderOf
|
|
15
|
+
} from "./chunk-EKXBHVMR.js";
|
|
15
16
|
import {
|
|
16
17
|
OtlpExporter_exports,
|
|
18
|
+
TraceContext,
|
|
17
19
|
externalTrace,
|
|
18
20
|
pendingSpan,
|
|
19
21
|
telemetryLayer,
|
|
20
22
|
traceLinks
|
|
21
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-JH3MOQZR.js";
|
|
22
24
|
import {
|
|
23
25
|
FetchHttpClient_exports
|
|
24
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-I6QAWNUM.js";
|
|
27
|
+
import "./chunk-LSOHA2RH.js";
|
|
25
28
|
import {
|
|
26
|
-
|
|
27
|
-
} from "./chunk-
|
|
28
|
-
import {
|
|
29
|
-
decoderOf
|
|
30
|
-
} from "./chunk-5T57N25Q.js";
|
|
29
|
+
JsonValue
|
|
30
|
+
} from "./chunk-H2K7OZ47.js";
|
|
31
31
|
import {
|
|
32
|
-
|
|
33
|
-
} from "./chunk-
|
|
32
|
+
HttpApiClient_exports
|
|
33
|
+
} from "./chunk-YVN2AMAU.js";
|
|
34
34
|
import {
|
|
35
|
-
|
|
36
|
-
} from "./chunk-
|
|
35
|
+
HttpClientError_exports
|
|
36
|
+
} from "./chunk-MB6L5YZE.js";
|
|
37
37
|
import {
|
|
38
38
|
Cause_exports,
|
|
39
39
|
Clock_exports,
|
|
@@ -46,25 +46,27 @@ import {
|
|
|
46
46
|
Logger_exports,
|
|
47
47
|
ManagedRuntime_exports,
|
|
48
48
|
Option_exports,
|
|
49
|
+
Queue_exports,
|
|
49
50
|
Schedule_exports,
|
|
50
51
|
Schema_exports,
|
|
51
52
|
Semaphore_exports,
|
|
52
53
|
Stream_exports,
|
|
53
54
|
Tracer_exports
|
|
54
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-YFSOSNF3.js";
|
|
55
56
|
import "./chunk-CZ7CSFO4.js";
|
|
56
57
|
|
|
57
58
|
// src/contracts/live.ts
|
|
59
|
+
var OperationName = Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(200));
|
|
58
60
|
var AppQueryFailed = class extends Schema_exports.TaggedError()("AppQueryFailed", {}) {
|
|
59
61
|
};
|
|
60
62
|
|
|
61
63
|
// src/implementation/live.ts
|
|
62
64
|
var queryReference = (name) => ({
|
|
63
|
-
name: Schema_exports.decodeUnknownSync(
|
|
65
|
+
name: Schema_exports.decodeUnknownSync(OperationName)(name),
|
|
64
66
|
kind: "query"
|
|
65
67
|
});
|
|
66
68
|
var mutationReference = (name) => ({
|
|
67
|
-
name: Schema_exports.decodeUnknownSync(
|
|
69
|
+
name: Schema_exports.decodeUnknownSync(OperationName)(name),
|
|
68
70
|
kind: "mutation"
|
|
69
71
|
});
|
|
70
72
|
var liveQueryAtom = (reference, input, options) => Atom_exports.make(
|
|
@@ -447,20 +449,165 @@ var observeBrowserPerformance = Effect_exports.gen(function* () {
|
|
|
447
449
|
};
|
|
448
450
|
});
|
|
449
451
|
|
|
452
|
+
// ../utils/src/random-uuid.ts
|
|
453
|
+
var randomUuid = () => Array.from(crypto.getRandomValues(new Uint8Array(16)), (byte, index) => {
|
|
454
|
+
const value = index === 6 ? byte & 15 | 64 : index === 8 ? byte & 63 | 128 : byte;
|
|
455
|
+
const separator = [4, 6, 8, 10].includes(index) ? "-" : "";
|
|
456
|
+
return separator + value.toString(16).padStart(2, "0");
|
|
457
|
+
}).join("");
|
|
458
|
+
|
|
459
|
+
// ../telemetry/src/browser-operations.ts
|
|
460
|
+
var pageIds = /* @__PURE__ */ new WeakMap();
|
|
461
|
+
var browserPageId = () => {
|
|
462
|
+
if (typeof document === "undefined") return void 0;
|
|
463
|
+
const existing = pageIds.get(document);
|
|
464
|
+
if (existing !== void 0) return existing;
|
|
465
|
+
const created = randomUuid();
|
|
466
|
+
pageIds.set(document, created);
|
|
467
|
+
return created;
|
|
468
|
+
};
|
|
469
|
+
var BrowserOperationFailure = Schema_exports.Struct({
|
|
470
|
+
error_type: Schema_exports.Literals([
|
|
471
|
+
"BrowserDecodeFailed",
|
|
472
|
+
"BrowserConnectionFailed",
|
|
473
|
+
"BrowserTransportFailed",
|
|
474
|
+
"BrowserOperationFailed"
|
|
475
|
+
]),
|
|
476
|
+
trace_id: TraceContext.fields.traceId,
|
|
477
|
+
span_id: TraceContext.fields.spanId,
|
|
478
|
+
page_id: Schema_exports.String
|
|
479
|
+
});
|
|
480
|
+
var ResponseTrace = Context_exports.Reference("telemetry/ResponseTrace", {
|
|
481
|
+
defaultValue: () => void 0
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
// ../telemetry/src/keepalive.ts
|
|
485
|
+
var quota = 65536;
|
|
486
|
+
var inFlight = 0;
|
|
487
|
+
var resendListener;
|
|
488
|
+
var earlyResends = [];
|
|
489
|
+
var recordResend = (sender, outcome) => {
|
|
490
|
+
if (resendListener !== void 0) resendListener(sender, outcome);
|
|
491
|
+
else if (earlyResends.length < 50) earlyResends.push([sender, outcome]);
|
|
492
|
+
};
|
|
493
|
+
var onKeepaliveResend = (listener) => {
|
|
494
|
+
resendListener = listener;
|
|
495
|
+
for (const [sender, outcome] of earlyResends.splice(0)) listener(sender, outcome);
|
|
496
|
+
return () => {
|
|
497
|
+
if (resendListener === listener) resendListener = void 0;
|
|
498
|
+
};
|
|
499
|
+
};
|
|
500
|
+
var pageFetch = globalThis.fetch.bind(globalThis);
|
|
501
|
+
var keepaliveRoom = () => quota - inFlight;
|
|
502
|
+
var countedFetch = (sender, send, input, init, keepaliveBytes) => {
|
|
503
|
+
const counted = keepaliveBytes === false ? 0 : keepaliveBytes;
|
|
504
|
+
inFlight += counted;
|
|
505
|
+
let released = false;
|
|
506
|
+
const release = () => {
|
|
507
|
+
if (released) return;
|
|
508
|
+
released = true;
|
|
509
|
+
inFlight -= counted;
|
|
510
|
+
};
|
|
511
|
+
let response;
|
|
512
|
+
try {
|
|
513
|
+
response = send(input, { ...init, keepalive: keepaliveBytes !== false });
|
|
514
|
+
} catch (cause) {
|
|
515
|
+
release();
|
|
516
|
+
throw cause;
|
|
517
|
+
}
|
|
518
|
+
if (counted === 0) release();
|
|
519
|
+
else response.then((answered) => answered.clone().arrayBuffer()).then(release, release);
|
|
520
|
+
if (keepaliveBytes === false) return response;
|
|
521
|
+
return response.catch((cause) => {
|
|
522
|
+
if (!(cause instanceof TypeError)) throw cause;
|
|
523
|
+
const resent = send(input, { ...init, keepalive: false });
|
|
524
|
+
resent.then(
|
|
525
|
+
() => recordResend(sender, "resent"),
|
|
526
|
+
() => recordResend(sender, "resend-failed")
|
|
527
|
+
);
|
|
528
|
+
return resent;
|
|
529
|
+
});
|
|
530
|
+
};
|
|
531
|
+
var encoder = new TextEncoder();
|
|
532
|
+
|
|
450
533
|
// ../telemetry/src/browser.ts
|
|
451
534
|
var BrowserTelemetry = class extends Context_exports.Service()("executor/BrowserTelemetry") {
|
|
452
535
|
};
|
|
536
|
+
var encoder2 = new TextEncoder();
|
|
537
|
+
var objects = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "object" && item !== null) : [];
|
|
538
|
+
var requestBytes = (body) => typeof body === "string" ? encoder2.encode(body) : ArrayBuffer.isView(body) ? new Uint8Array(new Uint8Array(body.buffer, body.byteOffset, body.byteLength)) : void 0;
|
|
539
|
+
var splitTraces = (body, limit) => {
|
|
540
|
+
const payload = JSON.parse(new TextDecoder().decode(body));
|
|
541
|
+
let seen = 0;
|
|
542
|
+
const part = (count, before) => {
|
|
543
|
+
seen = 0;
|
|
544
|
+
const resourceSpans = objects(payload.resourceSpans).map((resource) => ({
|
|
545
|
+
...resource,
|
|
546
|
+
scopeSpans: objects(resource.scopeSpans).map((scope) => {
|
|
547
|
+
const spans = objects(scope.spans);
|
|
548
|
+
const at = Math.max(count - seen, 0);
|
|
549
|
+
seen += spans.length;
|
|
550
|
+
return { ...scope, spans: before ? spans.slice(0, at) : spans.slice(at) };
|
|
551
|
+
})
|
|
552
|
+
}));
|
|
553
|
+
return encoder2.encode(JSON.stringify({ ...payload, resourceSpans }));
|
|
554
|
+
};
|
|
555
|
+
part(0, true);
|
|
556
|
+
let [low, high] = [0, seen - 1];
|
|
557
|
+
while (low < high) {
|
|
558
|
+
const middle = Math.ceil((low + high) / 2);
|
|
559
|
+
if (part(middle, true).byteLength <= limit) low = middle;
|
|
560
|
+
else high = middle - 1;
|
|
561
|
+
}
|
|
562
|
+
return low === 0 ? void 0 : [part(low, true), part(low, false)];
|
|
563
|
+
};
|
|
564
|
+
var exportFetch = (page) => {
|
|
565
|
+
const send = (input, init, body, keepalive) => countedFetch("exports", fetch, input, { ...init, body }, keepalive);
|
|
566
|
+
return (input, init) => {
|
|
567
|
+
const body = requestBytes(init?.body);
|
|
568
|
+
if (body === void 0) return fetch(input, init);
|
|
569
|
+
if (body.byteLength <= keepaliveRoom()) return send(input, init, body, body.byteLength);
|
|
570
|
+
if (!page.leaving && document.visibilityState !== "hidden")
|
|
571
|
+
return send(input, init, body, false);
|
|
572
|
+
const parts = splitTraces(body, keepaliveRoom());
|
|
573
|
+
if (parts === void 0) return send(input, init, body, false);
|
|
574
|
+
const [head, rest] = parts;
|
|
575
|
+
return Promise.all([
|
|
576
|
+
send(input, init, rest, false),
|
|
577
|
+
send(input, init, head, head.byteLength)
|
|
578
|
+
]).then(([rest2, head2]) => head2.ok ? rest2 : head2);
|
|
579
|
+
};
|
|
580
|
+
};
|
|
581
|
+
var carryExportResends = (pending) => Layer_exports.effect(Tracer_exports.Tracer)(
|
|
582
|
+
Tracer_exports.Tracer.pipe(
|
|
583
|
+
Effect_exports.map((tracer) => ({
|
|
584
|
+
...tracer,
|
|
585
|
+
span: (options) => {
|
|
586
|
+
const span = tracer.span(options);
|
|
587
|
+
if (pending.resent > 0)
|
|
588
|
+
span.attribute("executor.keepalive.export_resends", pending.resent);
|
|
589
|
+
if (pending.failed > 0)
|
|
590
|
+
span.attribute("executor.keepalive.export_resend_failures", pending.failed);
|
|
591
|
+
pending.resent = 0;
|
|
592
|
+
pending.failed = 0;
|
|
593
|
+
return span;
|
|
594
|
+
}
|
|
595
|
+
}))
|
|
596
|
+
)
|
|
597
|
+
);
|
|
453
598
|
var browserTelemetryLayer = (settings) => Layer_exports.unwrap(
|
|
454
599
|
settings.pipe(
|
|
455
|
-
Effect_exports.map(
|
|
456
|
-
|
|
600
|
+
Effect_exports.map((config) => {
|
|
601
|
+
const page = { leaving: false };
|
|
602
|
+
const exportResends = { resent: 0, failed: 0 };
|
|
603
|
+
return Layer_exports.effect(
|
|
457
604
|
BrowserTelemetry,
|
|
458
605
|
Effect_exports.gen(function* () {
|
|
459
606
|
const flusher = yield* OtlpExporter_exports.Flusher;
|
|
460
607
|
const run = yield* FiberSet_exports.makeRuntime();
|
|
461
608
|
let navigation;
|
|
462
|
-
const
|
|
463
|
-
const flush =
|
|
609
|
+
const performance2 = yield* observeBrowserPerformance;
|
|
610
|
+
const flush = performance2.flush.pipe(
|
|
464
611
|
Effect_exports.andThen(flusher.flush),
|
|
465
612
|
Effect_exports.timeoutOption("2 seconds"),
|
|
466
613
|
Effect_exports.asVoid
|
|
@@ -475,16 +622,38 @@ var browserTelemetryLayer = (settings) => Layer_exports.unwrap(
|
|
|
475
622
|
const onError = (event) => error("ui.error", event.error ?? new Error(event.message));
|
|
476
623
|
const onRejection = (event) => error("ui.unhandled-rejection", event.reason);
|
|
477
624
|
const onHidden = () => {
|
|
625
|
+
if (navigation !== void 0 && document.visibilityState === "hidden")
|
|
626
|
+
navigation.hidden = true;
|
|
478
627
|
run(
|
|
479
|
-
document.visibilityState === "hidden" ?
|
|
628
|
+
document.visibilityState === "hidden" ? performance2.pause.pipe(Effect_exports.andThen(flush)) : performance2.resume
|
|
480
629
|
);
|
|
481
630
|
};
|
|
482
631
|
const onHide = () => {
|
|
483
|
-
|
|
632
|
+
page.leaving = true;
|
|
633
|
+
run(performance2.hide.pipe(Effect_exports.andThen(flush)));
|
|
484
634
|
};
|
|
485
635
|
const onShow = (event) => {
|
|
486
|
-
|
|
636
|
+
page.leaving = false;
|
|
637
|
+
if (event.persisted) run(performance2.restore);
|
|
487
638
|
};
|
|
639
|
+
const stopResends = onKeepaliveResend((sender, outcome) => {
|
|
640
|
+
if (sender === "exports") {
|
|
641
|
+
if (outcome === "resent") exportResends.resent++;
|
|
642
|
+
else exportResends.failed++;
|
|
643
|
+
return;
|
|
644
|
+
}
|
|
645
|
+
const attributes = {
|
|
646
|
+
"executor.keepalive.sender": sender,
|
|
647
|
+
"executor.keepalive.outcome": outcome,
|
|
648
|
+
"executor.page.id": browserPageId() ?? ""
|
|
649
|
+
};
|
|
650
|
+
run(
|
|
651
|
+
Effect_exports.logInfo("ui.keepalive.resend").pipe(
|
|
652
|
+
Effect_exports.annotateLogs(attributes),
|
|
653
|
+
Effect_exports.withSpan("ui.keepalive.resend", { root: true, attributes })
|
|
654
|
+
)
|
|
655
|
+
);
|
|
656
|
+
});
|
|
488
657
|
window.addEventListener("error", onError);
|
|
489
658
|
window.addEventListener("unhandledrejection", onRejection);
|
|
490
659
|
window.addEventListener("pagehide", onHide);
|
|
@@ -497,20 +666,33 @@ var browserTelemetryLayer = (settings) => Layer_exports.unwrap(
|
|
|
497
666
|
window.removeEventListener("pagehide", onHide);
|
|
498
667
|
window.removeEventListener("pageshow", onShow);
|
|
499
668
|
document.removeEventListener("visibilitychange", onHidden);
|
|
669
|
+
stopResends();
|
|
500
670
|
})
|
|
501
671
|
);
|
|
502
672
|
return {
|
|
503
673
|
flush,
|
|
504
674
|
navigation: (event) => Effect_exports.sync(() => {
|
|
675
|
+
if (event.type === "load") return;
|
|
505
676
|
if (event.type === "end") {
|
|
506
|
-
if (navigation !== void 0) Deferred_exports.doneUnsafe(navigation, Effect_exports.void);
|
|
677
|
+
if (navigation !== void 0) Deferred_exports.doneUnsafe(navigation.done, Effect_exports.void);
|
|
507
678
|
navigation = void 0;
|
|
508
679
|
return;
|
|
509
680
|
}
|
|
510
|
-
if (navigation !== void 0)
|
|
511
|
-
|
|
681
|
+
if (navigation !== void 0)
|
|
682
|
+
Deferred_exports.doneUnsafe(navigation.done, Effect_exports.interrupt);
|
|
683
|
+
const current = {
|
|
684
|
+
done: Deferred_exports.makeUnsafe(),
|
|
685
|
+
hidden: document.visibilityState === "hidden"
|
|
686
|
+
};
|
|
687
|
+
navigation = current;
|
|
512
688
|
run(
|
|
513
|
-
Deferred_exports.await(
|
|
689
|
+
Deferred_exports.await(current.done).pipe(
|
|
690
|
+
// Record visibility however the navigation ends, including when a later one interrupts it.
|
|
691
|
+
Effect_exports.ensuring(
|
|
692
|
+
Effect_exports.suspend(
|
|
693
|
+
() => Effect_exports.annotateCurrentSpan("executor.navigation.hidden", current.hidden)
|
|
694
|
+
)
|
|
695
|
+
),
|
|
514
696
|
Effect_exports.withSpan("ui.navigation", {
|
|
515
697
|
root: true,
|
|
516
698
|
attributes: { "url.path": event.path }
|
|
@@ -520,21 +702,25 @@ var browserTelemetryLayer = (settings) => Layer_exports.unwrap(
|
|
|
520
702
|
);
|
|
521
703
|
}).pipe(
|
|
522
704
|
Effect_exports.andThen(
|
|
523
|
-
event.type === "
|
|
705
|
+
event.type === "end" ? Effect_exports.void : performance2.navigation(event.path)
|
|
524
706
|
)
|
|
525
707
|
)
|
|
526
708
|
};
|
|
527
709
|
})
|
|
528
710
|
).pipe(
|
|
529
|
-
Layer_exports.provideMerge(
|
|
711
|
+
Layer_exports.provideMerge(
|
|
712
|
+
carryExportResends(exportResends).pipe(
|
|
713
|
+
Layer_exports.provideMerge(telemetryLayer(config, "process", Logger_exports.consoleJson))
|
|
714
|
+
)
|
|
715
|
+
),
|
|
530
716
|
Layer_exports.provide(
|
|
531
|
-
Layer_exports.
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
717
|
+
Layer_exports.mergeAll(
|
|
718
|
+
Layer_exports.succeed(FetchHttpClient_exports.RequestInit, { credentials: "same-origin" }),
|
|
719
|
+
Layer_exports.succeed(FetchHttpClient_exports.Fetch, exportFetch(page))
|
|
720
|
+
)
|
|
535
721
|
)
|
|
536
|
-
)
|
|
537
|
-
)
|
|
722
|
+
);
|
|
723
|
+
})
|
|
538
724
|
)
|
|
539
725
|
);
|
|
540
726
|
var makeBrowserTelemetry = (settings) => {
|
|
@@ -793,12 +979,39 @@ var makeOptimisticClient = (transport) => {
|
|
|
793
979
|
};
|
|
794
980
|
|
|
795
981
|
// src/implementation/ui-client.ts
|
|
982
|
+
var resubscribeDelay = Schedule_exports.min([
|
|
983
|
+
Schedule_exports.exponential("1 second"),
|
|
984
|
+
Schedule_exports.spaced("1 minute")
|
|
985
|
+
]).pipe(Schedule_exports.jittered);
|
|
986
|
+
var appFailure = (error) => Schema_exports.is(UiFailed)(error) && error.reason === "operation_failed";
|
|
987
|
+
var resubscribes = (error) => HttpClientError_exports.isHttpClientError(error) || Cause_exports.isTimeoutError(error) || Schema_exports.is(UiFailed)(error) && error.reason !== "account_required";
|
|
988
|
+
var Retrying = class {
|
|
989
|
+
constructor(error, previous) {
|
|
990
|
+
this.error = error;
|
|
991
|
+
this.previous = previous;
|
|
992
|
+
}
|
|
993
|
+
error;
|
|
994
|
+
previous;
|
|
995
|
+
};
|
|
996
|
+
var visibleResult = (result) => {
|
|
997
|
+
const current = AsyncResult_exports.value(result);
|
|
998
|
+
if (Option_exports.isNone(current) || !(current.value instanceof Retrying)) {
|
|
999
|
+
return result;
|
|
1000
|
+
}
|
|
1001
|
+
const previous = Option_exports.map(
|
|
1002
|
+
Option_exports.fromUndefinedOr(current.value.previous),
|
|
1003
|
+
AsyncResult_exports.success
|
|
1004
|
+
);
|
|
1005
|
+
return AsyncResult_exports.isSuccess(result) ? AsyncResult_exports.failureWithPrevious(Cause_exports.fail(current.value.error), { previous, waiting: true }) : AsyncResult_exports.failureWithPrevious(AsyncResult_exports.isFailure(result) ? result.cause : Cause_exports.empty, {
|
|
1006
|
+
previous
|
|
1007
|
+
});
|
|
1008
|
+
};
|
|
796
1009
|
var createAppClient = () => {
|
|
797
1010
|
const { runtime, atoms } = makeBrowserTelemetry(
|
|
798
1011
|
browserSettings("/_executor/api/telemetry", "executor-app-web")
|
|
799
1012
|
);
|
|
800
1013
|
const browser = atoms(Layer_exports.empty);
|
|
801
|
-
const
|
|
1014
|
+
const versionChanged = Effect_exports.sync(() => {
|
|
802
1015
|
window.dispatchEvent(new Event("executor:deployment-changed"));
|
|
803
1016
|
});
|
|
804
1017
|
let pendingWrites = 0;
|
|
@@ -840,14 +1053,15 @@ var createAppClient = () => {
|
|
|
840
1053
|
const value = yield* api.ui[kind]({ payload: yield* payload(name, input) });
|
|
841
1054
|
return yield* Schema_exports.decodeUnknownEffect(decoderOf(output))(value);
|
|
842
1055
|
}).pipe(
|
|
843
|
-
Effect_exports.tapErrorTag("UiDeploymentChanged", () =>
|
|
1056
|
+
Effect_exports.tapErrorTag("UiDeploymentChanged", () => versionChanged),
|
|
844
1057
|
Effect_exports.withSpan(`ui.app.${kind}`, { attributes: { "executor.operation.name": name } })
|
|
845
1058
|
);
|
|
846
1059
|
const source = (name, input, output) => browser.atom(
|
|
847
1060
|
Stream_exports.suspend(() => {
|
|
848
1061
|
let previous;
|
|
849
1062
|
let attempts = 0;
|
|
850
|
-
|
|
1063
|
+
let latest;
|
|
1064
|
+
const subscription = Stream_exports.unwrap(
|
|
851
1065
|
Effect_exports.gen(function* () {
|
|
852
1066
|
const attempt = attempts++;
|
|
853
1067
|
const first = yield* pendingSpan("ui.app.first_result", {
|
|
@@ -895,73 +1109,94 @@ var createAppClient = () => {
|
|
|
895
1109
|
Stream_exports.timeout("45 seconds"),
|
|
896
1110
|
Stream_exports.concat(Stream_exports.fail(new UiFailed({ reason: "unavailable" }))),
|
|
897
1111
|
Stream_exports.filter((frame) => frame.type !== "heartbeat"),
|
|
898
|
-
Stream_exports.mapEffect(
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
Effect_exports.
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
1112
|
+
Stream_exports.mapEffect(
|
|
1113
|
+
(frame) => {
|
|
1114
|
+
if (frame.type === "failure") return Effect_exports.fail(frame.error);
|
|
1115
|
+
const server = externalTrace(frame.trace);
|
|
1116
|
+
return Effect_exports.gen(function* () {
|
|
1117
|
+
const value = yield* Schema_exports.decodeUnknownEffect(decoderOf(output))(
|
|
1118
|
+
frame.value
|
|
1119
|
+
).pipe(Effect_exports.mapError(() => new AppQueryFailed()));
|
|
1120
|
+
const received = yield* Effect_exports.currentSpan;
|
|
1121
|
+
const receivedAt = clock.currentTimeMillisUnsafe();
|
|
1122
|
+
const currentRevision = revision++;
|
|
1123
|
+
yield* Effect_exports.annotateCurrentSpan({
|
|
1124
|
+
"executor.operation.name": name,
|
|
1125
|
+
"executor.snapshot.revision": currentRevision,
|
|
1126
|
+
"browser.query.elapsed_ms": receivedAt - started,
|
|
1127
|
+
"executor.trace.context_valid": Option_exports.isSome(server)
|
|
1128
|
+
});
|
|
1129
|
+
yield* first.finish(Exit_exports.void);
|
|
1130
|
+
let committed = false;
|
|
1131
|
+
return {
|
|
1132
|
+
value,
|
|
1133
|
+
commit: () => {
|
|
1134
|
+
if (committed) return;
|
|
1135
|
+
committed = true;
|
|
1136
|
+
const committedAt = clock.currentTimeMillisUnsafe();
|
|
1137
|
+
runtime.runFork(
|
|
1138
|
+
Effect_exports.void.pipe(
|
|
1139
|
+
Effect_exports.withSpan("ui.app.result.commit", {
|
|
1140
|
+
parent: received,
|
|
1141
|
+
attributes: {
|
|
1142
|
+
"executor.operation.name": name,
|
|
1143
|
+
"executor.snapshot.revision": currentRevision,
|
|
1144
|
+
"browser.query.elapsed_ms": committedAt - started,
|
|
1145
|
+
"browser.query.receive_to_commit_ms": committedAt - receivedAt,
|
|
1146
|
+
"browser.page.hidden": document.visibilityState === "hidden"
|
|
1147
|
+
}
|
|
1148
|
+
})
|
|
1149
|
+
)
|
|
1150
|
+
);
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
}).pipe(
|
|
1154
|
+
Effect_exports.withSpan("ui.app.result.receive", {
|
|
1155
|
+
parent: Option_exports.isSome(server) ? server.value : first.span,
|
|
1156
|
+
kind: "consumer"
|
|
1157
|
+
})
|
|
1158
|
+
);
|
|
1159
|
+
}
|
|
1160
|
+
),
|
|
945
1161
|
Stream_exports.onExit(finish),
|
|
946
1162
|
Stream_exports.provideService(Tracer_exports.ParentSpan, first.span)
|
|
947
1163
|
);
|
|
948
1164
|
})
|
|
949
1165
|
).pipe(
|
|
950
1166
|
// Keep the last snapshot while the watcher replaces the document.
|
|
951
|
-
// Unmount or client disposal interrupts the
|
|
1167
|
+
// Unmount or client disposal interrupts the version-change wait.
|
|
952
1168
|
Stream_exports.catch(
|
|
953
|
-
(error) => Schema_exports.is(
|
|
1169
|
+
(error) => Schema_exports.is(UiVersionChanged)(error) ? Stream_exports.unwrap(versionChanged.pipe(Effect_exports.as(Stream_exports.never))) : Stream_exports.fail(error)
|
|
954
1170
|
),
|
|
955
|
-
Stream_exports.
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
)
|
|
960
|
-
)
|
|
1171
|
+
Stream_exports.tap(
|
|
1172
|
+
(value) => Effect_exports.sync(() => {
|
|
1173
|
+
latest = value;
|
|
1174
|
+
})
|
|
961
1175
|
)
|
|
962
1176
|
);
|
|
1177
|
+
return Stream_exports.unwrap(
|
|
1178
|
+
Effect_exports.gen(function* () {
|
|
1179
|
+
const retrying = yield* Queue_exports.unbounded();
|
|
1180
|
+
return Stream_exports.merge(
|
|
1181
|
+
subscription.pipe(
|
|
1182
|
+
Stream_exports.retry(
|
|
1183
|
+
resubscribeDelay.pipe(
|
|
1184
|
+
Schedule_exports.while(
|
|
1185
|
+
({ input: input2 }) => !resubscribes(input2) ? false : appFailure(input2) ? Queue_exports.offer(retrying, new Retrying(input2, latest)).pipe(
|
|
1186
|
+
Effect_exports.as(true)
|
|
1187
|
+
) : true
|
|
1188
|
+
)
|
|
1189
|
+
)
|
|
1190
|
+
)
|
|
1191
|
+
),
|
|
1192
|
+
// Shown outside the retried stream, so they do not reset its delay.
|
|
1193
|
+
Stream_exports.fromQueue(retrying),
|
|
1194
|
+
{ haltStrategy: "left" }
|
|
1195
|
+
);
|
|
1196
|
+
})
|
|
1197
|
+
);
|
|
963
1198
|
})
|
|
964
|
-
).pipe(Atom_exports.map(queryResult));
|
|
1199
|
+
).pipe(Atom_exports.map((result) => queryResult(visibleResult(result))));
|
|
965
1200
|
const optimistic = makeOptimisticClient({
|
|
966
1201
|
source,
|
|
967
1202
|
read: (name, input, output) => request("query", name, input, output),
|