@ai-devkit/agent-manager 0.27.0 → 0.28.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 +12 -4
- package/dist/__tests__/adapters/CodexAdapter.test.js +199 -0
- package/dist/__tests__/adapters/CodexAdapter.test.js.map +1 -1
- package/dist/__tests__/database/DurableAgentsDatabase.test.js +100 -0
- package/dist/__tests__/database/DurableAgentsDatabase.test.js.map +1 -0
- package/dist/__tests__/print/ClaudePrintAgent.integration.test.js +7 -7
- package/dist/__tests__/print/ClaudePrintAgent.integration.test.js.map +1 -1
- package/dist/__tests__/print/ClaudePrintAgentService.test.js +7 -7
- package/dist/__tests__/print/ClaudePrintAgentService.test.js.map +1 -1
- package/dist/__tests__/print/ClaudePrintRunner.test.js +1 -1
- package/dist/__tests__/print/ClaudePrintRunner.test.js.map +1 -1
- package/dist/__tests__/print/DurableAgent.test.js +17 -0
- package/dist/__tests__/print/DurableAgent.test.js.map +1 -0
- package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js +186 -0
- package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js.map +1 -0
- package/dist/__tests__/print/{PrintAgentStore.test.js → DurableAgentRepository.test.js} +63 -110
- package/dist/__tests__/print/DurableAgentRepository.test.js.map +1 -0
- package/dist/adapters/CodexAdapter.d.ts +1 -0
- package/dist/adapters/CodexAdapter.d.ts.map +1 -1
- package/dist/adapters/CodexAdapter.js +16 -6
- package/dist/adapters/CodexAdapter.js.map +1 -1
- package/dist/database/connection.d.ts.map +1 -1
- package/dist/database/connection.js +17 -9
- package/dist/database/connection.js.map +1 -1
- package/dist/database/migrations/003_durable_agents.sql +43 -0
- package/dist/durable/ClaudeCliProbe.d.ts.map +1 -0
- package/dist/{print → durable}/ClaudeCliProbe.js +1 -1
- package/dist/durable/ClaudeCliProbe.js.map +1 -0
- package/dist/{print → durable}/ClaudePrintAgentService.d.ts +11 -11
- package/dist/durable/ClaudePrintAgentService.d.ts.map +1 -0
- package/dist/{print → durable}/ClaudePrintAgentService.js +12 -12
- package/dist/durable/ClaudePrintAgentService.js.map +1 -0
- package/dist/{print → durable}/ClaudePrintRunner.d.ts +3 -3
- package/dist/durable/ClaudePrintRunner.d.ts.map +1 -0
- package/dist/{print → durable}/ClaudePrintRunner.js +2 -2
- package/dist/durable/ClaudePrintRunner.js.map +1 -0
- package/dist/durable/DurableAgent.d.ts +61 -0
- package/dist/durable/DurableAgent.d.ts.map +1 -0
- package/dist/durable/DurableAgent.js +46 -0
- package/dist/durable/DurableAgent.js.map +1 -0
- package/dist/durable/DurableAgentRepository.d.ts +60 -0
- package/dist/durable/DurableAgentRepository.d.ts.map +1 -0
- package/dist/durable/DurableAgentRepository.js +325 -0
- package/dist/durable/DurableAgentRepository.js.map +1 -0
- package/dist/index.d.ts +11 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/adapters/CodexAdapter.test.ts +132 -0
- package/src/__tests__/database/DurableAgentsDatabase.test.ts +77 -0
- package/src/__tests__/print/ClaudePrintAgent.integration.test.ts +6 -6
- package/src/__tests__/print/ClaudePrintAgentService.test.ts +7 -7
- package/src/__tests__/print/ClaudePrintRunner.test.ts +3 -3
- package/src/__tests__/print/{PrintAgent.test.ts → DurableAgent.test.ts} +6 -6
- package/src/__tests__/print/DurableAgentRepository.sqlite.test.ts +105 -0
- package/src/__tests__/print/DurableAgentRepository.test.ts +163 -0
- package/src/adapters/CodexAdapter.ts +14 -11
- package/src/database/connection.ts +15 -9
- package/src/database/migrations/003_durable_agents.sql +43 -0
- package/src/{print → durable}/ClaudeCliProbe.ts +1 -1
- package/src/{print → durable}/ClaudePrintAgentService.ts +21 -21
- package/src/{print → durable}/ClaudePrintRunner.ts +4 -4
- package/src/durable/DurableAgent.ts +91 -0
- package/src/durable/DurableAgentRepository.ts +307 -0
- package/src/index.ts +26 -25
- package/dist/__tests__/print/PrintAgent.test.js +0 -17
- package/dist/__tests__/print/PrintAgent.test.js.map +0 -1
- package/dist/__tests__/print/PrintAgentStore.test.js.map +0 -1
- package/dist/print/ClaudeCliProbe.d.ts.map +0 -1
- package/dist/print/ClaudeCliProbe.js.map +0 -1
- package/dist/print/ClaudePrintAgentService.d.ts.map +0 -1
- package/dist/print/ClaudePrintAgentService.js.map +0 -1
- package/dist/print/ClaudePrintRunner.d.ts.map +0 -1
- package/dist/print/ClaudePrintRunner.js.map +0 -1
- package/dist/print/PrintAgent.d.ts +0 -57
- package/dist/print/PrintAgent.d.ts.map +0 -1
- package/dist/print/PrintAgent.js +0 -42
- package/dist/print/PrintAgent.js.map +0 -1
- package/dist/print/PrintAgentStore.d.ts +0 -69
- package/dist/print/PrintAgentStore.d.ts.map +0 -1
- package/dist/print/PrintAgentStore.js +0 -484
- package/dist/print/PrintAgentStore.js.map +0 -1
- package/src/__tests__/print/PrintAgentStore.test.ts +0 -192
- package/src/print/PrintAgent.ts +0 -86
- package/src/print/PrintAgentStore.ts +0 -503
- /package/dist/{print → durable}/ClaudeCliProbe.d.ts +0 -0
|
@@ -11,36 +11,36 @@ afterEach(()=>{
|
|
|
11
11
|
});
|
|
12
12
|
async function loadStore() {
|
|
13
13
|
const api = await import('../../index.js');
|
|
14
|
-
expect(api).toHaveProperty('
|
|
15
|
-
return api.
|
|
14
|
+
expect(api).toHaveProperty('DurableAgentRepository');
|
|
15
|
+
return api.DurableAgentRepository;
|
|
16
16
|
}
|
|
17
17
|
function fixture() {
|
|
18
|
-
const root = fs.mkdtempSync(path.join(os.tmpdir(), '
|
|
18
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'durable-agent-store-'));
|
|
19
19
|
tempDirs.push(root);
|
|
20
20
|
const cwd = path.join(root, 'project');
|
|
21
21
|
fs.mkdirSync(cwd);
|
|
22
22
|
return {
|
|
23
23
|
root,
|
|
24
24
|
cwd,
|
|
25
|
-
|
|
25
|
+
dbPath: path.join(root, 'state', 'agents.db')
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
describe('
|
|
28
|
+
describe('DurableAgentRepository create/list/resolve', ()=>{
|
|
29
29
|
it('creates distinct durable identities with a canonical cwd and lists them', async ()=>{
|
|
30
|
-
const
|
|
31
|
-
const { cwd,
|
|
32
|
-
const
|
|
33
|
-
|
|
30
|
+
const DurableAgentRepository = await loadStore();
|
|
31
|
+
const { cwd, dbPath } = fixture();
|
|
32
|
+
const repository = new DurableAgentRepository({
|
|
33
|
+
dbPath,
|
|
34
34
|
now: ()=>new Date('2026-08-07T09:00:00Z')
|
|
35
35
|
});
|
|
36
|
-
const agent = await
|
|
36
|
+
const agent = await repository.create({
|
|
37
37
|
name: 'reviewer',
|
|
38
38
|
cwd
|
|
39
39
|
});
|
|
40
40
|
expect(agent).toMatchObject({
|
|
41
41
|
name: 'reviewer',
|
|
42
42
|
provider: 'claude',
|
|
43
|
-
mode: '
|
|
43
|
+
mode: 'durable',
|
|
44
44
|
cwd: fs.realpathSync(cwd),
|
|
45
45
|
state: 'ready',
|
|
46
46
|
sessionHealth: 'uninitialized',
|
|
@@ -49,96 +49,53 @@ describe('PrintAgentStore create/list/resolve', ()=>{
|
|
|
49
49
|
expect(agent.id).toMatch(/^[0-9a-f-]{36}$/);
|
|
50
50
|
expect(agent.providerSessionId).toMatch(/^[0-9a-f-]{36}$/);
|
|
51
51
|
expect(agent.id).not.toBe(agent.providerSessionId);
|
|
52
|
-
expect(await
|
|
52
|
+
expect(await repository.list()).toEqual([
|
|
53
53
|
agent
|
|
54
54
|
]);
|
|
55
|
-
expect(fs.
|
|
55
|
+
expect(fs.existsSync(dbPath)).toBe(true);
|
|
56
56
|
});
|
|
57
57
|
it('resolves exact ids and names and rejects duplicate names', async ()=>{
|
|
58
|
-
const
|
|
59
|
-
const { cwd,
|
|
60
|
-
const
|
|
61
|
-
|
|
58
|
+
const DurableAgentRepository = await loadStore();
|
|
59
|
+
const { cwd, dbPath } = fixture();
|
|
60
|
+
const repository = new DurableAgentRepository({
|
|
61
|
+
dbPath
|
|
62
62
|
});
|
|
63
|
-
const agent = await
|
|
63
|
+
const agent = await repository.create({
|
|
64
64
|
name: 'Reviewer',
|
|
65
65
|
cwd
|
|
66
66
|
});
|
|
67
|
-
expect(await
|
|
67
|
+
expect(await repository.resolve(agent.id)).toMatchObject({
|
|
68
68
|
id: agent.id
|
|
69
69
|
});
|
|
70
|
-
expect(await
|
|
70
|
+
expect(await repository.resolve('reviewer')).toMatchObject({
|
|
71
71
|
id: agent.id
|
|
72
72
|
});
|
|
73
|
-
expect(await
|
|
74
|
-
await expect(
|
|
73
|
+
expect(await repository.resolve('view')).toBeNull();
|
|
74
|
+
await expect(repository.create({
|
|
75
75
|
name: 'reviewer',
|
|
76
76
|
cwd
|
|
77
77
|
})).rejects.toMatchObject({
|
|
78
|
-
code: '
|
|
78
|
+
code: 'DURABLE_AGENT_NAME_CONFLICT'
|
|
79
79
|
});
|
|
80
80
|
});
|
|
81
|
-
it('rejects missing cwd
|
|
82
|
-
const
|
|
83
|
-
const { root,
|
|
84
|
-
const
|
|
85
|
-
|
|
81
|
+
it('rejects a missing cwd', async ()=>{
|
|
82
|
+
const DurableAgentRepository = await loadStore();
|
|
83
|
+
const { root, dbPath } = fixture();
|
|
84
|
+
const repository = new DurableAgentRepository({
|
|
85
|
+
dbPath
|
|
86
86
|
});
|
|
87
|
-
await expect(
|
|
87
|
+
await expect(repository.create({
|
|
88
88
|
name: 'missing',
|
|
89
89
|
cwd: path.join(root, 'missing')
|
|
90
90
|
})).rejects.toMatchObject({
|
|
91
|
-
code: '
|
|
92
|
-
});
|
|
93
|
-
fs.mkdirSync(path.dirname(filePath), {
|
|
94
|
-
recursive: true
|
|
95
|
-
});
|
|
96
|
-
fs.writeFileSync(filePath, '{bad json', {
|
|
97
|
-
mode: 0o600
|
|
98
|
-
});
|
|
99
|
-
await expect(store.list()).rejects.toMatchObject({
|
|
100
|
-
code: 'PRINT_AGENT_STORE'
|
|
101
|
-
});
|
|
102
|
-
fs.rmSync(filePath);
|
|
103
|
-
const target = path.join(root, 'target.json');
|
|
104
|
-
fs.writeFileSync(target, JSON.stringify({
|
|
105
|
-
version: 1,
|
|
106
|
-
agents: []
|
|
107
|
-
}));
|
|
108
|
-
fs.symlinkSync(target, filePath);
|
|
109
|
-
await expect(store.create({
|
|
110
|
-
name: 'unsafe',
|
|
111
|
-
cwd
|
|
112
|
-
})).rejects.toMatchObject({
|
|
113
|
-
code: 'PRINT_AGENT_STORE'
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
it('recovers an abandoned old mutation lock after a crash', async ()=>{
|
|
117
|
-
const PrintAgentStore = await loadStore();
|
|
118
|
-
const { cwd, filePath } = fixture();
|
|
119
|
-
fs.mkdirSync(path.dirname(filePath), {
|
|
120
|
-
recursive: true
|
|
121
|
-
});
|
|
122
|
-
const lockPath = `${filePath}.lock`;
|
|
123
|
-
fs.mkdirSync(lockPath);
|
|
124
|
-
const old = new Date(Date.now() - 60_000);
|
|
125
|
-
fs.utimesSync(lockPath, old, old);
|
|
126
|
-
const store = new PrintAgentStore({
|
|
127
|
-
filePath,
|
|
128
|
-
mutationLockStaleMs: 10
|
|
129
|
-
});
|
|
130
|
-
await expect(store.create({
|
|
131
|
-
name: 'recovered',
|
|
132
|
-
cwd
|
|
133
|
-
})).resolves.toMatchObject({
|
|
134
|
-
name: 'recovered'
|
|
91
|
+
code: 'DURABLE_AGENT_REPOSITORY'
|
|
135
92
|
});
|
|
136
93
|
});
|
|
137
94
|
});
|
|
138
|
-
describe('
|
|
95
|
+
describe('DurableAgentRepository run ownership', ()=>{
|
|
139
96
|
it('fails fast when another exact owner is live and completes only for its token', async ()=>{
|
|
140
|
-
const
|
|
141
|
-
const { cwd,
|
|
97
|
+
const DurableAgentRepository = await loadStore();
|
|
98
|
+
const { cwd, dbPath } = fixture();
|
|
142
99
|
const live = new Map([
|
|
143
100
|
[
|
|
144
101
|
process.pid,
|
|
@@ -154,27 +111,27 @@ describe('PrintAgentStore run ownership', ()=>{
|
|
|
154
111
|
} : null;
|
|
155
112
|
}
|
|
156
113
|
};
|
|
157
|
-
const
|
|
158
|
-
|
|
114
|
+
const repository = new DurableAgentRepository({
|
|
115
|
+
dbPath,
|
|
159
116
|
processInspector
|
|
160
117
|
});
|
|
161
|
-
const agent = await
|
|
118
|
+
const agent = await repository.create({
|
|
162
119
|
name: 'runner',
|
|
163
120
|
cwd
|
|
164
121
|
});
|
|
165
|
-
const acquired = await
|
|
166
|
-
await expect(
|
|
167
|
-
code: '
|
|
122
|
+
const acquired = await repository.acquireRun(agent.id);
|
|
123
|
+
await expect(repository.acquireRun(agent.id)).rejects.toMatchObject({
|
|
124
|
+
code: 'DURABLE_AGENT_BUSY'
|
|
168
125
|
});
|
|
169
|
-
await expect(
|
|
126
|
+
await expect(repository.completeRun(agent.id, 'wrong-token', {
|
|
170
127
|
status: 'succeeded',
|
|
171
128
|
exitCode: 0,
|
|
172
129
|
summary: 'done',
|
|
173
130
|
sessionHealth: 'healthy'
|
|
174
131
|
})).rejects.toMatchObject({
|
|
175
|
-
code: '
|
|
132
|
+
code: 'DURABLE_AGENT_REPOSITORY'
|
|
176
133
|
});
|
|
177
|
-
const completed = await
|
|
134
|
+
const completed = await repository.completeRun(agent.id, acquired.token, {
|
|
178
135
|
status: 'succeeded',
|
|
179
136
|
exitCode: 0,
|
|
180
137
|
summary: 'done',
|
|
@@ -187,8 +144,8 @@ describe('PrintAgentStore run ownership', ()=>{
|
|
|
187
144
|
});
|
|
188
145
|
});
|
|
189
146
|
it('retains busy for a live provider then recovers a dead run without signaling it', async ()=>{
|
|
190
|
-
const
|
|
191
|
-
const { cwd,
|
|
147
|
+
const DurableAgentRepository = await loadStore();
|
|
148
|
+
const { cwd, dbPath } = fixture();
|
|
192
149
|
const live = new Map([
|
|
193
150
|
[
|
|
194
151
|
process.pid,
|
|
@@ -208,8 +165,8 @@ describe('PrintAgentStore run ownership', ()=>{
|
|
|
208
165
|
} : null;
|
|
209
166
|
}
|
|
210
167
|
};
|
|
211
|
-
const first = new
|
|
212
|
-
|
|
168
|
+
const first = new DurableAgentRepository({
|
|
169
|
+
dbPath,
|
|
213
170
|
processInspector
|
|
214
171
|
});
|
|
215
172
|
const agent = await first.create({
|
|
@@ -223,7 +180,7 @@ describe('PrintAgentStore run ownership', ()=>{
|
|
|
223
180
|
});
|
|
224
181
|
live.delete(process.pid);
|
|
225
182
|
await expect(first.acquireRun(agent.id)).rejects.toMatchObject({
|
|
226
|
-
code: '
|
|
183
|
+
code: 'DURABLE_AGENT_BUSY'
|
|
227
184
|
});
|
|
228
185
|
live.delete(4242);
|
|
229
186
|
live.set(process.pid, 'replacement-owner-start');
|
|
@@ -241,17 +198,17 @@ describe('PrintAgentStore run ownership', ()=>{
|
|
|
241
198
|
sessionHealth: 'unknown'
|
|
242
199
|
});
|
|
243
200
|
});
|
|
244
|
-
it('reconciles an
|
|
245
|
-
const
|
|
246
|
-
const {
|
|
201
|
+
it('reconciles an interrupted run to degraded during list', async ()=>{
|
|
202
|
+
const DurableAgentRepository = await loadStore();
|
|
203
|
+
const { cwd, dbPath } = fixture();
|
|
247
204
|
const live = new Map([
|
|
248
205
|
[
|
|
249
206
|
process.pid,
|
|
250
207
|
'owner-start'
|
|
251
208
|
]
|
|
252
209
|
]);
|
|
253
|
-
const
|
|
254
|
-
|
|
210
|
+
const repository = new DurableAgentRepository({
|
|
211
|
+
dbPath,
|
|
255
212
|
incompleteLockGraceMs: 10,
|
|
256
213
|
processInspector: {
|
|
257
214
|
getIdentity: (pid)=>{
|
|
@@ -263,17 +220,13 @@ describe('PrintAgentStore run ownership', ()=>{
|
|
|
263
220
|
}
|
|
264
221
|
}
|
|
265
222
|
});
|
|
266
|
-
const agent = await
|
|
223
|
+
const agent = await repository.create({
|
|
267
224
|
name: 'crashed',
|
|
268
225
|
cwd
|
|
269
226
|
});
|
|
270
|
-
await
|
|
271
|
-
const lockPath = path.join(root, 'state', 'print-agent-locks', `${agent.id}.lock`);
|
|
272
|
-
fs.unlinkSync(path.join(lockPath, 'owner.json'));
|
|
273
|
-
const old = new Date(Date.now() - 1000);
|
|
274
|
-
fs.utimesSync(lockPath, old, old);
|
|
227
|
+
await repository.acquireRun(agent.id);
|
|
275
228
|
live.clear();
|
|
276
|
-
const listed = await
|
|
229
|
+
const listed = await repository.list();
|
|
277
230
|
expect(listed[0]).toMatchObject({
|
|
278
231
|
state: 'degraded',
|
|
279
232
|
sessionHealth: 'unknown',
|
|
@@ -284,12 +237,12 @@ describe('PrintAgentStore run ownership', ()=>{
|
|
|
284
237
|
});
|
|
285
238
|
});
|
|
286
239
|
it('rejects send acquisition when the bound cwd is replaced by a symlink', async ()=>{
|
|
287
|
-
const
|
|
288
|
-
const { root, cwd,
|
|
289
|
-
const
|
|
290
|
-
|
|
240
|
+
const DurableAgentRepository = await loadStore();
|
|
241
|
+
const { root, cwd, dbPath } = fixture();
|
|
242
|
+
const repository = new DurableAgentRepository({
|
|
243
|
+
dbPath
|
|
291
244
|
});
|
|
292
|
-
const agent = await
|
|
245
|
+
const agent = await repository.create({
|
|
293
246
|
name: 'bound',
|
|
294
247
|
cwd
|
|
295
248
|
});
|
|
@@ -298,10 +251,10 @@ describe('PrintAgentStore run ownership', ()=>{
|
|
|
298
251
|
fs.renameSync(cwd, moved);
|
|
299
252
|
fs.mkdirSync(other);
|
|
300
253
|
fs.symlinkSync(other, cwd);
|
|
301
|
-
await expect(
|
|
302
|
-
code: '
|
|
254
|
+
await expect(repository.acquireRun(agent.id)).rejects.toMatchObject({
|
|
255
|
+
code: 'DURABLE_AGENT_REPOSITORY'
|
|
303
256
|
});
|
|
304
257
|
});
|
|
305
258
|
});
|
|
306
259
|
|
|
307
|
-
//# sourceMappingURL=
|
|
260
|
+
//# sourceMappingURL=DurableAgentRepository.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/__tests__/print/DurableAgentRepository.test.ts"],"sourcesContent":["import fs from 'fs';\nimport os from 'os';\nimport path from 'path';\nimport { afterEach, describe, expect, it } from 'vitest';\n\nconst tempDirs: string[] = [];\n\nafterEach(() => {\n for (const dir of tempDirs.splice(0)) fs.rmSync(dir, { recursive: true, force: true });\n});\n\nasync function loadStore(): Promise<any> {\n const api = await import('../../index.js') as Record<string, unknown>;\n expect(api).toHaveProperty('DurableAgentRepository');\n return api.DurableAgentRepository;\n}\n\nfunction fixture(): { root: string; cwd: string; dbPath: string } {\n const root = fs.mkdtempSync(path.join(os.tmpdir(), 'durable-agent-store-'));\n tempDirs.push(root);\n const cwd = path.join(root, 'project');\n fs.mkdirSync(cwd);\n return { root, cwd, dbPath: path.join(root, 'state', 'agents.db') };\n}\n\ndescribe('DurableAgentRepository create/list/resolve', () => {\n it('creates distinct durable identities with a canonical cwd and lists them', async () => {\n const DurableAgentRepository = await loadStore();\n const { cwd, dbPath } = fixture();\n const repository = new DurableAgentRepository({ dbPath, now: () => new Date('2026-08-07T09:00:00Z') });\n\n const agent = await repository.create({ name: 'reviewer', cwd });\n\n expect(agent).toMatchObject({\n name: 'reviewer',\n provider: 'claude',\n mode: 'durable',\n cwd: fs.realpathSync(cwd),\n state: 'ready',\n sessionHealth: 'uninitialized',\n activeRun: null,\n });\n expect(agent.id).toMatch(/^[0-9a-f-]{36}$/);\n expect(agent.providerSessionId).toMatch(/^[0-9a-f-]{36}$/);\n expect(agent.id).not.toBe(agent.providerSessionId);\n expect(await repository.list()).toEqual([agent]);\n expect(fs.existsSync(dbPath)).toBe(true);\n });\n\n it('resolves exact ids and names and rejects duplicate names', async () => {\n const DurableAgentRepository = await loadStore();\n const { cwd, dbPath } = fixture();\n const repository = new DurableAgentRepository({ dbPath });\n const agent = await repository.create({ name: 'Reviewer', cwd });\n\n expect(await repository.resolve(agent.id)).toMatchObject({ id: agent.id });\n expect(await repository.resolve('reviewer')).toMatchObject({ id: agent.id });\n expect(await repository.resolve('view')).toBeNull();\n await expect(repository.create({ name: 'reviewer', cwd })).rejects.toMatchObject({\n code: 'DURABLE_AGENT_NAME_CONFLICT',\n });\n });\n\n it('rejects a missing cwd', async () => {\n const DurableAgentRepository = await loadStore();\n const { root, dbPath } = fixture();\n const repository = new DurableAgentRepository({ dbPath });\n\n await expect(repository.create({ name: 'missing', cwd: path.join(root, 'missing') }))\n .rejects.toMatchObject({ code: 'DURABLE_AGENT_REPOSITORY' });\n });\n});\n\ndescribe('DurableAgentRepository run ownership', () => {\n it('fails fast when another exact owner is live and completes only for its token', async () => {\n const DurableAgentRepository = await loadStore();\n const { cwd, dbPath } = fixture();\n const live = new Map<number, string>([[process.pid, 'owner-start']]);\n const processInspector = { getIdentity: (pid: number) => {\n const startedAt = live.get(pid);\n return startedAt ? { pid, startedAt } : null;\n } };\n const repository = new DurableAgentRepository({ dbPath, processInspector });\n const agent = await repository.create({ name: 'runner', cwd });\n\n const acquired = await repository.acquireRun(agent.id);\n await expect(repository.acquireRun(agent.id)).rejects.toMatchObject({ code: 'DURABLE_AGENT_BUSY' });\n await expect(repository.completeRun(agent.id, 'wrong-token', {\n status: 'succeeded', exitCode: 0, summary: 'done', sessionHealth: 'healthy',\n })).rejects.toMatchObject({ code: 'DURABLE_AGENT_REPOSITORY' });\n\n const completed = await repository.completeRun(agent.id, acquired.token, {\n status: 'succeeded', exitCode: 0, summary: 'done', sessionHealth: 'healthy',\n });\n expect(completed).toMatchObject({ state: 'ready', sessionHealth: 'healthy', activeRun: null });\n });\n\n it('retains busy for a live provider then recovers a dead run without signaling it', async () => {\n const DurableAgentRepository = await loadStore();\n const { cwd, dbPath } = fixture();\n const live = new Map<number, string>([[process.pid, 'owner-start'], [4242, 'provider-start']]);\n const processInspector = { getIdentity: (pid: number) => {\n const startedAt = live.get(pid);\n return startedAt ? { pid, startedAt } : null;\n } };\n const first = new DurableAgentRepository({ dbPath, processInspector });\n const agent = await first.create({ name: 'recoverable', cwd });\n const run = await first.acquireRun(agent.id);\n await first.recordProviderProcess(agent.id, run.token, { pid: 4242, startedAt: 'provider-start' });\n\n live.delete(process.pid);\n await expect(first.acquireRun(agent.id)).rejects.toMatchObject({ code: 'DURABLE_AGENT_BUSY' });\n\n live.delete(4242);\n live.set(process.pid, 'replacement-owner-start');\n const recovered = await first.acquireRun(agent.id);\n expect(recovered.agent).toMatchObject({\n state: 'running',\n lastResult: { status: 'interrupted' },\n });\n await first.completeRun(agent.id, recovered.token, {\n status: 'failed', exitCode: 1, summary: 'failed', sessionHealth: 'unknown',\n });\n });\n\n it('reconciles an interrupted run to degraded during list', async () => {\n const DurableAgentRepository = await loadStore();\n const { cwd, dbPath } = fixture();\n const live = new Map<number, string>([[process.pid, 'owner-start']]);\n const repository = new DurableAgentRepository({ dbPath, incompleteLockGraceMs: 10, processInspector: {\n getIdentity: (pid: number) => {\n const startedAt = live.get(pid);\n return startedAt ? { pid, startedAt } : null;\n },\n } });\n const agent = await repository.create({ name: 'crashed', cwd });\n await repository.acquireRun(agent.id);\n live.clear();\n\n const listed = await repository.list();\n\n expect(listed[0]).toMatchObject({\n state: 'degraded',\n sessionHealth: 'unknown',\n activeRun: null,\n lastResult: { status: 'interrupted' },\n });\n });\n\n it('rejects send acquisition when the bound cwd is replaced by a symlink', async () => {\n const DurableAgentRepository = await loadStore();\n const { root, cwd, dbPath } = fixture();\n const repository = new DurableAgentRepository({ dbPath });\n const agent = await repository.create({ name: 'bound', cwd });\n const moved = path.join(root, 'moved-project');\n const other = path.join(root, 'other-project');\n fs.renameSync(cwd, moved);\n fs.mkdirSync(other);\n fs.symlinkSync(other, cwd);\n\n await expect(repository.acquireRun(agent.id)).rejects.toMatchObject({ code: 'DURABLE_AGENT_REPOSITORY' });\n });\n});\n"],"names":["fs","os","path","afterEach","describe","expect","it","tempDirs","dir","splice","rmSync","recursive","force","loadStore","api","toHaveProperty","DurableAgentRepository","fixture","root","mkdtempSync","join","tmpdir","push","cwd","mkdirSync","dbPath","repository","now","Date","agent","create","name","toMatchObject","provider","mode","realpathSync","state","sessionHealth","activeRun","id","toMatch","providerSessionId","not","toBe","list","toEqual","existsSync","resolve","toBeNull","rejects","code","live","Map","process","pid","processInspector","getIdentity","startedAt","get","acquired","acquireRun","completeRun","status","exitCode","summary","completed","token","first","run","recordProviderProcess","delete","set","recovered","lastResult","incompleteLockGraceMs","clear","listed","moved","other","renameSync","symlinkSync"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,SAASC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAS;AAEzD,MAAMC,WAAqB,EAAE;AAE7BJ,UAAU;IACN,KAAK,MAAMK,OAAOD,SAASE,MAAM,CAAC,GAAIT,GAAGU,MAAM,CAACF,KAAK;QAAEG,WAAW;QAAMC,OAAO;IAAK;AACxF;AAEA,eAAeC;IACX,MAAMC,MAAM,MAAM,MAAM,CAAC;IACzBT,OAAOS,KAAKC,cAAc,CAAC;IAC3B,OAAOD,IAAIE,sBAAsB;AACrC;AAEA,SAASC;IACL,MAAMC,OAAOlB,GAAGmB,WAAW,CAACjB,KAAKkB,IAAI,CAACnB,GAAGoB,MAAM,IAAI;IACnDd,SAASe,IAAI,CAACJ;IACd,MAAMK,MAAMrB,KAAKkB,IAAI,CAACF,MAAM;IAC5BlB,GAAGwB,SAAS,CAACD;IACb,OAAO;QAAEL;QAAMK;QAAKE,QAAQvB,KAAKkB,IAAI,CAACF,MAAM,SAAS;IAAa;AACtE;AAEAd,SAAS,8CAA8C;IACnDE,GAAG,2EAA2E;QAC1E,MAAMU,yBAAyB,MAAMH;QACrC,MAAM,EAAEU,GAAG,EAAEE,MAAM,EAAE,GAAGR;QACxB,MAAMS,aAAa,IAAIV,uBAAuB;YAAES;YAAQE,KAAK,IAAM,IAAIC,KAAK;QAAwB;QAEpG,MAAMC,QAAQ,MAAMH,WAAWI,MAAM,CAAC;YAAEC,MAAM;YAAYR;QAAI;QAE9DlB,OAAOwB,OAAOG,aAAa,CAAC;YACxBD,MAAM;YACNE,UAAU;YACVC,M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AC,qBAAqB;IAmB7B,OAAO,CAAC,gBAAgB;IAYxB,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,iBAAiB;IAKzB;;;;;OAKG;IACH,eAAe,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,mBAAmB,EAAE;IA8ChG,OAAO,CAAC,qBAAqB;IAwC7B,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,kBAAkB;IAS1B,OAAO,CAAC,kBAAkB;IAYpB,YAAY,CAAC,IAAI,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAgBzE;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IA0B9B,OAAO,CAAC,6BAA6B;IAarC;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IA8D5B,OAAO,CAAC,sBAAsB;CAGjC"}
|
|
@@ -42,10 +42,13 @@ export class CodexAdapter {
|
|
|
42
42
|
const relevant = filterByProcessNames(snapshot, this.processNames);
|
|
43
43
|
const processes = relevant.filter((process1)=>this.canHandle(process1));
|
|
44
44
|
if (processes.length === 0) return [];
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
const mappingResult = this.mapSessionMappingMatches(processes);
|
|
46
|
+
const { cachedAgents, remaining } = this.tryRegistryCache(mappingResult.fallback);
|
|
47
|
+
if (remaining.length === 0) return [
|
|
48
|
+
...mappingResult.agents,
|
|
49
|
+
...cachedAgents
|
|
50
|
+
];
|
|
51
|
+
const { direct, fallback } = this.tryResumeMatching(remaining);
|
|
49
52
|
const directResult = this.mapDirectMatches(direct);
|
|
50
53
|
const { sessions, contentCache } = this.discoverSessions(fallback);
|
|
51
54
|
if (sessions.length === 0) {
|
|
@@ -678,8 +681,12 @@ export class CodexAdapter {
|
|
|
678
681
|
}
|
|
679
682
|
const ts = this.parseTimestamp(entry.timestamp);
|
|
680
683
|
if (ts) lastTimestamp = ts;
|
|
681
|
-
if (!firstUserMessage
|
|
682
|
-
|
|
684
|
+
if (!firstUserMessage) {
|
|
685
|
+
const message = this.toConversationMessage(entry, false);
|
|
686
|
+
const content = message?.content.trim() ?? '';
|
|
687
|
+
if (message?.role === 'user' && content.length > 0 && !this.isSyntheticUserMessage(content)) {
|
|
688
|
+
firstUserMessage = content;
|
|
689
|
+
}
|
|
683
690
|
}
|
|
684
691
|
}
|
|
685
692
|
const stat = safeStat(filePath);
|
|
@@ -695,6 +702,9 @@ export class CodexAdapter {
|
|
|
695
702
|
sessionFilePath: filePath
|
|
696
703
|
};
|
|
697
704
|
}
|
|
705
|
+
isSyntheticUserMessage(content) {
|
|
706
|
+
return content.startsWith('<environment_context>') && content.includes('</environment_context>');
|
|
707
|
+
}
|
|
698
708
|
}
|
|
699
709
|
|
|
700
710
|
//# sourceMappingURL=CodexAdapter.js.map
|