u-foo 4.0.3 → 4.0.5

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 (35) hide show
  1. package/README.md +15 -0
  2. package/dist/tui/darwin-arm64/ufoo-tui +0 -0
  3. package/dist/tui/darwin-x64/ufoo-tui +0 -0
  4. package/dist/tui/linux-arm64/ufoo-tui +0 -0
  5. package/dist/tui/linux-x64/ufoo-tui +0 -0
  6. package/package.json +3 -3
  7. package/src/agents/providers/nativeTransport.js +109 -53
  8. package/src/agents/providers/runtimeConfig.js +41 -1
  9. package/src/agents/runtime/context/checkpointStore.js +15 -1
  10. package/src/agents/runtime/context/compaction.js +27 -7
  11. package/src/agents/runtime/context/runtimeStore.js +1 -0
  12. package/src/agents/runtime/core/agentLoop.js +48 -6
  13. package/src/app/cli/busCoreCommands.js +63 -3
  14. package/src/app/cli/run.js +1 -0
  15. package/src/code/agent.js +36 -19
  16. package/src/code/context/planGraphService.js +41 -0
  17. package/src/code/modelCommand.js +6 -5
  18. package/src/code/nativeRunner.js +15 -56
  19. package/src/code/taskDecomposer.js +3 -0
  20. package/src/code/tools/executor.js +1 -0
  21. package/src/code/tools/planGraph.js +1 -0
  22. package/src/code/tools/specs.js +2 -1
  23. package/src/coordination/bus/index.js +2 -2
  24. package/src/coordination/bus/message.js +10 -1
  25. package/src/coordination/bus/nickname.js +3 -1
  26. package/src/coordination/bus/subscriber.js +25 -10
  27. package/src/coordination/bus/utils.js +4 -0
  28. package/src/coordination/bus/wakeEndpoint.js +198 -0
  29. package/src/coordination/state/paths.js +4 -0
  30. package/src/runtime/daemon/agentHost.js +2 -0
  31. package/src/runtime/daemon/deliveryScheduler.js +70 -2
  32. package/src/runtime/daemon/index.js +1 -0
  33. package/src/ui/agentSurface.js +34 -3
  34. package/src/ui/format/markdownRenderer.js +4 -2
  35. package/src/ui/rustUcodeHost.js +3 -3
@@ -318,6 +318,10 @@ function isMetaActive(meta) {
318
318
  // 1. 显式标记为 inactive
319
319
  if (meta.status === "inactive") return false;
320
320
 
321
+ // A wake registration has no local process. Liveness is the saved adapter,
322
+ // not a pid or a 30s heartbeat.
323
+ if (meta.launch_mode === "wake" && meta.wake_adapter) return true;
324
+
321
325
  // 2. PID 存活(最可靠)
322
326
  if (meta.pid && isAgentPidAlive(meta.pid)) return true;
323
327
 
@@ -0,0 +1,198 @@
1
+ "use strict";
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const { getUfooPaths } = require("../state/paths");
6
+ const { withFileLock } = require("../state/fileLock");
7
+
8
+ const WAKE_ADAPTERS = Object.freeze({
9
+ "bearer-json": Object.freeze({
10
+ acceptedStatuses: Object.freeze([200]),
11
+ }),
12
+ });
13
+
14
+ function isWakeMeta(meta) {
15
+ return Boolean(
16
+ meta
17
+ && meta.status !== "inactive"
18
+ && meta.launch_mode === "wake"
19
+ && typeof meta.wake_adapter === "string"
20
+ && WAKE_ADAPTERS[meta.wake_adapter]
21
+ );
22
+ }
23
+
24
+ function assertHttpsWakeUrl(rawUrl) {
25
+ let parsed;
26
+ try {
27
+ parsed = new URL(String(rawUrl || "").trim());
28
+ } catch {
29
+ throw new Error("wake URL must be an http(s) URL");
30
+ }
31
+ if (parsed.username || parsed.password) {
32
+ throw new Error("wake URL must not include credentials");
33
+ }
34
+ const loopback = ["localhost", "127.0.0.1", "::1", "[::1]"].includes(parsed.hostname);
35
+ if (parsed.protocol === "https:") return parsed.toString();
36
+ if (parsed.protocol === "http:" && loopback) return parsed.toString();
37
+ throw new Error("wake URL must use https");
38
+ }
39
+
40
+ function normalizeAdapter(adapter) {
41
+ const name = String(adapter || "bearer-json").trim();
42
+ if (!WAKE_ADAPTERS[name]) {
43
+ throw new Error(`Unknown wake adapter "${name}"`);
44
+ }
45
+ return name;
46
+ }
47
+
48
+ function readJsonFile(filePath) {
49
+ try {
50
+ if (!filePath || !fs.existsSync(filePath)) return null;
51
+ const parsed = JSON.parse(fs.readFileSync(filePath, "utf8"));
52
+ return parsed && typeof parsed === "object" ? parsed : null;
53
+ } catch {
54
+ return null;
55
+ }
56
+ }
57
+
58
+ function writeJsonFile(filePath, data, mode) {
59
+ fs.mkdirSync(path.dirname(filePath), { recursive: true, mode: 0o700 });
60
+ const tmp = `${filePath}.${process.pid}.tmp`;
61
+ fs.writeFileSync(tmp, `${JSON.stringify(data, null, 2)}\n`, { mode });
62
+ fs.renameSync(tmp, filePath);
63
+ fs.chmodSync(filePath, mode);
64
+ }
65
+
66
+ function endpointStore(projectRoot) {
67
+ const filePath = getUfooPaths(projectRoot).wakeEndpointsFile;
68
+ const parsed = readJsonFile(filePath) || { version: 1, endpoints: {} };
69
+ if (!parsed.endpoints || typeof parsed.endpoints !== "object") parsed.endpoints = {};
70
+ parsed.version = 1;
71
+ return { filePath, data: parsed };
72
+ }
73
+
74
+ function receiptStore(projectRoot) {
75
+ const filePath = getUfooPaths(projectRoot).wakeReceiptsFile;
76
+ const parsed = readJsonFile(filePath) || { version: 1, accepted: {} };
77
+ if (!parsed.accepted || typeof parsed.accepted !== "object") parsed.accepted = {};
78
+ parsed.version = 1;
79
+ return { filePath, data: parsed };
80
+ }
81
+
82
+ function writeWakeEndpoint(projectRoot, subscriber, endpoint = {}) {
83
+ const adapter = normalizeAdapter(endpoint.adapter);
84
+ const url = assertHttpsWakeUrl(endpoint.url);
85
+ const key = String(endpoint.key || "");
86
+ if (!key.trim()) throw new Error("wake key is empty");
87
+ if (key.length > 4096) throw new Error("wake key is too long");
88
+ if (/[\r\n]/.test(key)) throw new Error("wake key must be a single line");
89
+ return withFileLock(getUfooPaths(projectRoot).wakeEndpointsFile, () => {
90
+ const store = endpointStore(projectRoot);
91
+ store.data.endpoints[subscriber] = { adapter, url, key };
92
+ writeJsonFile(store.filePath, store.data, 0o600);
93
+ return { adapter, url };
94
+ });
95
+ }
96
+
97
+ function readWakeEndpoint(projectRoot, subscriber) {
98
+ const record = endpointStore(projectRoot).data.endpoints[subscriber];
99
+ if (!record || typeof record !== "object") return null;
100
+ if (!WAKE_ADAPTERS[record.adapter] || typeof record.url !== "string" || typeof record.key !== "string") {
101
+ return null;
102
+ }
103
+ return { adapter: record.adapter, url: record.url, key: record.key };
104
+ }
105
+
106
+ function removeWakeEndpoint(projectRoot, subscriber) {
107
+ return withFileLock(getUfooPaths(projectRoot).wakeEndpointsFile, () => {
108
+ const store = endpointStore(projectRoot);
109
+ if (!store.data.endpoints[subscriber]) return false;
110
+ delete store.data.endpoints[subscriber];
111
+ writeJsonFile(store.filePath, store.data, 0o600);
112
+ withFileLock(getUfooPaths(projectRoot).wakeReceiptsFile, () => {
113
+ const receipts = receiptStore(projectRoot);
114
+ if (receipts.data.accepted[subscriber]) {
115
+ delete receipts.data.accepted[subscriber];
116
+ writeJsonFile(receipts.filePath, receipts.data, 0o600);
117
+ }
118
+ });
119
+ return true;
120
+ });
121
+ }
122
+
123
+ function hasWakeAccepted(projectRoot, subscriber, seq) {
124
+ const accepted = receiptStore(projectRoot).data.accepted[subscriber] || {};
125
+ return Boolean(accepted[String(seq)]);
126
+ }
127
+
128
+ function markWakeAccepted(projectRoot, subscriber, seq) {
129
+ return withFileLock(getUfooPaths(projectRoot).wakeReceiptsFile, () => {
130
+ const store = receiptStore(projectRoot);
131
+ if (!store.data.accepted[subscriber]) store.data.accepted[subscriber] = {};
132
+ store.data.accepted[subscriber][String(seq)] = new Date().toISOString();
133
+ writeJsonFile(store.filePath, store.data, 0o600);
134
+ });
135
+ }
136
+
137
+ function readWakeKeyFile(filePath) {
138
+ const resolved = String(filePath || "").trim();
139
+ if (!resolved) throw new Error("wake key file is required");
140
+ let key = "";
141
+ try {
142
+ key = fs.readFileSync(resolved, "utf8");
143
+ } catch (error) {
144
+ throw new Error(`cannot read wake key file: ${error.message}`);
145
+ }
146
+ key = key.replace(/\r?\n$/, "");
147
+ if (!key.trim()) throw new Error("wake key file is empty");
148
+ return key;
149
+ }
150
+
151
+ async function wakeBearerJson({ url, key, payload, fetchImpl, signal }) {
152
+ const response = await fetchImpl(url, {
153
+ method: "POST",
154
+ headers: {
155
+ "content-type": "application/json",
156
+ authorization: `Bearer ${key}`,
157
+ },
158
+ body: JSON.stringify(payload),
159
+ signal,
160
+ redirect: "error",
161
+ });
162
+ try { Promise.resolve(response.body?.cancel()).catch(() => {}); } catch { /* response body is optional */ }
163
+ return {
164
+ accepted: response.status === 200,
165
+ status: response.status,
166
+ };
167
+ }
168
+
169
+ async function wakeSubscriber(endpoint, payload, fetchImpl = global.fetch, { timeoutMs = 10000 } = {}) {
170
+ if (!endpoint) throw new Error("wake endpoint is missing");
171
+ if (typeof fetchImpl !== "function") throw new Error("wake fetch is unavailable");
172
+ if (endpoint.adapter === "bearer-json") {
173
+ const controller = new AbortController();
174
+ let timer;
175
+ const timeout = new Promise((_, reject) => {
176
+ timer = setTimeout(() => {
177
+ controller.abort();
178
+ reject(Object.assign(new Error("wake request timed out"), { code: "WAKE_TIMEOUT" }));
179
+ }, timeoutMs);
180
+ });
181
+ try { return await Promise.race([wakeBearerJson({ ...endpoint, payload, fetchImpl, signal: controller.signal }), timeout]); }
182
+ finally { clearTimeout(timer); }
183
+ }
184
+ throw new Error(`Unknown wake adapter "${endpoint.adapter}"`);
185
+ }
186
+
187
+ module.exports = {
188
+ WAKE_ADAPTERS,
189
+ isWakeMeta,
190
+ assertHttpsWakeUrl,
191
+ writeWakeEndpoint,
192
+ readWakeEndpoint,
193
+ removeWakeEndpoint,
194
+ hasWakeAccepted,
195
+ markWakeAccepted,
196
+ readWakeKeyFile,
197
+ wakeSubscriber,
198
+ };
@@ -6,6 +6,8 @@ function getUfooPaths(projectRoot) {
6
6
  const agentDir = path.join(ufooDir, "agent");
7
7
  const memoryDir = path.join(ufooDir, "memory");
8
8
  const agentsFile = path.join(agentDir, "all-agents.json");
9
+ const wakeEndpointsFile = path.join(agentDir, "wake-endpoints.json");
10
+ const wakeReceiptsFile = path.join(busDir, "wake-receipts.json");
9
11
  const memoryFile = path.join(memoryDir, "memory.jsonl");
10
12
 
11
13
  const busQueuesDir = path.join(busDir, "queues");
@@ -33,6 +35,8 @@ function getUfooPaths(projectRoot) {
33
35
  agentDir,
34
36
  memoryDir,
35
37
  agentsFile,
38
+ wakeEndpointsFile,
39
+ wakeReceiptsFile,
36
40
  memoryFile,
37
41
  busQueuesDir,
38
42
  busEventsDir,
@@ -192,6 +192,8 @@ function createAgentHost({ projectRoot, provider, model, ports = {}, onEvent = (
192
192
  const contextManager = createContextManager({ policy: contextPolicy, store: {
193
193
  sourceRef: store.journal,
194
194
  load: () => store.read().contextCheckpoint || null,
195
+ loadRetryState: () => store.read().contextCompactionRetry || null,
196
+ saveRetryState: retryState => store.append({ type: "context.compaction.retry_state", retryState }),
195
197
  commit(checkpoint, sourceBatch, expectedVersion) {
196
198
  let committed = false;
197
199
  store.transaction(state => {
@@ -6,6 +6,13 @@ const { buildPromptInjectionText } = require("../../coordination/bus/promptEnvel
6
6
  const { createTerminalAdapterRouter } = require("../terminal/adapterRouter");
7
7
  const { normalizeQueueEnvelope } = require("../../coordination/bus/deliveryQueue");
8
8
  const { writeActivityState } = require("../../agents/activity/activityStateWriter");
9
+ const {
10
+ hasWakeAccepted,
11
+ isWakeMeta,
12
+ markWakeAccepted,
13
+ readWakeEndpoint,
14
+ wakeSubscriber,
15
+ } = require("../../coordination/bus/wakeEndpoint");
9
16
 
10
17
  function asState(value = "") {
11
18
  return String(value || "").trim().toLowerCase();
@@ -74,6 +81,8 @@ class DeliveryScheduler {
74
81
  });
75
82
  };
76
83
  this.log = typeof options.log === "function" ? options.log : () => {};
84
+ this.wakeFetch = typeof options.wakeFetch === "function" ? options.wakeFetch : global.fetch;
85
+ this.wakeTimeoutMs = positiveMs(options.wakeTimeoutMs, 10000);
77
86
  this.now = typeof options.now === "function" ? options.now : () => Date.now();
78
87
  this.deferWarnAfterMs = positiveMs(options.deferWarnAfterMs, DEFAULT_DEFER_WARN_AFTER_MS);
79
88
  this.warnIntervalMs = positiveMs(options.warnIntervalMs, DEFAULT_WARN_INTERVAL_MS);
@@ -188,6 +197,9 @@ class DeliveryScheduler {
188
197
  if (!meta || meta.status === "inactive") {
189
198
  return { ok: false, reason: "missing_or_inactive" };
190
199
  }
200
+ if (isWakeMeta(meta)) {
201
+ return { ok: true, reason: "wake" };
202
+ }
191
203
  if (meta.mcp_bridge === true) {
192
204
  return { ok: false, reason: "external_receive" };
193
205
  }
@@ -350,6 +362,49 @@ class DeliveryScheduler {
350
362
  };
351
363
  }
352
364
 
365
+ async deliverWake(subscriber) {
366
+ const queue = this.queueFactory(subscriber);
367
+ const pending = this.readPendingEvents(queue).filter((event) => (
368
+ event
369
+ && event.event === "message"
370
+ && event.data
371
+ && typeof event.data.message === "string"
372
+ ));
373
+ const next = pending[0];
374
+ if (!next || hasWakeAccepted(this.projectRoot, subscriber, next.seq)) {
375
+ return { ok: true, delivered: 0, reason: "wake_waiting_ack" };
376
+ }
377
+ const endpoint = readWakeEndpoint(this.projectRoot, subscriber);
378
+ if (!endpoint) {
379
+ return { ok: false, delivered: 0, reason: "wake_endpoint_missing" };
380
+ }
381
+ const claim = queue.claimNext((event) => Number(event && event.seq) === Number(next.seq));
382
+ if (!claim) return { ok: true, delivered: 0, reason: "empty" };
383
+ try {
384
+ const result = await wakeSubscriber(endpoint, {
385
+ source: "ufoo",
386
+ project_root: this.projectRoot,
387
+ subscriber,
388
+ seq: Number(next.seq) || 0,
389
+ publisher: next.publisher || "",
390
+ message: next.data.message,
391
+ }, this.wakeFetch, { timeoutMs: this.wakeTimeoutMs });
392
+ if (!result.accepted) {
393
+ queue.restoreClaim(claim);
394
+ this.log(`wake not accepted subscriber=${subscriber} seq=${next.seq} status=${result.status}`);
395
+ return { ok: false, delivered: 0, reason: "wake_not_accepted", status: result.status };
396
+ }
397
+ markWakeAccepted(this.projectRoot, subscriber, next.seq);
398
+ queue.restoreClaim(claim);
399
+ return { ok: true, delivered: 0, woken: true, seq: Number(next.seq) || 0 };
400
+ } catch (err) {
401
+ queue.restoreClaim(claim);
402
+ const message = err && err.message ? err.message : String(err || "wake failed");
403
+ this.log(`wake failed subscriber=${subscriber} seq=${next.seq}`);
404
+ return { ok: false, delivered: 0, reason: "wake_failed", error: message };
405
+ }
406
+ }
407
+
353
408
  async deliverSubscriber(subscriber) {
354
409
  if (!subscriber) return { ok: false, delivered: 0, reason: "missing_subscriber" };
355
410
  if (this.locks.has(subscriber)) {
@@ -361,6 +416,9 @@ class DeliveryScheduler {
361
416
  try {
362
417
  const queue = this.queueFactory(subscriber);
363
418
  const transportGate = this.shouldDeliver(subscriber, { requireIdle: false });
419
+ if (transportGate.reason === "wake") {
420
+ return await this.deliverWake(subscriber);
421
+ }
364
422
  if (!transportGate.ok) {
365
423
  this.noteDeferral(subscriber, transportGate.reason);
366
424
  return { ok: true, delivered: 0, deferred: true, reason: transportGate.reason };
@@ -510,7 +568,13 @@ class DeliveryScheduler {
510
568
  continue;
511
569
  }
512
570
  const queue = this.queueFactory(subscriber);
513
- if (queue.readPending().length > 0) {
571
+ let pending = [];
572
+ try {
573
+ pending = queue.readPending();
574
+ } catch {
575
+ continue;
576
+ }
577
+ if (pending.length > 0) {
514
578
  subscribers.push(subscriber);
515
579
  pendingSubscribers.add(subscriber);
516
580
  } else {
@@ -533,7 +597,11 @@ class DeliveryScheduler {
533
597
  this.running = true;
534
598
  const run = () => {
535
599
  this.tick().catch((err) => {
536
- this.log(`delivery scheduler tick failed: ${err && err.message ? err.message : String(err)}`);
600
+ try {
601
+ this.log(`delivery scheduler tick failed: ${err && err.message ? err.message : String(err)}`);
602
+ } catch {
603
+ // A full project volume must not take down the controller.
604
+ }
537
605
  });
538
606
  };
539
607
  run();
@@ -950,6 +950,7 @@ function startDaemon({
950
950
  if (manageProcessState) writePid(projectRoot);
951
951
 
952
952
  const logFile = fs.createWriteStream(logPath(projectRoot), { flags: "a" });
953
+ logFile.on("error", () => {});
953
954
  const formatLogLine = (msg) => `[daemon] ${new Date().toISOString()} ${msg}\n`;
954
955
  const log = (msg) => {
955
956
  logFile.write(formatLogLine(msg));
@@ -26,6 +26,22 @@ function createAgentSurface(options = {}) {
26
26
  const background = new Map();
27
27
  let contextUsage = "";
28
28
  const tools = new Map();
29
+ const renderedEntries = new WeakMap();
30
+
31
+ function presentEntry(row) {
32
+ if (!["assistant", "thinking"].includes(row.kind) || /\x1b\[/.test(row.text)) return { ...row };
33
+ let cached = renderedEntries.get(row);
34
+ if (!cached || cached.source !== row.text) {
35
+ cached = { source: row.text, text: fmt.renderLogLinesWithMarkdownAnsi(row.text, { inCodeBlock: false }).join("\n") };
36
+ renderedEntries.set(row, cached);
37
+ }
38
+ return { ...row, text: cached.text };
39
+ }
40
+
41
+ function getEntry(id) {
42
+ const row = entries.find((row) => row.id === id);
43
+ return row ? presentEntry(row) : null;
44
+ }
29
45
 
30
46
  function bound() {
31
47
  for (const entry of entries) {
@@ -261,10 +277,25 @@ function createAgentSurface(options = {}) {
261
277
  const failed = bg.filter((task) => ["failed", "stopped", "killed"].includes(task.status)).length;
262
278
  const suffix = [running && `${running} running`, done && `${done} done`, failed && `${failed} failed`].filter(Boolean).join("/");
263
279
  const label = `${status}${!busy && status === "ready" && idlePlanHint ? ` · ${idlePlanHint}` : ""}${submitted.length > 1 || (submitted.length && runningTask) ? ` · queued ${submitted.length}` : ""}${suffix ? ` · BG ${suffix}` : ""}`;
264
- return { entries: entries.map((row) => ({ ...row })), status: label, busy, usage, plan: plan.slice(), revision, started_at: startedAt };
280
+ return { entries: entries.map(presentEntry), status: label, busy, usage, plan: plan.slice(), revision, started_at: startedAt };
265
281
  }
266
282
 
267
- return { apply, accept, snapshot, toggleExpanded };
283
+ return { apply, accept, snapshot, getEntry, toggleExpanded };
284
+ }
285
+
286
+ // Keep source deltas in the surface; send the rendered entry as a replacement
287
+ // so delimiters split across chunks and multi-line tables can be re-evaluated.
288
+ function projectSurfaceEvent(surface, name, payload = {}) {
289
+ const delta = name === "stream.delta" || name === "thinking.delta";
290
+ const id = payload.id || (name === "thinking.delta" ? "thinking" : "stream");
291
+ const exists = delta && Boolean(surface.getEntry(id));
292
+ surface.apply(name, payload);
293
+ if (delta) {
294
+ const row = surface.getEntry(id);
295
+ return { name: exists ? "transcript.patch" : "transcript.append", payload: row };
296
+ }
297
+ if (name === "transcript.reset") return { name, payload: { ...payload, entries: surface.snapshot().entries } };
298
+ return { name, payload };
268
299
  }
269
300
 
270
- module.exports = { createAgentSurface };
301
+ module.exports = { createAgentSurface, projectSurfaceEvent };
@@ -222,8 +222,10 @@ function renderInlineMarkdown(input = "", adapters = createBlessedAdapters()) {
222
222
  let out = "";
223
223
  let i = 0;
224
224
  while (i < source.length) {
225
+ // Underscores inside identifiers/filenames are literal, as in GFM.
226
+ const canOpenUnderscore = i === 0 || !/[\p{L}\p{N}_]/u.test(source[i - 1]);
225
227
  // **bold** / __bold__
226
- if (source.startsWith("**", i) || source.startsWith("__", i)) {
228
+ if (source.startsWith("**", i) || source.startsWith("__", i) && canOpenUnderscore) {
227
229
  const mark = source.slice(i, i + 2);
228
230
  const close = source.indexOf(mark, i + 2);
229
231
  if (close !== -1) {
@@ -253,7 +255,7 @@ function renderInlineMarkdown(input = "", adapters = createBlessedAdapters()) {
253
255
  // *italic* / _italic_ (single delimiter; avoid ** / __)
254
256
  if (
255
257
  (source[i] === "*" && source[i + 1] !== "*")
256
- || (source[i] === "_" && source[i + 1] !== "_")
258
+ || (source[i] === "_" && source[i + 1] !== "_" && canOpenUnderscore)
257
259
  ) {
258
260
  const mark = source[i];
259
261
  const close = source.indexOf(mark, i + 1);
@@ -17,7 +17,7 @@ const {
17
17
  } = require("../code/UcodeController");
18
18
  const { createEnvelope, encodeMessage } = require("../runtime/contracts/uiProtocol");
19
19
  const fmt = require("./format");
20
- const { createAgentSurface } = require("./agentSurface");
20
+ const { createAgentSurface, projectSurfaceEvent } = require("./agentSurface");
21
21
  const { buildPlanSetPayload, statusForAgentPhase } = require("./agentPresentation");
22
22
  const PACKAGE_VERSION = require("../../package.json").version;
23
23
 
@@ -219,9 +219,9 @@ async function runUcodeRust(props = {}) {
219
219
  });
220
220
 
221
221
  function publish(name, payload) {
222
- surface.apply(name, payload);
222
+ const projected = projectSurfaceEvent(surface, name, payload);
223
223
  if (!hostRef) return;
224
- hostRef.broadcast(hostRef.createEvent(name, payload, {
224
+ hostRef.broadcast(hostRef.createEvent(projected.name, projected.payload, {
225
225
  surface: "ucode",
226
226
  project_id: workspaceRoot,
227
227
  }));