@alneas/eaos-server 0.0.0-stage → 0.2.0
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/CHANGELOG.md +41 -0
- package/LICENSE +21 -0
- package/README.ja.md +49 -0
- package/README.md +46 -2
- package/dist/agentic/agent-jobs.d.ts +333 -0
- package/dist/agentic/agent-jobs.js +15 -0
- package/dist/agentic/agent-jobs.js.map +1 -0
- package/dist/agentic/agent-node.d.ts +40 -0
- package/dist/agentic/agent-node.js +7 -0
- package/dist/agentic/agent-node.js.map +1 -0
- package/dist/agentic/agent-runner.d.ts +33 -0
- package/dist/agentic/agent-runner.js +7 -0
- package/dist/agentic/agent-runner.js.map +1 -0
- package/dist/agentic/ai-broker.d.ts +169 -0
- package/dist/agentic/ai-broker.js +8 -0
- package/dist/agentic/ai-broker.js.map +1 -0
- package/dist/agentic/atomic-checkpointer.d.ts +137 -0
- package/dist/agentic/atomic-checkpointer.js +9 -0
- package/dist/agentic/atomic-checkpointer.js.map +1 -0
- package/dist/agentic/autonomous-worker.d.ts +122 -0
- package/dist/agentic/autonomous-worker.js +10 -0
- package/dist/agentic/autonomous-worker.js.map +1 -0
- package/dist/agentic/event-bridge.d.ts +350 -0
- package/dist/agentic/event-bridge.js +9 -0
- package/dist/agentic/event-bridge.js.map +1 -0
- package/dist/agentic/executor.d.ts +91 -0
- package/dist/agentic/executor.js +12 -0
- package/dist/agentic/executor.js.map +1 -0
- package/dist/agentic/graph-projection.d.ts +119 -0
- package/dist/agentic/graph-projection.js +7 -0
- package/dist/agentic/graph-projection.js.map +1 -0
- package/dist/agentic/graph.d.ts +524 -0
- package/dist/agentic/graph.js +7 -0
- package/dist/agentic/graph.js.map +1 -0
- package/dist/agentic/index.d.ts +28 -0
- package/dist/agentic/index.js +87 -0
- package/dist/agentic/index.js.map +1 -0
- package/dist/agentic/local-runner.d.ts +106 -0
- package/dist/agentic/local-runner.js +7 -0
- package/dist/agentic/local-runner.js.map +1 -0
- package/dist/agentic/remote-executor.d.ts +67 -0
- package/dist/agentic/remote-executor.js +8 -0
- package/dist/agentic/remote-executor.js.map +1 -0
- package/dist/agentic/types.d.ts +157 -0
- package/dist/agentic/types.js +7 -0
- package/dist/agentic/types.js.map +1 -0
- package/dist/agentic/workflow-catalog.d.ts +152 -0
- package/dist/agentic/workflow-catalog.js +7 -0
- package/dist/agentic/workflow-catalog.js.map +1 -0
- package/dist/agentic/workflow-compiler.d.ts +44 -0
- package/dist/agentic/workflow-compiler.js +8 -0
- package/dist/agentic/workflow-compiler.js.map +1 -0
- package/dist/agentic/workflow-coordinator.d.ts +170 -0
- package/dist/agentic/workflow-coordinator.js +8 -0
- package/dist/agentic/workflow-coordinator.js.map +1 -0
- package/dist/agentic/workflow-manager.d.ts +91 -0
- package/dist/agentic/workflow-manager.js +7 -0
- package/dist/agentic/workflow-manager.js.map +1 -0
- package/dist/agentic/workflow-registry.d.ts +334 -0
- package/dist/agentic/workflow-registry.js +7 -0
- package/dist/agentic/workflow-registry.js.map +1 -0
- package/dist/artifacts-CteHmCMI.d.ts +614 -0
- package/dist/auth-hooks/api-key.d.ts +75 -0
- package/dist/auth-hooks/api-key.js +7 -0
- package/dist/auth-hooks/api-key.js.map +1 -0
- package/dist/auth-hooks/index.d.ts +80 -0
- package/dist/auth-hooks/index.js +28 -0
- package/dist/auth-hooks/index.js.map +1 -0
- package/dist/browser-auth/account-memberships.d.ts +213 -0
- package/dist/browser-auth/account-memberships.js +13 -0
- package/dist/browser-auth/account-memberships.js.map +1 -0
- package/dist/browser-auth/index.d.ts +8 -0
- package/dist/browser-auth/index.js +59 -0
- package/dist/browser-auth/index.js.map +1 -0
- package/dist/browser-auth/kratos-session.d.ts +37 -0
- package/dist/browser-auth/kratos-session.js +7 -0
- package/dist/browser-auth/kratos-session.js.map +1 -0
- package/dist/browser-auth/platform-session.d.ts +120 -0
- package/dist/browser-auth/platform-session.js +7 -0
- package/dist/browser-auth/platform-session.js.map +1 -0
- package/dist/browser-auth/public-memberships.d.ts +22 -0
- package/dist/browser-auth/public-memberships.js +7 -0
- package/dist/browser-auth/public-memberships.js.map +1 -0
- package/dist/cache/index.d.ts +181 -0
- package/dist/cache/index.js +197 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/chunk-32746UQZ.js +131 -0
- package/dist/chunk-32746UQZ.js.map +1 -0
- package/dist/chunk-3NLSWP2Y.js +223 -0
- package/dist/chunk-3NLSWP2Y.js.map +1 -0
- package/dist/chunk-3P4XTTQH.js +346 -0
- package/dist/chunk-3P4XTTQH.js.map +1 -0
- package/dist/chunk-3VITSHN3.js +15 -0
- package/dist/chunk-3VITSHN3.js.map +1 -0
- package/dist/chunk-46UWPEW2.js +226 -0
- package/dist/chunk-46UWPEW2.js.map +1 -0
- package/dist/chunk-4BARRLJR.js +180 -0
- package/dist/chunk-4BARRLJR.js.map +1 -0
- package/dist/chunk-4VORUFKR.js +45 -0
- package/dist/chunk-4VORUFKR.js.map +1 -0
- package/dist/chunk-55D4ERWO.js +1 -0
- package/dist/chunk-55D4ERWO.js.map +1 -0
- package/dist/chunk-5TBBZIND.js +18 -0
- package/dist/chunk-5TBBZIND.js.map +1 -0
- package/dist/chunk-5WOZWPZA.js +211 -0
- package/dist/chunk-5WOZWPZA.js.map +1 -0
- package/dist/chunk-6CBVZ6CT.js +168 -0
- package/dist/chunk-6CBVZ6CT.js.map +1 -0
- package/dist/chunk-6XZXYNJR.js +74 -0
- package/dist/chunk-6XZXYNJR.js.map +1 -0
- package/dist/chunk-753HWDSC.js +222 -0
- package/dist/chunk-753HWDSC.js.map +1 -0
- package/dist/chunk-7AHSS7SO.js +81 -0
- package/dist/chunk-7AHSS7SO.js.map +1 -0
- package/dist/chunk-7FTJN4SA.js +1 -0
- package/dist/chunk-7FTJN4SA.js.map +1 -0
- package/dist/chunk-AVDMLTPF.js +24 -0
- package/dist/chunk-AVDMLTPF.js.map +1 -0
- package/dist/chunk-BKAHUEIT.js +95 -0
- package/dist/chunk-BKAHUEIT.js.map +1 -0
- package/dist/chunk-CJ7OFEF7.js +134 -0
- package/dist/chunk-CJ7OFEF7.js.map +1 -0
- package/dist/chunk-EJKWDZIU.js +111 -0
- package/dist/chunk-EJKWDZIU.js.map +1 -0
- package/dist/chunk-F2J6IQ6I.js +247 -0
- package/dist/chunk-F2J6IQ6I.js.map +1 -0
- package/dist/chunk-F3O7CELI.js +23 -0
- package/dist/chunk-F3O7CELI.js.map +1 -0
- package/dist/chunk-F4IITPGX.js +221 -0
- package/dist/chunk-F4IITPGX.js.map +1 -0
- package/dist/chunk-FD6VC2NA.js +66 -0
- package/dist/chunk-FD6VC2NA.js.map +1 -0
- package/dist/chunk-FRRRWAHO.js +14 -0
- package/dist/chunk-FRRRWAHO.js.map +1 -0
- package/dist/chunk-HCKAGLLB.js +17 -0
- package/dist/chunk-HCKAGLLB.js.map +1 -0
- package/dist/chunk-HVC7FG6B.js +191 -0
- package/dist/chunk-HVC7FG6B.js.map +1 -0
- package/dist/chunk-HXFVOR7Z.js +496 -0
- package/dist/chunk-HXFVOR7Z.js.map +1 -0
- package/dist/chunk-IJWYS2PF.js +122 -0
- package/dist/chunk-IJWYS2PF.js.map +1 -0
- package/dist/chunk-INCHXAFK.js +1395 -0
- package/dist/chunk-INCHXAFK.js.map +1 -0
- package/dist/chunk-JT6BRGQM.js +1 -0
- package/dist/chunk-JT6BRGQM.js.map +1 -0
- package/dist/chunk-L6PMAEMB.js +115 -0
- package/dist/chunk-L6PMAEMB.js.map +1 -0
- package/dist/chunk-LOUGW6MU.js +126 -0
- package/dist/chunk-LOUGW6MU.js.map +1 -0
- package/dist/chunk-LYPZPE53.js +129 -0
- package/dist/chunk-LYPZPE53.js.map +1 -0
- package/dist/chunk-NNCCN7JP.js +186 -0
- package/dist/chunk-NNCCN7JP.js.map +1 -0
- package/dist/chunk-PBC3MZUL.js +212 -0
- package/dist/chunk-PBC3MZUL.js.map +1 -0
- package/dist/chunk-R4ADP2DC.js +20 -0
- package/dist/chunk-R4ADP2DC.js.map +1 -0
- package/dist/chunk-RHN4Y6VS.js +44 -0
- package/dist/chunk-RHN4Y6VS.js.map +1 -0
- package/dist/chunk-SDJNYPYK.js +770 -0
- package/dist/chunk-SDJNYPYK.js.map +1 -0
- package/dist/chunk-UGNTCOVR.js +28 -0
- package/dist/chunk-UGNTCOVR.js.map +1 -0
- package/dist/chunk-VC2PCK2S.js +31 -0
- package/dist/chunk-VC2PCK2S.js.map +1 -0
- package/dist/chunk-VF5YDZJC.js +305 -0
- package/dist/chunk-VF5YDZJC.js.map +1 -0
- package/dist/chunk-VISRDVTK.js +675 -0
- package/dist/chunk-VISRDVTK.js.map +1 -0
- package/dist/chunk-W6O3LVBY.js +102 -0
- package/dist/chunk-W6O3LVBY.js.map +1 -0
- package/dist/chunk-WFEAKJLR.js +47 -0
- package/dist/chunk-WFEAKJLR.js.map +1 -0
- package/dist/chunk-XIEY2OF4.js +67 -0
- package/dist/chunk-XIEY2OF4.js.map +1 -0
- package/dist/chunk-XITLHDG3.js +37 -0
- package/dist/chunk-XITLHDG3.js.map +1 -0
- package/dist/chunk-XMWPYZWZ.js +61 -0
- package/dist/chunk-XMWPYZWZ.js.map +1 -0
- package/dist/chunk-XUP6CNOM.js +34 -0
- package/dist/chunk-XUP6CNOM.js.map +1 -0
- package/dist/chunk-YABTQZDJ.js +25 -0
- package/dist/chunk-YABTQZDJ.js.map +1 -0
- package/dist/chunk-YMHVRBUU.js +199 -0
- package/dist/chunk-YMHVRBUU.js.map +1 -0
- package/dist/chunk-YMJ7BRKU.js +510 -0
- package/dist/chunk-YMJ7BRKU.js.map +1 -0
- package/dist/chunk-ZC3XWU7B.js +28 -0
- package/dist/chunk-ZC3XWU7B.js.map +1 -0
- package/dist/chunk-ZHMTD5KV.js +90 -0
- package/dist/chunk-ZHMTD5KV.js.map +1 -0
- package/dist/chunk-ZWZDLOE7.js +160 -0
- package/dist/chunk-ZWZDLOE7.js.map +1 -0
- package/dist/db-package/db/local-first-sqlite-adapter.d.ts +432 -0
- package/dist/db-package/db/local-first-sqlite-adapter.js +7 -0
- package/dist/db-package/db/local-first-sqlite-adapter.js.map +1 -0
- package/dist/db-package/index.d.ts +7 -0
- package/dist/db-package/index.js +16 -0
- package/dist/db-package/index.js.map +1 -0
- package/dist/db-package/migration/aggregator.d.ts +86 -0
- package/dist/db-package/migration/aggregator.js +7 -0
- package/dist/db-package/migration/aggregator.js.map +1 -0
- package/dist/db-package/migration/index.d.ts +3 -0
- package/dist/db-package/migration/index.js +8 -0
- package/dist/db-package/migration/index.js.map +1 -0
- package/dist/engine.d.ts +205 -0
- package/dist/engine.js +20 -0
- package/dist/engine.js.map +1 -0
- package/dist/entitlements/index.d.ts +313 -0
- package/dist/entitlements/index.js +23 -0
- package/dist/entitlements/index.js.map +1 -0
- package/dist/execution/chat.d.ts +7 -0
- package/dist/execution/chat.js +7 -0
- package/dist/execution/chat.js.map +1 -0
- package/dist/execution/index.d.ts +342 -0
- package/dist/execution/index.js +66 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/execution/tool-agent.d.ts +7 -0
- package/dist/execution/tool-agent.js +8 -0
- package/dist/execution/tool-agent.js.map +1 -0
- package/dist/extensions/index.d.ts +172 -0
- package/dist/extensions/index.js +95 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/health/index.d.ts +35 -0
- package/dist/health/index.js +7 -0
- package/dist/health/index.js.map +1 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +161 -0
- package/dist/index.js.map +1 -0
- package/dist/lifecycle/index.d.ts +133 -0
- package/dist/lifecycle/index.js +13 -0
- package/dist/lifecycle/index.js.map +1 -0
- package/dist/lifecycle-engine/backend-migration.d.ts +2 -0
- package/dist/lifecycle-engine/backend-migration.js +11 -0
- package/dist/lifecycle-engine/backend-migration.js.map +1 -0
- package/dist/lifecycle-engine/baseline.d.ts +2 -0
- package/dist/lifecycle-engine/baseline.js +9 -0
- package/dist/lifecycle-engine/baseline.js.map +1 -0
- package/dist/lifecycle-engine/index.d.ts +1497 -0
- package/dist/lifecycle-engine/index.js +41 -0
- package/dist/lifecycle-engine/index.js.map +1 -0
- package/dist/lifecycle-engine/platform/artifacts.d.ts +4 -0
- package/dist/lifecycle-engine/platform/artifacts.js +7 -0
- package/dist/lifecycle-engine/platform/artifacts.js.map +1 -0
- package/dist/lifecycle-engine/platform/control-plane.d.ts +12 -0
- package/dist/lifecycle-engine/platform/control-plane.js +2 -0
- package/dist/lifecycle-engine/platform/control-plane.js.map +1 -0
- package/dist/lifecycle-engine/platform/database-router.d.ts +118 -0
- package/dist/lifecycle-engine/platform/database-router.js +7 -0
- package/dist/lifecycle-engine/platform/database-router.js.map +1 -0
- package/dist/lifecycle-engine/platform/deployment-placements.d.ts +464 -0
- package/dist/lifecycle-engine/platform/deployment-placements.js +16 -0
- package/dist/lifecycle-engine/platform/deployment-placements.js.map +1 -0
- package/dist/lifecycle-engine/platform/deployment.d.ts +4 -0
- package/dist/lifecycle-engine/platform/deployment.js +17 -0
- package/dist/lifecycle-engine/platform/deployment.js.map +1 -0
- package/dist/lifecycle-engine/platform/index.d.ts +737 -0
- package/dist/lifecycle-engine/platform/index.js +60 -0
- package/dist/lifecycle-engine/platform/index.js.map +1 -0
- package/dist/lifecycle-engine/platform/runtime.d.ts +80 -0
- package/dist/lifecycle-engine/platform/runtime.js +11 -0
- package/dist/lifecycle-engine/platform/runtime.js.map +1 -0
- package/dist/lifecycle-engine/platform/site-publication.d.ts +102 -0
- package/dist/lifecycle-engine/platform/site-publication.js +7 -0
- package/dist/lifecycle-engine/platform/site-publication.js.map +1 -0
- package/dist/lifecycle-engine/platform/user-directory.d.ts +139 -0
- package/dist/lifecycle-engine/platform/user-directory.js +13 -0
- package/dist/lifecycle-engine/platform/user-directory.js.map +1 -0
- package/dist/mcp.d.ts +92 -0
- package/dist/mcp.js +10 -0
- package/dist/mcp.js.map +1 -0
- package/dist/middleware/auth.d.ts +118 -0
- package/dist/middleware/auth.js +7 -0
- package/dist/middleware/auth.js.map +1 -0
- package/dist/middleware/error-handler.d.ts +35 -0
- package/dist/middleware/error-handler.js +7 -0
- package/dist/middleware/error-handler.js.map +1 -0
- package/dist/middleware/module-guard.d.ts +33 -0
- package/dist/middleware/module-guard.js +7 -0
- package/dist/middleware/module-guard.js.map +1 -0
- package/dist/platform-admin/index.d.ts +37 -0
- package/dist/platform-admin/index.js +11 -0
- package/dist/platform-admin/index.js.map +1 -0
- package/dist/platform-admin/store.d.ts +346 -0
- package/dist/platform-admin/store.js +7 -0
- package/dist/platform-admin/store.js.map +1 -0
- package/dist/plugin-data/annotations.d.ts +6 -0
- package/dist/plugin-data/annotations.js +12 -0
- package/dist/plugin-data/annotations.js.map +1 -0
- package/dist/plugin-data/atomic-context.d.ts +41 -0
- package/dist/plugin-data/atomic-context.js +9 -0
- package/dist/plugin-data/atomic-context.js.map +1 -0
- package/dist/plugin-data/atomic.d.ts +6 -0
- package/dist/plugin-data/atomic.js +26 -0
- package/dist/plugin-data/atomic.js.map +1 -0
- package/dist/plugin-data/audit.d.ts +6 -0
- package/dist/plugin-data/audit.js +12 -0
- package/dist/plugin-data/audit.js.map +1 -0
- package/dist/plugin-data/commands.d.ts +6 -0
- package/dist/plugin-data/commands.js +8 -0
- package/dist/plugin-data/commands.js.map +1 -0
- package/dist/plugin-data/composite.d.ts +6 -0
- package/dist/plugin-data/composite.js +8 -0
- package/dist/plugin-data/composite.js.map +1 -0
- package/dist/plugin-data/delivery.d.ts +6 -0
- package/dist/plugin-data/delivery.js +16 -0
- package/dist/plugin-data/delivery.js.map +1 -0
- package/dist/plugin-data/index.d.ts +2798 -0
- package/dist/plugin-data/index.js +102 -0
- package/dist/plugin-data/index.js.map +1 -0
- package/dist/plugin-data/json-documents.d.ts +6 -0
- package/dist/plugin-data/json-documents.js +16 -0
- package/dist/plugin-data/json-documents.js.map +1 -0
- package/dist/plugin-data/outbox.d.ts +6 -0
- package/dist/plugin-data/outbox.js +16 -0
- package/dist/plugin-data/outbox.js.map +1 -0
- package/dist/plugin-data/scoped-records.d.ts +6 -0
- package/dist/plugin-data/scoped-records.js +10 -0
- package/dist/plugin-data/scoped-records.js.map +1 -0
- package/dist/plugin-sdk.d.ts +41 -0
- package/dist/plugin-sdk.js +10 -0
- package/dist/plugin-sdk.js.map +1 -0
- package/dist/sql-lifecycle/index.d.ts +138 -0
- package/dist/sql-lifecycle/index.js +167 -0
- package/dist/sql-lifecycle/index.js.map +1 -0
- package/dist/storage/index.d.ts +2 -0
- package/dist/storage/index.js +13 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/s3-compatible.d.ts +139 -0
- package/dist/storage/s3-compatible.js +11 -0
- package/dist/storage/s3-compatible.js.map +1 -0
- package/dist/tenant.d.ts +108 -0
- package/dist/tenant.js +9 -0
- package/dist/tenant.js.map +1 -0
- package/dist/workspace-context.d.ts +119 -0
- package/dist/workspace-context.js +9 -0
- package/dist/workspace-context.js.map +1 -0
- package/docs/api.md +30560 -0
- package/docs/db/README.md +49 -0
- package/docs/db/docs/api.md +1613 -0
- package/docs/db/docs/guide.md +47 -0
- package/docs/entitlements.md +60 -0
- package/docs/guide.md +92 -0
- package/docs/index.md +57 -0
- package/docs/ja/db/README.md +46 -0
- package/docs/ja/db/docs/guide.md +53 -0
- package/docs/ja/guide.md +46 -0
- package/docs/ja/lifecycle/README.md +46 -0
- package/docs/ja/lifecycle/docs/guide.md +45 -0
- package/docs/ja/storage/README.md +46 -0
- package/docs/ja/storage/docs/guide.md +43 -0
- package/docs/lifecycle/README.md +49 -0
- package/docs/lifecycle/docs/api.md +3770 -0
- package/docs/lifecycle/docs/baseline.md +50 -0
- package/docs/lifecycle/docs/guide.md +47 -0
- package/docs/storage/README.md +49 -0
- package/docs/storage/docs/api.md +470 -0
- package/docs/storage/docs/guide.md +47 -0
- package/package.json +354 -4
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ServerAgentExecutionError
|
|
3
|
+
} from "./chunk-YABTQZDJ.js";
|
|
4
|
+
|
|
5
|
+
// src/agentic/remote-executor.ts
|
|
6
|
+
var failureCodes = /* @__PURE__ */ new Set([
|
|
7
|
+
"AGENT_UNAVAILABLE",
|
|
8
|
+
"TIMEOUT",
|
|
9
|
+
"OUTPUT_LIMIT",
|
|
10
|
+
"RUNTIME_FAILED",
|
|
11
|
+
"INVALID_PROPOSAL"
|
|
12
|
+
]);
|
|
13
|
+
function assertEndpoint(value) {
|
|
14
|
+
const url = new URL(value);
|
|
15
|
+
const local = url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
|
|
16
|
+
if (!["https:", "http:"].includes(url.protocol) || url.protocol === "http:" && !local || url.username || url.password || url.hash) {
|
|
17
|
+
throw new Error("HTTPS agent runtime endpoint required");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function failureCode(value) {
|
|
21
|
+
return typeof value === "string" && failureCodes.has(value) ? value : void 0;
|
|
22
|
+
}
|
|
23
|
+
function retryable(value) {
|
|
24
|
+
return typeof value === "boolean" ? value : void 0;
|
|
25
|
+
}
|
|
26
|
+
async function readJson(response, maxBytes) {
|
|
27
|
+
const contentLength = Number(response.headers.get("content-length"));
|
|
28
|
+
if (Number.isFinite(contentLength) && contentLength > maxBytes) throw new ServerAgentExecutionError("Agent runtime response exceeds configured limit", "OUTPUT_LIMIT", false);
|
|
29
|
+
const reader = response.body?.getReader();
|
|
30
|
+
if (!reader) {
|
|
31
|
+
const text = await response.text();
|
|
32
|
+
if (Buffer.byteLength(text) > maxBytes) throw new ServerAgentExecutionError("Agent runtime response exceeds configured limit", "OUTPUT_LIMIT", false);
|
|
33
|
+
try {
|
|
34
|
+
return JSON.parse(text);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
throw new ServerAgentExecutionError("Agent runtime returned invalid JSON", "RUNTIME_FAILED", false, { cause: error });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const chunks = [];
|
|
40
|
+
let length = 0;
|
|
41
|
+
try {
|
|
42
|
+
for (; ; ) {
|
|
43
|
+
const next = await reader.read();
|
|
44
|
+
if (next.done) break;
|
|
45
|
+
length += next.value.byteLength;
|
|
46
|
+
if (length > maxBytes) {
|
|
47
|
+
await reader.cancel();
|
|
48
|
+
throw new ServerAgentExecutionError("Agent runtime response exceeds configured limit", "OUTPUT_LIMIT", false);
|
|
49
|
+
}
|
|
50
|
+
chunks.push(next.value);
|
|
51
|
+
}
|
|
52
|
+
} finally {
|
|
53
|
+
reader.releaseLock();
|
|
54
|
+
}
|
|
55
|
+
const bytes = new Uint8Array(length);
|
|
56
|
+
let offset = 0;
|
|
57
|
+
for (const chunk of chunks) {
|
|
58
|
+
bytes.set(chunk, offset);
|
|
59
|
+
offset += chunk.byteLength;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
return JSON.parse(new TextDecoder().decode(bytes));
|
|
63
|
+
} catch (error) {
|
|
64
|
+
throw new ServerAgentExecutionError("Agent runtime returned invalid JSON", "RUNTIME_FAILED", false, { cause: error });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function transportFailure(status) {
|
|
68
|
+
const retry = status === 408 || status === 425 || status === 429 || status >= 500;
|
|
69
|
+
return new ServerAgentExecutionError(`Agent runtime request failed (${status})`, retry ? "AGENT_UNAVAILABLE" : "RUNTIME_FAILED", retry);
|
|
70
|
+
}
|
|
71
|
+
function createHttpAgentExecutor(options) {
|
|
72
|
+
if (!options || typeof options.url !== "string" || !options.url.trim()) throw new Error("Agent runtime URL is required");
|
|
73
|
+
assertEndpoint(options.url);
|
|
74
|
+
const timeoutMs = options.timeoutMs ?? 6e4;
|
|
75
|
+
const maxResponseBytes = options.maxResponseBytes ?? 8 * 1024 * 1024;
|
|
76
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 36e5 || !Number.isSafeInteger(maxResponseBytes) || maxResponseBytes < 1 || maxResponseBytes > 128 * 1024 * 1024) throw new Error("Invalid HTTP agent executor limits");
|
|
77
|
+
const request = options.fetch ?? fetch;
|
|
78
|
+
return async (task) => {
|
|
79
|
+
const taskTimeoutMs = task.timeoutMs ?? timeoutMs;
|
|
80
|
+
if (!Number.isSafeInteger(taskTimeoutMs) || taskTimeoutMs < 1 || taskTimeoutMs > 36e5) throw new ServerAgentExecutionError("Invalid agent runtime timeout", "RUNTIME_FAILED", false);
|
|
81
|
+
const body = { protocolVersion: "1.0", task: structuredClone(task) };
|
|
82
|
+
let response;
|
|
83
|
+
try {
|
|
84
|
+
response = await request(options.url, {
|
|
85
|
+
method: "POST",
|
|
86
|
+
headers: { ...options.headers, "Content-Type": "application/json" },
|
|
87
|
+
body: JSON.stringify(body),
|
|
88
|
+
signal: AbortSignal.timeout(taskTimeoutMs),
|
|
89
|
+
redirect: "error",
|
|
90
|
+
credentials: "omit"
|
|
91
|
+
});
|
|
92
|
+
} catch (error) {
|
|
93
|
+
if (error instanceof Error && error.name === "TimeoutError") throw new ServerAgentExecutionError("Agent runtime request timed out", "TIMEOUT", true, { cause: error });
|
|
94
|
+
throw new ServerAgentExecutionError("Agent runtime is unavailable", "AGENT_UNAVAILABLE", true, { cause: error });
|
|
95
|
+
}
|
|
96
|
+
if (!response.ok) {
|
|
97
|
+
await response.body?.cancel();
|
|
98
|
+
throw transportFailure(response.status);
|
|
99
|
+
}
|
|
100
|
+
let value;
|
|
101
|
+
try {
|
|
102
|
+
value = await readJson(response, maxResponseBytes);
|
|
103
|
+
} catch (error) {
|
|
104
|
+
if (error instanceof ServerAgentExecutionError) throw error;
|
|
105
|
+
throw new ServerAgentExecutionError("Agent runtime response could not be read", "AGENT_UNAVAILABLE", true, { cause: error });
|
|
106
|
+
}
|
|
107
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new ServerAgentExecutionError("Agent runtime returned an invalid response", "RUNTIME_FAILED", false);
|
|
108
|
+
const result = value;
|
|
109
|
+
if (result.protocolVersion !== "1.0" || result.taskId !== task.id || result.status !== "COMPLETED" && result.status !== "FAILED") throw new ServerAgentExecutionError("Agent runtime response contract mismatch", "RUNTIME_FAILED", false);
|
|
110
|
+
if (result.status === "FAILED") {
|
|
111
|
+
const code = failureCode(result.failureCode) ?? "RUNTIME_FAILED";
|
|
112
|
+
throw new ServerAgentExecutionError(typeof result.error === "string" && result.error.trim() ? result.error : "Agent runtime failed", code, retryable(result.retryable) ?? (code === "AGENT_UNAVAILABLE" || code === "TIMEOUT" || code === "RUNTIME_FAILED"));
|
|
113
|
+
}
|
|
114
|
+
if (typeof result.output !== "string") throw new ServerAgentExecutionError("Agent runtime completed without output", "RUNTIME_FAILED", false);
|
|
115
|
+
return result.output;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export {
|
|
120
|
+
createHttpAgentExecutor
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=chunk-IJWYS2PF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/agentic/remote-executor.ts"],"sourcesContent":["import type { WorkflowAgentFailureCode } from '@alneas/eaos-core'\nimport { ServerAgentExecutionError, type ServerAgentExecutor, type ServerAgentTaskRequest } from './types'\n\n/**\n * Versioned JSON envelope POSTed by {@link createHttpAgentExecutor}.\n */\nexport interface HttpAgentRuntimeRequest {\n /** Wire protocol version; must be 1.0. */\n protocolVersion: '1.0'\n /** Cloned host-admitted task to execute. */\n task: ServerAgentTaskRequest\n}\n\n/**\n * Runtime reply validated by {@link createHttpAgentExecutor}; failed replies are converted to execution errors.\n */\nexport interface HttpAgentRuntimeResponse {\n /** Wire protocol version; must match 1.0. */\n protocolVersion: '1.0'\n /** Must match the submitted task ID. */\n taskId: string\n /** COMPLETED requires string output; FAILED is converted to a rejected execution. */\n status: 'COMPLETED' | 'FAILED'\n /** Required string result for COMPLETED replies; ignored on FAILED. */\n output?: string\n /** Optional failure description; a blank/missing value uses a generic message. */\n error?: string\n /** Optional recognized classification; unrecognized values become RUNTIME_FAILED. */\n failureCode?: WorkflowAgentFailureCode\n /** Optional retry advice on failures; otherwise unavailable/timeout/runtime failure default to retryable. */\n retryable?: boolean\n}\n\n/**\n * Trusted endpoint, credentials, transport, and limits for {@link createHttpAgentExecutor}.\n */\nexport interface HttpAgentExecutorOptions {\n /** Private host or ARM runtime endpoint. Credentials must be host-configured. */\n url: string\n /** Host-configured headers, including any runtime credentials; Content-Type is always application/json. */\n headers?: Record<string, string>\n /** Default timeout in milliseconds, safe integer 1–3600000; task.timeoutMs overrides this. @defaultValue 60000 */\n timeoutMs?: number\n /** Maximum response bytes, safe integer 1–134217728; content length and streaming bytes are checked. @defaultValue 8388608 */\n maxResponseBytes?: number\n /** Host transport implementation; defaults to global fetch. */\n fetch?: typeof fetch\n}\n\nconst failureCodes = new Set<WorkflowAgentFailureCode>([\n 'AGENT_UNAVAILABLE',\n 'TIMEOUT',\n 'OUTPUT_LIMIT',\n 'RUNTIME_FAILED',\n 'INVALID_PROPOSAL',\n])\n\nfunction assertEndpoint(value: string): void {\n const url = new URL(value)\n const local = url.protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname)\n if ((!['https:', 'http:'].includes(url.protocol) || (url.protocol === 'http:' && !local)) || url.username || url.password || url.hash) {\n throw new Error('HTTPS agent runtime endpoint required')\n }\n}\n\nfunction failureCode(value: unknown): WorkflowAgentFailureCode | undefined {\n return typeof value === 'string' && failureCodes.has(value as WorkflowAgentFailureCode) ? value as WorkflowAgentFailureCode : undefined\n}\n\nfunction retryable(value: unknown): boolean | undefined {\n return typeof value === 'boolean' ? value : undefined\n}\n\nasync function readJson(response: Response, maxBytes: number): Promise<unknown> {\n const contentLength = Number(response.headers.get('content-length'))\n if (Number.isFinite(contentLength) && contentLength > maxBytes) throw new ServerAgentExecutionError('Agent runtime response exceeds configured limit', 'OUTPUT_LIMIT', false)\n const reader = response.body?.getReader()\n if (!reader) {\n const text = await response.text()\n if (Buffer.byteLength(text) > maxBytes) throw new ServerAgentExecutionError('Agent runtime response exceeds configured limit', 'OUTPUT_LIMIT', false)\n try {\n return JSON.parse(text) as unknown\n } catch (error) {\n throw new ServerAgentExecutionError('Agent runtime returned invalid JSON', 'RUNTIME_FAILED', false, { cause: error })\n }\n }\n const chunks: Uint8Array[] = []\n let length = 0\n try {\n for (;;) {\n const next = await reader.read()\n if (next.done) break\n length += next.value.byteLength\n if (length > maxBytes) {\n await reader.cancel()\n throw new ServerAgentExecutionError('Agent runtime response exceeds configured limit', 'OUTPUT_LIMIT', false)\n }\n chunks.push(next.value)\n }\n } finally {\n reader.releaseLock()\n }\n const bytes = new Uint8Array(length)\n let offset = 0\n for (const chunk of chunks) {\n bytes.set(chunk, offset)\n offset += chunk.byteLength\n }\n try {\n return JSON.parse(new TextDecoder().decode(bytes)) as unknown\n } catch (error) {\n throw new ServerAgentExecutionError('Agent runtime returned invalid JSON', 'RUNTIME_FAILED', false, { cause: error })\n }\n}\n\nfunction transportFailure(status: number): ServerAgentExecutionError {\n const retry = status === 408 || status === 425 || status === 429 || status >= 500\n return new ServerAgentExecutionError(`Agent runtime request failed (${status})`, retry ? 'AGENT_UNAVAILABLE' : 'RUNTIME_FAILED', retry)\n}\n\n/**\n * Creates the standard private HTTP boundary from application-worker to an\n * ARM/remote agent runtime. The runtime returns text only; workflow proposal\n * parsing and all business side effects stay in EAOS/server/plugin code.\n * @param options - Trusted endpoint, headers, fetch implementation, and limits.\n * @returns An executor resolving runtime output text after checking protocolVersion, taskId, status, and output type.\n * @throws Synchronously for missing/invalid endpoint or limits. Invocations reject with ServerAgentExecutionError for transport, timeout, HTTP status, output size, JSON/contract errors, or reported runtime failure; clone/serialization errors can also reject.\n * @remarks HTTPS is required except localhost/127.0.0.1/IPv6 loopback HTTP; URL credentials and fragments are rejected. Each task uses one POST with redirects disabled, cookies omitted, and an AbortSignal timeout. No retries or business authorization occur here. Remote side effects may have happened before transport failure; the host must define safe idempotency before retrying. Response readers are released and oversized streams are cancelled.\n * @example\n * ```typescript\n * import { createHttpAgentExecutor, type HttpAgentExecutorOptions } from \"@alneas/eaos-server/agentic/remote-executor\";\n * export function remoteExecutor(hostConfiguration: HttpAgentExecutorOptions) {\n * // Provision/authenticate the runtime separately and keep its headers server-side.\n * return createHttpAgentExecutor(hostConfiguration);\n * }\n * ```\n */\nexport function createHttpAgentExecutor(options: HttpAgentExecutorOptions): ServerAgentExecutor {\n if (!options || typeof options.url !== 'string' || !options.url.trim()) throw new Error('Agent runtime URL is required')\n assertEndpoint(options.url)\n const timeoutMs = options.timeoutMs ?? 60_000\n const maxResponseBytes = options.maxResponseBytes ?? 8 * 1024 * 1024\n if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 3_600_000 || !Number.isSafeInteger(maxResponseBytes) || maxResponseBytes < 1 || maxResponseBytes > 128 * 1024 * 1024) throw new Error('Invalid HTTP agent executor limits')\n const request = options.fetch ?? fetch\n\n return async task => {\n const taskTimeoutMs = task.timeoutMs ?? timeoutMs\n if (!Number.isSafeInteger(taskTimeoutMs) || taskTimeoutMs < 1 || taskTimeoutMs > 3_600_000) throw new ServerAgentExecutionError('Invalid agent runtime timeout', 'RUNTIME_FAILED', false)\n const body: HttpAgentRuntimeRequest = { protocolVersion: '1.0', task: structuredClone(task) }\n let response: Response\n try {\n response = await request(options.url, {\n method: 'POST',\n headers: { ...options.headers, 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(taskTimeoutMs),\n redirect: 'error',\n credentials: 'omit',\n })\n } catch (error) {\n if (error instanceof Error && error.name === 'TimeoutError') throw new ServerAgentExecutionError('Agent runtime request timed out', 'TIMEOUT', true, { cause: error })\n throw new ServerAgentExecutionError('Agent runtime is unavailable', 'AGENT_UNAVAILABLE', true, { cause: error })\n }\n if (!response.ok) {\n await response.body?.cancel()\n throw transportFailure(response.status)\n }\n\n let value: unknown\n try {\n value = await readJson(response, maxResponseBytes)\n } catch (error) {\n if (error instanceof ServerAgentExecutionError) throw error\n throw new ServerAgentExecutionError('Agent runtime response could not be read', 'AGENT_UNAVAILABLE', true, { cause: error })\n }\n if (!value || typeof value !== 'object' || Array.isArray(value)) throw new ServerAgentExecutionError('Agent runtime returned an invalid response', 'RUNTIME_FAILED', false)\n const result = value as Partial<HttpAgentRuntimeResponse>\n if (result.protocolVersion !== '1.0' || result.taskId !== task.id || (result.status !== 'COMPLETED' && result.status !== 'FAILED')) throw new ServerAgentExecutionError('Agent runtime response contract mismatch', 'RUNTIME_FAILED', false)\n if (result.status === 'FAILED') {\n const code = failureCode(result.failureCode) ?? 'RUNTIME_FAILED'\n throw new ServerAgentExecutionError(typeof result.error === 'string' && result.error.trim() ? result.error : 'Agent runtime failed', code, retryable(result.retryable) ?? (code === 'AGENT_UNAVAILABLE' || code === 'TIMEOUT' || code === 'RUNTIME_FAILED'))\n }\n if (typeof result.output !== 'string') throw new ServerAgentExecutionError('Agent runtime completed without output', 'RUNTIME_FAILED', false)\n return result.output\n }\n}\n"],"mappings":";;;;;AAiDA,IAAM,eAAe,oBAAI,IAA8B;AAAA,EACrD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,SAAS,eAAe,OAAqB;AAC3C,QAAM,MAAM,IAAI,IAAI,KAAK;AACzB,QAAM,QAAQ,IAAI,aAAa,WAAW,CAAC,aAAa,aAAa,OAAO,EAAE,SAAS,IAAI,QAAQ;AACnG,MAAK,CAAC,CAAC,UAAU,OAAO,EAAE,SAAS,IAAI,QAAQ,KAAM,IAAI,aAAa,WAAW,CAAC,SAAW,IAAI,YAAY,IAAI,YAAY,IAAI,MAAM;AACrI,UAAM,IAAI,MAAM,uCAAuC;AAAA,EACzD;AACF;AAEA,SAAS,YAAY,OAAsD;AACzE,SAAO,OAAO,UAAU,YAAY,aAAa,IAAI,KAAiC,IAAI,QAAoC;AAChI;AAEA,SAAS,UAAU,OAAqC;AACtD,SAAO,OAAO,UAAU,YAAY,QAAQ;AAC9C;AAEA,eAAe,SAAS,UAAoB,UAAoC;AAC9E,QAAM,gBAAgB,OAAO,SAAS,QAAQ,IAAI,gBAAgB,CAAC;AACnE,M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