@mikode13/harness 4.0.1 → 5.1.0

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 (170) hide show
  1. package/README.md +299 -17
  2. package/dist/agent/domain/agent.d.ts +32 -1
  3. package/dist/agent/domain/agent.js.map +1 -1
  4. package/dist/agent/domain/approval.d.ts +9 -0
  5. package/dist/agent/domain/approval.js.map +1 -1
  6. package/dist/agent/domain/runContext.d.ts +31 -0
  7. package/dist/agent/domain/runContext.js +47 -0
  8. package/dist/agent/domain/runContext.js.map +1 -0
  9. package/dist/diff/domain/unifiedDiff.d.ts +19 -0
  10. package/dist/diff/domain/unifiedDiff.js +166 -0
  11. package/dist/diff/domain/unifiedDiff.js.map +1 -0
  12. package/dist/engines/domain/model/historyFollower.d.ts +41 -0
  13. package/dist/engines/domain/model/historyFollower.js +158 -0
  14. package/dist/engines/domain/model/historyFollower.js.map +1 -0
  15. package/dist/engines/domain/model/llmAgent.d.ts +42 -4
  16. package/dist/engines/domain/model/llmAgent.js +287 -31
  17. package/dist/engines/domain/model/llmAgent.js.map +1 -1
  18. package/dist/factory/infrastructure/agentFactory.d.ts +14 -0
  19. package/dist/factory/infrastructure/agentFactory.js +20 -2
  20. package/dist/factory/infrastructure/agentFactory.js.map +1 -1
  21. package/dist/factory/infrastructure/agentLLMFactory.d.ts +119 -14
  22. package/dist/factory/infrastructure/agentLLMFactory.js +284 -57
  23. package/dist/factory/infrastructure/agentLLMFactory.js.map +1 -1
  24. package/dist/index.d.ts +13 -5
  25. package/dist/index.js +5 -2
  26. package/dist/index.js.map +1 -1
  27. package/dist/llm/domain/conversation.d.ts +44 -4
  28. package/dist/llm/domain/conversation.js +56 -7
  29. package/dist/llm/domain/conversation.js.map +1 -1
  30. package/dist/llm/domain/llm.d.ts +3 -1
  31. package/dist/llm/domain/llm.js.map +1 -1
  32. package/dist/llm/domain/tool.d.ts +13 -0
  33. package/dist/llm/domain/tool.js +12 -1
  34. package/dist/llm/domain/tool.js.map +1 -1
  35. package/dist/llm/infrastructure/claudeLLMClient.d.ts +3 -2
  36. package/dist/llm/infrastructure/claudeLLMClient.js +38 -10
  37. package/dist/llm/infrastructure/claudeLLMClient.js.map +1 -1
  38. package/dist/llm/infrastructure/openAILLMClient.d.ts +2 -1
  39. package/dist/llm/infrastructure/openAILLMClient.js +67 -17
  40. package/dist/llm/infrastructure/openAILLMClient.js.map +1 -1
  41. package/dist/orchestration/domain/model/orchestratorAgent.d.ts +17 -3
  42. package/dist/orchestration/domain/model/orchestratorAgent.js +65 -8
  43. package/dist/orchestration/domain/model/orchestratorAgent.js.map +1 -1
  44. package/dist/recovery/domain/fileChanges.d.ts +31 -0
  45. package/dist/recovery/domain/fileChanges.js +48 -0
  46. package/dist/recovery/domain/fileChanges.js.map +1 -0
  47. package/dist/recovery/domain/history.d.ts +114 -0
  48. package/dist/recovery/domain/history.js +62 -0
  49. package/dist/recovery/domain/history.js.map +1 -0
  50. package/dist/recovery/domain/recoveryStore.d.ts +233 -0
  51. package/dist/recovery/domain/recoveryStore.js +32 -0
  52. package/dist/recovery/domain/recoveryStore.js.map +1 -0
  53. package/dist/recovery/domain/retention.d.ts +33 -0
  54. package/dist/recovery/domain/retention.js +90 -0
  55. package/dist/recovery/domain/retention.js.map +1 -0
  56. package/dist/recovery/domain/runChanges.d.ts +37 -0
  57. package/dist/recovery/domain/runChanges.js +109 -0
  58. package/dist/recovery/domain/runChanges.js.map +1 -0
  59. package/dist/recovery/domain/runTree.d.ts +32 -0
  60. package/dist/recovery/domain/runTree.js +90 -0
  61. package/dist/recovery/domain/runTree.js.map +1 -0
  62. package/dist/recovery/infrastructure/createHistory.d.ts +11 -0
  63. package/dist/recovery/infrastructure/createHistory.js +17 -0
  64. package/dist/recovery/infrastructure/createHistory.js.map +1 -0
  65. package/dist/recovery/infrastructure/fileRecoveryStore.d.ts +133 -0
  66. package/dist/recovery/infrastructure/fileRecoveryStore.js +1043 -0
  67. package/dist/recovery/infrastructure/fileRecoveryStore.js.map +1 -0
  68. package/dist/recovery/infrastructure/workspaceFiles.d.ts +30 -0
  69. package/dist/recovery/infrastructure/workspaceFiles.js +125 -0
  70. package/dist/recovery/infrastructure/workspaceFiles.js.map +1 -0
  71. package/dist/tools/domain/accessPolicy.d.ts +30 -0
  72. package/dist/tools/domain/accessPolicy.js +11 -0
  73. package/dist/tools/domain/accessPolicy.js.map +1 -0
  74. package/dist/tools/domain/commands.d.ts +93 -0
  75. package/dist/tools/domain/commands.js +191 -0
  76. package/dist/tools/domain/commands.js.map +1 -0
  77. package/dist/tools/domain/editResponse.d.ts +14 -0
  78. package/dist/tools/domain/editResponse.js +79 -0
  79. package/dist/tools/domain/editResponse.js.map +1 -0
  80. package/dist/tools/domain/fileEdits.d.ts +64 -0
  81. package/dist/tools/domain/fileEdits.js +21 -0
  82. package/dist/tools/domain/fileEdits.js.map +1 -0
  83. package/dist/tools/domain/lineLength.d.ts +7 -0
  84. package/dist/tools/domain/lineLength.js +26 -0
  85. package/dist/tools/domain/lineLength.js.map +1 -0
  86. package/dist/tools/domain/preparedCall.d.ts +44 -0
  87. package/dist/tools/domain/preparedCall.js +26 -0
  88. package/dist/tools/domain/preparedCall.js.map +1 -0
  89. package/dist/tools/domain/readRegistry.d.ts +46 -0
  90. package/dist/tools/domain/readRegistry.js +62 -0
  91. package/dist/tools/domain/readRegistry.js.map +1 -0
  92. package/dist/tools/domain/textLines.d.ts +26 -0
  93. package/dist/tools/domain/textLines.js +44 -0
  94. package/dist/tools/domain/textLines.js.map +1 -0
  95. package/dist/tools/domain/tool.d.ts +14 -0
  96. package/dist/tools/domain/tool.js +7 -1
  97. package/dist/tools/domain/tool.js.map +1 -1
  98. package/dist/tools/domain/v4aPatch.d.ts +17 -0
  99. package/dist/tools/domain/v4aPatch.js +236 -0
  100. package/dist/tools/domain/v4aPatch.js.map +1 -0
  101. package/dist/tools/infrastructure/boundedWorkspace.d.ts +11 -2
  102. package/dist/tools/infrastructure/boundedWorkspace.js +9 -1
  103. package/dist/tools/infrastructure/boundedWorkspace.js.map +1 -1
  104. package/dist/tools/infrastructure/commandCheckpoint.d.ts +55 -0
  105. package/dist/tools/infrastructure/commandCheckpoint.js +178 -0
  106. package/dist/tools/infrastructure/commandCheckpoint.js.map +1 -0
  107. package/dist/tools/infrastructure/commandProcess.d.ts +47 -0
  108. package/dist/tools/infrastructure/commandProcess.js +217 -0
  109. package/dist/tools/infrastructure/commandProcess.js.map +1 -0
  110. package/dist/tools/infrastructure/commandTool.d.ts +36 -0
  111. package/dist/tools/infrastructure/commandTool.js +285 -0
  112. package/dist/tools/infrastructure/commandTool.js.map +1 -0
  113. package/dist/tools/infrastructure/createWorkspace.d.ts +10 -0
  114. package/dist/tools/infrastructure/createWorkspace.js +11 -3
  115. package/dist/tools/infrastructure/createWorkspace.js.map +1 -1
  116. package/dist/tools/infrastructure/defineTool.d.ts +18 -2
  117. package/dist/tools/infrastructure/defineTool.js +52 -6
  118. package/dist/tools/infrastructure/defineTool.js.map +1 -1
  119. package/dist/tools/infrastructure/editFormats.d.ts +22 -0
  120. package/dist/tools/infrastructure/editFormats.js +243 -0
  121. package/dist/tools/infrastructure/editFormats.js.map +1 -0
  122. package/dist/tools/infrastructure/fileEditor.d.ts +64 -0
  123. package/dist/tools/infrastructure/fileEditor.js +306 -0
  124. package/dist/tools/infrastructure/fileEditor.js.map +1 -0
  125. package/dist/tools/infrastructure/fileTools.d.ts +81 -0
  126. package/dist/tools/infrastructure/fileTools.js +152 -0
  127. package/dist/tools/infrastructure/fileTools.js.map +1 -0
  128. package/dist/tools/infrastructure/gitIgnoreRules.d.ts +15 -0
  129. package/dist/tools/infrastructure/gitIgnoreRules.js +74 -0
  130. package/dist/tools/infrastructure/gitIgnoreRules.js.map +1 -0
  131. package/dist/tools/infrastructure/gitWorkspace.d.ts +1 -1
  132. package/dist/tools/infrastructure/gitWorkspace.js +1 -1
  133. package/dist/tools/infrastructure/gitWorkspace.js.map +1 -1
  134. package/dist/tools/infrastructure/ignoreFileChanges.d.ts +14 -0
  135. package/dist/tools/infrastructure/ignoreFileChanges.js +62 -0
  136. package/dist/tools/infrastructure/ignoreFileChanges.js.map +1 -0
  137. package/dist/tools/infrastructure/policyWorkspace.d.ts +52 -0
  138. package/dist/tools/infrastructure/policyWorkspace.js +32 -0
  139. package/dist/tools/infrastructure/policyWorkspace.js.map +1 -0
  140. package/dist/tools/infrastructure/ripgrepWorkspace.d.ts +2 -1
  141. package/dist/tools/infrastructure/ripgrepWorkspace.js +1 -1
  142. package/dist/tools/infrastructure/ripgrepWorkspace.js.map +1 -1
  143. package/dist/tools/infrastructure/rootsAccessPolicy.d.ts +100 -0
  144. package/dist/tools/infrastructure/rootsAccessPolicy.js +301 -0
  145. package/dist/tools/infrastructure/rootsAccessPolicy.js.map +1 -0
  146. package/dist/tools/infrastructure/runProcess.d.ts +4 -1
  147. package/dist/tools/infrastructure/runProcess.js +4 -2
  148. package/dist/tools/infrastructure/runProcess.js.map +1 -1
  149. package/dist/tools/infrastructure/secretPaths.d.ts +8 -0
  150. package/dist/tools/infrastructure/secretPaths.js +76 -0
  151. package/dist/tools/infrastructure/secretPaths.js.map +1 -0
  152. package/dist/tools/infrastructure/showChangesTool.d.ts +12 -0
  153. package/dist/tools/infrastructure/showChangesTool.js +44 -0
  154. package/dist/tools/infrastructure/showChangesTool.js.map +1 -0
  155. package/dist/tools/infrastructure/trackedEdits.d.ts +33 -0
  156. package/dist/tools/infrastructure/trackedEdits.js +70 -0
  157. package/dist/tools/infrastructure/trackedEdits.js.map +1 -0
  158. package/dist/tools/infrastructure/trackedReadFile.d.ts +21 -0
  159. package/dist/tools/infrastructure/trackedReadFile.js +79 -0
  160. package/dist/tools/infrastructure/trackedReadFile.js.map +1 -0
  161. package/dist/tools/infrastructure/workspaceTools.d.ts +34 -0
  162. package/dist/tools/infrastructure/workspaceTools.js +69 -40
  163. package/dist/tools/infrastructure/workspaceTools.js.map +1 -1
  164. package/dist/tools/infrastructure/workspaceWrites.d.ts +23 -0
  165. package/dist/tools/infrastructure/workspaceWrites.js +42 -0
  166. package/dist/tools/infrastructure/workspaceWrites.js.map +1 -0
  167. package/dist/tools/infrastructure/writeSession.d.ts +35 -0
  168. package/dist/tools/infrastructure/writeSession.js +81 -0
  169. package/dist/tools/infrastructure/writeSession.js.map +1 -0
  170. package/package.json +1 -1
@@ -0,0 +1,133 @@
1
+ import { type JournalEntry, type MoveOptions, type Revision, type RecoveryStore, type RunJournal, type RunRecord } from '../domain/recoveryStore.ts';
2
+ /** Where an application keeps state that is neither configuration nor cache, per platform. */
3
+ export declare function defaultStateDirectory(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform, home?: string): string;
4
+ /**
5
+ * The recovery store on disk, in a private directory per workspace under the platform's state
6
+ * directory:
7
+ *
8
+ * ```text
9
+ * <directory>/workspaces/<hash of the root>/
10
+ * workspace.json the root it belongs to
11
+ * lock the run writing now, if any
12
+ * head.json the run the workspace is at, and a move in progress
13
+ * revisions.jsonl every move of the workspace through its history
14
+ * content/<ab>/<hash> file contents, named by their SHA-256
15
+ * runs/<runId>/run.json the run's record
16
+ * runs/<runId>/journal.jsonl its changes, one line per step, appended and synced
17
+ * ```
18
+ *
19
+ * The lock only keeps a second run of this harness from writing at the same time. It does not
20
+ * stop an editor or another program, and two processes taking over a dead run's lock in the
21
+ * same instant could both believe they hold it.
22
+ */
23
+ export declare class FileRecoveryStore implements RecoveryStore {
24
+ private readonly root;
25
+ private readonly directory;
26
+ private readonly keepRuns;
27
+ private constructor();
28
+ static open({ root, directory, keepRuns, }: {
29
+ root: string;
30
+ /** Defaults to the platform's state directory. */
31
+ directory?: string;
32
+ /**
33
+ * The most runs kept per workspace, the one being recorded included. Defaults to 25. At
34
+ * least 3: the run the workspace is at is never removed, and the last run of its line has
35
+ * no next run to be chained into, so pruning can leave two runs besides the new one.
36
+ */
37
+ keepRuns?: number;
38
+ }): Promise<FileRecoveryStore>;
39
+ startRun(): Promise<RunJournal>;
40
+ listRuns(): Promise<{
41
+ head?: string;
42
+ runs: RunRecord[];
43
+ }>;
44
+ readRun(runId: string): Promise<{
45
+ record: RunRecord;
46
+ entries: JournalEntry[];
47
+ }>;
48
+ private readRecord;
49
+ private runDirectory;
50
+ private readHead;
51
+ private writeHead;
52
+ goTo(target: string, options?: MoveOptions): Promise<Revision>;
53
+ undo(options?: MoveOptions): Promise<Revision>;
54
+ redo(options?: MoveOptions): Promise<Revision>;
55
+ listRevisions(): Promise<Revision[]>;
56
+ /** Holds the workspace like a run does, then moves it to the run `resolve` picks. */
57
+ private move;
58
+ /** Finishes a move whose process stopped halfway, from the run its last step reached. */
59
+ private finishPendingMove;
60
+ /**
61
+ * Undoes, then redoes, one run at a time from where the head is to `pending.to`. After each
62
+ * step the head names the run reached, with the move still pending, so a crash loses at
63
+ * most the step in progress, and that step is safe to take again.
64
+ */
65
+ private takeSteps;
66
+ /** Takes one run's changes back to its parent, or forward again, file by file. */
67
+ private step;
68
+ /**
69
+ * Writes the state the step leads to, only if the file holds the state it leaves. A file
70
+ * already there is left alone, so taking a step again is safe. Returns whether the file
71
+ * ends where the step leads.
72
+ */
73
+ private moveFile;
74
+ /** Throws `HistoryExpiredError` if retention removed `runId` or chained it into a later run. */
75
+ private assertNotAbsorbed;
76
+ private listPruned;
77
+ /**
78
+ * Brings the history down to `keepRuns - 1`, so the run about to start makes `keepRuns`, then
79
+ * frees the contents no run kept refers to.
80
+ */
81
+ private prune;
82
+ /**
83
+ * Chains the changes of `older` into `newer`, its child: `newer` then hangs from `older`'s
84
+ * parent and goes back to where `older` started. The new record is the commit point. Before
85
+ * it, the history is as it was; after it, `finishChains` removes what is left of `older`.
86
+ */
87
+ private chain;
88
+ /**
89
+ * Removes what a chain or a removal a crash interrupted left behind: the folders of runs
90
+ * pruned or absorbed by a kept run, and journals a run no longer reads.
91
+ */
92
+ private finishChains;
93
+ /**
94
+ * Removes a run whole, recording its id first so a move to it reports an expired history.
95
+ * Its record goes next, so a crash halfway leaves no run behind.
96
+ */
97
+ private removeRun;
98
+ /**
99
+ * Takes a run that changed nothing out of the history, under the lock: the workspace goes back
100
+ * to its parent first, so the head never names a run that is gone. Until the run is removed,
101
+ * `listRuns` already hides it, and the next run or move finishes removing it. The contents it
102
+ * saved are freed by the next prune.
103
+ */
104
+ private discardRun;
105
+ /** Removes the stored contents no kept run refers to. */
106
+ private collectContent;
107
+ private appendRevision;
108
+ /**
109
+ * Marks every other run still recorded as `running` as `interrupted`: this run holds the lock,
110
+ * so their processes are gone. Each change one left `prepared` is settled from what its file
111
+ * holds now: its `after` means it was made, its `before` that it was not. A file that holds
112
+ * neither stays `prepared`, because nothing tells whether the change reached it.
113
+ */
114
+ private settleInterrupted;
115
+ /**
116
+ * The lines that record what a command an interrupted run was observing changed: every file of
117
+ * its manifest that holds something else now, as changed by that command, and then the end of
118
+ * the observation. A file recorded after the observation began is left alone: the run
119
+ * recorded it itself. One that is now a folder, a link or too large to record is left out.
120
+ */
121
+ private settleObservation;
122
+ /** What `path` holds now, with its content stored, or `undefined` for what no entry records. */
123
+ private saveState;
124
+ private readEntries;
125
+ /**
126
+ * A run's changes, the observations it began and never finished, and the highest sequence
127
+ * number its journal uses, which the next line it gets must exceed.
128
+ */
129
+ private readJournal;
130
+ readContent(hash: string): Promise<Buffer>;
131
+ private lock;
132
+ private unlock;
133
+ }