pi-harness-runtime 1.1.387 → 1.1.388

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 (127) hide show
  1. package/AGENTS.md +9 -4
  2. package/index.ts +20 -18
  3. package/package.json +1 -1
  4. package/packages/a2a-adapter/package.json +1 -1
  5. package/packages/agent-policy/package.json +1 -1
  6. package/packages/architecture-generator/package.json +1 -1
  7. package/packages/auth/package.json +1 -1
  8. package/packages/autonomous-refactor/package.json +1 -1
  9. package/packages/autonomous-runtime/package.json +1 -1
  10. package/packages/cache-strategy/package.json +1 -1
  11. package/packages/capability-registry/package.json +1 -1
  12. package/packages/checkpoint/package.json +1 -1
  13. package/packages/cli-plugin-sdk/package.json +1 -1
  14. package/packages/clipboard/package.json +1 -1
  15. package/packages/clipboard-plugin/package.json +1 -1
  16. package/packages/code-generation/package.json +1 -1
  17. package/packages/code-review/package.json +1 -1
  18. package/packages/codex-adapter/package.json +1 -1
  19. package/packages/codex-watcher/package.json +1 -1
  20. package/packages/config-capture/package.json +1 -1
  21. package/packages/connection-runtime/package.json +1 -1
  22. package/packages/context-compiler/package.json +1 -1
  23. package/packages/context-discovery/package.json +1 -1
  24. package/packages/context-manager/package.json +1 -1
  25. package/packages/contracts/dist/workspace-env-format.d.ts +71 -0
  26. package/packages/contracts/dist/workspace-env-format.js +120 -0
  27. package/packages/contracts/dist/workspace-env.d.ts +7 -30
  28. package/packages/contracts/dist/workspace-env.js +18 -57
  29. package/packages/contracts/package.json +1 -1
  30. package/packages/contracts/src/workspace-env-format.ts +165 -0
  31. package/packages/contracts/src/workspace-env.ts +27 -99
  32. package/packages/contracts/test/workspace-env.test.ts +144 -0
  33. package/packages/cookie-sanitizer/package.json +1 -1
  34. package/packages/cost-optimizer/package.json +1 -1
  35. package/packages/dependency-analyzer/package.json +1 -1
  36. package/packages/django-plugin/package.json +1 -1
  37. package/packages/doc-generator/package.json +1 -1
  38. package/packages/durable-review/package.json +1 -1
  39. package/packages/e2e-tester/package.json +1 -1
  40. package/packages/evaluation-engine/package.json +1 -1
  41. package/packages/evaluation-runner/package.json +1 -1
  42. package/packages/event-bus/package.json +1 -1
  43. package/packages/event-sink/package.json +1 -1
  44. package/packages/event-store/package.json +1 -1
  45. package/packages/experience-replay/package.json +1 -1
  46. package/packages/feedback-collector/package.json +1 -1
  47. package/packages/file-copy-helper/package.json +1 -1
  48. package/packages/framework-detector/package.json +1 -1
  49. package/packages/framework-plugin-sdk/package.json +1 -1
  50. package/packages/frappe-plugin/package.json +1 -1
  51. package/packages/generic-web-plugin/package.json +1 -1
  52. package/packages/health-monitor/package.json +1 -1
  53. package/packages/intent-analyzer/package.json +1 -1
  54. package/packages/jev-judge/package.json +1 -1
  55. package/packages/knowledge-graph/package.json +1 -1
  56. package/packages/knowledge-retrieval/package.json +1 -1
  57. package/packages/laravel-plugin/package.json +1 -1
  58. package/packages/learning-engine/package.json +1 -1
  59. package/packages/mcp-adapter/package.json +1 -1
  60. package/packages/memory-engine/package.json +1 -1
  61. package/packages/milestone-manager/package.json +1 -1
  62. package/packages/model-registry/package.json +1 -1
  63. package/packages/nextjs-plugin/package.json +1 -1
  64. package/packages/notification/package.json +1 -1
  65. package/packages/observability/package.json +1 -1
  66. package/packages/okf-indexer/package.json +1 -1
  67. package/packages/paperclip-integration/package.json +1 -1
  68. package/packages/performance-optimizer/package.json +1 -1
  69. package/packages/permission-mode/package.json +1 -1
  70. package/packages/privilege-broker/package.json +1 -1
  71. package/packages/project-analyzer/package.json +1 -1
  72. package/packages/project-bootstrap/package.json +1 -1
  73. package/packages/projection-engine/package.json +1 -1
  74. package/packages/prompt-compiler/package.json +1 -1
  75. package/packages/prompt-versioning/package.json +1 -1
  76. package/packages/provider-adapter-sdk/package.json +1 -1
  77. package/packages/provider-router/package.json +1 -1
  78. package/packages/provider-selector/package.json +1 -1
  79. package/packages/providers/package.json +1 -1
  80. package/packages/qdrant-skills/package.json +1 -1
  81. package/packages/quota-manager/package.json +1 -1
  82. package/packages/rate-limiter/package.json +1 -1
  83. package/packages/react-vite-plugin/package.json +1 -1
  84. package/packages/relay/dist/index.d.ts +3 -0
  85. package/packages/relay/dist/index.js +3 -0
  86. package/packages/relay/dist/relay-endpoint.d.ts +94 -0
  87. package/packages/relay/dist/relay-endpoint.js +239 -0
  88. package/packages/relay/package.json +1 -1
  89. package/packages/relay/src/index.ts +17 -0
  90. package/packages/relay/src/relay-endpoint.ts +304 -0
  91. package/packages/relay/test/relay-endpoint.test.ts +278 -0
  92. package/packages/release-manager/package.json +1 -1
  93. package/packages/requirement-compiler/package.json +1 -1
  94. package/packages/runtime/package.json +1 -1
  95. package/packages/scheduler/package.json +1 -1
  96. package/packages/scheduler-adapter/package.json +1 -1
  97. package/packages/session/package.json +1 -1
  98. package/packages/session-api/package.json +1 -1
  99. package/packages/session-export/package.json +1 -1
  100. package/packages/shared-context/package.json +1 -1
  101. package/packages/skill-mcp-client/package.json +1 -1
  102. package/packages/skill-registry/package.json +1 -1
  103. package/packages/skills/package.json +1 -1
  104. package/packages/sprint-planner/package.json +1 -1
  105. package/packages/subscription-engine/package.json +1 -1
  106. package/packages/task-compiler/package.json +1 -1
  107. package/packages/telegram/package.json +1 -1
  108. package/packages/tencentdb-memory/package.json +1 -1
  109. package/packages/tencentdb-sync/package.json +1 -1
  110. package/packages/test-data-generator/package.json +1 -1
  111. package/packages/test-generator/package.json +1 -1
  112. package/packages/todo-bd-sync/package.json +1 -1
  113. package/packages/token-estimation/package.json +1 -1
  114. package/packages/token-optimizer/package.json +1 -1
  115. package/packages/trajectory/package.json +1 -1
  116. package/packages/tui/package.json +1 -1
  117. package/packages/tui/test/harness-footer.test.ts +1 -1
  118. package/packages/types/package.json +1 -1
  119. package/packages/voice-api/package.json +1 -1
  120. package/packages/webmcp-tester/package.json +1 -1
  121. package/packages/wiki/package.json +1 -1
  122. package/packages/workflow-events/package.json +1 -1
  123. package/packages/workspace-scanner/package.json +1 -1
  124. package/packages/worktree/package.json +1 -1
  125. package/packages/write-review/package.json +1 -1
  126. package/scripts/relay-client.ts +24 -4
  127. package/scripts/unified-webhook-server.ts +29 -22
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/skills",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "description": "File-based skill system with pi.dev compatibility and Hermes self-improvement",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/sprint-planner",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "type": "module",
5
5
  "description": "Sprint planning engine for pi-harness",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/subscription-engine",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/task-compiler",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "description": "Task Compiler for pi-harness-runtime — produces deterministic task DAG from CompiledRequirement",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/telegram",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "description": "pi-harness-runtime — Telegram inbound/outbound",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moocoding/tencentdb-memory",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "description": "TencentDB Agent Memory client - sync skills to centralized knowledge base",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/tencentdb-sync",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "description": "Sync SKILL.md skills to TencentDB-Agent-Memory server (RFC-0105/0106)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/test-data-generator",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "description": "Test data generation for pi-harness-runtime",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/test-generator",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "description": "Auto-Test Generator — generate unit and E2E tests from source code (RFC-0013)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moocoding/todo-bd-sync",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "description": "Two-way sync between rpiv-todo overlay and bd issue tracker",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/token-estimation",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "description": "pi-harness-runtime — token-estimation",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/token-optimizer",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "description": "Token Budget Optimizer — maximize prompt value within token limits (RFC-0011)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/trajectory",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "description": "Trajectory capture for the write-review loop — persists cycle records for learning",
5
5
  "type": "module",
6
6
  "main": "./dist/src/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/tui",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "description": "pi-harness-runtime — tui",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -76,7 +76,7 @@ function makeSessionInfo(overrides: Partial<FooterSessionInfo> = {}): FooterSess
76
76
  }
77
77
 
78
78
  const QUOTA = "MiniMax: 5h: 98% left (resets 3 hr 15 min) - week: 85% left";
79
- const WORKSPACE = "Workspace: DEV | dev server: running | build: explicit request | RAM: 6.4/15";
79
+ const WORKSPACE = "Workspace: DEVELOPMENT | dev server: running | build: not running (script available) | RAM: 6.4/15";
80
80
 
81
81
  // ---------------------------------------------------------------------------
82
82
  // Tests
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/types",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "description": "Shared TypeScript types for pi-harness-runtime packages",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/voice-api",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "type": "module",
5
5
  "description": "Voice-to-text API using Whisper for Telegram and LINE integration",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/webmcp-tester",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "description": "WebMCP-powered E2E testing for pi-harness - natural language test scenarios",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/wiki",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "description": "LLM Wiki integration for pi-harness-runtime",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/workflow-events",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/workspace-scanner",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/worktree",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "description": "pi-harness-runtime — worktree",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moocoding/write-review",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "description": "Two-agent write-review loop with blackboard coordination",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -8,20 +8,31 @@
8
8
  * - Typed message handling
9
9
  *
10
10
  * Usage:
11
- * RELAY_WS_URL=wss://webhook.bunchee.online:8444 \
12
- * RELAY_AUTH_TOKEN=change-me-in-production \
13
11
  * bun run scripts/relay-client.ts
12
+ *
13
+ * The endpoint and the token are resolved from the environment and the key
14
+ * files (see resolveRelayEndpoint); no URL or token has to be passed in.
14
15
  */
15
16
 
16
17
  import { readFileSync, writeFileSync, existsSync } from "fs";
17
18
  import { join } from "path";
18
19
  import { homedir } from "os";
19
20
  import { RelayClient } from "../packages/relay/src/client";
21
+ import { describeRelayEndpoint, resolveRelayEndpoint } from "../packages/relay/src/relay-endpoint";
20
22
  import type { CallbackPayload, SnapshotMessage } from "../packages/relay/src/types";
21
23
 
22
24
  // Configuration
23
- const RELAY_WS_URL = process.env.RELAY_WS_URL || "wss://webhook.bunchee.online:8444";
24
- const RELAY_AUTH_TOKEN = process.env.RELAY_AUTH_TOKEN || "change-me-in-production";
25
+ // The relay endpoint is resolved from the SAME sources the relay server uses
26
+ // (env -> dedicated key file -> the telegram webhook url/secret), so the
27
+ // client and the server always agree on the URL and the token.
28
+ // The token value is never logged - only the source it came from.
29
+ const KEYS_DIR = join(homedir(), ".pi-harness-runtime", "keys");
30
+ const RELAY_ENDPOINT = resolveRelayEndpoint({ keysDir: KEYS_DIR });
31
+ // The resolver already consulted the environment - a value it rejected must
32
+ // NOT be re-used here, otherwise the client would connect to an endpoint the
33
+ // resolver deliberately skipped.
34
+ const RELAY_WS_URL = RELAY_ENDPOINT.url ?? "";
35
+ const RELAY_AUTH_TOKEN = RELAY_ENDPOINT.token ?? "";
25
36
  const JOB_PIPE_FILE = join(homedir(), ".pi-harness-runtime", "job-commands.jsonl");
26
37
 
27
38
  // ============================================================================
@@ -96,10 +107,19 @@ async function processCallback(callback: CallbackPayload): Promise<void> {
96
107
  // ============================================================================
97
108
 
98
109
  async function main() {
110
+ // Validate BEFORE printing the banner - an unconfigured run must not print
111
+ // an empty "Server:" line.
112
+ if (!RELAY_WS_URL || !RELAY_AUTH_TOKEN) {
113
+ console.error("[Client] Relay endpoint not configured");
114
+ console.error(`[Client] ${RELAY_ENDPOINT.missing.join("; ")}`);
115
+ process.exit(1);
116
+ }
117
+
99
118
  console.log("===========================================");
100
119
  console.log("Real-time Callback Relay Client - Streaming v2");
101
120
  console.log("===========================================");
102
121
  console.log(`Server: ${RELAY_WS_URL}`);
122
+ console.log(`Endpoint: ${describeRelayEndpoint(RELAY_ENDPOINT)}`);
103
123
  console.log("===========================================");
104
124
 
105
125
  // Create client with typed callbacks
@@ -22,6 +22,7 @@ import { join } from "node:path";
22
22
  import { homedir } from "os";
23
23
  import { createServer, IncomingMessage, ServerResponse } from "node:http";
24
24
  import { createRelayServer } from "../packages/relay/src/server";
25
+ import { resolveRelayEndpoint } from "../packages/relay/src/relay-endpoint";
25
26
  import { generateMessageId } from "../packages/relay/src/types";
26
27
  import type { CallbackPayload } from "../packages/relay/src/types";
27
28
  import type { RelayServerOptions } from "../packages/relay/src/server";
@@ -37,8 +38,8 @@ interface Config {
37
38
  accessToken: string;
38
39
  channelSecret: string;
39
40
  };
40
- /** Relay auth token used by WebSocket clients. */
41
- relayAuthToken: string;
41
+ /** Relay auth token used by WebSocket clients (null = relay stays off). */
42
+ relayAuthToken: string | null;
42
43
  }
43
44
 
44
45
  const PORT = parseInt(process.env.PORT || "8443", 10);
@@ -46,24 +47,17 @@ const WS_PORT = parseInt(process.env.WS_PORT || "8444", 10);
46
47
  /**
47
48
  * Resolve the relay auth token.
48
49
  *
49
- * Priority: RELAY_AUTH_TOKEN env -> keys/relay-auth-token.txt ->
50
- * keys/telegram-webhook-secret.txt -> placeholder.
50
+ * The chain lives in packages/relay/src/relay-endpoint.ts and is SHARED with
51
+ * the relay client, so the two sides can never disagree about the credential:
52
+ * RELAY_AUTH_TOKEN env -> keys/relay-auth-token.txt ->
53
+ * keys/telegram-webhook-secret.txt.
51
54
  *
52
- * Never hardcode a real token here; secrets live in key files.
55
+ * Never hardcode a real token here; secrets live in key files. When no token
56
+ * can be found the relay is NOT started at all - a placeholder token would
57
+ * let anyone who knows it connect to the relay.
53
58
  */
54
- function resolveAuthToken(keysDir: string): string {
55
- const fromEnv = process.env.RELAY_AUTH_TOKEN?.trim();
56
- if (fromEnv) return fromEnv;
57
-
58
- for (const name of ["relay-auth-token.txt", "telegram-webhook-secret.txt"]) {
59
- const path = join(keysDir, name);
60
- if (existsSync(path)) {
61
- const value = readFileSync(path, "utf-8").trim();
62
- if (value) return value;
63
- }
64
- }
65
-
66
- return "change-me-in-production";
59
+ function resolveAuthToken(keysDir: string): string | null {
60
+ return resolveRelayEndpoint({ keysDir }).token;
67
61
  }
68
62
  const SERVER_VERSION = process.env.SERVER_VERSION || "1.0.0";
69
63
 
@@ -377,14 +371,19 @@ async function main() {
377
371
  if (config.telegram) console.log(" /telegram - Telegram webhook");
378
372
  if (config.line) console.log(" /line - LINE webhook");
379
373
  console.log(` HTTP: http://0.0.0.0:${PORT}`);
380
- console.log(` WebSocket: ws://0.0.0.0:${WS_PORT}`);
374
+ console.log(
375
+ config.relayAuthToken
376
+ ? ` WebSocket: ws://0.0.0.0:${WS_PORT}`
377
+ : ` WebSocket: disabled (no relay auth token configured)`,
378
+ );
381
379
  console.log("===========================================");
382
380
 
383
381
  // Create relay server with typed streaming
384
382
  const relayOptions: RelayServerOptions = {
385
383
  port: WS_PORT,
386
384
  host: "0.0.0.0",
387
- authToken: config.relayAuthToken,
385
+ // Without a configured token the relay is never started - see below.
386
+ authToken: config.relayAuthToken ?? "",
388
387
  serverVersion: SERVER_VERSION,
389
388
  onStateChange: (change: { previous: { state: string }; current: { state: string }; timestamp: string }) => {
390
389
  console.log(`[Relay] State: ${change.previous.state} → ${change.current.state}`);
@@ -394,8 +393,16 @@ async function main() {
394
393
  const relayServer = createRelayServer(relayOptions);
395
394
 
396
395
  // Start WebSocket relay
397
- await relayServer.start();
398
- console.log("[Relay] WebSocket server started on port", WS_PORT);
396
+ if (config.relayAuthToken) {
397
+ await relayServer.start();
398
+ console.log("[Relay] WebSocket server started on port", WS_PORT);
399
+ } else {
400
+ // Fail closed: without a secret no client may connect. The HTTP webhook
401
+ // keeps working and the callbacks are queued on disk instead.
402
+ console.error(
403
+ "[Relay] No relay auth token configured (RELAY_AUTH_TOKEN, keys/relay-auth-token.txt or keys/telegram-webhook-secret.txt) - the relay WebSocket server will NOT start; callbacks are queued on disk.",
404
+ );
405
+ }
399
406
 
400
407
  // HTTP webhook server
401
408
  const server = createServer(async (req, res) => {