@evandu/super-pi 0.1.145 → 0.1.146

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 (75) hide show
  1. package/agents/super-pi-task/core.ts +15 -2
  2. package/agents/super-pi-task/index.ts +3 -0
  3. package/dist/.super-pi-check-inputs.json +2 -2
  4. package/dist/client/.super-pi-client-sources.json +9 -9
  5. package/dist/client/assets/{CodeMirrorEditor-A9KvbIkm.js → CodeMirrorEditor-CEwBCVM6.js} +2 -2
  6. package/dist/client/assets/{dist-Br-AuQUG.js → dist-76ArZ5M4.js} +1 -1
  7. package/dist/client/assets/{dist-DSHM-PAs.js → dist-9F1wL-T5.js} +1 -1
  8. package/dist/client/assets/{dist-UJ46aPS3.js → dist-B0RXZeXQ.js} +1 -1
  9. package/dist/client/assets/{dist-BAiV8I_O.js → dist-BCNaDgNW.js} +1 -1
  10. package/dist/client/assets/{dist-4JbFTwg2.js → dist-BXBSIuTD.js} +1 -1
  11. package/dist/client/assets/{dist-UPJPMjWv.js → dist-Bh8Q7Y_n.js} +1 -1
  12. package/dist/client/assets/{dist-CIgjifH-.js → dist-BoyICDlL.js} +1 -1
  13. package/dist/client/assets/{dist-2boAf_pN.js → dist-BuR5Iagd.js} +1 -1
  14. package/dist/client/assets/{dist-B1p4YF9C.js → dist-Bx6ZWYUW.js} +1 -1
  15. package/dist/client/assets/{dist-BTVbZigv.js → dist-CAOcjKAQ.js} +1 -1
  16. package/dist/client/assets/{dist-CjszAoXk.js → dist-CHt8PX8R.js} +1 -1
  17. package/dist/client/assets/{dist-bIDce5j-.js → dist-CSCUT1PQ.js} +1 -1
  18. package/dist/client/assets/{dist-Ds5gfeAi.js → dist-CUB_Chdh.js} +1 -1
  19. package/dist/client/assets/{dist-D-o7iQ8c.js → dist-CbVf2Cjn.js} +1 -1
  20. package/dist/client/assets/{dist-B9DE7sc5.js → dist-DBUqwiWG.js} +1 -1
  21. package/dist/client/assets/{dist-DM4Olwfx.js → dist-DC1IocrS.js} +1 -1
  22. package/dist/client/assets/{dist-CK2KFFtT.js → dist-DFMtP3wG.js} +1 -1
  23. package/dist/client/assets/{dist-BYOpvW02.js → dist-DN0GlnnZ.js} +1 -1
  24. package/dist/client/assets/{dist-CQFASxyb.js → dist-DftD4ibj.js} +1 -1
  25. package/dist/client/assets/{dist-BlxwDnWr.js → dist-Do52MRwm.js} +1 -1
  26. package/dist/client/assets/{dist-CQV5kOCE.js → dist-JvQIIdqB.js} +1 -1
  27. package/dist/client/assets/{dist-CRnm1rnO.js → dist-oLq6HXLG.js} +1 -1
  28. package/dist/client/assets/{index-CiIc734l.css → index-D-OxlUxN.css} +1 -1
  29. package/dist/client/assets/index-E7yaLa2C.js +102 -0
  30. package/dist/client/index.html +2 -2
  31. package/dist/server/agents.d.ts +1 -1
  32. package/dist/server/agents.js +3 -1
  33. package/dist/server/application/conversation-service.d.ts +1 -1
  34. package/dist/server/application/conversation-service.js +6 -4
  35. package/dist/server/application/run-service.d.ts +16 -2
  36. package/dist/server/application/run-service.js +121 -14
  37. package/dist/server/application/scheduled-task-service.d.ts +14 -1
  38. package/dist/server/application/scheduled-task-service.js +27 -2
  39. package/dist/server/application/session-orchestrator-service.d.ts +11 -2
  40. package/dist/server/application/session-orchestrator-service.js +103 -27
  41. package/dist/server/command-handler.js +1 -1
  42. package/dist/server/conversation-usage.d.ts +19 -0
  43. package/dist/server/conversation-usage.js +40 -0
  44. package/dist/server/file-diff.d.ts +3 -0
  45. package/dist/server/file-diff.js +4 -4
  46. package/dist/server/file-index.d.ts +4 -2
  47. package/dist/server/file-index.js +14 -9
  48. package/dist/server/file-name-index.d.ts +5 -2
  49. package/dist/server/file-name-index.js +22 -5
  50. package/dist/server/git.d.ts +3 -3
  51. package/dist/server/git.js +10 -9
  52. package/dist/server/http-server.js +195 -33
  53. package/dist/server/model-context-window.d.ts +46 -0
  54. package/dist/server/model-context-window.js +121 -0
  55. package/dist/server/pi-session.d.ts +6 -0
  56. package/dist/server/pi-session.js +15 -1
  57. package/dist/server/runtime.d.ts +3 -0
  58. package/dist/server/runtime.js +21 -6
  59. package/dist/server/session-cwd.d.ts +17 -0
  60. package/dist/server/session-cwd.js +43 -0
  61. package/dist/server/session-ledger.d.ts +7 -0
  62. package/dist/server/store.d.ts +22 -0
  63. package/dist/server/store.js +52 -0
  64. package/dist/server/task-tool.d.ts +2 -1
  65. package/dist/server/task-tool.js +3 -1
  66. package/dist/server/terminal.d.ts +1 -0
  67. package/dist/server/terminal.js +5 -3
  68. package/dist/server/turn-failure.js +16 -1
  69. package/dist/server/types.d.ts +18 -0
  70. package/dist/server/version.d.ts +25 -2
  71. package/dist/server/version.js +98 -26
  72. package/dist/server/ws-server.d.ts +1 -1
  73. package/dist/server/ws-server.js +7 -5
  74. package/package.json +20 -3
  75. package/dist/client/assets/index-BGsP8pt_.js +0 -100
@@ -1,39 +1,111 @@
1
- import { readFileSync } from "node:fs";
2
- import { join } from "node:path";
3
- let runningVersion = "0.1.3";
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { dirname, join, resolve } from "node:path";
3
+ export const UNKNOWN_VERSION = "0.0.0-unknown";
4
4
  /**
5
- * Initializes the version captured when this server process booted up.
5
+ * Reads and validates the version string from a package.json located in the given directory.
6
6
  */
7
- export function initRunningVersion(rootDir) {
7
+ export function readPackageVersion(dir) {
8
+ if (!dir || typeof dir !== "string")
9
+ return undefined;
8
10
  try {
9
- const pkg = JSON.parse(readFileSync(join(rootDir, "package.json"), "utf8"));
10
- if (pkg.version)
11
- runningVersion = pkg.version;
11
+ const pkgPath = join(dir, "package.json");
12
+ if (!existsSync(pkgPath))
13
+ return undefined;
14
+ const raw = readFileSync(pkgPath, "utf8");
15
+ const pkg = JSON.parse(raw);
16
+ if (pkg && typeof pkg.version === "string" && pkg.version.trim().length > 0) {
17
+ return pkg.version.trim();
18
+ }
12
19
  }
13
20
  catch {
14
- // fallback to default
21
+ // Read or JSON parse error - return undefined to allow self-healing / fallback
22
+ }
23
+ return undefined;
24
+ }
25
+ /**
26
+ * Resolves the version of Super Pi itself by searching relative to this module's location.
27
+ * In both development (`src/server/`) and production build (`dist/server/`), two levels up
28
+ * is the repository / package root containing package.json.
29
+ */
30
+ export function resolveSelfVersion(fromDir = import.meta.dirname) {
31
+ if (!fromDir || typeof fromDir !== "string")
32
+ return undefined;
33
+ // Primary path: two levels up from server module directory (src/server or dist/server)
34
+ const canonicalRoot = resolve(fromDir, "../..");
35
+ const canonicalVersion = readPackageVersion(canonicalRoot);
36
+ if (canonicalVersion)
37
+ return canonicalVersion;
38
+ // Secondary path: walk upwards to locate the nearest directory containing Super Pi's package.json
39
+ let current = resolve(fromDir);
40
+ while (true) {
41
+ try {
42
+ const pkgPath = join(current, "package.json");
43
+ if (existsSync(pkgPath)) {
44
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
45
+ if (pkg && pkg.name === "@evandu/super-pi" && typeof pkg.version === "string" && pkg.version.trim()) {
46
+ return pkg.version.trim();
47
+ }
48
+ }
49
+ }
50
+ catch {
51
+ // Continue searching upwards
52
+ }
53
+ const parent = dirname(current);
54
+ if (parent === current)
55
+ break;
56
+ current = parent;
57
+ }
58
+ return undefined;
59
+ }
60
+ let runningVersion = resolveSelfVersion() ?? UNKNOWN_VERSION;
61
+ /**
62
+ * Initializes the version captured when this server process booted up.
63
+ * If the provided rootDir fails to yield a valid package.json version,
64
+ * attempts to self-heal using the module's own location before falling back to UNKNOWN_VERSION.
65
+ */
66
+ export function initRunningVersion(rootDir, selfFromDir = import.meta.dirname) {
67
+ const direct = readPackageVersion(rootDir);
68
+ if (direct) {
69
+ runningVersion = direct;
70
+ return runningVersion;
71
+ }
72
+ const self = resolveSelfVersion(selfFromDir);
73
+ if (self) {
74
+ runningVersion = self;
75
+ return runningVersion;
15
76
  }
77
+ runningVersion = UNKNOWN_VERSION;
78
+ return runningVersion;
79
+ }
80
+ /**
81
+ * Returns the currently running version captured in memory.
82
+ */
83
+ export function getRunningVersion() {
84
+ return runningVersion;
85
+ }
86
+ /**
87
+ * Resets the in-memory running version, primarily for testing purposes.
88
+ */
89
+ export function resetRunningVersion(toVersion) {
90
+ runningVersion = toVersion ?? resolveSelfVersion() ?? UNKNOWN_VERSION;
16
91
  return runningVersion;
17
92
  }
18
93
  /**
19
94
  * Checks whether the package.json version on disk has been updated beyond
20
95
  * the version currently executing in this process.
96
+ * If rootDir fails to yield a valid package.json version, attempts to self-heal
97
+ * using the module's own location.
21
98
  */
22
- export function checkDiskVersion(rootDir) {
23
- try {
24
- const pkg = JSON.parse(readFileSync(join(rootDir, "package.json"), "utf8"));
25
- const diskVersion = pkg.version ?? runningVersion;
26
- return {
27
- runningVersion,
28
- diskVersion,
29
- needsRestart: diskVersion !== runningVersion,
30
- };
31
- }
32
- catch {
33
- return {
34
- runningVersion,
35
- diskVersion: runningVersion,
36
- needsRestart: false,
37
- };
38
- }
99
+ export function checkDiskVersion(rootDir, selfFromDir = import.meta.dirname) {
100
+ const diskVersion = readPackageVersion(rootDir) ??
101
+ resolveSelfVersion(selfFromDir) ??
102
+ runningVersion;
103
+ const needsRestart = Boolean(diskVersion !== runningVersion &&
104
+ runningVersion !== UNKNOWN_VERSION &&
105
+ diskVersion !== UNKNOWN_VERSION);
106
+ return {
107
+ runningVersion,
108
+ diskVersion,
109
+ needsRestart,
110
+ };
39
111
  }
@@ -71,7 +71,7 @@ export declare class WsBroadcaster implements EventBroadcaster {
71
71
  unregister(socket: WebSocket): void;
72
72
  subscribe(socket: WebSocket, conversationId?: string): void;
73
73
  sendState(socket: WebSocket): void;
74
- subscribeFileIndex(socket: WebSocket, workspaceId?: string): void;
74
+ subscribeFileIndex(socket: WebSocket, workspaceId?: string, cwd?: string): void;
75
75
  private receives;
76
76
  configureStreaming(socket: WebSocket, coalesce: boolean): void;
77
77
  private flushStreaming;
@@ -116,9 +116,9 @@ export class WsBroadcaster {
116
116
  this.flushStreaming(socket);
117
117
  safeSend(socket, JSON.stringify({ type: "state", state: this.getState(this.scopes.get(socket)) }));
118
118
  }
119
- subscribeFileIndex(socket, workspaceId) {
119
+ subscribeFileIndex(socket, workspaceId, cwd = "") {
120
120
  if (workspaceId)
121
- this.fileIndexScopes.set(socket, workspaceId);
121
+ this.fileIndexScopes.set(socket, { workspaceId, cwd });
122
122
  else
123
123
  this.fileIndexScopes.delete(socket);
124
124
  }
@@ -127,8 +127,10 @@ export class WsBroadcaster {
127
127
  if (!scope)
128
128
  return true;
129
129
  switch (event.type) {
130
- case "files.index":
131
- return this.fileIndexScopes.get(socket) === event.workspaceId;
130
+ case "files.index": {
131
+ const fileScope = this.fileIndexScopes.get(socket);
132
+ return fileScope?.workspaceId === event.workspaceId && fileScope.cwd === (event.cwd ?? "");
133
+ }
132
134
  case "message.delta":
133
135
  case "message.thinking":
134
136
  case "message.tools":
@@ -481,7 +483,7 @@ export class WsServer {
481
483
  return;
482
484
  }
483
485
  if (parsed.type === "files.index.subscribe") {
484
- this.broadcaster.subscribeFileIndex(socket, typeof parsed.workspaceId === "string" ? parsed.workspaceId : undefined);
486
+ this.broadcaster.subscribeFileIndex(socket, typeof parsed.workspaceId === "string" ? parsed.workspaceId : undefined, typeof parsed.cwd === "string" ? parsed.cwd : "");
485
487
  return;
486
488
  }
487
489
  if (parsed.type === "stream.configure") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evandu/super-pi",
3
- "version": "0.1.145",
3
+ "version": "0.1.146",
4
4
  "description": "Web control plane and companion for Pi",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -67,6 +67,7 @@
67
67
  "scripts/verify-source-text.test.mjs",
68
68
  "scripts/runtime-extension-ui.test.mjs",
69
69
  "scripts/agent-mechanism.test.mjs",
70
+ "scripts/super-pi-tool-names.test.mjs",
70
71
  "scripts/agent-wiring.test.mjs",
71
72
  "scripts/message-timestamps.test.mjs",
72
73
  "scripts/pi-resolution.test.mjs",
@@ -83,6 +84,8 @@
83
84
  "scripts/session-tree-collapse.test.mjs",
84
85
  "scripts/archive-cascade.test.mjs",
85
86
  "scripts/workspace-cwd.test.mjs",
87
+ "scripts/session-cwd.test.mjs",
88
+ "scripts/session-cwd-panels.test.mjs",
86
89
  "scripts/subagents.test.mjs",
87
90
  "scripts/subagent-noise.test.mjs",
88
91
  "scripts/subagent-response-receipt.test.mjs",
@@ -99,6 +102,7 @@
99
102
  "scripts/queue-store.test.mjs",
100
103
  "scripts/git-api.test.mjs",
101
104
  "scripts/turn-failure-marks-failed.test.mjs",
105
+ "scripts/model-context-window.test.mjs",
102
106
  "scripts/update-ui-contract.test.mjs",
103
107
  "scripts/temp-sweep.test.mjs",
104
108
  "scripts/workspace-identity.test.mjs",
@@ -192,7 +196,15 @@
192
196
  "scripts/scheduled-task-scope.test.mjs",
193
197
  "scripts/scheduled-task-tool.test.mjs",
194
198
  "scripts/run-state-sync.test.mjs",
195
- "scripts/performance-architecture.test.mjs"
199
+ "scripts/performance-architecture.test.mjs",
200
+ "scripts/upgrade-from-138-browser.test.mjs",
201
+ "scripts/session-orchestrator-role-prompt.test.mjs",
202
+ "scripts/context-overflow-failure.test.mjs",
203
+ "scripts/spawn-workspace-boundary.test.mjs",
204
+ "scripts/cwd-agent-spawn.test.mjs",
205
+ "scripts/capabilities-prompt.test.mjs",
206
+ "scripts/conversation-usage.test.mjs",
207
+ "scripts/orchestrator-observability.test.mjs"
196
208
  ],
197
209
  "check:browser": [
198
210
  "scripts/interrupt-browser.test.mjs",
@@ -268,7 +280,12 @@
268
280
  "scripts/ux-polish-browser.test.mjs",
269
281
  "scripts/prompt-templates-browser.test.mjs",
270
282
  "scripts/documents-browser.test.mjs",
271
- "scripts/feishu-browser.test.mjs"
283
+ "scripts/feishu-browser.test.mjs",
284
+ "scripts/session-read-state-regression.test.mjs",
285
+ "scripts/orchestrated-order-role-browser.test.mjs",
286
+ "scripts/result-file-link-browser.test.mjs",
287
+ "scripts/git-panel-confirm-browser.test.mjs",
288
+ "scripts/session-origin-badge-browser.test.mjs"
272
289
  ],
273
290
  "dependencies": {
274
291
  "@codemirror/commands": "^6.11.1",