@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
|
@@ -7704,11 +7704,70 @@ var AgentSessionStatusSchema = z5.enum([
|
|
|
7704
7704
|
"completed",
|
|
7705
7705
|
"failed"
|
|
7706
7706
|
]);
|
|
7707
|
+
var AgentSessionTerminalStatusSchema = z5.enum(["stopped", "completed", "failed"]);
|
|
7708
|
+
var AgentSessionRunSchema = z5.object({
|
|
7709
|
+
runId: ContractIdentifierSchema,
|
|
7710
|
+
sessionId: ContractIdentifierSchema,
|
|
7711
|
+
sourceMessageId: ContractIdentifierSchema,
|
|
7712
|
+
status: AgentSessionStatusSchema,
|
|
7713
|
+
startedAt: IsoDateTimeSchema,
|
|
7714
|
+
stoppingRequestedAt: IsoDateTimeSchema.optional(),
|
|
7715
|
+
stoppedAt: IsoDateTimeSchema.optional(),
|
|
7716
|
+
completedAt: IsoDateTimeSchema.optional(),
|
|
7717
|
+
failedAt: IsoDateTimeSchema.optional(),
|
|
7718
|
+
durationMs: z5.number().nonnegative().optional()
|
|
7719
|
+
}).strict().superRefine((value, context) => {
|
|
7720
|
+
const terminalTimestamps = [value.stoppedAt, value.completedAt, value.failedAt].filter(Boolean);
|
|
7721
|
+
if (terminalTimestamps.length > 1) {
|
|
7722
|
+
context.addIssue({
|
|
7723
|
+
code: "custom",
|
|
7724
|
+
path: ["status"],
|
|
7725
|
+
message: "A run may declare only one terminal timestamp."
|
|
7726
|
+
});
|
|
7727
|
+
}
|
|
7728
|
+
const expectedTimestamp = value.status === "stopped" ? value.stoppedAt : value.status === "completed" ? value.completedAt : value.status === "failed" ? value.failedAt : void 0;
|
|
7729
|
+
if (AgentSessionTerminalStatusSchema.safeParse(value.status).success && !expectedTimestamp) {
|
|
7730
|
+
context.addIssue({
|
|
7731
|
+
code: "custom",
|
|
7732
|
+
path: [value.status === "stopped" ? "stoppedAt" : value.status === "completed" ? "completedAt" : "failedAt"],
|
|
7733
|
+
message: `Run status ${value.status} requires its matching terminal timestamp.`
|
|
7734
|
+
});
|
|
7735
|
+
}
|
|
7736
|
+
if (!AgentSessionTerminalStatusSchema.safeParse(value.status).success && terminalTimestamps.length > 0) {
|
|
7737
|
+
context.addIssue({
|
|
7738
|
+
code: "custom",
|
|
7739
|
+
path: ["status"],
|
|
7740
|
+
message: "A non-terminal run must not declare a terminal timestamp."
|
|
7741
|
+
});
|
|
7742
|
+
}
|
|
7743
|
+
if ((value.status === "stopping" || value.status === "stopped") && !value.stoppingRequestedAt) {
|
|
7744
|
+
context.addIssue({
|
|
7745
|
+
code: "custom",
|
|
7746
|
+
path: ["stoppingRequestedAt"],
|
|
7747
|
+
message: `Run status ${value.status} requires stoppingRequestedAt.`
|
|
7748
|
+
});
|
|
7749
|
+
}
|
|
7750
|
+
if (!isAgentSessionTerminalStatus(value.status) && value.durationMs !== void 0) {
|
|
7751
|
+
context.addIssue({
|
|
7752
|
+
code: "custom",
|
|
7753
|
+
path: ["durationMs"],
|
|
7754
|
+
message: "Only a terminal run may declare durationMs."
|
|
7755
|
+
});
|
|
7756
|
+
}
|
|
7757
|
+
if (isAgentSessionTerminalStatus(value.status) && value.durationMs === void 0) {
|
|
7758
|
+
context.addIssue({
|
|
7759
|
+
code: "custom",
|
|
7760
|
+
path: ["durationMs"],
|
|
7761
|
+
message: `Terminal run status ${value.status} requires durationMs.`
|
|
7762
|
+
});
|
|
7763
|
+
}
|
|
7764
|
+
});
|
|
7707
7765
|
var AgentSessionCommandTypeSchema = z5.enum(["stop", "resume", "retry", "approval"]);
|
|
7708
7766
|
var AgentSessionCommandHeaderSchema = z5.object({
|
|
7709
7767
|
contract: z5.literal("AgentSessionCommand"),
|
|
7710
7768
|
commandId: ContractIdentifierSchema,
|
|
7711
7769
|
sessionId: ContractIdentifierSchema,
|
|
7770
|
+
runId: ContractIdentifierSchema.optional(),
|
|
7712
7771
|
idempotencyKey: ContractIdentifierSchema,
|
|
7713
7772
|
expectedSequence: z5.number().int().min(-1),
|
|
7714
7773
|
issuedAt: IsoDateTimeSchema
|
|
@@ -7733,8 +7792,14 @@ var AgentSessionCommandSchema = z5.discriminatedUnion("commandType", [
|
|
|
7733
7792
|
reason: z5.string().trim().min(1).optional()
|
|
7734
7793
|
})
|
|
7735
7794
|
]);
|
|
7795
|
+
var AgentSessionTargetedCommandSchema = AgentSessionCommandSchema.and(
|
|
7796
|
+
z5.object({ runId: ContractIdentifierSchema })
|
|
7797
|
+
);
|
|
7736
7798
|
var AgentSessionCommandErrorCodeSchema = z5.enum([
|
|
7737
7799
|
"SESSION_NOT_FOUND",
|
|
7800
|
+
"RUN_NOT_FOUND",
|
|
7801
|
+
"RUN_ALREADY_FINISHED",
|
|
7802
|
+
"STOP_TIMEOUT",
|
|
7738
7803
|
"COMMAND_NOT_SUPPORTED",
|
|
7739
7804
|
"CAPABILITY_UNAVAILABLE",
|
|
7740
7805
|
"SEQUENCE_CONFLICT",
|
|
@@ -7749,11 +7814,13 @@ var AgentSessionCommandResultSchema = z5.object({
|
|
|
7749
7814
|
contract: z5.literal("AgentSessionCommandResult"),
|
|
7750
7815
|
commandId: ContractIdentifierSchema,
|
|
7751
7816
|
sessionId: ContractIdentifierSchema,
|
|
7817
|
+
runId: ContractIdentifierSchema.optional(),
|
|
7752
7818
|
idempotencyKey: ContractIdentifierSchema,
|
|
7753
7819
|
outcome: z5.enum(["accepted", "duplicate", "rejected", "failed"]),
|
|
7754
7820
|
sessionStatus: AgentSessionStatusSchema,
|
|
7755
7821
|
acceptedSequence: z5.number().int().nonnegative().optional(),
|
|
7756
7822
|
resultEventIds: z5.array(ContractIdentifierSchema).default([]),
|
|
7823
|
+
termination: z5.enum(["requested", "confirmed"]).optional(),
|
|
7757
7824
|
error: z5.object({
|
|
7758
7825
|
code: AgentSessionCommandErrorCodeSchema,
|
|
7759
7826
|
message: z5.string(),
|
|
@@ -7769,11 +7836,30 @@ var AgentSessionCommandResultSchema = z5.object({
|
|
|
7769
7836
|
message: requiresError ? "Rejected and failed command results require an error." : "Accepted and duplicate command results must not contain an error."
|
|
7770
7837
|
});
|
|
7771
7838
|
}
|
|
7839
|
+
if (value.termination === "requested" && value.sessionStatus !== "stopping") {
|
|
7840
|
+
context.addIssue({
|
|
7841
|
+
code: "custom",
|
|
7842
|
+
path: ["termination"],
|
|
7843
|
+
message: "A requested termination must leave the run in stopping status."
|
|
7844
|
+
});
|
|
7845
|
+
}
|
|
7846
|
+
if (value.termination === "confirmed" && !isAgentSessionTerminalStatus(value.sessionStatus)) {
|
|
7847
|
+
context.addIssue({
|
|
7848
|
+
code: "custom",
|
|
7849
|
+
path: ["termination"],
|
|
7850
|
+
message: "A confirmed termination requires a terminal run status."
|
|
7851
|
+
});
|
|
7852
|
+
}
|
|
7772
7853
|
});
|
|
7854
|
+
function isAgentSessionTerminalStatus(status) {
|
|
7855
|
+
return AgentSessionTerminalStatusSchema.safeParse(status).success;
|
|
7856
|
+
}
|
|
7773
7857
|
var AgentSessionEventHeaderSchema = z5.object({
|
|
7774
7858
|
contract: z5.literal("AgentSessionEvent"),
|
|
7775
7859
|
eventId: ContractIdentifierSchema,
|
|
7776
7860
|
sessionId: ContractIdentifierSchema,
|
|
7861
|
+
runId: ContractIdentifierSchema.optional(),
|
|
7862
|
+
sourceMessageId: ContractIdentifierSchema.optional(),
|
|
7777
7863
|
sequence: z5.number().int().nonnegative(),
|
|
7778
7864
|
idempotencyKey: ContractIdentifierSchema,
|
|
7779
7865
|
occurredAt: IsoDateTimeSchema
|
|
@@ -7833,7 +7919,13 @@ var AgentSessionEventSchema = z5.discriminatedUnion("eventType", [
|
|
|
7833
7919
|
}),
|
|
7834
7920
|
sessionEvent("status", {
|
|
7835
7921
|
status: AgentSessionStatusSchema,
|
|
7836
|
-
detail: z5.string().optional()
|
|
7922
|
+
detail: z5.string().optional(),
|
|
7923
|
+
startedAt: IsoDateTimeSchema.optional(),
|
|
7924
|
+
stoppingRequestedAt: IsoDateTimeSchema.optional(),
|
|
7925
|
+
stoppedAt: IsoDateTimeSchema.optional(),
|
|
7926
|
+
completedAt: IsoDateTimeSchema.optional(),
|
|
7927
|
+
failedAt: IsoDateTimeSchema.optional(),
|
|
7928
|
+
durationMs: z5.number().nonnegative().optional()
|
|
7837
7929
|
}),
|
|
7838
7930
|
sessionEvent("artifact", {
|
|
7839
7931
|
artifactId: ContractIdentifierSchema,
|
|
@@ -7889,6 +7981,34 @@ var AgentSessionEventSchema = z5.discriminatedUnion("eventType", [
|
|
|
7889
7981
|
output: z5.string().optional()
|
|
7890
7982
|
})
|
|
7891
7983
|
]);
|
|
7984
|
+
var AgentSessionRunEventSchema = AgentSessionEventSchema.superRefine((value, context) => {
|
|
7985
|
+
if (!value.runId) {
|
|
7986
|
+
context.addIssue({ code: "custom", path: ["runId"], message: "Run events require runId." });
|
|
7987
|
+
}
|
|
7988
|
+
if (!value.sourceMessageId) {
|
|
7989
|
+
context.addIssue({
|
|
7990
|
+
code: "custom",
|
|
7991
|
+
path: ["sourceMessageId"],
|
|
7992
|
+
message: "Run events require sourceMessageId."
|
|
7993
|
+
});
|
|
7994
|
+
}
|
|
7995
|
+
if (value.eventType !== "status") return;
|
|
7996
|
+
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;
|
|
7997
|
+
if (requiredTimeField && !value.payload[requiredTimeField]) {
|
|
7998
|
+
context.addIssue({
|
|
7999
|
+
code: "custom",
|
|
8000
|
+
path: ["payload", requiredTimeField],
|
|
8001
|
+
message: `Run status ${value.payload.status} requires ${requiredTimeField}.`
|
|
8002
|
+
});
|
|
8003
|
+
}
|
|
8004
|
+
if (isAgentSessionTerminalStatus(value.payload.status) && value.payload.durationMs === void 0) {
|
|
8005
|
+
context.addIssue({
|
|
8006
|
+
code: "custom",
|
|
8007
|
+
path: ["payload", "durationMs"],
|
|
8008
|
+
message: `Terminal run status ${value.payload.status} requires durationMs.`
|
|
8009
|
+
});
|
|
8010
|
+
}
|
|
8011
|
+
});
|
|
7892
8012
|
var AgentSessionViewModelSchema = z5.object({
|
|
7893
8013
|
contract: z5.literal("AgentSessionViewModel"),
|
|
7894
8014
|
sessionId: ContractIdentifierSchema,
|
|
@@ -11554,7 +11674,8 @@ var TenantHeadbarModuleLeafSchema = z10.object({
|
|
|
11554
11674
|
disabled: z10.boolean().optional(),
|
|
11555
11675
|
icon: z10.string().optional(),
|
|
11556
11676
|
showQuickSwitcher: z10.boolean().optional(),
|
|
11557
|
-
showSidebar: z10.boolean().optional()
|
|
11677
|
+
showSidebar: z10.boolean().optional(),
|
|
11678
|
+
showContentFrame: z10.boolean().optional()
|
|
11558
11679
|
}).strict();
|
|
11559
11680
|
var TenantHeadbarModuleItemSchema = TenantHeadbarModuleLeafSchema.extend({
|
|
11560
11681
|
children: z10.array(TenantHeadbarModuleLeafSchema).optional()
|