@best-agent/cli 0.0.2-beta.7 → 0.0.2-beta.9
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/LICENSE +21 -0
- package/README.md +44 -181
- package/dist/launcher.js +32 -0
- package/package.json +15 -27
- package/dist/best-agent-native-bridge.d.ts +0 -389
- package/dist/best-agent-native-bridge.js +0 -4645
- package/dist/cli-storage.d.ts +0 -5
- package/dist/cli-storage.js +0 -7
- package/dist/dimsdk/ask-user.d.ts +0 -21
- package/dist/dimsdk/ask-user.js +0 -131
- package/dist/dimsdk/cli/version.d.ts +0 -6
- package/dist/dimsdk/cli/version.js +0 -36
- package/dist/dimsdk/compat/archships/dim-agent/runtime-host.d.ts +0 -49
- package/dist/dimsdk/compat/archships/dim-agent/runtime-host.js +0 -215
- package/dist/dimsdk/compat/runtime-host.d.ts +0 -2
- package/dist/dimsdk/compat/runtime-host.js +0 -2
- package/dist/dimsdk/core/debug-log.d.ts +0 -8
- package/dist/dimsdk/core/debug-log.js +0 -100
- package/dist/dimsdk/core/env.d.ts +0 -26
- package/dist/dimsdk/core/env.js +0 -130
- package/dist/dimsdk/core/markdown/sanitize.d.ts +0 -2
- package/dist/dimsdk/core/markdown/sanitize.js +0 -43
- package/dist/dimsdk/core/markdown/wrap.d.ts +0 -9
- package/dist/dimsdk/core/markdown/wrap.js +0 -139
- package/dist/dimsdk/core/markdown.d.ts +0 -18
- package/dist/dimsdk/core/markdown.js +0 -62
- package/dist/dimsdk/core/model.d.ts +0 -273
- package/dist/dimsdk/core/model.js +0 -16
- package/dist/dimsdk/core/observability/perf-log.d.ts +0 -18
- package/dist/dimsdk/core/observability/perf-log.js +0 -236
- package/dist/dimsdk/core/store/agent-event-mappers.d.ts +0 -26
- package/dist/dimsdk/core/store/agent-event-mappers.js +0 -109
- package/dist/dimsdk/core/store/message-mutations.d.ts +0 -105
- package/dist/dimsdk/core/store/message-mutations.js +0 -1528
- package/dist/dimsdk/core/store/semantic-readers.d.ts +0 -2
- package/dist/dimsdk/core/store/semantic-readers.js +0 -4
- package/dist/dimsdk/core/store/transcript-projector.d.ts +0 -164
- package/dist/dimsdk/core/store/transcript-projector.js +0 -580
- package/dist/dimsdk/core/tool-metadata.d.ts +0 -12
- package/dist/dimsdk/core/tool-metadata.js +0 -70
- package/dist/dimsdk/core/transcript-part-id.d.ts +0 -6
- package/dist/dimsdk/core/transcript-part-id.js +0 -22
- package/dist/dimsdk/i18n/index.d.ts +0 -18
- package/dist/dimsdk/i18n/index.js +0 -141
- package/dist/dimsdk/i18n/locales/en.d.ts +0 -988
- package/dist/dimsdk/i18n/locales/en.js +0 -987
- package/dist/dimsdk/i18n/locales/index.d.ts +0 -1976
- package/dist/dimsdk/i18n/locales/index.js +0 -8
- package/dist/dimsdk/i18n/locales/zh-CN.d.ts +0 -988
- package/dist/dimsdk/i18n/locales/zh-CN.js +0 -987
- package/dist/dimsdk/i18n/types.d.ts +0 -13
- package/dist/dimsdk/i18n/types.js +0 -2
- package/dist/dimsdk/shared/value-normalizers.d.ts +0 -7
- package/dist/dimsdk/shared/value-normalizers.js +0 -48
- package/dist/dimsdk-tui.bundle-size.json +0 -169
- package/dist/dimsdk-tui.bundle.js +0 -330756
- package/dist/goatchain-adapter.d.ts +0 -41
- package/dist/goatchain-adapter.js +0 -499
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -1405
- package/dist/native-runtime-bridge.d.ts +0 -387
- package/dist/native-runtime-bridge.js +0 -4624
- package/dist/provider-config-env.d.ts +0 -7
- package/dist/provider-config-env.js +0 -286
- package/dist/provider-model-limit-index.generated.d.ts +0 -3
- package/dist/provider-model-limit-index.generated.js +0 -7818
- package/dist/provider-model-limits.d.ts +0 -8
- package/dist/provider-model-limits.js +0 -43
- package/dist/runtime.d.ts +0 -47
- package/dist/runtime.js +0 -516
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export declare function isPerfEnabled(): boolean;
|
|
2
|
-
export declare function isOneShotEnabled(): boolean;
|
|
3
|
-
export declare function pushPerfSpan(name: string, detail?: string): void;
|
|
4
|
-
export declare function popPerfSpan(name?: string): void;
|
|
5
|
-
export declare function withPerfSpan<T>(name: string, detail: string | undefined, fn: () => T): T;
|
|
6
|
-
export declare function withPerfSpanAsync<T>(name: string, detail: string | undefined, fn: () => Promise<T>): Promise<T>;
|
|
7
|
-
export declare function getPerfSpanSnapshot(): {
|
|
8
|
-
path: string;
|
|
9
|
-
depth: number;
|
|
10
|
-
topAgeMs: number;
|
|
11
|
-
} | null;
|
|
12
|
-
export declare function getPerfSpanOverlapSummary(windowStartMs: number, windowEndMs: number): string;
|
|
13
|
-
export declare function getPerfSpanStats(): {
|
|
14
|
-
activeDepth: number;
|
|
15
|
-
historySize: number;
|
|
16
|
-
};
|
|
17
|
-
export declare function perfLog(line: string): void;
|
|
18
|
-
//# sourceMappingURL=perf-log.d.ts.map
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import { appendFileSync } from "node:fs";
|
|
2
|
-
import { createEnvReader, readProcessEnv } from "../env.js";
|
|
3
|
-
function runtimeGlobals() {
|
|
4
|
-
return globalThis;
|
|
5
|
-
}
|
|
6
|
-
function isNodeLike() {
|
|
7
|
-
const p = runtimeGlobals().process;
|
|
8
|
-
const v = p?.versions ?? {};
|
|
9
|
-
return Boolean(p && (typeof v?.node === "string" || typeof v?.bun === "string"));
|
|
10
|
-
}
|
|
11
|
-
function env() {
|
|
12
|
-
return createEnvReader(readProcessEnv());
|
|
13
|
-
}
|
|
14
|
-
function parseEnabled(v) {
|
|
15
|
-
const s = String(v ?? "")
|
|
16
|
-
.trim()
|
|
17
|
-
.toLowerCase();
|
|
18
|
-
return s === "1" || s === "true" || s === "yes" || s === "on";
|
|
19
|
-
}
|
|
20
|
-
export function isPerfEnabled() {
|
|
21
|
-
if (!isNodeLike())
|
|
22
|
-
return false;
|
|
23
|
-
const e = env();
|
|
24
|
-
return e.prefixedStr("PROFILE_1SHOT") === "1" || e.prefixedStr("PERF_LOG") === "1";
|
|
25
|
-
}
|
|
26
|
-
export function isOneShotEnabled() {
|
|
27
|
-
if (!isNodeLike())
|
|
28
|
-
return false;
|
|
29
|
-
return env().prefixedStr("PROFILE_1SHOT") === "1";
|
|
30
|
-
}
|
|
31
|
-
function shouldLogSlowSpans() {
|
|
32
|
-
const e = env();
|
|
33
|
-
if (isOneShotEnabled())
|
|
34
|
-
return true;
|
|
35
|
-
return parseEnabled(e.prefixedStr("PERF_SPAN_LOG"));
|
|
36
|
-
}
|
|
37
|
-
function slowSpanThresholdMs() {
|
|
38
|
-
const e = env();
|
|
39
|
-
const raw = Number(e.prefixedStr("PERF_SPAN_SLOW_MS"));
|
|
40
|
-
if (Number.isFinite(raw) && raw > 0)
|
|
41
|
-
return Math.max(1, Math.floor(raw));
|
|
42
|
-
return isOneShotEnabled() ? 5 : 50;
|
|
43
|
-
}
|
|
44
|
-
function formatClockTime(ms) {
|
|
45
|
-
const d = new Date(ms);
|
|
46
|
-
const hh = String(d.getHours()).padStart(2, "0");
|
|
47
|
-
const mm = String(d.getMinutes()).padStart(2, "0");
|
|
48
|
-
const ss = String(d.getSeconds()).padStart(2, "0");
|
|
49
|
-
const mmm = String(d.getMilliseconds()).padStart(3, "0");
|
|
50
|
-
return `${hh}:${mm}:${ss}.${mmm}`;
|
|
51
|
-
}
|
|
52
|
-
function writePerfLine(text) {
|
|
53
|
-
if (!isPerfEnabled())
|
|
54
|
-
return;
|
|
55
|
-
const line = String(text ?? "").trim();
|
|
56
|
-
if (!line)
|
|
57
|
-
return;
|
|
58
|
-
try {
|
|
59
|
-
appendFileSync("/tmp/dimcode-perf.log", `[${formatClockTime(Date.now())}] ${line}\n`);
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
// ignore
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function getSpanState() {
|
|
66
|
-
const g = runtimeGlobals();
|
|
67
|
-
if (!g.__DIMCODE_PERF_SPAN__)
|
|
68
|
-
g.__DIMCODE_PERF_SPAN__ = { stack: [] };
|
|
69
|
-
return g.__DIMCODE_PERF_SPAN__;
|
|
70
|
-
}
|
|
71
|
-
function getHistoryState() {
|
|
72
|
-
const g = runtimeGlobals();
|
|
73
|
-
if (!g.__DIMCODE_PERF_SPAN_HISTORY__) {
|
|
74
|
-
const e = env();
|
|
75
|
-
const rawMax = Number(e.prefixedStr("PERF_SPAN_HISTORY_MAX"));
|
|
76
|
-
const computedMax = Number.isFinite(rawMax) && rawMax > 0
|
|
77
|
-
? Math.max(1000, Math.floor(rawMax))
|
|
78
|
-
: isOneShotEnabled()
|
|
79
|
-
? 20000
|
|
80
|
-
: 2000;
|
|
81
|
-
g.__DIMCODE_PERF_SPAN_HISTORY__ = {
|
|
82
|
-
records: [],
|
|
83
|
-
maxRecords: computedMax,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
return g.__DIMCODE_PERF_SPAN_HISTORY__;
|
|
87
|
-
}
|
|
88
|
-
function recordSpan(span, endedAt) {
|
|
89
|
-
const start = Number(span.startedAt || 0);
|
|
90
|
-
const end = Number(endedAt || 0);
|
|
91
|
-
const durationMs = Math.max(0, end - start);
|
|
92
|
-
const rec = {
|
|
93
|
-
name: span.name,
|
|
94
|
-
...(span.detail ? { detail: span.detail } : {}),
|
|
95
|
-
startedAt: start,
|
|
96
|
-
endedAt: end,
|
|
97
|
-
durationMs,
|
|
98
|
-
};
|
|
99
|
-
const h = getHistoryState();
|
|
100
|
-
h.records.push(rec);
|
|
101
|
-
if (h.records.length > h.maxRecords)
|
|
102
|
-
h.records.splice(0, h.records.length - h.maxRecords);
|
|
103
|
-
if (shouldLogSlowSpans() && durationMs >= slowSpanThresholdMs()) {
|
|
104
|
-
const detail = rec.detail ? ` detail=${rec.detail}` : "";
|
|
105
|
-
writePerfLine(`[SPAN] ${rec.name} ${rec.durationMs}ms${detail}`);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
export function pushPerfSpan(name, detail) {
|
|
109
|
-
const n = String(name ?? "").trim();
|
|
110
|
-
if (!n)
|
|
111
|
-
return;
|
|
112
|
-
const d = detail !== undefined ? String(detail ?? "").trim() : undefined;
|
|
113
|
-
const state = getSpanState();
|
|
114
|
-
state.stack.push({
|
|
115
|
-
name: n,
|
|
116
|
-
startedAt: Date.now(),
|
|
117
|
-
...(d ? { detail: d } : {}),
|
|
118
|
-
});
|
|
119
|
-
// Avoid unbounded growth if someone forgets to pop.
|
|
120
|
-
if (state.stack.length > 64)
|
|
121
|
-
state.stack.splice(0, state.stack.length - 64);
|
|
122
|
-
}
|
|
123
|
-
export function popPerfSpan(name) {
|
|
124
|
-
const state = getSpanState();
|
|
125
|
-
if (state.stack.length === 0)
|
|
126
|
-
return;
|
|
127
|
-
const endedAt = Date.now();
|
|
128
|
-
if (!name) {
|
|
129
|
-
const span = state.stack.pop();
|
|
130
|
-
if (span)
|
|
131
|
-
recordSpan(span, endedAt);
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
const want = String(name ?? "").trim();
|
|
135
|
-
// Pop until we find the matching span name (best-effort).
|
|
136
|
-
for (let i = state.stack.length - 1; i >= 0; i--) {
|
|
137
|
-
const cur = state.stack[i];
|
|
138
|
-
state.stack.pop();
|
|
139
|
-
if (cur)
|
|
140
|
-
recordSpan(cur, endedAt);
|
|
141
|
-
if (cur?.name === want)
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
export function withPerfSpan(name, detail, fn) {
|
|
146
|
-
if (!isPerfEnabled())
|
|
147
|
-
return fn();
|
|
148
|
-
pushPerfSpan(name, detail);
|
|
149
|
-
try {
|
|
150
|
-
return fn();
|
|
151
|
-
}
|
|
152
|
-
finally {
|
|
153
|
-
popPerfSpan(name);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
export async function withPerfSpanAsync(name, detail, fn) {
|
|
157
|
-
if (!isPerfEnabled())
|
|
158
|
-
return await fn();
|
|
159
|
-
pushPerfSpan(name, detail);
|
|
160
|
-
try {
|
|
161
|
-
return await fn();
|
|
162
|
-
}
|
|
163
|
-
finally {
|
|
164
|
-
popPerfSpan(name);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
export function getPerfSpanSnapshot() {
|
|
168
|
-
const state = getSpanState();
|
|
169
|
-
if (!state.stack.length)
|
|
170
|
-
return null;
|
|
171
|
-
const now = Date.now();
|
|
172
|
-
const parts = state.stack.map((s) => {
|
|
173
|
-
const d = s.detail ? `(${s.detail})` : "";
|
|
174
|
-
return `${s.name}${d}`;
|
|
175
|
-
});
|
|
176
|
-
const top = state.stack[state.stack.length - 1];
|
|
177
|
-
const age = Math.max(0, now - Number(top.startedAt || 0));
|
|
178
|
-
return { path: parts.join(">"), depth: state.stack.length, topAgeMs: age };
|
|
179
|
-
}
|
|
180
|
-
export function getPerfSpanOverlapSummary(windowStartMs, windowEndMs) {
|
|
181
|
-
const start = Number(windowStartMs || 0);
|
|
182
|
-
const end = Number(windowEndMs || 0);
|
|
183
|
-
if (!Number.isFinite(start) || !Number.isFinite(end) || end <= 0 || end < start) {
|
|
184
|
-
return "";
|
|
185
|
-
}
|
|
186
|
-
const overlaps = [];
|
|
187
|
-
// Completed spans
|
|
188
|
-
const history = getHistoryState().records;
|
|
189
|
-
for (let i = history.length - 1; i >= 0; i--) {
|
|
190
|
-
const r = history[i];
|
|
191
|
-
if (r.endedAt < start)
|
|
192
|
-
break; // records are in chronological order
|
|
193
|
-
if (r.startedAt > end)
|
|
194
|
-
continue;
|
|
195
|
-
const oStart = Math.max(start, r.startedAt);
|
|
196
|
-
const oEnd = Math.min(end, r.endedAt);
|
|
197
|
-
const overlapMs = Math.max(0, oEnd - oStart);
|
|
198
|
-
if (overlapMs > 0)
|
|
199
|
-
overlaps.push({ rec: r, overlapMs });
|
|
200
|
-
}
|
|
201
|
-
// Active spans (no end time yet): treat as ending at windowEnd.
|
|
202
|
-
const active = getSpanState().stack;
|
|
203
|
-
for (const s of active) {
|
|
204
|
-
const r = {
|
|
205
|
-
name: s.name,
|
|
206
|
-
...(s.detail ? { detail: s.detail } : {}),
|
|
207
|
-
startedAt: s.startedAt,
|
|
208
|
-
endedAt: end,
|
|
209
|
-
durationMs: Math.max(0, end - Number(s.startedAt || 0)),
|
|
210
|
-
};
|
|
211
|
-
if (r.startedAt > end)
|
|
212
|
-
continue;
|
|
213
|
-
const oStart = Math.max(start, r.startedAt);
|
|
214
|
-
const oEnd = end;
|
|
215
|
-
const overlapMs = Math.max(0, oEnd - oStart);
|
|
216
|
-
if (overlapMs > 0)
|
|
217
|
-
overlaps.push({ rec: r, overlapMs });
|
|
218
|
-
}
|
|
219
|
-
if (overlaps.length === 0)
|
|
220
|
-
return "";
|
|
221
|
-
overlaps.sort((a, b) => b.overlapMs - a.overlapMs);
|
|
222
|
-
const top = overlaps.slice(0, 4).map(({ rec, overlapMs }) => {
|
|
223
|
-
const d = rec.detail ? `(${rec.detail})` : "";
|
|
224
|
-
return `${rec.name}${d}:${overlapMs}ms`;
|
|
225
|
-
});
|
|
226
|
-
return ` spanOverlaps=${top.join(",")}`;
|
|
227
|
-
}
|
|
228
|
-
export function getPerfSpanStats() {
|
|
229
|
-
const activeDepth = getSpanState().stack.length;
|
|
230
|
-
const historySize = getHistoryState().records.length;
|
|
231
|
-
return { activeDepth, historySize };
|
|
232
|
-
}
|
|
233
|
-
export function perfLog(line) {
|
|
234
|
-
writePerfLine(line);
|
|
235
|
-
}
|
|
236
|
-
//# sourceMappingURL=perf-log.js.map
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { ApprovalRequest, ToolResult } from "../model.js";
|
|
2
|
-
type ToolApprovalEventLike = Readonly<{
|
|
3
|
-
actionId: string;
|
|
4
|
-
args?: unknown;
|
|
5
|
-
availableScopes?: readonly unknown[];
|
|
6
|
-
payload?: unknown;
|
|
7
|
-
permission?: unknown;
|
|
8
|
-
reason?: unknown;
|
|
9
|
-
riskLevel?: unknown;
|
|
10
|
-
subagentId?: unknown;
|
|
11
|
-
toolCallId?: unknown;
|
|
12
|
-
toolName?: unknown;
|
|
13
|
-
}>;
|
|
14
|
-
type ToolFinishedEventLike = Readonly<{
|
|
15
|
-
errorCode?: string;
|
|
16
|
-
failureKind?: string;
|
|
17
|
-
isError?: boolean;
|
|
18
|
-
output: unknown;
|
|
19
|
-
subagentId?: string;
|
|
20
|
-
subagentTurnId?: string;
|
|
21
|
-
toolCallId: string;
|
|
22
|
-
}>;
|
|
23
|
-
export declare function buildApprovalRequestFromEvent(event: ToolApprovalEventLike): ApprovalRequest;
|
|
24
|
-
export declare function buildToolResultFromEvent(event: ToolFinishedEventLike): ToolResult;
|
|
25
|
-
export {};
|
|
26
|
-
//# sourceMappingURL=agent-event-mappers.d.ts.map
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { canonicalToolName, isReadLikeToolName, isSearchLikeToolName, isShellLikeToolName, isWriteLikeToolName, } from "../tool-metadata.js";
|
|
2
|
-
import { asRecord, extractTextParts, readTrimmedString, serializeUnknown, } from "../../shared/value-normalizers.js";
|
|
3
|
-
const APPROVAL_SCOPES = new Set(["once", "session", "thread", "workspace"]);
|
|
4
|
-
function isApprovalScope(value) {
|
|
5
|
-
return typeof value === "string" && APPROVAL_SCOPES.has(value);
|
|
6
|
-
}
|
|
7
|
-
function inferApprovalPermission(toolName, payload) {
|
|
8
|
-
const kind = readTrimmedString(payload.kind)?.toLowerCase() ?? "";
|
|
9
|
-
if (kind === "read" || isReadLikeToolName(toolName) || isSearchLikeToolName(toolName)) {
|
|
10
|
-
return "pass";
|
|
11
|
-
}
|
|
12
|
-
return "require_action";
|
|
13
|
-
}
|
|
14
|
-
function inferApprovalRiskLevel(permission, toolName, payload) {
|
|
15
|
-
if (permission === "pass")
|
|
16
|
-
return "safe";
|
|
17
|
-
const kind = readTrimmedString(payload.kind)?.toLowerCase() ?? "";
|
|
18
|
-
if (kind === "edit" || isWriteLikeToolName(toolName))
|
|
19
|
-
return "high";
|
|
20
|
-
if (kind === "execute" || isShellLikeToolName(toolName))
|
|
21
|
-
return "critical";
|
|
22
|
-
return "medium";
|
|
23
|
-
}
|
|
24
|
-
function normalizeApprovalRiskLevel(value) {
|
|
25
|
-
const riskLevel = readTrimmedString(value);
|
|
26
|
-
return riskLevel === "safe" ||
|
|
27
|
-
riskLevel === "low" ||
|
|
28
|
-
riskLevel === "medium" ||
|
|
29
|
-
riskLevel === "high" ||
|
|
30
|
-
riskLevel === "critical"
|
|
31
|
-
? riskLevel
|
|
32
|
-
: undefined;
|
|
33
|
-
}
|
|
34
|
-
function readToolApprovalRequiredEventMetadata(event) {
|
|
35
|
-
const permission = event.permission === "pass" || event.permission === "require_action"
|
|
36
|
-
? event.permission
|
|
37
|
-
: undefined;
|
|
38
|
-
const availableScopes = Array.isArray(event.availableScopes)
|
|
39
|
-
? event.availableScopes.filter(isApprovalScope)
|
|
40
|
-
: undefined;
|
|
41
|
-
const rawArgs = asRecord(event.args);
|
|
42
|
-
const args = Object.keys(rawArgs).length > 0 ? rawArgs : undefined;
|
|
43
|
-
const reason = readTrimmedString(event.reason);
|
|
44
|
-
const riskLevel = normalizeApprovalRiskLevel(event.riskLevel);
|
|
45
|
-
const subagentId = readTrimmedString(event.subagentId);
|
|
46
|
-
return {
|
|
47
|
-
...(args ? { args } : {}),
|
|
48
|
-
...(availableScopes && availableScopes.length > 0 ? { availableScopes } : {}),
|
|
49
|
-
...(permission ? { permission } : {}),
|
|
50
|
-
...(reason ? { reason } : {}),
|
|
51
|
-
...(riskLevel ? { riskLevel } : {}),
|
|
52
|
-
...(subagentId ? { subagentId } : {}),
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
export function buildApprovalRequestFromEvent(event) {
|
|
56
|
-
const payload = asRecord(event.payload);
|
|
57
|
-
const acpToolCall = asRecord(payload.acpToolCall);
|
|
58
|
-
const toolName = canonicalToolName(readTrimmedString(event.toolName) ??
|
|
59
|
-
readTrimmedString(acpToolCall.title) ??
|
|
60
|
-
readTrimmedString(acpToolCall.toolCallId) ??
|
|
61
|
-
"tool");
|
|
62
|
-
const args = asRecord(acpToolCall.rawInput);
|
|
63
|
-
const metadata = readToolApprovalRequiredEventMetadata(event);
|
|
64
|
-
const permission = metadata.permission ?? inferApprovalPermission(toolName, acpToolCall);
|
|
65
|
-
const reason = metadata.reason ??
|
|
66
|
-
readTrimmedString(payload.message) ??
|
|
67
|
-
readTrimmedString(acpToolCall.title) ??
|
|
68
|
-
`Approval required to execute ${toolName}`;
|
|
69
|
-
const riskLevel = metadata.riskLevel ?? inferApprovalRiskLevel(permission, toolName, acpToolCall);
|
|
70
|
-
const eventArgs = metadata.args ?? {};
|
|
71
|
-
const resolvedArgs = Object.keys(eventArgs).length > 0 ? eventArgs : args;
|
|
72
|
-
const availableScopes = metadata.availableScopes ?? [];
|
|
73
|
-
return {
|
|
74
|
-
id: event.actionId,
|
|
75
|
-
...(metadata.subagentId ? { subagentId: metadata.subagentId } : {}),
|
|
76
|
-
toolCallId: readTrimmedString(event.toolCallId) ??
|
|
77
|
-
readTrimmedString(acpToolCall.toolCallId) ??
|
|
78
|
-
event.actionId,
|
|
79
|
-
tool: toolName,
|
|
80
|
-
permission,
|
|
81
|
-
reason,
|
|
82
|
-
...(Object.keys(resolvedArgs).length > 0 ? { args: resolvedArgs } : {}),
|
|
83
|
-
...(availableScopes.length > 0 ? { availableScopes } : {}),
|
|
84
|
-
source: "runtime",
|
|
85
|
-
riskLevel,
|
|
86
|
-
status: "pending",
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
export function buildToolResultFromEvent(event) {
|
|
90
|
-
const outputRecord = asRecord(event.output);
|
|
91
|
-
const structuredContent = outputRecord.structuredContent && typeof outputRecord.structuredContent === "object"
|
|
92
|
-
? outputRecord.structuredContent
|
|
93
|
-
: undefined;
|
|
94
|
-
const textFromContent = extractTextParts(outputRecord.content).join("\n");
|
|
95
|
-
const output = readTrimmedString(outputRecord.output) ??
|
|
96
|
-
readTrimmedString(textFromContent) ??
|
|
97
|
-
serializeUnknown(event.output);
|
|
98
|
-
return {
|
|
99
|
-
toolCallId: event.toolCallId,
|
|
100
|
-
output,
|
|
101
|
-
...(event.errorCode ? { errorCode: event.errorCode } : {}),
|
|
102
|
-
...(event.failureKind ? { failureKind: event.failureKind } : {}),
|
|
103
|
-
...(event.subagentId ? { subagentId: event.subagentId } : {}),
|
|
104
|
-
...(event.subagentTurnId ? { subagentTurnId: event.subagentTurnId } : {}),
|
|
105
|
-
status: event.isError ? "error" : "success",
|
|
106
|
-
...(structuredContent ? { structuredContent } : {}),
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
//# sourceMappingURL=agent-event-mappers.js.map
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import type { ApprovalRequest, LlmMetaChangedFile, Message, ToolResult } from "../model.js";
|
|
2
|
-
import type { ComputedRef } from "vue";
|
|
3
|
-
interface MessageStoreState {
|
|
4
|
-
messages: Message[];
|
|
5
|
-
sessionHistoryDirty?: boolean;
|
|
6
|
-
revertedMessages: Message[];
|
|
7
|
-
userHistory: string[];
|
|
8
|
-
layoutDirtyMessageId: string | null;
|
|
9
|
-
layoutDirtySeq: number;
|
|
10
|
-
ui?: {
|
|
11
|
-
subagentSpinnerFrame?: number;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
type MessageMutationHooks = Readonly<{
|
|
15
|
-
onMessageAdded?: (message: Message) => void;
|
|
16
|
-
onMessageReplaced?: (prev: Message, next: Message) => void;
|
|
17
|
-
onMessagesRemoved?: (removed: Message[]) => void;
|
|
18
|
-
onMessagesRestored?: (restored: Message[]) => void;
|
|
19
|
-
}>;
|
|
20
|
-
export declare function createMessageMutations(state: MessageStoreState, hooks?: MessageMutationHooks): Readonly<{
|
|
21
|
-
pushMessage: (m: Message) => void;
|
|
22
|
-
setSessionHistoryDirty: (value: boolean) => void;
|
|
23
|
-
replaceMessage: (messageId: string, next: Message) => void;
|
|
24
|
-
updateAssistant: (messageId: string, fn: (m: Extract<Message, {
|
|
25
|
-
role: "assistant";
|
|
26
|
-
}>) => Extract<Message, {
|
|
27
|
-
role: "assistant";
|
|
28
|
-
}>) => void;
|
|
29
|
-
updateAssistantHidden: (messageId: string, fn: (m: Extract<Message, {
|
|
30
|
-
role: "assistant";
|
|
31
|
-
}>) => Extract<Message, {
|
|
32
|
-
role: "assistant";
|
|
33
|
-
}>) => void;
|
|
34
|
-
setAssistantStatus: (messageId: string, text: string) => void;
|
|
35
|
-
setAssistantThinking: (assistantId: string, content: string, partId: string) => void;
|
|
36
|
-
startNewThinkingBlock: (assistantId: string, partId: string) => void;
|
|
37
|
-
endThinkingBlock: (assistantId: string, partId: string, content?: string) => void;
|
|
38
|
-
appendAssistantMarkdown: (assistantId: string, delta: string) => void;
|
|
39
|
-
appendInfoPart: (assistantId: string, text: string, meta?: Readonly<Record<string, unknown>>) => void;
|
|
40
|
-
upsertSubagentInfo: (assistantId: string, subagentId: string, kind: "header" | "activity" | "finished", text: string, meta?: Readonly<{
|
|
41
|
-
subagentStream?: string;
|
|
42
|
-
subagentTurnId?: string;
|
|
43
|
-
}>) => void;
|
|
44
|
-
upsertSubagentInfoBatch: (assistantId: string, items: readonly {
|
|
45
|
-
subagentId: string;
|
|
46
|
-
kind: "header" | "activity" | "finished";
|
|
47
|
-
text: string;
|
|
48
|
-
meta?: Readonly<{
|
|
49
|
-
subagentStream?: string;
|
|
50
|
-
subagentTurnId?: string;
|
|
51
|
-
}>;
|
|
52
|
-
}[]) => void;
|
|
53
|
-
compactSettledSubagentTranscript: (assistantId: string) => void;
|
|
54
|
-
tickSubagentFrame: (assistantId: string) => void;
|
|
55
|
-
appendAssistantLlmMeta: (assistantId: string, info: Readonly<{
|
|
56
|
-
durationMs: number;
|
|
57
|
-
modelId?: string;
|
|
58
|
-
toolCalls?: number;
|
|
59
|
-
tokensUsed?: number;
|
|
60
|
-
changedFiles?: readonly string[];
|
|
61
|
-
changedFileDetails?: readonly LlmMetaChangedFile[];
|
|
62
|
-
isFinalRound?: boolean;
|
|
63
|
-
}>) => void;
|
|
64
|
-
updateAssistantLlmMeta: (assistantId: string, info: Readonly<{
|
|
65
|
-
durationMs?: number;
|
|
66
|
-
modelId?: string;
|
|
67
|
-
toolCalls?: number;
|
|
68
|
-
tokensUsed?: number;
|
|
69
|
-
changedFiles?: readonly string[];
|
|
70
|
-
changedFileDetails?: readonly LlmMetaChangedFile[];
|
|
71
|
-
}>) => void;
|
|
72
|
-
upsertToolCallDelta: (assistantId: string, callId: string, toolName: string | undefined, argsTextDelta: string | undefined, linesWritten?: number, meta?: Readonly<{
|
|
73
|
-
subagentId?: string;
|
|
74
|
-
subagentTurnId?: string;
|
|
75
|
-
startedAtMs?: number;
|
|
76
|
-
}>) => void;
|
|
77
|
-
upsertToolCallEnd: (assistantId: string, callId: string, toolName: string, args: Record<string, unknown>, thoughtSignature?: string, meta?: Readonly<{
|
|
78
|
-
subagentId?: string;
|
|
79
|
-
subagentTurnId?: string;
|
|
80
|
-
startedAtMs?: number;
|
|
81
|
-
}>) => void;
|
|
82
|
-
upsertToolOutputStart: (assistantId: string, toolCallId: string, toolName: string, meta?: Readonly<{
|
|
83
|
-
subagentId?: string;
|
|
84
|
-
subagentTurnId?: string;
|
|
85
|
-
}>) => void;
|
|
86
|
-
appendToolOutputDelta: (assistantId: string, toolCallId: string, toolName: string, delta: string, meta?: Readonly<{
|
|
87
|
-
subagentId?: string;
|
|
88
|
-
subagentTurnId?: string;
|
|
89
|
-
}>) => void;
|
|
90
|
-
attachToolResultPart: (assistantId: string, result: ToolResult, meta?: Readonly<{
|
|
91
|
-
subagentId?: string;
|
|
92
|
-
}>) => void;
|
|
93
|
-
insertApprovalPart: (assistantId: string, request: ApprovalRequest) => void;
|
|
94
|
-
toggleChecklist: (messageId: string, partType: "todo" | "plan", itemId: string) => void;
|
|
95
|
-
toggleBlockCollapsed: (messageId: string, partType: "todo" | "plan" | "thinking", partId: string) => void;
|
|
96
|
-
revertFromMessage: (messageId: string) => number;
|
|
97
|
-
restoreRevertedMessages: () => number;
|
|
98
|
-
clearRevertedMessages: () => void;
|
|
99
|
-
rebuildUserHistory: () => void;
|
|
100
|
-
hasRevertedMessages: ComputedRef<boolean>;
|
|
101
|
-
revertedMessageCount: ComputedRef<number>;
|
|
102
|
-
upsertChecklistPartFromDimSdk: (assistantId: string, kind: "todo" | "plan", toolCallId: string, structured: unknown) => void;
|
|
103
|
-
}>;
|
|
104
|
-
export {};
|
|
105
|
-
//# sourceMappingURL=message-mutations.d.ts.map
|