casedev 0.25.0 → 0.27.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/CHANGELOG.md +16 -0
- package/package.json +1 -1
- package/resources/agent/v1/chat/chat.d.mts +163 -0
- package/resources/agent/v1/chat/chat.d.mts.map +1 -0
- package/resources/agent/v1/chat/chat.d.ts +163 -0
- package/resources/agent/v1/chat/chat.d.ts.map +1 -0
- package/resources/agent/v1/chat/chat.js +109 -0
- package/resources/agent/v1/chat/chat.js.map +1 -0
- package/resources/agent/v1/chat/chat.mjs +104 -0
- package/resources/agent/v1/chat/chat.mjs.map +1 -0
- package/resources/agent/v1/chat/files.d.mts +42 -0
- package/resources/agent/v1/chat/files.d.mts.map +1 -0
- package/resources/agent/v1/chat/files.d.ts +42 -0
- package/resources/agent/v1/chat/files.d.ts.map +1 -0
- package/resources/agent/v1/chat/files.js +33 -0
- package/resources/agent/v1/chat/files.js.map +1 -0
- package/resources/agent/v1/chat/files.mjs +29 -0
- package/resources/agent/v1/chat/files.mjs.map +1 -0
- package/resources/agent/v1/chat/index.d.mts +3 -0
- package/resources/agent/v1/chat/index.d.mts.map +1 -0
- package/resources/agent/v1/chat/index.d.ts +3 -0
- package/resources/agent/v1/chat/index.d.ts.map +1 -0
- package/resources/agent/v1/chat/index.js +9 -0
- package/resources/agent/v1/chat/index.js.map +1 -0
- package/resources/agent/v1/chat/index.mjs +4 -0
- package/resources/agent/v1/chat/index.mjs.map +1 -0
- package/resources/agent/v1/chat.d.mts +1 -158
- package/resources/agent/v1/chat.d.mts.map +1 -1
- package/resources/agent/v1/chat.d.ts +1 -158
- package/resources/agent/v1/chat.d.ts.map +1 -1
- package/resources/agent/v1/chat.js +2 -97
- package/resources/agent/v1/chat.js.map +1 -1
- package/resources/agent/v1/chat.mjs +1 -95
- package/resources/agent/v1/chat.mjs.map +1 -1
- package/resources/agent/v1/index.d.mts +1 -1
- package/resources/agent/v1/index.d.ts +1 -1
- package/resources/agent/v1/index.js +2 -2
- package/resources/agent/v1/index.js.map +1 -1
- package/resources/agent/v1/index.mjs +1 -1
- package/resources/agent/v1/v1.d.mts +2 -2
- package/resources/agent/v1/v1.d.mts.map +1 -1
- package/resources/agent/v1/v1.d.ts +2 -2
- package/resources/agent/v1/v1.d.ts.map +1 -1
- package/resources/agent/v1/v1.js +2 -2
- package/resources/agent/v1/v1.js.map +1 -1
- package/resources/agent/v1/v1.mjs +2 -2
- package/resources/agent/v1/v1.mjs.map +1 -1
- package/src/resources/agent/v1/chat/chat.ts +267 -0
- package/src/resources/agent/v1/chat/files.ts +63 -0
- package/src/resources/agent/v1/chat/index.ts +16 -0
- package/src/resources/agent/v1/chat.ts +1 -253
- package/src/resources/agent/v1/index.ts +1 -1
- package/src/resources/agent/v1/v1.ts +14 -14
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.27.0 (2026-03-13)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.26.0...v0.27.0](https://github.com/CaseMark/casedev-typescript/compare/v0.26.0...v0.27.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** api update ([72c305e](https://github.com/CaseMark/casedev-typescript/commit/72c305e70e58f3d1c6d2269437223d34430c02db))
|
|
10
|
+
|
|
11
|
+
## 0.26.0 (2026-03-13)
|
|
12
|
+
|
|
13
|
+
Full Changelog: [v0.25.0...v0.26.0](https://github.com/CaseMark/casedev-typescript/compare/v0.25.0...v0.26.0)
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **api:** api update ([24af57a](https://github.com/CaseMark/casedev-typescript/commit/24af57a285fb86282498da8d35faa2404038327e))
|
|
18
|
+
|
|
3
19
|
## 0.25.0 (2026-03-12)
|
|
4
20
|
|
|
5
21
|
Full Changelog: [v0.24.0...v0.25.0](https://github.com/CaseMark/casedev-typescript/compare/v0.24.0...v0.25.0)
|
package/package.json
CHANGED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { APIResource } from "../../../../core/resource.mjs";
|
|
2
|
+
import * as FilesAPI from "./files.mjs";
|
|
3
|
+
import { FileDownloadParams, FileListResponse, Files } from "./files.mjs";
|
|
4
|
+
import { APIPromise } from "../../../../core/api-promise.mjs";
|
|
5
|
+
import { Stream } from "../../../../core/streaming.mjs";
|
|
6
|
+
import { RequestOptions } from "../../../../internal/request-options.mjs";
|
|
7
|
+
/**
|
|
8
|
+
* Create, manage, and execute AI agents with tool access, sandbox environments, and async run workflows
|
|
9
|
+
*/
|
|
10
|
+
export declare class Chat extends APIResource {
|
|
11
|
+
files: FilesAPI.Files;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a persistent OpenCode chat session in a Modal sandbox. Session state is
|
|
14
|
+
* retained and can be resumed across requests.
|
|
15
|
+
*/
|
|
16
|
+
create(body?: ChatCreateParams | null | undefined, options?: RequestOptions): APIPromise<ChatCreateResponse>;
|
|
17
|
+
/**
|
|
18
|
+
* Snapshots and terminates the active sandbox (if any), then marks the chat as
|
|
19
|
+
* ended.
|
|
20
|
+
*/
|
|
21
|
+
delete(id: string, options?: RequestOptions): APIPromise<ChatDeleteResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Aborts the active OpenCode generation for this chat session.
|
|
24
|
+
*/
|
|
25
|
+
cancel(id: string, options?: RequestOptions): APIPromise<ChatCancelResponse>;
|
|
26
|
+
/**
|
|
27
|
+
* Answers a pending OpenCode question for the chat session bound to this agent
|
|
28
|
+
* chat.
|
|
29
|
+
*/
|
|
30
|
+
replyToQuestion(requestID: string, params: ChatReplyToQuestionParams, options?: RequestOptions): APIPromise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Streams a single assistant turn as normalized SSE events with stable turn,
|
|
33
|
+
* message, and part IDs. Emits events: `turn.started`, `turn.status`,
|
|
34
|
+
* `message.created`, `message.part.updated`, `message.completed`, `session.usage`,
|
|
35
|
+
* `turn.completed`.
|
|
36
|
+
*
|
|
37
|
+
* **When to use this endpoint:** Recommended for building custom chat UIs that
|
|
38
|
+
* need real-time streaming progress. This is the primary streaming endpoint for
|
|
39
|
+
* new integrations.
|
|
40
|
+
*
|
|
41
|
+
* **Alternatives:**
|
|
42
|
+
*
|
|
43
|
+
* - `POST /chat/:id/message` — synchronous, returns complete response as JSON
|
|
44
|
+
* (best for server-to-server)
|
|
45
|
+
*/
|
|
46
|
+
respond(id: string, body: ChatRespondParams, options?: RequestOptions): APIPromise<Stream<ChatRespondResponse>>;
|
|
47
|
+
/**
|
|
48
|
+
* Sends a message and returns the complete response as a single JSON body. Blocks
|
|
49
|
+
* until the agent turn completes.
|
|
50
|
+
*
|
|
51
|
+
* **When to use this endpoint:** Best for server-to-server integrations,
|
|
52
|
+
* background processing, or any context where you want the full response in one
|
|
53
|
+
* call without managing an SSE stream.
|
|
54
|
+
*
|
|
55
|
+
* **Alternatives:**
|
|
56
|
+
*
|
|
57
|
+
* - `POST /chat/:id/respond` — streaming SSE with normalized events (recommended
|
|
58
|
+
* for custom chat UIs)
|
|
59
|
+
*/
|
|
60
|
+
sendMessage(id: string, body: ChatSendMessageParams, options?: RequestOptions): APIPromise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Relays OpenCode SSE events for this chat. Supports replay from buffered events
|
|
63
|
+
* using Last-Event-ID.
|
|
64
|
+
*/
|
|
65
|
+
stream(id: string, query?: ChatStreamParams | undefined, options?: RequestOptions): APIPromise<Stream<ChatStreamResponse>>;
|
|
66
|
+
}
|
|
67
|
+
export interface ChatCreateResponse {
|
|
68
|
+
id?: string;
|
|
69
|
+
createdAt?: string;
|
|
70
|
+
idleTimeoutMs?: number;
|
|
71
|
+
status?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface ChatDeleteResponse {
|
|
74
|
+
id?: string;
|
|
75
|
+
cost?: number;
|
|
76
|
+
runtimeMs?: number;
|
|
77
|
+
snapshotImageId?: string | null;
|
|
78
|
+
status?: string;
|
|
79
|
+
}
|
|
80
|
+
export interface ChatCancelResponse {
|
|
81
|
+
id?: string;
|
|
82
|
+
ok?: boolean;
|
|
83
|
+
}
|
|
84
|
+
export type ChatRespondResponse = string;
|
|
85
|
+
export type ChatStreamResponse = string;
|
|
86
|
+
export interface ChatCreateParams {
|
|
87
|
+
/**
|
|
88
|
+
* Idle timeout before session is eligible for snapshot/termination. Defaults to 15
|
|
89
|
+
* minutes.
|
|
90
|
+
*/
|
|
91
|
+
idleTimeoutMs?: number | null;
|
|
92
|
+
/**
|
|
93
|
+
* Optional model override for the OpenCode session
|
|
94
|
+
*/
|
|
95
|
+
model?: string | null;
|
|
96
|
+
/**
|
|
97
|
+
* Optional human-readable session title
|
|
98
|
+
*/
|
|
99
|
+
title?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Restrict the chat session to specific vault IDs
|
|
102
|
+
*/
|
|
103
|
+
vaultIds?: Array<string> | null;
|
|
104
|
+
}
|
|
105
|
+
export interface ChatReplyToQuestionParams {
|
|
106
|
+
/**
|
|
107
|
+
* Path param: Chat session ID
|
|
108
|
+
*/
|
|
109
|
+
id: string;
|
|
110
|
+
/**
|
|
111
|
+
* Body param: Answer selections for each prompt element in the pending question
|
|
112
|
+
*/
|
|
113
|
+
answers: Array<Array<string>>;
|
|
114
|
+
}
|
|
115
|
+
export interface ChatRespondParams {
|
|
116
|
+
/**
|
|
117
|
+
* Message content parts. Currently only "text" type is supported. Additional types
|
|
118
|
+
* (e.g. file, image) may be added in future versions.
|
|
119
|
+
*/
|
|
120
|
+
parts?: Array<ChatRespondParams.Part>;
|
|
121
|
+
}
|
|
122
|
+
export declare namespace ChatRespondParams {
|
|
123
|
+
interface Part {
|
|
124
|
+
/**
|
|
125
|
+
* The message text content
|
|
126
|
+
*/
|
|
127
|
+
text: string;
|
|
128
|
+
/**
|
|
129
|
+
* Part type. Currently only "text" is supported.
|
|
130
|
+
*/
|
|
131
|
+
type: 'text';
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
export interface ChatSendMessageParams {
|
|
135
|
+
/**
|
|
136
|
+
* Message content parts. Currently only "text" type is supported. Additional types
|
|
137
|
+
* (e.g. file, image) may be added in future versions.
|
|
138
|
+
*/
|
|
139
|
+
parts?: Array<ChatSendMessageParams.Part>;
|
|
140
|
+
}
|
|
141
|
+
export declare namespace ChatSendMessageParams {
|
|
142
|
+
interface Part {
|
|
143
|
+
/**
|
|
144
|
+
* The message text content
|
|
145
|
+
*/
|
|
146
|
+
text: string;
|
|
147
|
+
/**
|
|
148
|
+
* Part type. Currently only "text" is supported.
|
|
149
|
+
*/
|
|
150
|
+
type: 'text';
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
export interface ChatStreamParams {
|
|
154
|
+
/**
|
|
155
|
+
* Replay events after this sequence number
|
|
156
|
+
*/
|
|
157
|
+
lastEventId?: number;
|
|
158
|
+
}
|
|
159
|
+
export declare namespace Chat {
|
|
160
|
+
export { type ChatCreateResponse as ChatCreateResponse, type ChatDeleteResponse as ChatDeleteResponse, type ChatCancelResponse as ChatCancelResponse, type ChatRespondResponse as ChatRespondResponse, type ChatStreamResponse as ChatStreamResponse, type ChatCreateParams as ChatCreateParams, type ChatReplyToQuestionParams as ChatReplyToQuestionParams, type ChatRespondParams as ChatRespondParams, type ChatSendMessageParams as ChatSendMessageParams, type ChatStreamParams as ChatStreamParams, };
|
|
161
|
+
export { Files as Files, type FileListResponse as FileListResponse, type FileDownloadParams as FileDownloadParams, };
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=chat.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.d.mts","sourceRoot":"","sources":["../../../../src/resources/agent/v1/chat/chat.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,KAAK,QAAQ;OACb,EAAE,kBAAkB,EA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AC;KACd;CACF;AAED,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;CAC3C;AAED,yBAAiB,qBAAqB,CAAC;IACrC,UAAiB,IAAI;QACnB;;WAEG;QACH,IAAI,EAAE,MAAM,CAAC;QAEb;;WAEG;QACH,IAAI,EAAE,MAAM,CAAC;KACd;CACF;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAID,MAAM,CAAC,OAAO,WAAW,IAAI,CAAC;IAC5B,OAAO,EACL,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,yBAAyB,IAAI,yBAAyB,EAC3D,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,gBAAgB,IAAI,gBAAgB,GAC1C,CAAC;IAEF,OAAO,EACL,KAAK,IAAI,KAAK,EACd,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,kBAAkB,IAAI,kBAAkB,GAC9C,CAAC;CACH"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { APIResource } from "../../../../core/resource.js";
|
|
2
|
+
import * as FilesAPI from "./files.js";
|
|
3
|
+
import { FileDownloadParams, FileListResponse, Files } from "./files.js";
|
|
4
|
+
import { APIPromise } from "../../../../core/api-promise.js";
|
|
5
|
+
import { Stream } from "../../../../core/streaming.js";
|
|
6
|
+
import { RequestOptions } from "../../../../internal/request-options.js";
|
|
7
|
+
/**
|
|
8
|
+
* Create, manage, and execute AI agents with tool access, sandbox environments, and async run workflows
|
|
9
|
+
*/
|
|
10
|
+
export declare class Chat extends APIResource {
|
|
11
|
+
files: FilesAPI.Files;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a persistent OpenCode chat session in a Modal sandbox. Session state is
|
|
14
|
+
* retained and can be resumed across requests.
|
|
15
|
+
*/
|
|
16
|
+
create(body?: ChatCreateParams | null | undefined, options?: RequestOptions): APIPromise<ChatCreateResponse>;
|
|
17
|
+
/**
|
|
18
|
+
* Snapshots and terminates the active sandbox (if any), then marks the chat as
|
|
19
|
+
* ended.
|
|
20
|
+
*/
|
|
21
|
+
delete(id: string, options?: RequestOptions): APIPromise<ChatDeleteResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Aborts the active OpenCode generation for this chat session.
|
|
24
|
+
*/
|
|
25
|
+
cancel(id: string, options?: RequestOptions): APIPromise<ChatCancelResponse>;
|
|
26
|
+
/**
|
|
27
|
+
* Answers a pending OpenCode question for the chat session bound to this agent
|
|
28
|
+
* chat.
|
|
29
|
+
*/
|
|
30
|
+
replyToQuestion(requestID: string, params: ChatReplyToQuestionParams, options?: RequestOptions): APIPromise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Streams a single assistant turn as normalized SSE events with stable turn,
|
|
33
|
+
* message, and part IDs. Emits events: `turn.started`, `turn.status`,
|
|
34
|
+
* `message.created`, `message.part.updated`, `message.completed`, `session.usage`,
|
|
35
|
+
* `turn.completed`.
|
|
36
|
+
*
|
|
37
|
+
* **When to use this endpoint:** Recommended for building custom chat UIs that
|
|
38
|
+
* need real-time streaming progress. This is the primary streaming endpoint for
|
|
39
|
+
* new integrations.
|
|
40
|
+
*
|
|
41
|
+
* **Alternatives:**
|
|
42
|
+
*
|
|
43
|
+
* - `POST /chat/:id/message` — synchronous, returns complete response as JSON
|
|
44
|
+
* (best for server-to-server)
|
|
45
|
+
*/
|
|
46
|
+
respond(id: string, body: ChatRespondParams, options?: RequestOptions): APIPromise<Stream<ChatRespondResponse>>;
|
|
47
|
+
/**
|
|
48
|
+
* Sends a message and returns the complete response as a single JSON body. Blocks
|
|
49
|
+
* until the agent turn completes.
|
|
50
|
+
*
|
|
51
|
+
* **When to use this endpoint:** Best for server-to-server integrations,
|
|
52
|
+
* background processing, or any context where you want the full response in one
|
|
53
|
+
* call without managing an SSE stream.
|
|
54
|
+
*
|
|
55
|
+
* **Alternatives:**
|
|
56
|
+
*
|
|
57
|
+
* - `POST /chat/:id/respond` — streaming SSE with normalized events (recommended
|
|
58
|
+
* for custom chat UIs)
|
|
59
|
+
*/
|
|
60
|
+
sendMessage(id: string, body: ChatSendMessageParams, options?: RequestOptions): APIPromise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Relays OpenCode SSE events for this chat. Supports replay from buffered events
|
|
63
|
+
* using Last-Event-ID.
|
|
64
|
+
*/
|
|
65
|
+
stream(id: string, query?: ChatStreamParams | undefined, options?: RequestOptions): APIPromise<Stream<ChatStreamResponse>>;
|
|
66
|
+
}
|
|
67
|
+
export interface ChatCreateResponse {
|
|
68
|
+
id?: string;
|
|
69
|
+
createdAt?: string;
|
|
70
|
+
idleTimeoutMs?: number;
|
|
71
|
+
status?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface ChatDeleteResponse {
|
|
74
|
+
id?: string;
|
|
75
|
+
cost?: number;
|
|
76
|
+
runtimeMs?: number;
|
|
77
|
+
snapshotImageId?: string | null;
|
|
78
|
+
status?: string;
|
|
79
|
+
}
|
|
80
|
+
export interface ChatCancelResponse {
|
|
81
|
+
id?: string;
|
|
82
|
+
ok?: boolean;
|
|
83
|
+
}
|
|
84
|
+
export type ChatRespondResponse = string;
|
|
85
|
+
export type ChatStreamResponse = string;
|
|
86
|
+
export interface ChatCreateParams {
|
|
87
|
+
/**
|
|
88
|
+
* Idle timeout before session is eligible for snapshot/termination. Defaults to 15
|
|
89
|
+
* minutes.
|
|
90
|
+
*/
|
|
91
|
+
idleTimeoutMs?: number | null;
|
|
92
|
+
/**
|
|
93
|
+
* Optional model override for the OpenCode session
|
|
94
|
+
*/
|
|
95
|
+
model?: string | null;
|
|
96
|
+
/**
|
|
97
|
+
* Optional human-readable session title
|
|
98
|
+
*/
|
|
99
|
+
title?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Restrict the chat session to specific vault IDs
|
|
102
|
+
*/
|
|
103
|
+
vaultIds?: Array<string> | null;
|
|
104
|
+
}
|
|
105
|
+
export interface ChatReplyToQuestionParams {
|
|
106
|
+
/**
|
|
107
|
+
* Path param: Chat session ID
|
|
108
|
+
*/
|
|
109
|
+
id: string;
|
|
110
|
+
/**
|
|
111
|
+
* Body param: Answer selections for each prompt element in the pending question
|
|
112
|
+
*/
|
|
113
|
+
answers: Array<Array<string>>;
|
|
114
|
+
}
|
|
115
|
+
export interface ChatRespondParams {
|
|
116
|
+
/**
|
|
117
|
+
* Message content parts. Currently only "text" type is supported. Additional types
|
|
118
|
+
* (e.g. file, image) may be added in future versions.
|
|
119
|
+
*/
|
|
120
|
+
parts?: Array<ChatRespondParams.Part>;
|
|
121
|
+
}
|
|
122
|
+
export declare namespace ChatRespondParams {
|
|
123
|
+
interface Part {
|
|
124
|
+
/**
|
|
125
|
+
* The message text content
|
|
126
|
+
*/
|
|
127
|
+
text: string;
|
|
128
|
+
/**
|
|
129
|
+
* Part type. Currently only "text" is supported.
|
|
130
|
+
*/
|
|
131
|
+
type: 'text';
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
export interface ChatSendMessageParams {
|
|
135
|
+
/**
|
|
136
|
+
* Message content parts. Currently only "text" type is supported. Additional types
|
|
137
|
+
* (e.g. file, image) may be added in future versions.
|
|
138
|
+
*/
|
|
139
|
+
parts?: Array<ChatSendMessageParams.Part>;
|
|
140
|
+
}
|
|
141
|
+
export declare namespace ChatSendMessageParams {
|
|
142
|
+
interface Part {
|
|
143
|
+
/**
|
|
144
|
+
* The message text content
|
|
145
|
+
*/
|
|
146
|
+
text: string;
|
|
147
|
+
/**
|
|
148
|
+
* Part type. Currently only "text" is supported.
|
|
149
|
+
*/
|
|
150
|
+
type: 'text';
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
export interface ChatStreamParams {
|
|
154
|
+
/**
|
|
155
|
+
* Replay events after this sequence number
|
|
156
|
+
*/
|
|
157
|
+
lastEventId?: number;
|
|
158
|
+
}
|
|
159
|
+
export declare namespace Chat {
|
|
160
|
+
export { type ChatCreateResponse as ChatCreateResponse, type ChatDeleteResponse as ChatDeleteResponse, type ChatCancelResponse as ChatCancelResponse, type ChatRespondResponse as ChatRespondResponse, type ChatStreamResponse as ChatStreamResponse, type ChatCreateParams as ChatCreateParams, type ChatReplyToQuestionParams as ChatReplyToQuestionParams, type ChatRespondParams as ChatRespondParams, type ChatSendMessageParams as ChatSendMessageParams, type ChatStreamParams as ChatStreamParams, };
|
|
161
|
+
export { Files as Files, type FileListResponse as FileListResponse, type FileDownloadParams as FileDownloadParams, };
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../../../src/resources/agent/v1/chat/chat.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,KAAK,QAAQ;OACb,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,KAAK,EAAE;OAC/C,EAAE,UAAU,EAAE;OACd,EAAE,MAAM,EAAE;OAEV,EAAE,cAAc,EAAE;AAGzB;;GAEG;AACH,qBAAa,IAAK,SAAQ,WAAW;IACnC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAoC;IAEzD;;;OAGG;IACH,MAAM,CACJ,IAAI,GAAE,gBAAgB,GAAG,IAAI,GAAG,SAAc,EAC9C,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,kBAAkB,CAAC;IAIjC;;;OAGG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,kBAAkB,CAAC;IAI5E;;OAEG;IACH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kBAAkB,EAC7C,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,yBAAyB,IAAI,yBAAyB,EAC3D,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,gBAAgB,IAAI,gBAAgB,GAC1C,CAAC;IAEF,OAAO,EACL,KAAK,IAAI,KAAK,EACd,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,kBAAkB,IAAI,kBAAkB,GAC9C,CAAC;CACH"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Chat = void 0;
|
|
5
|
+
const tslib_1 = require("../../../../internal/tslib.js");
|
|
6
|
+
const resource_1 = require("../../../../core/resource.js");
|
|
7
|
+
const FilesAPI = tslib_1.__importStar(require("./files.js"));
|
|
8
|
+
const files_1 = require("./files.js");
|
|
9
|
+
const headers_1 = require("../../../../internal/headers.js");
|
|
10
|
+
const path_1 = require("../../../../internal/utils/path.js");
|
|
11
|
+
/**
|
|
12
|
+
* Create, manage, and execute AI agents with tool access, sandbox environments, and async run workflows
|
|
13
|
+
*/
|
|
14
|
+
class Chat extends resource_1.APIResource {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.files = new FilesAPI.Files(this._client);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates a persistent OpenCode chat session in a Modal sandbox. Session state is
|
|
21
|
+
* retained and can be resumed across requests.
|
|
22
|
+
*/
|
|
23
|
+
create(body = {}, options) {
|
|
24
|
+
return this._client.post('/agent/v1/chat', { body, ...options });
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Snapshots and terminates the active sandbox (if any), then marks the chat as
|
|
28
|
+
* ended.
|
|
29
|
+
*/
|
|
30
|
+
delete(id, options) {
|
|
31
|
+
return this._client.delete((0, path_1.path) `/agent/v1/chat/${id}`, options);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Aborts the active OpenCode generation for this chat session.
|
|
35
|
+
*/
|
|
36
|
+
cancel(id, options) {
|
|
37
|
+
return this._client.post((0, path_1.path) `/agent/v1/chat/${id}/cancel`, options);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Answers a pending OpenCode question for the chat session bound to this agent
|
|
41
|
+
* chat.
|
|
42
|
+
*/
|
|
43
|
+
replyToQuestion(requestID, params, options) {
|
|
44
|
+
const { id, ...body } = params;
|
|
45
|
+
return this._client.post((0, path_1.path) `/agent/v1/chat/${id}/question/${requestID}/reply`, {
|
|
46
|
+
body,
|
|
47
|
+
...options,
|
|
48
|
+
headers: (0, headers_1.buildHeaders)([{ Accept: '*/*' }, options?.headers]),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Streams a single assistant turn as normalized SSE events with stable turn,
|
|
53
|
+
* message, and part IDs. Emits events: `turn.started`, `turn.status`,
|
|
54
|
+
* `message.created`, `message.part.updated`, `message.completed`, `session.usage`,
|
|
55
|
+
* `turn.completed`.
|
|
56
|
+
*
|
|
57
|
+
* **When to use this endpoint:** Recommended for building custom chat UIs that
|
|
58
|
+
* need real-time streaming progress. This is the primary streaming endpoint for
|
|
59
|
+
* new integrations.
|
|
60
|
+
*
|
|
61
|
+
* **Alternatives:**
|
|
62
|
+
*
|
|
63
|
+
* - `POST /chat/:id/message` — synchronous, returns complete response as JSON
|
|
64
|
+
* (best for server-to-server)
|
|
65
|
+
*/
|
|
66
|
+
respond(id, body, options) {
|
|
67
|
+
return this._client.post((0, path_1.path) `/agent/v1/chat/${id}/respond`, {
|
|
68
|
+
body,
|
|
69
|
+
...options,
|
|
70
|
+
headers: (0, headers_1.buildHeaders)([{ Accept: 'text/event-stream' }, options?.headers]),
|
|
71
|
+
stream: true,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Sends a message and returns the complete response as a single JSON body. Blocks
|
|
76
|
+
* until the agent turn completes.
|
|
77
|
+
*
|
|
78
|
+
* **When to use this endpoint:** Best for server-to-server integrations,
|
|
79
|
+
* background processing, or any context where you want the full response in one
|
|
80
|
+
* call without managing an SSE stream.
|
|
81
|
+
*
|
|
82
|
+
* **Alternatives:**
|
|
83
|
+
*
|
|
84
|
+
* - `POST /chat/:id/respond` — streaming SSE with normalized events (recommended
|
|
85
|
+
* for custom chat UIs)
|
|
86
|
+
*/
|
|
87
|
+
sendMessage(id, body, options) {
|
|
88
|
+
return this._client.post((0, path_1.path) `/agent/v1/chat/${id}/message`, {
|
|
89
|
+
body,
|
|
90
|
+
...options,
|
|
91
|
+
headers: (0, headers_1.buildHeaders)([{ Accept: '*/*' }, options?.headers]),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Relays OpenCode SSE events for this chat. Supports replay from buffered events
|
|
96
|
+
* using Last-Event-ID.
|
|
97
|
+
*/
|
|
98
|
+
stream(id, query = {}, options) {
|
|
99
|
+
return this._client.get((0, path_1.path) `/agent/v1/chat/${id}/stream`, {
|
|
100
|
+
query,
|
|
101
|
+
...options,
|
|
102
|
+
headers: (0, headers_1.buildHeaders)([{ Accept: 'text/event-stream' }, options?.headers]),
|
|
103
|
+
stream: true,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.Chat = Chat;
|
|
108
|
+
Chat.Files = files_1.Files;
|
|
109
|
+
//# sourceMappingURL=chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../../../src/resources/agent/v1/chat/chat.ts"],"names":[],"mappings":";AAAA,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OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,WAAI,EAAA,kBAAkB,EAAE,UAAU,EAAE;YAC3D,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC1E,MAAM,EAAE,IAAI;SACb,CAA4C,CAAC;IAChD,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,WAAW,CAAC,EAAU,EAAE,IAA2B,EAAE,OAAwB;QAC3E,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,WAAI,EAAA,kBAAkB,EAAE,UAAU,EAAE;YAC3D,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;SAC7D,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,MAAM,CACJ,EAAU,EACV,QAAsC,EAAE,EACxC,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,kBAAkB,EAAE,SAAS,EAAE;YACzD,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC1E,MAAM,EAAE,IAAI;SACb,CAA2C,CAAC;IAC/C,CAAC;CACF;AA/GD,oBA+GC;AAwHD,IAAI,CAAC,KAAK,GAAG,aAAK,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { APIResource } from "../../../../core/resource.mjs";
|
|
3
|
+
import * as FilesAPI from "./files.mjs";
|
|
4
|
+
import { Files } from "./files.mjs";
|
|
5
|
+
import { buildHeaders } from "../../../../internal/headers.mjs";
|
|
6
|
+
import { path } from "../../../../internal/utils/path.mjs";
|
|
7
|
+
/**
|
|
8
|
+
* Create, manage, and execute AI agents with tool access, sandbox environments, and async run workflows
|
|
9
|
+
*/
|
|
10
|
+
export class Chat extends APIResource {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.files = new FilesAPI.Files(this._client);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates a persistent OpenCode chat session in a Modal sandbox. Session state is
|
|
17
|
+
* retained and can be resumed across requests.
|
|
18
|
+
*/
|
|
19
|
+
create(body = {}, options) {
|
|
20
|
+
return this._client.post('/agent/v1/chat', { body, ...options });
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Snapshots and terminates the active sandbox (if any), then marks the chat as
|
|
24
|
+
* ended.
|
|
25
|
+
*/
|
|
26
|
+
delete(id, options) {
|
|
27
|
+
return this._client.delete(path `/agent/v1/chat/${id}`, options);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Aborts the active OpenCode generation for this chat session.
|
|
31
|
+
*/
|
|
32
|
+
cancel(id, options) {
|
|
33
|
+
return this._client.post(path `/agent/v1/chat/${id}/cancel`, options);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Answers a pending OpenCode question for the chat session bound to this agent
|
|
37
|
+
* chat.
|
|
38
|
+
*/
|
|
39
|
+
replyToQuestion(requestID, params, options) {
|
|
40
|
+
const { id, ...body } = params;
|
|
41
|
+
return this._client.post(path `/agent/v1/chat/${id}/question/${requestID}/reply`, {
|
|
42
|
+
body,
|
|
43
|
+
...options,
|
|
44
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Streams a single assistant turn as normalized SSE events with stable turn,
|
|
49
|
+
* message, and part IDs. Emits events: `turn.started`, `turn.status`,
|
|
50
|
+
* `message.created`, `message.part.updated`, `message.completed`, `session.usage`,
|
|
51
|
+
* `turn.completed`.
|
|
52
|
+
*
|
|
53
|
+
* **When to use this endpoint:** Recommended for building custom chat UIs that
|
|
54
|
+
* need real-time streaming progress. This is the primary streaming endpoint for
|
|
55
|
+
* new integrations.
|
|
56
|
+
*
|
|
57
|
+
* **Alternatives:**
|
|
58
|
+
*
|
|
59
|
+
* - `POST /chat/:id/message` — synchronous, returns complete response as JSON
|
|
60
|
+
* (best for server-to-server)
|
|
61
|
+
*/
|
|
62
|
+
respond(id, body, options) {
|
|
63
|
+
return this._client.post(path `/agent/v1/chat/${id}/respond`, {
|
|
64
|
+
body,
|
|
65
|
+
...options,
|
|
66
|
+
headers: buildHeaders([{ Accept: 'text/event-stream' }, options?.headers]),
|
|
67
|
+
stream: true,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Sends a message and returns the complete response as a single JSON body. Blocks
|
|
72
|
+
* until the agent turn completes.
|
|
73
|
+
*
|
|
74
|
+
* **When to use this endpoint:** Best for server-to-server integrations,
|
|
75
|
+
* background processing, or any context where you want the full response in one
|
|
76
|
+
* call without managing an SSE stream.
|
|
77
|
+
*
|
|
78
|
+
* **Alternatives:**
|
|
79
|
+
*
|
|
80
|
+
* - `POST /chat/:id/respond` — streaming SSE with normalized events (recommended
|
|
81
|
+
* for custom chat UIs)
|
|
82
|
+
*/
|
|
83
|
+
sendMessage(id, body, options) {
|
|
84
|
+
return this._client.post(path `/agent/v1/chat/${id}/message`, {
|
|
85
|
+
body,
|
|
86
|
+
...options,
|
|
87
|
+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Relays OpenCode SSE events for this chat. Supports replay from buffered events
|
|
92
|
+
* using Last-Event-ID.
|
|
93
|
+
*/
|
|
94
|
+
stream(id, query = {}, options) {
|
|
95
|
+
return this._client.get(path `/agent/v1/chat/${id}/stream`, {
|
|
96
|
+
query,
|
|
97
|
+
...options,
|
|
98
|
+
headers: buildHeaders([{ Accept: 'text/event-stream' }, options?.headers]),
|
|
99
|
+
stream: true,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
Chat.Files = Files;
|
|
104
|
+
//# sourceMappingURL=chat.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.mjs","sourceRoot":"","sources":["../../../../src/resources/agent/v1/chat/chat.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OACf,KAAK,QAAQ;OACb,EAAwC,KAAK,EAAE;OAG/C,EAAE,YAAY,EAAE;OAEhB,EAAE,IAAI,EAAE;AAEf;;GAEG;AACH,MAAM,OAAO,IAAK,SAAQ,WAAW;IAArC;;QACE,UAAK,GAAmB,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IA8G3D,CAAC;IA5GC;;;OAGG;IACH,MAAM,CACJ,OAA4C,EAAE,EAC9C,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACnE,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,EAAU,EAAE,OAAwB;QACzC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAA,kBAAkB,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,EAAU,EAAE,OAAwB;QACzC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAA,kBAAkB,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACvE,CAAC;IAED;;;OAGG;IACH,eAAe,CACb,SAAiB,EACjB,MAAiC,EACjC,OAAwB;QAExB,MAA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AAmB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC1E,MAAM,EAAE,IAAI;SACb,CAA2C,CAAC;IAC/C,CAAC;CACF;AAwHD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { APIResource } from "../../../../core/resource.mjs";
|
|
2
|
+
import { APIPromise } from "../../../../core/api-promise.mjs";
|
|
3
|
+
import { RequestOptions } from "../../../../internal/request-options.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* Create, manage, and execute AI agents with tool access, sandbox environments, and async run workflows
|
|
6
|
+
*/
|
|
7
|
+
export declare class Files extends APIResource {
|
|
8
|
+
/**
|
|
9
|
+
* Lists files created by the agent in the sandbox workspace. Only available while
|
|
10
|
+
* the sandbox is running.
|
|
11
|
+
*/
|
|
12
|
+
list(id: string, options?: RequestOptions): APIPromise<FileListResponse>;
|
|
13
|
+
/**
|
|
14
|
+
* Downloads a file from the sandbox workspace by path. Only available while the
|
|
15
|
+
* sandbox is running.
|
|
16
|
+
*/
|
|
17
|
+
download(filePath: string, params: FileDownloadParams, options?: RequestOptions): APIPromise<Response>;
|
|
18
|
+
}
|
|
19
|
+
export interface FileListResponse {
|
|
20
|
+
chatId?: string;
|
|
21
|
+
files?: Array<FileListResponse.File>;
|
|
22
|
+
}
|
|
23
|
+
export declare namespace FileListResponse {
|
|
24
|
+
interface File {
|
|
25
|
+
name?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Relative path from /workspace
|
|
28
|
+
*/
|
|
29
|
+
path?: string;
|
|
30
|
+
sizeBytes?: number;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export interface FileDownloadParams {
|
|
34
|
+
/**
|
|
35
|
+
* Chat session ID
|
|
36
|
+
*/
|
|
37
|
+
id: string;
|
|
38
|
+
}
|
|
39
|
+
export declare namespace Files {
|
|
40
|
+
export { type FileListResponse as FileListResponse, type FileDownloadParams as FileDownloadParams };
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=files.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.mts","sourceRoot":"","sources":["../../../../src/resources/agent/v1/chat/files.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OAEd,EAAE,cAAc,EAAE;AAGzB;;GAEG;AACH,qBAAa,KAAM,SAAQ,WAAW;IACpC;;;OAGG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,gBAAgB,CAAC;IAIxE;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,QAAQ,CAAC;CAQvG;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,KAAK,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;CACtC;AAED,yBAAiB,gBAAgB,CAAC;IAChC,UAAiB,IAAI;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;QAEd;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QAEd,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB;CACF;AAED,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,CAAC,OAAO,WAAW,KAAK,CAAC;IAC7B,OAAO,EAAE,KAAK,gBAAgB,IAAI,gBAAgB,EAAE,KAAK,kBAAkB,IAAI,kBAAkB,EAAE,CAAC;CACrG"}
|