@aigne/aos 0.2.0-beta
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 +49 -0
- package/LICENSE.md +26 -0
- package/dist/agent-dsl.cjs +116 -0
- package/dist/agent-dsl.d.cts +31 -0
- package/dist/agent-dsl.d.cts.map +1 -0
- package/dist/agent-dsl.d.mts +31 -0
- package/dist/agent-dsl.d.mts.map +1 -0
- package/dist/agent-dsl.mjs +115 -0
- package/dist/agent-dsl.mjs.map +1 -0
- package/dist/arc-compat.cjs +125 -0
- package/dist/arc-compat.d.cts +17 -0
- package/dist/arc-compat.d.cts.map +1 -0
- package/dist/arc-compat.d.mts +17 -0
- package/dist/arc-compat.d.mts.map +1 -0
- package/dist/arc-compat.mjs +123 -0
- package/dist/arc-compat.mjs.map +1 -0
- package/dist/auto-surface/compiler.cjs +36 -0
- package/dist/auto-surface/compiler.d.cts +7 -0
- package/dist/auto-surface/compiler.d.cts.map +1 -0
- package/dist/auto-surface/compiler.d.mts +7 -0
- package/dist/auto-surface/compiler.d.mts.map +1 -0
- package/dist/auto-surface/compiler.mjs +37 -0
- package/dist/auto-surface/compiler.mjs.map +1 -0
- package/dist/auto-surface/definition-dsl.cjs +333 -0
- package/dist/auto-surface/definition-dsl.d.cts +41 -0
- package/dist/auto-surface/definition-dsl.d.cts.map +1 -0
- package/dist/auto-surface/definition-dsl.d.mts +41 -0
- package/dist/auto-surface/definition-dsl.d.mts.map +1 -0
- package/dist/auto-surface/definition-dsl.mjs +332 -0
- package/dist/auto-surface/definition-dsl.mjs.map +1 -0
- package/dist/auto-surface/fragments.cjs +177 -0
- package/dist/auto-surface/fragments.d.cts +23 -0
- package/dist/auto-surface/fragments.d.cts.map +1 -0
- package/dist/auto-surface/fragments.d.mts +23 -0
- package/dist/auto-surface/fragments.d.mts.map +1 -0
- package/dist/auto-surface/fragments.mjs +175 -0
- package/dist/auto-surface/fragments.mjs.map +1 -0
- package/dist/auto-surface/index.d.mts +9 -0
- package/dist/auto-surface/layering.cjs +43 -0
- package/dist/auto-surface/layering.d.cts +7 -0
- package/dist/auto-surface/layering.d.cts.map +1 -0
- package/dist/auto-surface/layering.d.mts +7 -0
- package/dist/auto-surface/layering.d.mts.map +1 -0
- package/dist/auto-surface/layering.mjs +43 -0
- package/dist/auto-surface/layering.mjs.map +1 -0
- package/dist/auto-surface/projection.cjs +11 -0
- package/dist/auto-surface/projection.d.cts +11 -0
- package/dist/auto-surface/projection.d.cts.map +1 -0
- package/dist/auto-surface/projection.d.mts +11 -0
- package/dist/auto-surface/projection.d.mts.map +1 -0
- package/dist/auto-surface/projection.mjs +12 -0
- package/dist/auto-surface/projection.mjs.map +1 -0
- package/dist/auto-surface/projectors/settings-shell.cjs +114 -0
- package/dist/auto-surface/projectors/settings-shell.d.cts +10 -0
- package/dist/auto-surface/projectors/settings-shell.d.cts.map +1 -0
- package/dist/auto-surface/projectors/settings-shell.d.mts +10 -0
- package/dist/auto-surface/projectors/settings-shell.d.mts.map +1 -0
- package/dist/auto-surface/projectors/settings-shell.mjs +114 -0
- package/dist/auto-surface/projectors/settings-shell.mjs.map +1 -0
- package/dist/auto-surface/scenario.cjs +38 -0
- package/dist/auto-surface/scenario.d.cts +31 -0
- package/dist/auto-surface/scenario.d.cts.map +1 -0
- package/dist/auto-surface/scenario.d.mts +31 -0
- package/dist/auto-surface/scenario.d.mts.map +1 -0
- package/dist/auto-surface/scenario.mjs +37 -0
- package/dist/auto-surface/scenario.mjs.map +1 -0
- package/dist/auto-surface/types.cjs +9 -0
- package/dist/auto-surface/types.d.cts +153 -0
- package/dist/auto-surface/types.d.cts.map +1 -0
- package/dist/auto-surface/types.d.mts +153 -0
- package/dist/auto-surface/types.d.mts.map +1 -0
- package/dist/auto-surface/types.mjs +9 -0
- package/dist/auto-surface/types.mjs.map +1 -0
- package/dist/auto-surface/value-dsl.cjs +80 -0
- package/dist/auto-surface/value-dsl.d.cts +24 -0
- package/dist/auto-surface/value-dsl.d.cts.map +1 -0
- package/dist/auto-surface/value-dsl.d.mts +24 -0
- package/dist/auto-surface/value-dsl.d.mts.map +1 -0
- package/dist/auto-surface/value-dsl.mjs +79 -0
- package/dist/auto-surface/value-dsl.mjs.map +1 -0
- package/dist/blocklet/activation.cjs +94 -0
- package/dist/blocklet/activation.d.cts +30 -0
- package/dist/blocklet/activation.d.cts.map +1 -0
- package/dist/blocklet/activation.d.mts +30 -0
- package/dist/blocklet/activation.d.mts.map +1 -0
- package/dist/blocklet/activation.mjs +94 -0
- package/dist/blocklet/activation.mjs.map +1 -0
- package/dist/blocklet/did-space-registry.cjs +282 -0
- package/dist/blocklet/did-space-registry.d.cts +82 -0
- package/dist/blocklet/did-space-registry.d.cts.map +1 -0
- package/dist/blocklet/did-space-registry.d.mts +82 -0
- package/dist/blocklet/did-space-registry.d.mts.map +1 -0
- package/dist/blocklet/did-space-registry.mjs +281 -0
- package/dist/blocklet/did-space-registry.mjs.map +1 -0
- package/dist/blocklet/handlers.cjs +66 -0
- package/dist/blocklet/handlers.d.cts +16 -0
- package/dist/blocklet/handlers.d.cts.map +1 -0
- package/dist/blocklet/handlers.d.mts +16 -0
- package/dist/blocklet/handlers.d.mts.map +1 -0
- package/dist/blocklet/handlers.mjs +65 -0
- package/dist/blocklet/handlers.mjs.map +1 -0
- package/dist/blocklet/index.d.mts +7 -0
- package/dist/blocklet/manifest.d.cts +2 -0
- package/dist/blocklet/manifest.d.mts +2 -0
- package/dist/blocklet/manifest.mjs +3 -0
- package/dist/blocklet/registry.cjs +447 -0
- package/dist/blocklet/registry.d.cts +197 -0
- package/dist/blocklet/registry.d.cts.map +1 -0
- package/dist/blocklet/registry.d.mts +197 -0
- package/dist/blocklet/registry.d.mts.map +1 -0
- package/dist/blocklet/registry.mjs +441 -0
- package/dist/blocklet/registry.mjs.map +1 -0
- package/dist/blocklet/static-render.cjs +183 -0
- package/dist/blocklet/static-render.d.cts +55 -0
- package/dist/blocklet/static-render.d.cts.map +1 -0
- package/dist/blocklet/static-render.d.mts +55 -0
- package/dist/blocklet/static-render.d.mts.map +1 -0
- package/dist/blocklet/static-render.mjs +181 -0
- package/dist/blocklet/static-render.mjs.map +1 -0
- package/dist/blocklet/types.d.cts +70 -0
- package/dist/blocklet/types.d.cts.map +1 -0
- package/dist/blocklet/types.d.mts +70 -0
- package/dist/blocklet/types.d.mts.map +1 -0
- package/dist/devices/chain.cjs +127 -0
- package/dist/devices/chain.d.cts +48 -0
- package/dist/devices/chain.d.cts.map +1 -0
- package/dist/devices/chain.d.mts +48 -0
- package/dist/devices/chain.d.mts.map +1 -0
- package/dist/devices/chain.mjs +125 -0
- package/dist/devices/chain.mjs.map +1 -0
- package/dist/dsl-shared.cjs +290 -0
- package/dist/dsl-shared.d.cts +54 -0
- package/dist/dsl-shared.d.cts.map +1 -0
- package/dist/dsl-shared.d.mts +54 -0
- package/dist/dsl-shared.d.mts.map +1 -0
- package/dist/dsl-shared.mjs +287 -0
- package/dist/dsl-shared.mjs.map +1 -0
- package/dist/http/afs-mcp.cjs +85 -0
- package/dist/http/afs-mcp.d.cts +14 -0
- package/dist/http/afs-mcp.d.cts.map +1 -0
- package/dist/http/afs-mcp.d.mts +14 -0
- package/dist/http/afs-mcp.d.mts.map +1 -0
- package/dist/http/afs-mcp.mjs +86 -0
- package/dist/http/afs-mcp.mjs.map +1 -0
- package/dist/http/afs-raw.cjs +264 -0
- package/dist/http/afs-raw.d.cts +31 -0
- package/dist/http/afs-raw.d.cts.map +1 -0
- package/dist/http/afs-raw.d.mts +31 -0
- package/dist/http/afs-raw.d.mts.map +1 -0
- package/dist/http/afs-raw.mjs +264 -0
- package/dist/http/afs-raw.mjs.map +1 -0
- package/dist/http/afs-rest.cjs +30 -0
- package/dist/http/afs-rest.d.cts +21 -0
- package/dist/http/afs-rest.d.cts.map +1 -0
- package/dist/http/afs-rest.d.mts +21 -0
- package/dist/http/afs-rest.d.mts.map +1 -0
- package/dist/http/afs-rest.mjs +31 -0
- package/dist/http/afs-rest.mjs.map +1 -0
- package/dist/http/afs-rpc-wire.cjs +271 -0
- package/dist/http/afs-rpc-wire.d.cts +195 -0
- package/dist/http/afs-rpc-wire.d.cts.map +1 -0
- package/dist/http/afs-rpc-wire.d.mts +195 -0
- package/dist/http/afs-rpc-wire.d.mts.map +1 -0
- package/dist/http/afs-rpc-wire.mjs +262 -0
- package/dist/http/afs-rpc-wire.mjs.map +1 -0
- package/dist/http/afs-rpc.cjs +729 -0
- package/dist/http/afs-rpc.d.cts +103 -0
- package/dist/http/afs-rpc.d.cts.map +1 -0
- package/dist/http/afs-rpc.d.mts +103 -0
- package/dist/http/afs-rpc.d.mts.map +1 -0
- package/dist/http/afs-rpc.mjs +729 -0
- package/dist/http/afs-rpc.mjs.map +1 -0
- package/dist/http/afs-upload.cjs +116 -0
- package/dist/http/afs-upload.d.cts +40 -0
- package/dist/http/afs-upload.d.cts.map +1 -0
- package/dist/http/afs-upload.d.mts +40 -0
- package/dist/http/afs-upload.d.mts.map +1 -0
- package/dist/http/afs-upload.mjs +116 -0
- package/dist/http/afs-upload.mjs.map +1 -0
- package/dist/http/aup-client.cjs +60 -0
- package/dist/http/aup-client.d.cts +22 -0
- package/dist/http/aup-client.d.cts.map +1 -0
- package/dist/http/aup-client.d.mts +22 -0
- package/dist/http/aup-client.d.mts.map +1 -0
- package/dist/http/aup-client.mjs +59 -0
- package/dist/http/aup-client.mjs.map +1 -0
- package/dist/http/aup-event.cjs +100 -0
- package/dist/http/aup-event.d.cts +38 -0
- package/dist/http/aup-event.d.cts.map +1 -0
- package/dist/http/aup-event.d.mts +38 -0
- package/dist/http/aup-event.d.mts.map +1 -0
- package/dist/http/aup-event.mjs +101 -0
- package/dist/http/aup-event.mjs.map +1 -0
- package/dist/http/auth-context.cjs +66 -0
- package/dist/http/auth-context.d.cts +64 -0
- package/dist/http/auth-context.d.cts.map +1 -0
- package/dist/http/auth-context.d.mts +64 -0
- package/dist/http/auth-context.d.mts.map +1 -0
- package/dist/http/auth-context.mjs +66 -0
- package/dist/http/auth-context.mjs.map +1 -0
- package/dist/http/csrf.cjs +50 -0
- package/dist/http/csrf.d.cts +8 -0
- package/dist/http/csrf.d.cts.map +1 -0
- package/dist/http/csrf.d.mts +8 -0
- package/dist/http/csrf.d.mts.map +1 -0
- package/dist/http/csrf.mjs +49 -0
- package/dist/http/csrf.mjs.map +1 -0
- package/dist/http/handlers.cjs +106 -0
- package/dist/http/handlers.d.cts +39 -0
- package/dist/http/handlers.d.cts.map +1 -0
- package/dist/http/handlers.d.mts +39 -0
- package/dist/http/handlers.d.mts.map +1 -0
- package/dist/http/handlers.mjs +104 -0
- package/dist/http/handlers.mjs.map +1 -0
- package/dist/http/index.d.mts +1 -0
- package/dist/http/ingest-facade.cjs +315 -0
- package/dist/http/ingest-facade.mjs +314 -0
- package/dist/http/ingest-facade.mjs.map +1 -0
- package/dist/http/raw-url.cjs +136 -0
- package/dist/http/raw-url.d.cts +54 -0
- package/dist/http/raw-url.d.cts.map +1 -0
- package/dist/http/raw-url.d.mts +54 -0
- package/dist/http/raw-url.d.mts.map +1 -0
- package/dist/http/raw-url.mjs +136 -0
- package/dist/http/raw-url.mjs.map +1 -0
- package/dist/http/request-context.cjs +178 -0
- package/dist/http/request-context.d.cts +76 -0
- package/dist/http/request-context.d.cts.map +1 -0
- package/dist/http/request-context.d.mts +76 -0
- package/dist/http/request-context.d.mts.map +1 -0
- package/dist/http/request-context.mjs +179 -0
- package/dist/http/request-context.mjs.map +1 -0
- package/dist/index.cjs +197 -0
- package/dist/index.d.cts +63 -0
- package/dist/index.d.mts +68 -0
- package/dist/index.mjs +61 -0
- package/dist/mcp/index.cjs +9 -0
- package/dist/mcp/index.d.cts +5 -0
- package/dist/mcp/index.d.mts +5 -0
- package/dist/mcp/index.mjs +6 -0
- package/dist/mcp/prompts.cjs +17 -0
- package/dist/mcp/prompts.d.cts +8 -0
- package/dist/mcp/prompts.d.cts.map +1 -0
- package/dist/mcp/prompts.d.mts +8 -0
- package/dist/mcp/prompts.d.mts.map +1 -0
- package/dist/mcp/prompts.mjs +17 -0
- package/dist/mcp/prompts.mjs.map +1 -0
- package/dist/mcp/resources.cjs +22 -0
- package/dist/mcp/resources.d.cts +8 -0
- package/dist/mcp/resources.d.cts.map +1 -0
- package/dist/mcp/resources.d.mts +8 -0
- package/dist/mcp/resources.d.mts.map +1 -0
- package/dist/mcp/resources.mjs +22 -0
- package/dist/mcp/resources.mjs.map +1 -0
- package/dist/mcp/server.cjs +51 -0
- package/dist/mcp/server.d.cts +20 -0
- package/dist/mcp/server.d.cts.map +1 -0
- package/dist/mcp/server.d.mts +20 -0
- package/dist/mcp/server.d.mts.map +1 -0
- package/dist/mcp/server.mjs +52 -0
- package/dist/mcp/server.mjs.map +1 -0
- package/dist/mcp/tools.cjs +218 -0
- package/dist/mcp/tools.d.cts +8 -0
- package/dist/mcp/tools.d.cts.map +1 -0
- package/dist/mcp/tools.d.mts +8 -0
- package/dist/mcp/tools.d.mts.map +1 -0
- package/dist/mcp/tools.mjs +219 -0
- package/dist/mcp/tools.mjs.map +1 -0
- package/dist/mcp/utils.cjs +75 -0
- package/dist/mcp/utils.mjs +69 -0
- package/dist/mcp/utils.mjs.map +1 -0
- package/dist/mount/index.cjs +4 -0
- package/dist/mount/index.d.cts +3 -0
- package/dist/mount/index.d.mts +3 -0
- package/dist/mount/index.mjs +3 -0
- package/dist/mount/materializer.cjs +167 -0
- package/dist/mount/materializer.d.cts +97 -0
- package/dist/mount/materializer.d.cts.map +1 -0
- package/dist/mount/materializer.d.mts +97 -0
- package/dist/mount/materializer.d.mts.map +1 -0
- package/dist/mount/materializer.mjs +167 -0
- package/dist/mount/materializer.mjs.map +1 -0
- package/dist/mount/types.d.cts +90 -0
- package/dist/mount/types.d.cts.map +1 -0
- package/dist/mount/types.d.mts +90 -0
- package/dist/mount/types.d.mts.map +1 -0
- package/dist/mount-config.cjs +61 -0
- package/dist/mount-config.d.cts +19 -0
- package/dist/mount-config.d.cts.map +1 -0
- package/dist/mount-config.d.mts +19 -0
- package/dist/mount-config.d.mts.map +1 -0
- package/dist/mount-config.mjs +61 -0
- package/dist/mount-config.mjs.map +1 -0
- package/dist/projectors/aup-projector.cjs +190 -0
- package/dist/projectors/aup-projector.d.cts +59 -0
- package/dist/projectors/aup-projector.d.cts.map +1 -0
- package/dist/projectors/aup-projector.d.mts +59 -0
- package/dist/projectors/aup-projector.d.mts.map +1 -0
- package/dist/projectors/aup-projector.mjs +188 -0
- package/dist/projectors/aup-projector.mjs.map +1 -0
- package/dist/projectors/index.cjs +6 -0
- package/dist/projectors/index.d.cts +2 -0
- package/dist/projectors/index.d.mts +2 -0
- package/dist/projectors/index.mjs +3 -0
- package/dist/scaffold/afs.cjs +195 -0
- package/dist/scaffold/afs.d.cts +16 -0
- package/dist/scaffold/afs.d.cts.map +1 -0
- package/dist/scaffold/afs.d.mts +16 -0
- package/dist/scaffold/afs.d.mts.map +1 -0
- package/dist/scaffold/afs.mjs +195 -0
- package/dist/scaffold/afs.mjs.map +1 -0
- package/dist/scaffold/composition.cjs +92 -0
- package/dist/scaffold/composition.d.cts +10 -0
- package/dist/scaffold/composition.d.cts.map +1 -0
- package/dist/scaffold/composition.d.mts +10 -0
- package/dist/scaffold/composition.d.mts.map +1 -0
- package/dist/scaffold/composition.mjs +92 -0
- package/dist/scaffold/composition.mjs.map +1 -0
- package/dist/scaffold/dsl-error.cjs +21 -0
- package/dist/scaffold/dsl-error.d.cts +11 -0
- package/dist/scaffold/dsl-error.d.cts.map +1 -0
- package/dist/scaffold/dsl-error.d.mts +11 -0
- package/dist/scaffold/dsl-error.d.mts.map +1 -0
- package/dist/scaffold/dsl-error.mjs +20 -0
- package/dist/scaffold/dsl-error.mjs.map +1 -0
- package/dist/scaffold/index.d.mts +12 -0
- package/dist/scaffold/manifest-dsl.cjs +188 -0
- package/dist/scaffold/manifest-dsl.d.cts +8 -0
- package/dist/scaffold/manifest-dsl.d.cts.map +1 -0
- package/dist/scaffold/manifest-dsl.d.mts +8 -0
- package/dist/scaffold/manifest-dsl.d.mts.map +1 -0
- package/dist/scaffold/manifest-dsl.mjs +188 -0
- package/dist/scaffold/manifest-dsl.mjs.map +1 -0
- package/dist/scaffold/module-dsl.cjs +284 -0
- package/dist/scaffold/module-dsl.d.cts +8 -0
- package/dist/scaffold/module-dsl.d.cts.map +1 -0
- package/dist/scaffold/module-dsl.d.mts +8 -0
- package/dist/scaffold/module-dsl.d.mts.map +1 -0
- package/dist/scaffold/module-dsl.mjs +284 -0
- package/dist/scaffold/module-dsl.mjs.map +1 -0
- package/dist/scaffold/resolver.cjs +156 -0
- package/dist/scaffold/resolver.d.cts +7 -0
- package/dist/scaffold/resolver.d.cts.map +1 -0
- package/dist/scaffold/resolver.d.mts +7 -0
- package/dist/scaffold/resolver.d.mts.map +1 -0
- package/dist/scaffold/resolver.mjs +156 -0
- package/dist/scaffold/resolver.mjs.map +1 -0
- package/dist/scaffold/runtime.cjs +24 -0
- package/dist/scaffold/runtime.d.cts +19 -0
- package/dist/scaffold/runtime.d.cts.map +1 -0
- package/dist/scaffold/runtime.d.mts +19 -0
- package/dist/scaffold/runtime.d.mts.map +1 -0
- package/dist/scaffold/runtime.mjs +25 -0
- package/dist/scaffold/runtime.mjs.map +1 -0
- package/dist/scaffold/shell-dsl.cjs +279 -0
- package/dist/scaffold/shell-dsl.d.cts +8 -0
- package/dist/scaffold/shell-dsl.d.cts.map +1 -0
- package/dist/scaffold/shell-dsl.d.mts +8 -0
- package/dist/scaffold/shell-dsl.d.mts.map +1 -0
- package/dist/scaffold/shell-dsl.mjs +279 -0
- package/dist/scaffold/shell-dsl.mjs.map +1 -0
- package/dist/scaffold/surface-dsl.cjs +182 -0
- package/dist/scaffold/surface-dsl.d.cts +8 -0
- package/dist/scaffold/surface-dsl.d.cts.map +1 -0
- package/dist/scaffold/surface-dsl.d.mts +8 -0
- package/dist/scaffold/surface-dsl.d.mts.map +1 -0
- package/dist/scaffold/surface-dsl.mjs +182 -0
- package/dist/scaffold/surface-dsl.mjs.map +1 -0
- package/dist/scaffold/surfaces.cjs +84 -0
- package/dist/scaffold/surfaces.d.cts +23 -0
- package/dist/scaffold/surfaces.d.cts.map +1 -0
- package/dist/scaffold/surfaces.d.mts +24 -0
- package/dist/scaffold/surfaces.d.mts.map +1 -0
- package/dist/scaffold/surfaces.mjs +84 -0
- package/dist/scaffold/surfaces.mjs.map +1 -0
- package/dist/scaffold/types.d.cts +264 -0
- package/dist/scaffold/types.d.cts.map +1 -0
- package/dist/scaffold/types.d.mts +265 -0
- package/dist/scaffold/types.d.mts.map +1 -0
- package/dist/scaffold/workspace-dsl.cjs +339 -0
- package/dist/scaffold/workspace-dsl.d.cts +49 -0
- package/dist/scaffold/workspace-dsl.d.cts.map +1 -0
- package/dist/scaffold/workspace-dsl.d.mts +49 -0
- package/dist/scaffold/workspace-dsl.d.mts.map +1 -0
- package/dist/scaffold/workspace-dsl.mjs +337 -0
- package/dist/scaffold/workspace-dsl.mjs.map +1 -0
- package/dist/scope/index.d.mts +3 -0
- package/dist/scope/read-blocklet-scope.cjs +29 -0
- package/dist/scope/read-blocklet-scope.d.cts +8 -0
- package/dist/scope/read-blocklet-scope.d.cts.map +1 -0
- package/dist/scope/read-blocklet-scope.d.mts +8 -0
- package/dist/scope/read-blocklet-scope.d.mts.map +1 -0
- package/dist/scope/read-blocklet-scope.mjs +30 -0
- package/dist/scope/read-blocklet-scope.mjs.map +1 -0
- package/dist/scope/resolve-scoped-afs.cjs +87 -0
- package/dist/scope/resolve-scoped-afs.d.cts +7 -0
- package/dist/scope/resolve-scoped-afs.d.cts.map +1 -0
- package/dist/scope/resolve-scoped-afs.d.mts +7 -0
- package/dist/scope/resolve-scoped-afs.d.mts.map +1 -0
- package/dist/scope/resolve-scoped-afs.mjs +88 -0
- package/dist/scope/resolve-scoped-afs.mjs.map +1 -0
- package/dist/scope/types.d.cts +25 -0
- package/dist/scope/types.d.cts.map +1 -0
- package/dist/scope/types.d.mts +25 -0
- package/dist/scope/types.d.mts.map +1 -0
- package/dist/session/backends.cjs +90 -0
- package/dist/session/backends.d.cts +35 -0
- package/dist/session/backends.d.cts.map +1 -0
- package/dist/session/backends.d.mts +35 -0
- package/dist/session/backends.d.mts.map +1 -0
- package/dist/session/backends.mjs +89 -0
- package/dist/session/backends.mjs.map +1 -0
- package/dist/session/replication-resolver.cjs +323 -0
- package/dist/session/replication-resolver.d.cts +71 -0
- package/dist/session/replication-resolver.d.cts.map +1 -0
- package/dist/session/replication-resolver.d.mts +71 -0
- package/dist/session/replication-resolver.d.mts.map +1 -0
- package/dist/session/replication-resolver.mjs +323 -0
- package/dist/session/replication-resolver.mjs.map +1 -0
- package/dist/session/role-level.cjs +36 -0
- package/dist/session/role-level.d.cts +24 -0
- package/dist/session/role-level.d.cts.map +1 -0
- package/dist/session/role-level.d.mts +24 -0
- package/dist/session/role-level.d.mts.map +1 -0
- package/dist/session/role-level.mjs +35 -0
- package/dist/session/role-level.mjs.map +1 -0
- package/dist/session/session-dir-providers.cjs +254 -0
- package/dist/session/session-dir-providers.d.cts +32 -0
- package/dist/session/session-dir-providers.d.cts.map +1 -0
- package/dist/session/session-dir-providers.d.mts +32 -0
- package/dist/session/session-dir-providers.d.mts.map +1 -0
- package/dist/session/session-dir-providers.mjs +252 -0
- package/dist/session/session-dir-providers.mjs.map +1 -0
- package/dist/session/session-id.cjs +20 -0
- package/dist/session/session-id.d.cts +15 -0
- package/dist/session/session-id.d.cts.map +1 -0
- package/dist/session/session-id.d.mts +15 -0
- package/dist/session/session-id.d.mts.map +1 -0
- package/dist/session/session-id.mjs +20 -0
- package/dist/session/session-id.mjs.map +1 -0
- package/dist/session/session-user-afs.cjs +899 -0
- package/dist/session/session-user-afs.d.cts +296 -0
- package/dist/session/session-user-afs.d.cts.map +1 -0
- package/dist/session/session-user-afs.d.mts +296 -0
- package/dist/session/session-user-afs.d.mts.map +1 -0
- package/dist/session/session-user-afs.mjs +896 -0
- package/dist/session/session-user-afs.mjs.map +1 -0
- package/dist/session/settings-cascade.cjs +69 -0
- package/dist/session/settings-cascade.d.cts +81 -0
- package/dist/session/settings-cascade.d.cts.map +1 -0
- package/dist/session/settings-cascade.d.mts +81 -0
- package/dist/session/settings-cascade.d.mts.map +1 -0
- package/dist/session/settings-cascade.mjs +69 -0
- package/dist/session/settings-cascade.mjs.map +1 -0
- package/dist/session/settings-resolver.cjs +770 -0
- package/dist/session/settings-resolver.d.cts +177 -0
- package/dist/session/settings-resolver.d.cts.map +1 -0
- package/dist/session/settings-resolver.d.mts +177 -0
- package/dist/session/settings-resolver.d.mts.map +1 -0
- package/dist/session/settings-resolver.mjs +771 -0
- package/dist/session/settings-resolver.mjs.map +1 -0
- package/dist/session/settings-schema-store.cjs +0 -0
- package/dist/session/settings-schema-store.d.cts +72 -0
- package/dist/session/settings-schema-store.d.cts.map +1 -0
- package/dist/session/settings-schema-store.d.mts +72 -0
- package/dist/session/settings-schema-store.d.mts.map +1 -0
- package/dist/session/settings-schema-store.mjs +0 -0
- package/dist/session/settings-schema-store.mjs.map +1 -0
- package/dist/system-mounts/index.cjs +14 -0
- package/dist/system-mounts/index.d.cts +6 -0
- package/dist/system-mounts/index.d.mts +6 -0
- package/dist/system-mounts/index.mjs +6 -0
- package/dist/system-mounts/install.cjs +101 -0
- package/dist/system-mounts/install.d.cts +36 -0
- package/dist/system-mounts/install.d.cts.map +1 -0
- package/dist/system-mounts/install.d.mts +37 -0
- package/dist/system-mounts/install.d.mts.map +1 -0
- package/dist/system-mounts/install.mjs +102 -0
- package/dist/system-mounts/install.mjs.map +1 -0
- package/dist/system-mounts/installers.cjs +247 -0
- package/dist/system-mounts/installers.d.cts +13 -0
- package/dist/system-mounts/installers.d.cts.map +1 -0
- package/dist/system-mounts/installers.d.mts +14 -0
- package/dist/system-mounts/installers.d.mts.map +1 -0
- package/dist/system-mounts/installers.mjs +244 -0
- package/dist/system-mounts/installers.mjs.map +1 -0
- package/dist/system-mounts/lists.cjs +122 -0
- package/dist/system-mounts/lists.d.cts +34 -0
- package/dist/system-mounts/lists.d.cts.map +1 -0
- package/dist/system-mounts/lists.d.mts +34 -0
- package/dist/system-mounts/lists.d.mts.map +1 -0
- package/dist/system-mounts/lists.mjs +122 -0
- package/dist/system-mounts/lists.mjs.map +1 -0
- package/dist/system-mounts/types.d.cts +124 -0
- package/dist/system-mounts/types.d.cts.map +1 -0
- package/dist/system-mounts/types.d.mts +125 -0
- package/dist/system-mounts/types.d.mts.map +1 -0
- package/dist/system-mounts/validate.cjs +56 -0
- package/dist/system-mounts/validate.d.cts +34 -0
- package/dist/system-mounts/validate.d.cts.map +1 -0
- package/dist/system-mounts/validate.d.mts +34 -0
- package/dist/system-mounts/validate.d.mts.map +1 -0
- package/dist/system-mounts/validate.mjs +56 -0
- package/dist/system-mounts/validate.mjs.map +1 -0
- package/dist/terminal-llm.cjs +90 -0
- package/dist/terminal-llm.d.cts +50 -0
- package/dist/terminal-llm.d.cts.map +1 -0
- package/dist/terminal-llm.d.mts +50 -0
- package/dist/terminal-llm.d.mts.map +1 -0
- package/dist/terminal-llm.mjs +90 -0
- package/dist/terminal-llm.mjs.map +1 -0
- package/dist/terminal-repl.cjs +371 -0
- package/dist/terminal-repl.d.cts +69 -0
- package/dist/terminal-repl.d.cts.map +1 -0
- package/dist/terminal-repl.d.mts +69 -0
- package/dist/terminal-repl.d.mts.map +1 -0
- package/dist/terminal-repl.mjs +370 -0
- package/dist/terminal-repl.mjs.map +1 -0
- package/dist/transport/idle-timer.cjs +136 -0
- package/dist/transport/idle-timer.d.cts +92 -0
- package/dist/transport/idle-timer.d.cts.map +1 -0
- package/dist/transport/idle-timer.d.mts +92 -0
- package/dist/transport/idle-timer.d.mts.map +1 -0
- package/dist/transport/idle-timer.mjs +132 -0
- package/dist/transport/idle-timer.mjs.map +1 -0
- package/dist/web-component-dsl.cjs +153 -0
- package/dist/web-component-dsl.d.cts +27 -0
- package/dist/web-component-dsl.d.cts.map +1 -0
- package/dist/web-component-dsl.d.mts +27 -0
- package/dist/web-component-dsl.d.mts.map +1 -0
- package/dist/web-component-dsl.mjs +152 -0
- package/dist/web-component-dsl.mjs.map +1 -0
- package/package.json +81 -0
|
@@ -0,0 +1,729 @@
|
|
|
1
|
+
const require_request_context = require('./request-context.cjs');
|
|
2
|
+
const require_afs_rpc_wire = require('./afs-rpc-wire.cjs');
|
|
3
|
+
const require_csrf = require('./csrf.cjs');
|
|
4
|
+
const require_ingest_facade = require('./ingest-facade.cjs');
|
|
5
|
+
let _aigne_afs = require("@aigne/afs");
|
|
6
|
+
let _aigne_afs_timing = require("@aigne/afs-timing");
|
|
7
|
+
|
|
8
|
+
//#region src/http/afs-rpc.ts
|
|
9
|
+
/**
|
|
10
|
+
* Blocklet-aware HTTP RPC handler for stateless AFS read operations.
|
|
11
|
+
*
|
|
12
|
+
* Why: AUP pages that just need `afs.list()` / `afs.read()` open a
|
|
13
|
+
* WebSocket otherwise — pinning a Durable Object on Cloudflare, or holding a
|
|
14
|
+
* WS handle on a Node daemon — even though the call is stateless. This
|
|
15
|
+
* handler runs purely in the HTTP request path; no WebSocket required.
|
|
16
|
+
*
|
|
17
|
+
* Distinct from `createAFSRestHandler` (which exposes the global AFS
|
|
18
|
+
* unscoped at `/afs/*`): this handler resolves the caller's blocklet from
|
|
19
|
+
* the request and returns paths that look like the blocklet's root to the
|
|
20
|
+
* client. It mirrors `AUPSessionDO.onSessionStart`'s `ProjectionProvider`
|
|
21
|
+
* setup but for HTTP, not WS.
|
|
22
|
+
*
|
|
23
|
+
* Scope: `read`, `list`, `stat`, `search`, `exec` (open to any resolved
|
|
24
|
+
* caller), plus `write`/`delete` (Phase 4) gated by an auth + allowlist layer —
|
|
25
|
+
* a verified Bearer caller writing only their own `/user/**` data path.
|
|
26
|
+
*
|
|
27
|
+
* Blocklet resolution priority:
|
|
28
|
+
* 1. options.resolveHostAlias(host) — caller-provided alias map
|
|
29
|
+
* (e.g. CF worker's patternCache
|
|
30
|
+
* from `.afs/aliases.json` —
|
|
31
|
+
* resolves `explorer.arcblock.io`
|
|
32
|
+
* → `chain-explorer` when the
|
|
33
|
+
* first label is NOT the
|
|
34
|
+
* blocklet id)
|
|
35
|
+
* 2. extractBlockletFromHost(host) — e.g. `showcase.afsd.io`
|
|
36
|
+
* → `"showcase"` when first
|
|
37
|
+
* label IS the blocklet id
|
|
38
|
+
* 3. body.blocklet / ?blocklet= — untrusted browser hint fallback
|
|
39
|
+
* 4. options.fallbackBlocklet
|
|
40
|
+
*/
|
|
41
|
+
const READ_ONLY_OPS = new Set([
|
|
42
|
+
"read",
|
|
43
|
+
"list",
|
|
44
|
+
"stat",
|
|
45
|
+
"search",
|
|
46
|
+
"exec",
|
|
47
|
+
"batchRead"
|
|
48
|
+
]);
|
|
49
|
+
const log = (0, _aigne_afs.makeNsLog)("aos:rpc");
|
|
50
|
+
/**
|
|
51
|
+
* Mutating ops (Phase 4 + afs-rpc-batch P1). Gated by an extra auth +
|
|
52
|
+
* allowlist layer on top of the read pipeline: a verified BEARER caller
|
|
53
|
+
* writing only their own `/user/**` data path. Batch ops run the SAME gate
|
|
54
|
+
* per entry — any entry failing it rejects the whole envelope (fail-closed).
|
|
55
|
+
*/
|
|
56
|
+
const MUTATING_OPS = new Set([
|
|
57
|
+
"write",
|
|
58
|
+
"delete",
|
|
59
|
+
"batchWrite",
|
|
60
|
+
"batchDelete"
|
|
61
|
+
]);
|
|
62
|
+
/** Batch wire ops (afs-rpc-batch P1): entries carry paths; no top-level path. */
|
|
63
|
+
const BATCH_OPS = new Set([
|
|
64
|
+
"batchRead",
|
|
65
|
+
"batchWrite",
|
|
66
|
+
"batchDelete"
|
|
67
|
+
]);
|
|
68
|
+
const RPC_BLOCKLET_HINT_PRIORITY = {
|
|
69
|
+
explicitPriority: "fallback",
|
|
70
|
+
queryPriority: "fallback"
|
|
71
|
+
};
|
|
72
|
+
const JSON_HEADERS = { "Content-Type": "application/json; charset=utf-8" };
|
|
73
|
+
function jsonResponse(status, body) {
|
|
74
|
+
return new Response(JSON.stringify(body), {
|
|
75
|
+
status,
|
|
76
|
+
headers: { ...JSON_HEADERS }
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function fail(status, error) {
|
|
80
|
+
return jsonResponse(status, {
|
|
81
|
+
ok: false,
|
|
82
|
+
error
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Lift a wire write entry's top-level `meta` onto `AFSWriteEntryPayload.meta`
|
|
87
|
+
* so metadata-aware providers (did-space) index application fields like
|
|
88
|
+
* `createdAt` / `updatedAt`. Sync provenance stays in `options.meta` and is
|
|
89
|
+
* untouched here. Mirrors `execRootWriteAction`'s `args.meta` forwarding
|
|
90
|
+
* (afs-root-handlers) for the RPC write/batchWrite ingress, which previously
|
|
91
|
+
* dropped `meta` entirely. Returns `undefined` for absent/non-object meta.
|
|
92
|
+
*/
|
|
93
|
+
function wireMeta(meta) {
|
|
94
|
+
return meta !== null && typeof meta === "object" ? meta : void 0;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Map AFS-layer errors onto sensible HTTP status codes.
|
|
98
|
+
* Unknown classes fall through to 500; the message still surfaces in
|
|
99
|
+
* the response body for debugging.
|
|
100
|
+
* Exported for the raw endpoint (afs-raw.ts) — one mapping, not two.
|
|
101
|
+
*/
|
|
102
|
+
/**
|
|
103
|
+
* Stable AFS error code → HTTP status (afs-rpc-batch P2). One map serves both
|
|
104
|
+
* thrown errors ({@link statusForError}) and the structured `code` slot on
|
|
105
|
+
* core batch entry results — the two derivations must never drift.
|
|
106
|
+
*/
|
|
107
|
+
const STATUS_BY_CODE = {
|
|
108
|
+
AFS_CONFLICT: 409,
|
|
109
|
+
AFS_NOT_FOUND: 404,
|
|
110
|
+
AFS_ACTION_NOT_FOUND: 404,
|
|
111
|
+
ENOENT: 404,
|
|
112
|
+
ENOTDIR: 404,
|
|
113
|
+
AFS_VALIDATION_ERROR: 400,
|
|
114
|
+
AFS_ACCESS_MODE: 405,
|
|
115
|
+
AFS_READONLY: 405,
|
|
116
|
+
AFS_ACCESS_DENIED: 403,
|
|
117
|
+
AFS_FORBIDDEN: 403,
|
|
118
|
+
AFS_AUTH_REQUIRED: 401,
|
|
119
|
+
AFS_PAYMENT_REQUIRED: 402,
|
|
120
|
+
AFS_UNSUPPORTED: 501
|
|
121
|
+
};
|
|
122
|
+
/** HTTP status for a structured per-entry error code (500 when unknown). */
|
|
123
|
+
function statusForCode(code) {
|
|
124
|
+
return code && STATUS_BY_CODE[code] || 500;
|
|
125
|
+
}
|
|
126
|
+
function statusForError(err) {
|
|
127
|
+
const byCode = STATUS_BY_CODE[err?.code ?? ""];
|
|
128
|
+
if (byCode) return byCode;
|
|
129
|
+
const name = err?.name ?? "";
|
|
130
|
+
if (name === "AFSAuthRequiredError") return 401;
|
|
131
|
+
if (name === "AFSPaymentRequiredError") return 402;
|
|
132
|
+
if (name === "AFSConflictError") return 409;
|
|
133
|
+
if (name === "AFSForbiddenError" || name === "AFSPermissionError") return 403;
|
|
134
|
+
if (name === "AFSNotFoundError") return 404;
|
|
135
|
+
if (name === "AFSValidationError") return 400;
|
|
136
|
+
if (name === "AFSAccessModeError") return 405;
|
|
137
|
+
if (name === "AFSReadonlyError") return 405;
|
|
138
|
+
if (name === "AFSUnsupportedError") return 501;
|
|
139
|
+
const message = errorMessage(err);
|
|
140
|
+
if (/\b(ENOENT|ENOTDIR):/.test(message)) return 404;
|
|
141
|
+
return 500;
|
|
142
|
+
}
|
|
143
|
+
function errorMessage(err) {
|
|
144
|
+
return err instanceof Error ? err.message : String(err);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Shape the 409 conflict body fields (wire-contract §7): the opaque
|
|
148
|
+
* current-version triple the client's conflict resolution (LWW) consumes.
|
|
149
|
+
* Single source for the single-op catch branch AND batch per-entry results —
|
|
150
|
+
* the triple must never drift between the two (afs-rpc-batch G3).
|
|
151
|
+
*/
|
|
152
|
+
function enrichConflictBody(err) {
|
|
153
|
+
const c = err;
|
|
154
|
+
return {
|
|
155
|
+
error: errorMessage(err),
|
|
156
|
+
code: require_afs_rpc_wire.WIRE_ERROR_CODES.conflict,
|
|
157
|
+
currentCid: typeof c.currentCid === "string" ? c.currentCid : null,
|
|
158
|
+
currentMtime: typeof c.currentMtime === "number" ? c.currentMtime : null,
|
|
159
|
+
currentDeviceId: typeof c.currentDeviceId === "string" ? c.currentDeviceId : null
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Map a per-entry failure onto the batch `results[i]` shape — identical to
|
|
164
|
+
* the single-op error body plus the `status` field (design §5.4 isomorphism).
|
|
165
|
+
* `optional` mirrors the single-op soft-miss: 404 → `{status:200, missing}`.
|
|
166
|
+
*/
|
|
167
|
+
function batchEntryError(err, optional) {
|
|
168
|
+
const status = statusForError(err);
|
|
169
|
+
const message = errorMessage(err);
|
|
170
|
+
if (optional === true && status === 404) return {
|
|
171
|
+
status: 200,
|
|
172
|
+
ok: false,
|
|
173
|
+
error: message,
|
|
174
|
+
missing: true
|
|
175
|
+
};
|
|
176
|
+
if (status === 409) return {
|
|
177
|
+
status: 409,
|
|
178
|
+
ok: false,
|
|
179
|
+
...enrichConflictBody(err)
|
|
180
|
+
};
|
|
181
|
+
const code = err?.code;
|
|
182
|
+
return {
|
|
183
|
+
status,
|
|
184
|
+
ok: false,
|
|
185
|
+
error: message,
|
|
186
|
+
...code ? { code } : {}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Map a CORE batch entry result onto the wire `results[i]` shape (L2 switch,
|
|
191
|
+
* P2). Field-for-field identical to what the P1 handler loop produced from
|
|
192
|
+
* thrown errors: success → single-op body, conflict → 409 + triple, other
|
|
193
|
+
* failures → status derived from the structured `code`.
|
|
194
|
+
*/
|
|
195
|
+
function wireResultFromCore(r) {
|
|
196
|
+
if (r.success) return {
|
|
197
|
+
status: 200,
|
|
198
|
+
ok: true,
|
|
199
|
+
data: encodeReadData(r.data)
|
|
200
|
+
};
|
|
201
|
+
if (r.conflict) return {
|
|
202
|
+
status: 409,
|
|
203
|
+
ok: false,
|
|
204
|
+
error: r.error ?? "",
|
|
205
|
+
code: require_afs_rpc_wire.WIRE_ERROR_CODES.conflict,
|
|
206
|
+
...r.conflict
|
|
207
|
+
};
|
|
208
|
+
return {
|
|
209
|
+
status: statusForCode(r.code),
|
|
210
|
+
ok: false,
|
|
211
|
+
error: r.error ?? "",
|
|
212
|
+
...r.code ? { code: r.code } : {}
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
/** Max write payload (decoded bytes) before a 413. Large-blob bypass (D-A) is
|
|
216
|
+
* deferred to Phase 6; until then, oversize writes are rejected outright. */
|
|
217
|
+
const MAX_WRITE_BYTES = 16 * 1024 * 1024;
|
|
218
|
+
/**
|
|
219
|
+
* Phase 4 write-surface allowlist: ONLY the caller's own `/user/**` data paths
|
|
220
|
+
* are mutable over afs-rpc. `/user` itself, `/instance/**`, `/space/**`, the
|
|
221
|
+
* blocklet-global root paths, and the `.objects`/`.changelog`/`.shares` virtual
|
|
222
|
+
* namespaces are all rejected (the provider's D4 guard is a second layer).
|
|
223
|
+
*/
|
|
224
|
+
function isAllowedUserDataPath(path) {
|
|
225
|
+
if (!path.startsWith("/user/")) return false;
|
|
226
|
+
const segs = path.split("/").filter(Boolean);
|
|
227
|
+
if (segs.length < 2) return false;
|
|
228
|
+
return !segs.some((s) => s === ".objects" || s === ".changelog" || s === ".shares");
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Authorize a mutating op (Phase 4, P0-1 + P1-1). Returns an error `Response`
|
|
232
|
+
* when the write/delete is NOT permitted, else `null`.
|
|
233
|
+
*
|
|
234
|
+
* Defense in depth (not "trust the client to write /user"):
|
|
235
|
+
* - authenticated (caller.did present) → else 401
|
|
236
|
+
* - BEARER auth-source (cookie alone can't drive a write) → else 403 (CSRF)
|
|
237
|
+
* - non-root blocklet scope (root exposes global topology) → else 403
|
|
238
|
+
* - path under the caller's own `/user/**` data namespace → else 403
|
|
239
|
+
* The `/user` overlay is keyed by `caller.did`, so a caller can only ever reach
|
|
240
|
+
* its own fragment (structural isolation); `body.blocklet` only selects the app.
|
|
241
|
+
*/
|
|
242
|
+
function checkMutationAllowed(path, caller, scope) {
|
|
243
|
+
if (!caller || !caller.did) return fail(401, "Authentication required for write/delete");
|
|
244
|
+
if (caller.authSource !== "bearer") return fail(403, "write/delete require Authorization: Bearer (cookie-only is rejected)");
|
|
245
|
+
if (scope === "root") return fail(403, "write/delete not allowed on a root-scope blocklet");
|
|
246
|
+
if (!isAllowedUserDataPath(path)) return fail(403, `write/delete only allowed under /user/** data paths (got '${path}')`);
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Wire-contract §5: a `read` whose `content` is raw bytes (e.g. `.objects/{cid}`
|
|
251
|
+
* or any binary file) is base64-encoded with an `encoding` marker so it
|
|
252
|
+
* survives JSON transport. Text/JSON content passes through unchanged. The
|
|
253
|
+
* client (mobile RemoteDIDSpaceAFS) base64-decodes + recomputes the CID.
|
|
254
|
+
*/
|
|
255
|
+
function encodeReadData(data) {
|
|
256
|
+
if (!data || typeof data !== "object") return data;
|
|
257
|
+
const c = data.content;
|
|
258
|
+
if (c instanceof Uint8Array) return {
|
|
259
|
+
...data,
|
|
260
|
+
content: require_afs_rpc_wire.encodeContentBase64(c),
|
|
261
|
+
encoding: "base64"
|
|
262
|
+
};
|
|
263
|
+
if (c instanceof ArrayBuffer) return {
|
|
264
|
+
...data,
|
|
265
|
+
content: require_afs_rpc_wire.encodeContentBase64(new Uint8Array(c)),
|
|
266
|
+
encoding: "base64"
|
|
267
|
+
};
|
|
268
|
+
return data;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Extract the `{error,code,details}` triple from a provider that resolved with
|
|
272
|
+
* `success:false` (semantic failure, no throw). Buffered and streaming exec
|
|
273
|
+
* MUST format these identically — the cross-phase "流式与 buffered 语义对齐"
|
|
274
|
+
* invariant — so both spread this single source of truth.
|
|
275
|
+
*/
|
|
276
|
+
function execFailureFields(error) {
|
|
277
|
+
return {
|
|
278
|
+
error: error?.message || error?.code || "Action failed",
|
|
279
|
+
code: error?.code,
|
|
280
|
+
details: error?.details
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* NDJSON streaming response for a streaming `exec` (README §3.2). Each output
|
|
285
|
+
* line is one typed envelope:
|
|
286
|
+
* {"t":"chunk","chunk":{ ...full AFSExecChunk... }} — per onChunk callback
|
|
287
|
+
* {"t":"done","data":<final exec result data>} — exec resolved success
|
|
288
|
+
* {"t":"error","error":"...","code":"...","details":...} — failure / reject
|
|
289
|
+
*
|
|
290
|
+
* Wire contract (§3.2): the chunk envelope serializes the WHOLE `AFSExecChunk`
|
|
291
|
+
* (incl. `thoughts` + provider-specific fields) so the transport layer never
|
|
292
|
+
* drops fields — the client typed-surface narrowing happens later, not here.
|
|
293
|
+
*
|
|
294
|
+
* Errors are two-layered (§3.2.1): handler-level errors (CSRF, bad path) are
|
|
295
|
+
* already returned with a real HTTP status BEFORE this is called. Once the
|
|
296
|
+
* stream is open the status is committed to 200, so an `afs.exec()` failure —
|
|
297
|
+
* including a provider that resolves with `success:false` (mirroring the
|
|
298
|
+
* buffered branch) or an effect-gate reject — surfaces as a `{"t":"error"}`
|
|
299
|
+
* line, never as `{"t":"done"}`.
|
|
300
|
+
*/
|
|
301
|
+
function execStreamResponse(afs, path, args, opts, context) {
|
|
302
|
+
const encoder = new TextEncoder();
|
|
303
|
+
const { stream: _wireOnlyStream, ...restOpts } = opts;
|
|
304
|
+
let closed = false;
|
|
305
|
+
const stream = new ReadableStream({
|
|
306
|
+
async start(controller) {
|
|
307
|
+
const enqueue = (line) => {
|
|
308
|
+
if (closed) return;
|
|
309
|
+
try {
|
|
310
|
+
controller.enqueue(encoder.encode(`${JSON.stringify(line)}\n`));
|
|
311
|
+
} catch {
|
|
312
|
+
closed = true;
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
const execOptions = {
|
|
316
|
+
...restOpts,
|
|
317
|
+
context,
|
|
318
|
+
onChunk: (chunk) => enqueue({
|
|
319
|
+
t: "chunk",
|
|
320
|
+
chunk
|
|
321
|
+
})
|
|
322
|
+
};
|
|
323
|
+
try {
|
|
324
|
+
const r = await (0, _aigne_afs_timing.time)("op", () => afs.exec(path, args, execOptions));
|
|
325
|
+
if (r.success === false) enqueue({
|
|
326
|
+
t: "error",
|
|
327
|
+
...execFailureFields(r.error)
|
|
328
|
+
});
|
|
329
|
+
else enqueue({
|
|
330
|
+
t: "done",
|
|
331
|
+
data: r.data
|
|
332
|
+
});
|
|
333
|
+
} catch (err) {
|
|
334
|
+
const code = err?.code;
|
|
335
|
+
enqueue({
|
|
336
|
+
t: "error",
|
|
337
|
+
error: errorMessage(err),
|
|
338
|
+
code
|
|
339
|
+
});
|
|
340
|
+
} finally {
|
|
341
|
+
if (!closed) try {
|
|
342
|
+
controller.close();
|
|
343
|
+
} catch {}
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
cancel() {
|
|
347
|
+
closed = true;
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
return new Response(stream, {
|
|
351
|
+
status: 200,
|
|
352
|
+
headers: { "Content-Type": "application/x-ndjson; charset=utf-8" }
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
function createAfsRpcHandler(options) {
|
|
356
|
+
const reqCtx = require_request_context.createAfsRequestContext(options);
|
|
357
|
+
return async function handle(request) {
|
|
358
|
+
const probe = { t0: Date.now() };
|
|
359
|
+
try {
|
|
360
|
+
const resp = await handleInner(request, probe);
|
|
361
|
+
if ((0, _aigne_afs.logEnabled)("aos:rpc", "debug")) log.debug(`rpc:done type=${probe.type ?? "?"} status=${resp.status} totalMs=${Date.now() - probe.t0}`);
|
|
362
|
+
return resp;
|
|
363
|
+
} catch (err) {
|
|
364
|
+
log.warn(`afs-rpc unhandled failure error=${errorMessage(err)}`);
|
|
365
|
+
return fail(500, errorMessage(err));
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
async function handleInner(request, probe) {
|
|
369
|
+
if (request.method !== "POST") return fail(405, "Method Not Allowed (use POST)");
|
|
370
|
+
const limits = options.batchLimits ?? require_afs_rpc_wire.BATCH_LIMITS_CF;
|
|
371
|
+
const bounded = await require_afs_rpc_wire.readBoundedBody(request, limits.maxEncodedRequestBytes);
|
|
372
|
+
if (bounded.tooLarge) return jsonResponse(413, {
|
|
373
|
+
ok: false,
|
|
374
|
+
error: `Request body too large (> ${limits.maxEncodedRequestBytes} bytes)`,
|
|
375
|
+
code: require_afs_rpc_wire.WIRE_ERROR_CODES.payloadTooLarge
|
|
376
|
+
});
|
|
377
|
+
let body;
|
|
378
|
+
try {
|
|
379
|
+
body = JSON.parse(bounded.text);
|
|
380
|
+
if (typeof body !== "object" || body === null) throw new Error("body must be object");
|
|
381
|
+
} catch (err) {
|
|
382
|
+
return fail(400, `Invalid JSON body: ${errorMessage(err)}`);
|
|
383
|
+
}
|
|
384
|
+
const type = body.type;
|
|
385
|
+
if (typeof type !== "string" || !type) return fail(400, "Missing 'type' field");
|
|
386
|
+
const isMutation = MUTATING_OPS.has(type);
|
|
387
|
+
if (!READ_ONLY_OPS.has(type) && !isMutation) return fail(400, `Unsupported op '${type}' (supported: ${[...READ_ONLY_OPS, ...MUTATING_OPS].join(", ")})`);
|
|
388
|
+
const isBatch = BATCH_OPS.has(type);
|
|
389
|
+
let batch = null;
|
|
390
|
+
let path = "";
|
|
391
|
+
if (isBatch) {
|
|
392
|
+
const validated = require_afs_rpc_wire.validateBatchBody(body, limits, _aigne_afs.sanitizeAfsPath);
|
|
393
|
+
if (!validated.ok) return jsonResponse(validated.status, {
|
|
394
|
+
ok: false,
|
|
395
|
+
error: validated.error,
|
|
396
|
+
...validated.code ? { code: validated.code } : {}
|
|
397
|
+
});
|
|
398
|
+
batch = validated;
|
|
399
|
+
} else {
|
|
400
|
+
if (typeof body.path !== "string" || (0, _aigne_afs.sanitizeAfsPath)(body.path) === null) return fail(400, "Missing or invalid 'path'");
|
|
401
|
+
path = body.path;
|
|
402
|
+
}
|
|
403
|
+
probe.type = type;
|
|
404
|
+
if ((0, _aigne_afs.logEnabled)("aos:rpc", "debug")) {
|
|
405
|
+
const o = body.options ?? {};
|
|
406
|
+
const optBits = [
|
|
407
|
+
o.maxDepth !== void 0 ? `maxDepth=${o.maxDepth}` : "",
|
|
408
|
+
o.limit !== void 0 ? `limit=${o.limit}` : "",
|
|
409
|
+
o.offset !== void 0 ? `offset=${o.offset}` : "",
|
|
410
|
+
o.cursor !== void 0 ? "cursor=1" : ""
|
|
411
|
+
].filter(Boolean).join(";");
|
|
412
|
+
const argEntries = Array.isArray(body.args?.entries) ? body.args.entries.length : void 0;
|
|
413
|
+
const target = isBatch ? `batch:${batch?.entries.length ?? 0}` : path;
|
|
414
|
+
log.debug(`rpc:begin type=${type} target=${target}${argEntries !== void 0 ? ` args.entries=${argEntries}` : ""}${optBits ? ` opt=${optBits}` : ""} blockletHint=${body.blocklet ?? "-"}`);
|
|
415
|
+
}
|
|
416
|
+
const tPre = Date.now();
|
|
417
|
+
const blocklet = await (0, _aigne_afs_timing.time)("resolve", () => reqCtx.resolveBlocklet(request, body.blocklet, RPC_BLOCKLET_HINT_PRIORITY));
|
|
418
|
+
const tBlocklet = Date.now();
|
|
419
|
+
if (!blocklet) return fail(400, "Could not resolve blocklet (set body.blocklet, ?blocklet=, or use a subdomain)");
|
|
420
|
+
const opts = body.options ?? {};
|
|
421
|
+
const caller = await reqCtx.resolveCaller(request);
|
|
422
|
+
const tCaller = Date.now();
|
|
423
|
+
const sessionIdForCtx = typeof body.sessionId === "string" && body.sessionId ? body.sessionId : null;
|
|
424
|
+
let scope;
|
|
425
|
+
let afs;
|
|
426
|
+
let context;
|
|
427
|
+
try {
|
|
428
|
+
const scoped = await reqCtx.resolveScoped(request, {
|
|
429
|
+
blocklet,
|
|
430
|
+
sessionId: sessionIdForCtx,
|
|
431
|
+
caller,
|
|
432
|
+
opOptions: opts
|
|
433
|
+
});
|
|
434
|
+
scope = scoped.scope;
|
|
435
|
+
afs = scoped.afs;
|
|
436
|
+
context = scoped.context;
|
|
437
|
+
} catch (err) {
|
|
438
|
+
return fail(statusForError(err), errorMessage(err));
|
|
439
|
+
}
|
|
440
|
+
const tScoped = Date.now();
|
|
441
|
+
if ((0, _aigne_afs.logEnabled)("aos:rpc", "debug")) log.debug(`rpc:resolved type=${type} blocklet=${blocklet} scope=${scope} resolveMs=${tScoped - probe.t0} blockletMs=${tBlocklet - tPre} callerMs=${tCaller - tBlocklet} scopedMs=${tScoped - tCaller}`);
|
|
442
|
+
if (isMutation) {
|
|
443
|
+
const gatePaths = batch ? batch.entries.map((e) => e.path) : [path];
|
|
444
|
+
for (const gatePath of gatePaths) {
|
|
445
|
+
const denied = checkMutationAllowed(gatePath, caller, scope);
|
|
446
|
+
if (denied) return denied;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
if (type === "exec") {
|
|
450
|
+
const csrfReason = require_csrf.csrfRejection(request, caller, true);
|
|
451
|
+
if (csrfReason) return fail(403, csrfReason);
|
|
452
|
+
}
|
|
453
|
+
try {
|
|
454
|
+
switch (type) {
|
|
455
|
+
case "read":
|
|
456
|
+
if (!afs.read) return fail(501, "read not supported");
|
|
457
|
+
return jsonResponse(200, {
|
|
458
|
+
ok: true,
|
|
459
|
+
data: encodeReadData((await (0, _aigne_afs_timing.time)("op", () => afs.read(path, {
|
|
460
|
+
...opts,
|
|
461
|
+
context
|
|
462
|
+
}))).data)
|
|
463
|
+
});
|
|
464
|
+
case "list": {
|
|
465
|
+
const r = await (0, _aigne_afs_timing.time)("op", () => afs.list(path, {
|
|
466
|
+
...opts,
|
|
467
|
+
context
|
|
468
|
+
}));
|
|
469
|
+
return jsonResponse(200, {
|
|
470
|
+
ok: true,
|
|
471
|
+
data: path === "/.actions" ? require_ingest_facade.injectIngestFacadeList(r.data) : r.data,
|
|
472
|
+
total: r.total,
|
|
473
|
+
meta: r.meta,
|
|
474
|
+
liveSeq: r.liveSeq
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
case "stat":
|
|
478
|
+
if (!afs.stat) return fail(501, "stat not supported");
|
|
479
|
+
return jsonResponse(200, {
|
|
480
|
+
ok: true,
|
|
481
|
+
data: (await (0, _aigne_afs_timing.time)("op", () => afs.stat(path, {
|
|
482
|
+
...opts,
|
|
483
|
+
context
|
|
484
|
+
}))).data
|
|
485
|
+
});
|
|
486
|
+
case "search": {
|
|
487
|
+
if (!afs.search) return fail(501, "search not supported");
|
|
488
|
+
const query = String(body.args?.query ?? body.options?.query ?? "");
|
|
489
|
+
const filters = body.args?.filters ?? body.options?.filters;
|
|
490
|
+
const mode = body.args?.mode ?? body.options?.mode;
|
|
491
|
+
const r = await (0, _aigne_afs_timing.time)("op", () => afs.search(path, query, {
|
|
492
|
+
...opts,
|
|
493
|
+
context,
|
|
494
|
+
filters,
|
|
495
|
+
mode
|
|
496
|
+
}));
|
|
497
|
+
return jsonResponse(200, {
|
|
498
|
+
ok: true,
|
|
499
|
+
data: r.data,
|
|
500
|
+
message: r.message,
|
|
501
|
+
meta: r.meta
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
case "exec": {
|
|
505
|
+
if (!afs.exec) return fail(501, "exec not supported");
|
|
506
|
+
if (require_ingest_facade.isIngestFacadePath(path)) {
|
|
507
|
+
const fr = await (0, _aigne_afs_timing.time)("op", () => require_ingest_facade.execIngestFacade({
|
|
508
|
+
afs,
|
|
509
|
+
path,
|
|
510
|
+
args: body.args ?? {},
|
|
511
|
+
context,
|
|
512
|
+
caller,
|
|
513
|
+
limits: options.uploadLimits ?? _aigne_afs.UPLOAD_LIMIT_DEFAULTS
|
|
514
|
+
}));
|
|
515
|
+
if ("status" in fr) return fail(fr.status, fr.error);
|
|
516
|
+
if (fr.ok) return jsonResponse(200, {
|
|
517
|
+
ok: true,
|
|
518
|
+
data: fr.data
|
|
519
|
+
});
|
|
520
|
+
return jsonResponse(200, {
|
|
521
|
+
ok: false,
|
|
522
|
+
error: fr.error,
|
|
523
|
+
...fr.code ? { code: fr.code } : {}
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
const args = { ...body.args ?? {} };
|
|
527
|
+
delete args._scope_afs;
|
|
528
|
+
args._scope_afs = afs;
|
|
529
|
+
if (opts.stream === true) return execStreamResponse(afs, path, args, opts, context);
|
|
530
|
+
const r = await (0, _aigne_afs_timing.time)("op", () => afs.exec(path, args, {
|
|
531
|
+
...opts,
|
|
532
|
+
context
|
|
533
|
+
}));
|
|
534
|
+
const exec = r;
|
|
535
|
+
if (exec.success === false) return jsonResponse(200, {
|
|
536
|
+
ok: false,
|
|
537
|
+
...execFailureFields(exec.error)
|
|
538
|
+
});
|
|
539
|
+
return jsonResponse(200, {
|
|
540
|
+
ok: true,
|
|
541
|
+
data: r.data
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
case "write": {
|
|
545
|
+
if (!afs.write) return fail(501, "write not supported");
|
|
546
|
+
const decoded = require_afs_rpc_wire.validateAndDecodeWrite({
|
|
547
|
+
type: "write",
|
|
548
|
+
path,
|
|
549
|
+
content: body.content,
|
|
550
|
+
encoding: body.encoding,
|
|
551
|
+
options: opts
|
|
552
|
+
});
|
|
553
|
+
if (!decoded.ok) return fail(decoded.status, decoded.error);
|
|
554
|
+
if (decoded.bytes.length > MAX_WRITE_BYTES) return jsonResponse(413, {
|
|
555
|
+
ok: false,
|
|
556
|
+
error: `Payload too large (> ${MAX_WRITE_BYTES} bytes)`,
|
|
557
|
+
code: require_afs_rpc_wire.WIRE_ERROR_CODES.payloadTooLarge
|
|
558
|
+
});
|
|
559
|
+
return jsonResponse(200, {
|
|
560
|
+
ok: true,
|
|
561
|
+
data: encodeReadData((await (0, _aigne_afs_timing.time)("op", () => afs.write(path, {
|
|
562
|
+
content: decoded.bytes,
|
|
563
|
+
meta: wireMeta(body.meta)
|
|
564
|
+
}, {
|
|
565
|
+
...opts,
|
|
566
|
+
context
|
|
567
|
+
}))).data)
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
case "delete":
|
|
571
|
+
if (!afs.delete) return fail(501, "delete not supported");
|
|
572
|
+
return jsonResponse(200, {
|
|
573
|
+
ok: true,
|
|
574
|
+
data: await (0, _aigne_afs_timing.time)("op", () => afs.delete(path, {
|
|
575
|
+
...opts,
|
|
576
|
+
context
|
|
577
|
+
}))
|
|
578
|
+
});
|
|
579
|
+
case "batchWrite": {
|
|
580
|
+
if (!afs.batchWrite) return fail(501, "write not supported");
|
|
581
|
+
const entries = batch.entries;
|
|
582
|
+
const decodes = batch.writeDecodes;
|
|
583
|
+
(0, _aigne_afs_timing.timeMeta)("batch", `batchWrite n=${entries.length}`);
|
|
584
|
+
const results = new Array(entries.length);
|
|
585
|
+
const coreEntries = [];
|
|
586
|
+
const coreIndex = [];
|
|
587
|
+
for (let i = 0; i < entries.length; i++) {
|
|
588
|
+
const decoded = decodes[i];
|
|
589
|
+
if (!decoded.ok) {
|
|
590
|
+
results[i] = {
|
|
591
|
+
status: decoded.status,
|
|
592
|
+
ok: false,
|
|
593
|
+
error: decoded.error,
|
|
594
|
+
...decoded.code ? { code: decoded.code } : {}
|
|
595
|
+
};
|
|
596
|
+
continue;
|
|
597
|
+
}
|
|
598
|
+
coreIndex.push(i);
|
|
599
|
+
coreEntries.push({
|
|
600
|
+
path: entries[i].path,
|
|
601
|
+
content: {
|
|
602
|
+
content: decoded.bytes,
|
|
603
|
+
meta: wireMeta(entries[i].meta)
|
|
604
|
+
},
|
|
605
|
+
options: entries[i].options
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
if (coreEntries.length > 0) {
|
|
609
|
+
const core = await (0, _aigne_afs_timing.time)("op", () => afs.batchWrite(coreEntries, { context }));
|
|
610
|
+
for (let j = 0; j < core.results.length; j++) results[coreIndex[j]] = wireResultFromCore(core.results[j]);
|
|
611
|
+
}
|
|
612
|
+
const succeeded = results.filter((r) => r?.ok === true).length;
|
|
613
|
+
return jsonResponse(200, {
|
|
614
|
+
ok: true,
|
|
615
|
+
results,
|
|
616
|
+
succeeded,
|
|
617
|
+
failed: results.length - succeeded
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
case "batchDelete": {
|
|
621
|
+
if (!afs.batchDelete) return fail(501, "delete not supported");
|
|
622
|
+
const entries = batch.entries;
|
|
623
|
+
(0, _aigne_afs_timing.timeMeta)("batch", `batchDelete n=${entries.length}`);
|
|
624
|
+
const core = await (0, _aigne_afs_timing.time)("op", () => afs.batchDelete(entries.map((entry) => ({
|
|
625
|
+
path: entry.path,
|
|
626
|
+
options: entry.options
|
|
627
|
+
})), { context }));
|
|
628
|
+
return jsonResponse(200, {
|
|
629
|
+
ok: true,
|
|
630
|
+
results: core.results.map((r) => r.success ? {
|
|
631
|
+
status: 200,
|
|
632
|
+
ok: true,
|
|
633
|
+
data: {
|
|
634
|
+
path: r.path,
|
|
635
|
+
deleted: true
|
|
636
|
+
}
|
|
637
|
+
} : wireResultFromCore(r)),
|
|
638
|
+
succeeded: core.succeeded,
|
|
639
|
+
failed: core.failed
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
case "batchRead": {
|
|
643
|
+
if (!afs.read) return fail(501, "read not supported");
|
|
644
|
+
const entries = batch.entries;
|
|
645
|
+
(0, _aigne_afs_timing.timeMeta)("batch", `batchRead n=${entries.length}`);
|
|
646
|
+
const results = [];
|
|
647
|
+
let succeeded = 0;
|
|
648
|
+
let encodedBytes = 0;
|
|
649
|
+
await (0, _aigne_afs_timing.time)("op", async () => {
|
|
650
|
+
for (const entry of entries) {
|
|
651
|
+
if (encodedBytes >= limits.readTailSkipThresholdBytes) {
|
|
652
|
+
results.push({
|
|
653
|
+
status: 503,
|
|
654
|
+
ok: false,
|
|
655
|
+
error: "Batch response budget reached — retry this entry in the next batch",
|
|
656
|
+
code: require_afs_rpc_wire.WIRE_ERROR_CODES.batchTailSkipped
|
|
657
|
+
});
|
|
658
|
+
continue;
|
|
659
|
+
}
|
|
660
|
+
try {
|
|
661
|
+
const data = encodeReadData((await afs.read(entry.path, {
|
|
662
|
+
...entry.options ?? {},
|
|
663
|
+
includeActions: "none",
|
|
664
|
+
context
|
|
665
|
+
})).data);
|
|
666
|
+
const content = data?.content;
|
|
667
|
+
if (typeof content === "string") encodedBytes += content.length;
|
|
668
|
+
results.push({
|
|
669
|
+
status: 200,
|
|
670
|
+
ok: true,
|
|
671
|
+
data
|
|
672
|
+
});
|
|
673
|
+
succeeded++;
|
|
674
|
+
} catch (err) {
|
|
675
|
+
results.push(batchEntryError(err, entry.optional === true));
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
});
|
|
679
|
+
return jsonResponse(200, {
|
|
680
|
+
ok: true,
|
|
681
|
+
results,
|
|
682
|
+
succeeded,
|
|
683
|
+
failed: results.length - succeeded
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
default: return fail(400, `Unsupported op '${type}'`);
|
|
687
|
+
}
|
|
688
|
+
} catch (err) {
|
|
689
|
+
const status = statusForError(err);
|
|
690
|
+
const message = errorMessage(err);
|
|
691
|
+
if (body.optional === true && status === 404) return jsonResponse(200, {
|
|
692
|
+
ok: false,
|
|
693
|
+
error: message,
|
|
694
|
+
missing: true
|
|
695
|
+
});
|
|
696
|
+
if (status === 402) {
|
|
697
|
+
const paymentRequired = err.paymentRequired;
|
|
698
|
+
const extraHeaders = paymentRequired !== void 0 ? { "PAYMENT-REQUIRED": typeof paymentRequired === "string" ? paymentRequired : JSON.stringify(paymentRequired) } : {};
|
|
699
|
+
return new Response(JSON.stringify({
|
|
700
|
+
ok: false,
|
|
701
|
+
error: message,
|
|
702
|
+
code: "AFS_PAYMENT_REQUIRED"
|
|
703
|
+
}), {
|
|
704
|
+
status: 402,
|
|
705
|
+
headers: {
|
|
706
|
+
...JSON_HEADERS,
|
|
707
|
+
...extraHeaders
|
|
708
|
+
}
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
if (status === 409) return jsonResponse(409, {
|
|
712
|
+
ok: false,
|
|
713
|
+
...enrichConflictBody(err)
|
|
714
|
+
});
|
|
715
|
+
if (status >= 500) log.warn(`afs-rpc op failed type=${type} path=${isBatch ? "<batch>" : path} blocklet=${blocklet} status=${status} error=${message}`);
|
|
716
|
+
const code = err?.code;
|
|
717
|
+
if (code) return jsonResponse(status, {
|
|
718
|
+
ok: false,
|
|
719
|
+
error: message,
|
|
720
|
+
code
|
|
721
|
+
});
|
|
722
|
+
return fail(status, message);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
//#endregion
|
|
728
|
+
exports.createAfsRpcHandler = createAfsRpcHandler;
|
|
729
|
+
exports.statusForError = statusForError;
|