@agent-native/core 0.164.11 → 0.164.12

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 (65) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/templates/calendar/.agents/skills/event-management/SKILL.md +84 -0
  3. package/corpus/templates/calendar/AGENTS.md +5 -0
  4. package/corpus/templates/calendar/actions/delete-event.ts +1 -1
  5. package/corpus/templates/calendar/actions/delete-events.ts +508 -0
  6. package/corpus/templates/calendar/actions/event-action-helpers.ts +1 -1
  7. package/corpus/templates/calendar/actions/list-events.ts +53 -0
  8. package/corpus/templates/calendar/changelog/2026-08-18-the-agent-can-now-remove-many-meetings-at-once-such-as-every.md +6 -0
  9. package/corpus/templates/calendar/server/lib/event-weekday.ts +112 -0
  10. package/corpus/templates/factory/AGENTS.md +2 -1
  11. package/corpus/templates/factory/actions/get-factory-graph-version.ts +69 -0
  12. package/corpus/templates/factory/actions/list-factory-graph-versions.ts +82 -0
  13. package/corpus/templates/factory/actions/restore-factory-graph-version.ts +163 -0
  14. package/corpus/templates/factory/actions/save-factory-graph.ts +93 -60
  15. package/corpus/templates/factory/app/components/factory/FactoryHistoryView.tsx +709 -0
  16. package/corpus/templates/factory/app/components/factory/FactoryInspector.tsx +62 -2
  17. package/corpus/templates/factory/app/components/ui/alert-dialog.tsx +1 -0
  18. package/corpus/templates/factory/app/i18n/en-US.ts +43 -0
  19. package/corpus/templates/factory/app/routes/factory.tsx +115 -15
  20. package/corpus/templates/factory/server/plugins/agent-chat.ts +3 -1
  21. package/dist/collab/awareness.d.ts +2 -2
  22. package/dist/collab/struct-routes.d.ts +1 -1
  23. package/dist/notifications/routes.d.ts +3 -3
  24. package/dist/observability/routes.d.ts +3 -3
  25. package/dist/progress/routes.d.ts +1 -1
  26. package/dist/secrets/routes.d.ts +9 -9
  27. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  28. package/dist/server/realtime-token.d.ts +1 -1
  29. package/docs/content/actions-access-control.mdx +136 -2
  30. package/docs/content/actions-agent-tools.mdx +101 -0
  31. package/docs/content/actions-defining.mdx +2 -2
  32. package/docs/content/audit-log.mdx +1 -1
  33. package/docs/content/authentication.mdx +1 -1
  34. package/docs/content/cloudflare.mdx +43 -0
  35. package/docs/content/creating-templates.mdx +1 -1
  36. package/docs/content/deploy-an-app.mdx +109 -0
  37. package/docs/content/deployment-environment-variables.mdx +101 -0
  38. package/docs/content/deployment.mdx +125 -792
  39. package/docs/content/docs-components.mdx +2 -2
  40. package/docs/content/environment-variables.mdx +41 -41
  41. package/docs/content/file-uploads.mdx +74 -40
  42. package/docs/content/harness-agents.mdx +2 -2
  43. package/docs/content/internationalization.mdx +61 -65
  44. package/docs/content/key-concepts.mdx +3 -3
  45. package/docs/content/multi-app-workspace.mdx +2 -2
  46. package/docs/content/netlify.mdx +47 -0
  47. package/docs/content/node-docker.mdx +138 -0
  48. package/docs/content/organizations-teams-permissions.mdx +5 -5
  49. package/docs/content/other-platforms.mdx +27 -0
  50. package/docs/content/ssr-caching.mdx +45 -0
  51. package/docs/content/template-assets-developers.mdx +2 -2
  52. package/docs/content/template-chat-developers.mdx +2 -2
  53. package/docs/content/template-content-developers.mdx +2 -2
  54. package/docs/content/{local-file-mode.mdx → template-content-local-files.mdx} +2 -1
  55. package/docs/content/template-content-sync.mdx +2 -2
  56. package/docs/content/toolkit-agent-ux.mdx +1 -1
  57. package/docs/content/toolkit-resources.mdx +2 -2
  58. package/docs/content/updating-ui-in-production.mdx +35 -0
  59. package/docs/content/vercel.mdx +38 -0
  60. package/docs/content/what-is-agent-native.mdx +1 -1
  61. package/docs/content/workspace-deployment.mdx +350 -0
  62. package/package.json +1 -1
  63. package/docs/content/agents.mdx +0 -9
  64. package/docs/content/database.mdx +0 -317
  65. package/docs/content/human-approval.mdx +0 -156
@@ -1,156 +0,0 @@
1
- ---
2
- title: "Human-in-the-Loop Approvals"
3
- description: "Pause the agent before a high-consequence action runs — defineAction's needsApproval gate emits an approval_required event, the human approves, and only then does the tool execute."
4
- ---
5
-
6
- # Human-in-the-Loop Approvals
7
-
8
- Most actions should just run. A few — sending an email, charging a card, deleting an account — are outward-facing and hard to undo, and you don't want the agent to do them autonomously. For those, `defineAction` has an opt-in **approval gate**: when the agent tries to call the action, the loop pauses, surfaces an Approve/Deny affordance to the human, and runs the action _only_ after the human approves that specific call.
9
-
10
- <Callout tone="warning">
11
- Keep approvals rare. Every gated action is a hard stop in the agent loop — it
12
- interrupts the run and demands a human round-trip. Use `needsApproval` only
13
- for genuinely high-consequence, hard-to-undo, outward-facing operations. If
14
- you find yourself gating reads or routine writes, you're holding it wrong. The
15
- default is **off**, and almost every action should leave it off.
16
- </Callout>
17
-
18
- ## The `needsApproval` gate {#needs-approval}
19
-
20
- Set `needsApproval` on a `defineAction`. It accepts a boolean or a predicate:
21
-
22
- <AnnotatedCode
23
- id="doc-block-13p4g9y"
24
- title="Gating the one consequential action"
25
- filename="actions/send-email.ts"
26
- language="ts"
27
- code={
28
- 'export default defineAction({\n description: "Send an email via Gmail.",\n schema: z.object({\n to: z.string(),\n subject: z.string(),\n body: z.string(),\n }),\n // Sending is outward-facing and hard to undo, so the agent can never send\n // without a human approving the specific call. Drafting/queueing is\n // unaffected — only the real send is gated.\n needsApproval: true,\n run: async (args) => {\n /* ...actually send... */\n },\n});'
29
- }
30
- annotations={[
31
- {
32
- lines: "10",
33
- label: "The whole gate",
34
- note: "One flag. With it truthy and the call unapproved, the loop stops before `run` — the model never reaches the side effect on its own.",
35
- },
36
- {
37
- lines: "11-13",
38
- label: "run() is untouched",
39
- note: "The handler stays the same. Approval is enforced by the loop around it, not by anything inside `run`.",
40
- },
41
- ]}
42
- />
43
-
44
- - **`needsApproval: true`** — always require approval.
45
- - **`needsApproval: (args, ctx) => boolean | Promise<boolean>`** — require approval only when the predicate returns true. Gate conditionally, e.g. only for external recipients or only above a dollar threshold:
46
-
47
- ```ts
48
- needsApproval: (args) => !args.to.endsWith("@your-company.com"),
49
- ```
50
-
51
- Keep the predicate pure and fast. **It fails closed**: if the predicate throws, the framework treats that as "approval required" rather than silently running a high-consequence action.
52
-
53
- When `needsApproval` is omitted, behavior is byte-for-byte unchanged — there is no extra cost on the common path.
54
-
55
- This works the same for legacy `parameters`-style actions and schema-based actions, and for the in-app agent, sub-agents, A2A, and MCP callers (every agent surface routes through the same loop).
56
-
57
- ## How the loop pauses {#loop}
58
-
59
- When the agent calls a gated action and this specific call has **not** already been approved, the loop does **not** execute `run()`. Instead it:
60
-
61
- 1. Resolves the gate. For a predicate, it calls `needsApproval(input, ctx)`; a throw is treated as "must approve" (fail closed).
62
- 2. Emits a `tool_start` event (so the UI shows the call) followed immediately by an **`approval_required`** event, then stops the turn. The action's side effect never happens.
63
-
64
- The `approval_required` event carries everything the client needs to render an affordance:
65
-
66
- | Field | Type | Notes |
67
- | ------------- | -------- | ------------------------------------------------------------------- |
68
- | `tool` | `string` | The action name the agent tried to call. |
69
- | `input` | object | The arguments the agent passed. |
70
- | `approvalKey` | `string` | **Stable key** the client echoes back to approve _this exact call_. |
71
- | `toolCallId` | `string` | The model-side tool-call id, when available. |
72
-
73
- The `approvalKey` is derived deterministically from the tool name plus its input, so the same logical call always produces the same key. The model never sees or sets it — it is purely a handshake between the framework and the human's Approve affordance.
74
-
75
- The paused tool returns a result telling the model the turn is paused and not to retry, so the model doesn't spin.
76
-
77
- ## How the human approves {#approve}
78
-
79
- On `approval_required`, the chat UI renders an **Approve / Deny** affordance on the paused tool call. This is wired automatically in `AssistantChat` — you don't build it per template.
80
-
81
- <WireframeBlock id="doc-block-humanapprovalwf1">
82
- <Screen
83
- surface="panel"
84
- html={
85
- "<div style='display:flex;flex-direction:column;min-height:200px;box-sizing:border-box;padding:16px;gap:12px'><div class='wf-card' style='display:flex;flex-direction:column;gap:8px'><div style='display:flex;align-items:center;gap:8px'><span class='wf-pill warn'>Needs approval</span><strong>send-email</strong></div><div style='display:flex;flex-direction:column;gap:2px'><span class='wf-muted'>to: alex@acme.com</span><span class='wf-muted'>subject: Following up on the proposal</span></div><div style='display:flex;gap:8px'><button>Deny</button><button class='primary'>Approve</button></div></div></div>"
86
- }
87
- />
88
- </WireframeBlock>
89
-
90
- - **Approve** re-issues the turn (an ordinary continuation message) carrying the call's key in `approvedToolCalls: [approvalKey]`. On the re-issued turn, the gate sees the key in the approved set and lets that specific call run normally.
91
- - **Deny** dismisses the affordance locally; nothing is re-issued, so the action never runs.
92
-
93
- `approvedToolCalls` is a field on the chat request (`AgentChatRequest.approvedToolCalls`). Keys not present in it stay paused — approving one call never blankly approves others. Because the key is content-addressed, an approval authorizes _that call with those arguments_; if the model later proposes a different send, that's a new key and a fresh approval.
94
-
95
- ## End-to-end {#flow}
96
-
97
- <Diagram id="doc-block-2nor1g" title="The approval interrupt" summary={"A gated call pauses the turn before run() fires. Approval re-issues the turn carrying the call's key; only then does the side effect happen."}>
98
-
99
- ```html
100
- <div class="diagram-approve">
101
- <div class="diagram-box" data-rough>Agent calls send-email</div>
102
- <div class="diagram-arrow diagram-muted" aria-hidden="true">&darr;</div>
103
- <div class="diagram-panel warn" data-rough>
104
- <strong>Gate truthy, call not yet approved</strong
105
- ><small class="diagram-muted"
106
- >loop emits tool_start + approval_required { tool, input, approvalKey
107
- }</small
108
- ><span class="diagram-pill warn"
109
- >turn pauses &mdash; run() did NOT execute</span
110
- >
111
- </div>
112
- <div class="diagram-arrow diagram-muted" aria-hidden="true">&darr;</div>
113
- <div class="diagram-box" data-rough>
114
- Human clicks Approve in chat<br /><small class="diagram-muted"
115
- >client re-issues the turn with approvedToolCalls: [approvalKey]</small
116
- >
117
- </div>
118
- <div class="diagram-arrow diagram-muted" aria-hidden="true">&darr;</div>
119
- <div class="diagram-panel ok" data-rough>
120
- <span class="diagram-pill ok"
121
- >Gate sees the key &rarr; run() executes &rarr; email sends</span
122
- >
123
- </div>
124
- </div>
125
- ```
126
-
127
- ```css
128
- .diagram-approve {
129
- display: flex;
130
- flex-direction: column;
131
- align-items: center;
132
- gap: 8px;
133
- }
134
- .diagram-approve .diagram-panel {
135
- display: flex;
136
- flex-direction: column;
137
- gap: 6px;
138
- align-items: center;
139
- padding: 12px 16px;
140
- text-align: center;
141
- }
142
- .diagram-approve .diagram-arrow {
143
- font-size: 22px;
144
- line-height: 1;
145
- }
146
- ```
147
-
148
- </Diagram>
149
-
150
- The canonical (and intentionally rare) use of this gate in the framework is the Mail template's `send-email` action, which sets `needsApproval: true` so the agent can draft and queue freely but can never actually send a message without a human approving the specific send.
151
-
152
- ## What's next
153
-
154
- - [**Actions**](/docs/actions-access-control#needs-approval) — the full `defineAction` surface, including `outputSchema` for validating return values.
155
- - [**Security**](/docs/security) — when to reach for an approval gate vs. hiding an action from the model.
156
- - [**Mail template**](/docs/template-mail) — `send-email` is the reference example.