@ottocode/server 0.1.260 → 0.1.262
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 +4 -3
- package/src/index.ts +5 -4
- package/src/openapi/register.ts +92 -0
- package/src/openapi/route.ts +22 -0
- package/src/routes/ask.ts +210 -99
- package/src/routes/auth.ts +1701 -626
- package/src/routes/branch.ts +281 -90
- package/src/routes/config/agents.ts +79 -32
- package/src/routes/config/cwd.ts +46 -14
- package/src/routes/config/debug.ts +159 -30
- package/src/routes/config/defaults.ts +182 -64
- package/src/routes/config/main.ts +109 -73
- package/src/routes/config/models.ts +304 -137
- package/src/routes/config/providers.ts +462 -166
- package/src/routes/config/utils.ts +2 -2
- package/src/routes/doctor.ts +395 -161
- package/src/routes/files.ts +650 -260
- package/src/routes/git/branch.ts +143 -52
- package/src/routes/git/commit.ts +347 -141
- package/src/routes/git/diff.ts +239 -116
- package/src/routes/git/init.ts +103 -23
- package/src/routes/git/pull.ts +167 -65
- package/src/routes/git/push.ts +222 -117
- package/src/routes/git/remote.ts +401 -100
- package/src/routes/git/staging.ts +502 -141
- package/src/routes/git/status.ts +171 -78
- package/src/routes/mcp.ts +1129 -404
- package/src/routes/openapi.ts +27 -4
- package/src/routes/ottorouter.ts +1221 -389
- package/src/routes/provider-usage.ts +153 -36
- package/src/routes/research.ts +817 -370
- package/src/routes/root.ts +50 -6
- package/src/routes/session-approval.ts +228 -54
- package/src/routes/session-files.ts +265 -134
- package/src/routes/session-messages.ts +330 -150
- package/src/routes/session-stream.ts +83 -2
- package/src/routes/sessions.ts +1830 -780
- package/src/routes/skills.ts +849 -161
- package/src/routes/terminals.ts +469 -103
- package/src/routes/tunnel.ts +394 -118
- package/src/runtime/ask/service.ts +1 -0
- package/src/runtime/message/compaction-limits.ts +3 -3
- package/src/runtime/provider/reasoning.ts +2 -1
- package/src/runtime/session/db-operations.ts +4 -3
- package/src/runtime/utils/token.ts +7 -2
- package/src/tools/adapter.ts +21 -0
- package/src/openapi/paths/ask.ts +0 -81
- package/src/openapi/paths/auth.ts +0 -687
- package/src/openapi/paths/branch.ts +0 -102
- package/src/openapi/paths/config.ts +0 -485
- package/src/openapi/paths/doctor.ts +0 -165
- package/src/openapi/paths/files.ts +0 -236
- package/src/openapi/paths/git.ts +0 -690
- package/src/openapi/paths/mcp.ts +0 -339
- package/src/openapi/paths/messages.ts +0 -103
- package/src/openapi/paths/ottorouter.ts +0 -594
- package/src/openapi/paths/provider-usage.ts +0 -59
- package/src/openapi/paths/research.ts +0 -227
- package/src/openapi/paths/session-approval.ts +0 -93
- package/src/openapi/paths/session-extras.ts +0 -336
- package/src/openapi/paths/session-files.ts +0 -91
- package/src/openapi/paths/sessions.ts +0 -210
- package/src/openapi/paths/skills.ts +0 -377
- package/src/openapi/paths/stream.ts +0 -26
- package/src/openapi/paths/terminals.ts +0 -226
- package/src/openapi/paths/tunnel.ts +0 -163
- package/src/openapi/spec.ts +0 -73
package/src/routes/root.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
}
|