@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,353 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The FeltKit agent: FeltDB's agent runtime and agent state, operating this
|
|
3
|
+
* application through AppPort.
|
|
4
|
+
*
|
|
5
|
+
* What is FeltDB's, reused as is (all on the environment's single instance):
|
|
6
|
+
*
|
|
7
|
+
* db.defineAgent(...) the agent's identity, capabilities, approval policy
|
|
8
|
+
* db.createAgentExecution({ taskId }) / start / transition / resume / complete / fail / cancel
|
|
9
|
+
* the durable lifecycle record of each task; every change
|
|
10
|
+
* is committed by FeltDB, invalid transitions refuse, and
|
|
11
|
+
* db.findAgentExecution({ taskId }) finds it (indexed)
|
|
12
|
+
* openAgentState(db) tasks, checkpoints whose `record` evidence is verified
|
|
13
|
+
* inside the commit, task memory (pending proposals),
|
|
14
|
+
* leased handoffs to another participant, bounded
|
|
15
|
+
* context bundles (feltdb.agent-context@1), and bounded,
|
|
16
|
+
* cursor-paged listTasks / listHandoffs
|
|
17
|
+
*
|
|
18
|
+
* What FeltKit adds is the product layer FeltDB does not have:
|
|
19
|
+
*
|
|
20
|
+
* - Actions go only through AppPort: application capabilities via the application's
|
|
21
|
+
* own dispatch pipeline (validate → authorize → execute), service operations via
|
|
22
|
+
* AppPort Services' invoke() and gateway. The agent has no other access to state.
|
|
23
|
+
* - Every action runs as the task's owner. An "observation" runs at once; a
|
|
24
|
+
* "consequential" action (AppPort's and AppPort Services' own effect classes) waits
|
|
25
|
+
* for a human who is also authorized to perform it. Approval is recorded; it never
|
|
26
|
+
* widens the owner's authority.
|
|
27
|
+
* - Decisions: FeltDB has no planner, and FeltKit adds none. Built-in playbooks choose
|
|
28
|
+
* capabilities by code (as FeltDB's own worker does); open-ended work is handed off,
|
|
29
|
+
* through FeltDB's handoff, to an external coding agent that proposes actions over MCP.
|
|
30
|
+
*
|
|
31
|
+
* Every result is redacted before it is recorded: secrets returned by an operation
|
|
32
|
+
* (an API key's plaintext, a session token) never reach a checkpoint, memory, or reply.
|
|
33
|
+
*/
|
|
34
|
+
import { type AgentCheckpoint, type AgentTask, type StateFirstDB } from "@feltdb/core";
|
|
35
|
+
import { type Principal } from "./authority.js";
|
|
36
|
+
import type { FeltKitRuntime } from "./runtime.js";
|
|
37
|
+
export declare const AGENT_NAME = "feltkit";
|
|
38
|
+
export declare const AGENT_VERSION = 1;
|
|
39
|
+
/** Permissions for using the agent itself. Actions still need their own permissions. */
|
|
40
|
+
export declare const AGENT_PERMISSIONS: {
|
|
41
|
+
readonly read: "feltkit.agent.read";
|
|
42
|
+
readonly write: "feltkit.agent.write";
|
|
43
|
+
};
|
|
44
|
+
export type ActionEffect = "observation" | "consequential";
|
|
45
|
+
export interface AgentTool {
|
|
46
|
+
/** AppPort capability name ("reports.list") or AppPort Services capability ("jobs.retry"). */
|
|
47
|
+
name: string;
|
|
48
|
+
source: "application" | "services";
|
|
49
|
+
effect: ActionEffect;
|
|
50
|
+
description?: string;
|
|
51
|
+
/** Whether the principal asking may perform it (a decision only; nothing runs). */
|
|
52
|
+
allowed: boolean;
|
|
53
|
+
}
|
|
54
|
+
export interface ProposedAction {
|
|
55
|
+
actionId: string;
|
|
56
|
+
capability: string;
|
|
57
|
+
source: "application" | "services";
|
|
58
|
+
effect: ActionEffect;
|
|
59
|
+
input: Record<string, unknown>;
|
|
60
|
+
reason: string;
|
|
61
|
+
proposedBy: string;
|
|
62
|
+
proposedAt: string;
|
|
63
|
+
/** When a model's decision chose this action: which decision record, runtime, and model. */
|
|
64
|
+
decision?: {
|
|
65
|
+
memoryId: string;
|
|
66
|
+
runtime: string;
|
|
67
|
+
provider: string;
|
|
68
|
+
model?: string;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A decision for the agent to put to the environment's model: application code supplies
|
|
73
|
+
* the candidate next steps; the model only chooses among those the task owner may take.
|
|
74
|
+
*/
|
|
75
|
+
export interface DecisionSpec {
|
|
76
|
+
question: string;
|
|
77
|
+
options: DecisionOption[];
|
|
78
|
+
/** Facts the model may use. Redacted before it is sent or recorded. */
|
|
79
|
+
context?: Record<string, unknown>;
|
|
80
|
+
}
|
|
81
|
+
export interface DecisionOption {
|
|
82
|
+
/** A short label the model answers with: lowercase letters, digits, dashes. */
|
|
83
|
+
id: string;
|
|
84
|
+
label?: string;
|
|
85
|
+
/** The capability this option proposes. Omit for a step only a person can take. */
|
|
86
|
+
capability?: string;
|
|
87
|
+
input?: Record<string, unknown>;
|
|
88
|
+
reason?: string;
|
|
89
|
+
}
|
|
90
|
+
/** Always offered: hand the task to a person instead of acting. */
|
|
91
|
+
export declare const ESCALATE = "escalate";
|
|
92
|
+
export interface ActionOutcome {
|
|
93
|
+
actionId: string;
|
|
94
|
+
capability: string;
|
|
95
|
+
ok: boolean;
|
|
96
|
+
/** Redacted. */
|
|
97
|
+
output?: unknown;
|
|
98
|
+
error?: {
|
|
99
|
+
code: string;
|
|
100
|
+
message: string;
|
|
101
|
+
};
|
|
102
|
+
/** The activity entry that records it: checkpoint evidence, verified on commit. */
|
|
103
|
+
activityId?: string;
|
|
104
|
+
durationMs: number;
|
|
105
|
+
/** Set when the call was abandoned before it answered; its effect may still happen. */
|
|
106
|
+
aborted?: "timeout" | "cancelled";
|
|
107
|
+
}
|
|
108
|
+
export type ActionState = "proposed" | "rejected" | "approved" | "executing" | "succeeded" | "failed" | "cancelled" | "interrupted";
|
|
109
|
+
/** States that still need something: approval, completion, or a person to settle them. */
|
|
110
|
+
export declare const OPEN_STATES: readonly ActionState[];
|
|
111
|
+
/** A consequential action as recorded in FeltDB agent memory. Never holds a secret. */
|
|
112
|
+
export interface ActionRecord extends ProposedAction {
|
|
113
|
+
state: ActionState;
|
|
114
|
+
/** Position in the record chain (`<actionId>.<seq>`). */
|
|
115
|
+
seq: number;
|
|
116
|
+
/** A retry after a failure is a new attempt, with a new idempotency key. */
|
|
117
|
+
attempt: number;
|
|
118
|
+
/** Who approved, rejected, or cancelled it (`type:id`). */
|
|
119
|
+
decidedBy?: string;
|
|
120
|
+
decidedAt?: string;
|
|
121
|
+
decisionNote?: string;
|
|
122
|
+
/** Whose authority it runs with: the task owner. */
|
|
123
|
+
executedAs?: string;
|
|
124
|
+
/** The AppPort request id, persisted before the call: how recovery finds its evidence. */
|
|
125
|
+
requestId?: string;
|
|
126
|
+
idempotencyKey?: string;
|
|
127
|
+
startedAt?: string;
|
|
128
|
+
finishedAt?: string;
|
|
129
|
+
outcome?: {
|
|
130
|
+
ok: boolean;
|
|
131
|
+
output?: unknown;
|
|
132
|
+
error?: {
|
|
133
|
+
code: string;
|
|
134
|
+
message: string;
|
|
135
|
+
};
|
|
136
|
+
activityId?: string;
|
|
137
|
+
determinedBy: "dispatch" | "appport-idempotency-record" | "function-activity" | "service-evidence" | "integration-call" | "integration-verification" | "person";
|
|
138
|
+
resolvedBy?: string;
|
|
139
|
+
};
|
|
140
|
+
/** Why the outcome is unknown. */
|
|
141
|
+
interruption?: string;
|
|
142
|
+
history: Array<{
|
|
143
|
+
state: ActionState;
|
|
144
|
+
at: string;
|
|
145
|
+
by: string;
|
|
146
|
+
note?: string;
|
|
147
|
+
}>;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Tests only: fault injection at the points where a real process could stop. A hook
|
|
151
|
+
* that throws behaves like a crash: nothing after it in the action's lifecycle runs.
|
|
152
|
+
*/
|
|
153
|
+
export interface AgentHooks {
|
|
154
|
+
afterApproved?: (at: {
|
|
155
|
+
taskId: string;
|
|
156
|
+
actionId: string;
|
|
157
|
+
}) => void | Promise<void>;
|
|
158
|
+
beforeInvoke?: (at: {
|
|
159
|
+
taskId: string;
|
|
160
|
+
actionId: string;
|
|
161
|
+
}) => void | Promise<void>;
|
|
162
|
+
afterInvoke?: (at: {
|
|
163
|
+
taskId: string;
|
|
164
|
+
actionId: string;
|
|
165
|
+
}) => void | Promise<void>;
|
|
166
|
+
}
|
|
167
|
+
export interface TaskView {
|
|
168
|
+
task: AgentTask;
|
|
169
|
+
checkpoints: AgentCheckpoint[];
|
|
170
|
+
execution: Record<string, unknown> | null;
|
|
171
|
+
/** Actions waiting for approval. */
|
|
172
|
+
pending: ActionRecord[];
|
|
173
|
+
/** Every consequential action on the task, in any state. */
|
|
174
|
+
actions: ActionRecord[];
|
|
175
|
+
playbook?: string;
|
|
176
|
+
}
|
|
177
|
+
export declare const PLAYBOOKS: readonly ["diagnose-job", "diagnose-delivery", "inspect-app", "invoke", "decide", "handoff"];
|
|
178
|
+
export type Playbook = (typeof PLAYBOOKS)[number];
|
|
179
|
+
/** Remove credential material from anything recorded or returned. */
|
|
180
|
+
export declare function redact(value: unknown, depth?: number): unknown;
|
|
181
|
+
export declare class AgentHost {
|
|
182
|
+
#private;
|
|
183
|
+
constructor(runtime: FeltKitRuntime, db: StateFirstDB, options?: {
|
|
184
|
+
actionTimeoutMs?: number;
|
|
185
|
+
hooks?: AgentHooks;
|
|
186
|
+
separateApprover?: boolean;
|
|
187
|
+
});
|
|
188
|
+
/** Open agent state and define the agent. The runtime reconciles open actions once it is ready (outcome hooks are function calls). */
|
|
189
|
+
open(): Promise<void>;
|
|
190
|
+
/** (Re)define the agent with the application's current capabilities. Called on reload. */
|
|
191
|
+
define(): void;
|
|
192
|
+
/** What `principal` could ask the agent to do, with an authorization decision for each. */
|
|
193
|
+
tools(principal: Principal): Promise<AgentTool[]>;
|
|
194
|
+
/**
|
|
195
|
+
* The agent's own boundary: using the agent needs feltkit.agent.* (or a grant covering
|
|
196
|
+
* it). "admin" is the dashboard's admin token, which may read (never act).
|
|
197
|
+
*/
|
|
198
|
+
authorizeRead(principal: Principal | null | "admin"): void;
|
|
199
|
+
createTask(input: {
|
|
200
|
+
objective: string;
|
|
201
|
+
principal: Principal | null;
|
|
202
|
+
playbook?: Playbook;
|
|
203
|
+
target?: string;
|
|
204
|
+
capability?: string;
|
|
205
|
+
args?: Record<string, unknown>;
|
|
206
|
+
decision?: DecisionSpec;
|
|
207
|
+
taskId?: string;
|
|
208
|
+
subject?: {
|
|
209
|
+
collection: string;
|
|
210
|
+
id: string;
|
|
211
|
+
};
|
|
212
|
+
}): Promise<TaskView>;
|
|
213
|
+
list(principal: Principal | null | "admin", limit?: number): Promise<Array<{
|
|
214
|
+
task: AgentTask;
|
|
215
|
+
execution: Record<string, unknown> | null;
|
|
216
|
+
pending: number;
|
|
217
|
+
}>>;
|
|
218
|
+
get(taskId: string, principal: Principal | null | "admin"): Promise<TaskView>;
|
|
219
|
+
/** The FeltDB context bundle for a task, plus this application's context. Redacted. */
|
|
220
|
+
context(taskId: string, principal: Principal | null): Promise<unknown>;
|
|
221
|
+
/**
|
|
222
|
+
* What an agent needs to know about this application, as `principal` sees it: the
|
|
223
|
+
* data model, capabilities it may use, services and their states, and recent failures.
|
|
224
|
+
*/
|
|
225
|
+
applicationContext(principal: Principal): Promise<{
|
|
226
|
+
application: string;
|
|
227
|
+
environment: import("./environment.js").EnvironmentName;
|
|
228
|
+
collections: {
|
|
229
|
+
fields: string[];
|
|
230
|
+
description?: string | undefined;
|
|
231
|
+
name: string;
|
|
232
|
+
}[];
|
|
233
|
+
tools: AgentTool[];
|
|
234
|
+
services: {
|
|
235
|
+
summary?: Record<string, number> | undefined;
|
|
236
|
+
id: string;
|
|
237
|
+
state: import("./services.js").ServiceState;
|
|
238
|
+
detail: string;
|
|
239
|
+
}[];
|
|
240
|
+
recentErrors: {
|
|
241
|
+
at: string;
|
|
242
|
+
name: string;
|
|
243
|
+
via: import("./activity.js").ActivityVia;
|
|
244
|
+
code: string | undefined;
|
|
245
|
+
message: string | undefined;
|
|
246
|
+
}[];
|
|
247
|
+
recentDenials: {
|
|
248
|
+
at: string;
|
|
249
|
+
name: string;
|
|
250
|
+
via: import("./activity.js").ActivityVia;
|
|
251
|
+
principal: string | undefined;
|
|
252
|
+
}[];
|
|
253
|
+
}>;
|
|
254
|
+
/**
|
|
255
|
+
* Propose an action. An observation runs now as the task owner; a consequential
|
|
256
|
+
* action waits for approval. Either way it goes only through AppPort.
|
|
257
|
+
*/
|
|
258
|
+
propose(taskId: string, proposal: {
|
|
259
|
+
capability: string;
|
|
260
|
+
input?: Record<string, unknown>;
|
|
261
|
+
reason: string;
|
|
262
|
+
decision?: ProposedAction["decision"];
|
|
263
|
+
}, principal: Principal | null): Promise<TaskView>;
|
|
264
|
+
/**
|
|
265
|
+
* Approve a proposed action, then run it as the task owner. Everything that can refuse
|
|
266
|
+
* is checked before the proposal is consumed: the approver is a person with
|
|
267
|
+
* feltkit.agent.write who may perform the action; the owner can still be resolved and
|
|
268
|
+
* may perform it. A refusal is recorded on the action, which stays proposed. A
|
|
269
|
+
* duplicate or concurrent approval of the same action never runs it twice.
|
|
270
|
+
*/
|
|
271
|
+
approve(taskId: string, actionId: string, approver: Principal | null): Promise<TaskView>;
|
|
272
|
+
/** Reject a proposed action. */
|
|
273
|
+
reject(taskId: string, actionId: string, principal: Principal | null, reason?: string): Promise<TaskView>;
|
|
274
|
+
/**
|
|
275
|
+
* Retry an action that failed with a known outcome: a new attempt, with a new
|
|
276
|
+
* idempotency key, that needs approval again. The owner or a person may ask.
|
|
277
|
+
*/
|
|
278
|
+
retry(taskId: string, actionId: string, principal: Principal | null): Promise<TaskView>;
|
|
279
|
+
/**
|
|
280
|
+
* Settle an interrupted action whose outcome FeltKit could not determine. Only a person
|
|
281
|
+
* who may perform the action can say what happened; FeltKit never guesses.
|
|
282
|
+
*/
|
|
283
|
+
resolve(taskId: string, actionId: string, input: {
|
|
284
|
+
outcome: "succeeded" | "failed";
|
|
285
|
+
note?: string;
|
|
286
|
+
}, principal: Principal | null): Promise<TaskView>;
|
|
287
|
+
/**
|
|
288
|
+
* Bring every open action to a state that matches what is known, after a restart or on
|
|
289
|
+
* demand. Every open task (FeltDB's listTasks, paged), deterministic; it never runs an
|
|
290
|
+
* action:
|
|
291
|
+
*
|
|
292
|
+
* approved → proposed execution had not started; approval must be repeated
|
|
293
|
+
* executing → succeeded / failed from evidence (AppPort's idempotency record or the
|
|
294
|
+
* function's activity entry; AppPort Services' effect evidence), else
|
|
295
|
+
* → interrupted (outcome unknown)
|
|
296
|
+
* interrupted → succeeded / failed when such evidence has appeared since
|
|
297
|
+
*/
|
|
298
|
+
reconcile(): Promise<{
|
|
299
|
+
examined: number;
|
|
300
|
+
changes: Array<{
|
|
301
|
+
taskId: string;
|
|
302
|
+
actionId: string;
|
|
303
|
+
from: ActionState;
|
|
304
|
+
to: ActionState;
|
|
305
|
+
determinedBy: string;
|
|
306
|
+
}>;
|
|
307
|
+
}>;
|
|
308
|
+
/** Finish a task. The summary is the owner's; evidence is what the checkpoints cite. */
|
|
309
|
+
complete(taskId: string, summary: string, principal: Principal | null): Promise<TaskView>;
|
|
310
|
+
/**
|
|
311
|
+
* Cancel a task. Actions not yet running are cancelled. A running action is aborted;
|
|
312
|
+
* since its effect may still complete, it becomes interrupted, and the task is not
|
|
313
|
+
* cancelled until every such action is settled (FeltDB takes no checkpoint after a
|
|
314
|
+
* terminal one, so settling must come first).
|
|
315
|
+
*/
|
|
316
|
+
cancel(taskId: string, principal: Principal | null, reason?: string): Promise<TaskView>;
|
|
317
|
+
openHandoffs(principal: Principal | null | "admin"): Promise<{
|
|
318
|
+
handoffId: string;
|
|
319
|
+
taskId: string;
|
|
320
|
+
objective: string;
|
|
321
|
+
from: string;
|
|
322
|
+
note: string | null;
|
|
323
|
+
createdAt: string;
|
|
324
|
+
}[]>;
|
|
325
|
+
/** Claim and accept a handoff: the claimant becomes the task's owner and gets its context. */
|
|
326
|
+
claim(handoffId: string, principal: Principal | null): Promise<{
|
|
327
|
+
taskId: string;
|
|
328
|
+
context: unknown;
|
|
329
|
+
}>;
|
|
330
|
+
/** A note from the owner: decisions and progress, recorded as a checkpoint. */
|
|
331
|
+
note(taskId: string, input: {
|
|
332
|
+
summary: string;
|
|
333
|
+
decisions?: string[];
|
|
334
|
+
pendingWork?: string[];
|
|
335
|
+
}, principal: Principal | null): Promise<TaskView>;
|
|
336
|
+
/**
|
|
337
|
+
* Put the task's decision to the model again, e.g. after its configuration was fixed.
|
|
338
|
+
* The owner or a person may ask; the answer is a new proposal, never an execution.
|
|
339
|
+
*/
|
|
340
|
+
decide(taskId: string, principal: Principal | null): Promise<TaskView>;
|
|
341
|
+
/** Start a decision task after the caller's transaction commits (ctx.agent.start). Tracked by idle(). */
|
|
342
|
+
startAfterCommit(input: {
|
|
343
|
+
taskId: string;
|
|
344
|
+
objective: string;
|
|
345
|
+
decision: DecisionSpec;
|
|
346
|
+
subject?: {
|
|
347
|
+
collection: string;
|
|
348
|
+
id: string;
|
|
349
|
+
};
|
|
350
|
+
}, principal: Principal): void;
|
|
351
|
+
/** Resolves when tasks started after commits have made their first decision. */
|
|
352
|
+
idle(): Promise<void>;
|
|
353
|
+
}
|