@sealant/sdk-next 0.40.0-next.976 → 0.40.0-next.978
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/api-client.d.ts +6 -2
- package/dist/effect/operations.d.ts +2 -1
- package/dist/effect/operations.js +5 -1
- package/dist/effect/run-harness.d.ts +5 -2
- package/dist/effect/run-harness.js +9 -6
- package/dist/effect/runtime.d.ts +4 -3
- package/dist/effect/runtime.js +6 -2
- package/dist/types.d.ts +13 -2
- package/package.json +3 -3
|
@@ -3049,7 +3049,9 @@ declare const makeControlPlaneClient: Effect.Effect<{
|
|
|
3049
3049
|
readonly cwd: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
3050
3050
|
}>>;
|
|
3051
3051
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Unknown>>;
|
|
3052
|
-
}>>,
|
|
3052
|
+
}>>, import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
|
|
3053
|
+
readonly "idempotency-key": import("effect/Schema").optional<import("effect/Schema").String>;
|
|
3054
|
+
}>>, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
3053
3055
|
readonly runId: import("effect/Schema").String;
|
|
3054
3056
|
readonly workspaceId: import("effect/Schema").String;
|
|
3055
3057
|
readonly attemptId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
@@ -8071,7 +8073,9 @@ declare const SealantApiClient_base: Context.ServiceClass<SealantApiClient, "@se
|
|
|
8071
8073
|
readonly cwd: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
8072
8074
|
}>>;
|
|
8073
8075
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Unknown>>;
|
|
8074
|
-
}>>,
|
|
8076
|
+
}>>, import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
|
|
8077
|
+
readonly "idempotency-key": import("effect/Schema").optional<import("effect/Schema").String>;
|
|
8078
|
+
}>>, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
8075
8079
|
readonly runId: import("effect/Schema").String;
|
|
8076
8080
|
readonly workspaceId: import("effect/Schema").String;
|
|
8077
8081
|
readonly attemptId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
@@ -1044,7 +1044,8 @@ export declare const getWorkspaceNetworkPolicyOp: (workspaceId: string, query: G
|
|
|
1044
1044
|
readonly confirmedRevocationWatermark?: number | undefined;
|
|
1045
1045
|
} | undefined;
|
|
1046
1046
|
}, import("@sealant/api-contracts").BudgetExceededError | import("effect/http/HttpClientError").HttpClientError | import("@sealant/api-contracts").RequestRefusedError | Schema.SchemaError | import("@sealant/api-contracts").WorkspaceInternalServerError | import("@sealant/api-contracts").WorkspaceNotFoundError, SealantApiClient>;
|
|
1047
|
-
|
|
1047
|
+
/** With `idempotencyKey`, a retried create answers the run the first one made (and is retry-safe). */
|
|
1048
|
+
export declare const createRunOp: (payload: CreateRunRequest, idempotencyKey?: string) => Effect.Effect<{
|
|
1048
1049
|
readonly runId: string;
|
|
1049
1050
|
readonly workspaceId: string;
|
|
1050
1051
|
readonly attemptId?: string | undefined;
|
|
@@ -51,7 +51,11 @@ export const revokeWorkspaceAccessOp = (workspaceId, payload) => Effect.flatMap(
|
|
|
51
51
|
/** A workspace's network policy, brokered secrets (no values), revocations and proxy state. */
|
|
52
52
|
export const getWorkspaceNetworkPolicyOp = (workspaceId, query) => Effect.flatMap(SealantApiClient, (client) => client.workspaces.getWorkspaceNetworkPolicy({ params: { workspaceId }, query }));
|
|
53
53
|
// ---- runs ----
|
|
54
|
-
|
|
54
|
+
/** With `idempotencyKey`, a retried create answers the run the first one made (and is retry-safe). */
|
|
55
|
+
export const createRunOp = (payload, idempotencyKey) => Effect.flatMap(SealantApiClient, (client) => client.runs.createRun({
|
|
56
|
+
payload,
|
|
57
|
+
headers: idempotencyKey === undefined ? {} : { "idempotency-key": idempotencyKey },
|
|
58
|
+
}));
|
|
55
59
|
const ownerQuery = (ownerUserId) => ownerUserId === undefined ? {} : { ownerUserId };
|
|
56
60
|
export const getRunOp = (runId, ownerUserId) => Effect.flatMap(SealantApiClient, (client) => client.runs.getRun({ params: { runId }, query: ownerQuery(ownerUserId) }));
|
|
57
61
|
export const listRunsOp = (query) => Effect.flatMap(SealantApiClient, (client) => client.runs.listRuns({ query }));
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { RunHarnessFn } from "../facade/workspace.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* The BLOCKING `harness.run()` implementation, registered into the Workspace facade by the client.
|
|
4
|
+
* `options.signal` interrupts the create and the wait.
|
|
5
|
+
*/
|
|
3
6
|
export declare const runHarness: RunHarnessFn;
|
|
4
7
|
/**
|
|
5
8
|
* The NON-BLOCKING `harness.start()` implementation: register the run and return the live handle
|
|
6
9
|
* immediately. Callers stream progress via `run.record.stream()` and settle via `run.wait()` (which
|
|
7
|
-
* fetches the captured changes once terminal).
|
|
10
|
+
* fetches the captured changes once terminal). `options.signal` interrupts the create.
|
|
8
11
|
*/
|
|
9
12
|
export declare const startHarness: RunHarnessFn;
|
|
@@ -40,7 +40,7 @@ const createHarnessRunEffect = (ctx, init, prompt, options) => Effect.gen(functi
|
|
|
40
40
|
prompt,
|
|
41
41
|
command: { executable: command.executable, args: [...command.args] },
|
|
42
42
|
...metadata,
|
|
43
|
-
});
|
|
43
|
+
}, options?.idempotencyKey);
|
|
44
44
|
}
|
|
45
45
|
const details = yield* getWorkspaceOp(init.id, ctx.config.hostLocal.ownerUserId);
|
|
46
46
|
const harnessId = specHarnessId(details.spec);
|
|
@@ -54,7 +54,7 @@ const createHarnessRunEffect = (ctx, init, prompt, options) => Effect.gen(functi
|
|
|
54
54
|
mode: "one-shot",
|
|
55
55
|
prompt,
|
|
56
56
|
...metadata,
|
|
57
|
-
});
|
|
57
|
+
}, options?.idempotencyKey);
|
|
58
58
|
});
|
|
59
59
|
const runHarnessEffect = (ctx, init, prompt, options) => Effect.gen(function* () {
|
|
60
60
|
const created = yield* createHarnessRunEffect(ctx, init, prompt, options);
|
|
@@ -82,11 +82,14 @@ const runHarnessEffect = (ctx, init, prompt, options) => Effect.gen(function* ()
|
|
|
82
82
|
})
|
|
83
83
|
: error));
|
|
84
84
|
});
|
|
85
|
-
/**
|
|
86
|
-
|
|
85
|
+
/**
|
|
86
|
+
* The BLOCKING `harness.run()` implementation, registered into the Workspace facade by the client.
|
|
87
|
+
* `options.signal` interrupts the create and the wait.
|
|
88
|
+
*/
|
|
89
|
+
export const runHarness = (ctx, init, prompt, options) => ctx.runtime.run(runHarnessEffect(ctx, init, prompt, options), undefined, options?.signal);
|
|
87
90
|
/**
|
|
88
91
|
* The NON-BLOCKING `harness.start()` implementation: register the run and return the live handle
|
|
89
92
|
* immediately. Callers stream progress via `run.record.stream()` and settle via `run.wait()` (which
|
|
90
|
-
* fetches the captured changes once terminal).
|
|
93
|
+
* fetches the captured changes once terminal). `options.signal` interrupts the create.
|
|
91
94
|
*/
|
|
92
|
-
export const startHarness = (ctx, init, prompt, options) => ctx.runtime.run(Effect.map(createHarnessRunEffect(ctx, init, prompt, options), (created) => makeRun(ctx, { wire: created })));
|
|
95
|
+
export const startHarness = (ctx, init, prompt, options) => ctx.runtime.run(Effect.map(createHarnessRunEffect(ctx, init, prompt, options), (created) => makeRun(ctx, { wire: created })), undefined, options?.signal);
|
package/dist/effect/runtime.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* client, the events channel and the services, over a fetch `HttpClient` (the configured `fetch`,
|
|
6
6
|
* else the global one) and the global `WebSocket`. Every facade call runs one effect on it and
|
|
7
7
|
* surfaces a plain `SealantError` (the typed failure is squashed and mapped here). A call given an
|
|
8
|
-
* `AbortSignal` is interrupted when it aborts. `dispose()`
|
|
9
|
-
* then releases the layer.
|
|
8
|
+
* `AbortSignal` is interrupted when it aborts and rejects with the signal's reason. `dispose()`
|
|
9
|
+
* interrupts every call still running, then releases the layer.
|
|
10
10
|
*/
|
|
11
11
|
import { type Context, type Effect, Layer, Stream } from "effect";
|
|
12
12
|
import type { Socket } from "effect/socket";
|
|
@@ -25,7 +25,8 @@ export interface SdkRuntime {
|
|
|
25
25
|
/**
|
|
26
26
|
* Provide the app context and run an operation effect, surfacing plain `SealantError`s. The
|
|
27
27
|
* effect continues `trace` when given, else the caller's trace captured when `run` is called
|
|
28
|
-
* (see `captureCallerTrace`), and is interrupted when `signal` aborts
|
|
28
|
+
* (see `captureCallerTrace`), and is interrupted when `signal` aborts, rejecting with
|
|
29
|
+
* `signal.reason`.
|
|
29
30
|
*/
|
|
30
31
|
readonly run: <A, E>(effect: Effect.Effect<A, E, SdkServices>, trace?: CallerTrace, signal?: AbortSignal) => Promise<A>;
|
|
31
32
|
/**
|
package/dist/effect/runtime.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* client, the events channel and the services, over a fetch `HttpClient` (the configured `fetch`,
|
|
6
6
|
* else the global one) and the global `WebSocket`. Every facade call runs one effect on it and
|
|
7
7
|
* surfaces a plain `SealantError` (the typed failure is squashed and mapped here). A call given an
|
|
8
|
-
* `AbortSignal` is interrupted when it aborts. `dispose()`
|
|
9
|
-
* then releases the layer.
|
|
8
|
+
* `AbortSignal` is interrupted when it aborts and rejects with the signal's reason. `dispose()`
|
|
9
|
+
* interrupts every call still running, then releases the layer.
|
|
10
10
|
*/
|
|
11
11
|
import { Cause, Exit, Layer, ManagedRuntime, Stream } from "effect";
|
|
12
12
|
import { toSealantError } from "../internal/map-error.js";
|
|
@@ -44,6 +44,10 @@ export const makeSdkRuntime = (config) => {
|
|
|
44
44
|
const exit = await runtime.runPromiseExit(effect.pipe(continueCallerTrace(trace)), signal === undefined ? undefined : { signal });
|
|
45
45
|
if (Exit.isSuccess(exit))
|
|
46
46
|
return exit.value;
|
|
47
|
+
// Interrupted because the caller aborted: reject with the signal's reason, as `fetch` does,
|
|
48
|
+
// so `error.name === "AbortError"` (or the caller's own reason) tells it apart from a failure.
|
|
49
|
+
if (signal?.aborted === true && Cause.hasInterruptsOnly(exit.cause))
|
|
50
|
+
throw signal.reason;
|
|
47
51
|
// Squash the Cause to its underlying failure/defect value, then map to a plain error.
|
|
48
52
|
throw toSealantError(Cause.squash(exit.cause));
|
|
49
53
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -2003,9 +2003,20 @@ export interface BoundedWorkspaceForward {
|
|
|
2003
2003
|
close(): void;
|
|
2004
2004
|
}
|
|
2005
2005
|
export interface RunOptions {
|
|
2006
|
-
/**
|
|
2006
|
+
/**
|
|
2007
|
+
* Stops the call. Aborting before `run()` or `start()` resolves cancels its requests and the
|
|
2008
|
+
* wait, and the call rejects with `signal.reason` (an `AbortError` unless you abort with your
|
|
2009
|
+
* own reason). It does not cancel a run the control plane has already accepted: that run goes
|
|
2010
|
+
* on. Pass an `idempotencyKey` too, and calling again with the same key answers that run
|
|
2011
|
+
* instead of starting another. Once `start()` has resolved, the signal is no longer watched.
|
|
2012
|
+
*/
|
|
2007
2013
|
readonly signal?: AbortSignal;
|
|
2008
|
-
/**
|
|
2014
|
+
/**
|
|
2015
|
+
* Your key for this run, unique per run you mean to start. A call that repeats a key of the
|
|
2016
|
+
* same owner answers the run the first call started, as it is now, instead of starting another,
|
|
2017
|
+
* and a create lost to a dropped connection is retried safely. A key is never reused for a run
|
|
2018
|
+
* in another workspace: that call rejects.
|
|
2019
|
+
*/
|
|
2009
2020
|
readonly idempotencyKey?: string;
|
|
2010
2021
|
/**
|
|
2011
2022
|
* Opaque correlation bag ({ projectId, sessionId, ... }): stored verbatim by the platform and
|
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.978",
|
|
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.978"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"effect": "^4.0.5"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "b9433c317787909c22b74e6cb6cab08c41183504",
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
}
|