@feltdb/feltkit 0.3.35 → 0.3.36

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/docs.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export declare const PACKAGE_NAME = "@feltdb/feltkit";
2
2
  /** The documents shipped in the package, with what each one answers. Order = reading order. */
3
- export declare const SHIPPED_DOCS: readonly [readonly ["ARCHITECTURE.md", "How FeltKit is put together: one FeltDB instance, AppPort, AppPort Services"], readonly ["GUARANTEES.md", "What FeltKit guarantees, and its known limitations"], readonly ["TRANSACTIONS.md", "Mutations, ctx.db.sequence and ctx.afterCommit: the transaction contract"], readonly ["SECURITY.md", "Authorization, sessions, credentials, and production Studio"], readonly ["AUTH.md", "Accounts, sessions, workspaces (tenancy), invitations, and the React sign-in and workspace screens"], readonly ["POLICIES.md", "Declarative policies (owner, sharing, state, input, roles, delegation), managed versions without a redeploy, simulation, decision evidence"], readonly ["SIGN-IN-BROKER.md", "Sign in with GitHub and Google with nothing to register: the FeltKit broker, the assertion it signs, the extension flow, running and rotating it"], readonly ["EXTENSION-HOSTS.md", "Running the app in a browser extension: ownership, token storage, session end, lifecycle, gaps"], readonly ["INVOCATIONS.md", "Surfaces and invocations: registering entry points, the feltkit.invocation/1 contract, the durable lifecycle, dispatch and recovery"], readonly ["EXECUTION.md", "Placement-neutral execution: the control plane and execution environments, the execution contract, adapters, placement, authority and evidence"], readonly ["LOCAL-AUTHORITY.md", "The private AuthBoundry beside the application (authority.local): grants, agents, per-agent delegation and the agentCallers opt-in"], readonly ["CONNECTIONS.md", "People's own connections to integrations (credential.owner: person): connecting, isolation, AuthBoundry at every call (reference implementation)"], readonly ["AGENT-OPERATIONS.md", "Agents: MCP, tasks, proposals, approvals, and evidence"], readonly ["GENERATION.md", "Model generation in an application: actions, streaming, tools as proposals, in-app approvals, caller context"], readonly ["RESOLVER.md", "Model references: change the model a deployed app uses through Resolver, without a redeploy"], readonly ["PATH-TO-PRODUCTION.md", "From a local app to production: deploy targets and what you must provide"], readonly ["BACKUP.md", "Backing up and restoring an environment's state"], readonly ["COMPONENTS.md", "Runtime components: a gateway or worker that runs with the application, as a declared principal"], readonly ["PROVIDERS.md", "AppPort providers: packages that contribute capabilities, credentials, external effects and channels to the application"], readonly ["APPBOUNDRY.md", "The AppBoundry artifact, deploying through AppBoundry, and the self-hosted runtime"], readonly ["APPBOUNDRY-DEPLOY-CONTRACT.md", "The deployment contract FeltKit expects from AppBoundry (proposed)"], readonly ["WHY-FELTKIT.md", "Design choices, compared with Convex"], readonly ["UPSTREAM-GAPS.md", "Known gaps in FeltDB, AppPort and AppPort Services, and their status"], readonly ["MEASURE.md", "feltkit measure: what an application is made of, its provenance, platform use and app-built infrastructure"]];
3
+ export declare const SHIPPED_DOCS: readonly [readonly ["ARCHITECTURE.md", "How FeltKit is put together: one FeltDB instance, AppPort, AppPort Services"], readonly ["GUARANTEES.md", "What FeltKit guarantees, and its known limitations"], readonly ["TRANSACTIONS.md", "Mutations, ctx.db.sequence and ctx.afterCommit: the transaction contract"], readonly ["SECURITY.md", "Authorization, sessions, credentials, and production Studio"], readonly ["AUTH.md", "Accounts, sessions, workspaces (tenancy), invitations, and the React sign-in and workspace screens"], readonly ["POLICIES.md", "Declarative policies (owner, sharing, state, input, roles, delegation), managed versions without a redeploy, simulation, decision evidence"], readonly ["SIGN-IN-BROKER.md", "Sign in with GitHub and Google with nothing to register: the FeltKit broker, the assertion it signs, the extension flow, running and rotating it"], readonly ["EXTENSION-HOSTS.md", "Running the app in a browser extension: ownership, token storage, session end, lifecycle, gaps"], readonly ["INVOCATIONS.md", "Surfaces and invocations: registering entry points, the feltkit.invocation/1 contract, the durable lifecycle, dispatch and recovery"], readonly ["EXECUTION.md", "Placement-neutral execution: the control plane and execution environments, the execution contract, adapters, placement, authority and evidence"], readonly ["LOCAL-AUTHORITY.md", "The private AuthBoundry beside the application (authority.local): grants, agents, per-agent delegation and the agentCallers opt-in"], readonly ["CONNECTIONS.md", "People's own connections to integrations (credential.owner: person): connecting, isolation, AuthBoundry at every call (reference implementation)"], readonly ["AGENT-OPERATIONS.md", "Agents: MCP, tasks, proposals, approvals, and evidence"], readonly ["AGENT-CONTROL.md", "Steering a running agent: update signals, submitted updates at safe boundaries, pause, resume, interrupt, stop"], readonly ["GENERATION.md", "Model generation in an application: actions, streaming, tools as proposals, in-app approvals, caller context"], readonly ["RESOLVER.md", "Model references: change the model a deployed app uses through Resolver, without a redeploy"], readonly ["PATH-TO-PRODUCTION.md", "From a local app to production: deploy targets and what you must provide"], readonly ["BACKUP.md", "Backing up and restoring an environment's state"], readonly ["COMPONENTS.md", "Runtime components: a gateway or worker that runs with the application, as a declared principal"], readonly ["PROVIDERS.md", "AppPort providers: packages that contribute capabilities, credentials, external effects and channels to the application"], readonly ["APPBOUNDRY.md", "The AppBoundry artifact, deploying through AppBoundry, and the self-hosted runtime"], readonly ["APPBOUNDRY-DEPLOY-CONTRACT.md", "The deployment contract FeltKit expects from AppBoundry (proposed)"], readonly ["WHY-FELTKIT.md", "Design choices, compared with Convex"], readonly ["UPSTREAM-GAPS.md", "Known gaps in FeltDB, AppPort and AppPort Services, and their status"], readonly ["MEASURE.md", "feltkit measure: what an application is made of, its provenance, platform use and app-built infrastructure"]];
4
4
  export type DocName = (typeof SHIPPED_DOCS)[number][0];
5
5
  /** The shipped file on disk (inside node_modules/@feltdb/feltkit in a project). */
6
6
  export declare function docFile(name: DocName): string;
package/dist/docs.js CHANGED
@@ -27,6 +27,7 @@ export const SHIPPED_DOCS = [
27
27
  ["LOCAL-AUTHORITY.md", "The private AuthBoundry beside the application (authority.local): grants, agents, per-agent delegation and the agentCallers opt-in"],
28
28
  ["CONNECTIONS.md", "People's own connections to integrations (credential.owner: person): connecting, isolation, AuthBoundry at every call (reference implementation)"],
29
29
  ["AGENT-OPERATIONS.md", "Agents: MCP, tasks, proposals, approvals, and evidence"],
30
+ ["AGENT-CONTROL.md", "Steering a running agent: update signals, submitted updates at safe boundaries, pause, resume, interrupt, stop"],
30
31
  ["GENERATION.md", "Model generation in an application: actions, streaming, tools as proposals, in-app approvals, caller context"],
31
32
  ["RESOLVER.md", "Model references: change the model a deployed app uses through Resolver, without a redeploy"],
32
33
  ["PATH-TO-PRODUCTION.md", "From a local app to production: deploy targets and what you must provide"],
package/dist/docs.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"docs.js","sourceRoot":"","sources":["../src/docs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,CAAC,MAAM,YAAY,GAAG,iBAAiB,CAAC;AAC9C,MAAM,OAAO,GAAW,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,iBAAiB,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;AAE9G,+FAA+F;AAC/F,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,CAAC,iBAAiB,EAAE,6EAA6E,CAAC;IAClG,CAAC,eAAe,EAAE,oDAAoD,CAAC;IACvE,CAAC,iBAAiB,EAAE,0EAA0E,CAAC;IAC/F,CAAC,aAAa,EAAE,6DAA6D,CAAC;IAC9E,CAAC,SAAS,EAAE,oGAAoG,CAAC;IACjH,CAAC,aAAa,EAAE,4IAA4I,CAAC;IAC7J,CAAC,mBAAmB,EAAE,kJAAkJ,CAAC;IACzK,CAAC,oBAAoB,EAAE,gGAAgG,CAAC;IACxH,CAAC,gBAAgB,EAAE,qIAAqI,CAAC;IACzJ,CAAC,cAAc,EAAE,gJAAgJ,CAAC;IAClK,CAAC,oBAAoB,EAAE,oIAAoI,CAAC;IAC5J,CAAC,gBAAgB,EAAE,kJAAkJ,CAAC;IACtK,CAAC,qBAAqB,EAAE,wDAAwD,CAAC;IACjF,CAAC,eAAe,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AAC;CACpH,CAAC;AAIX,mFAAmF;AACnF,MAAM,UAAU,OAAO,CAAC,IAAa;IACnC,OAAO,aAAa,CAAC,IAAI,GAAG,CAAC,WAAW,IAAI,EAAE,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,MAAM,CAAC,IAAc;IACnC,OAAO,gCAAgC,YAAY,IAAI,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AAC1G,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,MAAM,CAAC,IAAa;IAClC,OAAO,gBAAgB,YAAY,SAAS,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AACvE,CAAC;AAED,gFAAgF;AAChF,MAAM,CAAC,MAAM,YAAY,GAAG,iCAAiC,YAAY,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { AgentHost } from "./agent.js";
2
+ import type { Principal } from "./authority.js";
3
+ export declare const AGENT_CONTROL_EXTENSION = "appport.agent-control/1";
4
+ export declare function agentControlCapabilities(host: () => AgentHost, principalOf: (context: any) => Principal | null, errors: (fn: () => Promise<unknown>) => Promise<any>): import("@appport/sdk").CapabilityDefinition<unknown, unknown>[];
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Agent control as AppPort capabilities: the `appport.agent-control/1` contract (AppPort's
3
+ * spec/agent-control-1.md), served by this application beside its own capabilities. Each handler
4
+ * is one call into AgentHost.control; the lifecycle stays there. Names, effects, idempotency and
5
+ * required inputs follow the contract; `lintAgentControlSupport` (@appport/protocol) checks them.
6
+ *
7
+ * The schemas are written here with @appport/schema because the published @appport/protocol this
8
+ * package pins predates the contract module; once it ships, they should come from there.
9
+ */
10
+ import { defineCapability } from "@appport/sdk";
11
+ import { s } from "@appport/schema";
12
+ import { FeltKitError } from "../errors.js";
13
+ import { AGENT_PERMISSIONS } from "./agent.js";
14
+ export const AGENT_CONTROL_EXTENSION = "appport.agent-control/1";
15
+ const id = () => s.string({ minLength: 1, maxLength: 128 });
16
+ const reason = () => s.optional(s.string({ maxLength: 500 }));
17
+ const loose = (shape) => s.object(shape, { additionalProperties: true });
18
+ const instruction = loose({ instructionId: s.string(), taskId: s.string(), state: s.enum(["signaled", "received", "delivered", "incorporated", "conflict", "withdrawn", "abandoned"]), seq: s.integer(), from: s.string() });
19
+ const state = loose({ taskId: s.string(), phase: s.enum(["running", "pausing", "paused", "interrupted", "blocked", "completed", "stopped"]), mode: s.enum(["running", "paused", "interrupted"]), revision: s.string(), instructions: s.array(instruction) });
20
+ export function agentControlCapabilities(host, principalOf, errors) {
21
+ const write = [AGENT_PERMISSIONS.write];
22
+ const op = (name, input, output, run, description) => defineCapability({
23
+ name: `appport.agent.${name}`,
24
+ version: 1,
25
+ description,
26
+ input,
27
+ output,
28
+ authorization: write,
29
+ effect: "consequential",
30
+ idempotency: "supported",
31
+ handler: (i, context) => errors(() => run(principalOf(context), i, context)),
32
+ });
33
+ // An AppPort idempotencyKey also names the update, so a replay without a stored response is still one update.
34
+ const key = (context) => (typeof context?.idempotencyKey === "string" ? { key: context.idempotencyKey } : {});
35
+ const asState = async (p, taskId) => ({ state: await host().control.view(taskId, p) });
36
+ return [
37
+ defineCapability({
38
+ name: "appport.agent.state",
39
+ version: 1,
40
+ description: "A task's control state: phase, mode, work in flight, and every update in order.",
41
+ input: s.object({ taskId: id() }),
42
+ output: s.object({ state }),
43
+ authorization: [AGENT_PERMISSIONS.read],
44
+ effect: "observation",
45
+ handler: (i, context) => errors(async () => {
46
+ const p = principalOf(context);
47
+ if (!p)
48
+ throw new FeltKitError("UNAUTHORIZED", "Sign in to read agent tasks.");
49
+ return asState(p, i.taskId);
50
+ }),
51
+ }),
52
+ op("signal", s.object({ taskId: id(), note: s.optional(s.string({ maxLength: 200 })) }), s.object({ instruction }), async (p, i, c) => ({ instruction: await host().control.signal(i.taskId, { ...key(c), ...(i.note ? { note: i.note } : {}) }, p) }), "An update is coming. Recorded; the agent keeps working."),
53
+ op("submit", s.object({ taskId: id(), text: s.string({ minLength: 1, maxLength: 8000 }), instructionId: s.optional(id()) }), s.object({ instruction }), async (p, i, c) => ({ instruction: await host().control.submit(i.taskId, { text: i.text, ...(i.instructionId ? { instructionId: i.instructionId } : key(c)) }, p) }), "Submit an update; it reaches the agent at its next checkpoint. Acknowledges receipt only."),
54
+ op("withdraw", s.object({ taskId: id(), instructionId: id(), reason: reason() }), s.object({ instruction }), async (p, i) => ({ instruction: await host().control.withdraw(i.taskId, i.instructionId, p, i.reason) }), "Take back an update the agent has not been given."),
55
+ op("pause", s.object({ taskId: id(), reason: reason() }), s.object({ state }), async (p, i) => ({ state: await host().control.pause(i.taskId, p, i.reason) }), "Start no new work; work in flight finishes and is recorded."),
56
+ op("resume", s.object({ taskId: id(), reason: reason() }), s.object({ state }), async (p, i) => ({ state: await host().control.resume(i.taskId, p, i.reason) }), "Continue from the recorded state."),
57
+ op("interrupt", s.object({ taskId: id(), reason: reason() }), s.object({ state }), async (p, i) => ({ state: await host().control.interrupt(i.taskId, p, i.reason) }), "Cancel in-progress reasoning now and hold. A dispatched operation is not aborted."),
58
+ op("stop", s.object({ taskId: id(), reason: reason() }), s.object({ state }), async (p, i) => {
59
+ await host().cancel(i.taskId, p, i.reason ?? "stopped");
60
+ return asState(p, i.taskId);
61
+ }, "End the task. Open updates are closed as abandoned."),
62
+ op("checkpoint", s.object({ taskId: id() }), loose({ proceed: s.boolean(), mode: s.string(), instructions: s.array(loose({ instructionId: s.string(), text: s.string() })), signaled: s.integer(), checkpoint: s.integer() }), async (p, i) => host().control.checkpoint(i.taskId, p), "The safe boundary (the task owner): receive pending updates and whether to proceed."),
63
+ op("acknowledge", s.object({ taskId: id(), instructionId: id(), outcome: s.enum(["incorporated", "conflict"]), note: s.string({ minLength: 1, maxLength: 2000 }) }), s.object({ instruction }), async (p, i) => ({ instruction: await host().control.acknowledge(i.taskId, i.instructionId, { outcome: i.outcome, note: i.note }, p) }), "Say what a delivered update changed, or surface a conflict (the task pauses)."),
64
+ ];
65
+ }
66
+ //# sourceMappingURL=agent-control-capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-control-capabilities.js","sourceRoot":"","sources":["../../src/runtime/agent-control-capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAI/C,MAAM,CAAC,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AAEjE,MAAM,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;AAC5D,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;AAC9D,MAAM,KAAK,GAAG,CAAC,KAA0B,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9F,MAAM,WAAW,GAAG,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,C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EAAE,CAAc,CAAC,EAAE,qFAAqF,CAAC;QAC1X,EAAE,CAAC,aAAa,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,IAAI,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,aAAa,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAc,CAAC,EAAE,CAAC,EAAE,+EAA+E,CAAC;KACva,CAAC;AACJ,CAAC"}
@@ -0,0 +1,173 @@
1
+ import { type AgentMemory, type AgentStateStore, type AgentTask } from "@feltdb/core";
2
+ import type { Principal } from "./authority.js";
3
+ export declare const CONTROL_KIND = "agent-control";
4
+ export declare const INSTRUCTION_KIND = "agent-instruction";
5
+ export declare const INSTRUCTION_TEXT_LIMIT = 8000;
6
+ export type ControlMode = "running" | "paused" | "interrupted";
7
+ /** What a person sees: the mode, with in-flight work taken into account. Derived, never stored. */
8
+ export type ExecutionPhase = "running" | "pausing" | "paused" | "interrupted" | "blocked" | "completed" | "stopped";
9
+ export interface ControlRecord {
10
+ taskId: string;
11
+ mode: ControlMode;
12
+ seq: number;
13
+ reason?: string;
14
+ setBy?: string;
15
+ setAt?: string;
16
+ history: Array<{
17
+ mode: ControlMode;
18
+ at: string;
19
+ by: string;
20
+ note?: string;
21
+ }>;
22
+ }
23
+ export type InstructionState = "signaled" | "received" | "delivered" | "incorporated" | "conflict" | "withdrawn" | "abandoned";
24
+ export declare const OPEN_INSTRUCTION: readonly InstructionState[];
25
+ export interface InstructionRecord {
26
+ instructionId: string;
27
+ taskId: string;
28
+ state: InstructionState;
29
+ seq: number;
30
+ /** Who signaled or submitted it (`type:id`). */
31
+ from: string;
32
+ /** The update itself; absent while only signaled. */
33
+ text?: string;
34
+ /** A note sent with the signal ("about the date range"). Never instructions. */
35
+ note?: string;
36
+ signaledAt?: string;
37
+ receivedAt?: string;
38
+ deliveredAt?: string;
39
+ /** The checkpoint (FeltDB checkpoint version) at which it was handed to the reasoner. */
40
+ deliveredAtCheckpoint?: number;
41
+ resolvedAt?: string;
42
+ /** incorporated / conflict: what the reasoner said it changes; withdrawn / abandoned: why. */
43
+ resolution?: {
44
+ by: string;
45
+ note: string;
46
+ };
47
+ history: Array<{
48
+ state: InstructionState;
49
+ at: string;
50
+ by: string;
51
+ note?: string;
52
+ }>;
53
+ }
54
+ /** What AgentHost gives this module: its state store and its existing checks, nothing more. */
55
+ export interface ControlPort {
56
+ state(): AgentStateStore;
57
+ memories(taskId: string): Promise<AgentMemory[]>;
58
+ /** The task, in the caller's scope, not terminal (NOT_FOUND / CONFLICT otherwise). */
59
+ loaded(taskId: string, p: Principal): Promise<{
60
+ task: AgentTask;
61
+ }>;
62
+ /** Any task in the caller's scope, terminal ones included (for reads). */
63
+ find(taskId: string, p: Principal | "admin"): Promise<{
64
+ task: AgentTask;
65
+ } | null>;
66
+ /** Work in flight right now, from durable records: open generations and actions approved/executing. */
67
+ inFlight(taskId: string): Promise<{
68
+ generations: string[];
69
+ actions: string[];
70
+ }>;
71
+ /** Abort this process's running generations for a task (interrupt). */
72
+ abortGenerations(taskId: string, reason: string): number;
73
+ activity(name: string, p: Principal, taskId: string, outcome: "success" | "error" | "denied", detail: Record<string, unknown>): void;
74
+ }
75
+ export interface ControlView {
76
+ taskId: string;
77
+ objective: string;
78
+ owner: string;
79
+ phase: ExecutionPhase;
80
+ mode: ControlMode;
81
+ reason: string | null;
82
+ inFlight: {
83
+ generations: string[];
84
+ actions: string[];
85
+ };
86
+ /** Updates signaled and not yet submitted. */
87
+ signaled: number;
88
+ /** Every update, in order (oldest first). */
89
+ instructions: InstructionRecord[];
90
+ /** The latest FeltDB checkpoint version: the boundary count. */
91
+ checkpoint: number;
92
+ /** Changes whenever anything above changes; clients use it to drop stale snapshots. */
93
+ revision: string;
94
+ }
95
+ export interface Checkpoint {
96
+ /** False while paused or interrupted: start no new work, call checkpoint again later. */
97
+ proceed: boolean;
98
+ mode: ControlMode;
99
+ reason: string | null;
100
+ /** Updates the reasoner must take into account now, oldest first (delivered, not yet acknowledged). */
101
+ instructions: Array<{
102
+ instructionId: string;
103
+ text: string;
104
+ from: string;
105
+ receivedAt: string;
106
+ deliveredAt: string;
107
+ }>;
108
+ /** Updates a person has said are coming but not sent yet. Keep working; they arrive at a later checkpoint. */
109
+ signaled: number;
110
+ checkpoint: number;
111
+ }
112
+ export declare class AgentControl {
113
+ #private;
114
+ constructor(port: ControlPort);
115
+ mode(taskId: string): Promise<{
116
+ mode: ControlMode;
117
+ reason: string | null;
118
+ }>;
119
+ view(taskId: string, p: Principal | "admin"): Promise<ControlView>;
120
+ /**
121
+ * Refuses new work (a generation or a proposal) unless the task is running and every received
122
+ * update has been handed to the reasoner. Signaled updates do not block: the agent keeps working.
123
+ */
124
+ gate(taskId: string, what: string): Promise<void>;
125
+ /** Completing would silently drop an update: refused while any is open (signaled included). */
126
+ gateComplete(taskId: string): Promise<void>;
127
+ /** Approving runs an action now: not while the task is paused or interrupted. */
128
+ gateApproval(taskId: string): Promise<void>;
129
+ /** "An update is coming." Recorded; nothing about the agent's work changes. */
130
+ signal(taskId: string, input: {
131
+ key?: string;
132
+ note?: string;
133
+ }, p: Principal): Promise<InstructionRecord>;
134
+ /**
135
+ * Submit an update. With `instructionId`, it fills that signal (only its sender may); otherwise
136
+ * it is a new update. Acknowledges receipt only: it is not incorporated until the agent says so.
137
+ */
138
+ submit(taskId: string, input: {
139
+ text: string;
140
+ key?: string;
141
+ instructionId?: string;
142
+ }, p: Principal): Promise<InstructionRecord>;
143
+ /** Take back an update the agent has not been given yet. */
144
+ withdraw(taskId: string, instructionId: string, p: Principal, reason?: string): Promise<InstructionRecord>;
145
+ /** Stop starting new work. Running work finishes and is recorded (the phase is "pausing" until then). */
146
+ pause(taskId: string, p: Principal, reason?: string): Promise<ControlView>;
147
+ /**
148
+ * Stop now and hold: a running model generation is cancelled (recorded as cancelled). A dispatched
149
+ * action is not aborted, since that cannot undo its effect; it finishes or times out and is recorded.
150
+ */
151
+ interrupt(taskId: string, p: Principal, reason?: string): Promise<ControlView & {
152
+ cancelledGenerations: number;
153
+ }>;
154
+ /** Continue from the recorded state. Pending updates reach the agent at its next checkpoint. */
155
+ resume(taskId: string, p: Principal, reason?: string): Promise<ControlView>;
156
+ /**
157
+ * The safe boundary. Hands every received update to the reasoner (received → delivered, recorded
158
+ * with the checkpoint it was delivered at) and returns them with any delivered earlier and not yet
159
+ * acknowledged (redelivered after a restart). Idempotent: calling it again delivers nothing twice.
160
+ */
161
+ checkpoint(taskId: string, p: Principal): Promise<Checkpoint>;
162
+ /**
163
+ * The reasoner says what a delivered update changes. `incorporated`: the plan now reflects it.
164
+ * `conflict`: it contradicts the objective or completed work in a way the agent should not decide;
165
+ * the task is paused with the explanation, for a person to clarify and resume.
166
+ */
167
+ acknowledge(taskId: string, instructionId: string, input: {
168
+ outcome: "incorporated" | "conflict";
169
+ note: string;
170
+ }, p: Principal): Promise<InstructionRecord>;
171
+ /** Stop (AgentHost.cancel) succeeded: every open update is closed as abandoned, with the reason. */
172
+ abandonOpen(taskId: string, by: string, reason: string): Promise<number>;
173
+ }