opencode-orchestrator 0.6.3 → 0.6.5

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.
@@ -6,9 +6,18 @@ export declare const presets: {
6
6
  taskCompleted: (taskId: string, agent: string) => import("./types.js").ToastMessage;
7
7
  taskFailed: (taskId: string, error: string) => import("./types.js").ToastMessage;
8
8
  allTasksComplete: (count: number) => import("./types.js").ToastMessage;
9
+ sessionCreated: (sessionId: string, agent: string) => import("./types.js").ToastMessage;
10
+ sessionResumed: (sessionId: string, agent: string) => import("./types.js").ToastMessage;
11
+ sessionCompleted: (sessionId: string, duration: string) => import("./types.js").ToastMessage;
12
+ parallelTasksLaunched: (count: number, agents: string[]) => import("./types.js").ToastMessage;
13
+ concurrencyAcquired: (agent: string, slot: string) => import("./types.js").ToastMessage;
14
+ concurrencyReleased: (agent: string) => import("./types.js").ToastMessage;
9
15
  missionComplete: (summary: string) => import("./types.js").ToastMessage;
16
+ missionStarted: (description: string) => import("./types.js").ToastMessage;
17
+ toolExecuted: (toolName: string, target: string) => import("./types.js").ToastMessage;
10
18
  documentCached: (filename: string) => import("./types.js").ToastMessage;
11
19
  researchStarted: (topic: string) => import("./types.js").ToastMessage;
12
20
  warningRateLimited: () => import("./types.js").ToastMessage;
13
21
  errorRecovery: (action: string) => import("./types.js").ToastMessage;
22
+ warningMaxDepth: (depth: number) => import("./types.js").ToastMessage;
14
23
  };
@@ -1,13 +1,20 @@
1
1
  /**
2
2
  * Toast Core - Core notification functions
3
+ * Uses OpenCode TUI's showToast API for actual UI display
3
4
  */
4
5
  import type { ToastMessage, ToastOptions } from "./types.js";
6
+ import type { PluginInput } from "@opencode-ai/plugin";
7
+ type OpencodeClient = PluginInput["client"];
8
+ /**
9
+ * Initialize the toast system with the OpenCode client
10
+ */
11
+ export declare function initToastClient(client: OpencodeClient): void;
5
12
  /**
6
13
  * Register a notification handler
7
14
  */
8
15
  export declare function onToast(handler: (toast: ToastMessage) => void): () => void;
9
16
  /**
10
- * Show a toast notification
17
+ * Show a toast notification (both in TUI and internal storage)
11
18
  */
12
19
  export declare function show(options: ToastOptions): ToastMessage;
13
20
  /**
@@ -26,3 +33,4 @@ export declare function getHistory(limit?: number): ToastMessage[];
26
33
  * Clear all toasts
27
34
  */
28
35
  export declare function clear(): void;
36
+ export {};
@@ -4,6 +4,6 @@
4
4
  * Provides notifications for task events, completions, errors
5
5
  */
6
6
  export type { ToastVariant, ToastMessage, ToastOptions } from "./types.js";
7
- export { show, dismiss, getActive, getHistory, clear, onToast } from "./toast-core.js";
7
+ export { show, dismiss, getActive, getHistory, clear, onToast, initToastClient } from "./toast-core.js";
8
8
  export { presets } from "./presets.js";
9
9
  export { enableAutoToasts } from "./event-integration.js";
package/dist/index.js CHANGED
@@ -14290,6 +14290,182 @@ Use \`get_task_result({ taskId: "task_xxx" })\` to retrieve results.
14290
14290
  </system-notification>`;
14291
14291
  }
14292
14292
 
14293
+ // src/core/notification/toast-core.ts
14294
+ var tuiClient = null;
14295
+ function initToastClient(client) {
14296
+ tuiClient = client;
14297
+ }
14298
+ var toasts = [];
14299
+ var MAX_HISTORY = 50;
14300
+ var handlers = [];
14301
+ function show(options) {
14302
+ const toast = {
14303
+ id: `toast_${Date.now()}_${Math.random().toString(36).slice(2, 6)}`,
14304
+ title: options.title,
14305
+ message: options.message,
14306
+ variant: options.variant || "info",
14307
+ timestamp: /* @__PURE__ */ new Date(),
14308
+ duration: options.duration ?? 5e3,
14309
+ dismissed: false
14310
+ };
14311
+ toasts.push(toast);
14312
+ if (toasts.length > MAX_HISTORY) {
14313
+ toasts.shift();
14314
+ }
14315
+ for (const handler of handlers) {
14316
+ try {
14317
+ handler(toast);
14318
+ } catch (error45) {
14319
+ }
14320
+ }
14321
+ if (tuiClient) {
14322
+ const client = tuiClient;
14323
+ if (client.tui?.showToast) {
14324
+ client.tui.showToast({
14325
+ body: {
14326
+ title: toast.title,
14327
+ message: toast.message,
14328
+ variant: toast.variant,
14329
+ duration: toast.duration
14330
+ }
14331
+ }).catch(() => {
14332
+ });
14333
+ }
14334
+ }
14335
+ return toast;
14336
+ }
14337
+
14338
+ // src/core/notification/presets.ts
14339
+ var presets = {
14340
+ // =========================================
14341
+ // Task Lifecycle
14342
+ // =========================================
14343
+ taskStarted: (taskId, agent) => show({
14344
+ title: "\u26A1 Task Started",
14345
+ message: `${agent}: ${taskId}`,
14346
+ variant: "info",
14347
+ duration: 3e3
14348
+ }),
14349
+ taskCompleted: (taskId, agent) => show({
14350
+ title: "\u2705 Task Completed",
14351
+ message: `${agent}: ${taskId}`,
14352
+ variant: "success",
14353
+ duration: 3e3
14354
+ }),
14355
+ taskFailed: (taskId, error45) => show({
14356
+ title: "\u274C Task Failed",
14357
+ message: `${taskId}: ${error45}`,
14358
+ variant: "error",
14359
+ duration: 0
14360
+ // Persistent
14361
+ }),
14362
+ allTasksComplete: (count) => show({
14363
+ title: "\u{1F389} All Tasks Complete",
14364
+ message: `${count} tasks finished successfully`,
14365
+ variant: "success",
14366
+ duration: 5e3
14367
+ }),
14368
+ // =========================================
14369
+ // Session Management
14370
+ // =========================================
14371
+ sessionCreated: (sessionId, agent) => show({
14372
+ title: "\u{1F4CC} Session Created",
14373
+ message: `${agent} \u2192 ${sessionId.slice(0, 12)}...`,
14374
+ variant: "info",
14375
+ duration: 2e3
14376
+ }),
14377
+ sessionResumed: (sessionId, agent) => show({
14378
+ title: "\u{1F504} Session Resumed",
14379
+ message: `${agent} \u2192 ${sessionId.slice(0, 12)}...`,
14380
+ variant: "info",
14381
+ duration: 2e3
14382
+ }),
14383
+ sessionCompleted: (sessionId, duration3) => show({
14384
+ title: "\u2705 Session Completed",
14385
+ message: `${sessionId.slice(0, 12)}... (${duration3})`,
14386
+ variant: "success",
14387
+ duration: 3e3
14388
+ }),
14389
+ // =========================================
14390
+ // Parallel Processing
14391
+ // =========================================
14392
+ parallelTasksLaunched: (count, agents) => show({
14393
+ title: "\u{1F680} Parallel Tasks Launched",
14394
+ message: `${count} tasks: ${agents.join(", ")}`,
14395
+ variant: "info",
14396
+ duration: 4e3
14397
+ }),
14398
+ concurrencyAcquired: (agent, slot) => show({
14399
+ title: "\u{1F512} Concurrency Slot",
14400
+ message: `${agent} acquired ${slot}`,
14401
+ variant: "info",
14402
+ duration: 2e3
14403
+ }),
14404
+ concurrencyReleased: (agent) => show({
14405
+ title: "\u{1F513} Slot Released",
14406
+ message: agent,
14407
+ variant: "info",
14408
+ duration: 1500
14409
+ }),
14410
+ // =========================================
14411
+ // Mission & Progress
14412
+ // =========================================
14413
+ missionComplete: (summary) => show({
14414
+ title: "\u{1F389} Mission Complete",
14415
+ message: summary,
14416
+ variant: "success",
14417
+ duration: 0
14418
+ }),
14419
+ missionStarted: (description) => show({
14420
+ title: "\u{1F3AF} Mission Started",
14421
+ message: description.slice(0, 100),
14422
+ variant: "info",
14423
+ duration: 4e3
14424
+ }),
14425
+ // =========================================
14426
+ // Tools & Research
14427
+ // =========================================
14428
+ toolExecuted: (toolName, target) => show({
14429
+ title: `\u{1F527} ${toolName}`,
14430
+ message: target.slice(0, 80),
14431
+ variant: "info",
14432
+ duration: 2e3
14433
+ }),
14434
+ documentCached: (filename) => show({
14435
+ title: "\u{1F4C4} Document Cached",
14436
+ message: `.cache/docs/${filename}`,
14437
+ variant: "info",
14438
+ duration: 2e3
14439
+ }),
14440
+ researchStarted: (topic) => show({
14441
+ title: "\u{1F52C} Research Started",
14442
+ message: topic,
14443
+ variant: "info",
14444
+ duration: 3e3
14445
+ }),
14446
+ // =========================================
14447
+ // Warnings & Errors
14448
+ // =========================================
14449
+ warningRateLimited: () => show({
14450
+ title: "\u26A0\uFE0F Rate Limited",
14451
+ message: "Waiting before retry...",
14452
+ variant: "warning",
14453
+ duration: 5e3
14454
+ }),
14455
+ errorRecovery: (action) => show({
14456
+ title: "\u26A0\uFE0F Error Recovery",
14457
+ message: `Attempting: ${action}`,
14458
+ variant: "warning",
14459
+ duration: 3e3
14460
+ }),
14461
+ warningMaxDepth: (depth) => show({
14462
+ title: "\u26A0\uFE0F Max Depth Reached",
14463
+ message: `Recursion blocked at depth ${depth}`,
14464
+ variant: "warning",
14465
+ duration: 5e3
14466
+ })
14467
+ };
14468
+
14293
14469
  // src/core/agents/manager/task-launcher.ts
14294
14470
  var TaskLauncher = class {
14295
14471
  constructor(client, directory, store, concurrency, onTaskError, startPolling) {
@@ -14350,6 +14526,7 @@ var TaskLauncher = class {
14350
14526
  log2(`Prompt error for ${taskId}:`, error45);
14351
14527
  this.onTaskError(taskId, error45);
14352
14528
  });
14529
+ presets.sessionCreated(sessionID, input.agent);
14353
14530
  log2(`Launched ${taskId} in session ${sessionID}`);
14354
14531
  return task;
14355
14532
  } catch (error45) {
@@ -14495,7 +14672,9 @@ var TaskPoller = class {
14495
14672
  this.store.queueNotification(task);
14496
14673
  await this.notifyParentIfAllComplete(task.parentSessionID);
14497
14674
  this.scheduleCleanup(task.id);
14498
- log2(`Completed ${task.id} (${formatDuration(task.startedAt, task.completedAt)})`);
14675
+ const duration3 = formatDuration(task.startedAt, task.completedAt);
14676
+ presets.sessionCompleted(task.sessionID, duration3);
14677
+ log2(`Completed ${task.id} (${duration3})`);
14499
14678
  }
14500
14679
  async updateTaskProgress(task) {
14501
14680
  try {
@@ -16136,95 +16315,6 @@ ${r.content}
16136
16315
  }
16137
16316
  });
16138
16317
 
16139
- // src/core/notification/toast-core.ts
16140
- var toasts = [];
16141
- var MAX_HISTORY = 50;
16142
- var handlers = [];
16143
- function show(options) {
16144
- const toast = {
16145
- id: `toast_${Date.now()}_${Math.random().toString(36).slice(2, 6)}`,
16146
- title: options.title,
16147
- message: options.message,
16148
- variant: options.variant || "info",
16149
- timestamp: /* @__PURE__ */ new Date(),
16150
- duration: options.duration ?? 5e3,
16151
- dismissed: false
16152
- };
16153
- toasts.push(toast);
16154
- if (toasts.length > MAX_HISTORY) {
16155
- toasts.shift();
16156
- }
16157
- for (const handler of handlers) {
16158
- try {
16159
- handler(toast);
16160
- } catch (error45) {
16161
- console.error("[Toast] Handler error:", error45);
16162
- }
16163
- }
16164
- const icons = { info: "\u2139\uFE0F", success: "\u2705", warning: "\u26A0\uFE0F", error: "\u274C" };
16165
- console.log(`${icons[toast.variant]} [${toast.title}] ${toast.message}`);
16166
- return toast;
16167
- }
16168
-
16169
- // src/core/notification/presets.ts
16170
- var presets = {
16171
- taskStarted: (taskId, agent) => show({
16172
- title: "Task Started",
16173
- message: `${agent}: ${taskId}`,
16174
- variant: "info",
16175
- duration: 3e3
16176
- }),
16177
- taskCompleted: (taskId, agent) => show({
16178
- title: "Task Completed",
16179
- message: `${agent}: ${taskId}`,
16180
- variant: "success",
16181
- duration: 3e3
16182
- }),
16183
- taskFailed: (taskId, error45) => show({
16184
- title: "Task Failed",
16185
- message: `${taskId}: ${error45}`,
16186
- variant: "error",
16187
- duration: 0
16188
- // Persistent
16189
- }),
16190
- allTasksComplete: (count) => show({
16191
- title: "All Tasks Complete",
16192
- message: `${count} tasks finished successfully`,
16193
- variant: "success",
16194
- duration: 5e3
16195
- }),
16196
- missionComplete: (summary) => show({
16197
- title: "\u{1F389} Mission Complete",
16198
- message: summary,
16199
- variant: "success",
16200
- duration: 0
16201
- }),
16202
- documentCached: (filename) => show({
16203
- title: "Document Cached",
16204
- message: `.cache/docs/${filename}`,
16205
- variant: "info",
16206
- duration: 2e3
16207
- }),
16208
- researchStarted: (topic) => show({
16209
- title: "Research Started",
16210
- message: topic,
16211
- variant: "info",
16212
- duration: 3e3
16213
- }),
16214
- warningRateLimited: () => show({
16215
- title: "Rate Limited",
16216
- message: "Waiting before retry...",
16217
- variant: "warning",
16218
- duration: 5e3
16219
- }),
16220
- errorRecovery: (action) => show({
16221
- title: "Error Recovery",
16222
- message: `Attempting: ${action}`,
16223
- variant: "warning",
16224
- duration: 3e3
16225
- })
16226
- };
16227
-
16228
16318
  // src/core/notification/event-integration.ts
16229
16319
  function enableAutoToasts() {
16230
16320
  const unsubscribers = [];
@@ -16379,8 +16469,9 @@ var OrchestratorPlugin = async (input) => {
16379
16469
  console.log(`[orchestrator] v${PLUGIN_VERSION} loaded`);
16380
16470
  console.log(`[orchestrator] Log file: ${getLogPath()}`);
16381
16471
  log2("[index.ts] Plugin initialized", { version: PLUGIN_VERSION, directory });
16472
+ initToastClient(client);
16382
16473
  const disableAutoToasts = enableAutoToasts();
16383
- log2("[index.ts] Toast notifications enabled");
16474
+ log2("[index.ts] Toast notifications enabled with TUI");
16384
16475
  const sessions = /* @__PURE__ */ new Map();
16385
16476
  const parallelAgentManager2 = ParallelAgentManager.getInstance(client, directory);
16386
16477
  const asyncAgentTools = createAsyncAgentTools(parallelAgentManager2, client);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "opencode-orchestrator",
3
3
  "displayName": "OpenCode Orchestrator",
4
4
  "description": "Distributed Cognitive Architecture for OpenCode. Turns simple prompts into specialized multi-agent workflows (Planner, Coder, Reviewer).",
5
- "version": "0.6.3",
5
+ "version": "0.6.5",
6
6
  "author": "agnusdei1207",
7
7
  "license": "MIT",
8
8
  "repository": {