@howaboua/pi-durable-js-notebook 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 +39 -0
- package/README.md +38 -2
- 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/command-backend.d.ts +22 -0
- package/dist/execution/src/controls.d.ts +3 -0
- package/dist/execution/src/custom-command-config.d.ts +21 -0
- package/dist/execution/src/custom-commands.d.ts +62 -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/index.d.ts +6 -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/shell/backend.d.ts +28 -0
- package/dist/execution/src/shell/format.d.ts +2 -0
- package/dist/execution/src/shell/node-backend.d.ts +9 -0
- package/dist/execution/src/shell/output.d.ts +19 -0
- package/dist/execution/src/shell/process-session.d.ts +50 -0
- package/dist/execution/src/shell/results.d.ts +14 -0
- package/dist/execution/src/shell/session-manager.d.ts +46 -0
- package/dist/execution/src/shell/session-store.d.ts +53 -0
- package/dist/execution/src/shell/shell-args.d.ts +4 -0
- package/dist/execution/src/shell/shell.d.ts +14 -0
- package/dist/execution/src/shell/wait.d.ts +7 -0
- package/dist/execution/src/shell.d.ts +14 -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-source.d.ts +6 -0
- package/dist/execution/src/tool-value.d.ts +3 -0
- package/dist/execution/src/wait-session.d.ts +6 -0
- package/dist/index.js +6338 -0
- package/dist/js-notebook/src/bindings.d.ts +6 -0
- package/dist/js-notebook/src/client.d.ts +34 -0
- package/dist/js-notebook/src/data-state.d.ts +20 -0
- package/dist/js-notebook/src/data-storage.d.ts +17 -0
- package/dist/js-notebook/src/engine.d.ts +16 -0
- package/dist/js-notebook/src/index.d.ts +53 -0
- package/dist/js-notebook/src/kernel.d.ts +25 -0
- package/dist/js-notebook/src/managed-bindings.d.ts +20 -0
- package/dist/js-notebook/src/managed-source.d.ts +9 -0
- package/dist/js-notebook/src/notebook-control.d.ts +7 -0
- package/dist/js-notebook/src/portable-state.d.ts +79 -0
- package/dist/js-notebook/src/prelude.d.ts +1 -0
- package/dist/js-notebook/src/project.d.ts +67 -0
- package/dist/js-notebook/src/protocol.d.ts +115 -0
- package/dist/js-notebook/src/runtime-cache.d.ts +2 -0
- package/dist/js-notebook/src/runtime-contract.d.ts +117 -0
- package/dist/js-notebook/src/runtime.d.ts +8 -0
- package/dist/js-notebook/src/state-validation.d.ts +2 -0
- package/dist/js-notebook/src/storage.d.ts +18 -0
- package/dist/js-notebook/src/support.d.ts +12 -0
- package/dist/js-notebook/src/tool-calls.d.ts +11 -0
- package/dist/js-notebook/src/worker.d.ts +1 -0
- package/dist/notebook/src/cell.d.ts +34 -0
- package/dist/notebook/src/checkpoint-activity.d.ts +7 -0
- package/dist/notebook/src/checkpoint-format.d.ts +32 -0
- package/dist/notebook/src/checkpoint-store.d.ts +8 -0
- package/dist/notebook/src/command-output.d.ts +1 -0
- package/dist/notebook/src/deno-syntax-diagnostics.d.ts +1 -0
- package/dist/notebook/src/directory-lock.d.ts +10 -0
- package/dist/notebook/src/glob.d.ts +1 -0
- package/dist/notebook/src/jupyter-connection.d.ts +17 -0
- package/dist/notebook/src/jupyter-execution.d.ts +29 -0
- package/dist/notebook/src/jupyter-kernel.d.ts +43 -0
- package/dist/notebook/src/jupyter-output.d.ts +32 -0
- package/dist/notebook/src/jupyter-shell.d.ts +18 -0
- package/dist/notebook/src/jupyter-socket.d.ts +17 -0
- package/dist/notebook/src/jupyter-wire.d.ts +16 -0
- package/dist/notebook/src/profile-state-format.d.ts +36 -0
- package/dist/notebook/src/project-identity.d.ts +1 -0
- package/dist/notebook/src/project-state-format.d.ts +80 -0
- package/dist/notebook/src/project-state-lock.d.ts +1 -0
- package/dist/notebook/src/runtime-contract.d.ts +117 -0
- package/dist/notebook/src/runtime-health.d.ts +9 -0
- package/dist/notebook/src/storage-retention.d.ts +21 -0
- package/dist/notebook/src/tool-observation.d.ts +21 -0
- package/dist/worker.js +1545 -0
- package/package.json +51 -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,39 @@
|
|
|
1
|
+
JS Notebook adapted from IgorWarzocha/howaboua-pi-stuff, merged PR #552
|
|
2
|
+
revision 84bd5bce60a77c4298484d4b7c810d4fe5220a1b.
|
|
3
|
+
Source: packages/pi-codex-conversion/src/tools/js-mode and the selected-data
|
|
4
|
+
graph definitions, remapping, validation and compaction in ts-mode.
|
|
5
|
+
Repository: https://github.com/IgorWarzocha/howaboua-pi-stuff
|
|
6
|
+
|
|
7
|
+
The source checkout was inspected read-only with git show. Integration uses
|
|
8
|
+
public Pi Durable APIs, ordinary selected tool registrations and the internal
|
|
9
|
+
shared shell implementation. No Pi ExtensionAPI or compatibility wrapper is
|
|
10
|
+
carried. QuickJS retains complete VM snapshots without replaying user cells.
|
|
11
|
+
|
|
12
|
+
QuickJS runtime: quickjs-wasi 3.6.3, MIT, vercel-labs/quickjs-wasi.
|
|
13
|
+
WASM loader: @earendil-works/pi-codemode 1.4.0, MIT.
|
|
14
|
+
Parser: acorn 8.19.0, MIT.
|
|
15
|
+
These are external package dependencies and retain their own licence files.
|
|
16
|
+
|
|
17
|
+
Upstream source licence:
|
|
18
|
+
|
|
19
|
+
MIT License
|
|
20
|
+
|
|
21
|
+
Copyright (c) 2026 Igor Warzocha
|
|
22
|
+
|
|
23
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
24
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
25
|
+
in the Software without restriction, including without limitation the rights
|
|
26
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
27
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
28
|
+
furnished to do so, subject to the following conditions:
|
|
29
|
+
|
|
30
|
+
The above copyright notice and this permission notice shall be included in all
|
|
31
|
+
copies or substantial portions of the Software.
|
|
32
|
+
|
|
33
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
34
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
35
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
36
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
37
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
38
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
39
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
-
#
|
|
1
|
+
# JS Notebook
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Persistent JavaScript execution for Pi Durable. Closures, class instances, cyclic objects and lexical bindings survive a host restart through complete QuickJS VM checkpoints. Cells are never replayed to restore state.
|
|
4
|
+
|
|
5
|
+
The component registers `exec`, `wait`, `notebook`, `exec_command` and `write_stdin`. Ordinary selected Durable tools are available through `tools` inside cells, with their original registered names. It works without Howcode.
|
|
6
|
+
|
|
7
|
+
## Host setup
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install https://github.com/IgorWarzocha/pi-durable-components/releases/download/v0.9.1/howaboua-pi-durable-js-notebook-0.9.1.tgz
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Use Node.js 22.19 or later. Bun hosts are rejected because worker termination is part of the cancellation boundary. Install the package and its declared Durable peers through your application's package manager. QuickJS and its WASM loader use exact versions. If the installed runtime is unavailable, the component can provision its owned cache on first use and reuse it offline.
|
|
14
|
+
|
|
15
|
+
Create `createJsNotebookMode` with a `stateDirectory`, `native: { environmentId }`, a matching shell backend and a `cancelTask` callback that calls the owning Harness's `abortTask`. Install its `extension` in your Durable registry, then call `bind(harness)`. Call `close()` when the application shuts down.
|
|
16
|
+
|
|
17
|
+
`maxHeapMiB` defaults to 4096 and must be at least 128. Half is the live VM budget. Each of at most four isolated VMs receives one quarter of that live budget. An optional `profile` selects initial saved state when the project has no checkpoint.
|
|
18
|
+
|
|
19
|
+
The execution environment must match the explicit native grant. Checkpoint files use the host filesystem beneath `stateDirectory`. Conversations using that directory and the same project share one serial notebook, including lexical state. Projects are identified by the nearest Git root, or by the working directory outside Git. Use separate state directories when applications must not share state.
|
|
20
|
+
|
|
21
|
+
Do not install multiple execution modes with the same tool names in one selected agent.
|
|
22
|
+
|
|
23
|
+
## Cells and saved state
|
|
24
|
+
|
|
25
|
+
`exec` accepts JavaScript with top-level await. Bare values are discarded. Use `text(value)` or `image(value)` for output. `notify`, `generatedImage`, `store`, `load`, `exit` and `yield_control` are also available. `ALL_TOOLS` describes selected registrations. The VM has no Node globals, filesystem API or module imports. Use registered tools for external operations.
|
|
26
|
+
|
|
27
|
+
Normal successful cells save the complete VM. A leading `// @exec: {"isolated":true}` forks the last committed checkpoint without sampling a running live cell. Completion saves a named candidate without adopting it. External tool and file effects remain shared.
|
|
28
|
+
|
|
29
|
+
Call `notebook` without input for its action help. Whole-notebook profiles preserve the entire VM and replace live state when loaded. Selected-data profiles add noncolliding bindings. Pins preserve supported plain data across reset and protect names from release. Closures and class instances survive whole-VM checkpoints, but cannot be selected-data pins.
|
|
30
|
+
|
|
31
|
+
Startup and tool-result hooks use retained functions. Startup hooks cannot call tools. Failed startup blocks normal execution. Tool-result hooks run after settlement, and calls inside them do not recursively trigger hooks.
|
|
32
|
+
|
|
33
|
+
## Recovery
|
|
34
|
+
|
|
35
|
+
`wait` continues a yielded cell or terminates it. Cancellation stops its owned worker, including infinite promise chains. Cancellation does not undo tool effects. A stopped live VM requires `notebook restart`, which restores the last completed checkpoint without replaying side effects. Errors that leave a VM alive can retain earlier mutations.
|
|
36
|
+
|
|
37
|
+
An isolated candidate cannot silently overwrite newer project state. A stale load is refused and produces a recovery profile for an explicit replacement. `reset` discards the live project VM, while saved profiles and reset-survival pins remain.
|
|
38
|
+
|
|
39
|
+
Snapshots are runtime-specific, not portable JavaScript serialisations. Preserve the matching runtime version when recovering saved state.
|
|
@@ -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,22 @@
|
|
|
1
|
+
export interface CustomCommandRequest {
|
|
2
|
+
command: string;
|
|
3
|
+
args: readonly string[];
|
|
4
|
+
cwd: string;
|
|
5
|
+
stdin?: string;
|
|
6
|
+
}
|
|
7
|
+
/** Direct command capability. Implementations must enforce the output and cancellation contract. */
|
|
8
|
+
export interface CustomCommandBackend {
|
|
9
|
+
readonly environmentId: string;
|
|
10
|
+
readonly platform: string;
|
|
11
|
+
readonly javascriptRuntime: string;
|
|
12
|
+
/** No shell expansion. Return trimmed stdout, stderr when empty, or '(no output)'.
|
|
13
|
+
* Cap combined bytes at 50 KiB and reject nonzero exits. Cancellation must drain the owned process group. */
|
|
14
|
+
run(request: CustomCommandRequest, signal?: AbortSignal): Promise<string>;
|
|
15
|
+
}
|
|
16
|
+
export interface NodeCommandBackendOptions {
|
|
17
|
+
/** Explicitly verified local process namespace. Must match the invocation environment. */
|
|
18
|
+
environmentId: string;
|
|
19
|
+
env?: NodeJS.ProcessEnv;
|
|
20
|
+
javascriptRuntime?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function createNodeCommandBackend(options: NodeCommandBackendOptions): CustomCommandBackend;
|
|
@@ -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 interface CustomCommandDefinition {
|
|
2
|
+
name: string;
|
|
3
|
+
usage: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
output?: string;
|
|
6
|
+
deferLoading: boolean;
|
|
7
|
+
command: string;
|
|
8
|
+
args: string[];
|
|
9
|
+
input: "arg" | "stdin";
|
|
10
|
+
yieldTimeMs?: number;
|
|
11
|
+
sourcePath: string;
|
|
12
|
+
disabledReason?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface CustomCommandParseOptions {
|
|
15
|
+
platform: string;
|
|
16
|
+
/** JavaScript launcher in the command backend's namespace. */
|
|
17
|
+
javascriptRuntime: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const CUSTOM_TOOL_NAME_PATTERN: RegExp;
|
|
20
|
+
export declare function customCommandName(path: string, platform: string): string;
|
|
21
|
+
export declare function parseCustomCommand(path: string, text: string, options: CustomCommandParseOptions): CustomCommandDefinition;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Context } from "@earendil-works/chord";
|
|
2
|
+
import { type Registry } from "@earendil-works/pi-durable";
|
|
3
|
+
import { type FileSystem } from "@earendil-works/pi-durable/env";
|
|
4
|
+
import { Type } from "typebox";
|
|
5
|
+
import type { CustomCommandBackend } from "./command-backend.ts";
|
|
6
|
+
import { type CustomCommandDefinition } from "./custom-command-config.ts";
|
|
7
|
+
import type { ExecutionToolRegistration } from "./tool-contract.ts";
|
|
8
|
+
export interface CustomCommandRoot {
|
|
9
|
+
path: string;
|
|
10
|
+
/** The host owns trust. An untrusted root is never read. Later trusted roots override earlier roots. */
|
|
11
|
+
trusted: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface CustomCommandOptions {
|
|
14
|
+
files: FileSystem;
|
|
15
|
+
backend: CustomCommandBackend;
|
|
16
|
+
roots: readonly CustomCommandRoot[];
|
|
17
|
+
name?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface CustomCommandDiscoveryError {
|
|
20
|
+
path: string;
|
|
21
|
+
message: string;
|
|
22
|
+
}
|
|
23
|
+
export interface CustomCommandDiscovery {
|
|
24
|
+
tools: CustomCommandDefinition[];
|
|
25
|
+
errors: CustomCommandDiscoveryError[];
|
|
26
|
+
}
|
|
27
|
+
export interface LiveCustomCommandOptions extends CustomCommandOptions {
|
|
28
|
+
registry: Registry;
|
|
29
|
+
onDiscoveryError?(error: CustomCommandDiscoveryError): void;
|
|
30
|
+
}
|
|
31
|
+
/** Explicit trusted-root discovery. No ambient Pi directory, parent search, or bundled examples. */
|
|
32
|
+
export declare function discoverCustomCommands(options: CustomCommandOptions, context: Context): Promise<CustomCommandDiscovery>;
|
|
33
|
+
/** Load TOML commands as ordinary registrations. Re-run this factory and install its returned extension to refresh inventory. */
|
|
34
|
+
export declare function loadCustomCommandTools(options: CustomCommandOptions, context: Context): Promise<{
|
|
35
|
+
extension: import("@earendil-works/pi-durable").Extension<ExecutionToolRegistration<Type.TObject<{
|
|
36
|
+
input: Type.TString;
|
|
37
|
+
}>>>;
|
|
38
|
+
tools: ExecutionToolRegistration<Type.TObject<{
|
|
39
|
+
input: Type.TString;
|
|
40
|
+
}>>[];
|
|
41
|
+
errors: CustomCommandDiscoveryError[];
|
|
42
|
+
}>;
|
|
43
|
+
/** Live config inventory through supported ordinary registry publications, not a Code dispatch adapter. */
|
|
44
|
+
export declare function createCustomCommands(options: LiveCustomCommandOptions, context: Context): Promise<{
|
|
45
|
+
extension: {
|
|
46
|
+
name: string;
|
|
47
|
+
tools?: readonly ExecutionToolRegistration<Type.TObject<{
|
|
48
|
+
input: Type.TString;
|
|
49
|
+
}>>[];
|
|
50
|
+
sections?: readonly import("@earendil-works/pi-durable").PromptSection<ExecutionToolRegistration<Type.TObject<{
|
|
51
|
+
input: Type.TString;
|
|
52
|
+
}>>>[];
|
|
53
|
+
wraps?: readonly import("@earendil-works/pi-durable").Wrap<ExecutionToolRegistration<Type.TObject<{
|
|
54
|
+
input: Type.TString;
|
|
55
|
+
}>>>[];
|
|
56
|
+
tasks?: readonly import("@earendil-works/pi-durable").AnyTask[];
|
|
57
|
+
hooks: import("@earendil-works/pi-durable").HookRegistration[];
|
|
58
|
+
};
|
|
59
|
+
refresh: (refreshContext: Context) => Promise<import("@earendil-works/pi-durable").RegistrySnapshot<import("@earendil-works/pi-durable").ToolRegistration<Type.TSchema, import("@earendil-works/chord").JsonValue>>>;
|
|
60
|
+
readonly errors: readonly CustomCommandDiscoveryError[];
|
|
61
|
+
close(): Promise<void>;
|
|
62
|
+
}>;
|
|
@@ -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,6 @@
|
|
|
1
|
+
export type { CellObservation } from "./cell-contract.ts";
|
|
2
|
+
export { type CellCoordinatorOptions, createCellCoordinator } from "./cells.ts";
|
|
3
|
+
export { adaptiveWaitMs, MAX_CODE_MODE_OUTPUT_TOKENS } from "./exec-source.ts";
|
|
4
|
+
export { readToolContract } from "./tool-contract.ts";
|
|
5
|
+
export { directToolYieldTime } from "./tool-source.ts";
|
|
6
|
+
export { toolValue } from "./tool-value.ts";
|
|
@@ -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 {};
|