antpath 0.1.1 → 0.2.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.
- package/README.md +40 -4
- package/dist/client.js +4 -1
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/platform/client.d.ts +138 -7
- package/dist/platform/client.js +98 -2
- package/dist/platform/client.js.map +1 -1
- package/dist/providers/known-events.d.ts +60 -0
- package/dist/providers/known-events.js +64 -0
- package/dist/providers/known-events.js.map +1 -0
- package/dist/run/controller.d.ts +4 -1
- package/dist/run/controller.js +103 -13
- package/dist/run/controller.js.map +1 -1
- package/dist/template/index.d.ts +1 -1
- package/dist/types.d.ts +20 -0
- package/dist/utils/events.d.ts +21 -0
- package/dist/utils/events.js +97 -18
- package/dist/utils/events.js.map +1 -1
- package/docs/credentials.md +84 -2
- package/docs/events.md +129 -0
- package/docs/skills.md +2 -0
- package/package.json +1 -1
- package/references/architecture-decisions.md +110 -64
- package/references/implementation-plan.md +66 -44
|
@@ -8,7 +8,7 @@ scope: platform MVP
|
|
|
8
8
|
|
|
9
9
|
## Goal
|
|
10
10
|
|
|
11
|
-
Convert antpath from an SDK-only package into a TypeScript workspace containing:
|
|
11
|
+
Convert antpath from an SDK-only package into a pnpm TypeScript workspace containing:
|
|
12
12
|
|
|
13
13
|
- a platform SDK in `packages/sdk`;
|
|
14
14
|
- a dashboard app in `apps/dashboard`;
|
|
@@ -21,27 +21,30 @@ Implementation is test-driven. Each behavior starts with the narrowest failing t
|
|
|
21
21
|
|
|
22
22
|
## Acceptance criteria
|
|
23
23
|
|
|
24
|
-
- The repository is
|
|
24
|
+
- The repository is a pnpm workspace and the current SDK is moved to `packages/sdk`.
|
|
25
25
|
- Dashboard and worker app folders exist with build/test integration.
|
|
26
26
|
- Auth.js authenticates dashboard users.
|
|
27
27
|
- SDK API tokens authenticate programmatic clients.
|
|
28
28
|
- Workspaces are the tenant boundary.
|
|
29
29
|
- BFF/server actions scope every dashboard/API operation by workspace membership or API-token scope.
|
|
30
30
|
- Supabase service-role credentials are never exposed to browser/client bundles.
|
|
31
|
-
- Supabase Postgres stores durable run, attempt, provider resource, event, output, cleanup, usage, workspace, membership
|
|
32
|
-
-
|
|
33
|
-
- Run submission idempotency is enforced by workspace and request hash.
|
|
31
|
+
- Supabase Postgres stores durable run, attempt, provider resource, event, output, output-capture-failure, cleanup, usage, workspace, and membership metadata. There is no persistent `provider_connections` table in MVP.
|
|
32
|
+
- Per-run secrets bundles (Anthropic key, optional MCP credentials, optional skill references) arrive inline on submission, are encrypted through Supabase Vault for the lifetime of that single run, and are deleted at terminal cleanup. The Vault entry is the only durable trace of the user's provider key.
|
|
33
|
+
- Run submission idempotency is enforced by workspace and request hash. The hash excludes the `secrets` block so re-submitting the same logical run with a new key still matches.
|
|
34
34
|
- Workers claim due runs with leases and `FOR UPDATE SKIP LOCKED`.
|
|
35
35
|
- Multiple workers can run concurrently without duplicate lifecycle ownership.
|
|
36
36
|
- Worker polling recovers from missed `NOTIFY`, worker restart, deploy, and expired leases.
|
|
37
37
|
- Worker creates per-run provider resources and journals them for cleanup.
|
|
38
38
|
- Worker polls provider status and events and stores only redacted metadata.
|
|
39
|
-
- Output capture
|
|
39
|
+
- Output capture is unconditional: every artifact Claude exposes on the run's session is written to private Supabase Storage, bounded only by the workspace storage cap. Files that would exceed the cap are persisted as `output_capture_failures` rows.
|
|
40
40
|
- BFF returns signed output links only after workspace authorization.
|
|
41
|
-
- Cleanup runs after terminal provider state and output capture.
|
|
41
|
+
- Cleanup runs after terminal provider state and output capture, deletes the per-run Vault entry, and (by default) deletes Claude-side resources. `cleanup.claudeSession: "retain"` only affects Claude-side resources.
|
|
42
42
|
- Reconciliation can recover intended provider resources after partial worker crashes.
|
|
43
43
|
- User deletion is pending/soft until cleanup and storage deletion are complete.
|
|
44
44
|
- Exact tier/cap values are configurable through environment variables with conservative defaults and run-level snapshots.
|
|
45
|
+
- Security-sensitive BFF/API actions are audited and rate-limited.
|
|
46
|
+
- Workspace storage quota and workspace deletion are enforced before provider/storage side effects proceed.
|
|
47
|
+
- CI runs pnpm lint/test/build/package checks plus a local Supabase integration job.
|
|
45
48
|
- Tests follow the accepted taxonomy: deterministic unit tests (including fakes and sanitized recorded snapshots), live external-system integration tests with no skip flags, and top-to-bottom live e2e tests.
|
|
46
49
|
|
|
47
50
|
## Phase 1: Workspace foundation
|
|
@@ -50,16 +53,16 @@ Create the workspace structure without changing runtime behavior.
|
|
|
50
53
|
|
|
51
54
|
Deliverables:
|
|
52
55
|
|
|
53
|
-
- Root
|
|
56
|
+
- Root pnpm workspace configuration.
|
|
54
57
|
- Current SDK moved to `packages/sdk`.
|
|
55
58
|
- `apps/dashboard` placeholder.
|
|
56
59
|
- `apps/worker` placeholder.
|
|
57
60
|
- Shared TypeScript config/build/test commands.
|
|
58
61
|
- Existing SDK exports preserved or intentionally migrated with compatibility notes.
|
|
59
62
|
- Root validation commands:
|
|
60
|
-
- `
|
|
61
|
-
- `
|
|
62
|
-
- `
|
|
63
|
+
- `pnpm lint`
|
|
64
|
+
- `pnpm test`
|
|
65
|
+
- `pnpm build`
|
|
63
66
|
|
|
64
67
|
TDD gate:
|
|
65
68
|
|
|
@@ -113,23 +116,25 @@ Deliverables:
|
|
|
113
116
|
|
|
114
117
|
- Migration framework.
|
|
115
118
|
- Tables:
|
|
116
|
-
- `users`;
|
|
119
|
+
- Auth.js adapter tables: `users`, `accounts`, `sessions`, `verification_token`;
|
|
120
|
+
- antpath `app_users`;
|
|
117
121
|
- `workspaces`;
|
|
118
122
|
- `workspace_memberships`;
|
|
119
123
|
- `api_tokens`;
|
|
120
|
-
- `
|
|
121
|
-
- `runs`;
|
|
124
|
+
- `runs` (includes `execution_secret_id` referencing the per-run Vault entry);
|
|
122
125
|
- `run_attempts`;
|
|
123
126
|
- `provider_resources`;
|
|
124
127
|
- `run_events`;
|
|
125
128
|
- `output_objects`;
|
|
129
|
+
- `output_capture_failures`;
|
|
126
130
|
- `cleanup_attempts`;
|
|
127
131
|
- `usage_ledger`.
|
|
128
132
|
- Constraints:
|
|
129
133
|
- unique `(workspace_id, idempotency_key)` on runs;
|
|
130
134
|
- request-hash conflict handling;
|
|
131
135
|
- unique `(run_attempt_id, provider_event_id)` on events;
|
|
132
|
-
- foreign keys for workspace and attributed
|
|
136
|
+
- foreign keys for workspace and attributed `app_user_id` where practical;
|
|
137
|
+
- RLS enabled and `anon`/`authenticated` direct table access revoked for platform/Auth.js tables.
|
|
133
138
|
- DB query helpers for tenant-scoped access.
|
|
134
139
|
|
|
135
140
|
TDD gate:
|
|
@@ -174,10 +179,11 @@ Turn the SDK into the programmatic client for the platform while preserving Temp
|
|
|
174
179
|
Deliverables:
|
|
175
180
|
|
|
176
181
|
- SDK client for platform API base URL and API token.
|
|
177
|
-
-
|
|
182
|
+
- `AntpathPlatformClient` constructor accepts a default `secrets` bundle (Anthropic key + optional MCP credentials + optional skill references); every method accepts a per-call override.
|
|
183
|
+
- Submit run API (carries inline `secrets`).
|
|
178
184
|
- Get run status/detail API.
|
|
179
185
|
- List metadata events API.
|
|
180
|
-
- List outputs API.
|
|
186
|
+
- List outputs API (returns successful captures and capture failures).
|
|
181
187
|
- Create signed output link API.
|
|
182
188
|
- Cancel run API.
|
|
183
189
|
- Delete run API.
|
|
@@ -187,10 +193,11 @@ Deliverables:
|
|
|
187
193
|
TDD gate:
|
|
188
194
|
|
|
189
195
|
- Type/contract tests for public SDK API and runtime tests with fake platform responses.
|
|
196
|
+
- Tests asserting `secrets` never appears in serialized request hashes, error metadata, or retry telemetry.
|
|
190
197
|
|
|
191
198
|
Validation:
|
|
192
199
|
|
|
193
|
-
- SDK
|
|
200
|
+
- SDK does not persist provider keys: it forwards them to the platform per submission, where they are vaulted for the lifetime of one run and then deleted.
|
|
194
201
|
- SDK handles idempotency conflict, unauthorized, quota, and terminal states deterministically.
|
|
195
202
|
|
|
196
203
|
## Phase 6: Worker claim loop and state machine
|
|
@@ -203,7 +210,7 @@ Deliverables:
|
|
|
203
210
|
- Optional Postgres `NOTIFY` listener for fast wakeup.
|
|
204
211
|
- Lease claim/release helpers.
|
|
205
212
|
- Lease-guarded status update helper.
|
|
206
|
-
- Per-workspace
|
|
213
|
+
- Per-workspace rate limit hooks.
|
|
207
214
|
- Fair due-run ordering across workspaces.
|
|
208
215
|
- Cancellation/delete request checks before side effects.
|
|
209
216
|
- Timeout handling.
|
|
@@ -295,58 +302,65 @@ Validation:
|
|
|
295
302
|
|
|
296
303
|
## Phase 10: Output capture and Supabase Storage
|
|
297
304
|
|
|
298
|
-
|
|
305
|
+
Unconditionally capture every artifact the user's Claude session exposes into private Supabase Storage. The workspace storage cap is the only user-visible quota.
|
|
299
306
|
|
|
300
307
|
Deliverables:
|
|
301
308
|
|
|
302
|
-
-
|
|
303
|
-
-
|
|
304
|
-
-
|
|
305
|
-
- Streaming download with
|
|
306
|
-
- Private Supabase Storage upload.
|
|
307
|
-
-
|
|
308
|
-
-
|
|
309
|
-
-
|
|
310
|
-
- Per-user attribution from run row.
|
|
311
|
-
- Signed-link BFF action/API.
|
|
309
|
+
- Worker terminal-state list of session-scoped files via the Claude Files API (`GET /v1/files?scope_id=<sessionId>`), returning `id`, `filename`, and `size_bytes`.
|
|
310
|
+
- Workspace storage usage accounting helper.
|
|
311
|
+
- Pre-download quota check: if `(workspace_used + size_bytes) > workspace cap`, write an `output_capture_failures` row with `reason = "workspace_quota_exceeded"` and continue without downloading.
|
|
312
|
+
- Streaming download via `GET /v1/files/{file_id}/content` with a worker-internal safety cap so malformed listing responses cannot OOM the worker; safety-cap aborts are recorded as `output_capture_failures` with `reason = "download_failed"`.
|
|
313
|
+
- Private Supabase Storage upload with workspace-scoped path policy.
|
|
314
|
+
- `output_objects` metadata insert for each successful capture.
|
|
315
|
+
- Per-user attribution frozen from the run row (audit/billing dimension only; not a quota).
|
|
316
|
+
- Signed-link BFF action/API for both `output_objects` rows; capture failures are read-only.
|
|
312
317
|
|
|
313
318
|
TDD gate:
|
|
314
319
|
|
|
315
|
-
- Add failing tests for quota
|
|
320
|
+
- Add failing tests for: pre-download quota check choosing failure-row over download when over cap; safety-cap abort recording a failure row; happy path writing both an `output_objects` row and an audit entry; signed-link authorization; cross-workspace denial; listing returning zero files producing zero rows; listing returning N files with mixed sizes recording the expected mix of successes and failures.
|
|
321
|
+
- Tests must assert there is no user-facing knob for `capture: boolean`, `globs`, or per-file caps.
|
|
316
322
|
|
|
317
323
|
Validation:
|
|
318
324
|
|
|
319
|
-
-
|
|
325
|
+
- Output capture is unconditional and cannot be opted out by the submitter.
|
|
326
|
+
- Oversized output payloads do not OOM the worker.
|
|
320
327
|
- BFF only creates signed links for authorized workspace users/tokens.
|
|
328
|
+
- Dashboard renders successful captures and capture failures side by side.
|
|
321
329
|
|
|
322
330
|
## Phase 11: Cleanup, deletion, and retention
|
|
323
331
|
|
|
324
|
-
Make cleanup and deletion first-class state machines.
|
|
332
|
+
Make cleanup and deletion first-class state machines. Cleanup must also destroy the per-run Vault secret.
|
|
325
333
|
|
|
326
334
|
Deliverables:
|
|
327
335
|
|
|
328
|
-
- Cleanup ordering:
|
|
329
|
-
-
|
|
330
|
-
- session files/session where supported;
|
|
331
|
-
- agent/archive;
|
|
332
|
-
- environment/archive
|
|
333
|
-
- uploaded provider
|
|
334
|
-
-
|
|
335
|
-
-
|
|
336
|
+
- Cleanup ordering (per the architecture decisions doc):
|
|
337
|
+
- capture session-scoped files (Phase 10);
|
|
338
|
+
- provider session files / session where supported;
|
|
339
|
+
- agent / archive;
|
|
340
|
+
- environment / archive or delete;
|
|
341
|
+
- skills uploaded for this session and other ephemeral provider resources;
|
|
342
|
+
- provider Vault/credentials created on Claude's side for MCP wiring;
|
|
343
|
+
- the antpath per-run Vault entry: `vault.deleteSecret(runs.execution_secret_id)` and clear the column;
|
|
344
|
+
- local Supabase Storage and metadata only on user deletion.
|
|
345
|
+
- The Claude-side cleanup steps are skipped when `cleanup.claudeSession === "retain"` (or the worker default is `retain`); the per-run Vault deletion still runs.
|
|
346
|
+
- Cleanup retry/backoff with idempotent calls.
|
|
336
347
|
- `cleanup_attempts` records.
|
|
337
348
|
- Cleanup state separate from user-facing run terminal state.
|
|
338
349
|
- User `pending_delete` flow.
|
|
339
350
|
- Workspace deletion flow.
|
|
340
|
-
-
|
|
351
|
+
- Audit logs and rate limits for delete/cancel/signed-link/API-token mutations.
|
|
341
352
|
|
|
342
353
|
TDD gate:
|
|
343
354
|
|
|
344
|
-
- Add tests for cleanup after success, failure, timeout, cancellation, partial provider creation, duplicate cleanup calls,
|
|
355
|
+
- Add tests for cleanup after success, failure, timeout, cancellation, partial provider creation, duplicate cleanup calls, and pending-delete races.
|
|
356
|
+
- Add tests that the per-run Vault entry is deleted exactly once and `runs.execution_secret_id` is cleared whether or not Claude-side resources are retained.
|
|
357
|
+
- Add tests that a key rotated on the provider side mid-run produces a `tenant_permanent` failure on the next provider call and that cleanup still runs (and the Vault entry is still deleted).
|
|
345
358
|
|
|
346
359
|
Validation:
|
|
347
360
|
|
|
348
361
|
- Cleanup failures surface actionable redacted errors.
|
|
349
362
|
- Hard deletion only happens after cleanup/storage deletion succeeds.
|
|
363
|
+
- The per-run Vault entry is always destroyed at terminal cleanup, regardless of retention knobs.
|
|
350
364
|
|
|
351
365
|
## Phase 12: Minimal dashboard
|
|
352
366
|
|
|
@@ -407,18 +421,26 @@ Deliverables:
|
|
|
407
421
|
- Cleanup in `finally`.
|
|
408
422
|
- Release/readiness docs.
|
|
409
423
|
- Updated README and examples for platform SDK usage.
|
|
424
|
+
- GitHub Actions pnpm CI and local Supabase integration job.
|
|
425
|
+
- Vercel dashboard and Railway worker environment-variable contracts.
|
|
426
|
+
- `pnpm dev:stack` for local Supabase/dashboard/worker startup with fail-fast config checks.
|
|
427
|
+
- Deterministic MCP/skills request-wiring tests for SDK and worker providers.
|
|
428
|
+
- Separately gated public MCP plus Anthropic skill full-session e2e.
|
|
410
429
|
|
|
411
430
|
TDD gate:
|
|
412
431
|
|
|
413
432
|
- Live e2e is not a TDD driver for core logic, but must prove final integration before release.
|
|
433
|
+
- MCP/skills request shape, permission policy, and secret non-leakage must be covered by normal deterministic tests before relying on public live e2e.
|
|
414
434
|
|
|
415
435
|
Validation:
|
|
416
436
|
|
|
417
437
|
- Full submit -> provider session -> metadata poll -> output capture -> signed link -> cleanup works.
|
|
418
|
-
-
|
|
438
|
+
- Public MCP/skills e2e runs through the explicit `pnpm test:e2e:live` command with live credentials, reaches success, emits SDK/provider events, records safe provider IDs, exercises the default cleanup path, and exercises the `cleanup.claudeSession = "retain"` override path with a follow-up provider API check.
|
|
439
|
+
- Default `pnpm lint`, `pnpm test`, and `pnpm build` pass.
|
|
419
440
|
|
|
420
441
|
## Backlog
|
|
421
442
|
|
|
443
|
+
- Persistent workspace-level provider connections (saved Anthropic keys with rotation/revocation/re-use). The MVP submission contract carries the key inline per run.
|
|
422
444
|
- Provider webhooks as wakeup/reconciliation accelerator.
|
|
423
445
|
- SSE live event stream for richer dashboard UI.
|
|
424
446
|
- Supabase Realtime with explicit Auth.js-to-Supabase authorization design.
|