@sapiom/harness 0.0.0 → 0.1.1

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 (246) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +44 -43
  3. package/dist/cli/auth.d.ts +26 -0
  4. package/dist/cli/auth.d.ts.map +1 -0
  5. package/dist/cli/auth.js +39 -0
  6. package/dist/cli/auth.js.map +1 -0
  7. package/dist/cli/bin.d.ts +3 -0
  8. package/dist/cli/bin.d.ts.map +1 -0
  9. package/dist/cli/bin.js +163 -0
  10. package/dist/cli/bin.js.map +1 -0
  11. package/dist/cli/consent.d.ts +15 -0
  12. package/dist/cli/consent.d.ts.map +1 -0
  13. package/dist/cli/consent.js +81 -0
  14. package/dist/cli/consent.js.map +1 -0
  15. package/dist/cli/doctor.d.ts +27 -0
  16. package/dist/cli/doctor.d.ts.map +1 -0
  17. package/dist/cli/doctor.js +74 -0
  18. package/dist/cli/doctor.js.map +1 -0
  19. package/dist/cli/machine-id.d.ts +19 -0
  20. package/dist/cli/machine-id.d.ts.map +1 -0
  21. package/dist/cli/machine-id.js +75 -0
  22. package/dist/cli/machine-id.js.map +1 -0
  23. package/dist/cli/paths.d.ts +3 -0
  24. package/dist/cli/paths.d.ts.map +1 -0
  25. package/dist/cli/paths.js +11 -0
  26. package/dist/cli/paths.js.map +1 -0
  27. package/dist/cli/settings.d.ts +26 -0
  28. package/dist/cli/settings.d.ts.map +1 -0
  29. package/dist/cli/settings.js +123 -0
  30. package/dist/cli/settings.js.map +1 -0
  31. package/dist/core/adapters/claude-code.d.ts +41 -0
  32. package/dist/core/adapters/claude-code.d.ts.map +1 -0
  33. package/dist/core/adapters/claude-code.js +238 -0
  34. package/dist/core/adapters/claude-code.js.map +1 -0
  35. package/dist/core/adapters/codex.d.ts +59 -0
  36. package/dist/core/adapters/codex.d.ts.map +1 -0
  37. package/dist/core/adapters/codex.js +319 -0
  38. package/dist/core/adapters/codex.js.map +1 -0
  39. package/dist/core/canvas-body.d.ts +45 -0
  40. package/dist/core/canvas-body.d.ts.map +1 -0
  41. package/dist/core/canvas-body.js +94 -0
  42. package/dist/core/canvas-body.js.map +1 -0
  43. package/dist/core/canvas-cache.d.ts +23 -0
  44. package/dist/core/canvas-cache.d.ts.map +1 -0
  45. package/dist/core/canvas-cache.js +64 -0
  46. package/dist/core/canvas-cache.js.map +1 -0
  47. package/dist/core/canvas-enrich.d.ts +106 -0
  48. package/dist/core/canvas-enrich.d.ts.map +1 -0
  49. package/dist/core/canvas-enrich.js +178 -0
  50. package/dist/core/canvas-enrich.js.map +1 -0
  51. package/dist/core/canvas-enrichment.d.ts +144 -0
  52. package/dist/core/canvas-enrichment.d.ts.map +1 -0
  53. package/dist/core/canvas-enrichment.js +192 -0
  54. package/dist/core/canvas-enrichment.js.map +1 -0
  55. package/dist/core/canvas-graph.d.ts +71 -0
  56. package/dist/core/canvas-graph.d.ts.map +1 -0
  57. package/dist/core/canvas-graph.js +111 -0
  58. package/dist/core/canvas-graph.js.map +1 -0
  59. package/dist/core/canvas-index-classify.d.ts +41 -0
  60. package/dist/core/canvas-index-classify.d.ts.map +1 -0
  61. package/dist/core/canvas-index-classify.js +63 -0
  62. package/dist/core/canvas-index-classify.js.map +1 -0
  63. package/dist/core/canvas-interconnections.d.ts +24 -0
  64. package/dist/core/canvas-interconnections.d.ts.map +1 -0
  65. package/dist/core/canvas-interconnections.js +96 -0
  66. package/dist/core/canvas-interconnections.js.map +1 -0
  67. package/dist/core/canvas-manifest-check.d.ts +15 -0
  68. package/dist/core/canvas-manifest-check.d.ts.map +1 -0
  69. package/dist/core/canvas-manifest-check.js +90 -0
  70. package/dist/core/canvas-manifest-check.js.map +1 -0
  71. package/dist/core/canvas-render.d.ts +73 -0
  72. package/dist/core/canvas-render.d.ts.map +1 -0
  73. package/dist/core/canvas-render.js +145 -0
  74. package/dist/core/canvas-render.js.map +1 -0
  75. package/dist/core/canvas-svg.d.ts +50 -0
  76. package/dist/core/canvas-svg.d.ts.map +1 -0
  77. package/dist/core/canvas-svg.js +240 -0
  78. package/dist/core/canvas-svg.js.map +1 -0
  79. package/dist/core/canvas-template.d.ts +43 -0
  80. package/dist/core/canvas-template.d.ts.map +1 -0
  81. package/dist/core/canvas-template.js +365 -0
  82. package/dist/core/canvas-template.js.map +1 -0
  83. package/dist/core/canvas-watcher.d.ts +25 -0
  84. package/dist/core/canvas-watcher.d.ts.map +1 -0
  85. package/dist/core/canvas-watcher.js +144 -0
  86. package/dist/core/canvas-watcher.js.map +1 -0
  87. package/dist/core/collector/batcher.d.ts +57 -0
  88. package/dist/core/collector/batcher.d.ts.map +1 -0
  89. package/dist/core/collector/batcher.js +143 -0
  90. package/dist/core/collector/batcher.js.map +1 -0
  91. package/dist/core/collector/codex-tailer.d.ts +85 -0
  92. package/dist/core/collector/codex-tailer.d.ts.map +1 -0
  93. package/dist/core/collector/codex-tailer.js +270 -0
  94. package/dist/core/collector/codex-tailer.js.map +1 -0
  95. package/dist/core/collector/normalizer.d.ts +33 -0
  96. package/dist/core/collector/normalizer.d.ts.map +1 -0
  97. package/dist/core/collector/normalizer.js +94 -0
  98. package/dist/core/collector/normalizer.js.map +1 -0
  99. package/dist/core/collector/seq.d.ts +14 -0
  100. package/dist/core/collector/seq.d.ts.map +1 -0
  101. package/dist/core/collector/seq.js +20 -0
  102. package/dist/core/collector/seq.js.map +1 -0
  103. package/dist/core/collector/store.d.ts +16 -0
  104. package/dist/core/collector/store.d.ts.map +1 -0
  105. package/dist/core/collector/store.js +30 -0
  106. package/dist/core/collector/store.js.map +1 -0
  107. package/dist/core/collector/transcript.d.ts +38 -0
  108. package/dist/core/collector/transcript.d.ts.map +1 -0
  109. package/dist/core/collector/transcript.js +110 -0
  110. package/dist/core/collector/transcript.js.map +1 -0
  111. package/dist/core/event-bus.d.ts +9 -0
  112. package/dist/core/event-bus.d.ts.map +1 -0
  113. package/dist/core/event-bus.js +25 -0
  114. package/dist/core/event-bus.js.map +1 -0
  115. package/dist/core/example-seed.d.ts +34 -0
  116. package/dist/core/example-seed.d.ts.map +1 -0
  117. package/dist/core/example-seed.js +277 -0
  118. package/dist/core/example-seed.js.map +1 -0
  119. package/dist/core/inject/claude-settings.d.ts +34 -0
  120. package/dist/core/inject/claude-settings.d.ts.map +1 -0
  121. package/dist/core/inject/claude-settings.js +152 -0
  122. package/dist/core/inject/claude-settings.js.map +1 -0
  123. package/dist/core/inject/mcp-config.d.ts +26 -0
  124. package/dist/core/inject/mcp-config.d.ts.map +1 -0
  125. package/dist/core/inject/mcp-config.js +39 -0
  126. package/dist/core/inject/mcp-config.js.map +1 -0
  127. package/dist/core/inject/retention.d.ts +66 -0
  128. package/dist/core/inject/retention.d.ts.map +1 -0
  129. package/dist/core/inject/retention.js +119 -0
  130. package/dist/core/inject/retention.js.map +1 -0
  131. package/dist/core/inject/system-prompt.d.ts +11 -0
  132. package/dist/core/inject/system-prompt.d.ts.map +1 -0
  133. package/dist/core/inject/system-prompt.js +22 -0
  134. package/dist/core/inject/system-prompt.js.map +1 -0
  135. package/dist/core/macro-runner.d.ts +36 -0
  136. package/dist/core/macro-runner.d.ts.map +1 -0
  137. package/dist/core/macro-runner.js +66 -0
  138. package/dist/core/macro-runner.js.map +1 -0
  139. package/dist/core/macros.d.ts +10 -0
  140. package/dist/core/macros.d.ts.map +1 -0
  141. package/dist/core/macros.js +59 -0
  142. package/dist/core/macros.js.map +1 -0
  143. package/dist/core/path-safety.d.ts +33 -0
  144. package/dist/core/path-safety.d.ts.map +1 -0
  145. package/dist/core/path-safety.js +63 -0
  146. package/dist/core/path-safety.js.map +1 -0
  147. package/dist/core/paths.d.ts +27 -0
  148. package/dist/core/paths.d.ts.map +1 -0
  149. package/dist/core/paths.js +43 -0
  150. package/dist/core/paths.js.map +1 -0
  151. package/dist/core/port-detector.d.ts +69 -0
  152. package/dist/core/port-detector.d.ts.map +1 -0
  153. package/dist/core/port-detector.js +121 -0
  154. package/dist/core/port-detector.js.map +1 -0
  155. package/dist/core/session-manager.d.ts +275 -0
  156. package/dist/core/session-manager.d.ts.map +1 -0
  157. package/dist/core/session-manager.js +729 -0
  158. package/dist/core/session-manager.js.map +1 -0
  159. package/dist/core/task-manager.d.ts +138 -0
  160. package/dist/core/task-manager.d.ts.map +1 -0
  161. package/dist/core/task-manager.js +286 -0
  162. package/dist/core/task-manager.js.map +1 -0
  163. package/dist/core/task-stream.d.ts +32 -0
  164. package/dist/core/task-stream.d.ts.map +1 -0
  165. package/dist/core/task-stream.js +87 -0
  166. package/dist/core/task-stream.js.map +1 -0
  167. package/dist/core/workflow-registry.d.ts +36 -0
  168. package/dist/core/workflow-registry.d.ts.map +1 -0
  169. package/dist/core/workflow-registry.js +220 -0
  170. package/dist/core/workflow-registry.js.map +1 -0
  171. package/dist/core/workspace-context.d.ts +43 -0
  172. package/dist/core/workspace-context.d.ts.map +1 -0
  173. package/dist/core/workspace-context.js +108 -0
  174. package/dist/core/workspace-context.js.map +1 -0
  175. package/dist/core/workspace-watcher.d.ts +26 -0
  176. package/dist/core/workspace-watcher.d.ts.map +1 -0
  177. package/dist/core/workspace-watcher.js +174 -0
  178. package/dist/core/workspace-watcher.js.map +1 -0
  179. package/dist/index.d.ts +6 -0
  180. package/dist/index.d.ts.map +1 -0
  181. package/dist/index.js +6 -0
  182. package/dist/index.js.map +1 -0
  183. package/dist/profiles/canvas-guidelines.d.ts +20 -0
  184. package/dist/profiles/canvas-guidelines.d.ts.map +1 -0
  185. package/dist/profiles/canvas-guidelines.js +48 -0
  186. package/dist/profiles/canvas-guidelines.js.map +1 -0
  187. package/dist/profiles/default.d.ts +10 -0
  188. package/dist/profiles/default.d.ts.map +1 -0
  189. package/dist/profiles/default.js +70 -0
  190. package/dist/profiles/default.js.map +1 -0
  191. package/dist/server/auth.d.ts +9 -0
  192. package/dist/server/auth.d.ts.map +1 -0
  193. package/dist/server/auth.js +28 -0
  194. package/dist/server/auth.js.map +1 -0
  195. package/dist/server/canvas-render.d.ts +18 -0
  196. package/dist/server/canvas-render.d.ts.map +1 -0
  197. package/dist/server/canvas-render.js +24 -0
  198. package/dist/server/canvas-render.js.map +1 -0
  199. package/dist/server/canvas.d.ts +12 -0
  200. package/dist/server/canvas.d.ts.map +1 -0
  201. package/dist/server/canvas.js +174 -0
  202. package/dist/server/canvas.js.map +1 -0
  203. package/dist/server/events-ws.d.ts +11 -0
  204. package/dist/server/events-ws.d.ts.map +1 -0
  205. package/dist/server/events-ws.js +24 -0
  206. package/dist/server/events-ws.js.map +1 -0
  207. package/dist/server/fs.d.ts +4 -0
  208. package/dist/server/fs.d.ts.map +1 -0
  209. package/dist/server/fs.js +88 -0
  210. package/dist/server/fs.js.map +1 -0
  211. package/dist/server/index.d.ts +83 -0
  212. package/dist/server/index.d.ts.map +1 -0
  213. package/dist/server/index.js +0 -0
  214. package/dist/server/index.js.map +1 -0
  215. package/dist/server/ingest.d.ts +74 -0
  216. package/dist/server/ingest.d.ts.map +1 -0
  217. package/dist/server/ingest.js +74 -0
  218. package/dist/server/ingest.js.map +1 -0
  219. package/dist/server/macros.d.ts +32 -0
  220. package/dist/server/macros.d.ts.map +1 -0
  221. package/dist/server/macros.js +76 -0
  222. package/dist/server/macros.js.map +1 -0
  223. package/dist/server/rest.d.ts +75 -0
  224. package/dist/server/rest.d.ts.map +1 -0
  225. package/dist/server/rest.js +235 -0
  226. package/dist/server/rest.js.map +1 -0
  227. package/dist/server/static.d.ts +8 -0
  228. package/dist/server/static.d.ts.map +1 -0
  229. package/dist/server/static.js +36 -0
  230. package/dist/server/static.js.map +1 -0
  231. package/dist/server/terminal-ws.d.ts +9 -0
  232. package/dist/server/terminal-ws.d.ts.map +1 -0
  233. package/dist/server/terminal-ws.js +59 -0
  234. package/dist/server/terminal-ws.js.map +1 -0
  235. package/dist/server/ws-router.d.ts +16 -0
  236. package/dist/server/ws-router.d.ts.map +1 -0
  237. package/dist/server/ws-router.js +26 -0
  238. package/dist/server/ws-router.js.map +1 -0
  239. package/dist/shared/types.d.ts +485 -0
  240. package/dist/shared/types.d.ts.map +1 -0
  241. package/dist/shared/types.js +80 -0
  242. package/dist/shared/types.js.map +1 -0
  243. package/dist/web/assets/index-B9R4TzH7.css +32 -0
  244. package/dist/web/assets/index-Dh97QAgq.js +192 -0
  245. package/dist/web/index.html +27 -0
  246. package/package.json +84 -7
@@ -0,0 +1,485 @@
1
+ /**
2
+ * Sapiom Harness — shared interface contract.
3
+ *
4
+ * Every workstream (terminal core, SPA, analytics, CLI, canvas) builds against
5
+ * the types in this file. Change them only by agreement — this file is the
6
+ * integration boundary.
7
+ */
8
+ export declare const DEFAULT_PORT = 4100;
9
+ /** All harness-owned state lives under this directory. Uninstall = delete it. */
10
+ export declare const HARNESS_HOME = "~/.sapiom/harness";
11
+ export declare const HARNESS_PATHS: {
12
+ /** Stable anonymous install id (uuid, created on first run). */
13
+ readonly machineId: "~/.sapiom/harness/machine-id";
14
+ /** Session registry — HarnessSession[] as JSON. */
15
+ readonly sessions: "~/.sapiom/harness/sessions.json";
16
+ /** Workflow registry — WorkflowInfo[] as JSON. */
17
+ readonly workflows: "~/.sapiom/harness/workflows.json";
18
+ /** Local analytics sink (one AnalyticsEvent per line). Always written. */
19
+ readonly events: "~/.sapiom/harness/events.ndjson";
20
+ /** User settings (opt-in state, macros overrides). */
21
+ readonly settings: "~/.sapiom/harness/settings.json";
22
+ /** Generated per-session agent config (claude settings/mcp-config files). */
23
+ readonly generated: "~/.sapiom/harness/generated";
24
+ /** The bundled example project, seeded lazily by POST /api/sample-project
25
+ * (the welcome panel's "Run the sample project") — stable so re-running
26
+ * the sample reuses the same copy instead of scattering fresh ones. */
27
+ readonly sampleProject: "~/.sapiom/harness/sample-project";
28
+ };
29
+ /**
30
+ * Canvas convention: agents write static HTML here, relative to the session
31
+ * cwd. The server watches this directory and serves it at
32
+ * `/canvas/<harnessSessionId>/`.
33
+ */
34
+ export declare const CANVAS_DIR = ".sapiom/canvas";
35
+ export declare const CANVAS_INDEX = ".sapiom/canvas/index.html";
36
+ /**
37
+ * Deterministic per-workflow renders live here (one `<slug>.html` per
38
+ * workflow, slugged by `slugForWorkflowPath` in core/canvas-render.ts),
39
+ * relative to the session cwd. `GET /canvas/:sessionId/` serves the bound
40
+ * workflow's render from this directory; `index.html` above stays the
41
+ * agent-authored/custom canvas and is never rewritten by the deterministic
42
+ * pipeline.
43
+ */
44
+ export declare const CANVAS_RENDERS_DIR = ".sapiom/canvas/renders";
45
+ /**
46
+ * Per-workflow enrichment cache lives here (one `<slug>.json` per workflow,
47
+ * same slug scheme as CANVAS_RENDERS_DIR), relative to the session cwd:
48
+ * `{ graph, enrichment, sourceFingerprint, enrichedAt }`. A stale
49
+ * sourceFingerprint keeps the enrichment displayed (with a "stale" chip)
50
+ * until a re-run replaces it — see core/canvas-enrich.ts.
51
+ */
52
+ export declare const CANVAS_CACHE_DIR = ".sapiom/canvas/cache";
53
+ /**
54
+ * Workspace-state convention: the harness mirrors this session's binding,
55
+ * the full workflow registry, and its own identity here, relative to the
56
+ * session cwd, so the agent has an always-current, agent-legible answer to
57
+ * "what am I working on" and "what workflows exist" without asking. Written
58
+ * on session create, on every `PATCH /api/sessions/:id/workflow`, and
59
+ * whenever the workflow registry changes (scan/connect) — see
60
+ * HarnessWorkspaceContext. Kept present (never deleted) even on unbind.
61
+ */
62
+ export declare const HARNESS_CONTEXT_FILE = ".sapiom/harness-context.json";
63
+ /**
64
+ * Environment variables passed to hook scripts / child processes.
65
+ * INGEST_TOKEN is a per-boot secret; /ingest rejects requests without it.
66
+ */
67
+ export declare const ENV: {
68
+ readonly ingestUrl: "SAPIOM_HARNESS_INGEST_URL";
69
+ readonly ingestToken: "SAPIOM_HARNESS_INGEST_TOKEN";
70
+ readonly sessionId: "SAPIOM_HARNESS_SESSION_ID";
71
+ readonly collectorUrl: "SAPIOM_COLLECTOR_URL";
72
+ };
73
+ export type HarnessKind = "claude-code" | "codex";
74
+ export type SessionStatus = "starting" | "running" | "exited";
75
+ /** A harness session = one pty running one agent process in one directory. */
76
+ export interface HarnessSession {
77
+ /** Our id (uuid). */
78
+ id: string;
79
+ /** The agent's own session id (Claude session uuid / Codex rollout id), once known. */
80
+ agentSessionId: string | null;
81
+ harness: HarnessKind;
82
+ /** Absolute path of the project directory the agent runs in. */
83
+ cwd: string;
84
+ /** Display title (first prompt, or directory basename until known). */
85
+ title: string;
86
+ status: SessionStatus;
87
+ createdAt: string;
88
+ lastActiveAt: string;
89
+ /** Exit code when status === "exited". */
90
+ exitCode?: number | null;
91
+ /** The workflow (by path) this session is currently bound to, if any. Set
92
+ * via `PATCH /api/sessions/:id/workflow`; mirrored into
93
+ * HARNESS_CONTEXT_FILE in the session's cwd so the agent can read it. */
94
+ boundWorkflowPath: string | null;
95
+ /**
96
+ * `status === "running"` only means the pty is alive — the agent's TUI
97
+ * can still be sitting on a blocking prompt (most commonly: "trust this
98
+ * directory?") that isn't accepting real input yet. `ready` is the
99
+ * stronger signal: this pty is actually interactive. Reset to `false` on
100
+ * every fresh spawn (including resume) and only ever set by
101
+ * `SessionManager.setReady()` — see there for what flips it. Injecting
102
+ * input (macros, `/sessions/:id/input`) against a not-ready session
103
+ * queues briefly then fails loudly (`SessionNotReadyError`) rather than
104
+ * silently writing into a TUI that isn't listening; raw terminal
105
+ * keystrokes (`write()`) are deliberately never gated on this, since a
106
+ * human must always be able to answer the blocking prompt themselves.
107
+ */
108
+ ready: boolean;
109
+ }
110
+ /** A resumable past session discovered from agent transcripts or our registry. */
111
+ export interface SessionSummary {
112
+ /** Back-reference to our session when the registry tracked it (source "registry"). */
113
+ harnessSessionId?: string;
114
+ agentSessionId: string;
115
+ harness: HarnessKind;
116
+ cwd: string;
117
+ title: string;
118
+ lastActiveAt: string;
119
+ source: "registry" | "transcript";
120
+ }
121
+ export interface DoctorCheck {
122
+ name: string;
123
+ ok: boolean;
124
+ detail: string;
125
+ }
126
+ export interface SpawnSpec {
127
+ command: string;
128
+ args: string[];
129
+ /** Merged over process.env. Use `null` to unset a variable. */
130
+ env: Record<string, string | null>;
131
+ cwd: string;
132
+ }
133
+ export interface LaunchOpts {
134
+ harnessSessionId: string;
135
+ cwd: string;
136
+ /** Absolute path to the generated system-prompt file (profile). */
137
+ systemPromptFile?: string;
138
+ /** Absolute path to the generated MCP config file. */
139
+ mcpConfigFile?: string;
140
+ /** Absolute path to the generated settings file (hooks). Claude only. */
141
+ settingsFile?: string;
142
+ /** Only consulted by `launchTask` — the one-shot prompt a headless
143
+ * background task runs, then exits. Unused by `launch`/`resume`. */
144
+ prompt?: string;
145
+ /** Only consulted by `launchTask` — model override (`--model`), e.g.
146
+ * "sonnet". Interactive sessions keep the user's own default. */
147
+ model?: string;
148
+ /** Only consulted by `launchTask` — hard cap on agent turns
149
+ * (`--max-turns`), so a bounded task can't run away. */
150
+ maxTurns?: number;
151
+ }
152
+ /**
153
+ * One implementation per supported coding agent. Implementations must be
154
+ * side-effect free until `launch`/`resume` specs are actually spawned.
155
+ */
156
+ export interface HarnessAdapter {
157
+ id: HarnessKind;
158
+ /** Binary present, version acceptable. */
159
+ doctor(): Promise<DoctorCheck[]>;
160
+ launch(opts: LaunchOpts): SpawnSpec;
161
+ resume(agentSessionId: string, opts: LaunchOpts): SpawnSpec;
162
+ /** How analytics events are sourced for this harness. */
163
+ eventSource: "hooks" | "transcript-tail";
164
+ /** Resumable sessions for a directory (agent-side history). */
165
+ listPastSessions(cwd: string): Promise<SessionSummary[]>;
166
+ /**
167
+ * Best-effort scrollback check for this harness's own known blocking
168
+ * prompts (e.g. "trust this directory?"), for harnesses whose real
169
+ * readiness signal (SessionStart-equivalent) can't be trusted to arrive
170
+ * before the very first input is worth injecting — see CodexAdapter's
171
+ * implementation for why. Optional: a harness whose readiness signal IS
172
+ * trustworthy standalone (Claude Code's SessionStart hook) should leave
173
+ * this unimplemented rather than have SessionManager fall back to a
174
+ * scrollback heuristic it doesn't need.
175
+ */
176
+ detectBlockingPrompt?(scrollback: string): boolean;
177
+ /**
178
+ * Builds a one-shot, headless invocation for `TaskManager.run()`: executes
179
+ * `opts.prompt` non-interactively and exits on its own when the turn
180
+ * completes — no pty write to submit it and no trust dialog to wait out
181
+ * (see ClaudeCodeAdapter's implementation, verified against a real
182
+ * `claude` binary: `-p` mode fires the same hooks a real session does and
183
+ * skips the trust prompt entirely). Stdout is expected to be line-oriented
184
+ * JSON progress events (see core/task-stream.ts). Optional: a harness with
185
+ * no non-interactive mode simply doesn't support background tasks yet —
186
+ * TaskManager throws a clear error rather than silently misusing `launch`.
187
+ */
188
+ launchTask?(opts: LaunchOpts): SpawnSpec;
189
+ }
190
+ export type BackgroundTaskStatus = "running" | "completed" | "failed";
191
+ /**
192
+ * One headless agent run (today: canvas enrichment, spawned on bind or by
193
+ * the visualize macro). Deliberately NOT a HarnessSession: tasks never
194
+ * appear in the session registry (so no tab, no resume, no ghost-record
195
+ * reconciliation to worry about) and live only in TaskManager's memory —
196
+ * the pty-less process exits on its own when its single turn completes.
197
+ */
198
+ export interface BackgroundTask {
199
+ /** Our id (uuid). Also used as the task's SAPIOM_HARNESS_SESSION_ID and
200
+ * its generated-config dir name (covered by the same retention sweep as
201
+ * real sessions — see core/inject/retention.ts). */
202
+ id: string;
203
+ /** The macro that spawned it (retry re-runs this id). */
204
+ macroId: string;
205
+ /** Display label, e.g. "Visualize". */
206
+ label: string;
207
+ /** The interactive session the macro was triggered from — the canvas pane
208
+ * showing that session renders this task's live status. */
209
+ harnessSessionId: string;
210
+ cwd: string;
211
+ /** The workflow this task was launched for, when it targets one — the
212
+ * canvas pane scopes its activity view to the session's CURRENT binding
213
+ * via this, so switching workflows mid-task never bleeds another
214
+ * workflow's progress into the pane. Null for workflow-less tasks. */
215
+ workflowPath: string | null;
216
+ status: BackgroundTaskStatus;
217
+ startedAt: string;
218
+ endedAt: string | null;
219
+ exitCode: number | null;
220
+ /** Rolling tail of compact human-readable progress lines derived from the
221
+ * task's stream-json stdout (see core/task-stream.ts), oldest first. */
222
+ statusLines: string[];
223
+ /** The final result event's text when the task completed successfully —
224
+ * the payload a structured task (canvas enrichment) parses. Null while
225
+ * running and on failure. */
226
+ resultText: string | null;
227
+ /** On failure: the result error / stderr tail worth showing a user. */
228
+ errorTail: string | null;
229
+ }
230
+ export interface TerminalResizeMessage {
231
+ type: "resize";
232
+ cols: number;
233
+ rows: number;
234
+ }
235
+ export type TerminalControlMessage = TerminalResizeMessage;
236
+ export type BusMessage = {
237
+ type: "session.status";
238
+ session: HarnessSession;
239
+ } | {
240
+ type: "canvas.reload";
241
+ harnessSessionId: string;
242
+ } | {
243
+ type: "port.detected";
244
+ harnessSessionId: string;
245
+ port: number;
246
+ url: string;
247
+ } | {
248
+ type: "workflows.changed";
249
+ }
250
+ /**
251
+ * Full snapshot of one background task, re-broadcast on every change
252
+ * (spawn, each new status line, completion/failure). Tasks are rare and
253
+ * their records small, so snapshot-per-change beats a separate delta
254
+ * protocol the SPA would have to stitch together after a mid-run mount.
255
+ */
256
+ | {
257
+ type: "task.status";
258
+ task: BackgroundTask;
259
+ }
260
+ /**
261
+ * Best-effort "this session's pty just produced output" signal, throttled
262
+ * server-side to at most once per session per ~2s (see SessionManager's
263
+ * pty.onData handler) — a lightweight substitute for byte-level streaming
264
+ * on /ws/events, which only the session with an open /ws/terminal socket
265
+ * receives. Drives the SPA's per-tab busy pulse for background sessions.
266
+ */
267
+ | {
268
+ type: "session.activity";
269
+ harnessSessionId: string;
270
+ at: string;
271
+ };
272
+ export declare const ANALYTICS_SCHEMA_VERSION = 1;
273
+ export type AnalyticsEventType = "session.start" | "prompt.submitted" | "tool.call" | "turn.completed" | "session.end";
274
+ /**
275
+ * The normalized event — the shape that (with opt-in) is batched to the
276
+ * remote collector and always appended to events.ndjson locally.
277
+ * `payload` is deliberately schemaless; it lands in a JSONB column.
278
+ */
279
+ export interface AnalyticsEvent {
280
+ eventId: string;
281
+ /** Per-harnessSessionId monotonic counter from 1 — ordering + loss detection. */
282
+ seq: number;
283
+ /** ISO-8601, client clock. Use seq (not ts) for intra-session ordering. */
284
+ ts: string;
285
+ /** Sapiom user id from auth; null when not logged in. */
286
+ userId: string | null;
287
+ /** Sapiom tenant id from auth; null when not logged in. */
288
+ tenantId: string | null;
289
+ machineId: string;
290
+ harnessSessionId: string;
291
+ agentSessionId: string | null;
292
+ harness: HarnessKind;
293
+ type: AnalyticsEventType;
294
+ payload: Record<string, unknown>;
295
+ }
296
+ /** Static per-install/boot context, sent at batch level. */
297
+ export interface CollectorContext {
298
+ harnessVersion: string;
299
+ os: string;
300
+ arch: string;
301
+ nodeVersion: string;
302
+ /** Best-effort agent binary versions, e.g. { "claude-code": "2.0.1" }. */
303
+ agentVersions?: Record<string, string>;
304
+ }
305
+ /**
306
+ * Batch POSTed to `${SAPIOM_COLLECTOR_URL}/v1/harness/events`.
307
+ * Delivery is at-least-once (3 retries then drop): consumers dedupe on
308
+ * eventId and detect loss via seq gaps. 2xx = accepted; 4xx = drop; 5xx = retry.
309
+ */
310
+ export interface CollectorBatch {
311
+ batchId: string;
312
+ schemaVersion: typeof ANALYTICS_SCHEMA_VERSION;
313
+ machineId: string;
314
+ sentAt: string;
315
+ context: CollectorContext;
316
+ events: AnalyticsEvent[];
317
+ }
318
+ export interface CreateSessionRequest {
319
+ cwd: string;
320
+ harness: HarnessKind;
321
+ /** Profile id; omit for default. */
322
+ profile?: string;
323
+ }
324
+ /** Inject text into the session pty (used by macros and the Visualize button). */
325
+ export interface InjectInputRequest {
326
+ text: string;
327
+ /** Append a carriage return (submit). Default true. */
328
+ submit?: boolean;
329
+ }
330
+ /** `PATCH /api/sessions/:id/workflow` body. `null` unbinds. `workflowPath`
331
+ * must be a path already known to the workflow registry (scan/connect). */
332
+ export interface BindWorkflowRequest {
333
+ workflowPath: string | null;
334
+ }
335
+ /** The trimmed workflow shape embedded in HarnessWorkspaceContext — just
336
+ * enough for an agent to identify a workflow, not the full WorkflowInfo
337
+ * (e.g. `source` is registry bookkeeping the agent has no use for). */
338
+ export interface HarnessWorkspaceContextWorkflow {
339
+ name: string;
340
+ path: string;
341
+ definitionId: number | null;
342
+ }
343
+ /**
344
+ * The shape written to HARNESS_CONTEXT_FILE in a session's cwd. Schemaless
345
+ * by convention elsewhere in the harness, but this one file IS a contract —
346
+ * the default system prompt tells the agent to read it, so its shape is
347
+ * fixed here like any other REST payload. Deliberately small and
348
+ * stable-ordered (`workflows` sorted by path) so an agent can diff it
349
+ * cheaply across reads rather than re-parsing a growing blob.
350
+ */
351
+ export interface HarnessWorkspaceContext {
352
+ boundWorkflow: HarnessWorkspaceContextWorkflow | null;
353
+ /** Every workflow currently known to this harness instance's registry,
354
+ * selected or not — lets an agent answer "what workflows exist" without
355
+ * a UI action, not just "which one is selected." */
356
+ workflows: HarnessWorkspaceContextWorkflow[];
357
+ session: {
358
+ id: string;
359
+ cwd: string;
360
+ harness: HarnessKind;
361
+ };
362
+ updatedAt: string;
363
+ }
364
+ export interface AppState {
365
+ version: string;
366
+ authenticated: boolean;
367
+ userId: string | null;
368
+ organizationName: string | null;
369
+ telemetryOptIn: boolean;
370
+ sessions: HarnessSession[];
371
+ workflows: WorkflowInfo[];
372
+ macros: MacroDef[];
373
+ /** The directory the CLI was launched against — the SPA prefills the
374
+ * new-session modal with this instead of recentDirs[0]. */
375
+ launchDir: string;
376
+ /** Harness kinds with a working binary on PATH at CLI boot (from doctor()),
377
+ * in default-preference order — `[0]` is what the auto-created boot
378
+ * session used. Optional: omitted by callers that construct AppState
379
+ * without running doctor (tests, mocks); the SPA should treat a missing
380
+ * value as "assume claude-code is available" until it's wired up. */
381
+ availableHarnesses?: HarnessKind[];
382
+ /** Background tasks known to this server boot (running + recent), so a
383
+ * page load mid-run shows the canvas activity state immediately instead
384
+ * of waiting for the next task.status frame. Optional: omitted by callers
385
+ * without a TaskManager (tests, mocks). */
386
+ tasks?: BackgroundTask[];
387
+ /** True when this boot found no prior harness use on this machine (no
388
+ * recent directories recorded before this launch). Computed once by the
389
+ * CLI *before* it records the launch dir / auto-creates the boot session,
390
+ * and constant for the server's lifetime — the SPA combines it with "no
391
+ * live sessions" to show the first-run welcome panel instead of a bare
392
+ * terminal. Optional so AppState constructed without the CLI (tests,
393
+ * mocks) reads as a returning user by default. */
394
+ firstRun?: boolean;
395
+ }
396
+ /** `POST /api/sample-project` response — the seeded (or reused) example. */
397
+ export interface SampleProjectSeedResponse {
398
+ /** Directory to open a session in — contains the project + its canvas. */
399
+ root: string;
400
+ /** Absolute path of the scaffolded example project inside `root`. */
401
+ projectDir: string;
402
+ /** False when an already-seeded copy was reused as-is. */
403
+ created: boolean;
404
+ }
405
+ export interface HarnessSettings {
406
+ telemetryOptIn: boolean;
407
+ /** Most-recently-used project directories, newest first. */
408
+ recentDirs: string[];
409
+ }
410
+ export interface FsDirEntry {
411
+ name: string;
412
+ path: string;
413
+ }
414
+ /**
415
+ * GET /api/fs/list?path= response — directories only, one level deep.
416
+ * `parent` is always a real path, never null: at the filesystem root it
417
+ * equals `path` itself (matches `path.dirname("/") === "/"`), so "no
418
+ * further up" is `parent === path`.
419
+ */
420
+ export interface FsListResponse {
421
+ path: string;
422
+ parent: string;
423
+ dirs: FsDirEntry[];
424
+ }
425
+ /** An orchestration project on disk, identified by its sapiom.json marker. */
426
+ export interface WorkflowInfo {
427
+ /** Directory name (or package.json name when present). */
428
+ name: string;
429
+ /** Absolute path to the project directory (contains sapiom.json). */
430
+ path: string;
431
+ /** From sapiom.json once linked; null before first link. */
432
+ definitionId: number | null;
433
+ /** How it entered the registry. */
434
+ source: "scan" | "connect";
435
+ }
436
+ /**
437
+ * A macro injects text into the active session's pty, opens a URL, or (the
438
+ * one exception to "always goes through the agent's session") runs the
439
+ * deterministic canvas render + AI enrichment refresh server-side. Template
440
+ * placeholders, substituted server-side before "inject"/"open-url" execution:
441
+ * {{workflow.path}} {{workflow.name}} {{workflow.definitionId}}
442
+ * {{session.cwd}} {{canvas.path}} {{subject}}
443
+ */
444
+ export interface MacroDef {
445
+ id: string;
446
+ label: string;
447
+ /** Lucide icon name rendered in the rail. */
448
+ icon: string;
449
+ action: {
450
+ kind: "inject";
451
+ text: string;
452
+ submit?: boolean;
453
+ } | {
454
+ kind: "open-url";
455
+ url: string;
456
+ }
457
+ /** Force refresh of the bound workflow's canvas: invalidates the
458
+ * extraction + enrichment caches, re-renders the deterministic diagram
459
+ * instantly, and re-spawns the bounded AI enrichment task (see
460
+ * core/canvas-enrich.ts) — no pty involved. A cheap no-op when the
461
+ * session is unbound. */
462
+ | {
463
+ kind: "render-canvas";
464
+ };
465
+ /** Macro requires a selected workflow to be enabled. */
466
+ requiresWorkflow?: boolean;
467
+ /**
468
+ * Where an `"inject"` macro's resolved text runs. Default (omitted /
469
+ * `"inject"`): written into the user's own active session pty, visible in
470
+ * their terminal and occupying their thread — same as always.
471
+ * `"background"`: run headless in a one-shot task process via
472
+ * TaskManager (the user's session is never touched), so a long-running
473
+ * macro can't interrupt whatever the user was doing.
474
+ * Ignored for non-"inject" actions.
475
+ */
476
+ execution?: "inject" | "background";
477
+ }
478
+ export interface RunMacroRequest {
479
+ harnessSessionId: string;
480
+ /** Selected workflow path, when the macro requires one. */
481
+ workflowPath?: string;
482
+ /** Free-text subject for the visualize macro. */
483
+ subject?: string;
484
+ }
485
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,iFAAiF;AACjF,eAAO,MAAM,YAAY,sBAAsB,CAAC;AAEhD,eAAO,MAAM,aAAa;IACxB,gEAAgE;;IAEhE,mDAAmD;;IAEnD,kDAAkD;;IAElD,0EAA0E;;IAE1E,sDAAsD;;IAEtD,6EAA6E;;IAE7E;;4EAEwE;;CAEhE,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,UAAU,mBAAmB,CAAC;AAC3C,eAAO,MAAM,YAAY,8BAA6B,CAAC;AAEvD;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,2BAA0B,CAAC;AAE1D;;;;;;GAMG;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AO,CAAA;KAAE,GAClD;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE;IACnC;;;;8BAI0B;OACxB;QAAE,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;IAC9B,wDAAwD;IACxD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,QAAQ,GAAG,YAAY,CAAC;CACrC;AAED,MAAM,WAAW,eAAe;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,2DAA2D;IAC3D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Sapiom Harness — shared interface contract.
3
+ *
4
+ * Every workstream (terminal core, SPA, analytics, CLI, canvas) builds against
5
+ * the types in this file. Change them only by agreement — this file is the
6
+ * integration boundary.
7
+ */
8
+ // ---------------------------------------------------------------------------
9
+ // Constants & well-known paths
10
+ // ---------------------------------------------------------------------------
11
+ export const DEFAULT_PORT = 4100;
12
+ /** All harness-owned state lives under this directory. Uninstall = delete it. */
13
+ export const HARNESS_HOME = "~/.sapiom/harness";
14
+ export const HARNESS_PATHS = {
15
+ /** Stable anonymous install id (uuid, created on first run). */
16
+ machineId: `${HARNESS_HOME}/machine-id`,
17
+ /** Session registry — HarnessSession[] as JSON. */
18
+ sessions: `${HARNESS_HOME}/sessions.json`,
19
+ /** Workflow registry — WorkflowInfo[] as JSON. */
20
+ workflows: `${HARNESS_HOME}/workflows.json`,
21
+ /** Local analytics sink (one AnalyticsEvent per line). Always written. */
22
+ events: `${HARNESS_HOME}/events.ndjson`,
23
+ /** User settings (opt-in state, macros overrides). */
24
+ settings: `${HARNESS_HOME}/settings.json`,
25
+ /** Generated per-session agent config (claude settings/mcp-config files). */
26
+ generated: `${HARNESS_HOME}/generated`,
27
+ /** The bundled example project, seeded lazily by POST /api/sample-project
28
+ * (the welcome panel's "Run the sample project") — stable so re-running
29
+ * the sample reuses the same copy instead of scattering fresh ones. */
30
+ sampleProject: `${HARNESS_HOME}/sample-project`,
31
+ };
32
+ /**
33
+ * Canvas convention: agents write static HTML here, relative to the session
34
+ * cwd. The server watches this directory and serves it at
35
+ * `/canvas/<harnessSessionId>/`.
36
+ */
37
+ export const CANVAS_DIR = ".sapiom/canvas";
38
+ export const CANVAS_INDEX = `${CANVAS_DIR}/index.html`;
39
+ /**
40
+ * Deterministic per-workflow renders live here (one `<slug>.html` per
41
+ * workflow, slugged by `slugForWorkflowPath` in core/canvas-render.ts),
42
+ * relative to the session cwd. `GET /canvas/:sessionId/` serves the bound
43
+ * workflow's render from this directory; `index.html` above stays the
44
+ * agent-authored/custom canvas and is never rewritten by the deterministic
45
+ * pipeline.
46
+ */
47
+ export const CANVAS_RENDERS_DIR = `${CANVAS_DIR}/renders`;
48
+ /**
49
+ * Per-workflow enrichment cache lives here (one `<slug>.json` per workflow,
50
+ * same slug scheme as CANVAS_RENDERS_DIR), relative to the session cwd:
51
+ * `{ graph, enrichment, sourceFingerprint, enrichedAt }`. A stale
52
+ * sourceFingerprint keeps the enrichment displayed (with a "stale" chip)
53
+ * until a re-run replaces it — see core/canvas-enrich.ts.
54
+ */
55
+ export const CANVAS_CACHE_DIR = `${CANVAS_DIR}/cache`;
56
+ /**
57
+ * Workspace-state convention: the harness mirrors this session's binding,
58
+ * the full workflow registry, and its own identity here, relative to the
59
+ * session cwd, so the agent has an always-current, agent-legible answer to
60
+ * "what am I working on" and "what workflows exist" without asking. Written
61
+ * on session create, on every `PATCH /api/sessions/:id/workflow`, and
62
+ * whenever the workflow registry changes (scan/connect) — see
63
+ * HarnessWorkspaceContext. Kept present (never deleted) even on unbind.
64
+ */
65
+ export const HARNESS_CONTEXT_FILE = ".sapiom/harness-context.json";
66
+ /**
67
+ * Environment variables passed to hook scripts / child processes.
68
+ * INGEST_TOKEN is a per-boot secret; /ingest rejects requests without it.
69
+ */
70
+ export const ENV = {
71
+ ingestUrl: "SAPIOM_HARNESS_INGEST_URL",
72
+ ingestToken: "SAPIOM_HARNESS_INGEST_TOKEN",
73
+ sessionId: "SAPIOM_HARNESS_SESSION_ID",
74
+ collectorUrl: "SAPIOM_COLLECTOR_URL",
75
+ };
76
+ // ---------------------------------------------------------------------------
77
+ // Analytics events
78
+ // ---------------------------------------------------------------------------
79
+ export const ANALYTICS_SCHEMA_VERSION = 1;
80
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,8EAA8E;AAC9E,+BAA+B;AAC/B,8EAA8E;AAE9E,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AAEjC,iFAAiF;AACjF,MAAM,CAAC,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAEhD,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,gEAAgE;IAChE,SAAS,EAAE,GAAG,YAAY,aAAa;IACvC,mDAAmD;IACnD,QAAQ,EAAE,GAAG,YAAY,gBAAgB;IACzC,kDAAkD;IAClD,SAAS,EAAE,GAAG,YAAY,iBAAiB;IAC3C,0EAA0E;IAC1E,MAAM,EAAE,GAAG,YAAY,gBAAgB;IACvC,sDAAsD;IACtD,QAAQ,EAAE,GAAG,YAAY,gBAAgB;IACzC,6EAA6E;IAC7E,SAAS,EAAE,GAAG,YAAY,YAAY;IACtC;;4EAEwE;IACxE,aAAa,EAAE,GAAG,YAAY,iBAAiB;CACvC,CAAC;AAEX;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAC3C,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,UAAU,aAAa,CAAC;AAEvD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,UAAU,UAAU,CAAC;AAE1D;;;;;;GAMG;AACH,MAA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