@reminix/sdk 0.8.0 → 0.8.2
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 +21 -0
- package/README.md +33 -0
- package/index.d.mts +1 -0
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +5 -1
- package/index.js.map +1 -1
- package/index.mjs +2 -0
- package/index.mjs.map +1 -1
- package/package.json +11 -1
- package/resources/agents.d.mts +66 -16
- package/resources/agents.d.mts.map +1 -1
- package/resources/agents.d.ts +66 -16
- package/resources/agents.d.ts.map +1 -1
- package/resources/agents.js +54 -0
- package/resources/agents.js.map +1 -1
- package/resources/agents.mjs +53 -0
- package/resources/agents.mjs.map +1 -1
- package/src/index.ts +4 -0
- package/src/resources/agents.ts +97 -17
- package/src/streaming.ts +87 -0
- package/src/version.ts +1 -1
- package/streaming.d.mts +31 -0
- package/streaming.d.mts.map +1 -0
- package/streaming.d.ts +31 -0
- package/streaming.d.ts.map +1 -0
- package/streaming.js +83 -0
- package/streaming.js.map +1 -0
- package/streaming.mjs +79 -0
- package/streaming.mjs.map +1 -0
- 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,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.2 (2026-01-13)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.8.1...v0.8.2](https://github.com/reminix-ai/reminix-typescript/compare/v0.8.1...v0.8.2)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** api update ([8bf60ad](https://github.com/reminix-ai/reminix-typescript/commit/8bf60ad0759cb36c85f71b9149999fc3d26353dd))
|
|
10
|
+
|
|
11
|
+
## 0.8.1 (2026-01-13)
|
|
12
|
+
|
|
13
|
+
Full Changelog: [v0.8.0...v0.8.1](https://github.com/reminix-ai/reminix-typescript/compare/v0.8.0...v0.8.1)
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* add streaming support for chat and invoke methods ([d757805](https://github.com/reminix-ai/reminix-typescript/commit/d7578054e3ffa813fb6512122a8e91efb966fc20))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* use correct package name in examples ([0679b3e](https://github.com/reminix-ai/reminix-typescript/commit/0679b3ec1fd453c834cb5109255c97e95158c84d))
|
|
23
|
+
|
|
3
24
|
## 0.8.0 (2026-01-13)
|
|
4
25
|
|
|
5
26
|
Full Changelog: [v0.0.1...v0.8.0](https://github.com/reminix-ai/reminix-typescript/compare/v0.0.1...v0.8.0)
|
package/README.md
CHANGED
|
@@ -48,6 +48,39 @@ const project: Reminix.ProjectRetrieveResponse = await client.project.retrieve()
|
|
|
48
48
|
|
|
49
49
|
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
|
|
50
50
|
|
|
51
|
+
## Streaming
|
|
52
|
+
|
|
53
|
+
For real-time responses, use the streaming variants of `chat` and `invoke`:
|
|
54
|
+
|
|
55
|
+
<!-- prettier-ignore -->
|
|
56
|
+
```ts
|
|
57
|
+
import Reminix from '@reminix/sdk';
|
|
58
|
+
|
|
59
|
+
const client = new Reminix();
|
|
60
|
+
|
|
61
|
+
// Streaming chat - prints response in real-time
|
|
62
|
+
const chatStream = await client.agents.chatStream('my-agent', {
|
|
63
|
+
messages: [{ role: 'user', content: 'Tell me a story' }],
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
for await (const chunk of chatStream) {
|
|
67
|
+
process.stdout.write(chunk.chunk);
|
|
68
|
+
}
|
|
69
|
+
console.log();
|
|
70
|
+
|
|
71
|
+
// Streaming invoke
|
|
72
|
+
const invokeStream = await client.agents.invokeStream('my-agent', {
|
|
73
|
+
input: { task: 'generate', prompt: 'Write a poem' },
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
for await (const chunk of invokeStream) {
|
|
77
|
+
process.stdout.write(chunk.chunk);
|
|
78
|
+
}
|
|
79
|
+
console.log();
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The streaming methods return an async iterable `Stream<StreamChunk>` where each chunk contains a portion of the response as it's generated.
|
|
83
|
+
|
|
51
84
|
## Handling errors
|
|
52
85
|
|
|
53
86
|
When the library is unable to connect to the API,
|
package/index.d.mts
CHANGED
|
@@ -3,4 +3,5 @@ export { type Uploadable, toFile } from "./core/uploads.mjs";
|
|
|
3
3
|
export { APIPromise } from "./core/api-promise.mjs";
|
|
4
4
|
export { Reminix, type ClientOptions } from "./client.mjs";
|
|
5
5
|
export { ReminixError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "./core/error.mjs";
|
|
6
|
+
export { Stream, type StreamChunk } from "./streaming.mjs";
|
|
6
7
|
//# sourceMappingURL=index.d.mts.map
|
package/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"OAEO,EAAE,OAAO,IAAI,OAAO,EAAE;OAEtB,EAAE,KAAK,UAAU,EAAE,MAAM,EAAE;OAC3B,EAAE,UAAU,EAAE;OACd,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE;OAC/B,EACL,YAAY,EACZ,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"OAEO,EAAE,OAAO,IAAI,OAAO,EAAE;OAEtB,EAAE,KAAK,UAAU,EAAE,MAAM,EAAE;OAC3B,EAAE,UAAU,EAAE;OACd,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE;OAC/B,EACL,YAAY,EACZ,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB;OAGM,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE"}
|
package/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export { type Uploadable, toFile } from "./core/uploads.js";
|
|
|
3
3
|
export { APIPromise } from "./core/api-promise.js";
|
|
4
4
|
export { Reminix, type ClientOptions } from "./client.js";
|
|
5
5
|
export { ReminixError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "./core/error.js";
|
|
6
|
+
export { Stream, type StreamChunk } from "./streaming.js";
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"OAEO,EAAE,OAAO,IAAI,OAAO,EAAE;OAEtB,EAAE,KAAK,UAAU,EAAE,MAAM,EAAE;OAC3B,EAAE,UAAU,EAAE;OACd,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE;OAC/B,EACL,YAAY,EACZ,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"OAEO,EAAE,OAAO,IAAI,OAAO,EAAE;OAEtB,EAAE,KAAK,UAAU,EAAE,MAAM,EAAE;OAC3B,EAAE,UAAU,EAAE;OACd,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE;OAC/B,EACL,YAAY,EACZ,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB;OAGM,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE"}
|
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@ exports = module.exports = function (...args) {
|
|
|
4
4
|
return new exports.default(...args)
|
|
5
5
|
}
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.UnprocessableEntityError = exports.PermissionDeniedError = exports.InternalServerError = exports.AuthenticationError = exports.BadRequestError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.APIUserAbortError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIError = exports.ReminixError = exports.Reminix = exports.APIPromise = exports.toFile = exports.default = void 0;
|
|
7
|
+
exports.Stream = exports.UnprocessableEntityError = exports.PermissionDeniedError = exports.InternalServerError = exports.AuthenticationError = exports.BadRequestError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.APIUserAbortError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIError = exports.ReminixError = exports.Reminix = exports.APIPromise = exports.toFile = exports.default = void 0;
|
|
8
8
|
var client_1 = require("./client.js");
|
|
9
9
|
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return client_1.Reminix; } });
|
|
10
10
|
var uploads_1 = require("./core/uploads.js");
|
|
@@ -27,4 +27,8 @@ Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: f
|
|
|
27
27
|
Object.defineProperty(exports, "InternalServerError", { enumerable: true, get: function () { return error_1.InternalServerError; } });
|
|
28
28
|
Object.defineProperty(exports, "PermissionDeniedError", { enumerable: true, get: function () { return error_1.PermissionDeniedError; } });
|
|
29
29
|
Object.defineProperty(exports, "UnprocessableEntityError", { enumerable: true, get: function () { return error_1.UnprocessableEntityError; } });
|
|
30
|
+
// stainless-custom-start
|
|
31
|
+
var streaming_1 = require("./streaming.js");
|
|
32
|
+
Object.defineProperty(exports, "Stream", { enumerable: true, get: function () { return streaming_1.Stream; } });
|
|
33
|
+
// stainless-custom-end
|
|
30
34
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,sCAA8C;AAArC,iGAAA,OAAO,OAAW;AAE3B,6CAAyD;AAA/B,iGAAA,MAAM,OAAA;AAChC,qDAAgD;AAAvC,yGAAA,UAAU,OAAA;AACnB,sCAAuD;AAA9C,iGAAA,OAAO,OAAA;AAChB,yCAcsB;AAbpB,qGAAA,YAAY,OAAA;AACZ,iGAAA,QAAQ,OAAA;AACR,2GAAA,kBAAkB,OAAA;AAClB,kHAAA,yBAAyB,OAAA;AACzB,0GAAA,iBAAiB,OAAA;AACjB,sGAAA,aAAa,OAAA;AACb,sGAAA,aAAa,OAAA;AACb,uGAAA,cAAc,OAAA;AACd,wGAAA,eAAe,OAAA;AACf,4GAAA,mBAAmB,OAAA;AACnB,4GAAA,mBAAmB,OAAA;AACnB,8GAAA,qBAAqB,OAAA;AACrB,iHAAA,wBAAwB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,sCAA8C;AAArC,iGAAA,OAAO,OAAW;AAE3B,6CAAyD;AAA/B,iGAAA,MAAM,OAAA;AAChC,qDAAgD;AAAvC,yGAAA,UAAU,OAAA;AACnB,sCAAuD;AAA9C,iGAAA,OAAO,OAAA;AAChB,yCAcsB;AAbpB,qGAAA,YAAY,OAAA;AACZ,iGAAA,QAAQ,OAAA;AACR,2GAAA,kBAAkB,OAAA;AAClB,kHAAA,yBAAyB,OAAA;AACzB,0GAAA,iBAAiB,OAAA;AACjB,sGAAA,aAAa,OAAA;AACb,sGAAA,aAAa,OAAA;AACb,uGAAA,cAAc,OAAA;AACd,wGAAA,eAAe,OAAA;AACf,4GAAA,mBAAmB,OAAA;AACnB,4GAAA,mBAAmB,OAAA;AACnB,8GAAA,qBAAqB,OAAA;AACrB,iHAAA,wBAAwB,OAAA;AAG1B,yBAAyB;AACzB,4CAAuD;AAA9C,mGAAA,MAAM,OAAA;AACf,uBAAuB"}
|
package/index.mjs
CHANGED
|
@@ -4,4 +4,6 @@ export { toFile } from "./core/uploads.mjs";
|
|
|
4
4
|
export { APIPromise } from "./core/api-promise.mjs";
|
|
5
5
|
export { Reminix } from "./client.mjs";
|
|
6
6
|
export { ReminixError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "./core/error.mjs";
|
|
7
|
+
export { Stream } from "./streaming.mjs";
|
|
8
|
+
// stainless-custom-end
|
|
7
9
|
//# sourceMappingURL=index.mjs.map
|
package/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,OAAO,IAAI,OAAO,EAAE;OAEtB,EAAmB,MAAM,EAAE;OAC3B,EAAE,UAAU,EAAE;OACd,EAAE,OAAO,EAAsB;OAC/B,EACL,YAAY,EACZ,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,OAAO,IAAI,OAAO,EAAE;OAEtB,EAAmB,MAAM,EAAE;OAC3B,EAAE,UAAU,EAAE;OACd,EAAE,OAAO,EAAsB;OAC/B,EACL,YAAY,EACZ,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB;OAGM,EAAE,MAAM,EAAoB;AACnC,uBAAuB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reminix/sdk",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "The official TypeScript library for the Reminix API",
|
|
5
5
|
"author": "Reminix <>",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -105,6 +105,16 @@
|
|
|
105
105
|
"./resources.mjs": {
|
|
106
106
|
"default": "./resources.mjs"
|
|
107
107
|
},
|
|
108
|
+
"./streaming": {
|
|
109
|
+
"import": "./streaming.mjs",
|
|
110
|
+
"require": "./streaming.js"
|
|
111
|
+
},
|
|
112
|
+
"./streaming.js": {
|
|
113
|
+
"default": "./streaming.js"
|
|
114
|
+
},
|
|
115
|
+
"./streaming.mjs": {
|
|
116
|
+
"default": "./streaming.mjs"
|
|
117
|
+
},
|
|
108
118
|
"./uploads": {
|
|
109
119
|
"import": "./uploads.mjs",
|
|
110
120
|
"require": "./uploads.js"
|
package/resources/agents.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { APIResource } from "../core/resource.mjs";
|
|
2
2
|
import { APIPromise } from "../core/api-promise.mjs";
|
|
3
3
|
import { RequestOptions } from "../internal/request-options.mjs";
|
|
4
|
+
import { Stream, StreamChunk } from "../streaming.mjs";
|
|
4
5
|
export declare class Agents extends APIResource {
|
|
5
6
|
/**
|
|
6
7
|
* Have a conversational interaction with an agent. This endpoint maintains
|
|
@@ -78,6 +79,40 @@ export declare class Agents extends APIResource {
|
|
|
78
79
|
* ```
|
|
79
80
|
*/
|
|
80
81
|
invoke(name: string, body: AgentInvokeParams, options?: RequestOptions): APIPromise<AgentInvokeResponse>;
|
|
82
|
+
/**
|
|
83
|
+
* Streaming variant of chat(). Returns an async iterable of chunks.
|
|
84
|
+
*
|
|
85
|
+
* Have a conversational interaction with an agent with real-time streaming.
|
|
86
|
+
* Each chunk contains a portion of the response as it's generated.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* const stream = await client.agents.chatStream('my-agent', {
|
|
91
|
+
* messages: [{ role: 'user', content: 'Tell me a story' }],
|
|
92
|
+
* });
|
|
93
|
+
* for await (const chunk of stream) {
|
|
94
|
+
* process.stdout.write(chunk.chunk);
|
|
95
|
+
* }
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
chatStream(name: string, body: Omit<AgentChatParams, 'stream'>, options?: RequestOptions): Promise<Stream<StreamChunk>>;
|
|
99
|
+
/**
|
|
100
|
+
* Streaming variant of invoke(). Returns an async iterable of chunks.
|
|
101
|
+
*
|
|
102
|
+
* Execute a one-shot task with an agent with real-time streaming.
|
|
103
|
+
* Each chunk contains a portion of the response as it's generated.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* const stream = await client.agents.invokeStream('my-agent', {
|
|
108
|
+
* input: { task: 'generate', prompt: 'Write a poem' },
|
|
109
|
+
* });
|
|
110
|
+
* for await (const chunk of stream) {
|
|
111
|
+
* process.stdout.write(chunk.chunk);
|
|
112
|
+
* }
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
invokeStream(name: string, body: Omit<AgentInvokeParams, 'stream'>, options?: RequestOptions): Promise<Stream<StreamChunk>>;
|
|
81
116
|
}
|
|
82
117
|
/**
|
|
83
118
|
* Optional request context passed to the agent handler.
|
|
@@ -100,29 +135,44 @@ export interface Context {
|
|
|
100
135
|
}
|
|
101
136
|
export interface AgentChatResponse {
|
|
102
137
|
/**
|
|
103
|
-
*
|
|
138
|
+
* Full conversation history including the assistant response
|
|
104
139
|
*/
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
export declare namespace AgentChatResponse {
|
|
140
|
+
messages: Array<AgentChatResponse.Message>;
|
|
108
141
|
/**
|
|
109
|
-
*
|
|
142
|
+
* Final assistant response text
|
|
110
143
|
*/
|
|
144
|
+
output: string;
|
|
145
|
+
}
|
|
146
|
+
export declare namespace AgentChatResponse {
|
|
111
147
|
interface Message {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Message content. Can be string, array (multimodal), or object (tool).
|
|
150
|
+
*/
|
|
151
|
+
content: string | Array<Message.UnionMember1> | {
|
|
152
|
+
[key: string]: unknown;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Message role
|
|
156
|
+
*/
|
|
157
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
158
|
+
/**
|
|
159
|
+
* Tool name (required when role is "tool")
|
|
160
|
+
*/
|
|
161
|
+
name?: string;
|
|
162
|
+
/**
|
|
163
|
+
* Tool call ID (for tool role)
|
|
164
|
+
*/
|
|
165
|
+
tool_call_id?: string;
|
|
115
166
|
}
|
|
116
167
|
namespace Message {
|
|
117
|
-
interface
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
168
|
+
interface UnionMember1 {
|
|
169
|
+
type: 'text' | 'image_url';
|
|
170
|
+
image_url?: UnionMember1.ImageURL;
|
|
171
|
+
text?: string;
|
|
121
172
|
}
|
|
122
|
-
namespace
|
|
123
|
-
interface
|
|
124
|
-
|
|
125
|
-
name: string;
|
|
173
|
+
namespace UnionMember1 {
|
|
174
|
+
interface ImageURL {
|
|
175
|
+
url: string;
|
|
126
176
|
}
|
|
127
177
|
}
|
|
128
178
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.mts","sourceRoot":"","sources":["../src/resources/agents.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;
|
|
1
|
+
{"version":3,"file":"agents.d.mts","sourceRoot":"","sources":["../src/resources/agents.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;OAIlB,EAAE,MAAM,EAAE,WAAW,EAAE;AAG9B,qBAAa,MAAO,SAAQ,WAAW;IACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,iBAAiB,CAAC;IAIlG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,mBAAmB,CAAC;IAKxG;;;;;;;;;;;;;;;OAeG;IACG,UAAU,CACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC,EACrC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAU/B;;;;;;;;;;;;;;;OAeG;IACG,YAAY,CAChB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,EACvC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;CAUhC;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB;;OA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|
2
2
|
import { APIPromise } from "../core/api-promise.js";
|
|
3
3
|
import { RequestOptions } from "../internal/request-options.js";
|
|
4
|
+
import { Stream, StreamChunk } from "../streaming.js";
|
|
4
5
|
export declare class Agents extends APIResource {
|
|
5
6
|
/**
|
|
6
7
|
* Have a conversational interaction with an agent. This endpoint maintains
|
|
@@ -78,6 +79,40 @@ export declare class Agents extends APIResource {
|
|
|
78
79
|
* ```
|
|
79
80
|
*/
|
|
80
81
|
invoke(name: string, body: AgentInvokeParams, options?: RequestOptions): APIPromise<AgentInvokeResponse>;
|
|
82
|
+
/**
|
|
83
|
+
* Streaming variant of chat(). Returns an async iterable of chunks.
|
|
84
|
+
*
|
|
85
|
+
* Have a conversational interaction with an agent with real-time streaming.
|
|
86
|
+
* Each chunk contains a portion of the response as it's generated.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* const stream = await client.agents.chatStream('my-agent', {
|
|
91
|
+
* messages: [{ role: 'user', content: 'Tell me a story' }],
|
|
92
|
+
* });
|
|
93
|
+
* for await (const chunk of stream) {
|
|
94
|
+
* process.stdout.write(chunk.chunk);
|
|
95
|
+
* }
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
chatStream(name: string, body: Omit<AgentChatParams, 'stream'>, options?: RequestOptions): Promise<Stream<StreamChunk>>;
|
|
99
|
+
/**
|
|
100
|
+
* Streaming variant of invoke(). Returns an async iterable of chunks.
|
|
101
|
+
*
|
|
102
|
+
* Execute a one-shot task with an agent with real-time streaming.
|
|
103
|
+
* Each chunk contains a portion of the response as it's generated.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* const stream = await client.agents.invokeStream('my-agent', {
|
|
108
|
+
* input: { task: 'generate', prompt: 'Write a poem' },
|
|
109
|
+
* });
|
|
110
|
+
* for await (const chunk of stream) {
|
|
111
|
+
* process.stdout.write(chunk.chunk);
|
|
112
|
+
* }
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
invokeStream(name: string, body: Omit<AgentInvokeParams, 'stream'>, options?: RequestOptions): Promise<Stream<StreamChunk>>;
|
|
81
116
|
}
|
|
82
117
|
/**
|
|
83
118
|
* Optional request context passed to the agent handler.
|
|
@@ -100,29 +135,44 @@ export interface Context {
|
|
|
100
135
|
}
|
|
101
136
|
export interface AgentChatResponse {
|
|
102
137
|
/**
|
|
103
|
-
*
|
|
138
|
+
* Full conversation history including the assistant response
|
|
104
139
|
*/
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
export declare namespace AgentChatResponse {
|
|
140
|
+
messages: Array<AgentChatResponse.Message>;
|
|
108
141
|
/**
|
|
109
|
-
*
|
|
142
|
+
* Final assistant response text
|
|
110
143
|
*/
|
|
144
|
+
output: string;
|
|
145
|
+
}
|
|
146
|
+
export declare namespace AgentChatResponse {
|
|
111
147
|
interface Message {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Message content. Can be string, array (multimodal), or object (tool).
|
|
150
|
+
*/
|
|
151
|
+
content: string | Array<Message.UnionMember1> | {
|
|
152
|
+
[key: string]: unknown;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Message role
|
|
156
|
+
*/
|
|
157
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
158
|
+
/**
|
|
159
|
+
* Tool name (required when role is "tool")
|
|
160
|
+
*/
|
|
161
|
+
name?: string;
|
|
162
|
+
/**
|
|
163
|
+
* Tool call ID (for tool role)
|
|
164
|
+
*/
|
|
165
|
+
tool_call_id?: string;
|
|
115
166
|
}
|
|
116
167
|
namespace Message {
|
|
117
|
-
interface
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
168
|
+
interface UnionMember1 {
|
|
169
|
+
type: 'text' | 'image_url';
|
|
170
|
+
image_url?: UnionMember1.ImageURL;
|
|
171
|
+
text?: string;
|
|
121
172
|
}
|
|
122
|
-
namespace
|
|
123
|
-
interface
|
|
124
|
-
|
|
125
|
-
name: string;
|
|
173
|
+
namespace UnionMember1 {
|
|
174
|
+
interface ImageURL {
|
|
175
|
+
url: string;
|
|
126
176
|
}
|
|
127
177
|
}
|
|
128
178
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/resources/agents.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/resources/agents.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;OAIlB,EAAE,MAAM,EAAE,WAAW,EAAE;AAG9B,qBAAa,MAAO,SAAQ,WAAW;IACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,iBAAiB,CAAC;IAIlG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,mBAAmB,CAAC;IAKxG;;;;;;;;;;;;;;;OAeG;IACG,UAAU,CACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC,EACrC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAU/B;;;;;;;;;;;;;;;OAeG;IACG,YAAY,CAChB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,EACvC,OA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,IAAI,iBAAiB,GAC5C,CAAC;CACH"}
|
package/resources/agents.js
CHANGED
|
@@ -4,6 +4,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.Agents = void 0;
|
|
5
5
|
const resource_1 = require("../core/resource.js");
|
|
6
6
|
const path_1 = require("../internal/utils/path.js");
|
|
7
|
+
// stainless-custom-start
|
|
8
|
+
const streaming_1 = require("../streaming.js");
|
|
9
|
+
// stainless-custom-end
|
|
7
10
|
class Agents extends resource_1.APIResource {
|
|
8
11
|
/**
|
|
9
12
|
* Have a conversational interaction with an agent. This endpoint maintains
|
|
@@ -85,6 +88,57 @@ class Agents extends resource_1.APIResource {
|
|
|
85
88
|
invoke(name, body, options) {
|
|
86
89
|
return this._client.post((0, path_1.path) `/agents/${name}/invoke`, { body, ...options });
|
|
87
90
|
}
|
|
91
|
+
// stainless-custom-start
|
|
92
|
+
/**
|
|
93
|
+
* Streaming variant of chat(). Returns an async iterable of chunks.
|
|
94
|
+
*
|
|
95
|
+
* Have a conversational interaction with an agent with real-time streaming.
|
|
96
|
+
* Each chunk contains a portion of the response as it's generated.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* const stream = await client.agents.chatStream('my-agent', {
|
|
101
|
+
* messages: [{ role: 'user', content: 'Tell me a story' }],
|
|
102
|
+
* });
|
|
103
|
+
* for await (const chunk of stream) {
|
|
104
|
+
* process.stdout.write(chunk.chunk);
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
async chatStream(name, body, options) {
|
|
109
|
+
const response = await this._client.post((0, path_1.path) `/agents/${name}/chat`, {
|
|
110
|
+
body: { ...body, stream: true },
|
|
111
|
+
...options,
|
|
112
|
+
headers: { Accept: 'text/event-stream', ...options?.headers },
|
|
113
|
+
__binaryResponse: true,
|
|
114
|
+
});
|
|
115
|
+
return new streaming_1.Stream(response);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Streaming variant of invoke(). Returns an async iterable of chunks.
|
|
119
|
+
*
|
|
120
|
+
* Execute a one-shot task with an agent with real-time streaming.
|
|
121
|
+
* Each chunk contains a portion of the response as it's generated.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* const stream = await client.agents.invokeStream('my-agent', {
|
|
126
|
+
* input: { task: 'generate', prompt: 'Write a poem' },
|
|
127
|
+
* });
|
|
128
|
+
* for await (const chunk of stream) {
|
|
129
|
+
* process.stdout.write(chunk.chunk);
|
|
130
|
+
* }
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
async invokeStream(name, body, options) {
|
|
134
|
+
const response = await this._client.post((0, path_1.path) `/agents/${name}/invoke`, {
|
|
135
|
+
body: { ...body, stream: true },
|
|
136
|
+
...options,
|
|
137
|
+
headers: { Accept: 'text/event-stream', ...options?.headers },
|
|
138
|
+
__binaryResponse: true,
|
|
139
|
+
});
|
|
140
|
+
return new streaming_1.Stream(response);
|
|
141
|
+
}
|
|
88
142
|
}
|
|
89
143
|
exports.Agents = Agents;
|
|
90
144
|
//# sourceMappingURL=agents.js.map
|
package/resources/agents.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/resources/agents.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAG/C,oDAA8C;AAE9C,MAAa,MAAO,SAAQ,sBAAW;IACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;IACH,IAAI,CAAC,IAAY,EAAE,IAAqB,EAAE,OAAwB;QAChE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,WAAI,EAAA,WAAW,IAAI,OAAO,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IAC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MAAM,EAAE,mBAAmB,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE;YAC7D,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;QACH,OAAO,IAAI,kBAAM,CAAc,QAA+B,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,KAAK,CAAC,YAAY,CAChB,IAAY,EACZ,IAAuC,EACvC,OAAwB;QAExB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,WAAI,EAAA,WAAW,IAAI,SAAS,EAAE;YACrE,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;YAC/B,GAAG,OAAO;YACV,OAAO,EAAE,EAAE,MAAM,EAAE,mBAAmB,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE;YAC7D,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;QACH,OAAO,IAAI,kBAAM,CAAc,QAA+B,CAAC,CAAC;IAClE,CAAC;CAEF;AAhJD,wBAgJC"}
|
package/resources/agents.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
import { APIResource } from "../core/resource.mjs";
|
|
3
3
|
import { path } from "../internal/utils/path.mjs";
|
|
4
|
+
import { Stream } from "../streaming.mjs";
|
|
5
|
+
// stainless-custom-end
|
|
4
6
|
export class Agents extends APIResource {
|
|
5
7
|
/**
|
|
6
8
|
* Have a conversational interaction with an agent. This endpoint maintains
|
|
@@ -82,5 +84,56 @@ export class Agents extends APIResource {
|
|
|
82
84
|
invoke(name, body, options) {
|
|
83
85
|
return this._client.post(path `/agents/${name}/invoke`, { body, ...options });
|
|
84
86
|
}
|
|
87
|
+
// stainless-custom-start
|
|
88
|
+
/**
|
|
89
|
+
* Streaming variant of chat(). Returns an async iterable of chunks.
|
|
90
|
+
*
|
|
91
|
+
* Have a conversational interaction with an agent with real-time streaming.
|
|
92
|
+
* Each chunk contains a portion of the response as it's generated.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* const stream = await client.agents.chatStream('my-agent', {
|
|
97
|
+
* messages: [{ role: 'user', content: 'Tell me a story' }],
|
|
98
|
+
* });
|
|
99
|
+
* for await (const chunk of stream) {
|
|
100
|
+
* process.stdout.write(chunk.chunk);
|
|
101
|
+
* }
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
async chatStream(name, body, options) {
|
|
105
|
+
const response = await this._client.post(path `/agents/${name}/chat`, {
|
|
106
|
+
body: { ...body, stream: true },
|
|
107
|
+
...options,
|
|
108
|
+
headers: { Accept: 'text/event-stream', ...options?.headers },
|
|
109
|
+
__binaryResponse: true,
|
|
110
|
+
});
|
|
111
|
+
return new Stream(response);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Streaming variant of invoke(). Returns an async iterable of chunks.
|
|
115
|
+
*
|
|
116
|
+
* Execute a one-shot task with an agent with real-time streaming.
|
|
117
|
+
* Each chunk contains a portion of the response as it's generated.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* const stream = await client.agents.invokeStream('my-agent', {
|
|
122
|
+
* input: { task: 'generate', prompt: 'Write a poem' },
|
|
123
|
+
* });
|
|
124
|
+
* for await (const chunk of stream) {
|
|
125
|
+
* process.stdout.write(chunk.chunk);
|
|
126
|
+
* }
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
async invokeStream(name, body, options) {
|
|
130
|
+
const response = await this._client.post(path `/agents/${name}/invoke`, {
|
|
131
|
+
body: { ...body, stream: true },
|
|
132
|
+
...options,
|
|
133
|
+
headers: { Accept: 'text/event-stream', ...options?.headers },
|
|
134
|
+
__binaryResponse: true,
|
|
135
|
+
});
|
|
136
|
+
return new Stream(response);
|
|
137
|
+
}
|
|
85
138
|
}
|
|
86
139
|
//# sourceMappingURL=agents.mjs.map
|
package/resources/agents.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.mjs","sourceRoot":"","sources":["../src/resources/agents.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAGf,EAAE,IAAI,EAAE;
|
|
1
|
+
{"version":3,"file":"agents.mjs","sourceRoot":"","sources":["../src/resources/agents.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAGf,EAAE,IAAI,EAAE;OAGR,EAAE,MAAM,EAAe;AAC9B,uBAAuB;AAEvB,MAAM,OAAO,MAAO,SAAQ,WAAW;IACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;IACH,IAAI,CAAC,IAAY,EAAE,IAAqB,EAAE,OAAwB;QAChE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAA,WAAW,IAAI,OAAO,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,MAAM,CAAC,IAAY,EAAE,IAAuB,EAAE,OAAwB;QACpE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAA,WAAW,IAAI,SAAS,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC/E,CAAC;IAED,yBAAyB;IACzB;;;;;;;;;;;;;;;OAeG;IACH,KAAK,CAAC,UAAU,CACd,IAAY,EACZ,IAAqC,EACrC,OAAwB;QAExB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAA,WAAW,IAAI,OAAO,EAAE;YACnE,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;YAC/B,GAAG,OAAO;YACV,OAAO,EAAE,EAAE,MAAM,EAAE,mBAAmB,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE;YAC7D,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;QACH,OAAO,IAAI,MAAM,CAAc,QAA+B,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,KAAK,CAAC,YAAY,CAChB,IAAY,EACZ,IAAuC,EACvC,OAAwB;QAExB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAA,WAAW,IAAI,SAAS,EAAE;YACrE,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;YAC/B,GAAG,OAAO;YACV,OAAO,EAAE,EAAE,MAAM,EAAE,mBAAmB,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE;YAC7D,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;QACH,OAAO,IAAI,MAAM,CAAc,QAA+B,CAAC,CAAC;IAClE,CAAC;CAEF"}
|
package/src/index.ts
CHANGED
package/src/resources/agents.ts
CHANGED
|
@@ -5,6 +5,10 @@ import { APIPromise } from '../core/api-promise';
|
|
|
5
5
|
import { RequestOptions } from '../internal/request-options';
|
|
6
6
|
import { path } from '../internal/utils/path';
|
|
7
7
|
|
|
8
|
+
// stainless-custom-start
|
|
9
|
+
import { Stream, StreamChunk } from '../streaming';
|
|
10
|
+
// stainless-custom-end
|
|
11
|
+
|
|
8
12
|
export class Agents extends APIResource {
|
|
9
13
|
/**
|
|
10
14
|
* Have a conversational interaction with an agent. This endpoint maintains
|
|
@@ -87,6 +91,68 @@ export class Agents extends APIResource {
|
|
|
87
91
|
invoke(name: string, body: AgentInvokeParams, options?: RequestOptions): APIPromise<AgentInvokeResponse> {
|
|
88
92
|
return this._client.post(path`/agents/${name}/invoke`, { body, ...options });
|
|
89
93
|
}
|
|
94
|
+
|
|
95
|
+
// stainless-custom-start
|
|
96
|
+
/**
|
|
97
|
+
* Streaming variant of chat(). Returns an async iterable of chunks.
|
|
98
|
+
*
|
|
99
|
+
* Have a conversational interaction with an agent with real-time streaming.
|
|
100
|
+
* Each chunk contains a portion of the response as it's generated.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* const stream = await client.agents.chatStream('my-agent', {
|
|
105
|
+
* messages: [{ role: 'user', content: 'Tell me a story' }],
|
|
106
|
+
* });
|
|
107
|
+
* for await (const chunk of stream) {
|
|
108
|
+
* process.stdout.write(chunk.chunk);
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
async chatStream(
|
|
113
|
+
name: string,
|
|
114
|
+
body: Omit<AgentChatParams, 'stream'>,
|
|
115
|
+
options?: RequestOptions,
|
|
116
|
+
): Promise<Stream<StreamChunk>> {
|
|
117
|
+
const response = await this._client.post(path`/agents/${name}/chat`, {
|
|
118
|
+
body: { ...body, stream: true },
|
|
119
|
+
...options,
|
|
120
|
+
headers: { Accept: 'text/event-stream', ...options?.headers },
|
|
121
|
+
__binaryResponse: true,
|
|
122
|
+
});
|
|
123
|
+
return new Stream<StreamChunk>(response as unknown as Response);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Streaming variant of invoke(). Returns an async iterable of chunks.
|
|
128
|
+
*
|
|
129
|
+
* Execute a one-shot task with an agent with real-time streaming.
|
|
130
|
+
* Each chunk contains a portion of the response as it's generated.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* const stream = await client.agents.invokeStream('my-agent', {
|
|
135
|
+
* input: { task: 'generate', prompt: 'Write a poem' },
|
|
136
|
+
* });
|
|
137
|
+
* for await (const chunk of stream) {
|
|
138
|
+
* process.stdout.write(chunk.chunk);
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
async invokeStream(
|
|
143
|
+
name: string,
|
|
144
|
+
body: Omit<AgentInvokeParams, 'stream'>,
|
|
145
|
+
options?: RequestOptions,
|
|
146
|
+
): Promise<Stream<StreamChunk>> {
|
|
147
|
+
const response = await this._client.post(path`/agents/${name}/invoke`, {
|
|
148
|
+
body: { ...body, stream: true },
|
|
149
|
+
...options,
|
|
150
|
+
headers: { Accept: 'text/event-stream', ...options?.headers },
|
|
151
|
+
__binaryResponse: true,
|
|
152
|
+
});
|
|
153
|
+
return new Stream<StreamChunk>(response as unknown as Response);
|
|
154
|
+
}
|
|
155
|
+
// stainless-custom-end
|
|
90
156
|
}
|
|
91
157
|
|
|
92
158
|
/**
|
|
@@ -111,37 +177,51 @@ export interface Context {
|
|
|
111
177
|
|
|
112
178
|
export interface AgentChatResponse {
|
|
113
179
|
/**
|
|
114
|
-
*
|
|
180
|
+
* Full conversation history including the assistant response
|
|
115
181
|
*/
|
|
116
|
-
|
|
117
|
-
}
|
|
182
|
+
messages: Array<AgentChatResponse.Message>;
|
|
118
183
|
|
|
119
|
-
export namespace AgentChatResponse {
|
|
120
184
|
/**
|
|
121
|
-
*
|
|
185
|
+
* Final assistant response text
|
|
122
186
|
*/
|
|
187
|
+
output: string;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export namespace AgentChatResponse {
|
|
123
191
|
export interface Message {
|
|
124
|
-
|
|
192
|
+
/**
|
|
193
|
+
* Message content. Can be string, array (multimodal), or object (tool).
|
|
194
|
+
*/
|
|
195
|
+
content: string | Array<Message.UnionMember1> | { [key: string]: unknown };
|
|
125
196
|
|
|
126
|
-
|
|
197
|
+
/**
|
|
198
|
+
* Message role
|
|
199
|
+
*/
|
|
200
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Tool name (required when role is "tool")
|
|
204
|
+
*/
|
|
205
|
+
name?: string;
|
|
127
206
|
|
|
128
|
-
|
|
207
|
+
/**
|
|
208
|
+
* Tool call ID (for tool role)
|
|
209
|
+
*/
|
|
210
|
+
tool_call_id?: string;
|
|
129
211
|
}
|
|
130
212
|
|
|
131
213
|
export namespace Message {
|
|
132
|
-
export interface
|
|
133
|
-
|
|
214
|
+
export interface UnionMember1 {
|
|
215
|
+
type: 'text' | 'image_url';
|
|
134
216
|
|
|
135
|
-
|
|
217
|
+
image_url?: UnionMember1.ImageURL;
|
|
136
218
|
|
|
137
|
-
|
|
219
|
+
text?: string;
|
|
138
220
|
}
|
|
139
221
|
|
|
140
|
-
export namespace
|
|
141
|
-
export interface
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
name: string;
|
|
222
|
+
export namespace UnionMember1 {
|
|
223
|
+
export interface ImageURL {
|
|
224
|
+
url: string;
|
|
145
225
|
}
|
|
146
226
|
}
|
|
147
227
|
}
|
package/src/streaming.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// stainless-custom-start
|
|
2
|
+
/**
|
|
3
|
+
* Streaming utilities for SSE (Server-Sent Events) responses.
|
|
4
|
+
*
|
|
5
|
+
* This module provides streaming support for the Reminix API.
|
|
6
|
+
* When you upgrade to Stainless Pro, you can remove this file
|
|
7
|
+
* and use the built-in streaming support.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A chunk from a streaming response.
|
|
12
|
+
*/
|
|
13
|
+
export interface StreamChunk {
|
|
14
|
+
/** Text chunk from the stream */
|
|
15
|
+
chunk: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* An async iterable stream that parses SSE (Server-Sent Events) responses.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const stream = await client.agents.chatStream('agent', { messages: [...] });
|
|
24
|
+
* for await (const chunk of stream) {
|
|
25
|
+
* process.stdout.write(chunk.chunk);
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export class Stream<T> implements AsyncIterable<T> {
|
|
30
|
+
constructor(private response: Response) {}
|
|
31
|
+
|
|
32
|
+
async *[Symbol.asyncIterator](): AsyncIterator<T> {
|
|
33
|
+
const reader = this.response.body?.getReader();
|
|
34
|
+
if (!reader) {
|
|
35
|
+
throw new Error('Response body is not readable');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const decoder = new TextDecoder();
|
|
39
|
+
let buffer = '';
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
while (true) {
|
|
43
|
+
const { done, value } = await reader.read();
|
|
44
|
+
if (done) break;
|
|
45
|
+
|
|
46
|
+
buffer += decoder.decode(value, { stream: true });
|
|
47
|
+
const lines = buffer.split('\n');
|
|
48
|
+
buffer = lines.pop() || '';
|
|
49
|
+
|
|
50
|
+
for (const line of lines) {
|
|
51
|
+
const trimmed = line.trim();
|
|
52
|
+
if (trimmed.startsWith('data: ')) {
|
|
53
|
+
const data = trimmed.slice(6);
|
|
54
|
+
if (data === '[DONE]') {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (data) {
|
|
58
|
+
try {
|
|
59
|
+
yield JSON.parse(data) as T;
|
|
60
|
+
} catch {
|
|
61
|
+
// Skip malformed JSON
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Process any remaining data in buffer
|
|
69
|
+
if (buffer.trim()) {
|
|
70
|
+
const trimmed = buffer.trim();
|
|
71
|
+
if (trimmed.startsWith('data: ')) {
|
|
72
|
+
const data = trimmed.slice(6);
|
|
73
|
+
if (data && data !== '[DONE]') {
|
|
74
|
+
try {
|
|
75
|
+
yield JSON.parse(data) as T;
|
|
76
|
+
} catch {
|
|
77
|
+
// Skip malformed JSON
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
} finally {
|
|
83
|
+
reader.releaseLock();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// stainless-custom-end
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.8.
|
|
1
|
+
export const VERSION = '0.8.2'; // x-release-please-version
|
package/streaming.d.mts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming utilities for SSE (Server-Sent Events) responses.
|
|
3
|
+
*
|
|
4
|
+
* This module provides streaming support for the Reminix API.
|
|
5
|
+
* When you upgrade to Stainless Pro, you can remove this file
|
|
6
|
+
* and use the built-in streaming support.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A chunk from a streaming response.
|
|
10
|
+
*/
|
|
11
|
+
export interface StreamChunk {
|
|
12
|
+
/** Text chunk from the stream */
|
|
13
|
+
chunk: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* An async iterable stream that parses SSE (Server-Sent Events) responses.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const stream = await client.agents.chatStream('agent', { messages: [...] });
|
|
21
|
+
* for await (const chunk of stream) {
|
|
22
|
+
* process.stdout.write(chunk.chunk);
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class Stream<T> implements AsyncIterable<T> {
|
|
27
|
+
private response;
|
|
28
|
+
constructor(response: Response);
|
|
29
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=streaming.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.d.mts","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;GAUG;AACH,qBAAa,MAAM,CAAC,CAAC,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;IACpC,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,QAAQ;IAE/B,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC;CAsDlD"}
|
package/streaming.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming utilities for SSE (Server-Sent Events) responses.
|
|
3
|
+
*
|
|
4
|
+
* This module provides streaming support for the Reminix API.
|
|
5
|
+
* When you upgrade to Stainless Pro, you can remove this file
|
|
6
|
+
* and use the built-in streaming support.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A chunk from a streaming response.
|
|
10
|
+
*/
|
|
11
|
+
export interface StreamChunk {
|
|
12
|
+
/** Text chunk from the stream */
|
|
13
|
+
chunk: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* An async iterable stream that parses SSE (Server-Sent Events) responses.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const stream = await client.agents.chatStream('agent', { messages: [...] });
|
|
21
|
+
* for await (const chunk of stream) {
|
|
22
|
+
* process.stdout.write(chunk.chunk);
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class Stream<T> implements AsyncIterable<T> {
|
|
27
|
+
private response;
|
|
28
|
+
constructor(response: Response);
|
|
29
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=streaming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;GAUG;AACH,qBAAa,MAAM,CAAC,CAAC,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;IACpC,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,QAAQ;IAE/B,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC;CAsDlD"}
|
package/streaming.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// stainless-custom-start
|
|
3
|
+
/**
|
|
4
|
+
* Streaming utilities for SSE (Server-Sent Events) responses.
|
|
5
|
+
*
|
|
6
|
+
* This module provides streaming support for the Reminix API.
|
|
7
|
+
* When you upgrade to Stainless Pro, you can remove this file
|
|
8
|
+
* and use the built-in streaming support.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.Stream = void 0;
|
|
12
|
+
/**
|
|
13
|
+
* An async iterable stream that parses SSE (Server-Sent Events) responses.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const stream = await client.agents.chatStream('agent', { messages: [...] });
|
|
18
|
+
* for await (const chunk of stream) {
|
|
19
|
+
* process.stdout.write(chunk.chunk);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
class Stream {
|
|
24
|
+
constructor(response) {
|
|
25
|
+
this.response = response;
|
|
26
|
+
}
|
|
27
|
+
async *[Symbol.asyncIterator]() {
|
|
28
|
+
const reader = this.response.body?.getReader();
|
|
29
|
+
if (!reader) {
|
|
30
|
+
throw new Error('Response body is not readable');
|
|
31
|
+
}
|
|
32
|
+
const decoder = new TextDecoder();
|
|
33
|
+
let buffer = '';
|
|
34
|
+
try {
|
|
35
|
+
while (true) {
|
|
36
|
+
const { done, value } = await reader.read();
|
|
37
|
+
if (done)
|
|
38
|
+
break;
|
|
39
|
+
buffer += decoder.decode(value, { stream: true });
|
|
40
|
+
const lines = buffer.split('\n');
|
|
41
|
+
buffer = lines.pop() || '';
|
|
42
|
+
for (const line of lines) {
|
|
43
|
+
const trimmed = line.trim();
|
|
44
|
+
if (trimmed.startsWith('data: ')) {
|
|
45
|
+
const data = trimmed.slice(6);
|
|
46
|
+
if (data === '[DONE]') {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (data) {
|
|
50
|
+
try {
|
|
51
|
+
yield JSON.parse(data);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// Skip malformed JSON
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// Process any remaining data in buffer
|
|
61
|
+
if (buffer.trim()) {
|
|
62
|
+
const trimmed = buffer.trim();
|
|
63
|
+
if (trimmed.startsWith('data: ')) {
|
|
64
|
+
const data = trimmed.slice(6);
|
|
65
|
+
if (data && data !== '[DONE]') {
|
|
66
|
+
try {
|
|
67
|
+
yield JSON.parse(data);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// Skip malformed JSON
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
reader.releaseLock();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.Stream = Stream;
|
|
82
|
+
// stainless-custom-end
|
|
83
|
+
//# sourceMappingURL=streaming.js.map
|
package/streaming.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.js","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":";AAAA,yBAAyB;AACzB;;;;;;GAMG;;;AAUH;;;;;;;;;;GAUG;AACH,MAAa,MAAM;IACjB,YAAoB,QAAkB;QAAlB,aAAQ,GAAR,QAAQ,CAAU;IAAG,CAAC;IAE1C,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;QAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC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O,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;oBACjC,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBAC9B,IAAI,IAAI,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;wBAC9B,IAAI,CAAC;4BACH,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAC;wBAC9B,CAAC;wBAAC,MAAM,CAAC;4BACP,sBAAsB;wBACxB,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,WAAW,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;CACF;AAzDD,wBAyDC;AACD,uBAAuB"}
|
package/streaming.mjs
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// stainless-custom-start
|
|
2
|
+
/**
|
|
3
|
+
* Streaming utilities for SSE (Server-Sent Events) responses.
|
|
4
|
+
*
|
|
5
|
+
* This module provides streaming support for the Reminix API.
|
|
6
|
+
* When you upgrade to Stainless Pro, you can remove this file
|
|
7
|
+
* and use the built-in streaming support.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* An async iterable stream that parses SSE (Server-Sent Events) responses.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const stream = await client.agents.chatStream('agent', { messages: [...] });
|
|
15
|
+
* for await (const chunk of stream) {
|
|
16
|
+
* process.stdout.write(chunk.chunk);
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export class Stream {
|
|
21
|
+
constructor(response) {
|
|
22
|
+
this.response = response;
|
|
23
|
+
}
|
|
24
|
+
async *[Symbol.asyncIterator]() {
|
|
25
|
+
const reader = this.response.body?.getReader();
|
|
26
|
+
if (!reader) {
|
|
27
|
+
throw new Error('Response body is not readable');
|
|
28
|
+
}
|
|
29
|
+
const decoder = new TextDecoder();
|
|
30
|
+
let buffer = '';
|
|
31
|
+
try {
|
|
32
|
+
while (true) {
|
|
33
|
+
const { done, value } = await reader.read();
|
|
34
|
+
if (done)
|
|
35
|
+
break;
|
|
36
|
+
buffer += decoder.decode(value, { stream: true });
|
|
37
|
+
const lines = buffer.split('\n');
|
|
38
|
+
buffer = lines.pop() || '';
|
|
39
|
+
for (const line of lines) {
|
|
40
|
+
const trimmed = line.trim();
|
|
41
|
+
if (trimmed.startsWith('data: ')) {
|
|
42
|
+
const data = trimmed.slice(6);
|
|
43
|
+
if (data === '[DONE]') {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (data) {
|
|
47
|
+
try {
|
|
48
|
+
yield JSON.parse(data);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// Skip malformed JSON
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Process any remaining data in buffer
|
|
58
|
+
if (buffer.trim()) {
|
|
59
|
+
const trimmed = buffer.trim();
|
|
60
|
+
if (trimmed.startsWith('data: ')) {
|
|
61
|
+
const data = trimmed.slice(6);
|
|
62
|
+
if (data && data !== '[DONE]') {
|
|
63
|
+
try {
|
|
64
|
+
yield JSON.parse(data);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// Skip malformed JSON
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
reader.releaseLock();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// stainless-custom-end
|
|
79
|
+
//# sourceMappingURL=streaming.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.mjs","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB;;;;;;GAMG;AAUH;;;;;;;;;;GAUG;AACH,MAAM,OAAO,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ACP,sBAAsB;4BACxB,CAAC;wBACH,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;YAED,uCAAuC;YACvC,IAAI,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;gBAClB,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC9B,IAAI,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;oBACjC,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBAC9B,IAAI,IAAI,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;wBAC9B,IAAI,CAAC;4BACH,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAC;wBAC9B,CAAC;wBAAC,MAAM,CAAC;4BACP,sBAAsB;wBACxB,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,WAAW,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;CACF;AACD,uBAAuB"}
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.8.
|
|
1
|
+
export declare const VERSION = "0.8.2";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.8.
|
|
1
|
+
export declare const VERSION = "0.8.2";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.8.
|
|
1
|
+
export const VERSION = '0.8.2'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|