@wrongstack/core 0.265.1 → 0.268.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 (75) hide show
  1. package/dist/{agent-bridge-DrkBxszZ.d.ts → agent-bridge-UhojbpWx.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-DM2pP-B6.d.ts → agent-subagent-runner-Bvtf1o9K.d.ts} +25 -7
  3. package/dist/{brain-BXd_61kQ.d.ts → brain-69wzMKp1.d.ts} +73 -1
  4. package/dist/{compactor-B8pOf45Y.d.ts → compactor-CBQAJoDc.d.ts} +19 -1
  5. package/dist/{config-BMCj_XDs.d.ts → config-VKfOZ-6X.d.ts} +122 -3
  6. package/dist/{context-MRk5PhNv.d.ts → context-C0U8B9NF.d.ts} +88 -1
  7. package/dist/coordination/index.d.ts +57 -161
  8. package/dist/coordination/index.js +471 -177
  9. package/dist/coordination/index.js.map +1 -1
  10. package/dist/defaults/index.d.ts +26 -25
  11. package/dist/defaults/index.js +1818 -844
  12. package/dist/defaults/index.js.map +1 -1
  13. package/dist/execution/index.d.ts +72 -16
  14. package/dist/execution/index.js +1270 -265
  15. package/dist/execution/index.js.map +1 -1
  16. package/dist/execution/prompt-enhancer.d.ts +1 -1
  17. package/dist/extension/index.d.ts +7 -6
  18. package/dist/global-mailbox-KByEFFBa.d.ts +663 -0
  19. package/dist/{goal-preamble-DvHDSKSe.d.ts → goal-preamble-CrYjmdw4.d.ts} +28 -11
  20. package/dist/{goal-store-DtLMySNb.d.ts → goal-store-Y_zdLZ3q.d.ts} +1 -1
  21. package/dist/hq/index.d.ts +195 -0
  22. package/dist/hq/index.js +1884 -0
  23. package/dist/hq/index.js.map +1 -0
  24. package/dist/index-BfaS-f_m.d.ts +82 -0
  25. package/dist/{index-B-ch8K9C.d.ts → index-CtQnmkaS.d.ts} +8 -8
  26. package/dist/{index-CEDeNodM.d.ts → index-gCv830d7.d.ts} +5 -5
  27. package/dist/index.d.ts +124 -47
  28. package/dist/index.js +5600 -2662
  29. package/dist/index.js.map +1 -1
  30. package/dist/infrastructure/index.d.ts +6 -6
  31. package/dist/infrastructure/index.js +117 -19
  32. package/dist/infrastructure/index.js.map +1 -1
  33. package/dist/kernel/index.d.ts +10 -9
  34. package/dist/kernel/index.js.map +1 -1
  35. package/dist/{pipeline-DPDxH_7m.d.ts → mailbox-types-Ct2hJq0P.d.ts} +1 -244
  36. package/dist/{mcp-servers-2x4w6Jn9.d.ts → mcp-servers-HT3Fi7Bl.d.ts} +10 -4
  37. package/dist/models/index.d.ts +5 -5
  38. package/dist/models/index.js +33 -3
  39. package/dist/models/index.js.map +1 -1
  40. package/dist/{models-registry-DmJlKuNp.d.ts → models-registry-Bvcl3Vaa.d.ts} +1 -1
  41. package/dist/{multi-agent-coordinator-DyCkCZnU.d.ts → multi-agent-coordinator-BACjsmkC.d.ts} +1 -1
  42. package/dist/{null-fleet-bus-CG9QY2aP.d.ts → null-fleet-bus-DA7fvhUg.d.ts} +14 -9
  43. package/dist/observability/index.d.ts +2 -2
  44. package/dist/{parallel-eternal-engine-Jw9uhEoT.d.ts → parallel-eternal-engine-Ci71gYu_.d.ts} +11 -15
  45. package/dist/{path-resolver-Dy2ej-gE.d.ts → path-resolver-O1IJnmKE.d.ts} +4 -3
  46. package/dist/{permission-B9SB45lp.d.ts → permission-Bd-57Lbl.d.ts} +1 -1
  47. package/dist/{permission-policy-CkjSXabK.d.ts → permission-policy-uNXC6Kge.d.ts} +2 -3
  48. package/dist/pipeline-BDNvENyV.d.ts +245 -0
  49. package/dist/{plan-templates-CzD9GnAU.d.ts → plan-templates-EMsalEtN.d.ts} +5 -5
  50. package/dist/{llm-selector-C0tfTCUe.d.ts → provider-model-resolve-CEb9x886.d.ts} +40 -3
  51. package/dist/{provider-runner-DMa70ODu.d.ts → provider-runner-DWJbpo70.d.ts} +3 -3
  52. package/dist/{retry-policy-CN0khdlj.d.ts → retry-policy-C3s_lvdK.d.ts} +1 -1
  53. package/dist/sdd/index.d.ts +9 -8
  54. package/dist/sdd/index.js +44 -14
  55. package/dist/sdd/index.js.map +1 -1
  56. package/dist/{secret-vault-B2yw84VT.d.ts → secret-vault-Cgduf5xL.d.ts} +2 -2
  57. package/dist/security/index.d.ts +5 -67
  58. package/dist/security/index.js +129 -99
  59. package/dist/security/index.js.map +1 -1
  60. package/dist/{selector-CzHh_igB.d.ts → selector-47LBnBVk.d.ts} +1 -1
  61. package/dist/{session-event-bridge-BUI6Jf-4.d.ts → session-event-bridge-Cw7oqmW2.d.ts} +1 -1
  62. package/dist/{session-reader-CMgdMSRP.d.ts → session-reader-DD4v2Obw.d.ts} +1 -1
  63. package/dist/storage/index.d.ts +14 -12
  64. package/dist/storage/index.js +144 -120
  65. package/dist/storage/index.js.map +1 -1
  66. package/dist/tools/index.d.ts +4 -2
  67. package/dist/tools/index.js +166 -31
  68. package/dist/tools/index.js.map +1 -1
  69. package/dist/types/index.d.ts +20 -19
  70. package/dist/types/index.js +1358 -476
  71. package/dist/types/index.js.map +1 -1
  72. package/dist/utils/index.d.ts +472 -405
  73. package/dist/utils/index.js +2321 -1193
  74. package/dist/utils/index.js.map +1 -1
  75. package/package.json +5 -1
@@ -1,4 +1,4 @@
1
- import { B as BridgeTransport, a as BridgeMessage, A as AgentBridge, b as AgentBridgeConfig } from './agent-subagent-runner-DM2pP-B6.js';
1
+ import { B as BridgeTransport, a as BridgeMessage, A as AgentBridge, b as AgentBridgeConfig } from './agent-subagent-runner-Bvtf1o9K.js';
2
2
 
3
3
  /**
4
4
  * In-memory pub/sub transport for agent-to-agent messaging.
@@ -1,12 +1,12 @@
1
- import { c as ToolCallPipelinePayload, d as ToolWrapper, E as ExtensionRegistry, S as SystemPromptContributor, e as ToolRegistry, P as ProviderRegistry, A as AgentPipelines, f as ToolExecutorLike, g as AgentInit, h as AgentInput, R as RunResult } from './index-CEDeNodM.js';
2
- import { C as Container, R as ReadonlyPipeline, a as Renderer } from './pipeline-DPDxH_7m.js';
3
- import { E as EventBus, a as EventName, L as Listener } from './brain-BXd_61kQ.js';
4
- import { R as RetryPolicy, E as ErrorHandler } from './retry-policy-CN0khdlj.js';
1
+ import { c as ToolCallPipelinePayload, d as ToolWrapper, E as ExtensionRegistry, S as SystemPromptContributor, e as ToolRegistry, P as ProviderRegistry, A as AgentPipelines, f as ToolExecutorLike, g as AgentInit, h as AgentInput, R as RunResult } from './index-gCv830d7.js';
2
+ import { C as Container, R as ReadonlyPipeline, a as Renderer } from './pipeline-BDNvENyV.js';
3
+ import { E as EventBus, a as EventName, L as Listener } from './brain-69wzMKp1.js';
4
+ import { R as RetryPolicy, E as ErrorHandler } from './retry-policy-C3s_lvdK.js';
5
5
  import { L as Logger } from './logger-B63L5bTg.js';
6
6
  import { T as Tracer } from './observability-D-HZN_mF.js';
7
- import { P as PermissionPolicy } from './permission-B9SB45lp.js';
8
- import { U as Usage, C as Context, J as JSONSchema, R as Request, b as Response, g as ContentBlock, n as TextBlock, T as Tool, P as Provider, o as RunOptions } from './context-MRk5PhNv.js';
9
- import { W as WireFamily, H as HookEvent, e as HookMatcher, I as InProcessHook, h as Config } from './config-BMCj_XDs.js';
7
+ import { P as PermissionPolicy } from './permission-Bd-57Lbl.js';
8
+ import { U as Usage, C as Context, J as JSONSchema, R as Request, b as Response, g as ContentBlock, p as TextBlock, T as Tool, P as Provider, s as RunOptions } from './context-C0U8B9NF.js';
9
+ import { W as WireFamily, H as HookEvent, f as HookMatcher, I as InProcessHook, i as Config } from './config-VKfOZ-6X.js';
10
10
 
11
11
  /**
12
12
  * Single fleet-wide event with subagent attribution. Whatever a child
@@ -510,6 +510,17 @@ interface SubagentConfig {
510
510
  * fully enforce (e.g., preventing delegation by removing the delegate tool).
511
511
  */
512
512
  disabledTools?: string[] | undefined;
513
+ /**
514
+ * Capability allowlist for this subagent's `AutoApprovePermissionPolicy`.
515
+ * Subagents run non-interactively, so the policy auto-approves only tools
516
+ * whose declared capabilities intersect this list; everything else is
517
+ * denied by the subagent guard. Defaults (when omitted) to the read-only
518
+ * safe set `['fs.read', 'net.outbound']`. Widen it per-spawn when a task
519
+ * legitimately needs more — e.g. `/techstack` adds `'fs.write'` so the
520
+ * subagent can write its report. Never grant `shell.*` unless the task
521
+ * truly requires arbitrary command execution.
522
+ */
523
+ allowedCapabilities?: readonly string[] | undefined;
513
524
  model?: string | undefined;
514
525
  priority?: number | undefined;
515
526
  /**
@@ -819,6 +830,13 @@ interface SlashCommand {
819
830
  * If absent, `/help <name>` falls back to `description`.
820
831
  */
821
832
  help?: string | undefined;
833
+ /**
834
+ * When true, this command does not appear in the slash-picker list
835
+ * triggered by typing `/` alone. It is still dispatchable and
836
+ * searchable when the user types a matching prefix (e.g. `/f`).
837
+ * Defaults to false.
838
+ */
839
+ hidden?: boolean | undefined;
822
840
  /**
823
841
  * Execute the command.
824
842
  * @param args Everything after the command name (trimmed by dispatch).
@@ -1,4 +1,4 @@
1
- import { U as Usage, C as Context, j as ToolProgressEvent, T as Tool } from './context-MRk5PhNv.js';
1
+ import { U as Usage, C as Context, j as ToolProgressEvent, T as Tool, k as ToolOutputMetadata } from './context-C0U8B9NF.js';
2
2
 
3
3
  type MemoryScope = 'project-agents' | 'project-memory' | 'user-memory';
4
4
  type MemoryType = 'fact' | 'decision' | 'convention' | 'preference' | 'reference' | 'anti_pattern';
@@ -287,6 +287,43 @@ interface EventMap {
287
287
  pattern: string;
288
288
  decision: 'always' | 'deny';
289
289
  };
290
+ /**
291
+ * Fired when the agent loop detects that the model is repeating the same
292
+ * response shape over and over — a tight loop that would otherwise burn
293
+ * iterations indefinitely. The loop breaks with status `max_iterations`
294
+ * after `repeatCount` consecutive identical iterations.
295
+ *
296
+ * Two flavours caught by the same safety valve:
297
+ * - `kind: 'tool'` — the same tool(s) called with effectively the same
298
+ * inputs (catches k2p7's tendency to retry identical tool calls when
299
+ * a tool returns an unexpected empty result).
300
+ * - `kind: 'message'` — the same assistant text repeated, with no tool
301
+ * calls. K2P7 and other weak-instruction-following models can echo
302
+ * their last assistant turn verbatim across many iterations in
303
+ * autonomous-continue mode. The fingerprint also matches this case
304
+ * so the safety valve catches it too.
305
+ * - `kind: 'mixed'` — both: the response contains tool calls AND text,
306
+ * and the combined fingerprint (tool names + text) repeats.
307
+ *
308
+ * UIs can render a warning chip. The `kind` field is additive — older
309
+ * subscribers that only read `tools` continue to work.
310
+ */
311
+ 'tool.loop_detected': {
312
+ ctx: Context;
313
+ /** Comma-separated tool names involved in the loop, or empty string for pure message loops. */
314
+ tools: string;
315
+ /** Number of consecutive identical iterations detected. */
316
+ repeatCount: number;
317
+ /** 0-based iteration index where the loop was detected. */
318
+ iteration: number;
319
+ /**
320
+ * Shape of the loop. `tool` = identical tool calls; `message` = identical
321
+ * text-only response; `mixed` = both tool calls and text repeated.
322
+ * Defaults to `tool` for backward compatibility with subscribers that
323
+ * pre-date the field.
324
+ */
325
+ kind?: 'tool' | 'message' | 'mixed' | undefined;
326
+ };
290
327
  /**
291
328
  * `output` is a truncated preview of the tool's serialized result text
292
329
  * (capped at ~400 chars by the emitter). UIs render this inline in the
@@ -326,6 +363,13 @@ interface EventMap {
326
363
  * actual lines the model received and forwards it here. Undefined
327
364
  * for tools without a meaningful line count. */
328
365
  outputLines?: number | undefined;
366
+ /**
367
+ * Parsed context-management metadata for the result the model saw. This is
368
+ * intentionally compact: file/symbol/error/path-integrity hints, not the
369
+ * full output body. Compaction uses it to distinguish seen information from
370
+ * information later referenced by the assistant.
371
+ */
372
+ metadata?: ToolOutputMetadata | undefined;
329
373
  };
330
374
  /**
331
375
  * Fired by the `delegate` tool right before it hands work to a subagent
@@ -453,6 +497,21 @@ interface EventMap {
453
497
  load: number;
454
498
  /** Provider's max context window in tokens. */
455
499
  maxContext: number;
500
+ /** Budget snapshot used for the compaction decision. */
501
+ budget?: {
502
+ maxContext: number;
503
+ inputTokens: number;
504
+ availableInputTokens: number;
505
+ remainingInputTokens: number;
506
+ reservedOutputTokens: number;
507
+ reservedSafetyTokens: number;
508
+ load: number;
509
+ overflowTokens: number;
510
+ } | undefined;
511
+ /** Adaptive trigger signals observed alongside token pressure. */
512
+ signals?: {
513
+ repeatedReadCount?: number | undefined;
514
+ } | undefined;
456
515
  /** Full compaction report from the compactor. */
457
516
  report: {
458
517
  before: number;
@@ -478,6 +537,19 @@ interface EventMap {
478
537
  level: 'warn' | 'soft' | 'hard';
479
538
  tokens: number;
480
539
  maxContext: number;
540
+ budget?: {
541
+ maxContext: number;
542
+ inputTokens: number;
543
+ availableInputTokens: number;
544
+ remainingInputTokens: number;
545
+ reservedOutputTokens: number;
546
+ reservedSafetyTokens: number;
547
+ load: number;
548
+ overflowTokens: number;
549
+ } | undefined;
550
+ signals?: {
551
+ repeatedReadCount?: number | undefined;
552
+ } | undefined;
481
553
  load: number;
482
554
  fatal: boolean;
483
555
  };
@@ -1,4 +1,4 @@
1
- import { C as Context } from './context-MRk5PhNv.js';
1
+ import { C as Context } from './context-C0U8B9NF.js';
2
2
 
3
3
  interface CompactRepairReport {
4
4
  removedToolUses: string[];
@@ -39,6 +39,24 @@ interface CompactReport {
39
39
  * session log). Undefined when no range was collapsed this pass.
40
40
  */
41
41
  collapsedDigest?: string | undefined;
42
+ /**
43
+ * Compact state digest derived from tool-output instrumentation. It carries
44
+ * intent, path integrity, referenced tool results, active errors and implicit
45
+ * facts without copying full tool outputs back into the context window.
46
+ */
47
+ evidenceDigest?: string | undefined;
48
+ /**
49
+ * Deterministic post-compaction sanity check. This is deliberately local and
50
+ * cheap; LLM self-verification can be layered on top, but the compactor still
51
+ * records whether the compacted context retained an intent anchor and path
52
+ * trail.
53
+ */
54
+ quality?: {
55
+ ok: boolean;
56
+ hasIntent: boolean;
57
+ hasPathTrail: boolean;
58
+ issues: string[];
59
+ } | undefined;
42
60
  }
43
61
  interface Compactor {
44
62
  compact(ctx: Context, opts?: {
@@ -1,4 +1,4 @@
1
- import { k as Capabilities, f as Permission } from './context-MRk5PhNv.js';
1
+ import { l as ReasoningConfig, m as Capabilities, f as Permission, n as ReasoningEffort, o as CacheTtl } from './context-C0U8B9NF.js';
2
2
 
3
3
  type ContextWindowModeId = 'balanced' | 'frugal' | 'deep' | 'archival';
4
4
  type ContextWindowAggressiveOn = 'hard' | 'soft' | 'warn';
@@ -134,12 +134,14 @@ type HookEntry = {
134
134
  * Mirror of the models.dev/api.json schema. Top-level is keyed by provider id.
135
135
  * We keep `unknown` for fields we don't read so the cached payload stays faithful.
136
136
  */
137
+
137
138
  interface ModelsDevModel {
138
139
  id: string;
139
140
  name: string;
140
141
  family?: string | undefined;
141
142
  attachment?: boolean | undefined;
142
143
  reasoning?: boolean | undefined;
144
+ reasoningConfig?: ReasoningConfig | undefined;
143
145
  tool_call?: boolean | undefined;
144
146
  temperature?: boolean | undefined;
145
147
  knowledge?: string | undefined;
@@ -155,6 +157,8 @@ interface ModelsDevModel {
155
157
  output?: number | undefined;
156
158
  cache_read?: number | undefined;
157
159
  cache_write?: number | undefined;
160
+ cache_write_5m?: number | undefined;
161
+ cache_write_1h?: number | undefined;
158
162
  [k: string]: number | undefined;
159
163
  };
160
164
  limit?: {
@@ -181,7 +185,7 @@ type ModelsDevPayload = Record<string, ModelsDevProvider>;
181
185
  * Canonical wire-format families WrongStack knows how to speak natively.
182
186
  * Used by the provider registry to pick a transport.
183
187
  */
184
- type WireFamily = 'anthropic' | 'openai' | 'openai-compatible' | 'google' | 'unsupported';
188
+ type WireFamily = 'anthropic' | 'anthropic-oauth' | 'openai' | 'openai-compatible' | 'openai-codex' | 'github-copilot' | 'google' | 'unsupported';
185
189
  interface ResolvedProvider {
186
190
  id: string;
187
191
  name: string;
@@ -202,6 +206,7 @@ interface ResolvedModel {
202
206
  maxContext: number;
203
207
  maxOutput?: number | undefined;
204
208
  knowledge?: string | undefined;
209
+ reasoningConfig?: ReasoningConfig | undefined;
205
210
  };
206
211
  cost?: ModelsDevModel['cost'] | undefined;
207
212
  }
@@ -224,6 +229,60 @@ interface ModelsRegistry {
224
229
  ageSeconds(): Promise<number>;
225
230
  }
226
231
 
232
+ /**
233
+ * Runtime reasoning controls the user can set per-session/project. Mapped into
234
+ * the provider `Request.reasoning` field by the model-runtime request
235
+ * middleware, gated by the active model's `reasoningConfig` capabilities so
236
+ * unsupported values are omitted (and warned) instead of triggering provider
237
+ * 400s. See `resolveReasoningForRequest()` in packages/core.
238
+ */
239
+ interface ModelRuntimeReasoningConfig {
240
+ /**
241
+ * Whether to send explicit reasoning enable/disable.
242
+ * - 'auto' → do not send explicit fields; provider/model default wins
243
+ * - 'on' → send `reasoning.enabled = true`
244
+ * - 'off' → send `reasoning.enabled = false` only when the model supports disable
245
+ */
246
+ mode?: 'auto' | 'on' | 'off' | undefined;
247
+ /** Reasoning effort. Only sent when the model advertises `effortSupported`. */
248
+ effort?: ReasoningEffort | undefined;
249
+ /** Preserve thinking across turns. Only sent when `preserveThinking !== 'unsupported'`. */
250
+ preserve?: boolean | undefined;
251
+ }
252
+ /**
253
+ * Runtime prompt-cache controls mapped into `Request.cache`. Currently only the
254
+ * Anthropic TTL toggle (5m vs 1h) is exposed; other providers ignore it.
255
+ */
256
+ interface ModelRuntimeCacheConfig {
257
+ ttl?: CacheTtl | undefined;
258
+ }
259
+ /**
260
+ * Shared runtime controls applied to every provider request, regardless of host
261
+ * (REPL / TUI / WebUI). The CLI installs a single request-pipeline middleware
262
+ * that reads these and mutates the outgoing `Request`.
263
+ */
264
+ interface ModelRuntimeConfig {
265
+ reasoning?: ModelRuntimeReasoningConfig | undefined;
266
+ cache?: ModelRuntimeCacheConfig | undefined;
267
+ }
268
+ /**
269
+ * HQ client connection settings. Same-machine clients can auto-discover the
270
+ * local HQ auth file; remote clients use this config-backed URL/token pair.
271
+ */
272
+ interface HqClientConfig {
273
+ /** Enable HQ publishing. Env WRONGSTACK_HQ_ENABLED still overrides at runtime. */
274
+ enabled?: boolean | undefined;
275
+ /** HQ HTTP base URL, e.g. http://host:3499. */
276
+ url?: string | undefined;
277
+ /** Client token for /ws/client. Stored encrypted by SecretVault when persisted. */
278
+ token?: string | undefined;
279
+ /** Optional HQ data dir for same-machine auth.json discovery. */
280
+ dataDir?: string | undefined;
281
+ /** Send raw content previews to HQ instead of redacted previews. */
282
+ rawContent?: boolean | undefined;
283
+ /** Override project display name in HQ. */
284
+ projectAlias?: string | undefined;
285
+ }
227
286
  /**
228
287
  * Token-saving mode tier levels. Controls how aggressively the system prompt
229
288
  * is compacted to reduce per-request token consumption.
@@ -325,6 +384,32 @@ interface ProviderApiKey {
325
384
  apiKey: string;
326
385
  /** ISO-8601 timestamp the key was added. */
327
386
  createdAt: string;
387
+ /**
388
+ * How this credential was obtained.
389
+ * - `api_key` — manually pasted API key (default)
390
+ * - `oauth` — OAuth 2.0 device-code / authorization-code flow
391
+ * - `session_token` — extracted from browser session (ChatGPT web, etc.)
392
+ */
393
+ authMethod?: 'api_key' | 'oauth' | 'session_token' | undefined;
394
+ /** ISO-8601 expiry. When set, the token manager will refresh before this time. */
395
+ expiresAt?: string | undefined;
396
+ /**
397
+ * OAuth refresh token. Stored encrypted by the secret-vault walker because
398
+ * the field name contains `Token` (case-insensitive match by vault).
399
+ */
400
+ refreshToken?: string | undefined;
401
+ /** Token type as returned by the OAuth endpoint (e.g. "bearer"). */
402
+ tokenType?: string | undefined;
403
+ /** OAuth scope string (e.g. "openai.models.read openai.models.use"). */
404
+ scope?: string | undefined;
405
+ /**
406
+ * ChatGPT account id, extracted from the OAuth access-token JWT
407
+ * (`https://api.openai.com/auth`.chatgpt_account_id). Sent as the
408
+ * `chatgpt-account-id` header by the `openai-codex` wire family. Cached
409
+ * here for display/diagnostics; the provider re-derives it from the live
410
+ * token at request time so it can never go stale after a refresh.
411
+ */
412
+ accountId?: string | undefined;
328
413
  }
329
414
  interface ProviderConfig {
330
415
  type: string;
@@ -362,6 +447,23 @@ interface ProviderConfig {
362
447
  * capability overrides. The model id is the key, not a fully qualified id.
363
448
  */
364
449
  customModels?: Record<string, CustomModelDefinition>;
450
+ /**
451
+ * Per-provider OAuth configuration. When present, `wstack auth login <id>`
452
+ * uses this instead of prompting for a raw API key. Set by the catalog or
453
+ * by the user via `/settings`.
454
+ */
455
+ oauthConfig?: {
456
+ /** OAuth client id registered with the provider. */
457
+ clientId?: string | undefined;
458
+ /** Device authorization endpoint (RFC 8628). */
459
+ deviceCodeEndpoint?: string | undefined;
460
+ /** Token endpoint for code exchange and refresh. */
461
+ tokenEndpoint?: string | undefined;
462
+ /** Authorization server URL shown to the user for opening in browser. */
463
+ authorizationEndpoint?: string | undefined;
464
+ /** Default OAuth scopes to request. */
465
+ scopes?: string[] | undefined;
466
+ } | undefined;
365
467
  }
366
468
  /**
367
469
  * One entry in the per-task model matrix. Pins a catalog role, a phase, or
@@ -391,6 +493,14 @@ interface MCPServerConfig {
391
493
  permission?: Permission | undefined;
392
494
  startupTimeoutMs?: number | undefined;
393
495
  requestTimeoutMs?: number | undefined;
496
+ /**
497
+ * Lazy connect: when true, the server process is NOT spawned at boot. Its
498
+ * tools are registered from a cached manifest (discovered on the first ever
499
+ * connect) and the server only spawns when one of its tools is actually
500
+ * called, then auto-sleeps after an idle period. Default (false/undefined) =
501
+ * eager connect at boot.
502
+ */
503
+ lazy?: boolean | undefined;
394
504
  }
395
505
  interface LogConfig {
396
506
  level: 'error' | 'warn' | 'info' | 'debug' | 'trace';
@@ -638,6 +748,15 @@ interface Config {
638
748
  * Controls what gets written to the persistent JSONL transcript.
639
749
  */
640
750
  session?: SessionLoggingConfig | undefined;
751
+ /**
752
+ * Runtime reasoning / cache controls applied to every provider request
753
+ * (REPL/TUI/WebUI). Mapped into `Request.reasoning` and `Request.cache` by a
754
+ * single request-pipeline middleware, gated by the active model's
755
+ * capabilities. See `ModelRuntimeConfig`.
756
+ */
757
+ modelRuntime?: ModelRuntimeConfig | undefined;
758
+ /** HQ client publishing settings, used by CLI/REPL/TUI/WebUI consistently. */
759
+ hq?: HqClientConfig | undefined;
641
760
  /**
642
761
  * Cloud sync configuration. Stored separately in sync.json to avoid
643
762
  * accidentally committing the GitHub token to project configs.
@@ -699,4 +818,4 @@ interface ConfigStore {
699
818
  watch(cb: (next: Readonly<Config>, prev: Readonly<Config>) => void): () => void;
700
819
  }
701
820
 
702
- export { type AutonomyConfig as A, type ProviderApiKey as B, type ContextWindowAggressiveOn as C, DEFAULT_CONTEXT_WINDOW_MODE_ID as D, type SessionLoggingConfig as E, type FeaturesConfig as F, type SyncCategory as G, type HookEvent as H, type InProcessHook as I, type ToolsConfig as J, formatContextWindowModeList as K, type LaunchConfig as L, type ModelsRegistry as M, getContextWindowMode as N, isContextWindowModeId as O, type ProviderConfig as P, listContextWindowModes as Q, type ResolvedProvider as R, type ShellHook as S, type TokenSavingTier as T, normalizeTokenSavingTier as U, resolveContextWindowPolicy as V, type WireFamily as W, type ModelsDevPayload as a, type ResolvedModel as b, type MCPServerConfig as c, type ModelMatrixEntry as d, type HookMatcher as e, type HookEntry as f, type ContextWindowPolicy as g, type Config as h, type ConfigStore as i, type ConfigLoader as j, type SyncConfig as k, type HookInput as l, type HookOutcome as m, CONTEXT_WINDOW_MODES as n, type CircuitBreakerRuntimeConfig as o, type ContextConfig as p, type ContextWindowConfigLike as q, type ContextWindowMode as r, type ContextWindowModeId as s, type ContextWindowThresholds as t, type CustomModelDefinition as u, type IndexingConfig as v, type LogConfig as w, type ModelsDevModel as x, type ModelsDevProvider as y, type PluginConfig as z };
821
+ export { type AutonomyConfig as A, type ModelRuntimeConfig as B, type ContextWindowAggressiveOn as C, DEFAULT_CONTEXT_WINDOW_MODE_ID as D, type ModelRuntimeReasoningConfig as E, type FeaturesConfig as F, type ModelsDevProvider as G, type HookEvent as H, type InProcessHook as I, type PluginConfig as J, type ProviderApiKey as K, type LaunchConfig as L, type ModelsRegistry as M, type SessionLoggingConfig as N, type SyncCategory as O, type ProviderConfig as P, type ToolsConfig as Q, type ResolvedProvider as R, type ShellHook as S, type TokenSavingTier as T, formatContextWindowModeList as U, getContextWindowMode as V, type WireFamily as W, isContextWindowModeId as X, listContextWindowModes as Y, normalizeTokenSavingTier as Z, resolveContextWindowPolicy as _, type ModelsDevPayload as a, type ResolvedModel as b, type MCPServerConfig as c, type ModelMatrixEntry as d, type ModelsDevModel as e, type HookMatcher as f, type HookEntry as g, type ContextWindowPolicy as h, type Config as i, type ConfigStore as j, type ConfigLoader as k, type SyncConfig as l, type HookInput as m, type HookOutcome as n, CONTEXT_WINDOW_MODES as o, type CircuitBreakerRuntimeConfig as p, type ContextConfig as q, type ContextWindowConfigLike as r, type ContextWindowMode as s, type ContextWindowModeId as t, type ContextWindowThresholds as u, type CustomModelDefinition as v, type HqClientConfig as w, type IndexingConfig as x, type LogConfig as y, type ModelRuntimeCacheConfig as z };
@@ -502,11 +502,32 @@ interface ToolCallContext {
502
502
  * invariant — a TOTAL `input` plus a separate `cacheRead` count would bill
503
503
  * cached tokens twice and skew cache-hit-ratio reporting.
504
504
  */
505
+ type ReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
506
+ type CacheTtl = '5m' | '1h';
505
507
  interface Usage {
506
508
  input: number;
507
509
  output: number;
508
510
  cacheRead?: number | undefined;
511
+ /** Back-compat aggregate of all cache-write tokens. Prefer TTL-specific fields when present. */
509
512
  cacheWrite?: number | undefined;
513
+ cacheWrite5m?: number | undefined;
514
+ cacheWrite1h?: number | undefined;
515
+ }
516
+ interface ReasoningRequest {
517
+ enabled?: boolean | undefined;
518
+ effort?: ReasoningEffort | undefined;
519
+ preserve?: boolean | undefined;
520
+ display?: 'summarized' | 'omitted' | undefined;
521
+ }
522
+ interface RequestCacheControl {
523
+ ttl?: CacheTtl | undefined;
524
+ }
525
+ interface ReasoningConfig {
526
+ default: 'enabled' | 'disabled' | 'adaptive' | 'always_on';
527
+ disableSupported: boolean;
528
+ effortSupported: boolean;
529
+ effortLevels: ReasoningEffort[];
530
+ preserveThinking: 'unsupported' | 'optional' | 'always_on';
510
531
  }
511
532
  interface Capabilities {
512
533
  tools: boolean;
@@ -533,6 +554,8 @@ interface Request {
533
554
  type: 'tool' | undefined;
534
555
  name: string;
535
556
  };
557
+ reasoning?: ReasoningRequest | undefined;
558
+ cache?: RequestCacheControl | undefined;
536
559
  }
537
560
  type StopReason = 'end_turn' | 'tool_use' | 'max_tokens' | 'stop_sequence' | 'refusal';
538
561
  interface Response {
@@ -775,6 +798,21 @@ type SessionEvent = {
775
798
  phase: string;
776
799
  saved: number;
777
800
  }>;
801
+ /** Context budget snapshot used to trigger this compaction. */
802
+ budget?: {
803
+ maxContext: number;
804
+ inputTokens: number;
805
+ availableInputTokens: number;
806
+ remainingInputTokens: number;
807
+ reservedOutputTokens: number;
808
+ reservedSafetyTokens: number;
809
+ load: number;
810
+ overflowTokens: number;
811
+ } | undefined;
812
+ /** Adaptive trigger signals observed alongside token pressure. */
813
+ signals?: {
814
+ repeatedReadCount?: number | undefined;
815
+ } | undefined;
778
816
  /**
779
817
  * Lossless digest of the range collapsed during this compaction (text
780
818
  * content preserved; raw tool I/O omitted). Captures *what* was collapsed
@@ -1115,6 +1153,54 @@ interface SessionWriter {
1115
1153
  clearInFlightMarker(reason: 'clean' | 'aborted' | 'recovered'): Promise<void>;
1116
1154
  }
1117
1155
 
1156
+ type ToolEvidenceStatus = 'seen' | 'referenced';
1157
+ interface ToolOutputMetadata {
1158
+ toolUseId: string;
1159
+ toolName: string;
1160
+ ok: boolean;
1161
+ inputSummary?: string | undefined;
1162
+ summary: string;
1163
+ files: string[];
1164
+ symbols: string[];
1165
+ commands: string[];
1166
+ errors: string[];
1167
+ status: ToolEvidenceStatus;
1168
+ referenceCount: number;
1169
+ seenAt: number;
1170
+ referencedAt?: number | undefined;
1171
+ outputBytes?: number | undefined;
1172
+ outputTokens?: number | undefined;
1173
+ outputLines?: number | undefined;
1174
+ }
1175
+ interface ContextFileEvidence {
1176
+ path: string;
1177
+ reads: number;
1178
+ writes: number;
1179
+ tools: string[];
1180
+ referenced: boolean;
1181
+ lastToolUseId?: string | undefined;
1182
+ }
1183
+ interface ContextIntentEvidence {
1184
+ text: string;
1185
+ updatedAt: number;
1186
+ }
1187
+ interface ContextRepeatedReadEvidence {
1188
+ file: string;
1189
+ count: number;
1190
+ lastToolUseId: string;
1191
+ }
1192
+ interface ContextEvidenceState {
1193
+ currentIntent?: ContextIntentEvidence | undefined;
1194
+ sessionGoals: string[];
1195
+ implicitFacts: string[];
1196
+ activeErrors: string[];
1197
+ toolCalls: ToolOutputMetadata[];
1198
+ fileGraph: Record<string, ContextFileEvidence>;
1199
+ repeatedReads: ContextRepeatedReadEvidence[];
1200
+ lastReadPath?: string | undefined;
1201
+ updatedAt: number;
1202
+ }
1203
+
1118
1204
  interface CacheStats {
1119
1205
  /** Tokens served from cache (cheaper). */
1120
1206
  readTokens: number;
@@ -1340,6 +1426,7 @@ declare class Context implements RunEnv {
1340
1426
  todos: TodoItem[];
1341
1427
  readFiles: Set<string>;
1342
1428
  fileMtimes: Map<string, number>;
1429
+ contextEvidence: ContextEvidenceState;
1343
1430
  systemPrompt: TextBlock[];
1344
1431
  provider: Provider;
1345
1432
  session: SessionWriter;
@@ -1439,4 +1526,4 @@ declare class Context implements RunEnv {
1439
1526
  usage(): Usage;
1440
1527
  }
1441
1528
 
1442
- export { ToolError as $, AgentError as A, type MessageRole as B, Context as C, PluginError as D, ERROR_CODES as E, type FileSnapshot as F, type ProviderErrorBody as G, type ReadonlyConversationState as H, type ImageBlock as I, type JSONSchema as J, type RiskTier as K, type RunEnv as L, type Message as M, SddError as N, SessionError as O, type Provider as P, type StateChange as Q, type Request as R, type SessionEvent as S, type Tool as T, type Usage as U, type StateChangeHandler as V, type StopReason as W, type StreamEvent as X, StreamHangError as Y, type ThinkingBlock as Z, type ToolCallContext as _, type SessionWriter as a, type ToolFinalEvent as a0, type ToolIconId as a1, type ToolStreamEvent as a2, WrongStackError as a3, asBlocks as a4, asText as a5, extractRunEnv as a6, isAgentError as a7, isConfigError as a8, isFsError as a9, isImageBlock as aa, isPluginError as ab, isSddError as ac, isSessionError as ad, isTextBlock as ae, isThinkingBlock as af, isToolError as ag, isToolResultBlock as ah, isToolUseBlock as ai, isWrongStackError as aj, toWrongStackError as ak, wrapAsState as al, type Response as b, type TokenCounter as c, type CacheStats as d, ProviderError as e, type Permission as f, type ContentBlock as g, type SessionMetadata as h, type SessionStore as i, type ToolProgressEvent as j, type Capabilities as k, type ToolUseBlock as l, type ToolResultBlock as m, type TextBlock as n, type RunOptions as o, type ResumedSession as p, type SessionData as q, type SessionSummary as r, type TodoItem as s, ConversationState as t, ConfigError as u, type ContextInit as v, type ErrorCode as w, type ErrorSeverity as x, type ErrorSubsystem as y, FsError as z };
1529
+ export { type RunEnv as $, AgentError as A, type ContextFileEvidence as B, Context as C, type ContextInit as D, type ContextIntentEvidence as E, type ContextRepeatedReadEvidence as F, ERROR_CODES as G, type ErrorCode as H, type ErrorSeverity as I, type JSONSchema as J, type ErrorSubsystem as K, type FileSnapshot as L, type Message as M, FsError as N, type ImageBlock as O, type Provider as P, type MessageRole as Q, type Request as R, type SessionEvent as S, type Tool as T, type Usage as U, PluginError as V, type ProviderErrorBody as W, type ReadonlyConversationState as X, type ReasoningRequest as Y, type RequestCacheControl as Z, type RiskTier as _, type SessionWriter as a, SddError as a0, SessionError as a1, type StateChange as a2, type StateChangeHandler as a3, type StopReason as a4, type StreamEvent as a5, StreamHangError as a6, type ThinkingBlock as a7, type ToolCallContext as a8, ToolError as a9, type ToolEvidenceStatus as aa, type ToolFinalEvent as ab, type ToolIconId as ac, type ToolStreamEvent as ad, WrongStackError as ae, asBlocks as af, asText as ag, extractRunEnv as ah, isAgentError as ai, isConfigError as aj, isFsError as ak, isImageBlock as al, isPluginError as am, isSddError as an, isSessionError as ao, isTextBlock as ap, isThinkingBlock as aq, isToolError as ar, isToolResultBlock as as, isToolUseBlock as at, isWrongStackError as au, toWrongStackError as av, wrapAsState as aw, type Response as b, type TokenCounter as c, type CacheStats as d, ProviderError as e, type Permission as f, type ContentBlock as g, type SessionMetadata as h, type SessionStore as i, type ToolProgressEvent as j, type ToolOutputMetadata as k, type ReasoningConfig as l, type Capabilities as m, type ReasoningEffort as n, type CacheTtl as o, type TextBlock as p, type ToolUseBlock as q, type ToolResultBlock as r, type RunOptions as s, type ResumedSession as t, type SessionData as u, type SessionSummary as v, type TodoItem as w, ConversationState as x, ConfigError as y, type ContextEvidenceState as z };