@ottocode/server 0.1.173

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 (111) hide show
  1. package/package.json +42 -0
  2. package/src/events/bus.ts +43 -0
  3. package/src/events/types.ts +32 -0
  4. package/src/index.ts +281 -0
  5. package/src/openapi/helpers.ts +64 -0
  6. package/src/openapi/paths/ask.ts +70 -0
  7. package/src/openapi/paths/config.ts +218 -0
  8. package/src/openapi/paths/files.ts +72 -0
  9. package/src/openapi/paths/git.ts +457 -0
  10. package/src/openapi/paths/messages.ts +92 -0
  11. package/src/openapi/paths/sessions.ts +90 -0
  12. package/src/openapi/paths/setu.ts +154 -0
  13. package/src/openapi/paths/stream.ts +26 -0
  14. package/src/openapi/paths/terminals.ts +226 -0
  15. package/src/openapi/schemas.ts +345 -0
  16. package/src/openapi/spec.ts +49 -0
  17. package/src/presets.ts +85 -0
  18. package/src/routes/ask.ts +113 -0
  19. package/src/routes/auth.ts +592 -0
  20. package/src/routes/branch.ts +106 -0
  21. package/src/routes/config/agents.ts +44 -0
  22. package/src/routes/config/cwd.ts +21 -0
  23. package/src/routes/config/defaults.ts +45 -0
  24. package/src/routes/config/index.ts +16 -0
  25. package/src/routes/config/main.ts +73 -0
  26. package/src/routes/config/models.ts +139 -0
  27. package/src/routes/config/providers.ts +46 -0
  28. package/src/routes/config/utils.ts +120 -0
  29. package/src/routes/files.ts +218 -0
  30. package/src/routes/git/branch.ts +75 -0
  31. package/src/routes/git/commit.ts +209 -0
  32. package/src/routes/git/diff.ts +137 -0
  33. package/src/routes/git/index.ts +18 -0
  34. package/src/routes/git/push.ts +160 -0
  35. package/src/routes/git/schemas.ts +48 -0
  36. package/src/routes/git/staging.ts +208 -0
  37. package/src/routes/git/status.ts +83 -0
  38. package/src/routes/git/types.ts +31 -0
  39. package/src/routes/git/utils.ts +249 -0
  40. package/src/routes/openapi.ts +6 -0
  41. package/src/routes/research.ts +392 -0
  42. package/src/routes/root.ts +5 -0
  43. package/src/routes/session-approval.ts +63 -0
  44. package/src/routes/session-files.ts +387 -0
  45. package/src/routes/session-messages.ts +170 -0
  46. package/src/routes/session-stream.ts +61 -0
  47. package/src/routes/sessions.ts +814 -0
  48. package/src/routes/setu.ts +346 -0
  49. package/src/routes/terminals.ts +227 -0
  50. package/src/runtime/agent/registry.ts +351 -0
  51. package/src/runtime/agent/runner-reasoning.ts +108 -0
  52. package/src/runtime/agent/runner-setup.ts +257 -0
  53. package/src/runtime/agent/runner.ts +375 -0
  54. package/src/runtime/agent-registry.ts +6 -0
  55. package/src/runtime/ask/service.ts +369 -0
  56. package/src/runtime/context/environment.ts +202 -0
  57. package/src/runtime/debug/index.ts +117 -0
  58. package/src/runtime/debug/state.ts +140 -0
  59. package/src/runtime/errors/api-error.ts +192 -0
  60. package/src/runtime/errors/handling.ts +199 -0
  61. package/src/runtime/message/compaction-auto.ts +154 -0
  62. package/src/runtime/message/compaction-context.ts +101 -0
  63. package/src/runtime/message/compaction-detect.ts +26 -0
  64. package/src/runtime/message/compaction-limits.ts +37 -0
  65. package/src/runtime/message/compaction-mark.ts +111 -0
  66. package/src/runtime/message/compaction-prune.ts +75 -0
  67. package/src/runtime/message/compaction.ts +21 -0
  68. package/src/runtime/message/history-builder.ts +266 -0
  69. package/src/runtime/message/service.ts +468 -0
  70. package/src/runtime/message/tool-history-tracker.ts +204 -0
  71. package/src/runtime/prompt/builder.ts +167 -0
  72. package/src/runtime/provider/anthropic.ts +50 -0
  73. package/src/runtime/provider/copilot.ts +12 -0
  74. package/src/runtime/provider/google.ts +8 -0
  75. package/src/runtime/provider/index.ts +60 -0
  76. package/src/runtime/provider/moonshot.ts +8 -0
  77. package/src/runtime/provider/oauth-adapter.ts +237 -0
  78. package/src/runtime/provider/openai.ts +18 -0
  79. package/src/runtime/provider/opencode.ts +7 -0
  80. package/src/runtime/provider/openrouter.ts +7 -0
  81. package/src/runtime/provider/selection.ts +118 -0
  82. package/src/runtime/provider/setu.ts +126 -0
  83. package/src/runtime/provider/zai.ts +16 -0
  84. package/src/runtime/session/branch.ts +280 -0
  85. package/src/runtime/session/db-operations.ts +285 -0
  86. package/src/runtime/session/manager.ts +99 -0
  87. package/src/runtime/session/queue.ts +243 -0
  88. package/src/runtime/stream/abort-handler.ts +65 -0
  89. package/src/runtime/stream/error-handler.ts +371 -0
  90. package/src/runtime/stream/finish-handler.ts +101 -0
  91. package/src/runtime/stream/handlers.ts +5 -0
  92. package/src/runtime/stream/step-finish.ts +93 -0
  93. package/src/runtime/stream/types.ts +25 -0
  94. package/src/runtime/tools/approval.ts +180 -0
  95. package/src/runtime/tools/context.ts +83 -0
  96. package/src/runtime/tools/mapping.ts +154 -0
  97. package/src/runtime/tools/setup.ts +44 -0
  98. package/src/runtime/topup/manager.ts +110 -0
  99. package/src/runtime/utils/cwd.ts +69 -0
  100. package/src/runtime/utils/token.ts +35 -0
  101. package/src/tools/adapter.ts +634 -0
  102. package/src/tools/database/get-parent-session.ts +183 -0
  103. package/src/tools/database/get-session-context.ts +161 -0
  104. package/src/tools/database/index.ts +42 -0
  105. package/src/tools/database/present-session-links.ts +47 -0
  106. package/src/tools/database/query-messages.ts +160 -0
  107. package/src/tools/database/query-sessions.ts +126 -0
  108. package/src/tools/database/search-history.ts +135 -0
  109. package/src/types/sql-imports.d.ts +5 -0
  110. package/sst-env.d.ts +8 -0
  111. package/tsconfig.json +7 -0
@@ -0,0 +1,154 @@
1
+ export const setuPaths = {
2
+ '/v1/setu/balance': {
3
+ get: {
4
+ tags: ['setu'],
5
+ operationId: 'getSetuBalance',
6
+ summary: 'Get Setu account balance',
7
+ description:
8
+ 'Returns wallet balance, total spent, total topups, and request count',
9
+ responses: {
10
+ 200: {
11
+ description: 'OK',
12
+ content: {
13
+ 'application/json': {
14
+ schema: {
15
+ type: 'object',
16
+ properties: {
17
+ walletAddress: { type: 'string' },
18
+ balance: { type: 'number' },
19
+ totalSpent: { type: 'number' },
20
+ totalTopups: { type: 'number' },
21
+ requestCount: { type: 'number' },
22
+ },
23
+ required: [
24
+ 'walletAddress',
25
+ 'balance',
26
+ 'totalSpent',
27
+ 'totalTopups',
28
+ 'requestCount',
29
+ ],
30
+ },
31
+ },
32
+ },
33
+ },
34
+ 401: {
35
+ description: 'Wallet not configured',
36
+ content: {
37
+ 'application/json': {
38
+ schema: {
39
+ type: 'object',
40
+ properties: { error: { type: 'string' } },
41
+ required: ['error'],
42
+ },
43
+ },
44
+ },
45
+ },
46
+ 502: {
47
+ description: 'Failed to fetch balance from Setu',
48
+ content: {
49
+ 'application/json': {
50
+ schema: {
51
+ type: 'object',
52
+ properties: { error: { type: 'string' } },
53
+ required: ['error'],
54
+ },
55
+ },
56
+ },
57
+ },
58
+ },
59
+ },
60
+ },
61
+ '/v1/setu/wallet': {
62
+ get: {
63
+ tags: ['setu'],
64
+ operationId: 'getSetuWallet',
65
+ summary: 'Get Setu wallet info',
66
+ description:
67
+ 'Returns whether the wallet is configured and its public key',
68
+ responses: {
69
+ 200: {
70
+ description: 'OK',
71
+ content: {
72
+ 'application/json': {
73
+ schema: {
74
+ type: 'object',
75
+ properties: {
76
+ configured: { type: 'boolean' },
77
+ publicKey: { type: 'string' },
78
+ error: { type: 'string' },
79
+ },
80
+ required: ['configured'],
81
+ },
82
+ },
83
+ },
84
+ },
85
+ },
86
+ },
87
+ },
88
+ '/v1/setu/usdc-balance': {
89
+ get: {
90
+ tags: ['setu'],
91
+ operationId: 'getSetuUsdcBalance',
92
+ summary: 'Get USDC token balance',
93
+ description:
94
+ 'Fetches USDC balance from Solana blockchain for the configured wallet',
95
+ parameters: [
96
+ {
97
+ in: 'query',
98
+ name: 'network',
99
+ schema: {
100
+ type: 'string',
101
+ enum: ['mainnet', 'devnet'],
102
+ default: 'mainnet',
103
+ },
104
+ description: 'Solana network to query',
105
+ },
106
+ ],
107
+ responses: {
108
+ 200: {
109
+ description: 'OK',
110
+ content: {
111
+ 'application/json': {
112
+ schema: {
113
+ type: 'object',
114
+ properties: {
115
+ walletAddress: { type: 'string' },
116
+ usdcBalance: { type: 'number' },
117
+ network: {
118
+ type: 'string',
119
+ enum: ['mainnet', 'devnet'],
120
+ },
121
+ },
122
+ required: ['walletAddress', 'usdcBalance', 'network'],
123
+ },
124
+ },
125
+ },
126
+ },
127
+ 401: {
128
+ description: 'Wallet not configured',
129
+ content: {
130
+ 'application/json': {
131
+ schema: {
132
+ type: 'object',
133
+ properties: { error: { type: 'string' } },
134
+ required: ['error'],
135
+ },
136
+ },
137
+ },
138
+ },
139
+ 502: {
140
+ description: 'Failed to fetch USDC balance from Solana',
141
+ content: {
142
+ 'application/json': {
143
+ schema: {
144
+ type: 'object',
145
+ properties: { error: { type: 'string' } },
146
+ required: ['error'],
147
+ },
148
+ },
149
+ },
150
+ },
151
+ },
152
+ },
153
+ },
154
+ } as const;
@@ -0,0 +1,26 @@
1
+ import { projectQueryParam, sessionIdParam } from '../helpers';
2
+
3
+ export const streamPaths = {
4
+ '/v1/sessions/{id}/stream': {
5
+ get: {
6
+ tags: ['stream'],
7
+ operationId: 'subscribeSessionStream',
8
+ summary: 'Subscribe to session event stream (SSE)',
9
+ parameters: [projectQueryParam(), sessionIdParam()],
10
+ responses: {
11
+ 200: {
12
+ description: 'text/event-stream',
13
+ content: {
14
+ 'text/event-stream': {
15
+ schema: {
16
+ type: 'string',
17
+ description:
18
+ 'SSE event stream. Events include session.created, message.created, message.part.delta, tool.call, tool.delta, tool.result, message.completed, error.',
19
+ },
20
+ },
21
+ },
22
+ },
23
+ },
24
+ },
25
+ },
26
+ } as const;
@@ -0,0 +1,226 @@
1
+ export const terminalsPath = {
2
+ '/v1/terminals': {
3
+ get: {
4
+ operationId: 'getTerminals',
5
+ summary: 'List all terminals',
6
+ description: 'Get a list of all active terminal sessions',
7
+ responses: {
8
+ '200': {
9
+ description: 'List of terminals',
10
+ content: {
11
+ 'application/json': {
12
+ schema: {
13
+ type: 'object',
14
+ properties: {
15
+ terminals: {
16
+ type: 'array',
17
+ items: {
18
+ $ref: '#/components/schemas/Terminal',
19
+ },
20
+ },
21
+ count: {
22
+ type: 'integer',
23
+ },
24
+ },
25
+ },
26
+ },
27
+ },
28
+ },
29
+ },
30
+ },
31
+ post: {
32
+ operationId: 'postTerminals',
33
+ summary: 'Create a new terminal',
34
+ description: 'Spawn a new terminal process',
35
+ requestBody: {
36
+ required: true,
37
+ content: {
38
+ 'application/json': {
39
+ schema: {
40
+ type: 'object',
41
+ required: ['command', 'purpose'],
42
+ properties: {
43
+ command: {
44
+ type: 'string',
45
+ description: 'Command to execute',
46
+ },
47
+ args: {
48
+ type: 'array',
49
+ items: { type: 'string' },
50
+ description: 'Command arguments',
51
+ },
52
+ purpose: {
53
+ type: 'string',
54
+ description: 'Description of terminal purpose',
55
+ },
56
+ cwd: {
57
+ type: 'string',
58
+ description: 'Working directory',
59
+ },
60
+ title: {
61
+ type: 'string',
62
+ description: 'Terminal title',
63
+ },
64
+ },
65
+ },
66
+ },
67
+ },
68
+ },
69
+ responses: {
70
+ '200': {
71
+ description: 'Terminal created',
72
+ content: {
73
+ 'application/json': {
74
+ schema: {
75
+ type: 'object',
76
+ properties: {
77
+ terminalId: { type: 'string' },
78
+ pid: { type: 'integer' },
79
+ purpose: { type: 'string' },
80
+ command: { type: 'string' },
81
+ },
82
+ },
83
+ },
84
+ },
85
+ },
86
+ },
87
+ },
88
+ },
89
+ '/v1/terminals/{id}': {
90
+ get: {
91
+ operationId: 'getTerminalsById',
92
+ summary: 'Get terminal details',
93
+ description: 'Get information about a specific terminal',
94
+ parameters: [
95
+ {
96
+ name: 'id',
97
+ in: 'path',
98
+ required: true,
99
+ schema: { type: 'string' },
100
+ },
101
+ ],
102
+ responses: {
103
+ '200': {
104
+ description: 'Terminal details',
105
+ content: {
106
+ 'application/json': {
107
+ schema: {
108
+ type: 'object',
109
+ properties: {
110
+ terminal: {
111
+ $ref: '#/components/schemas/Terminal',
112
+ },
113
+ },
114
+ },
115
+ },
116
+ },
117
+ },
118
+ '404': {
119
+ description: 'Terminal not found',
120
+ },
121
+ },
122
+ },
123
+ delete: {
124
+ operationId: 'deleteTerminalsById',
125
+ summary: 'Kill terminal',
126
+ description: 'Terminate a running terminal process',
127
+ parameters: [
128
+ {
129
+ name: 'id',
130
+ in: 'path',
131
+ required: true,
132
+ schema: { type: 'string' },
133
+ },
134
+ ],
135
+ responses: {
136
+ '200': {
137
+ description: 'Terminal killed',
138
+ content: {
139
+ 'application/json': {
140
+ schema: {
141
+ type: 'object',
142
+ properties: {
143
+ success: { type: 'boolean' },
144
+ },
145
+ },
146
+ },
147
+ },
148
+ },
149
+ },
150
+ },
151
+ },
152
+ '/v1/terminals/{id}/output': {
153
+ get: {
154
+ operationId: 'getTerminalsByIdOutput',
155
+ summary: 'Stream terminal output',
156
+ description: 'Get real-time terminal output via SSE',
157
+ parameters: [
158
+ {
159
+ name: 'id',
160
+ in: 'path',
161
+ required: true,
162
+ schema: { type: 'string' },
163
+ },
164
+ ],
165
+ responses: {
166
+ '200': {
167
+ description: 'SSE stream of terminal output',
168
+ content: {
169
+ 'text/event-stream': {
170
+ schema: {
171
+ type: 'string',
172
+ },
173
+ },
174
+ },
175
+ },
176
+ },
177
+ },
178
+ },
179
+ '/v1/terminals/{id}/input': {
180
+ post: {
181
+ operationId: 'postTerminalsByIdInput',
182
+ summary: 'Send input to terminal',
183
+ description: 'Write data to terminal stdin',
184
+ parameters: [
185
+ {
186
+ name: 'id',
187
+ in: 'path',
188
+ required: true,
189
+ schema: { type: 'string' },
190
+ },
191
+ ],
192
+ requestBody: {
193
+ required: true,
194
+ content: {
195
+ 'application/json': {
196
+ schema: {
197
+ type: 'object',
198
+ required: ['input'],
199
+ properties: {
200
+ input: {
201
+ type: 'string',
202
+ description: 'Input to send to terminal',
203
+ },
204
+ },
205
+ },
206
+ },
207
+ },
208
+ },
209
+ responses: {
210
+ '200': {
211
+ description: 'Input sent',
212
+ content: {
213
+ 'application/json': {
214
+ schema: {
215
+ type: 'object',
216
+ properties: {
217
+ success: { type: 'boolean' },
218
+ },
219
+ },
220
+ },
221
+ },
222
+ },
223
+ },
224
+ },
225
+ },
226
+ };