@inf-monkeys-tech/monkeys 1.0.20 → 1.0.22
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/lib/contracts/agent.d.ts +1079 -95
- package/lib/contracts/agent.d.ts.map +1 -1
- package/lib/contracts/agent.js +365 -4
- package/lib/contracts/agent.js.map +1 -1
- package/lib/contracts/theme.d.ts +1 -1
- package/lib/esm/contracts/index.mjs +347 -9
- package/lib/esm/contracts/index.mjs.map +1 -1
- package/lib/esm/index.mjs +350 -9
- package/lib/esm/index.mjs.map +1 -1
- package/lib/esm/runtime/index.mjs +311 -8
- package/lib/esm/runtime/index.mjs.map +1 -1
- package/lib/esm/schemas/index.mjs +322 -8
- package/lib/esm/schemas/index.mjs.map +1 -1
- package/lib/json-schema/agent-session-command-result.schema.json +120 -0
- package/lib/json-schema/agent-session-command.schema.json +395 -0
- package/lib/json-schema/agent-session-event.schema.json +285 -0
- package/lib/json-schema/agent-session-run-event.schema.json +1607 -0
- package/lib/json-schema/agent-session-run.schema.json +72 -0
- package/lib/json-schema/agent-session-targeted-command.schema.json +677 -0
- package/lib/json-schema/agent-session-view-model.schema.json +396 -1
- package/lib/json-schema/index.json +3 -0
- package/lib/schemas/index.d.ts +783 -1
- package/lib/schemas/index.d.ts.map +1 -1
- package/lib/schemas/index.js +14 -3
- package/lib/schemas/index.js.map +1 -1
- package/package.json +1 -1
- package/test/fixtures/agent-session-agent.json +5 -1
- package/test/fixtures/agent-session-chatbot.json +5 -1
- package/test/fixtures/agent-session-kernel.json +5 -1
- package/test/fixtures/agent-session-runs.json +51 -0
|
@@ -7142,7 +7142,11 @@ var AgentSessionCapabilitySchema = z5.enum([
|
|
|
7142
7142
|
"diff",
|
|
7143
7143
|
"workspaceFiles",
|
|
7144
7144
|
"terminal",
|
|
7145
|
-
"testResults"
|
|
7145
|
+
"testResults",
|
|
7146
|
+
"threadForking",
|
|
7147
|
+
"editAndRerun",
|
|
7148
|
+
"steering",
|
|
7149
|
+
"summary"
|
|
7146
7150
|
]);
|
|
7147
7151
|
var AgentSessionCapabilitiesSchema = z5.object({
|
|
7148
7152
|
text: z5.boolean().default(true),
|
|
@@ -7161,7 +7165,11 @@ var AgentSessionCapabilitiesSchema = z5.object({
|
|
|
7161
7165
|
diff: z5.boolean().default(false),
|
|
7162
7166
|
workspaceFiles: z5.boolean().default(false),
|
|
7163
7167
|
terminal: z5.boolean().default(false),
|
|
7164
|
-
testResults: z5.boolean().default(false)
|
|
7168
|
+
testResults: z5.boolean().default(false),
|
|
7169
|
+
threadForking: z5.boolean().default(false),
|
|
7170
|
+
editAndRerun: z5.boolean().default(false),
|
|
7171
|
+
steering: z5.boolean().default(false),
|
|
7172
|
+
summary: z5.boolean().default(false)
|
|
7165
7173
|
}).strict();
|
|
7166
7174
|
var AGENT_SESSION_RUNTIME_CAPABILITIES = Object.freeze({
|
|
7167
7175
|
chatbot: AgentSessionCapabilitiesSchema.parse({ text: true, tools: true, mcp: true, skills: true, approval: true, usage: true }),
|
|
@@ -7184,7 +7192,11 @@ var AGENT_SESSION_CAPABILITY_EVIDENCE = Object.freeze({
|
|
|
7184
7192
|
diff: { eventTypes: ["diff"], commandTypes: [] },
|
|
7185
7193
|
workspaceFiles: { eventTypes: ["workspace-file"], commandTypes: [] },
|
|
7186
7194
|
terminal: { eventTypes: ["terminal"], commandTypes: [] },
|
|
7187
|
-
testResults: { eventTypes: ["test-result"], commandTypes: [] }
|
|
7195
|
+
testResults: { eventTypes: ["test-result"], commandTypes: [] },
|
|
7196
|
+
threadForking: { eventTypes: [], commandTypes: ["fork"] },
|
|
7197
|
+
editAndRerun: { eventTypes: [], commandTypes: ["edit-and-rerun"] },
|
|
7198
|
+
steering: { eventTypes: [], commandTypes: ["steer"] },
|
|
7199
|
+
summary: { eventTypes: ["summary"], commandTypes: [] }
|
|
7188
7200
|
});
|
|
7189
7201
|
var AgentSessionSnapshotSchema = z5.object({
|
|
7190
7202
|
mode: AgentModeSchema,
|
|
@@ -7200,11 +7212,98 @@ var AgentSessionStatusSchema = z5.enum([
|
|
|
7200
7212
|
"completed",
|
|
7201
7213
|
"failed"
|
|
7202
7214
|
]);
|
|
7203
|
-
var
|
|
7215
|
+
var AgentSessionTerminalStatusSchema = z5.enum(["stopped", "completed", "failed"]);
|
|
7216
|
+
var AgentSessionLineageSchema = z5.object({
|
|
7217
|
+
forkedFromThreadId: ContractIdentifierSchema,
|
|
7218
|
+
forkedFromMessageId: ContractIdentifierSchema,
|
|
7219
|
+
sourceRunId: ContractIdentifierSchema
|
|
7220
|
+
}).strict();
|
|
7221
|
+
var AgentSessionContextInheritanceSchema = z5.object({
|
|
7222
|
+
messages: z5.enum(["through-source-message", "exclude"]),
|
|
7223
|
+
attachments: z5.enum(["inherit", "exclude"]),
|
|
7224
|
+
summaries: z5.enum(["inherit", "exclude"]),
|
|
7225
|
+
toolResults: z5.enum(["inherit", "exclude"]),
|
|
7226
|
+
codeChanges: z5.enum(["inherit", "exclude"])
|
|
7227
|
+
}).strict();
|
|
7228
|
+
var AgentSessionActiveBranchSchema = z5.object({
|
|
7229
|
+
branchId: ContractIdentifierSchema,
|
|
7230
|
+
threadId: ContractIdentifierSchema,
|
|
7231
|
+
sourceMessageId: ContractIdentifierSchema,
|
|
7232
|
+
runId: ContractIdentifierSchema,
|
|
7233
|
+
lineage: AgentSessionLineageSchema.optional(),
|
|
7234
|
+
createdAt: IsoDateTimeSchema
|
|
7235
|
+
}).strict();
|
|
7236
|
+
var AgentSessionRunSchema = z5.object({
|
|
7237
|
+
runId: ContractIdentifierSchema,
|
|
7238
|
+
sessionId: ContractIdentifierSchema,
|
|
7239
|
+
sourceMessageId: ContractIdentifierSchema,
|
|
7240
|
+
status: AgentSessionStatusSchema,
|
|
7241
|
+
startedAt: IsoDateTimeSchema,
|
|
7242
|
+
stoppingRequestedAt: IsoDateTimeSchema.optional(),
|
|
7243
|
+
stoppedAt: IsoDateTimeSchema.optional(),
|
|
7244
|
+
completedAt: IsoDateTimeSchema.optional(),
|
|
7245
|
+
failedAt: IsoDateTimeSchema.optional(),
|
|
7246
|
+
durationMs: z5.number().nonnegative().optional()
|
|
7247
|
+
}).strict().superRefine((value, context) => {
|
|
7248
|
+
const terminalTimestamps = [value.stoppedAt, value.completedAt, value.failedAt].filter(Boolean);
|
|
7249
|
+
if (terminalTimestamps.length > 1) {
|
|
7250
|
+
context.addIssue({
|
|
7251
|
+
code: "custom",
|
|
7252
|
+
path: ["status"],
|
|
7253
|
+
message: "A run may declare only one terminal timestamp."
|
|
7254
|
+
});
|
|
7255
|
+
}
|
|
7256
|
+
const expectedTimestamp = value.status === "stopped" ? value.stoppedAt : value.status === "completed" ? value.completedAt : value.status === "failed" ? value.failedAt : void 0;
|
|
7257
|
+
if (AgentSessionTerminalStatusSchema.safeParse(value.status).success && !expectedTimestamp) {
|
|
7258
|
+
context.addIssue({
|
|
7259
|
+
code: "custom",
|
|
7260
|
+
path: [value.status === "stopped" ? "stoppedAt" : value.status === "completed" ? "completedAt" : "failedAt"],
|
|
7261
|
+
message: `Run status ${value.status} requires its matching terminal timestamp.`
|
|
7262
|
+
});
|
|
7263
|
+
}
|
|
7264
|
+
if (!AgentSessionTerminalStatusSchema.safeParse(value.status).success && terminalTimestamps.length > 0) {
|
|
7265
|
+
context.addIssue({
|
|
7266
|
+
code: "custom",
|
|
7267
|
+
path: ["status"],
|
|
7268
|
+
message: "A non-terminal run must not declare a terminal timestamp."
|
|
7269
|
+
});
|
|
7270
|
+
}
|
|
7271
|
+
if ((value.status === "stopping" || value.status === "stopped") && !value.stoppingRequestedAt) {
|
|
7272
|
+
context.addIssue({
|
|
7273
|
+
code: "custom",
|
|
7274
|
+
path: ["stoppingRequestedAt"],
|
|
7275
|
+
message: `Run status ${value.status} requires stoppingRequestedAt.`
|
|
7276
|
+
});
|
|
7277
|
+
}
|
|
7278
|
+
if (!isAgentSessionTerminalStatus(value.status) && value.durationMs !== void 0) {
|
|
7279
|
+
context.addIssue({
|
|
7280
|
+
code: "custom",
|
|
7281
|
+
path: ["durationMs"],
|
|
7282
|
+
message: "Only a terminal run may declare durationMs."
|
|
7283
|
+
});
|
|
7284
|
+
}
|
|
7285
|
+
if (isAgentSessionTerminalStatus(value.status) && value.durationMs === void 0) {
|
|
7286
|
+
context.addIssue({
|
|
7287
|
+
code: "custom",
|
|
7288
|
+
path: ["durationMs"],
|
|
7289
|
+
message: `Terminal run status ${value.status} requires durationMs.`
|
|
7290
|
+
});
|
|
7291
|
+
}
|
|
7292
|
+
});
|
|
7293
|
+
var AgentSessionCommandTypeSchema = z5.enum([
|
|
7294
|
+
"stop",
|
|
7295
|
+
"resume",
|
|
7296
|
+
"retry",
|
|
7297
|
+
"approval",
|
|
7298
|
+
"fork",
|
|
7299
|
+
"edit-and-rerun",
|
|
7300
|
+
"steer"
|
|
7301
|
+
]);
|
|
7204
7302
|
var AgentSessionCommandHeaderSchema = z5.object({
|
|
7205
7303
|
contract: z5.literal("AgentSessionCommand"),
|
|
7206
7304
|
commandId: ContractIdentifierSchema,
|
|
7207
7305
|
sessionId: ContractIdentifierSchema,
|
|
7306
|
+
runId: ContractIdentifierSchema.optional(),
|
|
7208
7307
|
idempotencyKey: ContractIdentifierSchema,
|
|
7209
7308
|
expectedSequence: z5.number().int().min(-1),
|
|
7210
7309
|
issuedAt: IsoDateTimeSchema
|
|
@@ -7227,10 +7326,41 @@ var AgentSessionCommandSchema = z5.discriminatedUnion("commandType", [
|
|
|
7227
7326
|
approvalId: ContractIdentifierSchema,
|
|
7228
7327
|
decision: z5.enum(["approved", "rejected"]),
|
|
7229
7328
|
reason: z5.string().trim().min(1).optional()
|
|
7329
|
+
}),
|
|
7330
|
+
sessionCommand("fork", {
|
|
7331
|
+
sourceThreadId: ContractIdentifierSchema,
|
|
7332
|
+
sourceMessageId: ContractIdentifierSchema,
|
|
7333
|
+
sourceRunId: ContractIdentifierSchema,
|
|
7334
|
+
inheritance: AgentSessionContextInheritanceSchema
|
|
7335
|
+
}),
|
|
7336
|
+
sessionCommand("edit-and-rerun", {
|
|
7337
|
+
sourceThreadId: ContractIdentifierSchema,
|
|
7338
|
+
sourceMessageId: ContractIdentifierSchema,
|
|
7339
|
+
sourceRunId: ContractIdentifierSchema,
|
|
7340
|
+
replacementParts: z5.array(JsonValueSchema).min(1),
|
|
7341
|
+
inheritance: AgentSessionContextInheritanceSchema
|
|
7342
|
+
}),
|
|
7343
|
+
sessionCommand("steer", {
|
|
7344
|
+
targetRunId: ContractIdentifierSchema,
|
|
7345
|
+
guidanceParts: z5.array(JsonValueSchema).min(1)
|
|
7230
7346
|
})
|
|
7231
|
-
])
|
|
7347
|
+
]).superRefine((value, context) => {
|
|
7348
|
+
if (value.commandType === "steer" && value.runId !== value.payload.targetRunId) {
|
|
7349
|
+
context.addIssue({
|
|
7350
|
+
code: "custom",
|
|
7351
|
+
path: ["payload", "targetRunId"],
|
|
7352
|
+
message: "Steering targetRunId must match the command runId."
|
|
7353
|
+
});
|
|
7354
|
+
}
|
|
7355
|
+
});
|
|
7356
|
+
var AgentSessionTargetedCommandSchema = AgentSessionCommandSchema.and(
|
|
7357
|
+
z5.object({ runId: ContractIdentifierSchema })
|
|
7358
|
+
);
|
|
7232
7359
|
var AgentSessionCommandErrorCodeSchema = z5.enum([
|
|
7233
7360
|
"SESSION_NOT_FOUND",
|
|
7361
|
+
"RUN_NOT_FOUND",
|
|
7362
|
+
"RUN_ALREADY_FINISHED",
|
|
7363
|
+
"STOP_TIMEOUT",
|
|
7234
7364
|
"COMMAND_NOT_SUPPORTED",
|
|
7235
7365
|
"CAPABILITY_UNAVAILABLE",
|
|
7236
7366
|
"SEQUENCE_CONFLICT",
|
|
@@ -7239,17 +7369,28 @@ var AgentSessionCommandErrorCodeSchema = z5.enum([
|
|
|
7239
7369
|
"TARGET_EVENT_NOT_RETRYABLE",
|
|
7240
7370
|
"APPROVAL_NOT_FOUND",
|
|
7241
7371
|
"APPROVAL_ALREADY_RESOLVED",
|
|
7372
|
+
"SOURCE_THREAD_NOT_FOUND",
|
|
7373
|
+
"SOURCE_MESSAGE_NOT_FOUND",
|
|
7374
|
+
"SOURCE_RUN_NOT_FOUND",
|
|
7375
|
+
"SOURCE_LINEAGE_INVALID",
|
|
7376
|
+
"ACTIVE_BRANCH_NOT_FOUND",
|
|
7242
7377
|
"COMMAND_EXECUTION_FAILED"
|
|
7243
7378
|
]);
|
|
7244
7379
|
var AgentSessionCommandResultSchema = z5.object({
|
|
7245
7380
|
contract: z5.literal("AgentSessionCommandResult"),
|
|
7246
7381
|
commandId: ContractIdentifierSchema,
|
|
7247
7382
|
sessionId: ContractIdentifierSchema,
|
|
7383
|
+
runId: ContractIdentifierSchema.optional(),
|
|
7248
7384
|
idempotencyKey: ContractIdentifierSchema,
|
|
7249
7385
|
outcome: z5.enum(["accepted", "duplicate", "rejected", "failed"]),
|
|
7250
7386
|
sessionStatus: AgentSessionStatusSchema,
|
|
7251
7387
|
acceptedSequence: z5.number().int().nonnegative().optional(),
|
|
7252
7388
|
resultEventIds: z5.array(ContractIdentifierSchema).default([]),
|
|
7389
|
+
operation: z5.object({
|
|
7390
|
+
lineage: AgentSessionLineageSchema,
|
|
7391
|
+
activeBranch: AgentSessionActiveBranchSchema
|
|
7392
|
+
}).strict().optional(),
|
|
7393
|
+
termination: z5.enum(["requested", "confirmed"]).optional(),
|
|
7253
7394
|
error: z5.object({
|
|
7254
7395
|
code: AgentSessionCommandErrorCodeSchema,
|
|
7255
7396
|
message: z5.string(),
|
|
@@ -7265,11 +7406,121 @@ var AgentSessionCommandResultSchema = z5.object({
|
|
|
7265
7406
|
message: requiresError ? "Rejected and failed command results require an error." : "Accepted and duplicate command results must not contain an error."
|
|
7266
7407
|
});
|
|
7267
7408
|
}
|
|
7409
|
+
if (value.termination === "requested" && value.sessionStatus !== "stopping") {
|
|
7410
|
+
context.addIssue({
|
|
7411
|
+
code: "custom",
|
|
7412
|
+
path: ["termination"],
|
|
7413
|
+
message: "A requested termination must leave the run in stopping status."
|
|
7414
|
+
});
|
|
7415
|
+
}
|
|
7416
|
+
if (value.termination === "confirmed" && !isAgentSessionTerminalStatus(value.sessionStatus)) {
|
|
7417
|
+
context.addIssue({
|
|
7418
|
+
code: "custom",
|
|
7419
|
+
path: ["termination"],
|
|
7420
|
+
message: "A confirmed termination requires a terminal run status."
|
|
7421
|
+
});
|
|
7422
|
+
}
|
|
7423
|
+
if (value.operation && !value.operation.activeBranch.lineage) {
|
|
7424
|
+
context.addIssue({
|
|
7425
|
+
code: "custom",
|
|
7426
|
+
path: ["operation", "activeBranch", "lineage"],
|
|
7427
|
+
message: "A branch operation result requires lineage on its active branch."
|
|
7428
|
+
});
|
|
7429
|
+
}
|
|
7430
|
+
const operation = value.operation;
|
|
7431
|
+
if (operation?.activeBranch.lineage) {
|
|
7432
|
+
const { lineage } = operation;
|
|
7433
|
+
const branchLineage = operation.activeBranch.lineage;
|
|
7434
|
+
if (lineage.forkedFromThreadId !== branchLineage.forkedFromThreadId || lineage.forkedFromMessageId !== branchLineage.forkedFromMessageId || lineage.sourceRunId !== branchLineage.sourceRunId) {
|
|
7435
|
+
context.addIssue({
|
|
7436
|
+
code: "custom",
|
|
7437
|
+
path: ["operation", "activeBranch", "lineage"],
|
|
7438
|
+
message: "Active branch lineage must match the operation lineage."
|
|
7439
|
+
});
|
|
7440
|
+
}
|
|
7441
|
+
}
|
|
7442
|
+
if (value.operation && value.runId !== value.operation.activeBranch.runId) {
|
|
7443
|
+
context.addIssue({
|
|
7444
|
+
code: "custom",
|
|
7445
|
+
path: ["operation", "activeBranch", "runId"],
|
|
7446
|
+
message: "Active branch runId must match the command result runId."
|
|
7447
|
+
});
|
|
7448
|
+
}
|
|
7449
|
+
});
|
|
7450
|
+
var AgentSessionCommandPolicySchema = z5.object({
|
|
7451
|
+
capability: AgentSessionCapabilitySchema.optional(),
|
|
7452
|
+
allowedStatuses: z5.array(AgentSessionStatusSchema).min(1),
|
|
7453
|
+
requiresRunId: z5.boolean(),
|
|
7454
|
+
sourceSessionEffect: z5.enum(["transition", "preserve"]),
|
|
7455
|
+
idempotencyScope: z5.literal("session-command"),
|
|
7456
|
+
sequenceRule: z5.literal("match-current")
|
|
7457
|
+
}).strict();
|
|
7458
|
+
var sessionCommandPolicy = (policy) => AgentSessionCommandPolicySchema.parse(policy);
|
|
7459
|
+
var AGENT_SESSION_COMMAND_POLICIES = Object.freeze({
|
|
7460
|
+
stop: sessionCommandPolicy({
|
|
7461
|
+
allowedStatuses: ["queued", "running", "waiting_approval"],
|
|
7462
|
+
requiresRunId: true,
|
|
7463
|
+
sourceSessionEffect: "transition",
|
|
7464
|
+
idempotencyScope: "session-command",
|
|
7465
|
+
sequenceRule: "match-current"
|
|
7466
|
+
}),
|
|
7467
|
+
resume: sessionCommandPolicy({
|
|
7468
|
+
capability: "resume",
|
|
7469
|
+
allowedStatuses: ["stopped", "completed", "failed"],
|
|
7470
|
+
requiresRunId: true,
|
|
7471
|
+
sourceSessionEffect: "transition",
|
|
7472
|
+
idempotencyScope: "session-command",
|
|
7473
|
+
sequenceRule: "match-current"
|
|
7474
|
+
}),
|
|
7475
|
+
retry: sessionCommandPolicy({
|
|
7476
|
+
allowedStatuses: ["failed"],
|
|
7477
|
+
requiresRunId: true,
|
|
7478
|
+
sourceSessionEffect: "transition",
|
|
7479
|
+
idempotencyScope: "session-command",
|
|
7480
|
+
sequenceRule: "match-current"
|
|
7481
|
+
}),
|
|
7482
|
+
approval: sessionCommandPolicy({
|
|
7483
|
+
capability: "approval",
|
|
7484
|
+
allowedStatuses: ["waiting_approval"],
|
|
7485
|
+
requiresRunId: true,
|
|
7486
|
+
sourceSessionEffect: "transition",
|
|
7487
|
+
idempotencyScope: "session-command",
|
|
7488
|
+
sequenceRule: "match-current"
|
|
7489
|
+
}),
|
|
7490
|
+
fork: sessionCommandPolicy({
|
|
7491
|
+
capability: "threadForking",
|
|
7492
|
+
allowedStatuses: AgentSessionStatusSchema.options,
|
|
7493
|
+
requiresRunId: false,
|
|
7494
|
+
sourceSessionEffect: "preserve",
|
|
7495
|
+
idempotencyScope: "session-command",
|
|
7496
|
+
sequenceRule: "match-current"
|
|
7497
|
+
}),
|
|
7498
|
+
"edit-and-rerun": sessionCommandPolicy({
|
|
7499
|
+
capability: "editAndRerun",
|
|
7500
|
+
allowedStatuses: ["stopped", "completed", "failed"],
|
|
7501
|
+
requiresRunId: false,
|
|
7502
|
+
sourceSessionEffect: "preserve",
|
|
7503
|
+
idempotencyScope: "session-command",
|
|
7504
|
+
sequenceRule: "match-current"
|
|
7505
|
+
}),
|
|
7506
|
+
steer: sessionCommandPolicy({
|
|
7507
|
+
capability: "steering",
|
|
7508
|
+
allowedStatuses: ["queued", "running"],
|
|
7509
|
+
requiresRunId: true,
|
|
7510
|
+
sourceSessionEffect: "preserve",
|
|
7511
|
+
idempotencyScope: "session-command",
|
|
7512
|
+
sequenceRule: "match-current"
|
|
7513
|
+
})
|
|
7268
7514
|
});
|
|
7515
|
+
function isAgentSessionTerminalStatus(status) {
|
|
7516
|
+
return AgentSessionTerminalStatusSchema.safeParse(status).success;
|
|
7517
|
+
}
|
|
7269
7518
|
var AgentSessionEventHeaderSchema = z5.object({
|
|
7270
7519
|
contract: z5.literal("AgentSessionEvent"),
|
|
7271
7520
|
eventId: ContractIdentifierSchema,
|
|
7272
7521
|
sessionId: ContractIdentifierSchema,
|
|
7522
|
+
runId: ContractIdentifierSchema.optional(),
|
|
7523
|
+
sourceMessageId: ContractIdentifierSchema.optional(),
|
|
7273
7524
|
sequence: z5.number().int().nonnegative(),
|
|
7274
7525
|
idempotencyKey: ContractIdentifierSchema,
|
|
7275
7526
|
occurredAt: IsoDateTimeSchema
|
|
@@ -7329,7 +7580,13 @@ var AgentSessionEventSchema = z5.discriminatedUnion("eventType", [
|
|
|
7329
7580
|
}),
|
|
7330
7581
|
sessionEvent("status", {
|
|
7331
7582
|
status: AgentSessionStatusSchema,
|
|
7332
|
-
detail: z5.string().optional()
|
|
7583
|
+
detail: z5.string().optional(),
|
|
7584
|
+
startedAt: IsoDateTimeSchema.optional(),
|
|
7585
|
+
stoppingRequestedAt: IsoDateTimeSchema.optional(),
|
|
7586
|
+
stoppedAt: IsoDateTimeSchema.optional(),
|
|
7587
|
+
completedAt: IsoDateTimeSchema.optional(),
|
|
7588
|
+
failedAt: IsoDateTimeSchema.optional(),
|
|
7589
|
+
durationMs: z5.number().nonnegative().optional()
|
|
7333
7590
|
}),
|
|
7334
7591
|
sessionEvent("artifact", {
|
|
7335
7592
|
artifactId: ContractIdentifierSchema,
|
|
@@ -7383,8 +7640,52 @@ var AgentSessionEventSchema = z5.discriminatedUnion("eventType", [
|
|
|
7383
7640
|
status: z5.enum(["running", "passed", "failed", "skipped"]),
|
|
7384
7641
|
durationMs: z5.number().nonnegative().optional(),
|
|
7385
7642
|
output: z5.string().optional()
|
|
7643
|
+
}),
|
|
7644
|
+
sessionEvent("summary", {
|
|
7645
|
+
summaryId: ContractIdentifierSchema,
|
|
7646
|
+
runId: ContractIdentifierSchema,
|
|
7647
|
+
text: z5.string(),
|
|
7648
|
+
highlights: z5.array(z5.string()),
|
|
7649
|
+
pendingItems: z5.array(z5.string()),
|
|
7650
|
+
status: z5.enum(["generating", "completed", "failed"])
|
|
7386
7651
|
})
|
|
7387
|
-
])
|
|
7652
|
+
]).superRefine((value, context) => {
|
|
7653
|
+
if (value.eventType === "summary" && value.runId !== value.payload.runId) {
|
|
7654
|
+
context.addIssue({
|
|
7655
|
+
code: "custom",
|
|
7656
|
+
path: ["payload", "runId"],
|
|
7657
|
+
message: "Summary payload runId must match the event runId."
|
|
7658
|
+
});
|
|
7659
|
+
}
|
|
7660
|
+
});
|
|
7661
|
+
var AgentSessionRunEventSchema = AgentSessionEventSchema.superRefine((value, context) => {
|
|
7662
|
+
if (!value.runId) {
|
|
7663
|
+
context.addIssue({ code: "custom", path: ["runId"], message: "Run events require runId." });
|
|
7664
|
+
}
|
|
7665
|
+
if (!value.sourceMessageId) {
|
|
7666
|
+
context.addIssue({
|
|
7667
|
+
code: "custom",
|
|
7668
|
+
path: ["sourceMessageId"],
|
|
7669
|
+
message: "Run events require sourceMessageId."
|
|
7670
|
+
});
|
|
7671
|
+
}
|
|
7672
|
+
if (value.eventType !== "status") return;
|
|
7673
|
+
const requiredTimeField = value.payload.status === "running" ? "startedAt" : value.payload.status === "stopping" ? "stoppingRequestedAt" : value.payload.status === "stopped" ? "stoppedAt" : value.payload.status === "completed" ? "completedAt" : value.payload.status === "failed" ? "failedAt" : void 0;
|
|
7674
|
+
if (requiredTimeField && !value.payload[requiredTimeField]) {
|
|
7675
|
+
context.addIssue({
|
|
7676
|
+
code: "custom",
|
|
7677
|
+
path: ["payload", requiredTimeField],
|
|
7678
|
+
message: `Run status ${value.payload.status} requires ${requiredTimeField}.`
|
|
7679
|
+
});
|
|
7680
|
+
}
|
|
7681
|
+
if (isAgentSessionTerminalStatus(value.payload.status) && value.payload.durationMs === void 0) {
|
|
7682
|
+
context.addIssue({
|
|
7683
|
+
code: "custom",
|
|
7684
|
+
path: ["payload", "durationMs"],
|
|
7685
|
+
message: `Terminal run status ${value.payload.status} requires durationMs.`
|
|
7686
|
+
});
|
|
7687
|
+
}
|
|
7688
|
+
});
|
|
7388
7689
|
var AgentSessionViewModelSchema = z5.object({
|
|
7389
7690
|
contract: z5.literal("AgentSessionViewModel"),
|
|
7390
7691
|
sessionId: ContractIdentifierSchema,
|
|
@@ -7392,7 +7693,9 @@ var AgentSessionViewModelSchema = z5.object({
|
|
|
7392
7693
|
status: AgentSessionStatusSchema,
|
|
7393
7694
|
events: z5.array(AgentSessionEventSchema),
|
|
7394
7695
|
lastSequence: z5.number().int().min(-1),
|
|
7395
|
-
resumable: z5.boolean().default(false)
|
|
7696
|
+
resumable: z5.boolean().default(false),
|
|
7697
|
+
lineage: AgentSessionLineageSchema.optional(),
|
|
7698
|
+
activeBranch: AgentSessionActiveBranchSchema.optional()
|
|
7396
7699
|
}).strict().superRefine((value, context) => {
|
|
7397
7700
|
const eventIds = /* @__PURE__ */ new Set();
|
|
7398
7701
|
const idempotencyKeys = /* @__PURE__ */ new Set();
|
|
@@ -11623,8 +11926,11 @@ var WorkflowCompletionReceiptSchema = z15.object({
|
|
|
11623
11926
|
// src/schemas/index.ts
|
|
11624
11927
|
var canonicalContractSchemas = {
|
|
11625
11928
|
"agent-session-command": AgentSessionCommandSchema,
|
|
11929
|
+
"agent-session-targeted-command": AgentSessionTargetedCommandSchema,
|
|
11626
11930
|
"agent-session-command-result": AgentSessionCommandResultSchema,
|
|
11627
11931
|
"agent-session-event": AgentSessionEventSchema,
|
|
11932
|
+
"agent-session-run-event": AgentSessionRunEventSchema,
|
|
11933
|
+
"agent-session-run": AgentSessionRunSchema,
|
|
11628
11934
|
"agent-session-view-model": AgentSessionViewModelSchema,
|
|
11629
11935
|
"agent-runtime-event": AgentRuntimeEventSchema,
|
|
11630
11936
|
"application-run": ApplicationRunSchema,
|
|
@@ -11691,15 +11997,23 @@ export {
|
|
|
11691
11997
|
AgentModeSchema,
|
|
11692
11998
|
AgentResourceModeSupportSchema,
|
|
11693
11999
|
AgentRuntimeEventSchema,
|
|
12000
|
+
AgentSessionActiveBranchSchema,
|
|
11694
12001
|
AgentSessionCapabilitiesSchema,
|
|
11695
12002
|
AgentSessionCapabilitySchema,
|
|
11696
12003
|
AgentSessionCommandErrorCodeSchema,
|
|
12004
|
+
AgentSessionCommandPolicySchema,
|
|
11697
12005
|
AgentSessionCommandResultSchema,
|
|
11698
12006
|
AgentSessionCommandSchema,
|
|
11699
12007
|
AgentSessionCommandTypeSchema,
|
|
12008
|
+
AgentSessionContextInheritanceSchema,
|
|
11700
12009
|
AgentSessionEventSchema,
|
|
12010
|
+
AgentSessionLineageSchema,
|
|
12011
|
+
AgentSessionRunEventSchema,
|
|
12012
|
+
AgentSessionRunSchema,
|
|
11701
12013
|
AgentSessionSnapshotSchema,
|
|
11702
12014
|
AgentSessionStatusSchema,
|
|
12015
|
+
AgentSessionTargetedCommandSchema,
|
|
12016
|
+
AgentSessionTerminalStatusSchema,
|
|
11703
12017
|
AgentSessionViewModelSchema,
|
|
11704
12018
|
ApplicationHandoffEndpointSchema,
|
|
11705
12019
|
ApplicationHandoffSchema,
|