@skein-js/core 0.4.0 → 0.5.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.
Files changed (2) hide show
  1. package/dist/index.d.ts +72 -58
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -7,6 +7,66 @@ type Run = Omit<Run$1, "status"> & {
7
7
  };
8
8
  type MultitaskStrategy = NonNullable<Run$1["multitask_strategy"]>;
9
9
 
10
+ /**
11
+ * The authenticated caller, normalized to the shape LangGraph's `Auth` produces: a required
12
+ * `identity`, `display_name`, `is_authenticated`, and `permissions` scopes, plus open extra keys a
13
+ * handler may attach (e.g. `email`, `org_id`). Structurally identical to the SDK's internal
14
+ * `BaseUser`, so a graph written for LangGraph Platform reads the same `langgraph_auth_user`.
15
+ */
16
+ interface AuthUser {
17
+ identity: string;
18
+ display_name: string;
19
+ is_authenticated: boolean;
20
+ permissions: string[];
21
+ [key: string]: unknown;
22
+ }
23
+ /** The result of authenticating a request: the caller plus their permission scopes. */
24
+ interface AuthContext {
25
+ user: AuthUser;
26
+ scopes: string[];
27
+ }
28
+ /** A protocol resource an `@auth.on.*` handler can guard. Runs authorize through their thread. */
29
+ type AuthResource = "threads" | "assistants" | "store";
30
+ /** An action on a resource, mirroring LangGraph's `resource:action` event names. */
31
+ type AuthAction = "create" | "read" | "update" | "delete" | "search" | "create_run" | "put" | "get" | "list_namespaces";
32
+ /** A single metadata filter clause — an exact value or an `$eq`/`$contains` operator object. */
33
+ type AuthFilterValue = string | {
34
+ $eq?: string;
35
+ $contains?: string | string[];
36
+ };
37
+ /**
38
+ * Ownership filters returned by an `@auth.on.*` handler. Keys are metadata fields; a returned filter
39
+ * both scopes reads (a resource is visible only if its metadata satisfies every clause) and stamps
40
+ * writes (the clause values are merged into new resources' metadata). Shape-compatible with
41
+ * `@langchain/langgraph-api`'s `isAuthMatching`.
42
+ */
43
+ type AuthFilters = Record<string, AuthFilterValue>;
44
+ /**
45
+ * The injectable auth engine — one per runtime, no module-global state (unlike langgraph-api's
46
+ * `registerAuth`). Absent from `ProtocolDeps` means no auth is configured and every request is
47
+ * allowed (the default, so `skein dev` stays frictionless).
48
+ */
49
+ interface AuthEngine {
50
+ /** True when a `langgraph.json` `auth.path` was loaded; false disables the whole gate. */
51
+ readonly enabled: boolean;
52
+ /** When true, studio traffic must present real credentials like any other client. */
53
+ readonly studioAuthDisabled: boolean;
54
+ /** Run the user's authenticate handler over a request; throws 401 on rejection/missing identity. */
55
+ authenticate(request: Request): Promise<AuthContext | undefined>;
56
+ /** Consult the `@auth.on.*` handlers for a resource+action; throws 403 on deny, else returns filters. */
57
+ authorize(input: {
58
+ resource: AuthResource;
59
+ action: AuthAction;
60
+ value: unknown;
61
+ context: AuthContext | undefined;
62
+ }): Promise<{
63
+ filters?: AuthFilters;
64
+ value: unknown;
65
+ }>;
66
+ /** Whether a resource's metadata satisfies the ownership filters (`$eq`/`$contains` semantics). */
67
+ matchesFilters(metadata: Record<string, unknown> | undefined, filters?: AuthFilters): boolean;
68
+ }
69
+
10
70
  /** Fields accepted when registering an assistant (from a langgraph.json graph or the API). */
11
71
  interface AssistantCreate {
12
72
  graph_id: string;
@@ -96,6 +156,18 @@ interface RunKwargs {
96
156
  stream_mode?: StreamMode | StreamMode[];
97
157
  interrupt_before?: string[] | "*";
98
158
  interrupt_after?: string[] | "*";
159
+ /**
160
+ * The authenticated caller, stamped by the server (never accepted from the client). Persisted
161
+ * opaquely with the run so a background/crash-recovered run on another instance reconstructs the
162
+ * principal via `getKwargs` and injects it into the graph's `configurable.langgraph_auth_user`.
163
+ */
164
+ auth_user?: AuthUser;
165
+ /**
166
+ * The caller's authenticated permission scopes (the `AuthContext.scopes`), stamped alongside
167
+ * {@link auth_user}. Injected as `configurable.langgraph_auth_permissions`, matching LangGraph
168
+ * (which sources permissions from the auth scopes, not from the user object's `permissions`).
169
+ */
170
+ auth_scopes?: string[];
99
171
  }
100
172
  interface RunCreate {
101
173
  thread_id: string;
@@ -293,62 +365,4 @@ declare class SkeinHttpError extends Error {
293
365
  /** Narrow an unknown thrown value to a {@link SkeinHttpError}. */
294
366
  declare function isSkeinHttpError(value: unknown): value is SkeinHttpError;
295
367
 
296
- /**
297
- * The authenticated caller, normalized to the shape LangGraph produces: a required `identity`,
298
- * `permissions` scopes, and open extra keys a handler may attach (e.g. `email`, `org_id`).
299
- */
300
- interface AuthUser {
301
- identity: string;
302
- display_name: string;
303
- is_authenticated: boolean;
304
- permissions: string[];
305
- [key: string]: unknown;
306
- }
307
- /** The result of authenticating a request: the caller plus their permission scopes. */
308
- interface AuthContext {
309
- user: AuthUser;
310
- scopes: string[];
311
- }
312
- /** A protocol resource an `@auth.on.*` handler can guard. Runs authorize through their thread. */
313
- type AuthResource = "threads" | "assistants" | "store";
314
- /** An action on a resource, mirroring LangGraph's `resource:action` event names. */
315
- type AuthAction = "create" | "read" | "update" | "delete" | "search" | "create_run" | "put" | "get" | "list_namespaces";
316
- /** A single metadata filter clause — an exact value or an `$eq`/`$contains` operator object. */
317
- type AuthFilterValue = string | {
318
- $eq?: string;
319
- $contains?: string | string[];
320
- };
321
- /**
322
- * Ownership filters returned by an `@auth.on.*` handler. Keys are metadata fields; a returned filter
323
- * both scopes reads (a resource is visible only if its metadata satisfies every clause) and stamps
324
- * writes (the clause values are merged into new resources' metadata). Shape-compatible with
325
- * `@langchain/langgraph-api`'s `isAuthMatching`.
326
- */
327
- type AuthFilters = Record<string, AuthFilterValue>;
328
- /**
329
- * The injectable auth engine — one per runtime, no module-global state (unlike langgraph-api's
330
- * `registerAuth`). Absent from `ProtocolDeps` means no auth is configured and every request is
331
- * allowed (the default, so `skein dev` stays frictionless).
332
- */
333
- interface AuthEngine {
334
- /** True when a `langgraph.json` `auth.path` was loaded; false disables the whole gate. */
335
- readonly enabled: boolean;
336
- /** When true, studio traffic must present real credentials like any other client. */
337
- readonly studioAuthDisabled: boolean;
338
- /** Run the user's authenticate handler over a request; throws 401 on rejection/missing identity. */
339
- authenticate(request: Request): Promise<AuthContext | undefined>;
340
- /** Consult the `@auth.on.*` handlers for a resource+action; throws 403 on deny, else returns filters. */
341
- authorize(input: {
342
- resource: AuthResource;
343
- action: AuthAction;
344
- value: unknown;
345
- context: AuthContext | undefined;
346
- }): Promise<{
347
- filters?: AuthFilters;
348
- value: unknown;
349
- }>;
350
- /** Whether a resource's metadata satisfies the ownership filters (`$eq`/`$contains` semantics). */
351
- matchesFilters(metadata: Record<string, unknown> | undefined, filters?: AuthFilters): boolean;
352
- }
353
-
354
368
  export { type AssistantCreate, type AssistantRepo, type AuthAction, type AuthContext, type AuthEngine, type AuthFilterValue, type AuthFilters, type AuthResource, type AuthUser, type MultitaskStrategy, type QueuedRun, type Run, type RunConsumer, type RunConsumerOptions, type RunCreate, type RunEventBus, type RunFrame, type RunKwargs, type RunProcessor, type RunQueue, type RunRepo, type RunStatus, SkeinHttpError, type SkeinHttpErrorOptions, type SkeinStore, type SkeinStoreSnapshot, type StorePutOptions, type StoreRepo, type StoreSearchQuery, type StoreTtlConfig, TERMINAL_RUN_STATUSES, type ThreadCreate, type ThreadRepo, type ThreadSearchQuery, type ThreadUpdate, isMetadataSubset, isSkeinHttpError, isTerminalRunStatus, serializeWireJson };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skein-js/core",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Framework-agnostic Agent Protocol engine for LangGraph.js — the heart of skein-js.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Maina Wycliffe <wmmaina7@gmail.com>",