@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,59 @@
|
|
|
1
|
+
import { ResourceProjector } from "../mount/types.mjs";
|
|
2
|
+
import { AFS, AFSModule } from "@aigne/afs";
|
|
3
|
+
|
|
4
|
+
//#region src/projectors/aup-projector.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
* AUP projector singleton — the first-class abstraction.
|
|
8
|
+
*/
|
|
9
|
+
declare const aupResourceProjector: ResourceProjector;
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
* Thin wrapper exposing the same behaviour as
|
|
13
|
+
* {@link aupResourceProjector}.project — kept as a stable function reference
|
|
14
|
+
* for the chain-as-device-placement plan, which imports this name directly.
|
|
15
|
+
*/
|
|
16
|
+
declare function projectAupResources(opts: {
|
|
17
|
+
afs: AFS;
|
|
18
|
+
mountPath: string;
|
|
19
|
+
resources: AFSModule;
|
|
20
|
+
scope?: "host" | "blocklet" | "instance";
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* @internal
|
|
24
|
+
* Scan an existing AFS path for `*.json` recipe files and mount each one as
|
|
25
|
+
* a hidden `AupRecipeProvider` supplement under `{mountTarget}`.
|
|
26
|
+
*
|
|
27
|
+
* Used both by `projectAupResources` (after temp-mounting an opaque
|
|
28
|
+
* resources module) and by Node's `autoSupplementAup` virtual-path flow
|
|
29
|
+
* (which already has a live AFS path to scan).
|
|
30
|
+
*
|
|
31
|
+
* Missing `scanRoot` → silent no-op, mirroring the original loader contract.
|
|
32
|
+
*/
|
|
33
|
+
declare function projectAupFromAfsPath(opts: {
|
|
34
|
+
afs: AFS;
|
|
35
|
+
scanRoot: string;
|
|
36
|
+
mountTarget: string;
|
|
37
|
+
}): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* @internal
|
|
40
|
+
* Parse a relative path inside an `aup/` directory into the mount-path
|
|
41
|
+
* components the supplement will occupy. Prefix segments are translated from
|
|
42
|
+
* `_param` placeholder syntax to `:param` mount syntax (see
|
|
43
|
+
* {@link translateParamSegment}); the view name is never translated.
|
|
44
|
+
*
|
|
45
|
+
* ```
|
|
46
|
+
* /default.json → { prefix: "", viewName: "default" }
|
|
47
|
+
* /transactions/item.json → { prefix: "/transactions", viewName: "item" }
|
|
48
|
+
* /a/b/c/view.json → { prefix: "/a/b/c", viewName: "view" }
|
|
49
|
+
* /bridges/_addr/blocks/item.json→ { prefix: "/bridges/:addr/blocks", viewName: "item" }
|
|
50
|
+
* /traces/_date/_runId/item.json → { prefix: "/traces/:date/:runId", viewName: "item" }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
declare function parseAupFilePath(relPath: string): {
|
|
54
|
+
prefix: string;
|
|
55
|
+
viewName: string;
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
58
|
+
export { aupResourceProjector, parseAupFilePath, projectAupFromAfsPath, projectAupResources };
|
|
59
|
+
//# sourceMappingURL=aup-projector.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aup-projector.d.mts","names":[],"sources":["../../src/projectors/aup-projector.ts"],"mappings":";;;;;;;;cAqEa,oBAAA,EAAsB,iBAAA;;;;;AA4DnC;;iBA/CsB,mBAAA,CAAoB,IAAA;EACxC,GAAA,EAAK,GAAA;EACL,SAAA;EACA,SAAA,EAAW,SAAA;EACX,KAAA;AAAA,IACE,OAAA;;;;;AA0IJ;;;;;;;iBAhGsB,qBAAA,CAAsB,IAAA;EAC1C,GAAA,EAAK,GAAA;EACL,QAAA;EACA,WAAA;AAAA,IACE,OAAA;;;;;;;;;;;;;;;;iBA4FY,gBAAA,CAAiB,OAAA;EAAoB,MAAA;EAAgB,QAAA;AAAA"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { joinURL } from "ufo";
|
|
2
|
+
import { AFSNotFoundError, AFSValidationError, AupRecipeProvider } from "@aigne/afs";
|
|
3
|
+
|
|
4
|
+
//#region src/projectors/aup-projector.ts
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*
|
|
8
|
+
* AUP `ResourceProjector` — projects an opaque `AFSModule` of `aup/**.json`
|
|
9
|
+
* recipes onto a target mount as hidden `AupRecipeProvider` supplements.
|
|
10
|
+
*
|
|
11
|
+
* Runtime-neutral: the projector only uses AFS APIs and knows nothing about
|
|
12
|
+
* Node fs, Cloudflare bindings, or any other runtime-specific surface. The
|
|
13
|
+
* `resources` module is opaque — Node's adapter wraps a packageDir via
|
|
14
|
+
* `AFSFS`, Cloudflare's adapter wraps a build-time bundled asset map, and
|
|
15
|
+
* tests can wrap any in-memory `AFSModule`.
|
|
16
|
+
*
|
|
17
|
+
* Subpath-only export: `@aigne/aos/projectors`. Not part of the @aigne/aos
|
|
18
|
+
* root contract. Cross-plan contract: chain-as-device-placement Phase 4
|
|
19
|
+
* imports `projectAupResources` directly.
|
|
20
|
+
*/
|
|
21
|
+
const randomUUID = () => globalThis.crypto.randomUUID();
|
|
22
|
+
/**
|
|
23
|
+
* 1 MiB safety cap for a single recipe file. Anything larger almost
|
|
24
|
+
* certainly represents a misconfiguration (e.g. a bundled asset landed in
|
|
25
|
+
* `aup/`) and would balloon every mount's memory footprint.
|
|
26
|
+
*
|
|
27
|
+
* **Failure semantics:** oversized files and malformed JSON are surfaced as
|
|
28
|
+
* `AFSValidationError` (not silent skip). This matches the legacy
|
|
29
|
+
* `autoSupplementAup` contract — fail-fast over partial recipes is the
|
|
30
|
+
* right default because supplements that are missing in production are
|
|
31
|
+
* confusing for users and noisy in logs. The planning doc tasks.md table
|
|
32
|
+
* mentions "skip + log"; the legacy implementation has always thrown, all
|
|
33
|
+
* pre-existing integration tests assert throwing, and this projector
|
|
34
|
+
* preserves that behaviour. If a future phase wants per-file isolation
|
|
35
|
+
* the policy can be lifted to a projector option.
|
|
36
|
+
*/
|
|
37
|
+
const MAX_RECIPE_BYTES = 1024 * 1024;
|
|
38
|
+
/** Bounded recursion depth for listing aup/ — enough for any realistic layout. */
|
|
39
|
+
const MAX_LIST_DEPTH = 100;
|
|
40
|
+
/** Hidden temp mount root for opaque resources modules. Dot-less to remain
|
|
41
|
+
* compatible with any future blocklet rules that reject dot-prefixed segments. */
|
|
42
|
+
const TMP_MOUNT_ROOT = "/materialize-tmp";
|
|
43
|
+
/** Supplement sub-path under each target (e.g. `/fix` → `/fix/.aup/default`). */
|
|
44
|
+
const AUP_SUBPATH = ".aup";
|
|
45
|
+
/** Top-level directory inside the resources module that holds recipe JSON. */
|
|
46
|
+
const AUP_RESOURCE_ROOT = "/aup";
|
|
47
|
+
/**
|
|
48
|
+
* @internal
|
|
49
|
+
* AUP projector singleton — the first-class abstraction.
|
|
50
|
+
*/
|
|
51
|
+
const aupResourceProjector = {
|
|
52
|
+
kind: "aup",
|
|
53
|
+
async project({ afs, mountPath, resources, scope }) {
|
|
54
|
+
await projectAupResources({
|
|
55
|
+
afs,
|
|
56
|
+
mountPath,
|
|
57
|
+
resources,
|
|
58
|
+
scope
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* @internal
|
|
64
|
+
* Thin wrapper exposing the same behaviour as
|
|
65
|
+
* {@link aupResourceProjector}.project — kept as a stable function reference
|
|
66
|
+
* for the chain-as-device-placement plan, which imports this name directly.
|
|
67
|
+
*/
|
|
68
|
+
async function projectAupResources(opts) {
|
|
69
|
+
opts.scope;
|
|
70
|
+
const tempMountPath = joinURL(TMP_MOUNT_ROOT, randomUUID());
|
|
71
|
+
try {
|
|
72
|
+
await opts.afs.mount(opts.resources, tempMountPath, { hidden: true });
|
|
73
|
+
} catch (err) {
|
|
74
|
+
if (isNotFoundError(err)) return;
|
|
75
|
+
throw err;
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
await projectAupFromAfsPath({
|
|
79
|
+
afs: opts.afs,
|
|
80
|
+
scanRoot: joinURL(tempMountPath, AUP_RESOURCE_ROOT),
|
|
81
|
+
mountTarget: opts.mountPath
|
|
82
|
+
});
|
|
83
|
+
} finally {
|
|
84
|
+
opts.afs.unmount(tempMountPath);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* @internal
|
|
89
|
+
* Scan an existing AFS path for `*.json` recipe files and mount each one as
|
|
90
|
+
* a hidden `AupRecipeProvider` supplement under `{mountTarget}`.
|
|
91
|
+
*
|
|
92
|
+
* Used both by `projectAupResources` (after temp-mounting an opaque
|
|
93
|
+
* resources module) and by Node's `autoSupplementAup` virtual-path flow
|
|
94
|
+
* (which already has a live AFS path to scan).
|
|
95
|
+
*
|
|
96
|
+
* Missing `scanRoot` → silent no-op, mirroring the original loader contract.
|
|
97
|
+
*/
|
|
98
|
+
async function projectAupFromAfsPath(opts) {
|
|
99
|
+
let listResult;
|
|
100
|
+
try {
|
|
101
|
+
listResult = await opts.afs.list(opts.scanRoot, { maxDepth: MAX_LIST_DEPTH });
|
|
102
|
+
} catch (err) {
|
|
103
|
+
if (isNotFoundError(err)) return;
|
|
104
|
+
throw err;
|
|
105
|
+
}
|
|
106
|
+
const jsonFiles = (listResult.data ?? []).filter(isJsonFileEntry).sort((a, b) => (a.path ?? "").localeCompare(b.path ?? ""));
|
|
107
|
+
for (const file of jsonFiles) {
|
|
108
|
+
const relPath = file.path.slice(opts.scanRoot.length);
|
|
109
|
+
const { prefix, viewName } = parseAupFilePath(relPath);
|
|
110
|
+
const declaredSize = file.meta?.size;
|
|
111
|
+
if (typeof declaredSize === "number" && declaredSize > MAX_RECIPE_BYTES) throw new AFSValidationError(`AUP recipe file too large (> ${MAX_RECIPE_BYTES} bytes): ${relPath}`);
|
|
112
|
+
const raw = (await opts.afs.read(file.path)).data?.content;
|
|
113
|
+
const text = typeof raw === "string" ? raw : new TextDecoder().decode(raw);
|
|
114
|
+
if (text.length > MAX_RECIPE_BYTES) throw new AFSValidationError(`AUP recipe file too large (> ${MAX_RECIPE_BYTES} bytes): ${relPath}`);
|
|
115
|
+
let recipe;
|
|
116
|
+
try {
|
|
117
|
+
recipe = JSON.parse(text);
|
|
118
|
+
} catch (err) {
|
|
119
|
+
throw new AFSValidationError(`Failed to parse AUP recipe ${relPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
120
|
+
}
|
|
121
|
+
const supplementPath = joinURL(opts.mountTarget, prefix, AUP_SUBPATH, viewName);
|
|
122
|
+
await opts.afs.mount(new AupRecipeProvider(recipe), supplementPath, { hidden: true });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* @internal
|
|
127
|
+
* Translate `aup/` placeholder syntax to AFS mount `:param` syntax within a
|
|
128
|
+
* single path segment. An `_<name>` token becomes `:<name>` ONLY when the `_`
|
|
129
|
+
* sits at the start of the segment or directly after a non-alphanumeric
|
|
130
|
+
* separator (e.g. `-`). An underscore surrounded by alphanumerics (`my_dir`)
|
|
131
|
+
* is left literal, so ordinary directory names with underscores are safe.
|
|
132
|
+
*
|
|
133
|
+
* ```
|
|
134
|
+
* _date → :date (segment-leading)
|
|
135
|
+
* round-_n → round-:n (after a `-` separator — mixed segment)
|
|
136
|
+
* my_dir → my_dir (alphanumeric-bounded `_` — unchanged)
|
|
137
|
+
* ```
|
|
138
|
+
*
|
|
139
|
+
* Disambiguation convention (design.md §3.2): inside `aup/`, an `_<name>`
|
|
140
|
+
* token in this position is a parameter segment.
|
|
141
|
+
*/
|
|
142
|
+
function translateParamSegment(segment) {
|
|
143
|
+
return segment.replace(/(^|[^a-zA-Z0-9])_([a-zA-Z][a-zA-Z0-9]*)/g, "$1:$2");
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* @internal
|
|
147
|
+
* Parse a relative path inside an `aup/` directory into the mount-path
|
|
148
|
+
* components the supplement will occupy. Prefix segments are translated from
|
|
149
|
+
* `_param` placeholder syntax to `:param` mount syntax (see
|
|
150
|
+
* {@link translateParamSegment}); the view name is never translated.
|
|
151
|
+
*
|
|
152
|
+
* ```
|
|
153
|
+
* /default.json → { prefix: "", viewName: "default" }
|
|
154
|
+
* /transactions/item.json → { prefix: "/transactions", viewName: "item" }
|
|
155
|
+
* /a/b/c/view.json → { prefix: "/a/b/c", viewName: "view" }
|
|
156
|
+
* /bridges/_addr/blocks/item.json→ { prefix: "/bridges/:addr/blocks", viewName: "item" }
|
|
157
|
+
* /traces/_date/_runId/item.json → { prefix: "/traces/:date/:runId", viewName: "item" }
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
function parseAupFilePath(relPath) {
|
|
161
|
+
if (!relPath || relPath.trim() === "") throw new Error("parseAupFilePath: path is empty");
|
|
162
|
+
const normalized = (relPath.startsWith("/") ? relPath : `/${relPath}`).replace(/\/+/g, "/").replace(/\/+$/, "");
|
|
163
|
+
if (!normalized.endsWith(".json")) throw new Error(`parseAupFilePath: file must end with .json, got "${relPath}"`);
|
|
164
|
+
const segments = normalized.split("/").filter(Boolean);
|
|
165
|
+
if (segments.some((s) => s === "..")) throw new Error(`parseAupFilePath: path traversal not allowed: "${relPath}"`);
|
|
166
|
+
const viewName = segments.pop().slice(0, -5);
|
|
167
|
+
if (!viewName) throw new Error(`parseAupFilePath: view name is empty for "${relPath}"`);
|
|
168
|
+
return {
|
|
169
|
+
prefix: segments.length === 0 ? "" : `/${segments.map(translateParamSegment).join("/")}`,
|
|
170
|
+
viewName
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function isJsonFileEntry(entry) {
|
|
174
|
+
if (!entry.path?.endsWith(".json")) return false;
|
|
175
|
+
return entry.meta?.kind !== "fs:directory";
|
|
176
|
+
}
|
|
177
|
+
function isNotFoundError(err) {
|
|
178
|
+
if (err instanceof AFSNotFoundError) return true;
|
|
179
|
+
if (err instanceof Error) {
|
|
180
|
+
if (err.code === "ENOENT") return true;
|
|
181
|
+
if (/ENOENT|no such file or directory|not found/i.test(err.message)) return true;
|
|
182
|
+
}
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
//#endregion
|
|
187
|
+
export { aupResourceProjector, parseAupFilePath, projectAupFromAfsPath, projectAupResources };
|
|
188
|
+
//# sourceMappingURL=aup-projector.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aup-projector.mjs","names":[],"sources":["../../src/projectors/aup-projector.ts"],"sourcesContent":["/**\n * @internal\n *\n * AUP `ResourceProjector` — projects an opaque `AFSModule` of `aup/**.json`\n * recipes onto a target mount as hidden `AupRecipeProvider` supplements.\n *\n * Runtime-neutral: the projector only uses AFS APIs and knows nothing about\n * Node fs, Cloudflare bindings, or any other runtime-specific surface. The\n * `resources` module is opaque — Node's adapter wraps a packageDir via\n * `AFSFS`, Cloudflare's adapter wraps a build-time bundled asset map, and\n * tests can wrap any in-memory `AFSModule`.\n *\n * Subpath-only export: `@aigne/aos/projectors`. Not part of the @aigne/aos\n * root contract. Cross-plan contract: chain-as-device-placement Phase 4\n * imports `projectAupResources` directly.\n */\n\nimport {\n type AFS,\n type AFSEntry,\n type AFSListResult,\n type AFSModule,\n AFSNotFoundError,\n AFSValidationError,\n AupRecipeProvider,\n} from \"@aigne/afs\";\nimport { joinURL } from \"ufo\";\n\n// Web Crypto API — available in Node 19+ and Cloudflare Workers, so the\n// projector remains runtime-neutral and importable from CF without\n// pulling in `node:crypto`.\nconst randomUUID = (): string => globalThis.crypto.randomUUID();\n\nimport type { ResourceProjector } from \"../mount/types.js\";\n\n/**\n * 1 MiB safety cap for a single recipe file. Anything larger almost\n * certainly represents a misconfiguration (e.g. a bundled asset landed in\n * `aup/`) and would balloon every mount's memory footprint.\n *\n * **Failure semantics:** oversized files and malformed JSON are surfaced as\n * `AFSValidationError` (not silent skip). This matches the legacy\n * `autoSupplementAup` contract — fail-fast over partial recipes is the\n * right default because supplements that are missing in production are\n * confusing for users and noisy in logs. The planning doc tasks.md table\n * mentions \"skip + log\"; the legacy implementation has always thrown, all\n * pre-existing integration tests assert throwing, and this projector\n * preserves that behaviour. If a future phase wants per-file isolation\n * the policy can be lifted to a projector option.\n */\nconst MAX_RECIPE_BYTES = 1024 * 1024;\n\n/** Bounded recursion depth for listing aup/ — enough for any realistic layout. */\nconst MAX_LIST_DEPTH = 100;\n\n/** Hidden temp mount root for opaque resources modules. Dot-less to remain\n * compatible with any future blocklet rules that reject dot-prefixed segments. */\nconst TMP_MOUNT_ROOT = \"/materialize-tmp\";\n\n/** Supplement sub-path under each target (e.g. `/fix` → `/fix/.aup/default`). */\nconst AUP_SUBPATH = \".aup\";\n\n/** Top-level directory inside the resources module that holds recipe JSON. */\nconst AUP_RESOURCE_ROOT = \"/aup\";\n\n/**\n * @internal\n * AUP projector singleton — the first-class abstraction.\n */\nexport const aupResourceProjector: ResourceProjector = {\n kind: \"aup\",\n async project({ afs, mountPath, resources, scope }) {\n await projectAupResources({ afs, mountPath, resources, scope });\n },\n};\n\n/**\n * @internal\n * Thin wrapper exposing the same behaviour as\n * {@link aupResourceProjector}.project — kept as a stable function reference\n * for the chain-as-device-placement plan, which imports this name directly.\n */\nexport async function projectAupResources(opts: {\n afs: AFS;\n mountPath: string;\n resources: AFSModule;\n scope?: \"host\" | \"blocklet\" | \"instance\";\n}): Promise<void> {\n // scope is accepted for cross-plan symmetry (chain-as-device-placement\n // Phase 4 forwards it) but the projector is currently scope-agnostic;\n // future policies (per-scope size limits, namespacing) will read it.\n const _scope = opts.scope ?? \"host\";\n void _scope;\n\n const tempMountPath = joinURL(TMP_MOUNT_ROOT, randomUUID());\n\n try {\n await opts.afs.mount(opts.resources, tempMountPath, { hidden: true });\n } catch (err) {\n // A resources module that can't be mounted is treated as \"no recipes\" —\n // matches the original Node-only loader where a missing `aup/` directory\n // is a silent no-op.\n if (isNotFoundError(err)) return;\n throw err;\n }\n\n try {\n await projectAupFromAfsPath({\n afs: opts.afs,\n scanRoot: joinURL(tempMountPath, AUP_RESOURCE_ROOT),\n mountTarget: opts.mountPath,\n });\n } finally {\n // Sync API — do NOT await.\n opts.afs.unmount(tempMountPath);\n }\n}\n\n/**\n * @internal\n * Scan an existing AFS path for `*.json` recipe files and mount each one as\n * a hidden `AupRecipeProvider` supplement under `{mountTarget}`.\n *\n * Used both by `projectAupResources` (after temp-mounting an opaque\n * resources module) and by Node's `autoSupplementAup` virtual-path flow\n * (which already has a live AFS path to scan).\n *\n * Missing `scanRoot` → silent no-op, mirroring the original loader contract.\n */\nexport async function projectAupFromAfsPath(opts: {\n afs: AFS;\n scanRoot: string;\n mountTarget: string;\n}): Promise<void> {\n let listResult: AFSListResult;\n try {\n listResult = await opts.afs.list(opts.scanRoot, { maxDepth: MAX_LIST_DEPTH });\n } catch (err) {\n if (isNotFoundError(err)) return;\n throw err;\n }\n\n const jsonFiles = (listResult.data ?? [])\n .filter(isJsonFileEntry)\n // Deterministic order makes test assertions and log output reproducible.\n .sort((a, b) => (a.path ?? \"\").localeCompare(b.path ?? \"\"));\n\n for (const file of jsonFiles) {\n const relPath = file.path!.slice(opts.scanRoot.length);\n const { prefix, viewName } = parseAupFilePath(relPath);\n\n const declaredSize = file.meta?.size;\n if (typeof declaredSize === \"number\" && declaredSize > MAX_RECIPE_BYTES) {\n throw new AFSValidationError(\n `AUP recipe file too large (> ${MAX_RECIPE_BYTES} bytes): ${relPath}`,\n );\n }\n\n const readResult = await opts.afs.read(file.path!);\n const raw = readResult.data?.content;\n const text = typeof raw === \"string\" ? raw : new TextDecoder().decode(raw as Uint8Array);\n\n if (text.length > MAX_RECIPE_BYTES) {\n throw new AFSValidationError(\n `AUP recipe file too large (> ${MAX_RECIPE_BYTES} bytes): ${relPath}`,\n );\n }\n\n let recipe: unknown;\n try {\n recipe = JSON.parse(text);\n } catch (err) {\n const detail = err instanceof Error ? err.message : String(err);\n throw new AFSValidationError(`Failed to parse AUP recipe ${relPath}: ${detail}`);\n }\n\n const supplementPath = joinURL(opts.mountTarget, prefix, AUP_SUBPATH, viewName);\n // hidden: true → routable for read but invisible in parent list() so the\n // user-browsable tree is not polluted with .aup/ entries.\n //\n // When `prefix` carries a `:param` segment (translated from an `_param`\n // directory by parseAupFilePath, e.g. `aup/traces/_date/...`), `supplementPath`\n // is a pattern path like `/{mount}/traces/:date/.aup/default`. AFS.mount\n // auto-detects the `:param` segment and registers a hidden PATTERN mount —\n // no branch needed here; literal and pattern recipes share this one call.\n await opts.afs.mount(new AupRecipeProvider(recipe), supplementPath, { hidden: true });\n }\n}\n\n/**\n * @internal\n * Translate `aup/` placeholder syntax to AFS mount `:param` syntax within a\n * single path segment. An `_<name>` token becomes `:<name>` ONLY when the `_`\n * sits at the start of the segment or directly after a non-alphanumeric\n * separator (e.g. `-`). An underscore surrounded by alphanumerics (`my_dir`)\n * is left literal, so ordinary directory names with underscores are safe.\n *\n * ```\n * _date → :date (segment-leading)\n * round-_n → round-:n (after a `-` separator — mixed segment)\n * my_dir → my_dir (alphanumeric-bounded `_` — unchanged)\n * ```\n *\n * Disambiguation convention (design.md §3.2): inside `aup/`, an `_<name>`\n * token in this position is a parameter segment.\n */\nfunction translateParamSegment(segment: string): string {\n return segment.replace(/(^|[^a-zA-Z0-9])_([a-zA-Z][a-zA-Z0-9]*)/g, \"$1:$2\");\n}\n\n/**\n * @internal\n * Parse a relative path inside an `aup/` directory into the mount-path\n * components the supplement will occupy. Prefix segments are translated from\n * `_param` placeholder syntax to `:param` mount syntax (see\n * {@link translateParamSegment}); the view name is never translated.\n *\n * ```\n * /default.json → { prefix: \"\", viewName: \"default\" }\n * /transactions/item.json → { prefix: \"/transactions\", viewName: \"item\" }\n * /a/b/c/view.json → { prefix: \"/a/b/c\", viewName: \"view\" }\n * /bridges/_addr/blocks/item.json→ { prefix: \"/bridges/:addr/blocks\", viewName: \"item\" }\n * /traces/_date/_runId/item.json → { prefix: \"/traces/:date/:runId\", viewName: \"item\" }\n * ```\n */\nexport function parseAupFilePath(relPath: string): { prefix: string; viewName: string } {\n if (!relPath || relPath.trim() === \"\") {\n throw new Error(\"parseAupFilePath: path is empty\");\n }\n\n const withLeading = relPath.startsWith(\"/\") ? relPath : `/${relPath}`;\n const normalized = withLeading.replace(/\\/+/g, \"/\").replace(/\\/+$/, \"\");\n\n if (!normalized.endsWith(\".json\")) {\n throw new Error(`parseAupFilePath: file must end with .json, got \"${relPath}\"`);\n }\n\n const segments = normalized.split(\"/\").filter(Boolean);\n\n if (segments.some((s) => s === \"..\")) {\n throw new Error(`parseAupFilePath: path traversal not allowed: \"${relPath}\"`);\n }\n\n const last = segments.pop()!;\n const viewName = last.slice(0, -\".json\".length);\n if (!viewName) {\n throw new Error(`parseAupFilePath: view name is empty for \"${relPath}\"`);\n }\n\n // Translate placeholder dirs (`_date` → `:date`) so the supplement mounts on\n // a pattern path. View name stays literal — views are never parameters.\n const prefix = segments.length === 0 ? \"\" : `/${segments.map(translateParamSegment).join(\"/\")}`;\n return { prefix, viewName };\n}\n\nfunction isJsonFileEntry(entry: AFSEntry): boolean {\n if (!entry.path?.endsWith(\".json\")) return false;\n // AFSFS tags directory entries with `meta.kind: \"fs:directory\"`. Any other\n // kind (or a missing kind) is treated as a file candidate so the same logic\n // works for AFSFS, AFSMemory, and bundled-asset-style modules alike.\n const kind = entry.meta?.kind;\n return kind !== \"fs:directory\";\n}\n\nfunction isNotFoundError(err: unknown): boolean {\n if (err instanceof AFSNotFoundError) return true;\n if (err instanceof Error) {\n const code = (err as { code?: string }).code;\n if (code === \"ENOENT\") return true;\n if (/ENOENT|no such file or directory|not found/i.test(err.message)) return true;\n }\n return false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,mBAA2B,WAAW,OAAO,YAAY;;;;;;;;;;;;;;;;AAmB/D,MAAM,mBAAmB,OAAO;;AAGhC,MAAM,iBAAiB;;;AAIvB,MAAM,iBAAiB;;AAGvB,MAAM,cAAc;;AAGpB,MAAM,oBAAoB;;;;;AAM1B,MAAa,uBAA0C;CACrD,MAAM;CACN,MAAM,QAAQ,EAAE,KAAK,WAAW,WAAW,SAAS;AAClD,QAAM,oBAAoB;GAAE;GAAK;GAAW;GAAW;GAAO,CAAC;;CAElE;;;;;;;AAQD,eAAsB,oBAAoB,MAKxB;AAID,MAAK;CAGpB,MAAM,gBAAgB,QAAQ,gBAAgB,YAAY,CAAC;AAE3D,KAAI;AACF,QAAM,KAAK,IAAI,MAAM,KAAK,WAAW,eAAe,EAAE,QAAQ,MAAM,CAAC;UAC9D,KAAK;AAIZ,MAAI,gBAAgB,IAAI,CAAE;AAC1B,QAAM;;AAGR,KAAI;AACF,QAAM,sBAAsB;GAC1B,KAAK,KAAK;GACV,UAAU,QAAQ,eAAe,kBAAkB;GACnD,aAAa,KAAK;GACnB,CAAC;WACM;AAER,OAAK,IAAI,QAAQ,cAAc;;;;;;;;;;;;;;AAenC,eAAsB,sBAAsB,MAI1B;CAChB,IAAI;AACJ,KAAI;AACF,eAAa,MAAM,KAAK,IAAI,KAAK,KAAK,UAAU,EAAE,UAAU,gBAAgB,CAAC;UACtE,KAAK;AACZ,MAAI,gBAAgB,IAAI,CAAE;AAC1B,QAAM;;CAGR,MAAM,aAAa,WAAW,QAAQ,EAAE,EACrC,OAAO,gBAAgB,CAEvB,MAAM,GAAG,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,QAAQ,GAAG,CAAC;AAE7D,MAAK,MAAM,QAAQ,WAAW;EAC5B,MAAM,UAAU,KAAK,KAAM,MAAM,KAAK,SAAS,OAAO;EACtD,MAAM,EAAE,QAAQ,aAAa,iBAAiB,QAAQ;EAEtD,MAAM,eAAe,KAAK,MAAM;AAChC,MAAI,OAAO,iBAAiB,YAAY,eAAe,iBACrD,OAAM,IAAI,mBACR,gCAAgC,iBAAiB,WAAW,UAC7D;EAIH,MAAM,OADa,MAAM,KAAK,IAAI,KAAK,KAAK,KAAM,EAC3B,MAAM;EAC7B,MAAM,OAAO,OAAO,QAAQ,WAAW,MAAM,IAAI,aAAa,CAAC,OAAO,IAAkB;AAExF,MAAI,KAAK,SAAS,iBAChB,OAAM,IAAI,mBACR,gCAAgC,iBAAiB,WAAW,UAC7D;EAGH,IAAI;AACJ,MAAI;AACF,YAAS,KAAK,MAAM,KAAK;WAClB,KAAK;AAEZ,SAAM,IAAI,mBAAmB,8BAA8B,QAAQ,IADpD,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,GACiB;;EAGlF,MAAM,iBAAiB,QAAQ,KAAK,aAAa,QAAQ,aAAa,SAAS;AAS/E,QAAM,KAAK,IAAI,MAAM,IAAI,kBAAkB,OAAO,EAAE,gBAAgB,EAAE,QAAQ,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;AAqBzF,SAAS,sBAAsB,SAAyB;AACtD,QAAO,QAAQ,QAAQ,4CAA4C,QAAQ;;;;;;;;;;;;;;;;;AAkB7E,SAAgB,iBAAiB,SAAuD;AACtF,KAAI,CAAC,WAAW,QAAQ,MAAM,KAAK,GACjC,OAAM,IAAI,MAAM,kCAAkC;CAIpD,MAAM,cADc,QAAQ,WAAW,IAAI,GAAG,UAAU,IAAI,WAC7B,QAAQ,QAAQ,IAAI,CAAC,QAAQ,QAAQ,GAAG;AAEvE,KAAI,CAAC,WAAW,SAAS,QAAQ,CAC/B,OAAM,IAAI,MAAM,oDAAoD,QAAQ,GAAG;CAGjF,MAAM,WAAW,WAAW,MAAM,IAAI,CAAC,OAAO,QAAQ;AAEtD,KAAI,SAAS,MAAM,MAAM,MAAM,KAAK,CAClC,OAAM,IAAI,MAAM,kDAAkD,QAAQ,GAAG;CAI/E,MAAM,WADO,SAAS,KAAK,CACL,MAAM,GAAG,GAAgB;AAC/C,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,6CAA6C,QAAQ,GAAG;AAM1E,QAAO;EAAE,QADM,SAAS,WAAW,IAAI,KAAK,IAAI,SAAS,IAAI,sBAAsB,CAAC,KAAK,IAAI;EAC5E;EAAU;;AAG7B,SAAS,gBAAgB,OAA0B;AACjD,KAAI,CAAC,MAAM,MAAM,SAAS,QAAQ,CAAE,QAAO;AAK3C,QADa,MAAM,MAAM,SACT;;AAGlB,SAAS,gBAAgB,KAAuB;AAC9C,KAAI,eAAe,iBAAkB,QAAO;AAC5C,KAAI,eAAe,OAAO;AAExB,MADc,IAA0B,SAC3B,SAAU,QAAO;AAC9B,MAAI,8CAA8C,KAAK,IAAI,QAAQ,CAAE,QAAO;;AAE9E,QAAO"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const require_aup_projector = require('./aup-projector.cjs');
|
|
2
|
+
|
|
3
|
+
exports.aupResourceProjector = require_aup_projector.aupResourceProjector;
|
|
4
|
+
exports.parseAupFilePath = require_aup_projector.parseAupFilePath;
|
|
5
|
+
exports.projectAupFromAfsPath = require_aup_projector.projectAupFromAfsPath;
|
|
6
|
+
exports.projectAupResources = require_aup_projector.projectAupResources;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
const require_manifest_dsl = require('./manifest-dsl.cjs');
|
|
2
|
+
const require_module_dsl = require('./module-dsl.cjs');
|
|
3
|
+
const require_shell_dsl = require('./shell-dsl.cjs');
|
|
4
|
+
const require_surface_dsl = require('./surface-dsl.cjs');
|
|
5
|
+
const require_workspace_dsl = require('./workspace-dsl.cjs');
|
|
6
|
+
let ufo = require("ufo");
|
|
7
|
+
|
|
8
|
+
//#region src/scaffold/afs.ts
|
|
9
|
+
const DEFAULT_SCAFFOLD_ROOT = "/.scaffold";
|
|
10
|
+
async function loadScaffoldDefinition(reader, options = {}) {
|
|
11
|
+
const root = options.root ?? DEFAULT_SCAFFOLD_ROOT;
|
|
12
|
+
const manifest = await loadManifestDslDefinition(reader, root) ?? await readOptionalJSON(reader, (0, ufo.joinURL)(root, "manifest.json")) ?? { title: "App" };
|
|
13
|
+
const shellDsl = await loadShellDslDefinition(reader, root);
|
|
14
|
+
const shell = {
|
|
15
|
+
menu: shellDsl?.menu ?? normalizeMenu(await readOptionalJSON(reader, (0, ufo.joinURL)(root, "shell/menu.json"))),
|
|
16
|
+
header: shellDsl?.header ?? await readOptionalJSON(reader, (0, ufo.joinURL)(root, "shell/header.json")),
|
|
17
|
+
footer: shellDsl?.footer ?? await readOptionalJSON(reader, (0, ufo.joinURL)(root, "shell/footer.json")),
|
|
18
|
+
workspace: await loadWorkspaceDefinition(reader, root)
|
|
19
|
+
};
|
|
20
|
+
const modules = await loadModuleRecords(reader, (0, ufo.joinURL)(root, "modules"));
|
|
21
|
+
const surfaces = await loadSurfaceRecords(reader, (0, ufo.joinURL)(root, "surfaces"));
|
|
22
|
+
return {
|
|
23
|
+
manifest,
|
|
24
|
+
shell: normalizeShell(shell),
|
|
25
|
+
modules: sortByOrderThenTitle(modules),
|
|
26
|
+
surfaces: sortByOrderThenTitle(surfaces)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
async function loadManifestDslDefinition(reader, root) {
|
|
30
|
+
const dsl = await readOptionalText(reader, (0, ufo.joinURL)(root, "manifest.dsl"));
|
|
31
|
+
if (dsl !== void 0) return require_manifest_dsl.compileManifestDsl(dsl);
|
|
32
|
+
}
|
|
33
|
+
async function loadShellDslDefinition(reader, root) {
|
|
34
|
+
const dsl = await readOptionalText(reader, (0, ufo.joinURL)(root, "shell/shell.dsl"));
|
|
35
|
+
if (dsl !== void 0) return require_shell_dsl.compileShellDsl(dsl);
|
|
36
|
+
}
|
|
37
|
+
async function loadWorkspaceDefinition(reader, root) {
|
|
38
|
+
const dsl = await readOptionalText(reader, (0, ufo.joinURL)(root, "shell/workspace.dsl"));
|
|
39
|
+
if (dsl !== void 0) return require_workspace_dsl.compileWorkspaceDsl(dsl);
|
|
40
|
+
return await readOptionalJSON(reader, (0, ufo.joinURL)(root, "shell/workspace.json"));
|
|
41
|
+
}
|
|
42
|
+
async function loadModuleRecords(reader, root) {
|
|
43
|
+
if (!await hasDirectory(reader, root)) return [];
|
|
44
|
+
const entries = await listVisible(reader, root);
|
|
45
|
+
const records = [];
|
|
46
|
+
const dslIds = /* @__PURE__ */ new Set();
|
|
47
|
+
for (const entry of entries) {
|
|
48
|
+
const path = entryPath(root, entry);
|
|
49
|
+
if (isDirectoryEntry(entry)) {
|
|
50
|
+
const dsl = await readOptionalText(reader, (0, ufo.joinURL)(path, "module.dsl"));
|
|
51
|
+
if (dsl !== void 0) {
|
|
52
|
+
const record = require_module_dsl.compileModuleDsl(dsl);
|
|
53
|
+
records.push(record);
|
|
54
|
+
dslIds.add(record.id);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const nested = await readOptionalJSON(reader, (0, ufo.joinURL)(path, "module.json"));
|
|
58
|
+
if (nested) records.push(nested);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (entry.id.endsWith(".module.dsl")) {
|
|
62
|
+
const record = require_module_dsl.compileModuleDsl(await readOptionalText(reader, path) ?? "");
|
|
63
|
+
records.push(record);
|
|
64
|
+
dslIds.add(record.id);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
for (const entry of entries) {
|
|
68
|
+
if (isDirectoryEntry(entry) || !entry.id.endsWith(".module.json")) continue;
|
|
69
|
+
const parsed = await readJSON(reader, entryPath(root, entry));
|
|
70
|
+
if (dslIds.has(parsed.id)) continue;
|
|
71
|
+
records.push(parsed);
|
|
72
|
+
}
|
|
73
|
+
return records;
|
|
74
|
+
}
|
|
75
|
+
async function loadSurfaceRecords(reader, root) {
|
|
76
|
+
if (!await hasDirectory(reader, root)) return [];
|
|
77
|
+
const entries = await listVisible(reader, root);
|
|
78
|
+
const records = [];
|
|
79
|
+
const dslIds = /* @__PURE__ */ new Set();
|
|
80
|
+
for (const entry of entries) {
|
|
81
|
+
const path = entryPath(root, entry);
|
|
82
|
+
if (isDirectoryEntry(entry)) {
|
|
83
|
+
const dsl = await readOptionalText(reader, (0, ufo.joinURL)(path, "surface.dsl"));
|
|
84
|
+
if (dsl !== void 0) {
|
|
85
|
+
const record = require_surface_dsl.compileSurfaceDsl(dsl);
|
|
86
|
+
records.push(record);
|
|
87
|
+
dslIds.add(record.id);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const nested = await readOptionalJSON(reader, (0, ufo.joinURL)(path, "surface.json"));
|
|
91
|
+
if (nested) records.push(nested);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (entry.id.endsWith(".surface.dsl")) {
|
|
95
|
+
const record = require_surface_dsl.compileSurfaceDsl(await readOptionalText(reader, path) ?? "");
|
|
96
|
+
records.push(record);
|
|
97
|
+
dslIds.add(record.id);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
for (const entry of entries) {
|
|
101
|
+
if (isDirectoryEntry(entry) || !entry.id.endsWith(".surface.json")) continue;
|
|
102
|
+
const parsed = await readJSON(reader, entryPath(root, entry));
|
|
103
|
+
if (dslIds.has(parsed.id)) continue;
|
|
104
|
+
records.push(parsed);
|
|
105
|
+
}
|
|
106
|
+
return records;
|
|
107
|
+
}
|
|
108
|
+
function normalizeShell(shell) {
|
|
109
|
+
return {
|
|
110
|
+
...shell,
|
|
111
|
+
menu: normalizeMenu(shell.menu),
|
|
112
|
+
header: shell.header ? {
|
|
113
|
+
...shell.header,
|
|
114
|
+
actions: sortByOrderThenTitle(shell.header.actions ?? [])
|
|
115
|
+
} : void 0,
|
|
116
|
+
footer: shell.footer ? {
|
|
117
|
+
...shell.footer,
|
|
118
|
+
links: sortByOrderThenTitle(shell.footer.links ?? [])
|
|
119
|
+
} : void 0,
|
|
120
|
+
workspace: shell.workspace ? normalizeWorkspace(shell.workspace) : void 0
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function normalizeWorkspace(workspace) {
|
|
124
|
+
return {
|
|
125
|
+
...workspace,
|
|
126
|
+
sections: sortByOrderThenTitle(workspace.sections ?? []).map((section) => ({
|
|
127
|
+
...section,
|
|
128
|
+
roots: sortByOrderThenTitle(section.roots ?? [])
|
|
129
|
+
}))
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function normalizeMenu(menu) {
|
|
133
|
+
if (!menu) return void 0;
|
|
134
|
+
return { groups: sortByOrderThenTitle(Array.isArray(menu) ? menu : menu.groups).map((group) => ({
|
|
135
|
+
...group,
|
|
136
|
+
items: normalizeMenuItems(group.items ?? [])
|
|
137
|
+
})) };
|
|
138
|
+
}
|
|
139
|
+
function normalizeMenuItems(items) {
|
|
140
|
+
return sortByOrderThenTitle(items).map((item) => ({
|
|
141
|
+
...item,
|
|
142
|
+
children: item.children ? normalizeMenuItems(item.children) : void 0
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
function sortByOrderThenTitle(items) {
|
|
146
|
+
return [...items].sort((left, right) => normalizeOrder(left.order) - normalizeOrder(right.order) || (left.title ?? left.id ?? "").localeCompare(right.title ?? right.id ?? ""));
|
|
147
|
+
}
|
|
148
|
+
function normalizeOrder(order) {
|
|
149
|
+
return order ?? Number.MAX_SAFE_INTEGER;
|
|
150
|
+
}
|
|
151
|
+
async function hasDirectory(reader, path) {
|
|
152
|
+
try {
|
|
153
|
+
const result = await reader.list(path);
|
|
154
|
+
return Array.isArray(result.data);
|
|
155
|
+
} catch {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
async function listVisible(reader, path) {
|
|
160
|
+
return ((await reader.list(path)).data ?? []).filter((entry) => entry?.id && !entry.id.startsWith("."));
|
|
161
|
+
}
|
|
162
|
+
async function readOptionalJSON(reader, path) {
|
|
163
|
+
try {
|
|
164
|
+
return await readJSON(reader, path);
|
|
165
|
+
} catch {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
async function readOptionalText(reader, path) {
|
|
170
|
+
try {
|
|
171
|
+
const data = (await reader.read(path)).data;
|
|
172
|
+
const content = data && typeof data === "object" && "content" in data ? data.content : data;
|
|
173
|
+
return typeof content === "string" ? content : void 0;
|
|
174
|
+
} catch {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
async function readJSON(reader, path) {
|
|
179
|
+
const data = (await reader.read(path)).data;
|
|
180
|
+
const content = data && typeof data === "object" && "content" in data ? data.content : data;
|
|
181
|
+
if (typeof content === "string") return JSON.parse(content);
|
|
182
|
+
if (content && typeof content === "object") return content;
|
|
183
|
+
throw new Error(`Expected JSON object in "${path}"`);
|
|
184
|
+
}
|
|
185
|
+
function isDirectoryEntry(entry) {
|
|
186
|
+
const meta = entry.meta ?? {};
|
|
187
|
+
return meta.kind === "fs:directory" || meta.kind === "directory" || Array.isArray(meta.kinds) && meta.kinds.includes("fs:directory") || typeof meta.childrenCount === "number";
|
|
188
|
+
}
|
|
189
|
+
function entryPath(parentPath, entry) {
|
|
190
|
+
return entry.path || (0, ufo.joinURL)(parentPath, entry.id);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
//#endregion
|
|
194
|
+
exports.DEFAULT_SCAFFOLD_ROOT = DEFAULT_SCAFFOLD_ROOT;
|
|
195
|
+
exports.loadScaffoldDefinition = loadScaffoldDefinition;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ScaffoldDefinition } from "./types.cjs";
|
|
2
|
+
import { AFSListResult, AFSReadResult } from "@aigne/afs";
|
|
3
|
+
|
|
4
|
+
//#region src/scaffold/afs.d.ts
|
|
5
|
+
declare const DEFAULT_SCAFFOLD_ROOT = "/.scaffold";
|
|
6
|
+
interface ScaffoldAfsReader {
|
|
7
|
+
list(path: string): Promise<AFSListResult>;
|
|
8
|
+
read(path: string): Promise<AFSReadResult>;
|
|
9
|
+
}
|
|
10
|
+
interface LoadScaffoldDefinitionOptions {
|
|
11
|
+
root?: string;
|
|
12
|
+
}
|
|
13
|
+
declare function loadScaffoldDefinition(reader: ScaffoldAfsReader, options?: LoadScaffoldDefinitionOptions): Promise<ScaffoldDefinition>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { DEFAULT_SCAFFOLD_ROOT, LoadScaffoldDefinitionOptions, ScaffoldAfsReader, loadScaffoldDefinition };
|
|
16
|
+
//# sourceMappingURL=afs.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"afs.d.cts","names":[],"sources":["../../src/scaffold/afs.ts"],"mappings":";;;;cAoBa,qBAAA;AAAA,UAEI,iBAAA;EACf,IAAA,CAAK,IAAA,WAAe,OAAA,CAAQ,aAAA;EAC5B,IAAA,CAAK,IAAA,WAAe,OAAA,CAAQ,aAAA;AAAA;AAAA,UAGb,6BAAA;EACf,IAAA;AAAA;AAAA,iBAGoB,sBAAA,CACpB,MAAA,EAAQ,iBAAA,EACR,OAAA,GAAS,6BAAA,GACR,OAAA,CAAQ,kBAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ScaffoldDefinition } from "./types.mjs";
|
|
2
|
+
import { AFSListResult, AFSReadResult } from "@aigne/afs";
|
|
3
|
+
|
|
4
|
+
//#region src/scaffold/afs.d.ts
|
|
5
|
+
declare const DEFAULT_SCAFFOLD_ROOT = "/.scaffold";
|
|
6
|
+
interface ScaffoldAfsReader {
|
|
7
|
+
list(path: string): Promise<AFSListResult>;
|
|
8
|
+
read(path: string): Promise<AFSReadResult>;
|
|
9
|
+
}
|
|
10
|
+
interface LoadScaffoldDefinitionOptions {
|
|
11
|
+
root?: string;
|
|
12
|
+
}
|
|
13
|
+
declare function loadScaffoldDefinition(reader: ScaffoldAfsReader, options?: LoadScaffoldDefinitionOptions): Promise<ScaffoldDefinition>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { DEFAULT_SCAFFOLD_ROOT, LoadScaffoldDefinitionOptions, ScaffoldAfsReader, loadScaffoldDefinition };
|
|
16
|
+
//# sourceMappingURL=afs.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"afs.d.mts","names":[],"sources":["../../src/scaffold/afs.ts"],"mappings":";;;;cAoBa,qBAAA;AAAA,UAEI,iBAAA;EACf,IAAA,CAAK,IAAA,WAAe,OAAA,CAAQ,aAAA;EAC5B,IAAA,CAAK,IAAA,WAAe,OAAA,CAAQ,aAAA;AAAA;AAAA,UAGb,6BAAA;EACf,IAAA;AAAA;AAAA,iBAGoB,sBAAA,CACpB,MAAA,EAAQ,iBAAA,EACR,OAAA,GAAS,6BAAA,GACR,OAAA,CAAQ,kBAAA"}
|