@aaif/goose-sdk 0.16.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod.gen.d.ts","sourceRoot":"","sources":["../../src/generated/zod.gen.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;EAG/B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc,wCAAwB,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;EAGlC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;EAE3B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;EAE5B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;EAI/B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;EAEhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;EAGnC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;EAEhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB,wCAAwB,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;EAGjC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;EAejC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;EAElC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB,wCAAwB,CAAC;AAE3D,eAAO,MAAM,kBAAkB;;;;;;;;;EAG7B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;EAEjC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM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;;EAEhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;EAWjC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;EAEjC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;EAEnC,CAAC;AAEH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCtB,CAAC;AAEH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA6BvB,CAAC"}
@@ -0,0 +1,316 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ import { z } from 'zod';
3
+ /**
4
+ * Add an extension to an active session.
5
+ */
6
+ export const zAddExtensionRequest = z.object({
7
+ sessionId: z.string(),
8
+ config: z.unknown().optional().default(null)
9
+ });
10
+ /**
11
+ * Empty success response for operations that return no data.
12
+ */
13
+ export const zEmptyResponse = z.record(z.unknown());
14
+ /**
15
+ * Remove an extension from an active session.
16
+ */
17
+ export const zRemoveExtensionRequest = z.object({
18
+ sessionId: z.string(),
19
+ name: z.string()
20
+ });
21
+ /**
22
+ * List all tools available in a session.
23
+ */
24
+ export const zGetToolsRequest = z.object({
25
+ sessionId: z.string()
26
+ });
27
+ /**
28
+ * Tools response.
29
+ */
30
+ export const zGetToolsResponse = z.object({
31
+ tools: z.array(z.unknown())
32
+ });
33
+ /**
34
+ * Read a resource from an extension.
35
+ */
36
+ export const zReadResourceRequest = z.object({
37
+ sessionId: z.string(),
38
+ uri: z.string(),
39
+ extensionName: z.string()
40
+ });
41
+ /**
42
+ * Resource read response.
43
+ */
44
+ export const zReadResourceResponse = z.object({
45
+ result: z.unknown().optional().default(null)
46
+ });
47
+ /**
48
+ * Update the working directory for a session.
49
+ */
50
+ export const zUpdateWorkingDirRequest = z.object({
51
+ sessionId: z.string(),
52
+ workingDir: z.string()
53
+ });
54
+ /**
55
+ * Delete a session.
56
+ */
57
+ export const zDeleteSessionRequest = z.object({
58
+ sessionId: z.string()
59
+ });
60
+ /**
61
+ * List configured extensions and any warnings.
62
+ */
63
+ export const zGetExtensionsRequest = z.record(z.unknown());
64
+ /**
65
+ * List configured extensions and any warnings.
66
+ */
67
+ export const zGetExtensionsResponse = z.object({
68
+ extensions: z.array(z.unknown()),
69
+ warnings: z.array(z.string())
70
+ });
71
+ /**
72
+ * Atomically update the provider for a live session.
73
+ */
74
+ export const zUpdateProviderRequest = z.object({
75
+ sessionId: z.string(),
76
+ provider: z.string(),
77
+ model: z.union([
78
+ z.string(),
79
+ z.null()
80
+ ]).optional(),
81
+ contextLimit: z.union([
82
+ z.number().int().gte(0),
83
+ z.null()
84
+ ]).optional(),
85
+ requestParams: z.union([
86
+ z.record(z.unknown()),
87
+ z.null()
88
+ ]).optional()
89
+ });
90
+ /**
91
+ * Provider update response.
92
+ */
93
+ export const zUpdateProviderResponse = z.object({
94
+ configOptions: z.array(z.unknown())
95
+ });
96
+ /**
97
+ * List providers available through goose, including the config-default sentinel.
98
+ */
99
+ export const zListProvidersRequest = z.record(z.unknown());
100
+ export const zProviderListEntry = z.object({
101
+ id: z.string(),
102
+ label: z.string()
103
+ });
104
+ /**
105
+ * Provider list response.
106
+ */
107
+ export const zListProvidersResponse = z.object({
108
+ providers: z.array(zProviderListEntry)
109
+ });
110
+ /**
111
+ * List providers with full metadata (config keys, setup steps, etc.).
112
+ */
113
+ export const zGetProviderDetailsRequest = z.record(z.unknown());
114
+ export const zProviderConfigKey = z.object({
115
+ name: z.string(),
116
+ required: z.boolean(),
117
+ secret: z.boolean(),
118
+ default: z.union([
119
+ z.string(),
120
+ z.null()
121
+ ]).optional().default(null),
122
+ oauthFlow: z.boolean().optional().default(false),
123
+ deviceCodeFlow: z.boolean().optional().default(false),
124
+ primary: z.boolean().optional().default(false)
125
+ });
126
+ export const zModelEntry = z.object({
127
+ name: z.string(),
128
+ contextLimit: z.number().int().gte(0)
129
+ });
130
+ export const zProviderDetailEntry = z.object({
131
+ name: z.string(),
132
+ displayName: z.string(),
133
+ description: z.string(),
134
+ defaultModel: z.string(),
135
+ isConfigured: z.boolean(),
136
+ providerType: z.string(),
137
+ configKeys: z.array(zProviderConfigKey),
138
+ setupSteps: z.array(z.string()).optional().default([]),
139
+ knownModels: z.array(zModelEntry).optional().default([])
140
+ });
141
+ /**
142
+ * Provider details response.
143
+ */
144
+ export const zGetProviderDetailsResponse = z.object({
145
+ providers: z.array(zProviderDetailEntry)
146
+ });
147
+ /**
148
+ * Fetch the full list of models available for a specific provider.
149
+ */
150
+ export const zGetProviderModelsRequest = z.object({
151
+ providerName: z.string()
152
+ });
153
+ /**
154
+ * Provider models response.
155
+ */
156
+ export const zGetProviderModelsResponse = z.object({
157
+ models: z.array(z.string())
158
+ });
159
+ /**
160
+ * Read a single non-secret config value.
161
+ */
162
+ export const zReadConfigRequest = z.object({
163
+ key: z.string()
164
+ });
165
+ /**
166
+ * Config read response.
167
+ */
168
+ export const zReadConfigResponse = z.object({
169
+ value: z.unknown().optional().default(null)
170
+ });
171
+ /**
172
+ * Upsert a single non-secret config value.
173
+ */
174
+ export const zUpsertConfigRequest = z.object({
175
+ key: z.string(),
176
+ value: z.unknown()
177
+ });
178
+ /**
179
+ * Remove a single non-secret config value.
180
+ */
181
+ export const zRemoveConfigRequest = z.object({
182
+ key: z.string()
183
+ });
184
+ /**
185
+ * Check whether a secret exists. Never returns the actual value.
186
+ */
187
+ export const zCheckSecretRequest = z.object({
188
+ key: z.string()
189
+ });
190
+ /**
191
+ * Secret check response.
192
+ */
193
+ export const zCheckSecretResponse = z.object({
194
+ exists: z.boolean()
195
+ });
196
+ /**
197
+ * Set a secret value (write-only).
198
+ */
199
+ export const zUpsertSecretRequest = z.object({
200
+ key: z.string(),
201
+ value: z.unknown()
202
+ });
203
+ /**
204
+ * Remove a secret.
205
+ */
206
+ export const zRemoveSecretRequest = z.object({
207
+ key: z.string()
208
+ });
209
+ /**
210
+ * Export a session as a JSON string.
211
+ */
212
+ export const zExportSessionRequest = z.object({
213
+ sessionId: z.string()
214
+ });
215
+ /**
216
+ * Export session response — raw JSON of the goose session with `conversation`.
217
+ */
218
+ export const zExportSessionResponse = z.object({
219
+ data: z.string()
220
+ });
221
+ /**
222
+ * Import a session from a JSON string.
223
+ */
224
+ export const zImportSessionRequest = z.object({
225
+ data: z.string()
226
+ });
227
+ /**
228
+ * Import session response — metadata about the newly created session.
229
+ */
230
+ export const zImportSessionResponse = z.object({
231
+ sessionId: z.string(),
232
+ title: z.union([
233
+ z.string(),
234
+ z.null()
235
+ ]).optional(),
236
+ updatedAt: z.union([
237
+ z.string(),
238
+ z.null()
239
+ ]).optional(),
240
+ messageCount: z.number().int().gte(0)
241
+ });
242
+ /**
243
+ * Archive a session (soft delete).
244
+ */
245
+ export const zArchiveSessionRequest = z.object({
246
+ sessionId: z.string()
247
+ });
248
+ /**
249
+ * Unarchive a previously archived session.
250
+ */
251
+ export const zUnarchiveSessionRequest = z.object({
252
+ sessionId: z.string()
253
+ });
254
+ export const zExtRequest = z.object({
255
+ id: z.string(),
256
+ method: z.string(),
257
+ params: z.union([
258
+ z.union([
259
+ zAddExtensionRequest,
260
+ zRemoveExtensionRequest,
261
+ zGetToolsRequest,
262
+ zReadResourceRequest,
263
+ zUpdateWorkingDirRequest,
264
+ zDeleteSessionRequest,
265
+ zGetExtensionsRequest,
266
+ zUpdateProviderRequest,
267
+ zListProvidersRequest,
268
+ zGetProviderDetailsRequest,
269
+ zGetProviderModelsRequest,
270
+ zReadConfigRequest,
271
+ zUpsertConfigRequest,
272
+ zRemoveConfigRequest,
273
+ zCheckSecretRequest,
274
+ zUpsertSecretRequest,
275
+ zRemoveSecretRequest,
276
+ zExportSessionRequest,
277
+ zImportSessionRequest,
278
+ zArchiveSessionRequest,
279
+ zUnarchiveSessionRequest
280
+ ]),
281
+ z.union([
282
+ z.record(z.unknown()),
283
+ z.null()
284
+ ])
285
+ ]).optional()
286
+ });
287
+ export const zExtResponse = z.union([
288
+ z.object({
289
+ id: z.string(),
290
+ result: z.union([
291
+ z.union([
292
+ zEmptyResponse,
293
+ zGetToolsResponse,
294
+ zReadResourceResponse,
295
+ zGetExtensionsResponse,
296
+ zUpdateProviderResponse,
297
+ zListProvidersResponse,
298
+ zGetProviderDetailsResponse,
299
+ zGetProviderModelsResponse,
300
+ zReadConfigResponse,
301
+ zCheckSecretResponse,
302
+ zExportSessionResponse,
303
+ zImportSessionResponse
304
+ ]),
305
+ z.unknown()
306
+ ]).optional()
307
+ }),
308
+ z.object({
309
+ error: z.object({
310
+ code: z.number().int(),
311
+ message: z.string(),
312
+ data: z.unknown().optional()
313
+ }),
314
+ id: z.string()
315
+ })
316
+ ]);
@@ -0,0 +1,24 @@
1
+ import { type Client, type Stream, type InitializeRequest, type InitializeResponse, type NewSessionRequest, type NewSessionResponse, type LoadSessionRequest, type LoadSessionResponse, type PromptRequest, type PromptResponse, type CancelNotification, type AuthenticateRequest, type AuthenticateResponse, type SetSessionModeRequest, type SetSessionModeResponse, type SetSessionConfigOptionRequest, type SetSessionConfigOptionResponse, type ForkSessionRequest, type ForkSessionResponse, type ListSessionsRequest, type ListSessionsResponse, type ResumeSessionRequest, type ResumeSessionResponse, type SetSessionModelRequest, type SetSessionModelResponse } from "@agentclientprotocol/sdk";
2
+ import { GooseExtClient } from "./generated/client.gen.js";
3
+ export declare class GooseClient {
4
+ private conn;
5
+ private ext;
6
+ constructor(toClient: () => Client, streamOrUrl: Stream | string);
7
+ get signal(): AbortSignal;
8
+ get closed(): Promise<void>;
9
+ initialize(params: InitializeRequest): Promise<InitializeResponse>;
10
+ newSession(params: NewSessionRequest): Promise<NewSessionResponse>;
11
+ loadSession(params: LoadSessionRequest): Promise<LoadSessionResponse>;
12
+ prompt(params: PromptRequest): Promise<PromptResponse>;
13
+ cancel(params: CancelNotification): Promise<void>;
14
+ authenticate(params: AuthenticateRequest): Promise<AuthenticateResponse>;
15
+ setSessionMode(params: SetSessionModeRequest): Promise<SetSessionModeResponse>;
16
+ setSessionConfigOption(params: SetSessionConfigOptionRequest): Promise<SetSessionConfigOptionResponse>;
17
+ unstable_forkSession(params: ForkSessionRequest): Promise<ForkSessionResponse>;
18
+ unstable_listSessions(params: ListSessionsRequest): Promise<ListSessionsResponse>;
19
+ unstable_resumeSession(params: ResumeSessionRequest): Promise<ResumeSessionResponse>;
20
+ unstable_setSessionModel(params: SetSessionModelRequest): Promise<SetSessionModelResponse>;
21
+ extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
22
+ get goose(): GooseExtClient;
23
+ }
24
+ //# sourceMappingURL=goose-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"goose-client.d.ts","sourceRoot":"","sources":["../src/goose-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACx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;IAI/B,qBAAqB,CACnB,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,oBAAoB,CAAC;IAIhC,sBAAsB,CACpB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,qBAAqB,CAAC;IAIjC,wBAAwB,CACtB,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,uBAAuB,CAAC;IAInC,SAAS,CACP,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAInC,IAAI,KAAK,IAAI,cAAc,CAE1B;CACF"}
@@ -0,0 +1,62 @@
1
+ import { ClientSideConnection, } from "@agentclientprotocol/sdk";
2
+ import { GooseExtClient } from "./generated/client.gen.js";
3
+ import { createHttpStream } from "./http-stream.js";
4
+ export class GooseClient {
5
+ conn;
6
+ ext;
7
+ constructor(toClient, streamOrUrl) {
8
+ const stream = typeof streamOrUrl === "string"
9
+ ? createHttpStream(streamOrUrl)
10
+ : streamOrUrl;
11
+ this.conn = new ClientSideConnection(toClient, stream);
12
+ this.ext = new GooseExtClient(this.conn);
13
+ }
14
+ get signal() {
15
+ return this.conn.signal;
16
+ }
17
+ get closed() {
18
+ return this.conn.closed;
19
+ }
20
+ initialize(params) {
21
+ return this.conn.initialize(params);
22
+ }
23
+ newSession(params) {
24
+ return this.conn.newSession(params);
25
+ }
26
+ loadSession(params) {
27
+ return this.conn.loadSession(params);
28
+ }
29
+ prompt(params) {
30
+ return this.conn.prompt(params);
31
+ }
32
+ cancel(params) {
33
+ return this.conn.cancel(params);
34
+ }
35
+ authenticate(params) {
36
+ return this.conn.authenticate(params);
37
+ }
38
+ setSessionMode(params) {
39
+ return this.conn.setSessionMode(params);
40
+ }
41
+ setSessionConfigOption(params) {
42
+ return this.conn.setSessionConfigOption(params);
43
+ }
44
+ unstable_forkSession(params) {
45
+ return this.conn.unstable_forkSession(params);
46
+ }
47
+ unstable_listSessions(params) {
48
+ return this.conn.unstable_listSessions(params);
49
+ }
50
+ unstable_resumeSession(params) {
51
+ return this.conn.unstable_resumeSession(params);
52
+ }
53
+ unstable_setSessionModel(params) {
54
+ return this.conn.unstable_setSessionModel(params);
55
+ }
56
+ extMethod(method, params) {
57
+ return this.conn.extMethod(method, params);
58
+ }
59
+ get goose() {
60
+ return this.ext;
61
+ }
62
+ }
@@ -0,0 +1,3 @@
1
+ import type { Stream } from "@agentclientprotocol/sdk";
2
+ export declare function createHttpStream(serverUrl: string): Stream;
3
+ //# sourceMappingURL=http-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-stream.d.ts","sourceRoot":"","sources":["../src/http-stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAInE,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAmH1D"}
@@ -0,0 +1,110 @@
1
+ const ACP_SESSION_HEADER = "Acp-Session-Id";
2
+ export function createHttpStream(serverUrl) {
3
+ let sessionId = null;
4
+ const incoming = [];
5
+ const waiters = [];
6
+ const sseAbort = new AbortController();
7
+ function pushMessage(msg) {
8
+ incoming.push(msg);
9
+ const w = waiters.shift();
10
+ if (w)
11
+ w();
12
+ }
13
+ function waitForMessage() {
14
+ if (incoming.length > 0)
15
+ return Promise.resolve();
16
+ return new Promise((r) => waiters.push(r));
17
+ }
18
+ async function consumeSSE(response) {
19
+ if (!response.body)
20
+ return;
21
+ const reader = response.body.getReader();
22
+ const decoder = new TextDecoder();
23
+ let buffer = "";
24
+ try {
25
+ while (true) {
26
+ const { done, value } = await reader.read();
27
+ if (done)
28
+ break;
29
+ buffer += decoder.decode(value, { stream: true });
30
+ const parts = buffer.split("\n\n");
31
+ buffer = parts.pop() || "";
32
+ for (const part of parts) {
33
+ for (const line of part.split("\n")) {
34
+ if (line.startsWith("data: ")) {
35
+ try {
36
+ const msg = JSON.parse(line.slice(6));
37
+ pushMessage(msg);
38
+ }
39
+ catch {
40
+ // ignore malformed JSON
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }
46
+ }
47
+ catch (e) {
48
+ if (e instanceof DOMException && e.name === "AbortError")
49
+ return;
50
+ }
51
+ }
52
+ let isFirstRequest = true;
53
+ const readable = new ReadableStream({
54
+ async pull(controller) {
55
+ await waitForMessage();
56
+ while (incoming.length > 0) {
57
+ controller.enqueue(incoming.shift());
58
+ }
59
+ },
60
+ });
61
+ const writable = new WritableStream({
62
+ async write(msg) {
63
+ const isRequest = "method" in msg &&
64
+ "id" in msg &&
65
+ msg.id !== undefined &&
66
+ msg.id !== null;
67
+ const headers = {
68
+ "Content-Type": "application/json",
69
+ Accept: "application/json, text/event-stream",
70
+ };
71
+ if (sessionId) {
72
+ headers[ACP_SESSION_HEADER] = sessionId;
73
+ }
74
+ if (isFirstRequest && isRequest) {
75
+ isFirstRequest = false;
76
+ const response = await fetch(`${serverUrl}/acp`, {
77
+ method: "POST",
78
+ headers,
79
+ body: JSON.stringify(msg),
80
+ signal: sseAbort.signal,
81
+ });
82
+ const sid = response.headers.get(ACP_SESSION_HEADER);
83
+ if (sid)
84
+ sessionId = sid;
85
+ consumeSSE(response);
86
+ }
87
+ else if (isRequest) {
88
+ const abort = new AbortController();
89
+ fetch(`${serverUrl}/acp`, {
90
+ method: "POST",
91
+ headers,
92
+ body: JSON.stringify(msg),
93
+ signal: abort.signal,
94
+ }).catch(() => { });
95
+ setTimeout(() => abort.abort(), 200);
96
+ }
97
+ else {
98
+ await fetch(`${serverUrl}/acp`, {
99
+ method: "POST",
100
+ headers,
101
+ body: JSON.stringify(msg),
102
+ });
103
+ }
104
+ },
105
+ close() {
106
+ sseAbort.abort();
107
+ },
108
+ });
109
+ return { readable, writable };
110
+ }
@@ -0,0 +1,6 @@
1
+ export * from "./generated/types.gen.js";
2
+ export * from "./generated/zod.gen.js";
3
+ export { GooseClient } from "./goose-client.js";
4
+ export { createHttpStream } from "./http-stream.js";
5
+ export { ClientSideConnection, type Client, type Stream, } from "@agentclientprotocol/sdk";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EACL,oBAAoB,EACpB,KAAK,MAAM,EACX,KAAK,MAAM,GACZ,MAAM,0BAA0B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from "./generated/types.gen.js";
2
+ export * from "./generated/zod.gen.js";
3
+ export { GooseClient } from "./goose-client.js";
4
+ export { createHttpStream } from "./http-stream.js";
5
+ export { ClientSideConnection, } from "@agentclientprotocol/sdk";
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@aaif/goose-sdk",
3
+ "version": "0.16.0",
4
+ "description": "Agent Client Protocol (ACP) SDK for Goose AI agent",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/aaif-goose/goose.git"
9
+ },
10
+ "keywords": [
11
+ "goose",
12
+ "ai",
13
+ "agent",
14
+ "acp",
15
+ "agent-client-protocol"
16
+ ],
17
+ "type": "module",
18
+ "main": "./dist/index.js",
19
+ "types": "./dist/index.d.ts",
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "dependencies": {
24
+ "zod": "^3.25.76"
25
+ },
26
+ "peerDependencies": {
27
+ "@agentclientprotocol/sdk": "*"
28
+ },
29
+ "devDependencies": {
30
+ "@agentclientprotocol/sdk": "^0.14.1",
31
+ "@hey-api/openapi-ts": "^0.92.3",
32
+ "@types/node": "^20.0.0",
33
+ "prettier": "^3.8.1",
34
+ "tsx": "^4.21.0",
35
+ "typescript": "~5.9.3"
36
+ },
37
+ "scripts": {
38
+ "build": "npm run generate && npm run build:ts",
39
+ "build:ts": "tsc",
40
+ "build:native": "tsx scripts/build-native.ts",
41
+ "build:native:all": "tsx scripts/build-native.ts --all",
42
+ "generate": "tsx generate-schema.ts",
43
+ "lint": "tsc --noEmit",
44
+ "format": "prettier --write src/"
45
+ }
46
+ }