shortcutxl 0.2.0
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/README.md +59 -0
- package/agent-docs/README.md +397 -0
- package/agent-docs/docs/compaction.md +390 -0
- package/agent-docs/docs/custom-provider.md +580 -0
- package/agent-docs/docs/development.md +69 -0
- package/agent-docs/docs/extensions.md +1971 -0
- package/agent-docs/docs/json.md +79 -0
- package/agent-docs/docs/keybindings.md +174 -0
- package/agent-docs/docs/models.md +293 -0
- package/agent-docs/docs/packages.md +209 -0
- package/agent-docs/docs/prompt-templates.md +67 -0
- package/agent-docs/docs/providers.md +186 -0
- package/agent-docs/docs/rpc.md +1317 -0
- package/agent-docs/docs/sdk.md +962 -0
- package/agent-docs/docs/session.md +412 -0
- package/agent-docs/docs/settings.md +223 -0
- package/agent-docs/docs/shell-aliases.md +13 -0
- package/agent-docs/docs/skills.md +231 -0
- package/agent-docs/docs/terminal-setup.md +70 -0
- package/agent-docs/docs/termux.md +127 -0
- package/agent-docs/docs/themes.md +295 -0
- package/agent-docs/docs/tree.md +219 -0
- package/agent-docs/docs/tui.md +887 -0
- package/agent-docs/docs/windows.md +17 -0
- package/agent-docs/examples/README.md +25 -0
- package/agent-docs/examples/extensions/README.md +205 -0
- package/agent-docs/examples/extensions/antigravity-image-gen.ts +447 -0
- package/agent-docs/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/agent-docs/examples/extensions/bash-spawn-hook.ts +30 -0
- package/agent-docs/examples/extensions/bookmark.ts +50 -0
- package/agent-docs/examples/extensions/built-in-tool-renderer.ts +256 -0
- package/agent-docs/examples/extensions/claude-rules.ts +86 -0
- package/agent-docs/examples/extensions/commands.ts +75 -0
- package/agent-docs/examples/extensions/confirm-destructive.ts +59 -0
- package/agent-docs/examples/extensions/custom-compaction.ts +126 -0
- package/agent-docs/examples/extensions/custom-footer.ts +63 -0
- package/agent-docs/examples/extensions/custom-header.ts +73 -0
- package/agent-docs/examples/extensions/custom-provider-anthropic/index.ts +660 -0
- package/agent-docs/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/agent-docs/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/agent-docs/examples/extensions/custom-provider-gitlab-duo/index.ts +362 -0
- package/agent-docs/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/agent-docs/examples/extensions/custom-provider-gitlab-duo/test.ts +88 -0
- package/agent-docs/examples/extensions/custom-provider-qwen-cli/index.ts +349 -0
- package/agent-docs/examples/extensions/custom-provider-qwen-cli/package.json +16 -0
- package/agent-docs/examples/extensions/dirty-repo-guard.ts +56 -0
- package/agent-docs/examples/extensions/doom-overlay/README.md +46 -0
- package/agent-docs/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/agent-docs/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/agent-docs/examples/extensions/doom-overlay/doom-component.ts +133 -0
- package/agent-docs/examples/extensions/doom-overlay/doom-engine.ts +186 -0
- package/agent-docs/examples/extensions/doom-overlay/doom-keys.ts +108 -0
- package/agent-docs/examples/extensions/doom-overlay/index.ts +74 -0
- package/agent-docs/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/agent-docs/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/agent-docs/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/agent-docs/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/agent-docs/examples/extensions/dynamic-resources/index.ts +15 -0
- package/agent-docs/examples/extensions/dynamic-tools.ts +77 -0
- package/agent-docs/examples/extensions/event-bus.ts +43 -0
- package/agent-docs/examples/extensions/file-trigger.ts +41 -0
- package/agent-docs/examples/extensions/git-checkpoint.ts +53 -0
- package/agent-docs/examples/extensions/handoff.ts +155 -0
- package/agent-docs/examples/extensions/hello.ts +25 -0
- package/agent-docs/examples/extensions/inline-bash.ts +94 -0
- package/agent-docs/examples/extensions/input-transform.ts +43 -0
- package/agent-docs/examples/extensions/interactive-shell.ts +209 -0
- package/agent-docs/examples/extensions/mac-system-theme.ts +47 -0
- package/agent-docs/examples/extensions/message-renderer.ts +59 -0
- package/agent-docs/examples/extensions/minimal-mode.ts +430 -0
- package/agent-docs/examples/extensions/modal-editor.ts +90 -0
- package/agent-docs/examples/extensions/model-status.ts +31 -0
- package/agent-docs/examples/extensions/notify.ts +55 -0
- package/agent-docs/examples/extensions/overlay-qa-tests.ts +936 -0
- package/agent-docs/examples/extensions/overlay-test.ts +159 -0
- package/agent-docs/examples/extensions/permission-gate.ts +37 -0
- package/agent-docs/examples/extensions/pirate.ts +47 -0
- package/agent-docs/examples/extensions/plan-mode/README.md +65 -0
- package/agent-docs/examples/extensions/plan-mode/index.ts +363 -0
- package/agent-docs/examples/extensions/plan-mode/utils.ts +173 -0
- package/agent-docs/examples/extensions/preset.ts +418 -0
- package/agent-docs/examples/extensions/protected-paths.ts +30 -0
- package/agent-docs/examples/extensions/qna.ts +122 -0
- package/agent-docs/examples/extensions/question.ts +278 -0
- package/agent-docs/examples/extensions/questionnaire.ts +440 -0
- package/agent-docs/examples/extensions/rainbow-editor.ts +90 -0
- package/agent-docs/examples/extensions/reload-runtime.ts +37 -0
- package/agent-docs/examples/extensions/rpc-demo.ts +124 -0
- package/agent-docs/examples/extensions/sandbox/index.ts +324 -0
- package/agent-docs/examples/extensions/sandbox/package-lock.json +92 -0
- package/agent-docs/examples/extensions/sandbox/package.json +19 -0
- package/agent-docs/examples/extensions/send-user-message.ts +97 -0
- package/agent-docs/examples/extensions/session-name.ts +27 -0
- package/agent-docs/examples/extensions/shutdown-command.ts +69 -0
- package/agent-docs/examples/extensions/snake.ts +343 -0
- package/agent-docs/examples/extensions/space-invaders.ts +566 -0
- package/agent-docs/examples/extensions/ssh.ts +233 -0
- package/agent-docs/examples/extensions/status-line.ts +40 -0
- package/agent-docs/examples/extensions/subagent/README.md +172 -0
- package/agent-docs/examples/extensions/subagent/agents/planner.md +37 -0
- package/agent-docs/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/agent-docs/examples/extensions/subagent/agents/scout.md +50 -0
- package/agent-docs/examples/extensions/subagent/agents/worker.md +24 -0
- package/agent-docs/examples/extensions/subagent/agents.ts +130 -0
- package/agent-docs/examples/extensions/subagent/index.ts +1068 -0
- package/agent-docs/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/agent-docs/examples/extensions/subagent/prompts/implement.md +10 -0
- package/agent-docs/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/agent-docs/examples/extensions/summarize.ts +206 -0
- package/agent-docs/examples/extensions/system-prompt-header.ts +17 -0
- package/agent-docs/examples/extensions/timed-confirm.ts +72 -0
- package/agent-docs/examples/extensions/titlebar-spinner.ts +58 -0
- package/agent-docs/examples/extensions/todo.ts +314 -0
- package/agent-docs/examples/extensions/tool-override.ts +146 -0
- package/agent-docs/examples/extensions/tools.ts +145 -0
- package/agent-docs/examples/extensions/trigger-compact.ts +40 -0
- package/agent-docs/examples/extensions/truncated-tool.ts +194 -0
- package/agent-docs/examples/extensions/widget-placement.ts +17 -0
- package/agent-docs/examples/extensions/with-deps/index.ts +37 -0
- package/agent-docs/examples/extensions/with-deps/package-lock.json +31 -0
- package/agent-docs/examples/extensions/with-deps/package.json +22 -0
- package/agent-docs/examples/rpc-extension-ui.ts +654 -0
- package/agent-docs/examples/sdk/01-minimal.ts +22 -0
- package/agent-docs/examples/sdk/02-custom-model.ts +48 -0
- package/agent-docs/examples/sdk/03-custom-prompt.ts +55 -0
- package/agent-docs/examples/sdk/04-skills.ts +53 -0
- package/agent-docs/examples/sdk/05-tools.ts +56 -0
- package/agent-docs/examples/sdk/06-extensions.ts +88 -0
- package/agent-docs/examples/sdk/07-context-files.ts +40 -0
- package/agent-docs/examples/sdk/08-prompt-templates.ts +47 -0
- package/agent-docs/examples/sdk/09-api-keys-and-oauth.ts +48 -0
- package/agent-docs/examples/sdk/10-settings.ts +54 -0
- package/agent-docs/examples/sdk/11-sessions.ts +48 -0
- package/agent-docs/examples/sdk/12-full-control.ts +82 -0
- package/agent-docs/examples/sdk/README.md +144 -0
- package/agent-docs/xll-skill.md +61 -0
- package/agent-docs/xll-spec.md +110 -0
- package/dist/cli/args.js +290 -0
- package/dist/cli/config-selector.js +31 -0
- package/dist/cli/file-processor.js +79 -0
- package/dist/cli/list-models.js +92 -0
- package/dist/cli/package-commands.js +210 -0
- package/dist/cli/report-settings-errors.js +11 -0
- package/dist/cli/session-picker.js +34 -0
- package/dist/cli.js +19 -0
- package/dist/config.js +288 -0
- package/dist/core/abort.js +15 -0
- package/dist/core/agent-loop.js +352 -0
- package/dist/core/agent-session.js +2019 -0
- package/dist/core/agent.js +410 -0
- package/dist/core/auth-storage.js +456 -0
- package/dist/core/bash-executor.js +222 -0
- package/dist/core/compaction/branch-summarization.js +242 -0
- package/dist/core/compaction/compaction.js +610 -0
- package/dist/core/compaction/index.js +7 -0
- package/dist/core/compaction/utils.js +139 -0
- package/dist/core/defaults.js +6 -0
- package/dist/core/diagnostics.js +2 -0
- package/dist/core/event-bus.js +25 -0
- package/dist/core/exec.js +71 -0
- package/dist/core/export-html/ansi-to-html.js +256 -0
- package/dist/core/export-html/index.js +238 -0
- package/dist/core/export-html/session-view-model.js +342 -0
- package/dist/core/export-html/template.css +1110 -0
- package/dist/core/export-html/template.html +76 -0
- package/dist/core/export-html/template.js +1990 -0
- package/dist/core/export-html/tool-renderer.js +63 -0
- package/dist/core/export-html/vendor/highlight.min.js +7725 -0
- package/dist/core/export-html/vendor/marked.min.js +1803 -0
- package/dist/core/extensions/index.js +9 -0
- package/dist/core/extensions/loader.js +422 -0
- package/dist/core/extensions/runner.js +651 -0
- package/dist/core/extensions/types.js +35 -0
- package/dist/core/extensions/wrapper.js +102 -0
- package/dist/core/footer-data-provider.js +162 -0
- package/dist/core/index.js +9 -0
- package/dist/core/keybindings.js +153 -0
- package/dist/core/messages.js +133 -0
- package/dist/core/model-registry.js +539 -0
- package/dist/core/model-resolver.js +370 -0
- package/dist/core/package-manager.js +1485 -0
- package/dist/core/prompt-templates.js +253 -0
- package/dist/core/resolve-config-value.js +59 -0
- package/dist/core/resource-loader.js +700 -0
- package/dist/core/sdk.js +197 -0
- package/dist/core/session-bash.js +99 -0
- package/dist/core/session-compaction.js +165 -0
- package/dist/core/session-manager.js +1153 -0
- package/dist/core/session-models.js +99 -0
- package/dist/core/session-retry.js +155 -0
- package/dist/core/settings-manager.js +572 -0
- package/dist/core/skills.js +382 -0
- package/dist/core/slash-commands.js +31 -0
- package/dist/core/system-prompt.js +161 -0
- package/dist/core/theme.js +770 -0
- package/dist/core/timings.js +26 -0
- package/dist/core/tools/bash.js +258 -0
- package/dist/core/tools/edit-diff.js +245 -0
- package/dist/core/tools/edit.js +148 -0
- package/dist/core/tools/find.js +208 -0
- package/dist/core/tools/grep.js +246 -0
- package/dist/core/tools/index.js +67 -0
- package/dist/core/tools/ls.js +123 -0
- package/dist/core/tools/path-utils.js +81 -0
- package/dist/core/tools/read.js +160 -0
- package/dist/core/tools/truncate.js +70 -0
- package/dist/core/tools/write.js +82 -0
- package/dist/custom/agents/action.js +13 -0
- package/dist/custom/agents/document-reader.js +70 -0
- package/dist/custom/agents/general.js +26 -0
- package/dist/custom/agents/index.js +49 -0
- package/dist/custom/agents/installation.js +13 -0
- package/dist/custom/agents/types.js +7 -0
- package/dist/custom/auth/refresh-timer.js +33 -0
- package/dist/custom/auth/shortcut-oauth.js +145 -0
- package/dist/custom/constants.js +21 -0
- package/dist/custom/context/workbook-summary.js +73 -0
- package/dist/custom/credits/shortcut-credits.js +29 -0
- package/dist/custom/cron/cron-daemon-entry.js +18 -0
- package/dist/custom/cron/daemon-ipc.js +131 -0
- package/dist/custom/cron/daemon.js +224 -0
- package/dist/custom/cron/jobs.js +226 -0
- package/dist/custom/cron/run-log.js +51 -0
- package/dist/custom/cron/schedule.js +72 -0
- package/dist/custom/cron/status-line.js +98 -0
- package/dist/custom/cron/store.js +87 -0
- package/dist/custom/cron/types.js +8 -0
- package/dist/custom/dev/index.js +59 -0
- package/dist/custom/dev/trace-export.js +58 -0
- package/dist/custom/ensure-excel.js +63 -0
- package/dist/custom/excel-config.js +36 -0
- package/dist/custom/preflight.js +422 -0
- package/dist/custom/prompts/action.js +100 -0
- package/dist/custom/prompts/api.js +66 -0
- package/dist/custom/prompts/installation.js +124 -0
- package/dist/custom/prompts/shared.js +138 -0
- package/dist/custom/providers/llm-usage.js +42 -0
- package/dist/custom/providers/message-converter.js +74 -0
- package/dist/custom/providers/provider-ids.js +9 -0
- package/dist/custom/providers/register-openai-codex-provider.js +27 -0
- package/dist/custom/providers/register-shortcut-provider.js +52 -0
- package/dist/custom/providers/shortcut-invoke.js +117 -0
- package/dist/custom/providers/shortcut-stream.js +252 -0
- package/dist/custom/providers/sse-protocol.js +38 -0
- package/dist/custom/sync-xll.js +130 -0
- package/dist/custom/tools/cron.js +413 -0
- package/dist/custom/tools/excel-exec.js +167 -0
- package/dist/custom/tools/excel-range.js +50 -0
- package/dist/custom/tools/llm-analysis.js +265 -0
- package/dist/custom/tools/render-helpers.js +38 -0
- package/dist/custom/tools/switch-mode.js +94 -0
- package/dist/custom/tools/task/agents.js +6 -0
- package/dist/custom/tools/task/index.js +8 -0
- package/dist/custom/tools/task/render.js +348 -0
- package/dist/custom/tools/task/subprocess.js +320 -0
- package/dist/custom/tools/task/task.js +205 -0
- package/dist/custom/tools/todo-list.js +195 -0
- package/dist/custom/tracing/session-upload.js +93 -0
- package/dist/index.js +45 -0
- package/dist/main.js +613 -0
- package/dist/migrations.js +265 -0
- package/dist/modes/index.js +8 -0
- package/dist/modes/interactive/components/armin.js +337 -0
- package/dist/modes/interactive/components/assistant-message.js +94 -0
- package/dist/modes/interactive/components/bash-execution.js +171 -0
- package/dist/modes/interactive/components/bordered-loader.js +51 -0
- package/dist/modes/interactive/components/branch-summary-message.js +45 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +46 -0
- package/dist/modes/interactive/components/config-selector.js +488 -0
- package/dist/modes/interactive/components/countdown-timer.js +33 -0
- package/dist/modes/interactive/components/custom-editor.js +93 -0
- package/dist/modes/interactive/components/custom-message.js +81 -0
- package/dist/modes/interactive/components/daxnuts.js +140 -0
- package/dist/modes/interactive/components/diff.js +133 -0
- package/dist/modes/interactive/components/dynamic-border.js +21 -0
- package/dist/modes/interactive/components/extension-editor.js +105 -0
- package/dist/modes/interactive/components/extension-input.js +61 -0
- package/dist/modes/interactive/components/extension-selector.js +78 -0
- package/dist/modes/interactive/components/footer.js +309 -0
- package/dist/modes/interactive/components/index.js +33 -0
- package/dist/modes/interactive/components/keybinding-hints.js +61 -0
- package/dist/modes/interactive/components/layout.js +64 -0
- package/dist/modes/interactive/components/login-dialog.js +148 -0
- package/dist/modes/interactive/components/model-selector.js +237 -0
- package/dist/modes/interactive/components/oauth-selector.js +111 -0
- package/dist/modes/interactive/components/session-selector-search.js +157 -0
- package/dist/modes/interactive/components/session-selector.js +860 -0
- package/dist/modes/interactive/components/settings-selector.js +123 -0
- package/dist/modes/interactive/components/show-images-selector.js +35 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +48 -0
- package/dist/modes/interactive/components/theme-selector.js +47 -0
- package/dist/modes/interactive/components/thinking-selector.js +47 -0
- package/dist/modes/interactive/components/tool-execution.js +789 -0
- package/dist/modes/interactive/components/tool-group.js +106 -0
- package/dist/modes/interactive/components/tree-selector.js +962 -0
- package/dist/modes/interactive/components/user-message-selector.js +115 -0
- package/dist/modes/interactive/components/user-message.js +48 -0
- package/dist/modes/interactive/components/visual-truncate.js +33 -0
- package/dist/modes/interactive/file-attachments.js +135 -0
- package/dist/modes/interactive/interactive-mode.js +3775 -0
- package/dist/modes/interactive/theme/dark.json +85 -0
- package/dist/modes/interactive/theme/light.json +85 -0
- package/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/dist/modes/interactive/theme/theme.js +177 -0
- package/dist/modes/print-mode.js +101 -0
- package/dist/modes/rpc/rpc-client.js +387 -0
- package/dist/modes/rpc/rpc-mode.js +509 -0
- package/dist/modes/rpc/rpc-types.js +8 -0
- package/dist/subagent-entry.js +145 -0
- package/dist/tool-names.js +34 -0
- package/dist/tui/autocomplete.js +596 -0
- package/dist/tui/components/box.js +104 -0
- package/dist/tui/components/cancellable-loader.js +35 -0
- package/dist/tui/components/editor.js +1679 -0
- package/dist/tui/components/image.js +69 -0
- package/dist/tui/components/input.js +433 -0
- package/dist/tui/components/loader.js +49 -0
- package/dist/tui/components/markdown.js +629 -0
- package/dist/tui/components/select-list.js +152 -0
- package/dist/tui/components/settings-list.js +185 -0
- package/dist/tui/components/spacer.js +23 -0
- package/dist/tui/components/text.js +89 -0
- package/dist/tui/components/truncated-text.js +51 -0
- package/dist/tui/editor-component.js +2 -0
- package/dist/tui/fuzzy.js +107 -0
- package/dist/tui/get-east-asian-width/index.js +32 -0
- package/dist/tui/get-east-asian-width/lookup.js +404 -0
- package/dist/tui/index.js +32 -0
- package/dist/tui/keybindings.js +114 -0
- package/dist/tui/keys.js +959 -0
- package/dist/tui/kill-ring.js +44 -0
- package/dist/tui/stdin-buffer.js +317 -0
- package/dist/tui/terminal-image.js +288 -0
- package/dist/tui/terminal.js +249 -0
- package/dist/tui/tui/autocomplete.js +596 -0
- package/dist/tui/tui/components/box.js +106 -0
- package/dist/tui/tui/components/cancellable-loader.js +35 -0
- package/dist/tui/tui/components/editor.js +1679 -0
- package/dist/tui/tui/components/image.js +69 -0
- package/dist/tui/tui/components/input.js +433 -0
- package/dist/tui/tui/components/loader.js +49 -0
- package/dist/tui/tui/components/markdown.js +629 -0
- package/dist/tui/tui/components/select-list.js +152 -0
- package/dist/tui/tui/components/settings-list.js +185 -0
- package/dist/tui/tui/components/spacer.js +23 -0
- package/dist/tui/tui/components/text.js +91 -0
- package/dist/tui/tui/components/truncated-text.js +51 -0
- package/dist/tui/tui/editor-component.js +2 -0
- package/dist/tui/tui/fuzzy.js +107 -0
- package/dist/tui/tui/get-east-asian-width/index.js +32 -0
- package/dist/tui/tui/get-east-asian-width/lookup.js +404 -0
- package/dist/tui/tui/index.js +32 -0
- package/dist/tui/tui/keybindings.js +114 -0
- package/dist/tui/tui/keys.js +959 -0
- package/dist/tui/tui/kill-ring.js +44 -0
- package/dist/tui/tui/stdin-buffer.js +317 -0
- package/dist/tui/tui/terminal-image.js +288 -0
- package/dist/tui/tui/terminal.js +249 -0
- package/dist/tui/tui/tui.js +955 -0
- package/dist/tui/tui/undo-stack.js +25 -0
- package/dist/tui/tui/utils.js +800 -0
- package/dist/tui/tui.js +955 -0
- package/dist/tui/undo-stack.js +25 -0
- package/dist/tui/utils.js +800 -0
- package/dist/utils/changelog.js +87 -0
- package/dist/utils/clipboard-image.js +164 -0
- package/dist/utils/clipboard-native.js +14 -0
- package/dist/utils/clipboard.js +67 -0
- package/dist/utils/frontmatter.js +26 -0
- package/dist/utils/git.js +166 -0
- package/dist/utils/image-convert.js +35 -0
- package/dist/utils/image-resize.js +183 -0
- package/dist/utils/mime.js +26 -0
- package/dist/utils/photon.js +121 -0
- package/dist/utils/shell.js +217 -0
- package/dist/utils/sleep.js +17 -0
- package/dist/utils/tools-manager.js +259 -0
- package/package.json +78 -0
- package/skills/excel-com-api/SKILL.md +74 -0
- package/skills/excel-com-api/excel-type-library.py +27767 -0
- package/skills/excel-com-api/office-type-library.py +10867 -0
- package/skills/integrations/SKILL.md +138 -0
- package/skills/integrations/alphasense.md +457 -0
- package/skills/integrations/bloomberg.md +803 -0
- package/skills/integrations/calcbench.md +315 -0
- package/skills/integrations/capiq.md +848 -0
- package/skills/integrations/dynamics-365-finance.md +354 -0
- package/skills/integrations/earnings_transcripts.md +387 -0
- package/skills/integrations/factset.md +758 -0
- package/skills/integrations/ice-fixed-income.md +344 -0
- package/skills/integrations/moodys-analytics.md +313 -0
- package/skills/integrations/morningstar.md +433 -0
- package/skills/integrations/nasdaq-data-link.md +249 -0
- package/skills/integrations/pitchbook.md +413 -0
- package/skills/integrations/preqin.md +422 -0
- package/skills/integrations/quickbooks.md +289 -0
- package/skills/integrations/quickfs.md +314 -0
- package/skills/integrations/refinitiv.md +473 -0
- package/skills/integrations/sage-intacct.md +401 -0
- package/skills/integrations/visible-alpha.md +320 -0
- package/skills/integrations/xero.md +393 -0
- package/skills/integrations/ycharts.md +306 -0
- package/skills/pdf-creation/SKILL.md +93 -0
- package/skills/pdf-extraction/SKILL.md +32 -0
- package/skills/powerpoint-creation/SKILL.md +110 -0
- package/skills/sec-edgar/SKILL.md +127 -0
- package/skills/sec-edgar/sec_to_pdf.py +109 -0
- package/xll/ShortcutXL.xll +0 -0
- package/xll/modules/debug_render.py +272 -0
- package/xll/modules/gameboy.py +241 -0
- package/xll/modules/pong.py +188 -0
- package/xll/modules/shortcut_xl/__init__.py +18 -0
- package/xll/modules/shortcut_xl/_categorize.py +200 -0
- package/xll/modules/shortcut_xl/_com.py +108 -0
- package/xll/modules/shortcut_xl/_format.py +252 -0
- package/xll/modules/shortcut_xl/_log.py +12 -0
- package/xll/modules/shortcut_xl/_managed.py +116 -0
- package/xll/modules/shortcut_xl/_registry.py +44 -0
- package/xll/modules/shortcut_xl/_threading.py +161 -0
- package/xll/modules/shortcut_xl/_tracking.py +283 -0
- package/xll/modules/stocks.py +100 -0
- package/xll/python3.dll +0 -0
- package/xll/python312.dll +0 -0
package/dist/core/sdk.js
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { getAgentDir, getDocsPath } from '../config.js';
|
|
3
|
+
import { AgentSession, LoginRequiredError } from './agent-session.js';
|
|
4
|
+
import { Agent } from './agent.js';
|
|
5
|
+
import { AuthStorage } from './auth-storage.js';
|
|
6
|
+
import { DEFAULT_THINKING_LEVEL } from './defaults.js';
|
|
7
|
+
import { convertToLlm } from './messages.js';
|
|
8
|
+
import { ModelRegistry } from './model-registry.js';
|
|
9
|
+
import { findInitialModel } from './model-resolver.js';
|
|
10
|
+
import { DefaultResourceLoader } from './resource-loader.js';
|
|
11
|
+
import { SessionManager } from './session-manager.js';
|
|
12
|
+
import { SettingsManager } from './settings-manager.js';
|
|
13
|
+
import { time } from './timings.js';
|
|
14
|
+
import { allTools, bashTool, codingTools, createBashTool, createCodingTools, createEditTool, createFindTool, createGrepTool, createLsTool, createReadOnlyTools, createReadTool, createWriteTool, editTool, findTool, grepTool, lsTool, readOnlyTools, readTool, writeTool } from './tools/index.js';
|
|
15
|
+
export { allTools as allBuiltInTools, bashTool, codingTools, createBashTool,
|
|
16
|
+
// Tool factories (for custom cwd)
|
|
17
|
+
createCodingTools, createEditTool, createFindTool, createGrepTool, createLsTool, createReadOnlyTools, createReadTool, createWriteTool, editTool, findTool, grepTool, lsTool, readOnlyTools,
|
|
18
|
+
// Pre-built tools (use process.cwd())
|
|
19
|
+
readTool, writeTool };
|
|
20
|
+
// Helper Functions
|
|
21
|
+
function getDefaultAgentDir() {
|
|
22
|
+
return getAgentDir();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create an AgentSession with the specified options.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* // Minimal - uses defaults
|
|
30
|
+
* const { session } = await createAgentSession();
|
|
31
|
+
*
|
|
32
|
+
* // With explicit model
|
|
33
|
+
* import { getModel } from '@mariozechner/pi-ai';
|
|
34
|
+
* const { session } = await createAgentSession({
|
|
35
|
+
* model: getModel('anthropic', 'claude-opus-4-5'),
|
|
36
|
+
* thinkingLevel: 'high',
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* // Continue previous session
|
|
40
|
+
* const { session, modelFallbackMessage } = await createAgentSession({
|
|
41
|
+
* continueSession: true,
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* // Full control
|
|
45
|
+
* const loader = new DefaultResourceLoader({
|
|
46
|
+
* cwd: process.cwd(),
|
|
47
|
+
* agentDir: getAgentDir(),
|
|
48
|
+
* settingsManager: SettingsManager.create(),
|
|
49
|
+
* });
|
|
50
|
+
* await loader.reload();
|
|
51
|
+
* const { session } = await createAgentSession({
|
|
52
|
+
* model: myModel,
|
|
53
|
+
* tools: [readTool, bashTool],
|
|
54
|
+
* resourceLoader: loader,
|
|
55
|
+
* sessionManager: SessionManager.inMemory(),
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export async function createAgentSession(options = {}) {
|
|
60
|
+
const cwd = options.cwd ?? process.cwd();
|
|
61
|
+
const agentDir = options.agentDir ?? getDefaultAgentDir();
|
|
62
|
+
let resourceLoader = options.resourceLoader;
|
|
63
|
+
// Use provided or create AuthStorage and ModelRegistry
|
|
64
|
+
const authPath = options.agentDir ? join(agentDir, 'auth.json') : undefined;
|
|
65
|
+
const modelsPath = options.agentDir ? join(agentDir, 'models.json') : undefined;
|
|
66
|
+
const authStorage = options.authStorage ?? AuthStorage.create(authPath);
|
|
67
|
+
const modelRegistry = options.modelRegistry ?? new ModelRegistry(authStorage, modelsPath);
|
|
68
|
+
const settingsManager = options.settingsManager ?? SettingsManager.create(cwd, agentDir);
|
|
69
|
+
const sessionManager = options.sessionManager ?? SessionManager.create(cwd);
|
|
70
|
+
if (!resourceLoader) {
|
|
71
|
+
resourceLoader = new DefaultResourceLoader({ cwd, agentDir, settingsManager });
|
|
72
|
+
await resourceLoader.reload();
|
|
73
|
+
time('resourceLoader.reload');
|
|
74
|
+
}
|
|
75
|
+
// Check if session has existing data to restore
|
|
76
|
+
const existingSession = sessionManager.buildSessionContext();
|
|
77
|
+
const hasExistingSession = existingSession.messages.length > 0;
|
|
78
|
+
const hasThinkingEntry = sessionManager
|
|
79
|
+
.getBranch()
|
|
80
|
+
.some((entry) => entry.type === 'thinking_level_change');
|
|
81
|
+
let model = options.model;
|
|
82
|
+
let modelFallbackMessage;
|
|
83
|
+
// If session has data, try to restore model from it
|
|
84
|
+
if (!model && hasExistingSession && existingSession.model) {
|
|
85
|
+
const restoredModel = modelRegistry.find(existingSession.model.provider, existingSession.model.modelId);
|
|
86
|
+
if (restoredModel && (await modelRegistry.getApiKey(restoredModel))) {
|
|
87
|
+
model = restoredModel;
|
|
88
|
+
}
|
|
89
|
+
if (!model) {
|
|
90
|
+
modelFallbackMessage = `Could not restore model ${existingSession.model.provider}/${existingSession.model.modelId}`;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// If still no model, use findInitialModel (checks settings default, then provider defaults)
|
|
94
|
+
if (!model) {
|
|
95
|
+
const result = await findInitialModel({
|
|
96
|
+
isContinuing: hasExistingSession,
|
|
97
|
+
defaultProvider: settingsManager.getDefaultProvider(),
|
|
98
|
+
defaultModelId: settingsManager.getDefaultModel(),
|
|
99
|
+
defaultThinkingLevel: settingsManager.getDefaultThinkingLevel(),
|
|
100
|
+
modelRegistry
|
|
101
|
+
});
|
|
102
|
+
model = result.model;
|
|
103
|
+
if (!model) {
|
|
104
|
+
modelFallbackMessage = `No models available. Use /login or set an API key environment variable. See ${join(getDocsPath(), 'providers.md')}. Then use /model to select a model.`;
|
|
105
|
+
}
|
|
106
|
+
else if (modelFallbackMessage) {
|
|
107
|
+
modelFallbackMessage += `. Using ${model.provider}/${model.id}`;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
let thinkingLevel = options.thinkingLevel;
|
|
111
|
+
// If session has data, restore thinking level from it
|
|
112
|
+
if (thinkingLevel === undefined && hasExistingSession) {
|
|
113
|
+
thinkingLevel = hasThinkingEntry
|
|
114
|
+
? existingSession.thinkingLevel
|
|
115
|
+
: (settingsManager.getDefaultThinkingLevel() ?? DEFAULT_THINKING_LEVEL);
|
|
116
|
+
}
|
|
117
|
+
// Fall back to settings default
|
|
118
|
+
if (thinkingLevel === undefined) {
|
|
119
|
+
thinkingLevel = settingsManager.getDefaultThinkingLevel() ?? DEFAULT_THINKING_LEVEL;
|
|
120
|
+
}
|
|
121
|
+
// Clamp to model capabilities
|
|
122
|
+
if (!model || !model.reasoning) {
|
|
123
|
+
thinkingLevel = 'off';
|
|
124
|
+
}
|
|
125
|
+
// SHORTCUT PATCH: no default tools — every agent must explicitly declare its tools
|
|
126
|
+
const initialActiveToolNames = options.tools
|
|
127
|
+
? options.tools.map((t) => t.name).filter((n) => n in allTools)
|
|
128
|
+
: [];
|
|
129
|
+
const extensionRunnerRef = {};
|
|
130
|
+
const agent = new Agent({
|
|
131
|
+
initialState: {
|
|
132
|
+
systemPrompt: '',
|
|
133
|
+
model,
|
|
134
|
+
thinkingLevel,
|
|
135
|
+
tools: []
|
|
136
|
+
},
|
|
137
|
+
convertToLlm,
|
|
138
|
+
sessionId: sessionManager.getSessionId(),
|
|
139
|
+
transformContext: async (messages) => {
|
|
140
|
+
const runner = extensionRunnerRef.current;
|
|
141
|
+
if (!runner)
|
|
142
|
+
return messages;
|
|
143
|
+
return runner.emitContext(messages);
|
|
144
|
+
},
|
|
145
|
+
steeringMode: settingsManager.getSteeringMode(),
|
|
146
|
+
followUpMode: settingsManager.getFollowUpMode(),
|
|
147
|
+
transport: settingsManager.getTransport(),
|
|
148
|
+
thinkingBudgets: settingsManager.getThinkingBudgets(),
|
|
149
|
+
maxRetryDelayMs: settingsManager.getRetrySettings().maxDelayMs,
|
|
150
|
+
getApiKey: async (provider) => {
|
|
151
|
+
// Use the provider argument from the in-flight request;
|
|
152
|
+
// agent.state.model may already be switched mid-turn.
|
|
153
|
+
const resolvedProvider = provider || agent.state.model?.provider;
|
|
154
|
+
if (!resolvedProvider) {
|
|
155
|
+
throw new LoginRequiredError();
|
|
156
|
+
}
|
|
157
|
+
const key = await modelRegistry.getApiKeyForProvider(resolvedProvider);
|
|
158
|
+
if (!key) {
|
|
159
|
+
throw new LoginRequiredError();
|
|
160
|
+
}
|
|
161
|
+
return key;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
// Restore messages if session has existing data
|
|
165
|
+
if (hasExistingSession) {
|
|
166
|
+
agent.replaceMessages(existingSession.messages);
|
|
167
|
+
if (!hasThinkingEntry) {
|
|
168
|
+
sessionManager.appendThinkingLevelChange(thinkingLevel);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
// Save initial model and thinking level for new sessions so they can be restored on resume
|
|
173
|
+
if (model) {
|
|
174
|
+
sessionManager.appendModelChange(model.provider, model.id);
|
|
175
|
+
}
|
|
176
|
+
sessionManager.appendThinkingLevelChange(thinkingLevel);
|
|
177
|
+
}
|
|
178
|
+
const session = new AgentSession({
|
|
179
|
+
agent: agent, // SHORTCUT PATCH: vendored Agent class (structurally identical, TS private mismatch)
|
|
180
|
+
sessionManager,
|
|
181
|
+
settingsManager,
|
|
182
|
+
cwd,
|
|
183
|
+
resourceLoader,
|
|
184
|
+
customTools: options.customTools,
|
|
185
|
+
modelRegistry,
|
|
186
|
+
initialActiveToolNames,
|
|
187
|
+
extensionRunnerRef,
|
|
188
|
+
prePromptContext: options.prePromptContext
|
|
189
|
+
});
|
|
190
|
+
const extensionsResult = resourceLoader.getExtensions();
|
|
191
|
+
return {
|
|
192
|
+
session,
|
|
193
|
+
extensionsResult,
|
|
194
|
+
modelFallbackMessage
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=sdk.js.map
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bash execution state management.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from AgentSession. Manages:
|
|
5
|
+
* - Command execution with abort support
|
|
6
|
+
* - Shell command prefix resolution
|
|
7
|
+
* - Deferred message queueing during streaming
|
|
8
|
+
*
|
|
9
|
+
* The actual bash execution lives in bash-executor.ts.
|
|
10
|
+
* This module owns the state and queueing logic.
|
|
11
|
+
*/
|
|
12
|
+
import { executeBash as executeBashCommand, executeBashWithOperations } from './bash-executor.js';
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// Pure helpers
|
|
15
|
+
// ============================================================================
|
|
16
|
+
/** Prepend shell command prefix to a command if configured. */
|
|
17
|
+
export function resolveCommand(command, prefix) {
|
|
18
|
+
return prefix ? `${prefix}\n${command}` : command;
|
|
19
|
+
}
|
|
20
|
+
/** Build a BashExecutionMessage from command + result. */
|
|
21
|
+
export function buildBashMessage(command, result, options) {
|
|
22
|
+
return {
|
|
23
|
+
role: 'bashExecution',
|
|
24
|
+
command,
|
|
25
|
+
output: result.output,
|
|
26
|
+
exitCode: result.exitCode,
|
|
27
|
+
cancelled: result.cancelled,
|
|
28
|
+
truncated: result.truncated,
|
|
29
|
+
fullOutputPath: result.fullOutputPath,
|
|
30
|
+
timestamp: Date.now(),
|
|
31
|
+
excludeFromContext: options?.excludeFromContext
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
// ============================================================================
|
|
35
|
+
// State Machine
|
|
36
|
+
// ============================================================================
|
|
37
|
+
export class SessionBash {
|
|
38
|
+
_abortController = undefined;
|
|
39
|
+
_pendingMessages = [];
|
|
40
|
+
get isRunning() {
|
|
41
|
+
return this._abortController !== undefined;
|
|
42
|
+
}
|
|
43
|
+
get hasPendingMessages() {
|
|
44
|
+
return this._pendingMessages.length > 0;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Execute a bash command.
|
|
48
|
+
* Records result via actions (immediately or deferred if streaming).
|
|
49
|
+
*/
|
|
50
|
+
async execute(command, actions, onChunk, options) {
|
|
51
|
+
this._abortController = new AbortController();
|
|
52
|
+
const resolvedCommand = resolveCommand(command, actions.getShellCommandPrefix());
|
|
53
|
+
try {
|
|
54
|
+
const result = options?.operations
|
|
55
|
+
? await executeBashWithOperations(resolvedCommand, process.cwd(), options.operations, {
|
|
56
|
+
onChunk,
|
|
57
|
+
signal: this._abortController.signal
|
|
58
|
+
})
|
|
59
|
+
: await executeBashCommand(resolvedCommand, {
|
|
60
|
+
onChunk,
|
|
61
|
+
signal: this._abortController.signal
|
|
62
|
+
});
|
|
63
|
+
this.record(command, result, actions, options);
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
this._abortController = undefined;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Record a bash result. If streaming, defers until flush().
|
|
72
|
+
* Also used by extensions that handle bash execution themselves.
|
|
73
|
+
*/
|
|
74
|
+
record(command, result, actions, options) {
|
|
75
|
+
const message = buildBashMessage(command, result, options);
|
|
76
|
+
if (actions.isStreaming()) {
|
|
77
|
+
this._pendingMessages.push(message);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
actions.appendToAgent(message);
|
|
81
|
+
actions.persistToSession(message);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/** Flush deferred messages to agent state and session. */
|
|
85
|
+
flush(actions) {
|
|
86
|
+
if (this._pendingMessages.length === 0)
|
|
87
|
+
return;
|
|
88
|
+
for (const message of this._pendingMessages) {
|
|
89
|
+
actions.appendToAgent(message);
|
|
90
|
+
actions.persistToSession(message);
|
|
91
|
+
}
|
|
92
|
+
this._pendingMessages = [];
|
|
93
|
+
}
|
|
94
|
+
/** Cancel running bash command. */
|
|
95
|
+
abort() {
|
|
96
|
+
this._abortController?.abort();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=session-bash.js.map
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session compaction logic.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from AgentSession to be independently testable.
|
|
5
|
+
* Handles two compaction triggers:
|
|
6
|
+
* 1. Overflow: LLM returned context overflow → compact → auto-retry
|
|
7
|
+
* 2. Threshold: Context over threshold → compact → user continues manually
|
|
8
|
+
*
|
|
9
|
+
* The actual LLM summarization lives in compaction/index.ts.
|
|
10
|
+
* This module owns the decision logic and orchestration.
|
|
11
|
+
*/
|
|
12
|
+
import { isContextOverflow } from '@mariozechner/pi-ai';
|
|
13
|
+
import { calculateContextTokens, compact, prepareCompaction, shouldCompact } from './compaction/index.js';
|
|
14
|
+
import { getLatestCompactionEntry } from './session-manager.js';
|
|
15
|
+
/**
|
|
16
|
+
* Decide whether compaction is needed based on the last assistant message.
|
|
17
|
+
* Pure function — no side effects.
|
|
18
|
+
*/
|
|
19
|
+
export function checkCompactionNeeded(message, ctx, skipAbortedCheck) {
|
|
20
|
+
if (!ctx.settings.enabled)
|
|
21
|
+
return { action: 'none' };
|
|
22
|
+
if (skipAbortedCheck && message.stopReason === 'aborted')
|
|
23
|
+
return { action: 'none' };
|
|
24
|
+
const contextWindow = ctx.currentModel?.contextWindow ?? 0;
|
|
25
|
+
const sameModel = ctx.currentModel &&
|
|
26
|
+
message.provider === ctx.currentModel.provider &&
|
|
27
|
+
message.model === ctx.currentModel.id;
|
|
28
|
+
const compactionEntry = getLatestCompactionEntry(ctx.branchEntries);
|
|
29
|
+
const errorIsFromBeforeCompaction = compactionEntry !== null && message.timestamp < new Date(compactionEntry.timestamp).getTime();
|
|
30
|
+
if (sameModel && !errorIsFromBeforeCompaction && isContextOverflow(message, contextWindow)) {
|
|
31
|
+
return { action: 'overflow' };
|
|
32
|
+
}
|
|
33
|
+
if (message.stopReason === 'error')
|
|
34
|
+
return { action: 'none' };
|
|
35
|
+
const contextTokens = calculateContextTokens(message.usage);
|
|
36
|
+
if (shouldCompact(contextTokens, contextWindow, ctx.settings)) {
|
|
37
|
+
return { action: 'threshold' };
|
|
38
|
+
}
|
|
39
|
+
return { action: 'none' };
|
|
40
|
+
}
|
|
41
|
+
// ============================================================================
|
|
42
|
+
// Orchestration
|
|
43
|
+
// ============================================================================
|
|
44
|
+
export class SessionCompaction {
|
|
45
|
+
_manualAbortController = undefined;
|
|
46
|
+
_autoAbortController = undefined;
|
|
47
|
+
_listener = undefined;
|
|
48
|
+
get isCompacting() {
|
|
49
|
+
return this._manualAbortController !== undefined || this._autoAbortController !== undefined;
|
|
50
|
+
}
|
|
51
|
+
/** Set the single event listener (the session facade). */
|
|
52
|
+
onEvent(listener) {
|
|
53
|
+
this._listener = listener;
|
|
54
|
+
}
|
|
55
|
+
_emit(event) {
|
|
56
|
+
this._listener?.(event);
|
|
57
|
+
}
|
|
58
|
+
abortAll() {
|
|
59
|
+
this._manualAbortController?.abort();
|
|
60
|
+
this._autoAbortController?.abort();
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Run manual compaction. Caller is responsible for disconnecting/reconnecting the agent.
|
|
64
|
+
*/
|
|
65
|
+
async runManual(model, apiKey, branchEntries, settings, customInstructions, actions) {
|
|
66
|
+
if (this.isCompacting)
|
|
67
|
+
throw new Error('Compaction already in progress');
|
|
68
|
+
this._manualAbortController = new AbortController();
|
|
69
|
+
try {
|
|
70
|
+
const preparation = prepareCompaction(branchEntries, settings);
|
|
71
|
+
if (!preparation) {
|
|
72
|
+
const lastEntry = branchEntries[branchEntries.length - 1];
|
|
73
|
+
throw new Error(lastEntry?.type === 'compaction'
|
|
74
|
+
? 'Already compacted'
|
|
75
|
+
: 'Nothing to compact (session too small)');
|
|
76
|
+
}
|
|
77
|
+
const result = await this._executeCompaction(preparation, branchEntries, model, apiKey, customInstructions, this._manualAbortController.signal, actions);
|
|
78
|
+
if (this._manualAbortController.signal.aborted) {
|
|
79
|
+
throw new Error('Compaction cancelled');
|
|
80
|
+
}
|
|
81
|
+
await actions.persistCompaction(result.compactionResult, result.fromExtension);
|
|
82
|
+
return result.compactionResult;
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
this._manualAbortController = undefined;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Run auto-compaction (triggered by overflow or threshold).
|
|
90
|
+
*/
|
|
91
|
+
async runAuto(reason, willRetry, model, apiKey, branchEntries, settings, actions) {
|
|
92
|
+
this._emit({ type: 'auto_compaction_start', reason });
|
|
93
|
+
this._autoAbortController = new AbortController();
|
|
94
|
+
try {
|
|
95
|
+
if (!model || !apiKey) {
|
|
96
|
+
this._emit({
|
|
97
|
+
type: 'auto_compaction_end',
|
|
98
|
+
result: undefined,
|
|
99
|
+
aborted: false,
|
|
100
|
+
willRetry: false
|
|
101
|
+
});
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const preparation = prepareCompaction(branchEntries, settings);
|
|
105
|
+
if (!preparation) {
|
|
106
|
+
this._emit({
|
|
107
|
+
type: 'auto_compaction_end',
|
|
108
|
+
result: undefined,
|
|
109
|
+
aborted: false,
|
|
110
|
+
willRetry: false
|
|
111
|
+
});
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const result = await this._executeCompaction(preparation, branchEntries, model, apiKey, undefined, this._autoAbortController.signal, actions);
|
|
115
|
+
if (this._autoAbortController.signal.aborted) {
|
|
116
|
+
this._emit({
|
|
117
|
+
type: 'auto_compaction_end',
|
|
118
|
+
result: undefined,
|
|
119
|
+
aborted: true,
|
|
120
|
+
willRetry: false
|
|
121
|
+
});
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
await actions.persistCompaction(result.compactionResult, result.fromExtension);
|
|
125
|
+
this._emit({
|
|
126
|
+
type: 'auto_compaction_end',
|
|
127
|
+
result: result.compactionResult,
|
|
128
|
+
aborted: false,
|
|
129
|
+
willRetry
|
|
130
|
+
});
|
|
131
|
+
if (willRetry) {
|
|
132
|
+
actions.removeLastAssistantMessage();
|
|
133
|
+
actions.continueAgent();
|
|
134
|
+
}
|
|
135
|
+
else if (actions.hasQueuedMessages()) {
|
|
136
|
+
actions.continueAgent();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
const errorMessage = error instanceof Error ? error.message : 'compaction failed';
|
|
141
|
+
this._emit({
|
|
142
|
+
type: 'auto_compaction_end',
|
|
143
|
+
result: undefined,
|
|
144
|
+
aborted: false,
|
|
145
|
+
willRetry: false,
|
|
146
|
+
errorMessage: reason === 'overflow'
|
|
147
|
+
? `Context overflow recovery failed: ${errorMessage}`
|
|
148
|
+
: `Auto-compaction failed: ${errorMessage}`
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
finally {
|
|
152
|
+
this._autoAbortController = undefined;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
async _executeCompaction(preparation, branchEntries, model, apiKey, customInstructions, signal, actions) {
|
|
156
|
+
const ext = await actions.tryExtensionCompaction(preparation, branchEntries, customInstructions, signal);
|
|
157
|
+
if (ext.cancelled)
|
|
158
|
+
throw new Error('Compaction cancelled');
|
|
159
|
+
if (ext.result)
|
|
160
|
+
return { compactionResult: ext.result, fromExtension: true };
|
|
161
|
+
const compactionResult = await compact(preparation, model, apiKey, customInstructions, signal);
|
|
162
|
+
return { compactionResult, fromExtension: false };
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=session-compaction.js.map
|