simetra 0.3.0-next.7 → 0.3.0-next.9

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.
@@ -154,6 +154,27 @@ interface ReconcileReport {
154
154
  /** Attach records of finished transactions removed from the database. */
155
155
  pendingSwept: number;
156
156
  }
157
+ /**
158
+ * Facts about the request origin that the host passes to the data handler.
159
+ * An HTTP call carries the `Sec-Fetch-Site` and `Origin` header values (absent
160
+ * header = absent field) and the origin the host serves from; a call inside
161
+ * the server process (SSR) is `{ inProcess: true }`.
162
+ */
163
+ type RequestOrigin = {
164
+ secFetchSite?: string;
165
+ origin?: string;
166
+ expectedOrigin: string;
167
+ } | {
168
+ inProcess: true;
169
+ };
170
+ /**
171
+ * Step 0 of the data handler: refuses a request that could be forged by
172
+ * another site. Runs before the envelope is parsed, so it touches nothing but
173
+ * the origin facts (and, for `inProcess`, the raw request type).
174
+ *
175
+ * @returns the refusal, or `undefined` when the request may proceed.
176
+ */
177
+ export declare function checkRequestOrigin(origin: RequestOrigin, rawRequest: unknown): CommandError | undefined;
157
178
  /**
158
179
  * One connection taken from a pool: bound text parameters only, unnamed
159
180
  * statements (P4 spec Рт19).
@@ -481,6 +502,50 @@ interface CommandRuntime {
481
502
  * Rejects with `command.nested` from inside a hook.
482
503
  */
483
504
  rebindFileStore(store: FileStore): Promise<void>;
505
+ /**
506
+ * Accepts an invitation by its secret (invitations spec §5) in a command
507
+ * transaction of its own. The origin is checked first: a foreign origin
508
+ * and `inProcess` alike are `command.forbidden` `reason: "origin"`, before
509
+ * the database. Rejects with `CommandFailure` before the database:
510
+ * `command.invalid` in a catalog without invitations, `command.forbidden`
511
+ * for a session without a user (invalid, no `sub`), an anonymous one or
512
+ * one with the `act` claim,
513
+ * `invitation.invalid` for a secret that is not 43 base64url characters.
514
+ * The database answer is committed whatever it is, then mapped: an unknown,
515
+ * expired, used or changed secret alike — `invitation.invalid`;
516
+ * `invitation.already-member`; `invitation.rate-limited`;
517
+ * `command.forbidden` when the database sees no actor.
518
+ */
519
+ acceptInvitation(session: SessionClaims, secret: string, origin: RequestOrigin): Promise<AcceptedInvitation>;
520
+ /**
521
+ * The scopes the session's user is a member of (invitations spec §7):
522
+ * `rights_my_scopes()` and the root row of each scope, read in one
523
+ * `REPEATABLE READ READ ONLY` transaction under the request role; a root
524
+ * the user cannot read is `null`. `inProcess` is allowed, as for reads. An
525
+ * anonymous session gets `[]` without a database call. Rejects with
526
+ * `CommandFailure`: `command.forbidden` `reason: "origin"`,
527
+ * `command.invalid` in a catalog without invitations,
528
+ * `command.unauthenticated` for an invalid session.
529
+ */
530
+ workspaces(session: SessionClaims, origin: RequestOrigin): Promise<Workspace[]>;
531
+ }
532
+ /** The membership an accepted invitation created. */
533
+ interface AcceptedInvitation {
534
+ /** The scope kind id. */
535
+ scopeKind: string;
536
+ scope: string;
537
+ /** The member row id. */
538
+ member: string;
539
+ }
540
+ /** One scope of {@link CommandRuntime.workspaces}. */
541
+ interface Workspace {
542
+ /** The scope kind id. */
543
+ scopeKind: string;
544
+ scope: string;
545
+ /** The user's member row id. */
546
+ member: string;
547
+ /** The root row of the scope by logical names; `null` — not readable. */
548
+ root: Record<string, unknown> | null;
484
549
  }
485
550
  /**
486
551
  * The request role of `purpose` the server reads under for a provider
@@ -506,27 +571,6 @@ export declare function sessionKind(provider: DatabaseProvider, claims: SessionC
506
571
  * catalog or module map throws before any database call.
507
572
  */
508
573
  export declare function createCommandRuntime(options: CommandRuntimeOptions): Promise<CommandRuntime>;
509
- /**
510
- * Facts about the request origin that the host passes to the data handler.
511
- * An HTTP call carries the `Sec-Fetch-Site` and `Origin` header values (absent
512
- * header = absent field) and the origin the host serves from; a call inside
513
- * the server process (SSR) is `{ inProcess: true }`.
514
- */
515
- type RequestOrigin = {
516
- secFetchSite?: string;
517
- origin?: string;
518
- expectedOrigin: string;
519
- } | {
520
- inProcess: true;
521
- };
522
- /**
523
- * Step 0 of the data handler: refuses a request that could be forged by
524
- * another site. Runs before the envelope is parsed, so it touches nothing but
525
- * the origin facts (and, for `inProcess`, the raw request type).
526
- *
527
- * @returns the refusal, or `undefined` when the request may proceed.
528
- */
529
- export declare function checkRequestOrigin(origin: RequestOrigin, rawRequest: unknown): CommandError | undefined;
530
574
  /**
531
575
  * Creates the data handler of the transport (P4-B spec §4.5): checks the
532
576
  * request origin, the envelope, the session and the compatibility with the
@@ -631,7 +675,7 @@ interface AgentCore {
631
675
  }
632
676
  export declare function createAgentCore(options: AgentCoreOptions): AgentCore;
633
677
  /** The closed set of codes an agent tool result may carry. */
634
- export declare const AGENT_ERROR_CODES: readonly ["command.forbidden", "command.conflict", "command.invalid", "command.constraint", "command.context", "command.unauthenticated", "command.rejected", "command.nested", "command.depth", "command.retry-exhausted", "command.model-mismatch", "command.read-role-missing", "command.privileged-login", "command.unavailable", "command.timeout", "command.busy", "command.stale-client", "command.internal", "catalog.invalid-input", "catalog.unknown-tool", "catalog.unknown-object", "catalog.rights-write-refused", "catalog.result-too-large"];
678
+ export declare const AGENT_ERROR_CODES: readonly ["command.forbidden", "command.conflict", "command.invalid", "command.constraint", "command.context", "command.unauthenticated", "command.rejected", "command.nested", "command.depth", "command.retry-exhausted", "command.model-mismatch", "command.read-role-missing", "command.privileged-login", "command.unavailable", "command.timeout", "command.busy", "command.stale-client", "command.internal", "invitation.invalid", "invitation.already-member", "invitation.rate-limited", "invitation.not-pending", "catalog.invalid-input", "catalog.unknown-tool", "catalog.unknown-object", "catalog.rights-write-refused", "catalog.result-too-large"];
635
679
  type AgentErrorCode = (typeof AGENT_ERROR_CODES)[number];
636
680
  /**
637
681
  * The next step for an agent: `retry` — the same call may work later;
@@ -719,9 +763,10 @@ export declare class AgentWriteRefused extends Error {
719
763
  * The rights-write guard: a pure function over the runtime catalog and a batch,
720
764
  * so an adapter can call it before opening a pool. It refuses when any
721
765
  * operation of the batch (not only the first) touches a rights system catalog
722
- * (its operations have the `administerRights` context) or creates a scope root
723
- * with a creator. An object outside the catalog is skipped: the runtime schema
724
- * rejects it. Without `rightsWrite` the refusal comes before the database.
766
+ * (its operations have the `administerRights` context), creates a scope root
767
+ * with a creator or issues an invitation. An object outside the catalog is
768
+ * skipped: the runtime schema rejects it. Without `rightsWrite` the refusal
769
+ * comes before the database.
725
770
  */
726
771
  export declare function agentWriteRefusal(catalog: RuntimeCatalog, batch: Batch, permissions: {
727
772
  rightsWrite: boolean;
@@ -744,4 +789,4 @@ interface AgentToolCatalog extends AgentCore {
744
789
  call(session: SessionClaims, name: string, input: unknown): Promise<AgentToolResult>;
745
790
  }
746
791
  export declare function createAgentToolCatalog(options: AgentToolCatalogOptions): AgentToolCatalog;
747
- export type { AgentAttributeDescription, AgentCore, AgentCoreOptions, AgentCorePermissions, AgentErrorCode, AgentMcpResult, AgentObjectDescription, AgentObjectSummary, AgentOutcome, AgentTool, AgentToolAnnotations, AgentToolCatalog, AgentToolCatalogOptions, AgentToolError, AgentToolResult, AgentToolState, AgentToolSuccess, AgentVerb, AttachFileInput, CheckUploadInput, CommandDatabase, CommandRunOptions, CommandRuntime, CommandRuntimeOptions, DatabaseClient, FileStore, LogEntry, PgPoolLike, ReadPartOutcome, ReadPartsOptions, ReadPartsResult, ReconcileLogEntry, ReconcileOptions, ReconcileRefusal, ReconcileReport, RequestOrigin, S3ClientLike, UploadLimits };
792
+ export type { AcceptedInvitation, AgentAttributeDescription, AgentCore, AgentCoreOptions, AgentCorePermissions, AgentErrorCode, AgentMcpResult, AgentObjectDescription, AgentObjectSummary, AgentOutcome, AgentTool, AgentToolAnnotations, AgentToolCatalog, AgentToolCatalogOptions, AgentToolError, AgentToolResult, AgentToolState, AgentToolSuccess, AgentVerb, AttachFileInput, CheckUploadInput, CommandDatabase, CommandRunOptions, CommandRuntime, CommandRuntimeOptions, DatabaseClient, FileStore, LogEntry, PgPoolLike, ReadPartOutcome, ReadPartsOptions, ReadPartsResult, ReconcileLogEntry, ReconcileOptions, ReconcileRefusal, ReconcileReport, RequestOrigin, S3ClientLike, UploadLimits, Workspace };