mixdog 0.9.166 → 0.9.167
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/package.json +1 -1
- package/scripts/audit-usage-ledger.mjs +86 -0
- package/scripts/generate-voice-runtime-manifest.mjs +22 -17
- package/scripts/memory-chunk-quality.mjs +128 -0
- package/scripts/memory-layer2-check.mjs +133 -0
- package/scripts/model-catalog-audit.mjs +6 -0
- package/scripts/native-tool-download.mjs +14 -0
- package/scripts/prepare-native-assets.mjs +2 -7
- package/scripts/tool-failures.mjs +7 -2
- package/scripts/verify-release-assets.mjs +48 -90
- package/src/defaults/skills/browser-use/SKILL.md +33 -18
- package/src/defaults/skills/computer-use/SKILL.md +16 -8
- package/src/lib/keychain-cjs.cjs +0 -1
- package/src/lib/rules-builder.cjs +4 -1
- package/src/rules/agent/40-cycle1-agent.md +21 -13
- package/src/rules/lead/01-general.md +8 -3
- package/src/rules/shared/10-tool-workflow.md +20 -11
- package/src/rules/shared/30-exploration.md +11 -4
- package/src/rules/shared/40-editing.md +2 -3
- package/src/rules/shared/50-execution.md +6 -3
- package/src/rules/shared/60-verification.md +3 -2
- package/src/rules/shared/70-delivery.md +0 -4
- package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs +51 -45
- package/src/runtime/agent/orchestrator/agent-runtime/agent-progress-watchdog.mjs +3 -4
- package/src/runtime/agent/orchestrator/agent-trace-format.mjs +44 -7
- package/src/runtime/agent/orchestrator/agent-trace.mjs +9 -0
- package/src/runtime/agent/orchestrator/config.mjs +9 -4
- package/src/runtime/agent/orchestrator/context/collect.mjs +25 -1055
- package/src/runtime/agent/orchestrator/context/deferred-tools.mjs +272 -0
- package/src/runtime/agent/orchestrator/context/role-instructions.mjs +296 -0
- package/src/runtime/agent/orchestrator/context/skill-catalog.mjs +523 -0
- package/src/runtime/agent/orchestrator/providers/account-pool.mjs +7 -2
- package/src/runtime/agent/orchestrator/providers/anthropic-sse.mjs +13 -14
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth-catalog.mjs +214 -0
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth-login.mjs +220 -116
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth-tokens.mjs +74 -44
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth.mjs +191 -29
- package/src/runtime/agent/orchestrator/providers/antigravity-request.mjs +13 -12
- package/src/runtime/agent/orchestrator/providers/cursor-wire-guards.mjs +1 -9
- package/src/runtime/agent/orchestrator/providers/cursor-wire-protobuf.mjs +5 -2
- package/src/runtime/agent/orchestrator/providers/cursor-wire.mjs +48 -25
- package/src/runtime/agent/orchestrator/providers/gemini-schema.mjs +28 -2
- package/src/runtime/agent/orchestrator/providers/gemini-stream.mjs +3 -1
- package/src/runtime/agent/orchestrator/providers/grok-oauth-tokens.mjs +1 -8
- package/src/runtime/agent/orchestrator/providers/lib/action-input-contract.mjs +32 -0
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +21 -6
- package/src/runtime/agent/orchestrator/providers/lib/grok-tool-schema.mjs +61 -13
- package/src/runtime/agent/orchestrator/providers/model-catalog-projection.mjs +6 -1
- package/src/runtime/agent/orchestrator/providers/model-catalog.mjs +123 -118
- package/src/runtime/agent/orchestrator/providers/model-pricing-rates.mjs +54 -0
- package/src/runtime/agent/orchestrator/providers/oauth-credential-probes.mjs +5 -2
- package/src/runtime/agent/orchestrator/providers/oauth-usage.mjs +34 -3
- package/src/runtime/agent/orchestrator/providers/openai-codex-endpoints.mjs +21 -0
- package/src/runtime/agent/orchestrator/providers/openai-oauth-catalog.mjs +154 -0
- package/src/runtime/agent/orchestrator/providers/openai-oauth-http-sse.mjs +2 -1
- package/src/runtime/agent/orchestrator/providers/openai-oauth-tokens.mjs +322 -0
- package/src/runtime/agent/orchestrator/providers/openai-oauth.mjs +243 -702
- package/src/runtime/agent/orchestrator/providers/openai-responses-payload.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/openai-startup-prewarm.mjs +221 -0
- package/src/runtime/agent/orchestrator/providers/openai-ws-stream.mjs +3 -2
- package/src/runtime/agent/orchestrator/providers/openai-ws.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/provider-catalog-cache.mjs +19 -0
- package/src/runtime/agent/orchestrator/providers/provider-model-identities.mjs +40 -0
- package/src/runtime/agent/orchestrator/session/agent-loop.mjs +120 -710
- package/src/runtime/agent/orchestrator/session/cache/read-cache.mjs +36 -15
- package/src/runtime/agent/orchestrator/session/cache/util.mjs +9 -0
- package/src/runtime/agent/orchestrator/session/compact/execution-tail.mjs +17 -4
- package/src/runtime/agent/orchestrator/session/compact/runner.mjs +36 -31
- package/src/runtime/agent/orchestrator/session/compact.mjs +4 -5
- package/src/runtime/agent/orchestrator/session/context-compaction-policy.mjs +6 -5
- package/src/runtime/agent/orchestrator/session/eager-dispatch.mjs +8 -6
- package/src/runtime/agent/orchestrator/session/loop/assistant-commit.mjs +121 -0
- package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +2 -3
- package/src/runtime/agent/orchestrator/session/loop/diagnostics.mjs +74 -0
- package/src/runtime/agent/orchestrator/session/loop/fresh-context.mjs +44 -17
- package/src/runtime/agent/orchestrator/session/loop/no-tool-turn.mjs +266 -0
- package/src/runtime/agent/orchestrator/session/loop/request-boundary.mjs +111 -0
- package/src/runtime/agent/orchestrator/session/loop/request-projection.mjs +99 -0
- package/src/runtime/agent/orchestrator/session/loop/steering.mjs +91 -0
- package/src/runtime/agent/orchestrator/session/loop/usage.mjs +36 -0
- package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +3 -3
- package/src/runtime/agent/orchestrator/session/manager/runtime-liveness.mjs +12 -0
- package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +20 -11
- package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +3 -5
- package/src/runtime/agent/orchestrator/session/send-with-recovery.mjs +9 -3
- package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +39 -0
- package/src/runtime/agent/orchestrator/session/store-transcript-cache.mjs +3 -2
- package/src/runtime/agent/orchestrator/session/tool-batch.mjs +21 -3
- package/src/runtime/agent/orchestrator/tools/builtin/arg-guard.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool.mjs +2 -3
- package/src/runtime/agent/orchestrator/tools/builtin/builtin-tools.mjs +25 -25
- package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.mjs +62 -10
- package/src/runtime/agent/orchestrator/tools/builtin/path-utils.mjs +17 -0
- package/src/runtime/agent/orchestrator/tools/builtin/read-batch.mjs +61 -4
- package/src/runtime/agent/orchestrator/tools/builtin/read-single-tool.mjs +13 -9
- package/src/runtime/agent/orchestrator/tools/builtin/read-snapshot-runtime.mjs +12 -2
- package/src/runtime/agent/orchestrator/tools/builtin/read-streaming.mjs +3 -2
- package/src/runtime/agent/orchestrator/tools/builtin/read-tool.mjs +8 -3
- package/src/runtime/agent/orchestrator/tools/builtin/runtime-capabilities.mjs +69 -6
- package/src/runtime/agent/orchestrator/tools/builtin.mjs +14 -17
- package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/code-graph/source-access.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/code-graph-tool-defs.mjs +6 -6
- package/src/runtime/agent/orchestrator/tools/patch-tool-defs.mjs +1 -1
- package/src/runtime/bridge-discovery.mjs +8 -0
- package/src/runtime/browser-bridge/action-schema.mjs +37 -43
- package/src/runtime/browser-bridge/client.mjs +111 -99
- package/src/runtime/browser-bridge/input-fields.mjs +187 -0
- package/src/runtime/browser-bridge/tool-defs.mjs +12 -227
- package/src/runtime/computer-bridge/action-schema.mjs +2 -46
- package/src/runtime/computer-bridge/client.mjs +69 -77
- package/src/runtime/computer-bridge/core-actions.mjs +7 -5
- package/src/runtime/computer-bridge/error-recovery.mjs +41 -37
- package/src/runtime/computer-bridge/tool-defs.mjs +1 -1
- package/src/runtime/github/commands.mjs +4 -1
- package/src/runtime/github/contract.mjs +1 -1
- package/src/runtime/github/tool.mjs +2 -2
- package/src/runtime/media/adapters/antigravity-image.mjs +72 -0
- package/src/runtime/media/adapters/gemini-image.mjs +20 -11
- package/src/runtime/media/auth.mjs +12 -0
- package/src/runtime/media/catalog.mjs +30 -10
- package/src/runtime/media/jobs.mjs +4 -0
- package/src/runtime/media/lanes.mjs +40 -31
- package/src/runtime/memory/index.mjs +2 -9
- package/src/runtime/memory/lib/compact-handoff.mjs +26 -18
- package/src/runtime/memory/lib/memory-chunk-audit.mjs +41 -0
- package/src/runtime/memory/lib/memory-chunk-quality.mjs +388 -0
- package/src/runtime/memory/lib/memory-cycle1.mjs +95 -394
- package/src/runtime/memory/lib/memory-recall-scope-filter.mjs +29 -4
- package/src/runtime/memory/lib/memory-recall-store.mjs +8 -12
- package/src/runtime/memory/lib/memory-retrievers.mjs +8 -11
- package/src/runtime/memory/lib/memory.mjs +2 -0
- package/src/runtime/memory/lib/query-handlers.mjs +98 -144
- package/src/runtime/memory/lib/query-ranking.mjs +23 -9
- package/src/runtime/memory/lib/recall-format.mjs +37 -27
- package/src/runtime/memory/lib/session-ingest-runtime.mjs +14 -8
- package/src/runtime/memory/lib/session-ingest.mjs +45 -84
- package/src/runtime/memory/lib/transcript-ingest.mjs +19 -21
- package/src/runtime/memory/tool-defs.mjs +2 -2
- package/src/runtime/office/authoring/pptx-author-session.mjs +3 -7
- package/src/runtime/office/core/office-actions-batch.mjs +2 -8
- package/src/runtime/office/core/office-actions-open.mjs +124 -0
- package/src/runtime/office/core/office-actions-read.mjs +127 -0
- package/src/runtime/office/core/office-core.mjs +80 -1
- package/src/runtime/office/core/office-sessions.mjs +116 -138
- package/src/runtime/office/index.mjs +18 -271
- package/src/runtime/office/pdf/pdf-analysis.mjs +2 -2
- package/src/runtime/office/pdf/pdf-limits.mjs +2 -0
- package/src/runtime/office/tool-defs.mjs +7 -6
- package/src/runtime/shared/agent-route-config.mjs +8 -8
- package/src/runtime/shared/child-spawn-gate.mjs +10 -13
- package/src/runtime/shared/config.mjs +2 -7
- package/src/runtime/shared/env.mjs +3 -3
- package/src/runtime/shared/err-text.mjs +1 -1
- package/src/runtime/shared/extension-scopes.mjs +3 -2
- package/src/runtime/shared/heap-cap.mjs +10 -6
- package/src/runtime/shared/llm/cost.mjs +35 -10
- package/src/runtime/shared/llm/usage-accounting.mjs +11 -1
- package/src/runtime/shared/llm/usage-context.mjs +6 -0
- package/src/runtime/shared/llm/usage-ledger-import.mjs +5 -0
- package/src/runtime/shared/llm/usage-ledger-repair.mjs +109 -0
- package/src/runtime/shared/llm/usage-ledger.mjs +59 -20
- package/src/runtime/shared/llm/usage-pricing-refresh.mjs +26 -0
- package/src/runtime/shared/llm/usage-rollup.mjs +17 -15
- package/src/runtime/shared/native-asset.mjs +3 -4
- package/src/runtime/shared/object.mjs +4 -0
- package/src/runtime/shared/pg-schema-db.mjs +21 -0
- package/src/runtime/shared/plugin-metadata.mjs +3 -1
- package/src/runtime/shared/resource-admission.mjs +1 -6
- package/src/runtime/shared/schedules-db.mjs +8 -24
- package/src/runtime/shared/schema-value-error.d.mts +2 -0
- package/src/runtime/shared/schema-value-error.mjs +68 -0
- package/src/runtime/shared/singleton-owner.mjs +11 -24
- package/src/runtime/shared/staged-update.mjs +1 -10
- package/src/runtime/shared/tool-card-model.mjs +8 -5
- package/src/runtime/shared/tool-execution-contract.mjs +1 -1
- package/src/runtime/shared/tool-surface.mjs +1 -5
- package/src/runtime/shared/user-data-guard.mjs +1 -4
- package/src/runtime/shared/webhooks-db.mjs +8 -24
- package/src/runtime/web-search/index.mjs +32 -8
- package/src/runtime/web-search/tool-defs.mjs +4 -4
- package/src/session-runtime/config-lifecycle.mjs +34 -0
- package/src/session-runtime/context-status.mjs +19 -0
- package/src/session-runtime/cwd-plugins.mjs +12 -29
- package/src/session-runtime/goal-tasks.mjs +2 -2
- package/src/session-runtime/goal-tool-defs.mjs +3 -2
- package/src/session-runtime/internal-tool-executor.mjs +7 -0
- package/src/session-runtime/lifecycle-api.mjs +5 -11
- package/src/session-runtime/notification-bus.mjs +41 -0
- package/src/session-runtime/prewarm.mjs +22 -0
- package/src/session-runtime/runtime-bootstrap.mjs +90 -0
- package/src/session-runtime/runtime-core.mjs +88 -202
- package/src/session-runtime/runtime-feature-gates.mjs +37 -0
- package/src/session-runtime/session-lifecycle.mjs +5 -5
- package/src/session-runtime/session-turn-api.mjs +1 -12
- package/src/session-runtime/setup-tool/executor.mjs +13 -5
- package/src/session-runtime/setup-tool/tool-defs.mjs +52 -46
- package/src/session-runtime/tool-defs.mjs +73 -4
- package/src/session-runtime/usage-stats-api.mjs +4 -1
- package/src/session-runtime/warmup-schedulers.mjs +8 -2
- package/src/session-runtime/workflow.mjs +14 -0
- package/src/standalone/channel-session-router.mjs +3 -1
- package/src/standalone/channel-worker.mjs +18 -9
- package/src/standalone/daemon-crash-capture.mjs +534 -0
- package/src/standalone/daemon-telemetry.mjs +175 -0
- package/src/standalone/daemon.mjs +31 -21
- package/src/standalone/session-client.mjs +31 -23
- package/src/standalone/usage-dashboard-model.mjs +2 -0
- package/src/standalone/usage-stats-hours.mjs +18 -11
- package/src/standalone/usage-stats-model.mjs +39 -28
- package/src/standalone/usage-stats-period.mjs +43 -45
- package/src/tui/app/use-transcript-window.mjs +1 -1
- package/src/tui/components/StatusLine.jsx +13 -42
- package/src/tui/dist/index.mjs +256 -239
- package/src/tui/session/session-api-ext.mjs +44 -41
- package/src/tui/session/session-api.mjs +4 -0
- package/src/tui/session/tool-card-results.mjs +25 -78
- package/src/tui/session/tool-result-status.mjs +94 -1
- package/src/tui/session/turn-aggregate-cards.mjs +17 -54
- package/src/ui/statusline-format.mjs +6 -26
- package/src/workflows/default/WORKFLOW.md +5 -0
|
@@ -31,6 +31,9 @@ import {
|
|
|
31
31
|
updateSessionStatus,
|
|
32
32
|
closeSession,
|
|
33
33
|
getSession,
|
|
34
|
+
getSessionLastProgressAt,
|
|
35
|
+
getSessionProgressSnapshot,
|
|
36
|
+
linkParentSignalToSession,
|
|
34
37
|
} from '../session/manager.mjs';
|
|
35
38
|
import {
|
|
36
39
|
abortAgentProgressWatchdog,
|
|
@@ -306,6 +309,27 @@ export function buildAgentDispatchAskSessionArgs(factoryOpts = {}, callArgs = {}
|
|
|
306
309
|
// cancellation sources, so collapse them before installing that one link.
|
|
307
310
|
// The first already-aborted source wins (in declaration order), retaining its
|
|
308
311
|
// original reason instead of replacing it with a generic AbortError.
|
|
312
|
+
function nonEmptyString(value) {
|
|
313
|
+
return typeof value === 'string' && value ? value : null;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function abortDispatchWatchdog({
|
|
317
|
+
controller, sessionId, agent, error, snapshot, policy, now, anchorTs, lastProgressAt,
|
|
318
|
+
}) {
|
|
319
|
+
const sess = getSession(sessionId);
|
|
320
|
+
abortAgentProgressWatchdog(controller, {
|
|
321
|
+
sessionId,
|
|
322
|
+
agent,
|
|
323
|
+
error,
|
|
324
|
+
snapshot,
|
|
325
|
+
policy,
|
|
326
|
+
now,
|
|
327
|
+
anchorTs,
|
|
328
|
+
lastProgressAt,
|
|
329
|
+
iteration: typeof sess?.lastIterationIndex === 'number' ? sess.lastIterationIndex : null,
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
|
|
309
333
|
function composeAgentDispatchAbortSignal(signals) {
|
|
310
334
|
const sources = (Array.isArray(signals) ? signals : [])
|
|
311
335
|
.filter((signal) => signal instanceof AbortSignal);
|
|
@@ -455,9 +479,7 @@ export function makeAgentDispatch(opts = {}) {
|
|
|
455
479
|
// and the downstream skill-discovery path tolerates null. Combined
|
|
456
480
|
// with the frozen agent skill meta-tools (collect.mjs) this keeps
|
|
457
481
|
// every caller on the same provider cache shard.
|
|
458
|
-
const cwd = (
|
|
459
|
-
? callCwd
|
|
460
|
-
: ((typeof opts.cwd === 'string' && opts.cwd) ? opts.cwd : null);
|
|
482
|
+
const cwd = nonEmptyString(callCwd) || nonEmptyString(opts.cwd);
|
|
461
483
|
|
|
462
484
|
// Unified dispatch: Pool B/C share bit-identical tools + system prompt
|
|
463
485
|
// unless a hidden role declares a narrow toolSchemaProfile. Per-role
|
|
@@ -512,24 +534,14 @@ export function makeAgentDispatch(opts = {}) {
|
|
|
512
534
|
await updateStatus(session.id, 'running');
|
|
513
535
|
// Parent→child abort cascade: when opts.parentSignal (factory) or
|
|
514
536
|
// callParentSignal (per-call) fires, abort the sub-session's own
|
|
515
|
-
// controller so the provider call tears down promptly.
|
|
516
|
-
// if the session/manager import is unavailable we fall back silently.
|
|
517
|
-
const _managerMod = await import('../session/manager.mjs').catch(() => null);
|
|
518
|
-
const _linkSignal = _managerMod?.linkParentSignalToSession;
|
|
519
|
-
const _getProgressSnapshot = _managerMod?.getSessionProgressSnapshot;
|
|
520
|
-
const _getLastProgressAt = _managerMod?.getSessionLastProgressAt;
|
|
521
|
-
const _getSession = _managerMod?.getSession || readSession;
|
|
522
|
-
// Watchdog policy is split:
|
|
523
|
-
// - firstResponseTimeoutMs cuts quickly only when the model produces no
|
|
524
|
-
// first stream/tool activity at all.
|
|
525
|
-
// - idle/tool-running caps come from role stallCap (hidden roles) or env defaults.
|
|
537
|
+
// controller so the provider call tears down promptly.
|
|
526
538
|
const _watchdogPolicy = resolveAgentWatchdogPolicy(agent, {
|
|
527
539
|
idleTimeoutMs: Number.isFinite(callIdleTimeoutMs)
|
|
528
540
|
? callIdleTimeoutMs
|
|
529
541
|
: opts.idleTimeoutMs,
|
|
530
542
|
firstResponseTimeoutMs: opts.firstResponseTimeoutMs,
|
|
531
543
|
});
|
|
532
|
-
const _idleController =
|
|
544
|
+
const _idleController = agentWatchdogPolicyActive(_watchdogPolicy)
|
|
533
545
|
? new AbortController()
|
|
534
546
|
: null;
|
|
535
547
|
// Do not link factory parent, per-call cancellation, and the
|
|
@@ -541,53 +553,47 @@ export function makeAgentDispatch(opts = {}) {
|
|
|
541
553
|
callParentSignal,
|
|
542
554
|
_idleController?.signal,
|
|
543
555
|
]);
|
|
544
|
-
if (
|
|
545
|
-
try {
|
|
556
|
+
if (_abortLink.signal) {
|
|
557
|
+
try { linkParentSignalToSession(session.id, _abortLink.signal); } catch { /* ignore */ }
|
|
546
558
|
}
|
|
547
559
|
// Watchdog blind spot guard: when the runtime snapshot is missing AND
|
|
548
560
|
// no progress timestamp exists (pre-liveness hang, swept runtime), the
|
|
549
561
|
// dispatch start time anchors staleness so the abort still fires.
|
|
550
562
|
const _watchdogAnchorTs = Date.now();
|
|
551
|
-
const _idleTimer =
|
|
563
|
+
const _idleTimer = _idleController
|
|
552
564
|
? setInterval(() => {
|
|
553
565
|
if (_idleController.signal?.aborted) return;
|
|
554
566
|
const now = Date.now();
|
|
555
|
-
const snapshot =
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
const last = reported || _watchdogAnchorTs;
|
|
562
|
-
if (_watchdogPolicy.idleStaleMs > 0 && now - last > _watchdogPolicy.idleStaleMs) {
|
|
563
|
-
const err = new AgentStallAbortError(`agent task stale (${_watchdogPolicy.idleStaleMs}ms without progress)`);
|
|
564
|
-
const sess = typeof _getSession === 'function' ? _getSession(session.id) : null;
|
|
565
|
-
abortAgentProgressWatchdog(_idleController, {
|
|
567
|
+
const snapshot = getSessionProgressSnapshot(session.id);
|
|
568
|
+
if (snapshot) {
|
|
569
|
+
const abortErr = evaluateAgentWatchdogAbort(snapshot, now, _watchdogPolicy);
|
|
570
|
+
if (abortErr) {
|
|
571
|
+
abortDispatchWatchdog({
|
|
572
|
+
controller: _idleController,
|
|
566
573
|
sessionId: session.id,
|
|
567
574
|
agent,
|
|
568
|
-
error:
|
|
575
|
+
error: abortErr,
|
|
576
|
+
snapshot,
|
|
569
577
|
policy: _watchdogPolicy,
|
|
570
578
|
now,
|
|
571
579
|
anchorTs: _watchdogAnchorTs,
|
|
572
|
-
lastProgressAt: reported,
|
|
573
|
-
iteration: typeof sess?.lastIterationIndex === 'number' ? sess.lastIterationIndex : null,
|
|
574
580
|
});
|
|
575
581
|
}
|
|
576
582
|
return;
|
|
577
583
|
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}
|
|
584
|
+
const reported = getSessionLastProgressAt(session.id);
|
|
585
|
+
const last = reported || _watchdogAnchorTs;
|
|
586
|
+
if (_watchdogPolicy.idleStaleMs <= 0 || now - last <= _watchdogPolicy.idleStaleMs) return;
|
|
587
|
+
abortDispatchWatchdog({
|
|
588
|
+
controller: _idleController,
|
|
589
|
+
sessionId: session.id,
|
|
590
|
+
agent,
|
|
591
|
+
error: new AgentStallAbortError(`agent task stale (${_watchdogPolicy.idleStaleMs}ms without progress)`),
|
|
592
|
+
policy: _watchdogPolicy,
|
|
593
|
+
now,
|
|
594
|
+
anchorTs: _watchdogAnchorTs,
|
|
595
|
+
lastProgressAt: reported,
|
|
596
|
+
});
|
|
591
597
|
}, 1000)
|
|
592
598
|
: null;
|
|
593
599
|
if (_idleTimer && typeof _idleTimer.unref === 'function') _idleTimer.unref();
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { appendAgentTrace } from '../agent-trace-io.mjs';
|
|
8
8
|
import { getHiddenAgent } from '../internal-agents.mjs';
|
|
9
|
+
import { envNonNegativeInt, envPresent } from '../../../shared/env.mjs';
|
|
9
10
|
import {
|
|
10
11
|
PROVIDER_SEMANTIC_IDLE_TIMEOUT_MS,
|
|
11
12
|
PROVIDER_WS_SEMANTIC_IDLE_TIMEOUT_MS,
|
|
@@ -196,10 +197,8 @@ export function abortAgentProgressWatchdog(controller, ctx) {
|
|
|
196
197
|
}
|
|
197
198
|
|
|
198
199
|
function envTimeoutMs(name, fallback) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const n = Number(raw);
|
|
202
|
-
return Number.isFinite(n) && n >= 0 ? Math.floor(n) : fallback;
|
|
200
|
+
if (!envPresent(name)) return fallback;
|
|
201
|
+
return envNonNegativeInt(name, fallback);
|
|
203
202
|
}
|
|
204
203
|
|
|
205
204
|
const DEFAULT_FIRST_RESPONSE_TIMEOUT_MS = envTimeoutMs(
|
|
@@ -328,8 +328,29 @@ function classifyPatchFailure(text) {
|
|
|
328
328
|
return null;
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
+
function toolTraceText(value) {
|
|
332
|
+
if (typeof value === 'string') return value;
|
|
333
|
+
const parts = Array.isArray(value) ? value : value?.content;
|
|
334
|
+
if (Array.isArray(parts)) {
|
|
335
|
+
return parts.filter((part) => part?.type === 'text' && typeof part.text === 'string')
|
|
336
|
+
.map((part) => part.text).join('\n');
|
|
337
|
+
}
|
|
338
|
+
return value == null ? '' : JSON.stringify(value);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function toolFailureCause(text) {
|
|
342
|
+
const body = text.trim().replace(/^Error:\s*/i, '');
|
|
343
|
+
if (body.startsWith('{')) {
|
|
344
|
+
try {
|
|
345
|
+
const value = JSON.parse(body);
|
|
346
|
+
if (value?.ok === false && typeof value.error === 'string') return value.error;
|
|
347
|
+
} catch { /* Bounded or non-JSON output keeps its original text. */ }
|
|
348
|
+
}
|
|
349
|
+
return text;
|
|
350
|
+
}
|
|
351
|
+
|
|
331
352
|
function classifyToolFailure(resultText, toolName) {
|
|
332
|
-
const raw =
|
|
353
|
+
const raw = toolFailureCause(toolTraceText(resultText));
|
|
333
354
|
const text = raw.toLowerCase();
|
|
334
355
|
if (isExpectedToolCancellation(raw)) return 'expected-cancellation';
|
|
335
356
|
// Shell renderers put the machine-readable status on the leading line.
|
|
@@ -340,6 +361,7 @@ function classifyToolFailure(resultText, toolName) {
|
|
|
340
361
|
.map((line) => line.trim())
|
|
341
362
|
.find((line) => line && !line.startsWith('⚠️ '))
|
|
342
363
|
?.replace(/^Error:\s*/i, '') || '';
|
|
364
|
+
if (/^\[shell-tool-failed\]\s+shell arg "[^"]+" is unsupported\b/i.test(leading)) return 'schema/args';
|
|
343
365
|
if (/^\[shell-tool-failed\](?:\s|$)/i.test(leading)) return 'tool-call/failure';
|
|
344
366
|
if (/^\[shell-run-failed\](?:\s|$)/i.test(leading)) {
|
|
345
367
|
if (/\[timeout:|cause:\s*(?:timeout|cancellation)\b/i.test(leading)) return 'timeout/abort';
|
|
@@ -349,6 +371,21 @@ function classifyToolFailure(resultText, toolName) {
|
|
|
349
371
|
}
|
|
350
372
|
if (/compacted-history placeholder/.test(text)) return 'expected-preflight';
|
|
351
373
|
if (/\[tool-input-validation\]/.test(text)) return 'schema/args';
|
|
374
|
+
// These are emitted validation/cancellation contracts, not keywords found
|
|
375
|
+
// somewhere in a quoted document, command output, or error preview.
|
|
376
|
+
if (/^(?:Browser command interrupted by local user input\.|computer_session_aborted: queued command was cancelled before execution|computer_user_control_active:)/i.test(leading)) return 'expected-cancellation';
|
|
377
|
+
if (/^The arguments provided to `[^`]+` are invalid JSON and could not be parsed:/i.test(leading)
|
|
378
|
+
|| /^new Goal tasks must omit ids; use updates for existing tasks$/i.test(leading)
|
|
379
|
+
|| /^goal task exceeds \d+ characters$/i.test(leading)
|
|
380
|
+
|| /^goal (?:tasks|updates) support at most \d+ entries$/i.test(leading)
|
|
381
|
+
|| /^goal arguments contain unknown fields:/i.test(leading)
|
|
382
|
+
|| /^Unsupported field for GitHub [\w.]+\.$/i.test(leading)
|
|
383
|
+
|| /^browser action "[^"]+" (?:does not accept input field|requires input\.|accepts only one input target form|fields must be inside input:|input\.[^\n]*(?:must be|requires|accepts at most))/i.test(leading)
|
|
384
|
+
|| /^Computer Use [^\n]*(?:does not accept|requires input|must be|accepts at most)/i.test(leading)
|
|
385
|
+
|| /^regex parse error:/i.test(leading)) return 'schema/args';
|
|
386
|
+
if (toolName === 'web_fetch' && /\berrorCode:\s*HTTP_ERROR\b/.test(raw)) return 'upstream/http';
|
|
387
|
+
if (toolName === 'media' && /^generation failed on [^\n]+failed \([45]\d\d\):/i.test(leading)) return 'upstream/http';
|
|
388
|
+
if (toolName === 'web_search' && /^Web search failed: native web search failed: .+: runtime is closing$/i.test(leading)) return 'lifecycle/closing';
|
|
352
389
|
// `shell` results quote git/patch output verbatim (e.g. `git apply`
|
|
353
390
|
// rejects); only real patch surfaces may claim the patch taxonomy, so an
|
|
354
391
|
// ordinary command exit is never rewritten into a patch failure.
|
|
@@ -368,8 +405,8 @@ function classifyToolFailure(resultText, toolName) {
|
|
|
368
405
|
if (patchCategory) return patchCategory;
|
|
369
406
|
if (/\bstat\b.*\bfor delete\b.*\(os error 2\)/.test(text)) return 'path/enoent';
|
|
370
407
|
}
|
|
371
|
-
if (/requires either|invalid arguments|unknown parameter|unknown memory action
|
|
372
|
-
|| /must be|schema|required|old_string is
|
|
408
|
+
if (/requires either|invalid arguments|unknown parameter|unknown memory action/i.test(leading)
|
|
409
|
+
|| /must be|schema|required|old_string is .*>?=/i.test(leading)) return 'schema/args';
|
|
373
410
|
if (/not in allow-list|not allowed/.test(text)) return 'permission';
|
|
374
411
|
if (String(toolName || '') === 'shell' || /^\s*\[exit code:\s*\d+\]/i.test(raw)) return 'command-exit';
|
|
375
412
|
if (isReadOnlyNavigationMiss(toolName, raw)) return 'navigation/miss';
|
|
@@ -396,7 +433,7 @@ function traceAgentToolFailure({ sessionId, iteration, toolName, toolKind, toolM
|
|
|
396
433
|
if (process.env.MIXDOG_AGENT_TRACE_DISABLE === '1') return;
|
|
397
434
|
if (!_resolveToolFailurePath()) return;
|
|
398
435
|
try {
|
|
399
|
-
const cleanText = _redactLogText(
|
|
436
|
+
const cleanText = _redactLogText(toolTraceText(resultText));
|
|
400
437
|
// A session close is deliberate orchestration, not a tool failure.
|
|
401
438
|
// traceAgentTool still records the error/category on the normal trace.
|
|
402
439
|
if (isExpectedToolCancellation(cleanText)) return;
|
|
@@ -413,7 +450,7 @@ function traceAgentToolFailure({ sessionId, iteration, toolName, toolKind, toolM
|
|
|
413
450
|
cwd: cwd || null,
|
|
414
451
|
tool_ms: Number.isFinite(Number(toolMs)) ? Number(toolMs) : null,
|
|
415
452
|
tool_args: summarizeToolArgs(toolName, toolArgs),
|
|
416
|
-
error_first_line: _firstNonEmptyLine(cleanText).slice(0, 300),
|
|
453
|
+
error_first_line: _firstNonEmptyLine(toolFailureCause(cleanText)).slice(0, 300),
|
|
417
454
|
error_preview: cleanText.slice(0, 1200),
|
|
418
455
|
result_bytes_est: Buffer.byteLength(cleanText, 'utf8'),
|
|
419
456
|
result_lines_est: cleanText.length > 0 ? cleanText.split('\n').length : 0,
|
|
@@ -465,13 +502,13 @@ function traceAgentTool({ sessionId, iteration, toolName, toolKind, toolMs, tool
|
|
|
465
502
|
// Keep a short redacted error preview on the tool row itself so trace
|
|
466
503
|
// analysis can see WHY a call failed without joining the failure log.
|
|
467
504
|
const errorFirstLine = resultKind === 'error'
|
|
468
|
-
? _firstNonEmptyLine(_redactLogText(
|
|
505
|
+
? _firstNonEmptyLine(toolFailureCause(_redactLogText(toolTraceText(resultText)))).slice(0, 200) || null
|
|
469
506
|
: null;
|
|
470
507
|
// Failure taxonomy on the tool row itself (mirrors the failure log's
|
|
471
508
|
// `category`) so trace-level aggregation can exclude expected command
|
|
472
509
|
// exits (`command-exit`) without joining tool-failures.jsonl.
|
|
473
510
|
const errorCategory = resultKind === 'error'
|
|
474
|
-
? classifyToolFailure(
|
|
511
|
+
? classifyToolFailure(resultText, toolName)
|
|
475
512
|
: null;
|
|
476
513
|
// Flat shape — fields named exactly as the agent_calls PG columns so
|
|
477
514
|
// insertAgentCalls can pick them up by direct property access without
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isInclusiveProvider } from '../../shared/llm/cost.mjs';
|
|
2
|
+
import { currentUsageContext } from '../../shared/llm/usage-context.mjs';
|
|
2
3
|
import { estimateJsonBytes, hashStructuredValue } from '../../shared/json-metrics.mjs';
|
|
3
4
|
import {
|
|
4
5
|
appendAgentTrace,
|
|
@@ -261,6 +262,7 @@ function traceAgentUsage({
|
|
|
261
262
|
cacheWriteTokens,
|
|
262
263
|
promptTokens,
|
|
263
264
|
model,
|
|
265
|
+
pricingModel,
|
|
264
266
|
modelDisplay,
|
|
265
267
|
responseId,
|
|
266
268
|
rawUsage,
|
|
@@ -272,6 +274,10 @@ function traceAgentUsage({
|
|
|
272
274
|
continuationResetReason,
|
|
273
275
|
inputTokensInclusive,
|
|
274
276
|
}) {
|
|
277
|
+
const identity = currentUsageContext();
|
|
278
|
+
provider = identity?.provider || provider;
|
|
279
|
+
sessionId = identity?.sessionId || sessionId;
|
|
280
|
+
inputTokensInclusive = identity?.inputTokensInclusive ?? inputTokensInclusive;
|
|
275
281
|
const accounting = resolveTraceUsageInput({
|
|
276
282
|
provider,
|
|
277
283
|
inputTokens,
|
|
@@ -308,6 +314,9 @@ function traceAgentUsage({
|
|
|
308
314
|
...(continuationResetReason !== undefined ? { continuation_reset_reason: continuationResetReason } : {}),
|
|
309
315
|
payload: {
|
|
310
316
|
provider: provider || null,
|
|
317
|
+
requested_model: identity?.requestedModel || null,
|
|
318
|
+
pricing_model: pricingModel || identity?.pricingModel || null,
|
|
319
|
+
source_type: identity?.sourceType || null,
|
|
311
320
|
prompt_tokens: promptTotal,
|
|
312
321
|
uncached_input_tokens: accounting.uncachedInputTokens,
|
|
313
322
|
thinking_tokens: thinkingTokens,
|
|
@@ -100,7 +100,7 @@ export function buildDefaultConfig(options = {}) {
|
|
|
100
100
|
return {
|
|
101
101
|
providers,
|
|
102
102
|
disabledAgents: [...DEFAULT_DISABLED_AGENT_IDS],
|
|
103
|
-
workflow: { active: '
|
|
103
|
+
workflow: { active: 'solo' },
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -242,7 +242,7 @@ export function loadConfig(options = {}) {
|
|
|
242
242
|
// Explicit "off" roster. canonicalizeAgentRouteStorage normalizes
|
|
243
243
|
// and drops it when empty, so an all-enabled config stays clean.
|
|
244
244
|
disabledAgents: Array.isArray(raw.disabledAgents) ? raw.disabledAgents : [],
|
|
245
|
-
workflow: raw.workflow && typeof raw.workflow === 'object' ? { active: String(raw.workflow.active || '
|
|
245
|
+
workflow: raw.workflow && typeof raw.workflow === 'object' ? { active: String(raw.workflow.active || 'solo') } : { active: 'solo' },
|
|
246
246
|
profile: normalizeProfileConfig(raw.profile),
|
|
247
247
|
skills: normalizeSkillsConfig(raw.skills),
|
|
248
248
|
extensionScopes: normalizeExtensionScopes(raw.extensionScopes),
|
|
@@ -285,7 +285,7 @@ export function loadConfig(options = {}) {
|
|
|
285
285
|
modelSettings: {},
|
|
286
286
|
onboarding: {},
|
|
287
287
|
agents: {},
|
|
288
|
-
workflow: { active: '
|
|
288
|
+
workflow: { active: 'solo' },
|
|
289
289
|
profile: normalizeProfileConfig(null),
|
|
290
290
|
skills: normalizeSkillsConfig(null),
|
|
291
291
|
extensionScopes: normalizeExtensionScopes(null),
|
|
@@ -384,7 +384,7 @@ function buildAgentSaveBuilder(config) {
|
|
|
384
384
|
modelSettings: canonicalRoutes.modelSettings,
|
|
385
385
|
onboarding: config.onboarding || {},
|
|
386
386
|
agents: canonicalRoutes.agents,
|
|
387
|
-
workflow: config.workflow || { active: '
|
|
387
|
+
workflow: config.workflow || { active: 'solo' },
|
|
388
388
|
profile,
|
|
389
389
|
skills,
|
|
390
390
|
extensionScopes,
|
|
@@ -396,6 +396,11 @@ function buildAgentSaveBuilder(config) {
|
|
|
396
396
|
modules,
|
|
397
397
|
builtins,
|
|
398
398
|
};
|
|
399
|
+
if (canonicalRoutes.disabledAgents) {
|
|
400
|
+
next.disabledAgents = canonicalRoutes.disabledAgents;
|
|
401
|
+
} else {
|
|
402
|
+
delete next.disabledAgents;
|
|
403
|
+
}
|
|
399
404
|
delete next.workflowRoutes;
|
|
400
405
|
return removeRetiredAgentFields(next);
|
|
401
406
|
};
|