@ottocode/server 0.1.259 → 0.1.261

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 (69) hide show
  1. package/package.json +4 -3
  2. package/src/index.ts +5 -4
  3. package/src/openapi/register.ts +92 -0
  4. package/src/openapi/route.ts +22 -0
  5. package/src/routes/ask.ts +210 -99
  6. package/src/routes/auth.ts +1701 -626
  7. package/src/routes/branch.ts +281 -90
  8. package/src/routes/config/agents.ts +79 -32
  9. package/src/routes/config/cwd.ts +46 -14
  10. package/src/routes/config/debug.ts +159 -30
  11. package/src/routes/config/defaults.ts +182 -64
  12. package/src/routes/config/main.ts +109 -73
  13. package/src/routes/config/models.ts +304 -137
  14. package/src/routes/config/providers.ts +462 -166
  15. package/src/routes/config/utils.ts +2 -2
  16. package/src/routes/doctor.ts +395 -161
  17. package/src/routes/files.ts +650 -260
  18. package/src/routes/git/branch.ts +143 -52
  19. package/src/routes/git/commit.ts +347 -141
  20. package/src/routes/git/diff.ts +239 -116
  21. package/src/routes/git/init.ts +103 -23
  22. package/src/routes/git/pull.ts +167 -65
  23. package/src/routes/git/push.ts +222 -117
  24. package/src/routes/git/remote.ts +401 -100
  25. package/src/routes/git/staging.ts +502 -141
  26. package/src/routes/git/status.ts +171 -78
  27. package/src/routes/mcp.ts +1129 -404
  28. package/src/routes/openapi.ts +27 -4
  29. package/src/routes/ottorouter.ts +1221 -389
  30. package/src/routes/provider-usage.ts +153 -36
  31. package/src/routes/research.ts +817 -370
  32. package/src/routes/root.ts +50 -6
  33. package/src/routes/session-approval.ts +228 -54
  34. package/src/routes/session-files.ts +265 -134
  35. package/src/routes/session-messages.ts +330 -150
  36. package/src/routes/session-stream.ts +83 -2
  37. package/src/routes/sessions.ts +1830 -780
  38. package/src/routes/skills.ts +849 -161
  39. package/src/routes/terminals.ts +469 -103
  40. package/src/routes/tunnel.ts +394 -118
  41. package/src/runtime/agent/runner-reasoning.ts +38 -3
  42. package/src/runtime/agent/runner.ts +1 -0
  43. package/src/runtime/ask/service.ts +1 -0
  44. package/src/runtime/message/compaction-limits.ts +3 -3
  45. package/src/runtime/provider/reasoning.ts +18 -7
  46. package/src/runtime/session/db-operations.ts +4 -3
  47. package/src/runtime/utils/token.ts +7 -2
  48. package/src/tools/adapter.ts +21 -0
  49. package/src/openapi/paths/ask.ts +0 -81
  50. package/src/openapi/paths/auth.ts +0 -687
  51. package/src/openapi/paths/branch.ts +0 -102
  52. package/src/openapi/paths/config.ts +0 -485
  53. package/src/openapi/paths/doctor.ts +0 -165
  54. package/src/openapi/paths/files.ts +0 -236
  55. package/src/openapi/paths/git.ts +0 -690
  56. package/src/openapi/paths/mcp.ts +0 -339
  57. package/src/openapi/paths/messages.ts +0 -103
  58. package/src/openapi/paths/ottorouter.ts +0 -594
  59. package/src/openapi/paths/provider-usage.ts +0 -59
  60. package/src/openapi/paths/research.ts +0 -227
  61. package/src/openapi/paths/session-approval.ts +0 -93
  62. package/src/openapi/paths/session-extras.ts +0 -336
  63. package/src/openapi/paths/session-files.ts +0 -91
  64. package/src/openapi/paths/sessions.ts +0 -210
  65. package/src/openapi/paths/skills.ts +0 -377
  66. package/src/openapi/paths/stream.ts +0 -26
  67. package/src/openapi/paths/terminals.ts +0 -226
  68. package/src/openapi/paths/tunnel.ts +0 -163
  69. package/src/openapi/spec.ts +0 -73
@@ -1,12 +1,56 @@
1
1
  import type { Hono } from 'hono';
2
2
  import { getServerInfo } from '../state.ts';
3
+ import { openApiRoute } from '../openapi/route.ts';
3
4
 
4
5
  export function registerRootRoutes(app: Hono) {
5
- app.get('/', (c) => c.text('otto server running'));
6
+ openApiRoute(
7
+ app,
8
+ {
9
+ method: 'get',
10
+ path: '/',
11
+ tags: ['server'],
12
+ operationId: 'getRoot',
13
+ summary: 'Server health check',
14
+ responses: {
15
+ '200': {
16
+ description: 'Server is running',
17
+ content: {
18
+ 'text/plain': {
19
+ schema: { type: 'string' },
20
+ },
21
+ },
22
+ },
23
+ },
24
+ },
25
+ (c) => c.text('otto server running'),
26
+ );
6
27
 
7
- app.get('/v1/server/info', (c) => {
8
- return c.json({
9
- ...getServerInfo(),
10
- });
11
- });
28
+ openApiRoute(
29
+ app,
30
+ {
31
+ method: 'get',
32
+ path: '/v1/server/info',
33
+ tags: ['server'],
34
+ operationId: 'getServerInfo',
35
+ summary: 'Get server runtime information',
36
+ responses: {
37
+ '200': {
38
+ description: 'Server runtime metadata',
39
+ content: {
40
+ 'application/json': {
41
+ schema: {
42
+ type: 'object',
43
+ additionalProperties: true,
44
+ },
45
+ },
46
+ },
47
+ },
48
+ },
49
+ },
50
+ (c) => {
51
+ return c.json({
52
+ ...getServerInfo(),
53
+ });
54
+ },
55
+ );
12
56
  }
@@ -4,60 +4,234 @@ import {
4
4
  getPendingApproval,
5
5
  getPendingApprovalsForSession,
6
6
  } from '../runtime/tools/approval.ts';
7
+ import { openApiRoute } from '../openapi/route.ts';
7
8
 
8
9
  export function registerSessionApprovalRoute(app: Hono) {
9
- app.post('/v1/sessions/:id/approval', async (c) => {
10
- const sessionId = c.req.param('id');
11
- const body = await c.req.json<{
12
- callId: string;
13
- approved: boolean;
14
- }>();
15
-
16
- if (!body.callId) {
17
- return c.json({ ok: false, error: 'callId is required' }, 400);
18
- }
19
-
20
- if (typeof body.approved !== 'boolean') {
21
- return c.json({ ok: false, error: 'approved must be a boolean' }, 400);
22
- }
23
-
24
- const pending = getPendingApproval(body.callId);
25
- if (!pending) {
26
- return c.json(
27
- { ok: false, error: 'No pending approval found for this callId' },
28
- 404,
29
- );
30
- }
31
-
32
- if (pending.sessionId !== sessionId) {
33
- return c.json(
34
- { ok: false, error: 'Approval does not belong to this session' },
35
- 403,
36
- );
37
- }
38
-
39
- const result = resolveApproval(body.callId, body.approved);
40
-
41
- if (!result.ok) {
42
- return c.json(result, 404);
43
- }
44
-
45
- return c.json({ ok: true, callId: body.callId, approved: body.approved });
46
- });
47
-
48
- app.get('/v1/sessions/:id/approval/pending', async (c) => {
49
- const sessionId = c.req.param('id');
50
- const pending = getPendingApprovalsForSession(sessionId);
51
-
52
- return c.json({
53
- ok: true,
54
- pending: pending.map((p) => ({
55
- callId: p.callId,
56
- toolName: p.toolName,
57
- args: p.args,
58
- messageId: p.messageId,
59
- createdAt: p.createdAt,
60
- })),
61
- });
62
- });
10
+ openApiRoute(
11
+ app,
12
+ {
13
+ method: 'post',
14
+ path: '/v1/sessions/{id}/approval',
15
+ tags: ['sessions'],
16
+ operationId: 'resolveApproval',
17
+ summary: 'Approve or deny a tool execution',
18
+ parameters: [
19
+ {
20
+ in: 'path',
21
+ name: 'id',
22
+ required: true,
23
+ schema: {
24
+ type: 'string',
25
+ },
26
+ },
27
+ ],
28
+ requestBody: {
29
+ required: true,
30
+ content: {
31
+ 'application/json': {
32
+ schema: {
33
+ type: 'object',
34
+ properties: {
35
+ callId: {
36
+ type: 'string',
37
+ },
38
+ approved: {
39
+ type: 'boolean',
40
+ },
41
+ },
42
+ required: ['callId', 'approved'],
43
+ },
44
+ },
45
+ },
46
+ },
47
+ responses: {
48
+ '200': {
49
+ description: 'OK',
50
+ content: {
51
+ 'application/json': {
52
+ schema: {
53
+ type: 'object',
54
+ properties: {
55
+ ok: {
56
+ type: 'boolean',
57
+ },
58
+ callId: {
59
+ type: 'string',
60
+ },
61
+ approved: {
62
+ type: 'boolean',
63
+ },
64
+ },
65
+ required: ['ok', 'callId', 'approved'],
66
+ },
67
+ },
68
+ },
69
+ },
70
+ '400': {
71
+ description: 'Bad Request',
72
+ content: {
73
+ 'application/json': {
74
+ schema: {
75
+ type: 'object',
76
+ properties: {
77
+ error: {
78
+ type: 'string',
79
+ },
80
+ },
81
+ required: ['error'],
82
+ },
83
+ },
84
+ },
85
+ },
86
+ '403': {
87
+ description: 'Bad Request',
88
+ content: {
89
+ 'application/json': {
90
+ schema: {
91
+ type: 'object',
92
+ properties: {
93
+ error: {
94
+ type: 'string',
95
+ },
96
+ },
97
+ required: ['error'],
98
+ },
99
+ },
100
+ },
101
+ },
102
+ '404': {
103
+ description: 'Bad Request',
104
+ content: {
105
+ 'application/json': {
106
+ schema: {
107
+ type: 'object',
108
+ properties: {
109
+ error: {
110
+ type: 'string',
111
+ },
112
+ },
113
+ required: ['error'],
114
+ },
115
+ },
116
+ },
117
+ },
118
+ },
119
+ },
120
+ async (c) => {
121
+ const sessionId = c.req.param('id');
122
+ const body = await c.req.json<{
123
+ callId: string;
124
+ approved: boolean;
125
+ }>();
126
+
127
+ if (!body.callId) {
128
+ return c.json({ ok: false, error: 'callId is required' }, 400);
129
+ }
130
+
131
+ if (typeof body.approved !== 'boolean') {
132
+ return c.json({ ok: false, error: 'approved must be a boolean' }, 400);
133
+ }
134
+
135
+ const pending = getPendingApproval(body.callId);
136
+ if (!pending) {
137
+ return c.json(
138
+ { ok: false, error: 'No pending approval found for this callId' },
139
+ 404,
140
+ );
141
+ }
142
+
143
+ if (pending.sessionId !== sessionId) {
144
+ return c.json(
145
+ { ok: false, error: 'Approval does not belong to this session' },
146
+ 403,
147
+ );
148
+ }
149
+
150
+ const result = resolveApproval(body.callId, body.approved);
151
+
152
+ if (!result.ok) {
153
+ return c.json(result, 404);
154
+ }
155
+
156
+ return c.json({ ok: true, callId: body.callId, approved: body.approved });
157
+ },
158
+ );
159
+
160
+ openApiRoute(
161
+ app,
162
+ {
163
+ method: 'get',
164
+ path: '/v1/sessions/{id}/approval/pending',
165
+ tags: ['sessions'],
166
+ operationId: 'getPendingApprovals',
167
+ summary: 'Get pending approvals for a session',
168
+ parameters: [
169
+ {
170
+ in: 'path',
171
+ name: 'id',
172
+ required: true,
173
+ schema: {
174
+ type: 'string',
175
+ },
176
+ },
177
+ ],
178
+ responses: {
179
+ '200': {
180
+ description: 'OK',
181
+ content: {
182
+ 'application/json': {
183
+ schema: {
184
+ type: 'object',
185
+ properties: {
186
+ ok: {
187
+ type: 'boolean',
188
+ },
189
+ pending: {
190
+ type: 'array',
191
+ items: {
192
+ type: 'object',
193
+ properties: {
194
+ callId: {
195
+ type: 'string',
196
+ },
197
+ toolName: {
198
+ type: 'string',
199
+ },
200
+ args: {
201
+ type: 'object',
202
+ },
203
+ messageId: {
204
+ type: 'string',
205
+ },
206
+ createdAt: {
207
+ type: 'integer',
208
+ },
209
+ },
210
+ required: ['callId', 'toolName', 'createdAt'],
211
+ },
212
+ },
213
+ },
214
+ required: ['ok', 'pending'],
215
+ },
216
+ },
217
+ },
218
+ },
219
+ },
220
+ },
221
+ async (c) => {
222
+ const sessionId = c.req.param('id');
223
+ const pending = getPendingApprovalsForSession(sessionId);
224
+
225
+ return c.json({
226
+ ok: true,
227
+ pending: pending.map((p) => ({
228
+ callId: p.callId,
229
+ toolName: p.toolName,
230
+ args: p.args,
231
+ messageId: p.messageId,
232
+ createdAt: p.createdAt,
233
+ })),
234
+ });
235
+ },
236
+ );
63
237
  }