@penguinharness/agent-development 0.2.18 → 0.2.19

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/ifaces.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "hash": "5972354ee34ed5d46c4928d2a0761a58a7189c96975518a2047feb03bcae4c9d",
3
+ "ifaces": {
4
+ "@penguinharness/agent-development#AgentDevelopmentPlugin": {
5
+ "name": "AgentDevelopmentPlugin",
6
+ "methods": {},
7
+ "slots": {}
8
+ }
9
+ },
10
+ "types": {},
11
+ "modules": {
12
+ "AgentDevelopmentPlugin": {
13
+ "name": "AgentDevelopmentPlugin",
14
+ "kind": "component",
15
+ "requires": {},
16
+ "provides": {
17
+ "AgentDevelopmentPlugin": "@penguinharness/agent-development#AgentDevelopmentPlugin"
18
+ },
19
+ "contributes": {
20
+ "PluginLibraryModule.cards": [
21
+ {
22
+ "id": "agent-development.card",
23
+ "title": "Agent Development",
24
+ "titleZh": "智能体开发",
25
+ "descriptionZh": "基于 PenguinHarness 的智能体开发:依据需求初始化智能体、用 SDK 构建应用或经 Agent API 接入智能体、搭建 Workbench(智能体自己维护的、对话旁的页面)、经统一的 LLM API 调用任意模型、管理模型与密钥、编排智能体/会话/成本/定时任务。",
26
+ "shortDescription": "Agent setup, SDK, Agent API, workbenches, LLM API, config and orchestration.",
27
+ "shortDescriptionZh": "智能体初始化、SDK、Agent API、Workbench、LLM API、配置与编排。",
28
+ "category": "ai-app-development",
29
+ "icon": "icon.svg",
30
+ "quickStart": {
31
+ "prompt": "Use the penguin CLI to list the agents in this Project and the five most recent sessions, then tell me in one line each what every agent is for.",
32
+ "promptZh": "用 penguin CLI 列出当前 Project 里的 Agent 和最近五个会话,再用一句话说明每个 Agent 是做什么的。",
33
+ "skills": [
34
+ "penguin-orchestration"
35
+ ]
36
+ }
37
+ }
38
+ ],
39
+ "PluginLibraryModule.skills": [
40
+ {
41
+ "id": "agent-development.skill.agent-initialization",
42
+ "name": "agent-initialization",
43
+ "path": "skills/agent-initialization"
44
+ },
45
+ {
46
+ "id": "agent-development.skill.penguin-config",
47
+ "name": "penguin-config",
48
+ "path": "skills/penguin-config"
49
+ },
50
+ {
51
+ "id": "agent-development.skill.penguin-orchestration",
52
+ "name": "penguin-orchestration",
53
+ "path": "skills/penguin-orchestration"
54
+ },
55
+ {
56
+ "id": "agent-development.skill.penguin-plugin",
57
+ "name": "penguin-plugin",
58
+ "path": "skills/penguin-plugin"
59
+ },
60
+ {
61
+ "id": "agent-development.skill.penguin-sdk",
62
+ "name": "penguin-sdk",
63
+ "path": "skills/penguin-sdk"
64
+ },
65
+ {
66
+ "id": "agent-development.skill.unified-llm-api",
67
+ "name": "unified-llm-api",
68
+ "path": "skills/unified-llm-api"
69
+ }
70
+ ]
71
+ },
72
+ "children": []
73
+ }
74
+ },
75
+ "plugin": {
76
+ "modules": [
77
+ "AgentDevelopmentPlugin"
78
+ ],
79
+ "replaces": []
80
+ }
81
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@penguinharness/agent-development",
3
- "version": "0.2.18",
3
+ "version": "0.2.19",
4
4
  "description": "Agent development on PenguinHarness: initialize agents from a requirement, build agent apps on the SDK or connect them to an agent over the Agent API, build workbenches (the pages beside the chat an agent keeps for itself), call any model through one unified LLM API, manage models and secrets, and orchestrate agents, sessions, costs and schedules.",
5
5
  "keywords": [
6
6
  "penguin-plugin",
@@ -8,6 +8,10 @@
8
8
  "skills"
9
9
  ],
10
10
  "license": "Apache-2.0",
11
+ "author": {
12
+ "name": "Prism-Shadow",
13
+ "url": "https://github.com/Prism-Shadow"
14
+ },
11
15
  "repository": {
12
16
  "type": "git",
13
17
  "url": "git+https://github.com/Prism-Shadow/penguin-harness.git",
@@ -17,32 +21,19 @@
17
21
  "icon.svg",
18
22
  "skills",
19
23
  "hooks",
24
+ "ifaces.json",
20
25
  "LICENSE"
21
26
  ],
22
27
  "publishConfig": {
23
28
  "access": "public"
24
29
  },
25
- "penguin": {
26
- "description_zh": "基于 PenguinHarness 的智能体开发:依据需求初始化智能体、用 SDK 构建应用或经 Agent API 接入智能体、搭建 Workbench(智能体自己维护的、对话旁的页面)、经统一的 LLM API 调用任意模型、管理模型与密钥、编排智能体/会话/成本/定时任务。",
27
- "short_description": "Agent setup, SDK, Agent API, workbenches, LLM API, config and orchestration.",
28
- "short_description_zh": "智能体初始化、SDK、Agent API、Workbench、LLM API、配置与编排。",
29
- "category": "ai-app-development",
30
- "icon": "icon.svg",
31
- "quick_start": {
32
- "prompt": "Use the penguin CLI to list the agents in this Project and the five most recent sessions, then tell me in one line each what every agent is for.",
33
- "prompt_zh": "用 penguin CLI 列出当前 Project 里的 Agent 和最近五个会话,再用一句话说明每个 Agent 是做什么的。",
34
- "skills": [
35
- "penguin-orchestration"
36
- ]
37
- },
38
- "title": "Agent Development",
39
- "title_zh": "智能体开发"
40
- },
41
30
  "devDependencies": {
42
31
  "vitest": "^4.1.12",
43
- "@prismshadow/skills": "0.2.18"
32
+ "@prismshadow/penguin-core": "0.2.19",
33
+ "@prismshadow/skills": "0.2.19"
44
34
  },
45
35
  "scripts": {
46
- "test": "vitest run"
36
+ "test": "vitest run",
37
+ "build": "node ../../scripts/gen-ifaces.mjs --project tsconfig.json --out ifaces.json"
47
38
  }
48
39
  }
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: agent-initialization
3
3
  description: Initialize or extend an Agent from a user requirement - write AGENTS.md, set identity metadata, and create, install or import Skills and hook packages (scripts the harness runs on every prompt, before tool calls, or after a task). For an Agent with an in-app workbench, pair with penguin-plugin; for a standalone external program, use penguin-sdk.
4
- version: 2026.10.14.1
4
+ version: 2026.11.07.1
5
5
  ---
6
6
 
7
7
  # Agent Initialization
@@ -151,7 +151,7 @@ Nothing changes in the middle of a context, so a hook you just wrote will not fi
151
151
 
152
152
  ## Set name and description
153
153
 
154
- In the target's `agent_state/system_config.yaml`, set the top-level `name:` and `description:` fields so the agent is recognizable in lists. For an existing Agent, edit only these two fields unless the user explicitly requested a `thinking_level` change.
154
+ In the target's `agent_state/system_config.yaml`, set the top-level `name:` and `description:` fields so the agent is recognizable in lists. For an existing Agent, edit only these two fields unless the user explicitly requested a `thinking_level` change; leave its `author` as it is.
155
155
 
156
156
  ## Creating a brand-new agent
157
157
 
@@ -164,13 +164,13 @@ mkdir -p "$TARGET/agent_state/skills" "$TARGET/agent_state/hooks" "$TARGET/agent
164
164
  cp "$APP_DATA_DIR/agents/default_agent/agent_state/system_config.yaml" "$TARGET/agent_state/"
165
165
  ```
166
166
 
167
- Then set the top-level `name`, `description`, and `version: 1`, set `model.thinking_level` to the resolved value, write `agent_state/AGENTS.md` (it lives under `agent_state/`, not at the agent directory root), and install only the Skills and hook packages required by the user's requirement. Do not persist the resolved provider/model pair in the Agent State. For a new Agent with a workbench, run the `penguin-plugin` check helper after writing its files: it first refreshes the Project's Agent index, so `host.createSession()` can find a file-created Agent before anybody opens the Agents page.
167
+ Then set the top-level `name`, `description`, `author: agent` (who created the Agent: one you create is `agent`, whatever the copied file says) and `version: 1`, set `model.thinking_level` to the resolved value, write `agent_state/AGENTS.md` (it lives under `agent_state/`, not at the agent directory root), and install only the Skills and hook packages required by the user's requirement. Do not persist the resolved provider/model pair in the Agent State. For a new Agent with a workbench, run the `penguin-plugin` check helper after writing its files: it first refreshes the Project's Agent index, so `host.createSession()` can find a file-created Agent before anybody opens the Agents page.
168
168
 
169
169
  ## Validate and report
170
170
 
171
171
  Before finishing:
172
172
 
173
- - parse `agent_state/system_config.yaml` and confirm `name`, `description`, a positive integer `version`, and the expected `model.thinking_level`;
173
+ - parse `agent_state/system_config.yaml` and confirm `name`, `description`, a positive integer `version`, the expected `model.thinking_level`, and `author: agent` on a brand-new Agent;
174
174
  - confirm `agent_state/AGENTS.md` exists and is non-empty;
175
175
  - confirm every installed Skill has a parseable `SKILL.md`, and its `name` matches its directory;
176
176
  - confirm every installed hook package has a `hooks.json` that parses, that each command it lists is a file inside the package, and that each script ran by hand exits 0 and prints JSON or nothing;
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: penguin-config
3
3
  description: Manage model API keys, default models and per-agent vault secrets with the penguin CLI.
4
- version: 2026.10.12.1
4
+ version: 2026.11.20.1
5
5
  ---
6
6
 
7
7
  # Penguin Config (CLI)
@@ -25,13 +25,13 @@ penguin config model add --provider <group> --model-id <upstream_id> [--api-key
25
25
  ```
26
26
 
27
27
  - A model is identified by the `(provider, model_id)` pair, so `--provider` and `--model-id` are **both required** to name one — the group is never inferred from the model id, because gateways resell vendor models under their upstream ids and a wrong guess would send the key to another vendor's endpoint. `--model-id` takes the provider's upstream model id (what the API expects) and is persisted as the entry's request id, so it reaches the API unchanged; `--provider` names the group (`deepseek`, `openai`, `anthropic`, `google`, `openrouter`, `siliconflow`, … — `custom` for any other endpoint).
28
- - Only `custom`, `vllm`, `openrouter`, `tokendance`, `siliconflow`, `atlascloud` and groups of your own take models added by hand. Every other built-in group carries its catalog models only: `model add` there accepts one of that group's catalog model ids (to set its key, limits or prices, or to bring it back) and refuses any other id with "cannot be added". Add such a model under `custom` with `--base-url`, or under a group of your own.
28
+ - Only `custom`, `vllm`, `openrouter`, `tokendance`, `siliconflow`, `atlascloud`, `runcrate` and groups of your own take models added by hand. Every other built-in group carries its catalog models only: `model add` there accepts one of that group's catalog model ids (to set its key, limits or prices, or to bring it back) and refuses any other id with "cannot be added". Add such a model under `custom` with `--base-url`, or under a group of your own.
29
29
  - `--api-key`, `--base-url` and `--client-type` set the model's **own** values, and `--clear-api-key`, `--clear-base-url` and `--clear-client-type` remove them. Omitted, the model follows its group (see [Group connection](#group-connection)), and with no group value it gets the client's default; the built-in catalog is never consulted. A model added to `openrouter`, `tokendance` or `siliconflow` needs only `--provider` and `--model-id` once the group has a key: a new Project already stores those gateways' endpoint and protocol on the group. For an OpenAI chat-completion compatible endpoint under `custom` or a group of your own, use `--client-type openai --base-url <endpoint>`, or set both once on the group; in a vendor group, omit `--client-type` to auto-route by model id.
30
30
  - Prices are USD per million tokens (cache read / cache write / output).
31
31
  - `--vision` / `--no-vision` mark whether the model accepts images; omitting both keeps the current value (default is vision-capable).
32
32
  - `--max-tokens <n>` pins a per-model output cap (positive integer), overriding the Agent's `model.max_tokens`; omit to inherit. Lower it for small-context models — the per-Agent default (32000) cannot fit into e.g. a 32k context window together with any prompt.
33
33
  - All `penguin config model ...` and `penguin config vault ...` commands accept `--root <dir>` to target another data root (default `PENGUIN_HOME`, then `~/.penguin/data`). Two configuration targets — treat the difference as a hard rule:
34
- - **Penguin's own model** (self-configuration: the model Penguin itself runs on): pass `--root <data root>` as well — the parent directory of the App Data Dir named in your Environment section. An agent running inside PenguinHarness never sees `PENGUIN_HOME`: the harness strips every `PENGUIN_*` variable from a command's environment, so a command without `--root` falls back to `~/.penguin/data` and configures a root the running server does not read.
34
+ - **Penguin's own model** (self-configuration: the model Penguin itself runs on): pass `--root <data root>` as well — the App Data Dir named in your Environment section is `<data root>/projects/<project_id>`, so the data root is the directory two levels above it. An agent running inside PenguinHarness never sees `PENGUIN_HOME`: the harness strips every `PENGUIN_*` variable from a command's environment, so a command without `--root` falls back to `~/.penguin/data` and configures a root the running server does not read.
35
35
  - **An AI app you are building**: `--root` **must** point at the app's own data directory inside the project (e.g. `--root ./penguin_data`, the same path the app gives `createAgent({ root })`) unless the user explicitly chose another location — never write an app's models or keys into the global `~/.penguin/data`, which belongs to the person running Penguin, not to the app.
36
36
  - While developing an app, review regularly: `penguin config model list --root <app root>` should show the app's entries, and the global list (no `--root`) should stay clean.
37
37
 
@@ -1,25 +1,55 @@
1
1
  ---
2
2
  name: penguin-plugin
3
- description: Use for workbenches — the tabs and pages beside the chat, with server code behind them, that an Agent keeps in its own `workbenches/` folder inside PenguinHarness — building one, changing it, showing it as the whole app, restoring an earlier version, and removing a tab or a whole workbench when the user wants the custom UI gone.
4
- version: 2026.10.26.1
3
+ description: Use for PenguinHarness plugins and workbenches — what a plugin package is and how to build, test, share and submit one, and the workbenches (the tabs and pages beside the chat, with server code behind them) an Agent keeps in its Agent State — building one, changing it, showing it as the whole app, restoring an earlier version, and removing it when the user wants the custom UI gone.
4
+ version: 2026.11.21.2
5
5
  ---
6
6
 
7
- # Agent Workbench with Penguin Plugins
8
-
9
- Inside PenguinHarness an Agent can hold *workbenches*: small plugin packages in its own directory, written in TypeScript, that the server boots as module trees, shows as tabs beside the chat, reloads on every file change, and versions so any edit can be undone. This is the same module mechanism the server itself is built from — manifests as data, everything checked before any code runs — so a workbench that does not type-check, that was written against an interface version this server no longer fits, or whose manifests do not hold together fails to load with the problem named, while the previous version keeps serving.
10
-
11
- A workbench is a plugin of the server's own kind, which is where this skill's name comes from. It is not a program that reaches an agent from outside, so it takes neither of the penguin-sdk skill's two ways, and that skill's question does not apply to it.
7
+ # Penguin Plugins
8
+
9
+ Inside PenguinHarness an Agent can hold *workbenches*: small plugin packages in its own Agent State, written in TypeScript, that the server boots as module trees, shows as tabs beside the chat, reloads on every file change, and versions so any edit can be undone. This is the same module mechanism the server itself is built from — manifests as data, everything checked before any code runs — so a workbench that does not type-check, that was written against an interface version this server no longer fits, or whose manifests do not hold together fails to load with the problem named, while the previous version keeps serving.
10
+
11
+ A workbench is a plugin of the server's own kind, which is where this skill's name comes from; the same skill covers standalone plugin packages — how to design, test and share one. A workbench is not a program that reaches an agent from outside, so it takes neither of the penguin-sdk skill's two ways, and that skill's question does not apply to it.
12
+
13
+ ## References
14
+
15
+ - [Before you start](#before-you-start)
16
+ - [Build a new Agent and its workbench](#build-a-new-agent-and-its-workbench)
17
+ - [Background jobs: launch, poll, persist](#background-jobs-launch-poll-persist)
18
+ - [Follow the Agent live (AMSP)](#follow-the-agent-live-amsp)
19
+ - [Design a plugin](#design-a-plugin)
20
+ - [Layout](#layout)
21
+ - [The manifest and the handler](#the-manifest-and-the-handler)
22
+ - [Design the interaction before writing the UI](#design-the-interaction-before-writing-the-ui)
23
+ - [TypeScript, checked by the server](#typescript-checked-by-the-server)
24
+ - [Types come from the harness that runs you](#types-come-from-the-harness-that-runs-you)
25
+ - [Pages in TSX](#pages-in-tsx)
26
+ - [Theme](#theme)
27
+ - [Tabs are contributions](#tabs-are-contributions)
28
+ - [Operate with plugin host](#operate-with-plugin-host)
29
+ - [The host](#the-host)
30
+ - [HTTP](#http)
31
+ - [Undoing, reverting, removing](#undoing-reverting-removing)
32
+ - [Filling the app](#filling-the-app)
33
+ - [The App Center](#the-app-center)
34
+ - [Data and storage](#data-and-storage)
35
+ - [Adding configuration](#adding-configuration)
36
+ - [A workbench's folders](#a-workbenchs-folders)
37
+ - [Test a plugin](#test-a-plugin)
38
+ - [Unit testing using vitest](#unit-testing-using-vitest)
39
+ - [E2E testing using electron](#e2e-testing-using-electron)
40
+ - [Integration testing using a separate penguin instance](#integration-testing-using-a-separate-penguin-instance)
41
+ - [Sharing a plugin](#sharing-a-plugin)
12
42
 
13
43
  ## Before you start
14
44
 
15
45
  If the user's message only invokes this skill (e.g. "use penguin-plugin skill") without saying what the workbench is for, ask the user what they want it to do. Once the request is concrete, do **not** ask follow-up questions: build it end to end and list the assumptions you made in your final reply. A request to undo, revert or remove the UI is the exception: work out which of the four in *Undoing, reverting, removing* is meant first.
16
46
 
17
- ## Build a new Agent and its workbench
47
+ ### Build a new Agent and its workbench
18
48
 
19
49
  For an app inside PenguinHarness, use this skill with `agent-initialization`. The Plugin host already runs the Agent; do not ask the user to choose SDK/API architecture or enable Agent API keys. If the request says **new Agent**, create that target first and put all workbench files in **its** directory, not the Builder's. Keep the resolved target path for the whole task.
20
50
 
21
51
  1. Read the Environment's App Data Dir and Agent ID; use `agent-initialization` to create the requested target. List existing agent ids, choose an unused id (letters, digits and underscores), and write its role. Give a contract reviewer domain instructions, not app-building skills. Inherit the current runtime unless the user specified another.
22
- 2. Under `<App Data Dir>/agents/<target_agent_id>/workbenches/<workbench_id>/`, write the three-file scaffold below. Every visible app needs a `WebModule.sessionTabs` contribution.
52
+ 2. Under `<App Data Dir>/agents/<target_agent_id>/agent_state/workbenches/<workbench_id>/`, write the three-file scaffold below. Every visible app needs a `WebModule.sessionTabs` contribution.
23
53
  3. **Activate and check the target**, including a new Agent nobody has opened yet:
24
54
  ```bash
25
55
  node "<this skill directory>/scripts/check.mjs" <target_agent_id> <workbench_id>
@@ -29,7 +59,7 @@ For an app inside PenguinHarness, use this skill with `agent-initialization`. Th
29
59
  5. Exercise a real request through your handler, wait for a terminal result, and inspect the returned answer or downloaded report. For HTTP tests use the injected URL with `curl --noproxy '*'`, bearer token only in the header. Check malformed input and empty/loading/failed states too. A compiler pass is not an end-to-end test. If browser automation is unavailable, report that limitation; finish the HTTP and script-syntax checks and state that the visual check remains unverified. Do not launch a separate system browser or install a DOM/browser test environment for a one-off workbench.
30
60
  6. Hand off through **Agents → target Agent → New chat → the named workbench tab**. The workbench works in a new conversation before the user sends a chat message. Include the target Agent's link (`/agents/<target_agent_id>`) and tab name. Full-page mode is optional.
31
61
 
32
- ## Background jobs: launch, poll, persist
62
+ ### Background jobs: launch, poll, persist
33
63
 
34
64
  `await host.run(...)` resolves when a turn **starts**. `await host.sessionResult(id)` is also a **snapshot**, never a wait. Its `status` is `running`, `completed` or `failed`; `text` is the final assistant answer only on success, and `error` explains failure. `sessionStatus() === "idle"` alone does not prove success.
35
65
 
@@ -40,9 +70,9 @@ Use this pattern for uploads, research and support tickets:
40
70
  - Let the page poll GET every few seconds while visible; to show the answer as it is written, follow the Session too (*Follow the Agent live*). Reopening the tab or reloading code resumes from persisted session ids. Do not keep the only job state in a detached promise or a timer that disappears on reload.
41
71
  - For text reports, ask the Agent to put the complete report in its **final answer**; store that returned text and serve it with a download content type and `Content-Disposition: attachment`. Link directly to the same-origin report route with an `<a download>`; avoid fetching a Blob and clicking an object URL, which did not download in the embedded browser. Verify the saved file, not a toast saying it started. No Trace parsing or cross-workspace report-file probe is needed.
42
72
  - `host.getState()` is synchronous, `unknown`, initially `null`. Clone before editing; serialize read/modify/write handlers to avoid lost updates. Await `host.setState` before returning success.
43
- - Store large upload bytes outside the watched source folder, e.g. the target Agent's `scratchpad/<workbench_id>/uploads/`. Keep metadata in host state. Source changes trigger reloads; runtime files in `workbenches/<id>/` trigger needless rebuilds and enter version history. `import.meta.url` points into `.build/<revision>/`, not the source root.
73
+ - Store large upload bytes and persistent artifacts in the workbench's `dataDir` with `node:fs` (see *Data and storage*), outside the watched source folder. Keep metadata in host state. Source changes trigger reloads; runtime files in `workbenches/<id>/` trigger needless rebuilds and enter version history. `import.meta.url` points into `.build/<revision>/`, not the source root.
44
74
 
45
- ## Follow the Agent live (AMSP)
75
+ ### Follow the Agent live (AMSP)
46
76
 
47
77
  Polling shows a job only once it is done. To show the answer while the Agent writes it, and to learn the moment a turn ends, follow the job's Session over AMSP: the records its Trace holds plus the streamed fragments, the same ones the chat view reads. AMSP carries the Agent's conversation and nothing else. Starting a turn, follow-ups, saving results and every other side effect stay in your handler.
48
78
 
@@ -83,6 +113,7 @@ function closeItem() {
83
113
  - `followSession(sessionId, options?)` returns the SDK's `SessionReader` on the Session's stream, taking `tailLimit` and the reader's other options: it reads the latest Tasks of the history (events with `source: "history"`), then the live tail, and reconnects on its own. On `reset`, drop what you drew; the history follows again. Records of subagents come through with an `origin`; skip them yourself.
84
114
  - `task_end` is a hint, not the result: on it, refresh from your handler, whose saved answer is what stays. Keep the polling path from *Background jobs* as the fallback for a failed import, and keep the list itself on (slower) polling.
85
115
  - `abortSession(sessionId)` stops the running task, for a Stop button, and resolves `true` when there was one to stop, `false` when nothing was running.
116
+ - `chooseChatModel(current?)` opens the app's own model picker over the page and resolves `{ provider, modelId, label }`, or `null` when the user closes it; `getChatModel(current?)` resolves a model's `{ provider, modelId, label }` as the app names it (the Project default when you pass none), or `null`. Hand the choice to your handler, which opens the Session with `host.createSession({ model: { provider, modelId } })`; to change the model of a Session that exists, `POST` `/sessions/<id>/switch-model` `{ provider, modelId }` through `transport`. Both reject with an error named `WorkbenchHostUnavailable` when the page is not shown in the app (opened on its own, or in an app too old to answer): fall back to the Project default.
86
117
  - `workbench.js` re-exports everything `@prismshadow/amsp` does, plus `apiBase` and `transport` for other reads of the signed-in user's door. Never write an absolute `/api/…` path into a page: a workbench on a machine is served under `/server/<machine>/api/…`, a reverse proxy may add a prefix of its own, and `apiBase` already says which.
87
118
 
88
119
  **The handler** gets the same records from `host.subscribe(sessionId, listener)`, which returns the function that stops them. It is live only: nothing from before the call, no history, so subscribe before `host.run`. A record is a `WorkbenchRecord` (`{ timestamp, type, payload: { type?, … }, origin? }`, from `@prismshadow/penguin-server/plugin`). Treat it as a trigger and keep `await host.sessionResult(sessionId)` as the authoritative snapshot:
@@ -118,20 +149,38 @@ Never reach the Agent from a workbench through the Agent API: not `/api/amsp/v1`
118
149
 
119
150
  To see what a page will see, start a turn through your handler and run `node "<this skill directory>/scripts/check.mjs" --follow <sessionId>`: it prints the Session's records as they arrive, one JSON line each, until the main conversation's `task_end` or for a minute at most.
120
151
 
121
- ## Layout
152
+ ## Design a plugin
153
+
154
+ ### Layout
122
155
 
123
- Layout, under `<root>/<project_id>/agents/<agent_id>/workbenches/<workbench_id>/` (beside `agent_state/`):
156
+ Layout, under `<App Data Dir>/agents/<agent_id>/agent_state/workbenches/<workbench_id>/` (inside the Agent State):
124
157
 
125
158
  ```
126
159
  package.json "type": "module" and "penguin": { "modules": [ …manifests ] } — no dependency to install
127
160
  index.ts default export { modules: { <Name>: { create(ctx) } } } satisfies WorkbenchPackage — TypeScript only
128
- ui/ the workbench's pages and their assets; which of them are tabs is what the manifest contributes
161
+ ui/ the workbench's pages and their assets, plain JS or TSX (see Pages in TSX); which of them are tabs is what the manifest contributes; ui/icon.svg is its App Center icon when the manifest names it
129
162
  state.json the workbench's own document, kept by the server across reloads and rollbacks
130
- .harness/ the server's: the types this workbench was written against (plugin.d.ts) and their interface table — read plugin.d.ts, never edit it
131
- .build/ the server's: emitted JavaScript per revision, and status.json — the result of the last load; read it, never edit it
163
+ .harness/ the server's: the types this workbench was written against (plugin.d.ts) and their interface table — read plugin.d.ts, never edit it; ui/ holds the types TSX pages compile against
164
+ .build/ the server's: emitted JavaScript per revision (<revision>/ui/ for TSX pages), and status.json — the result of the last load; read it, never edit it
165
+ ```
166
+
167
+ The versions are kept beside the Agent State, not in it: `<App Data Dir>/agents/<agent_id>/agent_state.git/` is a bare git repository, the server's record of workbench versions, created at the first successful load; `agent_state/` itself holds no git files. Each successful load that changed a workbench's source commits that folder as `workbenches/<id>/`, and nothing else: not its `state.json`, `.harness/`, `.build/`, `.plugin.json` or `node_modules/`, and none of the rest of the Agent State. A workbench's revision is git's tree id of its folder. Never delete or rewrite `agent_state.git`, and do not commit to it (the server writes it without an index). Use git on it only to read — `log`, `show` — and to write one version's files back into `agent_state/` with a path-limited `checkout` (see *Undoing, reverting, removing*).
168
+
169
+ A **standalone plugin package** (shared through npm, the plugin index or `penguin plugin link`) wraps Skills, a hook package, MCP servers, workbenches or server modules into a normal npm package:
170
+
171
+ ```
172
+ package.json npm's own fields only ("name", "version", "description", "files", "scripts": { "build": "penguin-gen-ifaces --project tsconfig.json --out ifaces.json", "test": "vitest run" })
173
+ tsconfig.json what the build compiles (src/)
174
+ src/index.ts @Component({ contributes: { "PluginLibraryModule.cards": […], "PluginLibraryModule.skills": […], … } }) and export default { modules: […] } satisfies Plugin
175
+ ifaces.json generated by penguin-gen-ifaces; what the server reads without running the package
176
+ icon.svg the plugin's icon (plain SVG, ≤ 64 KiB)
177
+ skills/<name>/SKILL.md contributed Skills, each with its own YYYY.MM.DD.N version
178
+ hooks/*.mjs optional hook scripts
179
+ workbenches/<id>/ optional workbench directories (same layout as above, with a YYYY.MM.DD.N penguin.version in the workbench's own package.json)
180
+ test/*.test.ts unit and e2e tests (see Test a plugin)
132
181
  ```
133
182
 
134
- ## The manifest and the handler
183
+ ### The manifest and the handler
135
184
 
136
185
  The root manifest is named `Workbench`; it requires the host, provides the handler, and contributes its tabs:
137
186
 
@@ -188,12 +237,17 @@ export default {
188
237
  } satisfies WorkbenchPackage;
189
238
  ```
190
239
 
191
- ## Design the interaction before writing the UI
240
+ ### Design the interaction before writing the UI
192
241
 
193
- Treat the workbench as an application people return to. Before coding, choose its main list,
194
- its item detail, and how a person creates and revisits an item. Use that structure even when the
195
- request only says “build a Q&A app”. Do not turn independent conversations into one ever-growing
196
- page of complete answers.
242
+ Choose one task people repeat. When improving an existing workbench, try that task with a real
243
+ item and note the exact step where you get stuck or lose work. See how an established app for
244
+ that task handles the step, using its official guide if needed. Adapt the interaction to the
245
+ workbench's content and Penguin's controls.
246
+
247
+ For document editors or workbenches with AI chat, read
248
+ [Document editors and AI conversations](reference/editors-and-chat.md) for the file menu,
249
+ saving an embedded editor, choosing a Session model and showing each turn's progress.
250
+ For a Q&A app or a job queue, give each item its own detail view.
197
251
 
198
252
  - For questions, requests and jobs, start with a compact, centered list of titles, statuses and
199
253
  update times. Open one item's conversation in a dialog or detail panel. Keep follow-up messages
@@ -225,32 +279,129 @@ far down the page. Also check a narrow viewport, dark mode, keyboard focus and t
225
279
  full-app mode. Use a real browser when available; report any interaction you could not run. A
226
280
  successful TypeScript load alone is not UI/UX validation.
227
281
 
228
- ## TypeScript, checked by the server
282
+ ### TypeScript, checked by the server
229
283
 
230
- There is no build step to run, no `tsconfig.json` to write and nothing to `npm install`: the server builds one program from `index.ts` (and the `.ts` files it imports, with `.js` in the import specifier as NodeNext asks) under options it fixes itself — `strict` among them — refuses the load on any diagnostic, reporting file, line and reason, and otherwise emits into `.build/<revision>/` and imports that. `satisfies WorkbenchPackage` is what types `use.host` and `req`; without it `strict` refuses the untyped parameters. A folder holding `index.js` or `index.mjs` instead is refused outright.
284
+ There is no build step to run, no `tsconfig.json` to write and nothing to `npm install`: the server builds one program from `index.ts` (and the `.ts` files it imports, with `.js` in the import specifier as NodeNext asks) under options it fixes itself — `strict` among them — refuses the load on any diagnostic, reporting file, line and reason, and otherwise emits into `.build/<revision>/` and imports that. `satisfies WorkbenchPackage` is what types `use.host` and `req`; without it `strict` refuses the untyped parameters. A folder holding `index.js` or `index.mjs` instead is refused outright. When `ui/` holds a `.tsx` file, the pages are a second program, checked and emitted the same way (*Pages in TSX*); a diagnostic in either refuses the whole load. Pages in plain JS are served as written and never checked.
231
285
 
232
- ## Types come from the harness that runs you
286
+ ### Types come from the harness that runs you
233
287
 
234
288
  One machine can run several harnesses — a release, a checkout, a platform someone pushed with interfaces of its own — and none of them is a version on npm, so `@prismshadow/penguin-server/plugin` is not a package here: the first time the server loads the folder it writes `.harness/plugin.d.ts`, rendered from ITS OWN interface table, and that is what the import resolves to. Create `package.json` and a minimal `index.ts`, let the server load it once, then read `.harness/plugin.d.ts` for the exact `WorkbenchHost` this harness offers. The server then leaves `.harness/` alone: it is the record of what the workbench was written against, and a later generation of the platform is COMPARED with it, by the TypeScript compiler, both for what the workbench requires and what it provides — a host method you rely on that has since gone is a load error naming it, not a failure on the first call. To move a workbench onto the harness that runs it now, delete `.harness/` and fix what the compiler then reports.
235
289
 
236
- ## Tabs are contributions
290
+ ### Pages in TSX
291
+
292
+ Write a new page in TSX with the app's own components; plain-JS pages keep working. There is nothing to install and no bundler: when `ui/` holds a `.tsx` file, the server type-checks every `.ts`/`.tsx` under `ui/`, emits them into `.build/<revision>/ui/`, serves React and `@prismshadow/penguin-ui` beside the workbench, and writes their stylesheet link and an import map into the head of every HTML file under `ui/` (so write neither yourself). A page runs against the copy that checked it, offline too; a version in your `package.json` changes nothing.
293
+
294
+ `ui/index.html` loads the emitted `app.js`, never `app.tsx`:
295
+
296
+ ```html
297
+ <!doctype html>
298
+ <html>
299
+ <head>
300
+ <meta charset="utf-8" />
301
+ <link rel="stylesheet" href="style.css" />
302
+ </head>
303
+ <body>
304
+ <div id="root"></div>
305
+ <script type="module" src="app.js"></script>
306
+ </body>
307
+ </html>
308
+ ```
309
+
310
+ `ui/app.tsx`:
311
+
312
+ ```tsx
313
+ import { useEffect, useState } from "react";
314
+ import { createRoot } from "react-dom/client";
315
+ import { Badge, Button, EmptyState, Spinner } from "@prismshadow/penguin-ui";
316
+
317
+ type Job = { id: string; title: string; status: "running" | "completed" | "failed" };
318
+ const BADGE = {
319
+ running: { tone: "success", label: "Running" },
320
+ completed: { tone: "done", label: "Answered" },
321
+ failed: { tone: "danger", label: "Failed" },
322
+ } as const;
323
+
324
+ function App() {
325
+ const [jobs, setJobs] = useState<Job[] | "failed" | null>(null);
326
+ const load = () =>
327
+ fetch("../api/jobs")
328
+ .then((r) => (r.ok ? (r.json() as Promise<{ jobs: Job[] }>) : Promise.reject(r.status)))
329
+ .then((body) => setJobs(body.jobs), () => setJobs("failed"));
330
+ useEffect(() => void load(), []);
331
+
332
+ if (jobs === null) return <Spinner label="Loading" />;
333
+ if (jobs === "failed") {
334
+ const retry = <Button onClick={() => void load()}>Try again</Button>;
335
+ return <EmptyState title="The questions could not be loaded" action={retry} />;
336
+ }
337
+ if (jobs.length === 0) return <EmptyState title="No questions yet" />;
338
+ return (
339
+ <ul className="jobs">
340
+ {jobs.map((job) => (
341
+ <li key={job.id}>
342
+ <span>{job.title}</span>
343
+ <Badge tone={BADGE[job.status].tone}>{BADGE[job.status].label}</Badge>
344
+ </li>
345
+ ))}
346
+ </ul>
347
+ );
348
+ }
349
+
350
+ createRoot(document.getElementById("root")!).render(<App />);
351
+ ```
352
+
353
+ `ui/style.css`, for your own elements only (*Theme*):
354
+
355
+ ```css
356
+ .jobs { max-width: 40rem; margin: 2rem auto; padding: 0; list-style: none; }
357
+ .jobs li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.625rem 0; border-bottom: 1px solid var(--ui-line); }
358
+ ```
359
+
360
+ - **Imports.** `react`, `react/jsx-runtime`, `react-dom`, `react-dom/client` and `@prismshadow/penguin-ui` (no subpath), plus your own files under `ui/`, named with `.js` as NodeNext asks (`./list.js` for `list.tsx`). Anything else fails the load, naming the import: another npm package, a source file outside `ui/` (the handler's included: copy a shared type instead), a CSS import (`import "./style.css"`: link it in the HTML), and `x.ts` or `x.tsx` beside an `x.js` of the same name.
361
+ - **Did it load.** A page's error, a broken import rule as much as a type error, lands in `.build/status.json` like the handler's and starts with `ui/<file>:<line>:<col>`, e.g. `ui/app.tsx:14:31 TS2322 …`; the previous version, pages included, keeps serving. The options are the server's (`strict`, ES2022, NodeNext, `jsx: react-jsx`, the DOM's types), so there is still no `tsconfig.json` to write.
362
+ - **Exact props.** On a load with a `.tsx`, the server writes the types pages compile against into `.harness/ui/`: read `.harness/ui/node_modules/@prismshadow/penguin-ui/index.d.ts` for a component's props instead of guessing. The other packages there (`react-markdown`, `zustand`, …) are only what those props name: a page still cannot import them. Unlike `plugin.d.ts`, `.harness/ui/` is no record: the server rewrites it whenever the copy it serves changes, so never edit it. If a load with a `.tsx` leaves no `.harness/ui/` and no error, this harness predates TSX pages; if it fails saying this server has "no page runtime", it has none (a source checkout whose Web App was never built, say). Either way, write the page in plain JS.
363
+ - **One kind per workbench.** Once `ui/` holds a `.tsx` file, every HTML page under it gets the components' stylesheet instead of `/workbench-ui.css`, so plain pages beside it lose their `wb-*` look: convert a workbench's pages together.
364
+ - **The page SDK** (*Follow the Agent live*) is served, not a file under `ui/`, so a literal `import("../sdk/workbench.js")` fails the check. Import it through a variable, which the compiler leaves alone, and type what you call:
365
+
366
+ ```tsx
367
+ const SDK_URL: string = "../sdk/workbench.js";
368
+ type PageSdk = { abortSession(sessionId: string): Promise<boolean> /* followSession, … */ };
369
+ // null: an older server without the page SDK; keep polling.
370
+ const loadSdk = () => import(SDK_URL).then((m) => m as PageSdk, () => null);
371
+ ```
372
+
373
+ ### Theme
374
+
375
+ A workbench page is a separate document, so it inherits nothing from the app's stylesheet by itself. The Web App stamps the app's look onto the page's root on every load and every appearance change: `light`/`dark`, `data-theme` (`modern`, `geek` or `github`), `data-accent` (only when the theme paints that accent), `data-font-latin` and `data-font-cjk`, the root font size, every `--ui-*` token of the app's token contract resolved as an inline style, and the app's bundled fonts. Take every colour and font from the variables below and the page follows the user through every theme, accent, font and light/dark change; hardcode them and it clashes in one theme or another. Pick a status tone the way the app does: there is no busy tone, so a running item is `success` with the word "Running", waiting or queued is `attention`, failed is `danger`, and finished is `done` or `neutral`.
376
+
377
+ **A TSX page** (*Pages in TSX*) gets the components' stylesheet from the server, and the Web App leaves `/workbench-ui.css` out of it: no `--wb-*` variables, no `wb-*` classes. The components follow the theme by themselves and take their look from props such as `variant`, `tone` and `size` (`<Badge tone="done">Resolved</Badge>`). Style your own elements in a stylesheet of your own, under class names of your own, reading the tokens the components paint with: `--ui-canvas`, `--ui-surface`, `--ui-fg`, `--ui-fg-muted`, `--ui-line`, `--ui-accent`, `--ui-accent-fg`, `--ui-radius-md`, `--ui-font-mono`, and `--ui-tone-<tone>-fg`, `-bg` and `-line`. No Tailwind classes on your own elements: only the classes the components use are compiled, so some would work by chance and the rest silently do nothing. No rules on bare elements (`button`, `input`, `table`): yours would beat the components' own, which sit in cascade layers, and for the same reason never link `/workbench-ui.css` into a TSX page.
378
+
379
+ **A plain-JS page** gets `/workbench-ui.css` injected first in the head: a base stylesheet that styles plain HTML (headings, lists, forms, tables, code) to match the app and exposes `--wb-bg`, `--wb-surface`, `--wb-fg`, `--wb-muted`, `--wb-border`, `--wb-hover`, `--wb-accent`, `--wb-accent-fg`, `--wb-radius` (a box radius, not a pill), `--wb-font`, `--wb-mono`, the tone colours `--wb-tone-<tone>-fg`, `-bg` and `-line`, plus the classes `wb-primary` (a button), `wb-card`, `wb-rows`, `wb-row`, `wb-muted` and `wb-badge`, a status pill coloured by `data-tone` (`neutral` without one), e.g. `<span class="wb-badge" data-tone="done">Resolved</span>`. The `--wb-*` names are only ever added to, never renamed. The `--ui-*` tokens underneath are readable too, but they follow the app's token contract and can be renamed with it, and as inline styles on the root no stylesheet of yours overrides them: to restyle, redeclare `--wb-*` on `:root`. The page's own rules always win over `/workbench-ui.css`, and linking `/workbench-ui.css` yourself makes it look right when opened outside the app too.
380
+
381
+ **The page is see-through.** In the app a page's body paints nothing, so whatever the app shows under the chat — the theme's page colour, the Frost sheet, the user's wallpaper — shows through the page as it does under the conversation. Leave the body without a background to keep that. For a solid sheet (a drawing surface, a page that must not show an image behind it), paint the app's opaque page colour yourself: `body { background: var(--wb-canvas); }` on a plain page, `var(--ui-canvas)` in a TSX page's stylesheet. A background your own rules set always wins. Cards, inputs and buttons keep their own fills.
382
+
383
+ Keep empty alerts hidden. A component rule such as `.notice { display: flex }` overrides the browser's default `[hidden]` styling; the shared stylesheet preserves `[hidden]`, and standalone custom CSS should do the same. Check both empty and populated states.
384
+
385
+ ### Tabs are contributions
237
386
 
238
387
  Each entry under `WebModule.sessionTabs` is one tab beside the chat: `key` (unique in the workbench, part of the full-page URL), `title` / `titleZh`, and a `renderer` whose `iframe.src` is a file under `ui/`. Several entries make several tabs; none makes a server-only workbench. It is the same slot, written the same way, a plugin contributes to — the host opens it to workbenches and scopes the tab to this Agent. A slot the host has not opened (`WebModule.pages`, say) is refused by name.
239
388
 
240
- ## The host
389
+ ## Operate with plugin host
241
390
 
242
- `WorkbenchHost` (published as module `Host`) speaks the SDK's verbs, scoped to the workbench's Project: `listAgents()` returns the Project's Agents as `{ agentId }[]`; `createSession({ agentId? })` opens a Session of this Agent — or of another Agent of the same Project — and returns `{ sessionId }`. These Sessions carry source `workbench` and are automatically archived from the main chat sidebar; your list still reads and runs them through the host. `sessionTitle(sessionId)` returns the current generated title (or `null` before one exists); `run(sessionId, [{ text: "…" }])` — the SDK's `session.run`, its input items spelled out because a workbench has no package to import `userText` from — runs one turn in a Session, new or existing, and returns `{ sessionId, queued }` once it has started (a busy Session queues it as a follow-up; the Agent hears it as a message from the server, not from a person); `sessionStatus(sessionId)` says `idle` / `running` / …; `await sessionResult(sessionId)` returns a snapshot of the latest task (see *Background jobs*); `subscribe(sessionId, listener)` hands the listener the Session's AMSP records as they are written, live only, and returns the function that stops it (see *Follow the Agent live*); `getState()` / `setState(doc)` over `state.json` (`getState()` is `unknown`: narrow it); `log(text)`. More modules may be listed in `penguin.modules` and named as `children` of `Workbench`, with their own `requires` between them — the tree is checked as a whole.
391
+ ### The host
243
392
 
244
- ## HTTP
393
+ `WorkbenchHost` (published as module `Host`) speaks the SDK's verbs, scoped to the workbench's Project: `listAgents()` returns the Project's Agents as `{ agentId }[]`; `createSession({ agentId?, approvalMode?, model? })` opens a Session of this Agent — or of another Agent of the same Project — and returns `{ sessionId }`; it runs on the Project's default model unless `model` (`{ provider, modelId }`, a model of the Project's catalog, such as one the user chose with the page SDK's `chooseChatModel()`) names another. Every tool call in it runs (`allow-all`) unless `approvalMode` is `"deny-all"`, which denies them all: pass it for a Session that only talks — a character, a game host, anything that hands the model the user's words or a text the user imported — and say in its prompt as well that it has no tools. No other mode is accepted: nobody is there to answer an ask. These Sessions carry source `workbench` and are automatically archived from the main chat sidebar; your list still reads and runs them through the host. `sessionTitle(sessionId)` returns the current generated title (or `null` before one exists); `run(sessionId, [{ text: "…" }])` — the SDK's `session.run`, its input items spelled out because a workbench has no package to import `userText` from — runs one turn in a Session, new or existing, and returns `{ sessionId, queued }` once it has started (a busy Session queues it as a follow-up; the Agent hears it as a message from the server, not from a person); `sessionStatus(sessionId)` says `idle` / `running` / …; `await sessionResult(sessionId)` returns a snapshot of the latest task (see *Background jobs*); `subscribe(sessionId, listener)` hands the listener the Session's AMSP records as they are written, live only, and returns the function that stops it (see *Follow the Agent live*); `getState()` / `setState(doc)` over `state.json` (`getState()` is `unknown`: narrow it); `dataPaths(level?)` returning the workbench's own folders `{ dataDir, cacheDir, stateDir }` at the `agent` (default), `server` or `machine` level, and `socketPath(name, level?)` for a local socket in that `stateDir` (see *Data and storage*); `log(text)`. More modules may be listed in `penguin.modules` and named as `children` of `Workbench`, with their own `requires` between them — the tree is checked as a whole.
245
394
 
246
- HTTP, all under `/api/projects/:projectId/agents/:agentId/workbenches` (Project members only): `GET /` lists the workbenches with their `revision`, `uiRev`, `tabs` (each page's URL resolved) and current load `error`; `GET /:id/ui/*` serves a file of `ui/` (there is no default document — a tab names its page); any method on `/:id/api/*` reaches `handle` — JSON by default in both directions (`req.body` parsed, `{ status?, body? }` answered as JSON), and anything else when you say so: a non-JSON request body arrives as `req.bytes` (a `Uint8Array`; `req.headers` has its `content-type`, never the app's cookie), and a response that names a `content-type` in `headers` sends `body` as the string you wrote, or `bytes` for binary, or `stream` — an async iterable (an `async function*`) of strings or `Uint8Array`s, each chunk written to the client as you yield it, which is how server-sent events and a model's token-by-token answer get through without waiting for the end (relay an upstream stream by yielding its chunks; a `finally` in the generator runs when the client goes away — though a generator parked inside an `await` only gets there once that await settles, so give a relay its own timeout rather than trusting the disconnect) — with `location` + a 3xx status for a redirect. That is how a handler serves a page it renders, an upload, a download, or the pages of a program it runs on this machine: fetch `http://127.0.0.1:<port>/…` from the HANDLER and return what came back — never put `127.0.0.1` in a page, because the page runs in the user's browser, which may be on another machine than you are; `GET /:id/sdk/workbench.js` and `GET /:id/sdk/amsp.js` serve the page SDK (the `@prismshadow/amsp` browser build of the server answering, see *Follow the Agent live*); `POST /:id/reload`; `GET /:id/history` lists recorded versions; `POST /:id/rollback { revision }` restores one (code only — `state.json` stays) and reloads. `DELETE /:id` removes the workbench together with its recorded versions. From a page directly under `ui/`, call your handler with a relative `fetch("../api/…")` and import the page SDK with `import("../sdk/workbench.js")`; the Web App shows each page in its tab and reloads it when `uiRev` changes.
395
+ ### HTTP
247
396
 
248
- ## Undoing, reverting, removing (撤销 / 还原 / 清掉界面)
397
+ HTTP, all under `/api/projects/:projectId/agents/:agentId/workbenches` (Project members only): `GET /` lists the workbenches with their `revision`, `uiRev`, `tabs` (each page's URL resolved) and current load `error`; `GET /:id/ui/*` serves a file of `ui/` (there is no default document — a tab names its page), or, for a `.js` with no such file, what the server emitted from the `.tsx` of that name; `GET /:id/sdk/ui/*` serves React, the components and their stylesheet to TSX pages, through the import map the server writes into them; any method on `/:id/api/*` reaches `handle` — JSON by default in both directions (`req.body` parsed, `{ status?, body? }` answered as JSON), and anything else when you say so: a non-JSON request body arrives as `req.bytes` (a `Uint8Array`; `req.headers` has its `content-type`, never the app's cookie), and a response that names a `content-type` in `headers` sends `body` as the string you wrote, or `bytes` for binary, or `stream` — an async iterable (an `async function*`) of strings or `Uint8Array`s, each chunk written to the client as you yield it, which is how server-sent events and a model's token-by-token answer get through without waiting for the end (relay an upstream stream by yielding its chunks; a `finally` in the generator runs when the client goes away — though a generator parked inside an `await` only gets there once that await settles, so give a relay its own timeout rather than trusting the disconnect) — with `location` + a 3xx status for a redirect. That is how a handler serves a page it renders, an upload, a download, or the pages of a program it runs on this machine: fetch `http://127.0.0.1:<port>/…` from the HANDLER and return what came back — never put `127.0.0.1` in a page, because the page runs in the user's browser, which may be on another machine than you are; `GET /:id/sdk/workbench.js` and `GET /:id/sdk/amsp.js` serve the page SDK (the `@prismshadow/amsp` browser build of the server answering, see *Follow the Agent live*); `POST /:id/reload`; `GET /:id/history` lists its versions, newest first and at most 50, each `{ revision, commit, savedAt }` — the commits of `agent_state.git` that changed its folder; `POST /:id/rollback { revision }` makes the source exactly that listed version (code only — `state.json` stays) and reloads, which records the restore as the newest version. `DELETE /:id` removes the folder, `state.json` included, and records the removal, so its earlier versions are no longer listed, even if the id comes back. `POST /archive { dataBase64, overwrite? }` imports one workbench's source from a zip and loads it, answering `201 { workbench }` with the load's `error` (an id that exists answers 409 `workbench_exists` unless `overwrite` is true, which replaces the source and keeps `state.json`; a zip holding `state.json`, a dot entry, `node_modules`, a link, or a name git refuses or Windows cannot hold is refused before anything is written), and `GET /:id/archive` downloads the source as a zip that imports back unchanged. From a page directly under `ui/`, call your handler with a relative `fetch("../api/…")` and import the page SDK with `import("../sdk/workbench.js")`; the Web App shows each page in its tab and reloads it when `uiRev` changes.
249
398
 
250
- When the user asks to undo the UI, revert it, clean it up or get the chat page back the way it was, they are asking you to TAKE SOMETHING AWAY — never to build something. Do not answer such a request by adding a feature (a reset button, an undo stack, a new route). Work out which of the four below they mean; if it is not obvious from what they said, ask in one line before touching anything. Everything about a workbench is files in your own Agent directory, so each of these is a file operation you make yourself — list `workbenches/` first to see what exists. The server notices within a moment and the user's tabs follow without a refresh.
399
+ ### Undoing, reverting, removing
251
400
 
252
- 1. *"Get rid of it" / "back to before there was any custom UI" / 回到没定义 UI 的状态* — remove the workbench entirely: delete the folder `workbenches/<id>/` **and** its recorded versions `workbenches-history/<id>/`. That is everything there is; the tabs disappear and nothing else of the Agent is touched. It cannot be undone, so say so in one line first, and never delete a workbench you were not asked to remove. (The user can do the same from the tab's bar: *Remove*, two clicks.)
253
- 2. *"Undo your last change" / "it was better before"* — go back to an earlier version of the CODE: the recorded versions are full copies under `workbenches-history/<id>/<revision>/` (`versions.json` lists them, newest first); copy that version's files over the folder and the server reloads it. The tab's bar offers the same as *History → Restore*.
401
+ When the user asks to undo the UI, revert it, clean it up or get the chat page back the way it was, they are asking you to TAKE SOMETHING AWAY — never to build something. Do not answer such a request by adding a feature (a reset button, an undo stack, a new route). Work out which of the four below they mean; if it is not obvious from what they said, ask in one line before touching anything. Everything about a workbench is files in your own Agent State, so each of these is a change to files, made by you or by the user in the app — list `agent_state/workbenches/` first to see what exists. The server notices within a moment and the user's tabs follow without a refresh.
402
+
403
+ 1. *"Get rid of it" / "back to before there was any custom UI" / 回到没定义 UI 的状态* — remove the workbench entirely: delete its folder `agent_state/workbenches/<id>/`. The tabs disappear and nothing else of the Agent is touched; its data (`state.json`) goes with the folder for good. Say so in one line first, and never delete a workbench you were not asked to remove. Leave `agent_state.git` alone: it holds the history of every workbench, not only this one. A folder deleted by hand keeps its listed history: a workbench made again under that id shows its old versions. The user's *Remove* (in the tab's bar or on the Agent settings Workbenches tab, two clicks) and `DELETE /:id` cut it, so a new one under that id starts clean.
404
+ 2. *"Undo your last change" / "it was better before"* — go back to an earlier version of the CODE. Ask the user to use *History → Restore* in the tab's bar or on the Agent settings Workbenches tab: it makes the folder exactly that version and the server reloads it; `POST /:id/rollback` with a `revision` from `GET /:id/history` does the same (see *HTTP*). With `git` installed you can also do it yourself: `git --git-dir=<App Data Dir>/agents/<agent_id>/agent_state.git log --oneline -- workbenches/<id>` lists the versions, newest first; `git --git-dir=<App Data Dir>/agents/<agent_id>/agent_state.git show <commit>:workbenches/<id>/<file>` prints one file as it was; and `git --git-dir=<App Data Dir>/agents/<agent_id>/agent_state.git --work-tree=<App Data Dir>/agents/<agent_id>/agent_state checkout <commit> -- workbenches/<id>` writes that version's files back, after which the server reloads it and records it as the newest version. Files added since that version stay, because git writes back only the files the version has: delete them yourself, or use the app's Restore, which is exact.
254
405
  3. *"Remove that tab" / "I only want the first page"* — delete its entry under `WebModule.sessionTabs` in `package.json` (and its page under `ui/` if nothing else uses it). With `"contributes": {}` the workbench keeps its server code and has no UI at all.
255
406
  4. *"Bring back the data"* — you cannot: `state.json` is never part of a version (restoring code leaves the data as it is) and it has no history of its own. Say so plainly rather than inventing a recovery.
256
407
 
@@ -258,12 +409,132 @@ One constraint follows from 4, and it is a constraint on you, not a task to go a
258
409
 
259
410
  Your handler's responses are served from the app's own origin, so anything you echo back from a request is executed there: escape what you put into HTML, and treat a value that came in over `/api/*` as untrusted even though only Project members can reach it.
260
411
 
261
- ## Theme
412
+ ### Filling the app
262
413
 
263
- A workbench page is a separate document, so it inherits nothing from the app's stylesheet by itself. The Web App stamps the app's look onto the page's root on every load and every appearance change: `light`/`dark`, `data-theme` (`modern`, `geek` or `github`), `data-accent` (only when the theme paints that accent), `data-font-latin` and `data-font-cjk`, the root font size, every `--ui-*` token of the app's token contract resolved as an inline style, and the app's bundled fonts. It injects `/workbench-ui.css` first in the head: a base stylesheet that styles plain HTML (headings, lists, forms, tables, code) to match the app and exposes `--wb-bg`, `--wb-surface`, `--wb-fg`, `--wb-muted`, `--wb-border`, `--wb-hover`, `--wb-accent`, `--wb-accent-fg`, `--wb-radius` (a box radius, not a pill), `--wb-font`, `--wb-mono`, the tone colours `--wb-tone-<tone>-fg`, `-bg` and `-line`, plus the classes `wb-primary` (a button), `wb-card`, `wb-rows`, `wb-row`, `wb-muted` and `wb-badge`, a status pill coloured by `data-tone` (`neutral` without one). Pick the tone the way the app does: there is no busy tone, so a running item is `success` with the word "Running", waiting or queued is `attention`, failed is `danger`, and finished is `done` or `neutral`, e.g. `<span class="wb-badge" data-tone="done">Resolved</span>`. Write plain markup, take every colour and font from those variables, and the page follows the user through every theme, accent, font and light/dark change; hardcode them and it clashes in one theme or another. The `--wb-*` names are only ever added to, never renamed. The `--ui-*` tokens underneath are readable too, but they follow the app's token contract and can be renamed with it, and as inline styles on the root no stylesheet of yours overrides them: to restyle, redeclare `--wb-*` on `:root`. The page's own rules always win over `/workbench-ui.css`, and linking `/workbench-ui.css` yourself makes it look right when opened outside the app too.
414
+ A page can be shown as the whole app — no sidebar, no chat, no tab strip — at `/app/<project>/<agent>/<workbench>[/<tab key>]` (the workbench's first tab when no key is given): the tab's *Fill the app* button goes there, `penguin web --app <project>/<agent>/<workbench>[/<tab key>]` opens the browser straight onto it, and the page itself can ask with `parent.postMessage({ type: "penguin:fill-app" }, "*")`. The floating *Exit full screen* button returns to the same Agent and workbench tab. The command palette also offers *Exit full page*. Its chord is Ctrl+Alt+P (⌥⌘P on macOS) unless the user rebound it under Settings › Keyboard shortcuts. A key pressed inside the page reaches the app only when the page has not handled it, so a page must not intercept that chord.
264
415
 
265
- Keep empty alerts hidden. A component rule such as `.notice { display: flex }` overrides the browser's default `[hidden]` styling; the shared stylesheet preserves `[hidden]`, and standalone custom CSS should do the same. Check both empty and populated states.
416
+ ### The App Center
266
417
 
267
- ## Filling the app
418
+ The App Center (`/apps` in the sidebar) is the Project's home screen: a grid of tiles, each a workbench's icon and name, that open the workbench in a window over the grid (or full screen from the tile's menu). The user arranges the tiles and folders themselves. A workbench is on it when its `package.json` says so, beside `penguin.version` and `penguin.modules`:
268
419
 
269
- A page can be shown as the whole app — no sidebar, no chat, no tab strip — at `/app/<project>/<agent>/<workbench>[/<tab key>]` (the workbench's first tab when no key is given): the tab's *Fill the app* button goes there, `penguin web --app <project>/<agent>/<workbench>[/<tab key>]` opens the browser straight onto it, and the page itself can ask with `parent.postMessage({ type: "penguin:fill-app" }, "*")`. The floating *Exit full screen* button returns to the same Agent and workbench tab. The command palette also offers *Exit full page*. Its chord is Ctrl+Alt+P (⌥⌘P on macOS) unless the user rebound it under Settings › Keyboard shortcuts. A key pressed inside the page reaches the app only when the page has not handled it, so a page must not intercept that chord.
420
+ ```json
421
+ "penguin": {
422
+ "appCenter": { "show": true, "title": "Tickets", "titleZh": "工单", "icon": "ui/icon.svg", "tab": "main" },
423
+ "modules": [ … ]
424
+ }
425
+ ```
426
+
427
+ - `show` is required when `appCenter` is there; `false`, or no `appCenter`, keeps the workbench off the App Center.
428
+ - `title` and `titleZh` are optional, at most 60 characters each; without them the shortcut takes the first tab's titles, then the package name.
429
+ - `icon` is optional: an SVG, PNG, JPEG, WebP, GIF or AVIF file under `ui/`, at most 256 KB, shown at 56 px as an image (never put into the page as markup). The server checks the file's bytes, so its extension must match what it is (`.jpg` or `.jpeg` for JPEG); an SVG must be plain (no script, animation, event handlers, links or external references). An SVG whose every paint is `currentColor` or `none` is drawn in the text colour; any other icon is drawn as itself, so a tile reads best as a filled rounded square with the glyph on it in its own colours. Without one the tile is a coloured letter.
430
+ - `tab` is optional: the key of the tab the shortcut opens; the first tab without it.
431
+
432
+ When you build a workbench for the user, set `"appCenter": { "show": true }` unless they say otherwise, so they find it again. While the server is loading your files the tile shows a building ring and does not open; a failed load leaves it marked, and its menu shows the error from `.build/status.json`. A declaration that does not hold up does not stop the load: the workbench loads, has no shortcut, and `.build/status.json` lists the fix in `hints`. The user turns the shortcut on or off with the switch on the workbench's row in Agent settings, which rewrites `penguin.appCenter.show` in this file and records a version; read the file before editing it again. The App Center lists the Agents of the server it runs on, so a workbench of an Agent on a connected machine opens from that Agent's settings instead.
433
+
434
+ ## Data and storage
435
+
436
+ Keep each kind of thing where it belongs:
437
+
438
+ | Kind | Where it lives | What belongs here |
439
+ | --- | --- | --- |
440
+ | Secrets | Agent Vault (`penguin config vault`) | API keys, tokens and credentials — never in config files or data folders |
441
+ | Configuration | `PluginConfig` / `PluginConfigProvider.groups` | Text key-value pairs and structured settings |
442
+ | A workbench's small state | `host.getState()` / `host.setState()` (`state.json`) | Session ids, metadata, what the page last showed |
443
+ | A workbench's files | `host.dataPaths().dataDir`, through `node:fs` | Documents the user edits and the Agent changes, uploads, media, exports — never code |
444
+ | A workbench's cache | `host.dataPaths().cacheDir` | What can be made again: thumbnails, intermediate renders |
445
+ | A workbench's runtime files | `host.dataPaths().stateDir` | Unix sockets, pipes, locks |
446
+ | What every copy of an app shares | `host.dataPaths("server")` or `("machine")` | A model's weights, a tool's binaries, a small local server — never anything one Project must not see |
447
+
448
+ ### Adding configuration
449
+
450
+ Use PenguinHarness's built-in configuration mechanism rather than writing standalone config files to the filesystem, unless an external tool requires its own file format:
451
+
452
+ - **Plugin settings.** Contribute a settings group schema to `PluginConfigProvider.groups` (`string`, `secret`, `boolean`, `number`, `enum`, `list` or `table` fields) so the **Settings › Plugins** page renders and validates it; read values and watch live edits through `PluginConfig` (`get(group)` and `watch(group, cb)`).
453
+ - **Secrets.** Store per-agent secrets in the Agent Vault (`penguin config vault set --key <NAME> --value <value> --agent-id <id>`), which injects them into shell subprocesses as environment variables.
454
+
455
+ ### A workbench's folders
456
+
457
+ `host.dataPaths(level?)` returns three folders of the workbench's own, outside its source folder and made by the time it returns. The handler runs in the server process with Node's modules typed for it, so it reads and writes them with `node:fs` like any Node program and serves what its page needs from its own routes; the host has no file API. The Agent edits the same files with its own file tools, so a document the user edits in the page and asks the Agent to change is one file on disk:
458
+
459
+ ```ts
460
+ import { readFile, rename, stat, writeFile } from "node:fs/promises";
461
+ import path from "node:path";
462
+
463
+ const { dataDir } = host.dataPaths();
464
+ const deck = path.join(dataDir, "deck.json");
465
+ // A route of your own: the page PUTs the deck, written whole (a temporary name, then rename).
466
+ await writeFile(`${deck}.tmp`, JSON.stringify(body));
467
+ await rename(`${deck}.tmp`, deck);
468
+ // Asking the Agent to edit it: name the path in the run's text.
469
+ await host.run(sessionId, [{ text: `${request}\n\nDeck file: ${deck}` }]);
470
+ // Noticing the Agent's write: compare mtimeMs and size on a timer while a page is open.
471
+ const { mtimeMs, size } = await stat(deck);
472
+ ```
473
+
474
+ - `dataDir`: files kept for good. `cacheDir`: what can be made again, never exported. `stateDir`: runtime-only files — Unix sockets, pipes, locks — never exported. A Unix socket path holds at most 103 bytes (macOS's limit; Linux allows 108), so listen on `host.socketPath("dev.sock", level?)`, which throws naming the limit when the path would be longer. On Windows it answers a named pipe, `\\.\pipe\penguin-…-dev.sock`, which is no file on disk: `net.createServer().listen(host.socketPath(…))` works on every platform. The state folder survives a restart, so unlink a stale socket before listening.
475
+ - **Choose the level by who shares the files.**
476
+ - `"agent"` (the default) is this Agent's copy of the app: `<agent>/app/{data,cache}/<id>/`. The Agent edits these files with its own file tools, even in a sandbox. The Agent export carries `dataDir` only with **With their data**, and removing the workbench removes all three folders. The user's documents go here, and nothing private goes anywhere else.
477
+ - `"server"` is every copy of the same app on this server, across its Projects and Agents: a TTS model's weights, a local language model. It lives under the data root's `app/`.
478
+ - `"machine"` is every PenguinHarness on this computer for this OS user (the installed app and a dev instance alike): a minimal server one computer runs once. It lives under `~/.penguin/machine/`. Other OS users never share it: anything they need is a system package an administrator installs.
479
+ - The two shared levels are never exported and never removed with a workbench; a user clears them by hand. Only an app installed from a plugin has them, since the plugin's name is what makes two copies one app; a workbench made in place gets an error and keeps to the agent level.
480
+ - Only the handler writes the shared levels. The Agent's sandboxed commands may read them but not write them, so a download step or a long-running process for them runs from the handler: `fetch`, or a child process it spawns. Anything written there is seen by every Project's copy of the app, so store only what is the same for everyone.
481
+ - A write in these folders reloads nothing and records no version; restoring a version or updating the plugin leaves them alone. Removing the workbench, or uninstalling its plugin, removes its agent-level folders: say so before a removal that would discard documents the user made.
482
+ - Under a `workspace-write` sandbox the Agent's commands can write the agent-level folders. So the handler never follows a link the Agent may have left: `lstat` a path before reading or writing through it, and refuse a link or a path that leaves the folder. The host itself refuses a link where one of the folders belongs.
483
+ - The handler names every path it gives the Agent. Never have the Agent work a path out from its `# Environment` block, and never put code in these folders.
484
+
485
+ ## Test a plugin
486
+
487
+ ### Unit testing using vitest
488
+
489
+ Unit tests live under `test/*.test.ts` in the plugin package and run with `vitest run` (`"test": "vitest run"` in `package.json`), without starting a server or a desktop shell.
490
+
491
+ - **Declarations and shipped files.** Rebuild `ifaces.json` first (`penguin-gen-ifaces`), then check what the package declares: pass each skill directory under `skills/` to `validateSkillDir(dir)` from `@prismshadow/skills` (it validates `SKILL.md` frontmatter and body and returns `[]` on success), and pass the package directory to `readLibraryPackage(dir)` from `@prismshadow/penguin-core` to run the same checks the plugin library runs on load (version, `ifaces.json`, card fields, icon bytes, hook manifest and MCP declarations).
492
+ - **Module logic.** Import your module functions directly and test command arguments, profile builders, parsers and failure paths with injected probes or mocked child processes so the suite runs deterministically on any host.
493
+
494
+ ### E2E testing using electron
495
+
496
+ End-to-end tests drive a real PenguinHarness desktop shell over Playwright's Electron channel (`_electron.launch`, wrapped by `@penguinharness/penguin-testing-electron`) so UI contributions and registered capabilities are verified in an actual window instead of a mock:
497
+
498
+ 1. **Prepare an isolated instance.** Point `PENGUIN_HOME` and `PENGUIN_BROWSER_DATA_DIR` at a persistent path under the repository root — `<repo>/.data/penguin-testing-electron/penguin` and `<repo>/.data/penguin-testing-electron/chrome` (add `.data/` to `.gitignore`) — and seed project config and credentials from the current harness so the shell boots without interactive prompts and nothing of the user's own data root is touched.
499
+ 2. **Launch the shell and take the window.** Start Electron on the desktop entry with `_electron.launch` (or `launchHarness()` from the testing driver) and await `app.firstWindow()`, which returns a standard Playwright `Page`.
500
+ 3. **Install, assert, and clean up.** Link or install the plugin under test into the running instance, assert the rendered UI and behavior with Playwright locators and `expect` (or run the plugin's `@Component()` `TestUnit` declarations in the shell), then remove the plugin and close `app` in `finally` so the instance returns to a clean state. On Linux, run headless under Xvfb and skip cleanly (`describe.skipIf`) when no display is available.
501
+
502
+ ### Integration testing using a separate penguin instance
503
+
504
+ A workbench is tested against the host it runs in (the check helper above). A plugin package you are building is tested the same way every deployment will see it: loaded by a real server through the plugin prefix. Run that against a **separate instance**, never against the user's own data root:
505
+
506
+ 1. Start an isolated instance with its own data root, on a free port. Pick a path to keep using, not the user's data root and not a temporary directory — a `.data/` directory inside the repository you are building the plugin in, for example `.data/penguin-plugin` (add it to `.gitignore`). The install cache, the linked plugins and the instance's own state are worth keeping across rounds of testing, and a directory the system may clean loses them:
507
+ ```bash
508
+ PENGUIN_HOME=<repo>/.data/penguin-plugin penguin server --port 7365
509
+ ```
510
+ `PENGUIN_HOME` moves the whole data root (`~/.penguin/data` by default) — a fresh one has no Project, no agents and no server yet, so nothing of the user's is touched. The first boot prints the first-login link; `penguin auth login --server http://127.0.0.1:7365 --user-id admin` signs in and sets a password. Between test rounds, stop the server with `penguin server stop --root <repo>/.data/penguin-plugin` (or Ctrl+C the supervisor) and start it again on the same `PENGUIN_HOME`: the linked plugins and everything the instance recorded are still there.
511
+ 2. Link the package into that instance's plugin prefix — no publishing, no copying; the directory stays where you are editing it:
512
+ ```bash
513
+ PENGUIN_HOME=<repo>/.data/penguin-plugin penguin plugin link /path/to/your-plugin
514
+ ```
515
+ The command reads the directory as a plugin package first (a `package.json`, a buildable `ifaces.json`, contributions that pass the library's checks — the same read an install goes through) and refuses in place with the reason if it is not one. A link is a symlink into `<PENGUIN_HOME>/plugins/node_modules/`; the loader follows it to the real directory, so the loaded plugin is the files you are editing. It does not run the package's install scripts; dependencies you need are yours to install in the package directory.
516
+ 3. List the plugin where a Project can load it: on the Web App's **Plugins** page of that instance (install it on an agent from the library, or add it to the Project when the package carries server modules), or through `penguin plugin list --server http://127.0.0.1:7365`. A Project change re-assembles the App without a restart; the **Plugins** page row shows the version read from your directory, and a link row is marked as linked.
517
+ 4. Exercise the capability for real, then edit and reload: the Skills and hooks a package contributes install on an agent — start a chat and check the behavior; the server modules it lists load with the next App — check the row's status and the server log. After an edit, rebuild the package's `ifaces.json` if its declaration changed (`penguin-gen-ifaces` as its `build` script does), then reinstall or re-list so the copy is refreshed; the page reads the new version straight from the directory. `penguin plugin remove <name>` removes the link and its record and leaves your directory untouched.
518
+
519
+ ## Sharing a plugin
520
+
521
+ The package is the same whatever way you share it: an npm package whose `package.json` carries npm's own fields only, whose entry declares its card, Skills, hook package, MCP servers and workbenches, whose default export may list the server modules it adds, and whose build writes that declaration into `ifaces.json` — the table every reader reads instead of running the package. Build and test it (*Test a plugin* above) before sharing.
522
+
523
+ Where plugins come from — four sources, four rules, which are also the four places a plugin you built can go:
524
+
525
+ 1. **The harness's own modules** are not yours to list or submit: they live in the main packages today and are being regrouped into per-function modules (the open pull request Prism-Shadow/penguin-harness#1550), and they will land in the repository's plugin library directory — they are part of PenguinHarness itself, not someone else's package. Yours is not one of these unless you are building the harness.
526
+ 2. **Built-in plugins** ship with the repository under `plugins/` — one npm package per plugin, listed by category in the built-in library. Installing one fetches it from npm or its repository; the desktop app packs its own set of them into the bundle. A plugin built around someone else's product carries a `use-` prefix (`use-firecrawl`), and a self-evolution toolkit's name ends in `-rsi-toolkit`.
527
+ 3. **Third-party plugins** are collected into the plugin index — one entry per pull request, under that repository's submission protocol (CONTRIBUTING.md is the authority; the steps are below). The server merges the index with its built-in list on the **Plugins** page; an entry is for discovery only, and the package still installs from the channel the entry names.
528
+ 4. **Your own or unlisted plugins** need no index at all: link a local directory into the server's plugin prefix with `penguin plugin link` — the directory stays where it is, referenced in place, loaded through the same path as an installed plugin (see *Integration testing using a separate penguin instance* above for the mechanics); for a published package, install it by npm name.
529
+
530
+ **Listing in the index** (for anyone besides you) — the protocol's authority is the index repository's [CONTRIBUTING.md](https://github.com/Prism-Shadow/penguin-harness-plugins/blob/main/CONTRIBUTING.md); these steps drive it and do not restate its rules, and when they disagree, it wins:
531
+
532
+ 1. **Check one channel exists.** The entry needs at least one source the harness can fetch the tarball from: npm, or a `[[channels]]` table pointing at a GitHub release (or any tarball URL), per the index repository's `docs/manifest.md`. CI fetches each URL and checks the bytes hash to the entry's `integrity`; publish exactly those bytes. Entry-side facts (ESM, a loadable entry with an `activate` export, a license) are CI's to check — you fix what CI reports.
533
+ 2. **Let the tooling write the entry.** In a checkout of the index repository, run `pnpm install && pnpm new-entry <name>@<version>` for an npm channel. For a channels-only entry, write the `manifest.toml` yourself following `docs/manifest.md` (no `package-lock.json`). Never edit `integrity`.
534
+ 3. **Fill in `categories`** (1–3, from the index repository's `docs/categories.md`) **and `owners`** — the GitHub handles allowed to change this entry later, including yours. Everything else the tooling wrote; leave it.
535
+ 4. **Run `pnpm validate && pnpm check-npm`** and fix what they report. Nothing here executes a submission's code.
536
+ 5. **Open one pull request with exactly one entry** and stop there — review is human, CI decides the mechanical questions.
537
+
538
+ Later: a new version is a new entry beside the old ones; moving is not possible — the path is its name, version and content; yanking and ownership transfers are in CONTRIBUTING.md. Changing this skill's sharing sections means keeping them in step with CONTRIBUTING.md — one change carries both.
539
+
540
+ **The other three ways** need no pull request: add it to the repository's `plugins/` tree if it should ship with PenguinHarness (a proposal and a review, like any change to the repository); or leave it local and `penguin plugin link` it on the machines that need it; publish to npm (any name, your own scope included) for an installable-by-name release.
@@ -0,0 +1,24 @@
1
+ # Document editors and AI conversations
2
+
3
+ ## Opening and saving documents
4
+
5
+ Open a document app on its recent files. Each entry shows the title once and opens that document in its editor. Put creation beside the list. When AI can create a document, expose its prompt on the start page, including when the list is empty.
6
+
7
+ In the editor, give the title and save status room to read as text. Keep the action people need while working within reach, such as **Present** for a slide deck. Put occasional commands such as New, Import, Export and Version history in a **File** menu. Name both the action and the format. A deck might offer **Import Bento HTML (.html)**, **Download Bento HTML (.html)** and **Export to PowerPoint (.pptx)**. Show whether the AI pane is open on the control that toggles it.
8
+
9
+ Route the Save command and Ctrl+S / Cmd+S through one save operation. Keyboard events in a nested editor frame stay in that frame. Handle the shortcut where focus lives, call `preventDefault()` there, and pass the active editor's latest contents to the workbench. If the editor uses a message bridge, associate the reply with the frame and document that requested it. Keep unsaved edits on failure and offer Retry. Mark a revision saved only after the host confirms it. Edits made during that save still count as unsaved.
10
+
11
+ ## Chat inside a workbench
12
+
13
+ Keep the Session ID with the document or conversation. Reopen the same Session for follow-ups and history. Use the Project's available chat models and the shared `ModelSelect` from `@prismshadow/penguin-ui`, paired with the host's picker when available. Show the current model, starting with the Session's effective default. Carry the pair `{ provider, modelId }` through the selection. Model IDs can repeat across providers. Read choices through the signed-in host and keep credentials on the server.
14
+
15
+ Apply a choice to this Session. On a running Session, keep the draft and tell the user when switching is available. For an existing Session the page SDK can call `transport.post("/sessions/" + encodeURIComponent(sessionId) + "/switch-model", { provider, modelId })`. A `202` starts the switch. Wait for the Session to become idle and check its actual provider and model before sending the next turn. On refusal or interruption, show the reason and keep the previous selection. A choice in one document leaves another document's Session and the Project default intact.
16
+
17
+ Put a single activity row directly below the user message that started the turn. Update it as the Agent thinks, reads a file or runs a command. Expanding the row reveals the steps in order, including tool names, descriptions, file paths and results when present. Keep a pending approval or recoverable error actionable there. Preserve the final status and assistant answer when the turn ends. Rebuild that turn from its Session on reopen. The [AMSP example](../SKILL.md#follow-the-agent-live-amsp) covers history, live events and stopping the run.
18
+
19
+ ## Try it in the app
20
+
21
+ - Try the task you used for comparison with a saved item, then repeat it at phone width. For a presentation app inspired by PowerPoint, preview the slides in a template, create a deck, change a slide and its speaker notes, save and reopen to check both changes. For a reading app, find a book on the shelf, read to a particular paragraph, then reopen it to check the resume position.
22
+ - Edit inside the embedded editor, press the platform save shortcut and immediately reopen the file. Check the exact last edit. Interrupt a save and retry. Import a supported file and open each exported format in its intended reader.
23
+ - With two documents and two configured chat models, send a first message, switch models in one document and send a follow-up. Verify the provider and model on the actual request. Reopen both documents and check the first conversation's history and the second document's model.
24
+ - Switch the app between English and Chinese with a menu or chat pane open. Check labels, errors and save status in both languages. At phone width, open the file menu, use the picker and expand a tool step with a long path. Check that each action remains reachable by touch and keyboard and the active theme keeps text and focus visible.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: penguin-sdk
3
3
  description: Use to build a standalone external program with an agent in it, or connect an external program to a Penguin agent. For an app inside PenguinHarness with its own Agent and workbench tab, use agent-initialization and penguin-plugin directly; no SDK/API question applies. A program reaches an agent in one of two ways, and the skill asks the user which before building — embedded with the Penguin Harness SDK (`@prismshadow/penguin-core`, no server), or over the Penguin server's Agent API (AMSP, with the `@prismshadow/amsp` client or curl). This is writing application code, not configuring an Agent State inside PenguinHarness. Covers self-contained projects, the createSession/run streaming loop with thinking and image messages, wiring the user's existing tools in as CLI commands, a complete RAG recipe that ingests documents into a knowledge base and answers with citations behind a web UI, and the Agent API client. Workbenches — the tabs and pages beside the chat that an Agent keeps for itself inside PenguinHarness — are the penguin-plugin skill's.
4
- version: 2026.10.26.1
4
+ version: 2026.11.20.1
5
5
  ---
6
6
 
7
7
  # Penguin Harness SDK and Agent API
@@ -78,7 +78,7 @@ Each path also needs one thing only the user can provide: a model credential on
78
78
 
79
79
  `@prismshadow/penguin-core` is the TypeScript SDK this agent itself runs on. Use it to build your own AI apps:
80
80
 
81
- - An **Agent** loads its state (prompts, tools, skills) from `<root>/<project_id>/agents/<agent_id>/`. Creating an Agent whose directory is empty initializes it with defaults.
81
+ - An **Agent** loads its state (prompts, tools, skills) from `<root>/projects/<project_id>/agents/<agent_id>/`. Creating an Agent whose directory is empty initializes it with defaults.
82
82
  - A **Session** is one conversation of an Agent inside a **Workspace** directory.
83
83
  - `session.run()` executes one task and streams every step (thinking, text, tool calls) as AMSP records.
84
84