@agent-native/core 0.92.2 → 0.92.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +32 -0
- package/corpus/core/docs/content/locales/ar-SA/server.mdx +35 -0
- package/corpus/core/docs/content/locales/de-DE/server.mdx +35 -0
- package/corpus/core/docs/content/locales/es-ES/server.mdx +35 -0
- package/corpus/core/docs/content/locales/fr-FR/server.mdx +35 -0
- package/corpus/core/docs/content/locales/hi-IN/server.mdx +35 -0
- package/corpus/core/docs/content/locales/ja-JP/server.mdx +35 -0
- package/corpus/core/docs/content/locales/ko-KR/server.mdx +35 -0
- package/corpus/core/docs/content/locales/pt-BR/server.mdx +35 -0
- package/corpus/core/docs/content/locales/zh-CN/server.mdx +35 -0
- package/corpus/core/docs/content/locales/zh-TW/server.mdx +35 -0
- package/corpus/core/docs/content/server.mdx +35 -0
- package/corpus/core/package.json +2 -2
- package/corpus/core/src/agent/engine/ai-sdk-engine.ts +14 -4
- package/corpus/core/src/agent/engine/anthropic-engine.ts +15 -3
- package/corpus/core/src/agent/engine/builder-engine.ts +30 -4
- package/corpus/core/src/agent/engine/registry.ts +63 -2
- package/corpus/core/src/agent/model-config.ts +0 -2
- package/corpus/core/src/agent/production-agent.ts +12 -1
- package/corpus/core/src/agent/run-manager.ts +57 -36
- package/corpus/core/src/agent/run-store.ts +81 -2
- package/corpus/core/src/agent/thread-data-builder.ts +33 -2
- package/corpus/core/src/client/AssistantChat.tsx +314 -96
- package/corpus/core/src/client/agent-chat-adapter.ts +17 -1
- package/corpus/core/src/client/chat/repo-helpers.ts +45 -0
- package/corpus/core/src/client/chat/tool-call-display.tsx +36 -27
- package/corpus/core/src/client/chat-model-groups.ts +1 -5
- package/corpus/core/src/client/composer/TiptapComposer.tsx +0 -2
- package/corpus/core/src/client/embed-auth.ts +20 -0
- package/corpus/core/src/client/settings/SettingsSection.tsx +66 -5
- package/corpus/core/src/client/sse-event-processor.ts +49 -17
- package/corpus/core/src/client/use-db-sync.ts +31 -9
- package/corpus/core/src/collab/agent-presence.ts +6 -1
- package/corpus/core/src/collab/awareness-store.ts +185 -0
- package/corpus/core/src/collab/awareness.ts +58 -2
- package/corpus/core/src/scripts/agent-engines/manage-agent-engine.ts +7 -8
- package/corpus/core/src/scripts/agent-engines/set-agent-engine.ts +7 -18
- package/corpus/core/src/server/core-routes-plugin.ts +21 -2
- package/corpus/core/src/server/embed-session.ts +20 -4
- package/corpus/core/src/styles/agent-native.css +51 -0
- package/corpus/core/src/tracking/providers.ts +33 -2
- package/corpus/templates/analytics/app/pages/adhoc/explorer-dashboard/index.tsx +8 -1
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/index.tsx +9 -1
- package/corpus/templates/analytics/app/pages/monitoring/uptime/MonitorDetail.tsx +41 -11
- package/corpus/templates/analytics/app/pages/monitoring/uptime/types.ts +44 -0
- package/corpus/templates/analytics/changelog/2026-07-09-dashboard-action-menus-now-close-cleanly-before-opening-hist.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-09-dashboard-email-reports-still-send-when-the-screenshot-captu.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-09-uptime-alerts-now-suppress-recovery-noise-during-flapping-an.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-09-uptime-check-history-now-shows-timing-diagnostics-so-slow-or.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-09-uptime-recovery-alerts-now-send-when-the-original-outage-not.md +6 -0
- package/corpus/templates/analytics/docs/uptime-monitoring.md +29 -16
- package/corpus/templates/analytics/netlify.toml +3 -0
- package/corpus/templates/analytics/scripts/emit-netlify-dashboard-report-cron.ts +126 -0
- package/corpus/templates/analytics/server/db/schema-monitoring.ts +5 -0
- package/corpus/templates/analytics/server/jobs/uptime-monitors.ts +5 -1
- package/corpus/templates/analytics/server/lib/uptime-monitors.ts +305 -31
- package/corpus/templates/analytics/server/plugins/db.ts +15 -0
- package/corpus/templates/analytics/server/plugins/uptime-monitor-jobs.ts +1 -1
- package/corpus/templates/analytics/server/routes/api/uptime-monitors/run.post.ts +57 -0
- package/corpus/templates/clips/actions/list-meetings.ts +12 -0
- package/corpus/templates/clips/changelog/2026-07-09-meeting-reminders-now-ignore-obvious-solo-personal-calendar-.md +6 -0
- package/corpus/templates/clips/desktop/src-tauri/src/meetings_watcher.rs +1 -0
- package/corpus/templates/clips/server/lib/calendar-event-classification.ts +79 -0
- package/dist/agent/engine/ai-sdk-engine.d.ts.map +1 -1
- package/dist/agent/engine/ai-sdk-engine.js +13 -4
- package/dist/agent/engine/ai-sdk-engine.js.map +1 -1
- package/dist/agent/engine/anthropic-engine.d.ts.map +1 -1
- package/dist/agent/engine/anthropic-engine.js +14 -3
- package/dist/agent/engine/anthropic-engine.js.map +1 -1
- package/dist/agent/engine/builder-engine.d.ts +1 -1
- package/dist/agent/engine/builder-engine.d.ts.map +1 -1
- package/dist/agent/engine/builder-engine.js +26 -4
- package/dist/agent/engine/builder-engine.js.map +1 -1
- package/dist/agent/engine/registry.d.ts.map +1 -1
- package/dist/agent/engine/registry.js +47 -2
- package/dist/agent/engine/registry.js.map +1 -1
- package/dist/agent/model-config.d.ts +2 -2
- package/dist/agent/model-config.d.ts.map +1 -1
- package/dist/agent/model-config.js +0 -2
- package/dist/agent/model-config.js.map +1 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +12 -1
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/run-manager.d.ts.map +1 -1
- package/dist/agent/run-manager.js +52 -33
- package/dist/agent/run-manager.js.map +1 -1
- package/dist/agent/run-store.d.ts +24 -0
- package/dist/agent/run-store.d.ts.map +1 -1
- package/dist/agent/run-store.js +64 -2
- package/dist/agent/run-store.js.map +1 -1
- package/dist/agent/thread-data-builder.d.ts.map +1 -1
- package/dist/agent/thread-data-builder.js +28 -2
- package/dist/agent/thread-data-builder.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +6 -0
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +243 -36
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +15 -1
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/chat/repo-helpers.d.ts.map +1 -1
- package/dist/client/chat/repo-helpers.js +43 -0
- package/dist/client/chat/repo-helpers.js.map +1 -1
- package/dist/client/chat/tool-call-display.d.ts.map +1 -1
- package/dist/client/chat/tool-call-display.js +4 -4
- package/dist/client/chat/tool-call-display.js.map +1 -1
- package/dist/client/chat-model-groups.d.ts.map +1 -1
- package/dist/client/chat-model-groups.js +1 -3
- package/dist/client/chat-model-groups.js.map +1 -1
- package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/client/composer/TiptapComposer.js +0 -2
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/embed-auth.d.ts.map +1 -1
- package/dist/client/embed-auth.js +14 -0
- package/dist/client/embed-auth.js.map +1 -1
- package/dist/client/settings/SettingsSection.d.ts.map +1 -1
- package/dist/client/settings/SettingsSection.js +32 -3
- package/dist/client/settings/SettingsSection.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +44 -17
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/client/use-db-sync.d.ts.map +1 -1
- package/dist/client/use-db-sync.js +29 -9
- package/dist/client/use-db-sync.js.map +1 -1
- package/dist/collab/agent-presence.d.ts.map +1 -1
- package/dist/collab/agent-presence.js +5 -2
- package/dist/collab/agent-presence.js.map +1 -1
- package/dist/collab/awareness-store.d.ts +1 -1
- package/dist/collab/awareness-store.d.ts.map +1 -1
- package/dist/collab/awareness-store.js +0 -0
- package/dist/collab/awareness-store.js.map +1 -1
- package/dist/collab/awareness.d.ts +4 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/collab/awareness.js +46 -2
- package/dist/collab/awareness.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/notifications/routes.d.ts +2 -2
- package/dist/observability/routes.d.ts +3 -3
- package/dist/progress/routes.d.ts +1 -1
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/scripts/agent-engines/manage-agent-engine.d.ts.map +1 -1
- package/dist/scripts/agent-engines/manage-agent-engine.js +6 -6
- package/dist/scripts/agent-engines/manage-agent-engine.js.map +1 -1
- package/dist/scripts/agent-engines/set-agent-engine.d.ts.map +1 -1
- package/dist/scripts/agent-engines/set-agent-engine.js +5 -13
- package/dist/scripts/agent-engines/set-agent-engine.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/core-routes-plugin.d.ts +5 -0
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +10 -3
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/embed-session.d.ts.map +1 -1
- package/dist/server/embed-session.js +17 -4
- package/dist/server/embed-session.js.map +1 -1
- package/dist/styles/agent-native.css +51 -0
- package/dist/tracking/providers.d.ts.map +1 -1
- package/dist/tracking/providers.js +23 -5
- package/dist/tracking/providers.js.map +1 -1
- package/docs/content/locales/ar-SA/server.mdx +35 -0
- package/docs/content/locales/de-DE/server.mdx +35 -0
- package/docs/content/locales/es-ES/server.mdx +35 -0
- package/docs/content/locales/fr-FR/server.mdx +35 -0
- package/docs/content/locales/hi-IN/server.mdx +35 -0
- package/docs/content/locales/ja-JP/server.mdx +35 -0
- package/docs/content/locales/ko-KR/server.mdx +35 -0
- package/docs/content/locales/pt-BR/server.mdx +35 -0
- package/docs/content/locales/zh-CN/server.mdx +35 -0
- package/docs/content/locales/zh-TW/server.mdx +35 -0
- package/docs/content/server.mdx +35 -0
- package/package.json +2 -2
package/corpus/README.md
CHANGED
package/corpus/core/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @agent-native/core
|
|
2
2
|
|
|
3
|
+
## 0.92.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 86697e9: Depend on `@agent-native/toolkit` via `workspace:^` instead of `workspace:*`. Publishing now pins a caret range (e.g. `^0.4.3`) rather than an exact version, so an app that scaffolds `@agent-native/toolkit@latest` separately can dedupe against it through normal semver resolution instead of installing two mismatched toolkit copies side by side (which crashed Vite with `"./collab-ui" is not exported`).
|
|
8
|
+
|
|
9
|
+
## 0.92.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 0fee97b: Animate settings section cards open and closed with intrinsic height transitions.
|
|
14
|
+
- 0fee97b: Document how to build API-only Agent Native apps with actions on the built-in Nitro/H3 server.
|
|
15
|
+
- 0fee97b: Replay the real terminal error for completed agent runs on reconnect instead of replacing provider failures with stale-run messages, and stop heartbeat updates after a run leaves the running state.
|
|
16
|
+
- 0fee97b: Allow signed embed sessions for Analytics dashboard deep links to authenticate after canonical `/dashboards/:id` redirects.
|
|
17
|
+
- 0fee97b: Prevent stale stored awareness rows from resurrecting user or agent presence after a client explicitly leaves a collaborative document.
|
|
18
|
+
- 0fee97b: Abort superseded chat reconnect readers and back off failed reattach attempts so repeated stale runs do not create client request storms.
|
|
19
|
+
- 0fee97b: Harden chat stop and queued follow-up handling so interrupted tool calls settle cleanly, and flush Agent Native analytics immediately in serverless runtimes.
|
|
20
|
+
- 0fee97b: Avoid CORS preflight storms for embedded framework polling by using query-token auth on safe `/_agent-native` GET requests.
|
|
21
|
+
- 0fee97b: Deliver Agent Native Analytics tracking immediately in serverless runtimes so `http.response` health telemetry is not lost after the response finishes.
|
|
22
|
+
- 0fee97b: Prevent in-flight tool call cards from flickering between newer and older states during reconnect, thread import, and retry clears.
|
|
23
|
+
- 0fee97b: Make chat prompt submission update immediately and make Stop clear queued follow-ups and settle interrupted tool calls.
|
|
24
|
+
- 0fee97b: Single-flight the agent run heartbeat write so a run holds at most one Neon connection for liveness. The 1.5s heartbeat timer previously fired a fresh write every tick regardless of whether the prior one was still in flight; under Neon pooler saturation (writes taking up to the ~8s DB timeout) this piled up ~5 concurrent heartbeat connections per run, adding to the connection-cap exhaustion that starves the heartbeat and gets the still-alive run false-reaped as stale. The abort and no-progress-backstop checks still run every tick.
|
|
25
|
+
- 0fee97b: Normalize unsupported saved agent models to a supported version match or the engine default.
|
|
26
|
+
- 0fee97b: Remove Grok Code Fast and Qwen3 Coder from the Builder gateway model picker.
|
|
27
|
+
- 0fee97b: Treat Anthropic/Builder bare "Connection error." failures as retryable network interruptions, and stop mislabeling those failed runs as stale_run when the client reconnects past the real terminal event.
|
|
28
|
+
- 0fee97b: Stop `useDbSync` from turning app-state navigation/selection churn into a client fetch storm. `app-state` change events (agent/UI navigation, selection, and the set-url/questions command channel) now only invalidate their own `["app-state"]` and command query keys — they no longer fan out into the broad `["action"]`, `["extension"]`, and `["tool"]` data-query invalidation. Only events that can actually change action/extension-backed data (action mutations, settings, extensions, collab, screen-refresh) refetch those prefixes.
|
|
29
|
+
|
|
30
|
+
During an active agent session the app mirrors navigation and selection into `application_state` continuously, and on serverless the poll fallback replays those writes back to the originating tab (the DB-scan path can't preserve `requestSource`, so `ignoreSource` can't filter them). Each replayed write previously refetched every action query at once, and that request storm exhausted the DB connection pool — which starved run heartbeat writes and surfaced downstream as `stale_run` chat errors. Real mutations that also write navigation state still refresh action queries because their `action` event rides in the same batch.
|
|
31
|
+
|
|
32
|
+
- 0fee97b: Show streamed agent reasoning when gateways emit AI SDK-style reasoning deltas.
|
|
33
|
+
- 0fee97b: Show raw tool call output in an auto-height popover with viewport-capped scrolling instead of a fixed-height dialog.
|
|
34
|
+
|
|
3
35
|
## 0.92.2
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
|
@@ -129,6 +129,41 @@ export default defineEventHandler(() => ({
|
|
|
129
129
|
|
|
130
130
|
استخدم مسارات `/api/*` المخصصة فقط عندما تحتاج إلى بروتوكول على شكل مسار أو سلوك ثنائي/دفق. انظر [Actions](/docs/actions).
|
|
131
131
|
|
|
132
|
+
### تطبيقات API فقط {#api-only-apps}
|
|
133
|
+
|
|
134
|
+
لا تحتاج إلى خادم Express لمجرد أن التطبيق مخصص للـ API فقط. يتضمن تطبيق Agent Native بالفعل خادم Nitro/H3، و`defineAction()` هو سطح API الافتراضي. عرّف العمليات في `actions/`؛ يقوم إطار العمل بتركيب كل action على `/_agent-native/actions/<name>` مع التحقق من schema وسياق الطلب.
|
|
135
|
+
|
|
136
|
+
استخدم خيار `http` في action لتشكيل الوصول المباشر عبر HTTP: تكون actions افتراضيًا `POST`، ويغيّر `http: { method: "GET" | "PUT" | "DELETE" }` الفعل، ويجعل `http: false` الـ action غير متاحة عبر HTTP. استخدم `server/routes/api/*` فقط للمخاوف التي لها شكل مسار أو بروتوكول: تحميل الملفات، streaming/SSE، webhooks، استدعاءات OAuth، الصفحات العامة، أو شكل REST خارجي لا يمكن تمثيله بوضوح كـ action. لا تنشئ مسارات `/api/*` تقوم غالبًا بتغليف actions أو إعادة تصديرها.
|
|
137
|
+
|
|
138
|
+
لإنشاء endpoint حالة للقراءة فقط، اجعله action:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
// actions/get-status.ts
|
|
142
|
+
import { defineAction } from "@agent-native/core/action";
|
|
143
|
+
import { z } from "zod";
|
|
144
|
+
|
|
145
|
+
export default defineAction({
|
|
146
|
+
description: "Return API service status",
|
|
147
|
+
schema: z.object({
|
|
148
|
+
service: z.string().optional(),
|
|
149
|
+
}),
|
|
150
|
+
http: { method: "GET" },
|
|
151
|
+
run: async ({ service }) => ({
|
|
152
|
+
ok: true,
|
|
153
|
+
service: service ?? "api",
|
|
154
|
+
checkedAt: new Date().toISOString(),
|
|
155
|
+
}),
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
استدعِه مباشرة عبر HTTP:
|
|
160
|
+
|
|
161
|
+
```http
|
|
162
|
+
GET /_agent-native/actions/get-status?service=billing
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
بالنسبة إلى `POST` وactions الكتابة الأخرى، أرسل جسم JSON إلى مسار action نفسه.
|
|
166
|
+
|
|
132
167
|
## إكمال النص بلقطة واحدة {#complete-text}
|
|
133
168
|
|
|
134
169
|
يجب أن تتم معظم أعمال الذكاء الاصطناعي من خلال دردشة الوكيل حتى يتمكن المستخدمون من الرؤية والتوجيه والتدقيق
|
|
@@ -127,6 +127,41 @@ Wenn UI und Agent beide etwas tun müssen, definieren Sie eine Aktion anstelle e
|
|
|
127
127
|
|
|
128
128
|
Verwenden Sie benutzerdefinierte `/api/*`-Routen nur, wenn Sie ein routenförmiges Protokoll oder Binär-/Streaming-Verhalten benötigen. Siehe [Actions](/docs/actions).
|
|
129
129
|
|
|
130
|
+
### API-only Apps {#api-only-apps}
|
|
131
|
+
|
|
132
|
+
Sie benötigen keinen Express-Server, nur weil die App nur eine API bereitstellt. Eine Agent Native-App bringt bereits einen Nitro/H3-Server mit, und `defineAction()` ist die standardmäßige API-Oberfläche. Definieren Sie Operationen in `actions/`; das Framework stellt jede action unter `/_agent-native/actions/<name>` mit Schemavalidierung und Anforderungskontext bereit.
|
|
133
|
+
|
|
134
|
+
Verwenden Sie die `http`-Option der action, um direkten HTTP-Zugriff zu formen: actions sind standardmäßig `POST`, `http: { method: "GET" | "PUT" | "DELETE" }` ändert das Verb, und `http: false` nimmt eine action aus HTTP heraus. Greifen Sie nur für routenförmige oder protokollbezogene Anliegen zu `server/routes/api/*`: Datei-Uploads, Streaming/SSE, webhooks, OAuth-Rückrufe, öffentliche Seiten oder eine externe REST-Form, die sich nicht sauber als action darstellen lässt. Erstellen Sie keine `/api/*`-Routen, die hauptsächlich actions umhüllen oder re-exportieren.
|
|
135
|
+
|
|
136
|
+
Für einen schreibgeschützten Status-endpoint behalten Sie ihn als action bei:
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
// actions/get-status.ts
|
|
140
|
+
import { defineAction } from "@agent-native/core/action";
|
|
141
|
+
import { z } from "zod";
|
|
142
|
+
|
|
143
|
+
export default defineAction({
|
|
144
|
+
description: "Return API service status",
|
|
145
|
+
schema: z.object({
|
|
146
|
+
service: z.string().optional(),
|
|
147
|
+
}),
|
|
148
|
+
http: { method: "GET" },
|
|
149
|
+
run: async ({ service }) => ({
|
|
150
|
+
ok: true,
|
|
151
|
+
service: service ?? "api",
|
|
152
|
+
checkedAt: new Date().toISOString(),
|
|
153
|
+
}),
|
|
154
|
+
});
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Rufen Sie ihn direkt über HTTP auf:
|
|
158
|
+
|
|
159
|
+
```http
|
|
160
|
+
GET /_agent-native/actions/get-status?service=billing
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Für `POST` und andere schreibende actions senden Sie einen JSON-body an denselben action-path.
|
|
164
|
+
|
|
130
165
|
## One-Shot-Textvervollständigung {#complete-text}
|
|
131
166
|
|
|
132
167
|
Der Großteil der KI-Arbeit sollte über den Agenten-Chat erfolgen, damit Benutzer sehen, steuern und prüfen können
|
|
@@ -129,6 +129,41 @@ Si tanto el UI como el agente necesitan hacer algo, defina una acción en lugar
|
|
|
129
129
|
|
|
130
130
|
Utilice rutas `/api/*` personalizadas solo cuando necesite un protocolo en forma de ruta o un comportamiento binario/de transmisión. Ver [Actions](/docs/actions).
|
|
131
131
|
|
|
132
|
+
### Aplicaciones solo API {#api-only-apps}
|
|
133
|
+
|
|
134
|
+
No necesita un servidor Express solo porque la aplicación sea solo API. Una aplicación Agent Native ya incluye un servidor Nitro/H3, y `defineAction()` es la superficie API predeterminada. Defina las operaciones en `actions/`; el marco monta cada action en `/_agent-native/actions/<name>` con validación de esquema y contexto de solicitud.
|
|
135
|
+
|
|
136
|
+
Use la opción `http` de la action para dar forma al acceso HTTP directo: las actions son `POST` de forma predeterminada, `http: { method: "GET" | "PUT" | "DELETE" }` cambia el verbo, y `http: false` deja una action fuera de HTTP. Use `server/routes/api/*` solo para necesidades con forma de ruta o protocolo: cargas de archivos, streaming/SSE, webhooks, devoluciones de llamada OAuth, páginas públicas o una forma REST externa que no pueda representarse limpiamente como una action. No cree rutas `/api/*` que principalmente envuelvan o reexporten actions.
|
|
137
|
+
|
|
138
|
+
Para un endpoint de estado de solo lectura, manténgalo como una action:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
// actions/get-status.ts
|
|
142
|
+
import { defineAction } from "@agent-native/core/action";
|
|
143
|
+
import { z } from "zod";
|
|
144
|
+
|
|
145
|
+
export default defineAction({
|
|
146
|
+
description: "Return API service status",
|
|
147
|
+
schema: z.object({
|
|
148
|
+
service: z.string().optional(),
|
|
149
|
+
}),
|
|
150
|
+
http: { method: "GET" },
|
|
151
|
+
run: async ({ service }) => ({
|
|
152
|
+
ok: true,
|
|
153
|
+
service: service ?? "api",
|
|
154
|
+
checkedAt: new Date().toISOString(),
|
|
155
|
+
}),
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Llámela directamente por HTTP:
|
|
160
|
+
|
|
161
|
+
```http
|
|
162
|
+
GET /_agent-native/actions/get-status?service=billing
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Para `POST` y otras actions de escritura, envíe un cuerpo JSON al mismo path de la action.
|
|
166
|
+
|
|
132
167
|
## Completación de texto de una sola vez {#complete-text}
|
|
133
168
|
|
|
134
169
|
La mayor parte del trabajo de IA debe realizarse a través del chat del agente para que los usuarios puedan verlo, dirigirlo y auditarlo
|
|
@@ -129,6 +129,41 @@ Si le UI et l'agent doivent tous deux faire quelque chose, définissez une actio
|
|
|
129
129
|
|
|
130
130
|
Utilisez des routes `/api/*` personnalisées uniquement lorsque vous avez besoin d'un protocole en forme de route ou d'un comportement binaire/streaming. Voir [Actions](/docs/actions).
|
|
131
131
|
|
|
132
|
+
### Applications API uniquement {#api-only-apps}
|
|
133
|
+
|
|
134
|
+
Vous n'avez pas besoin d'un serveur Express simplement parce que l'application expose uniquement une API. Une application Agent Native inclut déjà un serveur Nitro/H3, et `defineAction()` est la surface API par défaut. Définissez les opérations dans `actions/` ; le framework monte chaque action sur `/_agent-native/actions/<name>` avec validation de schéma et contexte de requête.
|
|
135
|
+
|
|
136
|
+
Utilisez l'option `http` de l'action pour façonner l'accès HTTP direct : les actions sont en `POST` par défaut, `http: { method: "GET" | "PUT" | "DELETE" }` change le verbe, et `http: false` désactive l'endpoint HTTP d'une action. Utilisez `server/routes/api/*` uniquement pour les besoins en forme de route ou de protocole : téléversements de fichiers, streaming/SSE, webhooks, rappels OAuth, pages publiques, ou une forme REST externe qui ne peut pas être représentée proprement par une action. Ne créez pas de routes `/api/*` qui se contentent surtout d'envelopper ou de réexporter des actions.
|
|
137
|
+
|
|
138
|
+
Pour un endpoint de statut en lecture seule, gardez-le comme une action :
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
// actions/get-status.ts
|
|
142
|
+
import { defineAction } from "@agent-native/core/action";
|
|
143
|
+
import { z } from "zod";
|
|
144
|
+
|
|
145
|
+
export default defineAction({
|
|
146
|
+
description: "Return API service status",
|
|
147
|
+
schema: z.object({
|
|
148
|
+
service: z.string().optional(),
|
|
149
|
+
}),
|
|
150
|
+
http: { method: "GET" },
|
|
151
|
+
run: async ({ service }) => ({
|
|
152
|
+
ok: true,
|
|
153
|
+
service: service ?? "api",
|
|
154
|
+
checkedAt: new Date().toISOString(),
|
|
155
|
+
}),
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Appelez-la directement via HTTP :
|
|
160
|
+
|
|
161
|
+
```http
|
|
162
|
+
GET /_agent-native/actions/get-status?service=billing
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Pour `POST` et les autres actions d'écriture, envoyez un corps JSON au même chemin d'action.
|
|
166
|
+
|
|
132
167
|
## Achèvement du texte en une seule fois {#complete-text}
|
|
133
168
|
|
|
134
169
|
La plupart des travaux d'IA doivent passer par le chat de l'agent afin que les utilisateurs puissent voir, piloter et auditer
|
|
@@ -125,6 +125,41 @@ export default defineEventHandler(() => ({
|
|
|
125
125
|
|
|
126
126
|
कस्टम `/api/*` रूट का उपयोग केवल तभी करें जब आपको रूट-आकार वाले प्रोटोकॉल या बाइनरी/स्ट्रीमिंग व्यवहार की आवश्यकता हो। [Actions](/docs/actions) देखें.
|
|
127
127
|
|
|
128
|
+
### केवल API ऐप्स {#api-only-apps}
|
|
129
|
+
|
|
130
|
+
सिर्फ इसलिए कि ऐप केवल API है, आपको Express सर्वर की आवश्यकता नहीं है। Agent Native ऐप में पहले से Nitro/H3 सर्वर शामिल होता है, और `defineAction()` डिफ़ॉल्ट API सतह है। संचालन को `actions/` में परिभाषित करें; फ़्रेमवर्क हर action को schema validation और request context के साथ `/_agent-native/actions/<name>` पर माउंट करता है।
|
|
131
|
+
|
|
132
|
+
सीधे HTTP access का आकार देने के लिए action के `http` विकल्प का उपयोग करें: actions डिफ़ॉल्ट रूप से `POST` होते हैं, `http: { method: "GET" | "PUT" | "DELETE" }` verb बदलता है, और `http: false` action को HTTP से हटा देता है। `server/routes/api/*` का उपयोग केवल route-shaped या protocol चिंताओं के लिए करें: file uploads, streaming/SSE, webhooks, OAuth callbacks, public pages, या ऐसा external REST shape जिसे action के रूप में साफ़ तरीके से व्यक्त नहीं किया जा सकता। ऐसे `/api/*` routes न बनाएं जो अधिकतर actions को wrap या re-export करते हों।
|
|
133
|
+
|
|
134
|
+
रीड-ओनली status endpoint के लिए, इसे action ही रखें:
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
// actions/get-status.ts
|
|
138
|
+
import { defineAction } from "@agent-native/core/action";
|
|
139
|
+
import { z } from "zod";
|
|
140
|
+
|
|
141
|
+
export default defineAction({
|
|
142
|
+
description: "Return API service status",
|
|
143
|
+
schema: z.object({
|
|
144
|
+
service: z.string().optional(),
|
|
145
|
+
}),
|
|
146
|
+
http: { method: "GET" },
|
|
147
|
+
run: async ({ service }) => ({
|
|
148
|
+
ok: true,
|
|
149
|
+
service: service ?? "api",
|
|
150
|
+
checkedAt: new Date().toISOString(),
|
|
151
|
+
}),
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
इसे सीधे HTTP पर कॉल करें:
|
|
156
|
+
|
|
157
|
+
```http
|
|
158
|
+
GET /_agent-native/actions/get-status?service=billing
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
`POST` और अन्य write actions के लिए, उसी action path पर JSON body भेजें.
|
|
162
|
+
|
|
128
163
|
## एक-शॉट पाठ समापन {#complete-text}
|
|
129
164
|
|
|
130
165
|
अधिकांश AI कार्य एजेंट चैट के माध्यम से होना चाहिए ताकि उपयोगकर्ता देख सकें, संचालन कर सकें और ऑडिट कर सकें
|
|
@@ -129,6 +129,41 @@ UI とエージェントの両方が何かを行う必要がある場合は、
|
|
|
129
129
|
|
|
130
130
|
カスタム `/api/*` ルートは、ルート形式のプロトコルまたはバイナリ/ストリーミング動作が必要な場合にのみ使用してください。 [Actions](/docs/actions) を参照してください。
|
|
131
131
|
|
|
132
|
+
### API 専用アプリ {#api-only-apps}
|
|
133
|
+
|
|
134
|
+
アプリが API 専用だからといって、Express サーバーは必要ありません。Agent Native アプリには Nitro/H3 サーバーがすでに含まれており、`defineAction()` がデフォルトの API サーフェスです。操作は `actions/` に定義します。フレームワークは、各 action をスキーマ検証とリクエスト コンテキスト付きで `/_agent-native/actions/<name>` にマウントします。
|
|
135
|
+
|
|
136
|
+
直接 HTTP アクセスの形は action の `http` オプションで調整します。actions はデフォルトで `POST`、`http: { method: "GET" | "PUT" | "DELETE" }` でメソッドを変更し、`http: false` で action を HTTP から外します。`server/routes/api/*` は、ファイル アップロード、ストリーミング/SSE、webhooks、OAuth コールバック、パブリック ページ、または action としてきれいに表せない外部向け REST 形状など、ルート形式またはプロトコル上の関心事にだけ使用してください。主に actions をラップまたは再エクスポートする `/api/*` ルートは作成しないでください。
|
|
137
|
+
|
|
138
|
+
読み取り専用の status endpoint は action として保持します:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
// actions/get-status.ts
|
|
142
|
+
import { defineAction } from "@agent-native/core/action";
|
|
143
|
+
import { z } from "zod";
|
|
144
|
+
|
|
145
|
+
export default defineAction({
|
|
146
|
+
description: "Return API service status",
|
|
147
|
+
schema: z.object({
|
|
148
|
+
service: z.string().optional(),
|
|
149
|
+
}),
|
|
150
|
+
http: { method: "GET" },
|
|
151
|
+
run: async ({ service }) => ({
|
|
152
|
+
ok: true,
|
|
153
|
+
service: service ?? "api",
|
|
154
|
+
checkedAt: new Date().toISOString(),
|
|
155
|
+
}),
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
HTTP で直接呼び出します:
|
|
160
|
+
|
|
161
|
+
```http
|
|
162
|
+
GET /_agent-native/actions/get-status?service=billing
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
`POST` とその他の書き込み actions では、同じ action path に JSON body を送信します。
|
|
166
|
+
|
|
132
167
|
## ワンショットテキスト補完 {#complete-text}
|
|
133
168
|
|
|
134
169
|
ユーザーが確認、操作、監査できるように、ほとんどの AI 作業はエージェント チャットを経由する必要があります
|
|
@@ -127,6 +127,41 @@ UI와 에이전트가 모두 작업을 수행해야 하는 경우 사용자 지
|
|
|
127
127
|
|
|
128
128
|
경로 형태의 프로토콜이나 바이너리/스트리밍 동작이 필요한 경우에만 사용자 지정 `/api/*` 경로를 사용하세요. [Actions](/docs/actions)를 참조하세요.
|
|
129
129
|
|
|
130
|
+
### API 전용 앱 {#api-only-apps}
|
|
131
|
+
|
|
132
|
+
앱이 API 전용이라고 해서 Express 서버가 필요한 것은 아닙니다. Agent Native 앱에는 이미 Nitro/H3 서버가 포함되어 있으며, `defineAction()`이 기본 API 표면입니다. 작업은 `actions/`에 정의하세요. 프레임워크는 각 action을 schema validation 및 request context와 함께 `/_agent-native/actions/<name>`에 마운트합니다.
|
|
133
|
+
|
|
134
|
+
직접 HTTP access의 형태는 action의 `http` 옵션으로 조정합니다. actions는 기본적으로 `POST`이고, `http: { method: "GET" | "PUT" | "DELETE" }`는 verb를 변경하며, `http: false`는 action을 HTTP에서 제외합니다. `server/routes/api/*`는 file uploads, streaming/SSE, webhooks, OAuth callbacks, public pages 또는 action으로 깔끔하게 표현할 수 없는 external REST shape처럼 route-shaped 또는 protocol 관련 요구에만 사용하세요. 주로 actions를 감싸거나 다시 내보내는 `/api/*` 경로는 만들지 마세요.
|
|
135
|
+
|
|
136
|
+
읽기 전용 상태 endpoint는 action으로 유지하세요:
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
// actions/get-status.ts
|
|
140
|
+
import { defineAction } from "@agent-native/core/action";
|
|
141
|
+
import { z } from "zod";
|
|
142
|
+
|
|
143
|
+
export default defineAction({
|
|
144
|
+
description: "Return API service status",
|
|
145
|
+
schema: z.object({
|
|
146
|
+
service: z.string().optional(),
|
|
147
|
+
}),
|
|
148
|
+
http: { method: "GET" },
|
|
149
|
+
run: async ({ service }) => ({
|
|
150
|
+
ok: true,
|
|
151
|
+
service: service ?? "api",
|
|
152
|
+
checkedAt: new Date().toISOString(),
|
|
153
|
+
}),
|
|
154
|
+
});
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
HTTP로 직접 호출합니다:
|
|
158
|
+
|
|
159
|
+
```http
|
|
160
|
+
GET /_agent-native/actions/get-status?service=billing
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
`POST` 및 기타 쓰기 actions는 같은 action path로 JSON body를 보냅니다.
|
|
164
|
+
|
|
130
165
|
## 원샷 텍스트 완성 {#complete-text}
|
|
131
166
|
|
|
132
167
|
대부분의 AI 작업은 사용자가 보고, 조종하고, 감사할 수 있도록 에이전트 채팅을 거쳐야 합니다.
|
|
@@ -129,6 +129,41 @@ Se o UI e o agente precisarem fazer algo, defina uma ação em vez de uma rota A
|
|
|
129
129
|
|
|
130
130
|
Use rotas `/api/*` personalizadas somente quando precisar de um protocolo em formato de rota ou comportamento binário/streaming. Consulte [Actions](/docs/actions).
|
|
131
131
|
|
|
132
|
+
### Aplicativos somente API {#api-only-apps}
|
|
133
|
+
|
|
134
|
+
Você não precisa de um servidor Express só porque o aplicativo é somente API. Um aplicativo Agent Native já vem com um servidor Nitro/H3, e `defineAction()` é a superfície API padrão. Defina operações em `actions/`; a estrutura monta cada action em `/_agent-native/actions/<name>` com validação de schema e contexto de solicitação.
|
|
135
|
+
|
|
136
|
+
Use a opção `http` da action para moldar o acesso HTTP direto: actions são `POST` por padrão, `http: { method: "GET" | "PUT" | "DELETE" }` altera o verbo, e `http: false` remove uma action do HTTP. Use `server/routes/api/*` apenas para necessidades com formato de rota ou protocolo: uploads de arquivos, streaming/SSE, webhooks, callbacks OAuth, páginas públicas ou uma forma REST externa que não possa ser representada claramente como uma action. Não crie rotas `/api/*` que principalmente encapsulem ou reexportem actions.
|
|
137
|
+
|
|
138
|
+
Para um endpoint de status somente leitura, mantenha-o como uma action:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
// actions/get-status.ts
|
|
142
|
+
import { defineAction } from "@agent-native/core/action";
|
|
143
|
+
import { z } from "zod";
|
|
144
|
+
|
|
145
|
+
export default defineAction({
|
|
146
|
+
description: "Return API service status",
|
|
147
|
+
schema: z.object({
|
|
148
|
+
service: z.string().optional(),
|
|
149
|
+
}),
|
|
150
|
+
http: { method: "GET" },
|
|
151
|
+
run: async ({ service }) => ({
|
|
152
|
+
ok: true,
|
|
153
|
+
service: service ?? "api",
|
|
154
|
+
checkedAt: new Date().toISOString(),
|
|
155
|
+
}),
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Chame diretamente via HTTP:
|
|
160
|
+
|
|
161
|
+
```http
|
|
162
|
+
GET /_agent-native/actions/get-status?service=billing
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Para `POST` e outras actions de escrita, envie um corpo JSON para o mesmo caminho da action.
|
|
166
|
+
|
|
132
167
|
## Completamento de texto único {#complete-text}
|
|
133
168
|
|
|
134
169
|
A maior parte do trabalho de IA deve passar pelo chat do agente para que os usuários possam ver, orientar e auditar
|
|
@@ -125,6 +125,41 @@ export default defineEventHandler(() => ({
|
|
|
125
125
|
|
|
126
126
|
仅当您需要路由型协议或二进制/流行为时才使用自定义 `/api/*` 路由。参见[Actions](/docs/actions)。
|
|
127
127
|
|
|
128
|
+
### 仅 API 应用 {#api-only-apps}
|
|
129
|
+
|
|
130
|
+
应用仅提供 API 并不意味着需要 Express 服务器。Agent Native 应用已经自带 Nitro/H3 服务器,`defineAction()` 是默认的 API 表面。将操作定义在 `actions/` 中;框架会把每个 action 挂载到 `/_agent-native/actions/<name>`,并带有 schema 验证和请求上下文。
|
|
131
|
+
|
|
132
|
+
使用 action 的 `http` 选项来调整直接 HTTP 访问方式:actions 默认是 `POST`,`http: { method: "GET" | "PUT" | "DELETE" }` 会更改动词,`http: false` 会关闭该 action 的 HTTP 端点。只有在处理路由形状或协议问题时才使用 `server/routes/api/*`:文件上传、流式传输/SSE、webhooks、OAuth 回调、公共页面,或无法干净表示为 action 的外部 REST 形状。不要创建主要只是包装或重新导出 actions 的 `/api/*` 路由。
|
|
133
|
+
|
|
134
|
+
对于只读状态 endpoint,请保持为 action:
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
// actions/get-status.ts
|
|
138
|
+
import { defineAction } from "@agent-native/core/action";
|
|
139
|
+
import { z } from "zod";
|
|
140
|
+
|
|
141
|
+
export default defineAction({
|
|
142
|
+
description: "Return API service status",
|
|
143
|
+
schema: z.object({
|
|
144
|
+
service: z.string().optional(),
|
|
145
|
+
}),
|
|
146
|
+
http: { method: "GET" },
|
|
147
|
+
run: async ({ service }) => ({
|
|
148
|
+
ok: true,
|
|
149
|
+
service: service ?? "api",
|
|
150
|
+
checkedAt: new Date().toISOString(),
|
|
151
|
+
}),
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
直接通过 HTTP 调用:
|
|
156
|
+
|
|
157
|
+
```http
|
|
158
|
+
GET /_agent-native/actions/get-status?service=billing
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
对于 `POST` 和其他写入 actions,请将 JSON body 发送到相同的 action path。
|
|
162
|
+
|
|
128
163
|
## 一次性文本完成 {#complete-text}
|
|
129
164
|
|
|
130
165
|
大多数人工智能工作应通过代理聊天进行,以便用户可以查看、引导和审核
|
|
@@ -125,6 +125,41 @@ export default defineEventHandler(() => ({
|
|
|
125
125
|
|
|
126
126
|
僅當您需要路由型協議或二進制/流行為時才使用自訂 `/api/*` 路由。參見[Actions](/docs/actions)。
|
|
127
127
|
|
|
128
|
+
### 僅 API 應用程式 {#api-only-apps}
|
|
129
|
+
|
|
130
|
+
應用程式僅提供 API 並不表示需要 Express 伺服器。Agent Native 應用程式已經內建 Nitro/H3 伺服器,`defineAction()` 是預設的 API 表面。將操作定義在 `actions/` 中;框架會將每個 action 掛載到 `/_agent-native/actions/<name>`,並包含 schema 驗證和請求脈絡。
|
|
131
|
+
|
|
132
|
+
使用 action 的 `http` 選項來調整直接 HTTP 存取方式:actions 預設是 `POST`,`http: { method: "GET" | "PUT" | "DELETE" }` 會變更動詞,`http: false` 會關閉該 action 的 HTTP 端點。只有在處理路由形狀或協議問題時才使用 `server/routes/api/*`:檔案上傳、串流/SSE、webhooks、OAuth 回呼、公開頁面,或無法乾淨表示為 action 的外部 REST 形狀。不要建立主要只是包裝或重新匯出 actions 的 `/api/*` 路由。
|
|
133
|
+
|
|
134
|
+
對於唯讀狀態 endpoint,請保持為 action:
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
// actions/get-status.ts
|
|
138
|
+
import { defineAction } from "@agent-native/core/action";
|
|
139
|
+
import { z } from "zod";
|
|
140
|
+
|
|
141
|
+
export default defineAction({
|
|
142
|
+
description: "Return API service status",
|
|
143
|
+
schema: z.object({
|
|
144
|
+
service: z.string().optional(),
|
|
145
|
+
}),
|
|
146
|
+
http: { method: "GET" },
|
|
147
|
+
run: async ({ service }) => ({
|
|
148
|
+
ok: true,
|
|
149
|
+
service: service ?? "api",
|
|
150
|
+
checkedAt: new Date().toISOString(),
|
|
151
|
+
}),
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
直接透過 HTTP 呼叫:
|
|
156
|
+
|
|
157
|
+
```http
|
|
158
|
+
GET /_agent-native/actions/get-status?service=billing
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
對於 `POST` 和其他寫入 actions,請將 JSON body 傳送到相同的 action path。
|
|
162
|
+
|
|
128
163
|
## 一次性文字完成 {#complete-text}
|
|
129
164
|
|
|
130
165
|
大多數人工智慧工作應透過代理聊天進行,以便使用者可以檢視、引導和審核
|
|
@@ -129,6 +129,41 @@ If the UI and agent both need to do something, define an action instead of a cus
|
|
|
129
129
|
|
|
130
130
|
Use custom `/api/*` routes only when you need a route-shaped protocol or binary/streaming behavior. See [Actions](/docs/actions).
|
|
131
131
|
|
|
132
|
+
### API-Only Apps {#api-only-apps}
|
|
133
|
+
|
|
134
|
+
You do not need an Express server just because the app is API-only. An agent-native app already ships with a Nitro/H3 server, and `defineAction()` is the default API surface. Define operations in `actions/`; the framework mounts each action at `/_agent-native/actions/<name>` with schema validation and request context.
|
|
135
|
+
|
|
136
|
+
Use the action `http` option to shape direct HTTP access: actions are `POST` by default, `http: { method: "GET" | "PUT" | "DELETE" }` changes the verb, and `http: false` keeps an action off HTTP. Reach for `server/routes/api/*` only for route-shaped or protocol concerns: file uploads, streaming/SSE, webhooks, OAuth callbacks, public pages, or an external REST shape that cannot be represented cleanly as an action. Do not create `/api/*` routes that mostly wrap or re-export actions.
|
|
137
|
+
|
|
138
|
+
For a read-only status endpoint, keep it as an action:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
// actions/get-status.ts
|
|
142
|
+
import { defineAction } from "@agent-native/core/action";
|
|
143
|
+
import { z } from "zod";
|
|
144
|
+
|
|
145
|
+
export default defineAction({
|
|
146
|
+
description: "Return API service status",
|
|
147
|
+
schema: z.object({
|
|
148
|
+
service: z.string().optional(),
|
|
149
|
+
}),
|
|
150
|
+
http: { method: "GET" },
|
|
151
|
+
run: async ({ service }) => ({
|
|
152
|
+
ok: true,
|
|
153
|
+
service: service ?? "api",
|
|
154
|
+
checkedAt: new Date().toISOString(),
|
|
155
|
+
}),
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Call it directly over HTTP:
|
|
160
|
+
|
|
161
|
+
```http
|
|
162
|
+
GET /_agent-native/actions/get-status?service=billing
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
For `POST` and other write actions, send a JSON body to the same action path.
|
|
166
|
+
|
|
132
167
|
## One-Shot Text Completion {#complete-text}
|
|
133
168
|
|
|
134
169
|
Most AI work should go through the agent chat so users can see, steer, and audit
|
package/corpus/core/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/core",
|
|
3
|
-
"version": "0.92.
|
|
3
|
+
"version": "0.92.4",
|
|
4
4
|
"description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/agent-native#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -235,7 +235,7 @@
|
|
|
235
235
|
"prepublishOnly": "npm run build"
|
|
236
236
|
},
|
|
237
237
|
"dependencies": {
|
|
238
|
-
"@agent-native/toolkit": "workspace
|
|
238
|
+
"@agent-native/toolkit": "workspace:^",
|
|
239
239
|
"@amplitude/analytics-browser": "^2.41.1",
|
|
240
240
|
"@anthropic-ai/sdk": "^0.90.0",
|
|
241
241
|
"@anthropic-ai/tokenizer": "0.0.4",
|
|
@@ -401,21 +401,29 @@ class AISDKEngine implements AgentEngine {
|
|
|
401
401
|
// rather than keyword-matching the message string.
|
|
402
402
|
const statusCode: number | undefined =
|
|
403
403
|
typeof err?.statusCode === "number" ? err.statusCode : undefined;
|
|
404
|
+
const errorMessage = err?.message ?? String(err);
|
|
405
|
+
const isConnectionError =
|
|
406
|
+
statusCode === undefined &&
|
|
407
|
+
String(errorMessage).trim().toLowerCase() === "connection error.";
|
|
404
408
|
const providerRetryable: boolean | undefined =
|
|
405
|
-
typeof err?.isRetryable === "boolean"
|
|
409
|
+
typeof err?.isRetryable === "boolean"
|
|
410
|
+
? err.isRetryable
|
|
411
|
+
: isConnectionError
|
|
412
|
+
? true
|
|
413
|
+
: undefined;
|
|
406
414
|
if (statusCode === 401) {
|
|
407
415
|
await recordProviderCredentialAuthFailure({
|
|
408
416
|
key: PROVIDER_ENV_VARS[this.provider][0],
|
|
409
417
|
value: this.apiKey,
|
|
410
418
|
status: statusCode,
|
|
411
419
|
code: "http_401",
|
|
412
|
-
message:
|
|
420
|
+
message: errorMessage,
|
|
413
421
|
});
|
|
414
422
|
}
|
|
415
423
|
yield {
|
|
416
424
|
type: "stop",
|
|
417
425
|
reason: "error",
|
|
418
|
-
error:
|
|
426
|
+
error: errorMessage,
|
|
419
427
|
// Tag every known status with `http_<status>` (not just 401) so a
|
|
420
428
|
// rate limit surfaces as `http_429`. The structured statusCode
|
|
421
429
|
// already drives turn-level retries, but the run-level continuation
|
|
@@ -423,7 +431,9 @@ class AISDKEngine implements AgentEngine {
|
|
|
423
431
|
// auto-resume too — matching the Builder gateway path.
|
|
424
432
|
...(statusCode !== undefined
|
|
425
433
|
? { errorCode: `http_${statusCode}`, statusCode }
|
|
426
|
-
:
|
|
434
|
+
: isConnectionError
|
|
435
|
+
? { errorCode: "provider_network_error" }
|
|
436
|
+
: {}),
|
|
427
437
|
...(providerRetryable !== undefined ? { providerRetryable } : {}),
|
|
428
438
|
};
|
|
429
439
|
throw err;
|
|
@@ -232,19 +232,26 @@ class AnthropicEngine implements AgentEngine {
|
|
|
232
232
|
: typeof err?.statusCode === "number"
|
|
233
233
|
? err.statusCode
|
|
234
234
|
: undefined;
|
|
235
|
+
const errorMessage = err?.message ?? String(err);
|
|
236
|
+
// Anthropic SDK APIConnectionError defaults to "Connection error." with
|
|
237
|
+
// no HTTP status. Tag it so in-run retries and run-level resume treat
|
|
238
|
+
// the failure as a transient network interruption.
|
|
239
|
+
const isConnectionError =
|
|
240
|
+
statusCode === undefined &&
|
|
241
|
+
String(errorMessage).trim().toLowerCase() === "connection error.";
|
|
235
242
|
if (statusCode === 401) {
|
|
236
243
|
await recordProviderCredentialAuthFailure({
|
|
237
244
|
key: "ANTHROPIC_API_KEY",
|
|
238
245
|
value: this.apiKey,
|
|
239
246
|
status: statusCode,
|
|
240
247
|
code: "http_401",
|
|
241
|
-
message:
|
|
248
|
+
message: errorMessage,
|
|
242
249
|
});
|
|
243
250
|
}
|
|
244
251
|
yield {
|
|
245
252
|
type: "stop",
|
|
246
253
|
reason: "error",
|
|
247
|
-
error:
|
|
254
|
+
error: errorMessage,
|
|
248
255
|
// Forward the provider HTTP status for EVERY known status, not just
|
|
249
256
|
// 401. The Anthropic SDK reports empty-body failures as a bare
|
|
250
257
|
// "429 status code (no body)" message, so without a structured
|
|
@@ -255,7 +262,12 @@ class AnthropicEngine implements AgentEngine {
|
|
|
255
262
|
// continuation logic auto-resume a rate-limited turn.
|
|
256
263
|
...(statusCode !== undefined
|
|
257
264
|
? { errorCode: `http_${statusCode}`, statusCode }
|
|
258
|
-
:
|
|
265
|
+
: isConnectionError
|
|
266
|
+
? {
|
|
267
|
+
errorCode: "provider_network_error",
|
|
268
|
+
providerRetryable: true,
|
|
269
|
+
}
|
|
270
|
+
: {}),
|
|
259
271
|
};
|
|
260
272
|
throw err;
|
|
261
273
|
}
|