@websitelabs/n8n-nodes-software-teams 0.12.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.
Files changed (176) hide show
  1. package/ARCHITECTURE.md +1232 -0
  2. package/CONTRACT.md +450 -0
  3. package/README.md +491 -0
  4. package/dist/agents/software-teams-architect.md +155 -0
  5. package/dist/agents/software-teams-backend.md +93 -0
  6. package/dist/agents/software-teams-codebase-mapper.md +67 -0
  7. package/dist/agents/software-teams-committer.md +90 -0
  8. package/dist/agents/software-teams-debugger.md +91 -0
  9. package/dist/agents/software-teams-dev-planner.md +175 -0
  10. package/dist/agents/software-teams-devops.md +92 -0
  11. package/dist/agents/software-teams-feedback-learner.md +118 -0
  12. package/dist/agents/software-teams-frontend.md +107 -0
  13. package/dist/agents/software-teams-game-ai-engineer.md +179 -0
  14. package/dist/agents/software-teams-game-art-pipeline.md +180 -0
  15. package/dist/agents/software-teams-game-designer.md +245 -0
  16. package/dist/agents/software-teams-game-devops.md +134 -0
  17. package/dist/agents/software-teams-game-engineer.md +146 -0
  18. package/dist/agents/software-teams-game-producer.md +288 -0
  19. package/dist/agents/software-teams-game-qa.md +297 -0
  20. package/dist/agents/software-teams-game-tech-artist.md +186 -0
  21. package/dist/agents/software-teams-head-engineering.md +37 -0
  22. package/dist/agents/software-teams-perf-analyst.md +124 -0
  23. package/dist/agents/software-teams-phase-researcher.md +75 -0
  24. package/dist/agents/software-teams-plan-checker.md +87 -0
  25. package/dist/agents/software-teams-planner.md +456 -0
  26. package/dist/agents/software-teams-pr-feedback.md +127 -0
  27. package/dist/agents/software-teams-pr-generator.md +107 -0
  28. package/dist/agents/software-teams-producer.md +203 -0
  29. package/dist/agents/software-teams-product-lead.md +51 -0
  30. package/dist/agents/software-teams-programmer.md +126 -0
  31. package/dist/agents/software-teams-qa-tester.md +165 -0
  32. package/dist/agents/software-teams-quality.md +153 -0
  33. package/dist/agents/software-teams-researcher.md +151 -0
  34. package/dist/agents/software-teams-security.md +126 -0
  35. package/dist/agents/software-teams-ux-designer.md +92 -0
  36. package/dist/agents/software-teams-verifier.md +87 -0
  37. package/dist/credentials/SoftwareTeamsApi.credentials.d.ts +18 -0
  38. package/dist/credentials/SoftwareTeamsApi.credentials.d.ts.map +1 -0
  39. package/dist/credentials/SoftwareTeamsApi.credentials.js +110 -0
  40. package/dist/credentials/SoftwareTeamsApi.credentials.js.map +1 -0
  41. package/dist/credentials/softwareTeamsApi.svg +14 -0
  42. package/dist/nodes/SoftwareTeamsAgent/SoftwareTeamsAgent.node.d.ts +23 -0
  43. package/dist/nodes/SoftwareTeamsAgent/SoftwareTeamsAgent.node.d.ts.map +1 -0
  44. package/dist/nodes/SoftwareTeamsAgent/SoftwareTeamsAgent.node.js +308 -0
  45. package/dist/nodes/SoftwareTeamsAgent/SoftwareTeamsAgent.node.js.map +1 -0
  46. package/dist/nodes/SoftwareTeamsAgent/softwareTeamsAgent.svg +18 -0
  47. package/dist/nodes/SoftwareTeamsCleanup/SoftwareTeamsCleanup.node.d.ts +24 -0
  48. package/dist/nodes/SoftwareTeamsCleanup/SoftwareTeamsCleanup.node.d.ts.map +1 -0
  49. package/dist/nodes/SoftwareTeamsCleanup/SoftwareTeamsCleanup.node.js +2635 -0
  50. package/dist/nodes/SoftwareTeamsCleanup/SoftwareTeamsCleanup.node.js.map +1 -0
  51. package/dist/nodes/SoftwareTeamsCleanup/SoftwareTeamsCleanup.svg +6 -0
  52. package/dist/nodes/SoftwareTeamsFinaliser/SoftwareTeamsFinaliser.node.d.ts +6 -0
  53. package/dist/nodes/SoftwareTeamsFinaliser/SoftwareTeamsFinaliser.node.d.ts.map +1 -0
  54. package/dist/nodes/SoftwareTeamsFinaliser/SoftwareTeamsFinaliser.node.js +231 -0
  55. package/dist/nodes/SoftwareTeamsFinaliser/SoftwareTeamsFinaliser.node.js.map +1 -0
  56. package/dist/nodes/SoftwareTeamsFinaliser/softwareTeamsFinaliser.svg +11 -0
  57. package/dist/nodes/SoftwareTeamsHitl/SoftwareTeamsHitl.node.d.ts +25 -0
  58. package/dist/nodes/SoftwareTeamsHitl/SoftwareTeamsHitl.node.d.ts.map +1 -0
  59. package/dist/nodes/SoftwareTeamsHitl/SoftwareTeamsHitl.node.js +366 -0
  60. package/dist/nodes/SoftwareTeamsHitl/SoftwareTeamsHitl.node.js.map +1 -0
  61. package/dist/nodes/SoftwareTeamsHitl/softwareTeamsHitl.svg +11 -0
  62. package/dist/nodes/SoftwareTeamsOrchestrator/SoftwareTeamsOrchestrator.node.d.ts +15 -0
  63. package/dist/nodes/SoftwareTeamsOrchestrator/SoftwareTeamsOrchestrator.node.d.ts.map +1 -0
  64. package/dist/nodes/SoftwareTeamsOrchestrator/SoftwareTeamsOrchestrator.node.js +373 -0
  65. package/dist/nodes/SoftwareTeamsOrchestrator/SoftwareTeamsOrchestrator.node.js.map +1 -0
  66. package/dist/nodes/SoftwareTeamsOrchestrator/softwareTeamsOrchestrator.svg +20 -0
  67. package/dist/nodes/SoftwareTeamsOutput/SoftwareTeamsOutput.node.d.ts +6 -0
  68. package/dist/nodes/SoftwareTeamsOutput/SoftwareTeamsOutput.node.d.ts.map +1 -0
  69. package/dist/nodes/SoftwareTeamsOutput/SoftwareTeamsOutput.node.js +2685 -0
  70. package/dist/nodes/SoftwareTeamsOutput/SoftwareTeamsOutput.node.js.map +1 -0
  71. package/dist/nodes/SoftwareTeamsOutput/SoftwareTeamsOutput.svg +6 -0
  72. package/dist/nodes/SoftwareTeamsPrFeedback/SoftwareTeamsPrFeedback.node.d.ts +22 -0
  73. package/dist/nodes/SoftwareTeamsPrFeedback/SoftwareTeamsPrFeedback.node.d.ts.map +1 -0
  74. package/dist/nodes/SoftwareTeamsPrFeedback/SoftwareTeamsPrFeedback.node.js +2655 -0
  75. package/dist/nodes/SoftwareTeamsPrFeedback/SoftwareTeamsPrFeedback.node.js.map +1 -0
  76. package/dist/nodes/SoftwareTeamsPrFeedback/softwareTeamsPrFeedback.svg +8 -0
  77. package/dist/nodes/SoftwareTeamsSlackHitl/SoftwareTeamsSlackHitl.node.d.ts +19 -0
  78. package/dist/nodes/SoftwareTeamsSlackHitl/SoftwareTeamsSlackHitl.node.d.ts.map +1 -0
  79. package/dist/nodes/SoftwareTeamsSlackHitl/SoftwareTeamsSlackHitl.node.js +198 -0
  80. package/dist/nodes/SoftwareTeamsSlackHitl/SoftwareTeamsSlackHitl.node.js.map +1 -0
  81. package/dist/nodes/SoftwareTeamsSlackHitl/softwareTeamsSlackHitl.svg +10 -0
  82. package/dist/nodes/SoftwareTeamsTrigger/SoftwareTeamsTrigger.node.d.ts +6 -0
  83. package/dist/nodes/SoftwareTeamsTrigger/SoftwareTeamsTrigger.node.d.ts.map +1 -0
  84. package/dist/nodes/SoftwareTeamsTrigger/SoftwareTeamsTrigger.node.js +2601 -0
  85. package/dist/nodes/SoftwareTeamsTrigger/SoftwareTeamsTrigger.node.js.map +1 -0
  86. package/dist/nodes/SoftwareTeamsTrigger/SoftwareTeamsTrigger.node.svg +6 -0
  87. package/dist/nodes/SoftwareTeamsWorkspace/SoftwareTeamsWorkspace.node.d.ts +20 -0
  88. package/dist/nodes/SoftwareTeamsWorkspace/SoftwareTeamsWorkspace.node.d.ts.map +1 -0
  89. package/dist/nodes/SoftwareTeamsWorkspace/SoftwareTeamsWorkspace.node.js +175 -0
  90. package/dist/nodes/SoftwareTeamsWorkspace/SoftwareTeamsWorkspace.node.js.map +1 -0
  91. package/dist/nodes/SoftwareTeamsWorkspace/softwareTeamsWorkspace.svg +13 -0
  92. package/dist/src/execution/single-turn.d.ts +6 -0
  93. package/dist/src/execution/single-turn.d.ts.map +1 -0
  94. package/dist/src/execution/single-turn.js +2662 -0
  95. package/dist/src/execution/single-turn.js.map +1 -0
  96. package/dist/src/hitl/channels.d.ts +48 -0
  97. package/dist/src/hitl/channels.d.ts.map +1 -0
  98. package/dist/src/hitl/channels.js +297 -0
  99. package/dist/src/hitl/channels.js.map +1 -0
  100. package/dist/src/hitl/conversation-state.d.ts +45 -0
  101. package/dist/src/hitl/conversation-state.d.ts.map +1 -0
  102. package/dist/src/hitl/conversation-state.js +69 -0
  103. package/dist/src/hitl/conversation-state.js.map +1 -0
  104. package/dist/src/hitl/slack.d.ts +32 -0
  105. package/dist/src/hitl/slack.d.ts.map +1 -0
  106. package/dist/src/hitl/slack.js +202 -0
  107. package/dist/src/hitl/slack.js.map +1 -0
  108. package/dist/src/ingestion/context.d.ts +38 -0
  109. package/dist/src/ingestion/context.d.ts.map +1 -0
  110. package/dist/src/ingestion/context.js +2501 -0
  111. package/dist/src/ingestion/context.js.map +1 -0
  112. package/dist/src/ingestion/pr-feedback.d.ts +48 -0
  113. package/dist/src/ingestion/pr-feedback.d.ts.map +1 -0
  114. package/dist/src/ingestion/pr-feedback.js +85 -0
  115. package/dist/src/ingestion/pr-feedback.js.map +1 -0
  116. package/dist/src/n8n-cast.d.ts +11 -0
  117. package/dist/src/n8n-cast.d.ts.map +1 -0
  118. package/dist/src/n8n-cast.js +17 -0
  119. package/dist/src/n8n-cast.js.map +1 -0
  120. package/dist/src/orchestration/run-state/global-store.d.ts +7 -0
  121. package/dist/src/orchestration/run-state/global-store.d.ts.map +1 -0
  122. package/dist/src/orchestration/run-state/global-store.js +27 -0
  123. package/dist/src/orchestration/run-state/global-store.js.map +1 -0
  124. package/dist/src/orchestration/run-state/ordering.d.ts +14 -0
  125. package/dist/src/orchestration/run-state/ordering.d.ts.map +1 -0
  126. package/dist/src/orchestration/run-state/ordering.js +59 -0
  127. package/dist/src/orchestration/run-state/ordering.js.map +1 -0
  128. package/dist/src/orchestration/run-state/persistence.d.ts +9 -0
  129. package/dist/src/orchestration/run-state/persistence.d.ts.map +1 -0
  130. package/dist/src/orchestration/run-state/persistence.js +29 -0
  131. package/dist/src/orchestration/run-state/persistence.js.map +1 -0
  132. package/dist/src/orchestration/run-state/planning.d.ts +17 -0
  133. package/dist/src/orchestration/run-state/planning.d.ts.map +1 -0
  134. package/dist/src/orchestration/run-state/planning.js +117 -0
  135. package/dist/src/orchestration/run-state/planning.js.map +1 -0
  136. package/dist/src/orchestration/run-state/readiness.d.ts +20 -0
  137. package/dist/src/orchestration/run-state/readiness.d.ts.map +1 -0
  138. package/dist/src/orchestration/run-state/readiness.js +105 -0
  139. package/dist/src/orchestration/run-state/readiness.js.map +1 -0
  140. package/dist/src/orchestration/run-state/shapes.d.ts +53 -0
  141. package/dist/src/orchestration/run-state/shapes.d.ts.map +1 -0
  142. package/dist/src/orchestration/run-state/shapes.js +3 -0
  143. package/dist/src/orchestration/run-state/shapes.js.map +1 -0
  144. package/dist/src/orchestration/run-state/transitions.d.ts +46 -0
  145. package/dist/src/orchestration/run-state/transitions.d.ts.map +1 -0
  146. package/dist/src/orchestration/run-state/transitions.js +133 -0
  147. package/dist/src/orchestration/run-state/transitions.js.map +1 -0
  148. package/dist/src/orchestration/run-state.d.ts +8 -0
  149. package/dist/src/orchestration/run-state.d.ts.map +1 -0
  150. package/dist/src/orchestration/run-state.js +35 -0
  151. package/dist/src/orchestration/run-state.js.map +1 -0
  152. package/dist/src/output/github.d.ts +39 -0
  153. package/dist/src/output/github.d.ts.map +1 -0
  154. package/dist/src/output/github.js +2492 -0
  155. package/dist/src/output/github.js.map +1 -0
  156. package/dist/src/repo/git.d.ts +71 -0
  157. package/dist/src/repo/git.d.ts.map +1 -0
  158. package/dist/src/repo/git.js +207 -0
  159. package/dist/src/repo/git.js.map +1 -0
  160. package/dist/src/repo/merge.d.ts +36 -0
  161. package/dist/src/repo/merge.d.ts.map +1 -0
  162. package/dist/src/repo/merge.js +133 -0
  163. package/dist/src/repo/merge.js.map +1 -0
  164. package/dist/src/repo/repo-context.d.ts +23 -0
  165. package/dist/src/repo/repo-context.d.ts.map +1 -0
  166. package/dist/src/repo/repo-context.js +10 -0
  167. package/dist/src/repo/repo-context.js.map +1 -0
  168. package/dist/src/repo/teardown.d.ts +38 -0
  169. package/dist/src/repo/teardown.d.ts.map +1 -0
  170. package/dist/src/repo/teardown.js +171 -0
  171. package/dist/src/repo/teardown.js.map +1 -0
  172. package/dist/src/repo/validate.d.ts +4 -0
  173. package/dist/src/repo/validate.d.ts.map +1 -0
  174. package/dist/src/repo/validate.js +42 -0
  175. package/dist/src/repo/validate.js.map +1 -0
  176. package/package.json +73 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.js","sourceRoot":"","sources":["../../../src/output/github.ts"],"names":[],"mappings":";;AAGA,0BAEC;AAkED,8CAUC;AAGD,kCAUC;AAUD,8CAQC;AAhHD,gEAAuE;AAEvE,4EAA4E;AAC5E,SAAgB,OAAO,CAAC,KAAa,EAAE,SAAS,GAAG,EAAE;IACnD,OAAO,IAAA,wBAAa,EAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AACzC,CAAC;AAmCD,KAAK,UAAU,MAAM,CACnB,IAAY,EACZ,IAA6B,EAC7B,KAAa;;IAEb,MAAM,UAAU,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,wBAAwB,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC/F,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,UAAU,GAAG,IAAI,EAAE,EAAE;QAC/C,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,aAAa,EAAE,SAAS,KAAK,EAAE;YAC/B,MAAM,EAAE,gCAAgC;YACxC,cAAc,EAAE,kBAAkB;YAClC,YAAY,EAAE,uCAAuC;SACtD;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAsB,CAAC;IAEtD,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QACb,MAAM,MAAM,GACV,MAAA,MAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI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,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtC,IAAI,OAAO,KAAK,CAAC,CAAC,EAAE,CAAC;QACnB,OAAO,GAAG,CAAC,KAAK,CAAC,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,GAAG,CAAC;IACxC,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,71 @@
1
+ import type { ChangeRef } from "./repo-context.js";
2
+ /**
3
+ * Shallow-clone `cloneUrl` at `branch` into `destDir`.
4
+ * Fails fast with an actionable message if `git` is missing (mirrors findClaude).
5
+ * All args are passed as argv arrays — never shell-concatenated (R-08).
6
+ * Diagnostics go to stderr to protect stream-json purity (R-09).
7
+ */
8
+ export declare function cloneRepo(opts: {
9
+ readonly cloneUrl: string;
10
+ readonly branch: string;
11
+ readonly destDir: string;
12
+ }): Promise<void>;
13
+ /**
14
+ * Create an isolated git worktree for an agent turn under `<repoDir>/worktrees/<agentId>`.
15
+ * The worktree is checked out at a new branch named after the agentId + correlationId suffix.
16
+ * Returns the absolute path to the new worktree.
17
+ */
18
+ export declare function createWorktree(opts: {
19
+ readonly repoDir: string;
20
+ readonly agentId: string;
21
+ readonly correlationId: string;
22
+ readonly baseBranch: string;
23
+ }): Promise<string>;
24
+ /**
25
+ * Remove the worktree rooted at `worktreePath` and prune the tracking entry.
26
+ */
27
+ export declare function removeWorktree(opts: {
28
+ readonly repoDir: string;
29
+ readonly worktreePath: string;
30
+ }): Promise<void>;
31
+ /**
32
+ * Capture the agent turn's changes as a portable `ChangeRef`.
33
+ * Uses `git format-patch` from the merge-base of the worktree branch and
34
+ * `baseBranch`, encodes the combined patch bytes as base64.
35
+ * If there are no commits ahead of baseBranch, stages and commits any
36
+ * uncommitted changes first. Returns null when the worktree is clean and
37
+ * has no diverging commits.
38
+ */
39
+ export declare function capturePortableChange(opts: {
40
+ readonly worktreePath: string;
41
+ readonly baseBranch: string;
42
+ }): Promise<ChangeRef | null>;
43
+ /**
44
+ * Apply a portable `ChangeRef` in `targetDir` via `git am`.
45
+ * Decodes base64 patch bytes and pipes them to `git am`.
46
+ * Queue-mode-safe: the targetDir may be on a different worker than where
47
+ * the ChangeRef was produced.
48
+ */
49
+ export declare function applyPortableChange(opts: {
50
+ readonly changeRef: ChangeRef;
51
+ readonly targetDir: string;
52
+ }): Promise<void>;
53
+ /**
54
+ * List files that differ between `targetRef` and `sourceRef` (or HEAD if absent).
55
+ * Returns an array of relative file paths. Used by the Finaliser to detect
56
+ * conflicts and build the run summary.
57
+ */
58
+ export declare function listChangedFiles(opts: {
59
+ readonly repoDir: string;
60
+ readonly baseRef: string;
61
+ readonly headRef?: string;
62
+ }): Promise<readonly string[]>;
63
+ /**
64
+ * Return the short git status of `repoDir` (porcelain v1).
65
+ * Each line is in the form `XY filename`. Used by the Finaliser to detect
66
+ * conflict markers in the working tree.
67
+ */
68
+ export declare function gitStatus(opts: {
69
+ readonly repoDir: string;
70
+ }): Promise<readonly string[]>;
71
+ //# sourceMappingURL=git.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../../src/repo/git.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AA6BnD;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBhB;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAC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ports.removeWorktree = removeWorktree;
6
+ exports.capturePortableChange = capturePortableChange;
7
+ exports.applyPortableChange = applyPortableChange;
8
+ exports.listChangedFiles = listChangedFiles;
9
+ exports.gitStatus = gitStatus;
10
+ const node_child_process_1 = require("node:child_process");
11
+ const node_util_1 = require("node:util");
12
+ const node_path_1 = require("node:path");
13
+ const execFile = (0, node_util_1.promisify)(node_child_process_1.execFile);
14
+ async function run(cmd, args, opts) {
15
+ return execFile(cmd, [...args], { cwd: opts === null || opts === void 0 ? void 0 : opts.cwd });
16
+ }
17
+ async function findGit() {
18
+ try {
19
+ const { stdout } = await execFile("which", ["git"]);
20
+ const path = stdout.trim();
21
+ if (path)
22
+ return path;
23
+ }
24
+ catch {
25
+ // not found via which
26
+ }
27
+ throw new Error("git binary not found. Install git and ensure it is on PATH. " +
28
+ "@websitelabs/n8n-nodes-software-teams requires a self-hosted n8n instance " +
29
+ "with the `git` binary available on the worker.");
30
+ }
31
+ /**
32
+ * Shallow-clone `cloneUrl` at `branch` into `destDir`.
33
+ * Fails fast with an actionable message if `git` is missing (mirrors findClaude).
34
+ * All args are passed as argv arrays — never shell-concatenated (R-08).
35
+ * Diagnostics go to stderr to protect stream-json purity (R-09).
36
+ */
37
+ async function cloneRepo(opts) {
38
+ const git = await findGit();
39
+ const { cloneUrl, branch, destDir } = opts;
40
+ const result = await run(git, [
41
+ "clone",
42
+ "--depth=1",
43
+ "--branch",
44
+ branch,
45
+ "--",
46
+ cloneUrl,
47
+ destDir,
48
+ ]).catch((err) => {
49
+ process.stderr.write(`[git] clone failed: ${err.message}\n`);
50
+ throw err;
51
+ });
52
+ if (result.stderr) {
53
+ process.stderr.write(`[git] clone: ${result.stderr}\n`);
54
+ }
55
+ }
56
+ /**
57
+ * Create an isolated git worktree for an agent turn under `<repoDir>/worktrees/<agentId>`.
58
+ * The worktree is checked out at a new branch named after the agentId + correlationId suffix.
59
+ * Returns the absolute path to the new worktree.
60
+ */
61
+ async function createWorktree(opts) {
62
+ const git = await findGit();
63
+ const { repoDir, agentId, correlationId, baseBranch } = opts;
64
+ const slug = correlationId.slice(0, 8);
65
+ const branchName = `wt/${agentId}/${slug}`;
66
+ const worktreePath = (0, node_path_1.join)(repoDir, "worktrees", `${agentId}-${slug}`);
67
+ const result = await run(git, ["worktree", "add", "-b", branchName, "--", worktreePath, baseBranch], { cwd: repoDir }).catch((err) => {
68
+ process.stderr.write(`[git] worktree add failed: ${err.message}\n`);
69
+ throw err;
70
+ });
71
+ if (result.stderr) {
72
+ process.stderr.write(`[git] worktree add: ${result.stderr}\n`);
73
+ }
74
+ return worktreePath;
75
+ }
76
+ /**
77
+ * Remove the worktree rooted at `worktreePath` and prune the tracking entry.
78
+ */
79
+ async function removeWorktree(opts) {
80
+ const git = await findGit();
81
+ const { repoDir, worktreePath } = opts;
82
+ const result = await run(git, ["worktree", "remove", "--force", "--", worktreePath], { cwd: repoDir }).catch((err) => {
83
+ process.stderr.write(`[git] worktree remove failed: ${err.message}\n`);
84
+ throw err;
85
+ });
86
+ if (result.stderr) {
87
+ process.stderr.write(`[git] worktree remove: ${result.stderr}\n`);
88
+ }
89
+ await run(git, ["worktree", "prune"], { cwd: repoDir }).catch(() => {
90
+ // best-effort
91
+ });
92
+ }
93
+ /**
94
+ * Stage all changes in `worktreePath` and commit them.
95
+ * Returns the commit SHA of the new commit, or null if there is nothing to commit.
96
+ */
97
+ async function stageAndCommit(opts) {
98
+ const { git, worktreePath, message } = opts;
99
+ const statusResult = await run(git, ["status", "--porcelain"], {
100
+ cwd: worktreePath,
101
+ });
102
+ if (!statusResult.stdout.trim())
103
+ return null;
104
+ await run(git, ["add", "--all"], { cwd: worktreePath });
105
+ await run(git, ["commit", "-m", message, "--allow-empty"], {
106
+ cwd: worktreePath,
107
+ });
108
+ const revResult = await run(git, ["rev-parse", "HEAD"], {
109
+ cwd: worktreePath,
110
+ });
111
+ return revResult.stdout.trim();
112
+ }
113
+ /**
114
+ * Capture the agent turn's changes as a portable `ChangeRef`.
115
+ * Uses `git format-patch` from the merge-base of the worktree branch and
116
+ * `baseBranch`, encodes the combined patch bytes as base64.
117
+ * If there are no commits ahead of baseBranch, stages and commits any
118
+ * uncommitted changes first. Returns null when the worktree is clean and
119
+ * has no diverging commits.
120
+ */
121
+ async function capturePortableChange(opts) {
122
+ const git = await findGit();
123
+ const { worktreePath, baseBranch } = opts;
124
+ await stageAndCommit({
125
+ git,
126
+ worktreePath,
127
+ message: "chore: capture agent turn changes",
128
+ });
129
+ const mergeBaseResult = await run(git, ["merge-base", "HEAD", baseBranch], { cwd: worktreePath }).catch(() => ({ stdout: "", stderr: "" }));
130
+ const mergeBase = mergeBaseResult.stdout.trim();
131
+ const patchRange = mergeBase ? `${mergeBase}..HEAD` : baseBranch;
132
+ const patchResult = await run(git, ["format-patch", "--stdout", patchRange], { cwd: worktreePath });
133
+ const patchBytes = patchResult.stdout;
134
+ if (!patchBytes.trim())
135
+ return null;
136
+ const patchBase64 = Buffer.from(patchBytes, "utf8").toString("base64");
137
+ return { kind: "format-patch", patchBase64 };
138
+ }
139
+ /**
140
+ * Apply a portable `ChangeRef` in `targetDir` via `git am`.
141
+ * Decodes base64 patch bytes and pipes them to `git am`.
142
+ * Queue-mode-safe: the targetDir may be on a different worker than where
143
+ * the ChangeRef was produced.
144
+ */
145
+ async function applyPortableChange(opts) {
146
+ const git = await findGit();
147
+ const { changeRef, targetDir } = opts;
148
+ const patchBytes = Buffer.from(changeRef.patchBase64, "base64").toString("utf8");
149
+ await new Promise((resolve, reject) => {
150
+ var _a, _b, _c;
151
+ const proc = (0, node_child_process_1.spawn)(git, ["am", "--3way"], {
152
+ cwd: targetDir,
153
+ stdio: ["pipe", "inherit", "pipe"],
154
+ });
155
+ const stderrChunks = [];
156
+ (_a = proc.stderr) === null || _a === void 0 ? void 0 : _a.on("data", (chunk) => {
157
+ stderrChunks.push(chunk);
158
+ });
159
+ proc.on("close", (code) => {
160
+ const stderrText = Buffer.concat(stderrChunks).toString("utf8");
161
+ if (stderrText)
162
+ process.stderr.write(`[git] am: ${stderrText}\n`);
163
+ if (code === 0) {
164
+ resolve();
165
+ }
166
+ else {
167
+ reject(new Error(`git am failed with exit code ${code}`));
168
+ }
169
+ });
170
+ proc.on("error", reject);
171
+ (_b = proc.stdin) === null || _b === void 0 ? void 0 : _b.write(patchBytes);
172
+ (_c = proc.stdin) === null || _c === void 0 ? void 0 : _c.end();
173
+ });
174
+ }
175
+ /**
176
+ * List files that differ between `targetRef` and `sourceRef` (or HEAD if absent).
177
+ * Returns an array of relative file paths. Used by the Finaliser to detect
178
+ * conflicts and build the run summary.
179
+ */
180
+ async function listChangedFiles(opts) {
181
+ const git = await findGit();
182
+ const { repoDir, baseRef, headRef } = opts;
183
+ const args = headRef
184
+ ? ["diff", "--name-only", baseRef, headRef]
185
+ : ["diff", "--name-only", baseRef, "HEAD"];
186
+ const result = await run(git, args, { cwd: repoDir });
187
+ return result.stdout
188
+ .split("\n")
189
+ .map((l) => l.trim())
190
+ .filter(Boolean);
191
+ }
192
+ /**
193
+ * Return the short git status of `repoDir` (porcelain v1).
194
+ * Each line is in the form `XY filename`. Used by the Finaliser to detect
195
+ * conflict markers in the working tree.
196
+ */
197
+ async function gitStatus(opts) {
198
+ const git = await findGit();
199
+ const result = await run(git, ["status", "--porcelain"], {
200
+ cwd: opts.repoDir,
201
+ });
202
+ return result.stdout
203
+ .split("\n")
204
+ .map((l) => l.trim())
205
+ .filter(Boolean);
206
+ }
207
+ //# sourceMappingURL=git.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.js","sourceRoot":"","sources":["../../../src/repo/git.ts"],"names":[],"mappings":";;AAsCA,8BAwBC;AAOD,wCAwBC;AAKD,wCAoBC;AAoCD,sDAiCC;AAQD,kDAiCC;AAOD,4CAgBC;AAOD,8BAWC;AA7QD,2DAAmE;AACnE,yCAAsC;AACtC,yCAAiC;AAGjC,MAAM,QAAQ,GAAG,IAAA,qBAAS,EAAC,6BAAU,CAAC,CAAC;AAIvC,KAAK,UAAU,GAA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CAAC,OAAO,CAAC,CAAC;AACrB,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { ChangeRef } from "./repo-context.js";
2
+ export interface MergeSuccess {
3
+ readonly kind: "success";
4
+ readonly branch: string;
5
+ }
6
+ export interface MergeFailure {
7
+ readonly kind: "bounded-failure";
8
+ readonly conflictingFiles: readonly string[];
9
+ readonly turnsExhausted: number;
10
+ }
11
+ export type MergeResult = MergeSuccess | MergeFailure;
12
+ export interface ApplyAndResolveOpts {
13
+ readonly repoDir: string;
14
+ readonly branchName: string;
15
+ readonly baseBranch: string;
16
+ readonly changeRefs: readonly ChangeRef[];
17
+ readonly resolver: (conflictingFiles: readonly string[]) => Promise<void>;
18
+ }
19
+ /**
20
+ * Apply each changeRef onto branchName (forked from baseBranch in repoDir),
21
+ * then run up to MAX_RESOLVER_TURNS of the injected resolver for any conflicts.
22
+ *
23
+ * The resolver is injected so T11 can mock it without invoking claude.
24
+ * Returns MergeSuccess when the tree is conflict-free, MergeFailure (with the
25
+ * conflicting file list) when MAX_RESOLVER_TURNS are exhausted.
26
+ *
27
+ * NEVER pushes. NEVER loops beyond MAX_RESOLVER_TURNS (R-16).
28
+ */
29
+ export declare function applyAndResolve(opts: ApplyAndResolveOpts): Promise<MergeResult>;
30
+ export declare function pushBranch(opts: {
31
+ readonly repoDir: string;
32
+ readonly branchName: string;
33
+ readonly remote: string;
34
+ readonly githubToken: string;
35
+ }): Promise<void>;
36
+ //# sourceMappingURL=merge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/repo/merge.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AA6EnD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,YAAY,CAAC;AAItD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,QAAQ,EAAE,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3E;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC,CAiDrF;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BhB"}
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applyAndResolve = applyAndResolve;
4
+ exports.pushBranch = pushBranch;
5
+ const node_child_process_1 = require("node:child_process");
6
+ const node_util_1 = require("node:util");
7
+ const git_js_1 = require("./git.js");
8
+ const execFile = (0, node_util_1.promisify)(node_child_process_1.execFile);
9
+ async function run(cmd, args, opts) {
10
+ return execFile(cmd, [...args], { cwd: opts === null || opts === void 0 ? void 0 : opts.cwd });
11
+ }
12
+ async function findGit() {
13
+ try {
14
+ const { stdout } = await execFile("which", ["git"]);
15
+ const path = stdout.trim();
16
+ if (path)
17
+ return path;
18
+ }
19
+ catch {
20
+ // not found via which
21
+ }
22
+ throw new Error("git binary not found. Install git and ensure it is on PATH.");
23
+ }
24
+ async function hasConflictMarkers(git, repoDir) {
25
+ const statusResult = await run(git, ["status", "--porcelain"], { cwd: repoDir }).catch(() => ({ stdout: "" }));
26
+ const conflicted = statusResult.stdout
27
+ .split("\n")
28
+ .filter((l) => /^(UU|AA|DD|AU|UA|DU|UD)\s/.test(l.trim()))
29
+ .map((l) => l.trim().slice(3).trim())
30
+ .filter(Boolean);
31
+ if (conflicted.length > 0)
32
+ return conflicted;
33
+ const checkResult = await run(git, ["diff", "--check"], { cwd: repoDir }).catch((err) => { var _a; return ({ stdout: (_a = err.stdout) !== null && _a !== void 0 ? _a : "" }); });
34
+ if (checkResult.stdout.trim()) {
35
+ return checkResult.stdout
36
+ .split("\n")
37
+ .map((l) => { var _a, _b; return (_b = (_a = l.split(":")[0]) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : ""; })
38
+ .filter(Boolean)
39
+ .filter((f, idx, arr) => arr.indexOf(f) === idx);
40
+ }
41
+ return [];
42
+ }
43
+ async function checkoutBranch(opts) {
44
+ const { git, repoDir, branchName, baseBranch } = opts;
45
+ await run(git, ["checkout", "-b", branchName, baseBranch], { cwd: repoDir }).catch(async () => {
46
+ await run(git, ["checkout", branchName], { cwd: repoDir });
47
+ });
48
+ }
49
+ async function stageAndCommit(opts) {
50
+ const { git, repoDir, message } = opts;
51
+ const statusResult = await run(git, ["status", "--porcelain"], { cwd: repoDir });
52
+ if (!statusResult.stdout.trim())
53
+ return;
54
+ await run(git, ["add", "--all"], { cwd: repoDir });
55
+ await run(git, ["commit", "-m", message, "--allow-empty"], { cwd: repoDir });
56
+ }
57
+ const MAX_RESOLVER_TURNS = 3;
58
+ /**
59
+ * Apply each changeRef onto branchName (forked from baseBranch in repoDir),
60
+ * then run up to MAX_RESOLVER_TURNS of the injected resolver for any conflicts.
61
+ *
62
+ * The resolver is injected so T11 can mock it without invoking claude.
63
+ * Returns MergeSuccess when the tree is conflict-free, MergeFailure (with the
64
+ * conflicting file list) when MAX_RESOLVER_TURNS are exhausted.
65
+ *
66
+ * NEVER pushes. NEVER loops beyond MAX_RESOLVER_TURNS (R-16).
67
+ */
68
+ async function applyAndResolve(opts) {
69
+ const { repoDir, branchName, baseBranch, changeRefs, resolver } = opts;
70
+ const git = await findGit();
71
+ await checkoutBranch({ git, repoDir, branchName, baseBranch });
72
+ for (const changeRef of changeRefs) {
73
+ await (0, git_js_1.applyPortableChange)({ changeRef, targetDir: repoDir }).catch(async (err) => {
74
+ process.stderr.write(`[merge] applyPortableChange failed: ${err.message}\n`);
75
+ const conflicts = await hasConflictMarkers(git, repoDir);
76
+ if (conflicts.length === 0) {
77
+ await run(git, ["am", "--abort"], { cwd: repoDir }).catch(() => undefined);
78
+ }
79
+ });
80
+ }
81
+ const initialConflicts = await hasConflictMarkers(git, repoDir);
82
+ if (initialConflicts.length === 0) {
83
+ await stageAndCommit({ git, repoDir, message: "chore: merge agent changes" });
84
+ return { kind: "success", branch: branchName };
85
+ }
86
+ for (const attempt of Array.from({ length: MAX_RESOLVER_TURNS }, (_value, index) => index)) {
87
+ const conflictsBeforeTurn = await hasConflictMarkers(git, repoDir);
88
+ if (conflictsBeforeTurn.length === 0) {
89
+ await stageAndCommit({ git, repoDir, message: "chore: merge agent changes" });
90
+ return { kind: "success", branch: branchName };
91
+ }
92
+ await resolver(conflictsBeforeTurn);
93
+ const conflictsAfterTurn = await hasConflictMarkers(git, repoDir);
94
+ if (conflictsAfterTurn.length === 0) {
95
+ await stageAndCommit({
96
+ git,
97
+ repoDir,
98
+ message: `chore: merge agent changes (resolved, attempt ${attempt + 1})`,
99
+ });
100
+ return { kind: "success", branch: branchName };
101
+ }
102
+ }
103
+ const remainingConflicts = await hasConflictMarkers(git, repoDir);
104
+ return {
105
+ kind: "bounded-failure",
106
+ conflictingFiles: remainingConflicts,
107
+ turnsExhausted: MAX_RESOLVER_TURNS,
108
+ };
109
+ }
110
+ async function pushBranch(opts) {
111
+ const { repoDir, branchName, remote, githubToken } = opts;
112
+ await new Promise((resolve, reject) => {
113
+ var _a;
114
+ const proc = (0, node_child_process_1.spawn)("git", ["push", "--set-upstream", remote, branchName], {
115
+ cwd: repoDir,
116
+ env: { ...process.env, GITHUB_TOKEN: githubToken, GIT_ASKPASS: "echo" },
117
+ stdio: ["ignore", "inherit", "pipe"],
118
+ });
119
+ const stderrChunks = [];
120
+ (_a = proc.stderr) === null || _a === void 0 ? void 0 : _a.on("data", (chunk) => stderrChunks.push(chunk));
121
+ proc.on("close", (code) => {
122
+ const stderrText = Buffer.concat(stderrChunks).toString("utf8");
123
+ if (stderrText)
124
+ process.stderr.write(`[merge] git push: ${stderrText}\n`);
125
+ if (code === 0)
126
+ resolve();
127
+ else
128
+ reject(new Error(`git push failed with exit code ${code}`));
129
+ });
130
+ proc.on("error", reject);
131
+ });
132
+ }
133
+ //# sourceMappingURL=merge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.js","sourceRoot":"","sources":["../../../src/repo/merge.ts"],"names":[],"mappings":";;AAgHA,0CAiDC;AAED,gCA+BC;AAlMD,2DAAmE;AACnE,yCAAsC;AAEtC,qCAA+C;AAE/C,MAAM,QAAQ,GAAG,IAAA,qBAAS,EAAC,6BAAU,CAAC,CAAC;AAEvC,KAAK,UAAU,GAAG,CAChB,GAAW,EACX,IAAuB,EACvB,IAAuB;IAEvB,OAAO,QAAQ,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,EAAE,CAAC,CAAC;AACtD,CAAC;AAED,KAAK,UAAU,OAAO;IACpB,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,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AAC,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * ADR-002 Decision D — canonical type for repo-scoped execution.
3
+ * This is the SINGLE source of truth imported by T2, T7, T8, T9.
4
+ * This type is OFF-WIRE: never serialised into NodeEnvelope or assemblePrompt.
5
+ *
6
+ * ChangeRef is the shared on-wire contract type; import it from @websitelabs/software-teams.
7
+ */
8
+ import type { ChangeRef } from "@websitelabs/software-teams";
9
+ export type { ChangeRef };
10
+ /**
11
+ * ADR-002 Decision D — the run's repository checkout descriptor.
12
+ * Threaded as a typed optional parameter on `runAgentTurn(input, repoContext?)`.
13
+ * Members are fixed and exhaustive; none may be added or removed without a new ADR.
14
+ */
15
+ export interface RepoContext {
16
+ readonly cloneUrl: string;
17
+ readonly ownerRepo: string;
18
+ readonly baseBranch: string;
19
+ readonly correlationId: string;
20
+ readonly worktreePath: string;
21
+ readonly changeRef?: ChangeRef;
22
+ }
23
+ //# sourceMappingURL=repo-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo-context.d.ts","sourceRoot":"","sources":["../../../src/repo/repo-context.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D,YAAY,EAAE,SAAS,EAAE,CAAC;AAE1B;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;CAChC"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ /**
3
+ * ADR-002 Decision D — canonical type for repo-scoped execution.
4
+ * This is the SINGLE source of truth imported by T2, T7, T8, T9.
5
+ * This type is OFF-WIRE: never serialised into NodeEnvelope or assemblePrompt.
6
+ *
7
+ * ChangeRef is the shared on-wire contract type; import it from @websitelabs/software-teams.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ //# sourceMappingURL=repo-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo-context.js","sourceRoot":"","sources":["../../../src/repo/repo-context.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
@@ -0,0 +1,38 @@
1
+ export interface TeardownResult {
2
+ readonly removed: boolean;
3
+ readonly detail?: string;
4
+ }
5
+ /**
6
+ * Assert that `targetPath` is strictly inside `basePath` after resolving both
7
+ * to absolute canonical paths. Throws if the target IS the base, is above it,
8
+ * or escapes via `..` traversal.
9
+ *
10
+ * Used by the rm-based helpers to prevent accidental deletion of the repo root,
11
+ * `/`, or any path outside the allowed run base (R-04).
12
+ */
13
+ export declare function assertWithinBase(targetPath: string, basePath: string): void;
14
+ /**
15
+ * Idempotently remove a git worktree rooted at `worktreePath` inside
16
+ * `repoRoot`. Delegates to the existing headless `removeWorktree` from
17
+ * `src/repo/git.ts`. Returns `{ removed: false }` (never throws) when the
18
+ * worktree path does not exist or git reports it is not a working tree.
19
+ */
20
+ export declare function teardownWorktree(repoRoot: string, worktreePath: string): Promise<TeardownResult>;
21
+ /**
22
+ * Idempotently remove a clone directory at `clonePath`, guarded by
23
+ * `assertWithinBase` against `runsBaseDir`. Skips silently if absent.
24
+ */
25
+ export declare function teardownClone(clonePath: string, runsBaseDir: string): TeardownResult;
26
+ /**
27
+ * Remove per-run agent-memory files and directories whose name contains the
28
+ * `correlationId` under `memoriesBase`. No-op if none match or the base does
29
+ * not exist.
30
+ */
31
+ export declare function teardownAgentMemories(correlationId: string, memoriesBase: string): TeardownResult;
32
+ /**
33
+ * Remove run-scoped plan/task artefact files under `plansDir` whose name
34
+ * encodes the `correlationId`. Never deletes the plans directory itself.
35
+ * Also removes a per-run subdirectory named after the correlationId if present.
36
+ */
37
+ export declare function teardownPlanArtefacts(correlationId: string, plansDir: string): TeardownResult;
38
+ //# sourceMappingURL=teardown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"teardown.d.ts","sourceRoot":"","sources":["../../../src/repo/teardown.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAID;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAmB3E;AAID;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,cAAc,CAAC,CAkBzB;AAID;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAClB,cAAc,CAiBhB;AAID;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,GACnB,cAAc,CAoChB;AAID;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,GACf,cAAc,CA8ChB"}