@feltdb/feltkit 0.3.37 → 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.
- package/dist/agent-engine.d.ts +93 -0
- package/dist/agent-engine.js +40 -0
- package/dist/agent-engine.js.map +1 -0
- package/dist/app.d.ts +306 -7
- package/dist/app.js +289 -28
- package/dist/app.js.map +1 -1
- package/dist/appboundry/build.d.ts +7 -0
- package/dist/appboundry/build.js +25 -1
- package/dist/appboundry/build.js.map +1 -1
- package/dist/appboundry/guest.js +8 -0
- package/dist/appboundry/guest.js.map +1 -1
- package/dist/appboundry/host.d.ts +21 -0
- package/dist/appboundry/host.js +25 -0
- package/dist/appboundry/host.js.map +1 -1
- package/dist/appboundry/runtime.js +1 -0
- package/dist/appboundry/runtime.js.map +1 -1
- package/dist/boards/index.d.ts +1258 -0
- package/dist/boards/index.js +1410 -0
- package/dist/boards/index.js.map +1 -0
- package/dist/boards/model.d.ts +177 -0
- package/dist/boards/model.js +177 -0
- package/dist/boards/model.js.map +1 -0
- package/dist/boards/react.d.ts +18 -0
- package/dist/boards/react.js +339 -0
- package/dist/boards/react.js.map +1 -0
- package/dist/cli/deploy-appboundry-self-hosted.js +2 -2
- package/dist/cli/deploy.js +19 -6
- package/dist/cli/deploy.js.map +1 -1
- package/dist/cli/main.js +70 -5
- package/dist/cli/main.js.map +1 -1
- package/dist/client/index.d.ts +454 -4
- package/dist/client/index.js +371 -3
- 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/cron.d.ts +18 -0
- package/dist/cron.js +67 -0
- package/dist/cron.js.map +1 -0
- package/dist/dashboard/assets/index-iIj7SL77.js +15 -0
- package/dist/dashboard/index.html +1 -1
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +4 -0
- package/dist/docs.js.map +1 -1
- package/dist/eve/index.d.ts +77 -0
- package/dist/eve/index.js +128 -0
- package/dist/eve/index.js.map +1 -0
- package/dist/event-stage.js +2 -0
- package/dist/event-stage.js.map +1 -1
- package/dist/index.d.ts +17 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/native/build.d.ts +112 -0
- package/dist/native/build.js +472 -0
- package/dist/native/build.js.map +1 -0
- package/dist/native/index.d.ts +67 -0
- package/dist/native/index.js +113 -0
- package/dist/native/index.js.map +1 -0
- package/dist/native/instance.d.ts +3 -0
- package/dist/native/instance.js +18 -0
- package/dist/native/instance.js.map +1 -0
- 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 +191 -0
- package/dist/react/agent-control.js +366 -0
- package/dist/react/agent-control.js.map +1 -0
- package/dist/react/auth.d.ts +15 -1
- package/dist/react/auth.js +28 -5
- package/dist/react/auth.js.map +1 -1
- package/dist/react/hooks.d.ts +88 -0
- package/dist/react/hooks.js +188 -0
- package/dist/react/hooks.js.map +1 -0
- package/dist/react/index.d.ts +5 -75
- package/dist/react/index.js +4 -145
- 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 +28 -0
- package/dist/runtime/agent-control.js +43 -2
- package/dist/runtime/agent-control.js.map +1 -1
- package/dist/runtime/agent-run.d.ts +166 -0
- package/dist/runtime/agent-run.js +431 -0
- package/dist/runtime/agent-run.js.map +1 -0
- package/dist/runtime/agent.d.ts +158 -1
- package/dist/runtime/agent.js +345 -12
- package/dist/runtime/agent.js.map +1 -1
- package/dist/runtime/assemble.js +15 -2
- package/dist/runtime/assemble.js.map +1 -1
- package/dist/runtime/authority.d.ts +47 -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 +123 -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 +5 -1
- package/dist/runtime/providers.js +11 -5
- package/dist/runtime/providers.js.map +1 -1
- package/dist/runtime/required-capabilities.d.ts +73 -0
- package/dist/runtime/required-capabilities.js +69 -0
- package/dist/runtime/required-capabilities.js.map +1 -0
- 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 +143 -1
- package/dist/runtime/runtime.js +853 -44
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/sessions.d.ts +12 -0
- package/dist/runtime/sessions.js +16 -1
- package/dist/runtime/sessions.js.map +1 -1
- package/dist/runtime/tenancy.d.ts +68 -1
- package/dist/runtime/tenancy.js +150 -0
- package/dist/runtime/tenancy.js.map +1 -1
- package/dist/runtime/transactions.d.ts +3 -1
- package/dist/runtime/transactions.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/eve.d.ts +287 -0
- package/dist/server/eve.js +1071 -0
- package/dist/server/eve.js.map +1 -0
- package/dist/server/index.d.ts +2 -19
- package/dist/server/index.js +102 -5
- package/dist/server/index.js.map +1 -1
- package/dist/server/mcp.d.ts +15 -22
- package/dist/server/mcp.js +40 -3
- package/dist/server/mcp.js.map +1 -1
- package/dist/server/project.js +26 -8
- package/dist/server/project.js.map +1 -1
- package/dist/server/tenancy.d.ts +9 -0
- package/dist/server/tenancy.js +62 -1
- 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 +4 -5
- package/dist/testing/index.js +3 -2
- package/dist/testing/index.js.map +1 -1
- package/docs/AGENT-CONTROL.md +166 -4
- package/docs/APPBOUNDRY.md +73 -0
- package/docs/ARCHITECTURE.md +6 -2
- package/docs/AUTH.md +37 -0
- package/docs/COMPONENTS.md +71 -0
- package/docs/EVE-COMPOSITION.md +75 -0
- package/docs/GUARANTEES.md +4 -4
- package/docs/NATIVE-AGENTS.md +353 -0
- package/docs/NATIVE.md +137 -0
- package/docs/PRESENCE-AND-SIGNALING-PROPOSAL.md +152 -0
- package/docs/README.md +6 -2
- package/docs/SECURITY.md +71 -3
- package/docs/TRANSACTIONS.md +48 -0
- package/docs/UPSTREAM-GAPS.md +16 -2
- package/package.json +42 -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-BhxrvY37.js +0 -15
|
@@ -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
|
+
//# sourceMappingURL=resource-access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-access.js","sourceRoot":"","sources":["../../src/runtime/resource-access.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIlE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,CAAC,MAAM,0BAA0B,GAAG,0BAA0B,CAAC;AACrE,MAAM,CAAC,MAAM,uBAAuB,GAAG,kCAAkC,CAAC;AAC1E,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AACzC,yEAAyE;AACzE,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACxD,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AA4E1D,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACnF,MAAM,GAAG,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AAEvD,MAAM,OAAO,mBAAmB;IACrB,GAAG,CAAqB;IACxB,MAAM,CAAQ;IAEvB,YAAY,EAAsB,EAAE,KAAY;QAC9C,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB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S,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;YAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC,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";
|
|
@@ -10,7 +16,7 @@ import { ActivityLog, type ActivityVia } from "./activity.js";
|
|
|
10
16
|
import { ProviderHost } from "./providers.js";
|
|
11
17
|
import { Authority, type CallerContext, type Principal } from "./authority.js";
|
|
12
18
|
import { ChangeFeed } from "./changes.js";
|
|
13
|
-
import type { AgentTrigger, Logger } from "./context.js";
|
|
19
|
+
import type { ActionCtx, AgentTrigger, Logger } from "./context.js";
|
|
14
20
|
import { ModelHost } from "./decisions.js";
|
|
15
21
|
import { type EnvironmentDescriptor } from "./environment.js";
|
|
16
22
|
import { type InstanceFactory, type StateInstance } from "./instance.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";
|
|
@@ -78,6 +85,8 @@ export interface CallOptions {
|
|
|
78
85
|
agentRun?: {
|
|
79
86
|
definition: AgentDefinition;
|
|
80
87
|
trigger: AgentTrigger;
|
|
88
|
+
outboxId?: string;
|
|
89
|
+
abort?: AbortController;
|
|
81
90
|
};
|
|
82
91
|
/** The caller's time zone and locale (validated), for `ctx.auth.context`. */
|
|
83
92
|
context?: CallerContext;
|
|
@@ -85,6 +94,8 @@ export interface CallOptions {
|
|
|
85
94
|
delegation?: Delegation;
|
|
86
95
|
/** Actions: aborted when the caller cancels (closes the stream). */
|
|
87
96
|
signal?: AbortSignal;
|
|
97
|
+
/** The caller's idempotency key (AppPort), recorded with an action's external effect. */
|
|
98
|
+
idempotencyKey?: string;
|
|
88
99
|
/** Actions: the caller's stream, for `ctx.emit` and model deltas. */
|
|
89
100
|
emit?: (event: {
|
|
90
101
|
type: string;
|
|
@@ -93,7 +104,39 @@ export interface CallOptions {
|
|
|
93
104
|
session?: {
|
|
94
105
|
ref: string;
|
|
95
106
|
};
|
|
107
|
+
/** The client's address, when the surface knows it: anonymous callers' quotas count per address. */
|
|
108
|
+
client?: string;
|
|
109
|
+
/**
|
|
110
|
+
* The call's invocation context (AppPort §9.1.1): the caller's claims (HTTP `x-appport-*` headers, the AppPort
|
|
111
|
+
* envelope, MCP `_meta`), verified at the execution boundary against work grants and approvals. `verified` is set
|
|
112
|
+
* only by the runtime itself, for an internal call that carries its caller's already verified context.
|
|
113
|
+
*/
|
|
114
|
+
invocation?: {
|
|
115
|
+
claimed: InvocationContext;
|
|
116
|
+
verified?: InvocationContext;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* @internal Set only by the runtime for the application's own calls (an action's ctx.runQuery/runMutation, a job
|
|
120
|
+
* handler, an inbound webhook handler, auth.onSessionEnd, an integration's onOutcome): no surface can set it.
|
|
121
|
+
* Internal calls pass every `visibility`; `access` still applies.
|
|
122
|
+
*/
|
|
123
|
+
internal?: boolean;
|
|
124
|
+
}
|
|
125
|
+
/** What one agent run reconciliation pass found and did. */
|
|
126
|
+
export interface AgentReconciliation {
|
|
127
|
+
examined: number;
|
|
128
|
+
expired: Array<{
|
|
129
|
+
taskId: string;
|
|
130
|
+
actionId: string;
|
|
131
|
+
}>;
|
|
132
|
+
resumed: Array<{
|
|
133
|
+
taskId: string;
|
|
134
|
+
cause: string;
|
|
135
|
+
resumeId: string;
|
|
136
|
+
}>;
|
|
96
137
|
}
|
|
138
|
+
/** How often the services tick reconciles agent runs. */
|
|
139
|
+
export declare const AGENT_RECONCILE_MS = 15000;
|
|
97
140
|
export type CallResult = {
|
|
98
141
|
ok: true;
|
|
99
142
|
value: unknown;
|
|
@@ -116,6 +159,8 @@ export interface RuntimeStartOptions {
|
|
|
116
159
|
workerIntervalMs?: number;
|
|
117
160
|
/** Deadline for one agent action. Default 30 s. */
|
|
118
161
|
agentActionTimeoutMs?: number;
|
|
162
|
+
/** Tests only: how long a reasoning run's lease holds without renewal (default: half the agent's leaseMs). */
|
|
163
|
+
agentRunLeaseMs?: number;
|
|
119
164
|
/** Tests only: fault-injection points in the agent's action lifecycle (see AgentHooks). */
|
|
120
165
|
agentHooks?: AgentHooks;
|
|
121
166
|
/**
|
|
@@ -132,6 +177,11 @@ export interface RuntimeStartOptions {
|
|
|
132
177
|
* opening an environment to read or migrate it); the status is still reported.
|
|
133
178
|
*/
|
|
134
179
|
migrate?: "auto" | "manual" | "off";
|
|
180
|
+
/**
|
|
181
|
+
* The clock presence leases and quotas read (src/clock.ts). Default: the system clock. Tests pass
|
|
182
|
+
* `manualClock()` to drive expiry and quota windows deterministically.
|
|
183
|
+
*/
|
|
184
|
+
clock?: Clock;
|
|
135
185
|
}
|
|
136
186
|
/**
|
|
137
187
|
* The application's schema, as this runtime holds it.
|
|
@@ -214,6 +264,16 @@ export declare class FeltKitRuntime {
|
|
|
214
264
|
}>;
|
|
215
265
|
/** The settings this runtime reads (where the authority's address resolves, for one). */
|
|
216
266
|
get settings(): NodeJS.ProcessEnv;
|
|
267
|
+
/** The clock leases and quotas read (RuntimeStartOptions.clock). */
|
|
268
|
+
readonly clock: Clock;
|
|
269
|
+
/** Call quotas (src/quota.ts): in-process sliding windows. */
|
|
270
|
+
readonly quotas: QuotaLimiter;
|
|
271
|
+
/** Presence leases (app.presence): ctx.presence, the live view, expiry and session ends (runtime/presence-host.ts). */
|
|
272
|
+
readonly presence: PresenceHost;
|
|
273
|
+
/** Guest links and agent grants: access to one resource (runtime/resource-access.ts). */
|
|
274
|
+
readonly access: ResourceAccessStore;
|
|
275
|
+
/** Workers, their work grants, and people's approvals of exact calls (runtime/workers.ts). */
|
|
276
|
+
readonly workers: WorkerAuthority;
|
|
217
277
|
private constructor();
|
|
218
278
|
static start(options: RuntimeStartOptions): Promise<FeltKitRuntime>;
|
|
219
279
|
get state(): RuntimeState;
|
|
@@ -261,6 +321,23 @@ export declare class FeltKitRuntime {
|
|
|
261
321
|
get workerId(): string;
|
|
262
322
|
/** The access a function declares (`app.mutation({ access })`), or undefined when there is no such function. */
|
|
263
323
|
functionAccess(name: string): string | undefined;
|
|
324
|
+
/**
|
|
325
|
+
* The permissions a function requires (`access`), by the capability it publishes or, for one that publishes none (an
|
|
326
|
+
* internal job handler recording an effect), by its name; null when there is no such function.
|
|
327
|
+
*/
|
|
328
|
+
capabilityAccess(capability: string): readonly string[] | null;
|
|
329
|
+
/** The `sequence` of the last appport.agent.changed event for a task (0 before any), from its durable counter. */
|
|
330
|
+
agentChangeSequence(taskId: string): Promise<number>;
|
|
331
|
+
/**
|
|
332
|
+
* A task's control state changed durably (runtime/agent-control.ts): allocate the next per-task sequence (a durable
|
|
333
|
+
* counter, compare-and-set, so it survives restarts and never repeats) and publish appport.agent.changed@1 with the
|
|
334
|
+
* state as that change left it, scoped to the task. Emissions for one task are serialized in this process.
|
|
335
|
+
*/
|
|
336
|
+
agentChanged(taskId: string, changes: AgentChangeKind[], instructionId: string | undefined, state: {
|
|
337
|
+
revision: string;
|
|
338
|
+
phase: string;
|
|
339
|
+
mode: string;
|
|
340
|
+
}): Promise<void>;
|
|
264
341
|
/** Whether `principal` holds `access` under this application's roles ("public" and "authenticated" as functions treat them). */
|
|
265
342
|
holds(principal: Principal | null, access: string): boolean;
|
|
266
343
|
/**
|
|
@@ -283,6 +360,18 @@ export declare class FeltKitRuntime {
|
|
|
283
360
|
* expired, and revoked credentials resolve to null.
|
|
284
361
|
*/
|
|
285
362
|
principalForToken(token: string | undefined): Promise<Principal | null>;
|
|
363
|
+
/**
|
|
364
|
+
* A member previewing the application as a lower role of their tenant: only the accounts' base roles and that
|
|
365
|
+
* role, marked `preview` (every write is then refused). A role that is not below theirs, or no tenant, previews
|
|
366
|
+
* nothing: the principal is returned as it is.
|
|
367
|
+
*/
|
|
368
|
+
previewAs(principal: Principal, role: string | undefined): Principal;
|
|
369
|
+
/**
|
|
370
|
+
* A worker as it is now, from its active registration (the same resolution as a worker session's): its
|
|
371
|
+
* registered roles, in the tenant it was registered in, through its live membership there. Null when no
|
|
372
|
+
* registration of that principal is active.
|
|
373
|
+
*/
|
|
374
|
+
workerPrincipal(principalId: string): Promise<Principal | null>;
|
|
286
375
|
/**
|
|
287
376
|
* The principal working in a tenant: the live membership's role joins its roles, and its claims
|
|
288
377
|
* come along. No active membership (removed, or never a member) means no tenant and no tenant role.
|
|
@@ -359,6 +448,38 @@ export declare class FeltKitRuntime {
|
|
|
359
448
|
* kept), then performed now as its caller, or by the worker if that caller cannot be resolved.
|
|
360
449
|
*/
|
|
361
450
|
retryOutbox(id: string, by: string): Promise<OutboxRecord>;
|
|
451
|
+
/**
|
|
452
|
+
* A new attempt of the reasoning run on `taskId`, when it is open and owned by one of this application's
|
|
453
|
+
* reasoning agents: an outbox record keyed by the task and `cause` (written once, `requireAbsent`: a repeated
|
|
454
|
+
* cause, from this process or another, adds nothing), run now and recovered by the services worker like any
|
|
455
|
+
* agent run. Nothing is decided here: the attempt takes the run's lease, reads its state and continues only
|
|
456
|
+
* where something changed. Returns the record's id when this call created it.
|
|
457
|
+
*/
|
|
458
|
+
resumeAgentRun(taskId: string, cause: string): Promise<string | null>;
|
|
459
|
+
/**
|
|
460
|
+
* Agent run reconciliation: find reasoning runs that should be executing and are not, from durable state only,
|
|
461
|
+
* and resume each through the outbox. Part of the services tick (at most every 15 s), and safe to call at any
|
|
462
|
+
* time, from any number of processes:
|
|
463
|
+
*
|
|
464
|
+
* proposal past its approval window expired (cancelled), as approve() would; the run then resumes
|
|
465
|
+
* released "waiting", every waited-on resume: a person decided (approve, reject, settle) or it expired, and
|
|
466
|
+
* action now decided the resume record was never written or never ran
|
|
467
|
+
* released "held", task running again resume: a person resumed it
|
|
468
|
+
* lease expired, never released resume, unless the outbox record of the attempt that held it is still
|
|
469
|
+
* pending or performing (outbox recovery takes that one over)
|
|
470
|
+
* no lease at all, task older than 30 s resume: the first attempt stopped before taking the run
|
|
471
|
+
* released "completed"/"stopped", resume: the attempt released before its task's end was recorded
|
|
472
|
+
* task still open
|
|
473
|
+
*
|
|
474
|
+
* Never resumed: a live lease (an attempt is executing), "error" (the outbox retries it or it failed; an operator
|
|
475
|
+
* decides), a proposal still waiting for a person, an outcome a person must settle, a paused task. Each resume is
|
|
476
|
+
* keyed by the lease link it reads and the states of what it waited on, so the same state resumes once however
|
|
477
|
+
* often or concurrently this runs; each is recorded on the task (`<task>.recovery-…`) and in the activity log.
|
|
478
|
+
*/
|
|
479
|
+
reconcileAgentRuns(options?: {
|
|
480
|
+
force?: boolean;
|
|
481
|
+
now?: number;
|
|
482
|
+
}): Promise<AgentReconciliation>;
|
|
362
483
|
/** Wait for the agent runs started so far (and any they start) to finish their current attempt. */
|
|
363
484
|
settleAgents(): Promise<void>;
|
|
364
485
|
/**
|
|
@@ -419,6 +540,7 @@ export declare class FeltKitRuntime {
|
|
|
419
540
|
via: ActivityVia;
|
|
420
541
|
actor?: Principal | null;
|
|
421
542
|
tenantId?: string | null;
|
|
543
|
+
previewRole?: string;
|
|
422
544
|
}): Promise<{
|
|
423
545
|
token: string;
|
|
424
546
|
principal: Principal;
|
|
@@ -435,6 +557,19 @@ export declare class FeltKitRuntime {
|
|
|
435
557
|
type: "agent" | "service";
|
|
436
558
|
displayName?: string;
|
|
437
559
|
} | null>;
|
|
560
|
+
/**
|
|
561
|
+
* Redeem a guest link (K4): a session for a guest with no account, holding the link's role, admitted to the
|
|
562
|
+
* link's one resource, lasting until the link expires (at most GUEST_SESSION_MAX_MS). The display name is the
|
|
563
|
+
* guest's own words, shown to others as such.
|
|
564
|
+
*/
|
|
565
|
+
redeemGuestLink(token: unknown, displayName: unknown): Promise<{
|
|
566
|
+
token: string;
|
|
567
|
+
principal: Principal;
|
|
568
|
+
expiresAt?: string;
|
|
569
|
+
}>;
|
|
570
|
+
/** ctx.grants for one call: guest links and agent grants for records the caller can see, issued as a person. */
|
|
571
|
+
/** `ctx.grants` as this principal, outside a function: the same rules (FeltKit's own surfaces, e.g. eve agents). */
|
|
572
|
+
grantsFor(principal: Principal | null): ActionCtx["grants"];
|
|
438
573
|
/** Record an authentication event (sign-in failures, revocations, membership changes) in the activity log. */
|
|
439
574
|
recordAuth(name: string, principal: Principal | null, detail: Record<string, unknown>, outcome?: "success" | "denied" | "error", via?: ActivityVia): void;
|
|
440
575
|
/** Run a query or mutation as `principal`. Authority is checked before the handler runs. */
|
|
@@ -550,3 +685,10 @@ export interface InvitationMailInput {
|
|
|
550
685
|
inviter: string;
|
|
551
686
|
expiresInDays: number;
|
|
552
687
|
}
|
|
688
|
+
/** Why `principal` may not call a function of this visibility from a surface, or null (runtime/workers.ts). */
|
|
689
|
+
export declare function visibilityRefusalFor(name: string, visibility: NonNullable<FunctionDefinition["visibility"]>, principal: Principal | null): {
|
|
690
|
+
code: "FUNCTION_NOT_FOUND" | "FORBIDDEN" | "UNAUTHORIZED";
|
|
691
|
+
message: string;
|
|
692
|
+
} | null;
|
|
693
|
+
/** How messages name the application: its name as a title ("team-board" → "Team board"). A description is not a name. */
|
|
694
|
+
export declare function appTitle(name: string): string;
|