@feltdb/feltkit 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +22 -2
- package/bin/feltkit.js +3 -0
- package/dist/app.d.ts +247 -0
- package/dist/app.js +181 -0
- package/dist/app.js.map +1 -0
- package/dist/cli/deploy.d.ts +8 -0
- package/dist/cli/deploy.js +125 -0
- package/dist/cli/deploy.js.map +1 -0
- package/dist/cli/main.d.ts +9 -0
- package/dist/cli/main.js +581 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/cli/output.d.ts +18 -0
- package/dist/cli/output.js +87 -0
- package/dist/cli/output.js.map +1 -0
- 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/client/index.d.ts +125 -0
- package/dist/client/index.js +306 -0
- package/dist/client/index.js.map +1 -0
- package/dist/dashboard/assets/index--1Tqbv_A.css +1 -0
- package/dist/dashboard/assets/index-Bm4qCYpv.js +15 -0
- package/dist/dashboard/index.html +16 -0
- package/dist/errors.d.ts +33 -0
- package/dist/errors.js +56 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/react/index.d.ts +40 -0
- package/dist/react/index.js +85 -0
- package/dist/react/index.js.map +1 -0
- package/dist/runtime/activity.d.ts +110 -0
- package/dist/runtime/activity.js +113 -0
- package/dist/runtime/activity.js.map +1 -0
- 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 +98 -0
- package/dist/runtime/authority.js +240 -0
- package/dist/runtime/authority.js.map +1 -0
- package/dist/runtime/changes.d.ts +42 -0
- package/dist/runtime/changes.js +85 -0
- package/dist/runtime/changes.js.map +1 -0
- 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 +76 -0
- package/dist/runtime/context.js +2 -0
- package/dist/runtime/context.js.map +1 -0
- 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 +145 -0
- package/dist/runtime/data.js +439 -0
- package/dist/runtime/data.js.map +1 -0
- 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.d.ts +36 -0
- package/dist/runtime/environment.js +73 -0
- package/dist/runtime/environment.js.map +1 -0
- 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 +82 -0
- package/dist/runtime/instance.js +253 -0
- package/dist/runtime/instance.js.map +1 -0
- 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 +15 -0
- package/dist/runtime/loader.js +121 -0
- package/dist/runtime/loader.js.map +1 -0
- package/dist/runtime/projects.d.ts +52 -0
- package/dist/runtime/projects.js +141 -0
- package/dist/runtime/projects.js.map +1 -0
- 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 +227 -0
- package/dist/runtime/runtime.js +664 -0
- package/dist/runtime/runtime.js.map +1 -0
- package/dist/runtime/services.d.ts +327 -0
- package/dist/runtime/services.js +686 -0
- package/dist/runtime/services.js.map +1 -0
- package/dist/runtime/sessions.d.ts +44 -0
- package/dist/runtime/sessions.js +109 -0
- package/dist/runtime/sessions.js.map +1 -0
- package/dist/schema.d.ts +56 -0
- package/dist/schema.js +44 -0
- package/dist/schema.js.map +1 -0
- package/dist/server/admin.d.ts +141 -0
- package/dist/server/admin.js +828 -0
- package/dist/server/admin.js.map +1 -0
- package/dist/server/http.d.ts +19 -0
- package/dist/server/http.js +99 -0
- package/dist/server/http.js.map +1 -0
- package/dist/server/index.d.ts +54 -0
- package/dist/server/index.js +305 -0
- package/dist/server/index.js.map +1 -0
- 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 +214 -0
- package/dist/server/mcp.js +135 -0
- package/dist/server/mcp.js.map +1 -0
- 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.d.ts +60 -0
- package/dist/server/project.js +344 -0
- package/dist/server/project.js.map +1 -0
- package/dist/server/public.d.ts +14 -0
- package/dist/server/public.js +15 -0
- package/dist/server/public.js.map +1 -0
- package/dist/testing/index.d.ts +20 -0
- package/dist/testing/index.js +65 -0
- package/dist/testing/index.js.map +1 -0
- package/package.json +91 -4
- 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
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The FeltDB instance factory.
|
|
3
|
+
*
|
|
4
|
+
* This module is the only place in FeltKit that calls `createFeltDB`. It opens one
|
|
5
|
+
* authoritative instance per environment and hands out *component handles*: views of
|
|
6
|
+
* that same `StateFirstDB` that record which component touched which collection.
|
|
7
|
+
* Every layer (application functions, AppPort capabilities, AppPort Services, the
|
|
8
|
+
* activity log, sessions) receives a handle through explicit dependency injection.
|
|
9
|
+
*
|
|
10
|
+
* One owner per state directory:
|
|
11
|
+
*
|
|
12
|
+
* - across processes, FeltDB's own lock: `createFeltDB({ path })` takes `owner.lock`
|
|
13
|
+
* in the state directory and refuses any other process (STATE_LOCKED, mapped here
|
|
14
|
+
* to DUPLICATE_INSTANCE naming the owner, and its URL when it is a FeltKit server);
|
|
15
|
+
* - within a process, this factory: FeltDB lets handles in one process share the lock,
|
|
16
|
+
* so a second open for the same environment, or for another environment pointing
|
|
17
|
+
* at the same state, throws DUPLICATE_INSTANCE here.
|
|
18
|
+
*/
|
|
19
|
+
import { type StateFirstDB } from "@feltdb/core";
|
|
20
|
+
import type { EnvironmentDescriptor } from "./environment.js";
|
|
21
|
+
export interface InstanceIdentity {
|
|
22
|
+
/** Environment this instance belongs to. */
|
|
23
|
+
environment: string;
|
|
24
|
+
/** FeltDB deployment mode. */
|
|
25
|
+
mode: "local" | "remote" | "memory";
|
|
26
|
+
/** Where state lives: an absolute path, a server origin, or "memory". Never a credential. */
|
|
27
|
+
location: string;
|
|
28
|
+
namespace: string;
|
|
29
|
+
/** FeltDB's own instance identity (`db.instanceId()`). */
|
|
30
|
+
instanceId: string;
|
|
31
|
+
/** Resolved `@feltdb/core` version backing this instance. */
|
|
32
|
+
feltdbVersion: string;
|
|
33
|
+
durable: boolean;
|
|
34
|
+
openedAt: string;
|
|
35
|
+
pid: number;
|
|
36
|
+
}
|
|
37
|
+
export interface InstanceEvent {
|
|
38
|
+
type: "open" | "close" | "refused";
|
|
39
|
+
key: string;
|
|
40
|
+
environment: string;
|
|
41
|
+
at: string;
|
|
42
|
+
reason?: string;
|
|
43
|
+
}
|
|
44
|
+
export declare class StateInstance {
|
|
45
|
+
#private;
|
|
46
|
+
readonly identity: InstanceIdentity;
|
|
47
|
+
/** component → collections it reached through its handle */
|
|
48
|
+
readonly access: Map<string, Set<string>>;
|
|
49
|
+
constructor(db: StateFirstDB, identity: InstanceIdentity, factory: InstanceFactory, key: string);
|
|
50
|
+
get closed(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* A handle on this instance for one component. The handle *is* this instance's
|
|
53
|
+
* `StateFirstDB` (calls forward to it unchanged); it only records collection access.
|
|
54
|
+
*/
|
|
55
|
+
handle(component: string): StateFirstDB;
|
|
56
|
+
/** True when `db` is this instance or a handle on it. */
|
|
57
|
+
owns(db: unknown): boolean;
|
|
58
|
+
/** The raw instance. Reserved for the runtime and documented escape hatches. */
|
|
59
|
+
unsafeRaw(): StateFirstDB;
|
|
60
|
+
close(): Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
/** Identify which handle (if any) a value is. */
|
|
63
|
+
export declare function describeHandle(db: unknown): {
|
|
64
|
+
component: string;
|
|
65
|
+
} | undefined;
|
|
66
|
+
export declare function feltdbVersion(): string;
|
|
67
|
+
/**
|
|
68
|
+
* Opens FeltDB instances. A process normally uses one factory (`defaultInstanceFactory`);
|
|
69
|
+
* tests construct their own to observe every open.
|
|
70
|
+
*/
|
|
71
|
+
export declare class InstanceFactory {
|
|
72
|
+
#private;
|
|
73
|
+
readonly events: InstanceEvent[];
|
|
74
|
+
onEvent(listener: (event: InstanceEvent) => void): void;
|
|
75
|
+
/** Environments currently holding an instance from this factory. */
|
|
76
|
+
get openEnvironments(): string[];
|
|
77
|
+
open(environment: EnvironmentDescriptor): StateInstance;
|
|
78
|
+
/** @internal called by StateInstance.close */
|
|
79
|
+
released(key: string, environment: string): void;
|
|
80
|
+
}
|
|
81
|
+
/** The process's factory. Runtimes use it unless given another. */
|
|
82
|
+
export declare const defaultInstanceFactory: InstanceFactory;
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The FeltDB instance factory.
|
|
3
|
+
*
|
|
4
|
+
* This module is the only place in FeltKit that calls `createFeltDB`. It opens one
|
|
5
|
+
* authoritative instance per environment and hands out *component handles*: views of
|
|
6
|
+
* that same `StateFirstDB` that record which component touched which collection.
|
|
7
|
+
* Every layer (application functions, AppPort capabilities, AppPort Services, the
|
|
8
|
+
* activity log, sessions) receives a handle through explicit dependency injection.
|
|
9
|
+
*
|
|
10
|
+
* One owner per state directory:
|
|
11
|
+
*
|
|
12
|
+
* - across processes, FeltDB's own lock: `createFeltDB({ path })` takes `owner.lock`
|
|
13
|
+
* in the state directory and refuses any other process (STATE_LOCKED, mapped here
|
|
14
|
+
* to DUPLICATE_INSTANCE naming the owner, and its URL when it is a FeltKit server);
|
|
15
|
+
* - within a process, this factory: FeltDB lets handles in one process share the lock,
|
|
16
|
+
* so a second open for the same environment, or for another environment pointing
|
|
17
|
+
* at the same state, throws DUPLICATE_INSTANCE here.
|
|
18
|
+
*/
|
|
19
|
+
import { createFeltDB, FeltDBErrorCode, FeltDBServiceError, LocalStateLockedError } from "@feltdb/core";
|
|
20
|
+
import { createRequire } from "node:module";
|
|
21
|
+
import { mkdirSync } from "node:fs";
|
|
22
|
+
import { resolve } from "node:path";
|
|
23
|
+
import { FeltKitError } from "../errors.js";
|
|
24
|
+
import { readRuntimeRecord } from "./projects.js";
|
|
25
|
+
const HANDLE = Symbol.for("feltkit.state-handle");
|
|
26
|
+
export class StateInstance {
|
|
27
|
+
identity;
|
|
28
|
+
/** component → collections it reached through its handle */
|
|
29
|
+
access = new Map();
|
|
30
|
+
#db;
|
|
31
|
+
#handles = new Map();
|
|
32
|
+
#factory;
|
|
33
|
+
#key;
|
|
34
|
+
#closed = false;
|
|
35
|
+
constructor(db, identity, factory, key) {
|
|
36
|
+
this.#db = db;
|
|
37
|
+
this.identity = identity;
|
|
38
|
+
this.#factory = factory;
|
|
39
|
+
this.#key = key;
|
|
40
|
+
}
|
|
41
|
+
get closed() {
|
|
42
|
+
return this.#closed;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A handle on this instance for one component. The handle *is* this instance's
|
|
46
|
+
* `StateFirstDB` (calls forward to it unchanged); it only records collection access.
|
|
47
|
+
*/
|
|
48
|
+
handle(component) {
|
|
49
|
+
const existing = this.#handles.get(component);
|
|
50
|
+
if (existing)
|
|
51
|
+
return existing;
|
|
52
|
+
const db = this.#db;
|
|
53
|
+
const record = (collection) => {
|
|
54
|
+
if (typeof collection !== "string")
|
|
55
|
+
return;
|
|
56
|
+
let set = this.access.get(component);
|
|
57
|
+
if (!set)
|
|
58
|
+
this.access.set(component, (set = new Set()));
|
|
59
|
+
set.add(collection);
|
|
60
|
+
};
|
|
61
|
+
const proxy = new Proxy(db, {
|
|
62
|
+
get: (target, property) => {
|
|
63
|
+
if (property === HANDLE)
|
|
64
|
+
return { instance: this, component };
|
|
65
|
+
if (property === "collection")
|
|
66
|
+
return (name) => (record(name), target.collection(name));
|
|
67
|
+
if (property === "query" || property === "explain") {
|
|
68
|
+
return (request) => (record(request?.collection), target[property](request));
|
|
69
|
+
}
|
|
70
|
+
if (property === "transaction") {
|
|
71
|
+
return (build, options) => {
|
|
72
|
+
if (build && typeof build === "object" && Array.isArray(build.operations)) {
|
|
73
|
+
for (const op of build.operations)
|
|
74
|
+
record(op.collection);
|
|
75
|
+
}
|
|
76
|
+
return target.transaction(build, options);
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (property === "close") {
|
|
80
|
+
return async () => {
|
|
81
|
+
throw new FeltKitError("CONFIGURATION", `Component "${component}" may not close the shared FeltDB instance; the runtime owns its lifecycle.`);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const value = Reflect.get(target, property, target);
|
|
85
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
this.#handles.set(component, proxy);
|
|
89
|
+
return proxy;
|
|
90
|
+
}
|
|
91
|
+
/** True when `db` is this instance or a handle on it. */
|
|
92
|
+
owns(db) {
|
|
93
|
+
if (db === this.#db)
|
|
94
|
+
return true;
|
|
95
|
+
if (typeof db !== "object" || db === null)
|
|
96
|
+
return false;
|
|
97
|
+
const marker = db[HANDLE];
|
|
98
|
+
return marker?.instance === this;
|
|
99
|
+
}
|
|
100
|
+
/** The raw instance. Reserved for the runtime and documented escape hatches. */
|
|
101
|
+
unsafeRaw() {
|
|
102
|
+
return this.#db;
|
|
103
|
+
}
|
|
104
|
+
async close() {
|
|
105
|
+
if (this.#closed)
|
|
106
|
+
return;
|
|
107
|
+
this.#closed = true;
|
|
108
|
+
try {
|
|
109
|
+
await this.#db.close();
|
|
110
|
+
}
|
|
111
|
+
finally {
|
|
112
|
+
this.#factory.released(this.#key, this.identity.environment);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/** Identify which handle (if any) a value is. */
|
|
117
|
+
export function describeHandle(db) {
|
|
118
|
+
if (typeof db !== "object" || db === null)
|
|
119
|
+
return undefined;
|
|
120
|
+
const marker = db[HANDLE];
|
|
121
|
+
return marker?.component ? { component: marker.component } : undefined;
|
|
122
|
+
}
|
|
123
|
+
let cachedVersion;
|
|
124
|
+
export function feltdbVersion() {
|
|
125
|
+
if (cachedVersion)
|
|
126
|
+
return cachedVersion;
|
|
127
|
+
try {
|
|
128
|
+
const require = createRequire(import.meta.url);
|
|
129
|
+
cachedVersion = require("@feltdb/core/package.json").version;
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
cachedVersion = "unknown";
|
|
133
|
+
}
|
|
134
|
+
return cachedVersion;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Opens FeltDB instances. A process normally uses one factory (`defaultInstanceFactory`);
|
|
138
|
+
* tests construct their own to observe every open.
|
|
139
|
+
*/
|
|
140
|
+
export class InstanceFactory {
|
|
141
|
+
#open = new Map(); // state key → environment
|
|
142
|
+
events = [];
|
|
143
|
+
#listener;
|
|
144
|
+
onEvent(listener) {
|
|
145
|
+
this.#listener = listener;
|
|
146
|
+
}
|
|
147
|
+
/** Environments currently holding an instance from this factory. */
|
|
148
|
+
get openEnvironments() {
|
|
149
|
+
return [...this.#open.values()];
|
|
150
|
+
}
|
|
151
|
+
open(environment) {
|
|
152
|
+
const { key, options, identity } = this.#plan(environment);
|
|
153
|
+
for (const [openKey, openEnv] of this.#open) {
|
|
154
|
+
if (openKey === key || openEnv === environment.name) {
|
|
155
|
+
const reason = openKey === key && openEnv !== environment.name
|
|
156
|
+
? `Environment "${environment.name}" points at the same state as the open "${openEnv}" environment (${identity.location}). Environments must not share state.`
|
|
157
|
+
: `A FeltDB instance for environment "${environment.name}" is already open in this process. Reuse the runtime's instance instead of opening another.`;
|
|
158
|
+
this.#emit({ type: "refused", key, environment: environment.name, at: new Date().toISOString(), reason });
|
|
159
|
+
throw new FeltKitError("DUPLICATE_INSTANCE", reason, {
|
|
160
|
+
hint: "Pass the existing runtime (or its instance) to the component that needs state.",
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (identity.mode === "local")
|
|
165
|
+
mkdirSync(identity.location, { recursive: true });
|
|
166
|
+
let db;
|
|
167
|
+
try {
|
|
168
|
+
db = createFeltDB(options);
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
if (error instanceof LocalStateLockedError || (error instanceof FeltDBServiceError && error.code === FeltDBErrorCode.STATE_LOCKED)) {
|
|
172
|
+
const reason = lockedReason(environment, error);
|
|
173
|
+
this.#emit({ type: "refused", key, environment: environment.name, at: new Date().toISOString(), reason });
|
|
174
|
+
throw new FeltKitError("DUPLICATE_INSTANCE", reason, {
|
|
175
|
+
hint: "Use that server, or stop it first. Two processes on one environment would mean two FeltDB instances on the same state.",
|
|
176
|
+
details: { lockPath: error.lockPath ?? null, owner: error.owner ?? null },
|
|
177
|
+
cause: error,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
throw new FeltKitError("UNAVAILABLE", `FeltDB could not open ${identity.location}: ${error.message}`, { cause: error });
|
|
181
|
+
}
|
|
182
|
+
this.#open.set(key, environment.name);
|
|
183
|
+
this.#emit({ type: "open", key, environment: environment.name, at: new Date().toISOString() });
|
|
184
|
+
return new StateInstance(db, { ...identity, instanceId: safeInstanceId(db) }, this, key);
|
|
185
|
+
}
|
|
186
|
+
/** @internal called by StateInstance.close */
|
|
187
|
+
released(key, environment) {
|
|
188
|
+
this.#open.delete(key);
|
|
189
|
+
this.#emit({ type: "close", key, environment, at: new Date().toISOString() });
|
|
190
|
+
}
|
|
191
|
+
#emit(event) {
|
|
192
|
+
this.events.push(event);
|
|
193
|
+
this.#listener?.(event);
|
|
194
|
+
}
|
|
195
|
+
#plan(environment) {
|
|
196
|
+
const base = {
|
|
197
|
+
environment: environment.name,
|
|
198
|
+
namespace: environment.namespace,
|
|
199
|
+
feltdbVersion: feltdbVersion(),
|
|
200
|
+
openedAt: new Date().toISOString(),
|
|
201
|
+
pid: process.pid,
|
|
202
|
+
};
|
|
203
|
+
const storage = environment.storage;
|
|
204
|
+
if (storage.kind === "local") {
|
|
205
|
+
const path = resolve(storage.path);
|
|
206
|
+
return {
|
|
207
|
+
key: `local:${path}`,
|
|
208
|
+
options: { mode: "local", namespace: environment.namespace, path },
|
|
209
|
+
identity: { ...base, mode: "local", location: path, durable: true, instanceId: "" },
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
if (storage.kind === "remote") {
|
|
213
|
+
const origin = new URL(storage.url).origin;
|
|
214
|
+
return {
|
|
215
|
+
key: `remote:${origin}:${environment.namespace}:${storage.applicationId ?? ""}`,
|
|
216
|
+
options: {
|
|
217
|
+
namespace: environment.namespace,
|
|
218
|
+
server: {
|
|
219
|
+
url: storage.url,
|
|
220
|
+
...(storage.token ? { token: storage.token } : {}),
|
|
221
|
+
...(storage.applicationId ? { applicationId: storage.applicationId } : {}),
|
|
222
|
+
environment: environment.name,
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
identity: { ...base, mode: "remote", location: origin, durable: true, instanceId: "" },
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
return {
|
|
229
|
+
key: `memory:${environment.namespace}:${environment.name}`,
|
|
230
|
+
options: { memory: true, namespace: `${environment.namespace}-${environment.name}` },
|
|
231
|
+
identity: { ...base, mode: "memory", location: "memory", durable: false, instanceId: "" },
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/** Who holds the state: the FeltKit server's runtime record when there is one, else FeltDB's lock owner. */
|
|
236
|
+
function lockedReason(environment, error) {
|
|
237
|
+
const server = readRuntimeRecord(environment.runtimeDir);
|
|
238
|
+
if (server)
|
|
239
|
+
return `The ${environment.name} environment is already running (pid ${server.pid}) at ${server.url}.`;
|
|
240
|
+
const owner = error.owner ?? {};
|
|
241
|
+
return `The ${environment.name} environment's state is already open in another process${owner.pid ? ` (pid ${owner.pid}${owner.host ? ` on ${owner.host}` : ""})` : ""}; FeltDB holds ${error.lockPath ?? "its owner lock"}.`;
|
|
242
|
+
}
|
|
243
|
+
function safeInstanceId(db) {
|
|
244
|
+
try {
|
|
245
|
+
return db.instanceId();
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
return "unknown";
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/** The process's factory. Runtimes use it unless given another. */
|
|
252
|
+
export const defaultInstanceFactory = new InstanceFactory();
|
|
253
|
+
//# sourceMappingURL=instance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance.js","sourceRoot":"","sources":["../../src/runtime/instance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,qBAAqB,EAAqB,MAAM,cAAc,CAAC;AAC3H,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AA2BlD,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;AAElD,MAAM,OAAO,aAAa;IACf,QAAQ,CAAmB;IACpC,4DAA4D;IACnD,MAAM,G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;AAED,mEAAmE;AACnE,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { CapabilityIntegration, FailureDeclaration, VerificationEvidence } from "@appport/protocol";
|
|
2
|
+
import type { IntegrationDefinition, IntegrationOperation } from "../app.js";
|
|
3
|
+
import { type Principal } from "./authority.js";
|
|
4
|
+
import type { FeltKitRuntime } from "./runtime.js";
|
|
5
|
+
export declare const INTEGRATION_CALLS = "_feltkit_integration_calls";
|
|
6
|
+
export type CallState = "started" | "succeeded" | "failed" | "unknown";
|
|
7
|
+
export interface IntegrationCall {
|
|
8
|
+
id: string;
|
|
9
|
+
integration: string;
|
|
10
|
+
operation: string;
|
|
11
|
+
capability: string;
|
|
12
|
+
effect: "observation" | "consequential";
|
|
13
|
+
state: CallState;
|
|
14
|
+
principal: {
|
|
15
|
+
id: string;
|
|
16
|
+
type: string;
|
|
17
|
+
};
|
|
18
|
+
idempotencyKey?: string;
|
|
19
|
+
request: {
|
|
20
|
+
method: string;
|
|
21
|
+
origin: string;
|
|
22
|
+
path: string;
|
|
23
|
+
};
|
|
24
|
+
/** The capability input, redacted: verification probes may refer to it. */
|
|
25
|
+
input: Record<string, unknown>;
|
|
26
|
+
startedAt: string;
|
|
27
|
+
finishedAt?: string;
|
|
28
|
+
status?: number;
|
|
29
|
+
/** Redacted. */
|
|
30
|
+
output?: unknown;
|
|
31
|
+
error?: {
|
|
32
|
+
code: string;
|
|
33
|
+
message: string;
|
|
34
|
+
};
|
|
35
|
+
/** How the state was established. */
|
|
36
|
+
determinedBy?: "response" | "verification" | "person";
|
|
37
|
+
verification?: VerificationEvidence;
|
|
38
|
+
environment: string;
|
|
39
|
+
}
|
|
40
|
+
export interface IntegrationStatus {
|
|
41
|
+
name: string;
|
|
42
|
+
description: string | null;
|
|
43
|
+
baseUrl: {
|
|
44
|
+
value: string | null;
|
|
45
|
+
source: "literal" | "env" | "development-default" | "missing";
|
|
46
|
+
variable?: string;
|
|
47
|
+
};
|
|
48
|
+
credential: {
|
|
49
|
+
ref: string | null;
|
|
50
|
+
variable: string | null;
|
|
51
|
+
present: boolean;
|
|
52
|
+
} | null;
|
|
53
|
+
health: {
|
|
54
|
+
path: string;
|
|
55
|
+
} | null;
|
|
56
|
+
operations: Array<{
|
|
57
|
+
name: string;
|
|
58
|
+
capability: string;
|
|
59
|
+
method: string;
|
|
60
|
+
path: string;
|
|
61
|
+
effect: "observation" | "consequential";
|
|
62
|
+
access: string;
|
|
63
|
+
idempotent: boolean;
|
|
64
|
+
verifiable: boolean;
|
|
65
|
+
/** What a failure without a definite answer means for retrying, as published. */
|
|
66
|
+
retry: FailureDeclaration["retry"] | null;
|
|
67
|
+
description: string | null;
|
|
68
|
+
}>;
|
|
69
|
+
problems: Array<{
|
|
70
|
+
message: string;
|
|
71
|
+
fix: string;
|
|
72
|
+
}>;
|
|
73
|
+
}
|
|
74
|
+
/** The published contract for one operation (`appport.integration/1`). */
|
|
75
|
+
export declare function integrationDescriptor(integration: IntegrationDefinition, op: IntegrationOperation & {
|
|
76
|
+
capability: string;
|
|
77
|
+
}): CapabilityIntegration;
|
|
78
|
+
export declare class IntegrationHost {
|
|
79
|
+
#private;
|
|
80
|
+
constructor(runtime: FeltKitRuntime);
|
|
81
|
+
definitions(): IntegrationDefinition[];
|
|
82
|
+
/** The operation behind a capability name, if it is an integration's. */
|
|
83
|
+
operationFor(capability: string): {
|
|
84
|
+
integration: IntegrationDefinition;
|
|
85
|
+
name: string;
|
|
86
|
+
op: IntegrationDefinition["operations"][string];
|
|
87
|
+
} | null;
|
|
88
|
+
status(integration: IntegrationDefinition): IntegrationStatus;
|
|
89
|
+
/**
|
|
90
|
+
* Call one operation as `principal`. Reached only through the operation's AppPort
|
|
91
|
+
* capability, which has validated the input and authorized `principal` for the
|
|
92
|
+
* operation's permission before this runs. Throws OUTCOME_UNKNOWN when a consequential
|
|
93
|
+
* request was sent without a definite answer.
|
|
94
|
+
*/
|
|
95
|
+
invoke(capability: string, input: Record<string, unknown>, options: {
|
|
96
|
+
principal: Principal | null;
|
|
97
|
+
requestId?: string;
|
|
98
|
+
idempotencyKey?: string;
|
|
99
|
+
signal?: AbortSignal;
|
|
100
|
+
via?: string;
|
|
101
|
+
}): Promise<unknown>;
|
|
102
|
+
call(requestId: string): Promise<IntegrationCall | null>;
|
|
103
|
+
calls(filter?: {
|
|
104
|
+
integration?: string;
|
|
105
|
+
state?: CallState;
|
|
106
|
+
limit?: number;
|
|
107
|
+
}): Promise<IntegrationCall[]>;
|
|
108
|
+
/**
|
|
109
|
+
* Establish an unknown outcome from the API's own state, through the declared probe,
|
|
110
|
+
* as `principal`. Never re-sends the call. Returns the call as it now stands.
|
|
111
|
+
*/
|
|
112
|
+
verify(requestId: string, principal: Principal): Promise<IntegrationCall>;
|
|
113
|
+
/** Probe the API's declared health path. Read-only; no credential is sent unless declared. */
|
|
114
|
+
check(name: string): Promise<{
|
|
115
|
+
ok: boolean;
|
|
116
|
+
status?: number;
|
|
117
|
+
message: string;
|
|
118
|
+
durationMs: number;
|
|
119
|
+
}>;
|
|
120
|
+
}
|