@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
|
@@ -7646,7 +7646,11 @@ var AgentSessionCapabilitySchema = z5.enum([
|
|
|
7646
7646
|
"diff",
|
|
7647
7647
|
"workspaceFiles",
|
|
7648
7648
|
"terminal",
|
|
7649
|
-
"testResults"
|
|
7649
|
+
"testResults",
|
|
7650
|
+
"threadForking",
|
|
7651
|
+
"editAndRerun",
|
|
7652
|
+
"steering",
|
|
7653
|
+
"summary"
|
|
7650
7654
|
]);
|
|
7651
7655
|
var AgentSessionCapabilitiesSchema = z5.object({
|
|
7652
7656
|
text: z5.boolean().default(true),
|
|
@@ -7665,7 +7669,11 @@ var AgentSessionCapabilitiesSchema = z5.object({
|
|
|
7665
7669
|
diff: z5.boolean().default(false),
|
|
7666
7670
|
workspaceFiles: z5.boolean().default(false),
|
|
7667
7671
|
terminal: z5.boolean().default(false),
|
|
7668
|
-
testResults: z5.boolean().default(false)
|
|
7672
|
+
testResults: z5.boolean().default(false),
|
|
7673
|
+
threadForking: z5.boolean().default(false),
|
|
7674
|
+
editAndRerun: z5.boolean().default(false),
|
|
7675
|
+
steering: z5.boolean().default(false),
|
|
7676
|
+
summary: z5.boolean().default(false)
|
|
7669
7677
|
}).strict();
|
|
7670
7678
|
var AGENT_SESSION_RUNTIME_CAPABILITIES = Object.freeze({
|
|
7671
7679
|
chatbot: AgentSessionCapabilitiesSchema.parse({ text: true, tools: true, mcp: true, skills: true, approval: true, usage: true }),
|
|
@@ -7688,7 +7696,11 @@ var AGENT_SESSION_CAPABILITY_EVIDENCE = Object.freeze({
|
|
|
7688
7696
|
diff: { eventTypes: ["diff"], commandTypes: [] },
|
|
7689
7697
|
workspaceFiles: { eventTypes: ["workspace-file"], commandTypes: [] },
|
|
7690
7698
|
terminal: { eventTypes: ["terminal"], commandTypes: [] },
|
|
7691
|
-
testResults: { eventTypes: ["test-result"], commandTypes: [] }
|
|
7699
|
+
testResults: { eventTypes: ["test-result"], commandTypes: [] },
|
|
7700
|
+
threadForking: { eventTypes: [], commandTypes: ["fork"] },
|
|
7701
|
+
editAndRerun: { eventTypes: [], commandTypes: ["edit-and-rerun"] },
|
|
7702
|
+
steering: { eventTypes: [], commandTypes: ["steer"] },
|
|
7703
|
+
summary: { eventTypes: ["summary"], commandTypes: [] }
|
|
7692
7704
|
});
|
|
7693
7705
|
var AgentSessionSnapshotSchema = z5.object({
|
|
7694
7706
|
mode: AgentModeSchema,
|
|
@@ -7704,11 +7716,98 @@ var AgentSessionStatusSchema = z5.enum([
|
|
|
7704
7716
|
"completed",
|
|
7705
7717
|
"failed"
|
|
7706
7718
|
]);
|
|
7707
|
-
var
|
|
7719
|
+
var AgentSessionTerminalStatusSchema = z5.enum(["stopped", "completed", "failed"]);
|
|
7720
|
+
var AgentSessionLineageSchema = z5.object({
|
|
7721
|
+
forkedFromThreadId: ContractIdentifierSchema,
|
|
7722
|
+
forkedFromMessageId: ContractIdentifierSchema,
|
|
7723
|
+
sourceRunId: ContractIdentifierSchema
|
|
7724
|
+
}).strict();
|
|
7725
|
+
var AgentSessionContextInheritanceSchema = z5.object({
|
|
7726
|
+
messages: z5.enum(["through-source-message", "exclude"]),
|
|
7727
|
+
attachments: z5.enum(["inherit", "exclude"]),
|
|
7728
|
+
summaries: z5.enum(["inherit", "exclude"]),
|
|
7729
|
+
toolResults: z5.enum(["inherit", "exclude"]),
|
|
7730
|
+
codeChanges: z5.enum(["inherit", "exclude"])
|
|
7731
|
+
}).strict();
|
|
7732
|
+
var AgentSessionActiveBranchSchema = z5.object({
|
|
7733
|
+
branchId: ContractIdentifierSchema,
|
|
7734
|
+
threadId: ContractIdentifierSchema,
|
|
7735
|
+
sourceMessageId: ContractIdentifierSchema,
|
|
7736
|
+
runId: ContractIdentifierSchema,
|
|
7737
|
+
lineage: AgentSessionLineageSchema.optional(),
|
|
7738
|
+
createdAt: IsoDateTimeSchema
|
|
7739
|
+
}).strict();
|
|
7740
|
+
var AgentSessionRunSchema = z5.object({
|
|
7741
|
+
runId: ContractIdentifierSchema,
|
|
7742
|
+
sessionId: ContractIdentifierSchema,
|
|
7743
|
+
sourceMessageId: ContractIdentifierSchema,
|
|
7744
|
+
status: AgentSessionStatusSchema,
|
|
7745
|
+
startedAt: IsoDateTimeSchema,
|
|
7746
|
+
stoppingRequestedAt: IsoDateTimeSchema.optional(),
|
|
7747
|
+
stoppedAt: IsoDateTimeSchema.optional(),
|
|
7748
|
+
completedAt: IsoDateTimeSchema.optional(),
|
|
7749
|
+
failedAt: IsoDateTimeSchema.optional(),
|
|
7750
|
+
durationMs: z5.number().nonnegative().optional()
|
|
7751
|
+
}).strict().superRefine((value, context) => {
|
|
7752
|
+
const terminalTimestamps = [value.stoppedAt, value.completedAt, value.failedAt].filter(Boolean);
|
|
7753
|
+
if (terminalTimestamps.length > 1) {
|
|
7754
|
+
context.addIssue({
|
|
7755
|
+
code: "custom",
|
|
7756
|
+
path: ["status"],
|
|
7757
|
+
message: "A run may declare only one terminal timestamp."
|
|
7758
|
+
});
|
|
7759
|
+
}
|
|
7760
|
+
const expectedTimestamp = value.status === "stopped" ? value.stoppedAt : value.status === "completed" ? value.completedAt : value.status === "failed" ? value.failedAt : void 0;
|
|
7761
|
+
if (AgentSessionTerminalStatusSchema.safeParse(value.status).success && !expectedTimestamp) {
|
|
7762
|
+
context.addIssue({
|
|
7763
|
+
code: "custom",
|
|
7764
|
+
path: [value.status === "stopped" ? "stoppedAt" : value.status === "completed" ? "completedAt" : "failedAt"],
|
|
7765
|
+
message: `Run status ${value.status} requires its matching terminal timestamp.`
|
|
7766
|
+
});
|
|
7767
|
+
}
|
|
7768
|
+
if (!AgentSessionTerminalStatusSchema.safeParse(value.status).success && terminalTimestamps.length > 0) {
|
|
7769
|
+
context.addIssue({
|
|
7770
|
+
code: "custom",
|
|
7771
|
+
path: ["status"],
|
|
7772
|
+
message: "A non-terminal run must not declare a terminal timestamp."
|
|
7773
|
+
});
|
|
7774
|
+
}
|
|
7775
|
+
if ((value.status === "stopping" || value.status === "stopped") && !value.stoppingRequestedAt) {
|
|
7776
|
+
context.addIssue({
|
|
7777
|
+
code: "custom",
|
|
7778
|
+
path: ["stoppingRequestedAt"],
|
|
7779
|
+
message: `Run status ${value.status} requires stoppingRequestedAt.`
|
|
7780
|
+
});
|
|
7781
|
+
}
|
|
7782
|
+
if (!isAgentSessionTerminalStatus(value.status) && value.durationMs !== void 0) {
|
|
7783
|
+
context.addIssue({
|
|
7784
|
+
code: "custom",
|
|
7785
|
+
path: ["durationMs"],
|
|
7786
|
+
message: "Only a terminal run may declare durationMs."
|
|
7787
|
+
});
|
|
7788
|
+
}
|
|
7789
|
+
if (isAgentSessionTerminalStatus(value.status) && value.durationMs === void 0) {
|
|
7790
|
+
context.addIssue({
|
|
7791
|
+
code: "custom",
|
|
7792
|
+
path: ["durationMs"],
|
|
7793
|
+
message: `Terminal run status ${value.status} requires durationMs.`
|
|
7794
|
+
});
|
|
7795
|
+
}
|
|
7796
|
+
});
|
|
7797
|
+
var AgentSessionCommandTypeSchema = z5.enum([
|
|
7798
|
+
"stop",
|
|
7799
|
+
"resume",
|
|
7800
|
+
"retry",
|
|
7801
|
+
"approval",
|
|
7802
|
+
"fork",
|
|
7803
|
+
"edit-and-rerun",
|
|
7804
|
+
"steer"
|
|
7805
|
+
]);
|
|
7708
7806
|
var AgentSessionCommandHeaderSchema = z5.object({
|
|
7709
7807
|
contract: z5.literal("AgentSessionCommand"),
|
|
7710
7808
|
commandId: ContractIdentifierSchema,
|
|
7711
7809
|
sessionId: ContractIdentifierSchema,
|
|
7810
|
+
runId: ContractIdentifierSchema.optional(),
|
|
7712
7811
|
idempotencyKey: ContractIdentifierSchema,
|
|
7713
7812
|
expectedSequence: z5.number().int().min(-1),
|
|
7714
7813
|
issuedAt: IsoDateTimeSchema
|
|
@@ -7731,10 +7830,41 @@ var AgentSessionCommandSchema = z5.discriminatedUnion("commandType", [
|
|
|
7731
7830
|
approvalId: ContractIdentifierSchema,
|
|
7732
7831
|
decision: z5.enum(["approved", "rejected"]),
|
|
7733
7832
|
reason: z5.string().trim().min(1).optional()
|
|
7833
|
+
}),
|
|
7834
|
+
sessionCommand("fork", {
|
|
7835
|
+
sourceThreadId: ContractIdentifierSchema,
|
|
7836
|
+
sourceMessageId: ContractIdentifierSchema,
|
|
7837
|
+
sourceRunId: ContractIdentifierSchema,
|
|
7838
|
+
inheritance: AgentSessionContextInheritanceSchema
|
|
7839
|
+
}),
|
|
7840
|
+
sessionCommand("edit-and-rerun", {
|
|
7841
|
+
sourceThreadId: ContractIdentifierSchema,
|
|
7842
|
+
sourceMessageId: ContractIdentifierSchema,
|
|
7843
|
+
sourceRunId: ContractIdentifierSchema,
|
|
7844
|
+
replacementParts: z5.array(JsonValueSchema).min(1),
|
|
7845
|
+
inheritance: AgentSessionContextInheritanceSchema
|
|
7846
|
+
}),
|
|
7847
|
+
sessionCommand("steer", {
|
|
7848
|
+
targetRunId: ContractIdentifierSchema,
|
|
7849
|
+
guidanceParts: z5.array(JsonValueSchema).min(1)
|
|
7734
7850
|
})
|
|
7735
|
-
])
|
|
7851
|
+
]).superRefine((value, context) => {
|
|
7852
|
+
if (value.commandType === "steer" && value.runId !== value.payload.targetRunId) {
|
|
7853
|
+
context.addIssue({
|
|
7854
|
+
code: "custom",
|
|
7855
|
+
path: ["payload", "targetRunId"],
|
|
7856
|
+
message: "Steering targetRunId must match the command runId."
|
|
7857
|
+
});
|
|
7858
|
+
}
|
|
7859
|
+
});
|
|
7860
|
+
var AgentSessionTargetedCommandSchema = AgentSessionCommandSchema.and(
|
|
7861
|
+
z5.object({ runId: ContractIdentifierSchema })
|
|
7862
|
+
);
|
|
7736
7863
|
var AgentSessionCommandErrorCodeSchema = z5.enum([
|
|
7737
7864
|
"SESSION_NOT_FOUND",
|
|
7865
|
+
"RUN_NOT_FOUND",
|
|
7866
|
+
"RUN_ALREADY_FINISHED",
|
|
7867
|
+
"STOP_TIMEOUT",
|
|
7738
7868
|
"COMMAND_NOT_SUPPORTED",
|
|
7739
7869
|
"CAPABILITY_UNAVAILABLE",
|
|
7740
7870
|
"SEQUENCE_CONFLICT",
|
|
@@ -7743,17 +7873,28 @@ var AgentSessionCommandErrorCodeSchema = z5.enum([
|
|
|
7743
7873
|
"TARGET_EVENT_NOT_RETRYABLE",
|
|
7744
7874
|
"APPROVAL_NOT_FOUND",
|
|
7745
7875
|
"APPROVAL_ALREADY_RESOLVED",
|
|
7876
|
+
"SOURCE_THREAD_NOT_FOUND",
|
|
7877
|
+
"SOURCE_MESSAGE_NOT_FOUND",
|
|
7878
|
+
"SOURCE_RUN_NOT_FOUND",
|
|
7879
|
+
"SOURCE_LINEAGE_INVALID",
|
|
7880
|
+
"ACTIVE_BRANCH_NOT_FOUND",
|
|
7746
7881
|
"COMMAND_EXECUTION_FAILED"
|
|
7747
7882
|
]);
|
|
7748
7883
|
var AgentSessionCommandResultSchema = z5.object({
|
|
7749
7884
|
contract: z5.literal("AgentSessionCommandResult"),
|
|
7750
7885
|
commandId: ContractIdentifierSchema,
|
|
7751
7886
|
sessionId: ContractIdentifierSchema,
|
|
7887
|
+
runId: ContractIdentifierSchema.optional(),
|
|
7752
7888
|
idempotencyKey: ContractIdentifierSchema,
|
|
7753
7889
|
outcome: z5.enum(["accepted", "duplicate", "rejected", "failed"]),
|
|
7754
7890
|
sessionStatus: AgentSessionStatusSchema,
|
|
7755
7891
|
acceptedSequence: z5.number().int().nonnegative().optional(),
|
|
7756
7892
|
resultEventIds: z5.array(ContractIdentifierSchema).default([]),
|
|
7893
|
+
operation: z5.object({
|
|
7894
|
+
lineage: AgentSessionLineageSchema,
|
|
7895
|
+
activeBranch: AgentSessionActiveBranchSchema
|
|
7896
|
+
}).strict().optional(),
|
|
7897
|
+
termination: z5.enum(["requested", "confirmed"]).optional(),
|
|
7757
7898
|
error: z5.object({
|
|
7758
7899
|
code: AgentSessionCommandErrorCodeSchema,
|
|
7759
7900
|
message: z5.string(),
|
|
@@ -7769,11 +7910,121 @@ var AgentSessionCommandResultSchema = z5.object({
|
|
|
7769
7910
|
message: requiresError ? "Rejected and failed command results require an error." : "Accepted and duplicate command results must not contain an error."
|
|
7770
7911
|
});
|
|
7771
7912
|
}
|
|
7913
|
+
if (value.termination === "requested" && value.sessionStatus !== "stopping") {
|
|
7914
|
+
context.addIssue({
|
|
7915
|
+
code: "custom",
|
|
7916
|
+
path: ["termination"],
|
|
7917
|
+
message: "A requested termination must leave the run in stopping status."
|
|
7918
|
+
});
|
|
7919
|
+
}
|
|
7920
|
+
if (value.termination === "confirmed" && !isAgentSessionTerminalStatus(value.sessionStatus)) {
|
|
7921
|
+
context.addIssue({
|
|
7922
|
+
code: "custom",
|
|
7923
|
+
path: ["termination"],
|
|
7924
|
+
message: "A confirmed termination requires a terminal run status."
|
|
7925
|
+
});
|
|
7926
|
+
}
|
|
7927
|
+
if (value.operation && !value.operation.activeBranch.lineage) {
|
|
7928
|
+
context.addIssue({
|
|
7929
|
+
code: "custom",
|
|
7930
|
+
path: ["operation", "activeBranch", "lineage"],
|
|
7931
|
+
message: "A branch operation result requires lineage on its active branch."
|
|
7932
|
+
});
|
|
7933
|
+
}
|
|
7934
|
+
const operation = value.operation;
|
|
7935
|
+
if (operation?.activeBranch.lineage) {
|
|
7936
|
+
const { lineage } = operation;
|
|
7937
|
+
const branchLineage = operation.activeBranch.lineage;
|
|
7938
|
+
if (lineage.forkedFromThreadId !== branchLineage.forkedFromThreadId || lineage.forkedFromMessageId !== branchLineage.forkedFromMessageId || lineage.sourceRunId !== branchLineage.sourceRunId) {
|
|
7939
|
+
context.addIssue({
|
|
7940
|
+
code: "custom",
|
|
7941
|
+
path: ["operation", "activeBranch", "lineage"],
|
|
7942
|
+
message: "Active branch lineage must match the operation lineage."
|
|
7943
|
+
});
|
|
7944
|
+
}
|
|
7945
|
+
}
|
|
7946
|
+
if (value.operation && value.runId !== value.operation.activeBranch.runId) {
|
|
7947
|
+
context.addIssue({
|
|
7948
|
+
code: "custom",
|
|
7949
|
+
path: ["operation", "activeBranch", "runId"],
|
|
7950
|
+
message: "Active branch runId must match the command result runId."
|
|
7951
|
+
});
|
|
7952
|
+
}
|
|
7953
|
+
});
|
|
7954
|
+
var AgentSessionCommandPolicySchema = z5.object({
|
|
7955
|
+
capability: AgentSessionCapabilitySchema.optional(),
|
|
7956
|
+
allowedStatuses: z5.array(AgentSessionStatusSchema).min(1),
|
|
7957
|
+
requiresRunId: z5.boolean(),
|
|
7958
|
+
sourceSessionEffect: z5.enum(["transition", "preserve"]),
|
|
7959
|
+
idempotencyScope: z5.literal("session-command"),
|
|
7960
|
+
sequenceRule: z5.literal("match-current")
|
|
7961
|
+
}).strict();
|
|
7962
|
+
var sessionCommandPolicy = (policy) => AgentSessionCommandPolicySchema.parse(policy);
|
|
7963
|
+
var AGENT_SESSION_COMMAND_POLICIES = Object.freeze({
|
|
7964
|
+
stop: sessionCommandPolicy({
|
|
7965
|
+
allowedStatuses: ["queued", "running", "waiting_approval"],
|
|
7966
|
+
requiresRunId: true,
|
|
7967
|
+
sourceSessionEffect: "transition",
|
|
7968
|
+
idempotencyScope: "session-command",
|
|
7969
|
+
sequenceRule: "match-current"
|
|
7970
|
+
}),
|
|
7971
|
+
resume: sessionCommandPolicy({
|
|
7972
|
+
capability: "resume",
|
|
7973
|
+
allowedStatuses: ["stopped", "completed", "failed"],
|
|
7974
|
+
requiresRunId: true,
|
|
7975
|
+
sourceSessionEffect: "transition",
|
|
7976
|
+
idempotencyScope: "session-command",
|
|
7977
|
+
sequenceRule: "match-current"
|
|
7978
|
+
}),
|
|
7979
|
+
retry: sessionCommandPolicy({
|
|
7980
|
+
allowedStatuses: ["failed"],
|
|
7981
|
+
requiresRunId: true,
|
|
7982
|
+
sourceSessionEffect: "transition",
|
|
7983
|
+
idempotencyScope: "session-command",
|
|
7984
|
+
sequenceRule: "match-current"
|
|
7985
|
+
}),
|
|
7986
|
+
approval: sessionCommandPolicy({
|
|
7987
|
+
capability: "approval",
|
|
7988
|
+
allowedStatuses: ["waiting_approval"],
|
|
7989
|
+
requiresRunId: true,
|
|
7990
|
+
sourceSessionEffect: "transition",
|
|
7991
|
+
idempotencyScope: "session-command",
|
|
7992
|
+
sequenceRule: "match-current"
|
|
7993
|
+
}),
|
|
7994
|
+
fork: sessionCommandPolicy({
|
|
7995
|
+
capability: "threadForking",
|
|
7996
|
+
allowedStatuses: AgentSessionStatusSchema.options,
|
|
7997
|
+
requiresRunId: false,
|
|
7998
|
+
sourceSessionEffect: "preserve",
|
|
7999
|
+
idempotencyScope: "session-command",
|
|
8000
|
+
sequenceRule: "match-current"
|
|
8001
|
+
}),
|
|
8002
|
+
"edit-and-rerun": sessionCommandPolicy({
|
|
8003
|
+
capability: "editAndRerun",
|
|
8004
|
+
allowedStatuses: ["stopped", "completed", "failed"],
|
|
8005
|
+
requiresRunId: false,
|
|
8006
|
+
sourceSessionEffect: "preserve",
|
|
8007
|
+
idempotencyScope: "session-command",
|
|
8008
|
+
sequenceRule: "match-current"
|
|
8009
|
+
}),
|
|
8010
|
+
steer: sessionCommandPolicy({
|
|
8011
|
+
capability: "steering",
|
|
8012
|
+
allowedStatuses: ["queued", "running"],
|
|
8013
|
+
requiresRunId: true,
|
|
8014
|
+
sourceSessionEffect: "preserve",
|
|
8015
|
+
idempotencyScope: "session-command",
|
|
8016
|
+
sequenceRule: "match-current"
|
|
8017
|
+
})
|
|
7772
8018
|
});
|
|
8019
|
+
function isAgentSessionTerminalStatus(status) {
|
|
8020
|
+
return AgentSessionTerminalStatusSchema.safeParse(status).success;
|
|
8021
|
+
}
|
|
7773
8022
|
var AgentSessionEventHeaderSchema = z5.object({
|
|
7774
8023
|
contract: z5.literal("AgentSessionEvent"),
|
|
7775
8024
|
eventId: ContractIdentifierSchema,
|
|
7776
8025
|
sessionId: ContractIdentifierSchema,
|
|
8026
|
+
runId: ContractIdentifierSchema.optional(),
|
|
8027
|
+
sourceMessageId: ContractIdentifierSchema.optional(),
|
|
7777
8028
|
sequence: z5.number().int().nonnegative(),
|
|
7778
8029
|
idempotencyKey: ContractIdentifierSchema,
|
|
7779
8030
|
occurredAt: IsoDateTimeSchema
|
|
@@ -7833,7 +8084,13 @@ var AgentSessionEventSchema = z5.discriminatedUnion("eventType", [
|
|
|
7833
8084
|
}),
|
|
7834
8085
|
sessionEvent("status", {
|
|
7835
8086
|
status: AgentSessionStatusSchema,
|
|
7836
|
-
detail: z5.string().optional()
|
|
8087
|
+
detail: z5.string().optional(),
|
|
8088
|
+
startedAt: IsoDateTimeSchema.optional(),
|
|
8089
|
+
stoppingRequestedAt: IsoDateTimeSchema.optional(),
|
|
8090
|
+
stoppedAt: IsoDateTimeSchema.optional(),
|
|
8091
|
+
completedAt: IsoDateTimeSchema.optional(),
|
|
8092
|
+
failedAt: IsoDateTimeSchema.optional(),
|
|
8093
|
+
durationMs: z5.number().nonnegative().optional()
|
|
7837
8094
|
}),
|
|
7838
8095
|
sessionEvent("artifact", {
|
|
7839
8096
|
artifactId: ContractIdentifierSchema,
|
|
@@ -7887,8 +8144,52 @@ var AgentSessionEventSchema = z5.discriminatedUnion("eventType", [
|
|
|
7887
8144
|
status: z5.enum(["running", "passed", "failed", "skipped"]),
|
|
7888
8145
|
durationMs: z5.number().nonnegative().optional(),
|
|
7889
8146
|
output: z5.string().optional()
|
|
8147
|
+
}),
|
|
8148
|
+
sessionEvent("summary", {
|
|
8149
|
+
summaryId: ContractIdentifierSchema,
|
|
8150
|
+
runId: ContractIdentifierSchema,
|
|
8151
|
+
text: z5.string(),
|
|
8152
|
+
highlights: z5.array(z5.string()),
|
|
8153
|
+
pendingItems: z5.array(z5.string()),
|
|
8154
|
+
status: z5.enum(["generating", "completed", "failed"])
|
|
7890
8155
|
})
|
|
7891
|
-
])
|
|
8156
|
+
]).superRefine((value, context) => {
|
|
8157
|
+
if (value.eventType === "summary" && value.runId !== value.payload.runId) {
|
|
8158
|
+
context.addIssue({
|
|
8159
|
+
code: "custom",
|
|
8160
|
+
path: ["payload", "runId"],
|
|
8161
|
+
message: "Summary payload runId must match the event runId."
|
|
8162
|
+
});
|
|
8163
|
+
}
|
|
8164
|
+
});
|
|
8165
|
+
var AgentSessionRunEventSchema = AgentSessionEventSchema.superRefine((value, context) => {
|
|
8166
|
+
if (!value.runId) {
|
|
8167
|
+
context.addIssue({ code: "custom", path: ["runId"], message: "Run events require runId." });
|
|
8168
|
+
}
|
|
8169
|
+
if (!value.sourceMessageId) {
|
|
8170
|
+
context.addIssue({
|
|
8171
|
+
code: "custom",
|
|
8172
|
+
path: ["sourceMessageId"],
|
|
8173
|
+
message: "Run events require sourceMessageId."
|
|
8174
|
+
});
|
|
8175
|
+
}
|
|
8176
|
+
if (value.eventType !== "status") return;
|
|
8177
|
+
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;
|
|
8178
|
+
if (requiredTimeField && !value.payload[requiredTimeField]) {
|
|
8179
|
+
context.addIssue({
|
|
8180
|
+
code: "custom",
|
|
8181
|
+
path: ["payload", requiredTimeField],
|
|
8182
|
+
message: `Run status ${value.payload.status} requires ${requiredTimeField}.`
|
|
8183
|
+
});
|
|
8184
|
+
}
|
|
8185
|
+
if (isAgentSessionTerminalStatus(value.payload.status) && value.payload.durationMs === void 0) {
|
|
8186
|
+
context.addIssue({
|
|
8187
|
+
code: "custom",
|
|
8188
|
+
path: ["payload", "durationMs"],
|
|
8189
|
+
message: `Terminal run status ${value.payload.status} requires durationMs.`
|
|
8190
|
+
});
|
|
8191
|
+
}
|
|
8192
|
+
});
|
|
7892
8193
|
var AgentSessionViewModelSchema = z5.object({
|
|
7893
8194
|
contract: z5.literal("AgentSessionViewModel"),
|
|
7894
8195
|
sessionId: ContractIdentifierSchema,
|
|
@@ -7896,7 +8197,9 @@ var AgentSessionViewModelSchema = z5.object({
|
|
|
7896
8197
|
status: AgentSessionStatusSchema,
|
|
7897
8198
|
events: z5.array(AgentSessionEventSchema),
|
|
7898
8199
|
lastSequence: z5.number().int().min(-1),
|
|
7899
|
-
resumable: z5.boolean().default(false)
|
|
8200
|
+
resumable: z5.boolean().default(false),
|
|
8201
|
+
lineage: AgentSessionLineageSchema.optional(),
|
|
8202
|
+
activeBranch: AgentSessionActiveBranchSchema.optional()
|
|
7900
8203
|
}).strict().superRefine((value, context) => {
|
|
7901
8204
|
const eventIds = /* @__PURE__ */ new Set();
|
|
7902
8205
|
const idempotencyKeys = /* @__PURE__ */ new Set();
|