@catamorphic/fastify-plugin 0.1.0-alpha.38 → 0.1.0-alpha.41
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/NOTICE.txt +7 -0
- package/dist/app.d.ts +2 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/chunk-jytcc42y.js +592 -0
- package/dist/chunk-jytcc42y.js.map +11 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1679 -411
- package/dist/index.js.map +29 -25
- package/dist/mcp-scopes.d.ts +12 -0
- package/dist/mcp-scopes.d.ts.map +1 -0
- package/dist/mcp-server.d.ts +158 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-shared.d.ts +3 -50
- package/dist/mcp-shared.d.ts.map +1 -1
- package/dist/mcp.d.ts +4 -2
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +6 -4
- package/dist/mcp.js.map +1 -1
- package/dist/plugin.d.ts +26 -2
- package/dist/plugin.d.ts.map +1 -1
- package/dist/project-capabilities.d.ts.map +1 -1
- package/dist/project-mcp-surface.d.ts +3 -4
- package/dist/project-mcp-surface.d.ts.map +1 -1
- package/dist/routes/agent.d.ts.map +1 -1
- package/dist/routes/apps-mcp.d.ts.map +1 -1
- package/dist/routes/client-runners.d.ts.map +1 -1
- package/dist/routes/connection-mcp.d.ts.map +1 -1
- package/dist/routes/documents.d.ts.map +1 -1
- package/dist/routes/environments.d.ts.map +1 -1
- package/dist/routes/project-mcp.d.ts.map +1 -1
- package/dist/routes/projects.d.ts.map +1 -1
- package/dist/routes/publications.d.ts.map +1 -1
- package/dist/routes/run-errors.d.ts.map +1 -1
- package/dist/routes/runs.d.ts.map +1 -1
- package/dist/routes/server-mcp.d.ts +17 -0
- package/dist/routes/server-mcp.d.ts.map +1 -0
- package/dist/routes/session-mailboxes.d.ts.map +1 -1
- package/dist/routes/triggers.d.ts.map +1 -1
- package/dist/routes/watchers.d.ts.map +1 -1
- package/dist/routes/workflow-enablements.d.ts.map +1 -1
- package/dist/routes/workflows.d.ts.map +1 -1
- package/dist/schemas.d.ts +3717 -28
- package/dist/schemas.d.ts.map +1 -1
- package/dist/session-mcp.d.ts +54 -0
- package/dist/session-mcp.d.ts.map +1 -0
- package/dist/session-tools.d.ts +49 -0
- package/dist/session-tools.d.ts.map +1 -0
- package/package.json +22 -20
- package/src/app.ts +3 -0
- package/src/index.ts +1 -0
- package/src/mcp-scopes.ts +69 -0
- package/src/mcp-server.ts +827 -0
- package/src/mcp-shared.ts +3 -151
- package/src/mcp.ts +6 -5
- package/src/plugin.ts +73 -2
- package/src/project-capabilities.ts +5 -3
- package/src/project-mcp-program.ts +2 -2
- package/src/project-mcp-surface.ts +18 -239
- package/src/routes/agent.ts +384 -41
- package/src/routes/apps-mcp.ts +84 -82
- package/src/routes/client-runners.ts +3 -1
- package/src/routes/connection-mcp.ts +6 -13
- package/src/routes/documents.ts +4 -0
- package/src/routes/environments.ts +49 -1
- package/src/routes/project-mcp.ts +176 -154
- package/src/routes/projects.ts +6 -0
- package/src/routes/publications.ts +2 -0
- package/src/routes/run-errors.ts +5 -1
- package/src/routes/runs.ts +4 -0
- package/src/routes/server-mcp.ts +151 -0
- package/src/routes/session-mailboxes.ts +1 -0
- package/src/routes/triggers.ts +6 -1
- package/src/routes/watchers.ts +1 -0
- package/src/routes/workflow-enablements.ts +132 -1
- package/src/routes/workflows.ts +4 -0
- package/src/schemas.ts +354 -6
- package/src/session-mcp.ts +696 -0
- package/src/session-tools.ts +169 -0
- package/dist/chunk-baagvvm3.js +0 -164
- package/dist/chunk-baagvvm3.js.map +0 -10
package/src/schemas.ts
CHANGED
|
@@ -46,6 +46,8 @@ import { APP_ICON_NAMES } from "@catamorphic/app";
|
|
|
46
46
|
import {
|
|
47
47
|
RoleDefinitionSchema as CoreRoleDefinitionSchema,
|
|
48
48
|
PROJECT_PERMISSION_PATTERN,
|
|
49
|
+
SESSION_OPERATION_ERROR_CODES,
|
|
50
|
+
SESSION_OPERATIONS,
|
|
49
51
|
type SessionMailboxItem,
|
|
50
52
|
} from "@catamorphic/core";
|
|
51
53
|
import {
|
|
@@ -249,6 +251,15 @@ export const TriggerBindingInfoSchema = z.object({
|
|
|
249
251
|
outputSchema: JsonOutSchema,
|
|
250
252
|
});
|
|
251
253
|
|
|
254
|
+
/**
|
|
255
|
+
* A project store path a workflow reads or writes (ADR 0335): one
|
|
256
|
+
* document, or a folder (ending in `/`) and everything under it.
|
|
257
|
+
*/
|
|
258
|
+
export const WorkflowDocumentAccessSchema = z.object({
|
|
259
|
+
path: z.string(),
|
|
260
|
+
access: z.enum(["read", "write"]),
|
|
261
|
+
});
|
|
262
|
+
|
|
252
263
|
export const WorkflowEnablementOwnerSchema = z.discriminatedUnion("type", [
|
|
253
264
|
z.object({ type: z.literal("member"), externalUserId: z.string().min(1) }),
|
|
254
265
|
z.object({ type: z.literal("project") }),
|
|
@@ -283,6 +294,11 @@ const WorkflowEnablementTargetSchema = z.object({
|
|
|
283
294
|
capabilities: z.array(z.string()),
|
|
284
295
|
/** Project permissions the workflow declares (ADR 0158). */
|
|
285
296
|
permissions: z.array(z.string()),
|
|
297
|
+
/**
|
|
298
|
+
* Project store paths the workflow reads or writes (ADR 0335); a path
|
|
299
|
+
* ending in `/` is a folder.
|
|
300
|
+
*/
|
|
301
|
+
documents: z.array(WorkflowDocumentAccessSchema),
|
|
286
302
|
consentDigest: z.string().length(64),
|
|
287
303
|
});
|
|
288
304
|
|
|
@@ -305,6 +321,11 @@ export const WorkflowEnablementSchema = WorkflowEnablementTargetSchema.extend({
|
|
|
305
321
|
status: z.enum(["active", "suspended", "disabled"]),
|
|
306
322
|
suspensionReason: z.string().nullable(),
|
|
307
323
|
updateAvailable: z.boolean(),
|
|
324
|
+
/**
|
|
325
|
+
* Moves to each newly published revision whose workflow builds and whose
|
|
326
|
+
* authority is unchanged (ADR 0330).
|
|
327
|
+
*/
|
|
328
|
+
follow: z.boolean(),
|
|
308
329
|
temporary: z.boolean(),
|
|
309
330
|
expiresAt: z.string().datetime().nullable(),
|
|
310
331
|
revision: z.number().int().positive(),
|
|
@@ -313,6 +334,38 @@ export const WorkflowEnablementSchema = WorkflowEnablementTargetSchema.extend({
|
|
|
313
334
|
updatedAt: z.string().datetime(),
|
|
314
335
|
});
|
|
315
336
|
|
|
337
|
+
/** One published revision and how it went live (ADRs 0330, 0331). */
|
|
338
|
+
export const PublishedRevisionSchema = z.object({
|
|
339
|
+
id: z.string().uuid(),
|
|
340
|
+
sequence: z.number().int(),
|
|
341
|
+
projectId: z.string().uuid(),
|
|
342
|
+
commitSha: z.string(),
|
|
343
|
+
status: z.enum([
|
|
344
|
+
"pending",
|
|
345
|
+
"deploying",
|
|
346
|
+
"applying",
|
|
347
|
+
"applied",
|
|
348
|
+
"superseded",
|
|
349
|
+
"failed",
|
|
350
|
+
]),
|
|
351
|
+
deployWorkflow: z.string().nullable(),
|
|
352
|
+
deployRunId: z.string().uuid().nullable(),
|
|
353
|
+
previousCommitSha: z.string().nullable(),
|
|
354
|
+
error: z.string().nullable(),
|
|
355
|
+
/** What following the revision did to each following enablement. */
|
|
356
|
+
report: z.array(
|
|
357
|
+
z.object({
|
|
358
|
+
kind: z.enum(["moved", "needs_consent", "skipped", "retry", "unchanged"]),
|
|
359
|
+
enablementId: z.string().uuid(),
|
|
360
|
+
workflowName: z.string(),
|
|
361
|
+
commitSha: z.string().optional(),
|
|
362
|
+
reason: z.string().optional(),
|
|
363
|
+
}),
|
|
364
|
+
),
|
|
365
|
+
createdAt: z.string().datetime(),
|
|
366
|
+
settledAt: z.string().datetime().nullable(),
|
|
367
|
+
});
|
|
368
|
+
|
|
316
369
|
export const WorkflowSummarySchema = z.object({
|
|
317
370
|
name: z.string(),
|
|
318
371
|
capabilities: WorkflowCapabilitiesSchema,
|
|
@@ -475,6 +528,8 @@ export const WorkflowGraphSchema = z.object({
|
|
|
475
528
|
}),
|
|
476
529
|
),
|
|
477
530
|
permissions: z.array(z.string()),
|
|
531
|
+
/** Project store paths its runs read or write (ADR 0335). */
|
|
532
|
+
documents: z.array(WorkflowDocumentAccessSchema),
|
|
478
533
|
canSuspend: z.boolean(),
|
|
479
534
|
nodes: z.array(WorkflowNodeSchema),
|
|
480
535
|
edges: z.array(WorkflowEdgeSchema),
|
|
@@ -488,6 +543,7 @@ export const WorkflowDetailSchema = WorkflowGraphSchema.extend({
|
|
|
488
543
|
|
|
489
544
|
// --- Runs ---
|
|
490
545
|
export const RunStatusSchema = z.enum([
|
|
546
|
+
"queued",
|
|
491
547
|
"pending",
|
|
492
548
|
"running",
|
|
493
549
|
"waiting",
|
|
@@ -635,6 +691,7 @@ export const EnrollmentConflictPolicySchema = z.enum([
|
|
|
635
691
|
"ignore",
|
|
636
692
|
"error",
|
|
637
693
|
"restart",
|
|
694
|
+
"queue",
|
|
638
695
|
]);
|
|
639
696
|
|
|
640
697
|
export const TriggerRunSchema = z.object({
|
|
@@ -649,6 +706,47 @@ export const EnvironmentListQuerySchema = z.object({
|
|
|
649
706
|
agentId: z.string().min(1).optional(),
|
|
650
707
|
});
|
|
651
708
|
|
|
709
|
+
/** One fill of an Environment cache on a machine (ADR 0334). */
|
|
710
|
+
export const CacheFillSchema = z.object({
|
|
711
|
+
id: z.string(),
|
|
712
|
+
environment: z.string(),
|
|
713
|
+
cache: z.string(),
|
|
714
|
+
machine: z.string().nullable(),
|
|
715
|
+
status: z.enum(["queued", "running", "succeeded", "failed", "evicted"]),
|
|
716
|
+
reason: z.enum(["requested", "first-use"]),
|
|
717
|
+
commit: z.string().nullable(),
|
|
718
|
+
generation: z.number().nullable(),
|
|
719
|
+
attempts: z.number(),
|
|
720
|
+
sizeBytes: z.number().nullable(),
|
|
721
|
+
error: z.string().nullable(),
|
|
722
|
+
createdAt: z.string(),
|
|
723
|
+
finishedAt: z.string().nullable(),
|
|
724
|
+
lastUsedAt: z.string().nullable(),
|
|
725
|
+
});
|
|
726
|
+
|
|
727
|
+
/** The project's Environment caches, their copies and recent fills (ADR 0334). */
|
|
728
|
+
export const EnvironmentCacheListSchema = z.object({
|
|
729
|
+
items: z.array(
|
|
730
|
+
z.object({
|
|
731
|
+
environment: z.string(),
|
|
732
|
+
cache: z.string(),
|
|
733
|
+
path: z.string(),
|
|
734
|
+
sizeMb: z.number(),
|
|
735
|
+
copies: z.array(
|
|
736
|
+
z.object({
|
|
737
|
+
machine: z.string(),
|
|
738
|
+
generation: z.number(),
|
|
739
|
+
commit: z.string().nullable(),
|
|
740
|
+
filledAt: z.string().nullable(),
|
|
741
|
+
sizeBytes: z.number().nullable(),
|
|
742
|
+
lastUsedAt: z.string().nullable(),
|
|
743
|
+
}),
|
|
744
|
+
),
|
|
745
|
+
fills: z.array(CacheFillSchema),
|
|
746
|
+
}),
|
|
747
|
+
),
|
|
748
|
+
});
|
|
749
|
+
|
|
652
750
|
export const EnvironmentListSchema = z.object({
|
|
653
751
|
items: z.array(
|
|
654
752
|
z.object({
|
|
@@ -1207,6 +1305,8 @@ export const AgentSessionSchema = z.object({
|
|
|
1207
1305
|
/** Provenance of a chat imported from another tool (ADR 0233). */
|
|
1208
1306
|
imported: ImportedSessionSchema.nullable(),
|
|
1209
1307
|
parentSessionId: z.string().uuid().nullable(),
|
|
1308
|
+
/** The session whose workspace it works in (ADR 0322), if not its own. */
|
|
1309
|
+
workspaceSessionId: z.string().uuid().nullable(),
|
|
1210
1310
|
visibility: z.enum(["latent", "promoted", "archived"]),
|
|
1211
1311
|
archivedAt: z.string().datetime().nullable(),
|
|
1212
1312
|
status: z.enum(["active", "closed"]),
|
|
@@ -1247,12 +1347,48 @@ export const AgentSessionIdParamsSchema = ProjectIdParamsSchema.extend({
|
|
|
1247
1347
|
sessionId: z.string().uuid(),
|
|
1248
1348
|
});
|
|
1249
1349
|
|
|
1350
|
+
export const AgentSessionUsageQuerySchema = z.object({
|
|
1351
|
+
/** Include every subsession below the chat. */
|
|
1352
|
+
family: z
|
|
1353
|
+
.enum(["true", "false"])
|
|
1354
|
+
.transform((value) => value === "true")
|
|
1355
|
+
.optional(),
|
|
1356
|
+
});
|
|
1357
|
+
|
|
1358
|
+
const ModelUsageTotalsShape = {
|
|
1359
|
+
calls: z.number().int().nonnegative(),
|
|
1360
|
+
inputTokens: z.number().int().nonnegative(),
|
|
1361
|
+
cachedInputTokens: z.number().int().nonnegative(),
|
|
1362
|
+
cacheCreationTokens: z.number().int().nonnegative(),
|
|
1363
|
+
outputTokens: z.number().int().nonnegative(),
|
|
1364
|
+
reasoningTokens: z.number().int().nonnegative(),
|
|
1365
|
+
/** Provider-reported cost in US dollars, summed; null when none reported. */
|
|
1366
|
+
costUsd: z.number().nonnegative().nullable(),
|
|
1367
|
+
/** Calls whose provider reported no cost: costUsd is a lower bound. */
|
|
1368
|
+
unpricedCalls: z.number().int().nonnegative(),
|
|
1369
|
+
/** Calls whose usage could not be read: token totals are a lower bound. */
|
|
1370
|
+
unmeteredCalls: z.number().int().nonnegative(),
|
|
1371
|
+
};
|
|
1372
|
+
|
|
1373
|
+
/** A chat's model usage through the gateway (ADR 0329). */
|
|
1374
|
+
export const AgentSessionUsageSchema = z.object({
|
|
1375
|
+
sessionId: z.string().uuid(),
|
|
1376
|
+
family: z.boolean(),
|
|
1377
|
+
sessions: z.number().int().nonnegative(),
|
|
1378
|
+
openCalls: z.number().int().nonnegative(),
|
|
1379
|
+
...ModelUsageTotalsShape,
|
|
1380
|
+
models: z.array(
|
|
1381
|
+
z.object({ model: z.string().nullable(), ...ModelUsageTotalsShape }),
|
|
1382
|
+
),
|
|
1383
|
+
});
|
|
1384
|
+
|
|
1250
1385
|
export const AgentSessionPeerSchema = z.object({
|
|
1251
1386
|
id: z.string().uuid(),
|
|
1252
1387
|
projectId: z.string().uuid(),
|
|
1253
1388
|
title: z.string().nullable(),
|
|
1254
1389
|
agentId: z.string().nullable(),
|
|
1255
1390
|
parentSessionId: z.string().uuid().nullable(),
|
|
1391
|
+
workspaceSessionId: z.string().uuid().nullable(),
|
|
1256
1392
|
forkedFromSessionId: z.string().uuid().nullable(),
|
|
1257
1393
|
visibility: z.enum(["latent", "promoted", "archived"]),
|
|
1258
1394
|
status: z.enum(["active", "closed"]),
|
|
@@ -1296,6 +1432,11 @@ export const CreateAgentSubsessionSchema = z.object({
|
|
|
1296
1432
|
readOnly: z.boolean().optional(),
|
|
1297
1433
|
/** False keeps the child from starting its own; always allowed. */
|
|
1298
1434
|
delegate: z.boolean().optional(),
|
|
1435
|
+
/**
|
|
1436
|
+
* Its parent's workspace (default: no admission or setup of its own) or
|
|
1437
|
+
* one of its own started at the parent's base (ADR 0322).
|
|
1438
|
+
*/
|
|
1439
|
+
workspace: z.enum(["shared", "own"]).optional(),
|
|
1299
1440
|
task: z.string().min(1).max(100_000),
|
|
1300
1441
|
contextMode: z.enum(["fresh", "inherit"]).optional(),
|
|
1301
1442
|
title: z.string().min(1).max(500).optional(),
|
|
@@ -1308,13 +1449,41 @@ export const AgentSubsessionSchema = z.object({
|
|
|
1308
1449
|
task: z.string(),
|
|
1309
1450
|
contextMode: z.enum(["fresh", "inherit"]),
|
|
1310
1451
|
allowFurtherDelegation: z.boolean(),
|
|
1452
|
+
/** Where it works: its parent's workspace or its own (ADR 0322). */
|
|
1453
|
+
workspace: z.enum(["shared", "own"]),
|
|
1311
1454
|
status: z.enum(["running", "completed", "failed", "interrupted", "archived"]),
|
|
1312
1455
|
session: AgentSessionSchema,
|
|
1456
|
+
/**
|
|
1457
|
+
* The child's latest accepted result of each name (ADR 0323). A large
|
|
1458
|
+
* value is left out (`value` null, `truncated`): read it with results.
|
|
1459
|
+
*/
|
|
1460
|
+
results: z.array(
|
|
1461
|
+
z.object({
|
|
1462
|
+
id: z.string(),
|
|
1463
|
+
name: z.string(),
|
|
1464
|
+
value: JsonValueSchema,
|
|
1465
|
+
truncated: z.boolean(),
|
|
1466
|
+
current: z.boolean(),
|
|
1467
|
+
turnId: z.string().nullable(),
|
|
1468
|
+
recordedAt: z.string(),
|
|
1469
|
+
}),
|
|
1470
|
+
),
|
|
1313
1471
|
});
|
|
1314
1472
|
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1473
|
+
/**
|
|
1474
|
+
* `POST .../agent/sessions/start` (ADR 0346): the `session_start`
|
|
1475
|
+
* operation, with the project named by the route.
|
|
1476
|
+
*/
|
|
1477
|
+
export const StartSessionSchema = SESSION_OPERATIONS.session_start.input.omit({
|
|
1478
|
+
project: true,
|
|
1479
|
+
});
|
|
1480
|
+
|
|
1481
|
+
/** How a session operation's route refuses: a code a client can act on. */
|
|
1482
|
+
export const SessionOperationErrorSchema = z.object({
|
|
1483
|
+
error: z.string(),
|
|
1484
|
+
code: z.enum(SESSION_OPERATION_ERROR_CODES),
|
|
1485
|
+
retryable: z.boolean(),
|
|
1486
|
+
sessionId: z.string().optional(),
|
|
1318
1487
|
});
|
|
1319
1488
|
|
|
1320
1489
|
export const ArchiveAgentSessionSchema = z.object({
|
|
@@ -1439,7 +1608,14 @@ const TurnErrorSchema = describes<TurnError>()(
|
|
|
1439
1608
|
z.object({
|
|
1440
1609
|
message: z.string(),
|
|
1441
1610
|
kind: z
|
|
1442
|
-
.enum([
|
|
1611
|
+
.enum([
|
|
1612
|
+
"auth",
|
|
1613
|
+
"rate_limit",
|
|
1614
|
+
"unavailable",
|
|
1615
|
+
"model_incompat",
|
|
1616
|
+
"agent_missing",
|
|
1617
|
+
"out_of_disk",
|
|
1618
|
+
])
|
|
1443
1619
|
.optional(),
|
|
1444
1620
|
retrySafe: z.boolean().optional(),
|
|
1445
1621
|
}),
|
|
@@ -1472,7 +1648,6 @@ const TurnOutcomeSchema = describes<TurnOutcome>()(
|
|
|
1472
1648
|
z.object({ path: z.string(), kind: z.enum(["modified", "deleted"]) }),
|
|
1473
1649
|
),
|
|
1474
1650
|
usage: AgentTurnUsageSchema.optional(),
|
|
1475
|
-
storeSync: JsonObjectSchema.optional(),
|
|
1476
1651
|
workspaceSync: z.object({ error: z.string() }).optional(),
|
|
1477
1652
|
notification: z
|
|
1478
1653
|
.object({ title: z.string().optional(), body: z.string().optional() })
|
|
@@ -1532,7 +1707,13 @@ export const AttemptSchema = describes<Attempt>()(
|
|
|
1532
1707
|
turnId: z.string(),
|
|
1533
1708
|
sessionId: z.string(),
|
|
1534
1709
|
ordinal: z.number().int(),
|
|
1535
|
-
reason: z.enum([
|
|
1710
|
+
reason: z.enum([
|
|
1711
|
+
"initial",
|
|
1712
|
+
"retry",
|
|
1713
|
+
"steer_restart",
|
|
1714
|
+
"recovery",
|
|
1715
|
+
"restart",
|
|
1716
|
+
]),
|
|
1536
1717
|
status: z.enum([
|
|
1537
1718
|
"preparing",
|
|
1538
1719
|
"running",
|
|
@@ -1541,6 +1722,7 @@ export const AttemptSchema = describes<Attempt>()(
|
|
|
1541
1722
|
"interrupted",
|
|
1542
1723
|
"lost",
|
|
1543
1724
|
"superseded",
|
|
1725
|
+
"restarted",
|
|
1544
1726
|
]),
|
|
1545
1727
|
providerThreadId: z.string().nullable(),
|
|
1546
1728
|
nativeTurnRef: NativeRefSchema.nullable(),
|
|
@@ -1695,6 +1877,24 @@ export const ItemSchema = describes<Item>()(
|
|
|
1695
1877
|
}),
|
|
1696
1878
|
text: z.string(),
|
|
1697
1879
|
}),
|
|
1880
|
+
z.object({
|
|
1881
|
+
...itemCommon,
|
|
1882
|
+
kind: z.literal("result"),
|
|
1883
|
+
name: z.string(),
|
|
1884
|
+
value: JsonValueSchema,
|
|
1885
|
+
input: z
|
|
1886
|
+
.object({
|
|
1887
|
+
itemId: z.string(),
|
|
1888
|
+
position: z.number().int(),
|
|
1889
|
+
kind: z.enum([
|
|
1890
|
+
"user_message",
|
|
1891
|
+
"inbound_message",
|
|
1892
|
+
"task_notification",
|
|
1893
|
+
]),
|
|
1894
|
+
})
|
|
1895
|
+
.nullable(),
|
|
1896
|
+
commit: z.string().nullable(),
|
|
1897
|
+
}),
|
|
1698
1898
|
])
|
|
1699
1899
|
.meta({ id: "Item" }),
|
|
1700
1900
|
);
|
|
@@ -1938,8 +2138,90 @@ export const CommandReceiptSchema = describes<CommandReceipt>()(
|
|
|
1938
2138
|
export const SessionCommandSchema =
|
|
1939
2139
|
describes<SessionCommand>()(sessionCommandSchema);
|
|
1940
2140
|
|
|
2141
|
+
/** The turn working now and its progress (ADR 0333). */
|
|
2142
|
+
export const TurnProgressSchema = z.object({
|
|
2143
|
+
id: z.string(),
|
|
2144
|
+
ordinal: z.number().int(),
|
|
2145
|
+
status: z.enum(["preparing", "running", "waiting", "finalizing"]),
|
|
2146
|
+
attempt: z
|
|
2147
|
+
.object({
|
|
2148
|
+
id: z.string(),
|
|
2149
|
+
ordinal: z.number().int(),
|
|
2150
|
+
reason: z.string(),
|
|
2151
|
+
startedAt: z.string().nullable(),
|
|
2152
|
+
})
|
|
2153
|
+
.nullable(),
|
|
2154
|
+
attempts: z.number().int(),
|
|
2155
|
+
restarts: z.number().int(),
|
|
2156
|
+
progressAt: z.string().nullable(),
|
|
2157
|
+
stalledAt: z.string().nullable(),
|
|
2158
|
+
stallMinutes: z.number().nullable(),
|
|
2159
|
+
activity: z.object({
|
|
2160
|
+
tools: z.array(
|
|
2161
|
+
z.object({
|
|
2162
|
+
name: z.string(),
|
|
2163
|
+
description: z.string().nullable(),
|
|
2164
|
+
since: z.string(),
|
|
2165
|
+
}),
|
|
2166
|
+
),
|
|
2167
|
+
commands: z.array(
|
|
2168
|
+
z.object({
|
|
2169
|
+
command: z.string(),
|
|
2170
|
+
description: z.string().nullable(),
|
|
2171
|
+
since: z.string(),
|
|
2172
|
+
}),
|
|
2173
|
+
),
|
|
2174
|
+
}),
|
|
2175
|
+
});
|
|
2176
|
+
|
|
1941
2177
|
export const AgentSessionDetailSchema = AgentSessionSchema.extend({
|
|
1942
2178
|
snapshot: SessionSnapshotSchema,
|
|
2179
|
+
turn: TurnProgressSchema.nullable(),
|
|
2180
|
+
});
|
|
2181
|
+
|
|
2182
|
+
/** A turn's attempts with their diagnostics (ADR 0333). */
|
|
2183
|
+
export const TurnAttemptsSchema = z.object({
|
|
2184
|
+
attempts: z.array(
|
|
2185
|
+
z.object({
|
|
2186
|
+
id: z.string(),
|
|
2187
|
+
ordinal: z.number().int(),
|
|
2188
|
+
reason: z.string(),
|
|
2189
|
+
status: z.string(),
|
|
2190
|
+
error: z.object({ message: z.string() }).nullable(),
|
|
2191
|
+
startedAt: z.string().nullable(),
|
|
2192
|
+
completedAt: z.string().nullable(),
|
|
2193
|
+
progressAt: z.string().nullable(),
|
|
2194
|
+
stalledAt: z.string().nullable(),
|
|
2195
|
+
diagnostics: z
|
|
2196
|
+
.object({ runner: z.string(), harness: z.string() })
|
|
2197
|
+
.nullable(),
|
|
2198
|
+
}),
|
|
2199
|
+
),
|
|
2200
|
+
});
|
|
2201
|
+
|
|
2202
|
+
export const TurnIdParamsSchema = z.object({
|
|
2203
|
+
projectId: z.string().uuid(),
|
|
2204
|
+
sessionId: z.string().uuid(),
|
|
2205
|
+
turnId: z.string().uuid(),
|
|
2206
|
+
});
|
|
2207
|
+
|
|
2208
|
+
/** Restart a running turn's attempt (ADR 0333). */
|
|
2209
|
+
export const RestartTurnSchema = z.object({
|
|
2210
|
+
/** The attempt to end: refused unless it is the turn's running attempt. */
|
|
2211
|
+
attemptId: z.string().uuid(),
|
|
2212
|
+
reason: z.string().min(1).max(500),
|
|
2213
|
+
/** Only while it is stalled. */
|
|
2214
|
+
onlyIfStalled: z.boolean().optional(),
|
|
2215
|
+
idempotencyKey: z.string().min(1).max(300),
|
|
2216
|
+
});
|
|
2217
|
+
|
|
2218
|
+
export const RestartTurnResultSchema = z.object({
|
|
2219
|
+
restarted: z.literal(true),
|
|
2220
|
+
turnId: z.string(),
|
|
2221
|
+
attemptId: z.string(),
|
|
2222
|
+
attempt: z.number().int(),
|
|
2223
|
+
attempts: z.number().int(),
|
|
2224
|
+
restarts: z.number().int(),
|
|
1943
2225
|
});
|
|
1944
2226
|
|
|
1945
2227
|
export const SessionItemsQuerySchema = z.object({
|
|
@@ -1953,11 +2235,71 @@ export const SessionItemsPageSchema = z.object({
|
|
|
1953
2235
|
olderBefore: z.number().int().nullable(),
|
|
1954
2236
|
});
|
|
1955
2237
|
|
|
2238
|
+
/** A typed result an agent submitted and its schema accepted (ADR 0323). */
|
|
2239
|
+
export const SessionResultSchema = z
|
|
2240
|
+
.object({
|
|
2241
|
+
id: z.string(),
|
|
2242
|
+
/** The chat that recorded it: the one asked about, or a subsession. */
|
|
2243
|
+
sessionId: z.string(),
|
|
2244
|
+
turnId: z.string().nullable(),
|
|
2245
|
+
attemptId: z.string().nullable(),
|
|
2246
|
+
name: z.string(),
|
|
2247
|
+
value: JsonValueSchema,
|
|
2248
|
+
/** The newest input the chat had taken in when it was submitted. */
|
|
2249
|
+
input: z
|
|
2250
|
+
.object({
|
|
2251
|
+
itemId: z.string(),
|
|
2252
|
+
position: z.number().int(),
|
|
2253
|
+
kind: z.enum(["user_message", "inbound_message", "task_notification"]),
|
|
2254
|
+
})
|
|
2255
|
+
.nullable(),
|
|
2256
|
+
/**
|
|
2257
|
+
* No new request reached the chat since: nothing a person, a workflow or
|
|
2258
|
+
* a session outside its own subsessions sent.
|
|
2259
|
+
*/
|
|
2260
|
+
current: z.boolean(),
|
|
2261
|
+
commit: z.string().nullable(),
|
|
2262
|
+
recordedAt: z.string(),
|
|
2263
|
+
})
|
|
2264
|
+
.meta({ id: "SessionResult" });
|
|
2265
|
+
|
|
2266
|
+
export const SessionResultsQuerySchema = z.object({
|
|
2267
|
+
name: z.string().min(1).max(64).optional(),
|
|
2268
|
+
/** `true`: the chat's subsessions' results too, at every depth. */
|
|
2269
|
+
family: z
|
|
2270
|
+
.enum(["true", "false"])
|
|
2271
|
+
.transform((value) => value === "true")
|
|
2272
|
+
.optional(),
|
|
2273
|
+
/** Only what one turn's attempts submitted. */
|
|
2274
|
+
turnId: z.string().uuid().optional(),
|
|
2275
|
+
/** An input's message id: results that answer it or a later one. */
|
|
2276
|
+
afterInput: z.string().uuid().optional(),
|
|
2277
|
+
limit: z.coerce.number().int().min(1).max(100).optional(),
|
|
2278
|
+
});
|
|
2279
|
+
|
|
2280
|
+
export const SessionResultsSchema = z.object({
|
|
2281
|
+
results: z.array(SessionResultSchema),
|
|
2282
|
+
});
|
|
2283
|
+
|
|
1956
2284
|
export const SessionEventsQuerySchema = z.object({
|
|
1957
2285
|
/** Stream events after this sequence: a snapshot's `sequence`. */
|
|
1958
2286
|
after: z.coerce.number().int().nonnegative().optional(),
|
|
1959
2287
|
});
|
|
1960
2288
|
|
|
2289
|
+
export const SessionMissedEventsQuerySchema = z.object({
|
|
2290
|
+
/** The last sequence the reader applied. */
|
|
2291
|
+
after: z.coerce.number().int().nonnegative(),
|
|
2292
|
+
});
|
|
2293
|
+
|
|
2294
|
+
/**
|
|
2295
|
+
* What a reader has missed since its sequence, read once: the messages a
|
|
2296
|
+
* stream opens with (the events since, or a `reset` with a fresh snapshot
|
|
2297
|
+
* when they are too many to replay); empty when it is current.
|
|
2298
|
+
*/
|
|
2299
|
+
export const SessionMissedEventsSchema = z.object({
|
|
2300
|
+
messages: z.array(SessionStreamMessageSchema),
|
|
2301
|
+
});
|
|
2302
|
+
|
|
1961
2303
|
export const SessionMirrorQuerySchema = z.object({
|
|
1962
2304
|
/** The copy's last sequence; omitted for a copy that does not exist yet. */
|
|
1963
2305
|
after: z.coerce.number().int().nonnegative().optional(),
|
|
@@ -2251,6 +2593,12 @@ export const ProjectAgentDefinitionSchema = z.object({
|
|
|
2251
2593
|
.object({
|
|
2252
2594
|
endpoint: z.string().optional(),
|
|
2253
2595
|
command: z.array(z.string()).optional(),
|
|
2596
|
+
/** The agent runs its commands with `$SHELL` (ADR 0332). */
|
|
2597
|
+
shell: z.boolean().optional(),
|
|
2598
|
+
/** `false`: the agent loads nothing from the checkout (ADR 0332). */
|
|
2599
|
+
projectConfig: z.boolean().optional(),
|
|
2600
|
+
/** Variables Work sets on the agent's process. */
|
|
2601
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
2254
2602
|
})
|
|
2255
2603
|
.optional(),
|
|
2256
2604
|
});
|