@bastani/atomic 0.9.16-alpha.6 → 0.9.16-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/README.md +4 -4
- package/dist/builtin/intercom/broker/broker.ts +617 -22
- package/dist/builtin/intercom/broker/client-message-validation.ts +9 -0
- package/dist/builtin/intercom/broker/client.ts +200 -10
- package/dist/builtin/intercom/broker/pending-send-registry.ts +4 -0
- package/dist/builtin/intercom/broker/send-handler.ts +90 -36
- package/dist/builtin/intercom/broker/send-signature.ts +20 -8
- package/dist/builtin/intercom/group.ts +85 -0
- package/dist/builtin/intercom/index.bundle.mjs +680 -53
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/session-target.ts +54 -0
- package/dist/builtin/intercom/skills/intercom/SKILL.md +18 -3
- package/dist/builtin/intercom/source-ownership.ts +31 -0
- package/dist/builtin/intercom/types.ts +115 -0
- package/dist/builtin/mcp/index.bundle.mjs +109 -35
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +6 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/qlty/SKILL.md +123 -0
- package/dist/builtin/subagents/skills/qlty/references/coding-with-ai-agents.md +64 -0
- package/dist/builtin/subagents/skills/qlty/references/commands.md +291 -0
- package/dist/builtin/subagents/skills/qlty/references/plugins-and-extensions.md +228 -0
- package/dist/builtin/subagents/skills/qlty/references/quickstart.md +110 -0
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +173 -51
- package/dist/builtin/web-access/index.bundle.mjs +109 -35
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +23 -0
- package/dist/builtin/workflows/README.md +40 -37
- package/dist/builtin/workflows/builtin/adversarial-verification.js +13 -0
- package/dist/builtin/workflows/builtin/{shared-prompts.ts → chunk-0x6e303p.js} +137 -133
- package/dist/builtin/workflows/builtin/chunk-29wrp38a.js +199 -0
- package/dist/builtin/workflows/builtin/chunk-2dqb5s2q.js +602 -0
- package/dist/builtin/workflows/builtin/chunk-4febxsv4.js +264 -0
- package/dist/builtin/workflows/builtin/chunk-5n10x7j2.js +69730 -0
- package/dist/builtin/workflows/builtin/chunk-5wgwscd0.js +4 -0
- package/dist/builtin/workflows/builtin/chunk-6fqs7c01.js +155 -0
- package/dist/builtin/workflows/builtin/chunk-7430zyas.js +126 -0
- package/dist/builtin/workflows/builtin/chunk-7at6dnkr.js +33 -0
- package/dist/builtin/workflows/builtin/chunk-82ha8p41.js +175 -0
- package/dist/builtin/workflows/builtin/chunk-bfkmzv9h.js +156 -0
- package/dist/builtin/workflows/builtin/chunk-c53y8bdh.js +345 -0
- package/dist/builtin/workflows/builtin/chunk-cdtd3m3w.js +529 -0
- package/dist/builtin/workflows/builtin/chunk-cg9tmks0.js +206 -0
- package/dist/builtin/workflows/builtin/chunk-hdpj1dkw.js +2447 -0
- package/dist/builtin/workflows/builtin/chunk-hzzn6adg.js +221 -0
- package/dist/builtin/workflows/builtin/chunk-nqr34qp3.js +1061 -0
- package/dist/builtin/workflows/builtin/chunk-qwzvgxnq.js +404 -0
- package/dist/builtin/workflows/builtin/chunk-qx2ptjs3.js +215 -0
- package/dist/builtin/workflows/builtin/chunk-v04c5qmd.js +1207 -0
- package/dist/builtin/workflows/builtin/chunk-wpckd35c.js +12 -0
- package/dist/builtin/workflows/builtin/chunk-x2ghn0je.js +4110 -0
- package/dist/builtin/workflows/builtin/chunk-zf28603f.js +1080 -0
- package/dist/builtin/workflows/builtin/classify-and-act.js +12 -0
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +10 -0
- package/dist/builtin/workflows/builtin/generate-and-filter.js +12 -0
- package/dist/builtin/workflows/builtin/goal.js +16 -0
- package/dist/builtin/workflows/builtin/index.js +49 -0
- package/dist/builtin/workflows/builtin/loop-until-done.js +12 -0
- package/dist/builtin/workflows/builtin/open-claude-design.js +11 -0
- package/dist/builtin/workflows/builtin/ralph.js +16 -0
- package/dist/builtin/workflows/builtin/steering-context.d.ts +6 -0
- package/dist/builtin/workflows/builtin/steering-context.js +7 -0
- package/dist/builtin/workflows/builtin/tournament.js +13 -0
- package/dist/builtin/workflows/package.json +10 -7
- package/dist/builtin/workflows/src/authoring/typebox-defaults.d.ts +41 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +1250 -428
- package/dist/builtin/workflows/src/{index.bundle.mjs → index.js} +956 -427
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +403 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +327 -0
- package/dist/builtin/workflows/src/shared/budget.d.ts +67 -0
- package/dist/builtin/workflows/src/shared/workflow-authoring-types.d.ts +60 -0
- package/dist/builtin/workflows/src/shared/workflow-heartbeat-contract.d.ts +21 -0
- package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -1
- package/dist/core/agent-session-custom-message-commit.js +12 -5
- package/dist/core/agent-session-custom-message-commit.js.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.js +2 -0
- package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +2 -0
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +4 -0
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/builtin-install-layout.d.ts +1 -1
- package/dist/core/builtin-install-layout.d.ts.map +1 -1
- package/dist/core/builtin-install-layout.js +1 -1
- package/dist/core/builtin-install-layout.js.map +1 -1
- package/dist/core/codex-fast-mode.d.ts +10 -7
- package/dist/core/codex-fast-mode.d.ts.map +1 -1
- package/dist/core/codex-fast-mode.js +31 -13
- package/dist/core/codex-fast-mode.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +35 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +6 -1
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/model-runtime.d.ts +2 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +4 -0
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +1 -0
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +8 -0
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +5 -5
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-storage.d.ts +2 -0
- package/dist/core/session-manager-storage.d.ts.map +1 -1
- package/dist/core/session-manager-storage.js +4 -2
- package/dist/core/session-manager-storage.js.map +1 -1
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/workflow-stage-admission.d.ts +6 -1
- package/dist/core/workflow-stage-admission.d.ts.map +1 -1
- package/dist/core/workflow-stage-admission.js +8 -9
- package/dist/core/workflow-stage-admission.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +1 -1
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +4 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +69 -10
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +18 -2
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js +33 -5
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +8 -4
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +13 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/intercom.md +15 -6
- package/docs/packages.md +2 -2
- package/docs/providers.md +8 -3
- package/docs/quickstart.md +3 -2
- package/docs/rpc.md +21 -4
- package/docs/settings.md +6 -4
- package/docs/skills.md +4 -0
- package/docs/subagents.md +1 -1
- package/docs/usage.md +1 -1
- package/docs/workflows.md +112 -239
- package/npm-shrinkwrap.json +32 -32
- package/package.json +9 -13
- package/dist/builtin/workflows/ambient.d.ts +0 -61
- package/dist/builtin/workflows/builtin/adversarial-verification-prompts.ts +0 -26
- package/dist/builtin/workflows/builtin/adversarial-verification-runner.ts +0 -391
- package/dist/builtin/workflows/builtin/adversarial-verification.ts +0 -34
- package/dist/builtin/workflows/builtin/classify-and-act-prompts.ts +0 -14
- package/dist/builtin/workflows/builtin/classify-and-act-runner.ts +0 -108
- package/dist/builtin/workflows/builtin/classify-and-act.ts +0 -40
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-prompts.ts +0 -14
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-runner.ts +0 -96
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.ts +0 -37
- package/dist/builtin/workflows/builtin/generate-and-filter-prompts.ts +0 -41
- package/dist/builtin/workflows/builtin/generate-and-filter-runner.ts +0 -90
- package/dist/builtin/workflows/builtin/generate-and-filter.ts +0 -31
- package/dist/builtin/workflows/builtin/goal-artifacts.ts +0 -64
- package/dist/builtin/workflows/builtin/goal-convergence.ts +0 -87
- package/dist/builtin/workflows/builtin/goal-ledger.ts +0 -139
- package/dist/builtin/workflows/builtin/goal-models.ts +0 -72
- package/dist/builtin/workflows/builtin/goal-orchestrator-prompts.ts +0 -94
- package/dist/builtin/workflows/builtin/goal-prompts.ts +0 -211
- package/dist/builtin/workflows/builtin/goal-reducer.ts +0 -176
- package/dist/builtin/workflows/builtin/goal-reports.ts +0 -76
- package/dist/builtin/workflows/builtin/goal-reverify.ts +0 -305
- package/dist/builtin/workflows/builtin/goal-review.ts +0 -139
- package/dist/builtin/workflows/builtin/goal-runner.ts +0 -504
- package/dist/builtin/workflows/builtin/goal-schemas.ts +0 -89
- package/dist/builtin/workflows/builtin/goal-types.ts +0 -164
- package/dist/builtin/workflows/builtin/goal.ts +0 -78
- package/dist/builtin/workflows/builtin/index.ts +0 -16
- package/dist/builtin/workflows/builtin/loop-until-done-prompts.ts +0 -87
- package/dist/builtin/workflows/builtin/loop-until-done-runner.ts +0 -282
- package/dist/builtin/workflows/builtin/loop-until-done.ts +0 -51
- package/dist/builtin/workflows/builtin/open-claude-design-live-protocol.ts +0 -305
- package/dist/builtin/workflows/builtin/open-claude-design-phases.ts +0 -337
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +0 -347
- package/dist/builtin/workflows/builtin/open-claude-design-setup.ts +0 -313
- package/dist/builtin/workflows/builtin/open-claude-design-utils.ts +0 -311
- package/dist/builtin/workflows/builtin/open-claude-design.ts +0 -57
- package/dist/builtin/workflows/builtin/pattern-artifact-root.ts +0 -28
- package/dist/builtin/workflows/builtin/progress-scoring.ts +0 -230
- package/dist/builtin/workflows/builtin/ralph-core.ts +0 -449
- package/dist/builtin/workflows/builtin/ralph-forked-prompts.ts +0 -100
- package/dist/builtin/workflows/builtin/ralph-models.ts +0 -183
- package/dist/builtin/workflows/builtin/ralph-review-gate.ts +0 -103
- package/dist/builtin/workflows/builtin/ralph-reviewer-prompt.ts +0 -100
- package/dist/builtin/workflows/builtin/ralph-runner.ts +0 -455
- package/dist/builtin/workflows/builtin/ralph.ts +0 -82
- package/dist/builtin/workflows/builtin/review-convergence.ts +0 -229
- package/dist/builtin/workflows/builtin/selection-math.ts +0 -156
- package/dist/builtin/workflows/builtin/steering-context.ts +0 -51
- package/dist/builtin/workflows/builtin/tournament-prompts.ts +0 -70
- package/dist/builtin/workflows/builtin/tournament-runner.ts +0 -400
- package/dist/builtin/workflows/builtin/tournament.ts +0 -73
- package/dist/builtin/workflows/builtin/verification-criteria.ts +0 -330
- package/dist/builtin/workflows/builtin/verification-prompts.ts +0 -206
- package/dist/builtin/workflows/builtin/verification-usage.ts +0 -44
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import"./chunk-5wgwscd0.js";
|
|
2
|
+
|
|
3
|
+
// src/core/export-html/ansi-to-html.ts
|
|
4
|
+
var ANSI_COLORS = [
|
|
5
|
+
"#000000",
|
|
6
|
+
"#800000",
|
|
7
|
+
"#008000",
|
|
8
|
+
"#808000",
|
|
9
|
+
"#000080",
|
|
10
|
+
"#800080",
|
|
11
|
+
"#008080",
|
|
12
|
+
"#c0c0c0",
|
|
13
|
+
"#808080",
|
|
14
|
+
"#ff0000",
|
|
15
|
+
"#00ff00",
|
|
16
|
+
"#ffff00",
|
|
17
|
+
"#0000ff",
|
|
18
|
+
"#ff00ff",
|
|
19
|
+
"#00ffff",
|
|
20
|
+
"#ffffff"
|
|
21
|
+
];
|
|
22
|
+
function color256ToHex(index) {
|
|
23
|
+
if (index < 16) {
|
|
24
|
+
return ANSI_COLORS[index];
|
|
25
|
+
}
|
|
26
|
+
if (index < 232) {
|
|
27
|
+
const cubeIndex = index - 16;
|
|
28
|
+
const r = Math.floor(cubeIndex / 36);
|
|
29
|
+
const g = Math.floor(cubeIndex % 36 / 6);
|
|
30
|
+
const b = cubeIndex % 6;
|
|
31
|
+
const toComponent = (n) => n === 0 ? 0 : 55 + n * 40;
|
|
32
|
+
const toHex = (n) => toComponent(n).toString(16).padStart(2, "0");
|
|
33
|
+
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
34
|
+
}
|
|
35
|
+
const gray = 8 + (index - 232) * 10;
|
|
36
|
+
const grayHex = gray.toString(16).padStart(2, "0");
|
|
37
|
+
return `#${grayHex}${grayHex}${grayHex}`;
|
|
38
|
+
}
|
|
39
|
+
function escapeHtml(text) {
|
|
40
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
41
|
+
}
|
|
42
|
+
function createEmptyStyle() {
|
|
43
|
+
return {
|
|
44
|
+
fg: null,
|
|
45
|
+
bg: null,
|
|
46
|
+
bold: false,
|
|
47
|
+
dim: false,
|
|
48
|
+
italic: false,
|
|
49
|
+
underline: false
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function styleToInlineCSS(style) {
|
|
53
|
+
const parts = [];
|
|
54
|
+
if (style.fg)
|
|
55
|
+
parts.push(`color:${style.fg}`);
|
|
56
|
+
if (style.bg)
|
|
57
|
+
parts.push(`background-color:${style.bg}`);
|
|
58
|
+
if (style.bold)
|
|
59
|
+
parts.push("font-weight:bold");
|
|
60
|
+
if (style.dim)
|
|
61
|
+
parts.push("opacity:0.6");
|
|
62
|
+
if (style.italic)
|
|
63
|
+
parts.push("font-style:italic");
|
|
64
|
+
if (style.underline)
|
|
65
|
+
parts.push("text-decoration:underline");
|
|
66
|
+
return parts.join(";");
|
|
67
|
+
}
|
|
68
|
+
function hasStyle(style) {
|
|
69
|
+
return style.fg !== null || style.bg !== null || style.bold || style.dim || style.italic || style.underline;
|
|
70
|
+
}
|
|
71
|
+
function applySgrCode(params, style) {
|
|
72
|
+
let i = 0;
|
|
73
|
+
while (i < params.length) {
|
|
74
|
+
const code = params[i];
|
|
75
|
+
if (code === 0) {
|
|
76
|
+
style.fg = null;
|
|
77
|
+
style.bg = null;
|
|
78
|
+
style.bold = false;
|
|
79
|
+
style.dim = false;
|
|
80
|
+
style.italic = false;
|
|
81
|
+
style.underline = false;
|
|
82
|
+
} else if (code === 1) {
|
|
83
|
+
style.bold = true;
|
|
84
|
+
} else if (code === 2) {
|
|
85
|
+
style.dim = true;
|
|
86
|
+
} else if (code === 3) {
|
|
87
|
+
style.italic = true;
|
|
88
|
+
} else if (code === 4) {
|
|
89
|
+
style.underline = true;
|
|
90
|
+
} else if (code === 22) {
|
|
91
|
+
style.bold = false;
|
|
92
|
+
style.dim = false;
|
|
93
|
+
} else if (code === 23) {
|
|
94
|
+
style.italic = false;
|
|
95
|
+
} else if (code === 24) {
|
|
96
|
+
style.underline = false;
|
|
97
|
+
} else if (code >= 30 && code <= 37) {
|
|
98
|
+
style.fg = ANSI_COLORS[code - 30];
|
|
99
|
+
} else if (code === 38) {
|
|
100
|
+
if (params[i + 1] === 5 && params.length > i + 2) {
|
|
101
|
+
style.fg = color256ToHex(params[i + 2]);
|
|
102
|
+
i += 2;
|
|
103
|
+
} else if (params[i + 1] === 2 && params.length > i + 4) {
|
|
104
|
+
const r = params[i + 2];
|
|
105
|
+
const g = params[i + 3];
|
|
106
|
+
const b = params[i + 4];
|
|
107
|
+
style.fg = `rgb(${r},${g},${b})`;
|
|
108
|
+
i += 4;
|
|
109
|
+
}
|
|
110
|
+
} else if (code === 39) {
|
|
111
|
+
style.fg = null;
|
|
112
|
+
} else if (code >= 40 && code <= 47) {
|
|
113
|
+
style.bg = ANSI_COLORS[code - 40];
|
|
114
|
+
} else if (code === 48) {
|
|
115
|
+
if (params[i + 1] === 5 && params.length > i + 2) {
|
|
116
|
+
style.bg = color256ToHex(params[i + 2]);
|
|
117
|
+
i += 2;
|
|
118
|
+
} else if (params[i + 1] === 2 && params.length > i + 4) {
|
|
119
|
+
const r = params[i + 2];
|
|
120
|
+
const g = params[i + 3];
|
|
121
|
+
const b = params[i + 4];
|
|
122
|
+
style.bg = `rgb(${r},${g},${b})`;
|
|
123
|
+
i += 4;
|
|
124
|
+
}
|
|
125
|
+
} else if (code === 49) {
|
|
126
|
+
style.bg = null;
|
|
127
|
+
} else if (code >= 90 && code <= 97) {
|
|
128
|
+
style.fg = ANSI_COLORS[code - 90 + 8];
|
|
129
|
+
} else if (code >= 100 && code <= 107) {
|
|
130
|
+
style.bg = ANSI_COLORS[code - 100 + 8];
|
|
131
|
+
}
|
|
132
|
+
i++;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
var ANSI_REGEX = /\x1b\[([\d;]*)m/g;
|
|
136
|
+
function ansiToHtml(text) {
|
|
137
|
+
const style = createEmptyStyle();
|
|
138
|
+
let result = "";
|
|
139
|
+
let lastIndex = 0;
|
|
140
|
+
let inSpan = false;
|
|
141
|
+
ANSI_REGEX.lastIndex = 0;
|
|
142
|
+
let match = ANSI_REGEX.exec(text);
|
|
143
|
+
while (match !== null) {
|
|
144
|
+
const beforeText = text.slice(lastIndex, match.index);
|
|
145
|
+
if (beforeText) {
|
|
146
|
+
result += escapeHtml(beforeText);
|
|
147
|
+
}
|
|
148
|
+
const paramStr = match[1];
|
|
149
|
+
const params = paramStr ? paramStr.split(";").map((p) => parseInt(p, 10) || 0) : [0];
|
|
150
|
+
if (inSpan) {
|
|
151
|
+
result += "</span>";
|
|
152
|
+
inSpan = false;
|
|
153
|
+
}
|
|
154
|
+
applySgrCode(params, style);
|
|
155
|
+
if (hasStyle(style)) {
|
|
156
|
+
result += `<span style="${styleToInlineCSS(style)}">`;
|
|
157
|
+
inSpan = true;
|
|
158
|
+
}
|
|
159
|
+
lastIndex = match.index + match[0].length;
|
|
160
|
+
match = ANSI_REGEX.exec(text);
|
|
161
|
+
}
|
|
162
|
+
const remainingText = text.slice(lastIndex);
|
|
163
|
+
if (remainingText) {
|
|
164
|
+
result += escapeHtml(remainingText);
|
|
165
|
+
}
|
|
166
|
+
if (inSpan) {
|
|
167
|
+
result += "</span>";
|
|
168
|
+
}
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
function ansiLinesToHtml(lines) {
|
|
172
|
+
return lines.map((line) => `<div class="ansi-line">${ansiToHtml(line) || " "}</div>`).join("");
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// src/core/export-html/tool-renderer.ts
|
|
176
|
+
var ANSI_ESCAPE_REGEX = /\x1b\[[\d;]*m/g;
|
|
177
|
+
function isBlankRenderedLine(line) {
|
|
178
|
+
return line.replace(ANSI_ESCAPE_REGEX, "").trim().length === 0;
|
|
179
|
+
}
|
|
180
|
+
function trimRenderedResultLines(lines) {
|
|
181
|
+
let start = 0;
|
|
182
|
+
let end = lines.length;
|
|
183
|
+
while (start < end && isBlankRenderedLine(lines[start]))
|
|
184
|
+
start++;
|
|
185
|
+
while (end > start && isBlankRenderedLine(lines[end - 1]))
|
|
186
|
+
end--;
|
|
187
|
+
return lines.slice(start, end);
|
|
188
|
+
}
|
|
189
|
+
function createToolHtmlRenderer(deps) {
|
|
190
|
+
const { getToolDefinition, theme, cwd, width = 100 } = deps;
|
|
191
|
+
const renderedCallComponents = new Map;
|
|
192
|
+
const renderedResultComponents = new Map;
|
|
193
|
+
const renderedStates = new Map;
|
|
194
|
+
const renderedArgs = new Map;
|
|
195
|
+
const getState = (toolCallId) => {
|
|
196
|
+
let state = renderedStates.get(toolCallId);
|
|
197
|
+
if (!state) {
|
|
198
|
+
state = {};
|
|
199
|
+
renderedStates.set(toolCallId, state);
|
|
200
|
+
}
|
|
201
|
+
return state;
|
|
202
|
+
};
|
|
203
|
+
const createRenderContext = (toolCallId, lastComponent, expanded, isPartial, isError) => {
|
|
204
|
+
return {
|
|
205
|
+
args: renderedArgs.get(toolCallId),
|
|
206
|
+
toolCallId,
|
|
207
|
+
invalidate: () => {},
|
|
208
|
+
lastComponent,
|
|
209
|
+
state: getState(toolCallId),
|
|
210
|
+
cwd,
|
|
211
|
+
executionStarted: true,
|
|
212
|
+
argsComplete: true,
|
|
213
|
+
isPartial,
|
|
214
|
+
expanded,
|
|
215
|
+
showImages: false,
|
|
216
|
+
isError
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
return {
|
|
220
|
+
renderCall(toolCallId, toolName, args) {
|
|
221
|
+
try {
|
|
222
|
+
renderedArgs.set(toolCallId, args);
|
|
223
|
+
const toolDef = getToolDefinition(toolName);
|
|
224
|
+
if (!toolDef?.renderCall) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const component = toolDef.renderCall(args, theme, createRenderContext(toolCallId, renderedCallComponents.get(toolCallId), false, true, false));
|
|
228
|
+
renderedCallComponents.set(toolCallId, component);
|
|
229
|
+
const lines = component.render(width);
|
|
230
|
+
return ansiLinesToHtml(lines);
|
|
231
|
+
} catch {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
renderResult(toolCallId, toolName, result, details, isError) {
|
|
236
|
+
try {
|
|
237
|
+
const toolDef = getToolDefinition(toolName);
|
|
238
|
+
if (!toolDef?.renderResult) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
const agentToolResult = {
|
|
242
|
+
content: result,
|
|
243
|
+
details,
|
|
244
|
+
isError
|
|
245
|
+
};
|
|
246
|
+
const collapsedComponent = toolDef.renderResult(agentToolResult, { expanded: false, isPartial: false }, theme, createRenderContext(toolCallId, renderedResultComponents.get(toolCallId), false, false, isError));
|
|
247
|
+
renderedResultComponents.set(toolCallId, collapsedComponent);
|
|
248
|
+
const collapsed = ansiLinesToHtml(trimRenderedResultLines(collapsedComponent.render(width)));
|
|
249
|
+
const expandedComponent = toolDef.renderResult(agentToolResult, { expanded: true, isPartial: false }, theme, createRenderContext(toolCallId, renderedResultComponents.get(toolCallId), true, false, isError));
|
|
250
|
+
renderedResultComponents.set(toolCallId, expandedComponent);
|
|
251
|
+
const expanded = ansiLinesToHtml(trimRenderedResultLines(expandedComponent.render(width)));
|
|
252
|
+
return {
|
|
253
|
+
...collapsed && collapsed !== expanded ? { collapsed } : {},
|
|
254
|
+
expanded
|
|
255
|
+
};
|
|
256
|
+
} catch {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
export {
|
|
263
|
+
createToolHtmlRenderer
|
|
264
|
+
};
|