zapagent 1.14.10 → 1.14.11

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 (37) hide show
  1. package/package.json +1 -1
  2. package/src/App.tsx +10 -4
  3. package/src/agent/buildAgentRuntime.ts +3 -0
  4. package/src/agent/cacheMemoryAudit.ts +56 -1
  5. package/src/agent/wireRunHandlers.ts +17 -10
  6. package/src/commands/dispatcher.ts +14 -10
  7. package/src/commands/status.ts +10 -0
  8. package/src/config.ts +10 -17
  9. package/src/context-budget.ts +3 -10
  10. package/src/headless/runHeadless.ts +3 -0
  11. package/src/hooks/useAgentRunner.ts +3 -92
  12. package/src/provider-catalog.ts +34 -3
  13. package/src/provider-metadata.ts +20 -9
  14. package/src/ui/dialog-connect.tsx +19 -10
  15. package/src/ui/dialog-context-window.tsx +42 -0
  16. package/src/ui/dialog-model-metadata.tsx +57 -0
  17. package/src/ui/dialog-model.tsx +30 -7
  18. package/src/ui/provider-directory.tsx +5 -5
  19. package/zapsdk/agent/events.ts +4 -0
  20. package/zapsdk/agent/loop.ts +153 -34
  21. package/zapsdk/agent/subagent-assembly.ts +3 -0
  22. package/zapsdk/builtin-tools/subagent.ts +6 -0
  23. package/zapsdk/context/autocompact.ts +17 -460
  24. package/zapsdk/context/compact-budget.ts +30 -0
  25. package/zapsdk/context/compact-summary.ts +336 -0
  26. package/zapsdk/context/compact.ts +290 -0
  27. package/zapsdk/context/microcompact.ts +1 -1
  28. package/zapsdk/context/prune.ts +106 -0
  29. package/zapsdk/context/reactive-compact.ts +44 -11
  30. package/zapsdk/context/request-cache.ts +76 -0
  31. package/zapsdk/core/llm.ts +3 -0
  32. package/zapsdk/core/provider-request.ts +11 -1
  33. package/zapsdk/core/providers/anthropic.ts +4 -2
  34. package/zapsdk/core/providers/openai-compatible.ts +4 -2
  35. package/zapsdk/core/providers/openai-responses.ts +2 -2
  36. package/zapsdk/index.ts +3 -0
  37. package/zapsdk/memory/conversation.ts +81 -92
@@ -46,12 +46,26 @@ export function pickModelMetadata(
46
46
  /** Apply one catalog provider to a connected provider without changing model
47
47
  * availability. Only ids already returned/selected by the provider survive. */
48
48
  export function enrichProviderMetadata(provider: Provider, catalog: ModelsDevProvider): Provider {
49
- const remote = modelsDevMetadata(catalog)
49
+ const catalogMetadata = modelsDevMetadata(catalog)
50
+ const directoryId = resolveCatalogProviderId(provider)
51
+ const directoryMatches = directoryId === catalog.id || (!directoryId
52
+ && !Object.values(provider.modelMetadata ?? {}).some(metadata => metadata.catalogRef))
53
+ const remote = directoryMatches ? { ...catalogMetadata } : {}
54
+ for (const id of provider.models) {
55
+ const ref = provider.modelMetadata?.[id]?.catalogRef
56
+ if (!ref) continue
57
+ // An explicit alias binding wins over coincidentally equal endpoint IDs.
58
+ const metadata = ref.providerId === catalog.id ? catalogMetadata[ref.modelId] : undefined
59
+ delete remote[id]
60
+ if (metadata) remote[id] = { ...metadata, catalogRef: ref }
61
+ }
50
62
  const merged = mergeModelMetadata(provider.modelMetadata ?? {}, remote)
51
63
  // A successful provider snapshot also retires identities for removed model
52
64
  // entries. Keep offline facts/capabilities, but do not keep claiming a precise
53
65
  // identity that the catalog no longer publishes for this endpoint alias.
54
66
  for (const [id, metadata] of Object.entries(merged)) {
67
+ if (metadata.catalogRef && metadata.catalogRef.providerId !== catalog.id) continue
68
+ if (!metadata.catalogRef && !directoryMatches) continue
55
69
  if (metadata.source !== "models.dev" || Object.hasOwn(remote, id) || !metadata.canonicalModelId) continue
56
70
  merged[id] = { ...metadata }
57
71
  delete merged[id].canonicalModelId
@@ -68,14 +82,11 @@ export function enrichProviderMetadata(provider: Provider, catalog: ModelsDevPro
68
82
  /** Best-effort startup refresh. Network failures leave the config untouched. */
69
83
  export async function refreshModelsDevMetadata(config: AppConfig): Promise<AppConfig> {
70
84
  const providers = await Promise.all(config.providers.map(async provider => {
71
- const modelsDevProviderId = resolveCatalogProviderId(provider)
72
- if (!modelsDevProviderId || provider.models.length === 0) return provider
73
- try {
74
- const catalog = await getModelsDevProvider(modelsDevProviderId)
75
- return catalog ? enrichProviderMetadata(provider, catalog) : provider
76
- } catch {
77
- return provider
78
- }
85
+ if (provider.models.length === 0) return provider
86
+ const ids = new Set([resolveCatalogProviderId(provider), ...provider.models.map(id =>
87
+ provider.modelMetadata?.[id]?.catalogRef?.providerId)].filter((id): id is string => !!id))
88
+ const catalogs = await Promise.all([...ids].map(id => getModelsDevProvider(id).catch(() => null)))
89
+ return catalogs.reduce((current, catalog) => catalog ? enrichProviderMetadata(current, catalog) : current, provider)
79
90
  }))
80
91
  return providers.every((provider, index) => provider === config.providers[index])
81
92
  ? config
@@ -2,8 +2,8 @@
2
2
  import { useRef, useState } from "react"
3
3
  import { Box, Text, useInput } from "ink"
4
4
  import { randomUUID } from "node:crypto"
5
- import { buildConnectedProvider, presetForConnection, removeProvider, upsertProvider,
6
- type AppConfig, type Provider, type ProviderProtocol } from "../config.js"
5
+ import { buildConnectedProvider, inferLegacyContextWindowMode, presetForConnection, removeProvider, upsertProvider,
6
+ type AppConfig, type ContextWindowMode, type Provider, type ProviderProtocol } from "../config.js"
7
7
  import { ProviderDirectory } from "./provider-directory.js"
8
8
  import { DialogFrame } from "./dialog-frame.js"
9
9
  import { PickerDialog } from "./dialog-picker.js"
@@ -11,11 +11,13 @@ import { TextField } from "./text-field.js"
11
11
  import { commandInput, isReturnInput } from "./controlled-input.js"
12
12
  import { c } from "./theme.js"
13
13
  import { ModelDialog } from "./dialog-model.js"
14
+ import { ContextWindowDialog } from "./dialog-context-window.js"
14
15
 
15
16
  interface Props { config: AppConfig; onSave: (next: AppConfig) => void; onCommit: (next: AppConfig) => void; onCancel: () => void }
16
17
  type Draft = { name: string; baseURL: string; apiKey: string; protocol: ProviderProtocol;
17
- authMode: "none" | "api-key"; catalogProviderId?: string; existing?: Provider }
18
- type Step = "connections" | "preset" | "name" | "endpoint" | "protocol" | "auth" | "key" | "review"
18
+ authMode: "none" | "api-key"; catalogProviderId?: string; existing?: Provider;
19
+ contextWindow?: number; contextWindowMode?: ContextWindowMode }
20
+ type Step = "connections" | "preset" | "name" | "endpoint" | "protocol" | "auth" | "key" | "context" | "review"
19
21
 
20
22
  export function saveConnection(config: AppConfig, draft: Draft): AppConfig {
21
23
  const existing = draft.existing
@@ -29,14 +31,15 @@ export function saveConnection(config: AppConfig, draft: Draft): AppConfig {
29
31
  name: draft.name.trim(), baseURL: draft.baseURL.trim(),
30
32
  apiKey: draft.authMode === "none" ? "" : draft.apiKey.trim(),
31
33
  models: existing?.models ?? [], modelMetadata: existing?.modelMetadata,
32
- contextWindowInput: existing?.contextWindow ?? 128000 })
34
+ contextWindowInput: draft.contextWindow ?? existing?.contextWindow ?? preset?.contextWindow ?? 128000,
35
+ contextWindowMode: draft.contextWindowMode ?? (existing
36
+ ? existing.contextWindowMode ?? inferLegacyContextWindowMode(existing) : "auto") })
33
37
  provider.id = existing?.id ?? `sp_${randomUUID()}`
34
38
  provider.protocol = draft.protocol
35
39
  provider.authMode = draft.authMode
36
40
  provider.catalogProviderId = catalogProviderId
37
41
  // Catalog identity is explicit, never inferred from a brand/URL heuristic.
38
42
  provider.sourcePresetId = existing?.sourcePresetId ?? preset?.id
39
- if (!existing && provider.catalogProviderId) provider.contextWindowMode = "auto"
40
43
  return upsertProvider(config, provider)
41
44
  }
42
45
 
@@ -78,7 +81,7 @@ export function ConnectDialog({ config, onSave, onCommit, onCancel }: Props) {
78
81
  })
79
82
 
80
83
  if (modelTarget) return <ModelDialog key={modelTarget.id} config={config}
81
- initialProviderId={modelTarget.id} setup={modelTarget.setup} onCommit={onCommit}
84
+ initialProviderId={modelTarget.id} setup={modelTarget.setup} onSave={onSave} onCommit={onCommit}
82
85
  onCancel={() => { if (modelTarget.setup) onCancel(); else setModelTarget(null) }} />
83
86
 
84
87
  if (step === "connections") return <DialogFrame title="Connections · /connect"
@@ -110,13 +113,19 @@ export function ConnectDialog({ config, onSave, onCommit, onCancel }: Props) {
110
113
  { id: "none", label: "No authentication", meta: "local or explicitly keyless endpoints" }]}
111
114
  onCancel={() => setStep("protocol")} onSelect={id => {
112
115
  setDraft({ ...draft, authMode: id as Draft["authMode"] })
113
- setStep(id === "none" ? "review" : "key")
116
+ setStep(id === "none" ? "context" : "key")
114
117
  }} />
118
+ if (step === "context") return <ContextWindowDialog
119
+ mode={draft.contextWindowMode ?? draft.existing?.contextWindowMode
120
+ ?? (draft.existing ? inferLegacyContextWindowMode(draft.existing) : "auto")}
121
+ contextWindow={draft.contextWindow ?? draft.existing?.contextWindow ?? 128000}
122
+ onCancel={() => setStep(draft.authMode === "none" ? "auth" : "key")}
123
+ onSave={(mode, tokens) => { setDraft({ ...draft, contextWindowMode: mode, contextWindow: tokens }); setStep("review") }} />
115
124
  if (step === "review") return <PickerDialog key={step} title={draft.existing ? "Review connection" : "Review connection · next: choose a model"}
116
125
  options={[{ id: "save", label: draft.existing ? `Save ${draft.name}` : `Save ${draft.name} and choose a model`, meta: `${draft.protocol} · ${draft.authMode} · ${draft.baseURL}` },
117
126
  { id: "edit", label: "Edit settings" }]}
118
127
  hint={draft.existing ? "enter save · esc back · current model is kept" : "enter save and continue · esc back"}
119
- onCancel={() => setStep("auth")} onSelect={id => {
128
+ onCancel={() => setStep("context")} onSelect={id => {
120
129
  if (id === "edit") setStep("name")
121
130
  else {
122
131
  const next = saveConnection(config, draft)
@@ -146,7 +155,7 @@ export function ConnectDialog({ config, onSave, onCommit, onCancel }: Props) {
146
155
  catch { setError("Use an HTTP(S) base URL without embedded credentials, query or fragment."); return }
147
156
  }
148
157
  setDraft({ ...draft, [field]: trimmed }); setError("")
149
- setStep(step === "name" ? "endpoint" : step === "endpoint" ? "protocol" : "review")
158
+ setStep(step === "name" ? "endpoint" : step === "endpoint" ? "protocol" : "context")
150
159
  }} />
151
160
  </DialogFrame>
152
161
  }
@@ -0,0 +1,42 @@
1
+ /** @jsxImportSource react */
2
+ import { useState } from "react"
3
+ import { Text } from "ink"
4
+ import type { ContextWindowMode } from "../config.js"
5
+ import { DialogFrame } from "./dialog-frame.js"
6
+ import { PickerDialog } from "./dialog-picker.js"
7
+ import { TextField } from "./text-field.js"
8
+ import { c } from "./theme.js"
9
+
10
+ export function parseContextWindowInput(value: string): number | undefined {
11
+ const trimmed = value.trim()
12
+ const tokens = Number(trimmed)
13
+ return /^\d+$/.test(trimmed) && Number.isSafeInteger(tokens) && tokens > 0 ? tokens : undefined
14
+ }
15
+
16
+ export function ContextWindowDialog({ mode, contextWindow, onSave, onCancel }: {
17
+ mode: ContextWindowMode
18
+ contextWindow: number
19
+ onSave: (mode: ContextWindowMode, tokens: number) => void
20
+ onCancel: () => void
21
+ }) {
22
+ const [manual, setManual] = useState(false)
23
+ const [value, setValue] = useState(String(contextWindow))
24
+ const [error, setError] = useState("")
25
+ if (!manual) return <PickerDialog title="Context window" initialIndex={mode === "manual" ? 1 : 0}
26
+ options={[{ id: "auto", label: "Automatic · use model metadata", meta: "unknown models use a visible fallback" },
27
+ { id: "manual", label: "Manual · set token limit", meta: "kept across catalog refreshes" }]}
28
+ onCancel={onCancel} onSelect={id => {
29
+ if (id === "manual") setManual(true)
30
+ else onSave("auto", contextWindow)
31
+ }} />
32
+ return <DialogFrame title="Manual context window" hint="enter save · esc back">
33
+ <Text color={c.text.faint}>Total input + output tokens. For a 1M window, enter 1048576. Overrides model metadata.</Text>
34
+ {error && <Text color={c.warning}>{error}</Text>}
35
+ <TextField isActive value={value} onChange={next => { setValue(next); setError("") }}
36
+ onCancel={() => setManual(false)} onSubmit={next => {
37
+ const tokens = parseContextWindowInput(next)
38
+ if (tokens === undefined) { setError("Enter a positive whole number of tokens."); return }
39
+ onSave("manual", tokens)
40
+ }} />
41
+ </DialogFrame>
42
+ }
@@ -0,0 +1,57 @@
1
+ /** @jsxImportSource react */
2
+ import { useEffect, useState } from "react"
3
+ import { Text } from "ink"
4
+ import type { ProviderModelMetadata } from "../config.js"
5
+ import { getModelsDevProvider, type ModelsDevProvider } from "../../zapsdk/core/models-dev.js"
6
+ import { catalogModelMetadata } from "../provider-catalog.js"
7
+ import { ProviderDirectory } from "./provider-directory.js"
8
+ import { DialogFrame } from "./dialog-frame.js"
9
+ import { PickerDialog } from "./dialog-picker.js"
10
+ import { TextField } from "./text-field.js"
11
+ import { c } from "./theme.js"
12
+
13
+ /** Explicit linkage only: catalog selections never replace endpoint or wire ID. */
14
+ export function ModelMetadataDialog({ modelId, onSelect, onCancel }: {
15
+ modelId: string
16
+ onSelect: (metadata: ProviderModelMetadata) => void
17
+ onCancel: () => void
18
+ }) {
19
+ const [providerId, setProviderId] = useState("")
20
+ const [catalog, setCatalog] = useState<ModelsDevProvider | null>(null)
21
+ const [error, setError] = useState("")
22
+ const [query, setQuery] = useState("")
23
+ const [filtering, setFiltering] = useState(false)
24
+ useEffect(() => {
25
+ if (!providerId) return
26
+ let cancelled = false
27
+ setCatalog(null); setError("")
28
+ void getModelsDevProvider(providerId).then(result => {
29
+ if (cancelled) return
30
+ if (!result) setError("Provider metadata unavailable. Press esc to choose another provider.")
31
+ else setCatalog(result)
32
+ }).catch(() => { if (!cancelled) setError("Catalog unavailable. Press esc to go back; your connection is unchanged.") })
33
+ return () => { cancelled = true }
34
+ }, [providerId])
35
+ if (!providerId) return <ProviderDirectory metadataOnly onCancel={onCancel}
36
+ onSelect={provider => { if (provider) { setProviderId(provider.id); setQuery("") } }} />
37
+ if (filtering) return <DialogFrame title="Filter metadata models" hint="enter filter · esc back">
38
+ <TextField isActive value={query} onChange={setQuery} onCancel={() => setFiltering(false)}
39
+ onSubmit={next => { setQuery(next.trim()); setFiltering(false) }} />
40
+ </DialogFrame>
41
+ if (!catalog || error) return <PickerDialog title="Model metadata · models.dev"
42
+ options={[{ id: "back", label: error || "Loading model metadata… · back" }]}
43
+ onCancel={() => setProviderId("")} onSelect={() => setProviderId("")} />
44
+ const models = catalog.models.filter(model => `${model.id} ${model.name}`.toLowerCase().includes(query.toLowerCase()))
45
+ return <>
46
+ <Text color={c.text.faint}>{`Metadata for endpoint model ${modelId}; endpoint and request ID stay unchanged.`}</Text>
47
+ <PickerDialog key={query} title={`Model metadata · ${catalog.name}`} maxRows={8}
48
+ options={[{ id: "filter", label: "Search models…" }, ...models.map(model => ({
49
+ id: `model:${model.id}`, label: model.id,
50
+ meta: `context ${model.contextWindow?.toLocaleString("en-US") ?? "unknown"} · ${model.name}`,
51
+ }))]} onCancel={() => setProviderId("")} onSelect={id => {
52
+ if (id === "filter") { setFiltering(true); return }
53
+ const metadata = catalogModelMetadata(catalog, id.slice("model:".length))
54
+ if (metadata) onSelect(metadata)
55
+ }} />
56
+ </>
57
+ }
@@ -1,8 +1,8 @@
1
1
  /** @jsxImportSource react */
2
2
  import { useEffect, useRef, useState } from "react"
3
3
  import { Box, Text, useInput } from "ink"
4
- import type { AppConfig } from "../config.js"
5
- import { discoverProviderModels, describeCatalogRow, selectCatalogModel, type CatalogRow } from "../provider-catalog.js"
4
+ import { inferLegacyContextWindowMode, resolveProviderContextWindow, upsertProvider, type AppConfig } from "../config.js"
5
+ import { associateModelMetadata, discoverProviderModels, describeCatalogRow, selectCatalogModel, type CatalogRow } from "../provider-catalog.js"
6
6
  import { DialogFrame } from "./dialog-frame.js"
7
7
  import { PickerDialog } from "./dialog-picker.js"
8
8
  import { TextField } from "./text-field.js"
@@ -10,10 +10,12 @@ import { commandInput, isReturnInput } from "./controlled-input.js"
10
10
  import { c } from "./theme.js"
11
11
  import { useTermWidth } from "./term-width.js"
12
12
  import { truncateToWidth } from "./truncate.js"
13
+ import { ModelMetadataDialog } from "./dialog-model-metadata.js"
14
+ import { ContextWindowDialog } from "./dialog-context-window.js"
13
15
 
14
- interface Props { config: AppConfig; initialProviderId?: string; setup?: boolean; onCommit: (next: AppConfig) => void; onCancel: () => void }
16
+ interface Props { config: AppConfig; initialProviderId?: string; setup?: boolean; onSave: (next: AppConfig) => void; onCommit: (next: AppConfig) => void; onCancel: () => void }
15
17
 
16
- export function ModelDialog({ config, initialProviderId, setup = false, onCommit, onCancel }: Props) {
18
+ export function ModelDialog({ config, initialProviderId, setup = false, onSave, onCommit, onCancel }: Props) {
17
19
  const width = Math.max(10, useTermWidth() - 2)
18
20
  const [height, setHeight] = useState(process.stdout.rows ?? 24)
19
21
  useEffect(() => {
@@ -23,7 +25,8 @@ export function ModelDialog({ config, initialProviderId, setup = false, onCommit
23
25
  }, [])
24
26
  const [providerId, setProviderId] = useState(initialProviderId ?? (config.active.providerId || config.providers[0]?.id || ""))
25
27
  const provider = config.providers.find(item => item.id === providerId)
26
- const [phase, setPhase] = useState<"models" | "providers" | "manual" | "search">("models")
28
+ const [phase, setPhase] = useState<"models" | "providers" | "manual" | "search" | "metadata" | "context">("models")
29
+ const [metadataTarget, setMetadataTarget] = useState<CatalogRow | null>(null)
27
30
  const [rows, setRows] = useState<CatalogRow[]>([])
28
31
  const [index, setIndex] = useState(0)
29
32
  const [query, setQuery] = useState("")
@@ -68,6 +71,12 @@ export function ModelDialog({ config, initialProviderId, setup = false, onCommit
68
71
  if (cmd === "t") { setManual(""); setPhase("manual"); return }
69
72
  if (cmd === "/") { setPhase("search"); return }
70
73
  if (cmd === "r") { setRefresh(value => value + 1); return }
74
+ if (cmd === "c") { setPhase("context"); return }
75
+ if (cmd === "m") {
76
+ const row = state.shown[state.selectedIndex]
77
+ if (row) { setMetadataTarget(row); setPhase("metadata") }
78
+ return
79
+ }
71
80
  if (key.upArrow) { setIndex(Math.max(0, state.selectedIndex - 1)); return }
72
81
  if (key.downArrow) { setIndex(Math.min(Math.max(0, state.shown.length - 1), state.selectedIndex + 1)); return }
73
82
  if (isReturnInput(input, key)) {
@@ -79,6 +88,18 @@ export function ModelDialog({ config, initialProviderId, setup = false, onCommit
79
88
  if (!provider) return <DialogFrame title="Models · /model" hint="esc close">
80
89
  <Text>No connection configured. Use /connect to create one first.</Text>
81
90
  </DialogFrame>
91
+ if (phase === "metadata" && metadataTarget) return <ModelMetadataDialog modelId={metadataTarget.id}
92
+ onCancel={() => setPhase("models")} onSelect={metadata => {
93
+ onSave(associateModelMetadata(config, providerId, metadataTarget.id, metadata))
94
+ setPhase("models")
95
+ }} />
96
+ if (phase === "context") return <ContextWindowDialog
97
+ mode={provider.contextWindowMode ?? inferLegacyContextWindowMode(provider)}
98
+ contextWindow={resolveProviderContextWindow(provider, config.active.model)}
99
+ onCancel={() => setPhase("models")} onSave={(mode, tokens) => {
100
+ onSave({ ...upsertProvider(config, { ...provider, contextWindowMode: mode, contextWindow: tokens }), active: config.active })
101
+ setPhase("models")
102
+ }} />
82
103
  if (phase === "providers") return <PickerDialog title="Models · choose connection"
83
104
  options={config.providers.map(item => ({ id: item.id, label: item.name || item.baseURL, meta: item.baseURL }))}
84
105
  initialIndex={Math.max(0, config.providers.findIndex(item => item.id === providerId))}
@@ -97,11 +118,13 @@ export function ModelDialog({ config, initialProviderId, setup = false, onCommit
97
118
  const count = Math.max(1, Math.min(7, Math.floor((height - 14) / 3)))
98
119
  const start = Math.max(0, selectedIndex - Math.floor(count / 2))
99
120
  return <DialogFrame title={`${setup ? "Choose a model" : "Models"} · ${provider.name || provider.baseURL}`}
100
- hint={setup ? "↑↓ navigate · enter select and finish · / filter · r refresh · t manual · esc choose later" : "↑↓ navigate · enter select · / filter · p connection · r refresh · t manual · esc close"}>
121
+ hint={setup ? "↑↓ navigate · enter select and finish · m metadata · c context · / filter · t manual · esc choose later" : "↑↓ navigate · enter select · m metadata · c context · / filter · p connection · r refresh · t manual · esc close"}>
101
122
  {setup && <Text color={c.accent}>Connection saved. Choose a model to use it, or press esc to choose later with /model.</Text>}
102
123
  <Text color={c.text.faint}>{truncateToWidth(provider.baseURL, width)}</Text>
103
124
  <Text color={c.text.faint}>{truncateToWidth(`Current: ${config.active.providerId === providerId ? config.active.model || "none" : "none on this connection"} · ${shown.length} models${loading ? " · discovering…" : ""}${query ? ` · filter: ${query}` : ""}`, width)}</Text>
104
- <Text color={c.text.faint}>{truncateToWidth("Metadata is not proof of account access.", width)}</Text>
125
+ <Text color={c.text.faint}>{truncateToWidth((provider.contextWindowMode ?? inferLegacyContextWindowMode(provider)) === "manual"
126
+ ? `Manual context: ${provider.contextWindow.toLocaleString("en-US")} tokens · c to change`
127
+ : `Automatic context · m to link metadata · unknown models use fallback ${provider.contextWindow.toLocaleString("en-US")} tokens (unverified)`, width)}</Text>
105
128
  {error && <Text color={c.warning}>{truncateToWidth(error, width)}</Text>}
106
129
  <Box flexDirection="column" marginTop={1}>
107
130
  {shown.slice(start, start + count).map((row, i) => <Box key={row.id} flexDirection="column">
@@ -10,11 +10,11 @@ import { useTermWidth } from "./term-width.js"
10
10
  import { truncateToWidth } from "./truncate.js"
11
11
  import { c } from "./theme.js"
12
12
 
13
- interface Props { onSelect: (provider: ModelsDevConnection | null) => void; onCancel: () => void }
13
+ interface Props { onSelect: (provider: ModelsDevConnection | null) => void; onCancel: () => void; metadataOnly?: boolean }
14
14
 
15
15
  /** Public directory data supplies vendor names and endpoints; adapters only
16
16
  * constrain which wire protocols the installed runtime actually supports. */
17
- export function ProviderDirectory({ onSelect, onCancel }: Props) {
17
+ export function ProviderDirectory({ onSelect, onCancel, metadataOnly = false }: Props) {
18
18
  const [providers, setProviders] = useState<ModelsDevConnection[]>([])
19
19
  const [loading, setLoading] = useState(true)
20
20
  const [error, setError] = useState("")
@@ -59,15 +59,15 @@ export function ProviderDirectory({ onSelect, onCancel }: Props) {
59
59
  <PickerDialog key={query} title="Provider directory · models.dev"
60
60
  maxRows={Math.max(3, Math.min(10, (process.stdout.rows ?? 24) - 15))}
61
61
  hint="↑↓ select · enter configure · / search · r reload · esc back"
62
- options={[{ id: "__custom", label: "Custom endpoint", meta: "configure manually" },
62
+ options={[...(!metadataOnly ? [{ id: "__custom", label: "Custom endpoint", meta: "configure manually" }] : []),
63
63
  ...visible.map(provider => ({ id: `catalog:${provider.id}`, label: truncateToWidth(provider.name, labelWidth),
64
64
  meta: truncateToWidth(provider.protocol ? `${provider.protocol}${provider.api ? " · endpoint provided" : " · enter endpoint"}` : "unsupported adapter", width - labelWidth - 2),
65
- disabled: !provider.protocol }))]}
65
+ disabled: !metadataOnly && !provider.protocol }))]}
66
66
  onCancel={onCancel} onSelect={id => {
67
67
  if (id === "__custom") onSelect(null)
68
68
  else {
69
69
  const provider = providers.find(item => item.id === id.slice("catalog:".length))
70
- if (provider?.protocol) onSelect(provider)
70
+ if (provider && (metadataOnly || provider.protocol)) onSelect(provider)
71
71
  }
72
72
  }} />
73
73
  </>
@@ -139,6 +139,10 @@ type ContentFinalToolResult = {
139
139
  // as part of the conversation; agent-logger and metrics consume them.
140
140
 
141
141
  export type ObservationKind =
142
+ | "prune_start"
143
+ | "prune_done"
144
+ | "prune_skipped"
145
+ | "request_cache_shape"
142
146
  | "autocompact_start"
143
147
  | "autocompact_done"
144
148
  | "reactive_compact"