@sealant/sdk-next 0.40.0-next.878 → 0.40.0-next.879
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/dist/effect/run-harness.js +2 -2
- package/dist/effect/runtime.d.ts +1 -1
- package/dist/effect/runtime.js +1 -3
- package/dist/facade/forward.js +5 -3
- package/dist/facade/session.js +5 -2
- package/dist/facade/workspace.js +2 -2
- package/dist/internal/blueprint.d.ts +140 -2
- package/dist/internal/blueprint.js +7 -0
- package/dist/internal/map-error.js +2 -2
- package/package.json +3 -3
|
@@ -12,6 +12,7 @@ import { BudgetExceededError } from "@sealant/api-contracts";
|
|
|
12
12
|
import { Effect } from "effect";
|
|
13
13
|
import { SealantError } from "../errors.js";
|
|
14
14
|
import { makeRun, toRunChangesData } from "../facade/run.js";
|
|
15
|
+
import { specHarnessId } from "../internal/blueprint.js";
|
|
15
16
|
import { elapsed } from "../internal/clock.js";
|
|
16
17
|
import { toSealantError } from "../internal/map-error.js";
|
|
17
18
|
import { createRunOp, getRunChangesOp, getRunOp, getWorkspaceOp } from "./operations.js";
|
|
@@ -42,8 +43,7 @@ const createHarnessRunEffect = (ctx, init, prompt, options) => Effect.gen(functi
|
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
45
|
const details = yield* getWorkspaceOp(init.id, ctx.config.hostLocal.ownerUserId);
|
|
45
|
-
const
|
|
46
|
-
const harnessId = spec?.harness?.id;
|
|
46
|
+
const harnessId = specHarnessId(details.spec);
|
|
47
47
|
if (harnessId === undefined) {
|
|
48
48
|
return yield* Effect.fail(new SealantError(`Workspace ${init.id} has no harness in its spec; pass a harness at workspaces.create() or use workspace.exec().`, { code: "harness_required" }));
|
|
49
49
|
}
|
package/dist/effect/runtime.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ import { SealantApiClient } from "./api-client.js";
|
|
|
15
15
|
export type SdkServices = SealantApiClient;
|
|
16
16
|
export interface SdkRuntime {
|
|
17
17
|
/** Provide the app context and run an operation effect, surfacing plain `SealantError`s. */
|
|
18
|
-
readonly run: <A, E
|
|
18
|
+
readonly run: <A, E>(effect: Effect.Effect<A, E, SdkServices>) => Promise<A>;
|
|
19
19
|
/** Dispose the runtime scope (the HTTP client). Idempotent. */
|
|
20
20
|
readonly dispose: () => Promise<void>;
|
|
21
21
|
}
|
package/dist/effect/runtime.js
CHANGED
|
@@ -22,7 +22,7 @@ export const makeSdkRuntime = (config) => {
|
|
|
22
22
|
const scope = yield* Scope.make();
|
|
23
23
|
const context = yield* Layer.buildWithScope(appLayer, scope);
|
|
24
24
|
// The layer provides a superset of SdkServices; narrow to the surfaced services.
|
|
25
|
-
return { context
|
|
25
|
+
return { context, scope };
|
|
26
26
|
})).then((exit) => {
|
|
27
27
|
if (Exit.isSuccess(exit)) {
|
|
28
28
|
return exit.value;
|
|
@@ -40,8 +40,6 @@ export const makeSdkRuntime = (config) => {
|
|
|
40
40
|
return {
|
|
41
41
|
run: async (effect) => {
|
|
42
42
|
const { context } = await build();
|
|
43
|
-
// R extends SdkServices and the context provides SdkServices, so all requirements are met
|
|
44
|
-
// (TS can't reduce Exclude<R, SdkServices> to never for a generic R).
|
|
45
43
|
const provided = Effect.provide(effect, context);
|
|
46
44
|
const exit = await Effect.runPromiseExit(provided);
|
|
47
45
|
if (Exit.isSuccess(exit)) {
|
package/dist/facade/forward.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FORWARD_REFUSAL_STATUS, FORWARD_V2_SUBPROTOCOL, forwardOpenFrameSchema, forwardRefusalReasonSchema, } from "@sealant/api-contracts";
|
|
2
|
-
import { Option, Schema } from "effect";
|
|
2
|
+
import { Option, Predicate, Schema } from "effect";
|
|
3
3
|
import { ForwardDialError } from "../errors.js";
|
|
4
4
|
import { resolveRequestPriority } from "../internal/config.js";
|
|
5
5
|
import { boundedForward } from "./bounded-forward.js";
|
|
@@ -36,14 +36,16 @@ const bridgeForward = (ws) => {
|
|
|
36
36
|
if (typeof event.data === "string") {
|
|
37
37
|
try {
|
|
38
38
|
const frame = JSON.parse(event.data);
|
|
39
|
-
if (frame
|
|
39
|
+
if (Predicate.isObject(frame) && frame["t"] === "end") {
|
|
40
40
|
finish("end");
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
catch { }
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
// binaryType is "arraybuffer", so every binary frame arrives as an ArrayBuffer.
|
|
47
|
+
if (event.data instanceof ArrayBuffer)
|
|
48
|
+
pending.push(new Uint8Array(event.data));
|
|
47
49
|
wake?.();
|
|
48
50
|
});
|
|
49
51
|
const output = {
|
package/dist/facade/session.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Predicate } from "effect";
|
|
1
2
|
import { closeSessionOp, getSessionOp, getSessionOutputOp, resizeSessionOp, sendSessionInputOp, signalSessionOp, } from "../effect/operations.js";
|
|
2
3
|
import { SealantBudgetExceededError } from "../errors.js";
|
|
3
4
|
import { resolveRequestPriority } from "../internal/config.js";
|
|
@@ -42,7 +43,7 @@ const openAttachment = (ctx, sessionId, options) => {
|
|
|
42
43
|
if (typeof event.data === "string") {
|
|
43
44
|
try {
|
|
44
45
|
const frame = JSON.parse(event.data);
|
|
45
|
-
if (frame
|
|
46
|
+
if (Predicate.isObject(frame) && frame["t"] === "end") {
|
|
46
47
|
finish("end");
|
|
47
48
|
}
|
|
48
49
|
}
|
|
@@ -51,7 +52,9 @@ const openAttachment = (ctx, sessionId, options) => {
|
|
|
51
52
|
}
|
|
52
53
|
return;
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
+
// binaryType is "arraybuffer", so every binary frame arrives as an ArrayBuffer.
|
|
56
|
+
if (event.data instanceof ArrayBuffer)
|
|
57
|
+
pending.push(new Uint8Array(event.data));
|
|
55
58
|
wake?.();
|
|
56
59
|
});
|
|
57
60
|
ws.addEventListener("close", () => finish("closed"));
|
package/dist/facade/workspace.js
CHANGED
|
@@ -3,6 +3,7 @@ import { applyDotfiles } from "../effect/apply-dotfiles.js";
|
|
|
3
3
|
import { execWorkspace } from "../effect/exec-workspace.js";
|
|
4
4
|
import { bindWorkspaceOp, flushWorkspaceCaptureOp, getWorkspaceCaptureStatusOp, createSessionAsUserOp, createSessionOp, expireWorkspaceOp, clearWorkspaceSshUserOp, getSessionOp, getWorkspaceOp, listSessionsOp, replanWorkspaceCaptureOp, recoverWorkspaceOp, restartWorkspaceOp, listWorkspaceCredentialsOp, putWorkspaceCredentialsOp, pruneWorkspaceCredentialsOp, releaseWorkspaceCredentialsOp, stopWorkspaceOp, } from "../effect/operations.js";
|
|
5
5
|
import { SealantApiError, SealantBoatError, SealantBudgetExceededError, SealantError, SealantNotImplementedError, } from "../errors.js";
|
|
6
|
+
import { specHarnessId } from "../internal/blueprint.js";
|
|
6
7
|
import { elapsed } from "../internal/clock.js";
|
|
7
8
|
import { mapAccountRef } from "../internal/credentials.js";
|
|
8
9
|
import { parseTtlSeconds } from "../internal/duration.js";
|
|
@@ -396,8 +397,7 @@ export const makeWorkspace = (ctx, init) => {
|
|
|
396
397
|
return [init.harness.launchCommand ?? init.harness.id];
|
|
397
398
|
}
|
|
398
399
|
const details = await ctx.runtime.run(getWorkspaceOp(init.id, ctx.config.hostLocal.ownerUserId));
|
|
399
|
-
const
|
|
400
|
-
const harnessId = spec?.harness?.id;
|
|
400
|
+
const harnessId = specHarnessId(details.spec);
|
|
401
401
|
if (harnessId === undefined) {
|
|
402
402
|
throw new SealantError(`Workspace ${init.id} has no harness in its spec; open a session with workspace.sessions.open(argv) instead.`, { code: "harness_required" });
|
|
403
403
|
}
|
|
@@ -1,7 +1,145 @@
|
|
|
1
|
-
import { type CreateWorkspaceRequest } from "@sealant/api-contracts";
|
|
2
1
|
import type { CreateOptions } from "../types.js";
|
|
3
2
|
import type { SealantInternalConfig } from "./config.js";
|
|
4
3
|
export declare const toGitUrl: (repository: string) => string;
|
|
5
4
|
export declare const buildCreateWorkspaceRequest: (options: CreateOptions, config: SealantInternalConfig) => {
|
|
6
|
-
|
|
5
|
+
payload: {
|
|
6
|
+
ownerUserId: string;
|
|
7
|
+
imageScopeId?: string;
|
|
8
|
+
registryId: string;
|
|
9
|
+
repository: string;
|
|
10
|
+
tag: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
ttlSeconds?: number;
|
|
13
|
+
idempotencyKey?: string;
|
|
14
|
+
launchId?: string;
|
|
15
|
+
sshAsOwner?: true;
|
|
16
|
+
spec: {
|
|
17
|
+
version: string;
|
|
18
|
+
sources: {
|
|
19
|
+
workspace: {
|
|
20
|
+
kind: string;
|
|
21
|
+
provider: string;
|
|
22
|
+
url: string;
|
|
23
|
+
ref?: string;
|
|
24
|
+
rootPath?: never;
|
|
25
|
+
hostPath?: never;
|
|
26
|
+
} | {
|
|
27
|
+
kind: string;
|
|
28
|
+
rootPath: string;
|
|
29
|
+
hostPath?: never;
|
|
30
|
+
} | {
|
|
31
|
+
rootPath?: never;
|
|
32
|
+
kind: string;
|
|
33
|
+
endpoint: string;
|
|
34
|
+
worktreeId?: string;
|
|
35
|
+
harnessHome?: string;
|
|
36
|
+
platform?: string;
|
|
37
|
+
transport?: import("../types.js").WorkspaceCaptureTransport;
|
|
38
|
+
ownerMap?: {
|
|
39
|
+
gid: number;
|
|
40
|
+
worktreeUid: number;
|
|
41
|
+
people: {
|
|
42
|
+
id: string;
|
|
43
|
+
uid: number;
|
|
44
|
+
}[];
|
|
45
|
+
};
|
|
46
|
+
hostPath?: never;
|
|
47
|
+
} | {
|
|
48
|
+
rootPath?: never;
|
|
49
|
+
kind: string;
|
|
50
|
+
hostPath: string | undefined;
|
|
51
|
+
};
|
|
52
|
+
inputs?: {
|
|
53
|
+
id: string;
|
|
54
|
+
kind: string;
|
|
55
|
+
purpose: string;
|
|
56
|
+
provider: string;
|
|
57
|
+
url: string;
|
|
58
|
+
ref?: string;
|
|
59
|
+
}[];
|
|
60
|
+
mounts?: {
|
|
61
|
+
hostPath: string;
|
|
62
|
+
mountPath: string;
|
|
63
|
+
readOnly?: boolean;
|
|
64
|
+
bindable?: boolean;
|
|
65
|
+
}[];
|
|
66
|
+
};
|
|
67
|
+
harness: {
|
|
68
|
+
id: string;
|
|
69
|
+
};
|
|
70
|
+
customization: {
|
|
71
|
+
enableSealantd: boolean;
|
|
72
|
+
defaultShell?: "bash" | "fish" | "zsh";
|
|
73
|
+
dotfilesManager?: import("../types.js").WorkspaceDotfilesManager;
|
|
74
|
+
dotfilesBootstrap?: boolean;
|
|
75
|
+
dotfilesBootstrapCommand?: string;
|
|
76
|
+
};
|
|
77
|
+
runtime?: {
|
|
78
|
+
dotfilesArchives?: {
|
|
79
|
+
data: string;
|
|
80
|
+
manager?: import("../types.js").WorkspaceDotfilesManager;
|
|
81
|
+
target?: "config" | "home";
|
|
82
|
+
bootstrap?: boolean;
|
|
83
|
+
bootstrapCommand?: string;
|
|
84
|
+
}[];
|
|
85
|
+
userEnv?: Readonly<Record<string, string>>;
|
|
86
|
+
envFrom?: {
|
|
87
|
+
kind: "configmap" | "secret";
|
|
88
|
+
name: string;
|
|
89
|
+
}[];
|
|
90
|
+
kubernetes?: {
|
|
91
|
+
serviceAccountName: string;
|
|
92
|
+
};
|
|
93
|
+
network?: {
|
|
94
|
+
cloudMetadata: boolean;
|
|
95
|
+
};
|
|
96
|
+
resources?: "none";
|
|
97
|
+
boatAccountId?: string;
|
|
98
|
+
credentialsHome?: {
|
|
99
|
+
path: string;
|
|
100
|
+
uid: number;
|
|
101
|
+
gid: number;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
target: {
|
|
105
|
+
os: {
|
|
106
|
+
family: string;
|
|
107
|
+
mode: string;
|
|
108
|
+
baseImage: string;
|
|
109
|
+
} | {
|
|
110
|
+
baseImage?: never;
|
|
111
|
+
family: import("../types.js").WorkspaceOs;
|
|
112
|
+
mode: string;
|
|
113
|
+
};
|
|
114
|
+
runtime: {
|
|
115
|
+
family: string;
|
|
116
|
+
mode: string;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
lifecycle: {
|
|
120
|
+
startup: {
|
|
121
|
+
foreground: {
|
|
122
|
+
kind: string;
|
|
123
|
+
run: string;
|
|
124
|
+
shell: string;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
tooling?: {
|
|
129
|
+
packages?: {
|
|
130
|
+
id: string;
|
|
131
|
+
}[];
|
|
132
|
+
services?: {
|
|
133
|
+
docker: {
|
|
134
|
+
enabled: boolean;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
credentials?: import("./credentials.js").WorkspaceCredentialsPayload;
|
|
139
|
+
};
|
|
140
|
+
secretEnv?: Readonly<Record<string, string>>;
|
|
141
|
+
captureToken?: string;
|
|
142
|
+
};
|
|
7
143
|
};
|
|
144
|
+
/** The harness id a workspace's spec names (`harness.id`, as `buildCreateWorkspaceRequest` writes it). */
|
|
145
|
+
export declare const specHarnessId: (spec: unknown) => string | undefined;
|
|
@@ -16,6 +16,7 @@ import { randomUUID } from "node:crypto";
|
|
|
16
16
|
import { toOciRepositoryComponent } from "@sealant/api-contracts";
|
|
17
17
|
import { captureOwnerMapProblems } from "@sealant/api-contracts/capture-owner-map";
|
|
18
18
|
import { formatWorkspaceEnvIssue, parseWorkspaceEnv, parseWorkspaceSecretEnv, } from "@sealant/api-contracts/workspace-environment";
|
|
19
|
+
import { Predicate } from "effect";
|
|
19
20
|
import { SealantError } from "../errors.js";
|
|
20
21
|
import { mapWorkspaceCredentials } from "./credentials.js";
|
|
21
22
|
import { parseTtlSeconds } from "./duration.js";
|
|
@@ -294,3 +295,9 @@ export const buildCreateWorkspaceRequest = (options, config) => {
|
|
|
294
295
|
},
|
|
295
296
|
};
|
|
296
297
|
};
|
|
298
|
+
/** The harness id a workspace's spec names (`harness.id`, as `buildCreateWorkspaceRequest` writes it). */
|
|
299
|
+
export const specHarnessId = (spec) => {
|
|
300
|
+
const harness = Predicate.isObject(spec) ? spec["harness"] : undefined;
|
|
301
|
+
const id = Predicate.isObject(harness) ? harness["id"] : undefined;
|
|
302
|
+
return typeof id === "string" ? id : undefined;
|
|
303
|
+
};
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* here. This is the single funnel that keeps Effect internals out of the public, Promise-based API.
|
|
6
6
|
*/
|
|
7
7
|
import { boatFailureSchema, boatKeyReportSchema, BudgetExceededError, } from "@sealant/api-contracts";
|
|
8
|
-
import { Option, Schema } from "effect";
|
|
8
|
+
import { Option, Predicate, Schema } from "effect";
|
|
9
9
|
import { SealantApiError, SealantBudgetExceededError, SealantError } from "../errors.js";
|
|
10
|
-
const asRecord = (value) =>
|
|
10
|
+
const asRecord = (value) => Predicate.isObject(value) ? value : undefined;
|
|
11
11
|
const extractStatus = (record) => {
|
|
12
12
|
if (record === undefined) {
|
|
13
13
|
return undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sealant/sdk-next",
|
|
3
|
-
"version": "0.40.0-next.
|
|
3
|
+
"version": "0.40.0-next.879",
|
|
4
4
|
"description": "The fluent public SDK for Sealant — create a workspace, run a harness, replay the record.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"node": ">=20"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@sealant/api-contracts": "npm:@sealant/api-contracts-next@0.40.0-next.
|
|
29
|
+
"@sealant/api-contracts": "npm:@sealant/api-contracts-next@0.40.0-next.879"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"effect": "^4.0.5"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "7023ad209c68e65b6b2bdf12b981e90f7b362d54",
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
}
|