@howaboua/pi-durable-notebook 0.9.1 → 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 +11436 -0
- 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/activation.d.ts +5 -0
- package/dist/notebook/src/history.d.ts +1 -1
- package/dist/notebook/src/index.d.ts +1 -1
- package/package.json +31 -6
|
@@ -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
|
]
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ComponentInstance, type ComponentRequest } from "@howaboua/pi-durable-components";
|
|
2
|
+
import { createNotebookMode, type NotebookModeOptions } from "./index.ts";
|
|
3
|
+
/** Optional complete constructor override; replaces baseline JSON configuration. */
|
|
4
|
+
export declare const notebookOptions: import("@howaboua/pi-durable-components").ComponentCapability<NotebookModeOptions>;
|
|
5
|
+
export declare function createComponent(request: ComponentRequest): ComponentInstance<ReturnType<typeof createNotebookMode>>;
|
|
@@ -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",
|
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
".": {
|
|
28
28
|
"types": "./dist/notebook/src/index.d.ts",
|
|
29
29
|
"import": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./component": {
|
|
32
|
+
"types": "./dist/notebook/src/activation.d.ts",
|
|
33
|
+
"import": "./dist/activation.js"
|
|
30
34
|
}
|
|
31
35
|
},
|
|
32
36
|
"files": [
|
|
@@ -41,15 +45,36 @@
|
|
|
41
45
|
"smol-toml": "1.9.0",
|
|
42
46
|
"proxy-from-env": "2.1.0",
|
|
43
47
|
"undici": "8.10.2",
|
|
44
|
-
"typebox": "1.3.27"
|
|
48
|
+
"typebox": "1.3.27",
|
|
49
|
+
"@howaboua/pi-durable-components": "0.11.0",
|
|
50
|
+
"@earendil-works/pi-schema": "1.5.0"
|
|
45
51
|
},
|
|
46
52
|
"peerDependencies": {
|
|
47
|
-
"@earendil-works/chord": "1.
|
|
48
|
-
"@earendil-works/pi-ai": "1.
|
|
49
|
-
"@earendil-works/pi-durable": "1.
|
|
50
|
-
"@modelcontextprotocol/sdk": "1.25.2"
|
|
53
|
+
"@earendil-works/chord": "1.5.0",
|
|
54
|
+
"@earendil-works/pi-ai": "1.5.0",
|
|
55
|
+
"@earendil-works/pi-durable": "1.5.0",
|
|
56
|
+
"@modelcontextprotocol/sdk": ">=1.25.2 <2"
|
|
51
57
|
},
|
|
52
58
|
"publishConfig": {
|
|
53
59
|
"access": "public"
|
|
60
|
+
},
|
|
61
|
+
"durable": {
|
|
62
|
+
"schemaVersion": 1,
|
|
63
|
+
"kind": "extension",
|
|
64
|
+
"entry": "./component",
|
|
65
|
+
"runtimes": [
|
|
66
|
+
"node"
|
|
67
|
+
],
|
|
68
|
+
"requires": [
|
|
69
|
+
"durable.node-execution.v1",
|
|
70
|
+
"durable.state.v1"
|
|
71
|
+
],
|
|
72
|
+
"permissions": [
|
|
73
|
+
"filesystem",
|
|
74
|
+
"process",
|
|
75
|
+
"network",
|
|
76
|
+
"storage"
|
|
77
|
+
],
|
|
78
|
+
"selectionGroup": "execution"
|
|
54
79
|
}
|
|
55
80
|
}
|