|
1 | 1 | import { Message, SendMessageRequest, Task } from '../../index.js'; |
2 | 2 | import { ServerCallContext } from '../context.js'; |
3 | 3 |
|
4 | | -export interface RequestContextParams { |
5 | | - /** The incoming `SendMessageRequest` payload. Its `message` field MUST be set. */ |
6 | | - request: SendMessageRequest; |
7 | | - /** The server call context associated with this request. */ |
8 | | - context: ServerCallContext; |
9 | | - /** The resolved task ID (either from the request or server-generated). */ |
10 | | - taskId: string; |
11 | | - /** The resolved context ID (either from the request or server-generated). */ |
12 | | - contextId: string; |
13 | | - /** The existing `Task` object retrieved from the store, if any. */ |
14 | | - task?: Task; |
15 | | - /** A list of other tasks related to the current request (e.g., for tool use). */ |
16 | | - referenceTasks?: Task[]; |
17 | | -} |
18 | | - |
19 | 4 | /** |
20 | 5 | * Holds information about the current request being processed by the server. |
21 | 6 | * |
22 | 7 | * Wraps the incoming {@link SendMessageRequest} so agent executors can reach |
23 | 8 | * the full payload (message, configuration, metadata, tenant) via `request`. |
24 | 9 | */ |
25 | 10 | export class RequestContext { |
26 | | - /** The incoming request payload, including `message`, `configuration`, `metadata`, and `tenant`. */ |
27 | 11 | public readonly request: SendMessageRequest; |
28 | | - /** The server call context associated with this request. */ |
29 | 12 | public readonly context: ServerCallContext; |
30 | | - /** The resolved task ID for this request. */ |
31 | 13 | public readonly taskId: string; |
32 | | - /** The resolved context ID for this request. */ |
33 | 14 | public readonly contextId: string; |
34 | | - /** The existing `Task` object retrieved from the store, if any. */ |
35 | 15 | public readonly task?: Task; |
36 | | - /** A list of other tasks related to the current request (e.g., for tool use). */ |
37 | 16 | public readonly referenceTasks?: Task[]; |
38 | 17 |
|
39 | | - constructor(params: RequestContextParams) { |
| 18 | + constructor(params: { |
| 19 | + request: SendMessageRequest; |
| 20 | + context: ServerCallContext; |
| 21 | + taskId: string; |
| 22 | + contextId: string; |
| 23 | + task?: Task; |
| 24 | + referenceTasks?: Task[]; |
| 25 | + }) { |
40 | 26 | if (!params.request.message) { |
41 | 27 | throw new Error('RequestContext requires request.message to be set.'); |
42 | 28 | } |
|
0 commit comments