talon-agent 3.32.1 → 3.33.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 (138) hide show
  1. package/package.json +1 -1
  2. package/src/backend/claude-sdk/constants.ts +1 -6
  3. package/src/backend/claude-sdk/index.ts +2 -11
  4. package/src/backend/claude-sdk/models/parsing.ts +2 -2
  5. package/src/backend/claude-sdk/plan-usage.ts +0 -5
  6. package/src/backend/claude-sdk/stream.ts +1 -1
  7. package/src/backend/codex/auth.ts +2 -2
  8. package/src/backend/codex/constants.ts +0 -21
  9. package/src/backend/codex/handler/index.ts +0 -1
  10. package/src/backend/codex/mcp-config.ts +2 -2
  11. package/src/backend/codex/plan-usage.ts +0 -5
  12. package/src/backend/codex/state.ts +1 -1
  13. package/src/backend/codex/token-usage.ts +1 -1
  14. package/src/backend/kilo/factory.ts +39 -119
  15. package/src/backend/kilo/handler/index.ts +1 -11
  16. package/src/backend/kilo/handler/message.ts +20 -317
  17. package/src/backend/kilo/index.ts +0 -6
  18. package/src/backend/kilo/server.ts +55 -292
  19. package/src/backend/kilo/sessions.ts +5 -86
  20. package/src/backend/openai-agents/handler/index.ts +0 -1
  21. package/src/backend/openai-agents/handler/state.ts +0 -5
  22. package/src/backend/openai-agents/init.ts +1 -18
  23. package/src/backend/opencode/factory.ts +41 -118
  24. package/src/backend/opencode/handler/index.ts +1 -11
  25. package/src/backend/opencode/handler/message.ts +20 -321
  26. package/src/backend/opencode/index.ts +0 -4
  27. package/src/backend/opencode/server.ts +56 -225
  28. package/src/backend/opencode/sessions.ts +5 -86
  29. package/src/backend/remote-server/chat-turn.ts +359 -0
  30. package/src/backend/remote-server/client.ts +1 -1
  31. package/src/backend/remote-server/events.ts +1 -1
  32. package/src/backend/remote-server/factory.ts +150 -0
  33. package/src/backend/remote-server/index.ts +15 -43
  34. package/src/backend/remote-server/mcp.ts +1 -4
  35. package/src/backend/remote-server/model-catalog/catalog.ts +1 -1
  36. package/src/backend/remote-server/model-catalog/index.ts +1 -15
  37. package/src/backend/remote-server/model-catalog/provider.ts +0 -1
  38. package/src/backend/remote-server/server-bindings.ts +232 -0
  39. package/src/backend/remote-server/sse-stream.ts +1 -3
  40. package/src/backend/remote-server/turn-timeout.ts +1 -1
  41. package/src/backend/{kilo/handler → remote-server}/turn.ts +103 -67
  42. package/src/backend/shared/index.ts +7 -43
  43. package/src/cli/logs.ts +1 -1
  44. package/src/cli/status.ts +1 -1
  45. package/src/core/agent-runtime/backend-registry.ts +1 -1
  46. package/src/core/agent-runtime/capabilities.ts +1 -1
  47. package/src/core/agent-runtime/events.ts +1 -1
  48. package/src/core/background/heartbeat/agent.ts +1 -1
  49. package/src/core/background/heartbeat/index.ts +1 -2
  50. package/src/core/background/isolated-agent.ts +1 -1
  51. package/src/core/background/triggers/exit.ts +1 -1
  52. package/src/core/background/triggers/index.ts +1 -1
  53. package/src/core/bus/events.ts +2 -2
  54. package/src/core/doctor.ts +1 -1
  55. package/src/core/engine/backend-controller/index.ts +1 -3
  56. package/src/core/engine/backend-controller/rebind.ts +2 -2
  57. package/src/core/engine/dispatcher.ts +1 -15
  58. package/src/core/engine/gateway-actions/index.ts +0 -3
  59. package/src/core/engine/gateway-actions/types.ts +1 -1
  60. package/src/core/frontend-runtime/capabilities.ts +0 -2
  61. package/src/core/frontend-runtime/index.ts +1 -6
  62. package/src/core/frontend-runtime/routing.ts +0 -1
  63. package/src/core/mcp-hub/children.ts +0 -5
  64. package/src/core/mesh/bridge-links.ts +319 -0
  65. package/src/core/mesh/common.ts +30 -0
  66. package/src/core/mesh/device-files.ts +710 -0
  67. package/src/core/mesh/index.ts +1 -18
  68. package/src/core/mesh/service.ts +72 -894
  69. package/src/core/models/active-model.ts +0 -19
  70. package/src/core/plugin/index.ts +0 -1
  71. package/src/core/plugin/registry.ts +1 -1
  72. package/src/core/prompt/templates.ts +0 -5
  73. package/src/core/scripting/lua-runner.ts +1 -1
  74. package/src/core/scripts/runner.ts +1 -1
  75. package/src/core/soul/critic.ts +1 -1
  76. package/src/core/soul/embedder.ts +2 -2
  77. package/src/core/soul/governance.ts +1 -1
  78. package/src/core/soul/hdc.ts +1 -1
  79. package/src/core/soul/reflex.ts +2 -2
  80. package/src/core/soul/retrieve.ts +1 -1
  81. package/src/core/soul/signals.ts +4 -4
  82. package/src/core/soul/types.ts +1 -1
  83. package/src/core/tasks/index.ts +0 -4
  84. package/src/core/tasks/types.ts +1 -1
  85. package/src/core/tools/index.ts +1 -6
  86. package/src/core/tools/mcp-env.ts +3 -33
  87. package/src/core/types.ts +1 -1
  88. package/src/core/update/self-update.ts +1 -1
  89. package/src/core/vfs/fusefs.ts +1 -1
  90. package/src/core/vfs/types.ts +1 -1
  91. package/src/core/weaver/index.ts +1 -1
  92. package/src/core/weaver/typing-loop.ts +1 -1
  93. package/src/frontend/discord/actions/types.ts +1 -1
  94. package/src/frontend/discord/commands/definitions.ts +1 -1
  95. package/src/frontend/discord/handlers/access.ts +7 -61
  96. package/src/frontend/discord/handlers/index.ts +2 -15
  97. package/src/frontend/discord/handlers/registry.ts +0 -6
  98. package/src/frontend/discord/handlers/state.ts +15 -8
  99. package/src/frontend/native/protocol.ts +1 -4
  100. package/src/frontend/native/server.ts +392 -324
  101. package/src/frontend/shared/access.ts +152 -0
  102. package/src/frontend/shared/status-context.ts +1 -1
  103. package/src/frontend/telegram/actions/types.ts +1 -1
  104. package/src/frontend/telegram/commands/index.ts +1 -1
  105. package/src/frontend/telegram/commands/state.ts +1 -1
  106. package/src/frontend/telegram/handlers/access.ts +8 -25
  107. package/src/frontend/telegram/handlers/index.ts +0 -1
  108. package/src/frontend/telegram/handlers/queue.ts +3 -35
  109. package/src/frontend/telegram/handlers/state.ts +15 -8
  110. package/src/frontend/telegram/helpers/menu.ts +1 -1
  111. package/src/frontend/terminal/commands.ts +1 -4
  112. package/src/frontend/terminal/renderer.ts +1 -1
  113. package/src/frontend/whatsapp/actions/chat-info.ts +0 -3
  114. package/src/frontend/whatsapp/actions/messaging.ts +1 -7
  115. package/src/frontend/whatsapp/actions/shared.ts +1 -1
  116. package/src/frontend/whatsapp/actions/types.ts +1 -1
  117. package/src/frontend/whatsapp/formatting.ts +1 -1
  118. package/src/frontend/whatsapp/media-store.ts +1 -1
  119. package/src/frontend/whatsapp/pins.ts +0 -5
  120. package/src/native/fusefs.ts +3 -3
  121. package/src/native/scheduler-core.ts +1 -1
  122. package/src/native/warden.ts +2 -2
  123. package/src/plugins/mempalace/provision.ts +1 -5
  124. package/src/plugins/playwright/provision.ts +1 -1
  125. package/src/storage/db.ts +1 -1
  126. package/src/storage/goal-store.ts +1 -5
  127. package/src/storage/metrics.ts +0 -5
  128. package/src/storage/repositories/scripts-repo.ts +0 -5
  129. package/src/storage/scheduled-store.ts +1 -5
  130. package/src/storage/script-store.ts +5 -13
  131. package/src/storage/sessions.ts +0 -3
  132. package/src/storage/skill-store.ts +3 -3
  133. package/src/util/exec-output.ts +1 -1
  134. package/src/util/mcp-launcher.ts +3 -0
  135. package/src/backend/kilo/events.ts +0 -60
  136. package/src/backend/kilo/handler/state.ts +0 -9
  137. package/src/backend/opencode/handler/state.ts +0 -9
  138. package/src/backend/opencode/handler/turn.ts +0 -314
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "talon-agent",
3
- "version": "3.32.1",
3
+ "version": "3.33.1",
4
4
  "description": "Multi-frontend AI agent with full tool access, streaming, cron jobs, and plugin system",
5
5
  "author": "Dylan Neve",
6
6
  "license": "MIT",
@@ -6,14 +6,9 @@
6
6
  * additions live next to the rest of the chat-handler config).
7
7
  */
8
8
 
9
- import {
10
- ALLOWED_TOOLS_CORE,
11
- ALLOWED_TOOLS_BACKGROUND,
12
- } from "../../core/constants.js";
9
+ import { ALLOWED_TOOLS_CORE } from "../../core/constants.js";
13
10
 
14
11
  // Re-export so existing backend imports keep working
15
- export { ALLOWED_TOOLS_CORE, ALLOWED_TOOLS_BACKGROUND };
16
-
17
12
  /**
18
13
  * Whitelist of built-in tools available to the main chat handler.
19
14
  *
@@ -8,14 +8,5 @@
8
8
  export { initAgent, updateSystemPrompt } from "./state.js";
9
9
  export { warmSession } from "./warm.js";
10
10
  export { getActiveQuery } from "./handler.js";
11
- export {
12
- buildMcpServers,
13
- buildPluginMcpServers,
14
- getActiveFrontends,
15
- } from "./options.js";
16
- export { getBridgePort } from "./state.js";
17
- export {
18
- runOneShotAgent,
19
- evictOrphanSubprocesses,
20
- initClaudeOneShot,
21
- } from "./one-shot.js";
11
+ export { buildMcpServers, buildPluginMcpServers } from "./options.js";
12
+ export { runOneShotAgent, evictOrphanSubprocesses } from "./one-shot.js";
@@ -167,7 +167,7 @@ export function describeSdkModel(model: SdkModelInfo): ParsedModelIdentity {
167
167
  };
168
168
  }
169
169
 
170
- export function buildFamilyKey(identity: ParsedModelIdentity): string | null {
170
+ function buildFamilyKey(identity: ParsedModelIdentity): string | null {
171
171
  return identity.family
172
172
  ? `${identity.family}:${identity.version ?? "*"}`
173
173
  : null;
@@ -178,7 +178,7 @@ export function buildFamilyKey(identity: ParsedModelIdentity): string | null {
178
178
  * context size. Base and 1M variants of one family+version land in separate
179
179
  * buckets so both surface in the picker, while redundant longhand ids collapse.
180
180
  */
181
- export function buildVariantKey(identity: ParsedModelIdentity): string | null {
181
+ function buildVariantKey(identity: ParsedModelIdentity): string | null {
182
182
  const familyKey = buildFamilyKey(identity);
183
183
  if (!familyKey) return null;
184
184
  return `${familyKey}:${identity.isOneMillion ? "1m" : "base"}`;
@@ -163,8 +163,3 @@ export async function getPlanUsage(): Promise<PlanUsage | undefined> {
163
163
  export function invalidatePlanUsage(): void {
164
164
  if (cache) cache.fetchedAt = 0;
165
165
  }
166
-
167
- export function resetPlanUsageForTest(): void {
168
- cache = undefined;
169
- inFlight = undefined;
170
- }
@@ -214,7 +214,7 @@ export function processStreamDelta(
214
214
  }
215
215
 
216
216
  /** A tool call extracted from an assistant message. */
217
- export type ToolCall = {
217
+ type ToolCall = {
218
218
  /** The SDK's tool_use block id — matches the later tool_result. */
219
219
  id: string;
220
220
  name: string;
@@ -45,7 +45,7 @@ import { existsSync, readFileSync } from "node:fs";
45
45
  import { join } from "node:path";
46
46
 
47
47
  /** Detected auth mode. */
48
- export type CodexAuthMode = "api-key" | "chatgpt" | "none";
48
+ type CodexAuthMode = "api-key" | "chatgpt" | "none";
49
49
 
50
50
  export type CodexApiKeySource =
51
51
  | "env:CODEX_API_KEY"
@@ -80,7 +80,7 @@ export interface DetectCodexAuthInput {
80
80
  env?: NodeJS.ProcessEnv;
81
81
  }
82
82
 
83
- export function normalizeCodexBaseUrl(
83
+ function normalizeCodexBaseUrl(
84
84
  baseUrl: string | undefined,
85
85
  ): string | undefined {
86
86
  const trimmed = baseUrl?.trim();
@@ -46,27 +46,6 @@ export const CODEX_DEFAULT_MODEL = "gpt-5-codex";
46
46
  */
47
47
  export const CODEX_CHATGPT_DEFAULT_MODEL = "gpt-5.5";
48
48
 
49
- /**
50
- * Set of Codex models that require an API key (i.e. won't work under
51
- * ChatGPT OAuth). Used by the handler's recovery ladder to detect a
52
- * model-not-supported error and automatically fall back to a
53
- * chatgpt-compatible model on retry.
54
- *
55
- * Keep this list in sync with `CODEX_MODELS` in `models.ts` — every
56
- * entry there with `apiKeyOnly: true` should appear here.
57
- */
58
- export const CODEX_API_KEY_ONLY_MODELS: ReadonlySet<string> = new Set([
59
- "gpt-5-codex",
60
- ]);
61
-
62
- /**
63
- * Default working directory for thread runs. Codex enforces a git-repo
64
- * check by default; we set `skipGitRepoCheck: true` and use a known
65
- * directory under the user's Talon workspace.
66
- */
67
- export const CODEX_DEFAULT_WORKING_DIRECTORY =
68
- process.env.HOME ?? process.cwd();
69
-
70
49
  /**
71
50
  * ThreadOptions permission settings shared by both the chat handler and
72
51
  * the heartbeat/dream one-shot path.
@@ -12,4 +12,3 @@
12
12
 
13
13
  export { handleMessage } from "./message.js";
14
14
  export { getActiveAbort } from "./state.js";
15
- export { CodexUsageExhaustedError } from "./usage.js";
@@ -49,7 +49,7 @@ import { frontendsForChat } from "../shared/frontends.js";
49
49
  * short-circuits to `true` for this server. Equivalent
50
50
  * to saying "Talon trusts this server, don't ask."
51
51
  */
52
- export type CodexToolApprovalMode = "auto" | "prompt" | "approve";
52
+ type CodexToolApprovalMode = "auto" | "prompt" | "approve";
53
53
 
54
54
  /** TOML-compatible record shape Codex's CLI accepts (HTTP transport). */
55
55
  export interface CodexMcpServer {
@@ -100,7 +100,7 @@ export function asCodexConfig(
100
100
  * reasoning. Exposed as a module-level constant rather than a
101
101
  * literal-everywhere so behaviour changes happen in exactly one place.
102
102
  */
103
- export const TALON_MCP_DEFAULT_APPROVAL: CodexToolApprovalMode = "approve";
103
+ const TALON_MCP_DEFAULT_APPROVAL: CodexToolApprovalMode = "approve";
104
104
 
105
105
  /**
106
106
  * Build the Codex `mcp_servers` config map for a given chat.
@@ -161,8 +161,3 @@ export async function getPlanUsage(): Promise<PlanUsage | undefined> {
161
161
  if (loaded) cache = { value: loaded, fetchedAt: loaded.fetchedAt };
162
162
  return loaded ?? cache?.value;
163
163
  }
164
-
165
- export function resetCodexPlanUsageForTest(): void {
166
- cache = undefined;
167
- inFlight = undefined;
168
- }
@@ -20,7 +20,7 @@ import type { FrontendName } from "../../core/agent-runtime/backend-registry.js"
20
20
  * window, description); the api-key path (`/v1/models`) is sparse and
21
21
  * leaves these fields undefined.
22
22
  */
23
- export interface DiscoveredModelMetadata {
23
+ interface DiscoveredModelMetadata {
24
24
  displayName?: string;
25
25
  contextWindow?: number;
26
26
  description?: string;
@@ -47,7 +47,7 @@ export interface CodexLastTokenUsage {
47
47
  * want per-turn usage must snapshot before the turn and diff after
48
48
  * (see the terminator-abort fallback in `handler.ts`).
49
49
  */
50
- export interface CodexTokenTotals {
50
+ interface CodexTokenTotals {
51
51
  inputTokens: number;
52
52
  cachedInputTokens: number;
53
53
  outputTokens: number;
@@ -3,131 +3,51 @@
3
3
  *
4
4
  * Side-effect import (`import "./factory.js"` from `bootstrap.ts`) calls
5
5
  * `registerBackend(...)` at module load, making Kilo available under
6
- * `config.backend === "kilo"`.
7
- *
8
- * Returns a composed `Backend` with capability slots for chat,
9
- * background, models, and usage.
6
+ * `config.backend === "kilo"`. The capability wiring is the shared
7
+ * remote-server composition; only the bound functions are Kilo's.
10
8
  */
11
9
 
12
10
  import { registerBackend } from "../../core/agent-runtime/backend-registry.js";
13
- import type { BackendFactory } from "../../core/agent-runtime/backend-registry.js";
14
- import { log } from "../../util/log.js";
15
- import { handlerToEvents } from "../shared/handler-to-events.js";
16
- import { interruptChatTurn } from "../shared/turn-interrupt.js";
17
- import {
18
- composeBackend,
19
- type ChatBackend,
20
- type BackgroundRunner,
21
- type ModelCatalog,
22
- type SessionBackend,
23
- type SystemControl,
24
- type ToolRuntime,
25
- type UsageTelemetry,
26
- } from "../../core/agent-runtime/capabilities.js";
27
-
11
+ import { createRemoteBackendFactory } from "../remote-server/factory.js";
28
12
  import {
29
13
  initKiloAgent,
30
14
  stopKiloServer,
31
- handleMessage as kiloHandleMessage,
32
- runOneShotAgent as kiloRunOneShotAgent,
15
+ handleMessage,
16
+ runOneShotAgent,
33
17
  getKiloSessionSnapshot,
34
- resolveModel as kiloResolveModel,
35
- getModelInfo as kiloGetModelInfo,
36
- getSettingsPresentation as kiloGetSettingsPresentation,
37
- getProviders as kiloGetProviders,
38
- getProviderModels as kiloGetProviderModels,
39
- formatModelError as kiloFormatModelError,
40
- listModels as kiloListModels,
41
- refreshPluginMcpServers as kiloRefreshPluginMcpServers,
42
- updateSystemPrompt as kiloUpdateSystemPrompt,
43
- warmSession as kiloWarmSession,
18
+ resolveModel,
19
+ getModelInfo,
20
+ getSettingsPresentation,
21
+ getProviders,
22
+ getProviderModels,
23
+ formatModelError,
24
+ listModels,
25
+ refreshPluginMcpServers,
26
+ updateSystemPrompt,
27
+ warmSession,
44
28
  } from "./index.js";
45
29
 
46
- const kiloFactory: BackendFactory = {
47
- id: "kilo",
48
- label: "Kilo",
49
-
50
- async init(config, ctx) {
51
- initKiloAgent(config, ctx.getBridgePort, ctx.frontendName);
52
- log("bot", "Backend: Kilo (@kilocode/sdk)");
53
-
54
- const chat: ChatBackend = {
55
- runChatTurn: (params) =>
56
- handlerToEvents((p) => kiloHandleMessage(p), params),
57
- interruptChatTurn: (chatId) => interruptChatTurn(chatId),
58
- };
59
-
60
- const background: BackgroundRunner = {
61
- runOneShotAgent: (p) => kiloRunOneShotAgent(p),
62
- // Kilo runs a long-lived HTTP server — no per-query subprocesses.
63
- // `evictOrphanSubprocesses` is intentionally not implemented.
64
- };
65
-
66
- const models: ModelCatalog = {
67
- resolveModelInfo: (q) => kiloResolveModel(q),
68
- // Catalog-driven backend with no canonical default — fall
69
- // through to `config.backendDefaults.kilo`.
70
- getDefaultModelId: () => undefined,
71
- getRawModelInfo: (id) => kiloGetModelInfo(id),
72
- getSettingsPresentation: (m, options) =>
73
- kiloGetSettingsPresentation(m, options),
74
- getProviders: () => kiloGetProviders(),
75
- getProviderModels: (p, pg, ps) => kiloGetProviderModels(p, pg, ps),
76
- formatModelError: (q, r) => kiloFormatModelError(q, r),
77
- listModels: (f) => kiloListModels(f),
78
- };
79
-
80
- const usage: UsageTelemetry = {
81
- getSessionSnapshot: async (sessionId) => {
82
- const snap = await getKiloSessionSnapshot(sessionId);
83
- if (!snap) return undefined;
84
- return {
85
- inputTokens: snap.usage?.totalInputTokens,
86
- outputTokens: snap.usage?.totalOutputTokens,
87
- cacheRead: snap.usage?.totalCacheRead,
88
- cacheWrite: snap.usage?.totalCacheWrite,
89
- contextModelId: snap.assistant?.modelID,
90
- };
91
- },
92
- };
93
-
94
- const tools: ToolRuntime = {
95
- refreshTools: (chatId) => kiloRefreshPluginMcpServers(chatId),
96
- };
97
-
98
- // Session state lives on the Kilo server, and `/reset` already clears
99
- // Talon's stored id centrally (storage/sessions.ts), so the next turn
100
- // creates a fresh one — no `resetChat` needed. `warmSession` front-loads
101
- // that creation plus the plugin-MCP sweep, matching what the Claude
102
- // backend does after a reset.
103
- const sessions: SessionBackend = {
104
- warmSession: (chatId) => kiloWarmSession(chatId),
105
- };
106
-
107
- const control: SystemControl = {
108
- updateSystemPrompt: (prompt) => kiloUpdateSystemPrompt(prompt),
109
- };
110
-
111
- const backend = composeBackend({
112
- id: "kilo",
113
- label: "Kilo",
114
- cacheMetrics: "readwrite",
115
- chat,
116
- background,
117
- models,
118
- sessions,
119
- tools,
120
- usage,
121
- control,
122
- });
123
-
124
- return {
125
- backend,
126
- cleanup: () => {
127
- stopKiloServer();
128
- },
129
- };
130
- },
131
- };
132
-
133
- registerBackend(kiloFactory);
30
+ registerBackend(
31
+ createRemoteBackendFactory({
32
+ id: "kilo",
33
+ label: "Kilo",
34
+ sdkPackage: "@kilocode/sdk",
35
+ init: initKiloAgent,
36
+ stop: stopKiloServer,
37
+ handleMessage,
38
+ runOneShotAgent,
39
+ getSessionSnapshot: getKiloSessionSnapshot,
40
+ models: {
41
+ resolveModel,
42
+ getModelInfo,
43
+ getSettingsPresentation,
44
+ getProviders,
45
+ getProviderModels,
46
+ formatModelError,
47
+ listModels,
48
+ },
49
+ refreshPluginMcpServers,
50
+ warmSession,
51
+ updateSystemPrompt,
52
+ }),
53
+ );
@@ -1,12 +1,2 @@
1
- /**
2
- * Kilo message handler.
3
- *
4
- * Split by responsibility:
5
- * - `state` — in-flight session registry (activeSessions)
6
- * - `turn` — runKiloTurn + SSE subscription + last-assistant lookup
7
- * - `message` — the handleMessage entry point + post-loop accounting
8
- *
9
- * Re-exports the same public surface the old single-file module exposed.
10
- */
11
-
1
+ /** Kilo message handler barrel. */
12
2
  export { handleMessage } from "./message.js";