@wrongstack/cli 0.291.2 → 0.292.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.
Files changed (92) hide show
  1. package/dist/auth-menu/helpers.d.ts.map +1 -1
  2. package/dist/auth-menu/panel-service.d.ts +3 -0
  3. package/dist/auth-menu/panel-service.d.ts.map +1 -1
  4. package/dist/auth-menu/types.d.ts +2 -0
  5. package/dist/auth-menu/types.d.ts.map +1 -1
  6. package/dist/boot/config-backup-recovery.d.ts +34 -0
  7. package/dist/boot/config-backup-recovery.d.ts.map +1 -0
  8. package/dist/boot/dispatch-webui.d.ts +1 -1
  9. package/dist/boot/dispatch-webui.d.ts.map +1 -1
  10. package/dist/boot/short-circuit-hq.d.ts.map +1 -1
  11. package/dist/boot/simpleui-full-auto.d.ts +1 -1
  12. package/dist/boot/simpleui-full-auto.d.ts.map +1 -1
  13. package/dist/boot/tool-registry.d.ts.map +1 -1
  14. package/dist/boot/tui-settings-adapter.d.ts.map +1 -1
  15. package/dist/boot.d.ts.map +1 -1
  16. package/dist/cli-context.d.ts.map +1 -1
  17. package/dist/cli-main.d.ts.map +1 -1
  18. package/dist/config-history.d.ts +3 -3
  19. package/dist/config-history.d.ts.map +1 -1
  20. package/dist/execute-deps.d.ts +9 -0
  21. package/dist/execute-deps.d.ts.map +1 -1
  22. package/dist/execution.d.ts.map +1 -1
  23. package/dist/fleet/host.d.ts.map +1 -1
  24. package/dist/hq-server/routes.d.ts +96 -0
  25. package/dist/hq-server/routes.d.ts.map +1 -0
  26. package/dist/hq-server/snapshot.d.ts +3 -1
  27. package/dist/hq-server/snapshot.d.ts.map +1 -1
  28. package/dist/hq-server/startup.d.ts +50 -0
  29. package/dist/hq-server/startup.d.ts.map +1 -0
  30. package/dist/hq-server.d.ts +41 -57
  31. package/dist/hq-server.d.ts.map +1 -1
  32. package/dist/index.js +5592 -4606
  33. package/dist/index.js.map +4 -4
  34. package/dist/profile-config-path.d.ts +6 -0
  35. package/dist/profile-config-path.d.ts.map +1 -0
  36. package/dist/provider-config-utils.d.ts +2 -1
  37. package/dist/provider-config-utils.d.ts.map +1 -1
  38. package/dist/settings-menu.d.ts +20 -8
  39. package/dist/settings-menu.d.ts.map +1 -1
  40. package/dist/slash-commands/agents.d.ts.map +1 -1
  41. package/dist/slash-commands/auth.d.ts.map +1 -1
  42. package/dist/slash-commands/clear.d.ts.map +1 -1
  43. package/dist/slash-commands/context.d.ts.map +1 -1
  44. package/dist/slash-commands/doctor.d.ts.map +1 -1
  45. package/dist/slash-commands/enhance.d.ts.map +1 -1
  46. package/dist/slash-commands/fallback.d.ts +1 -1
  47. package/dist/slash-commands/fallback.d.ts.map +1 -1
  48. package/dist/slash-commands/gitid.d.ts +1 -1
  49. package/dist/slash-commands/gitid.d.ts.map +1 -1
  50. package/dist/slash-commands/hq.d.ts.map +1 -1
  51. package/dist/slash-commands/memory.d.ts.map +1 -1
  52. package/dist/slash-commands/models.d.ts.map +1 -1
  53. package/dist/slash-commands/refiner.d.ts.map +1 -1
  54. package/dist/slash-commands/setmodel.d.ts +1 -1
  55. package/dist/slash-commands/setmodel.d.ts.map +1 -1
  56. package/dist/slash-commands/settings.d.ts.map +1 -1
  57. package/dist/slash-commands/statusline.d.ts +1 -0
  58. package/dist/slash-commands/statusline.d.ts.map +1 -1
  59. package/dist/slash-commands/telegram-settings.d.ts.map +1 -1
  60. package/dist/slash-commands/telegram-setup.d.ts.map +1 -1
  61. package/dist/slash-commands/tool.d.ts.map +1 -1
  62. package/dist/slash-commands/tuneup.d.ts.map +1 -1
  63. package/dist/subcommands/handlers/auth.d.ts.map +1 -1
  64. package/dist/subcommands/handlers/hq.d.ts +11 -0
  65. package/dist/subcommands/handlers/hq.d.ts.map +1 -1
  66. package/dist/subcommands/handlers/mcp.d.ts.map +1 -1
  67. package/dist/subcommands/handlers/plugin-usage.d.ts.map +1 -1
  68. package/dist/subcommands/handlers/providers-models.d.ts.map +1 -1
  69. package/dist/subcommands/handlers/sessions-config.d.ts.map +1 -1
  70. package/dist/utils/hq-ttl.d.ts +21 -0
  71. package/dist/utils/hq-ttl.d.ts.map +1 -0
  72. package/dist/webui-server/message-router.d.ts +21 -3
  73. package/dist/webui-server/message-router.d.ts.map +1 -1
  74. package/dist/webui-server/prefs-seeding.d.ts +1 -1
  75. package/dist/webui-server/prefs-seeding.d.ts.map +1 -1
  76. package/dist/webui-server/provider-config.d.ts.map +1 -1
  77. package/dist/webui-server/ws-handlers/context.d.ts.map +1 -1
  78. package/dist/webui-server/ws-handlers/sessions.d.ts.map +1 -1
  79. package/dist/webui-server.d.ts +1 -1
  80. package/dist/webui-server.d.ts.map +1 -1
  81. package/dist/wiring/brain-and-orchestration.d.ts.map +1 -1
  82. package/dist/wiring/lifecycle-plugins.d.ts.map +1 -1
  83. package/dist/wiring/plugins.d.ts +9 -0
  84. package/dist/wiring/plugins.d.ts.map +1 -1
  85. package/dist/wiring/provider-runtime-setup.d.ts +1 -0
  86. package/dist/wiring/provider-runtime-setup.d.ts.map +1 -1
  87. package/dist/wiring/session.d.ts.map +1 -1
  88. package/dist/wiring/super-memory.d.ts +3 -1
  89. package/dist/wiring/super-memory.d.ts.map +1 -1
  90. package/dist/wiring/tools.d.ts +2 -2
  91. package/dist/wiring/tools.d.ts.map +1 -1
  92. package/package.json +21 -21
@@ -1,53 +1,61 @@
1
- import { type HqTranscriptEntry } from '@wrongstack/core';
1
+ /**
2
+ * HQ server — the read-only command-center backend for `wstack --hq`.
3
+ *
4
+ * Single HTTP server, single port. Two WebSocket upgrade paths:
5
+ * /ws/client — TUI/REPL/WebUI clients publish telemetry
6
+ * /ws/browser — HQ browser connects and receives snapshot + events
7
+ *
8
+ * Phase 1 is read-only: the HQ browser observes what clients publish. No
9
+ * control commands are sent to clients from the browser yet.
10
+ *
11
+ * Mailbox aggregation: every `mailbox.snapshot` envelope from a client is
12
+ * stored per-(client, mailbox) and merged into the global HqSnapshot on
13
+ * each browser poll / broadcast. Mailbox events still flow through as
14
+ * transient events; snapshots give us the authoritative rollups.
15
+ *
16
+ * @module hq-server
17
+ */
2
18
  import { HQ_HTML } from './hq-dashboard-html.js';
19
+ import { readLocalSubagentTranscript, agentRingKey, agentMessageToEntry, decodePathSegment, sanitizeApiError } from './hq-server/routes.js';
20
+ import type { ConnectedClient, TranscriptRing } from './hq-server/types.js';
21
+ export type { ConnectedClient, TranscriptRing };
22
+ export { HqInsecureExposureError } from '@wrongstack/core';
23
+ export { HQ_HTML };
24
+ export declare const DEFAULT_HOST = "127.0.0.1";
25
+ export declare const DEFAULT_PORT = 3499;
26
+ export declare const MAX_EVENT_LOG = 5000;
27
+ export declare const MAX_NON_STRICT_PORT_SCAN = 50;
28
+ export declare const CLIENT_TTL_MS = 60000;
29
+ export declare const CLIENT_CLEANUP_INTERVAL_MS = 30000;
30
+ export declare const BROWSER_HEARTBEAT_INTERVAL_MS = 15000;
31
+ export declare const SESSION_SNAPSHOT_TTL_MS = 30000;
32
+ export { readLocalSubagentTranscript, decodePathSegment, sanitizeApiError, agentRingKey, agentMessageToEntry, };
3
33
  export interface HqServerOptions {
4
34
  host?: string;
5
35
  port?: number;
6
36
  strictPort?: boolean;
7
- /**
8
- * When true, the server binds exactly to `port` and fails with an error
9
- * if that port is already in use — no port scanning. Use this when the
10
- * user explicitly selected a port and we should not silently pick another.
11
- */
12
37
  exactPort?: boolean;
13
- /**
14
- * HQ data directory. When omitted, the server resolves one via
15
- * `resolveHqDataDir()` (honoring `WRONGSTACK_HQ_DATA_DIR` then falling
16
- * back to `~/.wrongstack/hq`). The directory holds `auth.json` and, in
17
- * later phases, the persistent event log and snapshot cache.
18
- */
19
38
  dataDir?: string;
20
- /** Browser liveness frame interval. Primarily exposed for deterministic integration tests. */
21
39
  browserHeartbeatIntervalMs?: number;
22
- /** Connected-client inactivity timeout. Primarily exposed for deterministic integration tests. */
23
40
  clientTtlMs?: number;
24
- /** Stale-client scan interval. Primarily exposed for deterministic integration tests. */
25
41
  clientCleanupIntervalMs?: number;
26
- /** Session-snapshot freshness timeout. Primarily exposed for deterministic integration tests. */
27
42
  sessionSnapshotTtlMs?: number;
28
- /** Optional browser password login. Sets or rotates the scrypt hash in auth.json. */
29
43
  password?: string;
30
- /**
31
- * Allow a non-loopback bind while HQ is in open mode (no tokens, no
32
- * password). Off by default: that pairing serves POST /api/command
33
- * unauthenticated to the whole network. See assessHqExposure.
34
- */
35
44
  allowInsecureOpen?: boolean;
36
- /**
37
- * Set `Secure` flag on session cookies. Enable this when HQ is behind a
38
- * TLS-terminating reverse proxy. Defaults to `false` because HQ speaks
39
- * plain HTTP; setting `Secure` on an HTTP cookie makes it invisible to
40
- * the browser.
41
- */
42
45
  secureCookies?: boolean;
46
+ requireBrowserAuth?: boolean;
43
47
  /**
44
- * Keep browser authentication enabled for the full server lifetime. Used
45
- * by public relays such as --tunnel so an auth.json reload cannot silently
46
- * turn an authenticated public endpoint into open mode.
48
+ * Optional time-to-live (milliseconds) stamped on the first-run browser
49
+ * and client tokens minted on a brand-new HQ data directory. Existing
50
+ * auth.json files are not modified. When set, tokens carry an `expiresAt`
51
+ * and the server refuses them past that timestamp; default is no expiry.
52
+ *
53
+ * Useful for short-lived deployments (CI, ephemeral relays) where a leaked
54
+ * first-run token should not outlive the deployment window. Set via the
55
+ * `--hq-token-ttl-ms` CLI flag.
47
56
  */
48
- requireBrowserAuth?: boolean;
57
+ tokenTtlMs?: number;
49
58
  }
50
- export { HqInsecureExposureError } from '@wrongstack/core';
51
59
  export interface HqStartupConnectionInfo {
52
60
  dataDir: string;
53
61
  browserUrl: string;
@@ -65,32 +73,8 @@ export interface HqServerHandle {
65
73
  host: string;
66
74
  port: number;
67
75
  firstRunSetup?: HqFirstRunSetup;
68
- /** Authorize an exact browser-facing HTTPS origin established by trusted server code. */
69
76
  trustPublicOrigin(origin: string): void;
70
77
  close(): Promise<void>;
71
78
  }
72
- /**
73
- * Read one local subagent's FULL conversation from disk. The agent monitor
74
- * writes every timeline entry to
75
- * <projectSessions>/<sessionId>/subagents/transcripts/<subId>/transcript.jsonl
76
- * so for sessions on THIS machine we can serve the complete history — not
77
- * just the ≤4000-entry live ring. Returns null when the session isn't local
78
- * or the file is absent (caller falls back to the ring).
79
- */
80
- export declare function readLocalSubagentTranscript(sessionId: string, subagentId: string): Promise<HqTranscriptEntry[] | null>;
81
- /**
82
- * Library default: loopback. `startHqServer` is called programmatically
83
- * (tests, embedders) as well as from the CLI, and a caller that never
84
- * mentions a host has not asked to be reachable from the network.
85
- *
86
- * HQ is still the deliberate cross-machine surface — the CLI entry points
87
- * (`wstack hq`, the launch menu) pass HQ_CLI_DEFAULT_HOST explicitly, so
88
- * `wstack hq` binds every interface with no extra flag. Keeping the wide
89
- * bind at the CLI edge rather than in this default is what stops an
90
- * unrelated embedder from silently publishing HQ to its whole network.
91
- */
92
- export declare const DEFAULT_HOST = "127.0.0.1";
93
- export declare const DEFAULT_PORT = 3499;
94
- export { HQ_HTML };
95
79
  export declare function startHqServer(options?: HqServerOptions): Promise<HqServerHandle>;
96
80
  //# sourceMappingURL=hq-server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hq-server.d.ts","sourceRoot":"","sources":["../src/hq-server.ts"],"names":[],"mappings":"AAsBA,OAAO,EA0BL,KAAK,iBAAiB,EAevB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAUjD,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8FAA8F;IAC9F,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,kGAAkG;IAClG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yFAAyF;IACzF,uBAAuB,CAAC,EAA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