@ottocode/server 0.1.265 → 0.1.267
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 +3 -3
- package/src/routes/auth/copilot.ts +699 -0
- package/src/routes/auth/oauth.ts +578 -0
- package/src/routes/auth/onboarding.ts +45 -0
- package/src/routes/auth/providers.ts +189 -0
- package/src/routes/auth/service.ts +167 -0
- package/src/routes/auth/state.ts +23 -0
- package/src/routes/auth/status.ts +203 -0
- package/src/routes/auth/wallet.ts +229 -0
- package/src/routes/auth.ts +12 -2080
- package/src/routes/config/models-service.ts +411 -0
- package/src/routes/config/models.ts +6 -426
- package/src/routes/config/providers-service.ts +237 -0
- package/src/routes/config/providers.ts +10 -242
- package/src/routes/files/handlers.ts +297 -0
- package/src/routes/files/service.ts +313 -0
- package/src/routes/files.ts +12 -608
- package/src/routes/git/commit-service.ts +207 -0
- package/src/routes/git/commit.ts +6 -220
- package/src/routes/git/remote-service.ts +116 -0
- package/src/routes/git/remote.ts +8 -115
- package/src/routes/git/staging-service.ts +111 -0
- package/src/routes/git/staging.ts +10 -205
- package/src/routes/mcp/auth.ts +338 -0
- package/src/routes/mcp/lifecycle.ts +263 -0
- package/src/routes/mcp/servers.ts +212 -0
- package/src/routes/mcp/service.ts +664 -0
- package/src/routes/mcp/state.ts +13 -0
- package/src/routes/mcp.ts +6 -1233
- package/src/routes/ottorouter/billing.ts +593 -0
- package/src/routes/ottorouter/service.ts +92 -0
- package/src/routes/ottorouter/topup.ts +301 -0
- package/src/routes/ottorouter/wallet.ts +370 -0
- package/src/routes/ottorouter.ts +6 -1319
- package/src/routes/research/service.ts +339 -0
- package/src/routes/research.ts +12 -390
- package/src/routes/sessions/crud.ts +563 -0
- package/src/routes/sessions/queue.ts +242 -0
- package/src/routes/sessions/retry.ts +121 -0
- package/src/routes/sessions/service.ts +768 -0
- package/src/routes/sessions/share.ts +434 -0
- package/src/routes/sessions.ts +8 -1977
- package/src/routes/skills/service.ts +221 -0
- package/src/routes/skills/spec.ts +309 -0
- package/src/routes/skills.ts +31 -909
- package/src/routes/terminals/service.ts +326 -0
- package/src/routes/terminals.ts +19 -295
- package/src/routes/tunnel/service.ts +217 -0
- package/src/routes/tunnel.ts +29 -219
- package/src/runtime/agent/registry-prompts.ts +147 -0
- package/src/runtime/agent/registry.ts +6 -124
- package/src/runtime/agent/runner-errors.ts +116 -0
- package/src/runtime/agent/runner-reminders.ts +45 -0
- package/src/runtime/agent/runner-setup-model.ts +75 -0
- package/src/runtime/agent/runner-setup-prompt.ts +185 -0
- package/src/runtime/agent/runner-setup-tools.ts +103 -0
- package/src/runtime/agent/runner-setup-utils.ts +21 -0
- package/src/runtime/agent/runner-setup.ts +54 -288
- package/src/runtime/agent/runner-telemetry.ts +112 -0
- package/src/runtime/agent/runner-text.ts +108 -0
- package/src/runtime/agent/runner-tool-observer.ts +86 -0
- package/src/runtime/agent/runner.ts +79 -378
- package/src/runtime/prompt/builder.ts +5 -1
- package/src/runtime/prompt/capabilities.ts +13 -8
- package/src/runtime/provider/custom.ts +73 -0
- package/src/runtime/provider/index.ts +2 -85
- package/src/runtime/provider/reasoning-builders.ts +280 -0
- package/src/runtime/provider/reasoning.ts +67 -264
- package/src/tools/adapter/events.ts +116 -0
- package/src/tools/adapter/execution.ts +160 -0
- package/src/tools/adapter/pending.ts +37 -0
- package/src/tools/adapter/persistence.ts +166 -0
- package/src/tools/adapter/results.ts +97 -0
- package/src/tools/adapter.ts +124 -451
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import type { Hono } from 'hono';
|
|
2
|
+
import {
|
|
3
|
+
ensureOttoRouterWallet,
|
|
4
|
+
getOttoRouterWallet,
|
|
5
|
+
importWallet,
|
|
6
|
+
setAuth,
|
|
7
|
+
} from '@ottocode/sdk';
|
|
8
|
+
import { logger } from '@ottocode/sdk';
|
|
9
|
+
import { openApiRoute } from '../../openapi/route.ts';
|
|
10
|
+
import { serializeError } from '../../runtime/errors/api-error.ts';
|
|
11
|
+
|
|
12
|
+
export function registerAuthWalletRoutes(app: Hono) {
|
|
13
|
+
openApiRoute(
|
|
14
|
+
app,
|
|
15
|
+
{
|
|
16
|
+
method: 'post',
|
|
17
|
+
path: '/v1/auth/ottorouter/setup',
|
|
18
|
+
tags: ['auth'],
|
|
19
|
+
operationId: 'setupOttoRouterWallet',
|
|
20
|
+
summary: 'Setup or ensure OttoRouter wallet',
|
|
21
|
+
responses: {
|
|
22
|
+
'200': {
|
|
23
|
+
description: 'OK',
|
|
24
|
+
content: {
|
|
25
|
+
'application/json': {
|
|
26
|
+
schema: {
|
|
27
|
+
type: 'object',
|
|
28
|
+
properties: {
|
|
29
|
+
success: {
|
|
30
|
+
type: 'boolean',
|
|
31
|
+
},
|
|
32
|
+
publicKey: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
},
|
|
35
|
+
isNew: {
|
|
36
|
+
type: 'boolean',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
required: ['success', 'publicKey', 'isNew'],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
async (c) => {
|
|
47
|
+
try {
|
|
48
|
+
const projectRoot = process.cwd();
|
|
49
|
+
const existing = await getOttoRouterWallet(projectRoot);
|
|
50
|
+
const wallet = await ensureOttoRouterWallet(projectRoot);
|
|
51
|
+
|
|
52
|
+
return c.json({
|
|
53
|
+
success: true,
|
|
54
|
+
publicKey: wallet.publicKey,
|
|
55
|
+
isNew: !existing,
|
|
56
|
+
});
|
|
57
|
+
} catch (error) {
|
|
58
|
+
logger.error('Failed to setup OttoRouter wallet', error);
|
|
59
|
+
const errorResponse = serializeError(error);
|
|
60
|
+
return c.json(errorResponse, errorResponse.error.status || 500);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
openApiRoute(
|
|
66
|
+
app,
|
|
67
|
+
{
|
|
68
|
+
method: 'post',
|
|
69
|
+
path: '/v1/auth/ottorouter/import',
|
|
70
|
+
tags: ['auth'],
|
|
71
|
+
operationId: 'importOttoRouterWallet',
|
|
72
|
+
summary: 'Import OttoRouter wallet from private key',
|
|
73
|
+
requestBody: {
|
|
74
|
+
required: true,
|
|
75
|
+
content: {
|
|
76
|
+
'application/json': {
|
|
77
|
+
schema: {
|
|
78
|
+
type: 'object',
|
|
79
|
+
properties: {
|
|
80
|
+
privateKey: {
|
|
81
|
+
type: 'string',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
required: ['privateKey'],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
responses: {
|
|
90
|
+
'200': {
|
|
91
|
+
description: 'OK',
|
|
92
|
+
content: {
|
|
93
|
+
'application/json': {
|
|
94
|
+
schema: {
|
|
95
|
+
type: 'object',
|
|
96
|
+
properties: {
|
|
97
|
+
success: {
|
|
98
|
+
type: 'boolean',
|
|
99
|
+
},
|
|
100
|
+
publicKey: {
|
|
101
|
+
type: 'string',
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
required: ['success', 'publicKey'],
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
'400': {
|
|
110
|
+
description: 'Bad Request',
|
|
111
|
+
content: {
|
|
112
|
+
'application/json': {
|
|
113
|
+
schema: {
|
|
114
|
+
type: 'object',
|
|
115
|
+
properties: {
|
|
116
|
+
error: {
|
|
117
|
+
type: 'string',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
required: ['error'],
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
async (c) => {
|
|
128
|
+
try {
|
|
129
|
+
const { privateKey } = await c.req.json<{ privateKey: string }>();
|
|
130
|
+
|
|
131
|
+
if (!privateKey) {
|
|
132
|
+
return c.json({ error: 'Private key required' }, 400);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
const wallet = importWallet(privateKey);
|
|
137
|
+
await setAuth(
|
|
138
|
+
'ottorouter',
|
|
139
|
+
{ type: 'wallet', secret: privateKey },
|
|
140
|
+
undefined,
|
|
141
|
+
'global',
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
return c.json({
|
|
145
|
+
success: true,
|
|
146
|
+
publicKey: wallet.publicKey,
|
|
147
|
+
});
|
|
148
|
+
} catch {
|
|
149
|
+
return c.json({ error: 'Invalid private key format' }, 400);
|
|
150
|
+
}
|
|
151
|
+
} catch (error) {
|
|
152
|
+
logger.error('Failed to import OttoRouter wallet', error);
|
|
153
|
+
const errorResponse = serializeError(error);
|
|
154
|
+
return c.json(errorResponse, errorResponse.error.status || 500);
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
openApiRoute(
|
|
160
|
+
app,
|
|
161
|
+
{
|
|
162
|
+
method: 'get',
|
|
163
|
+
path: '/v1/auth/ottorouter/export',
|
|
164
|
+
tags: ['auth'],
|
|
165
|
+
operationId: 'exportOttoRouterWallet',
|
|
166
|
+
summary: 'Export OttoRouter wallet private key',
|
|
167
|
+
responses: {
|
|
168
|
+
'200': {
|
|
169
|
+
description: 'OK',
|
|
170
|
+
content: {
|
|
171
|
+
'application/json': {
|
|
172
|
+
schema: {
|
|
173
|
+
type: 'object',
|
|
174
|
+
properties: {
|
|
175
|
+
success: {
|
|
176
|
+
type: 'boolean',
|
|
177
|
+
},
|
|
178
|
+
publicKey: {
|
|
179
|
+
type: 'string',
|
|
180
|
+
},
|
|
181
|
+
privateKey: {
|
|
182
|
+
type: 'string',
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
required: ['success', 'publicKey', 'privateKey'],
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
'404': {
|
|
191
|
+
description: 'Bad Request',
|
|
192
|
+
content: {
|
|
193
|
+
'application/json': {
|
|
194
|
+
schema: {
|
|
195
|
+
type: 'object',
|
|
196
|
+
properties: {
|
|
197
|
+
error: {
|
|
198
|
+
type: 'string',
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
required: ['error'],
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
async (c) => {
|
|
209
|
+
try {
|
|
210
|
+
const projectRoot = process.cwd();
|
|
211
|
+
const wallet = await getOttoRouterWallet(projectRoot);
|
|
212
|
+
|
|
213
|
+
if (!wallet) {
|
|
214
|
+
return c.json({ error: 'OttoRouter wallet not configured' }, 404);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return c.json({
|
|
218
|
+
success: true,
|
|
219
|
+
publicKey: wallet.publicKey,
|
|
220
|
+
privateKey: wallet.privateKey,
|
|
221
|
+
});
|
|
222
|
+
} catch (error) {
|
|
223
|
+
logger.error('Failed to export OttoRouter wallet', error);
|
|
224
|
+
const errorResponse = serializeError(error);
|
|
225
|
+
return c.json(errorResponse, errorResponse.error.status || 500);
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
);
|
|
229
|
+
}
|