@ulm0/gonogo 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +30 -2
  3. package/bin/gonogo.js +18 -0
  4. package/dist/client/THIRD-PARTY-NOTICES.md +409 -0
  5. package/dist/client/apple-touch-icon.png +0 -0
  6. package/dist/client/assets/doto-latin-900-normal-D1bF_x6I.woff +0 -0
  7. package/dist/client/assets/geist-latin-400-normal-B40WzpMT.woff2 +0 -0
  8. package/dist/client/assets/geist-latin-400-normal-akEymXtG.woff +0 -0
  9. package/dist/client/assets/geist-latin-500-normal-BDXIbFrL.woff +0 -0
  10. package/dist/client/assets/geist-latin-500-normal-CTWBw9NS.woff2 +0 -0
  11. package/dist/client/assets/geist-latin-600-normal-CSETrqM2.woff2 +0 -0
  12. package/dist/client/assets/geist-latin-600-normal-DsPlZH-9.woff +0 -0
  13. package/dist/client/assets/geist-mono-latin-400-normal-B2yvC1Cq.woff +0 -0
  14. package/dist/client/assets/geist-mono-latin-400-normal-DTRLJnHl.woff2 +0 -0
  15. package/dist/client/assets/geist-mono-latin-500-normal-D-GG86Jb.woff +0 -0
  16. package/dist/client/assets/geist-mono-latin-500-normal-YINYabwD.woff2 +0 -0
  17. package/dist/client/assets/geist-mono-latin-600-normal-V-KvD_pi.woff2 +0 -0
  18. package/dist/client/assets/geist-mono-latin-600-normal-bZn07FKM.woff +0 -0
  19. package/dist/client/assets/index-B6MsSoeo.css +1 -0
  20. package/dist/client/assets/index-DRtiRh1Y.js +31 -0
  21. package/dist/client/favicon.ico +0 -0
  22. package/dist/client/favicon.svg +1 -0
  23. package/dist/client/index.html +19 -0
  24. package/dist/server/cleanroom.js +214 -0
  25. package/dist/server/cli.js +630 -0
  26. package/dist/server/command.js +44 -0
  27. package/dist/server/constants.js +427 -0
  28. package/dist/server/docking.js +541 -0
  29. package/dist/server/downlink.js +191 -0
  30. package/dist/server/home.js +497 -0
  31. package/dist/server/hooks.js +166 -0
  32. package/dist/server/hub.js +2484 -0
  33. package/dist/server/launcher.js +542 -0
  34. package/dist/server/livery.js +210 -0
  35. package/dist/server/logsearch.js +112 -0
  36. package/dist/server/mcp.js +196 -0
  37. package/dist/server/migrate.js +119 -0
  38. package/dist/server/missionlog.js +209 -0
  39. package/dist/server/payload.js +168 -0
  40. package/dist/server/propellant.js +314 -0
  41. package/dist/server/providers.js +137 -0
  42. package/dist/server/relay.js +300 -0
  43. package/dist/server/relaykinds.js +182 -0
  44. package/dist/server/schedules.js +277 -0
  45. package/dist/server/tasks.js +272 -0
  46. package/dist/server/terminal.js +635 -0
  47. package/dist/server/uplinks.js +356 -0
  48. package/dist/server/web.js +1466 -0
  49. package/dist/shared/cron.js +149 -0
  50. package/dist/shared/fuel.js +18 -0
  51. package/dist/shared/livery.js +348 -0
  52. package/dist/shared/positions.js +132 -0
  53. package/dist/shared/protocol.js +212 -0
  54. package/package.json +84 -3
@@ -0,0 +1,209 @@
1
+ /**
2
+ * Mission Log: one memory shared by every agent, searchable (docs/mission-log-spec.md).
3
+ *
4
+ * One markdown file per entry, `<home>/mission-log/<id>.md`: a small front matter (id, title, tags, author, createdAt, updatedAt,
5
+ * each value written as JSON on one line) and then the body. The Director (the browser routes) and every agent (the MCP tools
6
+ * log_write, log_search, log_read) use the same store. The entries are held in memory and indexed for BM25 search (logsearch.ts) at
7
+ * start and at every write; a write goes to the file first, so a refusal of the disk reaches the caller and nothing changes in memory.
8
+ * The author is stamped by the server from the agent's token. An agent may change only what it wrote; the Director may change or
9
+ * remove any entry. The clock is injected for tests.
10
+ *
11
+ * shortcut: every entry is held in memory (at the limits, 2000 entries of 20,000 characters is about 40 MB) and the list of the page
12
+ * shows the newest LOG_SEARCH_MAX; page it or read the files on demand if a log ever gets that big.
13
+ * shortcut: `author` is an agent name, so a renamed agent can no longer change what it wrote (the Director still can), and a new
14
+ * agent hired under the name of a removed one may change what the old one wrote; stamp a per-hire id if that ever matters.
15
+ */
16
+ import { randomBytes } from 'node:crypto';
17
+ import { mkdir, readdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
18
+ import { join } from 'node:path';
19
+ import { LOG_BODY_MAX_CHARS, LOG_ENTRIES_MAX, LOG_QUERY_MAX_CHARS, LOG_SEARCH_MAX, LOG_TAG_PATTERN, LOG_TAGS_MAX, LOG_TITLE_MAX_CHARS } from '../shared/protocol.js';
20
+ import { DIR_MODE, FILE_MODE, LOG_DIR } from './constants.js';
21
+ import { isRecord } from './hooks.js';
22
+ import { HubError } from './hub.js';
23
+ import { createIndex, snippet } from './logsearch.js';
24
+ import { UNSAFE_IN_NAME } from './schedules.js';
25
+ const ID_RE = /^l[1-9]\d{0,5}$/;
26
+ const FILE_RE = /^(l[1-9]\d{0,5})\.md$/;
27
+ const TAG_RE = new RegExp(LOG_TAG_PATTERN);
28
+ const FIELDS = ['title', 'body', 'tags'];
29
+ /** Holds the highest id ever given, so that the id of a removed entry is not given again after a restart. */
30
+ const SEQ_FILE = '.seq';
31
+ const bad = (message, field) => new HubError('bad_request', message, field);
32
+ const copy = (entry) => ({ ...entry, tags: [...entry.tags] });
33
+ function validate(input, whole) {
34
+ if (!isRecord(input))
35
+ throw bad('request body must be a JSON object');
36
+ for (const key of Object.keys(input))
37
+ if (!FIELDS.includes(key))
38
+ throw bad(`unknown field "${key}"`, key);
39
+ if (whole && (input.title === undefined || input.body === undefined))
40
+ throw bad('title and body are required', input.title === undefined ? 'title' : 'body');
41
+ if (!whole && Object.keys(input).length === 0)
42
+ throw bad('nothing to change: give a title, a body or tags');
43
+ const out = {};
44
+ if (input.title !== undefined) {
45
+ const title = typeof input.title === 'string' ? input.title.trim() : '';
46
+ if (title === '' || title.length > LOG_TITLE_MAX_CHARS || UNSAFE_IN_NAME.test(title))
47
+ throw bad(`title must be 1 to ${LOG_TITLE_MAX_CHARS} characters on one line`, 'title');
48
+ out.title = title;
49
+ }
50
+ if (input.body !== undefined) {
51
+ const body = typeof input.body === 'string' ? input.body.trim() : '';
52
+ if (body === '' || body.length > LOG_BODY_MAX_CHARS)
53
+ throw bad(`body must be 1 to ${LOG_BODY_MAX_CHARS} characters`, 'body');
54
+ out.body = body;
55
+ }
56
+ if (input.tags !== undefined) {
57
+ const tags = Array.isArray(input.tags) ? input.tags.map((t) => (typeof t === 'string' ? t.trim().toLowerCase() : '')) : [];
58
+ if (!Array.isArray(input.tags) || tags.length > LOG_TAGS_MAX || !tags.every((t) => TAG_RE.test(t))) {
59
+ throw bad(`tags must be a list of at most ${LOG_TAGS_MAX} words of 1 to 30 letters, digits, dots, dashes or underscores`, 'tags');
60
+ }
61
+ out.tags = [...new Set(tags)];
62
+ }
63
+ return out;
64
+ }
65
+ const render = (e) => [
66
+ '---',
67
+ 'version: 1',
68
+ `id: ${JSON.stringify(e.id)}`,
69
+ `title: ${JSON.stringify(e.title)}`,
70
+ `tags: ${JSON.stringify(e.tags)}`,
71
+ `author: ${JSON.stringify(e.author)}`,
72
+ `createdAt: ${JSON.stringify(new Date(e.createdAt).toISOString())}`,
73
+ `updatedAt: ${JSON.stringify(new Date(e.updatedAt).toISOString())}`,
74
+ '---',
75
+ e.body,
76
+ '',
77
+ ].join('\n');
78
+ /** The entry in a file; a file that is not one throws, and the caller skips it. */
79
+ function parse(text, id) {
80
+ const found = /^---\n([\s\S]*?)\n---\n([\s\S]*)$/.exec(text.replace(/\r\n/g, '\n'));
81
+ if (!found)
82
+ throw new Error('no front matter');
83
+ const values = new Map();
84
+ for (const line of (found[1] ?? '').split('\n')) {
85
+ const at = line.indexOf(': ');
86
+ if (at < 0)
87
+ throw new Error('a front matter line is not "key: value"');
88
+ values.set(line.slice(0, at), JSON.parse(line.slice(at + 2)));
89
+ }
90
+ const { version, title, tags, author, createdAt, updatedAt } = Object.fromEntries(values);
91
+ const at = (value) => (typeof value === 'string' ? Date.parse(value) : Number.NaN);
92
+ // an entry from before there was a version has none and reads as version 1
93
+ if (version !== undefined && version !== 1)
94
+ throw new Error(`format version ${String(version)} was saved by another gonogo; this one reads version 1`);
95
+ if (values.get('id') !== id)
96
+ throw new Error('the id does not match the name of the file');
97
+ if (typeof title !== 'string' || title === '' || title.length > LOG_TITLE_MAX_CHARS)
98
+ throw new Error('no valid title');
99
+ if (!Array.isArray(tags) || !tags.every((t) => typeof t === 'string'))
100
+ throw new Error('no valid tags');
101
+ if (typeof author !== 'string' || author === '')
102
+ throw new Error('no valid author');
103
+ if (Number.isNaN(at(createdAt)) || Number.isNaN(at(updatedAt)))
104
+ throw new Error('no valid times');
105
+ const body = (found[2] ?? '').replace(/\n$/, '');
106
+ return { id, title, body: body.slice(0, LOG_BODY_MAX_CHARS), tags: tags, author, createdAt: at(createdAt), updatedAt: at(updatedAt) };
107
+ }
108
+ export function createMissionLog(options) {
109
+ const { now, log } = options;
110
+ const dir = join(options.dir, LOG_DIR);
111
+ const entries = new Map();
112
+ const index = createIndex();
113
+ let seq = 0;
114
+ let chain = Promise.resolve();
115
+ /** One write at a time, so the limit and the ids hold; a failure goes to the caller and the next write goes on. */
116
+ const locked = (fn) => {
117
+ const run = chain.then(fn);
118
+ chain = run.catch(() => undefined);
119
+ return run;
120
+ };
121
+ /** Written whole to a temporary file and renamed, so a crash leaves the old text or the new, never half. */
122
+ const writeFileAtomic = async (name, text) => {
123
+ const tmp = join(dir, `.${name}.${process.pid}.${randomBytes(4).toString('hex')}.tmp`);
124
+ await writeFile(tmp, text, { mode: FILE_MODE, flag: 'wx' });
125
+ await rename(tmp, join(dir, name));
126
+ };
127
+ const keep = (entry) => {
128
+ entries.set(entry.id, entry);
129
+ index.add({ id: entry.id, title: entry.title, tags: entry.tags, body: entry.body, at: entry.updatedAt });
130
+ };
131
+ const find = (id) => {
132
+ const entry = ID_RE.test(id) ? entries.get(id) : undefined;
133
+ if (!entry)
134
+ throw new HubError('not_found', 'unknown entry');
135
+ return entry;
136
+ };
137
+ const hit = (e, query) => ({ id: e.id, title: e.title, author: e.author, tags: e.tags, updatedAt: e.updatedAt, snippet: snippet(e.body, query) });
138
+ return {
139
+ async load() {
140
+ await mkdir(dir, { recursive: true, mode: DIR_MODE });
141
+ for (const name of await readdir(dir)) {
142
+ const id = FILE_RE.exec(name)?.[1];
143
+ if (id === undefined)
144
+ continue;
145
+ seq = Math.max(seq, Number(id.slice(1)));
146
+ try {
147
+ keep(parse(await readFile(join(dir, name), 'utf8'), id));
148
+ }
149
+ catch (error) {
150
+ // the file stays as it is: it may be a hand edit that the Director wants to mend
151
+ log.warn(`${LOG_DIR}/${name} was skipped: ${error instanceof Error ? error.message : String(error)}`);
152
+ }
153
+ }
154
+ const saved = Number(await readFile(join(dir, SEQ_FILE), 'utf8').catch(() => '0'));
155
+ if (Number.isSafeInteger(saved) && saved > seq)
156
+ seq = saved;
157
+ },
158
+ search(query, limit = LOG_SEARCH_MAX) {
159
+ const q = query.slice(0, LOG_QUERY_MAX_CHARS);
160
+ const cap = Math.min(Math.max(Math.trunc(limit), 1), LOG_SEARCH_MAX);
161
+ const found = q.trim() === '' ? [...entries.values()].sort((a, b) => b.updatedAt - a.updatedAt || b.createdAt - a.createdAt).slice(0, cap) : index.search(q, cap).map((r) => find(r.id));
162
+ return { total: entries.size, hits: found.map((e) => hit(e, q)) };
163
+ },
164
+ get: (id) => copy(find(id)),
165
+ create(author, input) {
166
+ return locked(async () => {
167
+ const fields = validate(input, true);
168
+ if (entries.size >= LOG_ENTRIES_MAX)
169
+ throw new HubError('conflict', `the Mission Log holds at most ${LOG_ENTRIES_MAX} entries: remove one first`, 'log');
170
+ const at = now();
171
+ const entry = { id: `l${seq + 1}`, title: fields.title ?? '', body: fields.body ?? '', tags: fields.tags ?? [], author, createdAt: at, updatedAt: at };
172
+ await writeFileAtomic(`${entry.id}.md`, render(entry));
173
+ seq += 1;
174
+ keep(entry);
175
+ options.emit({ t: 'log', changed: [{ id: entry.id, title: entry.title }], removed: [] });
176
+ return copy(entry);
177
+ });
178
+ },
179
+ update(id, input, by) {
180
+ return locked(async () => {
181
+ const old = find(id);
182
+ if (by !== null && old.author !== by)
183
+ throw new HubError('forbidden', `${id} was written by ${old.author}: only its author or the Director may change it`);
184
+ const fields = validate(input, false);
185
+ const next = { ...old, ...fields, updatedAt: now() };
186
+ if (next.title === old.title && next.body === old.body && next.tags.join() === old.tags.join())
187
+ return copy(old);
188
+ await writeFileAtomic(`${id}.md`, render(next));
189
+ keep(next);
190
+ options.emit({ t: 'log', changed: [{ id, title: next.title }], removed: [] });
191
+ return copy(next);
192
+ });
193
+ },
194
+ remove(id) {
195
+ return locked(async () => {
196
+ find(id);
197
+ await writeFileAtomic(SEQ_FILE, String(seq));
198
+ // force: a file already deleted by hand must not leave an entry that can never be removed
199
+ await rm(join(dir, `${id}.md`), { force: true });
200
+ entries.delete(id);
201
+ index.remove(id);
202
+ options.emit({ t: 'log', changed: [], removed: [id] });
203
+ });
204
+ },
205
+ close() {
206
+ return chain.then(() => undefined);
207
+ },
208
+ };
209
+ }
@@ -0,0 +1,168 @@
1
+ /**
2
+ * Payload (docs/payload-spec.md): the one reader of an agent's MCP servers and skill folders. The hub uses it for hire
3
+ * and edit, home.ts for the roster file. It looks at the shape only; whether a skill folder exists is the hub's and the
4
+ * launcher's to check.
5
+ */
6
+ import { isAbsolute, basename, resolve } from 'node:path';
7
+ import { MCP_SERVER_NAME, providerInfo } from '../shared/protocol.js';
8
+ import { DIR_MAX_CHARS, PAYLOAD_MAX_CHARS, PAYLOAD_MAX_ITEMS, PAYLOAD_MAX_SERVERS, PAYLOAD_MAX_SKILLS, PAYLOAD_SERVER_NAME_PATTERN, PAYLOAD_STRING_MAX_CHARS, } from './constants.js';
9
+ const NAME_RE = new RegExp(PAYLOAD_SERVER_NAME_PATTERN);
10
+ const ENV_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
11
+ const HEADER_NAME_RE = /^[A-Za-z0-9-]+$/;
12
+ const SERVER_TYPES = ['stdio', 'http', 'sse'];
13
+ const FIELDS_OF = { stdio: ['type', 'command', 'args', 'env'], http: ['type', 'url', 'headers'], sse: ['type', 'url', 'headers'] };
14
+ class Fault extends Error {
15
+ field;
16
+ constructor(field, message) {
17
+ super(message);
18
+ this.field = field;
19
+ }
20
+ }
21
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
22
+ /** A string within the limits; a NUL would end a C string, so it never passes. */
23
+ function text(value, what, min, max = PAYLOAD_STRING_MAX_CHARS) {
24
+ if (typeof value !== 'string' || value.length < min || value.length > max) {
25
+ throw new Fault('payload.mcpServers', `${what} must be text of ${min === 0 ? 'at most' : `1 to`} ${max} characters`);
26
+ }
27
+ if (value.includes('\u0000'))
28
+ throw new Fault('payload.mcpServers', `${what} cannot contain a NUL character`);
29
+ return value;
30
+ }
31
+ /** env or headers: names by `nameRe`, values text. Built with fromEntries so that a name like __proto__ stays a plain key. */
32
+ function table(value, what, nameRe, valueRe) {
33
+ if (!isRecord(value))
34
+ throw new Fault('payload.mcpServers', `${what} must be an object of text values`);
35
+ const entries = Object.entries(value);
36
+ if (entries.length > PAYLOAD_MAX_ITEMS)
37
+ throw new Fault('payload.mcpServers', `${what} can hold at most ${PAYLOAD_MAX_ITEMS} entries`);
38
+ return Object.fromEntries(entries.map(([key, item]) => {
39
+ if (!nameRe.test(key))
40
+ throw new Fault('payload.mcpServers', `${what}: "${key}" is not a usable name`);
41
+ const checked = text(item, `${what}.${key}`, 0);
42
+ if (valueRe?.test(checked))
43
+ throw new Fault('payload.mcpServers', `${what}.${key} cannot contain a line break`);
44
+ return [key, checked];
45
+ }));
46
+ }
47
+ function server(name, value) {
48
+ const where = `server "${name}"`;
49
+ if (!isRecord(value))
50
+ throw new Fault('payload.mcpServers', `${where} must be an object`);
51
+ const type = value.type ?? 'stdio';
52
+ if (!SERVER_TYPES.includes(type)) {
53
+ throw new Fault('payload.mcpServers', `${where}: type must be one of ${SERVER_TYPES.join(', ')}`);
54
+ }
55
+ const kind = type;
56
+ for (const key of Object.keys(value)) {
57
+ if (!FIELDS_OF[kind].includes(key)) {
58
+ throw new Fault('payload.mcpServers', `${where}: "${key}" is not a field of a ${kind} server (a server with a url needs "type": "http" or "sse")`);
59
+ }
60
+ }
61
+ const out = {};
62
+ if (value.type !== undefined)
63
+ out.type = kind;
64
+ if (kind === 'stdio') {
65
+ out.command = text(value.command, `${where}: command`, 1);
66
+ if (value.args !== undefined) {
67
+ if (!Array.isArray(value.args) || value.args.length > PAYLOAD_MAX_ITEMS) {
68
+ throw new Fault('payload.mcpServers', `${where}: args must be a list of at most ${PAYLOAD_MAX_ITEMS} texts`);
69
+ }
70
+ out.args = value.args.map((arg, i) => text(arg, `${where}: args[${i}]`, 0));
71
+ }
72
+ if (value.env !== undefined)
73
+ out.env = table(value.env, `${where}: env`, ENV_NAME_RE, null);
74
+ return out;
75
+ }
76
+ out.url = text(value.url, `${where}: url`, 1);
77
+ let parsed = null;
78
+ try {
79
+ parsed = new URL(out.url);
80
+ }
81
+ catch {
82
+ // reported below
83
+ }
84
+ if (parsed === null || (parsed.protocol !== 'http:' && parsed.protocol !== 'https:')) {
85
+ throw new Fault('payload.mcpServers', `${where}: url must be an http or https address`);
86
+ }
87
+ if (value.headers !== undefined)
88
+ out.headers = table(value.headers, `${where}: headers`, HEADER_NAME_RE, /[\r\n]/);
89
+ return out;
90
+ }
91
+ function servers(value) {
92
+ if (!isRecord(value))
93
+ throw new Fault('payload.mcpServers', 'mcpServers must be an object of servers');
94
+ const entries = Object.entries(value);
95
+ if (entries.length > PAYLOAD_MAX_SERVERS)
96
+ throw new Fault('payload.mcpServers', `at most ${PAYLOAD_MAX_SERVERS} servers`);
97
+ return Object.fromEntries(entries.map(([name, config]) => {
98
+ if (name === MCP_SERVER_NAME)
99
+ throw new Fault('payload.mcpServers', `"${MCP_SERVER_NAME}" is reserved for the gonogo tools`);
100
+ if (!NAME_RE.test(name)) {
101
+ throw new Fault('payload.mcpServers', `server name "${name}": use lowercase letters, digits, - and _, starting with a letter or digit (at most 32 characters)`);
102
+ }
103
+ return [name, server(name, config)];
104
+ }));
105
+ }
106
+ function skills(value) {
107
+ if (!Array.isArray(value) || value.length > PAYLOAD_MAX_SKILLS) {
108
+ throw new Fault('payload.skills', `skills must be a list of at most ${PAYLOAD_MAX_SKILLS} folders`);
109
+ }
110
+ const paths = new Set();
111
+ const names = new Set();
112
+ for (const item of value) {
113
+ if (typeof item !== 'string' || item.length === 0 || item.length > DIR_MAX_CHARS || item.includes('\u0000')) {
114
+ throw new Fault('payload.skills', `a skill folder must be a path of 1 to ${DIR_MAX_CHARS} characters`);
115
+ }
116
+ if (!isAbsolute(item))
117
+ throw new Fault('payload.skills', `a skill folder must be an absolute path: ${item}`);
118
+ const path = resolve(item);
119
+ // The folder's own name is the skill's name in the plugin, so two folders with one name would collide.
120
+ if (paths.has(path) || names.has(basename(path)))
121
+ throw new Fault('payload.skills', `skill folders must differ in name: ${path}`);
122
+ paths.add(path);
123
+ names.add(basename(path));
124
+ }
125
+ return [...paths];
126
+ }
127
+ /** `undefined` and `null` are no payload; an empty `mcpServers` or `skills` is dropped, and a payload left empty is none. */
128
+ export function parsePayload(value) {
129
+ try {
130
+ if (value === undefined || value === null)
131
+ return { ok: true, payload: undefined };
132
+ if (!isRecord(value))
133
+ throw new Fault('payload', 'payload must be an object');
134
+ for (const key of Object.keys(value)) {
135
+ if (key !== 'mcpServers' && key !== 'skills')
136
+ throw new Fault('payload', `payload has no field "${key}"`);
137
+ }
138
+ const payload = {};
139
+ if (value.mcpServers !== undefined) {
140
+ const found = servers(value.mcpServers);
141
+ if (Object.keys(found).length > 0)
142
+ payload.mcpServers = found;
143
+ }
144
+ if (value.skills !== undefined) {
145
+ const found = skills(value.skills);
146
+ if (found.length > 0)
147
+ payload.skills = found;
148
+ }
149
+ if (JSON.stringify(payload).length > PAYLOAD_MAX_CHARS)
150
+ throw new Fault('payload', `payload must be at most ${PAYLOAD_MAX_CHARS} characters of JSON`);
151
+ return { ok: true, payload: Object.keys(payload).length === 0 ? undefined : payload };
152
+ }
153
+ catch (error) {
154
+ if (error instanceof Fault)
155
+ return { ok: false, field: error.field, error: error.message };
156
+ throw error;
157
+ }
158
+ }
159
+ /** Why `provider` cannot take `payload` (PROVIDER_INFO.payload), or null. */
160
+ export function payloadRefusal(provider, payload) {
161
+ const info = providerInfo(provider);
162
+ if (info.payload === null)
163
+ return { field: 'payload', error: `${info.label} takes no payload` };
164
+ if (payload.skills !== undefined && info.payload !== 'all') {
165
+ return { field: 'payload.skills', error: `skills need Claude Code; ${info.label} takes MCP servers only` };
166
+ }
167
+ return null;
168
+ }