@copilotkitnext/runtime 0.0.2 → 0.0.4

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 (40) hide show
  1. package/dist/index.js +1 -14
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.mjs +1 -14
  4. package/dist/index.mjs.map +1 -1
  5. package/package.json +4 -4
  6. package/.turbo/turbo-build.log +0 -23
  7. package/.turbo/turbo-check-types.log +0 -4
  8. package/.turbo/turbo-lint.log +0 -56
  9. package/.turbo/turbo-test$colon$coverage.log +0 -149
  10. package/.turbo/turbo-test.log +0 -107
  11. package/src/__tests__/get-runtime-info.test.ts +0 -117
  12. package/src/__tests__/handle-run.test.ts +0 -69
  13. package/src/__tests__/handle-transcribe.test.ts +0 -289
  14. package/src/__tests__/in-process-agent-runner-messages.test.ts +0 -599
  15. package/src/__tests__/in-process-agent-runner.test.ts +0 -726
  16. package/src/__tests__/middleware.test.ts +0 -432
  17. package/src/__tests__/routing.test.ts +0 -257
  18. package/src/endpoint.ts +0 -150
  19. package/src/handler.ts +0 -3
  20. package/src/handlers/get-runtime-info.ts +0 -50
  21. package/src/handlers/handle-connect.ts +0 -144
  22. package/src/handlers/handle-run.ts +0 -156
  23. package/src/handlers/handle-transcribe.ts +0 -126
  24. package/src/index.ts +0 -8
  25. package/src/middleware.ts +0 -232
  26. package/src/runner/__tests__/enterprise-runner.test.ts +0 -992
  27. package/src/runner/__tests__/event-compaction.test.ts +0 -253
  28. package/src/runner/__tests__/in-memory-runner.test.ts +0 -483
  29. package/src/runner/__tests__/sqlite-runner.test.ts +0 -975
  30. package/src/runner/agent-runner.ts +0 -27
  31. package/src/runner/enterprise.ts +0 -653
  32. package/src/runner/event-compaction.ts +0 -250
  33. package/src/runner/in-memory.ts +0 -341
  34. package/src/runner/index.ts +0 -0
  35. package/src/runner/sqlite.ts +0 -481
  36. package/src/runtime.ts +0 -53
  37. package/src/transcription-service/transcription-service-openai.ts +0 -29
  38. package/src/transcription-service/transcription-service.ts +0 -11
  39. package/tsconfig.json +0 -13
  40. package/tsup.config.ts +0 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copilotkitnext/runtime",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Server-side runtime package for CopilotKit2",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,8 +24,8 @@
24
24
  "tsup": "^8.5.0",
25
25
  "typescript": "5.8.2",
26
26
  "vitest": "^3.0.5",
27
- "@copilotkitnext/eslint-config": "0.0.0",
28
- "@copilotkitnext/typescript-config": "0.0.0"
27
+ "@copilotkitnext/typescript-config": "0.0.0",
28
+ "@copilotkitnext/eslint-config": "0.0.0"
29
29
  },
30
30
  "dependencies": {
31
31
  "@ag-ui/client": "0.0.36-alpha.1",
@@ -35,7 +35,7 @@
35
35
  "ioredis": "^5.7.0",
36
36
  "kysely": "^0.28.5",
37
37
  "rxjs": "7.8.1",
38
- "@copilotkitnext/shared": "0.0.2"
38
+ "@copilotkitnext/shared": "0.0.4"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "better-sqlite3": "^12.2.0",
@@ -1,23 +0,0 @@
1
-
2
- 
3
- > @copilotkitnext/runtime@0.0.1 build /Users/mme/Code/vnext_experimental/packages/runtime
4
- > tsup
5
-
6
- CLI Building entry: src/index.ts
7
- CLI Using tsconfig: tsconfig.json
8
- CLI tsup v8.5.0
9
- CLI Using tsup config: /Users/mme/Code/vnext_experimental/packages/runtime/tsup.config.ts
10
- CLI Target: es2022
11
- CLI Cleaning output folder
12
- CJS Build start
13
- ESM Build start
14
- ESM dist/index.mjs 56.01 KB
15
- ESM dist/index.mjs.map 117.94 KB
16
- ESM ⚡️ Build success in 18ms
17
- CJS dist/index.js 58.53 KB
18
- CJS dist/index.js.map 118.22 KB
19
- CJS ⚡️ Build success in 18ms
20
- DTS Build start
21
- DTS ⚡️ Build success in 1717ms
22
- DTS dist/index.d.ts 7.96 KB
23
- DTS dist/index.d.mts 7.96 KB
@@ -1,4 +0,0 @@
1
-
2
- > @copilotkit/runtime@0.0.0 check-types /Users/mme/Code/CopilotKit2/packages/runtime
3
- > tsc --noEmit
4
-
@@ -1,56 +0,0 @@
1
-
2
- > @copilotkit/runtime@0.0.0 lint /Users/mme/Code/CopilotKit2/packages/runtime
3
- > eslint . --max-warnings 0
4
-
5
-
6
- /Users/mme/Code/CopilotKit2/packages/runtime/src/__tests__/in-process-agent-runner-messages.test.ts
7
- 35:17 warning 'input' is defined but never used @typescript-eslint/no-unused-vars
8
- 46:5 warning Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 3 characters or longer @typescript-eslint/ban-ts-comment
9
-
10
- /Users/mme/Code/CopilotKit2/packages/runtime/src/runner/__tests__/event-compaction.test.ts
11
- 21:29 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
12
- 41:29 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
13
- 45:29 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
14
- 47:29 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
15
- 66:29 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
16
- 68:29 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
17
- 72:29 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
18
- 74:29 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
19
- 90:29 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
20
- 117:29 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
21
- 137:31 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
22
- 157:31 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
23
- 161:31 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
24
- 163:31 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
25
- 182:31 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
26
- 184:31 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
27
- 188:31 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
28
- 190:31 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
29
- 206:31 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
30
- 221:31 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
31
- 244:31 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
32
- 249:31 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
33
-
34
- /Users/mme/Code/CopilotKit2/packages/runtime/src/runner/event-compaction.ts
35
- 129:19 warning 'messageId' is assigned a value but never used @typescript-eslint/no-unused-vars
36
- 140:21 warning 'toolCallId' is assigned a value but never used @typescript-eslint/no-unused-vars
37
-
38
- /Users/mme/Code/CopilotKit2/packages/runtime/src/runner/in-memory.ts
39
- 8:10 warning 'EMPTY' is defined but never used @typescript-eslint/no-unused-vars
40
- 99:31 warning 'args' is defined but never used @typescript-eslint/no-unused-vars
41
- 121:16 warning 'error' is defined but never used @typescript-eslint/no-unused-vars
42
-
43
- /Users/mme/Code/CopilotKit2/packages/runtime/src/runner/sqlite.ts
44
- 8:10 warning 'EMPTY' is defined but never used @typescript-eslint/no-unused-vars
45
- 60:15 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
46
- 68:41 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
47
- 71:24 warning A `require()` style import is forbidden @typescript-eslint/no-require-imports
48
- 73:14 warning 'e' is defined but never used @typescript-eslint/no-unused-vars
49
- 164:50 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
50
- 232:31 warning 'args' is defined but never used @typescript-eslint/no-unused-vars
51
- 254:16 warning 'error' is defined but never used @typescript-eslint/no-unused-vars
52
-
53
- ✖ 37 problems (0 errors, 37 warnings)
54
-
55
- ESLint found too many warnings (maximum: 0).
56
-  ELIFECYCLE  Command failed with exit code 1.
@@ -1,149 +0,0 @@
1
-
2
- 
3
- > @copilotkit/runtime@0.0.0 test:coverage /Users/mme/Code/CopilotKit2/packages/runtime
4
- > jest --coverage
5
-
6
- Determining test suites to run...
7
-
8
-
9
-  RUNS  src/__tests__/endpoint.test.ts
10
-
11
-  RUNS  src/__tests__/endpoint.test.ts
12
-
13
-  RUNS  src/__tests__/endpoint.test.ts
14
-
15
-  RUNS  src/__tests__/endpoint.test.ts
16
-
17
-  RUNS  src/__tests__/endpoint.test.ts
18
-
19
-  RUNS  src/__tests__/endpoint.test.ts
20
-
21
-  RUNS  src/__tests__/endpoint.test.ts
22
-
23
-  RUNS  src/__tests__/endpoint.test.ts
24
-
25
-  RUNS  src/__tests__/endpoint.test.ts
26
-
27
-  RUNS  src/__tests__/endpoint.test.ts
28
-
29
-  RUNS  src/__tests__/endpoint.test.ts
30
-
31
-  RUNS  src/__tests__/endpoint.test.ts
32
-
33
-  RUNS  src/__tests__/endpoint.test.ts
34
-
35
-  RUNS  src/__tests__/endpoint.test.ts
36
-
37
-  RUNS  src/__tests__/endpoint.test.ts
38
-
39
-  RUNS  src/__tests__/endpoint.test.ts
40
-
41
-  RUNS  src/__tests__/endpoint.test.ts
42
-
43
-  RUNS  src/__tests__/endpoint.test.ts
44
-
45
-  RUNS  src/__tests__/endpoint.test.ts
46
-
47
-  RUNS  src/__tests__/endpoint.test.ts
48
-
49
-  RUNS  src/__tests__/endpoint.test.ts
50
-
51
-
52
-  RUNS  src/__tests__/endpoint.test.ts
53
-
54
-
55
-  RUNS  src/__tests__/endpoint.test.ts
56
-
57
-
58
-  RUNS  src/__tests__/endpoint.test.ts
59
-
60
-
61
-  RUNS  src/__tests__/endpoint.test.ts
62
-
63
-
64
-  RUNS  src/__tests__/endpoint.test.ts
65
-
66
-
67
-  RUNS  src/__tests__/endpoint.test.ts
68
-
69
-
70
-  RUNS  src/__tests__/endpoint.test.ts
71
-
72
-
73
-  RUNS  src/__tests__/endpoint.test.ts
74
-
75
-
76
-  RUNS  src/__tests__/endpoint.test.ts
77
-
78
-
79
-  RUNS  src/__tests__/endpoint.test.ts
80
-
81
-
82
-  RUNS  src/__tests__/endpoint.test.ts
83
-
84
-
85
-  RUNS  src/__tests__/endpoint.test.ts
86
-
87
-
88
-  RUNS  src/__tests__/endpoint.test.ts
89
-
90
-
91
-  RUNS  src/__tests__/endpoint.test.ts
92
-
93
-
94
-  RUNS  src/__tests__/endpoint.test.ts
95
-
96
-
97
-  RUNS  src/__tests__/endpoint.test.ts
98
-
99
-
100
-  RUNS  src/__tests__/endpoint.test.ts
101
-
102
-
103
-  RUNS  src/__tests__/endpoint.test.ts
104
-
105
-
106
-  RUNS  src/__tests__/endpoint.test.ts
107
-
108
-
109
-  RUNS  src/__tests__/endpoint.test.ts
110
-
111
-
112
-  RUNS  src/__tests__/endpoint.test.ts
113
-
114
-
115
-  RUNS  src/__tests__/endpoint.test.ts
116
-
117
-
118
-  RUNS  src/__tests__/endpoint.test.ts
119
-
120
-
121
-  RUNS  src/__tests__/endpoint.test.ts
122
-
123
-
124
-  RUNS  src/__tests__/endpoint.test.ts
125
-
126
-
127
-  RUNS  src/__tests__/endpoint.test.ts
128
-
129
-
130
-  RUNS  src/__tests__/endpoint.test.ts
131
-
132
- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
133
- ----------------|---------|----------|---------|---------|-------------------
134
- All files  |  43.47 |  52.17 |  15.38 |  43.47 |  
135
-  src  |  46.42 |  57.14 |  22.22 |  46.42 |  
136
-  endpoint.ts  |  38.63 |  36.36 |  14.28 |  38.63 | 10-40,85-131 
137
-  handler.ts  |  100 |  100 |  100 |  100 |  
138
-  logger.ts  |  100 |  75 |  100 |  100 | 12-16 
139
-  runtime.ts  |  50 |  100 |  0 |  50 | 44-46 
140
-  src/handlers  |  30.76 |  0 |  0 |  30.76 |  
141
-  get-agents.ts |  12.5 |  0 |  0 |  12.5 | 10-34 
142
-  get-info.ts  |  66.66 |  100 |  0 |  66.66 | 10 
143
-  handle-run.ts |  50 |  100 |  0 |  50 | 14 
144
- ----------------|---------|----------|---------|---------|-------------------
145
- Test Suites: 1 passed, 1 total
146
- Tests: 20 passed, 20 total
147
- Snapshots: 0 total
148
- Time: 0.556 s, estimated 1 s
149
- Ran all test suites.
@@ -1,107 +0,0 @@
1
-
2
- > @copilotkitnext/runtime@0.0.0 test /Users/mme/Code/CopilotKit2/packages/runtime
3
- > vitest run
4
-
5
-
6
- RUN v3.2.4 /Users/mme/Code/CopilotKit2/packages/runtime
7
-
8
- ✓ src/__tests__/handle-transcribe.test.ts (12 tests) 36ms
9
- stderr | src/__tests__/handle-run.test.ts > handleRunAgent > should return 500 when runtime.agents throws an error
10
- Error running agent: Error: Database connection failed
11
- at /Users/mme/Code/CopilotKit2/packages/runtime/src/__tests__/handle-run.test.ts:46:30
12
- at file:///Users/mme/Code/CopilotKit2/node_modules/.pnpm/@vitest+runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.js:155:11
13
- at file:///Users/mme/Code/CopilotKit2/node_modules/.pnpm/@vitest+runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.js:752:26
14
- at file:///Users/mme/Code/CopilotKit2/node_modules/.pnpm/@vitest+runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.js:1897:20
15
- at new Promise (<anonymous>)
16
- at runWithTimeout (file:///Users/mme/Code/CopilotKit2/node_modules/.pnpm/@vitest+runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.js:1863:10)
17
- at runTest (file:///Users/mme/Code/CopilotKit2/node_modules/.pnpm/@vitest+runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.js:1574:12)
18
-  at processTicksAndRejections (node:internal/process/task_queues:95:5)
19
- at runSuite (file:///Users/mme/Code/CopilotKit2/node_modules/.pnpm/@vitest+runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.js:1729:8)
20
- at runSuite (file:///Users/mme/Code/CopilotKit2/node_modules/.pnpm/@vitest+runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.js:1729:8)
21
- Error stack: Error: Database connection failed
22
- at /Users/mme/Code/CopilotKit2/packages/runtime/src/__tests__/handle-run.test.ts:46:30
23
- at file:///Users/mme/Code/CopilotKit2/node_modules/.pnpm/@vitest+runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.js:155:11
24
- at file:///Users/mme/Code/CopilotKit2/node_modules/.pnpm/@vitest+runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.js:752:26
25
- at file:///Users/mme/Code/CopilotKit2/node_modules/.pnpm/@vitest+runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.js:1897:20
26
- at new Promise (<anonymous>)
27
- at runWithTimeout (file:///Users/mme/Code/CopilotKit2/node_modules/.pnpm/@vitest+runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.js:1863:10)
28
- at runTest (file:///Users/mme/Code/CopilotKit2/node_modules/.pnpm/@vitest+runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.js:1574:12)
29
- at processTicksAndRejections (node:internal/process/task_queues:95:5)
30
- at runSuite (file:///Users/mme/Code/CopilotKit2/node_modules/.pnpm/@vitest+runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.js:1729:8)
31
- at runSuite (file:///Users/mme/Code/CopilotKit2/node_modules/.pnpm/@vitest+runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.js:1729:8)
32
- Error details: {
33
- name: 'Error',
34
- message: 'Database connection failed',
35
- cause: undefined
36
- }
37
-
38
- ✓ src/runner/__tests__/in-memory-runner.test.ts (7 tests) 8ms
39
- ✓ src/__tests__/in-process-agent-runner-messages.test.ts (7 tests) 8ms
40
- ✓ src/__tests__/handle-run.test.ts (2 tests) 16ms
41
- ✓ src/__tests__/routing.test.ts (21 tests) 39ms
42
- ✓ src/runner/__tests__/sqlite-runner.test.ts (19 tests) 201ms
43
- ✓ src/__tests__/in-process-agent-runner.test.ts (18 tests) 749ms
44
- ✓ src/runner/__tests__/event-compaction.test.ts (12 tests) 28ms
45
- ✓ src/__tests__/get-runtime-info.test.ts (4 tests) 8ms
46
- stderr | src/__tests__/middleware.test.ts > CopilotEndpoint middleware > handles webhook middleware timeout
47
- {
48
- err: Response {
49
- status: 502,
50
- statusText: '',
51
- headers: Headers {},
52
- body: null,
53
- bodyUsed: false,
54
- ok: false,
55
- redirected: false,
56
- type: 'default',
57
- url: ''
58
- },
59
- url: 'https://example.com/info',
60
- path: '/info'
61
- } Error running before request middleware
62
-
63
- stderr | src/__tests__/middleware.test.ts > CopilotEndpoint middleware > handles webhook middleware error responses
64
- {
65
- err: Response {
66
- status: 400,
67
- statusText: '',
68
- headers: Headers { 'content-type': 'text/plain;charset=UTF-8' },
69
- body: ReadableStream { locked: false, state: 'readable', supportsBYOB: true },
70
- bodyUsed: false,
71
- ok: false,
72
- redirected: false,
73
- type: 'default',
74
- url: ''
75
- },
76
- url: 'https://example.com/info',
77
- path: '/info'
78
- } Error running before request middleware
79
-
80
- stderr | src/__tests__/middleware.test.ts > CopilotEndpoint middleware > handles webhook middleware server error
81
- {
82
- err: Response {
83
- status: 502,
84
- statusText: '',
85
- headers: Headers {},
86
- body: null,
87
- bodyUsed: false,
88
- ok: false,
89
- redirected: false,
90
- type: 'default',
91
- url: ''
92
- },
93
- url: 'https://example.com/info',
94
- path: '/info'
95
- } Error running before request middleware
96
-
97
- ✓ src/__tests__/middleware.test.ts (11 tests) 2378ms
98
- ✓ CopilotEndpoint middleware > handles webhook middleware timeout 2003ms
99
- ✓ src/runner/__tests__/enterprise-runner.test.ts (20 tests) 3206ms
100
- ✓ EnterpriseAgentRunner > should prevent concurrent runs on same thread 630ms
101
- ✓ EnterpriseAgentRunner > should track running state correctly 303ms
102
-
103
- Test Files 11 passed (11)
104
- Tests 133 passed (133)
105
- Start at 10:38:14
106
- Duration 4.92s (transform 1.12s, setup 0ms, collect 6.01s, tests 6.68s, environment 1ms, prepare 2.04s)
107
-
@@ -1,117 +0,0 @@
1
- import { handleGetRuntimeInfo } from "../handlers/get-runtime-info";
2
- import { CopilotRuntime } from "../runtime";
3
- import { TranscriptionService } from "../transcription-service/transcription-service";
4
- import { describe, it, expect } from "vitest";
5
- import type { AbstractAgent } from "@ag-ui/client";
6
-
7
- // Mock transcription service
8
- class MockTranscriptionService extends TranscriptionService {
9
- async transcribeFile(): Promise<string> {
10
- return "Mock transcription result";
11
- }
12
- }
13
-
14
- describe("handleGetRuntimeInfo", () => {
15
- const mockRequest = new Request("https://example.com/info");
16
-
17
- it("should return runtime info with audioFileTranscriptionEnabled=false when no transcription service", async () => {
18
- const runtime = new CopilotRuntime({
19
- agents: {},
20
- // No transcriptionService provided
21
- });
22
-
23
- const response = await handleGetRuntimeInfo({
24
- runtime,
25
- request: mockRequest,
26
- });
27
-
28
- expect(response.status).toBe(200);
29
-
30
- const data = await response.json();
31
- expect(data).toEqual({
32
- version: expect.any(String),
33
- agents: {},
34
- audioFileTranscriptionEnabled: false,
35
- });
36
- });
37
-
38
- it("should return runtime info with audioFileTranscriptionEnabled=true when transcription service is configured", async () => {
39
- const mockTranscriptionService = new MockTranscriptionService();
40
- const runtime = new CopilotRuntime({
41
- agents: {},
42
- transcriptionService: mockTranscriptionService,
43
- });
44
-
45
- const response = await handleGetRuntimeInfo({
46
- runtime,
47
- request: mockRequest,
48
- });
49
-
50
- expect(response.status).toBe(200);
51
-
52
- const data = await response.json();
53
- expect(data).toEqual({
54
- version: expect.any(String),
55
- agents: {},
56
- audioFileTranscriptionEnabled: true,
57
- });
58
- });
59
-
60
- it("should include agents information along with audioFileTranscriptionEnabled", async () => {
61
- const mockAgent = {
62
- description: "Test agent description",
63
- constructor: { name: "TestAgent" },
64
- };
65
-
66
- const runtime = new CopilotRuntime({
67
- agents: {
68
- testAgent: mockAgent as AbstractAgent,
69
- },
70
- transcriptionService: new MockTranscriptionService(),
71
- });
72
-
73
- const response = await handleGetRuntimeInfo({
74
- runtime,
75
- request: mockRequest,
76
- });
77
-
78
- expect(response.status).toBe(200);
79
-
80
- const data = await response.json();
81
- expect(data).toEqual({
82
- version: expect.any(String),
83
- agents: {
84
- testAgent: {
85
- name: "testAgent",
86
- description: "Test agent description",
87
- className: "TestAgent",
88
- },
89
- },
90
- audioFileTranscriptionEnabled: true,
91
- });
92
- });
93
-
94
- it("should return 500 error when runtime.agents throws an error", async () => {
95
- const runtime = {
96
- get agents(): Record<string, AbstractAgent> {
97
- throw new Error("Failed to get agents");
98
- },
99
- transcriptionService: undefined,
100
- beforeRequestMiddleware: undefined,
101
- afterRequestMiddleware: undefined,
102
- } as CopilotRuntime;
103
-
104
- const response = await handleGetRuntimeInfo({
105
- runtime,
106
- request: mockRequest,
107
- });
108
-
109
- expect(response.status).toBe(500);
110
-
111
- const data = await response.json();
112
- expect(data).toEqual({
113
- error: "Failed to retrieve runtime information",
114
- message: "Failed to get agents",
115
- });
116
- });
117
- });
@@ -1,69 +0,0 @@
1
- import { handleRunAgent } from "../handlers/handle-run";
2
- import { CopilotRuntime } from "../runtime";
3
- import { describe, it, expect } from "vitest";
4
-
5
- describe("handleRunAgent", () => {
6
- const createMockRuntime = (
7
- agents: Record<string, unknown> = {}
8
- ): CopilotRuntime => {
9
- return {
10
- agents: Promise.resolve(agents),
11
- transcriptionService: undefined,
12
- beforeRequestMiddleware: undefined,
13
- afterRequestMiddleware: undefined,
14
- } as CopilotRuntime;
15
- };
16
-
17
- const createMockRequest = (): Request => {
18
- return new Request("https://example.com/agent/test/run", {
19
- method: "POST",
20
- });
21
- };
22
-
23
- it("should return 404 when agent does not exist", async () => {
24
- const runtime = createMockRuntime({}); // Empty agents
25
- const request = createMockRequest();
26
- const agentId = "nonexistent-agent";
27
-
28
- const response = await handleRunAgent({
29
- runtime,
30
- request,
31
- agentId,
32
- });
33
-
34
- expect(response.status).toBe(404);
35
- expect(response.headers.get("Content-Type")).toBe("application/json");
36
-
37
- const body = await response.json();
38
- expect(body).toEqual({
39
- error: "Agent not found",
40
- message: "Agent 'nonexistent-agent' does not exist",
41
- });
42
- });
43
-
44
- it("should return 500 when runtime.agents throws an error", async () => {
45
- const runtime = {
46
- agents: Promise.reject(new Error("Database connection failed")),
47
- transcriptionService: undefined,
48
- beforeRequestMiddleware: undefined,
49
- afterRequestMiddleware: undefined,
50
- } as CopilotRuntime;
51
- const request = createMockRequest();
52
- const agentId = "test-agent";
53
-
54
- const response = await handleRunAgent({
55
- runtime,
56
- request,
57
- agentId,
58
- });
59
-
60
- expect(response.status).toBe(500);
61
- expect(response.headers.get("Content-Type")).toBe("application/json");
62
-
63
- const body = await response.json();
64
- expect(body).toEqual({
65
- error: "Failed to run agent",
66
- message: "Database connection failed",
67
- });
68
- });
69
- });