@agentuity/opencode 0.1.41 → 0.1.43

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.
Files changed (51) hide show
  1. package/README.md +3 -10
  2. package/dist/agents/lead.d.ts +1 -1
  3. package/dist/agents/lead.d.ts.map +1 -1
  4. package/dist/agents/lead.js +2 -3
  5. package/dist/agents/lead.js.map +1 -1
  6. package/dist/background/manager.d.ts +1 -0
  7. package/dist/background/manager.d.ts.map +1 -1
  8. package/dist/background/manager.js +6 -0
  9. package/dist/background/manager.js.map +1 -1
  10. package/dist/plugin/hooks/cadence.d.ts.map +1 -1
  11. package/dist/plugin/hooks/cadence.js +3 -1
  12. package/dist/plugin/hooks/cadence.js.map +1 -1
  13. package/dist/plugin/plugin.d.ts.map +1 -1
  14. package/dist/plugin/plugin.js +54 -11
  15. package/dist/plugin/plugin.js.map +1 -1
  16. package/dist/skills/frontmatter.js +1 -1
  17. package/dist/skills/frontmatter.js.map +1 -1
  18. package/dist/tmux/executor.d.ts +57 -6
  19. package/dist/tmux/executor.d.ts.map +1 -1
  20. package/dist/tmux/executor.js +676 -57
  21. package/dist/tmux/executor.js.map +1 -1
  22. package/dist/tmux/index.d.ts +1 -1
  23. package/dist/tmux/index.d.ts.map +1 -1
  24. package/dist/tmux/index.js +1 -1
  25. package/dist/tmux/index.js.map +1 -1
  26. package/dist/tmux/manager.d.ts +70 -0
  27. package/dist/tmux/manager.d.ts.map +1 -1
  28. package/dist/tmux/manager.js +357 -22
  29. package/dist/tmux/manager.js.map +1 -1
  30. package/dist/tmux/state-query.d.ts.map +1 -1
  31. package/dist/tmux/state-query.js +4 -1
  32. package/dist/tmux/state-query.js.map +1 -1
  33. package/dist/tmux/types.d.ts +11 -0
  34. package/dist/tmux/types.d.ts.map +1 -1
  35. package/dist/tmux/types.js.map +1 -1
  36. package/dist/tmux/utils.d.ts +17 -0
  37. package/dist/tmux/utils.d.ts.map +1 -1
  38. package/dist/tmux/utils.js +39 -0
  39. package/dist/tmux/utils.js.map +1 -1
  40. package/package.json +3 -3
  41. package/src/agents/lead.ts +2 -3
  42. package/src/background/manager.ts +6 -0
  43. package/src/plugin/hooks/cadence.ts +2 -1
  44. package/src/plugin/plugin.ts +67 -11
  45. package/src/skills/frontmatter.ts +1 -1
  46. package/src/tmux/executor.ts +748 -55
  47. package/src/tmux/index.ts +6 -0
  48. package/src/tmux/manager.ts +410 -21
  49. package/src/tmux/state-query.ts +4 -1
  50. package/src/tmux/types.ts +12 -0
  51. package/src/tmux/utils.ts +39 -0
@@ -1,10 +1,38 @@
1
1
  import type { PaneAction, WindowState, TmuxConfig } from './types';
2
+ type OwnershipContext = {
3
+ instanceId: string;
4
+ ownerPid: number;
5
+ serverKey: string;
6
+ tmuxSessionId?: string;
7
+ };
8
+ type OwnershipLookup = {
9
+ serverKey: string;
10
+ instanceId: string;
11
+ tmuxSessionId?: string;
12
+ };
2
13
  export interface ActionResult {
3
14
  success: boolean;
4
15
  paneId?: string;
5
16
  windowId?: string;
17
+ pid?: number;
6
18
  error?: string;
7
19
  }
20
+ export declare function getPanePid(paneId: string): Promise<number | undefined>;
21
+ export declare function getPanePidSync(paneId: string): number | undefined;
22
+ export declare function findOwnedAgentPanes(serverKey: string): Promise<Array<{
23
+ paneId: string;
24
+ panePid?: number;
25
+ sessionId?: string;
26
+ instanceId?: string;
27
+ }>>;
28
+ /**
29
+ * Kill a process and all its children (the entire process tree).
30
+ *
31
+ * This is necessary because we spawn `bash -c "opencode attach ...; tmux kill-pane"`
32
+ * and #{pane_pid} returns the bash PID, not the opencode attach PID.
33
+ * We need to kill the children (opencode attach) not just the parent (bash).
34
+ */
35
+ export declare function killProcessByPid(pid: number): Promise<boolean>;
8
36
  /**
9
37
  * Execute a single pane action
10
38
  *
@@ -14,6 +42,7 @@ export declare function executeAction(action: PaneAction, ctx: {
14
42
  config: TmuxConfig;
15
43
  serverUrl: string;
16
44
  windowState: WindowState;
45
+ ownership: OwnershipContext;
17
46
  }): Promise<ActionResult>;
18
47
  /**
19
48
  * Execute multiple actions in sequence
@@ -22,6 +51,7 @@ export declare function executeActions(actions: PaneAction[], ctx: {
22
51
  config: TmuxConfig;
23
52
  serverUrl: string;
24
53
  windowState: WindowState;
54
+ ownership: OwnershipContext;
25
55
  }): Promise<{
26
56
  success: boolean;
27
57
  spawnedPaneId?: string;
@@ -34,23 +64,44 @@ export declare function executeActions(actions: PaneAction[], ctx: {
34
64
  * Close a pane by its ID
35
65
  * Exported for use by TmuxSessionManager when sessions complete
36
66
  */
37
- export declare function closePaneById(paneId: string): Promise<ActionResult>;
67
+ export declare function closePaneById(paneId: string, pid?: number): Promise<ActionResult>;
38
68
  /**
39
69
  * Reset the agents window state (for cleanup)
40
70
  */
41
- export declare function resetAgentsWindow(): void;
71
+ export declare function resetAgentsWindow(ownership?: OwnershipContext): void;
42
72
  /**
43
73
  * Close the agents window if it exists
44
74
  * This kills the entire window, which closes all panes within it
75
+ *
76
+ * SAFETY: Verifies the window is named "Agents" before killing to prevent
77
+ * accidentally killing user windows if the cached ID is stale.
45
78
  */
46
- export declare function closeAgentsWindow(): Promise<void>;
79
+ export declare function closeAgentsWindow(ownership?: OwnershipLookup): Promise<void>;
47
80
  /**
48
81
  * Synchronously close the agents window (for shutdown)
49
- * Uses spawnSync to ensure it completes before process exit
82
+ * Uses runTmuxCommandSync to ensure it completes before process exit
83
+ *
84
+ * SAFETY: Verifies the window is named "Agents" before killing to prevent
85
+ * accidentally killing user windows if the cached ID is stale.
50
86
  */
51
- export declare function closeAgentsWindowSync(): void;
87
+ export declare function closeAgentsWindowSync(ownership?: OwnershipLookup): void;
52
88
  /**
53
89
  * Get the current agents window ID (for testing/debugging)
54
90
  */
55
- export declare function getAgentsWindowId(): string | undefined;
91
+ export declare function getAgentsWindowId(ownership?: OwnershipContext): string | undefined;
92
+ /**
93
+ * Clean up owned tmux windows/panes using ownership tags.
94
+ */
95
+ export declare function cleanupOwnedResources(serverKey: string, instanceId: string): Promise<{
96
+ panesClosed: number;
97
+ windowClosed: boolean;
98
+ }>;
99
+ /**
100
+ * Synchronous cleanup for owned tmux windows/panes.
101
+ */
102
+ export declare function cleanupOwnedResourcesSync(serverKey: string, instanceId: string): {
103
+ panesClosed: number;
104
+ windowClosed: boolean;
105
+ };
106
+ export {};
56
107
  //# sourceMappingURL=executor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/tmux/executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAenE,MAAM,WAAW,YAAY;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAOD;;;;GAIG;AACH,wBAAsB,aAAa,CAClC,MAAM,EAAE,UAAU,EAClB,GAAG,EAAE;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,WAAW,CAAA;CAAE,GACtE,OAAO,CAAC,YAAY,CAAC,CASvB;AAED;;GAEG;AACH,wBAAsB,cAAc,CACnC,OAAO,EAAE,UAAU,EAAE,EACrB,GAAG,EAAE;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,WAAW,CAAA;CAAE,GACtE,OAAO,CAAC;IACV,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,UAAU,CAAC;QAAC,MAAM,EAAE,YAAY,CAAA;KAAE,CAAC,CAAC;CAC7D,CAAC,CAgBD;AAcD;;;GAGG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CA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