Browse Source

chore: generate

opencode-agent[bot] 3 months ago
parent
commit
f26a9e8856

+ 3 - 11
packages/core/src/location-layer.ts

@@ -86,17 +86,9 @@ export class LocationServiceMap extends LayerMap.Service<LocationServiceMap>()("
       Layer.provide(model),
       Layer.provide(skillGuidance),
     )
-    return Layer.mergeAll(
-      services,
-      commits,
-      searches,
-      resources,
-      todos,
-      questions,
-      model,
-      runner,
-      builtInTools,
-    ).pipe(Layer.fresh)
+    return Layer.mergeAll(services, commits, searches, resources, todos, questions, model, runner, builtInTools).pipe(
+      Layer.fresh,
+    )
   },
   idleTimeToLive: "60 minutes",
   dependencies: [

+ 2 - 1
packages/core/src/session.ts

@@ -409,7 +409,8 @@ export const layer = Layer.effect(
               sessionID,
               timestamp: yield* DateTime.now,
             })
-            if (event.seq === undefined) return yield* Effect.die("Interrupt request event is missing aggregate sequence")
+            if (event.seq === undefined)
+              return yield* Effect.die("Interrupt request event is missing aggregate sequence")
             yield* execution.interrupt(sessionID, event.seq)
           }),
         ),

+ 16 - 3
packages/core/src/session/run-coordinator.ts

@@ -95,7 +95,10 @@ export const make = <Key, A, E>(options: {
       // Initial work retains immediate-start behavior but cannot run before ownership is published.
       // Observer-started successors yield once so synchronous drains cannot recurse on the JS stack.
       const owner = fork(
-        (successor ? Effect.yieldNow.pipe(Effect.andThen(drain)) : Deferred.await(ready).pipe(Effect.andThen(drain))).pipe(
+        (successor
+          ? Effect.yieldNow.pipe(Effect.andThen(drain))
+          : Deferred.await(ready).pipe(Effect.andThen(drain))
+        ).pipe(
           Effect.onExit((exit) => Effect.sync(() => settle(key, entry, demand, exit))),
           Effect.exit,
           Effect.asVoid,
@@ -194,7 +197,12 @@ export const make = <Key, A, E>(options: {
           return entry?.stopping && entry.owner !== undefined ? Fiber.interrupt(entry.owner) : Effect.void
         if (seq !== undefined) interruptSeq.set(key, seq)
         if (entry?.owner === undefined) return Effect.void
-        if (seq !== undefined && entry.current._tag === "wake" && entry.current.seq !== undefined && entry.current.seq > seq)
+        if (
+          seq !== undefined &&
+          entry.current._tag === "wake" &&
+          entry.current.seq !== undefined &&
+          entry.current.seq > seq
+        )
           return Effect.void
         if (entry.stopping) {
           entry.interruptSeq = maxSeq(entry.interruptSeq, seq)
@@ -246,7 +254,12 @@ export const make = <Key, A, E>(options: {
     }
 
     function suppressPendingAtOrBefore(entry: Entry<A, E>, seq: number | undefined) {
-      if (entry.pending?._tag === "wake" && seq !== undefined && entry.pending.seq !== undefined && entry.pending.seq > seq)
+      if (
+        entry.pending?._tag === "wake" &&
+        seq !== undefined &&
+        entry.pending.seq !== undefined &&
+        entry.pending.seq > seq
+      )
         return
       entry.pending = undefined
     }

+ 5 - 1
packages/core/test/session-prompt.test.ts

@@ -578,7 +578,11 @@ describe("SessionV2.prompt", () => {
       wakeCalls.length = 0
       wakeSeqs.length = 0
 
-      const admitted = yield* session.prompt({ sessionID, prompt: new Prompt({ text: "Run explicitly" }), resume: true })
+      const admitted = yield* session.prompt({
+        sessionID,
+        prompt: new Prompt({ text: "Run explicitly" }),
+        resume: true,
+      })
 
       expect(executionCalls).toEqual([])
       expect(wakeCalls).toEqual([sessionID])

+ 1 - 3
packages/core/test/session-run-coordinator.test.ts

@@ -325,9 +325,7 @@ describe("SessionRunCoordinator", () => {
           drain: () =>
             Effect.sync(() => ++runs).pipe(
               Effect.flatMap((run) =>
-                run === 1
-                  ? Deferred.succeed(firstStarted, undefined).pipe(Effect.andThen(Effect.never))
-                  : Effect.void,
+                run === 1 ? Deferred.succeed(firstStarted, undefined).pipe(Effect.andThen(Effect.never)) : Effect.void,
               ),
             ),
         })

+ 5 - 1
packages/core/test/session-runner-recorded.test.ts

@@ -81,7 +81,11 @@ const execution = Layer.effect(
   SessionExecution.Service,
   SessionRunCoordinator.Service.pipe(
     Effect.map((coordinator) =>
-      SessionExecution.Service.of({ resume: coordinator.run, wake: coordinator.wake, interrupt: coordinator.interrupt }),
+      SessionExecution.Service.of({
+        resume: coordinator.run,
+        wake: coordinator.wake,
+        interrupt: coordinator.interrupt,
+      }),
     ),
   ),
 ).pipe(Layer.provide(coordinator))

+ 5 - 1
packages/core/test/session-runner.test.ts

@@ -221,7 +221,11 @@ const execution = Layer.effect(
   SessionExecution.Service,
   SessionRunCoordinator.Service.pipe(
     Effect.map((coordinator) =>
-      SessionExecution.Service.of({ resume: coordinator.run, wake: coordinator.wake, interrupt: coordinator.interrupt }),
+      SessionExecution.Service.of({
+        resume: coordinator.run,
+        wake: coordinator.wake,
+        interrupt: coordinator.interrupt,
+      }),
     ),
   ),
 ).pipe(Layer.provide(coordinator))

+ 34 - 0
packages/sdk/js/src/v2/gen/types.gen.ts

@@ -21,6 +21,7 @@ export type Event =
   | EventSessionNextPrompted
   | EventSessionNextPromptAdmitted
   | EventSessionNextPromptPromoted
+  | EventSessionNextInterruptRequested
   | EventSessionNextContextUpdated
   | EventSessionNextSynthetic
   | EventSessionNextShellStarted
@@ -868,6 +869,14 @@ export type GlobalEvent = {
           timeCreated: number
         }
       }
+    | {
+        id: string
+        type: "session.next.interrupt.requested"
+        properties: {
+          timestamp: number
+          sessionID: string
+        }
+      }
     | {
         id: string
         type: "session.next.context.updated"
@@ -1626,6 +1635,7 @@ export type GlobalEvent = {
     | SyncEventSessionNextPrompted
     | SyncEventSessionNextPromptAdmitted
     | SyncEventSessionNextPromptPromoted
+    | SyncEventSessionNextInterruptRequested
     | SyncEventSessionNextContextUpdated
     | SyncEventSessionNextSynthetic
     | SyncEventSessionNextShellStarted
@@ -3271,6 +3281,21 @@ export type SyncEventSessionNextPromptPromoted = {
   }
 }
 
+export type SyncEventSessionNextInterruptRequested = {
+  type: "sync"
+  id: string
+  syncEvent: {
+    type: "session.next.interrupt.requested.1"
+    id: string
+    seq: number
+    aggregateID: string
+    data: {
+      timestamp: number
+      sessionID: string
+    }
+  }
+}
+
 export type SyncEventSessionNextContextUpdated = {
   type: "sync"
   id: string
@@ -4381,6 +4406,15 @@ export type EventSessionNextPromptPromoted = {
   }
 }
 
+export type EventSessionNextInterruptRequested = {
+  id: string
+  type: "session.next.interrupt.requested"
+  properties: {
+    timestamp: number
+    sessionID: string
+  }
+}
+
 export type EventSessionNextContextUpdated = {
   id: string
   type: "session.next.context.updated"

+ 114 - 0
packages/sdk/openapi.json

@@ -12097,6 +12097,9 @@
           {
             "$ref": "#/components/schemas/EventSessionNextPromptPromoted"
           },
+          {
+            "$ref": "#/components/schemas/EventSessionNextInterruptRequested"
+          },
           {
             "$ref": "#/components/schemas/EventSessionNextContextUpdated"
           },
@@ -14695,6 +14698,35 @@
                 "required": ["id", "type", "properties"],
                 "additionalProperties": false
               },
+              {
+                "type": "object",
+                "properties": {
+                  "id": {
+                    "type": "string",
+                    "pattern": "^evt_"
+                  },
+                  "type": {
+                    "type": "string",
+                    "enum": ["session.next.interrupt.requested"]
+                  },
+                  "properties": {
+                    "type": "object",
+                    "properties": {
+                      "timestamp": {
+                        "type": "number"
+                      },
+                      "sessionID": {
+                        "type": "string",
+                        "pattern": "^ses"
+                      }
+                    },
+                    "required": ["timestamp", "sessionID"],
+                    "additionalProperties": false
+                  }
+                },
+                "required": ["id", "type", "properties"],
+                "additionalProperties": false
+              },
               {
                 "type": "object",
                 "properties": {
@@ -17252,6 +17284,9 @@
               {
                 "$ref": "#/components/schemas/SyncEventSessionNextPromptPromoted"
               },
+              {
+                "$ref": "#/components/schemas/SyncEventSessionNextInterruptRequested"
+              },
               {
                 "$ref": "#/components/schemas/SyncEventSessionNextContextUpdated"
               },
@@ -21983,6 +22018,56 @@
         "required": ["type", "id", "syncEvent"],
         "additionalProperties": false
       },
+      "SyncEventSessionNextInterruptRequested": {
+        "type": "object",
+        "properties": {
+          "type": {
+            "type": "string",
+            "enum": ["sync"]
+          },
+          "id": {
+            "type": "string",
+            "pattern": "^evt_"
+          },
+          "syncEvent": {
+            "type": "object",
+            "properties": {
+              "type": {
+                "type": "string",
+                "enum": ["session.next.interrupt.requested.1"]
+              },
+              "id": {
+                "type": "string",
+                "pattern": "^evt_"
+              },
+              "seq": {
+                "type": "number"
+              },
+              "aggregateID": {
+                "type": "string"
+              },
+              "data": {
+                "type": "object",
+                "properties": {
+                  "timestamp": {
+                    "type": "number"
+                  },
+                  "sessionID": {
+                    "type": "string",
+                    "pattern": "^ses"
+                  }
+                },
+                "required": ["timestamp", "sessionID"],
+                "additionalProperties": false
+              }
+            },
+            "required": ["type", "id", "seq", "aggregateID", "data"],
+            "additionalProperties": false
+          }
+        },
+        "required": ["type", "id", "syncEvent"],
+        "additionalProperties": false
+      },
       "SyncEventSessionNextContextUpdated": {
         "type": "object",
         "properties": {
@@ -25378,6 +25463,35 @@
         "required": ["id", "type", "properties"],
         "additionalProperties": false
       },
+      "EventSessionNextInterruptRequested": {
+        "type": "object",
+        "properties": {
+          "id": {
+            "type": "string",
+            "pattern": "^evt_"
+          },
+          "type": {
+            "type": "string",
+            "enum": ["session.next.interrupt.requested"]
+          },
+          "properties": {
+            "type": "object",
+            "properties": {
+              "timestamp": {
+                "type": "number"
+              },
+              "sessionID": {
+                "type": "string",
+                "pattern": "^ses"
+              }
+            },
+            "required": ["timestamp", "sessionID"],
+            "additionalProperties": false
+          }
+        },
+        "required": ["id", "type", "properties"],
+        "additionalProperties": false
+      },
       "EventSessionNextContextUpdated": {
         "type": "object",
         "properties": {