letagents 0.12.11 → 0.12.13

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 (49) hide show
  1. package/dist/mcp/git-remote.js +7 -7
  2. package/dist/mcp/local-state/agent-sessions.js +78 -5
  3. package/dist/mcp/local-state/local-chat.js +189 -48
  4. package/dist/mcp/local-state/storage.js +16 -9
  5. package/dist/mcp/server/daemon-tool-executor.js +92 -0
  6. package/dist/mcp/server/register-tools.js +25 -12
  7. package/dist/mcp/server/runtime/agent-sessions.js +58 -9
  8. package/dist/mcp/server/runtime/api.js +40 -4
  9. package/dist/mcp/server/runtime/daemon-tool-context.js +11 -0
  10. package/dist/mcp/server/runtime/execution-profile.js +19 -0
  11. package/dist/mcp/server/runtime/identity/directory.js +2 -2
  12. package/dist/mcp/server/runtime/messages.js +55 -0
  13. package/dist/mcp/server/runtime/presence.js +4 -2
  14. package/dist/mcp/server/runtime/room-api.js +24 -7
  15. package/dist/mcp/server/runtime/room-state.js +59 -3
  16. package/dist/mcp/server/runtime/rooms.js +67 -32
  17. package/dist/mcp/server/runtime/supervised-room-authority.js +8 -0
  18. package/dist/mcp/server/runtime/supervisor-bridge.js +702 -24
  19. package/dist/mcp/server/runtime/tool-surface-policy.js +26 -0
  20. package/dist/mcp/server/runtime/worker-bearer.js +44 -6
  21. package/dist/mcp/server/runtime-contract.js +27 -0
  22. package/dist/mcp/server/runtime.js +15 -4
  23. package/dist/mcp/server/supervised-tool-facade.js +134 -0
  24. package/dist/mcp/server/tools/agent-sessions.js +74 -7
  25. package/dist/mcp/server/tools/messages/index.js +3 -2
  26. package/dist/mcp/server/tools/messages/read-tool.js +54 -97
  27. package/dist/mcp/server/tools/messages/reasoning-tool.js +2 -0
  28. package/dist/mcp/server/tools/messages/send-tool.js +5 -0
  29. package/dist/mcp/server/tools/messages/status-tool.js +2 -0
  30. package/dist/mcp/server/tools/messages/wait-tool.js +344 -71
  31. package/dist/mcp/server/tools/onboarding/status-tool.js +9 -8
  32. package/dist/mcp/server/tools/rooms/inspection-tools.js +40 -22
  33. package/dist/mcp/server/tools/rooms/repo-initialization-tool.js +2 -1
  34. package/dist/mcp/server/tools/supervised-room-turn.js +42 -0
  35. package/dist/mcp/server/tools/tasks/board-tools.js +34 -2
  36. package/dist/mcp/server.js +14 -7
  37. package/dist/mcp/sse-client.js +163 -20
  38. package/dist/shared/activation-routing.js +187 -20
  39. package/dist/shared/agent-presence.js +6 -0
  40. package/dist/shared/desktop-release-manifest.js +63 -0
  41. package/dist/shared/desktop-release.js +60 -0
  42. package/dist/shared/scoped-ids.js +6 -0
  43. package/package.json +11 -3
  44. package/shared/message-contracts.d.mts +32 -0
  45. package/shared/message-contracts.mjs +109 -0
  46. package/shared/routing-aliases.d.mts +18 -0
  47. package/shared/routing-aliases.mjs +66 -0
  48. package/shared/sqlite-thread-routing.d.mts +72 -0
  49. package/shared/sqlite-thread-routing.mjs +1038 -0
@@ -0,0 +1,66 @@
1
+ import { createHash } from "node:crypto";
2
+
3
+ /**
4
+ * Stable cross-engine fold: ASCII A-Z only. Unicode case conversion varies by
5
+ * JS/ICU/PostgreSQL version and locale, so non-ASCII aliases are deliberately
6
+ * case-sensitive while exact non-ASCII labels still match everywhere.
7
+ */
8
+ function foldRoutingText(value) {
9
+ return String(value ?? "").replace(/[A-Z]/g, (character) =>
10
+ String.fromCharCode(character.charCodeAt(0) + 32));
11
+ }
12
+
13
+ export function normalizeRoutingSender(value) {
14
+ return foldRoutingText(typeof value === "string" ? value.trim() : "")
15
+ .replace(/\s+/g, " ");
16
+ }
17
+
18
+ export function normalizeRoutingHandle(value) {
19
+ return foldRoutingText(typeof value === "string" ? value.trim() : "")
20
+ .replace(/[^a-z0-9_.:/-]+/g, "");
21
+ }
22
+
23
+ function routingIdentityAliasInputs(identity) {
24
+ const agentKey = typeof identity?.agentKey === "string"
25
+ ? identity.agentKey
26
+ : typeof identity?.agent_key === "string"
27
+ ? identity.agent_key
28
+ : "";
29
+ return Array.from(new Set([
30
+ identity?.actorLabel ?? identity?.actor_label,
31
+ identity?.displayName ?? identity?.display_name,
32
+ agentKey,
33
+ agentKey.split("/").pop(),
34
+ ].map((value) => typeof value === "string" ? value.trim() : "").filter(Boolean)));
35
+ }
36
+
37
+ export function routingIdentityAliases(identity) {
38
+ const aliases = new Set();
39
+ for (const value of routingIdentityAliasInputs(identity)) {
40
+ const senderAlias = normalizeRoutingSender(value);
41
+ if (senderAlias) aliases.add(senderAlias);
42
+ const handleAlias = normalizeRoutingHandle(value);
43
+ if (handleAlias) aliases.add(handleAlias);
44
+ }
45
+ return aliases;
46
+ }
47
+
48
+ export function routingSenderAliasRows(sender, segmentLimit = 16) {
49
+ const raw = typeof sender === "string" ? sender : "";
50
+ const fullAlias = normalizeRoutingSender(raw);
51
+ const byAlias = new Map();
52
+ if (fullAlias) byAlias.set(fullAlias, true);
53
+ for (const segment of raw.split("|").slice(0, Math.max(0, segmentLimit))) {
54
+ const alias = normalizeRoutingSender(segment);
55
+ if (alias && !byAlias.has(alias)) byAlias.set(alias, false);
56
+ }
57
+ return [...byAlias].map(([alias, isFull]) => ({ alias, isFull }));
58
+ }
59
+
60
+ export function routingSenderAliases(sender, segmentLimit = 16) {
61
+ return new Set(routingSenderAliasRows(sender, segmentLimit).map(({ alias }) => alias));
62
+ }
63
+
64
+ export function routingAliasHash(alias) {
65
+ return createHash("md5").update(alias).digest("hex");
66
+ }
@@ -0,0 +1,72 @@
1
+ import type { RoutingIdentityLike } from "./routing-aliases.mjs";
2
+
3
+ export type SqliteRoutingDatabase = {
4
+ exec(sql: string): void;
5
+ prepare(sql: string): {
6
+ all(...params: unknown[]): Record<string, unknown>[];
7
+ get(...params: unknown[]): Record<string, unknown> | undefined;
8
+ run(...params: unknown[]): unknown;
9
+ };
10
+ };
11
+
12
+ export const LOCAL_THREAD_ROUTING_BACKFILL_BATCH_SIZE: number;
13
+ export const LOCAL_THREAD_ROUTING_LOOKUP_BATCH_SIZE: number;
14
+ export const LOCAL_THREAD_ROUTING_BACKFILL_TIME_BUDGET_MS: number;
15
+ export class LocalThreadRoutingProjectionUnavailableError extends Error {}
16
+ export function ensureLocalThreadRoutingProjectionSchema(database: SqliteRoutingDatabase): void;
17
+ export function ensureLocalThreadRoutingProjectionSchemaAsync(
18
+ database: SqliteRoutingDatabase,
19
+ options?: { maxWaitMs?: number; random?: () => number },
20
+ ): Promise<void>;
21
+ export function runLocalSqliteWriteTransactionAsync<T>(
22
+ database: SqliteRoutingDatabase,
23
+ work: () => T,
24
+ options?: { maxWaitMs?: number; random?: () => number },
25
+ ): Promise<T>;
26
+ export function projectLocalThreadRoutingMessage(
27
+ database: SqliteRoutingDatabase,
28
+ row: {
29
+ room_id: string;
30
+ number: number;
31
+ thread_root_number?: number | null;
32
+ reply_to_number?: number | null;
33
+ sender: string;
34
+ text?: string;
35
+ source?: string | null;
36
+ timestamp?: string;
37
+ [key: string]: unknown;
38
+ },
39
+ ): void;
40
+ export function runLocalThreadRoutingBackfillBatch(
41
+ database: SqliteRoutingDatabase,
42
+ batchSize?: number,
43
+ ): { processed: number; completed: boolean };
44
+ export function scheduleLocalThreadRoutingBackfill(
45
+ database: SqliteRoutingDatabase,
46
+ options?: {
47
+ onError?: (error: unknown, delayMs: number | null) => void;
48
+ setImmediate?: (callback: () => void) => { unref?(): void } | unknown;
49
+ setTimeout?: (callback: () => void, delayMs: number) => { unref?(): void } | unknown;
50
+ },
51
+ ): void;
52
+ export function scheduleLocalThreadRoutingRootsRepair(
53
+ database: SqliteRoutingDatabase,
54
+ roomId: string,
55
+ rootNumbers: readonly number[],
56
+ ): void;
57
+ export function invalidateLocalThreadRoutingRoots(
58
+ database: SqliteRoutingDatabase,
59
+ roomId: string,
60
+ rootNumbers: readonly number[],
61
+ ): void;
62
+ export function getLocalThreadRoutingAgentKeysForRoots(
63
+ database: SqliteRoutingDatabase,
64
+ roomId: string,
65
+ rootNumbers: readonly number[],
66
+ identities: readonly RoutingIdentityLike[],
67
+ options?: {
68
+ foregroundTimeBudgetMs?: number;
69
+ scheduleOnTimeout?: boolean;
70
+ signal?: AbortSignal;
71
+ },
72
+ ): Promise<Map<number, Set<string>>>;