@howaboua/pi-durable-context 0.11.0 → 0.13.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/NOTICE +4 -0
- package/README.md +8 -4
- package/dist/activation.js +455 -116
- package/dist/index.js +440 -115
- package/dist/internal/context-visibility.d.ts +1 -1
- package/dist/packages/context/src/activation.d.ts +4 -1
- package/dist/packages/context/src/admission.d.ts +2 -0
- package/dist/packages/context/src/deferred-rollover.d.ts +30 -0
- package/dist/packages/context/src/history-archive.d.ts +1 -1
- package/dist/packages/context/src/history.d.ts +18 -2
- package/dist/packages/context/src/index.d.ts +10 -1
- package/dist/packages/context/src/input-placement.d.ts +1 -1
- package/dist/packages/context/src/instruction-run.d.ts +1 -1
- package/dist/packages/context/src/lifecycle.d.ts +1 -1
- package/dist/packages/context/src/model-roles.d.ts +2 -2
- package/dist/packages/context/src/note-store.d.ts +12 -1
- package/dist/packages/context/src/notes.d.ts +18 -1
- package/dist/packages/context/src/policy.d.ts +3 -2
- package/dist/packages/context/src/remote.d.ts +1 -1
- package/dist/packages/context/src/rollover-preparation.d.ts +1 -1
- package/dist/packages/context/src/rollover-tail.d.ts +12 -0
- package/dist/packages/context/src/rollover.d.ts +3 -2
- package/dist/packages/context/src/tool-contract.d.ts +4 -2
- package/dist/packages/context/src/tool-rollover.d.ts +11 -3
- package/dist/packages/context/src/usage.d.ts +1 -1
- package/dist/packages/context/src/window-state.d.ts +1 -0
- package/dist/packages/execution/src/tool-origin.d.ts +19 -0
- package/package.json +7 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import type { ConversationId, Storage, Tx } from "@earendil-works/pi-durable";
|
|
3
3
|
/** Persist an immutable group for a newly created child before dispatching its first task. */
|
|
4
4
|
export declare function assignContextVisibility(tx: Tx, parent: ConversationId, child: ConversationId, shareContext: boolean | undefined): Promise<void>;
|
|
@@ -9,9 +9,12 @@ export declare const contextOptions: import("@howaboua/pi-durable-components").C
|
|
|
9
9
|
beforeRollover?: import("./rollover-preparation.ts").BeforeRollover;
|
|
10
10
|
modelRoles?: import("./model-roles.ts").ContextModelRoles;
|
|
11
11
|
remote?: import("./remote.ts").ContextRemoteCatalog;
|
|
12
|
+
localNotes?: boolean;
|
|
12
13
|
now?: () => number;
|
|
13
14
|
newContextRequests?: import("./index.ts").NewContextRequests;
|
|
14
|
-
|
|
15
|
+
taskCompletionRollover?: boolean;
|
|
16
|
+
rolloverTail?: import("./rollover-tail.ts").RolloverTailMode;
|
|
17
|
+
hasEligibleContextHistory?: (conversationId: import("@earendil-works/pi-durable").ConversationId, context: import("@earendil-works/chord/context").Context) => boolean | Promise<boolean>;
|
|
15
18
|
automaticIdleRollover?: boolean;
|
|
16
19
|
idleRolloverMinutes?: 0 | 5 | 15 | 25 | 55 | 115 | 355 | 715;
|
|
17
20
|
taskBoundaryReminderTokens?: number;
|
|
@@ -14,11 +14,13 @@ type InputState = {
|
|
|
14
14
|
};
|
|
15
15
|
export declare function createInput(host: () => ContextHost, rollover: ReturnType<typeof createRollover>, idleMs: number): import("@earendil-works/pi-durable").Task<{
|
|
16
16
|
readonly requestId?: string;
|
|
17
|
+
readonly notify?: import("@earendil-works/pi-durable").SubmissionNotify;
|
|
17
18
|
} & {
|
|
18
19
|
readonly type: "input";
|
|
19
20
|
readonly content: import("@earendil-works/pi-durable").UserInput;
|
|
20
21
|
readonly whenBusy?: "steer" | "followUp" | "reject";
|
|
21
22
|
readonly whenIdle?: "reject";
|
|
23
|
+
readonly onAbort?: "withdraw" | "keep";
|
|
22
24
|
readonly entry?: import("@earendil-works/pi-durable").InputEntry;
|
|
23
25
|
}, InputState, InputResult, object>;
|
|
24
26
|
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
|
+
import { type Conversation, type ConversationId, type GenerationHooks, type HookApi, type SubmissionId, type TaskId, type Tx } from "@earendil-works/pi-durable";
|
|
3
|
+
import { type ContextHost } from "./lifecycle.ts";
|
|
4
|
+
import { type PreparedRole } from "./model-roles.ts";
|
|
5
|
+
import { type BeforeRollover } from "./rollover-preparation.ts";
|
|
6
|
+
import { type WindowIdentity } from "./window-state.ts";
|
|
7
|
+
export type WindowRequest = {
|
|
8
|
+
tool: TaskId;
|
|
9
|
+
nested?: {
|
|
10
|
+
cell: TaskId;
|
|
11
|
+
checkpoint: TaskId;
|
|
12
|
+
nativeTool: TaskId;
|
|
13
|
+
};
|
|
14
|
+
window: WindowIdentity;
|
|
15
|
+
role?: PreparedRole;
|
|
16
|
+
resume?: false;
|
|
17
|
+
};
|
|
18
|
+
export declare const ToolWindow: import("@earendil-works/pi-durable").TaskDocToken<{
|
|
19
|
+
request?: WindowRequest;
|
|
20
|
+
finished?: boolean;
|
|
21
|
+
}>;
|
|
22
|
+
export declare const DeferredWindow: import("@earendil-works/pi-durable").ConversationDocToken<{
|
|
23
|
+
pending?: {
|
|
24
|
+
input: SubmissionId;
|
|
25
|
+
request: WindowRequest;
|
|
26
|
+
};
|
|
27
|
+
}>;
|
|
28
|
+
export declare function finishesInFreshWindow(api: HookApi, context: Context): Promise<boolean>;
|
|
29
|
+
export declare function armDeferredWindow(conv: Conversation, generation: TaskId, ready: (tx: Tx) => Promise<boolean>, context: Context): Promise<void>;
|
|
30
|
+
export declare function deferredRolloverHooks(host: () => ContextHost, beforeRollover: BeforeRollover | undefined, cut: (tx: Tx, id: ConversationId, request: WindowRequest) => Promise<void>): Pick<GenerationHooks, "onYield" | "afterRun">;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import { type Conversation, type ConversationId, type EntryRecord, type Storage } from "@earendil-works/pi-durable";
|
|
3
3
|
export type HistoryEntry = {
|
|
4
4
|
windowId: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import { type Conversation, type ConversationId, type Storage } from "@earendil-works/pi-durable";
|
|
3
3
|
import { Type } from "typebox";
|
|
4
4
|
import type { RankedHistory } from "./history-ranker.ts";
|
|
@@ -70,7 +70,23 @@ export declare function createHistoryTool(options: {
|
|
|
70
70
|
tool_name?: string | null;
|
|
71
71
|
tool_namespace?: string | null;
|
|
72
72
|
window_id?: string | null;
|
|
73
|
-
}, api: import("@earendil-works/pi-durable").ToolExecutionApi<import("@earendil-works/chord").JsonValue>, context: Context): Promise<import("@earendil-works/pi-durable").ToolExecutionResult<import("@earendil-works/chord").JsonValue>>;
|
|
73
|
+
}, api: import("@earendil-works/pi-durable").ToolExecutionApi<import("@earendil-works/chord/json").JsonValue, import("@earendil-works/chord/json").JsonValue>, context: Context): Promise<import("@earendil-works/pi-durable").ToolExecutionResult<import("@earendil-works/chord/json").JsonValue> | import("@earendil-works/pi-durable").ToolPark<import("@earendil-works/chord/json").JsonValue>>;
|
|
74
|
+
cancel?(args: {
|
|
75
|
+
action?: "help" | "list" | "list_windows" | "read" | "search";
|
|
76
|
+
target?: string;
|
|
77
|
+
item_id?: string;
|
|
78
|
+
agent_name?: string | null;
|
|
79
|
+
limit?: number;
|
|
80
|
+
limit_chars?: number;
|
|
81
|
+
max_chars_per_item?: number;
|
|
82
|
+
offset_chars?: number;
|
|
83
|
+
query?: string;
|
|
84
|
+
recent_first?: boolean;
|
|
85
|
+
role?: "assistant" | "developer" | "system" | "tool" | "user" | null;
|
|
86
|
+
tool_name?: string | null;
|
|
87
|
+
tool_namespace?: string | null;
|
|
88
|
+
window_id?: string | null;
|
|
89
|
+
}, api: import("@earendil-works/pi-durable").ToolExecutionApi<import("@earendil-works/chord/json").JsonValue, import("@earendil-works/chord/json").JsonValue>, context: Context): Promise<void>;
|
|
74
90
|
executionHints: {
|
|
75
91
|
discovery: "help";
|
|
76
92
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import type { Models } from "@earendil-works/pi-ai";
|
|
3
3
|
import type { ConversationId, Harness, InputSubmissionDraft, Storage, TaskId } from "@earendil-works/pi-durable";
|
|
4
4
|
import type { RankedHistory } from "./history-ranker.ts";
|
|
@@ -6,12 +6,14 @@ import { type InputResult } from "./lifecycle.ts";
|
|
|
6
6
|
import type { ContextModelRoles } from "./model-roles.ts";
|
|
7
7
|
import type { ContextRemoteCatalog } from "./remote.ts";
|
|
8
8
|
import type { BeforeRollover } from "./rollover-preparation.ts";
|
|
9
|
+
import type { RolloverTailMode } from "./rollover-tail.ts";
|
|
9
10
|
export type { HistoryRanker, RankedHistory } from "./history-ranker.ts";
|
|
10
11
|
export type { InputResult } from "./lifecycle.ts";
|
|
11
12
|
export type { ContextModelRole, ContextModelRoles } from "./model-roles.ts";
|
|
12
13
|
export { readSavedNotes, type SavedNote } from "./note-store.ts";
|
|
13
14
|
export type { ContextRemoteCatalog } from "./remote.ts";
|
|
14
15
|
export type { BeforeRollover } from "./rollover-preparation.ts";
|
|
16
|
+
export type { RolloverTailMode } from "./rollover-tail.ts";
|
|
15
17
|
export type { TransitionResult, WindowIdentity } from "./window-state.ts";
|
|
16
18
|
/** Policy for model-requested context windows. */
|
|
17
19
|
export type NewContextRequests = "off" | "pi-limits" | "unrestricted";
|
|
@@ -28,9 +30,15 @@ export declare function createContextManagement(options: {
|
|
|
28
30
|
modelRoles?: ContextModelRoles;
|
|
29
31
|
/** Opt in to a host-owned stable family and agent namespace. No local fallback. */
|
|
30
32
|
remote?: ContextRemoteCatalog;
|
|
33
|
+
/** Disable the local notes registration when a separate notes component owns it. */
|
|
34
|
+
localNotes?: boolean;
|
|
31
35
|
now?: () => number;
|
|
32
36
|
/** Agent-requested rollover policy. `pi-limits` requires the host's history-eligibility signal below. */
|
|
33
37
|
newContextRequests?: NewContextRequests;
|
|
38
|
+
/** Allow new_context with resume:false to cut after the final answer, without starting another turn. */
|
|
39
|
+
taskCompletionRollover?: boolean;
|
|
40
|
+
/** Keep the model-visible tail from a completed save on manual and idle cuts. Default: off. */
|
|
41
|
+
rolloverTail?: RolloverTailMode;
|
|
34
42
|
/** Read-only host signal for history eligible for a new window; errors fail closed. */
|
|
35
43
|
hasEligibleContextHistory?: (conversationId: ConversationId, context: Context) => boolean | Promise<boolean>;
|
|
36
44
|
automaticIdleRollover?: boolean;
|
|
@@ -53,6 +61,7 @@ export declare function createContextManagement(options: {
|
|
|
53
61
|
status(id: ConversationId, context: Context): Promise<{
|
|
54
62
|
window: Readonly<{
|
|
55
63
|
window?: import("./window-state.ts").WindowIdentity;
|
|
64
|
+
selectedRole?: string;
|
|
56
65
|
entry?: import("@earendil-works/pi-durable").EntryId;
|
|
57
66
|
settlement?: {
|
|
58
67
|
observedAt: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import type { TaskId } from "@earendil-works/pi-durable";
|
|
3
3
|
import type { ComponentInputPlacement } from "@howaboua/pi-durable-components";
|
|
4
4
|
import { type ContextHost, type InputResult } from "./lifecycle.ts";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import { type ConversationId, type TaskId, type Tx } from "@earendil-works/pi-durable";
|
|
3
3
|
import { type ContextHost } from "./lifecycle.ts";
|
|
4
4
|
/** Start trusted component instructions only, never user or peer content. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import type { Conversation, ConversationId, DocumentWatch, Harness, JsonObject, Storage, SubmissionId, SubmissionSettlement, TaskId, Tx } from "@earendil-works/pi-durable";
|
|
3
3
|
import { type TransitionResult } from "./window-state.ts";
|
|
4
4
|
export declare const INPUT_TASK = "howaboua.context.input";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import type { Models, ModelThinkingLevel } from "@earendil-works/pi-ai";
|
|
3
3
|
import { type Agent, type ConversationId, type ModelRef, type Tx } from "@earendil-works/pi-durable";
|
|
4
4
|
/** User-owned role preferences. The host owns configuration paths and access policy. */
|
|
@@ -20,7 +20,7 @@ export type PreparedRole = {
|
|
|
20
20
|
thinkingLevel: ModelThinkingLevel;
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
|
-
export declare function renderModelRoles(catalog: ContextModelRoles | undefined, id: ConversationId,
|
|
23
|
+
export declare function renderModelRoles(catalog: ContextModelRoles | undefined, id: ConversationId, selected: string | undefined, context: Context): Promise<string>;
|
|
24
24
|
export declare function prepareRole(catalog: ContextModelRoles | undefined, id: string, conversationId: ConversationId, source: Agent, models: Models, context: Context): Promise<PreparedRole>;
|
|
25
25
|
/** Checked in the same transaction as the model selection and window cut. */
|
|
26
26
|
export declare function roleSourceMatches(tx: Tx, id: ConversationId, role: PreparedRole): Promise<boolean>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import type { ConversationId, DocumentReader, EntryId, Storage, TaskId, Tx } from "@earendil-works/pi-durable";
|
|
3
3
|
export type NoteMetadata = {
|
|
4
4
|
path: string;
|
|
@@ -11,6 +11,11 @@ type NoteFreshness = {
|
|
|
11
11
|
windowId: string;
|
|
12
12
|
userEntry: EntryId | null;
|
|
13
13
|
assistantEntry?: EntryId;
|
|
14
|
+
execution?: {
|
|
15
|
+
cell: TaskId;
|
|
16
|
+
tool: TaskId;
|
|
17
|
+
call: string;
|
|
18
|
+
};
|
|
14
19
|
taskId: TaskId;
|
|
15
20
|
updatedAt: number;
|
|
16
21
|
};
|
|
@@ -31,7 +36,13 @@ export type SavedNote = {
|
|
|
31
36
|
/** Supply an immutable storage view for coherent catalog/body reads. Storage stays caller-owned. */
|
|
32
37
|
export declare function readSavedNotes(storage: Storage, conversationId: ConversationId, context: Context): Promise<SavedNote[]>;
|
|
33
38
|
export declare function readNoteText(tx: Tx, id: ConversationId, path: string): Promise<string>;
|
|
39
|
+
export declare function successfulTask(tx: Tx, id: TaskId, owner?: TaskId): Promise<boolean>;
|
|
40
|
+
/** The completed write and requesting invocation must share the same admission, not merely a cell ID. */
|
|
41
|
+
export declare function sameCellCheckpoint(tx: Tx, id: ConversationId, request: TaskId, execution: NonNullable<NoteFreshness["execution"]>): Promise<TaskId | undefined>;
|
|
34
42
|
export declare function notesAreFresh(tx: Tx, id: ConversationId): Promise<boolean>;
|
|
43
|
+
export declare function isCurrentCheckpoint(tx: Tx, id: ConversationId, checkpoint: TaskId): Promise<boolean>;
|
|
44
|
+
/** Resolve the successful write to the outer model round, including nested tool calls. */
|
|
45
|
+
export declare function latestNoteRound(tx: Tx, id: ConversationId): Promise<EntryId | undefined>;
|
|
35
46
|
/** A requested cut needs a completed save in the immediately preceding native tool round. */
|
|
36
47
|
export declare function notesPrecedeRequest(tx: Tx, id: ConversationId, request: TaskId): Promise<boolean>;
|
|
37
48
|
/** Commit before validation/mutation so a rejected replacement cannot reuse an older save. */
|
|
@@ -69,7 +69,24 @@ export declare function createNotesTool(options: {
|
|
|
69
69
|
limit_chars?: number;
|
|
70
70
|
offset_chars?: number;
|
|
71
71
|
text?: string;
|
|
72
|
-
}, api: import("@earendil-works/pi-durable").ToolExecutionApi<import("@earendil-works/chord").JsonValue>, context: import("@earendil-works/chord").Context): Promise<import("@earendil-works/pi-durable").ToolExecutionResult<import("@earendil-works/chord").JsonValue>>;
|
|
72
|
+
}, api: import("@earendil-works/pi-durable").ToolExecutionApi<import("@earendil-works/chord/json").JsonValue, import("@earendil-works/chord/json").JsonValue>, context: import("@earendil-works/chord/context").Context): Promise<import("@earendil-works/pi-durable").ToolExecutionResult<import("@earendil-works/chord/json").JsonValue> | import("@earendil-works/pi-durable").ToolPark<import("@earendil-works/chord/json").JsonValue>>;
|
|
73
|
+
cancel?(args: {
|
|
74
|
+
action?: "append" | "help" | "list" | "read" | "search" | "write";
|
|
75
|
+
target?: string;
|
|
76
|
+
agent_name?: string | null;
|
|
77
|
+
file_order?: "ascending" | "descending";
|
|
78
|
+
file_order_by?: "created_at" | "name" | "updated_at";
|
|
79
|
+
limit?: number;
|
|
80
|
+
max_matches_per_file?: number;
|
|
81
|
+
path?: string | null;
|
|
82
|
+
query?: string;
|
|
83
|
+
recent_file_first?: boolean;
|
|
84
|
+
start_line?: number | null;
|
|
85
|
+
stop_line?: number | null;
|
|
86
|
+
limit_chars?: number;
|
|
87
|
+
offset_chars?: number;
|
|
88
|
+
text?: string;
|
|
89
|
+
}, api: import("@earendil-works/pi-durable").ToolExecutionApi<import("@earendil-works/chord/json").JsonValue, import("@earendil-works/chord/json").JsonValue>, context: import("@earendil-works/chord/context").Context): Promise<void>;
|
|
73
90
|
executionHints: {
|
|
74
91
|
discovery: "help";
|
|
75
92
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import type { Models } from "@earendil-works/pi-ai";
|
|
3
3
|
import type { ConversationId, Harness, Storage } from "@earendil-works/pi-durable";
|
|
4
4
|
import { Type } from "typebox";
|
|
@@ -8,6 +8,7 @@ export declare function createContextPolicy(options: {
|
|
|
8
8
|
models: Models;
|
|
9
9
|
taskBoundaryReminderTokens: number;
|
|
10
10
|
newContextRequests: "off" | "pi-limits" | "unrestricted";
|
|
11
|
+
taskCompletionRollover: boolean;
|
|
11
12
|
modelRoles?: ContextModelRoles | undefined;
|
|
12
13
|
archiveHistory?: boolean;
|
|
13
14
|
rankedHistory?: RankedHistory | undefined;
|
|
@@ -20,5 +21,5 @@ export declare function createContextPolicy(options: {
|
|
|
20
21
|
}): {
|
|
21
22
|
sections: import("@earendil-works/pi-durable").PromptSection<import("@earendil-works/pi-durable").ToolRegistration>[];
|
|
22
23
|
hooks: import("@earendil-works/pi-durable").HookRegistration[];
|
|
23
|
-
remainingTool: import("@earendil-works/pi-durable").ToolRegistration<Type.TObject<{}>, import("@earendil-works/chord").JsonValue>;
|
|
24
|
+
remainingTool: import("@earendil-works/pi-durable").ToolRegistration<Type.TObject<{}>, import("@earendil-works/chord/json").JsonValue, import("@earendil-works/chord/json").JsonValue>;
|
|
24
25
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import type { ConversationId, Storage } from "@earendil-works/pi-durable";
|
|
3
3
|
/** Host-owned stable family identities. This read-only catalogue never grants visibility. */
|
|
4
4
|
export interface ContextRemoteCatalog {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import { type Conversation, type ConversationId, type EntryId, type TaskId, type Tx } from "@earendil-works/pi-durable";
|
|
3
3
|
export type BeforeRollover = (request: {
|
|
4
4
|
conversationId: ConversationId;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
|
+
import type { ContextEdit, Conversation, EntryId, Tx } from "@earendil-works/pi-durable";
|
|
3
|
+
export type RolloverTailMode = "off" | "conversation" | "full";
|
|
4
|
+
type RolloverTail = {
|
|
5
|
+
head: EntryId;
|
|
6
|
+
tip: EntryId;
|
|
7
|
+
edits: ContextEdit[];
|
|
8
|
+
};
|
|
9
|
+
/** Use references and context edits, not duplicated transcript entries or a second history store. */
|
|
10
|
+
export declare function projectRolloverTail(conv: Conversation, mode: Exclude<RolloverTailMode, "off">, context: Context): Promise<RolloverTail | undefined>;
|
|
11
|
+
export declare function rolloverTailMatches(tx: Tx, conv: Conversation, tail: RolloverTail): Promise<boolean>;
|
|
12
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import type { ConversationId, SubmissionId, TaskId, Tx } from "@earendil-works/pi-durable";
|
|
3
3
|
import { type ContextHost } from "./lifecycle.ts";
|
|
4
4
|
import { type BeforeRollover } from "./rollover-preparation.ts";
|
|
5
|
+
import { type RolloverTailMode } from "./rollover-tail.ts";
|
|
5
6
|
import { type TransitionResult, type WindowIdentity } from "./window-state.ts";
|
|
6
7
|
type RolloverInput = {
|
|
7
8
|
reason: "idle" | "manual" | "tool";
|
|
@@ -26,7 +27,7 @@ type RolloverState = {
|
|
|
26
27
|
window: WindowIdentity;
|
|
27
28
|
generation: TaskId;
|
|
28
29
|
};
|
|
29
|
-
export declare function createRollover(host: () => ContextHost, beforeRollover?: BeforeRollover): import("@earendil-works/pi-durable").Task<RolloverInput, RolloverState, TransitionResult, object>;
|
|
30
|
+
export declare function createRollover(host: () => ContextHost, beforeRollover?: BeforeRollover, tailMode?: RolloverTailMode): import("@earendil-works/pi-durable").Task<RolloverInput, RolloverState, TransitionResult, object>;
|
|
30
31
|
export declare function scheduleRollover(tx: Tx, id: ConversationId, task: ReturnType<typeof createRollover>, reason: RolloverInput["reason"], owner?: TaskId): Promise<TaskId<TransitionResult>>;
|
|
31
32
|
export declare function transitionResult(host: ContextHost, id: TaskId<TransitionResult>, context: Context): Promise<TransitionResult>;
|
|
32
33
|
export {};
|
|
@@ -51,10 +51,12 @@ export declare const notesParameters: Type.TObject<{
|
|
|
51
51
|
}>;
|
|
52
52
|
export type NotesArguments = Static<typeof notesParameters>;
|
|
53
53
|
export type HistoryArguments = Static<typeof historyParameters>;
|
|
54
|
-
export declare
|
|
54
|
+
export declare function newContextParameters(taskCompletionRollover: boolean): Type.TObject<{
|
|
55
|
+
resume?: Type.TOptional<Type.TBoolean>;
|
|
55
56
|
role: Type.TOptional<Type.TString>;
|
|
56
57
|
}>;
|
|
57
|
-
export declare function prepareNewContextArguments(input: unknown): {
|
|
58
|
+
export declare function prepareNewContextArguments(input: unknown, taskCompletionRollover: boolean): {
|
|
59
|
+
resume: unknown;
|
|
58
60
|
role?: string;
|
|
59
61
|
};
|
|
60
62
|
export declare function prepareNotesArguments(input: unknown): NotesArguments;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import { type ConversationId } from "@earendil-works/pi-durable";
|
|
3
3
|
import { type ContextHost } from "./lifecycle.ts";
|
|
4
4
|
import { type ContextModelRoles } from "./model-roles.ts";
|
|
@@ -6,6 +6,7 @@ import { type BeforeRollover } from "./rollover-preparation.ts";
|
|
|
6
6
|
/** A tool-requested cut stays inside its native input, so every submission waiter sees the final answer. */
|
|
7
7
|
export declare function createToolRollover(host: () => ContextHost, now: () => number, policy: {
|
|
8
8
|
newContextRequests: "off" | "pi-limits" | "unrestricted";
|
|
9
|
+
taskCompletionRollover: boolean;
|
|
9
10
|
modelRoles?: ContextModelRoles | undefined;
|
|
10
11
|
beforeRollover?: BeforeRollover | undefined;
|
|
11
12
|
hasEligibleContextHistory?: (conversationId: ConversationId, context: Context) => boolean | Promise<boolean>;
|
|
@@ -14,12 +15,14 @@ export declare function createToolRollover(host: () => ContextHost, now: () => n
|
|
|
14
15
|
name: string;
|
|
15
16
|
description: string;
|
|
16
17
|
parameters: import("typebox").TObject<{
|
|
18
|
+
resume?: import("typebox").TOptional<import("typebox").TBoolean>;
|
|
17
19
|
role: import("typebox").TOptional<import("typebox").TString>;
|
|
18
20
|
}>;
|
|
19
21
|
constrainedSampling?: false | import("@earendil-works/pi-ai").ConstrainedSamplingConfig;
|
|
20
22
|
replay?: "safe" | "unsafe";
|
|
21
23
|
executionMode?: import("@earendil-works/pi-durable").ToolExecutionMode;
|
|
22
24
|
prepareArguments?(args: unknown): {
|
|
25
|
+
resume?: unknown;
|
|
23
26
|
role?: string;
|
|
24
27
|
};
|
|
25
28
|
structuredOutputSchema?: object;
|
|
@@ -31,10 +34,15 @@ export declare function createToolRollover(host: () => ContextHost, now: () => n
|
|
|
31
34
|
readonly retain?: "head" | "tail";
|
|
32
35
|
};
|
|
33
36
|
execute(args: {
|
|
37
|
+
resume?: unknown;
|
|
34
38
|
role?: string;
|
|
35
|
-
}, api: import("@earendil-works/pi-durable").ToolExecutionApi<import("@earendil-works/chord").JsonValue>, context: Context): Promise<import("@earendil-works/pi-durable").ToolExecutionResult<import("@earendil-works/chord").JsonValue>>;
|
|
39
|
+
}, api: import("@earendil-works/pi-durable").ToolExecutionApi<import("@earendil-works/chord/json").JsonValue, import("@earendil-works/chord/json").JsonValue>, context: Context): Promise<import("@earendil-works/pi-durable").ToolExecutionResult<import("@earendil-works/chord/json").JsonValue> | import("@earendil-works/pi-durable").ToolPark<import("@earendil-works/chord/json").JsonValue>>;
|
|
40
|
+
cancel?(args: {
|
|
41
|
+
resume?: unknown;
|
|
42
|
+
role?: string;
|
|
43
|
+
}, api: import("@earendil-works/pi-durable").ToolExecutionApi<import("@earendil-works/chord/json").JsonValue, import("@earendil-works/chord/json").JsonValue>, context: Context): Promise<void>;
|
|
36
44
|
executionHints: {
|
|
37
|
-
|
|
45
|
+
nestedHidden: true;
|
|
38
46
|
};
|
|
39
47
|
};
|
|
40
48
|
hooks: import("@earendil-works/pi-durable").HookRegistration[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/chord";
|
|
1
|
+
import type { Context } from "@earendil-works/chord/context";
|
|
2
2
|
import type { AssistantMessage, Models } from "@earendil-works/pi-ai";
|
|
3
3
|
import type { Conversation } from "@earendil-works/pi-durable";
|
|
4
4
|
/** Provider usage is a baseline, not an exact measurement of the unsent tail. */
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ConversationId, type TaskId, type Tx } from "@earendil-works/pi-durable";
|
|
2
|
+
/** Admission provenance, not authorization: consumers must still verify the live originating slot. */
|
|
3
|
+
export type ToolOrigin = {
|
|
4
|
+
conversationId: ConversationId;
|
|
5
|
+
taskId: TaskId;
|
|
6
|
+
callId: string;
|
|
7
|
+
};
|
|
8
|
+
/** Host-written metadata. Never populated from tool arguments or inferred from the latest turn. */
|
|
9
|
+
export declare const ToolOriginDoc: import("@earendil-works/pi-durable").TaskDocToken<{
|
|
10
|
+
origin?: ToolOrigin;
|
|
11
|
+
}>;
|
|
12
|
+
/** A direct execution invocation has an independently settled result and an admission snapshot. */
|
|
13
|
+
export declare function admittedExecutionCall(tx: Tx, conversation: ConversationId, child: TaskId): Promise<{
|
|
14
|
+
cell: TaskId<import("@earendil-works/chord/json").JsonValue>;
|
|
15
|
+
tool: TaskId<import("@earendil-works/chord/json").JsonValue>;
|
|
16
|
+
call: string;
|
|
17
|
+
} | undefined>;
|
|
18
|
+
/** Resolve immutable admission, never the latest observed assistant entry. */
|
|
19
|
+
export declare function admittedToolRound(tx: Tx, conversation: ConversationId, child: TaskId): Promise<import("@earendil-works/pi-durable").EntryId | undefined>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@howaboua/pi-durable-context",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Local notes, retained history and durable context rollover",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
],
|
|
42
42
|
"sideEffects": false,
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"typebox": "1.
|
|
45
|
-
"@howaboua/pi-durable-components": "0.
|
|
44
|
+
"typebox": "1.4.7",
|
|
45
|
+
"@howaboua/pi-durable-components": "0.13.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@earendil-works/chord": "1.
|
|
49
|
-
"@earendil-works/pi-ai": "1.
|
|
50
|
-
"@earendil-works/pi-durable": "1.
|
|
51
|
-
"@modelcontextprotocol/sdk": ">=1.
|
|
48
|
+
"@earendil-works/chord": "1.8.0",
|
|
49
|
+
"@earendil-works/pi-ai": "1.8.0",
|
|
50
|
+
"@earendil-works/pi-durable": "1.8.0",
|
|
51
|
+
"@modelcontextprotocol/sdk": ">=1.32.2 <2"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|