@ottocode/server 0.1.265 → 0.1.266

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 (72) hide show
  1. package/package.json +3 -3
  2. package/src/routes/auth/copilot.ts +699 -0
  3. package/src/routes/auth/oauth.ts +578 -0
  4. package/src/routes/auth/onboarding.ts +45 -0
  5. package/src/routes/auth/providers.ts +189 -0
  6. package/src/routes/auth/service.ts +167 -0
  7. package/src/routes/auth/state.ts +23 -0
  8. package/src/routes/auth/status.ts +203 -0
  9. package/src/routes/auth/wallet.ts +229 -0
  10. package/src/routes/auth.ts +12 -2080
  11. package/src/routes/config/models-service.ts +411 -0
  12. package/src/routes/config/models.ts +6 -426
  13. package/src/routes/config/providers-service.ts +237 -0
  14. package/src/routes/config/providers.ts +10 -242
  15. package/src/routes/files/handlers.ts +297 -0
  16. package/src/routes/files/service.ts +313 -0
  17. package/src/routes/files.ts +12 -608
  18. package/src/routes/git/commit-service.ts +207 -0
  19. package/src/routes/git/commit.ts +6 -220
  20. package/src/routes/git/remote-service.ts +116 -0
  21. package/src/routes/git/remote.ts +8 -115
  22. package/src/routes/git/staging-service.ts +111 -0
  23. package/src/routes/git/staging.ts +10 -205
  24. package/src/routes/mcp/auth.ts +338 -0
  25. package/src/routes/mcp/lifecycle.ts +263 -0
  26. package/src/routes/mcp/servers.ts +212 -0
  27. package/src/routes/mcp/service.ts +664 -0
  28. package/src/routes/mcp/state.ts +13 -0
  29. package/src/routes/mcp.ts +6 -1233
  30. package/src/routes/ottorouter/billing.ts +593 -0
  31. package/src/routes/ottorouter/service.ts +92 -0
  32. package/src/routes/ottorouter/topup.ts +301 -0
  33. package/src/routes/ottorouter/wallet.ts +370 -0
  34. package/src/routes/ottorouter.ts +6 -1319
  35. package/src/routes/research/service.ts +339 -0
  36. package/src/routes/research.ts +12 -390
  37. package/src/routes/sessions/crud.ts +563 -0
  38. package/src/routes/sessions/queue.ts +242 -0
  39. package/src/routes/sessions/retry.ts +121 -0
  40. package/src/routes/sessions/service.ts +768 -0
  41. package/src/routes/sessions/share.ts +434 -0
  42. package/src/routes/sessions.ts +8 -1977
  43. package/src/routes/skills/service.ts +221 -0
  44. package/src/routes/skills/spec.ts +309 -0
  45. package/src/routes/skills.ts +31 -909
  46. package/src/routes/terminals/service.ts +326 -0
  47. package/src/routes/terminals.ts +19 -295
  48. package/src/routes/tunnel/service.ts +217 -0
  49. package/src/routes/tunnel.ts +29 -219
  50. package/src/runtime/agent/registry-prompts.ts +147 -0
  51. package/src/runtime/agent/registry.ts +6 -124
  52. package/src/runtime/agent/runner-errors.ts +116 -0
  53. package/src/runtime/agent/runner-reminders.ts +45 -0
  54. package/src/runtime/agent/runner-setup-model.ts +75 -0
  55. package/src/runtime/agent/runner-setup-prompt.ts +185 -0
  56. package/src/runtime/agent/runner-setup-tools.ts +103 -0
  57. package/src/runtime/agent/runner-setup-utils.ts +21 -0
  58. package/src/runtime/agent/runner-setup.ts +54 -288
  59. package/src/runtime/agent/runner-telemetry.ts +112 -0
  60. package/src/runtime/agent/runner-text.ts +108 -0
  61. package/src/runtime/agent/runner-tool-observer.ts +86 -0
  62. package/src/runtime/agent/runner.ts +79 -378
  63. package/src/runtime/provider/custom.ts +73 -0
  64. package/src/runtime/provider/index.ts +2 -85
  65. package/src/runtime/provider/reasoning-builders.ts +280 -0
  66. package/src/runtime/provider/reasoning.ts +67 -264
  67. package/src/tools/adapter/events.ts +116 -0
  68. package/src/tools/adapter/execution.ts +160 -0
  69. package/src/tools/adapter/pending.ts +37 -0
  70. package/src/tools/adapter/persistence.ts +166 -0
  71. package/src/tools/adapter/results.ts +97 -0
  72. package/src/tools/adapter.ts +124 -451
@@ -0,0 +1,434 @@
1
+ import type { Hono } from 'hono';
2
+ import { openApiRoute } from '../../openapi/route.ts';
3
+ import {
4
+ createShare,
5
+ deleteShare,
6
+ getShareStatus,
7
+ listShares,
8
+ loadProjectDb,
9
+ syncShare,
10
+ } from './service.ts';
11
+
12
+ export function registerSessionShareRoutes(app: Hono) {
13
+ openApiRoute(
14
+ app,
15
+ {
16
+ method: 'get',
17
+ path: '/v1/sessions/{sessionId}/share',
18
+ tags: ['sessions'],
19
+ operationId: 'getShareStatus',
20
+ summary: 'Get share status for a session',
21
+ parameters: [
22
+ {
23
+ in: 'path',
24
+ name: 'sessionId',
25
+ required: true,
26
+ schema: {
27
+ type: 'string',
28
+ },
29
+ },
30
+ {
31
+ in: 'query',
32
+ name: 'project',
33
+ required: false,
34
+ schema: {
35
+ type: 'string',
36
+ },
37
+ description:
38
+ 'Project root override (defaults to current working directory).',
39
+ },
40
+ ],
41
+ responses: {
42
+ '200': {
43
+ description: 'OK',
44
+ content: {
45
+ 'application/json': {
46
+ schema: {
47
+ type: 'object',
48
+ properties: {
49
+ shared: {
50
+ type: 'boolean',
51
+ },
52
+ shareId: {
53
+ type: 'string',
54
+ },
55
+ url: {
56
+ type: 'string',
57
+ },
58
+ title: {
59
+ type: 'string',
60
+ nullable: true,
61
+ },
62
+ createdAt: {
63
+ type: 'integer',
64
+ },
65
+ lastSyncedAt: {
66
+ type: 'integer',
67
+ },
68
+ lastSyncedMessageId: {
69
+ type: 'string',
70
+ },
71
+ syncedMessages: {
72
+ type: 'integer',
73
+ },
74
+ totalMessages: {
75
+ type: 'integer',
76
+ },
77
+ pendingMessages: {
78
+ type: 'integer',
79
+ },
80
+ isSynced: {
81
+ type: 'boolean',
82
+ },
83
+ },
84
+ required: ['shared'],
85
+ },
86
+ },
87
+ },
88
+ },
89
+ },
90
+ },
91
+ async (c) => {
92
+ const sessionId = c.req.param('sessionId');
93
+ const projectRoot = c.req.query('project') || process.cwd();
94
+ const { db } = await loadProjectDb(projectRoot);
95
+ return c.json(await getShareStatus(db, sessionId));
96
+ },
97
+ );
98
+
99
+ openApiRoute(
100
+ app,
101
+ {
102
+ method: 'post',
103
+ path: '/v1/sessions/{sessionId}/share',
104
+ tags: ['sessions'],
105
+ operationId: 'shareSession',
106
+ summary: 'Share a session',
107
+ parameters: [
108
+ {
109
+ in: 'path',
110
+ name: 'sessionId',
111
+ required: true,
112
+ schema: {
113
+ type: 'string',
114
+ },
115
+ },
116
+ {
117
+ in: 'query',
118
+ name: 'project',
119
+ required: false,
120
+ schema: {
121
+ type: 'string',
122
+ },
123
+ description:
124
+ 'Project root override (defaults to current working directory).',
125
+ },
126
+ ],
127
+ responses: {
128
+ '200': {
129
+ description: 'OK',
130
+ content: {
131
+ 'application/json': {
132
+ schema: {
133
+ type: 'object',
134
+ properties: {
135
+ shared: {
136
+ type: 'boolean',
137
+ },
138
+ shareId: {
139
+ type: 'string',
140
+ },
141
+ url: {
142
+ type: 'string',
143
+ },
144
+ message: {
145
+ type: 'string',
146
+ },
147
+ },
148
+ required: ['shared'],
149
+ },
150
+ },
151
+ },
152
+ },
153
+ '400': {
154
+ description: 'Bad Request',
155
+ content: {
156
+ 'application/json': {
157
+ schema: {
158
+ type: 'object',
159
+ properties: {
160
+ error: {
161
+ type: 'string',
162
+ },
163
+ },
164
+ required: ['error'],
165
+ },
166
+ },
167
+ },
168
+ },
169
+ '404': {
170
+ description: 'Bad Request',
171
+ content: {
172
+ 'application/json': {
173
+ schema: {
174
+ type: 'object',
175
+ properties: {
176
+ error: {
177
+ type: 'string',
178
+ },
179
+ },
180
+ required: ['error'],
181
+ },
182
+ },
183
+ },
184
+ },
185
+ },
186
+ },
187
+ async (c) => {
188
+ const sessionId = c.req.param('sessionId');
189
+ const projectRoot = c.req.query('project') || process.cwd();
190
+ const { db } = await loadProjectDb(projectRoot);
191
+ const result = await createShare(db, sessionId);
192
+ return result.ok
193
+ ? c.json(result.body)
194
+ : c.json(result.body, result.status);
195
+ },
196
+ );
197
+
198
+ openApiRoute(
199
+ app,
200
+ {
201
+ method: 'put',
202
+ path: '/v1/sessions/{sessionId}/share',
203
+ tags: ['sessions'],
204
+ operationId: 'syncShare',
205
+ summary: 'Sync shared session with new messages',
206
+ parameters: [
207
+ {
208
+ in: 'path',
209
+ name: 'sessionId',
210
+ required: true,
211
+ schema: {
212
+ type: 'string',
213
+ },
214
+ },
215
+ {
216
+ in: 'query',
217
+ name: 'project',
218
+ required: false,
219
+ schema: {
220
+ type: 'string',
221
+ },
222
+ description:
223
+ 'Project root override (defaults to current working directory).',
224
+ },
225
+ ],
226
+ responses: {
227
+ '200': {
228
+ description: 'OK',
229
+ content: {
230
+ 'application/json': {
231
+ schema: {
232
+ type: 'object',
233
+ properties: {
234
+ synced: {
235
+ type: 'boolean',
236
+ },
237
+ url: {
238
+ type: 'string',
239
+ },
240
+ newMessages: {
241
+ type: 'integer',
242
+ },
243
+ message: {
244
+ type: 'string',
245
+ },
246
+ },
247
+ required: ['synced'],
248
+ },
249
+ },
250
+ },
251
+ },
252
+ '400': {
253
+ description: 'Bad Request',
254
+ content: {
255
+ 'application/json': {
256
+ schema: {
257
+ type: 'object',
258
+ properties: {
259
+ error: {
260
+ type: 'string',
261
+ },
262
+ },
263
+ required: ['error'],
264
+ },
265
+ },
266
+ },
267
+ },
268
+ },
269
+ },
270
+ async (c) => {
271
+ const sessionId = c.req.param('sessionId');
272
+ const projectRoot = c.req.query('project') || process.cwd();
273
+ const { db } = await loadProjectDb(projectRoot);
274
+ const result = await syncShare(db, sessionId);
275
+ return result.ok
276
+ ? c.json(result.body)
277
+ : c.json(result.body, result.status);
278
+ },
279
+ );
280
+
281
+ openApiRoute(
282
+ app,
283
+ {
284
+ method: 'delete',
285
+ path: '/v1/sessions/{sessionId}/share',
286
+ tags: ['sessions'],
287
+ operationId: 'deleteShare',
288
+ summary: 'Delete a shared session',
289
+ parameters: [
290
+ {
291
+ in: 'path',
292
+ name: 'sessionId',
293
+ required: true,
294
+ schema: {
295
+ type: 'string',
296
+ },
297
+ },
298
+ {
299
+ in: 'query',
300
+ name: 'project',
301
+ required: false,
302
+ schema: {
303
+ type: 'string',
304
+ },
305
+ description:
306
+ 'Project root override (defaults to current working directory).',
307
+ },
308
+ ],
309
+ responses: {
310
+ '200': {
311
+ description: 'OK',
312
+ content: {
313
+ 'application/json': {
314
+ schema: {
315
+ type: 'object',
316
+ properties: {
317
+ deleted: {
318
+ type: 'boolean',
319
+ },
320
+ sessionId: {
321
+ type: 'string',
322
+ },
323
+ },
324
+ required: ['deleted', 'sessionId'],
325
+ },
326
+ },
327
+ },
328
+ },
329
+ '404': {
330
+ description: 'Bad Request',
331
+ content: {
332
+ 'application/json': {
333
+ schema: {
334
+ type: 'object',
335
+ properties: {
336
+ error: {
337
+ type: 'string',
338
+ },
339
+ },
340
+ required: ['error'],
341
+ },
342
+ },
343
+ },
344
+ },
345
+ },
346
+ },
347
+ async (c) => {
348
+ const sessionId = c.req.param('sessionId');
349
+ const projectRoot = c.req.query('project') || process.cwd();
350
+ const { db } = await loadProjectDb(projectRoot);
351
+ const result = await deleteShare(db, sessionId);
352
+ return result.ok
353
+ ? c.json(result.body)
354
+ : c.json(result.body, result.status);
355
+ },
356
+ );
357
+
358
+ openApiRoute(
359
+ app,
360
+ {
361
+ method: 'get',
362
+ path: '/v1/shares',
363
+ tags: ['sessions'],
364
+ operationId: 'listShares',
365
+ summary: 'List all shared sessions for a project',
366
+ parameters: [
367
+ {
368
+ in: 'query',
369
+ name: 'project',
370
+ required: false,
371
+ schema: {
372
+ type: 'string',
373
+ },
374
+ description:
375
+ 'Project root override (defaults to current working directory).',
376
+ },
377
+ ],
378
+ responses: {
379
+ '200': {
380
+ description: 'OK',
381
+ content: {
382
+ 'application/json': {
383
+ schema: {
384
+ type: 'object',
385
+ properties: {
386
+ shares: {
387
+ type: 'array',
388
+ items: {
389
+ type: 'object',
390
+ properties: {
391
+ sessionId: {
392
+ type: 'string',
393
+ },
394
+ shareId: {
395
+ type: 'string',
396
+ },
397
+ url: {
398
+ type: 'string',
399
+ },
400
+ title: {
401
+ type: 'string',
402
+ nullable: true,
403
+ },
404
+ createdAt: {
405
+ type: 'integer',
406
+ },
407
+ lastSyncedAt: {
408
+ type: 'integer',
409
+ },
410
+ },
411
+ required: [
412
+ 'sessionId',
413
+ 'shareId',
414
+ 'url',
415
+ 'createdAt',
416
+ 'lastSyncedAt',
417
+ ],
418
+ },
419
+ },
420
+ },
421
+ required: ['shares'],
422
+ },
423
+ },
424
+ },
425
+ },
426
+ },
427
+ },
428
+ async (c) => {
429
+ const projectRoot = c.req.query('project') || process.cwd();
430
+ const { cfg, db } = await loadProjectDb(projectRoot);
431
+ return c.json({ shares: await listShares(cfg, db) });
432
+ },
433
+ );
434
+ }