@cogitator-ai/tetsu 0.5.25 → 0.6.0
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/README.md +97 -49
- package/dist/auth.d.ts +8 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +14 -0
- package/dist/auth.js.map +1 -1
- package/dist/controller.d.ts +33 -30
- package/dist/controller.d.ts.map +1 -1
- package/dist/controller.js +56 -39
- package/dist/controller.js.map +1 -1
- package/dist/errors.d.ts +11 -5
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +27 -20
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/operations.d.ts +18 -6
- package/dist/operations.d.ts.map +1 -1
- package/dist/operations.js +27 -14
- package/dist/operations.js.map +1 -1
- package/dist/schemas.d.ts +23 -3
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +70 -19
- package/dist/schemas.js.map +1 -1
- package/dist/socket.d.ts +15 -6
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +29 -15
- package/dist/socket.js.map +1 -1
- package/dist/types.d.ts +30 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -59,7 +59,10 @@ A Tetsu controller named `Cogitator`: `operationId`s in the OpenAPI document are
|
|
|
59
59
|
| `workflows` | `Record<string, Workflow>` | Workflows by name |
|
|
60
60
|
| `swarms` | `Record<string, SwarmConfig>` | Swarms by name |
|
|
61
61
|
| `auth` | `(ctx) => AuthContext \| undefined` or hook | Establishes the caller, see [Authentication](#authentication) |
|
|
62
|
+
| `anonymous` | `'allow' \| 'deny'` | Whether callers without a `userId` may use the API (default `'allow'`), see [Anonymous callers](#anonymous-callers) |
|
|
62
63
|
| `authorizeThread` | `(auth, threadId) => boolean` | Decides who may use a memory thread, see [Users and threads](#users-and-threads) |
|
|
64
|
+
| `limits` | `RunLimits` | Caps on what a request may ask a swarm or workflow run for, see [Run limits](#run-limits) |
|
|
65
|
+
| `deps` | `(ctx) => unknown \| Promise<unknown>` | Builds the `deps` agent runs pass to their tools, see [Run deps](#run-deps) |
|
|
63
66
|
| `websocket` | `boolean \| { path?: string }` | Serve the WebSocket endpoint (default path `/ws`) |
|
|
64
67
|
| `until` | `AbortSignal \| (() => AbortSignal)` | Ends open streams and sockets, such as `draining` from `@tetsujs/lifecycle` |
|
|
65
68
|
| `sseHeartbeatMs` | `number` | Heartbeat comment interval of SSE streams (default `5000`, `0` turns it off) |
|
|
@@ -68,26 +71,26 @@ A Tetsu controller named `Cogitator`: `operationId`s in the OpenAPI document are
|
|
|
68
71
|
|
|
69
72
|
## Endpoints
|
|
70
73
|
|
|
71
|
-
| Method | Path | Description
|
|
72
|
-
| -------- | ----------------------------- |
|
|
73
|
-
| `GET` | `/health`, `/ready` | Liveness and readiness, without `auth`
|
|
74
|
-
| `GET` | `/agents` | Agents with their description and tools
|
|
75
|
-
| `POST` | `/agents/:name/run` | Run an agent and wait for the answer
|
|
76
|
-
| `POST` | `/agents/:name/stream` | Run an agent over SSE
|
|
77
|
-
| `POST` | `/agents/:name/resume` | Resume a run paused for approvals
|
|
78
|
-
| `POST` | `/agents/:name/resume/stream` | Resume a paused run over SSE
|
|
79
|
-
| `GET` | `/tools` | Tools of every agent, as JSON Schema
|
|
80
|
-
| `GET` | `/threads/:id` | Messages of a
|
|
81
|
-
| `POST` | `/threads/:id/messages` | Append a message
|
|
82
|
-
| `DELETE` | `/threads/:id` | Delete a thread
|
|
83
|
-
| `GET` | `/workflows` | Workflows with their nodes
|
|
84
|
-
| `POST` | `/workflows/:name/run` | Run a workflow
|
|
85
|
-
| `POST` | `/workflows/:name/stream` | Run a workflow over SSE
|
|
86
|
-
| `GET` | `/swarms` | Swarms with their agents
|
|
87
|
-
| `POST` | `/swarms/:name/run` | Run a swarm
|
|
88
|
-
| `POST` | `/swarms/:name/stream` | Run a swarm over SSE
|
|
89
|
-
| `GET` | `/swarms/:name/blackboard` | Configured blackboard sections
|
|
90
|
-
| `GET` | `/ws` | WebSocket, when `websocket` is set
|
|
74
|
+
| Method | Path | Description |
|
|
75
|
+
| -------- | ----------------------------- | ------------------------------------------------- |
|
|
76
|
+
| `GET` | `/health`, `/ready` | Liveness and readiness, without `auth` |
|
|
77
|
+
| `GET` | `/agents` | Agents with their description and tools |
|
|
78
|
+
| `POST` | `/agents/:name/run` | Run an agent and wait for the answer |
|
|
79
|
+
| `POST` | `/agents/:name/stream` | Run an agent over SSE |
|
|
80
|
+
| `POST` | `/agents/:name/resume` | Resume a run paused for approvals |
|
|
81
|
+
| `POST` | `/agents/:name/resume/stream` | Resume a paused run over SSE |
|
|
82
|
+
| `GET` | `/tools` | Tools of every agent, as JSON Schema |
|
|
83
|
+
| `GET` | `/threads/:id` | Messages of a thread, a page with `?limit&cursor` |
|
|
84
|
+
| `POST` | `/threads/:id/messages` | Append a message |
|
|
85
|
+
| `DELETE` | `/threads/:id` | Delete a thread |
|
|
86
|
+
| `GET` | `/workflows` | Workflows with their nodes |
|
|
87
|
+
| `POST` | `/workflows/:name/run` | Run a workflow |
|
|
88
|
+
| `POST` | `/workflows/:name/stream` | Run a workflow over SSE |
|
|
89
|
+
| `GET` | `/swarms` | Swarms with their agents |
|
|
90
|
+
| `POST` | `/swarms/:name/run` | Run a swarm |
|
|
91
|
+
| `POST` | `/swarms/:name/stream` | Run a swarm over SSE |
|
|
92
|
+
| `GET` | `/swarms/:name/blackboard` | Configured blackboard sections |
|
|
93
|
+
| `GET` | `/ws` | WebSocket, when `websocket` is set |
|
|
91
94
|
|
|
92
95
|
Request bodies:
|
|
93
96
|
|
|
@@ -103,10 +106,10 @@ Request bodies:
|
|
|
103
106
|
}
|
|
104
107
|
|
|
105
108
|
// POST /swarms/:name/run, /swarms/:name/stream
|
|
106
|
-
{ input: string; context?: Record<string, unknown>; threadId?: string; timeout?: number } // timeout at most 2147483647 ms
|
|
109
|
+
{ input: string; context?: Record<string, unknown>; threadId?: string; timeout?: number } // timeout at most 2147483647 ms, held to limits.swarmTimeout
|
|
107
110
|
|
|
108
111
|
// POST /workflows/:name/run, /workflows/:name/stream
|
|
109
|
-
{ input?: Record<string, unknown>; options?: { maxConcurrency?: number; maxIterations?: number; checkpoint?: false } }
|
|
112
|
+
{ input?: Record<string, unknown>; options?: { maxConcurrency?: number; maxIterations?: number; checkpoint?: false } } // held to limits
|
|
110
113
|
|
|
111
114
|
// POST /threads/:id/messages
|
|
112
115
|
{ role: 'user' | 'assistant' | 'system'; content: string; metadata?: Record<string, unknown> } // system only with threadMessageRoles
|
|
@@ -114,6 +117,8 @@ Request bodies:
|
|
|
114
117
|
|
|
115
118
|
The schemas are refined with the validators every Cogitator adapter shares (`@cogitator-ai/server-shared`), so Tetsu refuses the same bodies as Express, Fastify, Hono, Koa and Next, under its own `VALIDATION_FAILED` envelope. A run sends `context` to the model as data the application supplied and the model reads a `system` thread message as operator instructions, so both are refused unless the controller accepts them: `acceptContext` lists the `context` keys clients may send (or `true` for any), and `threadMessageRoles` the roles they may add (`user` and `assistant` by default). A body that is not JSON (`text/plain`, a form) is refused with `415 UNSUPPORTED_MEDIA_TYPE` before it is read, since browsers send those across origins without a CORS preflight. `options.checkpoint: true` is refused: the controller runs each workflow on a fresh executor and keeps no checkpoint store to resume from.
|
|
116
119
|
|
|
120
|
+
`GET /threads/:id` answers the whole thread, or one page of it with `?limit=50`: the newest 50 messages (oldest first within the page) and a `nextCursor`. Pass it back as `?limit=50&cursor=<nextCursor>` for the 50 before them, until an answer has no `nextCursor`. Messages written in the same millisecond are neither skipped nor repeated across pages. A `limit` outside 1 to 1000 or a cursor the server did not give answers `422 VALIDATION_FAILED`.
|
|
121
|
+
|
|
117
122
|
`POST /agents/:name/run` and `/resume` answer `{ output, threadId, usage, toolCalls, status, traceId }` plus, when they apply, `reasoning`, `pendingApprovals`, `structured`, `structuredError`, `truncated`, `blocked` and `iterationLimitReached`: the same object as every other adapter, built by `toAgentRunResponse()` of `@cogitator-ai/server-shared`. It never carries the system prompt, the history, trace spans or the checkpoint of a paused run. Swarm routes close the swarm they build once the run ends, so a distributed swarm leaves no Redis connections behind, and `GET /swarms` lists every agent, a router and pipeline stages included.
|
|
118
123
|
|
|
119
124
|
## Errors
|
|
@@ -124,27 +129,30 @@ Every error is answered in Tetsu's envelope:
|
|
|
124
129
|
{ "status": 404, "message": "Agent 'ghost' not found", "error": "AGENT_NOT_FOUND" }
|
|
125
130
|
```
|
|
126
131
|
|
|
127
|
-
| Status | `error` | When
|
|
128
|
-
| ------- | ---------------------------------------------------------- |
|
|
129
|
-
| 400 | `MALFORMED_JSON` | The body is not valid JSON
|
|
130
|
-
| 401 | `UNAUTHORIZED` | `auth` returned `undefined`,
|
|
131
|
-
| 403 | `THREAD_ACCESS_DENIED` | The thread belongs to another user
|
|
132
|
-
| 403 | `THREAD_FORBIDDEN` | `authorizeThread` refused the thread
|
|
133
|
-
| 404 | `AGENT_NOT_FOUND`, `WORKFLOW_NOT_FOUND`, `SWARM_NOT_FOUND` | No such name
|
|
134
|
-
| 409 | `BLACKBOARD_DISABLED` | The swarm has no blackboard
|
|
135
|
-
| 409 | `RUN_NOT_PAUSED` | A resume named a thread without a paused run
|
|
136
|
-
| 413 | `BODY_TOO_LARGE` | The body is over the application's body limit
|
|
137
|
-
| 415 | `UNSUPPORTED_MEDIA_TYPE` | The body is not JSON (`text/plain`, a form)
|
|
138
|
-
| 499 | `CLIENT_CLOSED_REQUEST` | The client left before a `/run` or `/resume` answer was ready
|
|
139
|
-
| 422 | `VALIDATION_FAILED` | The body or the
|
|
140
|
-
| 501 | `PACKAGE_NOT_INSTALLED` | `@cogitator-ai/workflows` or `@cogitator-ai/swarms` is missing
|
|
141
|
-
| 503 | `MEMORY_NOT_CONFIGURED` | A thread endpoint was called on a runtime with no `memory` config
|
|
142
|
-
|
|
|
143
|
-
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
132
|
+
| Status | `error` | When |
|
|
133
|
+
| ------- | ---------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
134
|
+
| 400 | `MALFORMED_JSON` | The body is not valid JSON |
|
|
135
|
+
| 401 | `UNAUTHORIZED` | `auth` returned `undefined`, threw something other than an `HttpError` (an expired token), or `anonymous: 'deny'` met a caller without `userId` |
|
|
136
|
+
| 403 | `THREAD_ACCESS_DENIED` | The thread belongs to another user |
|
|
137
|
+
| 403 | `THREAD_FORBIDDEN` | `authorizeThread` refused the thread |
|
|
138
|
+
| 404 | `AGENT_NOT_FOUND`, `WORKFLOW_NOT_FOUND`, `SWARM_NOT_FOUND` | No such name |
|
|
139
|
+
| 409 | `BLACKBOARD_DISABLED` | The swarm has no blackboard |
|
|
140
|
+
| 409 | `RUN_NOT_PAUSED` | A resume named a thread without a paused run |
|
|
141
|
+
| 413 | `BODY_TOO_LARGE` | The body is over the application's body limit |
|
|
142
|
+
| 415 | `UNSUPPORTED_MEDIA_TYPE` | The body is not JSON (`text/plain`, a form) |
|
|
143
|
+
| 499 | `CLIENT_CLOSED_REQUEST` | The client left before a `/run` or `/resume` answer was ready |
|
|
144
|
+
| 422 | `VALIDATION_FAILED` | The body, the path or the query failed its schema, a `context` key or a thread message role the controller does not accept, `issues` lists every problem |
|
|
145
|
+
| 501 | `PACKAGE_NOT_INSTALLED` | `@cogitator-ai/workflows` or `@cogitator-ai/swarms` is missing |
|
|
146
|
+
| 503 | `MEMORY_NOT_CONFIGURED` | A thread endpoint was called on a runtime with no `memory` config |
|
|
147
|
+
| 504 | `RUN_TIMEOUT` | A swarm ran past its timeout |
|
|
148
|
+
| 4xx/5xx | the `CogitatorError` code | The run failed, e.g. `429 LLM_RATE_LIMITED` with `Retry-After` |
|
|
149
|
+
| 500 | `INTERNAL_SERVER_ERROR` | Anything else, the detail goes to `reportError`, never to the client |
|
|
150
|
+
|
|
151
|
+
Statuses, codes and `Retry-After` come from the taxonomy every Cogitator adapter shares (`describeHttpError()` of `@cogitator-ai/server-shared`): a `CogitatorError` answers its own `statusCode` or the status of its code, with `Retry-After` in whole seconds when the provider said when to retry, and a swarm that ran out of time answers `504 RUN_TIMEOUT`. Tetsu keeps its own envelope for them.
|
|
152
|
+
|
|
153
|
+
Only a `CogitatorError` and a swarm timeout keep their message and code. Any other error reaches the client only as a generic internal error: `500 INTERNAL_SERVER_ERROR` in JSON, Tetsu's own envelope, and `Internal server error` with code `INTERNAL_ERROR` in stream `error` events and WebSocket errors, the code the streams and sockets of every Cogitator adapter send. The `error` field of workflow `node_error` and swarm `agent_error` events carries the same `Internal server error`. Its text, which can carry connection strings or file paths, never leaves the server.
|
|
154
|
+
|
|
155
|
+
Every route mounts an `onError` hook made by `cogitatorErrors()`. Mount another on the application to answer `CogitatorError`s and swarm timeouts from your own routes the same way:
|
|
148
156
|
|
|
149
157
|
```typescript
|
|
150
158
|
import { cogitatorErrors } from '@cogitator-ai/tetsu';
|
|
@@ -200,6 +208,16 @@ createApp({
|
|
|
200
208
|
});
|
|
201
209
|
```
|
|
202
210
|
|
|
211
|
+
### Anonymous callers
|
|
212
|
+
|
|
213
|
+
By default a caller without a `userId` (no `auth`, or `auth` returned `{}`) may use the API as an anonymous user. With `anonymous: 'deny'` such a caller gets `401 UNAUTHORIZED` on every route and on the WebSocket handshake. `/health` and `/ready` stay open for probes, and so do the `docs()` routes of your application, which the controller does not guard. `auth` returning `undefined` answers `401` under either policy. A path the application does not serve, and a method a path does not take, are answered by the application before any route runs, with Tetsu's own `404` and `405`, so the controller cannot put `auth` in front of them.
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
cogitatorController({ cogitator, agents, auth, anonymous: 'deny' });
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Wrap the caller hook in `secured()`, as above, to have the OpenAPI document describe that `401`.
|
|
220
|
+
|
|
203
221
|
## Users and threads
|
|
204
222
|
|
|
205
223
|
### Multiple users
|
|
@@ -226,7 +244,37 @@ cogitatorController({
|
|
|
226
244
|
});
|
|
227
245
|
```
|
|
228
246
|
|
|
229
|
-
Use it for rules ownership does not express, such as thread ids your server hands out.
|
|
247
|
+
Use it for rules ownership does not express, such as thread ids your server hands out. It runs after the body is validated and before the owner check, on `GET`, `DELETE` and `POST /threads/:id/messages`, agent runs, streams and resumes, swarm runs and streams, and WebSocket runs and resumes, and `false` answers `403 THREAD_FORBIDDEN` without starting a run (an `error` frame with that code over the WebSocket).
|
|
248
|
+
|
|
249
|
+
## Run deps
|
|
250
|
+
|
|
251
|
+
`deps` builds what an agent's tools get as `context.deps`: a database handle, the tenant, a client with the caller's credentials. The model never sees them, and they never come from the request body.
|
|
252
|
+
|
|
253
|
+
```typescript
|
|
254
|
+
cogitatorController({
|
|
255
|
+
cogitator,
|
|
256
|
+
agents,
|
|
257
|
+
auth,
|
|
258
|
+
deps: async (ctx) => ({ db: await pool.connect(), tenant: ctx.req.headers.get('x-tenant') }),
|
|
259
|
+
});
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Agent runs, streams and resumes call it once per request, after `auth` and `authorizeThread`, so an error it throws is answered before a stream opens. A WebSocket connection calls it once, with its handshake, never for each run: every agent run and resume on the connection gets what it built, which lives as long as the connection. A Tetsu context belongs to its request, not to the connection that outlives it. An error it throws refuses the handshake, as `500` unless it is an `HttpError`, and no socket opens.
|
|
263
|
+
|
|
264
|
+
## Run limits
|
|
265
|
+
|
|
266
|
+
`limits` caps what a request may ask a run for: `swarmTimeout` (ms) for swarm runs, `workflowMaxIterations` and `workflowMaxConcurrency` for workflow runs, over HTTP, SSE and WebSocket alike. A request that asks for more is held to the cap, and one that asks for nothing gets the cap. Each limit must be a positive integer, or building the controller throws.
|
|
267
|
+
|
|
268
|
+
```typescript
|
|
269
|
+
cogitatorController({
|
|
270
|
+
cogitator,
|
|
271
|
+
swarms: { research: researchSwarm },
|
|
272
|
+
workflows: { pipeline },
|
|
273
|
+
limits: { swarmTimeout: 120_000, workflowMaxIterations: 50, workflowMaxConcurrency: 4 },
|
|
274
|
+
});
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
The request schemas show each limit as the default of the field it caps, with a description, and not as a `maximum`: a larger value is held to the limit, not refused. A swarm that runs past its timeout answers `504 RUN_TIMEOUT`.
|
|
230
278
|
|
|
231
279
|
## Approvals
|
|
232
280
|
|
|
@@ -285,7 +333,7 @@ data: [DONE]
|
|
|
285
333
|
|
|
286
334
|
An agent with `reasoning: { summary: true }` also streams its reasoning summary as `reasoning-start`, `reasoning-delta` and `reasoning-end` events. A text or reasoning part opens with its first delta and is closed before a part of the other kind, a tool call or `finish`, so parts never overlap and text after a tool call starts a new part. An answer the model gave in one piece arrives as one text part before `finish`, and a resumed run that pauses again sends `approval-required` before `finish`. `POST /agents/:name/run` returns the summary as `reasoning`, and `usage` gains `reasoningTokens`, `cachedInputTokens` and `cacheWriteTokens` when the provider reports them. The `finish` event of an agent stream carries the same `usage` as the JSON answer, these counts included.
|
|
287
335
|
|
|
288
|
-
A run that fails ends with `{"type":"error","message":"…","code":"…"}` instead of `finish`. A `CogitatorError` keeps its message and code, anything else is sent as `"message":"Internal server error","code":"
|
|
336
|
+
A run that fails ends with `{"type":"error","message":"…","code":"…"}` instead of `finish`. A `CogitatorError` keeps its message and code, anything else is sent as `"message":"Internal server error","code":"INTERNAL_ERROR"` and reported to the application's `reportError` with `source: "stream"`. Workflow streams send `workflow` events (`node_started`, `node_completed`, `node_error`, `node_progress`, `workflow_completed`), swarm streams send `swarm` events (`agent_start`, `agent_complete`, `agent_error`, `message`, every event the swarm itself emits under its own name, such as `swarm:start` or `agent:message`, and `swarm_completed`).
|
|
289
337
|
|
|
290
338
|
Validation (`415`, `422`), `401`, `404` and the `403 THREAD_FORBIDDEN` of `authorizeThread` are answered as JSON before the stream opens. Whether the thread belongs to the caller is checked by the run itself, so another user's thread ends an open stream with an `error` event, `"code":"THREAD_ACCESS_DENIED"`, instead of `finish`.
|
|
291
339
|
|
|
@@ -295,7 +343,7 @@ Validation (`415`, `422`), `401`, `404` and the `403 THREAD_FORBIDDEN` of `autho
|
|
|
295
343
|
cogitatorController({ cogitator, agents, auth, websocket: true });
|
|
296
344
|
```
|
|
297
345
|
|
|
298
|
-
The handshake runs `auth` like any route. Each socket runs one agent, workflow or swarm at a time
|
|
346
|
+
The handshake runs `auth` and the `anonymous` policy like any route, and builds the connection's `deps` once: every run and resume on the socket shares them, and none rebuilds them. Workflow and swarm runs are held to `limits`, and runs that name a thread are checked by `authorizeThread`. Each socket runs one agent, workflow or swarm at a time, and a `run` or `resume` sent while one is in progress gets an error with `code: 'RUN_IN_PROGRESS'`.
|
|
299
347
|
|
|
300
348
|
| Client sends | Server answers |
|
|
301
349
|
| ------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -304,7 +352,7 @@ The handshake runs `auth` like any route. Each socket runs one agent, workflow o
|
|
|
304
352
|
| `{ type: 'stop' }` | cancels the current run |
|
|
305
353
|
| `{ type: 'ping', id? }` | `{ type: 'pong', id }` |
|
|
306
354
|
|
|
307
|
-
Errors arrive as `{ type: 'error', id, error, code }` and leave the socket open
|
|
355
|
+
Errors arrive as `{ type: 'error', id, error, code }` and leave the socket open. An invalid frame gets `code: 'INVALID_MESSAGE'`, a swarm that ran out of time `code: 'RUN_TIMEOUT'`, and an error that is not a `CogitatorError` is sent as `Internal server error` with `code: 'INTERNAL_ERROR'`. Closing the socket cancels its run. Bun's server-level options such as `maxPayloadLength` are set where the app is served:
|
|
308
356
|
|
|
309
357
|
```typescript
|
|
310
358
|
Bun.serve({ ...app, websocket: { ...app.websocket, maxPayloadLength: 1024 * 1024 } });
|
|
@@ -328,9 +376,9 @@ shutdown = onShutdownSignals(server);
|
|
|
328
376
|
|
|
329
377
|
## OpenAPI
|
|
330
378
|
|
|
331
|
-
Request and response schemas are Zod, so `docs()` and `openapi()` from `@tetsujs/openapi` describe every route, the run failures a `CogitatorError` can produce, and the schemes of a `secured()` caller hook. SSE and WebSocket endpoints are documented by their description only, since OpenAPI cannot describe what follows the headers.
|
|
379
|
+
Request and response schemas are Zod, so `docs()` and `openapi()` from `@tetsujs/openapi` describe every route, the run failures a `CogitatorError` can produce, the thread page query, the `limits` as field defaults, and the schemes of a `secured()` caller hook. SSE and WebSocket endpoints are documented by their description only, since OpenAPI cannot describe what follows the headers.
|
|
332
380
|
|
|
333
|
-
The request and response schemas (`RunBody`, `ResumeBody`, `AgentRunResponse`, `SocketMessage`, …) and their TypeScript types (`AgentRunRequest`, `AgentRunResponseBody`, `WebSocketClientMessage`, …) are exported for clients and your own routes, along with the error helpers `cogitatorErrorResponse()`, `cogitatorErrorStatus()` and `describeError()
|
|
381
|
+
The request and response schemas (`RunBody`, `ResumeBody`, `AgentRunResponse`, `SocketMessage`, …) and their TypeScript types (`AgentRunRequest`, `AgentRunResponseBody`, `WebSocketClientMessage`, …) are exported for clients and your own routes, along with `ThreadQuery`, the error helpers `cogitatorErrorResponse()`, `cogitatorErrorStatus()` and `describeError()`, and the `RunLimits` and `AnonymousPolicy` types.
|
|
334
382
|
|
|
335
383
|
## Testing
|
|
336
384
|
|
package/dist/auth.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Requires } from '@tetsujs/core';
|
|
2
|
+
import type { AnonymousPolicy } from '@cogitator-ai/server-shared';
|
|
1
3
|
import type { AuthContext, Authenticate, CogitatorDeps } from './types.js';
|
|
2
4
|
/** What the caller hook adds to the context of every guarded route. */
|
|
3
5
|
export interface CallerFields {
|
|
@@ -22,4 +24,10 @@ export type CallerHook = ReturnType<typeof callerHook>;
|
|
|
22
24
|
* so the generated document describes the security scheme and the `401`.
|
|
23
25
|
*/
|
|
24
26
|
export declare function resolveCaller(auth: CogitatorDeps['auth']): CallerHook;
|
|
27
|
+
/**
|
|
28
|
+
* The `beforeParse` hook that runs after the caller hook and turns away a caller without a
|
|
29
|
+
* `userId` with `401 UNAUTHORIZED` when `anonymous` is `'deny'`. Under `'allow'` it lets
|
|
30
|
+
* every caller the caller hook admitted through.
|
|
31
|
+
*/
|
|
32
|
+
export declare function anonymousHook(anonymous: AnonymousPolicy | undefined): import("@tetsujs/core").Hook<"beforeParse", Requires<CallerFields>, unknown>;
|
|
25
33
|
//# sourceMappingURL=auth.d.ts.map
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3E,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE,WAAW,GAAG,SAAS,CAAC;CACxC;AASD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,SAAS;;;;wCAehE;AAWD,4EAA4E;AAC5E,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAEvD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,UAAU,CAErE"}
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3E,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE,WAAW,GAAG,SAAS,CAAC;CACxC;AASD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,SAAS;;;;wCAehE;AAWD,4EAA4E;AAC5E,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAEvD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,UAAU,CAErE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,eAAe,GAAG,SAAS,gFAKnE"}
|
package/dist/auth.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { hook, HttpError, httpError } from '@tetsujs/core';
|
|
2
|
+
import { admitCaller } from '@cogitator-ai/server-shared';
|
|
3
|
+
import { refusalError } from './errors.js';
|
|
2
4
|
const ANONYMOUS = { cogitatorAuth: undefined };
|
|
3
5
|
function admit(auth) {
|
|
4
6
|
if (!auth)
|
|
@@ -45,4 +47,16 @@ function refusal(error) {
|
|
|
45
47
|
export function resolveCaller(auth) {
|
|
46
48
|
return typeof auth === 'function' || auth === undefined ? callerHook(auth) : auth;
|
|
47
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* The `beforeParse` hook that runs after the caller hook and turns away a caller without a
|
|
52
|
+
* `userId` with `401 UNAUTHORIZED` when `anonymous` is `'deny'`. Under `'allow'` it lets
|
|
53
|
+
* every caller the caller hook admitted through.
|
|
54
|
+
*/
|
|
55
|
+
export function anonymousHook(anonymous) {
|
|
56
|
+
return hook.beforeParse((ctx) => {
|
|
57
|
+
const refusal = admitCaller(ctx.cogitatorAuth?.userId, anonymous);
|
|
58
|
+
if (refusal)
|
|
59
|
+
throw refusalError(refusal);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
48
62
|
//# sourceMappingURL=auth.js.map
|
package/dist/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAQ3C,MAAM,SAAS,GAAiB,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC;AAE7D,SAAS,KAAK,CAAC,IAA6B;IAC1C,IAAI,CAAC,IAAI;QAAE,MAAM,SAAS,CAAC,GAAG,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;IAChE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;AACjC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,YAAsC;IAC/D,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,EAAwC,EAAE;QACpE,IAAI,CAAC,YAAY;YAAE,OAAO,EAAE,GAAG,SAAS,EAAE,CAAC;QAC3C,IAAI,IAA8B,CAAC;QACnC,IAAI,CAAC;YACH,IAAI,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,IAAI,YAAY,OAAO;YAC5B,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAc,EAAE,EAAE;gBAClC,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC,CAAC;YACJ,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,SAAS,OAAO,CAAC,KAAc;IAC7B,OAAO,KAAK,YAAY,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;AAC7F,CAAC;AAKD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,IAA2B;IACvD,OAAO,OAAO,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACpF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,SAAsC;IAClE,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,GAA2B,EAAE,EAAE;QACtD,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QAClE,IAAI,OAAO;YAAE,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/controller.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Message } from '@cogitator-ai/types';
|
|
2
1
|
import type { z } from 'zod';
|
|
3
2
|
import type { CogitatorDeps } from './types.js';
|
|
4
3
|
/**
|
|
@@ -61,7 +60,11 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
61
60
|
readonly params: {
|
|
62
61
|
[x: string]: string;
|
|
63
62
|
};
|
|
64
|
-
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth"
|
|
63
|
+
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").Requires<import("./auth.js").CallerFields>, unknown>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").BaseCtx & {
|
|
64
|
+
readonly params: {
|
|
65
|
+
[x: string]: string;
|
|
66
|
+
};
|
|
67
|
+
}, Pick<import("./socket.js").ConnectionDeps, "cogitatorDeps">>];
|
|
65
68
|
}> | undefined;
|
|
66
69
|
health: import("@tetsujs/core").RouteDef<"/health", {
|
|
67
70
|
readonly response: z.ZodObject<{
|
|
@@ -102,7 +105,7 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
102
105
|
readonly params: {
|
|
103
106
|
[x: string]: string;
|
|
104
107
|
};
|
|
105
|
-
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth"
|
|
108
|
+
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").Requires<import("./auth.js").CallerFields>, unknown>];
|
|
106
109
|
readonly onError: readonly [import("@tetsujs/core").Hook<"onError", import("@tetsujs/core").BaseCtx & {
|
|
107
110
|
readonly error: unknown;
|
|
108
111
|
}, unknown>];
|
|
@@ -249,7 +252,7 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
249
252
|
readonly params: {
|
|
250
253
|
[x: string]: string;
|
|
251
254
|
};
|
|
252
|
-
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").BaseCtx & {
|
|
255
|
+
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").Requires<import("./auth.js").CallerFields>, unknown>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").BaseCtx & {
|
|
253
256
|
readonly params: {
|
|
254
257
|
[x: string]: string;
|
|
255
258
|
};
|
|
@@ -293,7 +296,7 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
293
296
|
readonly params: {
|
|
294
297
|
[x: string]: string;
|
|
295
298
|
};
|
|
296
|
-
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").BaseCtx & {
|
|
299
|
+
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").Requires<import("./auth.js").CallerFields>, unknown>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").BaseCtx & {
|
|
297
300
|
readonly params: {
|
|
298
301
|
[x: string]: string;
|
|
299
302
|
};
|
|
@@ -444,7 +447,7 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
444
447
|
readonly params: {
|
|
445
448
|
[x: string]: string;
|
|
446
449
|
};
|
|
447
|
-
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").BaseCtx & {
|
|
450
|
+
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").Requires<import("./auth.js").CallerFields>, unknown>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").BaseCtx & {
|
|
448
451
|
readonly params: {
|
|
449
452
|
[x: string]: string;
|
|
450
453
|
};
|
|
@@ -494,7 +497,7 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
494
497
|
readonly params: {
|
|
495
498
|
[x: string]: string;
|
|
496
499
|
};
|
|
497
|
-
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").BaseCtx & {
|
|
500
|
+
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").Requires<import("./auth.js").CallerFields>, unknown>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").BaseCtx & {
|
|
498
501
|
readonly params: {
|
|
499
502
|
[x: string]: string;
|
|
500
503
|
};
|
|
@@ -507,6 +510,10 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
507
510
|
readonly params: z.ZodObject<{
|
|
508
511
|
id: z.ZodString;
|
|
509
512
|
}, z.core.$strip>;
|
|
513
|
+
readonly query: z.ZodPreprocess<z.ZodObject<{
|
|
514
|
+
limit: z.ZodOptional<z.ZodInt>;
|
|
515
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
516
|
+
}, z.core.$strip>, unknown>;
|
|
510
517
|
readonly response: {
|
|
511
518
|
readonly 200: z.ZodObject<{
|
|
512
519
|
id: z.ZodString;
|
|
@@ -547,6 +554,7 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
547
554
|
}, z.core.$strip>>;
|
|
548
555
|
createdAt: z.ZodNumber;
|
|
549
556
|
updatedAt: z.ZodNumber;
|
|
557
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
550
558
|
}, z.core.$strip>;
|
|
551
559
|
readonly 403: z.ZodObject<{
|
|
552
560
|
status: z.ZodNumber;
|
|
@@ -573,16 +581,11 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
573
581
|
readonly params: {
|
|
574
582
|
[x: string]: string;
|
|
575
583
|
};
|
|
576
|
-
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth"
|
|
584
|
+
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").Requires<import("./auth.js").CallerFields>, unknown>];
|
|
577
585
|
readonly onError: readonly [import("@tetsujs/core").Hook<"onError", import("@tetsujs/core").BaseCtx & {
|
|
578
586
|
readonly error: unknown;
|
|
579
587
|
}, unknown>];
|
|
580
|
-
}, undefined, "GET", Promise<
|
|
581
|
-
id: string;
|
|
582
|
-
messages: Message[];
|
|
583
|
-
createdAt: number;
|
|
584
|
-
updatedAt: number;
|
|
585
|
-
}>, false>;
|
|
588
|
+
}, undefined, "GET", Promise<import("@cogitator-ai/server-shared").ThreadPage>, false>;
|
|
586
589
|
addThreadMessage: import("@tetsujs/core").RouteDef<"/threads/:id/messages", {
|
|
587
590
|
readonly params: z.ZodObject<{
|
|
588
591
|
id: z.ZodString;
|
|
@@ -630,7 +633,7 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
630
633
|
readonly params: {
|
|
631
634
|
[x: string]: string;
|
|
632
635
|
};
|
|
633
|
-
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").BaseCtx & {
|
|
636
|
+
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").Requires<import("./auth.js").CallerFields>, unknown>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").BaseCtx & {
|
|
634
637
|
readonly params: {
|
|
635
638
|
[x: string]: string;
|
|
636
639
|
};
|
|
@@ -672,7 +675,7 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
672
675
|
readonly params: {
|
|
673
676
|
[x: string]: string;
|
|
674
677
|
};
|
|
675
|
-
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth"
|
|
678
|
+
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").Requires<import("./auth.js").CallerFields>, unknown>];
|
|
676
679
|
readonly onError: readonly [import("@tetsujs/core").Hook<"onError", import("@tetsujs/core").BaseCtx & {
|
|
677
680
|
readonly error: unknown;
|
|
678
681
|
}, unknown>];
|
|
@@ -690,7 +693,7 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
690
693
|
readonly params: {
|
|
691
694
|
[x: string]: string;
|
|
692
695
|
};
|
|
693
|
-
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth"
|
|
696
|
+
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").Requires<import("./auth.js").CallerFields>, unknown>];
|
|
694
697
|
readonly onError: readonly [import("@tetsujs/core").Hook<"onError", import("@tetsujs/core").BaseCtx & {
|
|
695
698
|
readonly error: unknown;
|
|
696
699
|
}, unknown>];
|
|
@@ -714,7 +717,7 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
714
717
|
readonly params: {
|
|
715
718
|
[x: string]: string;
|
|
716
719
|
};
|
|
717
|
-
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth"
|
|
720
|
+
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").Requires<import("./auth.js").CallerFields>, unknown>];
|
|
718
721
|
readonly onError: readonly [import("@tetsujs/core").Hook<"onError", import("@tetsujs/core").BaseCtx & {
|
|
719
722
|
readonly error: unknown;
|
|
720
723
|
}, unknown>];
|
|
@@ -732,9 +735,9 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
732
735
|
readonly body: z.ZodObject<{
|
|
733
736
|
input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
734
737
|
options: z.ZodOptional<z.ZodObject<{
|
|
735
|
-
maxConcurrency: z.ZodOptional<z.ZodNumber>;
|
|
736
|
-
maxIterations: z.ZodOptional<z.ZodNumber>;
|
|
737
738
|
checkpoint: z.ZodOptional<z.ZodLiteral<false>>;
|
|
739
|
+
maxConcurrency: z.ZodOptional<z.ZodNumber> | z.ZodDefault<z.ZodNumber>;
|
|
740
|
+
maxIterations: z.ZodOptional<z.ZodNumber> | z.ZodDefault<z.ZodNumber>;
|
|
738
741
|
}, z.core.$strip>>;
|
|
739
742
|
}, z.core.$strip>;
|
|
740
743
|
readonly response: {
|
|
@@ -836,7 +839,7 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
836
839
|
readonly params: {
|
|
837
840
|
[x: string]: string;
|
|
838
841
|
};
|
|
839
|
-
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").BaseCtx & {
|
|
842
|
+
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").Requires<import("./auth.js").CallerFields>, unknown>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").BaseCtx & {
|
|
840
843
|
readonly params: {
|
|
841
844
|
[x: string]: string;
|
|
842
845
|
};
|
|
@@ -862,9 +865,9 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
862
865
|
readonly body: z.ZodObject<{
|
|
863
866
|
input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
864
867
|
options: z.ZodOptional<z.ZodObject<{
|
|
865
|
-
maxConcurrency: z.ZodOptional<z.ZodNumber>;
|
|
866
|
-
maxIterations: z.ZodOptional<z.ZodNumber>;
|
|
867
868
|
checkpoint: z.ZodOptional<z.ZodLiteral<false>>;
|
|
869
|
+
maxConcurrency: z.ZodOptional<z.ZodNumber> | z.ZodDefault<z.ZodNumber>;
|
|
870
|
+
maxIterations: z.ZodOptional<z.ZodNumber> | z.ZodDefault<z.ZodNumber>;
|
|
868
871
|
}, z.core.$strip>>;
|
|
869
872
|
}, z.core.$strip>;
|
|
870
873
|
readonly response: {
|
|
@@ -885,7 +888,7 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
885
888
|
readonly params: {
|
|
886
889
|
[x: string]: string;
|
|
887
890
|
};
|
|
888
|
-
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").BaseCtx & {
|
|
891
|
+
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").Requires<import("./auth.js").CallerFields>, unknown>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").BaseCtx & {
|
|
889
892
|
readonly params: {
|
|
890
893
|
[x: string]: string;
|
|
891
894
|
};
|
|
@@ -907,7 +910,7 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
907
910
|
readonly params: {
|
|
908
911
|
[x: string]: string;
|
|
909
912
|
};
|
|
910
|
-
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth"
|
|
913
|
+
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").Requires<import("./auth.js").CallerFields>, unknown>];
|
|
911
914
|
readonly onError: readonly [import("@tetsujs/core").Hook<"onError", import("@tetsujs/core").BaseCtx & {
|
|
912
915
|
readonly error: unknown;
|
|
913
916
|
}, unknown>];
|
|
@@ -926,7 +929,7 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
926
929
|
input: z.ZodString;
|
|
927
930
|
context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
928
931
|
threadId: z.ZodOptional<z.ZodString>;
|
|
929
|
-
timeout: z.ZodOptional<z.ZodNumber>;
|
|
932
|
+
timeout: z.ZodOptional<z.ZodNumber> | z.ZodDefault<z.ZodNumber>;
|
|
930
933
|
}, z.core.$strip>;
|
|
931
934
|
readonly response: {
|
|
932
935
|
readonly 200: z.ZodObject<{
|
|
@@ -1045,7 +1048,7 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
1045
1048
|
readonly params: {
|
|
1046
1049
|
[x: string]: string;
|
|
1047
1050
|
};
|
|
1048
|
-
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").BaseCtx & {
|
|
1051
|
+
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").Requires<import("./auth.js").CallerFields>, unknown>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").BaseCtx & {
|
|
1049
1052
|
readonly params: {
|
|
1050
1053
|
[x: string]: string;
|
|
1051
1054
|
};
|
|
@@ -1083,7 +1086,7 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
1083
1086
|
input: z.ZodString;
|
|
1084
1087
|
context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1085
1088
|
threadId: z.ZodOptional<z.ZodString>;
|
|
1086
|
-
timeout: z.ZodOptional<z.ZodNumber>;
|
|
1089
|
+
timeout: z.ZodOptional<z.ZodNumber> | z.ZodDefault<z.ZodNumber>;
|
|
1087
1090
|
}, z.core.$strip>;
|
|
1088
1091
|
readonly response: {
|
|
1089
1092
|
readonly 200: null;
|
|
@@ -1110,7 +1113,7 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
1110
1113
|
readonly params: {
|
|
1111
1114
|
[x: string]: string;
|
|
1112
1115
|
};
|
|
1113
|
-
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").BaseCtx & {
|
|
1116
|
+
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").Requires<import("./auth.js").CallerFields>, unknown>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").BaseCtx & {
|
|
1114
1117
|
readonly params: {
|
|
1115
1118
|
[x: string]: string;
|
|
1116
1119
|
};
|
|
@@ -1143,7 +1146,7 @@ export declare const cogitatorController: (deps: CogitatorDeps) => {
|
|
|
1143
1146
|
readonly params: {
|
|
1144
1147
|
[x: string]: string;
|
|
1145
1148
|
};
|
|
1146
|
-
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth"
|
|
1149
|
+
}, Pick<import("./auth.js").CallerFields, "cogitatorAuth">>, import("@tetsujs/core").Hook<"beforeParse", import("@tetsujs/core").Requires<import("./auth.js").CallerFields>, unknown>];
|
|
1147
1150
|
readonly onError: readonly [import("@tetsujs/core").Hook<"onError", import("@tetsujs/core").BaseCtx & {
|
|
1148
1151
|
readonly error: unknown;
|
|
1149
1152
|
}, unknown>];
|
package/dist/controller.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../src/controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../src/controller.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiD7B,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,YAAY,CAAC;AAqE7D;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAye9B,CAAC"}
|