@qwen-code/qwen-code 0.18.0-preview.2 → 0.18.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/bundled/loop/SKILL.md +2 -1
- package/bundled/qc-helper/docs/_meta.ts +1 -0
- package/bundled/qc-helper/docs/configuration/auth.md +1 -1
- package/bundled/qc-helper/docs/configuration/model-providers.md +12 -5
- package/bundled/qc-helper/docs/configuration/settings.md +33 -32
- package/bundled/qc-helper/docs/features/approval-mode.md +10 -14
- package/bundled/qc-helper/docs/features/commands.md +33 -11
- package/bundled/qc-helper/docs/features/dual-output.md +37 -3
- package/bundled/qc-helper/docs/features/followup-suggestions.md +2 -2
- package/bundled/qc-helper/docs/features/skills.md +29 -3
- package/bundled/qc-helper/docs/features/sub-agents.md +34 -12
- package/bundled/qc-helper/docs/qwen-serve-deploy-local.md +221 -0
- package/bundled/qc-helper/docs/qwen-serve.md +246 -28
- package/chunks/{agent-QB7TZ4HW.js → agent-XT7NHZ5H.js} +25 -24
- package/chunks/agent-headless-LNRE63ZL.js +51 -0
- package/chunks/{anthropicContentGenerator-M45EVVRM.js → anthropicContentGenerator-DCI26OQF.js} +7 -7
- package/chunks/{askUserQuestion-WM2KHM3K.js → askUserQuestion-ITYUTWLR.js} +45 -3
- package/chunks/{ca-BARBRL6N.js → ca-RK4QPLIX.js} +18 -1
- package/chunks/{chunk-CWV3SJZS.js → chunk-3NRO6NHX.js} +2 -2
- package/chunks/{chunk-BNESGOSJ.js → chunk-55ZMG67I.js} +1 -1
- package/chunks/{chunk-QCG6KPNM.js → chunk-6T7Y7USE.js} +18017 -11621
- package/chunks/{chunk-CNHFPN7T.js → chunk-7KPZFE5A.js} +1 -1
- package/chunks/{chunk-2ZTWI7KH.js → chunk-A2ZIEEGJ.js} +30 -22
- package/chunks/{chunk-JUGRPQAB.js → chunk-B4ZF2KSI.js} +1 -1
- package/chunks/chunk-BJ5HQ23U.js +178 -0
- package/chunks/{chunk-HXJE7VOG.js → chunk-BXYRCW2C.js} +1074 -144
- package/chunks/{chunk-ICOI4E4S.js → chunk-CPVI5J2L.js} +101 -23
- package/chunks/{chunk-HV3ZZ7G4.js → chunk-DHZREJTG.js} +2 -2
- package/chunks/{chunk-GX7VH5JQ.js → chunk-FIQECJTQ.js} +1 -1
- package/chunks/{chunk-SZOEIL6S.js → chunk-H6BD2ELD.js} +1 -0
- package/chunks/{chunk-JXAZUMDW.js → chunk-HA2UEYZP.js} +7 -4
- package/chunks/{chunk-USE2VQ5P.js → chunk-HED55F43.js} +26 -1
- package/chunks/{chunk-PAEBHDIO.js → chunk-HQUWWSSP.js} +1 -1
- package/chunks/{chunk-MVIVIPCU.js → chunk-IDYDPBBN.js} +361 -583
- package/chunks/{chunk-JVQOQ3OU.js → chunk-IQHSD7K5.js} +1 -1
- package/chunks/{chunk-NW5QBUYO.js → chunk-IS7UA4W3.js} +14 -14
- package/chunks/{chunk-UAMOBVVW.js → chunk-LXYWINWF.js} +1 -1
- package/chunks/{chunk-P4J26VDS.js → chunk-LYRSMKLS.js} +2 -2
- package/chunks/{chunk-Y7R6H6FT.js → chunk-LYSND7KR.js} +9 -4
- package/chunks/{chunk-LR62TEET.js → chunk-NNIYWQIS.js} +1 -1
- package/chunks/chunk-OMX7CUOE.js +356 -0
- package/chunks/{chunk-CNSMKPK6.js → chunk-QILTEBWS.js} +1 -1
- package/chunks/chunk-QQDPRDVW.js +25 -0
- package/chunks/{chunk-ZK4AMNIU.js → chunk-RON7LFNH.js} +1294 -314
- package/chunks/chunk-SFRV6BGY.js +243 -0
- package/chunks/{chunk-AVW55ZCO.js → chunk-WJ3SND6W.js} +37 -16
- package/chunks/{chunk-HGJPQK33.js → chunk-WPTCDQN6.js} +188 -534
- package/chunks/{chunk-7YKXFA3D.js → chunk-XZTNBSMW.js} +11 -11
- package/chunks/{chunk-C6WMLUNB.js → chunk-Y7KMDUEP.js} +1 -1
- package/chunks/{chunk-WFVXF3OM.js → chunk-Z2Z3GUXZ.js} +1 -0
- package/chunks/{chunk-KC6ZMJ5X.js → chunk-ZMIBJS45.js} +1 -1
- package/chunks/chunk-ZOFNJQNJ.js +607 -0
- package/chunks/computer-use-4YX3JGBV.js +2052 -0
- package/chunks/contextCommand-KS2H7MW5.js +53 -0
- package/chunks/cron-create-CAPUKK7I.js +184 -0
- package/chunks/{cron-delete-ZGUXWBTG.js → cron-delete-G3KAR26Q.js} +28 -5
- package/chunks/{cron-list-QNNZGMN3.js → cron-list-ZA4ZIUS5.js} +40 -7
- package/chunks/{de-YGKK2BC4.js → de-FGPM4KW5.js} +18 -1
- package/chunks/{devtools-IXE4UP72.js → devtools-FM6GJPYG.js} +1 -1
- package/chunks/{dist-ZMQ4TXD5.js → dist-7YWFWOCJ.js} +2 -2
- package/chunks/{dist-R2SXPG74.js → dist-VEGFONCF.js} +2 -2
- package/chunks/{dist-TE5QKMGR.js → dist-X4EXN7W6.js} +1 -1
- package/chunks/{dist-BXDUQ2QY.js → dist-YLS6NI7H.js} +1 -1
- package/chunks/{edit-6UBTS2J5.js → edit-2ARPEO4B.js} +26 -25
- package/chunks/{en-HSQQNQUB.js → en-VP6XPGEC.js} +9 -2
- package/chunks/{enter-worktree-NN7LIXCM.js → enter-worktree-IXNXNAW5.js} +25 -24
- package/chunks/enterPlanMode-TAKAGAYP.js +159 -0
- package/chunks/{exit-worktree-GGSS5KIE.js → exit-worktree-LHTRV7ML.js} +25 -24
- package/chunks/exitPlanMode-MK5UAITL.js +743 -0
- package/chunks/{fr-JXBKPJKQ.js → fr-ATYBVCLT.js} +18 -1
- package/chunks/{geminiContentGenerator-I4H2NLJG.js → geminiContentGenerator-HFJIGO77.js} +7 -7
- package/chunks/{getMachineId-bsd-F7GNPTER.js → getMachineId-bsd-4CASPIU4.js} +1 -1
- package/chunks/{getMachineId-darwin-T73DJL27.js → getMachineId-darwin-HPQPEMZR.js} +1 -1
- package/chunks/{getMachineId-linux-MKQTFPQM.js → getMachineId-linux-AUARKYHL.js} +1 -1
- package/chunks/{getMachineId-unsupported-MUR5KOQE.js → getMachineId-unsupported-S32ZDA2T.js} +1 -1
- package/chunks/{getMachineId-win-CDYFC6ZM.js → getMachineId-win-4EFLHYIJ.js} +1 -1
- package/chunks/{glob-OLCX57MD.js → glob-I2USLUSC.js} +25 -24
- package/chunks/{grep-7HXIMDOW.js → grep-WBIF7THR.js} +37 -30
- package/chunks/{ja-TGPZSP2B.js → ja-W2QEA2OI.js} +18 -1
- package/chunks/{keychain-token-storage-LB46DAEK.js → keychain-token-storage-QSTRHKKL.js} +3 -3
- package/chunks/{ls-6PEZUK6O.js → ls-2R5RHLX5.js} +4 -4
- package/chunks/{lsp-JZSJOVT7.js → lsp-XKH6ZIAN.js} +3 -3
- package/chunks/{monitor-SQO7MVAV.js → monitor-WU7UFATU.js} +25 -24
- package/chunks/{notebook-edit-72L3EBAL.js → notebook-edit-KUHYPXEM.js} +26 -25
- package/chunks/{openaiContentGenerator-FTR7CDWF.js → openaiContentGenerator-5PLHYJQL.js} +15 -15
- package/chunks/{pt-TIBG6BIO.js → pt-ZKEWJFBW.js} +18 -1
- package/chunks/{qwenContentGenerator-U5UFQ566.js → qwenContentGenerator-TSKW73KY.js} +27 -26
- package/chunks/{qwenOAuth2-EFSECGHF.js → qwenOAuth2-KK433U33.js} +6 -5
- package/chunks/{read-file-UA64EEQC.js → read-file-VIPF2PS6.js} +11 -11
- package/chunks/ripGrep-XLIZTYE7.js +49 -0
- package/chunks/{ru-JBCHCK4L.js → ru-VEKTPJ74.js} +18 -1
- package/chunks/{scheduler-VBASHOCA.js → scheduler-O66SLJGU.js} +25 -24
- package/chunks/{send-message-OYJZ5TPG.js → send-message-CTME7DXD.js} +3 -3
- package/chunks/{serve-A7E2OJDR.js → serve-BWOLYT62.js} +13164 -3840
- package/chunks/{shell-3NFOT6F5.js → shell-XE7UYKOO.js} +25 -24
- package/chunks/{skill-RA5YUREY.js → skill-RZWM6XMC.js} +64 -113
- package/chunks/{src-NFCMARMT.js → src-L5P7K4MH.js} +176 -44
- package/chunks/{syntheticOutput-DETQ2YM6.js → syntheticOutput-ZJGSU7OQ.js} +4 -4
- package/chunks/{task-create-Y3ZKTJIG.js → task-create-EE6JEM7G.js} +8 -7
- package/chunks/{task-list-ONXJ3I3A.js → task-list-EESYAC65.js} +7 -6
- package/chunks/{task-stop-UHDC4N5B.js → task-stop-XZVCFFYY.js} +3 -3
- package/chunks/{task-update-TCNOU3P5.js → task-update-EIO4HNE3.js} +21 -9
- package/chunks/{team-create-6SR4OVRG.js → team-create-R2H7Y3SG.js} +28 -26
- package/chunks/{team-delete-EJ4U4DDP.js → team-delete-A7LXPGV7.js} +9 -6
- package/chunks/{todoWrite-TEYDRS5L.js → todoWrite-VRKSGAWM.js} +5 -5
- package/chunks/{tool-search-OD435A3X.js → tool-search-USSQMTMS.js} +11 -11
- package/chunks/{web-fetch-6W67H5PO.js → web-fetch-GHAZUA54.js} +5 -5
- package/chunks/workflow-5LNNLNUR.js +1414 -0
- package/chunks/{write-file-475L5OPP.js → write-file-2I7HP24C.js} +26 -25
- package/chunks/{zh-VCLWO26Y.js → zh-OIXDDQHB.js} +10 -3
- package/chunks/{zh-TW-G3HFHVVT.js → zh-TW-6YFNCKTA.js} +10 -3
- package/cli-entry.js +19 -0
- package/cli.js +11064 -6628
- package/examples/starter/QWEN.md +30 -0
- package/examples/starter/README.md +59 -0
- package/examples/starter/agents/diary.md +86 -0
- package/examples/starter/commands/writing/polish.md +13 -0
- package/examples/starter/example.ts +64 -0
- package/examples/starter/package.json +18 -0
- package/examples/starter/qwen-extension.json +12 -0
- package/examples/starter/skills/synonyms/SKILL.md +48 -0
- package/examples/starter/tsconfig.json +13 -0
- package/fzfWorker.js +1083 -0
- package/locales/ca.js +20 -2
- package/locales/de.js +21 -2
- package/locales/en.js +13 -4
- package/locales/fr.js +22 -2
- package/locales/ja.js +22 -2
- package/locales/pt.js +21 -2
- package/locales/ru.js +20 -2
- package/locales/zh-TW.js +11 -4
- package/locales/zh.js +11 -4
- package/package.json +5 -3
- package/chunks/agent-headless-APVHH7QM.js +0 -50
- package/chunks/chunk-AJIR24J2.js +0 -59
- package/chunks/chunk-SKBPNJEW.js +0 -45
- package/chunks/chunk-XBFVXFB2.js +0 -216
- package/chunks/computer-use-B7VIUI7F.js +0 -825
- package/chunks/contextCommand-63RZ3O5R.js +0 -52
- package/chunks/cron-create-FI5LJVUS.js +0 -140
- package/chunks/exitPlanMode-H323NHB2.js +0 -235
- package/chunks/ripGrep-WSYCWZVK.js +0 -48
- package/chunks/workflow-62DHH4EO.js +0 -708
|
@@ -135,7 +135,7 @@ Subagents are configured using Markdown files with YAML frontmatter. This format
|
|
|
135
135
|
name: agent-name
|
|
136
136
|
description: Brief description of when and how to use this agent
|
|
137
137
|
model: inherit # Optional: inherit, fast, modelId, or authType:modelId
|
|
138
|
-
approvalMode: auto-edit # Optional: default, plan, auto-edit, yolo
|
|
138
|
+
approvalMode: auto-edit # Optional: default, plan, auto-edit, yolo, bubble
|
|
139
139
|
tools: # Optional: allowlist of tools
|
|
140
140
|
- tool1
|
|
141
141
|
- tool2
|
|
@@ -202,6 +202,7 @@ Use the optional `approvalMode` frontmatter field to control how a subagent's to
|
|
|
202
202
|
- `plan`: Analyze-only mode — the agent plans but does not execute changes
|
|
203
203
|
- `auto-edit`: Tools are auto-approved without prompting (recommended for most agents)
|
|
204
204
|
- `yolo`: All tools auto-approved, including potentially destructive ones
|
|
205
|
+
- `bubble`: Background-agent tool approvals are surfaced in the parent session
|
|
205
206
|
|
|
206
207
|
If you omit this field, the subagent's permission mode is determined automatically:
|
|
207
208
|
|
|
@@ -282,13 +283,15 @@ can drop a CC agent file into `.qwen/agents/` and have the supported fields
|
|
|
282
283
|
parse identically. Optional fields with invalid values are silently dropped
|
|
283
284
|
at parse time rather than rejected — the same lenient posture CC uses.
|
|
284
285
|
|
|
285
|
-
| Field | Type | Notes
|
|
286
|
-
| ---------------- | ---------------- |
|
|
287
|
-
| `permissionMode` | enum string | `acceptEdits`, `auto`, `bypassPermissions`, `default`, `dontAsk`, `plan`. Mapped to `approvalMode` at parse time; when both are set, the explicit `approvalMode` wins.
|
|
288
|
-
| `maxTurns` | positive integer | Caps the agent's turn budget. Wired into `runConfig.max_turns` at runtime; when both are set, the top-level field wins.
|
|
289
|
-
| `color` | enum string | Display color. Allowlist: `red`, `blue`, `green`, `yellow`, `purple`, `orange`, `pink`, `cyan` (mirrors CC's `_Y`). The legacy qwen sentinel `auto` is
|
|
286
|
+
| Field | Type | Notes |
|
|
287
|
+
| ---------------- | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
288
|
+
| `permissionMode` | enum string | `acceptEdits`, `auto`, `bypassPermissions`, `default`, `dontAsk`, `plan`. Mapped to `approvalMode` at parse time; when both are set, the explicit `approvalMode` wins. |
|
|
289
|
+
| `maxTurns` | positive integer | Caps the agent's turn budget. Wired into `runConfig.max_turns` at runtime; when both are set, the top-level field wins. The legacy nested value is pruned from the on-disk file on save to avoid two sources of truth. |
|
|
290
|
+
| `color` | enum string | Display color. Allowlist: `red`, `blue`, `green`, `yellow`, `purple`, `orange`, `pink`, `cyan` (mirrors CC's `_Y`). The legacy qwen sentinel `auto` is preserved for backward compatibility. Other values are silently dropped on parse. |
|
|
291
|
+
| `mcpServers` | record of specs | Per-agent MCP server overrides. Merged with the session-level MCP server set when the agent spawns; on key collision the agent's spec wins (matching CC's `scope: 'agent'` semantics). Malformed entries are dropped per-key with a warning rather than failing the whole agent. |
|
|
292
|
+
| `hooks` | record of arrays | Per-agent hooks. Keys are CC hook event names (`PreToolUse`, `PostToolUse`, `UserPromptSubmit`, …); values are arrays of `{ matcher?, hooks: [...] }` definitions in the same shape as `settings.json`'s `hooks` field. Registered while the agent runs, removed when it stops. |
|
|
290
293
|
|
|
291
|
-
Example:
|
|
294
|
+
Example with all of the above:
|
|
292
295
|
|
|
293
296
|
```
|
|
294
297
|
---
|
|
@@ -301,6 +304,17 @@ tools:
|
|
|
301
304
|
- read_file
|
|
302
305
|
- grep_search
|
|
303
306
|
- glob
|
|
307
|
+
mcpServers:
|
|
308
|
+
filesystem:
|
|
309
|
+
type: stdio
|
|
310
|
+
command: node
|
|
311
|
+
args: [/usr/local/lib/mcp-fs/server.js]
|
|
312
|
+
hooks:
|
|
313
|
+
PreToolUse:
|
|
314
|
+
- matcher: Bash
|
|
315
|
+
hooks:
|
|
316
|
+
- type: command
|
|
317
|
+
command: echo "review-agent about to run a shell command"
|
|
304
318
|
---
|
|
305
319
|
|
|
306
320
|
You are a code reviewer. Analyze the code thoroughly and report findings
|
|
@@ -308,11 +322,19 @@ ordered by severity.
|
|
|
308
322
|
```
|
|
309
323
|
|
|
310
324
|
The remaining CC frontmatter fields — `effort`, `skills`, `initialPrompt`,
|
|
311
|
-
`memory`, `isolation
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
325
|
+
`memory`, `isolation` — are documented in the declarative-agent design doc
|
|
326
|
+
and land in follow-up PRs once the prerequisite infrastructure exists
|
|
327
|
+
(`effort` needs a model-layer parameter; `memory` needs a scoped memory
|
|
328
|
+
subsystem; `--agent` CLI flag enables `initialPrompt`; etc.).
|
|
329
|
+
|
|
330
|
+
> **`hooks` v1 limitation.** While a subagent declaring `hooks` is running,
|
|
331
|
+
> its hook entries fire for every matching event in the session, not only
|
|
332
|
+
> for that subagent's own tool calls. If two subagents with different
|
|
333
|
+
> per-agent hook sets run concurrently, both sets fire for both agents.
|
|
334
|
+
> Per-agent scope filtering at hook-firing time is left to a follow-up;
|
|
335
|
+
> for v1, prefer per-agent hooks that are safe to fire globally for the
|
|
336
|
+
> duration of the agent's run (e.g. logging) over hooks that mutate
|
|
337
|
+
> behavior.
|
|
316
338
|
|
|
317
339
|
#### Example Usage
|
|
318
340
|
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# Local launch templates for `qwen serve` (v0.16-alpha)
|
|
2
|
+
|
|
3
|
+
Reference templates for running `qwen serve` as a long-lived background process on a developer workstation. Pairs with the [v0.16-alpha known limits](./qwen-serve.md#v016-alpha-known-limits) — local-only, single-user, BYO bearer token. Containerized / multi-host / TLS-fronted deployments defer to v0.16.x.
|
|
4
|
+
|
|
5
|
+
> **Audience**: dogfooding developers who want the daemon up across reboots, with logs going somewhere durable, and a clean `restart-on-failure` story. If you only need the daemon for the duration of a single shell session, plain `qwen serve` (foreground, Ctrl-C to stop) is fine.
|
|
6
|
+
|
|
7
|
+
## Generate a bearer token (once)
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
openssl rand -hex 32 > ~/.qwen-serve-token # user-managed, NOT a built-in path
|
|
11
|
+
chmod 600 ~/.qwen-serve-token
|
|
12
|
+
export QWEN_SERVER_TOKEN="$(cat ~/.qwen-serve-token)"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The path / filename is yours to choose; v0.16-alpha does not auto-generate or auto-locate a token file (deferred to v0.16.x). See the [Authentication](./qwen-serve.md#authentication) section of the user guide for the canonical BYO setup.
|
|
16
|
+
|
|
17
|
+
> **Scope this `export` to the current shell session only.** Don't add it to `~/.bashrc` / `~/.zshrc` — a profile-level export exposes the bearer token to every process spawned from that shell (IDE subprocesses, browser debuggers, `npm` scripts from unrelated projects). For long-running setups, use the systemd `EnvironmentFile=` / launchd `EnvironmentVariables` mechanisms below — both scope the token to just the daemon process.
|
|
18
|
+
|
|
19
|
+
The daemon reads the bearer token from either `--token <value>` on the CLI or the `QWEN_SERVER_TOKEN` env var (whitespace stripped from both). The TypeScript SDK's `DaemonClient` constructor falls back to `QWEN_SERVER_TOKEN` when no `token` option is passed (PR 27 fallback — clients with the env var set never need to thread the value through their script).
|
|
20
|
+
|
|
21
|
+
One shell-level `export` covers both server boot and SDK client construction (just keep it scoped to the session, per the note above).
|
|
22
|
+
|
|
23
|
+
## Linux: systemd user unit
|
|
24
|
+
|
|
25
|
+
> **Find your `qwen` binary first.** The unit file's `ExecStart=` must hold an **absolute path** — service managers don't read your shell's `PATH`. Run `which qwen` to discover it. Common locations: `/usr/local/bin/qwen` (Linuxbrew, manual installs), `~/.nvm/versions/node/vX.Y.Z/bin/qwen` (nvm), `~/.fnm/aliases/default/bin/qwen` (fnm), `~/.volta/bin/qwen` (Volta). Substitute the actual path everywhere the templates below show `/PATH/TO/qwen`.
|
|
26
|
+
|
|
27
|
+
`~/.config/systemd/user/qwen-serve.service`:
|
|
28
|
+
|
|
29
|
+
```ini
|
|
30
|
+
[Unit]
|
|
31
|
+
Description=Qwen Code daemon (loopback HTTP + SSE)
|
|
32
|
+
After=network.target
|
|
33
|
+
|
|
34
|
+
[Service]
|
|
35
|
+
Type=simple
|
|
36
|
+
# Replace with your project; %h expands to $HOME under user units.
|
|
37
|
+
WorkingDirectory=%h/your-project
|
|
38
|
+
# Run `which qwen` to find the absolute path. systemd does NOT read $PATH.
|
|
39
|
+
ExecStart=/PATH/TO/qwen serve --hostname 127.0.0.1 --port 4170
|
|
40
|
+
# Read the bearer token from a chmod 600 file rather than inlining it
|
|
41
|
+
# in the unit. `Environment=` would expose the token in the unit file
|
|
42
|
+
# (typically 644 = world-readable). EnvironmentFile keeps the token in
|
|
43
|
+
# the user-owned secret file you already created with `chmod 600`.
|
|
44
|
+
EnvironmentFile=%h/.qwen-serve-token-env
|
|
45
|
+
Restart=on-failure
|
|
46
|
+
RestartSec=5
|
|
47
|
+
StandardOutput=journal
|
|
48
|
+
StandardError=journal
|
|
49
|
+
|
|
50
|
+
[Install]
|
|
51
|
+
WantedBy=default.target
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Build the env file once (the token file from the setup step holds the raw value; this wraps it in `KEY=value` form so systemd reads it as an env assignment):
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
echo "QWEN_SERVER_TOKEN=$(cat ~/.qwen-serve-token)" > ~/.qwen-serve-token-env
|
|
58
|
+
chmod 600 ~/.qwen-serve-token-env
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Manage:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
systemctl --user daemon-reload
|
|
65
|
+
systemctl --user enable --now qwen-serve.service
|
|
66
|
+
loginctl enable-linger "$(whoami)" # keep the user manager running after logout / across reboot
|
|
67
|
+
journalctl --user -u qwen-serve -f # tail logs
|
|
68
|
+
systemctl --user restart qwen-serve.service # after token rotation
|
|
69
|
+
systemctl --user disable --now qwen-serve.service
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Without `loginctl enable-linger`, the user-level systemd instance shuts down when the user logs out and only restarts on next login — on a headless dev box the daemon would not survive an SSH session ending. `enable-linger` is what makes "across reboots" actually work.
|
|
73
|
+
|
|
74
|
+
**System-wide alternative** (shared dev hosts, less common): drop the unit at `/etc/systemd/system/qwen-serve@.service` with `User=%i`, manage via `sudo systemctl enable --now qwen-serve@<username>.service`. Same `[Service]` body otherwise — but world-readable `Environment=` exposure is even more problematic at this level, so always use `EnvironmentFile=` pointing at the user's `chmod 600` file. Pick user-level + linger for single-user workstations.
|
|
75
|
+
|
|
76
|
+
## macOS: launchd user agent
|
|
77
|
+
|
|
78
|
+
> **Find your `qwen` binary first.** Same constraint as systemd — `ProgramArguments` must hold an **absolute path**. Run `which qwen` to discover it. Common locations on macOS: `/opt/homebrew/bin/qwen` (Homebrew on Apple Silicon), `/usr/local/bin/qwen` (Homebrew on Intel, manual installs), `~/.nvm/versions/node/vX.Y.Z/bin/qwen` (nvm), `~/.volta/bin/qwen` (Volta). Substitute below where the template shows `/PATH/TO/qwen`.
|
|
79
|
+
|
|
80
|
+
`~/Library/LaunchAgents/com.qwenlm.qwen-serve.plist`:
|
|
81
|
+
|
|
82
|
+
```xml
|
|
83
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
84
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
85
|
+
<plist version="1.0">
|
|
86
|
+
<dict>
|
|
87
|
+
<key>Label</key>
|
|
88
|
+
<string>com.qwenlm.qwen-serve</string>
|
|
89
|
+
<key>ProgramArguments</key>
|
|
90
|
+
<array>
|
|
91
|
+
<!-- Run `which qwen` to find the absolute path; launchd does NOT read $PATH. -->
|
|
92
|
+
<string>/PATH/TO/qwen</string>
|
|
93
|
+
<string>serve</string>
|
|
94
|
+
<string>--hostname</string>
|
|
95
|
+
<string>127.0.0.1</string>
|
|
96
|
+
<string>--port</string>
|
|
97
|
+
<string>4170</string>
|
|
98
|
+
</array>
|
|
99
|
+
<!-- launchd does NOT expand `~` or `$HOME` — use absolute paths. -->
|
|
100
|
+
<key>WorkingDirectory</key>
|
|
101
|
+
<string>/Users/YOUR-USERNAME/your-project</string>
|
|
102
|
+
<key>EnvironmentVariables</key>
|
|
103
|
+
<dict>
|
|
104
|
+
<!-- DO NOT COMMIT this file with a real token. Also chmod 600 the
|
|
105
|
+
plist itself so the inlined token is not world-readable. -->
|
|
106
|
+
<key>QWEN_SERVER_TOKEN</key>
|
|
107
|
+
<string>PASTE-YOUR-TOKEN-HERE</string>
|
|
108
|
+
</dict>
|
|
109
|
+
<key>RunAtLoad</key>
|
|
110
|
+
<true/>
|
|
111
|
+
<!-- Restart only on non-zero exits (matches systemd Restart=on-failure).
|
|
112
|
+
A bare `<true/>` would respawn even after a clean SIGTERM, making
|
|
113
|
+
`kill <pid>` impossible to use as a stop signal — operator would
|
|
114
|
+
have to `launchctl unload`. SuccessfulExit=false fixes that. -->
|
|
115
|
+
<key>KeepAlive</key>
|
|
116
|
+
<dict>
|
|
117
|
+
<key>SuccessfulExit</key>
|
|
118
|
+
<false/>
|
|
119
|
+
</dict>
|
|
120
|
+
<!-- Throttle restart storms on persistent failures (mirrors systemd
|
|
121
|
+
RestartSec=5; launchd's default would respawn every <1s). -->
|
|
122
|
+
<key>ThrottleInterval</key>
|
|
123
|
+
<integer>10</integer>
|
|
124
|
+
<!-- Log into the user's Library, not /tmp. /tmp is world-writable
|
|
125
|
+
(symlink-attack risk on shared workstations) and gets cleaned by
|
|
126
|
+
periodic-daily after 3 days; `~/Library/Logs/qwen-serve/` is
|
|
127
|
+
user-scoped and survives. launchd truncates these on every
|
|
128
|
+
`load`, so the unload→load token-rotation cycle wipes prior
|
|
129
|
+
diagnostic logs — back them up if you need post-incident
|
|
130
|
+
inspection. -->
|
|
131
|
+
<key>StandardOutPath</key>
|
|
132
|
+
<string>/Users/YOUR-USERNAME/Library/Logs/qwen-serve/out.log</string>
|
|
133
|
+
<key>StandardErrorPath</key>
|
|
134
|
+
<string>/Users/YOUR-USERNAME/Library/Logs/qwen-serve/err.log</string>
|
|
135
|
+
</dict>
|
|
136
|
+
</plist>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Manage:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
mkdir -p ~/Library/Logs/qwen-serve # first time only
|
|
143
|
+
chmod 600 ~/Library/LaunchAgents/com.qwenlm.qwen-serve.plist # plist holds the inline token
|
|
144
|
+
launchctl load ~/Library/LaunchAgents/com.qwenlm.qwen-serve.plist
|
|
145
|
+
launchctl unload ~/Library/LaunchAgents/com.qwenlm.qwen-serve.plist # to stop
|
|
146
|
+
tail -f ~/Library/Logs/qwen-serve/out.log ~/Library/Logs/qwen-serve/err.log
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
After editing the plist (e.g., rotating the token) you must `unload` then `load` again — `launchctl` does not auto-reload on plist changes the way `systemd daemon-reload` does. Note: each `load` truncates the log files, so save them off if you're investigating an incident before rotating.
|
|
150
|
+
|
|
151
|
+
## tmux session (interactive supervision)
|
|
152
|
+
|
|
153
|
+
Assumes `QWEN_SERVER_TOKEN` is already exported in your shell (see the setup section above):
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
tmux new -d -s qwen-serve "cd ~/your-project && qwen serve --hostname 127.0.0.1"
|
|
157
|
+
tmux attach -t qwen-serve # see live logs; Ctrl-b d to detach
|
|
158
|
+
tmux kill-session -t qwen-serve
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
`tmux new -d` inherits the parent shell's environment, so `QWEN_SERVER_TOKEN` flows through automatically. Best when you want to occasionally watch the daemon's stdout (auth warnings, MCP discovery progress, slow-client warnings) without committing to a service unit. Survives terminal close but not host reboot.
|
|
162
|
+
|
|
163
|
+
## nohup one-liner (quick + dirty)
|
|
164
|
+
|
|
165
|
+
Assumes `QWEN_SERVER_TOKEN` is already exported in your shell:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
nohup bash -c 'cd ~/your-project && qwen serve --hostname 127.0.0.1' > qwen-serve.log 2>&1 &
|
|
169
|
+
echo $! # daemon PID; capture if you want to `kill` cleanly later
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
The wrapping `bash -c '...'` ensures the daemon binds to `~/your-project` rather than wherever you happened to run the command. Without that `cd`, `qwen serve` defaults to `process.cwd()` and a `POST /session` from a client expecting your project workspace returns `400 workspace_mismatch` — silent foot-gun.
|
|
173
|
+
|
|
174
|
+
OK for one-off "let me run this in the background while I poke at the API" workflows. **Not recommended** for anything beyond a single session — no restart-on-crash, log file grows unbounded, no clean way to find the daemon if you forget the PID. Prefer tmux for interactive supervision or systemd / launchd for anything you want to outlast a reboot.
|
|
175
|
+
|
|
176
|
+
## Verifying the daemon is up
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
curl http://127.0.0.1:4170/health # → {"status":"ok"}
|
|
180
|
+
curl -H "Authorization: Bearer $QWEN_SERVER_TOKEN" \
|
|
181
|
+
http://127.0.0.1:4170/capabilities | jq .protocolVersions # daemon's feature set
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
When auth is configured (i.e., the daemon was started with `--token` / `QWEN_SERVER_TOKEN` set, OR `--require-auth=true`), every route except `/health` on loopback binds requires `Authorization: Bearer <token>`. If you started the daemon without a token on the loopback default (the `qwen serve` zero-config path), neither call requires a header. The templates above all configure a token, so the `Authorization` header is needed in practice. If `/capabilities` returns `401`, the unit / plist token doesn't match the env-exported token your `curl` is using.
|
|
185
|
+
|
|
186
|
+
## Token rotation
|
|
187
|
+
|
|
188
|
+
1. Generate a new token + write the env file the unit references:
|
|
189
|
+
```bash
|
|
190
|
+
openssl rand -hex 32 > ~/.qwen-serve-token
|
|
191
|
+
chmod 600 ~/.qwen-serve-token
|
|
192
|
+
echo "QWEN_SERVER_TOKEN=$(cat ~/.qwen-serve-token)" > ~/.qwen-serve-token-env
|
|
193
|
+
chmod 600 ~/.qwen-serve-token-env
|
|
194
|
+
```
|
|
195
|
+
(For the launchd / nohup / tmux templates: edit the plist's `<string>` value or re-`export QWEN_SERVER_TOKEN`. Don't forget `chmod 600` on the plist if you regenerate it.)
|
|
196
|
+
2. Restart the daemon:
|
|
197
|
+
- **systemd**: `systemctl --user restart qwen-serve.service`
|
|
198
|
+
- **launchd**: `launchctl unload ~/Library/LaunchAgents/com.qwenlm.qwen-serve.plist && launchctl load ~/Library/LaunchAgents/com.qwenlm.qwen-serve.plist`
|
|
199
|
+
- **tmux / nohup**: `kill <pid>` then re-run with the new token in env
|
|
200
|
+
3. Update any client SDKs / scripts. The TypeScript SDK's `DaemonClient` reads `QWEN_SERVER_TOKEN` automatically (PR 27 fallback) — re-`export` the new value in any client shell and reconstruct the client.
|
|
201
|
+
|
|
202
|
+
## Restart and crash behavior
|
|
203
|
+
|
|
204
|
+
Service-manager restart semantics differ across the templates:
|
|
205
|
+
|
|
206
|
+
- **systemd `Restart=on-failure`** — restart only on non-zero exit / signal. A clean SIGTERM (`systemctl stop`) does **not** trigger a restart loop.
|
|
207
|
+
- **launchd `KeepAlive` with `SuccessfulExit=false`** (the template above) — matches systemd behavior. A bare `<true/>` would have respawned even after a clean exit. `ThrottleInterval=10` rate-limits restart storms on persistent failures, mirroring systemd's `RestartSec=5`.
|
|
208
|
+
- **tmux / nohup** — no automatic restart. A daemon crash leaves you with a dead PID until you re-run.
|
|
209
|
+
|
|
210
|
+
Within a **single daemon process lifetime**, client disconnects recover via SSE `Last-Event-ID` resume per the [Durability model](./qwen-serve.md#durability-model) section of the user guide — the replay ring is in-memory.
|
|
211
|
+
|
|
212
|
+
A daemon **restart** drops all in-memory sessions; clients reconnect and start fresh. Cross-restart durability of session content (prompts, tool calls, conversation history) is **NOT** in v0.16-alpha.
|
|
213
|
+
|
|
214
|
+
## Out of scope (defers to v0.16.x or later)
|
|
215
|
+
|
|
216
|
+
- **Containerized deployment** — Dockerfile, docker-compose, Kubernetes manifests, nginx + TLS reverse proxy, multi-instance token isolation. Defers to v0.16.x once an enterprise pilot is committed; the doc would otherwise rot from no-one-validating.
|
|
217
|
+
- **Cross-host federation / multi-daemon coordination on one host** — `1 daemon = 1 workspace × N sessions` is enforced. Instance-path token keying + stale-token cleanup defer to v0.16.x.
|
|
218
|
+
- **Auto-generated daemon tokens** — alpha is BYO-token. Auto-gen + token-store infrastructure defers to v0.16.x.
|
|
219
|
+
- **Windows native service** (`nssm`, Service Control Manager wrapper) — for now use [WSL2](https://learn.microsoft.com/en-us/windows/wsl/) and follow the systemd section above.
|
|
220
|
+
|
|
221
|
+
See the [v0.16-alpha known limits](./qwen-serve.md#v016-alpha-known-limits) callout in the main user guide for the full deferred-features list, and [#4175](https://github.com/QwenLM/qwen-code/issues/4175) for the v0.16-alpha rollout tracking issue.
|