@opencode-ai/sdk 0.1.0-alpha.14 → 0.1.0-alpha.15
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 +13 -0
- package/client.d.mts +4 -2
- package/client.d.mts.map +1 -1
- package/client.d.ts +4 -2
- package/client.d.ts.map +1 -1
- package/client.js.map +1 -1
- package/client.mjs.map +1 -1
- package/core/streaming.d.mts +5 -3
- package/core/streaming.d.mts.map +1 -1
- package/core/streaming.d.ts +5 -3
- package/core/streaming.d.ts.map +1 -1
- package/core/streaming.js +16 -10
- package/core/streaming.js.map +1 -1
- package/core/streaming.mjs +16 -10
- package/core/streaming.mjs.map +1 -1
- package/internal/parse.js +2 -2
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +2 -2
- package/internal/parse.mjs.map +1 -1
- package/internal/request-options.d.mts +42 -0
- package/internal/request-options.d.mts.map +1 -1
- package/internal/request-options.d.ts +42 -0
- package/internal/request-options.d.ts.map +1 -1
- package/internal/request-options.js.map +1 -1
- package/internal/request-options.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/event.d.mts +11 -11
- package/resources/event.d.mts.map +1 -1
- package/resources/event.d.ts +11 -11
- package/resources/event.d.ts.map +1 -1
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/session.d.mts +105 -105
- package/resources/session.d.mts.map +1 -1
- package/resources/session.d.ts +105 -105
- package/resources/session.d.ts.map +1 -1
- package/resources/session.js.map +1 -1
- package/resources/session.mjs.map +1 -1
- package/src/client.ts +18 -14
- package/src/core/streaming.ts +22 -8
- package/src/internal/parse.ts +2 -2
- package/src/internal/request-options.ts +53 -0
- package/src/resources/event.ts +14 -14
- package/src/resources/index.ts +8 -7
- package/src/resources/session.ts +122 -128
- 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/src/client.ts
CHANGED
|
@@ -39,10 +39,10 @@ import {
|
|
|
39
39
|
FindTextResponse,
|
|
40
40
|
} from './resources/find';
|
|
41
41
|
import {
|
|
42
|
+
AssistantMessage,
|
|
43
|
+
AssistantMessagePart,
|
|
42
44
|
FilePart,
|
|
43
45
|
Message,
|
|
44
|
-
MessagePart,
|
|
45
|
-
ReasoningPart,
|
|
46
46
|
Session,
|
|
47
47
|
SessionAbortResponse,
|
|
48
48
|
SessionChatParams,
|
|
@@ -54,13 +54,14 @@ import {
|
|
|
54
54
|
SessionResource,
|
|
55
55
|
SessionSummarizeParams,
|
|
56
56
|
SessionSummarizeResponse,
|
|
57
|
-
SourceURLPart,
|
|
58
57
|
StepStartPart,
|
|
59
58
|
TextPart,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
ToolPart,
|
|
60
|
+
ToolStateCompleted,
|
|
61
|
+
ToolStateError,
|
|
62
|
+
ToolStatePending,
|
|
63
|
+
ToolStateRunning,
|
|
64
|
+
UserMessagePart,
|
|
64
65
|
} from './resources/session';
|
|
65
66
|
import { type Fetch } from './internal/builtin-types';
|
|
66
67
|
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
|
|
@@ -89,6 +90,8 @@ export interface ClientOptions {
|
|
|
89
90
|
*
|
|
90
91
|
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
91
92
|
* much longer than this timeout before the promise succeeds or fails.
|
|
93
|
+
*
|
|
94
|
+
* @unit milliseconds
|
|
92
95
|
*/
|
|
93
96
|
timeout?: number | undefined;
|
|
94
97
|
/**
|
|
@@ -777,18 +780,19 @@ export declare namespace Opencode {
|
|
|
777
780
|
|
|
778
781
|
export {
|
|
779
782
|
SessionResource as SessionResource,
|
|
783
|
+
type AssistantMessage as AssistantMessage,
|
|
784
|
+
type AssistantMessagePart as AssistantMessagePart,
|
|
780
785
|
type FilePart as FilePart,
|
|
781
786
|
type Message as Message,
|
|
782
|
-
type MessagePart as MessagePart,
|
|
783
|
-
type ReasoningPart as ReasoningPart,
|
|
784
787
|
type Session as Session,
|
|
785
|
-
type SourceURLPart as SourceURLPart,
|
|
786
788
|
type StepStartPart as StepStartPart,
|
|
787
789
|
type TextPart as TextPart,
|
|
788
|
-
type
|
|
789
|
-
type
|
|
790
|
-
type
|
|
791
|
-
type
|
|
790
|
+
type ToolPart as ToolPart,
|
|
791
|
+
type ToolStateCompleted as ToolStateCompleted,
|
|
792
|
+
type ToolStateError as ToolStateError,
|
|
793
|
+
type ToolStatePending as ToolStatePending,
|
|
794
|
+
type ToolStateRunning as ToolStateRunning,
|
|
795
|
+
type UserMessagePart as UserMessagePart,
|
|
792
796
|
type SessionListResponse as SessionListResponse,
|
|
793
797
|
type SessionDeleteResponse as SessionDeleteResponse,
|
|
794
798
|
type SessionAbortResponse as SessionAbortResponse,
|
package/src/core/streaming.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { findDoubleNewlineIndex, LineDecoder } from '../internal/decoders/line';
|
|
|
5
5
|
import { ReadableStreamToAsyncIterable } from '../internal/shims';
|
|
6
6
|
import { isAbortError } from '../internal/errors';
|
|
7
7
|
import { encodeUTF8 } from '../internal/utils/bytes';
|
|
8
|
+
import { loggerFor } from '../internal/utils/log';
|
|
9
|
+
import type { Opencode } from '../client';
|
|
8
10
|
|
|
9
11
|
type Bytes = string | ArrayBuffer | Uint8Array | null | undefined;
|
|
10
12
|
|
|
@@ -16,16 +18,24 @@ export type ServerSentEvent = {
|
|
|
16
18
|
|
|
17
19
|
export class Stream<Item> implements AsyncIterable<Item> {
|
|
18
20
|
controller: AbortController;
|
|
21
|
+
#client: Opencode | undefined;
|
|
19
22
|
|
|
20
23
|
constructor(
|
|
21
24
|
private iterator: () => AsyncIterator<Item>,
|
|
22
25
|
controller: AbortController,
|
|
26
|
+
client?: Opencode,
|
|
23
27
|
) {
|
|
24
28
|
this.controller = controller;
|
|
29
|
+
this.#client = client;
|
|
25
30
|
}
|
|
26
31
|
|
|
27
|
-
static fromSSEResponse<Item>(
|
|
32
|
+
static fromSSEResponse<Item>(
|
|
33
|
+
response: Response,
|
|
34
|
+
controller: AbortController,
|
|
35
|
+
client?: Opencode,
|
|
36
|
+
): Stream<Item> {
|
|
28
37
|
let consumed = false;
|
|
38
|
+
const logger = client ? loggerFor(client) : console;
|
|
29
39
|
|
|
30
40
|
async function* iterator(): AsyncIterator<Item, any, undefined> {
|
|
31
41
|
if (consumed) {
|
|
@@ -38,8 +48,8 @@ export class Stream<Item> implements AsyncIterable<Item> {
|
|
|
38
48
|
try {
|
|
39
49
|
yield JSON.parse(sse.data);
|
|
40
50
|
} catch (e) {
|
|
41
|
-
|
|
42
|
-
|
|
51
|
+
logger.error(`Could not parse message into JSON:`, sse.data);
|
|
52
|
+
logger.error(`From chunk:`, sse.raw);
|
|
43
53
|
throw e;
|
|
44
54
|
}
|
|
45
55
|
}
|
|
@@ -54,14 +64,18 @@ export class Stream<Item> implements AsyncIterable<Item> {
|
|
|
54
64
|
}
|
|
55
65
|
}
|
|
56
66
|
|
|
57
|
-
return new Stream(iterator, controller);
|
|
67
|
+
return new Stream(iterator, controller, client);
|
|
58
68
|
}
|
|
59
69
|
|
|
60
70
|
/**
|
|
61
71
|
* Generates a Stream from a newline-separated ReadableStream
|
|
62
72
|
* where each item is a JSON value.
|
|
63
73
|
*/
|
|
64
|
-
static fromReadableStream<Item>(
|
|
74
|
+
static fromReadableStream<Item>(
|
|
75
|
+
readableStream: ReadableStream,
|
|
76
|
+
controller: AbortController,
|
|
77
|
+
client?: Opencode,
|
|
78
|
+
): Stream<Item> {
|
|
65
79
|
let consumed = false;
|
|
66
80
|
|
|
67
81
|
async function* iterLines(): AsyncGenerator<string, void, unknown> {
|
|
@@ -101,7 +115,7 @@ export class Stream<Item> implements AsyncIterable<Item> {
|
|
|
101
115
|
}
|
|
102
116
|
}
|
|
103
117
|
|
|
104
|
-
return new Stream(iterator, controller);
|
|
118
|
+
return new Stream(iterator, controller, client);
|
|
105
119
|
}
|
|
106
120
|
|
|
107
121
|
[Symbol.asyncIterator](): AsyncIterator<Item> {
|
|
@@ -131,8 +145,8 @@ export class Stream<Item> implements AsyncIterable<Item> {
|
|
|
131
145
|
};
|
|
132
146
|
|
|
133
147
|
return [
|
|
134
|
-
new Stream(() => teeIterator(left), this.controller),
|
|
135
|
-
new Stream(() => teeIterator(right), this.controller),
|
|
148
|
+
new Stream(() => teeIterator(left), this.controller, this.#client),
|
|
149
|
+
new Stream(() => teeIterator(right), this.controller, this.#client),
|
|
136
150
|
];
|
|
137
151
|
}
|
|
138
152
|
|
package/src/internal/parse.ts
CHANGED
|
@@ -24,10 +24,10 @@ export async function defaultParseResponse<T>(client: Opencode, props: APIRespon
|
|
|
24
24
|
// that if you set `stream: true` the response type must also be `Stream<T>`
|
|
25
25
|
|
|
26
26
|
if (props.options.__streamClass) {
|
|
27
|
-
return props.options.__streamClass.fromSSEResponse(response, props.controller) as any;
|
|
27
|
+
return props.options.__streamClass.fromSSEResponse(response, props.controller, client) as any;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
return Stream.fromSSEResponse(response, props.controller) as any;
|
|
30
|
+
return Stream.fromSSEResponse(response, props.controller, client) as any;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
// fetch refuses to read the body when the status code is 204.
|
|
@@ -10,17 +10,70 @@ import { type HeadersLike } from './headers';
|
|
|
10
10
|
export type FinalRequestOptions = RequestOptions & { method: HTTPMethod; path: string };
|
|
11
11
|
|
|
12
12
|
export type RequestOptions = {
|
|
13
|
+
/**
|
|
14
|
+
* The HTTP method for the request (e.g., 'get', 'post', 'put', 'delete').
|
|
15
|
+
*/
|
|
13
16
|
method?: HTTPMethod;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The URL path for the request.
|
|
20
|
+
*
|
|
21
|
+
* @example "/v1/foo"
|
|
22
|
+
*/
|
|
14
23
|
path?: string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Query parameters to include in the request URL.
|
|
27
|
+
*/
|
|
15
28
|
query?: object | undefined | null;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The request body. Can be a string, JSON object, FormData, or other supported types.
|
|
32
|
+
*/
|
|
16
33
|
body?: unknown;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* HTTP headers to include with the request. Can be a Headers object, plain object, or array of tuples.
|
|
37
|
+
*/
|
|
17
38
|
headers?: HeadersLike;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The maximum number of times that the client will retry a request in case of a
|
|
42
|
+
* temporary failure, like a network error or a 5XX error from the server.
|
|
43
|
+
*
|
|
44
|
+
* @default 2
|
|
45
|
+
*/
|
|
18
46
|
maxRetries?: number;
|
|
47
|
+
|
|
19
48
|
stream?: boolean | undefined;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The maximum amount of time (in milliseconds) that the client should wait for a response
|
|
52
|
+
* from the server before timing out a single request.
|
|
53
|
+
*
|
|
54
|
+
* @unit milliseconds
|
|
55
|
+
*/
|
|
20
56
|
timeout?: number;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Additional `RequestInit` options to be passed to the underlying `fetch` call.
|
|
60
|
+
* These options will be merged with the client's default fetch options.
|
|
61
|
+
*/
|
|
21
62
|
fetchOptions?: MergedRequestInit;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* An AbortSignal that can be used to cancel the request.
|
|
66
|
+
*/
|
|
22
67
|
signal?: AbortSignal | undefined | null;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A unique key for this request to enable idempotency.
|
|
71
|
+
*/
|
|
23
72
|
idempotencyKey?: string;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Override the default base URL for this specific request.
|
|
76
|
+
*/
|
|
24
77
|
defaultBaseURL?: string | undefined;
|
|
25
78
|
|
|
26
79
|
__binaryResponse?: boolean | undefined;
|
package/src/resources/event.ts
CHANGED
|
@@ -20,8 +20,8 @@ export type EventListResponse =
|
|
|
20
20
|
| EventListResponse.EventLspClientDiagnostics
|
|
21
21
|
| EventListResponse.EventPermissionUpdated
|
|
22
22
|
| EventListResponse.EventFileEdited
|
|
23
|
-
| EventListResponse.EventStorageWrite
|
|
24
23
|
| EventListResponse.EventInstallationUpdated
|
|
24
|
+
| EventListResponse.EventStorageWrite
|
|
25
25
|
| EventListResponse.EventMessageUpdated
|
|
26
26
|
| EventListResponse.EventMessageRemoved
|
|
27
27
|
| EventListResponse.EventMessagePartUpdated
|
|
@@ -84,29 +84,29 @@ export namespace EventListResponse {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
export interface
|
|
88
|
-
properties:
|
|
87
|
+
export interface EventInstallationUpdated {
|
|
88
|
+
properties: EventInstallationUpdated.Properties;
|
|
89
89
|
|
|
90
|
-
type: '
|
|
90
|
+
type: 'installation.updated';
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
export namespace
|
|
93
|
+
export namespace EventInstallationUpdated {
|
|
94
94
|
export interface Properties {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
content?: unknown;
|
|
95
|
+
version: string;
|
|
98
96
|
}
|
|
99
97
|
}
|
|
100
98
|
|
|
101
|
-
export interface
|
|
102
|
-
properties:
|
|
99
|
+
export interface EventStorageWrite {
|
|
100
|
+
properties: EventStorageWrite.Properties;
|
|
103
101
|
|
|
104
|
-
type: '
|
|
102
|
+
type: 'storage.write';
|
|
105
103
|
}
|
|
106
104
|
|
|
107
|
-
export namespace
|
|
105
|
+
export namespace EventStorageWrite {
|
|
108
106
|
export interface Properties {
|
|
109
|
-
|
|
107
|
+
key: string;
|
|
108
|
+
|
|
109
|
+
content?: unknown;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -146,7 +146,7 @@ export namespace EventListResponse {
|
|
|
146
146
|
export interface Properties {
|
|
147
147
|
messageID: string;
|
|
148
148
|
|
|
149
|
-
part: SessionAPI.
|
|
149
|
+
part: SessionAPI.AssistantMessagePart;
|
|
150
150
|
|
|
151
151
|
sessionID: string;
|
|
152
152
|
}
|
package/src/resources/index.ts
CHANGED
|
@@ -25,18 +25,19 @@ export {
|
|
|
25
25
|
} from './find';
|
|
26
26
|
export {
|
|
27
27
|
SessionResource,
|
|
28
|
+
type AssistantMessage,
|
|
29
|
+
type AssistantMessagePart,
|
|
28
30
|
type FilePart,
|
|
29
31
|
type Message,
|
|
30
|
-
type MessagePart,
|
|
31
|
-
type ReasoningPart,
|
|
32
32
|
type Session,
|
|
33
|
-
type SourceURLPart,
|
|
34
33
|
type StepStartPart,
|
|
35
34
|
type TextPart,
|
|
36
|
-
type
|
|
37
|
-
type
|
|
38
|
-
type
|
|
39
|
-
type
|
|
35
|
+
type ToolPart,
|
|
36
|
+
type ToolStateCompleted,
|
|
37
|
+
type ToolStateError,
|
|
38
|
+
type ToolStatePending,
|
|
39
|
+
type ToolStateRunning,
|
|
40
|
+
type UserMessagePart,
|
|
40
41
|
type SessionListResponse,
|
|
41
42
|
type SessionDeleteResponse,
|
|
42
43
|
type SessionAbortResponse,
|
package/src/resources/session.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
3
|
import { APIResource } from '../core/resource';
|
|
4
|
+
import * as SessionAPI from './session';
|
|
4
5
|
import * as Shared from './shared';
|
|
5
6
|
import { APIPromise } from '../core/api-promise';
|
|
6
7
|
import { RequestOptions } from '../internal/request-options';
|
|
@@ -38,7 +39,7 @@ export class SessionResource extends APIResource {
|
|
|
38
39
|
/**
|
|
39
40
|
* Create and send a new message to a session
|
|
40
41
|
*/
|
|
41
|
-
chat(id: string, body: SessionChatParams, options?: RequestOptions): APIPromise<
|
|
42
|
+
chat(id: string, body: SessionChatParams, options?: RequestOptions): APIPromise<AssistantMessage> {
|
|
42
43
|
return this._client.post(path`/session/${id}/message`, { body, ...options });
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -82,132 +83,106 @@ export class SessionResource extends APIResource {
|
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
|
|
85
|
-
export interface
|
|
86
|
-
|
|
86
|
+
export interface AssistantMessage {
|
|
87
|
+
id: string;
|
|
87
88
|
|
|
88
|
-
|
|
89
|
+
cost: number;
|
|
89
90
|
|
|
90
|
-
|
|
91
|
+
modelID: string;
|
|
91
92
|
|
|
92
|
-
|
|
93
|
-
}
|
|
93
|
+
parts: Array<AssistantMessagePart>;
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
id: string;
|
|
95
|
+
path: AssistantMessage.Path;
|
|
97
96
|
|
|
98
|
-
|
|
97
|
+
providerID: string;
|
|
99
98
|
|
|
100
|
-
|
|
99
|
+
role: 'assistant';
|
|
101
100
|
|
|
102
|
-
|
|
103
|
-
}
|
|
101
|
+
sessionID: string;
|
|
104
102
|
|
|
105
|
-
|
|
106
|
-
export interface Metadata {
|
|
107
|
-
sessionID: string;
|
|
103
|
+
system: Array<string>;
|
|
108
104
|
|
|
109
|
-
|
|
105
|
+
time: AssistantMessage.Time;
|
|
110
106
|
|
|
111
|
-
|
|
107
|
+
tokens: AssistantMessage.Tokens;
|
|
112
108
|
|
|
113
|
-
|
|
109
|
+
error?: Shared.ProviderAuthError | Shared.UnknownError | AssistantMessage.MessageOutputLengthError;
|
|
114
110
|
|
|
115
|
-
|
|
111
|
+
summary?: boolean;
|
|
112
|
+
}
|
|
116
113
|
|
|
117
|
-
|
|
114
|
+
export namespace AssistantMessage {
|
|
115
|
+
export interface Path {
|
|
116
|
+
cwd: string;
|
|
117
|
+
|
|
118
|
+
root: string;
|
|
118
119
|
}
|
|
119
120
|
|
|
120
|
-
export
|
|
121
|
-
|
|
122
|
-
created: number;
|
|
121
|
+
export interface Time {
|
|
122
|
+
created: number;
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
completed?: number;
|
|
125
|
+
}
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
export interface Tokens {
|
|
128
|
+
cache: Tokens.Cache;
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
input: number;
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
output: number;
|
|
133
133
|
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
reasoning: number;
|
|
135
|
+
}
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
export namespace Tokens {
|
|
138
|
+
export interface Cache {
|
|
139
|
+
read: number;
|
|
140
140
|
|
|
141
|
-
|
|
142
|
-
}
|
|
141
|
+
write: number;
|
|
143
142
|
}
|
|
143
|
+
}
|
|
144
144
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
modelID: string;
|
|
149
|
-
|
|
150
|
-
path: Assistant.Path;
|
|
151
|
-
|
|
152
|
-
providerID: string;
|
|
145
|
+
export interface MessageOutputLengthError {
|
|
146
|
+
data: unknown;
|
|
153
147
|
|
|
154
|
-
|
|
148
|
+
name: 'MessageOutputLengthError';
|
|
149
|
+
}
|
|
150
|
+
}
|
|
155
151
|
|
|
156
|
-
|
|
152
|
+
export type AssistantMessagePart = TextPart | ToolPart | StepStartPart;
|
|
157
153
|
|
|
158
|
-
|
|
159
|
-
|
|
154
|
+
export interface FilePart {
|
|
155
|
+
mime: string;
|
|
160
156
|
|
|
161
|
-
|
|
162
|
-
export interface Path {
|
|
163
|
-
cwd: string;
|
|
157
|
+
type: 'file';
|
|
164
158
|
|
|
165
|
-
|
|
166
|
-
}
|
|
159
|
+
url: string;
|
|
167
160
|
|
|
168
|
-
|
|
169
|
-
|
|
161
|
+
filename?: string;
|
|
162
|
+
}
|
|
170
163
|
|
|
171
|
-
|
|
164
|
+
export type Message = Message.UserMessage | AssistantMessage;
|
|
172
165
|
|
|
173
|
-
|
|
166
|
+
export namespace Message {
|
|
167
|
+
export interface UserMessage {
|
|
168
|
+
id: string;
|
|
174
169
|
|
|
175
|
-
|
|
176
|
-
}
|
|
170
|
+
parts: Array<SessionAPI.UserMessagePart>;
|
|
177
171
|
|
|
178
|
-
|
|
179
|
-
export interface Cache {
|
|
180
|
-
read: number;
|
|
172
|
+
role: 'user';
|
|
181
173
|
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
174
|
+
sessionID: string;
|
|
186
175
|
|
|
187
|
-
|
|
188
|
-
|
|
176
|
+
time: UserMessage.Time;
|
|
177
|
+
}
|
|
189
178
|
|
|
190
|
-
|
|
179
|
+
export namespace UserMessage {
|
|
180
|
+
export interface Time {
|
|
181
|
+
created: number;
|
|
191
182
|
}
|
|
192
183
|
}
|
|
193
184
|
}
|
|
194
185
|
|
|
195
|
-
export type MessagePart =
|
|
196
|
-
| TextPart
|
|
197
|
-
| ReasoningPart
|
|
198
|
-
| ToolInvocationPart
|
|
199
|
-
| SourceURLPart
|
|
200
|
-
| FilePart
|
|
201
|
-
| StepStartPart;
|
|
202
|
-
|
|
203
|
-
export interface ReasoningPart {
|
|
204
|
-
text: string;
|
|
205
|
-
|
|
206
|
-
type: 'reasoning';
|
|
207
|
-
|
|
208
|
-
providerMetadata?: { [key: string]: unknown };
|
|
209
|
-
}
|
|
210
|
-
|
|
211
186
|
export interface Session {
|
|
212
187
|
id: string;
|
|
213
188
|
|
|
@@ -244,18 +219,6 @@ export namespace Session {
|
|
|
244
219
|
}
|
|
245
220
|
}
|
|
246
221
|
|
|
247
|
-
export interface SourceURLPart {
|
|
248
|
-
sourceId: string;
|
|
249
|
-
|
|
250
|
-
type: 'source-url';
|
|
251
|
-
|
|
252
|
-
url: string;
|
|
253
|
-
|
|
254
|
-
providerMetadata?: { [key: string]: unknown };
|
|
255
|
-
|
|
256
|
-
title?: string;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
222
|
export interface StepStartPart {
|
|
260
223
|
type: 'step-start';
|
|
261
224
|
}
|
|
@@ -266,50 +229,80 @@ export interface TextPart {
|
|
|
266
229
|
type: 'text';
|
|
267
230
|
}
|
|
268
231
|
|
|
269
|
-
export interface
|
|
270
|
-
|
|
232
|
+
export interface ToolPart {
|
|
233
|
+
id: string;
|
|
234
|
+
|
|
235
|
+
state: ToolStatePending | ToolStateRunning | ToolStateCompleted | ToolStateError;
|
|
236
|
+
|
|
237
|
+
tool: string;
|
|
238
|
+
|
|
239
|
+
type: 'tool';
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export interface ToolStateCompleted {
|
|
243
|
+
metadata: { [key: string]: unknown };
|
|
244
|
+
|
|
245
|
+
output: string;
|
|
271
246
|
|
|
272
|
-
|
|
247
|
+
status: 'completed';
|
|
273
248
|
|
|
274
|
-
|
|
249
|
+
time: ToolStateCompleted.Time;
|
|
275
250
|
|
|
276
|
-
|
|
251
|
+
title: string;
|
|
277
252
|
|
|
278
|
-
|
|
253
|
+
input?: unknown;
|
|
279
254
|
}
|
|
280
255
|
|
|
281
|
-
export
|
|
282
|
-
|
|
256
|
+
export namespace ToolStateCompleted {
|
|
257
|
+
export interface Time {
|
|
258
|
+
end: number;
|
|
283
259
|
|
|
284
|
-
|
|
260
|
+
start: number;
|
|
261
|
+
}
|
|
285
262
|
}
|
|
286
263
|
|
|
287
|
-
export interface
|
|
288
|
-
|
|
264
|
+
export interface ToolStateError {
|
|
265
|
+
error: string;
|
|
289
266
|
|
|
290
|
-
|
|
267
|
+
status: 'error';
|
|
291
268
|
|
|
292
|
-
|
|
269
|
+
time: ToolStateError.Time;
|
|
293
270
|
|
|
294
|
-
|
|
271
|
+
input?: unknown;
|
|
272
|
+
}
|
|
295
273
|
|
|
296
|
-
|
|
274
|
+
export namespace ToolStateError {
|
|
275
|
+
export interface Time {
|
|
276
|
+
end: number;
|
|
277
|
+
|
|
278
|
+
start: number;
|
|
279
|
+
}
|
|
297
280
|
}
|
|
298
281
|
|
|
299
|
-
export interface
|
|
300
|
-
|
|
282
|
+
export interface ToolStatePending {
|
|
283
|
+
status: 'pending';
|
|
284
|
+
}
|
|
301
285
|
|
|
302
|
-
|
|
286
|
+
export interface ToolStateRunning {
|
|
287
|
+
status: 'running';
|
|
303
288
|
|
|
304
|
-
|
|
289
|
+
time: ToolStateRunning.Time;
|
|
305
290
|
|
|
306
|
-
|
|
291
|
+
input?: unknown;
|
|
307
292
|
|
|
308
|
-
|
|
293
|
+
metadata?: { [key: string]: unknown };
|
|
309
294
|
|
|
310
|
-
|
|
295
|
+
title?: string;
|
|
311
296
|
}
|
|
312
297
|
|
|
298
|
+
export namespace ToolStateRunning {
|
|
299
|
+
export interface Time {
|
|
300
|
+
start: number;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export type UserMessagePart = TextPart | FilePart;
|
|
305
|
+
|
|
313
306
|
export type SessionListResponse = Array<Session>;
|
|
314
307
|
|
|
315
308
|
export type SessionDeleteResponse = boolean;
|
|
@@ -325,7 +318,7 @@ export type SessionSummarizeResponse = boolean;
|
|
|
325
318
|
export interface SessionChatParams {
|
|
326
319
|
modelID: string;
|
|
327
320
|
|
|
328
|
-
parts: Array<
|
|
321
|
+
parts: Array<UserMessagePart>;
|
|
329
322
|
|
|
330
323
|
providerID: string;
|
|
331
324
|
}
|
|
@@ -344,18 +337,19 @@ export interface SessionSummarizeParams {
|
|
|
344
337
|
|
|
345
338
|
export declare namespace SessionResource {
|
|
346
339
|
export {
|
|
340
|
+
type AssistantMessage as AssistantMessage,
|
|
341
|
+
type AssistantMessagePart as AssistantMessagePart,
|
|
347
342
|
type FilePart as FilePart,
|
|
348
343
|
type Message as Message,
|
|
349
|
-
type MessagePart as MessagePart,
|
|
350
|
-
type ReasoningPart as ReasoningPart,
|
|
351
344
|
type Session as Session,
|
|
352
|
-
type SourceURLPart as SourceURLPart,
|
|
353
345
|
type StepStartPart as StepStartPart,
|
|
354
346
|
type TextPart as TextPart,
|
|
355
|
-
type
|
|
356
|
-
type
|
|
357
|
-
type
|
|
358
|
-
type
|
|
347
|
+
type ToolPart as ToolPart,
|
|
348
|
+
type ToolStateCompleted as ToolStateCompleted,
|
|
349
|
+
type ToolStateError as ToolStateError,
|
|
350
|
+
type ToolStatePending as ToolStatePending,
|
|
351
|
+
type ToolStateRunning as ToolStateRunning,
|
|
352
|
+
type UserMessagePart as UserMessagePart,
|
|
359
353
|
type SessionListResponse as SessionListResponse,
|
|
360
354
|
type SessionDeleteResponse as SessionDeleteResponse,
|
|
361
355
|
type SessionAbortResponse as SessionAbortResponse,
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.1.0-alpha.
|
|
1
|
+
export const VERSION = '0.1.0-alpha.15'; // x-release-please-version
|