@sapiom/tools 0.1.2 → 0.2.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 +16 -0
- package/README.md +2 -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 +4 -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/repositories/index.d.ts +13 -15
- package/dist/cjs/repositories/index.d.ts.map +1 -1
- package/dist/cjs/repositories/index.js +18 -30
- package/dist/cjs/repositories/index.js.map +1 -1
- package/dist/cjs/stub/index.d.ts +19 -0
- package/dist/cjs/stub/index.d.ts.map +1 -0
- package/dist/cjs/stub/index.js +187 -0
- package/dist/cjs/stub/index.js.map +1 -0
- 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 +4 -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/repositories/index.d.ts +13 -15
- package/dist/esm/repositories/index.d.ts.map +1 -1
- package/dist/esm/repositories/index.js +18 -30
- package/dist/esm/repositories/index.js.map +1 -1
- package/dist/esm/stub/index.d.ts +19 -0
- package/dist/esm/stub/index.d.ts.map +1 -0
- package/dist/esm/stub/index.js +184 -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
- package/src/repositories/README.md +2 -2
|
@@ -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,OAAO,EAAa,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,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
|
* 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,6 @@ 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 * as fileStorage from "./file-storage/index.js";
|
|
25
|
+
export { FileStorageHttpError } from "./file-storage/index.js";
|
|
24
26
|
//# 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;AAExD,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;AAExD,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `repositories` capability — in-network git repos: create, get, list, delete, and
|
|
3
|
-
*
|
|
3
|
+
* `repo.pushFromSandbox(sandbox)` to commit + push a sandbox checkout.
|
|
4
4
|
*
|
|
5
5
|
* import { repositories } from "@sapiom/tools";
|
|
6
6
|
* const repo = await repositories.create("my-app");
|
|
7
7
|
* // … an agent or your code writes files in a sandbox checkout of the repo …
|
|
8
8
|
* await repo.pushFromSandbox(box, { message: "build: page" });
|
|
9
|
-
*
|
|
10
|
-
* `pushFromSandbox` is the deterministic counterpart to a fuzzy agent step: it
|
|
11
|
-
* composes the `sandboxes` capability (calls `sandbox.exec`) to commit + push the
|
|
12
|
-
* repo's working tree. It references the `Sandbox` TYPE only — no module cycle.
|
|
13
|
-
*
|
|
14
|
-
* Note: `cloneUrl` is the unauthenticated origin. The gateway authenticates clones
|
|
15
|
-
* via basic-auth (the `auth` block returned by create); inside an agent run the
|
|
16
|
-
* `gitRepository` auto-clone wires that credential into the in-sandbox origin, so
|
|
17
|
-
* `pushFromSandbox` doesn't need it.
|
|
18
9
|
*/
|
|
19
10
|
import { Transport } from "../_client/index.js";
|
|
20
11
|
import type { Sandbox } from "../sandboxes/index.js";
|
|
21
12
|
export interface PushResult {
|
|
22
|
-
/**
|
|
13
|
+
/** True once your work has been pushed to the repo. */
|
|
23
14
|
pushed: boolean;
|
|
15
|
+
/** The pushed commit SHA, when available. */
|
|
24
16
|
sha: string | null;
|
|
17
|
+
/** The branch it was pushed to, when available. */
|
|
18
|
+
branch?: string | null;
|
|
25
19
|
}
|
|
26
20
|
/** A connected in-network repository. */
|
|
27
21
|
export declare class Repository {
|
|
@@ -41,13 +35,17 @@ export declare class Repository {
|
|
|
41
35
|
/** Delete this repository. */
|
|
42
36
|
delete(): Promise<void>;
|
|
43
37
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* `
|
|
38
|
+
* Commit and push this repo's working tree from a sandbox checkout. Commits any
|
|
39
|
+
* pending changes and pushes the current commit, so the agent's work is
|
|
40
|
+
* published whether it left changes uncommitted, already committed them, or
|
|
41
|
+
* both. Returns `{ pushed, sha, branch }`; throws if the push fails.
|
|
42
|
+
*
|
|
43
|
+
* `workingDirectory` defaults to the repo's checkout at `/workspace/<slug>`
|
|
44
|
+
* (where a coding agent run with `gitRepository: repo` clones it).
|
|
48
45
|
*/
|
|
49
46
|
pushFromSandbox(sandbox: Sandbox, opts?: {
|
|
50
47
|
message?: string;
|
|
48
|
+
workingDirectory?: string;
|
|
51
49
|
}): Promise<PushResult>;
|
|
52
50
|
}
|
|
53
51
|
export declare function create(slug: string): Promise<Repository>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/repositories/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/repositories/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,SAAS,EAAoB,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AA0BrD,MAAM,WAAW,UAAU;IACzB,uDAAuD;IACvD,MAAM,EAAE,OAAO,CAAC;IAChB,6CAA6C;IAC7C,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,yCAAyC;AACzC,qBAAa,UAAU;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAEjC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gBAAgB,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `repositories` capability — in-network git repos: create, get, list, delete, and
|
|
3
|
-
*
|
|
3
|
+
* `repo.pushFromSandbox(sandbox)` to commit + push a sandbox checkout.
|
|
4
4
|
*
|
|
5
5
|
* import { repositories } from "@sapiom/tools";
|
|
6
6
|
* const repo = await repositories.create("my-app");
|
|
7
7
|
* // … an agent or your code writes files in a sandbox checkout of the repo …
|
|
8
8
|
* await repo.pushFromSandbox(box, { message: "build: page" });
|
|
9
|
-
*
|
|
10
|
-
* `pushFromSandbox` is the deterministic counterpart to a fuzzy agent step: it
|
|
11
|
-
* composes the `sandboxes` capability (calls `sandbox.exec`) to commit + push the
|
|
12
|
-
* repo's working tree. It references the `Sandbox` TYPE only — no module cycle.
|
|
13
|
-
*
|
|
14
|
-
* Note: `cloneUrl` is the unauthenticated origin. The gateway authenticates clones
|
|
15
|
-
* via basic-auth (the `auth` block returned by create); inside an agent run the
|
|
16
|
-
* `gitRepository` auto-clone wires that credential into the in-sandbox origin, so
|
|
17
|
-
* `pushFromSandbox` doesn't need it.
|
|
18
9
|
*/
|
|
19
10
|
import { defaultTransport } from "../_client/index.js";
|
|
20
11
|
const DEFAULT_BASE_URL = process.env.SAPIOM_GIT_URL || "https://git.services.sapiom.ai";
|
|
21
|
-
/** Canonical in-sandbox checkout path (matches the agent's `gitRepository` auto-clone). */
|
|
22
|
-
const checkoutDir = (slug) => `/workspace/${slug}`;
|
|
23
12
|
/** A connected in-network repository. */
|
|
24
13
|
export class Repository {
|
|
25
14
|
constructor(fields, transport, baseUrl) {
|
|
@@ -61,26 +50,25 @@ export class Repository {
|
|
|
61
50
|
return Repository.delete(this.slug, this.transport, this.baseUrl);
|
|
62
51
|
}
|
|
63
52
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* `
|
|
53
|
+
* Commit and push this repo's working tree from a sandbox checkout. Commits any
|
|
54
|
+
* pending changes and pushes the current commit, so the agent's work is
|
|
55
|
+
* published whether it left changes uncommitted, already committed them, or
|
|
56
|
+
* both. Returns `{ pushed, sha, branch }`; throws if the push fails.
|
|
57
|
+
*
|
|
58
|
+
* `workingDirectory` defaults to the repo's checkout at `/workspace/<slug>`
|
|
59
|
+
* (where a coding agent run with `gitRepository: repo` clones it).
|
|
68
60
|
*/
|
|
69
61
|
async pushFromSandbox(sandbox, opts = {}) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (exitCode !== 0 || !sha) {
|
|
81
|
-
throw new Error(`pushFromSandbox(${this.slug}) failed (exit ${exitCode}): ${out.slice(-300)}`);
|
|
82
|
-
}
|
|
83
|
-
return { pushed: true, sha };
|
|
62
|
+
return this.transport.request(`${this.baseUrl}/v1/git/repositories/${encodeURIComponent(this.slug)}/push-from-sandbox`, {
|
|
63
|
+
method: "POST",
|
|
64
|
+
body: JSON.stringify({
|
|
65
|
+
executionEnvironmentId: sandbox.name,
|
|
66
|
+
...(opts.workingDirectory
|
|
67
|
+
? { workingDirectory: opts.workingDirectory }
|
|
68
|
+
: {}),
|
|
69
|
+
...(opts.message ? { message: opts.message } : {}),
|
|
70
|
+
}),
|
|
71
|
+
});
|
|
84
72
|
}
|
|
85
73
|
}
|
|
86
74
|
// Ambient-bound namespace functions.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/repositories/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/repositories/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAa,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGlE,MAAM,gBAAgB,GACpB,OAAO,CAAC,GAAG,C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CAAC,SAAS,CAAC;gBACnB,sBAAsB,EAAE,OAAO,CAAC,IAAI;gBACpC,GAAG,CAAC,IAAI,CAAC,gBAAgB;oBACvB,CAAC,CAAC,EAAE,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EAAE;oBAC7C,CAAC,CAAC,EAAE,CAAC;gBACP,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACnD,CAAC;SACH,CACF,CAAC;IACJ,CAAC;CACF;AAED,qCAAqC;AACrC,MAAM,UAAU,MAAM,CAAC,IAAY;IACjC,OAAO,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AACD,MAAM,UAAU,GAAG,CAAC,IAAY;IAC9B,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC;AACD,MAAM,UAAU,IAAI;IAClB,OAAO,UAAU,CAAC,IAAI,EAAE,CAAC;AAC3B,CAAC;AACD,MAAM,UAAU,MAAM,CAAC,IAAY,EAAE,QAAgB;IACnD,OAAO,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC3C,CAAC;AACD,SAAS,gBAAgB,CAAC,IAAY;IACpC,OAAO,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AACD,OAAO,EAAE,gBAAgB,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
/**
|
|
15
|
+
* Create a stub `Sapiom` client. Runs every capability against built-in defaults;
|
|
16
|
+
* pass `overrides` to control the results a step branches on.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createStubClient(opts?: StubClientOptions): Sapiom;
|
|
19
|
+
//# 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;AAK3C,4EAA4E;AAC5E,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC;AAExF,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAkID;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,iBAAsB,GAAG,MAAM,CAuFrE"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@sapiom/tools/stub` — a stub capability client for local development.
|
|
3
|
+
*
|
|
4
|
+
* `createStubClient()` returns a `Sapiom` of the same shape as the real client,
|
|
5
|
+
* but every capability is satisfied by a built-in default (so a workflow runs
|
|
6
|
+
* locally with zero setup) plus optional per-capability overrides (when a step's
|
|
7
|
+
* logic branches on a result). No network, no credentials.
|
|
8
|
+
*
|
|
9
|
+
* It is shape-faithful: namespace methods return the real handle types
|
|
10
|
+
* (`Repository`, `Sandbox`, `RunHandle`), and a handle's instance methods
|
|
11
|
+
* (`repo.pushFromSandbox(...)`, `sandbox.exec(...)`) work too — so a step never
|
|
12
|
+
* has to be rewritten to run locally. Method names are validated against the
|
|
13
|
+
* real handle classes, so a call to a method that doesn't exist throws.
|
|
14
|
+
*
|
|
15
|
+
* Overrides are keyed by capability path — namespace methods by their dotted
|
|
16
|
+
* path (`repositories.list`, `agent.coding.run`), handle methods by
|
|
17
|
+
* `<handle>.<method>` (`repository.pushFromSandbox`, `sandbox.exec`). A value
|
|
18
|
+
* replaces that capability's default; a function `(…args) => value` computes it
|
|
19
|
+
* from the call arguments.
|
|
20
|
+
*/
|
|
21
|
+
import { CODING_RESULT_SIGNAL } from '../agent/index.js';
|
|
22
|
+
import { Repository } from '../repositories/index.js';
|
|
23
|
+
import { Sandbox } from '../sandboxes/index.js';
|
|
24
|
+
// Module-scoped so correlation ids are unique across launches within a run.
|
|
25
|
+
let launchSeq = 0;
|
|
26
|
+
/** A launched, pausable capability handle (the `DispatchHandle` shape). */
|
|
27
|
+
function isDispatchHandle(v) {
|
|
28
|
+
if (!v || typeof v !== 'object')
|
|
29
|
+
return false;
|
|
30
|
+
const h = v;
|
|
31
|
+
return typeof h.wait === 'function' && typeof h.dispatch?.correlationId === 'string';
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Register a dispatch-able handle's eventual result so a pause on its signal can
|
|
35
|
+
* be auto-resumed, then return the handle. Capability-agnostic: any launch-style
|
|
36
|
+
* stub method wraps its returned handle in this — the result a `pauseUntilSignal`
|
|
37
|
+
* resumes with is exactly what the handle's `wait()` resolves to.
|
|
38
|
+
*/
|
|
39
|
+
async function dispatchable(handle, signals) {
|
|
40
|
+
if (signals && isDispatchHandle(handle)) {
|
|
41
|
+
signals.set(handle.dispatch.correlationId, await handle.wait());
|
|
42
|
+
}
|
|
43
|
+
return handle;
|
|
44
|
+
}
|
|
45
|
+
// Method names of each handle, reflected from the real classes so the stub stays
|
|
46
|
+
// in lockstep with the SDK (a renamed/added method is picked up automatically).
|
|
47
|
+
const REPOSITORY_METHODS = handleMethods(Repository.prototype);
|
|
48
|
+
const SANDBOX_METHODS = handleMethods(Sandbox.prototype);
|
|
49
|
+
const RUN_HANDLE_METHODS = new Set(['status', 'wait']); // RunHandle is a literal, not a class
|
|
50
|
+
function handleMethods(proto) {
|
|
51
|
+
return new Set(Object.getOwnPropertyNames(proto).filter((n) => n !== 'constructor'));
|
|
52
|
+
}
|
|
53
|
+
function resolve(overrides, path, args, fallback) {
|
|
54
|
+
if (Object.prototype.hasOwnProperty.call(overrides, path)) {
|
|
55
|
+
const o = overrides[path];
|
|
56
|
+
return typeof o === 'function' ? o(...args) : o;
|
|
57
|
+
}
|
|
58
|
+
return fallback();
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Build a handle proxy: data fields read from `data`; declared methods resolve an
|
|
62
|
+
* override (`<type>.<method>`) or a default; any other property is rejected as
|
|
63
|
+
* not part of the handle.
|
|
64
|
+
*/
|
|
65
|
+
function makeHandle(type, methods, data, overrides, defaults) {
|
|
66
|
+
return new Proxy(data, {
|
|
67
|
+
get(target, prop) {
|
|
68
|
+
if (typeof prop === 'symbol' || prop === 'then')
|
|
69
|
+
return undefined;
|
|
70
|
+
const key = String(prop);
|
|
71
|
+
if (key in target)
|
|
72
|
+
return target[key]; // data field (incl. nested handles)
|
|
73
|
+
if (methods.has(key)) {
|
|
74
|
+
return (...args) => Promise.resolve(resolve(overrides, `${type}.${key}`, args, () => defaults[key]?.(args)));
|
|
75
|
+
}
|
|
76
|
+
throw new Error(`'${type}.${key}' is not a method or field on this handle.`);
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const REPO_METHOD_DEFAULTS = {
|
|
81
|
+
delete: () => undefined,
|
|
82
|
+
pushFromSandbox: () => ({ pushed: true, sha: 'stub00000000', branch: 'main' }),
|
|
83
|
+
};
|
|
84
|
+
const SANDBOX_METHOD_DEFAULTS = {
|
|
85
|
+
exec: () => ({ pid: 'stub-proc', exitCode: 0, stdout: '', stderr: '' }),
|
|
86
|
+
readFile: () => '',
|
|
87
|
+
writeFile: () => undefined,
|
|
88
|
+
destroy: () => undefined,
|
|
89
|
+
};
|
|
90
|
+
function stubRepository(data, overrides) {
|
|
91
|
+
return makeHandle('repository', REPOSITORY_METHODS, { slug: data.slug, cloneUrl: data.cloneUrl, status: data.status ?? 'active' }, overrides, REPO_METHOD_DEFAULTS);
|
|
92
|
+
}
|
|
93
|
+
function stubSandbox(data, overrides) {
|
|
94
|
+
return makeHandle('sandbox', SANDBOX_METHODS, { name: data.name, workspaceRoot: data.workspaceRoot ?? '/workspace' }, overrides, SANDBOX_METHOD_DEFAULTS);
|
|
95
|
+
}
|
|
96
|
+
function stubCodingResult(overrides) {
|
|
97
|
+
return {
|
|
98
|
+
runId: 'stub-run',
|
|
99
|
+
status: 'completed',
|
|
100
|
+
summary: '(stub) coding run completed locally',
|
|
101
|
+
result: {
|
|
102
|
+
success: true,
|
|
103
|
+
turns: 1,
|
|
104
|
+
modelUsed: 'stub-model',
|
|
105
|
+
durationMs: 0,
|
|
106
|
+
toolCallCount: 0,
|
|
107
|
+
usage: { inputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheCreateTokens: 0, thinkingTokens: 0 },
|
|
108
|
+
},
|
|
109
|
+
error: null,
|
|
110
|
+
sandbox: stubSandbox({ name: 'stub-sandbox' }, overrides),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function stubRunHandle(overrides, correlationId, result) {
|
|
114
|
+
const handle = {
|
|
115
|
+
runId: correlationId,
|
|
116
|
+
sandbox: result.sandbox,
|
|
117
|
+
dispatch: { correlationId, resultSignal: CODING_RESULT_SIGNAL },
|
|
118
|
+
status: () => Promise.resolve(result.status),
|
|
119
|
+
wait: () => Promise.resolve(result),
|
|
120
|
+
};
|
|
121
|
+
return makeHandle('runHandle', RUN_HANDLE_METHODS, handle, overrides, {});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Create a stub `Sapiom` client. Runs every capability against built-in defaults;
|
|
125
|
+
* pass `overrides` to control the results a step branches on.
|
|
126
|
+
*/
|
|
127
|
+
export function createStubClient(opts = {}) {
|
|
128
|
+
const overrides = opts.overrides ?? {};
|
|
129
|
+
const r = (path, args, fallback) => resolve(overrides, path, args, fallback);
|
|
130
|
+
const client = {
|
|
131
|
+
sandboxes: {
|
|
132
|
+
create: (sandboxOpts) => Promise.resolve(r('sandboxes.create', [sandboxOpts], () => stubSandbox({ name: sandboxOpts?.name ?? 'stub-sandbox' }, overrides))),
|
|
133
|
+
attach: (name, attachOpts) => r('sandboxes.attach', [name, attachOpts], () => stubSandbox({ name }, overrides)),
|
|
134
|
+
},
|
|
135
|
+
repositories: {
|
|
136
|
+
create: (slug) => Promise.resolve(r('repositories.create', [slug], () => stubRepository({ slug, cloneUrl: `https://git.local/${slug}.git` }, overrides))),
|
|
137
|
+
get: (slug) => Promise.resolve(r('repositories.get', [slug], () => stubRepository({ slug, cloneUrl: `https://git.local/${slug}.git` }, overrides))),
|
|
138
|
+
list: () => Promise.resolve(r('repositories.list', [], () => [])),
|
|
139
|
+
delete: (slug) => Promise.resolve(r('repositories.delete', [slug], () => undefined)),
|
|
140
|
+
attach: (slug, cloneUrl) => r('repositories.attach', [slug, cloneUrl], () => stubRepository({ slug, cloneUrl }, overrides)),
|
|
141
|
+
},
|
|
142
|
+
agent: {
|
|
143
|
+
coding: {
|
|
144
|
+
run: (spec) => Promise.resolve(r('agent.coding.run', [spec], () => stubCodingResult(overrides))),
|
|
145
|
+
launch: (spec) => {
|
|
146
|
+
const correlationId = `stub-run-${++launchSeq}`;
|
|
147
|
+
// The resume payload IS the run result, so `agent.coding.run`
|
|
148
|
+
// overrides control both `await run()` and `launch()` + pause.
|
|
149
|
+
const result = {
|
|
150
|
+
...r('agent.coding.run', [spec], () => stubCodingResult(overrides)),
|
|
151
|
+
runId: correlationId,
|
|
152
|
+
};
|
|
153
|
+
// Generic: any dispatch-able handle registers itself for pause-resume.
|
|
154
|
+
return dispatchable(stubRunHandle(overrides, correlationId, result), opts.signals);
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
fileStorage: {
|
|
159
|
+
upload: (input) => Promise.resolve(r('fileStorage.upload', [input], () => ({
|
|
160
|
+
fileId: 'stub-file',
|
|
161
|
+
uploadUrl: 'https://storage.local/upload/stub-file',
|
|
162
|
+
expiresAt: '2099-01-01T00:00:00Z',
|
|
163
|
+
requiredHeaders: {},
|
|
164
|
+
}))),
|
|
165
|
+
getDownloadUrl: (fileId) => Promise.resolve(r('fileStorage.getDownloadUrl', [fileId], () => ({
|
|
166
|
+
downloadUrl: `https://storage.local/download/${fileId}`,
|
|
167
|
+
expiresAt: '2099-01-01T00:00:00Z',
|
|
168
|
+
}))),
|
|
169
|
+
list: (listOpts) => Promise.resolve(r('fileStorage.list', [listOpts], () => ({ files: [], limit: 20, offset: 0, hasMore: false }))),
|
|
170
|
+
delete: (fileId) => Promise.resolve(r('fileStorage.delete', [fileId], () => undefined)),
|
|
171
|
+
setVisibility: (fileId, visibility) => Promise.resolve(r('fileStorage.setVisibility', [fileId, visibility], () => ({
|
|
172
|
+
fileId,
|
|
173
|
+
contentType: 'application/octet-stream',
|
|
174
|
+
visibility,
|
|
175
|
+
status: 'uploaded',
|
|
176
|
+
createdAt: '2099-01-01T00:00:00Z',
|
|
177
|
+
downloadRequestCount: 0,
|
|
178
|
+
}))),
|
|
179
|
+
},
|
|
180
|
+
withAttribution: () => client,
|
|
181
|
+
};
|
|
182
|
+
return client;
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/stub/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAm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