@a5c-ai/babysitter-sdk 0.0.169 → 0.0.170-staging.00aac85c
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/dist/cli/commands/configure.d.ts +124 -0
- package/dist/cli/commands/configure.d.ts.map +1 -0
- package/dist/cli/commands/configure.js +514 -0
- package/dist/cli/commands/health.d.ts +89 -0
- package/dist/cli/commands/health.d.ts.map +1 -0
- package/dist/cli/commands/health.js +579 -0
- package/dist/cli/commands/hookLog.d.ts +15 -0
- package/dist/cli/commands/hookLog.d.ts.map +1 -0
- package/dist/cli/commands/hookLog.js +286 -0
- package/dist/cli/commands/hookRun.d.ts +20 -0
- package/dist/cli/commands/hookRun.d.ts.map +1 -0
- package/dist/cli/commands/hookRun.js +544 -0
- package/dist/cli/commands/runExecuteTasks.d.ts +42 -0
- package/dist/cli/commands/runExecuteTasks.d.ts.map +1 -0
- package/dist/cli/commands/runExecuteTasks.js +377 -0
- package/dist/cli/commands/runIterate.d.ts +5 -1
- package/dist/cli/commands/runIterate.d.ts.map +1 -1
- package/dist/cli/commands/runIterate.js +75 -6
- package/dist/cli/commands/session.d.ts +97 -0
- package/dist/cli/commands/session.d.ts.map +1 -0
- package/dist/cli/commands/session.js +922 -0
- package/dist/cli/commands/skill.d.ts +87 -0
- package/dist/cli/commands/skill.d.ts.map +1 -0
- package/dist/cli/commands/skill.js +869 -0
- package/dist/cli/completionProof.d.ts +4 -0
- package/dist/cli/completionProof.d.ts.map +1 -0
- package/dist/cli/{completionSecret.js → completionProof.js} +7 -7
- package/dist/cli/main.d.ts +14 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +649 -16
- package/dist/config/defaults.d.ts +165 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +281 -0
- package/dist/config/index.d.ts +25 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +35 -0
- package/dist/hooks/dispatcher.d.ts.map +1 -1
- package/dist/hooks/dispatcher.js +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/runtime/constants.d.ts +1 -1
- package/dist/runtime/constants.d.ts.map +1 -1
- package/dist/runtime/createRun.d.ts.map +1 -1
- package/dist/runtime/createRun.js +7 -3
- package/dist/runtime/exceptions.d.ts +186 -3
- package/dist/runtime/exceptions.d.ts.map +1 -1
- package/dist/runtime/exceptions.js +416 -15
- package/dist/runtime/types.d.ts +1 -0
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/session/index.d.ts +9 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +30 -0
- package/dist/session/parse.d.ts +45 -0
- package/dist/session/parse.d.ts.map +1 -0
- package/dist/session/parse.js +159 -0
- package/dist/session/types.d.ts +194 -0
- package/dist/session/types.d.ts.map +1 -0
- package/dist/session/types.js +45 -0
- package/dist/session/write.d.ts +50 -0
- package/dist/session/write.d.ts.map +1 -0
- package/dist/session/write.js +196 -0
- package/dist/storage/createRunDir.d.ts.map +1 -1
- package/dist/storage/createRunDir.js +1 -0
- package/dist/storage/paths.d.ts +5 -1
- package/dist/storage/paths.d.ts.map +1 -1
- package/dist/storage/paths.js +6 -1
- package/dist/storage/types.d.ts +3 -1
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/tasks/kinds/index.d.ts.map +1 -1
- package/dist/tasks/kinds/index.js +6 -1
- package/dist/testing/runHarness.d.ts.map +1 -1
- package/dist/testing/runHarness.js +5 -1
- package/package.json +1 -2
- package/dist/cli/completionSecret.d.ts +0 -4
- package/dist/cli/completionSecret.d.ts.map +0 -1
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Session state file parsing utilities.
|
|
4
|
+
* Parses markdown files with YAML frontmatter for session state.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DEFAULT_SESSION_STATE = void 0;
|
|
8
|
+
exports.parseYamlFrontmatter = parseYamlFrontmatter;
|
|
9
|
+
exports.parseSessionState = parseSessionState;
|
|
10
|
+
exports.readSessionFile = readSessionFile;
|
|
11
|
+
exports.sessionFileExists = sessionFileExists;
|
|
12
|
+
exports.validateSessionState = validateSessionState;
|
|
13
|
+
exports.getSessionFilePath = getSessionFilePath;
|
|
14
|
+
const node_fs_1 = require("node:fs");
|
|
15
|
+
const types_1 = require("./types");
|
|
16
|
+
/**
|
|
17
|
+
* Default session state values.
|
|
18
|
+
*/
|
|
19
|
+
exports.DEFAULT_SESSION_STATE = {
|
|
20
|
+
active: false,
|
|
21
|
+
iteration: 1,
|
|
22
|
+
maxIterations: 256,
|
|
23
|
+
runId: '',
|
|
24
|
+
startedAt: '',
|
|
25
|
+
lastIterationAt: '',
|
|
26
|
+
iterationTimes: [],
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Parse YAML frontmatter from a string.
|
|
30
|
+
* Expects format:
|
|
31
|
+
* ```
|
|
32
|
+
* ---
|
|
33
|
+
* key: value
|
|
34
|
+
* ---
|
|
35
|
+
* content
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
function parseYamlFrontmatter(content) {
|
|
39
|
+
const lines = content.split('\n');
|
|
40
|
+
const frontmatter = {};
|
|
41
|
+
let inFrontmatter = false;
|
|
42
|
+
let frontmatterEnd = -1;
|
|
43
|
+
for (let i = 0; i < lines.length; i++) {
|
|
44
|
+
const line = lines[i].trim();
|
|
45
|
+
if (line === '---') {
|
|
46
|
+
if (!inFrontmatter) {
|
|
47
|
+
inFrontmatter = true;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
frontmatterEnd = i;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (inFrontmatter && line) {
|
|
56
|
+
const colonIndex = line.indexOf(':');
|
|
57
|
+
if (colonIndex > 0) {
|
|
58
|
+
const key = line.slice(0, colonIndex).trim();
|
|
59
|
+
let value = line.slice(colonIndex + 1).trim();
|
|
60
|
+
// Remove surrounding quotes if present
|
|
61
|
+
if ((value.startsWith('"') && value.endsWith('"')) ||
|
|
62
|
+
(value.startsWith("'") && value.endsWith("'"))) {
|
|
63
|
+
value = value.slice(1, -1);
|
|
64
|
+
}
|
|
65
|
+
frontmatter[key] = value;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const body = frontmatterEnd >= 0
|
|
70
|
+
? lines.slice(frontmatterEnd + 1).join('\n').trim()
|
|
71
|
+
: content;
|
|
72
|
+
return { frontmatter, body };
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Parse session state from YAML frontmatter values.
|
|
76
|
+
*/
|
|
77
|
+
function parseSessionState(frontmatter) {
|
|
78
|
+
const parseNumber = (value, defaultValue) => {
|
|
79
|
+
if (!value)
|
|
80
|
+
return defaultValue;
|
|
81
|
+
const parsed = parseInt(value, 10);
|
|
82
|
+
return Number.isFinite(parsed) ? parsed : defaultValue;
|
|
83
|
+
};
|
|
84
|
+
const parseBoolean = (value, defaultValue) => {
|
|
85
|
+
if (!value)
|
|
86
|
+
return defaultValue;
|
|
87
|
+
return value.toLowerCase() === 'true';
|
|
88
|
+
};
|
|
89
|
+
const parseNumberArray = (value) => {
|
|
90
|
+
if (!value || value.trim() === '')
|
|
91
|
+
return [];
|
|
92
|
+
return value
|
|
93
|
+
.split(',')
|
|
94
|
+
.map(s => parseInt(s.trim(), 10))
|
|
95
|
+
.filter(n => Number.isFinite(n) && n > 0);
|
|
96
|
+
};
|
|
97
|
+
return {
|
|
98
|
+
active: parseBoolean(frontmatter.active, exports.DEFAULT_SESSION_STATE.active),
|
|
99
|
+
iteration: parseNumber(frontmatter.iteration, exports.DEFAULT_SESSION_STATE.iteration),
|
|
100
|
+
maxIterations: parseNumber(frontmatter.max_iterations, exports.DEFAULT_SESSION_STATE.maxIterations),
|
|
101
|
+
runId: frontmatter.run_id ?? exports.DEFAULT_SESSION_STATE.runId,
|
|
102
|
+
startedAt: frontmatter.started_at ?? exports.DEFAULT_SESSION_STATE.startedAt,
|
|
103
|
+
lastIterationAt: frontmatter.last_iteration_at ?? exports.DEFAULT_SESSION_STATE.lastIterationAt,
|
|
104
|
+
iterationTimes: parseNumberArray(frontmatter.iteration_times),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Read and parse a session state file.
|
|
109
|
+
*/
|
|
110
|
+
async function readSessionFile(filePath) {
|
|
111
|
+
let content;
|
|
112
|
+
try {
|
|
113
|
+
content = await node_fs_1.promises.readFile(filePath, 'utf8');
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
const err = error;
|
|
117
|
+
if (err.code === 'ENOENT') {
|
|
118
|
+
throw new types_1.SessionError(`Session state file not found: ${filePath}`, types_1.SessionErrorCode.SESSION_NOT_FOUND, { filePath });
|
|
119
|
+
}
|
|
120
|
+
throw new types_1.SessionError(`Failed to read session state file: ${err.message}`, types_1.SessionErrorCode.FS_ERROR, { filePath, originalError: err.message });
|
|
121
|
+
}
|
|
122
|
+
const { frontmatter, body } = parseYamlFrontmatter(content);
|
|
123
|
+
const state = parseSessionState(frontmatter);
|
|
124
|
+
return {
|
|
125
|
+
state,
|
|
126
|
+
prompt: body,
|
|
127
|
+
filePath,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Check if a session state file exists.
|
|
132
|
+
*/
|
|
133
|
+
async function sessionFileExists(filePath) {
|
|
134
|
+
try {
|
|
135
|
+
await node_fs_1.promises.access(filePath);
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Validate session state values.
|
|
144
|
+
* Throws SessionError if validation fails.
|
|
145
|
+
*/
|
|
146
|
+
function validateSessionState(state) {
|
|
147
|
+
if (typeof state.iteration !== 'number' || !Number.isFinite(state.iteration) || state.iteration < 0) {
|
|
148
|
+
throw new types_1.SessionError(`Invalid iteration value: ${state.iteration}`, types_1.SessionErrorCode.INVALID_STATE_VALUE, { field: 'iteration', value: state.iteration });
|
|
149
|
+
}
|
|
150
|
+
if (typeof state.maxIterations !== 'number' || !Number.isFinite(state.maxIterations) || state.maxIterations < 0) {
|
|
151
|
+
throw new types_1.SessionError(`Invalid maxIterations value: ${state.maxIterations}`, types_1.SessionErrorCode.INVALID_STATE_VALUE, { field: 'maxIterations', value: state.maxIterations });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Get the state file path for a session.
|
|
156
|
+
*/
|
|
157
|
+
function getSessionFilePath(stateDir, sessionId) {
|
|
158
|
+
return `${stateDir}/${sessionId}.md`;
|
|
159
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session state management types for babysitter orchestration.
|
|
3
|
+
* These types represent the state stored in markdown files with YAML frontmatter.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Session state stored in the state file's YAML frontmatter.
|
|
7
|
+
*/
|
|
8
|
+
export interface SessionState {
|
|
9
|
+
/** Whether the session is currently active */
|
|
10
|
+
active: boolean;
|
|
11
|
+
/** Current iteration number (1-based) */
|
|
12
|
+
iteration: number;
|
|
13
|
+
/** Maximum allowed iterations (0 = unlimited) */
|
|
14
|
+
maxIterations: number;
|
|
15
|
+
/** Associated run ID (empty string if not yet associated) */
|
|
16
|
+
runId: string;
|
|
17
|
+
/** ISO timestamp when session started */
|
|
18
|
+
startedAt: string;
|
|
19
|
+
/** ISO timestamp of last iteration */
|
|
20
|
+
lastIterationAt: string;
|
|
21
|
+
/** Array of recent iteration durations in seconds (last 3) */
|
|
22
|
+
iterationTimes: number[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Complete session file content including state and prompt.
|
|
26
|
+
*/
|
|
27
|
+
export interface SessionFile {
|
|
28
|
+
/** Parsed YAML frontmatter state */
|
|
29
|
+
state: SessionState;
|
|
30
|
+
/** Prompt content (everything after the YAML frontmatter) */
|
|
31
|
+
prompt: string;
|
|
32
|
+
/** Path to the state file */
|
|
33
|
+
filePath: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Options for initializing a new session.
|
|
37
|
+
*/
|
|
38
|
+
export interface SessionInitOptions {
|
|
39
|
+
/** Claude session ID */
|
|
40
|
+
sessionId: string;
|
|
41
|
+
/** Maximum iterations (default: 256) */
|
|
42
|
+
maxIterations?: number;
|
|
43
|
+
/** Optional run ID if already known */
|
|
44
|
+
runId?: string;
|
|
45
|
+
/** Directory to store state files */
|
|
46
|
+
stateDir: string;
|
|
47
|
+
/** Initial prompt text */
|
|
48
|
+
prompt: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Options for associating a session with a run.
|
|
52
|
+
*/
|
|
53
|
+
export interface SessionAssociateOptions {
|
|
54
|
+
/** Claude session ID */
|
|
55
|
+
sessionId: string;
|
|
56
|
+
/** Run ID to associate */
|
|
57
|
+
runId: string;
|
|
58
|
+
/** Directory containing state files */
|
|
59
|
+
stateDir: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Options for resuming an existing session.
|
|
63
|
+
*/
|
|
64
|
+
export interface SessionResumeOptions {
|
|
65
|
+
/** Claude session ID */
|
|
66
|
+
sessionId: string;
|
|
67
|
+
/** Run ID to resume */
|
|
68
|
+
runId: string;
|
|
69
|
+
/** Maximum iterations (default: 256) */
|
|
70
|
+
maxIterations?: number;
|
|
71
|
+
/** Directory to store state files */
|
|
72
|
+
stateDir: string;
|
|
73
|
+
/** Runs directory (default: .a5c/runs) */
|
|
74
|
+
runsDir?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Options for reading session state.
|
|
78
|
+
*/
|
|
79
|
+
export interface SessionStateOptions {
|
|
80
|
+
/** Claude session ID */
|
|
81
|
+
sessionId: string;
|
|
82
|
+
/** Directory containing state files */
|
|
83
|
+
stateDir: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Options for updating session state.
|
|
87
|
+
*/
|
|
88
|
+
export interface SessionUpdateOptions {
|
|
89
|
+
/** Claude session ID */
|
|
90
|
+
sessionId: string;
|
|
91
|
+
/** Directory containing state files */
|
|
92
|
+
stateDir: string;
|
|
93
|
+
/** New iteration number */
|
|
94
|
+
iteration?: number;
|
|
95
|
+
/** New last iteration timestamp */
|
|
96
|
+
lastIterationAt?: string;
|
|
97
|
+
/** New iteration times array */
|
|
98
|
+
iterationTimes?: number[];
|
|
99
|
+
/** Delete the state file */
|
|
100
|
+
delete?: boolean;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Result of session:init command.
|
|
104
|
+
*/
|
|
105
|
+
export interface SessionInitResult {
|
|
106
|
+
/** Path to created state file */
|
|
107
|
+
stateFile: string;
|
|
108
|
+
/** Initial iteration number */
|
|
109
|
+
iteration: number;
|
|
110
|
+
/** Maximum iterations */
|
|
111
|
+
maxIterations: number;
|
|
112
|
+
/** Run ID (may be empty) */
|
|
113
|
+
runId: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Result of session:associate command.
|
|
117
|
+
*/
|
|
118
|
+
export interface SessionAssociateResult {
|
|
119
|
+
/** Path to updated state file */
|
|
120
|
+
stateFile: string;
|
|
121
|
+
/** Associated run ID */
|
|
122
|
+
runId: string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Result of session:resume command.
|
|
126
|
+
*/
|
|
127
|
+
export interface SessionResumeResult {
|
|
128
|
+
/** Path to created state file */
|
|
129
|
+
stateFile: string;
|
|
130
|
+
/** Run ID being resumed */
|
|
131
|
+
runId: string;
|
|
132
|
+
/** Current run state */
|
|
133
|
+
runState: string;
|
|
134
|
+
/** Process ID from run metadata */
|
|
135
|
+
processId: string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Result of session:state command.
|
|
139
|
+
*/
|
|
140
|
+
export interface SessionStateResult {
|
|
141
|
+
/** Whether state file exists */
|
|
142
|
+
found: boolean;
|
|
143
|
+
/** Session state (if found) */
|
|
144
|
+
state?: SessionState;
|
|
145
|
+
/** Prompt content (if found) */
|
|
146
|
+
prompt?: string;
|
|
147
|
+
/** Path to state file */
|
|
148
|
+
stateFile: string;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Result of session:update command.
|
|
152
|
+
*/
|
|
153
|
+
export interface SessionUpdateResult {
|
|
154
|
+
/** Whether update was successful */
|
|
155
|
+
success: boolean;
|
|
156
|
+
/** Updated state (if not deleted) */
|
|
157
|
+
state?: SessionState;
|
|
158
|
+
/** Whether file was deleted */
|
|
159
|
+
deleted?: boolean;
|
|
160
|
+
/** Path to state file */
|
|
161
|
+
stateFile: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Error thrown when session operations fail.
|
|
165
|
+
*/
|
|
166
|
+
export declare class SessionError extends Error {
|
|
167
|
+
readonly code: SessionErrorCode;
|
|
168
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
169
|
+
constructor(message: string, code: SessionErrorCode, details?: Record<string, unknown> | undefined);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Session error codes.
|
|
173
|
+
*/
|
|
174
|
+
export declare enum SessionErrorCode {
|
|
175
|
+
/** Session ID not provided */
|
|
176
|
+
MISSING_SESSION_ID = "MISSING_SESSION_ID",
|
|
177
|
+
/** State file already exists */
|
|
178
|
+
SESSION_EXISTS = "SESSION_EXISTS",
|
|
179
|
+
/** State file not found */
|
|
180
|
+
SESSION_NOT_FOUND = "SESSION_NOT_FOUND",
|
|
181
|
+
/** Run already associated */
|
|
182
|
+
RUN_ALREADY_ASSOCIATED = "RUN_ALREADY_ASSOCIATED",
|
|
183
|
+
/** Run not found */
|
|
184
|
+
RUN_NOT_FOUND = "RUN_NOT_FOUND",
|
|
185
|
+
/** Run already completed */
|
|
186
|
+
RUN_COMPLETED = "RUN_COMPLETED",
|
|
187
|
+
/** State file corrupted */
|
|
188
|
+
CORRUPTED_STATE = "CORRUPTED_STATE",
|
|
189
|
+
/** Invalid state value */
|
|
190
|
+
INVALID_STATE_VALUE = "INVALID_STATE_VALUE",
|
|
191
|
+
/** File system error */
|
|
192
|
+
FS_ERROR = "FS_ERROR"
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/session/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Session state management types for babysitter orchestration.
|
|
4
|
+
* These types represent the state stored in markdown files with YAML frontmatter.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.SessionErrorCode = exports.SessionError = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Error thrown when session operations fail.
|
|
10
|
+
*/
|
|
11
|
+
class SessionError extends Error {
|
|
12
|
+
code;
|
|
13
|
+
details;
|
|
14
|
+
constructor(message, code, details) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.code = code;
|
|
17
|
+
this.details = details;
|
|
18
|
+
this.name = 'SessionError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.SessionError = SessionError;
|
|
22
|
+
/**
|
|
23
|
+
* Session error codes.
|
|
24
|
+
*/
|
|
25
|
+
var SessionErrorCode;
|
|
26
|
+
(function (SessionErrorCode) {
|
|
27
|
+
/** Session ID not provided */
|
|
28
|
+
SessionErrorCode["MISSING_SESSION_ID"] = "MISSING_SESSION_ID";
|
|
29
|
+
/** State file already exists */
|
|
30
|
+
SessionErrorCode["SESSION_EXISTS"] = "SESSION_EXISTS";
|
|
31
|
+
/** State file not found */
|
|
32
|
+
SessionErrorCode["SESSION_NOT_FOUND"] = "SESSION_NOT_FOUND";
|
|
33
|
+
/** Run already associated */
|
|
34
|
+
SessionErrorCode["RUN_ALREADY_ASSOCIATED"] = "RUN_ALREADY_ASSOCIATED";
|
|
35
|
+
/** Run not found */
|
|
36
|
+
SessionErrorCode["RUN_NOT_FOUND"] = "RUN_NOT_FOUND";
|
|
37
|
+
/** Run already completed */
|
|
38
|
+
SessionErrorCode["RUN_COMPLETED"] = "RUN_COMPLETED";
|
|
39
|
+
/** State file corrupted */
|
|
40
|
+
SessionErrorCode["CORRUPTED_STATE"] = "CORRUPTED_STATE";
|
|
41
|
+
/** Invalid state value */
|
|
42
|
+
SessionErrorCode["INVALID_STATE_VALUE"] = "INVALID_STATE_VALUE";
|
|
43
|
+
/** File system error */
|
|
44
|
+
SessionErrorCode["FS_ERROR"] = "FS_ERROR";
|
|
45
|
+
})(SessionErrorCode || (exports.SessionErrorCode = SessionErrorCode = {}));
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session state file writing utilities.
|
|
3
|
+
* Provides atomic writes for session state files.
|
|
4
|
+
*/
|
|
5
|
+
import type { SessionState } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Serialize session state to YAML frontmatter format.
|
|
8
|
+
*/
|
|
9
|
+
export declare function serializeSessionState(state: SessionState): string;
|
|
10
|
+
/**
|
|
11
|
+
* Create full session file content with YAML frontmatter and prompt.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createSessionFileContent(state: SessionState, prompt: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Write session state file atomically.
|
|
16
|
+
* Uses temp file + rename pattern to ensure atomic writes.
|
|
17
|
+
*/
|
|
18
|
+
export declare function writeSessionFile(filePath: string, state: SessionState, prompt: string): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Update specific fields in an existing session state file.
|
|
21
|
+
* Reads, modifies, and atomically writes the file.
|
|
22
|
+
*/
|
|
23
|
+
export declare function updateSessionState(filePath: string, updates: Partial<SessionState>, existingContent?: {
|
|
24
|
+
state: SessionState;
|
|
25
|
+
prompt: string;
|
|
26
|
+
}): Promise<SessionState>;
|
|
27
|
+
/**
|
|
28
|
+
* Delete session state file.
|
|
29
|
+
*/
|
|
30
|
+
export declare function deleteSessionFile(filePath: string): Promise<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Get current ISO timestamp.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getCurrentTimestamp(): string;
|
|
35
|
+
/**
|
|
36
|
+
* Convert ISO timestamp to epoch seconds.
|
|
37
|
+
* Returns null if conversion fails.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isoToEpochSeconds(isoTimestamp: string): number | null;
|
|
40
|
+
/**
|
|
41
|
+
* Calculate iteration duration and update times array.
|
|
42
|
+
* Keeps only the last 3 durations.
|
|
43
|
+
*/
|
|
44
|
+
export declare function updateIterationTimes(existingTimes: number[], lastIterationAt: string, currentTime: string): number[];
|
|
45
|
+
/**
|
|
46
|
+
* Check if average iteration time indicates runaway loop.
|
|
47
|
+
* Returns true if average of last 3 iterations is <= 15 seconds.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isIterationTooFast(iterationTimes: number[]): boolean;
|
|
50
|
+
//# sourceMappingURL=write.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../src/session/write.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG5C;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAYjE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAGpF;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CA6Bf;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,EAC9B,eAAe,CAAC,EAAE;IAAE,KAAK,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACxD,OAAO,CAAC,YAAY,CAAC,CAyBvB;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAe1E;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CASrE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,MAAM,EAAE,EACvB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,GAClB,MAAM,EAAE,CAgBV;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,OAAO,CAQpE"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Session state file writing utilities.
|
|
4
|
+
* Provides atomic writes for session state files.
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.serializeSessionState = serializeSessionState;
|
|
41
|
+
exports.createSessionFileContent = createSessionFileContent;
|
|
42
|
+
exports.writeSessionFile = writeSessionFile;
|
|
43
|
+
exports.updateSessionState = updateSessionState;
|
|
44
|
+
exports.deleteSessionFile = deleteSessionFile;
|
|
45
|
+
exports.getCurrentTimestamp = getCurrentTimestamp;
|
|
46
|
+
exports.isoToEpochSeconds = isoToEpochSeconds;
|
|
47
|
+
exports.updateIterationTimes = updateIterationTimes;
|
|
48
|
+
exports.isIterationTooFast = isIterationTooFast;
|
|
49
|
+
const node_fs_1 = require("node:fs");
|
|
50
|
+
const path = __importStar(require("node:path"));
|
|
51
|
+
const types_1 = require("./types");
|
|
52
|
+
/**
|
|
53
|
+
* Serialize session state to YAML frontmatter format.
|
|
54
|
+
*/
|
|
55
|
+
function serializeSessionState(state) {
|
|
56
|
+
const lines = [];
|
|
57
|
+
lines.push(`active: ${state.active}`);
|
|
58
|
+
lines.push(`iteration: ${state.iteration}`);
|
|
59
|
+
lines.push(`max_iterations: ${state.maxIterations}`);
|
|
60
|
+
lines.push(`run_id: "${state.runId}"`);
|
|
61
|
+
lines.push(`started_at: "${state.startedAt}"`);
|
|
62
|
+
lines.push(`last_iteration_at: "${state.lastIterationAt}"`);
|
|
63
|
+
lines.push(`iteration_times: ${state.iterationTimes.join(',')}`);
|
|
64
|
+
return lines.join('\n');
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Create full session file content with YAML frontmatter and prompt.
|
|
68
|
+
*/
|
|
69
|
+
function createSessionFileContent(state, prompt) {
|
|
70
|
+
const frontmatter = serializeSessionState(state);
|
|
71
|
+
return `---\n${frontmatter}\n---\n\n${prompt}\n`;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Write session state file atomically.
|
|
75
|
+
* Uses temp file + rename pattern to ensure atomic writes.
|
|
76
|
+
*/
|
|
77
|
+
async function writeSessionFile(filePath, state, prompt) {
|
|
78
|
+
const content = createSessionFileContent(state, prompt);
|
|
79
|
+
const dir = path.dirname(filePath);
|
|
80
|
+
const tempPath = `${filePath}.tmp.${process.pid}`;
|
|
81
|
+
try {
|
|
82
|
+
// Ensure directory exists
|
|
83
|
+
await node_fs_1.promises.mkdir(dir, { recursive: true });
|
|
84
|
+
// Write to temp file
|
|
85
|
+
await node_fs_1.promises.writeFile(tempPath, content, 'utf8');
|
|
86
|
+
// Atomic rename
|
|
87
|
+
await node_fs_1.promises.rename(tempPath, filePath);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
// Clean up temp file on error
|
|
91
|
+
try {
|
|
92
|
+
await node_fs_1.promises.unlink(tempPath);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
// Ignore cleanup errors
|
|
96
|
+
}
|
|
97
|
+
const err = error;
|
|
98
|
+
throw new types_1.SessionError(`Failed to write session state file: ${err.message}`, types_1.SessionErrorCode.FS_ERROR, { filePath, originalError: err.message });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Update specific fields in an existing session state file.
|
|
103
|
+
* Reads, modifies, and atomically writes the file.
|
|
104
|
+
*/
|
|
105
|
+
async function updateSessionState(filePath, updates, existingContent) {
|
|
106
|
+
let state;
|
|
107
|
+
let prompt;
|
|
108
|
+
if (existingContent) {
|
|
109
|
+
state = existingContent.state;
|
|
110
|
+
prompt = existingContent.prompt;
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
// Read existing file
|
|
114
|
+
const { readSessionFile } = await Promise.resolve().then(() => __importStar(require('./parse')));
|
|
115
|
+
const file = await readSessionFile(filePath);
|
|
116
|
+
state = file.state;
|
|
117
|
+
prompt = file.prompt;
|
|
118
|
+
}
|
|
119
|
+
// Apply updates
|
|
120
|
+
const updatedState = {
|
|
121
|
+
...state,
|
|
122
|
+
...updates,
|
|
123
|
+
};
|
|
124
|
+
// Write updated file
|
|
125
|
+
await writeSessionFile(filePath, updatedState, prompt);
|
|
126
|
+
return updatedState;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Delete session state file.
|
|
130
|
+
*/
|
|
131
|
+
async function deleteSessionFile(filePath) {
|
|
132
|
+
try {
|
|
133
|
+
await node_fs_1.promises.unlink(filePath);
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
const err = error;
|
|
138
|
+
if (err.code === 'ENOENT') {
|
|
139
|
+
return false; // File doesn't exist, consider it deleted
|
|
140
|
+
}
|
|
141
|
+
throw new types_1.SessionError(`Failed to delete session state file: ${err.message}`, types_1.SessionErrorCode.FS_ERROR, { filePath, originalError: err.message });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Get current ISO timestamp.
|
|
146
|
+
*/
|
|
147
|
+
function getCurrentTimestamp() {
|
|
148
|
+
return new Date().toISOString().replace(/\.\d{3}Z$/, 'Z');
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Convert ISO timestamp to epoch seconds.
|
|
152
|
+
* Returns null if conversion fails.
|
|
153
|
+
*/
|
|
154
|
+
function isoToEpochSeconds(isoTimestamp) {
|
|
155
|
+
if (!isoTimestamp)
|
|
156
|
+
return null;
|
|
157
|
+
try {
|
|
158
|
+
const date = new Date(isoTimestamp);
|
|
159
|
+
if (Number.isNaN(date.getTime()))
|
|
160
|
+
return null;
|
|
161
|
+
return Math.floor(date.getTime() / 1000);
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Calculate iteration duration and update times array.
|
|
169
|
+
* Keeps only the last 3 durations.
|
|
170
|
+
*/
|
|
171
|
+
function updateIterationTimes(existingTimes, lastIterationAt, currentTime) {
|
|
172
|
+
const lastEpoch = isoToEpochSeconds(lastIterationAt);
|
|
173
|
+
const currentEpoch = isoToEpochSeconds(currentTime);
|
|
174
|
+
if (lastEpoch === null || currentEpoch === null) {
|
|
175
|
+
return existingTimes;
|
|
176
|
+
}
|
|
177
|
+
const duration = currentEpoch - lastEpoch;
|
|
178
|
+
if (duration <= 0) {
|
|
179
|
+
return existingTimes;
|
|
180
|
+
}
|
|
181
|
+
const newTimes = [...existingTimes, duration];
|
|
182
|
+
// Keep only last 3
|
|
183
|
+
return newTimes.slice(-3);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Check if average iteration time indicates runaway loop.
|
|
187
|
+
* Returns true if average of last 3 iterations is <= 15 seconds.
|
|
188
|
+
*/
|
|
189
|
+
function isIterationTooFast(iterationTimes) {
|
|
190
|
+
if (iterationTimes.length < 3) {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
const sum = iterationTimes.reduce((a, b) => a + b, 0);
|
|
194
|
+
const avg = sum / iterationTimes.length;
|
|
195
|
+
return avg <= 15;
|
|
196
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRunDir.d.ts","sourceRoot":"","sources":["../../src/storage/createRunDir.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAyB,WAAW,EAAE,MAAM,SAAS,CAAC;AAkBlF,wBAAsB,YAAY,CAAC,OAAO,EAAE,mBAAmB;;;
|
|
1
|
+
{"version":3,"file":"createRunDir.d.ts","sourceRoot":"","sources":["../../src/storage/createRunDir.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAyB,WAAW,EAAE,MAAM,SAAS,CAAC;AAkBlF,wBAAsB,YAAY,CAAC,OAAO,EAAE,mBAAmB;;;GAmC9D"}
|
|
@@ -34,6 +34,7 @@ async function createRunDir(options) {
|
|
|
34
34
|
processRevision: options.processRevision,
|
|
35
35
|
layoutVersion,
|
|
36
36
|
createdAt,
|
|
37
|
+
...(options.prompt !== undefined ? { prompt: options.prompt } : {}),
|
|
37
38
|
};
|
|
38
39
|
if (options.extraMetadata) {
|
|
39
40
|
Object.assign(metadata, options.extraMetadata);
|
package/dist/storage/paths.d.ts
CHANGED
|
@@ -8,7 +8,11 @@ export declare const RUN_METADATA_FILE = "run.json";
|
|
|
8
8
|
export declare const INPUTS_FILE = "inputs.json";
|
|
9
9
|
export declare const LOCK_FILE = "run.lock";
|
|
10
10
|
export declare const STATE_FILE = "state.json";
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Default storage layout version.
|
|
13
|
+
* @see DEFAULTS.layoutVersion for the centralized default
|
|
14
|
+
*/
|
|
15
|
+
export declare const DEFAULT_LAYOUT_VERSION: string;
|
|
12
16
|
export declare function getRunDir(runsRoot: string, runId: string): string;
|
|
13
17
|
export declare function getJournalDir(runDir: string): string;
|
|
14
18
|
export declare function getTasksDir(runDir: string): string;
|