@howaboua/pi-durable-notebook 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/activation.js +17 -14
- package/dist/execution/src/custom-commands.d.ts +1 -1
- package/dist/execution/src/tool-contract.d.ts +2 -2
- package/dist/index.js +17 -14
- package/dist/notebook/src/history.d.ts +1 -1
- package/dist/notebook/src/index.d.ts +1 -1
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Run TypeScript in a persistent Deno kernel. Globals and imports survive between cells. Serializable values and self-contained functions restore from checkpoints without replaying the cells that created them. Shell tools are included.
|
|
4
4
|
|
|
5
|
-
Requires Node 22.19 or newer and Durable 1.
|
|
5
|
+
Requires Node 22.19 or newer and Durable 1.5.0.
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
npm install https://github.com/IgorWarzocha/pi-durable-components/releases/download/v0.
|
|
8
|
+
npm install https://github.com/IgorWarzocha/pi-durable-components/releases/download/v0.11.0/howaboua-pi-durable-notebook-0.11.0.tgz
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
The shell's native PTY addon requires Python, Make and a C++ compiler on Linux. If install scripts are disabled, run `npm rebuild node-pty` before using interactive shells. Pipe-based commands do not require the addon.
|
package/dist/activation.js
CHANGED
|
@@ -608,8 +608,14 @@ async function observeCellProgress(id, api, context, budget) {
|
|
|
608
608
|
return work;
|
|
609
609
|
};
|
|
610
610
|
const live = await api.watchDoc(LiveDoc2, api.conversationId, context);
|
|
611
|
-
cell.start((
|
|
612
|
-
|
|
611
|
+
cell.start((call) => own(async () => {
|
|
612
|
+
if (call.kind === "failed")
|
|
613
|
+
throw call.error;
|
|
614
|
+
await publish(call.value);
|
|
615
|
+
}));
|
|
616
|
+
live?.start((call) => own(async () => {
|
|
617
|
+
if (call.kind === "failed")
|
|
618
|
+
throw call.error;
|
|
613
619
|
await api.commit(async (tx) => {
|
|
614
620
|
const record = await tx.task(id);
|
|
615
621
|
if (record === undefined || record.state.status === "terminal")
|
|
@@ -629,7 +635,7 @@ async function observeCellProgress(id, api, context, budget) {
|
|
|
629
635
|
const endings = await Promise.all([cell.stop(), live?.stop()]);
|
|
630
636
|
await Promise.all([...pending]);
|
|
631
637
|
for (const ending of endings)
|
|
632
|
-
if (ending?.
|
|
638
|
+
if (ending?.kind === "listener_error" || ending?.kind === "failed")
|
|
633
639
|
throw ending.error;
|
|
634
640
|
};
|
|
635
641
|
}
|
|
@@ -1112,6 +1118,7 @@ function combineControls(controls, allowTermination = true) {
|
|
|
1112
1118
|
|
|
1113
1119
|
// packages/execution/src/tool-contract.ts
|
|
1114
1120
|
import { copyJson as copyJson7 } from "@earendil-works/chord";
|
|
1121
|
+
var nestedToolDiscoveryGuidance = "Tools without a shown call signature: help is required only while their current arguments are unknown. Call with no arguments and read the result before composing an operation. Reuse known arguments without repeating help. Structured discovery uses {}";
|
|
1115
1122
|
function readToolContract(tool) {
|
|
1116
1123
|
const candidate = "executionHints" in tool ? tool.executionHints : undefined;
|
|
1117
1124
|
if (candidate !== undefined && (candidate === null || typeof candidate !== "object" || Array.isArray(candidate))) {
|
|
@@ -1477,14 +1484,14 @@ function forwardingHook() {
|
|
|
1477
1484
|
import {
|
|
1478
1485
|
defineTask as defineTask2
|
|
1479
1486
|
} from "@earendil-works/pi-durable";
|
|
1480
|
-
import {
|
|
1487
|
+
import { compile as compile2 } from "@earendil-works/pi-schema";
|
|
1481
1488
|
|
|
1482
1489
|
// packages/execution/src/nested-call.ts
|
|
1483
1490
|
import { validateToolArguments } from "@earendil-works/pi-ai/utils/validation";
|
|
1484
1491
|
import {
|
|
1485
1492
|
ToolTask as ToolTask4
|
|
1486
1493
|
} from "@earendil-works/pi-durable";
|
|
1487
|
-
import {
|
|
1494
|
+
import { compile } from "@earendil-works/pi-schema";
|
|
1488
1495
|
function nestedCall(runtime, input) {
|
|
1489
1496
|
const args = input.arguments;
|
|
1490
1497
|
return {
|
|
@@ -1505,7 +1512,7 @@ function prepareNestedInput(tool, input) {
|
|
|
1505
1512
|
if (typeof input !== "string")
|
|
1506
1513
|
return input;
|
|
1507
1514
|
const contract = readToolContract(tool);
|
|
1508
|
-
if (Boolean(
|
|
1515
|
+
if (Boolean(compile(tool.parameters).check(input)) || (typeof contract.inputSchema === "boolean" || typeof contract.inputSchema === "object" && contract.inputSchema !== null && !Array.isArray(contract.inputSchema)) && Boolean(compile(contract.inputSchema).check(input)))
|
|
1509
1516
|
return input;
|
|
1510
1517
|
const text = input.trim();
|
|
1511
1518
|
if (contract.discovery === "help" && text === "help")
|
|
@@ -1668,9 +1675,9 @@ function createNestedToolTask(name) {
|
|
|
1668
1675
|
return reject(runtime, call, executionError("tool_unavailable", `Tool ${call.name} is not available`), agent, tool, context);
|
|
1669
1676
|
let args;
|
|
1670
1677
|
try {
|
|
1671
|
-
const supplied = task.input.arguments === null && !
|
|
1678
|
+
const supplied = task.input.arguments === null && !compile2(tool.parameters).check(null) && compile2(tool.parameters).check({}) ? undefined : task.input.arguments;
|
|
1672
1679
|
const prepared = tool.prepareArguments === undefined ? prepareNestedInput(tool, supplied) : tool.prepareArguments(prepareNestedInput(tool, supplied));
|
|
1673
|
-
args = checked(tool, call, prepared === undefined &&
|
|
1680
|
+
args = checked(tool, call, prepared === undefined && compile2(tool.parameters).check({}) ? {} : prepared);
|
|
1674
1681
|
if (task.input.arguments === null || typeof task.input.arguments !== "object" || Array.isArray(task.input.arguments))
|
|
1675
1682
|
call.arguments = args;
|
|
1676
1683
|
} catch (error) {
|
|
@@ -1810,7 +1817,7 @@ function finishResult(tool, name, result) {
|
|
|
1810
1817
|
} else if (final.structuredOutput === undefined) {
|
|
1811
1818
|
if (!final.isError)
|
|
1812
1819
|
throw new Error(`Tool ${name} returned no structuredOutput`);
|
|
1813
|
-
} else if (!
|
|
1820
|
+
} else if (!compile2(tool.structuredOutputSchema).check(final.structuredOutput)) {
|
|
1814
1821
|
throw new Error(`Tool ${name} returned structuredOutput that does not match its schema`);
|
|
1815
1822
|
}
|
|
1816
1823
|
} catch (error) {
|
|
@@ -11327,11 +11334,7 @@ function createNotebookMode(options) {
|
|
|
11327
11334
|
section("notebook", (input) => {
|
|
11328
11335
|
const base = 'exec: TypeScript, top-level await and globals persist. Run normal exec cells sequentially. A leading // @exec: {"isolated":true} runs a separate kernel from committed state, up to four at once; completion saves a candidate without changing live bindings. Use wait to continue or terminate. Bare values are discarded. Use text(value), image(value), generatedImage(value), notify(value), store(key,value), load(key), exit() and yield_control(). ALL_TOOLS lists selected tool contracts. Reuse matching retained globals. Keep one-offs block-local. Retain only what you plan to reuse, and clean up when the task ends. Keep retained helpers self-contained; recreate imports, closures and live handles after restart. Keep canonical project artifacts in files and carry shell state through files or arguments. Ask before adding npm imports inside this Deno notebook, then use exact-version npm: specifiers. This rule does not govern repository dependencies. Inside exec tools.notebook supports status without query, list and diagnostics. Run other notebook actions after exec returns.';
|
|
11329
11336
|
const promoted = input.agent.callable.filter((tool) => !["exec", "wait", "notebook"].includes(tool.name)).map(readToolContract).filter((contract) => !contract.nativeOnly && !contract.deferLoading).map((contract) => contract.prompt);
|
|
11330
|
-
return [
|
|
11331
|
-
base,
|
|
11332
|
-
"For tools listed without a call signature, call with no arguments to get usage without performing an operation. Structured calls use {}.",
|
|
11333
|
-
...promoted
|
|
11334
|
-
].join(`
|
|
11337
|
+
return [base, nestedToolDiscoveryGuidance, ...promoted].join(`
|
|
11335
11338
|
`);
|
|
11336
11339
|
})
|
|
11337
11340
|
]
|
|
@@ -56,7 +56,7 @@ export declare function createCustomCommands(options: LiveCustomCommandOptions,
|
|
|
56
56
|
tasks?: readonly import("@earendil-works/pi-durable").AnyTask[];
|
|
57
57
|
hooks: import("@earendil-works/pi-durable").HookRegistration[];
|
|
58
58
|
};
|
|
59
|
-
refresh: (refreshContext: Context) => Promise<import("@earendil-works/pi-durable").RegistrySnapshot<import("@earendil-works/pi-durable").ToolRegistration<
|
|
59
|
+
refresh: (refreshContext: Context) => Promise<import("@earendil-works/pi-durable").RegistrySnapshot<import("@earendil-works/pi-durable").ToolRegistration<object, import("@earendil-works/chord").JsonValue>>>;
|
|
60
60
|
readonly errors: readonly CustomCommandDiscoveryError[];
|
|
61
61
|
close(): Promise<void>;
|
|
62
62
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type JsonValue } from "@earendil-works/chord";
|
|
2
|
-
import type { TSchema } from "@earendil-works/pi-ai";
|
|
3
2
|
import type { ToolRegistration } from "@earendil-works/pi-durable";
|
|
3
|
+
export declare const nestedToolDiscoveryGuidance = "Tools without a shown call signature: help is required only while their current arguments are unknown. Call with no arguments and read the result before composing an operation. Reuse known arguments without repeating help. Structured discovery uses {}";
|
|
4
4
|
/** Optional runtime presentation and observation policy on an ordinary registration. */
|
|
5
5
|
export interface ExecutionToolHints {
|
|
6
6
|
readonly usage?: string;
|
|
@@ -13,7 +13,7 @@ export interface ExecutionToolHints {
|
|
|
13
13
|
/** Keep the tool on the provider surface and prohibit calls from execution cells. */
|
|
14
14
|
readonly nativeOnly?: boolean;
|
|
15
15
|
}
|
|
16
|
-
export type ExecutionToolRegistration<T extends
|
|
16
|
+
export type ExecutionToolRegistration<T extends object = object, D extends JsonValue = JsonValue> = ToolRegistration<T, D> & {
|
|
17
17
|
readonly executionHints?: ExecutionToolHints;
|
|
18
18
|
};
|
|
19
19
|
interface ExecutionToolContract {
|
package/dist/index.js
CHANGED
|
@@ -597,8 +597,14 @@ async function observeCellProgress(id, api, context, budget) {
|
|
|
597
597
|
return work;
|
|
598
598
|
};
|
|
599
599
|
const live = await api.watchDoc(LiveDoc2, api.conversationId, context);
|
|
600
|
-
cell.start((
|
|
601
|
-
|
|
600
|
+
cell.start((call) => own(async () => {
|
|
601
|
+
if (call.kind === "failed")
|
|
602
|
+
throw call.error;
|
|
603
|
+
await publish(call.value);
|
|
604
|
+
}));
|
|
605
|
+
live?.start((call) => own(async () => {
|
|
606
|
+
if (call.kind === "failed")
|
|
607
|
+
throw call.error;
|
|
602
608
|
await api.commit(async (tx) => {
|
|
603
609
|
const record = await tx.task(id);
|
|
604
610
|
if (record === undefined || record.state.status === "terminal")
|
|
@@ -618,7 +624,7 @@ async function observeCellProgress(id, api, context, budget) {
|
|
|
618
624
|
const endings = await Promise.all([cell.stop(), live?.stop()]);
|
|
619
625
|
await Promise.all([...pending]);
|
|
620
626
|
for (const ending of endings)
|
|
621
|
-
if (ending?.
|
|
627
|
+
if (ending?.kind === "listener_error" || ending?.kind === "failed")
|
|
622
628
|
throw ending.error;
|
|
623
629
|
};
|
|
624
630
|
}
|
|
@@ -1101,6 +1107,7 @@ function combineControls(controls, allowTermination = true) {
|
|
|
1101
1107
|
|
|
1102
1108
|
// packages/execution/src/tool-contract.ts
|
|
1103
1109
|
import { copyJson as copyJson7 } from "@earendil-works/chord";
|
|
1110
|
+
var nestedToolDiscoveryGuidance = "Tools without a shown call signature: help is required only while their current arguments are unknown. Call with no arguments and read the result before composing an operation. Reuse known arguments without repeating help. Structured discovery uses {}";
|
|
1104
1111
|
function readToolContract(tool) {
|
|
1105
1112
|
const candidate = "executionHints" in tool ? tool.executionHints : undefined;
|
|
1106
1113
|
if (candidate !== undefined && (candidate === null || typeof candidate !== "object" || Array.isArray(candidate))) {
|
|
@@ -1466,14 +1473,14 @@ function forwardingHook() {
|
|
|
1466
1473
|
import {
|
|
1467
1474
|
defineTask as defineTask2
|
|
1468
1475
|
} from "@earendil-works/pi-durable";
|
|
1469
|
-
import {
|
|
1476
|
+
import { compile as compile2 } from "@earendil-works/pi-schema";
|
|
1470
1477
|
|
|
1471
1478
|
// packages/execution/src/nested-call.ts
|
|
1472
1479
|
import { validateToolArguments } from "@earendil-works/pi-ai/utils/validation";
|
|
1473
1480
|
import {
|
|
1474
1481
|
ToolTask as ToolTask4
|
|
1475
1482
|
} from "@earendil-works/pi-durable";
|
|
1476
|
-
import {
|
|
1483
|
+
import { compile } from "@earendil-works/pi-schema";
|
|
1477
1484
|
function nestedCall(runtime, input) {
|
|
1478
1485
|
const args = input.arguments;
|
|
1479
1486
|
return {
|
|
@@ -1494,7 +1501,7 @@ function prepareNestedInput(tool, input) {
|
|
|
1494
1501
|
if (typeof input !== "string")
|
|
1495
1502
|
return input;
|
|
1496
1503
|
const contract = readToolContract(tool);
|
|
1497
|
-
if (Boolean(
|
|
1504
|
+
if (Boolean(compile(tool.parameters).check(input)) || (typeof contract.inputSchema === "boolean" || typeof contract.inputSchema === "object" && contract.inputSchema !== null && !Array.isArray(contract.inputSchema)) && Boolean(compile(contract.inputSchema).check(input)))
|
|
1498
1505
|
return input;
|
|
1499
1506
|
const text = input.trim();
|
|
1500
1507
|
if (contract.discovery === "help" && text === "help")
|
|
@@ -1657,9 +1664,9 @@ function createNestedToolTask(name) {
|
|
|
1657
1664
|
return reject(runtime, call, executionError("tool_unavailable", `Tool ${call.name} is not available`), agent, tool, context);
|
|
1658
1665
|
let args;
|
|
1659
1666
|
try {
|
|
1660
|
-
const supplied = task.input.arguments === null && !
|
|
1667
|
+
const supplied = task.input.arguments === null && !compile2(tool.parameters).check(null) && compile2(tool.parameters).check({}) ? undefined : task.input.arguments;
|
|
1661
1668
|
const prepared = tool.prepareArguments === undefined ? prepareNestedInput(tool, supplied) : tool.prepareArguments(prepareNestedInput(tool, supplied));
|
|
1662
|
-
args = checked(tool, call, prepared === undefined &&
|
|
1669
|
+
args = checked(tool, call, prepared === undefined && compile2(tool.parameters).check({}) ? {} : prepared);
|
|
1663
1670
|
if (task.input.arguments === null || typeof task.input.arguments !== "object" || Array.isArray(task.input.arguments))
|
|
1664
1671
|
call.arguments = args;
|
|
1665
1672
|
} catch (error) {
|
|
@@ -1799,7 +1806,7 @@ function finishResult(tool, name, result) {
|
|
|
1799
1806
|
} else if (final.structuredOutput === undefined) {
|
|
1800
1807
|
if (!final.isError)
|
|
1801
1808
|
throw new Error(`Tool ${name} returned no structuredOutput`);
|
|
1802
|
-
} else if (!
|
|
1809
|
+
} else if (!compile2(tool.structuredOutputSchema).check(final.structuredOutput)) {
|
|
1803
1810
|
throw new Error(`Tool ${name} returned structuredOutput that does not match its schema`);
|
|
1804
1811
|
}
|
|
1805
1812
|
} catch (error) {
|
|
@@ -11680,11 +11687,7 @@ function createNotebookMode(options) {
|
|
|
11680
11687
|
section("notebook", (input) => {
|
|
11681
11688
|
const base = 'exec: TypeScript, top-level await and globals persist. Run normal exec cells sequentially. A leading // @exec: {"isolated":true} runs a separate kernel from committed state, up to four at once; completion saves a candidate without changing live bindings. Use wait to continue or terminate. Bare values are discarded. Use text(value), image(value), generatedImage(value), notify(value), store(key,value), load(key), exit() and yield_control(). ALL_TOOLS lists selected tool contracts. Reuse matching retained globals. Keep one-offs block-local. Retain only what you plan to reuse, and clean up when the task ends. Keep retained helpers self-contained; recreate imports, closures and live handles after restart. Keep canonical project artifacts in files and carry shell state through files or arguments. Ask before adding npm imports inside this Deno notebook, then use exact-version npm: specifiers. This rule does not govern repository dependencies. Inside exec tools.notebook supports status without query, list and diagnostics. Run other notebook actions after exec returns.';
|
|
11682
11689
|
const promoted = input.agent.callable.filter((tool) => !["exec", "wait", "notebook"].includes(tool.name)).map(readToolContract).filter((contract) => !contract.nativeOnly && !contract.deferLoading).map((contract) => contract.prompt);
|
|
11683
|
-
return [
|
|
11684
|
-
base,
|
|
11685
|
-
"For tools listed without a call signature, call with no arguments to get usage without performing an operation. Structured calls use {}.",
|
|
11686
|
-
...promoted
|
|
11687
|
-
].join(`
|
|
11690
|
+
return [base, nestedToolDiscoveryGuidance, ...promoted].join(`
|
|
11688
11691
|
`);
|
|
11689
11692
|
})
|
|
11690
11693
|
]
|
|
@@ -2,5 +2,5 @@ export type { ExecutionHistoryRequest } from "../../execution/src/history.ts";
|
|
|
2
2
|
export declare const readForwardedToolCalls: (harness: {
|
|
3
3
|
conversation: (id: import("@earendil-works/pi-durable").ConversationId, context: import("@earendil-works/chord").Context) => Promise<import("@earendil-works/pi-durable").Conversation | undefined>;
|
|
4
4
|
getTask: <R>(id: import("@earendil-works/pi-durable").TaskId<R>, context: import("@earendil-works/chord").Context) => Promise<import("@earendil-works/pi-durable").TaskRecord<import("@earendil-works/chord").JsonValue, import("@earendil-works/chord").JsonValue, R> | undefined>;
|
|
5
|
-
commit: <T>(change: (tx: import("@earendil-works/pi-durable").Tx) => T | Promise<T>, context: import("@earendil-works/chord").Context) => Promise<T>;
|
|
5
|
+
commit: <T>(change: (tx: import("@earendil-works/pi-durable").Tx) => T | Promise<T>, context: import("@earendil-works/chord").Context, options?: import("@earendil-works/pi-durable").CommitOptions) => Promise<T>;
|
|
6
6
|
}, request: import("../../execution/src/history.ts").ExecutionHistoryRequest, context: import("@earendil-works/chord").Context) => Promise<ReadonlyMap<string, import("./presentation.ts").ForwardedToolCalls>>;
|
|
@@ -33,7 +33,7 @@ export declare function createNotebookMode(options: NotebookModeOptions): {
|
|
|
33
33
|
prepareArguments?(args: unknown): {
|
|
34
34
|
input?: string;
|
|
35
35
|
};
|
|
36
|
-
structuredOutputSchema?:
|
|
36
|
+
structuredOutputSchema?: object;
|
|
37
37
|
callers?: readonly ("model" | "tools")[];
|
|
38
38
|
deferred?: true;
|
|
39
39
|
outputLimits?: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@howaboua/pi-durable-notebook",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Persistent notebook execution and shell tools for Pi Durable",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,12 +46,13 @@
|
|
|
46
46
|
"proxy-from-env": "2.1.0",
|
|
47
47
|
"undici": "8.10.2",
|
|
48
48
|
"typebox": "1.3.27",
|
|
49
|
-
"@howaboua/pi-durable-components": "0.
|
|
49
|
+
"@howaboua/pi-durable-components": "0.11.0",
|
|
50
|
+
"@earendil-works/pi-schema": "1.5.0"
|
|
50
51
|
},
|
|
51
52
|
"peerDependencies": {
|
|
52
|
-
"@earendil-works/chord": "1.
|
|
53
|
-
"@earendil-works/pi-ai": "1.
|
|
54
|
-
"@earendil-works/pi-durable": "1.
|
|
53
|
+
"@earendil-works/chord": "1.5.0",
|
|
54
|
+
"@earendil-works/pi-ai": "1.5.0",
|
|
55
|
+
"@earendil-works/pi-durable": "1.5.0",
|
|
55
56
|
"@modelcontextprotocol/sdk": ">=1.25.2 <2"
|
|
56
57
|
},
|
|
57
58
|
"publishConfig": {
|