@inf-monkeys-tech/monkeys 1.0.21 → 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 +471 -0
- package/lib/contracts/agent.d.ts.map +1 -1
- package/lib/contracts/agent.js +211 -4
- package/lib/contracts/agent.js.map +1 -1
- package/lib/contracts/theme.d.ts +1 -1
- package/lib/esm/contracts/index.mjs +207 -8
- package/lib/esm/contracts/index.mjs.map +1 -1
- package/lib/esm/index.mjs +207 -8
- package/lib/esm/index.mjs.map +1 -1
- package/lib/esm/runtime/index.mjs +190 -7
- package/lib/esm/runtime/index.mjs.map +1 -1
- package/lib/esm/schemas/index.mjs +194 -7
- package/lib/esm/schemas/index.mjs.map +1 -1
- package/lib/json-schema/agent-session-command-result.schema.json +105 -0
- package/lib/json-schema/agent-session-command.schema.json +375 -0
- package/lib/json-schema/agent-session-event.schema.json +106 -0
- package/lib/json-schema/agent-session-run-event.schema.json +106 -0
- package/lib/json-schema/agent-session-targeted-command.schema.json +375 -0
- package/lib/json-schema/agent-session-view-model.schema.json +217 -1
- package/lib/schemas/index.d.ts +284 -1
- package/lib/schemas/index.d.ts.map +1 -1
- package/lib/schemas/index.js +7 -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
|
@@ -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 || []);
|
|
@@ -6783,6 +6795,26 @@ var AgentSessionStatusSchema = z3.enum([
|
|
|
6783
6795
|
"failed"
|
|
6784
6796
|
]);
|
|
6785
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();
|
|
6786
6818
|
var AgentSessionRunSchema = z3.object({
|
|
6787
6819
|
runId: ContractIdentifierSchema,
|
|
6788
6820
|
sessionId: ContractIdentifierSchema,
|
|
@@ -6840,7 +6872,15 @@ var AgentSessionRunSchema = z3.object({
|
|
|
6840
6872
|
});
|
|
6841
6873
|
}
|
|
6842
6874
|
});
|
|
6843
|
-
var AgentSessionCommandTypeSchema = z3.enum([
|
|
6875
|
+
var AgentSessionCommandTypeSchema = z3.enum([
|
|
6876
|
+
"stop",
|
|
6877
|
+
"resume",
|
|
6878
|
+
"retry",
|
|
6879
|
+
"approval",
|
|
6880
|
+
"fork",
|
|
6881
|
+
"edit-and-rerun",
|
|
6882
|
+
"steer"
|
|
6883
|
+
]);
|
|
6844
6884
|
var AgentSessionCommandHeaderSchema = z3.object({
|
|
6845
6885
|
contract: z3.literal("AgentSessionCommand"),
|
|
6846
6886
|
commandId: ContractIdentifierSchema,
|
|
@@ -6868,8 +6908,33 @@ var AgentSessionCommandSchema = z3.discriminatedUnion("commandType", [
|
|
|
6868
6908
|
approvalId: ContractIdentifierSchema,
|
|
6869
6909
|
decision: z3.enum(["approved", "rejected"]),
|
|
6870
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)
|
|
6871
6928
|
})
|
|
6872
|
-
])
|
|
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
|
+
});
|
|
6873
6938
|
var AgentSessionTargetedCommandSchema = AgentSessionCommandSchema.and(
|
|
6874
6939
|
z3.object({ runId: ContractIdentifierSchema })
|
|
6875
6940
|
);
|
|
@@ -6886,6 +6951,11 @@ var AgentSessionCommandErrorCodeSchema = z3.enum([
|
|
|
6886
6951
|
"TARGET_EVENT_NOT_RETRYABLE",
|
|
6887
6952
|
"APPROVAL_NOT_FOUND",
|
|
6888
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",
|
|
6889
6959
|
"COMMAND_EXECUTION_FAILED"
|
|
6890
6960
|
]);
|
|
6891
6961
|
var AgentSessionCommandResultSchema = z3.object({
|
|
@@ -6898,6 +6968,10 @@ var AgentSessionCommandResultSchema = z3.object({
|
|
|
6898
6968
|
sessionStatus: AgentSessionStatusSchema,
|
|
6899
6969
|
acceptedSequence: z3.number().int().nonnegative().optional(),
|
|
6900
6970
|
resultEventIds: z3.array(ContractIdentifierSchema).default([]),
|
|
6971
|
+
operation: z3.object({
|
|
6972
|
+
lineage: AgentSessionLineageSchema,
|
|
6973
|
+
activeBranch: AgentSessionActiveBranchSchema
|
|
6974
|
+
}).strict().optional(),
|
|
6901
6975
|
termination: z3.enum(["requested", "confirmed"]).optional(),
|
|
6902
6976
|
error: z3.object({
|
|
6903
6977
|
code: AgentSessionCommandErrorCodeSchema,
|
|
@@ -6928,13 +7002,113 @@ var AgentSessionCommandResultSchema = z3.object({
|
|
|
6928
7002
|
message: "A confirmed termination requires a terminal run status."
|
|
6929
7003
|
});
|
|
6930
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
|
+
}
|
|
6931
7031
|
});
|
|
6932
7032
|
var AGENT_SESSION_COMMAND_TRANSITIONS = {
|
|
6933
7033
|
stop: { queued: "stopping", running: "stopping", waiting_approval: "stopping" },
|
|
6934
7034
|
resume: { stopped: "queued", completed: "queued", failed: "queued" },
|
|
6935
7035
|
retry: { failed: "queued" },
|
|
6936
|
-
approval: { waiting_approval: "running" }
|
|
7036
|
+
approval: { waiting_approval: "running" },
|
|
7037
|
+
fork: {},
|
|
7038
|
+
"edit-and-rerun": {},
|
|
7039
|
+
steer: {}
|
|
6937
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
|
+
}
|
|
6938
7112
|
function resolveAgentSessionCommandTransition(status, commandType) {
|
|
6939
7113
|
return AGENT_SESSION_COMMAND_TRANSITIONS[commandType][status];
|
|
6940
7114
|
}
|
|
@@ -7079,8 +7253,24 @@ var AgentSessionEventSchema = z3.discriminatedUnion("eventType", [
|
|
|
7079
7253
|
status: z3.enum(["running", "passed", "failed", "skipped"]),
|
|
7080
7254
|
durationMs: z3.number().nonnegative().optional(),
|
|
7081
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"])
|
|
7082
7264
|
})
|
|
7083
|
-
])
|
|
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
|
+
});
|
|
7084
7274
|
var AgentSessionRunEventSchema = AgentSessionEventSchema.superRefine((value, context) => {
|
|
7085
7275
|
if (!value.runId) {
|
|
7086
7276
|
context.addIssue({ code: "custom", path: ["runId"], message: "Run events require runId." });
|
|
@@ -7116,7 +7306,9 @@ var AgentSessionViewModelSchema = z3.object({
|
|
|
7116
7306
|
status: AgentSessionStatusSchema,
|
|
7117
7307
|
events: z3.array(AgentSessionEventSchema),
|
|
7118
7308
|
lastSequence: z3.number().int().min(-1),
|
|
7119
|
-
resumable: z3.boolean().default(false)
|
|
7309
|
+
resumable: z3.boolean().default(false),
|
|
7310
|
+
lineage: AgentSessionLineageSchema.optional(),
|
|
7311
|
+
activeBranch: AgentSessionActiveBranchSchema.optional()
|
|
7120
7312
|
}).strict().superRefine((value, context) => {
|
|
7121
7313
|
const eventIds = /* @__PURE__ */ new Set();
|
|
7122
7314
|
const idempotencyKeys = /* @__PURE__ */ new Set();
|
|
@@ -11794,6 +11986,7 @@ var WorkflowCompletionReceiptSchema = z15.object({
|
|
|
11794
11986
|
export {
|
|
11795
11987
|
AGENT_MODE_CAPABILITIES,
|
|
11796
11988
|
AGENT_SESSION_CAPABILITY_EVIDENCE,
|
|
11989
|
+
AGENT_SESSION_COMMAND_POLICIES,
|
|
11797
11990
|
AGENT_SESSION_RUNTIME_CAPABILITIES,
|
|
11798
11991
|
ActorRefSchema,
|
|
11799
11992
|
AgentConfigurationCapabilitySchema,
|
|
@@ -11802,13 +11995,17 @@ export {
|
|
|
11802
11995
|
AgentModeSchema,
|
|
11803
11996
|
AgentResourceModeSupportSchema,
|
|
11804
11997
|
AgentRuntimeEventSchema,
|
|
11998
|
+
AgentSessionActiveBranchSchema,
|
|
11805
11999
|
AgentSessionCapabilitiesSchema,
|
|
11806
12000
|
AgentSessionCapabilitySchema,
|
|
11807
12001
|
AgentSessionCommandErrorCodeSchema,
|
|
12002
|
+
AgentSessionCommandPolicySchema,
|
|
11808
12003
|
AgentSessionCommandResultSchema,
|
|
11809
12004
|
AgentSessionCommandSchema,
|
|
11810
12005
|
AgentSessionCommandTypeSchema,
|
|
12006
|
+
AgentSessionContextInheritanceSchema,
|
|
11811
12007
|
AgentSessionEventSchema,
|
|
12008
|
+
AgentSessionLineageSchema,
|
|
11812
12009
|
AgentSessionRunEventSchema,
|
|
11813
12010
|
AgentSessionRunSchema,
|
|
11814
12011
|
AgentSessionSnapshotSchema,
|
|
@@ -11947,8 +12144,10 @@ export {
|
|
|
11947
12144
|
WorkflowValidationIssueSchema,
|
|
11948
12145
|
agentModeHasCapability,
|
|
11949
12146
|
canApplyAgentSessionRunStatus,
|
|
12147
|
+
canIssueAgentSessionCommand,
|
|
11950
12148
|
findUnsupportedAgentSessionCapabilities,
|
|
11951
12149
|
getAgentModeCapabilities,
|
|
12150
|
+
getAgentSessionCommandPolicy,
|
|
11952
12151
|
getAgentSessionRuntimeCapabilities,
|
|
11953
12152
|
isAgentResourceModeCompatible,
|
|
11954
12153
|
isAgentSessionTerminalStatus,
|