@sabaiway/agent-workflow-kit 22.2.0 → 23.1.0
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/CHANGELOG.md +49 -1
- package/README.md +1 -1
- package/SKILL.md +1 -1
- package/bridges/antigravity-cli-bridge/SKILL.md +11 -10
- package/bridges/antigravity-cli-bridge/bin/agy-jev.test.mjs +56 -7
- package/bridges/antigravity-cli-bridge/bin/agy-review.sh +81 -63
- package/bridges/antigravity-cli-bridge/bin/agy-review.test.mjs +0 -21
- package/bridges/antigravity-cli-bridge/bin/agy.sh +86 -12
- package/bridges/antigravity-cli-bridge/capability.json +4 -5
- package/bridges/antigravity-cli-bridge/references/models-and-flags.md +3 -3
- package/bridges/antigravity-cli-bridge/service-facts.txt +11 -0
- package/bridges/antigravity-cli-bridge/setup/README.md +1 -1
- package/bridges/codex-cli-bridge/SKILL.md +23 -24
- package/bridges/codex-cli-bridge/bin/codex-exec-jev.test.mjs +82 -47
- package/bridges/codex-cli-bridge/bin/codex-exec.sh +133 -52
- package/bridges/codex-cli-bridge/bin/codex-review-jev.test.mjs +44 -14
- package/bridges/codex-cli-bridge/bin/codex-review.sh +103 -30
- package/bridges/codex-cli-bridge/capability.json +7 -8
- package/bridges/codex-cli-bridge/references/driving-codex.md +6 -7
- package/bridges/codex-cli-bridge/references/sandbox-and-flags.md +8 -11
- package/bridges/codex-cli-bridge/service-facts.txt +9 -0
- package/bridges/codex-cli-bridge/setup/README.md +3 -3
- package/capability.json +1 -1
- package/package.json +1 -1
- package/references/modes/recommendations.md +3 -3
- package/references/modes/velocity.md +1 -1
- package/tools/bridge-sandbox-recipe.mjs +9 -6
- package/tools/bridge-state-dirs.mjs +2 -2
- package/tools/detect-backends.mjs +23 -15
- package/tools/manifest/schema.md +28 -47
- package/tools/manifest/validate.mjs +22 -60
- package/tools/procedures.mjs +1 -1
- package/tools/services/antigravity.json +17 -0
- package/tools/services/codex.json +15 -0
- package/tools/services/index.mjs +127 -0
- package/tools/services/jev.json +12 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { readdirSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
5
|
+
export const SERVICE_FACTS_FILE = 'service-facts.txt';
|
|
6
|
+
const SERVICES_DIRECTORY = fileURLToPath(new URL('.', import.meta.url));
|
|
7
|
+
const FRAGMENT_EXTENSION = '.json';
|
|
8
|
+
const FRAGMENT_KEYS = ['hosts', 'writableDirs', 'excludedCommands', 'passedVariables', 'runReachesHosts'];
|
|
9
|
+
const NETWORK_HOST_RE = /^(\*\.)?[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/i;
|
|
10
|
+
const VARIABLE_RE = /^[A-Z][A-Z0-9_]*$/;
|
|
11
|
+
const EXCLUDED_COMMAND_RE = /^[A-Za-z0-9][A-Za-z0-9._-]* \*$/;
|
|
12
|
+
const GLOB_RE = /[*?[\]]/;
|
|
13
|
+
const CONTROL_CHAR_RE = /[\x00-\x1f\x7f]/;
|
|
14
|
+
const FACTS_HEADER = "# generated from the kit's service fragments (agent-workflow-kit/tools/services/); do not edit";
|
|
15
|
+
const FACT_GROUPS = [
|
|
16
|
+
['HOST', 'hosts'], ['RUN_HOST', 'runHosts'], ['WRITABLE_DIR', 'dirEntries'],
|
|
17
|
+
['EXCLUDED_COMMAND', 'excludedCommands'], ['PASSED_VARIABLE', 'passedVariables'],
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const isObject = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
21
|
+
const hasTraversal = (path) => path.split(/[\\/]/).includes('..');
|
|
22
|
+
const isVariable = (value) => typeof value === 'string' && VARIABLE_RE.test(value);
|
|
23
|
+
const isDirectoryEntry = (entry) => {
|
|
24
|
+
if (!isObject(entry) || !(entry.env === null || isVariable(entry.env))) return false;
|
|
25
|
+
const directory = entry.default;
|
|
26
|
+
return typeof directory === 'string'
|
|
27
|
+
&& (directory.startsWith('~/') || directory.startsWith('/'))
|
|
28
|
+
&& !GLOB_RE.test(directory) && !CONTROL_CHAR_RE.test(directory)
|
|
29
|
+
&& !directory.endsWith('/') && !hasTraversal(directory);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const refuseSchema = (path, key, reason) => {
|
|
33
|
+
throw new Error(`${path}: ${key} ${reason}`);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const validateList = (value, path, key, accepts, identify = (entry) => entry) => {
|
|
37
|
+
if (!Array.isArray(value)) refuseSchema(path, key, 'must be an array');
|
|
38
|
+
const seen = new Set();
|
|
39
|
+
for (const entry of value) {
|
|
40
|
+
if (!accepts(entry)) refuseSchema(path, key, `has an invalid entry ${JSON.stringify(entry)}`);
|
|
41
|
+
const identity = identify(entry);
|
|
42
|
+
if (seen.has(identity)) refuseSchema(path, key, `has a duplicate entry ${JSON.stringify(identity)}`);
|
|
43
|
+
seen.add(identity);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const validateFragment = (fragment, path) => {
|
|
48
|
+
if (!isObject(fragment)) refuseSchema(path, 'root', 'must be an object');
|
|
49
|
+
for (const key of Object.keys(fragment)) {
|
|
50
|
+
if (!FRAGMENT_KEYS.includes(key)) refuseSchema(path, key, 'is unknown');
|
|
51
|
+
}
|
|
52
|
+
for (const key of FRAGMENT_KEYS) {
|
|
53
|
+
if (!Object.hasOwn(fragment, key)) refuseSchema(path, key, 'is required');
|
|
54
|
+
}
|
|
55
|
+
validateList(fragment.hosts, path, 'hosts',
|
|
56
|
+
(host) => typeof host === 'string' && NETWORK_HOST_RE.test(host));
|
|
57
|
+
validateList(fragment.writableDirs, path, 'writableDirs', isDirectoryEntry, (entry) => entry.default);
|
|
58
|
+
validateList(fragment.excludedCommands, path, 'excludedCommands',
|
|
59
|
+
(command) => typeof command === 'string' && EXCLUDED_COMMAND_RE.test(command));
|
|
60
|
+
validateList(fragment.passedVariables, path, 'passedVariables',
|
|
61
|
+
(value) => isVariable(value) && value !== 'OPENAI_BASE_URL');
|
|
62
|
+
if (typeof fragment.runReachesHosts !== 'boolean') refuseSchema(path, 'runReachesHosts', 'must be a boolean');
|
|
63
|
+
if (fragment.runReachesHosts && fragment.hosts.some((host) => host.startsWith('*.'))) {
|
|
64
|
+
refuseSchema(path, 'hosts', 'must not contain a wildcard when runReachesHosts is true');
|
|
65
|
+
}
|
|
66
|
+
return fragment;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const readFragment = (path, readFile) => {
|
|
70
|
+
const fragment = (() => {
|
|
71
|
+
try {
|
|
72
|
+
return JSON.parse(readFile(path, 'utf8'));
|
|
73
|
+
} catch (error) {
|
|
74
|
+
throw new Error(`${path}: cannot read or parse service fragment: ${error.message}`, { cause: error });
|
|
75
|
+
}
|
|
76
|
+
})();
|
|
77
|
+
return validateFragment(fragment, path);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const loadServiceFragments = (deps = {}) => {
|
|
81
|
+
const servicesDir = deps.servicesDir ?? SERVICES_DIRECTORY;
|
|
82
|
+
const readdir = deps.readdir ?? readdirSync;
|
|
83
|
+
const readFile = deps.readFile ?? readFileSync;
|
|
84
|
+
const entries = (() => {
|
|
85
|
+
try {
|
|
86
|
+
return readdir(servicesDir);
|
|
87
|
+
} catch (error) {
|
|
88
|
+
throw new Error(`${servicesDir}: cannot read services directory: ${error.message}`, { cause: error });
|
|
89
|
+
}
|
|
90
|
+
})();
|
|
91
|
+
return Object.fromEntries(entries.filter((name) => name.endsWith(FRAGMENT_EXTENSION)).sort().map((name) => [
|
|
92
|
+
name.slice(0, -FRAGMENT_EXTENSION.length), readFragment(join(servicesDir, name), readFile),
|
|
93
|
+
]));
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const takeUnique = (entries, identify = (entry) => entry) => {
|
|
97
|
+
const seen = new Set();
|
|
98
|
+
return entries.filter((entry) => {
|
|
99
|
+
const identity = identify(entry);
|
|
100
|
+
if (seen.has(identity)) return false;
|
|
101
|
+
seen.add(identity);
|
|
102
|
+
return true;
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const mergeServices = (ids, fragments) => {
|
|
107
|
+
const selected = ids.map((id) => {
|
|
108
|
+
if (!Object.hasOwn(fragments, id)) throw new Error(`Unknown service id: ${id}`);
|
|
109
|
+
return fragments[id];
|
|
110
|
+
});
|
|
111
|
+
return {
|
|
112
|
+
hosts: takeUnique(selected.flatMap((fragment) => fragment.hosts)),
|
|
113
|
+
dirEntries: takeUnique(selected.flatMap((fragment) => fragment.writableDirs),
|
|
114
|
+
(entry) => JSON.stringify([entry.env, entry.default]))
|
|
115
|
+
.map((entry) => ({ env: entry.env, default: entry.default })),
|
|
116
|
+
excludedCommands: takeUnique(selected.flatMap((fragment) => fragment.excludedCommands)),
|
|
117
|
+
passedVariables: takeUnique(selected.flatMap((fragment) => fragment.passedVariables)),
|
|
118
|
+
runHosts: takeUnique(selected.filter((fragment) => fragment.runReachesHosts).flatMap((fragment) => fragment.hosts)),
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const renderServiceFacts = (merged) => [
|
|
123
|
+
FACTS_HEADER,
|
|
124
|
+
...FACT_GROUPS.flatMap(([key, field]) => merged[field].map((entry) =>
|
|
125
|
+
`${key}=${field === 'dirEntries' ? `${entry.env ?? ''}:${entry.default}` : entry}`)),
|
|
126
|
+
'',
|
|
127
|
+
].join('\n');
|