@xingular/harness 1.3.1-unstable.8 → 1.3.1-unstable.9

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.
Files changed (64) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/dist/cli.js +1473 -1158
  3. package/dist/sdk/accounts/accounts.d.ts +26 -20
  4. package/dist/sdk/accounts/accounts.js +100 -63
  5. package/dist/sdk/agents/builtin.js +2 -0
  6. package/dist/sdk/core/commandBudget.js +7 -2
  7. package/dist/sdk/core/workspaceWriteOperations.d.ts +24 -0
  8. package/dist/sdk/core/workspaceWriteOperations.js +21 -0
  9. package/dist/sdk/plugins/builtin.js +0 -4
  10. package/dist/sdk/prompt/compile.d.ts +3 -1
  11. package/dist/sdk/prompt/compile.js +12 -11
  12. package/dist/sdk/prompt/standard.js +2 -2
  13. package/dist/sdk/sessions/checkpoint.d.ts +7 -0
  14. package/dist/sdk/sessions/checkpoint.js +41 -0
  15. package/dist/sdk/sessions/compactionCheckpoint.d.ts +2 -0
  16. package/dist/sdk/sessions/compactionCheckpoint.js +2 -1
  17. package/dist/sdk/sessions/completionCheck.d.ts +51 -0
  18. package/dist/sdk/sessions/completionCheck.js +148 -0
  19. package/dist/sdk/sessions/continuation.js +1 -1
  20. package/dist/sdk/sessions/contracts.d.ts +7 -1
  21. package/dist/sdk/sessions/contracts.js +4 -0
  22. package/dist/sdk/sessions/planMode.d.ts +31 -0
  23. package/dist/sdk/sessions/planMode.js +48 -3
  24. package/dist/sdk/sessions/registry.d.ts +6 -1
  25. package/dist/sdk/sessions/registry.js +4 -4
  26. package/dist/sdk/sessions/runner.d.ts +3 -0
  27. package/dist/sdk/sessions/runner.js +64 -13
  28. package/dist/sdk/sessions/sessions.js +44 -7
  29. package/dist/sdk/sessions/stopGate.d.ts +89 -0
  30. package/dist/sdk/sessions/stopGate.js +171 -0
  31. package/dist/sdk/sessions/subagentService.d.ts +2 -0
  32. package/dist/sdk/sessions/subagentService.js +1 -1
  33. package/dist/sdk/sessions/workSlice.d.ts +59 -12
  34. package/dist/sdk/sessions/workSlice.js +102 -33
  35. package/dist/sdk/terminal/controller.d.ts +2 -2
  36. package/dist/sdk/terminal/controller.js +14 -4
  37. package/dist/sdk/terminal/credentialStore.d.ts +4 -0
  38. package/dist/sdk/terminal/credentialStore.js +33 -0
  39. package/dist/sdk/terminal/piExtension.js +104 -26
  40. package/dist/sdk/terminal/terminals.js +25 -3
  41. package/dist/sdk/terminal/tui/planMode.d.ts +1 -1
  42. package/dist/sdk/terminal/tui/planMode.js +1 -1
  43. package/dist/sdk/terminal/tui/runtime.js +14 -3
  44. package/dist/sdk/tools/todo.js +1 -1
  45. package/dist/terminal-opentui.js +901 -508
  46. package/dist/terminal-pi.js +688 -406
  47. package/docs/architecture/02-sessions-and-runs.md +39 -11
  48. package/docs/architecture/04-prompt.md +49 -3
  49. package/docs/architecture/07-tools-and-gate.md +4 -2
  50. package/docs/architecture/09-accounts-and-connectors.md +9 -0
  51. package/docs/architecture/10-server-protocol.md +6 -0
  52. package/docs/architecture/11-terminal.md +22 -12
  53. package/docs/architecture/proposals/PROP-0041-bounded-work-slices.md +2 -0
  54. package/docs/decisions/ADR-0063-unfinished-work-handoffs.md +2 -0
  55. package/docs/decisions/ADR-0068-scope-and-completion-report.md +57 -0
  56. package/docs/decisions/ADR-0069-stop-gate-and-finish.md +130 -0
  57. package/docs/decisions/ADR-0070-terminal-slice-continuation.md +46 -0
  58. package/docs/decisions/ADR-0071-completion-check.md +103 -0
  59. package/docs/releases/1.3.1-unstable.9.md +54 -0
  60. package/docs/study/00-index.md +3 -0
  61. package/docs/study/STUDY-0004-turn-end-controls.md +121 -0
  62. package/package.json +1 -1
  63. package/dist/sdk/tools/checkpoint.d.ts +0 -27
  64. package/dist/sdk/tools/checkpoint.js +0 -154
package/CHANGELOG.md CHANGED
@@ -2,6 +2,87 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - **A completion check replaces `finish` (ADR-0071).**
6
+ - **The check.** When a reply that did work ends with its todo list closed or absent, the run's
7
+ own model, at low effort and with a fresh context, judges the person's request against what the
8
+ reply did: `done`, `continue` (the reply is sent back with the reason and next step), or
9
+ `needs_person`. The request is the goal; there is no `/goal` command.
10
+ - **Shared cap.** It shares the stop gate's cap of three nudges per reply and its no-progress rule.
11
+ - **Usage and failure.** Its request counts in the run's usage, and any failure leaves the reply
12
+ as it was.
13
+ - **`finish` is removed.** A live GPT 6 Luna run used `needs_decision` after 23 seconds to ask
14
+ something the handoff already answered. Only the check can now decide that the person is needed.
15
+ - **Prompt.** The `role` paragraph names which decisions are the agent's own, says a document the
16
+ request points to is the request, and says a question the request or files already answer is not
17
+ a question for the person. Its budget rises from 1,500 to 2,200 characters, so it fits uncut with
18
+ the subagent paragraph.
19
+ - **Kill switches.** `XINGULAR_STOP_GATE=off` and `XINGULAR_COMPLETION_CHECK=off` at launch switch a
20
+ layer off, for experiments.
21
+ - **The model is told it has `edit` and `write`.** Pi's `createEditTool` and `createWriteTool` drop
22
+ the definition's prompt line and guidelines, and Pi lists only tools with a prompt line, so every
23
+ terminal and headless run's system prompt named only `read` and `bash`. Models edited files
24
+ through shell scripts instead: one 2-hour terminal run made 156 script edits (14 failed) and no
25
+ `edit` call. `createWorkspaceFileTools` now restores the prompt line and guidelines, as Pi's own
26
+ `createBashTool` does, for both the terminal and the runner. The stable prefix changes once.
27
+ - **A plan no longer leaks its tools into normal mode.** A terminal plan request narrows the active
28
+ tools, and Pi records the restored normal set only with the next request. A rebuild before then
29
+ (a new runtime, resume, switch, fork or tree navigation) replayed the plan set, so normal work ran
30
+ without `edit`, `write`, browser and connected-app tools. One recorded session implemented a whole
31
+ plan that way. The terminal now marks each plan request in the session and restores the normal
32
+ set after any rebuild.
33
+ - **Terminal replies continue across work slices (ADR-0070).** A terminal reply that reaches its
34
+ 320-call or 60-minute budget after doing work now continues in place as the next slice, with a
35
+ checkpoint and a notice, up to 8 slices, instead of waiting for "continue" and re-sending the
36
+ whole context uncached. Fruitless, blocked, failed, aborted and plan slices still stop.
37
+ `XINGULAR_WORK_SLICE` also accepts key=value pairs such as `maxToolCalls=15,maxSlices=3`.
38
+ - **One copy of each credential: no more `invalid_grant` from terminals.** A terminal's Pi kept the
39
+ account's tokens in `auth.json` under its own lock while the host, its subagents and usage probes
40
+ refreshed the same token in the Keychain under another, and `terminalEnd` copied the file back
41
+ over whatever the Keychain held. OpenAI rotates refresh tokens, so whichever side refreshed second
42
+ failed with `invalid_grant` and the account needed a new sign-in. A terminal now reads and refreshes
43
+ through the host store (`accounts.credentials.*`, INV-ACC-5), holding its lock for the refresh. An
44
+ `auth.json` left by an older terminal is folded in, newest token first.
45
+ - **A stalled terminal reply is recorded as `stalled`.** Pi's abort reports back through
46
+ `terminal.interrupt` like a person's Esc, which closed the run as `user_abort` before the reply
47
+ settled as `stalled`; one silent 15-minute hang was recorded as the person's abort. The interrupt
48
+ now carries the stall. An interrupt also ends a settling reply's wait for its subagents.
49
+
50
+ - **A reply can no longer quietly stop with work open (ADR-0069).**
51
+ - **Stop gate.** In attended top-level runs, terminal included, a reply that ends while its todo
52
+ list has open items is sent back to the model, naming the items, up to three times per reply,
53
+ and never after a nudge that produced no work.
54
+ - **`finish`.** Added here as the one explicit way to stop with work open; removed again by ADR-0071
55
+ above.
56
+ - **Honest stop codes.** Such a reply settles `interrupted` with the new stop codes `needs_person`
57
+ or `unfinished`, never `completed`, with a checkpoint the harness writes from the todo list,
58
+ files and checks.
59
+ - **`checkpoint_write` is removed.** A run used it as a sign-off and stopped with work open. At a
60
+ work-slice budget the harness now writes the checkpoint itself.
61
+ - **One budget per reply.** The work-slice budget now covers the whole reply: Pi's own
62
+ continuations (nudges, delivered subagent results, plan repair) no longer reset it.
63
+ - **Prompt wording.** The texts that read as permission to stop were rewritten: the todo guidance's
64
+ "final update before your final reply", and `## What would make this complete` "when the run
65
+ could be more complete".
66
+ - **Subagents.** `spawn_subagent` now returns the child's tools, and the read-only profiles say up
67
+ front when a brief needs a tool they lack.
68
+ - **Hosts.** Accept the two new stop codes and offer Continue for them.
69
+ - **Restart required.** A live terminal session keeps the code it started with, so restart it to
70
+ get the gate.
71
+ - Do the job the request implies, and report it apart from the request. A standard session's role
72
+ paragraph now sets the scope of the work — the obvious adjacent step, what the work itself exposes,
73
+ the check it needs, inside the working folder and away from what a person must decide (a deploy, a
74
+ secret, remote data, money), without asking first inside those bounds — and the reporting guidance
75
+ requires two headings when they apply: `## Beyond what you asked` and
76
+ `## What would make this complete` (ADR-0068). The reporting budget rises from 2,000 to 2,400
77
+ characters so both fit uncut. All of it is stable-prefix text, so the cached prefix changes once
78
+ per session.
79
+ - Say in the prompt when a reply may end. The standard session's role paragraph, the opening of the
80
+ reporting guidance and the todo guidance now say that an open todo item, a passing check or a
81
+ partial result is not a reason to end the turn, and name the reasons that are: the request is done,
82
+ the work-slice guard hands the reply back, a person's decision is needed, or the person interrupts.
83
+ ADR-0069 below now enforces it in the runner. A sweep of 822 runs in seven days found 207 that ended with work left
84
+ (137 within 30 tool calls, median 17, and 191 with no checkpoint), which is what the wording is
85
+ for. All three texts are in the stable prefix, so this changes the cached prefix once.
5
86
  - Reword the final-reply guidance so the outcome leads and structure follows what the answer needs. The
6
87
  reporting guidance is part of every request's stable prefix, so this changes the cached prefix.
7
88
  - Keep the provider cache working after a compaction (ADR-0067). The compaction checkpoint now arms only