@cogitator-ai/openai-compat 21.2.13 → 21.3.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.
Files changed (46) hide show
  1. package/README.md +88 -10
  2. package/dist/client/openai-adapter.d.ts +61 -19
  3. package/dist/client/openai-adapter.d.ts.map +1 -1
  4. package/dist/client/openai-adapter.js +270 -77
  5. package/dist/client/openai-adapter.js.map +1 -1
  6. package/dist/client/pagination.d.ts +26 -0
  7. package/dist/client/pagination.d.ts.map +1 -0
  8. package/dist/client/pagination.js +34 -0
  9. package/dist/client/pagination.js.map +1 -0
  10. package/dist/client/run-steps.d.ts +66 -0
  11. package/dist/client/run-steps.d.ts.map +1 -0
  12. package/dist/client/run-steps.js +210 -0
  13. package/dist/client/run-steps.js.map +1 -0
  14. package/dist/client/storage.d.ts +44 -4
  15. package/dist/client/storage.d.ts.map +1 -1
  16. package/dist/client/storage.js +111 -7
  17. package/dist/client/storage.js.map +1 -1
  18. package/dist/client/thread-manager.d.ts +36 -3
  19. package/dist/client/thread-manager.d.ts.map +1 -1
  20. package/dist/client/thread-manager.js +49 -34
  21. package/dist/client/thread-manager.js.map +1 -1
  22. package/dist/index.d.ts +4 -2
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +1 -0
  25. package/dist/index.js.map +1 -1
  26. package/dist/server/api-server.d.ts +4 -0
  27. package/dist/server/api-server.d.ts.map +1 -1
  28. package/dist/server/api-server.js +1 -0
  29. package/dist/server/api-server.js.map +1 -1
  30. package/dist/server/middleware/auth.d.ts +13 -1
  31. package/dist/server/middleware/auth.d.ts.map +1 -1
  32. package/dist/server/middleware/auth.js +12 -5
  33. package/dist/server/middleware/auth.js.map +1 -1
  34. package/dist/server/routes/runs.d.ts.map +1 -1
  35. package/dist/server/routes/runs.js +45 -11
  36. package/dist/server/routes/runs.js.map +1 -1
  37. package/dist/server/routes/shared.d.ts +1 -15
  38. package/dist/server/routes/shared.d.ts.map +1 -1
  39. package/dist/server/routes/shared.js +1 -23
  40. package/dist/server/routes/shared.js.map +1 -1
  41. package/dist/server/routes/threads.d.ts.map +1 -1
  42. package/dist/server/routes/threads.js +14 -26
  43. package/dist/server/routes/threads.js.map +1 -1
  44. package/dist/types/openai-types.d.ts +23 -2
  45. package/dist/types/openai-types.d.ts.map +1 -1
  46. package/package.json +6 -6
package/README.md CHANGED
@@ -23,13 +23,13 @@ pnpm add openai
23
23
  - **Responses** - `POST /v1/responses` with the streaming events of the API, `previous_response_id`, function calls, and `GET` / `DELETE` of stored responses
24
24
  - **Agents as models** - `model` names a registered agent, which answers with its own instructions, model and tools. `GET /v1/models` lists them
25
25
  - **Client functions** - Functions a client declares come back as tool calls, and the outputs it sends resume the same run
26
- - **Assistants API (deprecated)** - Assistants, threads, messages, runs and files over pluggable storage (in-memory, Redis, PostgreSQL)
26
+ - **Assistants API (deprecated)** - Assistants, threads, messages, runs, run steps and files over pluggable storage (in-memory, Redis, PostgreSQL)
27
27
  - **OpenAI errors** - Every error in the OpenAI error format, with the parameter at fault
28
- - **Authentication** - Optional API keys (constant-time check, `/health` stays public)
28
+ - **Authentication** - Optional API keys (constant-time check, `/health` stays public), with threads and runs scoped to the key that created them
29
29
  - **Abort on disconnect** - A client that goes away stops the agent run
30
30
  - **CORS** - Configurable cross-origin requests
31
31
 
32
- There are no run steps or vector stores, and `code_interpreter` and `file_search` assistant tools are stored but not executed.
32
+ There are no vector stores, and `code_interpreter` and `file_search` assistant tools are stored but not executed.
33
33
 
34
34
  ---
35
35
 
@@ -249,7 +249,7 @@ const server = new OpenAIServer(cogitator, {
249
249
  | ---------------------------------- | ------------------------------- | -------------------------------------- | --------------------------------------------------------------------------- |
250
250
  | `port` | `number` | `8080` | Port to listen on (`0` picks a free port) |
251
251
  | `host` | `string` | `'127.0.0.1'` | Host to bind to. A public host needs `apiKeys` |
252
- | `apiKeys` | `string[]` | `[]` | API keys for authentication. Empty disables auth |
252
+ | `apiKeys` | `string[]` | `[]` | API keys for authentication, scoping threads and runs. Empty disables auth |
253
253
  | `allowUnauthenticatedPublicAccess` | `boolean` | `false` | Serve a public host without `apiKeys` (behind a gateway that authenticates) |
254
254
  | `sseHeartbeatMs` | `number` | `5000` | Heartbeat comment interval on streams, `0` turns it off |
255
255
  | `agents` | `Record<string, Agent>` | `{}` | Agents served by Chat Completions and Responses, by model id |
@@ -289,6 +289,16 @@ For tests without a listening socket, `await server.waitUntilReady()` and then c
289
289
 
290
290
  With `apiKeys` set, every request except `GET /health` needs `Authorization: Bearer <key>`. A missing header answers `401` with code `missing_api_key`; a malformed header or unknown key answers `401` with code `invalid_api_key`.
291
291
 
292
+ #### Threads and runs per key
293
+
294
+ A request that authenticates with a key carries `request.apiKeyOwner`, the sha256 hex digest of the key (the key itself is never stored). Threads (`POST /v1/threads`, `POST /v1/threads/runs`) keep that owner in storage, and runs keep it in memory. Another key gets `404 not_found` for the thread, its messages, its runs and their steps, the same answer as for an id that does not exist, so it cannot tell that the thread exists. Listing the runs of a thread shows only the runs of the caller's key.
295
+
296
+ - Threads stored before this scoping have no owner and stay reachable by every key, as before. Runs created on them still belong to the key that created them.
297
+ - Without `apiKeys` nothing is scoped.
298
+ - Assistants, files and stored responses are shared by every key.
299
+
300
+ `apiKeyOwner(key)` (exported) gives the owner of a key, for instance to list its threads from storage (see [Listing threads](#listing-threads)).
301
+
292
302
  ### Health Check
293
303
 
294
304
  ```bash
@@ -397,8 +407,36 @@ Runs use the whole thread as context (earlier messages are replayed to the agent
397
407
 
398
408
  `streamRunEvents(runId, fromIndex = 0)` replays the run's event log from `fromIndex` and ends after the next `done` event. `getRunEventCursor(runId)` returns the current log position (use it before `submitToolOutputs` to stream only the continuation), and `getStreamEmitter(runId)` exposes the raw `EventEmitter`. Token deltas are emitted only for runs created with `stream: true`.
399
409
 
410
+ Each thread, message and run method takes the caller's owner as its last argument (`adapter.getThread(id, owner)`, `adapter.createRun(threadId, request, owner)`, ...): a thread or run of another owner is treated as missing. Leave it out for unscoped access, which is what the server does without `apiKeys`.
411
+
400
412
  Runs live in the adapter's memory, unlike assistants, threads, messages and files, which go to `storage`. Poll, cancel or submit tool outputs to a run on the same process that created it: with several processes, run a single instance or route each thread to the same one (sticky routing).
401
413
 
414
+ ### Run Steps
415
+
416
+ Every run records its steps, as the Assistants API does:
417
+
418
+ - a `tool_calls` step for each model turn that called tools, with each call's `id`, `name`, `arguments` and `output` (`null` until the output is known). A step whose calls wait on the client stays `in_progress` while the run is in `requires_action`, and completes with the submitted outputs after `submit_tool_outputs`.
419
+ - a `message_creation` step for each assistant message, with its `message_id`. A run writes one message per model turn that answered with text: a turn that writes "Let me check." and then calls a tool stores that text as its own completed message (and completes its step) before the `tool_calls` step opens, so steps never overlap and the stored messages hold exactly the streamed text. A run without `stream: true` stores the same messages and steps, taking each turn's text as the run's middleware leaves it, also when the turn calls a client function and the run waits in `requires_action`.
420
+
421
+ Steps carry `created_at` / `completed_at` / `failed_at` / `cancelled_at` / `expired_at` (unix seconds) and `usage`: the tokens of the model call that produced the step, when the agent run reports them (a turn that wrote text and then called tools counts toward its message, the first step it produced), or the run's usage when the run has a single step. When the run is cancelled, expires or fails, the steps still in progress end `cancelled`, `expired` or `failed` (with the run's `last_error`), and a message the run had started streaming is kept with `status: 'incomplete'` and `incomplete_details.reason` `run_cancelled`, `run_expired` or `run_failed`. `thread.message.completed` goes out once the message is stored, so a client that reads the message on that event finds it, and a run reaches `requires_action` only once the messages before the pause are stored. A store that fails, or a thread deleted while the run writes to it, fails the run: that message ends `incomplete` with `run_failed` and its `message_creation` step `failed`.
422
+
423
+ ```typescript
424
+ const steps = await openai.beta.threads.runs.steps.list(run.id, { thread_id: thread.id });
425
+
426
+ for (const step of steps.data) {
427
+ if (step.step_details.type === 'tool_calls') {
428
+ for (const call of step.step_details.tool_calls) {
429
+ if (call.type === 'function') console.log(call.function.name, call.function.output);
430
+ }
431
+ }
432
+ }
433
+
434
+ const inProcess = adapter.listRunSteps(thread.id, run.id); // oldest first, undefined for an unknown run
435
+ const one = adapter.getRunStep(thread.id, run.id, steps.data[0].id);
436
+ ```
437
+
438
+ Steps are kept with their run, so they live in memory and leave with it (`maxStoredRuns`). The `include[]` parameter of the step endpoints is accepted and ignored, since there are no `file_search` results.
439
+
402
440
  ### Tool Outputs
403
441
 
404
442
  Server-side `tools` run inside Cogitator. Assistant tools of type `function` are executed by the API client: when the model calls one, the run moves to `requires_action` with the pending calls, and continues after all outputs are submitted (runs waiting longer than 10 minutes expire). Outputs must cover every pending call; missing or unknown `tool_call_id`s are rejected. With the OpenAI SDK use `submitToolOutputsAndPoll` / `submitToolOutputsStream`.
@@ -585,7 +623,7 @@ const storage = new PostgresThreadStorage({
585
623
  schema: 'public', // default: 'public'
586
624
  tableName: 'openai_compat_data', // default: 'openai_compat_data'
587
625
  });
588
- await storage.connect(); // creates the table and index if missing
626
+ await storage.connect(); // creates the table and its indexes if missing
589
627
 
590
628
  const manager = new ThreadManager(storage);
591
629
 
@@ -646,7 +684,7 @@ interface ThreadStorage {
646
684
  saveThread(id: string, thread: StoredThread): Promise<void>;
647
685
  loadThread(id: string): Promise<StoredThread | null>;
648
686
  deleteThread(id: string): Promise<boolean>;
649
- listThreads(): Promise<StoredThread[]>;
687
+ listThreads(options?: ListStoredThreadsOptions): Promise<StoredThreadPage>;
650
688
 
651
689
  // Assistants
652
690
  saveAssistant(id: string, assistant: StoredAssistant): Promise<void>;
@@ -666,7 +704,36 @@ interface ThreadStorage {
666
704
  }
667
705
  ```
668
706
 
669
- `StoredThread` is `{ thread: Thread; messages: Message[] }`; `StoredFile` is `{ id, content: Buffer, filename, created_at, purpose? }`.
707
+ `StoredThread` is `{ thread: Thread; messages: Message[]; owner?: string }`, `owner` being the digest of the API key that created the thread. `StoredFile` is `{ id, content: Buffer, filename, created_at, purpose? }`.
708
+
709
+ ### Listing threads
710
+
711
+ The Assistants API has no route that lists threads, so `listThreads` is for operators, on the storage or on `ThreadManager`:
712
+
713
+ ```typescript
714
+ import { apiKeyOwner } from '@cogitator-ai/openai-compat';
715
+
716
+ const first = await storage.listThreads({ owner: apiKeyOwner('sk-key1'), limit: 50 });
717
+ const next = await storage.listThreads({
718
+ owner: apiKeyOwner('sk-key1'),
719
+ limit: 50,
720
+ cursor: first.nextCursor,
721
+ });
722
+ const unowned = await storage.listThreads({ owner: null }); // threads stored before key scoping
723
+ ```
724
+
725
+ | Option | Default | Meaning |
726
+ | -------- | -------- | ------------------------------------------------------------------------------ |
727
+ | `owner` | all | Threads of this owner only, `null` for the threads without one |
728
+ | `limit` | `50` | Threads per page, from 1 to 500 (`RangeError` otherwise) |
729
+ | `cursor` | - | `nextCursor` of the page before, with the same filters and order |
730
+ | `order` | `'desc'` | By creation time, then id: `desc` starts with the newest threads, `asc` oldest |
731
+
732
+ A page is `{ threads, nextCursor? }`, `nextCursor` being absent on the last page. A cursor the storage did not hand out throws `TypeError`. What a page costs depends on the backend:
733
+
734
+ - **In-memory**: filters and sorts the threads of the process.
735
+ - **PostgreSQL**: `WHERE`, `ORDER BY` and `LIMIT` in SQL, served by the partial index `idx_<table>_thread_owner` on (owner, creation time, id) that `connect()` creates. Ids compare with `COLLATE "C"`, the code unit order the other backends use, whatever the database collation. A listing without `owner` reads every thread row.
736
+ - **Redis**: threads are plain keys with a TTL and no index, so every page reads all thread keys (`SCAN` + `MGET`, messages included) and sorts them in memory. That is fine for an occasional listing, use PostgreSQL when there are many threads.
670
737
 
671
738
  ### Custom Storage Implementation
672
739
 
@@ -687,7 +754,7 @@ const manager = new ThreadManager(new MyCustomStorage());
687
754
 
688
755
  ## Supported Endpoints
689
756
 
690
- All endpoints except `/health` live under `/v1`. List endpoints for assistants, messages and runs accept `limit` (1-100, default 20), `order` (`asc` / `desc`, default `desc`), `after` and `before`, and return `{ object: 'list', data, first_id, last_id, has_more }`. `GET /v1/files` accepts `limit` (1-10 000, default 10 000), `order` (default `desc`) and `after`, plus a `purpose` filter.
757
+ All endpoints except `/health` live under `/v1`. List endpoints for assistants, messages and runs accept `limit` (1-100, default 20), `order` (`asc` / `desc`, default `desc`), `after` and `before`, and return `{ object: 'list', data, first_id, last_id, has_more }`. `after` gives the items right after the cursor and `before` the items right before it, both in list order, and `has_more` tells whether more items lie beyond the page, away from the cursor. `GET /v1/files` accepts `limit` (1-10 000, default 10 000), `order` (default `desc`) and `after`, plus a `purpose` filter.
691
758
 
692
759
  ### Models
693
760
 
@@ -746,8 +813,10 @@ The Assistants API endpoints below are deprecated.
746
813
  | GET | `/v1/threads/:id/runs/:run_id` | Get run status |
747
814
  | POST | `/v1/threads/:id/runs/:run_id/cancel` | Cancel run |
748
815
  | POST | `/v1/threads/:id/runs/:run_id/submit_tool_outputs` | Submit tool outputs |
816
+ | GET | `/v1/threads/:id/runs/:run_id/steps` | List run steps |
817
+ | GET | `/v1/threads/:id/runs/:run_id/steps/:step_id` | Get run step |
749
818
 
750
- The create and `submit_tool_outputs` endpoints stream SSE when the body has `stream: true`.
819
+ The create and `submit_tool_outputs` endpoints stream SSE when the body has `stream: true`. Run steps are listed like the other lists (`limit`, `order`, `after`, `before`). There is no `GET /v1/threads`, as in the OpenAI API: operators list threads from storage.
751
820
 
752
821
  ### Files
753
822
 
@@ -912,7 +981,7 @@ for await (const event of run) {
912
981
 
913
982
  ### Stream Events
914
983
 
915
- The server emits these events (the exported `StreamEventType` union also lists run-step events, which are not emitted):
984
+ The server emits these events:
916
985
 
917
986
  ```typescript
918
987
  type EmittedEvent =
@@ -926,6 +995,13 @@ type EmittedEvent =
926
995
  | { event: 'thread.run.cancelled'; data: Run }
927
996
  | { event: 'thread.run.expired'; data: Run }
928
997
  | { event: 'thread.run.incomplete'; data: Run }
998
+ | { event: 'thread.run.step.created'; data: RunStep }
999
+ | { event: 'thread.run.step.in_progress'; data: RunStep }
1000
+ | { event: 'thread.run.step.delta'; data: RunStepDelta }
1001
+ | { event: 'thread.run.step.completed'; data: RunStep }
1002
+ | { event: 'thread.run.step.failed'; data: RunStep }
1003
+ | { event: 'thread.run.step.cancelled'; data: RunStep }
1004
+ | { event: 'thread.run.step.expired'; data: RunStep }
929
1005
  | { event: 'thread.message.created'; data: Message }
930
1006
  | { event: 'thread.message.in_progress'; data: Message }
931
1007
  | { event: 'thread.message.delta'; data: MessageDelta }
@@ -936,6 +1012,8 @@ type EmittedEvent =
936
1012
 
937
1013
  A stream ends with `done` after the run finishes or pauses on `requires_action`; continue a paused run with `submit_tool_outputs` and `stream: true`, which streams only the events after the submission.
938
1014
 
1015
+ Step events come in the order of the OpenAI API: `thread.run.step.created` and `thread.run.step.in_progress` open a step, before the `thread.message.*` events of its message. A `tool_calls` step opens with an empty `tool_calls` list, gets one `thread.run.step.delta` per call (so the SDK's `toolCallCreated` fires), and `thread.run.step.completed` carries the outputs. A run that waits on the client streams `thread.run.step.delta` and then `thread.run.requires_action`, and the stream after `submit_tool_outputs` starts with `thread.run.in_progress` and the completed step.
1016
+
939
1017
  ### Message Delta Format
940
1018
 
941
1019
  All text deltas target content index `0`, so SDK helpers accumulate them into a single text part whose message id matches the stored message.
@@ -9,9 +9,10 @@ import { EventEmitter } from 'events';
9
9
  import { z } from 'zod';
10
10
  import { ThreadManager } from './thread-manager.js';
11
11
  import type { ThreadStorage } from './storage.js';
12
- import type { Assistant, AssistantTool, CreateMessageRequest, Run, RunStep, Message, MessageDelta, CreateRunRequest, ResponseFormat, SubmitToolOutputsRequest, Thread } from '../types/openai-types.js';
13
- export type StreamEventType = 'thread.run.created' | 'thread.run.queued' | 'thread.run.in_progress' | 'thread.run.requires_action' | 'thread.run.completed' | 'thread.run.failed' | 'thread.run.cancelling' | 'thread.run.cancelled' | 'thread.run.expired' | 'thread.run.incomplete' | 'thread.run.step.created' | 'thread.run.step.in_progress' | 'thread.run.step.completed' | 'thread.message.created' | 'thread.message.in_progress' | 'thread.message.delta' | 'thread.message.completed' | 'thread.message.incomplete' | 'done' | 'error';
14
- export type StreamEventData = Run | RunStep | Message | MessageDelta | string;
12
+ import { type RunStepEventType } from './run-steps.js';
13
+ import type { Assistant, AssistantTool, CreateMessageRequest, Run, RunStep, RunStepDelta, Message, MessageDelta, CreateRunRequest, ResponseFormat, SubmitToolOutputsRequest, Thread } from '../types/openai-types.js';
14
+ export type StreamEventType = 'thread.run.created' | 'thread.run.queued' | 'thread.run.in_progress' | 'thread.run.requires_action' | 'thread.run.completed' | 'thread.run.failed' | 'thread.run.cancelling' | 'thread.run.cancelled' | 'thread.run.expired' | 'thread.run.incomplete' | RunStepEventType | 'thread.message.created' | 'thread.message.in_progress' | 'thread.message.delta' | 'thread.message.completed' | 'thread.message.incomplete' | 'done' | 'error';
15
+ export type StreamEventData = Run | RunStep | RunStepDelta | Message | MessageDelta | string;
15
16
  export interface StreamEmitterEvents {
16
17
  event: [type: StreamEventType, data: StreamEventData];
17
18
  error: [error: Error];
@@ -29,7 +30,7 @@ export interface OpenAIAdapterOptions {
29
30
  * model id (the one listed by `GET /v1/models`).
30
31
  */
31
32
  defaultModel?: string;
32
- /** Maximum number of finished runs kept in memory (default: 10 000) */
33
+ /** Maximum number of finished runs kept in memory, with their steps (default: 10 000) */
33
34
  maxStoredRuns?: number;
34
35
  /**
35
36
  * Persistence for assistants, threads, messages and files (default: in-memory).
@@ -106,46 +107,61 @@ export declare class OpenAIAdapter {
106
107
  deleteAssistant(id: string): Promise<boolean>;
107
108
  listAssistants(): Promise<Assistant[]>;
108
109
  private toAssistant;
109
- createThread(metadata?: Record<string, string>): Promise<Thread>;
110
- getThread(id: string): Promise<Thread | undefined>;
110
+ /**
111
+ * Create a thread. With an `owner` (the API key that created it, see the server's `apiKeys`),
112
+ * only that owner reaches the thread, its messages and its runs.
113
+ *
114
+ * The thread, message and run methods below take the `owner` of the caller last: a thread or
115
+ * run of another owner is treated as missing. Without one, nothing is scoped.
116
+ */
117
+ createThread(metadata?: Record<string, string>, owner?: string): Promise<Thread>;
118
+ getThread(id: string, owner?: string): Promise<Thread | undefined>;
111
119
  updateThread(id: string, updates: {
112
120
  metadata?: Record<string, string>;
113
- }): Promise<Thread | undefined>;
114
- deleteThread(id: string): Promise<boolean>;
115
- addMessage(threadId: string, params: CreateMessageRequest): Promise<Message | undefined>;
116
- getMessage(threadId: string, messageId: string): Promise<Message | undefined>;
121
+ }, owner?: string): Promise<Thread | undefined>;
122
+ deleteThread(id: string, owner?: string): Promise<boolean>;
123
+ addMessage(threadId: string, params: CreateMessageRequest, owner?: string): Promise<Message | undefined>;
124
+ getMessage(threadId: string, messageId: string, owner?: string): Promise<Message | undefined>;
117
125
  listMessages(threadId: string, options?: {
118
126
  limit?: number;
119
127
  order?: 'asc' | 'desc';
120
128
  after?: string;
121
129
  before?: string;
122
130
  run_id?: string;
123
- }): Promise<Message[]>;
131
+ }, owner?: string): Promise<Message[]>;
132
+ private accessibleThread;
133
+ private accessibleRun;
124
134
  /**
125
135
  * Create a run and start executing it in the background.
126
136
  *
127
- * Rejects when the assistant or thread does not exist, or when the thread
128
- * already has an active run.
137
+ * Rejects when the assistant or thread does not exist (or the thread belongs to another
138
+ * `owner`), or when the thread already has an active run.
129
139
  */
130
- createRun(threadId: string, request: CreateRunRequest): Promise<Run>;
140
+ createRun(threadId: string, request: CreateRunRequest, owner?: string): Promise<Run>;
131
141
  /**
132
142
  * Get a run by ID
133
143
  */
134
- getRun(threadId: string, runId: string): Run | undefined;
144
+ getRun(threadId: string, runId: string, owner?: string): Run | undefined;
135
145
  /**
136
146
  * List runs of a thread, newest first
137
147
  */
138
- listRuns(threadId: string): Run[];
148
+ listRuns(threadId: string, owner?: string): Run[];
149
+ /**
150
+ * The steps of a run in the order they were created, or undefined when there is no such run.
151
+ * Steps are kept with their run (see `maxStoredRuns`).
152
+ */
153
+ listRunSteps(threadId: string, runId: string, owner?: string): RunStep[] | undefined;
154
+ getRunStep(threadId: string, runId: string, stepId: string, owner?: string): RunStep | undefined;
139
155
  /**
140
156
  * Cancel a run. Throws when the run already finished.
141
157
  */
142
- cancelRun(threadId: string, runId: string): Run | undefined;
158
+ cancelRun(threadId: string, runId: string, owner?: string): Run | undefined;
143
159
  /**
144
160
  * Submit outputs for the tool calls of a run that requires action. Outputs for every pending
145
161
  * tool call must be provided: the result of a client-side function, or the decision on a
146
162
  * server tool that needs approval (see `toolOutputToDecision`).
147
163
  */
148
- submitToolOutputs(threadId: string, runId: string, request: SubmitToolOutputsRequest): Promise<Run | undefined>;
164
+ submitToolOutputs(threadId: string, runId: string, request: SubmitToolOutputsRequest, owner?: string): Promise<Run | undefined>;
149
165
  /**
150
166
  * Get the event emitter of a run (all runs have one)
151
167
  */
@@ -162,8 +178,19 @@ export declare class OpenAIAdapter {
162
178
  */
163
179
  streamRunEvents(runId: string, fromIndex?: number): AsyncGenerator<RunStreamEvent>;
164
180
  private emit;
181
+ /**
182
+ * Emit a step event. The settle event of a step that waits in the outbox is named by the
183
+ * status the step has when it goes out, so a message step whose message was not stored after
184
+ * all goes out failed.
185
+ */
186
+ private emitStep;
187
+ /** Send an event to the run's listeners: one that throws is logged and never stops the run */
188
+ private deliver;
189
+ /** Runs `step` once every event queued before it is out, holding back the events after it */
190
+ private enqueue;
165
191
  private end;
166
192
  private clearExpiry;
193
+ /** Stops the run with `reason`: a cancel, an expiry, or a store of its messages that failed */
167
194
  private terminate;
168
195
  private evictFinishedRuns;
169
196
  /**
@@ -183,7 +210,9 @@ export declare class OpenAIAdapter {
183
210
  private createClientTools;
184
211
  /**
185
212
  * Put the run in `requires_action` with `calls` and wait for the client's outputs, or for the
186
- * run to be cancelled or to expire (`RUN_TTL_SECONDS`).
213
+ * run to be cancelled or to expire (`RUN_TTL_SECONDS`). The messages before the pause are
214
+ * stored and their events sent first, so a client that sees `requires_action` has all of them,
215
+ * and a store that failed fails the run instead.
187
216
  */
188
217
  private awaitToolOutputs;
189
218
  /**
@@ -199,6 +228,19 @@ export declare class OpenAIAdapter {
199
228
  */
200
229
  private buildRunInput;
201
230
  private executeRun;
231
+ /**
232
+ * Finish a message of the run: store it and emit its final event once it is stored, with the
233
+ * events of the next steps held back until then. Stores to one thread keep the order of the
234
+ * calls, and the run waits for them (`messageWrites`) before it completes. A store that fails,
235
+ * or finds the thread deleted, stops the run right away, and the message ends as incomplete
236
+ * (`run_failed`) instead of completed, as it was never kept.
237
+ */
238
+ private sealMessage;
239
+ /**
240
+ * Keep what the model wrote of a message the run announced but did not finish, as an
241
+ * incomplete message, so the `message_creation` step points at a message that exists.
242
+ */
243
+ private keepUnfinishedMessage;
202
244
  }
203
245
  /**
204
246
  * Create an OpenAI adapter for Cogitator
@@ -1 +1 @@
1
- {"version":3,"file":"openai-adapter.d.ts","sourceRoot":"","sources":["../../src/client/openai-adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAsB,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAGL,KAAK,cAAc,IAAI,mBAAmB,EAE1C,KAAK,IAAI,EACT,KAAK,oBAAoB,EAE1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAA+C,MAAM,kBAAkB,CAAC;AAC9F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,oBAAoB,EAEpB,GAAG,EAEH,OAAO,EACP,OAAO,EACP,YAAY,EAEZ,gBAAgB,EAChB,cAAc,EACd,wBAAwB,EACxB,MAAM,EAEP,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,eAAe,GACvB,oBAAoB,GACpB,mBAAmB,GACnB,wBAAwB,GACxB,4BAA4B,GAC5B,sBAAsB,GACtB,mBAAmB,GACnB,uBAAuB,GACvB,sBAAsB,GACtB,oBAAoB,GACpB,uBAAuB,GACvB,yBAAyB,GACzB,6BAA6B,GAC7B,2BAA2B,GAC3B,wBAAwB,GACxB,4BAA4B,GAC5B,sBAAsB,GACtB,0BAA0B,GAC1B,2BAA2B,GAC3B,MAAM,GACN,O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