@feltdb/feltkit 0.3.12 → 0.3.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +4 -3
  2. package/dist/app.d.ts +27 -1
  3. package/dist/app.js +22 -0
  4. package/dist/app.js.map +1 -1
  5. package/dist/appboundry/build.js +10 -2
  6. package/dist/appboundry/build.js.map +1 -1
  7. package/dist/appboundry/host.js +2 -2
  8. package/dist/appboundry/host.js.map +1 -1
  9. package/dist/cli/deploy.js +9 -3
  10. package/dist/cli/deploy.js.map +1 -1
  11. package/dist/cli/main.d.ts +5 -0
  12. package/dist/cli/main.js +141 -40
  13. package/dist/cli/main.js.map +1 -1
  14. package/dist/client/index.d.ts +3 -0
  15. package/dist/client/index.js +3 -0
  16. package/dist/client/index.js.map +1 -1
  17. package/dist/dashboard/assets/{index-91I1zDK-.css → index-BXTNQAg1.css} +1 -1
  18. package/dist/dashboard/assets/index-DnIOVGF-.js +15 -0
  19. package/dist/dashboard/index.html +3 -3
  20. package/dist/docs.d.ts +12 -0
  21. package/dist/docs.js +43 -0
  22. package/dist/docs.js.map +1 -0
  23. package/dist/errors.d.ts +15 -0
  24. package/dist/errors.js +9 -0
  25. package/dist/errors.js.map +1 -1
  26. package/dist/index.d.ts +1 -0
  27. package/dist/platform/changes.js +4 -2
  28. package/dist/platform/changes.js.map +1 -1
  29. package/dist/platform/deployments.js +8 -6
  30. package/dist/platform/deployments.js.map +1 -1
  31. package/dist/runtime/activity.d.ts +25 -0
  32. package/dist/runtime/activity.js +38 -12
  33. package/dist/runtime/activity.js.map +1 -1
  34. package/dist/runtime/agent.d.ts +16 -0
  35. package/dist/runtime/agent.js +97 -30
  36. package/dist/runtime/agent.js.map +1 -1
  37. package/dist/runtime/backup-environment.d.ts +8 -1
  38. package/dist/runtime/backup-environment.js +44 -12
  39. package/dist/runtime/backup-environment.js.map +1 -1
  40. package/dist/runtime/backup.d.ts +45 -3
  41. package/dist/runtime/backup.js +237 -68
  42. package/dist/runtime/backup.js.map +1 -1
  43. package/dist/runtime/capabilities.js +4 -2
  44. package/dist/runtime/capabilities.js.map +1 -1
  45. package/dist/runtime/changes.js +2 -2
  46. package/dist/runtime/changes.js.map +1 -1
  47. package/dist/runtime/contract.d.ts +10 -0
  48. package/dist/runtime/contract.js +37 -15
  49. package/dist/runtime/contract.js.map +1 -1
  50. package/dist/runtime/data.d.ts +30 -3
  51. package/dist/runtime/data.js +136 -32
  52. package/dist/runtime/data.js.map +1 -1
  53. package/dist/runtime/decisions.d.ts +41 -3
  54. package/dist/runtime/decisions.js +159 -1
  55. package/dist/runtime/decisions.js.map +1 -1
  56. package/dist/runtime/integrations.js +14 -6
  57. package/dist/runtime/integrations.js.map +1 -1
  58. package/dist/runtime/loader.js +22 -2
  59. package/dist/runtime/loader.js.map +1 -1
  60. package/dist/runtime/readiness.js +6 -1
  61. package/dist/runtime/readiness.js.map +1 -1
  62. package/dist/runtime/runtime.d.ts +24 -6
  63. package/dist/runtime/runtime.js +77 -20
  64. package/dist/runtime/runtime.js.map +1 -1
  65. package/dist/runtime/services.d.ts +19 -5
  66. package/dist/runtime/services.js +14 -4
  67. package/dist/runtime/services.js.map +1 -1
  68. package/dist/runtime/sessions.js +4 -3
  69. package/dist/runtime/sessions.js.map +1 -1
  70. package/dist/runtime/state-contract.js +3 -3
  71. package/dist/runtime/state-contract.js.map +1 -1
  72. package/dist/runtime/targets.d.ts +6 -1
  73. package/dist/runtime/targets.js +8 -0
  74. package/dist/runtime/targets.js.map +1 -1
  75. package/dist/server/admin.d.ts +2 -2
  76. package/dist/server/admin.js +37 -12
  77. package/dist/server/admin.js.map +1 -1
  78. package/dist/server/index.d.ts +2 -1
  79. package/dist/server/index.js +45 -8
  80. package/dist/server/index.js.map +1 -1
  81. package/dist/server/mcp.js +1 -1
  82. package/dist/server/mcp.js.map +1 -1
  83. package/dist/testing/index.d.ts +6 -2
  84. package/dist/testing/index.js +28 -4
  85. package/dist/testing/index.js.map +1 -1
  86. package/docs/AGENT-OPERATIONS.md +515 -0
  87. package/docs/APPBOUNDRY.md +240 -0
  88. package/docs/ARCHITECTURE.md +126 -0
  89. package/docs/BACKUP.md +115 -0
  90. package/docs/GUARANTEES.md +460 -0
  91. package/docs/PATH-TO-PRODUCTION.md +117 -0
  92. package/docs/README.md +16 -0
  93. package/docs/RESOLVER.md +167 -0
  94. package/docs/SECURITY.md +182 -0
  95. package/docs/TRANSACTIONS.md +216 -0
  96. package/docs/UPSTREAM-GAPS.md +270 -0
  97. package/docs/WHY-FELTKIT.md +64 -0
  98. package/docs/assets/feltkit-logo-dark.png +0 -0
  99. package/docs/assets/feltkit-logo.png +0 -0
  100. package/package.json +11 -8
  101. package/skills/.claude-plugin/marketplace.json +1 -1
  102. package/skills/.claude-plugin/plugin.json +3 -3
  103. package/skills/feltkit-agent/SKILL.md +9 -5
  104. package/skills/feltkit-build/SKILL.md +10 -1
  105. package/skills/feltkit-data/SKILL.md +9 -3
  106. package/skills/feltkit-services/SKILL.md +8 -4
  107. package/dist/dashboard/assets/index-BhFOquA7.js +0 -15
  108. package/dist/dashboard/theme.js +0 -11
@@ -1,5 +1,7 @@
1
1
  import { isFeltKitError } from "../errors.js";
2
- import { newId } from "./data.js";
2
+ import { countAll, newId, readAll } from "./data.js";
3
+ /** Entries removed per transaction when the log is trimmed. */
4
+ const PRUNE_BATCH = 200;
3
5
  export const ACTIVITY_COLLECTION = "_feltkit_activity";
4
6
  export class ActivityLog {
5
7
  #db;
@@ -10,11 +12,18 @@ export class ActivityLog {
10
12
  #sincePrune = 0;
11
13
  #queue = Promise.resolve();
12
14
  lastError = null;
15
+ /**
16
+ * Retention: when the log was last trimmed to `retain`, and the last failure to trim it. A failed
17
+ * prune is retried on the next recorded entry until one succeeds, and readiness reports it, so a
18
+ * failure cannot quietly leave the log growing.
19
+ */
20
+ retention = { retain: 0, lastPrunedAt: null, pruneError: null };
13
21
  constructor(db, options) {
14
22
  this.#db = db;
15
23
  this.#evidence = options.evidence;
16
24
  this.#mode = options.mode;
17
25
  this.#retain = Math.max(100, options.retain ?? 2000);
26
+ this.retention.retain = this.#retain;
18
27
  }
19
28
  get mode() {
20
29
  return this.#mode;
@@ -48,10 +57,9 @@ export class ActivityLog {
48
57
  this.#queue = this.#queue
49
58
  .then(async () => {
50
59
  await this.#db.collection(ACTIVITY_COLLECTION).insert(full, full.id);
51
- if (++this.#sincePrune >= 100) {
52
- this.#sincePrune = 0;
53
- await this.#prune();
54
- }
60
+ // Every 100 entries, or on every entry while the last prune failed (until one succeeds).
61
+ if (++this.#sincePrune >= 100 || this.retention.pruneError)
62
+ await this.prune();
55
63
  })
56
64
  .catch((error) => {
57
65
  this.lastError = { at: new Date().toISOString(), message: error.message };
@@ -95,13 +103,31 @@ export class ActivityLog {
95
103
  const lookup = await this.#evidence(requestId);
96
104
  return lookup.truncated ? [] : [...lookup.records];
97
105
  }
98
- async #prune() {
99
- const all = await this.#db.collection(ACTIVITY_COLLECTION).find({});
100
- if (all.length <= this.#retain)
101
- return;
102
- const doomed = all.sort((a, b) => a.id.localeCompare(b.id)).slice(0, all.length - this.#retain);
103
- for (const entry of doomed)
104
- await this.#db.collection(ACTIVITY_COLLECTION).delete(entry.id);
106
+ /**
107
+ * Trim the log to the newest `retain` entries. Counted and read in FeltDB pages: entry ids start
108
+ * with their time, so FeltDB's id order is oldest first, and only the excess is read. Returns how
109
+ * many entries were removed. A failure is recorded in `retention` (and thrown), never ignored.
110
+ */
111
+ async prune() {
112
+ try {
113
+ const total = await countAll(this.#db, { collection: ACTIVITY_COLLECTION });
114
+ let removed = 0;
115
+ if (total > this.#retain) {
116
+ const doomed = await readAll(this.#db, { collection: ACTIVITY_COLLECTION }, total - this.#retain);
117
+ for (let i = 0; i < doomed.length; i += PRUNE_BATCH) {
118
+ await this.#db.transaction({ operations: doomed.slice(i, i + PRUNE_BATCH).map((entry) => ({ collection: ACTIVITY_COLLECTION, id: entry.id })) });
119
+ removed += Math.min(PRUNE_BATCH, doomed.length - i);
120
+ }
121
+ }
122
+ this.#sincePrune = 0;
123
+ this.retention.lastPrunedAt = new Date().toISOString();
124
+ this.retention.pruneError = null;
125
+ return removed;
126
+ }
127
+ catch (error) {
128
+ this.retention.pruneError = { at: new Date().toISOString(), message: error?.message ?? String(error) };
129
+ throw error;
130
+ }
105
131
  }
106
132
  }
107
133
  export function errorSummary(error) {
@@ -1 +1 @@
1
- {"version":3,"file":"activity.js","sourceRoot":"","sources":["../../src/runtime/activity.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAGlC,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AAoDvD,MAAM,OAAO,WAAW;IACb,GAAG,CAAe;IAClB,KAAK,CAA8B;IACnC,OAAO,CAAS;IAChB,UAAU,GAAG,IAAI,GAAG,EAAoB,CAAC;IACzC,SAAS,CAAmD;IACrE,WAAW,GAAG,CAAC,CAAC;IAChB,MAAM,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IAC1C,SAAS,GAA2C,IAAI,CAAC;IAEzD,YAAY,EAAgB,EAAE,OAA2H;QACvJ,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACd,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC;IACvD,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,SAAS,CAAC,QAA0B;QAClC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC9B,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC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KAAK,CAAC,EAAE,CAAC;AAC1I,CAAC"}
@@ -50,6 +50,14 @@ export interface AgentTool {
50
50
  description?: string;
51
51
  /** Whether the principal asking may perform it (a decision only; nothing runs). */
52
52
  allowed: boolean;
53
+ /**
54
+ * How this principal can use it: `"direct"` (call the tool), or `"propose"` (only through
55
+ * feltkit_agent_propose: an AppPort Services operation, which is not an MCP tool, or a
56
+ * capability that requires a person's approval). Absent when `allowed` is false.
57
+ */
58
+ invoke?: "direct" | "propose";
59
+ /** `"required"`: a consequential call by this principal runs only after a person approves it. */
60
+ approval?: "required";
53
61
  }
54
62
  export interface ProposedAction {
55
63
  actionId: string;
@@ -269,6 +277,14 @@ export declare class AgentHost {
269
277
  * duplicate or concurrent approval of the same action never runs it twice.
270
278
  */
271
279
  approve(taskId: string, actionId: string, approver: Principal | null): Promise<TaskView>;
280
+ /**
281
+ * For each proposed action of a task: whether `principal` may approve it now, and if not, why
282
+ * (the same checks approve() makes; nothing changes). Studio shows Approve only when it may.
283
+ */
284
+ approvability(taskId: string, principal: Principal): Promise<Record<string, {
285
+ allowed: boolean;
286
+ reason?: string;
287
+ }>>;
272
288
  /** Reject a proposed action. */
273
289
  reject(taskId: string, actionId: string, principal: Principal | null, reason?: string): Promise<TaskView>;
274
290
  /**
@@ -33,9 +33,11 @@
33
33
  */
34
34
  import { FELTDB_AGENT_MEMORY_COLLECTION, openAgentState } from "@feltdb/core";
35
35
  import { IDEMPOTENCY_OUTCOME_UNKNOWN, idempotencyErrorReason, isIdempotencyClaim } from "@appport/sdk";
36
+ import { grantsPermission } from "@appport/authorization";
36
37
  import { createHash, randomUUID } from "node:crypto";
37
38
  import { FeltKitError, isFeltKitError } from "../errors.js";
38
39
  import { authContext } from "./authority.js";
40
+ import { readAll } from "./data.js";
39
41
  export const AGENT_NAME = "feltkit";
40
42
  export const AGENT_VERSION = 1;
41
43
  /** Permissions for using the agent itself. Actions still need their own permissions. */
@@ -191,6 +193,7 @@ export class AgentHost {
191
193
  source: "application",
192
194
  effect: (c.effect === "observation" ? "observation" : "consequential"),
193
195
  ...(c.description ? { description: c.description } : {}),
196
+ ...(fn?.approval ? { approval: fn.approval } : {}),
194
197
  permission: integration ? [integration.op.access] : fn && fn.access !== "public" && fn.access !== "authenticated" ? [fn.access] : [],
195
198
  };
196
199
  });
@@ -212,7 +215,16 @@ export class AgentHost {
212
215
  target: { name: tool.name },
213
216
  transport: "agent",
214
217
  });
215
- out.push({ name: tool.name, source: tool.source, effect: tool.effect, ...(tool.description ? { description: tool.description } : {}), allowed: decision.allowed });
218
+ const proposeOnly = tool.source === "services" || (tool.approval === "required" && principal.type !== "user");
219
+ out.push({
220
+ name: tool.name,
221
+ source: tool.source,
222
+ effect: tool.effect,
223
+ ...(tool.description ? { description: tool.description } : {}),
224
+ allowed: decision.allowed,
225
+ ...(decision.allowed ? { invoke: proposeOnly ? "propose" : "direct" } : {}),
226
+ ...(tool.approval ? { approval: tool.approval } : {}),
227
+ });
216
228
  }
217
229
  return out;
218
230
  }
@@ -401,20 +413,7 @@ export class AgentHost {
401
413
  const head = await this.#head(taskId, actionId);
402
414
  if (head.record.state !== "proposed")
403
415
  return this.#unchanged(taskId, p, head.record, "approve");
404
- const tool = this.#catalog().find((t) => t.name === head.record.capability);
405
- const owner = await this.#resolveOwner(task);
406
- const allowed = async (who) => (await this.#runtime.authority.authorize({ access: tool?.permission[0] ?? "authenticated", principal: who, target: { name: head.record.capability }, transport: "agent" })).allowed;
407
- const refusal = !tool
408
- ? `${head.record.capability} is no longer a capability of this application`
409
- : this.#separateApprover && head.record.proposedBy === actorOf(p)
410
- ? `${actorOf(p)} proposed this action and may not also approve it`
411
- : !owner
412
- ? `the task owner ${task.owner} cannot be resolved (no active session or key)`
413
- : !(await allowed(p))
414
- ? `${actorOf(p)} may not perform ${head.record.capability}`
415
- : !(await allowed(owner))
416
- ? `the task owner ${task.owner} may not perform ${head.record.capability}`
417
- : null;
416
+ const { refusal, owner } = await this.#approvalCheck(task, head.record, p);
418
417
  if (refusal) {
419
418
  const refused = await this.#move(head, "proposed", {}, actorOf(p), `approval refused: ${refusal}`);
420
419
  await this.#sync(taskId, task.owner, `Approval of ${head.record.capability} refused: ${refusal}.`, { decisions: [`approval of ${actionId} by ${actorOf(p)} refused: ${refusal}`], evidence: [memoryEvidence(refused.memory.memory_id, "refused approval")] });
@@ -433,6 +432,46 @@ export class AgentHost {
433
432
  }
434
433
  return this.#run(taskId, task.owner, approved, owner, p);
435
434
  }
435
+ /** Why `p` may not approve `record` now (null: it may), and the resolved owner. The one rule approve() and Studio use. */
436
+ async #approvalCheck(task, record, p) {
437
+ const tool = this.#catalog().find((t) => t.name === record.capability);
438
+ const owner = await this.#resolveOwner(task);
439
+ const allowed = async (who) => (await this.#runtime.authority.authorize({ access: tool?.permission[0] ?? "authenticated", principal: who, target: { name: record.capability }, transport: "agent" })).allowed;
440
+ const refusal = !tool
441
+ ? `${record.capability} is no longer a capability of this application`
442
+ : this.#separateApprover && record.proposedBy === actorOf(p)
443
+ ? `${actorOf(p)} proposed this action and may not also approve it`
444
+ : !owner
445
+ ? `the task owner ${task.owner} cannot be resolved (no active session or key)`
446
+ : !(await allowed(p))
447
+ ? `${actorOf(p)} may not perform ${record.capability}`
448
+ : !(await allowed(owner))
449
+ ? `the task owner ${task.owner} may not perform ${record.capability}`
450
+ : null;
451
+ return { refusal, owner };
452
+ }
453
+ /**
454
+ * For each proposed action of a task: whether `principal` may approve it now, and if not, why
455
+ * (the same checks approve() makes; nothing changes). Studio shows Approve only when it may.
456
+ */
457
+ async approvability(taskId, principal) {
458
+ const { task } = await this.#loaded(taskId);
459
+ const out = {};
460
+ const writer = grantsPermission(this.#runtime.authority.permissionsFor(principal), AGENT_PERMISSIONS.write);
461
+ for (const { record } of await this.#heads(taskId)) {
462
+ if (record.state !== "proposed")
463
+ continue;
464
+ if (principal.type !== "user")
465
+ out[record.actionId] = { allowed: false, reason: "only a person can approve a consequential action" };
466
+ else if (!writer)
467
+ out[record.actionId] = { allowed: false, reason: `${actorOf(principal)} lacks ${AGENT_PERMISSIONS.write}` };
468
+ else {
469
+ const { refusal } = await this.#approvalCheck(task, record, principal);
470
+ out[record.actionId] = refusal ? { allowed: false, reason: refusal } : { allowed: true };
471
+ }
472
+ }
473
+ return out;
474
+ }
436
475
  /** Execute an approved action: durable intent first, then the call, then the outcome. */
437
476
  async #run(taskId, ownerActor, approved, owner, approver) {
438
477
  const work = (async () => {
@@ -818,7 +857,7 @@ export class AgentHost {
818
857
  }
819
858
  async #decide(taskId, owner) {
820
859
  const { task } = await this.#loaded(taskId);
821
- const stored = (await this.#state.recallForTask(taskId, { limit: 100 })).find((m) => m.kind === DECISION_REQUEST_KIND);
860
+ const stored = (await this.#taskMemories(taskId)).find((m) => m.kind === DECISION_REQUEST_KIND);
822
861
  if (!stored)
823
862
  throw new FeltKitError("NOT_FOUND", `${taskId} has no decision to make.`);
824
863
  const spec = stored.content;
@@ -880,15 +919,18 @@ export class AgentHost {
880
919
  capabilities: outcome.capabilities,
881
920
  provider: outcome.provider,
882
921
  source: outcome.source,
922
+ // The Resolver receipt: reference, revision and target this decision ran on. Never a secret.
923
+ ...(outcome.resolution ? { resolution: outcome.resolution } : {}),
883
924
  durationMs: outcome.durationMs,
884
925
  decidedAt: new Date().toISOString(),
885
926
  note: "A model's choice among the offered options: a proposal, not evidence that anything happened.",
886
927
  },
887
928
  source: { actor: task.owner },
888
929
  });
889
- const by = `${outcome.provider}${outcome.metadata.model ? `/${outcome.metadata.model}` : ""}`;
930
+ // With a Resolver reference, say which revision decided, so Studio and agents can see it.
931
+ const by = `${outcome.provider}${outcome.metadata.model ? `/${outcome.metadata.model}` : ""}${outcome.resolution ? ` (${outcome.resolution.ref} r${outcome.resolution.revision})` : ""}`;
890
932
  const evidence = [{ kind: "record", collection: FELTDB_AGENT_MEMORY_COLLECTION, id: decided.memory_id, description: "model decision" }];
891
- this.#activity("decision.made", owner, taskId, "success", { selected: selected.id, provider: outcome.provider, model: outcome.metadata.model ?? null, offered: offered.length, excluded: excluded.length });
933
+ this.#activity("decision.made", owner, taskId, "success", { selected: selected.id, provider: outcome.provider, model: outcome.metadata.model ?? null, offered: offered.length, excluded: excluded.length, ...(outcome.resolution ? { ref: outcome.resolution.ref, revision: outcome.resolution.revision } : {}) });
892
934
  if (!selected.capability) {
893
935
  await this.#state.checkpoint(taskId, {
894
936
  actor: task.owner,
@@ -941,16 +983,21 @@ export class AgentHost {
941
983
  const attribution = { owner, ...(approver ? { approver } : {}) };
942
984
  try {
943
985
  let output;
986
+ const dispatch = () => this.#runtime.appport.handleRequest({
987
+ protocol: "appport/1",
988
+ type: "request",
989
+ requestId,
990
+ capability: { name: action.capability, version: 1 },
991
+ input: action.input,
992
+ ...(action.idempotencyKey ? { idempotencyKey: action.idempotencyKey } : {}),
993
+ metadata: { transport: "agent" },
994
+ }, { principal: toAppPort(owner), transport: "agent", signal: controller.signal });
995
+ // An approved action runs inside the approval it carries: the only way a non-person
996
+ // principal runs an `approval: "required"` mutation (runtime.#approvalRefusal).
944
997
  const call = action.source === "application"
945
- ? this.#runtime.appport.handleRequest({
946
- protocol: "appport/1",
947
- type: "request",
948
- requestId,
949
- capability: { name: action.capability, version: 1 },
950
- input: action.input,
951
- ...(action.idempotencyKey ? { idempotencyKey: action.idempotencyKey } : {}),
952
- metadata: { transport: "agent" },
953
- }, { principal: toAppPort(owner), transport: "agent", signal: controller.signal })
998
+ ? approver
999
+ ? this.#runtime.runApproved({ capability: action.capability, taskId, actionId: action.actionId, approvedBy: actorOf(approver) }, dispatch)
1000
+ : dispatch()
954
1001
  : this.#runtime.services.invoke(action.capability, action.input, owner, controller.signal, requestId);
955
1002
  // The call itself may not observe the signal; stop waiting for it either way.
956
1003
  const result = await Promise.race([call, new Promise((_, reject) => controller.signal.addEventListener("abort", () => reject(controller.signal.reason), { once: true }))]);
@@ -1034,7 +1081,7 @@ export class AgentHost {
1034
1081
  await this.#state.remember({ taskId, kind: "outcome", content: outcome, source: { actor: owner } });
1035
1082
  }
1036
1083
  async #lastOutput(taskId) {
1037
- const memories = await this.#state.recallForTask(taskId, { limit: 50 });
1084
+ const memories = await this.#taskMemories(taskId);
1038
1085
  const outcome = memories.filter((m) => m.kind === "outcome").sort((a, b) => a.created_at.localeCompare(b.created_at)).at(-1);
1039
1086
  return outcome ? outcome.content.output ?? null : null;
1040
1087
  }
@@ -1049,9 +1096,29 @@ export class AgentHost {
1049
1096
  await this.#db.failAgentExecution(await this.#execution(taskId), message).catch(() => undefined);
1050
1097
  }
1051
1098
  // ---- FeltDB state helpers ----------------------------------------------------
1099
+ /**
1100
+ * Every active memory scoped to the task, paged with FeltDB's cursor. Not `recallForTask`: it
1101
+ * returns at most the 100 newest per scope, with no cursor, so a task with more active memories
1102
+ * would lose its oldest actions and its decision request (FeltKit's records are all task-scoped).
1103
+ */
1104
+ async #taskMemories(taskId) {
1105
+ const out = [];
1106
+ let cursor;
1107
+ const seen = new Set();
1108
+ do {
1109
+ const page = await this.#state.recall({ scope: { kind: "task", taskId }, limit: 1000, ...(cursor ? { cursor } : {}) });
1110
+ out.push(...page.memories);
1111
+ cursor = page.nextCursor;
1112
+ if (cursor && seen.has(cursor))
1113
+ throw new FeltKitError("INTERNAL", `FeltDB returned the same cursor twice while reading ${taskId}'s memories.`);
1114
+ if (cursor)
1115
+ seen.add(cursor);
1116
+ } while (cursor);
1117
+ return out;
1118
+ }
1052
1119
  /** The current record of every consequential action on a task (one per action). */
1053
1120
  async #heads(taskId) {
1054
- const memories = await this.#state.recallForTask(taskId, { limit: 100 });
1121
+ const memories = await this.#taskMemories(taskId);
1055
1122
  return memories
1056
1123
  .filter((m) => (m.kind === ACTION_KIND || m.kind === LEGACY_PROPOSAL_KIND) && m.scope.kind === "task" && m.status === "active")
1057
1124
  .map((m) => ({ memory: m, record: m.kind === ACTION_KIND ? m.content : legacy(m) }))
@@ -1268,7 +1335,7 @@ export class AgentHost {
1268
1335
  async #legacyExecution(taskId) {
1269
1336
  this.#legacy ??= (async () => {
1270
1337
  const byTask = new Map();
1271
- for (const row of (await this.#db.collection(LEGACY_EXECUTIONS).find({}))) {
1338
+ for (const row of (await readAll(this.#db, { collection: LEGACY_EXECUTIONS }))) {
1272
1339
  if (row.taskId || !Array.isArray(row.inputs))
1273
1340
  continue;
1274
1341
  for (const input of row.inputs) {