@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.
Files changed (129) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +22 -2
  3. package/bin/feltkit.js +3 -0
  4. package/dist/app.d.ts +247 -0
  5. package/dist/app.js +181 -0
  6. package/dist/app.js.map +1 -0
  7. package/dist/cli/deploy.d.ts +8 -0
  8. package/dist/cli/deploy.js +125 -0
  9. package/dist/cli/deploy.js.map +1 -0
  10. package/dist/cli/main.d.ts +9 -0
  11. package/dist/cli/main.js +581 -0
  12. package/dist/cli/main.js.map +1 -0
  13. package/dist/cli/output.d.ts +18 -0
  14. package/dist/cli/output.js +87 -0
  15. package/dist/cli/output.js.map +1 -0
  16. package/dist/cli/skills.d.ts +39 -0
  17. package/dist/cli/skills.js +125 -0
  18. package/dist/cli/skills.js.map +1 -0
  19. package/dist/client/index.d.ts +125 -0
  20. package/dist/client/index.js +306 -0
  21. package/dist/client/index.js.map +1 -0
  22. package/dist/dashboard/assets/index--1Tqbv_A.css +1 -0
  23. package/dist/dashboard/assets/index-Bm4qCYpv.js +15 -0
  24. package/dist/dashboard/index.html +16 -0
  25. package/dist/errors.d.ts +33 -0
  26. package/dist/errors.js +56 -0
  27. package/dist/errors.js.map +1 -0
  28. package/dist/index.d.ts +18 -0
  29. package/dist/index.js +12 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/react/index.d.ts +40 -0
  32. package/dist/react/index.js +85 -0
  33. package/dist/react/index.js.map +1 -0
  34. package/dist/runtime/activity.d.ts +110 -0
  35. package/dist/runtime/activity.js +113 -0
  36. package/dist/runtime/activity.js.map +1 -0
  37. package/dist/runtime/agent.d.ts +353 -0
  38. package/dist/runtime/agent.js +1345 -0
  39. package/dist/runtime/agent.js.map +1 -0
  40. package/dist/runtime/authority.d.ts +98 -0
  41. package/dist/runtime/authority.js +240 -0
  42. package/dist/runtime/authority.js.map +1 -0
  43. package/dist/runtime/changes.d.ts +42 -0
  44. package/dist/runtime/changes.js +85 -0
  45. package/dist/runtime/changes.js.map +1 -0
  46. package/dist/runtime/content.d.ts +33 -0
  47. package/dist/runtime/content.js +46 -0
  48. package/dist/runtime/content.js.map +1 -0
  49. package/dist/runtime/context.d.ts +76 -0
  50. package/dist/runtime/context.js +2 -0
  51. package/dist/runtime/context.js.map +1 -0
  52. package/dist/runtime/credentials.d.ts +42 -0
  53. package/dist/runtime/credentials.js +32 -0
  54. package/dist/runtime/credentials.js.map +1 -0
  55. package/dist/runtime/data.d.ts +145 -0
  56. package/dist/runtime/data.js +439 -0
  57. package/dist/runtime/data.js.map +1 -0
  58. package/dist/runtime/decisions.d.ts +131 -0
  59. package/dist/runtime/decisions.js +301 -0
  60. package/dist/runtime/decisions.js.map +1 -0
  61. package/dist/runtime/environment.d.ts +36 -0
  62. package/dist/runtime/environment.js +73 -0
  63. package/dist/runtime/environment.js.map +1 -0
  64. package/dist/runtime/idempotency.d.ts +37 -0
  65. package/dist/runtime/idempotency.js +88 -0
  66. package/dist/runtime/idempotency.js.map +1 -0
  67. package/dist/runtime/instance.d.ts +82 -0
  68. package/dist/runtime/instance.js +253 -0
  69. package/dist/runtime/instance.js.map +1 -0
  70. package/dist/runtime/integrations.d.ts +120 -0
  71. package/dist/runtime/integrations.js +412 -0
  72. package/dist/runtime/integrations.js.map +1 -0
  73. package/dist/runtime/loader.d.ts +15 -0
  74. package/dist/runtime/loader.js +121 -0
  75. package/dist/runtime/loader.js.map +1 -0
  76. package/dist/runtime/projects.d.ts +52 -0
  77. package/dist/runtime/projects.js +141 -0
  78. package/dist/runtime/projects.js.map +1 -0
  79. package/dist/runtime/readiness.d.ts +29 -0
  80. package/dist/runtime/readiness.js +154 -0
  81. package/dist/runtime/readiness.js.map +1 -0
  82. package/dist/runtime/runtime.d.ts +227 -0
  83. package/dist/runtime/runtime.js +664 -0
  84. package/dist/runtime/runtime.js.map +1 -0
  85. package/dist/runtime/services.d.ts +327 -0
  86. package/dist/runtime/services.js +686 -0
  87. package/dist/runtime/services.js.map +1 -0
  88. package/dist/runtime/sessions.d.ts +44 -0
  89. package/dist/runtime/sessions.js +109 -0
  90. package/dist/runtime/sessions.js.map +1 -0
  91. package/dist/schema.d.ts +56 -0
  92. package/dist/schema.js +44 -0
  93. package/dist/schema.js.map +1 -0
  94. package/dist/server/admin.d.ts +141 -0
  95. package/dist/server/admin.js +828 -0
  96. package/dist/server/admin.js.map +1 -0
  97. package/dist/server/http.d.ts +19 -0
  98. package/dist/server/http.js +99 -0
  99. package/dist/server/http.js.map +1 -0
  100. package/dist/server/index.d.ts +54 -0
  101. package/dist/server/index.js +305 -0
  102. package/dist/server/index.js.map +1 -0
  103. package/dist/server/management.d.ts +12 -0
  104. package/dist/server/management.js +177 -0
  105. package/dist/server/management.js.map +1 -0
  106. package/dist/server/mcp.d.ts +214 -0
  107. package/dist/server/mcp.js +135 -0
  108. package/dist/server/mcp.js.map +1 -0
  109. package/dist/server/operators.d.ts +77 -0
  110. package/dist/server/operators.js +162 -0
  111. package/dist/server/operators.js.map +1 -0
  112. package/dist/server/project.d.ts +60 -0
  113. package/dist/server/project.js +344 -0
  114. package/dist/server/project.js.map +1 -0
  115. package/dist/server/public.d.ts +14 -0
  116. package/dist/server/public.js +15 -0
  117. package/dist/server/public.js.map +1 -0
  118. package/dist/testing/index.d.ts +20 -0
  119. package/dist/testing/index.js +65 -0
  120. package/dist/testing/index.js.map +1 -0
  121. package/package.json +91 -4
  122. package/skills/.claude-plugin/marketplace.json +16 -0
  123. package/skills/.claude-plugin/plugin.json +24 -0
  124. package/skills/README.md +44 -0
  125. package/skills/feltkit-agent/SKILL.md +84 -0
  126. package/skills/feltkit-build/SKILL.md +143 -0
  127. package/skills/feltkit-data/SKILL.md +79 -0
  128. package/skills/feltkit-operations/SKILL.md +72 -0
  129. package/skills/feltkit-services/SKILL.md +102 -0
@@ -0,0 +1,227 @@
1
+ /**
2
+ * The FeltKit runtime: one application, one environment, one FeltDB instance.
3
+ *
4
+ * Lifecycle: start() opens the environment's instance through the factory, then
5
+ * builds every component on handles of that instance. If any step fails, everything
6
+ * already opened is closed before the error is rethrown. reload() swaps the
7
+ * application definition (functions, capabilities, policy) without reopening state.
8
+ * close() is idempotent and releases the instance.
9
+ */
10
+ import { type Authorizer } from "@appport/sdk";
11
+ import type { AppPortApplication } from "@appport/sdk";
12
+ import type { FeltKitApp, FunctionDefinition, PrincipalInput } from "../app.js";
13
+ import { IntegrationHost } from "./integrations.js";
14
+ import { type FeltKitErrorJSON } from "../errors.js";
15
+ import { ActivityLog, type ActivityVia } from "./activity.js";
16
+ import { Authority, type Principal } from "./authority.js";
17
+ import { ChangeFeed } from "./changes.js";
18
+ import type { Logger } from "./context.js";
19
+ import { ModelHost } from "./decisions.js";
20
+ import { type EnvironmentDescriptor } from "./environment.js";
21
+ import { type InstanceFactory, type StateInstance } from "./instance.js";
22
+ import { ServicesHost } from "./services.js";
23
+ import { AgentHost, type AgentHooks } from "./agent.js";
24
+ import { FeltDbIdempotencyStore } from "./idempotency.js";
25
+ import { FeltDbSessionStore } from "./sessions.js";
26
+ export interface LoadedProject {
27
+ app: FeltKitApp;
28
+ /** "module:export" → definition */
29
+ functions: Map<string, FunctionDefinition>;
30
+ modules: string[];
31
+ loadedAt: string;
32
+ }
33
+ export interface CallOptions {
34
+ principal: Principal | null;
35
+ via: ActivityVia;
36
+ requestId?: string;
37
+ /** Set when AppPort dispatched the call. */
38
+ capability?: {
39
+ name: string;
40
+ version: number;
41
+ };
42
+ appportDecisionId?: string;
43
+ /**
44
+ * AppPort's replay key for this call (`idempotencyStorageKey`: key, capability, version and
45
+ * the caller's session or principal). A mutation commits under a FeltDB transaction id
46
+ * derived from it, so a retry after an unconfirmed commit is answered by FeltDB's
47
+ * transaction-id binding (the original commit, or IDEMPOTENCY_CONFLICT) instead of writing
48
+ * again. AppPort releases its own claim when the handler throws, whatever the error (A5).
49
+ */
50
+ idempotencyReplayKey?: string;
51
+ }
52
+ export type CallResult = {
53
+ ok: true;
54
+ value: unknown;
55
+ reads: string[];
56
+ requestId: string;
57
+ } | {
58
+ ok: false;
59
+ error: FeltKitErrorJSON;
60
+ requestId: string;
61
+ };
62
+ export interface RuntimeStartOptions {
63
+ project: LoadedProject;
64
+ environment: EnvironmentDescriptor;
65
+ factory?: InstanceFactory;
66
+ logger?: Logger;
67
+ /**
68
+ * Drive durable service work (jobs, schedules, webhook deliveries) every this many
69
+ * milliseconds. Default 1000; 0 disables the loop (tests call `runServices()`).
70
+ */
71
+ workerIntervalMs?: number;
72
+ /** Deadline for one agent action. Default 30 s. */
73
+ agentActionTimeoutMs?: number;
74
+ /** Tests only: fault-injection points in the agent's action lifecycle (see AgentHooks). */
75
+ agentHooks?: AgentHooks;
76
+ }
77
+ export type RuntimeState = "starting" | "ready" | "closing" | "closed" | "failed";
78
+ export interface FunctionInfo {
79
+ name: string;
80
+ kind: "query" | "mutation";
81
+ access: string;
82
+ description?: string;
83
+ args: Record<string, unknown>;
84
+ returns?: unknown;
85
+ capability?: {
86
+ name: string;
87
+ version: number;
88
+ };
89
+ }
90
+ export declare const silentLogger: Logger;
91
+ export declare class FeltKitRuntime {
92
+ #private;
93
+ readonly environment: EnvironmentDescriptor;
94
+ readonly instance: StateInstance;
95
+ readonly sessions: FeltDbSessionStore;
96
+ readonly activity: ActivityLog;
97
+ readonly changes: ChangeFeed;
98
+ /** AppPort's idempotency records, in this instance. */
99
+ readonly idempotency: FeltDbIdempotencyStore;
100
+ /** The environment's model decisions (runtime/decisions.ts). */
101
+ readonly models: ModelHost;
102
+ /** HTTP integrations declared with app.integration() (runtime/integrations.ts). */
103
+ readonly integrations: IntegrationHost;
104
+ readonly logger: Logger;
105
+ readonly startedAt: string;
106
+ readonly recentErrors: Array<{
107
+ at: string;
108
+ name: string;
109
+ code: string;
110
+ message: string;
111
+ requestId: string;
112
+ }>;
113
+ private constructor();
114
+ static start(options: RuntimeStartOptions): Promise<FeltKitRuntime>;
115
+ get state(): RuntimeState;
116
+ get app(): FeltKitApp;
117
+ get project(): LoadedProject;
118
+ get authority(): Authority;
119
+ get services(): ServicesHost;
120
+ /** The FeltKit agent (FeltDB agent runtime + agent state, acting through AppPort). */
121
+ /** Whether this process drives durable service work (jobs, schedules, deliveries). */
122
+ get workerRunning(): boolean;
123
+ get agent(): AgentHost;
124
+ /** The AppPort application for the current definition. Replaced on reload. */
125
+ get appport(): AppPortApplication;
126
+ get authorizer(): Authorizer;
127
+ get generation(): number;
128
+ onReload(listener: () => void): () => void;
129
+ /** Swap in a new application definition. State, sessions, and history are untouched. */
130
+ reload(project: LoadedProject): Promise<void>;
131
+ functions(): FunctionInfo[];
132
+ /**
133
+ * Resolve a bearer token to a principal: a FeltKit session, or (when services.apiKeys
134
+ * is enabled) an AppPort Services API key holding services.apiKeys.roles. Unknown,
135
+ * expired, and revoked credentials resolve to null.
136
+ */
137
+ principalForToken(token: string | undefined): Promise<Principal | null>;
138
+ /**
139
+ * A principal as it is now, by id: a live API key, else the most recent active session.
140
+ * With `devUsers`, development also resolves declared dev identities (the agent's
141
+ * Studio-created tasks act as them). Durable service work never uses that fallback.
142
+ */
143
+ resolvePrincipal(subjectId: string, options?: {
144
+ devUsers?: boolean;
145
+ }): Promise<Principal | null>;
146
+ /** Drive durable service work once (jobs, schedules, webhook deliveries). */
147
+ runServices(): Promise<{
148
+ jobs: number;
149
+ deliveries: number;
150
+ scheduled: number;
151
+ }>;
152
+ /** Issue a session. Development sign-in, the CLI, and auth hooks all come through here. */
153
+ issueSession(input: PrincipalInput | Principal, options: {
154
+ kind: string;
155
+ label?: string;
156
+ ttlMs?: number;
157
+ via: ActivityVia;
158
+ actor?: Principal | null;
159
+ }): Promise<{
160
+ token: string;
161
+ principal: Principal;
162
+ expiresAt: string | undefined;
163
+ }>;
164
+ /** Run a query or mutation as `principal`. Authority is checked before the handler runs. */
165
+ call(name: string, rawArgs: unknown, options: CallOptions): Promise<CallResult>;
166
+ /** An MCP tool surface for one agent identity, backed by AppPort's MCP bridge. */
167
+ mcpBridge(principal: Principal | null, session?: Awaited<ReturnType<FeltDbSessionStore["get"]>>): import("@appport/sdk").McpBridge;
168
+ overview(): {
169
+ application: {
170
+ name: string;
171
+ version: string;
172
+ description: string | null;
173
+ };
174
+ state: RuntimeState;
175
+ startedAt: string;
176
+ generation: number;
177
+ loadedAt: string;
178
+ environment: {
179
+ name: import("./environment.js").EnvironmentName;
180
+ production: boolean;
181
+ development: boolean;
182
+ };
183
+ instance: {
184
+ storage: string;
185
+ location: string;
186
+ sequence: number;
187
+ environment: string;
188
+ mode: "local" | "remote" | "memory";
189
+ namespace: string;
190
+ instanceId: string;
191
+ feltdbVersion: string;
192
+ durable: boolean;
193
+ openedAt: string;
194
+ pid: number;
195
+ };
196
+ collections: {
197
+ description?: string | undefined;
198
+ name: string;
199
+ schema: import("@appport/protocol").JSONSchema;
200
+ }[];
201
+ functions: FunctionInfo[];
202
+ roles: Readonly<Record<string, readonly string[]>>;
203
+ policyVersion: string;
204
+ recentErrors: {
205
+ at: string;
206
+ name: string;
207
+ code: string;
208
+ message: string;
209
+ requestId: string;
210
+ }[];
211
+ activity: {
212
+ mode: "writes" | "all" | "errors";
213
+ lastError: {
214
+ at: string;
215
+ message: string;
216
+ } | null;
217
+ };
218
+ changeFeed: {
219
+ lastError: string | null;
220
+ };
221
+ components: {
222
+ [k: string]: string[];
223
+ };
224
+ };
225
+ /** Stop accepting calls, wait for in-flight work, flush the activity log, release the instance. */
226
+ close(): Promise<void>;
227
+ }