@agent-api/sdk 1.0.4 → 1.0.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 +7 -0
- package/README.md +20 -3
- package/dist/client.d.ts +2 -0
- package/dist/client.js +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/local-skills.d.ts +12 -0
- package/dist/local-skills.js +140 -0
- package/dist/resources/skills.d.ts +33 -0
- package/dist/resources/skills.js +76 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/responses.d.ts +3 -0
- package/dist/types/skills.d.ts +176 -0
- package/dist/types/skills.js +1 -0
- package/dist/version.d.ts +2 -2
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
# Changelog — @agent-api/sdk
|
|
2
2
|
|
|
3
|
+
## 1.0.5
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Main/dev skill branch support and model-facing skill operations for progressive discover, focus, and update workflows.
|
|
8
|
+
|
|
3
9
|
## 1.0.4
|
|
4
10
|
|
|
5
11
|
### Added
|
|
6
12
|
|
|
7
13
|
- `preferred_sites` create-run parameter (up to 3 hostnames) to bias web search and fetch toward specific domains when allowed tools include `web_search` or `web_fetch`.
|
|
14
|
+
- Skill APIs via `client.skills`, create-run `skills` / `local_skills` parameters, and `localSkillFromDirectory()` for SDK-local skill descriptors.
|
|
8
15
|
|
|
9
16
|
## 1.0.3
|
|
10
17
|
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Production JavaScript/TypeScript SDK for the Managed Agent API.
|
|
4
4
|
|
|
5
|
-
**Published on npm:** [`@agent-api/sdk`](https://www.npmjs.com/package/@agent-api/sdk) (v1.0.
|
|
5
|
+
**Published on npm:** [`@agent-api/sdk`](https://www.npmjs.com/package/@agent-api/sdk) (v1.0.5)
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -46,7 +46,7 @@ src/
|
|
|
46
46
|
errors.ts # Typed error hierarchy + retry helpers
|
|
47
47
|
pagination.ts # Cursor pagination utilities
|
|
48
48
|
streaming.ts # SSE parser
|
|
49
|
-
resources/ # responses, models, presets, tools, volumes
|
|
49
|
+
resources/ # responses, models, presets, tools, volumes, skills
|
|
50
50
|
types/ # Request/response TypeScript types
|
|
51
51
|
internal/http.ts # Retries, timeouts, User-Agent
|
|
52
52
|
```
|
|
@@ -60,6 +60,7 @@ src/
|
|
|
60
60
|
| `client.presets` | `list` |
|
|
61
61
|
| `client.tools` | `list` |
|
|
62
62
|
| `client.volumes` | `list`, `create`, `retrieve`, `update`, `delete`, `listEntries`, `searchEntries`, `readFile`, `writeFile`, `deletePath`, `reconcileUsage`, `createDirectory`, `downloadArchive`, `summarize`, `readLines`, `patchLines`, `grep` |
|
|
63
|
+
| `client.skills` | `list`, `create`, `discover`, `focus`, `createDev`, `updateFile`, `retrieve`, `update`, `archive`, `delete`, `acceptDev`, `discardDev`, `listFiles`, `readFile`, `writeFile`, `deleteFile` |
|
|
63
64
|
|
|
64
65
|
## Durable Volumes
|
|
65
66
|
|
|
@@ -77,6 +78,22 @@ const response = await client.agent.create({
|
|
|
77
78
|
});
|
|
78
79
|
```
|
|
79
80
|
|
|
81
|
+
## Skills
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { localSkillFromDirectory } from "@agent-api/sdk";
|
|
85
|
+
|
|
86
|
+
const skill = await client.skills.create({ name: "research-helper" });
|
|
87
|
+
await client.skills.writeFile(skill.skill_id, "SKILL.md", "# Research helper\n");
|
|
88
|
+
|
|
89
|
+
const localSkill = await localSkillFromDirectory("./skills/research-helper");
|
|
90
|
+
const response = await client.responses.create({
|
|
91
|
+
input: "Use the research helper.",
|
|
92
|
+
skills: [{ skill_id: skill.skill_id, branch: "main" }],
|
|
93
|
+
local_skills: [localSkill],
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
80
97
|
## Production features
|
|
81
98
|
|
|
82
99
|
- **Retries:** automatic exponential backoff for network failures, 429, and 5xx (default 2 retries).
|
|
@@ -144,6 +161,6 @@ AGENT_API_INTEGRATION=1 AGENT_API_KEY=sk-... AGENT_API_BASE_URL=https://api.agen
|
|
|
144
161
|
|
|
145
162
|
## Scope
|
|
146
163
|
|
|
147
|
-
The SDK covers the public agent/Responses API, durable volume APIs, and discovery
|
|
164
|
+
The SDK covers the public agent/Responses API, durable volume APIs, skill APIs, and discovery
|
|
148
165
|
endpoints. Console auth, workspace administration, and internal audit records
|
|
149
166
|
are intentionally out of scope.
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ModelsResource } from "./resources/models.js";
|
|
2
2
|
import { PresetsResource } from "./resources/presets.js";
|
|
3
3
|
import { ResponsesResource } from "./resources/responses.js";
|
|
4
|
+
import { SkillsResource } from "./resources/skills.js";
|
|
4
5
|
import { ToolsResource } from "./resources/tools.js";
|
|
5
6
|
import { VolumesResource } from "./resources/volumes.js";
|
|
6
7
|
import type { ClientOptions } from "./types/common.js";
|
|
@@ -21,6 +22,7 @@ export declare class AgentAPI {
|
|
|
21
22
|
readonly presets: PresetsResource;
|
|
22
23
|
readonly tools: ToolsResource;
|
|
23
24
|
readonly volumes: VolumesResource;
|
|
25
|
+
readonly skills: SkillsResource;
|
|
24
26
|
private readonly http;
|
|
25
27
|
constructor(options?: ClientOptions);
|
|
26
28
|
}
|
package/dist/client.js
CHANGED
|
@@ -4,6 +4,7 @@ import { HTTPClient } from "./internal/http.js";
|
|
|
4
4
|
import { ModelsResource } from "./resources/models.js";
|
|
5
5
|
import { PresetsResource } from "./resources/presets.js";
|
|
6
6
|
import { ResponsesResource } from "./resources/responses.js";
|
|
7
|
+
import { SkillsResource } from "./resources/skills.js";
|
|
7
8
|
import { ToolsResource } from "./resources/tools.js";
|
|
8
9
|
import { VolumesResource } from "./resources/volumes.js";
|
|
9
10
|
import { VERSION } from "./version.js";
|
|
@@ -23,6 +24,7 @@ export class AgentAPI {
|
|
|
23
24
|
presets;
|
|
24
25
|
tools;
|
|
25
26
|
volumes;
|
|
27
|
+
skills;
|
|
26
28
|
http;
|
|
27
29
|
constructor(options = {}) {
|
|
28
30
|
this.apiKey = options.apiKey ?? readEnv("AGENT_API_KEY");
|
|
@@ -50,6 +52,7 @@ export class AgentAPI {
|
|
|
50
52
|
this.presets = new PresetsResource(this.http);
|
|
51
53
|
this.tools = new ToolsResource(this.http);
|
|
52
54
|
this.volumes = new VolumesResource(this.http);
|
|
55
|
+
this.skills = new SkillsResource(this.http);
|
|
53
56
|
}
|
|
54
57
|
}
|
|
55
58
|
export { VERSION };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,3 +5,5 @@ export { APIError, APIConnectionError, APIStatusError, AuthenticationError, BadR
|
|
|
5
5
|
export * from "./types/index.js";
|
|
6
6
|
export { functionCallOutputInput, pendingFunctionCalls, runLocalFunctionHandlers, } from "./local-functions.js";
|
|
7
7
|
export type { LocalFunctionHandler, LocalFunctionHandlers } from "./local-functions.js";
|
|
8
|
+
export { localSkillFromDirectory, pendingLocalSkillCalls, runLocalSkillHandlers } from "./local-skills.js";
|
|
9
|
+
export type { LocalSkillDirectoryOptions } from "./local-skills.js";
|
package/dist/index.js
CHANGED
|
@@ -3,3 +3,4 @@ export { Page, collectPage } from "./pagination.js";
|
|
|
3
3
|
export { APIError, APIConnectionError, APIStatusError, AuthenticationError, BadRequestError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, isRetryableStatus, parseResponseError, } from "./errors.js";
|
|
4
4
|
export * from "./types/index.js";
|
|
5
5
|
export { functionCallOutputInput, pendingFunctionCalls, runLocalFunctionHandlers, } from "./local-functions.js";
|
|
6
|
+
export { localSkillFromDirectory, pendingLocalSkillCalls, runLocalSkillHandlers } from "./local-skills.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LocalSkillDescriptor } from "./types/skills.js";
|
|
2
|
+
import type { FunctionCallOutputInput } from "./types/input.js";
|
|
3
|
+
import type { AgentResponse, FunctionCallOutputItem } from "./types/responses.js";
|
|
4
|
+
export interface LocalSkillDirectoryOptions {
|
|
5
|
+
id?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
metadata?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
export declare function localSkillFromDirectory(rootDir: string, options?: LocalSkillDirectoryOptions): Promise<LocalSkillDescriptor>;
|
|
11
|
+
export declare function pendingLocalSkillCalls(response: AgentResponse): FunctionCallOutputItem[];
|
|
12
|
+
export declare function runLocalSkillHandlers(response: AgentResponse, localSkills: LocalSkillDescriptor[]): Promise<FunctionCallOutputInput[]>;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { functionCallOutputInput, pendingFunctionCalls } from "./local-functions.js";
|
|
2
|
+
export async function localSkillFromDirectory(rootDir, options = {}) {
|
|
3
|
+
const fs = await import("node:fs/promises");
|
|
4
|
+
const path = await import("node:path");
|
|
5
|
+
const crypto = await import("node:crypto");
|
|
6
|
+
const root = path.resolve(rootDir);
|
|
7
|
+
const files = await walkFiles(fs, path, root, root);
|
|
8
|
+
const hash = crypto.createHash("sha256");
|
|
9
|
+
for (const rel of files.sort()) {
|
|
10
|
+
hash.update(rel);
|
|
11
|
+
hash.update("\0");
|
|
12
|
+
hash.update(await fs.readFile(path.join(root, rel)));
|
|
13
|
+
hash.update("\0");
|
|
14
|
+
}
|
|
15
|
+
const digest = "sha256:" + hash.digest("hex");
|
|
16
|
+
const base = path.basename(root);
|
|
17
|
+
return {
|
|
18
|
+
local_skill_id: options.id ?? base,
|
|
19
|
+
name: options.name ?? base,
|
|
20
|
+
description: options.description,
|
|
21
|
+
root_hint: root,
|
|
22
|
+
digest,
|
|
23
|
+
metadata: options.metadata,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function pendingLocalSkillCalls(response) {
|
|
27
|
+
return pendingFunctionCalls(response).filter((call) => call.name === "skill_focus");
|
|
28
|
+
}
|
|
29
|
+
export async function runLocalSkillHandlers(response, localSkills) {
|
|
30
|
+
const byID = new Map(localSkills.map((skill) => [skill.local_skill_id, skill]));
|
|
31
|
+
const outputs = [];
|
|
32
|
+
for (const call of pendingLocalSkillCalls(response)) {
|
|
33
|
+
const args = call.arguments ? JSON.parse(call.arguments) : {};
|
|
34
|
+
const payload = await focusLocalSkills(args, byID);
|
|
35
|
+
outputs.push(functionCallOutputInput(call.call_id, payload));
|
|
36
|
+
}
|
|
37
|
+
return outputs;
|
|
38
|
+
}
|
|
39
|
+
async function focusLocalSkills(args, byID) {
|
|
40
|
+
const maxManifestBytes = Number(args.max_manifest_bytes || 16 * 1024);
|
|
41
|
+
const items = Array.isArray(args.skills) ? args.skills : [];
|
|
42
|
+
if (!Array.isArray(args.skills)) {
|
|
43
|
+
return { data: [{ ok: false, error: { code: "invalid_skill_focus", message: "skills must be an array" } }] };
|
|
44
|
+
}
|
|
45
|
+
const data = [];
|
|
46
|
+
for (const raw of items) {
|
|
47
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
48
|
+
data.push({ ok: false, error: { code: "invalid_skill_focus", message: "skill item must be an object" } });
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const item = raw;
|
|
52
|
+
const localSkillID = String(item.local_skill_id || "").trim();
|
|
53
|
+
const result = { ok: false, local_skill_id: localSkillID, branch: "main" };
|
|
54
|
+
const descriptor = byID.get(localSkillID);
|
|
55
|
+
if (!descriptor) {
|
|
56
|
+
result.error = { code: "local_skill_not_found", message: "local_skill_id was not registered with the SDK" };
|
|
57
|
+
data.push(result);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
result.skill = await focusedLocalSkill(descriptor, maxManifestBytes);
|
|
62
|
+
result.ok = true;
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
result.error = { code: "local_skill_focus_failed", message: error instanceof Error ? error.message : String(error) };
|
|
66
|
+
}
|
|
67
|
+
data.push(result);
|
|
68
|
+
}
|
|
69
|
+
return { data };
|
|
70
|
+
}
|
|
71
|
+
async function focusedLocalSkill(descriptor, maxManifestBytes) {
|
|
72
|
+
const fs = await import("node:fs/promises");
|
|
73
|
+
const path = await import("node:path");
|
|
74
|
+
const root = path.resolve(descriptor.root_hint || ".");
|
|
75
|
+
const stat = await fs.stat(root);
|
|
76
|
+
if (!stat.isDirectory()) {
|
|
77
|
+
throw new Error(`local skill root is not a directory: ${root}`);
|
|
78
|
+
}
|
|
79
|
+
let manifest = "";
|
|
80
|
+
let manifestTruncated = false;
|
|
81
|
+
try {
|
|
82
|
+
let manifestBytes = await fs.readFile(path.join(root, "SKILL.md"));
|
|
83
|
+
if (maxManifestBytes > 0 && manifestBytes.length > maxManifestBytes) {
|
|
84
|
+
manifestBytes = manifestBytes.subarray(0, maxManifestBytes);
|
|
85
|
+
manifestTruncated = true;
|
|
86
|
+
}
|
|
87
|
+
manifest = manifestBytes.toString("utf8");
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (error?.code !== "ENOENT") {
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const dirents = await fs.readdir(root, { withFileTypes: true });
|
|
95
|
+
const entries = await Promise.all(dirents
|
|
96
|
+
.filter((entry) => ![".git", "__pycache__", "node_modules"].includes(entry.name))
|
|
97
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
98
|
+
.map(async (entry) => {
|
|
99
|
+
const full = path.join(root, entry.name);
|
|
100
|
+
const entryStat = await fs.stat(full);
|
|
101
|
+
return {
|
|
102
|
+
path: entry.name,
|
|
103
|
+
is_dir: entry.isDirectory(),
|
|
104
|
+
size: entry.isDirectory() ? 0 : entryStat.size,
|
|
105
|
+
modified_at: Math.floor(entryStat.mtimeMs / 1000),
|
|
106
|
+
};
|
|
107
|
+
}));
|
|
108
|
+
return {
|
|
109
|
+
source_type: "SKILL_SOURCE_TYPE_LOCAL",
|
|
110
|
+
local_skill_id: descriptor.local_skill_id,
|
|
111
|
+
name: descriptor.name || "",
|
|
112
|
+
description: descriptor.description || "",
|
|
113
|
+
branch: "SKILL_BRANCH_MAIN",
|
|
114
|
+
digest: descriptor.digest || "",
|
|
115
|
+
artifact_uri: "local://" + root.replace(/^\/+/, ""),
|
|
116
|
+
mount_hint: root,
|
|
117
|
+
manifest,
|
|
118
|
+
manifest_truncated: manifestTruncated,
|
|
119
|
+
entries,
|
|
120
|
+
metadata: descriptor.metadata || {},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
async function walkFiles(fs, path, root, dir) {
|
|
124
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
125
|
+
const out = [];
|
|
126
|
+
for (const entry of entries) {
|
|
127
|
+
if (entry.name === ".git" || entry.name === "node_modules") {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
const full = path.join(dir, entry.name);
|
|
131
|
+
if (entry.isDirectory()) {
|
|
132
|
+
out.push(...await walkFiles(fs, path, root, full));
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (entry.isFile()) {
|
|
136
|
+
out.push(path.relative(root, full).split(path.sep).join("/"));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { HTTPClient } from "../internal/http.js";
|
|
2
|
+
import type { RequestOptions } from "../types/common.js";
|
|
3
|
+
import type { CreateSkillParams, CreateSkillDevParams, CreateSkillDevResponse, DiscoverSkillsParams, FocusSkillParams, ListSkillFilesParams, ListSkillFilesResponse, ListSkillsParams, ListSkillsResponse, ListSkillSummariesResponse, Skill, SkillFile, SkillBranch, SkillFocusResponse, UpdateSkillFilePrimitiveParams, UpdateSkillFilePrimitiveResponse, UpdateSkillParams } from "../types/skills.js";
|
|
4
|
+
export declare class SkillsResource {
|
|
5
|
+
private readonly http;
|
|
6
|
+
constructor(http: HTTPClient);
|
|
7
|
+
list(params?: ListSkillsParams, options?: RequestOptions): Promise<ListSkillsResponse>;
|
|
8
|
+
create(params?: CreateSkillParams, options?: RequestOptions): Promise<Skill>;
|
|
9
|
+
discover(params?: DiscoverSkillsParams, options?: RequestOptions): Promise<ListSkillSummariesResponse>;
|
|
10
|
+
focus(params: FocusSkillParams, options?: RequestOptions): Promise<SkillFocusResponse>;
|
|
11
|
+
createDev(params: CreateSkillDevParams, options?: RequestOptions): Promise<CreateSkillDevResponse>;
|
|
12
|
+
updateFile(params: UpdateSkillFilePrimitiveParams, options?: RequestOptions): Promise<UpdateSkillFilePrimitiveResponse>;
|
|
13
|
+
retrieve(skillID: string, options?: RequestOptions): Promise<Skill>;
|
|
14
|
+
update(skillID: string, params: UpdateSkillParams, options?: RequestOptions): Promise<Skill>;
|
|
15
|
+
archive(skillID: string, options?: RequestOptions): Promise<Skill>;
|
|
16
|
+
delete(skillID: string, options?: RequestOptions): Promise<{
|
|
17
|
+
deleted: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
acceptDev(skillID: string, options?: RequestOptions): Promise<Skill>;
|
|
20
|
+
discardDev(skillID: string, options?: RequestOptions): Promise<Skill>;
|
|
21
|
+
listFiles(skillID: string, params?: ListSkillFilesParams, options?: RequestOptions): Promise<ListSkillFilesResponse>;
|
|
22
|
+
readFile(skillID: string, path: string, params?: {
|
|
23
|
+
branch?: SkillBranch;
|
|
24
|
+
fallback_to_main?: boolean;
|
|
25
|
+
max_bytes?: number;
|
|
26
|
+
}, options?: RequestOptions): Promise<SkillFile>;
|
|
27
|
+
writeFile(skillID: string, path: string, content: string | ArrayBuffer | Blob, params?: {
|
|
28
|
+
branch?: SkillBranch;
|
|
29
|
+
}, options?: RequestOptions): Promise<SkillFile>;
|
|
30
|
+
deleteFile(skillID: string, path: string, params?: {
|
|
31
|
+
branch?: SkillBranch;
|
|
32
|
+
}, options?: RequestOptions): Promise<SkillFile>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { buildQuery } from "../internal/query.js";
|
|
2
|
+
export class SkillsResource {
|
|
3
|
+
http;
|
|
4
|
+
constructor(http) {
|
|
5
|
+
this.http = http;
|
|
6
|
+
}
|
|
7
|
+
list(params = {}, options) {
|
|
8
|
+
return this.http.request("GET", `/v1/skills${buildQuery({
|
|
9
|
+
include_archived: params.include_archived ? "true" : undefined,
|
|
10
|
+
limit: params.limit,
|
|
11
|
+
page_token: params.page_token,
|
|
12
|
+
})}`, undefined, options);
|
|
13
|
+
}
|
|
14
|
+
create(params = {}, options) {
|
|
15
|
+
return this.http.request("POST", "/v1/skills", params, options);
|
|
16
|
+
}
|
|
17
|
+
discover(params = {}, options) {
|
|
18
|
+
return this.http.request("POST", "/v1/skills/discover", params, options);
|
|
19
|
+
}
|
|
20
|
+
focus(params, options) {
|
|
21
|
+
return this.http.request("POST", "/v1/skills/focus", params, options);
|
|
22
|
+
}
|
|
23
|
+
createDev(params, options) {
|
|
24
|
+
return this.http.request("POST", "/v1/skills/create_dev", params, options);
|
|
25
|
+
}
|
|
26
|
+
updateFile(params, options) {
|
|
27
|
+
return this.http.request("POST", "/v1/skills/update_file", params, options);
|
|
28
|
+
}
|
|
29
|
+
retrieve(skillID, options) {
|
|
30
|
+
return this.http.request("GET", `/v1/skills/${encodeURIComponent(skillID)}`, undefined, options);
|
|
31
|
+
}
|
|
32
|
+
update(skillID, params, options) {
|
|
33
|
+
return this.http.request("PATCH", `/v1/skills/${encodeURIComponent(skillID)}`, params, options);
|
|
34
|
+
}
|
|
35
|
+
archive(skillID, options) {
|
|
36
|
+
return this.http.request("POST", `/v1/skills/${encodeURIComponent(skillID)}/archive`, {}, options);
|
|
37
|
+
}
|
|
38
|
+
delete(skillID, options) {
|
|
39
|
+
return this.http.request("DELETE", `/v1/skills/${encodeURIComponent(skillID)}`, undefined, options);
|
|
40
|
+
}
|
|
41
|
+
acceptDev(skillID, options) {
|
|
42
|
+
return this.http.request("POST", `/v1/skills/${encodeURIComponent(skillID)}/accept_dev`, {}, options);
|
|
43
|
+
}
|
|
44
|
+
discardDev(skillID, options) {
|
|
45
|
+
return this.http.request("POST", `/v1/skills/${encodeURIComponent(skillID)}/discard_dev`, {}, options);
|
|
46
|
+
}
|
|
47
|
+
listFiles(skillID, params = {}, options) {
|
|
48
|
+
return this.http.request("GET", `/v1/skills/${encodeURIComponent(skillID)}/files${buildQuery({
|
|
49
|
+
path: params.path,
|
|
50
|
+
branch: params.branch,
|
|
51
|
+
fallback_to_main: params.fallback_to_main === false ? "false" : undefined,
|
|
52
|
+
limit: params.limit,
|
|
53
|
+
page_token: params.page_token,
|
|
54
|
+
})}`, undefined, options);
|
|
55
|
+
}
|
|
56
|
+
readFile(skillID, path, params = {}, options) {
|
|
57
|
+
return this.http.request("GET", `/v1/skills/${encodeURIComponent(skillID)}/files/${skillPath(path)}${buildQuery({
|
|
58
|
+
branch: params.branch,
|
|
59
|
+
fallback_to_main: params.fallback_to_main === false ? "false" : undefined,
|
|
60
|
+
max_bytes: params.max_bytes,
|
|
61
|
+
})}`, undefined, options);
|
|
62
|
+
}
|
|
63
|
+
writeFile(skillID, path, content, params = {}, options) {
|
|
64
|
+
return this.http.requestRaw("PUT", `/v1/skills/${encodeURIComponent(skillID)}/files/${skillPath(path)}${buildQuery({ branch: params.branch })}`, content, options);
|
|
65
|
+
}
|
|
66
|
+
deleteFile(skillID, path, params = {}, options) {
|
|
67
|
+
return this.http.request("DELETE", `/v1/skills/${encodeURIComponent(skillID)}/files/${skillPath(path)}${buildQuery({ branch: params.branch })}`, undefined, options);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function skillPath(path) {
|
|
71
|
+
return path
|
|
72
|
+
.split("/")
|
|
73
|
+
.filter(Boolean)
|
|
74
|
+
.map((part) => encodeURIComponent(part))
|
|
75
|
+
.join("/");
|
|
76
|
+
}
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AgentCapabilityPreference, ErrorInfo, ModelRoutingMode, ModelRoutingStrategy, OutputItemStatus, ResponseStatus, Usage } from "./common.js";
|
|
2
2
|
import type { ContentPart, Input, MemoryOptions, ReasoningConfig, ResponseFormat } from "./input.js";
|
|
3
|
+
import type { LocalSkillDescriptor, SkillReference } from "./skills.js";
|
|
3
4
|
import type { Tool } from "./tools.js";
|
|
4
5
|
export interface ResponseCreateParamsBase {
|
|
5
6
|
input: Input;
|
|
@@ -22,6 +23,8 @@ export interface ResponseCreateParamsBase {
|
|
|
22
23
|
previous_response_id?: string;
|
|
23
24
|
volume_id?: string;
|
|
24
25
|
preferred_sites?: string[];
|
|
26
|
+
skills?: SkillReference[];
|
|
27
|
+
local_skills?: LocalSkillDescriptor[];
|
|
25
28
|
prompt_cache_key?: string;
|
|
26
29
|
memory?: MemoryOptions;
|
|
27
30
|
plan_mode_preference?: AgentCapabilityPreference;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
export type SkillSourceType = "SKILL_SOURCE_TYPE_PLATFORM" | "SKILL_SOURCE_TYPE_LOCAL" | "SKILL_SOURCE_TYPE_GENERATED" | string;
|
|
2
|
+
export type SkillBranch = "main" | "dev" | string;
|
|
3
|
+
export interface SkillReference {
|
|
4
|
+
skill_id: string;
|
|
5
|
+
branch?: SkillBranch;
|
|
6
|
+
}
|
|
7
|
+
export interface LocalSkillDescriptor {
|
|
8
|
+
local_skill_id: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
root_hint?: string;
|
|
12
|
+
digest?: string;
|
|
13
|
+
metadata?: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export interface Skill {
|
|
16
|
+
object: "skill";
|
|
17
|
+
skill_id: string;
|
|
18
|
+
tenant_id?: string;
|
|
19
|
+
name: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
source_type?: SkillSourceType;
|
|
22
|
+
main_digest?: string;
|
|
23
|
+
dev_digest?: string;
|
|
24
|
+
has_dev?: boolean;
|
|
25
|
+
dev_updated_at?: number;
|
|
26
|
+
dev_source_response_id?: string;
|
|
27
|
+
created_by_user_id?: string;
|
|
28
|
+
updated_by_user_id?: string;
|
|
29
|
+
created_at?: number;
|
|
30
|
+
updated_at?: number;
|
|
31
|
+
metadata?: Record<string, unknown>;
|
|
32
|
+
archived?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface SkillSummary {
|
|
35
|
+
object: "skill_summary";
|
|
36
|
+
skill_id: string;
|
|
37
|
+
name?: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
source_type?: SkillSourceType;
|
|
40
|
+
branch?: SkillBranch;
|
|
41
|
+
digest?: string;
|
|
42
|
+
artifact_uri?: string;
|
|
43
|
+
has_dev?: boolean;
|
|
44
|
+
metadata?: Record<string, unknown>;
|
|
45
|
+
}
|
|
46
|
+
export interface FocusedSkill extends Omit<SkillSummary, "object"> {
|
|
47
|
+
object: "focused_skill";
|
|
48
|
+
mount_hint?: string;
|
|
49
|
+
manifest?: string;
|
|
50
|
+
manifest_truncated?: boolean;
|
|
51
|
+
entries?: SkillFileEntry[];
|
|
52
|
+
}
|
|
53
|
+
export interface SkillFocusItem {
|
|
54
|
+
skill_id?: string;
|
|
55
|
+
branch?: SkillBranch;
|
|
56
|
+
local_skill?: LocalSkillDescriptor;
|
|
57
|
+
}
|
|
58
|
+
export interface SkillOperationError {
|
|
59
|
+
code?: string;
|
|
60
|
+
message?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface SkillFocusResultItem {
|
|
63
|
+
ok: boolean;
|
|
64
|
+
skill_id?: string;
|
|
65
|
+
local_skill_id?: string;
|
|
66
|
+
branch?: SkillBranch;
|
|
67
|
+
skill?: FocusedSkill;
|
|
68
|
+
error?: SkillOperationError;
|
|
69
|
+
}
|
|
70
|
+
export interface SkillFocusResponse {
|
|
71
|
+
object: "skill_focus_result";
|
|
72
|
+
data: SkillFocusResultItem[];
|
|
73
|
+
}
|
|
74
|
+
export interface SkillFileEntry {
|
|
75
|
+
path: string;
|
|
76
|
+
is_dir: boolean;
|
|
77
|
+
size: number;
|
|
78
|
+
modified_at?: number;
|
|
79
|
+
}
|
|
80
|
+
export interface ListSkillsParams {
|
|
81
|
+
include_archived?: boolean;
|
|
82
|
+
limit?: number;
|
|
83
|
+
page_token?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface ListSkillsResponse {
|
|
86
|
+
object: "list";
|
|
87
|
+
data: Skill[];
|
|
88
|
+
next_page_token?: string;
|
|
89
|
+
}
|
|
90
|
+
export interface ListSkillSummariesResponse {
|
|
91
|
+
object: "list";
|
|
92
|
+
data: SkillSummary[];
|
|
93
|
+
next_page_token?: string;
|
|
94
|
+
}
|
|
95
|
+
export interface DiscoverSkillsParams {
|
|
96
|
+
query?: string;
|
|
97
|
+
branch?: SkillBranch | "both";
|
|
98
|
+
include_dev?: boolean;
|
|
99
|
+
limit?: number;
|
|
100
|
+
local_skills?: LocalSkillDescriptor[];
|
|
101
|
+
}
|
|
102
|
+
export interface FocusSkillParams {
|
|
103
|
+
skills: SkillFocusItem[];
|
|
104
|
+
fallback_to_main?: boolean;
|
|
105
|
+
max_manifest_bytes?: number;
|
|
106
|
+
}
|
|
107
|
+
export interface SkillFileMutation {
|
|
108
|
+
path: string;
|
|
109
|
+
content?: string;
|
|
110
|
+
content_base64?: string;
|
|
111
|
+
}
|
|
112
|
+
export interface CreateSkillDevParams {
|
|
113
|
+
name: string;
|
|
114
|
+
description?: string;
|
|
115
|
+
metadata?: Record<string, unknown>;
|
|
116
|
+
files?: SkillFileMutation[];
|
|
117
|
+
}
|
|
118
|
+
export interface CreateSkillDevResponse {
|
|
119
|
+
object: "skill_create_result";
|
|
120
|
+
skill: Skill;
|
|
121
|
+
branch: SkillBranch;
|
|
122
|
+
files: Array<{
|
|
123
|
+
path: string;
|
|
124
|
+
size: number;
|
|
125
|
+
}>;
|
|
126
|
+
focused_skill?: FocusedSkill;
|
|
127
|
+
}
|
|
128
|
+
export interface SkillFileUpdateMutation extends SkillFileMutation {
|
|
129
|
+
skill_id: string;
|
|
130
|
+
}
|
|
131
|
+
export interface UpdateSkillFilePrimitiveParams {
|
|
132
|
+
updates: SkillFileUpdateMutation[];
|
|
133
|
+
}
|
|
134
|
+
export interface SkillUpdateResultItem {
|
|
135
|
+
ok: boolean;
|
|
136
|
+
skill_id?: string;
|
|
137
|
+
path?: string;
|
|
138
|
+
size?: number;
|
|
139
|
+
skill?: SkillSummary;
|
|
140
|
+
error?: SkillOperationError;
|
|
141
|
+
}
|
|
142
|
+
export interface UpdateSkillFilePrimitiveResponse {
|
|
143
|
+
object: "skill_update_result";
|
|
144
|
+
data: SkillUpdateResultItem[];
|
|
145
|
+
}
|
|
146
|
+
export interface ListSkillFilesParams {
|
|
147
|
+
path?: string;
|
|
148
|
+
branch?: SkillBranch;
|
|
149
|
+
fallback_to_main?: boolean;
|
|
150
|
+
limit?: number;
|
|
151
|
+
page_token?: string;
|
|
152
|
+
}
|
|
153
|
+
export interface ListSkillFilesResponse {
|
|
154
|
+
object: "list";
|
|
155
|
+
entries: SkillFileEntry[];
|
|
156
|
+
next_page_token?: string;
|
|
157
|
+
}
|
|
158
|
+
export interface SkillFile {
|
|
159
|
+
object: "skill_file";
|
|
160
|
+
path?: string;
|
|
161
|
+
branch?: SkillBranch;
|
|
162
|
+
content?: string;
|
|
163
|
+
size: number;
|
|
164
|
+
truncated?: boolean;
|
|
165
|
+
recursive?: boolean;
|
|
166
|
+
}
|
|
167
|
+
export interface CreateSkillParams {
|
|
168
|
+
name?: string;
|
|
169
|
+
description?: string;
|
|
170
|
+
metadata?: Record<string, unknown>;
|
|
171
|
+
}
|
|
172
|
+
export interface UpdateSkillParams {
|
|
173
|
+
name?: string;
|
|
174
|
+
description?: string;
|
|
175
|
+
metadata?: Record<string, unknown>;
|
|
176
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.0.
|
|
2
|
-
export declare const USER_AGENT = "@agent-api/sdk/1.0.
|
|
1
|
+
export declare const VERSION = "1.0.5";
|
|
2
|
+
export declare const USER_AGENT = "@agent-api/sdk/1.0.5";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = "1.0.
|
|
1
|
+
export const VERSION = "1.0.5";
|
|
2
2
|
export const USER_AGENT = `@agent-api/sdk/${VERSION}`;
|