@coda-console/kimi 0.0.0 → 1.2.2
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/agent/binary.mjs +11 -0
- package/agent/entry.mjs +20 -0
- package/agent/errors.mjs +16 -0
- package/agent/instructions.mjs +68 -0
- package/agent/lines.mjs +42 -0
- package/agent/observe.mjs +327 -0
- package/agent/relay.mjs +106 -0
- package/agent/subagents.mjs +323 -0
- package/agent/waits.mjs +153 -0
- package/icons/README.md +15 -0
- package/icons/kimi-dark.pdf +0 -0
- package/icons/kimi-dark.svg +5 -0
- package/icons/kimi-light.pdf +0 -0
- package/icons/kimi-light.svg +5 -0
- package/package.json +52 -3
- package/scripts/install.sh +6 -0
- package/scripts/login.sh +8 -0
- package/scripts/panel.mjs +37 -0
- package/scripts/quota.mjs +39 -0
- package/scripts/setup.mjs +41 -0
- package/scripts/web.mjs +72 -0
- package/README.md +0 -3
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { readdir } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
|
|
4
|
+
function toolKind(name) {
|
|
5
|
+
const n = String(name ?? '').toLowerCase();
|
|
6
|
+
if (['bash', 'terminal', 'sh', 'exec', 'command'].includes(n)) return 'execute';
|
|
7
|
+
if (['read', 'cat', 'view'].includes(n)) return 'read';
|
|
8
|
+
if (['write', 'edit', 'replace'].includes(n)) return 'edit';
|
|
9
|
+
return 'other';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function findTaskForTime(taskList, time) {
|
|
13
|
+
if (!taskList.length) return null;
|
|
14
|
+
if (!Number.isFinite(time)) {
|
|
15
|
+
const running = taskList.find(t => t.status === 'running');
|
|
16
|
+
return running || taskList[taskList.length - 1];
|
|
17
|
+
}
|
|
18
|
+
for (let i = 0; i < taskList.length; i++) {
|
|
19
|
+
const task = taskList[i];
|
|
20
|
+
if (Number.isFinite(task.startedAt)) {
|
|
21
|
+
if (i > 0) {
|
|
22
|
+
const prevTask = taskList[i - 1];
|
|
23
|
+
if (Number.isFinite(prevTask.endedAt)) {
|
|
24
|
+
if (time <= prevTask.endedAt) continue;
|
|
25
|
+
const minBound = Math.max(task.startedAt - 5000, prevTask.endedAt + 1);
|
|
26
|
+
if (time < minBound) continue;
|
|
27
|
+
} else {
|
|
28
|
+
if (time < task.startedAt) continue;
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
const minBound = task.startedAt - 5000;
|
|
32
|
+
if (time < minBound) continue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (Number.isFinite(task.endedAt)) {
|
|
36
|
+
if (time > task.endedAt) continue;
|
|
37
|
+
} else if (i + 1 < taskList.length && Number.isFinite(taskList[i + 1].startedAt)) {
|
|
38
|
+
if (time >= taskList[i + 1].startedAt) continue;
|
|
39
|
+
}
|
|
40
|
+
return task;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// What Kimi's subagents say in their own wires, told as updates of their own sessions (each subagent's is its agent id), a
|
|
47
|
+
// run (a task generation) at a time; and the runs its main agent's wire tells of without a task file. A run from before this
|
|
48
|
+
// agent process started (`startedAt`) is another process's: what it said is not told again.
|
|
49
|
+
export class KimiSubagentBridge {
|
|
50
|
+
constructor({ session, root, readBounded, contained, startedAt = 0 }) {
|
|
51
|
+
this.session = session;
|
|
52
|
+
this.root = root;
|
|
53
|
+
this.emit = () => {};
|
|
54
|
+
this.readBounded = readBounded;
|
|
55
|
+
this.contained = contained;
|
|
56
|
+
this.startedAt = startedAt;
|
|
57
|
+
// Map of agentId -> subagent state
|
|
58
|
+
this.subagents = new Map();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// `emit(update, sessionId, taskId)`: what a subagent said, in which run. Returns every task: those given and those its main
|
|
62
|
+
// agent's wire adds.
|
|
63
|
+
async sync({ agents, state, tasks, signal, emit, startedAt = this.startedAt }) {
|
|
64
|
+
this.emit = emit;
|
|
65
|
+
const allTasks = await this.loadAllTasks(signal, tasks);
|
|
66
|
+
// Group all tasks per agentId and sort chronologically by startedAt ascending
|
|
67
|
+
const tasksByAgent = new Map();
|
|
68
|
+
for (const task of allTasks) {
|
|
69
|
+
if (!task.agentId || task.kind !== 'agent') continue;
|
|
70
|
+
if (!tasksByAgent.has(task.agentId)) tasksByAgent.set(task.agentId, []);
|
|
71
|
+
tasksByAgent.get(task.agentId).push(task);
|
|
72
|
+
}
|
|
73
|
+
for (const list of tasksByAgent.values()) {
|
|
74
|
+
list.sort((a, b) => (a.startedAt ?? 0) - (b.startedAt ?? 0));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
for (const agentId of agents) {
|
|
78
|
+
signal.throwIfAborted();
|
|
79
|
+
if (agentId === 'main') continue;
|
|
80
|
+
|
|
81
|
+
const agentInfo = state?.agents?.[agentId];
|
|
82
|
+
if (agentInfo && agentInfo.type !== 'sub' && !tasksByAgent.has(agentId)) continue;
|
|
83
|
+
|
|
84
|
+
const taskList = tasksByAgent.get(agentId) || [];
|
|
85
|
+
|
|
86
|
+
let sub = this.subagents.get(agentId);
|
|
87
|
+
if (!sub) {
|
|
88
|
+
sub = {
|
|
89
|
+
agentId,
|
|
90
|
+
generations: new Map(), // taskId -> { generation, subagentSessionId, completed, hasAssistantMessage, earlier }
|
|
91
|
+
linesRead: 0,
|
|
92
|
+
emittedIds: new Set(),
|
|
93
|
+
};
|
|
94
|
+
this.subagents.set(agentId, sub);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
for (let i = 0; i < taskList.length; i++) {
|
|
98
|
+
const task = taskList[i];
|
|
99
|
+
const genNumber = i + 1;
|
|
100
|
+
if (sub.generations.has(task.taskId)) continue;
|
|
101
|
+
sub.generations.set(task.taskId, {
|
|
102
|
+
taskId: task.taskId,
|
|
103
|
+
generation: genNumber,
|
|
104
|
+
subagentSessionId: genNumber === 1 ? agentId : `${agentId}:generation:${genNumber}`,
|
|
105
|
+
completed: false,
|
|
106
|
+
hasAssistantMessage: false,
|
|
107
|
+
earlier: !Number.isSafeInteger(task.startedAt) || task.startedAt < startedAt,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Read wire events FIRST so all tools and replies are in place before terminal settlement
|
|
112
|
+
await this.syncWireEvents(agentId, sub, taskList, signal);
|
|
113
|
+
|
|
114
|
+
// Settle terminal states and fallback output AFTER wire events are processed
|
|
115
|
+
for (let i = 0; i < taskList.length; i++) {
|
|
116
|
+
const task = taskList[i];
|
|
117
|
+
const gen = sub.generations.get(task.taskId);
|
|
118
|
+
if (!gen || gen.earlier) continue;
|
|
119
|
+
|
|
120
|
+
if (!gen.completed && task.status && task.status !== 'running') {
|
|
121
|
+
if (!gen.hasAssistantMessage) {
|
|
122
|
+
await this.syncOutputFallback(gen.subagentSessionId, task, sub, gen, signal);
|
|
123
|
+
}
|
|
124
|
+
gen.completed = true;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return allTasks;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async loadAllTasks(signal, initialTasks = []) {
|
|
132
|
+
const tasksById = new Map();
|
|
133
|
+
for (const t of initialTasks || []) {
|
|
134
|
+
if (t?.taskId) tasksById.set(t.taskId, t);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (!initialTasks || !initialTasks.length) {
|
|
138
|
+
try {
|
|
139
|
+
const mainAgent = await this.contained(this.session, join(this.session, 'agents/main'));
|
|
140
|
+
let tasksDir;
|
|
141
|
+
try { tasksDir = await this.contained(mainAgent, join(mainAgent, 'tasks')); }
|
|
142
|
+
catch (e) { if (e.code !== 'ENOENT') throw e; }
|
|
143
|
+
if (tasksDir) {
|
|
144
|
+
const files = await readdir(tasksDir, { withFileTypes: true });
|
|
145
|
+
for (const file of files) {
|
|
146
|
+
signal.throwIfAborted();
|
|
147
|
+
if (!file.isFile() || !file.name.endsWith('.json')) continue;
|
|
148
|
+
try {
|
|
149
|
+
const content = await this.readBounded(join(tasksDir, file.name), 1024 * 1024, signal);
|
|
150
|
+
const task = JSON.parse(content);
|
|
151
|
+
if (task?.taskId && task.agentId && task.kind === 'agent') tasksById.set(task.taskId, task);
|
|
152
|
+
} catch { continue; }
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
} catch (error) {
|
|
156
|
+
if (error.code !== 'ENOENT') throw error;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
try {
|
|
161
|
+
const mainAgent = await this.contained(this.session, join(this.session, 'agents/main'));
|
|
162
|
+
let wirePath;
|
|
163
|
+
try { wirePath = await this.contained(mainAgent, join(mainAgent, 'wire.jsonl')); }
|
|
164
|
+
catch (e) { if (e.code !== 'ENOENT') throw e; }
|
|
165
|
+
if (wirePath) {
|
|
166
|
+
const wireContent = await this.readBounded(wirePath, 32 * 1024 * 1024, signal);
|
|
167
|
+
const lines = wireContent.split('\n');
|
|
168
|
+
const activeTaskOnSubagent = new Map();
|
|
169
|
+
for (const line of lines) {
|
|
170
|
+
signal.throwIfAborted();
|
|
171
|
+
if (!line.trim()) continue;
|
|
172
|
+
let ev;
|
|
173
|
+
try { ev = JSON.parse(line); } catch { continue; }
|
|
174
|
+
const type = ev?.type;
|
|
175
|
+
if (type === 'subagent.spawned' && ev.subagentId) {
|
|
176
|
+
const taskId = ev.taskId || `${ev.subagentId}:${ev.time}`;
|
|
177
|
+
const agentId = ev.subagentId;
|
|
178
|
+
activeTaskOnSubagent.set(agentId, taskId);
|
|
179
|
+
const existing = tasksById.get(taskId) || {};
|
|
180
|
+
const startedAt = Number.isSafeInteger(existing.startedAt)
|
|
181
|
+
? (Number.isSafeInteger(ev.time) ? Math.min(existing.startedAt, ev.time) : existing.startedAt)
|
|
182
|
+
: (ev.time ?? null);
|
|
183
|
+
tasksById.set(taskId, {
|
|
184
|
+
taskId,
|
|
185
|
+
agentId,
|
|
186
|
+
kind: 'agent',
|
|
187
|
+
description: ev.description || existing.description || '',
|
|
188
|
+
subagentType: ev.subagentName || existing.subagentType || 'delegate',
|
|
189
|
+
parentToolCallId: ev.parentToolCallId || existing.parentToolCallId,
|
|
190
|
+
model: ev.model || existing.model,
|
|
191
|
+
startedAt,
|
|
192
|
+
status: existing.status || 'running',
|
|
193
|
+
endedAt: existing.endedAt ?? null,
|
|
194
|
+
});
|
|
195
|
+
} else if (['subagent.completed', 'subagent.failed', 'subagent.cancelled'].includes(type) && ev.subagentId) {
|
|
196
|
+
const taskId = activeTaskOnSubagent.get(ev.subagentId);
|
|
197
|
+
if (taskId && tasksById.has(taskId)) {
|
|
198
|
+
const task = tasksById.get(taskId);
|
|
199
|
+
task.status = type === 'subagent.completed' ? 'completed' : 'failed';
|
|
200
|
+
task.endedAt = ev.time || task.endedAt || Date.now();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
} catch (error) {
|
|
206
|
+
if (error.code !== 'ENOENT') throw error;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return [...tasksById.values()];
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
async syncWireEvents(agentId, sub, taskList, signal) {
|
|
213
|
+
let wirePath;
|
|
214
|
+
try {
|
|
215
|
+
const agentDir = await this.contained(this.session, join(this.session, 'agents', agentId));
|
|
216
|
+
wirePath = await this.contained(agentDir, join(agentDir, 'wire.jsonl'));
|
|
217
|
+
} catch { return; }
|
|
218
|
+
|
|
219
|
+
let content;
|
|
220
|
+
try {
|
|
221
|
+
content = await this.readBounded(wirePath, 32 * 1024 * 1024, signal);
|
|
222
|
+
} catch { return; }
|
|
223
|
+
|
|
224
|
+
const trimmed = content.endsWith('\n') ? content.slice(0, -1) : content;
|
|
225
|
+
const lines = trimmed ? trimmed.split('\n') : [];
|
|
226
|
+
const limit = content.endsWith('\n') ? lines.length : Math.max(0, lines.length - 1);
|
|
227
|
+
for (let i = sub.linesRead; i < limit; i++) {
|
|
228
|
+
signal.throwIfAborted();
|
|
229
|
+
const line = lines[i].trim();
|
|
230
|
+
if (!line) {
|
|
231
|
+
sub.linesRead = i + 1;
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
let record;
|
|
235
|
+
try { record = JSON.parse(line); } catch {
|
|
236
|
+
sub.linesRead = i + 1;
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
if (record?.type === 'context.append_loop_event' && record.event) {
|
|
240
|
+
const matchedTask = findTaskForTime(taskList, record.time);
|
|
241
|
+
if (!matchedTask) {
|
|
242
|
+
// Cannot match to any known task generation; pause consumption and retain event for next sweep
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
const taskIndex = taskList.indexOf(matchedTask);
|
|
246
|
+
const genNumber = taskIndex >= 0 ? taskIndex + 1 : 1;
|
|
247
|
+
const subagentSessionId = genNumber === 1 ? agentId : `${agentId}:generation:${genNumber}`;
|
|
248
|
+
const gen = sub.generations.get(matchedTask.taskId);
|
|
249
|
+
if (gen && !gen.earlier) this.processLoopEvent(agentId, subagentSessionId, record.event, sub, gen);
|
|
250
|
+
}
|
|
251
|
+
sub.linesRead = i + 1;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
async syncOutputFallback(subagentSessionId, task, sub, gen, signal) {
|
|
256
|
+
if (!task?.taskId) return;
|
|
257
|
+
try {
|
|
258
|
+
const mainAgent = await this.contained(this.session, join(this.session, 'agents/main'));
|
|
259
|
+
const outputPath = await this.contained(mainAgent, join(mainAgent, 'tasks', task.taskId, 'output.log'));
|
|
260
|
+
const text = await this.readBounded(outputPath, 1024 * 1024, signal);
|
|
261
|
+
if (typeof text === 'string' && text.trim()) {
|
|
262
|
+
const id = `${subagentSessionId}:output_fallback:${task.taskId}`;
|
|
263
|
+
if (!sub.emittedIds.has(id)) {
|
|
264
|
+
sub.emittedIds.add(id);
|
|
265
|
+
this.emit({ sessionUpdate: 'agent_message_chunk', messageId: id, content: { type: 'text', text } }, sub.agentId, task.taskId);
|
|
266
|
+
if (gen) gen.hasAssistantMessage = true;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
} catch { /* output.log is optional */ }
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// `subagentSessionId` names the run, for what it said; it is said in the subagent's session, `agentId`.
|
|
273
|
+
processLoopEvent(agentId, subagentSessionId, event, sub, gen) {
|
|
274
|
+
const type = event?.type;
|
|
275
|
+
if (type === 'content.part' && event.part) {
|
|
276
|
+
const part = event.part;
|
|
277
|
+
if (part.type === 'think' && typeof part.think === 'string' && part.think.trim()) {
|
|
278
|
+
const id = event.uuid || `${subagentSessionId}:think:${event.step ?? ''}:${event.turnId ?? ''}`;
|
|
279
|
+
if (!sub.emittedIds.has(id)) {
|
|
280
|
+
sub.emittedIds.add(id);
|
|
281
|
+
this.emit({ sessionUpdate: 'agent_thought_chunk', messageId: id, content: { type: 'text', text: part.think } }, agentId, gen?.taskId);
|
|
282
|
+
}
|
|
283
|
+
} else if (part.type === 'text' && typeof part.text === 'string' && part.text.trim()) {
|
|
284
|
+
const id = event.uuid || `${subagentSessionId}:text:${event.step ?? ''}:${event.turnId ?? ''}`;
|
|
285
|
+
if (!sub.emittedIds.has(id)) {
|
|
286
|
+
sub.emittedIds.add(id);
|
|
287
|
+
this.emit({ sessionUpdate: 'agent_message_chunk', messageId: id, content: { type: 'text', text: part.text } }, agentId, gen?.taskId);
|
|
288
|
+
if (gen) gen.hasAssistantMessage = true;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
} else if (type === 'tool.call' && event.toolCallId) {
|
|
292
|
+
const callId = event.toolCallId;
|
|
293
|
+
if (!sub.emittedIds.has(callId)) {
|
|
294
|
+
sub.emittedIds.add(callId);
|
|
295
|
+
this.emit({
|
|
296
|
+
sessionUpdate: 'tool_call',
|
|
297
|
+
toolCallId: callId,
|
|
298
|
+
title: event.name ?? '工具',
|
|
299
|
+
kind: toolKind(event.name),
|
|
300
|
+
status: 'in_progress',
|
|
301
|
+
rawInput: event.args ?? {},
|
|
302
|
+
}, agentId, gen?.taskId);
|
|
303
|
+
}
|
|
304
|
+
} else if (type === 'tool.result' && event.toolCallId) {
|
|
305
|
+
const callId = event.toolCallId;
|
|
306
|
+
const resKey = `${callId}:result`;
|
|
307
|
+
if (!sub.emittedIds.has(resKey)) {
|
|
308
|
+
sub.emittedIds.add(resKey);
|
|
309
|
+
const isError = Boolean(event.result?.isError || event.result?.error);
|
|
310
|
+
const output = typeof event.result?.output === 'string'
|
|
311
|
+
? event.result.output
|
|
312
|
+
: (typeof event.result?.error === 'string' ? event.result.error : (event.result !== undefined ? JSON.stringify(event.result) : ''));
|
|
313
|
+
this.emit({
|
|
314
|
+
sessionUpdate: 'tool_call_update',
|
|
315
|
+
toolCallId: callId,
|
|
316
|
+
status: isError ? 'failed' : 'completed',
|
|
317
|
+
content: [{ type: 'content', content: { type: 'text', text: output } }],
|
|
318
|
+
rawOutput: event.result?.output ?? event.result,
|
|
319
|
+
}, agentId, gen?.taskId);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
package/agent/waits.mjs
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// Kimi's tasks, as its files show them (observe.mjs), told to Coda as waits of its own (docs/agent-protocol.md「_coda/wait」):
|
|
2
|
+
// a command as a task, a subagent's run as a subagent whose session is its agent id, a cron as a timer. A task ending during
|
|
3
|
+
// Coda's prompt ends there: the main agent is already handling it in that turn. One ending outside a prompt is handled until
|
|
4
|
+
// the main agent ends a turn after it; one it is not told of ends as it ends. Only tasks started since this agent process
|
|
5
|
+
// started (`startedAt`) are followed: an earlier process's are not told again. A cron is told whenever it is seen, including
|
|
6
|
+
// one set before this process: telling `waiting` again does not register a second one. One first seen already finished is
|
|
7
|
+
// not registered. Its next fire follows the cursor and Kimi's offset (`nextFire`). Coda cannot stop any of them.
|
|
8
|
+
const FINAL = { completed: 'done', failed: 'failed', killed: 'cancelled', lost: 'failed', timed_out: 'failed' };
|
|
9
|
+
const open = state => state === 'waiting' || state === 'handling';
|
|
10
|
+
|
|
11
|
+
export class KimiWaits {
|
|
12
|
+
constructor({ sessionId, startedAt = 0, now = () => Date.now() }) {
|
|
13
|
+
this.sessionId = sessionId; this.startedAt = startedAt; this.now = now; this.said = new Map(); this.held = new Map(); this.at = new Map();
|
|
14
|
+
}
|
|
15
|
+
get handling() { return [...this.said.values()].filter(state => state === 'handling').length; }
|
|
16
|
+
// What changed since last said, given what the files say now (`facts`) and what the subagents said meanwhile (`content`,
|
|
17
|
+
// updates of their sessions, each with the run it is of): run by run as they began, what it is or became, what was said in
|
|
18
|
+
// it, and its end. A subagent's later run is told once those before it have ended, so that it continues their card; what
|
|
19
|
+
// it said meanwhile is kept until then, all of it: what was read is not read again, and it is no more than the run's wire
|
|
20
|
+
// holds (subagents.mjs reads at most 32 MiB of it).
|
|
21
|
+
read({ tasks, turnEndedAt, crons = [], schedule = {} }, content = [], { promptActive = false } = {}) {
|
|
22
|
+
const runs = new Map(), going = new Set(), later = new Set();
|
|
23
|
+
for (const task of tasks.filter(task => Number.isSafeInteger(task.startedAt) && task.startedAt >= this.startedAt).sort((a, b) => a.startedAt - b.startedAt)) {
|
|
24
|
+
const run = { told: [], content: [], ended: [] }, subagent = task.kind === 'agent' && typeof task.agentId === 'string';
|
|
25
|
+
runs.set(task.taskId, run);
|
|
26
|
+
const before = this.said.get(task.taskId);
|
|
27
|
+
if (before !== undefined && !open(before)) continue;
|
|
28
|
+
if (before === undefined && subagent && going.has(task.agentId)) { later.add(task.taskId); continue; }
|
|
29
|
+
const state = task.status === 'running' ? 'waiting'
|
|
30
|
+
: task.terminalNotificationSuppressed === true || promptActive || turnEndedAt >= (task.endedAt ?? 0)
|
|
31
|
+
? FINAL[task.status] ?? 'failed' : 'handling';
|
|
32
|
+
if (subagent && open(state)) going.add(task.agentId);
|
|
33
|
+
if (state === before) continue;
|
|
34
|
+
this.said.set(task.taskId, state);
|
|
35
|
+
// What it is is said as it is first told: one first seen ended is told begun, so that what its subagent said is its own.
|
|
36
|
+
if (before === undefined) run.told.push({ sessionId: this.sessionId, waitId: task.taskId, state: open(state) ? state : 'waiting',
|
|
37
|
+
kind: subagent ? 'subagent' : 'task', title: String(task.description || (subagent ? '子 Agent' : '后台任务')).slice(0, 500), stoppable: false,
|
|
38
|
+
...(subagent ? { childSessionId: task.agentId } : {}), ...(typeof task.model === 'string' ? { model: task.model.slice(0, 200) } : {}) });
|
|
39
|
+
if (before === undefined) { run.content.push(...this.held.get(task.taskId) ?? []); this.held.delete(task.taskId); }
|
|
40
|
+
if (!open(state)) run.ended.push({ sessionId: this.sessionId, waitId: task.taskId, state });
|
|
41
|
+
else if (before !== undefined) run.told.push({ sessionId: this.sessionId, waitId: task.taskId, state });
|
|
42
|
+
}
|
|
43
|
+
// What was said in no run told here is of runs told before.
|
|
44
|
+
const earlier = [];
|
|
45
|
+
for (const said of content) {
|
|
46
|
+
if (!later.has(said.taskId)) { (runs.get(said.taskId)?.content ?? earlier).push(said); continue; }
|
|
47
|
+
if (!this.held.has(said.taskId)) this.held.set(said.taskId, []);
|
|
48
|
+
this.held.get(said.taskId).push(said);
|
|
49
|
+
}
|
|
50
|
+
const update = ({ update, sessionId }) => ({ jsonrpc: '2.0', method: 'session/update', params: { sessionId, update } });
|
|
51
|
+
return [...earlier.map(update), ...[...runs.values()].flatMap(run => [...run.told.map(wait), ...run.content.map(update), ...run.ended.map(wait)]),
|
|
52
|
+
...this.scheduled(crons, schedule)];
|
|
53
|
+
}
|
|
54
|
+
// Crons as the wire left them (`phase`): waiting, handling, done or cancelled. Done and cancelled are that wire fact,
|
|
55
|
+
// not the id having left the list. While it stays waiting, a new fire cursor still moves the next time.
|
|
56
|
+
scheduled(crons, schedule = {}) {
|
|
57
|
+
const told = [], asOf = Number.isFinite(schedule.asOf) ? schedule.asOf : this.now(), reliable = schedule.reliable !== false;
|
|
58
|
+
for (const cron of crons) {
|
|
59
|
+
if (cron.phase !== 'waiting' && cron.phase !== 'handling' && cron.phase !== 'done' && cron.phase !== 'cancelled') continue;
|
|
60
|
+
const before = this.said.get(cron.id);
|
|
61
|
+
if ((before !== undefined && !open(before)) || (before === undefined && !open(cron.phase))) continue;
|
|
62
|
+
const at = cron.phase === 'waiting' && reliable ? nextFire(cron, asOf, schedule.noJitter === true) : null;
|
|
63
|
+
const atIso = at === null ? '' : new Date(at).toISOString();
|
|
64
|
+
if (cron.phase === before && (cron.phase !== 'waiting' || atIso === this.at.get(cron.id))) continue;
|
|
65
|
+
this.said.set(cron.id, cron.phase);
|
|
66
|
+
if (cron.phase === 'waiting') this.at.set(cron.id, atIso);
|
|
67
|
+
const time = atIso === '' ? {} : { at: atIso };
|
|
68
|
+
told.push(before === undefined
|
|
69
|
+
? wait({ sessionId: this.sessionId, waitId: cron.id, state: cron.phase, kind: 'timer', title: String(cron.title || '定时检查').slice(0, 500),
|
|
70
|
+
detail: String(cron.schedule ?? '').slice(0, 4000), recurring: cron.recurring === true, stoppable: false, ...time })
|
|
71
|
+
: wait({ sessionId: this.sessionId, waitId: cron.id, state: cron.phase, ...time }));
|
|
72
|
+
}
|
|
73
|
+
return told;
|
|
74
|
+
}
|
|
75
|
+
// The files no longer read as understood: nothing will tell how what was waited on ended, so it ends.
|
|
76
|
+
lost() {
|
|
77
|
+
const ended = [...this.said].filter(([, state]) => open(state));
|
|
78
|
+
this.held.clear();
|
|
79
|
+
for (const [waitId] of ended) this.said.set(waitId, 'failed');
|
|
80
|
+
return ended.map(([waitId]) => wait({ sessionId: this.sessionId, waitId, state: 'failed' }));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const wait = params => ({ jsonrpc: '2.0', method: '_coda/wait', params });
|
|
84
|
+
|
|
85
|
+
// The next time Kimi 2.1.1 will fire `cron`, counted from the later of `createdAt` and a cursor `lastFiredAt` that is not
|
|
86
|
+
// still in the future (`now`), not from `now` itself: resuming inside the offset must not skip to the period after.
|
|
87
|
+
// Then the default offset, unless `noJitter`. Recurring waits by the id's fraction, at most 10% of the period and 15
|
|
88
|
+
// minutes. A one-shot on local minute 0 or 30, when that minute is a UTC minute, comes forward by up to 90 seconds,
|
|
89
|
+
// unless that would be before it was created. Null when the expression has no next minute within five years.
|
|
90
|
+
export function nextFire(cron, now = Date.now(), noJitter = false) {
|
|
91
|
+
const { id, schedule, recurring, createdAt, lastFiredAt } = cron ?? {};
|
|
92
|
+
if (typeof id !== 'string' || !Number.isFinite(createdAt)) return null;
|
|
93
|
+
const seeded = Number.isFinite(lastFiredAt) && lastFiredAt <= now && lastFiredAt > createdAt ? lastFiredAt : createdAt;
|
|
94
|
+
const ideal = nextRun(schedule, seeded);
|
|
95
|
+
if (ideal === null || noJitter === true) return ideal;
|
|
96
|
+
if (recurring === false) return oneShotAt(id, ideal, createdAt);
|
|
97
|
+
const cap = delayCap(schedule, ideal);
|
|
98
|
+
return cap > 0 ? ideal + cap * fractionFromId(id) : ideal;
|
|
99
|
+
}
|
|
100
|
+
function fractionFromId(id) {
|
|
101
|
+
if (/^[0-9a-f]{8}$/i.test(id)) {
|
|
102
|
+
const n = Number.parseInt(id, 16);
|
|
103
|
+
if (Number.isFinite(n)) return n / 4294967296;
|
|
104
|
+
}
|
|
105
|
+
let hash = 5381;
|
|
106
|
+
for (let i = 0; i < id.length; i++) hash = (hash << 5) + hash + id.charCodeAt(i) | 0;
|
|
107
|
+
return (hash >>> 0) / 4294967296;
|
|
108
|
+
}
|
|
109
|
+
function delayCap(schedule, ideal) {
|
|
110
|
+
const next = nextRun(schedule, ideal);
|
|
111
|
+
const period = next !== null && next > ideal ? next - ideal : 1_440 * 60_000;
|
|
112
|
+
return Math.min(period * 0.1, 15 * 60_000);
|
|
113
|
+
}
|
|
114
|
+
function oneShotAt(id, ideal, createdAt) {
|
|
115
|
+
if (ideal % 60_000 !== 0) return ideal;
|
|
116
|
+
const minute = new Date(ideal).getMinutes();
|
|
117
|
+
if (minute !== 0 && minute !== 30) return ideal;
|
|
118
|
+
const shifted = ideal - 90_000 * fractionFromId(id);
|
|
119
|
+
return shifted < createdAt ? ideal : shifted;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// The next minute after `from` a five-field cron schedule matches, in local time (as Kimi schedules on this machine);
|
|
123
|
+
// null when it cannot be read or never matches within five years.
|
|
124
|
+
export function nextRun(schedule, from = Date.now()) {
|
|
125
|
+
const fields = typeof schedule === 'string' ? schedule.trim().split(/\s+/) : [];
|
|
126
|
+
if (fields.length !== 5) return null;
|
|
127
|
+
const [minutes, hours, days, months, weekdays] = fields.map((field, i) => values(field, ...[[0, 59], [0, 23], [1, 31], [1, 12], [0, 7]][i]));
|
|
128
|
+
if (![minutes, hours, days, months, weekdays].every(Boolean)) return null;
|
|
129
|
+
if (weekdays.has(7)) weekdays.add(0);
|
|
130
|
+
// Both day fields restricted: either matches.
|
|
131
|
+
const day = date => fields[2] === '*' ? fields[4] === '*' || weekdays.has(date.getDay())
|
|
132
|
+
: fields[4] === '*' ? days.has(date.getDate()) : days.has(date.getDate()) || weekdays.has(date.getDay());
|
|
133
|
+
const t = new Date(from); t.setSeconds(0, 0); t.setMinutes(t.getMinutes() + 1);
|
|
134
|
+
for (const limit = from + 5 * 366 * 86_400_000; t.getTime() < limit;) {
|
|
135
|
+
if (!months.has(t.getMonth() + 1)) { t.setMonth(t.getMonth() + 1, 1); t.setHours(0, 0, 0, 0); }
|
|
136
|
+
else if (!day(t)) { t.setDate(t.getDate() + 1); t.setHours(0, 0, 0, 0); }
|
|
137
|
+
else if (!hours.has(t.getHours())) t.setHours(t.getHours() + 1, 0, 0, 0);
|
|
138
|
+
else if (!minutes.has(t.getMinutes())) t.setMinutes(t.getMinutes() + 1, 0, 0);
|
|
139
|
+
else return t.getTime();
|
|
140
|
+
}
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
function values(field, min, max) {
|
|
144
|
+
const set = new Set();
|
|
145
|
+
for (const part of field.split(',')) {
|
|
146
|
+
const m = /^(?:(\*)|(\d+)(?:-(\d+))?)(?:\/(\d+))?$/.exec(part);
|
|
147
|
+
if (!m) return null;
|
|
148
|
+
const low = m[1] ? min : Number(m[2]), high = m[1] ? max : m[3] !== undefined ? Number(m[3]) : m[4] ? max : low, step = m[4] ? Number(m[4]) : 1;
|
|
149
|
+
if (low < min || high > max || low > high || step < 1) return null;
|
|
150
|
+
for (let v = low; v <= high; v += step) set.add(v);
|
|
151
|
+
}
|
|
152
|
+
return set;
|
|
153
|
+
}
|
package/icons/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Kimi 品牌图形
|
|
2
|
+
|
|
3
|
+
仅用于标识会话所用的服务,不作为 Coda 自身标志。商标归各自权利人所有。
|
|
4
|
+
|
|
5
|
+
- `kimi-light.svg` / `kimi-dark.svg`:原样取自 [Kimi 品牌手册](https://www.kimi.com/resources/kimi-brand) 的官方 [素材包](https://kimi-file.kimi.ai/prod-chat-kimi/kfs/4/1/2026-08-12/1d9u74p1l51jas5cp5oq0?response-content-disposition=attachment%3Bfilename%3Dkimi-logo-assets.zip),对应 `KIMI-logos/Logomark/SVG/Logomark_Light.svg` / `Logomark_Dark.svg`,用于 Kimi Code。保留圆角底板、字形及品牌蓝。
|
|
6
|
+
|
|
7
|
+
提取日期:2026-09-19。SVG 是可审阅的源文件,PDF 是由 CairoSVG 转换的等比矢量资源,清单的 `icon` 指向 PDF。重新生成 PDF(开发工具,不是构建或运行依赖):
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
uv run --with cairosvg python - <<'PY'
|
|
11
|
+
import cairosvg
|
|
12
|
+
for name in ['kimi-light', 'kimi-dark']:
|
|
13
|
+
cairosvg.svg2pdf(url=f'{name}.svg', write_to=f'{name}.pdf')
|
|
14
|
+
PY
|
|
15
|
+
```
|
|
Binary file
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="180" height="180" viewBox="0 0 180 180" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect width="180" height="180" rx="45" fill="white"/>
|
|
3
|
+
<path d="M139.13 36.5137C144.237 36.5137 148.377 40.6535 148.377 45.7602C148.377 50.867 144.237 55.0068 139.13 55.0068L130.972 55.0068C130.371 55.0068 129.884 54.5198 129.884 53.919L129.884 45.7602C129.884 40.6535 134.024 36.5137 139.13 36.5137Z" fill="#1783FF"/>
|
|
4
|
+
<path d="M87.2905 90.3594L122.186 55.739C122.842 55.0865 122.473 53.7744 121.625 53.7744H102.848C102.644 53.7744 102.447 53.8577 102.288 54.0174L64.6898 91.3104C64.1035 91.8866 63.2366 91.3729 63.2366 90.4496V54.8782C63.2366 54.2673 62.8351 53.7744 62.3443 53.7744H49.406C48.9152 53.7744 48.5137 54.2673 48.5137 54.8782V131.575C48.5137 132.186 48.9152 132.679 49.406 132.679H62.3443C62.8351 132.679 63.2366 132.186 63.2366 131.575V115.948C63.2366 115.615 63.3577 115.295 63.5681 115.087L75.2254 103.522C75.5058 103.244 75.8946 103.202 76.2069 103.411L107.386 126.354C112.492 129.791 118.196 131.901 123.99 132.526C124.506 132.581 124.952 132.068 124.952 131.422V116.705C124.952 116.142 124.614 115.684 124.162 115.615C120.752 115.08 117.425 113.761 114.417 111.734L87.4244 92.1921C86.8635 91.8172 86.7934 90.8523 87.2905 90.3594Z" fill="black"/>
|
|
5
|
+
</svg>
|
|
Binary file
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="180" height="180" viewBox="0 0 180 180" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect width="180" height="180" rx="45" fill="black"/>
|
|
3
|
+
<path d="M139.13 36.5137C144.237 36.5137 148.377 40.6535 148.377 45.7602C148.377 50.867 144.237 55.0068 139.13 55.0068L130.972 55.0068C130.371 55.0068 129.884 54.5198 129.884 53.919L129.884 45.7602C129.884 40.6535 134.024 36.5137 139.13 36.5137Z" fill="#1783FF"/>
|
|
4
|
+
<path d="M87.2905 90.3594L122.186 55.739C122.842 55.0865 122.473 53.7744 121.625 53.7744H102.848C102.644 53.7744 102.447 53.8577 102.288 54.0174L64.6898 91.3104C64.1035 91.8866 63.2366 91.3729 63.2366 90.4496V54.8782C63.2366 54.2673 62.8351 53.7744 62.3443 53.7744H49.406C48.9152 53.7744 48.5137 54.2673 48.5137 54.8782V131.575C48.5137 132.186 48.9152 132.679 49.406 132.679H62.3443C62.8351 132.679 63.2366 132.186 63.2366 131.575V115.948C63.2366 115.615 63.3577 115.295 63.5681 115.087L75.2254 103.522C75.5058 103.244 75.8946 103.202 76.2069 103.411L107.386 126.354C112.492 129.791 118.196 131.901 123.99 132.526C124.506 132.581 124.952 132.068 124.952 131.422V116.705C124.952 116.142 124.614 115.684 124.162 115.615C120.752 115.08 117.425 113.761 114.417 111.734L87.4244 92.1921C86.8635 91.8172 86.7934 90.8523 87.2905 90.3594Z" fill="white"/>
|
|
5
|
+
</svg>
|
package/package.json
CHANGED
|
@@ -1,7 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coda-console/kimi",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"id": "kimi",
|
|
4
|
+
"displayName": "Kimi Code",
|
|
5
|
+
"description": "Kimi Code Agent:Coda 的入口在运行机的 kimi acp 与 Coda 之间转发,读 Kimi 的会话文件报出后台命令与子 Agent;资源页的「Kimi」面板显示账号与额度,可从 Coda 安装和登录。",
|
|
6
|
+
"version": "1.2.2",
|
|
7
|
+
"categories": ["Agent"],
|
|
8
|
+
"contributes": {
|
|
9
|
+
"agents": [
|
|
10
|
+
{
|
|
11
|
+
"id": "kimi",
|
|
12
|
+
"displayName": "Kimi Code",
|
|
13
|
+
"icon": {
|
|
14
|
+
"light": "icons/kimi-light.pdf",
|
|
15
|
+
"dark": "icons/kimi-dark.pdf"
|
|
16
|
+
},
|
|
17
|
+
"command": "exec \"$CODA_NODE\" \"$CODA_PLUGIN_PATH/agent/entry.mjs\"",
|
|
18
|
+
"modes": {
|
|
19
|
+
"title": "审批模式",
|
|
20
|
+
"unset": "人工审批",
|
|
21
|
+
"auto": "auto",
|
|
22
|
+
"full": "yolo"
|
|
23
|
+
},
|
|
24
|
+
"skillsDir": ".agents/skills",
|
|
25
|
+
"configFiles": [
|
|
26
|
+
"${KIMI_CODE_HOME:-~/.kimi-code}/config.toml"
|
|
27
|
+
],
|
|
28
|
+
"setupHint": "请在「资源」里为运行机添加 Kimi。"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"panels": [
|
|
32
|
+
{
|
|
33
|
+
"id": "account",
|
|
34
|
+
"title": "Kimi",
|
|
35
|
+
"command": "node \"$CODA_PLUGIN_PATH/scripts/panel.mjs\"",
|
|
36
|
+
"maxAge": "PT5M",
|
|
37
|
+
"signIn": {
|
|
38
|
+
"command": "exec sh \"$CODA_PLUGIN_PATH/scripts/login.sh\"",
|
|
39
|
+
"installed": "test -x \"$HOME/.kimi-code/bin/kimi\" || command -v kimi >/dev/null",
|
|
40
|
+
"install": "exec sh \"$CODA_PLUGIN_PATH/scripts/install.sh\"",
|
|
41
|
+
"note": "登录保存在这台机器的 Kimi CLI 里,由它自己续期。"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"setup": {
|
|
46
|
+
"command": "exec \"$CODA_NODE\" \"$CODA_PLUGIN_PATH/scripts/setup.mjs\""
|
|
47
|
+
}
|
|
48
|
+
},
|
|
5
49
|
"license": "MIT",
|
|
6
50
|
"repository": {
|
|
7
51
|
"type": "git",
|
|
@@ -10,5 +54,10 @@
|
|
|
10
54
|
},
|
|
11
55
|
"publishConfig": {
|
|
12
56
|
"access": "public"
|
|
13
|
-
}
|
|
57
|
+
},
|
|
58
|
+
"files": [
|
|
59
|
+
"agent",
|
|
60
|
+
"scripts",
|
|
61
|
+
"icons"
|
|
62
|
+
]
|
|
14
63
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# The Kimi CLI's own installer, as https://www.kimi.com/code gives it. It puts the CLI in ~/.kimi-code/bin, where Coda looks
|
|
3
|
+
# first, and would add that to the shell's configuration and rename an older Python `kimi` it finds on the PATH: told not to
|
|
4
|
+
# touch the configuration, with that directory not on the PATH, it leaves both alone.
|
|
5
|
+
PATH=$(printf '%s' "$PATH" | tr ':' '\n' | grep -vx "$HOME/.kimi-code/bin" | paste -sd: -)
|
|
6
|
+
KIMI_NO_MODIFY_PATH=1 PATH="$PATH" exec bash -c 'set -o pipefail; curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash'
|
package/scripts/login.sh
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# The「Kimi」panel's login (`signIn`): `kimi login`, the device-code login of the CLI the agent runs. `kimi login` opens the
|
|
3
|
+
# link with `open` (`xdg-open` on Linux) whatever BROWSER says: on a machine the user is not at, that would be a page left
|
|
4
|
+
# open for no one, so it finds do-nothing ones first on its PATH, in this plugin's own state.
|
|
5
|
+
stubs="$CODA_PLUGIN_STATE/no-browser"
|
|
6
|
+
mkdir -p "$stubs" && for name in open xdg-open; do printf '#!/bin/sh\nexit 0\n' > "$stubs/$name" && chmod 755 "$stubs/$name"; done || exit 1
|
|
7
|
+
k="$HOME/.kimi-code/bin/kimi"; [ -x "$k" ] || k=kimi
|
|
8
|
+
PATH="$stubs:$PATH" NO_COLOR=1 exec "$k" login
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// The「Kimi」panel's reading, printed once as `{ items }`. No login file here shows nothing (the panel is then offered under
|
|
2
|
+
// 「添加资源」). Who is signed in is asked once for each state of the login file, which the CLI rewrites as it signs in and
|
|
3
|
+
// renews, and kept in this plugin's state: Kimi's own upstream lookup takes seconds and gives up after 8. The quota is
|
|
4
|
+
// asked each reading, of the same `kimi web`.
|
|
5
|
+
import { readFileSync, renameSync, statSync, writeFileSync } from 'node:fs';
|
|
6
|
+
import { homedir } from 'node:os';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { kimiBinary } from '../agent/binary.mjs';
|
|
9
|
+
import { account, card } from './quota.mjs';
|
|
10
|
+
import { kimiWeb } from './web.mjs';
|
|
11
|
+
|
|
12
|
+
const home = process.env.KIMI_CODE_HOME || join(homedir(), '.kimi-code');
|
|
13
|
+
const print = value => console.log(JSON.stringify(value));
|
|
14
|
+
let changed;
|
|
15
|
+
try { changed = statSync(join(home, 'credentials/kimi-code.json')).mtimeMs; }
|
|
16
|
+
catch (error) { if (error.code === 'ENOENT') { print({ items: [] }); process.exit(0); } console.error(`读不了 Kimi 的登录:${error.code}`); process.exit(1); }
|
|
17
|
+
const binary = kimiBinary();
|
|
18
|
+
if (!binary) { print({ items: [{ type: 'card', title: 'Kimi', items: [{ type: 'error', text: '这台机器上找不到 Kimi CLI,用「···」里的「重新登录」安装' }] }] }); process.exit(0); }
|
|
19
|
+
|
|
20
|
+
const seenFile = process.env.CODA_PLUGIN_STATE && join(process.env.CODA_PLUGIN_STATE, 'account.json');
|
|
21
|
+
let seen = null;
|
|
22
|
+
try { seen = JSON.parse(readFileSync(seenFile, 'utf8')); } catch {}
|
|
23
|
+
const known = seen?.changed === changed;
|
|
24
|
+
try {
|
|
25
|
+
const [usage, info] = await kimiWeb(['/api/v1/oauth/usage', ...(known ? [] : ['/api/v1/oauth/userinfo'])], { binary, home });
|
|
26
|
+
// The login changed and who it is could not be asked: the last name and plan stand in, but not the last ID, which is
|
|
27
|
+
// the other login's and would name this one's quota as that account's.
|
|
28
|
+
let who = known ? seen.account : { name: seen?.account?.name ?? '', plan: seen?.account?.plan ?? '' };
|
|
29
|
+
if (!known) {
|
|
30
|
+
try {
|
|
31
|
+
if (info.error) throw new Error(info.error);
|
|
32
|
+
who = account(info.data);
|
|
33
|
+
if (seenFile) { writeFileSync(`${seenFile}.tmp`, JSON.stringify({ changed, account: who })); renameSync(`${seenFile}.tmp`, seenFile); }
|
|
34
|
+
} catch { /* Not told now: the account seen last, or the kind's own name, and asked again next time. */ }
|
|
35
|
+
}
|
|
36
|
+
print({ items: who ? [card(who, usage)] : [] });
|
|
37
|
+
} catch (error) { console.error(error.message); process.exit(1); }
|