@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.
Files changed (53) hide show
  1. package/agentic/code/providers/capability-matrix.yaml +75 -5
  2. package/agentic/code/providers/model-capabilities.v1.json +35 -27
  3. package/dist/src/artifacts/index-builder.js +4 -2
  4. package/dist/src/artifacts/query-engine-rules.js +2 -2
  5. package/dist/src/artifacts/types.js +1 -1
  6. package/dist/src/cli/handlers/script-runner.js +7 -4
  7. package/dist/src/cli/handlers/steward-format.js +12 -0
  8. package/dist/src/cli/handlers/use.js +13 -4
  9. package/dist/src/cli/handlers/utility-doctor.js +4 -0
  10. package/dist/src/extensions/manifest.js +6 -0
  11. package/dist/src/extensions/project-local-discovery.js +21 -1
  12. package/dist/src/extensions/project-local-scaffold.js +19 -7
  13. package/dist/src/models/factory-models.js +144 -0
  14. package/dist/src/models/model-capabilities.v1.json +35 -27
  15. package/dist/src/models/model-discovery.js +7 -3
  16. package/dist/src/models/worker-installation.d.mts +2 -0
  17. package/dist/src/models/worker-installation.mjs +11 -2
  18. package/dist/src/models/worker-invocation-policy.js +25 -1
  19. package/dist/src/models/wrapper-enforcement.js +1 -1
  20. package/dist/src/policy/repo-access.js +3 -1
  21. package/dist/src/providers/capability-matrix.yaml +75 -5
  22. package/dist/src/providers/deployment-ownership.mjs +8 -1
  23. package/dist/src/providers/deployment-preservation.mjs +44 -3
  24. package/dist/src/providers/grok-build-acp.js +13 -5
  25. package/dist/src/providers/grok-build-dispatch.js +35 -2
  26. package/dist/src/providers/grok-build-headless.js +2 -1
  27. package/dist/src/serve/worker-stdin-frame.mjs +1 -1
  28. package/dist/src/sessions/adapters/grok-build-native-records.js +77 -7
  29. package/dist/src/sessions/adapters/grok-build-native.js +148 -1
  30. package/dist/src/sessions/adapters/grok-build.js +36 -14
  31. package/dist/src/sessions/normalization.js +1 -1
  32. package/dist/src/smiths/context-pipeline/workspace-doctor.js +4 -0
  33. package/dist/src/smiths/hook-bridge/factory-trust.js +2 -2
  34. package/dist/src/smiths/hook-bridge/hermes-prompt-discovery.js +10 -7
  35. package/dist/src/smiths/hook-bridge/hermes-trust.js +65 -0
  36. package/package.json +1 -1
  37. package/tools/agents/deploy-agents.mjs +4 -2
  38. package/tools/agents/deploy-options.mjs +2 -0
  39. package/tools/agents/providers/base-inventory.mjs +3 -1
  40. package/tools/agents/providers/base-kernel-skills.mjs +11 -5
  41. package/tools/agents/providers/grok-build.mjs +31 -40
  42. package/tools/agents/providers/model-wrapper.mjs +2 -5
  43. package/tools/agents/providers/rule-deployment-commit.mjs +3 -0
  44. package/tools/agents/providers/rule-deployment-prepare.mjs +2 -2
  45. package/tools/agents/providers/rule-projection.mjs +39 -4
  46. package/tools/agents/providers/skill-copy-prune.mjs +12 -0
  47. package/tools/agents/providers/stale-artifact-prune.mjs +24 -10
  48. package/tools/ralph-external/lib/claude-adapter.mjs +2 -0
  49. package/tools/ralph-external/lib/factory-adapter.mjs +6 -2
  50. package/tools/ralph-external/lib/worker-inputs.mjs +20 -1
  51. package/tools/ralph-external/lib/worker-isolation.mjs +1 -0
  52. package/tools/ralph-external/lib/worker-termination.mjs +21 -12
  53. package/tools/ralph-external/session-launcher.mjs +22 -17
@@ -49,7 +49,7 @@ import { ScopedFailureBreaker, attributeFailureScope } from './lib/consecutive-f
49
49
  import { assertManagedWorkerLaunch, validateManagedAttempt } from './lib/managed-worker-attempt.mjs';
50
50
  export { assertManagedWorkerLaunch } from './lib/managed-worker-attempt.mjs';
51
51
  import { buildSessionEnvironment } from './lib/session-environment.mjs';
52
- import { withWorkerPath, boundedPrivateRead } from './lib/worker-inputs.mjs';
52
+ import { withWorkerPath, withWorkerDirectory, boundedPrivateRead } from './lib/worker-inputs.mjs';
53
53
  import { collectWorkerFinal } from './lib/worker-final.mjs';
54
54
  import { workerRunDirectoryRefusal } from './lib/worker-run-directory-refusal.mjs';
55
55
  import { workerPromptBrief } from './lib/worker-prompt.mjs';
@@ -1144,7 +1144,8 @@ async function captureOneWorker(owner, ctx) {
1144
1144
  // Require positive kernel evidence of owned containment being empty.
1145
1145
  const terminationEvidence = outcome.mode !== 'systemd-unit' && child.pid === undefined
1146
1146
  ? { confirmed: true, missing: null } : await settleWorkerTermination({ mode: outcome.mode, native,
1147
- workerExited: sawExit, identity, supervisor, invocationId });
1147
+ workerExited: sawExit, identity, supervisor, invocationId,
1148
+ detachedPid: !hasTransport && outcome.ownedGroup === true ? child.pid : undefined });
1148
1149
  const confirmed = terminationEvidence.confirmed;
1149
1150
  // `worker-exit.json`/`worker-identity.json` are written into a directory
1150
1151
  // the worker itself can reach (same UID, no filesystem confinement), so a
@@ -1819,7 +1820,8 @@ async function captureOneWorkerBaseline(owner, ctx) {
1819
1820
  const members = identity ? sampleWorkerGroup(identity.pgid) : null;
1820
1821
  const terminationEvidence = outcome.mode !== 'systemd-unit' && child.pid === undefined
1821
1822
  ? { confirmed: true, missing: null } : await settleWorkerTermination({ mode: outcome.mode, native,
1822
- workerExited: sawExit, identity, supervisor, invocationId });
1823
+ workerExited: sawExit, identity, supervisor, invocationId,
1824
+ detachedPid: !hasTransport && outcome.ownedGroup === true ? child.pid : undefined });
1823
1825
  const confirmed = terminationEvidence.confirmed;
1824
1826
  const workerExit = hasTransport ? await transportRecord('worker-exit.json') : null;
1825
1827
  if (!identity && hasTransport && nativeSupervisor) {
@@ -2301,10 +2303,10 @@ function strictLedgerJson(text) {
2301
2303
  * (someone else already created it) -- never throws for that one case, so
2302
2304
  * callers can treat "lost the create race" as an ordinary branch rather
2303
2305
  * than an exception. */
2304
- async function createLedgerFileExclusive(dir, name, content) {
2306
+ async function createLedgerFileExclusive(dir, name, content, withPath) {
2305
2307
  let handle;
2306
2308
  try {
2307
- handle = await withWorkerPath(join(dir, name), target =>
2309
+ handle = await withPath(join(dir, name), target =>
2308
2310
  open(target, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600));
2309
2311
  } catch (error) {
2310
2312
  if (error.code === 'EEXIST') return false;
@@ -2354,13 +2356,13 @@ const LEDGER_POLICY_LINK_RECHECK_ATTEMPTS = 4;
2354
2356
  * (attempt/correction slots and their `.charged` markers) keeps the
2355
2357
  * unconditional nlink-1 rule -- nothing ever legitimately double-links
2356
2358
  * them. */
2357
- async function statLedgerChainEntry(dir, name) {
2359
+ async function statLedgerChainEntry(dir, name, withPath = withWorkerPath) {
2358
2360
  const target = join(dir, name);
2359
- let stat = await withWorkerPath(target, t => lstat(t));
2361
+ let stat = await withPath(target, t => lstat(t));
2360
2362
  if (name === 'policy') {
2361
2363
  for (let attempt = 0; attempt < LEDGER_POLICY_LINK_RECHECK_ATTEMPTS && stat.nlink === 2; attempt += 1) {
2362
2364
  await new Promise(resolve => setTimeout(resolve, LEDGER_POLICY_LINK_RECHECK_MS));
2363
- stat = await withWorkerPath(target, t => lstat(t));
2365
+ stat = await withPath(target, t => lstat(t));
2364
2366
  }
2365
2367
  }
2366
2368
  return stat;
@@ -2480,9 +2482,9 @@ const CORRECTION_CHARGED_NAME_RE = /^correction-([1-9][0-9]*)\.charged$/;
2480
2482
  * whatever `policy` already pinned -- a correction reserved moments after
2481
2483
  * its attempt handle re-runs this against the CURRENT directory contents,
2482
2484
  * never trusting that nothing changed since the attempt's own reserve. */
2483
- async function validateLedgerChainDirectory(dir, policy) {
2485
+ async function validateLedgerChainDirectory(dir, policy, withPath) {
2484
2486
  let entries;
2485
- try { entries = await withWorkerPath(dir, target => readdir(target)); }
2487
+ try { entries = await withPath(dir, target => readdir(target)); }
2486
2488
  catch (error) { if (error.code === 'ENOENT') return; throw error; }
2487
2489
  if (entries.length > LEDGER_DIR_MAX_ENTRIES) {
2488
2490
  ledgerFail(LEDGER_RECORD_INVALID_CODE, 'Allowance ledger directory has more entries than expected');
@@ -2504,7 +2506,7 @@ async function validateLedgerChainDirectory(dir, policy) {
2504
2506
  }
2505
2507
  }
2506
2508
  let stat;
2507
- try { stat = await statLedgerChainEntry(dir, name); }
2509
+ try { stat = await statLedgerChainEntry(dir, name, withPath); }
2508
2510
  catch (error) { ledgerFail(LEDGER_RECORD_INVALID_CODE, `Allowance ledger entry '${name}' is not inspectable (${error.message})`); }
2509
2511
  if (!stat.isFile() || stat.uid !== process.getuid() || (stat.mode & 0o777) !== 0o600) {
2510
2512
  ledgerFail(LEDGER_RECORD_INVALID_CODE, `Allowance ledger entry '${name}' is not a canonical conductor-owned 0600 regular file`);
@@ -2582,7 +2584,7 @@ async function ensureLedgerChain({ captureRoot, taskChainDigest, maxAttempts, af
2582
2584
  }
2583
2585
  for (const parent of parents.reverse()) await syncLedgerDirectory(parent);
2584
2586
  const policy = await ensureLedgerPolicy(dir, ledgerRoot, taskChainDigest, maxAttempts, afterPolicyWrite);
2585
- await validateLedgerChainDirectory(dir, policy);
2587
+ await withWorkerDirectory(dir, withPath => validateLedgerChainDirectory(dir, policy, withPath));
2586
2588
  return { dir, policy };
2587
2589
  }
2588
2590
 
@@ -2599,11 +2601,11 @@ async function ensureLedgerChain({ captureRoot, taskChainDigest, maxAttempts, af
2599
2601
  * crit-round8 D1: "Lowest-free scanning is safe for the ceiling, not a
2600
2602
  * snapshot of availability"). Returns the won slot number, or `null` once
2601
2603
  * both passes find nothing free. */
2602
- async function reserveLedgerSlotFile(dir, prefix, ceiling, invocationId, { beforeRescan } = {}) {
2604
+ async function reserveLedgerSlotFile(dir, prefix, ceiling, invocationId, { beforeRescan, withPath }) {
2603
2605
  for (let pass = 0; pass < 2; pass += 1) {
2604
2606
  for (let n = 1; n <= ceiling; n += 1) {
2605
2607
  // eslint-disable-next-line no-await-in-loop
2606
- if (await createLedgerFileExclusive(dir, `${prefix}-${n}`, invocationId)) return n;
2608
+ if (await createLedgerFileExclusive(dir, `${prefix}-${n}`, invocationId, withPath)) return n;
2607
2609
  }
2608
2610
  if (pass === 0 && beforeRescan) await beforeRescan();
2609
2611
  }
@@ -2857,7 +2859,8 @@ export async function reserveDirectWorkerAllowance({ captureRoot, taskChainDiges
2857
2859
  dir: null, maxAttempts: chain.maxAttempts });
2858
2860
  }
2859
2861
  const { dir, policy } = await ensureLedgerChain({ captureRoot, taskChainDigest, maxAttempts, afterPolicyWrite });
2860
- const n = await reserveLedgerSlotFile(dir, 'attempt', policy.maxAttempts, invocationId, { beforeRescan: rescan });
2862
+ const n = await withWorkerDirectory(dir, withPath =>
2863
+ reserveLedgerSlotFile(dir, 'attempt', policy.maxAttempts, invocationId, { beforeRescan: rescan, withPath }));
2861
2864
  if (n == null) {
2862
2865
  const occupied = await describeOccupiedLedgerSlots(dir, 'attempt', policy.maxAttempts);
2863
2866
  ledgerFail(ALLOWANCE_EXHAUSTED_CODE, `Task-chain allowance exhausted (${policy.maxAttempts} attempt(s)); occupied: ${occupied}`);
@@ -3031,8 +3034,10 @@ export async function reserveLedgerCorrection({ ledger, reasonCode,
3031
3034
  const chain = _inProcessLedgerChains.get(ledger.taskChainDigest);
3032
3035
  n = chain ? reserveLedgerSlotInProcess(chain.corrections, ceiling, ledger.invocationId) : null;
3033
3036
  } else {
3034
- await validateLedgerChainDirectory(ledger.dir, { maxAttempts: ledger.maxAttempts, maxCorrections: ceiling });
3035
- n = await reserveLedgerSlotFile(ledger.dir, 'correction', ceiling, ledger.invocationId);
3037
+ await withWorkerDirectory(ledger.dir, withPath =>
3038
+ validateLedgerChainDirectory(ledger.dir, { maxAttempts: ledger.maxAttempts, maxCorrections: ceiling }, withPath));
3039
+ n = await withWorkerDirectory(ledger.dir, withPath =>
3040
+ reserveLedgerSlotFile(ledger.dir, 'correction', ceiling, ledger.invocationId, { withPath }));
3036
3041
  }
3037
3042
  if (n == null) return startupCorrectionGate({ correctionsUsed: ceiling, reasonCode });
3038
3043
  if (afterCorrectionReserved) await afterCorrectionReserved();