@bonesofspring/ai-rules 0.2.91 → 0.2.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/docs/TEAM-DB.md +2 -0
- package/package.json +1 -1
- package/presets/_shared/ai-local/scripts/team-db-api.mjs +33 -15
- package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +15 -0
- package/presets/_shared/ai-local/scripts/team-db-project.mjs +41 -2
- package/presets/_shared/ai-local/scripts/team-db-schema.mjs +23 -0
- package/presets/_shared/core/agent-team/agent-task-metrics.md +16 -1
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +87 -6
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +87 -6
- package/presets/claude/go/hooks/chain-team-phases.sh +87 -6
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +87 -6
- package/presets/claude/java/hooks/chain-team-phases.sh +87 -6
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +87 -6
- package/presets/claude/mol/hooks/chain-team-phases.sh +87 -6
- package/presets/claude/next/hooks/chain-team-phases.sh +87 -6
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +87 -6
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +87 -6
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +87 -6
- package/presets/claude/svelte/hooks/chain-team-phases.sh +87 -6
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +87 -6
- package/presets/cursor/go/hooks/chain-team-phases.sh +87 -6
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +87 -6
- package/presets/cursor/java/hooks/chain-team-phases.sh +87 -6
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +87 -6
- package/presets/cursor/mol/hooks/chain-team-phases.sh +87 -6
- package/presets/cursor/next/hooks/chain-team-phases.sh +87 -6
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +87 -6
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +87 -6
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +87 -6
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +87 -6
- package/presets/mavis/android-kotlin/adapter-map.json +1 -1
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +87 -6
- package/presets/mavis/go/adapter-map.json +1 -1
- package/presets/mavis/go/hooks/chain-team-phases.sh +87 -6
- package/presets/mavis/ios-swift/adapter-map.json +1 -1
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +87 -6
- package/presets/mavis/java/adapter-map.json +1 -1
- package/presets/mavis/java/hooks/chain-team-phases.sh +87 -6
- package/presets/mavis/mcp-ts/adapter-map.json +1 -1
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +87 -6
- package/presets/mavis/mol/adapter-map.json +1 -1
- package/presets/mavis/mol/hooks/chain-team-phases.sh +87 -6
- package/presets/mavis/next/adapter-map.json +1 -1
- package/presets/mavis/next/hooks/chain-team-phases.sh +87 -6
- package/presets/mavis/nuxt/adapter-map.json +1 -1
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +87 -6
- package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +87 -6
- package/presets/mavis/php-laravel/adapter-map.json +1 -1
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +87 -6
- package/presets/mavis/svelte/adapter-map.json +1 -1
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +87 -6
- package/presets/opencode/android-kotlin/adapter-map.json +1 -1
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +87 -6
- package/presets/opencode/go/adapter-map.json +1 -1
- package/presets/opencode/go/hooks/chain-team-phases.sh +87 -6
- package/presets/opencode/ios-swift/adapter-map.json +1 -1
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +87 -6
- package/presets/opencode/java/adapter-map.json +1 -1
- package/presets/opencode/java/hooks/chain-team-phases.sh +87 -6
- package/presets/opencode/mcp-ts/adapter-map.json +1 -1
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +87 -6
- package/presets/opencode/mol/adapter-map.json +1 -1
- package/presets/opencode/mol/hooks/chain-team-phases.sh +87 -6
- package/presets/opencode/next/adapter-map.json +1 -1
- package/presets/opencode/next/hooks/chain-team-phases.sh +87 -6
- package/presets/opencode/nuxt/adapter-map.json +1 -1
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +87 -6
- package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +87 -6
- package/presets/opencode/php-laravel/adapter-map.json +1 -1
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +87 -6
- package/presets/opencode/plugins/task-status/README.md +2 -2
- package/presets/opencode/plugins/task-status/deepseek.ts +8 -4
- package/presets/opencode/svelte/adapter-map.json +1 -1
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +87 -6
- package/presets/zcode/android-kotlin/adapter-map.json +1 -1
- package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +87 -6
- package/presets/zcode/go/adapter-map.json +1 -1
- package/presets/zcode/go/hooks/chain-team-phases.sh +87 -6
- package/presets/zcode/ios-swift/adapter-map.json +1 -1
- package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +87 -6
- package/presets/zcode/java/adapter-map.json +1 -1
- package/presets/zcode/java/hooks/chain-team-phases.sh +87 -6
- package/presets/zcode/mcp-ts/adapter-map.json +1 -1
- package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +87 -6
- package/presets/zcode/mol/adapter-map.json +1 -1
- package/presets/zcode/mol/hooks/chain-team-phases.sh +87 -6
- package/presets/zcode/next/adapter-map.json +1 -1
- package/presets/zcode/next/hooks/chain-team-phases.sh +87 -6
- package/presets/zcode/nuxt/adapter-map.json +1 -1
- package/presets/zcode/nuxt/hooks/chain-team-phases.sh +87 -6
- package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
- package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +87 -6
- package/presets/zcode/php-laravel/adapter-map.json +1 -1
- package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +87 -6
- package/presets/zcode/svelte/adapter-map.json +1 -1
- package/presets/zcode/svelte/hooks/chain-team-phases.sh +87 -6
|
@@ -86,7 +86,20 @@ function writeSessionLease(id, value) {
|
|
|
86
86
|
const temporary = `${file}.${process.pid}.tmp`;
|
|
87
87
|
const now = new Date().toISOString();
|
|
88
88
|
const firstSeenAt = firstSeenAtOf(file, value, now);
|
|
89
|
-
|
|
89
|
+
let model = null;
|
|
90
|
+
try {
|
|
91
|
+
if (Date.now() - fs.statSync(file).mtimeMs <= LEASE_TTL_MS) {
|
|
92
|
+
const previous = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
93
|
+
const previousTool = previous && typeof previous.tool === 'string' ? previous.tool : '';
|
|
94
|
+
const keepModel = previous && previous.slug === value && (previousTool === '' || previousTool === PLATFORM);
|
|
95
|
+
if (keepModel && typeof previous.model === 'string' && /^[A-Za-z0-9][A-Za-z0-9._:@/#-]{0,119}$/.test(previous.model)) {
|
|
96
|
+
model = previous.model;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
} catch {}
|
|
100
|
+
const body = { slug: value, sessionId: id, firstSeenAt, updatedAt: now, tool: PLATFORM };
|
|
101
|
+
if (model) body.model = model;
|
|
102
|
+
fs.writeFileSync(temporary, `${JSON.stringify(body)}\n`);
|
|
90
103
|
fs.renameSync(temporary, file);
|
|
91
104
|
for (const name of fs.readdirSync(LEASE_ROOT)) {
|
|
92
105
|
if (!name.endsWith('.json')) continue;
|
|
@@ -177,8 +190,6 @@ if (slugSource === 'active-task.json') {
|
|
|
177
190
|
if (slugSource !== 'TEAM_TASK_SLUG') {
|
|
178
191
|
process.stderr.write(`WARNING: ${slug}: chain hook resolved the slug from ${slugSource}; pass TEAM_TASK_SLUG=<slug> on every hook call so parallel sessions cannot no-op each other.\n`);
|
|
179
192
|
}
|
|
180
|
-
if (slugSource === 'TEAM_TASK_SLUG' && sessionId) writeSessionLease(sessionId, slug);
|
|
181
|
-
|
|
182
193
|
const taskDir = path.join(TEAM_ROOT, 'tasks', slug);
|
|
183
194
|
const statusPath = path.join(taskDir, 'status.json');
|
|
184
195
|
const pipelinePath = path.join(taskDir, 'pipeline.json');
|
|
@@ -197,6 +208,7 @@ let status;
|
|
|
197
208
|
const now = new Date().toISOString();
|
|
198
209
|
const STACK = 'android-kotlin';
|
|
199
210
|
const PLATFORM = 'opencode';
|
|
211
|
+
if (slugSource === 'TEAM_TASK_SLUG' && sessionId) writeSessionLease(sessionId, slug);
|
|
200
212
|
|
|
201
213
|
let metricsLockToken = null;
|
|
202
214
|
function readMetricsLockToken() {
|
|
@@ -495,6 +507,7 @@ function reclaimStaleAttempts(scope) {
|
|
|
495
507
|
type: 'attempt_finished',
|
|
496
508
|
at: now,
|
|
497
509
|
attemptId,
|
|
510
|
+
...closingExecution(entry, Array.isArray(steps) ? steps[entry.stepIndex] : null),
|
|
498
511
|
stepIndex: entry.stepIndex,
|
|
499
512
|
stepLabel: (Array.isArray(steps) && steps[entry.stepIndex] && steps[entry.stepIndex].label) || null,
|
|
500
513
|
agent: entry.agent,
|
|
@@ -561,6 +574,59 @@ function saveWriteScopeBaseline(step) {
|
|
|
561
574
|
.split('\n').map((line) => line.trim()).filter(Boolean)[0] || `exit ${result ? result.status : 'unknown'}`;
|
|
562
575
|
process.stderr.write(`[chain-team-phases] ${slug}: write-scope baseline for step ${stepId} not saved (${reason}); the audit will skip that step.\n`);
|
|
563
576
|
}
|
|
577
|
+
const MODEL_TIERS = new Set(['cheap', 'standard', 'strong']);
|
|
578
|
+
const MODEL_SOURCES = new Set(['host', 'lease', 'tier-map', 'session']);
|
|
579
|
+
function boundedModel(value) {
|
|
580
|
+
if (typeof value !== 'string') return null;
|
|
581
|
+
const text = value.trim();
|
|
582
|
+
return /^[A-Za-z0-9][A-Za-z0-9._:@/#-]{0,119}$/.test(text) ? text : null;
|
|
583
|
+
}
|
|
584
|
+
function readTierMapModel(tier) {
|
|
585
|
+
try {
|
|
586
|
+
const parsed = JSON.parse(fs.readFileSync(path.join(process.cwd(), '.ai.local', 'team', 'model-tiers.json'), 'utf8'));
|
|
587
|
+
const tiers = parsed && parsed.tiers;
|
|
588
|
+
if (!tiers || typeof tiers !== 'object') return null;
|
|
589
|
+
const approvedBy = typeof parsed.approvedBy === 'string' ? parsed.approvedBy.trim() : '';
|
|
590
|
+
const filled = ['cheap', 'standard', 'strong'].some((key) => typeof tiers[key] === 'string' && tiers[key].trim() !== '');
|
|
591
|
+
if (approvedBy === '' && !filled) return null;
|
|
592
|
+
return boundedModel(tiers[tier]);
|
|
593
|
+
} catch {
|
|
594
|
+
return null;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
function observedModel() {
|
|
598
|
+
const execution = hookInput && hookInput.execution;
|
|
599
|
+
if (execution && typeof execution === 'object') {
|
|
600
|
+
const model = boundedModel(execution.model);
|
|
601
|
+
if (model) return { model, modelSource: MODEL_SOURCES.has(execution.modelSource) ? execution.modelSource : 'host' };
|
|
602
|
+
}
|
|
603
|
+
const direct = boundedModel(hookInput && hookInput.model);
|
|
604
|
+
return direct ? { model: direct, modelSource: 'host' } : null;
|
|
605
|
+
}
|
|
606
|
+
function leaseModel() {
|
|
607
|
+
if (!sessionId) return null;
|
|
608
|
+
const lease = readSessionLease(sessionId);
|
|
609
|
+
if (!lease || lease.tool !== PLATFORM) return null;
|
|
610
|
+
const model = boundedModel(lease.model);
|
|
611
|
+
return model ? { model, modelSource: 'lease' } : null;
|
|
612
|
+
}
|
|
613
|
+
function executionForStep(step) {
|
|
614
|
+
const modelTier = step && MODEL_TIERS.has(step.model) ? step.model : null;
|
|
615
|
+
const observed = observedModel() || leaseModel();
|
|
616
|
+
if (observed) return { tool: PLATFORM, modelTier, model: observed.model, modelSource: observed.modelSource };
|
|
617
|
+
const mapped = modelTier ? readTierMapModel(modelTier) : null;
|
|
618
|
+
if (mapped) return { tool: PLATFORM, modelTier, model: mapped, modelSource: 'tier-map' };
|
|
619
|
+
return { tool: PLATFORM, modelTier, model: null, modelSource: null };
|
|
620
|
+
}
|
|
621
|
+
function closingExecution(entry, step) {
|
|
622
|
+
const model = boundedModel(entry && entry.model);
|
|
623
|
+
const armedTier = entry && MODEL_TIERS.has(entry.modelTier) ? entry.modelTier : null;
|
|
624
|
+
const armedSource = model && entry && MODEL_SOURCES.has(entry.modelSource) ? entry.modelSource : null;
|
|
625
|
+
const observed = observedModel();
|
|
626
|
+
const modelTier = (step && MODEL_TIERS.has(step.model) ? step.model : null) || armedTier;
|
|
627
|
+
if (observed) return { tool: PLATFORM, modelTier, model: observed.model, modelSource: observed.modelSource };
|
|
628
|
+
return { tool: PLATFORM, modelTier, model, modelSource: model ? armedSource : null };
|
|
629
|
+
}
|
|
564
630
|
function activateAttempts(step, stepIndex, waveId = null, agentsOverride = null) {
|
|
565
631
|
const agents = Array.isArray(agentsOverride) && agentsOverride.length > 0 ? agentsOverride : getStepAgents(step);
|
|
566
632
|
const parallelGroupId = step.parallel && getStepAgents(step).length > 1 ? `${status.metricsRunId || slug}:step-${stepIndex}` : null;
|
|
@@ -570,8 +636,9 @@ function activateAttempts(step, stepIndex, waveId = null, agentsOverride = null)
|
|
|
570
636
|
const attempt = nextAttemptOrdinal(stepIndex, agent); const runId = status.metricsRunId || `${slug}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
571
637
|
status.metricsRunId = runId; const attemptId = `${runId}:step-${stepIndex}:${agent}:attempt-${attempt}`;
|
|
572
638
|
if (active[attemptId]) continue;
|
|
573
|
-
|
|
574
|
-
|
|
639
|
+
const execution = executionForStep(step);
|
|
640
|
+
active[attemptId] = { agent, stepIndex, attempt, startedAt: now, parallelGroupId, waveId: waveId || null, ...execution };
|
|
641
|
+
appendMetric({ type: 'attempt_started', at: now, attemptId, stepIndex, stepLabel: step.label || null, agent, role: roleFor(agent), attempt, parallelGroupId, waveId: waveId || null, source: 'hook', attributionConfidence: 'high', ...execution });
|
|
575
642
|
}
|
|
576
643
|
status.activeAttempts = active;
|
|
577
644
|
saveWriteScopeBaseline(step);
|
|
@@ -1575,10 +1642,12 @@ function finishActiveAttempt(forced) {
|
|
|
1575
1642
|
const idleMs = wallMs === null ? null : Math.max(0, wallMs - (activeMs ?? 0));
|
|
1576
1643
|
const outcome = ['completed', 'blocked', 'changes_requested', 'validation_failed'].includes(status.state) ? status.state : 'unknown';
|
|
1577
1644
|
const usage = sanitizeUsage(hookInput.usage);
|
|
1645
|
+
const execution = closingExecution(resolved.entry, Array.isArray(steps) ? steps[resolved.entry.stepIndex] : null);
|
|
1578
1646
|
appendMetric({
|
|
1579
1647
|
type: 'attempt_finished',
|
|
1580
1648
|
at: now,
|
|
1581
1649
|
attemptId: resolved.attemptId,
|
|
1650
|
+
...execution,
|
|
1582
1651
|
stepIndex: typeof resolved.entry.stepIndex === 'number' ? resolved.entry.stepIndex : null,
|
|
1583
1652
|
agent: resolved.entry.agent || null,
|
|
1584
1653
|
outcome,
|
|
@@ -2928,9 +2997,10 @@ function armResumedAttempt(step, stepIndex, agent) {
|
|
|
2928
2997
|
0,
|
|
2929
2998
|
) + 1;
|
|
2930
2999
|
attemptId = `${runId}:step-${stepIndex}:${agent}:attempt-${attempt}`;
|
|
3000
|
+
const execution = executionForStep(step);
|
|
2931
3001
|
status.activeAttempts = {
|
|
2932
3002
|
...(status.activeAttempts || {}),
|
|
2933
|
-
[attemptId]: { agent, stepIndex, attempt, startedAt: now, parallelGroupId: null, waveId: null },
|
|
3003
|
+
[attemptId]: { agent, stepIndex, attempt, startedAt: now, parallelGroupId: null, waveId: null, ...execution },
|
|
2934
3004
|
};
|
|
2935
3005
|
events.push({
|
|
2936
3006
|
eventId: `${runId}:${Date.now()}:${Math.random().toString(16).slice(2)}`,
|
|
@@ -2946,6 +3016,7 @@ function armResumedAttempt(step, stepIndex, agent) {
|
|
|
2946
3016
|
waveId: null,
|
|
2947
3017
|
source: 'hook',
|
|
2948
3018
|
attributionConfidence: 'high',
|
|
3019
|
+
...execution,
|
|
2949
3020
|
});
|
|
2950
3021
|
});
|
|
2951
3022
|
return attemptId;
|
|
@@ -3121,12 +3192,17 @@ if (hookInput.action === 'out_of_band_start') {
|
|
|
3121
3192
|
const agent = typeof hookInput.agent === 'string' ? hookInput.agent : 'unknown';
|
|
3122
3193
|
const reason = typeof hookInput.reason === 'string' ? hookInput.reason : null;
|
|
3123
3194
|
const outOfBandId = `${status.metricsRunId || slug}:oob:${Date.now()}:${Math.random().toString(16).slice(2, 8)}`;
|
|
3195
|
+
const observed = observedModel();
|
|
3124
3196
|
appendMetric({
|
|
3125
3197
|
type: 'out_of_band_started',
|
|
3126
3198
|
outOfBandId,
|
|
3127
3199
|
agent,
|
|
3128
3200
|
reason,
|
|
3129
3201
|
at: now,
|
|
3202
|
+
tool: PLATFORM,
|
|
3203
|
+
modelTier: null,
|
|
3204
|
+
model: observed ? observed.model : null,
|
|
3205
|
+
modelSource: observed ? observed.modelSource : null,
|
|
3130
3206
|
source: 'orchestrator',
|
|
3131
3207
|
attributionConfidence: 'high',
|
|
3132
3208
|
});
|
|
@@ -3161,6 +3237,7 @@ if (hookInput.action === 'out_of_band_end') {
|
|
|
3161
3237
|
}
|
|
3162
3238
|
const durationMs = Math.max(0, Date.parse(now) - Date.parse(started.at));
|
|
3163
3239
|
const outcome = typeof hookInput.outcome === 'string' ? hookInput.outcome : 'completed';
|
|
3240
|
+
const finishedModel = boundedModel(started.model);
|
|
3164
3241
|
appendMetric({
|
|
3165
3242
|
type: 'out_of_band_finished',
|
|
3166
3243
|
outOfBandId: started.outOfBandId,
|
|
@@ -3169,6 +3246,10 @@ if (hookInput.action === 'out_of_band_end') {
|
|
|
3169
3246
|
outcome,
|
|
3170
3247
|
durationMs,
|
|
3171
3248
|
at: now,
|
|
3249
|
+
tool: PLATFORM,
|
|
3250
|
+
modelTier: MODEL_TIERS.has(started.modelTier) ? started.modelTier : null,
|
|
3251
|
+
model: finishedModel,
|
|
3252
|
+
modelSource: finishedModel && MODEL_SOURCES.has(started.modelSource) ? started.modelSource : null,
|
|
3172
3253
|
source: 'orchestrator',
|
|
3173
3254
|
attributionConfidence: 'high',
|
|
3174
3255
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"platform": "opencode",
|
|
4
4
|
"stack": "go",
|
|
5
5
|
"semanticSource": "cursor/go",
|
|
6
|
-
"sourceRevision": "
|
|
6
|
+
"sourceRevision": "7d31d2ab9508e6de003a7f8b11c968e8ce1f04e3ffa37d8eb44d1c1f574365ac",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
9
9
|
"source": "AGENTS.md",
|
|
@@ -87,7 +87,20 @@ function writeSessionLease(id, value) {
|
|
|
87
87
|
const temporary = `${file}.${process.pid}.tmp`;
|
|
88
88
|
const now = new Date().toISOString();
|
|
89
89
|
const firstSeenAt = firstSeenAtOf(file, value, now);
|
|
90
|
-
|
|
90
|
+
let model = null;
|
|
91
|
+
try {
|
|
92
|
+
if (Date.now() - fs.statSync(file).mtimeMs <= LEASE_TTL_MS) {
|
|
93
|
+
const previous = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
94
|
+
const previousTool = previous && typeof previous.tool === 'string' ? previous.tool : '';
|
|
95
|
+
const keepModel = previous && previous.slug === value && (previousTool === '' || previousTool === PLATFORM);
|
|
96
|
+
if (keepModel && typeof previous.model === 'string' && /^[A-Za-z0-9][A-Za-z0-9._:@/#-]{0,119}$/.test(previous.model)) {
|
|
97
|
+
model = previous.model;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
} catch {}
|
|
101
|
+
const body = { slug: value, sessionId: id, firstSeenAt, updatedAt: now, tool: PLATFORM };
|
|
102
|
+
if (model) body.model = model;
|
|
103
|
+
fs.writeFileSync(temporary, `${JSON.stringify(body)}\n`);
|
|
91
104
|
fs.renameSync(temporary, file);
|
|
92
105
|
for (const name of fs.readdirSync(LEASE_ROOT)) {
|
|
93
106
|
if (!name.endsWith('.json')) continue;
|
|
@@ -178,8 +191,6 @@ if (slugSource === 'active-task.json') {
|
|
|
178
191
|
if (slugSource !== 'TEAM_TASK_SLUG') {
|
|
179
192
|
process.stderr.write(`WARNING: ${slug}: chain hook resolved the slug from ${slugSource}; pass TEAM_TASK_SLUG=<slug> on every hook call so parallel sessions cannot no-op each other.\n`);
|
|
180
193
|
}
|
|
181
|
-
if (slugSource === 'TEAM_TASK_SLUG' && sessionId) writeSessionLease(sessionId, slug);
|
|
182
|
-
|
|
183
194
|
const taskDir = path.join(TEAM_ROOT, 'tasks', slug);
|
|
184
195
|
const statusPath = path.join(taskDir, 'status.json');
|
|
185
196
|
const pipelinePath = path.join(taskDir, 'pipeline.json');
|
|
@@ -198,6 +209,7 @@ let status;
|
|
|
198
209
|
const now = new Date().toISOString();
|
|
199
210
|
const STACK = 'go';
|
|
200
211
|
const PLATFORM = 'opencode';
|
|
212
|
+
if (slugSource === 'TEAM_TASK_SLUG' && sessionId) writeSessionLease(sessionId, slug);
|
|
201
213
|
|
|
202
214
|
let metricsLockToken = null;
|
|
203
215
|
function readMetricsLockToken() {
|
|
@@ -494,6 +506,7 @@ function reclaimStaleAttempts(scope) {
|
|
|
494
506
|
type: 'attempt_finished',
|
|
495
507
|
at: now,
|
|
496
508
|
attemptId,
|
|
509
|
+
...closingExecution(entry, Array.isArray(steps) ? steps[entry.stepIndex] : null),
|
|
497
510
|
stepIndex: entry.stepIndex,
|
|
498
511
|
stepLabel: (Array.isArray(steps) && steps[entry.stepIndex] && steps[entry.stepIndex].label) || null,
|
|
499
512
|
agent: entry.agent,
|
|
@@ -560,6 +573,59 @@ function saveWriteScopeBaseline(step) {
|
|
|
560
573
|
.split('\n').map((line) => line.trim()).filter(Boolean)[0] || `exit ${result ? result.status : 'unknown'}`;
|
|
561
574
|
process.stderr.write(`[chain-team-phases] ${slug}: write-scope baseline for step ${stepId} not saved (${reason}); the audit will skip that step.\n`);
|
|
562
575
|
}
|
|
576
|
+
const MODEL_TIERS = new Set(['cheap', 'standard', 'strong']);
|
|
577
|
+
const MODEL_SOURCES = new Set(['host', 'lease', 'tier-map', 'session']);
|
|
578
|
+
function boundedModel(value) {
|
|
579
|
+
if (typeof value !== 'string') return null;
|
|
580
|
+
const text = value.trim();
|
|
581
|
+
return /^[A-Za-z0-9][A-Za-z0-9._:@/#-]{0,119}$/.test(text) ? text : null;
|
|
582
|
+
}
|
|
583
|
+
function readTierMapModel(tier) {
|
|
584
|
+
try {
|
|
585
|
+
const parsed = JSON.parse(fs.readFileSync(path.join(process.cwd(), '.ai.local', 'team', 'model-tiers.json'), 'utf8'));
|
|
586
|
+
const tiers = parsed && parsed.tiers;
|
|
587
|
+
if (!tiers || typeof tiers !== 'object') return null;
|
|
588
|
+
const approvedBy = typeof parsed.approvedBy === 'string' ? parsed.approvedBy.trim() : '';
|
|
589
|
+
const filled = ['cheap', 'standard', 'strong'].some((key) => typeof tiers[key] === 'string' && tiers[key].trim() !== '');
|
|
590
|
+
if (approvedBy === '' && !filled) return null;
|
|
591
|
+
return boundedModel(tiers[tier]);
|
|
592
|
+
} catch {
|
|
593
|
+
return null;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
function observedModel() {
|
|
597
|
+
const execution = hookInput && hookInput.execution;
|
|
598
|
+
if (execution && typeof execution === 'object') {
|
|
599
|
+
const model = boundedModel(execution.model);
|
|
600
|
+
if (model) return { model, modelSource: MODEL_SOURCES.has(execution.modelSource) ? execution.modelSource : 'host' };
|
|
601
|
+
}
|
|
602
|
+
const direct = boundedModel(hookInput && hookInput.model);
|
|
603
|
+
return direct ? { model: direct, modelSource: 'host' } : null;
|
|
604
|
+
}
|
|
605
|
+
function leaseModel() {
|
|
606
|
+
if (!sessionId) return null;
|
|
607
|
+
const lease = readSessionLease(sessionId);
|
|
608
|
+
if (!lease || lease.tool !== PLATFORM) return null;
|
|
609
|
+
const model = boundedModel(lease.model);
|
|
610
|
+
return model ? { model, modelSource: 'lease' } : null;
|
|
611
|
+
}
|
|
612
|
+
function executionForStep(step) {
|
|
613
|
+
const modelTier = step && MODEL_TIERS.has(step.model) ? step.model : null;
|
|
614
|
+
const observed = observedModel() || leaseModel();
|
|
615
|
+
if (observed) return { tool: PLATFORM, modelTier, model: observed.model, modelSource: observed.modelSource };
|
|
616
|
+
const mapped = modelTier ? readTierMapModel(modelTier) : null;
|
|
617
|
+
if (mapped) return { tool: PLATFORM, modelTier, model: mapped, modelSource: 'tier-map' };
|
|
618
|
+
return { tool: PLATFORM, modelTier, model: null, modelSource: null };
|
|
619
|
+
}
|
|
620
|
+
function closingExecution(entry, step) {
|
|
621
|
+
const model = boundedModel(entry && entry.model);
|
|
622
|
+
const armedTier = entry && MODEL_TIERS.has(entry.modelTier) ? entry.modelTier : null;
|
|
623
|
+
const armedSource = model && entry && MODEL_SOURCES.has(entry.modelSource) ? entry.modelSource : null;
|
|
624
|
+
const observed = observedModel();
|
|
625
|
+
const modelTier = (step && MODEL_TIERS.has(step.model) ? step.model : null) || armedTier;
|
|
626
|
+
if (observed) return { tool: PLATFORM, modelTier, model: observed.model, modelSource: observed.modelSource };
|
|
627
|
+
return { tool: PLATFORM, modelTier, model, modelSource: model ? armedSource : null };
|
|
628
|
+
}
|
|
563
629
|
function activateAttempts(step, stepIndex, waveId = null, agentsOverride = null) {
|
|
564
630
|
const agents = Array.isArray(agentsOverride) && agentsOverride.length > 0 ? agentsOverride : getStepAgents(step);
|
|
565
631
|
const parallelGroupId = step.parallel && getStepAgents(step).length > 1 ? `${status.metricsRunId || slug}:step-${stepIndex}` : null;
|
|
@@ -569,8 +635,9 @@ function activateAttempts(step, stepIndex, waveId = null, agentsOverride = null)
|
|
|
569
635
|
const attempt = nextAttemptOrdinal(stepIndex, agent); const runId = status.metricsRunId || `${slug}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
570
636
|
status.metricsRunId = runId; const attemptId = `${runId}:step-${stepIndex}:${agent}:attempt-${attempt}`;
|
|
571
637
|
if (active[attemptId]) continue;
|
|
572
|
-
|
|
573
|
-
|
|
638
|
+
const execution = executionForStep(step);
|
|
639
|
+
active[attemptId] = { agent, stepIndex, attempt, startedAt: now, parallelGroupId, waveId: waveId || null, ...execution };
|
|
640
|
+
appendMetric({ type: 'attempt_started', at: now, attemptId, stepIndex, stepLabel: step.label || null, agent, role: roleFor(agent), attempt, parallelGroupId, waveId: waveId || null, source: 'hook', attributionConfidence: 'high', ...execution });
|
|
574
641
|
}
|
|
575
642
|
status.activeAttempts = active;
|
|
576
643
|
saveWriteScopeBaseline(step);
|
|
@@ -1574,10 +1641,12 @@ function finishActiveAttempt(forced) {
|
|
|
1574
1641
|
const idleMs = wallMs === null ? null : Math.max(0, wallMs - (activeMs ?? 0));
|
|
1575
1642
|
const outcome = ['completed', 'blocked', 'changes_requested', 'validation_failed'].includes(status.state) ? status.state : 'unknown';
|
|
1576
1643
|
const usage = sanitizeUsage(hookInput.usage);
|
|
1644
|
+
const execution = closingExecution(resolved.entry, Array.isArray(steps) ? steps[resolved.entry.stepIndex] : null);
|
|
1577
1645
|
appendMetric({
|
|
1578
1646
|
type: 'attempt_finished',
|
|
1579
1647
|
at: now,
|
|
1580
1648
|
attemptId: resolved.attemptId,
|
|
1649
|
+
...execution,
|
|
1581
1650
|
stepIndex: typeof resolved.entry.stepIndex === 'number' ? resolved.entry.stepIndex : null,
|
|
1582
1651
|
agent: resolved.entry.agent || null,
|
|
1583
1652
|
outcome,
|
|
@@ -2923,9 +2992,10 @@ function armResumedAttempt(step, stepIndex, agent) {
|
|
|
2923
2992
|
0,
|
|
2924
2993
|
) + 1;
|
|
2925
2994
|
attemptId = `${runId}:step-${stepIndex}:${agent}:attempt-${attempt}`;
|
|
2995
|
+
const execution = executionForStep(step);
|
|
2926
2996
|
status.activeAttempts = {
|
|
2927
2997
|
...(status.activeAttempts || {}),
|
|
2928
|
-
[attemptId]: { agent, stepIndex, attempt, startedAt: now, parallelGroupId: null, waveId: null },
|
|
2998
|
+
[attemptId]: { agent, stepIndex, attempt, startedAt: now, parallelGroupId: null, waveId: null, ...execution },
|
|
2929
2999
|
};
|
|
2930
3000
|
events.push({
|
|
2931
3001
|
eventId: `${runId}:${Date.now()}:${Math.random().toString(16).slice(2)}`,
|
|
@@ -2941,6 +3011,7 @@ function armResumedAttempt(step, stepIndex, agent) {
|
|
|
2941
3011
|
waveId: null,
|
|
2942
3012
|
source: 'hook',
|
|
2943
3013
|
attributionConfidence: 'high',
|
|
3014
|
+
...execution,
|
|
2944
3015
|
});
|
|
2945
3016
|
});
|
|
2946
3017
|
return attemptId;
|
|
@@ -3116,12 +3187,17 @@ if (hookInput.action === 'out_of_band_start') {
|
|
|
3116
3187
|
const agent = typeof hookInput.agent === 'string' ? hookInput.agent : 'unknown';
|
|
3117
3188
|
const reason = typeof hookInput.reason === 'string' ? hookInput.reason : null;
|
|
3118
3189
|
const outOfBandId = `${status.metricsRunId || slug}:oob:${Date.now()}:${Math.random().toString(16).slice(2, 8)}`;
|
|
3190
|
+
const observed = observedModel();
|
|
3119
3191
|
appendMetric({
|
|
3120
3192
|
type: 'out_of_band_started',
|
|
3121
3193
|
outOfBandId,
|
|
3122
3194
|
agent,
|
|
3123
3195
|
reason,
|
|
3124
3196
|
at: now,
|
|
3197
|
+
tool: PLATFORM,
|
|
3198
|
+
modelTier: null,
|
|
3199
|
+
model: observed ? observed.model : null,
|
|
3200
|
+
modelSource: observed ? observed.modelSource : null,
|
|
3125
3201
|
source: 'orchestrator',
|
|
3126
3202
|
attributionConfidence: 'high',
|
|
3127
3203
|
});
|
|
@@ -3156,6 +3232,7 @@ if (hookInput.action === 'out_of_band_end') {
|
|
|
3156
3232
|
}
|
|
3157
3233
|
const durationMs = Math.max(0, Date.parse(now) - Date.parse(started.at));
|
|
3158
3234
|
const outcome = typeof hookInput.outcome === 'string' ? hookInput.outcome : 'completed';
|
|
3235
|
+
const finishedModel = boundedModel(started.model);
|
|
3159
3236
|
appendMetric({
|
|
3160
3237
|
type: 'out_of_band_finished',
|
|
3161
3238
|
outOfBandId: started.outOfBandId,
|
|
@@ -3164,6 +3241,10 @@ if (hookInput.action === 'out_of_band_end') {
|
|
|
3164
3241
|
outcome,
|
|
3165
3242
|
durationMs,
|
|
3166
3243
|
at: now,
|
|
3244
|
+
tool: PLATFORM,
|
|
3245
|
+
modelTier: MODEL_TIERS.has(started.modelTier) ? started.modelTier : null,
|
|
3246
|
+
model: finishedModel,
|
|
3247
|
+
modelSource: finishedModel && MODEL_SOURCES.has(started.modelSource) ? started.modelSource : null,
|
|
3167
3248
|
source: 'orchestrator',
|
|
3168
3249
|
attributionConfidence: 'high',
|
|
3169
3250
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"platform": "opencode",
|
|
4
4
|
"stack": "ios-swift",
|
|
5
5
|
"semanticSource": "cursor/ios-swift",
|
|
6
|
-
"sourceRevision": "
|
|
6
|
+
"sourceRevision": "a55e671e7867e277ebbd1e9873a4f5e072b2b3fb070553b046d998f6278c36a6",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
9
9
|
"source": "AGENTS.md",
|
|
@@ -86,7 +86,20 @@ function writeSessionLease(id, value) {
|
|
|
86
86
|
const temporary = `${file}.${process.pid}.tmp`;
|
|
87
87
|
const now = new Date().toISOString();
|
|
88
88
|
const firstSeenAt = firstSeenAtOf(file, value, now);
|
|
89
|
-
|
|
89
|
+
let model = null;
|
|
90
|
+
try {
|
|
91
|
+
if (Date.now() - fs.statSync(file).mtimeMs <= LEASE_TTL_MS) {
|
|
92
|
+
const previous = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
93
|
+
const previousTool = previous && typeof previous.tool === 'string' ? previous.tool : '';
|
|
94
|
+
const keepModel = previous && previous.slug === value && (previousTool === '' || previousTool === PLATFORM);
|
|
95
|
+
if (keepModel && typeof previous.model === 'string' && /^[A-Za-z0-9][A-Za-z0-9._:@/#-]{0,119}$/.test(previous.model)) {
|
|
96
|
+
model = previous.model;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
} catch {}
|
|
100
|
+
const body = { slug: value, sessionId: id, firstSeenAt, updatedAt: now, tool: PLATFORM };
|
|
101
|
+
if (model) body.model = model;
|
|
102
|
+
fs.writeFileSync(temporary, `${JSON.stringify(body)}\n`);
|
|
90
103
|
fs.renameSync(temporary, file);
|
|
91
104
|
for (const name of fs.readdirSync(LEASE_ROOT)) {
|
|
92
105
|
if (!name.endsWith('.json')) continue;
|
|
@@ -177,8 +190,6 @@ if (slugSource === 'active-task.json') {
|
|
|
177
190
|
if (slugSource !== 'TEAM_TASK_SLUG') {
|
|
178
191
|
process.stderr.write(`WARNING: ${slug}: chain hook resolved the slug from ${slugSource}; pass TEAM_TASK_SLUG=<slug> on every hook call so parallel sessions cannot no-op each other.\n`);
|
|
179
192
|
}
|
|
180
|
-
if (slugSource === 'TEAM_TASK_SLUG' && sessionId) writeSessionLease(sessionId, slug);
|
|
181
|
-
|
|
182
193
|
const taskDir = path.join(TEAM_ROOT, 'tasks', slug);
|
|
183
194
|
const statusPath = path.join(taskDir, 'status.json');
|
|
184
195
|
const pipelinePath = path.join(taskDir, 'pipeline.json');
|
|
@@ -197,6 +208,7 @@ let status;
|
|
|
197
208
|
const now = new Date().toISOString();
|
|
198
209
|
const STACK = 'ios-swift';
|
|
199
210
|
const PLATFORM = 'opencode';
|
|
211
|
+
if (slugSource === 'TEAM_TASK_SLUG' && sessionId) writeSessionLease(sessionId, slug);
|
|
200
212
|
|
|
201
213
|
let metricsLockToken = null;
|
|
202
214
|
function readMetricsLockToken() {
|
|
@@ -495,6 +507,7 @@ function reclaimStaleAttempts(scope) {
|
|
|
495
507
|
type: 'attempt_finished',
|
|
496
508
|
at: now,
|
|
497
509
|
attemptId,
|
|
510
|
+
...closingExecution(entry, Array.isArray(steps) ? steps[entry.stepIndex] : null),
|
|
498
511
|
stepIndex: entry.stepIndex,
|
|
499
512
|
stepLabel: (Array.isArray(steps) && steps[entry.stepIndex] && steps[entry.stepIndex].label) || null,
|
|
500
513
|
agent: entry.agent,
|
|
@@ -561,6 +574,59 @@ function saveWriteScopeBaseline(step) {
|
|
|
561
574
|
.split('\n').map((line) => line.trim()).filter(Boolean)[0] || `exit ${result ? result.status : 'unknown'}`;
|
|
562
575
|
process.stderr.write(`[chain-team-phases] ${slug}: write-scope baseline for step ${stepId} not saved (${reason}); the audit will skip that step.\n`);
|
|
563
576
|
}
|
|
577
|
+
const MODEL_TIERS = new Set(['cheap', 'standard', 'strong']);
|
|
578
|
+
const MODEL_SOURCES = new Set(['host', 'lease', 'tier-map', 'session']);
|
|
579
|
+
function boundedModel(value) {
|
|
580
|
+
if (typeof value !== 'string') return null;
|
|
581
|
+
const text = value.trim();
|
|
582
|
+
return /^[A-Za-z0-9][A-Za-z0-9._:@/#-]{0,119}$/.test(text) ? text : null;
|
|
583
|
+
}
|
|
584
|
+
function readTierMapModel(tier) {
|
|
585
|
+
try {
|
|
586
|
+
const parsed = JSON.parse(fs.readFileSync(path.join(process.cwd(), '.ai.local', 'team', 'model-tiers.json'), 'utf8'));
|
|
587
|
+
const tiers = parsed && parsed.tiers;
|
|
588
|
+
if (!tiers || typeof tiers !== 'object') return null;
|
|
589
|
+
const approvedBy = typeof parsed.approvedBy === 'string' ? parsed.approvedBy.trim() : '';
|
|
590
|
+
const filled = ['cheap', 'standard', 'strong'].some((key) => typeof tiers[key] === 'string' && tiers[key].trim() !== '');
|
|
591
|
+
if (approvedBy === '' && !filled) return null;
|
|
592
|
+
return boundedModel(tiers[tier]);
|
|
593
|
+
} catch {
|
|
594
|
+
return null;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
function observedModel() {
|
|
598
|
+
const execution = hookInput && hookInput.execution;
|
|
599
|
+
if (execution && typeof execution === 'object') {
|
|
600
|
+
const model = boundedModel(execution.model);
|
|
601
|
+
if (model) return { model, modelSource: MODEL_SOURCES.has(execution.modelSource) ? execution.modelSource : 'host' };
|
|
602
|
+
}
|
|
603
|
+
const direct = boundedModel(hookInput && hookInput.model);
|
|
604
|
+
return direct ? { model: direct, modelSource: 'host' } : null;
|
|
605
|
+
}
|
|
606
|
+
function leaseModel() {
|
|
607
|
+
if (!sessionId) return null;
|
|
608
|
+
const lease = readSessionLease(sessionId);
|
|
609
|
+
if (!lease || lease.tool !== PLATFORM) return null;
|
|
610
|
+
const model = boundedModel(lease.model);
|
|
611
|
+
return model ? { model, modelSource: 'lease' } : null;
|
|
612
|
+
}
|
|
613
|
+
function executionForStep(step) {
|
|
614
|
+
const modelTier = step && MODEL_TIERS.has(step.model) ? step.model : null;
|
|
615
|
+
const observed = observedModel() || leaseModel();
|
|
616
|
+
if (observed) return { tool: PLATFORM, modelTier, model: observed.model, modelSource: observed.modelSource };
|
|
617
|
+
const mapped = modelTier ? readTierMapModel(modelTier) : null;
|
|
618
|
+
if (mapped) return { tool: PLATFORM, modelTier, model: mapped, modelSource: 'tier-map' };
|
|
619
|
+
return { tool: PLATFORM, modelTier, model: null, modelSource: null };
|
|
620
|
+
}
|
|
621
|
+
function closingExecution(entry, step) {
|
|
622
|
+
const model = boundedModel(entry && entry.model);
|
|
623
|
+
const armedTier = entry && MODEL_TIERS.has(entry.modelTier) ? entry.modelTier : null;
|
|
624
|
+
const armedSource = model && entry && MODEL_SOURCES.has(entry.modelSource) ? entry.modelSource : null;
|
|
625
|
+
const observed = observedModel();
|
|
626
|
+
const modelTier = (step && MODEL_TIERS.has(step.model) ? step.model : null) || armedTier;
|
|
627
|
+
if (observed) return { tool: PLATFORM, modelTier, model: observed.model, modelSource: observed.modelSource };
|
|
628
|
+
return { tool: PLATFORM, modelTier, model, modelSource: model ? armedSource : null };
|
|
629
|
+
}
|
|
564
630
|
function activateAttempts(step, stepIndex, waveId = null, agentsOverride = null) {
|
|
565
631
|
const agents = Array.isArray(agentsOverride) && agentsOverride.length > 0 ? agentsOverride : getStepAgents(step);
|
|
566
632
|
const parallelGroupId = step.parallel && getStepAgents(step).length > 1 ? `${status.metricsRunId || slug}:step-${stepIndex}` : null;
|
|
@@ -570,8 +636,9 @@ function activateAttempts(step, stepIndex, waveId = null, agentsOverride = null)
|
|
|
570
636
|
const attempt = nextAttemptOrdinal(stepIndex, agent); const runId = status.metricsRunId || `${slug}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
571
637
|
status.metricsRunId = runId; const attemptId = `${runId}:step-${stepIndex}:${agent}:attempt-${attempt}`;
|
|
572
638
|
if (active[attemptId]) continue;
|
|
573
|
-
|
|
574
|
-
|
|
639
|
+
const execution = executionForStep(step);
|
|
640
|
+
active[attemptId] = { agent, stepIndex, attempt, startedAt: now, parallelGroupId, waveId: waveId || null, ...execution };
|
|
641
|
+
appendMetric({ type: 'attempt_started', at: now, attemptId, stepIndex, stepLabel: step.label || null, agent, role: roleFor(agent), attempt, parallelGroupId, waveId: waveId || null, source: 'hook', attributionConfidence: 'high', ...execution });
|
|
575
642
|
}
|
|
576
643
|
status.activeAttempts = active;
|
|
577
644
|
saveWriteScopeBaseline(step);
|
|
@@ -1575,10 +1642,12 @@ function finishActiveAttempt(forced) {
|
|
|
1575
1642
|
const idleMs = wallMs === null ? null : Math.max(0, wallMs - (activeMs ?? 0));
|
|
1576
1643
|
const outcome = ['completed', 'blocked', 'changes_requested', 'validation_failed'].includes(status.state) ? status.state : 'unknown';
|
|
1577
1644
|
const usage = sanitizeUsage(hookInput.usage);
|
|
1645
|
+
const execution = closingExecution(resolved.entry, Array.isArray(steps) ? steps[resolved.entry.stepIndex] : null);
|
|
1578
1646
|
appendMetric({
|
|
1579
1647
|
type: 'attempt_finished',
|
|
1580
1648
|
at: now,
|
|
1581
1649
|
attemptId: resolved.attemptId,
|
|
1650
|
+
...execution,
|
|
1582
1651
|
stepIndex: typeof resolved.entry.stepIndex === 'number' ? resolved.entry.stepIndex : null,
|
|
1583
1652
|
agent: resolved.entry.agent || null,
|
|
1584
1653
|
outcome,
|
|
@@ -2928,9 +2997,10 @@ function armResumedAttempt(step, stepIndex, agent) {
|
|
|
2928
2997
|
0,
|
|
2929
2998
|
) + 1;
|
|
2930
2999
|
attemptId = `${runId}:step-${stepIndex}:${agent}:attempt-${attempt}`;
|
|
3000
|
+
const execution = executionForStep(step);
|
|
2931
3001
|
status.activeAttempts = {
|
|
2932
3002
|
...(status.activeAttempts || {}),
|
|
2933
|
-
[attemptId]: { agent, stepIndex, attempt, startedAt: now, parallelGroupId: null, waveId: null },
|
|
3003
|
+
[attemptId]: { agent, stepIndex, attempt, startedAt: now, parallelGroupId: null, waveId: null, ...execution },
|
|
2934
3004
|
};
|
|
2935
3005
|
events.push({
|
|
2936
3006
|
eventId: `${runId}:${Date.now()}:${Math.random().toString(16).slice(2)}`,
|
|
@@ -2946,6 +3016,7 @@ function armResumedAttempt(step, stepIndex, agent) {
|
|
|
2946
3016
|
waveId: null,
|
|
2947
3017
|
source: 'hook',
|
|
2948
3018
|
attributionConfidence: 'high',
|
|
3019
|
+
...execution,
|
|
2949
3020
|
});
|
|
2950
3021
|
});
|
|
2951
3022
|
return attemptId;
|
|
@@ -3121,12 +3192,17 @@ if (hookInput.action === 'out_of_band_start') {
|
|
|
3121
3192
|
const agent = typeof hookInput.agent === 'string' ? hookInput.agent : 'unknown';
|
|
3122
3193
|
const reason = typeof hookInput.reason === 'string' ? hookInput.reason : null;
|
|
3123
3194
|
const outOfBandId = `${status.metricsRunId || slug}:oob:${Date.now()}:${Math.random().toString(16).slice(2, 8)}`;
|
|
3195
|
+
const observed = observedModel();
|
|
3124
3196
|
appendMetric({
|
|
3125
3197
|
type: 'out_of_band_started',
|
|
3126
3198
|
outOfBandId,
|
|
3127
3199
|
agent,
|
|
3128
3200
|
reason,
|
|
3129
3201
|
at: now,
|
|
3202
|
+
tool: PLATFORM,
|
|
3203
|
+
modelTier: null,
|
|
3204
|
+
model: observed ? observed.model : null,
|
|
3205
|
+
modelSource: observed ? observed.modelSource : null,
|
|
3130
3206
|
source: 'orchestrator',
|
|
3131
3207
|
attributionConfidence: 'high',
|
|
3132
3208
|
});
|
|
@@ -3161,6 +3237,7 @@ if (hookInput.action === 'out_of_band_end') {
|
|
|
3161
3237
|
}
|
|
3162
3238
|
const durationMs = Math.max(0, Date.parse(now) - Date.parse(started.at));
|
|
3163
3239
|
const outcome = typeof hookInput.outcome === 'string' ? hookInput.outcome : 'completed';
|
|
3240
|
+
const finishedModel = boundedModel(started.model);
|
|
3164
3241
|
appendMetric({
|
|
3165
3242
|
type: 'out_of_band_finished',
|
|
3166
3243
|
outOfBandId: started.outOfBandId,
|
|
@@ -3169,6 +3246,10 @@ if (hookInput.action === 'out_of_band_end') {
|
|
|
3169
3246
|
outcome,
|
|
3170
3247
|
durationMs,
|
|
3171
3248
|
at: now,
|
|
3249
|
+
tool: PLATFORM,
|
|
3250
|
+
modelTier: MODEL_TIERS.has(started.modelTier) ? started.modelTier : null,
|
|
3251
|
+
model: finishedModel,
|
|
3252
|
+
modelSource: finishedModel && MODEL_SOURCES.has(started.modelSource) ? started.modelSource : null,
|
|
3172
3253
|
source: 'orchestrator',
|
|
3173
3254
|
attributionConfidence: 'high',
|
|
3174
3255
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"platform": "opencode",
|
|
4
4
|
"stack": "java",
|
|
5
5
|
"semanticSource": "cursor/java",
|
|
6
|
-
"sourceRevision": "
|
|
6
|
+
"sourceRevision": "90e18d05b81ff995f9a07830c9d6ca88df1aab8f3fd9e804f44e41957a811d52",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
9
9
|
"source": "AGENTS.md",
|