tarsk 0.4.4 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +447375 -37
- package/package.json +2 -2
- package/dist/agent/agent.error-utils.d.ts +0 -14
- package/dist/agent/agent.error-utils.js +0 -52
- package/dist/agent/agent.event-transformer.d.ts +0 -55
- package/dist/agent/agent.event-transformer.js +0 -175
- package/dist/agent/agent.executor.d.ts +0 -26
- package/dist/agent/agent.executor.js +0 -286
- package/dist/agent/agent.model-resolver.d.ts +0 -22
- package/dist/agent/agent.model-resolver.js +0 -67
- package/dist/agent/agent.process-manager.d.ts +0 -57
- package/dist/agent/agent.process-manager.js +0 -262
- package/dist/agent/agent.processing-state-manager.d.ts +0 -74
- package/dist/agent/agent.processing-state-manager.js +0 -87
- package/dist/agent/agent.prompt-loader.d.ts +0 -16
- package/dist/agent/agent.prompt-loader.js +0 -227
- package/dist/agent/agent.subagent-executor.d.ts +0 -35
- package/dist/agent/agent.subagent-executor.js +0 -135
- package/dist/bun/index.d.ts +0 -2
- package/dist/bun/index.js +0 -165
- package/dist/cli.d.ts +0 -3
- package/dist/cli.js +0 -22
- package/dist/core/crypto.d.ts +0 -29
- package/dist/core/crypto.js +0 -166
- package/dist/core/dev-server-cache.d.ts +0 -46
- package/dist/core/dev-server-cache.js +0 -59
- package/dist/core/env-manager.d.ts +0 -3
- package/dist/core/env-manager.js +0 -60
- package/dist/core/error-responses.d.ts +0 -61
- package/dist/core/error-responses.js +0 -64
- package/dist/core/logger.d.ts +0 -10
- package/dist/core/logger.js +0 -47
- package/dist/core/paths.d.ts +0 -22
- package/dist/core/paths.js +0 -26
- package/dist/core/random-words.d.ts +0 -18
- package/dist/core/random-words.js +0 -135
- package/dist/core/response-builder.d.ts +0 -50
- package/dist/core/response-builder.js +0 -56
- package/dist/core/route-helpers.d.ts +0 -47
- package/dist/core/route-helpers.js +0 -54
- package/dist/core/run-command-detector.d.ts +0 -26
- package/dist/core/run-command-detector.js +0 -98
- package/dist/core/stream-helper.d.ts +0 -44
- package/dist/core/stream-helper.js +0 -50
- package/dist/core/utils.d.ts +0 -43
- package/dist/core/utils.js +0 -113
- package/dist/core/validation.d.ts +0 -10
- package/dist/core/validation.js +0 -20
- package/dist/database/database.d.ts +0 -40
- package/dist/database/database.encryption.d.ts +0 -33
- package/dist/database/database.encryption.js +0 -62
- package/dist/database/database.js +0 -480
- package/dist/database/database.state.d.ts +0 -52
- package/dist/database/database.state.js +0 -119
- package/dist/database/database.test-utils.d.ts +0 -22
- package/dist/database/database.test-utils.js +0 -39
- package/dist/database/database.types.d.ts +0 -3
- package/dist/database/database.types.js +0 -2
- package/dist/features/agents/agents.manager.d.ts +0 -24
- package/dist/features/agents/agents.manager.js +0 -200
- package/dist/features/ask-user/ask-user.routes.d.ts +0 -9
- package/dist/features/ask-user/ask-user.routes.js +0 -35
- package/dist/features/chat/chat-delete.route.d.ts +0 -15
- package/dist/features/chat/chat-delete.route.js +0 -36
- package/dist/features/chat/chat-post.route.d.ts +0 -11
- package/dist/features/chat/chat-post.route.js +0 -270
- package/dist/features/chat/chat-stop.route.d.ts +0 -21
- package/dist/features/chat/chat-stop.route.js +0 -22
- package/dist/features/chat/chat-subscribe.route.d.ts +0 -9
- package/dist/features/chat/chat-subscribe.route.js +0 -71
- package/dist/features/chat/chat.routes.d.ts +0 -22
- package/dist/features/chat/chat.routes.js +0 -29
- package/dist/features/conversations/conversations-delete.route.d.ts +0 -16
- package/dist/features/conversations/conversations-delete.route.js +0 -34
- package/dist/features/conversations/conversations-get-all.route.d.ts +0 -16
- package/dist/features/conversations/conversations-get-all.route.js +0 -39
- package/dist/features/conversations/conversations-get-by-id.route.d.ts +0 -16
- package/dist/features/conversations/conversations-get-by-id.route.js +0 -38
- package/dist/features/conversations/conversations-get-deleted.route.d.ts +0 -15
- package/dist/features/conversations/conversations-get-deleted.route.js +0 -34
- package/dist/features/conversations/conversations-get-messages.route.d.ts +0 -16
- package/dist/features/conversations/conversations-get-messages.route.js +0 -49
- package/dist/features/conversations/conversations.content.d.ts +0 -28
- package/dist/features/conversations/conversations.content.js +0 -142
- package/dist/features/conversations/conversations.database.d.ts +0 -108
- package/dist/features/conversations/conversations.database.js +0 -373
- package/dist/features/conversations/conversations.manager.d.ts +0 -130
- package/dist/features/conversations/conversations.manager.js +0 -162
- package/dist/features/conversations/conversations.routes.d.ts +0 -21
- package/dist/features/conversations/conversations.routes.js +0 -38
- package/dist/features/conversations/token-usage.route.d.ts +0 -41
- package/dist/features/conversations/token-usage.route.js +0 -419
- package/dist/features/git/git-commit.route.d.ts +0 -12
- package/dist/features/git/git-commit.route.js +0 -39
- package/dist/features/git/git-create-branch.route.d.ts +0 -28
- package/dist/features/git/git-create-branch.route.js +0 -119
- package/dist/features/git/git-create-pr.route.d.ts +0 -13
- package/dist/features/git/git-create-pr.route.js +0 -50
- package/dist/features/git/git-create-repo.route.d.ts +0 -14
- package/dist/features/git/git-create-repo.route.js +0 -108
- package/dist/features/git/git-diff.route.d.ts +0 -30
- package/dist/features/git/git-diff.route.js +0 -189
- package/dist/features/git/git-fetch.route.d.ts +0 -12
- package/dist/features/git/git-fetch.route.js +0 -31
- package/dist/features/git/git-generate-commit-message.route.d.ts +0 -12
- package/dist/features/git/git-generate-commit-message.route.js +0 -76
- package/dist/features/git/git-generate-pr-info.route.d.ts +0 -13
- package/dist/features/git/git-generate-pr-info.route.js +0 -147
- package/dist/features/git/git-github-status.route.d.ts +0 -16
- package/dist/features/git/git-github-status.route.js +0 -68
- package/dist/features/git/git-log.route.d.ts +0 -17
- package/dist/features/git/git-log.route.js +0 -33
- package/dist/features/git/git-pr-status.route.d.ts +0 -15
- package/dist/features/git/git-pr-status.route.js +0 -33
- package/dist/features/git/git-pull.route.d.ts +0 -12
- package/dist/features/git/git-pull.route.js +0 -35
- package/dist/features/git/git-push.route.d.ts +0 -12
- package/dist/features/git/git-push.route.js +0 -46
- package/dist/features/git/git-status-cache.database.d.ts +0 -7
- package/dist/features/git/git-status-cache.database.js +0 -53
- package/dist/features/git/git-status.route.d.ts +0 -15
- package/dist/features/git/git-status.route.js +0 -62
- package/dist/features/git/git-sync-branch.route.d.ts +0 -4
- package/dist/features/git/git-sync-branch.route.js +0 -208
- package/dist/features/git/git-unified-status.route.d.ts +0 -30
- package/dist/features/git/git-unified-status.route.js +0 -165
- package/dist/features/git/git-username.route.d.ts +0 -3
- package/dist/features/git/git-username.route.js +0 -24
- package/dist/features/git/git.manager.d.ts +0 -139
- package/dist/features/git/git.manager.js +0 -352
- package/dist/features/git/git.routes.d.ts +0 -4
- package/dist/features/git/git.routes.js +0 -116
- package/dist/features/git/git.utils.d.ts +0 -82
- package/dist/features/git/git.utils.js +0 -1040
- package/dist/features/mcp/mcp.config.d.ts +0 -27
- package/dist/features/mcp/mcp.config.js +0 -148
- package/dist/features/mcp/mcp.manager.d.ts +0 -61
- package/dist/features/mcp/mcp.manager.js +0 -254
- package/dist/features/mcp/mcp.popular.json +0 -103
- package/dist/features/mcp/mcp.routes.d.ts +0 -13
- package/dist/features/mcp/mcp.routes.js +0 -159
- package/dist/features/mcp/mcp.types.d.ts +0 -80
- package/dist/features/mcp/mcp.types.js +0 -8
- package/dist/features/metadata/metadata.manager.d.ts +0 -126
- package/dist/features/metadata/metadata.manager.js +0 -423
- package/dist/features/models/model-info-aihubmix.d.ts +0 -25
- package/dist/features/models/model-info-aihubmix.js +0 -117
- package/dist/features/models/model-info-openrouter.d.ts +0 -25
- package/dist/features/models/model-info-openrouter.js +0 -104
- package/dist/features/models/model-info.d.ts +0 -37
- package/dist/features/models/model-info.js +0 -39
- package/dist/features/models/models-catalog.d.ts +0 -49
- package/dist/features/models/models-catalog.js +0 -80
- package/dist/features/models/models-catalog.route.d.ts +0 -43
- package/dist/features/models/models-catalog.route.js +0 -15
- package/dist/features/models/models-get-available.route.d.ts +0 -36
- package/dist/features/models/models-get-available.route.js +0 -66
- package/dist/features/models/models-get-enabled.route.d.ts +0 -33
- package/dist/features/models/models-get-enabled.route.js +0 -45
- package/dist/features/models/models-get-model-info.route.d.ts +0 -31
- package/dist/features/models/models-get-model-info.route.js +0 -84
- package/dist/features/models/models-model-disable.route.d.ts +0 -15
- package/dist/features/models/models-model-disable.route.js +0 -20
- package/dist/features/models/models-model-enable.route.d.ts +0 -13
- package/dist/features/models/models-model-enable.route.js +0 -20
- package/dist/features/models/models-provider-refresh.route.d.ts +0 -17
- package/dist/features/models/models-provider-refresh.route.js +0 -20
- package/dist/features/models/models.manager.d.ts +0 -58
- package/dist/features/models/models.manager.js +0 -138
- package/dist/features/models/models.routes.d.ts +0 -18
- package/dist/features/models/models.routes.js +0 -83
- package/dist/features/models/open-router-models.d.ts +0 -38
- package/dist/features/models/open-router-models.js +0 -73
- package/dist/features/models/openai-models.d.ts +0 -63
- package/dist/features/models/openai-models.js +0 -150
- package/dist/features/onboarding/onboarding-get-git-check.route.d.ts +0 -11
- package/dist/features/onboarding/onboarding-get-git-check.route.js +0 -28
- package/dist/features/onboarding/onboarding-get-status.route.d.ts +0 -12
- package/dist/features/onboarding/onboarding-get-status.route.js +0 -15
- package/dist/features/onboarding/onboarding-post-complete.route.d.ts +0 -12
- package/dist/features/onboarding/onboarding-post-complete.route.js +0 -15
- package/dist/features/onboarding/onboarding-post-reset.route.d.ts +0 -12
- package/dist/features/onboarding/onboarding-post-reset.route.js +0 -15
- package/dist/features/onboarding/onboarding.routes.d.ts +0 -18
- package/dist/features/onboarding/onboarding.routes.js +0 -28
- package/dist/features/project-todos/project-todos.database.d.ts +0 -38
- package/dist/features/project-todos/project-todos.database.js +0 -91
- package/dist/features/project-todos/project-todos.routes.d.ts +0 -4
- package/dist/features/project-todos/project-todos.routes.js +0 -94
- package/dist/features/projects/projects-ai-files.route.d.ts +0 -148
- package/dist/features/projects/projects-ai-files.route.js +0 -425
- package/dist/features/projects/projects-commands.route.d.ts +0 -27
- package/dist/features/projects/projects-commands.route.js +0 -39
- package/dist/features/projects/projects-create.route.d.ts +0 -19
- package/dist/features/projects/projects-create.route.js +0 -37
- package/dist/features/projects/projects-delete.route.d.ts +0 -24
- package/dist/features/projects/projects-delete.route.js +0 -34
- package/dist/features/projects/projects-get.route.d.ts +0 -47
- package/dist/features/projects/projects-get.route.js +0 -36
- package/dist/features/projects/projects-list.route.d.ts +0 -58
- package/dist/features/projects/projects-list.route.js +0 -59
- package/dist/features/projects/projects-open-folder.route.d.ts +0 -10
- package/dist/features/projects/projects-open-folder.route.js +0 -11
- package/dist/features/projects/projects-open.route.d.ts +0 -26
- package/dist/features/projects/projects-open.route.js +0 -49
- package/dist/features/projects/projects-package-scripts.route.d.ts +0 -15
- package/dist/features/projects/projects-package-scripts.route.js +0 -96
- package/dist/features/projects/projects-run-command.route.d.ts +0 -8
- package/dist/features/projects/projects-run-command.route.js +0 -21
- package/dist/features/projects/projects-run.route.d.ts +0 -51
- package/dist/features/projects/projects-run.route.js +0 -74
- package/dist/features/projects/projects-update.route.d.ts +0 -24
- package/dist/features/projects/projects-update.route.js +0 -81
- package/dist/features/projects/projects.creator.d.ts +0 -33
- package/dist/features/projects/projects.creator.js +0 -555
- package/dist/features/projects/projects.database.d.ts +0 -61
- package/dist/features/projects/projects.database.js +0 -212
- package/dist/features/projects/projects.manager.d.ts +0 -291
- package/dist/features/projects/projects.manager.js +0 -426
- package/dist/features/projects/projects.open-with.d.ts +0 -27
- package/dist/features/projects/projects.open-with.js +0 -156
- package/dist/features/projects/projects.routes.d.ts +0 -20
- package/dist/features/projects/projects.routes.js +0 -255
- package/dist/features/projects/terminal-session-manager.d.ts +0 -55
- package/dist/features/projects/terminal-session-manager.js +0 -90
- package/dist/features/providers/provider-resolver.d.ts +0 -13
- package/dist/features/providers/provider-resolver.js +0 -22
- package/dist/features/providers/providers-get-credits.route.d.ts +0 -15
- package/dist/features/providers/providers-get-credits.route.js +0 -51
- package/dist/features/providers/providers-get.route.d.ts +0 -16
- package/dist/features/providers/providers-get.route.js +0 -32
- package/dist/features/providers/providers-open-external.route.d.ts +0 -15
- package/dist/features/providers/providers-open-external.route.js +0 -49
- package/dist/features/providers/providers-post-bulk-keys.route.d.ts +0 -14
- package/dist/features/providers/providers-post-bulk-keys.route.js +0 -31
- package/dist/features/providers/providers-post-keys.route.d.ts +0 -14
- package/dist/features/providers/providers-post-keys.route.js +0 -25
- package/dist/features/providers/providers.routes.d.ts +0 -19
- package/dist/features/providers/providers.routes.js +0 -31
- package/dist/features/rules/rules-post.route.d.ts +0 -43
- package/dist/features/rules/rules-post.route.js +0 -89
- package/dist/features/rules/rules.manager.d.ts +0 -36
- package/dist/features/rules/rules.manager.js +0 -203
- package/dist/features/rules/rules.routes.d.ts +0 -12
- package/dist/features/rules/rules.routes.js +0 -13
- package/dist/features/run/run-get-running.route.d.ts +0 -15
- package/dist/features/run/run-get-running.route.js +0 -21
- package/dist/features/run/run-post-start.route.d.ts +0 -8
- package/dist/features/run/run-post-start.route.js +0 -21
- package/dist/features/run/run-post-stop.route.d.ts +0 -15
- package/dist/features/run/run-post-stop.route.js +0 -24
- package/dist/features/run/run-post-suggest.route.d.ts +0 -15
- package/dist/features/run/run-post-suggest.route.js +0 -21
- package/dist/features/run/run-put-command.route.d.ts +0 -15
- package/dist/features/run/run-put-command.route.js +0 -24
- package/dist/features/run/run.routes.d.ts +0 -19
- package/dist/features/run/run.routes.js +0 -31
- package/dist/features/scaffold/index.d.ts +0 -7
- package/dist/features/scaffold/index.js +0 -5
- package/dist/features/scaffold/scaffold-get-templates.route.d.ts +0 -27
- package/dist/features/scaffold/scaffold-get-templates.route.js +0 -17
- package/dist/features/scaffold/scaffold-post.route.d.ts +0 -8
- package/dist/features/scaffold/scaffold-post.route.js +0 -30
- package/dist/features/scaffold/scaffold.routes.d.ts +0 -10
- package/dist/features/scaffold/scaffold.routes.js +0 -16
- package/dist/features/scaffold/scaffold.runner.d.ts +0 -48
- package/dist/features/scaffold/scaffold.runner.js +0 -475
- package/dist/features/scaffold/scaffold.types.d.ts +0 -26
- package/dist/features/scaffold/scaffold.types.js +0 -5
- package/dist/features/skills/skills.activation.d.ts +0 -31
- package/dist/features/skills/skills.activation.js +0 -155
- package/dist/features/skills/skills.manager.d.ts +0 -35
- package/dist/features/skills/skills.manager.js +0 -251
- package/dist/features/slash-commands/slash-commands-delete.route.d.ts +0 -23
- package/dist/features/slash-commands/slash-commands-delete.route.js +0 -36
- package/dist/features/slash-commands/slash-commands-get.route.d.ts +0 -53
- package/dist/features/slash-commands/slash-commands-get.route.js +0 -54
- package/dist/features/slash-commands/slash-commands-post.route.d.ts +0 -39
- package/dist/features/slash-commands/slash-commands-post.route.js +0 -70
- package/dist/features/slash-commands/slash-commands-put.route.d.ts +0 -23
- package/dist/features/slash-commands/slash-commands-put.route.js +0 -36
- package/dist/features/slash-commands/slash-commands.manager.d.ts +0 -46
- package/dist/features/slash-commands/slash-commands.manager.js +0 -265
- package/dist/features/slash-commands/slash-commands.routes.d.ts +0 -13
- package/dist/features/slash-commands/slash-commands.routes.js +0 -20
- package/dist/features/threads/threads-ai-files.route.d.ts +0 -153
- package/dist/features/threads/threads-ai-files.route.js +0 -287
- package/dist/features/threads/threads-conversation-folder-path.route.d.ts +0 -14
- package/dist/features/threads/threads-conversation-folder-path.route.js +0 -23
- package/dist/features/threads/threads-create.route.d.ts +0 -22
- package/dist/features/threads/threads-create.route.js +0 -60
- package/dist/features/threads/threads-delete.route.d.ts +0 -25
- package/dist/features/threads/threads-delete.route.js +0 -35
- package/dist/features/threads/threads-files.route.d.ts +0 -15
- package/dist/features/threads/threads-files.route.js +0 -20
- package/dist/features/threads/threads-fix-comments.route.d.ts +0 -26
- package/dist/features/threads/threads-fix-comments.route.js +0 -45
- package/dist/features/threads/threads-get.route.d.ts +0 -30
- package/dist/features/threads/threads-get.route.js +0 -38
- package/dist/features/threads/threads-list.route.d.ts +0 -56
- package/dist/features/threads/threads-list.route.js +0 -58
- package/dist/features/threads/threads-messages.route.d.ts +0 -28
- package/dist/features/threads/threads-messages.route.js +0 -110
- package/dist/features/threads/threads-open.route.d.ts +0 -26
- package/dist/features/threads/threads-open.route.js +0 -62
- package/dist/features/threads/threads-select.route.d.ts +0 -25
- package/dist/features/threads/threads-select.route.js +0 -35
- package/dist/features/threads/threads-update.route.d.ts +0 -15
- package/dist/features/threads/threads-update.route.js +0 -30
- package/dist/features/threads/threads.database.d.ts +0 -68
- package/dist/features/threads/threads.database.js +0 -215
- package/dist/features/threads/threads.manager.d.ts +0 -204
- package/dist/features/threads/threads.manager.js +0 -505
- package/dist/features/threads/threads.routes.d.ts +0 -20
- package/dist/features/threads/threads.routes.js +0 -230
- package/dist/features/todos/todos.database.d.ts +0 -14
- package/dist/features/todos/todos.database.js +0 -31
- package/dist/features/updates/updates.routes.d.ts +0 -13
- package/dist/features/updates/updates.routes.js +0 -40
- package/dist/index.d.ts +0 -3
- package/dist/project-analyzer.d.ts +0 -26
- package/dist/project-analyzer.js +0 -307
- package/dist/server.d.ts +0 -12
- package/dist/server.js +0 -142
- package/dist/tools/agent-tool.d.ts +0 -49
- package/dist/tools/agent-tool.js +0 -131
- package/dist/tools/ask-user.d.ts +0 -25
- package/dist/tools/ask-user.js +0 -74
- package/dist/tools/ast-grep.d.ts +0 -28
- package/dist/tools/ast-grep.js +0 -273
- package/dist/tools/bash.d.ts +0 -33
- package/dist/tools/bash.js +0 -186
- package/dist/tools/edit-diff.d.ts +0 -24
- package/dist/tools/edit-diff.js +0 -136
- package/dist/tools/edit.d.ts +0 -28
- package/dist/tools/edit.js +0 -78
- package/dist/tools/find.d.ts +0 -31
- package/dist/tools/find.js +0 -117
- package/dist/tools/grep.d.ts +0 -37
- package/dist/tools/grep.js +0 -231
- package/dist/tools/index.d.ts +0 -93
- package/dist/tools/index.js +0 -110
- package/dist/tools/ls.d.ts +0 -31
- package/dist/tools/ls.js +0 -108
- package/dist/tools/mcp-tools.d.ts +0 -31
- package/dist/tools/mcp-tools.js +0 -59
- package/dist/tools/path-utils.d.ts +0 -14
- package/dist/tools/path-utils.js +0 -87
- package/dist/tools/read.d.ts +0 -27
- package/dist/tools/read.js +0 -86
- package/dist/tools/resolve-bin.d.ts +0 -5
- package/dist/tools/resolve-bin.js +0 -28
- package/dist/tools/shell.d.ts +0 -7
- package/dist/tools/shell.js +0 -143
- package/dist/tools/skill-reference-tool.d.ts +0 -30
- package/dist/tools/skill-reference-tool.js +0 -171
- package/dist/tools/skill-tool.d.ts +0 -33
- package/dist/tools/skill-tool.js +0 -213
- package/dist/tools/todo.d.ts +0 -20
- package/dist/tools/todo.js +0 -168
- package/dist/tools/tool-helpers.d.ts +0 -78
- package/dist/tools/tool-helpers.js +0 -109
- package/dist/tools/truncate.d.ts +0 -31
- package/dist/tools/truncate.js +0 -164
- package/dist/tools/write.d.ts +0 -21
- package/dist/tools/write.js +0 -65
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Model resolver for Pi Agent
|
|
3
|
-
* Handles provider mapping and model resolution for different AI providers
|
|
4
|
-
*/
|
|
5
|
-
import { getModel } from "@mariozechner/pi-ai";
|
|
6
|
-
/**
|
|
7
|
-
* Maps provider names to Pi AI known provider identifiers
|
|
8
|
-
*/
|
|
9
|
-
export const PROVIDER_NAME_TO_PI = {
|
|
10
|
-
anthropic: "anthropic",
|
|
11
|
-
openai: "openai",
|
|
12
|
-
google: "google",
|
|
13
|
-
groq: "groq",
|
|
14
|
-
cerebras: "cerebras",
|
|
15
|
-
xai: "xai",
|
|
16
|
-
openrouter: "openrouter",
|
|
17
|
-
"github copilot": "github-copilot",
|
|
18
|
-
minimax: "minimax",
|
|
19
|
-
"kimi coding plan": "kimi-coding",
|
|
20
|
-
"hugging face": "huggingface",
|
|
21
|
-
codex: "openai-codex",
|
|
22
|
-
mistral: "mistral",
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Determines the API type based on the provider's API URL
|
|
26
|
-
*/
|
|
27
|
-
export function determineApiType(apiUrl) {
|
|
28
|
-
if (apiUrl.includes("/anthropic/"))
|
|
29
|
-
return "anthropic-messages";
|
|
30
|
-
if (apiUrl.includes("api.anthropic.com"))
|
|
31
|
-
return "anthropic-messages";
|
|
32
|
-
return "openai-completions";
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Resolves a model configuration for the Pi Agent
|
|
36
|
-
* First attempts to use known providers from pi-ai registry,
|
|
37
|
-
* then falls back to creating a custom model configuration
|
|
38
|
-
*/
|
|
39
|
-
export function resolveModel(providerName, modelId, providerConfig) {
|
|
40
|
-
const piProvider = PROVIDER_NAME_TO_PI[providerName.toLowerCase()];
|
|
41
|
-
if (piProvider) {
|
|
42
|
-
try {
|
|
43
|
-
return getModel(piProvider, modelId);
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
// Model not in pi-ai registry — fall through to custom model
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
const baseUrl = providerConfig.api;
|
|
50
|
-
if (!baseUrl) {
|
|
51
|
-
throw new Error(`No API URL configured for provider: ${providerName}`);
|
|
52
|
-
}
|
|
53
|
-
const apiType = determineApiType(baseUrl);
|
|
54
|
-
return {
|
|
55
|
-
id: modelId,
|
|
56
|
-
name: modelId,
|
|
57
|
-
api: apiType,
|
|
58
|
-
provider: providerName.toLowerCase(),
|
|
59
|
-
baseUrl,
|
|
60
|
-
reasoning: false,
|
|
61
|
-
input: ["text"],
|
|
62
|
-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
63
|
-
contextWindow: 128000,
|
|
64
|
-
maxTokens: 16384,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=agent.model-resolver.js.map
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ProcessManager handles running and stopping dev server processes
|
|
3
|
-
*
|
|
4
|
-
* This manager is responsible for:
|
|
5
|
-
* - Starting dev server processes with output capture
|
|
6
|
-
* - Detecting URLs from process output
|
|
7
|
-
* - Stopping running processes
|
|
8
|
-
* - Streaming output back to the frontend
|
|
9
|
-
*/
|
|
10
|
-
import { EventEmitter } from "events";
|
|
11
|
-
export interface ProcessOutput {
|
|
12
|
-
type: "stdout" | "stderr" | "url" | "error" | "complete";
|
|
13
|
-
content?: string;
|
|
14
|
-
url?: string;
|
|
15
|
-
error?: unknown;
|
|
16
|
-
}
|
|
17
|
-
export declare class ProcessManager extends EventEmitter {
|
|
18
|
-
private processes;
|
|
19
|
-
private detectedUrls;
|
|
20
|
-
private queues;
|
|
21
|
-
private resolvers;
|
|
22
|
-
/**
|
|
23
|
-
* Run a command and stream its output
|
|
24
|
-
* @param projectId - The project ID (used as a key)
|
|
25
|
-
* @param command - The command to run (e.g., "npm run dev")
|
|
26
|
-
* @param cwd - Working directory to run the command in
|
|
27
|
-
* @param threadId - The thread ID to cache the URL for
|
|
28
|
-
* @returns AsyncGenerator that yields ProcessOutput events
|
|
29
|
-
*/
|
|
30
|
-
runProcess(projectId: string, command: string, cwd: string, threadId: string): AsyncGenerator<ProcessOutput>;
|
|
31
|
-
/**
|
|
32
|
-
* Stop a running process
|
|
33
|
-
* @param projectId - The project ID
|
|
34
|
-
* @param threadId - The thread ID to clear the URL from cache
|
|
35
|
-
* @returns true if process was stopped, false if no process was running
|
|
36
|
-
*/
|
|
37
|
-
stopProcess(projectId: string, threadId?: string): boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Check if a process is running for a project
|
|
40
|
-
* @param projectId - The project ID
|
|
41
|
-
* @returns true if a process is running
|
|
42
|
-
*/
|
|
43
|
-
isRunning(projectId: string): boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Get the detected URL for a running process
|
|
46
|
-
* @param projectId - The project ID
|
|
47
|
-
* @returns The URL if detected, undefined otherwise
|
|
48
|
-
*/
|
|
49
|
-
getDetectedUrl(projectId: string): string | undefined;
|
|
50
|
-
/**
|
|
51
|
-
* Detect URL from text output
|
|
52
|
-
* @param text - The text to search for URLs
|
|
53
|
-
* @returns The first detected URL or undefined
|
|
54
|
-
*/
|
|
55
|
-
private detectUrl;
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=agent.process-manager.d.ts.map
|
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ProcessManager handles running and stopping dev server processes
|
|
3
|
-
*
|
|
4
|
-
* This manager is responsible for:
|
|
5
|
-
* - Starting dev server processes with output capture
|
|
6
|
-
* - Detecting URLs from process output
|
|
7
|
-
* - Stopping running processes
|
|
8
|
-
* - Streaming output back to the frontend
|
|
9
|
-
*/
|
|
10
|
-
import { spawnProcess } from "../core/utils.js";
|
|
11
|
-
import { EventEmitter } from "events";
|
|
12
|
-
import { devServerCache } from "../core/dev-server-cache.js";
|
|
13
|
-
let Utils = null;
|
|
14
|
-
let utilsLoaded = false;
|
|
15
|
-
// Lazy load Utils from electrobun (optional - may not be available in pure server mode)
|
|
16
|
-
async function loadUtils() {
|
|
17
|
-
if (utilsLoaded)
|
|
18
|
-
return;
|
|
19
|
-
utilsLoaded = true;
|
|
20
|
-
try {
|
|
21
|
-
const electrobun = await import("electrobun/bun");
|
|
22
|
-
Utils = electrobun.Utils;
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
// electrobun not available in pure server mode - that's OK
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
// Common patterns for detecting dev server URLs in output
|
|
29
|
-
const URL_PATTERNS = [
|
|
30
|
-
// http(s)://localhost:PORT
|
|
31
|
-
/https?:\/\/localhost[:/](\d+)/i,
|
|
32
|
-
// localhost:PORT
|
|
33
|
-
/localhost:(\d+)/i,
|
|
34
|
-
// 127.0.0.1:PORT
|
|
35
|
-
/127\.0\.0\.1:(\d+)/i,
|
|
36
|
-
// http://0.0.0.0:PORT or http://[::]:PORT (for IPv6)
|
|
37
|
-
/https?:\/\/(0\.0\.0\.0|\[::?\]):(\d+)/i,
|
|
38
|
-
// Local address patterns like http://192.168...
|
|
39
|
-
/https?:\/\/(192\.168\.\d+\.\d+):(\d+)/i,
|
|
40
|
-
];
|
|
41
|
-
export class ProcessManager extends EventEmitter {
|
|
42
|
-
processes = new Map();
|
|
43
|
-
detectedUrls = new Map();
|
|
44
|
-
queues = new Map();
|
|
45
|
-
resolvers = new Map();
|
|
46
|
-
/**
|
|
47
|
-
* Run a command and stream its output
|
|
48
|
-
* @param projectId - The project ID (used as a key)
|
|
49
|
-
* @param command - The command to run (e.g., "npm run dev")
|
|
50
|
-
* @param cwd - Working directory to run the command in
|
|
51
|
-
* @param threadId - The thread ID to cache the URL for
|
|
52
|
-
* @returns AsyncGenerator that yields ProcessOutput events
|
|
53
|
-
*/
|
|
54
|
-
async *runProcess(projectId, command, cwd, threadId) {
|
|
55
|
-
console.log("CLI ProcessManager: runProcess called for project:", projectId, "thread:", threadId, "command:", command, "cwd:", cwd);
|
|
56
|
-
// Load utils (may fail gracefully if electrobun not available)
|
|
57
|
-
await loadUtils();
|
|
58
|
-
// Check if a process is already running for this project
|
|
59
|
-
if (this.processes.has(projectId)) {
|
|
60
|
-
console.log("CLI ProcessManager: Process already running for project:", projectId);
|
|
61
|
-
yield {
|
|
62
|
-
type: "error",
|
|
63
|
-
error: new Error("A process is already running for this project"),
|
|
64
|
-
};
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
console.log("CLI ProcessManager: Starting new process for project:", projectId);
|
|
68
|
-
// Initialize queue for this process
|
|
69
|
-
this.queues.set(projectId, []);
|
|
70
|
-
this.resolvers.set(projectId, []);
|
|
71
|
-
const addToQueue = (output) => {
|
|
72
|
-
const queue = this.queues.get(projectId);
|
|
73
|
-
if (queue) {
|
|
74
|
-
queue.push(output);
|
|
75
|
-
// Call any pending resolvers
|
|
76
|
-
const res = this.resolvers.get(projectId);
|
|
77
|
-
if (res && res.length > 0) {
|
|
78
|
-
const resolver = res.shift();
|
|
79
|
-
if (resolver)
|
|
80
|
-
resolver();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
const waitForQueue = () => {
|
|
85
|
-
return new Promise((resolve) => {
|
|
86
|
-
const queue = this.queues.get(projectId);
|
|
87
|
-
if (queue && queue.length > 0) {
|
|
88
|
-
resolve();
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
const res = this.resolvers.get(projectId);
|
|
92
|
-
if (res)
|
|
93
|
-
res.push(resolve);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
try {
|
|
98
|
-
const [cmd, ...args] = command.split(" ");
|
|
99
|
-
console.log("CLI ProcessManager: Spawning process:", cmd, "with args:", args);
|
|
100
|
-
const childProcess = spawnProcess(cmd, args, {
|
|
101
|
-
cwd,
|
|
102
|
-
shell: true,
|
|
103
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
104
|
-
});
|
|
105
|
-
this.processes.set(projectId, childProcess);
|
|
106
|
-
console.log("CLI ProcessManager: Process spawned with PID:", childProcess.pid);
|
|
107
|
-
let urlDetected = false;
|
|
108
|
-
let urlBuffer = "";
|
|
109
|
-
// Handle stdout - add to queue immediately
|
|
110
|
-
childProcess.stdout?.on("data", (data) => {
|
|
111
|
-
const text = data.toString();
|
|
112
|
-
urlBuffer += text;
|
|
113
|
-
// Try to detect URL
|
|
114
|
-
if (!urlDetected) {
|
|
115
|
-
const detectedUrl = this.detectUrl(urlBuffer);
|
|
116
|
-
if (detectedUrl) {
|
|
117
|
-
urlDetected = true;
|
|
118
|
-
this.detectedUrls.set(projectId, detectedUrl);
|
|
119
|
-
// Store URL in the thread-based cache
|
|
120
|
-
devServerCache.setUrl(threadId, detectedUrl);
|
|
121
|
-
// Open the URL in the system's default browser (only in desktop mode with electrobun)
|
|
122
|
-
if (Utils) {
|
|
123
|
-
Utils.openExternal(detectedUrl);
|
|
124
|
-
}
|
|
125
|
-
addToQueue({ type: "url", url: detectedUrl });
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
addToQueue({ type: "stdout", content: text });
|
|
129
|
-
});
|
|
130
|
-
// Handle stderr - add to queue immediately
|
|
131
|
-
childProcess.stderr?.on("data", (data) => {
|
|
132
|
-
const text = data.toString();
|
|
133
|
-
urlBuffer += text;
|
|
134
|
-
// Try to detect URL in stderr as well
|
|
135
|
-
if (!urlDetected) {
|
|
136
|
-
const detectedUrl = this.detectUrl(urlBuffer);
|
|
137
|
-
if (detectedUrl) {
|
|
138
|
-
urlDetected = true;
|
|
139
|
-
this.detectedUrls.set(projectId, detectedUrl);
|
|
140
|
-
// Store URL in the thread-based cache
|
|
141
|
-
devServerCache.setUrl(threadId, detectedUrl);
|
|
142
|
-
// Open the URL in the system's default browser (only in desktop mode with electrobun)
|
|
143
|
-
if (Utils) {
|
|
144
|
-
Utils.openExternal(detectedUrl);
|
|
145
|
-
}
|
|
146
|
-
addToQueue({ type: "url", url: detectedUrl });
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
addToQueue({ type: "stderr", content: text });
|
|
150
|
-
});
|
|
151
|
-
// Handle process end
|
|
152
|
-
let processEnded = false;
|
|
153
|
-
childProcess.on("close", () => {
|
|
154
|
-
processEnded = true;
|
|
155
|
-
this.processes.delete(projectId);
|
|
156
|
-
addToQueue({ type: "complete" });
|
|
157
|
-
// Call any pending resolvers to flush the queue
|
|
158
|
-
const res = this.resolvers.get(projectId);
|
|
159
|
-
if (res) {
|
|
160
|
-
res.forEach((r) => r());
|
|
161
|
-
res.length = 0;
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
childProcess.on("error", (err) => {
|
|
165
|
-
processEnded = true;
|
|
166
|
-
this.processes.delete(projectId);
|
|
167
|
-
addToQueue({ type: "error", error: err });
|
|
168
|
-
// Call any pending resolvers to flush the queue
|
|
169
|
-
const res = this.resolvers.get(projectId);
|
|
170
|
-
if (res) {
|
|
171
|
-
res.forEach((r) => r());
|
|
172
|
-
res.length = 0;
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
// Yield items from the queue
|
|
176
|
-
while (true) {
|
|
177
|
-
const queue = this.queues.get(projectId);
|
|
178
|
-
if (queue && queue.length > 0) {
|
|
179
|
-
const output = queue.shift();
|
|
180
|
-
if (output) {
|
|
181
|
-
yield output;
|
|
182
|
-
if (output.type === "complete" || output.type === "error") {
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
else if (processEnded) {
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
// Wait for more data
|
|
192
|
-
await waitForQueue();
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
catch (error) {
|
|
197
|
-
this.processes.delete(projectId);
|
|
198
|
-
this.detectedUrls.delete(projectId);
|
|
199
|
-
yield { type: "error", error };
|
|
200
|
-
}
|
|
201
|
-
finally {
|
|
202
|
-
// Cleanup
|
|
203
|
-
this.queues.delete(projectId);
|
|
204
|
-
this.resolvers.delete(projectId);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Stop a running process
|
|
209
|
-
* @param projectId - The project ID
|
|
210
|
-
* @param threadId - The thread ID to clear the URL from cache
|
|
211
|
-
* @returns true if process was stopped, false if no process was running
|
|
212
|
-
*/
|
|
213
|
-
stopProcess(projectId, threadId) {
|
|
214
|
-
const process = this.processes.get(projectId);
|
|
215
|
-
if (!process) {
|
|
216
|
-
return false;
|
|
217
|
-
}
|
|
218
|
-
process.kill();
|
|
219
|
-
this.processes.delete(projectId);
|
|
220
|
-
this.detectedUrls.delete(projectId);
|
|
221
|
-
// Clear URL from thread-based cache if threadId is provided
|
|
222
|
-
if (threadId) {
|
|
223
|
-
devServerCache.clearUrl(threadId);
|
|
224
|
-
}
|
|
225
|
-
return true;
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Check if a process is running for a project
|
|
229
|
-
* @param projectId - The project ID
|
|
230
|
-
* @returns true if a process is running
|
|
231
|
-
*/
|
|
232
|
-
isRunning(projectId) {
|
|
233
|
-
return this.processes.has(projectId);
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Get the detected URL for a running process
|
|
237
|
-
* @param projectId - The project ID
|
|
238
|
-
* @returns The URL if detected, undefined otherwise
|
|
239
|
-
*/
|
|
240
|
-
getDetectedUrl(projectId) {
|
|
241
|
-
return this.detectedUrls.get(projectId);
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Detect URL from text output
|
|
245
|
-
* @param text - The text to search for URLs
|
|
246
|
-
* @returns The first detected URL or undefined
|
|
247
|
-
*/
|
|
248
|
-
detectUrl(text) {
|
|
249
|
-
for (const pattern of URL_PATTERNS) {
|
|
250
|
-
const match = text.match(pattern);
|
|
251
|
-
if (match) {
|
|
252
|
-
// For simple localhost patterns, construct the full URL
|
|
253
|
-
if (match[1] && !match[0].includes("://")) {
|
|
254
|
-
return `http://localhost:${match[1]}`;
|
|
255
|
-
}
|
|
256
|
-
return match[0];
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
return undefined;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
//# sourceMappingURL=agent.process-manager.js.map
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ProcessingStateManager tracks which threads currently have active chat processing
|
|
3
|
-
*
|
|
4
|
-
* This is an in-memory store that tracks thread IDs that are currently
|
|
5
|
-
* processing chat messages. The frontend can poll this to show/hide spinners.
|
|
6
|
-
* It also buffers streaming events so late subscribers can replay them.
|
|
7
|
-
*/
|
|
8
|
-
import type { AgentEvent } from "@tarsk/shared";
|
|
9
|
-
export type StreamSubscriber = (event: AgentEvent) => void;
|
|
10
|
-
export interface ProcessingStateManager {
|
|
11
|
-
/**
|
|
12
|
-
* Mark a thread as currently processing
|
|
13
|
-
* @param threadId - The thread ID that started processing
|
|
14
|
-
*/
|
|
15
|
-
setProcessing(threadId: string): void;
|
|
16
|
-
/**
|
|
17
|
-
* Mark a thread as no longer processing
|
|
18
|
-
* @param threadId - The thread ID that finished processing
|
|
19
|
-
*/
|
|
20
|
-
clearProcessing(threadId: string): void;
|
|
21
|
-
/**
|
|
22
|
-
* Check if a thread is currently processing
|
|
23
|
-
* @param threadId - The thread ID to check
|
|
24
|
-
* @returns true if the thread is processing
|
|
25
|
-
*/
|
|
26
|
-
isProcessing(threadId: string): boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Get all thread IDs that are currently processing
|
|
29
|
-
* @returns Array of thread IDs
|
|
30
|
-
*/
|
|
31
|
-
getProcessingThreadIds(): string[];
|
|
32
|
-
/**
|
|
33
|
-
* Push a streaming event for a thread (buffered for late subscribers)
|
|
34
|
-
*/
|
|
35
|
-
pushEvent(threadId: string, event: AgentEvent): void;
|
|
36
|
-
/**
|
|
37
|
-
* Subscribe to a thread's stream. Replays buffered events immediately,
|
|
38
|
-
* then delivers new events as they arrive. Returns an unsubscribe function.
|
|
39
|
-
*/
|
|
40
|
-
subscribe(threadId: string, subscriber: StreamSubscriber): () => void;
|
|
41
|
-
/**
|
|
42
|
-
* Get buffered events for a thread
|
|
43
|
-
*/
|
|
44
|
-
getBufferedEvents(threadId: string): AgentEvent[];
|
|
45
|
-
/**
|
|
46
|
-
* Register the AbortController for a thread's active execution so it can
|
|
47
|
-
* be cancelled via the stop endpoint regardless of connection state.
|
|
48
|
-
*/
|
|
49
|
-
registerAbortController(threadId: string, controller: AbortController): void;
|
|
50
|
-
/**
|
|
51
|
-
* Abort the active execution for a thread.
|
|
52
|
-
* @returns true if an active controller was found and aborted
|
|
53
|
-
*/
|
|
54
|
-
abortThread(threadId: string): boolean;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Implementation of ProcessingStateManager using an in-memory Set
|
|
58
|
-
*/
|
|
59
|
-
export declare class ProcessingStateManagerImpl implements ProcessingStateManager {
|
|
60
|
-
private processingThreads;
|
|
61
|
-
private eventBuffers;
|
|
62
|
-
private subscribers;
|
|
63
|
-
private abortControllers;
|
|
64
|
-
setProcessing(threadId: string): void;
|
|
65
|
-
registerAbortController(threadId: string, controller: AbortController): void;
|
|
66
|
-
abortThread(threadId: string): boolean;
|
|
67
|
-
clearProcessing(threadId: string): void;
|
|
68
|
-
isProcessing(threadId: string): boolean;
|
|
69
|
-
getProcessingThreadIds(): string[];
|
|
70
|
-
pushEvent(threadId: string, event: AgentEvent): void;
|
|
71
|
-
subscribe(threadId: string, subscriber: StreamSubscriber): () => void;
|
|
72
|
-
getBufferedEvents(threadId: string): AgentEvent[];
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=agent.processing-state-manager.d.ts.map
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ProcessingStateManager tracks which threads currently have active chat processing
|
|
3
|
-
*
|
|
4
|
-
* This is an in-memory store that tracks thread IDs that are currently
|
|
5
|
-
* processing chat messages. The frontend can poll this to show/hide spinners.
|
|
6
|
-
* It also buffers streaming events so late subscribers can replay them.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Implementation of ProcessingStateManager using an in-memory Set
|
|
10
|
-
*/
|
|
11
|
-
export class ProcessingStateManagerImpl {
|
|
12
|
-
processingThreads = new Set();
|
|
13
|
-
eventBuffers = new Map();
|
|
14
|
-
subscribers = new Map();
|
|
15
|
-
abortControllers = new Map();
|
|
16
|
-
setProcessing(threadId) {
|
|
17
|
-
this.processingThreads.add(threadId);
|
|
18
|
-
this.eventBuffers.set(threadId, []);
|
|
19
|
-
console.log(`[ProcessingState] Thread ${threadId} started processing. Active: ${this.processingThreads.size}`);
|
|
20
|
-
}
|
|
21
|
-
registerAbortController(threadId, controller) {
|
|
22
|
-
this.abortControllers.set(threadId, controller);
|
|
23
|
-
}
|
|
24
|
-
abortThread(threadId) {
|
|
25
|
-
const controller = this.abortControllers.get(threadId);
|
|
26
|
-
if (!controller)
|
|
27
|
-
return false;
|
|
28
|
-
console.log(`[ProcessingState] Aborting thread ${threadId} via stop endpoint`);
|
|
29
|
-
controller.abort();
|
|
30
|
-
this.abortControllers.delete(threadId);
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
clearProcessing(threadId) {
|
|
34
|
-
this.abortControllers.delete(threadId);
|
|
35
|
-
this.processingThreads.delete(threadId);
|
|
36
|
-
// Notify subscribers that stream is complete, then clean up
|
|
37
|
-
const subs = this.subscribers.get(threadId);
|
|
38
|
-
if (subs) {
|
|
39
|
-
for (const sub of subs) {
|
|
40
|
-
sub({ type: "complete", content: "" });
|
|
41
|
-
}
|
|
42
|
-
this.subscribers.delete(threadId);
|
|
43
|
-
}
|
|
44
|
-
// Keep the buffer briefly for any final subscribers, then clean up
|
|
45
|
-
setTimeout(() => {
|
|
46
|
-
this.eventBuffers.delete(threadId);
|
|
47
|
-
}, 5000);
|
|
48
|
-
console.log(`[ProcessingState] Thread ${threadId} finished processing. Active: ${this.processingThreads.size}`);
|
|
49
|
-
}
|
|
50
|
-
isProcessing(threadId) {
|
|
51
|
-
return this.processingThreads.has(threadId);
|
|
52
|
-
}
|
|
53
|
-
getProcessingThreadIds() {
|
|
54
|
-
return Array.from(this.processingThreads);
|
|
55
|
-
}
|
|
56
|
-
pushEvent(threadId, event) {
|
|
57
|
-
const buffer = this.eventBuffers.get(threadId);
|
|
58
|
-
if (buffer) {
|
|
59
|
-
buffer.push(event);
|
|
60
|
-
}
|
|
61
|
-
const subs = this.subscribers.get(threadId);
|
|
62
|
-
if (subs) {
|
|
63
|
-
for (const sub of subs) {
|
|
64
|
-
sub(event);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
subscribe(threadId, subscriber) {
|
|
69
|
-
if (!this.subscribers.has(threadId)) {
|
|
70
|
-
this.subscribers.set(threadId, new Set());
|
|
71
|
-
}
|
|
72
|
-
this.subscribers.get(threadId).add(subscriber);
|
|
73
|
-
return () => {
|
|
74
|
-
const subs = this.subscribers.get(threadId);
|
|
75
|
-
if (subs) {
|
|
76
|
-
subs.delete(subscriber);
|
|
77
|
-
if (subs.size === 0) {
|
|
78
|
-
this.subscribers.delete(threadId);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
getBufferedEvents(threadId) {
|
|
84
|
-
return this.eventBuffers.get(threadId) ?? [];
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
//# sourceMappingURL=agent.processing-state-manager.js.map
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* System prompt loader for Pi Agent
|
|
3
|
-
* Loads agent system prompt from agents.md file with fallback
|
|
4
|
-
*/
|
|
5
|
-
import type { Skill, AgentDefinition } from "@tarsk/shared";
|
|
6
|
-
/**
|
|
7
|
-
* Load agent system prompt from agents.md file
|
|
8
|
-
* System prompt is the DEFAULT_PROMPT, agents.md is appended as developer context
|
|
9
|
-
*
|
|
10
|
-
* @param threadPath - Path to the thread directory (required)
|
|
11
|
-
* @param skills - Optional array of activated skills to inject into the prompt
|
|
12
|
-
* @param planMode - Optional flag to enable plan mode instructions
|
|
13
|
-
* @param agents - Optional array of available agent definitions to inject into the prompt
|
|
14
|
-
*/
|
|
15
|
-
export declare function loadAgentSystemPrompt(threadPath: string, skills?: Skill[], planMode?: boolean, agents?: AgentDefinition[]): Promise<string>;
|
|
16
|
-
//# sourceMappingURL=agent.prompt-loader.d.ts.map
|