@tinyweb_dev/agent-framework-agent 0.1.0 → 0.3.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 (144) hide show
  1. package/dist/agent.d.ts +116 -0
  2. package/dist/agent.d.ts.map +1 -0
  3. package/dist/attachments.d.ts +41 -0
  4. package/dist/attachments.d.ts.map +1 -0
  5. package/dist/bus/bus.d.ts +46 -0
  6. package/dist/bus/bus.d.ts.map +1 -0
  7. package/dist/bus/index.d.ts +2 -0
  8. package/dist/bus/index.d.ts.map +1 -0
  9. package/dist/define-tool.d.ts +13 -0
  10. package/dist/define-tool.d.ts.map +1 -0
  11. package/dist/events.d.ts +136 -0
  12. package/dist/events.d.ts.map +1 -0
  13. package/dist/http-handlers.cjs +253 -0
  14. package/dist/http-handlers.cjs.map +1 -0
  15. package/dist/http-handlers.d.ts +49 -0
  16. package/dist/http-handlers.d.ts.map +1 -0
  17. package/dist/http-handlers.js +251 -0
  18. package/dist/http-handlers.js.map +1 -0
  19. package/dist/index.cjs +2073 -0
  20. package/dist/index.cjs.map +1 -0
  21. package/dist/index.d.ts +19 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +2015 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/loop-guard.d.ts +42 -0
  26. package/dist/loop-guard.d.ts.map +1 -0
  27. package/dist/mcp/client.d.ts +25 -0
  28. package/dist/mcp/client.d.ts.map +1 -0
  29. package/dist/mcp/index.cjs +66 -0
  30. package/dist/mcp/index.cjs.map +1 -0
  31. package/{src/mcp/index.ts → dist/mcp/index.d.ts} +2 -1
  32. package/dist/mcp/index.d.ts.map +1 -0
  33. package/dist/mcp/index.js +63 -0
  34. package/dist/mcp/index.js.map +1 -0
  35. package/dist/permission.d.ts +26 -0
  36. package/dist/permission.d.ts.map +1 -0
  37. package/dist/plugin/apply.d.ts +12 -0
  38. package/dist/plugin/apply.d.ts.map +1 -0
  39. package/dist/plugin/index.cjs +63 -0
  40. package/dist/plugin/index.cjs.map +1 -0
  41. package/dist/plugin/index.d.ts +4 -0
  42. package/dist/plugin/index.d.ts.map +1 -0
  43. package/dist/plugin/index.js +52 -0
  44. package/dist/plugin/index.js.map +1 -0
  45. package/dist/plugin/loader.d.ts +3 -0
  46. package/dist/plugin/loader.d.ts.map +1 -0
  47. package/dist/plugin/types.d.ts +98 -0
  48. package/dist/plugin/types.d.ts.map +1 -0
  49. package/dist/prompt/index.d.ts +51 -0
  50. package/dist/prompt/index.d.ts.map +1 -0
  51. package/dist/prompt/objective.d.ts +29 -0
  52. package/dist/prompt/objective.d.ts.map +1 -0
  53. package/dist/prompt/response-style.d.ts +19 -0
  54. package/dist/prompt/response-style.d.ts.map +1 -0
  55. package/dist/prompt/tool-use-guidelines.d.ts +22 -0
  56. package/dist/prompt/tool-use-guidelines.d.ts.map +1 -0
  57. package/dist/prompt/tool-use.d.ts +12 -0
  58. package/dist/prompt/tool-use.d.ts.map +1 -0
  59. package/dist/runtime.d.ts +7 -0
  60. package/dist/runtime.d.ts.map +1 -0
  61. package/dist/session/adapter.d.ts +40 -0
  62. package/dist/session/adapter.d.ts.map +1 -0
  63. package/dist/session/compaction.d.ts +37 -0
  64. package/dist/session/compaction.d.ts.map +1 -0
  65. package/dist/session/index.d.ts +7 -0
  66. package/dist/session/index.d.ts.map +1 -0
  67. package/dist/session/memory.cjs +130 -0
  68. package/dist/session/memory.cjs.map +1 -0
  69. package/dist/session/memory.d.ts +3 -0
  70. package/dist/session/memory.d.ts.map +1 -0
  71. package/dist/session/memory.js +128 -0
  72. package/dist/session/memory.js.map +1 -0
  73. package/dist/session/overflow.d.ts +19 -0
  74. package/dist/session/overflow.d.ts.map +1 -0
  75. package/dist/session/postgres.cjs +245 -0
  76. package/dist/session/postgres.cjs.map +1 -0
  77. package/dist/session/postgres.d.ts +10 -0
  78. package/dist/session/postgres.d.ts.map +1 -0
  79. package/dist/session/postgres.js +243 -0
  80. package/dist/session/postgres.js.map +1 -0
  81. package/dist/session/processor.d.ts +52 -0
  82. package/dist/session/processor.d.ts.map +1 -0
  83. package/dist/session/replay.d.ts +4 -0
  84. package/dist/session/replay.d.ts.map +1 -0
  85. package/dist/session/schema.d.ts +104 -0
  86. package/dist/session/schema.d.ts.map +1 -0
  87. package/dist/session/sqlite.cjs +236 -0
  88. package/dist/session/sqlite.cjs.map +1 -0
  89. package/dist/session/sqlite.d.ts +3 -0
  90. package/dist/session/sqlite.d.ts.map +1 -0
  91. package/dist/session/sqlite.js +234 -0
  92. package/dist/session/sqlite.js.map +1 -0
  93. package/dist/session-api.cjs +56 -0
  94. package/dist/session-api.cjs.map +1 -0
  95. package/dist/session-api.d.ts +36 -0
  96. package/dist/session-api.d.ts.map +1 -0
  97. package/dist/session-api.js +54 -0
  98. package/dist/session-api.js.map +1 -0
  99. package/dist/skill/index.cjs +81 -0
  100. package/dist/skill/index.cjs.map +1 -0
  101. package/dist/skill/index.d.ts +10 -0
  102. package/dist/skill/index.d.ts.map +1 -0
  103. package/dist/skill/index.js +78 -0
  104. package/dist/skill/index.js.map +1 -0
  105. package/dist/sse-handler.d.ts +27 -0
  106. package/dist/sse-handler.d.ts.map +1 -0
  107. package/dist/transcript.d.ts +81 -0
  108. package/dist/transcript.d.ts.map +1 -0
  109. package/package.json +54 -19
  110. package/src/agent.ts +0 -317
  111. package/src/attachments.ts +0 -155
  112. package/src/bus/bus.ts +0 -89
  113. package/src/bus/index.ts +0 -1
  114. package/src/define-tool.ts +0 -41
  115. package/src/events.ts +0 -162
  116. package/src/http-handlers.ts +0 -251
  117. package/src/index.ts +0 -120
  118. package/src/loop-guard.ts +0 -99
  119. package/src/mcp/client.ts +0 -110
  120. package/src/permission.ts +0 -72
  121. package/src/plugin/apply.ts +0 -89
  122. package/src/plugin/index.ts +0 -3
  123. package/src/plugin/loader.ts +0 -42
  124. package/src/plugin/types.ts +0 -134
  125. package/src/prompt/index.ts +0 -90
  126. package/src/prompt/objective.ts +0 -104
  127. package/src/prompt/response-style.ts +0 -59
  128. package/src/prompt/tool-use-guidelines.ts +0 -57
  129. package/src/prompt/tool-use.ts +0 -27
  130. package/src/runtime.ts +0 -22
  131. package/src/session/adapter.ts +0 -37
  132. package/src/session/compaction.ts +0 -160
  133. package/src/session/index.ts +0 -11
  134. package/src/session/memory.ts +0 -154
  135. package/src/session/overflow.ts +0 -50
  136. package/src/session/postgres.ts +0 -330
  137. package/src/session/processor.ts +0 -500
  138. package/src/session/replay.ts +0 -140
  139. package/src/session/schema.ts +0 -140
  140. package/src/session/sqlite.ts +0 -281
  141. package/src/session-api.ts +0 -103
  142. package/src/skill/index.ts +0 -113
  143. package/src/sse-handler.ts +0 -67
  144. package/src/transcript.ts +0 -126
@@ -1,160 +0,0 @@
1
- // Adapted from opencode@v1.14.48 packages/opencode/src/session/compaction.ts
2
- //
3
- // Auto-compaction. Replaces a leading slice of the conversation with a
4
- // summarisation marker so subsequent turns replay only [marker, ...tail].
5
- // Critically we NEVER delete/recreate the session — the sessionId, owner and
6
- // metadata stay stable; only the message log is appended to.
7
- import { LLM, LLMClient, type ModelRef } from "@tinyweb-agent-framework/llm"
8
- import { Effect } from "effect"
9
- import type { SessionStore } from "./adapter"
10
- import { estimateTokens } from "./overflow"
11
- import {
12
- findCompactionPart,
13
- makeCompactionMessage,
14
- type Message,
15
- type MessageID,
16
- type SessionID,
17
- type TextPart,
18
- } from "./schema"
19
-
20
- const SUMMARY_PROMPT = `You are a conversation summarizer. Summarize the entire conversation below into a concise factual summary (1-3 paragraphs) that preserves: user intent, key facts established, decisions made, and outstanding tasks. Do not add commentary.`
21
-
22
- const SUMMARY_FALLBACK_MAX_CHARS = 200_000
23
-
24
- const partText = (part: unknown): string => {
25
- const tagged = part as { type?: string; text?: string; summary?: string }
26
- if (tagged.type === "text") return tagged.text ?? ""
27
- if (tagged.type === "reasoning") return tagged.text ?? ""
28
- if (tagged.type === "compaction") return `[previous summary] ${tagged.summary ?? ""}`
29
- return ""
30
- }
31
-
32
- const messageToWireText = (msg: Message): string => {
33
- const role = msg.role.toUpperCase()
34
- const text = msg.parts
35
- .map((p) => partText(p))
36
- .filter((s) => s.length > 0)
37
- .join("\n")
38
- return `[${role}] ${text}`
39
- }
40
-
41
- /**
42
- * Trim transcript to fit inside the summariser's own context window. Mirrors
43
- * opencode's `truncateToolOutput` pattern — when even the summariser would
44
- * overflow, prefer the head + tail of each message.
45
- */
46
- const truncateForSummary = (transcript: string, max: number): string => {
47
- if (transcript.length <= max) return transcript
48
- const half = Math.floor(max / 2) - 64
49
- return `${transcript.slice(0, half)}\n\n[... ${transcript.length - max} chars elided ...]\n\n${transcript.slice(-half)}`
50
- }
51
-
52
- export type CompactInput = {
53
- readonly sessionId: SessionID | string
54
- readonly store: SessionStore
55
- readonly model: ModelRef
56
- /** Number of trailing turns to keep verbatim. Default 4. */
57
- readonly keepRecent?: number
58
- /** True when triggered by a ContextOverflowReason from the previous turn. */
59
- readonly overflow?: boolean
60
- }
61
-
62
- export type CompactResult = {
63
- readonly compacted: boolean
64
- readonly summary?: string
65
- readonly markerId?: MessageID
66
- readonly tailStartId?: MessageID
67
- /** Approximate prompt tokens BEFORE compaction (estimateTokens of the head slice). */
68
- readonly prevTokens?: number
69
- /** Approximate prompt tokens AFTER compaction (`[marker, ...tail]`). */
70
- readonly newTokens?: number
71
- /** USD cost of the summariser call when the route surfaces it. */
72
- readonly cost?: number
73
- /** Model id used for the summarisation call. Today: same as the main agent. */
74
- readonly modelId?: string
75
- }
76
-
77
- /**
78
- * Run an auto-compaction pass. Appends a marker user message that summarises
79
- * the leading slice of history; replay logic in `replay.ts` will then emit
80
- * only `[marker, ...tail]` for subsequent LLM calls.
81
- *
82
- * Idempotent: if the most recent compaction marker has nothing prior to
83
- * summarise we no-op.
84
- */
85
- export const compact = (
86
- input: CompactInput,
87
- ): Effect.Effect<CompactResult, unknown, typeof LLMClient.Service> =>
88
- Effect.gen(function* () {
89
- const keepRecent = input.keepRecent ?? 4
90
- const all = yield* input.store.getMessages(input.sessionId)
91
- if (all.length <= keepRecent + 1) return { compacted: false } satisfies CompactResult
92
-
93
- // Find the last existing marker so we don't re-summarise already-summarised history.
94
- const lastMarkerIdx = (() => {
95
- for (let i = all.length - 1; i >= 0; i--) {
96
- if (findCompactionPart(all[i]!)) return i
97
- }
98
- return -1
99
- })()
100
-
101
- const head = all.slice(lastMarkerIdx + 1, Math.max(lastMarkerIdx + 1, all.length - keepRecent))
102
- if (head.length === 0) return { compacted: false } satisfies CompactResult
103
-
104
- const tail = all.slice(all.length - keepRecent)
105
- const tailStartId = tail[0]?.id
106
-
107
- const transcript = truncateForSummary(
108
- head.map(messageToWireText).join("\n\n"),
109
- SUMMARY_FALLBACK_MAX_CHARS,
110
- )
111
- const request = LLM.request({
112
- model: input.model,
113
- system: SUMMARY_PROMPT,
114
- messages: [LLM.user(`Conversation transcript to summarize:\n\n${transcript}`)],
115
- })
116
- const response = yield* LLMClient.generate(request)
117
- const summary = response.text.trim().length > 0 ? response.text : extractFallbackSummary(head)
118
-
119
- const marker = makeCompactionMessage({
120
- summary,
121
- tailStartId,
122
- auto: true,
123
- overflow: input.overflow ?? false,
124
- })
125
- yield* input.store.appendMessage(input.sessionId, marker)
126
-
127
- // Token accounting for the UI affordance. `prevTokens` is the size of the
128
- // slice we replaced; `newTokens` is the resulting view (marker + tail).
129
- // We deliberately use `estimateTokens` (cheap, provider-agnostic) rather
130
- // than the provider's usage object — providers don't agree on what counts.
131
- const prevTokens = estimateTokens(head)
132
- const newTokens = estimateTokens([marker, ...tail])
133
-
134
- // Cost / model id are best-effort: not every route fills `response.usage.cost`
135
- // and we never want a missing field to abort the compaction.
136
- const usage = response.usage as { cost?: number } | undefined
137
- const cost = typeof usage?.cost === "number" ? usage.cost : undefined
138
-
139
- return {
140
- compacted: true,
141
- summary,
142
- markerId: marker.id,
143
- tailStartId,
144
- prevTokens,
145
- newTokens,
146
- cost,
147
- modelId: input.model.id,
148
- } satisfies CompactResult
149
- })
150
-
151
- /** Best-effort offline summary when the summariser returns empty text. */
152
- const extractFallbackSummary = (msgs: ReadonlyArray<Message>): string => {
153
- const lines = msgs.flatMap((m) =>
154
- m.parts
155
- .map((p) => ((p as TextPart).type === "text" ? (p as TextPart).text : ""))
156
- .filter((s) => s.length > 0),
157
- )
158
- const head = lines.slice(0, 4).join(" ")
159
- return `Compacted ${msgs.length} prior message(s). ${head.slice(0, 400)}`
160
- }
@@ -1,11 +0,0 @@
1
- export * from "./schema"
2
- export * from "./adapter"
3
- export { makeMemoryStore } from "./memory"
4
- // NOTE: `makeSqliteStore` / `makePostgresStore` are NOT re-exported here to
5
- // avoid pulling `bun:sqlite` / `postgres` into bundlers (Next.js webpack, etc.)
6
- // when the consumer doesn't actually use them. Import them directly:
7
- // import { makeSqliteStore } from "@tinyweb-agent-framework/agent/session/sqlite"
8
- // import { makePostgresStore } from "@tinyweb-agent-framework/agent/session/postgres"
9
- export { makeProcessor, type Processor, type ProcessorConfig, type TurnInput } from "./processor"
10
- export { estimateTokens, isOverflow } from "./overflow"
11
- export { compact, type CompactInput } from "./compaction"
@@ -1,154 +0,0 @@
1
- import { Effect } from "effect"
2
- import type { ListSessionsOpts, ListSessionsResult, SessionPatch, SessionStore, GetMessagesOpts } from "./adapter"
3
- import {
4
- newSessionID,
5
- type CreateSessionInput,
6
- type Message,
7
- type MessageID,
8
- type Session,
9
- type SessionID,
10
- } from "./schema"
11
-
12
- type Entry = { info: Session.Info; messages: Message[] }
13
-
14
- type Cursor = { readonly updatedAt: number; readonly id: string }
15
-
16
- const encodeCursor = (cursor: Cursor): string =>
17
- Buffer.from(JSON.stringify(cursor), "utf8").toString("base64url")
18
-
19
- const decodeCursor = (raw: string): Cursor | undefined => {
20
- const json = Buffer.from(raw, "base64url").toString("utf8")
21
- const parsed = JSON.parse(json) as Partial<Cursor>
22
- if (typeof parsed.updatedAt !== "number" || typeof parsed.id !== "string") return undefined
23
- return { updatedAt: parsed.updatedAt, id: parsed.id }
24
- }
25
-
26
- export const makeMemoryStore = (): SessionStore => {
27
- const store = new Map<string, Entry>()
28
-
29
- const createSession = (input: CreateSessionInput): Effect.Effect<Session.Info> => {
30
- const now = Date.now()
31
- const info: Session.Info = {
32
- id: newSessionID(),
33
- agentName: input.agentName,
34
- title: input.title,
35
- metadata: input.metadata,
36
- createdAt: now,
37
- updatedAt: now,
38
- }
39
- store.set(info.id, { info, messages: [] })
40
- return Effect.succeed(info)
41
- }
42
-
43
- const getSession = (id: SessionID | string): Effect.Effect<Session.Info | undefined> =>
44
- Effect.succeed(store.get(id)?.info)
45
-
46
- const upsertSession = (
47
- input: CreateSessionInput & { id?: SessionID | string },
48
- ): Effect.Effect<Session.Info> => {
49
- const existing = input.id ? store.get(input.id) : undefined
50
- if (existing) return Effect.succeed(existing.info)
51
- if (!input.id) return createSession(input)
52
- const now = Date.now()
53
- const info: Session.Info = {
54
- id: input.id as SessionID,
55
- agentName: input.agentName,
56
- title: input.title,
57
- metadata: input.metadata,
58
- createdAt: now,
59
- updatedAt: now,
60
- }
61
- store.set(info.id, { info, messages: [] })
62
- return Effect.succeed(info)
63
- }
64
-
65
- const listSessions = (opts?: ListSessionsOpts): Effect.Effect<ListSessionsResult> => {
66
- const limit = opts?.limit ?? 50
67
- const filtered = Array.from(store.values())
68
- .map((e) => e.info)
69
- .filter((info) => (opts?.agentName ? info.agentName === opts.agentName : true))
70
- .filter((info) =>
71
- opts?.ownerId ? (info.metadata as { ownerId?: string } | undefined)?.ownerId === opts.ownerId : true,
72
- )
73
- .sort((a, b) => {
74
- if (b.updatedAt !== a.updatedAt) return b.updatedAt - a.updatedAt
75
- return b.id.localeCompare(a.id)
76
- })
77
-
78
- const cursor = opts?.cursor ? decodeCursor(opts.cursor) : undefined
79
- const startIdx = cursor
80
- ? filtered.findIndex(
81
- (info) =>
82
- info.updatedAt < cursor.updatedAt ||
83
- (info.updatedAt === cursor.updatedAt && info.id.localeCompare(cursor.id) < 0),
84
- )
85
- : 0
86
- if (startIdx === -1) return Effect.succeed({ items: [] })
87
-
88
- const page = filtered.slice(startIdx, startIdx + limit)
89
- const tail = page[page.length - 1]
90
- const hasMore = startIdx + limit < filtered.length
91
- const nextCursor = hasMore && tail ? encodeCursor({ updatedAt: tail.updatedAt, id: tail.id }) : undefined
92
- return Effect.succeed({ items: page, nextCursor })
93
- }
94
-
95
- const updateSession = (
96
- id: SessionID | string,
97
- patch: SessionPatch,
98
- ): Effect.Effect<Session.Info | undefined> => {
99
- const entry = store.get(id)
100
- if (!entry) return Effect.succeed(undefined)
101
- entry.info = {
102
- ...entry.info,
103
- ...(patch.title !== undefined ? { title: patch.title } : {}),
104
- ...(patch.metadata !== undefined ? { metadata: patch.metadata } : {}),
105
- updatedAt: Date.now(),
106
- }
107
- return Effect.succeed(entry.info)
108
- }
109
-
110
- const appendMessage = (sessionId: SessionID | string, msg: Message): Effect.Effect<void> => {
111
- const entry = store.get(sessionId)
112
- if (!entry) return Effect.void
113
- entry.messages.push(msg)
114
- entry.info = { ...entry.info, updatedAt: Date.now() }
115
- return Effect.void
116
- }
117
-
118
- const getMessages = (sessionId: SessionID | string, opts?: GetMessagesOpts): Effect.Effect<Message[]> => {
119
- const msgs = store.get(sessionId)?.messages ?? []
120
- const sliced = opts?.before ? msgs.slice(0, msgs.findIndex((m) => m.id === opts.before)) : msgs
121
- const limited = opts?.limit ? sliced.slice(-opts.limit) : sliced
122
- return Effect.succeed([...limited])
123
- }
124
-
125
- const deleteMessage = (
126
- sessionId: SessionID | string,
127
- messageId: MessageID | string,
128
- ): Effect.Effect<void> => {
129
- const entry = store.get(sessionId)
130
- if (!entry) return Effect.void
131
- const idx = entry.messages.findIndex((m) => m.id === messageId)
132
- if (idx === -1) return Effect.void
133
- entry.messages.splice(idx, 1)
134
- entry.info = { ...entry.info, updatedAt: Date.now() }
135
- return Effect.void
136
- }
137
-
138
- const deleteSession = (id: SessionID | string): Effect.Effect<void> => {
139
- store.delete(id)
140
- return Effect.void
141
- }
142
-
143
- return {
144
- createSession,
145
- getSession,
146
- upsertSession,
147
- listSessions,
148
- updateSession,
149
- appendMessage,
150
- getMessages,
151
- deleteMessage,
152
- deleteSession,
153
- }
154
- }
@@ -1,50 +0,0 @@
1
- // Adapted from opencode@v1.14.48 packages/opencode/src/session/overflow.ts
2
- //
3
- // Token-budget helpers used by the auto-compaction pre-flight check. We
4
- // deliberately keep this provider-agnostic — the agent layer feeds in a
5
- // `ModelLimits` (from `ModelRef`) and a reserved output buffer.
6
- import type { ModelLimits } from "@tinyweb-agent-framework/llm"
7
- import type { Message, ReasoningPart, TextPart } from "./schema"
8
-
9
- const DEFAULT_OUTPUT_RESERVE = 20_000
10
-
11
- const textFromPart = (part: { type: string }): string => {
12
- if ((part as TextPart).type === "text") return (part as TextPart).text
13
- if ((part as ReasoningPart).type === "reasoning") return (part as ReasoningPart).text
14
- return ""
15
- }
16
-
17
- /** Approximate tokens by chars/4. Cheap, provider-agnostic. */
18
- export const estimateTokens = (msgs: ReadonlyArray<Message>): number => {
19
- const totalChars = msgs.reduce(
20
- (acc, msg) => acc + msg.parts.reduce((sum, part) => sum + textFromPart(part as { type: string }).length, 0),
21
- 0,
22
- )
23
- return Math.ceil(totalChars / 4)
24
- }
25
-
26
- export type UsableInput = {
27
- readonly limits: ModelLimits | undefined
28
- /** Override reserved output buffer. Default min(20_000, limits.output). */
29
- readonly reservedTokens?: number
30
- }
31
-
32
- /**
33
- * Compute the usable input budget. Returns `Infinity` when the model exposes
34
- * no `context` limit, mirroring opencode behaviour (no enforced cap).
35
- */
36
- export const usable = (input: UsableInput): number => {
37
- const context = input.limits?.context
38
- if (context === undefined || context <= 0) return Number.POSITIVE_INFINITY
39
- const output = input.limits?.output ?? DEFAULT_OUTPUT_RESERVE
40
- const reserved = input.reservedTokens ?? Math.min(DEFAULT_OUTPUT_RESERVE, output)
41
- const budget = context - reserved
42
- return budget > 0 ? budget : Math.floor(context * 0.9)
43
- }
44
-
45
- /** True when estimated tokens would overflow the usable budget. */
46
- export const isOverflowEstimate = (tokens: number, budget: number): boolean => tokens >= budget
47
-
48
- /** Convenience: estimate + compare in one call. */
49
- export const isOverflow = (msgs: ReadonlyArray<Message>, budget: number): boolean =>
50
- isOverflowEstimate(estimateTokens(msgs), budget)