@inf-monkeys-tech/monkeys 1.0.19 → 1.0.21
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 +513 -0
- package/lib/contracts/agent.d.ts.map +1 -1
- package/lib/contracts/agent.js +155 -1
- package/lib/contracts/agent.js.map +1 -1
- package/lib/contracts/tenant.d.ts +8 -0
- package/lib/contracts/tenant.d.ts.map +1 -1
- package/lib/contracts/tenant.js +1 -0
- package/lib/contracts/tenant.js.map +1 -1
- package/lib/esm/contracts/index.mjs +142 -2
- package/lib/esm/contracts/index.mjs.map +1 -1
- package/lib/esm/index.mjs +145 -2
- package/lib/esm/index.mjs.map +1 -1
- package/lib/esm/runtime/index.mjs +123 -2
- package/lib/esm/runtime/index.mjs.map +1 -1
- package/lib/esm/schemas/index.mjs +130 -2
- package/lib/esm/schemas/index.mjs.map +1 -1
- package/lib/json-schema/agent-session-command-result.schema.json +15 -0
- package/lib/json-schema/agent-session-command.schema.json +20 -0
- package/lib/json-schema/agent-session-event.schema.json +179 -0
- package/lib/json-schema/agent-session-run-event.schema.json +1501 -0
- package/lib/json-schema/agent-session-run.schema.json +72 -0
- package/lib/json-schema/agent-session-targeted-command.schema.json +302 -0
- package/lib/json-schema/agent-session-view-model.schema.json +179 -0
- package/lib/json-schema/index.json +3 -0
- package/lib/json-schema/tenant-product-config.schema.json +6 -0
- package/lib/json-schema/tenant-runtime-config.schema.json +6 -0
- package/lib/schemas/index.d.ts +504 -1
- package/lib/schemas/index.d.ts.map +1 -1
- package/lib/schemas/index.js +10 -3
- package/lib/schemas/index.js.map +1 -1
- package/package.json +1 -1
- package/test/fixtures/agent-session-runs.json +51 -0
|
@@ -7200,11 +7200,70 @@ var AgentSessionStatusSchema = z5.enum([
|
|
|
7200
7200
|
"completed",
|
|
7201
7201
|
"failed"
|
|
7202
7202
|
]);
|
|
7203
|
+
var AgentSessionTerminalStatusSchema = z5.enum(["stopped", "completed", "failed"]);
|
|
7204
|
+
var AgentSessionRunSchema = z5.object({
|
|
7205
|
+
runId: ContractIdentifierSchema,
|
|
7206
|
+
sessionId: ContractIdentifierSchema,
|
|
7207
|
+
sourceMessageId: ContractIdentifierSchema,
|
|
7208
|
+
status: AgentSessionStatusSchema,
|
|
7209
|
+
startedAt: IsoDateTimeSchema,
|
|
7210
|
+
stoppingRequestedAt: IsoDateTimeSchema.optional(),
|
|
7211
|
+
stoppedAt: IsoDateTimeSchema.optional(),
|
|
7212
|
+
completedAt: IsoDateTimeSchema.optional(),
|
|
7213
|
+
failedAt: IsoDateTimeSchema.optional(),
|
|
7214
|
+
durationMs: z5.number().nonnegative().optional()
|
|
7215
|
+
}).strict().superRefine((value, context) => {
|
|
7216
|
+
const terminalTimestamps = [value.stoppedAt, value.completedAt, value.failedAt].filter(Boolean);
|
|
7217
|
+
if (terminalTimestamps.length > 1) {
|
|
7218
|
+
context.addIssue({
|
|
7219
|
+
code: "custom",
|
|
7220
|
+
path: ["status"],
|
|
7221
|
+
message: "A run may declare only one terminal timestamp."
|
|
7222
|
+
});
|
|
7223
|
+
}
|
|
7224
|
+
const expectedTimestamp = value.status === "stopped" ? value.stoppedAt : value.status === "completed" ? value.completedAt : value.status === "failed" ? value.failedAt : void 0;
|
|
7225
|
+
if (AgentSessionTerminalStatusSchema.safeParse(value.status).success && !expectedTimestamp) {
|
|
7226
|
+
context.addIssue({
|
|
7227
|
+
code: "custom",
|
|
7228
|
+
path: [value.status === "stopped" ? "stoppedAt" : value.status === "completed" ? "completedAt" : "failedAt"],
|
|
7229
|
+
message: `Run status ${value.status} requires its matching terminal timestamp.`
|
|
7230
|
+
});
|
|
7231
|
+
}
|
|
7232
|
+
if (!AgentSessionTerminalStatusSchema.safeParse(value.status).success && terminalTimestamps.length > 0) {
|
|
7233
|
+
context.addIssue({
|
|
7234
|
+
code: "custom",
|
|
7235
|
+
path: ["status"],
|
|
7236
|
+
message: "A non-terminal run must not declare a terminal timestamp."
|
|
7237
|
+
});
|
|
7238
|
+
}
|
|
7239
|
+
if ((value.status === "stopping" || value.status === "stopped") && !value.stoppingRequestedAt) {
|
|
7240
|
+
context.addIssue({
|
|
7241
|
+
code: "custom",
|
|
7242
|
+
path: ["stoppingRequestedAt"],
|
|
7243
|
+
message: `Run status ${value.status} requires stoppingRequestedAt.`
|
|
7244
|
+
});
|
|
7245
|
+
}
|
|
7246
|
+
if (!isAgentSessionTerminalStatus(value.status) && value.durationMs !== void 0) {
|
|
7247
|
+
context.addIssue({
|
|
7248
|
+
code: "custom",
|
|
7249
|
+
path: ["durationMs"],
|
|
7250
|
+
message: "Only a terminal run may declare durationMs."
|
|
7251
|
+
});
|
|
7252
|
+
}
|
|
7253
|
+
if (isAgentSessionTerminalStatus(value.status) && value.durationMs === void 0) {
|
|
7254
|
+
context.addIssue({
|
|
7255
|
+
code: "custom",
|
|
7256
|
+
path: ["durationMs"],
|
|
7257
|
+
message: `Terminal run status ${value.status} requires durationMs.`
|
|
7258
|
+
});
|
|
7259
|
+
}
|
|
7260
|
+
});
|
|
7203
7261
|
var AgentSessionCommandTypeSchema = z5.enum(["stop", "resume", "retry", "approval"]);
|
|
7204
7262
|
var AgentSessionCommandHeaderSchema = z5.object({
|
|
7205
7263
|
contract: z5.literal("AgentSessionCommand"),
|
|
7206
7264
|
commandId: ContractIdentifierSchema,
|
|
7207
7265
|
sessionId: ContractIdentifierSchema,
|
|
7266
|
+
runId: ContractIdentifierSchema.optional(),
|
|
7208
7267
|
idempotencyKey: ContractIdentifierSchema,
|
|
7209
7268
|
expectedSequence: z5.number().int().min(-1),
|
|
7210
7269
|
issuedAt: IsoDateTimeSchema
|
|
@@ -7229,8 +7288,14 @@ var AgentSessionCommandSchema = z5.discriminatedUnion("commandType", [
|
|
|
7229
7288
|
reason: z5.string().trim().min(1).optional()
|
|
7230
7289
|
})
|
|
7231
7290
|
]);
|
|
7291
|
+
var AgentSessionTargetedCommandSchema = AgentSessionCommandSchema.and(
|
|
7292
|
+
z5.object({ runId: ContractIdentifierSchema })
|
|
7293
|
+
);
|
|
7232
7294
|
var AgentSessionCommandErrorCodeSchema = z5.enum([
|
|
7233
7295
|
"SESSION_NOT_FOUND",
|
|
7296
|
+
"RUN_NOT_FOUND",
|
|
7297
|
+
"RUN_ALREADY_FINISHED",
|
|
7298
|
+
"STOP_TIMEOUT",
|
|
7234
7299
|
"COMMAND_NOT_SUPPORTED",
|
|
7235
7300
|
"CAPABILITY_UNAVAILABLE",
|
|
7236
7301
|
"SEQUENCE_CONFLICT",
|
|
@@ -7245,11 +7310,13 @@ var AgentSessionCommandResultSchema = z5.object({
|
|
|
7245
7310
|
contract: z5.literal("AgentSessionCommandResult"),
|
|
7246
7311
|
commandId: ContractIdentifierSchema,
|
|
7247
7312
|
sessionId: ContractIdentifierSchema,
|
|
7313
|
+
runId: ContractIdentifierSchema.optional(),
|
|
7248
7314
|
idempotencyKey: ContractIdentifierSchema,
|
|
7249
7315
|
outcome: z5.enum(["accepted", "duplicate", "rejected", "failed"]),
|
|
7250
7316
|
sessionStatus: AgentSessionStatusSchema,
|
|
7251
7317
|
acceptedSequence: z5.number().int().nonnegative().optional(),
|
|
7252
7318
|
resultEventIds: z5.array(ContractIdentifierSchema).default([]),
|
|
7319
|
+
termination: z5.enum(["requested", "confirmed"]).optional(),
|
|
7253
7320
|
error: z5.object({
|
|
7254
7321
|
code: AgentSessionCommandErrorCodeSchema,
|
|
7255
7322
|
message: z5.string(),
|
|
@@ -7265,11 +7332,30 @@ var AgentSessionCommandResultSchema = z5.object({
|
|
|
7265
7332
|
message: requiresError ? "Rejected and failed command results require an error." : "Accepted and duplicate command results must not contain an error."
|
|
7266
7333
|
});
|
|
7267
7334
|
}
|
|
7335
|
+
if (value.termination === "requested" && value.sessionStatus !== "stopping") {
|
|
7336
|
+
context.addIssue({
|
|
7337
|
+
code: "custom",
|
|
7338
|
+
path: ["termination"],
|
|
7339
|
+
message: "A requested termination must leave the run in stopping status."
|
|
7340
|
+
});
|
|
7341
|
+
}
|
|
7342
|
+
if (value.termination === "confirmed" && !isAgentSessionTerminalStatus(value.sessionStatus)) {
|
|
7343
|
+
context.addIssue({
|
|
7344
|
+
code: "custom",
|
|
7345
|
+
path: ["termination"],
|
|
7346
|
+
message: "A confirmed termination requires a terminal run status."
|
|
7347
|
+
});
|
|
7348
|
+
}
|
|
7268
7349
|
});
|
|
7350
|
+
function isAgentSessionTerminalStatus(status) {
|
|
7351
|
+
return AgentSessionTerminalStatusSchema.safeParse(status).success;
|
|
7352
|
+
}
|
|
7269
7353
|
var AgentSessionEventHeaderSchema = z5.object({
|
|
7270
7354
|
contract: z5.literal("AgentSessionEvent"),
|
|
7271
7355
|
eventId: ContractIdentifierSchema,
|
|
7272
7356
|
sessionId: ContractIdentifierSchema,
|
|
7357
|
+
runId: ContractIdentifierSchema.optional(),
|
|
7358
|
+
sourceMessageId: ContractIdentifierSchema.optional(),
|
|
7273
7359
|
sequence: z5.number().int().nonnegative(),
|
|
7274
7360
|
idempotencyKey: ContractIdentifierSchema,
|
|
7275
7361
|
occurredAt: IsoDateTimeSchema
|
|
@@ -7329,7 +7415,13 @@ var AgentSessionEventSchema = z5.discriminatedUnion("eventType", [
|
|
|
7329
7415
|
}),
|
|
7330
7416
|
sessionEvent("status", {
|
|
7331
7417
|
status: AgentSessionStatusSchema,
|
|
7332
|
-
detail: z5.string().optional()
|
|
7418
|
+
detail: z5.string().optional(),
|
|
7419
|
+
startedAt: IsoDateTimeSchema.optional(),
|
|
7420
|
+
stoppingRequestedAt: IsoDateTimeSchema.optional(),
|
|
7421
|
+
stoppedAt: IsoDateTimeSchema.optional(),
|
|
7422
|
+
completedAt: IsoDateTimeSchema.optional(),
|
|
7423
|
+
failedAt: IsoDateTimeSchema.optional(),
|
|
7424
|
+
durationMs: z5.number().nonnegative().optional()
|
|
7333
7425
|
}),
|
|
7334
7426
|
sessionEvent("artifact", {
|
|
7335
7427
|
artifactId: ContractIdentifierSchema,
|
|
@@ -7385,6 +7477,34 @@ var AgentSessionEventSchema = z5.discriminatedUnion("eventType", [
|
|
|
7385
7477
|
output: z5.string().optional()
|
|
7386
7478
|
})
|
|
7387
7479
|
]);
|
|
7480
|
+
var AgentSessionRunEventSchema = AgentSessionEventSchema.superRefine((value, context) => {
|
|
7481
|
+
if (!value.runId) {
|
|
7482
|
+
context.addIssue({ code: "custom", path: ["runId"], message: "Run events require runId." });
|
|
7483
|
+
}
|
|
7484
|
+
if (!value.sourceMessageId) {
|
|
7485
|
+
context.addIssue({
|
|
7486
|
+
code: "custom",
|
|
7487
|
+
path: ["sourceMessageId"],
|
|
7488
|
+
message: "Run events require sourceMessageId."
|
|
7489
|
+
});
|
|
7490
|
+
}
|
|
7491
|
+
if (value.eventType !== "status") return;
|
|
7492
|
+
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;
|
|
7493
|
+
if (requiredTimeField && !value.payload[requiredTimeField]) {
|
|
7494
|
+
context.addIssue({
|
|
7495
|
+
code: "custom",
|
|
7496
|
+
path: ["payload", requiredTimeField],
|
|
7497
|
+
message: `Run status ${value.payload.status} requires ${requiredTimeField}.`
|
|
7498
|
+
});
|
|
7499
|
+
}
|
|
7500
|
+
if (isAgentSessionTerminalStatus(value.payload.status) && value.payload.durationMs === void 0) {
|
|
7501
|
+
context.addIssue({
|
|
7502
|
+
code: "custom",
|
|
7503
|
+
path: ["payload", "durationMs"],
|
|
7504
|
+
message: `Terminal run status ${value.payload.status} requires durationMs.`
|
|
7505
|
+
});
|
|
7506
|
+
}
|
|
7507
|
+
});
|
|
7388
7508
|
var AgentSessionViewModelSchema = z5.object({
|
|
7389
7509
|
contract: z5.literal("AgentSessionViewModel"),
|
|
7390
7510
|
sessionId: ContractIdentifierSchema,
|
|
@@ -10352,7 +10472,8 @@ var TenantHeadbarModuleLeafSchema = z12.object({
|
|
|
10352
10472
|
disabled: z12.boolean().optional(),
|
|
10353
10473
|
icon: z12.string().optional(),
|
|
10354
10474
|
showQuickSwitcher: z12.boolean().optional(),
|
|
10355
|
-
showSidebar: z12.boolean().optional()
|
|
10475
|
+
showSidebar: z12.boolean().optional(),
|
|
10476
|
+
showContentFrame: z12.boolean().optional()
|
|
10356
10477
|
}).strict();
|
|
10357
10478
|
var TenantHeadbarModuleItemSchema = TenantHeadbarModuleLeafSchema.extend({
|
|
10358
10479
|
children: z12.array(TenantHeadbarModuleLeafSchema).optional()
|
|
@@ -11622,8 +11743,11 @@ var WorkflowCompletionReceiptSchema = z15.object({
|
|
|
11622
11743
|
// src/schemas/index.ts
|
|
11623
11744
|
var canonicalContractSchemas = {
|
|
11624
11745
|
"agent-session-command": AgentSessionCommandSchema,
|
|
11746
|
+
"agent-session-targeted-command": AgentSessionTargetedCommandSchema,
|
|
11625
11747
|
"agent-session-command-result": AgentSessionCommandResultSchema,
|
|
11626
11748
|
"agent-session-event": AgentSessionEventSchema,
|
|
11749
|
+
"agent-session-run-event": AgentSessionRunEventSchema,
|
|
11750
|
+
"agent-session-run": AgentSessionRunSchema,
|
|
11627
11751
|
"agent-session-view-model": AgentSessionViewModelSchema,
|
|
11628
11752
|
"agent-runtime-event": AgentRuntimeEventSchema,
|
|
11629
11753
|
"application-run": ApplicationRunSchema,
|
|
@@ -11697,8 +11821,12 @@ export {
|
|
|
11697
11821
|
AgentSessionCommandSchema,
|
|
11698
11822
|
AgentSessionCommandTypeSchema,
|
|
11699
11823
|
AgentSessionEventSchema,
|
|
11824
|
+
AgentSessionRunEventSchema,
|
|
11825
|
+
AgentSessionRunSchema,
|
|
11700
11826
|
AgentSessionSnapshotSchema,
|
|
11701
11827
|
AgentSessionStatusSchema,
|
|
11828
|
+
AgentSessionTargetedCommandSchema,
|
|
11829
|
+
AgentSessionTerminalStatusSchema,
|
|
11702
11830
|
AgentSessionViewModelSchema,
|
|
11703
11831
|
ApplicationHandoffEndpointSchema,
|
|
11704
11832
|
ApplicationHandoffSchema,
|