@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
@@ -7,69 +7,160 @@ import {
7
7
  getAheadBehind,
8
8
  getCurrentBranch,
9
9
  } from './utils.ts';
10
+ import { openApiRoute } from '../../openapi/route.ts';
10
11
 
11
12
  const execFileAsync = promisify(execFile);
12
13
 
13
14
  export function registerBranchRoute(app: Hono) {
14
- app.get('/v1/git/branch', async (c) => {
15
- try {
16
- const query = gitStatusSchema.parse({
17
- project: c.req.query('project'),
18
- });
15
+ openApiRoute(
16
+ app,
17
+ {
18
+ method: 'get',
19
+ path: '/v1/git/branch',
20
+ tags: ['git'],
21
+ operationId: 'getGitBranch',
22
+ summary: 'Get git branch information',
23
+ parameters: [
24
+ {
25
+ in: 'query',
26
+ name: 'project',
27
+ required: false,
28
+ schema: {
29
+ type: 'string',
30
+ },
31
+ description:
32
+ 'Project root override (defaults to current working directory).',
33
+ },
34
+ ],
35
+ responses: {
36
+ '200': {
37
+ description: 'OK',
38
+ content: {
39
+ 'application/json': {
40
+ schema: {
41
+ type: 'object',
42
+ properties: {
43
+ status: {
44
+ type: 'string',
45
+ enum: ['ok'],
46
+ },
47
+ data: {
48
+ $ref: '#/components/schemas/GitBranch',
49
+ },
50
+ },
51
+ required: ['status', 'data'],
52
+ },
53
+ },
54
+ },
55
+ },
56
+ '400': {
57
+ description: 'Error',
58
+ content: {
59
+ 'application/json': {
60
+ schema: {
61
+ type: 'object',
62
+ properties: {
63
+ status: {
64
+ type: 'string',
65
+ enum: ['error'],
66
+ },
67
+ error: {
68
+ type: 'string',
69
+ },
70
+ code: {
71
+ type: 'string',
72
+ },
73
+ },
74
+ required: ['status', 'error'],
75
+ },
76
+ },
77
+ },
78
+ },
79
+ '500': {
80
+ description: 'Error',
81
+ content: {
82
+ 'application/json': {
83
+ schema: {
84
+ type: 'object',
85
+ properties: {
86
+ status: {
87
+ type: 'string',
88
+ enum: ['error'],
89
+ },
90
+ error: {
91
+ type: 'string',
92
+ },
93
+ code: {
94
+ type: 'string',
95
+ },
96
+ },
97
+ required: ['status', 'error'],
98
+ },
99
+ },
100
+ },
101
+ },
102
+ },
103
+ },
104
+ async (c) => {
105
+ try {
106
+ const query = gitStatusSchema.parse({
107
+ project: c.req.query('project'),
108
+ });
19
109
 
20
- const requestedPath = query.project || process.cwd();
110
+ const requestedPath = query.project || process.cwd();
21
111
 
22
- const validation = await validateAndGetGitRoot(requestedPath);
23
- if ('error' in validation) {
24
- return c.json(
25
- { status: 'error', error: validation.error, code: validation.code },
26
- 400,
27
- );
28
- }
112
+ const validation = await validateAndGetGitRoot(requestedPath);
113
+ if ('error' in validation) {
114
+ return c.json(
115
+ { status: 'error', error: validation.error, code: validation.code },
116
+ 400,
117
+ );
118
+ }
29
119
 
30
- const { gitRoot } = validation;
120
+ const { gitRoot } = validation;
31
121
 
32
- const branch = await getCurrentBranch(gitRoot);
122
+ const branch = await getCurrentBranch(gitRoot);
33
123
 
34
- const { ahead, behind } = await getAheadBehind(gitRoot);
124
+ const { ahead, behind } = await getAheadBehind(gitRoot);
35
125
 
36
- try {
37
- const { stdout: remotes } = await execFileAsync('git', ['remote'], {
38
- cwd: gitRoot,
39
- });
40
- const remoteList = remotes.trim().split('\n').filter(Boolean);
126
+ try {
127
+ const { stdout: remotes } = await execFileAsync('git', ['remote'], {
128
+ cwd: gitRoot,
129
+ });
130
+ const remoteList = remotes.trim().split('\n').filter(Boolean);
41
131
 
42
- return c.json({
43
- status: 'ok',
44
- data: {
45
- branch,
46
- ahead,
47
- behind,
48
- remotes: remoteList,
49
- },
50
- });
51
- } catch {
52
- return c.json({
53
- status: 'ok',
54
- data: {
55
- branch,
56
- ahead,
57
- behind,
58
- remotes: [],
132
+ return c.json({
133
+ status: 'ok',
134
+ data: {
135
+ branch,
136
+ ahead,
137
+ behind,
138
+ remotes: remoteList,
139
+ },
140
+ });
141
+ } catch {
142
+ return c.json({
143
+ status: 'ok',
144
+ data: {
145
+ branch,
146
+ ahead,
147
+ behind,
148
+ remotes: [],
149
+ },
150
+ });
151
+ }
152
+ } catch (error) {
153
+ return c.json(
154
+ {
155
+ status: 'error',
156
+ error:
157
+ error instanceof Error
158
+ ? error.message
159
+ : 'Failed to get branch info',
59
160
  },
60
- });
161
+ 500,
162
+ );
61
163
  }
62
- } catch (error) {
63
- return c.json(
64
- {
65
- status: 'error',
66
- error:
67
- error instanceof Error
68
- ? error.message
69
- : 'Failed to get branch info',
70
- },
71
- 500,
72
- );
73
- }
74
- });
164
+ },
165
+ );
75
166
  }