@geekbeer/minion 3.60.4 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,53 @@
1
+ Copyright (c) 2026 GeekBeer Co., Ltd.
2
+
3
+ Source code in this repository is covered by the Elastic License 2.0.
4
+ The full license text is available at:
5
+ https://www.elastic.co/licensing/elastic-license
6
+
7
+ ----
8
+
9
+ Elastic License
10
+
11
+ Acceptance
12
+ By using the software, you agree to all of the terms and conditions below.
13
+
14
+ Copyright License
15
+ The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below.
16
+
17
+ Limitations
18
+ You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
19
+
20
+ You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
21
+
22
+ You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
23
+
24
+ Patents
25
+ The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
26
+
27
+ Notices
28
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
29
+
30
+ If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
31
+
32
+ No Other Rights
33
+ These terms do not imply any licenses other than those expressly granted in these terms.
34
+
35
+ Termination
36
+ If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
37
+
38
+ No Liability
39
+ As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
40
+
41
+ Definitions
42
+ The licensor is the entity offering these terms, and the software is the software the licensor makes available under these terms, including any portion of it.
43
+
44
+ you refers to the individual or entity agreeing to these terms.
45
+
46
+ your company is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. control means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
47
+
48
+ your licenses are all the licenses granted to you for the software under these terms.
49
+
50
+ use means anything you do with the software requiring one of your licenses.
51
+
52
+ trademark means trademarks, service marks, and similar rights.
53
+
package/README.md CHANGED
@@ -1,64 +1,59 @@
1
- # @geekbeer/minion
1
+ > [!IMPORTANT]
2
+ > This package is the agent runtime for [Minion](https://minion-agent.com), GeekBeer's AI agent platform. It is intended to run on a Minion-managed host (provisioned via the HQ dashboard) and is not designed for standalone use.
2
3
 
3
- AI Agent runtime for Minion - manages heartbeat, status, and skill deployment on VPS.
4
+ # @geekbeer/minion
4
5
 
5
- ## Install
6
+ AI agent runtime that runs on a Minion host (Lightsail VPS, Docker container, or self-hosted machine). It exposes a local HTTP API on port `8080`, syncs heartbeats and skills with the HQ server, and runs Claude Code–based workflows and routines via tmux (Linux/macOS) or node-pty (Windows).
6
7
 
7
- ```bash
8
- npm install -g @geekbeer/minion
9
- ```
8
+ Supported platforms: Linux (systemd / supervisord), Windows (NSSM service + WSL), macOS (launchd).
10
9
 
11
- ## Usage
10
+ ## Documentation
12
11
 
13
- ### Setup (VPS)
12
+ Full documentation lives at **https://docs.minion-agent.com**. Start here:
14
13
 
15
- ```bash
16
- minion-cli setup \
17
- --hq-url https://minion-agent.com \
18
- --minion-id <MINION_ID> \
19
- --api-token <API_TOKEN> \
20
- --setup-tunnel \
21
- --non-interactive
22
- ```
14
+ - [Quickstart](https://docs.minion-agent.com/getting-started/quickstart/) — provision a minion from the HQ dashboard
15
+ - [Concepts](https://docs.minion-agent.com/getting-started/concepts/) workspaces, projects, skills, workflows, routines
16
+ - [Self-hosting / Provisioning](https://docs.minion-agent.com/getting-started/provisioning/) — bring your own host
17
+ - [Skill authoring](https://docs.minion-agent.com/skills-workflows/skill-authoring/) and [workflow design](https://docs.minion-agent.com/skills-workflows/workflow-design/)
18
+ - [DAG workflow nodes](https://docs.minion-agent.com/skills-workflows/dag-nodes/)
23
19
 
24
- ### Service Management
20
+ Japanese documentation is available at https://docs.minion-agent.com/ja/.
25
21
 
26
- ```bash
27
- minion-cli start # Start the minion agent
28
- minion-cli stop # Stop the minion agent
29
- minion-cli restart # Restart the minion agent
30
- minion-cli status # Show service status
31
- minion-cli health # Run health check
32
- ```
22
+ ## Install
33
23
 
34
- ### Logging
24
+ Most users do **not** install this package manually — the HQ dashboard provisions hosts automatically. For self-hosted setups:
35
25
 
36
26
  ```bash
37
- minion-cli log -m "Task completed" -l info -s skill-name
27
+ npm install -g @geekbeer/minion
38
28
  ```
39
29
 
40
- ### Issue Reporting
30
+ Then follow the [self-hosting guide](https://docs.minion-agent.com/getting-started/provisioning/) to register the host with your HQ workspace.
41
31
 
42
- ```javascript
43
- const { reportIssue } = require('@geekbeer/minion/api')
32
+ ## CLI
44
33
 
45
- await reportIssue({
46
- title: 'HQ APIで502エラーが発生する',
47
- body: '## 状況\n...\n\n## 再現手順\n...',
48
- labels: ['bug', 'critical']
49
- })
50
- // { success: true, issue_url: '...', issue_number: 42 }
34
+ ```bash
35
+ minion-cli setup --user <USERNAME> # Install dependencies and register services (Linux/macOS, run as root)
36
+ minion-cli configure --hq-url ... --minion-id ... --api-token ...
37
+ minion-cli start | stop | restart | status
38
+ minion-cli health | diagnose | daemons
39
+ minion-cli set-status <status> [task]
40
+ hq <subcommand> # HQ API helper (notes, threads, tasks, memories, etc.)
51
41
  ```
52
42
 
43
+ On Windows the equivalents are exposed as `minion-cli-win` and `hq-win`; on macOS as `minion-cli-mac` and `hq-mac`. See the [provisioning guide](https://docs.minion-agent.com/getting-started/provisioning/) for end-to-end setup.
44
+
53
45
  ## Environment Variables
54
46
 
55
- | Variable | Description | Default |
56
- |----------|-------------|---------|
57
- | `HQ_URL` | Minion HQ server URL | - |
58
- | `API_TOKEN` | Authentication token | - |
59
- | `MINION_ID` | Minion UUID | - |
60
- | `AGENT_PORT` | Agent API listen port | `8080` |
47
+ | Variable | Description |
48
+ |----------|-------------|
49
+ | `HQ_URL` | HQ server URL (leave empty for standalone mode) |
50
+ | `API_TOKEN` | Bearer token for HQ and local API authentication |
51
+ | `MINION_ID` | UUID assigned by HQ on provisioning |
52
+ | `AGENT_PORT` | Local agent API port (default `8080`) |
53
+ | `MINION_USER` | System user that owns the agent process |
61
54
 
62
55
  ## License
63
56
 
64
- MIT
57
+ This software is licensed under the [Elastic License 2.0](./LICENSE.md) (SPDX: `Elastic-2.0`).
58
+
59
+ Copyright (c) 2026 GeekBeer Co., Ltd.
@@ -161,12 +161,19 @@ async function executeSkillNode(node) {
161
161
  )
162
162
 
163
163
  try {
164
- // 1. Claim the node
164
+ // 1. Claim the node. Response includes `template_vars` containing the
165
+ // workspace/project-scope variables resolved on HQ — we merge these
166
+ // with minion-local variables for the skill fetch below so HQ-side
167
+ // variable updates (e.g. project_variables) take effect on the next
168
+ // node execution. Minion-local values win over HQ-scope values,
169
+ // matching the cross-scope rule (workspace < project < minion).
170
+ let hqVars = {}
165
171
  try {
166
- await dagRequest('/claim-node', {
172
+ const claimResp = await dagRequest('/claim-node', {
167
173
  method: 'POST',
168
174
  body: JSON.stringify({ node_execution_id }),
169
175
  })
176
+ hqVars = (claimResp && claimResp.template_vars) || {}
170
177
  } catch (claimErr) {
171
178
  if (claimErr.statusCode === 409) {
172
179
  console.log(`[DagPoller] Node ${node_id} already claimed, skipping`)
@@ -187,7 +194,7 @@ async function executeSkillNode(node) {
187
194
  if (skillName) {
188
195
  try {
189
196
  const minionVars = variableStore.getAll('variables')
190
- const mergedVars = { ...minionVars }
197
+ const mergedVars = { ...hqVars, ...minionVars }
191
198
  const varsParam = Object.keys(mergedVars).length > 0
192
199
  ? `?vars=${Buffer.from(JSON.stringify(mergedVars)).toString('base64')}`
193
200
  : ''
@@ -1236,6 +1236,9 @@ POST `/api/minion/dag-workflows/:id/publish` (body なし):
1236
1236
  | POST | `/api/minion/dag-workflows/:id/contracts` | 個別contractを追加/更新 |
1237
1237
  | DELETE | `/api/minion/dag-workflows/:id/contracts` | 個別contractを削除 |
1238
1238
  | POST | `/api/minion/dag-workflows/:id/validate` | ドラフトをフル検証(公開せず) |
1239
+ | GET | `/api/minion/dag-workflows/:id/variables` | DAGワークフロー変数の一覧取得 |
1240
+ | PUT | `/api/minion/dag-workflows/:id/variables` | DAGワークフロー変数を一括 upsert(既存を全削除→再投入) |
1241
+ | POST | `/api/minion/dag-workflows/:id/trigger` | 公開済みワークフローを手動実行(pull-model) |
1239
1242
 
1240
1243
  #### POST `/api/minion/dag-workflows/:id/nodes` — ノード追加
1241
1244
 
@@ -1482,6 +1485,80 @@ body なし。現在のドラフトを `validateDagGraph` でフル検証し結
1482
1485
  }
1483
1486
  ```
1484
1487
 
1488
+ #### GET / PUT `/api/minion/dag-workflows/:id/variables` — DAGワークフロー変数
1489
+
1490
+ DAGワークフロー単位のキー/値ペア。スキル本文の `{{VAR_NAME}}` プレースホルダーに展開される。展開タイミングは `claim-node` のレスポンス `template_vars` に乗って降ってくる経路で、変更は **次のノード claim から即時反映** される。
1491
+
1492
+ **スコープ優先順位** (narrower wins): `workspace_variables` < `project_variables` < `dag_workflow_variables` < minion-local。
1493
+
1494
+ **バリデーション**:
1495
+ - `key`: `^[A-Za-z_][A-Za-z0-9_]{0,99}$`(先頭英字またはアンダースコア、最大100文字)
1496
+ - `value`: 文字列、最大2000文字
1497
+ - 同一 `key` の重複は不可
1498
+
1499
+ `GET /api/minion/dag-workflows/:id/variables` レスポンス:
1500
+ ```json
1501
+ {
1502
+ "variables": [
1503
+ { "id": "<uuid>", "key": "TARGET_CATEGORY", "value": "electronics", "created_at": "...", "updated_at": "..." }
1504
+ ]
1505
+ }
1506
+ ```
1507
+
1508
+ `PUT /api/minion/dag-workflows/:id/variables` body:
1509
+ ```json
1510
+ {
1511
+ "variables": [
1512
+ { "key": "TARGET_CATEGORY", "value": "electronics" },
1513
+ { "key": "API_BASE_URL", "value": "https://api.example.com" }
1514
+ ]
1515
+ }
1516
+ ```
1517
+
1518
+ - バッチ upsert 形式: **既存を全削除 → 渡された配列を全 insert** する(部分更新不可)。
1519
+ - 単一変数だけを変更したい場合も、先に GET で現在の集合を取得 → 編集 → PUT で全件送信する。
1520
+ - `variables: []` を送ると全削除になる。
1521
+
1522
+ レスポンス:
1523
+ ```json
1524
+ { "success": true, "count": 2 }
1525
+ ```
1526
+
1527
+ エラー時 (400): `{ "error": "Invalid key: 1FOO" }` / `{ "error": "Duplicate key: FOO" }` 等。
1528
+
1529
+ #### POST `/api/minion/dag-workflows/:id/trigger` — ワークフロー手動実行
1530
+
1531
+ 公開済み (`is_active=true` かつ `current_version_id` 設定済み) の DAG ワークフローを手動でトリガーする。HQダッシュボード経由の `POST /api/dag/projects/:projectId/workflows/:dagWfId/trigger` と同じ pull-model で動き、`trigger_source` は `'manual'` として記録される(cron / webhook と区別される)。
1532
+
1533
+ Body (任意):
1534
+ ```json
1535
+ {
1536
+ "payload": { "...": "..." }
1537
+ }
1538
+ ```
1539
+
1540
+ - `payload` は start ノードの `output_data` に注入され、cascade 経由で下流に伝播する。
1541
+ - start ノードに `input_contract` が定義されている場合、`payload` が contract に準拠していないと 400 (`violations` フィールドに違反詳細) が返る。
1542
+ - payload を省略すると start ノードは空の出力で完了する。
1543
+
1544
+ レスポンス (201):
1545
+ ```json
1546
+ {
1547
+ "execution_id": "<uuid>",
1548
+ "dag_workflow_name": "Order Pipeline",
1549
+ "root_nodes": 3,
1550
+ "total_nodes": 12,
1551
+ "mode": "pull"
1552
+ }
1553
+ ```
1554
+
1555
+ エラー応答:
1556
+ - 400: ワークフロー非アクティブ / 未公開 / graph 空 / payload 形式不正 / contract 違反
1557
+ - 403: ミニオンがプロジェクトの PM でない
1558
+ - 404: ワークフロー / プロジェクト未発見
1559
+
1560
+ トリガー後はミニオンの `dag-step-poller` が pending ノードを順次拾って実行する。手動実行も含め、すべての DAG 実行は `dag_executions` テーブル + ダッシュボードの実行履歴で追跡できる。
1561
+
1485
1562
  #### 全操作共通のレスポンス形式
1486
1563
 
1487
1564
  ノード/エッジ操作のレスポンスにはワークフロー全体 + `validation` フィールドが含まれる:
@@ -1682,9 +1759,15 @@ Body:
1682
1759
 
1683
1760
  Response (成功 / 201):
1684
1761
  ```json
1685
- { "success": true, "node_execution_id": "uuid" }
1762
+ {
1763
+ "success": true,
1764
+ "node_execution_id": "uuid",
1765
+ "template_vars": { "PROJECT_VAR_NAME": "value", "WORKSPACE_VAR": "value" }
1766
+ }
1686
1767
  ```
1687
1768
 
1769
+ `template_vars` には claim したノードのコンテキストで解決された **workspace_variables / project_variables / dag_workflow_variables** が narrower-scope-wins (workspace < project < dag_workflow) でマージされて入る。スキルノードの場合は後続の `POST /api/skills/fetch/:name?vars=...` でこの値を base64 JSON として渡し、HQ 側で SKILL.md の `{{VAR}}` を置換する。ミニオンローカル変数はミニオン側で更にレイヤされ、`template_vars` の値を上書きする(cross-scope rule: workspace < project < dag_workflow < minion)。
1770
+
1688
1771
  Response (競合 / 409): 他ミニオンが既に claim 済み、または状態が pending でない場合。
1689
1772
  ```json
1690
1773
  { "error": "Node already claimed or not pending" }
@@ -1949,6 +2032,55 @@ Response:
1949
2032
 
1950
2033
  スキルはバージョン管理される。push ごとに新バージョンが作成され、ファイルは Supabase Storage に保存される。
1951
2034
 
2035
+ **`GET /api/minion/skills/:name` レスポンス**:
2036
+ ```json
2037
+ {
2038
+ "id": "<skill-uuid>",
2039
+ "current_version_id": "<skill-version-uuid>",
2040
+ "name": "variable-injection-test",
2041
+ "display_name": "Variable Injection Test",
2042
+ "type": "workflow",
2043
+ "description": "...",
2044
+ "content": "...",
2045
+ "files": [{ "path": "files/extra.md", "content": "..." }]
2046
+ }
2047
+ ```
2048
+
2049
+ **`POST /api/minion/skills` レスポンス**:
2050
+ ```json
2051
+ {
2052
+ "success": true,
2053
+ "skill": {
2054
+ "id": "<skill-uuid>",
2055
+ "name": "variable-injection-test",
2056
+ "workspace_id": "<workspace-uuid>",
2057
+ "current_version_id": "<skill-version-uuid>",
2058
+ "version": 3
2059
+ }
2060
+ }
2061
+ ```
2062
+
2063
+ スキルを push してそのまま DAG ノードに組み込む典型フロー:
2064
+
2065
+ ```bash
2066
+ # 1. push してスキルIDを得る
2067
+ SKILL_ID=$(curl -s -X POST -H "Authorization: Bearer $API_TOKEN" -H "Content-Type: application/json" \
2068
+ $HQ_URL/api/minion/skills -d '{"name":"my-skill","content":"..."}' | jq -r '.skill.id')
2069
+
2070
+ # 2. DAG ノードを追加 (skill_version_id は省略 = 常に最新を追従)
2071
+ curl -X POST -H "Authorization: Bearer $API_TOKEN" -H "Content-Type: application/json" \
2072
+ $HQ_URL/api/minion/dag-workflows/$DAG_ID/nodes \
2073
+ -d "{\"type\":\"skill\",\"skill_id\":\"$SKILL_ID\",\"assigned_role\":\"engineer\",\"after\":\"start\",\"before\":\"end\"}"
2074
+ ```
2075
+
2076
+ **スキルバージョンの pin / latest 追従** (DAGスキルノード):
2077
+
2078
+ DAGスキルノードの `skill_version_id` は **オプション** です。
2079
+ - `skill_version_id` を **省略 / null** にすると、実行時に常に skill の `current_version_id` (最新版) を fetch する(**latest auto-track**)。スキルを push して新バージョンを公開すると、次のノード実行から自動で反映される。
2080
+ - `skill_version_id` を **明示的に指定** すると、その特定バージョンに pin される(将来の pinned 実行向け。現状ランタイムは latest 解決を使うが、カラムは保持される)。
2081
+
2082
+ 旧来の挙動(publish 時に skill_version_id 必須)は廃止済み。`skill_id` のみ指定すれば DAG publish できる。
2083
+
1952
2084
  ### Threads (HQ)
1953
2085
 
1954
2086
  | Method | Endpoint | Description |
@@ -2206,3 +2338,22 @@ POST レスポンス例:
2206
2338
  | 409 | `version_conflict` (他者の編集と衝突)、`name_conflict`、`order_key_collision` (同時挿入の競合、再送可) |
2207
2339
  | 410 | `deck_in_trash` (デッキがゴミ箱にある) |
2208
2340
 
2341
+ ### Accounting Receipts 🧪 (HQ, experimental)
2342
+
2343
+ `workspaces.feature_flags.experimental_accounting = true` のワークスペース向け。
2344
+ レシート (画像/PDF) の一覧取得・ダウンロード・取引紐付けをBearer認証で行える。
2345
+ **典型用途**: 人間が `/accounting/receipts` から大量アップロードした未仕訳レシートを
2346
+ ミニオン側で OCR → 仕訳作成 → 紐付け、という記帳ワークフロー。
2347
+
2348
+ | Method | Endpoint | 説明 |
2349
+ |--------|----------|-------------|
2350
+ | GET | `/api/minion/workspaces/:id/accounting/receipts` | レシート一覧。Query: `?attached=true\|false\|all` (default `false`), `?limit=100` (max 500) |
2351
+ | GET | `/api/minion/workspaces/:id/accounting/receipts/:receiptId` | メタデータ |
2352
+ | GET | `/api/minion/workspaces/:id/accounting/receipts/:receiptId/download` | 60秒有効な signed URL を返す (`{ url, mime_type, file_name, expires_in_seconds }`) |
2353
+ | PATCH | `/api/minion/workspaces/:id/accounting/receipts/:receiptId` | 取引と紐付け / 解除。Body: `{ entry_id: string \| null }`。entry_id 指定時は同じ book に属する取引でないと 400 |
2354
+
2355
+ レシートのMIME種別は `image/png`, `image/jpeg`, `image/webp`, `image/gif`, `image/heic`, `image/heif`, `application/pdf` のいずれか。
2356
+
2357
+ **未実装**: ミニオン向け仕訳作成 API (`POST /api/minion/workspaces/:id/accounting/entries`) は現状未実装。
2358
+ OCR後の仕訳作成は、当面ユーザー操作で `/accounting/new` から行うか、HQ管理者向けの Supabase session 経由のみ。
2359
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geekbeer/minion",
3
- "version": "3.60.4",
3
+ "version": "4.0.1",
4
4
  "description": "AI Agent runtime for Minion - manages status and skill deployment on VPS",
5
5
  "main": "linux/server.js",
6
6
  "bin": {
@@ -57,5 +57,5 @@
57
57
  "claude",
58
58
  "automation"
59
59
  ],
60
- "license": "MIT"
60
+ "license": "Elastic-2.0"
61
61
  }
package/rules/core.md CHANGED
@@ -32,6 +32,7 @@ Minion
32
32
  - **transform ノードの I/O 型は edge の contract から自動導出**。incoming edge と outgoing edge にそれぞれ contract を必ず貼ること。`transform_instruction` は contract だけで意図が伝わらない場合の補足ヒント(任意)
33
33
  - **script ノード (v3.54.0〜)** は LLM を使わない決定的処理用。`script_runtime` (`'python'` or `'node'`) と `script_source` を指定。input_data を stdin で JSON 受け取り → output_data を stdout に JSON 出力する規約。outgoing edge に contract を貼れば transform と同じ runtime validation が走る。LLMトークンを節約したい・出力ブレを許容できない定型処理に使う。詳細は `~/.minion/docs/task-guides.md` の「Script ノード」を参照
34
34
  - **fan_out の incoming edge に contract を貼る場合**、`fan_out_source` が指すフィールドが contract 内に `type='array'` として宣言されている必要がある(静的検証で弾かれる)
35
+ - **スキルノードの skill_version_id は省略可** (v3.60.8〜)。省略するとランタイムが常に skill の最新バージョンを fetch する(latest auto-track)。特定バージョンに pin したい場合のみ明示指定する。`POST /api/minion/skills` のレスポンスで `skill.id` (skill_id) と `skill.current_version_id` の両方が返るので、auto-track 運用なら前者だけ使えばよい
35
36
  - **Routine**: ミニオンスコープ。ミニオンローカルの定期タスク。
36
37
  - **Project Tasks / Milestones / Sprints**: プロジェクトスコープ。**人間+ミニオンが共有するタスクボード**(5段階Kanban: `backlog`→`todo`→`doing`→`review`→`done`)、ロードマップ(マイルストーン)、アジャイル運用単位(スプリント)。ミニオンは `/api/minion/projects/:projectId/{tasks,milestones,sprints,health}` で操作可能。
37
38
  - PMロールは朝のチェックで `/health` を叩いて遅延・停滞タスクを把握、ユーザー要望をエピック+子タスクに分解、スプリントに割り当てて active 化
@@ -225,6 +226,8 @@ Routine 実行中は以下もtmuxセッション環境で利用可能:
225
226
 
226
227
  **変数**(ワークスペース変数・プロジェクト変数・ワークフロー変数・ミニオン変数)はスキル本文の `{{VAR_NAME}}` テンプレートとして実行時に展開される。スキル作成時にパラメータ化したい値は `{{変数名}}` で記述すること。展開優先順位: ワークスペース < プロジェクト < ワークフロー < ミニオン(後者が優先)。ミニオンが最終オーバーライドとなる設計で、ミニオン運用者がHQ側のデフォルトを差し替えられる経路を保証する。ミニオン変数はさらにミニオン全体スコープとワークスペース別スコープに分かれ、当該ワークスペースのコンテキストで動く実行時はWS別がミニオン全体を上書きする。`/api/variables/*` は `?workspace_id=<uuid>` でスコープ指定(省略時はミニオン全体)。
227
228
 
229
+ DAGワークフローでは、HQ側スコープ(workspace/project/dag_workflow)の変数は **`POST /api/dag/minion/claim-node` のレスポンス `template_vars`** に乗って降ってきて、ミニオン側で minion-local 変数とマージしたうえで `POST /api/skills/fetch/:name?vars=...` の base64 JSON に詰めて HQ に渡し、HQ 側で SKILL.md の `{{VAR}}` を置換して返す。つまり HQ-scope 変数の更新は **次のノード claim から反映される**(既存のミニオン上 SKILL.md は次回 fetch で上書きされる)。DAGワークフロー単位の変数は `dag_workflow_variables` テーブルに格納され、DAGエディタの "Variables" ボタンから編集可能。
230
+
228
231
  **シークレット**はワークスペース別にスコープされ、ミニオンローカルのSQLite (`secrets(workspace_id, key, value)`) に保存される。ワークスペース未指定(`workspace_id=''`)はミニオン全体のスコープで、サーバー起動時に `process.env` にロードされ全子プロセスで `$SECRET_NAME` として利用可能。ワークスペース別シークレット(`workspace_id=<uuid>`)は `process.env` にはロードされず、当該ワークスペースのコンテキストで動くランナー(ワークフロー/WSバインドされたルーティン/チャットセッション)にのみ実行時注入される。同名キーが両スコープに存在する場合はワークスペース別が優先。スキル側は常に `$KEY` で参照すればよく、どちらのスコープから来た値かを意識する必要はない。シークレット値はHQ DBに保存されることはなく、HQはpass-throughとして中継するのみ。
229
232
 
230
233
  デイリーログやメモリーから変数・シークレットの値を推測して使用してはならない。変数は `{{VAR_NAME}}` テンプレートとして定義し、シークレットは環境変数として参照すること。