kward 0.66.0

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.
Files changed (93) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +9 -0
  3. data/CHANGELOG.md +12 -0
  4. data/Gemfile +8 -0
  5. data/Gemfile.lock +90 -0
  6. data/LICENSE +21 -0
  7. data/README.md +101 -0
  8. data/Rakefile +20 -0
  9. data/doc/authentication.md +105 -0
  10. data/doc/code-search.md +56 -0
  11. data/doc/configuration.md +310 -0
  12. data/doc/extensibility.md +186 -0
  13. data/doc/getting-started.md +127 -0
  14. data/doc/memory.md +192 -0
  15. data/doc/plugins.md +223 -0
  16. data/doc/releasing.md +36 -0
  17. data/doc/rpc.md +635 -0
  18. data/doc/usage.md +179 -0
  19. data/doc/web-search.md +28 -0
  20. data/exe/kward +5 -0
  21. data/kward.gemspec +33 -0
  22. data/lib/kward/agent.rb +234 -0
  23. data/lib/kward/ansi.rb +276 -0
  24. data/lib/kward/auth/file.rb +11 -0
  25. data/lib/kward/auth/github_oauth.rb +222 -0
  26. data/lib/kward/auth/openai_oauth.rb +323 -0
  27. data/lib/kward/auth/openrouter_api_key.rb +40 -0
  28. data/lib/kward/cancellation.rb +54 -0
  29. data/lib/kward/cli.rb +2122 -0
  30. data/lib/kward/clipboard.rb +84 -0
  31. data/lib/kward/compactor.rb +998 -0
  32. data/lib/kward/config_files.rb +564 -0
  33. data/lib/kward/conversation.rb +148 -0
  34. data/lib/kward/events.rb +13 -0
  35. data/lib/kward/export_path.rb +28 -0
  36. data/lib/kward/image_attachments.rb +331 -0
  37. data/lib/kward/markdown_transcript.rb +72 -0
  38. data/lib/kward/memory/manager.rb +652 -0
  39. data/lib/kward/message_access.rb +42 -0
  40. data/lib/kward/model/chat_invocation.rb +23 -0
  41. data/lib/kward/model/client.rb +875 -0
  42. data/lib/kward/model/context_overflow.rb +55 -0
  43. data/lib/kward/model/context_usage.rb +104 -0
  44. data/lib/kward/model/model_info.rb +188 -0
  45. data/lib/kward/model/retry_message.rb +11 -0
  46. data/lib/kward/model/stream_parser.rb +205 -0
  47. data/lib/kward/pan/index.html.erb +143 -0
  48. data/lib/kward/pan/server.rb +397 -0
  49. data/lib/kward/plugin_registry.rb +327 -0
  50. data/lib/kward/private_file.rb +18 -0
  51. data/lib/kward/prompt_interface.rb +2437 -0
  52. data/lib/kward/prompts/commands.rb +50 -0
  53. data/lib/kward/prompts/templates.rb +60 -0
  54. data/lib/kward/prompts.rb +58 -0
  55. data/lib/kward/resources/avatar_kward_logo.rb +48 -0
  56. data/lib/kward/resources/pixel_logo.rb +230 -0
  57. data/lib/kward/rpc/auth_manager.rb +265 -0
  58. data/lib/kward/rpc/config_manager.rb +58 -0
  59. data/lib/kward/rpc/prompt_bridge.rb +104 -0
  60. data/lib/kward/rpc/redactor.rb +47 -0
  61. data/lib/kward/rpc/server.rb +639 -0
  62. data/lib/kward/rpc/session_manager.rb +1122 -0
  63. data/lib/kward/rpc/tool_event_normalizer.rb +68 -0
  64. data/lib/kward/rpc/tool_metadata.rb +80 -0
  65. data/lib/kward/rpc/transcript_normalizer.rb +307 -0
  66. data/lib/kward/rpc/transport.rb +58 -0
  67. data/lib/kward/session_diff.rb +125 -0
  68. data/lib/kward/session_store.rb +493 -0
  69. data/lib/kward/skills/registry.rb +76 -0
  70. data/lib/kward/starter_pack_installer.rb +110 -0
  71. data/lib/kward/steering.rb +56 -0
  72. data/lib/kward/telemetry/logger.rb +195 -0
  73. data/lib/kward/telemetry/stats.rb +466 -0
  74. data/lib/kward/tools/ask_user_question.rb +107 -0
  75. data/lib/kward/tools/base.rb +45 -0
  76. data/lib/kward/tools/code_search.rb +65 -0
  77. data/lib/kward/tools/edit_file.rb +41 -0
  78. data/lib/kward/tools/list_directory.rb +21 -0
  79. data/lib/kward/tools/read_file.rb +30 -0
  80. data/lib/kward/tools/read_skill.rb +27 -0
  81. data/lib/kward/tools/registry.rb +117 -0
  82. data/lib/kward/tools/run_shell_command.rb +28 -0
  83. data/lib/kward/tools/search/code.rb +445 -0
  84. data/lib/kward/tools/search/web.rb +747 -0
  85. data/lib/kward/tools/tool_call.rb +87 -0
  86. data/lib/kward/tools/web_search.rb +48 -0
  87. data/lib/kward/tools/write_file.rb +29 -0
  88. data/lib/kward/transcript_export.rb +40 -0
  89. data/lib/kward/version.rb +4 -0
  90. data/lib/kward/workspace.rb +377 -0
  91. data/lib/kward.rb +6 -0
  92. data/lib/main.rb +3 -0
  93. metadata +232 -0
data/doc/rpc.md ADDED
@@ -0,0 +1,635 @@
1
+ # Kward RPC Protocol
2
+
3
+ Kward RPC is an experimental backend protocol for UI clients. It is versioned as protocol version `1`, but method names and payloads may still change while the UI integration is built.
4
+
5
+ This page is for people building UI clients or integrations. If you use Kward from the terminal, you can skip it.
6
+
7
+ ## Launch
8
+
9
+ ```bash
10
+ kward rpc
11
+ ```
12
+
13
+ From source:
14
+
15
+ ```bash
16
+ ruby lib/main.rb rpc
17
+ ```
18
+
19
+ The process uses stdin/stdout exclusively for protocol messages. Diagnostics are written to stderr.
20
+
21
+ ## Framing
22
+
23
+ Messages are JSON-RPC 2.0 objects framed like LSP messages:
24
+
25
+ ```text
26
+ Content-Length: <bytes>\r\n
27
+ \r\n
28
+ <json body>
29
+ ```
30
+
31
+ `Content-Length` is the byte size of the JSON body.
32
+
33
+ ## JSON-RPC
34
+
35
+ Requests include `jsonrpc: "2.0"`, an `id`, a `method`, and optional `params`. Responses include either `result` or `error`. Notifications omit `id`.
36
+
37
+ Errors use JSON-RPC codes where possible and include developer diagnostics in `error.data` when available. Tokens, API keys, authorization headers, and similar secret fields are redacted.
38
+
39
+ ## Initialization
40
+
41
+ ### `initialize`
42
+
43
+ Returns protocol metadata and capabilities.
44
+
45
+ Result fields:
46
+
47
+ - `protocolVersion`: currently `1`.
48
+ - `serverName`: `"kward"`.
49
+ - `experimental`: `true`.
50
+ - `capabilities`: includes detailed Tauren-compatible capability groups. Some legacy simple fields remain for older clients, but `sessions` is now the detailed session capability object.
51
+
52
+ Detailed capability fields include:
53
+
54
+ - `transcript`: Tauren transcript format support, including normalized messages, image/tool support, compaction summaries, and restored assistant reasoning as Pi-compatible `thinking` content blocks.
55
+ - `sessions`: explicit RPC session mode, JSONL persistence, supported session methods, RPC list support, supported linear-session fork methods, supported compaction, and explicit unsupported import/tree/update features.
56
+ - `turns`: async turn mode, per-session concurrency, provider-gated native busy-input steering, queued follow-up input, best-effort cancellation, and recent in-memory event replay behavior.
57
+ - `events`: `turn/event` notification details, assistant/reasoning event names, normalized tool metadata, diff result support, and explicit unsupported shell changed-file detection/session update flags.
58
+ - `attachments`: supported input attachment contract for `turns/start`, with accepted base64 image MIME types and a stable max byte value.
59
+ - `models`: model/reasoning RPC methods, explicit OpenRouter catalog listing, exposed model fields, and no scoped model support.
60
+ - `runtime`: supported state/stats methods with message-count stats and OpenAI/Codex context usage. Cumulative token and cost stats are not computed.
61
+ - `runtimeSettings`: live `runtime/updateSetting` support for `defaultModel` and `defaultThinkingLevel`, plus `runtime/reload`.
62
+ - `auth`: Tauren auth provider format, OpenAI OAuth, OpenRouter API-key login, and provider logout for stored credentials.
63
+ - `memory`: opt-in structured memory support, interactive prompt injection only, JSON/JSONL local storage, and dedicated `memory/*` methods.
64
+ - `commands`: supported `commands/list` capability for prompt, skill, and plugin command sources, plus plugin execution through `commands/run` or plugin slash turns.
65
+ - `startupResources`: supported startup resource listing for context, skills, prompts, and plugins.
66
+ - `extensionUi`: question bridge support via `ui/question` and `ui/answerQuestion`; other UI primitives are explicitly unsupported.
67
+ - `composer`: composer-only UI features. Interactive session diff totals are explicitly unsupported over RPC (`composer.sessionDiff.supported: false`) because RPC clients already receive per-tool diff results and no live composer status payload is exposed. Clipboard copy is also unsupported over RPC (`composer.copy.supported: false`) because UI clients own clipboard access.
68
+ - `security`: trusted-local behavior; no workspace mutation guard or tool approval, shell/file mutation can run.
69
+ - `export`: supported transcript export formats. Currently `markdown` and `html`; default is `markdown`.
70
+
71
+ Legacy compatibility fields still present include `asyncTurns`, `turnCancellation`, `turnEventReplay`, `uiQuestions`, `authLogin`, `configUpdate`, `session`, `cancellation`, `eventReplay`, `uiQuestion`, `prompts`, `skills`, `tools`, and `config`.
72
+
73
+ ### `shutdown`
74
+
75
+ Requests process shutdown after the response.
76
+
77
+ ## Workspace methods
78
+
79
+ ### `workspace/validate`
80
+
81
+ Params:
82
+
83
+ - `workspaceRoot`: optional path.
84
+
85
+ Returns the real workspace root. Any existing local directory accessible to the Kward process is allowed.
86
+
87
+ ### `workspace/info`
88
+
89
+ Returns root, basename, and writability for a workspace.
90
+
91
+ ## Session methods
92
+
93
+ RPC sessions are explicit and have an RPC `id`, a persisted session `path`, and a `workspaceRoot`. When a client creates, resumes, clones, or forks into another session, idle empty unnamed sessions are cleaned up automatically.
94
+
95
+ ### `sessions/create`
96
+
97
+ Params:
98
+
99
+ - `workspaceRoot`: optional existing directory; defaults to launch cwd.
100
+ - `name`: optional session name.
101
+
102
+ Creates a persisted Kward session and returns session metadata.
103
+
104
+ ### `sessions/resume`
105
+
106
+ Params:
107
+
108
+ - `path`: session JSONL path.
109
+ - `workspaceRoot`: optional root used to resolve the session path.
110
+
111
+ Loads a persisted session and returns a new RPC session ID.
112
+
113
+ ### `sessions/list`
114
+
115
+ Params:
116
+
117
+ - `workspaceRoot`: optional.
118
+ - `limit`: optional, default `20`.
119
+
120
+ Returns recent persisted sessions for that workspace. Existing sessions without ancestry are roots; cloned or forked sessions include parent metadata and tree display fields. Each item includes absolute `path`, `cwd`, `workspaceRoot`, `createdAt`, `modifiedAt`, optional `name`, compact `firstMessage`, `messageCount` excluding metadata records, optional `parentId`/`parentPath`, `depth`, `isLast`, and `ancestorContinues` for tree rendering.
121
+
122
+ ### `sessions/rename`
123
+
124
+ Params:
125
+
126
+ - `sessionId`
127
+ - `name`
128
+
129
+ Renames or clears the active persisted session name.
130
+
131
+ ### `sessions/clone`
132
+
133
+ Params:
134
+
135
+ - `sessionId`
136
+
137
+ Creates a new persisted session from the current conversation and returns a new independent RPC session with `parentId`/`parentPath` pointing at the source session. Future messages in the clone append only to the clone file; the source session remains unchanged.
138
+
139
+ ### `sessions/compact`
140
+
141
+ Params:
142
+
143
+ - `sessionId`
144
+ - `customInstructions`: optional additional guidance for the summarizer.
145
+
146
+ Summarizes older non-system conversation into a structured Ruby-aware checkpoint, keeps recent messages after `firstKeptEntryId` in live context, clears remembered read-file state, and appends a compaction record to the session JSONL. Historical message records remain in the session file for audit/export/navigation.
147
+
148
+ Returns:
149
+
150
+ ```json
151
+ {
152
+ "summary": "Compaction summary",
153
+ "firstKeptEntryId": "message:2",
154
+ "tokensBefore": 1234,
155
+ "details": {
156
+ "read_files": [],
157
+ "modified_files": []
158
+ }
159
+ }
160
+ ```
161
+
162
+ The server emits `session/event` notifications with `type: "compactionStart"` before summarization and `type: "compactionEnd"` after completion or failure. The end payload includes `{ "result": {}, "aborted": false, "willRetry": false, "errorMessage": null }`; failed compactions set `aborted: true` and return a JSON-RPC error.
163
+
164
+ ### `sessions/forkMessages`
165
+
166
+ Params:
167
+
168
+ - `sessionId`
169
+
170
+ Returns forkable user-message entries for the active session:
171
+
172
+ ```json
173
+ {
174
+ "messages": [
175
+ { "entryId": "message:0", "text": "User message text" }
176
+ ]
177
+ }
178
+ ```
179
+
180
+ `entryId` values are stable message-index IDs within the linear session. `text` is compact display text.
181
+
182
+ ### `sessions/fork`
183
+
184
+ Params:
185
+
186
+ - `sessionId`
187
+ - `entryId`: an ID returned by `sessions/forkMessages`.
188
+
189
+ Creates a new independent persisted session from history before the selected user message. The selected user message is excluded from the new session and returned as `text` so clients can place it into the composer for editing/resubmission.
190
+
191
+ Returns:
192
+
193
+ ```json
194
+ {
195
+ "session": {},
196
+ "text": "selected user message text",
197
+ "cancelled": false
198
+ }
199
+ ```
200
+
201
+ Future messages in the fork append only to the fork file; the source session remains unchanged.
202
+
203
+ ### `sessions/export`
204
+
205
+ Params:
206
+
207
+ - `sessionId`
208
+ - `path`: optional output path. Explicit paths are resolved relative to the session workspace and must stay inside the workspace or Kward session directory.
209
+ - `format`: optional export format, `markdown` or `html`; defaults to `markdown`. `md` is accepted as an alias for `markdown`.
210
+
211
+ Exports the transcript. Markdown preserves the previous default behavior. HTML is a minimal escaped `<pre>` transcript wrapper.
212
+
213
+ ### `sessions/delete`
214
+
215
+ Deletes the persisted session file and closes the RPC session.
216
+
217
+ ### `sessions/close`
218
+
219
+ Closes the RPC session. Empty unnamed session files may be cleaned up.
220
+
221
+ ### `sessions/transcript`
222
+
223
+ Returns session metadata and full conversation messages. Assistant `reasoning_summary` values and existing `thinking`/`reasoning` content parts are restored as normalized `{ "type": "thinking", "thinking": "..." }` blocks before assistant text; reasoning is not merged into normal text blocks.
224
+
225
+ ## Turn methods
226
+
227
+ Turns are asynchronous. A session queues turns sequentially; only one turn runs per session at a time.
228
+
229
+ ### `turns/start`
230
+
231
+ Params:
232
+
233
+ - `sessionId`
234
+ - `input`
235
+ - `streamingBehavior`: optional; `newTurn` by default when idle. `followUp` queues behind the active turn. `steer` routes input to the active turn only when `initialize.capabilities.turns.busyInput.steer` is `native`; unsupported providers return an invalid params error instead of queueing or approximating steering. When native steering is supported and a turn is already running, omitted `streamingBehavior` defaults to `steer`.
236
+ - `attachments`: optional array of image attachments: `{ "type": "image", "data": "base64", "mimeType": "image/png", "name": "optional.png", "sizeBytes": 12345 }`.
237
+
238
+ Supported attachment MIME types are `image/png`, `image/jpeg`, `image/gif`, and `image/webp`. Image data must be raw base64 without a `data:` prefix, and the RPC boundary limit is 10MB per image.
239
+
240
+ If `input` is a configured prompt slash command such as `/plan fix bug`, Kward expands the prompt template server-side before starting the turn. If `input` is a configured plugin slash command such as `/hi_chatgpt`, Kward runs the plugin command and emits its output as turn events without calling the model. Unknown slash commands remain literal input. Clients may still call `prompts/expand` themselves when they need preview/editing before submission.
241
+
242
+ Returns a turn object with `id`, `sessionId`, `status`, timestamps, and cancellation state. Status starts as `queued` or quickly becomes `running`.
243
+
244
+ ### `turns/cancel`
245
+
246
+ Params:
247
+
248
+ - `turnId`
249
+
250
+ Requests best-effort cancellation. Queued turns can be marked canceled before running. Running turns stop emitting further events when possible, but in-flight model requests or tool side effects may still complete because Ruby/network/tool APIs cannot always be interrupted safely.
251
+
252
+ ### `turns/status`
253
+
254
+ Returns the current turn object.
255
+
256
+ ### `turns/events`
257
+
258
+ Params:
259
+
260
+ - `turnId`
261
+ - `afterSequence`: optional sequence number.
262
+
263
+ Returns recent in-memory events after the requested sequence. Event history is not persisted and is bounded in memory.
264
+
265
+ ## Turn notifications
266
+
267
+ The server emits `turn/event` notifications:
268
+
269
+ ```json
270
+ {
271
+ "sequence": 1,
272
+ "timestamp": "...",
273
+ "sessionId": "...",
274
+ "turnId": "...",
275
+ "type": "assistantDelta",
276
+ "payload": { "delta": "text" }
277
+ }
278
+ ```
279
+
280
+ Known event types:
281
+
282
+ - `turnQueued`
283
+ - `turnSteered`
284
+ - `turnStarted`
285
+ - `reasoningDelta`
286
+ - `assistantDelta`
287
+ - `assistantMessage`
288
+ - `modelRetry`
289
+ - `toolCall`
290
+ - `toolResult`
291
+ - `answer`
292
+ - `turnCancelRequested`
293
+ - `error`
294
+ - `turnFinished`
295
+
296
+ Lifecycle payloads include `status` for `turnQueued`, `turnStarted`, and `turnFinished`. Exactly one terminal `turnFinished` is emitted per turn with `status` set to `completed`, `failed`, or `canceled`; failed turns include a sanitized `{ "message": "...", "code": "...", "fatal": false }` error payload.
297
+
298
+ `modelRetry` is emitted before Kward retries a transient model request failure. Its payload includes `provider`, `model`, `attempt`, `maxAttempts`, `delaySeconds`, and `error`.
299
+
300
+ `toolCall` and `toolResult` payloads include canonical Tauren-normalized fields:
301
+
302
+ - `toolCallId`: tool call ID.
303
+ - `toolName`: normalized tool name, such as `read`, `edit`, `write`, or `bash`.
304
+ - `args`: normalized arguments. Edit replacements use `oldText`/`newText`; shell timeout is `timeout`.
305
+ - `rawToolCall` and `toolCall`: original model tool call for compatibility.
306
+ - `tool`: legacy normalized metadata retained for older clients.
307
+
308
+ `toolResult` additionally includes `result` with `content`, `isError`, optional unified `diff`, optional `changedFiles`, and `images`. Failed or declined tools set `isError: true`.
309
+
310
+ Examples:
311
+
312
+ - `edit_file`: `toolName: "edit"`, `args: { "path": "...", "edits": [{ "oldText": "...", "newText": "..." }] }`.
313
+ - `write_file`: `toolName: "write"`, `args: { "path": "...", "content": "..." }`.
314
+ - `run_shell_command`: `toolName: "bash"`, `args: { "command": "...", "timeout": 30 }`.
315
+
316
+ ## UI question bridge
317
+
318
+ Kward's only supported extension-style UI surface is the structured question bridge. The `extensionUi` capability reports `question.supported: true` with `notification: "ui/question"`, `method: "ui/answerQuestion"`, `maxQuestions: 4`, `multiSelect: false`, and `preview: false`. Other Pi-style extension UI primitives (`select`, `confirm`, `input`, `editor`, `widgets`, `footer`, `custom`, and `terminalInput`) are explicitly reported as unsupported until Kward has a real plugin/extension consumer for them.
319
+
320
+ Question requests are validated before notification. Kward accepts 1-4 questions, each with 2-4 options, and rejects unsupported `multiSelect` or option `preview` requests.
321
+
322
+ When the model calls `ask_user_question`, RPC emits a `ui/question` notification:
323
+
324
+ ```json
325
+ {
326
+ "sessionId": "...",
327
+ "questionRequestId": "...",
328
+ "questions": []
329
+ }
330
+ ```
331
+
332
+ The UI must respond with `ui/answerQuestion`:
333
+
334
+ Params:
335
+
336
+ - `sessionId`
337
+ - `questionRequestId`
338
+ - `answers`: answer array returned to the tool.
339
+
340
+ ## Runtime methods
341
+
342
+ ### `runtime/state`
343
+
344
+ Params:
345
+
346
+ - `sessionId`: active RPC session ID.
347
+
348
+ Returns Tauren-compatible runtime state for the session, including session file, persisted session ID/name, active `rpcSessionId`, `persistentSessionId`, current model metadata, current thinking level, streaming/pending-message state, and stable Kward defaults. The legacy `sessionId` field remains the persisted session ID; clients must send the active RPC session `id`/`rpcSessionId` in RPC request params. Unsupported runtime settings are returned as false or omitted.
349
+
350
+ ### `runtime/stats`
351
+
352
+ Params:
353
+
354
+ - `sessionId`: active RPC session ID.
355
+
356
+ Returns session file/id/name, active `rpcSessionId`, `persistentSessionId`, message-count stats: user messages, assistant messages, tool calls, tool results, and total non-system messages. The legacy `sessionId` field remains the persisted session ID; clients must send the active RPC session `id`/`rpcSessionId` in RPC request params. For OpenAI/Codex sessions with a known model context window and text-only non-empty conversation context, also returns `contextUsage` with estimated current next-request context tokens, context window, percent used, and `estimated: true`. Fresh sessions with no non-system content omit `contextUsage` because only static prompt/tool overhead would be measurable. Cumulative token and cost fields are omitted until Kward tracks provider usage responses.
357
+
358
+ ### `runtime/updateSetting`
359
+
360
+ Params:
361
+
362
+ - `sessionId`: active RPC session ID.
363
+ - `settingId`: currently `defaultModel` or `defaultThinkingLevel`.
364
+ - `value`: setting value. `defaultModel` accepts `Provider/model-id` and preserves slashes after the provider separator.
365
+
366
+ Applies the setting live by updating config and refreshing client config. Unsupported setting IDs are rejected.
367
+
368
+ ### `runtime/reload`
369
+
370
+ Params:
371
+
372
+ - `sessionId`: active RPC session ID.
373
+
374
+ Refreshes config-backed runtime state and returns `{ "ok": true, "message": "Resources reloaded." }`.
375
+
376
+ ## Logging methods
377
+
378
+ The `logging` capability reports local redacted telemetry logging support, the log directory, enabled categories, and `methods: ["logging/stats"]`. Logging stats require logging to be enabled by config or environment for at least one category.
379
+
380
+ ### `logging/stats`
381
+
382
+ Params:
383
+
384
+ - `range`: optional duration string such as `10 minutes`, `2 days`, or `1 year`; defaults to `1 week`.
385
+
386
+ Accepted units are minutes, hours, days, weeks, months, and years. Ranges use UTC calendar periods: `1 month` means the current calendar month so far, and `2 months` means the previous month plus the current month so far. Invalid ranges return an invalid-params error with usage text.
387
+
388
+ Returns structured stats for enabled categories only, including the requested range, log directory, record counts by category/event, `usageStats` token totals, performance duration summaries, tool call summaries, and error counts by event/class/provider/code. Error messages are not included in the stats response.
389
+
390
+ ## Memory methods
391
+
392
+ Memory is disabled by default. Auto-summary is also disabled by default. RPC memory methods operate on the same local storage as the CLI: `<config-dir>/memory/core.json`, `<config-dir>/memory/soft.jsonl`, and `<config-dir>/memory/events.jsonl`. Retrieved memory is injected only for normal session turns when memory is enabled.
393
+
394
+ ### `memory/status`
395
+
396
+ Returns `{ "enabled": boolean, "autoSummary": boolean, "paths": { "core", "soft", "events" } }`.
397
+
398
+ ### `memory/enable`
399
+
400
+ Enables memory in config and creates storage files if needed. Returns `{ "enabled": true }`.
401
+
402
+ ### `memory/disable`
403
+
404
+ Disables memory prompt injection. Stored memories are left in place. Returns `{ "enabled": false }`.
405
+
406
+ ### `memory/autoSummary/enable`
407
+
408
+ Enables quiet memory summarization after completed interactive turns. Auto-summary runs only when memory is also enabled. Returns `{ "autoSummary": true }`.
409
+
410
+ ### `memory/autoSummary/disable`
411
+
412
+ Disables quiet memory summarization after completed interactive turns. Returns `{ "autoSummary": false }`.
413
+
414
+ ### `memory/list`
415
+
416
+ Params:
417
+
418
+ - `includeInactive`: optional boolean; includes forgotten soft memories when true.
419
+
420
+ Returns `{ "core": [], "soft": [] }`.
421
+
422
+ ### `memory/add`
423
+
424
+ Adds a manual soft memory.
425
+
426
+ Params:
427
+
428
+ - `text`: memory text.
429
+ - `scope`: optional, defaults to `global`.
430
+ - `tags`: optional array.
431
+
432
+ Returns `{ "memory": {} }`.
433
+
434
+ ### `memory/addCore`
435
+
436
+ Adds an explicit core memory.
437
+
438
+ Params:
439
+
440
+ - `text`: memory text.
441
+ - `scope`: optional, defaults to `global`.
442
+ - `tags`: optional array.
443
+
444
+ Returns `{ "memory": {} }`.
445
+
446
+ ### `memory/forget`
447
+
448
+ Params:
449
+
450
+ - `id`: memory ID such as `core_001` or `soft_001`.
451
+
452
+ Returns `{ "forgotten": true }` when a memory was removed or marked forgotten. Core memories are removed. Soft memories are marked inactive and their stored text, tags, confidence, and hit count are redacted.
453
+
454
+ ### `memory/promote`
455
+
456
+ Promotes an active soft memory to a new core memory and marks the soft memory forgotten.
457
+
458
+ Params:
459
+
460
+ - `id`: soft memory ID.
461
+
462
+ Returns `{ "memory": {} }` for the new core memory.
463
+
464
+ ### `memory/inspect`
465
+
466
+ Returns enabled status, storage paths, core memories, and soft memories including inactive records.
467
+
468
+ ### `memory/why`
469
+
470
+ Params:
471
+
472
+ - `sessionId`: optional active RPC session ID.
473
+
474
+ Returns the most recent memory retrieval explanation for the session when provided, otherwise the manager's latest explanation/no-retrieval message.
475
+
476
+ ### `memory/summarize`
477
+
478
+ Runs conservative heuristic soft-memory inference over the active session and persists any accepted soft memories.
479
+
480
+ Params:
481
+
482
+ - `sessionId`: active RPC session ID.
483
+
484
+ Returns `{ "memories": [] }`.
485
+
486
+ ## Model methods
487
+
488
+ ### `models/list`
489
+
490
+ Returns known model entries from the current client/config backend. OpenRouter entries prefer models available to the configured OpenRouter API key when they can be fetched; otherwise Kward falls back to defaults/currently configured options. Entries use `{ "provider", "id", "name", "reasoning", "reasoningEffort", "contextWindow", "current" }`; legacy `model` is retained as an alias for older clients.
491
+
492
+ ### `openrouter/catalog`
493
+
494
+ Returns the full OpenRouter model catalog as model entries. This is separate from `models/list`, which prefers models available to the configured API key. Models returned here may still fail at request time if the active OpenRouter key cannot access them.
495
+
496
+ ### `models/current`
497
+
498
+ Returns the current model entry with `id`, `name`, `reasoning`, `reasoningEffort`, and legacy `model` alias where available.
499
+
500
+ ### `models/set`
501
+
502
+ Params:
503
+
504
+ - `model`: model ID string.
505
+ - `provider`: optional provider hint, currently `Codex` or `OpenRouter`; defaults to the active provider.
506
+
507
+ Updates the config-backed provider model and returns the current model payload.
508
+
509
+ ### `reasoning/set`
510
+
511
+ Params:
512
+
513
+ - `effort`: reasoning effort string.
514
+
515
+ Updates the config-backed OpenAI/Codex reasoning effort and returns the current model payload.
516
+
517
+ ## Tool and prompt methods
518
+
519
+ ### `tools/list`
520
+
521
+ Returns current tool schemas.
522
+
523
+ ### `commands/list`
524
+
525
+ Params:
526
+
527
+ - `sessionId`: active RPC session ID.
528
+
529
+ Returns Tauren-compatible slash command metadata for configured prompt templates, skills, and plugins. Prompt command names omit the leading slash. Skill command names use `skill:<name>`. Plugin command names omit the leading slash and include `executable: true`. Builtin terminal-only commands are omitted. Prompt commands can be submitted directly to `turns/start` as slash commands or expanded first with `prompts/expand`; plugin commands can be submitted to `turns/start` or run explicitly with `commands/run`.
530
+
531
+ ### `resources/startup`
532
+
533
+ Params:
534
+
535
+ - `sessionId`: active RPC session ID.
536
+
537
+ Returns stable startup sections for configured context (`AGENTS.md`), skills, prompt templates, and plugin slash commands.
538
+
539
+ ### `prompts/list`
540
+
541
+ Returns configured prompt templates.
542
+
543
+ ### `prompts/expand`
544
+
545
+ Params:
546
+
547
+ - `command`: prompt command, with or without leading slash.
548
+ - `arguments`: optional string.
549
+
550
+ Returns expanded prompt text.
551
+
552
+ ## Config and auth methods
553
+
554
+ ### `config/read`
555
+
556
+ Params:
557
+
558
+ - `redacted`: optional, defaults to `true`.
559
+
560
+ Returns the config path and config object. Secret-looking fields are redacted by default.
561
+
562
+ ### `config/update`
563
+
564
+ Params:
565
+
566
+ - `values`: object of config keys and values.
567
+
568
+ Updates config, including secret values, and returns a redacted config object. The stored file contains the supplied values.
569
+
570
+ ### `auth/status`
571
+
572
+ Returns whether OpenAI OAuth, OpenAI access token env, and OpenRouter API key env/config are available.
573
+
574
+ ### `auth/providers`
575
+
576
+ Returns Tauren-compatible provider cards for OpenAI OAuth and OpenRouter API-key auth. Provider cards report whether credentials are configured, whether they came from stored config or environment variables, and whether stored credentials can be removed.
577
+
578
+ ### `auth/loginWithApiKey`
579
+
580
+ Params:
581
+
582
+ - `providerId`: currently `openrouter`.
583
+ - `apiKey`: API key secret.
584
+
585
+ Stores the API key with `0600` file permissions, refreshes client config, and returns a redacted message payload. Secret values are not returned.
586
+
587
+ ### `auth/logoutProvider`
588
+
589
+ Params:
590
+
591
+ - `providerId`: `openai` or `openrouter`.
592
+
593
+ Removes stored credentials only. Environment variables remain active and are still reported by `auth/providers`.
594
+
595
+ ### `auth/loginWithOAuth`
596
+
597
+ Params:
598
+
599
+ - `providerId`: currently `openai`.
600
+ - `timeoutSeconds`: optional callback wait timeout.
601
+
602
+ Provider-scoped wrapper around the OpenAI OAuth flow. The result includes `providerId`, `loginId`, `authorizationUrl`, `redirectUri`, and `status`.
603
+
604
+ ### `auth/startOpenAILogin`
605
+
606
+ Starts OAuth without opening a browser. The UI should open `authorizationUrl` and then either let the local callback complete or submit a code/callback URL.
607
+
608
+ Returns:
609
+
610
+ - `loginId`
611
+ - `authorizationUrl`
612
+ - `redirectUri`
613
+ - `status`
614
+
615
+ The server emits `auth/loginFinished` when login completes or fails. The notification includes `providerId`, `loginId`, `status`, `redirectUri`, and optional `message`/`error`.
616
+
617
+ ### `auth/submitOpenAICode`
618
+
619
+ Params:
620
+
621
+ - `loginId`
622
+ - `code`: authorization code or callback URL.
623
+
624
+ Completes the login using the submitted code.
625
+
626
+ ### `auth/loginStatus`
627
+
628
+ Returns login status for a login ID.
629
+
630
+ ## Security and privacy notes
631
+
632
+ - RPC is intended for a trusted local UI and can read/write files, run shell commands, update secrets, and use OAuth.
633
+ - Workspace roots may be any existing local directory accessible to the process.
634
+ - Tool execution matches current CLI behavior; mutating tools are not approval-gated by RPC.
635
+ - Responses and diagnostics redact secret-looking fields, but clients should still avoid logging full protocol traffic unless necessary.