pmx-canvas 0.3.2 → 0.3.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/Readme.md +2 -1
  3. package/dist/canvas/index.js +85 -83
  4. package/dist/json-render/index.js +47 -47
  5. package/dist/types/cli/agent.d.ts +13 -8
  6. package/dist/types/cli/commands/apps.d.ts +1 -0
  7. package/dist/types/cli/commands/ax.d.ts +1 -0
  8. package/dist/types/cli/commands/copilot.d.ts +1 -0
  9. package/dist/types/cli/commands/edges.d.ts +1 -0
  10. package/dist/types/cli/commands/groups.d.ts +1 -0
  11. package/dist/types/cli/commands/history.d.ts +1 -0
  12. package/dist/types/cli/commands/nodes.d.ts +1 -0
  13. package/dist/types/cli/commands/pins.d.ts +1 -0
  14. package/dist/types/cli/commands/query.d.ts +1 -0
  15. package/dist/types/cli/commands/view.d.ts +1 -0
  16. package/dist/types/cli/commands/webview.d.ts +1 -0
  17. package/dist/types/cli/daemon.d.ts +17 -0
  18. package/dist/types/cli/shared.d.ts +73 -0
  19. package/dist/types/client/canvas/ExpandedNodeOverlay.d.ts +1 -1
  20. package/dist/types/client/nodes/ExtAppFrame.d.ts +13 -0
  21. package/dist/types/client/nodes/HtmlNode.d.ts +1 -1
  22. package/dist/types/client/nodes/McpAppNode.d.ts +1 -1
  23. package/dist/types/client/nodes/use-ax-surface-bridge.d.ts +20 -0
  24. package/dist/types/server/canvas-operations.d.ts +2 -0
  25. package/dist/types/server/diagram-presets.d.ts +8 -0
  26. package/dist/types/server/operations/composites.d.ts +0 -9
  27. package/dist/types/shared/ax-surface-protocol.d.ts +18 -0
  28. package/docs/RELEASE.md +11 -0
  29. package/docs/bun-webview-integration.md +5 -0
  30. package/docs/environment.md +48 -0
  31. package/docs/node-types.md +5 -0
  32. package/docs/plans/plan-009-tech-debt-backlog.md +27 -9
  33. package/docs/screenshot.png +0 -0
  34. package/package.json +8 -5
  35. package/skills/pmx-canvas/SKILL.md +11 -8
  36. package/skills/pmx-canvas/evals/evals.json +5 -5
  37. package/skills/pmx-canvas/references/full-reference.md +8 -1
  38. package/src/cli/agent.ts +22 -3512
  39. package/src/cli/commands/apps.ts +165 -0
  40. package/src/cli/commands/ax.ts +604 -0
  41. package/src/cli/commands/copilot.ts +43 -0
  42. package/src/cli/commands/edges.ts +73 -0
  43. package/src/cli/commands/groups.ts +81 -0
  44. package/src/cli/commands/history.ts +220 -0
  45. package/src/cli/commands/nodes.ts +954 -0
  46. package/src/cli/commands/pins.ts +42 -0
  47. package/src/cli/commands/query.ts +223 -0
  48. package/src/cli/commands/view.ts +186 -0
  49. package/src/cli/commands/webview.ts +227 -0
  50. package/src/cli/daemon.ts +39 -7
  51. package/src/cli/shared.ts +860 -0
  52. package/src/client/canvas/ExpandedNodeOverlay.tsx +3 -2
  53. package/src/client/nodes/ExtAppFrame.tsx +166 -52
  54. package/src/client/nodes/HtmlNode.tsx +8 -51
  55. package/src/client/nodes/McpAppNode.tsx +12 -47
  56. package/src/client/nodes/use-ax-surface-bridge.ts +71 -0
  57. package/src/json-render/renderer/index.tsx +3 -2
  58. package/src/mcp/server.ts +0 -47
  59. package/src/server/bundled-skills.ts +5 -1
  60. package/src/server/canvas-operations.ts +8 -0
  61. package/src/server/diagram-presets.ts +15 -1
  62. package/src/server/html-surface.ts +11 -6
  63. package/src/server/operations/composites.ts +1 -13
  64. package/src/server/operations/invoker.ts +10 -3
  65. package/src/server/operations/mcp.ts +51 -1
  66. package/src/server/operations/ops/app.ts +5 -0
  67. package/src/server/server.ts +61 -3
  68. package/src/shared/ax-surface-protocol.ts +22 -0
  69. package/dist/types/client/canvas/ContextPinHud.d.ts +0 -1
  70. package/src/client/canvas/ContextPinHud.tsx +0 -17
package/src/cli/daemon.ts CHANGED
@@ -88,20 +88,26 @@ export function removePidFile(path: string): void {
88
88
  export interface HealthStatus {
89
89
  responsive: boolean;
90
90
  workspace: string | null;
91
+ /** The serving process's own pid, self-reported by /health (0.3.3+ servers). */
92
+ pid: number | null;
91
93
  }
92
94
 
93
95
  export async function readHealthStatus(url: string): Promise<HealthStatus> {
94
96
  try {
95
97
  const response = await fetch(url);
96
- if (!response.ok) return { responsive: false, workspace: null };
98
+ if (!response.ok) return { responsive: false, workspace: null, pid: null };
97
99
  const payload = (await response.json().catch(() => null)) as unknown;
98
100
  const workspace =
99
101
  payload && typeof payload === 'object' && 'workspace' in payload && typeof payload.workspace === 'string'
100
102
  ? payload.workspace
101
103
  : null;
102
- return { responsive: true, workspace };
104
+ const pid =
105
+ payload && typeof payload === 'object' && 'pid' in payload && typeof payload.pid === 'number'
106
+ ? payload.pid
107
+ : null;
108
+ return { responsive: true, workspace, pid };
103
109
  } catch {
104
- return { responsive: false, workspace: null };
110
+ return { responsive: false, workspace: null, pid: null };
105
111
  }
106
112
  }
107
113
 
@@ -335,17 +341,41 @@ export async function startDaemonMode(
335
341
  process.exit(0);
336
342
  }
337
343
 
344
+ /**
345
+ * Resolve the pid story `serve status` reports. The AUTHORITATIVE pid is the
346
+ * serving process's self-reported /health pid: the pid file can go stale when
347
+ * something other than `serve --daemon` (re)spawned the server on this port —
348
+ * e.g. a host adapter respawn (0.3.2 report Finding P). Reporting the dead
349
+ * file pid as `pid` while `running` was true made agents read a contradiction
350
+ * (`running: true, pidRunning: false`); report the real listener instead and
351
+ * mark the file explicitly stale. Pre-0.3.3 servers don't self-report a pid —
352
+ * for those, fall back to the pid-file view unchanged.
353
+ */
354
+ export function resolveDaemonPidView(
355
+ pidFilePid: number | null,
356
+ pidFilePidRunning: boolean,
357
+ health: HealthStatus,
358
+ ): { pid: number | null; pidRunning: boolean; pidFileStale: boolean } {
359
+ const authoritative = health.responsive && health.pid !== null;
360
+ return {
361
+ pid: authoritative ? health.pid : pidFilePid,
362
+ pidRunning: authoritative ? true : pidFilePidRunning,
363
+ pidFileStale: pidFilePid !== null && !pidFilePidRunning && (!health.responsive || health.pid !== pidFilePid),
364
+ };
365
+ }
366
+
338
367
  export async function showServeStatus(options: DaemonPaths & { entry: string }): Promise<void> {
339
368
  const healthUrl = `http://localhost:${options.port}/health`;
340
369
  const url = `http://localhost:${options.port}/workbench`;
341
- const pid = readPidFile(options.pidFile);
342
- const pidRunning = pid ? isOwnDaemonProcess(pid, options.entry) : false;
370
+ const pidFilePid = readPidFile(options.pidFile);
371
+ const pidFilePidRunning = pidFilePid ? isOwnDaemonProcess(pidFilePid, options.entry) : false;
343
372
  const health = await readHealthStatus(healthUrl);
344
373
  const responsive = health.responsive;
345
- const running = responsive || pidRunning;
374
+ const running = responsive || pidFilePidRunning;
375
+ const { pid, pidRunning, pidFileStale } = resolveDaemonPidView(pidFilePid, pidFilePidRunning, health);
346
376
  // Clean up a stale pid file, but never a concurrent starter's fresh empty
347
377
  // spawn lock (that would let a racing `serve --daemon` double-spawn).
348
- if (!running && existsSync(options.pidFile) && !pidRunning && !isFreshEmptyLock(options.pidFile)) {
378
+ if (!running && existsSync(options.pidFile) && !pidFilePidRunning && !isFreshEmptyLock(options.pidFile)) {
349
379
  removePidFile(options.pidFile);
350
380
  }
351
381
 
@@ -357,6 +387,8 @@ export async function showServeStatus(options: DaemonPaths & { entry: string }):
357
387
  workspace: health.workspace,
358
388
  pid,
359
389
  pidRunning,
390
+ pidFilePid,
391
+ pidFileStale,
360
392
  url,
361
393
  healthUrl,
362
394
  logFile: options.logFile,