@aiwg/cli 2026.11.4 → 2026.11.5
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/agentic/code/providers/capability-matrix.yaml +75 -5
- package/agentic/code/providers/model-capabilities.v1.json +35 -27
- package/dist/src/artifacts/index-builder.js +4 -2
- package/dist/src/artifacts/query-engine-rules.js +2 -2
- package/dist/src/artifacts/types.js +1 -1
- package/dist/src/cli/handlers/script-runner.js +7 -4
- package/dist/src/cli/handlers/steward-format.js +12 -0
- package/dist/src/cli/handlers/use.js +13 -4
- package/dist/src/cli/handlers/utility-doctor.js +4 -0
- package/dist/src/extensions/manifest.js +6 -0
- package/dist/src/extensions/project-local-discovery.js +21 -1
- package/dist/src/extensions/project-local-scaffold.js +19 -7
- package/dist/src/models/factory-models.js +144 -0
- package/dist/src/models/model-capabilities.v1.json +35 -27
- package/dist/src/models/model-discovery.js +7 -3
- package/dist/src/models/worker-installation.d.mts +2 -0
- package/dist/src/models/worker-installation.mjs +11 -2
- package/dist/src/models/worker-invocation-policy.js +25 -1
- package/dist/src/models/wrapper-enforcement.js +1 -1
- package/dist/src/policy/repo-access.js +3 -1
- package/dist/src/providers/capability-matrix.yaml +75 -5
- package/dist/src/providers/deployment-ownership.mjs +8 -1
- package/dist/src/providers/deployment-preservation.mjs +44 -3
- package/dist/src/providers/grok-build-acp.js +13 -5
- package/dist/src/providers/grok-build-dispatch.js +35 -2
- package/dist/src/providers/grok-build-headless.js +2 -1
- package/dist/src/serve/worker-stdin-frame.mjs +1 -1
- package/dist/src/sessions/adapters/grok-build-native-records.js +77 -7
- package/dist/src/sessions/adapters/grok-build-native.js +148 -1
- package/dist/src/sessions/adapters/grok-build.js +36 -14
- package/dist/src/sessions/normalization.js +1 -1
- package/dist/src/smiths/context-pipeline/workspace-doctor.js +4 -0
- package/dist/src/smiths/hook-bridge/factory-trust.js +2 -2
- package/dist/src/smiths/hook-bridge/hermes-prompt-discovery.js +10 -7
- package/dist/src/smiths/hook-bridge/hermes-trust.js +65 -0
- package/package.json +1 -1
- package/tools/agents/deploy-agents.mjs +4 -2
- package/tools/agents/deploy-options.mjs +2 -0
- package/tools/agents/providers/base-inventory.mjs +3 -1
- package/tools/agents/providers/base-kernel-skills.mjs +11 -5
- package/tools/agents/providers/grok-build.mjs +31 -40
- package/tools/agents/providers/model-wrapper.mjs +2 -5
- package/tools/agents/providers/rule-deployment-commit.mjs +3 -0
- package/tools/agents/providers/rule-deployment-prepare.mjs +2 -2
- package/tools/agents/providers/rule-projection.mjs +39 -4
- package/tools/agents/providers/skill-copy-prune.mjs +12 -0
- package/tools/agents/providers/stale-artifact-prune.mjs +24 -10
- package/tools/ralph-external/lib/claude-adapter.mjs +2 -0
- package/tools/ralph-external/lib/factory-adapter.mjs +6 -2
- package/tools/ralph-external/lib/worker-inputs.mjs +20 -1
- package/tools/ralph-external/lib/worker-isolation.mjs +1 -0
- package/tools/ralph-external/lib/worker-termination.mjs +21 -12
- package/tools/ralph-external/session-launcher.mjs +22 -17
|
@@ -93,6 +93,14 @@ providers:
|
|
|
93
93
|
|
|
94
94
|
codex:
|
|
95
95
|
display_name: OpenAI Codex
|
|
96
|
+
byok:
|
|
97
|
+
status: documented
|
|
98
|
+
settings:
|
|
99
|
+
- 'Harness config.toml: model_provider and model select a model_providers entry with base_url, env_key and wire_api = "responses".'
|
|
100
|
+
- 'env_key names an environment variable; inject its value from the environment or a secret-store command only.'
|
|
101
|
+
verification: 'After approval, send "Reply with exactly: byok-ok" and check the Codex session log for the resolved model and provider.'
|
|
102
|
+
notes: 'Custom providers require the Responses API; OpenRouter compatibility with the requested model is unverified. Do not copy a Chat Completions configuration.'
|
|
103
|
+
docs: docs/agents/providers/codex.md#wire-protocol
|
|
96
104
|
route_feasibility:
|
|
97
105
|
scope: in
|
|
98
106
|
identity: runtime-configured-only
|
|
@@ -176,6 +184,16 @@ providers:
|
|
|
176
184
|
|
|
177
185
|
copilot:
|
|
178
186
|
display_name: GitHub Copilot
|
|
187
|
+
byok:
|
|
188
|
+
status: verified
|
|
189
|
+
settings:
|
|
190
|
+
- 'COPILOT_PROVIDER_BASE_URL=https://openrouter.ai/api/v1'
|
|
191
|
+
- 'COPILOT_PROVIDER_TYPE=openai'
|
|
192
|
+
- 'COPILOT_MODEL=qwen/qwen3.8-27b'
|
|
193
|
+
- 'Key: COPILOT_PROVIDER_API_KEY environment variable or COPILOT_PROVIDER_API_KEY_COMMAND secret-store command.'
|
|
194
|
+
verification: 'After approval, send "Reply with exactly: byok-ok" and check the Copilot harness log/session for the resolved model qwen/qwen3.8-27b.'
|
|
195
|
+
notes: 'Operator live run, 2026-11-09 (#4054); harness BYOK settings do not qualify the AIWG direct-worker parser or its cleared-environment profile.'
|
|
196
|
+
docs: docs/providers/copilot-direct.md#bring-your-own-key
|
|
179
197
|
aliases:
|
|
180
198
|
- github-copilot
|
|
181
199
|
route_feasibility:
|
|
@@ -226,6 +244,14 @@ providers:
|
|
|
226
244
|
|
|
227
245
|
factory:
|
|
228
246
|
display_name: Factory AI
|
|
247
|
+
byok:
|
|
248
|
+
status: verified
|
|
249
|
+
settings:
|
|
250
|
+
- 'Harness-owned BYOK custom models: select the exact registered custom: model ID with droid exec -m <custom-model-id>.'
|
|
251
|
+
- 'Use only harness-supported environment or secret-store command injection at point of use; if the installed harness requires a plaintext apiKey in settings.json, stop and choose a secure route with the operator.'
|
|
252
|
+
verification: 'After approval, send "Reply with exactly: byok-ok" on stdin and inspect the Droid session for the resolved model and reasoning_effort none.'
|
|
253
|
+
notes: 'Operator live run, 2026-11-09 (#4054): -r reasoning effort is ignored for custom models. Copy the custom: selector from the harness model listing, not the upstream API ID or display name. #3969: heavy/medium/light aliases are rejected; use full built-in IDs for built-in models.'
|
|
254
|
+
docs: docs/providers/factory-direct.md#bring-your-own-key
|
|
229
255
|
aliases:
|
|
230
256
|
- factory-ai
|
|
231
257
|
route_feasibility:
|
|
@@ -327,6 +353,14 @@ providers:
|
|
|
327
353
|
|
|
328
354
|
opencode:
|
|
329
355
|
display_name: OpenCode
|
|
356
|
+
byok:
|
|
357
|
+
status: verified
|
|
358
|
+
settings:
|
|
359
|
+
- 'Key: OPENROUTER_API_KEY environment variable; OpenRouter provider is harness-owned.'
|
|
360
|
+
- 'Model: opencode run -m openrouter/qwen/qwen3.8-27b (provider-prefixed model selector).'
|
|
361
|
+
verification: 'After approval, send "Reply with exactly: byok-ok" and inspect the OpenCode log/session for the resolved model qwen/qwen3.8-27b under openrouter.'
|
|
362
|
+
notes: 'Operator live run, 2026-11-09 (#4054); this guidance does not change AIWG worker environment allowlists or qualify direct dispatch.'
|
|
363
|
+
docs: docs/providers/opencode-direct.md#bring-your-own-key
|
|
330
364
|
route_feasibility:
|
|
331
365
|
scope: in
|
|
332
366
|
identity: runtime-configured-only
|
|
@@ -549,7 +583,7 @@ providers:
|
|
|
549
583
|
scope: in
|
|
550
584
|
identity: runtime-configured-only
|
|
551
585
|
evidence: R
|
|
552
|
-
channel: "grok -p --output-format streaming-json; 1.0.77
|
|
586
|
+
channel: "grok -p --output-format streaming-json; 1.0.77 captures: headless/ACP parser contracts, workflow fan-out bypass; combined deny flags rendered (live enforcement and model/effort pins unverified)"
|
|
553
587
|
fanout: unknown
|
|
554
588
|
probe_budget: { status: authorized, calls: 3, tokens: 30000, authorized_by: operator, authorized_at: "2026-10-07", hosts: [titan, noodle] }
|
|
555
589
|
coverage:
|
|
@@ -558,17 +592,38 @@ providers:
|
|
|
558
592
|
live_qualified: false
|
|
559
593
|
sources:
|
|
560
594
|
- "src/providers/grok-build-headless.ts"
|
|
595
|
+
- "test/unit/providers/grok-build-headless.test.ts"
|
|
596
|
+
- "test/unit/providers/grok-build-acp.test.ts"
|
|
597
|
+
- "test/unit/providers/grok-build-dispatch.test.ts"
|
|
598
|
+
- "test/conformance/orchestration-v1/grok-build-direct.test.ts"
|
|
561
599
|
status: experimental
|
|
562
600
|
# xAI Grok Build CLI/TUI. Distinct from Grok Bot (`grokbot`).
|
|
563
601
|
# #2577: every claim and its limits are recorded in
|
|
564
602
|
# docs/providers/grok-build-native-agents.md (1.0.77 evidence table).
|
|
565
603
|
# Captured headless shapes: test/unit/providers/grok-build-headless.test.ts.
|
|
566
|
-
#
|
|
567
|
-
#
|
|
604
|
+
# 2026-11-10 1.0.77: captured-20261110 fixtures replayed by the tests above.
|
|
605
|
+
# Default headless cancels spawn_subagent/workflow: "a headless run cannot ask
|
|
606
|
+
# for approval". --allow spawn_subagent did not cover them; permission-mode auto
|
|
607
|
+
# ran them. AIWG permission defaults stay unchanged (no automatic approval).
|
|
608
|
+
# --no-subagents alone still permits workflow-spawned children. All AIWG leaf
|
|
609
|
+
# argv builders also deny workflow with --disallowed-tools workflow; combined
|
|
610
|
+
# live flag enforcement is unverified, so route_feasibility.fanout stays unknown.
|
|
611
|
+
# Native -w is a standalone copy under ~/.grok/worktrees/<slug>/<name>, NOT a
|
|
612
|
+
# git worktree; list --json ownership/recovery metadata parsing is fixture-backed
|
|
613
|
+
# in grok-build-dispatch.test.ts. AIWG isolation still uses its own detached Git
|
|
614
|
+
# worktree and never edits the user's working files (synthetic dispatch test).
|
|
615
|
+
# ACP authMethods, logged-in session/new amid _x.ai/* notifications, end_turn
|
|
616
|
+
# _meta usage, compact/summary notifications and cancelled/MidTurnAbort are
|
|
617
|
+
# fixture-backed in grok-build-acp.test.ts; live ACP dispatch remains deferred.
|
|
618
|
+
# 2026-11-10 set-b: project .grok/agents/*.md discovery and ignored model pins
|
|
619
|
+
# replayed by grok-build-provider.test.ts with captured-20261110/native-agents.json.
|
|
620
|
+
# Only name/description frontmatter is emitted; role/tier intent lives in the
|
|
621
|
+
# body, not model pins. User-scope mirroring is offline-tested in grok-build-use.test.ts.
|
|
622
|
+
# Resident lifecycle remains unverified.
|
|
568
623
|
daemon_tier: unsupported
|
|
569
624
|
daemon_pty_adapter: false
|
|
570
625
|
artifact_paths:
|
|
571
|
-
agents: .grok/agents/ #
|
|
626
|
+
agents: .grok/agents/ # captured project discovery; grok-build-provider.test.ts
|
|
572
627
|
commands: null
|
|
573
628
|
skills: .grok/skills/
|
|
574
629
|
skills_cross_agent: .grok/.aiwg/skills/ # --copy-all opt-in mirror
|
|
@@ -581,7 +636,7 @@ providers:
|
|
|
581
636
|
mcp: true # fixture-backed config only: grok-build-native-integration.test.ts; live MCP unverified
|
|
582
637
|
behaviors: false # unverified: needs behavior registration/execution capture
|
|
583
638
|
mission_control: false # unverified: needs mission lifecycle capture
|
|
584
|
-
daemon: false #
|
|
639
|
+
daemon: false # deferred: ACP frame replay is not resident lifecycle qualification (grok-build-acp.test.ts)
|
|
585
640
|
emulation:
|
|
586
641
|
cron: null
|
|
587
642
|
agent_teams: aiwg-mc
|
|
@@ -600,6 +655,14 @@ providers:
|
|
|
600
655
|
|
|
601
656
|
hermes:
|
|
602
657
|
display_name: Hermes
|
|
658
|
+
byok:
|
|
659
|
+
status: verified
|
|
660
|
+
settings:
|
|
661
|
+
- 'Key: OPENROUTER_API_KEY environment variable.'
|
|
662
|
+
- 'Provider/model: hermes chat --provider openrouter -m qwen/qwen3.8-27b; never rely on auto provider selection.'
|
|
663
|
+
verification: 'After approval, send "Reply with exactly: byok-ok" and inspect the Hermes log/session for the resolved model qwen/qwen3.8-27b under openrouter.'
|
|
664
|
+
notes: 'Operator live run, 2026-11-09 (#4054); manual CLI guidance does not change the AIWG direct-worker cleared environment or its dispatch status.'
|
|
665
|
+
docs: docs/providers/hermes-direct.md#bring-your-own-key
|
|
603
666
|
route_feasibility:
|
|
604
667
|
scope: in
|
|
605
668
|
identity: runtime-configured-only
|
|
@@ -654,6 +717,13 @@ providers:
|
|
|
654
717
|
|
|
655
718
|
muse:
|
|
656
719
|
display_name: Muse Code
|
|
720
|
+
byok:
|
|
721
|
+
status: unverified
|
|
722
|
+
settings:
|
|
723
|
+
- 'Muse --provider / --model and harness settings select catalog models; an OpenRouter key setting is unverified. Do not invent an environment variable or endpoint flag.'
|
|
724
|
+
verification: 'First confirm upstream BYOK support without a paid call; after explicit approval of a supported route, send "Reply with exactly: byok-ok" and check the Muse session log for the resolved model.'
|
|
725
|
+
notes: 'Existing Muse notes cover the Meta model catalog only. Offer a verified Hermes, OpenCode or Copilot route when OpenRouter is required.'
|
|
726
|
+
docs: docs/agents/providers/muse.md
|
|
657
727
|
route_feasibility:
|
|
658
728
|
scope: in
|
|
659
729
|
identity: runtime-configured-only
|
|
@@ -17,7 +17,14 @@ const bundleOwner = source => extractFrameworkSlug(source) || source.replaceAll(
|
|
|
17
17
|
export const deploymentOwner = opts => {
|
|
18
18
|
const names = { sdlc: 'sdlc-complete', marketing: 'media-marketing-kit', mmk: 'media-marketing-kit',
|
|
19
19
|
research: 'research-complete', forensics: 'forensics-complete', dfir: 'forensics-complete', validation: 'validation-complete', ops: 'ops-complete', general: 'writing-quality' };
|
|
20
|
-
|
|
20
|
+
const source = opts.logicalInputPath?.(opts.srcRoot) || opts.srcRoot;
|
|
21
|
+
let scopedOwner;
|
|
22
|
+
if (opts.bundleOnly && opts.srcRoot) {
|
|
23
|
+
const file = path.join(opts.srcRoot, 'manifest.json');
|
|
24
|
+
const manifest = parse(fs.existsSync(file) ? fs.readFileSync(file) : null);
|
|
25
|
+
scopedOwner = typeof manifest.id === 'string' && manifest.id ? manifest.id : path.resolve(source);
|
|
26
|
+
}
|
|
27
|
+
return opts.frameworkSlug || bundleOwner(`${source}/manifest.json`) || scopedOwner || names[opts.mode] || opts.mode;
|
|
21
28
|
};
|
|
22
29
|
|
|
23
30
|
/** Only provider output surfaces, never arbitrary project source directories. */
|
|
@@ -3,6 +3,7 @@ import fs from 'node:fs';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { createHash } from 'node:crypto';
|
|
5
5
|
import { frameworkRegistryId } from '../config/framework-aliases.js';
|
|
6
|
+
import { deploymentOwner } from './deployment-ownership.mjs';
|
|
6
7
|
const hash = bytes => `sha256:${createHash('sha256').update(bytes).digest('hex')}`;
|
|
7
8
|
const parse = bytes => { try { return JSON.parse(bytes?.toString() || '{}'); } catch { return {}; } };
|
|
8
9
|
const sidecar = '.aiwg-manifest.json';
|
|
@@ -48,10 +49,27 @@ export function preserveDeploymentOutputs(before, roots, opts = {}) {
|
|
|
48
49
|
const base = receipt.scope === 'project' && file === path.join(opts.target, '.aiwg', sidecar) ? opts.target : path.dirname(file);
|
|
49
50
|
for (const [name, record] of Object.entries(receipt.managed || {})) {
|
|
50
51
|
const target = path.resolve(base, name);
|
|
51
|
-
if (target.startsWith(`${base}${path.sep}`)) claims.set(target, { record, file, name });
|
|
52
|
+
if (target.startsWith(`${base}${path.sep}`)) claims.set(target, { record, file, name, target });
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
const restored = [];
|
|
56
|
+
const owner = deploymentOwner(opts);
|
|
57
|
+
const sharedIndex = file => /^RULES-(?:INDEX|ONDEMAND|BOUND)\.(?:md|mdc)$/.test(path.basename(file))
|
|
58
|
+
|| context.has(path.basename(file)) || path.basename(file) === '.windsurfrules'
|
|
59
|
+
// Flue's app modules describe every selected bundle, even in a scoped pass.
|
|
60
|
+
|| opts.provider === 'flue' && ['skills.ts', 'specialists.ts', 'tools.ts', 'remote-specialist.js', 'remote-specialist.d.ts']
|
|
61
|
+
.some(name => file === path.join(opts.target, 'src/aiwg', name));
|
|
62
|
+
const foreign = (file, record) => {
|
|
63
|
+
if (opts.force) {
|
|
64
|
+
const claim = claims.get(file);
|
|
65
|
+
const current = claim && parse(fs.existsSync(claim.file) ? fs.readFileSync(claim.file) : null);
|
|
66
|
+
const source = current?.skillSource || current?.managed?.[claim?.name]?.sourcePath;
|
|
67
|
+
const logical = opts.logicalInputPath || (file => file);
|
|
68
|
+
if (source && logical(source).startsWith(`${logical(opts.srcRoot)}${path.sep}`)) return false;
|
|
69
|
+
}
|
|
70
|
+
const owners = record?.owners || (record?.frameworkSlug ? [record.frameworkSlug] : []);
|
|
71
|
+
return opts.bundleOnly && !sharedIndex(file) && (owners.length !== 1 || owners[0] !== owner);
|
|
72
|
+
};
|
|
55
73
|
for (const [file, bytes] of before) {
|
|
56
74
|
if (path.basename(file) === sidecar) continue;
|
|
57
75
|
// Snapshots keep bytes for receipt-claimed and receipt-adjacent files only;
|
|
@@ -60,18 +78,41 @@ export function preserveDeploymentOutputs(before, roots, opts = {}) {
|
|
|
60
78
|
const exists = fs.existsSync(file);
|
|
61
79
|
if (!exists && opts.replacedSkillCopies?.has(file)) continue;
|
|
62
80
|
const claim = claims.get(file);
|
|
63
|
-
|
|
81
|
+
// A named bundle's transaction cannot rewrite or retire another owner's
|
|
82
|
+
// payload, including older marker-only kernel rules and shared settings.
|
|
83
|
+
const outOfScope = foreign(file, claim?.record);
|
|
84
|
+
const edited = claim && (claim.record.hash ? claim.record.hash !== hash(bytes) : opts.bundleOnly)
|
|
85
|
+
&& !context.has(path.basename(file)) && claim.record.kind !== 'settings';
|
|
64
86
|
const owners = claim?.record.owners || (claim?.record.frameworkSlug ? [claim.record.frameworkSlug] : []);
|
|
65
87
|
const currentOwner = (opts.srcRoot || '').replaceAll('\\', '/').match(/(?:agentic\/code|\.aiwg)\/(?:frameworks|addons|extensions)\/([^/]+)/)?.[1] || frameworkRegistryId(opts.mode || '');
|
|
66
88
|
const copy = (opts.copyMode ?? opts.copyStandardSkills) || owners.some(owner => providerCopyMode(opts.target, opts.provider, owner, opts.config, currentOwner));
|
|
67
|
-
|
|
89
|
+
const retire = opts.copyMode === false && opts.retiredRuleFiles?.has(file);
|
|
90
|
+
if (!(outOfScope || edited || !exists && copy && !retire) || exists && fs.readFileSync(file).equals(bytes)) continue;
|
|
68
91
|
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
69
92
|
fs.writeFileSync(file, bytes);
|
|
70
93
|
if (edited) console.warn(`${opts.logicalOutputPath?.(file) || file}: kept (operator-edited)`);
|
|
71
94
|
restored.push(claim);
|
|
72
95
|
}
|
|
96
|
+
if (opts.bundleOnly) {
|
|
97
|
+
opts.writtenFiles = opts.writtenFiles?.filter(file => !before.has(file) || !foreign(file, claims.get(file)?.record));
|
|
98
|
+
// Keep foreign ownership records verbatim. A rewritten sidecar must never
|
|
99
|
+
// turn an unchanged kernel payload into an output of the selected addon.
|
|
100
|
+
for (const [file, previous] of receipts) {
|
|
101
|
+
if (opts.replacedSkillCopies?.has(file) && !fs.existsSync(file)) continue;
|
|
102
|
+
const current = parse(fs.existsSync(file) ? fs.readFileSync(file) : null);
|
|
103
|
+
current.managed ||= {};
|
|
104
|
+
const base = previous.scope === 'project' && file === path.join(opts.target, '.aiwg', sidecar) ? opts.target : path.dirname(file);
|
|
105
|
+
for (const [name, record] of Object.entries(previous.managed || {})) {
|
|
106
|
+
if (foreign(path.resolve(base, name), record)) current.managed[name] = record;
|
|
107
|
+
}
|
|
108
|
+
const exclusivelyForeign = [previous.managed || {}, current.managed].every(managed =>
|
|
109
|
+
Object.entries(managed).every(([name, record]) => foreign(path.resolve(base, name), record)));
|
|
110
|
+
writeReceipt(file, exclusivelyForeign ? before.get(file) : `${JSON.stringify(current, null, 2)}\n`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
73
113
|
// Keep the old digest for protected payloads: a later run must still detect edits.
|
|
74
114
|
for (const claim of restored.filter(Boolean)) {
|
|
115
|
+
if (foreign(claim.target, claim.record)) continue;
|
|
75
116
|
const { managed: _managed, ...metadata } = receipts.get(claim.file) || {};
|
|
76
117
|
const receipt = { ...metadata, ...parse(fs.existsSync(claim.file) ? fs.readFileSync(claim.file) : null) };
|
|
77
118
|
receipt.managed ??= {};
|
|
@@ -23,7 +23,7 @@ export class GrokAcpClient {
|
|
|
23
23
|
this.timeoutMs = Math.min(Math.max(options.timeoutMs ?? 30_000, 1), 120_000);
|
|
24
24
|
this.maxStderrBytes = options.maxStderrBytes ?? 1024 * 1024;
|
|
25
25
|
this.onUpdate = options.onUpdate;
|
|
26
|
-
this.child = spawn(options.command ?? 'grok', [...(options.prefixArgs ?? []), '--no-auto-update', ...(options.disableSubagents ? ['--no-subagents'] : []), 'agent', 'stdio'], {
|
|
26
|
+
this.child = spawn(options.command ?? 'grok', [...(options.prefixArgs ?? []), '--no-auto-update', '--allow', 'Bash(aiwg discover *)', ...(options.disableSubagents ? ['--no-subagents', '--disallowed-tools', 'workflow'] : []), 'agent', 'stdio'], {
|
|
27
27
|
cwd: options.cwd, env: this.env, stdio: ['pipe', 'pipe', 'pipe'], shell: false,
|
|
28
28
|
});
|
|
29
29
|
this.child.on('error', error => this.failAll(new Error(`Grok ACP launch failed: ${error.message}`)));
|
|
@@ -71,7 +71,7 @@ export class GrokAcpClient {
|
|
|
71
71
|
this.close();
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
if (message.method === 'session/update') {
|
|
74
|
+
if (message.method === 'session/update' || message.method === '_x.ai/session_notification') {
|
|
75
75
|
const params = message.params;
|
|
76
76
|
const update = params?.update;
|
|
77
77
|
if (update) {
|
|
@@ -121,7 +121,7 @@ export class GrokAcpClient {
|
|
|
121
121
|
async initialize() {
|
|
122
122
|
const init = await this.request('initialize', {
|
|
123
123
|
protocolVersion: 1,
|
|
124
|
-
clientCapabilities: { fs: { readTextFile:
|
|
124
|
+
clientCapabilities: { fs: { readTextFile: false, writeTextFile: false }, terminal: false },
|
|
125
125
|
});
|
|
126
126
|
const methods = Array.isArray(init.authMethods)
|
|
127
127
|
? init.authMethods.map(item => item.id) : [];
|
|
@@ -133,7 +133,12 @@ export class GrokAcpClient {
|
|
|
133
133
|
: 'no supported non-interactive method was offered';
|
|
134
134
|
throw new Error(`Grok ACP authentication unavailable: ${reason}`);
|
|
135
135
|
}
|
|
136
|
-
|
|
136
|
+
// Captured 1.0.77 advertises the active cached login in initialize; it
|
|
137
|
+
// proceeds straight to session/new without an authenticate round trip.
|
|
138
|
+
const meta = init._meta;
|
|
139
|
+
if (authMethod !== 'cached_token' || meta?.defaultAuthMethodId !== 'cached_token') {
|
|
140
|
+
await this.request('authenticate', { methodId: authMethod, _meta: { headless: true } });
|
|
141
|
+
}
|
|
137
142
|
const session = await this.request('session/new', { cwd: this.cwd, mcpServers: [] });
|
|
138
143
|
if (typeof session.sessionId !== 'string' || !session.sessionId)
|
|
139
144
|
throw new Error('Grok ACP session/new returned no sessionId');
|
|
@@ -161,7 +166,10 @@ export class GrokAcpClient {
|
|
|
161
166
|
await new Promise(resolve => setTimeout(resolve, 150));
|
|
162
167
|
if (abortRequested || signal?.aborted)
|
|
163
168
|
throw aborted();
|
|
164
|
-
|
|
169
|
+
const meta = result._meta && typeof result._meta === 'object' && !Array.isArray(result._meta)
|
|
170
|
+
? JSON.parse(redactGrokOutput(JSON.stringify(result._meta), this.env)) : undefined;
|
|
171
|
+
return { text: this.text.trim(), ...(typeof result.stopReason === 'string' ? { stopReason: result.stopReason } : {}),
|
|
172
|
+
...(meta ? { _meta: meta } : {}) };
|
|
165
173
|
}
|
|
166
174
|
catch (error) {
|
|
167
175
|
if (abortRequested || signal?.aborted)
|
|
@@ -3,7 +3,7 @@ import { execFile } from 'node:child_process';
|
|
|
3
3
|
import { promisify } from 'node:util';
|
|
4
4
|
import { lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, unlink, writeFile } from 'node:fs/promises';
|
|
5
5
|
import { tmpdir } from 'node:os';
|
|
6
|
-
import { join, resolve } from 'node:path';
|
|
6
|
+
import { isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
7
7
|
import { createHash, randomUUID } from 'node:crypto';
|
|
8
8
|
import { readAiwgConfig, resolveParallelism } from '../config/aiwg-config.js';
|
|
9
9
|
import { runGrokHeadless } from './grok-build-headless.js';
|
|
@@ -122,6 +122,39 @@ export async function acquireGrokProjectSlot(key, limit) {
|
|
|
122
122
|
}
|
|
123
123
|
throw new Error(`Grok Build project parallelism cap ${limit} reached`);
|
|
124
124
|
}
|
|
125
|
+
/** Parse captured list metadata only; never create, remove or enter a native copy. */
|
|
126
|
+
export function parseGrokNativeWorktreeList(json) {
|
|
127
|
+
const invalid = () => { throw new Error('Invalid Grok Build worktree list: expected standalone copy ownership metadata'); };
|
|
128
|
+
let rows;
|
|
129
|
+
try {
|
|
130
|
+
rows = JSON.parse(json);
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
return invalid();
|
|
134
|
+
}
|
|
135
|
+
if (!Array.isArray(rows))
|
|
136
|
+
return invalid();
|
|
137
|
+
return rows.map(value => {
|
|
138
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
139
|
+
return invalid();
|
|
140
|
+
const row = value;
|
|
141
|
+
for (const key of ['id', 'path', 'source_repo', 'repo_name', 'kind', 'git_ref', 'head_commit', 'session_id', 'status']) {
|
|
142
|
+
if (typeof row[key] !== 'string' || !row[key] || row[key].includes('\0'))
|
|
143
|
+
return invalid();
|
|
144
|
+
}
|
|
145
|
+
const path = row.path;
|
|
146
|
+
const source = row.source_repo;
|
|
147
|
+
const offset = relative(source, path);
|
|
148
|
+
if (row.creation_mode !== 'standalone' || !isAbsolute(path) || !isAbsolute(source)
|
|
149
|
+
|| !offset || (!isAbsolute(offset) && offset !== '..' && !offset.startsWith(`..${sep}`))
|
|
150
|
+
|| !/^[0-9a-f]{40}$/i.test(row.head_commit)
|
|
151
|
+
|| !Number.isSafeInteger(row.creator_pid) || row.creator_pid < 1
|
|
152
|
+
|| !['created_at', 'last_accessed_at'].every(key => typeof row[key] === 'number' && Number.isFinite(row[key]) && row[key] >= 0)
|
|
153
|
+
|| (row.metadata !== undefined && (!row.metadata || typeof row.metadata !== 'object' || Array.isArray(row.metadata))))
|
|
154
|
+
return invalid();
|
|
155
|
+
return row;
|
|
156
|
+
});
|
|
157
|
+
}
|
|
125
158
|
async function gitOut(cwd, ...args) {
|
|
126
159
|
const result = await git('git', args, { cwd, timeout: 15_000, maxBuffer: 1024 * 1024 });
|
|
127
160
|
return result.stdout.trim();
|
|
@@ -234,7 +267,7 @@ export class GrokBuildDispatcher {
|
|
|
234
267
|
this.active += 1;
|
|
235
268
|
try {
|
|
236
269
|
const worktree = options.isolate ? await prepareGrokWorktree(options.projectRoot) : undefined;
|
|
237
|
-
// Grok's internal autonomous subagent fan-out has no documented hard
|
|
270
|
+
// Grok's internal autonomous subagent/workflow fan-out has no documented hard
|
|
238
271
|
// project cap. Disable it in AIWG-controlled headless workers so every
|
|
239
272
|
// parallel worker consumes one dispatcher slot. Interactive Grok use
|
|
240
273
|
// remains outside this bounded API and must not be claimed as enforced.
|
|
@@ -76,7 +76,8 @@ export async function runGrokHeadless(options) {
|
|
|
76
76
|
const timeoutMs = Math.min(options.timeoutMs ?? DEFAULT_TIMEOUT_MS, MAX_TIMEOUT_MS);
|
|
77
77
|
const maxBytes = Math.min(Math.max(options.maxOutputBytes ?? DEFAULT_MAX_OUTPUT, 1024), DEFAULT_MAX_OUTPUT);
|
|
78
78
|
const env = options.env ?? process.env;
|
|
79
|
-
|
|
79
|
+
// 1.0.77: workflow can spawn children even when spawn_subagent is disabled.
|
|
80
|
+
const args = [...(options.prefixArgs ?? []), '--no-auto-update', '--allow', 'Bash(aiwg discover *)', ...(options.disableSubagents ? ['--no-subagents', '--disallowed-tools', 'workflow'] : []), '-p', options.prompt, '--output-format', format];
|
|
80
81
|
const streaming = format === 'streaming-json' || format === 'streaming-messages-json';
|
|
81
82
|
return new Promise((resolve, reject) => {
|
|
82
83
|
const child = spawn(options.command ?? 'grok', args, {
|
|
@@ -73,7 +73,7 @@ export async function recordedWorkerStdinBytes({ filename, workspace, cli, adapt
|
|
|
73
73
|
const { loadRecordedWorkerInstallations } = await import('../models/worker-installation.mjs');
|
|
74
74
|
const { loadProviderModelCapabilities } = await import('../models/provider-policy.js');
|
|
75
75
|
const { drivers } = await loadRecordedWorkerInstallations({ registry: loadProviderModelCapabilities(),
|
|
76
|
-
cwd: workspace, policy, storePath, storeDigest });
|
|
76
|
+
cwd: workspace, policy, cli, storePath, storeDigest });
|
|
77
77
|
const driver = drivers[cli];
|
|
78
78
|
if (!driver || driver.qualification.adapterId !== adapterId
|
|
79
79
|
|| driver.qualification.adapter.invocation.stdin !== 'adapter-frame'
|
|
@@ -4,7 +4,7 @@ import { SessionContractError } from '../contracts.js';
|
|
|
4
4
|
const text = z.strictObject({ type: z.literal('text'), text: z.string() });
|
|
5
5
|
const tool = z.strictObject({ id: z.string().min(1), name: z.string().min(1), arguments: z.string() });
|
|
6
6
|
const recordSchema = z.discriminatedUnion('type', [
|
|
7
|
-
z.strictObject({ type: z.literal('user'), content: z.array(text), prompt_index: z.number().int().nonnegative().optional(), synthetic_reason: z.
|
|
7
|
+
z.strictObject({ type: z.literal('user'), content: z.array(text), prompt_index: z.number().int().nonnegative().optional(), synthetic_reason: z.enum(['system_reminder', 'compaction_meta']).optional() }),
|
|
8
8
|
z.strictObject({ type: z.literal('assistant'), content: z.string(), tool_calls: z.array(tool).max(999).optional(), model_id: z.string().optional(), model_fingerprint: z.string().optional(), reasoning_effort: z.string().optional() }),
|
|
9
9
|
z.strictObject({ type: z.literal('tool_result'), tool_call_id: z.string(), content: z.string() }),
|
|
10
10
|
z.strictObject({ type: z.literal('system'), content: z.string() }),
|
|
@@ -14,6 +14,8 @@ const summarySchema = z.looseObject({
|
|
|
14
14
|
chat_format_version: z.literal(1),
|
|
15
15
|
info: z.strictObject({ id: z.string().uuid(), cwd: z.string().min(1) }),
|
|
16
16
|
created_at: z.string(), updated_at: z.string(), current_model_id: z.string(),
|
|
17
|
+
session_kind: z.enum(['headless', 'interactive', 'subagent']).nullish(),
|
|
18
|
+
parent_session_id: z.string().uuid().optional(), forked_at: z.string().optional(),
|
|
17
19
|
});
|
|
18
20
|
export function nativeDrift() {
|
|
19
21
|
throw new SessionContractError('SCHEMA_DRIFT', 'Unrecognized Grok Build 1.0.77 native schema; fall back to `grok export <session-id> <session-id>.md`.');
|
|
@@ -25,7 +27,13 @@ export function parseNativeSummary(value, sessionId, cwd) {
|
|
|
25
27
|
for (const time of [parsed.data.created_at, parsed.data.updated_at])
|
|
26
28
|
if (!Number.isFinite(Date.parse(time)))
|
|
27
29
|
nativeDrift();
|
|
28
|
-
|
|
30
|
+
const data = parsed.data;
|
|
31
|
+
if (data.forked_at !== undefined && (!data.parent_session_id || !Number.isFinite(Date.parse(data.forked_at))))
|
|
32
|
+
nativeDrift();
|
|
33
|
+
if (data.parent_session_id?.toLowerCase() === sessionId)
|
|
34
|
+
nativeDrift();
|
|
35
|
+
const lineage = data.parent_session_id ? { parentSessionId: data.parent_session_id.toLowerCase(), ...(data.forked_at ? { forkedAt: data.forked_at } : {}) } : undefined;
|
|
36
|
+
return { sessionCreatedAt: data.created_at, sessionUpdatedAt: data.updated_at, currentModelId: data.current_model_id, ...(data.session_kind ? { sessionKind: data.session_kind } : {}), ...(lineage ? { lineage } : {}) };
|
|
29
37
|
}
|
|
30
38
|
export function projectNativeLine(line, cwd, metadata) {
|
|
31
39
|
const parsed = recordSchema.safeParse(line.value);
|
|
@@ -49,16 +57,78 @@ export function projectNativeLine(line, cwd, metadata) {
|
|
|
49
57
|
export function nativeProjectionRecord(sessionId, entry) {
|
|
50
58
|
const { record, line } = entry;
|
|
51
59
|
return {
|
|
52
|
-
nativeSessionId: sessionId, nativeEventId: `${sessionId}:${record.sequence}`, sequence: record.sequence,
|
|
53
|
-
kind: record.kind, role: record.role, occurredAt:
|
|
60
|
+
nativeSessionId: sessionId, nativeEventId: `${sessionId}:${record.acquisition === 'grok-build-native-updates' ? 'updates:' : ''}${record.sequence}`, sequence: record.sequence,
|
|
61
|
+
kind: record.kind, role: record.role, occurredAt: record.occurredAt, text: record.content, model: record.model,
|
|
54
62
|
toolName: record.toolName, toolCallId: record.toolCallId,
|
|
55
|
-
rawReference: { locatorClass: 'grok-build-native-chat-history', sequence: line.sequence },
|
|
63
|
+
rawReference: { locatorClass: record.acquisition ?? 'grok-build-native-chat-history', sequence: line.sequence },
|
|
56
64
|
extensions: {
|
|
57
65
|
lifecycle: 'unknown-at-import',
|
|
58
|
-
provenance: { product: 'grok-build', acquisition: 'grok-build-native-chat-history', sourceSchema: '1.0.0', nativeStoreInspected: true, toolOutputAvailable: true, grokVersion: '1.0.77', workingDirectory: record.cwd, sessionCreatedAt: record.sessionCreatedAt, sessionUpdatedAt: record.sessionUpdatedAt, sessionCreatedAtMs: Date.parse(record.sessionCreatedAt), sessionUpdatedAtMs: Date.parse(record.sessionUpdatedAt), currentModelId: record.currentModelId },
|
|
66
|
+
provenance: { product: 'grok-build', acquisition: record.acquisition ?? 'grok-build-native-chat-history', sourceSchema: '1.0.0', nativeStoreInspected: true, toolOutputAvailable: true, grokVersion: '1.0.77', workingDirectory: record.cwd, sessionCreatedAt: record.sessionCreatedAt, sessionUpdatedAt: record.sessionUpdatedAt, sessionCreatedAtMs: Date.parse(record.sessionCreatedAt), sessionUpdatedAtMs: Date.parse(record.sessionUpdatedAt), currentModelId: record.currentModelId, ...(record.sessionKind ? { sessionKind: record.sessionKind } : {}) },
|
|
67
|
+
...(record.lineage ? { lineage: record.lineage } : {}),
|
|
68
|
+
...(record.compaction ? { compaction: record.compaction } : {}),
|
|
59
69
|
identity: { nativeSessionIdKnown: true, nativeEventIdKnown: false, eventIdentityBasis: 'source-position' },
|
|
60
|
-
lossReport: { lossless: false, excludedRecordTypes: ['system', 'system_reminder', 'reasoning'], unavailable: ['eventTimestamps', 'attachments', 'fileSnapshots'
|
|
70
|
+
lossReport: { lossless: false, excludedRecordTypes: ['system', 'system_reminder', 'reasoning', ...(record.acquisition ? ['compaction_meta'] : [])], unavailable: [...(record.occurredAt ? [] : ['eventTimestamps']), 'attachments', 'fileSnapshots'] },
|
|
61
71
|
},
|
|
62
72
|
};
|
|
63
73
|
}
|
|
74
|
+
const updateEnvelope = z.looseObject({
|
|
75
|
+
timestamp: z.number().finite(),
|
|
76
|
+
method: z.enum(['session/update', '_x.ai/session/update']),
|
|
77
|
+
params: z.looseObject({
|
|
78
|
+
sessionId: z.string().uuid(),
|
|
79
|
+
update: z.looseObject({ sessionUpdate: z.string() }),
|
|
80
|
+
_meta: z.looseObject({ agentTimestampMs: z.number().finite().nonnegative().max(8_640_000_000_000_000).optional() }).optional(),
|
|
81
|
+
}),
|
|
82
|
+
});
|
|
83
|
+
const messageUpdate = z.looseObject({
|
|
84
|
+
content: text,
|
|
85
|
+
_meta: z.looseObject({ modelId: z.string().optional(), promptIndex: z.number().int().nonnegative().optional(), hostTurn: z.boolean().optional() }).optional(),
|
|
86
|
+
});
|
|
87
|
+
const compactUpdate = z.strictObject({
|
|
88
|
+
sessionUpdate: z.literal('auto_compact_completed'),
|
|
89
|
+
tokens_before: z.number().int().nonnegative(), tokens_after: z.number().int().nonnegative(),
|
|
90
|
+
summary_preview: z.string().nullable(),
|
|
91
|
+
});
|
|
92
|
+
const checkpointUpdate = z.strictObject({
|
|
93
|
+
sessionUpdate: z.literal('compaction_checkpoint'), checkpoint_id: z.string().uuid(),
|
|
94
|
+
prompt_index_at_compaction: z.number().int().nonnegative(), checkpoint_file: z.string(),
|
|
95
|
+
schema_version: z.literal(1), created_at: z.string(),
|
|
96
|
+
});
|
|
97
|
+
/** Validate checkpoint references without opening their private context files. */
|
|
98
|
+
export function parseNativeCompactionCheckpoint(value) {
|
|
99
|
+
const parsed = checkpointUpdate.safeParse(value);
|
|
100
|
+
if (!parsed.success || !Number.isFinite(Date.parse(parsed.data.created_at))
|
|
101
|
+
|| parsed.data.checkpoint_file !== `compaction_checkpoints/${parsed.data.checkpoint_id}.json`)
|
|
102
|
+
nativeDrift();
|
|
103
|
+
return { checkpointId: parsed.data.checkpoint_id.toLowerCase(), promptIndexAtCompaction: parsed.data.prompt_index_at_compaction };
|
|
104
|
+
}
|
|
105
|
+
const omittedUpdates = new Set(['agent_thought_chunk', 'turn_completed', 'hook_execution', 'background_tasks',
|
|
106
|
+
'compaction_checkpoint', 'subagent_spawned', 'subagent_finished', 'workflow_updated']);
|
|
107
|
+
/** Text-only update logs retain original turns when compaction rewrites chat history. */
|
|
108
|
+
export function projectNativeUpdate(line, sessionId, cwd, metadata) {
|
|
109
|
+
const parsed = updateEnvelope.safeParse(line.value);
|
|
110
|
+
if (!parsed.success || parsed.data.params.sessionId.toLowerCase() !== sessionId)
|
|
111
|
+
nativeDrift();
|
|
112
|
+
const { update, _meta } = parsed.data.params;
|
|
113
|
+
const type = update.sessionUpdate;
|
|
114
|
+
const base = { ...metadata, cwd, sequence: line.sequence * 1_000, acquisition: 'grok-build-native-updates',
|
|
115
|
+
...(_meta?.agentTimestampMs !== undefined ? { occurredAt: new Date(_meta.agentTimestampMs).toISOString() } : {}) };
|
|
116
|
+
if (type === 'user_message_chunk' || type === 'agent_message_chunk') {
|
|
117
|
+
const message = messageUpdate.safeParse(update);
|
|
118
|
+
if (!message.success)
|
|
119
|
+
nativeDrift();
|
|
120
|
+
return { record: { ...base, kind: 'message', role: type === 'user_message_chunk' ? 'user' : 'assistant',
|
|
121
|
+
content: message.data.content.text, ...(message.data._meta?.modelId ? { model: message.data._meta.modelId } : {}) }, line };
|
|
122
|
+
}
|
|
123
|
+
if (type === 'auto_compact_completed') {
|
|
124
|
+
const compact = compactUpdate.safeParse(update);
|
|
125
|
+
if (!compact.success)
|
|
126
|
+
nativeDrift();
|
|
127
|
+
return { record: { ...base, kind: 'compaction', content: '',
|
|
128
|
+
compaction: { tokensBefore: compact.data.tokens_before, tokensAfter: compact.data.tokens_after } }, line };
|
|
129
|
+
}
|
|
130
|
+
if (!omittedUpdates.has(type) && type !== 'tool_call' && type !== 'tool_call_update')
|
|
131
|
+
nativeDrift();
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
64
134
|
//# sourceMappingURL=grok-build-native-records.js.map
|