@agi-cli/server 0.1.80 → 0.1.82

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agi-cli/server",
3
- "version": "0.1.80",
3
+ "version": "0.1.82",
4
4
  "description": "HTTP API server for AGI CLI",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -29,8 +29,8 @@
29
29
  "typecheck": "tsc --noEmit"
30
30
  },
31
31
  "dependencies": {
32
- "@agi-cli/sdk": "0.1.80",
33
- "@agi-cli/database": "0.1.80",
32
+ "@agi-cli/sdk": "0.1.82",
33
+ "@agi-cli/database": "0.1.82",
34
34
  "drizzle-orm": "^0.44.5",
35
35
  "hono": "^4.9.9",
36
36
  "zod": "^4.1.8"
package/src/index.ts CHANGED
@@ -7,8 +7,9 @@ import { registerSessionsRoutes } from './routes/sessions.ts';
7
7
  import { registerSessionMessagesRoutes } from './routes/session-messages.ts';
8
8
  import { registerSessionStreamRoute } from './routes/session-stream.ts';
9
9
  import { registerAskRoutes } from './routes/ask.ts';
10
- import { registerConfigRoutes } from './routes/config.ts';
11
- import { registerGitRoutes } from './routes/git.ts';
10
+ import { registerConfigRoutes } from './routes/config/index.ts';
11
+ import { registerFilesRoutes } from './routes/files.ts';
12
+ import { registerGitRoutes } from './routes/git/index.ts';
12
13
  import type { AgentConfigEntry } from './runtime/agent-registry.ts';
13
14
 
14
15
  function initApp() {
@@ -52,6 +53,7 @@ function initApp() {
52
53
  registerSessionStreamRoute(app);
53
54
  registerAskRoutes(app);
54
55
  registerConfigRoutes(app);
56
+ registerFilesRoutes(app);
55
57
  registerGitRoutes(app);
56
58
 
57
59
  return app;
@@ -115,6 +117,7 @@ export function createStandaloneApp(_config?: StandaloneAppConfig) {
115
117
  registerSessionStreamRoute(honoApp);
116
118
  registerAskRoutes(honoApp);
117
119
  registerConfigRoutes(honoApp);
120
+ registerFilesRoutes(honoApp);
118
121
  registerGitRoutes(honoApp);
119
122
 
120
123
  return honoApp;
@@ -206,6 +209,7 @@ export function createEmbeddedApp(config: EmbeddedAppConfig = {}) {
206
209
  registerSessionStreamRoute(honoApp);
207
210
  registerAskRoutes(honoApp);
208
211
  registerConfigRoutes(honoApp);
212
+ registerFilesRoutes(honoApp);
209
213
  registerGitRoutes(honoApp);
210
214
 
211
215
  return honoApp;
@@ -0,0 +1,64 @@
1
+ export function projectQueryParam() {
2
+ return {
3
+ in: 'query',
4
+ name: 'project',
5
+ required: false,
6
+ schema: { type: 'string' },
7
+ description:
8
+ 'Project root override (defaults to current working directory).',
9
+ } as const;
10
+ }
11
+
12
+ export function sessionIdParam() {
13
+ return {
14
+ in: 'path',
15
+ name: 'id',
16
+ required: true,
17
+ schema: { type: 'string' },
18
+ } as const;
19
+ }
20
+
21
+ export function withoutParam() {
22
+ return {
23
+ in: 'query',
24
+ name: 'without',
25
+ required: false,
26
+ schema: { type: 'string', enum: ['parts'] },
27
+ description:
28
+ 'Exclude parts from the response. By default, parts are included.',
29
+ } as const;
30
+ }
31
+
32
+ export function errorResponse() {
33
+ return {
34
+ description: 'Bad Request',
35
+ content: {
36
+ 'application/json': {
37
+ schema: {
38
+ type: 'object',
39
+ properties: { error: { type: 'string' } },
40
+ required: ['error'],
41
+ },
42
+ },
43
+ },
44
+ } as const;
45
+ }
46
+
47
+ export function gitErrorResponse() {
48
+ return {
49
+ description: 'Error',
50
+ content: {
51
+ 'application/json': {
52
+ schema: {
53
+ type: 'object',
54
+ properties: {
55
+ status: { type: 'string', enum: ['error'] },
56
+ error: { type: 'string' },
57
+ code: { type: 'string' },
58
+ },
59
+ required: ['status', 'error'],
60
+ },
61
+ },
62
+ },
63
+ } as const;
64
+ }
@@ -0,0 +1,70 @@
1
+ import { errorResponse, projectQueryParam } from '../helpers';
2
+
3
+ export const askPaths = {
4
+ '/v1/ask': {
5
+ post: {
6
+ tags: ['ask'],
7
+ operationId: 'ask',
8
+ summary: 'Send a prompt using the ask service',
9
+ description:
10
+ 'Streamlined endpoint used by the CLI to send prompts and receive assistant responses. Creates sessions as needed and reuses the last session when requested.',
11
+ parameters: [projectQueryParam()],
12
+ requestBody: {
13
+ required: true,
14
+ content: {
15
+ 'application/json': {
16
+ schema: {
17
+ type: 'object',
18
+ required: ['prompt'],
19
+ properties: {
20
+ prompt: {
21
+ type: 'string',
22
+ description: 'User prompt to send to the assistant.',
23
+ },
24
+ agent: {
25
+ type: 'string',
26
+ description: 'Optional agent name to use for this request.',
27
+ },
28
+ provider: {
29
+ $ref: '#/components/schemas/Provider',
30
+ description:
31
+ 'Optional provider override. When omitted the agent and config defaults apply.',
32
+ },
33
+ model: {
34
+ type: 'string',
35
+ description:
36
+ 'Optional model override for the selected provider.',
37
+ },
38
+ sessionId: {
39
+ type: 'string',
40
+ description: 'Send the prompt to a specific session.',
41
+ },
42
+ last: {
43
+ type: 'boolean',
44
+ description:
45
+ 'If true, reuse the most recent session for the project.',
46
+ },
47
+ jsonMode: {
48
+ type: 'boolean',
49
+ description:
50
+ 'Request structured JSON output when supported by the agent.',
51
+ },
52
+ },
53
+ },
54
+ },
55
+ },
56
+ },
57
+ responses: {
58
+ 202: {
59
+ description: 'Accepted',
60
+ content: {
61
+ 'application/json': {
62
+ schema: { $ref: '#/components/schemas/AskResponse' },
63
+ },
64
+ },
65
+ },
66
+ 400: errorResponse(),
67
+ },
68
+ },
69
+ },
70
+ } as const;
@@ -0,0 +1,164 @@
1
+ import { projectQueryParam } from '../helpers';
2
+
3
+ export const configPaths = {
4
+ '/v1/config': {
5
+ get: {
6
+ tags: ['config'],
7
+ operationId: 'getConfig',
8
+ summary: 'Get full configuration',
9
+ description: 'Returns agents, authorized providers, models, and defaults',
10
+ parameters: [projectQueryParam()],
11
+ responses: {
12
+ 200: {
13
+ description: 'OK',
14
+ content: {
15
+ 'application/json': {
16
+ schema: { $ref: '#/components/schemas/Config' },
17
+ },
18
+ },
19
+ },
20
+ },
21
+ },
22
+ },
23
+ '/v1/config/cwd': {
24
+ get: {
25
+ tags: ['config'],
26
+ operationId: 'getCwd',
27
+ summary: 'Get current working directory info',
28
+ responses: {
29
+ 200: {
30
+ description: 'OK',
31
+ content: {
32
+ 'application/json': {
33
+ schema: {
34
+ type: 'object',
35
+ properties: {
36
+ cwd: { type: 'string' },
37
+ dirName: { type: 'string' },
38
+ },
39
+ required: ['cwd', 'dirName'],
40
+ },
41
+ },
42
+ },
43
+ },
44
+ },
45
+ },
46
+ },
47
+ '/v1/config/agents': {
48
+ get: {
49
+ tags: ['config'],
50
+ operationId: 'getAgents',
51
+ summary: 'Get available agents',
52
+ parameters: [projectQueryParam()],
53
+ responses: {
54
+ 200: {
55
+ description: 'OK',
56
+ content: {
57
+ 'application/json': {
58
+ schema: {
59
+ type: 'object',
60
+ properties: {
61
+ agents: {
62
+ type: 'array',
63
+ items: { type: 'string' },
64
+ },
65
+ default: { type: 'string' },
66
+ },
67
+ required: ['agents', 'default'],
68
+ },
69
+ },
70
+ },
71
+ },
72
+ },
73
+ },
74
+ },
75
+ '/v1/config/providers': {
76
+ get: {
77
+ tags: ['config'],
78
+ operationId: 'getProviders',
79
+ summary: 'Get available providers',
80
+ description: 'Returns only providers that have been authorized',
81
+ parameters: [projectQueryParam()],
82
+ responses: {
83
+ 200: {
84
+ description: 'OK',
85
+ content: {
86
+ 'application/json': {
87
+ schema: {
88
+ type: 'object',
89
+ properties: {
90
+ providers: {
91
+ type: 'array',
92
+ items: { $ref: '#/components/schemas/Provider' },
93
+ },
94
+ default: { $ref: '#/components/schemas/Provider' },
95
+ },
96
+ required: ['providers', 'default'],
97
+ },
98
+ },
99
+ },
100
+ },
101
+ },
102
+ },
103
+ },
104
+ '/v1/config/providers/{provider}/models': {
105
+ get: {
106
+ tags: ['config'],
107
+ operationId: 'getProviderModels',
108
+ summary: 'Get available models for a provider',
109
+ parameters: [
110
+ projectQueryParam(),
111
+ {
112
+ in: 'path',
113
+ name: 'provider',
114
+ required: true,
115
+ schema: { $ref: '#/components/schemas/Provider' },
116
+ },
117
+ ],
118
+ responses: {
119
+ 200: {
120
+ description: 'OK',
121
+ content: {
122
+ 'application/json': {
123
+ schema: {
124
+ type: 'object',
125
+ properties: {
126
+ models: {
127
+ type: 'array',
128
+ items: { $ref: '#/components/schemas/Model' },
129
+ },
130
+ default: { type: 'string', nullable: true },
131
+ },
132
+ required: ['models'],
133
+ },
134
+ },
135
+ },
136
+ },
137
+ 403: {
138
+ description: 'Provider not authorized',
139
+ content: {
140
+ 'application/json': {
141
+ schema: {
142
+ type: 'object',
143
+ properties: { error: { type: 'string' } },
144
+ required: ['error'],
145
+ },
146
+ },
147
+ },
148
+ },
149
+ 404: {
150
+ description: 'Provider not found',
151
+ content: {
152
+ 'application/json': {
153
+ schema: {
154
+ type: 'object',
155
+ properties: { error: { type: 'string' } },
156
+ required: ['error'],
157
+ },
158
+ },
159
+ },
160
+ },
161
+ },
162
+ },
163
+ },
164
+ } as const;
@@ -0,0 +1,72 @@
1
+ import { projectQueryParam } from '../helpers';
2
+
3
+ export const filesPaths = {
4
+ '/v1/files': {
5
+ get: {
6
+ tags: ['files'],
7
+ operationId: 'listFiles',
8
+ summary: 'List project files',
9
+ description:
10
+ 'Returns list of files in the project directory, excluding common build artifacts and dependencies',
11
+ parameters: [
12
+ projectQueryParam(),
13
+ {
14
+ in: 'query',
15
+ name: 'maxDepth',
16
+ required: false,
17
+ schema: { type: 'integer', default: 10 },
18
+ description: 'Maximum directory depth to traverse',
19
+ },
20
+ {
21
+ in: 'query',
22
+ name: 'limit',
23
+ required: false,
24
+ schema: { type: 'integer', default: 1000 },
25
+ description: 'Maximum number of files to return',
26
+ },
27
+ ],
28
+ responses: {
29
+ 200: {
30
+ description: 'OK',
31
+ content: {
32
+ 'application/json': {
33
+ schema: {
34
+ type: 'object',
35
+ properties: {
36
+ files: {
37
+ type: 'array',
38
+ items: { type: 'string' },
39
+ },
40
+ changedFiles: {
41
+ type: 'array',
42
+ items: {
43
+ type: 'object',
44
+ properties: {
45
+ path: { type: 'string' },
46
+ status: {
47
+ type: 'string',
48
+ enum: [
49
+ 'added',
50
+ 'modified',
51
+ 'deleted',
52
+ 'renamed',
53
+ 'untracked',
54
+ ],
55
+ },
56
+ },
57
+ required: ['path', 'status'],
58
+ },
59
+ description:
60
+ 'List of files with uncommitted changes (from git status)',
61
+ },
62
+ truncated: { type: 'boolean' },
63
+ },
64
+ required: ['files', 'changedFiles', 'truncated'],
65
+ },
66
+ },
67
+ },
68
+ },
69
+ },
70
+ },
71
+ },
72
+ } as const;