@oh-my-pi/pi-coding-agent 17.2.4 → 17.2.6
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 +69 -0
- package/dist/{CHANGELOG-bpmhv26t.md → CHANGELOG-gs76k6wc.md} +69 -0
- package/dist/cli.js +4438 -3962
- package/dist/{template-8vdv6xb4.js → template-c2hyaytt.js} +8 -26
- package/dist/types/cli/args.d.ts +4 -1
- package/dist/types/cli/browser-relay-cli.d.ts +15 -0
- package/dist/types/cli/command-help.d.ts +99 -0
- package/dist/types/cli/gc-cli.d.ts +1 -0
- package/dist/types/cli/help-extra.d.ts +2 -0
- package/dist/types/cli/thinking-levels.d.ts +5 -0
- package/dist/types/cli/update-cli.d.ts +13 -0
- package/dist/types/commands/browser-relay.d.ts +38 -0
- package/dist/types/commands/commit.d.ts +3 -0
- package/dist/types/commands/complete.d.ts +1 -1
- package/dist/types/commands/completions.d.ts +6 -0
- package/dist/types/commands/grep.d.ts +3 -0
- package/dist/types/commands/join.d.ts +4 -0
- package/dist/types/commands/launch-help.d.ts +171 -0
- package/dist/types/commands/launch.d.ts +5 -1
- package/dist/types/commands/models.d.ts +3 -0
- package/dist/types/commands/say.d.ts +10 -0
- package/dist/types/commands/worktree.d.ts +3 -0
- package/dist/types/config/keybindings.d.ts +5 -0
- package/dist/types/config/model-discovery.d.ts +2 -2
- package/dist/types/config/models-config-schema-bundle.d.ts +3 -0
- package/dist/types/config/models-config-schema.d.ts +2 -0
- package/dist/types/config/models-config.d.ts +1 -0
- package/dist/types/config/service-tier.d.ts +2 -0
- package/dist/types/config/settings-schema.d.ts +69 -21
- package/dist/types/cursor-bridge-tools.d.ts +1 -1
- package/dist/types/cursor.d.ts +7 -4
- package/dist/types/edit/index.d.ts +3 -3
- package/dist/types/edit/modes/replace.d.ts +22 -15
- package/dist/types/edit/renderer.d.ts +1 -1
- package/dist/types/eval/py/kernel.d.ts +3 -1
- package/dist/types/eval/py/spawn-options.d.ts +12 -16
- package/dist/types/extensibility/legacy-pi-ai-shim.d.ts +8 -1
- package/dist/types/extensibility/legacy-pi-coding-agent-shim.d.ts +1 -1
- package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +2 -0
- package/dist/types/launch/broker.d.ts +1 -1
- package/dist/types/launch/client.d.ts +15 -4
- package/dist/types/launch/ensure.d.ts +8 -0
- package/dist/types/launch/paths.d.ts +1 -1
- package/dist/types/launch/protocol.d.ts +19 -2
- package/dist/types/lsp/client.d.ts +2 -0
- package/dist/types/lsp/mux/daemon.d.ts +15 -0
- package/dist/types/lsp/mux/protocol.d.ts +57 -0
- package/dist/types/lsp/mux/server.d.ts +18 -0
- package/dist/types/lsp/types.d.ts +22 -2
- package/dist/types/main.d.ts +2 -0
- package/dist/types/mnemopi/embed-client.d.ts +1 -1
- package/dist/types/mnemopi/state.d.ts +0 -23
- package/dist/types/modes/components/assistant-message.d.ts +2 -0
- package/dist/types/modes/components/btw-panel.d.ts +3 -0
- package/dist/types/modes/components/custom-editor.d.ts +2 -1
- package/dist/types/modes/components/read-tool-group.d.ts +2 -0
- package/dist/types/modes/components/stripped-tool-calls-placeholder.d.ts +12 -0
- package/dist/types/modes/components/tool-execution.d.ts +2 -0
- package/dist/types/modes/controllers/btw-controller.d.ts +2 -0
- package/dist/types/modes/controllers/command-controller.d.ts +1 -0
- package/dist/types/modes/controllers/input-controller.d.ts +1 -0
- package/dist/types/modes/interactive-mode.d.ts +5 -1
- package/dist/types/modes/types.d.ts +4 -1
- package/dist/types/modes/workflow.d.ts +2 -1
- package/dist/types/sdk.d.ts +3 -1
- package/dist/types/secrets/index.d.ts +1 -1
- package/dist/types/security/contracts/schemas.d.ts +405 -403
- package/dist/types/session/agent-session-types.d.ts +8 -1
- package/dist/types/session/agent-session.d.ts +26 -2
- package/dist/types/session/indexed-session-storage.d.ts +1 -0
- package/dist/types/session/launch-completion.d.ts +10 -0
- package/dist/types/session/session-advisors.d.ts +1 -1
- package/dist/types/session/session-context.d.ts +2 -1
- package/dist/types/session/session-entries.d.ts +15 -1
- package/dist/types/session/session-maintenance.d.ts +1 -0
- package/dist/types/session/session-manager.d.ts +23 -11
- package/dist/types/session/session-stats.d.ts +10 -0
- package/dist/types/session/session-storage.d.ts +15 -3
- package/dist/types/session/yield-queue.d.ts +6 -1
- package/dist/types/system-prompt.d.ts +4 -1
- package/dist/types/task/index.d.ts +2 -1
- package/dist/types/task/spawn-policy.d.ts +5 -0
- package/dist/types/thinking.d.ts +1 -7
- package/dist/types/tools/ast-grep.d.ts +1 -1
- package/dist/types/tools/browser/registry.d.ts +2 -1
- package/dist/types/tools/browser/relay/bridge.d.ts +35 -0
- package/dist/types/tools/browser/relay/daemon.d.ts +16 -0
- package/dist/types/tools/browser/relay/kind.d.ts +19 -0
- package/dist/types/tools/browser/relay/protocol.d.ts +97 -0
- package/dist/types/tools/browser/relay/server.d.ts +35 -0
- package/dist/types/tools/browser/render.d.ts +1 -0
- package/dist/types/tools/browser.d.ts +3 -0
- package/dist/types/tools/computer/exposure.d.ts +9 -7
- package/dist/types/tools/computer/protocol.d.ts +70 -17
- package/dist/types/tools/computer/supervisor.d.ts +23 -10
- package/dist/types/tools/computer/worker-entry.d.ts +1 -0
- package/dist/types/tools/computer/worker.d.ts +42 -7
- package/dist/types/tools/computer-renderer.d.ts +7 -5
- package/dist/types/tools/computer.d.ts +25 -44
- package/dist/types/tools/context.d.ts +3 -0
- package/dist/types/tools/glob.d.ts +1 -1
- package/dist/types/tools/grep.d.ts +1 -1
- package/dist/types/tools/index.d.ts +9 -0
- package/dist/types/tools/render-utils.d.ts +2 -0
- package/dist/types/tools/{browser/run-cancellation.d.ts → run-scope.d.ts} +8 -8
- package/dist/types/tools/tool-timeouts.d.ts +5 -0
- package/dist/types/tools/xdev.d.ts +8 -0
- package/dist/types/utils/clipboard.d.ts +2 -2
- package/dist/types/web/kagi.d.ts +1 -0
- package/dist/types/web/search/index.d.ts +1 -1
- package/dist/types/web/search/providers/anthropic.d.ts +1 -0
- package/dist/types/web/search/providers/base.d.ts +2 -0
- package/dist/types/web/search/providers/brave.d.ts +1 -0
- package/dist/types/web/search/providers/browser-page.d.ts +1 -0
- package/dist/types/web/search/providers/codex.d.ts +1 -0
- package/dist/types/web/search/providers/exa.d.ts +1 -0
- package/dist/types/web/search/providers/firecrawl.d.ts +1 -0
- package/dist/types/web/search/providers/gemini.d.ts +1 -0
- package/dist/types/web/search/providers/jina.d.ts +1 -0
- package/dist/types/web/search/providers/kagi.d.ts +1 -0
- package/dist/types/web/search/providers/kimi.d.ts +1 -0
- package/dist/types/web/search/providers/parallel.d.ts +1 -0
- package/dist/types/web/search/providers/perplexity.d.ts +1 -0
- package/dist/types/web/search/providers/searxng.d.ts +1 -0
- package/dist/types/web/search/providers/tavily.d.ts +1 -0
- package/dist/types/web/search/providers/tinyfish.d.ts +1 -0
- package/dist/types/web/search/providers/utils.d.ts +6 -9
- package/dist/types/web/search/providers/zai.d.ts +1 -0
- package/dist/types/web/search/types.d.ts +4 -0
- package/package.json +12 -12
- package/src/cli/args.ts +7 -87
- package/src/cli/browser-relay-cli.ts +119 -0
- package/src/cli/command-help.ts +103 -0
- package/src/cli/completion-gen.ts +5 -5
- package/src/cli/flag-tables.ts +9 -0
- package/src/cli/gc-cli.ts +641 -21
- package/src/cli/help-extra.ts +89 -0
- package/src/cli/setup-cli.ts +13 -21
- package/src/cli/thinking-levels.ts +7 -0
- package/src/cli/update-cli.ts +26 -7
- package/src/cli-commands.ts +170 -33
- package/src/cli.ts +17 -5
- package/src/commands/acp.ts +3 -1
- package/src/commands/agents.ts +3 -2
- package/src/commands/auth-broker.ts +3 -2
- package/src/commands/auth-gateway.ts +3 -2
- package/src/commands/bench.ts +2 -3
- package/src/commands/browser-relay.ts +53 -0
- package/src/commands/cleanse.ts +2 -2
- package/src/commands/commit.ts +3 -2
- package/src/commands/complete.ts +2 -1
- package/src/commands/completions.ts +3 -2
- package/src/commands/config.ts +3 -2
- package/src/commands/dry-balance.ts +2 -2
- package/src/commands/gallery.ts +3 -2
- package/src/commands/gc.ts +3 -2
- package/src/commands/grep.ts +3 -2
- package/src/commands/grievances.ts +3 -2
- package/src/commands/install.ts +2 -2
- package/src/commands/join.ts +3 -2
- package/src/commands/launch-help.ts +116 -0
- package/src/commands/launch.ts +7 -191
- package/src/commands/models.ts +3 -2
- package/src/commands/plugin.ts +3 -2
- package/src/commands/read.ts +3 -2
- package/src/commands/say.ts +3 -2
- package/src/commands/setup.ts +3 -2
- package/src/commands/shell.ts +3 -2
- package/src/commands/ssh.ts +3 -2
- package/src/commands/stats.ts +3 -2
- package/src/commands/tiny-models.ts +2 -2
- package/src/commands/token.ts +2 -2
- package/src/commands/ttsr.ts +2 -2
- package/src/commands/update.ts +3 -2
- package/src/commands/usage.ts +3 -2
- package/src/commands/web-search.ts +3 -2
- package/src/commands/worktree.ts +3 -2
- package/src/config/keybindings.ts +5 -0
- package/src/config/model-discovery.ts +44 -27
- package/src/config/model-registry.ts +19 -13
- package/src/config/models-config-schema-bundle.ts +9 -0
- package/src/config/resolve-config-value.ts +2 -1
- package/src/config/service-tier.ts +5 -0
- package/src/config/settings-schema.ts +72 -20
- package/src/config/settings.ts +1 -1
- package/src/cursor-bridge-tools.ts +1 -1
- package/src/cursor.ts +10 -14
- package/src/edit/diff.ts +17 -8
- package/src/edit/index.ts +20 -7
- package/src/edit/modes/replace.ts +93 -40
- package/src/edit/renderer.ts +1 -1
- package/src/edit/streaming.ts +14 -17
- package/src/eval/py/kernel.ts +2 -1
- package/src/eval/py/spawn-options.ts +24 -29
- package/src/export/html/index.ts +10 -3
- package/src/export/html/template.js +8 -26
- package/src/export/share.ts +4 -0
- package/src/extensibility/extensions/wrapper.ts +1 -0
- package/src/extensibility/legacy-pi-ai-shim.ts +22 -1
- package/src/extensibility/legacy-pi-coding-agent-shim.ts +7 -6
- package/src/extensibility/plugins/legacy-pi-compat.ts +124 -57
- package/src/extensibility/skills.ts +11 -0
- package/src/extensibility/utils.ts +10 -2
- package/src/launch/broker.ts +223 -7
- package/src/launch/client.ts +192 -21
- package/src/launch/ensure.ts +73 -0
- package/src/launch/paths.ts +1 -1
- package/src/launch/protocol.ts +54 -2
- package/src/lsp/client.ts +23 -2
- package/src/lsp/index.ts +8 -0
- package/src/lsp/mux/daemon.ts +348 -0
- package/src/lsp/mux/protocol.ts +96 -0
- package/src/lsp/mux/server.ts +797 -0
- package/src/lsp/types.ts +28 -2
- package/src/main.ts +20 -8
- package/src/mcp/config-writer.ts +1 -1
- package/src/mcp/oauth-flow.ts +11 -1
- package/src/mnemopi/embed-client.ts +49 -2
- package/src/mnemopi/state.ts +57 -23
- package/src/modes/components/assistant-message.ts +11 -0
- package/src/modes/components/btw-panel.ts +41 -4
- package/src/modes/components/chat-transcript-builder.ts +4 -0
- package/src/modes/components/custom-editor.ts +9 -0
- package/src/modes/components/read-tool-group.ts +10 -0
- package/src/modes/components/status-line/component.ts +1 -1
- package/src/modes/components/stripped-tool-calls-placeholder.ts +35 -0
- package/src/modes/components/tool-execution.ts +8 -0
- package/src/modes/components/tree-selector.ts +46 -48
- package/src/modes/controllers/btw-controller.ts +55 -7
- package/src/modes/controllers/command-controller.ts +31 -0
- package/src/modes/controllers/event-controller.ts +17 -0
- package/src/modes/controllers/input-controller.ts +63 -8
- package/src/modes/controllers/mcp-command-controller.ts +11 -5
- package/src/modes/controllers/selector-controller.ts +20 -0
- package/src/modes/interactive-mode.ts +18 -2
- package/src/modes/types.ts +9 -1
- package/src/modes/utils/hotkeys-markdown.ts +1 -0
- package/src/modes/utils/interactive-context-helpers.ts +1 -0
- package/src/modes/utils/ui-helpers.ts +6 -10
- package/src/modes/workflow.ts +8 -2
- package/src/prompts/agents/init.md +1 -1
- package/src/prompts/session/launch-completion.md +1 -0
- package/src/prompts/system/plan-mode-active.md +2 -2
- package/src/prompts/system/system-prompt.md +26 -52
- package/src/prompts/system/workflow-notice.md +3 -3
- package/src/prompts/tools/ast-grep.md +1 -1
- package/src/prompts/tools/bash.md +1 -1
- package/src/prompts/tools/browser.md +1 -0
- package/src/prompts/tools/computer.md +21 -21
- package/src/prompts/tools/glob.md +1 -1
- package/src/prompts/tools/grep.md +1 -1
- package/src/prompts/tools/replace.md +5 -4
- package/src/prompts/tools/task.md +4 -4
- package/src/sdk.ts +49 -6
- package/src/secrets/index.ts +1 -1
- package/src/security/contracts/schemas.ts +205 -183
- package/src/security/contracts/validation.ts +5 -1
- package/src/security/store.ts +2 -2
- package/src/session/agent-session-types.ts +9 -1
- package/src/session/agent-session.ts +204 -15
- package/src/session/indexed-session-storage.ts +9 -0
- package/src/session/launch-completion.ts +37 -0
- package/src/session/prewalk.ts +24 -2
- package/src/session/session-advisors.ts +2 -2
- package/src/session/session-context.ts +42 -12
- package/src/session/session-dump-format.ts +1 -1
- package/src/session/session-entries.ts +17 -1
- package/src/session/session-maintenance.ts +38 -4
- package/src/session/session-manager.ts +123 -67
- package/src/session/session-paths.ts +118 -55
- package/src/session/session-stats.ts +48 -3
- package/src/session/session-storage.ts +30 -22
- package/src/session/stream-guards.ts +1 -1
- package/src/session/yield-queue.ts +121 -16
- package/src/slash-commands/builtin-registry.ts +37 -24
- package/src/system-prompt.ts +8 -3
- package/src/task/index.ts +23 -8
- package/src/task/spawn-policy.ts +14 -0
- package/src/thinking.ts +2 -8
- package/src/tools/ast-grep.ts +10 -4
- package/src/tools/browser/cmux/cmux-tab.ts +97 -14
- package/src/tools/browser/cmux/rpc.ts +2 -8
- package/src/tools/browser/registry.ts +53 -2
- package/src/tools/browser/relay/bridge.ts +945 -0
- package/src/tools/browser/relay/daemon.ts +117 -0
- package/src/tools/browser/relay/extension-assets/background.js.txt +242 -0
- package/src/tools/browser/relay/extension-assets/manifest.json.txt +14 -0
- package/src/tools/browser/relay/extension-assets/options.html.txt +53 -0
- package/src/tools/browser/relay/extension-assets/options.js.txt +23 -0
- package/src/tools/browser/relay/kind.ts +41 -0
- package/src/tools/browser/relay/protocol.ts +54 -0
- package/src/tools/browser/relay/server.ts +141 -0
- package/src/tools/browser/render.ts +4 -1
- package/src/tools/browser/shared-daemon.ts +7 -58
- package/src/tools/browser/tab-supervisor.ts +5 -4
- package/src/tools/browser/tab-worker.ts +33 -12
- package/src/tools/browser.ts +26 -1
- package/src/tools/computer/exposure.ts +11 -35
- package/src/tools/computer/protocol.ts +51 -10
- package/src/tools/computer/supervisor.ts +227 -124
- package/src/tools/computer/worker-entry.ts +11 -6
- package/src/tools/computer/worker.ts +695 -81
- package/src/tools/computer-renderer.ts +104 -65
- package/src/tools/computer.ts +134 -428
- package/src/tools/context.ts +3 -0
- package/src/tools/glob.ts +9 -2
- package/src/tools/grep.ts +12 -6
- package/src/tools/hub/launch.ts +122 -6
- package/src/tools/index.ts +9 -0
- package/src/tools/inspect-image.ts +32 -6
- package/src/tools/render-utils.ts +2 -0
- package/src/tools/{browser/run-cancellation.ts → run-scope.ts} +11 -11
- package/src/tools/tool-timeouts.ts +1 -0
- package/src/tools/xdev.ts +29 -2
- package/src/utils/clipboard.ts +40 -14
- package/src/utils/command-args.ts +26 -28
- package/src/utils/tool-choice.ts +0 -13
- package/src/web/kagi.ts +2 -1
- package/src/web/search/index.ts +18 -2
- package/src/web/search/providers/anthropic.ts +4 -1
- package/src/web/search/providers/base.ts +2 -0
- package/src/web/search/providers/brave.ts +3 -1
- package/src/web/search/providers/browser-page.ts +6 -4
- package/src/web/search/providers/codex.ts +4 -1
- package/src/web/search/providers/duckduckgo.ts +2 -1
- package/src/web/search/providers/ecosia.ts +2 -1
- package/src/web/search/providers/exa.ts +4 -2
- package/src/web/search/providers/firecrawl.ts +3 -1
- package/src/web/search/providers/gemini.ts +8 -2
- package/src/web/search/providers/google.ts +2 -1
- package/src/web/search/providers/jina.ts +12 -2
- package/src/web/search/providers/kagi.ts +3 -0
- package/src/web/search/providers/kimi.ts +5 -1
- package/src/web/search/providers/mojeek.ts +2 -1
- package/src/web/search/providers/parallel.ts +5 -1
- package/src/web/search/providers/perplexity.ts +6 -3
- package/src/web/search/providers/public.ts +1 -1
- package/src/web/search/providers/searxng.ts +11 -5
- package/src/web/search/providers/startpage.ts +10 -4
- package/src/web/search/providers/synthetic.ts +11 -5
- package/src/web/search/providers/tavily.ts +3 -1
- package/src/web/search/providers/tinyfish.ts +3 -1
- package/src/web/search/providers/utils.ts +12 -10
- package/src/web/search/providers/xai.ts +2 -2
- package/src/web/search/providers/zai.ts +18 -3
- package/src/web/search/types.ts +6 -0
- package/dist/types/config/file-lock.d.ts +0 -29
- package/src/config/file-lock.ts +0 -164
|
@@ -81,6 +81,8 @@ export interface AgentSessionConfig {
|
|
|
81
81
|
agent: Agent;
|
|
82
82
|
sessionManager: SessionManager;
|
|
83
83
|
settings: Settings;
|
|
84
|
+
/** Whether the session spawn policy permits the read-only `scout` subagent. Defaults to true. */
|
|
85
|
+
scoutAllowedBySpawnPolicy?: boolean;
|
|
84
86
|
/** Whether the caller explicitly requested yolo/auto-approve behavior for this session. */
|
|
85
87
|
autoApprove?: boolean;
|
|
86
88
|
/** Models to cycle through with Ctrl+P (from --models flag). */
|
|
@@ -213,7 +215,7 @@ export interface AgentSessionConfig {
|
|
|
213
215
|
/**
|
|
214
216
|
* Build the `replace`-mode `edit` a Cursor `pi_edit` frame needs, against the
|
|
215
217
|
* advisor-scoped tool session. The advisor's ordinary instance follows the
|
|
216
|
-
* configured `edit.mode` and rejects the frame's `
|
|
218
|
+
* configured `edit.mode` and rejects the frame's `old_string`/`new_string` args.
|
|
217
219
|
*/
|
|
218
220
|
advisorCreateEditTool?(): AgentTool | undefined;
|
|
219
221
|
/**
|
|
@@ -355,6 +357,11 @@ export interface FreshSessionResult {
|
|
|
355
357
|
sessionId: string;
|
|
356
358
|
closedProviderSessions: number;
|
|
357
359
|
}
|
|
360
|
+
/** Outcome of an in-place `/reset` conversation-context reset. */
|
|
361
|
+
export interface ResetSessionContextResult {
|
|
362
|
+
/** Number of live messages dropped from the model's context. */
|
|
363
|
+
droppedCount: number;
|
|
364
|
+
}
|
|
358
365
|
/** Queued user content restored to the editor. */
|
|
359
366
|
export type RestoredQueuedMessage = {
|
|
360
367
|
text: string;
|
|
@@ -37,6 +37,7 @@ import { GoalRuntime } from "../goals/runtime.js";
|
|
|
37
37
|
import type { GoalModeState } from "../goals/state.js";
|
|
38
38
|
import type { HindsightSessionState } from "../hindsight/state.js";
|
|
39
39
|
import type { IrcMessage } from "../irc/bus.js";
|
|
40
|
+
import type { DaemonCompletionNotification } from "../launch/protocol.js";
|
|
40
41
|
import { type MnemopiSessionState } from "../mnemopi/state.js";
|
|
41
42
|
import { type PlanApprovalDetails } from "../plan-mode/approved-plan.js";
|
|
42
43
|
import type { PlanModeState } from "../plan-mode/state.js";
|
|
@@ -49,7 +50,7 @@ import type { TodoPhase } from "../tools/todo.js";
|
|
|
49
50
|
import type { InspectImageMode } from "../utils/inspect-image-mode.js";
|
|
50
51
|
import type { VibeModeState } from "../vibe/state.js";
|
|
51
52
|
import type { AgentSessionEventListener } from "./agent-session-events.js";
|
|
52
|
-
import type { AgentSessionConfig, AgentSessionDisposeOptions, AsyncJobSnapshot, CommandMetadataChangedListener, ContextUsageBreakdown, FollowUpOptions, FreshSessionResult, HandoffResult, ModelCycleResult, Prewalk, PromptOptions, ResolvedRoleModel, RestoredQueuedMessage, RoleModelCycle, RoleModelCycleResult, SessionHandoffOptions, SessionOAuthAccountList, SessionStats, UsageFallbackConfirmation } from "./agent-session-types.js";
|
|
53
|
+
import type { AgentSessionConfig, AgentSessionDisposeOptions, AsyncJobSnapshot, CommandMetadataChangedListener, ContextUsageBreakdown, FollowUpOptions, FreshSessionResult, HandoffResult, ModelCycleResult, Prewalk, PromptOptions, ResetSessionContextResult, ResolvedRoleModel, RestoredQueuedMessage, RoleModelCycle, RoleModelCycleResult, SessionHandoffOptions, SessionOAuthAccountList, SessionStats, UsageFallbackConfirmation } from "./agent-session-types.js";
|
|
53
54
|
import type { ClientBridge } from "./client-bridge.js";
|
|
54
55
|
import { type CustomMessage, type CustomMessagePayload } from "./messages.js";
|
|
55
56
|
import { type AdvisorStats } from "./session-advisors.js";
|
|
@@ -180,6 +181,8 @@ export declare class AgentSession {
|
|
|
180
181
|
* Multiple listeners can be added. Returns unsubscribe function for this listener.
|
|
181
182
|
*/
|
|
182
183
|
subscribe(listener: AgentSessionEventListener): () => void;
|
|
184
|
+
/** Register cleanup that runs when this AgentSession adopts a different session ID. */
|
|
185
|
+
registerSessionChangeCallback(callback: () => void): () => void;
|
|
183
186
|
subscribeCommandMetadataChanged(listener: CommandMetadataChangedListener): () => void;
|
|
184
187
|
/** Run one abortable auto-learn capture outside the primary agent loop. */
|
|
185
188
|
runAutolearnCapture(capture: (signal: AbortSignal) => Promise<void>): Promise<void>;
|
|
@@ -199,6 +202,25 @@ export declare class AgentSession {
|
|
|
199
202
|
beginDispose(): void;
|
|
200
203
|
dispose(options?: AgentSessionDisposeOptions): Promise<void>;
|
|
201
204
|
freshSession(): FreshSessionResult | undefined;
|
|
205
|
+
/**
|
|
206
|
+
* Reset the current conversation in place: drop every message, queued turn,
|
|
207
|
+
* and pending tool call from the model's context while keeping the session
|
|
208
|
+
* itself — its id, title, cwd, model, settings, and on-disk transcript all
|
|
209
|
+
* survive. The next turn is sent with only the base system prompt plus the
|
|
210
|
+
* project rules/AGENTS.md.
|
|
211
|
+
*
|
|
212
|
+
* This is the in-place sibling of {@link newSession}: it reuses the same
|
|
213
|
+
* conversation-boundary teardown (drop the conversation, rotate provider-side
|
|
214
|
+
* session state so providers that keep history server-side resume nothing,
|
|
215
|
+
* re-prime the advisors, and undo any memory promotion) but skips minting a
|
|
216
|
+
* new session id and opening a fresh transcript file. Unlike
|
|
217
|
+
* {@link freshSession} (which only rotates provider stream state) it also
|
|
218
|
+
* clears the conversation.
|
|
219
|
+
*
|
|
220
|
+
* Returns `undefined` without mutating anything while a response is
|
|
221
|
+
* streaming or a foreground bash/python execution is in flight.
|
|
222
|
+
*/
|
|
223
|
+
resetSessionContext(): Promise<ResetSessionContextResult | undefined>;
|
|
202
224
|
/** Full agent state */
|
|
203
225
|
get state(): AgentState;
|
|
204
226
|
/** Current model (may be undefined if not yet selected) */
|
|
@@ -476,6 +498,7 @@ export declare class AgentSession {
|
|
|
476
498
|
*/
|
|
477
499
|
followUp(text: string, images?: ImageContent[], options?: FollowUpOptions): Promise<void>;
|
|
478
500
|
queueDeferredMessage(message: CustomMessage): void;
|
|
501
|
+
queueLaunchCompletion(notification: DaemonCompletionNotification): Promise<void>;
|
|
479
502
|
/**
|
|
480
503
|
* Send a custom message to the session. Creates a CustomMessageEntry.
|
|
481
504
|
*
|
|
@@ -805,7 +828,8 @@ export declare class AgentSession {
|
|
|
805
828
|
selectedImages: ImageContent[];
|
|
806
829
|
cancelled: boolean;
|
|
807
830
|
}>;
|
|
808
|
-
|
|
831
|
+
/** Promotes a completed /btw answer from the explicitly authorized session and leaf. */
|
|
832
|
+
branchFromBtw(question: string, assistantMessage: AssistantMessage, leafId: string, sessionId: string): Promise<{
|
|
809
833
|
cancelled: boolean;
|
|
810
834
|
sessionFile: string | undefined;
|
|
811
835
|
}>;
|
|
@@ -56,6 +56,7 @@ declare class IndexedSessionStorageWriter implements SessionStorageWriter {
|
|
|
56
56
|
flags?: "a" | "w";
|
|
57
57
|
onError?: (err: Error) => void;
|
|
58
58
|
});
|
|
59
|
+
appendSync(line: string): void;
|
|
59
60
|
append(line: string): Promise<void>;
|
|
60
61
|
flush(): Promise<void>;
|
|
61
62
|
isOpen(): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DaemonCompletionNotification } from "../launch/protocol.js";
|
|
2
|
+
import type { CustomMessage } from "./messages.js";
|
|
3
|
+
/** Yield-queue kind for broker-owned supervised process completions. */
|
|
4
|
+
export declare const LAUNCH_COMPLETION_MESSAGE_TYPE = "launch-completion";
|
|
5
|
+
/** One broker completion awaiting injection into its owning session. */
|
|
6
|
+
export type LaunchCompletionEntry = DaemonCompletionNotification;
|
|
7
|
+
/** Whether a broker completion belongs to the primary session or its advisor. */
|
|
8
|
+
export declare function isLaunchCompletionOwner(owner: string, sessionId: string): boolean;
|
|
9
|
+
/** Build one model-visible notification per terminal supervised process exit. */
|
|
10
|
+
export declare function buildLaunchCompletionBatchMessage(entries: LaunchCompletionEntry[]): CustomMessage;
|
|
@@ -65,7 +65,7 @@ export interface SessionAdvisorsOptions {
|
|
|
65
65
|
/**
|
|
66
66
|
* Build the `replace`-mode `edit` a Cursor `pi_edit` frame needs. The
|
|
67
67
|
* advisor's own instance follows the configured `edit.mode` (`hashline` by
|
|
68
|
-
* default), whose schema the frame's `
|
|
68
|
+
* default), whose schema the frame's `old_string`/`new_string` args do not
|
|
69
69
|
* match, so without this every native advisor edit fails validation.
|
|
70
70
|
*/
|
|
71
71
|
createEditTool?(): AgentTool | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentMessage } from "@oh-my-pi/pi-agent-core";
|
|
2
|
-
import { type ServiceTierByFamily } from "@oh-my-pi/pi-ai";
|
|
2
|
+
import { type ProviderPayload, type ServiceTierByFamily } from "@oh-my-pi/pi-ai";
|
|
3
3
|
import { type CompactionEntry, type SessionEntry } from "./session-entries.js";
|
|
4
4
|
export interface SessionContext {
|
|
5
5
|
messages: AgentMessage[];
|
|
@@ -55,4 +55,5 @@ export interface BuildSessionContextOptions {
|
|
|
55
55
|
export interface StrippedToolCallsMarker {
|
|
56
56
|
strippedToolCalls?: number;
|
|
57
57
|
}
|
|
58
|
+
export declare function getOpenAiRemoteCompactionPayload(compaction: CompactionEntry | null | undefined): ProviderPayload | undefined;
|
|
58
59
|
export declare function buildSessionContext(entries: SessionEntry[], leafId?: string | null, byId?: Map<string, SessionEntry>, options?: BuildSessionContextOptions): SessionContext;
|
|
@@ -31,6 +31,8 @@ export interface SessionHeader {
|
|
|
31
31
|
*/
|
|
32
32
|
additionalDirectories?: string[];
|
|
33
33
|
parentSession?: string;
|
|
34
|
+
/** Prior absolute JSONL locations recorded by successful session moves. */
|
|
35
|
+
previousSessionFiles?: string[];
|
|
34
36
|
/** Provider prompt-cache identity inherited by exact-route full forks. */
|
|
35
37
|
providerPromptCacheKey?: string;
|
|
36
38
|
}
|
|
@@ -102,6 +104,17 @@ export interface BranchSummaryEntry<T = unknown> extends SessionEntryBase {
|
|
|
102
104
|
/** True if generated by an extension, false if pi-generated */
|
|
103
105
|
fromExtension?: boolean;
|
|
104
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Pure marker entry recorded by `/reset` (resetSessionContext). It carries no
|
|
109
|
+
* payload — its presence on the branch is a durable boundary the collapsed
|
|
110
|
+
* live transcript and the model-context rebuild start emission after, so a
|
|
111
|
+
* rebuild (theme change, focus attach, /shake, resume) does not resurrect the
|
|
112
|
+
* pre-reset conversation. The on-disk record and the plain `transcript:true`
|
|
113
|
+
* export path keep the full pre-reset history.
|
|
114
|
+
*/
|
|
115
|
+
export interface ResetBoundaryEntry extends SessionEntryBase {
|
|
116
|
+
type: "reset_boundary";
|
|
117
|
+
}
|
|
105
118
|
/**
|
|
106
119
|
* Custom entry for extensions to store extension-specific data in the session.
|
|
107
120
|
* Use customType to identify your extension's entries.
|
|
@@ -135,6 +148,7 @@ declare module "@oh-my-pi/pi-agent-core/compaction/entries" {
|
|
|
135
148
|
interface CustomCompactionSessionEntries {
|
|
136
149
|
titleChange: TitleChangeEntry;
|
|
137
150
|
credentialPin: CredentialPinEntry;
|
|
151
|
+
resetBoundary: ResetBoundaryEntry;
|
|
138
152
|
}
|
|
139
153
|
}
|
|
140
154
|
/** TTSR injection entry - tracks which time-traveling rules have been injected this session. */
|
|
@@ -210,7 +224,7 @@ export interface CustomMessageEntry<T = unknown> extends SessionEntryBase {
|
|
|
210
224
|
attribution?: MessageAttribution;
|
|
211
225
|
}
|
|
212
226
|
/** Session entry - has id/parentId for tree structure (returned by "read" methods in SessionManager) */
|
|
213
|
-
export type SessionEntry = SessionMessageEntry | ThinkingLevelChangeEntry | ModelChangeEntry | ServiceTierChangeEntry | CompactionEntry | BranchSummaryEntry | CustomEntry | CustomMessageEntry | LabelEntry | TitleChangeEntry | TtsrInjectionEntry | SessionInitEntry | ModeChangeEntry | CredentialPinEntry;
|
|
227
|
+
export type SessionEntry = SessionMessageEntry | ThinkingLevelChangeEntry | ModelChangeEntry | ServiceTierChangeEntry | CompactionEntry | BranchSummaryEntry | CustomEntry | CustomMessageEntry | LabelEntry | TitleChangeEntry | TtsrInjectionEntry | SessionInitEntry | ModeChangeEntry | CredentialPinEntry | ResetBoundaryEntry;
|
|
214
228
|
/** Raw logical file entry after loaders strip any fixed-width title slot. */
|
|
215
229
|
export type FileEntry = SessionHeader | SessionEntry;
|
|
216
230
|
/** Physical JSONL entry before slot-aware loaders fold the title slot. */
|
|
@@ -87,6 +87,7 @@ export interface SessionMaintenanceHost {
|
|
|
87
87
|
syncTodoPhasesFromBranch(): void;
|
|
88
88
|
resetAdvisorRuntimes(): void;
|
|
89
89
|
rebaseAfterCompaction(): void;
|
|
90
|
+
recordAnchoredHistoryRewrite(tokensRemoved: number): void;
|
|
90
91
|
getContextBreakdown(options?: {
|
|
91
92
|
contextWindow?: number;
|
|
92
93
|
pendingMessages?: AgentMessage[];
|
|
@@ -39,17 +39,22 @@ export declare class SessionPersistenceIndeterminateError extends AggregateError
|
|
|
39
39
|
* tree by `(id, parentId)`, and the mutable leaf pointer selects which path is
|
|
40
40
|
* active for future appends and for LLM context construction.
|
|
41
41
|
*
|
|
42
|
-
* Durability is software-crash safe but not power-loss safe:
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* that
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
42
|
+
* Durability is software-crash safe but not power-loss safe: completed entries
|
|
43
|
+
* (user/assistant/toolResult messages, tool_execution_start markers, custom
|
|
44
|
+
* entries) are handed to the OS synchronously in-body on append and never
|
|
45
|
+
* `fsync`'d. In-flight streaming text is intentionally not durable until
|
|
46
|
+
* `message_end` persists the finished message.
|
|
47
|
+
*
|
|
48
|
+
* While an in-place atomic rewrite is publishing, a concurrent completed append
|
|
49
|
+
* supersedes that publish with a synchronous full-body rewrite so the entry is
|
|
50
|
+
* software-crash durable before the append returns; the abandoned atomic's
|
|
51
|
+
* `commitGuard` then refuses to clobber the fresher body.
|
|
52
|
+
*
|
|
53
|
+
* During {@link moveTo}, appends write a full body to the live relocation path
|
|
54
|
+
* (source until rename, destination once the rename has landed) so a crash mid-
|
|
55
|
+
* move still preserves completed entries without recreating a vacated source.
|
|
56
|
+
* A trailing atomic rewrite still rewrites the header cwd after the path is
|
|
57
|
+
* repointed.
|
|
53
58
|
*/
|
|
54
59
|
export declare class SessionManager {
|
|
55
60
|
#private;
|
|
@@ -228,6 +233,13 @@ export declare class SessionManager {
|
|
|
228
233
|
readSummarize?: boolean;
|
|
229
234
|
}): string;
|
|
230
235
|
appendCompaction<T = unknown>(summary: string, shortSummary: string | undefined, firstKeptEntryId: string, tokensBefore: number, details?: T, fromExtension?: boolean, preserveData?: Record<string, unknown>): string;
|
|
236
|
+
/**
|
|
237
|
+
* Append the durable conversation boundary recorded by `/reset`. The
|
|
238
|
+
* collapsed live transcript and the model-context rebuild start after the
|
|
239
|
+
* latest one, while the full history stays on disk (the plain
|
|
240
|
+
* `transcript:true` export walks it unchanged).
|
|
241
|
+
*/
|
|
242
|
+
appendResetBoundary(): string;
|
|
231
243
|
appendCustomEntry(customType: string, data?: unknown): string;
|
|
232
244
|
/**
|
|
233
245
|
* Rewrite the session file after in-place entry updates (e.g. pruning old tool
|
|
@@ -38,6 +38,16 @@ export declare class SessionStatsTracker {
|
|
|
38
38
|
get revision(): number;
|
|
39
39
|
/** Non-message token count captured for the active provider request. */
|
|
40
40
|
get pendingNonMessageTokens(): number | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Apply an estimated prompt-prefix reduction to the current provider anchor.
|
|
43
|
+
*
|
|
44
|
+
* History after the anchor is estimated live by {@link getContextBreakdown};
|
|
45
|
+
* callers must pass only savings from entries already included in the
|
|
46
|
+
* anchor's provider-reported prompt. Persisting the correction on the
|
|
47
|
+
* assistant snapshot keeps reloads accurate, and the next successful
|
|
48
|
+
* assistant response naturally replaces it with a fresh provider anchor.
|
|
49
|
+
*/
|
|
50
|
+
recordAnchoredHistoryRewrite(tokensRemoved: number): void;
|
|
41
51
|
/** Sets or clears the in-flight context snapshot. */
|
|
42
52
|
setPendingSnapshot(snapshot: PendingContextSnapshot | undefined): void;
|
|
43
53
|
/** Recomputes an in-flight snapshot after history is compacted or rewritten. */
|
|
@@ -6,13 +6,25 @@ export interface SessionStorageStat {
|
|
|
6
6
|
}
|
|
7
7
|
export interface SessionStorageWriter {
|
|
8
8
|
/**
|
|
9
|
-
* Append one newline-terminated line.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Append one newline-terminated line.
|
|
10
|
+
*
|
|
11
|
+
* File and memory storage apply the line synchronously before the returned
|
|
12
|
+
* promise settles, so a software crash after `append` returns (or after a
|
|
13
|
+
* fire-and-forget call begins) still sees the entry on disk / in body. No
|
|
14
|
+
* `fsync` — power loss may still drop the last page. Indexed backends update
|
|
15
|
+
* the local index immediately and queue the remote publish in call order.
|
|
12
16
|
*
|
|
13
17
|
* `line` MUST include the trailing newline.
|
|
14
18
|
*/
|
|
15
19
|
append(line: string): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Synchronous append when the backend can apply the line before return.
|
|
22
|
+
* File and memory implement this so {@link SessionManager} can latch the
|
|
23
|
+
* first write failure before the appending call returns (surfaced by a later
|
|
24
|
+
* flushSync/close/next append — the turn loop does not throw from append).
|
|
25
|
+
* Indexed backends update the local index immediately and queue remote I/O.
|
|
26
|
+
*/
|
|
27
|
+
appendSync?(line: string): void;
|
|
16
28
|
/** Resolve once all queued appends complete. No fsync. */
|
|
17
29
|
flush(): Promise<void>;
|
|
18
30
|
/** Drain synchronously flushable queued work when the backend supports it. No fsync. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AgentMessage } from "@oh-my-pi/pi-agent-core";
|
|
2
2
|
export interface YieldDispatcher<P> {
|
|
3
3
|
/** Drop entries already delivered through another path. Called per-entry at flush time. */
|
|
4
4
|
isStale?(entry: P): boolean;
|
|
@@ -19,7 +19,10 @@ export declare class YieldQueue {
|
|
|
19
19
|
constructor(options: YieldQueueOptions);
|
|
20
20
|
register<P>(kind: string, dispatcher: YieldDispatcher<P>): () => void;
|
|
21
21
|
enqueue<P>(kind: string, entry: P): void;
|
|
22
|
+
enqueueWithReceipt<P>(kind: string, entry: P): Promise<void>;
|
|
22
23
|
has(kind?: string): boolean;
|
|
24
|
+
/** Arrange an idle flush for entries queued near the end of a streaming run. */
|
|
25
|
+
requestIdleFlush(): void;
|
|
23
26
|
flush(mode: YieldFlushMode): Promise<void>;
|
|
24
27
|
/**
|
|
25
28
|
* Snapshot and remove all queued entries, returning one lazy thunk per kind.
|
|
@@ -33,5 +36,7 @@ export declare class YieldQueue {
|
|
|
33
36
|
/** Drop queued entries. With `kind`, drop only that kind's entries (leaving
|
|
34
37
|
* any pending idle-flush for other kinds intact); otherwise drop everything. */
|
|
35
38
|
clear(kind?: string): void;
|
|
39
|
+
/** Clear a scheduled-flush latch when its host task is cancelled before running. */
|
|
40
|
+
cancelIdleFlushScheduling(): void;
|
|
36
41
|
}
|
|
37
42
|
export {};
|
|
@@ -77,7 +77,8 @@ export interface BuildSystemPromptOptions {
|
|
|
77
77
|
/**
|
|
78
78
|
* Whether provider-native tool calling is active (no owned/in-band syntax).
|
|
79
79
|
* When true and `inlineToolDescriptors` is false, the inventory renders as a
|
|
80
|
-
* compact tool-name list; otherwise it renders full
|
|
80
|
+
* compact tool-name list; otherwise it renders the full Harmony-style
|
|
81
|
+
* `namespace functions { … }` catalog. Default: true
|
|
81
82
|
*/
|
|
82
83
|
nativeTools?: boolean;
|
|
83
84
|
/** Skills settings for discovery. */
|
|
@@ -113,6 +114,8 @@ export interface BuildSystemPromptOptions {
|
|
|
113
114
|
taskMaxConcurrency?: number;
|
|
114
115
|
/** Whether IRC-backed parallel coordination can be included in delegation policy. */
|
|
115
116
|
taskIrcEnabled?: boolean;
|
|
117
|
+
/** Whether the read-only `scout` subagent is spawnable (not disabled, allowed by spawn policy). Defaults to true. */
|
|
118
|
+
scoutAvailable?: boolean;
|
|
116
119
|
/** Rules with alwaysApply=true — their full content is injected into the prompt. */
|
|
117
120
|
alwaysApplyRules?: AlwaysApplyRule[];
|
|
118
121
|
/** Whether secret obfuscation is active. When true, explains the redaction format in the prompt. */
|
|
@@ -25,7 +25,7 @@ export declare function formatResultOutputFallback(result: Pick<SingleResult, "o
|
|
|
25
25
|
* (DepthCapacity: it currently has the `task` tool). `agentNames` are the
|
|
26
26
|
* per-item resolved agent types. Returns undefined when no nudge applies.
|
|
27
27
|
*/
|
|
28
|
-
export declare function buildSpecializationAdvisory(agentNames: string[], depthCapacity: boolean): string | undefined;
|
|
28
|
+
export declare function buildSpecializationAdvisory(agentNames: string[], depthCapacity: boolean, scoutAvailable?: boolean): string | undefined;
|
|
29
29
|
/**
|
|
30
30
|
* Suggestion — never a rejection — nudging the spawner to coordinate via the
|
|
31
31
|
* hub when one call creates ≥2 live siblings and it still holds spawn
|
|
@@ -48,6 +48,7 @@ export declare function composeSpawnAdvisory(args: {
|
|
|
48
48
|
depthCapacity: boolean;
|
|
49
49
|
ircEnabled: boolean;
|
|
50
50
|
willRunAsync: boolean;
|
|
51
|
+
scoutAvailable?: boolean;
|
|
51
52
|
}): string | undefined;
|
|
52
53
|
/**
|
|
53
54
|
* Task tool - Delegate tasks to specialized agents.
|
|
@@ -15,3 +15,8 @@ export interface ResolvedSpawnPolicy {
|
|
|
15
15
|
}
|
|
16
16
|
/** Resolves spawn frontmatter into the default and prompt/error surfaces. */
|
|
17
17
|
export declare function resolveSpawnPolicy(parentSpawns: string | boolean | null | undefined): ResolvedSpawnPolicy;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the `scout` agent is spawnable in a session: not disabled via
|
|
20
|
+
* `task.disabledAgents`, and permitted by the session spawn policy.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isScoutSpawnable(disabledAgents: readonly string[] | undefined, spawns: string | boolean | null | undefined): boolean;
|
package/dist/types/thinking.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ResolvedThinkingLevel, ThinkingLevel } from "@oh-my-pi/pi-agent-core";
|
|
2
2
|
import { Effort, type Model } from "@oh-my-pi/pi-ai";
|
|
3
|
+
export { CLI_THINKING_LEVELS } from "./cli/thinking-levels.js";
|
|
3
4
|
/**
|
|
4
5
|
* Metadata used to render thinking selector values in the coding-agent UI.
|
|
5
6
|
*/
|
|
@@ -81,13 +82,6 @@ export interface ConfiguredThinkingLevelMetadata {
|
|
|
81
82
|
export declare function parseConfiguredThinkingLevel(value: string | null | undefined): ConfiguredThinkingLevel | undefined;
|
|
82
83
|
/** Returns display metadata for a configured selector, including `auto`. */
|
|
83
84
|
export declare function getConfiguredThinkingLevelMetadata(level: ConfiguredThinkingLevel): ConfiguredThinkingLevelMetadata;
|
|
84
|
-
/**
|
|
85
|
-
* Thinking selectors accepted by the `--thinking` CLI flag, in display order:
|
|
86
|
-
* `off`, every concrete effort (`minimal`..`max`), then `auto`. Single source
|
|
87
|
-
* for the flag's `options` list, shell completions, and the "invalid level"
|
|
88
|
-
* warning so all three stay in sync.
|
|
89
|
-
*/
|
|
90
|
-
export declare const CLI_THINKING_LEVELS: readonly string[];
|
|
91
85
|
/**
|
|
92
86
|
* Parses a `--thinking` CLI value. Accepts every {@link parseConfiguredThinkingLevel}
|
|
93
87
|
* selector (`off`, `auto`, `minimal`..`max`) but rejects
|
|
@@ -41,7 +41,7 @@ export declare class AstGrepTool implements AgentTool<typeof astGrepSchema, AstG
|
|
|
41
41
|
readonly approval: "read";
|
|
42
42
|
readonly label = "AST Grep";
|
|
43
43
|
readonly summary = "Search code with AST patterns (structural grep)";
|
|
44
|
-
|
|
44
|
+
get description(): string;
|
|
45
45
|
readonly parameters: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
46
46
|
pat: string;
|
|
47
47
|
path?: string | undefined;
|
|
@@ -3,6 +3,7 @@ import type { Browser, CDPSession } from "puppeteer-core";
|
|
|
3
3
|
import type { CmuxKind } from "./cmux/rpc.js";
|
|
4
4
|
import { CmuxSocketClient } from "./cmux/socket-client.js";
|
|
5
5
|
import { type UserAgentOverride } from "./launch.js";
|
|
6
|
+
import type { RelayKind } from "./relay/kind.js";
|
|
6
7
|
export type PuppeteerBrowserKind = {
|
|
7
8
|
kind: "headless";
|
|
8
9
|
headless: boolean;
|
|
@@ -12,7 +13,7 @@ export type PuppeteerBrowserKind = {
|
|
|
12
13
|
} | {
|
|
13
14
|
kind: "connected";
|
|
14
15
|
cdpUrl: string;
|
|
15
|
-
};
|
|
16
|
+
} | RelayKind;
|
|
16
17
|
export type BrowserKind = PuppeteerBrowserKind | CmuxKind;
|
|
17
18
|
export type BrowserKindTag = BrowserKind["kind"];
|
|
18
19
|
interface BrowserHandleCommon {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Transport-agnostic websocket surface the bridge writes to. */
|
|
2
|
+
export interface RelaySocket {
|
|
3
|
+
send(text: string): void;
|
|
4
|
+
close(): void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Multiplexing CDP bridge between downstream puppeteer connections and the
|
|
8
|
+
* relay extension. One instance per relay server; all state lives here so an
|
|
9
|
+
* extension service-worker restart only has to re-handshake.
|
|
10
|
+
*/
|
|
11
|
+
export declare class RelayBridge {
|
|
12
|
+
#private;
|
|
13
|
+
constructor(opts?: {
|
|
14
|
+
log?: (message: string, data?: Record<string, unknown>) => void;
|
|
15
|
+
/** Group tabs the agent actively drives under one per-window Chrome tab group. */
|
|
16
|
+
group?: {
|
|
17
|
+
title: string;
|
|
18
|
+
color: string;
|
|
19
|
+
} | null;
|
|
20
|
+
});
|
|
21
|
+
/** True once the extension has completed its hello handshake. */
|
|
22
|
+
get ready(): boolean;
|
|
23
|
+
/** Payload for `GET /json/version`. */
|
|
24
|
+
versionInfo(wsUrl: string): Record<string, string>;
|
|
25
|
+
/** Payload for `GET /json/list` (debugging aid; per-target endpoints are not served). */
|
|
26
|
+
listTargets(): Array<Record<string, string>>;
|
|
27
|
+
/** A new extension socket connected; replaces any previous one. */
|
|
28
|
+
extConnected(socket: RelaySocket): void;
|
|
29
|
+
extClosed(socket: RelaySocket): void;
|
|
30
|
+
extMessage(socket: RelaySocket, raw: string): void;
|
|
31
|
+
/** Register a downstream CDP websocket; returns the connection id. */
|
|
32
|
+
cdpConnected(socket: RelaySocket): number;
|
|
33
|
+
cdpClosed(connId: number): void;
|
|
34
|
+
cdpMessage(connId: number, raw: string): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Stable broker daemon name for the relay server. */
|
|
2
|
+
export declare const RELAY_DAEMON_NAME = "omp.browser.relay";
|
|
3
|
+
/** True when the relay HTTP server answers /json/version at all (200 = extension connected, 503 = waiting for it). */
|
|
4
|
+
export declare function probeRelayServer(cdpUrl: string): Promise<boolean>;
|
|
5
|
+
/** Auto-start is only safe for endpoints this machine can own. */
|
|
6
|
+
export declare function isLoopbackRelayUrl(cdpUrl: string): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Ensure a relay server answers at `cdpUrl`, starting the broker-owned daemon
|
|
9
|
+
* when nothing is serving. Returns true once the HTTP endpoint responds — the
|
|
10
|
+
* extension handshake (503 → 200) is the caller's wait. False when the relay
|
|
11
|
+
* could not be started (broker unavailable or start rounds exhausted).
|
|
12
|
+
*/
|
|
13
|
+
export declare function ensureRelayDaemon(opts: {
|
|
14
|
+
cdpUrl: string;
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
}): Promise<boolean>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Browser kind selecting the omp browser relay. */
|
|
2
|
+
export interface RelayKind {
|
|
3
|
+
kind: "relay";
|
|
4
|
+
cdpUrl: string;
|
|
5
|
+
}
|
|
6
|
+
/** Default endpoint of the `omp-browser-relay` CLI. */
|
|
7
|
+
export declare const DEFAULT_RELAY_URL = "http://127.0.0.1:9224";
|
|
8
|
+
export interface ResolveRelayKindOptions {
|
|
9
|
+
/** `browser.relay` setting; `PI_BROWSER_RELAY=0|1` overrides it. */
|
|
10
|
+
settingEnabled?: boolean;
|
|
11
|
+
/** `browser.relayUrl` setting; falls back to {@link DEFAULT_RELAY_URL}. */
|
|
12
|
+
url?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Resolve the relay browser kind, or null when relay mode is disabled.
|
|
16
|
+
* Mirrors `resolveCmuxKind`: the setting opts in, the env var is the final
|
|
17
|
+
* override in both directions.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveRelayKind(options?: ResolveRelayKindOptions | null, env?: Record<string, string | undefined>): RelayKind | null;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire protocol between the relay server and the Chrome extension.
|
|
3
|
+
*
|
|
4
|
+
* The extension dials out to `ws://127.0.0.1:<port>/ext` and exchanges JSON
|
|
5
|
+
* messages. The relay drives the extension with numbered RPCs; the extension
|
|
6
|
+
* pushes tab lifecycle and `chrome.debugger` events as they happen.
|
|
7
|
+
*/
|
|
8
|
+
/** Minimal view of a Chrome tab shared between extension and relay. */
|
|
9
|
+
export interface TabSnapshot {
|
|
10
|
+
tabId: number;
|
|
11
|
+
url: string;
|
|
12
|
+
title: string;
|
|
13
|
+
active: boolean;
|
|
14
|
+
windowId: number;
|
|
15
|
+
/** Pinned tabs are never grouped (Chrome would silently unpin them). */
|
|
16
|
+
pinned: boolean;
|
|
17
|
+
/** Chrome tab group id; -1 when ungrouped. */
|
|
18
|
+
groupId: number;
|
|
19
|
+
}
|
|
20
|
+
/** RPCs the relay may ask the extension to perform. */
|
|
21
|
+
export type RelayRpcRequest = {
|
|
22
|
+
op: "attach";
|
|
23
|
+
tabId: number;
|
|
24
|
+
} | {
|
|
25
|
+
op: "detach";
|
|
26
|
+
tabId: number;
|
|
27
|
+
} | {
|
|
28
|
+
op: "send";
|
|
29
|
+
tabId: number;
|
|
30
|
+
sessionId?: string;
|
|
31
|
+
method: string;
|
|
32
|
+
params?: Record<string, unknown>;
|
|
33
|
+
} | {
|
|
34
|
+
op: "createTab";
|
|
35
|
+
url: string;
|
|
36
|
+
} | {
|
|
37
|
+
op: "removeTab";
|
|
38
|
+
tabId: number;
|
|
39
|
+
} | {
|
|
40
|
+
op: "activateTab";
|
|
41
|
+
tabId: number;
|
|
42
|
+
}
|
|
43
|
+
/** Add tabs to the per-window omp group (created/reused by title), remembering prior membership. */
|
|
44
|
+
| {
|
|
45
|
+
op: "group";
|
|
46
|
+
tabIds: number[];
|
|
47
|
+
title: string;
|
|
48
|
+
color: string;
|
|
49
|
+
}
|
|
50
|
+
/** Return tabs to their pre-omp group (or ungroup); no-op for tabs the relay never grouped. */
|
|
51
|
+
| {
|
|
52
|
+
op: "ungroup";
|
|
53
|
+
tabIds: number[];
|
|
54
|
+
};
|
|
55
|
+
/** Messages sent relay → extension. */
|
|
56
|
+
export type RelayToExtMessage = ({
|
|
57
|
+
t: "rpc";
|
|
58
|
+
id: number;
|
|
59
|
+
} & RelayRpcRequest) | {
|
|
60
|
+
t: "pong";
|
|
61
|
+
};
|
|
62
|
+
/** Messages sent extension → relay. */
|
|
63
|
+
export type ExtToRelayMessage = {
|
|
64
|
+
t: "hello";
|
|
65
|
+
userAgent: string;
|
|
66
|
+
browserVersion: string;
|
|
67
|
+
tabs: TabSnapshot[];
|
|
68
|
+
/** Tabs that already have a `chrome.debugger` attachment (relay reconciles after a service-worker restart). */
|
|
69
|
+
attachedTabIds: number[];
|
|
70
|
+
} | {
|
|
71
|
+
t: "cdpEvent";
|
|
72
|
+
tabId: number;
|
|
73
|
+
sessionId?: string;
|
|
74
|
+
method: string;
|
|
75
|
+
params?: Record<string, unknown>;
|
|
76
|
+
} | {
|
|
77
|
+
t: "detached";
|
|
78
|
+
tabId: number;
|
|
79
|
+
reason: string;
|
|
80
|
+
} | {
|
|
81
|
+
t: "tabCreated";
|
|
82
|
+
tab: TabSnapshot;
|
|
83
|
+
} | {
|
|
84
|
+
t: "tabUpdated";
|
|
85
|
+
tab: TabSnapshot;
|
|
86
|
+
} | {
|
|
87
|
+
t: "tabRemoved";
|
|
88
|
+
tabId: number;
|
|
89
|
+
} | {
|
|
90
|
+
t: "rpcResult";
|
|
91
|
+
id: number;
|
|
92
|
+
ok: boolean;
|
|
93
|
+
result?: unknown;
|
|
94
|
+
error?: string;
|
|
95
|
+
} | {
|
|
96
|
+
t: "ping";
|
|
97
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP + WebSocket server for the browser relay.
|
|
3
|
+
*
|
|
4
|
+
* Impersonates Chrome's CDP discovery endpoint so the omp browser tool (and
|
|
5
|
+
* any puppeteer client) can connect with a plain `browserURL`:
|
|
6
|
+
* - `GET /json/version` → 200 with `webSocketDebuggerUrl` once the extension
|
|
7
|
+
* is connected, 503 before that (clients like `waitForCdp` keep polling).
|
|
8
|
+
* - `GET /json` / `/json/list` → attachable page targets (debugging aid).
|
|
9
|
+
* - `WS /cdp` → downstream CDP clients (puppeteer).
|
|
10
|
+
* - `WS /ext` → the Chrome extension (token-gated when configured).
|
|
11
|
+
*
|
|
12
|
+
* Binds loopback only: anything that can reach this port can drive the
|
|
13
|
+
* user's logged-in browser.
|
|
14
|
+
*/
|
|
15
|
+
import { RelayBridge } from "./bridge.js";
|
|
16
|
+
/** Options for {@link startRelayServer}. */
|
|
17
|
+
export interface RelayServerOptions {
|
|
18
|
+
port: number;
|
|
19
|
+
/** Shared secret the extension must present as `?token=`; unset disables the check. */
|
|
20
|
+
token?: string;
|
|
21
|
+
/** Group tabs the agent actively drives under one per-window Chrome tab group (default on); `false` disables. */
|
|
22
|
+
group?: boolean | {
|
|
23
|
+
title: string;
|
|
24
|
+
color: string;
|
|
25
|
+
};
|
|
26
|
+
log?: (message: string, data?: Record<string, unknown>) => void;
|
|
27
|
+
}
|
|
28
|
+
/** A running relay server. */
|
|
29
|
+
export interface RelayServer {
|
|
30
|
+
bridge: RelayBridge;
|
|
31
|
+
port: number;
|
|
32
|
+
stop(): void;
|
|
33
|
+
}
|
|
34
|
+
/** Start the relay server on 127.0.0.1. Throws if the port is taken. */
|
|
35
|
+
export declare function startRelayServer(opts: RelayServerOptions): RelayServer;
|