@manyoars/oars 0.2.0 → 0.3.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 +132 -28
- package/dist/api.js +1 -1
- package/dist/bin.js +6 -29
- package/dist/cli.d.ts +6 -3
- package/dist/cli.js +367 -88
- package/dist/commands/keys.d.ts +31 -0
- package/dist/commands/keys.js +65 -0
- package/dist/commands/login.js +2 -2
- package/dist/errors.d.ts +13 -13
- package/dist/errors.js +28 -11
- package/dist/gate/checks.d.ts +68 -0
- package/dist/gate/checks.js +584 -0
- package/dist/gate/command.d.ts +14 -0
- package/dist/gate/command.js +61 -0
- package/dist/gate/hook-fill-main.d.ts +1 -0
- package/dist/gate/hook-fill-main.js +16 -0
- package/dist/gate/hook-fill.d.ts +38 -0
- package/dist/gate/hook-fill.js +94 -0
- package/dist/gate/hook-main.d.ts +1 -0
- package/dist/gate/hook-main.js +35 -0
- package/dist/gate/hook-process.d.ts +14 -0
- package/dist/gate/hook-process.js +64 -0
- package/dist/gate/hook.d.ts +46 -0
- package/dist/gate/hook.js +256 -0
- package/dist/gate/install.d.ts +25 -0
- package/dist/gate/install.js +126 -0
- package/dist/gate/local-bin.d.ts +8 -0
- package/dist/gate/local-bin.js +36 -0
- package/dist/gate/notes.d.ts +19 -0
- package/dist/gate/notes.js +27 -0
- package/dist/gate/novelty.d.ts +35 -0
- package/dist/gate/novelty.js +99 -0
- package/dist/gate/policy.d.ts +25 -0
- package/dist/gate/policy.js +73 -0
- package/dist/gate/record.d.ts +120 -0
- package/dist/gate/record.js +125 -0
- package/dist/gate/registry-state.d.ts +10 -0
- package/dist/gate/registry-state.js +30 -0
- package/dist/gate/registry.d.ts +56 -0
- package/dist/gate/registry.js +94 -0
- package/dist/gate/replay.d.ts +20 -0
- package/dist/gate/replay.js +257 -0
- package/dist/gate/report.d.ts +50 -0
- package/dist/gate/report.js +89 -0
- package/dist/gate/scope.d.ts +7 -0
- package/dist/gate/scope.js +27 -0
- package/dist/gate/transcripts.d.ts +68 -0
- package/dist/gate/transcripts.js +232 -0
- package/dist/hook-bin.d.ts +1 -0
- package/dist/hook-bin.js +25 -0
- package/dist/issuer.d.ts +7 -1
- package/dist/issuer.js +18 -1
- package/dist/main.d.ts +1 -0
- package/dist/main.js +64 -0
- package/dist/oidc.js +1 -1
- package/dist/sessions/actions.d.ts +35 -0
- package/dist/sessions/actions.js +351 -0
- package/dist/sessions/allow.d.ts +14 -0
- package/dist/sessions/allow.js +51 -0
- package/dist/sessions/archive.d.ts +11 -0
- package/dist/sessions/archive.js +38 -0
- package/dist/sessions/audit.d.ts +42 -0
- package/dist/sessions/audit.js +104 -0
- package/dist/sessions/baseline.d.ts +62 -0
- package/dist/sessions/baseline.js +188 -0
- package/dist/sessions/capture-runtime.d.ts +10 -0
- package/dist/sessions/capture-runtime.js +12 -0
- package/dist/sessions/cell-increments.d.ts +43 -0
- package/dist/sessions/cell-increments.js +209 -0
- package/dist/sessions/cells.d.ts +79 -0
- package/dist/sessions/cells.js +181 -0
- package/dist/sessions/codex.d.ts +53 -0
- package/dist/sessions/codex.js +679 -0
- package/dist/sessions/command.d.ts +117 -0
- package/dist/sessions/command.js +373 -0
- package/dist/sessions/copilot.d.ts +40 -0
- package/dist/sessions/copilot.js +432 -0
- package/dist/sessions/cursor.d.ts +24 -0
- package/dist/sessions/cursor.js +324 -0
- package/dist/sessions/derive.d.ts +57 -0
- package/dist/sessions/derive.js +320 -0
- package/dist/sessions/exclusion.d.ts +81 -0
- package/dist/sessions/exclusion.js +353 -0
- package/dist/sessions/extract.d.ts +179 -0
- package/dist/sessions/extract.js +1774 -0
- package/dist/sessions/fold.d.ts +17 -0
- package/dist/sessions/fold.js +71 -0
- package/dist/sessions/frame.d.ts +24 -0
- package/dist/sessions/frame.js +95 -0
- package/dist/sessions/gemini.d.ts +37 -0
- package/dist/sessions/gemini.js +613 -0
- package/dist/sessions/gold-arms.d.ts +67 -0
- package/dist/sessions/gold-arms.js +172 -0
- package/dist/sessions/gold.d.ts +197 -0
- package/dist/sessions/gold.js +463 -0
- package/dist/sessions/graph.d.ts +12 -0
- package/dist/sessions/graph.js +34 -0
- package/dist/sessions/grok.d.ts +36 -0
- package/dist/sessions/grok.js +421 -0
- package/dist/sessions/hook-calls.d.ts +3 -0
- package/dist/sessions/hook-calls.js +47 -0
- package/dist/sessions/hook-index.d.ts +53 -0
- package/dist/sessions/hook-index.js +157 -0
- package/dist/sessions/hooks.d.ts +13 -0
- package/dist/sessions/hooks.js +170 -0
- package/dist/sessions/identity.d.ts +22 -0
- package/dist/sessions/identity.js +101 -0
- package/dist/sessions/install.d.ts +54 -0
- package/dist/sessions/install.js +201 -0
- package/dist/sessions/lineage.d.ts +19 -0
- package/dist/sessions/lineage.js +118 -0
- package/dist/sessions/mcp.d.ts +6 -0
- package/dist/sessions/mcp.js +153 -0
- package/dist/sessions/merkle.d.ts +7 -0
- package/dist/sessions/merkle.js +28 -0
- package/dist/sessions/motif.d.ts +43 -0
- package/dist/sessions/motif.js +59 -0
- package/dist/sessions/package-resolve.d.ts +30 -0
- package/dist/sessions/package-resolve.js +183 -0
- package/dist/sessions/pending.d.ts +34 -0
- package/dist/sessions/pending.js +142 -0
- package/dist/sessions/pool-command.d.ts +44 -0
- package/dist/sessions/pool-command.js +542 -0
- package/dist/sessions/pool-delta.d.ts +54 -0
- package/dist/sessions/pool-delta.js +190 -0
- package/dist/sessions/pool-outbox.d.ts +63 -0
- package/dist/sessions/pool-outbox.js +260 -0
- package/dist/sessions/pool-print.d.ts +26 -0
- package/dist/sessions/pool-print.js +68 -0
- package/dist/sessions/pool-wire.d.ts +225 -0
- package/dist/sessions/pool-wire.js +620 -0
- package/dist/sessions/pool.d.ts +32 -0
- package/dist/sessions/pool.js +164 -0
- package/dist/sessions/projection.d.ts +75 -0
- package/dist/sessions/projection.js +165 -0
- package/dist/sessions/public-vocabulary.d.ts +73 -0
- package/dist/sessions/public-vocabulary.js +302 -0
- package/dist/sessions/query.d.ts +111 -0
- package/dist/sessions/query.js +246 -0
- package/dist/sessions/read-adoption.d.ts +2 -0
- package/dist/sessions/read-adoption.js +27 -0
- package/dist/sessions/read-call-shape.d.ts +2 -0
- package/dist/sessions/read-call-shape.js +25 -0
- package/dist/sessions/read-change.d.ts +2 -0
- package/dist/sessions/read-change.js +30 -0
- package/dist/sessions/read-cost.d.ts +4 -0
- package/dist/sessions/read-cost.js +37 -0
- package/dist/sessions/read-day-move.d.ts +3 -0
- package/dist/sessions/read-day-move.js +65 -0
- package/dist/sessions/read-fit.d.ts +7 -0
- package/dist/sessions/read-fit.js +41 -0
- package/dist/sessions/read-interaction.d.ts +5 -0
- package/dist/sessions/read-interaction.js +62 -0
- package/dist/sessions/read-lead-lag.d.ts +15 -0
- package/dist/sessions/read-lead-lag.js +81 -0
- package/dist/sessions/read-live.d.ts +6 -0
- package/dist/sessions/read-live.js +38 -0
- package/dist/sessions/read-method.d.ts +2 -0
- package/dist/sessions/read-method.js +29 -0
- package/dist/sessions/read-next-step.d.ts +2 -0
- package/dist/sessions/read-next-step.js +35 -0
- package/dist/sessions/read-order.d.ts +54 -0
- package/dist/sessions/read-order.js +62 -0
- package/dist/sessions/read-readable.d.ts +8 -0
- package/dist/sessions/read-readable.js +24 -0
- package/dist/sessions/read-recovery.d.ts +20 -0
- package/dist/sessions/read-recovery.js +97 -0
- package/dist/sessions/read-rows.d.ts +13 -0
- package/dist/sessions/read-rows.js +47 -0
- package/dist/sessions/read-substitution.d.ts +5 -0
- package/dist/sessions/read-substitution.js +51 -0
- package/dist/sessions/read-support.d.ts +48 -0
- package/dist/sessions/read-support.js +73 -0
- package/dist/sessions/read-tool-day.d.ts +2 -0
- package/dist/sessions/read-tool-day.js +26 -0
- package/dist/sessions/read-version-boundary.d.ts +31 -0
- package/dist/sessions/read-version-boundary.js +95 -0
- package/dist/sessions/read.d.ts +79 -0
- package/dist/sessions/read.js +84 -0
- package/dist/sessions/recall-consequence.d.ts +45 -0
- package/dist/sessions/recall-consequence.js +179 -0
- package/dist/sessions/recall-object.d.ts +137 -0
- package/dist/sessions/recall-object.js +77 -0
- package/dist/sessions/recall-pool.d.ts +19 -0
- package/dist/sessions/recall-pool.js +96 -0
- package/dist/sessions/recall-push.d.ts +26 -0
- package/dist/sessions/recall-push.js +95 -0
- package/dist/sessions/recall-reads.d.ts +117 -0
- package/dist/sessions/recall-reads.js +410 -0
- package/dist/sessions/recall-render.d.ts +19 -0
- package/dist/sessions/recall-render.js +168 -0
- package/dist/sessions/redact.d.ts +6 -0
- package/dist/sessions/redact.js +54 -0
- package/dist/sessions/repo-root.d.ts +10 -0
- package/dist/sessions/repo-root.js +101 -0
- package/dist/sessions/schema.d.ts +644 -0
- package/dist/sessions/schema.js +148 -0
- package/dist/sessions/session-shape.d.ts +73 -0
- package/dist/sessions/session-shape.js +342 -0
- package/dist/sessions/sources.d.ts +50 -0
- package/dist/sessions/sources.js +159 -0
- package/dist/sessions/steps.d.ts +105 -0
- package/dist/sessions/steps.js +250 -0
- package/dist/sessions/store.d.ts +297 -0
- package/dist/sessions/store.js +1478 -0
- package/dist/sessions/strata.d.ts +26 -0
- package/dist/sessions/strata.js +77 -0
- package/dist/sessions/survival.d.ts +25 -0
- package/dist/sessions/survival.js +230 -0
- package/dist/sessions/verify.d.ts +53 -0
- package/dist/sessions/verify.js +286 -0
- package/dist/sessions/vocab-load.d.ts +26 -0
- package/dist/sessions/vocab-load.js +61 -0
- package/dist/sessions/vscode-copilot.d.ts +38 -0
- package/dist/sessions/vscode-copilot.js +477 -0
- package/package.json +4 -5
- package/vocab/crates.json +1 -0
- package/vocab/go.json +1 -0
- package/vocab/harness.json +1 -0
- package/vocab/homebrew.json +1 -0
- package/vocab/manifest.json +1 -0
- package/vocab/maven.json +1 -0
- package/vocab/models.json +1 -0
- package/vocab/npm.json +1 -0
- package/vocab/programs.json +1 -0
- package/vocab/pypi.json +1 -0
- package/vocab/rubygems.json +1 -0
- package/dist/commands/deploy-input.d.ts +0 -38
- package/dist/commands/deploy-input.js +0 -150
- package/dist/commands/deploy.d.ts +0 -22
- package/dist/commands/deploy.js +0 -124
- package/dist/commands/status.d.ts +0 -7
- package/dist/commands/status.js +0 -18
- package/dist/commands/templates.d.ts +0 -11
- package/dist/commands/templates.js +0 -32
- package/dist/commands/test-charge.d.ts +0 -11
- package/dist/commands/test-charge.js +0 -34
- package/dist/journal.d.ts +0 -26
- package/dist/journal.js +0 -58
- package/parity/deploy-plans/paid-api.json +0 -34
- package/parity/deploy-plans/per-task-agent.json +0 -34
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import type { GoldEvaluator } from './gold-arms.js';
|
|
2
|
+
import { type FileHandle } from 'node:fs/promises';
|
|
3
|
+
import { CliError } from '../errors.js';
|
|
4
|
+
import { slugOf } from './allow.js';
|
|
5
|
+
import { type Source } from './sources.js';
|
|
6
|
+
import { type RepoSize } from './public-vocabulary.js';
|
|
7
|
+
import { type DerivedRecords, type ErrorObservation, type PromptObservation, type RecallCall, type SessionObservation, type SignatureRecord, type StepCounts, type Skeleton, type ToolObservation } from './schema.js';
|
|
8
|
+
/** Where the store and the operator's Claude Code logs are; `bin.ts` fills it from the environment. */
|
|
9
|
+
export interface SessionsRuntime {
|
|
10
|
+
/** `<config>/oars/sessions`. */
|
|
11
|
+
storeDir: string;
|
|
12
|
+
/** `~/.claude/projects` (or `$CLAUDE_CONFIG_DIR/projects`). */
|
|
13
|
+
projectsRoot: string;
|
|
14
|
+
/** Cursor's `User` folder (`cursorRoot` in cursor.ts), kept as the alias of `sourceRoots.cursor`; absent means no Cursor source. */
|
|
15
|
+
cursorRoot?: string;
|
|
16
|
+
/** Where each non-Claude source's store lives, by `Source.name` (sources.ts); a source with no root is not read. `deposit` reads one only when `--allow` names it. */
|
|
17
|
+
sourceRoots?: {
|
|
18
|
+
[source: string]: string;
|
|
19
|
+
};
|
|
20
|
+
/** The source table; absent means `SOURCES`. The seam a test uses to prove an entry needs no other wiring. */
|
|
21
|
+
sources?: readonly Source[];
|
|
22
|
+
/** Where the account's salt comes from; absent means this machine's own (`localSalt`). The seam an account identity replaces (M4). */
|
|
23
|
+
accountSalt?: (storeDir: string) => Promise<AccountSalt>;
|
|
24
|
+
/** The fresh single-turn reader behind `gold arms`; absent in a run that has none. */
|
|
25
|
+
evaluator?: GoldEvaluator | undefined;
|
|
26
|
+
stdin: NodeJS.ReadableStream;
|
|
27
|
+
stdout: {
|
|
28
|
+
write: (text: string) => unknown;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
interface FileState {
|
|
32
|
+
size: number;
|
|
33
|
+
mtimeMs: number;
|
|
34
|
+
rev: number;
|
|
35
|
+
/** The capture version that wrote this file's records; a file recorded under another version is deposited again. */
|
|
36
|
+
v: string;
|
|
37
|
+
/** The `sid` of the salt the file's records were hashed with; a file recorded under another salt is captured again from raw (spec Section 4). */
|
|
38
|
+
s?: string;
|
|
39
|
+
/** The sorted `--redact-domain` set in force when this file was deposited; a file recorded under another set is deposited again. */
|
|
40
|
+
d: string[];
|
|
41
|
+
/**
|
|
42
|
+
* The repository size bucket this file's first frame read, so a later capture's frame does not follow the repository. Held here as well as
|
|
43
|
+
* in the log because the SessionEnd hook has seconds to run and the log can run to hundreds of MB; absent on a file captured before frames.
|
|
44
|
+
*/
|
|
45
|
+
repoSize?: RepoSize | null;
|
|
46
|
+
}
|
|
47
|
+
export interface State {
|
|
48
|
+
files: {
|
|
49
|
+
[key: string]: FileState;
|
|
50
|
+
};
|
|
51
|
+
/** Every `--redact-domain` any deposit used, so recall masks a query the same way the log was masked. */
|
|
52
|
+
redactDomains: string[];
|
|
53
|
+
/** Every `--allow` entry any deposit used (folders, prefixes, globs): the SessionEnd hook deposits a session only from a folder these name. */
|
|
54
|
+
allow: string[];
|
|
55
|
+
}
|
|
56
|
+
export declare const paths: (storeDir: string) => {
|
|
57
|
+
observations: string;
|
|
58
|
+
state: string;
|
|
59
|
+
derived: string;
|
|
60
|
+
skeletons: string;
|
|
61
|
+
calls: string;
|
|
62
|
+
hookCalls: string;
|
|
63
|
+
pipelineRuns: string;
|
|
64
|
+
salt: string;
|
|
65
|
+
raw: string;
|
|
66
|
+
};
|
|
67
|
+
/** The salt every path hash in a store uses, and its `sid`: the first 8 hex characters of SHA-256(salt), stamped on each capture record. */
|
|
68
|
+
export interface AccountSalt {
|
|
69
|
+
salt: string;
|
|
70
|
+
sid: string;
|
|
71
|
+
}
|
|
72
|
+
export declare const sidOf: (salt: string) => string;
|
|
73
|
+
/**
|
|
74
|
+
* This machine's salt, created on first use: path targets hashed with it join inside this store only. This is the one seam where the
|
|
75
|
+
* account's salt replaces the machine's (`SessionsRuntime.accountSalt`, Open question M4): a store whose `sid` then changes captures its
|
|
76
|
+
* files again from raw at the next deposit, and nothing else moves.
|
|
77
|
+
*/
|
|
78
|
+
export declare const localSalt: (storeDir: string) => Promise<AccountSalt>;
|
|
79
|
+
export declare const readState: (storeDir: string) => Promise<State>;
|
|
80
|
+
export declare const readRedactDomains: (storeDir: string) => Promise<string[]>;
|
|
81
|
+
/** The `--allow` entries and `--redact-domain` set earlier deposits used; the nightly run repeats them. */
|
|
82
|
+
export declare const readSaved: (storeDir: string) => Promise<{
|
|
83
|
+
allow: string[];
|
|
84
|
+
redactDomains: string[];
|
|
85
|
+
}>;
|
|
86
|
+
export declare const writeAtomic: (file: string, text: string) => Promise<void>;
|
|
87
|
+
export { slugOf };
|
|
88
|
+
export interface DepositOptions {
|
|
89
|
+
allow: readonly string[];
|
|
90
|
+
redactDomains: readonly string[];
|
|
91
|
+
now: () => number;
|
|
92
|
+
}
|
|
93
|
+
/** What one deposit run read from one source. */
|
|
94
|
+
export interface SourceTally {
|
|
95
|
+
/** Of `sessions`, the ones this source supplied. */
|
|
96
|
+
read: number;
|
|
97
|
+
/** Why the store (or a file in it) could not be read: the full path for the terminal. */
|
|
98
|
+
unreadable: string[];
|
|
99
|
+
/** The same reasons with the file reduced to its base name: the hook-call record (class A) must not carry the user name in a path. */
|
|
100
|
+
unreadableLogged: string[];
|
|
101
|
+
/** Sessions skipped because their id is not a safe file name. */
|
|
102
|
+
rejected: number;
|
|
103
|
+
}
|
|
104
|
+
export interface DepositResult {
|
|
105
|
+
/** Session files parsed this run. */
|
|
106
|
+
sessions: number;
|
|
107
|
+
/** Session files skipped because size, mtime, capture version, salt, and redact-domain set were all unchanged. */
|
|
108
|
+
unchanged: number;
|
|
109
|
+
lines: number;
|
|
110
|
+
badLines: number;
|
|
111
|
+
observations: number;
|
|
112
|
+
/** Subagent transcripts parsed this run (A24); not counted in `sessions`, so per-session denominators stay main sessions. */
|
|
113
|
+
subagents: number;
|
|
114
|
+
/** Per source name (sources.ts): what this run read from it. A source that was not allowed or has no store has no entry. */
|
|
115
|
+
sources: {
|
|
116
|
+
[source: string]: SourceTally;
|
|
117
|
+
};
|
|
118
|
+
/** Of `sessions`, the Cursor composer sessions parsed this run; 0 when the Cursor source is not allowed or absent. Alias of `sources.cursor`. */
|
|
119
|
+
cursor: number;
|
|
120
|
+
/** Why the Cursor store could not be read this run (locked, corrupt, or from a Cursor version this reader does not know); empty when it was read or absent. */
|
|
121
|
+
cursorUnreadable: string[];
|
|
122
|
+
/** The same reasons with the store file reduced to its base name: the hook-call record (class A) must not carry the user name in a path. */
|
|
123
|
+
cursorUnreadableLogged: string[];
|
|
124
|
+
/** Cursor composers skipped this run because their id is not a safe file name. */
|
|
125
|
+
cursorRejected: number;
|
|
126
|
+
/** Project folders under the projects root that are not on the allowlist, so were not opened. */
|
|
127
|
+
skippedFolders: number;
|
|
128
|
+
/** The allowed folders that exist under the projects root. */
|
|
129
|
+
folders: string[];
|
|
130
|
+
/** Allowed names that matched no project folder. */
|
|
131
|
+
missing: string[];
|
|
132
|
+
}
|
|
133
|
+
/** What a deposit never reads: project folders that hold transcripts but that no `--allow` entry names. */
|
|
134
|
+
export interface SkippedScope {
|
|
135
|
+
folders: number;
|
|
136
|
+
/** Main transcripts in those folders; subagent transcripts are not counted, as everywhere else. */
|
|
137
|
+
transcripts: number;
|
|
138
|
+
/** The folder names, sorted. */
|
|
139
|
+
names: string[];
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* The scan rule is the allowlist (`depositLocked`, `depositSessionLocked`): a folder no entry names is not opened, by design, so
|
|
143
|
+
* a worktree folder of an allowed repository is skipped when only the repository's own folder is named. This reads folder listings
|
|
144
|
+
* only, never a transcript, so `verify` and `books` can say what the store does not hold.
|
|
145
|
+
*/
|
|
146
|
+
export declare const skippedFolders: (runtime: SessionsRuntime) => Promise<SkippedScope>;
|
|
147
|
+
export declare const listDir: (dir: string) => Promise<import("fs").Dirent<string>[]>;
|
|
148
|
+
interface SubagentFile {
|
|
149
|
+
dir: string;
|
|
150
|
+
/** The folders between `subagents` and the file, for example `['workflows', 'wf_x']`. */
|
|
151
|
+
path: string[];
|
|
152
|
+
parent: string;
|
|
153
|
+
name: string;
|
|
154
|
+
}
|
|
155
|
+
export declare const subagentFiles: (folder: string, sessions: readonly string[]) => Promise<SubagentFile[]>;
|
|
156
|
+
/** The session folders under a project folder: each may hold subagent transcripts, even when its main transcript is gone. */
|
|
157
|
+
export declare const sessionFolders: (folder: string) => Promise<string[]>;
|
|
158
|
+
/** What a derive pass read and wrote, for the step log (spec 3.1 `in` and `out`, 4.2 `key`). */
|
|
159
|
+
export interface DeriveTrace {
|
|
160
|
+
ms: number;
|
|
161
|
+
in: StepCounts;
|
|
162
|
+
out: StepCounts;
|
|
163
|
+
key: string;
|
|
164
|
+
}
|
|
165
|
+
/** What a deposit wrote, filled in by the caller's trace so `DepositResult` and the `--json` document keep their shape. */
|
|
166
|
+
export interface DepositTrace {
|
|
167
|
+
/** Records written, by kind: `session` (main), `subagent`, `user-prompt`, `tool`, `error-line`. */
|
|
168
|
+
kinds: StepCounts;
|
|
169
|
+
/** Pending sessions this deposit took before its own, as step-row `in` counts: `pending` found, `pendingDropped` (transcript gone, folder no longer allowed, not an entry, or removed at `PENDING_MAX_FAILURES` failures), `pendingKept` (failed, or an unreadable file; left for the next run). */
|
|
170
|
+
pending?: StepCounts;
|
|
171
|
+
/** Set to the refusal's first line when the Stop hook found the store locked and recorded its session in the pending list instead of depositing: the caller logs a `deferred` row, not an `error` one. */
|
|
172
|
+
deferred?: string;
|
|
173
|
+
/** The derive pass a whole-store deposit ends with (the index pass follows it: `index`). */
|
|
174
|
+
derive?: DeriveTrace;
|
|
175
|
+
/** A derive pass that failed after the deposit's records and `state.json` were written: the caller logs `deposit` ok and `derive` error, then rethrows. */
|
|
176
|
+
deriveFailure?: {
|
|
177
|
+
error: unknown;
|
|
178
|
+
key: string;
|
|
179
|
+
ms: number;
|
|
180
|
+
};
|
|
181
|
+
/** The index pass after a derive that succeeded: its own step (spec 3.1), run at the nightly and manual runs. */
|
|
182
|
+
index?: DeriveTrace;
|
|
183
|
+
/** An index pass that failed after the derive was written: the caller logs `derive` ok and `index` error, then rethrows. */
|
|
184
|
+
indexFailure?: {
|
|
185
|
+
error: unknown;
|
|
186
|
+
key: string;
|
|
187
|
+
ms: number;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
export declare const newTrace: () => DepositTrace;
|
|
191
|
+
export declare const digest: (parts: readonly string[]) => string;
|
|
192
|
+
/**
|
|
193
|
+
* Rewrites `derived.json` (the derive step), then the hook index (the index step), from the whole store. With a trace, a failure of
|
|
194
|
+
* either is recorded on it instead of thrown, so the caller can log the deposit that already wrote its records, then the failed step
|
|
195
|
+
* (spec 3.1: one row per step, a failed derive leaving the index skipped), and rethrow.
|
|
196
|
+
*/
|
|
197
|
+
export declare const refresh: (runtime: SessionsRuntime, redactDomains: readonly string[], at: string, trace?: DepositTrace, held?: LockHold) => Promise<void>;
|
|
198
|
+
/** Another deposit holds the store lock and the wait ran out: the one failure the Stop hook defers instead of counting as a failed run. */
|
|
199
|
+
export declare class StoreLockedError extends CliError {
|
|
200
|
+
constructor();
|
|
201
|
+
}
|
|
202
|
+
interface LockOptions {
|
|
203
|
+
/** How long to wait for a holder before giving up. */
|
|
204
|
+
waitMs: number;
|
|
205
|
+
/** A lock file older than this belongs to a process that died or passed `holdMs`; it is broken. */
|
|
206
|
+
staleMs: number;
|
|
207
|
+
/**
|
|
208
|
+
* The longest a holder keeps its lock refreshed; default six times `staleMs` (an hour). Past it the heartbeat stops, so a holder that
|
|
209
|
+
* hangs while its process lives ages out like a dead one and the next waiter breaks it, rather than every deposit waiting on it for good.
|
|
210
|
+
*/
|
|
211
|
+
holdMs?: number;
|
|
212
|
+
}
|
|
213
|
+
/** What `withLock` gives its work: whether this run's lock file is still the one standing. */
|
|
214
|
+
export type LockHold = () => Promise<boolean>;
|
|
215
|
+
/** The store lock was broken and taken by another run while this one worked: it writes nothing more. */
|
|
216
|
+
export declare class StoreLockLostError extends CliError {
|
|
217
|
+
constructor();
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Runs `work` as the only writer of `state.json` and the observations file. The SessionEnd hooks of parallel sessions and the nightly
|
|
221
|
+
* run each read, extract, and rewrite `state.json`; without this one's `files` and `allow` entries are lost to another's write.
|
|
222
|
+
*/
|
|
223
|
+
export declare const withLock: <T>(storeDir: string, work: (held: LockHold) => Promise<T>, options?: LockOptions) => Promise<T>;
|
|
224
|
+
export declare const deposit: (runtime: SessionsRuntime, options: DepositOptions, trace?: DepositTrace) => Promise<DepositResult>;
|
|
225
|
+
/**
|
|
226
|
+
* The log's lines, a chunk at a time: the log can pass the longest string Node can hold (536,870,888 characters), so it is never one string.
|
|
227
|
+
* It splits on the newline alone, not through `readline`, which also ends a line at U+2028 and U+2029: `JSON.stringify` leaves those raw inside a
|
|
228
|
+
* value. A missing log has no lines, and a last line with no newline is yielded as it stands, for the reader to parse or skip.
|
|
229
|
+
*/
|
|
230
|
+
export declare const logLines: (file: string, held?: FileHandle) => AsyncGenerator<string>;
|
|
231
|
+
/** The inverse of `sessionOfRelative`: `<id>.jsonl`, or `<parent>/subagents/[workflows/<wf>/]<agent>.jsonl` for a `<parent>~[<wf>~]agent-x` id. */
|
|
232
|
+
export declare const relativeOfSession: (session: string) => string[];
|
|
233
|
+
/**
|
|
234
|
+
* The sessions of `behind` (captured before the current version) whose source is gone (the transcript from both the harness and `raw/`, or the
|
|
235
|
+
* session from its source's store, such as a Cursor composer): they can never be captured again, so `verify` counts them `cv-frozen` instead of failing `--strict` over them.
|
|
236
|
+
*/
|
|
237
|
+
export declare const frozenSessions: (runtime: SessionsRuntime, behind: readonly {
|
|
238
|
+
project: string;
|
|
239
|
+
session: string;
|
|
240
|
+
}[]) => Promise<Set<string>>;
|
|
241
|
+
export type SessionDeposit = 'deposited' | 'unchanged' | 'not-allowed' | 'missing' | 'deferred';
|
|
242
|
+
/**
|
|
243
|
+
* Deposits one transcript, as the SessionEnd hook does: only from a folder that earlier `--allow` entries name, and idempotent by size and
|
|
244
|
+
* mtime. It does not rebuild `derived.json` or the hook index (that is a whole-store pass; the nightly run does it), so it stays fast.
|
|
245
|
+
* Under the lock it first takes up to `PENDING_HOOK_CAP` sessions an earlier hook deferred, then its own. If the lock is still held after the
|
|
246
|
+
* wait it records the session in the pending list, which needs no lock, and returns `deferred`: the next deposit of any kind takes it.
|
|
247
|
+
*/
|
|
248
|
+
export declare const depositSession: (runtime: SessionsRuntime, transcript: string, now: () => number, trace?: DepositTrace) => Promise<SessionDeposit>;
|
|
249
|
+
export interface Store {
|
|
250
|
+
/** Main transcripts only, so session counts and per-session denominators are unchanged by subagent deposits. */
|
|
251
|
+
sessions: SessionObservation[];
|
|
252
|
+
prompts: PromptObservation[];
|
|
253
|
+
errors: ErrorObservation[];
|
|
254
|
+
/** Subagent transcripts (A24), kept apart from `sessions` so G1 denominators stay main sessions. */
|
|
255
|
+
subagents: SessionObservation[];
|
|
256
|
+
/** The tool calls of every version-3 or later transcript, main and subagent. */
|
|
257
|
+
tools: ToolObservation[];
|
|
258
|
+
/** Sessions whose capture records a newer oars wrote: read for the fields known here, and reported by the commands that print the store. Set by `loadStore` only. */
|
|
259
|
+
newerCaptures: number;
|
|
260
|
+
}
|
|
261
|
+
/** What one pass over the log keeps: a number or two per session, never the records. */
|
|
262
|
+
interface LogScan {
|
|
263
|
+
/** Each session's highest rev, over every kind of record. */
|
|
264
|
+
latest: Map<string, number>;
|
|
265
|
+
/** True when some session has a record below its highest rev, which a compaction would drop. */
|
|
266
|
+
superseded: boolean;
|
|
267
|
+
/** Sessions whose newest capture record was written by a newer oars, counted as `loadStore` counts them. */
|
|
268
|
+
newerCaptures: number;
|
|
269
|
+
}
|
|
270
|
+
export declare const scanLog: (file: string, held?: FileHandle) => Promise<LogScan>;
|
|
271
|
+
/**
|
|
272
|
+
* The store as a reader sees it: for each session only the highest `rev`. A version-3 or later session is derived here from its capture records
|
|
273
|
+
* (EXTRACTOR_VERSION rules); a session whose last deposit was version 2 keeps the prompt and error lines that deposit wrote.
|
|
274
|
+
* `afterFirstPass` runs between the two passes over the log: a seam for the test that compacts the log there.
|
|
275
|
+
*/
|
|
276
|
+
export declare const loadStore: (storeDir: string, afterFirstPass?: () => Promise<void>) => Promise<Store>;
|
|
277
|
+
/**
|
|
278
|
+
* Drops the superseded revs from the log, so a re-capture does not leave a full copy of every session behind. The caller holds the store lock,
|
|
279
|
+
* the same one every append takes. Only a line a higher rev of its session replaces goes: a line this version cannot read stays, since a later
|
|
280
|
+
* oars may read it, and a kept line is written back byte for byte. A crash before the rename leaves the old log whole and a temp file that no
|
|
281
|
+
* reader opens and the next compaction removes. Throws, with the log as it was, when the rewrite cannot finish.
|
|
282
|
+
*/
|
|
283
|
+
export declare const compactLog: (storeDir: string, renameWaitMs?: number, held?: LockHold) => Promise<void>;
|
|
284
|
+
/** A version-3 `contextFingerprint` is `<prompt|->.<environment|->`: only the prompt half survives, and `-` reads as none. */
|
|
285
|
+
export declare const promptHalf: (contextFingerprint: unknown) => string | null;
|
|
286
|
+
export declare const readCalls: (storeDir: string) => Promise<RecallCall[]>;
|
|
287
|
+
/**
|
|
288
|
+
* `unreadable` counts skeleton files that are torn, corrupted, or not a skeleton, so verify reports them instead of aborting. With `lean`, each
|
|
289
|
+
* line's `hashes` read as empty: `verify` holds every skeleton at once and checks structure, never content.
|
|
290
|
+
*/
|
|
291
|
+
export declare const readSkeletons: (storeDir: string, only?: string, lean?: boolean) => Promise<{
|
|
292
|
+
skeletons: Skeleton[];
|
|
293
|
+
unreadable: number;
|
|
294
|
+
}>;
|
|
295
|
+
/** The derived records, a pure function of the store. */
|
|
296
|
+
export declare const derive: (store: Store, at: string) => DerivedRecords;
|
|
297
|
+
export declare const signatureRecord: (sig: string, list: readonly ErrorObservation[]) => SignatureRecord;
|