@turri-dev/cli 0.2.4-next.8422d0f → 0.2.4-next.d779410

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 (175) hide show
  1. package/README.md +7 -8
  2. package/dist/bedrock-region.js +3 -3
  3. package/dist/chat-idle.d.ts +2 -2
  4. package/dist/chat-idle.js +2 -2
  5. package/dist/chat-models.d.ts +1 -1
  6. package/dist/chat-models.js +1 -1
  7. package/dist/chat-scope.d.ts +1 -3
  8. package/dist/chat-skills.d.ts +1 -1
  9. package/dist/chat-skills.js +1 -1
  10. package/dist/chats.d.ts +44 -20
  11. package/dist/chats.js +125 -64
  12. package/dist/cli.js +12 -31
  13. package/dist/config-edit.d.ts +20 -8
  14. package/dist/config-edit.js +32 -26
  15. package/dist/config.d.ts +106 -78
  16. package/dist/config.js +267 -133
  17. package/dist/conform-cli.js +14 -3
  18. package/dist/conformance-switch.d.ts +13 -22
  19. package/dist/conformance-switch.js +37 -59
  20. package/dist/drift-cli.js +1 -1
  21. package/dist/extension.d.ts +17 -10
  22. package/dist/extension.js +435 -532
  23. package/dist/genome.js +10 -49
  24. package/dist/graph.js +3 -5
  25. package/dist/host-session.d.ts +11 -21
  26. package/dist/host-session.js +6 -8
  27. package/dist/host.d.ts +4 -4
  28. package/dist/host.js +4 -7
  29. package/dist/identity.js +2 -3
  30. package/dist/init-config.d.ts +1 -2
  31. package/dist/init-config.js +10 -17
  32. package/dist/installed-providers.d.ts +1 -1
  33. package/dist/installed-providers.js +1 -1
  34. package/dist/launch-agent.d.ts +51 -0
  35. package/dist/launch-agent.js +267 -0
  36. package/dist/{release-cli.js → launch-cli.js} +41 -24
  37. package/dist/launch-session.d.ts +68 -0
  38. package/dist/launch-session.js +217 -0
  39. package/dist/launch-tools.d.ts +28 -0
  40. package/dist/launch-tools.js +69 -0
  41. package/dist/launch-track.d.ts +125 -0
  42. package/dist/launch-track.js +320 -0
  43. package/dist/loop-cli.d.ts +4 -3
  44. package/dist/loop-cli.js +17 -15
  45. package/dist/loop-tools.d.ts +45 -21
  46. package/dist/loop-tools.js +155 -90
  47. package/dist/new-project.js +2 -2
  48. package/dist/notice.d.ts +7 -6
  49. package/dist/parse-cli.js +2 -2
  50. package/dist/pi-launch.js +4 -1
  51. package/dist/pi-settings.d.ts +4 -0
  52. package/dist/pi-settings.js +39 -0
  53. package/dist/pi.js +12 -9
  54. package/dist/plain/check.d.ts +2 -9
  55. package/dist/plain/check.js +6 -39
  56. package/dist/plain-files.d.ts +2 -2
  57. package/dist/plain-files.js +7 -7
  58. package/dist/regenerate/activity.d.ts +0 -7
  59. package/dist/regenerate/activity.js +2 -20
  60. package/dist/regenerate/agent-env.d.ts +1 -1
  61. package/dist/regenerate/agent-env.js +3 -3
  62. package/dist/regenerate/agent-shell.js +5 -3
  63. package/dist/regenerate/audit.js +9 -0
  64. package/dist/regenerate/base-folder.d.ts +2 -2
  65. package/dist/regenerate/base-folder.js +1 -1
  66. package/dist/regenerate/cases.js +7 -0
  67. package/dist/regenerate/chunk-plan.d.ts +5 -0
  68. package/dist/regenerate/chunk-plan.js +16 -1
  69. package/dist/regenerate/command-check.d.ts +7 -1
  70. package/dist/regenerate/command-check.js +43 -1
  71. package/dist/regenerate/delivery.d.ts +1 -1
  72. package/dist/regenerate/delivery.js +3 -3
  73. package/dist/regenerate/drift.d.ts +4 -0
  74. package/dist/regenerate/drift.js +26 -6
  75. package/dist/regenerate/failure-reports.d.ts +28 -0
  76. package/dist/regenerate/failure-reports.js +79 -0
  77. package/dist/regenerate/job-panel.js +3 -1
  78. package/dist/regenerate/jobs-tree.js +1 -1
  79. package/dist/regenerate/jobs.d.ts +4 -2
  80. package/dist/regenerate/jobs.js +14 -10
  81. package/dist/regenerate/launch.d.ts +154 -0
  82. package/dist/regenerate/{release.js → launch.js} +195 -51
  83. package/dist/regenerate/ledger-view.d.ts +11 -24
  84. package/dist/regenerate/ledger-view.js +14 -60
  85. package/dist/regenerate/ledger.d.ts +34 -16
  86. package/dist/regenerate/ledger.js +1 -1
  87. package/dist/regenerate/lineage.d.ts +2 -0
  88. package/dist/regenerate/lineage.js +8 -0
  89. package/dist/regenerate/loop.d.ts +54 -67
  90. package/dist/regenerate/loop.js +312 -148
  91. package/dist/regenerate/model-names.d.ts +33 -0
  92. package/dist/regenerate/{engine.js → model-names.js} +2 -28
  93. package/dist/regenerate/paths.d.ts +3 -3
  94. package/dist/regenerate/paths.js +4 -4
  95. package/dist/regenerate/records.d.ts +11 -0
  96. package/dist/regenerate/records.js +15 -0
  97. package/dist/regenerate/regenerate.d.ts +0 -2
  98. package/dist/regenerate/regenerate.js +4 -15
  99. package/dist/regenerate/renames.js +4 -4
  100. package/dist/regenerate/requires.d.ts +7 -0
  101. package/dist/regenerate/requires.js +24 -18
  102. package/dist/regenerate/scripts-being-written.d.ts +4 -4
  103. package/dist/regenerate/scripts-being-written.js +3 -3
  104. package/dist/regenerate/spec-map.js +3 -3
  105. package/dist/regenerate/standing.js +1 -1
  106. package/dist/regenerate/submit-work.d.ts +2 -0
  107. package/dist/regenerate/submit-work.js +8 -3
  108. package/dist/regenerate/test-scripts.d.ts +2 -1
  109. package/dist/regenerate/test-scripts.js +33 -23
  110. package/dist/regenerate/testing-steps.d.ts +16 -5
  111. package/dist/regenerate/testing-steps.js +28 -9
  112. package/dist/regenerate-cli.js +18 -9
  113. package/dist/self-invocation.d.ts +11 -0
  114. package/dist/self-invocation.js +36 -10
  115. package/dist/sentinel-check.d.ts +3 -3
  116. package/dist/sentinel-check.js +3 -3
  117. package/dist/sentinel.d.ts +18 -12
  118. package/dist/sentinel.js +75 -46
  119. package/dist/{config-command.d.ts → settings.d.ts} +13 -8
  120. package/dist/{config-command.js → settings.js} +155 -24
  121. package/dist/setup.d.ts +2 -2
  122. package/dist/setup.js +7 -7
  123. package/dist/skill.d.ts +0 -11
  124. package/dist/skill.js +0 -9
  125. package/dist/tools.js +2 -3
  126. package/dist/turri-versions.js +2 -1
  127. package/docs/README.md +4 -6
  128. package/docs/authoring-plain.md +3 -3
  129. package/docs/chats.md +6 -9
  130. package/docs/claude-subscription.md +2 -2
  131. package/docs/config.md +61 -51
  132. package/docs/development.md +4 -5
  133. package/docs/headless.md +7 -6
  134. package/docs/hosting.md +25 -24
  135. package/docs/launch.md +67 -0
  136. package/docs/parser.md +3 -3
  137. package/docs/regenerating.md +30 -22
  138. package/docs/sandbox.md +3 -3
  139. package/docs/sentinel.md +28 -16
  140. package/docs/skills-and-gates.md +6 -11
  141. package/docs/using.md +25 -42
  142. package/genome/rules/project-model.md +2 -1
  143. package/genome/rules/test-plain-files.md +15 -7
  144. package/genome/rules/turri-regeneration.md +7 -10
  145. package/genome/skills/convert-old-syntax/SKILL.md +5 -5
  146. package/genome/skills/implement-conformance-testing-script/SKILL.md +2 -2
  147. package/genome/skills/implement-unit-testing-script/SKILL.md +3 -3
  148. package/package.json +1 -1
  149. package/dist/advisor-chat.d.ts +0 -63
  150. package/dist/advisor-chat.js +0 -290
  151. package/dist/change-plain-cli.js +0 -55
  152. package/dist/ledger-cli.d.ts +0 -1
  153. package/dist/ledger-cli.js +0 -50
  154. package/dist/ledger-tools.d.ts +0 -10
  155. package/dist/ledger-tools.js +0 -64
  156. package/dist/regenerate/advisor-records.d.ts +0 -93
  157. package/dist/regenerate/advisor-records.js +0 -110
  158. package/dist/regenerate/advisor-runs.d.ts +0 -87
  159. package/dist/regenerate/advisor-runs.js +0 -327
  160. package/dist/regenerate/engine.d.ts +0 -52
  161. package/dist/regenerate/release.d.ts +0 -121
  162. package/dist/regenerate/test-advisor.d.ts +0 -101
  163. package/dist/regenerate/test-advisor.js +0 -379
  164. package/dist/release-agent.d.ts +0 -43
  165. package/dist/release-agent.js +0 -130
  166. package/dist/release-cli.d.ts +0 -1
  167. package/dist/release-tools.d.ts +0 -44
  168. package/dist/release-tools.js +0 -170
  169. package/dist/spec-tools.d.ts +0 -36
  170. package/dist/spec-tools.js +0 -128
  171. package/dist/stacks.d.ts +0 -13
  172. package/dist/stacks.js +0 -96
  173. package/docs/deploy.md +0 -48
  174. package/docs/test-advisor.md +0 -110
  175. /package/dist/{change-plain-cli.d.ts → launch-cli.d.ts} +0 -0
@@ -0,0 +1,79 @@
1
+ import { existsSync, readdirSync, readFileSync, statSync, unlinkSync, writeFileSync } from "node:fs";
2
+ import { join, resolve } from "node:path";
3
+ import { readProjectConfig } from "../config.js";
4
+ import { whyFailed } from "./diagnose-job.js";
5
+ import { DEFAULT_LEDGER_KEEP_MB, ledgerRun } from "./ledger.js";
6
+ import { maskSecrets } from "./masking.js";
7
+ import { ensureInScratch } from "./paths.js";
8
+ /**
9
+ * Why a pulse did not land, kept past its session.
10
+ *
11
+ * Outside debug mode a pulse's log and transcript go as it ends (pulse-files.ts), and the ledger keeps facts, never
12
+ * what a tool printed. So a pulse of an earlier session would be told as one-line facts alone - its failure's first
13
+ * line, its test runs' exit codes. What `pulses` says of one that did not land - its diagnosis, the stages that went
14
+ * wrong, the last failing test run's output, the last review that sent the work back, the tool calls that failed - is
15
+ * written here as it ends, whatever the debug setting, masked as the logs are: `.turri/pulses/<id>.md`. Kept while the
16
+ * ledger is on, and as long as the project keeps a ledger (`ledger-keep:`, 0 for none); the newest `KEPT` alone.
17
+ */
18
+ /** The folder, in a project's `.turri`. */
19
+ export const REPORTS_DIR = "pulses";
20
+ /** How many reports a project keeps: the newest. */
21
+ export const KEPT = 200;
22
+ /** Where a project's reports are. */
23
+ export function reportsDir(project) {
24
+ return join(resolve(project), ".turri", REPORTS_DIR);
25
+ }
26
+ /** Whether a pulse ended without landing: failed, stopped, or finished with nothing landed. */
27
+ export function didNotLand(job) {
28
+ if (job.status === "failed" || job.status === "stopped")
29
+ return true;
30
+ return job.status === "succeeded" && job.details?.landed === false;
31
+ }
32
+ /** Whether the project keeps a ledger, and so its reports. */
33
+ function keeps(project) {
34
+ try {
35
+ return (readProjectConfig(project).ledgerKeep ?? DEFAULT_LEDGER_KEEP_MB) > 0;
36
+ }
37
+ catch {
38
+ return true;
39
+ }
40
+ }
41
+ /**
42
+ * A pulse has ended: one that failed, or finished with nothing landed, has its report written, and the oldest past
43
+ * `KEPT` go. A stopped one has none - the person halted it, or the ***plain moved on, and the ledger says which. Nothing
44
+ * while the ledger is off, or where the project keeps none. Never throws: a report that cannot be written is never a
45
+ * reason for the pulse to fail.
46
+ */
47
+ export function keepFailureReport(project, job) {
48
+ if (ledgerRun() === undefined || job.status === "stopped" || !didNotLand(job) || !keeps(project))
49
+ return;
50
+ try {
51
+ const dir = ensureInScratch(join(resolve(project), ".turri"), reportsDir(project));
52
+ writeFileSync(join(dir, `${job.id}.md`), `${maskSecrets(whyFailed(job))}\n`);
53
+ prune(dir);
54
+ }
55
+ catch {
56
+ /* kept when it can be: the ledger still has the facts */
57
+ }
58
+ }
59
+ /** The newest `KEPT` reports stay. */
60
+ function prune(dir) {
61
+ const reports = readdirSync(dir)
62
+ .filter((name) => name.endsWith(".md"))
63
+ .map((name) => ({ name, at: statSync(join(dir, name)).mtimeMs }))
64
+ .sort((a, b) => b.at - a.at);
65
+ for (const old of reports.slice(KEPT))
66
+ unlinkSync(join(dir, old.name));
67
+ }
68
+ /** A pulse's report, by its whole id - or undefined when it has none. */
69
+ export function failureReport(project, id) {
70
+ const file = join(reportsDir(project), `${id}.md`);
71
+ if (!existsSync(file))
72
+ return undefined;
73
+ try {
74
+ return readFileSync(file, "utf8").trimEnd();
75
+ }
76
+ catch {
77
+ return undefined;
78
+ }
79
+ }
@@ -227,7 +227,9 @@ export function jobPanelLines(jobs, options = {}) {
227
227
  const key = options.keys ?? ((_key, text) => text);
228
228
  lines.push(` ${key("trace", `ctrl+o to ${expanded ? "collapse" : "expand"} the trace`)} · ${key("peek", `${PANEL_KEY} to peek at regen`)}`);
229
229
  }
230
- return lines;
230
+ // A line is one row of the screen: a newline in one - an agent's words, a command - would draw past what the renderer
231
+ // tracks and stay on the screen, so each part is a row of its own.
232
+ return lines.flatMap((line) => line.split(/\r?\n/));
231
233
  }
232
234
  /**
233
235
  * The keys of the line, painted at `now`'s breath: one not pressed yet in the text's colour mixed toward the dim one, one
@@ -209,7 +209,7 @@ export function jobsTreeLines(jobs, state, width, style) {
209
209
  });
210
210
  // The ledger has more than the runs shown: where to find them.
211
211
  if (state.open.earlier && (state.earlierMore ?? 0) > 0) {
212
- lines.push(style.muted(` ${state.earlierMore} earlier run${state.earlierMore === 1 ? "" : "s"} in the ledger - turri ledger lists them`));
212
+ lines.push(style.muted(` ${state.earlierMore} earlier run${state.earlierMore === 1 ? "" : "s"} in the ledger - pulses with runs lists them`));
213
213
  }
214
214
  return { lines, rowStarts, rows };
215
215
  }
@@ -46,8 +46,8 @@ export interface Job {
46
46
  note?: string;
47
47
  /** "provider/model-id" its agents run on, when known. */
48
48
  model?: string;
49
- /** The stack it is built with - its config.turri.<stack>.yaml over config.turri.yaml - as chosen when it was queued. */
50
- stack?: string;
49
+ /** The module whose config.turri.<module>.yaml it is built with, over config.turri.yaml - as worked out when it was queued. */
50
+ configModule?: string;
51
51
  /** The chat it was asked for in (chat-scope.ts): the one told how it went. */
52
52
  chat?: string;
53
53
  status: JobStatus;
@@ -60,6 +60,8 @@ export interface Job {
60
60
  planning?: {
61
61
  since: number;
62
62
  };
63
+ /** A row of the work loop's planned by a look ahead: it waits for regenerate, conform or /regenerate to start it. */
64
+ lookedAhead?: true;
63
65
  /** While queued: the jobs it is waiting for. */
64
66
  waitingOn: string[];
65
67
  finishedAt?: number;
@@ -5,9 +5,10 @@ import { describeEnvironmentError, EnvironmentError, missingCredentials } from "
5
5
  import { addAgentReport, describeAgents, JobStoppedError, withActivity } from "./activity.js";
6
6
  import { projectOfLanes, startJobLog } from "./job-log.js";
7
7
  import { firstLine, healing, record } from "./ledger.js";
8
- import { chosenStack, debugMode, withStack } from "../config.js";
8
+ import { debugMode, moduleConfigFile, pinnedConfigModule, withConfigModule } from "../config.js";
9
9
  import { currentChat } from "../chat-scope.js";
10
10
  import { pulseEnded, pulseWrote } from "./pulse-files.js";
11
+ import { keepFailureReport } from "./failure-reports.js";
11
12
  const DEFAULT_TAIL_CHARS = 4000;
12
13
  const ACTIVITY_LINES = 10;
13
14
  /** A long render's full transcript is kept, up to about this much text. */
@@ -57,9 +58,9 @@ export function createJobRegistry(options) {
57
58
  },
58
59
  start(input) {
59
60
  const id = randomUUID().slice(0, 8);
60
- // The stack chosen as it is queued - or pinned for the work that queues it - not as it starts: a job that waits
61
- // for a slot is built with the stack it was asked for, whatever is chosen meanwhile.
62
- const stack = chosenStack();
61
+ // The config pinned for the work that queues it, as it is queued - not as it starts: a job that waits for a slot is
62
+ // built with the config it was planned with, whatever the files say meanwhile.
63
+ const configModule = pinnedConfigModule();
63
64
  const chat = currentChat()?.id;
64
65
  const claimed = [...new Set(input.lanes ?? [])];
65
66
  const blockers = [
@@ -81,7 +82,7 @@ export function createJobRegistry(options) {
81
82
  ...(input.diffWhere !== undefined ? { diffWhere: input.diffWhere } : {}),
82
83
  ...(input.cases !== undefined ? { cases: input.cases } : {}),
83
84
  model: input.model,
84
- ...(stack !== undefined ? { stack } : {}),
85
+ ...(configModule !== undefined ? { configModule } : {}),
85
86
  ...(chat !== undefined ? { chat } : {}),
86
87
  ...(input.follows !== undefined ? { follows: input.follows } : {}),
87
88
  status: blockers.length > 0 || (limit !== undefined && active >= limit) ? "queued" : "running",
@@ -107,7 +108,7 @@ export function createJobRegistry(options) {
107
108
  ...(input.pulse !== undefined ? { pulse: input.pulse } : {}),
108
109
  ...(input.title !== undefined ? { title: input.title } : {}),
109
110
  ...(input.model !== undefined ? { model: input.model } : {}),
110
- ...(stack !== undefined ? { stack } : {}),
111
+ ...(configModule !== undefined ? { configModule } : {}),
111
112
  ...(input.cases !== undefined ? { cases: input.cases } : {}),
112
113
  waitingOn: blockers,
113
114
  ...(input.follows !== undefined ? { follows: input.follows } : {}),
@@ -318,9 +319,9 @@ export function createJobRegistry(options) {
318
319
  // Its log is named only where it is kept: otherwise it goes as the pulse ends.
319
320
  const named = log !== undefined && project !== undefined && debugMode(project);
320
321
  record({ kind: "job.started", waitedMs: job.startedAt - job.queuedAt, ...(named ? { logFile: log.file } : {}) }, place);
321
- // What the job's agents start runs until it ends, and no longer (withPulse) - with the stack it was queued
322
- // with, whatever is chosen while it waits or runs.
323
- return withStack(stack, () => (guarded ? runGuarded() : runOnce()));
322
+ // What the job's agents start runs until it ends, and no longer (withPulse) - with the config it was queued
323
+ // with, whatever the files say while it waits or runs.
324
+ return withConfigModule(configModule, () => (guarded ? runGuarded() : runOnce()));
324
325
  })
325
326
  .then((outcome) => {
326
327
  // Asked to stop, it is stopped - whether its work threw as it unwound or returned what it had.
@@ -347,6 +348,9 @@ export function createJobRegistry(options) {
347
348
  // What it wrote for a person goes now, outside debug mode - its log too, which nothing names from then on.
348
349
  if (ran && project !== undefined && !pulseEnded({ job: id, project, ...(input.module !== undefined ? { module: input.module } : {}), lanes: claimed }))
349
350
  delete finished.logFile;
351
+ // Why one that did not land did not, kept past the session whatever the debug setting (failure-reports.ts).
352
+ if (ran && project !== undefined)
353
+ keepFailureReport(project, finished);
350
354
  const outcome = finished.details;
351
355
  const stopReason = stopReasons.get(id);
352
356
  record({
@@ -475,7 +479,7 @@ export function pulseName(job) {
475
479
  }
476
480
  /** What the agent is told when it checks on a job. */
477
481
  export function describeJob(job) {
478
- const name = `${pulseName(job)}${job.stack !== undefined ? ` (stack ${job.stack})` : ""}`;
482
+ const name = `${pulseName(job)}${job.configModule !== undefined ? ` (built with ${moduleConfigFile(job.configModule)})` : ""}`;
479
483
  if (job.status === "queued") {
480
484
  return `${name}: queued behind ${job.waitingOn.map((id) => `pulse ${id}`).join(" and ")}. It starts when that finishes.`;
481
485
  }
@@ -0,0 +1,154 @@
1
+ import { type ChainEntry } from "./requires.ts";
2
+ /**
3
+ * Launch: a codebase's code, as one of its commits has it, put out in `dist/<module>` for the person and the sentinel
4
+ * to try - the commit a pulse landed, or the codebase's last.
5
+ *
6
+ * A pulse works in `plain_modules/<module>/code` while a launch runs, so what is there is half-written. A commit is not:
7
+ * every unit of work starts from one and ends with one, and both are runnable. So the commit is exported from the
8
+ * module's history - git's own list of what it tracks, and nothing else - without a list of what each stack leaves lying
9
+ * around (`node_modules`, `.venv`, `target`). The working tree is never read, reset or touched: the next pulse may be
10
+ * writing in it.
11
+ *
12
+ * What starts it runs here, on the person's machine, unfenced: a server the person opens in their browser, with their
13
+ * toolchains. The launch agent installs and runs what it needs itself, as any agent with a shell would - nothing is put to
14
+ * the person - and everything started is the harness's to stop: on the next launch, on /halt, and when turri exits.
15
+ */
16
+ /** A codebase's code at a commit, exported - what a launch takes on from. */
17
+ export interface ExportedCode {
18
+ /** The codebase: the module whose `plain_modules/<module>` holds the code. */
19
+ moduleName: string;
20
+ plainFile: string;
21
+ /** `dist/<module>`, in the project: the commit's code. */
22
+ dir: string;
23
+ /** Where the module's code is built: `plain_modules/<module>/code`. */
24
+ buildDir: string;
25
+ /** The commit, whole. */
26
+ commit: string;
27
+ /** The commit, short - as the person and the agents are told it. */
28
+ short: string;
29
+ /** The commit's subject: what the unit of work that landed it did. */
30
+ subject: string;
31
+ /** When, as git says it: "3 minutes ago". */
32
+ when: string;
33
+ /** Work under way in the module - changes nobody committed yet - left out. */
34
+ unfinished: boolean;
35
+ /** The module the spec's code lives in had nothing committed yet: the nearest one below it that had, instead. */
36
+ instead?: string;
37
+ }
38
+ /** The tree of a commit's code: two commits with the same one hold the same code - one landed only tests, say. */
39
+ export declare function codeTreeOf(moduleDir: string, commit: string): string | undefined;
40
+ /** Whether `commit` holds `ancestor`: the same commit, or one built on it. */
41
+ export declare function holdsCommit(moduleDir: string, ancestor: string, commit: string): boolean;
42
+ /**
43
+ * Which codebase to launch for a spec, and at which commit: the tip of its codebase - code accumulates up a requires
44
+ * chain, so the top module holds everything below it - at `commit`, or its last. Before the tip has anything committed,
45
+ * the nearest module below it that has.
46
+ */
47
+ export declare function launchTarget(plainFile: string, options?: {
48
+ inModule?: string;
49
+ commit?: string;
50
+ }): {
51
+ entry: ChainEntry;
52
+ commit: string;
53
+ instead?: string;
54
+ };
55
+ /**
56
+ * Export a codebase's code at a commit - its last, unless `commit` names one - into `dist/<module>`, or `into`
57
+ * (`turri regenerate --build-dir`), replacing whatever was there, the harness's own files (what the code is built from,
58
+ * the agents' notes) left out.
59
+ */
60
+ export declare function exportModule(plainFile: string, options?: {
61
+ inModule?: string;
62
+ into?: string;
63
+ commit?: string;
64
+ }): ExportedCode;
65
+ /**
66
+ * The host codebase a launch with guidance works in: the git repository the project is in - an embedded project's host -
67
+ * or else `fallback`, where turri runs.
68
+ */
69
+ export declare function hostDirOf(plainFile: string, fallback: string): string;
70
+ /** Where a path is, said from the current directory when it is below it. */
71
+ export declare function shortPath(path: string): string;
72
+ /** What was exported, in a line or three. */
73
+ export declare function describeExport(code: ExportedCode): string;
74
+ export interface LaunchedProcess {
75
+ name: string;
76
+ moduleName: string;
77
+ command: string;
78
+ /** Where it runs. */
79
+ dir: string;
80
+ url?: string;
81
+ /** Its output, both streams. */
82
+ log: string;
83
+ pid: number;
84
+ startedAt: number;
85
+ /** Set once it has ended. */
86
+ exited?: {
87
+ code: number | null;
88
+ signal: string | null;
89
+ };
90
+ }
91
+ /**
92
+ * What a launch started, written down as it starts - `.turri/launch/running/<pid>.json` - and taken out as it ends: a turri
93
+ * that dies without stopping what it started leaves it findable, for the next session to stop (`stopLeftBehind`).
94
+ */
95
+ export interface LaunchRecord {
96
+ pid: number;
97
+ /** Its process group: the pid, as it was started as the leader of a group of its own. */
98
+ pgid: number;
99
+ name: string;
100
+ moduleName: string;
101
+ command: string;
102
+ dir: string;
103
+ url?: string;
104
+ startedAt: number;
105
+ /** The turri process that started it. */
106
+ turri: number;
107
+ }
108
+ /**
109
+ * Stop what launches of an earlier turri left running in the project - the codebase's, or every one's - as stopLaunched
110
+ * stops this session's: its process group, politely, then not. Only what turri's own records name, whose turri has ended
111
+ * (another turri still running keeps its own), and only when the process is still the one recorded: a process turri did
112
+ * not start is never stopped. Records of what has ended are taken out. Returns what was stopped.
113
+ */
114
+ export declare function stopLeftBehind(projectDir: string, codebase?: string): Promise<LaunchRecord[]>;
115
+ /** What was stopped of an earlier session's, in a line - for a launch's summary. */
116
+ export declare function describeLeftBehind(stopped: LaunchRecord[]): string;
117
+ /** Everything a launch started, running or ended, oldest first. */
118
+ export declare function listLaunched(): LaunchedProcess[];
119
+ /** The ones still running. */
120
+ export declare function runningLaunched(moduleName?: string): LaunchedProcess[];
121
+ /** Where what a project's launches started write their output: its scratch, not the code in dist. */
122
+ export declare function launchLogDir(projectDir: string): string;
123
+ /** The end of a log, for when something did not come up. */
124
+ export declare function logTail(log: string, lines?: number, chars?: number): string;
125
+ /** Stop one launched process, or every one of a module, or every one: politely, then not. Returns the names stopped. */
126
+ export declare function stopLaunched(which?: {
127
+ name?: string;
128
+ moduleName?: string;
129
+ }): Promise<string[]>;
130
+ /** Stop everything at once, without waiting: for when turri itself is going. */
131
+ export declare function stopAllLaunchedNow(): void;
132
+ /** What holds a port, as lsof says it - or nothing when it cannot say. */
133
+ export declare function holderOf(port: number): string;
134
+ /** How long a server is given to answer at its URL, and to stay up when it has none. */
135
+ export declare const READY_TIMEOUT_MS: number;
136
+ export interface StartResult {
137
+ ok: boolean;
138
+ /** What happened, for the agent and the person. */
139
+ text: string;
140
+ process?: LaunchedProcess;
141
+ }
142
+ /**
143
+ * Start what keeps running, in `dir` - the folder `root` it is named from, or one inside it. A folder that is not there
144
+ * starts nothing: said, with what `root` holds, so the agent can name the right one.
145
+ */
146
+ export declare function startLaunched(input: {
147
+ name: string;
148
+ command: string;
149
+ dir: string;
150
+ moduleName: string;
151
+ logDir: string;
152
+ url?: string;
153
+ root?: string;
154
+ }): Promise<StartResult>;