@caupulican/pi-adaptative 0.80.14 → 0.80.16

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.80.16] - 2026-06-07
4
+
5
+ ### Fixed
6
+
7
+ - Reused active background script panels for same-turn repeated start/status/logs calls, so a model-issued status burst for one job still refreshes one TUI row instead of appending duplicates.
8
+ - Queued compaction messages with steering/follow-up behavior when auto-compaction finishes while the agent is still processing, avoiding the internal `streamingBehavior` error and duplicate restored queue display.
9
+
10
+ ## [0.80.15] - 2026-06-08
11
+
12
+ ### Fixed
13
+
14
+ - Reused background script job panels in place for repeated start/status/logs calls with the same job name/id, so long-running script status refreshes one persistent TUI line instead of appending repeated rows.
15
+
3
16
  ## [0.80.14] - 2026-06-08
4
17
 
5
18
  ### Fixed
@@ -6,11 +6,15 @@ export interface ToolPanelTenantScope {
6
6
  }
7
7
  export declare function createToolPanelTenantKey(scope: ToolPanelTenantScope): string;
8
8
  export declare function getToolPanelActionKey(scope: ToolPanelTenantScope, toolName: string, args: unknown): string | undefined;
9
+ export declare function shouldReuseToolPanelInPlace(toolName: string, args: unknown): boolean;
9
10
  export declare class ToolPanelRegistry {
10
11
  private readonly panelsByAction;
11
12
  private readonly activeByCallId;
12
13
  private readonly actionKeyByCallId;
13
- getReusable(actionKey: string | undefined): ToolExecutionComponent | undefined;
14
+ getReusable(actionKey: string | undefined, options?: {
15
+ allowActive?: boolean;
16
+ }): ToolExecutionComponent | undefined;
17
+ replaceActiveForAction(toolCallId: string, panel: ToolExecutionComponent, actionKey: string): void;
14
18
  register(toolCallId: string, panel: ToolExecutionComponent, actionKey?: string): void;
15
19
  hasActive(toolCallId: string): boolean;
16
20
  getActive(toolCallId: string): ToolExecutionComponent | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"tool-panel-registry.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-panel-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,MAAM,WAAW,oBAAoB;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;CACZ;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CAE5E;AAED,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,oBAAoB,EAC3B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,GACX,MAAM,GAAG,SAAS,CAYpB;AAED,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;IAC5E,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;IAC5E,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA6B;IAE/D,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,sBAAsB,GAAG,SAAS,CAK7E;IAED,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,sBAAsB,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAMpF;IAED,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAErC;IAED,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS,CAEhE;IAED,aAAa,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC,CAElE;IAED,QAAQ,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAK/C;IAED,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAG/B;IAED,WAAW,IAAI,IAAI,CAGlB;IAED,QAAQ,IAAI,IAAI,CAIf;CACD","sourcesContent":["import type { ToolExecutionComponent } from \"./tool-execution.ts\";\n\nexport interface ToolPanelTenantScope {\n\tsessionId?: string;\n\tsessionFile?: string;\n\tcwd: string;\n}\n\nexport function createToolPanelTenantKey(scope: ToolPanelTenantScope): string {\n\treturn [scope.sessionId || \"no-session-id\", scope.sessionFile || \"no-session-file\", scope.cwd].join(\"\\0\");\n}\n\nexport function getToolPanelActionKey(\n\tscope: ToolPanelTenantScope,\n\ttoolName: string,\n\targs: unknown,\n): string | undefined {\n\tconst tenantKey = createToolPanelTenantKey(scope);\n\tif (!args || typeof args !== \"object\") return toolName.endsWith(\"_status\") ? `${tenantKey}\\0${toolName}` : undefined;\n\tconst record = args as Record<string, unknown>;\n\tconst pathValue = record.path ?? record.file_path;\n\tif ([\"read\", \"edit\", \"write\"].includes(toolName) && typeof pathValue === \"string\" && pathValue.trim()) {\n\t\treturn `${tenantKey}\\0${toolName}:${pathValue.trim()}`;\n\t}\n\tif (toolName.endsWith(\"_status\")) return `${tenantKey}\\0${toolName}`;\n\tif (toolName === \"learning_auto_learn_state\") return `${tenantKey}\\0${toolName}:${String(record.action || \"read\")}`;\n\tif (toolName === \"task_steps\") return `${tenantKey}\\0${toolName}:${String(record.action || \"list\")}`;\n\treturn undefined;\n}\n\nexport class ToolPanelRegistry {\n\tprivate readonly panelsByAction = new Map<string, ToolExecutionComponent>();\n\tprivate readonly activeByCallId = new Map<string, ToolExecutionComponent>();\n\tprivate readonly actionKeyByCallId = new Map<string, string>();\n\n\tgetReusable(actionKey: string | undefined): ToolExecutionComponent | undefined {\n\t\tif (!actionKey) return undefined;\n\t\tconst panel = this.panelsByAction.get(actionKey);\n\t\tif (!panel || this.isActive(panel)) return undefined;\n\t\treturn panel;\n\t}\n\n\tregister(toolCallId: string, panel: ToolExecutionComponent, actionKey?: string): void {\n\t\tthis.activeByCallId.set(toolCallId, panel);\n\t\tif (actionKey) {\n\t\t\tthis.panelsByAction.set(actionKey, panel);\n\t\t\tthis.actionKeyByCallId.set(toolCallId, actionKey);\n\t\t}\n\t}\n\n\thasActive(toolCallId: string): boolean {\n\t\treturn this.activeByCallId.has(toolCallId);\n\t}\n\n\tgetActive(toolCallId: string): ToolExecutionComponent | undefined {\n\t\treturn this.activeByCallId.get(toolCallId);\n\t}\n\n\tactiveEntries(): IterableIterator<[string, ToolExecutionComponent]> {\n\t\treturn this.activeByCallId.entries();\n\t}\n\n\tisActive(panel: ToolExecutionComponent): boolean {\n\t\tfor (const active of this.activeByCallId.values()) {\n\t\t\tif (active === panel) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tfinish(toolCallId: string): void {\n\t\tthis.activeByCallId.delete(toolCallId);\n\t\tthis.actionKeyByCallId.delete(toolCallId);\n\t}\n\n\tclearActive(): void {\n\t\tthis.activeByCallId.clear();\n\t\tthis.actionKeyByCallId.clear();\n\t}\n\n\tclearAll(): void {\n\t\tthis.activeByCallId.clear();\n\t\tthis.panelsByAction.clear();\n\t\tthis.actionKeyByCallId.clear();\n\t}\n}\n"]}
1
+ {"version":3,"file":"tool-panel-registry.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-panel-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,MAAM,WAAW,oBAAoB;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;CACZ;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CAE5E;AAWD,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,oBAAoB,EAC3B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,GACX,MAAM,GAAG,SAAS,CAgBpB;AAED,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAOpF;AAED,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;IAC5E,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;IAC5E,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA6B;IAE/D,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,sBAAsB,GAAG,SAAS,CAKlH;IAED,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAOjG;IAED,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,sBAAsB,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAMpF;IAED,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAErC;IAED,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS,CAEhE;IAED,aAAa,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC,CAElE;IAED,QAAQ,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAK/C;IAED,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAG/B;IAED,WAAW,IAAI,IAAI,CAGlB;IAED,QAAQ,IAAI,IAAI,CAIf;CACD","sourcesContent":["import type { ToolExecutionComponent } from \"./tool-execution.ts\";\n\nexport interface ToolPanelTenantScope {\n\tsessionId?: string;\n\tsessionFile?: string;\n\tcwd: string;\n}\n\nexport function createToolPanelTenantKey(scope: ToolPanelTenantScope): string {\n\treturn [scope.sessionId || \"no-session-id\", scope.sessionFile || \"no-session-file\", scope.cwd].join(\"\\0\");\n}\n\nfunction backgroundScriptSelector(record: Record<string, unknown>): string | undefined {\n\tconst action = String(record.action || \"list\");\n\tif (action === \"start\" && typeof record.name === \"string\" && record.name.trim()) return record.name.trim();\n\tif ([\"status\", \"logs\", \"stop\"].includes(action) && typeof record.id === \"string\" && record.id.trim()) {\n\t\treturn record.id.trim();\n\t}\n\treturn undefined;\n}\n\nexport function getToolPanelActionKey(\n\tscope: ToolPanelTenantScope,\n\ttoolName: string,\n\targs: unknown,\n): string | undefined {\n\tconst tenantKey = createToolPanelTenantKey(scope);\n\tif (!args || typeof args !== \"object\") return toolName.endsWith(\"_status\") ? `${tenantKey}\\0${toolName}` : undefined;\n\tconst record = args as Record<string, unknown>;\n\tconst pathValue = record.path ?? record.file_path;\n\tif ([\"read\", \"edit\", \"write\"].includes(toolName) && typeof pathValue === \"string\" && pathValue.trim()) {\n\t\treturn `${tenantKey}\\0${toolName}:${pathValue.trim()}`;\n\t}\n\tif (toolName === \"background_script\") {\n\t\tconst selector = backgroundScriptSelector(record);\n\t\treturn selector ? `${tenantKey}\\0${toolName}:${selector}` : undefined;\n\t}\n\tif (toolName.endsWith(\"_status\")) return `${tenantKey}\\0${toolName}`;\n\tif (toolName === \"learning_auto_learn_state\") return `${tenantKey}\\0${toolName}:${String(record.action || \"read\")}`;\n\tif (toolName === \"task_steps\") return `${tenantKey}\\0${toolName}:${String(record.action || \"list\")}`;\n\treturn undefined;\n}\n\nexport function shouldReuseToolPanelInPlace(toolName: string, args: unknown): boolean {\n\treturn (\n\t\ttoolName === \"background_script\" &&\n\t\t!!args &&\n\t\ttypeof args === \"object\" &&\n\t\t!!backgroundScriptSelector(args as Record<string, unknown>)\n\t);\n}\n\nexport class ToolPanelRegistry {\n\tprivate readonly panelsByAction = new Map<string, ToolExecutionComponent>();\n\tprivate readonly activeByCallId = new Map<string, ToolExecutionComponent>();\n\tprivate readonly actionKeyByCallId = new Map<string, string>();\n\n\tgetReusable(actionKey: string | undefined, options?: { allowActive?: boolean }): ToolExecutionComponent | undefined {\n\t\tif (!actionKey) return undefined;\n\t\tconst panel = this.panelsByAction.get(actionKey);\n\t\tif (!panel || (!options?.allowActive && this.isActive(panel))) return undefined;\n\t\treturn panel;\n\t}\n\n\treplaceActiveForAction(toolCallId: string, panel: ToolExecutionComponent, actionKey: string): void {\n\t\tfor (const [activeCallId, activeActionKey] of this.actionKeyByCallId.entries()) {\n\t\t\tif (activeActionKey !== actionKey) continue;\n\t\t\tthis.activeByCallId.delete(activeCallId);\n\t\t\tthis.actionKeyByCallId.delete(activeCallId);\n\t\t}\n\t\tthis.register(toolCallId, panel, actionKey);\n\t}\n\n\tregister(toolCallId: string, panel: ToolExecutionComponent, actionKey?: string): void {\n\t\tthis.activeByCallId.set(toolCallId, panel);\n\t\tif (actionKey) {\n\t\t\tthis.panelsByAction.set(actionKey, panel);\n\t\t\tthis.actionKeyByCallId.set(toolCallId, actionKey);\n\t\t}\n\t}\n\n\thasActive(toolCallId: string): boolean {\n\t\treturn this.activeByCallId.has(toolCallId);\n\t}\n\n\tgetActive(toolCallId: string): ToolExecutionComponent | undefined {\n\t\treturn this.activeByCallId.get(toolCallId);\n\t}\n\n\tactiveEntries(): IterableIterator<[string, ToolExecutionComponent]> {\n\t\treturn this.activeByCallId.entries();\n\t}\n\n\tisActive(panel: ToolExecutionComponent): boolean {\n\t\tfor (const active of this.activeByCallId.values()) {\n\t\t\tif (active === panel) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tfinish(toolCallId: string): void {\n\t\tthis.activeByCallId.delete(toolCallId);\n\t\tthis.actionKeyByCallId.delete(toolCallId);\n\t}\n\n\tclearActive(): void {\n\t\tthis.activeByCallId.clear();\n\t\tthis.actionKeyByCallId.clear();\n\t}\n\n\tclearAll(): void {\n\t\tthis.activeByCallId.clear();\n\t\tthis.panelsByAction.clear();\n\t\tthis.actionKeyByCallId.clear();\n\t}\n}\n"]}
@@ -1,6 +1,15 @@
1
1
  export function createToolPanelTenantKey(scope) {
2
2
  return [scope.sessionId || "no-session-id", scope.sessionFile || "no-session-file", scope.cwd].join("\0");
3
3
  }
4
+ function backgroundScriptSelector(record) {
5
+ const action = String(record.action || "list");
6
+ if (action === "start" && typeof record.name === "string" && record.name.trim())
7
+ return record.name.trim();
8
+ if (["status", "logs", "stop"].includes(action) && typeof record.id === "string" && record.id.trim()) {
9
+ return record.id.trim();
10
+ }
11
+ return undefined;
12
+ }
4
13
  export function getToolPanelActionKey(scope, toolName, args) {
5
14
  const tenantKey = createToolPanelTenantKey(scope);
6
15
  if (!args || typeof args !== "object")
@@ -10,6 +19,10 @@ export function getToolPanelActionKey(scope, toolName, args) {
10
19
  if (["read", "edit", "write"].includes(toolName) && typeof pathValue === "string" && pathValue.trim()) {
11
20
  return `${tenantKey}\0${toolName}:${pathValue.trim()}`;
12
21
  }
22
+ if (toolName === "background_script") {
23
+ const selector = backgroundScriptSelector(record);
24
+ return selector ? `${tenantKey}\0${toolName}:${selector}` : undefined;
25
+ }
13
26
  if (toolName.endsWith("_status"))
14
27
  return `${tenantKey}\0${toolName}`;
15
28
  if (toolName === "learning_auto_learn_state")
@@ -18,18 +31,33 @@ export function getToolPanelActionKey(scope, toolName, args) {
18
31
  return `${tenantKey}\0${toolName}:${String(record.action || "list")}`;
19
32
  return undefined;
20
33
  }
34
+ export function shouldReuseToolPanelInPlace(toolName, args) {
35
+ return (toolName === "background_script" &&
36
+ !!args &&
37
+ typeof args === "object" &&
38
+ !!backgroundScriptSelector(args));
39
+ }
21
40
  export class ToolPanelRegistry {
22
41
  panelsByAction = new Map();
23
42
  activeByCallId = new Map();
24
43
  actionKeyByCallId = new Map();
25
- getReusable(actionKey) {
44
+ getReusable(actionKey, options) {
26
45
  if (!actionKey)
27
46
  return undefined;
28
47
  const panel = this.panelsByAction.get(actionKey);
29
- if (!panel || this.isActive(panel))
48
+ if (!panel || (!options?.allowActive && this.isActive(panel)))
30
49
  return undefined;
31
50
  return panel;
32
51
  }
52
+ replaceActiveForAction(toolCallId, panel, actionKey) {
53
+ for (const [activeCallId, activeActionKey] of this.actionKeyByCallId.entries()) {
54
+ if (activeActionKey !== actionKey)
55
+ continue;
56
+ this.activeByCallId.delete(activeCallId);
57
+ this.actionKeyByCallId.delete(activeCallId);
58
+ }
59
+ this.register(toolCallId, panel, actionKey);
60
+ }
33
61
  register(toolCallId, panel, actionKey) {
34
62
  this.activeByCallId.set(toolCallId, panel);
35
63
  if (actionKey) {
@@ -1 +1 @@
1
- {"version":3,"file":"tool-panel-registry.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-panel-registry.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,wBAAwB,CAAC,KAA2B,EAAU;IAC7E,OAAO,CAAC,KAAK,CAAC,SAAS,IAAI,eAAe,EAAE,KAAK,CAAC,WAAW,IAAI,iBAAiB,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAAA,CAC1G;AAED,MAAM,UAAU,qBAAqB,CACpC,KAA2B,EAC3B,QAAgB,EAChB,IAAa,EACQ;IACrB,MAAM,SAAS,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAClD,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,KAAK,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACrH,MAAM,MAAM,GAAG,IAA+B,CAAC;IAC/C,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,SAAS,CAAC;IAClD,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC;QACvG,OAAO,GAAG,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC;IACxD,CAAC;IACD,IAAI,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC;QAAE,OAAO,GAAG,SAAS,KAAK,QAAQ,EAAE,CAAC;IACrE,IAAI,QAAQ,KAAK,2BAA2B;QAAE,OAAO,GAAG,SAAS,KAAK,QAAQ,IAAI,MAAM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AAa,GAAuD;QACnE,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;IAAA,CACrC;IAED,QAAQ,CAAC,KAA6B,EAAW;QAChD,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,CAAC;YACnD,IAAI,MAAM,KAAK,KAAK;gBAAE,OAAO,IAAI,CAAC;QACnC,CAAC;QACD,OAAO,KAAK,CAAC;IAAA,CACb;IAED,MAAM,CAAC,UAAkB,EAAQ;QAChC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACvC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAAA,CAC1C;IAED,WAAW,GAAS;QACnB,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;IAAA,CAC/B;IAED,QAAQ,GAAS;QAChB,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;IAAA,CAC/B;CACD","sourcesContent":["import type { ToolExecutionComponent } from \"./tool-execution.ts\";\n\nexport interface ToolPanelTenantScope {\n\tsessionId?: string;\n\tsessionFile?: string;\n\tcwd: string;\n}\n\nexport function createToolPanelTenantKey(scope: ToolPanelTenantScope): string {\n\treturn [scope.sessionId || \"no-session-id\", scope.sessionFile || \"no-session-file\", scope.cwd].join(\"\\0\");\n}\n\nexport function getToolPanelActionKey(\n\tscope: ToolPanelTenantScope,\n\ttoolName: string,\n\targs: unknown,\n): string | undefined {\n\tconst tenantKey = createToolPanelTenantKey(scope);\n\tif (!args || typeof args !== \"object\") return toolName.endsWith(\"_status\") ? `${tenantKey}\\0${toolName}` : undefined;\n\tconst record = args as Record<string, unknown>;\n\tconst pathValue = record.path ?? record.file_path;\n\tif ([\"read\", \"edit\", \"write\"].includes(toolName) && typeof pathValue === \"string\" && pathValue.trim()) {\n\t\treturn `${tenantKey}\\0${toolName}:${pathValue.trim()}`;\n\t}\n\tif (toolName.endsWith(\"_status\")) return `${tenantKey}\\0${toolName}`;\n\tif (toolName === \"learning_auto_learn_state\") return `${tenantKey}\\0${toolName}:${String(record.action || \"read\")}`;\n\tif (toolName === \"task_steps\") return `${tenantKey}\\0${toolName}:${String(record.action || \"list\")}`;\n\treturn undefined;\n}\n\nexport class ToolPanelRegistry {\n\tprivate readonly panelsByAction = new Map<string, ToolExecutionComponent>();\n\tprivate readonly activeByCallId = new Map<string, ToolExecutionComponent>();\n\tprivate readonly actionKeyByCallId = new Map<string, string>();\n\n\tgetReusable(actionKey: string | undefined): ToolExecutionComponent | undefined {\n\t\tif (!actionKey) return undefined;\n\t\tconst panel = this.panelsByAction.get(actionKey);\n\t\tif (!panel || this.isActive(panel)) return undefined;\n\t\treturn panel;\n\t}\n\n\tregister(toolCallId: string, panel: ToolExecutionComponent, actionKey?: string): void {\n\t\tthis.activeByCallId.set(toolCallId, panel);\n\t\tif (actionKey) {\n\t\t\tthis.panelsByAction.set(actionKey, panel);\n\t\t\tthis.actionKeyByCallId.set(toolCallId, actionKey);\n\t\t}\n\t}\n\n\thasActive(toolCallId: string): boolean {\n\t\treturn this.activeByCallId.has(toolCallId);\n\t}\n\n\tgetActive(toolCallId: string): ToolExecutionComponent | undefined {\n\t\treturn this.activeByCallId.get(toolCallId);\n\t}\n\n\tactiveEntries(): IterableIterator<[string, ToolExecutionComponent]> {\n\t\treturn this.activeByCallId.entries();\n\t}\n\n\tisActive(panel: ToolExecutionComponent): boolean {\n\t\tfor (const active of this.activeByCallId.values()) {\n\t\t\tif (active === panel) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tfinish(toolCallId: string): void {\n\t\tthis.activeByCallId.delete(toolCallId);\n\t\tthis.actionKeyByCallId.delete(toolCallId);\n\t}\n\n\tclearActive(): void {\n\t\tthis.activeByCallId.clear();\n\t\tthis.actionKeyByCallId.clear();\n\t}\n\n\tclearAll(): void {\n\t\tthis.activeByCallId.clear();\n\t\tthis.panelsByAction.clear();\n\t\tthis.actionKeyByCallId.clear();\n\t}\n}\n"]}
1
+ {"version":3,"file":"tool-panel-registry.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-panel-registry.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,wBAAwB,CAAC,KAA2B,EAAU;IAC7E,OAAO,CAAC,KAAK,CAAC,SAAS,IAAI,eAAe,EAAE,KAAK,CAAC,WAAW,IAAI,iBAAiB,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAAA,CAC1G;AAED,SAAS,wBAAwB,CAAC,MAA+B,EAAsB;IACtF,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,CAAC;IAC/C,IAAI,MAAM,KAAK,OAAO,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAC3G,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,OAAO,MAAM,CAAC,EAAE,KAAK,QAAQ,IAAI,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;QACtG,OAAO,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;IACD,OAAO,SAAS,CAAC;AAAA,CACjB;AAED,MAAM,UAAU,qBAAqB,CACpC,KAA2B,EAC3B,QAAgB,EAChB,IAAa,EACQ;IACrB,MAAM,SAAS,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAClD,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QA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,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YAC1C,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QACnD,CAAC;IAAA,CACD;IAED,SAAS,CAAC,UAAkB,EAAW;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAAA,CAC3C;IAED,SAAS,CAAC,UAAkB,EAAsC;QACjE,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAAA,CAC3C;IAED,aAAa,GAAuD;QACnE,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;IAAA,CACrC;IAED,QAAQ,CAAC,KAA6B,EAAW;QAChD,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,CAAC;YACnD,IAAI,MAAM,KAAK,KAAK;gBAAE,OAAO,IAAI,CAAC;QACnC,CAAC;QACD,OAAO,KAAK,CAAC;IAAA,CACb;IAED,MAAM,CAAC,UAAkB,EAAQ;QAChC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACvC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAAA,CAC1C;IAED,WAAW,GAAS;QACnB,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;IAAA,CAC/B;IAED,QAAQ,GAAS;QAChB,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;IAAA,CAC/B;CACD","sourcesContent":["import type { ToolExecutionComponent } from \"./tool-execution.ts\";\n\nexport interface ToolPanelTenantScope {\n\tsessionId?: string;\n\tsessionFile?: string;\n\tcwd: string;\n}\n\nexport function createToolPanelTenantKey(scope: ToolPanelTenantScope): string {\n\treturn [scope.sessionId || \"no-session-id\", scope.sessionFile || \"no-session-file\", scope.cwd].join(\"\\0\");\n}\n\nfunction backgroundScriptSelector(record: Record<string, unknown>): string | undefined {\n\tconst action = String(record.action || \"list\");\n\tif (action === \"start\" && typeof record.name === \"string\" && record.name.trim()) return record.name.trim();\n\tif ([\"status\", \"logs\", \"stop\"].includes(action) && typeof record.id === \"string\" && record.id.trim()) {\n\t\treturn record.id.trim();\n\t}\n\treturn undefined;\n}\n\nexport function getToolPanelActionKey(\n\tscope: ToolPanelTenantScope,\n\ttoolName: string,\n\targs: unknown,\n): string | undefined {\n\tconst tenantKey = createToolPanelTenantKey(scope);\n\tif (!args || typeof args !== \"object\") return toolName.endsWith(\"_status\") ? `${tenantKey}\\0${toolName}` : undefined;\n\tconst record = args as Record<string, unknown>;\n\tconst pathValue = record.path ?? record.file_path;\n\tif ([\"read\", \"edit\", \"write\"].includes(toolName) && typeof pathValue === \"string\" && pathValue.trim()) {\n\t\treturn `${tenantKey}\\0${toolName}:${pathValue.trim()}`;\n\t}\n\tif (toolName === \"background_script\") {\n\t\tconst selector = backgroundScriptSelector(record);\n\t\treturn selector ? `${tenantKey}\\0${toolName}:${selector}` : undefined;\n\t}\n\tif (toolName.endsWith(\"_status\")) return `${tenantKey}\\0${toolName}`;\n\tif (toolName === \"learning_auto_learn_state\") return `${tenantKey}\\0${toolName}:${String(record.action || \"read\")}`;\n\tif (toolName === \"task_steps\") return `${tenantKey}\\0${toolName}:${String(record.action || \"list\")}`;\n\treturn undefined;\n}\n\nexport function shouldReuseToolPanelInPlace(toolName: string, args: unknown): boolean {\n\treturn (\n\t\ttoolName === \"background_script\" &&\n\t\t!!args &&\n\t\ttypeof args === \"object\" &&\n\t\t!!backgroundScriptSelector(args as Record<string, unknown>)\n\t);\n}\n\nexport class ToolPanelRegistry {\n\tprivate readonly panelsByAction = new Map<string, ToolExecutionComponent>();\n\tprivate readonly activeByCallId = new Map<string, ToolExecutionComponent>();\n\tprivate readonly actionKeyByCallId = new Map<string, string>();\n\n\tgetReusable(actionKey: string | undefined, options?: { allowActive?: boolean }): ToolExecutionComponent | undefined {\n\t\tif (!actionKey) return undefined;\n\t\tconst panel = this.panelsByAction.get(actionKey);\n\t\tif (!panel || (!options?.allowActive && this.isActive(panel))) return undefined;\n\t\treturn panel;\n\t}\n\n\treplaceActiveForAction(toolCallId: string, panel: ToolExecutionComponent, actionKey: string): void {\n\t\tfor (const [activeCallId, activeActionKey] of this.actionKeyByCallId.entries()) {\n\t\t\tif (activeActionKey !== actionKey) continue;\n\t\t\tthis.activeByCallId.delete(activeCallId);\n\t\t\tthis.actionKeyByCallId.delete(activeCallId);\n\t\t}\n\t\tthis.register(toolCallId, panel, actionKey);\n\t}\n\n\tregister(toolCallId: string, panel: ToolExecutionComponent, actionKey?: string): void {\n\t\tthis.activeByCallId.set(toolCallId, panel);\n\t\tif (actionKey) {\n\t\t\tthis.panelsByAction.set(actionKey, panel);\n\t\t\tthis.actionKeyByCallId.set(toolCallId, actionKey);\n\t\t}\n\t}\n\n\thasActive(toolCallId: string): boolean {\n\t\treturn this.activeByCallId.has(toolCallId);\n\t}\n\n\tgetActive(toolCallId: string): ToolExecutionComponent | undefined {\n\t\treturn this.activeByCallId.get(toolCallId);\n\t}\n\n\tactiveEntries(): IterableIterator<[string, ToolExecutionComponent]> {\n\t\treturn this.activeByCallId.entries();\n\t}\n\n\tisActive(panel: ToolExecutionComponent): boolean {\n\t\tfor (const active of this.activeByCallId.values()) {\n\t\t\tif (active === panel) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tfinish(toolCallId: string): void {\n\t\tthis.activeByCallId.delete(toolCallId);\n\t\tthis.actionKeyByCallId.delete(toolCallId);\n\t}\n\n\tclearActive(): void {\n\t\tthis.activeByCallId.clear();\n\t\tthis.actionKeyByCallId.clear();\n\t}\n\n\tclearAll(): void {\n\t\tthis.activeByCallId.clear();\n\t\tthis.panelsByAction.clear();\n\t\tthis.actionKeyByCallId.clear();\n\t}\n}\n"]}