@agent-api/sdk 1.1.3 → 1.1.5
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 +11 -0
- package/README.md +26 -4
- package/dist/client.d.ts +4 -1
- package/dist/client.js +5 -1
- package/dist/index.d.ts +1 -5
- package/dist/index.js +1 -3
- package/dist/local-skills.js +13 -1
- package/dist/node-client.d.ts +6 -0
- package/dist/node-client.js +7 -0
- package/dist/node.d.ts +8 -0
- package/dist/node.js +6 -0
- package/dist/resources/auth.d.ts +3 -1
- package/dist/resources/auth.js +18 -0
- package/dist/resources/skills-node.d.ts +7 -0
- package/dist/resources/skills-node.js +156 -0
- package/dist/resources/skills.d.ts +1 -3
- package/dist/resources/skills.js +0 -153
- package/dist/types/auth.d.ts +3 -0
- package/dist/types/responses.d.ts +4 -0
- package/dist/version.d.ts +2 -2
- package/dist/version.js +1 -1
- package/dist-cjs/client.js +72 -0
- package/dist-cjs/errors.js +146 -0
- package/dist-cjs/index.js +52 -0
- package/dist-cjs/internal/env.js +7 -0
- package/dist-cjs/internal/http.js +108 -0
- package/dist-cjs/internal/output-text.js +15 -0
- package/dist-cjs/internal/query.js +13 -0
- package/dist-cjs/local/context.js +158 -0
- package/dist-cjs/local/core.js +1077 -0
- package/dist-cjs/local/index.js +19 -0
- package/dist-cjs/local/tools.js +380 -0
- package/dist-cjs/local-functions.js +37 -0
- package/dist-cjs/local-skills.js +308 -0
- package/dist-cjs/node-client.js +11 -0
- package/dist-cjs/node.js +32 -0
- package/dist-cjs/package.json +3 -0
- package/dist-cjs/pagination.js +43 -0
- package/dist-cjs/preset-tools.js +91 -0
- package/dist-cjs/resources/auth.js +111 -0
- package/dist-cjs/resources/models.js +13 -0
- package/dist-cjs/resources/presets.js +13 -0
- package/dist-cjs/resources/responses.js +58 -0
- package/dist-cjs/resources/skills-node.js +193 -0
- package/dist-cjs/resources/skills.js +112 -0
- package/dist-cjs/resources/tools.js +13 -0
- package/dist-cjs/resources/volumes.js +114 -0
- package/dist-cjs/streaming.js +42 -0
- package/dist-cjs/tool-validation.js +18 -0
- package/dist-cjs/types/auth.js +2 -0
- package/dist-cjs/types/catalog.js +2 -0
- package/dist-cjs/types/common.js +2 -0
- package/dist-cjs/types/index.js +25 -0
- package/dist-cjs/types/input.js +2 -0
- package/dist-cjs/types/responses.js +2 -0
- package/dist-cjs/types/skills.js +2 -0
- package/dist-cjs/types/streaming.js +2 -0
- package/dist-cjs/types/tools.js +2 -0
- package/dist-cjs/types/volumes.js +2 -0
- package/dist-cjs/version.js +5 -0
- package/package.json +20 -5
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResponsesResource = void 0;
|
|
4
|
+
const output_text_js_1 = require("../internal/output-text.js");
|
|
5
|
+
const query_js_1 = require("../internal/query.js");
|
|
6
|
+
const pagination_js_1 = require("../pagination.js");
|
|
7
|
+
const tool_validation_js_1 = require("../tool-validation.js");
|
|
8
|
+
class ResponsesResource {
|
|
9
|
+
http;
|
|
10
|
+
path;
|
|
11
|
+
constructor(http, path = "/v1/responses") {
|
|
12
|
+
this.http = http;
|
|
13
|
+
this.path = path;
|
|
14
|
+
}
|
|
15
|
+
create(params, options) {
|
|
16
|
+
(0, tool_validation_js_1.validateUniqueToolNames)(params.tools);
|
|
17
|
+
if (params.stream) {
|
|
18
|
+
return this.http.stream(this.path, params, options);
|
|
19
|
+
}
|
|
20
|
+
return this.http.request("POST", this.path, params, options).then(output_text_js_1.addOutputText);
|
|
21
|
+
}
|
|
22
|
+
list(params = {}, options) {
|
|
23
|
+
return this.http.request("GET", `${this.path}${(0, query_js_1.buildQuery)({ limit: params.limit, page_token: params.page_token })}`, undefined, options);
|
|
24
|
+
}
|
|
25
|
+
async listPage(params = {}, options) {
|
|
26
|
+
return (0, pagination_js_1.collectPage)((pageParams) => this.list(pageParams, options), params);
|
|
27
|
+
}
|
|
28
|
+
listIterator(params = {}, options) {
|
|
29
|
+
const self = this;
|
|
30
|
+
return {
|
|
31
|
+
async *[Symbol.asyncIterator]() {
|
|
32
|
+
const page = await self.listPage(params, options);
|
|
33
|
+
yield* page.iterateAll();
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
retrieve(responseID, options) {
|
|
38
|
+
return this.http
|
|
39
|
+
.request("GET", `${this.path}/${encodeURIComponent(responseID)}`, undefined, options)
|
|
40
|
+
.then(output_text_js_1.addOutputText);
|
|
41
|
+
}
|
|
42
|
+
cancel(responseID, options) {
|
|
43
|
+
return this.http.request("POST", `${this.path}/${encodeURIComponent(responseID)}/cancel`, undefined, options);
|
|
44
|
+
}
|
|
45
|
+
listChildren(responseID, options) {
|
|
46
|
+
return this.http.request("GET", `${this.path}/${encodeURIComponent(responseID)}/children`, undefined, options);
|
|
47
|
+
}
|
|
48
|
+
listEvents(responseID, params = {}, options) {
|
|
49
|
+
return this.http.request("GET", `${this.path}/${encodeURIComponent(responseID)}/events${(0, query_js_1.buildQuery)({
|
|
50
|
+
after_sequence: params.after_sequence,
|
|
51
|
+
view: params.view,
|
|
52
|
+
})}`, undefined, options);
|
|
53
|
+
}
|
|
54
|
+
retrieveVolume(responseID, options) {
|
|
55
|
+
return this.http.request("GET", `${this.path}/${encodeURIComponent(responseID)}/volume`, undefined, options);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.ResponsesResource = ResponsesResource;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.NodeSkillsResource = void 0;
|
|
37
|
+
const skills_js_1 = require("./skills.js");
|
|
38
|
+
class NodeSkillsResource extends skills_js_1.SkillsResource {
|
|
39
|
+
async pushDirectory(skillID, rootDir, params = {}, options) {
|
|
40
|
+
const archive = await zipDirectory(rootDir);
|
|
41
|
+
return this.importArchive(skillID, archive, params, options);
|
|
42
|
+
}
|
|
43
|
+
async pullDirectory(skillID, targetDir, params = {}, options) {
|
|
44
|
+
const archive = await this.exportArchive(skillID, params, options);
|
|
45
|
+
return extractStoredZipToDirectory(archive.content, targetDir, { replace: params.replace === true });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.NodeSkillsResource = NodeSkillsResource;
|
|
49
|
+
async function zipDirectory(rootDir) {
|
|
50
|
+
const fs = await Promise.resolve().then(() => __importStar(require("node:fs/promises")));
|
|
51
|
+
const path = await Promise.resolve().then(() => __importStar(require("node:path")));
|
|
52
|
+
const root = path.resolve(rootDir);
|
|
53
|
+
const files = await walkArchiveFiles(fs, path, root, root);
|
|
54
|
+
const entries = [];
|
|
55
|
+
for (const rel of files.sort()) {
|
|
56
|
+
const content = await fs.readFile(path.join(root, rel));
|
|
57
|
+
entries.push({ path: rel, data: new Uint8Array(content.buffer, content.byteOffset, content.byteLength) });
|
|
58
|
+
}
|
|
59
|
+
return createStoredZip(entries);
|
|
60
|
+
}
|
|
61
|
+
async function walkArchiveFiles(fs, path, root, dir) {
|
|
62
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
63
|
+
const out = [];
|
|
64
|
+
for (const entry of entries) {
|
|
65
|
+
if (entry.name === ".git" || entry.name === "__pycache__" || entry.name === "node_modules") {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const full = path.join(dir, entry.name);
|
|
69
|
+
if (entry.isDirectory()) {
|
|
70
|
+
out.push(...await walkArchiveFiles(fs, path, root, full));
|
|
71
|
+
}
|
|
72
|
+
else if (entry.isFile()) {
|
|
73
|
+
out.push(path.relative(root, full).split(path.sep).join("/"));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
async function extractStoredZipToDirectory(archive, targetDir, opts) {
|
|
79
|
+
const fs = await Promise.resolve().then(() => __importStar(require("node:fs/promises")));
|
|
80
|
+
const path = await Promise.resolve().then(() => __importStar(require("node:path")));
|
|
81
|
+
const root = path.resolve(targetDir);
|
|
82
|
+
if (opts.replace) {
|
|
83
|
+
await fs.rm(root, { recursive: true, force: true });
|
|
84
|
+
}
|
|
85
|
+
await fs.mkdir(root, { recursive: true });
|
|
86
|
+
let fileCount = 0;
|
|
87
|
+
let byteCount = 0;
|
|
88
|
+
for (const entry of parseStoredZip(archive)) {
|
|
89
|
+
const dest = path.resolve(root, entry.path);
|
|
90
|
+
const rel = path.relative(root, dest);
|
|
91
|
+
if (rel.startsWith("..") || path.isAbsolute(rel)) {
|
|
92
|
+
throw new Error(`archive entry escapes target directory: ${entry.path}`);
|
|
93
|
+
}
|
|
94
|
+
await fs.mkdir(path.dirname(dest), { recursive: true });
|
|
95
|
+
await fs.writeFile(dest, entry.data);
|
|
96
|
+
fileCount += 1;
|
|
97
|
+
byteCount += entry.data.byteLength;
|
|
98
|
+
}
|
|
99
|
+
return { path: root, file_count: fileCount, byte_count: byteCount };
|
|
100
|
+
}
|
|
101
|
+
function createStoredZip(entries) {
|
|
102
|
+
const encoder = new TextEncoder();
|
|
103
|
+
const localParts = [];
|
|
104
|
+
const centralParts = [];
|
|
105
|
+
let offset = 0;
|
|
106
|
+
for (const entry of entries) {
|
|
107
|
+
const name = encoder.encode(entry.path);
|
|
108
|
+
const crc = crc32(entry.data);
|
|
109
|
+
const local = new Uint8Array(30 + name.length);
|
|
110
|
+
const lv = new DataView(local.buffer);
|
|
111
|
+
lv.setUint32(0, 0x04034b50, true);
|
|
112
|
+
lv.setUint16(4, 20, true);
|
|
113
|
+
lv.setUint16(8, 0, true);
|
|
114
|
+
lv.setUint32(14, crc, true);
|
|
115
|
+
lv.setUint32(18, entry.data.byteLength, true);
|
|
116
|
+
lv.setUint32(22, entry.data.byteLength, true);
|
|
117
|
+
lv.setUint16(26, name.length, true);
|
|
118
|
+
local.set(name, 30);
|
|
119
|
+
localParts.push(local, entry.data);
|
|
120
|
+
const central = new Uint8Array(46 + name.length);
|
|
121
|
+
const cv = new DataView(central.buffer);
|
|
122
|
+
cv.setUint32(0, 0x02014b50, true);
|
|
123
|
+
cv.setUint16(4, 20, true);
|
|
124
|
+
cv.setUint16(6, 20, true);
|
|
125
|
+
cv.setUint32(16, crc, true);
|
|
126
|
+
cv.setUint32(20, entry.data.byteLength, true);
|
|
127
|
+
cv.setUint32(24, entry.data.byteLength, true);
|
|
128
|
+
cv.setUint16(28, name.length, true);
|
|
129
|
+
cv.setUint32(42, offset, true);
|
|
130
|
+
central.set(name, 46);
|
|
131
|
+
centralParts.push(central);
|
|
132
|
+
offset += local.byteLength + entry.data.byteLength;
|
|
133
|
+
}
|
|
134
|
+
const centralOffset = offset;
|
|
135
|
+
const centralSize = centralParts.reduce((sum, part) => sum + part.byteLength, 0);
|
|
136
|
+
const end = new Uint8Array(22);
|
|
137
|
+
const ev = new DataView(end.buffer);
|
|
138
|
+
ev.setUint32(0, 0x06054b50, true);
|
|
139
|
+
ev.setUint16(8, entries.length, true);
|
|
140
|
+
ev.setUint16(10, entries.length, true);
|
|
141
|
+
ev.setUint32(12, centralSize, true);
|
|
142
|
+
ev.setUint32(16, centralOffset, true);
|
|
143
|
+
const zip = concatUint8([...localParts, ...centralParts, end]);
|
|
144
|
+
return zip.buffer.slice(zip.byteOffset, zip.byteOffset + zip.byteLength);
|
|
145
|
+
}
|
|
146
|
+
function parseStoredZip(archive) {
|
|
147
|
+
const data = new Uint8Array(archive);
|
|
148
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
149
|
+
const entries = [];
|
|
150
|
+
let pos = 0;
|
|
151
|
+
const decoder = new TextDecoder();
|
|
152
|
+
while (pos + 4 <= data.byteLength && view.getUint32(pos, true) === 0x04034b50) {
|
|
153
|
+
const method = view.getUint16(pos + 8, true);
|
|
154
|
+
if (method !== 0) {
|
|
155
|
+
throw new Error("Only stored ZIP entries are supported by pullDirectory");
|
|
156
|
+
}
|
|
157
|
+
const compressedSize = view.getUint32(pos + 18, true);
|
|
158
|
+
const fileNameLength = view.getUint16(pos + 26, true);
|
|
159
|
+
const extraLength = view.getUint16(pos + 28, true);
|
|
160
|
+
const nameStart = pos + 30;
|
|
161
|
+
const contentStart = nameStart + fileNameLength + extraLength;
|
|
162
|
+
const contentEnd = contentStart + compressedSize;
|
|
163
|
+
if (contentEnd > data.byteLength) {
|
|
164
|
+
throw new Error("Invalid ZIP archive");
|
|
165
|
+
}
|
|
166
|
+
const name = decoder.decode(data.slice(nameStart, nameStart + fileNameLength)).replace(/\\/g, "/");
|
|
167
|
+
if (name && !name.endsWith("/") && !name.startsWith("__MACOSX/") && !name.split("/").includes("..")) {
|
|
168
|
+
entries.push({ path: name.replace(/^\/+/, ""), data: data.slice(contentStart, contentEnd) });
|
|
169
|
+
}
|
|
170
|
+
pos = contentEnd;
|
|
171
|
+
}
|
|
172
|
+
return entries;
|
|
173
|
+
}
|
|
174
|
+
function concatUint8(parts) {
|
|
175
|
+
const total = parts.reduce((sum, part) => sum + part.byteLength, 0);
|
|
176
|
+
const out = new Uint8Array(total);
|
|
177
|
+
let offset = 0;
|
|
178
|
+
for (const part of parts) {
|
|
179
|
+
out.set(part, offset);
|
|
180
|
+
offset += part.byteLength;
|
|
181
|
+
}
|
|
182
|
+
return out;
|
|
183
|
+
}
|
|
184
|
+
function crc32(data) {
|
|
185
|
+
let crc = 0xffffffff;
|
|
186
|
+
for (const byte of data) {
|
|
187
|
+
crc ^= byte;
|
|
188
|
+
for (let i = 0; i < 8; i += 1) {
|
|
189
|
+
crc = (crc >>> 1) ^ (0xedb88320 & -(crc & 1));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return (crc ^ 0xffffffff) >>> 0;
|
|
193
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SkillsResource = void 0;
|
|
4
|
+
const query_js_1 = require("../internal/query.js");
|
|
5
|
+
class SkillsResource {
|
|
6
|
+
http;
|
|
7
|
+
constructor(http) {
|
|
8
|
+
this.http = http;
|
|
9
|
+
}
|
|
10
|
+
list(params = {}, options) {
|
|
11
|
+
return this.http.request("GET", `/v1/skills${(0, query_js_1.buildQuery)({
|
|
12
|
+
include_archived: params.include_archived ? "true" : undefined,
|
|
13
|
+
limit: params.limit,
|
|
14
|
+
page_token: params.page_token,
|
|
15
|
+
})}`, undefined, options);
|
|
16
|
+
}
|
|
17
|
+
create(params = {}, options) {
|
|
18
|
+
return this.http.request("POST", "/v1/skills", params, options);
|
|
19
|
+
}
|
|
20
|
+
discover(params = {}, options) {
|
|
21
|
+
return this.http.request("POST", "/v1/skills/discover", params, options);
|
|
22
|
+
}
|
|
23
|
+
focus(params, options) {
|
|
24
|
+
return this.http.request("POST", "/v1/skills/focus", params, options);
|
|
25
|
+
}
|
|
26
|
+
createDev(params, options) {
|
|
27
|
+
return this.http.request("POST", "/v1/skills/create_dev", params, options);
|
|
28
|
+
}
|
|
29
|
+
updateFile(params, options) {
|
|
30
|
+
return this.http.request("POST", "/v1/skills/update_file", params, options);
|
|
31
|
+
}
|
|
32
|
+
retrieve(skillID, options) {
|
|
33
|
+
return this.http.request("GET", `/v1/skills/${encodeURIComponent(skillID)}`, undefined, options);
|
|
34
|
+
}
|
|
35
|
+
update(skillID, params, options) {
|
|
36
|
+
return this.http.request("PATCH", `/v1/skills/${encodeURIComponent(skillID)}`, params, options);
|
|
37
|
+
}
|
|
38
|
+
archive(skillID, options) {
|
|
39
|
+
return this.http.request("POST", `/v1/skills/${encodeURIComponent(skillID)}/archive`, {}, options);
|
|
40
|
+
}
|
|
41
|
+
delete(skillID, options) {
|
|
42
|
+
return this.http.request("DELETE", `/v1/skills/${encodeURIComponent(skillID)}`, undefined, options);
|
|
43
|
+
}
|
|
44
|
+
acceptDev(skillID, params = {}, options) {
|
|
45
|
+
return this.http.request("POST", `/v1/skills/${encodeURIComponent(skillID)}/accept_dev${(0, query_js_1.buildQuery)({ strategy: params.strategy })}`, {}, options);
|
|
46
|
+
}
|
|
47
|
+
discardDev(skillID, options) {
|
|
48
|
+
return this.http.request("POST", `/v1/skills/${encodeURIComponent(skillID)}/discard_dev`, {}, options);
|
|
49
|
+
}
|
|
50
|
+
listFiles(skillID, params = {}, options) {
|
|
51
|
+
return this.http.request("GET", `/v1/skills/${encodeURIComponent(skillID)}/files${(0, query_js_1.buildQuery)({
|
|
52
|
+
path: params.path,
|
|
53
|
+
branch: params.branch,
|
|
54
|
+
fallback_to_main: params.fallback_to_main === false ? "false" : undefined,
|
|
55
|
+
limit: params.limit,
|
|
56
|
+
page_token: params.page_token,
|
|
57
|
+
})}`, undefined, options);
|
|
58
|
+
}
|
|
59
|
+
readFile(skillID, path, params = {}, options) {
|
|
60
|
+
return this.http.request("GET", `/v1/skills/${encodeURIComponent(skillID)}/files/${skillPath(path)}${(0, query_js_1.buildQuery)({
|
|
61
|
+
branch: params.branch,
|
|
62
|
+
fallback_to_main: params.fallback_to_main === false ? "false" : undefined,
|
|
63
|
+
max_bytes: params.max_bytes,
|
|
64
|
+
})}`, undefined, options);
|
|
65
|
+
}
|
|
66
|
+
writeFile(skillID, path, content, params = {}, options) {
|
|
67
|
+
return this.http.requestRaw("PUT", `/v1/skills/${encodeURIComponent(skillID)}/files/${skillPath(path)}${(0, query_js_1.buildQuery)({ branch: params.branch })}`, content, options);
|
|
68
|
+
}
|
|
69
|
+
deleteFile(skillID, path, params = {}, options) {
|
|
70
|
+
return this.http.request("DELETE", `/v1/skills/${encodeURIComponent(skillID)}/files/${skillPath(path)}${(0, query_js_1.buildQuery)({ branch: params.branch })}`, undefined, options);
|
|
71
|
+
}
|
|
72
|
+
exportArchive(skillID, params = {}, options) {
|
|
73
|
+
const archivePath = normalizeArchivePath(params.path);
|
|
74
|
+
return this.http
|
|
75
|
+
.requestBinary("GET", `/v1/skills/${encodeURIComponent(skillID)}/export${(0, query_js_1.buildQuery)({
|
|
76
|
+
path: archivePath || undefined,
|
|
77
|
+
branch: params.branch,
|
|
78
|
+
fallback_to_main: params.fallback_to_main === false ? "false" : undefined,
|
|
79
|
+
})}`, options)
|
|
80
|
+
.then(({ body, headers }) => ({
|
|
81
|
+
path: archivePath,
|
|
82
|
+
content: body,
|
|
83
|
+
content_type: headers.get("Content-Type") ?? undefined,
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
importArchive(skillID, archive, params = {}, options) {
|
|
87
|
+
return this.http.requestRaw("POST", `/v1/skills/${encodeURIComponent(skillID)}/import${(0, query_js_1.buildQuery)({
|
|
88
|
+
path: normalizeArchivePath(params.path) || undefined,
|
|
89
|
+
branch: params.branch,
|
|
90
|
+
replace: params.replace ? "true" : undefined,
|
|
91
|
+
strip_top_level_dir: params.strip_top_level_dir === false ? "false" : undefined,
|
|
92
|
+
})}`, archive, options);
|
|
93
|
+
}
|
|
94
|
+
diff(skillID, params = {}, options) {
|
|
95
|
+
return this.http.request("GET", `/v1/skills/${encodeURIComponent(skillID)}/diff${(0, query_js_1.buildQuery)({
|
|
96
|
+
path: normalizeArchivePath(params.path) || undefined,
|
|
97
|
+
max_file_chars: params.max_file_chars,
|
|
98
|
+
include_unchanged: params.include_unchanged ? "true" : undefined,
|
|
99
|
+
})}`, undefined, options);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.SkillsResource = SkillsResource;
|
|
103
|
+
function skillPath(path) {
|
|
104
|
+
return path
|
|
105
|
+
.split("/")
|
|
106
|
+
.filter(Boolean)
|
|
107
|
+
.map((part) => encodeURIComponent(part))
|
|
108
|
+
.join("/");
|
|
109
|
+
}
|
|
110
|
+
function normalizeArchivePath(path) {
|
|
111
|
+
return (path ?? "").trim().replace(/^\/+|\/+$/g, "");
|
|
112
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToolsResource = void 0;
|
|
4
|
+
class ToolsResource {
|
|
5
|
+
http;
|
|
6
|
+
constructor(http) {
|
|
7
|
+
this.http = http;
|
|
8
|
+
}
|
|
9
|
+
list(options) {
|
|
10
|
+
return this.http.request("GET", "/v1/tools", undefined, options);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.ToolsResource = ToolsResource;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VolumesResource = void 0;
|
|
4
|
+
const query_js_1 = require("../internal/query.js");
|
|
5
|
+
class VolumesResource {
|
|
6
|
+
http;
|
|
7
|
+
constructor(http) {
|
|
8
|
+
this.http = http;
|
|
9
|
+
}
|
|
10
|
+
list(params = {}, options) {
|
|
11
|
+
return this.http.request("GET", `/v1/volumes${(0, query_js_1.buildQuery)({ limit: params.limit, page_token: params.page_token })}`, undefined, options);
|
|
12
|
+
}
|
|
13
|
+
create(params = {}, options) {
|
|
14
|
+
return this.http.request("POST", "/v1/volumes", params, options);
|
|
15
|
+
}
|
|
16
|
+
retrieve(volumeID, options) {
|
|
17
|
+
return this.http.request("GET", `/v1/volumes/${encodeURIComponent(volumeID)}`, undefined, options);
|
|
18
|
+
}
|
|
19
|
+
update(volumeID, params, options) {
|
|
20
|
+
return this.http.request("PATCH", `/v1/volumes/${encodeURIComponent(volumeID)}`, params, options);
|
|
21
|
+
}
|
|
22
|
+
delete(volumeID, options) {
|
|
23
|
+
return this.http.requestVoid("DELETE", `/v1/volumes/${encodeURIComponent(volumeID)}`, options);
|
|
24
|
+
}
|
|
25
|
+
listEntries(volumeID, params = {}, options) {
|
|
26
|
+
return this.http.request("GET", `/v1/volumes/${encodeURIComponent(volumeID)}/entries${(0, query_js_1.buildQuery)({
|
|
27
|
+
path: params.path,
|
|
28
|
+
limit: params.limit,
|
|
29
|
+
page_token: params.page_token,
|
|
30
|
+
})}`, undefined, options);
|
|
31
|
+
}
|
|
32
|
+
searchEntries(volumeID, params, options) {
|
|
33
|
+
return this.http.request("GET", `/v1/volumes/${encodeURIComponent(volumeID)}/search${(0, query_js_1.buildQuery)({
|
|
34
|
+
query: params.query,
|
|
35
|
+
path: params.path,
|
|
36
|
+
limit: params.limit,
|
|
37
|
+
page_token: params.page_token,
|
|
38
|
+
})}`, undefined, options);
|
|
39
|
+
}
|
|
40
|
+
readFile(volumeID, path, params = {}, options) {
|
|
41
|
+
const format = "format" in params ? params.format : undefined;
|
|
42
|
+
const url = `/v1/volumes/${encodeURIComponent(volumeID)}/files/${volumePath(path)}${(0, query_js_1.buildQuery)({
|
|
43
|
+
max_bytes: params.max_bytes,
|
|
44
|
+
format,
|
|
45
|
+
})}`;
|
|
46
|
+
if (format === "raw") {
|
|
47
|
+
return this.http.requestBinary("GET", url, options).then(({ body, headers }) => ({
|
|
48
|
+
path,
|
|
49
|
+
size: Number(headers.get("X-Volume-Size") ?? body.byteLength),
|
|
50
|
+
truncated: headers.get("X-Volume-Truncated") === "true",
|
|
51
|
+
content: body,
|
|
52
|
+
content_type: headers.get("Content-Type") ?? undefined,
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
return this.http.request("GET", url, undefined, options);
|
|
56
|
+
}
|
|
57
|
+
writeFile(volumeID, path, content, options) {
|
|
58
|
+
return this.http.requestRaw("PUT", `/v1/volumes/${encodeURIComponent(volumeID)}/files/${volumePath(path)}`, content, options);
|
|
59
|
+
}
|
|
60
|
+
deletePath(volumeID, path, options) {
|
|
61
|
+
return this.http.request("DELETE", `/v1/volumes/${encodeURIComponent(volumeID)}/paths/${volumePath(path)}`, undefined, options);
|
|
62
|
+
}
|
|
63
|
+
reconcileUsage(volumeID, options) {
|
|
64
|
+
return this.http.request("POST", `/v1/volumes/${encodeURIComponent(volumeID)}/usage/reconcile`, undefined, options);
|
|
65
|
+
}
|
|
66
|
+
createDirectory(volumeID, path, options) {
|
|
67
|
+
return this.http.request("POST", `/v1/volumes/${encodeURIComponent(volumeID)}/directories`, { path }, options);
|
|
68
|
+
}
|
|
69
|
+
downloadArchive(volumeID, params = {}, options) {
|
|
70
|
+
const archivePath = normalizeArchivePath(params.path);
|
|
71
|
+
return this.http
|
|
72
|
+
.requestBinary("GET", `/v1/volumes/${encodeURIComponent(volumeID)}/archive${(0, query_js_1.buildQuery)({ path: archivePath || undefined })}`, options)
|
|
73
|
+
.then(({ body, headers }) => ({
|
|
74
|
+
path: archivePath,
|
|
75
|
+
content: body,
|
|
76
|
+
content_type: headers.get("Content-Type") ?? undefined,
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
summarize(volumeID, params = {}, options) {
|
|
80
|
+
return this.http.request("POST", `/v1/volumes/${encodeURIComponent(volumeID)}/summarize`, params, options);
|
|
81
|
+
}
|
|
82
|
+
readLines(volumeID, path, params, options) {
|
|
83
|
+
return this.http.request("GET", `/v1/volumes/${encodeURIComponent(volumeID)}/file_lines/${volumePath(path)}${(0, query_js_1.buildQuery)({
|
|
84
|
+
start_line: params.start_line,
|
|
85
|
+
end_line: params.end_line,
|
|
86
|
+
max_bytes: params.max_bytes,
|
|
87
|
+
})}`, undefined, options);
|
|
88
|
+
}
|
|
89
|
+
patchLines(volumeID, path, params, options) {
|
|
90
|
+
return this.http.request("PATCH", `/v1/volumes/${encodeURIComponent(volumeID)}/file_lines/${volumePath(path)}`, params, options);
|
|
91
|
+
}
|
|
92
|
+
grep(volumeID, params, options) {
|
|
93
|
+
return this.http.request("GET", `/v1/volumes/${encodeURIComponent(volumeID)}/grep${(0, query_js_1.buildQuery)({
|
|
94
|
+
pattern: params.pattern,
|
|
95
|
+
path: params.path,
|
|
96
|
+
limit: params.limit,
|
|
97
|
+
page_token: params.page_token,
|
|
98
|
+
})}`, undefined, options);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.VolumesResource = VolumesResource;
|
|
102
|
+
function volumePath(path) {
|
|
103
|
+
return path
|
|
104
|
+
.split("/")
|
|
105
|
+
.filter(Boolean)
|
|
106
|
+
.map((part) => encodeURIComponent(part))
|
|
107
|
+
.join("/");
|
|
108
|
+
}
|
|
109
|
+
function normalizeArchivePath(path) {
|
|
110
|
+
if (!path) {
|
|
111
|
+
return "";
|
|
112
|
+
}
|
|
113
|
+
return path.trim().replace(/^\/+/, "").replace(/\/+/g, "/").replace(/\/$/, "");
|
|
114
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseSSE = parseSSE;
|
|
4
|
+
const errors_js_1 = require("./errors.js");
|
|
5
|
+
async function* parseSSE(response) {
|
|
6
|
+
if (!response.body) {
|
|
7
|
+
throw new errors_js_1.APIConnectionError("Streaming response did not include a body");
|
|
8
|
+
}
|
|
9
|
+
const reader = response.body.getReader();
|
|
10
|
+
const decoder = new TextDecoder();
|
|
11
|
+
let buffer = "";
|
|
12
|
+
for (;;) {
|
|
13
|
+
const { value, done } = await reader.read();
|
|
14
|
+
if (done) {
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
buffer += decoder.decode(value, { stream: true });
|
|
18
|
+
const parts = buffer.split(/\r?\n\r?\n/);
|
|
19
|
+
buffer = parts.pop() ?? "";
|
|
20
|
+
for (const part of parts) {
|
|
21
|
+
const event = parseSSEBlock(part);
|
|
22
|
+
if (event !== undefined) {
|
|
23
|
+
yield event;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const finalEvent = parseSSEBlock(buffer);
|
|
28
|
+
if (finalEvent !== undefined) {
|
|
29
|
+
yield finalEvent;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function parseSSEBlock(block) {
|
|
33
|
+
const data = block
|
|
34
|
+
.split(/\r?\n/)
|
|
35
|
+
.filter((line) => line.startsWith("data:"))
|
|
36
|
+
.map((line) => line.slice(5).trimStart())
|
|
37
|
+
.join("\n");
|
|
38
|
+
if (!data || data === "[DONE]") {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
return JSON.parse(data);
|
|
42
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateUniqueToolNames = validateUniqueToolNames;
|
|
4
|
+
function validateUniqueToolNames(tools) {
|
|
5
|
+
if (!tools)
|
|
6
|
+
return;
|
|
7
|
+
const seen = new Set();
|
|
8
|
+
for (const tool of tools) {
|
|
9
|
+
const name = tool.name?.trim();
|
|
10
|
+
if (!name) {
|
|
11
|
+
throw new Error("tools[].name is required");
|
|
12
|
+
}
|
|
13
|
+
if (seen.has(name)) {
|
|
14
|
+
throw new Error(`duplicate tools[].name: ${name}`);
|
|
15
|
+
}
|
|
16
|
+
seen.add(name);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./common.js"), exports);
|
|
18
|
+
__exportStar(require("./input.js"), exports);
|
|
19
|
+
__exportStar(require("./tools.js"), exports);
|
|
20
|
+
__exportStar(require("./responses.js"), exports);
|
|
21
|
+
__exportStar(require("./streaming.js"), exports);
|
|
22
|
+
__exportStar(require("./catalog.js"), exports);
|
|
23
|
+
__exportStar(require("./volumes.js"), exports);
|
|
24
|
+
__exportStar(require("./skills.js"), exports);
|
|
25
|
+
__exportStar(require("./auth.js"), exports);
|