@mikode13/harness 4.0.1 → 5.0.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.
- package/README.md +278 -16
- package/dist/agent/domain/agent.d.ts +12 -0
- package/dist/agent/domain/agent.js.map +1 -1
- package/dist/agent/domain/approval.d.ts +9 -0
- package/dist/agent/domain/approval.js.map +1 -1
- package/dist/agent/domain/runContext.d.ts +31 -0
- package/dist/agent/domain/runContext.js +47 -0
- package/dist/agent/domain/runContext.js.map +1 -0
- package/dist/diff/domain/unifiedDiff.d.ts +19 -0
- package/dist/diff/domain/unifiedDiff.js +166 -0
- package/dist/diff/domain/unifiedDiff.js.map +1 -0
- package/dist/engines/domain/model/historyFollower.d.ts +41 -0
- package/dist/engines/domain/model/historyFollower.js +158 -0
- package/dist/engines/domain/model/historyFollower.js.map +1 -0
- package/dist/engines/domain/model/llmAgent.d.ts +42 -4
- package/dist/engines/domain/model/llmAgent.js +223 -23
- package/dist/engines/domain/model/llmAgent.js.map +1 -1
- package/dist/factory/infrastructure/agentFactory.d.ts +14 -0
- package/dist/factory/infrastructure/agentFactory.js +20 -2
- package/dist/factory/infrastructure/agentFactory.js.map +1 -1
- package/dist/factory/infrastructure/agentLLMFactory.d.ts +119 -14
- package/dist/factory/infrastructure/agentLLMFactory.js +284 -57
- package/dist/factory/infrastructure/agentLLMFactory.js.map +1 -1
- package/dist/index.d.ts +11 -3
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/llm/domain/conversation.d.ts +44 -4
- package/dist/llm/domain/conversation.js +56 -7
- package/dist/llm/domain/conversation.js.map +1 -1
- package/dist/llm/domain/llm.d.ts +3 -1
- package/dist/llm/domain/llm.js.map +1 -1
- package/dist/llm/domain/tool.d.ts +13 -0
- package/dist/llm/domain/tool.js +12 -1
- package/dist/llm/domain/tool.js.map +1 -1
- package/dist/llm/infrastructure/claudeLLMClient.d.ts +3 -2
- package/dist/llm/infrastructure/claudeLLMClient.js +38 -10
- package/dist/llm/infrastructure/claudeLLMClient.js.map +1 -1
- package/dist/llm/infrastructure/openAILLMClient.d.ts +2 -1
- package/dist/llm/infrastructure/openAILLMClient.js +66 -16
- package/dist/llm/infrastructure/openAILLMClient.js.map +1 -1
- package/dist/orchestration/domain/model/orchestratorAgent.d.ts +11 -2
- package/dist/orchestration/domain/model/orchestratorAgent.js +43 -4
- package/dist/orchestration/domain/model/orchestratorAgent.js.map +1 -1
- package/dist/recovery/domain/fileChanges.d.ts +31 -0
- package/dist/recovery/domain/fileChanges.js +48 -0
- package/dist/recovery/domain/fileChanges.js.map +1 -0
- package/dist/recovery/domain/history.d.ts +114 -0
- package/dist/recovery/domain/history.js +62 -0
- package/dist/recovery/domain/history.js.map +1 -0
- package/dist/recovery/domain/recoveryStore.d.ts +233 -0
- package/dist/recovery/domain/recoveryStore.js +32 -0
- package/dist/recovery/domain/recoveryStore.js.map +1 -0
- package/dist/recovery/domain/retention.d.ts +33 -0
- package/dist/recovery/domain/retention.js +90 -0
- package/dist/recovery/domain/retention.js.map +1 -0
- package/dist/recovery/domain/runChanges.d.ts +37 -0
- package/dist/recovery/domain/runChanges.js +109 -0
- package/dist/recovery/domain/runChanges.js.map +1 -0
- package/dist/recovery/domain/runTree.d.ts +32 -0
- package/dist/recovery/domain/runTree.js +90 -0
- package/dist/recovery/domain/runTree.js.map +1 -0
- package/dist/recovery/infrastructure/createHistory.d.ts +11 -0
- package/dist/recovery/infrastructure/createHistory.js +17 -0
- package/dist/recovery/infrastructure/createHistory.js.map +1 -0
- package/dist/recovery/infrastructure/fileRecoveryStore.d.ts +133 -0
- package/dist/recovery/infrastructure/fileRecoveryStore.js +1043 -0
- package/dist/recovery/infrastructure/fileRecoveryStore.js.map +1 -0
- package/dist/recovery/infrastructure/workspaceFiles.d.ts +30 -0
- package/dist/recovery/infrastructure/workspaceFiles.js +125 -0
- package/dist/recovery/infrastructure/workspaceFiles.js.map +1 -0
- package/dist/tools/domain/accessPolicy.d.ts +30 -0
- package/dist/tools/domain/accessPolicy.js +11 -0
- package/dist/tools/domain/accessPolicy.js.map +1 -0
- package/dist/tools/domain/commands.d.ts +93 -0
- package/dist/tools/domain/commands.js +191 -0
- package/dist/tools/domain/commands.js.map +1 -0
- package/dist/tools/domain/editResponse.d.ts +14 -0
- package/dist/tools/domain/editResponse.js +79 -0
- package/dist/tools/domain/editResponse.js.map +1 -0
- package/dist/tools/domain/fileEdits.d.ts +64 -0
- package/dist/tools/domain/fileEdits.js +21 -0
- package/dist/tools/domain/fileEdits.js.map +1 -0
- package/dist/tools/domain/lineLength.d.ts +7 -0
- package/dist/tools/domain/lineLength.js +26 -0
- package/dist/tools/domain/lineLength.js.map +1 -0
- package/dist/tools/domain/preparedCall.d.ts +31 -0
- package/dist/tools/domain/preparedCall.js +14 -0
- package/dist/tools/domain/preparedCall.js.map +1 -0
- package/dist/tools/domain/readRegistry.d.ts +46 -0
- package/dist/tools/domain/readRegistry.js +62 -0
- package/dist/tools/domain/readRegistry.js.map +1 -0
- package/dist/tools/domain/textLines.d.ts +26 -0
- package/dist/tools/domain/textLines.js +44 -0
- package/dist/tools/domain/textLines.js.map +1 -0
- package/dist/tools/domain/v4aPatch.d.ts +17 -0
- package/dist/tools/domain/v4aPatch.js +236 -0
- package/dist/tools/domain/v4aPatch.js.map +1 -0
- package/dist/tools/infrastructure/boundedWorkspace.d.ts +11 -2
- package/dist/tools/infrastructure/boundedWorkspace.js +9 -1
- package/dist/tools/infrastructure/boundedWorkspace.js.map +1 -1
- package/dist/tools/infrastructure/commandCheckpoint.d.ts +55 -0
- package/dist/tools/infrastructure/commandCheckpoint.js +178 -0
- package/dist/tools/infrastructure/commandCheckpoint.js.map +1 -0
- package/dist/tools/infrastructure/commandProcess.d.ts +47 -0
- package/dist/tools/infrastructure/commandProcess.js +217 -0
- package/dist/tools/infrastructure/commandProcess.js.map +1 -0
- package/dist/tools/infrastructure/commandTool.d.ts +36 -0
- package/dist/tools/infrastructure/commandTool.js +254 -0
- package/dist/tools/infrastructure/commandTool.js.map +1 -0
- package/dist/tools/infrastructure/createWorkspace.d.ts +10 -0
- package/dist/tools/infrastructure/createWorkspace.js +11 -3
- package/dist/tools/infrastructure/createWorkspace.js.map +1 -1
- package/dist/tools/infrastructure/defineTool.d.ts +14 -0
- package/dist/tools/infrastructure/defineTool.js +28 -5
- package/dist/tools/infrastructure/defineTool.js.map +1 -1
- package/dist/tools/infrastructure/editFormats.d.ts +22 -0
- package/dist/tools/infrastructure/editFormats.js +211 -0
- package/dist/tools/infrastructure/editFormats.js.map +1 -0
- package/dist/tools/infrastructure/fileEditor.d.ts +64 -0
- package/dist/tools/infrastructure/fileEditor.js +306 -0
- package/dist/tools/infrastructure/fileEditor.js.map +1 -0
- package/dist/tools/infrastructure/fileTools.d.ts +81 -0
- package/dist/tools/infrastructure/fileTools.js +152 -0
- package/dist/tools/infrastructure/fileTools.js.map +1 -0
- package/dist/tools/infrastructure/gitIgnoreRules.d.ts +15 -0
- package/dist/tools/infrastructure/gitIgnoreRules.js +74 -0
- package/dist/tools/infrastructure/gitIgnoreRules.js.map +1 -0
- package/dist/tools/infrastructure/gitWorkspace.d.ts +1 -1
- package/dist/tools/infrastructure/gitWorkspace.js +1 -1
- package/dist/tools/infrastructure/gitWorkspace.js.map +1 -1
- package/dist/tools/infrastructure/ignoreFileChanges.d.ts +14 -0
- package/dist/tools/infrastructure/ignoreFileChanges.js +62 -0
- package/dist/tools/infrastructure/ignoreFileChanges.js.map +1 -0
- package/dist/tools/infrastructure/policyWorkspace.d.ts +52 -0
- package/dist/tools/infrastructure/policyWorkspace.js +32 -0
- package/dist/tools/infrastructure/policyWorkspace.js.map +1 -0
- package/dist/tools/infrastructure/ripgrepWorkspace.d.ts +2 -1
- package/dist/tools/infrastructure/ripgrepWorkspace.js +1 -1
- package/dist/tools/infrastructure/ripgrepWorkspace.js.map +1 -1
- package/dist/tools/infrastructure/rootsAccessPolicy.d.ts +100 -0
- package/dist/tools/infrastructure/rootsAccessPolicy.js +301 -0
- package/dist/tools/infrastructure/rootsAccessPolicy.js.map +1 -0
- package/dist/tools/infrastructure/runProcess.d.ts +4 -1
- package/dist/tools/infrastructure/runProcess.js +4 -2
- package/dist/tools/infrastructure/runProcess.js.map +1 -1
- package/dist/tools/infrastructure/secretPaths.d.ts +8 -0
- package/dist/tools/infrastructure/secretPaths.js +76 -0
- package/dist/tools/infrastructure/secretPaths.js.map +1 -0
- package/dist/tools/infrastructure/showChangesTool.d.ts +12 -0
- package/dist/tools/infrastructure/showChangesTool.js +43 -0
- package/dist/tools/infrastructure/showChangesTool.js.map +1 -0
- package/dist/tools/infrastructure/trackedEdits.d.ts +33 -0
- package/dist/tools/infrastructure/trackedEdits.js +70 -0
- package/dist/tools/infrastructure/trackedEdits.js.map +1 -0
- package/dist/tools/infrastructure/trackedReadFile.d.ts +21 -0
- package/dist/tools/infrastructure/trackedReadFile.js +78 -0
- package/dist/tools/infrastructure/trackedReadFile.js.map +1 -0
- package/dist/tools/infrastructure/workspaceTools.d.ts +28 -0
- package/dist/tools/infrastructure/workspaceTools.js +53 -40
- package/dist/tools/infrastructure/workspaceTools.js.map +1 -1
- package/dist/tools/infrastructure/workspaceWrites.d.ts +23 -0
- package/dist/tools/infrastructure/workspaceWrites.js +42 -0
- package/dist/tools/infrastructure/workspaceWrites.js.map +1 -0
- package/dist/tools/infrastructure/writeSession.d.ts +35 -0
- package/dist/tools/infrastructure/writeSession.js +81 -0
- package/dist/tools/infrastructure/writeSession.js.map +1 -0
- 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
|
+
}
|