opencode-routines 0.1.1 → 0.1.2

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
@@ -53,6 +53,12 @@ interface Job {
53
53
  lastRunSource?: "manual" | "scheduled";
54
54
  lastRunStatus?: "running" | "success" | "failed";
55
55
  }
56
+ type RoutinePromptClient = {
57
+ session?: {
58
+ prompt?: (input: unknown) => Promise<unknown>;
59
+ };
60
+ };
61
+ export declare function __testSubmitSessionPrompt(client: RoutinePromptClient, sessionID: string, prompt: string): Promise<void>;
56
62
  export declare function __testBuildOpencodeArgs(job: Job): {
57
63
  command: string;
58
64
  args: string[];
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?.prompt;
12968
12978
  if (!send)
12969
12979
  throw new Error("Current opencode client does not expose session.prompt");
12970
- const result = await send({
12971
- path: { sessionID },
12972
- body: { parts: [{ type: "text", text: prompt }] }
12980
+ const result = await send.call(session, {
12981
+ sessionID,
12982
+ 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);
@@ -15378,6 +15389,7 @@ ${logs}`, { job, logPath, logs });
15378
15389
  var src_default = SchedulerPlugin;
15379
15390
  export {
15380
15391
  src_default as default,
15392
+ __testSubmitSessionPrompt,
15381
15393
  __testBuildOpencodeArgs,
15382
15394
  SchedulerPlugin
15383
15395
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-routines",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
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.1.1"
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.1.1"
65
65
  }
66
66
  }