@apholdings/jensen-code 0.0.1 → 0.0.3
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 +21 -20
- package/README.md +6 -5
- package/dist/cli/args.d.ts +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/file-processor.d.ts +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +1 -1
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-session.d.ts +2 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +1 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +2 -2
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +2 -2
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +2 -2
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +1 -1
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +2 -2
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +1 -1
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/utils.d.ts +2 -2
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/defaults.d.ts +1 -1
- package/dist/core/defaults.d.ts.map +1 -1
- package/dist/core/defaults.js.map +1 -1
- package/dist/core/export-html/index.d.ts +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +15 -15
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +3 -3
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +5 -5
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/wrapper.d.ts +1 -1
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/keybindings.d.ts +1 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +1 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/messages.d.ts +3 -3
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-registry.d.ts +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +2 -2
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +2 -2
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/sdk.d.ts +3 -3
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +2 -2
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +2 -2
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/tools/bash.d.ts +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +1 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/read.d.ts +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/write.d.ts +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/armin.d.ts +1 -1
- package/dist/modes/interactive/components/armin.d.ts.map +1 -1
- package/dist/modes/interactive/components/armin.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +2 -2
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +1 -1
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +1 -1
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +1 -1
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +1 -1
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.d.ts +1 -1
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +1 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +1 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/daxnuts.d.ts +1 -1
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
- package/dist/modes/interactive/components/daxnuts.js.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.d.ts +1 -1
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +1 -1
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +1 -1
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +1 -1
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/header.d.ts +1 -1
- package/dist/modes/interactive/components/header.d.ts.map +1 -1
- package/dist/modes/interactive/components/header.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +2 -2
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +2 -2
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +2 -2
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +2 -2
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +2 -2
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.js +1 -1
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +1 -1
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +3 -3
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +1 -1
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.d.ts +1 -1
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.js +1 -1
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/theme-selector.d.ts +1 -1
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/theme-selector.js +1 -1
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts +2 -2
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +1 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +1 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/top-bar.d.ts +1 -1
- package/dist/modes/interactive/components/top-bar.d.ts.map +1 -1
- package/dist/modes/interactive/components/top-bar.js +1 -1
- package/dist/modes/interactive/components/top-bar.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +1 -1
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +1 -1
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +1 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +1 -1
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.js +1 -1
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1 -1
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +2 -2
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +1 -1
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/print-mode.d.ts +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +2 -2
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +2 -2
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/utils/image-resize.d.ts +1 -1
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js.map +1 -1
- package/docs/compaction.md +3 -2
- package/docs/custom-provider.md +4 -3
- package/docs/extensions.md +25 -24
- package/docs/packages.md +2 -1
- package/docs/rpc.md +2 -1
- package/docs/sdk.md +25 -24
- package/docs/session.md +2 -1
- package/docs/termux.md +2 -1
- package/docs/tui.md +21 -20
- package/examples/extensions/README.md +3 -2
- package/examples/extensions/antigravity-image-gen.ts +3 -2
- package/examples/extensions/auto-commit-on-exit.ts +2 -1
- package/examples/extensions/bash-spawn-hook.ts +3 -2
- package/examples/extensions/bookmark.ts +2 -1
- package/examples/extensions/built-in-tool-renderer.ts +4 -3
- package/examples/extensions/claude-rules.ts +2 -1
- package/examples/extensions/commands.ts +2 -1
- package/examples/extensions/confirm-destructive.ts +2 -1
- package/examples/extensions/custom-compaction.ts +4 -3
- package/examples/extensions/custom-footer.ts +4 -3
- package/examples/extensions/custom-header.ts +3 -2
- package/examples/extensions/custom-provider-anthropic/index.ts +3 -2
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +3 -2
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +1 -1
- package/examples/extensions/custom-provider-qwen-cli/index.ts +3 -2
- package/examples/extensions/dirty-repo-guard.ts +2 -1
- package/examples/extensions/doom-overlay/doom-component.ts +2 -2
- package/examples/extensions/doom-overlay/doom-keys.ts +1 -1
- package/examples/extensions/doom-overlay/index.ts +2 -1
- package/examples/extensions/dynamic-resources/index.ts +2 -1
- package/examples/extensions/dynamic-tools.ts +2 -1
- package/examples/extensions/event-bus.ts +2 -1
- package/examples/extensions/file-trigger.ts +2 -1
- package/examples/extensions/git-checkpoint.ts +2 -1
- package/examples/extensions/handoff.ts +4 -3
- package/examples/extensions/hello.ts +3 -2
- package/examples/extensions/inline-bash.ts +2 -1
- package/examples/extensions/input-transform.ts +2 -1
- package/examples/extensions/interactive-shell.ts +2 -1
- package/examples/extensions/mac-system-theme.ts +2 -1
- package/examples/extensions/message-renderer.ts +3 -2
- package/examples/extensions/minimal-mode.ts +4 -3
- package/examples/extensions/modal-editor.ts +3 -2
- package/examples/extensions/model-status.ts +2 -1
- package/examples/extensions/notify.ts +2 -1
- package/examples/extensions/overlay-qa-tests.ts +4 -3
- package/examples/extensions/overlay-test.ts +3 -2
- package/examples/extensions/permission-gate.ts +2 -1
- package/examples/extensions/pirate.ts +2 -1
- package/examples/extensions/plan-mode/index.ts +5 -4
- package/examples/extensions/preset.ts +4 -3
- package/examples/extensions/protected-paths.ts +2 -1
- package/examples/extensions/provider-payload.ts +2 -1
- package/examples/extensions/qna.ts +4 -3
- package/examples/extensions/question.ts +3 -2
- package/examples/extensions/questionnaire.ts +3 -2
- package/examples/extensions/rainbow-editor.ts +2 -1
- package/examples/extensions/reload-runtime.ts +2 -1
- package/examples/extensions/rpc-demo.ts +2 -1
- package/examples/extensions/sandbox/index.ts +3 -2
- package/examples/extensions/send-user-message.ts +2 -1
- package/examples/extensions/session-name.ts +2 -1
- package/examples/extensions/shutdown-command.ts +2 -1
- package/examples/extensions/snake.ts +3 -2
- package/examples/extensions/space-invaders.ts +3 -2
- package/examples/extensions/ssh.ts +3 -2
- package/examples/extensions/status-line.ts +2 -1
- package/examples/extensions/subagent/agents.ts +2 -1
- package/examples/extensions/subagent/index.ts +6 -5
- package/examples/extensions/summarize.ts +5 -4
- package/examples/extensions/system-prompt-header.ts +2 -1
- package/examples/extensions/timed-confirm.ts +2 -1
- package/examples/extensions/titlebar-spinner.ts +2 -1
- package/examples/extensions/todo.ts +4 -3
- package/examples/extensions/tool-override.ts +3 -2
- package/examples/extensions/tools.ts +4 -3
- package/examples/extensions/trigger-compact.ts +2 -1
- package/examples/extensions/truncated-tool.ts +4 -3
- package/examples/extensions/widget-placement.ts +2 -1
- package/examples/extensions/with-deps/index.ts +2 -1
- package/examples/rpc-extension-ui.ts +1 -1
- package/examples/sdk/01-minimal.ts +2 -1
- package/examples/sdk/02-custom-model.ts +3 -2
- package/examples/sdk/03-custom-prompt.ts +2 -1
- package/examples/sdk/04-skills.ts +2 -1
- package/examples/sdk/05-tools.ts +2 -1
- package/examples/sdk/06-extensions.ts +3 -2
- package/examples/sdk/07-context-files.ts +2 -1
- package/examples/sdk/08-prompt-templates.ts +2 -1
- package/examples/sdk/09-api-keys-and-oauth.ts +2 -1
- package/examples/sdk/10-settings.ts +2 -1
- package/examples/sdk/11-sessions.ts +2 -1
- package/examples/sdk/12-full-control.ts +3 -2
- package/examples/sdk/README.md +3 -2
- package/package.json +11 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-resize.js","sourceRoot":"","sources":["../../src/utils/image-resize.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAmBzC,wDAAwD;AACxD,MAAM,iBAAiB,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C,MAAM,eAAe,GAAiC;IACrD,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,IAAI;IACf,QAAQ,EAAE,iBAAiB;IAC3B,WAAW,EAAE,EAAE;CACf,CAAC;AAEF,gDAAgD;AAChD,SAAS,WAAW,CACnB,CAA2C,EAC3C,CAA2C,EACA;IAC3C,OAAO,CAAC,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAAA,CAClD;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAiB,EAAE,OAA4B,EAAyB;IACzG,MAAM,IAAI,GAAG,EAAE,GAAG,eAAe,EAAE,GAAG,OAAO,EAAE,CAAC;IAChD,MAAM,WAAW,GAAG,MAAM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,EAAE,CAAC;QACd,CAAC;IACF,CAAC;AAAA,CACD;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAoB,EAAsB;IAC7E,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC;IAClD,OAAO,oBAAoB,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,cAAc,kBAAkB,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,MAAM,6BAA6B,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,6BAA6B,CAAC;AAAA,CAClM","sourcesContent":["import type { ImageContent } from \"@mariozechner/pi-ai\";\nimport { loadPhoton } from \"./photon.js\";\n\nexport interface ImageResizeOptions {\n\tmaxWidth?: number; // Default: 2000\n\tmaxHeight?: number; // Default: 2000\n\tmaxBytes?: number; // Default: 4.5MB (below Anthropic's 5MB limit)\n\tjpegQuality?: number; // Default: 80\n}\n\nexport interface ResizedImage {\n\tdata: string; // base64\n\tmimeType: string;\n\toriginalWidth: number;\n\toriginalHeight: number;\n\twidth: number;\n\theight: number;\n\twasResized: boolean;\n}\n\n// 4.5MB - provides headroom below Anthropic's 5MB limit\nconst DEFAULT_MAX_BYTES = 4.5 * 1024 * 1024;\n\nconst DEFAULT_OPTIONS: Required<ImageResizeOptions> = {\n\tmaxWidth: 2000,\n\tmaxHeight: 2000,\n\tmaxBytes: DEFAULT_MAX_BYTES,\n\tjpegQuality: 80,\n};\n\n/** Helper to pick the smaller of two buffers */\nfunction pickSmaller(\n\ta: { buffer: Uint8Array; mimeType: string },\n\tb: { buffer: Uint8Array; mimeType: string },\n): { buffer: Uint8Array; mimeType: string } {\n\treturn a.buffer.length <= b.buffer.length ? a : b;\n}\n\n/**\n * Resize an image to fit within the specified max dimensions and file size.\n * Returns the original image if it already fits within the limits.\n *\n * Uses Photon (Rust/WASM) for image processing. If Photon is not available,\n * returns the original image unchanged.\n *\n * Strategy for staying under maxBytes:\n * 1. First resize to maxWidth/maxHeight\n * 2. Try both PNG and JPEG formats, pick the smaller one\n * 3. If still too large, try JPEG with decreasing quality\n * 4. If still too large, progressively reduce dimensions\n */\nexport async function resizeImage(img: ImageContent, options?: ImageResizeOptions): Promise<ResizedImage> {\n\tconst opts = { ...DEFAULT_OPTIONS, ...options };\n\tconst inputBuffer = Buffer.from(img.data, \"base64\");\n\n\tconst photon = await loadPhoton();\n\tif (!photon) {\n\t\t// Photon not available, return original image\n\t\treturn {\n\t\t\tdata: img.data,\n\t\t\tmimeType: img.mimeType,\n\t\t\toriginalWidth: 0,\n\t\t\toriginalHeight: 0,\n\t\t\twidth: 0,\n\t\t\theight: 0,\n\t\t\twasResized: false,\n\t\t};\n\t}\n\n\tlet image: ReturnType<typeof photon.PhotonImage.new_from_byteslice> | undefined;\n\ttry {\n\t\timage = photon.PhotonImage.new_from_byteslice(new Uint8Array(inputBuffer));\n\n\t\tconst originalWidth = image.get_width();\n\t\tconst originalHeight = image.get_height();\n\t\tconst format = img.mimeType?.split(\"/\")[1] ?? \"png\";\n\n\t\t// Check if already within all limits (dimensions AND size)\n\t\tconst originalSize = inputBuffer.length;\n\t\tif (originalWidth <= opts.maxWidth && originalHeight <= opts.maxHeight && originalSize <= opts.maxBytes) {\n\t\t\treturn {\n\t\t\t\tdata: img.data,\n\t\t\t\tmimeType: img.mimeType ?? `image/${format}`,\n\t\t\t\toriginalWidth,\n\t\t\t\toriginalHeight,\n\t\t\t\twidth: originalWidth,\n\t\t\t\theight: originalHeight,\n\t\t\t\twasResized: false,\n\t\t\t};\n\t\t}\n\n\t\t// Calculate initial dimensions respecting max limits\n\t\tlet targetWidth = originalWidth;\n\t\tlet targetHeight = originalHeight;\n\n\t\tif (targetWidth > opts.maxWidth) {\n\t\t\ttargetHeight = Math.round((targetHeight * opts.maxWidth) / targetWidth);\n\t\t\ttargetWidth = opts.maxWidth;\n\t\t}\n\t\tif (targetHeight > opts.maxHeight) {\n\t\t\ttargetWidth = Math.round((targetWidth * opts.maxHeight) / targetHeight);\n\t\t\ttargetHeight = opts.maxHeight;\n\t\t}\n\n\t\t// Helper to resize and encode in both formats, returning the smaller one\n\t\tfunction tryBothFormats(\n\t\t\twidth: number,\n\t\t\theight: number,\n\t\t\tjpegQuality: number,\n\t\t): { buffer: Uint8Array; mimeType: string } {\n\t\t\tconst resized = photon!.resize(image!, width, height, photon!.SamplingFilter.Lanczos3);\n\n\t\t\ttry {\n\t\t\t\tconst pngBuffer = resized.get_bytes();\n\t\t\t\tconst jpegBuffer = resized.get_bytes_jpeg(jpegQuality);\n\n\t\t\t\treturn pickSmaller(\n\t\t\t\t\t{ buffer: pngBuffer, mimeType: \"image/png\" },\n\t\t\t\t\t{ buffer: jpegBuffer, mimeType: \"image/jpeg\" },\n\t\t\t\t);\n\t\t\t} finally {\n\t\t\t\tresized.free();\n\t\t\t}\n\t\t}\n\n\t\t// Try to produce an image under maxBytes\n\t\tconst qualitySteps = [85, 70, 55, 40];\n\t\tconst scaleSteps = [1.0, 0.75, 0.5, 0.35, 0.25];\n\n\t\tlet best: { buffer: Uint8Array; mimeType: string };\n\t\tlet finalWidth = targetWidth;\n\t\tlet finalHeight = targetHeight;\n\n\t\t// First attempt: resize to target dimensions, try both formats\n\t\tbest = tryBothFormats(targetWidth, targetHeight, opts.jpegQuality);\n\n\t\tif (best.buffer.length <= opts.maxBytes) {\n\t\t\treturn {\n\t\t\t\tdata: Buffer.from(best.buffer).toString(\"base64\"),\n\t\t\t\tmimeType: best.mimeType,\n\t\t\t\toriginalWidth,\n\t\t\t\toriginalHeight,\n\t\t\t\twidth: finalWidth,\n\t\t\t\theight: finalHeight,\n\t\t\t\twasResized: true,\n\t\t\t};\n\t\t}\n\n\t\t// Still too large - try JPEG with decreasing quality\n\t\tfor (const quality of qualitySteps) {\n\t\t\tbest = tryBothFormats(targetWidth, targetHeight, quality);\n\n\t\t\tif (best.buffer.length <= opts.maxBytes) {\n\t\t\t\treturn {\n\t\t\t\t\tdata: Buffer.from(best.buffer).toString(\"base64\"),\n\t\t\t\t\tmimeType: best.mimeType,\n\t\t\t\t\toriginalWidth,\n\t\t\t\t\toriginalHeight,\n\t\t\t\t\twidth: finalWidth,\n\t\t\t\t\theight: finalHeight,\n\t\t\t\t\twasResized: true,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t// Still too large - reduce dimensions progressively\n\t\tfor (const scale of scaleSteps) {\n\t\t\tfinalWidth = Math.round(targetWidth * scale);\n\t\t\tfinalHeight = Math.round(targetHeight * scale);\n\n\t\t\tif (finalWidth < 100 || finalHeight < 100) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tfor (const quality of qualitySteps) {\n\t\t\t\tbest = tryBothFormats(finalWidth, finalHeight, quality);\n\n\t\t\t\tif (best.buffer.length <= opts.maxBytes) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdata: Buffer.from(best.buffer).toString(\"base64\"),\n\t\t\t\t\t\tmimeType: best.mimeType,\n\t\t\t\t\t\toriginalWidth,\n\t\t\t\t\t\toriginalHeight,\n\t\t\t\t\t\twidth: finalWidth,\n\t\t\t\t\t\theight: finalHeight,\n\t\t\t\t\t\twasResized: true,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Last resort: return smallest version we produced\n\t\treturn {\n\t\t\tdata: Buffer.from(best.buffer).toString(\"base64\"),\n\t\t\tmimeType: best.mimeType,\n\t\t\toriginalWidth,\n\t\t\toriginalHeight,\n\t\t\twidth: finalWidth,\n\t\t\theight: finalHeight,\n\t\t\twasResized: true,\n\t\t};\n\t} catch {\n\t\t// Failed to load image\n\t\treturn {\n\t\t\tdata: img.data,\n\t\t\tmimeType: img.mimeType,\n\t\t\toriginalWidth: 0,\n\t\t\toriginalHeight: 0,\n\t\t\twidth: 0,\n\t\t\theight: 0,\n\t\t\twasResized: false,\n\t\t};\n\t} finally {\n\t\tif (image) {\n\t\t\timage.free();\n\t\t}\n\t}\n}\n\n/**\n * Format a dimension note for resized images.\n * This helps the model understand the coordinate mapping.\n */\nexport function formatDimensionNote(result: ResizedImage): string | undefined {\n\tif (!result.wasResized) {\n\t\treturn undefined;\n\t}\n\n\tconst scale = result.originalWidth / result.width;\n\treturn `[Image: original ${result.originalWidth}x${result.originalHeight}, displayed at ${result.width}x${result.height}. Multiply coordinates by ${scale.toFixed(2)} to map to original image.]`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"image-resize.js","sourceRoot":"","sources":["../../src/utils/image-resize.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAmBzC,wDAAwD;AACxD,MAAM,iBAAiB,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C,MAAM,eAAe,GAAiC;IACrD,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,IAAI;IACf,QAAQ,EAAE,iBAAiB;IAC3B,WAAW,EAAE,EAAE;CACf,CAAC;AAEF,gDAAgD;AAChD,SAAS,WAAW,CACnB,CAA2C,EAC3C,CAA2C,EACA;IAC3C,OAAO,CAAC,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAAA,CAClD;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAiB,EAAE,OAA4B,EAAyB;IACzG,MAAM,IAAI,GAAG,EAAE,GAAG,eAAe,EAAE,GAAG,OAAO,EAAE,CAAC;IAChD,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAEpD,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;IAClC,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,8CAA8C;QAC9C,OAAO;YACN,IA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B,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC;IAClD,OAAO,oBAAoB,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,cAAc,kBAAkB,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,MAAM,6BAA6B,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,6BAA6B,CAAC;AAAA,CAClM","sourcesContent":["import type { ImageContent } from \"@apholdings/jensen-ai\";\nimport { loadPhoton } from \"./photon.js\";\n\nexport interface ImageResizeOptions {\n\tmaxWidth?: number; // Default: 2000\n\tmaxHeight?: number; // Default: 2000\n\tmaxBytes?: number; // Default: 4.5MB (below Anthropic's 5MB limit)\n\tjpegQuality?: number; // Default: 80\n}\n\nexport interface ResizedImage {\n\tdata: string; // base64\n\tmimeType: string;\n\toriginalWidth: number;\n\toriginalHeight: number;\n\twidth: number;\n\theight: number;\n\twasResized: boolean;\n}\n\n// 4.5MB - provides headroom below Anthropic's 5MB limit\nconst DEFAULT_MAX_BYTES = 4.5 * 1024 * 1024;\n\nconst DEFAULT_OPTIONS: Required<ImageResizeOptions> = {\n\tmaxWidth: 2000,\n\tmaxHeight: 2000,\n\tmaxBytes: DEFAULT_MAX_BYTES,\n\tjpegQuality: 80,\n};\n\n/** Helper to pick the smaller of two buffers */\nfunction pickSmaller(\n\ta: { buffer: Uint8Array; mimeType: string },\n\tb: { buffer: Uint8Array; mimeType: string },\n): { buffer: Uint8Array; mimeType: string } {\n\treturn a.buffer.length <= b.buffer.length ? a : b;\n}\n\n/**\n * Resize an image to fit within the specified max dimensions and file size.\n * Returns the original image if it already fits within the limits.\n *\n * Uses Photon (Rust/WASM) for image processing. If Photon is not available,\n * returns the original image unchanged.\n *\n * Strategy for staying under maxBytes:\n * 1. First resize to maxWidth/maxHeight\n * 2. Try both PNG and JPEG formats, pick the smaller one\n * 3. If still too large, try JPEG with decreasing quality\n * 4. If still too large, progressively reduce dimensions\n */\nexport async function resizeImage(img: ImageContent, options?: ImageResizeOptions): Promise<ResizedImage> {\n\tconst opts = { ...DEFAULT_OPTIONS, ...options };\n\tconst inputBuffer = Buffer.from(img.data, \"base64\");\n\n\tconst photon = await loadPhoton();\n\tif (!photon) {\n\t\t// Photon not available, return original image\n\t\treturn {\n\t\t\tdata: img.data,\n\t\t\tmimeType: img.mimeType,\n\t\t\toriginalWidth: 0,\n\t\t\toriginalHeight: 0,\n\t\t\twidth: 0,\n\t\t\theight: 0,\n\t\t\twasResized: false,\n\t\t};\n\t}\n\n\tlet image: ReturnType<typeof photon.PhotonImage.new_from_byteslice> | undefined;\n\ttry {\n\t\timage = photon.PhotonImage.new_from_byteslice(new Uint8Array(inputBuffer));\n\n\t\tconst originalWidth = image.get_width();\n\t\tconst originalHeight = image.get_height();\n\t\tconst format = img.mimeType?.split(\"/\")[1] ?? \"png\";\n\n\t\t// Check if already within all limits (dimensions AND size)\n\t\tconst originalSize = inputBuffer.length;\n\t\tif (originalWidth <= opts.maxWidth && originalHeight <= opts.maxHeight && originalSize <= opts.maxBytes) {\n\t\t\treturn {\n\t\t\t\tdata: img.data,\n\t\t\t\tmimeType: img.mimeType ?? `image/${format}`,\n\t\t\t\toriginalWidth,\n\t\t\t\toriginalHeight,\n\t\t\t\twidth: originalWidth,\n\t\t\t\theight: originalHeight,\n\t\t\t\twasResized: false,\n\t\t\t};\n\t\t}\n\n\t\t// Calculate initial dimensions respecting max limits\n\t\tlet targetWidth = originalWidth;\n\t\tlet targetHeight = originalHeight;\n\n\t\tif (targetWidth > opts.maxWidth) {\n\t\t\ttargetHeight = Math.round((targetHeight * opts.maxWidth) / targetWidth);\n\t\t\ttargetWidth = opts.maxWidth;\n\t\t}\n\t\tif (targetHeight > opts.maxHeight) {\n\t\t\ttargetWidth = Math.round((targetWidth * opts.maxHeight) / targetHeight);\n\t\t\ttargetHeight = opts.maxHeight;\n\t\t}\n\n\t\t// Helper to resize and encode in both formats, returning the smaller one\n\t\tfunction tryBothFormats(\n\t\t\twidth: number,\n\t\t\theight: number,\n\t\t\tjpegQuality: number,\n\t\t): { buffer: Uint8Array; mimeType: string } {\n\t\t\tconst resized = photon!.resize(image!, width, height, photon!.SamplingFilter.Lanczos3);\n\n\t\t\ttry {\n\t\t\t\tconst pngBuffer = resized.get_bytes();\n\t\t\t\tconst jpegBuffer = resized.get_bytes_jpeg(jpegQuality);\n\n\t\t\t\treturn pickSmaller(\n\t\t\t\t\t{ buffer: pngBuffer, mimeType: \"image/png\" },\n\t\t\t\t\t{ buffer: jpegBuffer, mimeType: \"image/jpeg\" },\n\t\t\t\t);\n\t\t\t} finally {\n\t\t\t\tresized.free();\n\t\t\t}\n\t\t}\n\n\t\t// Try to produce an image under maxBytes\n\t\tconst qualitySteps = [85, 70, 55, 40];\n\t\tconst scaleSteps = [1.0, 0.75, 0.5, 0.35, 0.25];\n\n\t\tlet best: { buffer: Uint8Array; mimeType: string };\n\t\tlet finalWidth = targetWidth;\n\t\tlet finalHeight = targetHeight;\n\n\t\t// First attempt: resize to target dimensions, try both formats\n\t\tbest = tryBothFormats(targetWidth, targetHeight, opts.jpegQuality);\n\n\t\tif (best.buffer.length <= opts.maxBytes) {\n\t\t\treturn {\n\t\t\t\tdata: Buffer.from(best.buffer).toString(\"base64\"),\n\t\t\t\tmimeType: best.mimeType,\n\t\t\t\toriginalWidth,\n\t\t\t\toriginalHeight,\n\t\t\t\twidth: finalWidth,\n\t\t\t\theight: finalHeight,\n\t\t\t\twasResized: true,\n\t\t\t};\n\t\t}\n\n\t\t// Still too large - try JPEG with decreasing quality\n\t\tfor (const quality of qualitySteps) {\n\t\t\tbest = tryBothFormats(targetWidth, targetHeight, quality);\n\n\t\t\tif (best.buffer.length <= opts.maxBytes) {\n\t\t\t\treturn {\n\t\t\t\t\tdata: Buffer.from(best.buffer).toString(\"base64\"),\n\t\t\t\t\tmimeType: best.mimeType,\n\t\t\t\t\toriginalWidth,\n\t\t\t\t\toriginalHeight,\n\t\t\t\t\twidth: finalWidth,\n\t\t\t\t\theight: finalHeight,\n\t\t\t\t\twasResized: true,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t// Still too large - reduce dimensions progressively\n\t\tfor (const scale of scaleSteps) {\n\t\t\tfinalWidth = Math.round(targetWidth * scale);\n\t\t\tfinalHeight = Math.round(targetHeight * scale);\n\n\t\t\tif (finalWidth < 100 || finalHeight < 100) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tfor (const quality of qualitySteps) {\n\t\t\t\tbest = tryBothFormats(finalWidth, finalHeight, quality);\n\n\t\t\t\tif (best.buffer.length <= opts.maxBytes) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdata: Buffer.from(best.buffer).toString(\"base64\"),\n\t\t\t\t\t\tmimeType: best.mimeType,\n\t\t\t\t\t\toriginalWidth,\n\t\t\t\t\t\toriginalHeight,\n\t\t\t\t\t\twidth: finalWidth,\n\t\t\t\t\t\theight: finalHeight,\n\t\t\t\t\t\twasResized: true,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Last resort: return smallest version we produced\n\t\treturn {\n\t\t\tdata: Buffer.from(best.buffer).toString(\"base64\"),\n\t\t\tmimeType: best.mimeType,\n\t\t\toriginalWidth,\n\t\t\toriginalHeight,\n\t\t\twidth: finalWidth,\n\t\t\theight: finalHeight,\n\t\t\twasResized: true,\n\t\t};\n\t} catch {\n\t\t// Failed to load image\n\t\treturn {\n\t\t\tdata: img.data,\n\t\t\tmimeType: img.mimeType,\n\t\t\toriginalWidth: 0,\n\t\t\toriginalHeight: 0,\n\t\t\twidth: 0,\n\t\t\theight: 0,\n\t\t\twasResized: false,\n\t\t};\n\t} finally {\n\t\tif (image) {\n\t\t\timage.free();\n\t\t}\n\t}\n}\n\n/**\n * Format a dimension note for resized images.\n * This helps the model understand the coordinate mapping.\n */\nexport function formatDimensionNote(result: ResizedImage): string | undefined {\n\tif (!result.wasResized) {\n\t\treturn undefined;\n\t}\n\n\tconst scale = result.originalWidth / result.width;\n\treturn `[Image: original ${result.originalWidth}x${result.originalHeight}, displayed at ${result.width}x${result.height}. Multiply coordinates by ${scale.toFixed(2)} to map to original image.]`;\n}\n"]}
|
package/docs/compaction.md
CHANGED
|
@@ -9,7 +9,7 @@ LLMs have limited context windows. When conversations grow too long, pi uses com
|
|
|
9
9
|
- [`packages/coding-agent/src/core/session-manager.ts`](https://github.com/badlogic/pi-mono/blob/main/packages/coding-agent/src/core/session-manager.ts) - Entry types (`CompactionEntry`, `BranchSummaryEntry`)
|
|
10
10
|
- [`packages/coding-agent/src/core/extensions/types.ts`](https://github.com/badlogic/pi-mono/blob/main/packages/coding-agent/src/core/extensions/types.ts) - Extension event types
|
|
11
11
|
|
|
12
|
-
For TypeScript definitions in your project, inspect `node_modules/@
|
|
12
|
+
For TypeScript definitions in your project, inspect `node_modules/@apholdings/jensen-code/dist/`.
|
|
13
13
|
|
|
14
14
|
## Overview
|
|
15
15
|
|
|
@@ -307,7 +307,7 @@ pi.on("session_before_compact", async (event, ctx) => {
|
|
|
307
307
|
To generate a summary with your own model, convert messages to text using `serializeConversation`:
|
|
308
308
|
|
|
309
309
|
```typescript
|
|
310
|
-
import { convertToLlm, serializeConversation } from "@
|
|
310
|
+
import { convertToLlm, serializeConversation } from "@apholdings/jensen-code";
|
|
311
311
|
|
|
312
312
|
pi.on("session_before_compact", async (event, ctx) => {
|
|
313
313
|
const { preparation } = event;
|
|
@@ -390,3 +390,4 @@ Configure compaction in `~/.pi/agent/settings.json` or `<project-dir>/.pi/settin
|
|
|
390
390
|
| `keepRecentTokens` | `20000` | Recent tokens to keep (not summarized) |
|
|
391
391
|
|
|
392
392
|
Disable auto-compaction with `"enabled": false`. You can still compact manually with `/compact`.
|
|
393
|
+
|
package/docs/custom-provider.md
CHANGED
|
@@ -31,7 +31,7 @@ See these complete provider examples:
|
|
|
31
31
|
## Quick Reference
|
|
32
32
|
|
|
33
33
|
```typescript
|
|
34
|
-
import type { ExtensionAPI } from "@
|
|
34
|
+
import type { ExtensionAPI } from "@apholdings/jensen-code";
|
|
35
35
|
|
|
36
36
|
export default function (pi: ExtensionAPI) {
|
|
37
37
|
// Override baseUrl for existing provider
|
|
@@ -211,7 +211,7 @@ pi.registerProvider("custom-api", {
|
|
|
211
211
|
Add OAuth/SSO authentication that integrates with `/login`:
|
|
212
212
|
|
|
213
213
|
```typescript
|
|
214
|
-
import type { OAuthCredentials, OAuthLoginCallbacks } from "@
|
|
214
|
+
import type { OAuthCredentials, OAuthLoginCallbacks } from "@apholdings/jensen-ai";
|
|
215
215
|
|
|
216
216
|
pi.registerProvider("corporate-ai", {
|
|
217
217
|
baseUrl: "https://ai.corp.com/v1",
|
|
@@ -324,7 +324,7 @@ import {
|
|
|
324
324
|
type SimpleStreamOptions,
|
|
325
325
|
calculateCost,
|
|
326
326
|
createAssistantMessageEventStream,
|
|
327
|
-
} from "@
|
|
327
|
+
} from "@apholdings/jensen-ai";
|
|
328
328
|
|
|
329
329
|
function streamMyProvider(
|
|
330
330
|
model: Model<any>,
|
|
@@ -590,3 +590,4 @@ interface ProviderModelConfig {
|
|
|
590
590
|
};
|
|
591
591
|
}
|
|
592
592
|
```
|
|
593
|
+
|
package/docs/extensions.md
CHANGED
|
@@ -55,7 +55,7 @@ See [examples/extensions/](../examples/extensions/) for working implementations.
|
|
|
55
55
|
Create `~/.pi/agent/extensions/my-extension.ts`:
|
|
56
56
|
|
|
57
57
|
```typescript
|
|
58
|
-
import type { ExtensionAPI } from "@
|
|
58
|
+
import type { ExtensionAPI } from "@apholdings/jensen-code";
|
|
59
59
|
import { Type } from "@sinclair/typebox";
|
|
60
60
|
|
|
61
61
|
export default function (pi: ExtensionAPI) {
|
|
@@ -137,10 +137,10 @@ To share extensions via npm or git as pi packages, see [packages.md](packages.md
|
|
|
137
137
|
|
|
138
138
|
| Package | Purpose |
|
|
139
139
|
|---------|---------|
|
|
140
|
-
| `@
|
|
140
|
+
| `@apholdings/jensen-code` | Extension types (`ExtensionAPI`, `ExtensionContext`, events) |
|
|
141
141
|
| `@sinclair/typebox` | Schema definitions for tool parameters |
|
|
142
|
-
| `@
|
|
143
|
-
| `@
|
|
142
|
+
| `@apholdings/jensen-ai` | AI utilities (`StringEnum` for Google-compatible enums) |
|
|
143
|
+
| `@apholdings/jensen-tui` | TUI components for custom rendering |
|
|
144
144
|
|
|
145
145
|
npm dependencies work too. Add a `package.json` next to your extension (or in a parent directory), run `npm install`, and imports from `node_modules/` are resolved automatically.
|
|
146
146
|
|
|
@@ -151,7 +151,7 @@ Node.js built-ins (`node:fs`, `node:path`, etc.) are also available.
|
|
|
151
151
|
An extension exports a default function that receives `ExtensionAPI`:
|
|
152
152
|
|
|
153
153
|
```typescript
|
|
154
|
-
import type { ExtensionAPI } from "@
|
|
154
|
+
import type { ExtensionAPI } from "@apholdings/jensen-code";
|
|
155
155
|
|
|
156
156
|
export default function (pi: ExtensionAPI) {
|
|
157
157
|
// Subscribe to events
|
|
@@ -556,7 +556,7 @@ Use this to update UI elements (status bars, footers) or perform model-specific
|
|
|
556
556
|
Fired before tool executes. **Can block.** Use `isToolCallEventType` to narrow and get typed inputs.
|
|
557
557
|
|
|
558
558
|
```typescript
|
|
559
|
-
import { isToolCallEventType } from "@
|
|
559
|
+
import { isToolCallEventType } from "@apholdings/jensen-code";
|
|
560
560
|
|
|
561
561
|
pi.on("tool_call", async (event, ctx) => {
|
|
562
562
|
// event.toolName - "bash", "read", "write", "edit", etc.
|
|
@@ -590,7 +590,7 @@ export type MyToolInput = Static<typeof myToolSchema>;
|
|
|
590
590
|
Use `isToolCallEventType` with explicit type parameters:
|
|
591
591
|
|
|
592
592
|
```typescript
|
|
593
|
-
import { isToolCallEventType } from "@
|
|
593
|
+
import { isToolCallEventType } from "@apholdings/jensen-code";
|
|
594
594
|
import type { MyToolInput } from "my-extension";
|
|
595
595
|
|
|
596
596
|
pi.on("tool_call", (event) => {
|
|
@@ -610,7 +610,7 @@ Fired after tool executes. **Can modify result.**
|
|
|
610
610
|
- Handlers can return partial patches (`content`, `details`, or `isError`); omitted fields keep their current values
|
|
611
611
|
|
|
612
612
|
```typescript
|
|
613
|
-
import { isBashToolResult } from "@
|
|
613
|
+
import { isBashToolResult } from "@apholdings/jensen-code";
|
|
614
614
|
|
|
615
615
|
pi.on("tool_result", async (event, ctx) => {
|
|
616
616
|
// event.toolName, event.toolCallId, event.input
|
|
@@ -882,7 +882,7 @@ Tools run with `ExtensionContext`, so they cannot call `ctx.reload()` directly.
|
|
|
882
882
|
Example tool the LLM can call to trigger reload:
|
|
883
883
|
|
|
884
884
|
```typescript
|
|
885
|
-
import type { ExtensionAPI } from "@
|
|
885
|
+
import type { ExtensionAPI } from "@apholdings/jensen-code";
|
|
886
886
|
import { Type } from "@sinclair/typebox";
|
|
887
887
|
|
|
888
888
|
export default function (pi: ExtensionAPI) {
|
|
@@ -929,7 +929,7 @@ See [dynamic-tools.ts](../examples/extensions/dynamic-tools.ts) for a full examp
|
|
|
929
929
|
|
|
930
930
|
```typescript
|
|
931
931
|
import { Type } from "@sinclair/typebox";
|
|
932
|
-
import { StringEnum } from "@
|
|
932
|
+
import { StringEnum } from "@apholdings/jensen-ai";
|
|
933
933
|
|
|
934
934
|
pi.registerTool({
|
|
935
935
|
name: "my_tool",
|
|
@@ -1079,7 +1079,7 @@ pi.registerCommand("stats", {
|
|
|
1079
1079
|
Optional: add argument auto-completion for `/command ...`:
|
|
1080
1080
|
|
|
1081
1081
|
```typescript
|
|
1082
|
-
import type { AutocompleteItem } from "@
|
|
1082
|
+
import type { AutocompleteItem } from "@apholdings/jensen-tui";
|
|
1083
1083
|
|
|
1084
1084
|
pi.registerCommand("deploy", {
|
|
1085
1085
|
description: "Deploy to an environment",
|
|
@@ -1335,8 +1335,8 @@ Note: Some models are idiots and include the @ prefix in tool path arguments. Bu
|
|
|
1335
1335
|
|
|
1336
1336
|
```typescript
|
|
1337
1337
|
import { Type } from "@sinclair/typebox";
|
|
1338
|
-
import { StringEnum } from "@
|
|
1339
|
-
import { Text } from "@
|
|
1338
|
+
import { StringEnum } from "@apholdings/jensen-ai";
|
|
1339
|
+
import { Text } from "@apholdings/jensen-tui";
|
|
1340
1340
|
|
|
1341
1341
|
pi.registerTool({
|
|
1342
1342
|
name: "my_tool",
|
|
@@ -1391,7 +1391,7 @@ async execute(toolCallId, params) {
|
|
|
1391
1391
|
}
|
|
1392
1392
|
```
|
|
1393
1393
|
|
|
1394
|
-
**Important:** Use `StringEnum` from `@
|
|
1394
|
+
**Important:** Use `StringEnum` from `@apholdings/jensen-ai` for string enums. `Type.Union`/`Type.Literal` doesn't work with Google's API.
|
|
1395
1395
|
|
|
1396
1396
|
### Overriding Built-in Tools
|
|
1397
1397
|
|
|
@@ -1428,7 +1428,7 @@ Built-in tool implementations:
|
|
|
1428
1428
|
Built-in tools support pluggable operations for delegating to remote systems (SSH, containers, etc.):
|
|
1429
1429
|
|
|
1430
1430
|
```typescript
|
|
1431
|
-
import { createReadTool, createBashTool, type ReadOperations } from "@
|
|
1431
|
+
import { createReadTool, createBashTool, type ReadOperations } from "@apholdings/jensen-code";
|
|
1432
1432
|
|
|
1433
1433
|
// Create tool with custom operations
|
|
1434
1434
|
const remoteRead = createReadTool(cwd, {
|
|
@@ -1457,7 +1457,7 @@ pi.registerTool({
|
|
|
1457
1457
|
The bash tool also supports a spawn hook to adjust the command, cwd, or env before execution:
|
|
1458
1458
|
|
|
1459
1459
|
```typescript
|
|
1460
|
-
import { createBashTool } from "@
|
|
1460
|
+
import { createBashTool } from "@apholdings/jensen-code";
|
|
1461
1461
|
|
|
1462
1462
|
const bashTool = createBashTool(cwd, {
|
|
1463
1463
|
spawnHook: ({ command, cwd, env }) => ({
|
|
@@ -1487,7 +1487,7 @@ import {
|
|
|
1487
1487
|
formatSize, // Human-readable size (e.g., "50KB", "1.5MB")
|
|
1488
1488
|
DEFAULT_MAX_BYTES, // 50KB
|
|
1489
1489
|
DEFAULT_MAX_LINES, // 2000
|
|
1490
|
-
} from "@
|
|
1490
|
+
} from "@apholdings/jensen-code";
|
|
1491
1491
|
|
|
1492
1492
|
async execute(toolCallId, params, signal, onUpdate, ctx) {
|
|
1493
1493
|
const output = await runCommand();
|
|
@@ -1551,7 +1551,7 @@ Tool output is wrapped in a `Box` that handles padding and background. Your rend
|
|
|
1551
1551
|
Renders the tool call (before/during execution):
|
|
1552
1552
|
|
|
1553
1553
|
```typescript
|
|
1554
|
-
import { Text } from "@
|
|
1554
|
+
import { Text } from "@apholdings/jensen-tui";
|
|
1555
1555
|
|
|
1556
1556
|
renderCall(args, theme) {
|
|
1557
1557
|
let text = theme.fg("toolTitle", theme.bold("my_tool "));
|
|
@@ -1595,7 +1595,7 @@ renderResult(result, { expanded, isPartial }, theme) {
|
|
|
1595
1595
|
Use `keyHint()` to display keybinding hints that respect user's keybinding configuration:
|
|
1596
1596
|
|
|
1597
1597
|
```typescript
|
|
1598
|
-
import { keyHint } from "@
|
|
1598
|
+
import { keyHint } from "@apholdings/jensen-code";
|
|
1599
1599
|
|
|
1600
1600
|
renderResult(result, { expanded }, theme) {
|
|
1601
1601
|
let text = theme.fg("success", "✓ Done");
|
|
@@ -1769,7 +1769,7 @@ ctx.ui.theme.fg("accent", "styled text"); // Access current theme
|
|
|
1769
1769
|
For complex UI, use `ctx.ui.custom()`. This temporarily replaces the editor with your component until `done()` is called:
|
|
1770
1770
|
|
|
1771
1771
|
```typescript
|
|
1772
|
-
import { Text, Component } from "@
|
|
1772
|
+
import { Text, Component } from "@apholdings/jensen-tui";
|
|
1773
1773
|
|
|
1774
1774
|
const result = await ctx.ui.custom<boolean>((tui, theme, keybindings, done) => {
|
|
1775
1775
|
const text = new Text("Press Enter to confirm, Escape to cancel", 1, 1);
|
|
@@ -1827,8 +1827,8 @@ See [tui.md](tui.md) for the full `OverlayOptions` API and [overlay-qa-tests.ts]
|
|
|
1827
1827
|
Replace the main input editor with a custom implementation (vim mode, emacs mode, etc.):
|
|
1828
1828
|
|
|
1829
1829
|
```typescript
|
|
1830
|
-
import { CustomEditor, type ExtensionAPI } from "@
|
|
1831
|
-
import { matchesKey } from "@
|
|
1830
|
+
import { CustomEditor, type ExtensionAPI } from "@apholdings/jensen-code";
|
|
1831
|
+
import { matchesKey } from "@apholdings/jensen-tui";
|
|
1832
1832
|
|
|
1833
1833
|
class VimEditor extends CustomEditor {
|
|
1834
1834
|
private mode: "normal" | "insert" = "insert";
|
|
@@ -1868,7 +1868,7 @@ See [tui.md](tui.md) Pattern 7 for a complete example with mode indicator.
|
|
|
1868
1868
|
Register a custom renderer for messages with your `customType`:
|
|
1869
1869
|
|
|
1870
1870
|
```typescript
|
|
1871
|
-
import { Text } from "@
|
|
1871
|
+
import { Text } from "@apholdings/jensen-tui";
|
|
1872
1872
|
|
|
1873
1873
|
pi.registerMessageRenderer("my-extension", (message, options, theme) => {
|
|
1874
1874
|
const { expanded } = options;
|
|
@@ -1917,7 +1917,7 @@ theme.strikethrough(text)
|
|
|
1917
1917
|
For syntax highlighting in custom tool renderers:
|
|
1918
1918
|
|
|
1919
1919
|
```typescript
|
|
1920
|
-
import { highlightCode, getLanguageFromPath } from "@
|
|
1920
|
+
import { highlightCode, getLanguageFromPath } from "@apholdings/jensen-code";
|
|
1921
1921
|
|
|
1922
1922
|
// Highlight code with explicit language
|
|
1923
1923
|
const highlighted = highlightCode("const x = 1;", "typescript", theme);
|
|
@@ -2021,3 +2021,4 @@ All examples in [examples/extensions/](../examples/extensions/).
|
|
|
2021
2021
|
| `inline-bash.ts` | Inline bash in tool calls | `on("tool_call")` |
|
|
2022
2022
|
| `bash-spawn-hook.ts` | Adjust bash command, cwd, and env before execution | `createBashTool`, `spawnHook` |
|
|
2023
2023
|
| `with-deps/` | Extension with npm dependencies | Package structure with `package.json` |
|
|
2024
|
+
|
package/docs/packages.md
CHANGED
|
@@ -149,7 +149,7 @@ If no `pi` manifest is present, pi auto-discovers resources from these directori
|
|
|
149
149
|
|
|
150
150
|
Third party runtime dependencies belong in `dependencies` in `package.json`. Dependencies that do not register extensions, skills, prompt templates, or themes also belong in `dependencies`. When pi installs a package from npm or git, it runs `npm install`, so those dependencies are installed automatically.
|
|
151
151
|
|
|
152
|
-
Pi bundles core packages for extensions and skills. If you import any of these, list them in `peerDependencies` with a `"*"` range and do not bundle them: `@
|
|
152
|
+
Pi bundles core packages for extensions and skills. If you import any of these, list them in `peerDependencies` with a `"*"` range and do not bundle them: `@apholdings/jensen-ai`, `@apholdings/jensen-agent-core`, `@apholdings/jensen-code`, `@apholdings/jensen-tui`, `@sinclair/typebox`.
|
|
153
153
|
|
|
154
154
|
Other pi packages must be bundled in your tarball. Add them to `dependencies` and `bundledDependencies`, then reference their resources through `node_modules/` paths. Pi loads packages with separate module roots, so separate installs do not collide or share modules.
|
|
155
155
|
|
|
@@ -207,3 +207,4 @@ Packages can appear in both global and project settings. If the same package app
|
|
|
207
207
|
- npm: package name
|
|
208
208
|
- git: repository URL without ref
|
|
209
209
|
- local: resolved absolute path
|
|
210
|
+
|
package/docs/rpc.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
RPC mode enables headless operation of the coding agent via a JSON protocol over stdin/stdout. This is useful for embedding the agent in other applications, IDEs, or custom UIs.
|
|
4
4
|
|
|
5
|
-
**Note for Node.js/TypeScript users**: If you're building a Node.js application, consider using `AgentSession` directly from `@
|
|
5
|
+
**Note for Node.js/TypeScript users**: If you're building a Node.js application, consider using `AgentSession` directly from `@apholdings/jensen-code` instead of spawning a subprocess. See [`src/core/agent-session.ts`](../src/core/agent-session.ts) for the API. For a subprocess-based TypeScript client, see [`src/modes/rpc/rpc-client.ts`](../src/modes/rpc/rpc-client.ts).
|
|
6
6
|
|
|
7
7
|
## Starting RPC Mode
|
|
8
8
|
|
|
@@ -1352,3 +1352,4 @@ process.on("SIGINT", () => {
|
|
|
1352
1352
|
agent.stdin.write(JSON.stringify({ type: "abort" }) + "\n");
|
|
1353
1353
|
});
|
|
1354
1354
|
```
|
|
1355
|
+
|
package/docs/sdk.md
CHANGED
|
@@ -16,7 +16,7 @@ See [examples/sdk/](../examples/sdk/) for working examples from minimal to full
|
|
|
16
16
|
## Quick Start
|
|
17
17
|
|
|
18
18
|
```typescript
|
|
19
|
-
import { AuthStorage, createAgentSession, ModelRegistry, SessionManager } from "@
|
|
19
|
+
import { AuthStorage, createAgentSession, ModelRegistry, SessionManager } from "@apholdings/jensen-code";
|
|
20
20
|
|
|
21
21
|
// Set up credential storage and model registry
|
|
22
22
|
const authStorage = AuthStorage.create();
|
|
@@ -40,7 +40,7 @@ await session.prompt("What files are in the current directory?");
|
|
|
40
40
|
## Installation
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
npm install @
|
|
43
|
+
npm install @apholdings/jensen-code
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
The SDK is included in the main package. No separate installation needed.
|
|
@@ -54,7 +54,7 @@ The main factory function. Creates an `AgentSession` with configurable options.
|
|
|
54
54
|
`createAgentSession()` uses a `ResourceLoader` to supply extensions, skills, prompt templates, themes, and context files. If you do not provide one, it uses `DefaultResourceLoader` with standard discovery.
|
|
55
55
|
|
|
56
56
|
```typescript
|
|
57
|
-
import { createAgentSession } from "@
|
|
57
|
+
import { createAgentSession } from "@apholdings/jensen-code";
|
|
58
58
|
|
|
59
59
|
// Minimal: defaults with DefaultResourceLoader
|
|
60
60
|
const { session } = await createAgentSession();
|
|
@@ -161,7 +161,7 @@ Both `steer()` and `followUp()` expand file-based prompt templates but error on
|
|
|
161
161
|
|
|
162
162
|
### Agent and AgentState
|
|
163
163
|
|
|
164
|
-
The `Agent` class (from `@
|
|
164
|
+
The `Agent` class (from `@apholdings/jensen-agent-core`) handles the core LLM interaction. Access it via `session.agent`.
|
|
165
165
|
|
|
166
166
|
```typescript
|
|
167
167
|
// Access current state
|
|
@@ -282,8 +282,8 @@ When you pass a custom `ResourceLoader`, `cwd` and `agentDir` no longer control
|
|
|
282
282
|
### Model
|
|
283
283
|
|
|
284
284
|
```typescript
|
|
285
|
-
import { getModel } from "@
|
|
286
|
-
import { AuthStorage, ModelRegistry } from "@
|
|
285
|
+
import { getModel } from "@apholdings/jensen-ai";
|
|
286
|
+
import { AuthStorage, ModelRegistry } from "@apholdings/jensen-code";
|
|
287
287
|
|
|
288
288
|
const authStorage = AuthStorage.create();
|
|
289
289
|
const modelRegistry = new ModelRegistry(authStorage);
|
|
@@ -330,7 +330,7 @@ API key resolution priority (handled by AuthStorage):
|
|
|
330
330
|
4. Fallback resolver (for custom provider keys from `models.json`)
|
|
331
331
|
|
|
332
332
|
```typescript
|
|
333
|
-
import { AuthStorage, ModelRegistry } from "@
|
|
333
|
+
import { AuthStorage, ModelRegistry } from "@apholdings/jensen-code";
|
|
334
334
|
|
|
335
335
|
// Default: uses ~/.pi/agent/auth.json and ~/.pi/agent/models.json
|
|
336
336
|
const authStorage = AuthStorage.create();
|
|
@@ -366,7 +366,7 @@ const simpleRegistry = new ModelRegistry(authStorage);
|
|
|
366
366
|
Use a `ResourceLoader` to override the system prompt:
|
|
367
367
|
|
|
368
368
|
```typescript
|
|
369
|
-
import { createAgentSession, DefaultResourceLoader } from "@
|
|
369
|
+
import { createAgentSession, DefaultResourceLoader } from "@apholdings/jensen-code";
|
|
370
370
|
|
|
371
371
|
const loader = new DefaultResourceLoader({
|
|
372
372
|
systemPromptOverride: () => "You are a helpful assistant.",
|
|
@@ -386,7 +386,7 @@ import {
|
|
|
386
386
|
readOnlyTools, // read, grep, find, ls
|
|
387
387
|
readTool, bashTool, editTool, writeTool,
|
|
388
388
|
grepTool, findTool, lsTool,
|
|
389
|
-
} from "@
|
|
389
|
+
} from "@apholdings/jensen-code";
|
|
390
390
|
|
|
391
391
|
// Use built-in tool set
|
|
392
392
|
const { session } = await createAgentSession({
|
|
@@ -414,7 +414,7 @@ import {
|
|
|
414
414
|
createGrepTool,
|
|
415
415
|
createFindTool,
|
|
416
416
|
createLsTool,
|
|
417
|
-
} from "@
|
|
417
|
+
} from "@apholdings/jensen-code";
|
|
418
418
|
|
|
419
419
|
const cwd = "/path/to/project";
|
|
420
420
|
|
|
@@ -444,7 +444,7 @@ const { session } = await createAgentSession({
|
|
|
444
444
|
|
|
445
445
|
```typescript
|
|
446
446
|
import { Type } from "@sinclair/typebox";
|
|
447
|
-
import { createAgentSession, type ToolDefinition } from "@
|
|
447
|
+
import { createAgentSession, type ToolDefinition } from "@apholdings/jensen-code";
|
|
448
448
|
|
|
449
449
|
// Inline custom tool
|
|
450
450
|
const myTool: ToolDefinition = {
|
|
@@ -475,7 +475,7 @@ Custom tools passed via `customTools` are combined with extension-registered too
|
|
|
475
475
|
Extensions are loaded by the `ResourceLoader`. `DefaultResourceLoader` discovers extensions from `~/.pi/agent/extensions/`, `.pi/extensions/`, and settings.json extension sources.
|
|
476
476
|
|
|
477
477
|
```typescript
|
|
478
|
-
import { createAgentSession, DefaultResourceLoader } from "@
|
|
478
|
+
import { createAgentSession, DefaultResourceLoader } from "@apholdings/jensen-code";
|
|
479
479
|
|
|
480
480
|
const loader = new DefaultResourceLoader({
|
|
481
481
|
additionalExtensionPaths: ["/path/to/my-extension.ts"],
|
|
@@ -497,7 +497,7 @@ Extensions can register tools, subscribe to events, add commands, and more. See
|
|
|
497
497
|
**Event Bus:** Extensions can communicate via `pi.events`. Pass a shared `eventBus` to `DefaultResourceLoader` if you need to emit or listen from outside:
|
|
498
498
|
|
|
499
499
|
```typescript
|
|
500
|
-
import { createEventBus, DefaultResourceLoader } from "@
|
|
500
|
+
import { createEventBus, DefaultResourceLoader } from "@apholdings/jensen-code";
|
|
501
501
|
|
|
502
502
|
const eventBus = createEventBus();
|
|
503
503
|
const loader = new DefaultResourceLoader({
|
|
@@ -517,7 +517,7 @@ import {
|
|
|
517
517
|
createAgentSession,
|
|
518
518
|
DefaultResourceLoader,
|
|
519
519
|
type Skill,
|
|
520
|
-
} from "@
|
|
520
|
+
} from "@apholdings/jensen-code";
|
|
521
521
|
|
|
522
522
|
const customSkill: Skill = {
|
|
523
523
|
name: "my-skill",
|
|
@@ -543,7 +543,7 @@ const { session } = await createAgentSession({ resourceLoader: loader });
|
|
|
543
543
|
### Context Files
|
|
544
544
|
|
|
545
545
|
```typescript
|
|
546
|
-
import { createAgentSession, DefaultResourceLoader } from "@
|
|
546
|
+
import { createAgentSession, DefaultResourceLoader } from "@apholdings/jensen-code";
|
|
547
547
|
|
|
548
548
|
const loader = new DefaultResourceLoader({
|
|
549
549
|
agentsFilesOverride: (current) => ({
|
|
@@ -567,7 +567,7 @@ import {
|
|
|
567
567
|
createAgentSession,
|
|
568
568
|
DefaultResourceLoader,
|
|
569
569
|
type PromptTemplate,
|
|
570
|
-
} from "@
|
|
570
|
+
} from "@apholdings/jensen-code";
|
|
571
571
|
|
|
572
572
|
const customCommand: PromptTemplate = {
|
|
573
573
|
name: "deploy",
|
|
@@ -594,7 +594,7 @@ const { session } = await createAgentSession({ resourceLoader: loader });
|
|
|
594
594
|
Sessions use a tree structure with `id`/`parentId` linking, enabling in-place branching.
|
|
595
595
|
|
|
596
596
|
```typescript
|
|
597
|
-
import { createAgentSession, SessionManager } from "@
|
|
597
|
+
import { createAgentSession, SessionManager } from "@apholdings/jensen-code";
|
|
598
598
|
|
|
599
599
|
// In-memory (no persistence)
|
|
600
600
|
const { session } = await createAgentSession({
|
|
@@ -665,7 +665,7 @@ sm.createBranchedSession(leafId); // Extract path to new file
|
|
|
665
665
|
### Settings Management
|
|
666
666
|
|
|
667
667
|
```typescript
|
|
668
|
-
import { createAgentSession, SettingsManager, SessionManager } from "@
|
|
668
|
+
import { createAgentSession, SettingsManager, SessionManager } from "@apholdings/jensen-code";
|
|
669
669
|
|
|
670
670
|
// Default: loads from files (global + project merged)
|
|
671
671
|
const { session } = await createAgentSession({
|
|
@@ -721,7 +721,7 @@ Use `DefaultResourceLoader` to discover extensions, skills, prompts, themes, and
|
|
|
721
721
|
import {
|
|
722
722
|
DefaultResourceLoader,
|
|
723
723
|
getAgentDir,
|
|
724
|
-
} from "@
|
|
724
|
+
} from "@apholdings/jensen-code";
|
|
725
725
|
|
|
726
726
|
const loader = new DefaultResourceLoader({
|
|
727
727
|
cwd,
|
|
@@ -762,7 +762,7 @@ interface LoadExtensionsResult {
|
|
|
762
762
|
## Complete Example
|
|
763
763
|
|
|
764
764
|
```typescript
|
|
765
|
-
import { getModel } from "@
|
|
765
|
+
import { getModel } from "@apholdings/jensen-ai";
|
|
766
766
|
import { Type } from "@sinclair/typebox";
|
|
767
767
|
import {
|
|
768
768
|
AuthStorage,
|
|
@@ -774,7 +774,7 @@ import {
|
|
|
774
774
|
readTool,
|
|
775
775
|
bashTool,
|
|
776
776
|
type ToolDefinition,
|
|
777
|
-
} from "@
|
|
777
|
+
} from "@apholdings/jensen-code";
|
|
778
778
|
|
|
779
779
|
// Set up auth storage (custom location)
|
|
780
780
|
const authStorage = AuthStorage.create("/custom/agent/auth.json");
|
|
@@ -851,7 +851,7 @@ The SDK exports run mode utilities for building custom interfaces on top of `cre
|
|
|
851
851
|
Full TUI interactive mode with editor, chat history, and all built-in commands:
|
|
852
852
|
|
|
853
853
|
```typescript
|
|
854
|
-
import { createAgentSession, InteractiveMode } from "@
|
|
854
|
+
import { createAgentSession, InteractiveMode } from "@apholdings/jensen-code";
|
|
855
855
|
|
|
856
856
|
const { session } = await createAgentSession({ /* ... */ });
|
|
857
857
|
|
|
@@ -872,7 +872,7 @@ await mode.run(); // Blocks until exit
|
|
|
872
872
|
Single-shot mode: send prompts, output result, exit:
|
|
873
873
|
|
|
874
874
|
```typescript
|
|
875
|
-
import { createAgentSession, runPrintMode } from "@
|
|
875
|
+
import { createAgentSession, runPrintMode } from "@apholdings/jensen-code";
|
|
876
876
|
|
|
877
877
|
const { session } = await createAgentSession({ /* ... */ });
|
|
878
878
|
|
|
@@ -889,7 +889,7 @@ await runPrintMode(session, {
|
|
|
889
889
|
JSON-RPC mode for subprocess integration:
|
|
890
890
|
|
|
891
891
|
```typescript
|
|
892
|
-
import { createAgentSession, runRpcMode } from "@
|
|
892
|
+
import { createAgentSession, runRpcMode } from "@apholdings/jensen-code";
|
|
893
893
|
|
|
894
894
|
const { session } = await createAgentSession({ /* ... */ });
|
|
895
895
|
|
|
@@ -966,3 +966,4 @@ type Tool
|
|
|
966
966
|
```
|
|
967
967
|
|
|
968
968
|
For extension types, see [extensions.md](extensions.md) for the full API.
|
|
969
|
+
|
package/docs/session.md
CHANGED
|
@@ -34,7 +34,7 @@ Source on GitHub ([pi-mono](https://github.com/badlogic/pi-mono)):
|
|
|
34
34
|
- [`packages/ai/src/types.ts`](https://github.com/badlogic/pi-mono/blob/main/packages/ai/src/types.ts) - Base message types (UserMessage, AssistantMessage, ToolResultMessage)
|
|
35
35
|
- [`packages/agent/src/types.ts`](https://github.com/badlogic/pi-mono/blob/main/packages/agent/src/types.ts) - AgentMessage union type
|
|
36
36
|
|
|
37
|
-
For TypeScript definitions in your project, inspect `node_modules/@
|
|
37
|
+
For TypeScript definitions in your project, inspect `node_modules/@apholdings/jensen-code/dist/` and `node_modules/@apholdings/jensen-ai/dist/`.
|
|
38
38
|
|
|
39
39
|
## Message Types
|
|
40
40
|
|
|
@@ -410,3 +410,4 @@ Key methods for working with sessions programmatically.
|
|
|
410
410
|
- `getSessionId()` - Session UUID
|
|
411
411
|
- `getSessionFile()` - Session file path (undefined for in-memory)
|
|
412
412
|
- `isPersisted()` - Whether session is saved to disk
|
|
413
|
+
|
package/docs/termux.md
CHANGED
|
@@ -17,7 +17,7 @@ pkg update && pkg upgrade
|
|
|
17
17
|
pkg install nodejs termux-api git
|
|
18
18
|
|
|
19
19
|
# Install pi
|
|
20
|
-
npm install -g @
|
|
20
|
+
npm install -g @apholdings/jensen-code
|
|
21
21
|
|
|
22
22
|
# Create config directory
|
|
23
23
|
mkdir -p ~/.pi/agent
|
|
@@ -125,3 +125,4 @@ If npm fails, try clearing the cache:
|
|
|
125
125
|
```bash
|
|
126
126
|
npm cache clean --force
|
|
127
127
|
```
|
|
128
|
+
|