@akai-workflow-builder/cli-sdk 0.1.1 → 0.1.3
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 +19 -0
- package/README.md +27 -0
- package/dist/ctx/write-file.d.ts +5 -3
- package/dist/ctx/write-file.d.ts.map +1 -1
- package/dist/ctx/write-file.js +11 -4
- package/dist/define-cli.d.ts.map +1 -1
- package/dist/define-cli.js +12 -0
- package/dist/errors.d.ts +56 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +50 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/manifest/json-schema.d.ts +4 -0
- package/dist/manifest/json-schema.d.ts.map +1 -1
- package/dist/manifest/json-schema.js +15 -0
- package/dist/manifest/to-schema.d.ts.map +1 -1
- package/dist/manifest/to-schema.js +3 -1
- package/dist/manifest/types.d.ts +20 -1
- package/dist/manifest/types.d.ts.map +1 -1
- package/dist/types.d.ts +23 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@akai-workflow-builder/cli-sdk` are documented here.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
6
|
+
|
|
7
|
+
## [0.1.3]
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `AkaiToolError` — a typed, caller-facing tool failure carrying a stable `kind`
|
|
12
|
+
(`not_found` | `forbidden` | `auth_expired` | `invalid_input` | `conflict` |
|
|
13
|
+
`rate_limited` | `unavailable`), `message`, and optional `meta`. Pins
|
|
14
|
+
`name` to `'AkaiToolError'` so the host runtime can brand-check the
|
|
15
|
+
serialized shape (`{ name, kind, message, meta? }`) with no SDK dependency,
|
|
16
|
+
map `kind` to an HTTP status, and surface the message verbatim.
|
|
17
|
+
- Ergonomic static factories on `AkaiToolError`: `notFound`, `forbidden`,
|
|
18
|
+
`authExpired`, `invalidInput`, `conflict`, `rateLimited`, `unavailable`.
|
|
19
|
+
- Exported the `ToolErrorKind` type from the package entrypoint.
|
package/README.md
CHANGED
|
@@ -346,9 +346,36 @@ Each tool branches on `isJson` and uses the structured logger. The folder includ
|
|
|
346
346
|
| `AkaiSecretError` | A `required: true` secret is missing at invocation time — thrown by `buildCtx` |
|
|
347
347
|
| `AkaiPropertyError`| A `required: true` property is missing at invocation time — thrown by `buildCtx` |
|
|
348
348
|
| `AkaiEgressError` | `ctx.fetch` rejected the target |
|
|
349
|
+
| `AkaiToolError` | A handler threw a typed, caller-facing failure — the host maps `kind` to an HTTP status and surfaces the message verbatim |
|
|
349
350
|
|
|
350
351
|
Every error extends `AkaiError`; the runtime maps each to a structured error envelope.
|
|
351
352
|
|
|
353
|
+
### Typed tool errors
|
|
354
|
+
|
|
355
|
+
Throw `AkaiToolError` from a handler to give an expected failure a stable classification and author-vetted wording. The host runtime brand-checks the thrown value by its serialized shape — `{ name: 'AkaiToolError', kind, message, meta? }` — with no SDK dependency, maps `kind` to an HTTP status, and returns `message` to the caller **verbatim**. Keep messages secret-free.
|
|
356
|
+
|
|
357
|
+
```ts
|
|
358
|
+
import { AkaiToolError } from '@akai-workflow-builder/cli-sdk';
|
|
359
|
+
|
|
360
|
+
const res = await ctx.fetch(`https://api.example.com/tickets/${id}`);
|
|
361
|
+
if (res.status === 404) throw AkaiToolError.notFound(`No ticket ${id}`, { id });
|
|
362
|
+
if (res.status === 429) throw AkaiToolError.rateLimited('Slow down', { retryAfterMs: 1000 });
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
Factories — each sets the matching `kind`:
|
|
366
|
+
|
|
367
|
+
| Factory | `kind` | Host status |
|
|
368
|
+
|---|---|---|
|
|
369
|
+
| `AkaiToolError.notFound(msg, meta?)` | `not_found` | 404 |
|
|
370
|
+
| `AkaiToolError.forbidden(msg, meta?)` | `forbidden` | 403 |
|
|
371
|
+
| `AkaiToolError.authExpired(msg, meta?)` | `auth_expired` | 401 |
|
|
372
|
+
| `AkaiToolError.invalidInput(msg, meta?)` | `invalid_input` | 422 |
|
|
373
|
+
| `AkaiToolError.conflict(msg, meta?)` | `conflict` | 409 |
|
|
374
|
+
| `AkaiToolError.rateLimited(msg, meta?)` | `rate_limited` | 429 (retryable) |
|
|
375
|
+
| `AkaiToolError.unavailable(msg, meta?)` | `unavailable` | 503 (retryable) |
|
|
376
|
+
|
|
377
|
+
Untyped throws are classified generically (a 500 with a derived message).
|
|
378
|
+
|
|
352
379
|
---
|
|
353
380
|
|
|
354
381
|
## Troubleshooting
|
package/dist/ctx/write-file.d.ts
CHANGED
|
@@ -16,9 +16,11 @@ export interface CreateWriteFileOptions {
|
|
|
16
16
|
*/
|
|
17
17
|
export declare function createWriteFile(opts: CreateWriteFileOptions): (name: string, data: Buffer | Uint8Array | string) => Promise<void>;
|
|
18
18
|
/**
|
|
19
|
-
* Stub installed on `ctx.writeFile` when
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* Stub installed on `ctx.writeFile` when no output channel was provisioned —
|
|
20
|
+
* either the tool did not declare `options.producesFiles`, or it did but the
|
|
21
|
+
* host runtime did not supply the output staging dir. Calling it is an
|
|
22
|
+
* integration error — surface both causes clearly rather than writing to a
|
|
23
|
+
* stray path.
|
|
22
24
|
*/
|
|
23
25
|
export declare function unavailableWriteFile(): (name: string, data: unknown) => Promise<void>;
|
|
24
26
|
//# sourceMappingURL=write-file.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-file.d.ts","sourceRoot":"","sources":["../../src/ctx/write-file.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,sBAAsB,GAC3B,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"write-file.d.ts","sourceRoot":"","sources":["../../src/ctx/write-file.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,sBAAsB,GAC3B,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAyBrE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAQrF"}
|
package/dist/ctx/write-file.js
CHANGED
|
@@ -10,6 +10,11 @@ import { AkaiPathError } from '../errors.js';
|
|
|
10
10
|
* Parent directories are created as needed. Pairs with `options.producesFiles`.
|
|
11
11
|
*/
|
|
12
12
|
export function createWriteFile(opts) {
|
|
13
|
+
// Reject empty/whitespace outputDir: `path.resolve('')` falls back to
|
|
14
|
+
// `process.cwd()`, which would silently stage files into the runtime's cwd.
|
|
15
|
+
if (typeof opts.outputDir !== 'string' || opts.outputDir.trim() === '') {
|
|
16
|
+
throw new AkaiPathError('createWriteFile: outputDir must be a non-empty string');
|
|
17
|
+
}
|
|
13
18
|
const root = resolve(opts.outputDir);
|
|
14
19
|
const safePath = createSafePath([root]);
|
|
15
20
|
return async function writeFile(name, data) {
|
|
@@ -31,12 +36,14 @@ export function createWriteFile(opts) {
|
|
|
31
36
|
};
|
|
32
37
|
}
|
|
33
38
|
/**
|
|
34
|
-
* Stub installed on `ctx.writeFile` when
|
|
35
|
-
*
|
|
36
|
-
*
|
|
39
|
+
* Stub installed on `ctx.writeFile` when no output channel was provisioned —
|
|
40
|
+
* either the tool did not declare `options.producesFiles`, or it did but the
|
|
41
|
+
* host runtime did not supply the output staging dir. Calling it is an
|
|
42
|
+
* integration error — surface both causes clearly rather than writing to a
|
|
43
|
+
* stray path.
|
|
37
44
|
*/
|
|
38
45
|
export function unavailableWriteFile() {
|
|
39
46
|
return function writeFile() {
|
|
40
|
-
return Promise.reject(new AkaiPathError('ctx.writeFile is unavailable:
|
|
47
|
+
return Promise.reject(new AkaiPathError('ctx.writeFile is unavailable: no output channel provisioned. Declare options.producesFiles: true on the tool, and ensure the host runtime supplies an outputDir for it.'));
|
|
41
48
|
};
|
|
42
49
|
}
|
package/dist/define-cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-cli.d.ts","sourceRoot":"","sources":["../src/define-cli.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,MAAM,EAAE,OAAO,EAA4B,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"define-cli.d.ts","sourceRoot":"","sources":["../src/define-cli.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,MAAM,EAAE,OAAO,EAA4B,MAAM,YAAY,CAAC;AA2LxF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAmD/C"}
|
package/dist/define-cli.js
CHANGED
|
@@ -89,6 +89,16 @@ const CLISpecShape = z
|
|
|
89
89
|
seen.add(p.key);
|
|
90
90
|
}
|
|
91
91
|
}),
|
|
92
|
+
connectionSlug: z
|
|
93
|
+
.string({ error: 'connectionSlug must be a string if provided' })
|
|
94
|
+
.min(1, { error: 'connectionSlug must not be empty if provided' })
|
|
95
|
+
.regex(CLI_ID_RE, {
|
|
96
|
+
error: (issue) => `invalid connectionSlug ${JSON.stringify(issue.input)}: lowercase letters/digits/hyphens/underscores only, must start with a letter`,
|
|
97
|
+
})
|
|
98
|
+
.optional(),
|
|
99
|
+
vendorScopes: z
|
|
100
|
+
.array(z.string({ error: 'vendorScopes[i] must be a string' }).min(1, { error: 'vendorScopes[i] must not be empty' }), { error: 'vendorScopes must be an array of strings if provided' })
|
|
101
|
+
.optional(),
|
|
92
102
|
tools: z.custom(isPlainObjectMap, {
|
|
93
103
|
error: 'tools must be a plain object map',
|
|
94
104
|
}),
|
|
@@ -243,6 +253,8 @@ export function defineCLI(spec) {
|
|
|
243
253
|
instructions: Object.freeze([...(v.instructions ?? [])]),
|
|
244
254
|
secrets: frozenSecrets,
|
|
245
255
|
properties: frozenProperties,
|
|
256
|
+
...(v.connectionSlug !== undefined ? { connectionSlug: v.connectionSlug } : {}),
|
|
257
|
+
...(v.vendorScopes !== undefined ? { vendorScopes: Object.freeze([...v.vendorScopes]) } : {}),
|
|
246
258
|
tools: Object.freeze(toolsMap),
|
|
247
259
|
};
|
|
248
260
|
// Non-enumerable so it doesn't appear in Object.keys / JSON.stringify / spreads.
|
package/dist/errors.d.ts
CHANGED
|
@@ -25,4 +25,60 @@ export declare class AkaiPropertyError extends AkaiError {
|
|
|
25
25
|
/** `ctx.safePath` rejected a path that resolves outside the allowed roots. */
|
|
26
26
|
export declare class AkaiPathError extends AkaiError {
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Stable, vendor-neutral classification for a caller-facing tool failure.
|
|
30
|
+
*
|
|
31
|
+
* The host runtime maps each `kind` to an HTTP status and surfaces the
|
|
32
|
+
* accompanying `message` to the caller verbatim, so an agent can reason about
|
|
33
|
+
* the failure programmatically (fix the id, ask to be granted access,
|
|
34
|
+
* reconnect, retry) instead of seeing an opaque 500.
|
|
35
|
+
*
|
|
36
|
+
* - `not_found` — host maps to **404**: the entity does not exist or is not
|
|
37
|
+
* visible to this caller. Check the id/URL and that you have access.
|
|
38
|
+
* - `forbidden` — host maps to **403**: the entity exists but the caller lacks
|
|
39
|
+
* permission (not shared, insufficient scope).
|
|
40
|
+
* - `auth_expired` — host maps to **401**: the credential is invalid or expired;
|
|
41
|
+
* reconnect the integration.
|
|
42
|
+
* - `invalid_input` — host maps to **422**: arguments are well-formed but violate
|
|
43
|
+
* a runtime constraint the schema cannot express.
|
|
44
|
+
* - `conflict` — host maps to **409**: the request conflicts with current state
|
|
45
|
+
* (already exists, version mismatch).
|
|
46
|
+
* - `rate_limited` — host maps to **429**: an upstream throttle was hit; retryable.
|
|
47
|
+
* Put a hint in `meta` (e.g. `{ retryAfterMs }`).
|
|
48
|
+
* - `unavailable` — host maps to **503**: upstream is down, timed out, or
|
|
49
|
+
* unreachable; retryable.
|
|
50
|
+
*/
|
|
51
|
+
export type ToolErrorKind = 'not_found' | 'forbidden' | 'auth_expired' | 'invalid_input' | 'conflict' | 'rate_limited' | 'unavailable';
|
|
52
|
+
/**
|
|
53
|
+
* Caller-facing tool failure with a stable, vendor-neutral {@link ToolErrorKind}.
|
|
54
|
+
*
|
|
55
|
+
* Throw this from a tool handler when you want bespoke, author-vetted wording
|
|
56
|
+
* for an expected failure. The host runtime brand-checks the thrown value by its
|
|
57
|
+
* serialized shape — `{ name: 'AkaiToolError', kind, message, meta? }` — so the
|
|
58
|
+
* `name` is pinned to `'AkaiToolError'` in the constructor and survives across
|
|
59
|
+
* package-boundary `instanceof` gaps. On a match the host maps `kind` to an HTTP
|
|
60
|
+
* status and returns `message` to the caller **verbatim**, so the message must be
|
|
61
|
+
* secret-free and safe to expose. Untyped throws are classified generically.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* throw AkaiToolError.notFound(`No ticket ${id}`, { id });
|
|
65
|
+
*/
|
|
66
|
+
export declare class AkaiToolError extends AkaiError {
|
|
67
|
+
readonly kind: ToolErrorKind;
|
|
68
|
+
constructor(kind: ToolErrorKind, message: string, meta?: Record<string, unknown>);
|
|
69
|
+
/** `invalid_input` → host **422**: args violate a runtime constraint the schema can't express. */
|
|
70
|
+
static invalidInput(message: string, meta?: Record<string, unknown>): AkaiToolError;
|
|
71
|
+
/** `not_found` → host **404**: the entity doesn't exist or isn't visible to this caller. */
|
|
72
|
+
static notFound(message: string, meta?: Record<string, unknown>): AkaiToolError;
|
|
73
|
+
/** `forbidden` → host **403**: the entity exists but the caller lacks permission. */
|
|
74
|
+
static forbidden(message: string, meta?: Record<string, unknown>): AkaiToolError;
|
|
75
|
+
/** `auth_expired` → host **401**: the credential is invalid or expired; reconnect. */
|
|
76
|
+
static authExpired(message: string, meta?: Record<string, unknown>): AkaiToolError;
|
|
77
|
+
/** `conflict` → host **409**: the request conflicts with current state. */
|
|
78
|
+
static conflict(message: string, meta?: Record<string, unknown>): AkaiToolError;
|
|
79
|
+
/** `rate_limited` → host **429**: upstream throttle hit; retryable (e.g. `meta.retryAfterMs`). */
|
|
80
|
+
static rateLimited(message: string, meta?: Record<string, unknown>): AkaiToolError;
|
|
81
|
+
/** `unavailable` → host **503**: upstream down/timed-out/unreachable; retryable. */
|
|
82
|
+
static unavailable(message: string, meta?: Record<string, unknown>): AkaiToolError;
|
|
83
|
+
}
|
|
28
84
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAClC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAC5B,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAK5D;AAED,2EAA2E;AAC3E,qBAAa,aAAc,SAAQ,SAAS;CAAG;AAE/C,+EAA+E;AAC/E,qBAAa,cAAe,SAAQ,SAAS;CAAG;AAEhD,8CAA8C;AAC9C,qBAAa,eAAgB,SAAQ,SAAS;CAAG;A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AAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa;IAInF,4FAA4F;IAC5F,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa;IAI/E,qFAAqF;IACrF,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa;IAIhF,sFAAsF;IACtF,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa;IAIlF,2EAA2E;IAC3E,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa;IAI/E,kGAAkG;IAClG,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa;IAIlF,oFAAoF;IACpF,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa;CAGnF"}
|
package/dist/errors.js
CHANGED
|
@@ -29,3 +29,53 @@ export class AkaiPropertyError extends AkaiError {
|
|
|
29
29
|
/** `ctx.safePath` rejected a path that resolves outside the allowed roots. */
|
|
30
30
|
export class AkaiPathError extends AkaiError {
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Caller-facing tool failure with a stable, vendor-neutral {@link ToolErrorKind}.
|
|
34
|
+
*
|
|
35
|
+
* Throw this from a tool handler when you want bespoke, author-vetted wording
|
|
36
|
+
* for an expected failure. The host runtime brand-checks the thrown value by its
|
|
37
|
+
* serialized shape — `{ name: 'AkaiToolError', kind, message, meta? }` — so the
|
|
38
|
+
* `name` is pinned to `'AkaiToolError'` in the constructor and survives across
|
|
39
|
+
* package-boundary `instanceof` gaps. On a match the host maps `kind` to an HTTP
|
|
40
|
+
* status and returns `message` to the caller **verbatim**, so the message must be
|
|
41
|
+
* secret-free and safe to expose. Untyped throws are classified generically.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* throw AkaiToolError.notFound(`No ticket ${id}`, { id });
|
|
45
|
+
*/
|
|
46
|
+
export class AkaiToolError extends AkaiError {
|
|
47
|
+
kind;
|
|
48
|
+
constructor(kind, message, meta) {
|
|
49
|
+
super(message, meta);
|
|
50
|
+
this.name = 'AkaiToolError';
|
|
51
|
+
this.kind = kind;
|
|
52
|
+
}
|
|
53
|
+
/** `invalid_input` → host **422**: args violate a runtime constraint the schema can't express. */
|
|
54
|
+
static invalidInput(message, meta) {
|
|
55
|
+
return new AkaiToolError('invalid_input', message, meta);
|
|
56
|
+
}
|
|
57
|
+
/** `not_found` → host **404**: the entity doesn't exist or isn't visible to this caller. */
|
|
58
|
+
static notFound(message, meta) {
|
|
59
|
+
return new AkaiToolError('not_found', message, meta);
|
|
60
|
+
}
|
|
61
|
+
/** `forbidden` → host **403**: the entity exists but the caller lacks permission. */
|
|
62
|
+
static forbidden(message, meta) {
|
|
63
|
+
return new AkaiToolError('forbidden', message, meta);
|
|
64
|
+
}
|
|
65
|
+
/** `auth_expired` → host **401**: the credential is invalid or expired; reconnect. */
|
|
66
|
+
static authExpired(message, meta) {
|
|
67
|
+
return new AkaiToolError('auth_expired', message, meta);
|
|
68
|
+
}
|
|
69
|
+
/** `conflict` → host **409**: the request conflicts with current state. */
|
|
70
|
+
static conflict(message, meta) {
|
|
71
|
+
return new AkaiToolError('conflict', message, meta);
|
|
72
|
+
}
|
|
73
|
+
/** `rate_limited` → host **429**: upstream throttle hit; retryable (e.g. `meta.retryAfterMs`). */
|
|
74
|
+
static rateLimited(message, meta) {
|
|
75
|
+
return new AkaiToolError('rate_limited', message, meta);
|
|
76
|
+
}
|
|
77
|
+
/** `unavailable` → host **503**: upstream down/timed-out/unreachable; retryable. */
|
|
78
|
+
static unavailable(message, meta) {
|
|
79
|
+
return new AkaiToolError('unavailable', message, meta);
|
|
80
|
+
}
|
|
81
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ export type { BuildCtxParams } from './ctx/build-ctx.js';
|
|
|
8
8
|
export type { AnyToolDef, CLIDef, CLISpec, DynamicEgress, InputOf, NetworkOptions, OutputOf, PropertiesOf, PropertyDecl, SecretDecl, SecretsOf, ToolCtx, ToolDef, ToolLogger, ToolOptions, ToolSpec, } from './types.js';
|
|
9
9
|
export { createSafePath } from './ctx/safe-path.js';
|
|
10
10
|
export type { SafePath } from './ctx/safe-path.js';
|
|
11
|
-
export { AkaiEgressError, AkaiError, AkaiInputError, AkaiPathError, AkaiPropertyError, AkaiSecretError, AkaiSpecError, } from './errors.js';
|
|
11
|
+
export { AkaiEgressError, AkaiError, AkaiInputError, AkaiPathError, AkaiPropertyError, AkaiSecretError, AkaiSpecError, AkaiToolError, } from './errors.js';
|
|
12
|
+
export type { ToolErrorKind } from './errors.js';
|
|
12
13
|
export { ConnectionManifestSchema, ManifestJSONSchema, SCHEMA_VERSION, toSchema, validateManifest, } from './manifest/index.js';
|
|
13
14
|
export type { ConnectionManifest, DynamicEgressManifest, HttpToolManifest, ManifestProperty, ManifestSecret, NativeToolManifest, SchemaVersion, ToolManifest, } from './manifest/index.js';
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,i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EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,YAAY,EACV,UAAU,EACV,MAAM,EACN,OAAO,EACP,aAAa,EACb,OAAO,EACP,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,SAAS,EACT,OAAO,EACP,OAAO,EACP,UAAU,EACV,WAAW,EACX,QAAQ,GACT,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,eAAe,EACf,SAAS,EACT,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACR,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,YAAY,GACb,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,5 +4,5 @@ export { filePath, FILE_INPUT_META_KEY } from './file-input.js';
|
|
|
4
4
|
export { buildScopedSecrets, buildScopedProperties } from './ctx/secrets.js';
|
|
5
5
|
export { buildCtx } from './ctx/build-ctx.js';
|
|
6
6
|
export { createSafePath } from './ctx/safe-path.js';
|
|
7
|
-
export { AkaiEgressError, AkaiError, AkaiInputError, AkaiPathError, AkaiPropertyError, AkaiSecretError, AkaiSpecError, } from './errors.js';
|
|
7
|
+
export { AkaiEgressError, AkaiError, AkaiInputError, AkaiPathError, AkaiPropertyError, AkaiSecretError, AkaiSpecError, AkaiToolError, } from './errors.js';
|
|
8
8
|
export { ConnectionManifestSchema, ManifestJSONSchema, SCHEMA_VERSION, toSchema, validateManifest, } from './manifest/index.js';
|
|
@@ -31,6 +31,8 @@ export declare const ConnectionManifestSchema: z.ZodObject<{
|
|
|
31
31
|
description: z.ZodString;
|
|
32
32
|
required: z.ZodBoolean;
|
|
33
33
|
}, z.core.$strip>>;
|
|
34
|
+
connectionSlug: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
35
|
+
vendorScopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
34
36
|
tools: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
35
37
|
transport: z.ZodLiteral<"http">;
|
|
36
38
|
egress: z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodObject<{
|
|
@@ -40,6 +42,7 @@ export declare const ConnectionManifestSchema: z.ZodObject<{
|
|
|
40
42
|
name: z.ZodNullable<z.ZodString>;
|
|
41
43
|
description: z.ZodNullable<z.ZodString>;
|
|
42
44
|
isReadonly: z.ZodBoolean;
|
|
45
|
+
producesFiles: z.ZodOptional<z.ZodBoolean>;
|
|
43
46
|
secretKeys: z.ZodArray<z.ZodString>;
|
|
44
47
|
propertyKeys: z.ZodArray<z.ZodString>;
|
|
45
48
|
inputSchema: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
@@ -51,6 +54,7 @@ export declare const ConnectionManifestSchema: z.ZodObject<{
|
|
|
51
54
|
name: z.ZodNullable<z.ZodString>;
|
|
52
55
|
description: z.ZodNullable<z.ZodString>;
|
|
53
56
|
isReadonly: z.ZodBoolean;
|
|
57
|
+
producesFiles: z.ZodOptional<z.ZodBoolean>;
|
|
54
58
|
secretKeys: z.ZodArray<z.ZodString>;
|
|
55
59
|
propertyKeys: z.ZodArray<z.ZodString>;
|
|
56
60
|
inputSchema: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-schema.d.ts","sourceRoot":"","sources":["../../src/manifest/json-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"json-schema.d.ts","sourceRoot":"","sources":["../../src/manifest/json-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAoGrD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuBnC,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,EAAE,OAAsD,CAAC;AAExF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,GAAG,kBAAkB,CAE/D"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { SCHEMA_VERSION } from './constants.js';
|
|
3
|
+
// Mirrors defineCLI()'s CLI_ID_RE — a connection slug uses the same shape as a
|
|
4
|
+
// cli id (lowercase letter, then letters/digits/hyphens/underscores).
|
|
5
|
+
const CONNECTION_SLUG_RE = /^[a-z][a-z0-9_-]*$/;
|
|
3
6
|
/**
|
|
4
7
|
* Zod schema mirroring {@link ConnectionManifest}. Source of truth for both
|
|
5
8
|
* runtime validation (via {@link validateManifest}) and the published
|
|
@@ -33,6 +36,10 @@ const ToolManifestBaseShape = {
|
|
|
33
36
|
name: z.string().nullable(),
|
|
34
37
|
description: z.string().nullable(),
|
|
35
38
|
isReadonly: z.boolean(),
|
|
39
|
+
// Optional on the wire (older manifests predate it; "Absent = false"), but
|
|
40
|
+
// must be in the validator so `validateManifest()` round-trips it instead of
|
|
41
|
+
// Zod silently stripping the host's output-channel provisioning signal.
|
|
42
|
+
producesFiles: z.boolean().optional(),
|
|
36
43
|
secretKeys: z.array(z.string()),
|
|
37
44
|
propertyKeys: z.array(z.string()),
|
|
38
45
|
inputSchema: JsonSchemaField,
|
|
@@ -71,6 +78,14 @@ const ConnectionManifestBaseSchema = z.object({
|
|
|
71
78
|
instructions: z.array(z.string()),
|
|
72
79
|
secrets: z.array(ManifestSecretSchema),
|
|
73
80
|
properties: z.array(ManifestPropertySchema),
|
|
81
|
+
// Connection-grouping fields. Optional on the wire so manifests emitted
|
|
82
|
+
// before they existed still validate (same "absent = default" contract as
|
|
83
|
+
// producesFiles). `toSchema()` emits both explicitly: connectionSlug=null and
|
|
84
|
+
// vendorScopes=[] when undeclared. When present, mirror the constraints
|
|
85
|
+
// defineCLI() enforces (slug shape, non-empty scopes) so an untrusted/hand-
|
|
86
|
+
// crafted manifest can't smuggle an empty or malformed grouping value.
|
|
87
|
+
connectionSlug: z.string().regex(CONNECTION_SLUG_RE).nullable().optional(),
|
|
88
|
+
vendorScopes: z.array(z.string().min(1)).optional(),
|
|
74
89
|
tools: z.array(ToolManifestSchema),
|
|
75
90
|
});
|
|
76
91
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-schema.d.ts","sourceRoot":"","sources":["../../src/manifest/to-schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,MAAM,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,KAAK,EACV,kBAAkB,EAInB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,
|
|
1
|
+
{"version":3,"file":"to-schema.d.ts","sourceRoot":"","sources":["../../src/manifest/to-schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,MAAM,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,KAAK,EACV,kBAAkB,EAInB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAiCxD"}
|
|
@@ -40,6 +40,8 @@ export function toSchema(cli) {
|
|
|
40
40
|
description: p.description,
|
|
41
41
|
required: p.required,
|
|
42
42
|
})),
|
|
43
|
+
connectionSlug: cli.connectionSlug ?? null,
|
|
44
|
+
vendorScopes: [...(cli.vendorScopes ?? [])],
|
|
43
45
|
tools,
|
|
44
46
|
};
|
|
45
47
|
}
|
|
@@ -49,7 +51,7 @@ function toToolManifest(id, t) {
|
|
|
49
51
|
name: t.name ?? null,
|
|
50
52
|
description: t.description ?? null,
|
|
51
53
|
isReadonly: t.options.isReadonly,
|
|
52
|
-
producesFiles: t.options.producesFiles
|
|
54
|
+
producesFiles: t.options.producesFiles,
|
|
53
55
|
secretKeys: [...t.options.secretKeys],
|
|
54
56
|
propertyKeys: [...t.options.propertyKeys],
|
|
55
57
|
inputSchema: tryJsonSchema(t.input),
|
package/dist/manifest/types.d.ts
CHANGED
|
@@ -43,7 +43,12 @@ interface BaseToolManifest {
|
|
|
43
43
|
/** Human description, or `null` when omitted. */
|
|
44
44
|
readonly description: string | null;
|
|
45
45
|
readonly isReadonly: boolean;
|
|
46
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* True when the tool emits output files via `ctx.writeFile` (host provisions
|
|
48
|
+
* an output channel). Semantic default is false; `toSchema()` emits it
|
|
49
|
+
* explicitly so it's usually present on the wire, but older / hand-authored
|
|
50
|
+
* manifests may omit it — consumers must treat absent as false.
|
|
51
|
+
*/
|
|
47
52
|
readonly producesFiles?: boolean;
|
|
48
53
|
readonly secretKeys: readonly string[];
|
|
49
54
|
readonly propertyKeys: readonly string[];
|
|
@@ -98,6 +103,20 @@ export interface ConnectionManifest {
|
|
|
98
103
|
readonly instructions: readonly string[];
|
|
99
104
|
readonly secrets: readonly ManifestSecret[];
|
|
100
105
|
readonly properties: readonly ManifestProperty[];
|
|
106
|
+
/**
|
|
107
|
+
* Connection slug grouping CLIs that share one logical connection
|
|
108
|
+
* (e.g. gmail + gsheet → 'google'). `null` ⇒ the cli's `id` is the slug.
|
|
109
|
+
* Optional on the wire — manifests emitted before this field omit it, so
|
|
110
|
+
* consumers must resolve `connectionSlug ?? id`. `toSchema()` emits it
|
|
111
|
+
* explicitly (as `null` when undeclared).
|
|
112
|
+
*/
|
|
113
|
+
readonly connectionSlug?: string | null;
|
|
114
|
+
/**
|
|
115
|
+
* OAuth scope URIs this CLI's tools need. Consumers union these across a
|
|
116
|
+
* connection group to build the authorize request. Optional on the wire;
|
|
117
|
+
* `toSchema()` emits `[]` when undeclared — treat absent as no scope.
|
|
118
|
+
*/
|
|
119
|
+
readonly vendorScopes?: readonly string[];
|
|
101
120
|
readonly tools: readonly ToolManifest[];
|
|
102
121
|
}
|
|
103
122
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/manifest/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,C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,CAAC;IACpC,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;IAC5C,QAAQ,CAAC,UAAU,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACjD;;;;;;OAMG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;CACzC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -62,9 +62,10 @@ export interface ToolOptions<TSecrets extends string = string, TProperties exten
|
|
|
62
62
|
* When true, the handler emits one or more output files via `ctx.writeFile`.
|
|
63
63
|
* Host runtimes read this to provision an output channel (e.g. pre-mint an
|
|
64
64
|
* upload URL) before invoking the tool, then deliver the written files back
|
|
65
|
-
* to the caller's workdir.
|
|
65
|
+
* to the caller's workdir. Always set post-builder — `tool()` normalizes an
|
|
66
|
+
* omitted input to `false`.
|
|
66
67
|
*/
|
|
67
|
-
readonly producesFiles
|
|
68
|
+
readonly producesFiles: boolean;
|
|
68
69
|
}
|
|
69
70
|
/** Structured logger handed to tool handlers. Writes to stderr; stdout is reserved for handler output. */
|
|
70
71
|
export interface ToolLogger {
|
|
@@ -116,8 +117,9 @@ export interface ToolCtx<S extends string = string, P extends string = string> {
|
|
|
116
117
|
* workdir. `name` is a relative path under the invocation's output staging
|
|
117
118
|
* area (no absolute path, no `..` segments). Use for tools that produce
|
|
118
119
|
* files — downloads, exports; declare `options.producesFiles: true` so the
|
|
119
|
-
* host provisions the output channel. Throws
|
|
120
|
-
*
|
|
120
|
+
* host provisions the output channel. Throws when no output channel was
|
|
121
|
+
* provisioned — either the tool did not declare `producesFiles`, or it did
|
|
122
|
+
* but the host runtime did not supply the output staging dir.
|
|
121
123
|
*/
|
|
122
124
|
writeFile: (name: string, data: Buffer | Uint8Array | string) => Promise<void>;
|
|
123
125
|
}
|
|
@@ -164,6 +166,14 @@ export interface CLIDef {
|
|
|
164
166
|
readonly instructions: ReadonlyArray<string>;
|
|
165
167
|
readonly secrets: ReadonlyArray<SecretDecl>;
|
|
166
168
|
readonly properties: ReadonlyArray<PropertyDecl>;
|
|
169
|
+
/**
|
|
170
|
+
* Connection slug this CLI belongs to. CLIs sharing a slug form one logical
|
|
171
|
+
* connection (e.g. gmail + gsheet → 'google'). Absent ⇒ the cli's own `id`
|
|
172
|
+
* is the slug.
|
|
173
|
+
*/
|
|
174
|
+
readonly connectionSlug?: string;
|
|
175
|
+
/** OAuth scope URIs this CLI's tools need; the host unions them across the connection group. */
|
|
176
|
+
readonly vendorScopes?: readonly string[];
|
|
167
177
|
readonly tools: Readonly<Record<string, AnyToolDef>>;
|
|
168
178
|
/** Project this CLI to its Connections-manifest wire shape. Non-enumerable so JSON.stringify ignores it. */
|
|
169
179
|
toSchema(): ConnectionManifest;
|
|
@@ -227,6 +237,15 @@ export interface CLISpec {
|
|
|
227
237
|
secrets?: readonly SecretDecl[];
|
|
228
238
|
/** Non-sensitive tenant properties (base URLs, subdomains, region). Distinct from `secrets[]`. */
|
|
229
239
|
properties?: readonly PropertyDecl[];
|
|
240
|
+
/**
|
|
241
|
+
* Connection slug grouping this CLI with others that share one logical
|
|
242
|
+
* connection + OAuth token (e.g. gmail + gsheet → 'google'). Lowercase
|
|
243
|
+
* slug, same shape as `id`. Omit for single-CLI connections — the slug
|
|
244
|
+
* then defaults to `id`.
|
|
245
|
+
*/
|
|
246
|
+
connectionSlug?: string;
|
|
247
|
+
/** OAuth scope URIs this CLI's tools need. The host unions these across the connection group. */
|
|
248
|
+
vendorScopes?: readonly string[];
|
|
230
249
|
tools: Record<string, AnyToolDef>;
|
|
231
250
|
}
|
|
232
251
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|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AAS,MAAM,EAAE,CAAC;IACjC,OAAO,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IAChC,kGAAkG;IAClG,UAAU,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IACrC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iGAAiG;IACjG,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACnC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akai-workflow-builder/cli-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Authoring SDK for atomic, agent-executable CLIs and tools.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"akai",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"files": [
|
|
29
29
|
"bin",
|
|
30
30
|
"dist",
|
|
31
|
+
"CHANGELOG.md",
|
|
31
32
|
"LICENSE",
|
|
32
33
|
"README.md"
|
|
33
34
|
],
|