@miller-tech/uap 1.43.3 → 1.45.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"self-gate.js","sourceRoot":"","sources":["../../src/delivery/self-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAI5B,MAAM,QAAQ,GAAG,cAAc,CAAC;AAChC,MAAM,SAAS,GAAG,WAAW,CAAC;AAC9B,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAsBnC,4EAA4E;AAC5E,MAAM,UAAU,aAAa,CAAC,WAAmB;IAC/C,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC3E,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC;IACrD,oEAAoE;IACpE,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAClC,OAAO,wBAAwB,IAAI,EAAE,CAAC;AACxC,CAAC;AAED,SAAS,iBAAiB,CACxB,WAAmB,EACnB,WAAmB,EACnB,aAA4B;IAE5B,MAAM,KAAK,GAAG,aAAa;QACzB,CAAC,CAAC,kDAAkD,aAAa,yEAAyE;QAC1I,CAAC,CAAC,EAAE,CAAC;IACP,OAAO;QACL,uEAAuE;QACvE,EAAE;QACF,UAAU,WAAW,EAAE;QACvB,EAAE;QACF,iBAAiB,WAAW,EAAE;QAC9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AC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miller-tech/uap",
3
- "version": "1.43.3",
3
+ "version": "1.45.0",
4
4
  "description": "Autonomous AI agent memory system with CLAUDE.md protocol enforcement",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -118,12 +118,17 @@ else
118
118
  # -------------------------------------------------------------------
119
119
  # NPM REGISTRY MODE: Fallback when no local mount is present
120
120
  # -------------------------------------------------------------------
121
+ # NOTE: the published package is @miller-tech/uap (the old
122
+ # `universal-agent-protocol` name 404s). Prefer the local /uap-local mount
123
+ # (handled above + re-installed by the agent after upload); this registry
124
+ # path is only a last-resort fallback.
121
125
  CURRENT_UAP=$(uap --version 2>/dev/null || echo "none")
122
- if [ "$CURRENT_UAP" = "$UAP_VERSION" ]; then
123
- echo " UAP v${UAP_VERSION} already installed - skipping"
126
+ if [ "$CURRENT_UAP" != "none" ]; then
127
+ echo " UAP already installed (v${CURRENT_UAP}) - skipping registry fetch"
124
128
  else
125
- npm i -g universal-agent-protocol@${UAP_VERSION} 2>/dev/null || true
126
- echo " UAP v${UAP_VERSION} installed from npm registry"
129
+ npm i -g @miller-tech/uap@latest 2>/dev/null \
130
+ && echo " UAP installed from npm registry (@miller-tech/uap@latest)" \
131
+ || echo " WARNING: UAP npm registry install failed (will rely on /uap-local)"
127
132
  fi
128
133
  fi
129
134
 
@@ -1179,6 +1179,10 @@ class OpenCodeUAP(BaseInstalledAgent):
1179
1179
  "tools/agents",
1180
1180
  "tools/uap_harbor",
1181
1181
  "harbor-configs",
1182
+ # Needed so `uap install opencode` can wire the policy gate +
1183
+ # delivery-enforcement enforcer inside the container.
1184
+ "src/policies/enforcers",
1185
+ "src/policies/schemas/policies",
1182
1186
  ]
1183
1187
  local_upload_files = [
1184
1188
  "package.json",
@@ -1227,6 +1231,13 @@ class OpenCodeUAP(BaseInstalledAgent):
1227
1231
 
1228
1232
  logger.info("[Local UAP] Local project uploaded to /uap-local/")
1229
1233
 
1234
+ # NOTE: we deliberately do NOT `npm i -g file:/uap-local` here. The
1235
+ # install script's npm path already globally installs @miller-tech/uap
1236
+ # (with its runtime deps) and runs `uap install opencode`. Re-linking
1237
+ # the global bin to /uap-local — which has no node_modules — would break
1238
+ # the CLI at runtime (ERR_MODULE_NOT_FOUND: commander). The uploaded
1239
+ # /uap-local copy is kept only for Python-side imports / inspection.
1240
+
1230
1241
  def populate_context_post_run(self, context: AgentContext) -> None:
1231
1242
  _parse_token_counts(self.logs_dir, context)
1232
1243
 
@@ -1398,7 +1409,14 @@ class OpenCodeUAP(BaseInstalledAgent):
1398
1409
  def create_run_agent_commands(self, instruction: str) -> list[ExecInput]:
1399
1410
  model = self.model_name or "llama.cpp/qwen35-a3b-iq4xs"
1400
1411
 
1401
- env = {"OPENCODE_FAKE_VCS": "git"}
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
+ }
1402
1420
 
1403
1421
  # --- Step 0: Build classified CLAUDE.md and enhanced instruction ---
1404
1422
  classified_claude_md = build_classified_claude_md(instruction)
@@ -1524,6 +1542,17 @@ class OpenCodeUAP(BaseInstalledAgent):
1524
1542
  # --- Step 5: Environment bootstrapping ---
1525
1543
  commands.append(ExecInput(command=ENV_BOOTSTRAP_CMD))
1526
1544
 
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
+
1527
1556
  # --- Step 6: Run opencode with enhanced instruction ---
1528
1557
  # opencode.json baseURL points to proxy at http://127.0.0.1:11435/v1
1529
1558
  # which injects tool_choice="required" and forwards to the real LLM
@@ -41,6 +41,11 @@ 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
+
44
49
  const TELEMETRY_PATH = '/tmp/uap-telemetry.jsonl';
45
50
 
46
51
  const simpleHash = (s: string): string => {
@@ -60,6 +65,47 @@ export const UapEnforce: Plugin = async ({ $ }) => {
60
65
  'tool.execute.before': async (input, output) => {
61
66
  totalToolCalls++;
62
67
 
68
+ // --- Transparent delivery (Layer 5): converge via `uap deliver` ---
69
+ // When delivery enforcement is active (the UAP default), the FIRST
70
+ // substantive write/edit hands the task to the `uap deliver` convergence
71
+ // loop, which iterates the model against the project's real gates
72
+ // (build/typecheck/test) before the agent's own edit lands. This is how
73
+ // deliver "uplifts" a small local model: plausible -> verified. It runs
74
+ // exactly once per session; the original edit then proceeds normally.
75
+ // Escape hatches: UAP_ENFORCE_DELIVERY=advisory or UAP_DELIVER_BYPASS=1.
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
+ }
108
+
63
109
  // --- Worktree enforcement (Layer 4) ---
64
110
  // Warn when file writes happen outside a worktree
65
111
  if ((input.tool === 'write' || input.tool === 'edit') && output.args?.filePath) {