@aliip/pilah 0.0.0-stage → 1.0.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.
- package/BUILD_STATUS.md +23 -0
- package/LICENSE +21 -0
- package/README.md +108 -2
- package/assets/logo.svg +5 -0
- package/docs/ACCEPTANCE_GATE.md +41 -0
- package/docs/ADAPTIVE_RCA_WORKFLOW.md +93 -0
- package/docs/AGENT_DECISION_REVIEW.md +17 -0
- package/docs/ALWAYS_ON_5_WHYS.md +75 -0
- package/docs/ARCHITECTURE.md +43 -0
- package/docs/BEHAVIORAL_5_WHYS_V2_0_1.md +117 -0
- package/docs/CHECKPOINT_RECOVERY.md +86 -0
- package/docs/CI_EFFICIENCY.md +63 -0
- package/docs/COMPATIBILITY.md +84 -0
- package/docs/CONTRACTS.md +177 -0
- package/docs/CONVERSATION_USAGE.md +52 -0
- package/docs/ENGINEERING_METHOD.md +68 -0
- package/docs/HOST_VALIDATION.md +35 -0
- package/docs/INDEPENDENT_ACCEPTANCE_RUNBOOK.md +72 -0
- package/docs/INTERVENTION_LEDGER.md +25 -0
- package/docs/MAIN_VALIDATION_BACKLOG.md +19 -0
- package/docs/NATIVE_FIRST_WORKFLOW.md +27 -0
- package/docs/OPEN_SOURCE_ENGINEERING_STANDARDS.md +62 -0
- package/docs/ORCHESTRATION_ADVISOR.md +36 -0
- package/docs/PRE_VNEXT_INTEGRATION.md +27 -0
- package/docs/README.md +54 -0
- package/docs/RELEASE.md +33 -0
- package/docs/RELEASE_AUTHORIZATION.md +33 -0
- package/docs/RISK_GUIDANCE.md +18 -0
- package/docs/SECURITY.md +76 -0
- package/docs/SECURITY_RELIABILITY_AUDIT_V2_0_1.md +55 -0
- package/docs/SEMANTIC_EVIDENCE.md +27 -0
- package/docs/SOURCES.md +13 -0
- package/docs/TOKEN_EFFICIENCY.md +71 -0
- package/docs/TOKEN_PROVENANCE.md +15 -0
- package/docs/V2_0_1_TRACEABILITY.md +66 -0
- package/hooks.json +45 -0
- package/mcp_config.json +16 -0
- package/package.json +31 -4
- package/plugin.json +27 -0
- package/rules/AGENTS.md +2 -0
- package/schemas/database.sql +84 -0
- package/schemas/mcp-tools.json +552 -0
- package/scripts/a2a.mjs +344 -0
- package/scripts/check-release.mjs +42 -0
- package/scripts/check-syntax.mjs +30 -0
- package/scripts/checkpoint.mjs +50 -0
- package/scripts/compare-agent-traces.mjs +53 -0
- package/scripts/context-guardian.mjs +132 -0
- package/scripts/evaluate-acceptance.mjs +110 -0
- package/scripts/export-benchmark.mjs +31 -0
- package/scripts/generate-contracts.mjs +6 -0
- package/scripts/hook.mjs +406 -0
- package/scripts/host-check.mjs +40 -0
- package/scripts/intervention-ledger.mjs +94 -0
- package/scripts/pilah.mjs +3 -0
- package/scripts/release-authorization.mjs +137 -0
- package/scripts/review-agent-decisions.mjs +34 -0
- package/scripts/semantic-evidence.mjs +15 -0
- package/scripts/verifykit.mjs +3 -0
- package/skills/pilah/SKILL.md +24 -0
- package/src/acceptance-matrix.mjs +84 -0
- package/src/browser-evidence.mjs +40 -0
- package/src/context-health.mjs +14 -0
- package/src/conversations.mjs +302 -0
- package/src/engine.mjs +494 -0
- package/src/graph.mjs +169 -0
- package/src/mcp-diagnostics.mjs +53 -0
- package/src/mcp.mjs +151 -0
- package/src/model-recovery.mjs +108 -0
- package/src/native-tool-recovery.mjs +45 -0
- package/src/node-runtime.mjs +13 -0
- package/src/orchestration-advisor.mjs +24 -0
- package/src/rca.mjs +174 -0
- package/src/risk-guidance.mjs +95 -0
- package/src/scanner.mjs +303 -0
- package/src/security.mjs +793 -0
- package/src/semantic-evidence.mjs +144 -0
- package/src/skill-discovery.mjs +23 -0
- package/src/sqlite-compat.mjs +11 -0
- package/src/storage.mjs +455 -0
- package/src/tokens.mjs +627 -0
- package/src/tools.mjs +164 -0
- package/src/verification.mjs +567 -0
- package/src/workflow-router.mjs +34 -0
package/src/tools.mjs
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
const string={type:'string',maxLength:240};
|
|
2
|
+
const identifier={type:'string',maxLength:160};
|
|
3
|
+
const ws={type:'string',maxLength:1024};
|
|
4
|
+
const paths={type:'array',items:{type:'string',maxLength:500},maxItems:200};
|
|
5
|
+
|
|
6
|
+
const BASE_SPECS = [
|
|
7
|
+
{
|
|
8
|
+
name:'context',
|
|
9
|
+
description:'Scoped project symbols and file relations; static only.',
|
|
10
|
+
inputSchema:{
|
|
11
|
+
type:'object',
|
|
12
|
+
additionalProperties:false,
|
|
13
|
+
required:['workspace'],
|
|
14
|
+
properties:{
|
|
15
|
+
workspace:ws,
|
|
16
|
+
action:{type:'string',enum:['inspect','query','freshness','tokens','skeleton','orchestration'],default:'inspect'},
|
|
17
|
+
task:{type:'object',description:'Native advice only; launches nothing.',additionalProperties:false,properties:{tier:{type:'string',enum:['free','pro','ultra','paid-other','unknown']},available_commands:{type:'array',items:{type:'string',enum:['/swarm','/teamwork','/boost','@subagent']},maxItems:4},workstreams:{type:'array',items:{type:'string',maxLength:120},maxItems:30},dependencies:{type:'string',enum:['low','high','unknown']},milestones:{type:'integer',minimum:0,maximum:100},long_horizon:{type:'boolean'},hard_reasoning:{type:'boolean'},file_ownership:{type:'string',enum:['independent','shared','unknown']}}},
|
|
18
|
+
query:{type:'string',maxLength:160},
|
|
19
|
+
limit:{type:'integer',minimum:1,maximum:40},
|
|
20
|
+
history_scope:{type:'string',enum:['current','all'],},
|
|
21
|
+
history_limit:{type:'integer',minimum:1,maximum:10,},
|
|
22
|
+
file:{type:'string',maxLength:500,},
|
|
23
|
+
files:{type:'array',items:{type:'string',maxLength:500},maxItems:20,}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name:'impact',
|
|
29
|
+
description:'Static impact and candidate tests; not proof.',
|
|
30
|
+
inputSchema:{type:'object',additionalProperties:false,required:['workspace'],properties:{workspace:ws,changed:paths,depth:{type:'integer',minimum:1,maximum:4},summary:{type:'boolean',}}}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name:'verify',
|
|
34
|
+
description:'Local tests/evidence; not release proof.',
|
|
35
|
+
inputSchema:{type:'object',additionalProperties:false,required:['workspace','operation'],properties:{workspace:ws,operation:{type:'string',enum:['plan','assess','verify_handoff','assess_release','assess_semantic','assess_browser']},changed:paths,worker_name:{type:'string',maxLength:128,},artifact:{type:'string',maxLength:500,},allow_stale:{type:'boolean',description:'No-op: stale reports never pass.'},persist_plan:{type:'boolean',description:'Opt-in, revision-pinned plan.'},plan_id:{type:'string',maxLength:120,},criteria:{type:'array',maxItems:40,items:{oneOf:[string,{type:'object',additionalProperties:false,required:['id'],properties:{id:{type:'string',maxLength:160},description:{type:'string',maxLength:160},given:{type:'string',maxLength:200},when:{type:'string',maxLength:200},then:{type:'string',maxLength:200},evidence_type:{type:'string',enum:['build','unit','integration','browser','visual','hardware','security','independent']},viewport:{type:'string',maxLength:160},ui_state:{type:'string',maxLength:160},reference:{type:'string',maxLength:160},negative:{type:'boolean'},source_revision:{type:'string',maxLength:160},artifact:{type:'string',maxLength:500},test_name:{type:'string',maxLength:160,description:'Exact test; * is legacy only.'},blocked:{type:'boolean'},reason:{type:'string',maxLength:240}}}]}}}}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name:'evidence',
|
|
39
|
+
description:'Local incidents, RCA, history and artifacts.',
|
|
40
|
+
inputSchema:{
|
|
41
|
+
type:'object',
|
|
42
|
+
additionalProperties:false,
|
|
43
|
+
required:['workspace','operation'],
|
|
44
|
+
properties:{
|
|
45
|
+
workspace:ws,
|
|
46
|
+
operation:{type:'string',enum:['list','runs','incidents','record_incident','add_hypothesis','assess_hypothesis','hypotheses','delete_incident','side_questions','record_side_question','artifact_versions','artifact_diff','snapshot_artifact','save_checkpoint','model_recovery','tool_recovery']},
|
|
47
|
+
id:identifier,
|
|
48
|
+
limit:{type:'integer',minimum:1,maximum:50},
|
|
49
|
+
title:{type:'string',maxLength:240},
|
|
50
|
+
root_cause:{type:'string',maxLength:1400},
|
|
51
|
+
paths,
|
|
52
|
+
criteria:{type:'array',items:string,maxItems:40},
|
|
53
|
+
evidence_ids:{type:'array',items:identifier,maxItems:20},
|
|
54
|
+
hypothesis:{type:'string',maxLength:1000},
|
|
55
|
+
experiment:{type:'string',maxLength:1000},
|
|
56
|
+
incident_id:identifier,
|
|
57
|
+
persist_rca:{type:'boolean',description:'Opt-in local private RCA retention.'},
|
|
58
|
+
confirm_deletion:{type:'boolean',description:'Confirm logical removal; not secure erasure.'},
|
|
59
|
+
hypothesis_id:{type:'string',maxLength:128,},
|
|
60
|
+
parent_hypothesis_id:{type:'string',maxLength:128,},
|
|
61
|
+
predicted_observation:{type:'string',maxLength:300,},
|
|
62
|
+
disconfirming_test:{type:'string',maxLength:300,},
|
|
63
|
+
expected_criterion_id:{type:'string',maxLength:160,description:'Named test only, not causal proof.'},
|
|
64
|
+
plan_id:{type:'string',maxLength:120,},
|
|
65
|
+
experiment_outcome:{type:'string',enum:['supports','refutes','inconclusive'],description:'Agent report; not independent proof.'},
|
|
66
|
+
observation:{type:'string',maxLength:400,},
|
|
67
|
+
conversation_id:{type:'string',maxLength:128},
|
|
68
|
+
parent_conversation_id:{type:'string',maxLength:128},
|
|
69
|
+
question:{type:'string',maxLength:4000},
|
|
70
|
+
summary:{type:'string',maxLength:4000},
|
|
71
|
+
status:{type:'string',maxLength:40},
|
|
72
|
+
task_summary:{type:'string',maxLength:500,},
|
|
73
|
+
completed:{type:'array',maxItems:8,items:{type:'string',maxLength:200},},
|
|
74
|
+
next_steps:{type:'array',maxItems:8,items:{type:'string',maxLength:200},},
|
|
75
|
+
decisions:{type:'array',maxItems:8,items:{type:'string',maxLength:200},},
|
|
76
|
+
pending_tests:{type:'array',maxItems:8,items:{type:'string',maxLength:200},},
|
|
77
|
+
tool_family:{type:'string',enum:['mcp','browser','filesystem','terminal','other']},
|
|
78
|
+
error_hint:{type:'string',maxLength:400,},
|
|
79
|
+
error_class:{type:'string',enum:['invalid_arguments','context_lost','timeout','permission_denied','missing_file','edit_conflict','unknown']},
|
|
80
|
+
retry_count:{type:'integer',minimum:0,maximum:20},
|
|
81
|
+
artifact_name:{type:'string',maxLength:240},
|
|
82
|
+
artifact_path:{type:'string',maxLength:500},
|
|
83
|
+
v1:{type:'integer',minimum:0},
|
|
84
|
+
v2:{type:'integer',minimum:1}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
export const TOOLS = BASE_SPECS.map(s => ({name: `pilah_${s.name}`, description: s.description, inputSchema: s.inputSchema}));
|
|
91
|
+
// Compatibility aliases are callable, but never exposed by default to the model.
|
|
92
|
+
export const A2A_COMPAT_TOOLS = BASE_SPECS.map(s => ({name: `a2a_${s.name}`, description: s.description, inputSchema: s.inputSchema}));
|
|
93
|
+
export const LEGACY_TOOLS = BASE_SPECS.map(s => ({name: `verifykit_${s.name}`, description: s.description, inputSchema: s.inputSchema}));
|
|
94
|
+
export const ALL_TOOLS = [...TOOLS, ...A2A_COMPAT_TOOLS, ...LEGACY_TOOLS];
|
|
95
|
+
export const TOOL_NAMES = new Set(ALL_TOOLS.map(x=>x.name));
|
|
96
|
+
export function getListedTools() {
|
|
97
|
+
return process.env.A2A_LEGACY_TOOL_ALIASES === '1' ? ALL_TOOLS : TOOLS;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function validateValue(spec, value, key) {
|
|
101
|
+
if (!spec || typeof spec !== 'object') return;
|
|
102
|
+
if (Array.isArray(spec.oneOf)) {
|
|
103
|
+
let matched = false;
|
|
104
|
+
for (const sub of spec.oneOf) {
|
|
105
|
+
try { validateValue(sub, value, key); matched = true; break; } catch {}
|
|
106
|
+
}
|
|
107
|
+
if (!matched) throw new Error('Invalid item: ' + key);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const kind = spec.type;
|
|
111
|
+
if (kind === 'string') {
|
|
112
|
+
if (typeof value !== 'string') throw new Error('Invalid type: ' + key);
|
|
113
|
+
if (spec.enum && !spec.enum.includes(value)) throw new Error('Invalid value: ' + key);
|
|
114
|
+
if (spec.maxLength && value.length > spec.maxLength) throw new Error('Value too long: ' + key);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (kind === 'integer') {
|
|
118
|
+
if (!Number.isInteger(value) || (spec.minimum !== undefined && value < spec.minimum) || (spec.maximum !== undefined && value > spec.maximum)) {
|
|
119
|
+
throw new Error('Invalid integer: ' + key);
|
|
120
|
+
}
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (kind === 'boolean') {
|
|
124
|
+
if (typeof value !== 'boolean') throw new Error('Invalid boolean: ' + key);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (kind === 'object') {
|
|
128
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error('Invalid object: ' + key);
|
|
129
|
+
const props = spec.properties || {};
|
|
130
|
+
if (spec.additionalProperties === false) {
|
|
131
|
+
for (const k of Object.keys(value)) {
|
|
132
|
+
if (!Object.hasOwn(props,k)) throw new Error('Unknown argument: ' + key + '.' + k);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
for (const req of spec.required || []) {
|
|
136
|
+
if (value[req] === undefined) throw new Error('Missing ' + key + '.' + req);
|
|
137
|
+
}
|
|
138
|
+
for (const [k, v] of Object.entries(value)) {
|
|
139
|
+
if (Object.hasOwn(props,k)) validateValue(props[k], v, key + '.' + k);
|
|
140
|
+
}
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (kind === 'array') {
|
|
144
|
+
if (!Array.isArray(value) || (spec.maxItems !== undefined && value.length > spec.maxItems)) {
|
|
145
|
+
throw new Error('Invalid array: ' + key);
|
|
146
|
+
}
|
|
147
|
+
if (spec.items) {
|
|
148
|
+
for (let i = 0; i < value.length; i++) {
|
|
149
|
+
validateValue(spec.items, value[i], `${key}[${i}]`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export function validateArgs(name,args){
|
|
156
|
+
const tool=ALL_TOOLS.find(t=>t.name===name);if(!tool)throw new Error('Unknown tool');
|
|
157
|
+
if(!args||typeof args!=='object'||Array.isArray(args))throw new Error('Arguments must be an object');
|
|
158
|
+
const props=tool.inputSchema.properties;
|
|
159
|
+
for(const key of Object.keys(args))if(!Object.hasOwn(props,key))throw new Error('Unknown argument: '+key);
|
|
160
|
+
for(const key of tool.inputSchema.required||[])if(args[key]===undefined)throw new Error('Missing '+key);
|
|
161
|
+
for(const [key,value] of Object.entries(args)){
|
|
162
|
+
validateValue(props[key], value, key);
|
|
163
|
+
}
|
|
164
|
+
}
|