@feltdb/feltkit 0.3.32 → 0.3.34

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 (73) hide show
  1. package/dist/app.d.ts +15 -0
  2. package/dist/app.js +2 -0
  3. package/dist/app.js.map +1 -1
  4. package/dist/appboundry/build.js +3 -0
  5. package/dist/appboundry/build.js.map +1 -1
  6. package/dist/appboundry/runtime.d.ts +1 -1
  7. package/dist/appboundry/runtime.js +1 -1
  8. package/dist/appboundry/runtime.js.map +1 -1
  9. package/dist/cli/deploy-appboundry-self-hosted.js +10 -4
  10. package/dist/cli/deploy-appboundry-self-hosted.js.map +1 -1
  11. package/dist/cli/main.js +1 -1
  12. package/dist/cli/main.js.map +1 -1
  13. package/dist/client/index.d.ts +8 -0
  14. package/dist/client/index.js +7 -0
  15. package/dist/client/index.js.map +1 -1
  16. package/dist/component.js +1 -1
  17. package/dist/component.js.map +1 -1
  18. package/dist/docs.d.ts +1 -1
  19. package/dist/docs.js +1 -0
  20. package/dist/docs.js.map +1 -1
  21. package/dist/measure/index.js +17 -0
  22. package/dist/measure/index.js.map +1 -1
  23. package/dist/providers.d.ts +23 -0
  24. package/dist/providers.js +29 -0
  25. package/dist/providers.js.map +1 -0
  26. package/dist/runtime/access-grants.d.ts +25 -0
  27. package/dist/runtime/access-grants.js +78 -0
  28. package/dist/runtime/access-grants.js.map +1 -0
  29. package/dist/runtime/activity.d.ts +2 -0
  30. package/dist/runtime/activity.js.map +1 -1
  31. package/dist/runtime/authority.d.ts +16 -1
  32. package/dist/runtime/authority.js +3 -1
  33. package/dist/runtime/authority.js.map +1 -1
  34. package/dist/runtime/backup.js +2 -1
  35. package/dist/runtime/backup.js.map +1 -1
  36. package/dist/runtime/context.d.ts +8 -0
  37. package/dist/runtime/contract.js +10 -1
  38. package/dist/runtime/contract.js.map +1 -1
  39. package/dist/runtime/delegation.d.ts +47 -0
  40. package/dist/runtime/delegation.js +55 -0
  41. package/dist/runtime/delegation.js.map +1 -0
  42. package/dist/runtime/loader.js +2 -1
  43. package/dist/runtime/loader.js.map +1 -1
  44. package/dist/runtime/providers.d.ts +72 -0
  45. package/dist/runtime/providers.js +252 -0
  46. package/dist/runtime/providers.js.map +1 -0
  47. package/dist/runtime/runtime.d.ts +35 -1
  48. package/dist/runtime/runtime.js +204 -10
  49. package/dist/runtime/runtime.js.map +1 -1
  50. package/dist/runtime/sessions.d.ts +41 -1
  51. package/dist/runtime/sessions.js +74 -7
  52. package/dist/runtime/sessions.js.map +1 -1
  53. package/dist/server/admin.js +6 -1
  54. package/dist/server/admin.js.map +1 -1
  55. package/dist/server/index.d.ts +1 -0
  56. package/dist/server/index.js +60 -6
  57. package/dist/server/index.js.map +1 -1
  58. package/dist/server/mcp.d.ts +5 -0
  59. package/dist/server/mcp.js +42 -1
  60. package/dist/server/mcp.js.map +1 -1
  61. package/dist/server/project.d.ts +8 -0
  62. package/dist/server/project.js +10 -1
  63. package/dist/server/project.js.map +1 -1
  64. package/dist/server/tenancy.js +1 -1
  65. package/dist/server/tenancy.js.map +1 -1
  66. package/docs/AUTH.md +40 -0
  67. package/docs/LOCAL-AUTHORITY.md +37 -0
  68. package/docs/MEASURE.md +8 -1
  69. package/docs/PROVIDERS.md +103 -0
  70. package/docs/README.md +3 -2
  71. package/package.json +11 -10
  72. package/skills/.claude-plugin/marketplace.json +1 -1
  73. package/skills/.claude-plugin/plugin.json +1 -1
@@ -0,0 +1,72 @@
1
+ import { AccessGrants, type CapabilityDefinition, type ProviderDefinition, type ProviderHealth } from "@appport/core";
2
+ import { FeltKitError } from "../errors.js";
3
+ import type { ProviderDeclaration } from "../providers.js";
4
+ export type { ProviderDeclaration } from "../providers.js";
5
+ export declare const PROVIDER_CALLS = "_feltkit_provider_calls";
6
+ /**
7
+ * Imports a declared provider: a path relative to the project, or a package export resolved like an import from
8
+ * FeltKit's own installation (the project's node_modules). Checks that the export is a provider definition and that
9
+ * every credential the application maps is one the provider declares.
10
+ */
11
+ export declare function loadProvider(name: string, declaration: ProviderDeclaration, projectDir: string): Promise<ProviderDefinition<any, any>>;
12
+ export interface ProviderHostRuntime {
13
+ readonly logger: {
14
+ info?(message: string, meta?: object): void;
15
+ warn?(message: string, meta?: object): void;
16
+ error?(message: string, meta?: object): void;
17
+ };
18
+ readonly environment: {
19
+ name: string;
20
+ };
21
+ readonly instance: {
22
+ handle(name: string): any;
23
+ };
24
+ readonly credentials: {
25
+ withSecret<T>(request: {
26
+ reference: {
27
+ secretId: string;
28
+ };
29
+ context: {
30
+ purpose: string;
31
+ };
32
+ }, use: (secret: {
33
+ value: string;
34
+ }) => T | Promise<T>): Promise<T>;
35
+ };
36
+ }
37
+ /** Starts, registers, records, and stops the application's providers. */
38
+ export declare class ProviderHost {
39
+ #private;
40
+ constructor(runtime: ProviderHostRuntime);
41
+ /** Channel grants, kept in this environment's FeltDB instance (digests only). One minute by default, at most five. */
42
+ get grants(): AccessGrants;
43
+ /** Where a provider channel is served on the application's port. Relative, so it works on any origin the app is opened at. */
44
+ static channelPath(provider: string, channel: string): string;
45
+ /**
46
+ * A connection on a provider channel (`/_provider/<name>/<channel>`): the grant it presents is redeemed atomically for
47
+ * exactly that channel and purpose, and only then is the connection handed to the provider. Returns the refusal
48
+ * reason, or null when the provider took it.
49
+ */
50
+ accept(provider: string, channel: string, secret: string, transport: unknown): Promise<string | null>;
51
+ /** Brings the running providers in line with the declarations: starts new or changed ones, stops removed ones. */
52
+ sync(declarations: Record<string, ProviderDeclaration> | undefined, projectDir: string): Promise<void>;
53
+ /** The providers' capabilities, instantiated with this host's recorder. */
54
+ capabilities(): CapabilityDefinition[];
55
+ /** The capability names the running providers publish. */
56
+ capabilityNames(): string[];
57
+ /** Whether a capability name belongs to a running provider. */
58
+ provides(capability: string): boolean;
59
+ health(): Promise<Record<string, ProviderHealth>>;
60
+ /** A provider's external call record. */
61
+ call(id: string): Promise<Record<string, unknown> | null>;
62
+ close(): Promise<void>;
63
+ }
64
+ /**
65
+ * An AppPort error from a provider capability as the FeltKit error application code sees. An effect whose outcome is
66
+ * unknown is OUTCOME_UNKNOWN, exactly as for an integration call; other codes keep their meaning.
67
+ */
68
+ export declare function providerError(error: {
69
+ code: string;
70
+ message: string;
71
+ details?: unknown;
72
+ }): FeltKitError;
@@ -0,0 +1,252 @@
1
+ /**
2
+ * AppPort providers in a FeltKit application: `feltkit({ providers: { <name>: { provider, config?, credentials? } } })`.
3
+ *
4
+ * A provider is a package's `defineProvider(...)` from `@appport/core`: capabilities, a configuration schema, the
5
+ * credentials it needs, and how to start. FeltKit composes any provider the same way, knowing nothing about it:
6
+ *
7
+ * start validate the configuration against the provider's schema, then start it with credentials from
8
+ * FeltKit's custody (only the ids the application mapped; FELTKIT_CREDENTIAL_<ID> in production)
9
+ * register its capabilities join the application's AppPort registry beside the application's own functions,
10
+ * so roles authorize them on every surface (HTTP, WebSocket, MCP, agents) through the one pipeline
11
+ * execute handlers run outside any FeltDB transaction. An external effect is recorded in this environment's
12
+ * FeltDB instance before it is attempted (`started`) and after (`succeeded` / `failed` / `unknown`),
13
+ * with the same meaning as integration calls: a process that dies in between leaves `started`, which
14
+ * is unknown, and an unknown outcome is never retried automatically
15
+ * supervise stopped (close, then abort) when the runtime closes; restarted on reload only when its
16
+ * declaration changed
17
+ *
18
+ * Credentials are resolved when the provider starts and never recorded, returned, or logged by FeltKit.
19
+ */
20
+ import { resolve } from "node:path";
21
+ import { pathToFileURL } from "node:url";
22
+ import { AccessGrantRefused, AccessGrants, channelResource, EFFECT_OUTCOME_UNKNOWN, grantChannelIssuer, instantiateProvider, isProviderDefinition } from "@appport/core";
23
+ import { FeltKitError } from "../errors.js";
24
+ import { FeltDbAccessGrantStore } from "./access-grants.js";
25
+ export const PROVIDER_CALLS = "_feltkit_provider_calls";
26
+ /**
27
+ * Imports a declared provider: a path relative to the project, or a package export resolved like an import from
28
+ * FeltKit's own installation (the project's node_modules). Checks that the export is a provider definition and that
29
+ * every credential the application maps is one the provider declares.
30
+ */
31
+ export async function loadProvider(name, declaration, projectDir) {
32
+ const where = `providers.${name}`;
33
+ const specifier = declaration.module.startsWith(".") || declaration.module.startsWith("/") ? pathToFileURL(resolve(projectDir, declaration.module)).href : declaration.module;
34
+ let module;
35
+ try {
36
+ module = (await import(specifier));
37
+ }
38
+ catch (error) {
39
+ throw new FeltKitError("CONFIGURATION", `${where}.module "${declaration.module}" could not be loaded: ${error instanceof Error ? error.message : String(error)}`, { hint: "Install the package that provides it, or fix the path (relative to the project)." });
40
+ }
41
+ const exported = declaration.export ?? "default";
42
+ const provider = module[exported];
43
+ if (!isProviderDefinition(provider))
44
+ throw new FeltKitError("CONFIGURATION", `${where}: "${declaration.module}" exports no provider definition as ${exported === "default" ? "its default export" : `"${exported}"`}.`, { hint: "Name the export with providers.<name>.export." });
45
+ const declared = new Set(provider.credentials.map((c) => c.id));
46
+ for (const id of Object.keys(declaration.credentials ?? {})) {
47
+ if (!declared.has(id))
48
+ throw new FeltKitError("CONFIGURATION", `${where}.credentials: ${provider.id} declares no credential "${id}" (it declares ${[...declared].join(", ") || "none"}).`);
49
+ }
50
+ return provider;
51
+ }
52
+ /** Starts, registers, records, and stops the application's providers. */
53
+ export class ProviderHost {
54
+ #runtime;
55
+ #running = new Map();
56
+ #grants = null;
57
+ #projectDir = process.cwd();
58
+ constructor(runtime) {
59
+ this.#runtime = runtime;
60
+ }
61
+ /** Channel grants, kept in this environment's FeltDB instance (digests only). One minute by default, at most five. */
62
+ get grants() {
63
+ this.#grants ??= new AccessGrants({ store: new FeltDbAccessGrantStore(this.#runtime.instance.handle("feltkit.grants")) });
64
+ return this.#grants;
65
+ }
66
+ /** Where a provider channel is served on the application's port. Relative, so it works on any origin the app is opened at. */
67
+ static channelPath(provider, channel) {
68
+ return `/_provider/${provider}/${channel}`;
69
+ }
70
+ /**
71
+ * A connection on a provider channel (`/_provider/<name>/<channel>`): the grant it presents is redeemed atomically for
72
+ * exactly that channel and purpose, and only then is the connection handed to the provider. Returns the refusal
73
+ * reason, or null when the provider took it.
74
+ */
75
+ async accept(provider, channel, secret, transport) {
76
+ const running = this.#running.get(provider);
77
+ const declaration = running?.provider.channels?.find((c) => c.name === channel);
78
+ if (!running || !declaration || !running.instance.accept)
79
+ return "no-channel";
80
+ try {
81
+ const grant = await this.grants.redeem(secret, { purpose: declaration.purpose, resource: channelResource(provider, channel) });
82
+ await running.instance.accept({ channel, grant, transport });
83
+ return null;
84
+ }
85
+ catch (error) {
86
+ if (error instanceof AccessGrantRefused)
87
+ return error.reason;
88
+ this.#runtime.logger.error?.(`provider ${provider}: channel ${channel} failed`, { error: String(error) });
89
+ return "failed";
90
+ }
91
+ }
92
+ get #db() {
93
+ return this.#runtime.instance.handle("feltkit.providers");
94
+ }
95
+ /** Brings the running providers in line with the declarations: starts new or changed ones, stops removed ones. */
96
+ async sync(declarations, projectDir) {
97
+ this.#projectDir = projectDir;
98
+ const wanted = Object.entries(declarations ?? {});
99
+ const next = new Map();
100
+ for (const [name, declaration] of wanted) {
101
+ const signature = signatureOf(declaration);
102
+ const current = this.#running.get(name);
103
+ if (current && current.signature === signature) {
104
+ next.set(name, current);
105
+ continue;
106
+ }
107
+ if (current)
108
+ await this.#stop(current);
109
+ next.set(name, await this.#start(name, declaration, signature));
110
+ }
111
+ for (const [name, running] of this.#running)
112
+ if (!next.has(name))
113
+ await this.#stop(running);
114
+ this.#running = next;
115
+ }
116
+ /** The providers' capabilities, instantiated with this host's recorder. */
117
+ capabilities() {
118
+ const all = [];
119
+ for (const running of this.#running.values()) {
120
+ all.push(...instantiateProvider(running.provider, running.instance, {
121
+ name: running.name,
122
+ recorder: this.#recorder(),
123
+ channels: grantChannelIssuer({ grants: this.grants, url: (provider, channel) => ProviderHost.channelPath(provider, channel.name) }),
124
+ onRecordError: (error, call) => this.#runtime.logger.error?.(`provider ${running.name}: the outcome of ${call.id} could not be recorded`, { error: String(error), outcome: call.outcome }),
125
+ }));
126
+ }
127
+ return all;
128
+ }
129
+ /** The capability names the running providers publish. */
130
+ capabilityNames() {
131
+ return [...this.#running.values()].flatMap((running) => running.provider.capabilities.map((c) => c.options.name));
132
+ }
133
+ /** Whether a capability name belongs to a running provider. */
134
+ provides(capability) {
135
+ for (const running of this.#running.values())
136
+ if (running.provider.capabilities.some((c) => c.options.name === capability))
137
+ return true;
138
+ return false;
139
+ }
140
+ async health() {
141
+ const result = {};
142
+ for (const [name, running] of this.#running) {
143
+ try {
144
+ result[name] = running.instance.health ? await running.instance.health() : { state: "ready" };
145
+ }
146
+ catch (error) {
147
+ result[name] = { state: "failed", detail: error instanceof Error ? error.message : String(error) };
148
+ }
149
+ }
150
+ return result;
151
+ }
152
+ /** A provider's external call record. */
153
+ async call(id) {
154
+ return (await this.#db.collection(PROVIDER_CALLS).get(id)) ?? null;
155
+ }
156
+ async close() {
157
+ for (const running of this.#running.values())
158
+ await this.#stop(running);
159
+ this.#running.clear();
160
+ }
161
+ async #start(name, declaration, signature) {
162
+ const provider = await loadProvider(name, declaration, this.#projectDir);
163
+ let config = declaration.config ?? {};
164
+ if (provider.configuration) {
165
+ const parsed = provider.configuration.validate(config);
166
+ if (!parsed.ok)
167
+ throw new FeltKitError("CONFIGURATION", `providers.${name}.config does not match ${provider.id}'s configuration: ${parsed.issues.map((i) => `${i.path.join(".") || "(root)"}: ${i.message}`).join("; ")}`);
168
+ config = parsed.value;
169
+ }
170
+ const mapped = declaration.credentials ?? {};
171
+ for (const credential of provider.credentials) {
172
+ if ((credential.required ?? true) && !mapped[credential.id]) {
173
+ throw new FeltKitError("CONFIGURATION", `providers.${name} needs the credential "${credential.id}" (${credential.description}).`, { hint: `Map it to one of this application's credentials: providers.${name}.credentials.${credential.id}.` });
174
+ }
175
+ }
176
+ const abort = new AbortController();
177
+ const log = this.#runtime.logger;
178
+ try {
179
+ const instance = await provider.start({
180
+ name,
181
+ config,
182
+ signal: abort.signal,
183
+ credential: async (id) => {
184
+ if (!provider.credentials.some((c) => c.id === id))
185
+ throw new FeltKitError("FORBIDDEN", `${provider.id} did not declare credential "${id}".`);
186
+ const target = mapped[id];
187
+ if (!target)
188
+ return null;
189
+ try {
190
+ return await this.#runtime.credentials.withSecret({ reference: { secretId: target }, context: { purpose: `provider:${name}` } }, (secret) => secret.value);
191
+ }
192
+ catch {
193
+ return null;
194
+ }
195
+ },
196
+ log: {
197
+ info: (message) => log.info?.(`provider ${name}: ${message}`),
198
+ warn: (message) => log.warn?.(`provider ${name}: ${message}`),
199
+ error: (message) => log.error?.(`provider ${name}: ${message}`),
200
+ },
201
+ });
202
+ return { name, declaration, provider, signature, instance, abort };
203
+ }
204
+ catch (error) {
205
+ abort.abort();
206
+ if (error instanceof FeltKitError)
207
+ throw error;
208
+ throw new FeltKitError("CONFIGURATION", `providers.${name} (${provider.id}) failed to start: ${error instanceof Error ? error.message : String(error)}`);
209
+ }
210
+ }
211
+ async #stop(running) {
212
+ try {
213
+ await running.instance.close?.();
214
+ }
215
+ catch (error) {
216
+ this.#runtime.logger.warn?.(`provider ${running.name} did not close cleanly`, { error: String(error) });
217
+ }
218
+ finally {
219
+ running.abort.abort();
220
+ }
221
+ }
222
+ #recorder() {
223
+ const db = () => this.#db;
224
+ const environment = this.#runtime.environment.name;
225
+ return {
226
+ async started(call) {
227
+ await db().transaction({ operations: [{ collection: PROVIDER_CALLS, id: call.id, requireAbsent: true, value: { ...call, state: "started", environment } }] });
228
+ },
229
+ async finished(call) {
230
+ const current = (await db().collection(PROVIDER_CALLS).get(call.id));
231
+ if (!current)
232
+ throw new Error(`No started record for ${call.id}`);
233
+ const { __version, ...started } = current;
234
+ await db().transaction({ operations: [{ collection: PROVIDER_CALLS, id: call.id, ifVersion: __version, value: { ...started, state: call.outcome, finishedAt: call.finishedAt, ...(call.error ? { error: call.error } : {}) } }] });
235
+ },
236
+ };
237
+ }
238
+ }
239
+ function signatureOf(declaration) {
240
+ return JSON.stringify([declaration.module, declaration.export ?? "default", declaration.config ?? null, declaration.credentials ?? {}]);
241
+ }
242
+ /**
243
+ * An AppPort error from a provider capability as the FeltKit error application code sees. An effect whose outcome is
244
+ * unknown is OUTCOME_UNKNOWN, exactly as for an integration call; other codes keep their meaning.
245
+ */
246
+ export function providerError(error) {
247
+ const details = error.details;
248
+ const code = error.code === "CONFLICT" && details?.reason === EFFECT_OUTCOME_UNKNOWN ? "OUTCOME_UNKNOWN"
249
+ : { INVALID_INPUT: "INVALID_ARGUMENT", INVALID_REQUEST: "INVALID_ARGUMENT", UNKNOWN_CAPABILITY: "NOT_FOUND", UNAUTHORIZED: "UNAUTHORIZED", FORBIDDEN: "FORBIDDEN", NOT_FOUND: "NOT_FOUND", CONFLICT: "CONFLICT", RATE_LIMITED: "RATE_LIMITED", TIMEOUT: "UNAVAILABLE", CANCELLED: "UNAVAILABLE", PAYLOAD_TOO_LARGE: "PAYLOAD_TOO_LARGE" }[error.code] ?? "UNAVAILABLE";
250
+ return new FeltKitError(code, error.message, { ...(error.details !== undefined ? { details: { ...error.details, appportCode: error.code } } : { details: { appportCode: error.code } }) });
251
+ }
252
+ //# sourceMappingURL=providers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providers.js","sourceRoot":"","sources":["../../src/runtime/providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,oBAAoB,EAA8K,MAAM,eAAe,CAAC;AACrV,OAAO,EAAE,YAAY,EAAyB,MAAM,cAAc,CAAC;AAEnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAG5D,MAAM,CAAC,MAAM,cAAc,GAAG,yBAAyB,CAAC;AAExD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAY,EAAE,WAAgC,EAAE,UAAkB;IACnG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W,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,iBAAiB,EAAE,mBAAmB,EAAuC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC;IACjZ,OAAO,IAAI,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,GAAI,KAAK,CAAC,OAAkB,EAAE,WAAW,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;AACzM,CAAC"}
@@ -7,6 +7,7 @@ import { IntegrationHost } from "./integrations.js";
7
7
  import { type BackupHeader, type BackupSink } from "./backup.js";
8
8
  import { type FeltKitErrorJSON } from "../errors.js";
9
9
  import { ActivityLog, type ActivityVia } from "./activity.js";
10
+ import { ProviderHost } from "./providers.js";
10
11
  import { Authority, type CallerContext, type Principal } from "./authority.js";
11
12
  import { ChangeFeed } from "./changes.js";
12
13
  import type { AgentTrigger, Logger } from "./context.js";
@@ -20,6 +21,7 @@ import { OAuthCredentials } from "./oauth-credentials.js";
20
21
  import { InvocationStore } from "./invocations.js";
21
22
  import { ExecutionHost } from "./execution-host.js";
22
23
  import { LocalAuthorityHost } from "./local-authority.js";
24
+ import { type Delegation } from "./delegation.js";
23
25
  import { type HostCredentials } from "./credentials.js";
24
26
  import { AgentHost, type AgentHooks } from "./agent.js";
25
27
  import { FeltDbIdempotencyStore } from "./idempotency.js";
@@ -37,6 +39,8 @@ export interface LoadedProject {
37
39
  policies: import("../policy.js").ResolvedPolicyRule[];
38
40
  modules: string[];
39
41
  loadedAt: string;
42
+ /** The project directory, when the project was loaded from its sources; relative provider modules resolve from it. */
43
+ projectDir?: string;
40
44
  }
41
45
  /** An approved agent action, as the agent lifecycle executes it (runtime.runApproved). */
42
46
  export interface ApprovedAction {
@@ -48,6 +52,10 @@ export interface ApprovedAction {
48
52
  }
49
53
  import type { ComponentWorkItem, ComponentWorkOutcome } from "../component.js";
50
54
  export type { ComponentWorkItem, ComponentWorkOutcome };
55
+ /** How often expired sessions are ended for auth.onSessionEnd: the bound on noticing an expiry. */
56
+ export declare const SESSION_EXPIRY_SWEEP_MS = 5000;
57
+ /** Attempts at running auth.onSessionEnd for one ended session before it is kept as failed. */
58
+ export declare const SESSION_END_MAX_ATTEMPTS = 10;
51
59
  export interface CallOptions {
52
60
  principal: Principal | null;
53
61
  via: ActivityVia;
@@ -73,12 +81,18 @@ export interface CallOptions {
73
81
  };
74
82
  /** The caller's time zone and locale (validated), for `ctx.auth.context`. */
75
83
  context?: CallerContext;
84
+ /** Set only by AppPort dispatch after AuthBoundry verified it (runtime/delegation.ts): `principal` is then the person. */
85
+ delegation?: Delegation;
76
86
  /** Actions: aborted when the caller cancels (closes the stream). */
77
87
  signal?: AbortSignal;
78
88
  /** Actions: the caller's stream, for `ctx.emit` and model deltas. */
79
89
  emit?: (event: {
80
90
  type: string;
81
91
  } & Record<string, unknown>) => void;
92
+ /** The caller's FeltKit session, by ref (`ctx.auth.session`). Set by the HTTP and AppPort surfaces. */
93
+ session?: {
94
+ ref: string;
95
+ };
82
96
  }
83
97
  export type CallResult = {
84
98
  ok: true;
@@ -177,6 +191,8 @@ export declare class FeltKitRuntime {
177
191
  readonly models: ModelHost;
178
192
  /** HTTP integrations declared with app.integration() (runtime/integrations.ts). */
179
193
  readonly integrations: IntegrationHost;
194
+ /** AppPort providers the application declared (`feltkit({ providers })`): started, registered, recorded, stopped. */
195
+ readonly providers: ProviderHost;
180
196
  /** OAuth 2.0 grants of integrations: renewed, rotated, disconnected (runtime/oauth-credentials.ts). */
181
197
  readonly oauth: OAuthCredentials;
182
198
  /** Durable invocations from registered surfaces: lifecycle, dispatch, recovery (runtime/invocations.ts). */
@@ -247,6 +263,17 @@ export declare class FeltKitRuntime {
247
263
  functionAccess(name: string): string | undefined;
248
264
  /** Whether `principal` holds `access` under this application's roles ("public" and "authenticated" as functions treat them). */
249
265
  holds(principal: Principal | null, access: string): boolean;
266
+ /**
267
+ * Any published AppPort capability (the application's own, an integration's, a provider's), called as `principal`
268
+ * through the application's AppPort pipeline: validation, roles, idempotency, and effect recording apply exactly as
269
+ * for any AppPort client. Application code reaches it through ctx.integrations.invoke; browsers through
270
+ * POST /api/capability/<name> (client.invoke).
271
+ */
272
+ invokeCapability(capability: string, input: Record<string, unknown>, principal: Principal | null, options: {
273
+ version?: number;
274
+ idempotencyKey?: string;
275
+ via: string;
276
+ }): Promise<unknown>;
250
277
  /** Run `work` as the execution of an approved action (called by the agent lifecycle only). */
251
278
  runApproved<T>(action: ApprovedAction, work: () => Promise<T>): Promise<T>;
252
279
  functions(): FunctionInfo[];
@@ -334,7 +361,14 @@ export declare class FeltKitRuntime {
334
361
  retryOutbox(id: string, by: string): Promise<OutboxRecord>;
335
362
  /** Wait for the agent runs started so far (and any they start) to finish their current attempt. */
336
363
  settleAgents(): Promise<void>;
337
- /** Drive durable service work once (jobs, schedules, webhook deliveries, recovered after-commit effects). */
364
+ /**
365
+ * Hand ended sessions to the application's `auth.onSessionEnd` (docs/AUTH.md, "When a session ends"): end
366
+ * expired sessions (at most every SESSION_EXPIRY_SWEEP_MS), then run the hook for each recorded end, as the
367
+ * session's principal, and forget the end once it succeeds. A failed run is retried on the next pass and
368
+ * kept as failed, with its error, after SESSION_END_MAX_ATTEMPTS. Runs on every services tick and right
369
+ * after a session ends; one pass at a time.
370
+ */
371
+ runSessionEnds(): Promise<void>;
338
372
  runServices(): Promise<ServiceTick>;
339
373
  /**
340
374
  * API keys are stored as HMACs under a server-held key: FELTKIT_API_KEY_VERIFIER_KEY when