@howaboua/pi-durable-context 0.0.0-stage → 0.10.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/LICENSE +21 -0
- package/NOTICE +63 -0
- package/README.md +168 -2
- package/dist/activation.js +2953 -0
- package/dist/history-search-worker.js +85 -0
- package/dist/index.js +2703 -0
- package/dist/internal/context-visibility.d.ts +6 -0
- package/dist/node.js +124 -0
- package/dist/packages/context/src/activation.d.ts +20 -0
- package/dist/packages/context/src/admission.d.ts +23 -0
- package/dist/packages/context/src/history-archive.d.ts +24 -0
- package/dist/packages/context/src/history-items.d.ts +17 -0
- package/dist/packages/context/src/history-ranker.d.ts +27 -0
- package/dist/packages/context/src/history-search-worker.d.ts +15 -0
- package/dist/packages/context/src/history.d.ts +80 -0
- package/dist/packages/context/src/index.d.ts +76 -0
- package/dist/packages/context/src/input-placement.d.ts +6 -0
- package/dist/packages/context/src/instruction-run.d.ts +13 -0
- package/dist/packages/context/src/lifecycle.d.ts +40 -0
- package/dist/packages/context/src/model-roles.d.ts +26 -0
- package/dist/packages/context/src/node.d.ts +10 -0
- package/dist/packages/context/src/note-path.d.ts +2 -0
- package/dist/packages/context/src/note-store.d.ts +53 -0
- package/dist/packages/context/src/notes.d.ts +76 -0
- package/dist/packages/context/src/policy.d.ts +24 -0
- package/dist/packages/context/src/presentation.d.ts +52 -0
- package/dist/packages/context/src/query-input.d.ts +3 -0
- package/dist/packages/context/src/remote.d.ts +34 -0
- package/dist/packages/context/src/rollover-preparation.d.ts +16 -0
- package/dist/packages/context/src/rollover.d.ts +32 -0
- package/dist/packages/context/src/tool-contract.d.ts +85 -0
- package/dist/packages/context/src/tool-rollover.d.ts +41 -0
- package/dist/packages/context/src/usage.d.ts +24 -0
- package/dist/packages/context/src/window-state.d.ts +37 -0
- package/dist/presentation.js +93 -0
- package/package.json +70 -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,63 @@
|
|
|
1
|
+
Notes and History input contracts and configured role handoffs adapted from
|
|
2
|
+
howaboua-pi-stuff revision e4aa5bb43c560b722829a5123b3f2e05d3d9a19d,
|
|
3
|
+
including merged PRs #561 and #567. Native configuration, model selection and
|
|
4
|
+
chronological guidance use public Durable APIs. No Pi paths or TUI are carried.
|
|
5
|
+
|
|
6
|
+
Applicable PR #552 changes adapted from howaboua-pi-stuff revision
|
|
7
|
+
1338b66a1067c254fec46746ef96b6bd9456148b. TypeScript execution mode
|
|
8
|
+
and QuickJS Notebook are excluded. See docs/parity for native adaptations.
|
|
9
|
+
|
|
10
|
+
Minimal write receipts, targeted history errors and skill-reload guidance aligned
|
|
11
|
+
to pi-notes-compaction and pi-codex-conversion at revision
|
|
12
|
+
3d0faf5a6f0bc67c0bd9248d07da6ddfa901b281.
|
|
13
|
+
|
|
14
|
+
Source alignment inspected at Pi Stuff revision 7f3295e67a8e6146b2a6922b56a06fa4db5c3a32.
|
|
15
|
+
See docs/parity for carried changes and explicit native-environment exclusions.
|
|
16
|
+
|
|
17
|
+
Context notes, history contracts and lifecycle policy adapted from
|
|
18
|
+
@howaboua/pi-codex-conversion, revision
|
|
19
|
+
5dc8fa4bbded063f9c158e2af7a8a53eeaea7fbb.
|
|
20
|
+
Source: https://github.com/IgorWarzocha/howaboua-pi-stuff
|
|
21
|
+
The reference working tree also contained the local idle checkpoint changes
|
|
22
|
+
in window-kickoff.ts and window-manager.ts recorded in docs/parity/context.md.
|
|
23
|
+
Fresh-only idle rollover follows revision
|
|
24
|
+
f5b0483ed289c623b74a97f72606ce6ac57a03dd.
|
|
25
|
+
Host opt-in and task checkpoint guidance follow pi-notes-compaction revision
|
|
26
|
+
9b2707ac4490e3997738531f7202d971018ddab6.
|
|
27
|
+
Tool discovery and note argument aliases follow revisions 5291bc6f and
|
|
28
|
+
58935af5, inspected in snapshot 036dc876da5afc4ec27b64878ebb1cfb30c8211d.
|
|
29
|
+
Notes help, persistent-note guidance, compaction recovery guidance and concise
|
|
30
|
+
checkpoint prompts also follow 83781a25, ef4af742, ab4afd46 and 58935af5.
|
|
31
|
+
Modifications: Durable-native SQLite documents and tasks, one local notes
|
|
32
|
+
policy, durable admission and cancellation, provider-independent model usage,
|
|
33
|
+
and native-only rollover control through ordinary tool registrations.
|
|
34
|
+
|
|
35
|
+
Tree archive recovery, Remote family routing and rollover policy were compared
|
|
36
|
+
against canonical Pi Stuff revision 12c4357b. Native adaptations use Durable's
|
|
37
|
+
public retained entries, fork ancestry and compaction-summary references, with
|
|
38
|
+
bounded cancellable indexing and existing Context visibility checks. Optional
|
|
39
|
+
host-owned family catalogues resolve agent names to Durable conversations.
|
|
40
|
+
No Pi archive manifests, provider-private state or duplicate transcript store
|
|
41
|
+
are carried. Notes-only rollover still creates no summary.
|
|
42
|
+
|
|
43
|
+
MIT License
|
|
44
|
+
|
|
45
|
+
Copyright (c) 2026 Igor Warzocha
|
|
46
|
+
|
|
47
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
48
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
49
|
+
in the Software without restriction, including without limitation the rights
|
|
50
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
51
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
52
|
+
furnished to do so, subject to the following conditions:
|
|
53
|
+
|
|
54
|
+
The above copyright notice and this permission notice shall be included in all
|
|
55
|
+
copies or substantial portions of the Software.
|
|
56
|
+
|
|
57
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
58
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
59
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
60
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
61
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
62
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
63
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,169 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Context management for Durable
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Continue long conversations through saved notes and clean context windows. Notes, retained history, pending input and rollover progress live in the same SQLite database as your Durable conversation. No Codex account or provider-specific storage is required.
|
|
4
|
+
|
|
5
|
+
Requires Node 22.19 or newer and Durable 1.4.0.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install https://github.com/IgorWarzocha/pi-durable-components/releases/download/v0.10.0/howaboua-pi-durable-context-0.10.0.tgz
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Connect your host
|
|
12
|
+
|
|
13
|
+
Use your configured `models` collection and `model` reference. Install before opening the Harness, bind before resuming work, and send user input through `management.submit`.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { BACKGROUND_CONTEXT as ctx } from "@earendil-works/chord/context";
|
|
17
|
+
import { Harness, createRegistry } from "@earendil-works/pi-durable";
|
|
18
|
+
import { openNodeSqliteStorage } from "@earendil-works/pi-durable/storage/sqlite/node";
|
|
19
|
+
import { createContextManagement } from "@howaboua/pi-durable-context";
|
|
20
|
+
|
|
21
|
+
const storage = await openNodeSqliteStorage("conversation.sqlite");
|
|
22
|
+
const management = createContextManagement({ models });
|
|
23
|
+
const registry = createRegistry();
|
|
24
|
+
registry.install(management.extension);
|
|
25
|
+
const harness = await Harness.open(storage, { models, registry }, ctx);
|
|
26
|
+
management.bind(harness, storage);
|
|
27
|
+
const conversation = await harness.root(ctx, {
|
|
28
|
+
agent: { model, extensions: [management.extension] },
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const task = await management.submit(conversation.id, {
|
|
32
|
+
type: "input",
|
|
33
|
+
content: "Continue our work",
|
|
34
|
+
requestId: "message-001",
|
|
35
|
+
}, ctx);
|
|
36
|
+
const receipt = await harness.waitForTask(task, ctx);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The receipt uses Durable's normal task outcomes. A completed input result contains `status`, the native `submission` ID and either the final `answer` entry ID or an unanswered reason. A `new_context` tool call keeps the original native input open until the final answer. Delegation, watches and direct submission waits therefore see the same completion, without a Context-specific connector. Reusing a `requestId` returns the original task without admitting the input twice.
|
|
40
|
+
|
|
41
|
+
With Code or Notebook, also call `code.bind(harness)` or `notebook.bind(harness)`. The ordinary `notes`, `history` and `get_context_remaining` tools remain callable inside execution cells. `new_context` stays on the native model surface and must be called alone, outside a cell.
|
|
42
|
+
|
|
43
|
+
## What happens during a conversation
|
|
44
|
+
|
|
45
|
+
- `notes` reads and writes virtual paths under `/notes`. Relative paths resolve there. Notes are not workspace files. Each file is limited to 1 MB. Reads return the full selected lines by default. Optional `limit_chars` and `offset_chars` provide character paging. Search returns full matching lines. Supply `target` with another conversation's numeric ID as a string to read its notes when both conversations share a Context visibility group. Writes can only target the calling conversation.
|
|
46
|
+
- `history` searches retained entries by window and item ID, with bounded retrieval. Its optional `target` selects another conversation in the same storage and Context visibility group. Searches default to case-sensitive literal matches. Old history is never automatically reinserted into the prompt. Conversations without Context windows use `conversation:<id>` as their window ID.
|
|
47
|
+
- `new_context` requires fresh notes and a standalone native tool round. Without fresh notes it returns `checkpoint_required`, asking the model to save its checkpoint and call again. Once the round completes, it cuts the context and continues within the same native input. If queued input or other foreground work prevents a safe cut, the model receives an explicit skipped-rollover message and the window stays intact. The prompt lists recent note paths, not their contents.
|
|
48
|
+
- `newContextRequests` controls agent-requested windows: `unrestricted` (the source default) permits a new window at any history size, `off` removes the tool and its rollover reminders, and `pi-limits` requires eligible history. Supply the read-only `hasEligibleContextHistory(conversationId, context)` host signal for `pi-limits`; false leaves the window unchanged, and callback errors fail closed. The source mode invokes Pi compaction to determine eligibility; Durable uses this explicit host signal and does not emulate Pi compaction. The host's `management.newContext` API remains available in every mode.
|
|
49
|
+
- At 85% and 90% context usage, advisory reminders ask for a checkpoint. An optional token budget suggests finishing the current task and starting a fresh window before the next task. `get_context_remaining` reports provider usage plus an estimated tail, or explicitly reports an unknown budget.
|
|
50
|
+
- Automatic idle rollover defaults off. Enable it with `createContextManagement({ models, automaticIdleRollover: true })`. After 25 minutes of observed inactivity, the next managed input rolls only if the latest completed run saved fresh notes. Otherwise it is admitted normally, without a synthetic checkpoint. Its content, attachments and busy policy remain intact.
|
|
51
|
+
|
|
52
|
+
Set `idleRolloverMinutes` to `0`, `25`, `55`, `115`, `355` or `715` to choose the idle interval. Legacy `5` and `15` minute intervals are also supported. An explicit interval overrides `automaticIdleRollover`, including `0` to disable it. The boolean API still uses 25 minutes when enabled.
|
|
53
|
+
|
|
54
|
+
For models with a context larger than 272,000 tokens, `taskBoundaryReminderTokens` enables a once-per-window suggestion at a token budget. It defaults to `0`, disabled. Source presets are `250_000`, `300_000`, `400_000` and `450_000`; any non-negative safe integer is accepted. The suggestion does not force a rollover or replace the 85% and 90% reminders. Invalid configuration throws when creating the component.
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
const management = createContextManagement({
|
|
58
|
+
models,
|
|
59
|
+
idleRolloverMinutes: 55,
|
|
60
|
+
taskBoundaryReminderTokens: 300_000,
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The idle clock starts when this component observes actual input settlement. It does not use Durable's task timestamps. Recovery can delay the idle deadline, but cannot move it earlier by guessing from an assistant timestamp.
|
|
65
|
+
|
|
66
|
+
Notes uses `list`, `read`, `search`, `append` and `write`. `path` selects a file for reads and writes or a prefix for listing and searching. `limit` bounds listing and search results. History uses `list_windows`, `list`, `read` and `search`. Empty calls return help. Previous long action names and field aliases remain accepted, as do equivalent JSON strings in nested calls. Conflicting aliases and unknown operational fields reject.
|
|
67
|
+
|
|
68
|
+
Keep each task checkpoint at a stable note path and update it in place, including completion. Link separate reusable findings and deferred ideas instead of copying them. Deferred work is not authorization to implement. Include checkpoint paths in handoffs. The bootstrap lists only five recent paths; use `notes` list or search to find others.
|
|
69
|
+
|
|
70
|
+
Unassigned conversations in the same storage remain readable, including legacy conversations and host-created peers. When Agents assigns Context visibility groups, `notes` and `history` allow cross-conversation reads only within the caller's group; separate groups are isolated in both directions. Agents sharing defaults off, so a spawned worker gets a private group unless its controller enables sharing. A profile with `shareContext: false` also starts a private group, even when the controller enables sharing. A child can inherit its caller's group but cannot use profile sharing to widen it. Board membership does not grant or restrict Context visibility. This is a tool-level visibility policy, not a security boundary against other host tools or direct storage access. Use conversation IDs returned by Agents or the host. For example, `history` with `{"action":"search","target":"42","query":"deployment"}` searches a visible conversation without waking it. These reads do not copy its context into the caller's prompt beyond the requested results.
|
|
71
|
+
|
|
72
|
+
Normal threshold and manual compaction are declined. Overflow compaction remains an emergency fallback using the configured model, within the same logical window. For a host-initiated rollover, call `management.newContext(conversation.id, ctx)` and await its task. It requests a checkpoint through native instructions when needed, without inventing a user message or sending an extra continuation after the cut. Rollover instructions remain chronological system messages in Durable, projected to developer messages by providers that support that role. User and peer messages retain their original roles.
|
|
73
|
+
|
|
74
|
+
## Model roles
|
|
75
|
+
|
|
76
|
+
Supply `modelRoles(conversationId, context)` to expose user-configured roles authorised for that conversation. Each role has `id`, `description`, `provider`, `model` and `reasoning`. The host owns configuration storage and access policy. The agent sees only IDs, descriptions and guidance to switch for sustained scope changes rather than brief specialist detours.
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
const management = createContextManagement({
|
|
80
|
+
models,
|
|
81
|
+
modelRoles: (conversationId, context) => hostRoles(conversationId, context),
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
After saving its checkpoint, the agent can call `new_context({ role: "frontend" })`. The component checks the configured model and provider access, prepares the outgoing context through `beforeRollover`, then commits the new model, reasoning level and context window together. The same conversation resumes from its notes. Omitting `role` keeps the current model and reasoning. Missing roles, unavailable provider access, changed model settings, failed preparation or unsafe rollover leave the selection unchanged. Existing checkpoint and history-eligibility gates still apply. Disabling agent-requested windows also removes role guidance.
|
|
86
|
+
|
|
87
|
+
## Ranked history
|
|
88
|
+
|
|
89
|
+
Opt into keyword ranking for your own retired conversation text. Ranking requires all query words, ignores case and accents, and uses SQLite BM25 relevance order. `recent_first: true` selects newest matches instead. Active context, reasoning and tool activity are not indexed. Explicit current-window, tool, metadata and cross-conversation searches retain literal matching. Item IDs and full reads remain unchanged.
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
import { createNodeHistoryRanker } from "@howaboua/pi-durable-context/node";
|
|
93
|
+
|
|
94
|
+
const ranker = createNodeHistoryRanker({ path: hostHistoryIndexPath });
|
|
95
|
+
const management = createContextManagement({
|
|
96
|
+
models,
|
|
97
|
+
rankedHistory: {
|
|
98
|
+
ranker,
|
|
99
|
+
enabled: conversationId => hostSettings(conversationId).rankedHistory,
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The path must be an explicitly authorised absolute native path, separate from the Durable database. Use one index path per Durable storage. The host owns this grant, the live setting and `await ranker.close()` after draining the Harness. Omit `rankedHistory` to disable ranking entirely. A false `enabled` setting performs no indexing.
|
|
105
|
+
|
|
106
|
+
Custom `HistoryRanker` implementations must consume `items` as an iterable or async iterable. Earlier implementations that require array indexing need to be updated for streamed history.
|
|
107
|
+
|
|
108
|
+
The Node worker keeps derived contentless terms and IDs, not another transcript. It streams retired text in acknowledged batches at generation boundaries and before a ranked query, without keeping the full corpus in memory. There is no total history entry or byte ceiling. BM25 ties follow original entry chronology. Cancellation stops its work and rolls back an unfinished transaction. Background indexing failures do not interrupt ordinary replies. The next ranked search reports the failure and offers retry or disabling ranking; list and read actions remain available. The portable entry imports no native index code.
|
|
109
|
+
|
|
110
|
+
## Retained archives and agent namespaces
|
|
111
|
+
|
|
112
|
+
Set `archiveHistory: true` to include retained native fork branches in the ordinary `history` actions. It defaults off. Matching native compaction summaries come first in searches, followed by exact retained entries. Summary and recent user request IDs appear in context guidance, without their contents. Notes-only window changes do not invent summaries. Existing window and item IDs stay unchanged. Additional branch windows have opaque `archive:` IDs that can be passed straight to `read_item`.
|
|
113
|
+
|
|
114
|
+
The archive reader follows Durable's public fork ancestry, validates summary boundaries and checks visibility before reading another branch. It reads bounded pages without copying transcripts into another store. Catalogue and transcript scans have no total record ceiling and observe cancellation between pages and entries. An exact window restricts entry reads to its branch. Recovery hints search retained history for summary and recent-user IDs without a scan cutoff.
|
|
115
|
+
|
|
116
|
+
Hosts can opt into a stable family and agent namespace with `remote`. This resolves names to conversations in the same bound Durable storage, not to a provider account or a network backend:
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
const management = createContextManagement({
|
|
120
|
+
models,
|
|
121
|
+
remote: {
|
|
122
|
+
async catalog(caller, context) {
|
|
123
|
+
return hostContextCatalog(caller, context);
|
|
124
|
+
// { familyId, currentAgentName, agents: [{ agentName, conversationId }] }
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The host owns stable family identities, catalogue membership and cancellation of its catalogue lookup. The current agent must resolve to the caller. Agent names must be unique. `notes` and `history` help expose authorised agent names and numeric targets. Context overrides Durable's configurable output truncation defaults so discovery and note results remain complete. Existing actions accept `agent_name` when configured. Omit it to select the current agent, or supply either `agent_name` or numeric `target`, not both. Numeric targets must also belong to the configured family. Reads and discovered archive branches still require matching Context visibility groups. Notes writes remain caller-owned.
|
|
131
|
+
|
|
132
|
+
Missing agents, invalid catalogues and lookup failures are errors. They never fall back to the local namespace. Without `remote`, numeric targets work as before and agent names report that configuration is required. An interrupted dispatched write reports an uncertain outcome. Read the note before issuing another write. The component does not replay the side effect as a recovery strategy.
|
|
133
|
+
|
|
134
|
+
## Refresh connected services before rollover
|
|
135
|
+
|
|
136
|
+
Supply `beforeRollover(request, context)` when a connected service must capture the outgoing context before it is retired. For GipPity Voice, bind the matching conversation's controls:
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
const management = createContextManagement({
|
|
140
|
+
models,
|
|
141
|
+
beforeRollover: async ({ conversationId }, context) => {
|
|
142
|
+
await hostVoice(conversationId)?.controls.refreshContext(context.abortSignal);
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
The callback runs after checkpoint eligibility is established and before the window cut. Context rechecks native activity, queued input and the transcript afterwards. A failed refresh leaves the window intact. A recovered interrupted callback is not replayed: Context reports its uncertain outcome so the host can inspect the service before requesting another rollover. Saved notes inside failed or unfinished owning work do not authorise a cut.
|
|
148
|
+
|
|
149
|
+
## Resume and recover
|
|
150
|
+
|
|
151
|
+
Reopen the same database with the same extensions, bind the new component, then call `harness.resume()`. Persisted managed task IDs remain usable with `harness.getTask` and `harness.waitForTask`. Do not reinstall a different context policy over unfinished work.
|
|
152
|
+
|
|
153
|
+
Hosts that retain the component across Harness startup retries can call `management.unbind(harness)` before binding a replacement. First stop new host calls, drain in-flight calls and await closure of that Harness and its task invocations. Unbinding releases only the matching binding. It does not close the Harness, cancel work or change persisted state. Repeated or stale cleanup cannot clear a different Harness's binding. Keep the original Models collection valid across rebinding, or create a new component if that collection must be replaced. Install the extension before opening each replacement Harness and bind its exact storage before resuming.
|
|
154
|
+
|
|
155
|
+
If a checkpoint fails or finishes without saving fresh notes, the old window stays intact and pending input remains held. `management.status(id, ctx)` exposes the blocked reason. Call `management.retry(id, ctx)` or send a new user message to retry. Merely reopening the database or resubmitting an existing request ID does not retry it.
|
|
156
|
+
|
|
157
|
+
Use `harness.abortTask(task, ctx)` to cancel a managed request, including its pending rollover. Cancelling an idle checkpoint cancels the messages held behind it. Use `conversation.abort(ctx)` to stop all foreground work. Resubmit cancelled messages explicitly if you still want them processed.
|
|
158
|
+
|
|
159
|
+
Direct `conversation.submit` calls, including another extension's delegation or notifications, bypass managed idle admission. Route inputs through `management.submit` wherever that idle guarantee is needed. Native tool rollover works on directly submitted conversations and does not settle their inputs early. Host-initiated rollover still uses the managed checkpoint task and native idle boundary.
|
|
160
|
+
|
|
161
|
+
A window change preserves the conversation ID and live Code or Notebook runtime. A process restart does not preserve kernels or shell sessions. Close the Harness and storage using their normal lifecycle when the host exits. Notes and history remain local, but checkpoint and overflow-summary inference still use your configured model.
|
|
162
|
+
|
|
163
|
+
## Headless presentations
|
|
164
|
+
|
|
165
|
+
The browser-safe `@howaboua/pi-durable-context/presentation` entry provides validated host snapshots and pure summary and detail selectors, structurally compatible with `UiCapability` and `UiPresentation`. It does not import the UI runtime.
|
|
166
|
+
|
|
167
|
+
`contextCapability`, `contextSummaryPresentation` and `contextDetailPresentation` describe virtual notes. Populate `files` from the host-only `details.files` of `notes` with `list_files_by_prefix`. Populate nullable `detail` from `details.file` returned by `read_file`. The model-facing value omits byte counts and redundant timestamps; host details retain the complete presentation metadata. Counts and bytes describe only the supplied inventory, which can be bounded. Detail retains the returned line range, total line count and character-pagination metadata. `total_chars` is the UTF-16 length of the selected lines. When `next_offset_chars` is present, pass it as `offset_chars` to `read_file` with the same path and line range to retrieve the next page. Both fields remain optional for older snapshots. This is not `management.status` or the component's persisted rollover state.
|
|
168
|
+
|
|
169
|
+
Keep `detail: null` until the host acquires it. Detail must match an item in the supplied inventory. Refresh or clear detail when replacing that inventory. These snapshots are presentation data, not a replacement storage model or raw tool-result envelope. The host owns selection, freshness, binding, authorization and native controls. Summary requests identify a detail presentation but do not fetch data. Declared actions name the existing ordinary `notes` registration. Invoke it with its unchanged arguments and results through a host-authorized binding. No streams, transport adapters or additional lifecycle are introduced.
|