@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
package/lib/esm/index.mjs
CHANGED
|
@@ -6749,7 +6749,11 @@ var AgentSessionCapabilitySchema = z3.enum([
|
|
|
6749
6749
|
"diff",
|
|
6750
6750
|
"workspaceFiles",
|
|
6751
6751
|
"terminal",
|
|
6752
|
-
"testResults"
|
|
6752
|
+
"testResults",
|
|
6753
|
+
"threadForking",
|
|
6754
|
+
"editAndRerun",
|
|
6755
|
+
"steering",
|
|
6756
|
+
"summary"
|
|
6753
6757
|
]);
|
|
6754
6758
|
var AgentSessionCapabilitiesSchema = z3.object({
|
|
6755
6759
|
text: z3.boolean().default(true),
|
|
@@ -6768,7 +6772,11 @@ var AgentSessionCapabilitiesSchema = z3.object({
|
|
|
6768
6772
|
diff: z3.boolean().default(false),
|
|
6769
6773
|
workspaceFiles: z3.boolean().default(false),
|
|
6770
6774
|
terminal: z3.boolean().default(false),
|
|
6771
|
-
testResults: z3.boolean().default(false)
|
|
6775
|
+
testResults: z3.boolean().default(false),
|
|
6776
|
+
threadForking: z3.boolean().default(false),
|
|
6777
|
+
editAndRerun: z3.boolean().default(false),
|
|
6778
|
+
steering: z3.boolean().default(false),
|
|
6779
|
+
summary: z3.boolean().default(false)
|
|
6772
6780
|
}).strict();
|
|
6773
6781
|
var AGENT_SESSION_RUNTIME_CAPABILITIES = Object.freeze({
|
|
6774
6782
|
chatbot: AgentSessionCapabilitiesSchema.parse({ text: true, tools: true, mcp: true, skills: true, approval: true, usage: true }),
|
|
@@ -6794,7 +6802,11 @@ var AGENT_SESSION_CAPABILITY_EVIDENCE = Object.freeze({
|
|
|
6794
6802
|
diff: { eventTypes: ["diff"], commandTypes: [] },
|
|
6795
6803
|
workspaceFiles: { eventTypes: ["workspace-file"], commandTypes: [] },
|
|
6796
6804
|
terminal: { eventTypes: ["terminal"], commandTypes: [] },
|
|
6797
|
-
testResults: { eventTypes: ["test-result"], commandTypes: [] }
|
|
6805
|
+
testResults: { eventTypes: ["test-result"], commandTypes: [] },
|
|
6806
|
+
threadForking: { eventTypes: [], commandTypes: ["fork"] },
|
|
6807
|
+
editAndRerun: { eventTypes: [], commandTypes: ["edit-and-rerun"] },
|
|
6808
|
+
steering: { eventTypes: [], commandTypes: ["steer"] },
|
|
6809
|
+
summary: { eventTypes: ["summary"], commandTypes: [] }
|
|
6798
6810
|
});
|
|
6799
6811
|
function findUnsupportedAgentSessionCapabilities(capabilities, evidence) {
|
|
6800
6812
|
const eventTypes = new Set(evidence.eventTypes || []);
|
|
@@ -6819,11 +6831,98 @@ var AgentSessionStatusSchema = z3.enum([
|
|
|
6819
6831
|
"completed",
|
|
6820
6832
|
"failed"
|
|
6821
6833
|
]);
|
|
6822
|
-
var
|
|
6834
|
+
var AgentSessionTerminalStatusSchema = z3.enum(["stopped", "completed", "failed"]);
|
|
6835
|
+
var AgentSessionLineageSchema = z3.object({
|
|
6836
|
+
forkedFromThreadId: ContractIdentifierSchema,
|
|
6837
|
+
forkedFromMessageId: ContractIdentifierSchema,
|
|
6838
|
+
sourceRunId: ContractIdentifierSchema
|
|
6839
|
+
}).strict();
|
|
6840
|
+
var AgentSessionContextInheritanceSchema = z3.object({
|
|
6841
|
+
messages: z3.enum(["through-source-message", "exclude"]),
|
|
6842
|
+
attachments: z3.enum(["inherit", "exclude"]),
|
|
6843
|
+
summaries: z3.enum(["inherit", "exclude"]),
|
|
6844
|
+
toolResults: z3.enum(["inherit", "exclude"]),
|
|
6845
|
+
codeChanges: z3.enum(["inherit", "exclude"])
|
|
6846
|
+
}).strict();
|
|
6847
|
+
var AgentSessionActiveBranchSchema = z3.object({
|
|
6848
|
+
branchId: ContractIdentifierSchema,
|
|
6849
|
+
threadId: ContractIdentifierSchema,
|
|
6850
|
+
sourceMessageId: ContractIdentifierSchema,
|
|
6851
|
+
runId: ContractIdentifierSchema,
|
|
6852
|
+
lineage: AgentSessionLineageSchema.optional(),
|
|
6853
|
+
createdAt: IsoDateTimeSchema
|
|
6854
|
+
}).strict();
|
|
6855
|
+
var AgentSessionRunSchema = z3.object({
|
|
6856
|
+
runId: ContractIdentifierSchema,
|
|
6857
|
+
sessionId: ContractIdentifierSchema,
|
|
6858
|
+
sourceMessageId: ContractIdentifierSchema,
|
|
6859
|
+
status: AgentSessionStatusSchema,
|
|
6860
|
+
startedAt: IsoDateTimeSchema,
|
|
6861
|
+
stoppingRequestedAt: IsoDateTimeSchema.optional(),
|
|
6862
|
+
stoppedAt: IsoDateTimeSchema.optional(),
|
|
6863
|
+
completedAt: IsoDateTimeSchema.optional(),
|
|
6864
|
+
failedAt: IsoDateTimeSchema.optional(),
|
|
6865
|
+
durationMs: z3.number().nonnegative().optional()
|
|
6866
|
+
}).strict().superRefine((value, context) => {
|
|
6867
|
+
const terminalTimestamps = [value.stoppedAt, value.completedAt, value.failedAt].filter(Boolean);
|
|
6868
|
+
if (terminalTimestamps.length > 1) {
|
|
6869
|
+
context.addIssue({
|
|
6870
|
+
code: "custom",
|
|
6871
|
+
path: ["status"],
|
|
6872
|
+
message: "A run may declare only one terminal timestamp."
|
|
6873
|
+
});
|
|
6874
|
+
}
|
|
6875
|
+
const expectedTimestamp = value.status === "stopped" ? value.stoppedAt : value.status === "completed" ? value.completedAt : value.status === "failed" ? value.failedAt : void 0;
|
|
6876
|
+
if (AgentSessionTerminalStatusSchema.safeParse(value.status).success && !expectedTimestamp) {
|
|
6877
|
+
context.addIssue({
|
|
6878
|
+
code: "custom",
|
|
6879
|
+
path: [value.status === "stopped" ? "stoppedAt" : value.status === "completed" ? "completedAt" : "failedAt"],
|
|
6880
|
+
message: `Run status ${value.status} requires its matching terminal timestamp.`
|
|
6881
|
+
});
|
|
6882
|
+
}
|
|
6883
|
+
if (!AgentSessionTerminalStatusSchema.safeParse(value.status).success && terminalTimestamps.length > 0) {
|
|
6884
|
+
context.addIssue({
|
|
6885
|
+
code: "custom",
|
|
6886
|
+
path: ["status"],
|
|
6887
|
+
message: "A non-terminal run must not declare a terminal timestamp."
|
|
6888
|
+
});
|
|
6889
|
+
}
|
|
6890
|
+
if ((value.status === "stopping" || value.status === "stopped") && !value.stoppingRequestedAt) {
|
|
6891
|
+
context.addIssue({
|
|
6892
|
+
code: "custom",
|
|
6893
|
+
path: ["stoppingRequestedAt"],
|
|
6894
|
+
message: `Run status ${value.status} requires stoppingRequestedAt.`
|
|
6895
|
+
});
|
|
6896
|
+
}
|
|
6897
|
+
if (!isAgentSessionTerminalStatus(value.status) && value.durationMs !== void 0) {
|
|
6898
|
+
context.addIssue({
|
|
6899
|
+
code: "custom",
|
|
6900
|
+
path: ["durationMs"],
|
|
6901
|
+
message: "Only a terminal run may declare durationMs."
|
|
6902
|
+
});
|
|
6903
|
+
}
|
|
6904
|
+
if (isAgentSessionTerminalStatus(value.status) && value.durationMs === void 0) {
|
|
6905
|
+
context.addIssue({
|
|
6906
|
+
code: "custom",
|
|
6907
|
+
path: ["durationMs"],
|
|
6908
|
+
message: `Terminal run status ${value.status} requires durationMs.`
|
|
6909
|
+
});
|
|
6910
|
+
}
|
|
6911
|
+
});
|
|
6912
|
+
var AgentSessionCommandTypeSchema = z3.enum([
|
|
6913
|
+
"stop",
|
|
6914
|
+
"resume",
|
|
6915
|
+
"retry",
|
|
6916
|
+
"approval",
|
|
6917
|
+
"fork",
|
|
6918
|
+
"edit-and-rerun",
|
|
6919
|
+
"steer"
|
|
6920
|
+
]);
|
|
6823
6921
|
var AgentSessionCommandHeaderSchema = z3.object({
|
|
6824
6922
|
contract: z3.literal("AgentSessionCommand"),
|
|
6825
6923
|
commandId: ContractIdentifierSchema,
|
|
6826
6924
|
sessionId: ContractIdentifierSchema,
|
|
6925
|
+
runId: ContractIdentifierSchema.optional(),
|
|
6827
6926
|
idempotencyKey: ContractIdentifierSchema,
|
|
6828
6927
|
expectedSequence: z3.number().int().min(-1),
|
|
6829
6928
|
issuedAt: IsoDateTimeSchema
|
|
@@ -6846,10 +6945,41 @@ var AgentSessionCommandSchema = z3.discriminatedUnion("commandType", [
|
|
|
6846
6945
|
approvalId: ContractIdentifierSchema,
|
|
6847
6946
|
decision: z3.enum(["approved", "rejected"]),
|
|
6848
6947
|
reason: z3.string().trim().min(1).optional()
|
|
6948
|
+
}),
|
|
6949
|
+
sessionCommand("fork", {
|
|
6950
|
+
sourceThreadId: ContractIdentifierSchema,
|
|
6951
|
+
sourceMessageId: ContractIdentifierSchema,
|
|
6952
|
+
sourceRunId: ContractIdentifierSchema,
|
|
6953
|
+
inheritance: AgentSessionContextInheritanceSchema
|
|
6954
|
+
}),
|
|
6955
|
+
sessionCommand("edit-and-rerun", {
|
|
6956
|
+
sourceThreadId: ContractIdentifierSchema,
|
|
6957
|
+
sourceMessageId: ContractIdentifierSchema,
|
|
6958
|
+
sourceRunId: ContractIdentifierSchema,
|
|
6959
|
+
replacementParts: z3.array(JsonValueSchema).min(1),
|
|
6960
|
+
inheritance: AgentSessionContextInheritanceSchema
|
|
6961
|
+
}),
|
|
6962
|
+
sessionCommand("steer", {
|
|
6963
|
+
targetRunId: ContractIdentifierSchema,
|
|
6964
|
+
guidanceParts: z3.array(JsonValueSchema).min(1)
|
|
6849
6965
|
})
|
|
6850
|
-
])
|
|
6966
|
+
]).superRefine((value, context) => {
|
|
6967
|
+
if (value.commandType === "steer" && value.runId !== value.payload.targetRunId) {
|
|
6968
|
+
context.addIssue({
|
|
6969
|
+
code: "custom",
|
|
6970
|
+
path: ["payload", "targetRunId"],
|
|
6971
|
+
message: "Steering targetRunId must match the command runId."
|
|
6972
|
+
});
|
|
6973
|
+
}
|
|
6974
|
+
});
|
|
6975
|
+
var AgentSessionTargetedCommandSchema = AgentSessionCommandSchema.and(
|
|
6976
|
+
z3.object({ runId: ContractIdentifierSchema })
|
|
6977
|
+
);
|
|
6851
6978
|
var AgentSessionCommandErrorCodeSchema = z3.enum([
|
|
6852
6979
|
"SESSION_NOT_FOUND",
|
|
6980
|
+
"RUN_NOT_FOUND",
|
|
6981
|
+
"RUN_ALREADY_FINISHED",
|
|
6982
|
+
"STOP_TIMEOUT",
|
|
6853
6983
|
"COMMAND_NOT_SUPPORTED",
|
|
6854
6984
|
"CAPABILITY_UNAVAILABLE",
|
|
6855
6985
|
"SEQUENCE_CONFLICT",
|
|
@@ -6858,17 +6988,28 @@ var AgentSessionCommandErrorCodeSchema = z3.enum([
|
|
|
6858
6988
|
"TARGET_EVENT_NOT_RETRYABLE",
|
|
6859
6989
|
"APPROVAL_NOT_FOUND",
|
|
6860
6990
|
"APPROVAL_ALREADY_RESOLVED",
|
|
6991
|
+
"SOURCE_THREAD_NOT_FOUND",
|
|
6992
|
+
"SOURCE_MESSAGE_NOT_FOUND",
|
|
6993
|
+
"SOURCE_RUN_NOT_FOUND",
|
|
6994
|
+
"SOURCE_LINEAGE_INVALID",
|
|
6995
|
+
"ACTIVE_BRANCH_NOT_FOUND",
|
|
6861
6996
|
"COMMAND_EXECUTION_FAILED"
|
|
6862
6997
|
]);
|
|
6863
6998
|
var AgentSessionCommandResultSchema = z3.object({
|
|
6864
6999
|
contract: z3.literal("AgentSessionCommandResult"),
|
|
6865
7000
|
commandId: ContractIdentifierSchema,
|
|
6866
7001
|
sessionId: ContractIdentifierSchema,
|
|
7002
|
+
runId: ContractIdentifierSchema.optional(),
|
|
6867
7003
|
idempotencyKey: ContractIdentifierSchema,
|
|
6868
7004
|
outcome: z3.enum(["accepted", "duplicate", "rejected", "failed"]),
|
|
6869
7005
|
sessionStatus: AgentSessionStatusSchema,
|
|
6870
7006
|
acceptedSequence: z3.number().int().nonnegative().optional(),
|
|
6871
7007
|
resultEventIds: z3.array(ContractIdentifierSchema).default([]),
|
|
7008
|
+
operation: z3.object({
|
|
7009
|
+
lineage: AgentSessionLineageSchema,
|
|
7010
|
+
activeBranch: AgentSessionActiveBranchSchema
|
|
7011
|
+
}).strict().optional(),
|
|
7012
|
+
termination: z3.enum(["requested", "confirmed"]).optional(),
|
|
6872
7013
|
error: z3.object({
|
|
6873
7014
|
code: AgentSessionCommandErrorCodeSchema,
|
|
6874
7015
|
message: z3.string(),
|
|
@@ -6884,20 +7025,152 @@ var AgentSessionCommandResultSchema = z3.object({
|
|
|
6884
7025
|
message: requiresError ? "Rejected and failed command results require an error." : "Accepted and duplicate command results must not contain an error."
|
|
6885
7026
|
});
|
|
6886
7027
|
}
|
|
7028
|
+
if (value.termination === "requested" && value.sessionStatus !== "stopping") {
|
|
7029
|
+
context.addIssue({
|
|
7030
|
+
code: "custom",
|
|
7031
|
+
path: ["termination"],
|
|
7032
|
+
message: "A requested termination must leave the run in stopping status."
|
|
7033
|
+
});
|
|
7034
|
+
}
|
|
7035
|
+
if (value.termination === "confirmed" && !isAgentSessionTerminalStatus(value.sessionStatus)) {
|
|
7036
|
+
context.addIssue({
|
|
7037
|
+
code: "custom",
|
|
7038
|
+
path: ["termination"],
|
|
7039
|
+
message: "A confirmed termination requires a terminal run status."
|
|
7040
|
+
});
|
|
7041
|
+
}
|
|
7042
|
+
if (value.operation && !value.operation.activeBranch.lineage) {
|
|
7043
|
+
context.addIssue({
|
|
7044
|
+
code: "custom",
|
|
7045
|
+
path: ["operation", "activeBranch", "lineage"],
|
|
7046
|
+
message: "A branch operation result requires lineage on its active branch."
|
|
7047
|
+
});
|
|
7048
|
+
}
|
|
7049
|
+
const operation = value.operation;
|
|
7050
|
+
if (operation?.activeBranch.lineage) {
|
|
7051
|
+
const { lineage } = operation;
|
|
7052
|
+
const branchLineage = operation.activeBranch.lineage;
|
|
7053
|
+
if (lineage.forkedFromThreadId !== branchLineage.forkedFromThreadId || lineage.forkedFromMessageId !== branchLineage.forkedFromMessageId || lineage.sourceRunId !== branchLineage.sourceRunId) {
|
|
7054
|
+
context.addIssue({
|
|
7055
|
+
code: "custom",
|
|
7056
|
+
path: ["operation", "activeBranch", "lineage"],
|
|
7057
|
+
message: "Active branch lineage must match the operation lineage."
|
|
7058
|
+
});
|
|
7059
|
+
}
|
|
7060
|
+
}
|
|
7061
|
+
if (value.operation && value.runId !== value.operation.activeBranch.runId) {
|
|
7062
|
+
context.addIssue({
|
|
7063
|
+
code: "custom",
|
|
7064
|
+
path: ["operation", "activeBranch", "runId"],
|
|
7065
|
+
message: "Active branch runId must match the command result runId."
|
|
7066
|
+
});
|
|
7067
|
+
}
|
|
6887
7068
|
});
|
|
6888
7069
|
var AGENT_SESSION_COMMAND_TRANSITIONS = {
|
|
6889
7070
|
stop: { queued: "stopping", running: "stopping", waiting_approval: "stopping" },
|
|
6890
7071
|
resume: { stopped: "queued", completed: "queued", failed: "queued" },
|
|
6891
7072
|
retry: { failed: "queued" },
|
|
6892
|
-
approval: { waiting_approval: "running" }
|
|
7073
|
+
approval: { waiting_approval: "running" },
|
|
7074
|
+
fork: {},
|
|
7075
|
+
"edit-and-rerun": {},
|
|
7076
|
+
steer: {}
|
|
6893
7077
|
};
|
|
7078
|
+
var AgentSessionCommandPolicySchema = z3.object({
|
|
7079
|
+
capability: AgentSessionCapabilitySchema.optional(),
|
|
7080
|
+
allowedStatuses: z3.array(AgentSessionStatusSchema).min(1),
|
|
7081
|
+
requiresRunId: z3.boolean(),
|
|
7082
|
+
sourceSessionEffect: z3.enum(["transition", "preserve"]),
|
|
7083
|
+
idempotencyScope: z3.literal("session-command"),
|
|
7084
|
+
sequenceRule: z3.literal("match-current")
|
|
7085
|
+
}).strict();
|
|
7086
|
+
var sessionCommandPolicy = (policy) => AgentSessionCommandPolicySchema.parse(policy);
|
|
7087
|
+
var AGENT_SESSION_COMMAND_POLICIES = Object.freeze({
|
|
7088
|
+
stop: sessionCommandPolicy({
|
|
7089
|
+
allowedStatuses: ["queued", "running", "waiting_approval"],
|
|
7090
|
+
requiresRunId: true,
|
|
7091
|
+
sourceSessionEffect: "transition",
|
|
7092
|
+
idempotencyScope: "session-command",
|
|
7093
|
+
sequenceRule: "match-current"
|
|
7094
|
+
}),
|
|
7095
|
+
resume: sessionCommandPolicy({
|
|
7096
|
+
capability: "resume",
|
|
7097
|
+
allowedStatuses: ["stopped", "completed", "failed"],
|
|
7098
|
+
requiresRunId: true,
|
|
7099
|
+
sourceSessionEffect: "transition",
|
|
7100
|
+
idempotencyScope: "session-command",
|
|
7101
|
+
sequenceRule: "match-current"
|
|
7102
|
+
}),
|
|
7103
|
+
retry: sessionCommandPolicy({
|
|
7104
|
+
allowedStatuses: ["failed"],
|
|
7105
|
+
requiresRunId: true,
|
|
7106
|
+
sourceSessionEffect: "transition",
|
|
7107
|
+
idempotencyScope: "session-command",
|
|
7108
|
+
sequenceRule: "match-current"
|
|
7109
|
+
}),
|
|
7110
|
+
approval: sessionCommandPolicy({
|
|
7111
|
+
capability: "approval",
|
|
7112
|
+
allowedStatuses: ["waiting_approval"],
|
|
7113
|
+
requiresRunId: true,
|
|
7114
|
+
sourceSessionEffect: "transition",
|
|
7115
|
+
idempotencyScope: "session-command",
|
|
7116
|
+
sequenceRule: "match-current"
|
|
7117
|
+
}),
|
|
7118
|
+
fork: sessionCommandPolicy({
|
|
7119
|
+
capability: "threadForking",
|
|
7120
|
+
allowedStatuses: AgentSessionStatusSchema.options,
|
|
7121
|
+
requiresRunId: false,
|
|
7122
|
+
sourceSessionEffect: "preserve",
|
|
7123
|
+
idempotencyScope: "session-command",
|
|
7124
|
+
sequenceRule: "match-current"
|
|
7125
|
+
}),
|
|
7126
|
+
"edit-and-rerun": sessionCommandPolicy({
|
|
7127
|
+
capability: "editAndRerun",
|
|
7128
|
+
allowedStatuses: ["stopped", "completed", "failed"],
|
|
7129
|
+
requiresRunId: false,
|
|
7130
|
+
sourceSessionEffect: "preserve",
|
|
7131
|
+
idempotencyScope: "session-command",
|
|
7132
|
+
sequenceRule: "match-current"
|
|
7133
|
+
}),
|
|
7134
|
+
steer: sessionCommandPolicy({
|
|
7135
|
+
capability: "steering",
|
|
7136
|
+
allowedStatuses: ["queued", "running"],
|
|
7137
|
+
requiresRunId: true,
|
|
7138
|
+
sourceSessionEffect: "preserve",
|
|
7139
|
+
idempotencyScope: "session-command",
|
|
7140
|
+
sequenceRule: "match-current"
|
|
7141
|
+
})
|
|
7142
|
+
});
|
|
7143
|
+
function getAgentSessionCommandPolicy(commandType) {
|
|
7144
|
+
return AGENT_SESSION_COMMAND_POLICIES[commandType];
|
|
7145
|
+
}
|
|
7146
|
+
function canIssueAgentSessionCommand(status, commandType) {
|
|
7147
|
+
return getAgentSessionCommandPolicy(commandType).allowedStatuses.includes(status);
|
|
7148
|
+
}
|
|
6894
7149
|
function resolveAgentSessionCommandTransition(status, commandType) {
|
|
6895
7150
|
return AGENT_SESSION_COMMAND_TRANSITIONS[commandType][status];
|
|
6896
7151
|
}
|
|
7152
|
+
function isAgentSessionTerminalStatus(status) {
|
|
7153
|
+
return AgentSessionTerminalStatusSchema.safeParse(status).success;
|
|
7154
|
+
}
|
|
7155
|
+
function canApplyAgentSessionRunStatus(current, next) {
|
|
7156
|
+
if (current === next) return true;
|
|
7157
|
+
const transitions = {
|
|
7158
|
+
queued: ["running", "stopping", "failed"],
|
|
7159
|
+
running: ["waiting_approval", "stopping", "completed", "failed"],
|
|
7160
|
+
waiting_approval: ["running", "stopping", "failed"],
|
|
7161
|
+
stopping: ["stopped", "completed", "failed"],
|
|
7162
|
+
stopped: [],
|
|
7163
|
+
completed: [],
|
|
7164
|
+
failed: []
|
|
7165
|
+
};
|
|
7166
|
+
return transitions[current].includes(next);
|
|
7167
|
+
}
|
|
6897
7168
|
var AgentSessionEventHeaderSchema = z3.object({
|
|
6898
7169
|
contract: z3.literal("AgentSessionEvent"),
|
|
6899
7170
|
eventId: ContractIdentifierSchema,
|
|
6900
7171
|
sessionId: ContractIdentifierSchema,
|
|
7172
|
+
runId: ContractIdentifierSchema.optional(),
|
|
7173
|
+
sourceMessageId: ContractIdentifierSchema.optional(),
|
|
6901
7174
|
sequence: z3.number().int().nonnegative(),
|
|
6902
7175
|
idempotencyKey: ContractIdentifierSchema,
|
|
6903
7176
|
occurredAt: IsoDateTimeSchema
|
|
@@ -6957,7 +7230,13 @@ var AgentSessionEventSchema = z3.discriminatedUnion("eventType", [
|
|
|
6957
7230
|
}),
|
|
6958
7231
|
sessionEvent("status", {
|
|
6959
7232
|
status: AgentSessionStatusSchema,
|
|
6960
|
-
detail: z3.string().optional()
|
|
7233
|
+
detail: z3.string().optional(),
|
|
7234
|
+
startedAt: IsoDateTimeSchema.optional(),
|
|
7235
|
+
stoppingRequestedAt: IsoDateTimeSchema.optional(),
|
|
7236
|
+
stoppedAt: IsoDateTimeSchema.optional(),
|
|
7237
|
+
completedAt: IsoDateTimeSchema.optional(),
|
|
7238
|
+
failedAt: IsoDateTimeSchema.optional(),
|
|
7239
|
+
durationMs: z3.number().nonnegative().optional()
|
|
6961
7240
|
}),
|
|
6962
7241
|
sessionEvent("artifact", {
|
|
6963
7242
|
artifactId: ContractIdentifierSchema,
|
|
@@ -7011,8 +7290,52 @@ var AgentSessionEventSchema = z3.discriminatedUnion("eventType", [
|
|
|
7011
7290
|
status: z3.enum(["running", "passed", "failed", "skipped"]),
|
|
7012
7291
|
durationMs: z3.number().nonnegative().optional(),
|
|
7013
7292
|
output: z3.string().optional()
|
|
7293
|
+
}),
|
|
7294
|
+
sessionEvent("summary", {
|
|
7295
|
+
summaryId: ContractIdentifierSchema,
|
|
7296
|
+
runId: ContractIdentifierSchema,
|
|
7297
|
+
text: z3.string(),
|
|
7298
|
+
highlights: z3.array(z3.string()),
|
|
7299
|
+
pendingItems: z3.array(z3.string()),
|
|
7300
|
+
status: z3.enum(["generating", "completed", "failed"])
|
|
7014
7301
|
})
|
|
7015
|
-
])
|
|
7302
|
+
]).superRefine((value, context) => {
|
|
7303
|
+
if (value.eventType === "summary" && value.runId !== value.payload.runId) {
|
|
7304
|
+
context.addIssue({
|
|
7305
|
+
code: "custom",
|
|
7306
|
+
path: ["payload", "runId"],
|
|
7307
|
+
message: "Summary payload runId must match the event runId."
|
|
7308
|
+
});
|
|
7309
|
+
}
|
|
7310
|
+
});
|
|
7311
|
+
var AgentSessionRunEventSchema = AgentSessionEventSchema.superRefine((value, context) => {
|
|
7312
|
+
if (!value.runId) {
|
|
7313
|
+
context.addIssue({ code: "custom", path: ["runId"], message: "Run events require runId." });
|
|
7314
|
+
}
|
|
7315
|
+
if (!value.sourceMessageId) {
|
|
7316
|
+
context.addIssue({
|
|
7317
|
+
code: "custom",
|
|
7318
|
+
path: ["sourceMessageId"],
|
|
7319
|
+
message: "Run events require sourceMessageId."
|
|
7320
|
+
});
|
|
7321
|
+
}
|
|
7322
|
+
if (value.eventType !== "status") return;
|
|
7323
|
+
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;
|
|
7324
|
+
if (requiredTimeField && !value.payload[requiredTimeField]) {
|
|
7325
|
+
context.addIssue({
|
|
7326
|
+
code: "custom",
|
|
7327
|
+
path: ["payload", requiredTimeField],
|
|
7328
|
+
message: `Run status ${value.payload.status} requires ${requiredTimeField}.`
|
|
7329
|
+
});
|
|
7330
|
+
}
|
|
7331
|
+
if (isAgentSessionTerminalStatus(value.payload.status) && value.payload.durationMs === void 0) {
|
|
7332
|
+
context.addIssue({
|
|
7333
|
+
code: "custom",
|
|
7334
|
+
path: ["payload", "durationMs"],
|
|
7335
|
+
message: `Terminal run status ${value.payload.status} requires durationMs.`
|
|
7336
|
+
});
|
|
7337
|
+
}
|
|
7338
|
+
});
|
|
7016
7339
|
var AgentSessionViewModelSchema = z3.object({
|
|
7017
7340
|
contract: z3.literal("AgentSessionViewModel"),
|
|
7018
7341
|
sessionId: ContractIdentifierSchema,
|
|
@@ -7020,7 +7343,9 @@ var AgentSessionViewModelSchema = z3.object({
|
|
|
7020
7343
|
status: AgentSessionStatusSchema,
|
|
7021
7344
|
events: z3.array(AgentSessionEventSchema),
|
|
7022
7345
|
lastSequence: z3.number().int().min(-1),
|
|
7023
|
-
resumable: z3.boolean().default(false)
|
|
7346
|
+
resumable: z3.boolean().default(false),
|
|
7347
|
+
lineage: AgentSessionLineageSchema.optional(),
|
|
7348
|
+
activeBranch: AgentSessionActiveBranchSchema.optional()
|
|
7024
7349
|
}).strict().superRefine((value, context) => {
|
|
7025
7350
|
const eventIds = /* @__PURE__ */ new Set();
|
|
7026
7351
|
const idempotencyKeys = /* @__PURE__ */ new Set();
|
|
@@ -11732,8 +12057,11 @@ var WorkflowCompletionReceiptSchema = z15.object({
|
|
|
11732
12057
|
// src/schemas/index.ts
|
|
11733
12058
|
var canonicalContractSchemas = {
|
|
11734
12059
|
"agent-session-command": AgentSessionCommandSchema,
|
|
12060
|
+
"agent-session-targeted-command": AgentSessionTargetedCommandSchema,
|
|
11735
12061
|
"agent-session-command-result": AgentSessionCommandResultSchema,
|
|
11736
12062
|
"agent-session-event": AgentSessionEventSchema,
|
|
12063
|
+
"agent-session-run-event": AgentSessionRunEventSchema,
|
|
12064
|
+
"agent-session-run": AgentSessionRunSchema,
|
|
11737
12065
|
"agent-session-view-model": AgentSessionViewModelSchema,
|
|
11738
12066
|
"agent-runtime-event": AgentRuntimeEventSchema,
|
|
11739
12067
|
"application-run": ApplicationRunSchema,
|
|
@@ -13024,6 +13352,7 @@ var compileWorkflowPersistenceProjection = (input) => {
|
|
|
13024
13352
|
export {
|
|
13025
13353
|
AGENT_MODE_CAPABILITIES,
|
|
13026
13354
|
AGENT_SESSION_CAPABILITY_EVIDENCE,
|
|
13355
|
+
AGENT_SESSION_COMMAND_POLICIES,
|
|
13027
13356
|
AGENT_SESSION_RUNTIME_CAPABILITIES,
|
|
13028
13357
|
APPLICATION_HANDOFF_QUERY_PARAMETER,
|
|
13029
13358
|
ActorRefSchema,
|
|
@@ -13033,15 +13362,23 @@ export {
|
|
|
13033
13362
|
AgentModeSchema,
|
|
13034
13363
|
AgentResourceModeSupportSchema,
|
|
13035
13364
|
AgentRuntimeEventSchema,
|
|
13365
|
+
AgentSessionActiveBranchSchema,
|
|
13036
13366
|
AgentSessionCapabilitiesSchema,
|
|
13037
13367
|
AgentSessionCapabilitySchema,
|
|
13038
13368
|
AgentSessionCommandErrorCodeSchema,
|
|
13369
|
+
AgentSessionCommandPolicySchema,
|
|
13039
13370
|
AgentSessionCommandResultSchema,
|
|
13040
13371
|
AgentSessionCommandSchema,
|
|
13041
13372
|
AgentSessionCommandTypeSchema,
|
|
13373
|
+
AgentSessionContextInheritanceSchema,
|
|
13042
13374
|
AgentSessionEventSchema,
|
|
13375
|
+
AgentSessionLineageSchema,
|
|
13376
|
+
AgentSessionRunEventSchema,
|
|
13377
|
+
AgentSessionRunSchema,
|
|
13043
13378
|
AgentSessionSnapshotSchema,
|
|
13044
13379
|
AgentSessionStatusSchema,
|
|
13380
|
+
AgentSessionTargetedCommandSchema,
|
|
13381
|
+
AgentSessionTerminalStatusSchema,
|
|
13045
13382
|
AgentSessionViewModelSchema,
|
|
13046
13383
|
ApplicationHandoffEndpointSchema,
|
|
13047
13384
|
ApplicationHandoffSchema,
|
|
@@ -13186,6 +13523,8 @@ export {
|
|
|
13186
13523
|
assertThemeTokensDocumentStructure,
|
|
13187
13524
|
buildApplicationHandoffUrl,
|
|
13188
13525
|
buildChangeImpactGraph,
|
|
13526
|
+
canApplyAgentSessionRunStatus,
|
|
13527
|
+
canIssueAgentSessionCommand,
|
|
13189
13528
|
canonicalContractSchemas,
|
|
13190
13529
|
compileCapabilityRegistry,
|
|
13191
13530
|
compileConductorWorkflowDefinition,
|
|
@@ -13208,8 +13547,10 @@ export {
|
|
|
13208
13547
|
extractOpenApiCapabilityManifests,
|
|
13209
13548
|
findUnsupportedAgentSessionCapabilities,
|
|
13210
13549
|
getAgentModeCapabilities,
|
|
13550
|
+
getAgentSessionCommandPolicy,
|
|
13211
13551
|
getAgentSessionRuntimeCapabilities,
|
|
13212
13552
|
isAgentResourceModeCompatible,
|
|
13553
|
+
isAgentSessionTerminalStatus,
|
|
13213
13554
|
mergeThemeTokenDocuments,
|
|
13214
13555
|
normalizeAgentExecutionMode,
|
|
13215
13556
|
normalizeAgentMode,
|