@b3os/sdk 0.2.2 → 0.2.4
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/README.md +1 -1
- package/dist/cjs/core/util.d.ts +1 -1
- package/dist/cjs/core/util.js +1 -1
- package/dist/cjs/generated/client.d.ts +5 -0
- package/dist/cjs/generated/client.js +9 -0
- package/dist/cjs/generated/client.js.map +1 -1
- package/dist/cjs/generated/errors.d.ts +1 -1
- package/dist/cjs/generated/errors.js +45 -0
- package/dist/cjs/generated/errors.js.map +1 -1
- package/dist/cjs/generated/ids.d.ts +28 -0
- package/dist/cjs/generated/ids.js +7 -0
- package/dist/cjs/generated/ids.js.map +1 -1
- package/dist/cjs/generated/ns/agents.d.ts +449 -11
- package/dist/cjs/generated/ns/agents.js +609 -11
- package/dist/cjs/generated/ns/agents.js.map +1 -1
- package/dist/cjs/generated/ns/images.d.ts +84 -3
- package/dist/cjs/generated/ns/images.js +126 -2
- package/dist/cjs/generated/ns/images.js.map +1 -1
- package/dist/cjs/generated/ns/keys.d.ts +12 -4
- package/dist/cjs/generated/ns/keys.js +12 -4
- package/dist/cjs/generated/ns/keys.js.map +1 -1
- package/dist/cjs/generated/ns/listeners.d.ts +6 -2
- package/dist/cjs/generated/ns/listeners.js +6 -2
- package/dist/cjs/generated/ns/listeners.js.map +1 -1
- package/dist/cjs/generated/ns/routines.d.ts +11 -0
- package/dist/cjs/generated/ns/routines.js +11 -0
- package/dist/cjs/generated/ns/routines.js.map +1 -1
- package/dist/cjs/generated/ns/sandboxes.d.ts +140 -1
- package/dist/cjs/generated/ns/sandboxes.js +190 -1
- package/dist/cjs/generated/ns/sandboxes.js.map +1 -1
- package/dist/cjs/generated/ns/vision.d.ts +55 -1
- package/dist/cjs/generated/ns/vision.js +94 -1
- package/dist/cjs/generated/ns/vision.js.map +1 -1
- package/dist/cjs/generated/ns/workspaces.d.ts +225 -0
- package/dist/cjs/generated/ns/workspaces.js +410 -0
- package/dist/cjs/generated/ns/workspaces.js.map +1 -0
- package/dist/cjs/generated/types.d.ts +2312 -90
- package/dist/esm/core/util.d.ts +1 -1
- package/dist/esm/core/util.js +1 -1
- package/dist/esm/generated/client.d.ts +5 -0
- package/dist/esm/generated/client.js +9 -0
- package/dist/esm/generated/client.js.map +1 -1
- package/dist/esm/generated/errors.d.ts +1 -1
- package/dist/esm/generated/errors.js +45 -0
- package/dist/esm/generated/errors.js.map +1 -1
- package/dist/esm/generated/ids.d.ts +28 -0
- package/dist/esm/generated/ids.js +7 -0
- package/dist/esm/generated/ids.js.map +1 -1
- package/dist/esm/generated/ns/agents.d.ts +449 -11
- package/dist/esm/generated/ns/agents.js +609 -11
- package/dist/esm/generated/ns/agents.js.map +1 -1
- package/dist/esm/generated/ns/images.d.ts +84 -3
- package/dist/esm/generated/ns/images.js +126 -2
- package/dist/esm/generated/ns/images.js.map +1 -1
- package/dist/esm/generated/ns/keys.d.ts +12 -4
- package/dist/esm/generated/ns/keys.js +12 -4
- package/dist/esm/generated/ns/keys.js.map +1 -1
- package/dist/esm/generated/ns/listeners.d.ts +6 -2
- package/dist/esm/generated/ns/listeners.js +6 -2
- package/dist/esm/generated/ns/listeners.js.map +1 -1
- package/dist/esm/generated/ns/routines.d.ts +11 -0
- package/dist/esm/generated/ns/routines.js +11 -0
- package/dist/esm/generated/ns/routines.js.map +1 -1
- package/dist/esm/generated/ns/sandboxes.d.ts +140 -1
- package/dist/esm/generated/ns/sandboxes.js +190 -1
- package/dist/esm/generated/ns/sandboxes.js.map +1 -1
- package/dist/esm/generated/ns/vision.d.ts +55 -1
- package/dist/esm/generated/ns/vision.js +94 -1
- package/dist/esm/generated/ns/vision.js.map +1 -1
- package/dist/esm/generated/ns/workspaces.d.ts +225 -0
- package/dist/esm/generated/ns/workspaces.js +406 -0
- package/dist/esm/generated/ns/workspaces.js.map +1 -0
- package/dist/esm/generated/types.d.ts +2312 -90
- package/package.json +1 -1
- package/src/core/util.ts +1 -1
- package/src/generated/client.ts +10 -0
- package/src/generated/errors.ts +90 -0
- package/src/generated/ids.ts +7 -0
- package/src/generated/ns/agents.ts +663 -11
- package/src/generated/ns/images.ts +131 -3
- package/src/generated/ns/keys.ts +12 -4
- package/src/generated/ns/listeners.ts +6 -2
- package/src/generated/ns/routines.ts +11 -0
- package/src/generated/ns/sandboxes.ts +203 -1
- package/src/generated/ns/vision.ts +101 -1
- package/src/generated/ns/workspaces.ts +448 -0
- package/src/generated/types.ts +2488 -55
|
@@ -114,6 +114,29 @@ const extractEventsOp: Op = {
|
|
|
114
114
|
timeoutMs: 3600000,
|
|
115
115
|
scope: "vision:read",
|
|
116
116
|
};
|
|
117
|
+
const listIdentitiesOp: Op = {
|
|
118
|
+
id: "visionListIdentities",
|
|
119
|
+
method: "GET",
|
|
120
|
+
path: "/v1/vision/identities",
|
|
121
|
+
timeoutMs: 10000,
|
|
122
|
+
scope: "vision:read",
|
|
123
|
+
};
|
|
124
|
+
const retireIdentityOp: Op = {
|
|
125
|
+
id: "visionRetireIdentity",
|
|
126
|
+
method: "DELETE",
|
|
127
|
+
path: "/v1/vision/identities/{identity_id}",
|
|
128
|
+
params: ["identity_id"],
|
|
129
|
+
timeoutMs: 10000,
|
|
130
|
+
scope: "vision:write",
|
|
131
|
+
};
|
|
132
|
+
const getIdentityOp: Op = {
|
|
133
|
+
id: "visionGetIdentity",
|
|
134
|
+
method: "GET",
|
|
135
|
+
path: "/v1/vision/identities/{identity_id}",
|
|
136
|
+
params: ["identity_id"],
|
|
137
|
+
timeoutMs: 10000,
|
|
138
|
+
scope: "vision:read",
|
|
139
|
+
};
|
|
117
140
|
const mapOp: Op = {
|
|
118
141
|
id: "visionMap",
|
|
119
142
|
method: "POST",
|
|
@@ -255,6 +278,14 @@ const actOp: Op = {
|
|
|
255
278
|
timeoutMs: 65000,
|
|
256
279
|
scope: "vision:run",
|
|
257
280
|
};
|
|
281
|
+
const getSessionAuditOp: Op = {
|
|
282
|
+
id: "visionGetSessionAudit",
|
|
283
|
+
method: "GET",
|
|
284
|
+
path: "/v1/vision/sessions/{session_id}/audit",
|
|
285
|
+
params: ["session_id"],
|
|
286
|
+
timeoutMs: 10000,
|
|
287
|
+
scope: "vision:read",
|
|
288
|
+
};
|
|
258
289
|
const connectCdpOp: Op = {
|
|
259
290
|
id: "visionConnectCdp",
|
|
260
291
|
method: "GET",
|
|
@@ -341,6 +372,9 @@ export const visionOps = {
|
|
|
341
372
|
getExtract: getExtractOp,
|
|
342
373
|
cancelExtract: cancelExtractOp,
|
|
343
374
|
extractEvents: extractEventsOp,
|
|
375
|
+
listIdentities: listIdentitiesOp,
|
|
376
|
+
retireIdentity: retireIdentityOp,
|
|
377
|
+
getIdentity: getIdentityOp,
|
|
344
378
|
map: mapOp,
|
|
345
379
|
prepare: prepareOp,
|
|
346
380
|
listProfiles: listProfilesOp,
|
|
@@ -357,6 +391,7 @@ export const visionOps = {
|
|
|
357
391
|
closeSession: closeSessionOp,
|
|
358
392
|
getSession: getSessionOp,
|
|
359
393
|
act: actOp,
|
|
394
|
+
getSessionAudit: getSessionAuditOp,
|
|
360
395
|
connectCdp: connectCdpOp,
|
|
361
396
|
saveSessionProfile: saveSessionProfileOp,
|
|
362
397
|
createSessionTicket: createSessionTicketOp,
|
|
@@ -616,6 +651,50 @@ export class VisionAPI extends Namespace {
|
|
|
616
651
|
});
|
|
617
652
|
}
|
|
618
653
|
|
|
654
|
+
/**
|
|
655
|
+
* List stealth identities
|
|
656
|
+
*
|
|
657
|
+
* Lists your organization's stealth identities, newest first, retired ones included. A stealth session
|
|
658
|
+
* (`stealth` on `POST /v1/vision/sessions`) makes a new identity when it names none and its profile has none;
|
|
659
|
+
* new identities per day and active identities in all are limits (`vision.stealth.identities.daily`,
|
|
660
|
+
* `vision.stealth.identities.max`). Behind the `vision.stealth` feature flag: until it is on for your
|
|
661
|
+
* organization the operation answers `404 feature_not_enabled`.
|
|
662
|
+
*
|
|
663
|
+
* `GET /v1/vision/identities` · scope `vision:read` · served by the node
|
|
664
|
+
*/
|
|
665
|
+
listIdentities(
|
|
666
|
+
params?: T.VisionListIdentitiesParams,
|
|
667
|
+
options?: RequestOptions,
|
|
668
|
+
): ListPromise<T.StealthIdentityList, T.StealthIdentity> {
|
|
669
|
+
return this._client._list<T.StealthIdentityList, T.StealthIdentity>(listIdentitiesOp, { query: params }, options);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* Retire a stealth identity
|
|
674
|
+
*
|
|
675
|
+
* Retires the identity: no new session uses it (a create that names it answers `409 identity_retired`), and
|
|
676
|
+
* it no longer counts toward `vision.stealth.identities.max`. Its record stays, and it still counts toward the
|
|
677
|
+
* day's new identities. Sessions already using it are not closed. Retiring a retired identity changes nothing.
|
|
678
|
+
* Behind the `vision.stealth` feature flag.
|
|
679
|
+
*
|
|
680
|
+
* `DELETE /v1/vision/identities/{identity_id}` · scope `vision:write` · served by the node
|
|
681
|
+
*/
|
|
682
|
+
retireIdentity(identityId: string, options?: RequestOptions): APIPromise<T.StealthIdentity> {
|
|
683
|
+
return this._client._call<T.StealthIdentity>(retireIdentityOp, { path: [identityId] }, options);
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* Get a stealth identity
|
|
688
|
+
*
|
|
689
|
+
* One stealth identity of your organization: what its browser presents (screen, window, fonts), its home
|
|
690
|
+
* region and how often it was used. Behind the `vision.stealth` feature flag.
|
|
691
|
+
*
|
|
692
|
+
* `GET /v1/vision/identities/{identity_id}` · scope `vision:read` · served by the node
|
|
693
|
+
*/
|
|
694
|
+
getIdentity(identityId: string, options?: RequestOptions): APIPromise<T.StealthIdentity> {
|
|
695
|
+
return this._client._call<T.StealthIdentity>(getIdentityOp, { path: [identityId] }, options);
|
|
696
|
+
}
|
|
697
|
+
|
|
619
698
|
/**
|
|
620
699
|
* Map a site's URLs
|
|
621
700
|
*
|
|
@@ -826,7 +905,7 @@ export class VisionAPI extends Namespace {
|
|
|
826
905
|
* list and some categories, keeps one address per organization and host, and never retries a 429 or 503. A page read through a proxy is never read from or stored in the cache. `egress` says which exit served
|
|
827
906
|
* the page, `options` and `X-B3OS-Options` which values applied. A page bills one `vision.page` whichever
|
|
828
907
|
* address it was read from; bytes are never billed. The bytes of residential reads (walls and robots.txt
|
|
829
|
-
* included) count against the monthly safety limit `vision.proxy.bytes.monthly`. Batches, crawls, sessions and the Firecrawl surface leave from the node's address.
|
|
908
|
+
* included) count against the monthly safety limit `vision.proxy.bytes.monthly`. Batches, crawls, sessions (but stealth sessions, which may take your own proxy) and the Firecrawl surface leave from the node's address.
|
|
830
909
|
*
|
|
831
910
|
* `POST /v1/vision/scrape` · scope `vision:run` · served by the node
|
|
832
911
|
*/
|
|
@@ -880,6 +959,10 @@ export class VisionAPI extends Namespace {
|
|
|
880
959
|
* session closes after `timeout_s` (at most 1,800) or on `DELETE`. Bills `vision.browser_ms` from claim to
|
|
881
960
|
* close. A node whose Chrome runs without its own sandbox (`chrome_sandbox: off` in `/readyz`) answers
|
|
882
961
|
* `503 product_unavailable`: one browser per session, with a renderer sandbox.
|
|
962
|
+
* `stealth` (needs the `vision.stealth` flag, invited organizations only) gives a session whose browser keeps
|
|
963
|
+
* one consistent identity and leaves through your own proxy or the node's address (`proxy`); see
|
|
964
|
+
* `StealthOption`. A node that serves no stealth browser answers such a create with `503
|
|
965
|
+
* product_unavailable`.
|
|
883
966
|
*
|
|
884
967
|
* `POST /v1/vision/sessions` · scope `vision:write` · served by the node
|
|
885
968
|
*/
|
|
@@ -933,6 +1016,23 @@ export class VisionAPI extends Namespace {
|
|
|
933
1016
|
return this._client._call<T.ActResult>(actOp, { path: [sessionId], body }, options);
|
|
934
1017
|
}
|
|
935
1018
|
|
|
1019
|
+
/**
|
|
1020
|
+
* Get a stealth session's audit record
|
|
1021
|
+
*
|
|
1022
|
+
* The durable record of one stealth session, line by line, kept 400 days, also after the session itself is
|
|
1023
|
+
* no longer listed: who started it (organization, project, key, creator, the stealth terms version in force),
|
|
1024
|
+
* what it presented (identity, persona, stage, engine version, exit class and place), every connection its
|
|
1025
|
+
* browser opened (host, port, times, bytes), every main-frame navigation as origin and path (never the
|
|
1026
|
+
* query), challenges seen, refusals (the deny list, robots.txt), warnings, act step kinds and the close
|
|
1027
|
+
* reason. It never holds page content, form values, cookies, screenshots or CDP payloads. Behind the
|
|
1028
|
+
* `vision.stealth` feature flag; a session that was not a stealth session answers `404 session_not_found`.
|
|
1029
|
+
*
|
|
1030
|
+
* `GET /v1/vision/sessions/{session_id}/audit` · scope `vision:read` · served by the node
|
|
1031
|
+
*/
|
|
1032
|
+
getSessionAudit(sessionId: string, options?: RequestOptions): APIPromise<T.StealthAudit> {
|
|
1033
|
+
return this._client._call<T.StealthAudit>(getSessionAuditOp, { path: [sessionId] }, options);
|
|
1034
|
+
}
|
|
1035
|
+
|
|
936
1036
|
/**
|
|
937
1037
|
* Connect over CDP
|
|
938
1038
|
*
|
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
// Generated by packages/sdk/scripts/generate.mjs from packages/spec/dist. Do not edit; run `pnpm generate`.
|
|
2
|
+
|
|
3
|
+
import type { RequestOptions } from "../../core/client.ts";
|
|
4
|
+
import { Namespace } from "../../core/namespace.ts";
|
|
5
|
+
import type { Op } from "../../core/op.ts";
|
|
6
|
+
import type { APIPromise, ListPromise } from "../../core/promise.ts";
|
|
7
|
+
import type * as T from "../types.ts";
|
|
8
|
+
|
|
9
|
+
const listWorkspacesOp: Op = {
|
|
10
|
+
id: "workspacesListWorkspaces",
|
|
11
|
+
method: "GET",
|
|
12
|
+
path: "/v1/workspaces",
|
|
13
|
+
timeoutMs: 10000,
|
|
14
|
+
stretch: true,
|
|
15
|
+
scope: "workspaces:read",
|
|
16
|
+
};
|
|
17
|
+
const createWorkspaceOp: Op = {
|
|
18
|
+
id: "workspacesCreateWorkspace",
|
|
19
|
+
method: "POST",
|
|
20
|
+
path: "/v1/workspaces",
|
|
21
|
+
body: "json",
|
|
22
|
+
idem: true,
|
|
23
|
+
timeoutMs: 10000,
|
|
24
|
+
stretch: true,
|
|
25
|
+
scope: "workspaces:write",
|
|
26
|
+
};
|
|
27
|
+
const deleteWorkspaceOp: Op = {
|
|
28
|
+
id: "workspacesDeleteWorkspace",
|
|
29
|
+
method: "DELETE",
|
|
30
|
+
path: "/v1/workspaces/{workspace_id}",
|
|
31
|
+
params: ["workspace_id"],
|
|
32
|
+
timeoutMs: 10000,
|
|
33
|
+
stretch: true,
|
|
34
|
+
scope: "workspaces:write",
|
|
35
|
+
};
|
|
36
|
+
const getWorkspaceOp: Op = {
|
|
37
|
+
id: "workspacesGetWorkspace",
|
|
38
|
+
method: "GET",
|
|
39
|
+
path: "/v1/workspaces/{workspace_id}",
|
|
40
|
+
params: ["workspace_id"],
|
|
41
|
+
timeoutMs: 10000,
|
|
42
|
+
stretch: true,
|
|
43
|
+
scope: "workspaces:read",
|
|
44
|
+
};
|
|
45
|
+
const listBranchesOp: Op = {
|
|
46
|
+
id: "workspacesListBranches",
|
|
47
|
+
method: "GET",
|
|
48
|
+
path: "/v1/workspaces/{workspace_id}/branches",
|
|
49
|
+
params: ["workspace_id"],
|
|
50
|
+
timeoutMs: 10000,
|
|
51
|
+
stretch: true,
|
|
52
|
+
scope: "workspaces:read",
|
|
53
|
+
};
|
|
54
|
+
const createBranchOp: Op = {
|
|
55
|
+
id: "workspacesCreateBranch",
|
|
56
|
+
method: "POST",
|
|
57
|
+
path: "/v1/workspaces/{workspace_id}/branches",
|
|
58
|
+
params: ["workspace_id"],
|
|
59
|
+
body: "json",
|
|
60
|
+
idem: true,
|
|
61
|
+
timeoutMs: 10000,
|
|
62
|
+
stretch: true,
|
|
63
|
+
scope: "workspaces:run",
|
|
64
|
+
};
|
|
65
|
+
const deleteBranchOp: Op = {
|
|
66
|
+
id: "workspacesDeleteBranch",
|
|
67
|
+
method: "DELETE",
|
|
68
|
+
path: "/v1/workspaces/{workspace_id}/branches/{branch_id}",
|
|
69
|
+
params: ["workspace_id", "branch_id"],
|
|
70
|
+
timeoutMs: 10000,
|
|
71
|
+
stretch: true,
|
|
72
|
+
scope: "workspaces:run",
|
|
73
|
+
};
|
|
74
|
+
const getBranchOp: Op = {
|
|
75
|
+
id: "workspacesGetBranch",
|
|
76
|
+
method: "GET",
|
|
77
|
+
path: "/v1/workspaces/{workspace_id}/branches/{branch_id}",
|
|
78
|
+
params: ["workspace_id", "branch_id"],
|
|
79
|
+
timeoutMs: 10000,
|
|
80
|
+
stretch: true,
|
|
81
|
+
scope: "workspaces:read",
|
|
82
|
+
};
|
|
83
|
+
const commitOp: Op = {
|
|
84
|
+
id: "workspacesCommit",
|
|
85
|
+
method: "POST",
|
|
86
|
+
path: "/v1/workspaces/{workspace_id}/branches/{branch_id}/commits",
|
|
87
|
+
params: ["workspace_id", "branch_id"],
|
|
88
|
+
body: "json",
|
|
89
|
+
idem: true,
|
|
90
|
+
timeoutMs: 60000,
|
|
91
|
+
stretch: true,
|
|
92
|
+
scope: "workspaces:run",
|
|
93
|
+
};
|
|
94
|
+
const mergeOp: Op = {
|
|
95
|
+
id: "workspacesMerge",
|
|
96
|
+
method: "POST",
|
|
97
|
+
path: "/v1/workspaces/{workspace_id}/branches/{branch_id}/merge",
|
|
98
|
+
params: ["workspace_id", "branch_id"],
|
|
99
|
+
body: "json",
|
|
100
|
+
idem: true,
|
|
101
|
+
timeoutMs: 60000,
|
|
102
|
+
stretch: true,
|
|
103
|
+
scope: "workspaces:run",
|
|
104
|
+
};
|
|
105
|
+
const listCommitsOp: Op = {
|
|
106
|
+
id: "workspacesListCommits",
|
|
107
|
+
method: "GET",
|
|
108
|
+
path: "/v1/workspaces/{workspace_id}/commits",
|
|
109
|
+
params: ["workspace_id"],
|
|
110
|
+
timeoutMs: 10000,
|
|
111
|
+
stretch: true,
|
|
112
|
+
scope: "workspaces:read",
|
|
113
|
+
};
|
|
114
|
+
const getCommitOp: Op = {
|
|
115
|
+
id: "workspacesGetCommit",
|
|
116
|
+
method: "GET",
|
|
117
|
+
path: "/v1/workspaces/{workspace_id}/commits/{commit_id}",
|
|
118
|
+
params: ["workspace_id", "commit_id"],
|
|
119
|
+
timeoutMs: 10000,
|
|
120
|
+
stretch: true,
|
|
121
|
+
scope: "workspaces:read",
|
|
122
|
+
};
|
|
123
|
+
const diffOp: Op = {
|
|
124
|
+
id: "workspacesDiff",
|
|
125
|
+
method: "GET",
|
|
126
|
+
path: "/v1/workspaces/{workspace_id}/diff",
|
|
127
|
+
params: ["workspace_id"],
|
|
128
|
+
timeoutMs: 30000,
|
|
129
|
+
stretch: true,
|
|
130
|
+
scope: "workspaces:read",
|
|
131
|
+
};
|
|
132
|
+
const listFilesOp: Op = {
|
|
133
|
+
id: "workspacesListFiles",
|
|
134
|
+
method: "GET",
|
|
135
|
+
path: "/v1/workspaces/{workspace_id}/files",
|
|
136
|
+
params: ["workspace_id"],
|
|
137
|
+
timeoutMs: 10000,
|
|
138
|
+
stretch: true,
|
|
139
|
+
scope: "workspaces:read",
|
|
140
|
+
};
|
|
141
|
+
const readFileOp: Op = {
|
|
142
|
+
id: "workspacesReadFile",
|
|
143
|
+
method: "GET",
|
|
144
|
+
path: "/v1/workspaces/{workspace_id}/files/content",
|
|
145
|
+
params: ["workspace_id"],
|
|
146
|
+
timeoutMs: 30000,
|
|
147
|
+
stretch: true,
|
|
148
|
+
scope: "workspaces:read",
|
|
149
|
+
};
|
|
150
|
+
const putRulesOp: Op = {
|
|
151
|
+
id: "workspacesPutRules",
|
|
152
|
+
method: "PUT",
|
|
153
|
+
path: "/v1/workspaces/{workspace_id}/rules",
|
|
154
|
+
params: ["workspace_id"],
|
|
155
|
+
body: "json",
|
|
156
|
+
timeoutMs: 10000,
|
|
157
|
+
stretch: true,
|
|
158
|
+
scope: "workspaces:rules:write",
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/** Descriptors of every workspaces operation, keyed by method name (for tooling and custom clients). */
|
|
162
|
+
export const workspacesOps = {
|
|
163
|
+
listWorkspaces: listWorkspacesOp,
|
|
164
|
+
createWorkspace: createWorkspaceOp,
|
|
165
|
+
deleteWorkspace: deleteWorkspaceOp,
|
|
166
|
+
getWorkspace: getWorkspaceOp,
|
|
167
|
+
listBranches: listBranchesOp,
|
|
168
|
+
createBranch: createBranchOp,
|
|
169
|
+
deleteBranch: deleteBranchOp,
|
|
170
|
+
getBranch: getBranchOp,
|
|
171
|
+
commit: commitOp,
|
|
172
|
+
merge: mergeOp,
|
|
173
|
+
listCommits: listCommitsOp,
|
|
174
|
+
getCommit: getCommitOp,
|
|
175
|
+
diff: diffOp,
|
|
176
|
+
listFiles: listFilesOp,
|
|
177
|
+
readFile: readFileOp,
|
|
178
|
+
putRules: putRulesOp,
|
|
179
|
+
} as const;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Workspaces: file trees with git-compatible history, a branch per agent, commits checked against per-path rules, and merges that report every conflict (`/v1/workspaces`).
|
|
183
|
+
*/
|
|
184
|
+
export class WorkspacesAPI extends Namespace {
|
|
185
|
+
/**
|
|
186
|
+
* List workspaces
|
|
187
|
+
*
|
|
188
|
+
* Lists this project's workspaces, newest first. Deleted workspaces are not listed.
|
|
189
|
+
*
|
|
190
|
+
* `GET /v1/workspaces` · scope `workspaces:read` · served by the node
|
|
191
|
+
*
|
|
192
|
+
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
193
|
+
*/
|
|
194
|
+
listWorkspaces(
|
|
195
|
+
params?: T.WorkspacesListWorkspacesParams,
|
|
196
|
+
options?: RequestOptions,
|
|
197
|
+
): ListPromise<T.WorkspaceList, T.Workspace> {
|
|
198
|
+
return this._client._list<T.WorkspaceList, T.Workspace>(listWorkspacesOp, { query: params }, options);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Create a workspace
|
|
203
|
+
*
|
|
204
|
+
* Creates an empty workspace with one branch, `main`, protected: merging into `main` needs `workspaces:write`,
|
|
205
|
+
* so agents (whose grants hold `workspaces:run` unless they name more) merge into their own branches and a
|
|
206
|
+
* person or a routine promotes. `rules` are optional; a workspace without rules is open to the whole project,
|
|
207
|
+
* like every other B3OS object. Setting rules later needs `workspaces:rules:write`.
|
|
208
|
+
*
|
|
209
|
+
* `POST /v1/workspaces` · scope `workspaces:write` · served by the node
|
|
210
|
+
*
|
|
211
|
+
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
212
|
+
*/
|
|
213
|
+
createWorkspace(body: T.WorkspaceCreateRequest, options?: RequestOptions): APIPromise<T.Workspace> {
|
|
214
|
+
return this._client._call<T.Workspace>(createWorkspaceOp, { body }, options);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Delete a workspace
|
|
219
|
+
*
|
|
220
|
+
* Deletes the workspace, its branches and its history. A branch mounted into a sandbox or an agent instance
|
|
221
|
+
* answers `409 branch_held` until it is released. Only this call removes a workspace's data: no expiry, deploy
|
|
222
|
+
* or cleanup does.
|
|
223
|
+
*
|
|
224
|
+
* `DELETE /v1/workspaces/{workspace_id}` · scope `workspaces:write` · served by the node
|
|
225
|
+
*
|
|
226
|
+
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
227
|
+
*/
|
|
228
|
+
deleteWorkspace(workspaceId: string, options?: RequestOptions): APIPromise<T.Deleted> {
|
|
229
|
+
return this._client._call<T.Deleted>(deleteWorkspaceOp, { path: [workspaceId] }, options);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Get a workspace
|
|
234
|
+
*
|
|
235
|
+
* Returns one of this project's workspaces, with its rules, the head of `main` and its usage.
|
|
236
|
+
*
|
|
237
|
+
* `GET /v1/workspaces/{workspace_id}` · scope `workspaces:read` · served by the node
|
|
238
|
+
*
|
|
239
|
+
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
240
|
+
*/
|
|
241
|
+
getWorkspace(workspaceId: string, options?: RequestOptions): APIPromise<T.Workspace> {
|
|
242
|
+
return this._client._call<T.Workspace>(getWorkspaceOp, { path: [workspaceId] }, options);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* List branches
|
|
247
|
+
*
|
|
248
|
+
* Lists the workspace's branches, newest first, open ones unless `status` says otherwise.
|
|
249
|
+
*
|
|
250
|
+
* `GET /v1/workspaces/{workspace_id}/branches` · scope `workspaces:read` · served by the node
|
|
251
|
+
*
|
|
252
|
+
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
253
|
+
*/
|
|
254
|
+
listBranches(
|
|
255
|
+
workspaceId: string,
|
|
256
|
+
params?: T.WorkspacesListBranchesParams,
|
|
257
|
+
options?: RequestOptions,
|
|
258
|
+
): ListPromise<T.BranchList, T.Branch> {
|
|
259
|
+
return this._client._list<T.BranchList, T.Branch>(listBranchesOp, { path: [workspaceId], query: params }, options);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Create a branch
|
|
264
|
+
*
|
|
265
|
+
* Makes a branch from a branch's head or from a commit (`from`, `main` by default). No data is copied: the
|
|
266
|
+
* branch starts at that commit. Without a `name` the branch is ephemeral and expires `ttl_s` after its creation
|
|
267
|
+
* (7 days by default) unless it was merged; with one it is kept until it is deleted.
|
|
268
|
+
*
|
|
269
|
+
* `POST /v1/workspaces/{workspace_id}/branches` · scope `workspaces:run` · served by the node
|
|
270
|
+
*
|
|
271
|
+
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
272
|
+
*/
|
|
273
|
+
createBranch(workspaceId: string, body: T.BranchCreateRequest, options?: RequestOptions): APIPromise<T.Branch> {
|
|
274
|
+
return this._client._call<T.Branch>(createBranchOp, { path: [workspaceId], body }, options);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Delete a branch
|
|
279
|
+
*
|
|
280
|
+
* Closes the branch. Its commits stay in the history while another branch reaches them, and for
|
|
281
|
+
* `workspaces.history_days` after that. `main` cannot be deleted, and a mounted branch answers `409 branch_held`.
|
|
282
|
+
*
|
|
283
|
+
* `DELETE /v1/workspaces/{workspace_id}/branches/{branch_id}` · scope `workspaces:run` · served by the node
|
|
284
|
+
*
|
|
285
|
+
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
286
|
+
*/
|
|
287
|
+
deleteBranch(workspaceId: string, branchId: string, options?: RequestOptions): APIPromise<T.Deleted> {
|
|
288
|
+
return this._client._call<T.Deleted>(deleteBranchOp, { path: [workspaceId, branchId] }, options);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Get a branch
|
|
293
|
+
*
|
|
294
|
+
* Returns one branch: its base and head commits, whether it is protected, and what holds it mounted.
|
|
295
|
+
*
|
|
296
|
+
* `GET /v1/workspaces/{workspace_id}/branches/{branch_id}` · scope `workspaces:read` · served by the node
|
|
297
|
+
*
|
|
298
|
+
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
299
|
+
*/
|
|
300
|
+
getBranch(workspaceId: string, branchId: string, options?: RequestOptions): APIPromise<T.Branch> {
|
|
301
|
+
return this._client._call<T.Branch>(getBranchOp, { path: [workspaceId, branchId] }, options);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Commit to a branch
|
|
306
|
+
*
|
|
307
|
+
* Adds a commit on top of the branch's head from a list of files to write or delete. Every path is checked
|
|
308
|
+
* before anything is stored: a path the caller's principals may not write (or may not see) refuses the whole
|
|
309
|
+
* commit with `403 path_not_writable`, an `append_only` file that loses bytes with `422 append_only_violation`,
|
|
310
|
+
* and a file that holds a credential (B3OS keys, common provider tokens, private keys) with
|
|
311
|
+
* `422 secret_in_commit`, which names the path and line and never the value. `if_head` makes the commit apply
|
|
312
|
+
* only while the branch's head is still that commit (`409 head_moved` otherwise). Writing the same bytes a path
|
|
313
|
+
* already holds changes nothing; a commit that changes nothing answers the current head.
|
|
314
|
+
*
|
|
315
|
+
* From inside a sandbox that holds the branch (created with `workspaces`), send no `files`: the node reads what
|
|
316
|
+
* the sandbox changed under the branch's path (new and changed files, deletes, replaced folders), takes from the
|
|
317
|
+
* sandbox only the contents that differ from the head, and commits them as the sandbox, with the same checks.
|
|
318
|
+
* That call needs no workspaces scope: holding the branch is the authority for it, and for nothing else. A
|
|
319
|
+
* sandbox naming another branch is `403 forbidden` (reason `sandbox`), and a file that changes while the commit
|
|
320
|
+
* reads it is `409 conflict` (commit again). Uncommitted changes stay in the sandbox; the next commit sends only
|
|
321
|
+
* what changed since.
|
|
322
|
+
*
|
|
323
|
+
* `POST /v1/workspaces/{workspace_id}/branches/{branch_id}/commits` · scope `workspaces:run` · served by the node
|
|
324
|
+
*
|
|
325
|
+
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
326
|
+
*/
|
|
327
|
+
commit(workspaceId: string, branchId: string, body: T.CommitRequest, options?: RequestOptions): APIPromise<T.Commit> {
|
|
328
|
+
return this._client._call<T.Commit>(commitOp, { path: [workspaceId, branchId], body }, options);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Merge a branch into another
|
|
333
|
+
*
|
|
334
|
+
* Merges the branch into `into` (a branch name or ID, `main` by default) with a three-way merge against their
|
|
335
|
+
* merge base, and answers the target's new head. Paths changed on one side only merge without reading their
|
|
336
|
+
* content; a path changed on both sides merges line by line when both are text, and is a conflict when the
|
|
337
|
+
* changes overlap, when either is binary, or when one side deleted it. A conflict answers
|
|
338
|
+
* `409 merge_conflict` with every conflict (path, kind and the three blob IDs) and changes nothing.
|
|
339
|
+
* `mode: paths` makes any path changed on both sides a conflict. Merging into a protected branch (`main` by
|
|
340
|
+
* default) needs `workspaces:write`.
|
|
341
|
+
*
|
|
342
|
+
* `POST /v1/workspaces/{workspace_id}/branches/{branch_id}/merge` · scope `workspaces:run` · served by the node
|
|
343
|
+
*
|
|
344
|
+
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
345
|
+
*/
|
|
346
|
+
merge(
|
|
347
|
+
workspaceId: string,
|
|
348
|
+
branchId: string,
|
|
349
|
+
body: T.MergeRequest,
|
|
350
|
+
options?: RequestOptions,
|
|
351
|
+
): APIPromise<T.MergeResult> {
|
|
352
|
+
return this._client._call<T.MergeResult>(mergeOp, { path: [workspaceId, branchId], body }, options);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* List commits
|
|
357
|
+
*
|
|
358
|
+
* Lists the commits a branch reaches (`branch_id`, else `main`), newest first.
|
|
359
|
+
*
|
|
360
|
+
* `GET /v1/workspaces/{workspace_id}/commits` · scope `workspaces:read` · served by the node
|
|
361
|
+
*
|
|
362
|
+
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
363
|
+
*/
|
|
364
|
+
listCommits(
|
|
365
|
+
workspaceId: string,
|
|
366
|
+
params?: T.WorkspacesListCommitsParams,
|
|
367
|
+
options?: RequestOptions,
|
|
368
|
+
): ListPromise<T.CommitList, T.Commit> {
|
|
369
|
+
return this._client._list<T.CommitList, T.Commit>(listCommitsOp, { path: [workspaceId], query: params }, options);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Get a commit
|
|
374
|
+
*
|
|
375
|
+
* Returns one commit of the workspace, with its parents, its git IDs and the principals behind it.
|
|
376
|
+
*
|
|
377
|
+
* `GET /v1/workspaces/{workspace_id}/commits/{commit_id}` · scope `workspaces:read` · served by the node
|
|
378
|
+
*
|
|
379
|
+
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
380
|
+
*/
|
|
381
|
+
getCommit(workspaceId: string, commitId: string, options?: RequestOptions): APIPromise<T.Commit> {
|
|
382
|
+
return this._client._call<T.Commit>(getCommitOp, { path: [workspaceId, commitId] }, options);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Diff two commits
|
|
387
|
+
*
|
|
388
|
+
* The paths that differ between `base` and `head` (commit IDs or branch names), each added, modified, deleted or
|
|
389
|
+
* changed type, with sizes, read from the trees without walking any files. Only paths the caller may read are
|
|
390
|
+
* listed. `path` limits the answer to one directory.
|
|
391
|
+
*
|
|
392
|
+
* `GET /v1/workspaces/{workspace_id}/diff` · scope `workspaces:read` · served by the node
|
|
393
|
+
*
|
|
394
|
+
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
395
|
+
*/
|
|
396
|
+
diff(workspaceId: string, params: T.WorkspacesDiffParams, options?: RequestOptions): APIPromise<T.WorkspaceDiff> {
|
|
397
|
+
return this._client._call<T.WorkspaceDiff>(diffOp, { path: [workspaceId], query: params }, options);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* List files
|
|
402
|
+
*
|
|
403
|
+
* Lists a directory at `ref` (a commit ID or a branch name; `main` by default), or describes one file. Only
|
|
404
|
+
* paths the caller may read are listed; any other path answers `404 workspace_path_not_found`, as a path that
|
|
405
|
+
* does not exist does.
|
|
406
|
+
*
|
|
407
|
+
* `GET /v1/workspaces/{workspace_id}/files` · scope `workspaces:read` · served by the node
|
|
408
|
+
*
|
|
409
|
+
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
410
|
+
*/
|
|
411
|
+
listFiles(
|
|
412
|
+
workspaceId: string,
|
|
413
|
+
params?: T.WorkspacesListFilesParams,
|
|
414
|
+
options?: RequestOptions,
|
|
415
|
+
): APIPromise<T.WorkspaceEntryList> {
|
|
416
|
+
return this._client._call<T.WorkspaceEntryList>(listFilesOp, { path: [workspaceId], query: params }, options);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Read a file
|
|
421
|
+
*
|
|
422
|
+
* The bytes of one file at `ref` (a commit ID or a branch name; `main` by default), if the caller may read it.
|
|
423
|
+
*
|
|
424
|
+
* `GET /v1/workspaces/{workspace_id}/files/content` · scope `workspaces:read` · served by the node
|
|
425
|
+
*
|
|
426
|
+
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
427
|
+
*/
|
|
428
|
+
readFile(workspaceId: string, params: T.WorkspacesReadFileParams, options?: RequestOptions): APIPromise<Uint8Array> {
|
|
429
|
+
return this._client._call<Uint8Array>(readFileOp, { path: [workspaceId], query: params }, options, "*/*", "bytes");
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Replace a workspace's rules
|
|
434
|
+
*
|
|
435
|
+
* Replaces the ordered list of path rules. The last rule that matches a path decides it; a principal may read
|
|
436
|
+
* (or write) a path only when the agent, the human and whoever started the turn are all allowed by it. A rule
|
|
437
|
+
* with `append_only` lets a commit only add bytes at the end of a matching file. New rules bind every commit
|
|
438
|
+
* from now on. Needs `workspaces:rules:write`, which a sandbox's grant holds only when it names it exactly, so an
|
|
439
|
+
* agent never changes the rules that bind it.
|
|
440
|
+
*
|
|
441
|
+
* `PUT /v1/workspaces/{workspace_id}/rules` · scope `workspaces:rules:write` · served by the node
|
|
442
|
+
*
|
|
443
|
+
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
444
|
+
*/
|
|
445
|
+
putRules(workspaceId: string, body: T.WorkspaceRulesRequest, options?: RequestOptions): APIPromise<T.Workspace> {
|
|
446
|
+
return this._client._call<T.Workspace>(putRulesOp, { path: [workspaceId], body }, options);
|
|
447
|
+
}
|
|
448
|
+
}
|