@oh-my-pi/pi-coding-agent 15.10.9 → 15.10.11
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 +117 -0
- package/dist/cli.js +23087 -0
- package/dist/tokenizers.linux-x64-gnu-xcjh3jwk.node +0 -0
- package/dist/types/async/job-manager.d.ts +18 -0
- package/dist/types/cli/args.d.ts +1 -1
- package/dist/types/cli/dry-balance-cli.d.ts +1 -1
- package/dist/types/cli/gallery-cli.d.ts +1 -1
- package/dist/types/cli/gallery-fixtures/types.d.ts +1 -1
- package/dist/types/cli/usage-cli.d.ts +72 -0
- package/dist/types/commands/launch.d.ts +1 -1
- package/dist/types/commands/read.d.ts +1 -1
- package/dist/types/commands/usage.d.ts +25 -0
- package/dist/types/config/append-only-context-mode.d.ts +2 -1
- package/dist/types/config/model-discovery.d.ts +55 -0
- package/dist/types/config/model-registry.d.ts +20 -219
- package/dist/types/config/model-resolver.d.ts +16 -10
- package/dist/types/config/model-roles.d.ts +28 -0
- package/dist/types/config/models-config-schema.d.ts +523 -42
- package/dist/types/config/models-config.d.ts +385 -0
- package/dist/types/config/settings-schema.d.ts +12 -16
- package/dist/types/config/settings.d.ts +1 -1
- package/dist/types/debug/log-viewer.d.ts +1 -1
- package/dist/types/debug/raw-sse.d.ts +1 -1
- package/dist/types/debug/terminal-info.d.ts +0 -1
- package/dist/types/eval/backend.d.ts +0 -2
- package/dist/types/eval/idle-timeout.d.ts +0 -4
- package/dist/types/eval/js/shared/rewrite-imports.d.ts +6 -6
- package/dist/types/export/html/template.generated.d.ts +1 -1
- package/dist/types/extensibility/extensions/types.d.ts +3 -3
- package/dist/types/hindsight/mental-models.d.ts +17 -8
- package/dist/types/internal-urls/artifact-protocol.d.ts +2 -2
- package/dist/types/internal-urls/types.d.ts +1 -1
- package/dist/types/lsp/edits.d.ts +9 -0
- package/dist/types/lsp/index.d.ts +2 -2
- package/dist/types/lsp/types.d.ts +2 -0
- package/dist/types/lsp/utils.d.ts +3 -0
- package/dist/types/mcp/json-rpc.d.ts +5 -0
- package/dist/types/mnemopi/state.d.ts +11 -1
- package/dist/types/modes/components/agent-dashboard.d.ts +1 -1
- package/dist/types/modes/components/assistant-message.d.ts +3 -1
- package/dist/types/modes/components/bash-execution.d.ts +1 -1
- package/dist/types/modes/components/copy-selector.d.ts +1 -1
- package/dist/types/modes/components/dynamic-border.d.ts +1 -1
- package/dist/types/modes/components/extensions/extension-dashboard.d.ts +1 -1
- package/dist/types/modes/components/extensions/extension-list.d.ts +1 -1
- package/dist/types/modes/components/extensions/inspector-panel.d.ts +1 -1
- package/dist/types/modes/components/footer.d.ts +1 -1
- package/dist/types/modes/components/hook-editor.d.ts +5 -0
- package/dist/types/modes/components/hook-input.d.ts +4 -0
- package/dist/types/modes/components/hook-selector.d.ts +1 -1
- package/dist/types/modes/components/model-selector.d.ts +1 -1
- package/dist/types/modes/components/plan-review-overlay.d.ts +1 -1
- package/dist/types/modes/components/session-observer-overlay.d.ts +1 -1
- package/dist/types/modes/components/session-selector.d.ts +1 -1
- package/dist/types/modes/components/status-line/component.d.ts +1 -1
- package/dist/types/modes/components/tiny-title-download-progress.d.ts +1 -1
- package/dist/types/modes/components/transcript-container.d.ts +31 -26
- package/dist/types/modes/components/tree-selector.d.ts +1 -1
- package/dist/types/modes/components/user-message-selector.d.ts +1 -1
- package/dist/types/modes/components/user-message.d.ts +2 -1
- package/dist/types/modes/components/visual-truncate.d.ts +1 -1
- package/dist/types/modes/components/welcome.d.ts +19 -3
- package/dist/types/modes/controllers/mcp-command-controller.d.ts +1 -1
- package/dist/types/modes/controllers/streaming-reveal.d.ts +1 -1
- package/dist/types/modes/interactive-mode.d.ts +1 -1
- package/dist/types/modes/setup-wizard/scenes/sign-in.d.ts +1 -1
- package/dist/types/modes/setup-wizard/scenes/types.d.ts +1 -1
- package/dist/types/modes/setup-wizard/scenes/web-search.d.ts +1 -1
- package/dist/types/modes/setup-wizard/wizard-overlay.d.ts +1 -1
- package/dist/types/modes/types.d.ts +2 -1
- package/dist/types/session/agent-session.d.ts +1 -1
- package/dist/types/session/auth-broker-config.d.ts +4 -0
- package/dist/types/session/session-manager.d.ts +1 -1
- package/dist/types/slash-commands/helpers/stats-dashboard.d.ts +13 -0
- package/dist/types/ssh/connection-manager.d.ts +8 -0
- package/dist/types/task/discovery.d.ts +1 -2
- package/dist/types/task/parallel.d.ts +2 -2
- package/dist/types/task/worktree.d.ts +2 -0
- package/dist/types/tiny/title-client.d.ts +1 -1
- package/dist/types/tools/ask.d.ts +4 -0
- package/dist/types/tools/conflict-detect.d.ts +16 -0
- package/dist/types/tools/github-cache.d.ts +7 -0
- package/dist/types/tools/sqlite-reader.d.ts +3 -0
- package/dist/types/tools/todo.d.ts +2 -0
- package/dist/types/tui/output-block.d.ts +3 -3
- package/dist/types/utils/changelog.d.ts +8 -0
- package/dist/types/web/scrapers/readthedocs.d.ts +3 -0
- package/dist/types/web/scrapers/types.d.ts +12 -0
- package/dist/types/web/search/providers/codex.d.ts +1 -1
- package/dist/types/web/search/providers/gemini.d.ts +1 -1
- package/examples/extensions/tools.ts +5 -4
- package/package.json +14 -11
- package/scripts/build-binary.ts +18 -23
- package/scripts/bundle-dist.ts +81 -0
- package/scripts/{dev-launch → omp} +1 -1
- package/scripts/{dev-launch-preload.ts → omp.ts} +1 -1
- package/src/async/job-manager.ts +57 -3
- package/src/autoresearch/dashboard.ts +1 -1
- package/src/autoresearch/prompt-setup.md +6 -6
- package/src/autoresearch/prompt.md +6 -6
- package/src/capability/fs.ts +10 -0
- package/src/cli/args.ts +1 -1
- package/src/cli/auth-gateway-cli.ts +1 -3
- package/src/cli/dry-balance-cli.ts +1 -1
- package/src/cli/gallery-cli.ts +1 -1
- package/src/cli/gallery-fixtures/fs.ts +1 -1
- package/src/cli/gallery-fixtures/types.ts +5 -1
- package/src/cli/list-models.ts +7 -12
- package/src/cli/usage-cli.ts +603 -0
- package/src/cli-commands.ts +1 -0
- package/src/cli.ts +69 -5
- package/src/commands/complete.ts +1 -1
- package/src/commands/launch.ts +1 -1
- package/src/commands/read.ts +6 -3
- package/src/commands/usage.ts +35 -0
- package/src/commit/agentic/agent.ts +1 -1
- package/src/commit/model-selection.ts +1 -1
- package/src/config/append-only-context-mode.ts +6 -12
- package/src/config/model-discovery.ts +554 -0
- package/src/config/model-registry.ts +308 -1025
- package/src/config/model-resolver.ts +113 -156
- package/src/config/model-roles.ts +74 -0
- package/src/config/models-config-schema.ts +57 -8
- package/src/config/models-config.ts +129 -0
- package/src/config/settings-schema.ts +18 -14
- package/src/config/settings.ts +37 -1
- package/src/dap/client.ts +124 -37
- package/src/dap/session.ts +259 -158
- package/src/debug/log-viewer.ts +1 -1
- package/src/debug/raw-sse.ts +1 -1
- package/src/debug/terminal-info.ts +0 -3
- package/src/edit/diff.ts +95 -18
- package/src/edit/hashline/block-resolver.ts +20 -1
- package/src/edit/hashline/diff.ts +36 -1
- package/src/edit/hashline/execute.ts +8 -2
- package/src/edit/index.ts +16 -1
- package/src/edit/modes/patch.ts +52 -0
- package/src/edit/modes/replace.ts +56 -22
- package/src/edit/notebook.ts +22 -2
- package/src/edit/renderer.ts +36 -10
- package/src/eval/__tests__/completion-bridge.test.ts +1 -1
- package/src/eval/backend.ts +0 -2
- package/src/eval/completion-bridge.ts +2 -1
- package/src/eval/idle-timeout.ts +2 -9
- package/src/eval/js/context-manager.ts +6 -8
- package/src/eval/js/executor.ts +6 -2
- package/src/eval/js/index.ts +0 -2
- package/src/eval/js/shared/helpers.ts +5 -6
- package/src/eval/js/shared/local-module-loader.ts +1 -1
- package/src/eval/js/shared/prelude.txt +62 -1
- package/src/eval/js/shared/rewrite-imports.ts +49 -23
- package/src/eval/js/shared/runtime.ts +1 -1
- package/src/eval/py/index.ts +0 -2
- package/src/eval/py/kernel.ts +19 -0
- package/src/eval/py/runner.py +107 -3
- package/src/exec/bash-executor.ts +3 -1
- package/src/export/html/template.generated.ts +1 -1
- package/src/export/html/template.js +3 -1
- package/src/extensibility/extensions/types.ts +3 -2
- package/src/extensibility/plugins/legacy-pi-compat.ts +20 -3
- package/src/hindsight/mental-models.ts +59 -12
- package/src/hindsight/state.ts +6 -1
- package/src/internal-urls/artifact-protocol.ts +11 -2
- package/src/internal-urls/docs-index.generated.ts +10 -10
- package/src/internal-urls/issue-pr-protocol.ts +12 -5
- package/src/internal-urls/router.ts +1 -1
- package/src/internal-urls/types.ts +1 -1
- package/src/lib/xai-http.ts +1 -1
- package/src/lsp/client.ts +118 -38
- package/src/lsp/clients/biome-client.ts +101 -39
- package/src/lsp/edits.ts +143 -95
- package/src/lsp/index.ts +31 -22
- package/src/lsp/render.ts +1 -1
- package/src/lsp/types.ts +2 -0
- package/src/lsp/utils.ts +28 -10
- package/src/main.ts +165 -17
- package/src/mcp/json-rpc.ts +35 -5
- package/src/mcp/transports/stdio.ts +7 -1
- package/src/memories/index.ts +2 -1
- package/src/mnemopi/backend.ts +25 -3
- package/src/mnemopi/state.ts +38 -2
- package/src/modes/components/agent-dashboard.ts +10 -7
- package/src/modes/components/assistant-message.ts +19 -13
- package/src/modes/components/bash-execution.ts +1 -1
- package/src/modes/components/copy-selector.ts +1 -1
- package/src/modes/components/diff.ts +13 -2
- package/src/modes/components/dynamic-border.ts +12 -3
- package/src/modes/components/extensions/extension-dashboard.ts +8 -5
- package/src/modes/components/extensions/extension-list.ts +1 -1
- package/src/modes/components/extensions/inspector-panel.ts +1 -1
- package/src/modes/components/footer.ts +1 -1
- package/src/modes/components/history-search.ts +1 -1
- package/src/modes/components/hook-editor.ts +8 -0
- package/src/modes/components/hook-input.ts +8 -0
- package/src/modes/components/hook-selector.ts +2 -2
- package/src/modes/components/model-selector.ts +66 -54
- package/src/modes/components/plan-review-overlay.ts +1 -1
- package/src/modes/components/session-observer-overlay.ts +2 -2
- package/src/modes/components/session-selector.ts +1 -1
- package/src/modes/components/settings-selector.ts +5 -1
- package/src/modes/components/status-line/component.ts +1 -1
- package/src/modes/components/tiny-title-download-progress.ts +1 -1
- package/src/modes/components/transcript-container.ts +373 -141
- package/src/modes/components/tree-selector.ts +3 -3
- package/src/modes/components/user-message-selector.ts +1 -1
- package/src/modes/components/user-message.ts +17 -5
- package/src/modes/components/visual-truncate.ts +1 -1
- package/src/modes/components/welcome.ts +108 -26
- package/src/modes/controllers/command-controller.ts +10 -3
- package/src/modes/controllers/event-controller.ts +73 -49
- package/src/modes/controllers/input-controller.ts +5 -5
- package/src/modes/controllers/mcp-command-controller.ts +1 -1
- package/src/modes/controllers/selector-controller.ts +1 -5
- package/src/modes/controllers/streaming-reveal.ts +85 -18
- package/src/modes/interactive-mode.ts +5 -19
- package/src/modes/setup-wizard/scenes/glyph.ts +1 -1
- package/src/modes/setup-wizard/scenes/providers.ts +1 -1
- package/src/modes/setup-wizard/scenes/sign-in.ts +1 -1
- package/src/modes/setup-wizard/scenes/theme.ts +1 -1
- package/src/modes/setup-wizard/scenes/types.ts +1 -1
- package/src/modes/setup-wizard/scenes/web-search.ts +1 -1
- package/src/modes/setup-wizard/wizard-overlay.ts +1 -1
- package/src/modes/types.ts +2 -1
- package/src/prompts/agents/explore.md +2 -2
- package/src/prompts/agents/librarian.md +1 -2
- package/src/prompts/agents/oracle.md +1 -1
- package/src/prompts/agents/plan.md +5 -5
- package/src/prompts/agents/task.md +5 -5
- package/src/prompts/ci-green-request.md +5 -7
- package/src/prompts/goals/goal-budget-limit.md +2 -2
- package/src/prompts/goals/goal-continuation.md +4 -4
- package/src/prompts/goals/goal-mode-active.md +1 -1
- package/src/prompts/memories/read-path.md +1 -1
- package/src/prompts/memories/stage_one_system.md +2 -2
- package/src/prompts/review-custom-request.md +1 -1
- package/src/prompts/system/agent-creation-architect.md +2 -2
- package/src/prompts/system/auto-continue.md +1 -1
- package/src/prompts/system/background-tan-dispatch.md +1 -1
- package/src/prompts/system/btw-user.md +2 -2
- package/src/prompts/system/commit-message-system.md +13 -1
- package/src/prompts/system/custom-system-prompt.md +1 -1
- package/src/prompts/system/eager-todo.md +2 -2
- package/src/prompts/system/irc-incoming.md +1 -1
- package/src/prompts/system/manual-continue.md +1 -1
- package/src/prompts/system/omfg-user.md +3 -4
- package/src/prompts/system/orchestrate-notice.md +9 -9
- package/src/prompts/system/plan-mode-active.md +4 -4
- package/src/prompts/system/plan-mode-subagent.md +4 -5
- package/src/prompts/system/plan-mode-tool-decision-reminder.md +1 -1
- package/src/prompts/system/project-prompt.md +2 -2
- package/src/prompts/system/subagent-system-prompt.md +4 -4
- package/src/prompts/system/system-prompt.md +15 -26
- package/src/prompts/system/title-system.md +2 -2
- package/src/prompts/system/ttsr-tool-reminder.md +1 -1
- package/src/prompts/system/workflow-notice.md +1 -1
- package/src/prompts/tools/ast-edit.md +1 -1
- package/src/prompts/tools/ast-grep.md +2 -2
- package/src/prompts/tools/bash.md +8 -10
- package/src/prompts/tools/browser.md +7 -7
- package/src/prompts/tools/debug.md +1 -1
- package/src/prompts/tools/eval.md +3 -3
- package/src/prompts/tools/find.md +0 -1
- package/src/prompts/tools/github.md +8 -7
- package/src/prompts/tools/goal.md +1 -1
- package/src/prompts/tools/image-gen.md +1 -1
- package/src/prompts/tools/inspect-image-system.md +1 -1
- package/src/prompts/tools/irc.md +15 -15
- package/src/prompts/tools/lsp.md +2 -2
- package/src/prompts/tools/patch.md +2 -2
- package/src/prompts/tools/read.md +3 -4
- package/src/prompts/tools/recall.md +1 -1
- package/src/prompts/tools/reflect.md +1 -1
- package/src/prompts/tools/render-mermaid.md +2 -2
- package/src/prompts/tools/replace.md +4 -10
- package/src/prompts/tools/rewind.md +2 -2
- package/src/prompts/tools/search-tool-bm25.md +1 -9
- package/src/prompts/tools/search.md +0 -1
- package/src/prompts/tools/ssh.md +0 -4
- package/src/prompts/tools/task.md +2 -3
- package/src/prompts/tools/todo.md +6 -2
- package/src/sdk.ts +23 -10
- package/src/session/agent-session.ts +44 -10
- package/src/session/auth-broker-config.ts +30 -1
- package/src/session/session-manager.ts +2 -2
- package/src/session/streaming-output.ts +23 -2
- package/src/slash-commands/builtin-registry.ts +20 -0
- package/src/slash-commands/helpers/stats-dashboard.ts +85 -0
- package/src/ssh/connection-manager.ts +27 -0
- package/src/task/commands.ts +2 -1
- package/src/task/discovery.ts +17 -24
- package/src/task/executor.ts +61 -53
- package/src/task/index.ts +137 -60
- package/src/task/parallel.ts +3 -3
- package/src/task/render.ts +2 -2
- package/src/task/worktree.ts +64 -56
- package/src/thinking.ts +2 -1
- package/src/tiny/title-client.ts +32 -14
- package/src/tools/archive-reader.ts +30 -2
- package/src/tools/ask.ts +104 -21
- package/src/tools/ast-edit.ts +25 -5
- package/src/tools/auto-generated-guard.ts +20 -3
- package/src/tools/bash-interactive.ts +27 -7
- package/src/tools/bash.ts +54 -13
- package/src/tools/browser/launch.ts +11 -2
- package/src/tools/browser/readable.ts +19 -2
- package/src/tools/browser/registry.ts +4 -1
- package/src/tools/browser/render.ts +2 -2
- package/src/tools/browser/tab-supervisor.ts +55 -16
- package/src/tools/conflict-detect.ts +50 -4
- package/src/tools/debug.ts +1 -1
- package/src/tools/eval-render.ts +5 -5
- package/src/tools/eval.ts +0 -2
- package/src/tools/fetch.ts +33 -10
- package/src/tools/gh-cache-invalidation.ts +63 -8
- package/src/tools/gh-renderer.ts +1 -1
- package/src/tools/gh.ts +172 -29
- package/src/tools/github-cache.ts +70 -6
- package/src/tools/image-gen.ts +3 -9
- package/src/tools/irc.ts +5 -1
- package/src/tools/job.ts +1 -1
- package/src/tools/read.ts +202 -61
- package/src/tools/render-utils.ts +3 -3
- package/src/tools/resolve.ts +1 -1
- package/src/tools/search.ts +92 -29
- package/src/tools/sqlite-reader.ts +17 -5
- package/src/tools/ssh.ts +8 -8
- package/src/tools/todo.ts +51 -12
- package/src/tools/write.ts +118 -18
- package/src/tui/output-block.ts +4 -4
- package/src/utils/changelog.ts +27 -1
- package/src/utils/file-mentions.ts +2 -1
- package/src/web/scrapers/arxiv.ts +1 -1
- package/src/web/scrapers/go-pkg.ts +1 -1
- package/src/web/scrapers/iacr.ts +1 -1
- package/src/web/scrapers/readthedocs.ts +1 -1
- package/src/web/scrapers/twitter.ts +2 -1
- package/src/web/scrapers/types.ts +87 -8
- package/src/web/scrapers/wikipedia.ts +1 -1
- package/src/web/scrapers/youtube.ts +6 -1
- package/src/web/search/index.ts +1 -1
- package/src/web/search/providers/anthropic.ts +8 -2
- package/src/web/search/providers/codex.ts +2 -1
- package/src/web/search/providers/gemini.ts +2 -3
- package/src/web/search/render.ts +8 -6
- package/dist/types/config/model-equivalence.d.ts +0 -24
- package/dist/types/config/model-id-affixes.d.ts +0 -12
- package/dist/types/config/model-provider-priority.d.ts +0 -1
- package/dist/types/exec/idle-timeout-watchdog.d.ts +0 -18
- package/src/config/model-equivalence.ts +0 -875
- package/src/config/model-id-affixes.ts +0 -81
- package/src/config/model-provider-priority.ts +0 -56
- package/src/exec/idle-timeout-watchdog.ts +0 -126
|
Binary file
|
|
@@ -15,6 +15,12 @@ export interface AsyncJob {
|
|
|
15
15
|
* supply an id (e.g. legacy tests, SDK consumers without an agent context).
|
|
16
16
|
*/
|
|
17
17
|
ownerId?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Job is registered but parked behind a caller-managed gate (e.g. a task
|
|
20
|
+
* batch semaphore). Queued jobs do not count toward the running-job limit
|
|
21
|
+
* until the caller invokes `markRunning()` from the run context.
|
|
22
|
+
*/
|
|
23
|
+
queued?: boolean;
|
|
18
24
|
}
|
|
19
25
|
export interface AsyncJobManagerOptions {
|
|
20
26
|
onJobComplete: (jobId: string, text: string, job?: AsyncJob) => void | Promise<void>;
|
|
@@ -32,6 +38,8 @@ export interface AsyncJobRegisterOptions {
|
|
|
32
38
|
/** Registry id of the agent that owns this job; used to scope cancelAll. */
|
|
33
39
|
ownerId?: string;
|
|
34
40
|
onProgress?: (text: string, details?: Record<string, unknown>) => void | Promise<void>;
|
|
41
|
+
/** Register the job in queued state; see {@link AsyncJob.queued}. */
|
|
42
|
+
queued?: boolean;
|
|
35
43
|
}
|
|
36
44
|
/**
|
|
37
45
|
* Filter applied to job query/cancel APIs. With `ownerId`, results are
|
|
@@ -50,10 +58,14 @@ export declare class AsyncJobManager {
|
|
|
50
58
|
/** Reset the process-global instance. Test-only. */
|
|
51
59
|
static resetForTests(): void;
|
|
52
60
|
constructor(options: AsyncJobManagerOptions);
|
|
61
|
+
/** True when the running-job count has reached the configured cap. */
|
|
62
|
+
get atCapacity(): boolean;
|
|
53
63
|
register(type: "bash" | "task", label: string, run: (ctx: {
|
|
54
64
|
jobId: string;
|
|
55
65
|
signal: AbortSignal;
|
|
56
66
|
reportProgress: (text: string, details?: Record<string, unknown>) => Promise<void>;
|
|
67
|
+
/** Clear the queued flag once the job actually starts executing. */
|
|
68
|
+
markRunning: () => void;
|
|
57
69
|
}) => Promise<string>, options?: AsyncJobRegisterOptions): string;
|
|
58
70
|
/**
|
|
59
71
|
* Cancel a single job by id. When `filter.ownerId` is set and does not
|
|
@@ -70,6 +82,12 @@ export declare class AsyncJobManager {
|
|
|
70
82
|
watchJobs(jobIds: string[]): number;
|
|
71
83
|
unwatchJobs(jobIds: string[]): number;
|
|
72
84
|
acknowledgeDeliveries(jobIds: string[]): number;
|
|
85
|
+
/**
|
|
86
|
+
* Lift a foreground-wait suppression set via `acknowledgeDeliveries`. If the
|
|
87
|
+
* job already finished while suppressed (its delivery enqueue was skipped),
|
|
88
|
+
* re-enqueue the completion so the result is still delivered exactly once.
|
|
89
|
+
*/
|
|
90
|
+
resumeDeliveries(jobIds: string[]): void;
|
|
73
91
|
/**
|
|
74
92
|
* Cancel running jobs. With `filter.ownerId` set, cancels only jobs the
|
|
75
93
|
* matching agent registered; with no filter, cancels every running job
|
package/dist/types/cli/args.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* CLI argument parsing and help display
|
|
3
3
|
*/
|
|
4
|
-
import { type Effort } from "@oh-my-pi/pi-
|
|
4
|
+
import { type Effort } from "@oh-my-pi/pi-catalog/effort";
|
|
5
5
|
export type Mode = "text" | "json" | "rpc" | "acp" | "rpc-ui";
|
|
6
6
|
export interface Args {
|
|
7
7
|
cwd?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Api, AssistantMessageEventStream, AuthCredentialSnapshotEntry, Context, Model, OAuthAccess, OAuthAccessResolution, SimpleStreamOptions } from "@oh-my-pi/pi-ai";
|
|
2
|
-
import type { CanonicalModelVariant } from "
|
|
2
|
+
import type { CanonicalModelVariant } from "@oh-my-pi/pi-catalog/identity";
|
|
3
3
|
import { type CanonicalModelQueryOptions } from "../config/model-registry";
|
|
4
4
|
import { Settings } from "../config/settings";
|
|
5
5
|
export interface DryBalanceCommandArgs {
|
|
@@ -34,7 +34,7 @@ export declare function resolveFixture(name: string): GalleryFixture;
|
|
|
34
34
|
* to the requested state, settles any async edit preview, then snapshots the
|
|
35
35
|
* render and stops all animation timers.
|
|
36
36
|
*/
|
|
37
|
-
export declare function renderGalleryState(name: string, fixture: GalleryFixture, state: GalleryState, width: number, expanded?: boolean): Promise<string[]>;
|
|
37
|
+
export declare function renderGalleryState(name: string, fixture: GalleryFixture, state: GalleryState, width: number, expanded?: boolean): Promise<readonly string[]>;
|
|
38
38
|
/**
|
|
39
39
|
* Render the gallery. Iterates the renderer registry (or a single tool),
|
|
40
40
|
* printing each requested lifecycle state under a labeled section — or, with
|
|
@@ -24,7 +24,7 @@ export interface GalleryFixture {
|
|
|
24
24
|
* Custom gallery-only renderer for fixtures that are not one ToolExecutionComponent
|
|
25
25
|
* (for example the read-group transcript component).
|
|
26
26
|
*/
|
|
27
|
-
renderState?: (state: GalleryFixtureState, width: number, expanded: boolean) => string[] | Promise<string[]>;
|
|
27
|
+
renderState?: (state: GalleryFixtureState, width: number, expanded: boolean) => readonly string[] | Promise<readonly string[]>;
|
|
28
28
|
/**
|
|
29
29
|
* Set for tools whose real `AgentTool` attaches `renderCall`/`renderResult`
|
|
30
30
|
* directly on the instance (e.g. `task`). The harness then attaches
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Usage CLI command handler.
|
|
3
|
+
*
|
|
4
|
+
* Handles `omp usage` — fetches provider usage reports for every
|
|
5
|
+
* authenticated account and prints a detailed per-account breakdown
|
|
6
|
+
* (limits, windows, reset times, plan metadata). Accounts whose
|
|
7
|
+
* credentials produced no usage report are listed too, so the output
|
|
8
|
+
* always covers the full credential pool.
|
|
9
|
+
*/
|
|
10
|
+
import type { UsageReport } from "@oh-my-pi/pi-ai";
|
|
11
|
+
export interface UsageCommandArgs {
|
|
12
|
+
json?: boolean;
|
|
13
|
+
provider?: string;
|
|
14
|
+
redact?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Identity slice of a stored credential, for "every account" coverage. */
|
|
17
|
+
export interface UsageAccountIdentity {
|
|
18
|
+
provider: string;
|
|
19
|
+
type: "api_key" | "oauth";
|
|
20
|
+
email?: string;
|
|
21
|
+
accountId?: string;
|
|
22
|
+
projectId?: string;
|
|
23
|
+
enterpriseUrl?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Minimal-reveal masks for identity strings (`--redact`).
|
|
27
|
+
*
|
|
28
|
+
* Every mask shows a two-character anchor. When two identities share the
|
|
29
|
+
* anchor, the mask additionally reveals the shortest "middle-out"
|
|
30
|
+
* differentiator — the shortest substring (closest to the string's middle on
|
|
31
|
+
* ties) that no colliding identity contains — as `an*`, `ca*9*`, `ca*nb*`.
|
|
32
|
+
* Prefix growth is deliberately avoided: it leaks the start of the local
|
|
33
|
+
* part (`can.boluk@*`) when a couple of mid-string characters suffice.
|
|
34
|
+
* Duplicate strings (same account on two providers) share a mask.
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildRedactionMap(values: Iterable<string>): Map<string, string>;
|
|
37
|
+
/**
|
|
38
|
+
* Stored credentials that no usage report could be attributed to.
|
|
39
|
+
*
|
|
40
|
+
* Conservative on purpose: when a provider's reports carry no identity at
|
|
41
|
+
* all (or the credential is an API key alongside existing reports), we
|
|
42
|
+
* can't attribute, so we don't claim the account is missing.
|
|
43
|
+
*/
|
|
44
|
+
export declare function collectUnreportedAccounts(reports: UsageReport[], accounts: UsageAccountIdentity[]): UsageAccountIdentity[];
|
|
45
|
+
/** Per-window capacity stat: how much account quota is burned and left. */
|
|
46
|
+
export interface ProviderWindowStat {
|
|
47
|
+
/** Compact window label, e.g. "5h", "7d". */
|
|
48
|
+
window: string;
|
|
49
|
+
durationMs?: number;
|
|
50
|
+
/** Accounts reporting a limit in this window. */
|
|
51
|
+
accounts: number;
|
|
52
|
+
/** Sum of each account's binding used fraction — accounts' worth of quota burned. */
|
|
53
|
+
usedAccounts: number;
|
|
54
|
+
/** Accounts' worth of quota still available across reporting accounts. */
|
|
55
|
+
remainingAccounts: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Aggregate one provider's reports into per-window quota capacity stats.
|
|
59
|
+
*
|
|
60
|
+
* Limits are bucketed by window duration (5h, 7d, ...). Within a bucket each
|
|
61
|
+
* account contributes its single highest used fraction — when an account has
|
|
62
|
+
* several meters on the same window (tiered/metered limits), the most-burned
|
|
63
|
+
* one is what binds.
|
|
64
|
+
*/
|
|
65
|
+
export declare function computeProviderWindowStats(reports: UsageReport[]): ProviderWindowStat[];
|
|
66
|
+
/**
|
|
67
|
+
* Render the full text breakdown: per provider, per account, every limit
|
|
68
|
+
* with a bar, amounts, and reset times; unattributed credentials trail
|
|
69
|
+
* each provider section as "no usage data" rows.
|
|
70
|
+
*/
|
|
71
|
+
export declare function formatUsageBreakdown(reports: UsageReport[], accounts: UsageAccountIdentity[], nowMs: number, redaction?: Map<string, string>): string;
|
|
72
|
+
export declare function runUsageCommand(cmd: UsageCommandArgs): Promise<void>;
|
|
@@ -82,7 +82,7 @@ export default class Index extends Command {
|
|
|
82
82
|
};
|
|
83
83
|
thinking: import("@oh-my-pi/pi-utils/cli").FlagDescriptor<"string"> & {
|
|
84
84
|
description: string;
|
|
85
|
-
options: import("@oh-my-pi/pi-
|
|
85
|
+
options: import("@oh-my-pi/pi-catalog").Effort[];
|
|
86
86
|
};
|
|
87
87
|
"hide-thinking": import("@oh-my-pi/pi-utils/cli").FlagDescriptor<"boolean"> & {
|
|
88
88
|
description: string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Show provider usage limits for every authenticated account.
|
|
3
|
+
*/
|
|
4
|
+
import { Command } from "@oh-my-pi/pi-utils/cli";
|
|
5
|
+
export default class Usage extends Command {
|
|
6
|
+
static description: string;
|
|
7
|
+
static flags: {
|
|
8
|
+
json: import("@oh-my-pi/pi-utils/cli").FlagDescriptor<"boolean"> & {
|
|
9
|
+
char: string;
|
|
10
|
+
description: string;
|
|
11
|
+
default: boolean;
|
|
12
|
+
};
|
|
13
|
+
provider: import("@oh-my-pi/pi-utils/cli").FlagDescriptor<"string"> & {
|
|
14
|
+
char: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
redact: import("@oh-my-pi/pi-utils/cli").FlagDescriptor<"boolean"> & {
|
|
18
|
+
char: string;
|
|
19
|
+
description: string;
|
|
20
|
+
default: boolean;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
static examples: string[];
|
|
24
|
+
run(): Promise<void>;
|
|
25
|
+
}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
export interface AppendOnlyContextModel {
|
|
3
3
|
provider: string;
|
|
4
4
|
baseUrl: string;
|
|
5
|
-
compat
|
|
5
|
+
/** Verbatim sparse compat config (explicit user intent), never the resolved record. */
|
|
6
|
+
compatConfig?: object;
|
|
6
7
|
}
|
|
7
8
|
/** Resolves whether append-only context should be active for a model and setting. */
|
|
8
9
|
export declare function shouldEnableAppendOnlyContext(setting: "auto" | "on" | "off" | undefined, model: AppendOnlyContextModel | null | undefined): boolean;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP discovery protocols for configured and implicit providers — ollama,
|
|
3
|
+
* llama.cpp, lm-studio, openai-models-list, and new-api/one-api-style proxies.
|
|
4
|
+
* `ModelRegistry` owns the orchestration (status, state, caching) and calls
|
|
5
|
+
* `discoverModelsByProviderType` with a `DiscoveryContext`; built-in provider
|
|
6
|
+
* discovery lives in pi-catalog's provider-models.
|
|
7
|
+
*/
|
|
8
|
+
import type { FetchImpl } from "@oh-my-pi/pi-ai";
|
|
9
|
+
import type { Api, Model } from "@oh-my-pi/pi-ai/types";
|
|
10
|
+
import type { ModelSpec } from "@oh-my-pi/pi-catalog/types";
|
|
11
|
+
import type { ProviderDiscovery } from "./models-config-schema";
|
|
12
|
+
export declare const DISCOVERY_DEFAULT_MAX_TOKENS = 32768;
|
|
13
|
+
export declare function getImplicitOllamaBaseUrl(): string;
|
|
14
|
+
export declare function getOllamaContextLengthOverride(): number | undefined;
|
|
15
|
+
/** Routes discovered-model `maxTokens` defaults around Anthropic's 3× output divisor. */
|
|
16
|
+
export declare function discoveryDefaultMaxTokens(api: Api | undefined): number;
|
|
17
|
+
export interface DiscoveryProviderConfig {
|
|
18
|
+
provider: string;
|
|
19
|
+
api: Api;
|
|
20
|
+
baseUrl?: string;
|
|
21
|
+
headers?: Record<string, string>;
|
|
22
|
+
compat?: ModelSpec<Api>["compat"];
|
|
23
|
+
discovery: ProviderDiscovery;
|
|
24
|
+
optional?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** Registry-provided capabilities the protocol probes need; never the registry itself. */
|
|
27
|
+
export interface DiscoveryContext {
|
|
28
|
+
/** Injected fetch implementation (tests stub this). */
|
|
29
|
+
fetch: FetchImpl;
|
|
30
|
+
/**
|
|
31
|
+
* Resolve a provider's API key for `Authorization: Bearer …`. Returns
|
|
32
|
+
* undefined when no key is stored or it is a local/no-auth sentinel.
|
|
33
|
+
*/
|
|
34
|
+
getBearerApiKey(provider: string): Promise<string | undefined>;
|
|
35
|
+
}
|
|
36
|
+
export declare function discoverModelsByProviderType(providerConfig: DiscoveryProviderConfig, ctx: DiscoveryContext): Promise<Model<Api>[]>;
|
|
37
|
+
export declare function discoverOllamaModels(providerConfig: DiscoveryProviderConfig, ctx: DiscoveryContext): Promise<Model<Api>[]>;
|
|
38
|
+
export declare function discoverLlamaCppModels(providerConfig: DiscoveryProviderConfig, ctx: DiscoveryContext): Promise<Model<Api>[]>;
|
|
39
|
+
export declare function discoverOpenAIModelsList(providerConfig: DiscoveryProviderConfig, ctx: DiscoveryContext): Promise<Model<Api>[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Discover models from an Anthropic+OpenAI-compatible reseller proxy that
|
|
42
|
+
* exposes both `/v1/messages` and `/v1/chat/completions`, advertising each
|
|
43
|
+
* model's wire capabilities through `supported_endpoint_types` on
|
|
44
|
+
* `GET /v1/models` (new-api / one-api-style proxies).
|
|
45
|
+
*
|
|
46
|
+
* Routing per model:
|
|
47
|
+
* supported_endpoint_types: ["anthropic", ...] -> api: "anthropic-messages"
|
|
48
|
+
* supported_endpoint_types: ["openai"] -> api: "openai-completions"
|
|
49
|
+
* missing / neither -> provider-level api fallback
|
|
50
|
+
*
|
|
51
|
+
* Anthropic models share the same baseUrl; the Anthropic SDK strips a
|
|
52
|
+
* trailing `/v1` itself before appending `/v1/messages`, so the discovery
|
|
53
|
+
* URL (which ends in `/v1`) round-trips correctly.
|
|
54
|
+
*/
|
|
55
|
+
export declare function discoverProxyModels(providerConfig: DiscoveryProviderConfig, ctx: DiscoveryContext): Promise<Model<Api>[]>;
|
|
@@ -1,234 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { Api, Context, Model, SimpleStreamOptions, ThinkingConfig } from "@oh-my-pi/pi-ai/types";
|
|
1
|
+
import type { Api, Context, Model, ModelSpec, SimpleStreamOptions, ThinkingConfig } from "@oh-my-pi/pi-ai/types";
|
|
3
2
|
import type { AssistantMessageEventStream } from "@oh-my-pi/pi-ai/utils/event-stream";
|
|
3
|
+
import { type ModelRefreshStrategy } from "@oh-my-pi/pi-catalog/model-manager";
|
|
4
4
|
import type { ApiKeyResolver, FetchImpl } from "@oh-my-pi/pi-ai";
|
|
5
5
|
import type { OAuthCredentials, OAuthLoginCallbacks } from "@oh-my-pi/pi-ai/oauth/types";
|
|
6
|
-
import { type
|
|
6
|
+
import { type CanonicalModelIndex, type CanonicalModelRecord, type CanonicalModelVariant, type ModelEquivalenceConfig } from "@oh-my-pi/pi-catalog/identity";
|
|
7
7
|
import type { AuthStorage } from "../session/auth-storage";
|
|
8
8
|
import { type ApiKeyResolverOptions } from "./api-key-resolver";
|
|
9
|
-
import {
|
|
10
|
-
import { type CanonicalModelIndex, type CanonicalModelRecord, type CanonicalModelVariant, type ModelEquivalenceConfig } from "./model-equivalence";
|
|
11
|
-
import { type Settings } from "./settings";
|
|
9
|
+
import type { ConfigError } from "./config-file";
|
|
12
10
|
export type { CanonicalModelIndex, CanonicalModelRecord, CanonicalModelVariant, ModelEquivalenceConfig };
|
|
13
11
|
export declare const kNoAuth = "N/A";
|
|
14
12
|
export declare function isAuthenticated(apiKey: string | undefined | null): apiKey is string;
|
|
15
|
-
export type ModelRole = "default" | "smol" | "slow" | "vision" | "plan" | "designer" | "commit" | "task";
|
|
16
|
-
export interface ModelRoleInfo {
|
|
17
|
-
tag?: string;
|
|
18
|
-
name: string;
|
|
19
|
-
color?: ThemeColor;
|
|
20
|
-
}
|
|
21
|
-
export declare const MODEL_ROLES: Record<ModelRole, ModelRoleInfo>;
|
|
22
|
-
export declare const MODEL_ROLE_IDS: ModelRole[];
|
|
23
|
-
/** Alias for ModelRoleInfo - used for both built-in and custom roles */
|
|
24
|
-
export type RoleInfo = ModelRoleInfo;
|
|
25
|
-
/**
|
|
26
|
-
* Return the canonical set of known roles for selector/carousel UI.
|
|
27
|
-
*
|
|
28
|
-
* Built-ins always come first. Configured cycle order, model assignments, and
|
|
29
|
-
* tag metadata can introduce additional custom roles without requiring duplicate
|
|
30
|
-
* entries across settings.
|
|
31
|
-
*/
|
|
32
|
-
export declare function getKnownRoleIds(settings: Settings): string[];
|
|
33
|
-
/**
|
|
34
|
-
* Get role info for a role name (built-in or custom).
|
|
35
|
-
* Configured metadata overrides built-in defaults when present.
|
|
36
|
-
*/
|
|
37
|
-
export declare function getRoleInfo(role: string, settings: Settings): RoleInfo;
|
|
38
|
-
export declare const ModelsConfigFile: ConfigFile<{
|
|
39
|
-
providers?: Record<string, {
|
|
40
|
-
baseUrl?: string | undefined;
|
|
41
|
-
apiKey?: string | undefined;
|
|
42
|
-
api?: "anthropic-messages" | "azure-openai-responses" | "google-generative-ai" | "google-vertex" | "openai-codex-responses" | "openai-completions" | "openai-responses" | undefined;
|
|
43
|
-
headers?: Record<string, string> | undefined;
|
|
44
|
-
compat?: {
|
|
45
|
-
supportsStore?: boolean | undefined;
|
|
46
|
-
supportsDeveloperRole?: boolean | undefined;
|
|
47
|
-
supportsMultipleSystemMessages?: boolean | undefined;
|
|
48
|
-
supportsReasoningEffort?: boolean | undefined;
|
|
49
|
-
reasoningEffortMap?: {
|
|
50
|
-
minimal?: string | undefined;
|
|
51
|
-
low?: string | undefined;
|
|
52
|
-
medium?: string | undefined;
|
|
53
|
-
high?: string | undefined;
|
|
54
|
-
xhigh?: string | undefined;
|
|
55
|
-
} | undefined;
|
|
56
|
-
maxTokensField?: "max_completion_tokens" | "max_tokens" | undefined;
|
|
57
|
-
supportsUsageInStreaming?: boolean | undefined;
|
|
58
|
-
requiresToolResultName?: boolean | undefined;
|
|
59
|
-
requiresMistralToolIds?: boolean | undefined;
|
|
60
|
-
requiresAssistantAfterToolResult?: boolean | undefined;
|
|
61
|
-
requiresThinkingAsText?: boolean | undefined;
|
|
62
|
-
reasoningContentField?: "reasoning" | "reasoning_content" | "reasoning_text" | undefined;
|
|
63
|
-
requiresReasoningContentForToolCalls?: boolean | undefined;
|
|
64
|
-
allowsSyntheticReasoningContentForToolCalls?: boolean | undefined;
|
|
65
|
-
requiresAssistantContentForToolCalls?: boolean | undefined;
|
|
66
|
-
supportsToolChoice?: boolean | undefined;
|
|
67
|
-
disableReasoningOnForcedToolChoice?: boolean | undefined;
|
|
68
|
-
disableReasoningOnToolChoice?: boolean | undefined;
|
|
69
|
-
thinkingFormat?: "openai" | "openrouter" | "qwen" | "qwen-chat-template" | "zai" | undefined;
|
|
70
|
-
openRouterRouting?: {
|
|
71
|
-
only?: string[] | undefined;
|
|
72
|
-
order?: string[] | undefined;
|
|
73
|
-
} | undefined;
|
|
74
|
-
vercelGatewayRouting?: {
|
|
75
|
-
only?: string[] | undefined;
|
|
76
|
-
order?: string[] | undefined;
|
|
77
|
-
} | undefined;
|
|
78
|
-
extraBody?: Record<string, unknown> | undefined;
|
|
79
|
-
cacheControlFormat?: "anthropic" | undefined;
|
|
80
|
-
supportsStrictMode?: boolean | undefined;
|
|
81
|
-
toolStrictMode?: "all_strict" | "none" | undefined;
|
|
82
|
-
} | undefined;
|
|
83
|
-
authHeader?: boolean | undefined;
|
|
84
|
-
auth?: "apiKey" | "none" | "oauth" | undefined;
|
|
85
|
-
discovery?: {
|
|
86
|
-
type: "llama.cpp" | "lm-studio" | "ollama" | "openai-models-list" | "proxy";
|
|
87
|
-
} | undefined;
|
|
88
|
-
models?: {
|
|
89
|
-
id: string;
|
|
90
|
-
name?: string | undefined;
|
|
91
|
-
api?: "anthropic-messages" | "azure-openai-responses" | "google-generative-ai" | "google-vertex" | "openai-codex-responses" | "openai-completions" | "openai-responses" | undefined;
|
|
92
|
-
baseUrl?: string | undefined;
|
|
93
|
-
reasoning?: boolean | undefined;
|
|
94
|
-
thinking?: {
|
|
95
|
-
minLevel: "high" | "low" | "medium" | "minimal" | "xhigh";
|
|
96
|
-
maxLevel: "high" | "low" | "medium" | "minimal" | "xhigh";
|
|
97
|
-
mode: "anthropic-adaptive" | "anthropic-budget-effort" | "budget" | "effort" | "google-level";
|
|
98
|
-
defaultLevel?: "high" | "low" | "medium" | "minimal" | "xhigh" | undefined;
|
|
99
|
-
levels?: ("high" | "low" | "medium" | "minimal" | "xhigh")[] | undefined;
|
|
100
|
-
} | undefined;
|
|
101
|
-
input?: ("image" | "text")[] | undefined;
|
|
102
|
-
cost?: {
|
|
103
|
-
input: number;
|
|
104
|
-
output: number;
|
|
105
|
-
cacheRead: number;
|
|
106
|
-
cacheWrite: number;
|
|
107
|
-
} | undefined;
|
|
108
|
-
premiumMultiplier?: number | undefined;
|
|
109
|
-
contextWindow?: number | undefined;
|
|
110
|
-
maxTokens?: number | undefined;
|
|
111
|
-
omitMaxOutputTokens?: boolean | undefined;
|
|
112
|
-
headers?: Record<string, string> | undefined;
|
|
113
|
-
compat?: {
|
|
114
|
-
supportsStore?: boolean | undefined;
|
|
115
|
-
supportsDeveloperRole?: boolean | undefined;
|
|
116
|
-
supportsMultipleSystemMessages?: boolean | undefined;
|
|
117
|
-
supportsReasoningEffort?: boolean | undefined;
|
|
118
|
-
reasoningEffortMap?: {
|
|
119
|
-
minimal?: string | undefined;
|
|
120
|
-
low?: string | undefined;
|
|
121
|
-
medium?: string | undefined;
|
|
122
|
-
high?: string | undefined;
|
|
123
|
-
xhigh?: string | undefined;
|
|
124
|
-
} | undefined;
|
|
125
|
-
maxTokensField?: "max_completion_tokens" | "max_tokens" | undefined;
|
|
126
|
-
supportsUsageInStreaming?: boolean | undefined;
|
|
127
|
-
requiresToolResultName?: boolean | undefined;
|
|
128
|
-
requiresMistralToolIds?: boolean | undefined;
|
|
129
|
-
requiresAssistantAfterToolResult?: boolean | undefined;
|
|
130
|
-
requiresThinkingAsText?: boolean | undefined;
|
|
131
|
-
reasoningContentField?: "reasoning" | "reasoning_content" | "reasoning_text" | undefined;
|
|
132
|
-
requiresReasoningContentForToolCalls?: boolean | undefined;
|
|
133
|
-
allowsSyntheticReasoningContentForToolCalls?: boolean | undefined;
|
|
134
|
-
requiresAssistantContentForToolCalls?: boolean | undefined;
|
|
135
|
-
supportsToolChoice?: boolean | undefined;
|
|
136
|
-
disableReasoningOnForcedToolChoice?: boolean | undefined;
|
|
137
|
-
disableReasoningOnToolChoice?: boolean | undefined;
|
|
138
|
-
thinkingFormat?: "openai" | "openrouter" | "qwen" | "qwen-chat-template" | "zai" | undefined;
|
|
139
|
-
openRouterRouting?: {
|
|
140
|
-
only?: string[] | undefined;
|
|
141
|
-
order?: string[] | undefined;
|
|
142
|
-
} | undefined;
|
|
143
|
-
vercelGatewayRouting?: {
|
|
144
|
-
only?: string[] | undefined;
|
|
145
|
-
order?: string[] | undefined;
|
|
146
|
-
} | undefined;
|
|
147
|
-
extraBody?: Record<string, unknown> | undefined;
|
|
148
|
-
cacheControlFormat?: "anthropic" | undefined;
|
|
149
|
-
supportsStrictMode?: boolean | undefined;
|
|
150
|
-
toolStrictMode?: "all_strict" | "none" | undefined;
|
|
151
|
-
} | undefined;
|
|
152
|
-
contextPromotionTarget?: string | undefined;
|
|
153
|
-
}[] | undefined;
|
|
154
|
-
modelOverrides?: Record<string, {
|
|
155
|
-
name?: string | undefined;
|
|
156
|
-
reasoning?: boolean | undefined;
|
|
157
|
-
thinking?: {
|
|
158
|
-
minLevel: "high" | "low" | "medium" | "minimal" | "xhigh";
|
|
159
|
-
maxLevel: "high" | "low" | "medium" | "minimal" | "xhigh";
|
|
160
|
-
mode: "anthropic-adaptive" | "anthropic-budget-effort" | "budget" | "effort" | "google-level";
|
|
161
|
-
defaultLevel?: "high" | "low" | "medium" | "minimal" | "xhigh" | undefined;
|
|
162
|
-
levels?: ("high" | "low" | "medium" | "minimal" | "xhigh")[] | undefined;
|
|
163
|
-
} | undefined;
|
|
164
|
-
input?: ("image" | "text")[] | undefined;
|
|
165
|
-
cost?: {
|
|
166
|
-
input?: number | undefined;
|
|
167
|
-
output?: number | undefined;
|
|
168
|
-
cacheRead?: number | undefined;
|
|
169
|
-
cacheWrite?: number | undefined;
|
|
170
|
-
} | undefined;
|
|
171
|
-
premiumMultiplier?: number | undefined;
|
|
172
|
-
contextWindow?: number | undefined;
|
|
173
|
-
maxTokens?: number | undefined;
|
|
174
|
-
omitMaxOutputTokens?: boolean | undefined;
|
|
175
|
-
headers?: Record<string, string> | undefined;
|
|
176
|
-
compat?: {
|
|
177
|
-
supportsStore?: boolean | undefined;
|
|
178
|
-
supportsDeveloperRole?: boolean | undefined;
|
|
179
|
-
supportsMultipleSystemMessages?: boolean | undefined;
|
|
180
|
-
supportsReasoningEffort?: boolean | undefined;
|
|
181
|
-
reasoningEffortMap?: {
|
|
182
|
-
minimal?: string | undefined;
|
|
183
|
-
low?: string | undefined;
|
|
184
|
-
medium?: string | undefined;
|
|
185
|
-
high?: string | undefined;
|
|
186
|
-
xhigh?: string | undefined;
|
|
187
|
-
} | undefined;
|
|
188
|
-
maxTokensField?: "max_completion_tokens" | "max_tokens" | undefined;
|
|
189
|
-
supportsUsageInStreaming?: boolean | undefined;
|
|
190
|
-
requiresToolResultName?: boolean | undefined;
|
|
191
|
-
requiresMistralToolIds?: boolean | undefined;
|
|
192
|
-
requiresAssistantAfterToolResult?: boolean | undefined;
|
|
193
|
-
requiresThinkingAsText?: boolean | undefined;
|
|
194
|
-
reasoningContentField?: "reasoning" | "reasoning_content" | "reasoning_text" | undefined;
|
|
195
|
-
requiresReasoningContentForToolCalls?: boolean | undefined;
|
|
196
|
-
allowsSyntheticReasoningContentForToolCalls?: boolean | undefined;
|
|
197
|
-
requiresAssistantContentForToolCalls?: boolean | undefined;
|
|
198
|
-
supportsToolChoice?: boolean | undefined;
|
|
199
|
-
disableReasoningOnForcedToolChoice?: boolean | undefined;
|
|
200
|
-
disableReasoningOnToolChoice?: boolean | undefined;
|
|
201
|
-
thinkingFormat?: "openai" | "openrouter" | "qwen" | "qwen-chat-template" | "zai" | undefined;
|
|
202
|
-
openRouterRouting?: {
|
|
203
|
-
only?: string[] | undefined;
|
|
204
|
-
order?: string[] | undefined;
|
|
205
|
-
} | undefined;
|
|
206
|
-
vercelGatewayRouting?: {
|
|
207
|
-
only?: string[] | undefined;
|
|
208
|
-
order?: string[] | undefined;
|
|
209
|
-
} | undefined;
|
|
210
|
-
extraBody?: Record<string, unknown> | undefined;
|
|
211
|
-
cacheControlFormat?: "anthropic" | undefined;
|
|
212
|
-
supportsStrictMode?: boolean | undefined;
|
|
213
|
-
toolStrictMode?: "all_strict" | "none" | undefined;
|
|
214
|
-
} | undefined;
|
|
215
|
-
contextPromotionTarget?: string | undefined;
|
|
216
|
-
}> | undefined;
|
|
217
|
-
disableStrictTools?: boolean | undefined;
|
|
218
|
-
transport?: "pi-native" | undefined;
|
|
219
|
-
}> | undefined;
|
|
220
|
-
equivalence?: {
|
|
221
|
-
overrides?: Record<string, string> | undefined;
|
|
222
|
-
exclude?: string[] | undefined;
|
|
223
|
-
} | undefined;
|
|
224
|
-
}>;
|
|
225
13
|
/** Provider override config (baseUrl, headers, apiKey, compat, transport) without custom models */
|
|
226
14
|
interface ProviderOverride {
|
|
227
15
|
baseUrl?: string;
|
|
228
16
|
headers?: Record<string, string>;
|
|
229
17
|
apiKey?: string;
|
|
230
18
|
authHeader?: boolean;
|
|
231
|
-
compat?:
|
|
19
|
+
compat?: ModelSpec<Api>["compat"];
|
|
232
20
|
transport?: Model<Api>["transport"];
|
|
233
21
|
}
|
|
234
22
|
/**
|
|
@@ -262,6 +50,11 @@ export interface CanonicalModelQueryOptions {
|
|
|
262
50
|
availableOnly?: boolean;
|
|
263
51
|
candidates?: readonly Model<Api>[];
|
|
264
52
|
}
|
|
53
|
+
/** A canonical record (with query-filtered variants) plus the variant model selected for it. */
|
|
54
|
+
export interface CanonicalModelSelection {
|
|
55
|
+
record: CanonicalModelRecord;
|
|
56
|
+
model: Model<Api>;
|
|
57
|
+
}
|
|
265
58
|
/**
|
|
266
59
|
* Model registry - loads and manages models, resolves API keys via AuthStorage.
|
|
267
60
|
*/
|
|
@@ -306,6 +99,14 @@ export declare class ModelRegistry {
|
|
|
306
99
|
*/
|
|
307
100
|
getAll(): Model<Api>[];
|
|
308
101
|
getCanonicalModels(options?: CanonicalModelQueryOptions): CanonicalModelRecord[];
|
|
102
|
+
/**
|
|
103
|
+
* One-pass equivalent of `getCanonicalModels` + `resolveCanonicalModel` per
|
|
104
|
+
* record. The per-query state (candidate-selector set, availability memo,
|
|
105
|
+
* provider rank, candidate order) is built once, so the whole catalog
|
|
106
|
+
* resolves in O(records + candidates) instead of O(records × candidates).
|
|
107
|
+
* This is the path the model selector hydrates from synchronously on open.
|
|
108
|
+
*/
|
|
109
|
+
getCanonicalModelSelections(options?: CanonicalModelQueryOptions): CanonicalModelSelection[];
|
|
309
110
|
getCanonicalVariants(canonicalId: string, options?: CanonicalModelQueryOptions): CanonicalModelVariant[];
|
|
310
111
|
resolveCanonicalModel(canonicalId: string, options?: CanonicalModelQueryOptions): Model<Api> | undefined;
|
|
311
112
|
getCanonicalId(model: Model<Api>): string | undefined;
|
|
@@ -400,7 +201,7 @@ export interface ProviderConfigInput {
|
|
|
400
201
|
api?: Api;
|
|
401
202
|
streamSimple?: (model: Model<Api>, context: Context, options?: SimpleStreamOptions) => AssistantMessageEventStream;
|
|
402
203
|
headers?: Record<string, string>;
|
|
403
|
-
compat?:
|
|
204
|
+
compat?: ModelSpec<Api>["compat"];
|
|
404
205
|
authHeader?: boolean;
|
|
405
206
|
/** Streaming transport override — see {@link Model.transport}. */
|
|
406
207
|
transport?: Model<Api>["transport"];
|
|
@@ -435,7 +236,7 @@ export interface ProviderConfigInput {
|
|
|
435
236
|
contextWindow: number;
|
|
436
237
|
maxTokens: number;
|
|
437
238
|
headers?: Record<string, string>;
|
|
438
|
-
compat?:
|
|
239
|
+
compat?: ModelSpec<Api>["compat"];
|
|
439
240
|
contextPromotionTarget?: string;
|
|
440
241
|
premiumMultiplier?: number;
|
|
441
242
|
}>;
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Model resolution, scoping, and initial selection
|
|
2
|
+
* Model resolution, scoping, and initial selection.
|
|
3
|
+
*
|
|
4
|
+
* Layering:
|
|
5
|
+
* - `matchModel` is the single matching engine. Order: exact `provider/id`
|
|
6
|
+
* reference (with OpenRouter routed/date fallbacks) → exact canonical id →
|
|
7
|
+
* exact bare id → provider-scoped fuzzy → substring with alias-vs-dated pick.
|
|
8
|
+
* - `parseModelPatternWithContext`/`parseModelPattern` layer the selector
|
|
9
|
+
* grammar on top: trailing `:level` thinking suffixes (`splitThinkingSuffix`)
|
|
10
|
+
* and `@upstream` provider routing (`splitUpstreamRouting`).
|
|
11
|
+
* - Everything else (`resolveModelFromString`, `resolveModelOverride*`,
|
|
12
|
+
* `resolveRoleSelection`, `resolveModelScope`, `resolveCliModel`,
|
|
13
|
+
* `findSmolModel`/`findSlowModel`) adapts inputs — roles, settings patterns,
|
|
14
|
+
* CLI flags, scope globs — onto that pipeline.
|
|
3
15
|
*/
|
|
4
16
|
import { ThinkingLevel } from "@oh-my-pi/pi-agent-core";
|
|
5
|
-
import {
|
|
6
|
-
import { type ModelRegistry
|
|
17
|
+
import type { Api, Effort, Model } from "@oh-my-pi/pi-ai";
|
|
18
|
+
import { type ModelRegistry } from "./model-registry";
|
|
19
|
+
import { type ModelRole } from "./model-roles";
|
|
7
20
|
import type { Settings } from "./settings";
|
|
8
|
-
/** Default model IDs for each known provider */
|
|
9
|
-
export declare const defaultModelPerProvider: Record<KnownProvider, string>;
|
|
10
21
|
export interface ScopedModel {
|
|
11
22
|
model: Model<Api>;
|
|
12
23
|
thinkingLevel?: ThinkingLevel;
|
|
@@ -41,11 +52,6 @@ type CliModelRegistry = Pick<ModelRegistry, "getAll"> & Partial<CanonicalModelRe
|
|
|
41
52
|
type InitialModelRegistry = Pick<ModelRegistry, "getAvailable" | "find">;
|
|
42
53
|
type RestorableModelRegistry = Pick<ModelRegistry, "getAvailable" | "find" | "getApiKey">;
|
|
43
54
|
export declare function getModelMatchPreferences(settings?: Partial<Pick<Settings, "get" | "getStorage">>): ModelMatchPreferences;
|
|
44
|
-
/**
|
|
45
|
-
* Find an exact explicit provider/model match.
|
|
46
|
-
* Bare model ids are handled separately so canonical ids can coalesce variants.
|
|
47
|
-
*/
|
|
48
|
-
export declare function findExactModelReferenceMatch(modelReference: string, availableModels: Model<Api>[]): Model<Api> | undefined;
|
|
49
55
|
export interface ParsedModelResult {
|
|
50
56
|
model: Model<Api> | undefined;
|
|
51
57
|
/** Thinking level if explicitly specified in pattern, undefined otherwise */
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in model roles and role metadata helpers.
|
|
3
|
+
*/
|
|
4
|
+
import { type ThemeColor } from "../modes/theme/theme";
|
|
5
|
+
import type { Settings } from "./settings";
|
|
6
|
+
export type ModelRole = "default" | "smol" | "slow" | "vision" | "plan" | "designer" | "commit" | "task";
|
|
7
|
+
export interface ModelRoleInfo {
|
|
8
|
+
tag?: string;
|
|
9
|
+
name: string;
|
|
10
|
+
color?: ThemeColor;
|
|
11
|
+
}
|
|
12
|
+
export declare const MODEL_ROLES: Record<ModelRole, ModelRoleInfo>;
|
|
13
|
+
export declare const MODEL_ROLE_IDS: ModelRole[];
|
|
14
|
+
/** Alias for ModelRoleInfo - used for both built-in and custom roles */
|
|
15
|
+
export type RoleInfo = ModelRoleInfo;
|
|
16
|
+
/**
|
|
17
|
+
* Return the canonical set of known roles for selector/carousel UI.
|
|
18
|
+
*
|
|
19
|
+
* Built-ins always come first. Configured cycle order, model assignments, and
|
|
20
|
+
* tag metadata can introduce additional custom roles without requiring duplicate
|
|
21
|
+
* entries across settings.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getKnownRoleIds(settings: Settings): string[];
|
|
24
|
+
/**
|
|
25
|
+
* Get role info for a role name (built-in or custom).
|
|
26
|
+
* Configured metadata overrides built-in defaults when present.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getRoleInfo(role: string, settings: Settings): RoleInfo;
|