@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/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 || []);
@@ -6820,6 +6832,26 @@ var AgentSessionStatusSchema = z3.enum([
6820
6832
  "failed"
6821
6833
  ]);
6822
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();
6823
6855
  var AgentSessionRunSchema = z3.object({
6824
6856
  runId: ContractIdentifierSchema,
6825
6857
  sessionId: ContractIdentifierSchema,
@@ -6877,7 +6909,15 @@ var AgentSessionRunSchema = z3.object({
6877
6909
  });
6878
6910
  }
6879
6911
  });
6880
- var AgentSessionCommandTypeSchema = z3.enum(["stop", "resume", "retry", "approval"]);
6912
+ var AgentSessionCommandTypeSchema = z3.enum([
6913
+ "stop",
6914
+ "resume",
6915
+ "retry",
6916
+ "approval",
6917
+ "fork",
6918
+ "edit-and-rerun",
6919
+ "steer"
6920
+ ]);
6881
6921
  var AgentSessionCommandHeaderSchema = z3.object({
6882
6922
  contract: z3.literal("AgentSessionCommand"),
6883
6923
  commandId: ContractIdentifierSchema,
@@ -6905,8 +6945,33 @@ var AgentSessionCommandSchema = z3.discriminatedUnion("commandType", [
6905
6945
  approvalId: ContractIdentifierSchema,
6906
6946
  decision: z3.enum(["approved", "rejected"]),
6907
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)
6908
6965
  })
6909
- ]);
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
+ });
6910
6975
  var AgentSessionTargetedCommandSchema = AgentSessionCommandSchema.and(
6911
6976
  z3.object({ runId: ContractIdentifierSchema })
6912
6977
  );
@@ -6923,6 +6988,11 @@ var AgentSessionCommandErrorCodeSchema = z3.enum([
6923
6988
  "TARGET_EVENT_NOT_RETRYABLE",
6924
6989
  "APPROVAL_NOT_FOUND",
6925
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",
6926
6996
  "COMMAND_EXECUTION_FAILED"
6927
6997
  ]);
6928
6998
  var AgentSessionCommandResultSchema = z3.object({
@@ -6935,6 +7005,10 @@ var AgentSessionCommandResultSchema = z3.object({
6935
7005
  sessionStatus: AgentSessionStatusSchema,
6936
7006
  acceptedSequence: z3.number().int().nonnegative().optional(),
6937
7007
  resultEventIds: z3.array(ContractIdentifierSchema).default([]),
7008
+ operation: z3.object({
7009
+ lineage: AgentSessionLineageSchema,
7010
+ activeBranch: AgentSessionActiveBranchSchema
7011
+ }).strict().optional(),
6938
7012
  termination: z3.enum(["requested", "confirmed"]).optional(),
6939
7013
  error: z3.object({
6940
7014
  code: AgentSessionCommandErrorCodeSchema,
@@ -6965,13 +7039,113 @@ var AgentSessionCommandResultSchema = z3.object({
6965
7039
  message: "A confirmed termination requires a terminal run status."
6966
7040
  });
6967
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
+ }
6968
7068
  });
6969
7069
  var AGENT_SESSION_COMMAND_TRANSITIONS = {
6970
7070
  stop: { queued: "stopping", running: "stopping", waiting_approval: "stopping" },
6971
7071
  resume: { stopped: "queued", completed: "queued", failed: "queued" },
6972
7072
  retry: { failed: "queued" },
6973
- approval: { waiting_approval: "running" }
7073
+ approval: { waiting_approval: "running" },
7074
+ fork: {},
7075
+ "edit-and-rerun": {},
7076
+ steer: {}
6974
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
+ }
6975
7149
  function resolveAgentSessionCommandTransition(status, commandType) {
6976
7150
  return AGENT_SESSION_COMMAND_TRANSITIONS[commandType][status];
6977
7151
  }
@@ -7116,8 +7290,24 @@ var AgentSessionEventSchema = z3.discriminatedUnion("eventType", [
7116
7290
  status: z3.enum(["running", "passed", "failed", "skipped"]),
7117
7291
  durationMs: z3.number().nonnegative().optional(),
7118
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"])
7119
7301
  })
7120
- ]);
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
+ });
7121
7311
  var AgentSessionRunEventSchema = AgentSessionEventSchema.superRefine((value, context) => {
7122
7312
  if (!value.runId) {
7123
7313
  context.addIssue({ code: "custom", path: ["runId"], message: "Run events require runId." });
@@ -7153,7 +7343,9 @@ var AgentSessionViewModelSchema = z3.object({
7153
7343
  status: AgentSessionStatusSchema,
7154
7344
  events: z3.array(AgentSessionEventSchema),
7155
7345
  lastSequence: z3.number().int().min(-1),
7156
- resumable: z3.boolean().default(false)
7346
+ resumable: z3.boolean().default(false),
7347
+ lineage: AgentSessionLineageSchema.optional(),
7348
+ activeBranch: AgentSessionActiveBranchSchema.optional()
7157
7349
  }).strict().superRefine((value, context) => {
7158
7350
  const eventIds = /* @__PURE__ */ new Set();
7159
7351
  const idempotencyKeys = /* @__PURE__ */ new Set();
@@ -13160,6 +13352,7 @@ var compileWorkflowPersistenceProjection = (input) => {
13160
13352
  export {
13161
13353
  AGENT_MODE_CAPABILITIES,
13162
13354
  AGENT_SESSION_CAPABILITY_EVIDENCE,
13355
+ AGENT_SESSION_COMMAND_POLICIES,
13163
13356
  AGENT_SESSION_RUNTIME_CAPABILITIES,
13164
13357
  APPLICATION_HANDOFF_QUERY_PARAMETER,
13165
13358
  ActorRefSchema,
@@ -13169,13 +13362,17 @@ export {
13169
13362
  AgentModeSchema,
13170
13363
  AgentResourceModeSupportSchema,
13171
13364
  AgentRuntimeEventSchema,
13365
+ AgentSessionActiveBranchSchema,
13172
13366
  AgentSessionCapabilitiesSchema,
13173
13367
  AgentSessionCapabilitySchema,
13174
13368
  AgentSessionCommandErrorCodeSchema,
13369
+ AgentSessionCommandPolicySchema,
13175
13370
  AgentSessionCommandResultSchema,
13176
13371
  AgentSessionCommandSchema,
13177
13372
  AgentSessionCommandTypeSchema,
13373
+ AgentSessionContextInheritanceSchema,
13178
13374
  AgentSessionEventSchema,
13375
+ AgentSessionLineageSchema,
13179
13376
  AgentSessionRunEventSchema,
13180
13377
  AgentSessionRunSchema,
13181
13378
  AgentSessionSnapshotSchema,
@@ -13327,6 +13524,7 @@ export {
13327
13524
  buildApplicationHandoffUrl,
13328
13525
  buildChangeImpactGraph,
13329
13526
  canApplyAgentSessionRunStatus,
13527
+ canIssueAgentSessionCommand,
13330
13528
  canonicalContractSchemas,
13331
13529
  compileCapabilityRegistry,
13332
13530
  compileConductorWorkflowDefinition,
@@ -13349,6 +13547,7 @@ export {
13349
13547
  extractOpenApiCapabilityManifests,
13350
13548
  findUnsupportedAgentSessionCapabilities,
13351
13549
  getAgentModeCapabilities,
13550
+ getAgentSessionCommandPolicy,
13352
13551
  getAgentSessionRuntimeCapabilities,
13353
13552
  isAgentResourceModeCompatible,
13354
13553
  isAgentSessionTerminalStatus,