@aexhq/sdk 0.33.1 → 0.34.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.
Files changed (76) hide show
  1. package/README.md +19 -27
  2. package/dist/_contracts/operations.d.ts +2 -54
  3. package/dist/_contracts/operations.js +2 -87
  4. package/dist/_contracts/run-config.d.ts +19 -13
  5. package/dist/_contracts/run-config.js +6 -33
  6. package/dist/_contracts/run-unit.d.ts +1 -33
  7. package/dist/_contracts/run-unit.js +2 -21
  8. package/dist/_contracts/runtime-sizes.d.ts +2 -2
  9. package/dist/_contracts/runtime-sizes.js +2 -2
  10. package/dist/_contracts/status.d.ts +2 -2
  11. package/dist/_contracts/status.js +3 -0
  12. package/dist/_contracts/submission.d.ts +22 -18
  13. package/dist/_contracts/submission.js +60 -42
  14. package/dist/agents-md.d.ts +5 -5
  15. package/dist/agents-md.js +7 -7
  16. package/dist/agents-md.js.map +1 -1
  17. package/dist/asset-upload.d.ts +4 -4
  18. package/dist/asset-upload.js +4 -4
  19. package/dist/bundle.d.ts +2 -2
  20. package/dist/bundle.js +2 -2
  21. package/dist/cli.mjs +354 -12982
  22. package/dist/cli.mjs.sha256 +1 -1
  23. package/dist/client.d.ts +218 -386
  24. package/dist/client.js +347 -645
  25. package/dist/client.js.map +1 -1
  26. package/dist/data-tools.d.ts +25 -22
  27. package/dist/data-tools.js +75 -62
  28. package/dist/data-tools.js.map +1 -1
  29. package/dist/fetch-archive.js +16 -16
  30. package/dist/fetch-archive.js.map +1 -1
  31. package/dist/file.d.ts +5 -5
  32. package/dist/file.js +7 -7
  33. package/dist/file.js.map +1 -1
  34. package/dist/index.d.ts +9 -9
  35. package/dist/index.js +14 -13
  36. package/dist/index.js.map +1 -1
  37. package/dist/mcp-server.d.ts +4 -4
  38. package/dist/mcp-server.js +4 -4
  39. package/dist/proxy-endpoint.d.ts +4 -4
  40. package/dist/proxy-endpoint.js +1 -1
  41. package/dist/secret.d.ts +8 -8
  42. package/dist/secret.js +8 -8
  43. package/dist/secret.js.map +1 -1
  44. package/dist/skill-tool.d.ts +102 -0
  45. package/dist/skill-tool.js +190 -0
  46. package/dist/skill-tool.js.map +1 -0
  47. package/dist/tool.d.ts +1 -1
  48. package/dist/tool.js +3 -3
  49. package/dist/tool.js.map +1 -1
  50. package/dist/version.d.ts +1 -1
  51. package/dist/version.js +1 -1
  52. package/docs/cleanup.md +3 -3
  53. package/docs/concepts/agent-tools.md +6 -25
  54. package/docs/concepts/composition.md +15 -12
  55. package/docs/concepts/providers-and-runtimes.md +3 -3
  56. package/docs/concepts/runs.md +27 -22
  57. package/docs/credentials.md +52 -84
  58. package/docs/defaults.md +6 -6
  59. package/docs/events.md +65 -44
  60. package/docs/limits-and-quotas.md +3 -4
  61. package/docs/mcp.md +3 -3
  62. package/docs/networking.md +8 -8
  63. package/docs/outputs.md +44 -40
  64. package/docs/provider-runtime-capabilities.md +1 -1
  65. package/docs/public-surface.json +2 -2
  66. package/docs/quickstart.md +20 -10
  67. package/docs/run-config.md +12 -14
  68. package/docs/run-record.md +8 -8
  69. package/docs/secrets.md +16 -26
  70. package/docs/skills.md +55 -110
  71. package/docs/vision-skills.md +29 -40
  72. package/examples/chat-corpus.ts +8 -9
  73. package/package.json +1 -1
  74. package/dist/skill.d.ts +0 -149
  75. package/dist/skill.js +0 -198
  76. package/dist/skill.js.map +0 -1
package/dist/skill.js DELETED
@@ -1,198 +0,0 @@
1
- import { SKILL_NAME_PATTERN } from "./_contracts/index.js";
2
- import { bundleSkillFiles, hashSkillBundle } from "./bundle.js";
3
- import { fetchSkillArchive } from "./fetch-archive.js";
4
- import { readDirectoryAsFiles } from "./node-fs.js";
5
- /**
6
- * One `Skill` class for skill bytes. `client.submit` materializes the bytes
7
- * as an uploaded asset before the run lands; the wire ref becomes
8
- * `kind:"asset"`.
9
- *
10
- * Build from an inline files map (`Skill.fromFiles`), a local directory
11
- * (`Skill.fromPath`), or a remote zip archive over a signed URL
12
- * (`Skill.fromUrl`). All three converge on the same canonical bundle, so
13
- * identical content dedups across sources.
14
- *
15
- * Asset deduplication makes the same bytes a no-op upload on subsequent runs.
16
- * There is no `Skill.fromId(...)`. A URL is an ingestion source, not a
17
- * persistent reference.
18
- *
19
- * An inline draft is auto-staged to the content-addressable asset store at
20
- * submit time (the bytes upload before `POST /runs`; the wire ref becomes
21
- * `kind:"asset"`). Call `await skill.upload(client)` to pre-stage the bytes
22
- * explicitly — useful when you want to reuse the resulting `kind:"asset"`
23
- * Skill across multiple runs.
24
- */
25
- export class Skill {
26
- #ref;
27
- #inlineBytes;
28
- /** Asset id cached after the first submit, so reuse skips a re-upload. */
29
- #assetId;
30
- /**
31
- * Internal constructor. Use `Skill.fromFiles` or `Skill.fromPath` to create
32
- * instances.
33
- */
34
- constructor(ref, inlineBytes) {
35
- this.#ref = ref;
36
- this.#inlineBytes = inlineBytes;
37
- }
38
- /**
39
- * The wire-level reference. Returns the SDK-private draft shape for
40
- * un-materialized skills (kind:"draft", with name + contentHash).
41
- * `client.submit` walks these and uploads them before the run
42
- * lands.
43
- */
44
- get ref() {
45
- return this.#ref;
46
- }
47
- /** True for local-bytes Skills that haven't been uploaded yet. */
48
- get isDraft() {
49
- return this.#ref.kind === "draft";
50
- }
51
- /** Internal: the asset id resolved on a prior submit, or undefined. */
52
- get _cachedAssetId() {
53
- return this.#assetId;
54
- }
55
- /** Internal: remember the asset id resolved for this draft's bytes. */
56
- _rememberAsset(assetId) {
57
- this.#assetId = assetId;
58
- }
59
- /**
60
- * Build a draft Skill from an inline files map. The SDK validates
61
- * basic safety (no path traversal, size caps, has `SKILL.md`),
62
- * deterministically zips the bundle, and computes the
63
- * `sha256:<hex>` content hash. `client.submit` materializes
64
- * these before the run lands.
65
- */
66
- static async fromFiles(args) {
67
- if (!args || typeof args !== "object") {
68
- throw new Error("Skill.fromFiles: args is required");
69
- }
70
- if (typeof args.name !== "string" || !SKILL_NAME_PATTERN.test(args.name)) {
71
- throw new Error(`Skill.fromFiles: name must match ${SKILL_NAME_PATTERN.source}`);
72
- }
73
- const bundled = bundleSkillFiles(args.files);
74
- const contentHash = await hashSkillBundle(bundled.zip);
75
- const ref = {
76
- kind: "draft",
77
- name: args.name,
78
- contentHash
79
- };
80
- return new Skill(ref, bundled.zip);
81
- }
82
- /**
83
- * Read a local directory and build a draft Skill. Symlinks and
84
- * non-regular files are skipped. Bun/Node filesystem runtimes only.
85
- */
86
- static async fromPath(rootDir, args) {
87
- const files = await readDirectoryAsFiles(rootDir);
88
- return Skill.fromFiles({ name: args.name, files });
89
- }
90
- /**
91
- * Fetch a zip-archived skill from a URL and build a draft Skill. The archive
92
- * is downloaded in the SDK process, so the URL is caller-controlled — host
93
- * the skill yourself and pass a temporary signed URL (e.g. an S3 presigned
94
- * URL). Its bytes are optionally integrity-checked against `sha256`, unzipped,
95
- * and reduced to the same files map as `Skill.fromFiles` — so a URL-sourced
96
- * skill and the identical local skill produce the same canonical asset and
97
- * dedup against each other.
98
- *
99
- * The archive must contain `SKILL.md` at its root, or inside a single
100
- * top-level folder (which is stripped). The signed URL only needs to be valid
101
- * for this call; `client.submit` snapshots the bytes into the run.
102
- *
103
- * Universal (Bun / Node 18+ / browser): requires a global `fetch`, or pass one.
104
- */
105
- static async fromUrl(url, args) {
106
- if (!args || typeof args !== "object") {
107
- throw new Error("Skill.fromUrl: args is required");
108
- }
109
- if (typeof args.name !== "string" || !SKILL_NAME_PATTERN.test(args.name)) {
110
- throw new Error(`Skill.fromUrl: name must match ${SKILL_NAME_PATTERN.source}`);
111
- }
112
- const files = await fetchSkillArchive(url, {
113
- ...(args.sha256 !== undefined ? { sha256: args.sha256 } : {}),
114
- ...(args.timeoutMs !== undefined ? { timeoutMs: args.timeoutMs } : {}),
115
- ...(args.fetch !== undefined ? { fetch: args.fetch } : {})
116
- });
117
- return Skill.fromFiles({ name: args.name, files });
118
- }
119
- /**
120
- * Reference a skill already uploaded to the workspace catalog
121
- * (`aex skills upload`) in a run.
122
- *
123
- * A catalog skill's bytes are a content-addressed asset, so referencing it
124
- * is just an `{ kind:"asset" }` ref — once a run snapshots the bytes, it is
125
- * the identical normalized flow as an inline or file-sourced skill. Pass the
126
- * `Skill` record returned by `client.skills.list()` / `.get()`:
127
- *
128
- * const [s] = await client.skills.list();
129
- * await client.submit({ ..., skills: [Skill.fromCatalog(s)] });
130
- *
131
- * The record must be `ready` (it has a content hash). Unlike the draft
132
- * builders this performs no upload — the bytes already live in the catalog.
133
- */
134
- static fromCatalog(record) {
135
- if (!record || typeof record !== "object") {
136
- throw new Error("Skill.fromCatalog: a catalog skill record is required");
137
- }
138
- if (typeof record.name !== "string" || !SKILL_NAME_PATTERN.test(record.name)) {
139
- throw new Error(`Skill.fromCatalog: record.name must match ${SKILL_NAME_PATTERN.source}`);
140
- }
141
- const rawHash = typeof record.hash === "string" ? record.hash : "";
142
- const hashHex = rawHash.startsWith("sha256:") ? rawHash.slice("sha256:".length) : rawHash;
143
- if (!/^[0-9a-f]{64}$/.test(hashHex)) {
144
- throw new Error("Skill.fromCatalog: record.hash must be a sha256 digest — only `ready` catalog skills are referenceable");
145
- }
146
- const ref = { kind: "asset", assetId: `asset_${hashHex}`, name: record.name };
147
- return new Skill(ref);
148
- }
149
- /**
150
- * Internal: yield the draft's bytes + metadata so `client.submit` can upload
151
- * the asset. Idempotent (non-consuming): a Skill is reusable across submits —
152
- * the first submit caches the resolved asset id (see `_rememberAsset`) so
153
- * later submits reuse it instead of re-uploading.
154
- *
155
- * Returns undefined for already-materialized Skills.
156
- */
157
- _takeDraftBundle() {
158
- if (this.#ref.kind !== "draft" || !this.#inlineBytes) {
159
- return undefined;
160
- }
161
- return {
162
- name: this.#ref.name,
163
- contentHash: this.#ref.contentHash,
164
- bytes: this.#inlineBytes
165
- };
166
- }
167
- /**
168
- * Pre-upload a draft Skill's bytes to the workspace asset store and return a
169
- * NEW materialized Skill carrying a `kind:"asset"` ref. Blocking: the upload
170
- * completes before this resolves. Submitting the returned Skill sends a plain
171
- * asset ref and the run pulls the bytes from storage.
172
- *
173
- * Consumes this draft (a draft becomes an asset exactly once); call only on a
174
- * draft built via `Skill.fromFiles` / `Skill.fromPath` / `Skill.fromUrl`.
175
- */
176
- async upload(client) {
177
- const bundle = this._takeDraftBundle();
178
- if (!bundle) {
179
- throw new Error("Skill.upload: only draft Skills can be uploaded. A Skill from " +
180
- "Skill.fromCatalog(...) is already materialized.");
181
- }
182
- const uploaded = await client._uploadAsset({
183
- bytes: bundle.bytes,
184
- hash: bundle.contentHash,
185
- contentType: "application/zip"
186
- });
187
- const ref = { kind: "asset", assetId: uploaded.assetId, name: bundle.name };
188
- return new Skill(ref);
189
- }
190
- toJSON() {
191
- if (this.#ref.kind === "draft") {
192
- throw new Error("Skill: draft Skills cannot be JSON-serialised — they only become wire refs when " +
193
- "client.submit uploads the bytes as an asset.");
194
- }
195
- return this.#ref;
196
- }
197
- }
198
- //# sourceMappingURL=skill.js.map
package/dist/skill.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"skill.js","sourceRoot":"","sources":["../src/skill.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAInB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAmB,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,KAAK;IACP,IAAI,CAA2B;IAC/B,YAAY,CAAyB;IAC9C,0EAA0E;IAC1E,QAAQ,CAAqB;IAE7B;;;OAGG;IACH,YAAoB,GAA6B,EAAE,WAAwB;QACzE,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IAED;;;;;OAKG;IACH,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,C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