@sapiom/tools 0.1.3 → 0.3.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.
- package/CHANGELOG.md +20 -0
- package/README.md +2 -1
- package/dist/cjs/agent/index.d.ts +22 -0
- package/dist/cjs/agent/index.d.ts.map +1 -1
- package/dist/cjs/agent/index.js.map +1 -1
- package/dist/cjs/client.d.ts +8 -0
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +41 -0
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/file-storage/errors.d.ts +16 -0
- package/dist/cjs/file-storage/errors.d.ts.map +1 -0
- package/dist/cjs/file-storage/errors.js +36 -0
- package/dist/cjs/file-storage/errors.js.map +1 -0
- package/dist/cjs/file-storage/index.d.ts +116 -0
- package/dist/cjs/file-storage/index.d.ts.map +1 -0
- package/dist/cjs/file-storage/index.js +136 -0
- package/dist/cjs/file-storage/index.js.map +1 -0
- package/dist/cjs/index.d.ts +5 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +6 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/stub/index.d.ts +34 -0
- package/dist/cjs/stub/index.d.ts.map +1 -0
- package/dist/cjs/stub/index.js +333 -0
- package/dist/cjs/stub/index.js.map +1 -0
- package/dist/esm/agent/index.d.ts +22 -0
- package/dist/esm/agent/index.d.ts.map +1 -1
- package/dist/esm/agent/index.js.map +1 -1
- package/dist/esm/client.d.ts +8 -0
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +8 -0
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/file-storage/errors.d.ts +16 -0
- package/dist/esm/file-storage/errors.d.ts.map +1 -0
- package/dist/esm/file-storage/errors.js +31 -0
- package/dist/esm/file-storage/errors.js.map +1 -0
- package/dist/esm/file-storage/index.d.ts +116 -0
- package/dist/esm/file-storage/index.d.ts.map +1 -0
- package/dist/esm/file-storage/index.js +129 -0
- package/dist/esm/file-storage/index.js.map +1 -0
- package/dist/esm/index.d.ts +5 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +4 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/stub/index.d.ts +34 -0
- package/dist/esm/stub/index.d.ts.map +1 -0
- package/dist/esm/stub/index.js +330 -0
- package/dist/esm/stub/index.js.map +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +12 -2
- package/src/file-storage/README.md +61 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `fileStorage` capability — tenant-scoped object storage on presigned GCS URLs.
|
|
3
|
+
*
|
|
4
|
+
* The control plane only: `upload` hands back a presigned URL you PUT the bytes to
|
|
5
|
+
* yourself (so you own streaming / progress / resumable uploads), and
|
|
6
|
+
* `getDownloadUrl` hands back a presigned URL you GET. `list`, `setVisibility`, and
|
|
7
|
+
* `delete` round out the lifecycle.
|
|
8
|
+
*
|
|
9
|
+
* import { fileStorage } from "@sapiom/tools"; // ambient auth
|
|
10
|
+
* const { uploadUrl, requiredHeaders } = await fileStorage.upload({
|
|
11
|
+
* contentType: "image/png",
|
|
12
|
+
* fileName: "photo.png",
|
|
13
|
+
* });
|
|
14
|
+
* await fetch(uploadUrl, { method: "PUT", headers: requiredHeaders, body: bytes });
|
|
15
|
+
*
|
|
16
|
+
* Or via an explicit client: `createClient({ apiKey }).fileStorage.upload(...)`.
|
|
17
|
+
*
|
|
18
|
+
* Wire fields are snake_case; this module maps them to the camelCase SDK surface.
|
|
19
|
+
* Byte counts are int64 — the gateway serializes them as strings (precision-safe),
|
|
20
|
+
* so `expectedFileSize` / `actualFileSize` on returned metadata are `string | null`.
|
|
21
|
+
*/
|
|
22
|
+
import { Transport } from "../_client/index.js";
|
|
23
|
+
import { FileStorageHttpError } from "./errors.js";
|
|
24
|
+
export { FileStorageHttpError };
|
|
25
|
+
export interface UploadInput {
|
|
26
|
+
/** MIME content type of the file (e.g. "image/png", "application/pdf"). */
|
|
27
|
+
contentType: string;
|
|
28
|
+
/** Original file name for display purposes. */
|
|
29
|
+
fileName?: string;
|
|
30
|
+
/**
|
|
31
|
+
* File visibility.
|
|
32
|
+
* - "private" — download requires authentication (default).
|
|
33
|
+
* - "public" — download URL is unauthenticated.
|
|
34
|
+
*/
|
|
35
|
+
visibility?: "private" | "public";
|
|
36
|
+
/** Expected file size in bytes. Used to pre-allocate storage. */
|
|
37
|
+
expectedFileSize?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface UploadResponse {
|
|
40
|
+
/** Unique file identifier. Use this in subsequent calls. */
|
|
41
|
+
fileId: string;
|
|
42
|
+
/** GCS presigned upload URL. PUT the file bytes here directly. Expires at `expiresAt`. */
|
|
43
|
+
uploadUrl: string;
|
|
44
|
+
/** ISO-8601 timestamp when the upload URL expires. */
|
|
45
|
+
expiresAt: string;
|
|
46
|
+
/** Headers that must be sent when PUTting bytes to `uploadUrl` (e.g. Content-Type). */
|
|
47
|
+
requiredHeaders: Record<string, string>;
|
|
48
|
+
}
|
|
49
|
+
export interface DownloadUrlResponse {
|
|
50
|
+
/** Presigned GCS download URL. Expires at `expiresAt`. */
|
|
51
|
+
downloadUrl: string;
|
|
52
|
+
/** ISO-8601 timestamp when the download URL expires. */
|
|
53
|
+
expiresAt: string;
|
|
54
|
+
}
|
|
55
|
+
export interface FileMetadata {
|
|
56
|
+
/** Unique file identifier. */
|
|
57
|
+
fileId: string;
|
|
58
|
+
/** Original file name, if provided at upload time. */
|
|
59
|
+
fileName?: string;
|
|
60
|
+
/** MIME content type. */
|
|
61
|
+
contentType: string;
|
|
62
|
+
/** File visibility ("private" or "public"). */
|
|
63
|
+
visibility: "private" | "public";
|
|
64
|
+
/** Upload lifecycle status (e.g. "pending_upload", "uploaded", "deleted"). */
|
|
65
|
+
status: string;
|
|
66
|
+
/**
|
|
67
|
+
* Expected (client-declared) size in bytes — a string (int64, precision-safe),
|
|
68
|
+
* `null` when not declared.
|
|
69
|
+
*/
|
|
70
|
+
expectedFileSize?: string | null;
|
|
71
|
+
/** Actual size in bytes after upload (string; `null` until the verify sweep records it). */
|
|
72
|
+
actualFileSize?: string | null;
|
|
73
|
+
/** ISO-8601 timestamp when the record was created. */
|
|
74
|
+
createdAt: string;
|
|
75
|
+
/** ISO-8601 timestamp when the bytes were uploaded. */
|
|
76
|
+
uploadedAt?: string;
|
|
77
|
+
/** ISO-8601 timestamp when the file was soft-deleted. */
|
|
78
|
+
deletedAt?: string;
|
|
79
|
+
/** Number of times a download URL was generated for this file. */
|
|
80
|
+
downloadRequestCount: number;
|
|
81
|
+
}
|
|
82
|
+
export interface ListOptions {
|
|
83
|
+
/** Maximum number of files to return. */
|
|
84
|
+
limit?: number;
|
|
85
|
+
/** Number of files to skip (pagination). */
|
|
86
|
+
offset?: number;
|
|
87
|
+
}
|
|
88
|
+
export interface ListResponse {
|
|
89
|
+
/** Files on the current page. */
|
|
90
|
+
files: FileMetadata[];
|
|
91
|
+
/** Page size used. */
|
|
92
|
+
limit: number;
|
|
93
|
+
/** Offset used. */
|
|
94
|
+
offset: number;
|
|
95
|
+
/** Whether more files exist beyond this page. */
|
|
96
|
+
hasMore: boolean;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Initiate an upload. Returns a presigned GCS URL; PUT the bytes to `uploadUrl`
|
|
100
|
+
* with `requiredHeaders` yourself (this capability owns only the control plane).
|
|
101
|
+
*/
|
|
102
|
+
export declare function upload(input: UploadInput, transport?: Transport, baseUrl?: string): Promise<UploadResponse>;
|
|
103
|
+
/** Generate a presigned download URL for a file. */
|
|
104
|
+
export declare function getDownloadUrl(fileId: string, transport?: Transport, baseUrl?: string): Promise<DownloadUrlResponse>;
|
|
105
|
+
/** List files owned by the authenticated tenant. */
|
|
106
|
+
export declare function list(opts?: ListOptions, transport?: Transport, baseUrl?: string): Promise<ListResponse>;
|
|
107
|
+
/** Update a file's visibility. */
|
|
108
|
+
export declare function setVisibility(fileId: string, visibility: "private" | "public", transport?: Transport, baseUrl?: string): Promise<FileMetadata>;
|
|
109
|
+
/**
|
|
110
|
+
* Delete a file. Idempotent on the gateway (deleting an already-deleted file is a
|
|
111
|
+
* no-op success). Exported as `delete`:
|
|
112
|
+
* `import { fileStorage } from "@sapiom/tools"; await fileStorage.delete(id)`.
|
|
113
|
+
*/
|
|
114
|
+
declare function deleteFile(fileId: string, transport?: Transport, baseUrl?: string): Promise<void>;
|
|
115
|
+
export { deleteFile as delete };
|
|
116
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/file-storage/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,SAAS,EAAoB,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAY,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE7D,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAShC,MAAM,WAAW,WAAW;IAC1B,2EAA2E;IAC3E,WAAW,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAClC,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,cAAc;IAC7B,4DAA4D;IAC5D,MAAM,EAAE,MAAM,CAAC;IACf,0FAA0F;IAC1F,SAAS,EAAE,MAAM,CAAC;IAClB,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAC;IAClB,uFAAuF;IACvF,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,mBAAmB;IAClC,0DAA0D;IAC1D,WAAW,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,SAAS,E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,CAAC,CAO9B;AAED,oDAAoD;AACpD,wBAAsB,IAAI,CACxB,IAAI,CAAC,EAAE,WAAW,EAClB,SAAS,GAAE,SAA8B,EACzC,OAAO,SAAmB,GACzB,OAAO,CAAC,YAAY,CAAC,CAmBvB;AAED,kCAAkC;AAClC,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,SAAS,GAAG,QAAQ,EAChC,SAAS,GAAE,SAA8B,EACzC,OAAO,SAAmB,GACzB,OAAO,CAAC,YAAY,CAAC,CAWvB;AAED;;;;GAIG;AACH,iBAAe,UAAU,CACvB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAA8B,EACzC,OAAO,SAAmB,GACzB,OAAO,CAAC,IAAI,CAAC,CAoBf;AAED,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `fileStorage` capability — tenant-scoped object storage on presigned GCS URLs.
|
|
3
|
+
*
|
|
4
|
+
* The control plane only: `upload` hands back a presigned URL you PUT the bytes to
|
|
5
|
+
* yourself (so you own streaming / progress / resumable uploads), and
|
|
6
|
+
* `getDownloadUrl` hands back a presigned URL you GET. `list`, `setVisibility`, and
|
|
7
|
+
* `delete` round out the lifecycle.
|
|
8
|
+
*
|
|
9
|
+
* import { fileStorage } from "@sapiom/tools"; // ambient auth
|
|
10
|
+
* const { uploadUrl, requiredHeaders } = await fileStorage.upload({
|
|
11
|
+
* contentType: "image/png",
|
|
12
|
+
* fileName: "photo.png",
|
|
13
|
+
* });
|
|
14
|
+
* await fetch(uploadUrl, { method: "PUT", headers: requiredHeaders, body: bytes });
|
|
15
|
+
*
|
|
16
|
+
* Or via an explicit client: `createClient({ apiKey }).fileStorage.upload(...)`.
|
|
17
|
+
*
|
|
18
|
+
* Wire fields are snake_case; this module maps them to the camelCase SDK surface.
|
|
19
|
+
* Byte counts are int64 — the gateway serializes them as strings (precision-safe),
|
|
20
|
+
* so `expectedFileSize` / `actualFileSize` on returned metadata are `string | null`.
|
|
21
|
+
*/
|
|
22
|
+
import { defaultTransport } from "../_client/index.js";
|
|
23
|
+
import { ensureOk, FileStorageHttpError } from "./errors.js";
|
|
24
|
+
export { FileStorageHttpError };
|
|
25
|
+
/** Object storage service. Host routing is an internal detail — override via SAPIOM_FILE_STORAGE_URL. */
|
|
26
|
+
const DEFAULT_BASE_URL = process.env.SAPIOM_FILE_STORAGE_URL ||
|
|
27
|
+
"https://file-storage.services.sapiom.ai";
|
|
28
|
+
function mapFileMetadata(raw) {
|
|
29
|
+
return {
|
|
30
|
+
fileId: raw.file_id,
|
|
31
|
+
...(raw.file_name !== undefined && { fileName: raw.file_name }),
|
|
32
|
+
contentType: raw.content_type,
|
|
33
|
+
visibility: raw.visibility,
|
|
34
|
+
status: raw.status,
|
|
35
|
+
...(raw.expected_file_size !== undefined && {
|
|
36
|
+
expectedFileSize: raw.expected_file_size,
|
|
37
|
+
}),
|
|
38
|
+
...(raw.actual_file_size !== undefined && {
|
|
39
|
+
actualFileSize: raw.actual_file_size,
|
|
40
|
+
}),
|
|
41
|
+
createdAt: raw.created_at,
|
|
42
|
+
...(raw.uploaded_at !== undefined && { uploadedAt: raw.uploaded_at }),
|
|
43
|
+
...(raw.deleted_at !== undefined && { deletedAt: raw.deleted_at }),
|
|
44
|
+
downloadRequestCount: raw.download_request_count,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// ----- capability operations -----
|
|
48
|
+
/**
|
|
49
|
+
* Initiate an upload. Returns a presigned GCS URL; PUT the bytes to `uploadUrl`
|
|
50
|
+
* with `requiredHeaders` yourself (this capability owns only the control plane).
|
|
51
|
+
*/
|
|
52
|
+
export async function upload(input, transport = defaultTransport(), baseUrl = DEFAULT_BASE_URL) {
|
|
53
|
+
const body = { content_type: input.contentType };
|
|
54
|
+
if (input.fileName !== undefined)
|
|
55
|
+
body.file_name = input.fileName;
|
|
56
|
+
if (input.visibility !== undefined)
|
|
57
|
+
body.visibility = input.visibility;
|
|
58
|
+
if (input.expectedFileSize !== undefined) {
|
|
59
|
+
body.expected_file_size = input.expectedFileSize;
|
|
60
|
+
}
|
|
61
|
+
const res = await ensureOk(await transport.fetch(`${baseUrl}/upload`, {
|
|
62
|
+
method: "POST",
|
|
63
|
+
headers: { "content-type": "application/json" },
|
|
64
|
+
body: JSON.stringify(body),
|
|
65
|
+
}), "Failed to initiate file upload");
|
|
66
|
+
const raw = (await res.json());
|
|
67
|
+
return {
|
|
68
|
+
fileId: raw.file_id,
|
|
69
|
+
uploadUrl: raw.upload_url,
|
|
70
|
+
expiresAt: raw.expires_at,
|
|
71
|
+
requiredHeaders: raw.required_headers,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** Generate a presigned download URL for a file. */
|
|
75
|
+
export async function getDownloadUrl(fileId, transport = defaultTransport(), baseUrl = DEFAULT_BASE_URL) {
|
|
76
|
+
const res = await ensureOk(await transport.fetch(`${baseUrl}/download/${encodeURIComponent(fileId)}`), `Failed to get download URL for file '${fileId}'`);
|
|
77
|
+
const raw = (await res.json());
|
|
78
|
+
return { downloadUrl: raw.download_url, expiresAt: raw.expires_at };
|
|
79
|
+
}
|
|
80
|
+
/** List files owned by the authenticated tenant. */
|
|
81
|
+
export async function list(opts, transport = defaultTransport(), baseUrl = DEFAULT_BASE_URL) {
|
|
82
|
+
const url = new URL(`${baseUrl}/files`);
|
|
83
|
+
if (opts?.limit !== undefined) {
|
|
84
|
+
url.searchParams.set("limit", String(opts.limit));
|
|
85
|
+
}
|
|
86
|
+
if (opts?.offset !== undefined) {
|
|
87
|
+
url.searchParams.set("offset", String(opts.offset));
|
|
88
|
+
}
|
|
89
|
+
const res = await ensureOk(await transport.fetch(url.toString()), "Failed to list files");
|
|
90
|
+
const raw = (await res.json());
|
|
91
|
+
return {
|
|
92
|
+
files: raw.files.map(mapFileMetadata),
|
|
93
|
+
limit: raw.limit,
|
|
94
|
+
offset: raw.offset,
|
|
95
|
+
hasMore: raw.has_more,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/** Update a file's visibility. */
|
|
99
|
+
export async function setVisibility(fileId, visibility, transport = defaultTransport(), baseUrl = DEFAULT_BASE_URL) {
|
|
100
|
+
const res = await ensureOk(await transport.fetch(`${baseUrl}/${encodeURIComponent(fileId)}`, {
|
|
101
|
+
method: "PATCH",
|
|
102
|
+
headers: { "content-type": "application/json" },
|
|
103
|
+
body: JSON.stringify({ visibility }),
|
|
104
|
+
}), `Failed to set visibility for file '${fileId}'`);
|
|
105
|
+
const raw = (await res.json());
|
|
106
|
+
return mapFileMetadata(raw);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Delete a file. Idempotent on the gateway (deleting an already-deleted file is a
|
|
110
|
+
* no-op success). Exported as `delete`:
|
|
111
|
+
* `import { fileStorage } from "@sapiom/tools"; await fileStorage.delete(id)`.
|
|
112
|
+
*/
|
|
113
|
+
async function deleteFile(fileId, transport = defaultTransport(), baseUrl = DEFAULT_BASE_URL) {
|
|
114
|
+
const res = await transport.fetch(`${baseUrl}/${encodeURIComponent(fileId)}`, { method: "DELETE" });
|
|
115
|
+
if (!res.ok) {
|
|
116
|
+
const text = await res.text().catch(() => "");
|
|
117
|
+
let parsed;
|
|
118
|
+
try {
|
|
119
|
+
parsed = JSON.parse(text);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
parsed = text;
|
|
123
|
+
}
|
|
124
|
+
throw new FileStorageHttpError(`Failed to delete file '${fileId}': ${res.status} ${text}`, res.status, parsed);
|
|
125
|
+
}
|
|
126
|
+
// 204 No Content — nothing to parse.
|
|
127
|
+
}
|
|
128
|
+
export { deleteFile as delete };
|
|
129
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/file-storage/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAA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HANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* `@sapiom/tools` — the typed Sapiom capability client.
|
|
3
3
|
*
|
|
4
4
|
* The same catalog your agents call over MCP, callable from code. Capabilities are
|
|
5
|
-
* namespaces (`sandboxes`, `repositories`, `agent`, … ), importable
|
|
6
|
-
* or a subpath:
|
|
5
|
+
* namespaces (`sandboxes`, `repositories`, `agent`, `fileStorage`, … ), importable
|
|
6
|
+
* from the barrel or a subpath:
|
|
7
7
|
*
|
|
8
8
|
* import { sandboxes } from "@sapiom/tools";
|
|
9
9
|
* import { sandboxes } from "@sapiom/tools/sandboxes";
|
|
@@ -21,4 +21,7 @@ export * as repositories from "./repositories/index.js";
|
|
|
21
21
|
export { Repository } from "./repositories/index.js";
|
|
22
22
|
export * as agent from "./agent/index.js";
|
|
23
23
|
export { CODING_RESULT_SIGNAL } from "./agent/index.js";
|
|
24
|
+
export type { CodingResultPayload } from "./agent/index.js";
|
|
25
|
+
export * as fileStorage from "./file-storage/index.js";
|
|
26
|
+
export { FileStorageHttpError } from "./file-storage/index.js";
|
|
24
27
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAChE,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAIvE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,KAAK,YAAY,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAChE,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAIvE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,KAAK,YAAY,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGxD,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* `@sapiom/tools` — the typed Sapiom capability client.
|
|
3
3
|
*
|
|
4
4
|
* The same catalog your agents call over MCP, callable from code. Capabilities are
|
|
5
|
-
* namespaces (`sandboxes`, `repositories`, `agent`, … ), importable
|
|
6
|
-
* or a subpath:
|
|
5
|
+
* namespaces (`sandboxes`, `repositories`, `agent`, `fileStorage`, … ), importable
|
|
6
|
+
* from the barrel or a subpath:
|
|
7
7
|
*
|
|
8
8
|
* import { sandboxes } from "@sapiom/tools";
|
|
9
9
|
* import { sandboxes } from "@sapiom/tools/sandboxes";
|
|
@@ -19,4 +19,6 @@ export { Repository } from "./repositories/index.js";
|
|
|
19
19
|
export * as agent from "./agent/index.js";
|
|
20
20
|
// Surfaced top-level for the static `pause: { signal }` decl on a workflow step.
|
|
21
21
|
export { CODING_RESULT_SIGNAL } from "./agent/index.js";
|
|
22
|
+
export * as fileStorage from "./file-storage/index.js";
|
|
23
|
+
export { FileStorageHttpError } from "./file-storage/index.js";
|
|
22
24
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAQhE,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,KAAK,YAAY,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,iFAAiF;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAQhE,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,KAAK,YAAY,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,iFAAiF;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAKxD,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Sapiom } from "../client.js";
|
|
2
|
+
/** Per-capability overrides, keyed by capability path (see module docs). */
|
|
3
|
+
export type StubOverrides = Record<string, unknown | ((...args: unknown[]) => unknown)>;
|
|
4
|
+
export interface StubClientOptions {
|
|
5
|
+
overrides?: StubOverrides;
|
|
6
|
+
/**
|
|
7
|
+
* When provided, any dispatch-able capability records `(correlationId →
|
|
8
|
+
* result)` here (via {@link dispatchable}). A local runner uses it to
|
|
9
|
+
* auto-resume a `pauseUntilSignal(handle, …)` with the result the handle's
|
|
10
|
+
* signal would have carried.
|
|
11
|
+
*/
|
|
12
|
+
signals?: Map<string, unknown>;
|
|
13
|
+
/**
|
|
14
|
+
* When provided, every override key that is actually matched by a capability
|
|
15
|
+
* call is added here. A local runner diffs this against the keys the author
|
|
16
|
+
* supplied to warn about stub keys that matched nothing (a typo'd path, or the
|
|
17
|
+
* wrong plural/singular form) — which otherwise fail silently.
|
|
18
|
+
*/
|
|
19
|
+
usedKeys?: Set<string>;
|
|
20
|
+
/**
|
|
21
|
+
* When provided, collects human-readable warnings about stub *values* that are
|
|
22
|
+
* present but malformed for the capability they override (e.g. a
|
|
23
|
+
* `repositories.list` stub that isn't an array of repositories). Catches the
|
|
24
|
+
* silent-wrong-data trap that `usedKeys` can't — a key that matched but carried
|
|
25
|
+
* the wrong shape.
|
|
26
|
+
*/
|
|
27
|
+
warnings?: Set<string>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create a stub `Sapiom` client. Runs every capability against built-in defaults;
|
|
31
|
+
* pass `overrides` to control the results a step branches on.
|
|
32
|
+
*/
|
|
33
|
+
export declare function createStubClient(opts?: StubClientOptions): Sapiom;
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stub/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAU3C,4EAA4E;AAC5E,MAAM,MAAM,aAAa,GAAG,MAAM,CAChC,MAAM,EACN,OAAO,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,CAC5C,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACxB;AA6TD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,iBAAsB,GAAG,MAAM,CAgJrE"}
|