@feltdb/feltkit 0.1.1 → 0.2.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 +106 -10
- package/dist/app.js +51 -0
- package/dist/app.js.map +1 -1
- package/dist/cli/main.js +218 -2
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/skills.d.ts +39 -0
- package/dist/cli/skills.js +125 -0
- package/dist/cli/skills.js.map +1 -0
- package/dist/dashboard/assets/{index-BLnBFDJs.css → index--1Tqbv_A.css} +1 -1
- package/dist/dashboard/assets/index-Bm4qCYpv.js +15 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/errors.d.ts +3 -1
- package/dist/errors.js +2 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/runtime/activity.d.ts +21 -8
- package/dist/runtime/activity.js +17 -3
- package/dist/runtime/activity.js.map +1 -1
- package/dist/runtime/agent.d.ts +353 -0
- package/dist/runtime/agent.js +1345 -0
- package/dist/runtime/agent.js.map +1 -0
- package/dist/runtime/authority.d.ts +23 -3
- package/dist/runtime/authority.js +69 -5
- package/dist/runtime/authority.js.map +1 -1
- package/dist/runtime/changes.d.ts +16 -8
- package/dist/runtime/changes.js.map +1 -1
- package/dist/runtime/content.d.ts +33 -0
- package/dist/runtime/content.js +46 -0
- package/dist/runtime/content.js.map +1 -0
- package/dist/runtime/context.d.ts +26 -1
- package/dist/runtime/credentials.d.ts +42 -0
- package/dist/runtime/credentials.js +32 -0
- package/dist/runtime/credentials.js.map +1 -0
- package/dist/runtime/data.d.ts +8 -2
- package/dist/runtime/data.js +74 -9
- package/dist/runtime/data.js.map +1 -1
- package/dist/runtime/decisions.d.ts +131 -0
- package/dist/runtime/decisions.js +301 -0
- package/dist/runtime/decisions.js.map +1 -0
- package/dist/runtime/environment.js +11 -0
- package/dist/runtime/environment.js.map +1 -1
- package/dist/runtime/idempotency.d.ts +37 -0
- package/dist/runtime/idempotency.js +88 -0
- package/dist/runtime/idempotency.js.map +1 -0
- package/dist/runtime/instance.d.ts +8 -3
- package/dist/runtime/instance.js +27 -4
- package/dist/runtime/instance.js.map +1 -1
- package/dist/runtime/integrations.d.ts +120 -0
- package/dist/runtime/integrations.js +412 -0
- package/dist/runtime/integrations.js.map +1 -0
- package/dist/runtime/loader.d.ts +5 -1
- package/dist/runtime/loader.js +35 -13
- package/dist/runtime/loader.js.map +1 -1
- package/dist/runtime/projects.d.ts +1 -0
- package/dist/runtime/projects.js +6 -4
- package/dist/runtime/projects.js.map +1 -1
- package/dist/runtime/readiness.d.ts +29 -0
- package/dist/runtime/readiness.js +154 -0
- package/dist/runtime/readiness.js.map +1 -0
- package/dist/runtime/runtime.d.ts +50 -1
- package/dist/runtime/runtime.js +225 -9
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/services.d.ts +186 -36
- package/dist/runtime/services.js +420 -152
- package/dist/runtime/services.js.map +1 -1
- package/dist/runtime/sessions.d.ts +7 -18
- package/dist/runtime/sessions.js +7 -5
- package/dist/runtime/sessions.js.map +1 -1
- package/dist/server/admin.d.ts +26 -0
- package/dist/server/admin.js +510 -8
- package/dist/server/admin.js.map +1 -1
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +13 -4
- package/dist/server/index.js.map +1 -1
- package/dist/server/management.d.ts +12 -0
- package/dist/server/management.js +177 -0
- package/dist/server/management.js.map +1 -0
- package/dist/server/mcp.d.ts +202 -0
- package/dist/server/mcp.js +62 -4
- package/dist/server/mcp.js.map +1 -1
- package/dist/server/operators.d.ts +77 -0
- package/dist/server/operators.js +162 -0
- package/dist/server/operators.js.map +1 -0
- package/dist/server/project.js +17 -4
- package/dist/server/project.js.map +1 -1
- package/dist/testing/index.js +3 -2
- package/dist/testing/index.js.map +1 -1
- package/package.json +18 -11
- package/skills/.claude-plugin/marketplace.json +16 -0
- package/skills/.claude-plugin/plugin.json +24 -0
- package/skills/README.md +44 -0
- package/skills/feltkit-agent/SKILL.md +84 -0
- package/skills/feltkit-build/SKILL.md +143 -0
- package/skills/feltkit-data/SKILL.md +79 -0
- package/skills/feltkit-operations/SKILL.md +72 -0
- package/skills/feltkit-services/SKILL.md +102 -0
- package/dist/dashboard/assets/index-CxJGCspE.js +0 -15
|
@@ -1,37 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AppPort Services on the application's FeltDB instance.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* FeltKit constructs the package's own `createServices({ db })` with the shared
|
|
5
|
+
* instance's "appport-services" handle and refuses to start unless
|
|
6
|
+
* `services.usesInstance(handle)` confirms the services run on it. Every effect passes
|
|
7
|
+
* AppPort Services' gateway, whose authorizer is FeltKit's policy (see
|
|
8
|
+
* Authority.serviceAuthorizer), and evidence is written to the same instance.
|
|
5
9
|
*
|
|
6
|
-
*
|
|
7
|
-
* shared instance's "appport-services" handle. FeltKit asserts the services
|
|
8
|
-
* really use that handle and refuses to start otherwise.
|
|
9
|
-
* 0.4.x "composed": `createServices()` would open a second FeltDB instance, so
|
|
10
|
-
* FeltKit builds Files from the package's public classes on the handle.
|
|
11
|
-
* Only Files is available on this path.
|
|
10
|
+
* Services:
|
|
12
11
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* files records with audit; bytes in the same instance (see below)
|
|
13
|
+
* notifications in-app channel, delivered inline; a principal reads only its own
|
|
14
|
+
* configuration variables for this environment; secrets are credential references
|
|
15
|
+
* apiKeys machine credentials, accepted by FeltKit as an identity with the
|
|
16
|
+
* roles in services.apiKeys.roles
|
|
17
|
+
* webhooks signed outbound delivery; signing secrets resolved by
|
|
18
|
+
* EnvironmentCredentials, never stored
|
|
19
|
+
* jobs durable background work; each job type runs a FeltKit function
|
|
20
|
+
* as the principal that enqueued it
|
|
21
|
+
* schedules recurring jobs
|
|
22
|
+
* intelligence provider/model configuration only (AppPort Services never runs a model)
|
|
16
23
|
*
|
|
17
|
-
*
|
|
24
|
+
* The packaged management pages for every enabled service are served by
|
|
25
|
+
* ManagementHost (server/management.ts) against `management()`; durable work is
|
|
26
|
+
* driven by `tick()`. Both run through the same gateway and policy as application code.
|
|
27
|
+
* Service state comes from `services.health()`; effect evidence from
|
|
28
|
+
* `services.evidence.findByRunId()`.
|
|
18
29
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* apikeys, webhooks, jobs, schedules, intelligence: not offered; see UNAVAILABLE.
|
|
24
|
-
*
|
|
25
|
-
* File *bytes*: AppPort Files stores metadata and a `storageKey`. The local FeltDB
|
|
26
|
-
* runtime has no content store (`storeContent` requires a FeltDB server), so FeltKit
|
|
27
|
-
* stores bytes in `_feltkit_file_content` in the same instance and verifies the
|
|
28
|
-
* SHA-256 checksum on read. Upload is two commits (metadata, then bytes); if the
|
|
29
|
-
* second fails FeltKit deletes the metadata through the same authorized service.
|
|
30
|
+
* File *bytes*: AppPort Files stores metadata and a `storageKey`; the bytes are in the
|
|
31
|
+
* same instance (runtime/content.ts). Upload stores the bytes first (verified on every
|
|
32
|
+
* read), then commits the metadata once, so a file record never points at bytes that
|
|
33
|
+
* were not stored; deleting a file removes its bytes.
|
|
30
34
|
*/
|
|
31
35
|
import type { StateFirstDB } from "@feltdb/core";
|
|
32
|
-
import {
|
|
33
|
-
import
|
|
34
|
-
|
|
36
|
+
import { type AppPortServices, type AppPortServicesHealth, type ConfigurationExportDocument, type ConfigurationImportReport, type EffectEvidenceLookup, type ServiceGateway, type VerifiedPrincipal } from "@appport/services";
|
|
37
|
+
import { FILE_CONTENT_COLLECTION } from "./content.js";
|
|
38
|
+
import { EnvironmentCredentials } from "./credentials.js";
|
|
39
|
+
import { type Authority, type Principal } from "./authority.js";
|
|
40
|
+
export { FILE_CONTENT_COLLECTION };
|
|
35
41
|
export declare const DEFAULT_MAX_FILE_BYTES: number;
|
|
36
42
|
export interface FileInfo {
|
|
37
43
|
id: string;
|
|
@@ -111,19 +117,53 @@ export interface ConfigurationWriter extends ConfigurationReader {
|
|
|
111
117
|
set(name: string, value: string): Promise<void>;
|
|
112
118
|
remove(name: string): Promise<void>;
|
|
113
119
|
}
|
|
120
|
+
/** Enqueue background work. The job runs later as the caller, re-authorized on every attempt. */
|
|
121
|
+
export interface JobsWriter {
|
|
122
|
+
enqueue(type: string, payload?: Record<string, unknown>, options?: {
|
|
123
|
+
runAt?: string;
|
|
124
|
+
maxAttempts?: number;
|
|
125
|
+
}): Promise<{
|
|
126
|
+
id: string;
|
|
127
|
+
status: string;
|
|
128
|
+
}>;
|
|
129
|
+
}
|
|
130
|
+
/** Emit an event to every registered webhook endpoint subscribed to it. Delivery is asynchronous. */
|
|
131
|
+
export interface WebhooksWriter {
|
|
132
|
+
emit(type: string, payload: Record<string, unknown>): Promise<{
|
|
133
|
+
deliveries: number;
|
|
134
|
+
}>;
|
|
135
|
+
}
|
|
114
136
|
export interface BoundServices {
|
|
115
137
|
files: FilesReader | FilesWriter;
|
|
116
138
|
notifications: NotificationsReader | NotificationsWriter;
|
|
117
139
|
configuration: ConfigurationReader | ConfigurationWriter;
|
|
140
|
+
/** Mutations only. */
|
|
141
|
+
jobs?: JobsWriter;
|
|
142
|
+
/** Mutations only. */
|
|
143
|
+
webhooks?: WebhooksWriter;
|
|
118
144
|
}
|
|
119
|
-
export type ServicesMode = "shared-instance" | "composed";
|
|
120
145
|
export interface ServicesConfig {
|
|
121
146
|
files?: boolean | {
|
|
122
147
|
maxBytes?: number;
|
|
123
148
|
};
|
|
124
149
|
notifications?: boolean;
|
|
125
150
|
configuration?: boolean;
|
|
151
|
+
/** API keys. `roles` are the roles a request authenticated by an API key holds. Default none. */
|
|
152
|
+
apiKeys?: boolean | {
|
|
153
|
+
roles?: string[];
|
|
154
|
+
};
|
|
155
|
+
webhooks?: boolean;
|
|
156
|
+
/** `handlers`: job type → FeltKit function (e.g. { "digest.send": "reports:sendDigest" }). */
|
|
157
|
+
jobs?: boolean | {
|
|
158
|
+
handlers?: Record<string, string>;
|
|
159
|
+
};
|
|
160
|
+
/** Recurring jobs. Needs jobs. */
|
|
161
|
+
schedules?: boolean;
|
|
162
|
+
intelligence?: boolean;
|
|
126
163
|
}
|
|
164
|
+
/** What FeltKit can honestly say about a service. */
|
|
165
|
+
export type ServiceState = "unavailable" | "available" | "unconfigured" | "configured" | "unhealthy";
|
|
166
|
+
export type JobRunner = (functionName: string, payload: unknown, principal: Principal, runId: string) => Promise<void>;
|
|
127
167
|
export interface ServiceStatus {
|
|
128
168
|
id: string;
|
|
129
169
|
name: string;
|
|
@@ -144,19 +184,37 @@ export interface ServiceStatus {
|
|
|
144
184
|
};
|
|
145
185
|
/** Whether application code can use it in this installation. */
|
|
146
186
|
available: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* unavailable cannot run here (reason in detail)
|
|
189
|
+
* available can run here; not enabled
|
|
190
|
+
* unconfigured enabled; nothing set up yet (no endpoints, handlers, variables…)
|
|
191
|
+
* configured enabled and set up
|
|
192
|
+
* unhealthy enabled, but its store failed a check or recent work failed
|
|
193
|
+
*/
|
|
194
|
+
state: ServiceState;
|
|
195
|
+
/** Counts from the service's own records, when it has them. Never values or secrets. */
|
|
196
|
+
summary?: Record<string, number>;
|
|
197
|
+
/** The packaged AppPort Services management page for it, when one is served. */
|
|
198
|
+
page?: string;
|
|
147
199
|
}
|
|
148
|
-
/** The first @appport/services release whose createServices() accepts the host's instance. */
|
|
149
|
-
export declare const SHARED_INSTANCE_SERVICES = "0.5.0";
|
|
150
|
-
export declare function supportsSharedInstance(version: string): boolean;
|
|
151
200
|
export declare const CONFIGURATION_ENVIRONMENT: Record<string, "development" | "staging" | "production">;
|
|
152
201
|
export declare class ServicesHost {
|
|
153
202
|
#private;
|
|
154
|
-
readonly mode: ServicesMode;
|
|
155
203
|
readonly gateway: ServiceGateway;
|
|
156
|
-
readonly files:
|
|
157
|
-
readonly notifications:
|
|
158
|
-
readonly configuration:
|
|
159
|
-
|
|
204
|
+
readonly files: AppPortServices["files"] | null;
|
|
205
|
+
readonly notifications: AppPortServices["notifications"] | null;
|
|
206
|
+
readonly configuration: AppPortServices["configuration"] | null;
|
|
207
|
+
readonly apiKeys: AppPortServices["apiKeys"] | null;
|
|
208
|
+
readonly webhooks: AppPortServices["webhooks"] | null;
|
|
209
|
+
readonly jobs: AppPortServices["jobs"] | null;
|
|
210
|
+
readonly schedules: AppPortServices["schedules"] | null;
|
|
211
|
+
readonly intelligence: AppPortServices["intelligence"] | null;
|
|
212
|
+
readonly credentials: EnvironmentCredentials;
|
|
213
|
+
/** Roles a request authenticated by an API key holds. */
|
|
214
|
+
readonly apiKeyRoles: readonly string[];
|
|
215
|
+
/** Job type → FeltKit function. */
|
|
216
|
+
readonly jobHandlers: Readonly<Record<string, string>>;
|
|
217
|
+
/** The instance handle every service store uses (`services.db`, checked with `usesInstance`). */
|
|
160
218
|
readonly db: StateFirstDB;
|
|
161
219
|
constructor(options: {
|
|
162
220
|
servicesDb: StateFirstDB;
|
|
@@ -165,13 +223,105 @@ export declare class ServicesHost {
|
|
|
165
223
|
authority: Authority;
|
|
166
224
|
config: ServicesConfig;
|
|
167
225
|
environment: string;
|
|
226
|
+
/** Resolves the principal behind durable work (jobs, deliveries) to its current roles. */
|
|
227
|
+
resolveDurable?: (subjectId: string, subjectKind: string) => Promise<Principal | null>;
|
|
228
|
+
/** Runs a job's FeltKit function as its principal. */
|
|
229
|
+
runJob?: JobRunner;
|
|
230
|
+
credentials?: EnvironmentCredentials;
|
|
231
|
+
/** Server-held API-key verifier key (>= 32 bytes). */
|
|
232
|
+
apiKeyVerifierKey?: string;
|
|
233
|
+
/** Development and tests: allow webhook deliveries to loopback/private addresses. */
|
|
234
|
+
allowPrivateWebhookDestinations?: boolean;
|
|
168
235
|
});
|
|
236
|
+
/**
|
|
237
|
+
* The services the packaged management pages and routes are mounted for: exactly
|
|
238
|
+
* the enabled ones, as the same objects application code uses.
|
|
239
|
+
*/
|
|
240
|
+
management(): Record<string, unknown>;
|
|
241
|
+
/**
|
|
242
|
+
* Run `work` with `principal` bound as a live invocation: any service effect inside is
|
|
243
|
+
* authorized by the gateway as that principal, exactly as from a function.
|
|
244
|
+
*/
|
|
245
|
+
asPrincipal<T>(principal: Principal, work: (verified: VerifiedPrincipal) => Promise<T>, requestId?: string): Promise<T>;
|
|
246
|
+
/** AppPort Services' capability manifest (name, service, effect, invocable). */
|
|
247
|
+
capabilities(): ReadonlyArray<{
|
|
248
|
+
name: string;
|
|
249
|
+
service: string;
|
|
250
|
+
operation: string;
|
|
251
|
+
effect: "observation" | "consequential";
|
|
252
|
+
invocable: boolean;
|
|
253
|
+
}>;
|
|
254
|
+
/**
|
|
255
|
+
* AppPort Services' own invoke(), as `principal`, for an enabled service only. The
|
|
256
|
+
* gateway authorizes it exactly as it would a function's or the console's request.
|
|
257
|
+
*/
|
|
258
|
+
invoke(capability: string, input: Record<string, unknown>, principal: Principal, signal?: AbortSignal, requestId?: string): Promise<unknown>;
|
|
259
|
+
/**
|
|
260
|
+
* AppPort Services' effect evidence for one run id (a FeltKit request id, a job attempt
|
|
261
|
+
* `<jobId>:<attempt>`, or a delivery attempt `<deliveryId>:<attempt>`), this application
|
|
262
|
+
* and tenant only. `state: "started"` means a completion was never recorded: the
|
|
263
|
+
* outcome is unknown, not failed.
|
|
264
|
+
*/
|
|
265
|
+
evidence(runId: string): Promise<EffectEvidenceLookup>;
|
|
266
|
+
/** AppPort Services' own health for this application's tenant. Trusted host read: counts only, authorizes nothing. */
|
|
267
|
+
health(options?: {
|
|
268
|
+
countLimit?: number;
|
|
269
|
+
}): Promise<AppPortServicesHealth>;
|
|
270
|
+
/** Identity claims for the management router: verified against this gateway, bound to a request. */
|
|
271
|
+
identify(principal: Principal, requestId: string): VerifiedPrincipal;
|
|
272
|
+
/**
|
|
273
|
+
* Drive durable work once: recurring schedules, due jobs, due webhook deliveries.
|
|
274
|
+
* Every attempt is authorized by AppPort Services as its own principal.
|
|
275
|
+
*/
|
|
276
|
+
tick(workerId: string): Promise<{
|
|
277
|
+
jobs: number;
|
|
278
|
+
deliveries: number;
|
|
279
|
+
scheduled: number;
|
|
280
|
+
}>;
|
|
169
281
|
get tenantId(): string;
|
|
282
|
+
/** Every credential reference the services hold, what uses it, and whether it resolves. Never a value. */
|
|
283
|
+
credentialReferences(): Promise<Array<{
|
|
284
|
+
ref: string;
|
|
285
|
+
variable: string | null;
|
|
286
|
+
present: boolean;
|
|
287
|
+
usedBy: string[];
|
|
288
|
+
}>>;
|
|
289
|
+
/** The tenant, application, and configuration environment this runtime's services use. */
|
|
290
|
+
get scope(): {
|
|
291
|
+
tenantId: string;
|
|
292
|
+
applicationId: string;
|
|
293
|
+
environment: "development" | "staging" | "production";
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* This environment's non-secret configuration as AppPort Services' versioned export
|
|
297
|
+
* document (`appport.configuration-export`): variables, credential binding names and
|
|
298
|
+
* references, active webhook endpoints (signing reference only), enabled schedules.
|
|
299
|
+
* Read as FeltKit's host-only transfer principal. Secret values never appear.
|
|
300
|
+
*/
|
|
301
|
+
exportConfiguration(): Promise<ConfigurationExportDocument>;
|
|
302
|
+
/**
|
|
303
|
+
* Plan (dryRun) or apply an export document to this environment through AppPort
|
|
304
|
+
* Services' own import: each write goes through its capability, credential bindings
|
|
305
|
+
* are never created (they are reported in `missingSecrets` for a person to attach),
|
|
306
|
+
* and a document carrying a secret value is refused. Schedules are reported as
|
|
307
|
+
* skipped, not imported: a schedule's jobs run as its creator, and the transfer
|
|
308
|
+
* principal is not a person FeltKit can resolve when they run.
|
|
309
|
+
*/
|
|
310
|
+
importConfiguration(input: unknown, options?: {
|
|
311
|
+
dryRun?: boolean;
|
|
312
|
+
overwrite?: boolean;
|
|
313
|
+
}): Promise<ConfigurationImportReport>;
|
|
170
314
|
/** Allow `principal` to cause service effects while request `requestId` runs. */
|
|
171
315
|
enter(requestId: string, principal: Principal | null): () => void;
|
|
172
316
|
/** The `ctx.services` object for one invocation. `reads` collects collections read, for reactivity. */
|
|
173
317
|
bind(principal: Principal | null, requestId: string, reads: Set<string>, writable: boolean, used?: Set<string>): BoundServices;
|
|
174
|
-
/** A live check:
|
|
318
|
+
/** A live check: AppPort Services' health() answers through the shared instance. Authorizes nothing. */
|
|
175
319
|
check(): Promise<void>;
|
|
176
|
-
|
|
320
|
+
/**
|
|
321
|
+
* Every service, with an honest state, from AppPort Services' own `health()` for this
|
|
322
|
+
* application's tenant. FeltKit adds only what it alone knows: whether the credential
|
|
323
|
+
* references endpoints sign with resolve in its custody, and which job types have a
|
|
324
|
+
* handler. No value, payload, secret, or credential is read into the result.
|
|
325
|
+
*/
|
|
326
|
+
status(connected: boolean): Promise<ServiceStatus[]>;
|
|
177
327
|
}
|