gdp-wired 0.50.3 → 0.50.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/README.md +4 -0
- package/dist/core/agent-consult/cli.d.ts +2 -0
- package/dist/core/agent-consult/cli.js +19 -0
- package/dist/core/agent-consult/protocol.d.ts +93 -0
- package/dist/core/agent-consult/protocol.js +154 -0
- package/dist/core/agent-consult/service.d.ts +435 -0
- package/dist/core/agent-consult/service.js +84 -0
- package/dist/core/agent-consult/session.d.ts +13 -0
- package/dist/core/agent-consult/session.js +163 -0
- package/dist/core/agent-consult/source-service.d.ts +83 -0
- package/dist/core/agent-consult/source-service.js +51 -0
- package/dist/core/agent-consult/tsconfig.json +5 -0
- package/dist/core/agent-consult/worker.d.ts +1 -0
- package/dist/core/agent-consult/worker.js +17 -0
- package/dist/core/agent-consult/workspace.d.ts +27 -0
- package/dist/core/agent-consult/workspace.js +66 -0
- package/dist/core/agent-consult.d.ts +8 -0
- package/dist/core/agent-consult.js +6 -0
- package/dist/core/cli.d.ts +5 -0
- package/dist/core/cli.js +118 -49
- package/docs/agent-consult-workspace-check.md +118 -0
- package/docs/agent-consult.md +151 -0
- package/examples/agent-consult.json +22 -0
- package/package.json +11 -3
package/README.md
CHANGED
|
@@ -675,6 +675,10 @@ Each directory's README has its own runs and results.
|
|
|
675
675
|
|
|
676
676
|
## The skill
|
|
677
677
|
|
|
678
|
+
Coding agents can also consult the data-only [agent-consult MCP / library](docs/agent-consult.md):
|
|
679
|
+
`gdp-wired-agent-consult` exposes `prove`, `why_not`, `suggest`, `check_change`, and `status`
|
|
680
|
+
without importing project code. Checked model proofs are not native conformance; counted accounting remains provisional.
|
|
681
|
+
|
|
678
682
|
`npx skills add monotykamary/gdp-wired` installs a skill that guides coding agents (and people) through writing a rule
|
|
679
683
|
the way the code does it, stating its laws, reading a refused proof and handing a claim to Lean:
|
|
680
684
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { serveStdio } from "./session.js";
|
|
3
|
+
// No tool/CLI flags accept roots or interpreters. Only trusted server startup environment configures roots.
|
|
4
|
+
if (process.argv.length > 2) {
|
|
5
|
+
process.stderr.write('Usage: gdp-wired-agent-consult (stdio MCP; accepts no arguments)\n');
|
|
6
|
+
process.exitCode = 2;
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
try {
|
|
10
|
+
const configured = JSON.parse(process.env.GDP_AGENT_CONSULT_ROOTS ?? '[]');
|
|
11
|
+
if (!Array.isArray(configured) || !configured.every(p => typeof p === 'string'))
|
|
12
|
+
throw Error('GDP_AGENT_CONSULT_ROOTS must be a JSON array of trusted absolute directories');
|
|
13
|
+
await serveStdio({ workspaceRoots: configured });
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
process.stderr.write(String(e) + '\n');
|
|
17
|
+
process.exitCode = 1;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { Machine, Law } from '../../core/machine.js';
|
|
2
|
+
export type Tool = 'prove' | 'why_not' | 'suggest' | 'check_change' | 'status' | 'check';
|
|
3
|
+
export type Unit = {
|
|
4
|
+
unit: string;
|
|
5
|
+
rule: Machine;
|
|
6
|
+
};
|
|
7
|
+
export type Budget = {
|
|
8
|
+
work: number;
|
|
9
|
+
apiCalls: number;
|
|
10
|
+
depth: number;
|
|
11
|
+
bound: number;
|
|
12
|
+
candidates: number;
|
|
13
|
+
};
|
|
14
|
+
export type Request = {
|
|
15
|
+
tool: Tool;
|
|
16
|
+
file?: string;
|
|
17
|
+
unit?: string;
|
|
18
|
+
revision?: string;
|
|
19
|
+
subject?: Unit;
|
|
20
|
+
before?: Unit;
|
|
21
|
+
after?: Unit;
|
|
22
|
+
laws?: Law[];
|
|
23
|
+
nearMisses?: Law[];
|
|
24
|
+
budget: Budget;
|
|
25
|
+
};
|
|
26
|
+
export type Json = null | boolean | number | string | Json[] | {
|
|
27
|
+
[key: string]: Json;
|
|
28
|
+
};
|
|
29
|
+
export declare class Refusal extends Error {
|
|
30
|
+
readonly code: string;
|
|
31
|
+
readonly fix: string;
|
|
32
|
+
constructor(code: string, fix: string, message: string);
|
|
33
|
+
}
|
|
34
|
+
export declare function refuse(code: string, fix: string, message: string): never;
|
|
35
|
+
export declare const canonical: (x: unknown) => string;
|
|
36
|
+
export declare const digest: (x: unknown) => string;
|
|
37
|
+
export declare const revision: (u: Unit, laws: Law[]) => string;
|
|
38
|
+
export declare function parseRequest(tool: unknown, value: unknown): Request;
|
|
39
|
+
export declare const toolNames: Tool[];
|
|
40
|
+
export declare const toolDescriptions: Record<Tool, string>;
|
|
41
|
+
export declare function wireJSON(value: unknown): string;
|
|
42
|
+
export declare const inputSchema: (tool: Tool) => {
|
|
43
|
+
type: string;
|
|
44
|
+
additionalProperties: boolean;
|
|
45
|
+
properties: Record<string, unknown>;
|
|
46
|
+
required: string[];
|
|
47
|
+
} | {
|
|
48
|
+
type: string;
|
|
49
|
+
additionalProperties: boolean;
|
|
50
|
+
properties: Record<string, unknown>;
|
|
51
|
+
required: string[];
|
|
52
|
+
$defs: {
|
|
53
|
+
term: {
|
|
54
|
+
oneOf: {
|
|
55
|
+
type: string;
|
|
56
|
+
additionalProperties: boolean;
|
|
57
|
+
properties: Record<string, unknown>;
|
|
58
|
+
required: string[];
|
|
59
|
+
}[];
|
|
60
|
+
};
|
|
61
|
+
condition: {
|
|
62
|
+
oneOf: {
|
|
63
|
+
type: string;
|
|
64
|
+
additionalProperties: boolean;
|
|
65
|
+
properties: Record<string, unknown>;
|
|
66
|
+
required: string[];
|
|
67
|
+
}[];
|
|
68
|
+
};
|
|
69
|
+
unit: {
|
|
70
|
+
type: string;
|
|
71
|
+
additionalProperties: boolean;
|
|
72
|
+
properties: Record<string, unknown>;
|
|
73
|
+
required: string[];
|
|
74
|
+
};
|
|
75
|
+
laws: {
|
|
76
|
+
type: string;
|
|
77
|
+
minItems: number;
|
|
78
|
+
maxItems: number;
|
|
79
|
+
items: {
|
|
80
|
+
type: string;
|
|
81
|
+
additionalProperties: boolean;
|
|
82
|
+
properties: Record<string, unknown>;
|
|
83
|
+
required: string[];
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
budget: {
|
|
87
|
+
type: string;
|
|
88
|
+
additionalProperties: boolean;
|
|
89
|
+
properties: Record<string, unknown>;
|
|
90
|
+
required: string[];
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
export class Refusal extends Error {
|
|
3
|
+
code;
|
|
4
|
+
fix;
|
|
5
|
+
constructor(code, fix, message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.fix = fix;
|
|
9
|
+
this.name = 'Refusal';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function refuse(code, fix, message) { throw new Refusal(code, fix, message); }
|
|
13
|
+
export const canonical = (x) => JSON.stringify(x, (_k, v) => typeof v === 'bigint' ? v.toString() : v && typeof v === 'object' && !Array.isArray(v) ? Object.fromEntries(Object.keys(v).sort().map(k => [k, v[k]])) : v);
|
|
14
|
+
export const digest = (x) => createHash('sha256').update(canonical(x)).digest('hex');
|
|
15
|
+
export const revision = (u, laws) => digest({ rule: u.rule, laws });
|
|
16
|
+
function object(v, path, keys) {
|
|
17
|
+
if (!v || typeof v !== 'object' || Array.isArray(v))
|
|
18
|
+
return refuse('invalid-input', `Supply an object at ${path}.`, `${path} must be an object`);
|
|
19
|
+
for (const k of Object.keys(v))
|
|
20
|
+
if (!keys.includes(k))
|
|
21
|
+
refuse('unsupported-field', `Remove ${path}.${k}; supported fields: ${keys.join(', ')}.`, `Unsupported field ${path}.${k}`);
|
|
22
|
+
return v;
|
|
23
|
+
}
|
|
24
|
+
function name(v, path) {
|
|
25
|
+
if (typeof v !== 'string' || !/^[A-Za-z_][A-Za-z0-9_]{0,63}$/.test(v) || v in Object.prototype || v.startsWith('a_') || v.startsWith('b_'))
|
|
26
|
+
return refuse('unsupported-name', `Use a unique ordinary identifier at ${path}, without a_/b_ prefixes or prototype names.`, `Unsupported identifier at ${path}`);
|
|
27
|
+
return v;
|
|
28
|
+
}
|
|
29
|
+
function integer(v, path, min = 0, max = 1_000_000) { if (typeof v !== 'number' || !Number.isSafeInteger(v) || v < min || v > max)
|
|
30
|
+
return refuse('invalid-bound', `Use an integer ${min}..${max} at ${path}.`, `Invalid numeric bound at ${path}`); return v; }
|
|
31
|
+
function names(v, path) { if (!Array.isArray(v) || v.length > 6)
|
|
32
|
+
refuse('unsupported-shape', `Supply at most six names at ${path}.`, `${path} is not a supported scalar name list`); return v.map((x, i) => name(x, `${path}[${i}]`)); }
|
|
33
|
+
function text(v, path) { if (typeof v !== 'string' || !v.length || v.length > 160 || v.split('').some(c => c.charCodeAt(0) < 32))
|
|
34
|
+
refuse('invalid-input', `Supply 1..160 printable characters at ${path}.`, `Invalid text at ${path}`); return v; }
|
|
35
|
+
function expression(v, allowed, path, depth = 0, nodes = { n: 0 }) {
|
|
36
|
+
if (depth > 16 || ++nodes.n > 256)
|
|
37
|
+
refuse('input-budget-exceeded', 'Reduce expression depth to16 and nodes to256.', 'Expression exceeds the structural budget');
|
|
38
|
+
const p = v, op = p?.op;
|
|
39
|
+
const child = (x, k) => expression(x, allowed, `${path}.${k}`, depth + 1, nodes);
|
|
40
|
+
if (op === 'var') {
|
|
41
|
+
object(v, path, ['op', 'name']);
|
|
42
|
+
const n = name(p.name, path + '.name');
|
|
43
|
+
if (!allowed.has(n))
|
|
44
|
+
refuse('unbound-name', `Declare ${n} in the relevant state/parameter/input scope.`, `Unbound name ${n}`);
|
|
45
|
+
return { op, name: n };
|
|
46
|
+
}
|
|
47
|
+
if (op === 'const') {
|
|
48
|
+
object(v, path, ['op', 'value']);
|
|
49
|
+
return { op, value: integer(p.value, path + '.value', 0, Number.MAX_SAFE_INTEGER) };
|
|
50
|
+
}
|
|
51
|
+
if (op === 'add' || op === 'sub' || op === 'min' || op === 'max') {
|
|
52
|
+
object(v, path, ['op', 'a', 'b']);
|
|
53
|
+
return { op, a: child(p.a, 'a'), b: child(p.b, 'b') };
|
|
54
|
+
}
|
|
55
|
+
if (op === 'mul') {
|
|
56
|
+
object(v, path, ['op', 'k', 'a']);
|
|
57
|
+
return { op, k: integer(p.k, path + '.k', 0, 1000), a: child(p.a, 'a') };
|
|
58
|
+
}
|
|
59
|
+
if (op === 'if') {
|
|
60
|
+
object(v, path, ['op', 'c', 'then', 'else']);
|
|
61
|
+
return { op, c: condition(p.c, allowed, path + '.c', depth + 1, nodes), then: child(p.then, 'then'), else: child(p.else, 'else') };
|
|
62
|
+
}
|
|
63
|
+
return refuse('unsupported-expression', 'Use scalar natural var/const/add/sub/min/max/mul/if AST. Functions, maps, code and external calls are not supported by this prototype.', `Unsupported expression at ${path}`);
|
|
64
|
+
}
|
|
65
|
+
function condition(v, allowed, path, depth = 0, nodes = { n: 0 }) {
|
|
66
|
+
if (depth > 16 || ++nodes.n > 256)
|
|
67
|
+
refuse('input-budget-exceeded', 'Reduce condition depth to16 and nodes to256.', 'Condition exceeds the structural budget');
|
|
68
|
+
const p = v, op = p?.op;
|
|
69
|
+
if (op === '<' || op === '<=' || op === '=') {
|
|
70
|
+
object(v, path, ['op', 'a', 'b']);
|
|
71
|
+
return { op, a: expression(p.a, allowed, path + '.a', depth + 1, nodes), b: expression(p.b, allowed, path + '.b', depth + 1, nodes) };
|
|
72
|
+
}
|
|
73
|
+
if (op === 'and' || op === 'or') {
|
|
74
|
+
object(v, path, ['op', 'xs']);
|
|
75
|
+
if (!Array.isArray(p.xs) || p.xs.length > 16)
|
|
76
|
+
refuse('unsupported-shape', 'Use at most16 conditions in xs.', 'Invalid condition list');
|
|
77
|
+
return { op, xs: p.xs.map((x, i) => condition(x, allowed, `${path}.xs[${i}]`, depth + 1, nodes)) };
|
|
78
|
+
}
|
|
79
|
+
if (op === 'not') {
|
|
80
|
+
object(v, path, ['op', 'x']);
|
|
81
|
+
return { op, x: condition(p.x, allowed, path + '.x', depth + 1, nodes) };
|
|
82
|
+
}
|
|
83
|
+
return refuse('unsupported-condition', 'Use scalar comparisons, and/or/not; quantified/maps/functions need a later validated surface.', `Unsupported condition at ${path}`);
|
|
84
|
+
}
|
|
85
|
+
function unit(v, path) {
|
|
86
|
+
const u = object(v, path, ['unit', 'rule']), id = name(u.unit, path + '.unit'), r = object(u.rule, path + '.rule', ['name', 'params', 'inputs', 'state', 'step', 'pre', 'assume']);
|
|
87
|
+
const params = names(r.params, path + '.rule.params'), inputs = names(r.inputs, path + '.rule.inputs'), state = object(r.state, path + '.rule.state', Object.keys((r.state ?? {}))), stateNames = Object.keys(state).map(k => name(k, path + '.rule.state'));
|
|
88
|
+
if (!stateNames.length || stateNames.length > 6 || params.length > 3 || inputs.length > 3)
|
|
89
|
+
refuse('unsupported-shape', 'Use1..6 scalar state fields and at most3 params/inputs.', 'Prototype scalar size exceeded');
|
|
90
|
+
const all = [...params, ...inputs, ...stateNames];
|
|
91
|
+
if (new Set(all).size !== all.length)
|
|
92
|
+
refuse('ambiguous-name', 'Give each state, parameter and input a distinct name.', 'Variable names overlap');
|
|
93
|
+
const step = object(r.step, path + '.rule.step', ['state']), changes = object(step.state, path + '.rule.step.state', stateNames);
|
|
94
|
+
const initial = Object.fromEntries(stateNames.map(k => [k, expression(state[k], new Set(params), `${path}.rule.state.${k}`)]));
|
|
95
|
+
const update = Object.fromEntries(Object.entries(changes).map(([k, x]) => [k, expression(x, new Set(all), `${path}.rule.step.state.${k}`)]));
|
|
96
|
+
return { unit: id, rule: { name: text(r.name, path + '.rule.name'), params, inputs, state: initial, step: { state: update }, ...(r.pre === undefined ? {} : { pre: condition(r.pre, new Set(params), path + '.rule.pre') }), ...(r.assume === undefined ? {} : { assume: condition(r.assume, new Set(all), path + '.rule.assume') }) } };
|
|
97
|
+
}
|
|
98
|
+
function laws(v, u, path) { if (!Array.isArray(v) || v.length < 1 || v.length > 8)
|
|
99
|
+
refuse('invalid-laws', `Supply1..8 named laws at ${path}.`, 'Empty or oversized law list'); const seen = new Set(); return v.map((x, i) => { const p = object(x, `${path}[${i}]`, ['name', 'holds']), n = text(p.name, `${path}[${i}].name`); if (seen.has(n))
|
|
100
|
+
refuse('duplicate-law', 'Use a unique name for each law.', `Repeated law ${n}`); seen.add(n); return { name: n, holds: condition(p.holds, new Set([...u.rule.params, ...Object.keys(u.rule.state)]), `${path}[${i}].holds`) }; }); }
|
|
101
|
+
export function parseRequest(tool, value) {
|
|
102
|
+
if (!['prove', 'why_not', 'suggest', 'check_change', 'status', 'check'].includes(tool))
|
|
103
|
+
refuse('unknown-tool', 'Choose prove, why_not, suggest, check_change, status or check.', 'Unknown tool');
|
|
104
|
+
const t = tool, p = object(value, 'arguments', t === 'check' ? ['file', 'budget'] : t === 'status' ? ['unit', 'revision'] : t === 'check_change' ? ['before', 'after', 'laws', 'budget'] : ['subject', 'laws', 'nearMisses', 'budget']);
|
|
105
|
+
const b = object(p.budget ?? {}, 'budget', ['work', 'apiCalls', 'depth', 'bound', 'candidates']);
|
|
106
|
+
const budget = { work: integer(b.work ?? 500_000, 'budget.work', 0, 5_000_000), apiCalls: integer(b.apiCalls ?? 24, 'budget.apiCalls', 0, 64), depth: integer(b.depth ?? 3, 'budget.depth', 0, 4), bound: integer(b.bound ?? 2, 'budget.bound', 0, 3), candidates: integer(b.candidates ?? 64, 'budget.candidates', 1, 256) };
|
|
107
|
+
if (t === 'check') {
|
|
108
|
+
if (typeof p.file !== 'string' || !p.file.length || p.file.length > 4096 || Array.from(p.file).some(c => c.charCodeAt(0) < 32))
|
|
109
|
+
refuse('invalid-file', 'Supply an absolute local regular-file path under a server-configured root.', 'Invalid workspace file');
|
|
110
|
+
return { tool: t, file: p.file, budget };
|
|
111
|
+
}
|
|
112
|
+
if (t === 'status') {
|
|
113
|
+
const rev = p.revision;
|
|
114
|
+
if (typeof rev !== 'string' || !/^[a-f0-9]{64}$/.test(rev))
|
|
115
|
+
refuse('missing-revision', 'Pass the revision digest returned by prove/check_change.', 'Status requires an exact revision');
|
|
116
|
+
return { tool: t, unit: name(p.unit, 'unit'), revision: rev, budget };
|
|
117
|
+
}
|
|
118
|
+
if (t === 'check_change') {
|
|
119
|
+
const before = unit(p.before, 'before'), after = unit(p.after, 'after');
|
|
120
|
+
if (before.unit !== after.unit || canonical(before.rule.params) !== canonical(after.rule.params) || canonical(before.rule.inputs) !== canonical(after.rule.inputs) || canonical(Object.keys(before.rule.state).sort()) !== canonical(Object.keys(after.rule.state).sort()))
|
|
121
|
+
refuse('unsupported-correspondence', 'Use matching unit/state/parameter/input names; explicit renaming relations are not supported in the prototype.', 'Cannot infer revision correspondence');
|
|
122
|
+
const ls = laws(p.laws, before, 'laws');
|
|
123
|
+
return { tool: t, before, after, laws: ls, budget };
|
|
124
|
+
}
|
|
125
|
+
const subject = unit(p.subject, 'subject'), ls = laws(p.laws, subject, 'laws');
|
|
126
|
+
if (t !== 'suggest' && p.nearMisses !== undefined)
|
|
127
|
+
refuse('unsupported-field', 'Pass nearMisses only to suggest.', 'nearMisses is not valid for this tool');
|
|
128
|
+
return { tool: t, subject, laws: ls, budget, ...(p.nearMisses === undefined ? {} : { nearMisses: laws(p.nearMisses, subject, 'nearMisses') }) };
|
|
129
|
+
}
|
|
130
|
+
export const toolNames = ['prove', 'why_not', 'suggest', 'check_change', 'status', 'check'];
|
|
131
|
+
export const toolDescriptions = { check: 'Execute the CLI engine on Python/plain TypeScript in server-configured trusted roots. Executes project code, not an OS sandbox. No roots means refused.', prove: 'Check scalar natural rule laws with existing kernel proofs; only checked proofs are proven.', why_not: 'Find an existing interpreter-checked shortest counterexample within explicit finite depth/value bounds.', suggest: 'Call inferLaws and check supplied near-miss candidates; return pasteable source and real bounded counterexamples.', check_change: 'Compare two revisions against the same laws and existing compose refinement; distinguish lost proof from a real counterexample.', status: 'Read evidence observed by this process for an exact unit/revision; never trust a caller-supplied label.' };
|
|
132
|
+
// Never silently turn a diagnostic Infinity/NaN into JSON null. Exact integer
|
|
133
|
+
// diagnostics are tagged; inputs still accept only validated natural literals.
|
|
134
|
+
export function wireJSON(value) {
|
|
135
|
+
const encoded = JSON.stringify(value, (_key, v) => {
|
|
136
|
+
if (typeof v === 'number' && !Number.isFinite(v))
|
|
137
|
+
refuse('nonfinite-output', 'Reduce/split the numeric example or use a separately validated exact-number surface.', 'An engine result contains a nonfinite number; no JSON result was published.');
|
|
138
|
+
return typeof v === 'bigint' ? { type: 'bigint', decimal: v.toString() } : v;
|
|
139
|
+
});
|
|
140
|
+
if (encoded === undefined)
|
|
141
|
+
refuse('unsupported-output', 'Request a supported data result.', 'The result is not JSON serializable.');
|
|
142
|
+
return encoded;
|
|
143
|
+
}
|
|
144
|
+
const idSchema = { type: 'string', pattern: '^[A-Za-z_][A-Za-z0-9_]{0,63}$' };
|
|
145
|
+
const obj = (properties, required = Object.keys(properties)) => ({ type: 'object', additionalProperties: false, properties, required });
|
|
146
|
+
const ref = (name) => ({ $ref: `#/$defs/${name}` });
|
|
147
|
+
const defs = {
|
|
148
|
+
term: { oneOf: [obj({ op: { const: 'var' }, name: idSchema }), obj({ op: { const: 'const' }, value: { type: 'integer', minimum: 0, maximum: Number.MAX_SAFE_INTEGER } }), obj({ op: { enum: ['add', 'sub', 'min', 'max'] }, a: ref('term'), b: ref('term') }), obj({ op: { const: 'mul' }, k: { type: 'integer', minimum: 0, maximum: 1000 }, a: ref('term') }), obj({ op: { const: 'if' }, c: ref('condition'), then: ref('term'), else: ref('term') })] },
|
|
149
|
+
condition: { oneOf: [obj({ op: { enum: ['<', '<=', '='] }, a: ref('term'), b: ref('term') }), obj({ op: { enum: ['and', 'or'] }, xs: { type: 'array', maxItems: 16, items: ref('condition') } }), obj({ op: { const: 'not' }, x: ref('condition') })] },
|
|
150
|
+
unit: obj({ unit: idSchema, rule: obj({ name: { type: 'string', minLength: 1, maxLength: 160 }, params: { type: 'array', maxItems: 3, uniqueItems: true, items: idSchema }, inputs: { type: 'array', maxItems: 3, uniqueItems: true, items: idSchema }, state: { type: 'object', minProperties: 1, maxProperties: 6, additionalProperties: ref('term') }, step: obj({ state: { type: 'object', maxProperties: 6, additionalProperties: ref('term') } }), pre: ref('condition'), assume: ref('condition') }, ['name', 'params', 'inputs', 'state', 'step']) }),
|
|
151
|
+
laws: { type: 'array', minItems: 1, maxItems: 8, items: obj({ name: { type: 'string', minLength: 1, maxLength: 160 }, holds: ref('condition') }) },
|
|
152
|
+
budget: obj({ work: { type: 'integer', minimum: 0, maximum: 5000000, default: 500000 }, apiCalls: { type: 'integer', minimum: 0, maximum: 64, default: 24 }, depth: { type: 'integer', minimum: 0, maximum: 4, default: 3 }, bound: { type: 'integer', minimum: 0, maximum: 3, default: 2 }, candidates: { type: 'integer', minimum: 1, maximum: 256, default: 64 } }, []),
|
|
153
|
+
};
|
|
154
|
+
export const inputSchema = (tool) => tool === 'check' ? { $defs: defs, ...obj({ file: { type: 'string', minLength: 1, maxLength: 4096 }, budget: ref('budget') }, ['file']) } : tool === 'status' ? obj({ unit: idSchema, revision: { type: 'string', pattern: '^[a-f0-9]{64}$' } }) : { $defs: defs, ...obj(tool === 'check_change' ? { before: ref('unit'), after: ref('unit'), laws: ref('laws'), budget: ref('budget') } : { subject: ref('unit'), laws: ref('laws'), ...(tool === 'suggest' ? { nearMisses: ref('laws') } : {}), budget: ref('budget') }, tool === 'check_change' ? ['before', 'after', 'laws'] : ['subject', 'laws']) };
|