@deepagents/trajectory 0.0.0-stage → 7.54.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 +251 -2
- package/dist/adapter.d.ts +47 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/atif.d.ts +122 -0
- package/dist/atif.d.ts.map +1 -0
- package/dist/claude-code/adapter.d.ts +9 -0
- package/dist/claude-code/adapter.d.ts.map +1 -0
- package/dist/claude-code/session.d.ts +40 -0
- package/dist/claude-code/session.d.ts.map +1 -0
- package/dist/claude-code/store.d.ts +40 -0
- package/dist/claude-code/store.d.ts.map +1 -0
- package/dist/codex/adapter.d.ts +14 -0
- package/dist/codex/adapter.d.ts.map +1 -0
- package/dist/codex/store.d.ts +24 -0
- package/dist/codex/store.d.ts.map +1 -0
- package/dist/codex/thread.d.ts +20 -0
- package/dist/codex/thread.d.ts.map +1 -0
- package/dist/errors.d.ts +14 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +977 -0
- package/dist/index.js.map +7 -0
- package/package.json +37 -4
package/README.md
CHANGED
|
@@ -1,3 +1,252 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @deepagents/trajectory
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **Status:** Claude Code and Codex read today (#6107); other agents come as
|
|
4
|
+
> adapters. Each decision is in [docs/adr](./docs/adr).
|
|
5
|
+
|
|
6
|
+
Read a coding agent's stored sessions (Claude Code transcripts, Codex rollouts)
|
|
7
|
+
as [ATIF](https://github.com/harbor-framework/harbor/blob/main/rfcs/0001-trajectory-format.md)
|
|
8
|
+
v1.8 trajectories: one ordered list of user, agent and system steps per session,
|
|
9
|
+
with tool calls, their results, metrics and the subagents nested inside.
|
|
10
|
+
|
|
11
|
+
Each agent is an `Adapter`. This package ships one for Claude Code and one for
|
|
12
|
+
Codex. An agent it does not cover gets an adapter of your own that returns the
|
|
13
|
+
same `Trajectory`, so every consumer reads every agent the same way.
|
|
14
|
+
|
|
15
|
+
The package only reads. It owns no store, index or schedule, and it has no
|
|
16
|
+
policy. Rules such as "the housekeeping is due" belong to the host; this package
|
|
17
|
+
gives the host the steps to decide from.
|
|
18
|
+
|
|
19
|
+
## Read the transcript a hook was given
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import {
|
|
23
|
+
ClaudeCodeAdapter,
|
|
24
|
+
ClaudeCodeSession,
|
|
25
|
+
ClaudeCodeSubagent,
|
|
26
|
+
} from '@deepagents/trajectory';
|
|
27
|
+
|
|
28
|
+
// SubagentStop reads the subagent's own transcript, never the parent's.
|
|
29
|
+
const session = input.agent_transcript_path
|
|
30
|
+
? ClaudeCodeSubagent.fromTranscriptPath(input.agent_transcript_path)
|
|
31
|
+
: ClaudeCodeSession.fromTranscriptPath(input.transcript_path);
|
|
32
|
+
const { trajectory } = await new ClaudeCodeAdapter().read(session, {
|
|
33
|
+
subagents: false,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const written = trajectory.steps
|
|
37
|
+
.flatMap((step) => (step.source === 'agent' ? (step.tool_calls ?? []) : []))
|
|
38
|
+
.filter((call) =>
|
|
39
|
+
['Edit', 'Write', 'MultiEdit', 'NotebookEdit'].includes(call.function_name),
|
|
40
|
+
)
|
|
41
|
+
.map((call) => call.arguments.file_path ?? call.arguments.notebook_path);
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Find what the user typed
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
const typed = trajectory.steps.filter(
|
|
48
|
+
(step) =>
|
|
49
|
+
step.source === 'user' && step.extra?.claude_code?.origin === 'human',
|
|
50
|
+
);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
A prompt typed while the agent works (a `queued_command` attachment) is a user
|
|
54
|
+
step too. Task notifications, peer messages and hand-backs are user steps with
|
|
55
|
+
their own `origin`. Skill bodies, command expansions and other `isMeta` entries
|
|
56
|
+
are system steps. See [ADR 0004](./docs/adr/0004-every-claude-code-entry-becomes-a-step-or-a-counted-diagnostic.md).
|
|
57
|
+
|
|
58
|
+
## Read a whole session after a /clear
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
const store = new ClaudeCodeStore({ root: join(homedir(), '.claude') });
|
|
62
|
+
const session = await store.session(process.env.CLAUDE_CODE_SESSION_ID);
|
|
63
|
+
const { sessions, missing } = await store.chain(session); // oldest first, linked by derived-from entries
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`missing` names each id the chain points to whose transcript is no longer in the
|
|
67
|
+
store. Each segment reads as its own trajectory. All segments share one `session_id`
|
|
68
|
+
(the first id of the chain), and each one names the next in
|
|
69
|
+
`continued_trajectory_ref`. See [ADR 0007](./docs/adr/0007-a-clear-chain-is-separate-trajectories-that-share-session-id-and-link-by-continued-trajectory-ref.md).
|
|
70
|
+
|
|
71
|
+
## Mine every session since a date
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
const store = new ClaudeCodeStore({ root: join(homedir(), '.claude') });
|
|
75
|
+
const adapter = new ClaudeCodeAdapter();
|
|
76
|
+
for await (const session of store.sessions({ since: new Date('2026-11-20') })) {
|
|
77
|
+
const { trajectory, diagnostics } = await adapter.read(session);
|
|
78
|
+
// …
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Read Codex history
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
const store = new CodexStore({ root: join(homedir(), '.codex') });
|
|
86
|
+
const adapter = new CodexAdapter();
|
|
87
|
+
for await (const thread of store.threads({ since })) {
|
|
88
|
+
const { trajectory } = await adapter.read(thread); // .jsonl and .jsonl.zst
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Write your own adapter
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
import type { Adapter, ReadResult } from '@deepagents/trajectory';
|
|
96
|
+
|
|
97
|
+
class GooseAdapter implements Adapter<GooseSession> {
|
|
98
|
+
readonly agent = 'goose';
|
|
99
|
+
async read(session: GooseSession): Promise<ReadResult> {
|
|
100
|
+
// Read the store, then return { trajectory, diagnostics } in ATIF v1.8.
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Signatures
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
// The port.
|
|
109
|
+
export interface Adapter<Session> {
|
|
110
|
+
readonly agent: string; // ATIF agent.name: 'claude-code', 'codex', …
|
|
111
|
+
read(session: Session, options?: ReadOptions): Promise<ReadResult>;
|
|
112
|
+
}
|
|
113
|
+
export interface ReadOptions { subagents?: boolean } // default true
|
|
114
|
+
export interface ReadResult { trajectory: Trajectory; diagnostics: Diagnostic[] }
|
|
115
|
+
export interface Diagnostic { code: DiagnosticCode; path: string; line?: number; count?: number; entryType?: string; message: string }
|
|
116
|
+
export type DiagnosticCode =
|
|
117
|
+
| 'invalid_json_line' // a line that does not parse
|
|
118
|
+
| 'partial_last_line' // the agent is still writing it
|
|
119
|
+
| 'unmapped_entry' // bookkeeping that has no step (counted by type)
|
|
120
|
+
| 'sidechain_entry' // an isSidechain row inside a main transcript
|
|
121
|
+
| 'orphan_tool_result' // a result whose call is not in the transcript
|
|
122
|
+
| 'unlinked_subagent' // a subagent whose spawning call is not found
|
|
123
|
+
| 'unreadable_subagent'; // a subagent transcript that cannot be read
|
|
124
|
+
|
|
125
|
+
// Claude Code.
|
|
126
|
+
export class ClaudeCodeStore {
|
|
127
|
+
constructor(options: { root: string }); // the folder that holds projects/
|
|
128
|
+
sessions(options: { since: Date }): AsyncIterable<ClaudeCodeSession>;
|
|
129
|
+
session(sessionId: string): Promise<ClaudeCodeSession | undefined>;
|
|
130
|
+
chain(session: ClaudeCodeSession): Promise<ClaudeCodeChain>;
|
|
131
|
+
}
|
|
132
|
+
export interface ClaudeCodeChain {
|
|
133
|
+
readonly sessions: readonly ClaudeCodeSession[]; // oldest first
|
|
134
|
+
readonly missing: readonly string[]; // ids the chain names whose transcript is gone
|
|
135
|
+
}
|
|
136
|
+
export class ClaudeCodeSession {
|
|
137
|
+
static fromTranscriptPath(path: string): ClaudeCodeSession; // a main transcript; touches no disk
|
|
138
|
+
readonly sessionId: string;
|
|
139
|
+
readonly transcriptPath: string;
|
|
140
|
+
readonly runId: string; // the chain's first id; its own id when read alone
|
|
141
|
+
readonly continuedBy: string | undefined; // the next segment's transcript, from chain()
|
|
142
|
+
}
|
|
143
|
+
export class ClaudeCodeSubagent {
|
|
144
|
+
static fromTranscriptPath(path: string): ClaudeCodeSubagent; // <session>/subagents/agent-<id>.jsonl
|
|
145
|
+
readonly agentId: string;
|
|
146
|
+
readonly sessionId: string; // the session that started it
|
|
147
|
+
readonly transcriptPath: string;
|
|
148
|
+
}
|
|
149
|
+
export class ClaudeCodeAdapter implements Adapter<ClaudeCodeSession | ClaudeCodeSubagent> { readonly agent = 'claude-code' }
|
|
150
|
+
|
|
151
|
+
// Codex.
|
|
152
|
+
export class CodexStore {
|
|
153
|
+
constructor(options: { root: string }); // the folder that holds sessions/ and archived_sessions/
|
|
154
|
+
threads(options: { since: Date }): AsyncIterable<CodexThread>;
|
|
155
|
+
}
|
|
156
|
+
export class CodexThread {
|
|
157
|
+
constructor(threadId: string, rolloutPaths: readonly string[], subagents?: readonly CodexSubagentThread[]);
|
|
158
|
+
readonly threadId: string;
|
|
159
|
+
readonly rolloutPaths: readonly string[]; // the original first, then any a revert wrote
|
|
160
|
+
readonly subagents: readonly CodexSubagentThread[]; // every thread under it, flat
|
|
161
|
+
}
|
|
162
|
+
export interface CodexSubagentThread { readonly threadId: string; readonly rolloutPaths: readonly string[] }
|
|
163
|
+
export class CodexAdapter implements Adapter<CodexThread> { readonly agent = 'codex' }
|
|
164
|
+
|
|
165
|
+
// ATIF v1.8, ported from Harbor's models (docs/ported-from-harbor-atif.md).
|
|
166
|
+
export const ATIF_SCHEMA_VERSION = 'ATIF-v1.8';
|
|
167
|
+
export type Trajectory, Step, UserStep, AgentStep, SystemStep, ToolCall, Observation,
|
|
168
|
+
ObservationResult, Metrics, FinalMetrics, Agent, ContentPart, SubagentTrajectoryRef;
|
|
169
|
+
|
|
170
|
+
// Errors.
|
|
171
|
+
export class SessionReadError extends Error { readonly path: string } // missing or unreadable; cause attached
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## What each call does underneath
|
|
175
|
+
|
|
176
|
+
| Call | Underneath |
|
|
177
|
+
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
178
|
+
| `ClaudeCodeSession.fromTranscriptPath(p)` | Takes the id from the file name; touches no disk. |
|
|
179
|
+
| `ClaudeCodeStore.sessions({ since })` | Walks `projects/*/*.jsonl` and yields each main transcript changed since `since`, newest first. Subagent files are not sessions. |
|
|
180
|
+
| `ClaudeCodeStore.session(id)` | Looks for `projects/*/<id>.jsonl`. |
|
|
181
|
+
| `ClaudeCodeStore.chain(s)` | Reads each transcript's `derived-from` entry back to the first segment. It follows every `claude_code_session` it names (any `via`), skips ids already in the chain, looks beside the current transcript first, then in every project. |
|
|
182
|
+
| `ClaudeCodeAdapter.read(s)` | Streams the transcript line by line. It maps every entry by the [mapping table](#claude-code-entry--atif), pairs each `tool_use` with its `tool_result` by id, and reads `<id>/subagents/agent-*.jsonl` plus `.meta.json` into `subagent_trajectories`. |
|
|
183
|
+
| `CodexStore.threads({ since })` | Walks `sessions/` and `archived_sessions/` (`.jsonl`, `.jsonl.zst`), reads each rollout's first line (`session_meta`, decompressing only that far) and groups a subagent thread under its parent with meticulous's rule: the meta's `session_id` when it differs from the thread id, else `parent_thread_id`. |
|
|
184
|
+
| `CodexAdapter.read(t)` | Decodes `.zst` with `node:zlib` `zstdDecompressSync`, then calls meticulous's `convertCodexSession`, and writes `schema_version: ATIF-v1.8`. |
|
|
185
|
+
|
|
186
|
+
Speed, measured on this Mac on 2026-11-27 (a measurement, not a test: the
|
|
187
|
+
repo's `no-wall-clock-bound` rule forbids timing bounds in tests):
|
|
188
|
+
|
|
189
|
+
- meticulous converts 3 MB plus 6 subagents in 34 ms;
|
|
190
|
+
- a whole-file read of 24 h of transcripts (835 files, 311k entries) takes 3.7 s warm.
|
|
191
|
+
|
|
192
|
+
## Claude Code entry → ATIF
|
|
193
|
+
|
|
194
|
+
| Entry | Becomes |
|
|
195
|
+
| ------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
196
|
+
| `user` with an `origin` (typed prompts, peer messages, task notifications; `isMeta` or not) | `UserStep`; `extra.claude_code.origin` = `origin.kind` (`human`, `peer`, `task-notification`, …) |
|
|
197
|
+
| `user`, `isMeta`, no `origin` (skill bodies, command expansions) | `SystemStep`, `extra.claude_code.is_meta: true` |
|
|
198
|
+
| `user`, text content, no `origin`, not `isMeta` (Claude Code builds before `origin`) | `UserStep` with no `extra.claude_code.origin`: its author is unknown, so it never counts as typed |
|
|
199
|
+
| `user` with `tool_result` blocks | `ObservationResult` on the agent step that made the call; `toolUseResult` goes in `result.extra.claude_code.tool_use_result` |
|
|
200
|
+
| `assistant` (entries with one `message.id` merge into one step) | `AgentStep`: text → `message`, `thinking` → `reasoning_content`, `tool_use` → `tool_calls`, `usage` → `metrics` |
|
|
201
|
+
| `attachment` `queued_command` | `UserStep` with that attachment's `origin` (a prompt typed mid-turn, or a peer message) |
|
|
202
|
+
| any other `attachment` (`hook_additional_context`, `hook_success`, …) | `SystemStep`, the attachment in `extra.claude_code.attachment` |
|
|
203
|
+
| `system` (`stop_hook_summary`, `turn_duration`, `compact_boundary`, …) | `SystemStep`, the entry in `extra.claude_code.system` |
|
|
204
|
+
| `derived-from` | `Trajectory.extra.claude_code.derived_from`; `chain()` follows it |
|
|
205
|
+
| `ai-title`, `custom-title`, `summary`, `pr-link` | `Trajectory.extra.claude_code` |
|
|
206
|
+
| `isSidechain` row in a main transcript | skipped, counted as `sidechain_entry` |
|
|
207
|
+
| bookkeeping (`api-request`, `data-flow-records`, `permission-mode`, `queue-operation`, `file-history-snapshot`, …) | skipped, counted by type as `unmapped_entry` |
|
|
208
|
+
|
|
209
|
+
Every step keeps `extra.claude_code` with `uuid`, `parent_uuid`, `timestamp`,
|
|
210
|
+
`cwd`, `entrypoint` and `prompt_id`, so a consumer can join back to the raw line.
|
|
211
|
+
|
|
212
|
+
## Errors
|
|
213
|
+
|
|
214
|
+
- `SessionReadError`: the transcript or rollout is missing or cannot be read or
|
|
215
|
+
decoded. It has one class because the caller's next step is the same either
|
|
216
|
+
way: a hook does not fire, and a miner logs and skips.
|
|
217
|
+
- A bad line never throws; it becomes a `Diagnostic`. The last line is often
|
|
218
|
+
half-written while the agent runs.
|
|
219
|
+
|
|
220
|
+
## The same concepts in other systems
|
|
221
|
+
|
|
222
|
+
| System | Their word | Ours |
|
|
223
|
+
| -------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
|
|
224
|
+
| Harbor ATIF v1.8 | `Trajectory`, `Step`, `subagent_trajectories`, `continued_trajectory_ref` | same (the port) |
|
|
225
|
+
| Google ADK (Go) | `session.Session` holds `Event`s | `ClaudeCodeSession` is the stored session; the trajectory is what is read back |
|
|
226
|
+
| Microsoft Agent Framework (.NET) | `AgentSession` + `ChatHistoryProvider` | the same split |
|
|
227
|
+
| Claude Agent SDK | `listSessions`, `getSessionMessages`, `listSubagents` | `ClaudeCodeStore.sessions`, `ClaudeCodeAdapter.read` |
|
|
228
|
+
| Codex app-server | thread → turn → item; rollout files | `CodexThread` → `Trajectory` |
|
|
229
|
+
| `@letta-ai/trajectory` | `listTrajectories`, `normalizeTranscript` | `Store.sessions`, `Adapter.read` |
|
|
230
|
+
| franken-agent-detection (Rust) | `Connector` trait, `NormalizedConversation` | `Adapter`, `Trajectory` |
|
|
231
|
+
|
|
232
|
+
## Why not an npm package
|
|
233
|
+
|
|
234
|
+
| Package | Why it fails |
|
|
235
|
+
| -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
236
|
+
| `@alwaysmeticulous/agent-traces` 3.2.0 | Used here for Codex only. Its Claude converter reads only `user` and `assistant` lines: it drops `queued_command` prompts, system rows, attachments, `toolUseResult` and `/clear` chains, with no extension points. Its output is ATIF v1.7. |
|
|
237
|
+
| `@letta-ai/trajectory` 0.4.4 | Closed set of sources, a closed schema with no extra slot, and its own format rather than ATIF. |
|
|
238
|
+
| `atifact` 0.16.0 | Reads `claude -p` stream-json only, not stored sessions. |
|
|
239
|
+
| `@kontourai/thread` 0.7.0 | Its own format, and young. |
|
|
240
|
+
| `@anthropic-ai/claude-agent-sdk` | Claude only; one reader per agent was rejected. Its messages drop attachments and system rows; its raw store API is alpha. |
|
|
241
|
+
| franken-agent-detection (crate) | Rust only, and it also drops attachments, system rows and `toolUseResult`. |
|
|
242
|
+
|
|
243
|
+
## Who uses what
|
|
244
|
+
|
|
245
|
+
| Consumer | Uses |
|
|
246
|
+
| --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
|
|
247
|
+
| agent-plugin `hooks/compile-guard` | `fromTranscriptPath`, `read({ subagents: false })`, agent `tool_calls` |
|
|
248
|
+
| agent-plugin `hooks/ezzs-way-of-coding` stop and verification rules | `read`, user steps by origin, system steps (`stop_hook_summary`), last agent message, subagent transcript |
|
|
249
|
+
| deepagents `experimental/coding-agent-reminders` | `read`, user steps by origin, `hook_additional_context` system steps |
|
|
250
|
+
| agent-plugin housekeeping `close-check` / `records-check` | `ClaudeCodeStore.chain`, tool calls with results and `tool_use_result` |
|
|
251
|
+
| agent-plugin update-docs evidence | `sessions({ since })`, typed prompts, agent text and tool calls, `cwd` |
|
|
252
|
+
| later: context-compiler sessions connector (#2400), rollover resume (#6075), night-run miners | `sessions({ since })`, `read` |
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Trajectory } from './atif.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The port: turns one located session of one agent into one ATIF trajectory
|
|
4
|
+
* (ADR 0006). Each agent has its own `Session` type, so an adapter cannot be
|
|
5
|
+
* handed another agent's session.
|
|
6
|
+
*/
|
|
7
|
+
export interface Adapter<Session> {
|
|
8
|
+
/** ATIF `agent.name`: `claude-code`, `codex`, … */
|
|
9
|
+
readonly agent: string;
|
|
10
|
+
read(session: Session, options?: ReadOptions): Promise<ReadResult>;
|
|
11
|
+
}
|
|
12
|
+
export interface ReadOptions {
|
|
13
|
+
/** Read the session's subagents into `subagent_trajectories`. Default true. */
|
|
14
|
+
subagents?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface ReadResult {
|
|
17
|
+
trajectory: Trajectory;
|
|
18
|
+
diagnostics: Diagnostic[];
|
|
19
|
+
}
|
|
20
|
+
export type DiagnosticCode =
|
|
21
|
+
/** A line that does not parse as a JSON object. */
|
|
22
|
+
'invalid_json_line'
|
|
23
|
+
/** The last line, still being written by the agent. */
|
|
24
|
+
| 'partial_last_line'
|
|
25
|
+
/** Bookkeeping with no step, counted by entry type. */
|
|
26
|
+
| 'unmapped_entry'
|
|
27
|
+
/** An `isSidechain` row inside a main transcript. */
|
|
28
|
+
| 'sidechain_entry'
|
|
29
|
+
/** A tool result whose call is not in the transcript. */
|
|
30
|
+
| 'orphan_tool_result'
|
|
31
|
+
/** A subagent whose spawning call could not be found. */
|
|
32
|
+
| 'unlinked_subagent'
|
|
33
|
+
/** A subagent transcript that could not be read. */
|
|
34
|
+
| 'unreadable_subagent';
|
|
35
|
+
export interface Diagnostic {
|
|
36
|
+
code: DiagnosticCode;
|
|
37
|
+
/** The file the diagnostic is about. */
|
|
38
|
+
path: string;
|
|
39
|
+
/** 1-based line, for a diagnostic about one line. */
|
|
40
|
+
line?: number;
|
|
41
|
+
/** How many entries it covers, for a counted diagnostic. */
|
|
42
|
+
count?: number;
|
|
43
|
+
/** The entry type an `unmapped_entry` diagnostic counts. */
|
|
44
|
+
entryType?: string;
|
|
45
|
+
message: string;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;GAIG;AACH,MAAM,WAAW,OAAO,CAAC,OAAO;IAC9B,mDAAmD;IACnD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACpE;AAED,MAAM,WAAW,WAAW;IAC1B,+EAA+E;IAC/E,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED,MAAM,MAAM,cAAc;AACxB,mDAAmD;AACjD,mBAAmB;AACrB,uDAAuD;GACrD,mBAAmB;AACrB,uDAAuD;GACrD,gBAAgB;AAClB,qDAAqD;GACnD,iBAAiB;AACnB,yDAAyD;GACvD,oBAAoB;AACtB,yDAAyD;GACvD,mBAAmB;AACrB,oDAAoD;GAClD,qBAAqB,CAAC;AAE1B,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,cAAc,CAAC;IACrB,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
package/dist/atif.d.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ATIF v1.8, the Agent Trajectory Interchange Format, ported from Harbor's
|
|
3
|
+
* Pydantic models (harbor-framework/harbor src/harbor/models/trajectories,
|
|
4
|
+
* RFC 0001). Names, fields and optionality follow Harbor exactly; the two
|
|
5
|
+
* divergences are unions that turn Harbor's runtime validators into types
|
|
6
|
+
* (docs/ported-from-harbor-atif.md, ADR 0002).
|
|
7
|
+
*/
|
|
8
|
+
export declare const ATIF_SCHEMA_VERSION = "ATIF-v1.8";
|
|
9
|
+
export type SchemaVersion = 'ATIF-v1.0' | 'ATIF-v1.1' | 'ATIF-v1.2' | 'ATIF-v1.3' | 'ATIF-v1.4' | 'ATIF-v1.5' | 'ATIF-v1.6' | 'ATIF-v1.7' | 'ATIF-v1.8';
|
|
10
|
+
export type Extra = Record<string, unknown>;
|
|
11
|
+
export interface ImageSource {
|
|
12
|
+
media_type: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp';
|
|
13
|
+
path: string;
|
|
14
|
+
}
|
|
15
|
+
export interface AudioSource {
|
|
16
|
+
media_type: 'audio/wav' | 'audio/mpeg' | 'audio/mp4' | 'audio/aac' | 'audio/ogg' | 'audio/flac' | 'audio/webm' | 'audio/aiff';
|
|
17
|
+
path: string;
|
|
18
|
+
duration_sec?: number | null;
|
|
19
|
+
}
|
|
20
|
+
/** Harbor's `ContentPart`, whose `validate_content_type` becomes this union. */
|
|
21
|
+
export type ContentPart = {
|
|
22
|
+
type: 'text';
|
|
23
|
+
text: string;
|
|
24
|
+
} | {
|
|
25
|
+
type: 'image';
|
|
26
|
+
source: ImageSource;
|
|
27
|
+
} | {
|
|
28
|
+
type: 'audio';
|
|
29
|
+
source: AudioSource;
|
|
30
|
+
};
|
|
31
|
+
export interface ToolCall {
|
|
32
|
+
tool_call_id: string;
|
|
33
|
+
function_name: string;
|
|
34
|
+
arguments: Record<string, unknown>;
|
|
35
|
+
extra?: Extra | null;
|
|
36
|
+
}
|
|
37
|
+
export interface SubagentTrajectoryRef {
|
|
38
|
+
trajectory_id?: string | null;
|
|
39
|
+
session_id?: string | null;
|
|
40
|
+
trajectory_path?: string | null;
|
|
41
|
+
extra?: Extra | null;
|
|
42
|
+
}
|
|
43
|
+
export interface ObservationResult {
|
|
44
|
+
/** A `tool_call_id` of the same step's `tool_calls` (Harbor's `validate_tool_call_references`). */
|
|
45
|
+
source_call_id?: string | null;
|
|
46
|
+
content?: string | ContentPart[] | null;
|
|
47
|
+
subagent_trajectory_ref?: SubagentTrajectoryRef[] | null;
|
|
48
|
+
extra?: Extra | null;
|
|
49
|
+
}
|
|
50
|
+
export interface Observation {
|
|
51
|
+
results: ObservationResult[];
|
|
52
|
+
}
|
|
53
|
+
export interface Metrics {
|
|
54
|
+
prompt_tokens?: number | null;
|
|
55
|
+
completion_tokens?: number | null;
|
|
56
|
+
cached_tokens?: number | null;
|
|
57
|
+
cost_usd?: number | null;
|
|
58
|
+
prompt_token_ids?: number[] | null;
|
|
59
|
+
completion_token_ids?: number[] | null;
|
|
60
|
+
logprobs?: number[] | null;
|
|
61
|
+
extra?: Extra | null;
|
|
62
|
+
}
|
|
63
|
+
export interface FinalMetrics {
|
|
64
|
+
total_prompt_tokens?: number | null;
|
|
65
|
+
total_completion_tokens?: number | null;
|
|
66
|
+
total_cached_tokens?: number | null;
|
|
67
|
+
total_cost_usd?: number | null;
|
|
68
|
+
total_steps?: number | null;
|
|
69
|
+
extra?: Extra | null;
|
|
70
|
+
}
|
|
71
|
+
export interface Agent {
|
|
72
|
+
name: string;
|
|
73
|
+
version: string;
|
|
74
|
+
model_name?: string | null;
|
|
75
|
+
tool_definitions?: Record<string, unknown>[] | null;
|
|
76
|
+
extra?: Extra | null;
|
|
77
|
+
}
|
|
78
|
+
interface StepBase {
|
|
79
|
+
/** Sequential from 1 within one trajectory (Harbor's `validate_step_ids`). */
|
|
80
|
+
step_id: number;
|
|
81
|
+
/** ISO 8601. */
|
|
82
|
+
timestamp?: string | null;
|
|
83
|
+
message: string | ContentPart[];
|
|
84
|
+
observation?: Observation | null;
|
|
85
|
+
is_copied_context?: boolean | null;
|
|
86
|
+
/** 0 on an agent step marks a deterministic dispatch with no model call. */
|
|
87
|
+
llm_call_count?: number | null;
|
|
88
|
+
extra?: Extra | null;
|
|
89
|
+
}
|
|
90
|
+
export interface UserStep extends StepBase {
|
|
91
|
+
source: 'user';
|
|
92
|
+
}
|
|
93
|
+
export interface SystemStep extends StepBase {
|
|
94
|
+
source: 'system';
|
|
95
|
+
}
|
|
96
|
+
/** The only step that may carry a model, reasoning, tool calls and metrics (Harbor's `validate_agent_only_fields`). */
|
|
97
|
+
export interface AgentStep extends StepBase {
|
|
98
|
+
source: 'agent';
|
|
99
|
+
model_name?: string | null;
|
|
100
|
+
reasoning_effort?: string | number | null;
|
|
101
|
+
reasoning_content?: string | null;
|
|
102
|
+
tool_calls?: ToolCall[] | null;
|
|
103
|
+
metrics?: Metrics | null;
|
|
104
|
+
}
|
|
105
|
+
export type Step = UserStep | AgentStep | SystemStep;
|
|
106
|
+
export interface Trajectory {
|
|
107
|
+
schema_version: SchemaVersion;
|
|
108
|
+
/** Run-scoped: segments of one run (a /clear chain, embedded subagents) may share it. */
|
|
109
|
+
session_id?: string | null;
|
|
110
|
+
/** Unique per document; required on every embedded subagent trajectory. */
|
|
111
|
+
trajectory_id?: string | null;
|
|
112
|
+
agent: Agent;
|
|
113
|
+
/** At least one step. */
|
|
114
|
+
steps: [Step, ...Step[]];
|
|
115
|
+
notes?: string | null;
|
|
116
|
+
final_metrics?: FinalMetrics | null;
|
|
117
|
+
continued_trajectory_ref?: string | null;
|
|
118
|
+
extra?: Extra | null;
|
|
119
|
+
subagent_trajectories?: Trajectory[] | null;
|
|
120
|
+
}
|
|
121
|
+
export {};
|
|
122
|
+
//# sourceMappingURL=atif.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atif.d.ts","sources":["../src/atif.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,mBAAmB,cAAc,CAAC;AAE/C,MAAM,MAAM,aAAa,GACrB,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX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AC9B,KAAK,EAAE,KAAK,CAAC;IACb,yBAAyB;IACzB,KAAK,EAAE,CAAC,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,aAAa,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IACpC,wBAAwB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,qBAAqB,CAAC,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;CAC7C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Adapter, ReadOptions, ReadResult } from '../adapter.ts';
|
|
2
|
+
import { ClaudeCodeSession, ClaudeCodeSubagent } from './session.ts';
|
|
3
|
+
/** Reads a Claude Code transcript into an ATIF v1.8 trajectory, as ADR 0004 maps each entry. */
|
|
4
|
+
export declare class ClaudeCodeAdapter implements Adapter<ClaudeCodeSession | ClaudeCodeSubagent> {
|
|
5
|
+
#private;
|
|
6
|
+
readonly agent = "claude-code";
|
|
7
|
+
read(session: ClaudeCodeSession | ClaudeCodeSubagent, options?: ReadOptions): Promise<ReadResult>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sources":["../../src/claude-code/adapter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,OAAO,EAEP,WAAW,EACX,UAAU,EACX,MAAM,eAAe,CAAC;AAYvB,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAIrE,gGAAgG;AAChG,qBAAa,iBAAkB,YAAW,OAAO,CAC/C,iBAAiB,GAAG,kBAAkB,CACvC;;IACC,QAAQ,CAAC,KAAK,iBAAiB;IAEzB,IAAI,CACR,OAAO,EAAE,iBAAiB,GAAG,kBAAkB,EAC/C,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,UAAU,CAAC,CAiHrB;CAoFF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Only the store places a session in a chain; the package index does not export this key. */
|
|
2
|
+
export declare const placeInChain: unique symbol;
|
|
3
|
+
/**
|
|
4
|
+
* One Claude Code session: `<root>/projects/<project>/<session-id>.jsonl` and
|
|
5
|
+
* its `<session-id>/subagents/` folder. Building one touches no disk.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ClaudeCodeSession {
|
|
8
|
+
readonly sessionId: string;
|
|
9
|
+
readonly transcriptPath: string;
|
|
10
|
+
/** The run this segment belongs to: the first session id of its /clear chain (ADR 0007). */
|
|
11
|
+
readonly runId: string;
|
|
12
|
+
/** The next segment's transcript, when the chain continues after this one. */
|
|
13
|
+
readonly continuedBy: string | undefined;
|
|
14
|
+
private constructor();
|
|
15
|
+
/** The session of a main transcript path, such as a hook's `transcript_path`. */
|
|
16
|
+
static fromTranscriptPath(path: string): ClaudeCodeSession;
|
|
17
|
+
/** The chain gives each segment its run and its successor. */
|
|
18
|
+
static [placeInChain](session: ClaudeCodeSession, runId: string, continuedBy: string | undefined): ClaudeCodeSession;
|
|
19
|
+
/** The folder that holds this session's subagent transcripts. */
|
|
20
|
+
get subagentsPath(): string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* One subagent's transcript: `<session-id>/subagents/agent-<agent-id>.jsonl`,
|
|
24
|
+
* with its `.meta.json` beside it. A SubagentStop hook reads it from
|
|
25
|
+
* `agent_transcript_path`. Building one touches no disk.
|
|
26
|
+
*/
|
|
27
|
+
export declare class ClaudeCodeSubagent {
|
|
28
|
+
readonly agentId: string;
|
|
29
|
+
/** The session that started this subagent. */
|
|
30
|
+
readonly sessionId: string;
|
|
31
|
+
readonly transcriptPath: string;
|
|
32
|
+
private constructor();
|
|
33
|
+
/** The subagent of a subagent transcript path, such as a hook's `agent_transcript_path`. */
|
|
34
|
+
static fromTranscriptPath(path: string): ClaudeCodeSubagent;
|
|
35
|
+
/** The `.meta.json` file beside the transcript, which names the call that spawned it. */
|
|
36
|
+
get metaPath(): string;
|
|
37
|
+
/** ATIF's per-document id of this subagent's trajectory. */
|
|
38
|
+
get trajectoryId(): string;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sources":["../../src/claude-code/session.ts"],"names":[],"mappings":"AAIA,8FAA8F;AAC9F,eAAO,MAAM,YAAY,eAAyB,CAAC;AAEnD;;;GAGG;AACH,qBAAa,iBAAiB;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,4FAA4F;IAC5F,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8EAA8E;IAC9E,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAEzC,OAAO,eAUN;IAED,iFAAiF;IACjF,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,CASzD;IAED,8DAA8D;IAC9D,MAAM,CAAC,CAAC,YAAY,CAAC,CACnB,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,iBAAiB,CAOnB;IAED,iEAAiE;IACjE,IAAI,aAAa,IAAI,MAAM,CAE1B;CACF;AAED;;;;GAIG;AACH,qBAAa,kBAAkB;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,8CAA8C;IAC9C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC,OAAO,eAQN;IAED,4FAA4F;IAC5F,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAS1D;IAED,yFAAyF;IACzF,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,4DAA4D;IAC5D,IAAI,YAAY,IAAI,MAAM,CAEzB;CACF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ClaudeCodeSession } from './session.ts';
|
|
2
|
+
/** The segments of one Claude Code session across /clear, and the ids it names whose transcript is gone. */
|
|
3
|
+
export interface ClaudeCodeChain {
|
|
4
|
+
/** Oldest first. */
|
|
5
|
+
readonly sessions: readonly ClaudeCodeSession[];
|
|
6
|
+
/** Ids a `derived-from` entry names whose transcript is not in the store. */
|
|
7
|
+
readonly missing: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A Claude Code store: the folder that holds `projects/`. The root is
|
|
11
|
+
* required, and nothing here reads the home folder, the environment or the
|
|
12
|
+
* clock (ADR 0005).
|
|
13
|
+
*/
|
|
14
|
+
export declare class ClaudeCodeStore {
|
|
15
|
+
#private;
|
|
16
|
+
readonly root: string;
|
|
17
|
+
constructor(options: {
|
|
18
|
+
root: string;
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Each main transcript (`projects/<project>/<id>.jsonl`) changed at or after
|
|
22
|
+
* `since`, newest first. It reads file times only, never their content, and
|
|
23
|
+
* subagent transcripts are not sessions.
|
|
24
|
+
*/
|
|
25
|
+
sessions(options: {
|
|
26
|
+
since: Date;
|
|
27
|
+
}): AsyncIterable<ClaudeCodeSession>;
|
|
28
|
+
/** The session whose transcript a project holds, or undefined when none does. */
|
|
29
|
+
session(sessionId: string): Promise<ClaudeCodeSession | undefined>;
|
|
30
|
+
/**
|
|
31
|
+
* The segments of the session's /clear chain, oldest first (ADR 0007, as
|
|
32
|
+
* agent-plugin housekeeping's `lib/session.mjs` walks it). It follows every
|
|
33
|
+
* `claude_code_session` a `derived-from` entry names, whatever its `via`,
|
|
34
|
+
* skips ids already in the chain (a resume names its own session), and looks
|
|
35
|
+
* beside the current transcript before every project. Each segment carries
|
|
36
|
+
* the chain's first id as its run and the next segment's transcript.
|
|
37
|
+
*/
|
|
38
|
+
chain(session: ClaudeCodeSession): Promise<ClaudeCodeChain>;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sources":["../../src/claude-code/store.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAgB,MAAM,cAAc,CAAC;AAE/D,4GAA4G;AAC5G,MAAM,WAAW,eAAe;IAC9B,oBAAoB;IACpB,QAAQ,CAAC,QAAQ,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAChD,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED;;;;GAIG;AACH,qBAAa,eAAe;;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,YAAY,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAEpC;IAED;;;;OAIG;IACI,QAAQ,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,IAAI,CAAA;KAAE,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAc1E;IAED,iFAAiF;IAC3E,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAOvE;IAED;;;;;;;OAOG;IACG,KAAK,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAyChE;CAOF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Adapter, ReadOptions, ReadResult } from '../adapter.ts';
|
|
2
|
+
import type { CodexThread } from './thread.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Reads a Codex thread into an ATIF v1.8 trajectory through meticulous's
|
|
5
|
+
* `convertCodexSession` (ADR 0003): it tells typed prompts from injected
|
|
6
|
+
* context, pairs calls with outputs and links subagent threads. This adapter
|
|
7
|
+
* decodes `.jsonl.zst`, which meticulous does not, and maps its v1.7 types
|
|
8
|
+
* onto this package's.
|
|
9
|
+
*/
|
|
10
|
+
export declare class CodexAdapter implements Adapter<CodexThread> {
|
|
11
|
+
readonly agent = "codex";
|
|
12
|
+
read(thread: CodexThread, options?: ReadOptions): Promise<ReadResult>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sources":["../../src/codex/adapter.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAUtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAK/C;;;;;;GAMG;AACH,qBAAa,YAAa,YAAW,OAAO,CAAC,WAAW,CAAC;IACvD,QAAQ,CAAC,KAAK,WAAW;IAEnB,IAAI,CACR,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,UAAU,CAAC,CA6BrB;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CodexThread } from './thread.ts';
|
|
2
|
+
/**
|
|
3
|
+
* A Codex store: the folder that holds `sessions/` and `archived_sessions/`.
|
|
4
|
+
* The root is required, and nothing here reads the home folder, the
|
|
5
|
+
* environment or the clock (ADR 0005).
|
|
6
|
+
*/
|
|
7
|
+
export declare class CodexStore {
|
|
8
|
+
readonly root: string;
|
|
9
|
+
constructor(options: {
|
|
10
|
+
root: string;
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* Each root thread with a rollout changed at or after `since`, newest first.
|
|
14
|
+
* A rollout is `.jsonl` or `.jsonl.zst`. It reads each rollout's first line
|
|
15
|
+
* (`session_meta`) to group a subagent thread under its parent, as
|
|
16
|
+
* meticulous does: the parent is the meta's `session_id` when it differs
|
|
17
|
+
* from the thread id, else its `parent_thread_id`, followed while the parent
|
|
18
|
+
* is among the files, so an orphan is its own root.
|
|
19
|
+
*/
|
|
20
|
+
threads(options: {
|
|
21
|
+
since: Date;
|
|
22
|
+
}): AsyncIterable<CodexThread>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sources":["../../src/codex/store.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAe1C;;;;GAIG;AACH,qBAAa,UAAU;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,YAAY,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAEpC;IAED;;;;;;;OAOG;IACI,OAAO,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,IAAI,CAAA;KAAE,GAAG,aAAa,CAAC,WAAW,CAAC,CA2DnE;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** A subagent thread under a Codex thread. */
|
|
2
|
+
export interface CodexSubagentThread {
|
|
3
|
+
readonly threadId: string;
|
|
4
|
+
/** The thread's rollout files, the original first, then any a revert wrote. */
|
|
5
|
+
readonly rolloutPaths: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* One Codex thread as its rollout files hold it: `<root>/sessions/…/rollout-*.jsonl[.zst]`
|
|
9
|
+
* and `archived_sessions/`, with the threads it spawned. `CodexStore.threads()`
|
|
10
|
+
* builds it from each rollout's `session_meta`.
|
|
11
|
+
*/
|
|
12
|
+
export declare class CodexThread {
|
|
13
|
+
readonly threadId: string;
|
|
14
|
+
/** The thread's rollout files, the original first, then any a revert wrote. */
|
|
15
|
+
readonly rolloutPaths: readonly string[];
|
|
16
|
+
/** Every thread under this one (subagents of subagents too), flat. */
|
|
17
|
+
readonly subagents: readonly CodexSubagentThread[];
|
|
18
|
+
constructor(threadId: string, rolloutPaths: readonly string[], subagents?: readonly CodexSubagentThread[]);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=thread.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thread.d.ts","sources":["../../src/codex/thread.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,+EAA+E;IAC/E,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AAED;;;;GAIG;AACH,qBAAa,WAAW;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,+EAA+E;IAC/E,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,sEAAsE;IACtE,QAAQ,CAAC,SAAS,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAEnD,YACE,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,SAAS,MAAM,EAAE,EAC/B,SAAS,GAAE,SAAS,mBAAmB,EAAO,EAK/C;CACF"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one class a read throws: the session's file is missing, cannot be read
|
|
3
|
+
* or decoded, or holds no step. The caller's next step is the same for each
|
|
4
|
+
* (a hook does not fire, a miner logs and skips), so they share a class and
|
|
5
|
+
* differ only in `cause` (ADR 0009).
|
|
6
|
+
*/
|
|
7
|
+
export declare class SessionReadError extends Error {
|
|
8
|
+
readonly name = "SessionReadError";
|
|
9
|
+
readonly path: string;
|
|
10
|
+
constructor(path: string, message: string, options?: {
|
|
11
|
+
cause?: unknown;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,SAAkB,IAAI,sBAAsB;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,YAAY,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAGvE;CACF"}
|