akanjs 3.2.0-rc.0 → 3.2.0-rc.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/CHANGELOG.md +35 -4
- package/common/abortSignals.ts +39 -3
- package/common/akanGraph.ts +1 -0
- package/common/types.ts +1 -0
- package/fetch/client/fetchClient.ts +7 -8
- package/fetch/client/httpClient.ts +7 -4
- package/fetch/client/wsClient.ts +18 -14
- package/package.json +1 -1
- package/server/devtools/README.md +6 -3
- package/server/devtools/studio/studioDocument.tsx +29 -15
- package/server/devtools/studio/studioLayout.ts +1 -0
- package/server/devtools/studio/studioRoute.ts +19 -7
- package/server/devtools/studio/studioRuntimeGraph.ts +12 -10
- package/store/SliceRequest.ts +23 -2
- package/store/action.ts +16 -17
- package/store/storeInstance.ts +1 -1
- package/types/common/abortSignals.d.ts +3 -0
- package/types/common/akanGraph.d.ts +1 -0
- package/types/common/types.d.ts +1 -0
- package/types/dictionary/base.dictionary.d.ts +1 -1
- package/types/dictionary/dictionary.d.ts +8 -8
- package/types/fetch/client/fetchClient.d.ts +2 -0
- package/types/fetch/client/httpClient.d.ts +1 -0
- package/types/fetch/client/wsClient.d.ts +3 -2
- package/types/server/devtools/studio/studioDocument.d.ts +3 -1
- package/types/server/devtools/studio/studioLayout.d.ts +1 -0
- package/types/store/SliceRequest.d.ts +6 -1
- package/types/webkit/McpAppBridge.d.ts +4 -2
- package/webkit/McpAppBridge.ts +28 -4
- package/webkit/McpAppFetchBridge.ts +32 -5
package/CHANGELOG.md
CHANGED
|
@@ -32,6 +32,32 @@
|
|
|
32
32
|
- **`pkgs/akanjs/ARCHITECTURE.md`** pairs a hand-kept walk through the processes and a request with a generated part between markers. `akan sync-architecture` regenerates that part, and a devkit test fails when it is stale, when a channel is gone, when two facets load values from each other, when a message lacks a recognised sender or handler outside a short list whose other end lies beyond the framework source, or when the hand-kept part names a class the source no longer has.
|
|
33
33
|
- **`AkanIpcMessage` no longer lists `backend-ready`.** The gateway sends it to the dev host, which reads it as a `BuilderMessage`, where it stays; no gateway or child ever handled it.
|
|
34
34
|
|
|
35
|
+
- c723713: The Akan Graph keys a guard function by the file that declares it, locates more of a workspace's guards, and stops counting things that are not guards.
|
|
36
|
+
|
|
37
|
+
A guard function a route or layout imports is keyed by its file, as one the page declares already was: `guard:libs/shared:webkit/signedIn.ts#signedIn`. A `canEdit` in `webkit/` and one in `common/` are two nodes, each at its own declaration, and an edit to either marks only that one changed in the Change Map. A guard called through a namespace import (`auth.signedIn()`), or imported under a name a file re-exports (`export { signedIn as hasSession } from "./auth"`), reaches its declaration. A function the guard declares, or a parameter it binds, shadows an import of the same name only inside its own scope, so `[1].forEach((signedIn) => …)` no longer hides a real `signedIn()` beside it. A guard declared after another declarator (`export const ready = true, signedIn = …`) is found, and an overloaded guard's digest covers every signature. Only a file whose text declares or re-exports the name is parsed, so a guard that calls `usePage()` from the generated client no longer parses every page that names it.
|
|
38
|
+
|
|
39
|
+
A function is a guard factory only when it returns a guard, a class that implements `Guard` (also one handed to a wrapper, `withName(class implements Guard {…}, field)`) or a call to a factory, so `const guardCount = countGuards()` is no longer a guard. An import from a package outside the workspace (`@vendor/auth`) resolves to no guard: it no longer links a same-name workspace guard, and a vendor's `Public` no longer reads as the framework's. A factory imported from akanjs or a package makes no guard. A lib's `export *` chain, walked from the path the import names, is followed only when it reaches exactly one workspace lib declaring the name, none of its `export *` names a package, and the lib does not declare, destructure or export the name itself; otherwise the guard stays `guard:<lib>:<Name>` without a location, so a vendor shim no longer links another lib's guard. A class extending a base that is not a known guard is no guard, even when a lib declares a guard of that name.
|
|
40
|
+
|
|
41
|
+
More guards carry their location: a name a lib re-exports under another name (`export { Admin as AdminGuard }`) reaches the class, and one it re-exports from akanjs is `guard::Public`; `srvkit.SSO.Kakao` reads through the namespace to the lib's map; a map entry a factory makes (`SSO = { Kakao: ssoGuardOf("kakao") }`) is the guard `SSO.Kakao`; a local wrapper of an imported factory, a factory called through a namespace (`srvkit.resourceGuard("pin")`) and a class that extends a guard (`class DemoAdmin extends Admin`) and a factory a lib re-exports under another name (`export { resourceGuard as rg }`) make guards; a guard made in place, `guards: [canEdit("memo")]`, is a node at the call, keyed by its member, callee and ordinal so an edit to its arguments, or to another member's guards, keeps the id. Of two same-name guards in one owner, an import reaches the one its path names. A wrapper's digest covers every factory it can return, and an edit to a factory in another file marks the guards it makes changed instead of listing the file as unmapped.
|
|
42
|
+
|
|
43
|
+
In the Change Map, a declaration whose id moves between `kind:owner:Name` and `kind:owner:<file>#Name` at the same file is one node, so a second same-name guard shows as one addition, not the first one removed and re-added.
|
|
44
|
+
|
|
45
|
+
`get_graph` past the node limit names owners by the nodes it would answer with, changed pages included, so 650 changed routes no longer hide behind one changed lib method. A guard on `const route = page()…; export default route` is no longer read: `RouteSourceValidator` rejects that shape.
|
|
46
|
+
|
|
47
|
+
Ids and details that change for a saved graph or a Change Map base:
|
|
48
|
+
|
|
49
|
+
- An imported guard function's id names its file: `guard:libs/shared:signedIn` is now `guard:libs/shared:webkit/signedIn.ts#signedIn`.
|
|
50
|
+
- A guard name two files of one owner declare is keyed by file, `guard:apps/demo:srvkit/admin.ts#Admin`.
|
|
51
|
+
- A guard made in place is `guard:<owner>:<file>#<model>.<key>:<callee>@<n>`, the `n`th in-place call of that callee in that slice or endpoint key (`…/memo.signal.ts#memo.shareMemo:resourceGuard@1`). Its label, an endpoint's `detail` and the editor hover name the call: `resourceGuard("memo")` where `detail` read `resourceGuard`, or `allow(…)` when the arguments run past 32 characters or a line. A guard read through a namespace's map reads `srvkit.SSO.Kakao` where it read `Kakao`.
|
|
52
|
+
- A map entry a factory makes is `guard:libs/shared:SSO.Kakao` where it was `guard::Kakao` or `guard:<lib>:Kakao`, and a local map's `Roles.Owner` is `guard:apps/demo:Roles.Owner` where it linked `guard:apps/demo:Owner`.
|
|
53
|
+
- A guard a lib re-exports, under its own name or another, or from akanjs, takes the declaring owner's id (`guard:libs/util:Admin`, `guard::Public`) where it took the re-exporting lib's.
|
|
54
|
+
- A guard imported from an unknown package draws no edge.
|
|
55
|
+
- A name the old "sole visible lib" fallback linked through a lib that does not declare it (`guard:libs/billing:Admin` behind a vendor `export *`) now reads `guard:<lib>:<Name>` without a location, unless the lib's `export *` chain reaches exactly one workspace lib declaring it.
|
|
56
|
+
- A class extending a base that is not a known guard (`class Thing extends Base` with an ordinary `Base`) no longer has a guard node; an endpoint naming it in `guards` links an unlocated `guard:<owner>:Thing`.
|
|
57
|
+
|
|
58
|
+
- **`AkanGraphNode.sources`** in `akanjs/common`: the files besides `at.file` that a node's digest reads, set only with digests. The Change Map uses it to map those files and leaves it out of its answer.
|
|
59
|
+
- **The fact reader** in `@akanjs/language`: `GuardFactoryFact.via` is a list and gains `direct`; `GuardCallFact` gains `kind` (`call` or `extends`) and `scope`; `FileFacts` gains `guardLabels`, an in-place guard's name to its call. A slice's or endpoint's guard made in place is read as `<model>.<key>:<callee>@<n>`, and every in-place call is a `GuardCallFact`.
|
|
60
|
+
|
|
35
61
|
- 0351ad4: The Akan Graph keys each guard by the app or lib that declares it, `guard:libs/shared:Admin`, and follows the import that names it there, so `Admin as AdminGuard` reaches `Admin`, `srvkit.Admin` reaches the lib's class, and two libs' `Admin` stay two nodes. A guard read out of an object map, `SSO.Kakao`, resolves through the imports of the file that declares the map. A name a lib only re-exports reaches the class it re-exports. A guard a factory makes is a guard too, whether the factory sits in the same file, wraps another factory there, or is imported from another lib. A guard node carries its source location, `doc` (the comment above its declaration that says what it checks) and, in `detail`, its `scope` (`account` or `resource`). A factory-made guard takes the factory's scope, and takes its doc when no guard of that factory has its own. With digests, an edit to a guard or to the factory that makes it marks the guard changed in the Change Map. Every guard a workspace declares is a node, referenced or not. `Public` and `None` come from `akanjs`, carry no location and say what they do. Studio shows a node's `doc` in its tooltip.
|
|
36
62
|
|
|
37
63
|
Ids and details that change for a saved graph or a Change Map base:
|
|
@@ -139,13 +165,13 @@
|
|
|
139
165
|
`akan tunnel` and `akan start --share` keep working: the tunnel agent now dials the local app under the app's own address and leaves the public host name in `x-forwarded-host`, which is where the app already reads it. A redirect a page raises during SSR now sends a same-origin target as a relative `Location`, so a tunnel or proxy caller lands on the host it used rather than the one the server was dialed as; a target on another origin stays absolute.
|
|
140
166
|
|
|
141
167
|
- 9f30e93: A dev page no longer loses its styles after a stylesheet change arrives together with a pages rebuild. The most common case was the first save after `akan start` released its builder for being idle: the waking builder announces a new pages bundle and a new stylesheet at once, and the SSR worker that had started importing the bundle put the old stylesheet back when the import finished. Pages kept linking that stylesheet, whose file the dev server had already deleted, so they rendered unstyled with a 404 until `akan start` was restarted. The same update also reaches an SSR worker that is still booting after a recycle, which used to keep the stylesheet it was started with.
|
|
142
|
-
- d9eaacc: A query takes `signal` in its `FetchPolicy`, joined with its deadline: an abort rejects the call with the signal's reason, stops the request, and ends the retries, including one waiting between tries. A signal from `AbortSignal.timeout` rejects with the slow-server error (`base.error.gatewayTimeout`, 408), as the query's own deadline does. A mutation ignores it, since one already sent may have run.
|
|
168
|
+
- d9eaacc: A query takes `signal` in its `FetchPolicy`, joined with its deadline: an abort rejects the call with the signal's reason, stops the request, and ends the retries, including one waiting between tries. A signal already aborted sends nothing, over HTTP, inside a server render or through an MCP App view's host. A signal from `AbortSignal.timeout` rejects with the slow-server error (`base.error.gatewayTimeout`, 408), as the query's own deadline does. A mutation ignores it, since one already sent may have run. In an MCP App view an abort, or the query's own deadline running out, also asks the host to cancel the call it relayed (`notifications/cancelled`); a mutation that runs out of time is only given up on. A custom `FetchBridge` receives the signal as `signal`.
|
|
143
169
|
|
|
144
|
-
A slice's list loads (`init`, `refresh`, `setPage`, `setLimit`, `setSort`, `setQueryArgs`, `loadMore`) abort the request a newer load of the same slice supersedes, instead of letting it run to the end and dropping its answer. The superseded load writes nothing and shows no error, and so does one aborted by a `signal` its caller passed. A store action that rejects with
|
|
170
|
+
A slice's list loads (`init`, `refresh`, `setPage`, `setLimit`, `setSort`, `setQueryArgs`, `loadMore`) abort the request a newer load of the same slice supersedes, instead of letting it run to the end and dropping its answer. The superseded load writes nothing and shows no error, and so does one aborted by a `signal` its caller passed, which resolves; `init` still applies its `default` at once unless the signal was already aborted, and an `init` aborted mid-flight, or one with nothing to change, leaves a loaded-more list whole, so the next refresh still reloads every row shown. A caller's `AbortSignal.timeout` is the exception: the load rejects with the slow-server error and shows it, as a query does. A store action that rejects with the abort of a signal it was given no longer shows an error toast, whatever reason that signal was aborted with, except an app or server error (one with a dictionary key or a status) and a timeout, which still show.
|
|
145
171
|
|
|
146
172
|
- d9eaacc: Identical queries a browser tab has in flight at once share one request: same endpoint, arguments, credential, timeout and retry. The caller that started it parses the answer, and the others parse a copy. One caller's abort leaves the request running for the rest, and it stops only when every caller waiting on it has aborted. A write (a mutation, a file upload, a socket message) or a sign-in or sign-out ends the sharing: a call made after it sends a request of its own, while a caller already waiting keeps its answer. A server still memoizes a request's queries for the whole render, and outside a request it sends each call.
|
|
147
173
|
|
|
148
|
-
`FetchPolicy.cache` and `FetchPolicy.partial` are deprecated. Nothing has read them since v2 dropped GraphQL; an endpoint reuses its answer with its own `query(T, { cache })`.
|
|
174
|
+
`FetchPolicy.cache` and `FetchPolicy.partial` are deprecated. Nothing has read them since v2 dropped GraphQL; an endpoint reuses its answer with its own `query(T, { cache })`. `FetchPolicy.onError` is deprecated too, since nothing calls it: catch the call's rejection instead.
|
|
149
175
|
|
|
150
176
|
- c334caf: A root layout's fonts now preload one face per family instead of every face. By default that is the regular face: 400 normal, or the weight a browser draws regular text with when the family has no 400 (500, then lighter, then heavier). Every other weight still has its `@font-face` rule, with `font-display: swap`, and loads when text first uses it. A path set to `preload: true` is preloaded as well, and `preload: false` still never is. The app template's home page declares nine Pretendard weights and preloaded all of them, 166 KB; it now preloads one, 18 KB, and fetches the three other weights it shows when it draws them. To keep a weight the first screen shows preloaded, set `preload: true` on its path; the akanjs.com layout now does that for 700 and 900.
|
|
151
177
|
- e143263: The optional `happy-dom` and `@happy-dom/global-registrator` peers now ask for `^21.0.4`. Versions 17.0.0 through 21.0.3 compile a `<script type="module">` import alias into code unchecked, so a page loaded into a happy-dom window could run code on the host (GHSA-834v-8h66-3h79). UI tests register one through `akanjs/test/registerDom`; run `bun update happy-dom @happy-dom/global-registrator` in a workspace that pins an older one.
|
|
@@ -410,8 +436,13 @@
|
|
|
410
436
|
- **A write leaves untouched `search()` values as they were.** An array `search()` value used to be parsed again on every write, as a new array, so a component reading it rendered again on writes it did not read.
|
|
411
437
|
- **`set` with a `search()` or `computed()` key** now throws before it writes anything. Before, the state was already replaced when it threw.
|
|
412
438
|
|
|
439
|
+
- 6291fec: Akan Studio opens without a dev builder, and names every job in full.
|
|
440
|
+
|
|
441
|
+
- **`/_akan/studio` with no dev builder** lands on the Runtime view, which reads the running server, instead of answering 503 with nothing to click. A view that needs the builder (ERD, Signals, Changes, Framework) still answers 503, now inside Studio's header and nav, saying to open it under `akan start` and that Runtime needs no builder. A failed build shows its error the same way.
|
|
442
|
+
- **Each job row** carries its full name and schedule as a tooltip (`cron syncAccountBalances · 0 * * * *`), with the skip reason below it for a job this server does not run, so two long names clipped alike can be told apart.
|
|
443
|
+
|
|
413
444
|
- 0c480c6: The signal-test harness clears the env cache once it has set the test port, so a fetch client built after setup reaches the test server even when a module read `getEnv()` before the harness ran.
|
|
414
|
-
- d9eaacc: A socket that is down keeps at most 100 messages emitted meanwhile, dropping the oldest, and says how many it dropped when it reconnects. Before, the outbox grew without end, so a stream of emits (a cursor, a typing signal) on a tab offline for minutes held every one of them and sent them all at once on reconnect. `configureWs({ outboxLimit })` sets the cap, and `
|
|
445
|
+
- d9eaacc: A socket that is down keeps at most 100 messages emitted meanwhile, dropping the oldest, and says how many it dropped when it reconnects. Before, the outbox grew without end, so a stream of emits (a cursor, a typing signal) on a tab offline for minutes held every one of them and sent them all at once on reconnect. `configureWs({ outboxLimit })` sets the cap: `0` keeps none and says so once rather than on every reconnect, and a negative limit or `Infinity` keeps every one. Room subscriptions never queue there and are sent again on every open, as before.
|
|
415
446
|
|
|
416
447
|
## 3.1.1
|
|
417
448
|
|
package/common/abortSignals.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export class AbortSignals {
|
|
2
2
|
static readonly #noop = () => undefined;
|
|
3
|
+
static readonly #reasons = new WeakSet<object>();
|
|
3
4
|
|
|
4
5
|
static join(signals: (AbortSignal | null | undefined)[]): { signal?: AbortSignal; dispose: () => void } {
|
|
5
6
|
const live = signals.filter((signal): signal is AbortSignal => !!signal);
|
|
@@ -29,16 +30,51 @@ export class AbortSignals {
|
|
|
29
30
|
if (!signal) return promise;
|
|
30
31
|
if (signal.aborted) {
|
|
31
32
|
void promise.catch(() => undefined);
|
|
32
|
-
return Promise.reject(signal
|
|
33
|
+
return Promise.reject(AbortSignals.reasonOf(signal));
|
|
33
34
|
}
|
|
34
35
|
return new Promise<T>((resolve, reject) => {
|
|
35
|
-
const abort = () => reject(signal
|
|
36
|
+
const abort = () => reject(AbortSignals.reasonOf(signal));
|
|
36
37
|
signal.addEventListener("abort", abort, { once: true });
|
|
37
38
|
promise.then(resolve, reject).finally(() => signal.removeEventListener("abort", abort));
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
static reasonOf(signal: AbortSignal): unknown {
|
|
43
|
+
const reason: unknown = signal.reason;
|
|
44
|
+
if (typeof reason === "object" && reason !== null && AbortSignals.#isQuiet(reason, signal))
|
|
45
|
+
AbortSignals.#reasons.add(reason);
|
|
46
|
+
return reason;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static isTimeout(signal: AbortSignal) {
|
|
50
|
+
const reason: unknown = signal.reason;
|
|
51
|
+
return reason instanceof Error && reason.name === "TimeoutError";
|
|
52
|
+
}
|
|
53
|
+
|
|
41
54
|
static isAbort(error: unknown) {
|
|
42
|
-
|
|
55
|
+
if (typeof error !== "object" || error === null) return false;
|
|
56
|
+
return (error as { name?: unknown }).name === "AbortError" || AbortSignals.#reasons.has(error);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static isAbortOf(error: unknown, callArgs: unknown[]) {
|
|
60
|
+
if (AbortSignals.isAbort(error)) return true;
|
|
61
|
+
return callArgs.some((arg) => {
|
|
62
|
+
const signal = AbortSignals.#signalIn(arg);
|
|
63
|
+
return !!signal?.aborted && Object.is(signal.reason, error) && AbortSignals.#isQuiet(error, signal);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static #isQuiet(reason: unknown, signal: AbortSignal) {
|
|
68
|
+
if (AbortSignals.isTimeout(signal)) return false;
|
|
69
|
+
if (typeof reason !== "object" || reason === null) return true;
|
|
70
|
+
const { error, statusCode } = reason as { error?: unknown; statusCode?: unknown };
|
|
71
|
+
return typeof error !== "string" && statusCode === undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static #signalIn(arg: unknown): AbortSignal | undefined {
|
|
75
|
+
if (typeof AbortSignal === "undefined" || typeof arg !== "object" || arg === null) return undefined;
|
|
76
|
+
if (arg instanceof AbortSignal) return arg;
|
|
77
|
+
const signal = (arg as { signal?: unknown }).signal;
|
|
78
|
+
return signal instanceof AbortSignal ? signal : undefined;
|
|
43
79
|
}
|
|
44
80
|
}
|
package/common/akanGraph.ts
CHANGED
package/common/types.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface FetchPolicy<_Returns = unknown> {
|
|
|
11
11
|
cache?: boolean | number;
|
|
12
12
|
crystalize?: boolean;
|
|
13
13
|
origin?: string;
|
|
14
|
+
/** @deprecated Read by nothing; catch the call's rejection instead. */
|
|
14
15
|
onError?: (error: string) => void;
|
|
15
16
|
token?: string;
|
|
16
17
|
/** @deprecated Read by nothing; a query always answers its whole return. */
|
|
@@ -82,6 +82,8 @@ export interface FetchBridgeCall {
|
|
|
82
82
|
args: UnknownRecord;
|
|
83
83
|
returns: SerializedReturns;
|
|
84
84
|
timeout?: number | false;
|
|
85
|
+
/** A query's; the call rejects on abort whether or not the bridge stops what it relayed. */
|
|
86
|
+
signal?: AbortSignal;
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
/** A transport that is not HTTP: a view inside an MCP host has no network, and reaches the server through the host. */
|
|
@@ -473,9 +475,10 @@ export class FetchClient {
|
|
|
473
475
|
return async (...argData: unknown[]) => {
|
|
474
476
|
const { option, argMap, url } = requestOf(argData);
|
|
475
477
|
const signal = option?.signal;
|
|
478
|
+
if (signal?.aborted) throw this.http.abortError(signal);
|
|
476
479
|
const bridge = this.#bridgeOf(option?.origin);
|
|
477
480
|
if (bridge) {
|
|
478
|
-
const call = this.#viaBridge(bridge, { key, type: "query", endpoint, option, argMap });
|
|
481
|
+
const call = this.#viaBridge(bridge, { key, type: "query", endpoint, option, argMap, signal });
|
|
479
482
|
return parseReturn(await this.#untilAborted(call, signal), { crystalize: option?.crystalize ?? true });
|
|
480
483
|
}
|
|
481
484
|
const headers = this.#makeRequestHeaders(option);
|
|
@@ -644,14 +647,11 @@ export class FetchClient {
|
|
|
644
647
|
async #viaBridge(
|
|
645
648
|
bridge: FetchBridge,
|
|
646
649
|
{
|
|
647
|
-
key,
|
|
648
|
-
type,
|
|
649
650
|
endpoint,
|
|
650
651
|
option,
|
|
651
652
|
argMap,
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
type: FetchBridgeCall["type"];
|
|
653
|
+
...call
|
|
654
|
+
}: Pick<FetchBridgeCall, "key" | "type" | "signal"> & {
|
|
655
655
|
endpoint: SerializedEndpoint;
|
|
656
656
|
option?: FetchPolicy;
|
|
657
657
|
argMap: Map<string, unknown>;
|
|
@@ -659,8 +659,7 @@ export class FetchClient {
|
|
|
659
659
|
) {
|
|
660
660
|
try {
|
|
661
661
|
return await bridge.call({
|
|
662
|
-
|
|
663
|
-
type,
|
|
662
|
+
...call,
|
|
664
663
|
args: Object.fromEntries(argMap),
|
|
665
664
|
returns: endpoint.returns,
|
|
666
665
|
timeout: option?.timeout ?? endpoint.timeout ?? this.http.timeout,
|
|
@@ -171,10 +171,13 @@ export class HttpClient {
|
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
abortError(signal: AbortSignal): unknown {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
174
|
+
return HttpClient.abortErrorOf(signal, this.ErrorCls);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
static abortErrorOf(signal: AbortSignal, ErrorCls?: ErrorConstructor): unknown {
|
|
178
|
+
if (AbortSignals.isTimeout(signal))
|
|
179
|
+
return restoreRemoteError({ error: transportErrorKeyMap[408], data: { status: 408 } }, 408, ErrorCls);
|
|
180
|
+
return AbortSignals.reasonOf(signal);
|
|
178
181
|
}
|
|
179
182
|
|
|
180
183
|
static #uuid(): string {
|
package/fetch/client/wsClient.ts
CHANGED
|
@@ -44,8 +44,9 @@ export interface WsClientOptions {
|
|
|
44
44
|
*/
|
|
45
45
|
onCredentialExpired?: () => unknown;
|
|
46
46
|
/**
|
|
47
|
-
* Messages kept while the socket is down, the oldest dropped past it; 100 unless named, `0` keeps none
|
|
48
|
-
* never queue here: every room is sent again
|
|
47
|
+
* Messages kept while the socket is down, the oldest dropped past it; 100 unless named, `0` keeps none and says so
|
|
48
|
+
* once, and a negative limit or `Infinity` keeps every one. Subscribes never queue here: every room is sent again
|
|
49
|
+
* on open.
|
|
49
50
|
*/
|
|
50
51
|
outboxLimit?: number;
|
|
51
52
|
}
|
|
@@ -102,7 +103,7 @@ export class WsClient {
|
|
|
102
103
|
/** Whether this client has been connected before, so the first open is a start rather than a recovery. */
|
|
103
104
|
#hadConnection = false;
|
|
104
105
|
#outbox: string[] = [];
|
|
105
|
-
#
|
|
106
|
+
#outboxDrops = { count: 0, noneWarned: false };
|
|
106
107
|
#unconnectedWarnTimers = new Map<string, ReturnType<typeof setTimeout>>();
|
|
107
108
|
#jwt: string | null = null;
|
|
108
109
|
#renewing: Promise<unknown> | null = null;
|
|
@@ -203,9 +204,12 @@ export class WsClient {
|
|
|
203
204
|
});
|
|
204
205
|
const queued = this.#outbox;
|
|
205
206
|
this.#outbox = [];
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
const keepsNone = outboxLimitOf(this.#options.outboxLimit) === 0;
|
|
208
|
+
if (this.#outboxDrops.count > 0 && !(keepsNone && this.#outboxDrops.noneWarned)) {
|
|
209
|
+
this.logger.warn(`WebSocket dropped ${this.#outboxDrops.count} oldest queued message(s) while disconnected`);
|
|
210
|
+
this.#outboxDrops.noneWarned ||= keepsNone;
|
|
211
|
+
}
|
|
212
|
+
this.#outboxDrops.count = 0;
|
|
209
213
|
for (const frame of queued) this.#ws?.send(frame);
|
|
210
214
|
this.#handleMessage("connect", undefined);
|
|
211
215
|
};
|
|
@@ -459,7 +463,7 @@ export class WsClient {
|
|
|
459
463
|
for (const timer of this.#unconnectedWarnTimers.values()) clearTimeout(timer);
|
|
460
464
|
this.#unconnectedWarnTimers.clear();
|
|
461
465
|
this.#outbox = [];
|
|
462
|
-
this.#
|
|
466
|
+
this.#outboxDrops.count = 0;
|
|
463
467
|
this.#roomAliasMap.clear();
|
|
464
468
|
this.#ws?.close();
|
|
465
469
|
this.#ws = null;
|
|
@@ -528,16 +532,11 @@ export class WsClient {
|
|
|
528
532
|
return this;
|
|
529
533
|
}
|
|
530
534
|
#enqueue(frame: string) {
|
|
531
|
-
const { outboxLimit } = this.#options;
|
|
532
|
-
const limit =
|
|
533
|
-
outboxLimit !== undefined && Number.isFinite(outboxLimit)
|
|
534
|
-
? Math.max(0, Math.floor(outboxLimit))
|
|
535
|
-
: WsClient.defaultOutboxLimit;
|
|
536
535
|
this.#outbox.push(frame);
|
|
537
|
-
const overflow = this.#outbox.length -
|
|
536
|
+
const overflow = this.#outbox.length - outboxLimitOf(this.#options.outboxLimit);
|
|
538
537
|
if (overflow <= 0) return;
|
|
539
538
|
this.#outbox.splice(0, overflow);
|
|
540
|
-
this.#
|
|
539
|
+
this.#outboxDrops.count += overflow;
|
|
541
540
|
}
|
|
542
541
|
subscribe(option: RoomSubscription) {
|
|
543
542
|
const roomId = WsClient.makeRoomId(option.key, option.data);
|
|
@@ -581,3 +580,8 @@ export class WsClient {
|
|
|
581
580
|
this.#ws?.send(JSON.stringify(payload));
|
|
582
581
|
}
|
|
583
582
|
}
|
|
583
|
+
|
|
584
|
+
const outboxLimitOf = (outboxLimit: number | undefined) => {
|
|
585
|
+
if (outboxLimit === undefined || Number.isNaN(outboxLimit)) return WsClient.defaultOutboxLimit;
|
|
586
|
+
return outboxLimit < 0 ? Number.POSITIVE_INFINITY : Math.floor(outboxLimit);
|
|
587
|
+
};
|
package/package.json
CHANGED
|
@@ -676,7 +676,9 @@ for it to be added.
|
|
|
676
676
|
`/_akan/studio?view=runtime` draws `/_akan/deps` and `/_akan/signal` as one picture, next to Studio's
|
|
677
677
|
source-built views (ERD, Signals, Changes, Framework). It calls the same serializers in process, so it reads the
|
|
678
678
|
container of the process that answered and needs that server running; the header says which (`pid`,
|
|
679
|
-
`serverMode`, `replicaIdx`).
|
|
679
|
+
`serverMode`, `replicaIdx`). It needs no dev builder, so `/_akan/studio` with no `view` lands on it when no
|
|
680
|
+
builder answers; a source-built view asked for then answers 503 inside Studio's nav, saying to open it under
|
|
681
|
+
`akan start`.
|
|
680
682
|
|
|
681
683
|
- **Columns.** Jobs, then services by boot stage, then adaptors by boot stage. An injection always targets
|
|
682
684
|
an earlier stage, so the latest stage stands leftmost and every arrow points from what injects to what it
|
|
@@ -684,8 +686,9 @@ container of the process that answered and needs that server running; the header
|
|
|
684
686
|
- **Edges.** `database`, `service`, `plug` and `memory` injections, one arrow per `from|to|kind` with every
|
|
685
687
|
prop in its title. `env`, `use` and `signal` injections are left out (see §7).
|
|
686
688
|
- **Jobs.** One box per internal class that declares a job, one row per job with its schedule; `resolveField`
|
|
687
|
-
internals are not jobs and are left out.
|
|
688
|
-
|
|
689
|
+
internals are not jobs and are left out. Each row's tooltip names the job in full with its schedule
|
|
690
|
+
(`cron syncAccountBalances · 0 * * * *`). A row the process does not run (`scheduledHere: false`) is greyed,
|
|
691
|
+
and its `skipReason` is the tooltip's second line. Behind the gateway only a `federation` or `all` child answers, so
|
|
689
692
|
with separate `federation` and `batch` replicas every `serverMode: "batch"` job is greyed: it runs on a
|
|
690
693
|
batch child, which Studio never reads.
|
|
691
694
|
- **`disabledModules`** are listed under the diagram.
|
|
@@ -96,18 +96,7 @@ export class StudioDocument {
|
|
|
96
96
|
<header>
|
|
97
97
|
<strong>Akan Studio</strong>
|
|
98
98
|
<span className="muted">{appName}</span>
|
|
99
|
-
|
|
100
|
-
{views.map((view) => (
|
|
101
|
-
<a
|
|
102
|
-
key={view}
|
|
103
|
-
href={hrefOf({ view })}
|
|
104
|
-
title={viewTitles[view]}
|
|
105
|
-
aria-current={view === query.view ? "page" : undefined}
|
|
106
|
-
>
|
|
107
|
-
{viewLabels[view]}
|
|
108
|
-
</a>
|
|
109
|
-
))}
|
|
110
|
-
</nav>
|
|
99
|
+
{StudioDocument.#views(basePath, query)}
|
|
111
100
|
<form method="get" action={basePath} hidden={query.view === "framework"}>
|
|
112
101
|
<input type="hidden" name="view" value={query.view} />
|
|
113
102
|
<input type="hidden" name="editor" value={query.editor} />
|
|
@@ -230,22 +219,47 @@ export class StudioDocument {
|
|
|
230
219
|
);
|
|
231
220
|
}
|
|
232
221
|
|
|
233
|
-
static unavailable(appName:
|
|
222
|
+
static unavailable({ basePath, appName, query, reason }: Omit<StudioDocumentProps, "payload"> & { reason: string }) {
|
|
234
223
|
return (
|
|
235
224
|
<html lang="en">
|
|
236
225
|
<head>
|
|
237
226
|
<meta charSet="utf-8" />
|
|
227
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
238
228
|
<title>{`Akan Studio · ${appName}`}</title>
|
|
239
229
|
<style>{studioStyle}</style>
|
|
240
230
|
</head>
|
|
241
231
|
<body>
|
|
242
|
-
<
|
|
232
|
+
<header>
|
|
233
|
+
<strong>Akan Studio</strong>
|
|
234
|
+
<span className="muted">{appName}</span>
|
|
235
|
+
{StudioDocument.#views(basePath, query)}
|
|
236
|
+
</header>
|
|
237
|
+
<main>
|
|
238
|
+
<p className="empty">{reason}</p>
|
|
239
|
+
</main>
|
|
243
240
|
{StudioDocument.#runtime()}
|
|
244
241
|
</body>
|
|
245
242
|
</html>
|
|
246
243
|
);
|
|
247
244
|
}
|
|
248
245
|
|
|
246
|
+
static #views(basePath: string, query: StudioQuery) {
|
|
247
|
+
return (
|
|
248
|
+
<nav>
|
|
249
|
+
{views.map((view) => (
|
|
250
|
+
<a
|
|
251
|
+
key={view}
|
|
252
|
+
href={StudioDocument.href(basePath, { ...query, view })}
|
|
253
|
+
title={viewTitles[view]}
|
|
254
|
+
aria-current={view === query.view ? "page" : undefined}
|
|
255
|
+
>
|
|
256
|
+
{viewLabels[view]}
|
|
257
|
+
</a>
|
|
258
|
+
))}
|
|
259
|
+
</nav>
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
|
|
249
263
|
static #runtime() {
|
|
250
264
|
return (
|
|
251
265
|
|
|
@@ -348,7 +362,7 @@ export class StudioDocument {
|
|
|
348
362
|
</text>
|
|
349
363
|
{rows.map((row, idx) => (
|
|
350
364
|
<a key={idx} href={openOf(row.at)}>
|
|
351
|
-
{row.skipped ? <title>{row.skipped}</title> : null}
|
|
365
|
+
{row.title || row.skipped ? <title>{[row.title, row.skipped].filter(Boolean).join("\n")}</title> : null}
|
|
352
366
|
<text className={row.skipped ? "skipped" : row.change} x={x + 12} y={row.y + 4}>
|
|
353
367
|
{clip(
|
|
354
368
|
row.change ? `${changeSigns[row.change]} ${row.text}` : row.text,
|
|
@@ -39,10 +39,18 @@ export class StudioRoute {
|
|
|
39
39
|
|
|
40
40
|
async page(req: Request): Promise<Response> {
|
|
41
41
|
const { basePath, appName } = this.#context;
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
const url = new URL(req.url);
|
|
43
|
+
const asked = StudioRoute.queryOf(url);
|
|
44
|
+
const loaded = await this.#load(asked);
|
|
45
|
+
const landed = "error" in loaded && loaded.builderless && !url.searchParams.has("view");
|
|
46
|
+
const query: StudioQuery = landed ? { ...asked, view: "runtime" } : asked;
|
|
47
|
+
const shown = landed ? await this.#load(query) : loaded;
|
|
48
|
+
if ("error" in shown)
|
|
49
|
+
return await StudioRoute.#html(
|
|
50
|
+
StudioDocument.unavailable({ basePath, appName, query, reason: shown.error }),
|
|
51
|
+
503,
|
|
52
|
+
);
|
|
53
|
+
return await StudioRoute.#html(StudioDocument.render({ basePath, appName, payload: shown.payload, query }), 200);
|
|
46
54
|
}
|
|
47
55
|
|
|
48
56
|
async graph(req: Request): Promise<Response> {
|
|
@@ -59,17 +67,21 @@ export class StudioRoute {
|
|
|
59
67
|
return buildGraph ? await buildGraph() : null;
|
|
60
68
|
}
|
|
61
69
|
|
|
62
|
-
async #load(query: StudioQuery): Promise<{ payload: StudioPayload } | { error: string }> {
|
|
70
|
+
async #load(query: StudioQuery): Promise<{ payload: StudioPayload } | { error: string; builderless: boolean }> {
|
|
63
71
|
if (query.view === "runtime") return { payload: this.#context.runtime() };
|
|
64
72
|
try {
|
|
65
73
|
const payload = await this.#payloadOf(query);
|
|
66
74
|
return payload
|
|
67
75
|
? { payload }
|
|
68
|
-
: {
|
|
76
|
+
: {
|
|
77
|
+
error:
|
|
78
|
+
"Akan Studio reads this view from the dev builder; open it under `akan start`. Runtime (live) reads this running server and needs no builder.",
|
|
79
|
+
builderless: true,
|
|
80
|
+
};
|
|
69
81
|
} catch (error) {
|
|
70
82
|
const message = error instanceof Error ? error.message : String(error);
|
|
71
83
|
StudioRoute.logger.warn(`Failed to build the Akan Graph: ${message}`);
|
|
72
|
-
return { error: message };
|
|
84
|
+
return { error: message, builderless: false };
|
|
73
85
|
}
|
|
74
86
|
}
|
|
75
87
|
|
|
@@ -38,10 +38,7 @@ export class StudioRuntimeGraph {
|
|
|
38
38
|
this.columns = [
|
|
39
39
|
{ label: "Jobs", nodes: internals },
|
|
40
40
|
...StudioRuntimeGraph.#byStage(services, deps.stages.service.length, "Services", (node) =>
|
|
41
|
-
StudioRuntimeGraph.#node(node, node.refName, [
|
|
42
|
-
...(node.serviceType === "database" ? ["database"] : []),
|
|
43
|
-
...(node.enabled === false ? ["disabled"] : []),
|
|
44
|
-
]),
|
|
41
|
+
StudioRuntimeGraph.#node(node, node.refName, node.serviceType === "database" ? ["database"] : []),
|
|
45
42
|
),
|
|
46
43
|
...StudioRuntimeGraph.#byStage(adaptors, deps.stages.adaptor.length, "Adaptors", (node) =>
|
|
47
44
|
StudioRuntimeGraph.#node(node, moduleOf.get(node.id) ?? null, node.role ? [node.role] : []),
|
|
@@ -71,12 +68,17 @@ export class StudioRuntimeGraph {
|
|
|
71
68
|
rowsOf(node: StudioNode): Omit<StudioRow, "y">[] {
|
|
72
69
|
const jobs = this.#jobs.get(node.id);
|
|
73
70
|
if (!jobs) return node.detail.length ? [{ text: node.detail.join(" · "), hint: "", at: null }] : [];
|
|
74
|
-
return jobs.map((job) =>
|
|
75
|
-
text
|
|
76
|
-
hint
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
return jobs.map((job) => {
|
|
72
|
+
const text = `${job.type} ${job.key}`;
|
|
73
|
+
const hint = StudioRuntimeGraph.#scheduleOf(job);
|
|
74
|
+
return {
|
|
75
|
+
text,
|
|
76
|
+
hint,
|
|
77
|
+
title: hint ? `${text} · ${hint}` : text,
|
|
78
|
+
at: null,
|
|
79
|
+
...(job.scheduledHere ? {} : { skipped: job.skipReason ?? "not scheduled on this server" }),
|
|
80
|
+
};
|
|
81
|
+
});
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
static #jobsOf(signal: SignalData | null) {
|
package/store/SliceRequest.ts
CHANGED
|
@@ -1,16 +1,37 @@
|
|
|
1
|
+
import { AbortSignals } from "akanjs/common";
|
|
2
|
+
import { HttpClient } from "akanjs/fetch";
|
|
3
|
+
|
|
1
4
|
/** Which of a slice's list requests is current: claiming a new one aborts the older, whose answer would be dropped. */
|
|
2
5
|
export class SliceRequest {
|
|
3
6
|
#latest = 0;
|
|
4
7
|
#controller: AbortController | null = null;
|
|
8
|
+
readonly #httpOf: () => HttpClient | undefined;
|
|
9
|
+
|
|
10
|
+
constructor(httpOf: () => HttpClient | undefined = () => undefined) {
|
|
11
|
+
this.#httpOf = httpOf;
|
|
12
|
+
}
|
|
5
13
|
|
|
6
|
-
claim() {
|
|
14
|
+
claim(callerSignal?: AbortSignal) {
|
|
7
15
|
this.#controller?.abort();
|
|
8
16
|
this.#controller = new AbortController();
|
|
9
17
|
this.#latest += 1;
|
|
10
|
-
|
|
18
|
+
const ownSignal = this.#controller.signal;
|
|
19
|
+
const joined = AbortSignals.join([ownSignal, callerSignal]);
|
|
20
|
+
return {
|
|
21
|
+
ticket: this.#latest,
|
|
22
|
+
signal: joined.signal ?? ownSignal,
|
|
23
|
+
dispose: joined.dispose,
|
|
24
|
+
|
|
25
|
+
endsQuietly: () => ownSignal.aborted || (!!callerSignal?.aborted && !AbortSignals.isTimeout(callerSignal)),
|
|
26
|
+
};
|
|
11
27
|
}
|
|
12
28
|
|
|
13
29
|
isCurrent(ticket: number): boolean {
|
|
14
30
|
return ticket === this.#latest;
|
|
15
31
|
}
|
|
32
|
+
|
|
33
|
+
endSpent(callerSignal: AbortSignal) {
|
|
34
|
+
if (!AbortSignals.isTimeout(callerSignal)) return;
|
|
35
|
+
throw this.#httpOf()?.abortError(callerSignal) ?? HttpClient.abortErrorOf(callerSignal);
|
|
36
|
+
}
|
|
16
37
|
}
|
package/store/action.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DataList, type Dayjs, FIELD_META, type GetStateObject } from "akanjs/base";
|
|
2
2
|
import {
|
|
3
|
-
AbortSignals,
|
|
4
3
|
capitalize,
|
|
5
4
|
type DynamicRecord,
|
|
6
5
|
deepObjectify,
|
|
@@ -913,7 +912,7 @@ export const makeActions = (refName: string, slice: { [key: string]: SerializedS
|
|
|
913
912
|
};
|
|
914
913
|
const sliceAction = slices.reduce((acc, { keys, slice }) => {
|
|
915
914
|
|
|
916
|
-
const requests = new SliceRequest();
|
|
915
|
+
const requests = new SliceRequest(() => fetch.instance?.http);
|
|
917
916
|
|
|
918
917
|
let liveWatch: { signature: string; dispose: () => void } | null = null;
|
|
919
918
|
let liveWatchers = 0;
|
|
@@ -953,6 +952,7 @@ export const makeActions = (refName: string, slice: { [key: string]: SerializedS
|
|
|
953
952
|
modelObjInsight ?? (new cnst.insight().set({ count: modelDataList.length }) as unknown as Insight & BaseInsight);
|
|
954
953
|
const queryArgsIn = (self: SetGet) =>
|
|
955
954
|
(self.get() as { [key: string]: any })[namesOfSlice.queryArgsOfModel] as object[];
|
|
955
|
+
const freshLoad = Symbol("freshLoad");
|
|
956
956
|
|
|
957
957
|
const loadList = async <T>(
|
|
958
958
|
self: SetGet,
|
|
@@ -960,11 +960,9 @@ export const makeActions = (refName: string, slice: { [key: string]: SerializedS
|
|
|
960
960
|
load: (signal: AbortSignal) => Promise<T>,
|
|
961
961
|
commit: (loaded: T, requestedAt: Date) => object,
|
|
962
962
|
) => {
|
|
963
|
-
if (callerSignal?.aborted) return;
|
|
963
|
+
if (callerSignal?.aborted) return requests.endSpent(callerSignal);
|
|
964
964
|
self.set({ [namesOfSlice.modelListLoading]: true });
|
|
965
|
-
const { ticket, signal
|
|
966
|
-
const joined = AbortSignals.join([ownSignal, callerSignal]);
|
|
967
|
-
const signal = joined.signal ?? ownSignal;
|
|
965
|
+
const { ticket, signal, dispose, endsQuietly } = requests.claim(callerSignal);
|
|
968
966
|
try {
|
|
969
967
|
for (let round = 0; round < 2; round += 1) {
|
|
970
968
|
|
|
@@ -978,10 +976,10 @@ export const makeActions = (refName: string, slice: { [key: string]: SerializedS
|
|
|
978
976
|
if (staleAt.getTime() <= requestedAt.getTime()) return;
|
|
979
977
|
}
|
|
980
978
|
} catch (error) {
|
|
981
|
-
if (
|
|
979
|
+
if (endsQuietly()) return;
|
|
982
980
|
throw error;
|
|
983
981
|
} finally {
|
|
984
|
-
|
|
982
|
+
dispose();
|
|
985
983
|
if (requests.isCurrent(ticket)) self.set({ [namesOfSlice.modelListLoading]: false });
|
|
986
984
|
}
|
|
987
985
|
};
|
|
@@ -998,15 +996,16 @@ export const makeActions = (refName: string, slice: { [key: string]: SerializedS
|
|
|
998
996
|
} as FetchInitForm<Input, Filter> & FetchPolicy;
|
|
999
997
|
const queryArgs = new Array(initArgLength).fill(null).map((_, i) => args[i] as object);
|
|
1000
998
|
const defaultModel = new cnst.full().set(initForm.default ?? {}) as unknown as Full;
|
|
1001
|
-
this.set({ [names.defaultModel]: defaultModel
|
|
999
|
+
if (!initForm.signal?.aborted) this.set({ [names.defaultModel]: defaultModel });
|
|
1002
1000
|
await ((this as unknown as DynamicRecord)[namesOfSlice.refreshModel] as (...args: any[]) => Promise<void>)({
|
|
1003
1001
|
...initForm,
|
|
1004
1002
|
queryArgs,
|
|
1003
|
+
[freshLoad]: true,
|
|
1005
1004
|
});
|
|
1006
1005
|
},
|
|
1007
1006
|
[namesOfSlice.refreshModel]: async function (
|
|
1008
1007
|
this: SetGet,
|
|
1009
|
-
initForm: FetchInitForm<Input, Filter> & FetchPolicy & { queryArgs?: any[] } = {},
|
|
1008
|
+
initForm: FetchInitForm<Input, Filter> & FetchPolicy & { queryArgs?: any[]; [freshLoad]?: boolean } = {},
|
|
1010
1009
|
) {
|
|
1011
1010
|
const args = initForm.queryArgs ?? [];
|
|
1012
1011
|
const refreshArgLength = Math.min(args.length, slice.args.length);
|
|
@@ -1027,10 +1026,11 @@ export const makeActions = (refName: string, slice: { [key: string]: SerializedS
|
|
|
1027
1026
|
sort = currentState[namesOfSlice.sortOfModel] as Sort,
|
|
1028
1027
|
invalidate = true,
|
|
1029
1028
|
queryArgs: queryArgsFromInitForm,
|
|
1029
|
+
[freshLoad]: fresh = false,
|
|
1030
1030
|
...fetchPolicy
|
|
1031
1031
|
} = initForm;
|
|
1032
1032
|
const modelOperation = currentState[names.modelOperation] as string;
|
|
1033
|
-
const isCumulative = currentState[namesOfSlice.isCumulativeOfModel] as boolean;
|
|
1033
|
+
const isCumulative = !fresh && (currentState[namesOfSlice.isCumulativeOfModel] as boolean);
|
|
1034
1034
|
const loadedLength = (currentState[namesOfSlice.modelList] as DataList<Light>).length;
|
|
1035
1035
|
|
|
1036
1036
|
const fetchLimit = isCumulative ? Math.max(limit, loadedLength) : limit;
|
|
@@ -1071,6 +1071,7 @@ export const makeActions = (refName: string, slice: { [key: string]: SerializedS
|
|
|
1071
1071
|
[namesOfSlice.sortOfModel]: sort,
|
|
1072
1072
|
[namesOfSlice.pageOfModel]: page,
|
|
1073
1073
|
[names.modelOperation]: "idle",
|
|
1074
|
+
...(fresh ? { [namesOfSlice.isCumulativeOfModel]: false } : {}),
|
|
1074
1075
|
};
|
|
1075
1076
|
},
|
|
1076
1077
|
);
|
|
@@ -1123,10 +1124,8 @@ export const makeActions = (refName: string, slice: { [key: string]: SerializedS
|
|
|
1123
1124
|
const pageOfModel = currentState[namesOfSlice.pageOfModel] as number;
|
|
1124
1125
|
const limitOfModel = (currentState[namesOfSlice.limitOfModel] as number) || 20;
|
|
1125
1126
|
const sortOfModel = currentState[namesOfSlice.sortOfModel] as Sort;
|
|
1126
|
-
if (options?.signal?.aborted) return;
|
|
1127
|
-
const { ticket, signal
|
|
1128
|
-
const joined = AbortSignals.join([ownSignal, options?.signal]);
|
|
1129
|
-
const signal = joined.signal ?? ownSignal;
|
|
1127
|
+
if (options?.signal?.aborted) return requests.endSpent(options.signal);
|
|
1128
|
+
const { ticket, signal, dispose, endsQuietly } = requests.claim(options?.signal);
|
|
1130
1129
|
const modelDataList = await fetchList(
|
|
1131
1130
|
queryArgsOfModel,
|
|
1132
1131
|
(pageOfModel - 1) * limitOfModel + modelList.length,
|
|
@@ -1135,10 +1134,10 @@ export const makeActions = (refName: string, slice: { [key: string]: SerializedS
|
|
|
1135
1134
|
{ ...options, signal },
|
|
1136
1135
|
)
|
|
1137
1136
|
.catch((error: unknown) => {
|
|
1138
|
-
if (
|
|
1137
|
+
if (endsQuietly()) return null;
|
|
1139
1138
|
throw error;
|
|
1140
1139
|
})
|
|
1141
|
-
.finally(
|
|
1140
|
+
.finally(dispose);
|
|
1142
1141
|
if (!modelDataList || !requests.isCurrent(ticket) || queryArgsIn(this) !== queryArgsOfModel) return;
|
|
1143
1142
|
|
|
1144
1143
|
const currentModelList = (this.get() as { [key: string]: any })[namesOfSlice.modelList] as DataList<Light>;
|
package/store/storeInstance.ts
CHANGED
|
@@ -405,7 +405,7 @@ export class StoreInstance {
|
|
|
405
405
|
Logger.verbose(`=> ${k} action dispatched (${Date.now() - start}ms)`);
|
|
406
406
|
} catch (error) {
|
|
407
407
|
const message = error instanceof Error ? error.message : String(error);
|
|
408
|
-
if (silent || AbortSignals.
|
|
408
|
+
if (silent || AbortSignals.isAbortOf(error, args)) Logger.verbose(`${k} action failed silently: ${message}`);
|
|
409
409
|
else {
|
|
410
410
|
this.#showActionErrorMessage(k, error);
|
|
411
411
|
Logger.error(`${k} action error return: ${message}`);
|
|
@@ -5,5 +5,8 @@ export declare class AbortSignals {
|
|
|
5
5
|
dispose: () => void;
|
|
6
6
|
};
|
|
7
7
|
static race<T>(promise: Promise<T>, signal?: AbortSignal): Promise<T>;
|
|
8
|
+
static reasonOf(signal: AbortSignal): unknown;
|
|
9
|
+
static isTimeout(signal: AbortSignal): boolean;
|
|
8
10
|
static isAbort(error: unknown): boolean;
|
|
11
|
+
static isAbortOf(error: unknown, callArgs: unknown[]): boolean;
|
|
9
12
|
}
|
package/types/common/types.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface FetchPolicy<_Returns = unknown> {
|
|
|
9
9
|
cache?: boolean | number;
|
|
10
10
|
crystalize?: boolean;
|
|
11
11
|
origin?: string;
|
|
12
|
+
/** @deprecated Read by nothing; catch the call's rejection instead. */
|
|
12
13
|
onError?: (error: string) => void;
|
|
13
14
|
token?: string;
|
|
14
15
|
/** @deprecated Read by nothing; a query always answers its whole return. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const baseDictionary: import("./dictInfo.d.ts").ServiceDictInfo<[string, string], "ping" | "pingBody" | "pingParam" | "pingQuery" | "wsPing" | "pubsubPing", "payloadTooLarge" | "tooManyRequests" | "gatewayTimeout" | "documentNotFound" | "serverUnreachable" | "serverUnavailable" | "unexpectedResponse" | "immutableField" | "invalidArgument" | "requiredArgument" | "invalidField" | "relationNotFound" | "idempotencyInFlight" | "endpointClosed" | "mutationInApp" | "mutationInRender" | "readOnlyDeployment", "
|
|
1
|
+
export declare const baseDictionary: import("./dictInfo.d.ts").ServiceDictInfo<[string, string], "ping" | "pingBody" | "pingParam" | "pingQuery" | "wsPing" | "pubsubPing", "payloadTooLarge" | "tooManyRequests" | "gatewayTimeout" | "documentNotFound" | "serverUnreachable" | "serverUnavailable" | "unexpectedResponse" | "immutableField" | "invalidArgument" | "requiredArgument" | "invalidField" | "relationNotFound" | "idempotencyInFlight" | "endpointClosed" | "mutationInApp" | "mutationInRender" | "readOnlyDeployment", "error" | "unauthorized" | "edit" | "ok" | "retry" | "approve" | "view" | "remove" | "skip" | "success" | "password" | "save" | "refresh" | "agent" | "stop" | "connecting" | "send" | "cancel" | "copy" | "createModel" | "updateModel" | "removeModel" | "somethingWrong" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "cameraPromptHeader" | "cameraPromptPhoto" | "cameraPromptPicture" | "cameraPromptCancel" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "pageLoadFailed" | "pageNotFound" | "goBack" | "agentIntro" | "agentPlaceholder" | "agentClear" | "agentQuestion" | "agentToolCard" | "agentAnswer" | "agentListen" | "agentVoiceFailed" | "agentAttach" | "agentAttachRemove" | "agentAttachReading" | "agentReferenceRemove" | "agentReferenceFailed" | "agentAttachTooLarge" | "agentAttachUnsupported" | "agentAttachDuplicate" | "agentAttachTooMany" | "agentAttachTooMuch" | "agentAnswerNeeded" | "agentQueue" | "agentQueuePlaceholder" | "agentQueued" | "agentQueueEdit" | "agentQueueCancel" | "agentToolDone" | "agentToolFailed" | "agentToolRunning" | "agentToolResult" | "agentTokens" | "agentTokensOf" | "agentCompactsAt" | "agentSummarizing" | "agentContinue" | "agentKeepGoing" | "agentCmdNew" | "agentCmdRetry" | "agentCmdCompact" | "agentCmdCopy" | "agentCmdHelp" | "agentCmdTools" | "agentHelpIntro" | "agentHelpNote" | "agentNothingToRetry" | "agentNothingToCompact" | "agentCompacted" | "agentSummary" | "agentBusy" | "agentCopied" | "agentCopyFailed" | "agentToolsHead" | "agentToolsState" | "decline" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "noSelection" | "addModel" | "createSuccess" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "cardView" | "tableView" | "exportCsv" | "exportJson" | "actions" | "draftConflict" | "draftApplied" | "draftRestore" | "draftDiscard" | "draftStartOver" | "new">;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { AgentEndpoint, AgentTurn, BaseEndpoint } from "akanjs/signal";
|
|
2
2
|
export declare const dictionary: {
|
|
3
|
-
base: import("./locale.d.ts").DictModule<import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "
|
|
3
|
+
base: import("./locale.d.ts").DictModule<import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "unauthorized" | "edit" | "ok" | "retry" | "approve" | "view" | "remove" | "skip" | "success" | "password" | "save" | "refresh" | "agent" | "stop" | "connecting" | "send" | "cancel" | "copy" | "createModel" | "updateModel" | "removeModel" | "somethingWrong" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "cameraPromptHeader" | "cameraPromptPhoto" | "cameraPromptPicture" | "cameraPromptCancel" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "pageLoadFailed" | "pageNotFound" | "goBack" | "agentIntro" | "agentPlaceholder" | "agentClear" | "agentQuestion" | "agentToolCard" | "agentAnswer" | "agentListen" | "agentVoiceFailed" | "agentAttach" | "agentAttachRemove" | "agentAttachReading" | "agentReferenceRemove" | "agentReferenceFailed" | "agentAttachTooLarge" | "agentAttachUnsupported" | "agentAttachDuplicate" | "agentAttachTooMany" | "agentAttachTooMuch" | "agentAnswerNeeded" | "agentQueue" | "agentQueuePlaceholder" | "agentQueued" | "agentQueueEdit" | "agentQueueCancel" | "agentToolDone" | "agentToolFailed" | "agentToolRunning" | "agentToolResult" | "agentTokens" | "agentTokensOf" | "agentCompactsAt" | "agentSummarizing" | "agentContinue" | "agentKeepGoing" | "agentCmdNew" | "agentCmdRetry" | "agentCmdCompact" | "agentCmdCopy" | "agentCmdHelp" | "agentCmdTools" | "agentHelpIntro" | "agentHelpNote" | "agentNothingToRetry" | "agentNothingToCompact" | "agentCompacted" | "agentSummary" | "agentBusy" | "agentCopied" | "agentCopyFailed" | "agentToolsHead" | "agentToolsState" | "decline" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "noSelection" | "addModel" | "createSuccess" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "cardView" | "tableView" | "exportCsv" | "exportJson" | "actions" | "draftConflict" | "draftApplied" | "draftRestore" | "draftDiscard" | "draftStartOver" | "new">, "base.error.documentNotFound" | "base.error.gatewayTimeout" | "base.error.payloadTooLarge" | "base.error.tooManyRequests" | "base.error.serverUnavailable" | "base.error.serverUnreachable" | "base.error.idempotencyInFlight" | "base.error.unexpectedResponse" | "base.error.mutationInApp" | "base.error.mutationInRender" | "base.error.immutableField" | "base.error.invalidArgument" | "base.error.requiredArgument" | "base.error.invalidField" | "base.error.relationNotFound" | "base.error.endpointClosed" | "base.error.readOnlyDeployment">;
|
|
4
4
|
agentTurn: import("./locale.d.ts").DictModule<import("./locale.d.ts").ScalarTranslatorKey<"agentTurn", AgentTurn, never> | `agentStop.${string}` | `agentStop.${string}.desc`, never>;
|
|
5
5
|
agent: import("./locale.d.ts").DictModule<import("./locale.d.ts").ServiceTranslatorKey<"agent", AgentEndpoint, never>, "agent.error.llmUnavailable" | "agent.error.llmRequestFailed" | "agent.error.contextOverflow" | "agent.error.quotaExceeded" | "agent.error.requestRefused">;
|
|
6
6
|
};
|
|
7
|
-
export declare const Err: import("./trans.d.ts").ErrConstructor<"base.error.documentNotFound" | "base.error.gatewayTimeout" | "base.error.payloadTooLarge" | "base.error.tooManyRequests" | "base.error.serverUnavailable" | "base.error.serverUnreachable" | "base.error.idempotencyInFlight" | "base.error.unexpectedResponse" | "base.error.mutationInApp" | "base.error.mutationInRender" | "base.error.immutableField" | "base.error.invalidArgument" | "base.error.requiredArgument" | "base.error.invalidField" | "base.error.relationNotFound" | "base.error.endpointClosed" | "base.error.readOnlyDeployment" | "agent.error.llmUnavailable" | "agent.error.llmRequestFailed" | "agent.error.contextOverflow" | "agent.error.quotaExceeded" | "agent.error.requestRefused">, translate: (lang: "en" | "ko" | (string & {}) | "zhChs" | "zhCht" | "ja", key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "
|
|
8
|
-
error: (key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "
|
|
9
|
-
info: (key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "
|
|
10
|
-
warning: (key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "
|
|
11
|
-
success: (key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "
|
|
12
|
-
loading: (key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "
|
|
13
|
-
}, getDictionary: (lang: "en" | "ko" | (string & {}) | "zhChs" | "zhCht" | "ja") => object, getAllDictionary: () => import("./trans.d.ts").RootDictionary, __Dict_Key__: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "
|
|
7
|
+
export declare const Err: import("./trans.d.ts").ErrConstructor<"base.error.documentNotFound" | "base.error.gatewayTimeout" | "base.error.payloadTooLarge" | "base.error.tooManyRequests" | "base.error.serverUnavailable" | "base.error.serverUnreachable" | "base.error.idempotencyInFlight" | "base.error.unexpectedResponse" | "base.error.mutationInApp" | "base.error.mutationInRender" | "base.error.immutableField" | "base.error.invalidArgument" | "base.error.requiredArgument" | "base.error.invalidField" | "base.error.relationNotFound" | "base.error.endpointClosed" | "base.error.readOnlyDeployment" | "agent.error.llmUnavailable" | "agent.error.llmRequestFailed" | "agent.error.contextOverflow" | "agent.error.quotaExceeded" | "agent.error.requestRefused">, translate: (lang: "en" | "ko" | (string & {}) | "zhChs" | "zhCht" | "ja", key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "unauthorized" | "edit" | "ok" | "retry" | "approve" | "view" | "remove" | "skip" | "success" | "password" | "save" | "refresh" | "agent" | "stop" | "connecting" | "send" | "cancel" | "copy" | "createModel" | "updateModel" | "removeModel" | "somethingWrong" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "cameraPromptHeader" | "cameraPromptPhoto" | "cameraPromptPicture" | "cameraPromptCancel" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "pageLoadFailed" | "pageNotFound" | "goBack" | "agentIntro" | "agentPlaceholder" | "agentClear" | "agentQuestion" | "agentToolCard" | "agentAnswer" | "agentListen" | "agentVoiceFailed" | "agentAttach" | "agentAttachRemove" | "agentAttachReading" | "agentReferenceRemove" | "agentReferenceFailed" | "agentAttachTooLarge" | "agentAttachUnsupported" | "agentAttachDuplicate" | "agentAttachTooMany" | "agentAttachTooMuch" | "agentAnswerNeeded" | "agentQueue" | "agentQueuePlaceholder" | "agentQueued" | "agentQueueEdit" | "agentQueueCancel" | "agentToolDone" | "agentToolFailed" | "agentToolRunning" | "agentToolResult" | "agentTokens" | "agentTokensOf" | "agentCompactsAt" | "agentSummarizing" | "agentContinue" | "agentKeepGoing" | "agentCmdNew" | "agentCmdRetry" | "agentCmdCompact" | "agentCmdCopy" | "agentCmdHelp" | "agentCmdTools" | "agentHelpIntro" | "agentHelpNote" | "agentNothingToRetry" | "agentNothingToCompact" | "agentCompacted" | "agentSummary" | "agentBusy" | "agentCopied" | "agentCopyFailed" | "agentToolsHead" | "agentToolsState" | "decline" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "noSelection" | "addModel" | "createSuccess" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "cardView" | "tableView" | "exportCsv" | "exportJson" | "actions" | "draftConflict" | "draftApplied" | "draftRestore" | "draftDiscard" | "draftStartOver" | "new"> | import("./locale.d.ts").ScalarTranslatorKey<"agentTurn", AgentTurn, never> | `agentStop.${string}` | `agentStop.${string}.desc` | import("./locale.d.ts").ServiceTranslatorKey<"agent", AgentEndpoint, never>, data?: import("./trans.d.ts").TranslationData) => string, msg: {
|
|
8
|
+
error: (key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "unauthorized" | "edit" | "ok" | "retry" | "approve" | "view" | "remove" | "skip" | "success" | "password" | "save" | "refresh" | "agent" | "stop" | "connecting" | "send" | "cancel" | "copy" | "createModel" | "updateModel" | "removeModel" | "somethingWrong" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "cameraPromptHeader" | "cameraPromptPhoto" | "cameraPromptPicture" | "cameraPromptCancel" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "pageLoadFailed" | "pageNotFound" | "goBack" | "agentIntro" | "agentPlaceholder" | "agentClear" | "agentQuestion" | "agentToolCard" | "agentAnswer" | "agentListen" | "agentVoiceFailed" | "agentAttach" | "agentAttachRemove" | "agentAttachReading" | "agentReferenceRemove" | "agentReferenceFailed" | "agentAttachTooLarge" | "agentAttachUnsupported" | "agentAttachDuplicate" | "agentAttachTooMany" | "agentAttachTooMuch" | "agentAnswerNeeded" | "agentQueue" | "agentQueuePlaceholder" | "agentQueued" | "agentQueueEdit" | "agentQueueCancel" | "agentToolDone" | "agentToolFailed" | "agentToolRunning" | "agentToolResult" | "agentTokens" | "agentTokensOf" | "agentCompactsAt" | "agentSummarizing" | "agentContinue" | "agentKeepGoing" | "agentCmdNew" | "agentCmdRetry" | "agentCmdCompact" | "agentCmdCopy" | "agentCmdHelp" | "agentCmdTools" | "agentHelpIntro" | "agentHelpNote" | "agentNothingToRetry" | "agentNothingToCompact" | "agentCompacted" | "agentSummary" | "agentBusy" | "agentCopied" | "agentCopyFailed" | "agentToolsHead" | "agentToolsState" | "decline" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "noSelection" | "addModel" | "createSuccess" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "cardView" | "tableView" | "exportCsv" | "exportJson" | "actions" | "draftConflict" | "draftApplied" | "draftRestore" | "draftDiscard" | "draftStartOver" | "new"> | import("./locale.d.ts").ScalarTranslatorKey<"agentTurn", AgentTurn, never> | `agentStop.${string}` | `agentStop.${string}.desc` | import("./locale.d.ts").ServiceTranslatorKey<"agent", AgentEndpoint, never>, option?: import("./trans.d.ts").TransMessageOption) => void;
|
|
9
|
+
info: (key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "unauthorized" | "edit" | "ok" | "retry" | "approve" | "view" | "remove" | "skip" | "success" | "password" | "save" | "refresh" | "agent" | "stop" | "connecting" | "send" | "cancel" | "copy" | "createModel" | "updateModel" | "removeModel" | "somethingWrong" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "cameraPromptHeader" | "cameraPromptPhoto" | "cameraPromptPicture" | "cameraPromptCancel" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "pageLoadFailed" | "pageNotFound" | "goBack" | "agentIntro" | "agentPlaceholder" | "agentClear" | "agentQuestion" | "agentToolCard" | "agentAnswer" | "agentListen" | "agentVoiceFailed" | "agentAttach" | "agentAttachRemove" | "agentAttachReading" | "agentReferenceRemove" | "agentReferenceFailed" | "agentAttachTooLarge" | "agentAttachUnsupported" | "agentAttachDuplicate" | "agentAttachTooMany" | "agentAttachTooMuch" | "agentAnswerNeeded" | "agentQueue" | "agentQueuePlaceholder" | "agentQueued" | "agentQueueEdit" | "agentQueueCancel" | "agentToolDone" | "agentToolFailed" | "agentToolRunning" | "agentToolResult" | "agentTokens" | "agentTokensOf" | "agentCompactsAt" | "agentSummarizing" | "agentContinue" | "agentKeepGoing" | "agentCmdNew" | "agentCmdRetry" | "agentCmdCompact" | "agentCmdCopy" | "agentCmdHelp" | "agentCmdTools" | "agentHelpIntro" | "agentHelpNote" | "agentNothingToRetry" | "agentNothingToCompact" | "agentCompacted" | "agentSummary" | "agentBusy" | "agentCopied" | "agentCopyFailed" | "agentToolsHead" | "agentToolsState" | "decline" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "noSelection" | "addModel" | "createSuccess" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "cardView" | "tableView" | "exportCsv" | "exportJson" | "actions" | "draftConflict" | "draftApplied" | "draftRestore" | "draftDiscard" | "draftStartOver" | "new"> | import("./locale.d.ts").ScalarTranslatorKey<"agentTurn", AgentTurn, never> | `agentStop.${string}` | `agentStop.${string}.desc` | import("./locale.d.ts").ServiceTranslatorKey<"agent", AgentEndpoint, never>, option?: import("./trans.d.ts").TransMessageOption) => void;
|
|
10
|
+
warning: (key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "unauthorized" | "edit" | "ok" | "retry" | "approve" | "view" | "remove" | "skip" | "success" | "password" | "save" | "refresh" | "agent" | "stop" | "connecting" | "send" | "cancel" | "copy" | "createModel" | "updateModel" | "removeModel" | "somethingWrong" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "cameraPromptHeader" | "cameraPromptPhoto" | "cameraPromptPicture" | "cameraPromptCancel" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "pageLoadFailed" | "pageNotFound" | "goBack" | "agentIntro" | "agentPlaceholder" | "agentClear" | "agentQuestion" | "agentToolCard" | "agentAnswer" | "agentListen" | "agentVoiceFailed" | "agentAttach" | "agentAttachRemove" | "agentAttachReading" | "agentReferenceRemove" | "agentReferenceFailed" | "agentAttachTooLarge" | "agentAttachUnsupported" | "agentAttachDuplicate" | "agentAttachTooMany" | "agentAttachTooMuch" | "agentAnswerNeeded" | "agentQueue" | "agentQueuePlaceholder" | "agentQueued" | "agentQueueEdit" | "agentQueueCancel" | "agentToolDone" | "agentToolFailed" | "agentToolRunning" | "agentToolResult" | "agentTokens" | "agentTokensOf" | "agentCompactsAt" | "agentSummarizing" | "agentContinue" | "agentKeepGoing" | "agentCmdNew" | "agentCmdRetry" | "agentCmdCompact" | "agentCmdCopy" | "agentCmdHelp" | "agentCmdTools" | "agentHelpIntro" | "agentHelpNote" | "agentNothingToRetry" | "agentNothingToCompact" | "agentCompacted" | "agentSummary" | "agentBusy" | "agentCopied" | "agentCopyFailed" | "agentToolsHead" | "agentToolsState" | "decline" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "noSelection" | "addModel" | "createSuccess" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "cardView" | "tableView" | "exportCsv" | "exportJson" | "actions" | "draftConflict" | "draftApplied" | "draftRestore" | "draftDiscard" | "draftStartOver" | "new"> | import("./locale.d.ts").ScalarTranslatorKey<"agentTurn", AgentTurn, never> | `agentStop.${string}` | `agentStop.${string}.desc` | import("./locale.d.ts").ServiceTranslatorKey<"agent", AgentEndpoint, never>, option?: import("./trans.d.ts").TransMessageOption) => void;
|
|
11
|
+
success: (key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "unauthorized" | "edit" | "ok" | "retry" | "approve" | "view" | "remove" | "skip" | "success" | "password" | "save" | "refresh" | "agent" | "stop" | "connecting" | "send" | "cancel" | "copy" | "createModel" | "updateModel" | "removeModel" | "somethingWrong" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "cameraPromptHeader" | "cameraPromptPhoto" | "cameraPromptPicture" | "cameraPromptCancel" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "pageLoadFailed" | "pageNotFound" | "goBack" | "agentIntro" | "agentPlaceholder" | "agentClear" | "agentQuestion" | "agentToolCard" | "agentAnswer" | "agentListen" | "agentVoiceFailed" | "agentAttach" | "agentAttachRemove" | "agentAttachReading" | "agentReferenceRemove" | "agentReferenceFailed" | "agentAttachTooLarge" | "agentAttachUnsupported" | "agentAttachDuplicate" | "agentAttachTooMany" | "agentAttachTooMuch" | "agentAnswerNeeded" | "agentQueue" | "agentQueuePlaceholder" | "agentQueued" | "agentQueueEdit" | "agentQueueCancel" | "agentToolDone" | "agentToolFailed" | "agentToolRunning" | "agentToolResult" | "agentTokens" | "agentTokensOf" | "agentCompactsAt" | "agentSummarizing" | "agentContinue" | "agentKeepGoing" | "agentCmdNew" | "agentCmdRetry" | "agentCmdCompact" | "agentCmdCopy" | "agentCmdHelp" | "agentCmdTools" | "agentHelpIntro" | "agentHelpNote" | "agentNothingToRetry" | "agentNothingToCompact" | "agentCompacted" | "agentSummary" | "agentBusy" | "agentCopied" | "agentCopyFailed" | "agentToolsHead" | "agentToolsState" | "decline" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "noSelection" | "addModel" | "createSuccess" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "cardView" | "tableView" | "exportCsv" | "exportJson" | "actions" | "draftConflict" | "draftApplied" | "draftRestore" | "draftDiscard" | "draftStartOver" | "new"> | import("./locale.d.ts").ScalarTranslatorKey<"agentTurn", AgentTurn, never> | `agentStop.${string}` | `agentStop.${string}.desc` | import("./locale.d.ts").ServiceTranslatorKey<"agent", AgentEndpoint, never>, option?: import("./trans.d.ts").TransMessageOption) => void;
|
|
12
|
+
loading: (key: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "unauthorized" | "edit" | "ok" | "retry" | "approve" | "view" | "remove" | "skip" | "success" | "password" | "save" | "refresh" | "agent" | "stop" | "connecting" | "send" | "cancel" | "copy" | "createModel" | "updateModel" | "removeModel" | "somethingWrong" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "cameraPromptHeader" | "cameraPromptPhoto" | "cameraPromptPicture" | "cameraPromptCancel" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "pageLoadFailed" | "pageNotFound" | "goBack" | "agentIntro" | "agentPlaceholder" | "agentClear" | "agentQuestion" | "agentToolCard" | "agentAnswer" | "agentListen" | "agentVoiceFailed" | "agentAttach" | "agentAttachRemove" | "agentAttachReading" | "agentReferenceRemove" | "agentReferenceFailed" | "agentAttachTooLarge" | "agentAttachUnsupported" | "agentAttachDuplicate" | "agentAttachTooMany" | "agentAttachTooMuch" | "agentAnswerNeeded" | "agentQueue" | "agentQueuePlaceholder" | "agentQueued" | "agentQueueEdit" | "agentQueueCancel" | "agentToolDone" | "agentToolFailed" | "agentToolRunning" | "agentToolResult" | "agentTokens" | "agentTokensOf" | "agentCompactsAt" | "agentSummarizing" | "agentContinue" | "agentKeepGoing" | "agentCmdNew" | "agentCmdRetry" | "agentCmdCompact" | "agentCmdCopy" | "agentCmdHelp" | "agentCmdTools" | "agentHelpIntro" | "agentHelpNote" | "agentNothingToRetry" | "agentNothingToCompact" | "agentCompacted" | "agentSummary" | "agentBusy" | "agentCopied" | "agentCopyFailed" | "agentToolsHead" | "agentToolsState" | "decline" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "noSelection" | "addModel" | "createSuccess" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "cardView" | "tableView" | "exportCsv" | "exportJson" | "actions" | "draftConflict" | "draftApplied" | "draftRestore" | "draftDiscard" | "draftStartOver" | "new"> | import("./locale.d.ts").ScalarTranslatorKey<"agentTurn", AgentTurn, never> | `agentStop.${string}` | `agentStop.${string}.desc` | import("./locale.d.ts").ServiceTranslatorKey<"agent", AgentEndpoint, never>, option?: import("./trans.d.ts").TransMessageOption) => void;
|
|
13
|
+
}, getDictionary: (lang: "en" | "ko" | (string & {}) | "zhChs" | "zhCht" | "ja") => object, getAllDictionary: () => import("./trans.d.ts").RootDictionary, __Dict_Key__: import("./locale.d.ts").ServiceTranslatorKey<"base", BaseEndpoint, "error" | "unauthorized" | "edit" | "ok" | "retry" | "approve" | "view" | "remove" | "skip" | "success" | "password" | "save" | "refresh" | "agent" | "stop" | "connecting" | "send" | "cancel" | "copy" | "createModel" | "updateModel" | "removeModel" | "somethingWrong" | "connected" | "serverDisconnected" | "refreshing" | "tryReconnecting" | "serverHasProblem" | "checkServerStatus" | "cameraPromptHeader" | "cameraPromptPhoto" | "cameraPromptPicture" | "cameraPromptCancel" | "failed" | "processing" | "processed" | "noData" | "invalidValueError" | "emailInvalidError" | "phoneInvalidError" | "pageLoadFailed" | "pageNotFound" | "goBack" | "agentIntro" | "agentPlaceholder" | "agentClear" | "agentQuestion" | "agentToolCard" | "agentAnswer" | "agentListen" | "agentVoiceFailed" | "agentAttach" | "agentAttachRemove" | "agentAttachReading" | "agentReferenceRemove" | "agentReferenceFailed" | "agentAttachTooLarge" | "agentAttachUnsupported" | "agentAttachDuplicate" | "agentAttachTooMany" | "agentAttachTooMuch" | "agentAnswerNeeded" | "agentQueue" | "agentQueuePlaceholder" | "agentQueued" | "agentQueueEdit" | "agentQueueCancel" | "agentToolDone" | "agentToolFailed" | "agentToolRunning" | "agentToolResult" | "agentTokens" | "agentTokensOf" | "agentCompactsAt" | "agentSummarizing" | "agentContinue" | "agentKeepGoing" | "agentCmdNew" | "agentCmdRetry" | "agentCmdCompact" | "agentCmdCopy" | "agentCmdHelp" | "agentCmdTools" | "agentHelpIntro" | "agentHelpNote" | "agentNothingToRetry" | "agentNothingToCompact" | "agentCompacted" | "agentSummary" | "agentBusy" | "agentCopied" | "agentCopyFailed" | "agentToolsHead" | "agentToolsState" | "decline" | "confirmClose" | "textTooShortError" | "textTooLongError" | "selectTooShortError" | "selectTooLongError" | "numberTooSmallError" | "numberTooBigError" | "passwordNotMatchError" | "selectDateError" | "priceUnit" | "passwordConfirm" | "noOptions" | "noSelection" | "addModel" | "createSuccess" | "updateSuccess" | "removeSuccess" | "sureToRemove" | "irreversibleOps" | "typeNameToRemove" | "yesRemove" | "removeMsg" | "confirmMsg" | "perPage" | "cardView" | "tableView" | "exportCsv" | "exportJson" | "actions" | "draftConflict" | "draftApplied" | "draftRestore" | "draftDiscard" | "draftStartOver" | "new"> | import("./locale.d.ts").ScalarTranslatorKey<"agentTurn", AgentTurn, never> | `agentStop.${string}` | `agentStop.${string}.desc` | import("./locale.d.ts").ServiceTranslatorKey<"agent", AgentEndpoint, never>, __Error_Key__: "base.error.documentNotFound" | "base.error.gatewayTimeout" | "base.error.payloadTooLarge" | "base.error.tooManyRequests" | "base.error.serverUnavailable" | "base.error.serverUnreachable" | "base.error.idempotencyInFlight" | "base.error.unexpectedResponse" | "base.error.mutationInApp" | "base.error.mutationInRender" | "base.error.immutableField" | "base.error.invalidArgument" | "base.error.requiredArgument" | "base.error.invalidField" | "base.error.relationNotFound" | "base.error.endpointClosed" | "base.error.readOnlyDeployment" | "agent.error.llmUnavailable" | "agent.error.llmRequestFailed" | "agent.error.contextOverflow" | "agent.error.quotaExceeded" | "agent.error.requestRefused";
|
|
@@ -19,6 +19,8 @@ export interface FetchBridgeCall {
|
|
|
19
19
|
args: UnknownRecord;
|
|
20
20
|
returns: SerializedReturns;
|
|
21
21
|
timeout?: number | false;
|
|
22
|
+
/** A query's; the call rejects on abort whether or not the bridge stops what it relayed. */
|
|
23
|
+
signal?: AbortSignal;
|
|
22
24
|
}
|
|
23
25
|
/** A transport that is not HTTP: a view inside an MCP host has no network, and reaches the server through the host. */
|
|
24
26
|
export interface FetchBridge {
|
|
@@ -32,6 +32,7 @@ export declare class HttpClient {
|
|
|
32
32
|
post<Returns = unknown>(url: string, data: FormData | Record<string, unknown>, options?: FetchOptions): Promise<Returns>;
|
|
33
33
|
delete<Returns = unknown>(url: string, options?: FetchOptions): Promise<Returns>;
|
|
34
34
|
abortError(signal: AbortSignal): unknown;
|
|
35
|
+
static abortErrorOf(signal: AbortSignal, ErrorCls?: ErrorConstructor): unknown;
|
|
35
36
|
/** The wait before the next try, or `null` when this error is final or the tries are spent. */
|
|
36
37
|
static retryWait(error: unknown, attempt: number, { attempts, ...backoff }: RetryPolicy): number | null;
|
|
37
38
|
static makePath(key: string, paramArgs: SerializedArg[], prefix?: string): string;
|
|
@@ -25,8 +25,9 @@ export interface WsClientOptions {
|
|
|
25
25
|
*/
|
|
26
26
|
onCredentialExpired?: () => unknown;
|
|
27
27
|
/**
|
|
28
|
-
* Messages kept while the socket is down, the oldest dropped past it; 100 unless named, `0` keeps none
|
|
29
|
-
* never queue here: every room is sent again
|
|
28
|
+
* Messages kept while the socket is down, the oldest dropped past it; 100 unless named, `0` keeps none and says so
|
|
29
|
+
* once, and a negative limit or `Infinity` keeps every one. Subscribes never queue here: every room is sent again
|
|
30
|
+
* on open.
|
|
30
31
|
*/
|
|
31
32
|
outboxLimit?: number;
|
|
32
33
|
}
|
|
@@ -19,7 +19,9 @@ export interface StudioDocumentProps {
|
|
|
19
19
|
export declare class StudioDocument {
|
|
20
20
|
#private;
|
|
21
21
|
static render({ basePath, appName, payload, query }: StudioDocumentProps): import("react").JSX.Element;
|
|
22
|
-
static unavailable(appName
|
|
22
|
+
static unavailable({ basePath, appName, query, reason }: Omit<StudioDocumentProps, "payload"> & {
|
|
23
|
+
reason: string;
|
|
24
|
+
}): import("react").JSX.Element;
|
|
23
25
|
static href(basePath: string, { view, module, editor, since }: StudioQuery): string;
|
|
24
26
|
static editorHref(editor: StudioEditor, workspaceRoot: string, at: AkanGraphLocation): string;
|
|
25
27
|
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { HttpClient } from "akanjs/fetch";
|
|
1
2
|
/** Which of a slice's list requests is current: claiming a new one aborts the older, whose answer would be dropped. */
|
|
2
3
|
export declare class SliceRequest {
|
|
3
4
|
#private;
|
|
4
|
-
|
|
5
|
+
constructor(httpOf?: () => HttpClient | undefined);
|
|
6
|
+
claim(callerSignal?: AbortSignal): {
|
|
5
7
|
ticket: number;
|
|
6
8
|
signal: AbortSignal;
|
|
9
|
+
dispose: () => void;
|
|
10
|
+
endsQuietly: () => boolean;
|
|
7
11
|
};
|
|
8
12
|
isCurrent(ticket: number): boolean;
|
|
13
|
+
endSpent(callerSignal: AbortSignal): void;
|
|
9
14
|
}
|
|
@@ -70,13 +70,15 @@ export declare class McpAppBridge {
|
|
|
70
70
|
get toolsListed(): boolean;
|
|
71
71
|
connect(): Promise<McpAppStart>;
|
|
72
72
|
onHostContext(listener: (context: McpHostContext) => void): () => boolean;
|
|
73
|
-
request(method: string, params: Record<string, unknown>, { timeoutMs, timedOut }?: {
|
|
73
|
+
request(method: string, params: Record<string, unknown>, { timeoutMs, timedOut, signal }?: {
|
|
74
74
|
timeoutMs?: number;
|
|
75
75
|
timedOut?: () => Error;
|
|
76
|
+
signal?: AbortSignal;
|
|
76
77
|
}): Promise<unknown>;
|
|
77
78
|
notify(method: string, params: Record<string, unknown>): void;
|
|
78
|
-
callTool(name: string, args: Record<string, unknown>, { timeoutMs }?: {
|
|
79
|
+
callTool(name: string, args: Record<string, unknown>, { timeoutMs, signal }?: {
|
|
79
80
|
timeoutMs?: number;
|
|
81
|
+
signal?: AbortSignal;
|
|
80
82
|
}): Promise<Partial<McpToolResult>>;
|
|
81
83
|
openLink(url: string): Promise<void>;
|
|
82
84
|
downloadFile(contents: McpDownloadContent[]): Promise<void>;
|
package/webkit/McpAppBridge.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { getEnv } from "akanjs/base";
|
|
3
|
+
import { AbortSignals } from "akanjs/common";
|
|
3
4
|
import { type FetchBridge, restoreRemoteError } from "akanjs/fetch";
|
|
4
5
|
import {
|
|
5
6
|
MCP_APP_META,
|
|
@@ -139,15 +140,34 @@ export class McpAppBridge {
|
|
|
139
140
|
request(
|
|
140
141
|
method: string,
|
|
141
142
|
params: Record<string, unknown>,
|
|
142
|
-
{ timeoutMs, timedOut }: { timeoutMs?: number; timedOut?: () => Error } = {},
|
|
143
|
+
{ timeoutMs, timedOut, signal }: { timeoutMs?: number; timedOut?: () => Error; signal?: AbortSignal } = {},
|
|
143
144
|
): Promise<unknown> {
|
|
145
|
+
if (signal?.aborted) return Promise.reject(AbortSignals.reasonOf(signal));
|
|
144
146
|
const id = ++this.#seq;
|
|
145
147
|
return new Promise((resolve, reject) => {
|
|
146
|
-
|
|
148
|
+
|
|
149
|
+
const cancel = () => {
|
|
150
|
+
if (!signal || !this.#pending.delete(id)) return;
|
|
151
|
+
this.notify("notifications/cancelled", { requestId: id });
|
|
152
|
+
reject(AbortSignals.reasonOf(signal));
|
|
153
|
+
};
|
|
154
|
+
const release = () => signal?.removeEventListener("abort", cancel);
|
|
155
|
+
this.#pending.set(id, {
|
|
156
|
+
resolve: (value) => {
|
|
157
|
+
release();
|
|
158
|
+
resolve(value);
|
|
159
|
+
},
|
|
160
|
+
reject: (error) => {
|
|
161
|
+
release();
|
|
162
|
+
reject(error);
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
signal?.addEventListener("abort", cancel, { once: true });
|
|
147
166
|
window.parent.postMessage({ jsonrpc: "2.0", id, method, params }, "*");
|
|
148
167
|
if (timeoutMs)
|
|
149
168
|
setTimeout(() => {
|
|
150
169
|
if (!this.#pending.delete(id)) return;
|
|
170
|
+
release();
|
|
151
171
|
reject(timedOut?.() ?? new Error(`The host did not answer ${method}`));
|
|
152
172
|
}, timeoutMs);
|
|
153
173
|
});
|
|
@@ -157,11 +177,15 @@ export class McpAppBridge {
|
|
|
157
177
|
window.parent.postMessage({ jsonrpc: "2.0", method, params }, "*");
|
|
158
178
|
}
|
|
159
179
|
|
|
160
|
-
async callTool(
|
|
180
|
+
async callTool(
|
|
181
|
+
name: string,
|
|
182
|
+
args: Record<string, unknown>,
|
|
183
|
+
{ timeoutMs, signal }: { timeoutMs?: number; signal?: AbortSignal } = {},
|
|
184
|
+
) {
|
|
161
185
|
return (await this.request(
|
|
162
186
|
"tools/call",
|
|
163
187
|
{ name, arguments: args, _meta: { [MCP_APP_META.view]: true } },
|
|
164
|
-
{ timeoutMs, timedOut: McpAppBridge.#timedOut },
|
|
188
|
+
{ timeoutMs, timedOut: McpAppBridge.#timedOut, signal },
|
|
165
189
|
)) as Partial<McpToolResult>;
|
|
166
190
|
}
|
|
167
191
|
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { AbortSignals } from "akanjs/common";
|
|
3
|
+
import {
|
|
4
|
+
type ErrorResponsePayload,
|
|
5
|
+
type FetchBridge,
|
|
6
|
+
type FetchBridgeCall,
|
|
7
|
+
HttpClient,
|
|
8
|
+
restoreRemoteError,
|
|
9
|
+
} from "akanjs/fetch";
|
|
3
10
|
import { MCP_APP_META, type McpAppSnapshotRecord, type McpToolResult } from "../signal/mcp/mcpProtocol";
|
|
4
11
|
import type { McpAppBridge } from "./McpAppBridge";
|
|
5
12
|
|
|
@@ -29,10 +36,30 @@ export class McpAppFetchBridge implements FetchBridge {
|
|
|
29
36
|
return value;
|
|
30
37
|
}
|
|
31
38
|
const args = McpAppFetchBridge.#defined(request.args);
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
const timeoutMs = McpAppFetchBridge.#deadlineOf(request);
|
|
40
|
+
if (request.type === "mutation")
|
|
41
|
+
return McpAppFetchBridge.#valueOf(request, await this.#bridge.callTool(request.key, args, { timeoutMs }));
|
|
42
|
+
|
|
43
|
+
const deadline = new AbortController();
|
|
44
|
+
const timer =
|
|
45
|
+
timeoutMs === undefined
|
|
46
|
+
? undefined
|
|
47
|
+
: setTimeout(
|
|
48
|
+
() => deadline.abort(new DOMException("The host did not answer in time.", "TimeoutError")),
|
|
49
|
+
timeoutMs,
|
|
50
|
+
);
|
|
51
|
+
const joined = AbortSignals.join([request.signal, deadline.signal]);
|
|
52
|
+
try {
|
|
53
|
+
return McpAppFetchBridge.#valueOf(
|
|
54
|
+
request,
|
|
55
|
+
await this.#bridge.callTool(request.key, args, { signal: joined.signal }),
|
|
56
|
+
);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
throw joined.signal?.aborted ? HttpClient.abortErrorOf(joined.signal) : error;
|
|
59
|
+
} finally {
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
joined.dispose();
|
|
62
|
+
}
|
|
36
63
|
}
|
|
37
64
|
|
|
38
65
|
static #valueOf({ key, returns }: FetchBridgeCall, result: Partial<McpToolResult>) {
|