@aiwg/cli 2026.11.4 → 2026.11.6
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 +44 -36
- package/bin/aiwg.mjs +6 -4
- package/dist/src/activity-log/cli.js +1 -1
- package/dist/src/agents/agent-deployer.js +1 -1
- package/dist/src/artifacts/audit/types.js +1 -1
- package/dist/src/artifacts/discover-facets.js +1 -1
- package/dist/src/artifacts/enrichment/prompt.js +1 -1
- package/dist/src/artifacts/enrichment/types.js +1 -1
- 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/artifacts/views/definition.js +1 -1
- package/dist/src/artifacts/views/types.js +1 -1
- package/dist/src/catalog/cli.js +1 -1
- package/dist/src/catalog/cli.mjs +1 -1
- package/dist/src/catalog/loader.js +1 -1
- package/dist/src/catalog/loader.mjs +1 -1
- package/dist/src/catalog/types.js +1 -1
- package/dist/src/cli/cli-extension-loader.js +19 -5
- package/dist/src/cli/cli-extension-paths.js +65 -0
- package/dist/src/cli/handlers/best-practices-audit.js +1 -1
- package/dist/src/cli/handlers/help.js +3 -4
- package/dist/src/cli/handlers/index.js +1 -1
- package/dist/src/cli/handlers/marketplace-plugin-search.js +37 -0
- package/dist/src/cli/handlers/marketplace.js +3 -1
- package/dist/src/cli/handlers/models.js +1 -1
- package/dist/src/cli/handlers/ralph-launcher.js +8 -2
- package/dist/src/cli/handlers/ralph.js +1 -1
- package/dist/src/cli/handlers/runtime-info.js +1 -1
- package/dist/src/cli/handlers/scaffolding.js +2 -2
- package/dist/src/cli/handlers/script-runner.js +8 -5
- package/dist/src/cli/handlers/sdlc-accelerate.js +1 -1
- package/dist/src/cli/handlers/steward-format.js +12 -0
- package/dist/src/cli/handlers/subcommands-bundles.js +1 -1
- package/dist/src/cli/handlers/subcommands-list-format.js +19 -1
- package/dist/src/cli/handlers/types.js +1 -1
- package/dist/src/cli/handlers/use.js +15 -6
- package/dist/src/cli/handlers/utilities.js +1 -1
- package/dist/src/cli/handlers/utility-doctor.js +4 -0
- package/dist/src/cli/handlers/version.js +1 -1
- package/dist/src/cli/handlers/workspace.js +1 -1
- package/dist/src/cli/help-generator.js +9 -11
- package/dist/src/cli/hooks/builtin/activity-log-hook.js +1 -1
- package/dist/src/cli/router.js +1 -1
- package/dist/src/cli/workflow-orchestrator.js +1 -1
- package/dist/src/config/worker-context.js +37 -7
- package/dist/src/config/worker-parallelism.js +11 -0
- package/dist/src/contributors/detect.js +1 -1
- package/dist/src/contributors/discover.js +1 -1
- package/dist/src/contributors/heuristic.js +1 -1
- package/dist/src/contributors/index.js +1 -1
- package/dist/src/contributors/types.js +1 -1
- package/dist/src/contributors/validation.js +1 -1
- package/dist/src/effects/worker-delivery.js +83 -0
- package/dist/src/extensions/capability-index.js +1 -1
- package/dist/src/extensions/commands/definitions.js +2 -2
- package/dist/src/extensions/deployment-registration.js +1 -1
- package/dist/src/extensions/index.js +1 -1
- package/dist/src/extensions/loader.js +1 -1
- package/dist/src/extensions/manifest.js +10 -2
- package/dist/src/extensions/project-local-activity.js +1 -1
- package/dist/src/extensions/project-local-discovery.js +23 -3
- package/dist/src/extensions/project-local-doctor.js +7 -3
- package/dist/src/extensions/project-local-promote.js +3 -3
- package/dist/src/extensions/project-local-remove.js +3 -3
- package/dist/src/extensions/project-local-scaffold.js +20 -8
- package/dist/src/extensions/registry.js +1 -1
- package/dist/src/extensions/shadow-resolver.js +1 -1
- package/dist/src/extensions/types.js +1 -1
- package/dist/src/extensions/upstream-registry.js +1 -1
- package/dist/src/extensions/validation.js +1 -1
- package/dist/src/intake/git-history-analyzer.js +1 -1
- package/dist/src/kb/cli.js +1 -1
- package/dist/src/marketplace/plugin-directory.js +36 -0
- package/dist/src/marketplace/plugin-search.js +180 -0
- package/dist/src/mcp/cli.mjs +2 -2
- package/dist/src/mcp/helpers.mjs +1 -1
- package/dist/src/mcp/http-tools.mjs +8 -6
- package/dist/src/mcp/http-transport.mjs +3 -1
- package/dist/src/mcp/server.mjs +1 -1
- package/dist/src/mcp/tools/command-run.mjs +1 -1
- package/dist/src/mcp/tools/discovery.mjs +1 -1
- package/dist/src/mcp/tools/subsystems.mjs +1 -1
- package/dist/src/mcp/tools/worker-invoke.mjs +68 -22
- package/dist/src/mcp/tools/worker-local-only-preflight.mjs +79 -0
- package/dist/src/mcp/tools/worker-recorded-launch.mjs +26 -0
- package/dist/src/mcp/tools/worker-stdin-runtime.mjs +33 -6
- package/dist/src/mcp/tools/worker-verify-deliver-schema.mjs +33 -0
- package/dist/src/mcp/tools/worker-verify-deliver.mjs +27 -0
- package/dist/src/models/catalog-policy.js +2 -2
- package/dist/src/models/conductor-data-policy.mjs +83 -14
- package/dist/src/models/config-loader.js +2 -2
- package/dist/src/models/factory-models.js +144 -0
- package/dist/src/models/index.js +2 -2
- package/dist/src/models/local-endpoint-models.js +155 -0
- package/dist/src/models/model-capabilities.v1.json +44 -36
- package/dist/src/models/model-discovery.js +16 -8
- package/dist/src/models/opencode-worker-model.mjs +16 -0
- package/dist/src/models/resolver.js +2 -2
- package/dist/src/models/worker-installation.d.mts +2 -0
- package/dist/src/models/worker-installation.mjs +16 -5
- package/dist/src/models/worker-invocation-policy.js +25 -1
- package/dist/src/models/worker-plan.js +1 -1
- package/dist/src/models/wrapper-enforcement.js +1 -1
- package/dist/src/plugin/plugin-installer.js +2 -2
- package/dist/src/plugin/registry-validator.js +2 -2
- package/dist/src/plugin/skill-command-translator.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/rlm/cache/hash.js +1 -1
- package/dist/src/rlm/cache/store.js +1 -1
- package/dist/src/rlm/cache/types.js +1 -1
- package/dist/src/serve/worker-invocation-preparation.js +13 -0
- package/dist/src/serve/worker-invocation.js +21 -6
- 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/skills/run.js +0 -11
- package/dist/src/smiths/agentsmith/generator.js +1 -1
- package/dist/src/smiths/context-pipeline/index.js +1 -1
- package/dist/src/smiths/context-pipeline/provider-policy.js +1 -1
- package/dist/src/smiths/context-pipeline/types.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/dist/src/smiths/mcpsmith/analyzers/cli-analyzer.js +2 -2
- package/dist/src/smiths/mcpsmith/generator.js +2 -2
- package/dist/src/smiths/mcpsmith/index.js +2 -2
- package/dist/src/smiths/mcpsmith/types.js +2 -2
- package/dist/src/smiths/skillsmith/collision-detector.js +1 -1
- package/dist/src/smiths/skillsmith/namespace-adapter.js +1 -1
- package/dist/src/smiths/toolsmith/runtime-discovery.mjs +2 -2
- package/dist/src/smiths/toolsmith/types.js +2 -2
- package/dist/src/storage/backends/fortemi.js +1 -1
- package/dist/src/storage/backends/fs.js +1 -1
- package/dist/src/storage/backends/logseq.js +1 -1
- package/dist/src/storage/backends/obsidian.js +1 -1
- package/dist/src/storage/cli.js +2 -2
- package/dist/src/storage/config.js +1 -1
- package/dist/src/storage/index.js +1 -1
- package/dist/src/storage/subsystem-cli.js +1 -1
- package/dist/src/storage/types.js +1 -1
- package/dist/src/testing/generators/test-case-generator.js +1 -1
- package/dist/src/writing/validation-engine.js +1 -1
- package/package.json +11 -1
- package/schemas/models/model-catalog.v1.schema.json +6 -3
- 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/conductor-data-guard.mjs +1 -1
- 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/mcp-worker-launch.mjs +67 -0
- package/tools/ralph-external/lib/opencode-adapter.mjs +9 -7
- package/tools/ralph-external/lib/trusted-verification.mjs +1021 -0
- package/tools/ralph-external/lib/typed-stop-delivery.mjs +46 -0
- package/tools/ralph-external/lib/verification-isolation.mjs +509 -0
- package/tools/ralph-external/lib/worker-context.mjs +3 -3
- package/tools/ralph-external/lib/worker-delivery-guards.mjs +95 -0
- package/tools/ralph-external/lib/worker-delivery-record.mjs +15 -0
- package/tools/ralph-external/lib/worker-final.mjs +4 -1
- package/tools/ralph-external/lib/worker-inputs.mjs +20 -1
- package/tools/ralph-external/lib/worker-isolation-status.mjs +3 -0
- package/tools/ralph-external/lib/worker-isolation.mjs +1 -0
- package/tools/ralph-external/lib/worker-launch-cli.mjs +8 -0
- package/tools/ralph-external/lib/worker-local-only-paths.mjs +45 -0
- package/tools/ralph-external/lib/worker-prompt.mjs +4 -1
- package/tools/ralph-external/lib/worker-retry-evidence.mjs +2 -1
- package/tools/ralph-external/lib/worker-run-directory.mjs +45 -0
- package/tools/ralph-external/lib/worker-termination.mjs +21 -12
- package/tools/ralph-external/lib/worker-unit-cleanup.mjs +10 -2
- package/tools/ralph-external/lib/worker-verification-cli.mjs +164 -0
- package/tools/ralph-external/lib/worktree-preparation.mjs +417 -0
- package/tools/ralph-external/session-launcher.mjs +30 -32
- package/vscode-extension/schemas/aiwg.config.v1.json +27 -0
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Provides efficient storage, indexing, and retrieval of AIWG extensions.
|
|
5
5
|
* Supports O(1) lookup by ID, type-based indexing, and command alias resolution.
|
|
6
6
|
*
|
|
7
|
-
* @architecture
|
|
7
|
+
* @architecture @docs/architecture/cli/extending-cli.md
|
|
8
8
|
* @tests @test/unit/extensions/registry.test.ts
|
|
9
9
|
* @version 1.0.0
|
|
10
10
|
*/
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Shadow Resolver
|
|
3
3
|
*
|
|
4
4
|
* Implements the override / shadow-resolution policy from
|
|
5
|
-
*
|
|
5
|
+
* `docs/customization/project-local-lifecycle.md` (#1041) for project-local
|
|
6
6
|
* artifact bundles deployed via `aiwg use` / `aiwg refresh`.
|
|
7
7
|
*
|
|
8
8
|
* Resolves the seven cases from ADR §4:
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* hooks, tools, and MCP servers. Enables dynamic discovery, semantic search,
|
|
6
6
|
* and unified help generation.
|
|
7
7
|
*
|
|
8
|
-
* @architecture
|
|
8
|
+
* @architecture @docs/architecture/cli/extending-cli.md
|
|
9
9
|
* @version 1.0.0
|
|
10
10
|
*/
|
|
11
11
|
// ============================================
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Consumed by the shadow resolver (#1036) to detect collisions between project-
|
|
12
12
|
* local bundles and upstream artifacts and apply the override / safety-critical
|
|
13
|
-
* denylist policy from
|
|
13
|
+
* denylist policy from `docs/customization/project-local-lifecycle.md`.
|
|
14
14
|
*
|
|
15
15
|
* @implements #1036
|
|
16
16
|
*/
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* error messages. Ensures extension manifests conform to the unified schema.
|
|
6
6
|
*
|
|
7
7
|
* @implements @.aiwg/requirements/use-cases/UC-003-extension-validation.md
|
|
8
|
-
* @architecture
|
|
8
|
+
* @architecture @docs/architecture/cli/extending-cli.md
|
|
9
9
|
* @tests @test/unit/extensions/validation.test.ts
|
|
10
10
|
* @version 1.0.0
|
|
11
11
|
*/
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module src/intake/git-history-analyzer
|
|
8
8
|
* @implements @.aiwg/requirements/use-cases/UC-003-generate-intake-from-codebase.md
|
|
9
|
-
* @architecture
|
|
9
|
+
* @architecture @docs/architecture/cli/index.md
|
|
10
10
|
* @tests @test/unit/intake/git-history-analyzer.test.ts
|
|
11
11
|
* @command @.claude/commands/intake-from-codebase.md
|
|
12
12
|
* @agent @agentic/code/frameworks/sdlc-complete/agents/intake-coordinator.md
|
package/dist/src/kb/cli.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* put <path> Write stdin contents to an entry (creates parents)
|
|
14
14
|
* delete <path> Delete an entry (no-op if missing)
|
|
15
15
|
*
|
|
16
|
-
* @design
|
|
16
|
+
* @design @docs/storage/overview.md
|
|
17
17
|
* @issue #934
|
|
18
18
|
* @issue #965
|
|
19
19
|
*/
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const record = (value) => value !== null && typeof value === 'object' ? value : {};
|
|
2
|
+
export function repositoryKey(value) {
|
|
3
|
+
if (typeof value !== 'string')
|
|
4
|
+
return null;
|
|
5
|
+
try {
|
|
6
|
+
const url = new URL(value);
|
|
7
|
+
return `${url.hostname.toLowerCase()}${url.pathname.replace(/\.git\/?$/, '').replace(/\/$/, '')}`.toLowerCase();
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return /^[\w.-]+\/[\w.-]+$/.test(value) ? `github.com/${value.toLowerCase().replace(/\.git$/, '')}` : null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function pluginRepository(plugin, marketplaceSource) {
|
|
14
|
+
const source = record(record(plugin).source);
|
|
15
|
+
const market = record(marketplaceSource);
|
|
16
|
+
return repositoryKey(source.url ?? source.repo) ?? repositoryKey(market.repo ?? market.url);
|
|
17
|
+
}
|
|
18
|
+
export function normalizeDirectoryListing(raw, entryNames, targets) {
|
|
19
|
+
const entry = record(raw);
|
|
20
|
+
if (typeof entry.id !== 'string')
|
|
21
|
+
return null;
|
|
22
|
+
const repository = record(record(entry.source).repository);
|
|
23
|
+
const key = repositoryKey(repository.url);
|
|
24
|
+
const slug = record(entryNames)[entry.id];
|
|
25
|
+
const name = typeof slug === 'string' && slug ? slug : typeof entry.name === 'string' ? entry.name : null;
|
|
26
|
+
if (!name)
|
|
27
|
+
return null;
|
|
28
|
+
const matches = targets.filter(target => key !== null && target.repository === key && target.name === name);
|
|
29
|
+
const matching = matches.length === 1 ? matches[0] : undefined;
|
|
30
|
+
return {
|
|
31
|
+
plugin: { ...entry, name, description: entry.summary, repository: repository.url },
|
|
32
|
+
marketplace: matching?.marketplace ?? undefined,
|
|
33
|
+
directoryId: matching ? undefined : entry.id,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=plugin-directory.js.map
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
// Read provider-owned plugin manifests and caches without fetching or changing state.
|
|
2
|
+
import { normalizeDirectoryListing, pluginRepository, repositoryKey } from './plugin-directory.js';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
const object = (value) => value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
7
|
+
? value : {};
|
|
8
|
+
const string = (value) => typeof value === 'string' && value.trim() ? value : undefined;
|
|
9
|
+
function date(value) {
|
|
10
|
+
if (typeof value !== 'string' && typeof value !== 'number')
|
|
11
|
+
return null;
|
|
12
|
+
const milliseconds = typeof value === 'number' && value < 1e12 ? value * 1000 : value;
|
|
13
|
+
const parsed = new Date(milliseconds);
|
|
14
|
+
return Number.isFinite(parsed.getTime()) ? parsed.toISOString() : null;
|
|
15
|
+
}
|
|
16
|
+
function asOf(value) {
|
|
17
|
+
return date(value.lastUpdated ?? value.updatedAt ?? value.fetchedAt ?? value.timestamp);
|
|
18
|
+
}
|
|
19
|
+
function entries(value) {
|
|
20
|
+
return Array.isArray(value) ? value.map((entry, index) => [String(index), entry]) : Object.entries(object(value));
|
|
21
|
+
}
|
|
22
|
+
export function searchProviderPlugins(query, options = {}) {
|
|
23
|
+
const maxAgeDays = options.maxAgeDays ?? 30;
|
|
24
|
+
if (!Number.isFinite(maxAgeDays) || maxAgeDays < 0)
|
|
25
|
+
throw new Error('--max-age-days must be a non-negative number');
|
|
26
|
+
const report = {
|
|
27
|
+
query, marketplaces: [], results: [], warnings: [],
|
|
28
|
+
ranking: 'Matched terms, review tier (anthropic > partner > none/unknown), installs, cache date; descending. Signals are observations, not ratings or capability measurements.',
|
|
29
|
+
};
|
|
30
|
+
const provider = options.provider ?? 'all';
|
|
31
|
+
if (!['all', 'claude', 'codex'].includes(provider))
|
|
32
|
+
throw new Error('Plugin search supports --provider all, claude or codex');
|
|
33
|
+
if (provider !== 'claude')
|
|
34
|
+
report.warnings.push('Codex marketplace.json search deferred pending a stable local manifest/configuration contract (#783). Other provider formats are not yet supported.');
|
|
35
|
+
if (provider === 'codex')
|
|
36
|
+
return report;
|
|
37
|
+
const base = path.join(options.claudeConfigDir ?? process.env.CLAUDE_CONFIG_DIR
|
|
38
|
+
?? path.join(options.home ?? os.homedir(), '.claude'), 'plugins');
|
|
39
|
+
const now = options.now ?? Date.now();
|
|
40
|
+
function read(file, required = false) {
|
|
41
|
+
try {
|
|
42
|
+
const parsed = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
43
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
44
|
+
throw new Error('Expected a JSON object');
|
|
45
|
+
return object(parsed);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (required || error.code !== 'ENOENT') {
|
|
49
|
+
report.warnings.push(`Unable to read marketplace data: ${file}`);
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function checkAge(file, timestamp) {
|
|
55
|
+
if (!timestamp)
|
|
56
|
+
report.warnings.push(`Cache date unknown: ${file}`);
|
|
57
|
+
else if (Date.parse(timestamp) > now)
|
|
58
|
+
report.warnings.push(`Cache date is in the future: ${file} (as of ${timestamp})`);
|
|
59
|
+
else if (now - Date.parse(timestamp) > maxAgeDays * 86_400_000) {
|
|
60
|
+
report.warnings.push(`Stale cache: ${file} (as of ${timestamp}; maximum age ${maxAgeDays} days)`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const results = new Map();
|
|
64
|
+
function add(raw, marketplace, source, timestamp, key, directoryId, repository) {
|
|
65
|
+
const entry = object(raw);
|
|
66
|
+
const plugin = Object.keys(object(entry.plugin)).length ? object(entry.plugin) : entry;
|
|
67
|
+
const coordinate = string(entry.id) ?? (key?.includes('@') ? key : undefined);
|
|
68
|
+
const split = coordinate?.lastIndexOf('@') ?? -1;
|
|
69
|
+
const name = string(plugin.name) ?? (split > 0 ? coordinate?.slice(0, split) : undefined);
|
|
70
|
+
const market = marketplace ?? string(entry.marketplace) ?? string(object(entry.marketplace).name)
|
|
71
|
+
?? string(entry.marketplaceName) ?? (split > 0 ? coordinate?.slice(split + 1) : undefined);
|
|
72
|
+
if (!name || (!market && !directoryId))
|
|
73
|
+
return;
|
|
74
|
+
const id = directoryId ? `directory:${directoryId}` : `${name}@${market}`;
|
|
75
|
+
const previous = results.get(id);
|
|
76
|
+
const keywords = Array.isArray(plugin.keywords) ? plugin.keywords.filter((item) => typeof item === 'string') : [];
|
|
77
|
+
const reviewType = object(object(object(entry.checks).review).by).type;
|
|
78
|
+
const review = ['anthropic', 'partner', 'none'].includes(String(reviewType))
|
|
79
|
+
? reviewType : null;
|
|
80
|
+
const observedAt = asOf(entry) ?? timestamp;
|
|
81
|
+
results.set(id, {
|
|
82
|
+
id, name, marketplace: market ?? null, provider: 'claude',
|
|
83
|
+
repository: repository ?? repositoryKey(plugin.repository) ?? previous?.repository ?? null,
|
|
84
|
+
description: string(plugin.description) ?? previous?.description ?? '',
|
|
85
|
+
category: string(plugin.category) ?? previous?.category ?? null,
|
|
86
|
+
keywords: [...new Set([...(previous?.keywords ?? []), ...keywords])],
|
|
87
|
+
sources: [...new Set([...(previous?.sources ?? []), source])],
|
|
88
|
+
cacheAsOf: observedAt ?? previous?.cacheAsOf ?? null,
|
|
89
|
+
installs: previous?.installs ?? { value: null, asOf: null },
|
|
90
|
+
review: review ? { value: review, asOf: observedAt } : previous?.review ?? { value: null, asOf: null },
|
|
91
|
+
matchedTerms: [], installSkill: 'install-plugin',
|
|
92
|
+
installHelp: 'aiwg show skill install-plugin',
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const registryFile = path.join(base, 'known_marketplaces.json');
|
|
96
|
+
const registry = read(registryFile);
|
|
97
|
+
for (const [name, value] of Object.entries(registry ?? {}).sort(([a], [b]) => a.localeCompare(b))) {
|
|
98
|
+
const config = object(value);
|
|
99
|
+
const location = string(config.installLocation);
|
|
100
|
+
// Registry names must never escape the provider's marketplaces directory.
|
|
101
|
+
if (!location && (name === '.' || name === '..' || /[\\/]/.test(name))) {
|
|
102
|
+
report.warnings.push(`Invalid marketplace name: ${name}`);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
const manifest = path.join(location ? path.resolve(base, location) : path.join(base, 'marketplaces', name), '.claude-plugin/marketplace.json');
|
|
106
|
+
const data = read(manifest, true);
|
|
107
|
+
const timestamp = asOf(data ?? {}) ?? asOf(config);
|
|
108
|
+
report.marketplaces.push({ name, provider: 'claude', manifest, asOf: timestamp });
|
|
109
|
+
if (!data)
|
|
110
|
+
continue;
|
|
111
|
+
checkAge(manifest, timestamp);
|
|
112
|
+
for (const [key, plugin] of entries(data.plugins))
|
|
113
|
+
add(plugin, name, manifest, timestamp, key, undefined, pluginRepository(plugin, config.source));
|
|
114
|
+
}
|
|
115
|
+
const directoryFile = path.join(base, 'plugin-directory-cache-v2.json');
|
|
116
|
+
const directory = read(directoryFile);
|
|
117
|
+
if (directory) {
|
|
118
|
+
const timestamp = asOf(directory);
|
|
119
|
+
checkAge(directoryFile, timestamp);
|
|
120
|
+
if (!directory.plugins && !directory.listings)
|
|
121
|
+
report.warnings.push(`Unrecognized directory cache format: ${directoryFile}`);
|
|
122
|
+
const manifestTargets = [...results.values()];
|
|
123
|
+
for (const [key, plugin] of entries(directory.plugins))
|
|
124
|
+
add(plugin, undefined, directoryFile, timestamp, key);
|
|
125
|
+
// V2 directory IDs do not encode marketplace membership. Join only on
|
|
126
|
+
// both repository identity and the provider's recorded entry name.
|
|
127
|
+
for (const [, listing] of entries(directory.listings)) {
|
|
128
|
+
const normalized = normalizeDirectoryListing(listing, directory.entryNames, manifestTargets);
|
|
129
|
+
if (normalized)
|
|
130
|
+
add(normalized.plugin, normalized.marketplace, directoryFile, timestamp, undefined, normalized.directoryId);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const countsFile = path.join(base, 'install-counts-cache.json');
|
|
134
|
+
const counts = read(countsFile);
|
|
135
|
+
if (counts) {
|
|
136
|
+
const timestamp = asOf(counts);
|
|
137
|
+
checkAge(countsFile, timestamp);
|
|
138
|
+
if (!counts.counts)
|
|
139
|
+
report.warnings.push(`Unrecognized install-count cache format: ${countsFile}`);
|
|
140
|
+
for (const [key, value] of entries(counts.counts)) {
|
|
141
|
+
const entry = object(value);
|
|
142
|
+
const id = string(entry.plugin) ?? string(entry.id) ?? key;
|
|
143
|
+
const result = results.get(id);
|
|
144
|
+
const installs = entry.unique_installs;
|
|
145
|
+
if (result && typeof installs === 'number' && Number.isSafeInteger(installs) && installs >= 0) {
|
|
146
|
+
result.installs = { value: installs, asOf: asOf(entry) ?? timestamp };
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const terms = [...new Set(query.toLowerCase().match(/[\p{L}\p{N}]+/gu) ?? [])];
|
|
151
|
+
const tier = (result) => ({ anthropic: 2, partner: 1, none: 0 })[result.review.value ?? 'none'];
|
|
152
|
+
report.results = [...results.values()].filter(result => {
|
|
153
|
+
const text = [result.name, result.description, result.category, ...result.keywords].join(' ').toLowerCase();
|
|
154
|
+
result.matchedTerms = terms.filter(term => text.includes(term));
|
|
155
|
+
return terms.length > 0 && result.matchedTerms.length > 0;
|
|
156
|
+
}).sort((a, b) => b.matchedTerms.length - a.matchedTerms.length || tier(b) - tier(a)
|
|
157
|
+
|| (b.installs.value ?? -1) - (a.installs.value ?? -1)
|
|
158
|
+
|| Date.parse(b.cacheAsOf ?? '1970-01-01') - Date.parse(a.cacheAsOf ?? '1970-01-01')
|
|
159
|
+
|| a.id.localeCompare(b.id));
|
|
160
|
+
if (!registry && !directory)
|
|
161
|
+
report.warnings.push('No local Claude marketplace manifests or directory cache found; nothing was fetched.');
|
|
162
|
+
return report;
|
|
163
|
+
}
|
|
164
|
+
export function formatPluginSearch(report) {
|
|
165
|
+
const clean = (value) => value.replace(/[\u0000-\u001f\u007f-\u009f]/g, ' ');
|
|
166
|
+
const lines = [`Plugin marketplace search: ${clean(report.query)}`,
|
|
167
|
+
`Configured marketplaces: ${report.marketplaces.map(market => clean(market.name)).join(', ') || 'none'}`,
|
|
168
|
+
'Plugin / ID | Marketplace | Installs (as of) | Review (as of) | Cache as of | Description'];
|
|
169
|
+
for (const result of report.results)
|
|
170
|
+
lines.push([
|
|
171
|
+
clean(result.marketplace ? result.id : `${result.name} / ${result.id}`), clean(result.marketplace ?? 'unknown'),
|
|
172
|
+
`${result.installs.value ?? 'unknown'} (${result.installs.asOf ?? 'unknown'})`,
|
|
173
|
+
`${result.review.value ?? 'unknown'} (${result.review.asOf ?? 'unknown'})`, result.cacheAsOf ?? 'unknown', clean(result.description),
|
|
174
|
+
].join(' | '));
|
|
175
|
+
if (!report.results.length)
|
|
176
|
+
lines.push('No results found.');
|
|
177
|
+
lines.push(report.ranking, 'Installation guidance for a selected ID: aiwg show skill install-plugin');
|
|
178
|
+
return lines.join('\n');
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=plugin-search.js.map
|
package/dist/src/mcp/cli.mjs
CHANGED
|
@@ -628,7 +628,7 @@ CORE TOOLS (19, always registered):
|
|
|
628
628
|
aiwg_authorization_grant_lookup Read-only list/search/explain of signed grants
|
|
629
629
|
aiwg_authorization_grant_request Save a bounded grant only after native form confirmation
|
|
630
630
|
|
|
631
|
-
OPT-IN TOOLSETS (
|
|
631
|
+
OPT-IN TOOLSETS (72 additional tools, including explicit workers):
|
|
632
632
|
flows flow-list / flow-show / flow-run
|
|
633
633
|
missions mission-guide / mission-dispatch / mission-status / worker-resolve
|
|
634
634
|
memory memory-* and reflections-* storage operations
|
|
@@ -641,7 +641,7 @@ OPT-IN TOOLSETS (71 additional tools, including explicit workers):
|
|
|
641
641
|
ops status / list / use / push
|
|
642
642
|
sandbox fleet inventory / mutation / reconciliation and governed activity
|
|
643
643
|
decision validation / evaluation / rules / features / calibration
|
|
644
|
-
workers worker-invoke (explicit opt-in; all excludes workers)
|
|
644
|
+
workers worker-invoke, worker-verify-deliver (explicit opt-in; all excludes workers)
|
|
645
645
|
|
|
646
646
|
Enable opt-in tools:
|
|
647
647
|
AIWG_MCP_TOOLSETS=flows,missions,memory,kb,ralph,sandbox aiwg mcp serve
|
package/dist/src/mcp/helpers.mjs
CHANGED
|
@@ -14,25 +14,27 @@ function containsCliOption(value) {
|
|
|
14
14
|
return false;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export function remoteToolPolicy(projectDir, tools) {
|
|
17
|
+
export function remoteToolPolicy(projectDir, tools, { verifiedDeliveryOnly = false } = {}) {
|
|
18
18
|
const selected = tools === undefined ? undefined : new Set(tools);
|
|
19
19
|
const exposed = new Set();
|
|
20
20
|
const children = new Set();
|
|
21
21
|
let active = 0;
|
|
22
22
|
return {
|
|
23
23
|
configureTool(name, config, handler) {
|
|
24
|
-
const allowed = name === 'discover' || name.endsWith('-show') || name === 'artifact-write';
|
|
24
|
+
const allowed = name === 'discover' || name.endsWith('-show') || (name === 'artifact-write' && !verifiedDeliveryOnly) || name === 'worker-verify-deliver' || name === 'worker-invoke';
|
|
25
25
|
if (!allowed || (selected && !selected.has(name))) return undefined;
|
|
26
26
|
exposed.add(name);
|
|
27
27
|
const shape = config.inputSchema?.shape ?? {};
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
// This tool's strict publication union already excludes every scope
|
|
29
|
+
// override; reconstructing its shape would discard union validation.
|
|
30
|
+
const inputSchema = name === 'worker-verify-deliver' ? config.inputSchema : z.strictObject(Object.fromEntries(
|
|
31
|
+
Object.entries(shape).filter(([key]) => !scopeFields.has(key) || (name === 'worker-invoke' && key === 'workdir')),
|
|
30
32
|
));
|
|
31
33
|
return { config: { ...config, inputSchema }, handler: async (args, extra) => {
|
|
32
34
|
extra.signal.throwIfAborted();
|
|
33
35
|
// CLI-backed cards must not reinterpret data values as scope/source flags.
|
|
34
36
|
// artifact-write uses openArtifact directly and spawns no CLI.
|
|
35
|
-
if (name !== 'artifact-write' && containsCliOption(args)) {
|
|
37
|
+
if (name !== 'artifact-write' && name !== 'worker-verify-deliver' && name !== 'worker-invoke' && containsCliOption(args)) {
|
|
36
38
|
throw new Error('Tool arguments must not contain CLI options');
|
|
37
39
|
}
|
|
38
40
|
active++;
|
|
@@ -44,7 +46,7 @@ export function remoteToolPolicy(projectDir, tools) {
|
|
|
44
46
|
drain: () => Promise.allSettled([...children]),
|
|
45
47
|
validate() {
|
|
46
48
|
if (selected && [...selected].some(name => !exposed.has(name))) {
|
|
47
|
-
throw new Error('--tools must name only available discover, *-show
|
|
49
|
+
throw new Error('--tools must name only available discover, *-show, artifact-write, worker-invoke or worker-verify-deliver tools; enable required --toolsets explicitly');
|
|
48
50
|
}
|
|
49
51
|
},
|
|
50
52
|
};
|
|
@@ -38,6 +38,8 @@ async function readBody(request, response) {
|
|
|
38
38
|
export async function startHttpServer(options) {
|
|
39
39
|
const host = options.host === '[::1]' ? '::1' : options.host ?? '127.0.0.1';
|
|
40
40
|
const loopback = host === '127.0.0.1' || host === '::1' || host === 'localhost';
|
|
41
|
+
const workersEnabled = String(options.toolsets ?? '').split(',').map(value => value.trim()).includes('workers');
|
|
42
|
+
if (!loopback && workersEnabled) throw new Error('The workers toolset requires a localhost HTTP bind');
|
|
41
43
|
if (!loopback && !options.allowRemoteBind) {
|
|
42
44
|
throw new Error('A non-loopback --host requires --allow-remote-bind');
|
|
43
45
|
}
|
|
@@ -58,7 +60,7 @@ export async function startHttpServer(options) {
|
|
|
58
60
|
let closing = false;
|
|
59
61
|
let stopPromise;
|
|
60
62
|
const buildServer = async () => {
|
|
61
|
-
const policy = remoteToolPolicy(projectDir, options.tools);
|
|
63
|
+
const policy = remoteToolPolicy(projectDir, options.tools, { verifiedDeliveryOnly: workersEnabled });
|
|
62
64
|
const mcp = await createServer({ projectDir, artifactStore, toolsets: options.toolsets ?? '', configureTool: policy.configureTool });
|
|
63
65
|
try { policy.validate(); } catch (error) { await mcp.close(); throw error; }
|
|
64
66
|
policies.set(mcp, policy);
|
package/dist/src/mcp/server.mjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Follows MCP 2025-11-25 specification.
|
|
6
6
|
*
|
|
7
7
|
* @see https://modelcontextprotocol.io/specification/2025-11-25
|
|
8
|
-
* @architecture
|
|
8
|
+
* @architecture @docs/architecture/cli/index.md
|
|
9
9
|
* @reference @docs/references/REF-066-mcp-specification-2025.md
|
|
10
10
|
* @cli @docs/cli/agent-usage.md - mcp serve command
|
|
11
11
|
* @frameworks @agentic/code/frameworks/sdlc-complete/
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* - `shell: false` enforced in spawn
|
|
12
12
|
* - Destructive commands require `confirmed: true`
|
|
13
13
|
*
|
|
14
|
-
* @architecture
|
|
14
|
+
* @architecture @docs/cli/agent-usage.md
|
|
15
15
|
* @issues #1312 (S1)
|
|
16
16
|
* @rules @token-security, @anti-laziness
|
|
17
17
|
*/
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*
|
|
18
18
|
* All are global-allowed (#1311) — work without a project root.
|
|
19
19
|
*
|
|
20
|
-
* @architecture
|
|
20
|
+
* @architecture @docs/cli/agent-usage.md
|
|
21
21
|
* @issues #1311 (scope split), #1313 (discover + pairs), #1320 (rule-list/show)
|
|
22
22
|
*/
|
|
23
23
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Default toolset enabled: `core` (already registered by discovery.mjs +
|
|
10
10
|
* command-run.mjs in server.mjs).
|
|
11
11
|
*
|
|
12
|
-
* @architecture
|
|
12
|
+
* @architecture @docs/cli/agent-usage.md
|
|
13
13
|
* @issues #1322 (memory) #1323 (kb) #1324 (provenance) #1325 (activity-log)
|
|
14
14
|
* #1326 (index) #1327 (ralph) #1328 (ops) #1331 (mc) #1332 (dispatch)
|
|
15
15
|
*/
|
|
@@ -156,7 +156,9 @@
|
|
|
156
156
|
* @issues #2892, #2896 (review reference, not reused as-is)
|
|
157
157
|
*/
|
|
158
158
|
|
|
159
|
+
import { registerWorkerVerifyDeliverTool } from './worker-verify-deliver.mjs';
|
|
159
160
|
import { workerFailureDiagnostics } from './worker-failure-diagnostics.mjs';
|
|
161
|
+
import { workerLocalOnlyPreflight } from './worker-local-only-preflight.mjs';
|
|
160
162
|
import { signalChild } from '../../process/signal-child.mjs';
|
|
161
163
|
import { z } from 'zod';
|
|
162
164
|
|
|
@@ -177,6 +179,7 @@ import path from 'node:path';
|
|
|
177
179
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
178
180
|
import { mcpError, mcpJson } from '../helpers.mjs';
|
|
179
181
|
import { buildShellStopControl, waitForUnitTermination } from './worker-shell-control.mjs';
|
|
182
|
+
import { recordedShellLauncher } from './worker-recorded-launch.mjs';
|
|
180
183
|
import { launchPreparedShellWorker, sweepWorkerStdin, markWorkerServer } from './worker-stdin-runtime.mjs';
|
|
181
184
|
// NOTE: no static import of ../../config/worker-context.js here. That
|
|
182
185
|
// module is TypeScript: a literal relative import resolves under vitest
|
|
@@ -613,7 +616,39 @@ async function loadRalphExternal(relativeFromToolsRoot) {
|
|
|
613
616
|
* in-process instead of shelling out to `aiwg models resolve`. */
|
|
614
617
|
async function defaultLoadWorkerInputs(servedRoot) {
|
|
615
618
|
const { loadWorkerInputs } = await loadModelsHandlerInternals();
|
|
616
|
-
return loadWorkerInputs(
|
|
619
|
+
return loadWorkerInputs(servedWorkerInputsContext(servedRoot));
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/** Same context shape as the launcher's in-process loader. A bare `resolve`
|
|
623
|
+
* subcommand made the host-resource sampler parse a request with no flags
|
|
624
|
+
* and fail every real launch with `Missing role` (#4148). */
|
|
625
|
+
/** A shell worker's final file holds either plain workerClaims JSON (what
|
|
626
|
+
* real workers write, and what the launcher's own final collection reads) or
|
|
627
|
+
* a JSONL result stream. Parsing plain claims as JSONL rejected every real
|
|
628
|
+
* worker final with OG_CONTRACT_INVALID (#4151). The adapter still performs
|
|
629
|
+
* the strict decode and schema validation for either framing. */
|
|
630
|
+
export function shellFinalFormat(rawOutput) {
|
|
631
|
+
try {
|
|
632
|
+
const text = typeof rawOutput === 'string' ? rawOutput : Buffer.from(rawOutput).toString('utf8');
|
|
633
|
+
const value = JSON.parse(text);
|
|
634
|
+
return value && typeof value === 'object' && !Array.isArray(value) && !Object.hasOwn(value, 'type') ? 'json' : 'jsonl';
|
|
635
|
+
} catch {
|
|
636
|
+
return 'jsonl';
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/** systemd collects a unit that exits successfully, so the legacy dispatch path cannot observe a
|
|
641
|
+
* clean exit (#4157). Name the owned-capture route instead of a misleading contract error. */
|
|
642
|
+
export function unobservedSystemdExit(invocation, outcome) {
|
|
643
|
+
if (invocation?.isolation !== 'systemd-unit' || outcome?.termination !== 'confirmed' || outcome.exitCode !== null
|
|
644
|
+
|| outcome.timedOut || outcome.stopped || outcome.neverExecuted) return null;
|
|
645
|
+
return { code: 'OG_WORKER_EXIT_UNOBSERVED',
|
|
646
|
+
message: 'The systemd worker unit ended but its exit status could not be observed (systemd collects units that exit successfully); its result is unknown and the worker tree is retained.',
|
|
647
|
+
remedy: 'Pass run_dir to worker-invoke so the launcher owns capture and records the exit status and final output.' };
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
export function servedWorkerInputsContext(servedRoot) {
|
|
651
|
+
return { cwd: servedRoot, args: [], rawArgs: [], frameworkRoot: findOwnPackageRoot() };
|
|
617
652
|
}
|
|
618
653
|
|
|
619
654
|
/** #2892 D1: the registry's default `maxActive` respects the project's own
|
|
@@ -666,7 +701,7 @@ async function loadWorkerContextModule() {
|
|
|
666
701
|
* provider's bootstrap is missing; an unmappable CLI refuses with the
|
|
667
702
|
* typed diagnostic, since no deploy could target it. */
|
|
668
703
|
async function ensureWorkerContextForInvocation({ invocation, config }) {
|
|
669
|
-
const { ensureWorkerContextBootstrap, mapCliToProviderId,
|
|
704
|
+
const { ensureWorkerContextBootstrap, mapCliToProviderId, WorkerContextBootstrapError } =
|
|
670
705
|
await loadWorkerContextModule();
|
|
671
706
|
const cli = invocation?.selected?.cli;
|
|
672
707
|
const mapped = mapCliToProviderId(cli, config?.parallelism);
|
|
@@ -677,13 +712,7 @@ async function ensureWorkerContextForInvocation({ invocation, config }) {
|
|
|
677
712
|
{ workdir: invocation?.cwd },
|
|
678
713
|
);
|
|
679
714
|
}
|
|
680
|
-
|
|
681
|
-
try {
|
|
682
|
-
providers = [...new Set([...resolveWorkerContextProvidersFromConfig(config).providers, mapped.provider])];
|
|
683
|
-
} catch {
|
|
684
|
-
providers = [mapped.provider];
|
|
685
|
-
}
|
|
686
|
-
return ensureWorkerContextBootstrap({ workdir: invocation?.cwd, provider: mapped.provider, providers });
|
|
715
|
+
return ensureWorkerContextBootstrap({ workdir: invocation?.cwd, provider: mapped.provider, providers: [mapped.provider], projectLocal: true });
|
|
687
716
|
}
|
|
688
717
|
|
|
689
718
|
/** Refuse a failed bootstrap ensure as a typed blocked diagnostic that
|
|
@@ -733,7 +762,7 @@ async function defaultLaunchShellWorkerBaseline(invocation, { memoryMaxGb = DEFA
|
|
|
733
762
|
return launchIsolatedWorker({
|
|
734
763
|
command: invocation?.argv?.[0], args: invocation?.argv?.slice(1) ?? [], cwd,
|
|
735
764
|
stdoutPath: invocation?.stdoutPath, stderrPath: invocation?.stderrPath, envNames: invocation?.envNames,
|
|
736
|
-
...launchOptions, gate,
|
|
765
|
+
...launchOptions, workerGroup: invocation?.selected?.group, gate,
|
|
737
766
|
});
|
|
738
767
|
},
|
|
739
768
|
};
|
|
@@ -1595,6 +1624,7 @@ async function defaultCallMcpWorker(mcpBinding, server, options = {}) {
|
|
|
1595
1624
|
function publicStatus(entry, healthHook) {
|
|
1596
1625
|
const base = {
|
|
1597
1626
|
invocationId: entry.invocationId,
|
|
1627
|
+
run_dir: entry.run_dir ?? null,
|
|
1598
1628
|
requestId: entry.requestId,
|
|
1599
1629
|
status: entry.status ?? (entry.terminalAt === null ? 'running' : 'uncertain'),
|
|
1600
1630
|
termination: entry.termination ?? 'running',
|
|
@@ -1625,6 +1655,7 @@ const inputSchema = z.strictObject({
|
|
|
1625
1655
|
// authorized reconciliation operation on this SAME handler (never a
|
|
1626
1656
|
// mailbox file, never a new breaker) — see `reconcileStopped` below.
|
|
1627
1657
|
operation: z.enum(['run', 'status', 'cancel', 'reconcile_stopped', 'reset_recovery_scope']),
|
|
1658
|
+
run_dir: z.string().startsWith('/').max(4096).refine(value => !value.includes('\0')).optional(),
|
|
1628
1659
|
invocation_id: invocationUuid().optional(),
|
|
1629
1660
|
scope_id: z.string().min(1).max(512).optional(),
|
|
1630
1661
|
request_id: z.string().min(1).max(128).regex(/^[a-zA-Z0-9_.:-]+$/).optional(),
|
|
@@ -1661,6 +1692,10 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
|
|
|
1661
1692
|
return;
|
|
1662
1693
|
}
|
|
1663
1694
|
const servedRootReal = await resolveServedProjectRoot(options.projectRoot);
|
|
1695
|
+
registerWorkerVerifyDeliverTool(server, { projectRoot: servedRootReal,
|
|
1696
|
+
assertPath: candidate => assertServedPath(servedRootReal, candidate),
|
|
1697
|
+
verify: async input => (await loadRalphExternal('lib/worker-verification-cli.mjs')).verifyWorkerRun(input),
|
|
1698
|
+
});
|
|
1664
1699
|
await sweepWorkerStdin(options.stdinRuntimeRoot);
|
|
1665
1700
|
// Pinned once, here, at registration — never re-resolved per request, and
|
|
1666
1701
|
// never re-derived from `process.cwd()` (#2892 B1).
|
|
@@ -1673,7 +1708,10 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
|
|
|
1673
1708
|
const ttlMs = options.ttlMs ?? resolveServerTerminalTtlMs();
|
|
1674
1709
|
const registry = options.registry ?? createInvocationRegistry({ now: options.now, maxActive, ttlMs });
|
|
1675
1710
|
const loadWorkerInputsImpl = options.loadWorkerInputs ?? defaultLoadWorkerInputs;
|
|
1676
|
-
const
|
|
1711
|
+
const recordedShell = recordedShellLauncher({ loadRalphExternal, loadInputs: () => loadWorkerInputsImpl(servedRootReal),
|
|
1712
|
+
assertPath: candidate => assertServedPath(servedRootReal, candidate), registry, now: options.now ?? (() => new Date()) });
|
|
1713
|
+
const launchShellWorkerImpl = options.launchShellWorker ?? ((invocation, context) => recordedShell.requested(invocation)
|
|
1714
|
+
? recordedShell.launch(invocation, context) : defaultLaunchShellWorker(invocation, context));
|
|
1677
1715
|
const callMcpWorkerImpl = options.callMcpWorker ?? defaultCallMcpWorker;
|
|
1678
1716
|
// Both continuations use the audited observer and hardened stop controls.
|
|
1679
1717
|
const waitForUnitTerminationOverride = options.waitForUnitTermination;
|
|
@@ -1810,17 +1848,13 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
|
|
|
1810
1848
|
const root = await servedRoot();
|
|
1811
1849
|
const { snapshot, drivers } = await loadWorkerInputsImpl(root);
|
|
1812
1850
|
const { resolveWorkerInvocation } = await loadServeWorkerInvocation();
|
|
1813
|
-
|
|
1851
|
+
let plan = await resolveWorkerInvocation(snapshot, request, drivers, now().toISOString());
|
|
1852
|
+
plan = await recordedShell.bindPlan(plan, { resolve: resolveWorkerInvocation, snapshot, drivers, at: now().toISOString(), invocationId: entry.invocationId, input });
|
|
1814
1853
|
if (plan.invocation?.readiness !== 'launchable') {
|
|
1815
1854
|
return markTerminal({ status: 'blocked', termination: 'confirmed', diagnostics: plan.diagnostics ?? [] });
|
|
1816
1855
|
}
|
|
1817
|
-
if (plan.invocation.isolation === 'native-sandbox') {
|
|
1818
|
-
return markTerminal({ status: 'blocked', termination: 'confirmed', diagnostics: [{
|
|
1819
|
-
code: 'OG_POLICY_RELAXATION', pointer: '/worker/isolation',
|
|
1820
|
-
message: 'MCP worker-invoke run does not support pinned native-sandbox isolation',
|
|
1821
|
-
}] });
|
|
1822
|
-
}
|
|
1823
1856
|
prefix = { root, snapshot, drivers, invocation: plan.invocation };
|
|
1857
|
+
recordedShell.prepare(plan.invocation, { plan, input, invocationId: entry.invocationId, releaseOutput: cleanupReservation });
|
|
1824
1858
|
} catch (error) {
|
|
1825
1859
|
return markTerminal({ status: 'blocked', termination: 'confirmed', diagnostics: [error.message] });
|
|
1826
1860
|
}
|
|
@@ -1844,6 +1878,11 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
|
|
|
1844
1878
|
}
|
|
1845
1879
|
}
|
|
1846
1880
|
|
|
1881
|
+
try {
|
|
1882
|
+
const diagnostic = await workerLocalOnlyPreflight({ root, snapshot, invocation, drivers });
|
|
1883
|
+
if (diagnostic) return markTerminal({ status: 'blocked', termination: 'confirmed', diagnostics: [diagnostic] });
|
|
1884
|
+
} catch (error) { return markTerminal({ status: 'blocked', termination: 'confirmed', diagnostics: [error.message] }); }
|
|
1885
|
+
|
|
1847
1886
|
// =========================================================================
|
|
1848
1887
|
// #2915 round 8 (D6): ONE decision, immediately after the prefix, from
|
|
1849
1888
|
// the launcher's own pure eligibility predicate,
|
|
@@ -2020,7 +2059,7 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
|
|
|
2020
2059
|
// M2: a live stop handle for the duration of this call, so an
|
|
2021
2060
|
// explicit `cancel` can actually stop the isolated unit / kill the
|
|
2022
2061
|
// child, not just record that cancellation was requested.
|
|
2023
|
-
const control = buildShellStopControl(launch, {
|
|
2062
|
+
const control = launch.control ?? buildShellStopControl(launch, {
|
|
2024
2063
|
waitForUnit: (waitForUnitTerminationOverride ?? waitForUnitTerminationBaseline),
|
|
2025
2064
|
stopUnit: options.stopWorkerUnit,
|
|
2026
2065
|
killUnit: options.killWorkerUnit,
|
|
@@ -2062,6 +2101,8 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
|
|
|
2062
2101
|
status: registry.get(entry.invocationId)?.cancelRequested ? 'cancelled' : 'failed',
|
|
2063
2102
|
diagnostics: [outcome.timedOut ? 'worker deadline exceeded; termination confirmed' : 'worker stopped; termination confirmed'] });
|
|
2064
2103
|
}
|
|
2104
|
+
const unobserved1 = unobservedSystemdExit(invocation, outcome);
|
|
2105
|
+
if (unobserved1) return registry.markTerminal(entry.invocationId, { status: 'failed', termination: 'confirmed', diagnostics: [unobserved1] });
|
|
2065
2106
|
try { rawOutput = await readBoundedFile(invocation.finalPath, invocation.maxOutputBytes, root); } catch {
|
|
2066
2107
|
return registry.markTerminal(entry.invocationId, { status: 'failed', termination: 'confirmed', diagnostics: ['worker final output was not written'] });
|
|
2067
2108
|
}
|
|
@@ -2114,7 +2155,7 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
|
|
|
2114
2155
|
let claims;
|
|
2115
2156
|
try {
|
|
2116
2157
|
claims = await new (class extends ProviderAdapter {})().parseWorkerFinal(rawOutput, {
|
|
2117
|
-
format: invocation.transport === 'shell' ?
|
|
2158
|
+
format: invocation.transport === 'shell' ? shellFinalFormat(rawOutput) : 'mcp', observation, maxOutputBytes: invocation.maxOutputBytes,
|
|
2118
2159
|
});
|
|
2119
2160
|
} catch (error) {
|
|
2120
2161
|
// M5: bounded, fixed-vocabulary diagnostic only — never the raw
|
|
@@ -2405,7 +2446,7 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
|
|
|
2405
2446
|
// "remaining from right now" so time already spent launching is
|
|
2406
2447
|
// never double-counted.
|
|
2407
2448
|
let deadlineMs = Math.max(0, deadlineAtMs - deadlineClockNow());
|
|
2408
|
-
const control = buildShellStopControl(launch, {
|
|
2449
|
+
const control = launch.control ?? buildShellStopControl(launch, {
|
|
2409
2450
|
waitForUnit: (unit, budgetMs, observerOptions) => (waitForUnitTerminationOverride ?? waitForUnitTermination)(unit,
|
|
2410
2451
|
budgetMs, { ...observerOptions, clock: deadlineClockNow }),
|
|
2411
2452
|
nowMs: deadlineClockNow,
|
|
@@ -2501,6 +2542,11 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
|
|
|
2501
2542
|
status: registry.get(entry.invocationId)?.cancelRequested ? 'cancelled' : 'failed',
|
|
2502
2543
|
diagnostics: [outcome.timedOut ? 'worker deadline exceeded; termination confirmed' : 'worker stopped; termination confirmed'] });
|
|
2503
2544
|
}
|
|
2545
|
+
const unobserved2 = unobservedSystemdExit(invocation, outcome);
|
|
2546
|
+
if (unobserved2) {
|
|
2547
|
+
settleRecovery({ kind: 'failed', confirmedStop });
|
|
2548
|
+
return registry.markTerminal(entry.invocationId, { status: 'failed', termination: 'confirmed', diagnostics: [unobserved2] });
|
|
2549
|
+
}
|
|
2504
2550
|
try { rawOutput = await readBoundedFile(invocation.finalPath, invocation.maxOutputBytes, root); } catch {
|
|
2505
2551
|
// #2915 review 5 (finding 1a): a confirmed clean exit that never
|
|
2506
2552
|
// produced a readable final output is not a success -- settle
|
|
@@ -2671,7 +2717,7 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
|
|
|
2671
2717
|
let claims;
|
|
2672
2718
|
try {
|
|
2673
2719
|
claims = await new (class extends ProviderAdapter {})().parseWorkerFinal(rawOutput, {
|
|
2674
|
-
format: invocation.transport === 'shell' ?
|
|
2720
|
+
format: invocation.transport === 'shell' ? shellFinalFormat(rawOutput) : 'mcp', observation, maxOutputBytes: invocation.maxOutputBytes,
|
|
2675
2721
|
});
|
|
2676
2722
|
} catch (error) {
|
|
2677
2723
|
// #2915 review 5 (finding 1a): the strict parse itself rejected the
|