@inf-monkeys-tech/monkeys 1.0.14 → 1.0.15

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
@@ -6770,6 +6770,41 @@ var AgentSessionCapabilitiesSchema = z3.object({
6770
6770
  terminal: z3.boolean().default(false),
6771
6771
  testResults: z3.boolean().default(false)
6772
6772
  }).strict();
6773
+ var AGENT_SESSION_RUNTIME_CAPABILITIES = Object.freeze({
6774
+ chatbot: AgentSessionCapabilitiesSchema.parse({ text: true, tools: true, mcp: true, skills: true, approval: true, usage: true }),
6775
+ agent: AgentSessionCapabilitiesSchema.parse({ text: true, tools: true, mcp: true, shell: true, fileChange: true, skills: true, approval: true, artifacts: true, usage: true, resume: true })
6776
+ });
6777
+ function getAgentSessionRuntimeCapabilities(mode) {
6778
+ return AGENT_SESSION_RUNTIME_CAPABILITIES[mode];
6779
+ }
6780
+ var AGENT_SESSION_CAPABILITY_EVIDENCE = Object.freeze({
6781
+ text: { eventTypes: ["message"], commandTypes: [] },
6782
+ reasoning: { eventTypes: ["reasoning"], commandTypes: [] },
6783
+ plan: { eventTypes: ["plan"], commandTypes: [] },
6784
+ tasks: { eventTypes: ["task"], commandTypes: [] },
6785
+ tools: { eventTypes: ["tool"], commandTypes: [] },
6786
+ mcp: { eventTypes: ["tool"], commandTypes: [] },
6787
+ shell: { eventTypes: ["tool", "terminal"], commandTypes: [] },
6788
+ fileChange: { eventTypes: ["tool", "diff", "workspace-file"], commandTypes: [] },
6789
+ skills: { eventTypes: ["tool"], commandTypes: [] },
6790
+ approval: { eventTypes: ["approval"], commandTypes: ["approval"] },
6791
+ artifacts: { eventTypes: ["artifact"], commandTypes: [] },
6792
+ usage: { eventTypes: ["usage"], commandTypes: [] },
6793
+ resume: { eventTypes: ["resume"], commandTypes: ["resume"] },
6794
+ diff: { eventTypes: ["diff"], commandTypes: [] },
6795
+ workspaceFiles: { eventTypes: ["workspace-file"], commandTypes: [] },
6796
+ terminal: { eventTypes: ["terminal"], commandTypes: [] },
6797
+ testResults: { eventTypes: ["test-result"], commandTypes: [] }
6798
+ });
6799
+ function findUnsupportedAgentSessionCapabilities(capabilities, evidence) {
6800
+ const eventTypes = new Set(evidence.eventTypes || []);
6801
+ const commandTypes = new Set(evidence.commandTypes || []);
6802
+ return AgentSessionCapabilitySchema.options.filter((capability) => {
6803
+ if (!capabilities[capability]) return false;
6804
+ const requirement = AGENT_SESSION_CAPABILITY_EVIDENCE[capability];
6805
+ return !requirement.eventTypes.some((eventType) => eventTypes.has(eventType)) && !requirement.commandTypes.some((commandType) => commandTypes.has(commandType));
6806
+ });
6807
+ }
6773
6808
  var AgentSessionSnapshotSchema = z3.object({
6774
6809
  mode: AgentModeSchema,
6775
6810
  modelId: z3.string().trim().min(1),
@@ -11670,6 +11705,98 @@ var compileCapabilityRegistry = (sources) => {
11670
11705
  });
11671
11706
  };
11672
11707
 
11708
+ // src/runtime/agent-session-projector.ts
11709
+ function createAgentSessionEventProjection(sessionId) {
11710
+ return {
11711
+ sessionId,
11712
+ events: [],
11713
+ lastSequence: -1,
11714
+ status: "queued",
11715
+ resumable: false
11716
+ };
11717
+ }
11718
+ function projectAgentSessionEvents(current, candidates) {
11719
+ const parsed = candidates.map(
11720
+ (candidate) => AgentSessionEventSchema.parse(candidate)
11721
+ );
11722
+ if (parsed.some((event) => event.sessionId !== current.sessionId)) {
11723
+ throw new TypeError(
11724
+ "Agent session event sessionId does not match the projection sessionId."
11725
+ );
11726
+ }
11727
+ const eventIds = new Set(current.events.map((event) => event.eventId));
11728
+ const idempotencyKeys = new Set(
11729
+ current.events.map((event) => event.idempotencyKey)
11730
+ );
11731
+ const eventsBySequence = new Map(
11732
+ current.events.map((event) => [event.sequence, event])
11733
+ );
11734
+ const acceptedCandidates = [];
11735
+ for (const event of parsed.sort(
11736
+ (left, right) => left.sequence - right.sequence
11737
+ )) {
11738
+ if (eventIds.has(event.eventId) || idempotencyKeys.has(event.idempotencyKey))
11739
+ continue;
11740
+ const existing = eventsBySequence.get(event.sequence);
11741
+ if (existing) {
11742
+ throw new TypeError(
11743
+ `Conflicting Agent session events share sequence ${event.sequence}.`
11744
+ );
11745
+ }
11746
+ eventsBySequence.set(event.sequence, event);
11747
+ eventIds.add(event.eventId);
11748
+ idempotencyKeys.add(event.idempotencyKey);
11749
+ acceptedCandidates.push(event);
11750
+ }
11751
+ for (const event of acceptedCandidates)
11752
+ eventsBySequence.delete(event.sequence);
11753
+ let expectedSequence = current.lastSequence + 1;
11754
+ let gap;
11755
+ for (const event of acceptedCandidates) {
11756
+ if (event.sequence < expectedSequence) {
11757
+ throw new TypeError(
11758
+ `Agent session event sequence ${event.sequence} is behind the recovery cursor.`
11759
+ );
11760
+ }
11761
+ if (event.sequence > expectedSequence) {
11762
+ gap = { expectedSequence, receivedSequence: event.sequence };
11763
+ break;
11764
+ }
11765
+ eventsBySequence.set(event.sequence, event);
11766
+ eventIds.add(event.eventId);
11767
+ idempotencyKeys.add(event.idempotencyKey);
11768
+ expectedSequence += 1;
11769
+ }
11770
+ const events = [...eventsBySequence.values()].sort(
11771
+ (left, right) => left.sequence - right.sequence
11772
+ );
11773
+ let status = "queued";
11774
+ let resumable = false;
11775
+ for (const event of events) {
11776
+ if (event.eventType === "status") status = event.payload.status;
11777
+ if (event.eventType === "resume") resumable = event.payload.resumable;
11778
+ }
11779
+ return {
11780
+ sessionId: current.sessionId,
11781
+ events,
11782
+ lastSequence: events.length > 0 ? events[events.length - 1].sequence : -1,
11783
+ status,
11784
+ resumable,
11785
+ ...gap ? { gap } : {}
11786
+ };
11787
+ }
11788
+ function toAgentSessionViewModel(projection, snapshot) {
11789
+ return AgentSessionViewModelSchema.parse({
11790
+ contract: "AgentSessionViewModel",
11791
+ sessionId: projection.sessionId,
11792
+ snapshot,
11793
+ status: projection.status,
11794
+ events: projection.events,
11795
+ lastSequence: projection.lastSequence,
11796
+ resumable: projection.resumable
11797
+ });
11798
+ }
11799
+
11673
11800
  // src/runtime/declaration-compiler.ts
11674
11801
  var uniqueIndex = (values, key, label) => {
11675
11802
  const result = /* @__PURE__ */ new Map();
@@ -12679,6 +12806,8 @@ var compileWorkflowPersistenceProjection = (input) => {
12679
12806
  };
12680
12807
  export {
12681
12808
  AGENT_MODE_CAPABILITIES,
12809
+ AGENT_SESSION_CAPABILITY_EVIDENCE,
12810
+ AGENT_SESSION_RUNTIME_CAPABILITIES,
12682
12811
  APPLICATION_HANDOFF_QUERY_PARAMETER,
12683
12812
  ActorRefSchema,
12684
12813
  AgentConfigurationCapabilitySchema,
@@ -12850,22 +12979,27 @@ export {
12850
12979
  compileViewProviderRegistry,
12851
12980
  compileWorkflowDefinitionFromConductor,
12852
12981
  compileWorkflowPersistenceProjection,
12982
+ createAgentSessionEventProjection,
12853
12983
  createCapabilityRegistrySource,
12854
12984
  createOpenApiCapabilityRegistrySource,
12855
12985
  createToolCapabilityManifest,
12856
12986
  createWorkflowCapabilityManifest,
12857
12987
  extractOpenApiCapabilityManifests,
12988
+ findUnsupportedAgentSessionCapabilities,
12858
12989
  getAgentModeCapabilities,
12990
+ getAgentSessionRuntimeCapabilities,
12859
12991
  isAgentResourceModeCompatible,
12860
12992
  mergeThemeTokenDocuments,
12861
12993
  normalizeAgentExecutionMode,
12862
12994
  normalizeAgentMode,
12863
12995
  parseApplicationHandoff,
12996
+ projectAgentSessionEvents,
12864
12997
  publishOpenApiToolCapabilityManifests,
12865
12998
  readApplicationHandoffFromUrl,
12866
12999
  resolveAgentSessionCommandTransition,
12867
13000
  resolveThemeTokens,
12868
13001
  serializeApplicationHandoff,
13002
+ toAgentSessionViewModel,
12869
13003
  validateDomainCommand,
12870
13004
  validateThemeTokensDocument,
12871
13005
  validateThemeTokensDocumentStructure