letagents 0.12.9 → 0.12.10

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 (117) hide show
  1. package/README.md +16 -15
  2. package/dist/mcp/agent-prompt-delivery.js +20 -0
  3. package/dist/mcp/codex-session/app-server.js +89 -0
  4. package/dist/mcp/codex-session/index.js +10 -0
  5. package/dist/mcp/codex-session/rpc-client.js +85 -0
  6. package/dist/mcp/codex-session/runtime-bridge.js +254 -0
  7. package/dist/mcp/codex-session/runtime-summary.js +220 -0
  8. package/dist/mcp/codex-session/session-inspection.js +100 -0
  9. package/dist/mcp/codex-session/session-mapper.js +51 -0
  10. package/dist/mcp/codex-session/session-start.js +182 -0
  11. package/dist/mcp/codex-session/session-status.js +77 -0
  12. package/dist/mcp/codex-session/session-stop.js +43 -0
  13. package/dist/mcp/codex-session/session-supervisor.js +111 -0
  14. package/dist/mcp/codex-session/start-prompt.js +49 -0
  15. package/dist/mcp/codex-session/types.js +1 -0
  16. package/dist/mcp/codex-session.js +1 -672
  17. package/dist/mcp/config-reader.js +10 -2
  18. package/dist/mcp/git-remote.js +90 -14
  19. package/dist/mcp/local-state/agent-identity.js +26 -0
  20. package/dist/mcp/local-state/agent-sessions.js +66 -0
  21. package/dist/mcp/local-state/auth.js +57 -0
  22. package/dist/mcp/local-state/codex-live-sessions.js +59 -0
  23. package/dist/mcp/local-state/index.js +8 -0
  24. package/dist/mcp/local-state/local-chat.js +808 -0
  25. package/dist/mcp/local-state/room-sessions.js +51 -0
  26. package/dist/mcp/local-state/storage.js +95 -0
  27. package/dist/mcp/local-state/types.js +1 -0
  28. package/dist/mcp/local-state.js +1 -351
  29. package/dist/mcp/managed-agent-providers.js +65 -0
  30. package/dist/mcp/rental-tools/activity.js +37 -0
  31. package/dist/mcp/rental-tools/budget.js +36 -0
  32. package/dist/mcp/rental-tools/context.js +62 -0
  33. package/dist/mcp/rental-tools/lifecycle.js +47 -0
  34. package/dist/mcp/rental-tools/metering.js +73 -0
  35. package/dist/mcp/rental-tools/patches.js +100 -0
  36. package/dist/mcp/rental-tools/provider.js +117 -0
  37. package/dist/mcp/rental-tools/shared.js +19 -0
  38. package/dist/mcp/rental-tools/types.js +1 -0
  39. package/dist/mcp/rental-tools.js +7 -0
  40. package/dist/mcp/repo-visibility.js +8 -6
  41. package/dist/mcp/server/register-tools.js +19 -0
  42. package/dist/mcp/server/repo-context.js +28 -0
  43. package/dist/mcp/server/resources.js +77 -0
  44. package/dist/mcp/server/runtime/agent-sessions.js +134 -0
  45. package/dist/mcp/server/runtime/api.js +82 -0
  46. package/dist/mcp/server/runtime/auth-cache.js +20 -0
  47. package/dist/mcp/server/runtime/device-auth.js +48 -0
  48. package/dist/mcp/server/runtime/identity/config.js +58 -0
  49. package/dist/mcp/server/runtime/identity/directory.js +87 -0
  50. package/dist/mcp/server/runtime/identity/liveness.js +32 -0
  51. package/dist/mcp/server/runtime/identity/names.js +74 -0
  52. package/dist/mcp/server/runtime/identity/public.js +19 -0
  53. package/dist/mcp/server/runtime/identity/state.js +32 -0
  54. package/dist/mcp/server/runtime/identity.js +96 -0
  55. package/dist/mcp/server/runtime/messages.js +160 -0
  56. package/dist/mcp/server/runtime/presence.js +52 -0
  57. package/dist/mcp/server/runtime/room-api.js +42 -0
  58. package/dist/mcp/server/runtime/room-state.js +122 -0
  59. package/dist/mcp/server/runtime/rooms.js +318 -0
  60. package/dist/mcp/server/runtime.js +14 -0
  61. package/dist/mcp/server/tools/agent-sessions.js +374 -0
  62. package/dist/mcp/server/tools/messages/index.js +14 -0
  63. package/dist/mcp/server/tools/messages/read-tool.js +176 -0
  64. package/dist/mcp/server/tools/messages/reasoning-tool.js +179 -0
  65. package/dist/mcp/server/tools/messages/response.js +17 -0
  66. package/dist/mcp/server/tools/messages/send-tool.js +203 -0
  67. package/dist/mcp/server/tools/messages/status-tool.js +87 -0
  68. package/dist/mcp/server/tools/messages/wait-tool.js +333 -0
  69. package/dist/mcp/server/tools/messages.js +1 -0
  70. package/dist/mcp/server/tools/onboarding/device-auth-tools.js +148 -0
  71. package/dist/mcp/server/tools/onboarding/name-tool.js +89 -0
  72. package/dist/mcp/server/tools/onboarding/responses.js +10 -0
  73. package/dist/mcp/server/tools/onboarding/status-tool.js +108 -0
  74. package/dist/mcp/server/tools/onboarding.js +8 -0
  75. package/dist/mcp/server/tools/rental/activity-tools.js +43 -0
  76. package/dist/mcp/server/tools/rental/context-tools.js +35 -0
  77. package/dist/mcp/server/tools/rental/index.js +17 -0
  78. package/dist/mcp/server/tools/rental/metering-tools.js +39 -0
  79. package/dist/mcp/server/tools/rental/patch-tools.js +53 -0
  80. package/dist/mcp/server/tools/rental/provider-tools.js +44 -0
  81. package/dist/mcp/server/tools/rental/response.js +10 -0
  82. package/dist/mcp/server/tools/rental/types.js +1 -0
  83. package/dist/mcp/server/tools/rental.js +1 -0
  84. package/dist/mcp/server/tools/rooms/index.js +5 -0
  85. package/dist/mcp/server/tools/rooms/inspection-tools.js +124 -0
  86. package/dist/mcp/server/tools/rooms/join-tools.js +37 -0
  87. package/dist/mcp/server/tools/rooms/repo-initialization-tool.js +113 -0
  88. package/dist/mcp/server/tools/rooms/repo-visibility-tool.js +20 -0
  89. package/dist/mcp/server/tools/rooms/response.js +10 -0
  90. package/dist/mcp/server/tools/rooms/resume-tool.js +48 -0
  91. package/dist/mcp/server/tools/rooms.js +1 -0
  92. package/dist/mcp/server/tools/tasks/api.js +222 -0
  93. package/dist/mcp/server/tools/tasks/artifact-tools.js +75 -0
  94. package/dist/mcp/server/tools/tasks/board-intent-tools.js +321 -0
  95. package/dist/mcp/server/tools/tasks/board-tools.js +73 -0
  96. package/dist/mcp/server/tools/tasks/context.js +35 -0
  97. package/dist/mcp/server/tools/tasks/event-tools.js +40 -0
  98. package/dist/mcp/server/tools/tasks/index.js +14 -0
  99. package/dist/mcp/server/tools/tasks/lease-tools.js +145 -0
  100. package/dist/mcp/server/tools/tasks/mutation-tools.js +121 -0
  101. package/dist/mcp/server/tools/tasks/response.js +13 -0
  102. package/dist/mcp/server/tools/tasks/schemas.js +68 -0
  103. package/dist/mcp/server/tools/tasks.js +1 -0
  104. package/dist/mcp/server.js +10 -3157
  105. package/dist/mcp/sse-client.js +6 -14
  106. package/dist/shared/activation-routing.js +263 -0
  107. package/dist/shared/agent-identity.js +21 -5
  108. package/dist/shared/agent-presence.js +4 -3
  109. package/dist/shared/rental/lrt.js +214 -0
  110. package/dist/shared/rental/meter-types.js +14 -0
  111. package/dist/shared/room-agent-prompts.js +14 -1
  112. package/package.json +15 -5
  113. package/dist/mcp/__tests__/config-reader.test.js +0 -93
  114. package/dist/mcp/__tests__/git-remote.test.js +0 -37
  115. package/dist/mcp/__tests__/server-helpers.test.js +0 -121
  116. package/dist/shared/agent-reasoning.js +0 -49
  117. /package/dist/{mcp → shared}/codenames.js +0 -0
@@ -1,93 +0,0 @@
1
- import { findLetagentsConfig, getRoomFromConfig } from "../config-reader";
2
- import { mkdirSync, writeFileSync, rmSync } from "fs";
3
- import { join } from "path";
4
- import { tmpdir } from "os";
5
- // Helper to create temp directories with config files
6
- function createTempDir() {
7
- const dir = join(tmpdir(), `letagents-test-${Date.now()}-${Math.random().toString(36).slice(2)}`);
8
- mkdirSync(dir, { recursive: true });
9
- return dir;
10
- }
11
- function cleanup(dir) {
12
- try {
13
- rmSync(dir, { recursive: true, force: true });
14
- }
15
- catch {
16
- // ignore cleanup errors
17
- }
18
- }
19
- describe("findLetagentsConfig", () => {
20
- let tempDir;
21
- afterEach(() => {
22
- if (tempDir)
23
- cleanup(tempDir);
24
- });
25
- it("returns config when .letagents.json is in the start directory", () => {
26
- tempDir = createTempDir();
27
- writeFileSync(join(tempDir, ".letagents.json"), JSON.stringify({ room: "github.com/EmmyMay/letagents" }));
28
- const config = findLetagentsConfig(tempDir);
29
- expect(config).toEqual({ room: "github.com/EmmyMay/letagents" });
30
- });
31
- it("walks up to find config in parent directory", () => {
32
- tempDir = createTempDir();
33
- const childDir = join(tempDir, "src", "mcp");
34
- mkdirSync(childDir, { recursive: true });
35
- writeFileSync(join(tempDir, ".letagents.json"), JSON.stringify({ room: "gitlab.com/team/project" }));
36
- const config = findLetagentsConfig(childDir);
37
- expect(config).toEqual({ room: "gitlab.com/team/project" });
38
- });
39
- it("returns null when no config file exists", () => {
40
- tempDir = createTempDir();
41
- const config = findLetagentsConfig(tempDir);
42
- expect(config).toBeNull();
43
- });
44
- it("returns null for config with missing room field", () => {
45
- tempDir = createTempDir();
46
- writeFileSync(join(tempDir, ".letagents.json"), JSON.stringify({ version: "1.0" }));
47
- // Suppress console.error for this test
48
- const spy = jest.spyOn(console, "error").mockImplementation();
49
- const config = findLetagentsConfig(tempDir);
50
- expect(config).toBeNull();
51
- spy.mockRestore();
52
- });
53
- it("returns null for config with empty room field", () => {
54
- tempDir = createTempDir();
55
- writeFileSync(join(tempDir, ".letagents.json"), JSON.stringify({ room: "" }));
56
- const spy = jest.spyOn(console, "error").mockImplementation();
57
- const config = findLetagentsConfig(tempDir);
58
- expect(config).toBeNull();
59
- spy.mockRestore();
60
- });
61
- it("returns null for invalid JSON", () => {
62
- tempDir = createTempDir();
63
- writeFileSync(join(tempDir, ".letagents.json"), "not valid json {{{");
64
- const spy = jest.spyOn(console, "error").mockImplementation();
65
- const config = findLetagentsConfig(tempDir);
66
- expect(config).toBeNull();
67
- spy.mockRestore();
68
- });
69
- it("trims whitespace from room name", () => {
70
- tempDir = createTempDir();
71
- writeFileSync(join(tempDir, ".letagents.json"), JSON.stringify({ room: " github.com/EmmyMay/letagents " }));
72
- const config = findLetagentsConfig(tempDir);
73
- expect(config).toEqual({ room: "github.com/EmmyMay/letagents" });
74
- });
75
- });
76
- describe("getRoomFromConfig", () => {
77
- let tempDir;
78
- afterEach(() => {
79
- if (tempDir)
80
- cleanup(tempDir);
81
- });
82
- it("returns room string when config exists", () => {
83
- tempDir = createTempDir();
84
- writeFileSync(join(tempDir, ".letagents.json"), JSON.stringify({ room: "github.com/EmmyMay/letagents" }));
85
- const room = getRoomFromConfig(tempDir);
86
- expect(room).toBe("github.com/EmmyMay/letagents");
87
- });
88
- it("returns null when no config exists", () => {
89
- tempDir = createTempDir();
90
- const room = getRoomFromConfig(tempDir);
91
- expect(room).toBeNull();
92
- });
93
- });
@@ -1,37 +0,0 @@
1
- import { normalizeGitRemote } from "../git-remote";
2
- describe("normalizeGitRemote", () => {
3
- // SSH format tests
4
- it("normalizes SSH git@github.com format", () => {
5
- expect(normalizeGitRemote("git@github.com:EmmyMay/letagents.git")).toBe("github.com/EmmyMay/letagents");
6
- });
7
- it("normalizes SSH without .git suffix", () => {
8
- expect(normalizeGitRemote("git@github.com:EmmyMay/letagents")).toBe("github.com/EmmyMay/letagents");
9
- });
10
- it("normalizes SSH with gitlab host", () => {
11
- expect(normalizeGitRemote("git@gitlab.com:team/project.git")).toBe("gitlab.com/team/project");
12
- });
13
- // HTTPS format tests
14
- it("normalizes HTTPS with .git suffix", () => {
15
- expect(normalizeGitRemote("https://github.com/EmmyMay/letagents.git")).toBe("github.com/EmmyMay/letagents");
16
- });
17
- it("normalizes HTTPS without .git suffix", () => {
18
- expect(normalizeGitRemote("https://github.com/EmmyMay/letagents")).toBe("github.com/EmmyMay/letagents");
19
- });
20
- it("normalizes HTTPS with trailing slash", () => {
21
- expect(normalizeGitRemote("https://github.com/EmmyMay/letagents/")).toBe("github.com/EmmyMay/letagents");
22
- });
23
- // SSH protocol format tests
24
- it("normalizes ssh:// protocol format", () => {
25
- expect(normalizeGitRemote("ssh://git@gitlab.com/team/project.git")).toBe("gitlab.com/team/project");
26
- });
27
- // Edge cases
28
- it("handles whitespace", () => {
29
- expect(normalizeGitRemote(" git@github.com:EmmyMay/letagents.git ")).toBe("github.com/EmmyMay/letagents");
30
- });
31
- it("handles nested paths", () => {
32
- expect(normalizeGitRemote("https://gitlab.com/org/sub-group/project.git")).toBe("gitlab.com/org/sub-group/project");
33
- });
34
- it("handles Bitbucket SSH format", () => {
35
- expect(normalizeGitRemote("git@bitbucket.org:workspace/repo.git")).toBe("bitbucket.org/workspace/repo");
36
- });
37
- });
@@ -1,121 +0,0 @@
1
- /**
2
- * Tests for server helper functions:
3
- * - resolveGitRoot: resolves the root of a git repo from any subdirectory
4
- * - findExistingConfig: walks parent dirs to find .letagents.json
5
- *
6
- * These helpers underpin the corrected initialize_repo tool behavior.
7
- * @author Kingdavid Ehindero <kdof64squares@gmail.com>
8
- */
9
- import { execSync } from "child_process";
10
- import { existsSync, mkdirSync, writeFileSync, rmSync } from "fs";
11
- import { join, resolve } from "path";
12
- import { tmpdir } from "os";
13
- // ---------------------------------------------------------------------------
14
- // Re-implement helpers here (they are not exported from server.ts yet)
15
- // We test the logic directly until we extract them to a shared module.
16
- // ---------------------------------------------------------------------------
17
- function resolveGitRoot(dir) {
18
- try {
19
- const root = execSync("git rev-parse --show-toplevel", {
20
- cwd: dir,
21
- stdio: ["pipe", "pipe", "pipe"],
22
- encoding: "utf-8",
23
- }).trim();
24
- return root || null;
25
- }
26
- catch {
27
- return null;
28
- }
29
- }
30
- function findExistingConfig(startDir) {
31
- const { dirname } = require("path");
32
- let current = startDir;
33
- while (true) {
34
- if (existsSync(join(current, ".letagents.json")))
35
- return current;
36
- const parent = dirname(current);
37
- if (parent === current)
38
- break;
39
- current = parent;
40
- }
41
- return null;
42
- }
43
- // ---------------------------------------------------------------------------
44
- // Helpers for tests
45
- // ---------------------------------------------------------------------------
46
- function makeTempGitRepo() {
47
- const dir = join(tmpdir(), `letagents-test-${Date.now()}`);
48
- mkdirSync(dir, { recursive: true });
49
- execSync("git init", { cwd: dir, stdio: "pipe" });
50
- execSync("git commit --allow-empty -m init", { cwd: dir, stdio: "pipe" });
51
- return dir;
52
- }
53
- function cleanup(dir) {
54
- try {
55
- rmSync(dir, { recursive: true, force: true });
56
- }
57
- catch { /* ignore */ }
58
- }
59
- // ---------------------------------------------------------------------------
60
- // resolveGitRoot tests
61
- // ---------------------------------------------------------------------------
62
- describe("resolveGitRoot", () => {
63
- let repoDir;
64
- beforeAll(() => { repoDir = makeTempGitRepo(); });
65
- afterAll(() => cleanup(repoDir));
66
- it("returns the repo root when called from repo root", () => {
67
- const result = resolveGitRoot(repoDir);
68
- expect(result).toBe(resolve(repoDir));
69
- });
70
- it("returns the repo root when called from a subdirectory", () => {
71
- const subDir = join(repoDir, "src", "deep", "path");
72
- mkdirSync(subDir, { recursive: true });
73
- const result = resolveGitRoot(subDir);
74
- expect(result).toBe(resolve(repoDir));
75
- });
76
- it("returns null when not inside a git repo", () => {
77
- const nonRepoDir = join(tmpdir(), `no-git-${Date.now()}`);
78
- mkdirSync(nonRepoDir, { recursive: true });
79
- const result = resolveGitRoot(nonRepoDir);
80
- cleanup(nonRepoDir);
81
- expect(result).toBeNull();
82
- });
83
- it("returns null for a non-existent directory", () => {
84
- const result = resolveGitRoot(join(tmpdir(), "does-not-exist-12345"));
85
- expect(result).toBeNull();
86
- });
87
- });
88
- // ---------------------------------------------------------------------------
89
- // findExistingConfig tests
90
- // ---------------------------------------------------------------------------
91
- describe("findExistingConfig", () => {
92
- let tempDir;
93
- beforeEach(() => {
94
- tempDir = join(tmpdir(), `letagents-cfg-test-${Date.now()}`);
95
- mkdirSync(tempDir, { recursive: true });
96
- });
97
- afterEach(() => cleanup(tempDir));
98
- it("returns null when no .letagents.json exists anywhere", () => {
99
- const subDir = join(tempDir, "a", "b", "c");
100
- mkdirSync(subDir, { recursive: true });
101
- expect(findExistingConfig(subDir)).toBeNull();
102
- });
103
- it("finds config in the start directory", () => {
104
- writeFileSync(join(tempDir, ".letagents.json"), JSON.stringify({ room: "test" }));
105
- expect(findExistingConfig(tempDir)).toBe(tempDir);
106
- });
107
- it("finds config in a parent directory when called from subdirectory", () => {
108
- const subDir = join(tempDir, "nested", "path");
109
- mkdirSync(subDir, { recursive: true });
110
- writeFileSync(join(tempDir, ".letagents.json"), JSON.stringify({ room: "test" }));
111
- expect(findExistingConfig(subDir)).toBe(tempDir);
112
- });
113
- it("returns the closest config when multiple exist in the tree", () => {
114
- const subDir = join(tempDir, "nested");
115
- mkdirSync(subDir, { recursive: true });
116
- // Config at root and at nested level — should find nested first
117
- writeFileSync(join(tempDir, ".letagents.json"), JSON.stringify({ room: "root" }));
118
- writeFileSync(join(subDir, ".letagents.json"), JSON.stringify({ room: "nested" }));
119
- expect(findExistingConfig(subDir)).toBe(subDir);
120
- });
121
- });
@@ -1,49 +0,0 @@
1
- const MAX_REASONING_TEXT_LENGTH = 280;
2
- function normalizeReasoningText(value) {
3
- const normalized = String(value ?? "")
4
- .replace(/\s+/g, " ")
5
- .trim();
6
- if (!normalized) {
7
- return null;
8
- }
9
- return normalized.slice(0, MAX_REASONING_TEXT_LENGTH);
10
- }
11
- function normalizeReasoningConfidence(value) {
12
- if (value === undefined || value === null || value === "") {
13
- return null;
14
- }
15
- const numeric = typeof value === "number" ? value : Number(value);
16
- if (!Number.isFinite(numeric)) {
17
- return null;
18
- }
19
- return Math.min(1, Math.max(0, Math.round(numeric * 100) / 100));
20
- }
21
- export function normalizeAgentReasoningTrace(value) {
22
- if (!value || typeof value !== "object") {
23
- return null;
24
- }
25
- const record = value;
26
- const goal = normalizeReasoningText(record.goal);
27
- const hypothesis = normalizeReasoningText(record.hypothesis);
28
- const checking = normalizeReasoningText(record.checking);
29
- const nextAction = normalizeReasoningText(record.next_action);
30
- const blocker = normalizeReasoningText(record.blocker);
31
- const summary = normalizeReasoningText(record.summary)
32
- || goal
33
- || nextAction
34
- || checking
35
- || hypothesis
36
- || blocker;
37
- if (!summary) {
38
- return null;
39
- }
40
- return {
41
- summary,
42
- goal,
43
- hypothesis,
44
- checking,
45
- next_action: nextAction,
46
- blocker,
47
- confidence: normalizeReasoningConfidence(record.confidence),
48
- };
49
- }
File without changes