@sealant/sdk 0.5.2 → 0.7.1

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/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CreateOptions, InferenceNamespace, ListOptions, Run, Workspace, SealantConfig } from "./types.js";
1
+ import type { AccessTokensNamespace, CreateOptions, InferenceNamespace, ListOptions, Run, Workspace, SealantConfig } from "./types.js";
2
2
  export declare class Sealant {
3
3
  #private;
4
4
  constructor(config: SealantConfig);
@@ -15,6 +15,13 @@ export declare class Sealant {
15
15
  * calls. Tool calls park server-side; execute them here and `respond()` with the results.
16
16
  */
17
17
  readonly inference: InferenceNamespace;
18
+ /**
19
+ * Scoped bearer tokens for the session surface — `session:read` / `session:input` /
20
+ * `workspace:exec`. The returned secret is shown once; hand it to a client as its `apiKey` and
21
+ * the session endpoints enforce exactly those scopes (a read-stream token can stream but is
22
+ * rejected for input and exec).
23
+ */
24
+ readonly accessTokens: AccessTokensNamespace;
18
25
  /** Runs by id — so a record can be replayed long after its workspace is gone. */
19
26
  readonly runs: {
20
27
  get: (runId: string) => Promise<Run>;
package/dist/client.js CHANGED
@@ -10,7 +10,7 @@
10
10
  * stable surface and reject with `SealantNotImplementedError` so callers can compile and wire
11
11
  * against the final shape today.
12
12
  */
13
- import { createWorkspaceOp, getRunOp, getWorkspaceOp, inferenceRespondOp, listWorkspacesOp, } from "./effect/operations.js";
13
+ import { createAccessTokenOp, createWorkspaceOp, getRunOp, getWorkspaceOp, inferenceRespondOp, listWorkspacesOp, } from "./effect/operations.js";
14
14
  import { runHarness, startHarness } from "./effect/run-harness.js";
15
15
  import { makeSdkRuntime } from "./effect/runtime.js";
16
16
  import { SealantError } from "./errors.js";
@@ -18,6 +18,7 @@ import { makeRun } from "./facade/run.js";
18
18
  import { makeWorkspace, registerHarnessExecutors } from "./facade/workspace.js";
19
19
  import { buildCreateWorkspaceRequest } from "./internal/blueprint.js";
20
20
  import { resolveInternalConfig } from "./internal/config.js";
21
+ import { parseTtlSeconds } from "./internal/duration.js";
21
22
  import { buildInferenceRespondRequest, mapInferenceResponse } from "./internal/inference.js";
22
23
  // Wire the run-execution implementations into the Workspace facade (the injection point exists to
23
24
  // break the workspace <-> run-harness import cycle; the client is the composition root).
@@ -102,6 +103,30 @@ export class Sealant {
102
103
  return mapInferenceResponse(wire);
103
104
  },
104
105
  };
106
+ /**
107
+ * Scoped bearer tokens for the session surface — `session:read` / `session:input` /
108
+ * `workspace:exec`. The returned secret is shown once; hand it to a client as its `apiKey` and
109
+ * the session endpoints enforce exactly those scopes (a read-stream token can stream but is
110
+ * rejected for input and exec).
111
+ */
112
+ accessTokens = {
113
+ create: async (options) => {
114
+ const wire = await this.#runtime.run(createAccessTokenOp({
115
+ ownerUserId: this.#ctx.config.hostLocal.ownerUserId,
116
+ scopes: [...options.scopes],
117
+ ...(options.name === undefined ? {} : { name: options.name }),
118
+ ...(options.workspaceId === undefined ? {} : { workspaceId: options.workspaceId }),
119
+ ...(options.ttl === undefined ? {} : { ttlSeconds: parseTtlSeconds(options.ttl) }),
120
+ }));
121
+ return {
122
+ tokenId: wire.tokenId,
123
+ token: wire.token,
124
+ scopes: [...wire.scopes],
125
+ ...(wire.workspaceId === undefined ? {} : { workspaceId: wire.workspaceId }),
126
+ ...(wire.expiresAt === undefined ? {} : { expiresAt: wire.expiresAt }),
127
+ };
128
+ },
129
+ };
105
130
  /** Runs by id — so a record can be replayed long after its workspace is gone. */
106
131
  runs = {
107
132
  get: async (runId) => {