macro-agent 0.0.13 → 0.0.15

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 (143) hide show
  1. package/.claude/settings.local.json +59 -0
  2. package/dist/agent/agent-manager.d.ts.map +1 -1
  3. package/dist/agent/agent-manager.js +10 -4
  4. package/dist/agent/agent-manager.js.map +1 -1
  5. package/dist/cli/acp.d.ts +6 -0
  6. package/dist/cli/acp.d.ts.map +1 -1
  7. package/dist/cli/acp.js +16 -2
  8. package/dist/cli/acp.js.map +1 -1
  9. package/dist/map/adapter/index.d.ts +1 -1
  10. package/dist/map/adapter/index.d.ts.map +1 -1
  11. package/dist/map/adapter/index.js +1 -1
  12. package/dist/map/adapter/index.js.map +1 -1
  13. package/dist/map/utils/address-translation.d.ts +99 -0
  14. package/dist/map/utils/address-translation.d.ts.map +1 -0
  15. package/dist/map/utils/address-translation.js +285 -0
  16. package/dist/map/utils/address-translation.js.map +1 -0
  17. package/dist/map/utils/index.d.ts +7 -0
  18. package/dist/map/utils/index.d.ts.map +1 -0
  19. package/dist/map/utils/index.js +7 -0
  20. package/dist/map/utils/index.js.map +1 -0
  21. package/dist/server/combined-server.d.ts.map +1 -1
  22. package/dist/server/combined-server.js +8 -1
  23. package/dist/server/combined-server.js.map +1 -1
  24. package/dist/store/event-store.js +9 -2
  25. package/dist/store/event-store.js.map +1 -1
  26. package/dist/store/types/agents.d.ts +2 -0
  27. package/dist/store/types/agents.d.ts.map +1 -1
  28. package/package.json +4 -4
  29. package/references/acp-factory-ref/CHANGELOG.md +33 -0
  30. package/references/acp-factory-ref/LICENSE +21 -0
  31. package/references/acp-factory-ref/README.md +341 -0
  32. package/references/acp-factory-ref/package-lock.json +3102 -0
  33. package/references/acp-factory-ref/package.json +96 -0
  34. package/references/acp-factory-ref/python/CHANGELOG.md +33 -0
  35. package/references/acp-factory-ref/python/LICENSE +21 -0
  36. package/references/acp-factory-ref/python/Makefile +57 -0
  37. package/references/acp-factory-ref/python/README.md +253 -0
  38. package/references/acp-factory-ref/python/pyproject.toml +73 -0
  39. package/references/acp-factory-ref/python/tests/__init__.py +0 -0
  40. package/references/acp-factory-ref/python/tests/e2e/__init__.py +1 -0
  41. package/references/acp-factory-ref/python/tests/e2e/test_codex_e2e.py +349 -0
  42. package/references/acp-factory-ref/python/tests/e2e/test_gemini_e2e.py +165 -0
  43. package/references/acp-factory-ref/python/tests/e2e/test_opencode_e2e.py +296 -0
  44. package/references/acp-factory-ref/python/tests/test_client_handler.py +543 -0
  45. package/references/acp-factory-ref/python/tests/test_pushable.py +199 -0
  46. package/references/claude-code-acp/.github/workflows/ci.yml +45 -0
  47. package/references/claude-code-acp/.github/workflows/publish.yml +34 -0
  48. package/references/claude-code-acp/.prettierrc.json +4 -0
  49. package/references/claude-code-acp/CHANGELOG.md +249 -0
  50. package/references/claude-code-acp/LICENSE +222 -0
  51. package/references/claude-code-acp/README.md +53 -0
  52. package/references/claude-code-acp/docs/RELEASES.md +24 -0
  53. package/references/claude-code-acp/eslint.config.js +48 -0
  54. package/references/claude-code-acp/package-lock.json +4570 -0
  55. package/references/claude-code-acp/package.json +88 -0
  56. package/references/claude-code-acp/scripts/release.sh +119 -0
  57. package/references/claude-code-acp/src/acp-agent.ts +2079 -0
  58. package/references/claude-code-acp/src/index.ts +26 -0
  59. package/references/claude-code-acp/src/lib.ts +38 -0
  60. package/references/claude-code-acp/src/mcp-server.ts +911 -0
  61. package/references/claude-code-acp/src/settings.ts +522 -0
  62. package/references/claude-code-acp/src/tests/.claude/commands/quick-math.md +5 -0
  63. package/references/claude-code-acp/src/tests/.claude/commands/say-hello.md +6 -0
  64. package/references/claude-code-acp/src/tests/acp-agent-fork.test.ts +479 -0
  65. package/references/claude-code-acp/src/tests/acp-agent.test.ts +1502 -0
  66. package/references/claude-code-acp/src/tests/extract-lines.test.ts +103 -0
  67. package/references/claude-code-acp/src/tests/fork-session.test.ts +335 -0
  68. package/references/claude-code-acp/src/tests/replace-and-calculate-location.test.ts +334 -0
  69. package/references/claude-code-acp/src/tests/settings.test.ts +617 -0
  70. package/references/claude-code-acp/src/tests/skills-options.test.ts +187 -0
  71. package/references/claude-code-acp/src/tests/tools.test.ts +318 -0
  72. package/references/claude-code-acp/src/tests/typescript-declarations.test.ts +558 -0
  73. package/references/claude-code-acp/src/tools.ts +819 -0
  74. package/references/claude-code-acp/src/utils.ts +171 -0
  75. package/references/claude-code-acp/tsconfig.json +18 -0
  76. package/references/claude-code-acp/vitest.config.ts +19 -0
  77. package/references/multi-agent-protocol/.sudocode/issues.jsonl +111 -0
  78. package/references/multi-agent-protocol/.sudocode/specs.jsonl +13 -0
  79. package/references/multi-agent-protocol/LICENSE +21 -0
  80. package/references/multi-agent-protocol/README.md +113 -0
  81. package/references/multi-agent-protocol/docs/00-design-specification.md +496 -0
  82. package/references/multi-agent-protocol/docs/01-open-questions.md +1050 -0
  83. package/references/multi-agent-protocol/docs/02-wire-protocol.md +296 -0
  84. package/references/multi-agent-protocol/docs/03-streaming-semantics.md +252 -0
  85. package/references/multi-agent-protocol/docs/04-error-handling.md +231 -0
  86. package/references/multi-agent-protocol/docs/05-connection-model.md +244 -0
  87. package/references/multi-agent-protocol/docs/06-visibility-permissions.md +243 -0
  88. package/references/multi-agent-protocol/docs/07-federation.md +259 -0
  89. package/references/multi-agent-protocol/docs/08-macro-agent-migration.md +253 -0
  90. package/references/multi-agent-protocol/docs/09-authentication.md +680 -0
  91. package/references/multi-agent-protocol/docs/10-mail-protocol.md +553 -0
  92. package/references/multi-agent-protocol/docs/agent-iam-integration.md +877 -0
  93. package/references/multi-agent-protocol/docs/agentic-mesh-integration-draft.md +459 -0
  94. package/references/multi-agent-protocol/docs/git-transport-draft.md +251 -0
  95. package/references/multi-agent-protocol/docs-site/Gemfile +22 -0
  96. package/references/multi-agent-protocol/docs-site/README.md +82 -0
  97. package/references/multi-agent-protocol/docs-site/_config.yml +91 -0
  98. package/references/multi-agent-protocol/docs-site/_includes/head_custom.html +20 -0
  99. package/references/multi-agent-protocol/docs-site/_sass/color_schemes/map.scss +42 -0
  100. package/references/multi-agent-protocol/docs-site/_sass/custom/custom.scss +34 -0
  101. package/references/multi-agent-protocol/docs-site/examples/full-integration.md +510 -0
  102. package/references/multi-agent-protocol/docs-site/examples/index.md +138 -0
  103. package/references/multi-agent-protocol/docs-site/examples/simple-chat.md +282 -0
  104. package/references/multi-agent-protocol/docs-site/examples/task-queue.md +399 -0
  105. package/references/multi-agent-protocol/docs-site/getting-started/index.md +98 -0
  106. package/references/multi-agent-protocol/docs-site/getting-started/installation.md +219 -0
  107. package/references/multi-agent-protocol/docs-site/getting-started/overview.md +172 -0
  108. package/references/multi-agent-protocol/docs-site/getting-started/quickstart.md +237 -0
  109. package/references/multi-agent-protocol/docs-site/index.md +136 -0
  110. package/references/multi-agent-protocol/docs-site/protocol/authentication.md +391 -0
  111. package/references/multi-agent-protocol/docs-site/protocol/connection-model.md +376 -0
  112. package/references/multi-agent-protocol/docs-site/protocol/design.md +284 -0
  113. package/references/multi-agent-protocol/docs-site/protocol/error-handling.md +312 -0
  114. package/references/multi-agent-protocol/docs-site/protocol/federation.md +449 -0
  115. package/references/multi-agent-protocol/docs-site/protocol/index.md +129 -0
  116. package/references/multi-agent-protocol/docs-site/protocol/permissions.md +398 -0
  117. package/references/multi-agent-protocol/docs-site/protocol/streaming.md +353 -0
  118. package/references/multi-agent-protocol/docs-site/protocol/wire-protocol.md +369 -0
  119. package/references/multi-agent-protocol/docs-site/sdk/api/agent.md +357 -0
  120. package/references/multi-agent-protocol/docs-site/sdk/api/client.md +380 -0
  121. package/references/multi-agent-protocol/docs-site/sdk/api/index.md +62 -0
  122. package/references/multi-agent-protocol/docs-site/sdk/api/server.md +453 -0
  123. package/references/multi-agent-protocol/docs-site/sdk/api/types.md +468 -0
  124. package/references/multi-agent-protocol/docs-site/sdk/guides/agent.md +375 -0
  125. package/references/multi-agent-protocol/docs-site/sdk/guides/authentication.md +405 -0
  126. package/references/multi-agent-protocol/docs-site/sdk/guides/client.md +352 -0
  127. package/references/multi-agent-protocol/docs-site/sdk/guides/index.md +89 -0
  128. package/references/multi-agent-protocol/docs-site/sdk/guides/server.md +360 -0
  129. package/references/multi-agent-protocol/docs-site/sdk/guides/testing.md +446 -0
  130. package/references/multi-agent-protocol/docs-site/sdk/guides/transports.md +363 -0
  131. package/references/multi-agent-protocol/docs-site/sdk/index.md +206 -0
  132. package/references/multi-agent-protocol/package-lock.json +3886 -0
  133. package/references/multi-agent-protocol/package.json +56 -0
  134. package/references/multi-agent-protocol/schema/meta.json +467 -0
  135. package/references/multi-agent-protocol/schema/schema.json +2558 -0
  136. package/src/agent/__tests__/agent-manager.test.ts +67 -1
  137. package/src/agent/agent-manager.ts +10 -4
  138. package/src/cli/__tests__/stable-instance-id.test.ts +57 -0
  139. package/src/cli/acp.ts +17 -2
  140. package/src/map/adapter/index.ts +3 -0
  141. package/src/server/combined-server.ts +10 -0
  142. package/src/store/event-store.ts +10 -3
  143. package/src/store/types/agents.ts +2 -0
@@ -0,0 +1,558 @@
1
+ import { describe, it, expect, beforeAll, afterAll, beforeEach, afterEach } from "vitest";
2
+ import * as fs from "node:fs";
3
+ import * as path from "node:path";
4
+ import * as os from "node:os";
5
+ import { spawnSync } from "child_process";
6
+
7
+ describe.skipIf(!process.env.RUN_INTEGRATION_TESTS)(
8
+ "TypeScript declaration files integration",
9
+ () => {
10
+ let tempDir: string;
11
+ let tarballPath: string;
12
+ const projectRoot = path.resolve(__dirname, "../..");
13
+
14
+ // Base configuration templates
15
+ const basePackageJson = {
16
+ name: "ts-declaration-test",
17
+ version: "1.0.0",
18
+ type: "module",
19
+ dependencies: {},
20
+ devDependencies: {
21
+ typescript: "5.9.3",
22
+ "@types/node": "25.0.3",
23
+ },
24
+ };
25
+
26
+ const baseTsConfig = {
27
+ compilerOptions: {
28
+ target: "ES2020",
29
+ module: "NodeNext",
30
+ moduleResolution: "NodeNext",
31
+ lib: ["ES2020"],
32
+ strict: true,
33
+ esModuleInterop: true,
34
+ skipLibCheck: true, // Skip checking dependency internals, focus on our types
35
+ noEmit: true,
36
+ declaration: false,
37
+ },
38
+ include: ["*.ts"],
39
+ };
40
+
41
+ // Build and pack the package once for all tests
42
+ beforeAll(async () => {
43
+ // Step 1: Clean dist folder to ensure fresh build
44
+ const distPath = path.join(projectRoot, "dist");
45
+ await fs.promises.rm(distPath, { recursive: true, force: true });
46
+ console.log("Cleaned dist folder");
47
+
48
+ console.log("Building package...");
49
+
50
+ // Step 2: Build the package
51
+ const buildResult = spawnSync("npm", ["run", "build"], {
52
+ cwd: projectRoot,
53
+ stdio: "pipe",
54
+ encoding: "utf-8",
55
+ });
56
+
57
+ if (buildResult.status !== 0) {
58
+ throw new Error(`Build failed: ${buildResult.stderr || buildResult.stdout}`);
59
+ }
60
+
61
+ console.log("Packing package...");
62
+
63
+ // Step 3: Pack to create tarball
64
+ const packResult = spawnSync("npm", ["pack", "--pack-destination", os.tmpdir()], {
65
+ cwd: projectRoot,
66
+ stdio: "pipe",
67
+ encoding: "utf-8",
68
+ });
69
+
70
+ if (packResult.status !== 0) {
71
+ throw new Error(`Pack failed: ${packResult.stderr || packResult.stdout}`);
72
+ }
73
+
74
+ // Get the tarball filename from stdout (npm pack outputs the filename)
75
+ const tarballName = packResult.stdout.trim().split("\n").pop();
76
+ if (!tarballName) {
77
+ throw new Error("Failed to get tarball name from npm pack output");
78
+ }
79
+ tarballPath = path.join(os.tmpdir(), tarballName);
80
+
81
+ console.log(`Tarball created at: ${tarballPath}`);
82
+ }, 60000); // 60 second timeout for build
83
+
84
+ // Clean up the tarball after all tests
85
+ afterAll(async () => {
86
+ if (tarballPath && fs.existsSync(tarballPath)) {
87
+ await fs.promises.unlink(tarballPath);
88
+ console.log("Cleaned up tarball");
89
+ }
90
+ });
91
+
92
+ // Create fresh temp directory for each test
93
+ beforeEach(async () => {
94
+ tempDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "ts-declaration-test-"));
95
+ });
96
+
97
+ // Clean up temp directory after each test
98
+ afterEach(async () => {
99
+ if (tempDir) {
100
+ await fs.promises.rm(tempDir, { recursive: true, force: true });
101
+ }
102
+ });
103
+
104
+ // Helper function to set up a test TypeScript project
105
+ async function setupTestProject(
106
+ packageJson: object = basePackageJson,
107
+ tsconfig: object = baseTsConfig,
108
+ ): Promise<void> {
109
+ // Write package.json
110
+ await fs.promises.writeFile(
111
+ path.join(tempDir, "package.json"),
112
+ JSON.stringify(packageJson, null, 2),
113
+ );
114
+
115
+ // Write tsconfig.json
116
+ await fs.promises.writeFile(
117
+ path.join(tempDir, "tsconfig.json"),
118
+ JSON.stringify(tsconfig, null, 2),
119
+ );
120
+
121
+ // Install all dependencies (TypeScript, @types/node, and the tarball)
122
+ console.log(`Installing dependencies in ${tempDir}...`);
123
+ const installResult = spawnSync("npm", ["install", tarballPath], {
124
+ cwd: tempDir,
125
+ stdio: "pipe",
126
+ encoding: "utf-8",
127
+ timeout: 60000, // 60 second timeout
128
+ });
129
+
130
+ if (installResult.status !== 0) {
131
+ throw new Error(`npm install failed: ${installResult.stderr || installResult.stdout}`);
132
+ }
133
+ }
134
+
135
+ // Helper function to run TypeScript type checking
136
+ function runTypeCheck(srcDir: string = tempDir): {
137
+ success: boolean;
138
+ output: string;
139
+ } {
140
+ const result = spawnSync("npx", ["tsc", "--noEmit"], {
141
+ cwd: srcDir,
142
+ stdio: "pipe",
143
+ encoding: "utf-8",
144
+ timeout: 30000, // 30 second timeout
145
+ });
146
+
147
+ return {
148
+ success: result.status === 0,
149
+ output: result.stdout + result.stderr,
150
+ };
151
+ }
152
+
153
+ // Helper function to write a test TypeScript file
154
+ async function writeTestFile(filename: string, content: string): Promise<void> {
155
+ await fs.promises.writeFile(path.join(tempDir, filename), content);
156
+ }
157
+
158
+ // Test 1: Main exports import verification
159
+ it("should successfully type-check main exports", async () => {
160
+ await setupTestProject();
161
+
162
+ await writeTestFile(
163
+ "test-main-exports.ts",
164
+ `
165
+ import {
166
+ ClaudeAcpAgent,
167
+ runAcp,
168
+ toAcpNotifications,
169
+ streamEventToAcpNotifications,
170
+ SettingsManager,
171
+ createMcpServer,
172
+ loadManagedSettings,
173
+ applyEnvironmentSettings,
174
+ nodeToWebReadable,
175
+ nodeToWebWritable,
176
+ Pushable,
177
+ unreachable,
178
+ toolInfoFromToolUse,
179
+ planEntries,
180
+ toolUpdateFromToolResult,
181
+ createPreToolUseHook,
182
+ toolNames,
183
+ } from "@sudocode-ai/claude-code-acp";
184
+
185
+ // Type-only imports
186
+ import type {
187
+ ToolUpdateMeta,
188
+ NewSessionMeta,
189
+ ClaudeCodeSettings,
190
+ PermissionSettings,
191
+ PermissionDecision,
192
+ PermissionCheckResult,
193
+ SettingsManagerOptions,
194
+ ClaudePlanEntry,
195
+ } from "@sudocode-ai/claude-code-acp";
196
+
197
+ // Verify exports exist and have expected types
198
+ const _runAcp: typeof runAcp = runAcp;
199
+ const _createMcpServer: typeof createMcpServer = createMcpServer;
200
+ const _toolNames: typeof toolNames = toolNames;
201
+ `,
202
+ );
203
+
204
+ const result = runTypeCheck();
205
+ if (!result.success) {
206
+ console.error("TypeScript errors:", result.output);
207
+ }
208
+ expect(result.success).toBe(true);
209
+ }, 120000);
210
+
211
+ // Test 2: Deep imports verification (backwards compatibility)
212
+ it("should successfully type-check deep imports", async () => {
213
+ await setupTestProject();
214
+
215
+ await writeTestFile(
216
+ "test-deep-imports.ts",
217
+ `
218
+ // Deep import from dist/tools.js
219
+ import {
220
+ acpToolNames,
221
+ EDIT_TOOL_NAMES,
222
+ ACP_TOOL_NAME_PREFIX,
223
+ toolInfoFromToolUse,
224
+ planEntries,
225
+ } from "@sudocode-ai/claude-code-acp/dist/tools.js";
226
+
227
+ // Deep import from dist/settings.js
228
+ import {
229
+ SettingsManager,
230
+ getManagedSettingsPath,
231
+ } from "@sudocode-ai/claude-code-acp/dist/settings.js";
232
+
233
+ // Deep import from dist/utils.js
234
+ import {
235
+ Pushable,
236
+ nodeToWebReadable,
237
+ nodeToWebWritable,
238
+ loadManagedSettings,
239
+ } from "@sudocode-ai/claude-code-acp/dist/utils.js";
240
+
241
+ // Verify types work
242
+ const prefix: string = ACP_TOOL_NAME_PREFIX;
243
+ const editTools: readonly string[] = EDIT_TOOL_NAMES;
244
+ `,
245
+ );
246
+
247
+ const result = runTypeCheck();
248
+ if (!result.success) {
249
+ console.error("TypeScript errors:", result.output);
250
+ }
251
+ expect(result.success).toBe(true);
252
+ }, 120000);
253
+
254
+ // Test 3: SettingsManager type shape verification
255
+ it("should verify SettingsManager has correct type shape", async () => {
256
+ await setupTestProject();
257
+
258
+ await writeTestFile(
259
+ "test-settings-manager.ts",
260
+ `
261
+ import {
262
+ SettingsManager,
263
+ ClaudeCodeSettings,
264
+ PermissionCheckResult,
265
+ SettingsManagerOptions
266
+ } from "@sudocode-ai/claude-code-acp";
267
+
268
+ // Test constructor signature
269
+ const options: SettingsManagerOptions = {
270
+ onChange: () => {},
271
+ logger: { log: console.log, error: console.error },
272
+ };
273
+ declare const cwd: string;
274
+ const manager = new SettingsManager(cwd, options);
275
+
276
+ // Test method signatures
277
+ async function testMethods() {
278
+ // initialize returns Promise<void>
279
+ await manager.initialize();
280
+
281
+ // checkPermission returns PermissionCheckResult
282
+ const result: PermissionCheckResult = manager.checkPermission(
283
+ "mcp__acp__Read",
284
+ { file_path: "/some/path" }
285
+ );
286
+
287
+ // Verify decision type
288
+ const decision: "allow" | "deny" | "ask" = result.decision;
289
+ const rule: string | undefined = result.rule;
290
+ const source: "allow" | "deny" | "ask" | undefined = result.source;
291
+
292
+ // getSettings returns ClaudeCodeSettings
293
+ const settings: ClaudeCodeSettings = manager.getSettings();
294
+
295
+ // getCwd returns string
296
+ const currentCwd: string = manager.getCwd();
297
+
298
+ // setCwd returns Promise<void>
299
+ await manager.setCwd("/new/path");
300
+
301
+ // dispose returns void
302
+ manager.dispose();
303
+ }
304
+ `,
305
+ );
306
+
307
+ const result = runTypeCheck();
308
+ if (!result.success) {
309
+ console.error("TypeScript errors:", result.output);
310
+ }
311
+ expect(result.success).toBe(true);
312
+ }, 120000);
313
+
314
+ // Test 4: ClaudeAcpAgent instantiation and type verification
315
+ it("should verify ClaudeAcpAgent has correct type shape", async () => {
316
+ await setupTestProject();
317
+
318
+ await writeTestFile(
319
+ "test-claude-acp-agent.ts",
320
+ `
321
+ import { ClaudeAcpAgent } from "@sudocode-ai/claude-code-acp";
322
+ import type { AgentSideConnection } from "@agentclientprotocol/sdk";
323
+
324
+ // ClaudeAcpAgent should be a class that can be instantiated
325
+ declare const mockConnection: AgentSideConnection;
326
+ declare const mockLogger: { log: (...args: any[]) => void; error: (...args: any[]) => void };
327
+
328
+ // Test constructor - accepts AgentSideConnection and optional logger
329
+ const agent = new ClaudeAcpAgent(mockConnection, mockLogger);
330
+
331
+ // Verify it has sessions property
332
+ const sessions: Record<string, any> = agent.sessions;
333
+
334
+ // Verify it has client property
335
+ const client: AgentSideConnection = agent.client;
336
+
337
+ // Verify it has logger property
338
+ const logger = agent.logger;
339
+ `,
340
+ );
341
+
342
+ const result = runTypeCheck();
343
+ if (!result.success) {
344
+ console.error("TypeScript errors:", result.output);
345
+ }
346
+ expect(result.success).toBe(true);
347
+ }, 120000);
348
+
349
+ // Test 5: Type-only exports work correctly
350
+ it("should verify type-only exports are usable", async () => {
351
+ await setupTestProject();
352
+
353
+ await writeTestFile(
354
+ "test-type-exports.ts",
355
+ `
356
+ import type {
357
+ ClaudeCodeSettings,
358
+ PermissionSettings,
359
+ PermissionDecision,
360
+ PermissionCheckResult,
361
+ SettingsManagerOptions,
362
+ ClaudePlanEntry,
363
+ ToolUpdateMeta,
364
+ NewSessionMeta,
365
+ } from "@sudocode-ai/claude-code-acp";
366
+
367
+ // Test ClaudeCodeSettings shape
368
+ const settings: ClaudeCodeSettings = {
369
+ permissions: {
370
+ allow: ["Read"],
371
+ deny: ["Read(./.env)"],
372
+ ask: ["Bash"],
373
+ additionalDirectories: ["/extra"],
374
+ defaultMode: "default",
375
+ },
376
+ env: {
377
+ API_KEY: "secret",
378
+ },
379
+ };
380
+
381
+ // Test PermissionSettings shape
382
+ const perms: PermissionSettings = {
383
+ allow: ["Read"],
384
+ deny: ["Write"],
385
+ };
386
+
387
+ // Test PermissionDecision
388
+ const decisions: PermissionDecision[] = ["allow", "deny", "ask"];
389
+
390
+ // Test ClaudePlanEntry shape
391
+ const planEntry: ClaudePlanEntry = {
392
+ content: "Do something",
393
+ status: "pending",
394
+ activeForm: "Doing something",
395
+ };
396
+
397
+ // Test valid status values
398
+ const validStatuses: ClaudePlanEntry["status"][] = [
399
+ "pending",
400
+ "in_progress",
401
+ "completed",
402
+ ];
403
+
404
+ // Test ToolUpdateMeta shape
405
+ const toolMeta: ToolUpdateMeta = {
406
+ claudeCode: {
407
+ toolName: "Read",
408
+ toolResponse: { success: true },
409
+ },
410
+ };
411
+
412
+ // Test NewSessionMeta shape
413
+ const sessionMeta: NewSessionMeta = {
414
+ claudeCode: {
415
+ options: {},
416
+ },
417
+ };
418
+ `,
419
+ );
420
+
421
+ const result = runTypeCheck();
422
+ if (!result.success) {
423
+ console.error("TypeScript errors:", result.output);
424
+ }
425
+ expect(result.success).toBe(true);
426
+ }, 120000);
427
+
428
+ // Test 6: Function signatures verification
429
+ it("should verify function signatures are correct", async () => {
430
+ await setupTestProject();
431
+
432
+ await writeTestFile(
433
+ "test-function-signatures.ts",
434
+ `
435
+ import {
436
+ runAcp,
437
+ createMcpServer,
438
+ toolInfoFromToolUse,
439
+ planEntries,
440
+ createPreToolUseHook,
441
+ loadManagedSettings,
442
+ applyEnvironmentSettings,
443
+ SettingsManager,
444
+ } from "@sudocode-ai/claude-code-acp";
445
+
446
+ import type { ClaudeCodeSettings } from "@sudocode-ai/claude-code-acp";
447
+
448
+ // runAcp should be a function with no parameters that returns void
449
+ const runAcpType: () => void = runAcp;
450
+
451
+ // toolInfoFromToolUse should accept any and return object with title and kind
452
+ const info = toolInfoFromToolUse({ name: "Read", input: {} });
453
+ const title: string = info.title;
454
+ const kind: string = info.kind;
455
+
456
+ // planEntries should accept todos array and return array
457
+ const entries = planEntries({
458
+ todos: [
459
+ { content: "test", status: "pending", activeForm: "testing" }
460
+ ]
461
+ });
462
+ // entries should be an array
463
+ const entriesArray: any[] = entries;
464
+
465
+ // createPreToolUseHook should accept SettingsManager and optional logger
466
+ declare const settingsManager: SettingsManager;
467
+ const hook = createPreToolUseHook(settingsManager, console);
468
+
469
+ // loadManagedSettings should return ClaudeCodeSettings | null
470
+ const managedSettings: ClaudeCodeSettings | null = loadManagedSettings();
471
+
472
+ // applyEnvironmentSettings should accept ClaudeCodeSettings and return void
473
+ const applyResult: void = applyEnvironmentSettings({ permissions: {} });
474
+ `,
475
+ );
476
+
477
+ const result = runTypeCheck();
478
+ if (!result.success) {
479
+ console.error("TypeScript errors:", result.output);
480
+ }
481
+ expect(result.success).toBe(true);
482
+ }, 120000);
483
+
484
+ // Test 7: Pushable generic class verification
485
+ it("should verify Pushable class works correctly", async () => {
486
+ await setupTestProject();
487
+
488
+ await writeTestFile(
489
+ "test-pushable.ts",
490
+ `
491
+ import { Pushable } from "@sudocode-ai/claude-code-acp";
492
+
493
+ // Pushable should be a generic class
494
+ const pushable = new Pushable<string>();
495
+
496
+ // Should have push method
497
+ pushable.push("test");
498
+
499
+ // Should have end method
500
+ pushable.end();
501
+
502
+ // Should implement AsyncIterable
503
+ async function consume() {
504
+ for await (const item of pushable) {
505
+ const str: string = item;
506
+ }
507
+ }
508
+
509
+ // Generic type parameter should work
510
+ const numPushable = new Pushable<number>();
511
+ numPushable.push(42);
512
+
513
+ interface MyType { id: number; name: string; }
514
+ const customPushable = new Pushable<MyType>();
515
+ customPushable.push({ id: 1, name: "test" });
516
+ `,
517
+ );
518
+
519
+ const result = runTypeCheck();
520
+ if (!result.success) {
521
+ console.error("TypeScript errors:", result.output);
522
+ }
523
+ expect(result.success).toBe(true);
524
+ }, 120000);
525
+
526
+ // Test 8: Verify incorrect types fail
527
+ it("should fail type-check with incorrect types", async () => {
528
+ await setupTestProject();
529
+
530
+ await writeTestFile(
531
+ "test-invalid-types.ts",
532
+ `
533
+ import { SettingsManager, ClaudeCodeSettings } from "@sudocode-ai/claude-code-acp";
534
+
535
+ // This should fail - SettingsManager constructor requires string cwd
536
+ // @ts-expect-error - Testing that wrong argument type fails
537
+ const badManager = new SettingsManager(123);
538
+
539
+ // This should fail - ClaudeCodeSettings permissions must be an object
540
+ const badSettings: ClaudeCodeSettings = {
541
+ // @ts-expect-error - Testing that wrong type fails
542
+ permissions: "not-an-object",
543
+ };
544
+ `,
545
+ );
546
+
547
+ // This test should PASS because we expect tsc to catch these errors
548
+ // with @ts-expect-error directives
549
+ const result = runTypeCheck();
550
+ if (!result.success) {
551
+ // If it fails, it means @ts-expect-error didn't catch the error
552
+ // which could mean the types are too permissive
553
+ console.error("TypeScript errors (expected @ts-expect-error to catch):", result.output);
554
+ }
555
+ expect(result.success).toBe(true);
556
+ }, 120000);
557
+ },
558
+ );