@miller-tech/uap 1.45.0 → 1.46.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/dist/.tsbuildinfo +1 -1
- package/dist/bin/cli.js +1 -0
- package/dist/bin/cli.js.map +1 -1
- package/dist/cli/deliver.d.ts +2 -0
- package/dist/cli/deliver.d.ts.map +1 -1
- package/dist/cli/deliver.js +27 -1
- package/dist/cli/deliver.js.map +1 -1
- package/dist/delivery/snapshot.d.ts +15 -0
- package/dist/delivery/snapshot.d.ts.map +1 -0
- package/dist/delivery/snapshot.js +37 -0
- package/dist/delivery/snapshot.js.map +1 -0
- package/dist/delivery/verifier-ladder.d.ts +5 -0
- package/dist/delivery/verifier-ladder.d.ts.map +1 -1
- package/dist/delivery/verifier-ladder.js +84 -11
- package/dist/delivery/verifier-ladder.js.map +1 -1
- package/package.json +1 -1
- package/src/policies/enforcers/__pycache__/_common.cpython-312.pyc +0 -0
- package/tools/agents/deliver_hybrid_agent.py +71 -0
- package/tools/agents/opencode_uap_agent.py +1 -19
- package/tools/agents/plugins/uap-enforce.ts +8 -45
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* ecosystems can pass explicit rungs.
|
|
12
12
|
*/
|
|
13
13
|
import { spawnSync } from 'child_process';
|
|
14
|
-
import { existsSync, readFileSync } from 'fs';
|
|
14
|
+
import { existsSync, readFileSync, readdirSync } from 'fs';
|
|
15
15
|
import { join } from 'path';
|
|
16
16
|
const DEFAULT_TIMEOUT_MS = 300_000;
|
|
17
17
|
const DEFAULT_TAIL_CHARS = 2_000;
|
|
@@ -34,19 +34,18 @@ function sanitizedEnv() {
|
|
|
34
34
|
* feedback arrives fast.
|
|
35
35
|
*/
|
|
36
36
|
export function detectRungs(projectRoot, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
37
|
+
const rungs = [];
|
|
37
38
|
const pkgPath = join(projectRoot, 'package.json');
|
|
38
|
-
if (!existsSync(pkgPath)) {
|
|
39
|
-
return [];
|
|
40
|
-
}
|
|
41
39
|
let scripts = {};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
if (existsSync(pkgPath)) {
|
|
41
|
+
try {
|
|
42
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
43
|
+
scripts = pkg.scripts ?? {};
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
scripts = {};
|
|
47
|
+
}
|
|
48
48
|
}
|
|
49
|
-
const rungs = [];
|
|
50
49
|
if (scripts['build']) {
|
|
51
50
|
rungs.push({
|
|
52
51
|
id: 'build',
|
|
@@ -91,6 +90,80 @@ export function detectRungs(projectRoot, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
|
91
90
|
timeoutMs,
|
|
92
91
|
});
|
|
93
92
|
}
|
|
93
|
+
// Non-npm projects (the common case for polyglot CLI tasks) expose their
|
|
94
|
+
// checks differently. Detect the real ones so deliver gates on the task's
|
|
95
|
+
// own verifier instead of a hallucinated self-gate.
|
|
96
|
+
if (rungs.length === 0) {
|
|
97
|
+
rungs.push(...detectNonNpmRungs(projectRoot, timeoutMs));
|
|
98
|
+
}
|
|
99
|
+
return rungs;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Detect real gates in non-npm projects: a Makefile test/check/build target,
|
|
103
|
+
* a pytest suite, or a conventional shell test script. Ordered cheap→expensive.
|
|
104
|
+
*/
|
|
105
|
+
export function detectNonNpmRungs(projectRoot, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
106
|
+
const rungs = [];
|
|
107
|
+
const has = (p) => existsSync(join(projectRoot, p));
|
|
108
|
+
// Makefile — prefer a test/check target, else the default build target.
|
|
109
|
+
const makefile = ['Makefile', 'makefile', 'GNUmakefile'].find((m) => has(m));
|
|
110
|
+
if (makefile) {
|
|
111
|
+
let target = null;
|
|
112
|
+
try {
|
|
113
|
+
const body = readFileSync(join(projectRoot, makefile), 'utf-8');
|
|
114
|
+
if (/^test\s*:/m.test(body))
|
|
115
|
+
target = 'test';
|
|
116
|
+
else if (/^check\s*:/m.test(body))
|
|
117
|
+
target = 'check';
|
|
118
|
+
else if (/^(all|build)\s*:/m.test(body))
|
|
119
|
+
target = null; // default goal
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
/* unreadable Makefile — fall back to default goal */
|
|
123
|
+
}
|
|
124
|
+
rungs.push({
|
|
125
|
+
id: 'make',
|
|
126
|
+
name: `Make (${target ? `make ${target}` : 'make'})`,
|
|
127
|
+
command: 'make',
|
|
128
|
+
args: target ? [target] : [],
|
|
129
|
+
required: true,
|
|
130
|
+
timeoutMs,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
// pytest — only when there are actual test files (an empty suite exits 5).
|
|
134
|
+
let hasPyTests = has('tests') || has('test');
|
|
135
|
+
if (!hasPyTests) {
|
|
136
|
+
try {
|
|
137
|
+
hasPyTests = readdirSync(projectRoot).some((f) => /^test_.*\.py$|.*_test\.py$/.test(f));
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
/* unreadable dir */
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (hasPyTests && rungs.length === 0) {
|
|
144
|
+
rungs.push({
|
|
145
|
+
id: 'pytest',
|
|
146
|
+
name: 'Tests (pytest)',
|
|
147
|
+
command: 'python3',
|
|
148
|
+
args: ['-m', 'pytest', '-q'],
|
|
149
|
+
required: true,
|
|
150
|
+
timeoutMs,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
// Conventional shell test/check scripts (NOT deliver's own .uap-deliver gate).
|
|
154
|
+
if (rungs.length === 0) {
|
|
155
|
+
const script = ['run_tests.sh', 'run-tests.sh', 'test.sh', 'tests.sh', 'check.sh'].find((s) => has(s));
|
|
156
|
+
if (script) {
|
|
157
|
+
rungs.push({
|
|
158
|
+
id: 'script',
|
|
159
|
+
name: `Script (bash ${script})`,
|
|
160
|
+
command: 'bash',
|
|
161
|
+
args: [script],
|
|
162
|
+
required: true,
|
|
163
|
+
timeoutMs,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
94
167
|
return rungs;
|
|
95
168
|
}
|
|
96
169
|
function truncateTail(text, maxChars) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifier-ladder.js","sourceRoot":"","sources":["../../src/delivery/verifier-ladder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"verifier-ladder.js","sourceRoot":"","sources":["../../src/delivery/verifier-ladder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAwD5B,MAAM,kBAAkB,GAAG,OAAO,CAAC;AACnC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAEjC;;qEAEqE;AACrE,MAAM,aAAa,GAAG,6CAA6C,CAAC;AAEpE,SAAS,YAAY;IACnB,MAAM,GAAG,GAAsB,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;IAC9C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvD,IAAI,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC;YAAE,SAAS;QACtC,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACnB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WA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Q,IAAI,QAAQ,EAAE,CAAC;YAChD,IAAI,GAAG,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;IAC3D,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhE,sEAAsE;IACtE,wCAAwC;IACxC,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IACtD,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CACnC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAClE,CAAC,MAAM,CAAC;IACT,MAAM,MAAM,GAAG,cAAc,KAAK,aAAa,CAAC,MAAM,CAAC;IAEvD,OAAO;QACL,MAAM;QACN,KAAK;QACL,OAAO;QACP,QAAQ,EAAE,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC;KACzC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Deliver-hybrid harbor agent: opencode solves, then `uap deliver` repairs —
|
|
3
|
+
never regressing.
|
|
4
|
+
|
|
5
|
+
Empirically, deliver-as-the-sole-solver underperforms a strong agentic baseline
|
|
6
|
+
on a hidden-verifier benchmark (its self-gate is a misleading proxy). This agent
|
|
7
|
+
instead makes deliver STRICTLY ADDITIVE:
|
|
8
|
+
|
|
9
|
+
1. opencode (the strong baseline harness) solves the task — this is the floor.
|
|
10
|
+
2. `uap deliver --no-self-gate --keep-best` runs an agentic repair pass against
|
|
11
|
+
the project's REAL detected gates (Makefile/pytest/test-script/npm). With
|
|
12
|
+
no real gate it no-ops and opencode's output stands; with a real gate it can
|
|
13
|
+
only improve the gate score (`--keep-best` rolls back any regression).
|
|
14
|
+
|
|
15
|
+
So the result is >= baseline by construction, and beats it where a detectable
|
|
16
|
+
gate was left failing and deliver repairs it.
|
|
17
|
+
|
|
18
|
+
Run:
|
|
19
|
+
harbor run -d terminal-bench@2.0 \
|
|
20
|
+
--agent-import-path tools.agents.deliver_hybrid_agent:DeliverHybrid ...
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
from __future__ import annotations
|
|
24
|
+
|
|
25
|
+
import shlex
|
|
26
|
+
|
|
27
|
+
from harbor.agents.installed.base import ExecInput
|
|
28
|
+
from harbor.environments.base import BaseEnvironment
|
|
29
|
+
from harbor.models.agent.context import AgentContext
|
|
30
|
+
|
|
31
|
+
from tools.agents.opencode_uap_agent import OpenCodeUAP, logger
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class DeliverHybrid(OpenCodeUAP):
|
|
35
|
+
"""opencode solves; `uap deliver --keep-best` repairs against real gates."""
|
|
36
|
+
|
|
37
|
+
@staticmethod
|
|
38
|
+
def name() -> str:
|
|
39
|
+
return "deliver-hybrid"
|
|
40
|
+
|
|
41
|
+
# Single execution — the opencode retry-on-zero-tools logic would also
|
|
42
|
+
# re-run the appended deliver-repair step, which is wasteful.
|
|
43
|
+
async def run(
|
|
44
|
+
self,
|
|
45
|
+
instruction: str,
|
|
46
|
+
environment: BaseEnvironment,
|
|
47
|
+
context: AgentContext,
|
|
48
|
+
) -> None:
|
|
49
|
+
await self._execute_run(instruction, environment, context, attempt=0)
|
|
50
|
+
self.populate_context_post_run(context)
|
|
51
|
+
|
|
52
|
+
def create_run_agent_commands(self, instruction: str) -> list[ExecInput]:
|
|
53
|
+
# Stage 1: the full opencode solve (baseline floor).
|
|
54
|
+
commands = super().create_run_agent_commands(instruction)
|
|
55
|
+
|
|
56
|
+
# Stage 2: deliver repair against REAL gates only, never regressing.
|
|
57
|
+
# --no-self-gate: do NOT invent a proxy gate; if no real gate is
|
|
58
|
+
# detected, deliver exits non-zero and `|| true` keeps opencode's work.
|
|
59
|
+
# --keep-best: snapshot first; roll back if the real-gate score drops.
|
|
60
|
+
escaped = shlex.quote(instruction)
|
|
61
|
+
endpoint = self._api_endpoint
|
|
62
|
+
repair = (
|
|
63
|
+
"source $HOME/.nvm/nvm.sh && cd /app && "
|
|
64
|
+
f"UAP_DELIVER_ACTIVE=1 uap deliver {escaped} "
|
|
65
|
+
f"--project-root /app --endpoint {endpoint} --model qwen35-a3b "
|
|
66
|
+
"--executor agentic --no-self-gate --keep-best --max-turns 4 --no-until-delivered "
|
|
67
|
+
"2>&1 | tee /logs/agent/uap-deliver-repair.txt || true"
|
|
68
|
+
)
|
|
69
|
+
logger.info("[DeliverHybrid] appending deliver repair pass (real gates, --keep-best)")
|
|
70
|
+
commands.append(ExecInput(command=repair))
|
|
71
|
+
return commands
|
|
@@ -1409,14 +1409,7 @@ class OpenCodeUAP(BaseInstalledAgent):
|
|
|
1409
1409
|
def create_run_agent_commands(self, instruction: str) -> list[ExecInput]:
|
|
1410
1410
|
model = self.model_name or "llama.cpp/qwen35-a3b-iq4xs"
|
|
1411
1411
|
|
|
1412
|
-
env = {
|
|
1413
|
-
"OPENCODE_FAKE_VCS": "git",
|
|
1414
|
-
# Transparent delivery: the uap-enforce plugin reads these to run
|
|
1415
|
-
# the `uap deliver` convergence loop on the first source edit.
|
|
1416
|
-
"UAP_DELIVER_ENDPOINT": self._api_endpoint,
|
|
1417
|
-
"UAP_DELIVER_MODEL": os.environ.get("UAP_DELIVER_MODEL", "qwen35-a3b"),
|
|
1418
|
-
"UAP_ENFORCE_DELIVERY": os.environ.get("UAP_ENFORCE_DELIVERY", "block"),
|
|
1419
|
-
}
|
|
1412
|
+
env = {"OPENCODE_FAKE_VCS": "git"}
|
|
1420
1413
|
|
|
1421
1414
|
# --- Step 0: Build classified CLAUDE.md and enhanced instruction ---
|
|
1422
1415
|
classified_claude_md = build_classified_claude_md(instruction)
|
|
@@ -1542,17 +1535,6 @@ class OpenCodeUAP(BaseInstalledAgent):
|
|
|
1542
1535
|
# --- Step 5: Environment bootstrapping ---
|
|
1543
1536
|
commands.append(ExecInput(command=ENV_BOOTSTRAP_CMD))
|
|
1544
1537
|
|
|
1545
|
-
# --- Step 5b: Stage raw task instruction for transparent delivery ---
|
|
1546
|
-
# The uap-enforce plugin reads /app/.uap-deliver/task.txt to seed the
|
|
1547
|
-
# `uap deliver` convergence loop on the first source edit.
|
|
1548
|
-
task_b64 = base64.b64encode(instruction.encode()).decode()
|
|
1549
|
-
deliver_task_cmd = (
|
|
1550
|
-
"mkdir -p /app/.uap-deliver && "
|
|
1551
|
-
f"echo '{task_b64}' | base64 -d > /app/.uap-deliver/task.txt && "
|
|
1552
|
-
"echo '[Deliver] task instruction staged for transparent delivery'"
|
|
1553
|
-
)
|
|
1554
|
-
commands.append(ExecInput(command=deliver_task_cmd))
|
|
1555
|
-
|
|
1556
1538
|
# --- Step 6: Run opencode with enhanced instruction ---
|
|
1557
1539
|
# opencode.json baseURL points to proxy at http://127.0.0.1:11435/v1
|
|
1558
1540
|
# which injects tool_choice="required" and forwards to the real LLM
|
|
@@ -41,11 +41,6 @@ export const UapEnforce: Plugin = async ({ $ }) => {
|
|
|
41
41
|
let totalToolCalls = 0;
|
|
42
42
|
const SOFT_BUDGET = 30;
|
|
43
43
|
|
|
44
|
-
// Transparent delivery: the first substantive source edit triggers the
|
|
45
|
-
// `uap deliver` convergence loop ONCE per session. Guarded so it never
|
|
46
|
-
// re-enters or fires per-edit.
|
|
47
|
-
let deliverRan = false;
|
|
48
|
-
|
|
49
44
|
const TELEMETRY_PATH = '/tmp/uap-telemetry.jsonl';
|
|
50
45
|
|
|
51
46
|
const simpleHash = (s: string): string => {
|
|
@@ -65,46 +60,14 @@ export const UapEnforce: Plugin = async ({ $ }) => {
|
|
|
65
60
|
'tool.execute.before': async (input, output) => {
|
|
66
61
|
totalToolCalls++;
|
|
67
62
|
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
//
|
|
76
|
-
if (
|
|
77
|
-
!deliverRan &&
|
|
78
|
-
(input.tool === 'write' || input.tool === 'edit') &&
|
|
79
|
-
process.env.UAP_ENFORCE_DELIVERY !== 'advisory' &&
|
|
80
|
-
!process.env.UAP_DELIVER_BYPASS
|
|
81
|
-
) {
|
|
82
|
-
deliverRan = true; // set first — prevents re-entry / per-edit loops
|
|
83
|
-
try {
|
|
84
|
-
const endpoint = process.env.UAP_DELIVER_ENDPOINT || '';
|
|
85
|
-
const model = process.env.UAP_DELIVER_MODEL || 'qwen35-a3b';
|
|
86
|
-
const endpointArg = endpoint ? `--endpoint ${endpoint}` : '';
|
|
87
|
-
const deliverScript =
|
|
88
|
-
'source $HOME/.nvm/nvm.sh 2>/dev/null || true; ' +
|
|
89
|
-
'TASK="$(cat /app/.uap-deliver/task.txt 2>/dev/null)"; ' +
|
|
90
|
-
'if [ -n "$TASK" ] && command -v uap >/dev/null 2>&1; then ' +
|
|
91
|
-
`echo "[Deliver] converging via uap deliver (model ${model})..."; ` +
|
|
92
|
-
`UAP_DELIVER_ACTIVE=1 uap deliver "$TASK" ${endpointArg} --model ${model} ` +
|
|
93
|
-
'--project-root /app --max-turns 5 --no-until-delivered ' +
|
|
94
|
-
'> /logs/agent/uap-deliver.log 2>&1 || true; ' +
|
|
95
|
-
'echo "[Deliver] convergence loop finished"; ' +
|
|
96
|
-
'else echo "[Deliver] skipped (no task file or uap CLI absent)"; fi';
|
|
97
|
-
await $`bash -lc ${deliverScript}`.nothrow();
|
|
98
|
-
await $`echo ${JSON.stringify(
|
|
99
|
-
JSON.stringify({ event: 'transparent_deliver', tool: input.tool, ts: new Date().toISOString() })
|
|
100
|
-
)} >> ${TELEMETRY_PATH}`
|
|
101
|
-
.quiet()
|
|
102
|
-
.nothrow();
|
|
103
|
-
} catch {
|
|
104
|
-
/* fail open — let the original edit proceed */
|
|
105
|
-
}
|
|
106
|
-
// fall through: the agent's own edit still executes
|
|
107
|
-
}
|
|
63
|
+
// NOTE: a transparent "run `uap deliver` on the first edit" trigger was
|
|
64
|
+
// trialed here and REMOVED. Benchmarking showed it net-harmful: it ran a
|
|
65
|
+
// heavyweight second agent (the deliver convergence loop) against a
|
|
66
|
+
// self-authored PROXY gate that does not match the task's hidden verifier,
|
|
67
|
+
// mutating the workspace and corrupting tasks plain opencode solved
|
|
68
|
+
// (e.g. openssl-selfsigned-cert regressed; 4/6 -> 2/6). deliver's
|
|
69
|
+
// self-gate + agentic executor remain valuable as a STANDALONE `uap
|
|
70
|
+
// deliver` invocation, just not as a per-edit parasite on the agent loop.
|
|
108
71
|
|
|
109
72
|
// --- Worktree enforcement (Layer 4) ---
|
|
110
73
|
// Warn when file writes happen outside a worktree
|