opencode-orchestrator 0.6.20 → 0.6.21

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,4 +6,3 @@
6
6
  export type { ToastVariant, ToastMessage, ToastOptions } from "./types.js";
7
7
  export { show, dismiss, getActive, getHistory, clear, onToast, initToastClient } from "./toast-core.js";
8
8
  export { presets } from "./presets.js";
9
- export { enableAutoToasts } from "./event-integration.js";
package/dist/index.js CHANGED
@@ -545,11 +545,22 @@ Blocked: [if any]
545
545
  </context_format>
546
546
 
547
547
  <summarization>
548
- When context gets long:
549
- 1. Create .opencode/summary.md
550
- 2. Keep key decisions, file changes
551
- 3. Remove verbose details
552
- 4. Team references summary instead
548
+ CRITICAL: Prevent .opencode/ from growing too large!
549
+
550
+ AFTER EVERY MAJOR UPDATE:
551
+ 1. Check file sizes in .opencode/
552
+ 2. If context.md > 200 lines \u2192 SUMMARIZE NOW
553
+
554
+ SUMMARIZE:
555
+ - Create/update .opencode/summary.md
556
+ - Keep: key decisions, file changes, blockers
557
+ - Remove: verbose logs, old iterations
558
+ - Team reads summary, not full history
559
+
560
+ CLEANUP OLD:
561
+ - Archive old context to .opencode/archive/
562
+ - Delete temporary notes
563
+ - Keep only current state
553
564
  </summarization>
554
565
 
555
566
  <output>
@@ -14466,180 +14477,11 @@ var TaskCleaner = class {
14466
14477
  }
14467
14478
  };
14468
14479
 
14469
- // src/shared/event-types.ts
14470
- var TASK_EVENTS = {
14471
- STARTED: "task.started",
14472
- COMPLETED: "task.completed",
14473
- FAILED: "task.failed",
14474
- CANCELLED: "task.cancelled"
14475
- };
14476
- var TODO_EVENTS = {
14477
- CREATED: "todo.created",
14478
- UPDATED: "todo.updated",
14479
- COMPLETED: "todo.completed"
14480
- };
14480
+ // src/core/agents/manager/event-handler.ts
14481
14481
  var SESSION_EVENTS = {
14482
14482
  IDLE: "session.idle",
14483
- BUSY: "session.busy",
14484
- ERROR: "session.error",
14485
14483
  DELETED: "session.deleted"
14486
14484
  };
14487
- var DOCUMENT_EVENTS = {
14488
- CACHED: "document.cached",
14489
- EXPIRED: "document.expired"
14490
- };
14491
- var MISSION_EVENTS = {
14492
- COMPLETE: "mission.complete",
14493
- FAILED: "mission.failed",
14494
- ALL_TASKS_COMPLETE: "all_tasks.complete"
14495
- };
14496
- var SPECIAL_EVENTS = {
14497
- WILDCARD: "*"
14498
- };
14499
- var EVENT_TYPES = {
14500
- ...TASK_EVENTS,
14501
- ...TODO_EVENTS,
14502
- ...SESSION_EVENTS,
14503
- ...DOCUMENT_EVENTS,
14504
- ...MISSION_EVENTS,
14505
- ...SPECIAL_EVENTS
14506
- };
14507
-
14508
- // src/core/bus/event-bus.ts
14509
- var EventBusImpl = class {
14510
- subscriptions = /* @__PURE__ */ new Map();
14511
- eventHistory = [];
14512
- maxHistorySize = 100;
14513
- subscriptionCounter = 0;
14514
- /**
14515
- * Subscribe to an event type
14516
- * Returns unsubscribe function
14517
- */
14518
- subscribe(type, handler) {
14519
- const id = `sub_${++this.subscriptionCounter}`;
14520
- const subscription = { id, type, handler, once: false };
14521
- const existing = this.subscriptions.get(type) || [];
14522
- existing.push(subscription);
14523
- this.subscriptions.set(type, existing);
14524
- return () => this.unsubscribe(id, type);
14525
- }
14526
- /**
14527
- * Subscribe to an event type, auto-unsubscribe after first event
14528
- */
14529
- once(type, handler) {
14530
- const id = `sub_${++this.subscriptionCounter}`;
14531
- const subscription = { id, type, handler, once: true };
14532
- const existing = this.subscriptions.get(type) || [];
14533
- existing.push(subscription);
14534
- this.subscriptions.set(type, existing);
14535
- return () => this.unsubscribe(id, type);
14536
- }
14537
- /**
14538
- * Unsubscribe from an event
14539
- */
14540
- unsubscribe(id, type) {
14541
- const subs = this.subscriptions.get(type);
14542
- if (subs) {
14543
- const filtered = subs.filter((s) => s.id !== id);
14544
- if (filtered.length > 0) {
14545
- this.subscriptions.set(type, filtered);
14546
- } else {
14547
- this.subscriptions.delete(type);
14548
- }
14549
- }
14550
- }
14551
- /**
14552
- * Publish an event
14553
- */
14554
- async publish(type, properties = {}, options = {}) {
14555
- const event = {
14556
- type,
14557
- timestamp: /* @__PURE__ */ new Date(),
14558
- source: options.source || "unknown",
14559
- sessionId: options.sessionId,
14560
- properties
14561
- };
14562
- this.eventHistory.push(event);
14563
- if (this.eventHistory.length > this.maxHistorySize) {
14564
- this.eventHistory.shift();
14565
- }
14566
- const toNotify = [];
14567
- const typeSubs = this.subscriptions.get(type) || [];
14568
- toNotify.push(...typeSubs);
14569
- const wildcardSubs = this.subscriptions.get(SPECIAL_EVENTS.WILDCARD) || [];
14570
- toNotify.push(...wildcardSubs);
14571
- const toRemove = [];
14572
- for (const sub of toNotify) {
14573
- try {
14574
- await sub.handler(event);
14575
- } catch (error45) {
14576
- console.error(`[EventBus] Handler error for ${type}:`, error45);
14577
- }
14578
- if (sub.once) {
14579
- toRemove.push({ id: sub.id, type: sub.type });
14580
- }
14581
- }
14582
- for (const { id, type: t } of toRemove) {
14583
- this.unsubscribe(id, t);
14584
- }
14585
- }
14586
- /**
14587
- * Emit (alias for publish, sync-looking API)
14588
- */
14589
- emit(type, properties = {}) {
14590
- this.publish(type, properties).catch(console.error);
14591
- }
14592
- /**
14593
- * Get recent event history
14594
- */
14595
- getHistory(type, limit = 20) {
14596
- let events = this.eventHistory;
14597
- if (type && type !== SPECIAL_EVENTS.WILDCARD) {
14598
- events = events.filter((e) => e.type === type);
14599
- }
14600
- return events.slice(-limit);
14601
- }
14602
- /**
14603
- * Clear all subscriptions
14604
- */
14605
- clear() {
14606
- this.subscriptions.clear();
14607
- this.eventHistory = [];
14608
- }
14609
- /**
14610
- * Get subscription count
14611
- */
14612
- getSubscriptionCount() {
14613
- let count = 0;
14614
- for (const subs of this.subscriptions.values()) {
14615
- count += subs.length;
14616
- }
14617
- return count;
14618
- }
14619
- /**
14620
- * Wait for a specific event (Promise-based)
14621
- */
14622
- waitFor(type, timeout = 3e4) {
14623
- return new Promise((resolve, reject) => {
14624
- const timer = setTimeout(() => {
14625
- unsubscribe();
14626
- reject(new Error(`Timeout waiting for event: ${type}`));
14627
- }, timeout);
14628
- const unsubscribe = this.once(type, (event) => {
14629
- clearTimeout(timer);
14630
- resolve(event);
14631
- });
14632
- });
14633
- }
14634
- };
14635
-
14636
- // src/core/bus/index.ts
14637
- var EventBus = new EventBusImpl();
14638
- function emit(type, properties) {
14639
- EventBus.emit(type, properties);
14640
- }
14641
-
14642
- // src/core/agents/manager/event-handler.ts
14643
14485
  var EventHandler = class {
14644
14486
  constructor(client, store, concurrency, findBySession, notifyParentIfAllComplete, scheduleCleanup, validateSessionHasOutput) {
14645
14487
  this.client = client;
@@ -16009,40 +15851,6 @@ ${r.content}
16009
15851
  }
16010
15852
  });
16011
15853
 
16012
- // src/core/notification/event-integration.ts
16013
- function enableAutoToasts() {
16014
- const unsubscribers = [];
16015
- unsubscribers.push(EventBus.subscribe(TASK_EVENTS.STARTED, (event) => {
16016
- const { taskId, agent } = event.properties;
16017
- presets.taskStarted(taskId, agent);
16018
- }));
16019
- unsubscribers.push(EventBus.subscribe(TASK_EVENTS.COMPLETED, (event) => {
16020
- const { taskId, agent } = event.properties;
16021
- presets.taskCompleted(taskId, agent);
16022
- }));
16023
- unsubscribers.push(EventBus.subscribe(TASK_EVENTS.FAILED, (event) => {
16024
- const { taskId, error: error45 } = event.properties;
16025
- presets.taskFailed(taskId, error45);
16026
- }));
16027
- unsubscribers.push(EventBus.subscribe(MISSION_EVENTS.ALL_TASKS_COMPLETE, (event) => {
16028
- const { count } = event.properties;
16029
- presets.allTasksComplete(count);
16030
- }));
16031
- unsubscribers.push(EventBus.subscribe(MISSION_EVENTS.COMPLETE, (event) => {
16032
- const { summary } = event.properties;
16033
- presets.missionComplete(summary);
16034
- }));
16035
- unsubscribers.push(EventBus.subscribe(DOCUMENT_EVENTS.CACHED, (event) => {
16036
- const { filename } = event.properties;
16037
- presets.documentCached(filename);
16038
- }));
16039
- return () => {
16040
- for (const unsub of unsubscribers) {
16041
- unsub();
16042
- }
16043
- };
16044
- }
16045
-
16046
15854
  // src/core/progress/store.ts
16047
15855
  var progressHistory = /* @__PURE__ */ new Map();
16048
15856
  var sessionStartTimes = /* @__PURE__ */ new Map();
@@ -16164,7 +15972,6 @@ var OrchestratorPlugin = async (input) => {
16164
15972
  console.log(`[orchestrator] Log file: ${getLogPath()}`);
16165
15973
  log2("[index.ts] Plugin initialized", { version: PLUGIN_VERSION, directory });
16166
15974
  initToastClient(client);
16167
- const disableAutoToasts = enableAutoToasts();
16168
15975
  log2("[index.ts] Toast notifications enabled with TUI");
16169
15976
  const sessions = /* @__PURE__ */ new Map();
16170
15977
  const parallelAgentManager2 = ParallelAgentManager.getInstance(client, directory);
@@ -16307,7 +16114,7 @@ var OrchestratorPlugin = async (input) => {
16307
16114
  log2("[index.ts] event: session.created", { sessionID });
16308
16115
  presets.missionStarted(`Session ${sessionID.slice(0, 12)}...`);
16309
16116
  }
16310
- if (event.type === "session.deleted" || event.type === SESSION_EVENTS.DELETED) {
16117
+ if (event.type === "session.deleted") {
16311
16118
  const sessionID = event.properties?.id || event.properties?.info?.id || "";
16312
16119
  const session = sessions.get(sessionID);
16313
16120
  if (session) {
@@ -16364,11 +16171,7 @@ var OrchestratorPlugin = async (input) => {
16364
16171
  anomalyCount: 0
16365
16172
  });
16366
16173
  startSession(sessionID);
16367
- emit(TASK_EVENTS.STARTED, {
16368
- taskId: sessionID,
16369
- agent: AGENT_NAMES.COMMANDER,
16370
- description: "Mission started"
16371
- });
16174
+ presets.taskStarted(sessionID, AGENT_NAMES.COMMANDER);
16372
16175
  }
16373
16176
  if (!parsed || parsed.command !== "task") {
16374
16177
  const taskTemplate = COMMANDS["task"].template;
@@ -16527,10 +16330,7 @@ Anomaly count: ${stateSession.anomalyCount}
16527
16330
  if (textContent.includes(MISSION.COMPLETE) || textContent.includes(MISSION.COMPLETE_TEXT)) {
16528
16331
  session.active = false;
16529
16332
  state.missionActive = false;
16530
- emit(MISSION_EVENTS.COMPLETE, {
16531
- sessionId: sessionID,
16532
- summary: "Mission completed successfully"
16533
- });
16333
+ presets.missionComplete("Mission completed successfully");
16534
16334
  clearSession(sessionID);
16535
16335
  sessions.delete(sessionID);
16536
16336
  state.sessions.delete(sessionID);
@@ -16539,10 +16339,7 @@ Anomaly count: ${stateSession.anomalyCount}
16539
16339
  if (textContent.includes(MISSION.STOP_COMMAND) || textContent.includes(MISSION.CANCEL_COMMAND)) {
16540
16340
  session.active = false;
16541
16341
  state.missionActive = false;
16542
- emit(TASK_EVENTS.FAILED, {
16543
- taskId: sessionID,
16544
- error: "Cancelled by user"
16545
- });
16342
+ presets.taskFailed(sessionID, "Cancelled by user");
16546
16343
  clearSession(sessionID);
16547
16344
  sessions.delete(sessionID);
16548
16345
  state.sessions.delete(sessionID);
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.20",
5
+ "version": "0.6.21",
6
6
  "author": "agnusdei1207",
7
7
  "license": "MIT",
8
8
  "repository": {
@@ -1,53 +0,0 @@
1
- /**
2
- * Event Bus Implementation
3
- *
4
- * Core pub/sub system for communication between sessions and agents
5
- */
6
- import type { EventType } from "./types.js";
7
- import type { BusEvent, EventHandler } from "./interfaces.js";
8
- export declare class EventBusImpl {
9
- private subscriptions;
10
- private eventHistory;
11
- private maxHistorySize;
12
- private subscriptionCounter;
13
- /**
14
- * Subscribe to an event type
15
- * Returns unsubscribe function
16
- */
17
- subscribe(type: EventType, handler: EventHandler): () => void;
18
- /**
19
- * Subscribe to an event type, auto-unsubscribe after first event
20
- */
21
- once(type: EventType, handler: EventHandler): () => void;
22
- /**
23
- * Unsubscribe from an event
24
- */
25
- private unsubscribe;
26
- /**
27
- * Publish an event
28
- */
29
- publish(type: EventType, properties?: Record<string, unknown>, options?: {
30
- source?: string;
31
- sessionId?: string;
32
- }): Promise<void>;
33
- /**
34
- * Emit (alias for publish, sync-looking API)
35
- */
36
- emit(type: EventType, properties?: Record<string, unknown>): void;
37
- /**
38
- * Get recent event history
39
- */
40
- getHistory(type?: EventType, limit?: number): BusEvent[];
41
- /**
42
- * Clear all subscriptions
43
- */
44
- clear(): void;
45
- /**
46
- * Get subscription count
47
- */
48
- getSubscriptionCount(): number;
49
- /**
50
- * Wait for a specific event (Promise-based)
51
- */
52
- waitFor(type: EventType, timeout?: number): Promise<BusEvent>;
53
- }
@@ -1,19 +0,0 @@
1
- /**
2
- * Event Bus System
3
- *
4
- * Pub/Sub system for communication between sessions and agents
5
- * Enables loose coupling and async event handling
6
- */
7
- export type { EventType, EventProperties } from "./types.js";
8
- export type { BusEvent, EventHandler, Subscription, PublishOptions } from "./interfaces.js";
9
- export { EVENT_TYPES, TASK_EVENTS, TODO_EVENTS, SESSION_EVENTS, DOCUMENT_EVENTS, MISSION_EVENTS, SPECIAL_EVENTS, } from "../../shared/event-types.js";
10
- import { EventBusImpl } from "./event-bus.js";
11
- import type { EventType, EventProperties } from "./types.js";
12
- import type { EventHandler } from "./interfaces.js";
13
- export declare const EventBus: EventBusImpl;
14
- export declare function subscribe(type: EventType, handler: EventHandler): () => void;
15
- export declare function publish(type: EventType, properties?: EventProperties, options?: {
16
- source?: string;
17
- sessionId?: string;
18
- }): Promise<void>;
19
- export declare function emit(type: EventType, properties?: EventProperties): void;
@@ -1,34 +0,0 @@
1
- /**
2
- * Event Bus Interfaces
3
- */
4
- import type { EventType, EventProperties } from "./types.js";
5
- /**
6
- * Event payload structure
7
- */
8
- export interface BusEvent {
9
- type: EventType;
10
- timestamp: Date;
11
- source: string;
12
- sessionId?: string;
13
- properties: EventProperties;
14
- }
15
- /**
16
- * Event handler function signature
17
- */
18
- export type EventHandler = (event: BusEvent) => void | Promise<void>;
19
- /**
20
- * Internal subscription record
21
- */
22
- export interface Subscription {
23
- id: string;
24
- type: EventType;
25
- handler: EventHandler;
26
- once: boolean;
27
- }
28
- /**
29
- * Publish options
30
- */
31
- export interface PublishOptions {
32
- source?: string;
33
- sessionId?: string;
34
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * Event Bus Types (Type Aliases Only)
3
- */
4
- import type { EventTypeValue } from "../../shared/event-types.js";
5
- /**
6
- * Event type - allows constants or custom strings
7
- */
8
- export type EventType = EventTypeValue | (string & {});
9
- /**
10
- * Properties payload for events
11
- */
12
- export type EventProperties = Record<string, unknown>;
@@ -1,7 +0,0 @@
1
- /**
2
- * Event Bus Integration - Auto-subscribe to events
3
- */
4
- /**
5
- * Auto-subscribe to events and show toasts
6
- */
7
- export declare function enableAutoToasts(): () => void;