@best-agent/cli 0.0.2-beta.8 → 0.0.3-beta.1

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.
Files changed (70) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +44 -181
  3. package/dist/launcher.js +32 -0
  4. package/package.json +15 -27
  5. package/dist/best-agent-native-bridge.d.ts +0 -389
  6. package/dist/best-agent-native-bridge.js +0 -4645
  7. package/dist/cli-storage.d.ts +0 -5
  8. package/dist/cli-storage.js +0 -7
  9. package/dist/dimsdk/ask-user.d.ts +0 -21
  10. package/dist/dimsdk/ask-user.js +0 -131
  11. package/dist/dimsdk/cli/version.d.ts +0 -6
  12. package/dist/dimsdk/cli/version.js +0 -36
  13. package/dist/dimsdk/compat/archships/dim-agent/runtime-host.d.ts +0 -49
  14. package/dist/dimsdk/compat/archships/dim-agent/runtime-host.js +0 -215
  15. package/dist/dimsdk/compat/runtime-host.d.ts +0 -2
  16. package/dist/dimsdk/compat/runtime-host.js +0 -2
  17. package/dist/dimsdk/core/debug-log.d.ts +0 -8
  18. package/dist/dimsdk/core/debug-log.js +0 -100
  19. package/dist/dimsdk/core/env.d.ts +0 -26
  20. package/dist/dimsdk/core/env.js +0 -130
  21. package/dist/dimsdk/core/markdown/sanitize.d.ts +0 -2
  22. package/dist/dimsdk/core/markdown/sanitize.js +0 -43
  23. package/dist/dimsdk/core/markdown/wrap.d.ts +0 -9
  24. package/dist/dimsdk/core/markdown/wrap.js +0 -139
  25. package/dist/dimsdk/core/markdown.d.ts +0 -18
  26. package/dist/dimsdk/core/markdown.js +0 -62
  27. package/dist/dimsdk/core/model.d.ts +0 -273
  28. package/dist/dimsdk/core/model.js +0 -16
  29. package/dist/dimsdk/core/observability/perf-log.d.ts +0 -18
  30. package/dist/dimsdk/core/observability/perf-log.js +0 -236
  31. package/dist/dimsdk/core/store/agent-event-mappers.d.ts +0 -26
  32. package/dist/dimsdk/core/store/agent-event-mappers.js +0 -109
  33. package/dist/dimsdk/core/store/message-mutations.d.ts +0 -105
  34. package/dist/dimsdk/core/store/message-mutations.js +0 -1528
  35. package/dist/dimsdk/core/store/semantic-readers.d.ts +0 -2
  36. package/dist/dimsdk/core/store/semantic-readers.js +0 -4
  37. package/dist/dimsdk/core/store/transcript-projector.d.ts +0 -164
  38. package/dist/dimsdk/core/store/transcript-projector.js +0 -580
  39. package/dist/dimsdk/core/tool-metadata.d.ts +0 -12
  40. package/dist/dimsdk/core/tool-metadata.js +0 -70
  41. package/dist/dimsdk/core/transcript-part-id.d.ts +0 -6
  42. package/dist/dimsdk/core/transcript-part-id.js +0 -22
  43. package/dist/dimsdk/i18n/index.d.ts +0 -18
  44. package/dist/dimsdk/i18n/index.js +0 -141
  45. package/dist/dimsdk/i18n/locales/en.d.ts +0 -988
  46. package/dist/dimsdk/i18n/locales/en.js +0 -987
  47. package/dist/dimsdk/i18n/locales/index.d.ts +0 -1976
  48. package/dist/dimsdk/i18n/locales/index.js +0 -8
  49. package/dist/dimsdk/i18n/locales/zh-CN.d.ts +0 -988
  50. package/dist/dimsdk/i18n/locales/zh-CN.js +0 -987
  51. package/dist/dimsdk/i18n/types.d.ts +0 -13
  52. package/dist/dimsdk/i18n/types.js +0 -2
  53. package/dist/dimsdk/shared/value-normalizers.d.ts +0 -7
  54. package/dist/dimsdk/shared/value-normalizers.js +0 -48
  55. package/dist/dimsdk-tui.bundle-size.json +0 -169
  56. package/dist/dimsdk-tui.bundle.js +0 -330756
  57. package/dist/goatchain-adapter.d.ts +0 -41
  58. package/dist/goatchain-adapter.js +0 -499
  59. package/dist/index.d.ts +0 -3
  60. package/dist/index.js +0 -1405
  61. package/dist/native-runtime-bridge.d.ts +0 -387
  62. package/dist/native-runtime-bridge.js +0 -4624
  63. package/dist/provider-config-env.d.ts +0 -7
  64. package/dist/provider-config-env.js +0 -286
  65. package/dist/provider-model-limit-index.generated.d.ts +0 -3
  66. package/dist/provider-model-limit-index.generated.js +0 -7818
  67. package/dist/provider-model-limits.d.ts +0 -8
  68. package/dist/provider-model-limits.js +0 -43
  69. package/dist/runtime.d.ts +0 -47
  70. package/dist/runtime.js +0 -516
@@ -1,387 +0,0 @@
1
- import type { AgentRuntime } from "@best-agent/engine";
2
- import type { ServerEvent, ThreadDetail, ThreadId, ThreadMode } from "@best-agent/protocol";
3
- import type { Message } from "./dimsdk/core/model.js";
4
- import type { TranscriptSessionEvent } from "./dimsdk/core/store/transcript-projector.js";
5
- type CliModeId = "agent" | "plan";
6
- type RuntimeConfigLike = Readonly<{
7
- adapter?: string;
8
- apiKey?: string;
9
- baseUrl?: string;
10
- env?: Record<string, string | undefined>;
11
- maxInputTokens?: number;
12
- maxOutputTokens?: number;
13
- modelId?: string;
14
- nextApiOAuth?: boolean;
15
- provider?: string;
16
- }>;
17
- type ToolApprovalMode = "always" | "auto" | "normal" | "strict";
18
- type EnsureSessionInput = Readonly<{
19
- sessionId?: string;
20
- cwd?: string;
21
- modeId?: CliModeId;
22
- runtimeConfig?: RuntimeConfigLike;
23
- toolApprovalMode?: ToolApprovalMode;
24
- mcpServers?: readonly Record<string, unknown>[];
25
- metadata?: Record<string, unknown>;
26
- }>;
27
- type LastRequestBudget = Readonly<{
28
- runId?: string;
29
- requestId?: string;
30
- autoBudgetOutcome: "budget-unknown" | "compacted" | "failed-to-fit" | "not-needed";
31
- autoBudgetReasonCode?: string;
32
- budgetSource?: string;
33
- contextWindowTokens?: number;
34
- estimatedInputTokens: number;
35
- inputBudgetTokens?: number;
36
- maxOutputTokens?: number;
37
- protocolReserveTokens?: number;
38
- reservedOutputTokens?: number;
39
- thresholdTokens?: number;
40
- maxInputTokens?: number;
41
- triggerRatio?: number;
42
- usedAutoCompaction: boolean;
43
- updatedAt?: string;
44
- updatedAtMs: number;
45
- }>;
46
- type SessionQueueStatus = "idle" | "running" | "paused_confirm" | "error";
47
- type SessionQueueErrorCode = "network_error" | "timeout" | "canceled_by_user" | "rate_limited" | "config_unavailable" | "unknown";
48
- type SessionQueueItem = Readonly<{
49
- id: string;
50
- text: string;
51
- createdAt: number;
52
- kind: "user" | "steer";
53
- steeredAt?: number;
54
- config?: Readonly<{
55
- model?: string;
56
- temperature?: number;
57
- interleavedThinking?: boolean;
58
- approvalsMode?: ToolApprovalMode;
59
- providerId?: string;
60
- }>;
61
- }>;
62
- type BridgeUsageUpdate = Readonly<{
63
- completionTokens: number;
64
- promptTokens: number;
65
- totalTokens: number;
66
- reasoningTokens?: number;
67
- }>;
68
- type BridgeBudgetUpdate = LastRequestBudget | NonNullable<Extract<ServerEvent, {
69
- type: "thread.usage.updated";
70
- }>["lastRequestBudget"]>;
71
- type BridgeSessionUiMetadata = {
72
- lastErrorCode?: SessionQueueErrorCode;
73
- lastUpdatedAt: number;
74
- pinnedMessageIds: string[];
75
- queue: SessionQueueItem[];
76
- queueLength: number;
77
- reasoningDiagnosticsByTurn: ReasoningDiagnosticsByTurn;
78
- status: SessionQueueStatus;
79
- titleSuggestedAt?: number;
80
- };
81
- type StoreUsageState = {
82
- completion_tokens?: number;
83
- prompt_tokens?: number;
84
- total_tokens?: number;
85
- };
86
- export type BridgeMessage = Message;
87
- type ManualCompactionResult = Readonly<{
88
- error?: string;
89
- errorCode?: string;
90
- event?: {
91
- diagnostics?: {
92
- notification?: {
93
- maxInputTokens?: number;
94
- thresholdTokens?: number;
95
- };
96
- };
97
- tokensBefore?: number;
98
- tokensAfter?: number;
99
- };
100
- messageCount?: number;
101
- success: boolean;
102
- }>;
103
- type CliSession = Readonly<{
104
- id: string;
105
- run: (input: Readonly<{
106
- content: unknown;
107
- metadata?: Record<string, unknown>;
108
- }>, options?: Readonly<{
109
- signal?: AbortSignal;
110
- }>) => AsyncGenerator<NativeSessionEvent, void, void>;
111
- resume: (input: Readonly<{
112
- kind: "tool_approval" | "ask_user";
113
- actionId: string;
114
- toolCallId?: string;
115
- approved?: boolean;
116
- alwaysAllowForConversation?: boolean;
117
- answers?: Record<string, string | string[]>;
118
- rejected?: boolean;
119
- reason?: string;
120
- }>, options?: Readonly<{
121
- signal?: AbortSignal;
122
- }>) => AsyncGenerator<NativeSessionEvent, void, void>;
123
- setMode: (modeId: CliModeId) => Promise<void>;
124
- steer: (input: string) => Promise<boolean>;
125
- triggerManualCompaction: () => Promise<ManualCompactionResult>;
126
- updateConfig: (input: Record<string, unknown>) => Promise<void>;
127
- }>;
128
- type CliAgentBridge = Readonly<{
129
- sessions?: Readonly<{
130
- create: () => Promise<CliSession>;
131
- destroy: (sessionId: string) => Promise<void>;
132
- get: (sessionId: string) => Promise<ThreadDetail | null>;
133
- interrupt: (sessionId: string) => Promise<boolean>;
134
- list: () => Promise<ThreadDetail[]>;
135
- rename: (sessionId: string, title: string) => Promise<void>;
136
- updateMetadata: (sessionId: string, metadata: Record<string, unknown>) => Promise<void>;
137
- }>;
138
- openSession?: (sessionId: string) => Promise<CliSession | null>;
139
- ensureSession?: (opts?: EnsureSessionInput) => Promise<CliSession>;
140
- steerSession?: (sessionId: string, input: string) => Promise<boolean>;
141
- setMode?: (modeId: CliModeId) => void;
142
- getMode?: () => CliModeId;
143
- triggerManualCompression?: (sessionId?: string) => Promise<ManualCompactionResult>;
144
- invalidateSession?: (sessionId: string) => void;
145
- }>;
146
- type ReasoningDiagnostics = Readonly<{
147
- state: "visible" | "tokens_only" | "none";
148
- }>;
149
- type ReasoningDiagnosticState = ReasoningDiagnostics["state"];
150
- type ReasoningDiagnosticsByTurn = Record<string, ReasoningDiagnosticState>;
151
- type NativeSessionEvent = TranscriptSessionEvent | Readonly<{
152
- type: "steer_injected";
153
- content: string;
154
- createdAtMs?: number;
155
- }> | Readonly<{
156
- type: "context.compression";
157
- state: "completed" | "started";
158
- trigger: "auto" | "manual";
159
- threshold?: number;
160
- tokensBefore?: number;
161
- tokensAfter?: number;
162
- diagnostics?: Record<string, unknown>;
163
- }> | Readonly<{
164
- type: "usage.updated";
165
- usage?: BridgeUsageUpdate;
166
- lastRequestBudget?: BridgeBudgetUpdate;
167
- }> | Readonly<{
168
- type: "run.finished";
169
- status: "completed" | "interrupted";
170
- reasoningDiagnostics: ReasoningDiagnostics;
171
- usage?: BridgeUsageUpdate;
172
- }> | Readonly<{
173
- type: "run.error";
174
- error: unknown;
175
- reasoningDiagnostics?: ReasoningDiagnostics;
176
- usage?: BridgeUsageUpdate;
177
- }>;
178
- type DimSdkStoreLike = {
179
- applyLastRequestBudget?: (budget: BridgeBudgetUpdate | null | undefined) => void;
180
- applyUsageFromSession?: (usage: BridgeUsageUpdate) => void;
181
- replaceMessages?: (messages: readonly BridgeMessage[]) => void;
182
- setCwd?: (cwd: string) => void;
183
- setMode?: (modeId: CliModeId) => void;
184
- state: {
185
- approval?: {
186
- active: unknown;
187
- pendingAutoRun: unknown;
188
- skipApproval?: boolean;
189
- };
190
- context: {
191
- cwd: string;
192
- env: Record<string, string | undefined>;
193
- focusFiles?: readonly string[];
194
- system: string;
195
- };
196
- chromeVersion?: number;
197
- messages: BridgeMessage[];
198
- paused: unknown;
199
- revertedMessages?: BridgeMessage[];
200
- runningAgentRound?: boolean;
201
- runningToolCallId?: string | null;
202
- sessionId: string;
203
- sessionMeta?: BridgeSessionUiMetadata;
204
- usage?: StoreUsageState;
205
- lastRequestBudget?: LastRequestBudget | null;
206
- ui?: {
207
- activeSubagentIds?: string[];
208
- mode?: CliModeId;
209
- restore?: {
210
- status: "idle" | "loading" | "error";
211
- sessionId: string;
212
- };
213
- };
214
- userHistory?: string[];
215
- thinking?: {
216
- active: boolean;
217
- endedAt: number | null;
218
- startedAt: number | null;
219
- };
220
- };
221
- };
222
- export type BestAgentSessionsApi = Readonly<{
223
- list: () => Promise<ReadonlyArray<{
224
- id: string;
225
- updatedAt: number;
226
- cwd?: string;
227
- title: string;
228
- summary: string;
229
- messageCount: number;
230
- lastMessage?: string;
231
- status?: string;
232
- queueLength?: number;
233
- queue?: readonly SessionQueueItem[];
234
- lastUpdatedAt?: number;
235
- reasoningDiagnosticsByTurn?: ReasoningDiagnosticsByTurn;
236
- }>>;
237
- get?: (id: string, options?: Readonly<{
238
- includeMessages?: boolean;
239
- }>) => Promise<(ThreadDetail & {
240
- messages?: BridgeMessage[];
241
- }) | null>;
242
- trace?: (id: string) => Promise<BestAgentSessionTrace | null>;
243
- subagent?: (id: string) => Promise<BestAgentSubagentDetail | null>;
244
- watchSubagent?: (id: string, options: Readonly<{
245
- turnId?: string;
246
- }>, onEvent: (event: BestAgentSubagentLiveEvent) => void) => () => void;
247
- steerSubagent?: (id: string, turnId: string, prompt: string) => Promise<BestAgentSubagentSteerResult>;
248
- loadMoreHistory?: (id: string) => Promise<boolean>;
249
- reload?: (id: string) => Promise<boolean>;
250
- use: (id: string) => Promise<void>;
251
- createNew: () => Promise<void>;
252
- delete: (id: string) => Promise<void>;
253
- rename?: (id: string, title: string) => Promise<void>;
254
- fork?: (opts: Readonly<{
255
- messages: readonly BridgeMessage[];
256
- }>) => Promise<void>;
257
- updateMetadata?: (id: string, metadata: Record<string, unknown>) => Promise<void>;
258
- }>;
259
- type BestAgentSubagentLine = Readonly<{
260
- id: string;
261
- at?: number;
262
- kind: "message" | "reasoning" | "tool-call" | "tool-result" | "error" | "control";
263
- label: string;
264
- text: string;
265
- }>;
266
- type BestAgentSubagentPendingSteer = Readonly<{
267
- id: string;
268
- text: string;
269
- createdAt?: number;
270
- }>;
271
- type BestAgentSubagentDetail = Readonly<{
272
- threadId: string;
273
- title: string;
274
- status: BestAgentSubagentStatus;
275
- activeTurnId?: string;
276
- steerable: boolean;
277
- generatedAt: number;
278
- itemCount: number;
279
- toolCallCount: number;
280
- messageCount: number;
281
- eventCount: number;
282
- pausedReason?: string;
283
- requestId?: string;
284
- lines: readonly BestAgentSubagentLine[];
285
- messages: readonly BridgeMessage[];
286
- pendingSteers?: readonly BestAgentSubagentPendingSteer[];
287
- }>;
288
- type BestAgentSubagentStatus = "running" | "paused" | "completed" | "failed" | "interrupted" | "blocked" | "unknown";
289
- type BestAgentSubagentSteerResult = Readonly<{
290
- ok: true;
291
- status: BestAgentSubagentStatus;
292
- }> | Readonly<{
293
- ok: false;
294
- message?: string;
295
- status?: BestAgentSubagentStatus;
296
- }>;
297
- type BestAgentSubagentLiveEvent = TranscriptSessionEvent | Readonly<{
298
- type: "steer_queued";
299
- id?: string;
300
- content: string;
301
- createdAtMs?: number;
302
- }> | Readonly<{
303
- type: "steer_injected";
304
- content: string;
305
- createdAtMs?: number;
306
- }> | Readonly<{
307
- type: "subagent.status";
308
- status: BestAgentSubagentStatus;
309
- activeTurnId?: string;
310
- eventCount?: number;
311
- itemCount?: number;
312
- messageCount?: number;
313
- steerable?: boolean;
314
- toolCallCount?: number;
315
- }>;
316
- type BestAgentSessionTrace = Readonly<{
317
- threadId: string;
318
- generatedAt: number;
319
- eventCount: number;
320
- processes?: ReadonlyArray<BestAgentSessionTraceProcess>;
321
- requests: ReadonlyArray<{
322
- id: string;
323
- index: number;
324
- kind: "turn" | "session";
325
- status: string;
326
- turnId?: string;
327
- startedAt?: number;
328
- completedAt?: number;
329
- promptPreview?: string;
330
- assistantPreview?: string;
331
- userMessageCount: number;
332
- assistantMessageCount: number;
333
- toolCallCount: number;
334
- childTaskCount: number;
335
- compactionCount: number;
336
- runCount: number;
337
- eventCount: number;
338
- events: ReadonlyArray<{
339
- sequence: number;
340
- at: number;
341
- type: string;
342
- summary: string;
343
- }>;
344
- }>;
345
- }>;
346
- type BestAgentSessionTraceProcess = Readonly<{
347
- command: string;
348
- completedAt?: string;
349
- cwd: string;
350
- descendantPids: ReadonlyArray<number>;
351
- evictedAt?: string;
352
- exitCode: number | null;
353
- owner?: Readonly<{
354
- threadId: string;
355
- turnId: string;
356
- toolCallId?: string;
357
- }>;
358
- pid?: number;
359
- sessionId: string;
360
- signalCode?: string | null;
361
- sigkillSentAt?: string;
362
- sigtermSentAt?: string;
363
- startedAt: string;
364
- status: "running" | "completed";
365
- stopMethod?: "already-completed" | "sigterm" | "sigkill";
366
- stopRequestedAt?: string;
367
- stopVerifiedAt?: string;
368
- survivingPids?: ReadonlyArray<number>;
369
- updatedAt: string;
370
- }>;
371
- export declare function resolveInitialBestAgentThread(runtime: AgentRuntime, options: Readonly<{
372
- latest?: boolean;
373
- resumeThreadId?: string;
374
- threadMode?: ThreadMode;
375
- }>): Promise<ThreadDetail>;
376
- export declare function createBestAgentNativeBridge(options: Readonly<{
377
- agentProfile?: string;
378
- runtime: AgentRuntime;
379
- threadMode?: ThreadMode;
380
- }>): Readonly<{
381
- agent: CliAgentBridge;
382
- attachStore: (store: DimSdkStoreLike) => void;
383
- hydrateThread: (threadId: ThreadId) => Promise<BridgeMessage[]>;
384
- sessions: BestAgentSessionsApi;
385
- }>;
386
- export {};
387
- //# sourceMappingURL=native-runtime-bridge.d.ts.map