@selesai/code 0.13.15 → 0.13.18
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 +37 -0
- package/README.md +2 -14
- package/dist/bun/cli.d.ts +3 -1
- package/dist/bun/cli.js +3 -9
- package/dist/bun/{register-bedrock.js → runtime-setup.js} +5 -0
- package/dist/bun/sandbox-env-setup.d.ts +1 -0
- package/dist/bun/sandbox-env-setup.js +3 -0
- package/dist/cli/auth-command.d.ts +23 -0
- package/dist/cli/auth-command.js +102 -0
- package/dist/cli/config-selector.js +2 -1
- package/dist/cli/setup.d.ts +1 -0
- package/dist/cli/setup.js +11 -0
- package/dist/cli.js +2 -14
- package/dist/config.d.ts +3 -2
- package/dist/config.js +9 -4
- package/dist/core/agent-session-runtime.js +15 -7
- package/dist/core/agent-session.d.ts +2 -6
- package/dist/core/agent-session.js +15 -4
- package/dist/core/compaction/branch-summarization.d.ts +1 -1
- package/dist/core/compaction/branch-summarization.js +2 -1
- package/dist/core/extensions/loader.js +3 -0
- package/dist/core/extensions/types.d.ts +16 -2
- package/dist/core/http-dispatcher.js +2 -0
- package/dist/core/keybindings.d.ts +5 -0
- package/dist/core/keybindings.js +4 -0
- package/dist/core/messages.d.ts +1 -1
- package/dist/core/model-config.d.ts +15 -0
- package/dist/core/model-config.js +3 -0
- package/dist/core/model-runtime.d.ts +1 -0
- package/dist/core/model-runtime.js +5 -2
- package/dist/core/provider-composer.js +8 -2
- package/dist/core/session-export.d.ts +3 -0
- package/dist/core/session-export.js +31 -0
- package/dist/core/session-manager.d.ts +3 -2
- package/dist/core/session-manager.js +40 -13
- package/dist/core/skills.d.ts +1 -1
- package/dist/core/skills.js +4 -2
- package/dist/core/system-prompt.js +10 -10
- package/dist/core/tools/bash.js +3 -117
- package/dist/core/tools/edit.d.ts +1 -12
- package/dist/core/tools/edit.js +5 -163
- package/dist/core/tools/find.js +4 -55
- package/dist/core/tools/grep.js +4 -60
- package/dist/core/tools/ls.js +4 -49
- package/dist/core/tools/read.d.ts +4 -0
- package/dist/core/tools/read.js +10 -122
- package/dist/core/tools/renderers/bash.d.ts +11 -0
- package/dist/core/tools/renderers/bash.js +129 -0
- package/dist/core/tools/renderers/edit.d.ts +22 -0
- package/dist/core/tools/renderers/edit.js +166 -0
- package/dist/core/tools/renderers/find.d.ts +9 -0
- package/dist/core/tools/renderers/find.js +63 -0
- package/dist/core/tools/renderers/grep.d.ts +9 -0
- package/dist/core/tools/renderers/grep.js +68 -0
- package/dist/core/tools/renderers/index.d.ts +27 -0
- package/dist/core/tools/renderers/index.js +46 -0
- package/dist/core/tools/renderers/ls.d.ts +9 -0
- package/dist/core/tools/renderers/ls.js +57 -0
- package/dist/core/tools/renderers/read.d.ts +10 -0
- package/dist/core/tools/renderers/read.js +128 -0
- package/dist/core/tools/renderers/write.d.ts +9 -0
- package/dist/core/tools/renderers/write.js +152 -0
- package/dist/core/tools/write.js +5 -146
- package/dist/extensions/capability-gateway/index.ts +12 -1
- package/dist/extensions/capability-gateway/integration.test.ts +23 -0
- package/dist/extensions/pi-hermes-memory/CHANGELOG.md +18 -0
- package/dist/extensions/pi-hermes-memory/README.md +16 -12
- package/dist/extensions/pi-hermes-memory/docs/ROADMAP.md +1 -1
- package/dist/extensions/pi-hermes-memory/package-lock.json +587 -62
- package/dist/extensions/pi-hermes-memory/package.json +4 -4
- package/dist/extensions/pi-hermes-memory/src/config.ts +32 -0
- package/dist/extensions/pi-hermes-memory/src/constants.ts +12 -2
- package/dist/extensions/pi-hermes-memory/src/handlers/background-review.ts +109 -51
- package/dist/extensions/pi-hermes-memory/src/handlers/index-sessions.ts +9 -3
- package/dist/extensions/pi-hermes-memory/src/handlers/review-memory-ops.ts +257 -98
- package/dist/extensions/pi-hermes-memory/src/handlers/session-backfill.ts +9 -2
- package/dist/extensions/pi-hermes-memory/src/handlers/sync-markdown-memories.ts +5 -0
- package/dist/extensions/pi-hermes-memory/src/index.ts +22 -2
- package/dist/extensions/pi-hermes-memory/src/paths.ts +1 -1
- package/dist/extensions/pi-hermes-memory/src/store/db.ts +6 -0
- package/dist/extensions/pi-hermes-memory/src/store/fts-query.ts +58 -1
- package/dist/extensions/pi-hermes-memory/src/store/memory-store.ts +60 -8
- package/dist/extensions/pi-hermes-memory/src/store/session-indexer.ts +169 -7
- package/dist/extensions/pi-hermes-memory/src/store/session-search.ts +7 -21
- package/dist/extensions/pi-hermes-memory/src/store/sqlite-memory-store.ts +134 -15
- package/dist/extensions/pi-hermes-memory/src/tools/memory-search-tool.ts +4 -2
- package/dist/extensions/pi-hermes-memory/src/tools/memory-tool.ts +24 -9
- package/dist/extensions/pi-hermes-memory/src/types.ts +11 -0
- package/dist/extensions/pi-hermes-memory/tests/config.test.ts +42 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/background-review.test.ts +159 -3
- package/dist/extensions/pi-hermes-memory/tests/handlers/review-memory-ops.test.ts +452 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/session-backfill.test.ts +39 -0
- package/dist/extensions/pi-hermes-memory/tests/integration/corruption-recovery-integration.test.ts +91 -0
- package/dist/extensions/pi-hermes-memory/tests/store/db.test.ts +29 -0
- package/dist/extensions/pi-hermes-memory/tests/store/fts-query.test.ts +116 -0
- package/dist/extensions/pi-hermes-memory/tests/store/memory-store.test.ts +163 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-indexer.test.ts +233 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-search.test.ts +12 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-memory-store.test.ts +175 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-native.test.ts +2 -2
- package/dist/extensions/pi-hermes-memory/tests/tools/memory-search-tool.test.ts +22 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/memory-tool.test.ts +37 -1
- package/dist/extensions/pi-intercom/CHANGELOG.md +13 -0
- package/dist/extensions/pi-intercom/README.md +16 -2
- package/dist/extensions/pi-intercom/broker/spawn.test.ts +19 -2
- package/dist/extensions/pi-intercom/broker/spawn.ts +4 -4
- package/dist/extensions/pi-intercom/index.ts +1 -1
- package/dist/extensions/pi-intercom/intercom.integration.test.ts +121 -2
- package/dist/extensions/pi-intercom/package.json +1 -1
- package/dist/extensions/pi-intercom/project-agent.test.ts +1 -1
- package/dist/extensions/pi-intercom/project-agent.ts +1 -6
- package/dist/extensions/pi-intercom/skills/pi-intercom/SKILL.md +7 -6
- package/dist/extensions/pi-rewind-hook/index.test.ts +7 -0
- package/dist/extensions/pi-subagents/.github/workflows/test.yml +36 -4
- package/dist/extensions/pi-subagents/CHANGELOG.md +120 -0
- package/dist/extensions/pi-subagents/README.md +3 -3
- package/dist/extensions/pi-subagents/agents/researcher.md +23 -13
- package/dist/extensions/pi-subagents/agents/reviewer.md +1 -1
- package/dist/extensions/pi-subagents/agents/scout.md +1 -1
- package/dist/extensions/pi-subagents/docs/agents.md +32 -16
- package/dist/extensions/pi-subagents/docs/configuration.md +41 -15
- package/dist/extensions/pi-subagents/docs/extension-api.md +109 -6
- package/dist/extensions/pi-subagents/docs/missions.md +2 -0
- package/dist/extensions/pi-subagents/docs/models.md +58 -1
- package/dist/extensions/pi-subagents/docs/observability.md +50 -12
- package/dist/extensions/pi-subagents/docs/tool-reference.md +17 -10
- package/dist/extensions/pi-subagents/docs/watchdog.md +1 -1
- package/dist/extensions/pi-subagents/docs/workflows.md +26 -9
- package/dist/extensions/pi-subagents/package-lock.json +747 -177
- package/dist/extensions/pi-subagents/package.json +6 -4
- package/dist/extensions/pi-subagents/runner-server-preload.mjs +13 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +2 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/constraints-and-recipes.md +1 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md +21 -4
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/management-authoring-rpc.md +2 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/multi-lane-orchestration.md +2 -0
- package/dist/extensions/pi-subagents/src/agents/advertised-agent-prompt.ts +63 -0
- package/dist/extensions/pi-subagents/src/agents/agent-management.ts +61 -16
- package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +2 -0
- package/dist/extensions/pi-subagents/src/agents/agents.ts +8 -0
- package/dist/extensions/pi-subagents/src/api/capability-ceiling.ts +0 -1
- package/dist/extensions/pi-subagents/src/api/{pi-args.ts → child-tool-plan.ts} +1 -1
- package/dist/extensions/pi-subagents/src/api/preflight.ts +7 -4
- package/dist/extensions/pi-subagents/src/api/shared-types.ts +2 -2
- package/dist/extensions/pi-subagents/src/api/workflow-resources.ts +6 -0
- package/dist/extensions/pi-subagents/src/extension/config.ts +4 -2
- package/dist/extensions/pi-subagents/src/extension/doctor.ts +2 -10
- package/dist/extensions/pi-subagents/src/extension/fanout-child.ts +9 -11
- package/dist/extensions/pi-subagents/src/extension/index.ts +99 -10
- package/dist/extensions/pi-subagents/src/extension/public-execution.ts +13 -0
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +7 -23
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +11 -8
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +25 -7
- package/dist/extensions/pi-subagents/src/integrations/pi-web-session-liveness.ts +73 -0
- package/dist/extensions/pi-subagents/src/intercom/native-supervisor-channel.ts +228 -136
- package/dist/extensions/pi-subagents/src/intercom/supervisor-ui.ts +244 -0
- package/dist/extensions/pi-subagents/src/missions/workflow-state.ts +37 -16
- package/dist/extensions/pi-subagents/src/runs/background/active-async-capacity.ts +18 -18
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +51 -25
- package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +46 -3
- package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +14 -3
- package/dist/extensions/pi-subagents/src/runs/background/async-retention.ts +9 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-status-snapshot.ts +10 -12
- package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +18 -15
- package/dist/extensions/pi-subagents/src/runs/background/auto-drain.ts +40 -29
- package/dist/extensions/pi-subagents/src/runs/background/chain-root-attachment.ts +8 -0
- package/dist/extensions/pi-subagents/src/runs/background/control-channel.ts +79 -247
- package/dist/extensions/pi-subagents/src/runs/background/notify.ts +88 -12
- package/dist/extensions/pi-subagents/src/runs/background/owned-process-tree.ts +6 -6
- package/dist/extensions/pi-subagents/src/runs/background/process-terminal.ts +24 -24
- package/dist/extensions/pi-subagents/src/runs/background/retained-nested-route-tracker.ts +96 -0
- package/dist/extensions/pi-subagents/src/runs/background/run-child-session.ts +642 -0
- package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +75 -6
- package/dist/extensions/pi-subagents/src/runs/background/runner-aliases.ts +163 -0
- package/dist/extensions/pi-subagents/src/runs/background/runner-child-launch.ts +86 -0
- package/dist/extensions/pi-subagents/src/runs/background/runner-child-sessions.ts +31 -0
- package/dist/extensions/pi-subagents/src/runs/background/scheduled-runs.ts +18 -4
- package/dist/extensions/pi-subagents/src/runs/background/stale-run-reconciler.ts +3 -1
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +597 -1092
- package/dist/extensions/pi-subagents/src/runs/background/subagent-wait.ts +3 -0
- package/dist/extensions/pi-subagents/src/runs/background/wait-completions.ts +4 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/async-steering-action.ts +20 -17
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +296 -394
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-control.ts +4 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-history.ts +3 -1
- package/dist/extensions/pi-subagents/src/runs/foreground/prompt-audit.ts +9 -5
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +630 -283
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-detach-reconcile.ts +8 -5
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-foreground-steering.ts +78 -98
- package/dist/extensions/pi-subagents/src/runs/shared/abort-recovery.ts +3 -3
- package/dist/extensions/pi-subagents/src/runs/shared/acceptance.ts +16 -3
- package/dist/extensions/pi-subagents/src/runs/shared/agent-contract.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/async-status-projection.ts +47 -47
- package/dist/extensions/pi-subagents/src/runs/shared/capability-ceiling.ts +1 -2
- package/dist/extensions/pi-subagents/src/runs/shared/child-hooks.ts +174 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-identity.ts +14 -3
- package/dist/extensions/pi-subagents/src/runs/shared/child-launch.ts +319 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-lifecycle.ts +25 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-runtime-config.ts +126 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-session.ts +373 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-tool-plan.ts +530 -0
- package/dist/extensions/pi-subagents/src/runs/shared/completion-evidence.ts +2 -2
- package/dist/extensions/pi-subagents/src/runs/shared/completion-guard.ts +2 -1
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-preflight.ts +16 -0
- package/dist/extensions/pi-subagents/src/runs/shared/host-step-status.ts +11 -11
- package/dist/extensions/pi-subagents/src/runs/shared/llm-intent-arbiter.ts +30 -20
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +5 -4
- package/dist/extensions/pi-subagents/src/runs/shared/model-exclusions.ts +84 -15
- package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +88 -12
- package/dist/extensions/pi-subagents/src/runs/shared/nested-events.ts +37 -53
- package/dist/extensions/pi-subagents/src/runs/shared/nested-path.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/orca-progress-tabs.ts +18 -7
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-handoff.ts +57 -12
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +3 -4
- package/dist/extensions/pi-subagents/src/runs/shared/permissions.ts +0 -11
- package/dist/extensions/pi-subagents/src/runs/shared/process-signal.ts +4 -1
- package/dist/extensions/pi-subagents/src/runs/shared/readonly-drain-observation.ts +42 -0
- package/dist/extensions/pi-subagents/src/runs/shared/readonly-model-continuation.ts +69 -0
- package/dist/extensions/pi-subagents/src/runs/shared/readonly-session-evidence.ts +307 -0
- package/dist/extensions/pi-subagents/src/runs/shared/run-fanout-budget.ts +8 -21
- package/dist/extensions/pi-subagents/src/runs/shared/runtime-acknowledged-extensions.ts +3 -30
- package/dist/extensions/pi-subagents/src/runs/shared/structured-output.ts +17 -4
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-control.ts +2 -0
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +99 -386
- package/dist/extensions/pi-subagents/src/runs/shared/tool-availability.ts +18 -62
- package/dist/extensions/pi-subagents/src/runs/shared/tool-budget.ts +0 -14
- package/dist/extensions/pi-subagents/src/runs/shared/worktree-cleanup-plan.ts +31 -9
- package/dist/extensions/pi-subagents/src/runs/shared/worktree-setup-command.ts +190 -0
- package/dist/extensions/pi-subagents/src/runs/shared/worktree.ts +506 -226
- package/dist/extensions/pi-subagents/src/shared/child-session-name.ts +1 -1
- package/dist/extensions/pi-subagents/src/shared/jsonl-writer.ts +11 -0
- package/dist/extensions/pi-subagents/src/shared/model-response-aliases.ts +13 -0
- package/dist/extensions/pi-subagents/src/shared/thinking-ceiling.ts +0 -6
- package/dist/extensions/pi-subagents/src/shared/types.ts +145 -89
- package/dist/extensions/pi-subagents/src/shared/utils.ts +13 -6
- package/dist/extensions/pi-subagents/src/shared/watch-strategy.ts +2 -0
- package/dist/extensions/pi-subagents/src/shared/workflow-child-permit.ts +18 -13
- package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +0 -6
- package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +1 -1
- package/dist/extensions/pi-subagents/src/tui/fleet.ts +11 -6
- package/dist/extensions/pi-subagents/src/tui/render.ts +277 -46
- package/dist/extensions/pi-subagents/src/watchdog/child-status.ts +0 -1
- package/dist/extensions/pi-subagents/src/watchdog/register-child.ts +12 -12
- package/dist/extensions/pi-subagents/src/workflows/chat-progress.ts +3 -3
- package/dist/extensions/pi-subagents/src/workflows/scripted-workflow.ts +116 -15
- package/dist/extensions/pi-subagents/src/workflows/workflow-checklist.ts +15 -18
- package/dist/extensions/pi-subagents/src/workflows/workflow-child-summary.ts +57 -8
- package/dist/extensions/pi-subagents/src/workflows/workflow-preflight.ts +19 -19
- package/dist/extensions/pi-subagents/src/workflows/workflow-receipt.ts +3 -3
- package/dist/extensions/pi-subagents/src/workflows/workflow-resources.ts +97 -22
- package/dist/extensions/pi-subagents/src/workflows/workflow-settlement.ts +3 -0
- package/dist/extensions/pi-subagents/test/integration/acceptance-file-report.test.ts +336 -21
- package/dist/extensions/pi-subagents/test/integration/async-execution.part-1.test.ts +1181 -0
- package/dist/extensions/pi-subagents/test/integration/async-execution.part-2.test.ts +2240 -0
- package/dist/extensions/pi-subagents/test/integration/async-execution.part-3.test.ts +2268 -0
- package/dist/extensions/pi-subagents/test/integration/async-execution.part-4.test.ts +1512 -0
- package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +231 -16
- package/dist/extensions/pi-subagents/test/integration/error-handling.test.ts +4 -18
- package/dist/extensions/pi-subagents/test/integration/foreign-workflow-steering.test.ts +95 -0
- package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +9 -15
- package/dist/extensions/pi-subagents/test/integration/in-process-child.test.ts +374 -0
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +20 -10
- package/dist/extensions/pi-subagents/test/integration/orca-progress-tabs.test.ts +18 -6
- package/dist/extensions/pi-subagents/test/integration/recovered-assistant-error.test.ts +151 -0
- package/dist/extensions/pi-subagents/test/integration/render-fork-badge.test.ts +42 -1
- package/dist/extensions/pi-subagents/test/integration/render-widget.test.ts +150 -25
- package/dist/extensions/pi-subagents/test/integration/result-publication.test.ts +354 -0
- package/dist/extensions/pi-subagents/test/integration/shared-cwd-terminal-evidence.test.ts +117 -0
- package/dist/extensions/pi-subagents/test/integration/single-execution.part-1.test.ts +3678 -0
- package/dist/extensions/pi-subagents/test/integration/{single-execution.test.ts → single-execution.part-2.test.ts} +500 -4207
- package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +1 -2
- package/dist/extensions/pi-subagents/test/integration/workflow-result-publication.test.ts +127 -0
- package/dist/extensions/pi-subagents/test/integration/workflow-steer-inbox.test.ts +365 -0
- package/dist/extensions/pi-subagents/test/smoke/pi085-child.ts +31 -0
- package/dist/extensions/pi-subagents/test/smoke/pi085-clean-install.mjs +74 -0
- package/dist/extensions/pi-subagents/test/smoke/pi085-extension.ts +16 -0
- package/dist/extensions/pi-subagents/test/support/async-execution-fixture.ts +699 -0
- package/dist/extensions/pi-subagents/test/support/fake-child-session.ts +418 -0
- package/dist/extensions/pi-subagents/test/support/foreign-workflow-steer-host.mjs +13 -0
- package/dist/extensions/pi-subagents/test/support/mock-pi.ts +30 -76
- package/dist/extensions/pi-subagents/test/support/notify-diagnostics-fixture.ts +84 -0
- package/dist/extensions/pi-subagents/test/support/result-publication-capacity-preload.mjs +70 -0
- package/dist/extensions/pi-subagents/test/support/runner-child-session-factory.ts +17 -0
- package/dist/extensions/pi-subagents/test/support/single-execution-fixture.ts +390 -0
- package/dist/extensions/pi-subagents/test/unit/acceptance-compaction.test.ts +120 -0
- package/dist/extensions/pi-subagents/test/unit/acceptance.test.ts +24 -3
- package/dist/extensions/pi-subagents/test/unit/advertised-agent-prompt.test.ts +87 -0
- package/dist/extensions/pi-subagents/test/unit/advertised-agent-refresh.test.ts +163 -0
- package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +70 -31
- package/dist/extensions/pi-subagents/test/unit/agent-management.test.ts +78 -3
- package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +2 -8
- package/dist/extensions/pi-subagents/test/unit/async-execution.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/async-interrupt-action.test.ts +73 -66
- package/dist/extensions/pi-subagents/test/unit/async-recovery-descriptor.test.ts +51 -1
- package/dist/extensions/pi-subagents/test/unit/async-retention.test.ts +49 -1
- package/dist/extensions/pi-subagents/test/unit/async-spawn-preload.test.ts +103 -0
- package/dist/extensions/pi-subagents/test/unit/async-status-projection.test.ts +3 -3
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling-agent-allowlist.test.ts +9 -8
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling.test.ts +10 -7
- package/dist/extensions/pi-subagents/test/unit/chain-root-attachment.test.ts +48 -6
- package/dist/extensions/pi-subagents/test/unit/child-runtime-config.test.ts +90 -0
- package/dist/extensions/pi-subagents/test/unit/{pi-args-permission-system.test.ts → child-tool-plan-permission-system.test.ts} +48 -86
- package/dist/extensions/pi-subagents/test/unit/child-tool-plan.test.ts +33 -0
- package/dist/extensions/pi-subagents/test/unit/compaction-resume.test.ts +18 -18
- package/dist/extensions/pi-subagents/test/unit/completion-evidence.test.ts +9 -9
- package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +8 -7
- package/dist/extensions/pi-subagents/test/unit/control-channel.test.ts +225 -65
- package/dist/extensions/pi-subagents/test/unit/extension-bindings.test.ts +17 -22
- package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +11 -1
- package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +47 -3
- package/dist/extensions/pi-subagents/test/unit/foreign-workflow-steering.test.ts +74 -0
- package/dist/extensions/pi-subagents/test/unit/fork-cache-key.test.ts +23 -29
- package/dist/extensions/pi-subagents/test/unit/host-peer-runtime-imports.test.ts +96 -4
- package/dist/extensions/pi-subagents/test/unit/host-step-status.test.ts +4 -4
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +116 -55
- package/dist/extensions/pi-subagents/test/unit/index-segment.test.ts +58 -1
- package/dist/extensions/pi-subagents/test/unit/llm-intent-arbiter.test.ts +104 -3
- package/dist/extensions/pi-subagents/test/unit/mission-lifecycle.test.ts +10 -1
- package/dist/extensions/pi-subagents/test/unit/mission-store.test.ts +31 -1
- package/dist/extensions/pi-subagents/test/unit/model-exclusions.test.ts +102 -51
- package/dist/extensions/pi-subagents/test/unit/model-fallback.test.ts +196 -6
- package/dist/extensions/pi-subagents/test/unit/native-supervisor-channel.test.ts +181 -38
- package/dist/extensions/pi-subagents/test/unit/nested-control.test.ts +62 -70
- package/dist/extensions/pi-subagents/test/unit/nested-events.test.ts +58 -53
- package/dist/extensions/pi-subagents/test/unit/notify-diagnostics.test.ts +42 -0
- package/dist/extensions/pi-subagents/test/unit/notify.test.ts +84 -0
- package/dist/extensions/pi-subagents/test/unit/orca-progress-tabs.test.ts +13 -5
- package/dist/extensions/pi-subagents/test/unit/package-manifest.test.ts +21 -5
- package/dist/extensions/pi-subagents/test/unit/parallel-handoff.test.ts +5 -4
- package/dist/extensions/pi-subagents/test/unit/permissions.test.ts +2 -6
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +28 -2
- package/dist/extensions/pi-subagents/test/unit/pi-web-session-liveness.test.ts +209 -0
- package/dist/extensions/pi-subagents/test/unit/preflight.test.ts +38 -1
- package/dist/extensions/pi-subagents/test/unit/prompt-audit-optional-peers.test.ts +43 -0
- package/dist/extensions/pi-subagents/test/unit/public-execution.test.ts +24 -2
- package/dist/extensions/pi-subagents/test/unit/readonly-drain-observation.test.ts +174 -0
- package/dist/extensions/pi-subagents/test/unit/readonly-model-continuation.test.ts +94 -0
- package/dist/extensions/pi-subagents/test/unit/readonly-session-evidence.test.ts +1329 -0
- package/dist/extensions/pi-subagents/test/unit/recursion-guard.test.ts +29 -80
- package/dist/extensions/pi-subagents/test/unit/render-helpers.test.ts +11 -8
- package/dist/extensions/pi-subagents/test/unit/result-files.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/retained-nested-route-tracker.test.ts +175 -0
- package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +38 -12
- package/dist/extensions/pi-subagents/test/unit/run-fanout-budget.test.ts +2 -5
- package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +89 -1
- package/dist/extensions/pi-subagents/test/unit/runtime-acknowledged-extensions.test.ts +2 -16
- package/dist/extensions/pi-subagents/test/unit/scheduled-runs.test.ts +27 -3
- package/dist/extensions/pi-subagents/test/unit/scheduled-supervisor-demand.test.ts +215 -0
- package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +15 -11
- package/dist/extensions/pi-subagents/test/unit/scripted-workflow.test.ts +237 -1
- package/dist/extensions/pi-subagents/test/unit/steering-action.test.ts +2 -5
- package/dist/extensions/pi-subagents/test/unit/streamed-progress-bounds.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/subagent-guide.test.ts +14 -1
- package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +130 -739
- package/dist/extensions/pi-subagents/test/unit/supervisor-ask-registration.test.ts +682 -0
- package/dist/extensions/pi-subagents/test/unit/supervisor-ui.test.ts +137 -0
- package/dist/extensions/pi-subagents/test/unit/tool-budget.test.ts +1 -11
- package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +23 -3
- package/dist/extensions/pi-subagents/test/unit/wait-completions.test.ts +8 -1
- package/dist/extensions/pi-subagents/test/unit/watchdog-tool-actions.test.ts +19 -1
- package/dist/extensions/pi-subagents/test/unit/workflow-chat-progress.test.ts +72 -4
- package/dist/extensions/pi-subagents/test/unit/workflow-checklist.test.ts +17 -3
- package/dist/extensions/pi-subagents/test/unit/workflow-child-summary.test.ts +34 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-detach-reconcile.test.ts +12 -2
- package/dist/extensions/pi-subagents/test/unit/workflow-launch-params.test.ts +46 -6
- package/dist/extensions/pi-subagents/test/unit/workflow-receipt.test.ts +3 -3
- package/dist/extensions/pi-subagents/test/unit/workflow-resources.test.ts +133 -1
- package/dist/extensions/pi-subagents/test/unit/workflow-resume-hint.test.ts +53 -2
- package/dist/extensions/pi-subagents/test/unit/worktree-cleanup-plan.test.ts +222 -14
- package/dist/extensions/pi-subagents/test/unit/worktree.test.ts +526 -85
- package/dist/extensions/pi-web-agent/src/backends/config.ts +1 -0
- package/dist/extensions/pi-web-agent/src/backends/settings-reader.ts +5 -3
- package/dist/extensions/pi-web-agent/src/search/tokenin.ts +7 -3
- package/dist/extensions/pi-web-agent/src/types.ts +1 -1
- package/dist/extensions/pi-zentui/README.md +17 -0
- package/dist/extensions/pi-zentui/assets/screenshots/footer-status-hyperlink.png +0 -0
- package/dist/extensions/pi-zentui/docs/configuration.md +71 -2
- package/dist/extensions/pi-zentui/extensions/zentui/config.ts +11 -0
- package/dist/extensions/pi-zentui/extensions/zentui/editor-transfer.ts +14 -0
- package/dist/extensions/pi-zentui/extensions/zentui/extension-status.ts +29 -13
- package/dist/extensions/pi-zentui/extensions/zentui/footer-layout.ts +5 -4
- package/dist/extensions/pi-zentui/extensions/zentui/footer-text.ts +11 -0
- package/dist/extensions/pi-zentui/extensions/zentui/footer.ts +11 -10
- package/dist/extensions/pi-zentui/extensions/zentui/index.ts +77 -3
- package/dist/extensions/pi-zentui/extensions/zentui/presets.ts +77 -0
- package/dist/extensions/pi-zentui/extensions/zentui/settings-command.ts +103 -2
- package/dist/extensions/pi-zentui/extensions/zentui/working-line-extension-segments.ts +115 -0
- package/dist/extensions/pi-zentui/extensions/zentui/working-line.ts +87 -5
- package/dist/extensions/pi-zentui/package-lock.json +277 -517
- package/dist/extensions/pi-zentui/package.json +7 -4
- package/dist/extensions/pi-zentui/test/config-presets.test.ts +238 -0
- package/dist/extensions/pi-zentui/test/editor-transfer.test.ts +24 -1
- package/dist/extensions/pi-zentui/test/extension-compliance.test.ts +570 -2
- package/dist/extensions/pi-zentui/test/extension-status.test.ts +90 -0
- package/dist/extensions/pi-zentui/test/footer-hyperlink.test.ts +243 -0
- package/dist/extensions/pi-zentui/test/package-contents.mjs +1 -0
- package/dist/extensions/pi-zentui/test/presets.test.ts +121 -0
- package/dist/extensions/pi-zentui/test/settings-command.test.ts +205 -1
- package/dist/extensions/pi-zentui/test/working-line-extension-segments.test.ts +139 -0
- package/dist/extensions/pi-zentui/test/working-line-lifecycle.integration.test.ts +237 -3
- package/dist/extensions/pi-zentui/test/working-line.test.ts +94 -2
- package/dist/index.d.ts +1 -1
- package/dist/main.js +4 -1
- package/dist/modes/interactive/chat-viewport.d.ts +19 -0
- package/dist/modes/interactive/chat-viewport.js +27 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +6 -2
- package/dist/modes/interactive/components/assistant-message.js +30 -13
- package/dist/modes/interactive/components/custom-editor.d.ts +10 -1
- package/dist/modes/interactive/components/custom-editor.js +39 -1
- package/dist/modes/interactive/components/first-time-setup.js +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts +2 -0
- package/dist/modes/interactive/components/markdown-transform.js +18 -0
- package/dist/modes/interactive/components/model-selector.js +19 -17
- package/dist/modes/interactive/components/scoped-models-selector.js +21 -23
- package/dist/modes/interactive/components/settings-selector.d.ts +7 -1
- package/dist/modes/interactive/components/settings-selector.js +128 -20
- package/dist/modes/interactive/components/settings-submenu.d.ts +71 -0
- package/dist/modes/interactive/components/settings-submenu.js +164 -0
- package/dist/modes/interactive/components/status-indicator.d.ts +3 -1
- package/dist/modes/interactive/components/status-indicator.js +10 -3
- package/dist/modes/interactive/components/thinking-selector.d.ts +15 -3
- package/dist/modes/interactive/components/thinking-selector.js +75 -18
- package/dist/modes/interactive/components/tool-execution.d.ts +21 -4
- package/dist/modes/interactive/components/tool-execution.js +35 -33
- package/dist/modes/interactive/components/trust-selector.js +2 -2
- package/dist/modes/interactive/interactive-mode.d.ts +13 -15
- package/dist/modes/interactive/interactive-mode.js +144 -80
- package/dist/modes/interactive/session-share.d.ts +15 -0
- package/dist/modes/interactive/session-share.js +183 -0
- package/dist/modes/interactive/theme/dark.json +2 -1
- package/dist/modes/interactive/theme/light.json +2 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts +1 -0
- package/dist/modes/interactive/theme/theme-controller.js +5 -0
- package/dist/modes/interactive/theme/theme-json.d.ts +83 -0
- package/dist/modes/interactive/theme/theme-json.js +129 -0
- package/dist/modes/interactive/theme/theme-schema.json +9 -1
- package/dist/modes/interactive/theme/theme.d.ts +14 -5
- package/dist/modes/interactive/theme/theme.js +18 -119
- package/dist/modes/interactive/tui-renderer.d.ts +20 -0
- package/dist/modes/interactive/tui-renderer.js +65 -0
- package/dist/utils/exif-orientation.js +2 -3
- package/dist/utils/management-http.d.ts +24 -0
- package/dist/utils/management-http.js +53 -0
- package/dist/utils/text.d.ts +7 -0
- package/dist/utils/text.js +8 -0
- package/dist/utils/tools-manager.d.ts +1 -0
- package/dist/utils/tools-manager.js +43 -21
- package/docs/docs.json +0 -4
- package/package.json +4 -4
- package/dist/extensions/pi-subagents/src/runs/shared/child-protocol.ts +0 -415
- package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +0 -1059
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-startup-retry.ts +0 -116
- package/dist/extensions/pi-subagents/src/shared/post-exit-stdio-guard.ts +0 -85
- package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +0 -224
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +0 -6986
- package/dist/extensions/pi-subagents/test/support/mock-pi-script.mjs +0 -447
- package/dist/extensions/pi-subagents/test/support/real-session-child-cli.mjs +0 -185
- package/dist/extensions/pi-subagents/test/support/real-session-runner.ts +0 -311
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling-pi-args.test.ts +0 -84
- package/dist/extensions/pi-subagents/test/unit/child-protocol.test.ts +0 -202
- package/dist/extensions/pi-subagents/test/unit/close-grace-timer.test.ts +0 -101
- package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +0 -2347
- package/dist/extensions/pi-subagents/test/unit/subagent-startup-retry.test.ts +0 -104
- package/dist/extensions/pi-subagents/test/unit/windows-hide-spawn.test.ts +0 -49
- package/dist/skills/imagegen-frontend-mobile/SKILL.md +0 -1465
- package/dist/skills/imagegen-frontend-web/SKILL.md +0 -987
- package/dist/skills/implanger/SKILL.md +0 -70
- package/dist/skills/output/SKILL.md +0 -49
- package/dist/skills/planger/SKILL.md +0 -167
- package/dist/skills/workflow/SKILL.md +0 -95
- package/docs/workflows.md +0 -18
- /package/dist/bun/{register-bedrock.d.ts → runtime-setup.d.ts} +0 -0
|
@@ -6,7 +6,7 @@ import * as fs from "node:fs";
|
|
|
6
6
|
import * as os from "node:os";
|
|
7
7
|
import * as path from "node:path";
|
|
8
8
|
import * as TuiLayouts from "@earendil-works/pi-tui";
|
|
9
|
-
import { CombinedAutocompleteProvider, Container, fuzzyFilter, Markdown, matchesKey,
|
|
9
|
+
import { CombinedAutocompleteProvider, Container, fuzzyFilter, Markdown, matchesKey, Spacer, setCapabilityOverrides, setKeybindings, Text, TruncatedText, TuiAltScreen, TuiMainScreen, visibleWidth, } from "@earendil-works/pi-tui";
|
|
10
10
|
import chalk from "chalk";
|
|
11
11
|
import { spawn, spawnSync } from "child_process";
|
|
12
12
|
import { APP_NAME, APP_TITLE, CONFIG_DIR_NAME, getAgentDir, getAuthPath, getBundledDefaultsDir, getDebugLogPath, getDocsPath, getShareViewerUrl, getUpdateInstruction, PACKAGE_NAME, VERSION, } from "../../config.js";
|
|
@@ -24,19 +24,21 @@ import { SessionManager, sessionEntryToContextMessages } from "../../core/sessio
|
|
|
24
24
|
import { buildGitCommandPrompt, GIT_COMMAND_MODES } from "../../core/git-command.js";
|
|
25
25
|
import { BUILTIN_SLASH_COMMANDS } from "../../core/slash-commands.js";
|
|
26
26
|
import { isInstallTelemetryEnabled } from "../../core/telemetry.js";
|
|
27
|
+
import { withBuiltInRenderers } from "../../core/tools/renderers/index.js";
|
|
27
28
|
import { hasTrustRequiringProjectResources, ProjectTrustStore } from "../../core/trust-manager.js";
|
|
28
29
|
import { formatCost, getUsageCostBreakdown } from "../../core/usage-totals.js";
|
|
30
|
+
import { DEFAULT_THINKING_LEVEL } from "../../core/defaults.js";
|
|
29
31
|
import { getChangelogPath, getNewEntries, normalizeChangelogLinks, parseChangelog } from "../../utils/changelog.js";
|
|
30
32
|
import { copyToClipboard, readClipboardText } from "../../utils/clipboard.js";
|
|
31
33
|
import { extensionForImageMimeType, readClipboardImage } from "../../utils/clipboard-image.js";
|
|
32
34
|
import { parseGitUrl } from "../../utils/git.js";
|
|
33
35
|
import { formatDimensionNote, resizeImage } from "../../utils/image-resize.js";
|
|
34
36
|
import { getCwdRelativePath } from "../../utils/paths.js";
|
|
35
|
-
import { openBrowser } from "../../utils/open-browser.js";
|
|
36
37
|
import { getPiUserAgent } from "../../utils/pi-user-agent.js";
|
|
37
38
|
import { killTrackedDetachedChildren } from "../../utils/shell.js";
|
|
38
39
|
import { ensureTool } from "../../utils/tools-manager.js";
|
|
39
40
|
import { checkForNewPiVersion } from "../../utils/version-check.js";
|
|
41
|
+
import { createChatViewport } from "./chat-viewport.js";
|
|
40
42
|
import { ArminComponent } from "./components/armin.js";
|
|
41
43
|
import { AssistantMessageComponent } from "./components/assistant-message.js";
|
|
42
44
|
import { BashExecutionComponent } from "./components/bash-execution.js";
|
|
@@ -73,6 +75,14 @@ import { getModelSearchText } from "./model-search.js";
|
|
|
73
75
|
import { refreshModelCatalogs } from "./model-catalog-refresh.js";
|
|
74
76
|
import { getAvailableThemes, getAvailableThemesWithPaths, getEditorTheme, getMarkdownTheme, getThemeByName, onThemeChange, setRegisteredThemes, stopThemeWatcher, Theme, theme, } from "./theme/theme.js";
|
|
75
77
|
import { InteractiveThemeController } from "./theme/theme-controller.js";
|
|
78
|
+
import { createInteractiveTui, createInteractiveTuiReference } from "./tui-renderer.js";
|
|
79
|
+
export { createInteractiveTui, createInteractiveTuiReference } from "./tui-renderer.js";
|
|
80
|
+
function isWorkingStatusEditor(editor) {
|
|
81
|
+
return ("embedWorkingStatus" in editor &&
|
|
82
|
+
editor.embedWorkingStatus === true &&
|
|
83
|
+
"setWorkingStatusIndicator" in editor &&
|
|
84
|
+
typeof editor.setWorkingStatusIndicator === "function");
|
|
85
|
+
}
|
|
76
86
|
function isExpandable(obj) {
|
|
77
87
|
return typeof obj === "object" && obj !== null && "setExpanded" in obj && typeof obj.setExpanded === "function";
|
|
78
88
|
}
|
|
@@ -91,6 +101,9 @@ class ExpandableText extends Text {
|
|
|
91
101
|
function isCustomSessionEntry(item) {
|
|
92
102
|
return "type" in item && item.type === "custom";
|
|
93
103
|
}
|
|
104
|
+
function isCompactionCostNotice(item) {
|
|
105
|
+
return "type" in item && item.type === "compaction_cost";
|
|
106
|
+
}
|
|
94
107
|
const DEAD_TERMINAL_ERROR_CODES = new Set(["EIO", "EPIPE", "ENOTCONN"]);
|
|
95
108
|
function isDeadTerminalError(error) {
|
|
96
109
|
if (!error || typeof error !== "object" || !("code" in error)) {
|
|
@@ -189,61 +202,6 @@ function formatLoginProviderCompletionDescription(provider) {
|
|
|
189
202
|
const authTypes = provider.authTypes.map(formatAuthSelectorProviderType).join("/");
|
|
190
203
|
return provider.name === provider.id ? authTypes : `${provider.name} · ${authTypes}`;
|
|
191
204
|
}
|
|
192
|
-
/** Composition root for selecting the interactive terminal renderer. */
|
|
193
|
-
export function createInteractiveTui(options) {
|
|
194
|
-
const terminal = options.terminal ?? new ProcessTerminal();
|
|
195
|
-
if (options.tuiMode === "fullscreen") {
|
|
196
|
-
const styleSearchMatch = (text) => theme.bg("searchMatchBg", theme.fg("searchMatchText", text));
|
|
197
|
-
return new TuiAltScreen(terminal, options.showHardwareCursor, options.logDirectory, {
|
|
198
|
-
searchMatchStyle: (text) => theme.underline(styleSearchMatch(text)),
|
|
199
|
-
searchCurrentMatchStyle: (text) => theme.bold(theme.inverse(styleSearchMatch(text))),
|
|
200
|
-
openUrl: openBrowser,
|
|
201
|
-
onRightClickPaste: options.onRightClickPaste,
|
|
202
|
-
copyOnSelect: options.fullscreenCopyOnSelect,
|
|
203
|
-
copySelection: async (text) => {
|
|
204
|
-
try {
|
|
205
|
-
await copyToClipboard(text);
|
|
206
|
-
return true;
|
|
207
|
-
}
|
|
208
|
-
catch {
|
|
209
|
-
return false;
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
return new TuiMainScreen(terminal, options.showHardwareCursor, options.logDirectory);
|
|
215
|
-
}
|
|
216
|
-
/** Stable reference for components while InteractiveMode replaces the active renderer. */
|
|
217
|
-
export function createInteractiveTuiReference(getTui) {
|
|
218
|
-
return new Proxy({}, {
|
|
219
|
-
get: (_target, property) => {
|
|
220
|
-
const tui = getTui();
|
|
221
|
-
const value = Reflect.get(tui, property, tui);
|
|
222
|
-
if (typeof value !== "function")
|
|
223
|
-
return value;
|
|
224
|
-
let methodTui = tui;
|
|
225
|
-
let method = value;
|
|
226
|
-
return (...args) => {
|
|
227
|
-
const currentTui = getTui();
|
|
228
|
-
if (currentTui !== methodTui) {
|
|
229
|
-
const currentMethod = Reflect.get(currentTui, property, currentTui);
|
|
230
|
-
if (typeof currentMethod !== "function") {
|
|
231
|
-
throw new TypeError(`TUI property ${String(property)} is not callable`);
|
|
232
|
-
}
|
|
233
|
-
methodTui = currentTui;
|
|
234
|
-
method = currentMethod;
|
|
235
|
-
}
|
|
236
|
-
return Reflect.apply(method, methodTui, args);
|
|
237
|
-
};
|
|
238
|
-
},
|
|
239
|
-
set: (_target, property, value) => {
|
|
240
|
-
const tui = getTui();
|
|
241
|
-
return Reflect.set(tui, property, value, tui);
|
|
242
|
-
},
|
|
243
|
-
has: (_target, property) => Reflect.has(getTui(), property),
|
|
244
|
-
getPrototypeOf: () => Reflect.getPrototypeOf(getTui()),
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
205
|
export class InteractiveMode {
|
|
248
206
|
runtimeHost;
|
|
249
207
|
renderer;
|
|
@@ -274,11 +232,12 @@ export class InteractiveMode {
|
|
|
274
232
|
pendingUserInputs = [];
|
|
275
233
|
pendingInputImages = [];
|
|
276
234
|
activeStatusIndicator = undefined;
|
|
235
|
+
activeWorkingIndicatorEmbedded = false;
|
|
277
236
|
idleStatus = new IdleStatus();
|
|
278
237
|
workingMessage = undefined;
|
|
279
238
|
workingVisible = true;
|
|
280
239
|
workingIndicatorOptions = undefined;
|
|
281
|
-
defaultWorkingMessage = "Working
|
|
240
|
+
defaultWorkingMessage = "Working";
|
|
282
241
|
defaultHiddenThinkingLabel = "Thinking...";
|
|
283
242
|
hiddenThinkingLabel = this.defaultHiddenThinkingLabel;
|
|
284
243
|
lastSigintTime = 0;
|
|
@@ -398,6 +357,7 @@ export class InteractiveMode {
|
|
|
398
357
|
this.defaultEditor = new CustomEditor(this.ui, getEditorTheme(), this.keybindings, {
|
|
399
358
|
paddingX: editorPaddingX,
|
|
400
359
|
autocompleteMaxVisible,
|
|
360
|
+
embedWorkingStatus: true,
|
|
401
361
|
});
|
|
402
362
|
this.editor = this.defaultEditor;
|
|
403
363
|
this.editorContainer = new Container();
|
|
@@ -658,25 +618,20 @@ export class InteractiveMode {
|
|
|
658
618
|
}
|
|
659
619
|
// Keep one component tree and remount it when changing renderers.
|
|
660
620
|
this.renderWidgets(); // Initialize with default spacer
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
621
|
+
const viewport = createChatViewport({
|
|
622
|
+
document: this.documentContainer,
|
|
623
|
+
pendingMessages: this.pendingMessagesContainer,
|
|
624
|
+
status: this.statusContainer,
|
|
625
|
+
widgetsAbove: this.widgetContainerAbove,
|
|
626
|
+
editor: this.editorContainer,
|
|
627
|
+
widgetsBelow: this.widgetContainerBelow,
|
|
628
|
+
footer: this.footerContainer,
|
|
665
629
|
scrollbar: this.settingsManager.getFullscreenScrollbar(),
|
|
666
|
-
|
|
630
|
+
scrollbarTrackStyle: (text) => theme.fg("scrollbarTrack", text),
|
|
631
|
+
scrollbarThumbStyle: (text) => theme.fg("scrollbarThumb", text),
|
|
667
632
|
});
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
{ component: this.statusContainer, shrink: 1, minSize: 0 },
|
|
671
|
-
{ component: this.widgetContainerAbove, shrink: 1, minSize: 0 },
|
|
672
|
-
{ component: this.editorContainer, shrink: 1, minSize: 3 },
|
|
673
|
-
{ component: this.widgetContainerBelow, shrink: 1, minSize: 0 },
|
|
674
|
-
{ component: this.footerContainer, shrink: 1, minSize: 1 },
|
|
675
|
-
]);
|
|
676
|
-
this.fullscreenLayoutRoot = new TuiLayouts.VStack([
|
|
677
|
-
{ component: this.transcriptScrollView, basis: 0, grow: 1, shrink: 1, minSize: 1 },
|
|
678
|
-
{ component: dock, basis: "auto", grow: 0, shrink: 1, minSize: 1 },
|
|
679
|
-
]);
|
|
633
|
+
this.transcriptScrollView = viewport.transcript;
|
|
634
|
+
this.fullscreenLayoutRoot = viewport.root;
|
|
680
635
|
this.mountInteractiveTui(this.renderer, [
|
|
681
636
|
this.documentContainer,
|
|
682
637
|
this.pendingMessagesContainer,
|
|
@@ -1493,8 +1448,12 @@ export class InteractiveMode {
|
|
|
1493
1448
|
/**
|
|
1494
1449
|
* Get a registered tool definition by name (for custom rendering).
|
|
1495
1450
|
*/
|
|
1451
|
+
/**
|
|
1452
|
+
* Extension-registered definition, falling back to the built-in one. The renderer components take
|
|
1453
|
+
* whatever this returns, so they never reach into the tool registry themselves.
|
|
1454
|
+
*/
|
|
1496
1455
|
getRegisteredToolDefinition(toolName) {
|
|
1497
|
-
return this.session.getToolDefinition(toolName);
|
|
1456
|
+
return withBuiltInRenderers(toolName, this.session.getToolDefinition(toolName));
|
|
1498
1457
|
}
|
|
1499
1458
|
/**
|
|
1500
1459
|
* Set up keyboard shortcuts registered by extensions.
|
|
@@ -1561,26 +1520,48 @@ export class InteractiveMode {
|
|
|
1561
1520
|
this.footerDataProvider.setExtensionStatus(key, text);
|
|
1562
1521
|
this.ui.requestRender();
|
|
1563
1522
|
}
|
|
1523
|
+
setEditorWorkingStatusIndicator(indicator) {
|
|
1524
|
+
this.defaultEditor.setWorkingStatusIndicator(undefined);
|
|
1525
|
+
if (!isWorkingStatusEditor(this.editor))
|
|
1526
|
+
return false;
|
|
1527
|
+
this.editor.setWorkingStatusIndicator(indicator);
|
|
1528
|
+
return true;
|
|
1529
|
+
}
|
|
1564
1530
|
showStatusIndicator(indicator) {
|
|
1565
1531
|
this.activeStatusIndicator?.dispose();
|
|
1566
1532
|
this.activeStatusIndicator = indicator;
|
|
1533
|
+
this.activeWorkingIndicatorEmbedded = false;
|
|
1567
1534
|
this.statusContainer.clear();
|
|
1535
|
+
this.setEditorWorkingStatusIndicator(undefined);
|
|
1536
|
+
if (indicator instanceof WorkingStatusIndicator && this.setEditorWorkingStatusIndicator(indicator)) {
|
|
1537
|
+
this.activeWorkingIndicatorEmbedded = true;
|
|
1538
|
+
return;
|
|
1539
|
+
}
|
|
1568
1540
|
this.statusContainer.addChild(indicator);
|
|
1569
1541
|
}
|
|
1570
1542
|
clearStatusIndicator(kind) {
|
|
1571
1543
|
if (kind && this.activeStatusIndicator?.kind !== kind) {
|
|
1572
1544
|
return;
|
|
1573
1545
|
}
|
|
1574
|
-
const
|
|
1575
|
-
this.
|
|
1546
|
+
const clearedIndicator = this.activeStatusIndicator;
|
|
1547
|
+
const clearedIndicatorWasEmbedded = clearedIndicator?.kind === "working" && this.activeWorkingIndicatorEmbedded;
|
|
1548
|
+
clearedIndicator?.dispose();
|
|
1576
1549
|
this.activeStatusIndicator = undefined;
|
|
1550
|
+
this.activeWorkingIndicatorEmbedded = false;
|
|
1577
1551
|
this.statusContainer.clear();
|
|
1578
|
-
|
|
1552
|
+
this.setEditorWorkingStatusIndicator(undefined);
|
|
1553
|
+
if (clearedIndicator &&
|
|
1554
|
+
!clearedIndicatorWasEmbedded &&
|
|
1555
|
+
this.options.tuiMode === "regular" &&
|
|
1556
|
+
this.ui.getClearOnShrink()) {
|
|
1579
1557
|
this.statusContainer.addChild(this.idleStatus);
|
|
1580
1558
|
}
|
|
1581
1559
|
}
|
|
1582
1560
|
showWorkingStatusIndicator() {
|
|
1583
|
-
|
|
1561
|
+
const colorFn = isWorkingStatusEditor(this.editor)
|
|
1562
|
+
? (text) => (this.editor.borderColor ?? theme.getThinkingBorderColor(this.session.thinkingLevel || "off"))(text)
|
|
1563
|
+
: undefined;
|
|
1564
|
+
this.showStatusIndicator(new WorkingStatusIndicator(this.ui, this.workingMessage ?? this.defaultWorkingMessage, this.workingIndicatorOptions, colorFn));
|
|
1584
1565
|
}
|
|
1585
1566
|
setWorkingVisible(visible) {
|
|
1586
1567
|
this.workingVisible = visible;
|
|
@@ -2045,6 +2026,13 @@ export class InteractiveMode {
|
|
|
2045
2026
|
this.editor = this.defaultEditor;
|
|
2046
2027
|
}
|
|
2047
2028
|
this.editorContainer.addChild(this.editor);
|
|
2029
|
+
if (this.activeStatusIndicator instanceof WorkingStatusIndicator) {
|
|
2030
|
+
this.statusContainer.clear();
|
|
2031
|
+
this.activeWorkingIndicatorEmbedded = this.setEditorWorkingStatusIndicator(this.activeStatusIndicator);
|
|
2032
|
+
if (!this.activeWorkingIndicatorEmbedded) {
|
|
2033
|
+
this.statusContainer.addChild(this.activeStatusIndicator);
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2048
2036
|
this.ui.setFocus(this.editor);
|
|
2049
2037
|
this.ui.requestRender();
|
|
2050
2038
|
}
|
|
@@ -2637,6 +2625,7 @@ export class InteractiveMode {
|
|
|
2637
2625
|
for (const [, component] of this.pendingTools.entries()) {
|
|
2638
2626
|
component.setArgsComplete();
|
|
2639
2627
|
}
|
|
2628
|
+
this.maybeShowAssistantDiagnostics(this.streamingMessage);
|
|
2640
2629
|
this.maybeShowCacheMissNotice(this.streamingMessage);
|
|
2641
2630
|
}
|
|
2642
2631
|
this.streamingComponent = undefined;
|
|
@@ -2963,6 +2952,10 @@ export class InteractiveMode {
|
|
|
2963
2952
|
this.addCustomEntryToChat(item);
|
|
2964
2953
|
continue;
|
|
2965
2954
|
}
|
|
2955
|
+
if (isCompactionCostNotice(item)) {
|
|
2956
|
+
this.addCompactionCostNotice(item);
|
|
2957
|
+
continue;
|
|
2958
|
+
}
|
|
2966
2959
|
const message = item;
|
|
2967
2960
|
// Assistant messages need special handling for tool calls
|
|
2968
2961
|
if (message.role === "assistant") {
|
|
@@ -2996,6 +2989,7 @@ export class InteractiveMode {
|
|
|
2996
2989
|
}
|
|
2997
2990
|
}
|
|
2998
2991
|
if (message.stopReason !== "aborted" && message.stopReason !== "error") {
|
|
2992
|
+
this.maybeShowAssistantDiagnostics(message);
|
|
2999
2993
|
const miss = cacheMisses.get(message);
|
|
3000
2994
|
if (miss)
|
|
3001
2995
|
this.addCacheMissNotice(miss);
|
|
@@ -3034,6 +3028,46 @@ export class InteractiveMode {
|
|
|
3034
3028
|
});
|
|
3035
3029
|
this.renderSessionItems(items, options);
|
|
3036
3030
|
}
|
|
3031
|
+
/**
|
|
3032
|
+
* Render billing usage for a compaction or branch summary. The notice is derived
|
|
3033
|
+
* from persisted summary usage and is not stored as a separate session entry.
|
|
3034
|
+
*/
|
|
3035
|
+
addCompactionCostNotice(notice) {
|
|
3036
|
+
if (!this.settingsManager.getShowCacheMissNotices())
|
|
3037
|
+
return;
|
|
3038
|
+
const { usage } = notice;
|
|
3039
|
+
const tokens = usage.input + usage.output + usage.cacheRead + usage.cacheWrite;
|
|
3040
|
+
const cost = usage.cost.total >= 0.01 ? ` (~$${usage.cost.total.toFixed(2)})` : "";
|
|
3041
|
+
const label = notice.kind === "compaction" ? "Compaction" : "Branch summary";
|
|
3042
|
+
this.chatContainer.addChild(new Spacer(1));
|
|
3043
|
+
this.chatContainer.addChild(new Text(theme.fg("warning", `${label}: ${formatTokens(tokens)} tokens billed${cost}`), 1, 0));
|
|
3044
|
+
}
|
|
3045
|
+
maybeShowAssistantDiagnostics(message) {
|
|
3046
|
+
if (!this.settingsManager.getShowCacheMissNotices())
|
|
3047
|
+
return;
|
|
3048
|
+
for (const diagnostic of message.diagnostics ?? []) {
|
|
3049
|
+
if (diagnostic.type !== "anthropic_input_transformations")
|
|
3050
|
+
continue;
|
|
3051
|
+
const transformations = diagnostic.details?.transformations;
|
|
3052
|
+
if (!Array.isArray(transformations))
|
|
3053
|
+
continue;
|
|
3054
|
+
const dropped = transformations.flatMap((transformation) => {
|
|
3055
|
+
if (typeof transformation !== "object" || transformation === null)
|
|
3056
|
+
return [];
|
|
3057
|
+
const details = transformation;
|
|
3058
|
+
if (details.type !== "thinking_dropped")
|
|
3059
|
+
return [];
|
|
3060
|
+
const reason = typeof details.reason === "string" ? details.reason : "unknown reason";
|
|
3061
|
+
const location = typeof details.path === "string" ? ` at ${details.path}` : "";
|
|
3062
|
+
return [`${reason}${location}`];
|
|
3063
|
+
});
|
|
3064
|
+
if (dropped.length === 0)
|
|
3065
|
+
continue;
|
|
3066
|
+
const noun = dropped.length === 1 ? "thinking block" : `${dropped.length} thinking blocks`;
|
|
3067
|
+
this.chatContainer.addChild(new Spacer(1));
|
|
3068
|
+
this.chatContainer.addChild(new Text(theme.fg("warning", `Anthropic dropped ${noun}: ${dropped.join("; ")}`), 1, 0));
|
|
3069
|
+
}
|
|
3070
|
+
}
|
|
3037
3071
|
/**
|
|
3038
3072
|
* Show a transcript notice when a completed assistant message paid for a
|
|
3039
3073
|
* significant cache miss. Only states observable facts: the miss itself,
|
|
@@ -3337,6 +3371,9 @@ export class InteractiveMode {
|
|
|
3337
3371
|
const level = this.session.thinkingLevel || "off";
|
|
3338
3372
|
this.editor.borderColor = theme.getThinkingBorderColor(level);
|
|
3339
3373
|
}
|
|
3374
|
+
if (this.activeStatusIndicator?.kind === "working") {
|
|
3375
|
+
this.activeStatusIndicator.invalidate();
|
|
3376
|
+
}
|
|
3340
3377
|
this.ui.requestRender();
|
|
3341
3378
|
}
|
|
3342
3379
|
cycleThinkingLevel() {
|
|
@@ -3654,6 +3691,13 @@ export class InteractiveMode {
|
|
|
3654
3691
|
autoCompact: this.session.autoCompactionEnabled,
|
|
3655
3692
|
autoHandoffEnabled: this.settingsManager.getAutoHandoffEnabled(),
|
|
3656
3693
|
autoHandoffThresholdTokens: this.settingsManager.getAutoHandoffThresholdTokens(),
|
|
3694
|
+
defaultModel: (() => {
|
|
3695
|
+
const defaultProvider = this.settingsManager.getDefaultProvider();
|
|
3696
|
+
const defaultModelId = this.settingsManager.getDefaultModel();
|
|
3697
|
+
return defaultProvider && defaultModelId ? `${defaultProvider}/${defaultModelId}` : "not set";
|
|
3698
|
+
})(),
|
|
3699
|
+
currentModel: this.session.model,
|
|
3700
|
+
availableDefaultModels: this.session.modelRuntime.getAvailableSnapshot(),
|
|
3657
3701
|
showImages: this.settingsManager.getShowImages(),
|
|
3658
3702
|
imageWidthCells: this.settingsManager.getImageWidthCells(),
|
|
3659
3703
|
autoResizeImages: this.settingsManager.getImageAutoResize(),
|
|
@@ -3676,6 +3720,7 @@ export class InteractiveMode {
|
|
|
3676
3720
|
httpIdleTimeoutMs: this.settingsManager.getHttpIdleTimeoutMs(),
|
|
3677
3721
|
thinkingLevel: this.session.thinkingLevel,
|
|
3678
3722
|
availableThinkingLevels: this.session.getAvailableThinkingLevels(),
|
|
3723
|
+
modelThinkingLevels: this.settingsManager.getAllModelThinkingLevels(),
|
|
3679
3724
|
currentTheme: this.themeController.getThemeSelection() || "dark",
|
|
3680
3725
|
terminalTheme: this.themeController.getTerminalTheme(),
|
|
3681
3726
|
availableThemes: getAvailableThemes(),
|
|
@@ -3755,6 +3800,25 @@ export class InteractiveMode {
|
|
|
3755
3800
|
configureHttpDispatcher(timeoutMs);
|
|
3756
3801
|
this.showStatus(`HTTP idle timeout: ${formatHttpIdleTimeoutMs(timeoutMs)}`);
|
|
3757
3802
|
},
|
|
3803
|
+
onModelThinkingLevelChange: (provider, modelId, level) => {
|
|
3804
|
+
this.settingsManager.setModelThinkingLevel(provider, modelId, level);
|
|
3805
|
+
const current = this.session.model;
|
|
3806
|
+
if (current && current.provider === provider && current.id === modelId) {
|
|
3807
|
+
this.session.setThinkingLevel(level);
|
|
3808
|
+
this.footer.invalidate();
|
|
3809
|
+
this.updateEditorBorderColor();
|
|
3810
|
+
}
|
|
3811
|
+
},
|
|
3812
|
+
onModelThinkingLevelRemove: (provider, modelId) => {
|
|
3813
|
+
this.settingsManager.removeModelThinkingLevel(provider, modelId);
|
|
3814
|
+
const current = this.session.model;
|
|
3815
|
+
if (current && current.provider === provider && current.id === modelId) {
|
|
3816
|
+
const globalDefault = this.settingsManager.getDefaultThinkingLevel() ?? DEFAULT_THINKING_LEVEL;
|
|
3817
|
+
this.session.setThinkingLevel(globalDefault);
|
|
3818
|
+
this.footer.invalidate();
|
|
3819
|
+
this.updateEditorBorderColor();
|
|
3820
|
+
}
|
|
3821
|
+
},
|
|
3758
3822
|
onThinkingLevelChange: (level) => {
|
|
3759
3823
|
this.session.setThinkingLevel(level);
|
|
3760
3824
|
this.footer.invalidate();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Container, type EditorComponent, type TUI } from "@earendil-works/pi-tui";
|
|
2
|
+
import type { AgentSession } from "../../core/agent-session.ts";
|
|
3
|
+
interface SessionShareContext {
|
|
4
|
+
session: AgentSession;
|
|
5
|
+
ui: TUI;
|
|
6
|
+
editorContainer: Container;
|
|
7
|
+
editor: EditorComponent;
|
|
8
|
+
showStatus: (message: string) => void;
|
|
9
|
+
showError: (message: string) => void;
|
|
10
|
+
}
|
|
11
|
+
/** Export the current branch with presentation metadata for Radius. */
|
|
12
|
+
export declare function exportSessionForShare(filePath: string, session: AgentSession): void;
|
|
13
|
+
/** Share the current session through Radius, falling back to a private gist. */
|
|
14
|
+
export declare function shareSession(context: SessionShareContext): Promise<void>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
2
|
+
import * as crypto from "node:crypto";
|
|
3
|
+
import * as fs from "node:fs";
|
|
4
|
+
import * as os from "node:os";
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
import { DEFAULT_RADIUS_GATEWAY } from "@earendil-works/pi-ai/providers/radius-config";
|
|
7
|
+
import { hyperlink } from "@earendil-works/pi-tui";
|
|
8
|
+
import { getAuthCredential } from "../../cli/auth-command.js";
|
|
9
|
+
import { getShareViewerUrl } from "../../config.js";
|
|
10
|
+
import { exportSessionToJsonl } from "../../core/session-export.js";
|
|
11
|
+
import { BorderedLoader } from "./components/bordered-loader.js";
|
|
12
|
+
import { theme } from "./theme/theme.js";
|
|
13
|
+
/** Export the current branch with presentation metadata for Radius. */
|
|
14
|
+
export function exportSessionForShare(filePath, session) {
|
|
15
|
+
exportSessionToJsonl(session.sessionManager, filePath, (parentId, timestamp) => [
|
|
16
|
+
{
|
|
17
|
+
type: "custom",
|
|
18
|
+
customType: "pi.share",
|
|
19
|
+
id: crypto.randomUUID().slice(0, 8),
|
|
20
|
+
parentId,
|
|
21
|
+
timestamp,
|
|
22
|
+
data: {
|
|
23
|
+
systemPrompt: session.state.systemPrompt,
|
|
24
|
+
tools: session.state.tools.map((tool) => ({
|
|
25
|
+
name: tool.name,
|
|
26
|
+
description: tool.description,
|
|
27
|
+
parameters: tool.parameters,
|
|
28
|
+
})),
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
]);
|
|
32
|
+
}
|
|
33
|
+
/** Share the current session through Radius, falling back to a private gist. */
|
|
34
|
+
export async function shareSession(context) {
|
|
35
|
+
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-share-"));
|
|
36
|
+
const jsonlFile = path.join(tempDir, "session.jsonl");
|
|
37
|
+
const htmlFile = path.join(tempDir, "session.html");
|
|
38
|
+
try {
|
|
39
|
+
try {
|
|
40
|
+
exportSessionForShare(jsonlFile, context.session);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
context.showError(`Failed to export session: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (await tryShareViaRadius(jsonlFile, context))
|
|
47
|
+
return;
|
|
48
|
+
try {
|
|
49
|
+
const authResult = spawnSync("gh", ["auth", "status"], { encoding: "utf-8" });
|
|
50
|
+
if (authResult.status !== 0) {
|
|
51
|
+
context.showError("GitHub CLI is not logged in. Run 'gh auth login' first.");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
context.showError("GitHub CLI (gh) is not installed. Install it from https://cli.github.com/");
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
await context.session.exportToHtml(htmlFile, { themeName: theme.name });
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
context.showError(`Failed to export session: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
await shareViaGist(htmlFile, context);
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
try {
|
|
70
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
// Ignore cleanup errors
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async function tryShareViaRadius(tmpFile, context) {
|
|
78
|
+
const provider = context.session.modelRuntime.getProvider("radius");
|
|
79
|
+
if (!provider)
|
|
80
|
+
return false;
|
|
81
|
+
const token = getAuthCredential(await context.session.modelRuntime.getAuth("radius", { minOAuthValidityMs: 5 * 60_000 }));
|
|
82
|
+
if (!token)
|
|
83
|
+
return false;
|
|
84
|
+
const loader = new BorderedLoader(context.ui, theme, "Uploading to Radius...");
|
|
85
|
+
context.editorContainer.clear();
|
|
86
|
+
context.editorContainer.addChild(loader);
|
|
87
|
+
context.ui.setFocus(loader);
|
|
88
|
+
context.ui.requestRender();
|
|
89
|
+
loader.onAbort = () => {
|
|
90
|
+
restoreEditor(loader, context);
|
|
91
|
+
context.showStatus("Share cancelled");
|
|
92
|
+
};
|
|
93
|
+
try {
|
|
94
|
+
const body = fs.readFileSync(tmpFile);
|
|
95
|
+
const url = new URL("/v1/artifacts", DEFAULT_RADIUS_GATEWAY);
|
|
96
|
+
url.searchParams.set("visibility", "organization");
|
|
97
|
+
url.searchParams.set("title", "Pi session");
|
|
98
|
+
const response = await fetch(url, {
|
|
99
|
+
method: "POST",
|
|
100
|
+
headers: {
|
|
101
|
+
Authorization: `Bearer ${token}`,
|
|
102
|
+
"Content-Type": "application/x-ndjson",
|
|
103
|
+
"Content-Length": String(body.byteLength),
|
|
104
|
+
},
|
|
105
|
+
body,
|
|
106
|
+
signal: loader.signal,
|
|
107
|
+
});
|
|
108
|
+
if (loader.signal.aborted)
|
|
109
|
+
return true;
|
|
110
|
+
const json = (await response.json().catch(() => null));
|
|
111
|
+
if (loader.signal.aborted)
|
|
112
|
+
return true;
|
|
113
|
+
restoreEditor(loader, context);
|
|
114
|
+
if (!response.ok || !json?.artifact) {
|
|
115
|
+
context.showError(`Failed to upload Radius artifact: ${json?.error || response.statusText || response.status}`);
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
const shareUrl = json.artifact.canonical_url;
|
|
119
|
+
context.showStatus(`Share URL: ${hyperlink(shareUrl, shareUrl)}`);
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
if (!loader.signal.aborted) {
|
|
124
|
+
restoreEditor(loader, context);
|
|
125
|
+
context.showError(`Failed to upload Radius artifact: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
126
|
+
}
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async function shareViaGist(tmpFile, context) {
|
|
131
|
+
const loader = new BorderedLoader(context.ui, theme, "Creating gist...");
|
|
132
|
+
context.editorContainer.clear();
|
|
133
|
+
context.editorContainer.addChild(loader);
|
|
134
|
+
context.ui.setFocus(loader);
|
|
135
|
+
context.ui.requestRender();
|
|
136
|
+
let proc = null;
|
|
137
|
+
loader.onAbort = () => {
|
|
138
|
+
proc?.kill();
|
|
139
|
+
restoreEditor(loader, context);
|
|
140
|
+
context.showStatus("Share cancelled");
|
|
141
|
+
};
|
|
142
|
+
try {
|
|
143
|
+
const result = await new Promise((resolve) => {
|
|
144
|
+
proc = spawn("gh", ["gist", "create", "--public=false", tmpFile]);
|
|
145
|
+
let stdout = "";
|
|
146
|
+
let stderr = "";
|
|
147
|
+
proc.stdout?.on("data", (data) => {
|
|
148
|
+
stdout += data.toString();
|
|
149
|
+
});
|
|
150
|
+
proc.stderr?.on("data", (data) => {
|
|
151
|
+
stderr += data.toString();
|
|
152
|
+
});
|
|
153
|
+
proc.on("close", (code) => resolve({ stdout, stderr, code }));
|
|
154
|
+
});
|
|
155
|
+
if (loader.signal.aborted)
|
|
156
|
+
return;
|
|
157
|
+
restoreEditor(loader, context);
|
|
158
|
+
if (result.code !== 0) {
|
|
159
|
+
context.showError(`Failed to create gist: ${result.stderr?.trim() || "Unknown error"}`);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const gistUrl = result.stdout?.trim();
|
|
163
|
+
const gistId = gistUrl?.split("/").pop();
|
|
164
|
+
if (!gistId) {
|
|
165
|
+
context.showError("Failed to parse gist ID from gh output");
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const previewUrl = getShareViewerUrl(gistId);
|
|
169
|
+
context.showStatus(`Share URL: ${hyperlink(previewUrl, previewUrl)}\nGist: ${hyperlink(gistUrl, gistUrl)}`);
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
if (!loader.signal.aborted) {
|
|
173
|
+
restoreEditor(loader, context);
|
|
174
|
+
context.showError(`Failed to create gist: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function restoreEditor(loader, context) {
|
|
179
|
+
loader.dispose();
|
|
180
|
+
context.editorContainer.clear();
|
|
181
|
+
context.editorContainer.addChild(context.editor);
|
|
182
|
+
context.ui.setFocus(context.editor);
|
|
183
|
+
}
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
"thinkingText": "mediumGray",
|
|
33
33
|
|
|
34
34
|
"selectedBg": "selectedBg",
|
|
35
|
-
"
|
|
35
|
+
"scrollbarTrack": "lightGray",
|
|
36
|
+
"scrollbarThumb": "text",
|
|
36
37
|
"searchMatchBg": "selectedBg",
|
|
37
38
|
"searchMatchText": "text",
|
|
38
39
|
"userMessageBg": "userMsgBg",
|
|
@@ -29,6 +29,7 @@ export declare class InteractiveThemeController {
|
|
|
29
29
|
setThemeInstance(themeInstance: Theme): ThemeResult;
|
|
30
30
|
preview(themeSettingOrName: string): void;
|
|
31
31
|
disableAutoSync(): void;
|
|
32
|
+
dispose(): void;
|
|
32
33
|
getTerminalTheme(): TerminalTheme;
|
|
33
34
|
private applyThemeName;
|
|
34
35
|
private notifyChanged;
|
|
@@ -82,6 +82,11 @@ export class InteractiveThemeController {
|
|
|
82
82
|
disableAutoSync() {
|
|
83
83
|
this.setAutoSync(false);
|
|
84
84
|
}
|
|
85
|
+
dispose() {
|
|
86
|
+
this.setAutoSync(false);
|
|
87
|
+
this.terminalColorSchemeUnsubscribe?.();
|
|
88
|
+
this.terminalColorSchemeUnsubscribe = undefined;
|
|
89
|
+
}
|
|
85
90
|
getTerminalTheme() {
|
|
86
91
|
return this.terminalTheme;
|
|
87
92
|
}
|