typeclaw 0.50.0 → 0.51.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 (90) hide show
  1. package/dist/types/agent/bash-sandbox-env.d.ts +15 -0
  2. package/dist/types/agent/bash-sandbox-proc.d.ts +8 -0
  3. package/dist/types/agent/bash-sandbox.d.ts +94 -0
  4. package/dist/types/agent/compaction.d.ts +4 -4
  5. package/dist/types/agent/idle-compaction.d.ts +1 -0
  6. package/dist/types/agent/index.d.ts +5 -17
  7. package/dist/types/agent/output-allowance.d.ts +4 -0
  8. package/dist/types/agent/plugin-tools.d.ts +4 -75
  9. package/dist/types/agent/system-prompt-composition.d.ts +17 -0
  10. package/dist/types/agent/tools/ddg.d.ts +9 -0
  11. package/dist/types/agent/tools/stream-snapshot.d.ts +1 -1
  12. package/dist/types/agent/tools/webfetch/tool.d.ts +1 -1
  13. package/dist/types/channels/github-review-check.d.ts +1 -1
  14. package/dist/types/channels/router.d.ts +11 -49
  15. package/dist/types/config/config.d.ts +24 -11
  16. package/dist/types/config/providers.d.ts +3 -1
  17. package/dist/types/container/start.d.ts +1 -0
  18. package/dist/types/eval/cell.d.ts +26 -0
  19. package/dist/types/eval/config.d.ts +19 -0
  20. package/dist/types/eval/dispatch.d.ts +7 -0
  21. package/dist/types/eval/kernel.d.ts +28 -0
  22. package/dist/types/eval/process.d.ts +23 -0
  23. package/dist/types/eval/protocol.d.ts +34 -0
  24. package/dist/types/eval/sandbox.d.ts +10 -0
  25. package/dist/types/eval/tool.d.ts +17 -0
  26. package/dist/types/eval/wire.d.ts +33 -0
  27. package/dist/types/sandbox/env-exposure.d.ts +2 -0
  28. package/package.json +5 -5
  29. package/src/agent/bash-sandbox-env.ts +104 -0
  30. package/src/agent/bash-sandbox-proc.ts +70 -0
  31. package/src/agent/bash-sandbox.ts +225 -0
  32. package/src/agent/compaction.ts +22 -10
  33. package/src/agent/idle-compaction.ts +7 -3
  34. package/src/agent/index.ts +66 -157
  35. package/src/agent/output-allowance.ts +7 -0
  36. package/src/agent/plugin-tools.ts +29 -379
  37. package/src/agent/session-origin.ts +2 -1
  38. package/src/agent/subagent-completion-reminder.ts +2 -2
  39. package/src/agent/system-prompt-composition.ts +141 -0
  40. package/src/agent/system-prompt.ts +4 -4
  41. package/src/agent/todo/scope.ts +1 -1
  42. package/src/agent/tools/ddg.ts +71 -11
  43. package/src/agent/tools-without-local-file-operands.ts +4 -0
  44. package/src/browser/fill-secret.ts +307 -0
  45. package/src/bundled-plugins/explorer/explorer.ts +1 -1
  46. package/src/bundled-plugins/github-cli-auth/gh-review-detect.ts +40 -16
  47. package/src/bundled-plugins/github-cli-auth/graphql-auth-nudge.ts +12 -7
  48. package/src/bundled-plugins/github-cli-auth/index.ts +10 -1
  49. package/src/bundled-plugins/managed-browser/index.ts +107 -2
  50. package/src/bundled-plugins/memory/dreaming.ts +4 -1
  51. package/src/bundled-plugins/memory/load-memory.ts +2 -4
  52. package/src/bundled-plugins/memory/memory-logger.ts +74 -2
  53. package/src/bundled-plugins/memory/transcript-preload.ts +103 -0
  54. package/src/bundled-plugins/memory/vector/hybrid.ts +25 -14
  55. package/src/bundled-plugins/security/policies/private-surface-read.ts +166 -201
  56. package/src/channels/adapters/discord-bot-reference.ts +5 -4
  57. package/src/channels/adapters/discord-bot.ts +1 -0
  58. package/src/channels/adapters/discord-classify.ts +8 -3
  59. package/src/channels/adapters/discord.ts +29 -0
  60. package/src/channels/github-review-check.ts +5 -1
  61. package/src/channels/github-review-verdict-coordinator.ts +68 -2
  62. package/src/channels/router.ts +88 -107
  63. package/src/channels/subagent-completion-bridge.ts +3 -2
  64. package/src/cli/hostd.ts +3 -0
  65. package/src/config/config.ts +15 -0
  66. package/src/config/providers.ts +10 -4
  67. package/src/container/start.ts +37 -1
  68. package/src/doctor/checks.ts +25 -16
  69. package/src/doctor/index.ts +48 -12
  70. package/src/doctor/operational-incidents.ts +16 -1
  71. package/src/doctor/plugin-bridge.ts +14 -1
  72. package/src/doctor/stage.ts +14 -0
  73. package/src/doctor/types.ts +6 -0
  74. package/src/eval/cell.ts +93 -0
  75. package/src/eval/config.ts +32 -0
  76. package/src/eval/dispatch.ts +67 -0
  77. package/src/eval/entry.ts +261 -0
  78. package/src/eval/kernel.ts +154 -0
  79. package/src/eval/process.ts +113 -0
  80. package/src/eval/protocol.ts +26 -0
  81. package/src/eval/redeclare.ts +174 -0
  82. package/src/eval/sandbox.ts +114 -0
  83. package/src/eval/tool.ts +98 -0
  84. package/src/eval/wire.ts +93 -0
  85. package/src/operations/classify-tool-outcome.ts +1 -1
  86. package/src/plugin/core-tool-names.ts +6 -1
  87. package/src/sandbox/env-exposure.ts +20 -0
  88. package/src/server/index.ts +46 -11
  89. package/src/skills/typeclaw-config/SKILL.md +20 -2
  90. package/typeclaw.schema.json +52 -0
@@ -10,7 +10,7 @@ const IDLE_COMPACTION_TRIGGER_RATIO = 0.9
10
10
 
11
11
  export function attachIdleCompaction(
12
12
  session: AgentSession,
13
- options: { schedule?: IdleSchedule; onApplied?: () => void } = {},
13
+ options: { schedule?: IdleSchedule; onApplied?: () => void; maxTriggerTokens?: number } = {},
14
14
  ): () => void {
15
15
  const schedule = options.schedule ?? scheduleIdle
16
16
  // Capture before turn drivers install output caps that apply only to replies.
@@ -42,7 +42,7 @@ export function attachIdleCompaction(
42
42
  !model ||
43
43
  leaf === attemptedLeaf ||
44
44
  tokens == null ||
45
- tokens < compactionTriggerTokens(model) * IDLE_COMPACTION_TRIGGER_RATIO
45
+ tokens < compactionTriggerTokens(model, options.maxTriggerTokens) * IDLE_COMPACTION_TRIGGER_RATIO
46
46
  )
47
47
  return
48
48
 
@@ -95,7 +95,11 @@ export function attachIdleCompaction(
95
95
  // can be disposed without starting a summary they will never use.
96
96
  const tokens = session.getContextUsage()?.tokens
97
97
  const model = session.model
98
- if (model && tokens != null && tokens >= compactionTriggerTokens(model) * IDLE_COMPACTION_TRIGGER_RATIO) {
98
+ if (
99
+ model &&
100
+ tokens != null &&
101
+ tokens >= compactionTriggerTokens(model, options.maxTriggerTokens) * IDLE_COMPACTION_TRIGGER_RATIO
102
+ ) {
99
103
  cancelScheduled = schedule(run)
100
104
  }
101
105
  } else if (event.type === 'agent_start' || event.type === 'compaction_start' || event.type === 'entry_appended') {
@@ -22,6 +22,16 @@ import {
22
22
  type ResolvedProfile,
23
23
  type ThinkingLevel,
24
24
  } from '@/config'
25
+ import { config } from '@/config/config'
26
+ import { registerEvalTool, EVAL_PROMPT_HINT } from '@/eval/tool'
27
+
28
+ import { composeSystemPrompt, deriveSystemPromptMode, type SystemPromptMode } from './system-prompt-composition'
29
+ export {
30
+ composeSystemPrompt,
31
+ deriveSystemPromptMode,
32
+ type SystemPromptMode,
33
+ type SystemPromptComposition,
34
+ } from './system-prompt-composition'
25
35
  import { effectiveModels } from '@/config/model-overrides'
26
36
  import { defaultThinkingLevelForRef, isOpenAiFamilyRef, providerForModelRef, type ModelRef } from '@/config/providers'
27
37
  import { renderMcpCatalog } from '@/mcp/catalog'
@@ -53,6 +63,7 @@ import type { LiveSubagentRegistry } from './live-subagents'
53
63
  import { sanitizeMessagesForLlmReplay } from './llm-replay-sanitizer'
54
64
  import { applyModelRuntimeOverrides } from './model-overrides'
55
65
  import { createChannelLookAtTool, createLookAtTool } from './multimodal'
66
+ import { defaultOutputAllowance } from './output-allowance'
56
67
  import {
57
68
  buildBuiltinPiToolOverrides,
58
69
  isPiCodingBuiltinName,
@@ -69,12 +80,7 @@ import type { RestartHandoffOrigin } from './restart-handoff'
69
80
  import type { SubagentBashPolicy } from './reviewer-bash-policy'
70
81
  import { loadSelf } from './self'
71
82
  import { SESSION_META_CUSTOM_TYPE, sessionMetaPayload } from './session-meta'
72
- import {
73
- renderInteractiveSessionContext,
74
- renderSessionOrigin,
75
- type SessionOrigin,
76
- type SessionRoleContext,
77
- } from './session-origin'
83
+ import { renderSessionOrigin, type SessionOrigin, type SessionRoleContext } from './session-origin'
78
84
  import { SubagentCacheKeepalive } from './subagent-cache-keepalive'
79
85
  import type { CreateSessionForSubagent, SubagentCoalescer, SubagentRegistry } from './subagents'
80
86
  import {
@@ -121,7 +127,7 @@ type AgentSessionTools = NonNullable<Parameters<typeof createAgentSession>[0]>['
121
127
  // the full model maximum before context clamping (dist/api/simple-options.js:17),
122
128
  // so preserve the former safe default at the session boundary. Explicit budgets
123
129
  // remain untouched for compaction and channel-specific output caps.
124
- export const DEFAULT_MAX_OUTPUT_TOKENS = 32_000
130
+ export { DEFAULT_MAX_OUTPUT_TOKENS } from './output-allowance'
125
131
 
126
132
  export type PluginSessionWiring = {
127
133
  registry: PluginRegistry
@@ -328,24 +334,6 @@ export async function createSessionWithDispose(options: CreateSessionOptions = {
328
334
  )
329
335
  : null
330
336
 
331
- const resourceLoader =
332
- options.systemPromptOverride !== undefined
333
- ? await createOverrideResourceLoader(
334
- options.systemPromptOverride,
335
- options.origin,
336
- options.permissions,
337
- options.runtimeVersion,
338
- )
339
- : await createResourceLoader({
340
- ...(options.plugins ? { plugins: options.plugins, materializedSkills } : {}),
341
- ...(options.origin ? { origin: options.origin } : {}),
342
- ...(options.permissions ? { permissions: options.permissions } : {}),
343
- ...(options.runtimeVersion !== undefined ? { runtimeVersion: options.runtimeVersion } : {}),
344
- ...(options.mcpManager !== undefined ? { mcpManager: options.mcpManager } : {}),
345
- ...(options.subagentRegistry !== undefined ? { subagentRegistry: options.subagentRegistry } : {}),
346
- ...(isOpenAiFamilyRef(activeRef) ? { proactiveNextStepNudge: true } : {}),
347
- })
348
-
349
337
  const getOrigin: () => SessionOrigin | undefined =
350
338
  options.originRef !== undefined ? () => options.originRef!.current : () => options.origin
351
339
 
@@ -567,15 +555,57 @@ export async function createSessionWithDispose(options: CreateSessionOptions = {
567
555
  ...new Set([...builtinActiveNames, ...[...wrappedCustomSystemTools, ...pluginCustomTools].map((t) => t.name)]),
568
556
  ]
569
557
 
558
+ let activeSession: AgentSession | undefined
559
+ const evalRuntime = registerEvalTool({
560
+ settings: config.eval,
561
+ tools: customTools,
562
+ activeNames: intendedActiveToolNames,
563
+ getActiveNames: () => activeSession?.getActiveToolNames() ?? intendedActiveToolNames,
564
+ wrappers: {
565
+ agentDir: options.plugins?.agentDir ?? process.cwd(),
566
+ sessionId: options.plugins?.sessionId ?? sessionManager.getSessionId(),
567
+ hooks: options.plugins?.hooks ?? createHookBus(),
568
+ guards,
569
+ getOrigin,
570
+ getAbort,
571
+ getLoopGuardTurn,
572
+ permissions: options.permissions ?? noopPermissionService,
573
+ bashPolicy: options.bashPolicy,
574
+ },
575
+ budget: sessionBudget,
576
+ budgetState: sessionBudgetState,
577
+ })
578
+
579
+ const resourceLoader =
580
+ options.systemPromptOverride !== undefined
581
+ ? await createOverrideResourceLoader(
582
+ options.systemPromptOverride + (evalRuntime ? `\n\n${EVAL_PROMPT_HINT}` : ''),
583
+ options.origin,
584
+ options.permissions,
585
+ options.runtimeVersion,
586
+ )
587
+ : await createResourceLoader({
588
+ evalEnabled: evalRuntime !== undefined,
589
+ ...(options.plugins ? { plugins: options.plugins, materializedSkills } : {}),
590
+ ...(options.origin ? { origin: options.origin } : {}),
591
+ ...(options.permissions ? { permissions: options.permissions } : {}),
592
+ ...(options.runtimeVersion !== undefined ? { runtimeVersion: options.runtimeVersion } : {}),
593
+ ...(options.mcpManager !== undefined ? { mcpManager: options.mcpManager } : {}),
594
+ ...(options.subagentRegistry !== undefined ? { subagentRegistry: options.subagentRegistry } : {}),
595
+ ...(isOpenAiFamilyRef(activeRef) ? { proactiveNextStepNudge: true } : {}),
596
+ })
597
+
570
598
  const model = applyModelRuntimeOverrides(resolveModel(activeRef), activeRef)
571
599
  // Read live so a reloaded `models` lands on the next session without a
572
600
  // container restart.
573
601
  const thinkingLevel = resolveSessionThinkingLevel(models, resolved, activeRef, options.thinkingLevel)
602
+ // Read per session like `models`, so a reloaded ceiling applies to new sessions.
603
+ const maxCompactionTriggerTokens = getConfig().compaction.maxTriggerTokens
574
604
  const { session } = await createAgentSession({
575
605
  model,
576
606
  modelRuntime,
577
607
  sessionManager,
578
- settingsManager: createCompactionSettingsManager(model),
608
+ settingsManager: createCompactionSettingsManager(model, maxCompactionTriggerTokens),
579
609
  resourceLoader,
580
610
  noTools: 'builtin',
581
611
  tools: intendedActiveToolNames,
@@ -584,6 +614,7 @@ export async function createSessionWithDispose(options: CreateSessionOptions = {
584
614
  })
585
615
  // Pi's general warmer also runs without background children. TypeClaw owns
586
616
  // the narrower idle-parent policy and never persists synthetic ping results.
617
+ activeSession = session
587
618
  session.setCacheWarmingMode('off')
588
619
  const cacheKeepalive = options.liveSubagentRegistry
589
620
  ? new SubagentCacheKeepalive(
@@ -598,6 +629,7 @@ export async function createSessionWithDispose(options: CreateSessionOptions = {
598
629
  })
599
630
  const innerDispose = session.dispose.bind(session)
600
631
  session.dispose = () => {
632
+ void evalRuntime?.dispose()
601
633
  cacheKeepalive?.close()
602
634
  unsubCacheKeepalive()
603
635
  innerDispose()
@@ -610,9 +642,7 @@ export async function createSessionWithDispose(options: CreateSessionOptions = {
610
642
  // this function, so every origin now behaves the same way.
611
643
  const innerStreamFunction = session.agent.streamFunction
612
644
  session.agent.streamFunction = async (requestModel, context, streamOptions) => {
613
- const maxTokens =
614
- streamOptions?.maxTokens ??
615
- (requestModel.maxTokens > 0 ? Math.min(requestModel.maxTokens, DEFAULT_MAX_OUTPUT_TOKENS) : undefined)
645
+ const maxTokens = streamOptions?.maxTokens ?? defaultOutputAllowance(requestModel)
616
646
  const promptCacheKey = promptCacheKeyForOrigin(getOrigin())
617
647
  const onPayload = async (payload: unknown, payloadModel: typeof requestModel) => {
618
648
  const next = (await streamOptions?.onPayload?.(payload, payloadModel)) ?? payload
@@ -683,7 +713,10 @@ export async function createSessionWithDispose(options: CreateSessionOptions = {
683
713
  const unsubToolNudge = attachToolNotFoundNudge(session, intendedActiveToolNames)
684
714
  // An applied idle summary replaces the prefix the keepalive captured;
685
715
  // replaying the old one would only refresh a cache no turn will read.
686
- const stopIdleCompaction = attachIdleCompaction(session, { onApplied: () => cacheKeepalive?.invalidate() })
716
+ const stopIdleCompaction = attachIdleCompaction(session, {
717
+ maxTriggerTokens: maxCompactionTriggerTokens,
718
+ onApplied: () => cacheKeepalive?.invalidate(),
719
+ })
687
720
 
688
721
  // Registered only once creation can no longer fail, so a rejected creation
689
722
  // leaves no scope entry behind; tools resolve the scope lazily at call time.
@@ -695,6 +728,7 @@ export async function createSessionWithDispose(options: CreateSessionOptions = {
695
728
  )
696
729
  : undefined
697
730
  const dispose = async () => {
731
+ await evalRuntime?.dispose()
698
732
  stopIdleCompaction()
699
733
  cacheKeepalive?.close()
700
734
  unsubCacheKeepalive()
@@ -1238,133 +1272,7 @@ export type CreateResourceLoaderOptions = {
1238
1272
  // useful; mostly an escape hatch for ad-hoc debugging).
1239
1273
  mode?: SystemPromptMode
1240
1274
  proactiveNextStepNudge?: boolean
1241
- }
1242
-
1243
- // Origins with a conversation partner waiting on the reply get the full-mode
1244
- // session context: the interactive orchestration context with the live public
1245
- // roster, the MCP catalog, and the git nudge. Unattended origins (cron fires,
1246
- // default subagents, system processes) skip that context and the roster/git/MCP
1247
- // work it needs — their origin block already says what is expected. Every
1248
- // origin gets the same shared policy either way.
1249
- //
1250
- // Exhaustive switch (not a boolean expression) so a future origin kind forces
1251
- // the author to make an explicit full-or-slim decision at compile time. The
1252
- // previous form silently defaulted new origins to slim, which would have
1253
- // stripped the interactive context from a new interactive surface by
1254
- // accident.
1255
- export function deriveSystemPromptMode(origin: SessionOrigin | undefined): SystemPromptMode {
1256
- if (origin === undefined) return 'full'
1257
- switch (origin.kind) {
1258
- case 'tui':
1259
- case 'channel':
1260
- return 'full'
1261
- case 'cron':
1262
- case 'subagent':
1263
- case 'system':
1264
- return 'slim'
1265
- default: {
1266
- const _exhaustive: never = origin
1267
- void _exhaustive
1268
- return 'full'
1269
- }
1270
- }
1271
- }
1272
-
1273
- // Pure inputs for `composeSystemPrompt`. Each field maps 1:1 to a rendered
1274
- // section of the prompt; callers that don't want a section pass `undefined`
1275
- // (or `''` for `gitNudge`). Extracted so the debug dumper in
1276
- // `scripts/dump-system-prompt.ts` can reuse the exact same composition
1277
- // pipeline `createResourceLoader` uses, with no risk of drift if the
1278
- // section order changes.
1279
- //
1280
- // `mode` selects only the optional session context, never the policy: every
1281
- // standard session starts with `buildSystemPolicy(branding)`.
1282
- // - 'full' (default) — TUI, channel, and origin-less sessions: appends the
1283
- // interactive context (`renderInteractiveSessionContext`) with the roster.
1284
- // - 'slim' — cron, default subagents, system processes: no interactive
1285
- // context; the origin block covers per-kind specifics (no human, side
1286
- // effects via tools, narrow scope).
1287
- export type SystemPromptMode = 'full' | 'slim'
1288
-
1289
- export type SystemPromptComposition = {
1290
- mode?: SystemPromptMode
1291
- // Whether the prompt discloses that the agent runs on TypeClaw. When false,
1292
- // the policy's opening is phrased generically, the `## Runtime` version
1293
- // block is dropped, and the runtime-disclosure rule is appended. Defaults to
1294
- // true. Mirrors `config.branding`.
1295
- branding?: boolean
1296
- self: string
1297
- // Pre-rendered interactive-context roster (from `renderPublicSubagentRoster`).
1298
- // Kept as a ready string so this composer stays pure and registry-free; the
1299
- // registry-aware caller renders it. Ignored in slim mode (no interactive
1300
- // context). Falls back to `DEFAULT_SUBAGENT_ROSTER` when omitted.
1301
- subagentRoster?: string
1302
- runtimeVersion?: string
1303
- origin?: SessionOrigin
1304
- roleContext?: SessionRoleContext
1305
- mcpCatalog?: string
1306
- gitNudge: string
1307
- proactiveNextStepNudge?: string
1308
- }
1309
-
1310
- // Section-order contract for the system prompt. Kept as a pure string→string
1311
- // transform so it can be exercised without disk, plugin runtime, or auth.
1312
- //
1313
- // Cache-suffix ordering: least-volatile sections first, most-volatile last.
1314
- // This minimises the number of cached prompt bytes invalidated when a
1315
- // section changes (the provider's prompt cache hits up to the first byte
1316
- // that differs).
1317
- //
1318
- // 0. shared policy — identical for every standard session of an agent.
1319
- // 1. self — IDENTITY.md + SOUL.md (plus any plugin `session.prompt` append).
1320
- // 2. runtime block (or the runtime-disclosure rule when branding is off) —
1321
- // only changes on typeclaw releases.
1322
- // 3. interactive context (full mode) — stable per agent registry, so it
1323
- // precedes the per-session origin block.
1324
- // 4. origin block + role — stable across sessions of the same kind; channel
1325
- // origins carry per-conversation details.
1326
- // 5. MCP catalog — changes when servers connect or disconnect.
1327
- // 6. gitNudge — rare changes; agent folders force-commit sessions/ and
1328
- // memory/ after every turn, so the dirty-files list is empty most of
1329
- // the time.
1330
- // 7. proactive next-step nudge — deterministic per model family.
1331
- //
1332
- // The wall-clock anchor that used to live here as `## Now` moved out
1333
- // entirely. It is now injected into the user turn at each `session.prompt`
1334
- // site via `renderTurnTimeAnchor` (src/agent/system-prompt.ts) so the
1335
- // stamp reflects the moment of THIS turn, not session creation. Per-turn
1336
- // injection costs zero cached bytes — the user turn is the non-cacheable
1337
- // suffix anyway — and removes the staleness failure mode where a session
1338
- // opened Friday answered "today is Friday" on Thursday. Retrieved memory and
1339
- // the live channel role ride in the user turn for the same reason.
1340
- //
1341
- // pi appends project context (AGENTS.md), the skill catalog, and the cwd
1342
- // after this preamble when it builds the final system message.
1343
- export function composeSystemPrompt(parts: SystemPromptComposition): string {
1344
- const branding = parts.branding ?? true
1345
- let prompt = `${buildSystemPolicy(branding)}\n\n${parts.self}`
1346
- if (branding && parts.runtimeVersion !== undefined) {
1347
- prompt = `${prompt}\n\n${renderRuntimeBlock(parts.runtimeVersion)}`
1348
- }
1349
- if (!branding) {
1350
- prompt = `${prompt}\n\n${renderRuntimeNondisclosureRule()}`
1351
- }
1352
- if (parts.mode !== 'slim') {
1353
- prompt = `${prompt}\n\n${renderInteractiveSessionContext(parts.subagentRoster ?? DEFAULT_SUBAGENT_ROSTER)}`
1354
- }
1355
- if (parts.origin !== undefined) {
1356
- prompt = `${prompt}\n\n${renderSessionOrigin(parts.origin, Date.now(), parts.roleContext)}`
1357
- }
1358
- if (parts.mcpCatalog !== undefined && parts.mcpCatalog !== '') {
1359
- prompt = `${prompt}\n\n${parts.mcpCatalog}`
1360
- }
1361
- if (parts.gitNudge !== '') {
1362
- prompt = `${prompt}\n\n${parts.gitNudge}`
1363
- }
1364
- if (parts.proactiveNextStepNudge !== undefined && parts.proactiveNextStepNudge !== '') {
1365
- prompt = `${prompt}\n\n${parts.proactiveNextStepNudge}`
1366
- }
1367
- return prompt
1275
+ evalEnabled?: boolean
1368
1276
  }
1369
1277
 
1370
1278
  export async function createResourceLoader(options: CreateResourceLoaderOptions = {}): Promise<DefaultResourceLoader> {
@@ -1453,6 +1361,7 @@ export async function createResourceLoader(options: CreateResourceLoaderOptions
1453
1361
  ...(roleContext !== undefined ? { roleContext } : {}),
1454
1362
  ...(mcpCatalog !== undefined ? { mcpCatalog } : {}),
1455
1363
  gitNudge,
1364
+ ...(options.evalEnabled ? { evalHint: EVAL_PROMPT_HINT } : {}),
1456
1365
  ...(options.proactiveNextStepNudge === true ? { proactiveNextStepNudge: PROACTIVE_NEXT_STEP_NUDGE } : {}),
1457
1366
  })
1458
1367
 
@@ -0,0 +1,7 @@
1
+ export const DEFAULT_MAX_OUTPUT_TOKENS = 32_000
2
+
3
+ // The output cap every session request sends when the caller set none.
4
+ // Undefined leaves the provider's own default in place.
5
+ export function defaultOutputAllowance(model: { maxTokens: number }): number | undefined {
6
+ return model.maxTokens > 0 ? Math.min(model.maxTokens, DEFAULT_MAX_OUTPUT_TOKENS) : undefined
7
+ }