notesoup 0.51.1 → 0.51.3
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/dist/plugins/pi/entries.d.ts +2 -0
- package/dist/plugins/pi/entries.js +2 -0
- package/dist/plugins/pi/reset/artifacts.d.ts +10 -2
- package/dist/plugins/pi/reset/artifacts.js +24 -5
- package/dist/plugins/pi/reset/lifecycle.d.ts +37 -21
- package/dist/plugins/pi/reset/lifecycle.js +132 -57
- package/dist/plugins/pi/runtime.js +9 -10
- package/dist/plugins/pi/text.d.ts +11 -14
- package/dist/plugins/pi/text.js +15 -16
- package/dist/test/agent-loop.test.js +316 -163
- package/dist/test/boot.integration.test.js +3 -3
- package/dist/test/claude-validation.test.js +4 -2
- package/dist/test/dsh-cli.test.js +7 -6
- package/dist/test/helpers/dsh-messages.js +3 -0
- package/dist/test/model-facing-text.test.js +10 -4
- package/dist/test/reset-lifecycle.test.js +272 -88
- package/docs/architecture.md +1 -1
- package/docs/reset-lifecycle.md +42 -57
- package/package.json +2 -2
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/paseo/OVERVIEW.md +7 -0
- package/plugins/paseo/README.md +12 -0
- package/plugins/paseo/client/source-row.ts +14 -0
- package/plugins/paseo/client/sticky-card.tsx +21 -0
- package/plugins/paseo/index.client.tsx +10 -0
- package/plugins/paseo/package.json +19 -0
- package/plugins/paseo/paseo-plugin.json +4 -0
- package/plugins/paseo/shared/last-word.ts +6 -0
- package/plugins/paseo/test/source-row.test.ts +19 -0
- package/plugins/paseo/tsconfig.json +16 -0
- package/plugins/pi/entries.ts +2 -0
- package/plugins/pi/reset/artifacts.ts +26 -5
- package/plugins/pi/reset/lifecycle.ts +135 -70
- package/plugins/pi/runtime.ts +9 -10
- package/plugins/pi/text.ts +17 -17
package/docs/reset-lifecycle.md
CHANGED
|
@@ -1,87 +1,72 @@
|
|
|
1
1
|
# Reset lifecycle
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Boot acquisition/rendering is shared: `src/boot/snapshot.ts` receives explicit identity, a captured time and an optional scope loader; `src/boot/render.ts` receives the snapshot and logical tool bindings. Pi supplies its existing names. Shared history is an addressed query projection, never an inference transcript or reset scheduler. There is no generic HostEvent or Harness reducer, and no second commit database.
|
|
3
|
+
Pi reset control lives in `plugins/pi/reset/lifecycle.ts`: the pure `reduceResetControl` selects state transitions or boundary intents; after asynchronous construction, `finalizeResetBoundary` owns final state, carried inputs and continuation. `registerResetLifecycle` adapts public Pi events, constructs boundaries and applies the finalizer's result unchanged. `budget.ts` stages reminders and checks settings; `reset/artifacts.ts` builds and repairs ordered artifacts; `reset/committed.ts` confirms durable boundaries. `window.ts` owns identities and provider projection; `runtime.ts` wires commands and tools. No Pi source patches, native summarization requests, or second commit database are used.
|
|
6
4
|
|
|
7
5
|
## Lifecycle at a glance
|
|
8
6
|
|
|
7
|
+
**Human input not yet answered must survive a reset and be answered afterward. Only a bare `/empty` with no later human input stops after resetting.**
|
|
8
|
+
|
|
9
9
|
| Trigger | Behavior |
|
|
10
10
|
| --- | --- |
|
|
11
|
-
| `empty_brain` tool | Record
|
|
12
|
-
| `/fresh-window
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
2. A `notesoup/reset-marker` custom entry with `{ windowId, origin }`.
|
|
22
|
-
3. A hidden `notesoup/boot` custom message with matching `details.windowId`.
|
|
23
|
-
4. A hidden continuation message carrying the paragraph drawn for that boundary.
|
|
24
|
-
5. If the closing window passed a `last_word`, a visible `notesoup/reset-last-word` message carrying it. Pi boundary drafts do not support ordinary user entries, so the parting line is committed with the reset instead of queued separately.
|
|
11
|
+
| `empty_brain` tool | Record the actual call and optional last word. Without command policy, reset after the whole tool batch at `turn_end` and continue. Under command policy, wait for settlement. |
|
|
12
|
+
| `/empty <text>` or `/fresh-window <text>` | Send a hidden close-out warning (trigger when idle, steer when busy), then reset and continue. Carry the argument text verbatim as the next window's human message; it is not merely a notes hint. |
|
|
13
|
+
| Bare `/empty` or `/fresh-window` | Close out, reset, and stop, unless more human input arrives while close-out is pending. |
|
|
14
|
+
| Human input during command close-out | Intercept public `input` events except source `extension`, return `handled`, and stash text/images in command state. Also hidden-steer the bare `<notesoup:next_window_prompt>` block plus original images to the closing model. The originals are carried even if that steer never arrives; any carried input makes the reset continue. |
|
|
15
|
+
| Passive provider overflow / recoverable length | With automatic reset enabled, force a retain-none reset and continue once. Carry the failed logical run's human messages: starting prompt and delivered steering/follow-ups. A run started by our own continuation has no human input to carry. |
|
|
16
|
+
| Command close-out overflow | Force a reset even if automatic reset is disabled. Apply command policy: continue with text/carried input, otherwise stop. The recovery attempt is spent, so an oversized carried prompt cannot loop. |
|
|
17
|
+
| Budget warning | Stage reminders when automatic reset is enabled. Warnings alone never authorize reset. |
|
|
18
|
+
| Hard reserve | Independently reset at `turn_end` when automatic reset is enabled. A bare-command stop latch cancels empty tool follow-ups, but never real queued or carried human input. |
|
|
19
|
+
| Abort / ordinary error | Restore stashed originals as visible user-content custom messages before clearing command state. Explicit abort stays stopped; ordinary close-out errors do not force reset. |
|
|
20
|
+
| `/compact` while active | Cancel native compaction; manual attempts receive a `/fresh-window` notice. |
|
|
25
21
|
|
|
26
|
-
|
|
22
|
+
Switching to a smaller model does not proactively reset or select another model. If its request overflows, the same bounded automatic recovery carries the unanswered prompt into a fresh window on the selected model. Disabling automatic reset disables passive overflow recovery.
|
|
27
23
|
|
|
28
|
-
|
|
24
|
+
## Boundary order and handoff
|
|
29
25
|
|
|
30
|
-
|
|
26
|
+
One public boundary draft contains, in order:
|
|
31
27
|
|
|
32
|
-
|
|
28
|
+
1. A native `compaction` with `summary: ""` and `firstKeptEntryId: null` (Pi materializes its own ID: retain none).
|
|
29
|
+
2. A `notesoup/reset-marker` custom entry with `{ windowId, origin }`.
|
|
30
|
+
3. A hidden `notesoup/boot` custom message with matching `details.windowId`.
|
|
31
|
+
4. One hidden continuation paragraph, selected once when the artifact is built.
|
|
32
|
+
5. An optional visible `notesoup/reset-last-word` sticky note.
|
|
33
|
+
6. One visible `notesoup/carried-input` custom message per carried human input, preserving original text/image content and order.
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
Boundary drafts cannot contain ordinary user entries. Pi's public custom-message conversion supplies role `user` to the provider, including text/image arrays. Carried inputs are appended atomically with the reset artifacts, not queued as separate prompts; any carried input returns `continue: true`.
|
|
35
36
|
|
|
36
|
-
The
|
|
37
|
+
The origin is `normal` for an actual tool request, otherwise `forced`; overflow recovery is always forced. Each origin has an approved complete-paragraph pool. Construction draws once and persists the paragraph verbatim; rendering, reads, reloads and repair never redraw an existing continuation. Legacy markers without a valid origin default to normal. Other hosts retain their own scheduling: dsh shares one draw across checkpoint and continuation; Claude caches its forced handoff per window.
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
Raw session history remains available. The retain-none checkpoint excludes old conversational context while preserving Pi's empty summary wrapper and system/tool state. Marker-only legacy sessions use boot slicing as a compatibility fallback. A marker is checkpoint-backed only if it directly follows a self-retaining, empty native compaction.
|
|
39
40
|
|
|
40
|
-
## Reducer state
|
|
41
|
+
## Reducer and run state
|
|
41
42
|
|
|
42
|
-
`
|
|
43
|
+
`ResetControlState` combines a request, a bounded overflow phase, and an optional run-scoped `stopAfterReset` latch:
|
|
43
44
|
|
|
44
|
-
|
|
|
45
|
+
| Request | Meaning |
|
|
45
46
|
| --- | --- |
|
|
46
|
-
| `
|
|
47
|
-
| `
|
|
48
|
-
| `{ phase: "stop-pending", windowId, tool? }` | A manual hard-reserve reset was proposed for the given old window. The stop survives a committed window change; settlement stops without a second wipe (or retries construction if the old window is still active). New wipe requests only acknowledge it. |
|
|
49
|
-
|
|
50
|
-
| `overflow: "idle"` | No overflow recovery is pending. |
|
|
51
|
-
| `overflow: "pending"` | An overflow failure may recover once at pre-settlement. |
|
|
52
|
-
| `overflow: "pending-spent"` | Recovery was already spent in this failure chain. |
|
|
53
|
-
| `overflow: "spent"` | The one recovery has been used until the chain settles. |
|
|
54
|
-
|
|
55
|
-
### Transition rules
|
|
56
|
-
|
|
57
|
-
- `command(windowId, continueAfterReset)` stores settlement policy. Duplicate same-window commands retain the first policy; a pending tool request is retained.
|
|
58
|
-
- `tool_request(windowId, lastWord?)` records an actual call without changing command policy. Tool-only duplicates keep the first request; under command policy, repeated calls may supply the first nonempty last word.
|
|
59
|
-
- `turn_end` clears on abort. Overflow preserves command policy and its tool request; otherwise automatic recovery is armed only when enabled and unqueued. Other errors drop pending requests. Success commits a tool-only request or hard-reserve reset. Hard reserve under a bare command retains the cross-window `stop-pending` latch; a continuing command needs no stop latch.
|
|
60
|
-
- `agent_before_settle` waits for queued work. Command overflow resets even with automatic recovery disabled, honoring command continuation policy. Other overflow recovery gets one attempt. A committed stop latch stops without a second wipe; an uncommitted one can retry construction. Otherwise a successful command settles and resets. No command means no ordinary settle reset.
|
|
61
|
-
- `agent_settled`, session start/tree navigation/shutdown, `/notesoup off`, and abort clear transient request state. Durable checkpoint/marker history remains authoritative after transient state is gone.
|
|
62
|
-
|
|
63
|
-
After a manual safety reset, `context_with_system` verifies the committed checkpoint/marker/boot/continuation before using public `ctx.abort()` to cancel Pi's otherwise unavoidable tool-batch follow-up, returning a system-only safe context. Pending messages or a real user message after the reset marker bypass cancellation so queued work is not swallowed. A follow-up queue may require Pi's ordinary tool follow-up to finish before delivery; the stop intent remains armed until that work settles. Abort/settlement clears the run-scoped latch, so later user prompts work normally.
|
|
47
|
+
| `none` | No command or tool request. |
|
|
48
|
+
| `pending` | Current `windowId`, optional `tool: { lastWord? }`, and optional `command: { continueAfterReset, inputs? }`. Command inputs retain originals, not prompt-block wrappers. Duplicate commands retain the first policy/text; tool calls do not overwrite command policy. |
|
|
64
49
|
|
|
65
|
-
|
|
50
|
+
`stopAfterReset` is separate from the request. It retains the safety boundary's intent after construction, while `request` becomes `none`. Settlement waits for queued work; if the window changed, it stops without a second wipe. If the window did not change, the boundary never committed, so settlement retries the retained intent with its stop policy and tool origin intact. A successful settle retry consumes the latch.
|
|
66
51
|
|
|
67
|
-
|
|
52
|
+
Overflow phases are `idle`, `pending`, `spent`, and `pending-spent`. `turn_end` arms enabled recovery; `agent_before_settle` waits for queued work and selects recovery intent. Only successful, current construction reaches finalization and spends the attempt. A successful queued turn supersedes the failure. Command overflow spends the same bounded attempt before continuing. Abort, final settlement, session start/tree/shutdown and `/notesoup off` clear transient state.
|
|
68
53
|
|
|
69
|
-
The
|
|
54
|
+
The adapter collects actual user `message_end` content until settlement or a successful reset boundary. Low-level `agent_start` events do not clear it: Pi can start additional loops while draining follow-ups/recovering. Custom boot/warning/continuation messages are never mistaken for human input. Successful boundary construction clears this run collection, so an automatic continuation does not replay old input.
|
|
70
55
|
|
|
71
|
-
|
|
56
|
+
Command state remains live during asynchronous notes acquisition. Boundary intent captures the trigger, explicit `continueAfterReset` policy, tool fact and origin, but contains no final state or continuation decision. After construction passes the currentness guard, the pure finalizer selects live command-owned originals, or the current run's inputs only for passive recovery, and resolves `resumeModel` and the next control state together. `resumeModel` is true when the policy requests continuation or carried input needs an answer; the adapter maps it to Pi's `continue` field. Late originals therefore join the same boundary and prevent a stop latch from being installed; delivery contents never replace explicit command policy. Hidden steers carry window/command identity; provider projection excludes them once that command ends, including steers Pi delivers only after the reset. Originals remain available exactly once as carried input. Construction captures session/window generations and rechecks identity, enabled state and abort status before returning drafts. Clearing the run invalidates any unfinished construction before resetting its input collection. Stale work preserves incoming/budget entries but discards reset drafts; construction failures notify only while current and do not claim continuation. If close-out cannot commit, stashed originals are restored with public `sendMessage(..., { triggerTurn: false })`, including cancellation during construction; clearing command state must not erase input already reported as handled.
|
|
72
57
|
|
|
73
|
-
|
|
58
|
+
After a manual safety reset, `context_with_system` checks the committed boundary before using public `ctx.abort()` to cancel an unavoidable empty tool follow-up with system-only context. Pending messages, ordinary user entries or carried inputs after the marker bypass cancellation. Later user prompts are not affected by the run-scoped stop latch.
|
|
74
59
|
|
|
75
|
-
##
|
|
60
|
+
## Warnings, projection and repair
|
|
76
61
|
|
|
77
|
-
|
|
62
|
+
Budget reminders are staged once per window at reserve plus reminder margin, then reserve plus warning runway. Hard reserve remains independent. Budget and command warnings use different types. The final budget warning notifies at first provider injection, not durability; early guidance stays UI-silent. Budget drafts are instance-local and discarded on abort, failed turn, transition or window mismatch. Active-window usage and the exact public `SettingsManager` authority determine thresholds.
|
|
78
63
|
|
|
79
|
-
|
|
64
|
+
Manual warnings begin with the `/empty` notice inside `<notesoup:budget_notice>`, followed by `WARNING_BODY`, the last-word hint and countdown. Optional command text sits after the closing tag in `<notesoup:next_window_prompt>`. They omit budget timing hints. Pi's boot protocol and budget warnings explain that reset erases the human's view and leave timing to the model unless directed otherwise; other hosts do not inherit that Pi-only claim.
|
|
80
65
|
|
|
81
|
-
|
|
66
|
+
`context_with_system` selects the boot by durable window identity, using Pi's canonical checkpoint projection or legacy slicing. Missing boot aborts safely instead of exposing raw history. Usage estimates use the same projection decision. `/tree` summaries are suppressed when crossing reset branches because native branch summarization bypasses this projection.
|
|
82
67
|
|
|
83
|
-
|
|
68
|
+
`resetBoundaryCommitted` validates checkpoint -> marker -> matching hidden boot -> hidden continuation; trailing last words, carried input or later conversation cannot undo that committed prefix. `inspectResetTail` checks the entire repairable suffix: optional last word and carried inputs must follow the continuation, with no duplicate/misordered artifacts or later conversation. A carried input before boot/continuation blocks repair rather than allowing metadata to be appended after human content. Startup/tree repair only fills missing boot/continuation when safe, rechecking lifecycle identity after notes acquisition. UI success notices use committed confirmation, not repairability.
|
|
84
69
|
|
|
85
|
-
|
|
70
|
+
## Validation
|
|
86
71
|
|
|
87
|
-
|
|
72
|
+
Scripted SDK tests run Pi's real agent loop without network calls: smaller-model overflow and prompt replay, command text, bare stop, intercepted text/images, hard-reserve handling, overflowing close-out and bounded retry. They also cover passive tool-loop steering/follow-ups and input-free automatic continuations. Focused tests check late input during asynchronous construction, stale queued steer exclusion, abort/error restoration, ordered carry artifacts, commit confirmation, safe repair, canonical projection and persisted history. External-provider behavior and every malformed persisted/filesystem case are not established by this suite.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "notesoup",
|
|
3
|
-
"version": "0.51.
|
|
3
|
+
"version": "0.51.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/src/index.js",
|
|
6
6
|
"types": "./dist/src/index.d.ts",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json && node scripts/build-extension.mjs && node -e \"require('node:fs').chmodSync('dist/plugins/pi/dream/cli.js', 0o755)\"",
|
|
64
64
|
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p plugins/claude/tsconfig.json",
|
|
65
|
-
"test": "npm run build && node --test --test-concurrency=4 dist/test/*.test.js",
|
|
65
|
+
"test": "npm run build && node --test --test-concurrency=4 $(ls dist/test/*.test.js | grep -v dist/test/claude-validation.test.js) && node --test dist/test/claude-validation.test.js",
|
|
66
66
|
"prepublishOnly": "npm run typecheck",
|
|
67
67
|
"prepack": "npm run build"
|
|
68
68
|
},
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Notesoup last word
|
|
2
|
+
|
|
3
|
+
Displays notesoup last-word messages already present in Paseo’s timeline as expanded, selectable cards. Cards use the current theme and compact layout. Requires Paseo 0.11.2 on the client and daemon.
|
|
4
|
+
|
|
5
|
+
This client-only plugin transforms the existing custom-message row in place. It does not read session files or append messages. Other timeline items are unchanged.
|
|
6
|
+
|
|
7
|
+
Paseo 0.11.2 drops Pi boundary `entry_appended` events from its live timeline. This plugin cannot display messages that Paseo has not received; that adapter gap needs an upstream fix. Messages available through history can be rendered.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Notesoup Paseo plugin
|
|
2
|
+
|
|
3
|
+
Client-only last-word renderer. See [OVERVIEW.md](OVERVIEW.md) for behavior and the upstream live-event limitation.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
cd plugins/paseo
|
|
7
|
+
npm install --ignore-scripts --package-lock=false
|
|
8
|
+
npm run typecheck
|
|
9
|
+
npm test
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Install this directory with `paseo plugin install /absolute/path/to/plugins/paseo`. Source changes require `paseo plugin reload notesoup-last-word`; no daemon restart is needed.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PluginClientContext } from "@getpaseo/plugin/client";
|
|
2
|
+
import { CARD_KIND, LAST_WORD_TYPE } from "../shared/last-word.ts";
|
|
3
|
+
|
|
4
|
+
type Transformer = Extract<Parameters<PluginClientContext["addTimelineTransformer"]>[0], { query: { itemType: "tool_call" } }>;
|
|
5
|
+
type Source = Parameters<Transformer["transform"]>[0];
|
|
6
|
+
|
|
7
|
+
export const sourceRowTransformer = {
|
|
8
|
+
id: "last-word-source",
|
|
9
|
+
query: { itemType: "tool_call" },
|
|
10
|
+
transform: ({ item }: Pick<Source, "item">) => {
|
|
11
|
+
if (item.type !== "tool_call" || item.metadata?.customType !== LAST_WORD_TYPE || item.detail?.type !== "plain_text" || typeof item.detail.text !== "string") return undefined;
|
|
12
|
+
return { items: [{ type: "plugin" as const, kind: CARD_KIND, version: 1, data: { text: item.detail.text } }] };
|
|
13
|
+
},
|
|
14
|
+
} satisfies Transformer;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PluginTimelineItemProps } from "@getpaseo/plugin/client";
|
|
2
|
+
import { Text, View } from "react-native";
|
|
3
|
+
import type { LastWord } from "../shared/last-word.ts";
|
|
4
|
+
|
|
5
|
+
export function StickyCard({ item, theme, layout }: PluginTimelineItemProps<LastWord>) {
|
|
6
|
+
const text = item.data.text.replace(/^\*You peel a sticky note off your forehead\.\*\n/, "");
|
|
7
|
+
return (
|
|
8
|
+
<View style={{
|
|
9
|
+
padding: layout.compact ? 12 : 16,
|
|
10
|
+
gap: 8,
|
|
11
|
+
minWidth: 0,
|
|
12
|
+
borderRadius: 12,
|
|
13
|
+
borderWidth: 1,
|
|
14
|
+
borderColor: theme.colors.border,
|
|
15
|
+
backgroundColor: theme.colors.surface1,
|
|
16
|
+
}}>
|
|
17
|
+
<Text style={{ color: theme.colors.foregroundMuted, fontWeight: "600" }}>Last word</Text>
|
|
18
|
+
<Text selectable style={{ color: theme.colors.foreground, flexShrink: 1 }}>{text}</Text>
|
|
19
|
+
</View>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PluginClientContext } from "@getpaseo/plugin/client";
|
|
2
|
+
import { sourceRowTransformer } from "./client/source-row.ts";
|
|
3
|
+
import { StickyCard } from "./client/sticky-card.tsx";
|
|
4
|
+
import { CARD_KIND, lastWordSchema } from "./shared/last-word.ts";
|
|
5
|
+
|
|
6
|
+
export default function contribute(client: PluginClientContext) {
|
|
7
|
+
const removeRenderer = client.addTimelineRenderer({ kind: CARD_KIND, version: 1, schema: lastWordSchema, Component: StickyCard });
|
|
8
|
+
const removeTransformer = client.addTimelineTransformer(sourceRowTransformer);
|
|
9
|
+
return () => { removeTransformer(); removeRenderer(); };
|
|
10
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@astrosheep/notesoup-paseo",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"typecheck": "tsc --noEmit",
|
|
8
|
+
"test": "node --experimental-strip-types --test test/*.test.ts"
|
|
9
|
+
},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@getpaseo/plugin": "0.11.2",
|
|
12
|
+
"@types/node": "^22.19.19",
|
|
13
|
+
"@types/react": "~19.2.0",
|
|
14
|
+
"react": "19.1.0",
|
|
15
|
+
"react-native": "0.81.5",
|
|
16
|
+
"typescript": "^5.9.3",
|
|
17
|
+
"zod": "^4.4.3"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { sourceRowTransformer } from "../client/source-row.ts";
|
|
4
|
+
import { LAST_WORD_TYPE, lastWordSchema } from "../shared/last-word.ts";
|
|
5
|
+
|
|
6
|
+
test("renders the Pi adapter's replayed last word in place and leaves other rows intact", () => {
|
|
7
|
+
const item = {
|
|
8
|
+
type: "tool_call" as const, callId: "pi-custom-1", name: LAST_WORD_TYPE,
|
|
9
|
+
status: "completed" as const, error: null,
|
|
10
|
+
detail: { type: "plain_text" as const, text: "*You peel a sticky note off your forehead.*\nKeep the handoff." },
|
|
11
|
+
metadata: { synthetic: true, customType: LAST_WORD_TYPE },
|
|
12
|
+
};
|
|
13
|
+
const result = sourceRowTransformer.transform({ item });
|
|
14
|
+
assert.equal(result?.items.length, 1);
|
|
15
|
+
assert.equal(lastWordSchema.parse(result!.items[0]!.data).text, item.detail.text);
|
|
16
|
+
assert.deepEqual(sourceRowTransformer.transform({ item }), result, "replay deterministically replaces one source row");
|
|
17
|
+
assert.equal(sourceRowTransformer.transform({ item: { ...item, metadata: { synthetic: true, customType: "other" } } }), undefined);
|
|
18
|
+
assert.equal(sourceRowTransformer.transform({ item: { ...item, detail: { type: "plain_text" } } }), undefined);
|
|
19
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"lib": ["ES2023"],
|
|
7
|
+
"types": ["react", "node"],
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"allowImportingTsExtensions": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"noEmit": true,
|
|
13
|
+
"esModuleInterop": true
|
|
14
|
+
},
|
|
15
|
+
"include": ["**/*.ts", "**/*.tsx"]
|
|
16
|
+
}
|
package/plugins/pi/entries.ts
CHANGED
|
@@ -5,3 +5,5 @@ export const MANUAL_WIPE_TYPE = "notesoup/manual-wipe";
|
|
|
5
5
|
export const RESET_MARKER_TYPE = "notesoup/reset-marker";
|
|
6
6
|
export const CONTINUATION_TYPE = "notesoup/continuation";
|
|
7
7
|
export const RESET_LAST_WORD_TYPE = "notesoup/reset-last-word";
|
|
8
|
+
export const CARRIED_INPUT_TYPE = "notesoup/carried-input";
|
|
9
|
+
export const NEXT_WINDOW_PROMPT_TYPE = "notesoup/next-window-prompt";
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import type { ExtensionAPI, ExtensionContext, SessionBoundaryDraft, SessionEntry } from "@earendil-works/pi-coding-agent";
|
|
3
|
-
import { BOOT_TYPE, CONTINUATION_TYPE, RESET_LAST_WORD_TYPE, RESET_MARKER_TYPE } from "../entries.js";
|
|
3
|
+
import { BOOT_TYPE, CARRIED_INPUT_TYPE, CONTINUATION_TYPE, RESET_LAST_WORD_TYPE, RESET_MARKER_TYPE } from "../entries.js";
|
|
4
4
|
import { selectContinuation, type ResetOrigin } from "../../../src/budget/text.js";
|
|
5
5
|
import { isForeignResetTailEntry, isWindowBootEntry, isWindowMarker, markerResetOrigin, type WindowMarker } from "../window.js";
|
|
6
6
|
import { buildBootMessage, sendBoot, type IncompleteNotesNotifier } from "../boot.js";
|
|
7
7
|
|
|
8
8
|
export type ResetTailState = { readonly boot: boolean; readonly continuation: boolean };
|
|
9
9
|
|
|
10
|
+
/** Original user content, including images; custom boundary messages become LLM user messages. */
|
|
11
|
+
export type CarriedInput = Extract<SessionBoundaryDraft, { type: "custom_message" }>["content"];
|
|
12
|
+
|
|
13
|
+
export function carriedInputDrafts(inputs: readonly CarriedInput[]): Extract<SessionBoundaryDraft, { type: "custom_message" }>[] {
|
|
14
|
+
return inputs.map((content) => ({ type: "custom_message", customType: CARRIED_INPUT_TYPE, content, display: true }));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function isCarriedInputEntry(entry: SessionEntry): boolean {
|
|
18
|
+
return entry.type === "custom_message" && entry.customType === CARRIED_INPUT_TYPE && entry.display === true;
|
|
19
|
+
}
|
|
20
|
+
|
|
10
21
|
/** A sticky note, not a letter: over this, empty_brain refuses instead of truncating. */
|
|
11
22
|
export const MAX_LAST_WORD_CHARS = 250;
|
|
12
23
|
|
|
@@ -33,8 +44,8 @@ function sendContinuation(pi: ExtensionAPI, content: string): void {
|
|
|
33
44
|
|
|
34
45
|
/**
|
|
35
46
|
* The closed, ordered reset shape: retain-none native checkpoint, marker, matching boot,
|
|
36
|
-
* continuation, then an optional parting line. The
|
|
37
|
-
*
|
|
47
|
+
* continuation, then an optional parting line. The lifecycle appends carried inputs in the same
|
|
48
|
+
* boundary after these artifacts. The boot snapshot is acquired asynchronously after capturing
|
|
38
49
|
* this identity. The continuation is drawn from the pool its origin names, here, once: the caller
|
|
39
50
|
* persists the returned text and no read, render, or repair draws it again. The origin defaults to
|
|
40
51
|
* `normal`, the same reading a legacy marker with no origin gets.
|
|
@@ -77,6 +88,8 @@ export function inspectResetTail(ctx: ExtensionContext, markerId: string, window
|
|
|
77
88
|
if (markerIndex < 0) return undefined;
|
|
78
89
|
let boot = false;
|
|
79
90
|
let continuation = false;
|
|
91
|
+
let lastWord = false;
|
|
92
|
+
let carried = false;
|
|
80
93
|
for (const entry of branch.slice(markerIndex + 1)) {
|
|
81
94
|
if (isWindowBootEntry(entry, windowId)) {
|
|
82
95
|
// The boot is unique and must precede the continuation; a repeat or a late
|
|
@@ -90,9 +103,17 @@ export function inspectResetTail(ctx: ExtensionContext, markerId: string, window
|
|
|
90
103
|
continuation = true;
|
|
91
104
|
continue;
|
|
92
105
|
}
|
|
93
|
-
if (
|
|
94
|
-
return undefined;
|
|
106
|
+
if (entry.type === "custom_message" && entry.customType === RESET_LAST_WORD_TYPE) {
|
|
107
|
+
if (!continuation || lastWord || carried || entry.display !== true) return undefined;
|
|
108
|
+
lastWord = true;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (isCarriedInputEntry(entry)) {
|
|
112
|
+
if (!continuation) return undefined;
|
|
113
|
+
carried = true;
|
|
114
|
+
continue;
|
|
95
115
|
}
|
|
116
|
+
if (isForeignResetTailEntry(entry)) return undefined;
|
|
96
117
|
}
|
|
97
118
|
return { boot, continuation };
|
|
98
119
|
}
|