@renxqoo/renx-code 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -40
- package/bin/renx.cjs +79 -42
- package/bin/renx.exe +0 -0
- package/package.json +10 -28
- package/src/App.tsx +0 -297
- package/src/agent/runtime/event-format.ts +0 -258
- package/src/agent/runtime/model-types.ts +0 -13
- package/src/agent/runtime/runtime.context-usage.test.ts +0 -192
- package/src/agent/runtime/runtime.error-handling.test.ts +0 -235
- package/src/agent/runtime/runtime.simple.test.ts +0 -16
- package/src/agent/runtime/runtime.test.ts +0 -296
- package/src/agent/runtime/runtime.ts +0 -875
- package/src/agent/runtime/runtime.usage-forwarding.test.ts +0 -228
- package/src/agent/runtime/source-modules.test.ts +0 -38
- package/src/agent/runtime/source-modules.ts +0 -370
- package/src/agent/runtime/tool-call-buffer.test.ts +0 -65
- package/src/agent/runtime/tool-call-buffer.ts +0 -60
- package/src/agent/runtime/tool-confirmation.test.ts +0 -56
- package/src/agent/runtime/tool-confirmation.ts +0 -15
- package/src/agent/runtime/types.ts +0 -99
- package/src/commands/slash-commands.test.ts +0 -216
- package/src/commands/slash-commands.ts +0 -64
- package/src/components/chat/assistant-reply.test.tsx +0 -47
- package/src/components/chat/assistant-reply.tsx +0 -136
- package/src/components/chat/assistant-segment.test.ts +0 -99
- package/src/components/chat/assistant-segment.tsx +0 -125
- package/src/components/chat/assistant-tool-group.tsx +0 -900
- package/src/components/chat/code-block.test.tsx +0 -206
- package/src/components/chat/code-block.tsx +0 -313
- package/src/components/chat/prompt-card.tsx +0 -81
- package/src/components/chat/segment-groups.test.ts +0 -52
- package/src/components/chat/segment-groups.ts +0 -106
- package/src/components/chat/turn-item.tsx +0 -39
- package/src/components/conversation-panel.tsx +0 -43
- package/src/components/file-mention-menu.tsx +0 -77
- package/src/components/file-picker-dialog.tsx +0 -206
- package/src/components/footer-hints.tsx +0 -75
- package/src/components/model-picker-dialog.tsx +0 -248
- package/src/components/prompt.tsx +0 -233
- package/src/components/slash-command-menu.tsx +0 -65
- package/src/components/tool-confirm-dialog-content.test.ts +0 -103
- package/src/components/tool-confirm-dialog-content.ts +0 -186
- package/src/components/tool-confirm-dialog.tsx +0 -187
- package/src/components/tool-display-config.ts +0 -119
- package/src/context-usage-regressions.test.ts +0 -26
- package/src/files/attachment-capabilities.test.ts +0 -30
- package/src/files/attachment-capabilities.ts +0 -50
- package/src/files/attachment-content.ts +0 -153
- package/src/files/file-mention-query.test.ts +0 -34
- package/src/files/file-mention-query.ts +0 -32
- package/src/files/prompt-display.ts +0 -13
- package/src/files/types.ts +0 -5
- package/src/files/workspace-files.ts +0 -61
- package/src/hooks/agent-event-handlers.test.ts +0 -207
- package/src/hooks/agent-event-handlers.ts +0 -196
- package/src/hooks/chat-local-replies.fixed.test.ts +0 -119
- package/src/hooks/chat-local-replies.test.ts +0 -153
- package/src/hooks/chat-local-replies.ts +0 -63
- package/src/hooks/turn-updater.test.ts +0 -70
- package/src/hooks/turn-updater.ts +0 -166
- package/src/hooks/use-agent-chat.context.test.ts +0 -10
- package/src/hooks/use-agent-chat.status.test.ts +0 -14
- package/src/hooks/use-agent-chat.test.ts +0 -80
- package/src/hooks/use-agent-chat.ts +0 -621
- package/src/hooks/use-file-mention-menu.ts +0 -196
- package/src/hooks/use-file-picker.ts +0 -185
- package/src/hooks/use-model-picker.ts +0 -196
- package/src/hooks/use-slash-command-menu.ts +0 -154
- package/src/index.tsx +0 -55
- package/src/runtime/clipboard.test.ts +0 -43
- package/src/runtime/clipboard.ts +0 -89
- package/src/runtime/exit.test.ts +0 -177
- package/src/runtime/exit.ts +0 -98
- package/src/runtime/runtime-support.test.ts +0 -31
- package/src/runtime/terminal-theme.test.ts +0 -55
- package/src/runtime/terminal-theme.ts +0 -196
- package/src/types/chat.ts +0 -32
- package/src/types/message-content.ts +0 -48
- package/src/ui/open-code-theme.ts +0 -176
- package/src/ui/opencode-markdown.ts +0 -211
- package/src/ui/theme.simple.test.ts +0 -52
- package/src/ui/theme.test.ts +0 -151
- package/src/ui/theme.ts +0 -152
- package/src/utils/time.test.ts +0 -144
- package/src/utils/time.ts +0 -7
- package/tsconfig.json +0 -30
- package/vendor/agent-root/src/agent/ENTERPRISE_ACCEPTANCE_CHECKLIST.md +0 -95
- package/vendor/agent-root/src/agent/ENTERPRISE_REALTIME.html +0 -1345
- package/vendor/agent-root/src/agent/ENTERPRISE_REALTIME.md +0 -1353
- package/vendor/agent-root/src/agent/ERROR_CONTRACT.md +0 -60
- package/vendor/agent-root/src/agent/TEST_COVERAGE_ANALYSIS.md +0 -278
- package/vendor/agent-root/src/agent/__test__/error-contract.test.ts +0 -72
- package/vendor/agent-root/src/agent/__test__/types.test.ts +0 -137
- package/vendor/agent-root/src/agent/agent/__test__/abort-runtime.test.ts +0 -83
- package/vendor/agent-root/src/agent/agent/__test__/callback-safety.test.ts +0 -34
- package/vendor/agent-root/src/agent/agent/__test__/compaction.test.ts +0 -323
- package/vendor/agent-root/src/agent/agent/__test__/concurrency.test.ts +0 -290
- package/vendor/agent-root/src/agent/agent/__test__/error-normalizer.test.ts +0 -377
- package/vendor/agent-root/src/agent/agent/__test__/error.test.ts +0 -212
- package/vendor/agent-root/src/agent/agent/__test__/fault-injection.test.ts +0 -295
- package/vendor/agent-root/src/agent/agent/__test__/index.test.ts +0 -3607
- package/vendor/agent-root/src/agent/agent/__test__/logger.test.ts +0 -35
- package/vendor/agent-root/src/agent/agent/__test__/message-utils.test.ts +0 -517
- package/vendor/agent-root/src/agent/agent/__test__/telemetry.test.ts +0 -97
- package/vendor/agent-root/src/agent/agent/__test__/timeout-budget.test.ts +0 -479
- package/vendor/agent-root/src/agent/agent/__test__/tool-call-merge.test.ts +0 -80
- package/vendor/agent-root/src/agent/agent/__test__/tool-execution-ledger.test.ts +0 -76
- package/vendor/agent-root/src/agent/agent/__test__/write-buffer.test.ts +0 -173
- package/vendor/agent-root/src/agent/agent/__test__/write-file-session.test.ts +0 -109
- package/vendor/agent-root/src/agent/agent/abort-runtime.ts +0 -71
- package/vendor/agent-root/src/agent/agent/callback-safety.ts +0 -33
- package/vendor/agent-root/src/agent/agent/compaction.ts +0 -291
- package/vendor/agent-root/src/agent/agent/concurrency.ts +0 -103
- package/vendor/agent-root/src/agent/agent/error-normalizer.ts +0 -190
- package/vendor/agent-root/src/agent/agent/error.ts +0 -198
- package/vendor/agent-root/src/agent/agent/index.ts +0 -1772
- package/vendor/agent-root/src/agent/agent/logger.ts +0 -65
- package/vendor/agent-root/src/agent/agent/message-utils.ts +0 -101
- package/vendor/agent-root/src/agent/agent/stream-events.ts +0 -61
- package/vendor/agent-root/src/agent/agent/telemetry.ts +0 -123
- package/vendor/agent-root/src/agent/agent/timeout-budget.ts +0 -227
- package/vendor/agent-root/src/agent/agent/tool-call-merge.ts +0 -111
- package/vendor/agent-root/src/agent/agent/tool-execution-ledger.ts +0 -164
- package/vendor/agent-root/src/agent/agent/write-buffer.ts +0 -188
- package/vendor/agent-root/src/agent/agent/write-file-session.ts +0 -238
- package/vendor/agent-root/src/agent/app/__test__/agent-app-service.test.ts +0 -1053
- package/vendor/agent-root/src/agent/app/__test__/minimal-agent-application.test.ts +0 -158
- package/vendor/agent-root/src/agent/app/__test__/sqlite-agent-app-store.test.ts +0 -437
- package/vendor/agent-root/src/agent/app/agent-app-service.ts +0 -748
- package/vendor/agent-root/src/agent/app/contracts.ts +0 -109
- package/vendor/agent-root/src/agent/app/index.ts +0 -5
- package/vendor/agent-root/src/agent/app/minimal-agent-application.ts +0 -151
- package/vendor/agent-root/src/agent/app/ports.ts +0 -72
- package/vendor/agent-root/src/agent/app/sqlite-agent-app-store.ts +0 -1182
- package/vendor/agent-root/src/agent/app/sqlite-client.ts +0 -177
- package/vendor/agent-root/src/agent/docs/cli-app-layer/00-README.md +0 -36
- package/vendor/agent-root/src/agent/docs/cli-app-layer/01-scope-and-goals.md +0 -33
- package/vendor/agent-root/src/agent/docs/cli-app-layer/02-architecture-overview.md +0 -40
- package/vendor/agent-root/src/agent/docs/cli-app-layer/03-domain-model-and-contracts.md +0 -91
- package/vendor/agent-root/src/agent/docs/cli-app-layer/04-ports-and-interfaces.md +0 -116
- package/vendor/agent-root/src/agent/docs/cli-app-layer/05-run-orchestration-and-state-machine.md +0 -52
- package/vendor/agent-root/src/agent/docs/cli-app-layer/06-cli-commands-and-ux.md +0 -53
- package/vendor/agent-root/src/agent/docs/cli-app-layer/07-storage-design-local.md +0 -52
- package/vendor/agent-root/src/agent/docs/cli-app-layer/08-error-and-observability.md +0 -40
- package/vendor/agent-root/src/agent/docs/cli-app-layer/09-security-and-policy-boundary.md +0 -19
- package/vendor/agent-root/src/agent/docs/cli-app-layer/10-test-plan-and-acceptance.md +0 -28
- package/vendor/agent-root/src/agent/docs/cli-app-layer/11-implementation-phases.md +0 -26
- package/vendor/agent-root/src/agent/docs/cli-app-layer/12-open-questions-and-risks.md +0 -30
- package/vendor/agent-root/src/agent/docs/cli-app-layer/13-sqlite-schema-fields-and-rationale.md +0 -567
- package/vendor/agent-root/src/agent/docs/cli-app-layer/14-project-flow-mermaid.md +0 -583
- package/vendor/agent-root/src/agent/docs/cli-app-layer/15-openclaw-style-project-blueprint.md +0 -972
- package/vendor/agent-root/src/agent/error-contract.ts +0 -154
- package/vendor/agent-root/src/agent/prompts/system.ts +0 -246
- package/vendor/agent-root/src/agent/prompts/system1.ts +0 -208
- package/vendor/agent-root/src/agent/storage/__test__/file-history-store.test.ts +0 -98
- package/vendor/agent-root/src/agent/storage/file-history-store.ts +0 -313
- package/vendor/agent-root/src/agent/storage/file-storage-config.ts +0 -94
- package/vendor/agent-root/src/agent/storage/file-system.ts +0 -31
- package/vendor/agent-root/src/agent/storage/file-write-service.ts +0 -21
- package/vendor/agent-root/src/agent/tool/__test__/base-tool.test.ts +0 -413
- package/vendor/agent-root/src/agent/tool/__test__/bash-policy.test.ts +0 -356
- package/vendor/agent-root/src/agent/tool/__test__/bash.mocked-coverage.test.ts +0 -375
- package/vendor/agent-root/src/agent/tool/__test__/bash.test.ts +0 -372
- package/vendor/agent-root/src/agent/tool/__test__/error.test.ts +0 -108
- package/vendor/agent-root/src/agent/tool/__test__/file-edit-tool.test.ts +0 -258
- package/vendor/agent-root/src/agent/tool/__test__/file-history-tools.test.ts +0 -121
- package/vendor/agent-root/src/agent/tool/__test__/file-read-tool.test.ts +0 -210
- package/vendor/agent-root/src/agent/tool/__test__/glob.test.ts +0 -139
- package/vendor/agent-root/src/agent/tool/__test__/grep.mocked-coverage.test.ts +0 -456
- package/vendor/agent-root/src/agent/tool/__test__/grep.test.ts +0 -192
- package/vendor/agent-root/src/agent/tool/__test__/lsp.test.ts +0 -300
- package/vendor/agent-root/src/agent/tool/__test__/outside-workspace-confirmation.test.ts +0 -214
- package/vendor/agent-root/src/agent/tool/__test__/path-security.test.ts +0 -336
- package/vendor/agent-root/src/agent/tool/__test__/skill-loader.test.ts +0 -494
- package/vendor/agent-root/src/agent/tool/__test__/skill-parser.test.ts +0 -543
- package/vendor/agent-root/src/agent/tool/__test__/skill-tool.test.ts +0 -172
- package/vendor/agent-root/src/agent/tool/__test__/task-concurrency-and-version.test.ts +0 -116
- package/vendor/agent-root/src/agent/tool/__test__/task-create-get-list-update.test.ts +0 -267
- package/vendor/agent-root/src/agent/tool/__test__/task-create.test.ts +0 -519
- package/vendor/agent-root/src/agent/tool/__test__/task-errors.test.ts +0 -225
- package/vendor/agent-root/src/agent/tool/__test__/task-output-blocking.test.ts +0 -223
- package/vendor/agent-root/src/agent/tool/__test__/task-output.test.ts +0 -184
- package/vendor/agent-root/src/agent/tool/__test__/task-parent-abort.test.ts +0 -287
- package/vendor/agent-root/src/agent/tool/__test__/task-real-runner-adapter.test.ts +0 -190
- package/vendor/agent-root/src/agent/tool/__test__/task-run-lifecycle.test.ts +0 -352
- package/vendor/agent-root/src/agent/tool/__test__/task-store-runner-branches.test.ts +0 -395
- package/vendor/agent-root/src/agent/tool/__test__/task-store.test.ts +0 -391
- package/vendor/agent-root/src/agent/tool/__test__/task-subagent-config-integration.test.ts +0 -176
- package/vendor/agent-root/src/agent/tool/__test__/task-subagent-config.test.ts +0 -68
- package/vendor/agent-root/src/agent/tool/__test__/task-tools-core-edges.test.ts +0 -630
- package/vendor/agent-root/src/agent/tool/__test__/task-tools-runtime-edges.test.ts +0 -732
- package/vendor/agent-root/src/agent/tool/__test__/task-types.test.ts +0 -494
- package/vendor/agent-root/src/agent/tool/__test__/task-utils-branches.test.ts +0 -175
- package/vendor/agent-root/src/agent/tool/__test__/tool-manager.test.ts +0 -505
- package/vendor/agent-root/src/agent/tool/__test__/types.test.ts +0 -55
- package/vendor/agent-root/src/agent/tool/__test__/web-fetch.test.ts +0 -244
- package/vendor/agent-root/src/agent/tool/__test__/web-search.test.ts +0 -290
- package/vendor/agent-root/src/agent/tool/__test__/write-file.test.ts +0 -368
- package/vendor/agent-root/src/agent/tool/base-tool.ts +0 -345
- package/vendor/agent-root/src/agent/tool/bash-policy.ts +0 -636
- package/vendor/agent-root/src/agent/tool/bash.ts +0 -688
- package/vendor/agent-root/src/agent/tool/error.ts +0 -131
- package/vendor/agent-root/src/agent/tool/file-edit-tool.ts +0 -264
- package/vendor/agent-root/src/agent/tool/file-history-list.ts +0 -103
- package/vendor/agent-root/src/agent/tool/file-history-restore.ts +0 -149
- package/vendor/agent-root/src/agent/tool/file-read-tool.ts +0 -211
- package/vendor/agent-root/src/agent/tool/glob.ts +0 -171
- package/vendor/agent-root/src/agent/tool/grep.ts +0 -496
- package/vendor/agent-root/src/agent/tool/lsp.ts +0 -481
- package/vendor/agent-root/src/agent/tool/path-security.ts +0 -117
- package/vendor/agent-root/src/agent/tool/search/common.ts +0 -153
- package/vendor/agent-root/src/agent/tool/skill/index.ts +0 -13
- package/vendor/agent-root/src/agent/tool/skill/loader.ts +0 -229
- package/vendor/agent-root/src/agent/tool/skill/parser.ts +0 -124
- package/vendor/agent-root/src/agent/tool/skill/types.ts +0 -27
- package/vendor/agent-root/src/agent/tool/skill-tool.ts +0 -143
- package/vendor/agent-root/src/agent/tool/task-create.ts +0 -186
- package/vendor/agent-root/src/agent/tool/task-errors.ts +0 -42
- package/vendor/agent-root/src/agent/tool/task-get.ts +0 -116
- package/vendor/agent-root/src/agent/tool/task-graph.ts +0 -78
- package/vendor/agent-root/src/agent/tool/task-list.ts +0 -141
- package/vendor/agent-root/src/agent/tool/task-mock-runner-adapter.ts +0 -232
- package/vendor/agent-root/src/agent/tool/task-output.ts +0 -223
- package/vendor/agent-root/src/agent/tool/task-parent-abort.ts +0 -115
- package/vendor/agent-root/src/agent/tool/task-real-runner-adapter.ts +0 -336
- package/vendor/agent-root/src/agent/tool/task-runner-adapter.ts +0 -55
- package/vendor/agent-root/src/agent/tool/task-stop.ts +0 -187
- package/vendor/agent-root/src/agent/tool/task-store.ts +0 -217
- package/vendor/agent-root/src/agent/tool/task-subagent-config.ts +0 -149
- package/vendor/agent-root/src/agent/tool/task-types.ts +0 -264
- package/vendor/agent-root/src/agent/tool/task-update.ts +0 -315
- package/vendor/agent-root/src/agent/tool/task.ts +0 -209
- package/vendor/agent-root/src/agent/tool/tool-manager.ts +0 -361
- package/vendor/agent-root/src/agent/tool/tool-prompts.ts +0 -242
- package/vendor/agent-root/src/agent/tool/types.ts +0 -116
- package/vendor/agent-root/src/agent/tool/web-fetch.ts +0 -227
- package/vendor/agent-root/src/agent/tool/web-search.ts +0 -208
- package/vendor/agent-root/src/agent/tool/write-file.ts +0 -497
- package/vendor/agent-root/src/agent/types.ts +0 -232
- package/vendor/agent-root/src/agent/utils/__tests__/index.test.ts +0 -18
- package/vendor/agent-root/src/agent/utils/__tests__/message-utils.test.ts +0 -610
- package/vendor/agent-root/src/agent/utils/__tests__/message.test.ts +0 -223
- package/vendor/agent-root/src/agent/utils/__tests__/token.test.ts +0 -42
- package/vendor/agent-root/src/agent/utils/index.ts +0 -16
- package/vendor/agent-root/src/agent/utils/message.ts +0 -171
- package/vendor/agent-root/src/agent/utils/token.ts +0 -28
- package/vendor/agent-root/src/config/__tests__/load-config-to-env.test.ts +0 -238
- package/vendor/agent-root/src/config/__tests__/loader.test.ts +0 -361
- package/vendor/agent-root/src/config/__tests__/runtime.test.ts +0 -88
- package/vendor/agent-root/src/config/index.ts +0 -55
- package/vendor/agent-root/src/config/loader.ts +0 -494
- package/vendor/agent-root/src/config/paths.ts +0 -30
- package/vendor/agent-root/src/config/runtime.ts +0 -163
- package/vendor/agent-root/src/config/types.ts +0 -96
- package/vendor/agent-root/src/logger/index.ts +0 -57
- package/vendor/agent-root/src/logger/logger.ts +0 -819
- package/vendor/agent-root/src/logger/types.ts +0 -150
- package/vendor/agent-root/src/providers/__tests__/errors.test.ts +0 -441
- package/vendor/agent-root/src/providers/__tests__/index.test.ts +0 -16
- package/vendor/agent-root/src/providers/__tests__/openai-compatible.options.test.ts +0 -318
- package/vendor/agent-root/src/providers/__tests__/openai-compatible.test.ts +0 -600
- package/vendor/agent-root/src/providers/__tests__/registry.test.ts +0 -523
- package/vendor/agent-root/src/providers/__tests__/responses-adapter.test.ts +0 -298
- package/vendor/agent-root/src/providers/adapters/__tests__/anthropic.test.ts +0 -354
- package/vendor/agent-root/src/providers/adapters/__tests__/kimi.test.ts +0 -58
- package/vendor/agent-root/src/providers/adapters/__tests__/standard.test.ts +0 -261
- package/vendor/agent-root/src/providers/adapters/anthropic.ts +0 -572
- package/vendor/agent-root/src/providers/adapters/base.ts +0 -131
- package/vendor/agent-root/src/providers/adapters/kimi.ts +0 -48
- package/vendor/agent-root/src/providers/adapters/responses.ts +0 -732
- package/vendor/agent-root/src/providers/adapters/standard.ts +0 -120
- package/vendor/agent-root/src/providers/http/__tests__/client.timeout.test.ts +0 -313
- package/vendor/agent-root/src/providers/http/client.ts +0 -289
- package/vendor/agent-root/src/providers/http/stream-parser.ts +0 -109
- package/vendor/agent-root/src/providers/index.ts +0 -76
- package/vendor/agent-root/src/providers/kimi-headers.ts +0 -177
- package/vendor/agent-root/src/providers/openai-compatible.ts +0 -387
- package/vendor/agent-root/src/providers/registry/model-config.ts +0 -477
- package/vendor/agent-root/src/providers/registry/provider-factory.ts +0 -127
- package/vendor/agent-root/src/providers/registry.ts +0 -135
- package/vendor/agent-root/src/providers/types/api.ts +0 -284
- package/vendor/agent-root/src/providers/types/config.ts +0 -58
- package/vendor/agent-root/src/providers/types/errors.ts +0 -323
- package/vendor/agent-root/src/providers/types/index.ts +0 -72
- package/vendor/agent-root/src/providers/types/provider.ts +0 -45
- package/vendor/agent-root/src/providers/types/registry.ts +0 -68
|
@@ -1,900 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { uiTheme } from '../../ui/theme';
|
|
4
|
-
import { getToolDisplayIcon, getToolDisplayName } from '../tool-display-config';
|
|
5
|
-
import { CodeBlock } from './code-block';
|
|
6
|
-
import type { ToolSegmentGroup } from './segment-groups';
|
|
7
|
-
|
|
8
|
-
type AssistantToolGroupProps = {
|
|
9
|
-
group: ToolSegmentGroup;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
type ParsedToolUse = {
|
|
13
|
-
name: string;
|
|
14
|
-
callId: string;
|
|
15
|
-
command?: string;
|
|
16
|
-
details?: string;
|
|
17
|
-
args?: Record<string, unknown> | null;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
type ParsedToolResult = {
|
|
21
|
-
name: string;
|
|
22
|
-
callId: string;
|
|
23
|
-
status: 'success' | 'error' | 'unknown';
|
|
24
|
-
details?: string;
|
|
25
|
-
summary?: string;
|
|
26
|
-
output?: string;
|
|
27
|
-
payload?: unknown;
|
|
28
|
-
metadata?: unknown;
|
|
29
|
-
error?: string;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
type ToolSection = {
|
|
33
|
-
label?: string;
|
|
34
|
-
content: string;
|
|
35
|
-
tone?: 'body' | 'code';
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
type SpecialToolPresentation = {
|
|
39
|
-
toolLabel?: string;
|
|
40
|
-
headerDetail?: string;
|
|
41
|
-
sections: ToolSection[];
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const COLLAPSIBLE_OUTPUT_LINES = 16;
|
|
45
|
-
const COLLAPSIBLE_OUTPUT_LABELS = new Set(['output', 'error', 'result', 'details']);
|
|
46
|
-
|
|
47
|
-
const asObjectLike = (value: unknown): Record<string, unknown> | null => {
|
|
48
|
-
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
return value as Record<string, unknown>;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const parseToolArgumentsObject = (raw?: string): Record<string, unknown> | null => {
|
|
55
|
-
if (!raw) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
try {
|
|
59
|
-
return asObjectLike(JSON.parse(raw));
|
|
60
|
-
} catch {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const parseToolUseFromData = (value: unknown): ParsedToolUse | null => {
|
|
66
|
-
const toolCall = asObjectLike(value);
|
|
67
|
-
const toolFunction = asObjectLike(toolCall?.function);
|
|
68
|
-
if (!toolFunction) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
const name = typeof toolFunction.name === 'string' ? toolFunction.name : undefined;
|
|
72
|
-
const callId = typeof toolCall?.id === 'string' ? toolCall.id : undefined;
|
|
73
|
-
if (!name || !callId) {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const rawArguments =
|
|
78
|
-
typeof toolFunction.arguments === 'string' ? toolFunction.arguments : undefined;
|
|
79
|
-
const args = parseToolArgumentsObject(rawArguments);
|
|
80
|
-
const command = name === 'bash' && typeof args?.command === 'string' ? args.command : undefined;
|
|
81
|
-
|
|
82
|
-
return {
|
|
83
|
-
name,
|
|
84
|
-
callId,
|
|
85
|
-
command,
|
|
86
|
-
details: rawArguments,
|
|
87
|
-
args,
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const parseToolUse = (content?: string, data?: unknown): ParsedToolUse | null => {
|
|
92
|
-
const structured = parseToolUseFromData(data);
|
|
93
|
-
if (structured) {
|
|
94
|
-
return structured;
|
|
95
|
-
}
|
|
96
|
-
if (!content) {
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
const lines = content.split('\n');
|
|
100
|
-
const header = lines[0]?.trim();
|
|
101
|
-
if (!header) {
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
const match = header.match(/^# Tool:\s+(.+?)\s+\(([^)]+)\)$/);
|
|
105
|
-
if (!match || !match[1] || !match[2]) {
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const [_, name, callId] = match;
|
|
110
|
-
const bodyLines = lines.slice(1);
|
|
111
|
-
const commandLine = bodyLines.find(line => line.trim().startsWith('$ '));
|
|
112
|
-
const command = commandLine ? commandLine.trim().slice(2).trim() : undefined;
|
|
113
|
-
const details = bodyLines
|
|
114
|
-
.filter(line => !line.trim().startsWith('$ '))
|
|
115
|
-
.join('\n')
|
|
116
|
-
.trim();
|
|
117
|
-
|
|
118
|
-
return {
|
|
119
|
-
name,
|
|
120
|
-
callId,
|
|
121
|
-
command: command || undefined,
|
|
122
|
-
details: details || undefined,
|
|
123
|
-
args: parseJsonObject(details),
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
const parseToolResultFromData = (value: unknown): ParsedToolResult | null => {
|
|
128
|
-
const event = asObjectLike(value);
|
|
129
|
-
const toolCall = asObjectLike(event?.toolCall);
|
|
130
|
-
const toolFunction = asObjectLike(toolCall?.function);
|
|
131
|
-
const result = asObjectLike(event?.result);
|
|
132
|
-
const data = asObjectLike(result?.data);
|
|
133
|
-
const name = typeof toolFunction?.name === 'string' ? toolFunction.name : undefined;
|
|
134
|
-
const callId = typeof toolCall?.id === 'string' ? toolCall.id : undefined;
|
|
135
|
-
if (!name || !callId) {
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const successValue = result?.success;
|
|
140
|
-
const status = successValue === true ? 'success' : successValue === false ? 'error' : 'unknown';
|
|
141
|
-
const summary = typeof data?.summary === 'string' ? data.summary : undefined;
|
|
142
|
-
const output = typeof data?.output === 'string' ? data.output : undefined;
|
|
143
|
-
const error = typeof result?.error === 'string' ? result.error : undefined;
|
|
144
|
-
|
|
145
|
-
return {
|
|
146
|
-
name,
|
|
147
|
-
callId,
|
|
148
|
-
status,
|
|
149
|
-
details: output || summary || error,
|
|
150
|
-
summary,
|
|
151
|
-
output,
|
|
152
|
-
payload: data?.payload,
|
|
153
|
-
metadata: data?.metadata,
|
|
154
|
-
error,
|
|
155
|
-
};
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
const parseToolResult = (content?: string, data?: unknown): ParsedToolResult | null => {
|
|
159
|
-
const structured = parseToolResultFromData(data);
|
|
160
|
-
if (structured) {
|
|
161
|
-
return structured;
|
|
162
|
-
}
|
|
163
|
-
if (!content) {
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
const lines = content.split('\n');
|
|
167
|
-
const header = lines[0]?.trim();
|
|
168
|
-
if (!header) {
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
const match = header.match(/^# Result:\s+(.+?)\s+\(([^)]+)\)\s+(success|error)$/);
|
|
172
|
-
if (!match || !match[1] || !match[2] || !match[3]) {
|
|
173
|
-
return null;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const [_, name, callId, status] = match;
|
|
177
|
-
const details = lines.slice(1).join('\n').trim();
|
|
178
|
-
|
|
179
|
-
return {
|
|
180
|
-
name,
|
|
181
|
-
callId,
|
|
182
|
-
status: status === 'success' || status === 'error' ? status : 'unknown',
|
|
183
|
-
details: details || undefined,
|
|
184
|
-
...(status === 'error' ? { error: details || undefined } : {}),
|
|
185
|
-
};
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
const resolveToolIcon = (toolName: string): string => {
|
|
189
|
-
return getToolDisplayIcon(toolName);
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
const mergeOutputLines = (
|
|
193
|
-
group: ToolSegmentGroup,
|
|
194
|
-
parsedResult: ParsedToolResult | null
|
|
195
|
-
): string => {
|
|
196
|
-
const streamText = group.streams
|
|
197
|
-
.map(segment => segment.content)
|
|
198
|
-
.join('')
|
|
199
|
-
.trim();
|
|
200
|
-
const resultText = parsedResult?.output?.trim() || parsedResult?.details?.trim();
|
|
201
|
-
if (streamText && resultText && streamText === resultText) {
|
|
202
|
-
return streamText;
|
|
203
|
-
}
|
|
204
|
-
if (streamText && resultText) {
|
|
205
|
-
return `${streamText}\n${resultText}`;
|
|
206
|
-
}
|
|
207
|
-
return streamText || resultText || parsedResult?.summary?.trim() || '';
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
const readObject = (value: unknown): Record<string, unknown> | null => {
|
|
211
|
-
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
212
|
-
return null;
|
|
213
|
-
}
|
|
214
|
-
return value as Record<string, unknown>;
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
const readArray = (value: unknown): unknown[] => {
|
|
218
|
-
return Array.isArray(value) ? value : [];
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
const readString = (value: unknown): string | undefined => {
|
|
222
|
-
return typeof value === 'string' ? value : undefined;
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
const readNumber = (value: unknown): number | undefined => {
|
|
226
|
-
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
const readBoolean = (value: unknown): boolean | undefined => {
|
|
230
|
-
return typeof value === 'boolean' ? value : undefined;
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
const parseJsonObject = (content?: string): Record<string, unknown> | null => {
|
|
234
|
-
if (!content) {
|
|
235
|
-
return null;
|
|
236
|
-
}
|
|
237
|
-
try {
|
|
238
|
-
return readObject(JSON.parse(content));
|
|
239
|
-
} catch {
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
const parseJsonValue = (content?: string): unknown => {
|
|
245
|
-
if (!content) {
|
|
246
|
-
return undefined;
|
|
247
|
-
}
|
|
248
|
-
try {
|
|
249
|
-
return JSON.parse(content);
|
|
250
|
-
} catch {
|
|
251
|
-
return undefined;
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
const countEscapeMarkers = (value: string): number => {
|
|
256
|
-
return (value.match(/\\r\\n|\\n|\\t|\\"|\\\\/g) ?? []).length;
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
const decodeEscapeSequencesOnce = (value: string): string => {
|
|
260
|
-
return value
|
|
261
|
-
.replace(/\\r\\n/g, '\n')
|
|
262
|
-
.replace(/\\n/g, '\n')
|
|
263
|
-
.replace(/\\t/g, '\t')
|
|
264
|
-
.replace(/\\"/g, '"')
|
|
265
|
-
.replace(/\\\\/g, '\\');
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
const normalizeToolDisplayText = (value: string): string => {
|
|
269
|
-
let current = value.replace(/\r\n/g, '\n').trimEnd();
|
|
270
|
-
for (let index = 0; index < 2; index += 1) {
|
|
271
|
-
const next = decodeEscapeSequencesOnce(current);
|
|
272
|
-
if (countEscapeMarkers(next) >= countEscapeMarkers(current)) {
|
|
273
|
-
break;
|
|
274
|
-
}
|
|
275
|
-
current = next;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
const parsed = parseJsonValue(current);
|
|
279
|
-
if (parsed !== undefined && typeof parsed !== 'string') {
|
|
280
|
-
try {
|
|
281
|
-
return JSON.stringify(parsed, null, 2);
|
|
282
|
-
} catch {
|
|
283
|
-
return current;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
return current;
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
const resolveSectionLanguageHint = (
|
|
291
|
-
toolName: string,
|
|
292
|
-
section: Pick<ToolSection, 'label' | 'tone'>
|
|
293
|
-
): string | undefined => {
|
|
294
|
-
if (section.tone !== 'code') {
|
|
295
|
-
return undefined;
|
|
296
|
-
}
|
|
297
|
-
if (section.label === 'command') {
|
|
298
|
-
return toolName === 'bash' ? 'bash' : undefined;
|
|
299
|
-
}
|
|
300
|
-
if (section.label === 'arguments') {
|
|
301
|
-
return 'json';
|
|
302
|
-
}
|
|
303
|
-
return undefined;
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
const isCollapsibleResultSection = (section: ToolSection): boolean => {
|
|
307
|
-
if (section.tone !== 'code') {
|
|
308
|
-
return false;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
if (!section.label) {
|
|
312
|
-
return false;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
return COLLAPSIBLE_OUTPUT_LABELS.has(section.label.toLowerCase());
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
const resolveStructuredResultObject = (
|
|
319
|
-
result: ParsedToolResult | null
|
|
320
|
-
): Record<string, unknown> | null => {
|
|
321
|
-
return (
|
|
322
|
-
readObject(result?.payload) ?? readObject(result?.metadata) ?? parseJsonObject(result?.details)
|
|
323
|
-
);
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
const formatToolName = (toolName: string): string => {
|
|
327
|
-
return getToolDisplayName(toolName);
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
const truncate = (value: string, maxLength = 88): string => {
|
|
331
|
-
const normalized = value.trim().replace(/\s+/g, ' ');
|
|
332
|
-
if (normalized.length <= maxLength) {
|
|
333
|
-
return normalized;
|
|
334
|
-
}
|
|
335
|
-
return `${normalized.slice(0, maxLength - 1)}…`;
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
const compactDetail = (value?: string, maxLength = 72): string | null => {
|
|
339
|
-
if (!value) {
|
|
340
|
-
return null;
|
|
341
|
-
}
|
|
342
|
-
const normalized = value.trim().replace(/\s+/g, ' ');
|
|
343
|
-
if (!normalized) {
|
|
344
|
-
return null;
|
|
345
|
-
}
|
|
346
|
-
return truncate(normalized, maxLength);
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
const formatStatusLabel = (status?: string): string | null => {
|
|
350
|
-
if (!status) {
|
|
351
|
-
return null;
|
|
352
|
-
}
|
|
353
|
-
return status.replace(/_/g, ' ');
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
const formatTaskStatusIcon = (status?: string): string => {
|
|
357
|
-
switch (status) {
|
|
358
|
-
case 'completed':
|
|
359
|
-
return '●';
|
|
360
|
-
case 'in_progress':
|
|
361
|
-
case 'running':
|
|
362
|
-
return '◐';
|
|
363
|
-
case 'pending':
|
|
364
|
-
case 'queued':
|
|
365
|
-
return '○';
|
|
366
|
-
case 'cancelled':
|
|
367
|
-
return '⊘';
|
|
368
|
-
case 'failed':
|
|
369
|
-
case 'timed_out':
|
|
370
|
-
return '×';
|
|
371
|
-
case 'paused':
|
|
372
|
-
return '⏸';
|
|
373
|
-
default:
|
|
374
|
-
return '•';
|
|
375
|
-
}
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
const formatSummaryMeta = (parts: Array<string | null | undefined>): string | null => {
|
|
379
|
-
const filtered = parts.map(part => part?.trim()).filter((part): part is string => Boolean(part));
|
|
380
|
-
return filtered.length > 0 ? filtered.join(' · ') : null;
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
const summarizeTaskRecord = (
|
|
384
|
-
task: Record<string, unknown>,
|
|
385
|
-
options?: { canStart?: Record<string, unknown> | null }
|
|
386
|
-
): string[] => {
|
|
387
|
-
const subject =
|
|
388
|
-
readString(task.subject) ?? readString(task.activeForm) ?? readString(task.id) ?? 'task';
|
|
389
|
-
const id = readString(task.id);
|
|
390
|
-
const status = readString(task.status);
|
|
391
|
-
const priority = readString(task.priority);
|
|
392
|
-
const progress = readNumber(task.effective_progress) ?? readNumber(task.progress);
|
|
393
|
-
const owner = readString(task.owner);
|
|
394
|
-
const blockers = readArray(task.blockers).length || readArray(task.blocked_by).length;
|
|
395
|
-
const blocks = readArray(task.blocked_tasks).length || readArray(task.blocks).length;
|
|
396
|
-
|
|
397
|
-
const lines = [`${formatTaskStatusIcon(status)} ${truncate(subject)}`];
|
|
398
|
-
const meta = formatSummaryMeta([
|
|
399
|
-
id,
|
|
400
|
-
formatStatusLabel(status),
|
|
401
|
-
priority,
|
|
402
|
-
progress !== undefined ? `${Math.round(progress)}%` : null,
|
|
403
|
-
owner ? `owner ${owner}` : null,
|
|
404
|
-
blockers > 0 ? `${blockers} blocker${blockers === 1 ? '' : 's'}` : null,
|
|
405
|
-
blocks > 0 ? `blocks ${blocks}` : null,
|
|
406
|
-
]);
|
|
407
|
-
if (meta) {
|
|
408
|
-
lines.push(meta);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
const canStart = options?.canStart;
|
|
412
|
-
if (canStart && readBoolean(canStart.canStart) === false) {
|
|
413
|
-
const reason = readString(canStart.reason);
|
|
414
|
-
if (reason) {
|
|
415
|
-
lines.push(`blocked: ${truncate(reason, 96)}`);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
return lines;
|
|
420
|
-
};
|
|
421
|
-
|
|
422
|
-
const summarizeAgentRun = (
|
|
423
|
-
run: Record<string, unknown>,
|
|
424
|
-
extras?: Record<string, unknown>
|
|
425
|
-
): { lines: string[]; output?: string } => {
|
|
426
|
-
const agentId = readString(run.agentId);
|
|
427
|
-
const status = readString(run.status);
|
|
428
|
-
const subagentType = readString(run.subagentType);
|
|
429
|
-
const description = readString(run.description);
|
|
430
|
-
const linkedTaskId = readString(run.linkedTaskId);
|
|
431
|
-
const progress = readNumber(run.progress);
|
|
432
|
-
const error = readString(run.error);
|
|
433
|
-
const output = readString(run.output);
|
|
434
|
-
|
|
435
|
-
const headline = description ?? agentId ?? 'agent run';
|
|
436
|
-
const lines = [`${formatTaskStatusIcon(status)} ${truncate(headline)}`];
|
|
437
|
-
const meta = formatSummaryMeta([
|
|
438
|
-
agentId,
|
|
439
|
-
formatStatusLabel(status),
|
|
440
|
-
subagentType,
|
|
441
|
-
progress !== undefined ? `${Math.round(progress)}%` : null,
|
|
442
|
-
linkedTaskId ? `task ${linkedTaskId}` : null,
|
|
443
|
-
readBoolean(extras?.completed) === false ? 'still running' : null,
|
|
444
|
-
readBoolean(extras?.timeout_hit) === true ? 'timeout hit' : null,
|
|
445
|
-
readNumber(extras?.waited_ms) !== undefined
|
|
446
|
-
? `${Math.round((readNumber(extras?.waited_ms) ?? 0) / 1000)}s waited`
|
|
447
|
-
: null,
|
|
448
|
-
]);
|
|
449
|
-
if (meta) {
|
|
450
|
-
lines.push(meta);
|
|
451
|
-
}
|
|
452
|
-
if (error && !output) {
|
|
453
|
-
lines.push(`error: ${truncate(error, 96)}`);
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
return {
|
|
457
|
-
lines,
|
|
458
|
-
output: output?.trim() ? output : undefined,
|
|
459
|
-
};
|
|
460
|
-
};
|
|
461
|
-
|
|
462
|
-
const buildTaskHeaderDetail = (
|
|
463
|
-
toolName: string,
|
|
464
|
-
args: Record<string, unknown> | null
|
|
465
|
-
): string | null => {
|
|
466
|
-
if (!args) {
|
|
467
|
-
return null;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
if (toolName === 'task_create') {
|
|
471
|
-
const subject = readString(args.subject);
|
|
472
|
-
return formatSummaryMeta([
|
|
473
|
-
subject ? `create ${truncate(subject, 56)}` : null,
|
|
474
|
-
readString(args.namespace),
|
|
475
|
-
readString(args.priority),
|
|
476
|
-
readArray(args.checkpoints).length > 0
|
|
477
|
-
? `${readArray(args.checkpoints).length} checkpoints`
|
|
478
|
-
: null,
|
|
479
|
-
]);
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
if (toolName === 'task_get') {
|
|
483
|
-
return formatSummaryMeta([
|
|
484
|
-
`inspect ${readString(args.task_id) ?? 'task'}`,
|
|
485
|
-
readBoolean(args.include_history) ? 'include history' : null,
|
|
486
|
-
]);
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
if (toolName === 'task_list') {
|
|
490
|
-
const statuses = readArray(args.statuses)
|
|
491
|
-
.map(value => readString(value))
|
|
492
|
-
.filter(Boolean)
|
|
493
|
-
.join(', ');
|
|
494
|
-
return formatSummaryMeta([
|
|
495
|
-
`list${readString(args.namespace) ? ` in ${readString(args.namespace)}` : ''}`,
|
|
496
|
-
statuses ? `status ${statuses}` : null,
|
|
497
|
-
readString(args.owner) ? `owner ${readString(args.owner)}` : null,
|
|
498
|
-
readString(args.tag) ? `tag ${readString(args.tag)}` : null,
|
|
499
|
-
]);
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
if (toolName === 'task_update') {
|
|
503
|
-
const changes: string[] = [`update ${readString(args.task_id) ?? 'task'}`];
|
|
504
|
-
if (readString(args.status))
|
|
505
|
-
changes.push(`status -> ${readString(args.status)?.replace(/_/g, ' ')}`);
|
|
506
|
-
if (readNumber(args.progress) !== undefined)
|
|
507
|
-
changes.push(`progress ${Math.round(readNumber(args.progress) ?? 0)}%`);
|
|
508
|
-
if (readString(args.owner)) changes.push(`owner ${readString(args.owner)}`);
|
|
509
|
-
if (readArray(args.add_blocked_by).length > 0)
|
|
510
|
-
changes.push(`+${readArray(args.add_blocked_by).length} blockers`);
|
|
511
|
-
if (readArray(args.remove_blocked_by).length > 0)
|
|
512
|
-
changes.push(`-${readArray(args.remove_blocked_by).length} blockers`);
|
|
513
|
-
return changes.join(' · ');
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
if (toolName === 'task_stop') {
|
|
517
|
-
return formatSummaryMeta([
|
|
518
|
-
`stop ${readString(args.task_id) ?? readString(args.agent_id) ?? 'agent run'}`,
|
|
519
|
-
readBoolean(args.cancel_linked_task) !== false ? 'cancel linked tasks' : null,
|
|
520
|
-
]);
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
if (toolName === 'task_output') {
|
|
524
|
-
return formatSummaryMeta([
|
|
525
|
-
`watch ${readString(args.task_id) ?? readString(args.agent_id) ?? 'agent run'}`,
|
|
526
|
-
readBoolean(args.block) === false ? 'non-blocking poll' : 'wait for completion',
|
|
527
|
-
]);
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
if (toolName === 'agent' || toolName === 'task') {
|
|
531
|
-
const prompt = readString(args.prompt);
|
|
532
|
-
const description = readString(args.description);
|
|
533
|
-
return formatSummaryMeta([
|
|
534
|
-
description ? truncate(description, 56) : prompt ? truncate(prompt, 56) : null,
|
|
535
|
-
readString(args.subagent_type),
|
|
536
|
-
readBoolean(args.run_in_background) ? 'background' : 'foreground',
|
|
537
|
-
readString(args.linked_task_id) ? `task ${readString(args.linked_task_id)}` : null,
|
|
538
|
-
]);
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
return null;
|
|
542
|
-
};
|
|
543
|
-
|
|
544
|
-
const buildTaskResultSections = (
|
|
545
|
-
toolName: string,
|
|
546
|
-
result: ParsedToolResult | null
|
|
547
|
-
): ToolSection[] => {
|
|
548
|
-
const resultDetails = result?.details?.trim();
|
|
549
|
-
const summary = result?.summary?.trim();
|
|
550
|
-
if (!resultDetails && !summary && !result?.payload && !result?.metadata) {
|
|
551
|
-
return [];
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
if (result?.status === 'error') {
|
|
555
|
-
return [
|
|
556
|
-
{
|
|
557
|
-
label: 'result',
|
|
558
|
-
content: result?.error?.trim() || resultDetails || summary || 'task failed',
|
|
559
|
-
tone: 'body',
|
|
560
|
-
},
|
|
561
|
-
];
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
const payload = resolveStructuredResultObject(result);
|
|
565
|
-
if (!payload) {
|
|
566
|
-
return [
|
|
567
|
-
{
|
|
568
|
-
label: 'result',
|
|
569
|
-
content: resultDetails || summary || '',
|
|
570
|
-
tone: 'body',
|
|
571
|
-
},
|
|
572
|
-
];
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
if (toolName === 'task_list') {
|
|
576
|
-
const namespace = readString(payload.namespace) ?? 'default';
|
|
577
|
-
const tasks = readArray(payload.tasks)
|
|
578
|
-
.map(item => readObject(item))
|
|
579
|
-
.filter((item): item is Record<string, unknown> => Boolean(item));
|
|
580
|
-
const total = readNumber(payload.total) ?? tasks.length;
|
|
581
|
-
const lines = [`${total} task${total === 1 ? '' : 's'} in ${namespace}`];
|
|
582
|
-
tasks.slice(0, 5).forEach(task => {
|
|
583
|
-
const summary = summarizeTaskRecord(task);
|
|
584
|
-
if (summary[0]) {
|
|
585
|
-
lines.push(summary[0]);
|
|
586
|
-
}
|
|
587
|
-
if (summary[1]) {
|
|
588
|
-
lines.push(` ${summary[1]}`);
|
|
589
|
-
}
|
|
590
|
-
});
|
|
591
|
-
if (tasks.length > 5) {
|
|
592
|
-
lines.push(`+${tasks.length - 5} more`);
|
|
593
|
-
}
|
|
594
|
-
return [{ label: 'result', content: lines.join('\n'), tone: 'body' }];
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
if (toolName === 'task_stop') {
|
|
598
|
-
const run = readObject(payload.agent_run);
|
|
599
|
-
const cancelledTaskIds = readArray(payload.cancelled_task_ids)
|
|
600
|
-
.map(item => readString(item))
|
|
601
|
-
.filter(Boolean);
|
|
602
|
-
const sections: ToolSection[] = [];
|
|
603
|
-
if (run) {
|
|
604
|
-
sections.push({
|
|
605
|
-
label: 'result',
|
|
606
|
-
content: summarizeAgentRun(run).lines.join('\n'),
|
|
607
|
-
tone: 'body',
|
|
608
|
-
});
|
|
609
|
-
}
|
|
610
|
-
if (cancelledTaskIds.length > 0) {
|
|
611
|
-
sections.push({
|
|
612
|
-
label: 'cancelled',
|
|
613
|
-
content: cancelledTaskIds.join(', '),
|
|
614
|
-
tone: 'body',
|
|
615
|
-
});
|
|
616
|
-
}
|
|
617
|
-
return sections;
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
if (toolName === 'task_output' || toolName === 'task' || toolName === 'agent') {
|
|
621
|
-
const run = readObject(payload.agent_run);
|
|
622
|
-
if (run) {
|
|
623
|
-
const summary = summarizeAgentRun(run, payload);
|
|
624
|
-
const sections: ToolSection[] = [
|
|
625
|
-
{
|
|
626
|
-
label: 'result',
|
|
627
|
-
content: summary.lines.join('\n'),
|
|
628
|
-
tone: 'body',
|
|
629
|
-
},
|
|
630
|
-
];
|
|
631
|
-
if (summary.output) {
|
|
632
|
-
sections.push({
|
|
633
|
-
label: 'output',
|
|
634
|
-
content: summary.output,
|
|
635
|
-
tone: 'body',
|
|
636
|
-
});
|
|
637
|
-
}
|
|
638
|
-
return sections;
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
const task = readObject(payload.task);
|
|
643
|
-
if (task) {
|
|
644
|
-
const canStart = readObject(payload.can_start) ?? readObject(task.can_start);
|
|
645
|
-
return [
|
|
646
|
-
{
|
|
647
|
-
label: 'result',
|
|
648
|
-
content: summarizeTaskRecord(task, { canStart }).join('\n'),
|
|
649
|
-
tone: 'body',
|
|
650
|
-
},
|
|
651
|
-
];
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
return [
|
|
655
|
-
{
|
|
656
|
-
label: 'result',
|
|
657
|
-
content: resultDetails || summary || '',
|
|
658
|
-
tone: 'body',
|
|
659
|
-
},
|
|
660
|
-
];
|
|
661
|
-
};
|
|
662
|
-
|
|
663
|
-
const buildSearchHeaderDetail = (
|
|
664
|
-
toolName: string,
|
|
665
|
-
args: Record<string, unknown> | null
|
|
666
|
-
): string | null => {
|
|
667
|
-
if (!args) {
|
|
668
|
-
return null;
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
if (toolName === 'grep') {
|
|
672
|
-
const pattern = readString(args.pattern);
|
|
673
|
-
if (!pattern) {
|
|
674
|
-
return null;
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
return formatSummaryMeta([
|
|
678
|
-
JSON.stringify(pattern),
|
|
679
|
-
readString(args.path) ? `in ${readString(args.path)}` : null,
|
|
680
|
-
readString(args.glob) ? `glob ${readString(args.glob)}` : null,
|
|
681
|
-
readNumber(args.max_results) !== undefined
|
|
682
|
-
? `limit ${Math.round(readNumber(args.max_results) ?? 0)}`
|
|
683
|
-
: null,
|
|
684
|
-
readNumber(args.timeout_ms) !== undefined
|
|
685
|
-
? `${Math.round((readNumber(args.timeout_ms) ?? 0) / 1000)}s timeout`
|
|
686
|
-
: null,
|
|
687
|
-
]);
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
if (toolName === 'glob') {
|
|
691
|
-
const pattern = readString(args.pattern);
|
|
692
|
-
if (!pattern) {
|
|
693
|
-
return null;
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
return formatSummaryMeta([
|
|
697
|
-
pattern,
|
|
698
|
-
readString(args.path) ? `in ${readString(args.path)}` : null,
|
|
699
|
-
readBoolean(args.include_hidden) ? 'include hidden' : null,
|
|
700
|
-
readNumber(args.max_results) !== undefined
|
|
701
|
-
? `limit ${Math.round(readNumber(args.max_results) ?? 0)}`
|
|
702
|
-
: null,
|
|
703
|
-
]);
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
return null;
|
|
707
|
-
};
|
|
708
|
-
|
|
709
|
-
const buildSearchResultSections = (result: ParsedToolResult | null): ToolSection[] => {
|
|
710
|
-
const summary = result?.summary?.trim();
|
|
711
|
-
const output = result?.output?.trim() || result?.details?.trim();
|
|
712
|
-
const metadata = readObject(result?.metadata) ?? readObject(result?.payload);
|
|
713
|
-
|
|
714
|
-
if (!summary && !output && !metadata) {
|
|
715
|
-
return [];
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
if (metadata) {
|
|
719
|
-
const matchCount = readNumber(metadata.countMatches);
|
|
720
|
-
const fileCount = readNumber(metadata.countFiles);
|
|
721
|
-
const path = readString(metadata.path);
|
|
722
|
-
const flags = formatSummaryMeta([
|
|
723
|
-
matchCount !== undefined ? `${matchCount} matches` : null,
|
|
724
|
-
fileCount !== undefined ? `${fileCount} files` : null,
|
|
725
|
-
path ? `in ${path}` : null,
|
|
726
|
-
readBoolean(metadata.truncated) ? 'truncated' : null,
|
|
727
|
-
readBoolean(metadata.timed_out) ? 'timed out' : null,
|
|
728
|
-
]);
|
|
729
|
-
if (summary && output && summary !== output && flags) {
|
|
730
|
-
return [
|
|
731
|
-
{ label: 'result', content: summary, tone: 'body' },
|
|
732
|
-
{ label: 'details', content: `${flags}\n${output}`, tone: 'body' },
|
|
733
|
-
];
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
return [
|
|
738
|
-
{
|
|
739
|
-
label: 'result',
|
|
740
|
-
content: output || summary || '',
|
|
741
|
-
tone: 'body',
|
|
742
|
-
},
|
|
743
|
-
];
|
|
744
|
-
};
|
|
745
|
-
|
|
746
|
-
const buildSpecialToolPresentation = (
|
|
747
|
-
toolName: string,
|
|
748
|
-
parsedUse: ParsedToolUse | null,
|
|
749
|
-
parsedResult: ParsedToolResult | null
|
|
750
|
-
): SpecialToolPresentation | null => {
|
|
751
|
-
const args = parsedUse?.args ?? parseJsonObject(parsedUse?.details);
|
|
752
|
-
if (toolName === 'agent' || toolName === 'task' || toolName.startsWith('task_')) {
|
|
753
|
-
const sections = buildTaskResultSections(toolName, parsedResult);
|
|
754
|
-
|
|
755
|
-
return {
|
|
756
|
-
toolLabel: formatToolName(toolName),
|
|
757
|
-
headerDetail: buildTaskHeaderDetail(toolName, args) ?? undefined,
|
|
758
|
-
sections,
|
|
759
|
-
};
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
if (toolName === 'grep' || toolName === 'glob') {
|
|
763
|
-
const sections = buildSearchResultSections(parsedResult);
|
|
764
|
-
|
|
765
|
-
return {
|
|
766
|
-
toolLabel: formatToolName(toolName),
|
|
767
|
-
headerDetail: buildSearchHeaderDetail(toolName, args) ?? undefined,
|
|
768
|
-
sections,
|
|
769
|
-
};
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
return null;
|
|
773
|
-
};
|
|
774
|
-
|
|
775
|
-
export const AssistantToolGroup = ({ group }: AssistantToolGroupProps) => {
|
|
776
|
-
const [expandedSections, setExpandedSections] = useState<Record<string, boolean>>({});
|
|
777
|
-
const parsedUse = parseToolUse(group.use?.content, group.use?.data);
|
|
778
|
-
const parsedResult = parseToolResult(group.result?.content, group.result?.data);
|
|
779
|
-
const toolName = parsedUse?.name ?? parsedResult?.name ?? 'tool';
|
|
780
|
-
const commandText = parsedUse?.command;
|
|
781
|
-
const invocationDetails = parsedUse?.details;
|
|
782
|
-
const icon = resolveToolIcon(toolName);
|
|
783
|
-
const outputText = mergeOutputLines(group, parsedResult);
|
|
784
|
-
const _hasInvocationDetails = Boolean(invocationDetails);
|
|
785
|
-
const hasOutput = outputText.length > 0;
|
|
786
|
-
const specialPresentation = buildSpecialToolPresentation(toolName, parsedUse, parsedResult);
|
|
787
|
-
const titleDetail =
|
|
788
|
-
specialPresentation?.headerDetail ??
|
|
789
|
-
compactDetail(commandText, 64) ??
|
|
790
|
-
compactDetail(invocationDetails, 64);
|
|
791
|
-
const defaultSections: ToolSection[] = [];
|
|
792
|
-
if (commandText && !titleDetail) {
|
|
793
|
-
defaultSections.push({
|
|
794
|
-
label: 'command',
|
|
795
|
-
content: `$ ${commandText}`,
|
|
796
|
-
tone: 'code',
|
|
797
|
-
});
|
|
798
|
-
}
|
|
799
|
-
if (invocationDetails && !titleDetail) {
|
|
800
|
-
defaultSections.push({
|
|
801
|
-
label: 'arguments',
|
|
802
|
-
content: invocationDetails,
|
|
803
|
-
tone: 'code',
|
|
804
|
-
});
|
|
805
|
-
}
|
|
806
|
-
if (hasOutput) {
|
|
807
|
-
defaultSections.push({
|
|
808
|
-
label: parsedResult?.status === 'error' ? 'error' : 'output',
|
|
809
|
-
content: outputText,
|
|
810
|
-
tone: 'code',
|
|
811
|
-
});
|
|
812
|
-
}
|
|
813
|
-
const sections = specialPresentation?.sections ?? defaultSections;
|
|
814
|
-
const hasBody = sections.length > 0;
|
|
815
|
-
const statusText =
|
|
816
|
-
parsedResult?.status === 'success'
|
|
817
|
-
? 'completed'
|
|
818
|
-
: parsedResult?.status === 'error'
|
|
819
|
-
? 'error'
|
|
820
|
-
: group.result
|
|
821
|
-
? 'finished'
|
|
822
|
-
: 'running';
|
|
823
|
-
|
|
824
|
-
return (
|
|
825
|
-
<box flexDirection="column">
|
|
826
|
-
<box paddingLeft={3}>
|
|
827
|
-
<text fg={uiTheme.text} attributes={uiTheme.typography.note} wrapMode="word">
|
|
828
|
-
<span fg={uiTheme.accent}>{icon}</span>{' '}
|
|
829
|
-
{specialPresentation?.toolLabel ?? formatToolName(toolName)}
|
|
830
|
-
{titleDetail ? <span fg={uiTheme.muted}>({titleDetail})</span> : null}
|
|
831
|
-
<span fg={uiTheme.subtle}> ({statusText})</span>
|
|
832
|
-
</text>
|
|
833
|
-
</box>
|
|
834
|
-
{hasBody ? (
|
|
835
|
-
<box flexDirection="row" marginTop={1}>
|
|
836
|
-
<box width={1} backgroundColor={uiTheme.divider} />
|
|
837
|
-
<box
|
|
838
|
-
flexGrow={1}
|
|
839
|
-
backgroundColor={uiTheme.panel}
|
|
840
|
-
paddingLeft={2}
|
|
841
|
-
paddingRight={1}
|
|
842
|
-
paddingTop={1}
|
|
843
|
-
paddingBottom={1}
|
|
844
|
-
>
|
|
845
|
-
{sections.map((section, index) => {
|
|
846
|
-
const content = normalizeToolDisplayText(section.content);
|
|
847
|
-
const isCode = section.tone === 'code';
|
|
848
|
-
const sectionId = `${toolName}:section:${index}`;
|
|
849
|
-
const collapsible = isCollapsibleResultSection(section);
|
|
850
|
-
const expanded = Boolean(expandedSections[sectionId]);
|
|
851
|
-
|
|
852
|
-
return (
|
|
853
|
-
<box
|
|
854
|
-
key={sectionId}
|
|
855
|
-
flexDirection="column"
|
|
856
|
-
paddingBottom={index < sections.length - 1 ? 1 : 0}
|
|
857
|
-
>
|
|
858
|
-
{section.label ? (
|
|
859
|
-
isCode ? null : (
|
|
860
|
-
<text fg={uiTheme.muted} attributes={uiTheme.typography.note}>
|
|
861
|
-
{section.label}
|
|
862
|
-
</text>
|
|
863
|
-
)
|
|
864
|
-
) : null}
|
|
865
|
-
{isCode ? (
|
|
866
|
-
<box>
|
|
867
|
-
<CodeBlock
|
|
868
|
-
content={content}
|
|
869
|
-
label={section.label}
|
|
870
|
-
languageHint={resolveSectionLanguageHint(toolName, section)}
|
|
871
|
-
collapsible={collapsible}
|
|
872
|
-
collapsedLines={COLLAPSIBLE_OUTPUT_LINES}
|
|
873
|
-
expanded={expanded}
|
|
874
|
-
onToggleExpanded={() => {
|
|
875
|
-
if (!collapsible) {
|
|
876
|
-
return;
|
|
877
|
-
}
|
|
878
|
-
setExpandedSections(previous => ({
|
|
879
|
-
...previous,
|
|
880
|
-
[sectionId]: !previous[sectionId],
|
|
881
|
-
}));
|
|
882
|
-
}}
|
|
883
|
-
/>
|
|
884
|
-
</box>
|
|
885
|
-
) : (
|
|
886
|
-
<box marginTop={section.label ? 1 : 0}>
|
|
887
|
-
<text fg={uiTheme.text} attributes={uiTheme.typography.body} wrapMode="word">
|
|
888
|
-
{content}
|
|
889
|
-
</text>
|
|
890
|
-
</box>
|
|
891
|
-
)}
|
|
892
|
-
</box>
|
|
893
|
-
);
|
|
894
|
-
})}
|
|
895
|
-
</box>
|
|
896
|
-
</box>
|
|
897
|
-
) : null}
|
|
898
|
-
</box>
|
|
899
|
-
);
|
|
900
|
-
};
|