@vicoa/opencode 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/dist/index.js CHANGED
@@ -34,6 +34,8 @@ let preferredAgent;
34
34
  // the TUI sent that message with). Used to compute how many agent.cycle
35
35
  // steps are needed to land on a target agent.
36
36
  let tuiCurrentAgent;
37
+ // Track current session status to detect if OpenCode is idle
38
+ let currentSessionStatus;
37
39
  // Track messages that came from the UI (to avoid sending them back)
38
40
  // Keep a simple FIFO buffer of message content
39
41
  const messagesFromUI = [];
@@ -254,6 +256,7 @@ export const VicoaPlugin = async (context) => {
254
256
  client,
255
257
  vicoaClient,
256
258
  currentSessionId,
259
+ currentSessionStatus,
257
260
  getTuiCurrentAgent: () => tuiCurrentAgent,
258
261
  setTuiCurrentAgent: (agent) => {
259
262
  tuiCurrentAgent = agent;
@@ -291,6 +294,8 @@ export const VicoaPlugin = async (context) => {
291
294
  return; // Do NOT forward this message as a prompt
292
295
  }
293
296
  if (await handleSlashCommand(userMessage, client, currentSessionId, vicoaClient)) {
297
+ // After processing a slash command, set status to AWAITING_INPUT
298
+ await vicoaClient.updateStatus('AWAITING_INPUT');
294
299
  return;
295
300
  }
296
301
  // Submit as a prompt via the TUI. Mark it first so the chat.message
@@ -394,6 +399,8 @@ export const VicoaPlugin = async (context) => {
394
399
  }
395
400
  case 'session.status': {
396
401
  const statusType = event.properties.status.type;
402
+ // Track current status for interrupt handling
403
+ currentSessionStatus = statusType;
397
404
  if (statusType === 'busy' || statusType === 'retry') {
398
405
  await vicoaClient.updateStatus('ACTIVE');
399
406
  }
@@ -3,6 +3,7 @@ type ControlCommandContext = {
3
3
  client: any;
4
4
  vicoaClient: VicoaClient;
5
5
  currentSessionId?: string;
6
+ currentSessionStatus?: 'idle' | 'busy' | 'retry';
6
7
  getTuiCurrentAgent: () => string | undefined;
7
8
  setTuiCurrentAgent: (agent: string | undefined) => void;
8
9
  setPreferredAgent: (agent: string | undefined) => void;
@@ -61,7 +61,7 @@ function extractControlPayload(content) {
61
61
  * Handle control commands from Vicoa (matching Claude wrapper pattern)
62
62
  */
63
63
  export async function handleControlCommand(content, context) {
64
- const { client, vicoaClient, currentSessionId, getTuiCurrentAgent, setPreferredAgent, setTuiCurrentAgent } = context;
64
+ const { client, vicoaClient, currentSessionId, currentSessionStatus, getTuiCurrentAgent, setPreferredAgent, setTuiCurrentAgent } = context;
65
65
  // Try to parse as JSON control command
66
66
  try {
67
67
  const controlPayload = extractControlPayload(content);
@@ -74,6 +74,12 @@ export async function handleControlCommand(content, context) {
74
74
  log(client, 'warn', '[Vicoa] Interrupt failed: no active session');
75
75
  return true;
76
76
  }
77
+ // Check if OpenCode is idle
78
+ if (currentSessionStatus === 'idle') {
79
+ await vicoaClient.sendMessage('OpenCode is idle.');
80
+ log(client, 'info', '[Vicoa] OpenCode is already idle, no interrupt needed');
81
+ return true;
82
+ }
77
83
  try {
78
84
  await executeTuiCommand(client, 'session.interrupt');
79
85
  await executeTuiCommand(client, 'session.interrupt');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vicoa/opencode",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "OpenCode plugin for using OpenCode anywhere, on any device with Vicoa",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",