afyx-engineering-kit 0.0.0-stage → 0.1.0-alpha.4
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/.afyx-source-revision +1 -0
- package/LICENSE +21 -0
- package/README.md +377 -2
- package/SECURITY.md +74 -0
- package/afyx-context/LICENSE +21 -0
- package/afyx-context/README.md +155 -0
- package/afyx-context/afyx-context.json +30 -0
- package/afyx-context/contracts/integration-v1.schema.json +34 -0
- package/afyx-context/package-lock.json +53 -0
- package/afyx-context/package.json +34 -0
- package/afyx-context/scripts/benchmark.mjs +39 -0
- package/afyx-context/scripts/build.mjs +15 -0
- package/afyx-context/scripts/comparative-benchmark.mjs +342 -0
- package/afyx-context/scripts/comparative-worker.mjs +74 -0
- package/afyx-context/scripts/graph-integration-e2e.mjs +188 -0
- package/afyx-context/scripts/integrated-dogfood.mjs +309 -0
- package/afyx-context/src/budget.js +166 -0
- package/afyx-context/src/cli.js +110 -0
- package/afyx-context/src/coordination.js +343 -0
- package/afyx-context/src/engine.js +198 -0
- package/afyx-context/src/errors.js +14 -0
- package/afyx-context/src/graph-integration-worker.js +70 -0
- package/afyx-context/src/graph-integration.js +373 -0
- package/afyx-context/src/graph-mcp-bridge.js +103 -0
- package/afyx-context/src/index.js +25 -0
- package/afyx-context/src/integrations.js +87 -0
- package/afyx-context/src/memory.js +255 -0
- package/afyx-context/src/storage.js +364 -0
- package/afyx-context/test-fixtures/coordination-worker.mjs +52 -0
- package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/__init__.py +1 -0
- package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/__manifest__.py +4 -0
- package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/models/__init__.py +1 -0
- package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/models/sale_order.py +5 -0
- package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/__init__.py +1 -0
- package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/__manifest__.py +10 -0
- package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/models/__init__.py +2 -0
- package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/models/sale_order.py +20 -0
- package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/models/sale_order_audit.py +11 -0
- package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/security/ir.model.access.csv +2 -0
- package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/views/sale_order_views.xml +14 -0
- package/afyx-forge/LICENSE +55 -0
- package/afyx-forge/README.md +126 -0
- package/afyx-forge/afyx-forge.json +28 -0
- package/afyx-forge/bin/afyx-forge +4 -0
- package/afyx-forge/bin/afyx-forge.cmd +3 -0
- package/afyx-forge/bin/afyx-forge.js +16 -0
- package/afyx-forge/contracts/forge-plan-v1.schema.json +172 -0
- package/afyx-forge/package.json +26 -0
- package/afyx-forge/src/classifier.js +190 -0
- package/afyx-forge/src/cli.js +111 -0
- package/afyx-forge/src/doctor.js +105 -0
- package/afyx-forge/src/guidance.js +120 -0
- package/afyx-forge/src/index.js +273 -0
- package/afyx-forge/src/planning.js +107 -0
- package/afyx-forge/src/policy.js +109 -0
- package/afyx-forge/src/workflow-refiner.js +151 -0
- package/afyx-graph/afyx-graph.json +20 -0
- package/afyx-graph/engine/LICENSE +21 -0
- package/afyx-graph/engine/README.md +104 -0
- package/afyx-graph/engine/release/RELEASE-MANIFEST.json +21 -0
- package/afyx-graph/engine/release/SHA256SUMS +2 -0
- package/afyx-graph/engine/release/afyx-graph-linux-x64.tar.gz +0 -0
- package/afyx-graph/engine/release/afyx-graph-win32-x64.zip +0 -0
- package/afyx-graph/engine/scripts/distribution-contract.mjs +212 -0
- package/afyx-graph/engine/scripts/distribution-product.json +33 -0
- package/bin/afyx-engineering-kit.mjs +61 -0
- package/install.ps1 +1053 -0
- package/install.sh +617 -0
- package/package.json +66 -4
- package/scripts/afyx-capability-orchestrator.mjs +752 -0
- package/scripts/afyx-claude-integration.mjs +547 -0
- package/scripts/afyx-context-artifact.mjs +105 -0
- package/scripts/afyx-credential-broker.mjs +75 -0
- package/scripts/afyx-doctor.ps1 +152 -0
- package/scripts/afyx-doctor.sh +146 -0
- package/scripts/afyx-forge-artifact.mjs +183 -0
- package/scripts/afyx-global-routing-policy.md +12 -0
- package/scripts/afyx-global-routing.mjs +168 -0
- package/scripts/afyx-graph-artifact.mjs +178 -0
- package/scripts/afyx-host-adapters.mjs +543 -0
- package/scripts/afyx-host-bridge-lifecycle.mjs +174 -0
- package/scripts/afyx-host-bridge.mjs +288 -0
- package/scripts/afyx-integration-contracts.mjs +825 -0
- package/scripts/afyx-mcp-integration.mjs +528 -0
- package/scripts/afyx-modular-integration.mjs +361 -0
- package/scripts/afyx-modular-runtime.mjs +451 -0
- package/scripts/afyx-native-skill-host.mjs +124 -0
- package/scripts/afyx-npm-installer.mjs +486 -0
- package/scripts/afyx-project.ps1 +205 -0
- package/scripts/afyx-project.sh +207 -0
- package/scripts/afyx-provider-backup.mjs +1206 -0
- package/scripts/afyx-provider-integration.mjs +724 -0
- package/scripts/afyx-provider-inventory.mjs +147 -0
- package/scripts/afyx-security-auditor.mjs +224 -0
- package/scripts/afyx-skill-engineering.mjs +354 -0
- package/scripts/afyx-tool-family-routing.mjs +64 -0
- package/scripts/afyx-universal-runtime.mjs +530 -0
- package/scripts/alpha_acceptance_preflight.py +240 -0
- package/scripts/benchmark-graph-memory.mjs +96 -0
- package/scripts/benchmark_capability_orchestrator.mjs +64 -0
- package/scripts/build-windows-installer.ps1 +259 -0
- package/scripts/build_forge_synthetic_image.py +328 -0
- package/scripts/check-reference-staleness.py +71 -0
- package/scripts/components.json +254 -0
- package/scripts/contracts/afyx-capability-request-v1.schema.json +189 -0
- package/scripts/contracts/afyx-capability-result-v1.schema.json +32 -0
- package/scripts/dogfood_engineering_comparison.mjs +303 -0
- package/scripts/engineering-assurance.json +28 -0
- package/scripts/install-afyx-context.ps1 +142 -0
- package/scripts/install-afyx-context.sh +126 -0
- package/scripts/install-afyx-forge.ps1 +265 -0
- package/scripts/install-afyx-forge.sh +273 -0
- package/scripts/install-afyx-graph.ps1 +571 -0
- package/scripts/install-afyx-graph.sh +438 -0
- package/scripts/install-codex-usage-tracker.ps1 +172 -0
- package/scripts/lib/AfyxComponents.psm1 +399 -0
- package/scripts/lib/AfyxSkillLifecycle.psm1 +289 -0
- package/scripts/lib/AfyxTerminal.psm1 +838 -0
- package/scripts/lib/afyx-components.sh +256 -0
- package/scripts/lib/afyx-skill-lifecycle.sh +271 -0
- package/scripts/link-global-dev.ps1 +193 -0
- package/scripts/link-global-dev.sh +130 -0
- package/scripts/phase8-paired-evidence.mjs +195 -0
- package/scripts/phase8-representative-workload.mjs +771 -0
- package/scripts/phase8-session-recorder.mjs +157 -0
- package/scripts/phase8_event_ledger.py +248 -0
- package/scripts/phase8_evidence_discovery.py +189 -0
- package/scripts/prepare-g6-package.mjs +349 -0
- package/scripts/resolve-git-release-artifacts.mjs +321 -0
- package/scripts/stage-npm-release.mjs +94 -0
- package/scripts/validate-afyx-graph.py +203 -0
- package/scripts/validate-components.py +194 -0
- package/scripts/validate-engineering-assurance.py +281 -0
- package/scripts/verify-graph-archive.mjs +64 -0
- package/skills/afyx-context/SKILL.md +26 -0
- package/skills/afyx-engineering-expert/README.md +42 -0
- package/skills/afyx-engineering-expert/SKILL.md +70 -0
- package/skills/afyx-engineering-expert/assets/result-template.md +15 -0
- package/skills/afyx-engineering-expert/references/ai-ml-engineer.md +17 -0
- package/skills/afyx-engineering-expert/references/business-analyst.md +17 -0
- package/skills/afyx-engineering-expert/references/clean-code-engineer.md +26 -0
- package/skills/afyx-engineering-expert/references/code-reviewer.md +24 -0
- package/skills/afyx-engineering-expert/references/cybersecurity-devsecops.md +17 -0
- package/skills/afyx-engineering-expert/references/data-analyst-bi.md +24 -0
- package/skills/afyx-engineering-expert/references/data-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/database-administrator.md +17 -0
- package/skills/afyx-engineering-expert/references/debugging-specialist.md +24 -0
- package/skills/afyx-engineering-expert/references/embedded-iot-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/erp-technical-specialist.md +17 -0
- package/skills/afyx-engineering-expert/references/hardware-diagnostics-auditor.md +24 -0
- package/skills/afyx-engineering-expert/references/hardware-electronics-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/integration-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/legacy-modernization-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/llmops-prompt-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/network-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/performance-benchmark-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/platform-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/product-manager.md +17 -0
- package/skills/afyx-engineering-expert/references/qa-engineer.md +17 -0
- package/skills/afyx-engineering-expert/references/site-reliability-engineer.md +17 -0
- package/skills/afyx-engineering-expert/references/software-engineer.md +17 -0
- package/skills/afyx-engineering-expert/references/solutions-architect.md +17 -0
- package/skills/afyx-engineering-expert/references/specialists-index.md +33 -0
- package/skills/afyx-engineering-expert/references/subject-matter-expert.md +17 -0
- package/skills/afyx-engineering-expert/references/system-analyst.md +17 -0
- package/skills/afyx-engineering-expert/references/technical-project-manager.md +24 -0
- package/skills/afyx-engineering-expert/references/technical-writer.md +24 -0
- package/skills/afyx-engineering-expert/references/ui-ux-designer.md +17 -0
- package/skills/afyx-engineering-expert/workflows/ai-data-erp.md +20 -0
- package/skills/afyx-engineering-expert/workflows/debugging.md +10 -0
- package/skills/afyx-engineering-expert/workflows/discovery-design.md +11 -0
- package/skills/afyx-engineering-expert/workflows/implementation.md +12 -0
- package/skills/afyx-engineering-expert/workflows/incident-reliability.md +12 -0
- package/skills/afyx-engineering-expert/workflows/review-audit.md +13 -0
- package/skills/afyx-forge/SKILL.md +43 -0
- package/skills/afyx-forge/references/adaptive-policy.md +19 -0
- package/skills/efficient-coding/SKILL.md +33 -0
- package/skills/efficient-coding/references/investigation.md +27 -0
- package/skills/efficient-coding/references/token-efficiency.md +25 -0
- package/skills/efficient-coding/references/tool-routing.md +13 -0
- package/skills/odoo-engineering/SKILL.md +33 -0
- package/skills/odoo-engineering/references/common.md +9 -0
- package/skills/odoo-engineering/references/odoo-10.md +32 -0
- package/skills/odoo-engineering/references/odoo-11.md +26 -0
- package/skills/odoo-engineering/references/odoo-12.md +31 -0
- package/skills/odoo-engineering/references/odoo-13.md +27 -0
- package/skills/odoo-engineering/references/odoo-14.md +31 -0
- package/skills/odoo-engineering/references/odoo-15.md +34 -0
- package/skills/odoo-engineering/references/odoo-16.md +37 -0
- package/skills/odoo-engineering/references/odoo-17.md +37 -0
- package/skills/odoo-engineering/references/odoo-18.md +48 -0
- package/skills/odoo-engineering/references/odoo-19.md +43 -0
- package/skills/odoo-engineering/references/odoo-20.md +39 -0
- package/skills/odoo-engineering/references/reference-schema.md +16 -0
- package/skills/odoo-engineering/references/version-detection.md +13 -0
- package/tools/codex-usage/CodexUsage.psm1 +496 -0
- package/tools/codex-usage/codex-usage-doctor.ps1 +150 -0
- package/tools/codex-usage/codex-usage-pricing.json +25 -0
- package/tools/codex-usage/codex-usage-stop.ps1 +167 -0
- package/tools/codex-usage/codex-usage-watch.ps1 +250 -0
- package/tools/codex-usage/vscode-user-task.json +31 -0
- package/tools/windows-setup/SetupBootstrapper.cs +258 -0
- package/uninstall.ps1 +189 -0
- package/uninstall.sh +167 -0
- package/update.ps1 +95 -0
- package/update.sh +67 -0
- package/verify.ps1 +411 -0
- package/verify.sh +265 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
/** AFYX-owned skill lifecycle. No provider profile is selected implicitly. */
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import {
|
|
4
|
+
existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync,
|
|
5
|
+
rmSync, writeFileSync,
|
|
6
|
+
} from 'node:fs';
|
|
7
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
8
|
+
|
|
9
|
+
export const SKILL_ENGINEERING_CONTRACT = 'AfyxSkillEngineering/v1';
|
|
10
|
+
const PROVIDER_DEFS = new Map(JSON.parse(readFileSync(new URL('./components.json', import.meta.url), 'utf8'))
|
|
11
|
+
.providers.map((provider) => [provider.provider, provider]));
|
|
12
|
+
const PROVIDERS = new Set(PROVIDER_DEFS.keys());
|
|
13
|
+
const MAX_FILE_BYTES = 2 * 1024 * 1024;
|
|
14
|
+
const MAX_PACKAGE_BYTES = 8 * 1024 * 1024;
|
|
15
|
+
const MAX_FILES = 1000;
|
|
16
|
+
const SHA256 = (data) => createHash('sha256').update(data).digest('hex');
|
|
17
|
+
|
|
18
|
+
function fail(code) { throw new Error(code); }
|
|
19
|
+
function itemAt(path) {
|
|
20
|
+
try { return lstatSync(path); }
|
|
21
|
+
catch (error) { if (error?.code === 'ENOENT') return null; throw error; }
|
|
22
|
+
}
|
|
23
|
+
function inside(root, target) {
|
|
24
|
+
const rel = relative(resolve(root), resolve(target));
|
|
25
|
+
return rel === '' || (rel !== '..' && !rel.startsWith(`..${sep}`) && !isAbsolute(rel));
|
|
26
|
+
}
|
|
27
|
+
function ordinary(path, directory) {
|
|
28
|
+
const item = lstatSync(path);
|
|
29
|
+
if (item.isSymbolicLink() || (item.isDirectory() !== directory)) fail('UNSAFE_FILE_TYPE');
|
|
30
|
+
return item;
|
|
31
|
+
}
|
|
32
|
+
function safeRoot(root) {
|
|
33
|
+
const absolute = resolve(root);
|
|
34
|
+
let cursor = absolute;
|
|
35
|
+
for (;;) {
|
|
36
|
+
if (itemAt(cursor)) ordinary(cursor, true);
|
|
37
|
+
const parent = dirname(cursor);
|
|
38
|
+
if (parent === cursor) break;
|
|
39
|
+
cursor = parent;
|
|
40
|
+
}
|
|
41
|
+
return absolute;
|
|
42
|
+
}
|
|
43
|
+
function safePart(path, root) {
|
|
44
|
+
if (!inside(root, path)) fail('PATH_OUTSIDE_SCOPE');
|
|
45
|
+
let cursor = resolve(root);
|
|
46
|
+
for (const part of relative(cursor, resolve(path)).split(sep).filter(Boolean)) {
|
|
47
|
+
cursor = join(cursor, part);
|
|
48
|
+
if (itemAt(cursor)) {
|
|
49
|
+
const item = lstatSync(cursor);
|
|
50
|
+
if (item.isSymbolicLink()) fail('REPARSE_POINT_BLOCKED');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function filesOf(source) {
|
|
55
|
+
const root = safeRoot(source);
|
|
56
|
+
ordinary(root, true);
|
|
57
|
+
const files = [];
|
|
58
|
+
let bytes = 0;
|
|
59
|
+
function visit(directory) {
|
|
60
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
61
|
+
if (entry.name === '.afyx-skill-ownership.json') continue;
|
|
62
|
+
const path = join(directory, entry.name);
|
|
63
|
+
if (entry.isSymbolicLink()) fail('REPARSE_POINT_BLOCKED');
|
|
64
|
+
if (entry.isDirectory()) { ordinary(path, true); visit(path); continue; }
|
|
65
|
+
if (!entry.isFile()) fail('UNSAFE_FILE_TYPE');
|
|
66
|
+
if (files.length >= MAX_FILES) fail('PACKAGE_TOO_MANY_FILES');
|
|
67
|
+
const size = ordinary(path, false).size;
|
|
68
|
+
if (size > MAX_FILE_BYTES || (bytes += size) > MAX_PACKAGE_BYTES) fail('PACKAGE_TOO_LARGE');
|
|
69
|
+
files.push({ path: relative(root, path).split(sep).join('/'), bytes: readFileSync(path) });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
visit(root);
|
|
73
|
+
return files.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
74
|
+
}
|
|
75
|
+
function metadataOf(content) {
|
|
76
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(content);
|
|
77
|
+
if (!match) fail('FRONTMATTER_REQUIRED');
|
|
78
|
+
const fields = new Map();
|
|
79
|
+
for (const line of match[1].split(/\r?\n/)) {
|
|
80
|
+
if (!line.trim() || line.trimStart().startsWith('#')) continue;
|
|
81
|
+
const item = /^([a-z][a-z0-9-]*):\s*(.*?)\s*$/.exec(line);
|
|
82
|
+
if (!item) fail('FRONTMATTER_UNSUPPORTED');
|
|
83
|
+
if (fields.has(item[1])) fail('DUPLICATE_METADATA');
|
|
84
|
+
fields.set(item[1], item[2].replace(/^['"]|['"]$/g, ''));
|
|
85
|
+
}
|
|
86
|
+
const name = fields.get('name');
|
|
87
|
+
const description = fields.get('description');
|
|
88
|
+
if (!name || !/^[a-z][a-z0-9-]{1,63}$/.test(name)) fail('INVALID_SKILL_NAME');
|
|
89
|
+
if (!description || description.length > 1000) fail('INVALID_DESCRIPTION');
|
|
90
|
+
let extension = {};
|
|
91
|
+
try { extension = fields.has('metadata') ? JSON.parse(fields.get('metadata')) : {}; }
|
|
92
|
+
catch { fail('INVALID_METADATA'); }
|
|
93
|
+
const rawTriggers = extension?.afyx?.triggers ?? [];
|
|
94
|
+
if (!Array.isArray(rawTriggers) || rawTriggers.some((x) => typeof x !== 'string')) fail('INVALID_TRIGGERS');
|
|
95
|
+
const triggers = rawTriggers.map((x) => x.trim().toLowerCase());
|
|
96
|
+
if (triggers.some((x) => !/^[a-z][a-z0-9 -]{1,79}$/.test(x) || !description.toLowerCase().includes(x))
|
|
97
|
+
|| new Set(triggers).size !== triggers.length) fail('INVALID_TRIGGERS');
|
|
98
|
+
return { name, description, triggers };
|
|
99
|
+
}
|
|
100
|
+
function checkedReferences(content, paths, sourcePath = 'SKILL.md') {
|
|
101
|
+
const candidates = [
|
|
102
|
+
...[...content.matchAll(/\]\(([^)]+)\)/g)].map((match) => match[1]),
|
|
103
|
+
...(sourcePath === 'SKILL.md' ? [...content.matchAll(/`((?:references|scripts|assets)\/[^`]+)`/g)].map((match) => match[1]) : []),
|
|
104
|
+
];
|
|
105
|
+
const prefix = sourcePath.split('/').slice(0, -1).join('/');
|
|
106
|
+
for (const candidate of candidates) {
|
|
107
|
+
const target = candidate.split(/[?#]/, 1)[0];
|
|
108
|
+
if (!target || /^(?:https?:|mailto:)/i.test(target)) continue;
|
|
109
|
+
const normalized = target.replace(/^\.\//, '');
|
|
110
|
+
const local = prefix ? `${prefix}/${normalized}` : normalized;
|
|
111
|
+
if (target.includes('%') || target.includes('\\') || target.startsWith('/') || target.split('/').includes('..') || !paths.has(local)) fail('INVALID_RESOURCE_REFERENCE');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function validateSkill(source, { peerRoots = [], allowDirectoryMismatch = false } = {}) {
|
|
116
|
+
const files = filesOf(source);
|
|
117
|
+
const manifest = files.find((file) => file.path === 'SKILL.md');
|
|
118
|
+
if (!manifest) fail('SKILL_MANIFEST_MISSING');
|
|
119
|
+
const metadata = metadataOf(manifest.bytes.toString('utf8'));
|
|
120
|
+
if (!allowDirectoryMismatch && basename(resolve(source)) !== metadata.name) fail('SKILL_DIRECTORY_NAME_MISMATCH');
|
|
121
|
+
const paths = new Set(files.map((file) => file.path));
|
|
122
|
+
for (const file of files.filter((item) => item.path.endsWith('.md'))) {
|
|
123
|
+
checkedReferences(file.bytes.toString('utf8'), paths, file.path);
|
|
124
|
+
}
|
|
125
|
+
for (const peerRoot of peerRoots) {
|
|
126
|
+
if (!itemAt(peerRoot)) continue;
|
|
127
|
+
const peer = filesOf(peerRoot).find((file) => file.path === 'SKILL.md');
|
|
128
|
+
if (!peer) continue;
|
|
129
|
+
const other = metadataOf(peer.bytes.toString('utf8'));
|
|
130
|
+
if (other.name === metadata.name || other.triggers.some((trigger) => metadata.triggers.includes(trigger))) fail('SKILL_OR_TRIGGER_CONFLICT');
|
|
131
|
+
}
|
|
132
|
+
const inventory = files.map(({ path, bytes }) => ({ path, sha256: SHA256(bytes), size: bytes.length }));
|
|
133
|
+
const digest = SHA256(Buffer.from(JSON.stringify(inventory)));
|
|
134
|
+
return Object.freeze({ contract: SKILL_ENGINEERING_CONTRACT, ...metadata, digest, inventory });
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function createSkill(directory, { name, description, triggers = [], body = '' }) {
|
|
138
|
+
if (itemAt(directory)) fail('TARGET_ALREADY_EXISTS');
|
|
139
|
+
if (basename(resolve(directory)) !== name) fail('SKILL_DIRECTORY_NAME_MISMATCH');
|
|
140
|
+
safeRoot(dirname(directory));
|
|
141
|
+
const text = `---\nname: ${name}\ndescription: ${description}\nmetadata: ${JSON.stringify({ afyx: { triggers } })}\n---\n\n${body}\n`;
|
|
142
|
+
// Validate all caller-supplied fields before the first write.
|
|
143
|
+
const parsed = metadataOf(text);
|
|
144
|
+
if (parsed.name !== name || parsed.description !== description
|
|
145
|
+
|| JSON.stringify(parsed.triggers) !== JSON.stringify(triggers)) fail('SKILL_METADATA_INVALID');
|
|
146
|
+
checkedReferences(text, new Set(['SKILL.md']));
|
|
147
|
+
mkdirSync(directory);
|
|
148
|
+
writeFileSync(join(directory, 'SKILL.md'), text, { flag: 'wx' });
|
|
149
|
+
return validateSkill(directory);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Revision/repair is a host-approved source edit with exact-byte restoration on failure. */
|
|
153
|
+
export function reviseSkill(source, { description, triggers = [], body }, { authorize } = {}) {
|
|
154
|
+
const root = safeRoot(source);
|
|
155
|
+
ordinary(root, true);
|
|
156
|
+
const manifest = join(root, 'SKILL.md');
|
|
157
|
+
ordinary(manifest, false);
|
|
158
|
+
const original = readFileSync(manifest);
|
|
159
|
+
const oldText = original.toString('utf8');
|
|
160
|
+
const existingBody = oldText.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n/, '');
|
|
161
|
+
const draft = `---\nname: ${basename(root)}\ndescription: ${description}\nmetadata: ${JSON.stringify({ afyx: { triggers } })}\n---\n\n${body ?? existingBody}`;
|
|
162
|
+
const parsed = metadataOf(draft);
|
|
163
|
+
if (parsed.name !== basename(root) || parsed.description !== description
|
|
164
|
+
|| JSON.stringify(parsed.triggers) !== JSON.stringify(triggers)) fail('REVISION_METADATA_INVALID');
|
|
165
|
+
checkedReferences(draft, new Set(filesOf(root).map((file) => file.path)));
|
|
166
|
+
const proposal = Object.freeze({ contract: SKILL_ENGINEERING_CONTRACT, name: parsed.name, action: 'REVISE', beforeSha256: SHA256(original), afterSha256: SHA256(Buffer.from(draft)) });
|
|
167
|
+
if (typeof authorize !== 'function' || authorize(proposal) !== true) fail('HOST_APPROVAL_REQUIRED');
|
|
168
|
+
if (SHA256(readFileSync(manifest)) !== proposal.beforeSha256) fail('PREVIEW_STALE');
|
|
169
|
+
try {
|
|
170
|
+
writeFileSync(manifest, draft);
|
|
171
|
+
return validateSkill(root);
|
|
172
|
+
} catch (error) {
|
|
173
|
+
writeFileSync(manifest, original);
|
|
174
|
+
throw error;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function packageSkill(source) {
|
|
179
|
+
const report = validateSkill(source);
|
|
180
|
+
const files = filesOf(source).map(({ path, bytes }) => ({ path, data: bytes.toString('base64') }));
|
|
181
|
+
const payload = { contract: SKILL_ENGINEERING_CONTRACT, metadata: report, files };
|
|
182
|
+
return Buffer.from(`${JSON.stringify(payload)}\n`);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export function inspectSkillPackage(packageBytes) {
|
|
186
|
+
if (!Buffer.isBuffer(packageBytes) || packageBytes.length > MAX_PACKAGE_BYTES * 2) fail('PACKAGE_INVALID');
|
|
187
|
+
const payload = JSON.parse(packageBytes.toString('utf8'));
|
|
188
|
+
if (payload.contract !== SKILL_ENGINEERING_CONTRACT || !Array.isArray(payload.files)) fail('PACKAGE_INVALID');
|
|
189
|
+
const names = new Set();
|
|
190
|
+
const inventory = payload.files.map((file) => {
|
|
191
|
+
if (typeof file.path !== 'string' || !/^[A-Za-z0-9._/-]+$/.test(file.path) || file.path.startsWith('/') || file.path === '.afyx-skill-ownership.json' || file.path.split('/').some((part) => part === '..' || part === '.' || !part) || names.has(file.path)) fail('PACKAGE_PATH_INVALID');
|
|
192
|
+
names.add(file.path);
|
|
193
|
+
const bytes = Buffer.from(file.data, 'base64');
|
|
194
|
+
if (bytes.toString('base64') !== file.data || bytes.length > MAX_FILE_BYTES) fail('PACKAGE_INVALID');
|
|
195
|
+
return { path: file.path, sha256: SHA256(bytes), size: bytes.length };
|
|
196
|
+
});
|
|
197
|
+
if (inventory.length > MAX_FILES || !names.has('SKILL.md')
|
|
198
|
+
|| SHA256(Buffer.from(JSON.stringify(inventory))) !== payload.metadata?.digest
|
|
199
|
+
|| JSON.stringify(inventory) !== JSON.stringify(payload.metadata?.inventory)) fail('PACKAGE_INTEGRITY_FAILED');
|
|
200
|
+
const manifest = payload.files.find((file) => file.path === 'SKILL.md');
|
|
201
|
+
const parsed = metadataOf(Buffer.from(manifest.data, 'base64').toString('utf8'));
|
|
202
|
+
if (parsed.name !== payload.metadata.name || parsed.description !== payload.metadata.description
|
|
203
|
+
|| JSON.stringify(parsed.triggers) !== JSON.stringify(payload.metadata.triggers)) fail('PACKAGE_METADATA_MISMATCH');
|
|
204
|
+
for (const file of payload.files.filter((item) => item.path.endsWith('.md'))) {
|
|
205
|
+
checkedReferences(Buffer.from(file.data, 'base64').toString('utf8'), names, file.path);
|
|
206
|
+
}
|
|
207
|
+
return payload;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export function negotiateSkillProvider(provider, scope = 'workspace') {
|
|
211
|
+
const supportedScopes = PROVIDER_DEFS.get(provider)?.skill_scopes?.split(';') ?? [];
|
|
212
|
+
return Object.freeze({ contract: SKILL_ENGINEERING_CONTRACT, provider, scope,
|
|
213
|
+
status: supportedScopes.includes(scope) ? 'SUPPORTED' : 'UNSUPPORTED_SCOPE' });
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export function previewSkillInstall(packageBytes, { provider, scope = 'workspace', skillsRoot, peerRoots = [] }) {
|
|
217
|
+
if (!PROVIDERS.has(provider) || negotiateSkillProvider(provider, scope).status !== 'SUPPORTED') fail('PROVIDER_SCOPE_UNSUPPORTED');
|
|
218
|
+
const payload = inspectSkillPackage(packageBytes);
|
|
219
|
+
if (!Array.isArray(peerRoots) || peerRoots.some((peer) => typeof peer !== 'string' || !peer.trim())) fail('PEER_ROOTS_INVALID');
|
|
220
|
+
const scopedPeerRoots = Object.freeze(peerRoots.map((peer) => resolve(peer)));
|
|
221
|
+
const root = safeRoot(skillsRoot);
|
|
222
|
+
ordinary(root, true);
|
|
223
|
+
const target = join(root, payload.metadata.name);
|
|
224
|
+
safePart(target, root);
|
|
225
|
+
const existing = itemAt(target) ? validateSkill(target) : null;
|
|
226
|
+
if (existing) {
|
|
227
|
+
const markerPath = join(target, '.afyx-skill-ownership.json');
|
|
228
|
+
if (!existsSync(markerPath) || !ordinary(markerPath, false)) fail('FOREIGN_SKILL_PROTECTED');
|
|
229
|
+
const marker = JSON.parse(readFileSync(markerPath, 'utf8'));
|
|
230
|
+
if (marker.contract !== SKILL_ENGINEERING_CONTRACT || marker.provider !== provider || marker.digest !== existing.digest) fail('FOREIGN_SKILL_PROTECTED');
|
|
231
|
+
}
|
|
232
|
+
// Inspect neighboring provider skills without following foreign junctions.
|
|
233
|
+
for (const entry of readdirSync(root, { withFileTypes: true })) {
|
|
234
|
+
if (!entry.isDirectory() || entry.isSymbolicLink() || !/^[a-z][a-z0-9-]{1,63}$/.test(entry.name)
|
|
235
|
+
|| entry.name === payload.metadata.name) continue;
|
|
236
|
+
const neighbor = join(root, entry.name, 'SKILL.md');
|
|
237
|
+
const stat = itemAt(neighbor);
|
|
238
|
+
if (!stat || !stat.isFile() || stat.isSymbolicLink()) continue;
|
|
239
|
+
const text = readFileSync(neighbor, 'utf8');
|
|
240
|
+
const metadataLine = /^metadata:\s*(\{.*\})\s*$/m.exec(text)?.[1];
|
|
241
|
+
let triggers = [];
|
|
242
|
+
try { triggers = JSON.parse(metadataLine ?? '{}')?.afyx?.triggers ?? []; } catch { /* foreign metadata */ }
|
|
243
|
+
if (!Array.isArray(triggers)) triggers = [];
|
|
244
|
+
if (triggers.some((trigger) => payload.metadata.triggers.includes(trigger))) fail('SKILL_OR_TRIGGER_CONFLICT');
|
|
245
|
+
}
|
|
246
|
+
for (const peer of scopedPeerRoots) {
|
|
247
|
+
if (!itemAt(peer)) continue;
|
|
248
|
+
const other = validateSkill(peer);
|
|
249
|
+
if (other.name !== payload.metadata.name && other.triggers.some((trigger) => payload.metadata.triggers.includes(trigger))) fail('SKILL_OR_TRIGGER_CONFLICT');
|
|
250
|
+
}
|
|
251
|
+
return Object.freeze({ contract: SKILL_ENGINEERING_CONTRACT, provider, scope, root, target, action: existing ? 'UPDATE' : 'INSTALL', digest: payload.metadata.digest, previousDigest: existing?.digest ?? null,
|
|
252
|
+
peerRoots: scopedPeerRoots });
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export function verifySkillInstall({ provider, skillsRoot, name }) {
|
|
256
|
+
if (!PROVIDERS.has(provider) || !/^[a-z][a-z0-9-]{1,63}$/.test(name)) fail('VERIFY_REQUEST_INVALID');
|
|
257
|
+
const root = safeRoot(skillsRoot);
|
|
258
|
+
ordinary(root, true);
|
|
259
|
+
const target = join(root, name);
|
|
260
|
+
safePart(target, root);
|
|
261
|
+
if (!itemAt(target)) return { contract: SKILL_ENGINEERING_CONTRACT, status: 'NOT_INSTALLED' };
|
|
262
|
+
const report = validateSkill(target);
|
|
263
|
+
const markerPath = join(target, '.afyx-skill-ownership.json');
|
|
264
|
+
if (!existsSync(markerPath)) return { contract: SKILL_ENGINEERING_CONTRACT, status: 'FOREIGN_UNPROVEN' };
|
|
265
|
+
ordinary(markerPath, false);
|
|
266
|
+
const marker = JSON.parse(readFileSync(markerPath, 'utf8'));
|
|
267
|
+
return { contract: SKILL_ENGINEERING_CONTRACT,
|
|
268
|
+
status: marker.contract === SKILL_ENGINEERING_CONTRACT && marker.provider === provider && marker.digest === report.digest ? 'VERIFIED' : 'INTEGRITY_FAILED',
|
|
269
|
+
digest: report.digest };
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export function reconcileSkillInstall({ provider, skillsRoot, name }, { authorize } = {}) {
|
|
273
|
+
if (!PROVIDERS.has(provider) || !/^[a-z][a-z0-9-]{1,63}$/.test(name)) fail('RECOVERY_REQUEST_INVALID');
|
|
274
|
+
const root = safeRoot(skillsRoot);
|
|
275
|
+
ordinary(root, true);
|
|
276
|
+
const target = join(root, name);
|
|
277
|
+
const backup = join(root, `.${name}.afyx-rollback`);
|
|
278
|
+
const stage = join(root, `.${name}.afyx-stage`);
|
|
279
|
+
safePart(target, root); safePart(backup, root); safePart(stage, root);
|
|
280
|
+
const state = Object.freeze({ targetPresent: Boolean(itemAt(target)), backupPresent: Boolean(itemAt(backup)), stagePresent: Boolean(itemAt(stage)) });
|
|
281
|
+
if (state.targetPresent && state.backupPresent) return { status: 'REVIEW_BOTH_VERSIONS', ...state };
|
|
282
|
+
if (!state.backupPresent) return { status: state.stagePresent ? 'REVIEW_STAGE' : 'NO_RECOVERY_NEEDED', ...state };
|
|
283
|
+
const report = validateSkill(backup, { allowDirectoryMismatch: true });
|
|
284
|
+
const backupMarker = join(backup, '.afyx-skill-ownership.json');
|
|
285
|
+
ordinary(backupMarker, false);
|
|
286
|
+
const marker = JSON.parse(readFileSync(backupMarker, 'utf8'));
|
|
287
|
+
if (marker.contract !== SKILL_ENGINEERING_CONTRACT || marker.provider !== provider || marker.digest !== report.digest) fail('OWNERSHIP_DRIFT');
|
|
288
|
+
const proposal = Object.freeze({ provider, target, backup, digest: report.digest, action: 'RESTORE_INTERRUPTED_INSTALL' });
|
|
289
|
+
if (typeof authorize !== 'function' || authorize(proposal) !== true) return { status: 'HOST_APPROVAL_REQUIRED', ...state };
|
|
290
|
+
if (itemAt(target) || !itemAt(backup)) fail('RECOVERY_STATE_CHANGED');
|
|
291
|
+
renameSync(backup, target);
|
|
292
|
+
return { status: 'RESTORED_PREVIOUS', target, digest: report.digest, stagePreserved: state.stagePresent };
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export function applySkillInstall(packageBytes, preview, { authorize } = {}) {
|
|
296
|
+
if (typeof authorize !== 'function' || authorize(preview) !== true) fail('HOST_APPROVAL_REQUIRED');
|
|
297
|
+
const current = previewSkillInstall(packageBytes, {
|
|
298
|
+
provider: preview.provider, scope: preview.scope, skillsRoot: preview.root,
|
|
299
|
+
peerRoots: preview.peerRoots,
|
|
300
|
+
});
|
|
301
|
+
if (JSON.stringify(current) !== JSON.stringify(preview)) fail('PREVIEW_STALE');
|
|
302
|
+
const payload = inspectSkillPackage(packageBytes);
|
|
303
|
+
const root = preview.root;
|
|
304
|
+
const target = preview.target;
|
|
305
|
+
const stage = join(root, `.${payload.metadata.name}.afyx-stage`);
|
|
306
|
+
const backup = join(root, `.${payload.metadata.name}.afyx-rollback`);
|
|
307
|
+
if (itemAt(stage) || itemAt(backup)) fail('TRANSACTION_RECONCILIATION_REQUIRED');
|
|
308
|
+
mkdirSync(stage);
|
|
309
|
+
let movedOld = false;
|
|
310
|
+
try {
|
|
311
|
+
for (const file of payload.files) {
|
|
312
|
+
const destination = join(stage, ...file.path.split('/'));
|
|
313
|
+
safePart(destination, stage);
|
|
314
|
+
mkdirSync(dirname(destination), { recursive: true });
|
|
315
|
+
writeFileSync(destination, Buffer.from(file.data, 'base64'), { flag: 'wx' });
|
|
316
|
+
}
|
|
317
|
+
if (validateSkill(stage, { allowDirectoryMismatch: true }).digest !== preview.digest) fail('PACKAGE_INTEGRITY_FAILED');
|
|
318
|
+
writeFileSync(join(stage, '.afyx-skill-ownership.json'), `${JSON.stringify({ contract: SKILL_ENGINEERING_CONTRACT, provider: preview.provider, digest: preview.digest })}\n`, { flag: 'wx' });
|
|
319
|
+
if (itemAt(target)) { renameSync(target, backup); movedOld = true; }
|
|
320
|
+
renameSync(stage, target);
|
|
321
|
+
if (validateSkill(target).digest !== preview.digest) fail('INSTALL_VERIFY_FAILED');
|
|
322
|
+
return { contract: SKILL_ENGINEERING_CONTRACT, status: 'VERIFIED', target, digest: preview.digest, rollbackAvailable: movedOld };
|
|
323
|
+
} catch (error) {
|
|
324
|
+
if (movedOld && !itemAt(target)) renameSync(backup, target);
|
|
325
|
+
if (itemAt(stage)) rmSync(stage, { recursive: true });
|
|
326
|
+
throw error;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
export function rollbackSkillInstall({ provider, skillsRoot, name }, { authorize } = {}) {
|
|
331
|
+
if (!PROVIDERS.has(provider) || !/^[a-z][a-z0-9-]{1,63}$/.test(name)) fail('ROLLBACK_REQUEST_INVALID');
|
|
332
|
+
const root = safeRoot(skillsRoot);
|
|
333
|
+
ordinary(root, true);
|
|
334
|
+
const target = join(root, name);
|
|
335
|
+
const backup = join(root, `.${name}.afyx-rollback`);
|
|
336
|
+
safePart(target, root); safePart(backup, root);
|
|
337
|
+
if (!itemAt(target) || !itemAt(backup)) fail('ROLLBACK_UNAVAILABLE');
|
|
338
|
+
if (typeof authorize !== 'function' || authorize({ provider, target, action: 'ROLLBACK' }) !== true) fail('HOST_APPROVAL_REQUIRED');
|
|
339
|
+
const current = validateSkill(target);
|
|
340
|
+
const previous = validateSkill(backup, { allowDirectoryMismatch: true });
|
|
341
|
+
const markerPath = join(target, '.afyx-skill-ownership.json');
|
|
342
|
+
const oldMarkerPath = join(backup, '.afyx-skill-ownership.json');
|
|
343
|
+
ordinary(markerPath, false); ordinary(oldMarkerPath, false);
|
|
344
|
+
const marker = JSON.parse(readFileSync(markerPath, 'utf8'));
|
|
345
|
+
const oldMarker = JSON.parse(readFileSync(oldMarkerPath, 'utf8'));
|
|
346
|
+
if (marker.contract !== SKILL_ENGINEERING_CONTRACT || marker.provider !== provider || marker.digest !== current.digest
|
|
347
|
+
|| oldMarker.contract !== SKILL_ENGINEERING_CONTRACT || oldMarker.provider !== provider || oldMarker.digest !== previous.digest) fail('OWNERSHIP_DRIFT');
|
|
348
|
+
const displaced = join(root, `.${name}.afyx-displaced`);
|
|
349
|
+
if (itemAt(displaced)) fail('TRANSACTION_RECONCILIATION_REQUIRED');
|
|
350
|
+
renameSync(target, displaced);
|
|
351
|
+
try { renameSync(backup, target); }
|
|
352
|
+
catch (error) { renameSync(displaced, target); throw error; }
|
|
353
|
+
return { status: 'ROLLED_BACK', target, digest: previous.digest, displaced };
|
|
354
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** Pure, provider-neutral Afyx-first tool-family decision. No I/O or tool execution. */
|
|
2
|
+
export const AFYX_TOOL_FAMILY_ROUTING_CONTRACT = 'AfyxToolFamilyRouting/v1';
|
|
3
|
+
const OWNERS = new Set(['AFYX', 'EXTERNAL']);
|
|
4
|
+
function invalid(message) {
|
|
5
|
+
const error = new TypeError(message);
|
|
6
|
+
error.code = 'INVALID_TOOL_ROUTING_INPUT';
|
|
7
|
+
return error;
|
|
8
|
+
}
|
|
9
|
+
function text(value) {
|
|
10
|
+
return typeof value === 'string' && value.length > 0 && !/[\x00-\x1f\x7f]/u.test(value);
|
|
11
|
+
}
|
|
12
|
+
function candidateValid(c, i) {
|
|
13
|
+
if (!c || typeof c !== 'object' || Array.isArray(c) ||
|
|
14
|
+
!text(c.id) || !text(c.surface) || !OWNERS.has(c.ownership)) {
|
|
15
|
+
throw invalid('candidate ' + i + ' invalid identity or ownership');
|
|
16
|
+
}
|
|
17
|
+
if (!Array.isArray(c.capabilities) || c.capabilities.some((v) => !text(v))) {
|
|
18
|
+
throw invalid('candidate ' + i + ' invalid capabilities');
|
|
19
|
+
}
|
|
20
|
+
for (const field of ['installed','enabled','reachable','healthy','authorized','compatible']) {
|
|
21
|
+
if (typeof c[field] !== 'boolean') throw invalid('candidate ' + i + ' missing verified ' + field);
|
|
22
|
+
}
|
|
23
|
+
if (typeof c.fresh !== 'boolean') {
|
|
24
|
+
throw invalid('candidate ' + i + ' invalid freshness');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Caller must verify status/permissions independently for each MCP/CLI surface.
|
|
29
|
+
* Returns a decision, never probes/installs/executes a host tool.
|
|
30
|
+
* Inputs: {intent:'exact-source'|'capability', capability, candidates[],
|
|
31
|
+
* allowExternalFallback?:boolean}.
|
|
32
|
+
*/
|
|
33
|
+
export function resolveAfyxToolFamilyRoute(config) {
|
|
34
|
+
if (!config || typeof config !== 'object' || Array.isArray(config)) throw invalid('invalid configuration');
|
|
35
|
+
const {intent, capability, candidates, allowExternalFallback = false} = config;
|
|
36
|
+
if (!['exact-source','capability'].includes(intent) || !text(capability) || !Array.isArray(candidates) ||
|
|
37
|
+
typeof allowExternalFallback !== 'boolean') throw invalid('invalid routing fields');
|
|
38
|
+
candidates.forEach(candidateValid);
|
|
39
|
+
const seen = new Set();
|
|
40
|
+
for (const c of candidates) {
|
|
41
|
+
const key = c.id + ':' + c.surface;
|
|
42
|
+
if (seen.has(key)) throw invalid('duplicate candidate surface');
|
|
43
|
+
seen.add(key);
|
|
44
|
+
}
|
|
45
|
+
function decision(route, reason, item = null) {
|
|
46
|
+
return Object.freeze({contract: AFYX_TOOL_FAMILY_ROUTING_CONTRACT, capability,
|
|
47
|
+
route, reason, toolId: item?.id ?? null, surface: item?.surface ?? null,
|
|
48
|
+
externalFallbackAuthorized: allowExternalFallback,
|
|
49
|
+
observationSource: 'CALLER_VERIFIED'});
|
|
50
|
+
}
|
|
51
|
+
// Exact known-source operations need not incur graph/context tool overhead.
|
|
52
|
+
if (intent === 'exact-source') return decision('DIRECT_SOURCE', 'EXACT_SOURCE');
|
|
53
|
+
const usable = candidates.filter((c) =>
|
|
54
|
+
c.capabilities.includes(capability) && c.installed && c.enabled &&
|
|
55
|
+
c.reachable && c.healthy && c.authorized && c.compatible && c.fresh
|
|
56
|
+
).sort((a,b) => a.id.localeCompare(b.id) || a.surface.localeCompare(b.surface));
|
|
57
|
+
const native = usable.find((c) => c.ownership === 'AFYX');
|
|
58
|
+
if (native) return decision('AFYX', 'NATIVE_READY', native);
|
|
59
|
+
if (allowExternalFallback) {
|
|
60
|
+
const fallback = usable.find((c) => c.ownership === 'EXTERNAL');
|
|
61
|
+
if (fallback) return decision('EXTERNAL', 'EXTERNAL_EXPLICITLY_ALLOWED', fallback);
|
|
62
|
+
}
|
|
63
|
+
return decision('DIRECT_SOURCE', 'NO_AUTHORIZED_COMPATIBLE_TOOL');
|
|
64
|
+
}
|