@feltdb/feltkit 0.4.0 → 0.5.1

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 (132) hide show
  1. package/dist/agent-engine.d.ts +93 -0
  2. package/dist/agent-engine.js +40 -0
  3. package/dist/agent-engine.js.map +1 -0
  4. package/dist/app.d.ts +153 -4
  5. package/dist/app.js +134 -25
  6. package/dist/app.js.map +1 -1
  7. package/dist/appboundry/build.d.ts +9 -1
  8. package/dist/appboundry/build.js +7 -7
  9. package/dist/appboundry/build.js.map +1 -1
  10. package/dist/appboundry/guest.js +82 -0
  11. package/dist/appboundry/guest.js.map +1 -1
  12. package/dist/appboundry/host.d.ts +21 -0
  13. package/dist/appboundry/host.js +83 -2
  14. package/dist/appboundry/host.js.map +1 -1
  15. package/dist/appboundry/runtime.js +2 -0
  16. package/dist/appboundry/runtime.js.map +1 -1
  17. package/dist/boards/index.d.ts +1258 -0
  18. package/dist/boards/index.js +1410 -0
  19. package/dist/boards/index.js.map +1 -0
  20. package/dist/boards/model.d.ts +177 -0
  21. package/dist/boards/model.js +177 -0
  22. package/dist/boards/model.js.map +1 -0
  23. package/dist/boards/react.d.ts +18 -0
  24. package/dist/boards/react.js +339 -0
  25. package/dist/boards/react.js.map +1 -0
  26. package/dist/cli/deploy-appboundry-self-hosted.js +2 -2
  27. package/dist/cli/deploy.js +19 -6
  28. package/dist/cli/deploy.js.map +1 -1
  29. package/dist/cli/main.js +70 -5
  30. package/dist/cli/main.js.map +1 -1
  31. package/dist/client/index.d.ts +265 -4
  32. package/dist/client/index.js +170 -3
  33. package/dist/client/index.js.map +1 -1
  34. package/dist/cron.d.ts +18 -0
  35. package/dist/cron.js +67 -0
  36. package/dist/cron.js.map +1 -0
  37. package/dist/dashboard/assets/index-CLzg0fuZ.js +14 -0
  38. package/dist/dashboard/assets/index-D2XOWzK9.css +1 -0
  39. package/dist/dashboard/index.html +2 -2
  40. package/dist/docs.d.ts +1 -1
  41. package/dist/docs.js +3 -0
  42. package/dist/docs.js.map +1 -1
  43. package/dist/eve/index.d.ts +77 -0
  44. package/dist/eve/index.js +128 -0
  45. package/dist/eve/index.js.map +1 -0
  46. package/dist/index.d.ts +7 -2
  47. package/dist/index.js +2 -1
  48. package/dist/index.js.map +1 -1
  49. package/dist/native/build.d.ts +112 -0
  50. package/dist/native/build.js +472 -0
  51. package/dist/native/build.js.map +1 -0
  52. package/dist/native/index.d.ts +67 -0
  53. package/dist/native/index.js +113 -0
  54. package/dist/native/index.js.map +1 -0
  55. package/dist/native/instance.d.ts +3 -0
  56. package/dist/native/instance.js +18 -0
  57. package/dist/native/instance.js.map +1 -0
  58. package/dist/react/agent-control.d.ts +2 -0
  59. package/dist/react/agent-control.js +1 -1
  60. package/dist/react/agent-control.js.map +1 -1
  61. package/dist/react/auth.d.ts +15 -1
  62. package/dist/react/auth.js +28 -5
  63. package/dist/react/auth.js.map +1 -1
  64. package/dist/react/hooks.d.ts +88 -0
  65. package/dist/react/hooks.js +188 -0
  66. package/dist/react/hooks.js.map +1 -0
  67. package/dist/react/index.d.ts +5 -88
  68. package/dist/react/index.js +3 -185
  69. package/dist/react/index.js.map +1 -1
  70. package/dist/runtime/agent-control.d.ts +10 -0
  71. package/dist/runtime/agent-control.js +9 -1
  72. package/dist/runtime/agent-control.js.map +1 -1
  73. package/dist/runtime/agent-run.d.ts +166 -0
  74. package/dist/runtime/agent-run.js +431 -0
  75. package/dist/runtime/agent-run.js.map +1 -0
  76. package/dist/runtime/agent.d.ts +158 -1
  77. package/dist/runtime/agent.js +329 -8
  78. package/dist/runtime/agent.js.map +1 -1
  79. package/dist/runtime/assemble.js +14 -1
  80. package/dist/runtime/assemble.js.map +1 -1
  81. package/dist/runtime/authority.d.ts +9 -0
  82. package/dist/runtime/authority.js.map +1 -1
  83. package/dist/runtime/context.d.ts +9 -0
  84. package/dist/runtime/required-capabilities.d.ts +73 -0
  85. package/dist/runtime/required-capabilities.js +69 -0
  86. package/dist/runtime/required-capabilities.js.map +1 -0
  87. package/dist/runtime/runtime.d.ts +70 -1
  88. package/dist/runtime/runtime.js +261 -9
  89. package/dist/runtime/runtime.js.map +1 -1
  90. package/dist/runtime/sessions.d.ts +1 -0
  91. package/dist/runtime/sessions.js +1 -1
  92. package/dist/runtime/sessions.js.map +1 -1
  93. package/dist/runtime/tenancy.d.ts +9 -1
  94. package/dist/runtime/tenancy.js +22 -0
  95. package/dist/runtime/tenancy.js.map +1 -1
  96. package/dist/runtime/transactions.d.ts +3 -1
  97. package/dist/runtime/transactions.js.map +1 -1
  98. package/dist/server/eve.d.ts +287 -0
  99. package/dist/server/eve.js +1071 -0
  100. package/dist/server/eve.js.map +1 -0
  101. package/dist/server/index.d.ts +2 -0
  102. package/dist/server/index.js +61 -4
  103. package/dist/server/index.js.map +1 -1
  104. package/dist/server/mcp.d.ts +7 -7
  105. package/dist/server/project.js +20 -3
  106. package/dist/server/project.js.map +1 -1
  107. package/dist/server/session-http.d.ts +7 -1
  108. package/dist/server/session-http.js +11 -1
  109. package/dist/server/session-http.js.map +1 -1
  110. package/dist/server/tenancy.d.ts +2 -0
  111. package/dist/server/tenancy.js +31 -1
  112. package/dist/server/tenancy.js.map +1 -1
  113. package/dist/testing/index.d.ts +1 -4
  114. package/dist/testing/index.js +2 -1
  115. package/dist/testing/index.js.map +1 -1
  116. package/docs/AGENT-CONTROL.md +36 -0
  117. package/docs/APPBOUNDRY.md +68 -2
  118. package/docs/AUTH.md +2 -0
  119. package/docs/EVE-COMPOSITION.md +75 -0
  120. package/docs/NATIVE-AGENTS.md +353 -0
  121. package/docs/NATIVE.md +137 -0
  122. package/docs/README.md +5 -2
  123. package/package.json +35 -9
  124. package/skills/.claude-plugin/marketplace.json +1 -1
  125. package/skills/.claude-plugin/plugin.json +1 -1
  126. package/skills/feltkit-agent/SKILL.md +1 -1
  127. package/skills/feltkit-build/SKILL.md +1 -1
  128. package/skills/feltkit-data/SKILL.md +1 -1
  129. package/skills/feltkit-operations/SKILL.md +1 -1
  130. package/skills/feltkit-services/SKILL.md +1 -1
  131. package/dist/dashboard/assets/index-BhxrvY37.js +0 -15
  132. package/dist/dashboard/assets/index-CSzYeCo_.css +0 -1
@@ -0,0 +1,75 @@
1
+ # EVE and FeltKit: standalone runtime, composed host
2
+
3
+ Status: Phase 0 (investigation). Decisions below are proposals backed by the evidence cited; nothing here is
4
+ implemented yet.
5
+
6
+ ## The boundary
7
+
8
+ | | Owns | Standalone | Composed into FeltKit |
9
+ |---|---|---|---|
10
+ | **EVE** | the agent: authoring (agent directory), compilation, the turn loop, tools, model adaptation, skills, subagents, sandboxes, runtime semantics | its own host (Nitro), its own World (local SQLite, Postgres), its own credentials | the same compiled agent, unchanged |
11
+ | **Host** | durable execution state, capability discovery and authority, identity, approvals, budgets, evidence, operations | EVE's World + tools | FeltDB (a FeltDB World), AppPort, FeltKit identity and approvals, Studio |
12
+
13
+ EVE must not need FeltKit; FeltKit must not give up its control plane to run EVE. The seam is EVE's existing
14
+ Workflow **World** interface, plus a small number of host services EVE calls (tools, model, memory).
15
+
16
+ ## Where the run lives
17
+
18
+ EVE's durable execution is event-sourced through its World: each run is an append-only event log with gap-free
19
+ positions and an in-band fence (spec 9); runs, steps, hooks and waits are views of it; delivery is a queue whose
20
+ handler EVE registers in-process; session output is per-run streams. Session state lives entirely in the World
21
+ (`packages/eve/src/execution/durable-session-store.ts` only shapes it). The World is selected per agent build
22
+ (`experimental.workflow.world`), and nothing in it is Vercel-specific.
23
+
24
+ **Decision (proposed): when composed, the run lives in FeltDB through a FeltDB World.** EVE keeps its execution
25
+ model; FeltDB is the only authoritative store. FeltKit does not keep a second transcript or a second lease for EVE
26
+ runs: the World's event log and in-band fence are the run's record and its fencing. FeltKit keeps the
27
+ application-facing record (owner, workspace, approvals, evidence) as an agent task linked to the run id.
28
+
29
+ Measured evidence for feasibility (Workflow World 5.2.2):
30
+
31
+ - Every World write is "read the run, compare-and-set, append at the next position, update the run" in one
32
+ transaction: FeltDB's `ifVersion` + `requireAbsent` multi-record transactions.
33
+ - Delivery: a durable queue (visibility time, lease, delivery count, stable message id, idempotency keys, delayed
34
+ messages for timers, one orchestrator delivery per run). The local World keeps its queue in memory and
35
+ re-enqueues on start; a FeltDB World keeps it in FeltDB and wakes from the commit listener.
36
+ - Streams: append-only chunks keyed `(name, index)`, live tails from the commit listener.
37
+ - Size: comparable to `@workflow/world-postgres` (about 8k lines). Conformance: Workflow ships suites for the
38
+ in-band fence and start-hook admission; queue, streams and views are covered by EVE's own World e2e matrix
39
+ (`e2e/matrix.json`, `EVE_E2E_WORKFLOW_WORLD`).
40
+
41
+ ## Collisions to resolve
42
+
43
+ | | EVE today | FeltKit today | Proposal |
44
+ |---|---|---|---|
45
+ | Durable run | World event log (SQLite) | agent task, transcript, lease (slices 1–2) | World event log in FeltDB; the task references it; no FeltKit transcript or lease for EVE runs |
46
+ | Fencing and recovery | in-band fence, queue redelivery, `reenqueueActiveRuns` | run lease, reconciliation | EVE's, over FeltDB. FeltKit reconciliation keeps only what is the host's: proposals waiting for people |
47
+ | Tool calls with effects | EVE tools; `approval` policies held in session state | AppPort capabilities as proposals; people approve; AppPort executes | Host tools are AppPort capabilities. A consequential call is a FeltKit proposal; the EVE tool waits on a hook; the approval decision resumes the hook. EVE's own approval policy is `never` for host tools: the host decides |
48
+ | Authority | the session's auth; tool-level checks | AppPort roles, tenancy, AuthBoundry | the agent's principal and tenant come from the host; every host tool call is authorized by AppPort at execution |
49
+ | Model and credentials | AI SDK providers with EVE's own credentials | environment model selection, credential custody, recorded generations | a host-provided model resolver: EVE asks the host for the model; credentials never enter EVE |
50
+ | Budgets | EVE's turn limits | durable budgets (slice 2) | enforced at the host boundaries: model resolver (generations, tokens) and tool calls; turns by EVE |
51
+ | Memory | `.eve/memory` files (authoritative) | FeltDB | a FeltDB memory backend |
52
+ | Hosting | Nitro server per agent | one FeltKit process | open question below |
53
+
54
+ ## Node.js
55
+
56
+ EVE builds and tests on Node 26 (`.nvmrc`); its shipped code needs Node 24+ in one place (`AsyncDisposableStack`
57
+ in `eve dev`) plus the CLI's version gate. Its unit tier passes on Node 22 except for those (9351 of 9387). The
58
+ stack standardizes on **Node 26**: FeltKit, AppPort, AppPort Services and FeltDB move up, rather than EVE down.
59
+
60
+ ## Open questions for the next prototype
61
+
62
+ 1. **Hosting EVE inside FeltKit's process.** EVE's published runtime is a compiled agent behind a Nitro handler.
63
+ Either FeltKit mounts that handler in its own HTTP server (one process, one deploy), or EVE gains a headless
64
+ host entry. Prototype the first; it changes nothing in EVE.
65
+ 2. **Hooks as the approval wait.** Confirm an EVE tool can suspend on a hook and be resumed by a FeltKit decision
66
+ without EVE's HITL approval state.
67
+ 3. **Model resolver.** Confirm EVE's model call can be routed through a host-supplied resolver.
68
+ 4. **Spec churn.** EVE pins Workflow versions and checks World compatibility (`validate-world.ts`); a FeltDB World
69
+ must track every Workflow upgrade.
70
+
71
+ ## Distribution
72
+
73
+ `@appport/eve` is built from this fork and published (1.0.2, 1.1.0) by `npm run publish:packages` (version-stamped,
74
+ clean-tree, refuses re-publishing). A local repack of 1.1.0 from the same commit has a different integrity than the
75
+ published tarball: packing is not byte-reproducible yet.
@@ -0,0 +1,353 @@
1
+ # Native agents
2
+
3
+ An application declares an agent the way it declares a collection or a mutation. FeltKit runs it in the
4
+ application's own process, on the application's own FeltDB instance, through the application's own AppPort
5
+ capabilities and authority. There is no agent server, agent database, agent container or second runtime to
6
+ deploy. `feltkit deploy` ships the agent with the app, and the app's health, restart, backup and Studio cover it.
7
+
8
+ Code: `packages/sdk/src/app.ts` (`app.agent`), `src/agent-engine.ts` (engines), `src/runtime/agent-run.ts` (the
9
+ run, its lease, budgets, output), `src/runtime/agent.ts` (tasks, proposals, approvals, generations, the approvals
10
+ inbox), `src/runtime/runtime.ts` (`reconcileAgentRuns`).
11
+ Tests: `packages/sdk/test/native-agents.test.ts`, `test/native-agents-recovery.test.ts`,
12
+ `test/native-agents-security.test.ts`, `test/native-agents-limits.test.ts`, `tests/e2e/native-agents.test.mjs`
13
+ (deployed artifact). Example: `examples/approvals`.
14
+
15
+ ## One declaration, three kinds of agent
16
+
17
+ `app.agent(name, …)` takes exactly one of `handler`, `instructions` or `project`:
18
+
19
+ - `handler`: a deterministic agent, a mutation (below).
20
+ - `instructions` + `tools`: a reasoning agent run by FeltKit's in-process engine (below).
21
+ - `project`: an agent that runs on the agent runtime from its own project directory (`agent/`), built and supervised
22
+ by FeltKit, acting only through the capabilities it names, in a workspace as a member with `tenantRole`, under the
23
+ work grant of the person working with it, with a person's approval of each exact call that needs one:
24
+
25
+ ```ts
26
+ export const helper = app.agent("helper", { project: ".", displayName: "Product agent", roles: ["agent"], tenantRole: "agent", capabilities: ["product.*"] });
27
+ ```
28
+
29
+ The browser reaches it with `client.agent("helper")`. `feltkit({ eve: { … } })` is the same declaration and keeps
30
+ working; see [EVE-COMPOSITION.md](EVE-COMPOSITION.md) for how the runtime is hosted.
31
+
32
+ **Direction:** one reasoning runtime. New reasoning agents use `project`. The in-process engine (`instructions`)
33
+ stays supported for existing applications; it is not removed until a reasoning agent declared with `instructions`
34
+ can run on the agent runtime unchanged (same tools, approvals, budgets, output contracts and durable transcript),
35
+ proven by this file's tests passing against it, and a release has deprecated it first.
36
+
37
+ ## Handler and in-process reasoning agents
38
+
39
+ `app.agent(name, { principal, roles, access, on?, retry?, leaseMs?, … })` declares an agent: an identity
40
+ (principal type `agent`), its authority (`roles`, and nothing else), and what triggers it. Then exactly one of:
41
+
42
+ | | `handler` (deterministic) | `instructions` + `tools` (reasoning) |
43
+ |---|---|---|
44
+ | What runs | your function, as a mutation: one transaction | turns: an engine decides, FeltKit executes |
45
+ | Model | none | the engine's choice: the environment's model, rules, or your own |
46
+ | State | `ctx.db`, written once per trigger | a durable task, transcript and actions in FeltDB |
47
+ | Effects | the mutation's writes and `ctx.afterCommit` | AppPort capability calls, authorized and evidenced one by one |
48
+ | Waits for people | no | yes: approvals, pause/resume, updates |
49
+
50
+ Both are triggered the same way: `ctx.afterCommit.agent(name, input)` from a mutation, or an `app.event` named in
51
+ `on`. A recurring schedule starts one through existing primitives: the schedule enqueues a job, and the job's
52
+ handler (`services.jobs.handlers`) is a mutation that stages the agent. The job runs as the schedule's creator, only
53
+ while that principal still resolves (a live session or API key).
54
+
55
+ ## A reasoning agent
56
+
57
+ ```ts
58
+ // feltkit/triage.ts
59
+ import { s } from "@feltdb/feltkit";
60
+ import { app } from "./app.js";
61
+ import { getTicket, setPriority, closeTicket } from "./tickets.js";
62
+
63
+ export const triage = app.agent("triage", {
64
+ principal: { id: "triage", displayName: "Triage" },
65
+ roles: ["triager"], // its authority: e.g. ["tickets.read", "tickets.prioritize", "tickets.close", "feltkit.agent.write"]
66
+ access: "tickets.read", // the permission it needs to run at all
67
+ input: { ticketId: s.string() }, // validated before a run starts
68
+ instructions: "Read the ticket with tickets_get, then set its priority with tickets_prioritize.",
69
+ tools: [getTicket, setPriority, closeTicket], // published capabilities, by definition
70
+ autonomous: [setPriority], // consequential tools it may run without a person (your policy)
71
+ limits: { maxTurns: 8, maxToolCalls: 20 },
72
+ });
73
+
74
+ // feltkit/tickets.ts: a person opens a ticket; triage runs after the commit
75
+ export const open = app.mutation({
76
+ access: "tickets.write",
77
+ args: { title: s.string() },
78
+ handler: async (ctx, { title }) => {
79
+ const ticketId = await ctx.db.insert(tickets, { title, status: "open" });
80
+ ctx.afterCommit.agent("triage", { ticketId });
81
+ return ticketId;
82
+ },
83
+ });
84
+ ```
85
+
86
+ The application never imports an agent framework or a model SDK. Which model decides is the environment's
87
+ configuration (Studio → Models, `feltkit model set`, or a Resolver reference): switching provider or model is a
88
+ configuration change, not a redeploy, and no agent definition names one.
89
+
90
+ ### What the declaration checks
91
+
92
+ - `tools` and `autonomous` are this app's functions **published as capabilities** (`capability: "…"`): the agent
93
+ reaches them through AppPort like any other caller, never by calling the function.
94
+ - `autonomous` is a subset of `tools`.
95
+ - The agent's roles grant `feltkit.agent.write` (it records its own work as agent tasks). Checked when the runtime
96
+ starts: a missing grant stops the start with the agent's name and the fix.
97
+ - Exactly one of `handler` and `instructions`.
98
+
99
+ ## How a run works
100
+
101
+ A run is driven by outbox records (its trigger, and later resumes), each attempt claimed and retried with backoff
102
+ like every `app.agent` run, as the agent's own principal through the same call path as any request (roles →
103
+ `access` → `feltkit({ authorize })` → activity log). An attempt executes the run only while it holds the run's
104
+ lease, and continues from what FeltDB holds:
105
+
106
+ | Durable state | Where | Written |
107
+ |---|---|---|
108
+ | the task | FeltDB agent state, keyed by the run (`openTask`) | once per run |
109
+ | the run record: agent, definition version, engine, input, tenant | task memory `<task>.run` | once |
110
+ | the lease: which attempt executes the run, until when, why the last one ended | task memory `<task>.lease-eNNNN-rNNNN` | a compare-and-set chain (FeltDB supersede) |
111
+ | the transcript: input, each turn, each tool result, each person's update, each output refusal | task memory `<task>.msg-NNNN` | each message once, at a fixed id (FeltDB `requireAbsent`) |
112
+ | the validated output | task memory `<task>.output` | once |
113
+ | each tool call: proposal, approval, execution, outcome | action records (agent memory chains) | per state transition |
114
+ | each model generation: model, timing, usage, outcome | generation records | per state transition |
115
+ | each repair by reconciliation | task memory `<task>.recovery-…`, activity `agent.run.recovered` | once per repair |
116
+
117
+ One step looks only at the transcript's last message:
118
+
119
+ ```
120
+ assistant asked for tools ──▶ each call is a proposal keyed <message>:<call id>
121
+ observation runs now, as the agent
122
+ consequential waits for a person, unless declared autonomous
123
+ any call waiting the attempt releases the run "waiting", naming the actions
124
+ all answered the tool results are appended
125
+ assistant answered only ──▶ output contract checked (if any); the task completes
126
+ anything else ──▶ budgets, checkpoint (pause, interrupt, updates), then the engine's next turn
127
+ ```
128
+
129
+ ### Ownership and fencing
130
+
131
+ The lease is a chain of FeltDB memory records, each superseding the last in one compare-and-set transaction:
132
+ `lease-e0001-r0000` (taken), `…-r0001` (renewed), …, `…-rNNNN` with `released` (why the attempt ended). Taking the
133
+ run is a new epoch, allowed only from a released lease or one whose holder stopped renewing past `until`; the new
134
+ link records `takeover: { fromEpoch, fromHolder, because }`. A live attempt renews every third of the lease (half the
135
+ agent's `leaseMs`, so 60 s by default).
136
+
137
+ An attempt checks that its link is still the active one before every durable write: appending to the transcript,
138
+ proposing, running an autonomous call, recording the output, completing or stopping. An attempt that lost the run
139
+ stops there (`CONFLICT`, `RUN_FENCED`); its in-flight model call is aborted. An attempt that finds the run held by a
140
+ live attempt is refused (`RUN_BUSY`) and its outbox record is tried again with backoff.
141
+
142
+ | A stale attempt cannot | because |
143
+ |---|---|
144
+ | append a turn that conflicts | messages are written once at fixed ids: the first write stands, and a loser adopts it (recording that its turn was discarded) |
145
+ | create competing proposals | proposals are keyed by the message and call id; the same key is the same proposal |
146
+ | run an action twice | approval is a compare-and-set on the action record; execution happens once per approval |
147
+ | complete, stop or continue the run | each of those is preceded by the lease check |
148
+ | resume an obsolete execution | a resume is a new attempt: it takes the lease and reads the run as it is now |
149
+
150
+ **Model inference is not exactly-once.** If an attempt's lease lapses while it is deciding (a frozen process) and
151
+ another attempt takes the run, both may compute the same turn. Only one becomes durable; the other is a recorded
152
+ generation and nothing else. Provider retries after an uncertain failure also repeat inference. Budgets count every
153
+ generation, so repeated inference is bounded.
154
+
155
+ ### Lifecycle
156
+
157
+ Four records each own one part; the run's state is derived from them, never stored twice.
158
+
159
+ ```
160
+ Task (FeltDB) ready ─▶ running ⇄ blocked ─▶ completed
161
+ └──────────────▶ cancelled (a person's stop, or a budget)
162
+
163
+ Lease (per attempt) (none) ─acquire▶ held ─renew▶ held ─release▶ released{completed|stopped|waiting|held|error}
164
+ └─ not renewed past until ─▶ expired ─acquire (new epoch)▶ held
165
+ released ─acquire (new epoch)▶ held
166
+
167
+ Action (proposal) proposed ─approve (a person, or the agent's autonomous policy)▶ approved ─▶ executing ─▶ succeeded | failed
168
+ │ └─ outcome unknown ─▶ interrupted ─settle▶ succeeded | failed
169
+ ├─reject (a person)▶ rejected
170
+ └─expire / task cancelled▶ cancelled
171
+ approved ─(process stopped before executing; next start)▶ proposed (approval asked again)
172
+ failed ─retry (owner or a person)▶ proposed
173
+
174
+ Outbox (per attempt) pending ─claim▶ performing ─▶ done (result.run: the attempt's outcome)
175
+ ├─ RUN_BUSY / error with retries left ─▶ pending (notBefore)
176
+ ├─ error, terminal (CONFIGURATION, permission, attempts spent) ─▶ failed
177
+ └─ claim stale ─▶ claimed again (the run lease decides who executes)
178
+ ```
179
+
180
+ | Transition | Owner | Authorized by | Persisted as | Idempotent | Reconciled when lost |
181
+ |---|---|---|---|---|---|
182
+ | start a run | a committed mutation / event / job | the agent's roles + `access` | outbox record, then task + run record | trigger id = run id | outbox recovery |
183
+ | take / renew / release the run | the attempt | holding the lease | lease chain | compare-and-set | expired lease → resume |
184
+ | append a turn or result | the lease holder | the lease | `msg-NNNN` | fixed id | next attempt continues |
185
+ | propose a call | the lease holder | the agent's roles, now | action record | key `msg:call` | next attempt re-proposes, same key |
186
+ | approve / reject | a person in the workspace who may perform it | AuthBoundry/roles at approval, owner rechecked | action record | compare-and-set; repeated decision answers current state | `decided:` → resume |
187
+ | approve autonomously | the lease holder | `autonomous` policy; never `approval: "required"` | action record (`policy:agent/<name>`) | compare-and-set | next attempt |
188
+ | expire | reconciliation, or an approval attempt | the proposal's `expiresAt` | action record (`cancelled`, `feltkit:expiry`) | compare-and-set | the pass that expires it resumes the run |
189
+ | pause / resume | a person | `feltkit.agent.write` | control record | revisioned | `unheld:` → resume |
190
+ | complete / stop | the lease holder | the lease; open actions refuse completion | task checkpoint | terminal | `unfinished:` → resume |
191
+
192
+ Impossible by construction: a completed or cancelled task reopened (every attempt and pass reads the task first and
193
+ leaves an ended run alone); a rejected or expired action executed (only `approved` executes, and approval is a
194
+ compare-and-set from `proposed`); a run completing with an action still open (completion refuses it).
195
+
196
+ ### Reconciliation
197
+
198
+ Every services tick (at most every 15 s; also `runtime.reconcileAgentRuns()`), FeltKit lists open tasks of its
199
+ reasoning agents through FeltDB's indexed, paged listing and decides from durable state alone:
200
+
201
+ | Found | Done |
202
+ |---|---|
203
+ | a proposal past its approval window | expired (cancelled), exactly as a late approval would |
204
+ | released `waiting`, every action it waits on now decided | resume (`decided:`) |
205
+ | released `held`, the task running again | resume (`unheld:`) |
206
+ | a lease past `until`, never released, its attempt's outbox record not pending or performing | resume (`expired:`) |
207
+ | no lease, task older than 30 s | resume (`no-lease:`) |
208
+ | released `completed`/`stopped`, task still open | resume (`unfinished:`) |
209
+ | a live lease, `error` (the outbox owns the retry), a proposal still waiting, an unknown outcome, a paused task | nothing |
210
+
211
+ A resume is an outbox record whose id is derived from the task and the state it was decided from (the lease link and
212
+ the states of what it waited on), written with `requireAbsent`: the same state resumes once, however many passes
213
+ run, in however many processes. A pass never decides for a person, never executes anything, and never touches an
214
+ ended run; it records each repair on the task and in the activity log.
215
+
216
+ ## Approvals in the application
217
+
218
+ Agent proposals are application actions, decided in the application's own interface. The API lists a proposal to a
219
+ person only when it is on a task owned by one of the app's declared agents, in the person's own workspace, and the
220
+ person may perform its capability themselves. A person without `feltkit.agent.read` is refused; agents and services
221
+ are refused.
222
+
223
+ | | HTTP | Client |
224
+ |---|---|---|
225
+ | list (default: waiting) | `GET /api/agent/approvals?state=proposed\|all` | `client.agentApprovals({ state })` |
226
+ | detail: capability, validated input, digest, attempt, the agent's explanation, the run's input, history | `GET /api/agent/approvals/:taskId/:actionId` | `client.agentApproval(taskId, actionId)` |
227
+ | approve / reject | `POST /api/agent/approvals/decide { taskId, actionId, attempt, inputDigest, decision, reason? }` | `client.decideAgentApproval(approval, "approve" \| "reject", reason?)` |
228
+
229
+ - The caller is the session's principal; nothing in the request names who decides.
230
+ - A decision binds to what was reviewed: the proposal's `attempt` (a retry is a new attempt) and, to approve, its
231
+ `inputDigest`. Anything else is refused (`FAILED_PRECONDITION`, `STALE_PROPOSAL`) and nothing changes.
232
+ - Deciding what is already decided answers its current state; concurrent approvals execute once.
233
+ - Approving runs the action (as the agent, through AppPort) before answering; the run then resumes.
234
+ - The run's transcript is not exposed: the detail carries the agent's own words for that call only.
235
+
236
+ `examples/approvals` is a small app built on it: an expense reviewer agent, an approvals list and detail, approve and
237
+ reject, and the expense's status afterwards.
238
+
239
+ ## Output contracts
240
+
241
+ `output: s.object({ … })` (or a shape) makes the final answer a contract. The engine is told the JSON Schema; the
242
+ answer must be JSON (a fenced block is accepted) that validates. An answer that does not is never the output: the
243
+ agent receives the issues as a message (recorded with `validation: { ok: false, issues }`) and answers again, within
244
+ `maxTurns`. A valid answer is stored at `<task>.output` with the definition version it was validated against, and is
245
+ the run's `result.run.output`. When the turns are spent first, the run stops with no output.
246
+
247
+ ## Budgets
248
+
249
+ | Limit | Counted from | Default |
250
+ |---|---|---|
251
+ | `maxTurns` | assistant messages in the transcript | 8 |
252
+ | `maxToolCalls` | tool results in the transcript | 20 |
253
+ | `maxGenerations` | the task's generation records, failed ones included | 2 × maxTurns |
254
+ | `maxActiveMs` | the lease chain: each epoch from acquisition to release or expiry (waiting for a person is not counted) | 10 min |
255
+ | `maxTokens` | input + output tokens the provider reported | none |
256
+ | `concurrency` | attempts of this agent executing in this process | 4 |
257
+
258
+ Budgets are checked before each turn, from durable records, so a restart does not reset them. Spending one stops the
259
+ run (task cancelled; the reason names the budget and the amount). Token usage is enforced only where the provider
260
+ reports it: a generation without usage is not counted, and the reason says how many were not. `concurrency` is per
261
+ process, not across processes; an attempt over it waits (`RUN_BUSY`) and is retried with backoff.
262
+
263
+ ### Failures
264
+
265
+ | Failure | What happens |
266
+ |---|---|
267
+ | No model configured (model engine) | the attempt fails `CONFIGURATION`, saying what to set; not retried automatically (an operator retries the outbox record) |
268
+ | Provider error, timeout, dropped stream | the generation is recorded `failed`; the attempt is retried with backoff; earlier tool calls are not repeated |
269
+ | A tool fails, or its arguments break the capability's contract | its error is the tool result; nothing runs; the engine decides what next |
270
+ | A person stops the task while the engine decides | the turn is not recorded; nothing more runs |
271
+ | Process killed | its lease lapses (half of `leaseMs`, 60 s by default); outbox recovery or reconciliation resumes the run |
272
+
273
+ ## Engines
274
+
275
+ An engine decides one thing: the agent's next turn (text and tool calls), from the instructions, the transcript, the
276
+ tools offered now and the output contract. It never reads or writes state, holds a credential, or runs a tool.
277
+
278
+ ```ts
279
+ interface AgentEngine {
280
+ readonly id: string; // recorded on every run and turn
281
+ readonly usesModel: boolean; // a run fails clearly before starting when no model is ready
282
+ next(request: AgentTurnRequest): Promise<AgentTurn>;
283
+ }
284
+ ```
285
+
286
+ | Engine | |
287
+ |---|---|
288
+ | `modelEngine()` (default) | one generation per turn with the environment's model; every generation is evidence on the task |
289
+ | `rulesEngine(id, decide)` | ordinary code, no model: the same lifecycle, authority, approvals and evidence |
290
+ | your own | anything that implements `next`; `request.model.generate` is the environment's model, recorded; honor `request.signal` |
291
+
292
+ ## Inspecting runs
293
+
294
+ Runs are agent tasks: Studio's agent screen (the task, its transcript, checkpoints, actions with approve/reject/settle),
295
+ `GET /_feltkit/api/agent/tasks/:id`, `feltkit outbox list` (each attempt's `result.run`), the activity log
296
+ (`agent/<name>` attempts, `agent.run.recovered`), and the app's approvals API for people deciding.
297
+
298
+ ## Testing an agent
299
+
300
+ Tests run against a fresh FeltDB instance like every FeltKit test. A `rulesEngine` agent needs no model. To test a
301
+ model-driven agent, point the environment's Intelligence selection at a scripted server that speaks the provider's
302
+ real protocol (see `test/fixtures/streaming-model.ts`), so the request, tool mapping, streaming and evidence are the
303
+ real ones and only the answers are scripted.
304
+
305
+ ## What it costs (measured)
306
+
307
+ `node --import tsx --import ./test/isolate-env.ts bench/native-agents.ts` in `packages/sdk` (Node 22, Linux x64,
308
+ local FeltDB; cold starts are medians of 5–7 fresh processes; 30 warm runs each; sessions on 2026-11-24, ranges across
309
+ sessions):
310
+
311
+ | | Start | RSS |
312
+ |---|---|---|
313
+ | support app, no agents declared | 537–671 ms | 145–154 MB |
314
+ | the same app, 4 reasoning agents declared, idle | 605–690 ms | 145–155 MB |
315
+
316
+ Declaring agents adds nothing measurable at rest beyond run-to-run variation; an app without reasoning agents pays
317
+ about 10 µs per reconciliation pass (it returns at once) and nothing else.
318
+
319
+ | Per run (warm) | p50 | p95 | CPU | FeltDB records written |
320
+ |---|---|---|---|---|
321
+ | rules engine: 3 turns, 2 tool calls (one autonomous consequential) | 70–85 ms | 89–103 ms | 56–67 ms | 14 memories (2 of them the lease), 7 checkpoints, 1 task, 1 outbox |
322
+ | model engine, loopback model: 3 generations, 2 tool calls | 111–146 ms | 133–182 ms | 96–108 ms | 23 memories, 10 checkpoints, 1 task, 1 outbox |
323
+ | 20 rules-engine runs at once (concurrency 4 per agent) | 10–14 runs/s | | | |
324
+
325
+ | Reconciliation, 50 runs waiting for approval | |
326
+ |---|---|
327
+ | a pass that finds nothing to do | 10 ms (p50), 12 ms (max) |
328
+ | a pass that recovers all 50 (decisions whose resumes were lost) | 670–785 ms for the pass; every run completed after 1.9–2.0 s and 6–7 worker ticks (concurrency 4) |
329
+ | records written to recover 50 runs | 50 outbox records, 300 memories (recovery notes, leases, transcript), 50 checkpoints |
330
+
331
+ A real provider adds its own latency per generation (`gpt-4.1-mini` through AI Gateway: 0.8–1.4 s). The lease
332
+ added two memory records per attempt and no measurable latency over slice 1's 72 ms p50 within run-to-run variation.
333
+
334
+ ## Choices and limits
335
+
336
+ - **Why not EVE inside FeltKit.** EVE's turn loop is reachable only through a compiled agent directory and a
337
+ Workflow "World" that holds the session's durable state; its in-process runtime and in-memory compiler are
338
+ test-only and excluded from its published build, and it requires Node 24. Embedding it would mean a second durable
339
+ store and either a fork or reliance on unexported internals. FeltKit owns the loop over FeltDB; the engine boundary
340
+ is where another reasoning implementation plugs in. EVE stays usable standalone and as a remote AppPort client.
341
+ - **Inference can repeat** (see Ownership and fencing); side effects and durable turns do not.
342
+ - **Lease checks are check-then-write.** A stale attempt can pass a check just before losing the lease; what it
343
+ writes then is a fixed-id message or a keyed proposal, so it either becomes the run's (it was first) or is adopted
344
+ away. It cannot overwrite.
345
+ - **Concurrency is per process.** `limits.concurrency` does not count attempts in other processes.
346
+ - **Approval after a restart.** An action approved but not yet executing when a process stopped goes back to
347
+ `proposed` at the next start (FeltKit asks the person again rather than act on a decision whose execution it did
348
+ not begin). The run waits for that new decision.
349
+ - **Retrying a failed action** (owner or person) makes a new proposal attempt after the run has already received the
350
+ failure; that attempt is decided and runs on its own, not as part of the run's flow.
351
+ - **Output to application code.** The validated output is in `result.run.output` and `<task>.output`; there is no
352
+ hook that hands it to a mutation yet. Persist results through a tool the agent calls.
353
+ - **Not in AppBoundry artifacts.** `app.agent` runs on FeltKit's runtime (as before).
package/docs/NATIVE.md ADDED
@@ -0,0 +1,137 @@
1
+ # Native iOS and Android apps as a FeltKit host
2
+
3
+ A FeltKit application can run as a native iOS and Android app, written with React Native components (Expo). It is the same application: the same functions, collections, authorization, AppPort capabilities and agents, on the same instance. It is not a WebView around the web app, and not a second application model. The native app is a **host** for the application's client, as the [browser extension](EXTENSION-HOSTS.md) is: it carries screens and talks to an instance with a bearer session.
4
+
5
+ ```
6
+ npx feltkit build ios # Expo project + compiled Hermes bundle
7
+ npx feltkit build android
8
+ npx feltkit build ios --compile # + the native project, built for the iOS Simulator
9
+ npx feltkit build android --compile --release --instance https://tasks.example.com
10
+ npx feltkit build web # the existing build, unchanged (also: `feltkit build`)
11
+ ```
12
+
13
+ ## What a build produces (and what it never claims)
14
+
15
+ The command prints, and `--json` returns, exactly one `kind`:
16
+
17
+ | kind | What was done | What it is |
18
+ |---|---|---|
19
+ | `project` (`--prepare`) | The Expo project was generated into `.feltkit/native`. | Nothing compiled. |
20
+ | `bundle` (default) | + dependencies installed, the screens typechecked, the JavaScript compiled to Hermes bytecode (`expo export`). | Proves the app and the FeltKit client bundle for that platform. **Not an installable app.** |
21
+ | `native` (`--compile`) | + `expo prebuild`, then Xcode (iOS Simulator) or Gradle (Android APK). Debug loads JavaScript from Metro; `--release` embeds the bundle. | **Never store-signed.** An iOS Simulator app runs on the Simulator only; an Android APK is signed with the debug key. |
22
+
23
+ Not done by FeltKit: signing, provisioning, App Store Connect, Google Play. `eas.json` is generated in the Expo project for `npx eas-cli build` (EAS is optional; nothing here requires a cloud service). Local development builds are `--compile` (Debug) plus `npx expo start` in `.feltkit/native`.
24
+
25
+ If the machine cannot compile, the build says precisely what is missing instead of guessing (Xcode, CocoaPods, the Android SDK, a JDK), and keeps the `bundle` it did produce.
26
+
27
+ ## What you write
28
+
29
+ ```
30
+ feltkit/ functions, collections, capabilities (the backend: unchanged)
31
+ shared/rules.ts what both UIs decide: permissions, error wording (optional, plain TypeScript)
32
+ src/ the web screens (React DOM)
33
+ native/App.tsx the native screens (React Native) ← required for ios/android
34
+ native/native.json name, bundleIdentifier, package, scheme, instance, extra native modules (optional)
35
+ ```
36
+
37
+ `native/App.tsx` default-exports a component that receives `NativeAppProps` and uses `@feltdb/feltkit/native`: the same hooks as `@feltdb/feltkit/react` (`useQueryState`, `useMutation`, `useSession`, `useConnectionState`, …) and the same generated `api`. See `examples/tasks`: `src/App.tsx` (web) and `native/App.tsx` (native) share `feltkit/_generated/api` and `shared/rules.ts`, and nothing else.
38
+
39
+ Share application semantics, not components: the DOM components of `@feltdb/feltkit/react` (sign-in screens, the agent control bar) render `<div>`s and are not available natively; `@feltdb/feltkit/native` does not import them.
40
+
41
+ ### The generated host
42
+
43
+ `.feltkit/native/` (derived, like `.feltkit/build/`; gitignore it) holds the Expo project: pinned dependencies, `app.json`, `metro.config.js`, `eas.json`, and `host.tsx`, which:
44
+
45
+ - creates the client with `createNativeClient`: a bearer session kept in secure storage (`expo-secure-store`: Keychain / Keystore), `expo/fetch` for the streaming change feed, and reconnect on foreground (`AppState` → `client.wake()`);
46
+ - shows loading, and a failure screen with **Try again** when the instance is unreachable or serves another application;
47
+ - hands e-mail links that open the app (`<scheme>://…#feltkit-magic-link=…`) to `handleDeepLink`.
48
+
49
+ Metro reads the screens, `shared/` and `feltkit/` from the project itself (one copy), and resolves `react`, `react-native` and `expo*` only from the Expo project (a second React copy breaks hooks).
50
+
51
+ ### Environment
52
+
53
+ The instance the app talks to is, in order: `--instance`, `FELTKIT_URL`, `native/native.json` `instance`. It must be https, or http for `localhost` and the Android emulator's `10.0.2.2`; credentials in the address are refused. With none, a development build uses `localhost:3000` (`10.0.2.2:3000` on Android). `--release` requires an https instance and turns off the local-network exception in the iOS app.
54
+
55
+ ## The application artifact
56
+
57
+ A native app is **not** part of the AppBoundry artifact (`feltkit build --target appboundry`), and the artifact does not change. The artifact is the *server* side: its WASM module, manifest, permissions and collections. A native app is a client of whichever instance serves that application, so the same deployed instance serves web, iOS and Android, and a native release needs no backend release.
58
+
59
+ The unit a native app is built from is the project: `feltkit/`, `shared/`, `native/` and `package.json` (name, version). The Expo project is derived from it and is regenerated freely. This is the smallest extension of the existing model: no second application model, and no new deployable.
60
+
61
+ Identity and version:
62
+
63
+ - **Version** comes from `package.json` (`1.2.3`); the build number is derived (`10203`), so a higher version is always a higher build.
64
+ - **Identity** is `native/native.json` (`bundleIdentifier`, `package`, `scheme`); without it a development default (`dev.feltkit.<application>`) is used and the build warns, because a store identity is yours to choose.
65
+ - **Reproducibility.** Dependencies are pinned to exact versions in one table (`NATIVE_PINS` in the SDK: Expo SDK 58's own set), extra modules need exact versions in `native.json`, and `.feltkit/native/feltkit-native.json` records a digest of the generated files and the application's sources: equal inputs give an equal digest (tested). A lockfile is not kept (gap N5).
66
+
67
+ ## Compatibility matrix
68
+
69
+ Verified against the source and, where stated, by running it. "Verified" means evidence below, not the package name.
70
+
71
+ | Component | Web | Node | React Native | Required changes |
72
+ |---|---|---|---|---|
73
+ | **Client** (`@feltdb/feltkit/client`) | Yes (cookie or bearer) | Yes (bearer; tested) | **Yes, with adapters.** Imports nothing; uses only `fetch`, `AbortController`, `URL`, `TextDecoder`. Bundles unchanged for iOS and Android (Hermes). | `fetch` must stream: React Native's does not expose `response.body`, so the host passes `expo/fetch` (`createNativeClient`). `online` / `visibilitychange` do not exist: added `client.wake()`. Token store: `secureTokenStore`. |
74
+ | **React hooks** (`useQueryState`, `useMutation`, …) | Yes | n/a | **Yes.** Only `react` imports. | Split `react/index.tsx` into `hooks.tsx` (shared) and the DOM components; `@feltdb/feltkit/native` re-exports the hooks. |
75
+ | **React DOM components** (`auth.tsx`, `agent-control.tsx`) | Yes | n/a | **No**: they render `<div>`, `document`, `sessionStorage`. | None possible. Native screens are written natively (the principle: share semantics, not components). |
76
+ | **FeltDB client** (`@feltdb/core`) | n/a: never in a browser | Yes (server) | **Not used.** No client code imports it (`grep` of `src/client`, `src/react`, `src/native`). | None. FeltDB stays the authoritative state on the instance; the native app reaches it only through the application's functions, as the web app does. Evidence: the live-instance test. |
77
+ | **AppPort SDK** (`@appport/*`) | n/a (server) | Yes | **Not used on-device.** The app speaks FeltKit's HTTP API; AppPort capabilities are invoked by HTTP (`POST /appport`) with the same bearer session. | None. Tested: a capability invoked with the session the native client stored. |
78
+ | **Authentication** | Cookie session (HttpOnly) or bearer | Bearer | **Bearer in the Keychain / Keystore.** Password, sign-up, dev sign-in, e-mail code, session token, magic link via deep link. | Provider sign-in (`signInWith`) needs the instance to return to a native scheme: **gap N1**. Links that carry a session are refused by `handleDeepLink`. |
79
+ | **Capabilities / authorization** | Server-enforced | Server-enforced | Server-enforced; the screen only hides what the server would refuse (`shared/rules.ts`). | None. Tested: a viewer reads and is refused a write (`FORBIDDEN`). |
80
+ | **Files** | `client.uploadFile(link, Blob\|ArrayBuffer\|Uint8Array)` | Same | The client method works with the same inputs; **no picker or camera adapter exists** (gap N3). | An adapter over `expo-document-picker` / `expo-image-picker` returning a `Blob` or `Uint8Array`. |
81
+ | **Notifications** | In-app inbox (`services.notifications`) | n/a | The inbox is readable through the same functions. **Push is not supported**: the instance has no push channel (no APNs/FCM code in `src/`) (gap N2). | A server delivery channel and a device-token registration capability, then `expo-notifications`. |
82
+ | **Application runtime** | Vite + React | Server (`feltkit start`) | **Host only**: the backend never runs on the device. | `feltkit build ios\|android` (this document). |
83
+ | **Background work** | Service worker (extension) | Workers on the instance | Not supported: iOS/Android suspend the app and its sockets; reconnect on foreground catches up in one round trip (tested at the client). | Background sync would need a queue of offline writes (gap N4). |
84
+
85
+ **Compatible as-is:** the client, the hooks, the generated `api`, authorization, AppPort over HTTP. **Needs adapters:** secure storage, streaming fetch, app state, deep links (`createNativeClient`, `handleDeepLink`). **Needs platform-specific implementations:** screens; pickers and camera; push. **Cannot work natively:** the DOM components, and anything of the backend (it is not meant to).
86
+
87
+ ## What is validated
88
+
89
+ Run `npm run test -w @feltdb/feltkit` (`test/native.test.ts`) and the commands below.
90
+
91
+ | Claim | Evidence |
92
+ |---|---|
93
+ | Existing web build works | `feltkit build web` / `feltkit build` on `examples/tasks`; the whole existing suite passes. |
94
+ | Native project generated | `feltkit build ios --prepare`, `android --prepare`; `generateFiles` determinism test. |
95
+ | JavaScript for both platforms compiles to Hermes bytecode | `feltkit build ios` and `feltkit build android` on `examples/tasks`: the screens typecheck against React Native's types, and Metro bundles the screens, `shared/rules.ts`, `feltkit/_generated/api` and the SDK client (≈1.6 MB `.hbc` each). |
96
+ | iOS native build | `feltkit build ios --compile` (Debug, 25 s Xcode) and `--compile --release --instance https://…` (Release, 45 s Xcode) both produced `Tasks.app` for the iOS Simulator on Xcode 27. |
97
+ | The app runs natively and talks to an instance | The Debug app, installed on an iPhone 16 Pro Simulator with `feltkit dev`'s instance and Metro running: it launched in Hermes, signed in as the first dev user, and rendered the seeded project and its three tasks with the connection shown as `live` ([screenshot](evidence/native-ios-simulator.png)). The instance was started through `startDev` because `feltkit dev` refuses Node 24. Not automated (gap N6): there was no tapping, so creating and toggling tasks on the device was not exercised. |
98
+ | Android native build | Blocked here by the environment: no Android SDK (`ANDROID_HOME` unset) and no JDK. The build reports exactly that; the Gradle path is **not exercised**. |
99
+ | Client works with the native adapters against a real instance | `native.test.ts`: sign in (token written to the secure store), `watchQuery` over the streaming feed, a mutation arriving live, an AppPort capability with the stored session, sign-out clears the store, a viewer refused a write. Runs in Node with a fake secure store and fetch, **not in Hermes**. |
100
+ | Reconnect on foreground | `native.test.ts`: `wake()` ends a back-off at once. |
101
+ | Deep links | `native.test.ts`: reset / invitation / error / magic link handled; a session in a link refused. |
102
+ | Shared logic is not duplicated | `src/App.tsx` and `native/App.tsx` both import `shared/rules.ts` (`can`, `describe`) and `feltkit/_generated/api`; the rules were moved out of the web app, not copied. |
103
+
104
+ ### Build evidence
105
+
106
+ Recorded when this was written (macOS, Xcode 27, Node 24.9; the repository asks for Node 26, which this machine lacks, so the SDK's own tests ran on 24):
107
+
108
+ ```
109
+ $ feltkit build ios → bundle typecheck 0.5 s, Hermes 4-5 s, 1.6 MB
110
+ $ feltkit build android → bundle 1.6 MB
111
+ $ feltkit build ios --compile --release --instance https://tasks.example.com
112
+ → native pods 22 s, xcodebuild Release 45 s, Tasks.app (unsigned, Simulator)
113
+ $ feltkit build ios --compile → native xcodebuild Debug 25 s
114
+ $ feltkit build android --compile → refused: Android SDK not set up; no JDK (bundle kept)
115
+ ```
116
+
117
+ Environment finding: Homebrew's CocoaPods failed here because the shell's chruby `GEM_PATH` leaked into it ("Could not find 'nkf'"). The build now runs `pod` without Ruby gem variables (`podEnv`, tested) and reports "installed but does not run" separately from "not installed".
118
+
119
+ ## Gap register
120
+
121
+ | # | Gap | Evidence | Needed |
122
+ |---|---|---|---|
123
+ | N1 | Sign-in with a provider (GitHub, Google) is not available natively. | `server/oauth.ts` `returnTarget` accepts a web path or `https://<id>.chromiumapp.org/…` only. | The instance trusts the app's scheme as a return target (as `auth.extensions` does) and the host opens `expo-web-browser` auth sessions; then `signInWith` for native. |
124
+ | N2 | No push notifications. | No APNs/FCM code in `src/`. | A delivery channel on the instance, device-token registration as a capability, `expo-notifications` in the host. |
125
+ | N3 | No camera, media or file-picker adapter. | Not implemented; `uploadFile` accepts `Blob`/`Uint8Array`, unexercised on a device. | Adapter over `expo-image-picker` / `expo-document-picker`; a device test. |
126
+ | N4 | No offline writes or background sync. Reads are live only while connected; queries show the last data and the app shows `offline`. | The client has no outbox. | An outbox of idempotent mutations (the instance already has idempotency keys) replayed on reconnect. |
127
+ | N5 | No lockfile for the generated project, so transitive versions can drift. | `npm install` runs in `.feltkit/native`. | Keep `native/package-lock.json` and restore it before install (the SDK path is machine-specific in `file:` form: use the published package). |
128
+ | N6 | Android compile and any Android run were not exercised; the iOS run was a manual screenshot, not automated interaction. | Environment: no Android SDK, JDK. | Run `feltkit build android --compile` where the SDK is installed; UI automation on the Simulator/emulator. |
129
+ | N7 | App Store / Google Play distribution, signing, and EAS builds are not run or tested. | `eas.json` is generated only. | A credentialed `eas build` pass; documented per store. |
130
+ | N8 | Deep links: only the e-mail links; no universal/app links (`https://` associated domains). | `handleDeepLink`, scheme only. | Associated-domains configuration and a hosted `apple-app-site-association` / `assetlinks.json`. |
131
+
132
+ ## Recommended next slice
133
+
134
+ 1. **Run it on a device or emulator** (N6): boot the Simulator against `feltkit dev`, drive sign-in → create task → toggle, screenshot it, and make that a CI job on macOS; same for an Android emulator.
135
+ 2. **Provider sign-in and links (N1, N8)**: one change on the instance (trust the app's scheme/links) unlocks the broker flow (`providers: { github: { broker: true } }`) for native with `expo-web-browser`.
136
+ 3. **Push (N2)**: the highest-value native capability, and the first that needs a server change.
137
+ 4. **Offline outbox (N4)** on top of idempotency keys.
package/docs/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # FeltKit 0.4.0 documentation
1
+ # FeltKit 0.5.1 documentation
2
2
 
3
3
  Shipped with `@feltdb/feltkit`. In a project: `node_modules/@feltdb/feltkit/docs/`, or run `npx feltkit docs`.
4
- Public copy: https://cdn.jsdelivr.net/npm/@feltdb/feltkit@0.4.0/docs/README.md
4
+ Public copy: https://cdn.jsdelivr.net/npm/@feltdb/feltkit@0.5.1/docs/README.md
5
5
 
6
6
  - [ARCHITECTURE.md](ARCHITECTURE.md): How FeltKit is put together: one FeltDB instance, AppPort, AppPort Services
7
7
  - [GUARANTEES.md](GUARANTEES.md): What FeltKit guarantees, and its known limitations
@@ -12,11 +12,14 @@ Public copy: https://cdn.jsdelivr.net/npm/@feltdb/feltkit@0.4.0/docs/README.md
12
12
  - [POLICIES.md](POLICIES.md): Declarative policies (owner, sharing, state, input, roles, delegation), managed versions without a redeploy, simulation, decision evidence
13
13
  - [SIGN-IN-BROKER.md](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
14
14
  - [EXTENSION-HOSTS.md](EXTENSION-HOSTS.md): Running the app in a browser extension: ownership, token storage, session end, lifecycle, gaps
15
+ - [NATIVE.md](NATIVE.md): Running the app as a native iOS and Android app (Expo / React Native): feltkit build ios|android, what it produces, the compatibility matrix, validation, gaps
15
16
  - [INVOCATIONS.md](INVOCATIONS.md): Surfaces and invocations: registering entry points, the feltkit.invocation/1 contract, the durable lifecycle, dispatch and recovery
16
17
  - [EXECUTION.md](EXECUTION.md): Placement-neutral execution: the control plane and execution environments, the execution contract, adapters, placement, authority and evidence
17
18
  - [LOCAL-AUTHORITY.md](LOCAL-AUTHORITY.md): The private AuthBoundry beside the application (authority.local): grants, agents, per-agent delegation and the agentCallers opt-in
18
19
  - [CONNECTIONS.md](CONNECTIONS.md): People's own connections to integrations (credential.owner: person): connecting, isolation, AuthBoundry at every call (reference implementation)
19
20
  - [AGENT-OPERATIONS.md](AGENT-OPERATIONS.md): Agents: MCP, tasks, proposals, approvals, and evidence
21
+ - [EVE-COMPOSITION.md](EVE-COMPOSITION.md): Composing FeltKit with EVE: the run lives in FeltDB through a FeltDB World; collisions, approvals as AppPort approvals, open questions
22
+ - [NATIVE-AGENTS.md](NATIVE-AGENTS.md): Native agents: app.agent with instructions and tools, run in the app's own runtime; engines, durability, authority, approvals, limits
20
23
  - [AGENT-CONTROL.md](AGENT-CONTROL.md): Steering a running agent: update signals, submitted updates at safe boundaries, pause, resume, interrupt, stop
21
24
  - [GENERATION.md](GENERATION.md): Model generation in an application: actions, streaming, tools as proposals, in-app approvals, caller context
22
25
  - [RESOLVER.md](RESOLVER.md): Model references: change the model a deployed app uses through Resolver, without a redeploy