@turri-dev/core 0.1.1-next.8cda3cc → 0.1.1-next.ad4aa8f

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 (163) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +17 -11
  3. package/dist/api/models.d.ts +9 -0
  4. package/dist/api/models.js +15 -0
  5. package/dist/api/plain.d.ts +6 -6
  6. package/dist/api/plain.js +4 -7
  7. package/dist/api/project.d.ts +35 -0
  8. package/dist/api/project.js +47 -0
  9. package/dist/api/session.d.ts +48 -0
  10. package/dist/api/session.js +17 -0
  11. package/dist/api/system.d.ts +18 -0
  12. package/dist/api/system.js +23 -0
  13. package/dist/btw.d.ts +1 -1
  14. package/dist/capture/capture.js +11 -8
  15. package/dist/capture/chat.d.ts +0 -11
  16. package/dist/capture/chat.js +0 -29
  17. package/dist/capture/config.d.ts +4 -5
  18. package/dist/capture/config.js +34 -20
  19. package/dist/capture/models.d.ts +2 -1
  20. package/dist/capture/models.js +1 -0
  21. package/dist/chat-entries.d.ts +81 -39
  22. package/dist/chat-entries.js +125 -11
  23. package/dist/chat-model.d.ts +37 -0
  24. package/dist/chat-model.js +61 -0
  25. package/dist/chats.d.ts +54 -42
  26. package/dist/chats.js +86 -80
  27. package/dist/client.d.ts +30 -0
  28. package/dist/client.js +12 -0
  29. package/dist/config-edit.d.ts +54 -1
  30. package/dist/config-edit.js +103 -33
  31. package/dist/config.d.ts +12 -9
  32. package/dist/config.js +38 -9
  33. package/dist/doctor-checks.d.ts +42 -0
  34. package/dist/doctor-checks.js +39 -0
  35. package/dist/environment.d.ts +2 -23
  36. package/dist/environment.js +5 -68
  37. package/dist/errors.d.ts +32 -0
  38. package/dist/errors.js +24 -0
  39. package/dist/extension.d.ts +23 -16
  40. package/dist/extension.js +170 -234
  41. package/dist/identity.d.ts +1 -1
  42. package/dist/identity.js +13 -9
  43. package/dist/init-config.d.ts +11 -9
  44. package/dist/init-config.js +15 -7
  45. package/dist/launch-session.d.ts +2 -0
  46. package/dist/launch-session.js +17 -1
  47. package/dist/loop-tools.js +11 -10
  48. package/dist/module-check.d.ts +13 -0
  49. package/dist/module-check.js +117 -0
  50. package/dist/notice.d.ts +5 -0
  51. package/dist/parse-tool.js +3 -2
  52. package/dist/plain/check.d.ts +27 -13
  53. package/dist/plain/check.js +51 -116
  54. package/dist/plain/files.d.ts +2 -0
  55. package/dist/plain/files.js +13 -0
  56. package/dist/plain/graph.js +2 -2
  57. package/dist/plain/highlight.d.ts +4 -20
  58. package/dist/plain/highlight.js +7 -5
  59. package/dist/project.d.ts +19 -0
  60. package/dist/project.js +34 -0
  61. package/dist/quiet.d.ts +0 -2
  62. package/dist/quiet.js +0 -14
  63. package/dist/regenerate/command-check.d.ts +0 -8
  64. package/dist/regenerate/command-check.js +133 -53
  65. package/dist/regenerate/conversation-writes.d.ts +5 -1
  66. package/dist/regenerate/conversation-writes.js +7 -3
  67. package/dist/regenerate/jobs.d.ts +25 -2
  68. package/dist/regenerate/jobs.js +3 -0
  69. package/dist/regenerate/launch.d.ts +1 -0
  70. package/dist/regenerate/launch.js +9 -0
  71. package/dist/regenerate/ledger-view.d.ts +14 -14
  72. package/dist/regenerate/ledger.d.ts +1 -0
  73. package/dist/regenerate/ledger.js +4 -2
  74. package/dist/regenerate/loop.d.ts +2 -1
  75. package/dist/regenerate/loop.js +9 -1
  76. package/dist/regenerate/os-sandbox.d.ts +4 -2
  77. package/dist/regenerate/os-sandbox.js +0 -1
  78. package/dist/regenerate/regenerate.js +2 -1
  79. package/dist/regenerate/requires-chain.d.ts +44 -0
  80. package/dist/regenerate/requires-chain.js +174 -0
  81. package/dist/regenerate/requires.d.ts +2 -40
  82. package/dist/regenerate/requires.js +14 -171
  83. package/dist/regenerate/resources.d.ts +0 -2
  84. package/dist/regenerate/resources.js +2 -14
  85. package/dist/regenerate/shell.js +20 -9
  86. package/dist/regenerate/spec-map.d.ts +2 -0
  87. package/dist/regenerate/spec-map.js +4 -0
  88. package/dist/regenerate/standing.d.ts +5 -2
  89. package/dist/run-report.js +2 -2
  90. package/dist/self-invocation.d.ts +1 -1
  91. package/dist/self-invocation.js +2 -3
  92. package/dist/sentinel-chat.js +7 -11
  93. package/dist/sentinel.d.ts +1 -1
  94. package/dist/sentinel.js +12 -5
  95. package/dist/session-events.d.ts +14 -0
  96. package/dist/session.d.ts +594 -0
  97. package/dist/session.js +672 -0
  98. package/dist/settings.d.ts +28 -2
  99. package/dist/settings.js +92 -56
  100. package/dist/setup.d.ts +6 -30
  101. package/dist/setup.js +28 -105
  102. package/dist/stack.d.ts +25 -12
  103. package/dist/stack.js +77 -12
  104. package/dist/surface.d.ts +2 -2
  105. package/dist/surface.js +4 -5
  106. package/dist/work.d.ts +125 -0
  107. package/dist/work.js +250 -0
  108. package/docs/README.md +2 -3
  109. package/docs/capture.md +4 -4
  110. package/docs/chats.md +5 -3
  111. package/docs/claude-subscription.md +2 -2
  112. package/docs/config.md +4 -4
  113. package/docs/core.md +105 -128
  114. package/docs/development.md +9 -9
  115. package/docs/headless.md +1 -1
  116. package/docs/installation.md +4 -2
  117. package/docs/launch.md +2 -2
  118. package/docs/parser.md +1 -1
  119. package/docs/regenerating.md +1 -1
  120. package/docs/sandbox.md +4 -4
  121. package/docs/sentinel.md +4 -4
  122. package/docs/skills-and-gates.md +1 -1
  123. package/docs/using.md +2 -2
  124. package/genome/rules/integration-embedded-testing.md +3 -3
  125. package/genome/rules/integration-embedded.md +3 -3
  126. package/genome/skills/implement-conformance-testing-script/SKILL.md +6 -4
  127. package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_java.sh +13 -11
  128. package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_python.sh +8 -7
  129. package/genome/skills/implement-unit-testing-script/SKILL.md +7 -5
  130. package/genome/skills/implement-unit-testing-script/assets/run_unittests_java.sh +9 -13
  131. package/genome/skills/implement-unit-testing-script/assets/run_unittests_python.sh +1 -1
  132. package/package.json +19 -32
  133. package/dist/api/commands.d.ts +0 -45
  134. package/dist/api/commands.js +0 -54
  135. package/dist/api/config.d.ts +0 -8
  136. package/dist/api/config.js +0 -8
  137. package/dist/api/ledger.d.ts +0 -3
  138. package/dist/api/ledger.js +0 -3
  139. package/dist/api/startup.d.ts +0 -8
  140. package/dist/api/startup.js +0 -8
  141. package/dist/api/terminal.d.ts +0 -18
  142. package/dist/api/terminal.js +0 -16
  143. package/dist/chat-models.d.ts +0 -11
  144. package/dist/chat-models.js +0 -11
  145. package/dist/chat-ui.d.ts +0 -33
  146. package/dist/chat-ui.js +0 -192
  147. package/dist/headless.d.ts +0 -99
  148. package/dist/headless.js +0 -226
  149. package/dist/host-session.d.ts +0 -136
  150. package/dist/host-session.js +0 -139
  151. package/dist/host.d.ts +0 -8
  152. package/dist/host.js +0 -17
  153. package/dist/index.d.ts +0 -16
  154. package/dist/index.js +0 -7
  155. package/dist/notifications.d.ts +0 -21
  156. package/dist/notifications.js +0 -44
  157. package/dist/reopen.d.ts +0 -29
  158. package/dist/reopen.js +0 -47
  159. package/dist/turri-versions.d.ts +0 -71
  160. package/dist/turri-versions.js +0 -276
  161. package/dist/view.d.ts +0 -78
  162. package/dist/view.js +0 -1
  163. package/docs/hosting.md +0 -284
package/dist/sentinel.js CHANGED
@@ -119,9 +119,10 @@ export function keepGuidance(cwd, text) {
119
119
  * What a chat of the person's is told of the pulses that end: told itself, of those asked for in it - or, with the
120
120
  * sentinel on, nothing, the sentinel telling the person what needs them.
121
121
  */
122
- export function pulseEndsBlock(sentinel, terminal = false) {
123
- if (sentinel && terminal)
124
- return "<pulse-ends>\nThe sentinel checks finished pulses. Their results, its conclusions and its notices go to the notification centre (/notifications). Do not announce them here. Answer if the person asks; when they accept a notice's action, do the task you are given.\n</pulse-ends>";
122
+ export function pulseEndsBlock(sentinel, shown = false) {
123
+ // A front end that shows pulse ends itself: what the sentinel finds is shown to the person there, not said here.
124
+ if (sentinel && shown)
125
+ return "<pulse-ends>\nThe sentinel checks finished pulses. Their results, its conclusions and its notices are shown to the person where they watch the pulses. Do not announce them here. Answer if the person asks; when they accept a notice's action, do the task you are given.\n</pulse-ends>";
125
126
  return sentinel
126
127
  ? [
127
128
  "<pulse-ends>",
@@ -532,21 +533,27 @@ export function concludedNote(conclusion, options = {}) {
532
533
  return [`The sentinel did not do ${about} (${conclusion.check ?? conclusion.job}).`, conclusion.summary.trim()].join("\n");
533
534
  return [`The sentinel did not do ${about} (${conclusion.check ?? conclusion.job}).`, conclusion.summary.trim(), "", "Tell the person, in a line, that it was not checked and why. Do nothing else about it."].join("\n");
534
535
  }
536
+ // How the person tries it themselves, as the launch the sentinel tested in said it.
537
+ const tryIt = conclusion.tryIt?.trim();
538
+ const launched = tryIt !== undefined && tryIt !== "" ? ["", `How the person tries it themselves, as its launch said it: ${tryIt}`] : [];
535
539
  // The host showed the person the conclusion itself: what the sentinel found, for when they ask.
536
540
  if (options.shown === true) {
537
541
  return [
538
542
  `The sentinel is done with ${about} (${conclusion.check ?? conclusion.job}): ${conclusion.verdict === "holds" ? "it holds" : "something is wrong"}.`,
539
543
  conclusion.summary.trim(),
544
+ ...launched,
540
545
  ...(conclusion.verdict === "wrong" ? ["", "Its notice in this chat says what is wrong and what can be done; nothing is done about it until the person answers it."] : []),
541
546
  ].join("\n");
542
547
  }
548
+ const howTo = launched.length > 0 ? " - and how they try it themselves, in a line or two, from what its launch said" : "";
543
549
  return [
544
550
  `The sentinel is done with ${about} (${conclusion.check ?? conclusion.job}): ${conclusion.verdict === "holds" ? "it holds" : "something is wrong"}.`,
545
551
  conclusion.summary.trim(),
552
+ ...launched,
546
553
  "",
547
554
  conclusion.verdict === "holds"
548
- ? "Tell the person, in a line, that the sentinel checked it and it holds - and what it checked. Do nothing else about it."
549
- : "Tell the person, in a line, that the sentinel found something wrong, and that its notice in this chat says what and what can be done. Do nothing else about it until they answer the notice.",
555
+ ? `Tell the person, in a line, that the sentinel checked it and it holds - and what it checked${howTo}. Do nothing else about it.`
556
+ : `Tell the person, in a line, that the sentinel found something wrong, and that its notice in this chat says what and what can be done${howTo}. Do nothing else about it until they answer the notice.`,
550
557
  ].join("\n");
551
558
  }
552
559
  /** Bring a module up again once the sentinel fixed what stopped its pulse: what is left there is regenerated, its scripts run. */
@@ -2,6 +2,7 @@ import type { ModelEvent } from "./regenerate/activity.ts";
2
2
  import type { ChatEntry } from "./chat-entries.ts";
3
3
  import type { CaptureResult } from "./capture/capture.ts";
4
4
  import type { CaptureStatus } from "./capture/progress.ts";
5
+ import type { ModelOutOfReach } from "./chat-model.ts";
5
6
  /** A foreground skill's position. A view chooses its own width, colours and animation. */
6
7
  export interface SkillProgress {
7
8
  skill: string;
@@ -47,6 +48,19 @@ export type SessionEvent = {
47
48
  type: "entry";
48
49
  chat: string;
49
50
  entry: ChatEntry;
51
+ }
52
+ /** What turri says to the person, outside any chat's transcript: in the chat shown, as pi says what an extension says. */
53
+ | {
54
+ type: "notification";
55
+ chat?: string;
56
+ text: string;
57
+ level: "info" | "warning" | "error";
58
+ }
59
+ /** A person's chat cannot be on harness-model now, or can again: null. */
60
+ | {
61
+ type: "outOfReach";
62
+ chat: string;
63
+ outOfReach: ModelOutOfReach | null;
50
64
  };
51
65
  /** An observer that has lost its window must not interrupt a skill or prevent a chat from opening. */
52
66
  export declare function emitSessionEvent(host: {
@@ -0,0 +1,594 @@
1
+ import { type AgentSession, type ExtensionFactory, type ExtensionUIContext, type ToolDefinition } from "@earendil-works/pi-coding-agent";
2
+ import { type ChatEntry } from "./chat-entries.ts";
3
+ import type { ModelOutOfReach } from "./chat-model.ts";
4
+ import { type RunRecord } from "./chat-records.ts";
5
+ import { type ChatInfo } from "./chats.ts";
6
+ import type { ClientInfo } from "./client.ts";
7
+ import { type SettingKey, type SettingValues } from "./config-edit.ts";
8
+ import { type ModelEvent } from "./regenerate/activity.ts";
9
+ import type { Job } from "./regenerate/jobs.ts";
10
+ import { type LaunchedProcess } from "./regenerate/launch.ts";
11
+ import { type RunView } from "./regenerate/ledger-view.ts";
12
+ import type { ModuleStatus, PlannedPulse } from "./regenerate/loop.ts";
13
+ import { type MarkedPage } from "./regenerate/spec-map.ts";
14
+ import { type ModuleStanding } from "./regenerate/standing.ts";
15
+ import { type CheckRequest } from "./sentinel-check.ts";
16
+ import type { CaptureResult } from "./capture/capture.ts";
17
+ import type { CaptureStatus } from "./capture/progress.ts";
18
+ import type { Launch } from "./launch-track.ts";
19
+ import type { Conclusion, Notice, NoticeAnswer } from "./notice.ts";
20
+ import type { SkillProgress } from "./session-events.ts";
21
+ import type { SessionSpending } from "./session-spending.ts";
22
+ import { type WorkRequest, type WorkResult, type WorkRunOptions } from "./work.ts";
23
+ /**
24
+ * turri's session: one project's chats, work, launches and sentinel, for any front end - a terminal, a desktop app, an
25
+ * editor's extension - or none at all, for unattended work. What a front end does differently it says in `Frontend`;
26
+ * what happens it hears as typed events; what it asks it asks of the session's methods. One session a process, in the
27
+ * process's working folder: the project.
28
+ */
29
+ /** A question turri puts to the person: options to pick from, or words to type. */
30
+ export type Question = {
31
+ kind: "select";
32
+ title: string;
33
+ options: string[]; /** What to read to answer it. */
34
+ context?: string; /** The option to start on. */
35
+ at?: number;
36
+ } | {
37
+ kind: "input";
38
+ title: string;
39
+ context?: string;
40
+ };
41
+ /** Where a front end shows what turri asks it to: every pulse, one pulse, the spec map. */
42
+ export type RevealTarget = {
43
+ kind: "pulses" | "map";
44
+ } | {
45
+ kind: "pulse";
46
+ id: string;
47
+ };
48
+ /** turri makes each chat's pi session itself, and lets it go. */
49
+ export interface ManagedSessions {
50
+ kind: "managed";
51
+ /** What a chat's UI calls - an extension's notify, its working line, a dialog of its own - reach, by the chat's id. */
52
+ ui?(chat: string): ExtensionUIContext | undefined;
53
+ }
54
+ /**
55
+ * The front end makes each chat's pi session on its own pi runtime - pi's interactive mode, say - with `Turri.extension`
56
+ * built into it before `create` resolves, and lets it go itself.
57
+ */
58
+ export interface ExternalSessions {
59
+ kind: "external";
60
+ create(request: SessionRequest): Promise<AgentSession>;
61
+ /** Put the chat in front, when turri asks: a notice in it, a chat opened to be shown. */
62
+ show?(chat: string): Promise<void>;
63
+ /** The chat is closed, or the session ends: its pi session let go. */
64
+ release?(chat: string, session: AgentSession): Promise<void>;
65
+ }
66
+ /**
67
+ * The front end has no chats: it answers turri's questions (`ask`) and shows what it does from the events - a command
68
+ * run at a terminal. No chat opens (`chats.open` is refused with `no-chat`), so neither does the sentinel.
69
+ */
70
+ export interface NoSessions {
71
+ kind: "none";
72
+ }
73
+ export interface SessionRequest {
74
+ chat: string;
75
+ /** A saved conversation to reopen; none, a fresh one. */
76
+ sessionFile?: string;
77
+ /** Kept on disk for the person to reopen, as turri keeps its own chats. */
78
+ persisted: boolean;
79
+ }
80
+ /**
81
+ * What a front end does with turri, every member optional: given none, the session works unattended - no chats, no
82
+ * sentinel, nobody asked.
83
+ */
84
+ export interface Frontend {
85
+ /** Where the person watches turri's work, in the front end's own words: told the model, which names no other view. */
86
+ surface?: string;
87
+ /** The front end's own pi extensions, built into every chat after turri's: its renderers, tools, commands and keys. */
88
+ extensions?: ExtensionFactory[];
89
+ /**
90
+ * Put a question to the person - ask_user's, a skill's interview, a review gate's - and resolve with what they chose
91
+ * or typed; undefined when they gave no answer. `chat` is the chat that asks, none for a question outside any chat - a
92
+ * skill's run or a start over asked of `skills.run` or `work`. `signal` is aborted when the question is over without
93
+ * an answer - declined, or its turn stopped: the front end closes it.
94
+ */
95
+ ask?(question: Question, context: {
96
+ chat?: string;
97
+ signal: AbortSignal;
98
+ }): Promise<string | undefined>;
99
+ /** Where the chats' pi sessions are made - none, for a front end with no chats. Default: `{ kind: "managed" }`. */
100
+ sessions?: ManagedSessions | ExternalSessions | NoSessions;
101
+ /** The person asked to see something the front end shows - `/pulses`: true when it shows it, else the chat lists it. */
102
+ reveal?(target: RevealTarget, context: {
103
+ chat: string;
104
+ }): boolean;
105
+ /**
106
+ * A capture wrote a project of its own: open it, as the front end opens projects - asking the person first, if it
107
+ * asks - and tell its report there (a session opened with `captured`). False leaves the report to the chat.
108
+ */
109
+ openProject?(dir: string, context: {
110
+ summary: string;
111
+ reportFile: string;
112
+ }): Promise<boolean>;
113
+ /** pi's own settings, the last entry of /settings: opened where the front end has them. */
114
+ openPiSettings?(): boolean;
115
+ /** The last word on a chat's whole system prompt, as turri built it for the turn. */
116
+ systemPrompt?(prompt: string, context: {
117
+ chat: string;
118
+ }): string;
119
+ /**
120
+ * What the front end shows the person itself, from the events: pulse ends and the sentinel's conclusions - the chat's
121
+ * agent is told them with no turn of its own - notices, which a chat then never puts as a question, and the spec map,
122
+ * which the session then watches, sending `map` as it changes.
123
+ */
124
+ shows?: {
125
+ pulseEnds?: boolean;
126
+ notices?: boolean;
127
+ map?: boolean;
128
+ };
129
+ /** The sentinel's own tools beside turri's - a front end's browser - and where the person watches it use them. */
130
+ sentinel?: {
131
+ tools?: ToolDefinition[];
132
+ surface?: string;
133
+ };
134
+ }
135
+ /** A session's own values for config keys, read in its project as config.turri.yaml's: models as provider/model-id[:thinking]. */
136
+ export interface SessionOverrides {
137
+ harnessModel?: string;
138
+ codingModel?: string;
139
+ judgeModel?: string;
140
+ review?: boolean;
141
+ mutationTesting?: boolean;
142
+ /** Keep what turri writes for a person debugging it (logs, sessions, outputs). */
143
+ debug?: boolean;
144
+ }
145
+ export interface TurriOptions {
146
+ /** The front end. None: unattended. */
147
+ frontend?: Frontend;
148
+ /** Who runs turri - the banner shows it, the ledger and run reports record it. Default: the core. */
149
+ client?: ClientInfo;
150
+ /** This session's own config values, over config.turri.yaml's while it is open. */
151
+ overrides?: SessionOverrides;
152
+ /** Keep the open chats in .turri/chats.json, for `chats.restore("last")`. Default: with a front end. */
153
+ persist?: boolean;
154
+ /** pi's folder - settings, models, credentials. Default: pi's own. */
155
+ agentDir?: string;
156
+ /** Where managed chats' conversations are saved. Default: pi's own folder for the project. */
157
+ sessionDir?: string;
158
+ /** This session is opened in the project a capture wrote: its report, told in the first chat. */
159
+ captured?: {
160
+ summary: string;
161
+ };
162
+ /** A listener from the moment the session opens: it hears what happens as it opens - `orphansStopped` - too. */
163
+ onEvent?(event: TurriEvent): void;
164
+ }
165
+ /** How a capture ended, as its `captureEnded` event says. */
166
+ export type CaptureEnd = {
167
+ state: "completed";
168
+ result: CaptureResult;
169
+ } | {
170
+ state: "failed";
171
+ error: string;
172
+ } | {
173
+ state: "stopped";
174
+ };
175
+ /** Every event, by its type: plain data, safe to send across a process (structuredClone). */
176
+ export interface TurriEventMap {
177
+ /** A chat opened, closed, renamed, or started or stopped working or asking. */
178
+ chats: {
179
+ chats: ChatInfo[];
180
+ };
181
+ /** A chat's pi session replaced under the same id - the sentinel's fresh conversation: read `chats.get(chat).session`. */
182
+ chatSession: {
183
+ chat: string;
184
+ };
185
+ /** turri appended an entry to a chat, or sent it a message. */
186
+ entry: {
187
+ chat: string;
188
+ entry: ChatEntry;
189
+ };
190
+ /** What turri said to the person outside any transcript. */
191
+ notification: {
192
+ chat?: string;
193
+ text: string;
194
+ level: "info" | "warning" | "error";
195
+ };
196
+ /** A pulse started, moved on, or ended; `final` once it ended and is not run again as another. */
197
+ job: {
198
+ job: Job;
199
+ final: boolean;
200
+ };
201
+ /** What is planned changed, with no pulse changing. */
202
+ plan: Record<never, never>;
203
+ /** A launch asked for, started, or ended. */
204
+ launch: {
205
+ launch: Launch;
206
+ };
207
+ /** A launch's agent said more, as it streams: `text` follows what it said before. */
208
+ launchOutput: {
209
+ launch: string;
210
+ codebase: string;
211
+ text: string;
212
+ };
213
+ /** The spec map changed - sent while the front end shows it (`shows.map`). */
214
+ map: {
215
+ pages: MarkedPage[];
216
+ };
217
+ /** Put to the person by the sentinel or turri - answer with `notices.answer`. */
218
+ notice: {
219
+ notice: Notice;
220
+ };
221
+ /** Answered, dismissed or superseded. */
222
+ noticeOver: {
223
+ notice: Notice;
224
+ };
225
+ /** The sentinel done with a pulse or a check, told in `chat`. */
226
+ concluded: {
227
+ chat: string;
228
+ conclusion: Conclusion;
229
+ };
230
+ /** A foreground skill's place in its phases; null when it ends. */
231
+ skillProgress: {
232
+ chat?: string;
233
+ progress: SkillProgress | null;
234
+ };
235
+ /** A capture's status as it runs. */
236
+ captureProgress: {
237
+ chat?: string;
238
+ status: CaptureStatus;
239
+ };
240
+ /** A capture ended. */
241
+ captureEnded: {
242
+ chat?: string;
243
+ root: string;
244
+ } & CaptureEnd;
245
+ /** A provider failing and waited out, or a turn turri ended itself. */
246
+ incident: {
247
+ text: string;
248
+ event: ModelEvent;
249
+ };
250
+ /** What the session has spent changed. */
251
+ spending: {
252
+ spending: SessionSpending;
253
+ };
254
+ /** A person's chat cannot be on harness-model now - and sends nothing to a model - or, null, it can again. */
255
+ outOfReach: {
256
+ chat: string;
257
+ outOfReach: ModelOutOfReach | null;
258
+ };
259
+ /** Something of turri's own failed - a healer, a provider, the history, the planner - said in a line. */
260
+ failure: {
261
+ what: "healer" | "provider" | "history" | "planner";
262
+ text: string;
263
+ };
264
+ /** A func-id or scenario-id renamed in a module's records. */
265
+ renamed: {
266
+ what: "func-id" | "scenario-id";
267
+ from: string;
268
+ to: string;
269
+ spec: string;
270
+ };
271
+ /** A killed turri's process groups, stopped as this session opened. */
272
+ orphansStopped: {
273
+ count: number;
274
+ };
275
+ }
276
+ export type TurriEventType = keyof TurriEventMap;
277
+ export type TurriEvent = {
278
+ [K in TurriEventType]: {
279
+ type: K;
280
+ } & TurriEventMap[K];
281
+ }[TurriEventType];
282
+ /** One chat: a pi session with turri in it. A handle to a chat that has been closed throws `chat-closed`. */
283
+ export interface Chat {
284
+ readonly id: string;
285
+ info(): ChatInfo;
286
+ /** Its pi session: prompt it, subscribe to it, abort it, set its model. */
287
+ readonly session: AgentSession;
288
+ /** turri's entries and messages in its current branch, in order. */
289
+ entries(): ChatEntry[];
290
+ /** Stop what it does now - its turn, a command, a compaction, a retry; `idle` when it does nothing. Never ends the session. */
291
+ stop(): Promise<"stopped" | "idle">;
292
+ /** Decline every question it asks now: the asker told the person declined, its turn going on. */
293
+ decline(): Promise<"declined" | "none">;
294
+ /**
295
+ * harness-model as this chat cannot be on it now - no such model here, or its provider not signed in: while it cannot,
296
+ * the chat sends nothing to a model. None while it is on it, or for the sentinel's chat.
297
+ */
298
+ outOfReach(): ModelOutOfReach | undefined;
299
+ }
300
+ /** What the pulses view shows: each codebase, the pulses this session ran, and those planned. */
301
+ export interface WorkStatus {
302
+ modules: Array<ModuleStatus & {
303
+ lookedAhead?: boolean;
304
+ }>;
305
+ jobs: Job[];
306
+ planned: Job[];
307
+ /** Planning or regenerating now. */
308
+ busy: boolean;
309
+ }
310
+ /** What to halt: a pulse, a module's planned pulses (by a planned row or the module's name), or what a launch started. */
311
+ export type HaltTarget = {
312
+ pulse: string;
313
+ reason?: string;
314
+ } | {
315
+ launched: string;
316
+ };
317
+ /** How a launch is asked for, and what it tells as it runs. */
318
+ export interface LaunchOptions {
319
+ /** The chat told when it ends. */
320
+ chat?: string;
321
+ /** How this project launches it, as the person said it - kept for the codebase's launches after it. */
322
+ guidance?: string;
323
+ /** The codebase to take, when modules built on this one branch. */
324
+ inModule?: string;
325
+ /** Launch it even when its code is out already. */
326
+ again?: boolean;
327
+ /** The launch agent's words as they stream - this launch's, and the one that took its place. */
328
+ onOutput?(text: string): void;
329
+ /** Stops the launch - and what it started - while it is under way. */
330
+ signal?: AbortSignal;
331
+ }
332
+ export interface SkillRunOptions {
333
+ /** The module it is about, when it is about one. */
334
+ plainFile?: string;
335
+ /** What it is asked to do, in words. */
336
+ context?: string;
337
+ /** The model it runs on. Default: the project's harness model - or its coding model, for a skill that says so. */
338
+ model?: string;
339
+ signal?: AbortSignal;
340
+ /** What the run says as it goes - each step tried, what it left, each gate's review and decision - as it says it. */
341
+ onReport?(report: SkillReport): void;
342
+ }
343
+ /** A skill: its name, what it is for, and its steps - each with the review gate after it, if it has one. */
344
+ export interface SkillInfo {
345
+ name: string;
346
+ description: string;
347
+ steps: SkillStep[];
348
+ }
349
+ export interface SkillStep {
350
+ name: string;
351
+ /** What the step does, in a short line for the person. */
352
+ about?: string;
353
+ gate?: SkillGate;
354
+ }
355
+ /** The review a step's work passes before the skill goes on. */
356
+ export interface SkillGate {
357
+ /** The rubric the judges hold the work to: its file, in the skill's folder. */
358
+ rubric: string;
359
+ /** Independent judges, each in a session of its own. */
360
+ judges: number;
361
+ /** How many of them must pass the work. */
362
+ quorum: "all" | "majority" | "any";
363
+ /** What a review the work fails does: the step tried again, the person asked, or the run ended. */
364
+ onFail: "retry" | "escalate" | "abort";
365
+ /** How many times the step is tried again before `onFail` gives up on it. */
366
+ maxRetries: number;
367
+ /** A reviewer reading along as the step works, its findings settled before the judges are asked. */
368
+ continuous?: {
369
+ rubric: string;
370
+ judges: number;
371
+ };
372
+ }
373
+ /** What a skill's run says as it goes, in order. */
374
+ export type SkillReport =
375
+ /** It starts: the skill, and its steps and gates. */
376
+ {
377
+ kind: "start";
378
+ skill: string;
379
+ steps: SkillStep[];
380
+ }
381
+ /** A step tried - again, after its gate sent it back, from attempt 2. */
382
+ | {
383
+ kind: "step";
384
+ step: string;
385
+ attempt: number;
386
+ }
387
+ /** What the step left, by its file in the run's folder. */
388
+ | {
389
+ kind: "artifact";
390
+ step: string;
391
+ path: string;
392
+ body: string;
393
+ }
394
+ /** One pass of the reviewer reading along: what it read, and how many findings it left to fix. */
395
+ | {
396
+ kind: "livePass";
397
+ step: string;
398
+ scope: string;
399
+ findings: number;
400
+ }
401
+ /** The reviewer reading along, at the gate: its passes, and the findings still open - any fail the gate at once. */
402
+ | {
403
+ kind: "liveReview";
404
+ step: string;
405
+ passes: number;
406
+ findings: number;
407
+ }
408
+ /** The gate reviews the step's work with this many judges - none when there is no work to review: it fails. */
409
+ | {
410
+ kind: "gate";
411
+ step: string;
412
+ judges: number;
413
+ }
414
+ /** One judge's verdict - `none` when it gave none, which counts as a fail - and how many violations it found. */
415
+ | {
416
+ kind: "judge";
417
+ step: string;
418
+ judge: number;
419
+ model: string;
420
+ verdict: "pass" | "fail" | "none";
421
+ violations: number;
422
+ }
423
+ /** The gate's decision, and the critique it sends the step back with. */
424
+ | {
425
+ kind: "outcome";
426
+ step: string;
427
+ decision: "advance" | "retry" | "escalate" | "abort";
428
+ critique: string;
429
+ };
430
+ export interface SkillResult {
431
+ ok: boolean;
432
+ /** Each step's artifact, by its file. */
433
+ artifacts: Record<string, string>;
434
+ /** The last step's artifact. */
435
+ output: string;
436
+ /** The run's folder: each step's artifact, and what an interrupted run resumes from. */
437
+ runDir: string;
438
+ }
439
+ export interface Turri {
440
+ /** The project's folder. */
441
+ readonly cwd: string;
442
+ /** turri for a pi session the front end makes itself (`sessions: external`, or pi's own first session): it joins as a chat. */
443
+ readonly extension: ExtensionFactory;
444
+ /** Hear one type of event, or all of them; returns what stops hearing - as does `signal`. */
445
+ on<K extends TurriEventType>(type: K, listener: (event: Extract<TurriEvent, {
446
+ type: K;
447
+ }>) => void, options?: {
448
+ signal?: AbortSignal;
449
+ }): () => void;
450
+ on(listener: (event: TurriEvent) => void, options?: {
451
+ signal?: AbortSignal;
452
+ }): () => void;
453
+ /** Every event from now on, until `signal` is aborted or the session is let go. */
454
+ events(options?: {
455
+ signal?: AbortSignal;
456
+ }): AsyncIterable<TurriEvent>;
457
+ readonly chats: {
458
+ list(): ChatInfo[];
459
+ get(id: string): Chat | undefined;
460
+ /** The chat the person looks at now. */
461
+ focused(): string | undefined;
462
+ /** The person looks at this chat now: a pulse a closed chat asked for is told there. */
463
+ focus(id: string): Promise<void>;
464
+ /** A fresh chat, or the saved one `sessionFile` is - focused unless `focus: false`. Needs a front end. */
465
+ open(options?: {
466
+ sessionFile?: string;
467
+ title?: string;
468
+ focus?: boolean;
469
+ }): Promise<Chat>;
470
+ /** A pi session the front end made with `extension` in it - pi's first, one it rebuilt or forked - as a chat. */
471
+ adopt(session: AgentSession): Chat;
472
+ /** Reopen a run's chats - the last one that ended here, by default - except those open already. */
473
+ restore(run?: RunRecord | "last"): Promise<Chat[]>;
474
+ /** Closed: its turn stopped, its conversation let go - its pulses run on. */
475
+ close(id: string): Promise<void>;
476
+ /**
477
+ * Each of the person's chats put on harness-model as the config has it now, where it can be: after the person signed
478
+ * in to a provider, or changed harness-model outside turri. A chat checks it again as it is sent something, too.
479
+ */
480
+ onHarnessModel(): Promise<void>;
481
+ };
482
+ readonly work: {
483
+ status(): WorkStatus;
484
+ jobs(): Job[];
485
+ job(id: string): Job | undefined;
486
+ /** How far each module is built and conformed, and what drifted - never planning or starting anything. */
487
+ standing(files?: string[]): ModuleStanding[];
488
+ /** The spec map: each module's items, marked built, regenerating, planned or waiting - read at most every second. */
489
+ map(options?: {
490
+ refresh?: boolean;
491
+ }): MarkedPage[];
492
+ /** Earlier sessions' pulses here, newest runs first. */
493
+ history(options?: {
494
+ runs?: number;
495
+ }): {
496
+ jobs: Job[];
497
+ runs: RunView[];
498
+ more: number;
499
+ };
500
+ /** Plan as regenerate would and hold the plan; the next pulses' prompts. Starts nothing. */
501
+ lookAhead(plainFile: string): Promise<{
502
+ statuses: ModuleStatus[];
503
+ next: PlannedPulse[];
504
+ }>;
505
+ /** Regenerate a module's code from its spec as it is now. `chat`: the chat told when it ends. */
506
+ regenerate(request: Partial<WorkRequest> & WorkRunOptions & {
507
+ chat?: string;
508
+ }): Promise<{
509
+ planned: ModuleStatus[];
510
+ done: Promise<WorkResult>;
511
+ }>;
512
+ /** Write and run a module's conformance tests. Refused while they are off. */
513
+ conform(request: Partial<WorkRequest> & WorkRunOptions & {
514
+ chat?: string;
515
+ }): Promise<{
516
+ planned: ModuleStatus[];
517
+ done: Promise<WorkResult>;
518
+ }>;
519
+ /** Halt a pulse, a module's planned pulses, or what a launch started: what was halted, said. */
520
+ halt(target: HaltTarget): Promise<string>;
521
+ };
522
+ readonly launches: {
523
+ /** This session's launches, oldest first. */
524
+ list(): Launch[];
525
+ /** What launches started and is running now, on this machine. */
526
+ running(): LaunchedProcess[];
527
+ /**
528
+ * Launch a module's code - the config's module, none named - and resolve when the launch ends: or, superseded by a
529
+ * newer one as it waited, when that one ends. Already out, it resolves with the launch that put it out.
530
+ */
531
+ launch(plainFile?: string, options?: LaunchOptions): Promise<Launch>;
532
+ /** Follow what launches started as it logs, a line at a time, until nothing runs or `signal` is aborted. */
533
+ followLogs(onLine: (name: string, line: string) => void, options?: {
534
+ signal?: AbortSignal;
535
+ }): Promise<void>;
536
+ };
537
+ readonly notices: {
538
+ list(): Notice[];
539
+ answer(id: string, answer: NoticeAnswer): Promise<"done" | "dismissed" | "ignored" | "refused" | "missing" | "over">;
540
+ };
541
+ readonly sentinel: {
542
+ /** Ask the sentinel to check functional specs in what is launched of a module: the check's id, or why it was refused. */
543
+ check(request: CheckRequest): {
544
+ check: string;
545
+ } | {
546
+ refused: string;
547
+ };
548
+ };
549
+ readonly settings: {
550
+ /**
551
+ * A setting's value as config.turri.yaml - or `module`'s own file - has it; undefined when unset there. One the file
552
+ * has that its kind cannot take throws `config-invalid`.
553
+ */
554
+ get<K extends SettingKey>(key: K, options?: {
555
+ module?: string;
556
+ }): SettingValues[K] | undefined;
557
+ /**
558
+ * Set a setting - undefined unsets it - as /settings does: checked (`refused`, with why), written, and what turri
559
+ * fixed at its start changed now. `said` is what changed and when it takes effect, in a line or more.
560
+ */
561
+ set<K extends SettingKey>(key: K, value: SettingValues[K] | undefined, options?: {
562
+ module?: string;
563
+ }): Promise<{
564
+ file: string;
565
+ said: string;
566
+ }>;
567
+ /** The values /settings offers for a setting after `typed`. */
568
+ choices(key: SettingKey, typed?: string): string[];
569
+ /**
570
+ * Conformance tests turned on, as /conform does - the person's decision: `conformance-tests: true` written where the
571
+ * module's value comes from (its own file, a required module's, else config.turri.yaml). Returns the file written.
572
+ */
573
+ turnOnConformanceTests(plainFile?: string): string;
574
+ };
575
+ readonly skills: {
576
+ /** turri's own skills and the project's, each with its steps and gates. */
577
+ list(): SkillInfo[];
578
+ /**
579
+ * Run a skill outside any chat: one by name - turri's own or the project's, as `list` has them - or the skill in a
580
+ * folder with a SKILL.md (`{ dir }`, from the project's folder). One there is none of is `not-found`; a SKILL.md that
581
+ * does not parse, `refused` with why.
582
+ */
583
+ run(skill: string | {
584
+ dir: string;
585
+ }, options?: SkillRunOptions): Promise<SkillResult>;
586
+ };
587
+ /** Dollars spent since the session opened. */
588
+ spending(): SessionSpending;
589
+ /** Every chat let go, what launches started stopped, the session's overrides cleared. Safe to call again. */
590
+ dispose(): Promise<void>;
591
+ [Symbol.asyncDispose](): Promise<void>;
592
+ }
593
+ /** Open turri's session on the project in the process's working folder. One a process: a second throws `session-open`. */
594
+ export declare function createTurri(options?: TurriOptions): Promise<Turri>;