talon-agent 3.8.2 → 3.9.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.
- package/package.json +1 -2
- package/src/backend/claude-sdk/handler.ts +1 -1
- package/src/backend/codex/handler/message.ts +1 -1
- package/src/backend/kilo/handler/index.ts +1 -2
- package/src/backend/kilo/handler/state.ts +3 -8
- package/src/backend/kilo/index.ts +2 -28
- package/src/backend/openai-agents/handler/message.ts +1 -1
- package/src/backend/openai-agents/session.ts +1 -1
- package/src/backend/opencode/handler/index.ts +1 -2
- package/src/backend/opencode/handler/state.ts +3 -8
- package/src/backend/opencode/index.ts +0 -7
- package/src/backend/shared/delivery.ts +1 -1
- package/src/backend/shared/handle-retry.ts +1 -1
- package/src/backend/shared/index.ts +3 -2
- package/src/backend/shared/turn-interrupt.ts +1 -1
- package/src/cli/index.ts +0 -8
- package/src/core/bus/index.ts +1 -9
- package/src/core/mesh/registry.ts +106 -4
- package/src/core/mesh/service.ts +22 -7
- package/src/core/mesh/transfers.ts +33 -4
- package/src/core/plugin/index.ts +0 -9
- package/src/core/prompt/index.ts +1 -16
- package/src/core/vfs/index.ts +2 -21
- package/src/core/weaver/index.ts +5 -9
- package/src/frontend/discord/actions/messaging.ts +73 -13
- package/src/frontend/discord/actions/shared.ts +21 -3
- package/src/frontend/discord/commands/admin.ts +1 -1
- package/src/frontend/discord/errors.ts +16 -5
- package/src/frontend/discord/formatting.ts +19 -4
- package/src/frontend/native/index.ts +22 -8
- package/src/frontend/native/protocol.ts +6 -0
- package/src/frontend/native/server.ts +171 -12
- package/src/frontend/shared/format.ts +6 -0
- package/src/frontend/telegram/actions/messaging.ts +120 -24
- package/src/frontend/telegram/callbacks/metrics.ts +1 -1
- package/src/frontend/telegram/commands/admin.ts +1 -1
- package/src/frontend/telegram/formatting.ts +64 -19
- package/src/frontend/terminal/commands.ts +46 -8
- package/src/frontend/terminal/input.ts +110 -12
- package/src/frontend/terminal/renderer.ts +2 -0
- package/src/{util → storage}/metrics.ts +1 -1
- package/src/storage/scheduled-store.ts +6 -3
- package/src/util/config.ts +8 -0
- package/src/util/log.ts +1 -0
- package/src/backend/codex/index.ts +0 -33
- package/src/backend/openai-agents/index.ts +0 -48
- package/src/cli/plugin-entries.ts +0 -104
- package/src/core/agent-runtime/index.ts +0 -62
- package/src/core/background/index.ts +0 -21
- package/src/core/engine/index.ts +0 -20
- package/src/core/models/index.ts +0 -17
- package/src/core/soul/index.ts +0 -140
- package/src/core/tools/mcp-server.ts +0 -111
- /package/src/{backend/shared → util}/session-name.ts +0 -0
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Codex backend — barrel re-export.
|
|
3
|
-
*
|
|
4
|
-
* Wraps `@openai/codex-sdk` (which in turn spawns the `codex` CLI from
|
|
5
|
-
* `@openai/codex`) and exposes a Backend-compatible API. The
|
|
6
|
-
* implementation is split across focused modules:
|
|
7
|
-
*
|
|
8
|
-
* - `constants.ts` — system-prompt suffix, default model.
|
|
9
|
-
* - `state.ts` — per-process state container.
|
|
10
|
-
* - `init.ts` — backend init + lazy Codex-instance construction.
|
|
11
|
-
* - `mcp-config.ts` — Talon MCP plugins → Codex `--config` TOML.
|
|
12
|
-
* - `handler.ts` — main message handler (streaming, end_turn).
|
|
13
|
-
* - `factory.ts` — registry registration.
|
|
14
|
-
*
|
|
15
|
-
* MCP integration: Codex configures MCP servers at thread-creation
|
|
16
|
-
* time via TOML overrides. Talon rebuilds the `Codex` instance when
|
|
17
|
-
* the active chat id changes so each chat sees its own MCP server
|
|
18
|
-
* environment (frontend-tools + plugin servers).
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
export {
|
|
22
|
-
CODEX_SYSTEM_PROMPT_SUFFIX,
|
|
23
|
-
CODEX_DEFAULT_MODEL,
|
|
24
|
-
CODEX_DEFAULT_WORKING_DIRECTORY,
|
|
25
|
-
} from "./constants.js";
|
|
26
|
-
|
|
27
|
-
export { initCodexAgent, ensureCodex } from "./init.js";
|
|
28
|
-
|
|
29
|
-
export { handleMessage, getActiveAbort } from "./handler/index.js";
|
|
30
|
-
|
|
31
|
-
export { runOneShotAgent } from "./one-shot.js";
|
|
32
|
-
|
|
33
|
-
export { buildCodexMcpServers, type CodexMcpServer } from "./mcp-config.js";
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OpenAI Agents backend — barrel.
|
|
3
|
-
*
|
|
4
|
-
* Importing this module registers the backend with the registry via
|
|
5
|
-
* `factory.ts`'s side-effect import. Most callers should NOT need to
|
|
6
|
-
* reach in here — the bootstrap layer picks the active backend by id.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import "./factory.js";
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
initOpenAIAgentsAgent,
|
|
13
|
-
getOpenAIApiKey,
|
|
14
|
-
getOpenAIBaseUrl,
|
|
15
|
-
triggerDiscoveryRefresh,
|
|
16
|
-
} from "./init.js";
|
|
17
|
-
export {
|
|
18
|
-
awaitDiscovery,
|
|
19
|
-
startDiscovery,
|
|
20
|
-
refreshDiscovery,
|
|
21
|
-
hasDiscoveredCatalog,
|
|
22
|
-
fetchEndpointModels,
|
|
23
|
-
extractCapabilities,
|
|
24
|
-
} from "./discovery.js";
|
|
25
|
-
export { handleMessage, getActiveAbort } from "./handler/index.js";
|
|
26
|
-
export { resetState, getState } from "./state.js";
|
|
27
|
-
export {
|
|
28
|
-
resolveModel,
|
|
29
|
-
getModelInfo,
|
|
30
|
-
getSettingsPresentation,
|
|
31
|
-
getProviders,
|
|
32
|
-
getProviderModels,
|
|
33
|
-
formatModelError,
|
|
34
|
-
listModels,
|
|
35
|
-
} from "./models.js";
|
|
36
|
-
export {
|
|
37
|
-
OPENAI_AGENTS_SYSTEM_PROMPT_SUFFIX,
|
|
38
|
-
OPENAI_AGENTS_DEFAULT_MODEL,
|
|
39
|
-
OPENAI_AGENTS_MAX_TURNS,
|
|
40
|
-
OPENAI_AGENTS_AGENT_NAME,
|
|
41
|
-
} from "./constants.js";
|
|
42
|
-
export {
|
|
43
|
-
getOrCreateBundle,
|
|
44
|
-
releaseBundle,
|
|
45
|
-
releaseAllBundles,
|
|
46
|
-
getActiveBundleIds,
|
|
47
|
-
} from "./mcp-pool.js";
|
|
48
|
-
export type { OpenAIAgentsMcpBundle, BundleInputs } from "./mcp-pool.js";
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure helpers over the config `plugins` array for the `talon plugin`
|
|
3
|
-
* command group. The CLI edits config.json as JSON — entries here are the
|
|
4
|
-
* on-disk shape (`core/plugin/types.ts` PluginEntry), not loaded plugins.
|
|
5
|
-
* No filesystem or process access — everything is testable data-in/data-out.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/** On-disk plugin entry — path-based module or standalone MCP server. */
|
|
9
|
-
export type PluginEntryJson = {
|
|
10
|
-
path?: string;
|
|
11
|
-
config?: Record<string, unknown>;
|
|
12
|
-
name?: string;
|
|
13
|
-
command?: string;
|
|
14
|
-
args?: string[];
|
|
15
|
-
env?: Record<string, string>;
|
|
16
|
-
enabled?: boolean;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Built-in plugins toggled by their own config sections (`github.enabled`,
|
|
21
|
-
* …) rather than `plugins[]` entries — see core/plugin/builtins.ts.
|
|
22
|
-
*/
|
|
23
|
-
export const BUILTIN_PLUGINS = [
|
|
24
|
-
"github",
|
|
25
|
-
"mempalace",
|
|
26
|
-
"mem0",
|
|
27
|
-
"playwright",
|
|
28
|
-
] as const;
|
|
29
|
-
|
|
30
|
-
export function isBuiltinPlugin(name: string): boolean {
|
|
31
|
-
return (BUILTIN_PLUGINS as readonly string[]).includes(name);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** Split a config path on either separator — Windows configs carry `\`. */
|
|
35
|
-
function pathSegments(path: string): string[] {
|
|
36
|
-
return path.split(/[\\/]+/).filter(Boolean);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Display name for an entry: the MCP name, or for path entries the package
|
|
41
|
-
* name — segments after the last `node_modules` (preserving `@scope/pkg`),
|
|
42
|
-
* else the folder basename.
|
|
43
|
-
*/
|
|
44
|
-
export function entryDisplayName(entry: PluginEntryJson): string {
|
|
45
|
-
if (entry.name) return entry.name;
|
|
46
|
-
if (!entry.path) return "(invalid entry)";
|
|
47
|
-
const segments = pathSegments(entry.path);
|
|
48
|
-
const nm = segments.lastIndexOf("node_modules");
|
|
49
|
-
if (nm >= 0 && nm < segments.length - 1) {
|
|
50
|
-
return segments.slice(nm + 1).join("/");
|
|
51
|
-
}
|
|
52
|
-
return segments[segments.length - 1] ?? entry.path;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** Does `token` identify this entry? Display name, basename, or full path. */
|
|
56
|
-
export function entryMatches(entry: PluginEntryJson, token: string): boolean {
|
|
57
|
-
if (entryDisplayName(entry) === token) return true;
|
|
58
|
-
if (!entry.path) return false;
|
|
59
|
-
const segments = pathSegments(entry.path);
|
|
60
|
-
return entry.path === token || segments[segments.length - 1] === token;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function findEntryIndex(
|
|
64
|
-
entries: PluginEntryJson[],
|
|
65
|
-
token: string,
|
|
66
|
-
): number {
|
|
67
|
-
return entries.findIndex((entry) => entryMatches(entry, token));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Index of an entry with the same identity as `candidate` (same module
|
|
72
|
-
* path or same MCP name) — the duplicate an install must replace.
|
|
73
|
-
*/
|
|
74
|
-
export function findConflictIndex(
|
|
75
|
-
entries: PluginEntryJson[],
|
|
76
|
-
candidate: PluginEntryJson,
|
|
77
|
-
): number {
|
|
78
|
-
return entries.findIndex((entry) =>
|
|
79
|
-
candidate.path !== undefined
|
|
80
|
-
? entry.path === candidate.path
|
|
81
|
-
: entry.name !== undefined && entry.name === candidate.name,
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Copy of `entry` with the enabled state applied. Enabled is the default,
|
|
87
|
-
* so enabling removes the key rather than writing `enabled: true`.
|
|
88
|
-
*/
|
|
89
|
-
export function withEnabled(
|
|
90
|
-
entry: PluginEntryJson,
|
|
91
|
-
enabled: boolean,
|
|
92
|
-
): PluginEntryJson {
|
|
93
|
-
const { enabled: _drop, ...rest } = entry;
|
|
94
|
-
return enabled ? rest : { ...rest, enabled: false };
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Package name of an npm spec, version stripped: `pkg@1.2` → `pkg`,
|
|
99
|
-
* `@scope/pkg@^1` → `@scope/pkg`. A leading `@` is the scope, not a version.
|
|
100
|
-
*/
|
|
101
|
-
export function npmSpecName(spec: string): string {
|
|
102
|
-
const at = spec.lastIndexOf("@");
|
|
103
|
-
return at > 0 ? spec.slice(0, at) : spec;
|
|
104
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent runtime — barrel for the primitives every backend, frontend,
|
|
3
|
-
* and dispatcher consumer reads through. See `agent-runtime/README.md`
|
|
4
|
-
* for the module map.
|
|
5
|
-
*
|
|
6
|
-
* - `AgentEvent` + helpers (events.ts)
|
|
7
|
-
* - `ModelRef` + helpers (model-ref.ts)
|
|
8
|
-
* - `Backend` + capability interfaces + `composeBackend` (capabilities.ts)
|
|
9
|
-
* - Backend contract assertions (contract-tests.ts)
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
type AgentEvent,
|
|
14
|
-
type AgentError,
|
|
15
|
-
type AgentErrorKind,
|
|
16
|
-
type AgentResult,
|
|
17
|
-
type UsageSnapshot,
|
|
18
|
-
addUsage,
|
|
19
|
-
AgentRunError,
|
|
20
|
-
classifiedToAgentError,
|
|
21
|
-
emptyUsage,
|
|
22
|
-
isAgentEventOf,
|
|
23
|
-
isAgentRunTerminator,
|
|
24
|
-
toolInputToRecord,
|
|
25
|
-
} from "./events.js";
|
|
26
|
-
|
|
27
|
-
export {
|
|
28
|
-
type BackendId,
|
|
29
|
-
type CacheSupport,
|
|
30
|
-
type ModelRef,
|
|
31
|
-
type ModelSource,
|
|
32
|
-
BACKEND_IDS,
|
|
33
|
-
isBackendId,
|
|
34
|
-
makeBareModelRef,
|
|
35
|
-
sameModelRef,
|
|
36
|
-
} from "./model-ref.js";
|
|
37
|
-
|
|
38
|
-
export {
|
|
39
|
-
type Backend,
|
|
40
|
-
type BackgroundRunner,
|
|
41
|
-
type ChatBackend,
|
|
42
|
-
type ChatRunParams,
|
|
43
|
-
type ModelCatalog,
|
|
44
|
-
type SessionBackend,
|
|
45
|
-
type SystemControl,
|
|
46
|
-
type ToolRefreshResult,
|
|
47
|
-
type ToolRuntime,
|
|
48
|
-
type UsageTelemetry,
|
|
49
|
-
composeBackend,
|
|
50
|
-
} from "./capabilities.js";
|
|
51
|
-
|
|
52
|
-
export {
|
|
53
|
-
assertBackendContract,
|
|
54
|
-
assertBackendIdentity,
|
|
55
|
-
assertBackgroundRunnerLifecycle,
|
|
56
|
-
assertChatBackendEmitsRunStarted,
|
|
57
|
-
assertChatBackendEmitsSingleUsage,
|
|
58
|
-
assertChatBackendTerminates,
|
|
59
|
-
assertCompletedUsageMatchesUsageEvent,
|
|
60
|
-
assertModelCatalogDefaultShape,
|
|
61
|
-
assertUsageTelemetryShape,
|
|
62
|
-
} from "./contract-tests.js";
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Background agents — everything that runs without a user message.
|
|
3
|
-
*
|
|
4
|
-
* - `heartbeat` — periodic autonomous agent pass ("anything need
|
|
5
|
-
* doing?"), prompted by prompts/heartbeat.md.
|
|
6
|
-
* - `dream` — memory-consolidation agent (daily notes → memory,
|
|
7
|
-
* mempalace mining), prompted by prompts/dream.md.
|
|
8
|
-
* - `pulse` — lightweight liveness/typing-indicator ticker.
|
|
9
|
-
* - `cron` — persistent user-scheduled jobs (message / query).
|
|
10
|
-
* - `triggers` — user-authored watcher scripts that fire wake-ups.
|
|
11
|
-
*
|
|
12
|
-
* All of these drive the backend through the same `BackgroundRunner`
|
|
13
|
-
* surface (core/agent-runtime/capabilities.ts) — they never talk to a
|
|
14
|
-
* concrete backend directly.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
export * from "./heartbeat/index.js";
|
|
18
|
-
export * from "./dream.js";
|
|
19
|
-
export * from "./pulse.js";
|
|
20
|
-
export * from "./cron.js";
|
|
21
|
-
export * from "./triggers/index.js";
|
package/src/core/engine/index.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Engine — the message-flow core.
|
|
3
|
-
*
|
|
4
|
-
* - `dispatcher` — per-chat serial, cross-chat parallel turn
|
|
5
|
-
* execution; the single entry point for "run this user message".
|
|
6
|
-
* - `gateway` — loopback HTTP bridge the MCP tool
|
|
7
|
-
* subprocesses call back into.
|
|
8
|
-
* - `gateway-actions` — the action handlers the bridge dispatches
|
|
9
|
-
* to (send/edit/react/cron/trigger/admin …).
|
|
10
|
-
* - `backend-controller` — backend lifecycle: init, hot-swap,
|
|
11
|
-
* cleanup, registry lookup.
|
|
12
|
-
*
|
|
13
|
-
* Everything here is frontend- and backend-agnostic: frontends feed
|
|
14
|
-
* the dispatcher, backends are reached through the agent-runtime
|
|
15
|
-
* capability slots.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
export * from "./dispatcher.js";
|
|
19
|
-
export * from "./gateway.js";
|
|
20
|
-
export * from "./backend-controller/index.js";
|
package/src/core/models/index.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Model layer — everything about "which model is the chat using".
|
|
3
|
-
*
|
|
4
|
-
* - `catalog` — model-id resolution, defaults, and the
|
|
5
|
-
* curated cross-backend catalog.
|
|
6
|
-
* - `active-model` — per-chat active-model resolution
|
|
7
|
-
* (chat-settings → config → backend default).
|
|
8
|
-
* - `reasoning-levels` — the reasoning-effort vocabulary shared by
|
|
9
|
-
* every backend (order, labels, normalisation).
|
|
10
|
-
*
|
|
11
|
-
* Presentation helpers (menus, status lines) live in `frontend/` —
|
|
12
|
-
* this layer is pure domain.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
export * from "./catalog.js";
|
|
16
|
-
export * from "./active-model.js";
|
|
17
|
-
export * from "./reasoning-levels.js";
|
package/src/core/soul/index.ts
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Soul Kernel — public surface.
|
|
3
|
-
*
|
|
4
|
-
* Talon's compiled identity: a content-addressed Merkle DAG of evidence, values,
|
|
5
|
-
* spine, reflexes, and lenses, learned mechanically from behavioral telemetry and
|
|
6
|
-
* projected into the system prompt by selection. The reasoning model reads the
|
|
7
|
-
* soul; it never writes it.
|
|
8
|
-
*
|
|
9
|
-
* Typical lifecycle:
|
|
10
|
-
*
|
|
11
|
-
* const soul = SoulKernel.genesis({ seedValues: [...] });
|
|
12
|
-
* soul.ingest({ kind: "correction", at, text, activeNodes });
|
|
13
|
-
* soul.commit("nightly");
|
|
14
|
-
* const { text } = soul.project({ lens: "dylan" }); // inject `text`
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
export { SoulKernel } from "./kernel.js";
|
|
18
|
-
export type { GenesisOptions } from "./kernel.js";
|
|
19
|
-
export { SoulDag, structuralChildren } from "./dag.js";
|
|
20
|
-
export { projectRuntime, estimateTokens } from "./projector.js";
|
|
21
|
-
export type { Projection, ProjectionOptions } from "./projector.js";
|
|
22
|
-
export { retrieveValues, DEFAULT_RETRIEVAL_WEIGHTS } from "./retrieve.js";
|
|
23
|
-
export type {
|
|
24
|
-
RetrievedValue,
|
|
25
|
-
RetrievalWeights,
|
|
26
|
-
RetrieveOptions,
|
|
27
|
-
} from "./retrieve.js";
|
|
28
|
-
export {
|
|
29
|
-
evaluateReflexes,
|
|
30
|
-
evaluateReflex,
|
|
31
|
-
isBlocked,
|
|
32
|
-
seedReflexes,
|
|
33
|
-
BUILTIN_PREDICATES,
|
|
34
|
-
} from "./reflex.js";
|
|
35
|
-
export type {
|
|
36
|
-
ReflexContext,
|
|
37
|
-
ReflexVerdict,
|
|
38
|
-
ReflexPredicate,
|
|
39
|
-
} from "./reflex.js";
|
|
40
|
-
export {
|
|
41
|
-
reinforce,
|
|
42
|
-
coactivate,
|
|
43
|
-
applyPredictionError,
|
|
44
|
-
effectiveSalience,
|
|
45
|
-
confidence,
|
|
46
|
-
decayFactor,
|
|
47
|
-
} from "./salience.js";
|
|
48
|
-
export { ingest, ingestAll, appendSpine } from "./compiler.js";
|
|
49
|
-
export type { IngestResult } from "./compiler.js";
|
|
50
|
-
export {
|
|
51
|
-
retrievability,
|
|
52
|
-
effectiveStrength,
|
|
53
|
-
reinforceFsrs,
|
|
54
|
-
nextStability,
|
|
55
|
-
initialStability,
|
|
56
|
-
} from "./forgetting.js";
|
|
57
|
-
export {
|
|
58
|
-
critique,
|
|
59
|
-
extractFeatures,
|
|
60
|
-
isFlagged,
|
|
61
|
-
DEFAULT_THRESHOLDS,
|
|
62
|
-
} from "./critic.js";
|
|
63
|
-
export type {
|
|
64
|
-
Critique,
|
|
65
|
-
CritiqueFeatures,
|
|
66
|
-
CritiqueThresholds,
|
|
67
|
-
FailureMode,
|
|
68
|
-
} from "./critic.js";
|
|
69
|
-
export { deriveFailureModes, assessText } from "./emergent-critic.js";
|
|
70
|
-
export type { EmergentFailureMode, FailureRisk } from "./emergent-critic.js";
|
|
71
|
-
export { emojiValence } from "./signals.js";
|
|
72
|
-
export type { Signal } from "./signals.js";
|
|
73
|
-
export { ValenceModel } from "./valence.js";
|
|
74
|
-
export type { ValenceSnapshot } from "./valence.js";
|
|
75
|
-
export { Adwin } from "./drift.js";
|
|
76
|
-
export type { AdwinChange } from "./drift.js";
|
|
77
|
-
export { diffSnapshots, renderDelta, explainDelta } from "./delta.js";
|
|
78
|
-
export type { SoulDelta } from "./delta.js";
|
|
79
|
-
export { ApprovalQueue } from "./governance.js";
|
|
80
|
-
export type {
|
|
81
|
-
Proposal,
|
|
82
|
-
ProposalStatus,
|
|
83
|
-
ApprovalSnapshot,
|
|
84
|
-
} from "./governance.js";
|
|
85
|
-
export {
|
|
86
|
-
CompositionalMemory,
|
|
87
|
-
symbolVector,
|
|
88
|
-
bind,
|
|
89
|
-
bundle,
|
|
90
|
-
permute,
|
|
91
|
-
cleanup,
|
|
92
|
-
hdCosine,
|
|
93
|
-
DEFAULT_HD_DIM,
|
|
94
|
-
} from "./hdc.js";
|
|
95
|
-
export type { Hypervector } from "./hdc.js";
|
|
96
|
-
export {
|
|
97
|
-
HashingEmbedder,
|
|
98
|
-
cosineSimilarity,
|
|
99
|
-
cosineDistance,
|
|
100
|
-
normalize,
|
|
101
|
-
centroid,
|
|
102
|
-
medoidIndex,
|
|
103
|
-
dot,
|
|
104
|
-
norm,
|
|
105
|
-
} from "./embedder.js";
|
|
106
|
-
export type { Embedder } from "./embedder.js";
|
|
107
|
-
export { TalonEmbedder } from "./talon-embedder.js";
|
|
108
|
-
export type { TalonEmbedderOptions } from "./talon-embedder.js";
|
|
109
|
-
export {
|
|
110
|
-
resolveSoulSettings,
|
|
111
|
-
soulEnabled,
|
|
112
|
-
DEFAULT_SOUL_SETTINGS,
|
|
113
|
-
} from "./settings.js";
|
|
114
|
-
export type { SoulSettings } from "./settings.js";
|
|
115
|
-
export { clusterEvidence } from "./cluster.js";
|
|
116
|
-
export type { Embedded, EvidenceCluster } from "./cluster.js";
|
|
117
|
-
export { detectTensions, tensionPairs } from "./lattice.js";
|
|
118
|
-
export type { TensionOptions } from "./lattice.js";
|
|
119
|
-
export { associativeRecall, prime } from "./associative.js";
|
|
120
|
-
export type {
|
|
121
|
-
RecallResult,
|
|
122
|
-
RecallOptions,
|
|
123
|
-
PrimeOptions,
|
|
124
|
-
} from "./associative.js";
|
|
125
|
-
export { pagerank } from "./centrality.js";
|
|
126
|
-
export type { PageRankOptions } from "./centrality.js";
|
|
127
|
-
export { consolidate, liveValues, isSuperseded } from "./consolidate.js";
|
|
128
|
-
export type { ConsolidateOptions, ConsolidateResult } from "./consolidate.js";
|
|
129
|
-
export { reflect } from "./reflect.js";
|
|
130
|
-
export { compileLens, liveLens } from "./lens.js";
|
|
131
|
-
export type { LensOptions } from "./lens.js";
|
|
132
|
-
export type { ReflectOptions, ReflectResult } from "./reflect.js";
|
|
133
|
-
export {
|
|
134
|
-
hashContent,
|
|
135
|
-
hashPayload,
|
|
136
|
-
canonicalize,
|
|
137
|
-
merkleRoot,
|
|
138
|
-
isHash,
|
|
139
|
-
} from "./hash.js";
|
|
140
|
-
export * from "./types.js";
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Unified MCP server — replaces per-backend tools.ts files.
|
|
4
|
-
*
|
|
5
|
-
* Reads TALON_FRONTEND env var to compose the right tool set,
|
|
6
|
-
* then registers them all on a single MCP server over stdio.
|
|
7
|
-
*
|
|
8
|
-
* Environment:
|
|
9
|
-
* TALON_BRIDGE_URL — HTTP bridge URL (default: http://127.0.0.1:19876)
|
|
10
|
-
* TALON_CHAT_ID — Current chat ID
|
|
11
|
-
* TALON_FRONTEND — Frontend type: "telegram" | "teams" | "terminal" | "discord" | "native" (default: "telegram")
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
15
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
16
|
-
import { composeTools } from "./index.js";
|
|
17
|
-
import { createBridge, textResult } from "./bridge.js";
|
|
18
|
-
import {
|
|
19
|
-
ENV_DISABLED_TOOLS,
|
|
20
|
-
ENV_DISABLED_TOOL_TAGS,
|
|
21
|
-
parseEnvList,
|
|
22
|
-
} from "./mcp-env.js";
|
|
23
|
-
import type { ToolFrontend, ToolTag } from "./types.js";
|
|
24
|
-
|
|
25
|
-
process.on("unhandledRejection", (err) => {
|
|
26
|
-
const detail =
|
|
27
|
-
err instanceof Error ? (err.stack ?? err.message) : String(err);
|
|
28
|
-
const message = `[mcp-server] Unhandled rejection: ${detail}\n`;
|
|
29
|
-
|
|
30
|
-
// Ensure we always exit even if stderr is backpressured
|
|
31
|
-
const forceExit = setTimeout(() => process.exit(1), 1000);
|
|
32
|
-
forceExit.unref();
|
|
33
|
-
|
|
34
|
-
process.stderr.write(message, () => {
|
|
35
|
-
clearTimeout(forceExit);
|
|
36
|
-
process.exit(1);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const VALID_FRONTENDS = new Set<ToolFrontend>([
|
|
41
|
-
"telegram",
|
|
42
|
-
"teams",
|
|
43
|
-
"terminal",
|
|
44
|
-
"discord",
|
|
45
|
-
"native",
|
|
46
|
-
]);
|
|
47
|
-
const BRIDGE_URL = process.env.TALON_BRIDGE_URL || "http://127.0.0.1:19876";
|
|
48
|
-
const CHAT_ID = process.env.TALON_CHAT_ID || "";
|
|
49
|
-
const rawFrontend = (process.env.TALON_FRONTEND || "telegram") as ToolFrontend;
|
|
50
|
-
|
|
51
|
-
if (!CHAT_ID) {
|
|
52
|
-
console.warn(
|
|
53
|
-
"TALON_CHAT_ID is not set — bridge calls will fail without a valid chat context.",
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (!VALID_FRONTENDS.has(rawFrontend)) {
|
|
58
|
-
console.error(
|
|
59
|
-
`Invalid TALON_FRONTEND: "${rawFrontend}". Must be one of: ${[...VALID_FRONTENDS].join(", ")}`,
|
|
60
|
-
);
|
|
61
|
-
process.exit(1);
|
|
62
|
-
}
|
|
63
|
-
const FRONTEND = rawFrontend;
|
|
64
|
-
|
|
65
|
-
const bridge = createBridge(BRIDGE_URL, CHAT_ID);
|
|
66
|
-
const serverName = `${FRONTEND}-tools`;
|
|
67
|
-
const server = new McpServer({ name: serverName, version: "3.0.0" });
|
|
68
|
-
|
|
69
|
-
// Compose and register the tool set for the active frontend, minus
|
|
70
|
-
// any config-disabled tools/tags (see `disabledTools` /
|
|
71
|
-
// `disabledToolTags` in talon.json — every registered tool costs
|
|
72
|
-
// context tokens in every session, so unused groups are trimmable).
|
|
73
|
-
// `end_turn` is exempt: tool-only backends need it to close every turn.
|
|
74
|
-
const excludeNames = parseEnvList(process.env[ENV_DISABLED_TOOLS]).filter(
|
|
75
|
-
(name) => name !== "end_turn",
|
|
76
|
-
);
|
|
77
|
-
const excludeTags = parseEnvList(
|
|
78
|
-
process.env[ENV_DISABLED_TOOL_TAGS],
|
|
79
|
-
) as ToolTag[];
|
|
80
|
-
|
|
81
|
-
const tools = composeTools({ frontend: FRONTEND, excludeTags, excludeNames });
|
|
82
|
-
if (excludeTags.length > 0 && !tools.some((t) => t.name === "end_turn")) {
|
|
83
|
-
const endTurn = composeTools({ frontend: FRONTEND }).find(
|
|
84
|
-
(t) => t.name === "end_turn",
|
|
85
|
-
);
|
|
86
|
-
if (endTurn) tools.push(endTurn);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
for (const tool of tools) {
|
|
90
|
-
server.tool(tool.name, tool.description, tool.schema, async (params) =>
|
|
91
|
-
textResult(await tool.execute(params, bridge)),
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
async function main() {
|
|
96
|
-
const transport = new StdioServerTransport();
|
|
97
|
-
await server.connect(transport);
|
|
98
|
-
|
|
99
|
-
// Graceful self-termination: when the parent closes our stdin (e.g. the SDK
|
|
100
|
-
// tears down this MCP server during hot-swap), exit cleanly. This is the
|
|
101
|
-
// OS-agnostic replacement for scanning /proc — the parent signals "you're done"
|
|
102
|
-
// by closing the stdio pipe, and we respect it.
|
|
103
|
-
process.stdin.on("end", () => {
|
|
104
|
-
server.close().finally(() => process.exit(0));
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
main().catch((err) => {
|
|
109
|
-
console.error("MCP server error:", err);
|
|
110
|
-
process.exit(1);
|
|
111
|
-
});
|
|
File without changes
|