agent-mockingbird 0.0.1

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 (227) hide show
  1. package/.agents/skills/btca-cli/SKILL.md +64 -0
  2. package/.agents/skills/btca-cli/agents/openai.yaml +3 -0
  3. package/.agents/skills/frontend-design/SKILL.md +42 -0
  4. package/.agents/skills/frontend-design/agents/openai.yaml +3 -0
  5. package/.env.example +36 -0
  6. package/.githooks/pre-commit +33 -0
  7. package/.github/workflows/ci.yml +309 -0
  8. package/.opencode/bun.lock +18 -0
  9. package/.opencode/package.json +5 -0
  10. package/.opencode/tools/agent_type_manager.ts +100 -0
  11. package/.opencode/tools/config_manager.ts +87 -0
  12. package/.opencode/tools/cron_manager.ts +145 -0
  13. package/.opencode/tools/memory_get.ts +43 -0
  14. package/.opencode/tools/memory_remember.ts +53 -0
  15. package/.opencode/tools/memory_search.ts +48 -0
  16. package/AGENTS.md +126 -0
  17. package/MEMORY.md +2 -0
  18. package/README.md +451 -0
  19. package/THIRD_PARTY_NOTICES.md +11 -0
  20. package/agent-mockingbird.config.example.json +135 -0
  21. package/apps/server/package.json +32 -0
  22. package/apps/server/src/backend/agents/bootstrapContext.ts +362 -0
  23. package/apps/server/src/backend/agents/openclawImport.test.ts +133 -0
  24. package/apps/server/src/backend/agents/openclawImport.ts +797 -0
  25. package/apps/server/src/backend/agents/opencodeConfig.ts +428 -0
  26. package/apps/server/src/backend/agents/service.ts +10 -0
  27. package/apps/server/src/backend/config/example-config.test.ts +20 -0
  28. package/apps/server/src/backend/config/orchestration.ts +243 -0
  29. package/apps/server/src/backend/config/policy.ts +158 -0
  30. package/apps/server/src/backend/config/schema.test.ts +15 -0
  31. package/apps/server/src/backend/config/schema.ts +391 -0
  32. package/apps/server/src/backend/config/semantic.test.ts +34 -0
  33. package/apps/server/src/backend/config/semantic.ts +149 -0
  34. package/apps/server/src/backend/config/service.test.ts +75 -0
  35. package/apps/server/src/backend/config/service.ts +207 -0
  36. package/apps/server/src/backend/config/smoke.ts +77 -0
  37. package/apps/server/src/backend/config/store.test.ts +123 -0
  38. package/apps/server/src/backend/config/store.ts +581 -0
  39. package/apps/server/src/backend/config/testFixtures.ts +5 -0
  40. package/apps/server/src/backend/config/types.ts +56 -0
  41. package/apps/server/src/backend/contracts/events.ts +320 -0
  42. package/apps/server/src/backend/contracts/runtime.ts +111 -0
  43. package/apps/server/src/backend/cron/executor.ts +435 -0
  44. package/apps/server/src/backend/cron/repository.ts +170 -0
  45. package/apps/server/src/backend/cron/service.ts +660 -0
  46. package/apps/server/src/backend/cron/storage.ts +92 -0
  47. package/apps/server/src/backend/cron/types.ts +138 -0
  48. package/apps/server/src/backend/cron/utils.ts +351 -0
  49. package/apps/server/src/backend/db/client.ts +20 -0
  50. package/apps/server/src/backend/db/migrate.ts +40 -0
  51. package/apps/server/src/backend/db/repository.ts +1762 -0
  52. package/apps/server/src/backend/db/schema.ts +113 -0
  53. package/apps/server/src/backend/db/usageDashboard.test.ts +102 -0
  54. package/apps/server/src/backend/db/wipe.ts +13 -0
  55. package/apps/server/src/backend/defaults.ts +32 -0
  56. package/apps/server/src/backend/env.ts +48 -0
  57. package/apps/server/src/backend/heartbeat/activeHours.ts +45 -0
  58. package/apps/server/src/backend/heartbeat/defaultJob.ts +88 -0
  59. package/apps/server/src/backend/heartbeat/heartbeat.test.ts +110 -0
  60. package/apps/server/src/backend/heartbeat/runtimeService.ts +190 -0
  61. package/apps/server/src/backend/heartbeat/service.ts +176 -0
  62. package/apps/server/src/backend/heartbeat/state.test.ts +63 -0
  63. package/apps/server/src/backend/heartbeat/state.ts +167 -0
  64. package/apps/server/src/backend/heartbeat/types.ts +54 -0
  65. package/apps/server/src/backend/http/boundedQueue.test.ts +49 -0
  66. package/apps/server/src/backend/http/boundedQueue.ts +92 -0
  67. package/apps/server/src/backend/http/parsers.ts +40 -0
  68. package/apps/server/src/backend/http/router.ts +61 -0
  69. package/apps/server/src/backend/http/routes/agentRoutes.ts +67 -0
  70. package/apps/server/src/backend/http/routes/backgroundRoutes.ts +203 -0
  71. package/apps/server/src/backend/http/routes/chatRoutes.ts +107 -0
  72. package/apps/server/src/backend/http/routes/configRoutes.ts +602 -0
  73. package/apps/server/src/backend/http/routes/cronRoutes.ts +221 -0
  74. package/apps/server/src/backend/http/routes/dashboardRoutes.ts +308 -0
  75. package/apps/server/src/backend/http/routes/eventRoutes.ts +7 -0
  76. package/apps/server/src/backend/http/routes/heartbeatRoutes.test.ts +41 -0
  77. package/apps/server/src/backend/http/routes/heartbeatRoutes.ts +28 -0
  78. package/apps/server/src/backend/http/routes/index.ts +101 -0
  79. package/apps/server/src/backend/http/routes/mcpRoutes.ts +213 -0
  80. package/apps/server/src/backend/http/routes/memoryRoutes.ts +154 -0
  81. package/apps/server/src/backend/http/routes/runRoutes.ts +310 -0
  82. package/apps/server/src/backend/http/routes/runtimeRoutes.ts +197 -0
  83. package/apps/server/src/backend/http/routes/skillRoutes.ts +112 -0
  84. package/apps/server/src/backend/http/routes/uiRoutes.test.ts +161 -0
  85. package/apps/server/src/backend/http/routes/uiRoutes.ts +177 -0
  86. package/apps/server/src/backend/http/routes/usageRoutes.test.ts +104 -0
  87. package/apps/server/src/backend/http/routes/usageRoutes.ts +767 -0
  88. package/apps/server/src/backend/http/schemas.ts +64 -0
  89. package/apps/server/src/backend/http/sse.ts +144 -0
  90. package/apps/server/src/backend/integration/backend-core.test.ts +2316 -0
  91. package/apps/server/src/backend/logging/logger.ts +64 -0
  92. package/apps/server/src/backend/mcp/service.ts +326 -0
  93. package/apps/server/src/backend/memory/cli.ts +170 -0
  94. package/apps/server/src/backend/memory/conceptExpansion.test.ts +28 -0
  95. package/apps/server/src/backend/memory/conceptExpansion.ts +80 -0
  96. package/apps/server/src/backend/memory/qmdPort.test.ts +54 -0
  97. package/apps/server/src/backend/memory/qmdPort.ts +61 -0
  98. package/apps/server/src/backend/memory/records.test.ts +66 -0
  99. package/apps/server/src/backend/memory/records.ts +229 -0
  100. package/apps/server/src/backend/memory/service.ts +2012 -0
  101. package/apps/server/src/backend/memory/sqliteVec.ts +58 -0
  102. package/apps/server/src/backend/memory/types.ts +104 -0
  103. package/apps/server/src/backend/opencode/agentMockingbirdPlugin.test.ts +396 -0
  104. package/apps/server/src/backend/opencode/client.ts +98 -0
  105. package/apps/server/src/backend/opencode/models.ts +41 -0
  106. package/apps/server/src/backend/opencode/systemPrompt.test.ts +146 -0
  107. package/apps/server/src/backend/opencode/systemPrompt.ts +284 -0
  108. package/apps/server/src/backend/paths.ts +57 -0
  109. package/apps/server/src/backend/prompts/service.ts +100 -0
  110. package/apps/server/src/backend/queue/queue.test.ts +189 -0
  111. package/apps/server/src/backend/queue/service.ts +177 -0
  112. package/apps/server/src/backend/queue/types.ts +39 -0
  113. package/apps/server/src/backend/run/service.ts +576 -0
  114. package/apps/server/src/backend/run/storage.ts +47 -0
  115. package/apps/server/src/backend/run/types.ts +44 -0
  116. package/apps/server/src/backend/runtime/errors.ts +61 -0
  117. package/apps/server/src/backend/runtime/index.ts +72 -0
  118. package/apps/server/src/backend/runtime/memoryPromptDedup.test.ts +153 -0
  119. package/apps/server/src/backend/runtime/memoryPromptDedup.ts +76 -0
  120. package/apps/server/src/backend/runtime/opencodeRuntime/backgroundMethods.ts +765 -0
  121. package/apps/server/src/backend/runtime/opencodeRuntime/coreMethods.ts +705 -0
  122. package/apps/server/src/backend/runtime/opencodeRuntime/eventMethods.ts +503 -0
  123. package/apps/server/src/backend/runtime/opencodeRuntime/memoryMethods.ts +462 -0
  124. package/apps/server/src/backend/runtime/opencodeRuntime/promptMethods.ts +1167 -0
  125. package/apps/server/src/backend/runtime/opencodeRuntime/shared.ts +254 -0
  126. package/apps/server/src/backend/runtime/opencodeRuntime.test.ts +2899 -0
  127. package/apps/server/src/backend/runtime/opencodeRuntime.ts +135 -0
  128. package/apps/server/src/backend/runtime/sessionScope.ts +45 -0
  129. package/apps/server/src/backend/skills/service.ts +442 -0
  130. package/apps/server/src/backend/workspace/resolve.ts +27 -0
  131. package/apps/server/src/cli/agent-mockingbird.mjs +2522 -0
  132. package/apps/server/src/cli/agent-mockingbird.test.ts +68 -0
  133. package/apps/server/src/cli/runtime-assets.mjs +269 -0
  134. package/apps/server/src/cli/runtime-assets.test.ts +52 -0
  135. package/apps/server/src/cli/runtime-layout.mjs +75 -0
  136. package/apps/server/src/cli/standaloneBuild.test.ts +19 -0
  137. package/apps/server/src/cli/standaloneBuild.ts +19 -0
  138. package/apps/server/src/cli/standaloneCronBinary.test.ts +187 -0
  139. package/apps/server/src/index.ts +178 -0
  140. package/apps/server/tsconfig.json +12 -0
  141. package/backlog.md +5 -0
  142. package/bin/agent-mockingbird +2522 -0
  143. package/bin/runtime-layout.mjs +75 -0
  144. package/build-bin.ts +34 -0
  145. package/build-cli.mjs +37 -0
  146. package/build.ts +40 -0
  147. package/bun-env.d.ts +11 -0
  148. package/bun.lock +888 -0
  149. package/bunfig.toml +2 -0
  150. package/components.json +21 -0
  151. package/config.json +130 -0
  152. package/deploy/RELEASE_INSTALL.md +112 -0
  153. package/deploy/docker-compose.yml +42 -0
  154. package/deploy/systemd/README.md +46 -0
  155. package/deploy/systemd/agent-mockingbird.service +28 -0
  156. package/deploy/systemd/opencode.service +25 -0
  157. package/docs/legacy-config-ui-reference.md +51 -0
  158. package/docs/memory-e2e-trace-2026-03-04.md +63 -0
  159. package/docs/memory-ops.md +96 -0
  160. package/docs/memory-runtime-contract.md +42 -0
  161. package/docs/memory-tuning-remote-2026-03-04.md +59 -0
  162. package/docs/opencode-rebase-workflow-plan.md +614 -0
  163. package/docs/opencode-startup-sync-plan.md +94 -0
  164. package/docs/vendor-opencode.md +41 -0
  165. package/drizzle/0000_famous_turbo.sql +49 -0
  166. package/drizzle/0001_cron_memory_aux.sql +160 -0
  167. package/drizzle/0002_runtime_session_bindings.sql +28 -0
  168. package/drizzle/0003_background_runs.sql +27 -0
  169. package/drizzle/0004_memory_open_write.sql +63 -0
  170. package/drizzle/0005_signal_channel.sql +47 -0
  171. package/drizzle/0006_usage_event_dimensions.sql +7 -0
  172. package/drizzle/meta/0000_snapshot.json +341 -0
  173. package/drizzle/meta/_journal.json +55 -0
  174. package/drizzle.config.ts +14 -0
  175. package/eslint.config.mjs +77 -0
  176. package/knip.json +18 -0
  177. package/memory/2026-03-04.md +4 -0
  178. package/opencode.lock.json +16 -0
  179. package/package.json +67 -0
  180. package/packages/agent-mockingbird-installer/README.md +31 -0
  181. package/packages/agent-mockingbird-installer/bin/agent-mockingbird-installer.mjs +44 -0
  182. package/packages/agent-mockingbird-installer/opencode.lock.json +16 -0
  183. package/packages/agent-mockingbird-installer/package.json +23 -0
  184. package/packages/contracts/package.json +19 -0
  185. package/packages/contracts/src/agentTypes.ts +122 -0
  186. package/packages/contracts/src/cron.ts +146 -0
  187. package/packages/contracts/src/dashboard.ts +378 -0
  188. package/packages/contracts/src/index.ts +3 -0
  189. package/packages/contracts/tsconfig.json +4 -0
  190. package/patches/opencode/0001-Wafflebot-OpenCode-baseline.patch +2341 -0
  191. package/patches/opencode/0002-Fix-OpenCode-web-entry-and-settings-icons.patch +104 -0
  192. package/patches/opencode/0003-fix-app-remove-duplicate-sidebar-mount.patch +32 -0
  193. package/patches/opencode/0004-Add-heartbeat-settings-and-usage-nav.patch +506 -0
  194. package/patches/opencode/0005-Use-chart-icon-for-usage-nav.patch +38 -0
  195. package/patches/opencode/0006-Modernize-cron-settings.patch +399 -0
  196. package/patches/opencode/0007-Rename-waffle-namespaces-to-mockingbird.patch +1110 -0
  197. package/patches/opencode/0008-Remove-cron-contract-section.patch +178 -0
  198. package/patches/opencode/0009-Rework-cron-tab-as-operations-console.patch +414 -0
  199. package/patches/opencode/0010-Refine-heartbeat-settings-controls.patch +208 -0
  200. package/runtime-assets/opencode-config/opencode.jsonc +25 -0
  201. package/runtime-assets/opencode-config/package.json +5 -0
  202. package/runtime-assets/opencode-config/plugins/agent-mockingbird.ts +715 -0
  203. package/runtime-assets/workspace/.agents/skills/config-auditor/SKILL.md +25 -0
  204. package/runtime-assets/workspace/.agents/skills/config-editor/SKILL.md +24 -0
  205. package/runtime-assets/workspace/.agents/skills/cron-manager/SKILL.md +57 -0
  206. package/runtime-assets/workspace/.agents/skills/memory-ops/SKILL.md +120 -0
  207. package/runtime-assets/workspace/.agents/skills/runtime-diagnose/SKILL.md +25 -0
  208. package/runtime-assets/workspace/AGENTS.md +56 -0
  209. package/runtime-assets/workspace/MEMORY.md +4 -0
  210. package/scripts/build-release-bundle.sh +66 -0
  211. package/scripts/check-ship.ts +383 -0
  212. package/scripts/dev-opencode.sh +17 -0
  213. package/scripts/dev-stack-opencode.sh +15 -0
  214. package/scripts/dev-stack.sh +61 -0
  215. package/scripts/install-systemd.sh +87 -0
  216. package/scripts/memory-e2e.sh +76 -0
  217. package/scripts/memory-trace-e2e.sh +141 -0
  218. package/scripts/migrate-opencode-env.ts +108 -0
  219. package/scripts/onboard/bootstrap.sh +32 -0
  220. package/scripts/opencode-swap.ts +78 -0
  221. package/scripts/opencode-sync.ts +715 -0
  222. package/scripts/runtime-assets-sync.mjs +83 -0
  223. package/scripts/setup-git-hooks.ts +39 -0
  224. package/tsconfig.json +45 -0
  225. package/tui.json +98 -0
  226. package/turbo.json +36 -0
  227. package/vendor/OPENCODE_VENDOR.md +13 -0
@@ -0,0 +1,254 @@
1
+ import type {
2
+ ChatMessagePart,
3
+ MemoryToolCallTrace,
4
+ MessageMemoryTrace,
5
+ } from "@agent-mockingbird/contracts/dashboard";
6
+ import type {
7
+ Config,
8
+ Event as OpencodeEvent,
9
+ Message,
10
+ OpencodeClient,
11
+ Part,
12
+ Session,
13
+ SessionStatus as OpencodeSessionStatus,
14
+ } from "@opencode-ai/sdk/client";
15
+
16
+ import type {
17
+ ConfiguredMcpServer,
18
+ AgentMockingbirdConfig,
19
+ } from "../../config/schema";
20
+ import { getConfigSnapshot } from "../../config/service";
21
+ import type { RuntimeEvent } from "../../contracts/events";
22
+ import type {
23
+ BackgroundRunHandle,
24
+ BackgroundRunStatus,
25
+ ListBackgroundRunsInput,
26
+ PromptBackgroundAsyncInput,
27
+ RuntimeHealthCheckInput,
28
+ RuntimeHealthCheckResult,
29
+ RuntimeInputPart,
30
+ RuntimeMessageAck,
31
+ SendUserMessageInput,
32
+ SpawnBackgroundSessionInput,
33
+ } from "../../contracts/runtime";
34
+ import { createLogger } from "../../logging/logger";
35
+ import type { MemorySearchResult } from "../../memory/types";
36
+
37
+ export type Listener = (event: RuntimeEvent) => void;
38
+ export type AssistantInfo = Extract<Message, { role: "assistant" }>;
39
+ export type OpencodeMessagePartUpdatedEvent = Extract<
40
+ OpencodeEvent,
41
+ { type: "message.part.updated" }
42
+ >;
43
+ export type OpencodeMessageUpdatedEvent = Extract<
44
+ OpencodeEvent,
45
+ { type: "message.updated" }
46
+ >;
47
+ export type OpencodeMessagePartDeltaEvent = {
48
+ type: "message.part.delta";
49
+ properties: {
50
+ sessionID: string;
51
+ messageID: string;
52
+ partID: string;
53
+ field: string;
54
+ delta: string;
55
+ };
56
+ };
57
+ export type OpencodePermissionAskedEvent = {
58
+ type: "permission.asked";
59
+ properties: {
60
+ id: string;
61
+ sessionID: string;
62
+ permission: string;
63
+ patterns: string[];
64
+ metadata: Record<string, unknown>;
65
+ always: string[];
66
+ };
67
+ };
68
+ export type OpencodePermissionRepliedEvent = {
69
+ type: "permission.replied";
70
+ properties: {
71
+ sessionID: string;
72
+ requestID?: string;
73
+ reply?: "once" | "always" | "reject";
74
+ permissionID?: string;
75
+ response?: string;
76
+ };
77
+ };
78
+ export type OpencodeQuestionAskedEvent = {
79
+ type: "question.asked";
80
+ properties: {
81
+ id: string;
82
+ sessionID: string;
83
+ questions: Array<{
84
+ question: string;
85
+ header: string;
86
+ options: Array<{ label: string; description: string }>;
87
+ multiple?: boolean;
88
+ custom?: boolean;
89
+ }>;
90
+ };
91
+ };
92
+ export type OpencodeQuestionRepliedEvent = {
93
+ type: "question.replied";
94
+ properties: {
95
+ sessionID: string;
96
+ requestID: string;
97
+ };
98
+ };
99
+ export type OpencodeQuestionRejectedEvent = {
100
+ type: "question.rejected";
101
+ properties: {
102
+ sessionID: string;
103
+ requestID: string;
104
+ };
105
+ };
106
+ export type OpencodeRuntimeEvent =
107
+ | OpencodeEvent
108
+ | OpencodeMessagePartDeltaEvent
109
+ | OpencodePermissionAskedEvent
110
+ | OpencodePermissionRepliedEvent
111
+ | OpencodeQuestionAskedEvent
112
+ | OpencodeQuestionRepliedEvent
113
+ | OpencodeQuestionRejectedEvent;
114
+ export type ResolvedModel = { providerId: string; modelId: string };
115
+ export type RuntimeOpencodeConfig =
116
+ AgentMockingbirdConfig["runtime"]["opencode"];
117
+ export type RuntimeAgentCatalog = {
118
+ ids: Set<string>;
119
+ primaryId?: string;
120
+ };
121
+
122
+ export interface OpencodeRuntimeOptions {
123
+ defaultProviderId: string;
124
+ defaultModelId: string;
125
+ fallbackModelRefs?: Array<string>;
126
+ client?: OpencodeClient;
127
+ getRuntimeConfig?: () => RuntimeOpencodeConfig;
128
+ getEnabledSkills?: () => Array<string>;
129
+ getEnabledMcps?: () => Array<string>;
130
+ getConfiguredMcpServers?: () => Array<ConfiguredMcpServer>;
131
+ enableEventSync?: boolean;
132
+ enableSmallModelSync?: boolean;
133
+ enableBackgroundSync?: boolean;
134
+ searchMemoryFn?: (
135
+ query: string,
136
+ options?: { maxResults?: number; minScore?: number },
137
+ ) => Promise<MemorySearchResult[]>;
138
+ }
139
+
140
+ export const MODEL_MEMORY_TOOLS = new Set([
141
+ "memory_search",
142
+ "memory_get",
143
+ "memory_remember",
144
+ ]);
145
+ export const RUNTIME_HEALTH_PROMPT =
146
+ 'Just respond "OK" to this to confirm the gateway is working.';
147
+ export const RUNTIME_HEALTH_OK_PATTERN = /\bok\b/i;
148
+ export const RUNTIME_HEALTH_CACHE_TTL_MS = 5_000;
149
+ export const RUNTIME_HEALTH_TIMEOUT_CAP_MS = 15_000;
150
+ export const OPENCODE_RUNTIME_ID = "opencode";
151
+ export const BACKGROUND_SYNC_INTERVAL_MS = 8_000;
152
+ export const BACKGROUND_SYNC_BATCH_LIMIT = 200;
153
+ export const BACKGROUND_MESSAGE_SYNC_MIN_INTERVAL_MS = 3_000;
154
+ export const SESSION_SYNC_MESSAGE_LIMIT = 10_000;
155
+ const QUEUE_DRAIN_METADATA_KEY = "__queueDrain";
156
+ export const STREAMED_METADATA_CACHE_LIMIT = 10_000;
157
+ export const AGENT_NAME_CACHE_TTL_MS = 5_000;
158
+ export const MEMORY_INJECTION_STATE_TTL_MS = 6 * 60 * 60_000;
159
+ export const MEMORY_INJECTION_STATE_MAX_ENTRIES = 1_000;
160
+ export const BUILTIN_SUBAGENT_IDS = new Set(["general", "explore"]);
161
+ export const BUILTIN_PRIMARY_AGENT_IDS = new Set([
162
+ "build",
163
+ "plan",
164
+ "title",
165
+ "summary",
166
+ "compaction",
167
+ ]);
168
+ export type RuntimeHealthSnapshot = Omit<RuntimeHealthCheckResult, "fromCache">;
169
+ export type MemoryInjectionState = {
170
+ fingerprint: string;
171
+ forceReinject: boolean;
172
+ generation: number;
173
+ turn: number;
174
+ injectedKeysByGeneration: string[];
175
+ };
176
+ export type MemoryInjectionStateEntry = {
177
+ state: MemoryInjectionState;
178
+ lastTouchedAt: number;
179
+ };
180
+
181
+ export const logger = createLogger("opencode-runtime");
182
+
183
+ export function shouldQueueWhenBusy(input: SendUserMessageInput): boolean {
184
+ return input.metadata?.heartbeat !== true;
185
+ }
186
+
187
+ export function isQueueDrainRequest(input: SendUserMessageInput): boolean {
188
+ return input.metadata?.[QUEUE_DRAIN_METADATA_KEY] === true;
189
+ }
190
+
191
+ export function isPlainObject(
192
+ value: unknown,
193
+ ): value is Record<string, unknown> {
194
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
195
+ }
196
+
197
+ export function normalizeStringArray(values: unknown) {
198
+ if (!Array.isArray(values)) return [];
199
+ const normalized = values
200
+ .map((value) => (typeof value === "string" ? value.trim() : ""))
201
+ .filter(Boolean);
202
+ return [...new Set(normalized)].sort((a, b) => a.localeCompare(b));
203
+ }
204
+
205
+ export function shallowEqualStringArrays(
206
+ left: Array<string>,
207
+ right: Array<string>,
208
+ ) {
209
+ if (left.length !== right.length) return false;
210
+ for (let index = 0; index < left.length; index += 1) {
211
+ if (left[index] !== right[index]) return false;
212
+ }
213
+ return true;
214
+ }
215
+
216
+ export function currentMemoryConfig() {
217
+ return getConfigSnapshot().config.runtime.memory;
218
+ }
219
+
220
+ export function normalizeUsageDelta(value: unknown): number {
221
+ if (typeof value !== "number" || !Number.isFinite(value)) return 0;
222
+ if (value <= 0) return 0;
223
+ return Math.round(value);
224
+ }
225
+
226
+ export function normalizeCostDelta(value: unknown): number {
227
+ if (typeof value !== "number" || !Number.isFinite(value)) return 0;
228
+ if (value <= 0) return 0;
229
+ return value;
230
+ }
231
+
232
+ export type {
233
+ ChatMessagePart,
234
+ Config,
235
+ ListBackgroundRunsInput,
236
+ MemorySearchResult,
237
+ MemoryToolCallTrace,
238
+ Message,
239
+ MessageMemoryTrace,
240
+ OpencodeClient,
241
+ OpencodeEvent,
242
+ OpencodeSessionStatus,
243
+ Part,
244
+ PromptBackgroundAsyncInput,
245
+ RuntimeHealthCheckInput,
246
+ RuntimeHealthCheckResult,
247
+ RuntimeInputPart,
248
+ RuntimeMessageAck,
249
+ SendUserMessageInput,
250
+ Session,
251
+ SpawnBackgroundSessionInput,
252
+ BackgroundRunHandle,
253
+ BackgroundRunStatus,
254
+ };