@penguinharness/agent-development 0.2.13 → 0.2.15

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/package.json CHANGED
@@ -1,7 +1,12 @@
1
1
  {
2
2
  "name": "@penguinharness/agent-development",
3
- "version": "0.2.13",
4
- "description": "Agent development on PenguinHarness: build on the SDK, call any model through one unified LLM API, manage models and secrets, and orchestrate agents, sessions, costs and schedules.",
3
+ "version": "0.2.15",
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 workflows (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
+ "keywords": [
6
+ "penguin-plugin",
7
+ "penguinharness",
8
+ "skills"
9
+ ],
5
10
  "license": "Apache-2.0",
6
11
  "repository": {
7
12
  "type": "git",
@@ -9,7 +14,6 @@
9
14
  "directory": "plugins/agent-development"
10
15
  },
11
16
  "files": [
12
- "plugin.json",
13
17
  "icon.svg",
14
18
  "skills",
15
19
  "hooks",
@@ -17,5 +21,19 @@
17
21
  ],
18
22
  "publishConfig": {
19
23
  "access": "public"
24
+ },
25
+ "penguin": {
26
+ "description_zh": "基于 PenguinHarness 的智能体开发:依据需求初始化智能体、用 SDK 构建应用或经 Agent API 接入智能体、搭建 Workflow(智能体自己维护的、对话旁的页面)、经统一的 LLM API 调用任意模型、管理模型与密钥、编排智能体/会话/成本/定时任务。",
27
+ "short_description": "Agent setup, SDK, Agent API, workflows, LLM API, config and orchestration.",
28
+ "short_description_zh": "智能体初始化、SDK、Agent API、Workflow、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
+ }
20
38
  }
21
39
  }
@@ -0,0 +1,182 @@
1
+ ---
2
+ name: agent-initialization
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 that a program will use, the penguin-sdk skill first settles how the program reaches it.
4
+ version: 2026.10.12.1
5
+ ---
6
+
7
+ # Agent Initialization
8
+
9
+ This skill initializes an agent's settings from a user requirement — plain files in the target agent's directory. It is also the reference for giving an agent, yourself included, a new Skill or a new hook: both are directories you write, and the harness picks them up from disk.
10
+
11
+ ## Before you start
12
+
13
+ If the user's message only invokes this skill (e.g. "use agent-initialization skill") without a concrete requirement, ask the user what agent they want and what it should do. But when the requirement is already concrete — even a single sentence like "an expert that answers questions about X" — do **not** ask follow-up questions: derive the role and rules from that sentence, apply the defaults below, and list your assumptions in the final reply.
14
+
15
+ One question comes first even then: when the agent is for a program to use, how the program reaches it is settled before you create anything (see *An agent for a program*).
16
+
17
+ ## An agent for a program
18
+
19
+ A program — an app, a service, a bot, a script — reaches a Penguin agent either embedded with the SDK or through the Penguin server's Agent API, and the two put the agent in different places. That choice is the penguin-sdk skill's, in this same plugin: whenever the requested agent is for a program, follow its *Ask which way first* before you create anything. An agent that people talk to, in the Web App, the CLI or a Remote-control bot, is not for a program and needs no question. Then:
20
+
21
+ - **SDK:** no Agent is created in this Project. Build the program with the penguin-sdk skill, and apply this skill to the program's embedded agent (see *The embedded agent of an SDK app*).
22
+ - **API:** create or configure the Agent here with the rest of this skill. Its API access and keys are the owner's to turn on, never yours; the penguin-sdk skill's *The API path* and its `reference/agent-api.md` have the rules and the steps to hand the user.
23
+
24
+ ## Resolve the inherited runtime
25
+
26
+ Treat the current Agent as the **Builder**. Resolve the runtime before creating a new Agent:
27
+
28
+ - `provider` and `model_id` are one complete pair. If the user explicitly supplies both, use that pair. If the user supplies neither, inherit the current Builder Session's `Provider` and `Model ID` from the Environment. Reject a half pair.
29
+ - `thinking_level` is independent. If the user explicitly supplies it, use that value. Otherwise read `model.thinking_level` from the Builder's own `agent_state/system_config.yaml`; when the field is absent, use the normal Agent-config default `medium`.
30
+
31
+ Write the resolved `thinking_level` into a brand-new target Agent's `model.thinking_level`, preserving all other copied `model` fields. Penguin does not persist `provider` or `model_id` in Agent State, so never add either field to `system_config.yaml`. When the same request continues into Benchmark design, carry the resolved model pair forward explicitly so evaluation uses the Builder runtime instead of a Project default. When configuring an existing Agent, change `model.thinking_level` only when the user explicitly requests that runtime change.
32
+
33
+ ## Locate the target agent
34
+
35
+ All agents of this project live side by side under `agents/` in the App Data Dir:
36
+
37
+ ```bash
38
+ APP_DATA_DIR="<app_data_dir>" # the App Data Dir value from your Environment section
39
+ ls "$APP_DATA_DIR/agents" # existing agents (each is a folder here)
40
+ TARGET="$APP_DATA_DIR/agents/<agent_id>" # the agent to configure
41
+ ```
42
+
43
+ An agent directory contains `agent_state/` (`system_config.yaml`, `AGENTS.md`, `skills/`, `hooks/`, `memory/`, `tools/`) plus `scratchpad/` — and `traces/`, which appears once the agent has run at least once. `hooks/` exists once a hook package is installed; create it when you need it.
44
+
45
+ To extend the agent you are running as, the target is your own directory: `<app_data_dir>/agents/<agent_id>` with the Agent ID from your Environment section.
46
+
47
+ ## Write AGENTS.md
48
+
49
+ `agent_state/AGENTS.md` is injected into the agent's system prompt — it is where the user requirement becomes behavior. Keep `system_config.yaml`'s `system_prompt` untouched (that is the stable system layer); put everything requirement-specific in AGENTS.md:
50
+
51
+ - Role — what the agent is for, in one or two sentences.
52
+ - Domain guidance — the concrete rules, steps and constraints derived from the user requirement.
53
+
54
+ Be concise: AGENTS.md is prompt context, not documentation. For a domain expert that answers from a knowledge base, a good AGENTS.md is a few lines: the role sentence, "answer strictly from the provided context blocks", citation rules ("cite blocks inline as [1][2]"), a refusal rule for questions the context cannot answer, and "answer in the language of the question".
55
+
56
+ ## Skills
57
+
58
+ A Skill is a directory `agent_state/skills/<skill_name>/` containing a `SKILL.md`. The directory name is the Skill's name (letters, digits, `_`, `-`); nothing else registers it.
59
+
60
+ ```md
61
+ ---
62
+ name: <skill_name>
63
+ description: <one line: what it does and when to use it>
64
+ version: <YYYY.MM.DD.N, e.g. 2026.09.29.1 - today's date, N counts that day's changes>
65
+ ---
66
+
67
+ <skill_instructions>
68
+ ```
69
+
70
+ The `description` line is what the target agent sees in its system prompt, so it has to say when the Skill applies; the body is read only once the agent decides to use it. Optional `short_description` and `short_description_zh` lines give the UI a short blurb. Files the body refers to go beside it (`reference/<topic>.md`, scripts), linked by relative path.
71
+
72
+ There are three ways to get one in place:
73
+
74
+ - **Create.** Write the directory yourself. Keep the body to what a capable agent would not already know: the steps, the commands, the traps.
75
+ - **Install from the library.** Copy the whole `skills/<skill_name>/` directory from an agent that has it — `default_agent` ships the whole library. The user can also install from the Web App's Plugins page.
76
+ - **Import.** Fetch a Skill from a URL, a repository or a local path (`curl`, `git clone`, `unzip`), then place it under `skills/`. A Skill written for another tool usually needs only the frontmatter above. Read everything you fetched in full before installing, and tell the user what it does: a Skill becomes instructions the agent follows in every future session.
77
+
78
+ Do not register Skills in AGENTS.md; the frontmatter is injected automatically.
79
+
80
+ Common library bundles, so you don't under-equip the target:
81
+
82
+ - **App builder** (builds apps or web frontends): `penguin-sdk`, `web-design`, `unified-llm-api`.
83
+ - **Knowledge expert** (answers questions over a document set): usually a RAG app built with the penguin-sdk skill rather than a harness agent alone (see *An agent for a program*).
84
+ - **Evaluation loop**: `benchmark-design` and `agent-evaluation` (the `agent-evaluation` plugin), `agent-optimization` (the `default-rsi-toolkit` plugin).
85
+
86
+ When creating a Test Agent, install only the capabilities it needs to solve ordinary tasks.
87
+
88
+ ## Hook packages
89
+
90
+ A hook is a script the harness itself runs at a fixed point of the agent loop. Use one when something must happen every time, whether or not the model remembers: adding context to every prompt, vetting a tool call, deciding that a finished task should continue. A rule the model can simply follow belongs in AGENTS.md or a Skill instead.
91
+
92
+ A hook package is a directory `agent_state/hooks/<package_name>/` holding a `hooks.json` and the scripts it names:
93
+
94
+ ```json
95
+ {
96
+ "name": "append-time",
97
+ "description": "Adds the current local time to every prompt.",
98
+ "description_zh": "为每条 Prompt 附上当前本地时间。",
99
+ "version": "2026.09.29.1",
100
+ "user_prompt": [{ "command": "time.mjs", "timeout": 10 }]
101
+ }
102
+ ```
103
+
104
+ ```js
105
+ // time.mjs - answers every prompt with the current local time.
106
+ const now = new Date();
107
+ const pad = (n) => String(n).padStart(2, "0");
108
+ const offset = -now.getTimezoneOffset();
109
+ const stamp =
110
+ `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ` +
111
+ `${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`;
112
+ const utc = `UTC${offset < 0 ? "-" : "+"}${pad(Math.floor(Math.abs(offset) / 60))}:${pad(Math.abs(offset) % 60)}`;
113
+ const zone = Intl.DateTimeFormat().resolvedOptions().timeZone;
114
+ process.stdout.write(`${JSON.stringify({ context: `Current time: ${stamp} ${zone} (${utc})` })}\n`);
115
+ ```
116
+
117
+ The three hook points, one command list each in `hooks.json` (leave out the ones you do not use):
118
+
119
+ | Key | Runs | The script answers |
120
+ | --- | --- | --- |
121
+ | `user_prompt` | Every time the user submits a prompt | `{ "context": "<text>" }` — sent to the model right behind the user's message |
122
+ | `pre_tool_use` | Before each tool call is approved | `{ "decision": "allow" \| "deny", "reason": "<one line>" }` |
123
+ | `stop` | After every task ends | `{ "decision": "continue", "input": "<next user message>" }` to keep going, or `{ "decision": "stop" }` |
124
+
125
+ Every script is plain Node (`.mjs`, builtin modules only), run as `node <script>` with the package directory as its working directory. It receives one JSON object on stdin and prints one JSON object on stdout; printing nothing means no opinion. A non-zero exit, output that is not JSON, or running past `timeout` seconds (default 60) counts as a failure: it is recorded and ignored, and never stops the run. The full contract — every stdin field, the remaining answer fields, `trigger`, and how to convert another tool's hooks — is in [`reference/hooks.md`](reference/hooks.md); read it before writing a `pre_tool_use` or `stop` hook.
126
+
127
+ The same three ways apply:
128
+
129
+ - **Create.** Write the directory. Give `user_prompt` and `pre_tool_use` commands a small `timeout`: they run on the hot path.
130
+ - **Install from the library.** Copy the whole `hooks/<package_name>/` directory from an agent that has it, or have the user install the plugin from the Web App's Plugins page.
131
+ - **Import.** Fetch the source, read every script in full and review it for anything that exfiltrates data, touches files outside its purpose or runs unknown commands, then convert it to the layout above. Another tool's hook configuration (the `hooks` block of a Claude Code `settings.json`, for instance) maps point by point; `reference/hooks.md` has the table.
132
+
133
+ Test a script by hand before you rely on it — feed it the input it will get and check the exit code and the output:
134
+
135
+ ```bash
136
+ cd "$TARGET/agent_state/hooks/append-time"
137
+ echo '{"hook":"user_prompt","session_id":"test","scratchpad_dir":"/tmp","prompt":"hello"}' | node time.mjs; echo "exit $?"
138
+ ```
139
+
140
+ A hook runs on the user's machine, on every prompt, tool call or task, under the Session's sandbox: the same policy as the agent's commands, which with the sandbox off means the harness's own permissions. Tell the user what each hook you install does and at which point it fires. One switch turns all of an agent's hooks off without uninstalling them: `hooks.enabled: false` in `system_config.yaml`.
141
+
142
+ ## When a change takes effect
143
+
144
+ The harness reads an agent's configuration from disk each time a model context opens — AGENTS.md, `system_config.yaml`, Skills and hook packages alike:
145
+
146
+ - a **new conversation** starts with everything you wrote;
147
+ - a **conversation already running** — the one you are in, if you are changing yourself — picks the change up when its context is next compacted. The user can force that with `/compact`.
148
+
149
+ Nothing changes in the middle of a context, so a hook you just wrote will not fire on the next message of this conversation, and a Skill you just wrote is not in your own system prompt yet. You can still read a new SKILL.md directly and follow it now. Say which of the two cases applies when you report.
150
+
151
+ ## Set name and description
152
+
153
+ 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
+
155
+ ## Creating a brand-new agent
156
+
157
+ Prefer configuring an agent the user already created. If the user requires a new Agent, confirm that `TARGET` does not exist. If it already exists, stop and tell the user; never silently overwrite, reinitialize, or reuse an existing Agent under the same id.
158
+
159
+ After confirming that the target is absent, pick a short id using letters, digits, `_`, or `-`, copy the default Agent's `system_config.yaml` as the base, and create the layout described above:
160
+
161
+ ```bash
162
+ mkdir -p "$TARGET/agent_state/skills" "$TARGET/agent_state/hooks" "$TARGET/agent_state/memory" "$TARGET/agent_state/tools" "$TARGET/scratchpad"
163
+ cp "$APP_DATA_DIR/agents/default_agent/agent_state/system_config.yaml" "$TARGET/agent_state/"
164
+ ```
165
+
166
+ 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.
167
+
168
+ ## Validate and report
169
+
170
+ Before finishing:
171
+
172
+ - parse `agent_state/system_config.yaml` and confirm `name`, `description`, a positive integer `version`, and the expected `model.thinking_level`;
173
+ - confirm `agent_state/AGENTS.md` exists and is non-empty;
174
+ - confirm every installed Skill has a parseable `SKILL.md`, and its `name` matches its directory;
175
+ - 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;
176
+ - confirm no Agent outside `TARGET` was changed.
177
+
178
+ Report the target path, whether an existing Agent was configured or a new Agent was created, assumptions, installed Skills and hook packages (for each hook: what it does and at which point it fires), when the change takes effect, the resolved runtime and whether each value was user-specified or inherited, and validation results. For an agent that a program uses, also report the way chosen and, on the API path, the owner's steps, the Agent ID and the Base URL.
179
+
180
+ ## The embedded agent of an SDK app
181
+
182
+ On the SDK path, the app carries its own agent inside its project; where its directory is, and how the app writes its persona into it, are the penguin-sdk skill's. That directory has exactly the layout described here, and everything in this skill applies to it: the persona goes into its `agent_state/AGENTS.md`, not into application code, and `name`/`description` in its `system_config.yaml` make the app recognizable.
@@ -0,0 +1,112 @@
1
+ # Hook packages: the full contract
2
+
3
+ A hook package is `agent_state/hooks/<package_name>/`: a `hooks.json` manifest and the scripts it names. The directory name is the package's name (letters, digits, `_`, `-`) and wins over the manifest's `name`.
4
+
5
+ ## `hooks.json`
6
+
7
+ ```json
8
+ {
9
+ "name": "<package_name>",
10
+ "description": "<one line, English>",
11
+ "description_zh": "<one line, Chinese - optional>",
12
+ "version": "<YYYY.MM.DD.N>",
13
+ "user_prompt": [{ "command": "prompt.mjs", "timeout": 10 }],
14
+ "pre_tool_use": [{ "command": "guard.mjs", "timeout": 5 }],
15
+ "stop": [{ "command": "stop.mjs", "timeout": 60 }]
16
+ }
17
+ ```
18
+
19
+ - A hook point you do not use may be left out or given `[]`.
20
+ - `command` is a path relative to the package directory and must stay inside it. An entry without one is ignored.
21
+ - `timeout` is in seconds; 60 when absent.
22
+ - `version` is today's date plus a counter, `2026.09.29.1`. Raise it whenever you change the package.
23
+ - Commands of one point run in the order listed; packages run in name order.
24
+
25
+ ### `trigger` (on `user_prompt` commands only)
26
+
27
+ | Value | The command runs |
28
+ | --- | --- |
29
+ | `"prompt"` (default) | On every prompt the user submits |
30
+ | `"host"` | Only when the host starts the package's own flow by name. Goal mode's start script is the shipped example; an ordinary hook never needs it |
31
+
32
+ Write `trigger` explicitly only for `"host"`. One thing to know when editing an older package: a manifest whose `version` is older than `2026.09.29.1` has its unmarked `user_prompt` commands read as `"host"`, so raise the version when you want them to run on every prompt.
33
+
34
+ ## What a script receives and answers
35
+
36
+ Every script gets one JSON object on stdin with these fields, plus the ones of its point:
37
+
38
+ | Field | Meaning |
39
+ | --- | --- |
40
+ | `hook` | The point: `user_prompt`, `pre_tool_use` or `stop` |
41
+ | `session_id` | The Session's id |
42
+ | `trace_path` | Absolute path of the Trace file being written — a JSONL record of the conversation so far. Absent when the Session keeps no Trace |
43
+
44
+ stdout is one JSON object, or nothing for "no opinion". Unknown fields are dropped.
45
+
46
+ ### `user_prompt`
47
+
48
+ Runs when a task starts from a message the user wrote. It does not run for messages the harness or the server injects: scheduled tasks, a `stop` hook's continuation, background-task reports, mid-run steering.
49
+
50
+ | stdin | |
51
+ | --- | --- |
52
+ | `prompt` | The user's text, with leading marker blocks (a skill invocation, an origin note) stripped |
53
+ | `scratchpad_dir` | The Session's scratchpad directory — the place for state the hook keeps between prompts |
54
+
55
+ | stdout | |
56
+ | --- | --- |
57
+ | `context` | Text for the model. It is sent as its own message right behind the user's, marked as harness-injected, and shown to the user as a collapsed card. Empty or absent adds nothing |
58
+
59
+ The context is appended after the user's message, so it never invalidates the prompt cache of the conversation before it. Keep it short: it is paid for on every prompt.
60
+
61
+ ### `pre_tool_use`
62
+
63
+ Runs once per tool call, before the approval step.
64
+
65
+ | stdin | |
66
+ | --- | --- |
67
+ | `tool_name` | The tool being called, e.g. `exec_command` |
68
+ | `tool_call_id` | The call's id |
69
+ | `arguments` | The call's arguments as the raw JSON string the model wrote — parse it yourself |
70
+
71
+ | stdout | |
72
+ | --- | --- |
73
+ | `decision` | `"deny"` refuses the call and the model reads `reason`; `"allow"` approves it without asking the user; absent leaves the call to the normal approval |
74
+ | `reason` | One line for people |
75
+ | `output` | Your own record: an object of string, number or boolean values |
76
+
77
+ The first decision among all hooks wins. An `allow` never overrides the Project's command policy: a command the policy forbids stays forbidden.
78
+
79
+ ### `stop`
80
+
81
+ Runs after every task: the model's final reply, or a cutoff (the user's abort, a failed request, the turn cap).
82
+
83
+ | stdout | |
84
+ | --- | --- |
85
+ | `decision` | `"continue"` starts another task with `input` as its user message; `"stop"` lets the run end |
86
+ | `input` | Required with `continue`: the next task's input text |
87
+ | `reason` | One line for people |
88
+ | `output` | Your own record: an object of string, number or boolean values |
89
+ | `subagent` | `{ "prompt": "<text>", "agent_id": "<optional>" }` — hands work to a detached background session |
90
+
91
+ The first `continue` wins. After a cutoff a `continue` is recorded but not run: the user's interruption outranks every hook. A `stop` hook that always continues never lets the agent finish — decide from state (the Trace, a file in the scratchpad), and make sure the state eventually says stop.
92
+
93
+ ## Failures
94
+
95
+ A non-zero exit, stdout that is not JSON, or a timeout is a failure. So is a script the Session's sandbox could not confine: it never runs, and its error starts with `sandbox:`. The harness records a failure as a `hook` event carrying the error (the tail of stderr for a non-zero exit) and carries on as if the hook had no opinion. To debug a hook that seems not to fire, look for `"type":"hook"` records in the Trace file, and run the script by hand:
96
+
97
+ ```bash
98
+ echo '{"hook":"stop","session_id":"test","trace_path":"/path/to/trace.jsonl"}' | node stop.mjs; echo "exit $?"
99
+ ```
100
+
101
+ Check three more things when nothing happens: the agent's `hooks.enabled` is not `false`, the conversation has opened a new context since you wrote the package (see "When a change takes effect" in SKILL.md), and the session is not a subagent's — child sessions run no hooks.
102
+
103
+ ## Converting hooks from Claude Code
104
+
105
+ | Claude Code | Here |
106
+ | --- | --- |
107
+ | `UserPromptSubmit` | `user_prompt` — print `{ "context": … }` instead of plain text |
108
+ | `PreToolUse` | `pre_tool_use` — `permissionDecision` becomes `decision`; filter on `tool_name` inside the script, there is no `matcher` |
109
+ | `Stop` | `stop` — `{"decision":"block","reason":…}` becomes `{"decision":"continue","input":…}` |
110
+ | `PostToolUse`, `SessionStart`, `Notification`, others | No counterpart. Say so rather than approximating |
111
+
112
+ A Claude Code hook is a shell command; here a command is a Node script. Wrap a shell command with `node:child_process` (`execFileSync`) when you need one, and keep the JSON on stdout yours.
@@ -1,11 +1,12 @@
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
5
  ---
5
6
 
6
7
  # Penguin Config (CLI)
7
8
 
8
- The `penguin` CLI manages model credentials, default models and per-agent vault secrets. Its primary job is model configuration: `penguin config model add` registers a model and `penguin config model list` shows the models currently available. Configuration goes through the CLI only — never read or hand-edit the underlying hidden files.
9
+ The `penguin` CLI manages model credentials, default models and per-agent vault secrets. Its primary job is model configuration: `penguin config model add` registers a model, or — without `--model-id` — gives a whole group its key, base URL or protocol, and `penguin config model list` shows the groups' connections and the models currently available. Configuration goes through the CLI only — never read or hand-edit the underlying hidden files.
9
10
 
10
11
  ## Before you start
11
12
 
@@ -16,14 +17,16 @@ If the user's message only invokes this skill (e.g. "use penguin-cli skill") wit
16
17
  Add or update a model (upsert by the `(provider, model_id)` pair; re-run with more options to amend an entry):
17
18
 
18
19
  ```bash
19
- penguin config model add --provider <group> --model-id <upstream_id> [--api-key <key>] [--base-url <url>] \
20
- [--client-type <type>] [--context-window <n>] [--max-tokens <n>] [--vision | --no-vision] \
20
+ penguin config model add --provider <group> --model-id <upstream_id> [--api-key <key> | --clear-api-key] \
21
+ [--base-url <url> | --clear-base-url] [--client-type <type> | --clear-client-type] \
22
+ [--context-window <n>] [--max-tokens <n>] [--vision | --no-vision] [--fast-mode | --no-fast-mode] \
21
23
  [--price-cache-read <n>] [--price-cache-write <n>] [--price-output <n>] \
22
24
  [--project-id <id>] [--root <dir>] [--set-default]
23
25
  ```
24
26
 
25
- - A model is identified by the `(provider, model_id)` pair, so `--provider` and `--model-id` are **both required** — 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).
26
- - For any OpenAI chat-completion compatible endpoint use `--client-type openai --base-url <endpoint>`; omit `--client-type` to auto-route by model id.
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.
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.
27
30
  - Prices are USD per million tokens (cache read / cache write / output).
28
31
  - `--vision` / `--no-vision` mark whether the model accepts images; omitting both keeps the current value (default is vision-capable).
29
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.
@@ -37,9 +40,26 @@ Other model commands:
37
40
  ```bash
38
41
  penguin config model default --model-id <upstream_id> --provider <group> [--root <dir>] # set the project default model
39
42
  penguin config model vision --model-id <upstream_id> --provider <group> [--root <dir>] # set the project vision model (reads images for text-only sessions)
40
- penguin config model list [--root <dir>] # list models; api_key is shown masked
43
+ penguin config model list [--root <dir>] # the groups' connections, then the models with the connection each uses; api_key masked, (provider) = from the group, (env) = from an environment variable
44
+ penguin config model remove --model-id <upstream_id> --provider <group> [--root <dir>] # remove one model
41
45
  ```
42
46
 
47
+ ## Group connection
48
+
49
+ A group holds one connection — API key, base URL, protocol — in its `[providers.<group>]` table, and every model in it without a value of its own follows it. Each field resolves on its own from the config file alone: the model's value, else the group's, else nothing (the client's default endpoint, MMSP routing by model id, the environment key where allowed). The built-in catalog is only a reference: a new Project's file already stores each gateway's endpoint and protocol on its group. Set a key once on the group rather than on every model. `model add` and `model remove` without `--model-id` act on the group:
50
+
51
+ ```bash
52
+ penguin config model add --provider <group> [--api-key <key> | --clear-api-key] [--base-url <url> | --clear-base-url] \
53
+ [--client-type <type> | --clear-client-type] [--project-id <id>] [--root <dir>]
54
+ penguin config model remove --provider <group> [--project-id <id>] [--root <dir>] # removes the group's connection only; its models stay
55
+ ```
56
+
57
+ - A field you do not name is left as it is. An empty value is refused: remove a field with its `--clear-*` flag.
58
+ - The flags that describe one model (`--context-window`, `--max-tokens`, `--vision`, `--fast-mode`, `--price-*`, `--set-default`) are refused without `--model-id`; nothing is written.
59
+ - Any group but `penguin-go` takes a protocol, `opencode-go` included: a model's own protocol always wins over its group's. `penguin-go` is fixed to `mmsp`, for its models too: another `--client-type`, or `--clear-client-type` on the group, is refused.
60
+ - The group key never replaces a key set on one model with `model add --api-key`; the command says how many models keep their own. It reaches only the models that go to the group's endpoint: a model whose own `--base-url` is on another host (scheme, host and port) needs its own `--api-key`.
61
+ - For a group of your own on one endpoint, set its connection first, then add each model with only `--provider` and `--model-id`: the models store nothing and follow the group. Removing the group's last model removes its connection too.
62
+
43
63
  ## Vault (per-agent secrets)
44
64
 
45
65
  The vault holds an agent's environment-variable secrets (third-party API keys etc.); values are injected into that agent's shell subprocesses:
@@ -67,5 +87,5 @@ penguin config lang <en|zh> # persist the CLI language via PENGUIN_LANG in you
67
87
 
68
88
  Paths use `<app_data_dir>`, the App Data Dir value from your Environment section.
69
89
 
70
- - `<app_data_dir>/.project_config.toml` — the project's single hidden config file: model list, settings and per-model credentials (`api_key` etc. inlined in each model entry). Configuration is CLI-only — never read, print or hand-edit this file.
90
+ - `<app_data_dir>/.project_config.toml` — the project's single hidden config file: model list, settings, each group's connection (`[providers.<group>]`) and the values a model overrides (`api_key` etc. on its entry). Configuration is CLI-only — never read, print or hand-edit this file.
71
91
  - `<app_data_dir>/agents/<agent_id>/agent_state/.vault.toml` — that agent's vault entries, hidden file; same rule, manage it with `penguin config vault`.
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: penguin-orchestration
3
3
  description: Drive PenguinHarness itself from a shell — list and create agents and sessions, send and steer messages mid-flight, and query costs and scheduled tasks via the penguin CLI over the local server.
4
+ version: 2026.10.10.1
4
5
  ---
5
6
 
6
7
  # Penguin Orchestration
@@ -9,7 +10,7 @@ The `penguin` CLI is a thin client of the PenguinHarness server. Inside a harnes
9
10
 
10
11
  ## Before you start
11
12
 
12
- If the user's message only invokes this skill (e.g. "use penguin-orchestration skill") without a concrete request, ask the user what they want to orchestrate. Read-only commands (`project ls`, `agent ls`, `ls`, `logs`, `cost`, `schedule ls`) are always safe; do not create agents, start sessions or send messages until the goal is clear.
13
+ If the user's message only invokes this skill (e.g. "use penguin-orchestration skill") without a concrete request, ask the user what they want to orchestrate. Read-only commands (`project ls`, `agent ls`, `session ls`, `session log`, `cost`, `schedule ls`) are always safe; do not create agents, start sessions or send messages until the goal is clear.
13
14
 
14
15
  ## How the connection works
15
16
 
@@ -23,9 +24,9 @@ If the user's message only invokes this skill (e.g. "use penguin-orchestration s
23
24
  Before mutating anything, see what exists:
24
25
 
25
26
  ```bash
26
- penguin project ls # projects on this server
27
- penguin agent ls # agents in the current project
28
- penguin ls --json # the project's sessions, with running state
27
+ penguin project ls # projects on this server
28
+ penguin agent ls # agents in the current project
29
+ penguin session ls --json # the project's sessions, with running state
29
30
  ```
30
31
 
31
32
  `--json` on any listing gives machine-parseable output.
@@ -35,13 +36,14 @@ penguin ls --json # the project's sessions, with running state
35
36
  ```
36
37
  penguin run -m <msg> [--project-id <id>] [--agent-id <id>] [--workspace <path>]
37
38
  [--model-id <id> --provider <p>] [--approve <mode>] [--thinking <level>]
38
- [--session <session_id>] [--background] [--timeout <duration>]
39
- [--goal [budget]] [--json]
40
- penguin ls [--project-id <id>] [--agent-id <id>] [--days <n>] [-a|--all] [--json]
41
- penguin input [session_id] [-m <text>] [--timeout <duration>]
42
- [--project-id <id>] [--agent-id <id>] [--json] [--server <url>]
43
- penguin logs [session_id] [--project-id <id>] [--agent-id <id>] [--tail <n>]
44
- [-f|--follow] [--timeout <duration>] [--json]
39
+ [--session <session_id>] [--title <title>] [--background]
40
+ [--timeout <duration>] [--goal [budget]] [--json]
41
+ penguin session ls [--project-id <id>] [--agent-id <id>] [--days <n>] [-a|--all] [--json]
42
+ penguin session input [session_id] [-m <text>] [--timeout <duration>]
43
+ [--project-id <id>] [--agent-id <id>] [--json] [--server <url>]
44
+ penguin session log [session_id] [--project-id <id>] [--agent-id <id>] [--tail <n>]
45
+ [-f|--follow] [--timeout <duration>] [--json]
46
+ penguin session rename [session_id] -t <title> [--project-id <id>] [--agent-id <id>] [--json]
45
47
  penguin agent ls [--project-id <id>] [--json]
46
48
  penguin agent create --agent-id <id> [--name <s>] [--description <s>] [--skills <a,b>]
47
49
  [--project-id <id>] [--json]
@@ -60,32 +62,33 @@ penguin schedule rm <name> [--project-id <id>] [--agent-id <id>]
60
62
 
61
63
  - `run` starts a task and waits, rendering the conversation, unless `--background` — then it prints the new session id and exits while the server keeps running the task. `--session <session_id>` runs the task in an existing session instead of creating one; the model reference is the `--provider` + `--model-id` pair (both or neither); `--goal [budget]` runs in goal mode — the session loops until the agent declares the goal complete, with an optional spend budget.
62
64
  - **Caller-context defaults.** Inside a harness agent, a session-creating `run` fills every field you leave unspecified from your own live session, per field independently: `--workspace`, the `--model-id`/`--provider` pair, `--approve` and `--thinking` inherit the caller's values — the same convention as `run_subagent` parent inheritance. Precedence: explicit flag > caller value > plain fallback (cwd, the Project default model, `allow-all`, none — used wholesale if the caller lookup fails, with a dim stderr note). So inside an agent, `penguin run -m "..."` alone typically does the right thing; pass flags only to diverge.
63
- - `--timeout <duration>` (`30s`, `5m`, `2h`, or bare seconds) bounds the wait of a foreground `run`, an `input`, or a `logs -f`. Expiry is a soft yield, not an error: the command exits 0 while the task keeps running server-side, printing a still-running note that names the follow-up commands (`--json` prints `{sessionId, status: "running", text}` with the text so far). `--timeout 0` (also `0s`) returns immediately after delivery — the same note without collected text (`--json`: `{sessionId, status: "running"}`); on a bare poll it snapshots a running session instantly. `run --background` stays the idiomatic fire-and-forget for new tasks and rejects `--timeout`; `logs --timeout` requires `-f`.
64
- - `input` with `-m` steers a **running** session mid-turn (the agent absorbs it as a course correction within the current task) or starts a new turn on an idle one; it waits for the reply unless a `--timeout` bounds the wait (`--timeout 0` = deliver and return at once). Bare `input [session_id]` (no `-m`) **polls**: it prints the session's most recent complete assistant text — an idempotent snapshot that skips user/thinking/tool output and never touches approvals, mirroring `input_subagent`'s empty-prompt semantics. A running session is waited on first (bounded by `--timeout`, else indefinitely); a session with no reply yet prints `(no assistant reply yet)`. `--json` reports `{sessionId, status, text}` — `idle`/`running` when polling, `completed`/`aborted`/`running` with `-m`.
65
- - `ls` spans every agent of the project, newest first (by last active); archived sessions are left out unless `-a`/`--all` includes them, and `--days <n>` keeps only sessions last active since local midnight n−1 days ago — today counts as day 1, so `--days 2` is yesterday and today, `--days 7` this week. `logs` renders a session's transcript: `--tail <n>` for the last entries, `-f` to follow live.
66
- - Session ids embed their creation timestamp — `session-YYYY-MM-DD-HH-mm-ss-<8hex>`. Every `<session_id>` argument takes any unique substring of an id; the 8-hex tail is the recommended short form, and an ambiguous fragment errors listing the candidates. On `input` and `logs`, `--project-id` scopes that fragment search (unnecessary with a full id).
67
- - On `input` and `logs` the id is optional altogether: omitted, it is the agent's most recent session, off the same newest-first listing `chat --resume` uses, with `--agent-id` picking whose. The chosen id is announced as a dim `[latest]` line on stderr, so the target is never ambiguous and `--json` on stdout stays parseable. Bare `penguin logs` is therefore "what just happened" and bare `penguin input` is "what did my agent last say"; an agent with no session at all gets one line pointing at `penguin run` and a non-zero exit.
65
+ - `--timeout <duration>` (`30s`, `5m`, `2h`, or bare seconds) bounds the wait of a foreground `run`, a `session input`, or a `session log -f`. Expiry is a soft yield, not an error: the command exits 0 while the task keeps running server-side, printing a still-running note that names the follow-up commands (`--json` prints `{sessionId, status: "running", text}` with the text so far). `--timeout 0` (also `0s`) returns immediately after delivery — the same note without collected text (`--json`: `{sessionId, status: "running"}`); on a bare poll it snapshots a running session instantly. `run --background` stays the idiomatic fire-and-forget for new tasks and rejects `--timeout`; `session log --timeout` requires `-f`.
66
+ - `session input` with `-m` steers a **running** session mid-turn (the agent absorbs it as a course correction within the current task) or starts a new turn on an idle one; it waits for the reply unless a `--timeout` bounds the wait (`--timeout 0` = deliver and return at once). Bare `session input [session_id]` (no `-m`) **polls**: it prints the session's most recent complete assistant text — an idempotent snapshot that skips user/thinking/tool output and never touches approvals, mirroring `input_subagent`'s empty-prompt semantics. A running session is waited on first (bounded by `--timeout`, else indefinitely); a session with no reply yet prints `(no assistant reply yet)`. `--json` reports `{sessionId, status, text}` — `idle`/`running` when polling, `completed`/`aborted`/`running` with `-m`.
67
+ - `session ls` spans every agent of the project, newest first (by last active); archived sessions are left out unless `-a`/`--all` includes them, and `--days <n>` keeps only sessions last active since local midnight n−1 days ago — today counts as day 1, so `--days 2` is yesterday and today, `--days 7` this week. `session log` renders a session's transcript: `--tail <n>` for the last entries, `-f` to follow live.
68
+ - Session ids embed their creation timestamp — `session-YYYY-MM-DD-HH-mm-ss-<8hex>`. Every `<session_id>` argument takes any unique substring of an id; the 8-hex tail is the recommended short form, and an ambiguous fragment errors listing the candidates. On the `session` commands, `--project-id` scopes that fragment search (unnecessary with a full id).
69
+ - On `session input` and `session log` the id is optional altogether: omitted, it is the agent's most recent session, off the same newest-first listing `chat --resume` uses, with `--agent-id` picking whose. The chosen id is announced as a dim `[latest]` line on stderr, so the target is never ambiguous and `--json` on stdout stays parseable. Bare `penguin session log` is therefore "what just happened" and bare `penguin session input` is "what did my agent last say"; an agent with no session at all gets one line pointing at `penguin run` and a non-zero exit.
70
+ - `session rename -t <title>` sets a session's title, the same manual rename as the web UI's, which the auto-generated title never overwrites. Without an id it renames **the session you are running in** (`PENGUIN_SESSION_ID`), so "rename this chat" is `penguin session rename -t "<title>"`; an id renames another session. `run --title <title>` names a session as `run` creates it.
68
71
 
69
72
  ## Recipes
70
73
 
71
74
  ### Yesterday's or this week's sessions, with their latest replies
72
75
 
73
76
  ```bash
74
- penguin ls --days 2 --json # yesterday + today (today counts as day 1)
75
- penguin ls --days 7 --json # this week; add -a to include archived sessions
76
- penguin input <session_id> # one session's latest complete assistant reply
77
+ penguin session ls --days 2 --json # yesterday + today (today counts as day 1)
78
+ penguin session ls --days 7 --json # this week; add -a to include archived sessions
79
+ penguin session input <session_id> # one session's latest complete assistant reply
77
80
  ```
78
81
 
79
82
  - `--days <n>` keeps sessions last active since local midnight n−1 days ago. For strictly-yesterday, take `--days 2` and drop today's entries client-side — ids embed the creation date and the JSON carries last-active.
80
- - Bare `input` prints the latest reply; add `--timeout 0` to snapshot a running session instantly instead of waiting for its turn to finish.
83
+ - Bare `session input` prints the latest reply; add `--timeout 0` to snapshot a running session instantly instead of waiting for its turn to finish.
81
84
 
82
85
  ### Summarize this week's history in a new session
83
86
 
84
87
  A fresh session gets a fresh context window for the summary; feed it through a file, not the prompt:
85
88
 
86
89
  ```bash
87
- penguin ls --days 7 --json # pick the sessions
88
- penguin logs <session_id> --tail 100 # gather each transcript (widen if cut short)
90
+ penguin session ls --days 7 --json # pick the sessions
91
+ penguin session log <session_id> --tail 100 # gather each transcript (widen if cut short)
89
92
  # write what you gathered into a workspace file with your file tools, then:
90
93
  penguin run -m "Read ./weekly-material.md and write the weekly summary to ./weekly-summary.md"
91
94
  ```
@@ -143,19 +146,20 @@ penguin run --agent-id <agent_id> -m "<long task>"
143
146
  ```
144
147
 
145
148
  - The harness delivers a `[background_task_done]` report when the CLI exits — no polling needed for completion.
146
- - Meanwhile, find the session with `penguin ls --json` (it shows as running, with the newest id) and steer it: `penguin input <session_id> -m "Focus on X; skip Y" --timeout 0` (deliver and return at once).
147
- - Poll the latest answer with bare `penguin input <session_id> --timeout 30s` — a bounded wait that exits 0 with a still-running note when the reply is not in yet — or read the raw transcript with `penguin logs <session_id> --tail 20`.
149
+ - Meanwhile, find the session with `penguin session ls --json` (it shows as running, with the newest id) and steer it: `penguin session input <session_id> -m "Focus on X; skip Y" --timeout 0` (deliver and return at once).
150
+ - Poll the latest answer with bare `penguin session input <session_id> --timeout 30s` — a bounded wait that exits 0 with a still-running note when the reply is not in yet — or read the raw transcript with `penguin session log <session_id> --tail 20`.
148
151
 
149
152
  **(b) Server-side background — survives you.** `penguin run --background --agent-id <agent_id> -m "<long task>"` prints the session id and exits; the server keeps running the task with no local process.
150
153
 
151
- - Poll the latest answer with bare `penguin input <session_id> --timeout 30s`, watch live with `penguin logs <session_id> -f`, and check running state with `penguin ls --json`; steer with `penguin input <session_id> -m ...` the same way.
154
+ - Poll the latest answer with bare `penguin session input <session_id> --timeout 30s`, watch live with `penguin session log <session_id> -f`, and check running state with `penguin session ls --json`; steer with `penguin session input <session_id> -m ...` the same way.
152
155
 
153
- Prefer (a) when you stay around for the result — the completion report comes to you. Prefer (b) when the work must survive your own session ending, or when fanning out many tasks without holding a process per task. A bounded foreground run is the middle ground: `penguin run --timeout 5m -m "..."` renders up to the bound, then soft-yields with the task still running — pick up the answer later with a bare `penguin input <session_id>`.
156
+ Prefer (a) when you stay around for the result — the completion report comes to you. Prefer (b) when the work must survive your own session ending, or when fanning out many tasks without holding a process per task. A bounded foreground run is the middle ground: `penguin run --timeout 5m -m "..."` renders up to the bound, then soft-yields with the task still running — pick up the answer later with a bare `penguin session input <session_id>`.
154
157
 
155
158
  ## Cautions
156
159
 
157
- - **One active task per session.** `penguin input` at a busy session steers the running task rather than starting a second one; a new task sent at a busy session waits its turn. For parallel work, start parallel sessions.
160
+ - **One active task per session.** `penguin session input` at a busy session steers the running task rather than starting a second one; a new task sent at a busy session waits its turn. For parallel work, start parallel sessions.
158
161
  - **Unattended sessions must not need a human.** A spawned session inherits your approval mode (`allow-all` when there is no caller to inherit from); if you yourself run under `always-ask`, pass `--approve allow-all` (trusted work) or `--approve read-only` explicitly — an unattended `always-ask` session hangs waiting for approval in the web UI.
159
162
  - **No runaway loops.** An agent that messages itself — directly, through a chain of agents, or through a schedule aimed back at its own session — keeps spending until someone stops it. Make every automated conversation terminate: a recurring schedule pointed at your own session takes an `--end-at` whenever the request has a natural horizon (or no `--period` at all, for a one-time reminder), and a prompt whose per-firing work stays small — that session's context grows with every firing. When the user wants it open-ended, leave `--end-at` off and tell them it runs until they remove it.
160
163
  - **Spawned work bills the project.** Everything you start lands in the same project's usage (`penguin cost` shows it); a fan-out of sessions multiplies spend.
164
+ - **Opening an agent to programs is the owner's call.** `penguin agent api` manages an agent's Agent API. Its `status` and `keys ls` only read. Never run `enable`, `disable`, `set`, `keys create`, `keys rm` or `server` yourself: the server refuses them to your token (`403 human_required`), and you must not sign in or mint a session to get past that. Ask the user to make the change on the agent's **API** tab, or in their own terminal after `penguin auth login`. To connect a program to an agent, use the penguin-sdk skill.
161
165
  - **Configuration stays CLI-managed.** Never read or hand-edit `.project_config.toml` or `agent_state/.vault.toml` — models and secrets go through `penguin config` (see the penguin-cli skill).