@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
|
@@ -6712,7 +6712,11 @@ var AgentSessionCapabilitySchema = z3.enum([
|
|
|
6712
6712
|
"diff",
|
|
6713
6713
|
"workspaceFiles",
|
|
6714
6714
|
"terminal",
|
|
6715
|
-
"testResults"
|
|
6715
|
+
"testResults",
|
|
6716
|
+
"threadForking",
|
|
6717
|
+
"editAndRerun",
|
|
6718
|
+
"steering",
|
|
6719
|
+
"summary"
|
|
6716
6720
|
]);
|
|
6717
6721
|
var AgentSessionCapabilitiesSchema = z3.object({
|
|
6718
6722
|
text: z3.boolean().default(true),
|
|
@@ -6731,7 +6735,11 @@ var AgentSessionCapabilitiesSchema = z3.object({
|
|
|
6731
6735
|
diff: z3.boolean().default(false),
|
|
6732
6736
|
workspaceFiles: z3.boolean().default(false),
|
|
6733
6737
|
terminal: z3.boolean().default(false),
|
|
6734
|
-
testResults: z3.boolean().default(false)
|
|
6738
|
+
testResults: z3.boolean().default(false),
|
|
6739
|
+
threadForking: z3.boolean().default(false),
|
|
6740
|
+
editAndRerun: z3.boolean().default(false),
|
|
6741
|
+
steering: z3.boolean().default(false),
|
|
6742
|
+
summary: z3.boolean().default(false)
|
|
6735
6743
|
}).strict();
|
|
6736
6744
|
var AGENT_SESSION_RUNTIME_CAPABILITIES = Object.freeze({
|
|
6737
6745
|
chatbot: AgentSessionCapabilitiesSchema.parse({ text: true, tools: true, mcp: true, skills: true, approval: true, usage: true }),
|
|
@@ -6757,7 +6765,11 @@ var AGENT_SESSION_CAPABILITY_EVIDENCE = Object.freeze({
|
|
|
6757
6765
|
diff: { eventTypes: ["diff"], commandTypes: [] },
|
|
6758
6766
|
workspaceFiles: { eventTypes: ["workspace-file"], commandTypes: [] },
|
|
6759
6767
|
terminal: { eventTypes: ["terminal"], commandTypes: [] },
|
|
6760
|
-
testResults: { eventTypes: ["test-result"], commandTypes: [] }
|
|
6768
|
+
testResults: { eventTypes: ["test-result"], commandTypes: [] },
|
|
6769
|
+
threadForking: { eventTypes: [], commandTypes: ["fork"] },
|
|
6770
|
+
editAndRerun: { eventTypes: [], commandTypes: ["edit-and-rerun"] },
|
|
6771
|
+
steering: { eventTypes: [], commandTypes: ["steer"] },
|
|
6772
|
+
summary: { eventTypes: ["summary"], commandTypes: [] }
|
|
6761
6773
|
});
|
|
6762
6774
|
function findUnsupportedAgentSessionCapabilities(capabilities, evidence) {
|
|
6763
6775
|
const eventTypes = new Set(evidence.eventTypes || []);
|
|
@@ -6782,11 +6794,98 @@ var AgentSessionStatusSchema = z3.enum([
|
|
|
6782
6794
|
"completed",
|
|
6783
6795
|
"failed"
|
|
6784
6796
|
]);
|
|
6785
|
-
var
|
|
6797
|
+
var AgentSessionTerminalStatusSchema = z3.enum(["stopped", "completed", "failed"]);
|
|
6798
|
+
var AgentSessionLineageSchema = z3.object({
|
|
6799
|
+
forkedFromThreadId: ContractIdentifierSchema,
|
|
6800
|
+
forkedFromMessageId: ContractIdentifierSchema,
|
|
6801
|
+
sourceRunId: ContractIdentifierSchema
|
|
6802
|
+
}).strict();
|
|
6803
|
+
var AgentSessionContextInheritanceSchema = z3.object({
|
|
6804
|
+
messages: z3.enum(["through-source-message", "exclude"]),
|
|
6805
|
+
attachments: z3.enum(["inherit", "exclude"]),
|
|
6806
|
+
summaries: z3.enum(["inherit", "exclude"]),
|
|
6807
|
+
toolResults: z3.enum(["inherit", "exclude"]),
|
|
6808
|
+
codeChanges: z3.enum(["inherit", "exclude"])
|
|
6809
|
+
}).strict();
|
|
6810
|
+
var AgentSessionActiveBranchSchema = z3.object({
|
|
6811
|
+
branchId: ContractIdentifierSchema,
|
|
6812
|
+
threadId: ContractIdentifierSchema,
|
|
6813
|
+
sourceMessageId: ContractIdentifierSchema,
|
|
6814
|
+
runId: ContractIdentifierSchema,
|
|
6815
|
+
lineage: AgentSessionLineageSchema.optional(),
|
|
6816
|
+
createdAt: IsoDateTimeSchema
|
|
6817
|
+
}).strict();
|
|
6818
|
+
var AgentSessionRunSchema = z3.object({
|
|
6819
|
+
runId: ContractIdentifierSchema,
|
|
6820
|
+
sessionId: ContractIdentifierSchema,
|
|
6821
|
+
sourceMessageId: ContractIdentifierSchema,
|
|
6822
|
+
status: AgentSessionStatusSchema,
|
|
6823
|
+
startedAt: IsoDateTimeSchema,
|
|
6824
|
+
stoppingRequestedAt: IsoDateTimeSchema.optional(),
|
|
6825
|
+
stoppedAt: IsoDateTimeSchema.optional(),
|
|
6826
|
+
completedAt: IsoDateTimeSchema.optional(),
|
|
6827
|
+
failedAt: IsoDateTimeSchema.optional(),
|
|
6828
|
+
durationMs: z3.number().nonnegative().optional()
|
|
6829
|
+
}).strict().superRefine((value, context) => {
|
|
6830
|
+
const terminalTimestamps = [value.stoppedAt, value.completedAt, value.failedAt].filter(Boolean);
|
|
6831
|
+
if (terminalTimestamps.length > 1) {
|
|
6832
|
+
context.addIssue({
|
|
6833
|
+
code: "custom",
|
|
6834
|
+
path: ["status"],
|
|
6835
|
+
message: "A run may declare only one terminal timestamp."
|
|
6836
|
+
});
|
|
6837
|
+
}
|
|
6838
|
+
const expectedTimestamp = value.status === "stopped" ? value.stoppedAt : value.status === "completed" ? value.completedAt : value.status === "failed" ? value.failedAt : void 0;
|
|
6839
|
+
if (AgentSessionTerminalStatusSchema.safeParse(value.status).success && !expectedTimestamp) {
|
|
6840
|
+
context.addIssue({
|
|
6841
|
+
code: "custom",
|
|
6842
|
+
path: [value.status === "stopped" ? "stoppedAt" : value.status === "completed" ? "completedAt" : "failedAt"],
|
|
6843
|
+
message: `Run status ${value.status} requires its matching terminal timestamp.`
|
|
6844
|
+
});
|
|
6845
|
+
}
|
|
6846
|
+
if (!AgentSessionTerminalStatusSchema.safeParse(value.status).success && terminalTimestamps.length > 0) {
|
|
6847
|
+
context.addIssue({
|
|
6848
|
+
code: "custom",
|
|
6849
|
+
path: ["status"],
|
|
6850
|
+
message: "A non-terminal run must not declare a terminal timestamp."
|
|
6851
|
+
});
|
|
6852
|
+
}
|
|
6853
|
+
if ((value.status === "stopping" || value.status === "stopped") && !value.stoppingRequestedAt) {
|
|
6854
|
+
context.addIssue({
|
|
6855
|
+
code: "custom",
|
|
6856
|
+
path: ["stoppingRequestedAt"],
|
|
6857
|
+
message: `Run status ${value.status} requires stoppingRequestedAt.`
|
|
6858
|
+
});
|
|
6859
|
+
}
|
|
6860
|
+
if (!isAgentSessionTerminalStatus(value.status) && value.durationMs !== void 0) {
|
|
6861
|
+
context.addIssue({
|
|
6862
|
+
code: "custom",
|
|
6863
|
+
path: ["durationMs"],
|
|
6864
|
+
message: "Only a terminal run may declare durationMs."
|
|
6865
|
+
});
|
|
6866
|
+
}
|
|
6867
|
+
if (isAgentSessionTerminalStatus(value.status) && value.durationMs === void 0) {
|
|
6868
|
+
context.addIssue({
|
|
6869
|
+
code: "custom",
|
|
6870
|
+
path: ["durationMs"],
|
|
6871
|
+
message: `Terminal run status ${value.status} requires durationMs.`
|
|
6872
|
+
});
|
|
6873
|
+
}
|
|
6874
|
+
});
|
|
6875
|
+
var AgentSessionCommandTypeSchema = z3.enum([
|
|
6876
|
+
"stop",
|
|
6877
|
+
"resume",
|
|
6878
|
+
"retry",
|
|
6879
|
+
"approval",
|
|
6880
|
+
"fork",
|
|
6881
|
+
"edit-and-rerun",
|
|
6882
|
+
"steer"
|
|
6883
|
+
]);
|
|
6786
6884
|
var AgentSessionCommandHeaderSchema = z3.object({
|
|
6787
6885
|
contract: z3.literal("AgentSessionCommand"),
|
|
6788
6886
|
commandId: ContractIdentifierSchema,
|
|
6789
6887
|
sessionId: ContractIdentifierSchema,
|
|
6888
|
+
runId: ContractIdentifierSchema.optional(),
|
|
6790
6889
|
idempotencyKey: ContractIdentifierSchema,
|
|
6791
6890
|
expectedSequence: z3.number().int().min(-1),
|
|
6792
6891
|
issuedAt: IsoDateTimeSchema
|
|
@@ -6809,10 +6908,41 @@ var AgentSessionCommandSchema = z3.discriminatedUnion("commandType", [
|
|
|
6809
6908
|
approvalId: ContractIdentifierSchema,
|
|
6810
6909
|
decision: z3.enum(["approved", "rejected"]),
|
|
6811
6910
|
reason: z3.string().trim().min(1).optional()
|
|
6911
|
+
}),
|
|
6912
|
+
sessionCommand("fork", {
|
|
6913
|
+
sourceThreadId: ContractIdentifierSchema,
|
|
6914
|
+
sourceMessageId: ContractIdentifierSchema,
|
|
6915
|
+
sourceRunId: ContractIdentifierSchema,
|
|
6916
|
+
inheritance: AgentSessionContextInheritanceSchema
|
|
6917
|
+
}),
|
|
6918
|
+
sessionCommand("edit-and-rerun", {
|
|
6919
|
+
sourceThreadId: ContractIdentifierSchema,
|
|
6920
|
+
sourceMessageId: ContractIdentifierSchema,
|
|
6921
|
+
sourceRunId: ContractIdentifierSchema,
|
|
6922
|
+
replacementParts: z3.array(JsonValueSchema).min(1),
|
|
6923
|
+
inheritance: AgentSessionContextInheritanceSchema
|
|
6924
|
+
}),
|
|
6925
|
+
sessionCommand("steer", {
|
|
6926
|
+
targetRunId: ContractIdentifierSchema,
|
|
6927
|
+
guidanceParts: z3.array(JsonValueSchema).min(1)
|
|
6812
6928
|
})
|
|
6813
|
-
])
|
|
6929
|
+
]).superRefine((value, context) => {
|
|
6930
|
+
if (value.commandType === "steer" && value.runId !== value.payload.targetRunId) {
|
|
6931
|
+
context.addIssue({
|
|
6932
|
+
code: "custom",
|
|
6933
|
+
path: ["payload", "targetRunId"],
|
|
6934
|
+
message: "Steering targetRunId must match the command runId."
|
|
6935
|
+
});
|
|
6936
|
+
}
|
|
6937
|
+
});
|
|
6938
|
+
var AgentSessionTargetedCommandSchema = AgentSessionCommandSchema.and(
|
|
6939
|
+
z3.object({ runId: ContractIdentifierSchema })
|
|
6940
|
+
);
|
|
6814
6941
|
var AgentSessionCommandErrorCodeSchema = z3.enum([
|
|
6815
6942
|
"SESSION_NOT_FOUND",
|
|
6943
|
+
"RUN_NOT_FOUND",
|
|
6944
|
+
"RUN_ALREADY_FINISHED",
|
|
6945
|
+
"STOP_TIMEOUT",
|
|
6816
6946
|
"COMMAND_NOT_SUPPORTED",
|
|
6817
6947
|
"CAPABILITY_UNAVAILABLE",
|
|
6818
6948
|
"SEQUENCE_CONFLICT",
|
|
@@ -6821,17 +6951,28 @@ var AgentSessionCommandErrorCodeSchema = z3.enum([
|
|
|
6821
6951
|
"TARGET_EVENT_NOT_RETRYABLE",
|
|
6822
6952
|
"APPROVAL_NOT_FOUND",
|
|
6823
6953
|
"APPROVAL_ALREADY_RESOLVED",
|
|
6954
|
+
"SOURCE_THREAD_NOT_FOUND",
|
|
6955
|
+
"SOURCE_MESSAGE_NOT_FOUND",
|
|
6956
|
+
"SOURCE_RUN_NOT_FOUND",
|
|
6957
|
+
"SOURCE_LINEAGE_INVALID",
|
|
6958
|
+
"ACTIVE_BRANCH_NOT_FOUND",
|
|
6824
6959
|
"COMMAND_EXECUTION_FAILED"
|
|
6825
6960
|
]);
|
|
6826
6961
|
var AgentSessionCommandResultSchema = z3.object({
|
|
6827
6962
|
contract: z3.literal("AgentSessionCommandResult"),
|
|
6828
6963
|
commandId: ContractIdentifierSchema,
|
|
6829
6964
|
sessionId: ContractIdentifierSchema,
|
|
6965
|
+
runId: ContractIdentifierSchema.optional(),
|
|
6830
6966
|
idempotencyKey: ContractIdentifierSchema,
|
|
6831
6967
|
outcome: z3.enum(["accepted", "duplicate", "rejected", "failed"]),
|
|
6832
6968
|
sessionStatus: AgentSessionStatusSchema,
|
|
6833
6969
|
acceptedSequence: z3.number().int().nonnegative().optional(),
|
|
6834
6970
|
resultEventIds: z3.array(ContractIdentifierSchema).default([]),
|
|
6971
|
+
operation: z3.object({
|
|
6972
|
+
lineage: AgentSessionLineageSchema,
|
|
6973
|
+
activeBranch: AgentSessionActiveBranchSchema
|
|
6974
|
+
}).strict().optional(),
|
|
6975
|
+
termination: z3.enum(["requested", "confirmed"]).optional(),
|
|
6835
6976
|
error: z3.object({
|
|
6836
6977
|
code: AgentSessionCommandErrorCodeSchema,
|
|
6837
6978
|
message: z3.string(),
|
|
@@ -6847,20 +6988,152 @@ var AgentSessionCommandResultSchema = z3.object({
|
|
|
6847
6988
|
message: requiresError ? "Rejected and failed command results require an error." : "Accepted and duplicate command results must not contain an error."
|
|
6848
6989
|
});
|
|
6849
6990
|
}
|
|
6991
|
+
if (value.termination === "requested" && value.sessionStatus !== "stopping") {
|
|
6992
|
+
context.addIssue({
|
|
6993
|
+
code: "custom",
|
|
6994
|
+
path: ["termination"],
|
|
6995
|
+
message: "A requested termination must leave the run in stopping status."
|
|
6996
|
+
});
|
|
6997
|
+
}
|
|
6998
|
+
if (value.termination === "confirmed" && !isAgentSessionTerminalStatus(value.sessionStatus)) {
|
|
6999
|
+
context.addIssue({
|
|
7000
|
+
code: "custom",
|
|
7001
|
+
path: ["termination"],
|
|
7002
|
+
message: "A confirmed termination requires a terminal run status."
|
|
7003
|
+
});
|
|
7004
|
+
}
|
|
7005
|
+
if (value.operation && !value.operation.activeBranch.lineage) {
|
|
7006
|
+
context.addIssue({
|
|
7007
|
+
code: "custom",
|
|
7008
|
+
path: ["operation", "activeBranch", "lineage"],
|
|
7009
|
+
message: "A branch operation result requires lineage on its active branch."
|
|
7010
|
+
});
|
|
7011
|
+
}
|
|
7012
|
+
const operation = value.operation;
|
|
7013
|
+
if (operation?.activeBranch.lineage) {
|
|
7014
|
+
const { lineage } = operation;
|
|
7015
|
+
const branchLineage = operation.activeBranch.lineage;
|
|
7016
|
+
if (lineage.forkedFromThreadId !== branchLineage.forkedFromThreadId || lineage.forkedFromMessageId !== branchLineage.forkedFromMessageId || lineage.sourceRunId !== branchLineage.sourceRunId) {
|
|
7017
|
+
context.addIssue({
|
|
7018
|
+
code: "custom",
|
|
7019
|
+
path: ["operation", "activeBranch", "lineage"],
|
|
7020
|
+
message: "Active branch lineage must match the operation lineage."
|
|
7021
|
+
});
|
|
7022
|
+
}
|
|
7023
|
+
}
|
|
7024
|
+
if (value.operation && value.runId !== value.operation.activeBranch.runId) {
|
|
7025
|
+
context.addIssue({
|
|
7026
|
+
code: "custom",
|
|
7027
|
+
path: ["operation", "activeBranch", "runId"],
|
|
7028
|
+
message: "Active branch runId must match the command result runId."
|
|
7029
|
+
});
|
|
7030
|
+
}
|
|
6850
7031
|
});
|
|
6851
7032
|
var AGENT_SESSION_COMMAND_TRANSITIONS = {
|
|
6852
7033
|
stop: { queued: "stopping", running: "stopping", waiting_approval: "stopping" },
|
|
6853
7034
|
resume: { stopped: "queued", completed: "queued", failed: "queued" },
|
|
6854
7035
|
retry: { failed: "queued" },
|
|
6855
|
-
approval: { waiting_approval: "running" }
|
|
7036
|
+
approval: { waiting_approval: "running" },
|
|
7037
|
+
fork: {},
|
|
7038
|
+
"edit-and-rerun": {},
|
|
7039
|
+
steer: {}
|
|
6856
7040
|
};
|
|
7041
|
+
var AgentSessionCommandPolicySchema = z3.object({
|
|
7042
|
+
capability: AgentSessionCapabilitySchema.optional(),
|
|
7043
|
+
allowedStatuses: z3.array(AgentSessionStatusSchema).min(1),
|
|
7044
|
+
requiresRunId: z3.boolean(),
|
|
7045
|
+
sourceSessionEffect: z3.enum(["transition", "preserve"]),
|
|
7046
|
+
idempotencyScope: z3.literal("session-command"),
|
|
7047
|
+
sequenceRule: z3.literal("match-current")
|
|
7048
|
+
}).strict();
|
|
7049
|
+
var sessionCommandPolicy = (policy) => AgentSessionCommandPolicySchema.parse(policy);
|
|
7050
|
+
var AGENT_SESSION_COMMAND_POLICIES = Object.freeze({
|
|
7051
|
+
stop: sessionCommandPolicy({
|
|
7052
|
+
allowedStatuses: ["queued", "running", "waiting_approval"],
|
|
7053
|
+
requiresRunId: true,
|
|
7054
|
+
sourceSessionEffect: "transition",
|
|
7055
|
+
idempotencyScope: "session-command",
|
|
7056
|
+
sequenceRule: "match-current"
|
|
7057
|
+
}),
|
|
7058
|
+
resume: sessionCommandPolicy({
|
|
7059
|
+
capability: "resume",
|
|
7060
|
+
allowedStatuses: ["stopped", "completed", "failed"],
|
|
7061
|
+
requiresRunId: true,
|
|
7062
|
+
sourceSessionEffect: "transition",
|
|
7063
|
+
idempotencyScope: "session-command",
|
|
7064
|
+
sequenceRule: "match-current"
|
|
7065
|
+
}),
|
|
7066
|
+
retry: sessionCommandPolicy({
|
|
7067
|
+
allowedStatuses: ["failed"],
|
|
7068
|
+
requiresRunId: true,
|
|
7069
|
+
sourceSessionEffect: "transition",
|
|
7070
|
+
idempotencyScope: "session-command",
|
|
7071
|
+
sequenceRule: "match-current"
|
|
7072
|
+
}),
|
|
7073
|
+
approval: sessionCommandPolicy({
|
|
7074
|
+
capability: "approval",
|
|
7075
|
+
allowedStatuses: ["waiting_approval"],
|
|
7076
|
+
requiresRunId: true,
|
|
7077
|
+
sourceSessionEffect: "transition",
|
|
7078
|
+
idempotencyScope: "session-command",
|
|
7079
|
+
sequenceRule: "match-current"
|
|
7080
|
+
}),
|
|
7081
|
+
fork: sessionCommandPolicy({
|
|
7082
|
+
capability: "threadForking",
|
|
7083
|
+
allowedStatuses: AgentSessionStatusSchema.options,
|
|
7084
|
+
requiresRunId: false,
|
|
7085
|
+
sourceSessionEffect: "preserve",
|
|
7086
|
+
idempotencyScope: "session-command",
|
|
7087
|
+
sequenceRule: "match-current"
|
|
7088
|
+
}),
|
|
7089
|
+
"edit-and-rerun": sessionCommandPolicy({
|
|
7090
|
+
capability: "editAndRerun",
|
|
7091
|
+
allowedStatuses: ["stopped", "completed", "failed"],
|
|
7092
|
+
requiresRunId: false,
|
|
7093
|
+
sourceSessionEffect: "preserve",
|
|
7094
|
+
idempotencyScope: "session-command",
|
|
7095
|
+
sequenceRule: "match-current"
|
|
7096
|
+
}),
|
|
7097
|
+
steer: sessionCommandPolicy({
|
|
7098
|
+
capability: "steering",
|
|
7099
|
+
allowedStatuses: ["queued", "running"],
|
|
7100
|
+
requiresRunId: true,
|
|
7101
|
+
sourceSessionEffect: "preserve",
|
|
7102
|
+
idempotencyScope: "session-command",
|
|
7103
|
+
sequenceRule: "match-current"
|
|
7104
|
+
})
|
|
7105
|
+
});
|
|
7106
|
+
function getAgentSessionCommandPolicy(commandType) {
|
|
7107
|
+
return AGENT_SESSION_COMMAND_POLICIES[commandType];
|
|
7108
|
+
}
|
|
7109
|
+
function canIssueAgentSessionCommand(status, commandType) {
|
|
7110
|
+
return getAgentSessionCommandPolicy(commandType).allowedStatuses.includes(status);
|
|
7111
|
+
}
|
|
6857
7112
|
function resolveAgentSessionCommandTransition(status, commandType) {
|
|
6858
7113
|
return AGENT_SESSION_COMMAND_TRANSITIONS[commandType][status];
|
|
6859
7114
|
}
|
|
7115
|
+
function isAgentSessionTerminalStatus(status) {
|
|
7116
|
+
return AgentSessionTerminalStatusSchema.safeParse(status).success;
|
|
7117
|
+
}
|
|
7118
|
+
function canApplyAgentSessionRunStatus(current, next) {
|
|
7119
|
+
if (current === next) return true;
|
|
7120
|
+
const transitions = {
|
|
7121
|
+
queued: ["running", "stopping", "failed"],
|
|
7122
|
+
running: ["waiting_approval", "stopping", "completed", "failed"],
|
|
7123
|
+
waiting_approval: ["running", "stopping", "failed"],
|
|
7124
|
+
stopping: ["stopped", "completed", "failed"],
|
|
7125
|
+
stopped: [],
|
|
7126
|
+
completed: [],
|
|
7127
|
+
failed: []
|
|
7128
|
+
};
|
|
7129
|
+
return transitions[current].includes(next);
|
|
7130
|
+
}
|
|
6860
7131
|
var AgentSessionEventHeaderSchema = z3.object({
|
|
6861
7132
|
contract: z3.literal("AgentSessionEvent"),
|
|
6862
7133
|
eventId: ContractIdentifierSchema,
|
|
6863
7134
|
sessionId: ContractIdentifierSchema,
|
|
7135
|
+
runId: ContractIdentifierSchema.optional(),
|
|
7136
|
+
sourceMessageId: ContractIdentifierSchema.optional(),
|
|
6864
7137
|
sequence: z3.number().int().nonnegative(),
|
|
6865
7138
|
idempotencyKey: ContractIdentifierSchema,
|
|
6866
7139
|
occurredAt: IsoDateTimeSchema
|
|
@@ -6920,7 +7193,13 @@ var AgentSessionEventSchema = z3.discriminatedUnion("eventType", [
|
|
|
6920
7193
|
}),
|
|
6921
7194
|
sessionEvent("status", {
|
|
6922
7195
|
status: AgentSessionStatusSchema,
|
|
6923
|
-
detail: z3.string().optional()
|
|
7196
|
+
detail: z3.string().optional(),
|
|
7197
|
+
startedAt: IsoDateTimeSchema.optional(),
|
|
7198
|
+
stoppingRequestedAt: IsoDateTimeSchema.optional(),
|
|
7199
|
+
stoppedAt: IsoDateTimeSchema.optional(),
|
|
7200
|
+
completedAt: IsoDateTimeSchema.optional(),
|
|
7201
|
+
failedAt: IsoDateTimeSchema.optional(),
|
|
7202
|
+
durationMs: z3.number().nonnegative().optional()
|
|
6924
7203
|
}),
|
|
6925
7204
|
sessionEvent("artifact", {
|
|
6926
7205
|
artifactId: ContractIdentifierSchema,
|
|
@@ -6974,8 +7253,52 @@ var AgentSessionEventSchema = z3.discriminatedUnion("eventType", [
|
|
|
6974
7253
|
status: z3.enum(["running", "passed", "failed", "skipped"]),
|
|
6975
7254
|
durationMs: z3.number().nonnegative().optional(),
|
|
6976
7255
|
output: z3.string().optional()
|
|
7256
|
+
}),
|
|
7257
|
+
sessionEvent("summary", {
|
|
7258
|
+
summaryId: ContractIdentifierSchema,
|
|
7259
|
+
runId: ContractIdentifierSchema,
|
|
7260
|
+
text: z3.string(),
|
|
7261
|
+
highlights: z3.array(z3.string()),
|
|
7262
|
+
pendingItems: z3.array(z3.string()),
|
|
7263
|
+
status: z3.enum(["generating", "completed", "failed"])
|
|
6977
7264
|
})
|
|
6978
|
-
])
|
|
7265
|
+
]).superRefine((value, context) => {
|
|
7266
|
+
if (value.eventType === "summary" && value.runId !== value.payload.runId) {
|
|
7267
|
+
context.addIssue({
|
|
7268
|
+
code: "custom",
|
|
7269
|
+
path: ["payload", "runId"],
|
|
7270
|
+
message: "Summary payload runId must match the event runId."
|
|
7271
|
+
});
|
|
7272
|
+
}
|
|
7273
|
+
});
|
|
7274
|
+
var AgentSessionRunEventSchema = AgentSessionEventSchema.superRefine((value, context) => {
|
|
7275
|
+
if (!value.runId) {
|
|
7276
|
+
context.addIssue({ code: "custom", path: ["runId"], message: "Run events require runId." });
|
|
7277
|
+
}
|
|
7278
|
+
if (!value.sourceMessageId) {
|
|
7279
|
+
context.addIssue({
|
|
7280
|
+
code: "custom",
|
|
7281
|
+
path: ["sourceMessageId"],
|
|
7282
|
+
message: "Run events require sourceMessageId."
|
|
7283
|
+
});
|
|
7284
|
+
}
|
|
7285
|
+
if (value.eventType !== "status") return;
|
|
7286
|
+
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;
|
|
7287
|
+
if (requiredTimeField && !value.payload[requiredTimeField]) {
|
|
7288
|
+
context.addIssue({
|
|
7289
|
+
code: "custom",
|
|
7290
|
+
path: ["payload", requiredTimeField],
|
|
7291
|
+
message: `Run status ${value.payload.status} requires ${requiredTimeField}.`
|
|
7292
|
+
});
|
|
7293
|
+
}
|
|
7294
|
+
if (isAgentSessionTerminalStatus(value.payload.status) && value.payload.durationMs === void 0) {
|
|
7295
|
+
context.addIssue({
|
|
7296
|
+
code: "custom",
|
|
7297
|
+
path: ["payload", "durationMs"],
|
|
7298
|
+
message: `Terminal run status ${value.payload.status} requires durationMs.`
|
|
7299
|
+
});
|
|
7300
|
+
}
|
|
7301
|
+
});
|
|
6979
7302
|
var AgentSessionViewModelSchema = z3.object({
|
|
6980
7303
|
contract: z3.literal("AgentSessionViewModel"),
|
|
6981
7304
|
sessionId: ContractIdentifierSchema,
|
|
@@ -6983,7 +7306,9 @@ var AgentSessionViewModelSchema = z3.object({
|
|
|
6983
7306
|
status: AgentSessionStatusSchema,
|
|
6984
7307
|
events: z3.array(AgentSessionEventSchema),
|
|
6985
7308
|
lastSequence: z3.number().int().min(-1),
|
|
6986
|
-
resumable: z3.boolean().default(false)
|
|
7309
|
+
resumable: z3.boolean().default(false),
|
|
7310
|
+
lineage: AgentSessionLineageSchema.optional(),
|
|
7311
|
+
activeBranch: AgentSessionActiveBranchSchema.optional()
|
|
6987
7312
|
}).strict().superRefine((value, context) => {
|
|
6988
7313
|
const eventIds = /* @__PURE__ */ new Set();
|
|
6989
7314
|
const idempotencyKeys = /* @__PURE__ */ new Set();
|
|
@@ -11661,6 +11986,7 @@ var WorkflowCompletionReceiptSchema = z15.object({
|
|
|
11661
11986
|
export {
|
|
11662
11987
|
AGENT_MODE_CAPABILITIES,
|
|
11663
11988
|
AGENT_SESSION_CAPABILITY_EVIDENCE,
|
|
11989
|
+
AGENT_SESSION_COMMAND_POLICIES,
|
|
11664
11990
|
AGENT_SESSION_RUNTIME_CAPABILITIES,
|
|
11665
11991
|
ActorRefSchema,
|
|
11666
11992
|
AgentConfigurationCapabilitySchema,
|
|
@@ -11669,15 +11995,23 @@ export {
|
|
|
11669
11995
|
AgentModeSchema,
|
|
11670
11996
|
AgentResourceModeSupportSchema,
|
|
11671
11997
|
AgentRuntimeEventSchema,
|
|
11998
|
+
AgentSessionActiveBranchSchema,
|
|
11672
11999
|
AgentSessionCapabilitiesSchema,
|
|
11673
12000
|
AgentSessionCapabilitySchema,
|
|
11674
12001
|
AgentSessionCommandErrorCodeSchema,
|
|
12002
|
+
AgentSessionCommandPolicySchema,
|
|
11675
12003
|
AgentSessionCommandResultSchema,
|
|
11676
12004
|
AgentSessionCommandSchema,
|
|
11677
12005
|
AgentSessionCommandTypeSchema,
|
|
12006
|
+
AgentSessionContextInheritanceSchema,
|
|
11678
12007
|
AgentSessionEventSchema,
|
|
12008
|
+
AgentSessionLineageSchema,
|
|
12009
|
+
AgentSessionRunEventSchema,
|
|
12010
|
+
AgentSessionRunSchema,
|
|
11679
12011
|
AgentSessionSnapshotSchema,
|
|
11680
12012
|
AgentSessionStatusSchema,
|
|
12013
|
+
AgentSessionTargetedCommandSchema,
|
|
12014
|
+
AgentSessionTerminalStatusSchema,
|
|
11681
12015
|
AgentSessionViewModelSchema,
|
|
11682
12016
|
ApplicationHandoffEndpointSchema,
|
|
11683
12017
|
ApplicationHandoffSchema,
|
|
@@ -11809,10 +12143,14 @@ export {
|
|
|
11809
12143
|
WorkflowTriggerSchema,
|
|
11810
12144
|
WorkflowValidationIssueSchema,
|
|
11811
12145
|
agentModeHasCapability,
|
|
12146
|
+
canApplyAgentSessionRunStatus,
|
|
12147
|
+
canIssueAgentSessionCommand,
|
|
11812
12148
|
findUnsupportedAgentSessionCapabilities,
|
|
11813
12149
|
getAgentModeCapabilities,
|
|
12150
|
+
getAgentSessionCommandPolicy,
|
|
11814
12151
|
getAgentSessionRuntimeCapabilities,
|
|
11815
12152
|
isAgentResourceModeCompatible,
|
|
12153
|
+
isAgentSessionTerminalStatus,
|
|
11816
12154
|
normalizeAgentExecutionMode,
|
|
11817
12155
|
normalizeAgentMode,
|
|
11818
12156
|
resolveAgentSessionCommandTransition
|