@letta-ai/letta-code 0.30.13 → 0.30.14

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 (58) hide show
  1. package/dist/channels-slack.js +106 -26
  2. package/dist/channels-slack.js.map +5 -4
  3. package/dist/gateway-core.js +12 -2
  4. package/dist/gateway-core.js.map +3 -3
  5. package/dist/mcp-client.js +2 -2
  6. package/dist/mcp-client.js.map +1 -1
  7. package/dist/types/channels/message-channel-executor.d.ts +4 -0
  8. package/dist/types/channels/message-channel-executor.d.ts.map +1 -1
  9. package/dist/types/channels/slack/bot-policy.d.ts +25 -0
  10. package/dist/types/channels/slack/bot-policy.d.ts.map +1 -0
  11. package/dist/types/channels/slack/ingress-policy.d.ts +32 -1
  12. package/dist/types/channels/slack/ingress-policy.d.ts.map +1 -1
  13. package/dist/types/channels-slack.d.ts +3 -2
  14. package/dist/types/channels-slack.d.ts.map +1 -1
  15. package/dist/types/gateway-core.d.ts +1 -1
  16. package/dist/types/gateway-core.d.ts.map +1 -1
  17. package/dist/types/permissions/analyzer.d.ts.map +1 -1
  18. package/dist/types/permissions/canonical.d.ts +1 -0
  19. package/dist/types/permissions/canonical.d.ts.map +1 -1
  20. package/dist/types/permissions/checker.d.ts.map +1 -1
  21. package/dist/types/tools/impl/bash.d.ts +7 -0
  22. package/dist/types/tools/impl/bash.d.ts.map +1 -1
  23. package/dist/types/tools/impl/enter-worktree.d.ts +16 -1
  24. package/dist/types/tools/impl/enter-worktree.d.ts.map +1 -1
  25. package/dist/types/tools/impl/exit-worktree.d.ts +21 -0
  26. package/dist/types/tools/impl/exit-worktree.d.ts.map +1 -0
  27. package/dist/types/tools/impl/kill-bash.d.ts.map +1 -1
  28. package/dist/types/tools/impl/monitor-event-stream.d.ts +23 -0
  29. package/dist/types/tools/impl/monitor-event-stream.d.ts.map +1 -0
  30. package/dist/types/tools/impl/monitor.d.ts +30 -0
  31. package/dist/types/tools/impl/monitor.d.ts.map +1 -0
  32. package/dist/types/tools/impl/process_manager.d.ts +8 -0
  33. package/dist/types/tools/impl/process_manager.d.ts.map +1 -1
  34. package/dist/types/tools/impl/shell-runner.d.ts +1 -0
  35. package/dist/types/tools/impl/shell-runner.d.ts.map +1 -1
  36. package/dist/types/tools/impl/worktree-git.d.ts +26 -0
  37. package/dist/types/tools/impl/worktree-git.d.ts.map +1 -0
  38. package/dist/types/tools/manager.d.ts.map +1 -1
  39. package/dist/types/tools/tool-definitions.d.ts +2 -0
  40. package/dist/types/tools/tool-definitions.d.ts.map +1 -1
  41. package/dist/types/tools/tool-permissions.d.ts +7 -0
  42. package/dist/types/tools/tool-permissions.d.ts.map +1 -0
  43. package/dist/types/types/background-process-protocol.d.ts +29 -0
  44. package/dist/types/types/background-process-protocol.d.ts.map +1 -0
  45. package/dist/types/types/protocol_v2.d.ts +2 -19
  46. package/dist/types/types/protocol_v2.d.ts.map +1 -1
  47. package/dist/types/utils/task-notifications.d.ts +5 -0
  48. package/dist/types/utils/task-notifications.d.ts.map +1 -1
  49. package/dist/types/websocket/listener/background-process-snapshot.d.ts.map +1 -1
  50. package/dist/types/websocket/listener/types.d.ts +2 -0
  51. package/dist/types/websocket/listener/types.d.ts.map +1 -1
  52. package/letta.js +3682 -2358
  53. package/package.json +1 -1
  54. package/scripts/isolated-unit-tests.json +5 -0
  55. package/scripts/run-unit-tests.cjs +83 -2
  56. package/scripts/source-file-size-baseline.json +3 -4
  57. package/scripts/unit-test-impact.cjs +578 -0
  58. package/scripts/unit-test-impact.test.cjs +328 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letta-ai/letta-code",
3
- "version": "0.30.13",
3
+ "version": "0.30.14",
4
4
  "description": "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
5
5
  "type": "module",
6
6
  "packageManager": "bun@1.3.0",
@@ -1,5 +1,10 @@
1
1
  {
2
2
  "tests": [
3
+ {
4
+ "path": "scripts/unit-test-impact.test.cjs",
5
+ "timeoutMs": 15000,
6
+ "reason": "Adding this test to the shared Bun batch shifted existing batch boundaries and exposed package-installer module-mock leakage; run it separately."
7
+ },
3
8
  {
4
9
  "path": "src/channels/discord-reconcile.test.ts",
5
10
  "timeoutMs": 15000,
@@ -2,6 +2,12 @@
2
2
  const { execFileSync } = require("node:child_process");
3
3
  const { readFileSync, readdirSync } = require("node:fs");
4
4
  const path = require("node:path");
5
+ const {
6
+ buildFamilyImpactIndex,
7
+ getGitChangedFiles,
8
+ planUnitTests,
9
+ readPullRequestShas,
10
+ } = require("./unit-test-impact.cjs");
5
11
 
6
12
  // Unit test directories — bun discovers *.test.ts / *.test.tsx within each.
7
13
  // Listed explicitly so we skip src/integration-tests (API-gated).
@@ -68,6 +74,7 @@ const allTestFiles = [
68
74
  ...dirs.flatMap((dir) => findTestFiles(dir)),
69
75
  ...findTestFiles("src/channels"),
70
76
  ...findRootTestFiles("src"),
77
+ "scripts/unit-test-impact.test.cjs",
71
78
  ].sort();
72
79
  const discoveredPaths = new Set(allTestFiles);
73
80
 
@@ -112,12 +119,86 @@ function chunkByCommandLength(files, maxChars = 20000) {
112
119
  return chunks;
113
120
  }
114
121
 
122
+ function readSelectionShas() {
123
+ const baseIndex = process.argv.indexOf("--base");
124
+ const headIndex = process.argv.indexOf("--head");
125
+ if (baseIndex !== -1 || headIndex !== -1) {
126
+ if (baseIndex === -1 || headIndex === -1) {
127
+ throw new Error("Both --base and --head are required");
128
+ }
129
+ const baseSha = process.argv[baseIndex + 1];
130
+ const headSha = process.argv[headIndex + 1];
131
+ if (!baseSha || !headSha) {
132
+ throw new Error("Both --base and --head are required");
133
+ }
134
+ return { baseSha, headSha };
135
+ }
136
+
137
+ if (process.env.GITHUB_EVENT_NAME !== "pull_request") {
138
+ return null;
139
+ }
140
+ if (!process.env.GITHUB_EVENT_PATH) {
141
+ throw new Error("GITHUB_EVENT_PATH is required for pull request selection");
142
+ }
143
+ return readPullRequestShas(process.env.GITHUB_EVENT_PATH);
144
+ }
145
+
146
+ function selectTestFiles() {
147
+ let shas;
148
+ try {
149
+ shas = readSelectionShas();
150
+ } catch (error) {
151
+ console.warn(
152
+ `unit-test impact: running all tests because selection setup failed: ${error.message}`,
153
+ );
154
+ return allTestFiles;
155
+ }
156
+
157
+ if (!shas) {
158
+ console.log(
159
+ `unit-test impact: running all ${allTestFiles.length} tests outside a pull request`,
160
+ );
161
+ return allTestFiles;
162
+ }
163
+
164
+ try {
165
+ const plan = planUnitTests({
166
+ changedFiles: getGitChangedFiles(shas.baseSha, shas.headSha),
167
+ allTestFiles,
168
+ impactIndex: buildFamilyImpactIndex(),
169
+ });
170
+ console.log(
171
+ `unit-test impact: ${plan.selectedTests.length}/${allTestFiles.length} tests (${plan.reason})`,
172
+ );
173
+ for (const selection of plan.selectedFamilies) {
174
+ const shownReasons = selection.reasons.slice(0, 3);
175
+ const hiddenReasonCount = selection.reasons.length - shownReasons.length;
176
+ const suffix =
177
+ hiddenReasonCount > 0 ? `; +${hiddenReasonCount} more` : "";
178
+ console.log(` ${selection.family}: ${shownReasons.join("; ")}${suffix}`);
179
+ }
180
+ if (plan.omittedTests.length > 0) {
181
+ console.log(` omitted: ${plan.omittedTests.length} unrelated tests`);
182
+ }
183
+ return plan.selectedTests;
184
+ } catch (error) {
185
+ console.warn(
186
+ `unit-test impact: running all tests because planning failed: ${error.message}`,
187
+ );
188
+ return allTestFiles;
189
+ }
190
+ }
191
+
115
192
  let exitCode = 0;
193
+ const selectedTestFiles = selectTestFiles();
194
+ const selectedTestPaths = new Set(selectedTestFiles);
116
195
 
117
196
  // Bun module mocks and process-global state are shared within one test process.
118
197
  // Keep the explicitly stateful suites in fresh processes so they cannot poison
119
198
  // the ordinary unit batch or inherit another suite's cwd/env/module registry.
120
- for (const entry of isolatedTests) {
199
+ for (const entry of isolatedTests.filter((entry) =>
200
+ selectedTestPaths.has(entry.path),
201
+ )) {
121
202
  try {
122
203
  runTests([entry.path], entry.timeoutMs, entry.env);
123
204
  } catch (error) {
@@ -125,7 +206,7 @@ for (const entry of isolatedTests) {
125
206
  }
126
207
  }
127
208
 
128
- const sharedProcessTests = allTestFiles.filter(
209
+ const sharedProcessTests = selectedTestFiles.filter(
129
210
  (file) => !isolatedPaths.has(file),
130
211
  );
131
212
 
@@ -30,16 +30,15 @@
30
30
  "src/mods/package-installer.test.ts": 1248,
31
31
  "src/mods/package-installer.ts": 1201,
32
32
  "src/mods/package-registry.ts": 1033,
33
- "src/permissions/checker.ts": 1009,
34
33
  "src/permissions/read-only-shell.test.ts": 1303,
35
34
  "src/permissions/read-only-shell.ts": 2009,
36
35
  "src/providers/chatgpt-usage-service.ts": 1112,
37
36
  "src/settings-manager.test.ts": 1635,
38
37
  "src/settings-manager.ts": 2102,
39
- "src/tools/impl/enter-worktree.ts": 1197,
40
- "src/tools/manager.ts": 3077,
38
+ "src/tools/impl/enter-worktree.ts": 1020,
39
+ "src/tools/manager.ts": 3016,
41
40
  "src/tools/tool-execution-context.test.ts": 1138,
42
- "src/types/protocol_v2.ts": 2911,
41
+ "src/types/protocol_v2.ts": 2889,
43
42
  "src/websocket/listen-client-concurrency.test.ts": 2686,
44
43
  "src/websocket/listen-client-protocol.test.ts": 5820,
45
44
  "src/websocket/listener/commands/memory.ts": 1114,