angine 0.0.0-stage → 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 (69) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +21 -0
  3. package/README.md +175 -2
  4. package/dist/bin/angine.d.ts +2 -0
  5. package/dist/bin/angine.js +85 -0
  6. package/dist/bin/angine.js.map +1 -0
  7. package/dist/src/colors.d.ts +4 -0
  8. package/dist/src/colors.js +9 -0
  9. package/dist/src/colors.js.map +1 -0
  10. package/dist/src/config.d.ts +1 -0
  11. package/dist/src/config.js +24 -0
  12. package/dist/src/config.js.map +1 -0
  13. package/dist/src/daemon.d.ts +1 -0
  14. package/dist/src/daemon.js +227 -0
  15. package/dist/src/daemon.js.map +1 -0
  16. package/dist/src/dashboard.d.ts +4 -0
  17. package/dist/src/dashboard.js +63 -0
  18. package/dist/src/dashboard.js.map +1 -0
  19. package/dist/src/graph.d.ts +47 -0
  20. package/dist/src/graph.js +100 -0
  21. package/dist/src/graph.js.map +1 -0
  22. package/dist/src/health.d.ts +13 -0
  23. package/dist/src/health.js +66 -0
  24. package/dist/src/health.js.map +1 -0
  25. package/dist/src/hierarchy.d.ts +7 -0
  26. package/dist/src/hierarchy.js +41 -0
  27. package/dist/src/hierarchy.js.map +1 -0
  28. package/dist/src/identity.d.ts +3 -0
  29. package/dist/src/identity.js +12 -0
  30. package/dist/src/identity.js.map +1 -0
  31. package/dist/src/ipc.d.ts +5 -0
  32. package/dist/src/ipc.js +101 -0
  33. package/dist/src/ipc.js.map +1 -0
  34. package/dist/src/mcp.d.ts +1 -0
  35. package/dist/src/mcp.js +85 -0
  36. package/dist/src/mcp.js.map +1 -0
  37. package/dist/src/model.d.ts +13 -0
  38. package/dist/src/model.js +93 -0
  39. package/dist/src/model.js.map +1 -0
  40. package/dist/src/paths.d.ts +7 -0
  41. package/dist/src/paths.js +12 -0
  42. package/dist/src/paths.js.map +1 -0
  43. package/dist/src/reporting.d.ts +21 -0
  44. package/dist/src/reporting.js +51 -0
  45. package/dist/src/reporting.js.map +1 -0
  46. package/dist/src/repositories.d.ts +4 -0
  47. package/dist/src/repositories.js +60 -0
  48. package/dist/src/repositories.js.map +1 -0
  49. package/dist/src/setup.d.ts +15 -0
  50. package/dist/src/setup.js +220 -0
  51. package/dist/src/setup.js.map +1 -0
  52. package/dist/src/store.d.ts +29 -0
  53. package/dist/src/store.js +419 -0
  54. package/dist/src/store.js.map +1 -0
  55. package/dist/src/types.d.ts +211 -0
  56. package/dist/src/types.js +2 -0
  57. package/dist/src/types.js.map +1 -0
  58. package/dist/src/workflow.d.ts +4 -0
  59. package/dist/src/workflow.js +21 -0
  60. package/dist/src/workflow.js.map +1 -0
  61. package/docs/protocol.md +142 -0
  62. package/docs/releases/v0.1.0.md +15 -0
  63. package/docs/releases/v0.1.1.md +21 -0
  64. package/docs/releasing.md +58 -0
  65. package/package.json +60 -4
  66. package/ui/dist/assets/index-DG1yX0hc.js +7 -0
  67. package/ui/dist/assets/index-Dspuc4WV.css +1 -0
  68. package/ui/dist/favicon.svg +4 -0
  69. package/ui/dist/index.html +4 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ # Release notes
2
+
3
+ ## 0.1.1 — Worktrees, colors, and graph
4
+
5
+ - Add a live React Flow graph tab with pan/zoom, draggable nodes, minimap, filtering, inherited colors, and saved node positions.
6
+
7
+ - Group Git worktrees under their shared repository while retaining workspace paths and observed branches.
8
+ - Merge existing worktree projects with a backup; preserve mission/task/session IDs, archived work, project links, and event history.
9
+ - Add a default color per project, inherited by missions and tasks, with editable project colors and optional mission overrides.
10
+
11
+ ## 0.1.0 — Initial local MVP
12
+
13
+ - Project → Missions → Tasks, with workspace grouping, mission pages and filters, and automatic migration preserving IDs/history.
14
+ - Agent-reported mission plans and task updates over MCP, CLI, and local HTTP.
15
+ - Setup integration for Codex and Claude Code, with automatic server startup on reporting.
16
+ - Project and task pages, status lists, progress, and independently scrolling board columns.
17
+ - Agent/profile/project filtering, saved filters, stale indicators, and configurable browser alerts.
18
+ - Profiles, reported sessions and child-agent IDs, shared projects, related tasks, and blocker details.
19
+ - Archive/restore controls that preserve local history.
20
+ - Metadata persistence, input validation, token-protected HTTP reporting, and same-origin dashboard edits.
21
+ - A restart command for loading server updates, with proactive UI/server compatibility notices.
22
+ - MCP reporter heartbeat, connection check, accepted/rejected report diagnostics, and a compact needs-attention summary.
23
+ - Expandable connection instructions and secondary filters to keep the main views concise.
24
+
25
+ This version depends on agents reporting their work. Shared team hosting, Wi-Fi/mobile access, independent observation, and alerts with no open dashboard tab are future work.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Angine contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,176 @@
1
- # Temporary Holding Version
1
+ # Angine
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **One local dashboard for work reported by your coding agents.**
4
+
5
+ [![npm version](https://img.shields.io/npm/v/angine)](https://www.npmjs.com/package/angine)
6
+ [![CI](https://github.com/askinjohn/angine/actions/workflows/ci.yml/badge.svg)](https://github.com/askinjohn/angine/actions/workflows/ci.yml)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
8
+
9
+ Working with Claude Code and Codex across several projects? Angine brings their reported goals, tasks, progress, and blockers into one place. Agents send updates through MCP while they work, and you follow them in your browser.
10
+
11
+ **Local storage · Open source · Claude Code and Codex setup · Shared missions across agents**
12
+
13
+ **v0.1.1 is an early local release.** Angine relies on reports from connected agents; it does not independently observe their tool calls, file changes, or transcripts.
14
+
15
+ ## Quick start
16
+
17
+ Requires Node.js 20 or later and a supported agent CLI installed locally. Git must be available for automatic repository/worktree grouping.
18
+
19
+ ```bash
20
+ npm install -g angine
21
+ angine setup
22
+ ```
23
+
24
+ `angine setup` configures detected Codex and Claude Code CLIs, starts the Angine server, and opens the dashboard. Restart your agent sessions after setup so they load the integration. You can configure just one with `angine setup codex` or `angine setup claude`.
25
+
26
+ Installing the package alone does not start Angine or configure an agent. After setup, agent reports start the server automatically when needed. Run `angine` anytime to reopen the dashboard.
27
+
28
+ ## What you can see
29
+
30
+ | View | What it answers |
31
+ | --- | --- |
32
+ | Projects and missions | Which goals are running across my repositories? |
33
+ | Graph | How do projects, missions, and tasks connect on a live canvas? |
34
+ | Tasks and board | What is complete, in progress, or blocked? |
35
+ | Needs attention | Which work has failed or stopped reporting recently? |
36
+ | Agents and sessions | Which reporter is connected, and which work belongs to it? |
37
+
38
+ ### Project → Missions → Tasks
39
+
40
+ ```text
41
+ My app
42
+ ├── Improve checkout
43
+ │ ├── Validate payment amount — Claude Code
44
+ │ └── Verify checkout flow — Codex
45
+ └── Update documentation
46
+ └── Write the setup guide — Claude Code
47
+ ```
48
+
49
+ A project is a repository (or a folder outside Git); a mission is a goal; a task is a step toward that goal. Multiple agents can contribute to the same mission when they report the same workspace and mission key.
50
+
51
+ ## How it works
52
+
53
+ 1. Setup registers a local MCP reporter and adds instructions telling the agent when to report.
54
+ 2. The agent registers a mission with `sync_project`, using stable project, mission, and task keys.
55
+ 3. It sends meaningful status changes with `update_tasks`.
56
+ 4. The dashboard receives updates and shows the reported work live.
57
+
58
+ Angine collects short metadata: titles, statuses, progress, notes, timestamps, and optional reporter identity. Reports must not contain prompts, reasoning, source code, diffs, commands, terminal output, credentials, or environment variables. Angine does not read those sources itself. Reporting quality depends on the agent following the reporting instructions.
59
+
60
+ ## Included in the MVP
61
+
62
+ - **Projects:** one container per local workspace, showing mission counts, running work, agents, and attention needed.
63
+ - **Missions:** project colors carry through to missions and tasks, with optional mission overrides in each detail page’s color control; goals within a project, grouped by status, with task completion percentages and separately scrolling sections.
64
+ - **Tasks:** status groups, reported progress, project and mission filters, and dedicated detail pages.
65
+ - **Board:** status columns with independent vertical scrolling.
66
+ - **Graph:** a top-down React Flow canvas with Project → Mission → Task connections, readable default zoom, drag-to-arrange nodes, pan/zoom, minimap, filters, and links to details. Reports add nodes automatically. The opening overview shows all project cards; expand a project to show missions, then expand a mission to show tasks. All projects returns to the overview. Searching and filtering reveal matching branches. Node positions are saved in this browser; Auto arrange resets the layout. Connections reflect reported hierarchy and are not edited by dragging nodes.
67
+ - **Filters:** search, agent, profile, project, mission, status, and stale activity; saved separately for each view in your browser.
68
+ - **Connection health:** automatic MCP reporter heartbeats, accepted/rejected report counts, a connection check tool, and explicit server update notices.
69
+ - **Needs attention:** a compact summary of blocked, failed, stale, and tracked disconnected work; detailed diagnostics stay expandable.
70
+ - **Agents and sessions:** editable profiles, reporter sessions, supplied native session IDs, and parent/child links when IDs are reported.
71
+ - **Related work:** agents can share a project and mission, and link related tasks within that mission.
72
+ - **Blockers:** reason, next action, and optional owner.
73
+ - **Archive:** hide projects or individual missions and restore them without deleting their tasks or history.
74
+ - **Stale indicators:** flag active work with no recent report; threshold is configurable and does not change task status.
75
+ - **Notifications:** optional desktop alerts for existing tasks that finish or become blocked. An Angine browser tab must remain open, and browser/OS permission must be allowed.
76
+
77
+ Task progress is reported explicitly. Unknown active progress displays “Not reported”; completed tasks show 100% and to-do tasks show 0%. Mission progress is the share of non-cancelled tasks completed, not an estimate of effort. Projects stay active as long-lived containers; completing their current missions does not close them.
78
+
79
+ ## Connecting a profile
80
+
81
+ A profile labels a reporter's work and can hold a context, owner name/email, and account nickname. Those details are user supplied; Angine does not retrieve or verify the agent's login account. Initial profiles use a neutral Other context.
82
+
83
+ Create or edit profiles in **Agents**. A profile connects in either of two ways:
84
+
85
+ - Set it as the default for its agent type. Reports without a profile key use it.
86
+ - Configure that agent's Angine MCP connection with the profile's stable key:
87
+
88
+ ```text
89
+ command: angine
90
+ args: mcp --agent claude --profile claude-default
91
+ ```
92
+
93
+ Replace the agent name and profile key with your own. Creating a profile does not install, connect, or start the agent. Additional agents can report through MCP, CLI, or HTTP. Adding a profile for another agent does not create an integration for it.
94
+
95
+ Git worktrees group under one project using their shared local Git repository. Worktree paths and observed branches remain visible in mission and reporter details. Separate clones stay separate, even when their names or remotes match. Non-Git folders group by canonical workspace path. Two agents share a mission by reporting workspaces in that repository and the same stable mission key. Existing duplicate missions remain separate during migration, even if they share a key. Use distinct task keys within each mission; the same task key may appear in other missions. Parent/child agent relationships require supplied identifiers; Angine does not invent them. Codex native session IDs are populated when its runtime makes them available to the reporter; other identity fields are optional.
96
+
97
+ <details>
98
+ <summary>Reporter connections and heartbeat details</summary>
99
+
100
+ In Agents, expand **Connect this profile** to copy its MCP configuration. The connections panel shows whether the reporter is reachable and when work was last reported. Heartbeats run every 25 seconds; after 75 seconds without one, the connection is marked disconnected. They do not refresh task timestamps or change task statuses. Connection diagnostics are in memory and counters reset when the Angine server restarts. Last known report times are restored when an exact reporter ID matches saved session history. Older reporters and CLI/HTTP-only reports have unknown connection status until an updated MCP reporter connects.
101
+
102
+ </details>
103
+
104
+ See the [reporting protocol](docs/protocol.md) for payloads and integration examples.
105
+
106
+ ## Commands
107
+
108
+ | Command | Purpose |
109
+ | --- | --- |
110
+ | `angine` or `angine open` | Start the server if needed and open the dashboard |
111
+ | `angine setup [codex\|claude]` | Configure detected supported agents and open Angine |
112
+ | `angine status` | Show server status, dashboard URL, and project counts |
113
+ | `angine restart` | Restart the server to load updated code; preserve history |
114
+ | `angine doctor` | Check agent integrations |
115
+ | `angine uninstall` | Remove managed integrations; preserve local history |
116
+ | `angine mcp --agent <name> [--profile <key>]` | Run an MCP reporter |
117
+ | `angine report <operation> --agent <name>` | Read a report as JSON from standard input |
118
+ | `angine token` | Show the local HTTP reporting token; keep it private |
119
+
120
+ For Codex, setup installs a removable approval policy for Angine's two reporting tools. Uninstall removes the managed instruction blocks, integrations, and policy.
121
+
122
+ ## Local storage and access
123
+
124
+ The hierarchy is **Project → Missions → Tasks**. For example, a product contains a mission to improve reporting, which contains tasks to add connection checks and verify updates.
125
+
126
+ Angine stores history and configuration in `~/.angine`. The dashboard binds to `127.0.0.1`, starting at port 4317; use `angine status` for the active URL. MCP and CLI updates use a local Unix socket or Windows named pipe. HTTP reporting requires a local write token; dashboard edits require a same-origin browser session.
127
+
128
+ Angine makes no outbound network requests during normal operation. Saved filters and notification preferences live in browser storage. Agent reports and optional owner details are visible in the local dashboard; avoid putting sensitive content in metadata.
129
+
130
+ This MVP is for one computer. Mobile access over Wi-Fi, a shared company server, team authentication, independent agent observation, and notifications with all browser tabs closed are not implemented.
131
+
132
+ ## Upgrading and troubleshooting
133
+
134
+ On startup, existing worktree projects are merged under their repository, preserving mission, task, and session IDs. Old project links remain usable, and a `snapshot.json.before-worktrees` backup is saved before migration. Previously removed worktrees with no saved Git identity cannot be matched automatically.
135
+
136
+ Existing plans automatically become missions grouped under their workspace project. IDs and history are preserved; old plan links still open their mission. Legacy snapshots are backed up before conversion.
137
+
138
+ After installing an update:
139
+
140
+ ```bash
141
+ angine restart
142
+ ```
143
+
144
+ Refresh the dashboard and restart agent sessions to load changed reporter tools. A new UI can load while an older server is still running; if saving a profile shows a restart message, restart Angine, refresh, and save again. On Windows, upgrading from a server without process identity support may require closing that old server manually first.
145
+
146
+ If work does not appear, inspect **Agents → Connections**, ask the agent to use `check_connection`, run `angine doctor`, confirm the agent loaded its MCP connection, and check agent/project/profile filters. A stale label means no recent report, not confirmed failure.
147
+
148
+ ## Development and release
149
+
150
+ For contributors:
151
+
152
+ ```bash
153
+ git clone https://github.com/askinjohn/angine.git
154
+ cd angine
155
+ npm ci
156
+ npm test
157
+ npx tsc --noEmit -p ui/tsconfig.json
158
+ npm run build
159
+ node dist/bin/angine.js open
160
+ ```
161
+
162
+ The UI build uses Vite 7; development requires a compatible Node release (20.19+ or 22.12+). Published packages include compiled server code and dashboard assets; users do not need TypeScript or Vite.
163
+
164
+ Use `ANGINE_HOME` for isolated storage, `ANGINE_PORT` for a dashboard port, and `CODEX_HOME` for isolated Codex configuration tests.
165
+
166
+ See the [contribution guide](CONTRIBUTING.md), [release notes](CHANGELOG.md), and [release checklist](docs/releasing.md).
167
+
168
+ ## Feedback
169
+
170
+ Angine is an early MVP. If setup fails or the dashboard is unclear, [open an issue](https://github.com/askinjohn/angine/issues) with your OS, Node.js version, agent type, and a description of what happened. Remove private information from any screenshots or logs you share.
171
+
172
+ Useful feedback: did your first mission appear, were the statuses accurate, and what did you need to understand at a glance?
173
+
174
+ ## License
175
+
176
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from 'node:child_process';
3
+ import { ensureDaemon, request, restartDaemon } from '../src/ipc.js';
4
+ import { serverVersion } from '../src/reporting.js';
5
+ const command = process.argv[2] || 'open';
6
+ async function openDashboard() {
7
+ const status = await ensureDaemon();
8
+ const opener = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd' : 'xdg-open';
9
+ const args = process.platform === 'win32' ? ['/c', 'start', '', status.url] : [status.url];
10
+ const child = spawn(opener, args, { stdio: 'ignore', detached: true });
11
+ child.on('error', () => { });
12
+ child.unref();
13
+ console.log(status.url);
14
+ }
15
+ try {
16
+ if (command === '--version' || command === 'version' || command === '-v')
17
+ console.log(`Angine ${serverVersion}`);
18
+ else if (command === 'mcp')
19
+ await import('../src/mcp.js');
20
+ else if (command === 'daemon')
21
+ await (await import('../src/daemon.js')).startDaemon();
22
+ else if (command === 'restart') {
23
+ await restartDaemon();
24
+ console.log('Angine restarted. Project history was kept.');
25
+ await openDashboard();
26
+ }
27
+ else if (command === 'setup') {
28
+ const { setup } = await import('../src/setup.js');
29
+ const result = setup(process.argv[3] || 'all');
30
+ console.log(`Angine ready. Configured: ${result.installed.join(', ')}.${result.skipped.length ? ` Not installed: ${result.skipped.join(', ')}.` : ''}\nRestart your agents to begin reporting. Opening the dashboard…`);
31
+ await openDashboard();
32
+ }
33
+ else if (command === 'uninstall') {
34
+ const { uninstall } = await import('../src/setup.js');
35
+ const result = uninstall();
36
+ console.log(result.removed.length ? `Removed ${result.removed.join(', ')} integration. Local project history was kept.` : 'No Angine integration found.');
37
+ }
38
+ else if (command === 'token') {
39
+ const { httpWriteToken } = await import('../src/config.js');
40
+ console.log(httpWriteToken());
41
+ }
42
+ else if (command === 'report') {
43
+ const method = process.argv[3];
44
+ if (!['sync_project', 'update_tasks'].includes(method))
45
+ throw new Error('Use: angine report sync_project|update_tasks --agent <name> < input.json');
46
+ const index = process.argv.indexOf('--agent');
47
+ const { agentName } = await import('../src/model.js');
48
+ const agent = agentName(index >= 0 ? process.argv[index + 1] : 'external');
49
+ let body = '';
50
+ for await (const chunk of process.stdin) {
51
+ body += chunk.toString();
52
+ if (body.length > 1_000_000)
53
+ throw new Error('Report exceeds 1 MB');
54
+ }
55
+ const input = JSON.parse(body);
56
+ const profileIndex = process.argv.indexOf('--profile');
57
+ const { nativeReporterIdentity } = await import('../src/identity.js');
58
+ await ensureDaemon();
59
+ console.log(JSON.stringify(await request(method, { ...nativeReporterIdentity(agent), ...input, ...(profileIndex >= 0 ? { profileKey: process.argv[profileIndex + 1] } : {}), agent })));
60
+ }
61
+ else if (command === 'doctor') {
62
+ const { doctor } = await import('../src/setup.js');
63
+ const checks = doctor();
64
+ for (const check of checks)
65
+ console.log(`${check.ok ? '✓' : '✗'} ${check.name}: ${check.detail}`);
66
+ if (checks.some(c => !c.ok))
67
+ process.exitCode = 1;
68
+ }
69
+ else if (command === 'status') {
70
+ const status = await request('status');
71
+ console.log(`Daemon: ${status.daemon}\nDashboard: ${status.url}\nProjects: ${status.projects}${status.missions !== undefined ? `\nMissions: ${status.missions}` : ''}\nRunning missions: ${status.running}`);
72
+ }
73
+ else if (command === 'open') {
74
+ await openDashboard();
75
+ }
76
+ else {
77
+ console.error('Usage: angine [setup [codex|claude]|open|restart|status|doctor|uninstall|token|report|mcp]');
78
+ process.exitCode = 1;
79
+ }
80
+ }
81
+ catch (error) {
82
+ console.error(`Angine: ${error.message}`);
83
+ process.exitCode = 1;
84
+ }
85
+ //# sourceMappingURL=angine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"angine.js","sourceRoot":"","sources":["../../bin/angine.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAErE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC;AAC1C,KAAK,UAAU,aAAa;IAC1B,MAAM,MAAM,GAAG,MAAM,YAAY,EAAE,CAAC;IACpC,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU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CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QAClG,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAAE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACpD,CAAC;SAAM,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAe,QAAQ,CAAC,CAAC;QACrD,OAAO,CAAC,GAAG,CAAC,WAAW,MAAM,CAAC,MAAM,gBAAgB,MAAM,CAAC,GAAG,eAAe,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,eAAe,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,uBAAuB,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAC/M,CAAC;SAAM,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QAC9B,MAAM,aAAa,EAAE,CAAC;IACxB,CAAC;SAAM,CAAC;QAAC,OAAO,CAAC,KAAK,CAAC,4FAA4F,CAAC,CAAC;QAAC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IAAC,CAAC;AAC/I,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IAAC,OAAO,CAAC,KAAK,CAAC,WAAY,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IAAC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Project, State } from './types.js';
2
+ export declare function defaultProjectColor(id: string): string;
3
+ export declare const projectColor: (project: Pick<Project, "id" | "color">) => string;
4
+ export declare const effectiveColor: (state: Pick<State, "projects" | "missions">, projectId: string, missionId?: string) => string;
@@ -0,0 +1,9 @@
1
+ export function defaultProjectColor(id) {
2
+ let hash = 2166136261;
3
+ for (const char of id)
4
+ hash = Math.imul(hash ^ char.charCodeAt(0), 16777619) >>> 0;
5
+ return '#' + [0, 8, 16].map(shift => (60 + ((hash >>> shift) & 255) % 111).toString(16).padStart(2, '0')).join('');
6
+ }
7
+ export const projectColor = (project) => project.color || defaultProjectColor(project.id);
8
+ export const effectiveColor = (state, projectId, missionId) => (missionId && state.missions[missionId]?.color) || projectColor(state.projects[projectId] || { id: projectId });
9
+ //# sourceMappingURL=colors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.js","sourceRoot":"","sources":["../../src/colors.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,mBAAmB,CAAC,EAAU;IAC5C,IAAI,IAAI,GAAG,UAAU,CAAC;IACtB,KAAK,MAAM,IAAI,IAAI,EAAE;QAAE,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClF,OAAO,GAAG,GAAG,CAAC,CAAC,EAAC,CAAC,EAAC,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAClH,CAAC;AACD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAmC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,IAAI,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AACtH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAwC,EAAE,SAAiB,EAAE,SAAkB,EAAU,EAAE,CACxH,CAAC,SAAS,IAAI,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,IAAI,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAC,EAAE,EAAC,SAAS,EAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function httpWriteToken(): string;
@@ -0,0 +1,24 @@
1
+ import crypto from 'node:crypto';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { dataDir } from './paths.js';
5
+ const file = () => path.join(dataDir(), 'config.json');
6
+ export function httpWriteToken() {
7
+ fs.mkdirSync(dataDir(), { recursive: true, mode: 0o700 });
8
+ let config = {};
9
+ try {
10
+ config = JSON.parse(fs.readFileSync(file(), 'utf8'));
11
+ }
12
+ catch (error) {
13
+ if (error.code !== 'ENOENT')
14
+ throw error;
15
+ }
16
+ if (typeof config.httpWriteToken === 'string' && config.httpWriteToken.length >= 32)
17
+ return config.httpWriteToken;
18
+ config.httpWriteToken = crypto.randomBytes(32).toString('hex');
19
+ const temp = `${file()}.${process.pid}.tmp`;
20
+ fs.writeFileSync(temp, JSON.stringify(config, null, 2) + '\n', { mode: 0o600 });
21
+ fs.renameSync(temp, file());
22
+ return config.httpWriteToken;
23
+ }
24
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,aAAa,CAAC,CAAC;AACvD,MAAM,UAAU,cAAc;IAC5B,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1D,IAAI,MAAM,GAA4B,EAAE,CAAC;IACzC,IAAI,CAAC;QAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAA4B,CAAC;IAAC,CAAC;IACxF,OAAO,KAAK,EAAE,CAAC;QAAC,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YAAE,MAAM,KAAK,CAAC;IAAC,CAAC;IACtF,IAAI,OAAO,MAAM,CAAC,cAAc,KAAK,QAAQ,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,IAAI,EAAE;QAAE,OAAO,MAAM,CAAC,cAAc,CAAC;IAClH,MAAM,CAAC,cAAc,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC/D,MAAM,IAAI,GAAG,GAAG,IAAI,EAAE,IAAI,OAAO,CAAC,GAAG,MAAM,CAAC;IAC5C,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAChF,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5B,OAAO,MAAM,CAAC,cAAwB,CAAC;AACzC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function startDaemon(): Promise<void>;
@@ -0,0 +1,227 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import net from 'node:net';
4
+ import http from 'node:http';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { Store } from './store.js';
7
+ import { ReporterRegistry, protocolVersion, serverVersion } from './health.js';
8
+ import { createDashboardRouter, equalSecret } from './dashboard.js';
9
+ import { dataDir, runtimePath, socketPath } from './paths.js';
10
+ import { httpWriteToken } from './config.js';
11
+ const uiDir = path.resolve(fileURLToPath(new URL('../../ui/dist/', import.meta.url)));
12
+ const mime = { '.html': 'text/html; charset=utf-8', '.js': 'text/javascript; charset=utf-8', '.css': 'text/css; charset=utf-8', '.svg': 'image/svg+xml' };
13
+ const securityHeaders = {
14
+ 'Content-Security-Policy': "default-src 'self'; script-src 'self'; style-src 'self'; connect-src 'self'; img-src 'self' data:; object-src 'none'; base-uri 'none'; frame-ancestors 'none'",
15
+ 'X-Content-Type-Options': 'nosniff',
16
+ 'Referrer-Policy': 'no-referrer',
17
+ 'Cache-Control': 'no-store'
18
+ };
19
+ const json = (res, value, status = 200) => { res.writeHead(status, { ...securityHeaders, 'Content-Type': 'application/json; charset=utf-8' }); res.end(JSON.stringify(value)); };
20
+ export async function startDaemon() {
21
+ fs.mkdirSync(path.join(dataDir(), 'runtime'), { recursive: true, mode: 0o700 });
22
+ const store = new Store();
23
+ store.load();
24
+ const reporters = new ReporterRegistry(() => store.state.profiles, () => Date.now(), reporterId => Object.values(store.state.sessions).filter(s => s.reporterId === reporterId).map(s => s.lastSeenAt).sort().at(-1));
25
+ const writeToken = httpWriteToken();
26
+ const dashboard = createDashboardRouter(store);
27
+ let port = Number(process.env.ANGINE_PORT || 4317);
28
+ if (!Number.isInteger(port) || port < 1 || port > 65535)
29
+ throw new Error('Invalid ANGINE_PORT');
30
+ const clients = new Set();
31
+ const httpServer = http.createServer((req, res) => {
32
+ const host = req.headers.host || '';
33
+ if (!/^((127\.0\.0\.1)|(localhost))(:(\d{1,5}))?$/.test(host))
34
+ return json(res, { error: 'Invalid host' }, 403);
35
+ const origin = req.headers.origin;
36
+ if (origin && origin !== `http://${host}`)
37
+ return json(res, { error: 'Invalid origin' }, 403);
38
+ let url;
39
+ try {
40
+ url = new URL(req.url || '/', `http://${host}`);
41
+ }
42
+ catch {
43
+ return json(res, { error: 'Invalid URL' }, 400);
44
+ }
45
+ if (dashboard(req, res, url))
46
+ return;
47
+ if (req.method === 'POST' && (url.pathname === '/api/ingest/sync_project' || url.pathname === '/api/ingest/update_tasks')) {
48
+ const header = req.headers.authorization || '';
49
+ const supplied = header.startsWith('Bearer ') ? header.slice(7) : '';
50
+ const valid = equalSecret(supplied, writeToken);
51
+ if (!valid)
52
+ return json(res, { error: 'Unauthorized' }, 401);
53
+ if (!String(req.headers['content-type'] || '').startsWith('application/json'))
54
+ return json(res, { error: 'JSON required' }, 415);
55
+ let body = '', exceeded = false;
56
+ req.on('data', (chunk) => {
57
+ body += chunk;
58
+ if (body.length > 1_000_000) {
59
+ exceeded = true;
60
+ req.destroy();
61
+ }
62
+ });
63
+ req.on('end', () => {
64
+ if (exceeded)
65
+ return;
66
+ try {
67
+ const input = JSON.parse(body);
68
+ const value = url.pathname.endsWith('sync_project') ? store.syncProject(input) : store.updateTasks(input);
69
+ json(res, value);
70
+ }
71
+ catch (error) {
72
+ json(res, { error: error.message }, 400);
73
+ }
74
+ });
75
+ return;
76
+ }
77
+ if (req.method !== 'GET')
78
+ return json(res, { error: 'Method not allowed' }, 405);
79
+ if (url.pathname === '/api/health')
80
+ return json(res, reporters.view());
81
+ if (url.pathname === '/api/state')
82
+ return json(res, store.view());
83
+ if (url.pathname.startsWith('/api/missions/') && url.pathname.endsWith('/events')) {
84
+ const missionId = url.pathname.split('/')[3];
85
+ if (!store.state.missions[missionId])
86
+ return json(res, { error: 'Mission not found' }, 404);
87
+ return json(res, store.missionEvents(missionId));
88
+ }
89
+ if (url.pathname.startsWith('/api/projects/') && url.pathname.endsWith('/events')) {
90
+ const projectId = url.pathname.split('/')[3];
91
+ if (!store.state.projects[projectId] && !store.state.missions[projectId])
92
+ return json(res, { error: 'Project not found' }, 404);
93
+ return json(res, store.projectEvents(projectId));
94
+ }
95
+ if (url.pathname === '/api/events') {
96
+ res.writeHead(200, { ...securityHeaders, 'Content-Type': 'text/event-stream', Connection: 'keep-alive' });
97
+ res.write(`event: state\ndata: ${JSON.stringify(store.view())}\n\n`);
98
+ res.write(`event: health\ndata: ${JSON.stringify(reporters.view())}\n\n`);
99
+ clients.add(res);
100
+ req.on('close', () => clients.delete(res));
101
+ return;
102
+ }
103
+ const relative = url.pathname === '/' ? 'index.html' : decodeURIComponent(url.pathname.slice(1));
104
+ const full = path.resolve(uiDir, relative);
105
+ if (!full.startsWith(uiDir + path.sep) && full !== path.join(uiDir, 'index.html'))
106
+ return json(res, { error: 'Not found' }, 404);
107
+ let content;
108
+ try {
109
+ content = fs.readFileSync(full);
110
+ }
111
+ catch {
112
+ return json(res, { error: 'Dashboard not built. Run npm run build.' }, 404);
113
+ }
114
+ res.writeHead(200, { ...securityHeaders, 'Content-Type': mime[path.extname(full)] || 'application/octet-stream' });
115
+ res.end(content);
116
+ });
117
+ store.listeners.add((_events, state) => {
118
+ const message = `event: state\ndata: ${JSON.stringify(state)}\n\n`;
119
+ for (const client of clients)
120
+ client.write(message);
121
+ });
122
+ const healthUpdate = () => { for (const client of clients)
123
+ client.write(`event: health\ndata: ${JSON.stringify(reporters.view())}\n\n`); };
124
+ const keepalive = setInterval(healthUpdate, 25000);
125
+ const desired = port;
126
+ while (true) {
127
+ try {
128
+ await new Promise((resolve, reject) => {
129
+ httpServer.once('error', reject);
130
+ httpServer.listen(port, '127.0.0.1', () => { httpServer.off('error', reject); resolve(); });
131
+ });
132
+ break;
133
+ }
134
+ catch (error) {
135
+ if (error.code !== 'EADDRINUSE' || port >= desired + 20)
136
+ throw error;
137
+ port++;
138
+ }
139
+ }
140
+ const sock = socketPath();
141
+ if (process.platform !== 'win32' && fs.existsSync(sock)) {
142
+ try {
143
+ await new Promise((resolve, reject) => { const probe = net.createConnection(sock); probe.once('connect', () => { probe.destroy(); reject(new Error('Daemon already running')); }); probe.once('error', () => resolve()); });
144
+ }
145
+ catch (error) {
146
+ httpServer.close();
147
+ throw error;
148
+ }
149
+ fs.unlinkSync(sock);
150
+ }
151
+ const ipc = net.createServer(socket => {
152
+ let buffer = '';
153
+ socket.on('data', (chunk) => {
154
+ buffer += chunk;
155
+ if (buffer.length > 1_000_000)
156
+ return socket.destroy();
157
+ const end = buffer.indexOf('\n');
158
+ if (end < 0)
159
+ return;
160
+ try {
161
+ const { method, params } = JSON.parse(buffer.slice(0, end));
162
+ let value;
163
+ if (method === 'status')
164
+ value = { serverVersion, protocolVersion, pid: process.pid, daemon: 'running', url: `http://127.0.0.1:${port}`, projects: Object.keys(store.state.projects).length, missions: Object.keys(store.state.missions).length, running: Object.values(store.state.missions).filter(p => p.status === 'running' && !p.archivedAt && !store.state.projects[p.projectId]?.archivedAt).length };
165
+ else if (method === 'reporter_ping') {
166
+ value = reporters.ping(params);
167
+ healthUpdate();
168
+ }
169
+ else if (method === 'reporter_close') {
170
+ reporters.close(params?.reporterId);
171
+ value = { closed: true };
172
+ healthUpdate();
173
+ }
174
+ else if (method === 'reporter_health')
175
+ value = reporters.view();
176
+ else if (method === 'sync_project') {
177
+ try {
178
+ value = store.syncProject(params);
179
+ reporters.report(params?.reporterId, true);
180
+ }
181
+ catch (error) {
182
+ reporters.report(params?.reporterId, false);
183
+ throw error;
184
+ }
185
+ finally {
186
+ healthUpdate();
187
+ }
188
+ }
189
+ else if (method === 'update_tasks') {
190
+ try {
191
+ value = store.updateTasks(params);
192
+ reporters.report(params?.reporterId, true);
193
+ }
194
+ catch (error) {
195
+ reporters.report(params?.reporterId, false);
196
+ throw error;
197
+ }
198
+ finally {
199
+ healthUpdate();
200
+ }
201
+ }
202
+ else
203
+ throw new Error('Unknown method');
204
+ socket.end(JSON.stringify({ ok: true, value }) + '\n');
205
+ }
206
+ catch (error) {
207
+ socket.end(JSON.stringify({ ok: false, error: error.message }) + '\n');
208
+ }
209
+ });
210
+ });
211
+ await new Promise((resolve, reject) => { ipc.once('error', reject); ipc.listen(sock, () => { ipc.off('error', reject); resolve(); }); });
212
+ if (process.platform !== 'win32')
213
+ fs.chmodSync(sock, 0o600);
214
+ fs.writeFileSync(runtimePath(), JSON.stringify({ pid: process.pid, port, startedAt: new Date().toISOString() }), { mode: 0o600 });
215
+ const stop = () => { clearInterval(keepalive); store.snapshot(); for (const client of clients)
216
+ client.end(); clients.clear(); ipc.close(); httpServer.close(); if (process.platform !== 'win32')
217
+ try {
218
+ fs.unlinkSync(sock);
219
+ }
220
+ catch { } try {
221
+ fs.unlinkSync(runtimePath());
222
+ }
223
+ catch { } };
224
+ process.once('SIGTERM', stop);
225
+ process.once('SIGINT', stop);
226
+ }
227
+ //# sourceMappingURL=daemon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daemon.js","sourceRoot":"","sources":["../../src/daemon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,gBAAgB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACtF,MAAM,IAAI,GAA2B,EAAE,OAAO,EAAE,0BAA0B,EAAE,KAAK,EAAE,gCAAgC,EAAE,MAAM,EAAE,yBAAyB,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;AAClL,MAAM,eAAe,GAAG;IACtB,yBAAyB,EAAE,+JAA+J;IAC1L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