@howaboua/pi-durable-worker-code 0.0.0-stage → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NOTICE +49 -0
- package/README.md +71 -2
- package/dist/QUICKJS-LICENSE +47 -0
- package/dist/execution/src/cell-contract.d.ts +49 -0
- package/dist/execution/src/cell-observation.d.ts +7 -0
- package/dist/execution/src/cell-progress.d.ts +4 -0
- package/dist/execution/src/cell-task.d.ts +17 -0
- package/dist/execution/src/cell-tools.d.ts +8 -0
- package/dist/execution/src/cells.d.ts +14 -0
- package/dist/execution/src/controls.d.ts +3 -0
- package/dist/execution/src/exec-source.d.ts +21 -0
- package/dist/execution/src/forwarded-tools.d.ts +21 -0
- package/dist/execution/src/forwarding-hook.d.ts +6 -0
- package/dist/execution/src/forwarding.d.ts +15 -0
- package/dist/execution/src/history.d.ts +14 -0
- package/dist/execution/src/invocation-state.d.ts +26 -0
- package/dist/execution/src/invocation.d.ts +35 -0
- package/dist/execution/src/native-tools.d.ts +11 -0
- package/dist/execution/src/nested-call.d.ts +26 -0
- package/dist/execution/src/nested-result.d.ts +8 -0
- package/dist/execution/src/nested.d.ts +3 -0
- package/dist/execution/src/output.d.ts +48 -0
- package/dist/execution/src/presentation.d.ts +59 -0
- package/dist/execution/src/progress.d.ts +23 -0
- package/dist/execution/src/projection.d.ts +5 -0
- package/dist/execution/src/tool-contract.d.ts +34 -0
- package/dist/execution/src/tool-origin.d.ts +11 -0
- package/dist/execution/src/tool-value.d.ts +3 -0
- package/dist/execution/src/wait-session.d.ts +6 -0
- package/dist/history.js +315 -0
- package/dist/index.js +2771 -0
- package/dist/presentation.js +201 -0
- package/dist/quickjs.wasm +0 -0
- package/dist/worker-code/src/guest.d.ts +16 -0
- package/dist/worker-code/src/history.d.ts +6 -0
- package/dist/worker-code/src/index.d.ts +47 -0
- package/dist/worker-code/src/interpreter.d.ts +20 -0
- package/dist/worker-code/src/limits.d.ts +20 -0
- package/dist/worker-code/src/modules.d.ts +13 -0
- package/dist/worker-code/src/output.d.ts +6 -0
- package/dist/worker-code/src/presentation.d.ts +22 -0
- package/dist/worker-code/src/runtime.d.ts +17 -0
- package/dist/worker-code/src/tool-result.d.ts +3 -0
- package/package.json +50 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Igor Warzocha
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
Generic truncation recovery guidance follows Pi Stuff merged PR #552
|
|
2
|
+
revision 84bd5bce60a77c4298484d4b7c810d4fe5220a1b, retaining the MIT notices below.
|
|
3
|
+
|
|
4
|
+
Worker Code is an original bounded runtime adapter for Pi Durable. Its
|
|
5
|
+
runtime-neutral execution coordinator and nested dispatcher are compiled
|
|
6
|
+
from the internal packages/execution source tree. See that directory's NOTICE
|
|
7
|
+
for notices for its shared output and execution contracts.
|
|
8
|
+
|
|
9
|
+
Shared execution contracts are adapted from @howaboua/pi-codex-conversion,
|
|
10
|
+
revision b2006db9def12c373ae48e70044d30f7d6b7e34f.
|
|
11
|
+
Source: https://github.com/IgorWarzocha/howaboua-pi-stuff
|
|
12
|
+
Shared output retention derives from Pi Durable revision
|
|
13
|
+
f5d20047b3ad43d068a8eb61bd4e1f193bedbce6.
|
|
14
|
+
Modifications: Durable-native execution ownership, bounded Worker runtime,
|
|
15
|
+
ordinary-tool dispatch and cancellation cleanup.
|
|
16
|
+
|
|
17
|
+
MIT License
|
|
18
|
+
Copyright (c) 2025 Mario Zechner
|
|
19
|
+
Copyright (c) 2026 Igor Warzocha
|
|
20
|
+
|
|
21
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
22
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
23
|
+
in the Software without restriction, including without limitation the rights
|
|
24
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
25
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
26
|
+
furnished to do so, subject to the following conditions:
|
|
27
|
+
|
|
28
|
+
The above copyright notice and this permission notice shall be included in all
|
|
29
|
+
copies or substantial portions of the Software.
|
|
30
|
+
|
|
31
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
32
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
33
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
34
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
35
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
36
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
37
|
+
SOFTWARE.
|
|
38
|
+
|
|
39
|
+
The compiled quickjs.wasm asset is copied without modification from
|
|
40
|
+
@jitl/quickjs-wasmfile-release-sync 0.32.0. The adapter uses the exact pinned
|
|
41
|
+
quickjs-emscripten 0.32.0 release-sync public API.
|
|
42
|
+
Source: https://github.com/justjake/quickjs-emscripten
|
|
43
|
+
|
|
44
|
+
quickjs-emscripten copyright (c) 2019-2024 Jake Teton-Landis
|
|
45
|
+
QuickJS Javascript Engine copyright (c) 2017-2021 Fabrice Bellard
|
|
46
|
+
QuickJS Javascript Engine copyright (c) 2017-2021 Charlie Gordon
|
|
47
|
+
|
|
48
|
+
The complete upstream MIT license notices accompany the binary in
|
|
49
|
+
dist/QUICKJS-LICENSE. No QuickJS or Pi Durable source was modified or vendored.
|
package/README.md
CHANGED
|
@@ -1,3 +1,72 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Worker Code
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Run bounded JavaScript inside a Worker and call ordinary Pi Durable tools. This package adds `exec` and `wait` to an existing Harness. It also executes app-owned workspace modules for editable tools, tests, prompts and hooks.
|
|
4
|
+
|
|
5
|
+
This is a separate execution product, not native Code or Notebook parity. There is no shell, filesystem, ambient network, Node, Deno, timer or arbitrary npm access in the guest. Each invocation gets a fresh QuickJS context. Workspace persistence and activation belong to the app.
|
|
6
|
+
|
|
7
|
+
## Install in a Worker
|
|
8
|
+
|
|
9
|
+
Install the release package with its pinned Durable peers. It is not published to the npm registry.
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install https://github.com/IgorWarzocha/pi-durable-components/releases/download/v0.9.1/howaboua-pi-durable-worker-code-0.9.1.tgz
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Import the package's compiled WASM through your host bundler. For Wrangler, add a `CompiledWasm` rule for `**/*.wasm` with `fallthrough: false`. No runtime fetching or compilation is needed.
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import wasmModule from "@howaboua/pi-durable-worker-code/quickjs.wasm";
|
|
19
|
+
import { createWorkerCode } from "@howaboua/pi-durable-worker-code";
|
|
20
|
+
|
|
21
|
+
const workerCode = createWorkerCode({
|
|
22
|
+
wasmModule,
|
|
23
|
+
cancelTask: (id, context) => harness.abortTask(id, context),
|
|
24
|
+
});
|
|
25
|
+
registry.install(workerCode.extension);
|
|
26
|
+
// Open your existing Harness with this registry, then bind it.
|
|
27
|
+
workerCode.bind(harness);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Declare static `.wasm` imports as `WebAssembly.Module` in the consuming app's TypeScript configuration. Install extensions before resuming persisted tasks. Select `workerCode.extension` alongside your ordinary tool extensions through the conversation's agent configuration. Do not select native Code or Notebook at the same time. On shutdown, await `workerCode.close()` before closing the Harness.
|
|
31
|
+
|
|
32
|
+
The model calls `exec` with JavaScript source. Guest code awaits `tools[name](args)` and emits with `text(value)` or `image({data,mimeType})`. Original registration names remain intact. `ALL_TOOLS` lists callable contracts. Bare values and returned values are discarded by `exec`.
|
|
33
|
+
|
|
34
|
+
`await yield_control()` publishes progress and wakes the observer without stopping the cell. A running observation returns its `cellId`. `wait` observes that cell or terminates it with `terminate: true`. The optional leading `// @exec: {"yield_time_ms":0,"max_output_tokens":1000}` controls observation, not runtime quotas. Each observation has an independent output budget. An unchanged running snapshot is not repeated.
|
|
35
|
+
|
|
36
|
+
## Execute workspace modules
|
|
37
|
+
|
|
38
|
+
Snapshots are immutable maps of canonical absolute virtual paths to source strings. Imports resolve only inside that snapshot. Relative imports are allowed, root escapes and unknown modules are rejected.
|
|
39
|
+
|
|
40
|
+
For `exec`, factory `modules` accepts a snapshot or a synchronous snapshot provider. Use `modules: () => activeFiles` when the app reloads its workspace. Each cell copies the provider's current source map before awaiting interpreter admission. Already-running cells retain their old imports after activation.
|
|
41
|
+
|
|
42
|
+
`evaluateModule({modules,entry,exportName}, {signal})` reads a JSON data export. Supply `args` to call the export as a function instead. This route is pure. Use it for manifests, fixed tests, prompt rendering and bounded hooks. Guest code receives no ordinary tools or output capabilities.
|
|
43
|
+
|
|
44
|
+
An ordinary app-owned tool can call `executeToolModule(request, api, context, {allowedTools})`. The export is invoked with `request.args` and must return a JSON `ToolExecutionResult`. Grants default to empty. `exec`, `wait` and native-only registrations are always excluded. Granted calls use the same nested Durable task path owned by the current tool, not another cell or direct registration execution. Validation, preparation, wrapping, hooks, results, usage and invocation-ordered controls survive.
|
|
45
|
+
|
|
46
|
+
Host wrappers for impure guest modules must declare `replay: "unsafe"`. Never expose credentials, bindings, registry mutation or arbitrary host callbacks to the guest. Keep capability grants and fixed validation outside editable source. The app owns source versions, passing test receipts and atomic activation of its ordinary extension registrations.
|
|
47
|
+
|
|
48
|
+
## Bounds and recovery
|
|
49
|
+
|
|
50
|
+
`limits` is trusted host configuration and can only reduce `DEFAULT_WORKER_CODE_LIMITS`. Defaults are 8 MiB guest heap, 256 KiB stack, 64 interrupt polls, 4096 promise jobs, 128 tool calls, 32 pending bridge calls, 64 KiB source per file, 256 KiB total module snapshot, 128 modules, 32 KiB arguments, 128 KiB JSON results, 256 KiB total emitted output and 30 seconds waiting for host work. Heap cannot be configured below 256 KiB or stack below 16 KiB because context startup needs memory.
|
|
51
|
+
|
|
52
|
+
All component instances in an isolate share one compiled interpreter with 16 MiB initial and 32 MiB maximum imported WASM memory. Admission allows at most four runtimes and 24 MiB reserved guest heaps across all Harness owners. Three default-size guests can run together. Admission fails immediately when exhausted, avoiding nested-call deadlocks. Reuse the same imported module identity. `budget()` reports admission and linear-memory usage.
|
|
53
|
+
|
|
54
|
+
Fuel and job counts bound interpreted loops. A wall timer only bounds host I/O waits. Expensive interpreter builtins still rely on the hosting Worker's CPU quota as the outer limit. Tool JSON is never silently truncated. Transport and output overflow fail visibly. Images count against the same output budget.
|
|
55
|
+
|
|
56
|
+
Cells and their owned calls are cancelled and joined. Interrupted cells do not replay source. Unsafe nested effects remain reported as potentially partially executed. Guest globals do not survive a process restart. Reinstall the app's active immutable source snapshot before resuming its existing journal.
|
|
57
|
+
|
|
58
|
+
## Validation
|
|
59
|
+
|
|
60
|
+
From the repository, run `node --experimental-strip-types --test packages/worker-code/test/workflows.test.mjs`. This executes the actual compiled WASM on workerd with genuine Durable registrations. It covers concurrent impure handlers, hooks and wrapped results, isolation, module imports, fuel, jobs, heap and transport limits, incremental output, yield, wait, cancellation and isolate-wide admission across separate Harness owners.
|
|
61
|
+
|
|
62
|
+
The consuming app must separately prove its persistence, lease fencing, activation and abrupt process-loss recovery. This package does not supply another scheduler or journal.
|
|
63
|
+
|
|
64
|
+
## Headless presentations
|
|
65
|
+
|
|
66
|
+
`@howaboua/pi-durable-worker-code/presentation` exports `workerCodeCapability`, `workerCodeSummary` and `workerCodeDetail`. These browser-safe descriptors are structurally compatible with the UI SDK without importing it. They perform no I/O and have no renderer.
|
|
67
|
+
|
|
68
|
+
The host supplies `{cell, result}`. Each field is explicitly nullable. A cell is `{id, status}`, with a canonical positive decimal task ID and the actual coordinator status: `running`, `completed`, `failed`, `aborted` or `interrupted`. Read these from exec/wait receipt details `cellId` and `status`. Do not substitute host request activity for cell lifecycle.
|
|
69
|
+
|
|
70
|
+
`result: null` means output has not been acquired. Otherwise pass the ordinary execution receipt. Parsing retains text, base64 images, `isError`, JSON details and structured diagnostics. Omitted fields normalize to empty content, false, null and empty diagnostics. Usage and controls remain Durable-owned, not presentation actions. Summary selects title, cell identity and status, output availability and nullable `isError`. Detail selects the full validated state. Summary can request detail without acquiring it.
|
|
71
|
+
|
|
72
|
+
The host authorizes `exec` and `wait` through ordinary registrations and publishes acquired receipts on the declared `results` stream. This is host publication, not a new runtime stream or tool bridge. Each receipt is one bounded observation, not cumulative output. Presentation disposal does not terminate cells, roll back effects or authorize replay. Acquisition, binding and cancellation policy belong to the host.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
quickjs-emscripten:
|
|
2
|
+
The MIT License
|
|
3
|
+
|
|
4
|
+
quickjs-emscripten copyright (c) 2019-2024 Jake Teton-Landis
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
quickjs:
|
|
26
|
+
QuickJS Javascript Engine
|
|
27
|
+
|
|
28
|
+
Copyright (c) 2017-2021 Fabrice Bellard
|
|
29
|
+
Copyright (c) 2017-2021 Charlie Gordon
|
|
30
|
+
|
|
31
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
32
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
33
|
+
in the Software without restriction, including without limitation the rights
|
|
34
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
35
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
36
|
+
furnished to do so, subject to the following conditions:
|
|
37
|
+
|
|
38
|
+
The above copyright notice and this permission notice shall be included in
|
|
39
|
+
all copies or substantial portions of the Software.
|
|
40
|
+
|
|
41
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
42
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
43
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
44
|
+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
45
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
46
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
47
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Context, JsonValue } from "@earendil-works/chord";
|
|
2
|
+
import type { ConversationId, Harness, JsonObject, TaskId, ToolExecutionApi, ToolExecutionResult, ToolRegistration } from "@earendil-works/pi-durable";
|
|
3
|
+
import type { ForwardedToolCalls } from "./forwarded-tools.ts";
|
|
4
|
+
/** Drivers own language/runtime globals. The coordinator owns durable execution and tool calls. */
|
|
5
|
+
export interface CellEngine {
|
|
6
|
+
run(input: JsonObject, api: CellEngineApi, context: Context): Promise<ToolExecutionResult>;
|
|
7
|
+
close(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export interface CellEngineApi {
|
|
10
|
+
readonly taskId: TaskId;
|
|
11
|
+
readonly conversationId: ConversationId;
|
|
12
|
+
readonly signal: AbortSignal;
|
|
13
|
+
readonly toolApi: ToolExecutionApi;
|
|
14
|
+
/** Current selected, wrapped registrations, excluding this execution surface. */
|
|
15
|
+
readonly registrations: readonly ToolRegistration[];
|
|
16
|
+
readonly tools: Readonly<Record<string, (args: JsonValue, signal?: AbortSignal) => Promise<ToolExecutionResult & {
|
|
17
|
+
readonly callId: string;
|
|
18
|
+
}>>>;
|
|
19
|
+
/** Replace the durable driver snapshot, including text, images and runtime errors. */
|
|
20
|
+
publish(result: ToolExecutionResult, context: Context): Promise<void>;
|
|
21
|
+
/** Wake exec/wait observers without settling or cancelling this cell. */
|
|
22
|
+
requestYield(context: Context): Promise<void>;
|
|
23
|
+
/** Optional driver-specific progress, persisted without a provider transcript. */
|
|
24
|
+
checkpoint(value: JsonValue, context: Context): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export type CellObservation = {
|
|
27
|
+
/** A mistaken shell handle was polled directly, not an incremental cell snapshot. */
|
|
28
|
+
readonly recoveredSession?: true;
|
|
29
|
+
readonly cellId: TaskId<ToolExecutionResult>;
|
|
30
|
+
readonly status: "running" | "completed" | "failed" | "aborted" | "interrupted";
|
|
31
|
+
readonly result: ToolExecutionResult;
|
|
32
|
+
readonly forwardedToolCalls?: ForwardedToolCalls;
|
|
33
|
+
readonly checkpoint?: JsonValue;
|
|
34
|
+
};
|
|
35
|
+
export type CellCoordinatorOptions = {
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly engine: CellEngine;
|
|
38
|
+
readonly surfaceTools: readonly string[];
|
|
39
|
+
/** Surface registrations that may also be called through ordinary nested dispatch. */
|
|
40
|
+
readonly callableSurfaceTools?: readonly string[];
|
|
41
|
+
/** Admit queued normal cells; the engine owns serial execution and cancellation. */
|
|
42
|
+
readonly normalQueueLimit?: number;
|
|
43
|
+
/** Combined live and isolated admission bound where the runtime shares worker slots. */
|
|
44
|
+
readonly activeCellLimit?: number;
|
|
45
|
+
/** Notebook admits independent checkpoint-copy cells alongside its single live cell. */
|
|
46
|
+
readonly isolatedConcurrency?: number;
|
|
47
|
+
/** Individual task cancellation is a host operation, not part of the tool invocation API. */
|
|
48
|
+
readonly cancelTask: (id: TaskId, context: Context) => ReturnType<Harness["abortTask"]>;
|
|
49
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Context } from "@earendil-works/chord";
|
|
2
|
+
import { type TaskId, type ToolExecutionApi, type ToolExecutionResult } from "@earendil-works/pi-durable";
|
|
3
|
+
import type { CellObservation } from "./cell-contract.ts";
|
|
4
|
+
import { type InvocationState } from "./invocation-state.ts";
|
|
5
|
+
/** Task documents retire on settlement. Completed cells retain driver snapshots here. */
|
|
6
|
+
export declare const CellStateDoc: import("@earendil-works/pi-durable").ConversationDocFamilyToken<InvocationState, null>;
|
|
7
|
+
export declare function observeCell(kind: string, id: TaskId<ToolExecutionResult>, api: ToolExecutionApi, context: Context, budget?: number): Promise<CellObservation>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Context } from "@earendil-works/chord";
|
|
2
|
+
import { type TaskId, type ToolExecutionApi, type ToolExecutionResult } from "@earendil-works/pi-durable";
|
|
3
|
+
/** The observer owns subscriptions and in-flight callbacks until exec/wait returns. */
|
|
4
|
+
export declare function observeCellProgress(id: TaskId<ToolExecutionResult>, api: ToolExecutionApi, context: Context, budget: number): Promise<() => Promise<void>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type JsonObject, type TaskId, type ToolExecutionResult } from "@earendil-works/pi-durable";
|
|
2
|
+
import type { CellCoordinatorOptions } from "./cell-contract.ts";
|
|
3
|
+
import { createNestedToolTask } from "./nested.ts";
|
|
4
|
+
/** Own the durable cell phases and the process-local driver lifetime together. */
|
|
5
|
+
export declare function createCellTask(options: CellCoordinatorOptions, nestedTask: ReturnType<typeof createNestedToolTask>): {
|
|
6
|
+
task: import("@earendil-works/pi-durable").Task<JsonObject, {
|
|
7
|
+
phase: "start";
|
|
8
|
+
} | {
|
|
9
|
+
phase: "execute";
|
|
10
|
+
}, ToolExecutionResult, Record<string, never>>;
|
|
11
|
+
readonly closed: boolean;
|
|
12
|
+
observeYield(id: TaskId): {
|
|
13
|
+
wake: Promise<void>;
|
|
14
|
+
consume(): boolean;
|
|
15
|
+
};
|
|
16
|
+
close(): Promise<void>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Context, type JsonValue } from "@earendil-works/chord";
|
|
2
|
+
import type { TaskRuntime, ToolControl, ToolExecutionApi, ToolExecutionResult, ToolRegistration } from "@earendil-works/pi-durable";
|
|
3
|
+
import type { CellCoordinatorOptions } from "./cell-contract.ts";
|
|
4
|
+
import { createNestedToolTask } from "./nested.ts";
|
|
5
|
+
/** Preserve invocation order for controls even when nested tools settle out of order. */
|
|
6
|
+
export declare function cellTools(runtime: Pick<TaskRuntime<unknown, unknown, unknown, Record<string, never>>, "taskId" | "signal" | "waitForTask" | "report">, toolApi: ToolExecutionApi, registrations: readonly ToolRegistration[], nestedTask: ReturnType<typeof createNestedToolTask>, controls: (ToolControl | undefined)[], cancelTask: CellCoordinatorOptions["cancelTask"], cellContext: Context): Record<string, (args: JsonValue, signal?: AbortSignal) => Promise<ToolExecutionResult & {
|
|
7
|
+
readonly callId: string;
|
|
8
|
+
}>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Context } from "@earendil-works/chord";
|
|
2
|
+
import { type Harness, type JsonObject, type TaskId, type ToolExecutionApi, type ToolExecutionResult } from "@earendil-works/pi-durable";
|
|
3
|
+
import type { CellCoordinatorOptions, CellObservation } from "./cell-contract.ts";
|
|
4
|
+
export type { CellCoordinatorOptions } from "./cell-contract.ts";
|
|
5
|
+
export declare function createCellCoordinator(options: CellCoordinatorOptions): {
|
|
6
|
+
extension: import("@earendil-works/pi-durable").Extension<import("@earendil-works/pi-durable").ToolRegistration>;
|
|
7
|
+
/** Shared nested dispatch for guest handlers owned by an ordinary tool task. */
|
|
8
|
+
nestedTask: import("@earendil-works/pi-durable").Task<import("./nested-call.ts").NestedInput, import("./nested-call.ts").Checkpoint, ToolExecutionResult, Record<string, never>>;
|
|
9
|
+
bind(harness: Pick<Harness, "conversation">): void;
|
|
10
|
+
start(input: JsonObject, api: ToolExecutionApi, context: Context): Promise<TaskId<ToolExecutionResult>>;
|
|
11
|
+
wait(id: TaskId<ToolExecutionResult>, api: ToolExecutionApi, context: Context, yieldTimeMs?: number, maxTokens?: number, sessionYieldTimeMs?: number): Promise<CellObservation>;
|
|
12
|
+
cancel(id: TaskId<ToolExecutionResult>, api: ToolExecutionApi, context: Context, maxTokens?: number): Promise<CellObservation>;
|
|
13
|
+
close: () => Promise<void>;
|
|
14
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ToolControl } from "@earendil-works/pi-durable";
|
|
2
|
+
/** Nested-cell policy: union additions, any successful termination, first handoff in call order. */
|
|
3
|
+
export declare function combineControls(controls: readonly (ToolControl | undefined)[], allowTermination?: boolean): ToolControl | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const MAX_CODE_MODE_OUTPUT_TOKENS = 100000;
|
|
2
|
+
export declare const DEFAULT_CODE_MODE_EXEC_YIELD_MS = 30000;
|
|
3
|
+
export declare const TRUNCATED_OUTPUT_NOTICE = "[Output truncated; later results may be omitted. Narrow reads or fetch missing help separately. Do not rerun side effects for output.]";
|
|
4
|
+
/** Grow top-level wait observations after incomplete receipts. Requested waits remain a floor. */
|
|
5
|
+
export declare function adaptiveWaitMs(requestedMs: number, previousIncompleteWaits: number): number;
|
|
6
|
+
export declare const CODE_MODE_EXEC_GRAMMAR: string;
|
|
7
|
+
export declare const CODE_MODE_EXEC_CONSTRAINED_SAMPLING: {
|
|
8
|
+
readonly type: "grammar";
|
|
9
|
+
readonly variants: {
|
|
10
|
+
readonly openai_lark: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
/** A source cell with optional leading execution budget. Both drivers share this boundary. */
|
|
14
|
+
export declare function parseExecSource(source: string, capabilities?: {
|
|
15
|
+
allowIsolated?: boolean;
|
|
16
|
+
}): {
|
|
17
|
+
code: string;
|
|
18
|
+
yieldTimeMs: number | null;
|
|
19
|
+
maxOutputTokens: number | null;
|
|
20
|
+
isolated: boolean;
|
|
21
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ExecutionResultReceipt, type JsonValue } from "./presentation.ts";
|
|
2
|
+
export type ForwardedToolStatus = "pending" | "running" | "completed" | "failed" | "aborted" | "interrupted";
|
|
3
|
+
/** Display data only; omitted arguments are never substituted into execution. */
|
|
4
|
+
export interface ForwardedToolCall {
|
|
5
|
+
readonly callId: string;
|
|
6
|
+
readonly parentCallId: string;
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly arguments?: JsonValue;
|
|
9
|
+
readonly status: ForwardedToolStatus;
|
|
10
|
+
readonly result: ExecutionResultReceipt | null;
|
|
11
|
+
readonly omittedFields: readonly ("arguments" | "result")[];
|
|
12
|
+
}
|
|
13
|
+
/** Cumulative cell snapshot. Repeated exec/wait observations retain call identities. */
|
|
14
|
+
export interface ForwardedToolCalls {
|
|
15
|
+
readonly version: 1;
|
|
16
|
+
readonly cellId: string;
|
|
17
|
+
readonly calls: readonly ForwardedToolCall[];
|
|
18
|
+
readonly omittedCalls: number;
|
|
19
|
+
}
|
|
20
|
+
/** Old receipts return null. A present malformed receipt is an error, never an inferred call. */
|
|
21
|
+
export declare function parseForwardedToolCalls(details: unknown): ForwardedToolCalls | null;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Harness } from "@earendil-works/pi-durable";
|
|
2
|
+
/** Observe real native dispatch, including children made by a native tool's own API. */
|
|
3
|
+
export declare function forwardingHook(): {
|
|
4
|
+
bind(harness: Pick<Harness, "conversation">): void;
|
|
5
|
+
hook: import("@earendil-works/pi-durable").HookRegistration;
|
|
6
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ConversationId, type TaskId, type ToolExecutionResult, type Tx } from "@earendil-works/pi-durable";
|
|
2
|
+
import type { ForwardedToolCall, ForwardedToolCalls, ForwardedToolStatus } from "./forwarded-tools.ts";
|
|
3
|
+
import type { ExecutionResultReceipt } from "./presentation.ts";
|
|
4
|
+
/** The budget applies only to display copies, never invocation inputs or runtime results. */
|
|
5
|
+
export declare function boundForwardedToolCalls(value: ForwardedToolCalls, budget: number): ForwardedToolCalls;
|
|
6
|
+
export declare function displayResult(result: ToolExecutionResult, budget: number): ExecutionResultReceipt;
|
|
7
|
+
export declare function forwardedStatus(result: ToolExecutionResult, fallback: ForwardedToolStatus): ForwardedToolStatus;
|
|
8
|
+
/** Update the current cell's existing receipt; no transcript entry or parallel history. */
|
|
9
|
+
export declare function forwardCall(tx: Tx, cellId: TaskId | undefined, call: ForwardedToolCall, admission?: boolean, nativeTask?: {
|
|
10
|
+
taskId: TaskId;
|
|
11
|
+
ownerTaskId: TaskId;
|
|
12
|
+
}): Promise<void>;
|
|
13
|
+
export declare function forwardInvocationResult(tx: Tx, taskId: TaskId, result: ToolExecutionResult, status: ForwardedToolStatus): Promise<void>;
|
|
14
|
+
/** Acquire native progress/results while the caller's task-scoped receipts still exist. */
|
|
15
|
+
export declare function captureNativeCalls(tx: Tx, conversationId: ConversationId, owner: TaskId, cellId: TaskId | undefined): Promise<void>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Context } from "@earendil-works/chord";
|
|
2
|
+
import type { ConversationId, Harness } from "@earendil-works/pi-durable";
|
|
3
|
+
import type { ForwardedToolCalls } from "./forwarded-tools.ts";
|
|
4
|
+
export interface ExecutionHistoryRequest {
|
|
5
|
+
readonly conversationId: ConversationId;
|
|
6
|
+
readonly cellIds: readonly string[];
|
|
7
|
+
readonly maxOutputTokens?: number;
|
|
8
|
+
}
|
|
9
|
+
type HistoryHarness = Pick<Harness, "conversation" | "getTask" | "commit">;
|
|
10
|
+
/** Verified retained direct calls only, not a reconstructed native descendant graph.
|
|
11
|
+
* Current fork-visible history excludes later results from the parent conversation.
|
|
12
|
+
*/
|
|
13
|
+
export declare function executionHistory(mode: "notebook" | "code" | "worker-code"): (harness: HistoryHarness, request: ExecutionHistoryRequest, context: Context) => Promise<ReadonlyMap<string, ForwardedToolCalls>>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type JsonRepresentation, type JsonValue } from "@earendil-works/chord";
|
|
2
|
+
import { type TaskId, type ToolExecutionResult } from "@earendil-works/pi-durable";
|
|
3
|
+
import type { ForwardedToolCalls } from "./forwarded-tools.ts";
|
|
4
|
+
type StoredResult = JsonRepresentation<ToolExecutionResult>;
|
|
5
|
+
export type InvocationState = {
|
|
6
|
+
result: StoredResult;
|
|
7
|
+
checkpoint?: JsonValue;
|
|
8
|
+
yieldCount?: number;
|
|
9
|
+
isolated?: boolean;
|
|
10
|
+
droppedBytes?: number;
|
|
11
|
+
droppedLines?: number;
|
|
12
|
+
forwardingCellId?: TaskId;
|
|
13
|
+
forwardingBudget?: number;
|
|
14
|
+
forwardedToolCalls?: JsonRepresentation<ForwardedToolCalls>;
|
|
15
|
+
/** Admission identities only, bounded to retained display calls; native slots may retire first. */
|
|
16
|
+
forwardedNativeTasks?: {
|
|
17
|
+
callId: string;
|
|
18
|
+
taskId: TaskId;
|
|
19
|
+
ownerTaskId: TaskId;
|
|
20
|
+
}[];
|
|
21
|
+
};
|
|
22
|
+
export declare const InvocationDoc: import("@earendil-works/pi-durable").TaskDocToken<InvocationState>;
|
|
23
|
+
/** Version-one task receipts remain readable after their task documents retire. */
|
|
24
|
+
export declare function readStoredResult(result: ToolExecutionResult): ToolExecutionResult;
|
|
25
|
+
export declare function storeResult(result: ToolExecutionResult): StoredResult;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type Context } from "@earendil-works/chord";
|
|
2
|
+
import type { TextContent } from "@earendil-works/pi-ai";
|
|
3
|
+
import { type TaskRuntime, type ToolDiagnostic, type ToolExecutionApi, type ToolExecutionResult, type ToolRegistration } from "@earendil-works/pi-durable";
|
|
4
|
+
import { OutputBuffer, type OutputLimits } from "./output.ts";
|
|
5
|
+
import { Progress } from "./progress.ts";
|
|
6
|
+
export declare function executionError(code: string, message: string): ToolExecutionResult;
|
|
7
|
+
export declare function errorText(error: unknown): string;
|
|
8
|
+
/** One invocation owns its output, progress commits, environment and child-task API. */
|
|
9
|
+
export declare function createInvocation<I, S, R, H extends object>(runtime: TaskRuntime<I, S, R, H>, tool: Pick<ToolRegistration, "outputLimits" | "replay">, context: Context): {
|
|
10
|
+
/** Resolve the environment after the tracker exists, so environment failures still settle bounded hook results. */
|
|
11
|
+
executionApi(): Promise<ToolExecutionApi>;
|
|
12
|
+
finish(result: ToolExecutionResult): Promise<{
|
|
13
|
+
result: ToolExecutionResult;
|
|
14
|
+
pending: {
|
|
15
|
+
promise: Promise<void>;
|
|
16
|
+
resolve(): void;
|
|
17
|
+
reject(error: unknown): void;
|
|
18
|
+
}[];
|
|
19
|
+
retained: {
|
|
20
|
+
readonly text: string;
|
|
21
|
+
readonly droppedBytes: number;
|
|
22
|
+
readonly droppedLines: number;
|
|
23
|
+
};
|
|
24
|
+
content: (import("@earendil-works/pi-ai").ImageContent | TextContent)[];
|
|
25
|
+
}>;
|
|
26
|
+
stop(error: unknown): Promise<void>;
|
|
27
|
+
limits: OutputLimits;
|
|
28
|
+
output: OutputBuffer;
|
|
29
|
+
progress: Progress;
|
|
30
|
+
};
|
|
31
|
+
export declare function boundResult(result: ToolExecutionResult, limits: OutputLimits): ToolExecutionResult;
|
|
32
|
+
export declare function truncation(dropped: {
|
|
33
|
+
droppedLines: number;
|
|
34
|
+
droppedBytes: number;
|
|
35
|
+
}, retain?: "head" | "tail"): ToolDiagnostic;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Context } from "@earendil-works/chord";
|
|
2
|
+
import { type JsonObject, type NestedToolExecutionResult, type TaskRuntime } from "@earendil-works/pi-durable";
|
|
3
|
+
export declare function nativeToolCalls<I, S, R, H extends object>(runtime: TaskRuntime<I, S, R, H>, callId: string, replay: "safe" | "unsafe" | undefined, assertLive: () => void, context: Context): {
|
|
4
|
+
execute: (name: string, args: JsonObject, context: Context, options?: {
|
|
5
|
+
readonly key?: string;
|
|
6
|
+
readonly progress?: boolean;
|
|
7
|
+
}) => Promise<NestedToolExecutionResult>;
|
|
8
|
+
finish(): Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
/** Custom cell callers own native nested slots too, including after recovery. */
|
|
11
|
+
export declare function cleanupNativeCalls<I, S, R, H extends object>(runtime: TaskRuntime<I, S, R, H>, context: Context): Promise<void>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { JsonValue } from "@earendil-works/chord";
|
|
2
|
+
import type { ToolCall } from "@earendil-works/pi-ai";
|
|
3
|
+
import { type Agent, type HookApi, type JsonObject, type TaskId, type TaskRuntime, type ToolExecutionResult, type ToolHookCall, type ToolHooks, type ToolRegistration } from "@earendil-works/pi-durable";
|
|
4
|
+
export type NestedInput = {
|
|
5
|
+
name: string;
|
|
6
|
+
arguments: JsonValue;
|
|
7
|
+
cellId?: TaskId;
|
|
8
|
+
parent?: NonNullable<ToolHookCall["parent"]>;
|
|
9
|
+
};
|
|
10
|
+
export type Checkpoint = {
|
|
11
|
+
phase: "call";
|
|
12
|
+
} | {
|
|
13
|
+
phase: "execute";
|
|
14
|
+
arguments: JsonObject;
|
|
15
|
+
replay: "safe" | "unsafe";
|
|
16
|
+
};
|
|
17
|
+
export type Runtime = TaskRuntime<NestedInput, Checkpoint, ToolExecutionResult, Record<string, never>>;
|
|
18
|
+
export declare function nestedCall(runtime: Runtime, input: NestedInput): ToolHookCall;
|
|
19
|
+
export declare function checked(tool: ToolRegistration, call: ToolCall, args: unknown): JsonObject;
|
|
20
|
+
/** Decode equivalent structured requests before registration preparation and hooks. */
|
|
21
|
+
export declare function prepareNestedInput(tool: ToolRegistration, input: unknown): unknown;
|
|
22
|
+
/** Public hook registrations erase their handler type. Select by the built-in task name before restoring it. */
|
|
23
|
+
export declare function eachHook<K extends keyof ToolHooks>(agent: Agent, name: K, api: HookApi & {
|
|
24
|
+
signal: AbortSignal;
|
|
25
|
+
report(error: unknown): void;
|
|
26
|
+
}, invoke: (hook: ToolHooks[K]) => Promise<void>): Promise<void>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Context } from "@earendil-works/chord";
|
|
2
|
+
import type { ToolCall } from "@earendil-works/pi-ai";
|
|
3
|
+
import { type JsonObject, type ToolExecutionResult } from "@earendil-works/pi-durable";
|
|
4
|
+
import type { Runtime } from "./nested-call.ts";
|
|
5
|
+
/** An audit record, deliberately with no assistant or tool-result model contribution. */
|
|
6
|
+
export declare const NestedResultEntry: import("@earendil-works/pi-durable").Entry<JsonObject>;
|
|
7
|
+
export declare function interrupted(runtime: Runtime, call: ToolCall, code: "interrupted" | "aborted", message: string, context: Context): Promise<void>;
|
|
8
|
+
export declare function settle(runtime: Runtime, call: ToolCall, result: ToolExecutionResult, ending: "completed" | "failed" | "aborted", context: Context): Promise<void>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type ToolExecutionResult } from "@earendil-works/pi-durable";
|
|
2
|
+
import { type Checkpoint, type NestedInput } from "./nested-call.ts";
|
|
3
|
+
export declare function createNestedToolTask(name: string): import("@earendil-works/pi-durable").Task<NestedInput, Checkpoint, ToolExecutionResult, Record<string, never>>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ShellOutputSkip } from "@earendil-works/pi-durable/env";
|
|
2
|
+
/** Retention limits of one tool's output. */
|
|
3
|
+
export type OutputLimits = {
|
|
4
|
+
readonly maxBytes: number;
|
|
5
|
+
readonly maxLines: number;
|
|
6
|
+
readonly retain: "head" | "tail";
|
|
7
|
+
};
|
|
8
|
+
/** Retained output and what the limits dropped. */
|
|
9
|
+
type BoundedOutput = {
|
|
10
|
+
readonly text: string;
|
|
11
|
+
readonly droppedBytes: number;
|
|
12
|
+
readonly droppedLines: number;
|
|
13
|
+
};
|
|
14
|
+
/** An exact slice of the input within the limits, and what it left out. */
|
|
15
|
+
type OutputSlice = {
|
|
16
|
+
readonly text: string;
|
|
17
|
+
readonly bytes: number;
|
|
18
|
+
readonly droppedBytes: number;
|
|
19
|
+
readonly droppedLines: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Bound `text` to whole lines within the limits: the first lines for `head`, the last lines for `tail`. The result is an
|
|
23
|
+
* exact slice, trailing newline included. A single line longer than `maxBytes` is cut at the byte limit on a character
|
|
24
|
+
* boundary.
|
|
25
|
+
*/
|
|
26
|
+
export declare function boundOutput(text: string, limits: OutputLimits): OutputSlice;
|
|
27
|
+
/**
|
|
28
|
+
* Bounded running output of one tool call. Accepting a chunk costs time proportional to the chunk: head retention stops
|
|
29
|
+
* storing once the window is full, and tail retention drops stored text the window no longer needs when it snapshots.
|
|
30
|
+
* Counts of the whole stream are kept so the dropped totals stay exact.
|
|
31
|
+
*/
|
|
32
|
+
export declare class OutputBuffer {
|
|
33
|
+
#private;
|
|
34
|
+
constructor(limits: OutputLimits);
|
|
35
|
+
/** Bytes currently held; bounded by the limits plus one chunk. */
|
|
36
|
+
get storedBytes(): number;
|
|
37
|
+
/**
|
|
38
|
+
* Accept a chunk; returns whether anything was accepted. `skipped` is output omitted right before the chunk, which
|
|
39
|
+
* must be more than the tail window by at least one byte or line (`ShellOutputInfo.skipped`); only tail retention
|
|
40
|
+
* accepts it.
|
|
41
|
+
*/
|
|
42
|
+
push(chunk: string | Uint8Array, skipped?: ShellOutputSkip): boolean;
|
|
43
|
+
/** Flush an incomplete trailing character as a replacement character; call when the stream ends. */
|
|
44
|
+
end(): void;
|
|
45
|
+
/** Retained, sanitized output and what the limits dropped from the whole stream. */
|
|
46
|
+
snapshot(): BoundedOutput;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
|
|
2
|
+
readonly [key: string]: JsonValue;
|
|
3
|
+
};
|
|
4
|
+
export type ExecutionCellStatus = "running" | "completed" | "failed" | "aborted" | "interrupted";
|
|
5
|
+
export interface ExecutionCellReference {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly status: ExecutionCellStatus;
|
|
8
|
+
}
|
|
9
|
+
/** Display receipt only. Usage and tool controls remain owned by Durable. */
|
|
10
|
+
export interface ExecutionResultReceipt {
|
|
11
|
+
readonly content: readonly ({
|
|
12
|
+
readonly type: "text";
|
|
13
|
+
readonly text: string;
|
|
14
|
+
} | {
|
|
15
|
+
readonly type: "image";
|
|
16
|
+
readonly data: string;
|
|
17
|
+
readonly mimeType: string;
|
|
18
|
+
})[];
|
|
19
|
+
readonly isError: boolean;
|
|
20
|
+
readonly details: JsonValue;
|
|
21
|
+
readonly diagnostics: readonly {
|
|
22
|
+
readonly severity: "info" | "warn" | "error";
|
|
23
|
+
readonly message: string;
|
|
24
|
+
readonly code?: string;
|
|
25
|
+
}[];
|
|
26
|
+
}
|
|
27
|
+
/** Host-projected identity and independently acquired, bounded exec/wait or control receipt. */
|
|
28
|
+
export interface ExecutionPresentationState {
|
|
29
|
+
readonly cell: ExecutionCellReference | null;
|
|
30
|
+
readonly result: ExecutionResultReceipt | null;
|
|
31
|
+
}
|
|
32
|
+
export interface ExecutionSummaryModel {
|
|
33
|
+
readonly title: string;
|
|
34
|
+
readonly cell: ExecutionCellReference | null;
|
|
35
|
+
readonly hasResult: boolean;
|
|
36
|
+
readonly isError: boolean | null;
|
|
37
|
+
}
|
|
38
|
+
export declare function parseExecutionResultReceipt(value: JsonValue | undefined): ExecutionResultReceipt | null;
|
|
39
|
+
/** No acquisition, invocation, cancellation, replay or runtime-status inference. */
|
|
40
|
+
declare function parseExecutionPresentationState(value: JsonValue): ExecutionPresentationState;
|
|
41
|
+
export declare function executionCapability(id: string, actions: readonly string[]): {
|
|
42
|
+
id: string;
|
|
43
|
+
version: number;
|
|
44
|
+
actions: readonly string[];
|
|
45
|
+
streams: readonly ["results"];
|
|
46
|
+
presentations: readonly ["summary", "detail"];
|
|
47
|
+
parseState: typeof parseExecutionPresentationState;
|
|
48
|
+
};
|
|
49
|
+
export declare function executionSummary(title: string): {
|
|
50
|
+
id: string;
|
|
51
|
+
select: (state: ExecutionPresentationState) => ExecutionSummaryModel;
|
|
52
|
+
requests: readonly ["detail"];
|
|
53
|
+
};
|
|
54
|
+
export declare const executionDetail: {
|
|
55
|
+
id: string;
|
|
56
|
+
select: (state: ExecutionPresentationState) => ExecutionPresentationState;
|
|
57
|
+
requests: readonly [];
|
|
58
|
+
};
|
|
59
|
+
export {};
|