| @@ -75,6 +75,7 @@ import { · 74 unmodified lines |
| 75 | type ProviderAdapterError, | 75 | type ProviderAdapterError, |
| 76 | } from "../Errors.ts"; | 76 | } from "../Errors.ts"; |
| 77 | import { ClaudeAdapter, type ClaudeAdapterShape } from "../Services/ClaudeAdapter.ts"; | 77 | import { ClaudeAdapter, type ClaudeAdapterShape } from "../Services/ClaudeAdapter.ts"; |
| | 78 | import { normalizeCommandValue, pushChangedFile } from "../toolDataUtils.ts"; |
| 78 | import { type EventNdjsonLogger, makeEventNdjsonLogger } from "./EventNdjsonLogger.ts"; | 79 | import { type EventNdjsonLogger, makeEventNdjsonLogger } from "./EventNdjsonLogger.ts"; |
| 79 | | 80 | |
| 80 | const PROVIDER = "claudeAgent" as const; | 81 | const PROVIDER = "claudeAgent" as const; |
| @@ -747,32 +748,6 @@ function tryParseJsonRecord(value: string): Record<string, unknown> | undefined · 666 unmodified lines |
| 747 | } | 748 | } |
| 748 | } | 749 | } |
| 749 | | 750 | |
| 750 | function normalizeCommandValue(value: unknown): string | undefined { | | |
| 751 | if (typeof value === "string") { | | |
| 752 | const trimmed = value.trim(); | | |
| 753 | return trimmed.length > 0 ? trimmed : undefined; | | |
| 754 | } | | |
| 755 | if (!Array.isArray(value)) { | | |
| 756 | return undefined; | | |
| 757 | } | | |
| 758 | const parts = value | | |
| 759 | .map((entry) => (typeof entry === "string" ? entry.trim() : "")) | | |
| 760 | .filter((entry) => entry.length > 0); | | |
| 761 | return parts.length > 0 ? parts.join(" ") : undefined; | | |
| 762 | } | | |
| 763 | | | |
| 764 | function pushChangedFile(target: string[], seen: Set<string>, value: unknown) { | | |
| 765 | if (typeof value !== "string") { | | |
| 766 | return; | | |
| 767 | } | | |
| 768 | const normalized = value.trim(); | | |
| 769 | if (normalized.length === 0 || seen.has(normalized)) { | | |
| 770 | return; | | |
| 771 | } | | |
| 772 | seen.add(normalized); | | |
| 773 | target.push(normalized); | | |
| 774 | } | | |
| 775 | | | |
| 776 | function collectChangedFiles(value: unknown, target: string[], seen: Set<string>, depth: number) { | 751 | function collectChangedFiles(value: unknown, target: string[], seen: Set<string>, depth: number) { |
| 777 | if (depth > 4 || target.length >= 12) { | 752 | if (depth > 4 || target.length >= 12) { |
| 778 | return; | 753 | return; |
| @@ -1540,19 +1515,14 @@ function makeClaudeAdapter(options?: ClaudeAdapterLiveOptions) { · 761 unmodified lines |
| 1540 | status: status === "completed" ? "completed" : "failed", | 1515 | status: status === "completed" ? "completed" : "failed", |
| 1541 | title: tool.title, | 1516 | title: tool.title, |
| 1542 | ...(tool.detail ? { detail: tool.detail } : {}), | 1517 | ...(tool.detail ? { detail: tool.detail } : {}), |
| 1543 | ...(canonicalToolLifecycleData({ | 1518 | ...(() => { |
| 1544 | itemType: tool.itemType, | 1519 | const toolData = canonicalToolLifecycleData({ |
| 1545 | toolName: tool.toolName, | 1520 | itemType: tool.itemType, |
| 1546 | input: tool.input, | 1521 | toolName: tool.toolName, |
| 1547 | }) | 1522 | input: tool.input, |
| 1548 | ? { | 1523 | }); |
| 1549 | data: canonicalToolLifecycleData({ | 1524 | return toolData ? { data: toolData } : {}; |
| 1550 | itemType: tool.itemType, | 1525 | })(), |
| 1551 | toolName: tool.toolName, | | |
| 1552 | input: tool.input, | | |
| 1553 | }), | | |
| 1554 | } | | |
| 1555 | : {}), | | |
| 1556 | }, | 1526 | }, |
| 1557 | providerRefs: nativeProviderRefs(context, { providerItemId: tool.itemId }), | 1527 | providerRefs: nativeProviderRefs(context, { providerItemId: tool.itemId }), |
| 1558 | raw: { | 1528 | raw: { |
| @@ -1744,19 +1714,14 @@ function makeClaudeAdapter(options?: ClaudeAdapterLiveOptions) { · 185 unmodified lines |
| 1744 | status: "inProgress", | 1714 | status: "inProgress", |
| 1745 | title: nextTool.title, | 1715 | title: nextTool.title, |
| 1746 | ...(nextTool.detail ? { detail: nextTool.detail } : {}), | 1716 | ...(nextTool.detail ? { detail: nextTool.detail } : {}), |
| 1747 | ...(canonicalToolLifecycleData({ | 1717 | ...(() => { |
| 1748 | itemType: nextTool.itemType, | 1718 | const toolData = canonicalToolLifecycleData({ |
| 1749 | toolName: nextTool.toolName, | 1719 | itemType: nextTool.itemType, |
| 1750 | input: nextTool.input, | 1720 | toolName: nextTool.toolName, |
| 1751 | }) | 1721 | input: nextTool.input, |
| 1752 | ? { | 1722 | }); |
| 1753 | data: canonicalToolLifecycleData({ | 1723 | return toolData ? { data: toolData } : {}; |
| 1754 | itemType: nextTool.itemType, | 1724 | })(), |
| 1755 | toolName: nextTool.toolName, | | |
| 1756 | input: nextTool.input, | | |
| 1757 | }), | | |
| 1758 | } | | |
| 1759 | : {}), | | |
| 1760 | }, | 1725 | }, |
| 1761 | providerRefs: nativeProviderRefs(context, { providerItemId: nextTool.itemId }), | 1726 | providerRefs: nativeProviderRefs(context, { providerItemId: nextTool.itemId }), |
| 1762 | raw: { | 1727 | raw: { |
| @@ -1822,19 +1787,14 @@ function makeClaudeAdapter(options?: ClaudeAdapterLiveOptions) { · 59 unmodified lines |
| 1822 | status: "inProgress", | 1787 | status: "inProgress", |
| 1823 | title: tool.title, | 1788 | title: tool.title, |
| 1824 | ...(tool.detail ? { detail: tool.detail } : {}), | 1789 | ...(tool.detail ? { detail: tool.detail } : {}), |
| 1825 | ...(canonicalToolLifecycleData({ | 1790 | ...(() => { |
| 1826 | itemType: tool.itemType, | 1791 | const toolData = canonicalToolLifecycleData({ |
| 1827 | toolName: tool.toolName, | 1792 | itemType: tool.itemType, |
| 1828 | input: toolInput, | 1793 | toolName: tool.toolName, |
| 1829 | }) | 1794 | input: toolInput, |
| 1830 | ? { | 1795 | }); |
| 1831 | data: canonicalToolLifecycleData({ | 1796 | return toolData ? { data: toolData } : {}; |
| 1832 | itemType: tool.itemType, | 1797 | })(), |
| 1833 | toolName: tool.toolName, | | |
| 1834 | input: toolInput, | | |
| 1835 | }), | | |
| 1836 | } | | |
| 1837 | : {}), | | |
| 1838 | }, | 1798 | }, |
| 1839 | providerRefs: nativeProviderRefs(context, { providerItemId: tool.itemId }), | 1799 | providerRefs: nativeProviderRefs(context, { providerItemId: tool.itemId }), |
| 1840 | raw: { | 1800 | raw: { |