@bastani/atomic 0.9.5-alpha.7 → 0.9.5-alpha.9
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 +33 -2
- package/dist/builtin/cursor/package.json +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +17 -0
- package/dist/builtin/intercom/README.md +27 -21
- package/dist/builtin/intercom/broker/broker.ts +3 -6
- package/dist/builtin/intercom/broker/paths.ts +42 -5
- package/dist/builtin/intercom/broker/spawn.ts +78 -10
- package/dist/builtin/intercom/config.ts +6 -3
- package/dist/builtin/intercom/contact-supervisor-tool.ts +6 -4
- package/dist/builtin/intercom/index-heavy.ts +1 -1
- package/dist/builtin/intercom/index.ts +162 -130
- package/dist/builtin/intercom/intercom-tool.ts +9 -3
- package/dist/builtin/intercom/package.json +10 -1
- package/dist/builtin/intercom/result-renderers.ts +1 -1
- package/dist/builtin/intercom/ui/compose.ts +2 -2
- package/dist/builtin/intercom/ui/inline-message.ts +2 -2
- package/dist/builtin/intercom/ui/session-list.ts +2 -2
- package/dist/builtin/mcp/CHANGELOG.md +11 -0
- package/dist/builtin/mcp/README.md +6 -6
- package/dist/builtin/mcp/direct-tools.ts +41 -23
- package/dist/builtin/mcp/index.ts +31 -4
- package/dist/builtin/mcp/init.ts +4 -43
- package/dist/builtin/mcp/metadata-hydration.ts +37 -0
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/mcp/proxy-info-modes.ts +67 -14
- package/dist/builtin/mcp/startup-warmup.ts +98 -0
- package/dist/builtin/mcp/tool-result-renderer.ts +3 -3
- package/dist/builtin/subagents/CHANGELOG.md +18 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.ts +14 -25
- package/dist/builtin/subagents/src/extension/startup-maintenance.ts +89 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-common.ts +23 -18
- package/dist/builtin/subagents/src/runs/background/result-watcher.ts +20 -10
- package/dist/builtin/subagents/src/runs/background/subagent-runner-streaming.ts +13 -3
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +10 -2
- package/dist/builtin/subagents/src/runs/shared/pi-spawn.ts +28 -1
- package/dist/builtin/subagents/src/tui/render-event-formatting.ts +15 -48
- package/dist/builtin/subagents/src/tui/render-layout.ts +9 -0
- package/dist/builtin/subagents/src/tui/render-widget-graph.ts +27 -25
- package/dist/builtin/subagents/src/tui/render-widget.ts +72 -66
- package/dist/builtin/subagents/src/tui/render.ts +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +29 -0
- package/dist/builtin/workflows/README.md +4 -2
- package/dist/builtin/workflows/builtin/goal-artifacts.ts +3 -1
- package/dist/builtin/workflows/builtin/goal-prompts.ts +23 -2
- package/dist/builtin/workflows/builtin/goal-reducer.ts +21 -0
- package/dist/builtin/workflows/builtin/goal-review.ts +60 -6
- package/dist/builtin/workflows/builtin/goal-runner.ts +71 -22
- package/dist/builtin/workflows/builtin/goal-types.ts +7 -1
- package/dist/builtin/workflows/builtin/ralph-core.ts +52 -4
- package/dist/builtin/workflows/builtin/ralph-review-gate.ts +10 -3
- package/dist/builtin/workflows/builtin/ralph-reviewer-prompt.ts +23 -2
- package/dist/builtin/workflows/builtin/ralph-runner.ts +38 -16
- package/dist/builtin/workflows/builtin/review-convergence.ts +111 -0
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/skills/create-spec/SKILL.md +2 -0
- package/dist/builtin/workflows/skills/impeccable/SKILL.md +16 -13
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.md +1 -0
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.native.md +58 -0
- package/dist/builtin/workflows/skills/impeccable/reference/android.md +40 -0
- package/dist/builtin/workflows/skills/impeccable/reference/animate.md +2 -0
- package/dist/builtin/workflows/skills/impeccable/reference/audit.md +2 -0
- package/dist/builtin/workflows/skills/impeccable/reference/audit.native.md +139 -0
- package/dist/builtin/workflows/skills/impeccable/reference/bolder.md +69 -62
- package/dist/builtin/workflows/skills/impeccable/reference/critique.md +21 -7
- package/dist/builtin/workflows/skills/impeccable/reference/document.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +92 -0
- package/dist/builtin/workflows/skills/impeccable/reference/init.md +29 -7
- package/dist/builtin/workflows/skills/impeccable/reference/ios.md +45 -0
- package/dist/builtin/workflows/skills/impeccable/reference/layout.md +25 -1
- package/dist/builtin/workflows/skills/impeccable/reference/typeset.md +23 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/context-signals.mjs +2 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/context.mjs +75 -14
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/browser/injected/index.mjs +1 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/cli/main.mjs +31 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/design-system.mjs +64 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +118 -11
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +16 -11
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/registry/antipatterns.mjs +66 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/rules/checks.mjs +42 -10
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/fonts.mjs +30 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/page.mjs +4 -6
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-admin.mjs +660 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-before-edit.mjs +516 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-lib.mjs +1764 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/hook.mjs +61 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-config.mjs +4 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/is-generated.mjs +2 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-component.mjs +13 -16
- package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +17 -11
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +104 -37
- package/dist/builtin/workflows/skills/impeccable/scripts/live-wrap.mjs +9 -0
- package/dist/builtin/workflows/src/durable/backend.ts +12 -0
- package/dist/builtin/workflows/src/durable/child-primitive.ts +12 -8
- package/dist/builtin/workflows/src/durable/dbos-backend.ts +63 -2
- package/dist/builtin/workflows/src/durable/dbos-envelope.ts +28 -0
- package/dist/builtin/workflows/src/durable/resume-catalog.ts +12 -0
- package/dist/builtin/workflows/src/durable/resume-runtime.ts +5 -2
- package/dist/builtin/workflows/src/durable/stage-primitive.ts +165 -27
- package/dist/builtin/workflows/src/durable/types.ts +30 -1
- package/dist/builtin/workflows/src/engine/primitives/task.ts +1 -0
- package/dist/builtin/workflows/src/engine/run-durable-finalize.ts +1 -2
- package/dist/builtin/workflows/src/engine/run-returned-status.ts +50 -16
- package/dist/builtin/workflows/src/engine/run.ts +32 -32
- package/dist/builtin/workflows/src/engine/runtime.ts +5 -0
- package/dist/builtin/workflows/src/extension/extension-factory.ts +3 -0
- package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +9 -2
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +137 -27
- package/dist/builtin/workflows/src/extension/lifecycle-notifications.ts +22 -6
- package/dist/builtin/workflows/src/extension/public-types.ts +1 -1
- package/dist/builtin/workflows/src/extension/workflow-command-completions.ts +13 -1
- package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +19 -4
- package/dist/builtin/workflows/src/extension/workflow-command-surfaces.ts +9 -0
- package/dist/builtin/workflows/src/extension/workflow-prompts.ts +2 -0
- package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +48 -23
- package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +20 -8
- package/dist/builtin/workflows/src/extension/workflow-tool.ts +24 -8
- package/dist/builtin/workflows/src/runs/background/status.ts +4 -3
- package/dist/builtin/workflows/src/runs/foreground/executor-continuation.ts +13 -3
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +29 -8
- package/dist/builtin/workflows/src/runs/foreground/executor-hil.ts +2 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +4 -3
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +18 -19
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-unresolved-overflow.ts +38 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-git.ts +155 -20
- package/dist/builtin/workflows/src/runs/shared/worktree-types.ts +6 -0
- package/dist/builtin/workflows/src/runs/shared/worktree.ts +2 -1
- package/dist/builtin/workflows/src/shared/persistence-restore-helpers.ts +18 -1
- package/dist/builtin/workflows/src/shared/persistence-restore.ts +23 -5
- package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +4 -0
- package/dist/builtin/workflows/src/shared/returned-run-status.ts +116 -0
- package/dist/builtin/workflows/src/shared/workflow-failures-decisions.ts +2 -0
- package/dist/builtin/workflows/src/tui/graph-view-render-helpers.ts +21 -3
- package/dist/builtin/workflows/src/tui/graph-view-state.ts +3 -0
- package/dist/builtin/workflows/src/tui/graph-view-types.ts +3 -0
- package/dist/builtin/workflows/src/tui/status-list.ts +22 -15
- package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +4 -4
- package/dist/bun/internal-intercom-broker.d.ts +6 -0
- package/dist/bun/internal-intercom-broker.d.ts.map +1 -0
- package/dist/bun/internal-intercom-broker.js +39 -0
- package/dist/bun/internal-intercom-broker.js.map +1 -0
- package/dist/bun/split-loader.d.ts.map +1 -1
- package/dist/bun/split-loader.js +21 -8
- package/dist/bun/split-loader.js.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts +21 -2
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +163 -11
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +10 -1
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +12 -3
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-models.d.ts +2 -2
- package/dist/core/agent-session-models.d.ts.map +1 -1
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +1 -0
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts +2 -0
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +152 -4
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +1 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +15 -1
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +6 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +6 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/context-compaction-runner.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-runner.js +36 -20
- package/dist/core/compaction/context-compaction-runner.js.map +1 -1
- package/dist/core/copilot-anthropic-sse-repair.d.ts +23 -0
- package/dist/core/copilot-anthropic-sse-repair.d.ts.map +1 -0
- package/dist/core/copilot-anthropic-sse-repair.js +340 -0
- package/dist/core/copilot-anthropic-sse-repair.js.map +1 -0
- package/dist/core/copilot-gemini-reasoning.d.ts +16 -8
- package/dist/core/copilot-gemini-reasoning.d.ts.map +1 -1
- package/dist/core/copilot-gemini-reasoning.js +27 -22
- package/dist/core/copilot-gemini-reasoning.js.map +1 -1
- package/dist/core/copilot-hosts.d.ts +12 -0
- package/dist/core/copilot-hosts.d.ts.map +1 -0
- package/dist/core/copilot-hosts.js +33 -0
- package/dist/core/copilot-hosts.js.map +1 -0
- package/dist/core/extensions/agent-events.d.ts +1 -1
- package/dist/core/extensions/agent-events.d.ts.map +1 -1
- package/dist/core/extensions/agent-events.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts +8 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +2 -1
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +6 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +72 -29
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +5 -5
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/openai-responses-payload-sanitizer.d.ts +1 -0
- package/dist/core/openai-responses-payload-sanitizer.d.ts.map +1 -1
- package/dist/core/openai-responses-payload-sanitizer.js +24 -9
- package/dist/core/openai-responses-payload-sanitizer.js.map +1 -1
- package/dist/core/sdk-types.d.ts +2 -0
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +1 -0
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +1 -0
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +6 -0
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-types.d.ts +1 -0
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/slash-commands.d.ts +2 -0
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +141 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/main-deferred-startup.d.ts +12 -0
- package/dist/main-deferred-startup.d.ts.map +1 -1
- package/dist/main-deferred-startup.js +23 -2
- package/dist/main-deferred-startup.js.map +1 -1
- package/dist/main-early-input.d.ts +41 -0
- package/dist/main-early-input.d.ts.map +1 -0
- package/dist/main-early-input.js +154 -0
- package/dist/main-early-input.js.map +1 -0
- package/dist/main.d.ts +0 -6
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +20 -14
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js +0 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.js +15 -0
- package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +25 -0
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +21 -9
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js +41 -28
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.js +1 -0
- package/dist/modes/interactive/interactive-hotkeys-debug.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +318 -185
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +12 -0
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +39 -0
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +6 -2
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.d.ts +3 -0
- package/dist/modes/interactive/interactive-mode-types.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +3 -1
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js +0 -3
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +36 -10
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +5 -1
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +26 -22
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/theme/global-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/global-theme.js +26 -2
- package/dist/modes/interactive/theme/global-theme.js.map +1 -1
- package/dist/utils/fs-watch.d.ts +24 -1
- package/dist/utils/fs-watch.d.ts.map +1 -1
- package/dist/utils/fs-watch.js +60 -5
- package/dist/utils/fs-watch.js.map +1 -1
- package/docs/compaction.md +8 -0
- package/docs/development.md +4 -0
- package/docs/extensions.md +5 -0
- package/docs/json.md +3 -1
- package/docs/providers.md +1 -0
- package/docs/quickstart.md +1 -1
- package/docs/rpc.md +3 -1
- package/docs/settings.md +27 -1
- package/docs/subagents.md +4 -0
- package/docs/terminal-setup.md +4 -0
- package/docs/usage.md +2 -2
- package/docs/windows.md +4 -0
- package/docs/workflows.md +21 -9
- package/npm-shrinkwrap.json +513 -23
- package/package.json +3 -2
|
@@ -1,57 +1,54 @@
|
|
|
1
|
-
import type { ExtensionAPI, ExtensionContext,
|
|
2
|
-
import { Text } from "@
|
|
1
|
+
import type { AgentEndEvent, AgentStartEvent, ExtensionAPI, ExtensionCommandContext, ExtensionContext, ExtensionHandler, MessageRenderer, ModelSelectEvent, RegisteredCommand, SessionShutdownEvent, SessionStartEvent, ToolDefinition, ToolExecutionEndEvent, ToolExecutionStartEvent, TurnEndEvent, TurnStartEvent } from "@bastani/atomic";
|
|
2
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
3
3
|
import { Type } from "typebox";
|
|
4
4
|
import { renderIntercomToolResult } from "./result-renderers.js";
|
|
5
5
|
|
|
6
6
|
type CapturedCommand = Omit<RegisteredCommand, "name" | "sourceInfo">;
|
|
7
7
|
type CapturedShortcut = Parameters<ExtensionAPI["registerShortcut"]>[1];
|
|
8
8
|
type EventHandler = Parameters<ExtensionAPI["events"]["on"]>[1];
|
|
9
|
+
type EventPayload = Parameters<EventHandler>[0];
|
|
9
10
|
type ToolRenderResultArgs = Parameters<NonNullable<ToolDefinition["renderResult"]>>;
|
|
11
|
+
|
|
12
|
+
type ForwardedEventMap = {
|
|
13
|
+
session_start: SessionStartEvent;
|
|
14
|
+
session_shutdown: SessionShutdownEvent;
|
|
15
|
+
turn_start: TurnStartEvent;
|
|
16
|
+
turn_end: TurnEndEvent;
|
|
17
|
+
agent_start: AgentStartEvent;
|
|
18
|
+
agent_end: AgentEndEvent;
|
|
19
|
+
tool_execution_start: ToolExecutionStartEvent;
|
|
20
|
+
tool_execution_end: ToolExecutionEndEvent;
|
|
21
|
+
model_select: ModelSelectEvent;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type LazyLifecycleEvent = keyof ForwardedEventMap;
|
|
25
|
+
type ForwardedHandler<K extends LazyLifecycleEvent> = ExtensionHandler<ForwardedEventMap[K]>;
|
|
26
|
+
type ForwardedHandlerMap = { [K in LazyLifecycleEvent]: ForwardedHandler<K>[] };
|
|
27
|
+
type AnyForwardedHandler = { [K in LazyLifecycleEvent]: ForwardedHandler<K> }[LazyLifecycleEvent];
|
|
28
|
+
|
|
10
29
|
type CapturedHeavy = {
|
|
11
30
|
tools: Map<string, ToolDefinition>;
|
|
12
31
|
commands: Map<string, CapturedCommand>;
|
|
13
|
-
handlers:
|
|
32
|
+
handlers: ForwardedHandlerMap;
|
|
14
33
|
shortcuts: Map<string, CapturedShortcut>;
|
|
15
34
|
eventHandlers: Map<string, EventHandler[]>;
|
|
16
35
|
};
|
|
17
|
-
|
|
18
|
-
|
|
36
|
+
|
|
37
|
+
type LifecycleSnapshot<K extends LazyLifecycleEvent> = {
|
|
38
|
+
event: ForwardedEventMap[K];
|
|
19
39
|
ctx: ExtensionContext;
|
|
20
40
|
};
|
|
21
41
|
|
|
22
|
-
type SessionSnapshot = LifecycleSnapshot & {
|
|
42
|
+
type SessionSnapshot = LifecycleSnapshot<"session_start"> & {
|
|
23
43
|
generation: number;
|
|
24
44
|
};
|
|
25
45
|
|
|
26
46
|
type ActiveLifecycleState = {
|
|
27
|
-
turnStart: LifecycleSnapshot | null;
|
|
28
|
-
agentStart: LifecycleSnapshot | null;
|
|
29
|
-
activeTools: Map<string, LifecycleSnapshot
|
|
30
|
-
modelSelect: LifecycleSnapshot | null;
|
|
47
|
+
turnStart: LifecycleSnapshot<"turn_start"> | null;
|
|
48
|
+
agentStart: LifecycleSnapshot<"agent_start"> | null;
|
|
49
|
+
activeTools: Map<string, LifecycleSnapshot<"tool_execution_start">>;
|
|
50
|
+
modelSelect: LifecycleSnapshot<"model_select"> | null;
|
|
31
51
|
};
|
|
32
|
-
|
|
33
|
-
type LazyLifecycleEvent =
|
|
34
|
-
| "session_start"
|
|
35
|
-
| "session_shutdown"
|
|
36
|
-
| "turn_start"
|
|
37
|
-
| "turn_end"
|
|
38
|
-
| "agent_start"
|
|
39
|
-
| "agent_end"
|
|
40
|
-
| "tool_execution_start"
|
|
41
|
-
| "tool_execution_end"
|
|
42
|
-
| "model_select";
|
|
43
|
-
|
|
44
|
-
const FORWARDED_EVENTS: readonly LazyLifecycleEvent[] = [
|
|
45
|
-
"session_start",
|
|
46
|
-
"session_shutdown",
|
|
47
|
-
"turn_start",
|
|
48
|
-
"turn_end",
|
|
49
|
-
"agent_start",
|
|
50
|
-
"agent_end",
|
|
51
|
-
"tool_execution_start",
|
|
52
|
-
"tool_execution_end",
|
|
53
|
-
"model_select",
|
|
54
|
-
];
|
|
55
52
|
const SUBAGENT_CONTROL_INTERCOM_EVENT = "subagent:control-intercom";
|
|
56
53
|
const SUBAGENT_RESULT_INTERCOM_EVENT = "subagent:result-intercom";
|
|
57
54
|
|
|
@@ -59,16 +56,67 @@ function hasSubagentIntercomEnv(): boolean {
|
|
|
59
56
|
return Object.keys(process.env).some((key) => key.endsWith("_SUBAGENT_ORCHESTRATOR_TARGET"));
|
|
60
57
|
}
|
|
61
58
|
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
-
const toolCallId = event.toolCallId;
|
|
65
|
-
return typeof toolCallId === "string" ? toolCallId : null;
|
|
59
|
+
function createSyntheticSessionStartEvent(): SessionStartEvent {
|
|
60
|
+
return { type: "session_start", reason: "startup" };
|
|
66
61
|
}
|
|
67
62
|
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
function createForwardedHandlerMap(): ForwardedHandlerMap {
|
|
64
|
+
return {
|
|
65
|
+
session_start: [],
|
|
66
|
+
session_shutdown: [],
|
|
67
|
+
turn_start: [],
|
|
68
|
+
turn_end: [],
|
|
69
|
+
agent_start: [],
|
|
70
|
+
agent_end: [],
|
|
71
|
+
tool_execution_start: [],
|
|
72
|
+
tool_execution_end: [],
|
|
73
|
+
model_select: [],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function addHandler<K extends LazyLifecycleEvent>(captured: CapturedHeavy, event: K, handler: ForwardedHandler<K>): void {
|
|
78
|
+
captured.handlers[event].push(handler);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function captureForwardedHandler(captured: CapturedHeavy, event: "session_start", handler: ForwardedHandler<"session_start">): void;
|
|
82
|
+
function captureForwardedHandler(captured: CapturedHeavy, event: "session_shutdown", handler: ForwardedHandler<"session_shutdown">): void;
|
|
83
|
+
function captureForwardedHandler(captured: CapturedHeavy, event: "turn_start", handler: ForwardedHandler<"turn_start">): void;
|
|
84
|
+
function captureForwardedHandler(captured: CapturedHeavy, event: "turn_end", handler: ForwardedHandler<"turn_end">): void;
|
|
85
|
+
function captureForwardedHandler(captured: CapturedHeavy, event: "agent_start", handler: ForwardedHandler<"agent_start">): void;
|
|
86
|
+
function captureForwardedHandler(captured: CapturedHeavy, event: "agent_end", handler: ForwardedHandler<"agent_end">): void;
|
|
87
|
+
function captureForwardedHandler(captured: CapturedHeavy, event: "tool_execution_start", handler: ForwardedHandler<"tool_execution_start">): void;
|
|
88
|
+
function captureForwardedHandler(captured: CapturedHeavy, event: "tool_execution_end", handler: ForwardedHandler<"tool_execution_end">): void;
|
|
89
|
+
function captureForwardedHandler(captured: CapturedHeavy, event: "model_select", handler: ForwardedHandler<"model_select">): void;
|
|
90
|
+
function captureForwardedHandler(captured: CapturedHeavy, event: LazyLifecycleEvent, handler: AnyForwardedHandler): void;
|
|
91
|
+
function captureForwardedHandler(captured: CapturedHeavy, event: LazyLifecycleEvent, handler: AnyForwardedHandler): void {
|
|
92
|
+
switch (event) {
|
|
93
|
+
case "session_start":
|
|
94
|
+
addHandler(captured, event, handler as ForwardedHandler<"session_start">);
|
|
95
|
+
return;
|
|
96
|
+
case "session_shutdown":
|
|
97
|
+
addHandler(captured, event, handler as ForwardedHandler<"session_shutdown">);
|
|
98
|
+
return;
|
|
99
|
+
case "turn_start":
|
|
100
|
+
addHandler(captured, event, handler as ForwardedHandler<"turn_start">);
|
|
101
|
+
return;
|
|
102
|
+
case "turn_end":
|
|
103
|
+
addHandler(captured, event, handler as ForwardedHandler<"turn_end">);
|
|
104
|
+
return;
|
|
105
|
+
case "agent_start":
|
|
106
|
+
addHandler(captured, event, handler as ForwardedHandler<"agent_start">);
|
|
107
|
+
return;
|
|
108
|
+
case "agent_end":
|
|
109
|
+
addHandler(captured, event, handler as ForwardedHandler<"agent_end">);
|
|
110
|
+
return;
|
|
111
|
+
case "tool_execution_start":
|
|
112
|
+
addHandler(captured, event, handler as ForwardedHandler<"tool_execution_start">);
|
|
113
|
+
return;
|
|
114
|
+
case "tool_execution_end":
|
|
115
|
+
addHandler(captured, event, handler as ForwardedHandler<"tool_execution_end">);
|
|
116
|
+
return;
|
|
117
|
+
case "model_select":
|
|
118
|
+
addHandler(captured, event, handler as ForwardedHandler<"model_select">);
|
|
119
|
+
}
|
|
72
120
|
}
|
|
73
121
|
|
|
74
122
|
function addEventHandler(captured: CapturedHeavy, event: string, handler: EventHandler): void {
|
|
@@ -77,13 +125,13 @@ function addEventHandler(captured: CapturedHeavy, event: string, handler: EventH
|
|
|
77
125
|
captured.eventHandlers.set(event, handlers);
|
|
78
126
|
}
|
|
79
127
|
|
|
80
|
-
async function dispatchHandlers(captured: CapturedHeavy, eventName:
|
|
81
|
-
for (const handler of captured.handlers
|
|
128
|
+
async function dispatchHandlers<K extends LazyLifecycleEvent>(captured: CapturedHeavy, eventName: K, event: ForwardedEventMap[K], ctx: ExtensionContext): Promise<void> {
|
|
129
|
+
for (const handler of captured.handlers[eventName]) {
|
|
82
130
|
await handler(event, ctx);
|
|
83
131
|
}
|
|
84
132
|
}
|
|
85
133
|
|
|
86
|
-
async function dispatchEventHandlers(captured: CapturedHeavy, eventName: string, payload:
|
|
134
|
+
async function dispatchEventHandlers(captured: CapturedHeavy, eventName: string, payload: EventPayload): Promise<void> {
|
|
87
135
|
for (const handler of captured.eventHandlers.get(eventName) ?? []) {
|
|
88
136
|
await handler(payload);
|
|
89
137
|
}
|
|
@@ -99,8 +147,8 @@ function createHeavyProxy(pi: ExtensionAPI, captured: CapturedHeavy): ExtensionA
|
|
|
99
147
|
return (name: string, options: CapturedCommand) => captured.commands.set(name, options);
|
|
100
148
|
}
|
|
101
149
|
if (prop === "on") {
|
|
102
|
-
return (event:
|
|
103
|
-
|
|
150
|
+
return (event: LazyLifecycleEvent, handler: AnyForwardedHandler) => {
|
|
151
|
+
captureForwardedHandler(captured, event, handler);
|
|
104
152
|
};
|
|
105
153
|
}
|
|
106
154
|
if (prop === "registerShortcut") {
|
|
@@ -136,19 +184,19 @@ async function executeHeavyTool(
|
|
|
136
184
|
loadHeavy: (ctx?: ExtensionContext) => Promise<CapturedHeavy>,
|
|
137
185
|
name: string,
|
|
138
186
|
args: Parameters<NonNullable<ToolDefinition["execute"]>>,
|
|
139
|
-
): Promise<ReturnType<NonNullable<ToolDefinition["execute"]
|
|
187
|
+
): Promise<Awaited<ReturnType<NonNullable<ToolDefinition["execute"]>>>> {
|
|
140
188
|
const ctx = args[4];
|
|
141
189
|
const heavy = await loadHeavy(ctx);
|
|
142
190
|
const tool = heavy.tools.get(name);
|
|
143
191
|
if (!tool?.execute) throw new Error(`Intercom tool implementation not found: ${name}`);
|
|
144
|
-
return tool.execute(...args) as ReturnType<NonNullable<ToolDefinition["execute"]
|
|
192
|
+
return await tool.execute(...args) as Awaited<ReturnType<NonNullable<ToolDefinition["execute"]>>>;
|
|
145
193
|
}
|
|
146
194
|
|
|
147
|
-
async function runHeavyCommand(loadHeavy: (ctx?: ExtensionContext) => Promise<CapturedHeavy>, args: string | undefined, ctx:
|
|
195
|
+
async function runHeavyCommand(loadHeavy: (ctx?: ExtensionContext) => Promise<CapturedHeavy>, args: string | undefined, ctx: ExtensionCommandContext): Promise<void> {
|
|
148
196
|
const heavy = await loadHeavy(ctx);
|
|
149
197
|
const command = heavy.commands.get("intercom");
|
|
150
198
|
if (!command) throw new Error("Intercom command implementation not found");
|
|
151
|
-
await command.handler(args, ctx);
|
|
199
|
+
await command.handler(args ?? "", ctx);
|
|
152
200
|
}
|
|
153
201
|
|
|
154
202
|
function renderHeavyToolResult(loadedHeavy: CapturedHeavy | null, name: string, args: ToolRenderResultArgs): ReturnType<NonNullable<ToolDefinition["renderResult"]>> {
|
|
@@ -194,7 +242,7 @@ export default function intercom(pi: ExtensionAPI) {
|
|
|
194
242
|
const captured: CapturedHeavy = {
|
|
195
243
|
tools: new Map(),
|
|
196
244
|
commands: new Map(),
|
|
197
|
-
handlers:
|
|
245
|
+
handlers: createForwardedHandlerMap(),
|
|
198
246
|
shortcuts: new Map(),
|
|
199
247
|
eventHandlers: new Map(),
|
|
200
248
|
};
|
|
@@ -202,7 +250,7 @@ export default function intercom(pi: ExtensionAPI) {
|
|
|
202
250
|
await mod.default(createHeavyProxy(pi, captured));
|
|
203
251
|
loadedHeavy = captured;
|
|
204
252
|
if (!sessionSnapshot && ctx) {
|
|
205
|
-
sessionSnapshot = { event:
|
|
253
|
+
sessionSnapshot = { event: createSyntheticSessionStartEvent(), ctx, generation: ++lifecycleGeneration };
|
|
206
254
|
}
|
|
207
255
|
await replaySessionStart(captured);
|
|
208
256
|
return captured;
|
|
@@ -210,88 +258,72 @@ export default function intercom(pi: ExtensionAPI) {
|
|
|
210
258
|
}
|
|
211
259
|
const heavy = await heavyPromise;
|
|
212
260
|
if (!sessionSnapshot && ctx) {
|
|
213
|
-
sessionSnapshot = { event:
|
|
261
|
+
sessionSnapshot = { event: createSyntheticSessionStartEvent(), ctx, generation: ++lifecycleGeneration };
|
|
214
262
|
await replaySessionStart(heavy);
|
|
215
263
|
}
|
|
216
264
|
return heavy;
|
|
217
265
|
}
|
|
218
266
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
if (loadedHeavy) {
|
|
226
|
-
replayedGeneration = generation;
|
|
227
|
-
await dispatchHandlers(loadedHeavy, "session_start", event, ctx);
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
break;
|
|
231
|
-
case "session_shutdown":
|
|
232
|
-
pi.on("session_shutdown", async (event, ctx) => {
|
|
233
|
-
++lifecycleGeneration;
|
|
234
|
-
activeLifecycle.turnStart = null;
|
|
235
|
-
activeLifecycle.agentStart = null;
|
|
236
|
-
activeLifecycle.activeTools.clear();
|
|
237
|
-
activeLifecycle.modelSelect = null;
|
|
238
|
-
if (loadedHeavy) {
|
|
239
|
-
await dispatchHandlers(loadedHeavy, "session_shutdown", event, ctx);
|
|
240
|
-
}
|
|
241
|
-
sessionSnapshot = null;
|
|
242
|
-
replayedGeneration = lifecycleGeneration;
|
|
243
|
-
});
|
|
244
|
-
break;
|
|
245
|
-
case "turn_start":
|
|
246
|
-
pi.on("turn_start", async (event, ctx) => {
|
|
247
|
-
activeLifecycle.turnStart = { event, ctx };
|
|
248
|
-
if (loadedHeavy) await dispatchHandlers(loadedHeavy, "turn_start", event, ctx);
|
|
249
|
-
});
|
|
250
|
-
break;
|
|
251
|
-
case "turn_end":
|
|
252
|
-
pi.on("turn_end", async (event, ctx) => {
|
|
253
|
-
activeLifecycle.turnStart = null;
|
|
254
|
-
activeLifecycle.agentStart = null;
|
|
255
|
-
activeLifecycle.activeTools.clear();
|
|
256
|
-
if (loadedHeavy) await dispatchHandlers(loadedHeavy, "turn_end", event, ctx);
|
|
257
|
-
});
|
|
258
|
-
break;
|
|
259
|
-
case "agent_start":
|
|
260
|
-
pi.on("agent_start", async (event, ctx) => {
|
|
261
|
-
activeLifecycle.agentStart = { event, ctx };
|
|
262
|
-
activeLifecycle.activeTools.clear();
|
|
263
|
-
if (loadedHeavy) await dispatchHandlers(loadedHeavy, "agent_start", event, ctx);
|
|
264
|
-
});
|
|
265
|
-
break;
|
|
266
|
-
case "agent_end":
|
|
267
|
-
pi.on("agent_end", async (event, ctx) => {
|
|
268
|
-
activeLifecycle.agentStart = null;
|
|
269
|
-
activeLifecycle.activeTools.clear();
|
|
270
|
-
if (loadedHeavy) await dispatchHandlers(loadedHeavy, "agent_end", event, ctx);
|
|
271
|
-
});
|
|
272
|
-
break;
|
|
273
|
-
case "tool_execution_start":
|
|
274
|
-
pi.on("tool_execution_start", async (event, ctx) => {
|
|
275
|
-
const toolCallId = getToolCallId(event);
|
|
276
|
-
if (toolCallId) activeLifecycle.activeTools.set(toolCallId, { event, ctx });
|
|
277
|
-
if (loadedHeavy) await dispatchHandlers(loadedHeavy, "tool_execution_start", event, ctx);
|
|
278
|
-
});
|
|
279
|
-
break;
|
|
280
|
-
case "tool_execution_end":
|
|
281
|
-
pi.on("tool_execution_end", async (event, ctx) => {
|
|
282
|
-
const toolCallId = getToolCallId(event);
|
|
283
|
-
if (toolCallId) activeLifecycle.activeTools.delete(toolCallId);
|
|
284
|
-
if (loadedHeavy) await dispatchHandlers(loadedHeavy, "tool_execution_end", event, ctx);
|
|
285
|
-
});
|
|
286
|
-
break;
|
|
287
|
-
case "model_select":
|
|
288
|
-
pi.on("model_select", async (event, ctx) => {
|
|
289
|
-
activeLifecycle.modelSelect = { event, ctx };
|
|
290
|
-
if (loadedHeavy) await dispatchHandlers(loadedHeavy, "model_select", event, ctx);
|
|
291
|
-
});
|
|
292
|
-
break;
|
|
267
|
+
pi.on("session_start", async (event, ctx) => {
|
|
268
|
+
const generation = ++lifecycleGeneration;
|
|
269
|
+
sessionSnapshot = { event, ctx, generation };
|
|
270
|
+
if (loadedHeavy) {
|
|
271
|
+
replayedGeneration = generation;
|
|
272
|
+
await dispatchHandlers(loadedHeavy, "session_start", event, ctx);
|
|
293
273
|
}
|
|
294
|
-
}
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
pi.on("session_shutdown", async (event, ctx) => {
|
|
277
|
+
++lifecycleGeneration;
|
|
278
|
+
activeLifecycle.turnStart = null;
|
|
279
|
+
activeLifecycle.agentStart = null;
|
|
280
|
+
activeLifecycle.activeTools.clear();
|
|
281
|
+
activeLifecycle.modelSelect = null;
|
|
282
|
+
if (loadedHeavy) {
|
|
283
|
+
await dispatchHandlers(loadedHeavy, "session_shutdown", event, ctx);
|
|
284
|
+
}
|
|
285
|
+
sessionSnapshot = null;
|
|
286
|
+
replayedGeneration = lifecycleGeneration;
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
pi.on("turn_start", async (event, ctx) => {
|
|
290
|
+
activeLifecycle.turnStart = { event, ctx };
|
|
291
|
+
if (loadedHeavy) await dispatchHandlers(loadedHeavy, "turn_start", event, ctx);
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
pi.on("turn_end", async (event, ctx) => {
|
|
295
|
+
activeLifecycle.turnStart = null;
|
|
296
|
+
activeLifecycle.agentStart = null;
|
|
297
|
+
activeLifecycle.activeTools.clear();
|
|
298
|
+
if (loadedHeavy) await dispatchHandlers(loadedHeavy, "turn_end", event, ctx);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
pi.on("agent_start", async (event, ctx) => {
|
|
302
|
+
activeLifecycle.agentStart = { event, ctx };
|
|
303
|
+
activeLifecycle.activeTools.clear();
|
|
304
|
+
if (loadedHeavy) await dispatchHandlers(loadedHeavy, "agent_start", event, ctx);
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
pi.on("agent_end", async (event, ctx) => {
|
|
308
|
+
activeLifecycle.agentStart = null;
|
|
309
|
+
activeLifecycle.activeTools.clear();
|
|
310
|
+
if (loadedHeavy) await dispatchHandlers(loadedHeavy, "agent_end", event, ctx);
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
pi.on("tool_execution_start", async (event, ctx) => {
|
|
314
|
+
activeLifecycle.activeTools.set(event.toolCallId, { event, ctx });
|
|
315
|
+
if (loadedHeavy) await dispatchHandlers(loadedHeavy, "tool_execution_start", event, ctx);
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
pi.on("tool_execution_end", async (event, ctx) => {
|
|
319
|
+
activeLifecycle.activeTools.delete(event.toolCallId);
|
|
320
|
+
if (loadedHeavy) await dispatchHandlers(loadedHeavy, "tool_execution_end", event, ctx);
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
pi.on("model_select", async (event, ctx) => {
|
|
324
|
+
activeLifecycle.modelSelect = { event, ctx };
|
|
325
|
+
if (loadedHeavy) await dispatchHandlers(loadedHeavy, "model_select", event, ctx);
|
|
326
|
+
});
|
|
295
327
|
|
|
296
328
|
pi.registerShortcut("alt+m", {
|
|
297
329
|
description: "Open session intercom overlay",
|
|
@@ -322,7 +354,7 @@ export default function intercom(pi: ExtensionAPI) {
|
|
|
322
354
|
pi.registerTool({
|
|
323
355
|
name: "intercom",
|
|
324
356
|
label: "Intercom",
|
|
325
|
-
description: `Send a message to another
|
|
357
|
+
description: `Send a message to another local agent session running on this machine.
|
|
326
358
|
Use this to communicate findings, request help, or coordinate work with other sessions.
|
|
327
359
|
|
|
328
360
|
Usage:
|
|
@@ -332,7 +364,7 @@ Usage:
|
|
|
332
364
|
intercom({ action: "reply", message: "..." }) → Reply to the active/single pending ask
|
|
333
365
|
intercom({ action: "pending" }) → List unresolved inbound asks
|
|
334
366
|
intercom({ action: "status" }) → Show connection status`,
|
|
335
|
-
promptSnippet: "Use to coordinate with other local
|
|
367
|
+
promptSnippet: "Use to coordinate with other local agent sessions: list peers, send updates, ask for help, or check intercom connectivity.",
|
|
336
368
|
parameters: Type.Object({
|
|
337
369
|
action: Type.String({ description: "Action: 'list', 'send', 'ask', 'reply', 'pending', or 'status'" }),
|
|
338
370
|
to: Type.Optional(Type.String({ description: "Target session name or ID (for 'send', 'ask', or disambiguating 'reply')" })),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@bastani/atomic";
|
|
2
2
|
import { randomUUID } from "crypto";
|
|
3
3
|
import { Type } from "typebox";
|
|
4
|
-
import { Text } from "@
|
|
4
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
5
5
|
import type { IntercomClient } from "./broker/client.ts";
|
|
6
6
|
import type { Message } from "./types.ts";
|
|
7
7
|
import { renderIntercomResult } from "./result-renderers.js";
|
|
@@ -30,7 +30,7 @@ export function registerIntercomTool(pi: ExtensionAPI, deps: IntercomToolDeps):
|
|
|
30
30
|
pi.registerTool({
|
|
31
31
|
name: "intercom",
|
|
32
32
|
label: "Intercom",
|
|
33
|
-
description: `Send a message to another
|
|
33
|
+
description: `Send a message to another local agent session running on this machine.
|
|
34
34
|
Use this to communicate findings, request help, or coordinate work with other sessions.
|
|
35
35
|
|
|
36
36
|
Usage:
|
|
@@ -41,7 +41,7 @@ Usage:
|
|
|
41
41
|
intercom({ action: "pending" }) → List unresolved inbound asks
|
|
42
42
|
intercom({ action: "status" }) → Show connection status`,
|
|
43
43
|
promptSnippet:
|
|
44
|
-
"Use to coordinate with other local
|
|
44
|
+
"Use to coordinate with other local agent sessions: list peers, send updates, ask for help, or check intercom connectivity.",
|
|
45
45
|
|
|
46
46
|
parameters: Type.Object({
|
|
47
47
|
action: Type.String({
|
|
@@ -104,6 +104,7 @@ Usage:
|
|
|
104
104
|
return {
|
|
105
105
|
content: [{ type: "text", text: `${currentSection}\n\n${otherSection}` }],
|
|
106
106
|
isError: false,
|
|
107
|
+
details: {},
|
|
107
108
|
};
|
|
108
109
|
} catch (error) {
|
|
109
110
|
return {
|
|
@@ -141,6 +142,7 @@ Usage:
|
|
|
141
142
|
return {
|
|
142
143
|
content: [{ type: "text", text: "Message cancelled by user" }],
|
|
143
144
|
isError: false,
|
|
145
|
+
details: {},
|
|
144
146
|
};
|
|
145
147
|
}
|
|
146
148
|
}
|
|
@@ -268,6 +270,7 @@ Usage:
|
|
|
268
270
|
return {
|
|
269
271
|
content: [{ type: "text", text: `**Reply from ${to}:**\n${replyText}${replyAttachments}` }],
|
|
270
272
|
isError: false,
|
|
273
|
+
details: {},
|
|
271
274
|
};
|
|
272
275
|
} catch (error) {
|
|
273
276
|
rejectReplyWaiter(toError(error));
|
|
@@ -343,6 +346,7 @@ Usage:
|
|
|
343
346
|
return {
|
|
344
347
|
content: [{ type: "text", text: "No unresolved inbound asks." }],
|
|
345
348
|
isError: false,
|
|
349
|
+
details: {},
|
|
346
350
|
};
|
|
347
351
|
}
|
|
348
352
|
|
|
@@ -355,6 +359,7 @@ Usage:
|
|
|
355
359
|
return {
|
|
356
360
|
content: [{ type: "text", text: `**Pending asks:**\n${lines.join("\n")}` }],
|
|
357
361
|
isError: false,
|
|
362
|
+
details: {},
|
|
358
363
|
};
|
|
359
364
|
}
|
|
360
365
|
|
|
@@ -368,6 +373,7 @@ Usage:
|
|
|
368
373
|
text: `**Intercom Status:**\nConnected: Yes\nSession ID: ${mySessionId}\nActive sessions: ${sessions.length}`,
|
|
369
374
|
}],
|
|
370
375
|
isError: false,
|
|
376
|
+
details: {},
|
|
371
377
|
};
|
|
372
378
|
} catch (error) {
|
|
373
379
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bastani/intercom",
|
|
3
|
-
"version": "0.9.5-alpha.
|
|
3
|
+
"version": "0.9.5-alpha.9",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Atomic extension providing a private coordination channel between parent and child agent sessions. Fork of: https://github.com/nicobailon/pi-intercom",
|
|
6
6
|
"contributors": [
|
|
@@ -29,6 +29,14 @@
|
|
|
29
29
|
"CHANGELOG.md",
|
|
30
30
|
"LICENSE"
|
|
31
31
|
],
|
|
32
|
+
"atomic": {
|
|
33
|
+
"extensions": [
|
|
34
|
+
"./index.ts"
|
|
35
|
+
],
|
|
36
|
+
"skills": [
|
|
37
|
+
"./skills"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
32
40
|
"pi": {
|
|
33
41
|
"extensions": [
|
|
34
42
|
"./index.ts"
|
|
@@ -50,6 +58,7 @@
|
|
|
50
58
|
}
|
|
51
59
|
},
|
|
52
60
|
"dependencies": {
|
|
61
|
+
"tsx": "^4.20.6",
|
|
53
62
|
"typebox": "^1.1.24"
|
|
54
63
|
}
|
|
55
64
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ToolDefinition } from "@bastani/atomic";
|
|
2
|
-
import { Text } from "@
|
|
2
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
3
3
|
|
|
4
4
|
type ToolResultRenderer = NonNullable<ToolDefinition["renderResult"]>;
|
|
5
5
|
type ToolRenderResultArgs = Parameters<ToolResultRenderer>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Component, TUI } from "@
|
|
2
|
-
import { truncateToWidth, visibleWidth } from "@
|
|
1
|
+
import type { Component, TUI } from "@earendil-works/pi-tui";
|
|
2
|
+
import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
3
3
|
import type { KeybindingsManager, Theme } from "@bastani/atomic";
|
|
4
4
|
import type { IntercomClient } from "../broker/client.js";
|
|
5
5
|
import type { SessionInfo } from "../types.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Component } from "@
|
|
2
|
-
import { truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@
|
|
1
|
+
import type { Component } from "@earendil-works/pi-tui";
|
|
2
|
+
import { truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
3
3
|
import type { Theme } from "@bastani/atomic";
|
|
4
4
|
import type { SessionInfo, Message } from "../types.js";
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Component } from "@
|
|
2
|
-
import { truncateToWidth, visibleWidth } from "@
|
|
1
|
+
import type { Component } from "@earendil-works/pi-tui";
|
|
2
|
+
import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
3
3
|
import type { KeybindingsManager, Theme } from "@bastani/atomic";
|
|
4
4
|
import type { SessionInfo } from "../types.js";
|
|
5
5
|
|
|
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.9.5-alpha.9] - 2026-07-09
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Improved startup responsiveness by keeping first-run/default lazy MCP metadata bootstrap out of `initializeMcp()`'s synchronous path. Cached direct tools and the MCP proxy still register immediately, explicit `eager`/`keep-alive` servers still connect during initialization, missing configured or `MCP_DIRECT_TOOLS`-selected direct-tool metadata is warmed in the background, and explicit proxy `search`, `describe`, and server-list requests hydrate cold-cache lazy server metadata on demand instead of broadening startup warmup. Warmed direct tools are registered live in the current session after metadata refresh rather than requiring restart. Cold-cache `describe` first narrows hydration to prefix-matched or explicitly requested servers, treats hyphen/underscore prefixes as aliases, and does not fan out to unrelated lazy servers after a prefix-directed miss; cold-cache proxy `search` intentionally hydrates all matching lazy servers so unscoped searches can see every configured tool.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Aligned MCP tool result expansion hints with the CLI-wide `Ctrl+o` keybinding copy.
|
|
19
|
+
- Fixed MCP background direct-tool warmup cancellation so stale in-flight connects are discarded before metadata/cache mutation, direct-tool refresh callbacks are guarded to the active session, completed warmups clear their active handle safely, and env-selected direct tool servers hydrate without forcing every lazy server eager.
|
|
20
|
+
|
|
10
21
|
## [0.9.4] - 2026-07-03
|
|
11
22
|
|
|
12
23
|
### Changed
|
|
@@ -65,7 +65,7 @@ Precedence is:
|
|
|
65
65
|
3. `.mcp.json`
|
|
66
66
|
4. `.pi/mcp.json`
|
|
67
67
|
|
|
68
|
-
Servers are **lazy by default** — they won't connect until you actually call one of their tools. The adapter caches tool metadata so search and describe work without live connections.
|
|
68
|
+
Servers are **lazy by default** — they won't connect until you actually call one of their tools. The adapter caches tool metadata so search and describe work without live connections when a valid cache exists; on a cold cache, explicit proxy search/describe/server-list requests may connect lazy server(s) once to hydrate metadata on demand. `describe` narrows cold-cache hydration to an explicitly requested server or the server identified by the configured tool-name prefix before falling back to broader discovery. Unscoped `search` intentionally hydrates every configured lazy server that lacks cached metadata so the search can see all available tools.
|
|
69
69
|
|
|
70
70
|
```
|
|
71
71
|
mcp({ search: "screenshot" })
|
|
@@ -136,7 +136,7 @@ Pi-specific files are the write targets for imported or shared global servers wh
|
|
|
136
136
|
|
|
137
137
|
### Lifecycle Modes
|
|
138
138
|
|
|
139
|
-
- **`lazy`** (default) — Don't connect at startup. Connect on first tool call. Disconnect after idle timeout. Cached metadata keeps search/list working without connections.
|
|
139
|
+
- **`lazy`** (default) — Don't connect at startup. Connect on first tool call or explicit cold-cache proxy metadata request (`search`, `describe`, or `server` list). Disconnect after idle timeout. Cached metadata keeps search/list working without connections.
|
|
140
140
|
- **`eager`** — Connect at startup but don't auto-reconnect if the connection drops. No idle timeout by default (set `idleTimeout` explicitly to enable).
|
|
141
141
|
- **`keep-alive`** — Connect at startup. Auto-reconnect via health checks. No idle timeout. Use for servers you always need available.
|
|
142
142
|
|
|
@@ -232,7 +232,7 @@ To exclude specific tools while still using `directTools: true`, add `excludeToo
|
|
|
232
232
|
|
|
233
233
|
Each direct tool costs ~150-300 tokens in the system prompt (name + description + schema). Good for targeted sets of 5-20 tools. For servers with 75+ tools, stick with the proxy or pick specific tools with a `string[]`.
|
|
234
234
|
|
|
235
|
-
Direct tools register from the metadata cache in the Pi agent dir (`~/.pi/agent/mcp-cache.json` by default, or `$PI_CODING_AGENT_DIR/mcp-cache.json` when set), so no server connections are needed at startup. On the first session after adding `directTools` to a new server, the cache
|
|
235
|
+
Direct tools register from the metadata cache in the Pi agent dir (`~/.pi/agent/mcp-cache.json` by default, or `$PI_CODING_AGENT_DIR/mcp-cache.json` when set), so no server connections are needed at startup when the cache is warm. On the first session after adding `directTools` to a new server, or when a child/subagent selects tools through `MCP_DIRECT_TOOLS`, the cache may not exist yet — tools fall back to proxy-only while the selected/configured direct-tool servers populate in the background, then the extension refreshes tool registration so the warmed direct tools become available in the current session. To force it immediately: `/mcp reconnect <server>`.
|
|
236
236
|
|
|
237
237
|
When you change direct-tool toggles in `/mcp` or write new config through `/mcp setup`, the extension triggers Pi's normal reload flow automatically. That refreshes extensions, prompts, skills, and MCP tool registration in one shot, so newly configured direct tools can appear without a manual restart.
|
|
238
238
|
|
|
@@ -332,7 +332,7 @@ Prefer `.mcp.json` for project-local shared MCP config. Use `.pi/mcp.json` only
|
|
|
332
332
|
| Connect | `mcp({ connect: "server-name" })` |
|
|
333
333
|
| UI messages | `mcp({ action: "ui-messages" })` |
|
|
334
334
|
|
|
335
|
-
MCP proxy and direct-tool results render compactly by default: long text shows the first three lines plus a `
|
|
335
|
+
MCP proxy and direct-tool results render compactly by default: long text shows the first three lines plus a `Ctrl+o Expand` hint, while the full result remains available when expanded and is still returned unchanged to the model.
|
|
336
336
|
|
|
337
337
|
Search includes both MCP tools and Pi tools (from extensions). Pi tools appear first with `[pi tool]` prefix. Space-separated words are OR'd.
|
|
338
338
|
|
|
@@ -358,8 +358,8 @@ In interactive sessions, you can also authenticate from `/mcp` with `CTRL+A` or
|
|
|
358
358
|
## How It Works
|
|
359
359
|
|
|
360
360
|
- One `mcp` tool in context (~200 tokens) instead of hundreds
|
|
361
|
-
- Servers are lazy by default — they connect on first tool call, not at startup
|
|
362
|
-
- Tool metadata is cached to disk so search/list/describe work without live connections
|
|
361
|
+
- Servers are lazy by default — they connect on first tool call or explicit cold-cache proxy metadata request, not at startup
|
|
362
|
+
- Tool metadata is cached to disk so search/list/describe work without live connections when the cache is valid; cold-cache explicit search/describe/server-list requests hydrate metadata on demand
|
|
363
363
|
- Idle servers disconnect after 10 minutes (configurable), reconnect automatically on next use
|
|
364
364
|
- npx-based servers resolve to direct binary paths, skipping the ~143 MB npm parent process
|
|
365
365
|
- MCP server validates arguments, not the adapter
|