@feltdb/feltkit 0.3.36 → 0.4.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.
- package/dist/app.d.ts +153 -3
- package/dist/app.js +159 -7
- package/dist/app.js.map +1 -1
- package/dist/appboundry/build.js +21 -0
- package/dist/appboundry/build.js.map +1 -1
- package/dist/appboundry/guest.js +4 -0
- package/dist/appboundry/guest.js.map +1 -1
- package/dist/client/index.d.ts +189 -0
- package/dist/client/index.js +201 -0
- package/dist/client/index.js.map +1 -1
- package/dist/clock.d.ts +24 -0
- package/dist/clock.js +49 -0
- package/dist/clock.js.map +1 -0
- package/dist/dashboard/assets/index-BhxrvY37.js +15 -0
- package/dist/dashboard/assets/index-CSzYeCo_.css +1 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +1 -0
- package/dist/docs.js.map +1 -1
- package/dist/event-stage.js +2 -0
- package/dist/event-stage.js.map +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/policy.d.ts +9 -1
- package/dist/policy.js +16 -3
- package/dist/policy.js.map +1 -1
- package/dist/presence.d.ts +85 -0
- package/dist/presence.js +37 -0
- package/dist/presence.js.map +1 -0
- package/dist/quota.d.ts +72 -0
- package/dist/quota.js +143 -0
- package/dist/quota.js.map +1 -0
- package/dist/react/agent-control.d.ts +189 -0
- package/dist/react/agent-control.js +366 -0
- package/dist/react/agent-control.js.map +1 -0
- package/dist/react/index.d.ts +14 -1
- package/dist/react/index.js +41 -0
- package/dist/react/index.js.map +1 -1
- package/dist/runtime/activity.d.ts +8 -0
- package/dist/runtime/activity.js.map +1 -1
- package/dist/runtime/agent-control.d.ts +18 -0
- package/dist/runtime/agent-control.js +34 -1
- package/dist/runtime/agent-control.js.map +1 -1
- package/dist/runtime/agent.js +16 -4
- package/dist/runtime/agent.js.map +1 -1
- package/dist/runtime/assemble.js +1 -1
- package/dist/runtime/assemble.js.map +1 -1
- package/dist/runtime/authority.d.ts +38 -0
- package/dist/runtime/authority.js +13 -2
- package/dist/runtime/authority.js.map +1 -1
- package/dist/runtime/capabilities.js +2 -1
- package/dist/runtime/capabilities.js.map +1 -1
- package/dist/runtime/changes.d.ts +17 -0
- package/dist/runtime/changes.js +65 -2
- package/dist/runtime/changes.js.map +1 -1
- package/dist/runtime/context.d.ts +114 -0
- package/dist/runtime/contract.js +9 -3
- package/dist/runtime/contract.js.map +1 -1
- package/dist/runtime/events.js +17 -1
- package/dist/runtime/events.js.map +1 -1
- package/dist/runtime/integrations.js +7 -7
- package/dist/runtime/integrations.js.map +1 -1
- package/dist/runtime/invocations.d.ts +19 -2
- package/dist/runtime/invocations.js +16 -3
- package/dist/runtime/invocations.js.map +1 -1
- package/dist/runtime/policies.d.ts +5 -2
- package/dist/runtime/policies.js.map +1 -1
- package/dist/runtime/presence-host.d.ts +84 -0
- package/dist/runtime/presence-host.js +303 -0
- package/dist/runtime/presence-host.js.map +1 -0
- package/dist/runtime/providers.d.ts +130 -1
- package/dist/runtime/providers.js +251 -9
- package/dist/runtime/providers.js.map +1 -1
- package/dist/runtime/resource-access.d.ts +137 -0
- package/dist/runtime/resource-access.js +177 -0
- package/dist/runtime/resource-access.js.map +1 -0
- package/dist/runtime/runtime.d.ts +73 -0
- package/dist/runtime/runtime.js +594 -37
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/sessions.d.ts +11 -0
- package/dist/runtime/sessions.js +15 -0
- package/dist/runtime/sessions.js.map +1 -1
- package/dist/runtime/tenancy.d.ts +59 -0
- package/dist/runtime/tenancy.js +128 -0
- package/dist/runtime/tenancy.js.map +1 -1
- package/dist/runtime/workers.d.ts +123 -0
- package/dist/runtime/workers.js +291 -0
- package/dist/runtime/workers.js.map +1 -0
- package/dist/server/admin.js +48 -1
- package/dist/server/admin.js.map +1 -1
- package/dist/server/index.d.ts +0 -19
- package/dist/server/index.js +61 -4
- package/dist/server/index.js.map +1 -1
- package/dist/server/mcp.d.ts +8 -15
- package/dist/server/mcp.js +40 -3
- package/dist/server/mcp.js.map +1 -1
- package/dist/server/project.js +6 -5
- package/dist/server/project.js.map +1 -1
- package/dist/server/tenancy.d.ts +7 -0
- package/dist/server/tenancy.js +31 -0
- package/dist/server/tenancy.js.map +1 -1
- package/dist/server/watch.d.ts +10 -0
- package/dist/server/watch.js +88 -0
- package/dist/server/watch.js.map +1 -0
- package/dist/testing/index.d.ts +3 -1
- package/dist/testing/index.js +3 -2
- package/dist/testing/index.js.map +1 -1
- package/docs/AGENT-CONTROL.md +130 -4
- package/docs/APPBOUNDRY.md +37 -0
- package/docs/ARCHITECTURE.md +6 -2
- package/docs/AUTH.md +35 -0
- package/docs/COMPONENTS.md +71 -0
- package/docs/GUARANTEES.md +4 -4
- package/docs/PRESENCE-AND-SIGNALING-PROPOSAL.md +152 -0
- package/docs/PROVIDERS.md +58 -1
- package/docs/README.md +3 -2
- package/docs/SECURITY.md +71 -3
- package/docs/TRANSACTIONS.md +48 -0
- package/docs/UPSTREAM-GAPS.md +16 -2
- package/package.json +16 -16
- package/skills/.claude-plugin/marketplace.json +1 -1
- package/skills/.claude-plugin/plugin.json +1 -1
- package/skills/feltkit-agent/SKILL.md +1 -1
- package/skills/feltkit-build/SKILL.md +11 -1
- package/skills/feltkit-data/SKILL.md +1 -1
- package/skills/feltkit-operations/SKILL.md +1 -1
- package/skills/feltkit-services/SKILL.md +1 -1
- package/dist/dashboard/assets/index-9rMS3yBm.js +0 -15
- package/dist/dashboard/assets/index-DkiYTUMR.css +0 -1
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Access to one resource for someone who is not otherwise allowed it (K4, K6):
|
|
3
|
+
*
|
|
4
|
+
* guest link a person without an account, admitted by a link a host issued for one record (a
|
|
5
|
+
* meeting), with a display name, one restricted role (from `auth.guests.roles`) and an
|
|
6
|
+
* expiry. `POST /api/auth/guest { token, displayName }` gives a guest session.
|
|
7
|
+
* agent grant a named agent (or service) principal, admitted by a host to one record. A function that
|
|
8
|
+
* declares `resource: { …, agents: "grant" }` refuses every non-person caller without a live
|
|
9
|
+
* grant for that record.
|
|
10
|
+
*
|
|
11
|
+
* Both are records in `_feltkit_resource_access`, revocable at once: a guest session and a grant are
|
|
12
|
+
* resolved from their record on every call, never trusted as copied. Only a link token's SHA-256 is stored
|
|
13
|
+
* (`_feltkit_resource_access_digests` maps it to the link).
|
|
14
|
+
*
|
|
15
|
+
* The binding is declared on the function (`resource: { collection, id, by?, guests?, agents? }`), checked at
|
|
16
|
+
* the execution boundary every interface goes through, before the policies and the authorize hook, and
|
|
17
|
+
* every refusal is durable decision evidence (layer "resource").
|
|
18
|
+
*/
|
|
19
|
+
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
20
|
+
import { FeltKitError } from "../errors.js";
|
|
21
|
+
import { readAll } from "./data.js";
|
|
22
|
+
export const RESOURCE_ACCESS_COLLECTION = "_feltkit_resource_access";
|
|
23
|
+
export const RESOURCE_ACCESS_DIGESTS = "_feltkit_resource_access_digests";
|
|
24
|
+
export const GUEST_TOKEN_PREFIX = "fkg_";
|
|
25
|
+
/** A guest session lasts at most this long (and never past its link). */
|
|
26
|
+
export const GUEST_SESSION_MAX_MS = 12 * 60 * 60 * 1000;
|
|
27
|
+
export const MAX_ACCESS_TTL_MS = 30 * 24 * 60 * 60 * 1000;
|
|
28
|
+
const digest = (token) => createHash("sha256").update(token).digest("hex");
|
|
29
|
+
const iso = (ms) => new Date(ms).toISOString();
|
|
30
|
+
export class ResourceAccessStore {
|
|
31
|
+
#db;
|
|
32
|
+
#clock;
|
|
33
|
+
constructor(db, clock) {
|
|
34
|
+
this.#db = db;
|
|
35
|
+
this.#clock = clock;
|
|
36
|
+
}
|
|
37
|
+
#state(record) {
|
|
38
|
+
if (record.revokedAt !== undefined)
|
|
39
|
+
return "revoked";
|
|
40
|
+
return record.expiresAt <= this.#clock.now() ? "expired" : "active";
|
|
41
|
+
}
|
|
42
|
+
async get(id) {
|
|
43
|
+
if (typeof id !== "string" || !id)
|
|
44
|
+
return null;
|
|
45
|
+
return (await this.#db().collection(RESOURCE_ACCESS_COLLECTION).get(id)) ?? null;
|
|
46
|
+
}
|
|
47
|
+
async #insert(record, token) {
|
|
48
|
+
await this.#db().transaction({
|
|
49
|
+
operations: [
|
|
50
|
+
{ collection: RESOURCE_ACCESS_COLLECTION, id: record.id, requireAbsent: true, value: record },
|
|
51
|
+
...(token ? [{ collection: RESOURCE_ACCESS_DIGESTS, id: digest(token), requireAbsent: true, value: { accessId: record.id } }] : []),
|
|
52
|
+
],
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/** Issue a guest link. Returns the token once; only its digest is stored. */
|
|
56
|
+
async issueGuestLink(input) {
|
|
57
|
+
const now = this.#clock.now();
|
|
58
|
+
const token = `${GUEST_TOKEN_PREFIX}${randomBytes(32).toString("base64url")}`;
|
|
59
|
+
const record = {
|
|
60
|
+
id: `gl_${randomUUID().replace(/-/g, "")}`,
|
|
61
|
+
kind: "guest-link",
|
|
62
|
+
resource: { ...input.resource },
|
|
63
|
+
role: input.role,
|
|
64
|
+
...(input.label ? { label: input.label.slice(0, 120) } : {}),
|
|
65
|
+
createdBy: `${input.by.type}:${input.by.id}`,
|
|
66
|
+
createdAt: now,
|
|
67
|
+
expiresAt: now + input.ttlMs,
|
|
68
|
+
...(input.by.tenant ? { tenantId: input.by.tenant.id } : {}),
|
|
69
|
+
};
|
|
70
|
+
await this.#insert(record, token);
|
|
71
|
+
return { link: this.guestView(record), token };
|
|
72
|
+
}
|
|
73
|
+
/** Admit a named agent (or service) to one resource. */
|
|
74
|
+
async grantAgent(input) {
|
|
75
|
+
const now = this.#clock.now();
|
|
76
|
+
const record = {
|
|
77
|
+
id: `ag_${randomUUID().replace(/-/g, "")}`,
|
|
78
|
+
kind: "agent-grant",
|
|
79
|
+
resource: { ...input.resource },
|
|
80
|
+
principalId: input.agent,
|
|
81
|
+
...(input.label ? { label: input.label.slice(0, 120) } : {}),
|
|
82
|
+
createdBy: `${input.by.type}:${input.by.id}`,
|
|
83
|
+
createdAt: now,
|
|
84
|
+
expiresAt: now + input.ttlMs,
|
|
85
|
+
...(input.by.tenant ? { tenantId: input.by.tenant.id } : {}),
|
|
86
|
+
};
|
|
87
|
+
await this.#insert(record);
|
|
88
|
+
return this.grantView(record);
|
|
89
|
+
}
|
|
90
|
+
/** Revoke a link or grant for `resource` (the issuer's function decided who may). Idempotent. */
|
|
91
|
+
async revoke(id, resource, by) {
|
|
92
|
+
const record = await this.get(id);
|
|
93
|
+
if (!record || record.resource.collection !== resource.collection || record.resource.id !== resource.id)
|
|
94
|
+
throw new FeltKitError("NOT_FOUND", `No guest link or agent grant ${id} for this ${resource.collection}.`);
|
|
95
|
+
if (record.revokedAt !== undefined)
|
|
96
|
+
return false;
|
|
97
|
+
const { __version, ...rest } = record;
|
|
98
|
+
await this.#db().transaction({ operations: [{ collection: RESOURCE_ACCESS_COLLECTION, id, ifVersion: __version, value: { ...rest, revokedAt: this.#clock.now(), revokedBy: `${by.type}:${by.id}` } }] });
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
/** The links and grants of one resource. */
|
|
102
|
+
async list(resource) {
|
|
103
|
+
const all = (await readAll(this.#db(), { collection: RESOURCE_ACCESS_COLLECTION })).filter((r) => r.resource?.collection === resource.collection && r.resource?.id === resource.id);
|
|
104
|
+
return {
|
|
105
|
+
guestLinks: all.filter((r) => r.kind === "guest-link").map((r) => this.guestView(r)),
|
|
106
|
+
agentGrants: all.filter((r) => r.kind === "agent-grant").map((r) => this.grantView(r)),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/** The live guest link a token names, or null (unknown, revoked, expired). */
|
|
110
|
+
async guestLinkFor(token) {
|
|
111
|
+
if (typeof token !== "string" || !token.startsWith(GUEST_TOKEN_PREFIX) || token.length > 128)
|
|
112
|
+
return null;
|
|
113
|
+
const index = (await this.#db().collection(RESOURCE_ACCESS_DIGESTS).get(digest(token)));
|
|
114
|
+
const record = index ? await this.get(index.accessId) : null;
|
|
115
|
+
return record && record.kind === "guest-link" && this.#state(record) === "active" ? record : null;
|
|
116
|
+
}
|
|
117
|
+
/** A live guest link by id (a guest session's link, on every request). */
|
|
118
|
+
async liveGuestLink(id) {
|
|
119
|
+
const record = await this.get(id);
|
|
120
|
+
return record && record.kind === "guest-link" && this.#state(record) === "active" ? record : null;
|
|
121
|
+
}
|
|
122
|
+
/** Whether `principalId` holds a live grant for `resource`. */
|
|
123
|
+
async granted(principalId, resource) {
|
|
124
|
+
const all = (await readAll(this.#db(), { collection: RESOURCE_ACCESS_COLLECTION, where: [{ field: "principalId", eq: principalId }] }));
|
|
125
|
+
return all.find((r) => r.kind === "agent-grant" && r.resource.collection === resource.collection && r.resource.id === resource.id && this.#state(r) === "active") ?? null;
|
|
126
|
+
}
|
|
127
|
+
guestView(r) {
|
|
128
|
+
return { id: r.id, resource: r.resource, role: r.role, ...(r.label ? { label: r.label } : {}), createdBy: r.createdBy, createdAt: iso(r.createdAt), expiresAt: iso(r.expiresAt), state: this.#state(r) };
|
|
129
|
+
}
|
|
130
|
+
grantView(r) {
|
|
131
|
+
return { id: r.id, resource: r.resource, agent: r.principalId, ...(r.label ? { label: r.label } : {}), createdBy: r.createdBy, createdAt: iso(r.createdAt), expiresAt: iso(r.expiresAt), state: this.#state(r) };
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The record a resource-bound call acts on, through the call's own reader (so a mutation's commit is fenced
|
|
136
|
+
* on it): by id, or by a unique field's value. Null when there is none (or, by value, not exactly one).
|
|
137
|
+
*/
|
|
138
|
+
export async function loadBoundResource(fn, args, db) {
|
|
139
|
+
const binding = fn.resource;
|
|
140
|
+
const value = args[binding.id];
|
|
141
|
+
if (binding.by === undefined)
|
|
142
|
+
return typeof value === "string" && value ? (await db.get(binding.collection, value)) : null;
|
|
143
|
+
if (value === undefined || value === null || typeof value === "object")
|
|
144
|
+
return null;
|
|
145
|
+
const found = (await db.find(binding.collection, { [binding.by]: value }, { limit: 2 }));
|
|
146
|
+
return found.length === 1 ? found[0] : null;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The resource gate for one call: guests reach only functions bound to their resource, and only it;
|
|
150
|
+
* a function with `agents: "grant"` admits a non-person caller only with a live grant for the record.
|
|
151
|
+
* Returns null (allowed, or nothing to decide) or the refusal's reason. Throws nothing.
|
|
152
|
+
*/
|
|
153
|
+
export async function resourceRefusal(fn, name, args, principal, db, grants) {
|
|
154
|
+
const binding = fn.resource;
|
|
155
|
+
const guest = principal?.guest;
|
|
156
|
+
if (guest) {
|
|
157
|
+
if (!binding || binding.guests !== true)
|
|
158
|
+
return { code: "FORBIDDEN", reason: `${name} is not open to guests.` };
|
|
159
|
+
if (binding.collection.name !== guest.resource.collection)
|
|
160
|
+
return { code: "FORBIDDEN", reason: `A guest of ${guest.resource.collection} ${guest.resource.id} cannot reach ${binding.collection.name}.` };
|
|
161
|
+
const record = await loadBoundResource(fn, args, db);
|
|
162
|
+
// Another record, or none: the guest learns nothing about which.
|
|
163
|
+
if (!record || record.id !== guest.resource.id)
|
|
164
|
+
return { code: "NOT_FOUND", reason: `${name}: a guest reaches only the ${binding.collection.name} they were invited to.`, resource: guest.resource };
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
if (binding?.agents === "grant" && principal && principal.type !== "user") {
|
|
168
|
+
const record = await loadBoundResource(fn, args, db);
|
|
169
|
+
if (!record)
|
|
170
|
+
return { code: "NOT_FOUND", reason: `${name}: no such ${binding.collection.name}.` };
|
|
171
|
+
const resource = { collection: binding.collection.name, id: String(record.id) };
|
|
172
|
+
if (!(await grants.granted(principal.id, resource)))
|
|
173
|
+
return { code: "FORBIDDEN", reason: `${principal.id} has no grant for ${resource.collection} ${resource.id}: a host must admit this agent to it.`, resource };
|
|
174
|
+
}
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
//# sourceMapping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AAC,EAAE,qBAAqB,QAAQ,CAAC,UAAU,IAAI,QAAQ,CAAC,EAAE,uCAAuC,EAAE,QAAQ,EAAE,CAAC;IACrN,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { type PolicyDecision } from "../policy.js";
|
|
2
2
|
import { PolicyStore } from "./policies.js";
|
|
3
|
+
import { type Clock } from "../clock.js";
|
|
4
|
+
import { PresenceHost } from "./presence-host.js";
|
|
5
|
+
import { ResourceAccessStore } from "./resource-access.js";
|
|
6
|
+
import { QuotaLimiter } from "../quota.js";
|
|
3
7
|
import { type Authorizer } from "@appport/sdk";
|
|
8
|
+
import type { InvocationContext } from "@appport/protocol";
|
|
9
|
+
import { WorkerAuthority } from "./workers.js";
|
|
4
10
|
import type { AppPortApplication } from "@appport/sdk";
|
|
5
11
|
import { type AgentDefinition, type FeltKitApp, type FunctionDefinition, type PrincipalInput } from "../app.js";
|
|
6
12
|
import { IntegrationHost } from "./integrations.js";
|
|
@@ -24,6 +30,7 @@ import { LocalAuthorityHost } from "./local-authority.js";
|
|
|
24
30
|
import { type Delegation } from "./delegation.js";
|
|
25
31
|
import { type HostCredentials } from "./credentials.js";
|
|
26
32
|
import { AgentHost, type AgentHooks } from "./agent.js";
|
|
33
|
+
import type { AgentChangeKind } from "./agent-control.js";
|
|
27
34
|
import { FeltDbIdempotencyStore } from "./idempotency.js";
|
|
28
35
|
import { FeltDbSessionStore } from "./sessions.js";
|
|
29
36
|
import { type AuditRecord } from "./audit.js";
|
|
@@ -85,6 +92,8 @@ export interface CallOptions {
|
|
|
85
92
|
delegation?: Delegation;
|
|
86
93
|
/** Actions: aborted when the caller cancels (closes the stream). */
|
|
87
94
|
signal?: AbortSignal;
|
|
95
|
+
/** The caller's idempotency key (AppPort), recorded with an action's external effect. */
|
|
96
|
+
idempotencyKey?: string;
|
|
88
97
|
/** Actions: the caller's stream, for `ctx.emit` and model deltas. */
|
|
89
98
|
emit?: (event: {
|
|
90
99
|
type: string;
|
|
@@ -93,6 +102,23 @@ export interface CallOptions {
|
|
|
93
102
|
session?: {
|
|
94
103
|
ref: string;
|
|
95
104
|
};
|
|
105
|
+
/** The client's address, when the surface knows it: anonymous callers' quotas count per address. */
|
|
106
|
+
client?: string;
|
|
107
|
+
/**
|
|
108
|
+
* The call's invocation context (AppPort §9.1.1): the caller's claims (HTTP `x-appport-*` headers, the AppPort
|
|
109
|
+
* envelope, MCP `_meta`), verified at the execution boundary against work grants and approvals. `verified` is set
|
|
110
|
+
* only by the runtime itself, for an internal call that carries its caller's already verified context.
|
|
111
|
+
*/
|
|
112
|
+
invocation?: {
|
|
113
|
+
claimed: InvocationContext;
|
|
114
|
+
verified?: InvocationContext;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* @internal Set only by the runtime for the application's own calls (an action's ctx.runQuery/runMutation, a job
|
|
118
|
+
* handler, an inbound webhook handler, auth.onSessionEnd, an integration's onOutcome): no surface can set it.
|
|
119
|
+
* Internal calls pass every `visibility`; `access` still applies.
|
|
120
|
+
*/
|
|
121
|
+
internal?: boolean;
|
|
96
122
|
}
|
|
97
123
|
export type CallResult = {
|
|
98
124
|
ok: true;
|
|
@@ -132,6 +158,11 @@ export interface RuntimeStartOptions {
|
|
|
132
158
|
* opening an environment to read or migrate it); the status is still reported.
|
|
133
159
|
*/
|
|
134
160
|
migrate?: "auto" | "manual" | "off";
|
|
161
|
+
/**
|
|
162
|
+
* The clock presence leases and quotas read (src/clock.ts). Default: the system clock. Tests pass
|
|
163
|
+
* `manualClock()` to drive expiry and quota windows deterministically.
|
|
164
|
+
*/
|
|
165
|
+
clock?: Clock;
|
|
135
166
|
}
|
|
136
167
|
/**
|
|
137
168
|
* The application's schema, as this runtime holds it.
|
|
@@ -214,6 +245,16 @@ export declare class FeltKitRuntime {
|
|
|
214
245
|
}>;
|
|
215
246
|
/** The settings this runtime reads (where the authority's address resolves, for one). */
|
|
216
247
|
get settings(): NodeJS.ProcessEnv;
|
|
248
|
+
/** The clock leases and quotas read (RuntimeStartOptions.clock). */
|
|
249
|
+
readonly clock: Clock;
|
|
250
|
+
/** Call quotas (src/quota.ts): in-process sliding windows. */
|
|
251
|
+
readonly quotas: QuotaLimiter;
|
|
252
|
+
/** Presence leases (app.presence): ctx.presence, the live view, expiry and session ends (runtime/presence-host.ts). */
|
|
253
|
+
readonly presence: PresenceHost;
|
|
254
|
+
/** Guest links and agent grants: access to one resource (runtime/resource-access.ts). */
|
|
255
|
+
readonly access: ResourceAccessStore;
|
|
256
|
+
/** Workers, their work grants, and people's approvals of exact calls (runtime/workers.ts). */
|
|
257
|
+
readonly workers: WorkerAuthority;
|
|
217
258
|
private constructor();
|
|
218
259
|
static start(options: RuntimeStartOptions): Promise<FeltKitRuntime>;
|
|
219
260
|
get state(): RuntimeState;
|
|
@@ -261,6 +302,23 @@ export declare class FeltKitRuntime {
|
|
|
261
302
|
get workerId(): string;
|
|
262
303
|
/** The access a function declares (`app.mutation({ access })`), or undefined when there is no such function. */
|
|
263
304
|
functionAccess(name: string): string | undefined;
|
|
305
|
+
/**
|
|
306
|
+
* The permissions a function requires (`access`), by the capability it publishes or, for one that publishes none (an
|
|
307
|
+
* internal job handler recording an effect), by its name; null when there is no such function.
|
|
308
|
+
*/
|
|
309
|
+
capabilityAccess(capability: string): readonly string[] | null;
|
|
310
|
+
/** The `sequence` of the last appport.agent.changed event for a task (0 before any), from its durable counter. */
|
|
311
|
+
agentChangeSequence(taskId: string): Promise<number>;
|
|
312
|
+
/**
|
|
313
|
+
* A task's control state changed durably (runtime/agent-control.ts): allocate the next per-task sequence (a durable
|
|
314
|
+
* counter, compare-and-set, so it survives restarts and never repeats) and publish appport.agent.changed@1 with the
|
|
315
|
+
* state as that change left it, scoped to the task. Emissions for one task are serialized in this process.
|
|
316
|
+
*/
|
|
317
|
+
agentChanged(taskId: string, changes: AgentChangeKind[], instructionId: string | undefined, state: {
|
|
318
|
+
revision: string;
|
|
319
|
+
phase: string;
|
|
320
|
+
mode: string;
|
|
321
|
+
}): Promise<void>;
|
|
264
322
|
/** Whether `principal` holds `access` under this application's roles ("public" and "authenticated" as functions treat them). */
|
|
265
323
|
holds(principal: Principal | null, access: string): boolean;
|
|
266
324
|
/**
|
|
@@ -435,6 +493,16 @@ export declare class FeltKitRuntime {
|
|
|
435
493
|
type: "agent" | "service";
|
|
436
494
|
displayName?: string;
|
|
437
495
|
} | null>;
|
|
496
|
+
/**
|
|
497
|
+
* Redeem a guest link (K4): a session for a guest with no account, holding the link's role, admitted to the
|
|
498
|
+
* link's one resource, lasting until the link expires (at most GUEST_SESSION_MAX_MS). The display name is the
|
|
499
|
+
* guest's own words, shown to others as such.
|
|
500
|
+
*/
|
|
501
|
+
redeemGuestLink(token: unknown, displayName: unknown): Promise<{
|
|
502
|
+
token: string;
|
|
503
|
+
principal: Principal;
|
|
504
|
+
expiresAt?: string;
|
|
505
|
+
}>;
|
|
438
506
|
/** Record an authentication event (sign-in failures, revocations, membership changes) in the activity log. */
|
|
439
507
|
recordAuth(name: string, principal: Principal | null, detail: Record<string, unknown>, outcome?: "success" | "denied" | "error", via?: ActivityVia): void;
|
|
440
508
|
/** Run a query or mutation as `principal`. Authority is checked before the handler runs. */
|
|
@@ -550,3 +618,8 @@ export interface InvitationMailInput {
|
|
|
550
618
|
inviter: string;
|
|
551
619
|
expiresInDays: number;
|
|
552
620
|
}
|
|
621
|
+
/** Why `principal` may not call a function of this visibility from a surface, or null (runtime/workers.ts). */
|
|
622
|
+
export declare function visibilityRefusalFor(name: string, visibility: NonNullable<FunctionDefinition["visibility"]>, principal: Principal | null): {
|
|
623
|
+
code: "FUNCTION_NOT_FOUND" | "FORBIDDEN" | "UNAUTHORIZED";
|
|
624
|
+
message: string;
|
|
625
|
+
} | null;
|