mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-03 20:09:33 +01:00
2b65b97caeda70f90ee76d1d10e7c3f3b048d710
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f0ee1b40f0 |
docs(headless): make tutorials copy-pasteable and add workflow commands (#23433)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Headless channels, fenced task queues, and workflow primitives landed in #23330 and #23415, with walkthrough documentation in `doc/HEADLESS-TUTORIALS.md`. > - The previous `doc/HEADLESS-TUTORIALS.md` used invented issue IDs (`PAP-14`, `PAP-50`, `PAP-88`), missing local files (`plan.json`, `./finding.schema.json`), and non-existent project slugs (`web-app`, `api-server`), and did not cover the newer workflow commands or multi-agent workflow patterns. > - Readers trying to walk through the tutorial by hand could not copy and paste the commands directly on a fresh local board and missed the new `assign`, `handoff`, `claim --mine`/`--status backlog`, `block --needs`, `cancel`/`reopen`, and `channels` admin commands. > - This pull request rewrites `doc/HEADLESS-TUTORIALS.md` with deterministic hard-coded values (`--company-name "Demo"`, `DEM-1` through `DEM-10`), adds hands-on sections for the new workflow commands, and adds a concise overview of the workflow patterns from `.agents/skills/channels-queues-and-workflows/SKILL.md`. > - The benefit is a verified, top-to-bottom copy-pasteable tutorial that matches the current CLI surface and introduces Paperclip's core multi-agent coordination patterns. ## Linked Issues or Issue Description Refs #23330 Refs #23415 **Issue type** Outdated (no longer matches behavior) **Where is the issue?** `doc/HEADLESS-TUTORIALS.md` **What's wrong?** The tutorials relied on placeholder IDs, missing local files, and uncreated project slugs, so copying and pasting commands on a fresh `pc up --local` board failed. They also omitted the newer workflow ergonomics commands from #23415 (`tasks assign`, `tasks handoff`, `tasks claim --mine` / `--status backlog`, `tasks block --needs`, `tasks deps list`, `tasks cancel` / `reopen`, `channels create --private`, `channels members`, `channels update --managed-pool`) and did not summarize the workflow patterns in `.agents/skills/channels-queues-and-workflows/SKILL.md`. **Suggested fix** Update `doc/HEADLESS-TUTORIALS.md` to use deterministic hard-coded values (`--company-name "Demo"`, `DEM-1` through `DEM-10`), inline heredocs/JSON, runnable `node -e` commands, hands-on examples for the new workflow commands, and a concise workflow patterns overview linking to the skill and examples. ## What Changed - Updated `doc/HEADLESS-TUTORIALS.md` to start with `npx paperclipai up --local --port 3199 --company-name "Demo"` and use deterministic hard-coded IDs (`DEM-1`–`DEM-10`), inline `--file -` heredocs, inline `--data` schemas, and runnable `node -e` worker commands with zero placeholders. - Fixed `pc channels` to `pc channels list` (since bare `pc channels` prints Paperclip release channels) and `--schema ... --data '{...}'` flag syntax using the built-in `finding@1` schema. - Added hands-on walkthroughs for `pc tasks block --needs` + `pc tasks deps list`, `pc agent connect` + `pc tasks assign` + `pc tasks claim --mine`, `pc tasks claim --status backlog`, `pc tasks cancel` / `reopen`, `pc tasks handoff` with `--if` CAS, and `pc channels create --private` / `members` / `update --managed-pool`. - Added Tutorial 4 ("Multi-Agent Workflow Patterns at a Glance") summarizing Direct Work Queue, Two-Step Inbox, Single-Thread Relay, Assembly Line, and DAG Fan-Out/Fan-In with links to `.agents/skills/channels-queues-and-workflows/SKILL.md` and `examples.md`. - Updated Cloud graduation in Tutorial 5 to use `pc channels update --project ... --managed-pool ...` instead of raw API calls. ## Verification - Ran every command in Tutorials 1–3 verbatim in an isolated temporary `PAPERCLIP_HOME` against a fresh `pc up --local --port 3297 --company-name "Demo"` server (`DEM-1` through `DEM-10` plus expected `409 label_conflict` on competing CAS label update): all commands succeeded with exit code 0. - Confirmed `pc channels list` lists board channels instead of release channels. ## Risks - Low risk. Documentation-only change (`doc/HEADLESS-TUTORIALS.md`); no runtime, schema, or API behavior changes. ## Model Used - Google Gemini (Antigravity agentic runtime, Gemini 4 Neon Medium, extended thinking with tool use and code execution) ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
1c0233526d |
feat(tools): add experimental minimal channels viewer example (#23380)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Headless Channels, Task Queues, Interactions, and SSE event streams are exposed through `paperclipai/sdk` so scripts and tools can coordinate agents without full board ceremony. > - Developers who want to build a custom minimal web interface over Paperclip Channels have no standalone runnable example to inspect or copy. > - Putting experimental example viewers into `ui/` would add maintenance load to the permanent React board UI instead of proving that external callers can build on the public SDK. > - This pull request adds an experimental, zero-dependency Channels and Activity web viewer binary under `tools/experimental/channels-viewer/` built strictly on `paperclipai/sdk`. > - The benefit is a clean reference implementation that connects to local or authenticated Paperclip servers, streams live updates over SSE, and keeps the main `ui/` bundle untouched. ## Linked Issues or Issue Description Refs #23329 Refs #23330 **Problem or motivation** Developers can post to channels, claim tasks, and stream events from the CLI or `paperclipai/sdk`, but there is no minimal runnable example showing how to build a custom web UI over those headless APIs with standard Paperclip authentication. **Proposed solution** Add a standalone experimental viewer binary at `tools/experimental/channels-viewer/bin/paperclip-channels-viewer.mjs` backed by `node:http`, `paperclipai/sdk`, and zero-bundler ES modules. The viewer defaults to Paperclip's dark control-plane surface (`data-theme="dark"` with an optional Light mode switch in Settings), pairing sans-serif prose with monospace machine values (`DEM-1`, `#channel`, `key=value`, relative timestamps) and CSP-safe agent capsule avatars across an `Activity` feed, per-channel thread views, a `Task Queue` inspector, and a right-hand `Thread` pane with `kv_labels` editing, `approve`/`reject` confirmations, live SSE updates, and `--as` profile switching. **Alternatives considered** Adding a minimal channels layout directly inside `ui/` was rejected because this viewer is an experimental SDK integration example rather than a permanent core UI surface. Adding a frontend bundler or framework dependency under `tools/` was also rejected so the example runs directly on Node with zero extra packages. **Roadmap alignment** Builds directly on the headless coordination and SDK surface introduced in #23329 and #23330 without overlapping or altering planned core `ui/` work. ## What Changed - Added `tools/experimental/channels-viewer/bin/paperclip-channels-viewer.mjs` with `--port`, `--host`, `--allow-remote`, `--remote-token`, `--allow-host`, `--api-base`, `--company`, `--as`, `--open`, and `--help` flags plus a startup status banner. - Added `tools/experimental/channels-viewer/src/server.mjs`, `src/viewer-data.mjs`, `src/auth.mjs`, `src/security.mjs`, and `src/format.mjs` to resolve Paperclip context/credentials via `paperclipai/sdk` (preserving untrusted repo-local endpoint guards), expose `/viewer-api/*` JSON and SSE proxy endpoints, and enforce loopback/remote-token binding, Host/DNS-rebinding guards, Origin checks, strict CSP headers, and timing-safe CSRF token validation. - Added zero-dependency ES module frontend files (`src/public/index.html`, `styles.css`, `overlays.css`, `app.js`, `render.js`, `dom-helpers.js`) styled with Paperclip's dark control-plane tokens (`data-theme="dark"` default + Light mode toggle), sans/mono typography hierarchy, status dots, and CSP-safe capsule avatars using safe DOM construction (`textContent`). - Added `tools/experimental/channels-viewer/README.md` and a brief reference section in `doc/HEADLESS-TUTORIALS.md`. - Excluded `tools/experimental` in `.dockerignore` so production Docker build contexts remain slim. - Added `tools/experimental/channels-viewer/test/channels-viewer.test.mjs` (`node:test`) and `server/src/__tests__/experimental-channels-viewer.test.ts` (Vitest full-stack E2E with Express, embedded PostgreSQL, and live SSE). ## Verification - Ran `node --test tools/experimental/channels-viewer/test/channels-viewer.test.mjs` (4/4 tests passed). - Ran `pnpm --filter @paperclipai/server typecheck` (passed across all server and test layers). - Ran `pnpm --filter @paperclipai/server exec vitest run src/__tests__/experimental-channels-viewer.test.ts` (3/3 tests passed, covering loopback/remote-token/Host/CSRF/strict-CSP protections, dark-mode `data-theme="dark"` default with zero inline styles, cross-source profile isolation, live SSE `board_event` delivery + `Last-Event-ID` precedence, interleaved channel activity, `kv_labels`, queued tasks, `approve`/`reject` interactions, and instant SSE-aware `viewer.close()`). - Ran `node scripts/check-module-boundaries.mjs`, `node scripts/check-test-budget.mjs --base origin/master`, `node scripts/check-docker-deps-stage.mjs`, and `node tests/runner-e2e/source-sdk-public-inputs.mjs $(git rev-parse HEAD) --check` (all passed). ## Risks - Low risk to core Paperclip runtime and builds: no files under `ui/`, `server/src/routes/`, `packages/db/`, or `packages/shared/` were modified, and `tools/experimental` is excluded from Docker build contexts via `.dockerignore`. - Local browser-to-localhost security is hardened by default loopback binding (`127.0.0.1`), strict `Host` and `Origin` checks, immutable startup `apiBase`, zero bearer-token serialization to the browser, and timing-safe CSRF headers on all mutating `/viewer-api/*` endpoints. ## Model Used - Anthropic Claude Opus 4.6 (`claude-opus-4-6`) with extended thinking, code execution, and tool use in Antigravity. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
ea56320e10 |
feat(board): add headless channels, fenced task queues, paperclipai/sdk, and pc CLI (#23330)
<!-- Write all pull request text in Simplified Technical English (ASD-STE100): short sentences, one instruction per sentence, simple approved vocabulary, and the active voice. --> ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Multi-agent workflows and terminal scripts often need lightweight shared channels, structured task queues, and scriptable CLI/SDK primitives without building a full project UI first. > - Today, Paperclip issues require board-oriented setup, lack lazy hierarchical channels, lack fenced task claim leases, and lack a zero-dependency TypeScript SDK and short CLI alias for fast script coordination. > - Without fenced leases, blocking queue claims, CAS key-value labels, and race-free event streaming, multiple headless workers collide on shared work or fall back to wasteful polling loops. > - This pull request adds headless channels, versioned JSON schemas, topological `plan.json` batch creation, fenced task queues with `FOR UPDATE SKIP LOCKED` claims, CAS key-value labels, one-line ask/confirm interactions, SSE event streaming, `paperclipai/sdk`, and the `pc` CLI with `paperclipai up`. > - The benefit is zero-ceremony, machine-readable, race-safe coordination across terminal agents, CI scripts, and local Paperclip servers while staying compatible with existing Web UI issue threads. ## Linked Issues or Issue Description **Subsystem affected** Cross-cutting (`packages/db`, `packages/shared`, `server/`, `cli/`, `doc/`, `skills/`) **Problem or motivation** Agents and terminal workflows need a fast way to post updates, queue DAG tasks, claim work without double-execution, ask humans for approval, and wait on board events without browser setup or polling loops. Existing Paperclip routes assume UI-driven projects, lack fenced claim leases for pools of workers, and lack a minimal `pc` CLI and `paperclipai/sdk` client. **Proposed solution** Build a headless coordination layer directly on top of Paperclip `issues` and `issue_comments` using `issues.scope = 'channel'`: - **Database & Contracts (`packages/db`, `packages/shared`)**: Add `0511_pale_kronos.sql` (`issues.scope`) and `0512_stormy_the_hood.sql` for lazy hierarchical `channels`, `channel_access_members`, immutable `company_schemas`, monotonic `board_events`, `scheduled_board_posts`, `issue_batch_idempotency_keys`, scoped `board_api_keys`, `agent_identity_policy`, `kv_labels`, `schema_blocks`, and fenced claim leases. Export Zod contracts, DAG sorting, KV CAS helpers, and the zero-dependency `paperclip()` SDK (`packages/shared/src/sdk/`), including an in-memory test backend. - **Server APIs & Workers (`server/`)**: Add routes and services for progressive `--as` actor resolution (`open_local_profiles`, `delegated_profiles`, `strict_agent_keys`), `pc agent connect` auth challenges, lazy channels, CAS `kv-labels`, versioned schemas, topological batch creation, `FOR UPDATE SKIP LOCKED` pool claims with fenced TTL renewal/release/complete/fail, one-line `ask`/`confirm`/`approve`/`reject` interactions, SSE cursor streaming (`events/wait`, `events/stream`), and sleep-aware lease expiry and scheduled post workers. - **CLI, Launcher & Docs (`cli/`, `doc/`, `skills/`)**: Expose the `pc` binary alias and `paperclipai/sdk` export, add the zero-prompt `paperclipai up` / `pc up` local launcher, add `pc` commands (`post`, `reply`, `read`, `channels`, `label`, `tasks`, `ask`, `confirm`, `approve`, `reject`, `schemas`, `schedule`, `tail`, `wait`, `agent connect/login`), add documentation (`doc/CHANNELS-AND-QUEUES.md`, `doc/CLI.md`, `doc/HEADLESS-TUTORIALS.md`), and add `skills/paperclip-lite/SKILL.md`. **Alternatives considered** - **Separate message and queue tables outside `issues`**: Rejected because channel posts and queued tasks would lose Paperclip identifiers (`PC-1`), comments, attachments, privacy ACLs, and direct Web UI issue URLs (`/<prefix>/issues/PC-1`). - **Advisory locks or polling loops for task workers**: Rejected because advisory locks drop on reconnect across laptop sleep, and polling wastes tokens and prevents database sleep. Fenced `(claimToken, claimEpoch)` TTL leases with `events/wait` and `waitSec` solve both safely. **Roadmap alignment** Extends core Paperclip agent orchestration and CLI workflows with a headless board, SDK, and queue primitive without altering existing Web UI board behavior. **Additional context** This PR builds on the `issues.scope` surface visibility foundation from #23329 (included as the base commit in this stacked branch so CI and reviewers can test the full integration against `master`). ## What Changed - **Schema & Migrations (`packages/db`)**: Added online-compatible migrations `0511_pale_kronos.sql` and `0512_stormy_the_hood.sql`, schema definitions (`channels.ts`, `company_schemas.ts`, `headless_board.ts`), and column extensions on `issues`, `issue_comments`, `companies`, `board_api_keys`, and `cli_auth_challenges`. - **Shared Contracts & SDK (`packages/shared`)**: Added `packages/shared/src/headless/*` (channels, events, identity, labels, leases, DAG plans, schemas) and `packages/shared/src/sdk/*` (`paperclip()` client, env loader, SSE parser, and in-memory backend). - **Server Routes & Services (`server/`)**: Added `headless-channels-schemas.ts`, `headless-queues-events.ts`, `headless-identity.ts` routes and supporting services (`headless-channels.ts`, `headless-common.ts`, `headless-events-schedules-interactions.ts`, `headless-identity.ts`, `headless-labels-batch.ts`, `headless-schemas.ts`, `headless-task-queue.ts`), plus `issues.scope` visibility isolation and `board-auth.ts` extensions. - **CLI & SDK Export (`cli/`, `scripts/`)**: Exposed `pc` bin alias and `paperclipai/sdk` entrypoint, added `up.ts` zero-prompt launcher and `cli/src/commands/board/*` commands (`post`, `reply`, `read`, `channels`, `label`, `tasks`, `ask`, `confirm`, `approve`, `reject`, `schemas`, `schedule`, `tail`, `wait`, `agent`). - **Docs, Skill & Runner Registry (`doc/`, `skills/`, `tests/runner-e2e/`)**: Added `doc/CHANNELS-AND-QUEUES.md`, `doc/CLI.md`, `doc/HEADLESS-TUTORIALS.md`, plan docs, `skills/paperclip-lite/SKILL.md`, and synchronized `tests/runner-e2e/source-sdk-public-inputs.json`. ## Verification - `pnpm --filter @paperclipai/shared build` — passed. - `pnpm --filter @paperclipai/db check:migrations` — passed (`0511_pale_kronos.sql` and `0512_stormy_the_hood.sql` verified online-compatible, 2 new migrations since `630cf0423024`, none blocked). - `node tests/runner-e2e/source-sdk-public-inputs.mjs $(git rev-parse HEAD) --check` — passed (`598` inputs, `changed: false`). - `pnpm exec vitest run --config tests/runner-e2e/vitest.config.ts tests/runner-e2e/source-sdk-public-inputs.test.mjs` — 13/13 tests passed. - `node scripts/check-maps.mjs` — passed (`35` areas, `192` capability IDs aligned). - `pnpm exec vitest run packages/shared/src/headless/headless.test.ts packages/shared/src/sdk/sdk.test.ts cli/src/__tests__/headless-board-cli.test.ts` — 3 files, 22/22 tests passed. - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/issue-scope-visibility.test.ts src/__tests__/headless-channels-schemas-batch.test.ts src/__tests__/headless-identity-auth.test.ts src/__tests__/headless-queues-leases-events.test.ts src/__tests__/headless-e2e-sdk-cli.test.ts` — 5 files, 25/25 tests passed. - `pnpm --filter @paperclipai/shared typecheck && pnpm --filter @paperclipai/db typecheck && pnpm --filter @paperclipai/server typecheck && pnpm --filter paperclipai typecheck` — all passed. - `pnpm --filter paperclipai build` — passed. ## Risks - **Two new migrations (`0511`, `0512`)**: Both migrations are marked online-compatible (`NOT VALID` constraints validated afterwards, `CONCURRENTLY` index creation, idempotent statements for non-transactional execution) and checked by `check:migrations`. If #23329 lands separately with `0511` modified or renumbered, this branch will rebase on top cleanly. - **Large surface area (91 files)**: Changes are primarily additive new modules (`headless-*`, `cli/src/commands/board/*`, `packages/shared/src/headless/*`, `packages/shared/src/sdk/*`); existing Web UI board behavior remains isolated via `issues.scope`. - **Full repository Vitest suite**: Only the targeted headless, SDK, CLI, server, and runner-e2e pin suites ran locally after rebasing; full cross-package CI checks will validate the remaining suite. ## Model Used - Google DeepMind Antigravity (Gemini coding agent) with tool use and code execution ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [ ] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing> |