opencode-queue 0.10.0 → 0.10.1
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/index.ts +10 -5
- package/package.json +4 -1
package/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Plugin } from "@opencode-ai/plugin"
|
|
2
2
|
import type { AgentPartInput, FilePart, FilePartInput, SubtaskPartInput, TextPart, TextPartInput } from "@opencode-ai/sdk"
|
|
3
|
+
import { HttpServerResponse } from "effect/unstable/http"
|
|
3
4
|
|
|
4
5
|
const QUEUE = /^\/queue(?:\s+([\s\S]*))?$/
|
|
5
6
|
const SUFFIX = /^([\s\S]*?)\s+\/queue(?:\s+(front))?\s*$/
|
|
6
7
|
const CMD = /^\/(\S+)(?:\s+([\s\S]*))?$/
|
|
7
8
|
const ITEM_NUMBER = /^[1-9]\d*$/
|
|
8
|
-
const HANDLED = "__QUEUE_HANDLED__"
|
|
9
9
|
const TUI_COMPACT = "session_compact"
|
|
10
10
|
|
|
11
11
|
type InputPart = TextPartInput | FilePartInput | AgentPartInput | SubtaskPartInput
|
|
@@ -129,6 +129,11 @@ const control = (op: Op): op is ControlOp => {
|
|
|
129
129
|
const shouldQueue = (state?: State) => Boolean(state && (state.activity.kind !== "idle" || state.stopped))
|
|
130
130
|
const shouldDeclinePlan = (state?: State) => Boolean(state && (state.activity.kind === "sending" || (!state.stopped && state.items.length)))
|
|
131
131
|
const itemText = (item: Item) => (item.kind === "prompt" ? item.body.trim() || item.label : item.source)
|
|
132
|
+
// OpenCode's command hook has no cancel/noReply output. Throwing a raw Effect
|
|
133
|
+
// response is handled by OpenCode's HTTP layer as an empty successful command.
|
|
134
|
+
const handled = (): never => {
|
|
135
|
+
throw HttpServerResponse.empty({ status: 204 })
|
|
136
|
+
}
|
|
132
137
|
const plan = (event: unknown): event is Ask => {
|
|
133
138
|
if (typeof event !== "object" || !event || !("type" in event) || event.type !== "question.asked") return false
|
|
134
139
|
const question = (event as Ask).properties?.questions?.[0]
|
|
@@ -154,7 +159,7 @@ export const QueuePlugin: Plugin = async ({ client }) => {
|
|
|
154
159
|
|
|
155
160
|
const stop = async (message: string, variant: "info" | "error" = "info", duration = 5000): Promise<never> => {
|
|
156
161
|
await toast(message, variant, duration)
|
|
157
|
-
|
|
162
|
+
return handled()
|
|
158
163
|
}
|
|
159
164
|
|
|
160
165
|
const no = async (id: string) => {
|
|
@@ -406,17 +411,17 @@ export const QueuePlugin: Plugin = async ({ client }) => {
|
|
|
406
411
|
if (!shouldQueue(sessions.get(sid))) {
|
|
407
412
|
if (op.kind === "shell") {
|
|
408
413
|
await shell(sid, op.shell, await run(sid))
|
|
409
|
-
|
|
414
|
+
return handled()
|
|
410
415
|
}
|
|
411
416
|
|
|
412
417
|
if (op.kind === "compact") {
|
|
413
418
|
await client.tui.executeCommand({ body: { command: TUI_COMPACT }, throwOnError: true })
|
|
414
|
-
|
|
419
|
+
return handled()
|
|
415
420
|
}
|
|
416
421
|
|
|
417
422
|
if (op.kind === "command") {
|
|
418
423
|
await client.session.command({ path: { id: sid }, body: { command: op.cmd, arguments: op.args, parts } as any })
|
|
419
|
-
|
|
424
|
+
return handled()
|
|
420
425
|
}
|
|
421
426
|
|
|
422
427
|
output.parts.splice(0, output.parts.length, { type: "text", text: op.body } as any, ...parts)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "opencode-queue",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Queue OpenCode prompts and slash commands until the agent is idle",
|
|
7
7
|
"main": "./index.ts",
|
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
"scripts": {
|
|
38
38
|
"typecheck": "tsc --noEmit"
|
|
39
39
|
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"effect": "4.0.0-beta.59"
|
|
42
|
+
},
|
|
40
43
|
"devDependencies": {
|
|
41
44
|
"@opencode-ai/plugin": "^1.14.37",
|
|
42
45
|
"@opencode-ai/sdk": "^1.14.37",
|