@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,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The execution-engine boundary for reasoning agents (`app.agent` with `instructions`).
|
|
3
|
+
*
|
|
4
|
+
* FeltKit owns everything durable about a run: its task, its transcript (one FeltDB memory per message,
|
|
5
|
+
* written once), its authority, every tool call (an AppPort proposal: authorized, approval-gated,
|
|
6
|
+
* idempotent per call), and its evidence. An engine owns one decision: given the instructions, the
|
|
7
|
+
* transcript so far and the tools the agent may use now, what is the agent's next turn (text, and the
|
|
8
|
+
* tool calls it asks for)? It never reads or writes state, never holds a credential, and never runs a
|
|
9
|
+
* tool. So a run resumes after a restart from FeltDB alone, whatever engine produced its earlier turns,
|
|
10
|
+
* and engines (a model, a local model, rules, a future external engine) replace each other without
|
|
11
|
+
* changing the agent's definition.
|
|
12
|
+
*/
|
|
13
|
+
import type { GenerationMessage, GenerationResult, ToolCall, ToolDefinition } from "./runtime/generation.js";
|
|
14
|
+
export type { GenerationMessage as AgentMessage, ToolCall as AgentToolCall } from "./runtime/generation.js";
|
|
15
|
+
/** A tool the agent may use in this turn: an AppPort capability it declared, that its roles allow now. */
|
|
16
|
+
export interface AgentToolSpec extends ToolDefinition {
|
|
17
|
+
/** "observation" runs at once; "consequential" waits for a person's approval unless the agent declares it autonomous. */
|
|
18
|
+
effect: "observation" | "consequential";
|
|
19
|
+
/** True when the agent's definition lets it run this consequential tool without a person's approval. */
|
|
20
|
+
autonomous?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** What the engine is asked for: the next turn. */
|
|
23
|
+
export interface AgentTurnRequest {
|
|
24
|
+
readonly agent: {
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly version: string;
|
|
27
|
+
};
|
|
28
|
+
readonly instructions: string;
|
|
29
|
+
/** Every message so far, from durable state: the input, earlier turns, tool results, people's updates. */
|
|
30
|
+
readonly transcript: readonly GenerationMessage[];
|
|
31
|
+
readonly tools: readonly AgentToolSpec[];
|
|
32
|
+
/** The output contract (JSON Schema), when the agent declares one: the final answer must be JSON matching it. */
|
|
33
|
+
readonly output?: Record<string, unknown>;
|
|
34
|
+
/** Aborted when this attempt must stop (it lost the run to another attempt): stop the model call. */
|
|
35
|
+
readonly signal: AbortSignal;
|
|
36
|
+
/**
|
|
37
|
+
* The environment's model, through FeltKit: resolved from the environment's configuration (never from
|
|
38
|
+
* the agent's definition), credentials kept server-side, every generation recorded as evidence on the
|
|
39
|
+
* run's task. Throws a CONFIGURATION error that says what to set when no model is configured.
|
|
40
|
+
*/
|
|
41
|
+
readonly model: {
|
|
42
|
+
generate(request: {
|
|
43
|
+
messages: GenerationMessage[];
|
|
44
|
+
tools?: ToolDefinition[];
|
|
45
|
+
maxTokens?: number;
|
|
46
|
+
temperature?: number;
|
|
47
|
+
}): Promise<GenerationResult & {
|
|
48
|
+
generationId: string;
|
|
49
|
+
memoryId: string;
|
|
50
|
+
receipt: {
|
|
51
|
+
provider: string;
|
|
52
|
+
model: string;
|
|
53
|
+
};
|
|
54
|
+
}>;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** The engine's answer: the agent's next turn. No tool calls ends the run with `text` as its output. */
|
|
58
|
+
export interface AgentTurn {
|
|
59
|
+
text: string;
|
|
60
|
+
toolCalls: ToolCall[];
|
|
61
|
+
/** The recorded generation this turn came from, when a model produced it (its id and FeltDB memory id). */
|
|
62
|
+
generation?: {
|
|
63
|
+
generationId: string;
|
|
64
|
+
memoryId: string;
|
|
65
|
+
};
|
|
66
|
+
/** The model that decided, when one did: recorded on each proposal as `model:<provider>/<model>`. */
|
|
67
|
+
decidedBy?: {
|
|
68
|
+
provider: string;
|
|
69
|
+
model: string;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** An execution engine: decides an agent's next turn. Stateless between calls. */
|
|
73
|
+
export interface AgentEngine {
|
|
74
|
+
/** Recorded on the run and its evidence ("feltkit.model", "rules:triage", …). */
|
|
75
|
+
readonly id: string;
|
|
76
|
+
/** Whether the engine needs the environment's model; a run without one fails clearly before it starts. */
|
|
77
|
+
readonly usesModel: boolean;
|
|
78
|
+
next(request: AgentTurnRequest): Promise<AgentTurn>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The default engine: one generation with the environment's model per turn, the instructions as the
|
|
82
|
+
* system message, the agent's tools offered as the model's tools.
|
|
83
|
+
*/
|
|
84
|
+
export declare function modelEngine(options?: {
|
|
85
|
+
maxTokens?: number;
|
|
86
|
+
temperature?: number;
|
|
87
|
+
}): AgentEngine;
|
|
88
|
+
/**
|
|
89
|
+
* A deterministic engine: `decide` maps the transcript to the next turn with ordinary code, no model.
|
|
90
|
+
* Same lifecycle, authority, approvals and evidence as a model-driven agent; useful for rule-based
|
|
91
|
+
* agents and for testing an agent's tools and approvals without a provider.
|
|
92
|
+
*/
|
|
93
|
+
export declare function rulesEngine(id: string, decide: (request: Omit<AgentTurnRequest, "model">) => AgentTurn | Promise<AgentTurn>): AgentEngine;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default engine: one generation with the environment's model per turn, the instructions as the
|
|
3
|
+
* system message, the agent's tools offered as the model's tools.
|
|
4
|
+
*/
|
|
5
|
+
export function modelEngine(options = {}) {
|
|
6
|
+
return Object.freeze({
|
|
7
|
+
id: "feltkit.model",
|
|
8
|
+
usesModel: true,
|
|
9
|
+
async next(request) {
|
|
10
|
+
const g = await request.model.generate({
|
|
11
|
+
messages: [{ role: "system", content: request.output ? `${request.instructions}\n\nWhen you are done, answer with only a JSON value matching this JSON Schema (no other text):\n${JSON.stringify(request.output)}` : request.instructions }, ...request.transcript],
|
|
12
|
+
...(request.tools.length ? { tools: request.tools.map((t) => ({ name: t.name, ...(t.description ? { description: t.description } : {}), inputSchema: t.inputSchema })) } : {}),
|
|
13
|
+
...(options.maxTokens !== undefined ? { maxTokens: options.maxTokens } : {}),
|
|
14
|
+
...(options.temperature !== undefined ? { temperature: options.temperature } : {}),
|
|
15
|
+
});
|
|
16
|
+
return { text: g.text, toolCalls: g.toolCalls, generation: { generationId: g.generationId, memoryId: g.memoryId }, decidedBy: { provider: g.receipt.provider, model: g.receipt.model } };
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A deterministic engine: `decide` maps the transcript to the next turn with ordinary code, no model.
|
|
22
|
+
* Same lifecycle, authority, approvals and evidence as a model-driven agent; useful for rule-based
|
|
23
|
+
* agents and for testing an agent's tools and approvals without a provider.
|
|
24
|
+
*/
|
|
25
|
+
export function rulesEngine(id, decide) {
|
|
26
|
+
if (typeof id !== "string" || !/^[a-z][a-z0-9._:-]{0,62}$/.test(id))
|
|
27
|
+
throw new TypeError(`rulesEngine("${id}"): the id is a lowercase letter, then letters, digits, ".", "_", ":" or "-".`);
|
|
28
|
+
if (typeof decide !== "function")
|
|
29
|
+
throw new TypeError(`rulesEngine("${id}") needs a decide function.`);
|
|
30
|
+
return Object.freeze({
|
|
31
|
+
id: `rules:${id}`,
|
|
32
|
+
usesModel: false,
|
|
33
|
+
async next(request) {
|
|
34
|
+
const { model: _model, ...rest } = request;
|
|
35
|
+
const turn = await decide(rest);
|
|
36
|
+
return { text: String(turn?.text ?? ""), toolCalls: Array.isArray(turn?.toolCalls) ? turn.toolCalls : [] };
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=agent-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-engine.js","sourceRoot":"","sources":["../src/agent-engine.ts"],"names":[],"mappings":"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"}
|
package/dist/app.d.ts
CHANGED
|
@@ -13,9 +13,37 @@ import type { Schema } from "@appport/sdk";
|
|
|
13
13
|
import { type Doc, type InferShape, type ShapeInput, type Simplify } from "./schema.js";
|
|
14
14
|
import type { ActionCtx, AgentCtx, MutationCtx, QueryCtx } from "./runtime/context.js";
|
|
15
15
|
import { type ClaimDeclaration } from "./runtime/claims.js";
|
|
16
|
+
import { type QuotaDeclaration, type QuotaSpec } from "./quota.js";
|
|
16
17
|
declare const APP: unique symbol;
|
|
17
18
|
declare const COLLECTION: unique symbol;
|
|
18
19
|
declare const FUNCTION: unique symbol;
|
|
20
|
+
/**
|
|
21
|
+
* A transient-message channel (`app.channel`, K2): an AppPort event that carries a message to one scope
|
|
22
|
+
* (a recipient: a connection, a call), authorized for each sender and for each recipient at subscribe and
|
|
23
|
+
* at every delivery, never written to FeltDB. See `FeltKitApp.channel`.
|
|
24
|
+
*/
|
|
25
|
+
export interface ChannelConfig {
|
|
26
|
+
/** Who may send: a permission (checked against the sender's roles), plus `authorize.send` when declared. */
|
|
27
|
+
readonly send: Access;
|
|
28
|
+
/** Who may receive: a permission, plus `authorize.receive` (required) for the scope, at subscribe and per delivery. */
|
|
29
|
+
readonly receive: Access;
|
|
30
|
+
readonly authorize: {
|
|
31
|
+
readonly send?: (request: ChannelSendRequest) => boolean | Promise<boolean>;
|
|
32
|
+
readonly receive: (request: ChannelReceiveRequest) => boolean | Promise<boolean>;
|
|
33
|
+
};
|
|
34
|
+
/** The largest message, as JSON bytes. Default 64 KiB. */
|
|
35
|
+
readonly maxBytes: number;
|
|
36
|
+
readonly quota?: readonly QuotaSpec[];
|
|
37
|
+
}
|
|
38
|
+
export interface ChannelReceiveRequest {
|
|
39
|
+
principal: import("./runtime/authority.js").Principal | null;
|
|
40
|
+
scope: string;
|
|
41
|
+
/** Read-only, the application's data (tenant-scoped to the recipient). */
|
|
42
|
+
db: import("./runtime/data.js").DatabaseReader;
|
|
43
|
+
}
|
|
44
|
+
export interface ChannelSendRequest extends ChannelReceiveRequest {
|
|
45
|
+
message: unknown;
|
|
46
|
+
}
|
|
19
47
|
/** An ephemeral event declared with `app.event` (see there). */
|
|
20
48
|
export interface EventDefinition<Payload = unknown> {
|
|
21
49
|
readonly name: string;
|
|
@@ -23,6 +51,8 @@ export interface EventDefinition<Payload = unknown> {
|
|
|
23
51
|
/** Who may observe it: a permission, "authenticated" or "public". Always declared. */
|
|
24
52
|
readonly access: Access;
|
|
25
53
|
readonly description?: string;
|
|
54
|
+
/** Set for a channel (`app.channel`): sent with ctx.channels.send, never ctx.events.publish. */
|
|
55
|
+
readonly channel?: ChannelConfig;
|
|
26
56
|
/** Type only. */
|
|
27
57
|
readonly __payload?: Payload;
|
|
28
58
|
}
|
|
@@ -136,6 +166,44 @@ export interface OidcProvider extends ProviderClient {
|
|
|
136
166
|
/** Default ["openid", "email", "profile"]. */
|
|
137
167
|
scopes?: string[];
|
|
138
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* An agent that runs on the agent runtime from its own project (`agent/`), built and supervised by FeltKit:
|
|
171
|
+
* `app.agent(name, { project: ".", roles, tenantRole, capabilities })`. (`feltkit({ eve })` is the same declaration.)
|
|
172
|
+
*/
|
|
173
|
+
export interface ProjectAgentConfig {
|
|
174
|
+
/** The agent's project directory (it holds `agent/` and installs the agent runtime), relative to the application. */
|
|
175
|
+
project: string;
|
|
176
|
+
/** Application roles the agent's worker holds in a workspace. No more than the person who activates it holds. */
|
|
177
|
+
roles: readonly string[];
|
|
178
|
+
/** The workspace role the agent joins a workspace with (`auth.tenant.roles`). Required when the app has workspaces. */
|
|
179
|
+
tenantRole?: string;
|
|
180
|
+
/** The capabilities the agent may be granted: exact names or `namespace.*`. A person grants only those they may call. */
|
|
181
|
+
capabilities: readonly string[];
|
|
182
|
+
/** Shown as the agent's name. */
|
|
183
|
+
displayName?: string;
|
|
184
|
+
/** How long a person's work grant to the agent lasts. Default 24 h. */
|
|
185
|
+
grantTtlMs?: number;
|
|
186
|
+
}
|
|
187
|
+
/** A project agent, as `app.agent` returns it. */
|
|
188
|
+
export interface ProjectAgentDefinition {
|
|
189
|
+
readonly name: string;
|
|
190
|
+
readonly project: string;
|
|
191
|
+
}
|
|
192
|
+
/** One agent of the application that runs on the agent runtime (`app.agent(name, { project })` or `feltkit({ eve })`). */
|
|
193
|
+
export interface EveAgentDeclaration {
|
|
194
|
+
/** The eve project directory (it holds `agent/` and installs `eve`), relative to the application. Default ".". */
|
|
195
|
+
root?: string;
|
|
196
|
+
/** Application roles the agent's worker holds in a workspace. No more than the person who activates it holds. */
|
|
197
|
+
roles: readonly string[];
|
|
198
|
+
/** The workspace role the agent joins a workspace with (`auth.tenant.roles`). Required when the app has workspaces. */
|
|
199
|
+
tenantRole?: string;
|
|
200
|
+
/** The capabilities the agent may be granted: exact names or `namespace.*`. A person grants only those they may call. */
|
|
201
|
+
capabilities: readonly string[];
|
|
202
|
+
/** Shown as the agent's name. */
|
|
203
|
+
displayName?: string;
|
|
204
|
+
/** How long a person's work grant to the agent lasts. Default 24 h. */
|
|
205
|
+
grantTtlMs?: number;
|
|
206
|
+
}
|
|
139
207
|
/**
|
|
140
208
|
* Sign in with Google or GitHub through FeltKit's broker instead of your own provider client: nothing to register and no
|
|
141
209
|
* client secret to keep. The broker signs the person in and hands this app a signed statement of who they are (the
|
|
@@ -193,6 +261,16 @@ export interface FeltKitOptions {
|
|
|
193
261
|
authenticate?: (request: AuthenticateRequest) => PrincipalInput | null | Promise<PrincipalInput | null>;
|
|
194
262
|
/** Session lifetime. Default 7 days. */
|
|
195
263
|
sessionTtlMs?: number;
|
|
264
|
+
/**
|
|
265
|
+
* Guests (K4): people without an account, admitted by a guest link to one record (`ctx.grants.guestLink`).
|
|
266
|
+
* `roles`: the roles a guest link may give (each declared in `roles`; keep them narrow); `ttlMs`: a link's
|
|
267
|
+
* default lifetime (default 24 h, at most 30 days). A guest reaches only functions declaring
|
|
268
|
+
* `resource: { …, guests: true }`, and only its own record. See docs/AUTH.md ("Guests").
|
|
269
|
+
*/
|
|
270
|
+
guests?: {
|
|
271
|
+
roles: readonly string[];
|
|
272
|
+
ttlMs?: number;
|
|
273
|
+
};
|
|
196
274
|
/**
|
|
197
275
|
* A mutation (`"<module>:<export>"`) FeltKit runs when a session ends, so state bound to that session can end
|
|
198
276
|
* too (docs/AUTH.md, "When a session ends"). It runs as the session's principal (as recorded on the session,
|
|
@@ -349,6 +427,15 @@ export interface FeltKitOptions {
|
|
|
349
427
|
* docs/COMPONENTS.md.
|
|
350
428
|
*/
|
|
351
429
|
components?: Record<string, import("./component.js").ComponentDeclaration>;
|
|
430
|
+
/**
|
|
431
|
+
* eve agents this application runs (`@appport/eve`), each from its own eve project directory. FeltKit builds
|
|
432
|
+
* and supervises each as a child process on a loopback port, with its sessions in FeltDB (the FeltDB World,
|
|
433
|
+
* `@appport/eve-world-feltdb`, under this environment's state), and forwards `/eve/<name>/…` to it only for
|
|
434
|
+
* signed-in people, with a short-lived signed identity (person, workspace, roles, work grant). The agent acts
|
|
435
|
+
* on the application only through its published capabilities, as a worker under the person's work grant;
|
|
436
|
+
* approvals are AppPort approvals of one exact call. See docs/EVE-COMPOSITION.md.
|
|
437
|
+
*/
|
|
438
|
+
eve?: Record<string, EveAgentDeclaration>;
|
|
352
439
|
/**
|
|
353
440
|
* AppPort providers this application uses: `{ <name>: { provider, config?, credentials? } }`, where `provider` is
|
|
354
441
|
* the `defineProvider(...)` a package exports. Their capabilities join the application's own, authorized by its
|
|
@@ -356,6 +443,19 @@ export interface FeltKitOptions {
|
|
|
356
443
|
* runtime/providers.ts and docs/PROVIDERS.md.
|
|
357
444
|
*/
|
|
358
445
|
providers?: Record<string, import("./providers.js").ProviderDeclaration>;
|
|
446
|
+
/**
|
|
447
|
+
* Capabilities of other applications this one needs, by AppPort name and integer version range. A declaration
|
|
448
|
+
* names no provider, endpoint or credential: an AppBoundry host binds each to a provider and grant, and the code
|
|
449
|
+
* reaches it through `ctx.capabilities`. Emitted as the artifact manifest's `requires` (host interface capabilities@1).
|
|
450
|
+
*/
|
|
451
|
+
requires?: readonly import("./runtime/required-capabilities.js").CapabilityRequirement[];
|
|
452
|
+
/**
|
|
453
|
+
* Quotas for every function of the application (K3), on top of each function's own `quota`: at most
|
|
454
|
+
* `limit` calls in any `windowMs`, counted per principal across all functions ("principal") or for
|
|
455
|
+
* the whole application ("function" here means every call). Checked before the handler runs; a
|
|
456
|
+
* refusal is RATE_LIMITED with details.retryAfterMs (HTTP 429, Retry-After). See src/quota.ts.
|
|
457
|
+
*/
|
|
458
|
+
quotas?: QuotaDeclaration;
|
|
359
459
|
activity?: {
|
|
360
460
|
/** What to record. Default: "all" in development/test, "writes" in production. */
|
|
361
461
|
record?: "all" | "writes" | "errors";
|
|
@@ -721,15 +821,52 @@ export interface FunctionConfig<Kind extends FunctionKind, A extends ShapeInput,
|
|
|
721
821
|
sequenceConflicts: number;
|
|
722
822
|
};
|
|
723
823
|
/**
|
|
724
|
-
* Mutations
|
|
824
|
+
* Mutations and actions. `"required"`: an agent, service, worker or API key may never run it directly, on any
|
|
725
825
|
* interface (HTTP, AppPort, MCP, a job it queued). It may discover it and propose it
|
|
726
826
|
* (`feltkit_agent_propose`); the proposal runs only after a person approves it, as the
|
|
727
827
|
* proposer, with the proposer's own permissions (`access` still applies to it and to the
|
|
728
|
-
* approver). People call it directly.
|
|
828
|
+
* approver). People call it directly. A worker (or any non-person caller) may also run it with a person's
|
|
829
|
+
* approval of exactly that call (`ctx.grants.approve`, named as `x-appport-approval`). See docs/GUARANTEES.md (Agents).
|
|
729
830
|
*/
|
|
730
831
|
approval?: "required";
|
|
731
832
|
/** Queries and mutations: the record it acts on must be the caller's. See OwnerDeclaration. */
|
|
732
833
|
owner?: OwnerDeclaration;
|
|
834
|
+
/**
|
|
835
|
+
* How often a caller may run it (K3): `{ per: "principal", limit: 30, windowMs: 10_000 }`, or several.
|
|
836
|
+
* `per` is "principal", "function" (everyone together), "arg:<argument>" or "principal+arg:<argument>".
|
|
837
|
+
* Enforced before the handler (and before the policies and the authorize hook), on every interface;
|
|
838
|
+
* the (limit+1)th call in a window is RATE_LIMITED with details.retryAfterMs. See src/quota.ts.
|
|
839
|
+
*/
|
|
840
|
+
quota?: QuotaDeclaration;
|
|
841
|
+
/**
|
|
842
|
+
* The record this function acts on (K4, K6, K7): `{ collection, id: "<argument>", by?: "<unique field>",
|
|
843
|
+
* guests?: true, agents?: "grant" }`. `id` names the argument holding the record's id, or with `by` a value
|
|
844
|
+
* of that unique field (a meeting's `code`). With `guests: true`, a guest admitted to that record by a guest
|
|
845
|
+
* link may call it (guests are refused by every function that does not say so); with `agents: "grant"`, an
|
|
846
|
+
* agent or service may call it only with a live grant for that record (`ctx.grants.admitAgent`). Checked at
|
|
847
|
+
* the execution boundary before the policies and the authorize hook; refusals are durable evidence.
|
|
848
|
+
*/
|
|
849
|
+
resource?: {
|
|
850
|
+
collection: CollectionDefinition;
|
|
851
|
+
id: string;
|
|
852
|
+
by?: string;
|
|
853
|
+
guests?: boolean;
|
|
854
|
+
agents?: "grant";
|
|
855
|
+
};
|
|
856
|
+
/**
|
|
857
|
+
* Who may call it at all, before `access` is checked. Enforced at dispatch on every surface (HTTP, AppPort, MCP,
|
|
858
|
+
* the agent's tools):
|
|
859
|
+
*
|
|
860
|
+
* - `"public"` (default): anyone `access` admits.
|
|
861
|
+
* - `"worker"`: only a registered worker (`ctx.grants.registerWorker`), under a work grant naming it.
|
|
862
|
+
* - `"service"`: only a service principal (an API key, a runtime component, an operator-issued service session).
|
|
863
|
+
* - `"internal"`: no surface at all: only the application's own code calls it (`ctx.runQuery` / `ctx.runMutation`
|
|
864
|
+
* from an action, a job handler, an inbound webhook handler, `auth.onSessionEnd`). Every surface answers
|
|
865
|
+
* FUNCTION_NOT_FOUND; it is never published as a capability, listed to agents, or shown as a tool.
|
|
866
|
+
*
|
|
867
|
+
* Internal calls (the list above) pass every visibility; `access` still applies to them, as the caller.
|
|
868
|
+
*/
|
|
869
|
+
visibility?: FunctionVisibility;
|
|
733
870
|
handler: (ctx: Kind extends "query" ? QueryCtx : Kind extends "action" ? ActionCtx : MutationCtx, args: Simplify<InferShape<A>>) => R | Promise<R>;
|
|
734
871
|
}
|
|
735
872
|
export interface FunctionDefinition<Kind extends FunctionKind = FunctionKind, Args = any, Result = any> {
|
|
@@ -751,6 +888,12 @@ export interface FunctionDefinition<Kind extends FunctionKind = FunctionKind, Ar
|
|
|
751
888
|
readonly approval?: "required";
|
|
752
889
|
/** The record it acts on must be the caller's (queries and mutations). */
|
|
753
890
|
readonly owner?: OwnerDeclaration;
|
|
891
|
+
/** Call limits (K3). */
|
|
892
|
+
readonly quota?: readonly QuotaSpec[];
|
|
893
|
+
/** The record it acts on, and who besides its role holders may reach it (guests, granted agents). */
|
|
894
|
+
readonly resource?: import("./runtime/resource-access.js").ResourceDeclaration;
|
|
895
|
+
/** Who may call it at all (default "public"); see FunctionConfig.visibility. */
|
|
896
|
+
readonly visibility?: FunctionVisibility;
|
|
754
897
|
readonly handler: (ctx: any, args: any) => unknown;
|
|
755
898
|
readonly app: FeltKitApp;
|
|
756
899
|
/** Type-only markers. */
|
|
@@ -783,9 +926,78 @@ export interface AgentConfig<Input extends Record<string, unknown> = Record<stri
|
|
|
783
926
|
maxAttempts?: number;
|
|
784
927
|
backoffMs?: number;
|
|
785
928
|
};
|
|
786
|
-
/**
|
|
929
|
+
/**
|
|
930
|
+
* How long a run holds its claim before the services worker treats it as abandoned and runs it again (default
|
|
931
|
+
* 300 000 ms; 120 000 ms for a reasoning agent, whose run lease is half of it, renewed while an attempt works:
|
|
932
|
+
* a process that stops is taken over within about this long).
|
|
933
|
+
*/
|
|
787
934
|
leaseMs?: number;
|
|
788
|
-
|
|
935
|
+
/** A deterministic agent: code that runs as a mutation, in one transaction. Exactly one of `handler` and `instructions`. */
|
|
936
|
+
handler?: (ctx: AgentCtx, input: Input) => unknown;
|
|
937
|
+
/**
|
|
938
|
+
* A reasoning agent: FeltKit runs it turn by turn. Each turn the engine (default: the environment's model)
|
|
939
|
+
* reads the durable transcript and answers with text and tool calls; FeltKit runs each tool call as an
|
|
940
|
+
* AppPort proposal by the agent (observations at once, consequential calls after a person approves them,
|
|
941
|
+
* unless listed in `autonomous`), records the result, and continues until a turn asks for no tool. The
|
|
942
|
+
* run's task, transcript, generations and actions are FeltDB state: a run resumes after a restart, and a
|
|
943
|
+
* run waiting for an approval resumes when a person decides. Its roles must grant `feltkit.agent.write`
|
|
944
|
+
* (checked when the runtime starts).
|
|
945
|
+
*/
|
|
946
|
+
instructions?: string;
|
|
947
|
+
/** The capabilities a reasoning agent may use, by definition (published functions of this app). Its roles must also allow each one. */
|
|
948
|
+
tools?: readonly FunctionDefinition<any, any, any>[];
|
|
949
|
+
/**
|
|
950
|
+
* Consequential tools (a subset of `tools`) the agent runs without a person's approval: the application's
|
|
951
|
+
* explicit policy, recorded on each action as `policy:agent/<name>`. Never applies to a function declared
|
|
952
|
+
* `approval: "required"`, which still waits for a person.
|
|
953
|
+
*/
|
|
954
|
+
autonomous?: readonly FunctionDefinition<any, any, any>[];
|
|
955
|
+
/** Input contract of a reasoning agent's runs (validated before a run starts). Default: any object. */
|
|
956
|
+
input?: ShapeInput;
|
|
957
|
+
/**
|
|
958
|
+
* Budgets of one reasoning run, enforced by FeltKit from durable records across every attempt (a restart does
|
|
959
|
+
* not reset them). Exhausting one stops the run (its task is cancelled with the budget as the reason).
|
|
960
|
+
* maxTurns the agent's turns (default 8, at most 100)
|
|
961
|
+
* maxToolCalls tool results (default 20, at most 500)
|
|
962
|
+
* maxGenerations model generations, failed ones included (default 2 × maxTurns)
|
|
963
|
+
* maxActiveMs execution time, summed over attempts; waiting for a person does not count (default 10 min)
|
|
964
|
+
* maxTokens input + output tokens the provider reported; generations that report none are not counted
|
|
965
|
+
* (and the stop says so). Optional: not every provider reports usage.
|
|
966
|
+
* concurrency runs of this agent executing at once in one process (default 4); more wait their turn
|
|
967
|
+
*/
|
|
968
|
+
limits?: {
|
|
969
|
+
maxTurns?: number;
|
|
970
|
+
maxToolCalls?: number;
|
|
971
|
+
maxGenerations?: number;
|
|
972
|
+
maxActiveMs?: number;
|
|
973
|
+
maxTokens?: number;
|
|
974
|
+
concurrency?: number;
|
|
975
|
+
};
|
|
976
|
+
/**
|
|
977
|
+
* The output contract: the final answer must be JSON matching it (a schema from `s`, or a shape like `args`).
|
|
978
|
+
* An answer that does not match is never the run's result: the agent is told why and answers again, within
|
|
979
|
+
* maxTurns. The validated value is the run's output (`result.run.output`, `<task>.output`).
|
|
980
|
+
*/
|
|
981
|
+
output?: ShapeInput | import("@appport/sdk").Schema;
|
|
982
|
+
/** Who decides each turn (default `modelEngine()`: the environment's model). See `@feltdb/feltkit` AgentEngine. */
|
|
983
|
+
engine?: import("./agent-engine.js").AgentEngine;
|
|
984
|
+
}
|
|
985
|
+
/** A reasoning agent's definition, as FeltKit runs it. */
|
|
986
|
+
export interface ReasoningDefinition {
|
|
987
|
+
readonly instructions: string;
|
|
988
|
+
/** Capability names. */
|
|
989
|
+
readonly tools: readonly string[];
|
|
990
|
+
readonly autonomous: readonly string[];
|
|
991
|
+
readonly limits: {
|
|
992
|
+
readonly maxTurns: number;
|
|
993
|
+
readonly maxToolCalls: number;
|
|
994
|
+
readonly maxGenerations: number;
|
|
995
|
+
readonly maxActiveMs: number;
|
|
996
|
+
readonly maxTokens?: number;
|
|
997
|
+
readonly concurrency: number;
|
|
998
|
+
};
|
|
999
|
+
readonly output?: import("@appport/sdk").Schema;
|
|
1000
|
+
readonly engine: import("./agent-engine.js").AgentEngine;
|
|
789
1001
|
}
|
|
790
1002
|
export interface AgentDefinition {
|
|
791
1003
|
readonly name: string;
|
|
@@ -802,9 +1014,17 @@ export interface AgentDefinition {
|
|
|
802
1014
|
readonly backoffMs: number;
|
|
803
1015
|
};
|
|
804
1016
|
readonly leaseMs: number;
|
|
805
|
-
/** The handler as a mutation (internal: run only by the runtime, under the name `agent/<name>`). */
|
|
806
|
-
readonly function: FunctionDefinition<"mutation">;
|
|
1017
|
+
/** The handler as a mutation, or a reasoning agent's run as an action (internal: run only by the runtime, under the name `agent/<name>`). */
|
|
1018
|
+
readonly function: FunctionDefinition<"mutation"> | FunctionDefinition<"action">;
|
|
1019
|
+
/** Present for a reasoning agent (`instructions`). */
|
|
1020
|
+
readonly reasoning?: ReasoningDefinition;
|
|
807
1021
|
}
|
|
1022
|
+
/** The outbox claim of one reasoning attempt. Short: the run's own lease (renewed while it works) keeps a live attempt's run from being taken over. */
|
|
1023
|
+
export declare const AGENT_REASONING_LEASE_MS = 120000;
|
|
1024
|
+
export declare const AGENT_MAX_TURNS = 100;
|
|
1025
|
+
export declare const AGENT_MAX_TOOL_CALLS = 500;
|
|
1026
|
+
/** The internal hook a reasoning agent's action calls: the runtime puts its run driver here on the action's ctx. */
|
|
1027
|
+
export declare const AGENT_RUN: unique symbol;
|
|
808
1028
|
export declare const AGENT_DEFAULT_ATTEMPTS = 5;
|
|
809
1029
|
export declare const AGENT_DEFAULT_BACKOFF_MS = 1000;
|
|
810
1030
|
export declare const AGENT_MAX_BACKOFF_MS = 600000;
|
|
@@ -853,6 +1073,8 @@ export declare class FeltKitApp<O extends FeltKitOptions = FeltKitOptions> {
|
|
|
853
1073
|
readonly migrations: MigrationDefinition[];
|
|
854
1074
|
/** Application agents (see `agent`), by name. */
|
|
855
1075
|
readonly agents: Map<string, AgentDefinition>;
|
|
1076
|
+
/** Agents that run on the agent runtime from their own project (`app.agent(name, { project })`), by name. */
|
|
1077
|
+
readonly projectAgents: Map<string, EveAgentDeclaration>;
|
|
856
1078
|
/** Declared policies (`app.policy`), in declaration order. Resolved to function names at assembly. */
|
|
857
1079
|
readonly policies: PolicyRule[];
|
|
858
1080
|
constructor(options: O);
|
|
@@ -879,6 +1101,37 @@ export declare class FeltKitApp<O extends FeltKitOptions = FeltKitOptions> {
|
|
|
879
1101
|
access: Access;
|
|
880
1102
|
description?: string;
|
|
881
1103
|
}): EventDefinition<S extends Schema<infer T> ? T : unknown>;
|
|
1104
|
+
/**
|
|
1105
|
+
* A channel of transient messages (K2): WebRTC signaling, typing, a raised hand, reactions. A message is
|
|
1106
|
+
* sent to one scope (a recipient: a connection id, a call) with `ctx.channels.send(channel, scope,
|
|
1107
|
+
* message)` from a mutation, delivered after it commits, at most once, to whoever is subscribed to that
|
|
1108
|
+
* scope now (`client.subscribe(channel, { scope }, listener)` / `useEvent`), and **never written to
|
|
1109
|
+
* FeltDB**: no record, no journal entry, no backup; the activity log records the sending call's
|
|
1110
|
+
* metadata only (never a payload).
|
|
1111
|
+
*
|
|
1112
|
+
* Authority is the channel's, declared here: the sender needs `access.send` (and `authorize.send` when
|
|
1113
|
+
* declared); each recipient needs `access.receive` and `authorize.receive` for the scope, asked when it
|
|
1114
|
+
* subscribes and again before every delivery, so a revoked recipient gets nothing more, and a wildcard
|
|
1115
|
+
* subscription never carries a message its holder may not receive. `quota` limits each sender.
|
|
1116
|
+
*
|
|
1117
|
+
* export const signaling = app.channel("call.signal", {
|
|
1118
|
+
* message: s.object({ kind: s.enum(["offer", "answer", "ice"]), sdp: s.string({ maxLength: 65_536 }) }),
|
|
1119
|
+
* access: { send: "calls.signal", receive: "calls.signal" },
|
|
1120
|
+
* authorize: { receive: async ({ principal, scope, db }) => (await db.get(connections, scope))?.holder === principal?.id },
|
|
1121
|
+
* quota: { per: "principal", limit: 60, windowMs: 60_000 },
|
|
1122
|
+
* });
|
|
1123
|
+
*/
|
|
1124
|
+
channel<S extends Schema>(name: string, config: {
|
|
1125
|
+
message: S;
|
|
1126
|
+
access: {
|
|
1127
|
+
send: Access;
|
|
1128
|
+
receive: Access;
|
|
1129
|
+
};
|
|
1130
|
+
authorize: ChannelConfig["authorize"];
|
|
1131
|
+
maxBytes?: number;
|
|
1132
|
+
quota?: QuotaDeclaration;
|
|
1133
|
+
description?: string;
|
|
1134
|
+
}): EventDefinition<S extends Schema<infer T> ? T : unknown>;
|
|
882
1135
|
/**
|
|
883
1136
|
* An application agent: a handler that runs after a mutation commits, **as the agent** (principal
|
|
884
1137
|
* type "agent", `roles`, never the triggering caller's authority), through the same authority as
|
|
@@ -898,7 +1151,11 @@ export declare class FeltKitApp<O extends FeltKitOptions = FeltKitOptions> {
|
|
|
898
1151
|
*
|
|
899
1152
|
* See docs/TRANSACTIONS.md ("Application agents"). Not available in an AppBoundry artifact.
|
|
900
1153
|
*/
|
|
1154
|
+
agent(name: string, config: ProjectAgentConfig): ProjectAgentDefinition;
|
|
901
1155
|
agent<Input extends Record<string, unknown> = Record<string, unknown>>(name: string, config: AgentConfig<Input>): AgentDefinition;
|
|
1156
|
+
private projectAgent;
|
|
1157
|
+
private inProcessAgent;
|
|
1158
|
+
private checkReasoning;
|
|
902
1159
|
/**
|
|
903
1160
|
* Declare a policy: who may call which functions, on which resource, under which conditions
|
|
904
1161
|
* (see PolicyRule and src/policy.ts for the semantics). Deterministic, enforced at the execution
|
|
@@ -906,6 +1163,24 @@ export declare class FeltKitApp<O extends FeltKitOptions = FeltKitOptions> {
|
|
|
906
1163
|
* definitions (rename-safe) and the resource by its collection, both checked here.
|
|
907
1164
|
*/
|
|
908
1165
|
policy<const R extends PolicyRule>(rule: R): R;
|
|
1166
|
+
/**
|
|
1167
|
+
* Presence (K1): a collection whose records are leases, bound to their holder and ending exactly once
|
|
1168
|
+
* (left, removed, expired, session-ended, replaced). Hold one with `ctx.presence.join(peers, fields)`,
|
|
1169
|
+
* renew it with `ctx.presence.renew`, end it with `ctx.presence.end`; read live leases with `ctx.db`
|
|
1170
|
+
* as usual (expired and ended ones are left out). A lease not renewed within `ttlMs` ends at that time
|
|
1171
|
+
* without anyone asking, and live queries over the collection re-run. `onEnd` names an `app.agent` run
|
|
1172
|
+
* after each end. See src/presence.ts and docs/PRESENCE-AND-SIGNALING-PROPOSAL.md.
|
|
1173
|
+
*
|
|
1174
|
+
* export const peers = app.presence("peers", { callId: s.string(), name: s.string() }, { ttlMs: 45_000 });
|
|
1175
|
+
*/
|
|
1176
|
+
presence<S extends ShapeInput>(name: string, shape: S, options: {
|
|
1177
|
+
ttlMs: number;
|
|
1178
|
+
onEnd?: AgentDefinition | string;
|
|
1179
|
+
history?: boolean;
|
|
1180
|
+
tenant?: CollectionOptions["tenant"];
|
|
1181
|
+
indexes?: CollectionOptions["indexes"];
|
|
1182
|
+
description?: string;
|
|
1183
|
+
}): CollectionDefinition<S>;
|
|
909
1184
|
collection<S extends ShapeInput>(name: string, shape: S, options?: CollectionOptions): CollectionDefinition<S>;
|
|
910
1185
|
/**
|
|
911
1186
|
* A business audit trail: an append-only collection of events about the app's own subjects, each
|
|
@@ -996,17 +1271,39 @@ export declare class FeltKitApp<O extends FeltKitOptions = FeltKitOptions> {
|
|
|
996
1271
|
* `ctx.runMutation`) and the agent's proposals, all as the caller, so it can never bypass a
|
|
997
1272
|
* function's authority. It can use the environment's model (`ctx.model.generate`) and stream
|
|
998
1273
|
* events to its caller (`client.action(ref, args, { onEvent })`); the caller cancels by closing
|
|
999
|
-
* the stream (`ctx.signal`).
|
|
1274
|
+
* the stream (`ctx.signal`).
|
|
1275
|
+
*
|
|
1276
|
+
* Published with `capability`, it is an AppPort `consequential` capability with idempotency support: the
|
|
1277
|
+
* application-callable way to make an external effect (open a pull request, a payment). `ctx.effect.begin()` records
|
|
1278
|
+
* the effect before it is attempted, and an unknown outcome is never repeated by a retry (see ActionCtx.effect).
|
|
1279
|
+
* `approval: "required"` makes non-person callers need a person's approval of the exact call.
|
|
1000
1280
|
*/
|
|
1001
1281
|
action<A extends ShapeInput = {}, R = unknown>(config: FunctionConfig<"action", A, R>): ActionDefinition<Simplify<InferShape<A>>, Awaited<R>>;
|
|
1282
|
+
/** A resource binding (FunctionConfig.resource), checked when the function is declared, and frozen. */
|
|
1283
|
+
private checkResource;
|
|
1002
1284
|
/** An owner declaration, checked when the function is declared (never at a call), and frozen. */
|
|
1003
1285
|
private checkOwner;
|
|
1004
1286
|
private define;
|
|
1005
1287
|
}
|
|
1288
|
+
/** Whether `field` has a single-field unique constraint on `collection` (it then names at most one record). */
|
|
1289
|
+
export declare function uniqueField(collection: CollectionDefinition, field: string): boolean;
|
|
1290
|
+
/** Who may call a function at all, before `access` (see FunctionConfig.visibility). */
|
|
1291
|
+
export type FunctionVisibility = "public" | "worker" | "service" | "internal";
|
|
1006
1292
|
/** Define a FeltKit application. */
|
|
1007
1293
|
export declare function feltkit<const O extends FeltKitOptions>(options: O): FeltKitApp<O>;
|
|
1008
1294
|
export declare function isFeltKitApp(value: unknown): value is FeltKitApp;
|
|
1009
1295
|
export declare function isFunctionDefinition(value: unknown): value is FunctionDefinition;
|
|
1296
|
+
/**
|
|
1297
|
+
* A function group: one export whose function members are named `<module>:<member>`, as if each
|
|
1298
|
+
* were exported on its own (a capability built from the public API, such as Boards, ships its
|
|
1299
|
+
* functions this way). Members that are not functions (collections, helpers) are ignored.
|
|
1300
|
+
*/
|
|
1301
|
+
export declare const FUNCTION_GROUP: unique symbol;
|
|
1302
|
+
export type FunctionGroup<T extends object> = T & {
|
|
1303
|
+
readonly $functionGroup: true;
|
|
1304
|
+
};
|
|
1305
|
+
export declare function functionGroup<T extends object>(members: T): FunctionGroup<T>;
|
|
1306
|
+
export declare function isFunctionGroup(value: unknown): value is Record<string, unknown>;
|
|
1010
1307
|
export declare function isEventDefinition(value: unknown): value is EventDefinition;
|
|
1011
1308
|
/** Marks a collection declared with app.auditTrail (its record() allocates a sequence: transactions@1 in an artifact). */
|
|
1012
1309
|
export declare const AUDIT_TRAIL: unique symbol;
|
|
@@ -1018,4 +1315,6 @@ export declare function isCollectionDefinition(value: unknown): value is Collect
|
|
|
1018
1315
|
* letter (more dotted segments are allowed). No hyphens, underscores, or capitals.
|
|
1019
1316
|
*/
|
|
1020
1317
|
export declare function capabilityNameSuggestion(name: string): string;
|
|
1318
|
+
/** Every agent of the application that runs on the agent runtime: `app.agent(name, { project })` and `feltkit({ eve })`. */
|
|
1319
|
+
export declare function projectAgentsOf(app: FeltKitApp): Record<string, EveAgentDeclaration>;
|
|
1021
1320
|
export {};
|