opencode-routines 0.1.1 → 0.1.3

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/README.md CHANGED
@@ -34,16 +34,16 @@ Add the server plugin to your OpenCode config (`~/.config/opencode/opencode.json
34
34
 
35
35
  OpenCode installs the package from npm on next start. Use `@latest` if you want new versions on restart, or pin a version such as `"opencode-routines@0.1.1"`.
36
36
 
37
- Optional TUI slash commands live in a second plugin entrypoint from the same npm package:
37
+ Optional TUI slash commands are published as a companion package:
38
38
 
39
39
  ```jsonc
40
40
  {
41
41
  "$schema": "https://opencode.ai/config.json",
42
- "plugin": ["opencode-routines@latest", "opencode-routines/tui@latest"]
42
+ "plugin": ["opencode-routines@latest", "opencode-routines-tui@latest"]
43
43
  }
44
44
  ```
45
45
 
46
- `opencode-routines/tui` is a subpath export, not a second npm package.
46
+ `opencode-routines-tui` is separate so OpenCode can explicitly install and load the TUI plugin entrypoint. The root package still ships a `./tui` export for advanced/manual loaders, but managed installs should use the companion package.
47
47
 
48
48
  ## What it provides
49
49
 
@@ -131,7 +131,7 @@ Legacy compatibility tools from `opencode-scheduler` are still present: `schedul
131
131
 
132
132
  ## TUI slash commands
133
133
 
134
- Available when `opencode-routines/tui` is installed:
134
+ Available when `opencode-routines-tui` is installed:
135
135
 
136
136
  | Command | Meaning |
137
137
  |---|---|
@@ -163,8 +163,9 @@ Standalone schedule backends:
163
163
 
164
164
  ## Compatibility notes
165
165
 
166
+ - Requires OpenCode `1.17.3` or newer.
166
167
  - OpenCode loads config once at startup. Restart OpenCode after changing plugin configuration.
167
- - `opencode-routines/tui` requires OpenCode's TUI plugin runtime. If your OpenCode build does not support TUI plugins, install only `opencode-routines`.
168
+ - `opencode-routines-tui` requires OpenCode's TUI plugin runtime. If your OpenCode build does not support TUI plugins, install only `opencode-routines`.
168
169
  - `CronCreate({ durable: true })` is accepted for Claude Code compatibility but currently behaves as session-only.
169
170
 
170
171
  ## Debugging
package/dist/index.d.ts CHANGED
@@ -12,50 +12,5 @@
12
12
  * - Environment variable injection (PATH for node/npx)
13
13
  */
14
14
  import type { Plugin } from "@opencode-ai/plugin";
15
- type OpencodeRunFormat = "default" | "json";
16
- interface JobRunSpec {
17
- prompt?: string;
18
- command?: string;
19
- arguments?: string;
20
- files?: string[];
21
- agent?: string;
22
- model?: string;
23
- variant?: string;
24
- title?: string;
25
- share?: boolean;
26
- continue?: boolean;
27
- session?: string;
28
- runFormat?: OpencodeRunFormat;
29
- attachUrl?: string;
30
- port?: number;
31
- }
32
- type JobInvocation = {
33
- command: string;
34
- args: string[];
35
- };
36
- interface Job {
37
- scopeId?: string;
38
- slug: string;
39
- name: string;
40
- schedule: string;
41
- prompt?: string;
42
- attachUrl?: string;
43
- run?: JobRunSpec;
44
- invocation?: JobInvocation;
45
- timeoutSeconds?: number;
46
- source?: string;
47
- workdir?: string;
48
- createdAt: string;
49
- updatedAt?: string;
50
- lastRunAt?: string;
51
- lastRunExitCode?: number;
52
- lastRunError?: string;
53
- lastRunSource?: "manual" | "scheduled";
54
- lastRunStatus?: "running" | "success" | "failed";
55
- }
56
- export declare function __testBuildOpencodeArgs(job: Job): {
57
- command: string;
58
- args: string[];
59
- };
60
15
  export declare const SchedulerPlugin: Plugin;
61
16
  export default SchedulerPlugin;
package/dist/index.js CHANGED
@@ -12963,16 +12963,27 @@ function nextCronRun(cron, after = new Date) {
12963
12963
  }
12964
12964
  throw new Error(`Could not find next run for cron: ${cron}`);
12965
12965
  }
12966
+ function promptResultError(result) {
12967
+ const error45 = result?.error;
12968
+ if (!error45)
12969
+ return;
12970
+ return typeof error45 === "string" ? error45 : JSON.stringify(error45);
12971
+ }
12972
+ async function testSubmitSessionPrompt(client, sessionID, prompt) {
12973
+ await submitSessionPrompt(client, sessionID, prompt);
12974
+ }
12966
12975
  async function submitSessionPrompt(client, sessionID, prompt) {
12967
- const send = client.session?.prompt;
12976
+ const session = client.session;
12977
+ const send = session?.promptAsync;
12968
12978
  if (!send)
12969
- throw new Error("Current opencode client does not expose session.prompt");
12970
- const result = await send({
12971
- path: { sessionID },
12979
+ throw new Error("Current opencode client does not expose session.promptAsync");
12980
+ const result = await send.call(session, {
12981
+ path: { id: sessionID },
12972
12982
  body: { parts: [{ type: "text", text: prompt }] }
12973
12983
  });
12974
- if (result?.error)
12975
- throw new Error(typeof result.error === "string" ? result.error : JSON.stringify(result.error));
12984
+ const error45 = promptResultError(result);
12985
+ if (error45)
12986
+ throw new Error(error45);
12976
12987
  }
12977
12988
  function stopLoop(id) {
12978
12989
  const loop = loops.get(id);
@@ -14171,7 +14182,7 @@ function buildOpencodeArgs(job) {
14171
14182
  args.push(run.command ? run.arguments ?? "" : run.prompt ?? "");
14172
14183
  return { command, args };
14173
14184
  }
14174
- function __testBuildOpencodeArgs(job) {
14185
+ function testBuildOpencodeArgs(job) {
14175
14186
  return buildOpencodeArgs(job);
14176
14187
  }
14177
14188
  function buildRunEnvironment() {
@@ -15375,9 +15386,12 @@ ${logs}`, { job, logPath, logs });
15375
15386
  }
15376
15387
  };
15377
15388
  };
15389
+ SchedulerPlugin.__test = {
15390
+ buildOpencodeArgs: testBuildOpencodeArgs,
15391
+ submitSessionPrompt: testSubmitSessionPrompt
15392
+ };
15378
15393
  var src_default = SchedulerPlugin;
15379
15394
  export {
15380
15395
  src_default as default,
15381
- __testBuildOpencodeArgs,
15382
15396
  SchedulerPlugin
15383
15397
  };
package/dist/tui.d.ts CHANGED
@@ -1,59 +1,4 @@
1
- type TuiApi = {
2
- route: {
3
- current: {
4
- name: string;
5
- params?: Record<string, any>;
6
- };
7
- navigate?: (name: string, params?: Record<string, unknown>) => void;
8
- };
9
- client: {
10
- session: {
11
- prompt: (input: any) => Promise<unknown>;
12
- };
13
- };
14
- ui: {
15
- dialog: {
16
- replace: (render: () => any) => void;
17
- clear: () => void;
18
- };
19
- DialogAlert: (props: {
20
- title: string;
21
- message: string;
22
- }) => any;
23
- DialogPrompt: (props: {
24
- title: string;
25
- placeholder?: string;
26
- onConfirm?: (value: string) => void;
27
- }) => any;
28
- DialogSelect: (props: {
29
- title: string;
30
- options: Array<{
31
- title: string;
32
- value: string;
33
- description?: string;
34
- footer?: string;
35
- }>;
36
- onSelect?: (option: {
37
- value: string;
38
- }) => void;
39
- }) => any;
40
- toast: (input: {
41
- variant?: "info" | "success" | "warning" | "error";
42
- title?: string;
43
- message: string;
44
- }) => void;
45
- };
46
- lifecycle: {
47
- onDispose: (fn: () => void) => void;
48
- };
49
- keymap: {
50
- registerLayer: (input: {
51
- commands: any[];
52
- bindings?: any[];
53
- }) => unknown;
54
- };
55
- };
56
- type TuiPlugin = (api: TuiApi, options?: Record<string, unknown>, meta?: Record<string, unknown>) => Promise<void>;
1
+ import type { TuiPlugin } from "@opencode-ai/plugin/tui";
57
2
  declare const _default: {
58
3
  id: string;
59
4
  tui: TuiPlugin;
package/dist/tui.js CHANGED
@@ -54,11 +54,9 @@ function loopID() {
54
54
  }
55
55
  async function submitPrompt(api, loop) {
56
56
  loop.fires += 1;
57
- await api.client.session.prompt({
58
- path: { sessionID: loop.sessionID },
59
- body: {
60
- parts: [{ type: "text", text: loop.prompt }]
61
- }
57
+ await api.client.session.promptAsync({
58
+ sessionID: loop.sessionID,
59
+ parts: [{ type: "text", text: loop.prompt }]
62
60
  });
63
61
  }
64
62
  function scheduleFixed(api, loop) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-routines",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "OpenCode routines: same-session loops, cron prompts, and host-backed standalone scheduled agents",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -54,13 +54,13 @@
54
54
  },
55
55
  "homepage": "https://github.com/EmilioEsposito/opencode-routines#readme",
56
56
  "dependencies": {
57
- "@opencode-ai/plugin": "^1.0.162"
57
+ "@opencode-ai/plugin": "^1.17.3"
58
58
  },
59
59
  "devDependencies": {
60
60
  "bun-types": "latest",
61
61
  "typescript": "^5.7.3"
62
62
  },
63
63
  "peerDependencies": {
64
- "@opencode-ai/plugin": ">=1.0.0"
64
+ "@opencode-ai/plugin": ">=1.17.3"
65
65
  }
66
66
  }