jg-agent-hq 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +13 -13
- package/api/README.md +91 -102
- package/dist/actions/actions.js +15 -0
- package/dist/cli/cli.js +26 -35
- package/dist/cli/utilities.d.ts +1 -1
- package/dist/cli/utilities.js +8 -25
- package/dist/collaboration/dispatch/types.d.ts +2 -2
- package/dist/contracts/actions/types.d.ts +4 -4
- package/dist/contracts/browser/index.d.ts +1 -3
- package/dist/contracts/browser/index.js +1 -3
- package/dist/contracts/browser/types.d.ts +15 -1447
- package/dist/contracts/browser/types.js +3 -112
- package/dist/contracts/index.d.ts +7 -9
- package/dist/contracts/index.js +5 -7
- package/dist/contracts/plans/index.d.ts +4 -6
- package/dist/contracts/plans/index.js +2 -4
- package/dist/contracts/plans/types.d.ts +38 -905
- package/dist/contracts/plans/types.js +13 -139
- package/dist/contracts/sessions/index.d.ts +2 -0
- package/dist/contracts/sessions/index.js +2 -0
- package/dist/contracts/sessions/types.d.ts +101 -0
- package/dist/contracts/sessions/types.js +43 -0
- package/dist/contracts/types.d.ts +461 -1047
- package/dist/contracts/types.js +8 -0
- package/dist/index.d.ts +2 -4
- package/dist/index.js +1 -3
- package/dist/plans/admission.d.ts +6 -6
- package/dist/plans/admission.js +1 -1
- package/dist/plans/authority.js +15 -13
- package/dist/plans/documents.d.ts +3 -17
- package/dist/plans/documents.js +6 -62
- package/dist/plans/files.d.ts +2 -2
- package/dist/plans/files.js +2 -4
- package/dist/plans/finalization.d.ts +6 -8
- package/dist/plans/finalization.js +25 -26
- package/dist/plans/index.d.ts +2 -3
- package/dist/plans/index.js +1 -2
- package/dist/plans/plans.d.ts +8 -8
- package/dist/plans/plans.js +33 -82
- package/dist/plans/projections.d.ts +2 -2
- package/dist/plans/projections.js +44 -82
- package/dist/plans/revisions.d.ts +4 -5
- package/dist/plans/revisions.js +5 -44
- package/dist/plans/types.d.ts +0 -281
- package/dist/plans/types.js +2 -30
- package/dist/plans/utilities.js +2 -11
- package/dist/providers/claude/agents/agents.d.ts +16 -0
- package/dist/providers/claude/agents/agents.js +80 -0
- package/dist/providers/claude/agents/constants.d.ts +3 -0
- package/dist/providers/claude/agents/constants.js +4 -0
- package/dist/providers/claude/agents/index.d.ts +1 -0
- package/dist/providers/claude/agents/index.js +2 -0
- package/dist/providers/claude/agents/types.d.ts +14 -0
- package/dist/providers/claude/agents/types.js +9 -0
- package/dist/providers/claude/history/history.model.js +2 -0
- package/dist/providers/claude/history/types.d.ts +92 -368
- package/dist/providers/claude/index.d.ts +1 -0
- package/dist/providers/claude/index.js +2 -0
- package/dist/providers/codex/adapter.d.ts +1 -1
- package/dist/providers/codex/adapter.js +26 -3
- package/dist/providers/codex/codex.js +47 -18
- package/dist/providers/codex/events.d.ts +2 -1
- package/dist/providers/codex/events.js +8 -3
- package/dist/providers/codex/index.d.ts +1 -1
- package/dist/providers/codex/index.js +1 -1
- package/dist/providers/codex/rpc.d.ts +9 -4
- package/dist/providers/codex/rpc.js +109 -47
- package/dist/providers/codex/skill-roots/constants.d.ts +4 -0
- package/dist/providers/codex/skill-roots/constants.js +7 -0
- package/dist/providers/codex/skill-roots/index.d.ts +2 -0
- package/dist/providers/codex/skill-roots/index.js +4 -0
- package/dist/providers/codex/skill-roots/skill-roots.d.ts +35 -0
- package/dist/providers/codex/skill-roots/skill-roots.js +93 -0
- package/dist/providers/codex/transformers.d.ts +3 -1
- package/dist/providers/codex/transformers.js +12 -1
- package/dist/providers/codex/types.d.ts +4 -0
- package/dist/providers/codex/types.js +4 -1
- package/dist/providers/codex/websocket/constants.d.ts +11 -0
- package/dist/providers/codex/websocket/constants.js +18 -0
- package/dist/providers/codex/websocket/index.d.ts +1 -0
- package/dist/providers/codex/websocket/index.js +2 -0
- package/dist/providers/codex/websocket/websocket.d.ts +7 -0
- package/dist/providers/codex/websocket/websocket.js +219 -0
- package/dist/providers/index.d.ts +2 -2
- package/dist/providers/index.js +1 -1
- package/dist/providers/process.d.ts +2 -2
- package/dist/providers/process.js +37 -4
- package/dist/providers/registry/registry.js +2 -1
- package/dist/providers/types.d.ts +25 -2
- package/dist/runtime/runtime.d.ts +0 -2
- package/dist/runtime/runtime.js +11 -5
- package/dist/runtime/state/state.d.ts +1 -1
- package/dist/runtime/state/state.js +2 -2
- package/dist/runtime/types.d.ts +0 -2
- package/dist/runtime/types.js +0 -3
- package/dist/sessions/sessions.js +2 -0
- package/dist/snapshots/archive/archive.d.ts +29 -0
- package/dist/snapshots/archive/archive.js +342 -0
- package/dist/snapshots/archive/constants.d.ts +5 -0
- package/dist/snapshots/archive/constants.js +8 -0
- package/dist/snapshots/archive/index.d.ts +1 -0
- package/dist/snapshots/archive/index.js +2 -0
- package/dist/snapshots/artifacts.d.ts +10 -1
- package/dist/snapshots/artifacts.js +38 -13
- package/dist/snapshots/capture.d.ts +3 -2
- package/dist/snapshots/capture.js +29 -13
- package/dist/snapshots/database.d.ts +2 -2
- package/dist/snapshots/database.js +30 -14
- package/dist/snapshots/fences.d.ts +4 -9
- package/dist/snapshots/fences.js +9 -22
- package/dist/snapshots/index.d.ts +1 -2
- package/dist/snapshots/index.js +2 -3
- package/dist/snapshots/snapshots.d.ts +6 -5
- package/dist/snapshots/snapshots.js +13 -13
- package/dist/snapshots/snapshots.worker.js +1 -1
- package/dist/snapshots/types.d.ts +26 -5
- package/dist/snapshots/types.js +15 -4
- package/dist/storage/schema/constants.d.ts +2 -2
- package/dist/storage/schema/constants.js +9 -3
- package/dist/storage/schema/index.d.ts +2 -3
- package/dist/storage/schema/index.js +4 -3
- package/dist/storage/schema/schema.d.ts +10 -8
- package/dist/storage/schema/schema.js +22 -36
- package/dist/storage/schema/types.d.ts +1 -11
- package/dist/storage/schema/types.js +2 -2
- package/dist/storage/storage.d.ts +1 -1
- package/dist/storage/storage.js +2 -2
- package/dist/store/collaboration/collaboration.model.d.ts +2 -2
- package/dist/store/control/types.d.ts +16 -16
- package/dist/store/plans/plans.model.d.ts +3 -105
- package/dist/store/plans/plans.model.js +6 -46
- package/dist/store/schema.d.ts +0 -2
- package/dist/store/schema.js +6 -25
- package/dist/store/schema.sql +90 -16
- package/dist/store/sessions/index.d.ts +1 -0
- package/dist/store/sessions/index.js +2 -0
- package/dist/store/sessions/sessions.model.d.ts +28 -0
- package/dist/store/sessions/sessions.model.js +105 -0
- package/dist/store/store.d.ts +0 -2
- package/dist/store/store.js +13 -9
- package/dist/store/store.worker.js +16 -11
- package/dist/store/types.d.ts +134 -513
- package/dist/store/types.js +21 -7
- package/docs/recovery.md +6 -16
- package/errors/README.md +30 -36
- package/package.json +1 -1
- package/dist/plans/reconciliation.d.ts +0 -34
- package/dist/plans/reconciliation.js +0 -246
- package/dist/storage/schema/v1-to-v2.sql +0 -1
- package/dist/storage/schema/v1.sql +0 -538
- package/dist/storage/upgrade/index.d.ts +0 -2
- package/dist/storage/upgrade/index.js +0 -2
- package/dist/storage/upgrade/types.d.ts +0 -61
- package/dist/storage/upgrade/types.js +0 -42
- package/dist/storage/upgrade/upgrade.d.ts +0 -33
- package/dist/storage/upgrade/upgrade.js +0 -196
- package/dist/storage/upgrade/upgrade.worker.d.ts +0 -1
- package/dist/storage/upgrade/upgrade.worker.js +0 -220
|
@@ -1,27 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { ProviderIdSchema } from '../providers/index.js';
|
|
3
2
|
// execution revisions are independent of exact file inspection hashes
|
|
4
3
|
export const PlanDigestSchema = z.string().regex(/^[a-f0-9]{64}$/);
|
|
5
4
|
export const PlanRevisionSchema = z.strictObject({
|
|
6
5
|
planDigest: PlanDigestSchema,
|
|
7
6
|
breakdownDigest: PlanDigestSchema.nullable(),
|
|
8
7
|
});
|
|
9
|
-
//
|
|
8
|
+
// plan frontmatter beyond the administrative keys, kept as JSON-safe extensions
|
|
10
9
|
export const PlanMetadataSchema = z.strictObject({
|
|
11
|
-
scope: z.string().min(1).max(128),
|
|
12
|
-
repositories: z.array(z.string().min(1).max(128)).max(128),
|
|
13
|
-
errorReservations: z
|
|
14
|
-
.array(z
|
|
15
|
-
.strictObject({
|
|
16
|
-
repository: z.string().min(1).max(128),
|
|
17
|
-
namespace: z.string().min(1).max(256),
|
|
18
|
-
start: z.number().int().safe(),
|
|
19
|
-
end: z.number().int().safe(),
|
|
20
|
-
registryPath: z.string().min(1).max(4096),
|
|
21
|
-
purpose: z.string().min(1).max(4096),
|
|
22
|
-
})
|
|
23
|
-
.refine((reservation) => reservation.end >= reservation.start))
|
|
24
|
-
.max(128),
|
|
25
10
|
extensions: z.record(z.string(), z.json()).default({}),
|
|
26
11
|
});
|
|
27
12
|
export const PlanTargetSchema = z.strictObject({
|
|
@@ -43,7 +28,7 @@ export const PlanMilestoneSchema = z.object({
|
|
|
43
28
|
status: z.enum(['pending', 'in progress', 'done']),
|
|
44
29
|
contractDigest: PlanDigestSchema.nullable(),
|
|
45
30
|
});
|
|
46
|
-
// actual evidence
|
|
31
|
+
// actual evidence stays attached to its milestone ID across jg-breakdown revisions
|
|
47
32
|
export const PlanCheckSchema = z.strictObject({
|
|
48
33
|
command: z.string().min(1).max(4096),
|
|
49
34
|
outcome: z.literal('passed'),
|
|
@@ -75,7 +60,8 @@ export const PlanCompletionSchema = z.strictObject({
|
|
|
75
60
|
checkouts: z.array(PlanWorktreeProofSchema).max(128),
|
|
76
61
|
checks: z.array(PlanCheckSchema).min(1).max(32),
|
|
77
62
|
completedAt: z.number().int(),
|
|
78
|
-
|
|
63
|
+
// the finalization that found this milestone no longer done; the receipt then stops counting
|
|
64
|
+
reopenedBy: z.uuid().nullable(),
|
|
79
65
|
});
|
|
80
66
|
export const PlanSnapshotMilestoneSchema = PlanMilestoneSchema.extend({
|
|
81
67
|
id: z.uuid(),
|
|
@@ -93,36 +79,6 @@ export const PlanCheckpointSchema = z.strictObject({
|
|
|
93
79
|
capturedAt: z.number().int(),
|
|
94
80
|
isQuiescent: z.boolean(),
|
|
95
81
|
});
|
|
96
|
-
// one explicit confirmation covers all unmatched checkpoint entries, including completed work
|
|
97
|
-
export const PlanCorrespondenceSchema = z.strictObject({
|
|
98
|
-
sourceIds: z
|
|
99
|
-
.array(z.uuid())
|
|
100
|
-
.min(1)
|
|
101
|
-
.max(1024)
|
|
102
|
-
.refine((ids) => new Set(ids).size === ids.length),
|
|
103
|
-
targetIds: z
|
|
104
|
-
.array(z.uuid())
|
|
105
|
-
.max(1024)
|
|
106
|
-
.refine((ids) => new Set(ids).size === ids.length),
|
|
107
|
-
relation: z.enum(['equivalent', 'requirements-changed', 'omitted', 'reopened']),
|
|
108
|
-
retainedPairs: z.array(z.strictObject({ sourceId: z.uuid(), targetId: z.uuid() })).max(1024),
|
|
109
|
-
});
|
|
110
|
-
export const PlanDraftMilestoneSchema = PlanSnapshotMilestoneSchema.extend({
|
|
111
|
-
matchedSourceId: z.uuid().nullable(),
|
|
112
|
-
});
|
|
113
|
-
export const PlanProposalSchema = z.strictObject({
|
|
114
|
-
id: z.uuid(),
|
|
115
|
-
revision: PlanRevisionSchema,
|
|
116
|
-
inspectionHash: PlanDigestSchema.nullable(),
|
|
117
|
-
drafts: z.array(PlanDraftMilestoneSchema).max(1024),
|
|
118
|
-
unmatchedSourceIds: z.array(z.uuid()).max(1024),
|
|
119
|
-
confirmation: z
|
|
120
|
-
.strictObject({
|
|
121
|
-
action: PlanOperatorActionSchema,
|
|
122
|
-
decisions: z.array(PlanCorrespondenceSchema).max(1024),
|
|
123
|
-
})
|
|
124
|
-
.nullable(),
|
|
125
|
-
});
|
|
126
82
|
export const PlanRevisionWorkflowSchema = z.strictObject({
|
|
127
83
|
id: z.uuid(),
|
|
128
84
|
action: PlanOperatorActionSchema,
|
|
@@ -134,14 +90,7 @@ export const PlanRevisionWorkflowSchema = z.strictObject({
|
|
|
134
90
|
controls: z
|
|
135
91
|
.array(z.strictObject({ threadId: z.uuid(), interruptActionId: z.uuid(), closeActionId: z.uuid() }))
|
|
136
92
|
.max(32),
|
|
137
|
-
phase: z.enum([
|
|
138
|
-
'quiescing',
|
|
139
|
-
'editing',
|
|
140
|
-
'reconciling',
|
|
141
|
-
'awaiting-approval',
|
|
142
|
-
'blocked',
|
|
143
|
-
'finished',
|
|
144
|
-
]),
|
|
93
|
+
phase: z.enum(['quiescing', 'editing', 'awaiting-approval', 'blocked', 'finished']),
|
|
145
94
|
reason: z.string().max(4096).nullable(),
|
|
146
95
|
threadIds: z.array(z.uuid()).max(32),
|
|
147
96
|
checkouts: z.array(PlanCheckoutSchema).max(128),
|
|
@@ -149,26 +98,9 @@ export const PlanRevisionWorkflowSchema = z.strictObject({
|
|
|
149
98
|
invocation: z
|
|
150
99
|
.strictObject({ action: PlanOperatorActionSchema, skill: z.enum(['jg-plan', 'jg-breakdown']) })
|
|
151
100
|
.nullable(),
|
|
152
|
-
proposal: PlanProposalSchema.nullable(),
|
|
153
101
|
createdAt: z.number().int(),
|
|
154
102
|
hasUncertainEffects: z.boolean(),
|
|
155
103
|
});
|
|
156
|
-
export const PlanCorrespondenceRecordSchema = z.strictObject({
|
|
157
|
-
id: z.uuid(),
|
|
158
|
-
action: PlanOperatorActionSchema,
|
|
159
|
-
revision: PlanRevisionSchema,
|
|
160
|
-
sources: z.array(PlanSnapshotMilestoneSchema).max(1024),
|
|
161
|
-
targets: z
|
|
162
|
-
.array(z.strictObject({
|
|
163
|
-
id: z.uuid(),
|
|
164
|
-
contractDigest: PlanDigestSchema,
|
|
165
|
-
status: PlanMilestoneSchema.shape.status,
|
|
166
|
-
}))
|
|
167
|
-
.max(1024),
|
|
168
|
-
relation: PlanCorrespondenceSchema.shape.relation,
|
|
169
|
-
invalidatedReceiptIds: z.array(z.uuid()).max(1024),
|
|
170
|
-
recordedAt: z.number().int(),
|
|
171
|
-
});
|
|
172
104
|
const MutationFields = {
|
|
173
105
|
target: PlanTargetSchema,
|
|
174
106
|
action: PlanOperatorActionSchema,
|
|
@@ -182,16 +114,8 @@ export const PlanCommandSchema = z.discriminatedUnion('kind', [
|
|
|
182
114
|
limit: z.number().int().min(1).max(128).default(32),
|
|
183
115
|
cursor: z.string().min(1).max(16_384).optional(),
|
|
184
116
|
}),
|
|
185
|
-
z.strictObject({
|
|
186
|
-
|
|
187
|
-
...MutationFields,
|
|
188
|
-
confirmation: z
|
|
189
|
-
.strictObject({
|
|
190
|
-
proposalId: z.uuid(),
|
|
191
|
-
decisions: z.array(PlanCorrespondenceSchema).max(1024),
|
|
192
|
-
})
|
|
193
|
-
.optional(),
|
|
194
|
-
}),
|
|
117
|
+
z.strictObject({ kind: z.literal('register'), target: PlanTargetSchema }),
|
|
118
|
+
z.strictObject({ kind: z.literal('finalize'), ...MutationFields }),
|
|
195
119
|
z.strictObject({
|
|
196
120
|
kind: z.literal('complete'),
|
|
197
121
|
...MutationFields,
|
|
@@ -212,13 +136,6 @@ export const PlanCommandSchema = z.discriminatedUnion('kind', [
|
|
|
212
136
|
revisionId: z.uuid(),
|
|
213
137
|
skill: z.enum(['jg-plan', 'jg-breakdown']),
|
|
214
138
|
}),
|
|
215
|
-
z.strictObject({
|
|
216
|
-
kind: z.literal('reconciliation'),
|
|
217
|
-
target: PlanTargetSchema,
|
|
218
|
-
collection: z.enum(['sources', 'drafts', 'evidence', 'correspondences']),
|
|
219
|
-
limit: z.number().int().min(1).max(128).default(32),
|
|
220
|
-
cursor: z.string().min(1).max(16_384).optional(),
|
|
221
|
-
}),
|
|
222
139
|
z.strictObject({
|
|
223
140
|
kind: z.literal('approve'),
|
|
224
141
|
...MutationFields,
|
|
@@ -271,31 +188,14 @@ export const PlanFinalizationSchema = z.strictObject({
|
|
|
271
188
|
fileHash: PlanDigestSchema.nullable(),
|
|
272
189
|
createdAt: z.number().int(),
|
|
273
190
|
});
|
|
274
|
-
// coordinators own semantic review; the core preserves its exact revision-bound evidence
|
|
275
|
-
export const PlanComparisonSchema = z.strictObject({
|
|
276
|
-
sourceRevision: PlanRevisionSchema,
|
|
277
|
-
targetDirectory: z.string().min(1).max(4096),
|
|
278
|
-
targetRevision: PlanRevisionSchema,
|
|
279
|
-
verdict: z.enum(['compatible', 'contradiction']),
|
|
280
|
-
reason: z.string().min(1).max(4096),
|
|
281
|
-
reviewer: z.strictObject({
|
|
282
|
-
provider: ProviderIdSchema,
|
|
283
|
-
cliVersion: z.string().min(1).max(128),
|
|
284
|
-
model: z.string().min(1).max(256).nullable(),
|
|
285
|
-
reference: z.string().min(1).max(4096),
|
|
286
|
-
}),
|
|
287
|
-
reviewedAt: z.number().int().nonnegative(),
|
|
288
|
-
});
|
|
289
191
|
export const PlanCoordinationSchema = z.strictObject({
|
|
290
192
|
schemaVersion: z.literal(1),
|
|
291
|
-
comparisons: z.array(PlanComparisonSchema).max(1024),
|
|
292
193
|
finalized: PlanFinalizationSchema.nullable(),
|
|
293
194
|
planApproval: PlanApprovalSchema.nullable(),
|
|
294
195
|
sequenceApproval: PlanApprovalSchema.nullable(),
|
|
295
196
|
execution: PlanExecutionSchema.nullable(),
|
|
296
197
|
lastActionId: z.uuid().nullable(),
|
|
297
198
|
completions: z.array(PlanCompletionSchema).max(1024),
|
|
298
|
-
correspondences: z.array(PlanCorrespondenceRecordSchema).max(1024),
|
|
299
199
|
revision: PlanRevisionWorkflowSchema.nullable(),
|
|
300
200
|
baseline: PlanCheckpointSchema.nullable(),
|
|
301
201
|
observedConflict: z
|
|
@@ -311,28 +211,23 @@ export const PlanCoordinationSchema = z.strictObject({
|
|
|
311
211
|
});
|
|
312
212
|
// collection bodies remain in the file owner and paged SQLite projections
|
|
313
213
|
export const PlanCoordinationSummarySchema = PlanCoordinationSchema.omit({
|
|
314
|
-
comparisons: true,
|
|
315
214
|
completions: true,
|
|
316
|
-
correspondences: true,
|
|
317
215
|
revision: true,
|
|
318
216
|
baseline: true,
|
|
319
217
|
}).extend({
|
|
320
|
-
comparisonCount: z.number().int().nonnegative(),
|
|
321
218
|
completionCount: z.number().int().nonnegative(),
|
|
219
|
+
// current receipts whose milestone ID no longer appears in the sequence
|
|
220
|
+
unmatchedEvidence: z
|
|
221
|
+
.array(PlanCompletionSchema.pick({ id: true, milestoneId: true, title: true, completedAt: true }))
|
|
222
|
+
.max(1024),
|
|
322
223
|
revision: PlanRevisionWorkflowSchema.omit({
|
|
323
224
|
checkpoint: true,
|
|
324
|
-
proposal: true,
|
|
325
225
|
checkouts: true,
|
|
326
226
|
controls: true,
|
|
327
227
|
checkpointActionId: true,
|
|
328
228
|
blockActionId: true,
|
|
329
229
|
})
|
|
330
|
-
.extend({
|
|
331
|
-
hasCheckpoint: z.boolean(),
|
|
332
|
-
hasProposal: z.boolean(),
|
|
333
|
-
proposalId: z.uuid().nullable(),
|
|
334
|
-
unmatchedCount: z.number().int().nonnegative(),
|
|
335
|
-
})
|
|
230
|
+
.extend({ hasCheckpoint: z.boolean() })
|
|
336
231
|
.nullable(),
|
|
337
232
|
});
|
|
338
233
|
export const PlanStatusSchema = z.object({
|
|
@@ -361,30 +256,9 @@ export const PlanStatusSchema = z.object({
|
|
|
361
256
|
milestoneCount: z.number().int().min(0).max(1024),
|
|
362
257
|
coordination: PlanCoordinationSummarySchema,
|
|
363
258
|
});
|
|
364
|
-
// paged retained history omits duplicated source contracts from correspondence summaries
|
|
365
|
-
export const PlanCorrespondenceSummarySchema = PlanCorrespondenceRecordSchema.omit({
|
|
366
|
-
sources: true,
|
|
367
|
-
}).extend({
|
|
368
|
-
sources: z
|
|
369
|
-
.array(PlanSnapshotMilestoneSchema.pick({ id: true, contractDigest: true, status: true }))
|
|
370
|
-
.max(1024),
|
|
371
|
-
});
|
|
372
|
-
export const PlanReconciliationEntrySchema = z.discriminatedUnion('kind', [
|
|
373
|
-
z.object({ kind: z.literal('source'), entry: PlanSnapshotMilestoneSchema }),
|
|
374
|
-
z.object({ kind: z.literal('draft'), entry: PlanDraftMilestoneSchema }),
|
|
375
|
-
z.object({ kind: z.literal('evidence'), entry: PlanCompletionSchema }),
|
|
376
|
-
z.object({ kind: z.literal('correspondence'), entry: PlanCorrespondenceSummarySchema }),
|
|
377
|
-
]);
|
|
378
259
|
export const PlanResultSchema = z.discriminatedUnion('kind', [
|
|
379
260
|
z.object({ kind: z.literal('status'), result: PlanStatusSchema }),
|
|
380
|
-
z.object({ kind: z.literal('
|
|
381
|
-
z.object({
|
|
382
|
-
kind: z.literal('reconciliation'),
|
|
383
|
-
result: z.object({
|
|
384
|
-
data: z.array(PlanReconciliationEntrySchema).max(128),
|
|
385
|
-
nextCursor: z.string().nullable(),
|
|
386
|
-
}),
|
|
387
|
-
}),
|
|
261
|
+
z.object({ kind: z.literal('registered'), result: z.object({ directory: z.string() }) }),
|
|
388
262
|
z.object({
|
|
389
263
|
kind: z.literal('finalized'),
|
|
390
264
|
result: PlanStatusSchema,
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const SessionStateSchema: z.ZodEnum<{
|
|
3
|
+
unknown: "unknown";
|
|
4
|
+
idle: "idle";
|
|
5
|
+
failed: "failed";
|
|
6
|
+
running: "running";
|
|
7
|
+
waiting: "waiting";
|
|
8
|
+
closed: "closed";
|
|
9
|
+
}>;
|
|
10
|
+
export type ISessionState = z.infer<typeof SessionStateSchema>;
|
|
11
|
+
export declare const SessionTransitionReasonSchema: z.ZodEnum<{
|
|
12
|
+
failed: "failed";
|
|
13
|
+
closed: "closed";
|
|
14
|
+
opened: "opened";
|
|
15
|
+
"turn-started": "turn-started";
|
|
16
|
+
"turn-completed": "turn-completed";
|
|
17
|
+
"waiting-for-input": "waiting-for-input";
|
|
18
|
+
"operator-stopped": "operator-stopped";
|
|
19
|
+
disappeared: "disappeared";
|
|
20
|
+
}>;
|
|
21
|
+
export type ISessionTransitionReason = z.infer<typeof SessionTransitionReasonSchema>;
|
|
22
|
+
export declare const SessionTransitionSchema: z.ZodObject<{
|
|
23
|
+
sequence: z.ZodNumber;
|
|
24
|
+
provider: z.ZodString;
|
|
25
|
+
nativeId: z.ZodNullable<z.ZodString>;
|
|
26
|
+
threadId: z.ZodNullable<z.ZodUUID>;
|
|
27
|
+
ownership: z.ZodEnum<{
|
|
28
|
+
external: "external";
|
|
29
|
+
managed: "managed";
|
|
30
|
+
uncertain: "uncertain";
|
|
31
|
+
}>;
|
|
32
|
+
previousState: z.ZodNullable<z.ZodEnum<{
|
|
33
|
+
unknown: "unknown";
|
|
34
|
+
idle: "idle";
|
|
35
|
+
failed: "failed";
|
|
36
|
+
running: "running";
|
|
37
|
+
waiting: "waiting";
|
|
38
|
+
closed: "closed";
|
|
39
|
+
}>>;
|
|
40
|
+
state: z.ZodEnum<{
|
|
41
|
+
unknown: "unknown";
|
|
42
|
+
idle: "idle";
|
|
43
|
+
failed: "failed";
|
|
44
|
+
running: "running";
|
|
45
|
+
waiting: "waiting";
|
|
46
|
+
closed: "closed";
|
|
47
|
+
}>;
|
|
48
|
+
reason: z.ZodEnum<{
|
|
49
|
+
failed: "failed";
|
|
50
|
+
closed: "closed";
|
|
51
|
+
opened: "opened";
|
|
52
|
+
"turn-started": "turn-started";
|
|
53
|
+
"turn-completed": "turn-completed";
|
|
54
|
+
"waiting-for-input": "waiting-for-input";
|
|
55
|
+
"operator-stopped": "operator-stopped";
|
|
56
|
+
disappeared: "disappeared";
|
|
57
|
+
}>;
|
|
58
|
+
recordedAt: z.ZodNumber;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
export type ISessionTransition = z.infer<typeof SessionTransitionSchema>;
|
|
61
|
+
export declare const SessionTransitionPageSchema: z.ZodObject<{
|
|
62
|
+
data: z.ZodArray<z.ZodObject<{
|
|
63
|
+
sequence: z.ZodNumber;
|
|
64
|
+
provider: z.ZodString;
|
|
65
|
+
nativeId: z.ZodNullable<z.ZodString>;
|
|
66
|
+
threadId: z.ZodNullable<z.ZodUUID>;
|
|
67
|
+
ownership: z.ZodEnum<{
|
|
68
|
+
external: "external";
|
|
69
|
+
managed: "managed";
|
|
70
|
+
uncertain: "uncertain";
|
|
71
|
+
}>;
|
|
72
|
+
previousState: z.ZodNullable<z.ZodEnum<{
|
|
73
|
+
unknown: "unknown";
|
|
74
|
+
idle: "idle";
|
|
75
|
+
failed: "failed";
|
|
76
|
+
running: "running";
|
|
77
|
+
waiting: "waiting";
|
|
78
|
+
closed: "closed";
|
|
79
|
+
}>>;
|
|
80
|
+
state: z.ZodEnum<{
|
|
81
|
+
unknown: "unknown";
|
|
82
|
+
idle: "idle";
|
|
83
|
+
failed: "failed";
|
|
84
|
+
running: "running";
|
|
85
|
+
waiting: "waiting";
|
|
86
|
+
closed: "closed";
|
|
87
|
+
}>;
|
|
88
|
+
reason: z.ZodEnum<{
|
|
89
|
+
failed: "failed";
|
|
90
|
+
closed: "closed";
|
|
91
|
+
opened: "opened";
|
|
92
|
+
"turn-started": "turn-started";
|
|
93
|
+
"turn-completed": "turn-completed";
|
|
94
|
+
"waiting-for-input": "waiting-for-input";
|
|
95
|
+
"operator-stopped": "operator-stopped";
|
|
96
|
+
disappeared: "disappeared";
|
|
97
|
+
}>;
|
|
98
|
+
recordedAt: z.ZodNumber;
|
|
99
|
+
}, z.core.$strip>>;
|
|
100
|
+
hasMore: z.ZodBoolean;
|
|
101
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { NativeIdSchema } from '../identities/index.js';
|
|
3
|
+
import { ProviderIdSchema } from '../providers/index.js';
|
|
4
|
+
// the live state shared by managed sessions and sessions another client drives
|
|
5
|
+
export const SessionStateSchema = z.enum([
|
|
6
|
+
'running',
|
|
7
|
+
'waiting',
|
|
8
|
+
'idle',
|
|
9
|
+
'closed',
|
|
10
|
+
'failed',
|
|
11
|
+
'unknown',
|
|
12
|
+
]);
|
|
13
|
+
// why a session entered its new state
|
|
14
|
+
export const SessionTransitionReasonSchema = z.enum([
|
|
15
|
+
'opened',
|
|
16
|
+
'turn-started',
|
|
17
|
+
'turn-completed',
|
|
18
|
+
'waiting-for-input',
|
|
19
|
+
'operator-stopped',
|
|
20
|
+
'failed',
|
|
21
|
+
'disappeared',
|
|
22
|
+
'closed',
|
|
23
|
+
]);
|
|
24
|
+
/*
|
|
25
|
+
* One recorded state change, in sequence order. A managed session carries its HQ thread ID and
|
|
26
|
+
* may have no native ID while it is created; an observed session has only its native identity.
|
|
27
|
+
*/
|
|
28
|
+
export const SessionTransitionSchema = z.object({
|
|
29
|
+
sequence: z.number().int().positive(),
|
|
30
|
+
provider: ProviderIdSchema,
|
|
31
|
+
nativeId: NativeIdSchema.nullable(),
|
|
32
|
+
threadId: z.uuid().nullable(),
|
|
33
|
+
ownership: z.enum(['external', 'managed', 'uncertain']),
|
|
34
|
+
previousState: SessionStateSchema.nullable(),
|
|
35
|
+
state: SessionStateSchema,
|
|
36
|
+
reason: SessionTransitionReasonSchema,
|
|
37
|
+
recordedAt: z.number().int(),
|
|
38
|
+
});
|
|
39
|
+
// transitions after a sequence cursor; continue with the last returned sequence
|
|
40
|
+
export const SessionTransitionPageSchema = z.object({
|
|
41
|
+
data: z.array(SessionTransitionSchema).max(128),
|
|
42
|
+
hasMore: z.boolean(),
|
|
43
|
+
});
|