@margay/ccl-core 1.4.5-rc.9 → 1.4.6-beta.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.
package/sdk/README.md CHANGED
@@ -66,6 +66,43 @@ process events. Those events do not replace or add a terminal result.
66
66
  See the [API contract](./API.md) and [recovery guide](../docs/error-recovery-usage.md)
67
67
  for consent, external blockers, and continuation rules.
68
68
 
69
+ ## Gateway request status (source candidate)
70
+
71
+ Set `includeRequestProgress: true` to receive nonterminal `request_progress`
72
+ events. This is off by default, independent of raw/partial/error diagnostic
73
+ options. It does not change `result`, cancellation, or `onSessionEnd`.
74
+
75
+ ```ts
76
+ for await (const event of query('Summarize this project.', {
77
+ includeRequestProgress: true,
78
+ })) {
79
+ if (event.type === 'request_progress') {
80
+ const { requestId, phase, attempt, elapsedMs, idleMs, slow } = event.progress
81
+ // Update a transient status indicator, keyed by requestId.
82
+ }
83
+ if (event.type === 'result') {
84
+ // End the turn using the existing success/error contract.
85
+ }
86
+ }
87
+ ```
88
+
89
+ Phases are `preparing`, `connecting`, `sending`, `waiting_response`,
90
+ `response_headers`, `retry_wait`, `streaming`, and `finished`. `connecting`
91
+ includes pool waiting, DNS, TCP, TLS and proxy negotiation; it does not identify
92
+ which of those substeps is slow. `idleMs` measures time without effective model
93
+ progress. Events contain no prompt, headers, credentials or endpoint URL.
94
+
95
+ Events are finite (at most 32 per model request), not periodic heartbeats.
96
+ A slow notice never counts as model progress or grants permission to retry.
97
+ `finished` ends a request, not necessarily the turn; clear status on the existing
98
+ result/abort/disconnect path as well. Hosts should keep their own deadlines
99
+ and avoid replaying tools when the remote completion state is unknown.
100
+
101
+ CLI users can opt in with `--print --output-format stream-json
102
+ --include-request-progress`; each wire event is `system/request_progress`.
103
+ The flag is invalid with text or JSON output. See
104
+ [request deadlines](../docs/gateway-quickstart.md#request-deadlines-and-slow-waits).
105
+
69
106
  ## Architecture
70
107
 
71
108
  The SDK is the **host side** of the stream-json control protocol that
@@ -146,3 +183,60 @@ provider mapping, skills-dir wrapping, hooks, usage accumulation, file-store
146
183
  round-trip. The issue's live end-to-end DoD slice (real model + mock outbound
147
184
  endpoint + real process exit) is CoS-side per the issue's division of labor —
148
185
  the SDK-side seams it needs are all covered above.
186
+ # Minimal mode and explicit tools
187
+
188
+ When passing `--bare` through `extraArgs`, the built-in tool set is Bash, Read,
189
+ and Edit (REPL/coordinator modes have their own subset). `--tools default` uses
190
+ that mode's available set; an explicit incompatible selection such as
191
+ `--bare --tools Write` fails with a diagnostic before a model request. Remove
192
+ `--bare` and unset `CLAUDE_CODE_SIMPLE` to request Write. Allow/deny permissions
193
+ still apply; `--allowedTools` does not add tools to the available set.
194
+
195
+ Use `extraArgs: ['--thinking', 'disabled']` to explicitly disable thinking on
196
+ Anthropic Messages compatible routes. Omitting the option retains the route's
197
+ default. The selection persists across requests; a query handle's
198
+ `setMaxThinkingTokens(0)` explicitly disables it, and `null` restores the default.
199
+ # Persistent sessions and streamed input
200
+
201
+ `query({ prompt: asyncIterable, options })` accepts `SDKUserMessage` values. It
202
+ submits one message at a time, waits for its result before pulling the next,
203
+ and adds the input UUID as `result.turnId` (generating a UUID if omitted).
204
+ Input EOF closes a streamed query. Invalid messages or producer failures reject
205
+ the event iterator. Consume events as they arrive: an unread streamed query fails
206
+ explicitly at 1024 buffered events instead of retaining unlimited output.
207
+
208
+ Use `createSession` when the host owns a longer conversation:
209
+
210
+ ```ts
211
+ import { createSession } from '@margay/ccl-core/sdk'
212
+
213
+ const session = createSession({ cwd: projectDir, maxPendingTurns: 32 })
214
+ try {
215
+ const first = session.prompt('Inspect the project and describe the failing test.')
216
+ console.log(await first.result)
217
+ const next = session.followUp('Fix that failure and run the relevant test.')
218
+ console.log(await next.result)
219
+ await session.endInput()
220
+ // The same child and controls remain alive until close().
221
+ console.log(session.pid, await session.controls.initializationResult())
222
+ } finally {
223
+ await session.close()
224
+ }
225
+ ```
226
+
227
+ `prompt` and `followUp` enqueue FIFO; exceeding `maxPendingTurns` throws before
228
+ acceptance. Each `Turn` has a stable `id`, a `result` promise and `cancel()`.
229
+ Cancelling a queued turn rejects its promise. Cancelling an active turn interrupts
230
+ the CLI and returns its interrupted result; already executed tool effects remain.
231
+ `steer(text)` interrupts the active turn and puts the correction ahead of waiting
232
+ follow-ups. It does not undo earlier effects. `endInput()` rejects new inputs and
233
+ waits for accepted turns while preserving controls; `close()` terminates the child
234
+ and rejects unfinished turns. `onEvent` observes events without retaining history.
235
+
236
+ Permission callbacks can wait for a host decision while the process stays alive.
237
+ Interrupt and close cancel that wait. Returning `{ behavior: 'pending' }` retains
238
+ the existing durable suspend contract: it ends this process and requires
239
+ `resumeWithDecision(sessionId, decision)`; it does not imply automatic approval.
240
+ Uncooperative application iterators/callbacks cannot be forcibly stopped, but do
241
+ not prevent CLI cleanup. One-shot string queries and post-result `rewindFiles`
242
+ retain their existing behavior.