saeeol 1.1.1 → 1.2.1
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/package.json +14 -14
- package/script/build.ts +1 -1
- package/src/addons/addon-analytics.ts +1 -1
- package/src/cli/cmd/tui/routes/session/suggest.tsx +1 -1
- package/src/cli/logo.ts +1 -1
- package/src/cli/ui.ts +1 -1
- package/src/config/config-loader.ts +1 -1
- package/src/config/config-schema.ts +1 -1
- package/src/config/config.ts +1 -1
- package/src/config/markdown.ts +1 -1
- package/src/index.ts +2 -2
- package/src/lsp/lsp.ts +1 -1
- package/src/lsp/server-web.ts +1 -1
- package/src/mcp/oauth-callback.ts +1 -1
- package/src/{saeeol → overlay}/encoding.ts +1 -1
- package/src/{saeeol → overlay}/text-stream.ts +1 -1
- package/src/{saeeol → overlay}/tool/encoded-io.ts +1 -1
- package/src/patch/patch-apply.ts +1 -1
- package/src/patch/patch-parse.ts +1 -1
- package/src/session/compaction-helpers.ts +1 -169
- package/src/session/compaction.ts +1 -712
- package/src/session/core/compaction/compaction-helpers.ts +169 -0
- package/src/session/core/compaction/compaction.ts +712 -0
- package/src/session/core/compaction/overflow.ts +28 -0
- package/src/session/core/instruction.ts +234 -0
- package/src/session/core/llm.ts +504 -0
- package/src/session/core/network.ts +392 -0
- package/src/session/core/processor.ts +731 -0
- package/src/session/core/projectors.ts +139 -0
- package/src/session/core/resolve-tools.ts +241 -0
- package/src/session/core/retry.ts +149 -0
- package/src/session/core/revert.ts +173 -0
- package/src/session/core/run-state.ts +110 -0
- package/src/session/core/schema.ts +35 -0
- package/src/session/core/session-types.ts +160 -0
- package/src/session/core/session.sql.ts +124 -0
- package/src/session/core/session.ts +948 -0
- package/src/session/core/shell-exec.ts +205 -0
- package/src/session/core/status.ts +100 -0
- package/src/session/core/subtask.ts +268 -0
- package/src/session/core/summary.ts +173 -0
- package/src/session/core/system.ts +114 -0
- package/src/session/core/todo.ts +86 -0
- package/src/session/core/user-part.ts +293 -0
- package/src/session/instruction.ts +1 -234
- package/src/session/llm.ts +1 -504
- package/src/session/message/message-errors.ts +83 -0
- package/src/session/message/message-parts.ts +89 -0
- package/src/session/message/message-query.ts +107 -0
- package/src/session/message/message-transform.ts +156 -0
- package/src/session/message/message-types.ts +68 -0
- package/src/session/message/message-v2.ts +73 -0
- package/src/session/message/message.ts +192 -0
- package/src/session/message-errors.ts +1 -83
- package/src/session/message-parts.ts +1 -89
- package/src/session/message-query.ts +1 -107
- package/src/session/message-transform.ts +1 -156
- package/src/session/message-types.ts +1 -68
- package/src/session/message-v2.ts +1 -73
- package/src/session/message.ts +1 -192
- package/src/session/network.ts +1 -392
- package/src/session/overflow.ts +1 -28
- package/src/session/processor.ts +1 -731
- package/src/session/projectors.ts +2 -139
- package/src/session/prompt/prompt-command.ts +93 -0
- package/src/session/prompt/prompt-loop.ts +299 -0
- package/src/session/prompt/prompt-model.ts +44 -0
- package/src/session/prompt/prompt-reminders.ts +120 -0
- package/src/session/prompt/prompt-resolve.ts +42 -0
- package/src/session/prompt/prompt-schemas.ts +128 -0
- package/src/session/prompt/prompt-title.ts +55 -0
- package/src/session/prompt/prompt-types.ts +47 -0
- package/src/session/prompt/prompt-user-msg.ts +80 -0
- package/src/session/prompt/prompt.ts +211 -0
- package/src/session/prompt-command.ts +1 -93
- package/src/session/prompt-loop.ts +1 -299
- package/src/session/prompt-model.ts +1 -44
- package/src/session/prompt-reminders.ts +1 -120
- package/src/session/prompt-resolve.ts +1 -42
- package/src/session/prompt-schemas.ts +1 -128
- package/src/session/prompt-title.ts +1 -55
- package/src/session/prompt-types.ts +1 -47
- package/src/session/prompt-user-msg.ts +1 -80
- package/src/session/prompt.ts +1 -211
- package/src/session/resolve-tools.ts +1 -241
- package/src/session/retry.ts +1 -149
- package/src/session/revert.ts +1 -173
- package/src/session/run-state.ts +1 -110
- package/src/session/schema.ts +1 -35
- package/src/session/session-types.ts +1 -160
- package/src/session/session.sql.ts +1 -124
- package/src/session/session.ts +1 -948
- package/src/session/shell-exec.ts +1 -205
- package/src/session/status.ts +1 -100
- package/src/session/subtask.ts +1 -268
- package/src/session/summary.ts +1 -173
- package/src/session/system.ts +1 -114
- package/src/session/todo.ts +1 -86
- package/src/session/user-part.ts +1 -293
- package/src/skill/index.ts +1 -1
- package/src/suggestion/index.ts +1 -1
- package/src/tool/apply_patch.ts +2 -2
- package/src/tool/edit.ts +2 -2
- package/src/tool/read.ts +2 -2
- package/src/tool/recall.ts +1 -1
- package/src/tool/registry.ts +2 -2
- package/src/tool/suggest.ts +1 -1
- package/src/tool/task.ts +3 -3
- package/src/tool/todo.ts +1 -1
- package/src/tool/write.ts +2 -2
- package/test/lsp/index.test.ts +1 -1
- package/test/saeeol/agent-manager-tool.test.ts +1 -1
- package/test/saeeol/ask-agent-permissions.test.ts +1 -1
- package/test/saeeol/bash-hierarchy.test.ts +1 -1
- package/test/saeeol/builtin-skills.test.ts +1 -1
- package/test/saeeol/cli/dev-setup.test.ts +1 -1
- package/test/saeeol/cli/roll-call.test.ts +1 -1
- package/test/saeeol/cli-run-auto-helper.test.ts +1 -1
- package/test/saeeol/codex-auth-refresh.test.ts +1 -1
- package/test/saeeol/commit-message/generate.test.ts +1 -1
- package/test/saeeol/commit-message/git-context.test.ts +1 -1
- package/test/saeeol/commit-message-windows.test.ts +1 -1
- package/test/saeeol/compaction-payload-recovery.test.ts +1 -1
- package/test/saeeol/config/config.test.ts +1 -1
- package/test/saeeol/config-injector.test.ts +1 -1
- package/test/saeeol/config-validation.test.ts +1 -1
- package/test/saeeol/cost-propagation.test.ts +1 -1
- package/test/saeeol/custom-provider-delete.test.ts +1 -1
- package/test/saeeol/diff-full.test.ts +1 -1
- package/test/saeeol/encoding.test.ts +1 -1
- package/test/saeeol/enhance-prompt.test.ts +1 -1
- package/test/saeeol/ensure-plan-dir.test.ts +1 -1
- package/test/saeeol/errors.test.ts +1 -1
- package/test/saeeol/help.test.ts +3 -3
- package/test/saeeol/ignore-migrator.test.ts +1 -1
- package/test/saeeol/indexing-auth.test.ts +1 -1
- package/test/saeeol/indexing-feature.test.ts +1 -1
- package/test/saeeol/indexing-label.test.ts +1 -1
- package/test/saeeol/indexing-startup.test.ts +1 -1
- package/test/saeeol/indexing-worktree.test.ts +1 -1
- package/test/saeeol/lancedb-runtime.test.ts +9 -9
- package/test/saeeol/logo.test.ts +1 -1
- package/test/saeeol/lsp-typescript-lightweight.test.ts +2 -2
- package/test/saeeol/mcp-migrator.test.ts +1 -1
- package/test/saeeol/model-info-panel-utils.test.ts +1 -1
- package/test/saeeol/modes-migrator.test.ts +1 -1
- package/test/saeeol/paths.test.ts +1 -1
- package/test/saeeol/permission/config-paths.test.ts +2 -2
- package/test/saeeol/permission/external-directory-allow.test.ts +1 -1
- package/test/saeeol/plan-exit-detection.test.ts +1 -1
- package/test/saeeol/plan-followup.test.ts +2 -2
- package/test/saeeol/project-id.test.ts +1 -1
- package/test/saeeol/question-dismiss-all.test.ts +1 -1
- package/test/saeeol/rules-migrator.test.ts +1 -1
- package/test/saeeol/semantic-search.test.ts +2 -2
- package/test/saeeol/session/platform-attribution.test.ts +1 -1
- package/test/saeeol/session-compaction-cap.test.ts +2 -2
- package/test/saeeol/session-compaction-chunks.test.ts +1 -1
- package/test/saeeol/session-compaction-safety.test.ts +1 -1
- package/test/saeeol/session-import-service.test.ts +1 -1
- package/test/saeeol/session-processor-empty-tool-calls.test.ts +1 -1
- package/test/saeeol/session-processor-review-telemetry.test.ts +1 -1
- package/test/saeeol/session-prompt-queue.test.ts +1 -1
- package/test/saeeol/sessions/remote-sender.test.ts +1 -1
- package/test/saeeol/snapshot-track-timeout.test.ts +1 -1
- package/test/saeeol/suggestion/auto-dismiss.test.ts +2 -2
- package/test/saeeol/suggestion/suggestion.test.ts +1 -1
- package/test/saeeol/suggestion/tool.test.ts +2 -2
- package/test/saeeol/system-prompt.test.ts +1 -1
- package/test/saeeol/todo-view.test.ts +1 -1
- package/test/saeeol/tool-registry-indexing.test.ts +3 -3
- package/test/saeeol/tui-diff.test.ts +1 -1
- package/test/saeeol/tui-sync.test.ts +1 -1
- package/test/saeeol/util/url.test.ts +1 -1
- package/test/saeeol/workflows-migrator.test.ts +1 -1
- package/test/saeeol/worktree-diff-summary.test.ts +1 -1
- package/tsconfig.json +1 -1
- /package/src/{saeeol → overlay}/agent/agent-remove.ts +0 -0
- /package/src/{saeeol → overlay}/agent/index.ts +0 -0
- /package/src/{saeeol → overlay}/agent/patch-agents.ts +0 -0
- /package/src/{saeeol → overlay}/agent/permissions.ts +0 -0
- /package/src/{saeeol → overlay}/agent-manager/event.ts +0 -0
- /package/src/{saeeol → overlay}/bash-hierarchy.ts +0 -0
- /package/src/{saeeol → overlay}/bell.ts +0 -0
- /package/src/{saeeol → overlay}/bootstrap.ts +0 -0
- /package/src/{saeeol → overlay}/claw/autocomplete-popup.tsx +0 -0
- /package/src/{saeeol → overlay}/claw/autocomplete-ref.ts +0 -0
- /package/src/{saeeol → overlay}/claw/autocomplete-types.ts +0 -0
- /package/src/{saeeol → overlay}/claw/autocomplete.tsx +0 -0
- /package/src/{saeeol → overlay}/claw/chat-client.ts +0 -0
- /package/src/{saeeol → overlay}/claw/chat.tsx +0 -0
- /package/src/{saeeol → overlay}/claw/client-events.ts +0 -0
- /package/src/{saeeol → overlay}/claw/client-helpers.ts +0 -0
- /package/src/{saeeol → overlay}/claw/client.ts +0 -0
- /package/src/{saeeol → overlay}/claw/dialog-conversation-list.tsx +0 -0
- /package/src/{saeeol → overlay}/claw/event-service-client-core.ts +0 -0
- /package/src/{saeeol → overlay}/claw/event-service-client-impl.ts +0 -0
- /package/src/{saeeol → overlay}/claw/event-service-client.ts +0 -0
- /package/src/{saeeol → overlay}/claw/hooks.ts +0 -0
- /package/src/{saeeol → overlay}/claw/sidebar.tsx +0 -0
- /package/src/{saeeol → overlay}/claw/types.ts +0 -0
- /package/src/{saeeol → overlay}/claw/view.tsx +0 -0
- /package/src/{saeeol → overlay}/cli/cmd/roll-call-call.ts +0 -0
- /package/src/{saeeol → overlay}/cli/cmd/roll-call-format.ts +0 -0
- /package/src/{saeeol → overlay}/cli/cmd/roll-call.ts +0 -0
- /package/src/{saeeol → overlay}/cli/cmd/tui/app.tsx +0 -0
- /package/src/{saeeol → overlay}/cli/cmd/tui/component/dialog-provider.tsx +0 -0
- /package/src/{saeeol → overlay}/cli/cmd/tui/feedback.ts +0 -0
- /package/src/{saeeol → overlay}/cli/cmd/tui/util/terminal.ts +0 -0
- /package/src/{saeeol → overlay}/cli/dev-setup-utils.ts +0 -0
- /package/src/{saeeol → overlay}/cli/dev-setup.ts +0 -0
- /package/src/{saeeol → overlay}/cli/heap-snapshot.ts +0 -0
- /package/src/{saeeol → overlay}/cli/logo.ts +0 -0
- /package/src/{saeeol → overlay}/cli/run-auto.ts +0 -0
- /package/src/{saeeol → overlay}/cli/saeeol-logo.ts +0 -0
- /package/src/{saeeol → overlay}/cloud-session.ts +0 -0
- /package/src/{saeeol → overlay}/commands-index.ts +0 -0
- /package/src/{saeeol → overlay}/commands.ts +0 -0
- /package/src/{saeeol → overlay}/commands.tsx +0 -0
- /package/src/{saeeol → overlay}/commit-message/generate.ts +0 -0
- /package/src/{saeeol → overlay}/commit-message/git-context.ts +0 -0
- /package/src/{saeeol → overlay}/commit-message/index.ts +0 -0
- /package/src/{saeeol → overlay}/commit-message/types.ts +0 -0
- /package/src/{saeeol → overlay}/components/dialog-auto-method.tsx +0 -0
- /package/src/{saeeol → overlay}/components/dialog-claw-setup.tsx +0 -0
- /package/src/{saeeol → overlay}/components/dialog-claw-upgrade.tsx +0 -0
- /package/src/{saeeol → overlay}/components/dialog-indexing-helpers.ts +0 -0
- /package/src/{saeeol → overlay}/components/dialog-indexing.tsx +0 -0
- /package/src/{saeeol → overlay}/components/dialog-notifications.tsx +0 -0
- /package/src/{saeeol → overlay}/components/dialog-organization.tsx +0 -0
- /package/src/{saeeol → overlay}/components/dialog-profile.tsx +0 -0
- /package/src/{saeeol → overlay}/components/dialog-provider-settings.tsx +0 -0
- /package/src/{saeeol → overlay}/components/dialog-team-select.tsx +0 -0
- /package/src/{saeeol → overlay}/components/dialog-tuning.tsx +0 -0
- /package/src/{saeeol → overlay}/components/dialog-vector-store.tsx +0 -0
- /package/src/{saeeol → overlay}/components/error-display.tsx +0 -0
- /package/src/{saeeol → overlay}/components/model-info-panel-utils.ts +0 -0
- /package/src/{saeeol → overlay}/components/model-info-panel.tsx +0 -0
- /package/src/{saeeol → overlay}/components/news.tsx +0 -0
- /package/src/{saeeol → overlay}/components/notification-banner.tsx +0 -0
- /package/src/{saeeol → overlay}/components/session-indexing.tsx +0 -0
- /package/src/{saeeol → overlay}/components/tips.tsx +0 -0
- /package/src/{saeeol → overlay}/config/config-core.ts +0 -0
- /package/src/{saeeol → overlay}/config/config-helpers.ts +0 -0
- /package/src/{saeeol → overlay}/config/config-legacy.ts +0 -0
- /package/src/{saeeol → overlay}/config/config.ts +0 -0
- /package/src/{saeeol → overlay}/config/default-plugins.ts +0 -0
- /package/src/{saeeol → overlay}/config/markdown.ts +0 -0
- /package/src/{saeeol → overlay}/config-injector.ts +0 -0
- /package/src/{saeeol → overlay}/config-validation.ts +0 -0
- /package/src/{saeeol → overlay}/const.ts +0 -0
- /package/src/{saeeol → overlay}/cost-tracker/format.ts +0 -0
- /package/src/{saeeol → overlay}/cost-tracker/index.ts +0 -0
- /package/src/{saeeol → overlay}/cost-tracker/state.ts +0 -0
- /package/src/{saeeol → overlay}/cost-tracker/types.ts +0 -0
- /package/src/{saeeol → overlay}/docs/migration.md +0 -0
- /package/src/{saeeol → overlay}/docs/rules-migration.md +0 -0
- /package/src/{saeeol → overlay}/editor-context.ts +0 -0
- /package/src/{saeeol → overlay}/enhance-prompt.ts +0 -0
- /package/src/{saeeol → overlay}/errors.ts +0 -0
- /package/src/{saeeol → overlay}/generate-cli-docs.ts +0 -0
- /package/src/{saeeol → overlay}/help-command.ts +0 -0
- /package/src/{saeeol → overlay}/help.ts +0 -0
- /package/src/{saeeol → overlay}/i18n/index.ts +0 -0
- /package/src/{saeeol → overlay}/ignore-migrator.ts +0 -0
- /package/src/{saeeol → overlay}/index.ts +0 -0
- /package/src/{saeeol → overlay}/indexing-auth.ts +0 -0
- /package/src/{saeeol → overlay}/indexing-feature.ts +0 -0
- /package/src/{saeeol → overlay}/indexing-helpers.ts +0 -0
- /package/src/{saeeol → overlay}/indexing-label.ts +0 -0
- /package/src/{saeeol → overlay}/indexing-state.ts +0 -0
- /package/src/{saeeol → overlay}/indexing-types.ts +0 -0
- /package/src/{saeeol → overlay}/indexing.ts +0 -0
- /package/src/{saeeol → overlay}/lancedb.ts +0 -0
- /package/src/{saeeol → overlay}/mcp-migrator.ts +0 -0
- /package/src/{saeeol → overlay}/mcp-oauth-callback.ts +0 -0
- /package/src/{saeeol → overlay}/memory/age.ts +0 -0
- /package/src/{saeeol → overlay}/memory/index.ts +0 -0
- /package/src/{saeeol → overlay}/memory/paths.ts +0 -0
- /package/src/{saeeol → overlay}/memory/scan.ts +0 -0
- /package/src/{saeeol → overlay}/memory/types.ts +0 -0
- /package/src/{saeeol → overlay}/model-match.ts +0 -0
- /package/src/{saeeol → overlay}/modes-migrator.ts +0 -0
- /package/src/{saeeol → overlay}/paths.ts +0 -0
- /package/src/{saeeol → overlay}/permission/config-paths.ts +0 -0
- /package/src/{saeeol → overlay}/permission/drain.ts +0 -0
- /package/src/{saeeol → overlay}/permission/external-directory.ts +0 -0
- /package/src/{saeeol → overlay}/permission/read.ts +0 -0
- /package/src/{saeeol → overlay}/permission/routes.ts +0 -0
- /package/src/{saeeol → overlay}/permission/rule.ts +0 -0
- /package/src/{saeeol → overlay}/plan-followup-handover.ts +0 -0
- /package/src/{saeeol → overlay}/plan-followup-runtime.ts +0 -0
- /package/src/{saeeol → overlay}/plan-followup-session.ts +0 -0
- /package/src/{saeeol → overlay}/plan-followup.ts +0 -0
- /package/src/{saeeol → overlay}/plugins/home-footer.tsx +0 -0
- /package/src/{saeeol → overlay}/plugins/home-news.tsx +0 -0
- /package/src/{saeeol → overlay}/plugins/home-onboarding.tsx +0 -0
- /package/src/{saeeol → overlay}/plugins/sidebar-footer.tsx +0 -0
- /package/src/{saeeol → overlay}/plugins/sidebar-pr.tsx +0 -0
- /package/src/{saeeol → overlay}/plugins/sidebar-usage.tsx +0 -0
- /package/src/{saeeol → overlay}/project-id.ts +0 -0
- /package/src/{saeeol → overlay}/provider/codex-refresh.ts +0 -0
- /package/src/{saeeol → overlay}/provider/provider.ts +0 -0
- /package/src/{saeeol → overlay}/provider-options.ts +0 -0
- /package/src/{saeeol → overlay}/question/index.ts +0 -0
- /package/src/{saeeol → overlay}/remote-tui.tsx +0 -0
- /package/src/{saeeol → overlay}/review/command.ts +0 -0
- /package/src/{saeeol → overlay}/review/diff.ts +0 -0
- /package/src/{saeeol → overlay}/review/prompt.ts +0 -0
- /package/src/{saeeol → overlay}/review/review.ts +0 -0
- /package/src/{saeeol → overlay}/review/types.ts +0 -0
- /package/src/{saeeol → overlay}/review/worktree-diff.ts +0 -0
- /package/src/{saeeol → overlay}/rules-migrator.ts +0 -0
- /package/src/{saeeol → overlay}/server/instance.ts +0 -0
- /package/src/{saeeol → overlay}/server/router.ts +0 -0
- /package/src/{saeeol → overlay}/server/routes/commit-message.ts +0 -0
- /package/src/{saeeol → overlay}/server/routes/indexing.ts +0 -0
- /package/src/{saeeol → overlay}/server/server.ts +0 -0
- /package/src/{saeeol → overlay}/session/compaction-chunks-core.ts +0 -0
- /package/src/{saeeol → overlay}/session/compaction-chunks-utils.ts +0 -0
- /package/src/{saeeol → overlay}/session/compaction-chunks.ts +0 -0
- /package/src/{saeeol → overlay}/session/compaction-payload-recovery.ts +0 -0
- /package/src/{saeeol → overlay}/session/cost-propagation.ts +0 -0
- /package/src/{saeeol → overlay}/session/digest-storage.ts +0 -0
- /package/src/{saeeol → overlay}/session/fork.ts +0 -0
- /package/src/{saeeol → overlay}/session/index.ts +0 -0
- /package/src/{saeeol → overlay}/session/instruction.ts +0 -0
- /package/src/{saeeol → overlay}/session/kg-compaction.ts +0 -0
- /package/src/{saeeol → overlay}/session/llm.ts +0 -0
- /package/src/{saeeol → overlay}/session/overflow.ts +0 -0
- /package/src/{saeeol → overlay}/session/platform.ts +0 -0
- /package/src/{saeeol → overlay}/session/processor.ts +0 -0
- /package/src/{saeeol → overlay}/session/prompt-context.ts +0 -0
- /package/src/{saeeol → overlay}/session/prompt-plan.ts +0 -0
- /package/src/{saeeol → overlay}/session/prompt-queue.ts +0 -0
- /package/src/{saeeol → overlay}/session/prompt.ts +0 -0
- /package/src/{saeeol → overlay}/session/queries.ts +0 -0
- /package/src/{saeeol → overlay}/session/tui-sync.ts +0 -0
- /package/src/{saeeol → overlay}/session-import/routes.ts +0 -0
- /package/src/{saeeol → overlay}/session-import/service.ts +0 -0
- /package/src/{saeeol → overlay}/session-import/types.ts +0 -0
- /package/src/{saeeol → overlay}/skills/builtin.ts +0 -0
- /package/src/{saeeol → overlay}/skills/config.md +0 -0
- /package/src/{saeeol → overlay}/snapshot/diff-full.ts +0 -0
- /package/src/{saeeol → overlay}/snapshot/index.ts +0 -0
- /package/src/{saeeol → overlay}/snapshot/track-hooks.ts +0 -0
- /package/src/{saeeol → overlay}/snapshot/track-types.ts +0 -0
- /package/src/{saeeol → overlay}/snapshot/track.ts +0 -0
- /package/src/{saeeol → overlay}/soul.txt +0 -0
- /package/src/{saeeol → overlay}/suggestion/index.ts +0 -0
- /package/src/{saeeol → overlay}/suggestion/routes.ts +0 -0
- /package/src/{saeeol → overlay}/suggestion/tool.ts +0 -0
- /package/src/{saeeol → overlay}/suggestion/tool.txt +0 -0
- /package/src/{saeeol → overlay}/suggestion/tui/bar.tsx +0 -0
- /package/src/{saeeol → overlay}/suggestion/tui/prompt.tsx +0 -0
- /package/src/{saeeol → overlay}/suggestion/tui/render.tsx +0 -0
- /package/src/{saeeol → overlay}/suggestion/tui/sync.ts +0 -0
- /package/src/{saeeol → overlay}/system-prompt.ts +0 -0
- /package/src/{saeeol → overlay}/todo-view.ts +0 -0
- /package/src/{saeeol → overlay}/tool/agent-manager.ts +0 -0
- /package/src/{saeeol → overlay}/tool/agent-manager.txt +0 -0
- /package/src/{saeeol → overlay}/tool/bash-security-patterns.ts +0 -0
- /package/src/{saeeol → overlay}/tool/bash-security.ts +0 -0
- /package/src/{saeeol → overlay}/tool/question.ts +0 -0
- /package/src/{saeeol → overlay}/tool/registry.ts +0 -0
- /package/src/{saeeol → overlay}/tool/semantic-search.ts +0 -0
- /package/src/{saeeol → overlay}/tool/semantic-search.txt +0 -0
- /package/src/{saeeol → overlay}/tool/task.ts +0 -0
- /package/src/{saeeol → overlay}/ts-check.ts +0 -0
- /package/src/{saeeol → overlay}/ts-client.ts +0 -0
- /package/src/{saeeol → overlay}/tui/diff.ts +0 -0
- /package/src/{saeeol → overlay}/util/url.ts +0 -0
- /package/src/{saeeol → overlay}/worker/index.ts +0 -0
- /package/src/{saeeol → overlay}/worker/pool.ts +0 -0
- /package/src/{saeeol → overlay}/worker/store.ts +0 -0
- /package/src/{saeeol → overlay}/worker/types.ts +0 -0
- /package/src/{saeeol → overlay}/workflows-migrator.ts +0 -0
- /package/src/{saeeol → overlay}/worktree-cleanup.ts +0 -0
- /package/src/{saeeol → overlay}/worktree-family.ts +0 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { ulid } from "ulid"
|
|
2
|
+
import { Effect, Context, Layer, Exit, Cause, Latch } from "effect"
|
|
3
|
+
import { MessageID, PartID } from "./schema"
|
|
4
|
+
import { MessageV2 } from "../message/message-v2"
|
|
5
|
+
import * as Session from "./session"
|
|
6
|
+
import { Agent } from "../../agent/agent"
|
|
7
|
+
import { Provider } from "@/provider/provider"
|
|
8
|
+
import { ProviderID, ModelID } from "../../provider/schema"
|
|
9
|
+
import { Bus } from "../../bus"
|
|
10
|
+
import { Plugin } from "../../plugin"
|
|
11
|
+
import { Config } from "@/config/config"
|
|
12
|
+
import { Shell } from "@/shell/shell"
|
|
13
|
+
import { SessionRevert } from "./revert"
|
|
14
|
+
import { InstanceState } from "@/effect/instance-state"
|
|
15
|
+
import { ChildProcess } from "effect/unstable/process"
|
|
16
|
+
import { ChildProcessSpawner } from "effect/unstable/process"
|
|
17
|
+
import { CrossSpawnSpawner } from "@saeeol/core/cross-spawn-spawner"
|
|
18
|
+
import * as Stream from "effect/Stream"
|
|
19
|
+
import { NamedError } from "@saeeol/core/util/error"
|
|
20
|
+
import type { ShellInput } from "../prompt/prompt-schemas"
|
|
21
|
+
|
|
22
|
+
export interface Interface {
|
|
23
|
+
readonly exec: (
|
|
24
|
+
input: ShellInput,
|
|
25
|
+
getModel: (p: ProviderID, m: ModelID, s: any) => Effect.Effect<Provider.Model>,
|
|
26
|
+
lastModel: (s: any) => Effect.Effect<any>,
|
|
27
|
+
ready?: Latch.Latch,
|
|
28
|
+
) => Effect.Effect<MessageV2.WithParts>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class Service extends Context.Service<Service, Interface>()("@saeeol/SessionShell") {}
|
|
32
|
+
|
|
33
|
+
export const layer = Layer.effect(
|
|
34
|
+
Service,
|
|
35
|
+
Effect.gen(function* () {
|
|
36
|
+
const sessions = yield* Session.Service
|
|
37
|
+
const agents = yield* Agent.Service
|
|
38
|
+
const bus = yield* Bus.Service
|
|
39
|
+
const plugin = yield* Plugin.Service
|
|
40
|
+
const config = yield* Config.Service
|
|
41
|
+
const revert = yield* SessionRevert.Service
|
|
42
|
+
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner
|
|
43
|
+
|
|
44
|
+
const exec = Effect.fn("SessionShell.exec")(function* (
|
|
45
|
+
input: ShellInput,
|
|
46
|
+
getModel: (p: ProviderID, m: ModelID, s: any) => Effect.Effect<Provider.Model>,
|
|
47
|
+
lastModel: (s: any) => Effect.Effect<any>,
|
|
48
|
+
ready?: Latch.Latch,
|
|
49
|
+
) {
|
|
50
|
+
return yield* Effect.uninterruptibleMask((restore) =>
|
|
51
|
+
Effect.gen(function* () {
|
|
52
|
+
const markReady = ready ? ready.open.pipe(Effect.asVoid) : Effect.void
|
|
53
|
+
const { msg, part, cwd } = yield* Effect.gen(function* () {
|
|
54
|
+
const ctx = yield* InstanceState.context
|
|
55
|
+
const session = yield* sessions.get(input.sessionID)
|
|
56
|
+
if (session.revert) {
|
|
57
|
+
yield* revert.cleanup(session)
|
|
58
|
+
}
|
|
59
|
+
const agent = yield* agents.get(input.agent)
|
|
60
|
+
if (!agent) {
|
|
61
|
+
const available = (yield* agents.list()).filter((a: any) => !a.hidden).map((a: any) => a.name)
|
|
62
|
+
const hint = available.length ? ` Available agents: ${available.join(", ")}` : ""
|
|
63
|
+
const error = new NamedError.Unknown({ message: `Agent not found: "${input.agent}".${hint}` })
|
|
64
|
+
yield* bus.publish(Session.Event.Error, { sessionID: input.sessionID, error: error.toObject() })
|
|
65
|
+
throw error
|
|
66
|
+
}
|
|
67
|
+
const model = input.model ?? agent.model ?? (yield* lastModel(input.sessionID))!
|
|
68
|
+
const userMsg: MessageV2.User = {
|
|
69
|
+
id: input.messageID ?? MessageID.ascending(),
|
|
70
|
+
sessionID: input.sessionID,
|
|
71
|
+
time: { created: Date.now() },
|
|
72
|
+
role: "user",
|
|
73
|
+
agent: input.agent,
|
|
74
|
+
model: { providerID: model.providerID, modelID: model.modelID },
|
|
75
|
+
}
|
|
76
|
+
yield* sessions.updateMessage(userMsg)
|
|
77
|
+
const userPart: MessageV2.Part = {
|
|
78
|
+
type: "text",
|
|
79
|
+
id: PartID.ascending(),
|
|
80
|
+
messageID: userMsg.id,
|
|
81
|
+
sessionID: input.sessionID,
|
|
82
|
+
text: "The following tool was executed by the user",
|
|
83
|
+
synthetic: true,
|
|
84
|
+
}
|
|
85
|
+
yield* sessions.updatePart(userPart)
|
|
86
|
+
|
|
87
|
+
const msg: MessageV2.Assistant = {
|
|
88
|
+
id: MessageID.ascending(),
|
|
89
|
+
sessionID: input.sessionID,
|
|
90
|
+
parentID: userMsg.id,
|
|
91
|
+
mode: input.agent,
|
|
92
|
+
agent: input.agent,
|
|
93
|
+
cost: 0,
|
|
94
|
+
path: { cwd: ctx.directory, root: ctx.worktree },
|
|
95
|
+
time: { created: Date.now() },
|
|
96
|
+
role: "assistant",
|
|
97
|
+
tokens: { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
|
|
98
|
+
modelID: model.modelID,
|
|
99
|
+
providerID: model.providerID,
|
|
100
|
+
}
|
|
101
|
+
yield* sessions.updateMessage(msg)
|
|
102
|
+
const part: MessageV2.ToolPart = {
|
|
103
|
+
type: "tool",
|
|
104
|
+
id: PartID.ascending(),
|
|
105
|
+
messageID: msg.id,
|
|
106
|
+
sessionID: input.sessionID,
|
|
107
|
+
tool: "bash",
|
|
108
|
+
callID: ulid(),
|
|
109
|
+
state: {
|
|
110
|
+
status: "running",
|
|
111
|
+
time: { start: Date.now() },
|
|
112
|
+
input: { command: input.command },
|
|
113
|
+
},
|
|
114
|
+
}
|
|
115
|
+
yield* sessions.updatePart(part)
|
|
116
|
+
return { msg, part, cwd: ctx.directory }
|
|
117
|
+
}).pipe(Effect.ensuring(markReady))
|
|
118
|
+
|
|
119
|
+
const cfg = yield* config.get()
|
|
120
|
+
const sh = Shell.preferred(cfg.shell)
|
|
121
|
+
const args = Shell.args(sh, input.command, cwd)
|
|
122
|
+
let output = ""
|
|
123
|
+
let aborted = false
|
|
124
|
+
|
|
125
|
+
const finish = Effect.uninterruptible(
|
|
126
|
+
Effect.gen(function* () {
|
|
127
|
+
if (aborted) {
|
|
128
|
+
output += "\n\n" + ["<metadata>", "User aborted the command", "</metadata>"].join("\n")
|
|
129
|
+
}
|
|
130
|
+
if (!msg.time.completed) {
|
|
131
|
+
msg.time.completed = Date.now()
|
|
132
|
+
yield* sessions.updateMessage(msg)
|
|
133
|
+
}
|
|
134
|
+
if (part.state.status === "running") {
|
|
135
|
+
part.state = {
|
|
136
|
+
status: "completed",
|
|
137
|
+
time: { ...part.state.time, end: Date.now() },
|
|
138
|
+
input: part.state.input,
|
|
139
|
+
title: "",
|
|
140
|
+
metadata: { output, description: "" },
|
|
141
|
+
output,
|
|
142
|
+
}
|
|
143
|
+
yield* sessions.updatePart(part)
|
|
144
|
+
}
|
|
145
|
+
}),
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
const exit = yield* restore(
|
|
149
|
+
Effect.gen(function* () {
|
|
150
|
+
const shellEnv = yield* plugin.trigger(
|
|
151
|
+
"shell.env",
|
|
152
|
+
{ cwd, sessionID: input.sessionID, callID: part.callID },
|
|
153
|
+
{ env: {} },
|
|
154
|
+
)
|
|
155
|
+
const cmd = ChildProcess.make(sh, args, {
|
|
156
|
+
cwd,
|
|
157
|
+
extendEnv: true,
|
|
158
|
+
env: { ...shellEnv.env, TERM: "dumb" },
|
|
159
|
+
stdin: "ignore",
|
|
160
|
+
forceKillAfter: "3 seconds",
|
|
161
|
+
})
|
|
162
|
+
const handle = yield* spawner.spawn(cmd)
|
|
163
|
+
yield* Stream.runForEach(Stream.decodeText(handle.all), (chunk) =>
|
|
164
|
+
Effect.gen(function* () {
|
|
165
|
+
output += chunk
|
|
166
|
+
if (part.state.status === "running") {
|
|
167
|
+
part.state.metadata = { output, description: "" }
|
|
168
|
+
yield* sessions.updatePart(part)
|
|
169
|
+
}
|
|
170
|
+
}),
|
|
171
|
+
)
|
|
172
|
+
yield* handle.exitCode
|
|
173
|
+
}).pipe(Effect.scoped, Effect.orDie),
|
|
174
|
+
).pipe(Effect.exit)
|
|
175
|
+
|
|
176
|
+
if (Exit.isFailure(exit) && Cause.hasInterrupts(exit.cause) && !Cause.hasDies(exit.cause)) {
|
|
177
|
+
aborted = true
|
|
178
|
+
}
|
|
179
|
+
yield* finish
|
|
180
|
+
|
|
181
|
+
if (Exit.isFailure(exit) && !aborted && !Cause.hasInterruptsOnly(exit.cause)) {
|
|
182
|
+
return yield* Effect.failCause(exit.cause)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return { info: msg, parts: [part] }
|
|
186
|
+
}),
|
|
187
|
+
)
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
return { exec }
|
|
191
|
+
}),
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
export const defaultLayer = Layer.suspend(() =>
|
|
195
|
+
layer.pipe(
|
|
196
|
+
Layer.provide(Session.defaultLayer),
|
|
197
|
+
Layer.provide(Agent.defaultLayer),
|
|
198
|
+
Layer.provide(Plugin.defaultLayer),
|
|
199
|
+
Layer.provide(Config.defaultLayer),
|
|
200
|
+
Layer.provide(SessionRevert.defaultLayer),
|
|
201
|
+
Layer.provide(Provider.defaultLayer),
|
|
202
|
+
Layer.provide(Bus.layer),
|
|
203
|
+
Layer.provide(CrossSpawnSpawner.defaultLayer),
|
|
204
|
+
),
|
|
205
|
+
)
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { BusEvent } from "@/bus/bus-event"
|
|
2
|
+
import { Bus } from "@/bus"
|
|
3
|
+
import { InstanceState } from "@/effect/instance-state"
|
|
4
|
+
import { SessionID } from "./schema"
|
|
5
|
+
import { QuestionID } from "@/question/schema"
|
|
6
|
+
import { makeRuntime } from "@/effect/run-service"
|
|
7
|
+
import { zod } from "@/util/effect-zod"
|
|
8
|
+
import { NonNegativeInt, withStatics } from "@/util/schema"
|
|
9
|
+
import { Effect, Layer, Context, Schema } from "effect"
|
|
10
|
+
import z from "zod"
|
|
11
|
+
|
|
12
|
+
export const Info = Schema.Union([
|
|
13
|
+
Schema.Struct({
|
|
14
|
+
type: Schema.Literal("idle"),
|
|
15
|
+
}),
|
|
16
|
+
Schema.Struct({
|
|
17
|
+
type: Schema.Literal("retry"),
|
|
18
|
+
attempt: NonNegativeInt,
|
|
19
|
+
message: Schema.String,
|
|
20
|
+
next: NonNegativeInt,
|
|
21
|
+
}),
|
|
22
|
+
Schema.Struct({
|
|
23
|
+
type: Schema.Literal("busy"),
|
|
24
|
+
}),
|
|
25
|
+
Schema.Struct({
|
|
26
|
+
type: Schema.Literal("offline"),
|
|
27
|
+
requestID: QuestionID,
|
|
28
|
+
message: Schema.String,
|
|
29
|
+
}),
|
|
30
|
+
])
|
|
31
|
+
.annotate({ identifier: "SessionStatus" })
|
|
32
|
+
.pipe(withStatics((s) => ({ zod: zod(s) })))
|
|
33
|
+
export type Info = Schema.Schema.Type<typeof Info>
|
|
34
|
+
|
|
35
|
+
export const Event = {
|
|
36
|
+
Status: BusEvent.define(
|
|
37
|
+
"session.status",
|
|
38
|
+
Schema.Struct({
|
|
39
|
+
sessionID: SessionID,
|
|
40
|
+
status: Info,
|
|
41
|
+
}),
|
|
42
|
+
),
|
|
43
|
+
// deprecated
|
|
44
|
+
Idle: BusEvent.define(
|
|
45
|
+
"session.idle",
|
|
46
|
+
Schema.Struct({
|
|
47
|
+
sessionID: SessionID,
|
|
48
|
+
}),
|
|
49
|
+
),
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface Interface {
|
|
53
|
+
readonly get: (sessionID: SessionID) => Effect.Effect<Info>
|
|
54
|
+
readonly list: () => Effect.Effect<Map<SessionID, Info>>
|
|
55
|
+
readonly set: (sessionID: SessionID, status: Info) => Effect.Effect<void>
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export class Service extends Context.Service<Service, Interface>()("@saeeol/SessionStatus") {}
|
|
59
|
+
|
|
60
|
+
export const layer = Layer.effect(
|
|
61
|
+
Service,
|
|
62
|
+
Effect.gen(function* () {
|
|
63
|
+
const bus = yield* Bus.Service
|
|
64
|
+
|
|
65
|
+
const state = yield* InstanceState.make(
|
|
66
|
+
Effect.fn("SessionStatus.state")(() => Effect.succeed(new Map<SessionID, Info>())),
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
const get = Effect.fn("SessionStatus.get")(function* (sessionID: SessionID) {
|
|
70
|
+
const data = yield* InstanceState.get(state)
|
|
71
|
+
return data.get(sessionID) ?? { type: "idle" as const }
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
const list = Effect.fn("SessionStatus.list")(function* () {
|
|
75
|
+
return new Map(yield* InstanceState.get(state))
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
const set = Effect.fn("SessionStatus.set")(function* (sessionID: SessionID, status: Info) {
|
|
79
|
+
const data = yield* InstanceState.get(state)
|
|
80
|
+
yield* bus.publish(Event.Status, { sessionID, status })
|
|
81
|
+
if (status.type === "idle") {
|
|
82
|
+
yield* bus.publish(Event.Idle, { sessionID })
|
|
83
|
+
data.delete(sessionID)
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
data.set(sessionID, status)
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
return Service.of({ get, list, set })
|
|
90
|
+
}),
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
export const defaultLayer = layer.pipe(Layer.provide(Bus.layer))
|
|
94
|
+
const { runPromise } = makeRuntime(Service, defaultLayer)
|
|
95
|
+
|
|
96
|
+
export const list = () => runPromise((svc) => svc.list())
|
|
97
|
+
export const get = (sessionID: SessionID) => runPromise((svc) => svc.get(sessionID))
|
|
98
|
+
export const set = (sessionID: SessionID, status: Info) => runPromise((svc) => svc.set(sessionID, status))
|
|
99
|
+
|
|
100
|
+
export * as SessionStatus from "./status"
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { ulid } from "ulid"
|
|
2
|
+
import { Effect, Context, Layer, Cause } from "effect"
|
|
3
|
+
import { MessageID, PartID, SessionID } from "./schema"
|
|
4
|
+
import { MessageV2 } from "../message/message-v2"
|
|
5
|
+
import * as Session from "./session"
|
|
6
|
+
import { Agent } from "../../agent/agent"
|
|
7
|
+
import { Provider } from "@/provider/provider"
|
|
8
|
+
import { ProviderID, ModelID } from "../../provider/schema"
|
|
9
|
+
import { Bus } from "../../bus"
|
|
10
|
+
import { Permission } from "@/permission"
|
|
11
|
+
import { Plugin } from "../../plugin"
|
|
12
|
+
import { ToolRegistry } from "@/tool/registry"
|
|
13
|
+
import { TaskTool, type TaskPromptOps } from "@/tool/task"
|
|
14
|
+
import { EffectBridge } from "@/effect/bridge"
|
|
15
|
+
import { NamedError } from "@saeeol/core/util/error"
|
|
16
|
+
import { InstanceState } from "@/effect/instance-state"
|
|
17
|
+
import { SaeeolSessionPrompt } from "@/saeeol/session/prompt"
|
|
18
|
+
import { SaeeolCostPropagation } from "@/saeeol/session/cost-propagation"
|
|
19
|
+
import * as Log from "@saeeol/core/util/log"
|
|
20
|
+
|
|
21
|
+
const log = Log.create({ service: "session.subtask" })
|
|
22
|
+
|
|
23
|
+
export interface SubtaskInput {
|
|
24
|
+
task: MessageV2.SubtaskPart
|
|
25
|
+
model: Provider.Model
|
|
26
|
+
lastUser: MessageV2.User
|
|
27
|
+
sessionID: SessionID
|
|
28
|
+
session: Session.Info
|
|
29
|
+
msgs: MessageV2.WithParts[]
|
|
30
|
+
getModel: (p: ProviderID, m: ModelID, s: SessionID) => Effect.Effect<Provider.Model>
|
|
31
|
+
promptOps: TaskPromptOps
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface Interface {
|
|
35
|
+
readonly handle: (input: SubtaskInput) => Effect.Effect<void>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class Service extends Context.Service<Service, Interface>()("@saeeol/SessionSubtask") {}
|
|
39
|
+
|
|
40
|
+
export const layer = Layer.effect(
|
|
41
|
+
Service,
|
|
42
|
+
Effect.gen(function* () {
|
|
43
|
+
const sessions = yield* Session.Service
|
|
44
|
+
const agents = yield* Agent.Service
|
|
45
|
+
const bus = yield* Bus.Service
|
|
46
|
+
const plugin = yield* Plugin.Service
|
|
47
|
+
const permission = yield* Permission.Service
|
|
48
|
+
const registry = yield* ToolRegistry.Service
|
|
49
|
+
const bridge = yield* EffectBridge.make()
|
|
50
|
+
|
|
51
|
+
const handle = Effect.fn("SessionSubtask.handle")(function* (input: SubtaskInput) {
|
|
52
|
+
const { task, model, lastUser, sessionID, session, msgs } = input
|
|
53
|
+
const ctx = yield* InstanceState.context
|
|
54
|
+
const { task: taskTool } = yield* registry.named()
|
|
55
|
+
const taskModel = task.model ? yield* input.getModel(task.model.providerID, task.model.modelID, sessionID) : model
|
|
56
|
+
const assistantMessage: MessageV2.Assistant = yield* sessions.updateMessage({
|
|
57
|
+
id: MessageID.ascending(),
|
|
58
|
+
role: "assistant",
|
|
59
|
+
parentID: lastUser.id,
|
|
60
|
+
sessionID,
|
|
61
|
+
mode: task.agent,
|
|
62
|
+
agent: task.agent,
|
|
63
|
+
variant: lastUser.model.variant,
|
|
64
|
+
path: { cwd: ctx.directory, root: ctx.worktree },
|
|
65
|
+
cost: 0,
|
|
66
|
+
tokens: { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
|
|
67
|
+
modelID: taskModel.id,
|
|
68
|
+
providerID: taskModel.providerID,
|
|
69
|
+
time: { created: Date.now() },
|
|
70
|
+
})
|
|
71
|
+
let part: MessageV2.ToolPart = yield* sessions.updatePart({
|
|
72
|
+
id: PartID.ascending(),
|
|
73
|
+
messageID: assistantMessage.id,
|
|
74
|
+
sessionID: assistantMessage.sessionID,
|
|
75
|
+
type: "tool",
|
|
76
|
+
callID: ulid(),
|
|
77
|
+
tool: TaskTool.id,
|
|
78
|
+
state: {
|
|
79
|
+
status: "running",
|
|
80
|
+
input: {
|
|
81
|
+
prompt: task.prompt,
|
|
82
|
+
description: task.description,
|
|
83
|
+
subagent_type: task.agent,
|
|
84
|
+
command: task.command,
|
|
85
|
+
},
|
|
86
|
+
time: { start: Date.now() },
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
const taskArgs = {
|
|
90
|
+
prompt: task.prompt,
|
|
91
|
+
description: task.description,
|
|
92
|
+
subagent_type: task.agent,
|
|
93
|
+
command: task.command,
|
|
94
|
+
}
|
|
95
|
+
yield* plugin.trigger(
|
|
96
|
+
"tool.execute.before",
|
|
97
|
+
{ tool: TaskTool.id, sessionID, callID: part.id },
|
|
98
|
+
{ args: taskArgs },
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
const taskAgent = yield* agents.get(task.agent)
|
|
102
|
+
if (!taskAgent) {
|
|
103
|
+
const available = (yield* agents.list()).filter((a: any) => !a.hidden).map((a: any) => a.name)
|
|
104
|
+
const hint = available.length ? ` Available agents: ${available.join(", ")}` : ""
|
|
105
|
+
const error = new NamedError.Unknown({ message: `Agent not found: "${task.agent}".${hint}` })
|
|
106
|
+
yield* bus.publish(Session.Event.Error, { sessionID, error: error.toObject() })
|
|
107
|
+
throw error
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
let error: Error | undefined
|
|
111
|
+
const taskAbort = new AbortController()
|
|
112
|
+
const childID = () => {
|
|
113
|
+
const meta = part.state.status !== "pending" ? part.state.metadata : undefined
|
|
114
|
+
return (meta as { sessionId?: string } | undefined)?.sessionId
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const result = yield* taskTool
|
|
118
|
+
.execute(taskArgs, {
|
|
119
|
+
agent: task.agent,
|
|
120
|
+
messageID: assistantMessage.id,
|
|
121
|
+
sessionID,
|
|
122
|
+
abort: taskAbort.signal,
|
|
123
|
+
callID: part.callID,
|
|
124
|
+
extra: { bypassAgentCheck: true, promptOps: input.promptOps },
|
|
125
|
+
messages: msgs,
|
|
126
|
+
metadata: (val: any) =>
|
|
127
|
+
Effect.gen(function* () {
|
|
128
|
+
part = yield* sessions.updatePart({
|
|
129
|
+
...part,
|
|
130
|
+
type: "tool",
|
|
131
|
+
state: { ...part.state, ...val },
|
|
132
|
+
} satisfies MessageV2.ToolPart)
|
|
133
|
+
}),
|
|
134
|
+
ask: (req: any) =>
|
|
135
|
+
permission
|
|
136
|
+
.ask({
|
|
137
|
+
...req,
|
|
138
|
+
sessionID,
|
|
139
|
+
ruleset: Permission.merge(
|
|
140
|
+
taskAgent.permission,
|
|
141
|
+
SaeeolSessionPrompt.guardPermissions({ agent: taskAgent, session }),
|
|
142
|
+
),
|
|
143
|
+
hardRuleset: SaeeolSessionPrompt.hardPermissions({ agent: taskAgent }),
|
|
144
|
+
})
|
|
145
|
+
.pipe(Effect.orDie),
|
|
146
|
+
})
|
|
147
|
+
.pipe(
|
|
148
|
+
Effect.catchCause((cause) => {
|
|
149
|
+
const defect = Cause.squash(cause)
|
|
150
|
+
error = defect instanceof Error ? defect : new Error(String(defect))
|
|
151
|
+
log.error("subtask execution failed", { error, agent: task.agent, description: task.description })
|
|
152
|
+
return Effect.void
|
|
153
|
+
}),
|
|
154
|
+
Effect.onInterrupt(() =>
|
|
155
|
+
Effect.gen(function* () {
|
|
156
|
+
taskAbort.abort()
|
|
157
|
+
assistantMessage.finish = "tool-calls"
|
|
158
|
+
assistantMessage.time.completed = Date.now()
|
|
159
|
+
const cid = childID()
|
|
160
|
+
if (cid) {
|
|
161
|
+
assistantMessage.cost = yield* SaeeolCostPropagation.childCost(sessions, SessionID.make(cid))
|
|
162
|
+
}
|
|
163
|
+
yield* sessions.updateMessage(assistantMessage)
|
|
164
|
+
if (part.state.status === "running") {
|
|
165
|
+
yield* sessions.updatePart({
|
|
166
|
+
...part,
|
|
167
|
+
state: {
|
|
168
|
+
status: "error",
|
|
169
|
+
error: "Cancelled",
|
|
170
|
+
time: { start: part.state.time.start, end: Date.now() },
|
|
171
|
+
metadata: part.state.metadata,
|
|
172
|
+
input: part.state.input,
|
|
173
|
+
},
|
|
174
|
+
} satisfies MessageV2.ToolPart)
|
|
175
|
+
}
|
|
176
|
+
}),
|
|
177
|
+
),
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
const attachments = result?.attachments?.map((attachment: any) => ({
|
|
181
|
+
...attachment,
|
|
182
|
+
id: PartID.ascending(),
|
|
183
|
+
sessionID,
|
|
184
|
+
messageID: assistantMessage.id,
|
|
185
|
+
}))
|
|
186
|
+
|
|
187
|
+
yield* plugin.trigger(
|
|
188
|
+
"tool.execute.after",
|
|
189
|
+
{ tool: TaskTool.id, sessionID, callID: part.id, args: taskArgs },
|
|
190
|
+
result,
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
assistantMessage.finish = "tool-calls"
|
|
194
|
+
assistantMessage.time.completed = Date.now()
|
|
195
|
+
const cid = result?.metadata?.sessionId ?? childID()
|
|
196
|
+
if (cid) {
|
|
197
|
+
assistantMessage.cost = yield* SaeeolCostPropagation.childCost(sessions, SessionID.make(cid))
|
|
198
|
+
}
|
|
199
|
+
yield* sessions.updateMessage(assistantMessage)
|
|
200
|
+
|
|
201
|
+
if (result && part.state.status === "running") {
|
|
202
|
+
yield* sessions.updatePart({
|
|
203
|
+
...part,
|
|
204
|
+
state: {
|
|
205
|
+
status: "completed",
|
|
206
|
+
input: part.state.input,
|
|
207
|
+
title: result.title,
|
|
208
|
+
metadata: result.metadata,
|
|
209
|
+
output: result.output,
|
|
210
|
+
attachments,
|
|
211
|
+
time: { ...part.state.time, end: Date.now() },
|
|
212
|
+
},
|
|
213
|
+
} satisfies MessageV2.ToolPart)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (!result) {
|
|
217
|
+
yield* sessions.updatePart({
|
|
218
|
+
...part,
|
|
219
|
+
state: {
|
|
220
|
+
status: "error",
|
|
221
|
+
error: error ? `Tool execution failed: ${error.message}` : "Tool execution failed",
|
|
222
|
+
time: {
|
|
223
|
+
start: part.state.status === "running" ? part.state.time.start : Date.now(),
|
|
224
|
+
end: Date.now(),
|
|
225
|
+
},
|
|
226
|
+
metadata: part.state.status === "pending" ? undefined : part.state.metadata,
|
|
227
|
+
input: part.state.input,
|
|
228
|
+
},
|
|
229
|
+
} satisfies MessageV2.ToolPart)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (!task.command) return
|
|
233
|
+
|
|
234
|
+
const summaryUserMsg: MessageV2.User = {
|
|
235
|
+
id: MessageID.ascending(),
|
|
236
|
+
sessionID,
|
|
237
|
+
role: "user",
|
|
238
|
+
time: { created: Date.now() },
|
|
239
|
+
agent: lastUser.agent,
|
|
240
|
+
model: lastUser.model,
|
|
241
|
+
editorContext: lastUser.editorContext,
|
|
242
|
+
}
|
|
243
|
+
yield* sessions.updateMessage(summaryUserMsg)
|
|
244
|
+
yield* sessions.updatePart({
|
|
245
|
+
id: PartID.ascending(),
|
|
246
|
+
messageID: summaryUserMsg.id,
|
|
247
|
+
sessionID,
|
|
248
|
+
type: "text",
|
|
249
|
+
text: "Summarize the task tool output above and continue with your task.",
|
|
250
|
+
synthetic: true,
|
|
251
|
+
} satisfies MessageV2.TextPart)
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
return { handle }
|
|
255
|
+
}),
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
export const defaultLayer = Layer.suspend(() =>
|
|
259
|
+
layer.pipe(
|
|
260
|
+
Layer.provide(Session.defaultLayer),
|
|
261
|
+
Layer.provide(Agent.defaultLayer),
|
|
262
|
+
Layer.provide(Plugin.defaultLayer),
|
|
263
|
+
Layer.provide(Permission.defaultLayer),
|
|
264
|
+
Layer.provide(ToolRegistry.defaultLayer),
|
|
265
|
+
Layer.provide(Provider.defaultLayer),
|
|
266
|
+
Layer.provide(Bus.layer),
|
|
267
|
+
),
|
|
268
|
+
)
|