@yunhozz/arc 0.2.6 → 0.2.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/MANIFEST.sha256 +115 -69
- package/README.md +21 -5
- package/claude/agents/arc-implementer.md +3 -3
- package/claude/agents/arc-planner.md +3 -3
- package/claude/agents/arc-qa.md +3 -3
- package/claude/agents/arc-reviewer.md +3 -3
- package/claude/agents/arc-scouter.md +3 -3
- package/claude/skill/SKILL.md +5 -5
- package/claude/skill/models.toml +7 -48
- package/claude/skill/references/commit.md +7 -7
- package/claude/skill/references/coordination.md +39 -3
- package/claude/skill/references/git-recovery.md +1 -1
- package/claude/skill/references/handoff-prep.md +6 -6
- package/claude/skill/references/handoff.md +8 -3
- package/claude/skill/references/limits.md +2 -0
- package/claude/skill/references/planning.md +8 -8
- package/claude/skill/references/verification.md +9 -9
- package/claude/skill/runtime/adapters/claude.mjs +4 -0
- package/claude/skill/runtime/adapters/codex.mjs +3 -0
- package/claude/skill/runtime/bootstrap.mjs +4 -2
- package/claude/skill/runtime/command.mjs +21 -4
- package/claude/skill/runtime/local-cli.mjs +248 -0
- package/claude/skill/runtime/role-bridge-args.mjs +148 -0
- package/claude/skill/runtime/role-bridge.mjs +227 -0
- package/claude/skill/runtime/role-dispatch-policy.mjs +110 -0
- package/claude/skill/runtime/role-dispatch-store.mjs +134 -0
- package/claude/skill/runtime/role-observe.mjs +299 -0
- package/claude/skill/runtime/role-policy.json +12 -10
- package/claude/skill/runtime/role-routing-config.mjs +19 -0
- package/claude/skill/runtime/role-routing.mjs +233 -0
- package/claude/skill/runtime/role-supervisor.mjs +356 -0
- package/claude/skill/scripts/model_config.py +23 -5
- package/codex/agents/arc-implementer.toml +3 -3
- package/codex/agents/arc-planner.toml +3 -3
- package/codex/agents/arc-qa.toml +3 -3
- package/codex/agents/arc-reviewer.toml +3 -3
- package/codex/agents/arc-scouter.toml +3 -3
- package/codex/skill/SKILL.md +5 -5
- package/codex/skill/models.toml +7 -48
- package/codex/skill/references/commit.md +7 -7
- package/codex/skill/references/coordination.md +38 -2
- package/codex/skill/references/handoff-prep.md +6 -6
- package/codex/skill/references/handoff-worktree.md +3 -3
- package/codex/skill/references/handoff.md +8 -3
- package/codex/skill/references/limits.md +2 -0
- package/codex/skill/references/planning.md +8 -8
- package/codex/skill/references/verification.md +9 -9
- package/codex/skill/runtime/adapters/claude.mjs +4 -0
- package/codex/skill/runtime/adapters/codex.mjs +3 -0
- package/codex/skill/runtime/bootstrap.mjs +4 -2
- package/codex/skill/runtime/command.mjs +21 -4
- package/codex/skill/runtime/local-cli.mjs +248 -0
- package/codex/skill/runtime/role-bridge-args.mjs +148 -0
- package/codex/skill/runtime/role-bridge.mjs +227 -0
- package/codex/skill/runtime/role-dispatch-policy.mjs +110 -0
- package/codex/skill/runtime/role-dispatch-store.mjs +134 -0
- package/codex/skill/runtime/role-observe.mjs +299 -0
- package/codex/skill/runtime/role-policy.json +12 -10
- package/codex/skill/runtime/role-routing-config.mjs +19 -0
- package/codex/skill/runtime/role-routing.mjs +233 -0
- package/codex/skill/runtime/role-supervisor.mjs +356 -0
- package/codex/skill/scripts/model_config.py +17 -22
- package/lib/cli/root.mjs +3 -2
- package/lib/installer/install-mode.mjs +34 -0
- package/lib/installer/install.mjs +1 -1
- package/lib/installer/plan.mjs +16 -7
- package/lib/installer/preset.mjs +18 -11
- package/lib/installer/role-routing.mjs +175 -0
- package/lib/installer/runtime-assets.mjs +9 -0
- package/lib/installer/targets.mjs +2 -7
- package/lib/installer/transaction.mjs +1 -1
- package/lib/installer/uninstall.mjs +10 -5
- package/lib/installer/upgrade-state.mjs +9 -6
- package/lib/installer/upgrade.mjs +2 -2
- package/lib/management/operations.mjs +94 -5
- package/lib/management/status.mjs +12 -6
- package/lib/management/update.mjs +3 -1
- package/lib/models/catalog.mjs +3 -3
- package/lib/models/claude-models.json +297 -0
- package/lib/models/codex-catalog.mjs +9 -6
- package/lib/models/codex-models.json +189 -0
- package/lib/models/config.mjs +25 -20
- package/lib/models/index.mjs +1 -1
- package/lib/models/static-catalog.mjs +42 -0
- package/lib/policy/role-policy.json +12 -10
- package/lib/runtime/adapters/claude.mjs +4 -0
- package/lib/runtime/adapters/codex.mjs +3 -0
- package/lib/runtime/bootstrap.mjs +4 -2
- package/lib/runtime/command.mjs +21 -4
- package/lib/runtime/local-cli.mjs +248 -0
- package/lib/runtime/role-bridge-args.mjs +148 -0
- package/lib/runtime/role-bridge.mjs +227 -0
- package/lib/runtime/role-dispatch-policy.mjs +110 -0
- package/lib/runtime/role-dispatch-store.mjs +134 -0
- package/lib/runtime/role-observe.mjs +299 -0
- package/lib/runtime/role-routing-config.mjs +19 -0
- package/lib/runtime/role-routing.mjs +233 -0
- package/lib/runtime/role-supervisor.mjs +356 -0
- package/lib/tui/app.mjs +32 -23
- package/lib/tui/custom-preset.mjs +138 -66
- package/lib/tui/render.mjs +4 -3
- package/lib/tui/setup.mjs +96 -51
- package/lib/watch/args.mjs +43 -0
- package/lib/watch/discover-claude.mjs +63 -0
- package/lib/watch/discover-codex.mjs +45 -0
- package/lib/watch/dispatch.mjs +133 -0
- package/lib/watch/git.mjs +29 -0
- package/lib/watch/index.mjs +112 -0
- package/lib/watch/labels.mjs +24 -0
- package/lib/watch/model.mjs +48 -0
- package/lib/watch/normalize-claude.mjs +99 -0
- package/lib/watch/normalize-codex.mjs +96 -0
- package/lib/watch/policy.mjs +52 -0
- package/lib/watch/render.mjs +86 -0
- package/lib/watch/scope.mjs +64 -0
- package/lib/watch/tail.mjs +75 -0
- package/lib/watch/watcher.mjs +337 -0
- package/package.json +4 -3
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import {WATCH_LIMITS as L} from './model.mjs';
|
|
3
|
+
|
|
4
|
+
export function parseWatchArgs(argv) {
|
|
5
|
+
const options = {mode:'default',dir:null,session:null,platforms:['codex','claude'],tail:L.defaultTail,verbose:false,json:false,width:null,help:false};
|
|
6
|
+
const seen = new Set(), values = ['cwd','session','platform','tail','width'];
|
|
7
|
+
const fail = message => ({ok:false,message});
|
|
8
|
+
for (let i = 0; i < argv.length; i++) {
|
|
9
|
+
const match = /^--([a-z]+)(?:=(.*))?$/.exec(argv[i]);
|
|
10
|
+
if (!match) return fail(`Unsupported argument: ${argv[i]}`);
|
|
11
|
+
const [, name, inline] = match;
|
|
12
|
+
if (![...values,'all','verbose','json','help'].includes(name)) return fail(`Unknown option: --${name}`);
|
|
13
|
+
if (seen.has(name)) return fail(`Duplicate option: --${name}`);
|
|
14
|
+
seen.add(name);
|
|
15
|
+
if (!values.includes(name)) {
|
|
16
|
+
if (inline !== undefined) return fail(`--${name} does not take a value`);
|
|
17
|
+
if (name !== 'all') options[name] = true;
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const value = inline ?? argv[++i];
|
|
21
|
+
if (value === undefined || value === '' || value.startsWith('--')) return fail(`Missing value for --${name}`);
|
|
22
|
+
if (name === 'tail' || name === 'width') {
|
|
23
|
+
const n = Number(value), min = name === 'tail' ? 0 : L.widthMin, max = name === 'tail' ? L.maxTail : L.widthMax;
|
|
24
|
+
if (!/^\d+$/.test(value) || !Number.isSafeInteger(n) || n < min || n > max) return fail(`--${name} must be an integer from ${min} to ${max}`);
|
|
25
|
+
options[name] = n;
|
|
26
|
+
} else if (name === 'platform') {
|
|
27
|
+
if (!['codex','claude'].includes(value)) return fail('--platform must be codex or claude');
|
|
28
|
+
options.platforms = [value];
|
|
29
|
+
} else if (name === 'session') {
|
|
30
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(value)) return fail('Invalid session id');
|
|
31
|
+
options.session = value;
|
|
32
|
+
} else {
|
|
33
|
+
try {
|
|
34
|
+
if (!fs.statSync(value).isDirectory()) return fail('--cwd must name an existing directory');
|
|
35
|
+
options.dir = fs.realpathSync(value);
|
|
36
|
+
} catch { return fail('--cwd must name an existing directory'); }
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const modes = ['cwd','all','session'].filter(name => seen.has(name));
|
|
40
|
+
if (modes.length > 1) return fail('--cwd, --all and --session are mutually exclusive');
|
|
41
|
+
if (modes.length) options.mode = modes[0];
|
|
42
|
+
return {ok:true,options};
|
|
43
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import fsp from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {WATCH_LIMITS} from './model.mjs';
|
|
4
|
+
import {normalizeSlug} from './scope.mjs';
|
|
5
|
+
import {parseClaudeHead, parseClaudeAgentMeta} from './normalize-claude.mjs';
|
|
6
|
+
import {readHead} from './tail.mjs';
|
|
7
|
+
|
|
8
|
+
const absent = error => ['ENOENT','EACCES'].includes(error.code);
|
|
9
|
+
|
|
10
|
+
export function createClaudeDiscovery({claudeHome}) {
|
|
11
|
+
const directories = new Map();
|
|
12
|
+
async function entries(dir) {
|
|
13
|
+
try {
|
|
14
|
+
const stat = await fsp.stat(dir), cached = directories.get(dir);
|
|
15
|
+
if (cached?.mtimeMs === stat.mtimeMs) return cached.entries;
|
|
16
|
+
const entries = await fsp.readdir(dir, {withFileTypes:true});
|
|
17
|
+
directories.set(dir, {mtimeMs:stat.mtimeMs, entries});
|
|
18
|
+
return entries;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
if (!absent(error)) throw error;
|
|
21
|
+
directories.delete(dir); return [];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function details(file) {
|
|
25
|
+
try {
|
|
26
|
+
const stat = await fsp.stat(file);
|
|
27
|
+
return {file, mtimeMs:stat.mtimeMs, size:stat.size, birthtimeMs:stat.birthtimeMs};
|
|
28
|
+
} catch (error) { if (absent(error)) return null; throw error; }
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
async scan({prefixes, now, startup}) {
|
|
32
|
+
const projects = path.join(claudeHome, 'projects'), found = [];
|
|
33
|
+
for (const project of await entries(projects)) {
|
|
34
|
+
if (!project.isDirectory() || (prefixes !== null && !prefixes.some(prefix => normalizeSlug(project.name).startsWith(prefix)))) continue;
|
|
35
|
+
const dir = path.join(projects, project.name);
|
|
36
|
+
for (const entry of await entries(dir)) {
|
|
37
|
+
if (!entry.isFile() || !entry.name.endsWith('.jsonl')) continue;
|
|
38
|
+
const row = await details(path.join(dir, entry.name));
|
|
39
|
+
if (row && (!startup || row.mtimeMs >= now - WATCH_LIMITS.attachWindowMs)) found.push({...row, sessionId:entry.name.slice(0,-6)});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return found;
|
|
43
|
+
},
|
|
44
|
+
async subagents(sessionFile) {
|
|
45
|
+
const dir = path.join(sessionFile.slice(0,-6), 'subagents'), found = [];
|
|
46
|
+
for (const entry of await entries(dir)) {
|
|
47
|
+
if (!entry.isFile() || !/^agent-.+\.jsonl$/.test(entry.name)) continue;
|
|
48
|
+
const row = await details(path.join(dir, entry.name));
|
|
49
|
+
if (!row) continue;
|
|
50
|
+
const obj = await readHead(path.join(dir, entry.name.replace(/\.jsonl$/, '.meta.json')), {
|
|
51
|
+
maxBytes:WATCH_LIMITS.claudeHeadBytes, accept:obj => parseClaudeAgentMeta(obj) !== null,
|
|
52
|
+
});
|
|
53
|
+
found.push({...row, agentId:entry.name.slice(6,-6), meta:parseClaudeAgentMeta(obj)});
|
|
54
|
+
}
|
|
55
|
+
return found;
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function readClaudeHead(file) {
|
|
61
|
+
const obj = await readHead(file, {maxBytes:WATCH_LIMITS.claudeHeadBytes, accept:obj => parseClaudeHead(obj) !== null});
|
|
62
|
+
return parseClaudeHead(obj);
|
|
63
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import fsp from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {WATCH_LIMITS} from './model.mjs';
|
|
4
|
+
import {parseCodexMeta} from './normalize-codex.mjs';
|
|
5
|
+
import {readHead} from './tail.mjs';
|
|
6
|
+
|
|
7
|
+
function dateFolder(date, utc) {
|
|
8
|
+
const year = utc ? date.getUTCFullYear() : date.getFullYear();
|
|
9
|
+
const month = (utc ? date.getUTCMonth() : date.getMonth()) + 1;
|
|
10
|
+
const day = utc ? date.getUTCDate() : date.getDate();
|
|
11
|
+
return path.join(String(year), String(month).padStart(2,'0'), String(day).padStart(2,'0'));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function listCodexRollouts({codexHome, now, startup}) {
|
|
15
|
+
const folders = new Set(), found = [];
|
|
16
|
+
for (const utc of startup ? [false] : [false,true]) {
|
|
17
|
+
for (let back = 0; back <= (startup ? WATCH_LIMITS.lookbackDays : 1); back++) {
|
|
18
|
+
const date = new Date(now);
|
|
19
|
+
if (utc) date.setUTCDate(date.getUTCDate() - back); else date.setDate(date.getDate() - back);
|
|
20
|
+
folders.add(dateFolder(date, utc));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
for (const folder of folders) {
|
|
24
|
+
const dir = path.join(codexHome, 'sessions', folder);
|
|
25
|
+
let entries;
|
|
26
|
+
try { entries = await fsp.readdir(dir, {withFileTypes:true}); }
|
|
27
|
+
catch (error) { if (['ENOENT','EACCES'].includes(error.code)) continue; throw error; }
|
|
28
|
+
for (const entry of entries) {
|
|
29
|
+
if (!entry.isFile() || !/^rollout-.+\.jsonl(?:\.zst)?$/.test(entry.name)) continue;
|
|
30
|
+
const file = path.join(dir, entry.name);
|
|
31
|
+
let stat;
|
|
32
|
+
try { stat = await fsp.stat(file); }
|
|
33
|
+
catch (error) { if (['ENOENT','EACCES'].includes(error.code)) continue; throw error; }
|
|
34
|
+
if (startup && stat.mtimeMs < now - WATCH_LIMITS.attachWindowMs) continue;
|
|
35
|
+
const threadId = entry.name.replace(/^rollout-(?:\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}-)?/, '').replace(/\.jsonl(?:\.zst)?$/, '');
|
|
36
|
+
found.push({file, threadId, mtimeMs:stat.mtimeMs, size:stat.size, birthtimeMs:stat.birthtimeMs, compressed:entry.name.endsWith('.zst')});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return found;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function readCodexMeta(file) {
|
|
43
|
+
const obj = await readHead(file, {maxBytes:WATCH_LIMITS.codexMetaBytes, accept:obj => parseCodexMeta(obj) !== null});
|
|
44
|
+
return parseCodexMeta(obj);
|
|
45
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import fsp from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {createTail} from './tail.mjs';
|
|
4
|
+
import {roleFromName} from './labels.mjs';
|
|
5
|
+
|
|
6
|
+
export function parseLeaseLenient(text) {
|
|
7
|
+
let value;
|
|
8
|
+
try { value = JSON.parse(text); } catch { return null; }
|
|
9
|
+
if (!value || typeof value.dispatchId !== 'string') return null;
|
|
10
|
+
const lease = {};
|
|
11
|
+
for (const key of ['dispatchId', 'workflowId', 'role', 'route', 'hostPlatform', 'state', 'sessionId', 'nativeAgentId', 'createdAt', 'updatedAt']) {
|
|
12
|
+
if (typeof value[key] === 'string') lease[key] = value[key];
|
|
13
|
+
}
|
|
14
|
+
lease.reasons = Array.isArray(value.reasons) ? value.reasons.filter(reason => typeof reason === 'string') : [];
|
|
15
|
+
return lease;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async function entries(dir) {
|
|
19
|
+
try { return (await fsp.readdir(dir, {withFileTypes:true})).sort((a, b) => a.name.localeCompare(b.name, 'en', {numeric:true})); }
|
|
20
|
+
catch (error) {
|
|
21
|
+
if (!['ENOENT', 'ENOTDIR', 'EACCES'].includes(error.code)) throw error;
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function createDispatchIndex({codexHome}) {
|
|
27
|
+
const refs = new Map(), leases = new Map(), tails = new Map(), records = new Map(), signatures = new Map();
|
|
28
|
+
|
|
29
|
+
async function readLeases() {
|
|
30
|
+
const dir = path.join(codexHome, 'arc-role-dispatch'), seen = new Set();
|
|
31
|
+
for (const entry of await entries(dir)) {
|
|
32
|
+
if (!entry.isFile() || entry.name.startsWith('.') || !entry.name.endsWith('.json') || entry.name.endsWith('.heartbeat.json')) continue;
|
|
33
|
+
const file = path.join(dir, entry.name);
|
|
34
|
+
seen.add(file);
|
|
35
|
+
try {
|
|
36
|
+
const {mtimeMs} = await fsp.stat(file);
|
|
37
|
+
if (leases.get(file)?.mtimeMs === mtimeMs) continue;
|
|
38
|
+
const value = parseLeaseLenient(await fsp.readFile(file, 'utf8'));
|
|
39
|
+
if (value) leases.set(file, {mtimeMs, value});
|
|
40
|
+
} catch (error) {
|
|
41
|
+
if (!['ENOENT', 'EACCES'].includes(error.code)) throw error;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
for (const file of leases.keys()) if (!seen.has(file)) leases.delete(file);
|
|
45
|
+
return new Map([...leases.values()].map(({value}) => [value.dispatchId, value]));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function readRecord(dir) {
|
|
49
|
+
const file = path.join(dir, 'record.json');
|
|
50
|
+
try {
|
|
51
|
+
const value = parseLeaseLenient(JSON.stringify({...JSON.parse(await fsp.readFile(file, 'utf8')), dispatchId:path.basename(dir)}));
|
|
52
|
+
if (value) records.set(file, value);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
if (!(error instanceof SyntaxError) && !['ENOENT', 'EACCES'].includes(error.code)) throw error;
|
|
55
|
+
}
|
|
56
|
+
return records.get(file);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function readEvents(dir, ref) {
|
|
60
|
+
const file = path.join(dir, 'events.jsonl');
|
|
61
|
+
if (!tails.has(file)) tails.set(file, createTail(file));
|
|
62
|
+
let result;
|
|
63
|
+
try { result = await tails.get(file).poll(); }
|
|
64
|
+
catch (error) {
|
|
65
|
+
if (error.code !== 'EACCES') throw error;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
for (const event of result.lines) {
|
|
69
|
+
const sessionId = event?.kind === 'thread' ? event.threadId : event?.kind === 'init' ? event.sessionId : null;
|
|
70
|
+
if (typeof sessionId !== 'string') continue;
|
|
71
|
+
if (!ref.sessionIds.includes(sessionId)) ref.sessionIds.push(sessionId);
|
|
72
|
+
ref.childPlatform = event.kind === 'thread' ? 'codex' : 'claude';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function ensure(id) {
|
|
77
|
+
if (!refs.has(id)) refs.set(id, {dispatchId:id, role:null, reasons:[], sessionIds:[], childPlatform:null, inScope:false, artifactDir:null});
|
|
78
|
+
return refs.get(id);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
async scan({gitCommonDirs, includeAllLeases}) {
|
|
83
|
+
const currentLeases = codexHome ? await readLeases() : new Map(), artifacts = new Map();
|
|
84
|
+
for (const gcd of gitCommonDirs) {
|
|
85
|
+
const workflows = path.join(gcd, 'arc', 'workflows');
|
|
86
|
+
for (const workflow of await entries(workflows)) {
|
|
87
|
+
if (!workflow.isDirectory()) continue;
|
|
88
|
+
const dispatches = path.join(workflows, workflow.name, 'dispatches');
|
|
89
|
+
for (const dispatch of await entries(dispatches)) {
|
|
90
|
+
if (!dispatch.isDirectory()) continue;
|
|
91
|
+
const dir = path.join(dispatches, dispatch.name), ref = ensure(dispatch.name);
|
|
92
|
+
let record = await readRecord(dir);
|
|
93
|
+
await readEvents(dir, ref);
|
|
94
|
+
const segments = path.join(dir, 'segments');
|
|
95
|
+
for (const segment of await entries(segments)) {
|
|
96
|
+
if (!segment.isDirectory() || !/^\d+$/.test(segment.name)) continue;
|
|
97
|
+
const segmentDir = path.join(segments, segment.name);
|
|
98
|
+
record = await readRecord(segmentDir) ?? record;
|
|
99
|
+
await readEvents(segmentDir, ref);
|
|
100
|
+
}
|
|
101
|
+
artifacts.set(dispatch.name, {dir, workflowId:workflow.name, record});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
for (const id of currentLeases.keys()) ensure(id);
|
|
106
|
+
const updates = [];
|
|
107
|
+
for (const [id, ref] of refs) {
|
|
108
|
+
const artifact = artifacts.get(id), lease = currentLeases.get(id), value = lease ?? artifact?.record;
|
|
109
|
+
ref.inScope = Boolean(artifact || (includeAllLeases && lease));
|
|
110
|
+
ref.artifactDir = artifact?.dir ?? null;
|
|
111
|
+
if (!lease && !artifact) continue;
|
|
112
|
+
for (const key of ['workflowId', 'rawRole', 'route', 'hostPlatform', 'state', 'updatedAt']) delete ref[key];
|
|
113
|
+
if (artifact) ref.workflowId = artifact.workflowId;
|
|
114
|
+
if (value) {
|
|
115
|
+
for (const key of ['workflowId', 'route', 'hostPlatform', 'state', 'updatedAt']) {
|
|
116
|
+
if (value[key] !== undefined) ref[key] = value[key];
|
|
117
|
+
}
|
|
118
|
+
if (value.role !== undefined) ref.rawRole = value.role;
|
|
119
|
+
if (value.sessionId !== undefined && !ref.sessionIds.includes(value.sessionId)) ref.sessionIds.push(value.sessionId);
|
|
120
|
+
}
|
|
121
|
+
ref.role = roleFromName(ref.rawRole);
|
|
122
|
+
ref.reasons = value?.reasons ?? [];
|
|
123
|
+
const signature = JSON.stringify([ref.state, ref.reasons]), first = !signatures.has(id);
|
|
124
|
+
if (first || signatures.get(id) !== signature) updates.push({ref, first});
|
|
125
|
+
signatures.set(id, signature);
|
|
126
|
+
}
|
|
127
|
+
return updates;
|
|
128
|
+
},
|
|
129
|
+
bySession(sessionId) { return [...refs.values()].find(ref => ref.sessionIds.includes(sessionId)) ?? null; },
|
|
130
|
+
byId(id) { return refs.get(id) ?? null; },
|
|
131
|
+
list() { return [...refs.values()]; },
|
|
132
|
+
};
|
|
133
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {execFile} from 'node:child_process';
|
|
2
|
+
import {promisify} from 'node:util';
|
|
3
|
+
import {WATCH_LIMITS} from './model.mjs';
|
|
4
|
+
|
|
5
|
+
const execFileAsync = promisify(execFile);
|
|
6
|
+
export const GIT_ALLOWED = Object.freeze([
|
|
7
|
+
Object.freeze(['rev-parse','--show-toplevel']),
|
|
8
|
+
Object.freeze(['rev-parse','--path-format=absolute','--git-common-dir']),
|
|
9
|
+
Object.freeze(['worktree','list','--porcelain','-z']),
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
export function createGitRunner({env = process.env, timeoutMs = WATCH_LIMITS.gitTimeoutMs} = {}) {
|
|
13
|
+
const cleanEnv = Object.fromEntries(Object.entries(env).filter(([key]) => !key.toUpperCase().startsWith('GIT_')));
|
|
14
|
+
Object.assign(cleanEnv, {
|
|
15
|
+
GIT_CONFIG_NOSYSTEM:'1', GIT_CONFIG_GLOBAL:process.platform === 'win32' ? 'NUL' : '/dev/null',
|
|
16
|
+
GIT_OPTIONAL_LOCKS:'0', GIT_NO_REPLACE_OBJECTS:'1', GIT_NO_LAZY_FETCH:'1', GIT_TERMINAL_PROMPT:'0',
|
|
17
|
+
});
|
|
18
|
+
return async (cwd, args) => {
|
|
19
|
+
if (!Array.isArray(args) || !GIT_ALLOWED.some(allowed => allowed.length === args.length && allowed.every((arg,i) => arg === args[i]))) {
|
|
20
|
+
throw Error('git command not allowed');
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const {stdout} = await execFileAsync('git', ['--no-pager','-c','core.fsmonitor=false',...args], {
|
|
24
|
+
cwd, env:cleanEnv, shell:false, encoding:'utf8', timeout:timeoutMs,
|
|
25
|
+
});
|
|
26
|
+
return stdout;
|
|
27
|
+
} catch { return null; }
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import os from 'node:os';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {parseWatchArgs} from './args.mjs';
|
|
4
|
+
import {resolveConfigHome} from '../runtime/local-cli.mjs';
|
|
5
|
+
import {createWatcher} from './watcher.mjs';
|
|
6
|
+
import {resolveScope} from './scope.mjs';
|
|
7
|
+
import {createGitRunner} from './git.mjs';
|
|
8
|
+
import {renderHuman, renderJson} from './render.mjs';
|
|
9
|
+
import {WATCH_LIMITS as L} from './model.mjs';
|
|
10
|
+
|
|
11
|
+
export {parseWatchArgs};
|
|
12
|
+
export const WATCH_HELP = `Usage: arc watch [options]
|
|
13
|
+
|
|
14
|
+
Follow Claude Code and Codex session activity in one read-only stream.
|
|
15
|
+
|
|
16
|
+
Scope (default: every worktree of the current Git repository, or the current directory):
|
|
17
|
+
--cwd <dir> Watch the repository or directory at <dir>
|
|
18
|
+
--all Watch sessions from every directory
|
|
19
|
+
--session <id> Follow one session or ARC dispatch and its subagents
|
|
20
|
+
--platform <name> codex or claude (default: both)
|
|
21
|
+
|
|
22
|
+
Output:
|
|
23
|
+
--tail <n> First show the last <n> events from recently active sessions (default 20, 0 = new only)
|
|
24
|
+
--verbose Also show reasoning, settings, turn starts and diagnostics
|
|
25
|
+
--json Write one JSON object per line
|
|
26
|
+
--width <n> Maximum width of one-line events (default: terminal width, or 200)
|
|
27
|
+
--help Show this help
|
|
28
|
+
|
|
29
|
+
User and agent messages are shown in full; other events use one line.
|
|
30
|
+
Tool and command outputs are never shown; common secret patterns are masked.
|
|
31
|
+
Codex Desktop sessions are not included.
|
|
32
|
+
Bridge roles on a Codex host are currently held (host_sandbox_blocked) and appear once they run.
|
|
33
|
+
Press Ctrl-C to stop.`;
|
|
34
|
+
|
|
35
|
+
export async function runWatch(argv, io = {}) {
|
|
36
|
+
const output = io.output ?? process.stdout, error = io.error ?? process.stderr;
|
|
37
|
+
const cwd = io.cwd ?? process.cwd(), env = io.env ?? process.env;
|
|
38
|
+
// Resolve relative --cwd without changing the process cwd shared by other callers.
|
|
39
|
+
const args = argv.map((arg, i) => {
|
|
40
|
+
if (arg.startsWith('--cwd=') && arg.length > 6) return '--cwd=' + path.resolve(cwd, arg.slice(6));
|
|
41
|
+
if (i > 0 && argv[i-1] === '--cwd' && arg && !arg.startsWith('--')) return path.resolve(cwd, arg);
|
|
42
|
+
return arg;
|
|
43
|
+
});
|
|
44
|
+
const parsed = parseWatchArgs(args);
|
|
45
|
+
if (!parsed.ok) { error.write(`Error: ${parsed.message}. Run arc watch --help for usage.\n`); return 2; }
|
|
46
|
+
const options = parsed.options;
|
|
47
|
+
if (options.help) { output.write(WATCH_HELP + '\n'); return 0; }
|
|
48
|
+
if (io.signal?.aborted) return 0;
|
|
49
|
+
const userHome = io.userHome ?? os.homedir(), homes = {codex:null,claude:null}, disabled = [];
|
|
50
|
+
for (const platform of new Set([...options.platforms,'codex'])) {
|
|
51
|
+
try { homes[platform] = resolveConfigHome(platform, {userHome,env,cwd}); }
|
|
52
|
+
catch (cause) { if (options.platforms.includes(platform)) disabled.push(`${platform} disabled: ${cause.message}`); }
|
|
53
|
+
}
|
|
54
|
+
options.platforms = options.platforms.filter(platform => homes[platform] !== null);
|
|
55
|
+
if (!options.platforms.length) { error.write('Error: no usable watch source.\n'); return 1; }
|
|
56
|
+
const now = io.now ?? Date.now, git = io.git ?? createGitRunner({env});
|
|
57
|
+
const proc = io.process ?? process, schedule = io.setInterval ?? setInterval, unschedule = io.clearInterval ?? clearInterval;
|
|
58
|
+
let width, watcher, timer, stopped = false, active;
|
|
59
|
+
const resize = () => { width = options.width ?? (output.isTTY ? Math.max(L.ttyWidthMin, output.columns || L.ttyWidthMin) : L.nonTtyWidth); };
|
|
60
|
+
resize();
|
|
61
|
+
return new Promise(resolve => {
|
|
62
|
+
const signals = ['SIGINT','SIGTERM','SIGHUP'];
|
|
63
|
+
const stop = (code = 0, cause) => {
|
|
64
|
+
if (stopped) return;
|
|
65
|
+
stopped = true;
|
|
66
|
+
if (timer !== undefined) unschedule(timer);
|
|
67
|
+
for (const signal of signals) proc.removeListener(signal, onSignal);
|
|
68
|
+
io.signal?.removeEventListener('abort', onSignal);
|
|
69
|
+
output.removeListener('resize', resize);
|
|
70
|
+
// Retain the error handler until pending writes and reads have settled.
|
|
71
|
+
Promise.resolve(active).catch(() => {}).then(async () => {
|
|
72
|
+
try { await watcher?.close(); }
|
|
73
|
+
catch (failure) { if (code === 0) { code = 1; cause = failure; } }
|
|
74
|
+
output.removeListener('error', onError);
|
|
75
|
+
if (code && cause) error.write(`Error: ${String(cause.message ?? cause).replace(/[\r\n]+/g,' ')}\n`);
|
|
76
|
+
resolve(code);
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
const onSignal = () => stop();
|
|
80
|
+
const onError = cause => stop(cause.code === 'EPIPE' ? 0 : 1, cause);
|
|
81
|
+
const write = events => {
|
|
82
|
+
for (const event of events) {
|
|
83
|
+
if (stopped) break;
|
|
84
|
+
output.write((options.json ? renderJson(event) : renderHuman(event,{width,color:Boolean(output.isTTY && !options.json && !env.NO_COLOR),verbose:options.verbose})) + '\n');
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
for (const signal of signals) proc.on(signal, onSignal);
|
|
88
|
+
output.on('error', onError);
|
|
89
|
+
output.on('resize', resize);
|
|
90
|
+
io.signal?.addEventListener('abort', onSignal, {once:true});
|
|
91
|
+
let ticking = false;
|
|
92
|
+
active = (async () => {
|
|
93
|
+
const scope = await resolveScope({mode:options.mode,dir:options.dir ?? cwd,session:options.session,git});
|
|
94
|
+
if (stopped) return;
|
|
95
|
+
watcher = createWatcher({options,homes,scope,git,now});
|
|
96
|
+
for (const text of disabled) {
|
|
97
|
+
const ts = new Date(now()).toISOString();
|
|
98
|
+
write([{v:1,ts,observedAt:ts,source:'watch',kind:'notice',label:'watch',text}]);
|
|
99
|
+
}
|
|
100
|
+
write(await watcher.start());
|
|
101
|
+
if (stopped) return;
|
|
102
|
+
timer = schedule(() => {
|
|
103
|
+
if (stopped || ticking) return;
|
|
104
|
+
ticking = true;
|
|
105
|
+
active = (async () => { try { write(await watcher.tick()); } finally { ticking = false; } })();
|
|
106
|
+
active.catch(onError);
|
|
107
|
+
return active;
|
|
108
|
+
}, L.filePollMs);
|
|
109
|
+
})();
|
|
110
|
+
active.catch(onError);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function asciiToken(s) {
|
|
2
|
+
return String(s ?? '').replace(/[^A-Za-z0-9._:-]/g, '-').replace(/-+/g, '-');
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function roleFromName(name) {
|
|
6
|
+
return typeof name === 'string' ? /^arc[_-](?:routing[_-])?(scouter|planner|implementer|qa|reviewer)$/.exec(name)?.[1] ?? null : null;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function topLabel({platform, origin, sessionId}) {
|
|
10
|
+
const kind = platform === 'claude'
|
|
11
|
+
? (!origin || origin === 'cli' ? 'main' : `main:${asciiToken(origin)}`)
|
|
12
|
+
: origin === 'codex-tui' ? 'tui' : origin === 'codex_exec' ? 'exec' : asciiToken(origin);
|
|
13
|
+
return `${kind}#${asciiToken(String(sessionId ?? '').slice(-4))}`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function childLabel(parentLabel, {agentRole, agentType, nickname}) {
|
|
17
|
+
const child = roleFromName(agentRole) ?? roleFromName(agentType) ?? nickname ?? agentRole ?? agentType ?? 'agent';
|
|
18
|
+
// Parent separators are structural, so normalize each token separately.
|
|
19
|
+
return `${String(parentLabel).split('/').map(part => part.split(/([#@])/).map(token => token === '#' || token === '@' ? token : asciiToken(token)).join('')).join('/')}/${asciiToken(child)}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function dispatchLabel(rawRole, dispatchId) {
|
|
23
|
+
return `${asciiToken(roleFromName(rawRole) ?? rawRole ?? 'dispatch')}@${String(dispatchId).replace(/[^A-Za-z0-9]/g, '').slice(0,4)}`;
|
|
24
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export const WATCH_KINDS = Object.freeze(['session','settings','turn_start','turn_end','turn_failed','user','agent','reasoning','command','tool','tool_failed','file_change','spawn','approval','dispatch','error','other','notice']);
|
|
2
|
+
export const MESSAGE_KINDS = Object.freeze(['user','agent']);
|
|
3
|
+
export const VERBOSE_KINDS = Object.freeze(['settings','turn_start','reasoning','other']);
|
|
4
|
+
export const ROLE_NAMES = Object.freeze(['scouter','planner','implementer','qa','reviewer']);
|
|
5
|
+
|
|
6
|
+
export const WATCH_LIMITS = Object.freeze({
|
|
7
|
+
filePollMs:500, discoveryMs:2000, worktreeRefreshMs:30000, holdMs:2000,
|
|
8
|
+
holdCreatedWithinMs:10000, attachWindowMs:1800000, historyWindowMs:600000,
|
|
9
|
+
idleDetachMs:1800000, maxFollowed:64, maxReadBytesPerTick:1048576,
|
|
10
|
+
maxLineBytes:4194304, historyBytes:262144, maxRepos:32, claudeHeadBytes:1048576,
|
|
11
|
+
claudeCwdWaitMs:10000, codexMetaBytes:4194304, lookbackDays:7,
|
|
12
|
+
jsonTextMax:1000, agentNameMax:20, pathsMax:20, toolCacheMax:512, defaultTail:20,
|
|
13
|
+
maxTail:1000, widthMin:40, widthMax:2000, ttyWidthMin:60, nonTtyWidth:200,
|
|
14
|
+
gitTimeoutMs:10000,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Normalized event. Omit absent fields rather than assigning null.
|
|
19
|
+
* Unknown dispatch platforms and watch notices omit platform; never infer it from hostPlatform.
|
|
20
|
+
* @typedef {object} WatchEvent
|
|
21
|
+
* @property {1} v
|
|
22
|
+
* @property {string} ts Source timestamp, or observation time if absent.
|
|
23
|
+
* @property {string} observedAt
|
|
24
|
+
* @property {'codex'|'claude'} [platform]
|
|
25
|
+
* @property {'session'|'subagent'|'bridge'|'dispatch'|'watch'} source
|
|
26
|
+
* @property {string} [origin]
|
|
27
|
+
* @property {string} [sessionId]
|
|
28
|
+
* @property {string} [parentId]
|
|
29
|
+
* @property {number} [depth]
|
|
30
|
+
* @property {string} label
|
|
31
|
+
* @property {'scouter'|'planner'|'implementer'|'qa'|'reviewer'|'orchestrator'} [role]
|
|
32
|
+
* @property {string} [dispatchId]
|
|
33
|
+
* @property {string} [workflowId]
|
|
34
|
+
* @property {'session'|'settings'|'turn_start'|'turn_end'|'turn_failed'|'user'|'agent'|'reasoning'|'command'|'tool'|'tool_failed'|'file_change'|'spawn'|'approval'|'dispatch'|'error'|'other'|'notice'} kind
|
|
35
|
+
* @property {string} [text] Sanitized, masked text; user/agent preserve newlines without a length cap. Other JSON text is capped at 1000 code points.
|
|
36
|
+
* @property {boolean} [truncated]
|
|
37
|
+
* @property {number} [exitCode]
|
|
38
|
+
* @property {string} [tool]
|
|
39
|
+
* @property {string[]} [paths] At most 20 paths.
|
|
40
|
+
* @property {string} [model]
|
|
41
|
+
* @property {string} [effort]
|
|
42
|
+
* @property {string} [approval]
|
|
43
|
+
* @property {string} [state]
|
|
44
|
+
* @property {string[]} [reasons]
|
|
45
|
+
* @property {string} [route]
|
|
46
|
+
* @property {string} [hostPlatform]
|
|
47
|
+
* @property {string} [cwd]
|
|
48
|
+
*/
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {WATCH_LIMITS} from './model.mjs';
|
|
2
|
+
|
|
3
|
+
const object = value => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
4
|
+
const string = value => typeof value === 'string';
|
|
5
|
+
|
|
6
|
+
export function createClaudeState() {
|
|
7
|
+
return {modelSeen:false, tools:new Map()};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function parseClaudeHead(obj) {
|
|
11
|
+
try {
|
|
12
|
+
if (!object(obj) || !string(obj.cwd) || !string(obj.sessionId)) return null;
|
|
13
|
+
const head = {sessionId:obj.sessionId, cwd:obj.cwd};
|
|
14
|
+
for (const key of ['entrypoint','version']) if (string(obj[key])) head[key] = obj[key];
|
|
15
|
+
return head;
|
|
16
|
+
} catch { return null; }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function parseClaudeAgentMeta(obj) {
|
|
20
|
+
try {
|
|
21
|
+
if (!object(obj)) return null;
|
|
22
|
+
const meta = {};
|
|
23
|
+
for (const key of ['agentType','description']) if (string(obj[key])) meta[key] = obj[key];
|
|
24
|
+
return Object.keys(meta).length ? meta : null;
|
|
25
|
+
} catch { return null; }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function userText(content) {
|
|
29
|
+
const text = string(content) ? content : Array.isArray(content)
|
|
30
|
+
? content.filter(block => block?.type === 'text' && string(block.text)).map(block => block.text).join('') : '';
|
|
31
|
+
return text.replace(/<(system-reminder|command-[\w-]+|local-command-[\w-]+|task-notification|bash-input|bash-stdout|bash-stderr)\b[^>]*>[\s\S]*?(?:<\/\1\s*>|$)/gi, '');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** State contains only the first-model flag and a bounded tool-name cache. */
|
|
35
|
+
export function normalizeClaudeLine(obj, state) {
|
|
36
|
+
try {
|
|
37
|
+
if (!object(obj) || !['user','assistant'].includes(obj.type) || !object(obj.message)) return [];
|
|
38
|
+
if (!object(state) || !(state.tools instanceof Map)) return [];
|
|
39
|
+
const events = [];
|
|
40
|
+
const emit = (kind, fields={}) => {
|
|
41
|
+
const event = {kind, ...fields};
|
|
42
|
+
if (string(obj.timestamp)) event.ts = obj.timestamp;
|
|
43
|
+
events.push(event);
|
|
44
|
+
};
|
|
45
|
+
const message = obj.message;
|
|
46
|
+
const blocks = Array.isArray(message.content) ? message.content : [];
|
|
47
|
+
if (obj.type === 'user') {
|
|
48
|
+
if (obj.isCompactSummary === true) {
|
|
49
|
+
const text = string(message.content) ? message.content : blocks
|
|
50
|
+
.filter(block => block?.type === 'text' && string(block.text)).map(block => block.text).join('');
|
|
51
|
+
emit('notice', {text:`compact summary (${text.length} chars)`});
|
|
52
|
+
return events;
|
|
53
|
+
}
|
|
54
|
+
// Results never contribute text, even when the line also has toolUseResult.
|
|
55
|
+
for (const block of blocks) {
|
|
56
|
+
if (block?.type === 'tool_result' && block.is_error === true) {
|
|
57
|
+
const tool = state.tools.get(block.tool_use_id);
|
|
58
|
+
emit('tool_failed', string(tool) ? {tool} : {});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (!obj.isMeta && !Object.hasOwn(obj, 'toolUseResult')) {
|
|
62
|
+
const text = userText(message.content);
|
|
63
|
+
if (text.trim()) emit('user', {text});
|
|
64
|
+
}
|
|
65
|
+
return events;
|
|
66
|
+
}
|
|
67
|
+
if (!state.modelSeen && string(message.model) && message.model) {
|
|
68
|
+
state.modelSeen = true;
|
|
69
|
+
emit('settings', {model:message.model});
|
|
70
|
+
}
|
|
71
|
+
for (const block of blocks) {
|
|
72
|
+
if (!object(block)) continue;
|
|
73
|
+
if (block.type === 'text' && string(block.text)) emit('agent', {text:block.text});
|
|
74
|
+
else if (block.type === 'thinking' && string(block.thinking) && block.thinking) emit('reasoning', {text:block.thinking});
|
|
75
|
+
else if (block.type === 'tool_use' && string(block.name)) {
|
|
76
|
+
const name = block.name;
|
|
77
|
+
if (string(block.id)) {
|
|
78
|
+
state.tools.delete(block.id);
|
|
79
|
+
state.tools.set(block.id, name);
|
|
80
|
+
while (state.tools.size > WATCH_LIMITS.toolCacheMax) state.tools.delete(state.tools.keys().next().value);
|
|
81
|
+
}
|
|
82
|
+
const input = object(block.input) ? block.input : {};
|
|
83
|
+
if (name === 'Bash') emit('command', string(input.command) ? {text:input.command} : {});
|
|
84
|
+
else if (['Edit','MultiEdit','Write','NotebookEdit'].includes(name)) {
|
|
85
|
+
emit('file_change', {paths:[...new Set([input.file_path,input.notebook_path].filter(string))].slice(0,WATCH_LIMITS.pathsMax)});
|
|
86
|
+
} else if (['Agent','Task'].includes(name)) {
|
|
87
|
+
const agent = string(input.subagent_type) ? input.subagent_type : '';
|
|
88
|
+
const description = string(input.description) ? input.description : '';
|
|
89
|
+
emit('spawn', {text:agent && description ? `${agent}: ${description}` : agent || description});
|
|
90
|
+
} else if (['Read','Grep','Glob','WebFetch','WebSearch'].includes(name)) {
|
|
91
|
+
const target = [input.file_path,input.pattern,input.path,input.url,input.query].find(string);
|
|
92
|
+
emit('tool', {tool:name, ...(target === undefined ? {} : {text:target})});
|
|
93
|
+
} else emit('tool', {tool:name});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (message.stop_reason === 'end_turn') emit('turn_end');
|
|
97
|
+
return events;
|
|
98
|
+
} catch { return []; }
|
|
99
|
+
}
|