@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,56 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/system-mounts/validate.ts
|
|
3
|
+
/**
|
|
4
|
+
* Property names that, if present on a descriptor's `options`, could pollute
|
|
5
|
+
* `Object.prototype` when later spread/merged into a provider config. Reject
|
|
6
|
+
* descriptors carrying them outright.
|
|
7
|
+
*/
|
|
8
|
+
const FORBIDDEN_OPTION_KEYS = [
|
|
9
|
+
"__proto__",
|
|
10
|
+
"constructor",
|
|
11
|
+
"prototype"
|
|
12
|
+
];
|
|
13
|
+
/**
|
|
14
|
+
* Validate a single descriptor. Checks:
|
|
15
|
+
* - `path` is a non-empty string, starts with `/`, has no `..` segment, and
|
|
16
|
+
* no empty (`//`) segment — closes the leak vector where a `..` could
|
|
17
|
+
* project a mount outside its namespace.
|
|
18
|
+
* - either `providerKey` (non-empty string) or `install` (function) is
|
|
19
|
+
* present — a descriptor with neither is unmountable.
|
|
20
|
+
* - `order` is a finite number.
|
|
21
|
+
* - `options`, when an object, carries no prototype-pollution key.
|
|
22
|
+
*
|
|
23
|
+
* Pure: does not mutate `descriptor`. Tolerant of `null`/non-object input
|
|
24
|
+
* (returns `ok: false`) so a malformed list entry can't crash the driver.
|
|
25
|
+
*/
|
|
26
|
+
function validateDescriptor(descriptor) {
|
|
27
|
+
const errors = [];
|
|
28
|
+
if (descriptor === null || typeof descriptor !== "object") return {
|
|
29
|
+
ok: false,
|
|
30
|
+
errors: ["descriptor must be an object"]
|
|
31
|
+
};
|
|
32
|
+
const d = descriptor;
|
|
33
|
+
if (typeof d.path !== "string" || d.path.length === 0) errors.push("path must be a non-empty string");
|
|
34
|
+
else {
|
|
35
|
+
if (!d.path.startsWith("/")) errors.push(`path must start with '/' (got '${d.path}')`);
|
|
36
|
+
const segments = d.path.split("/");
|
|
37
|
+
if (segments.some((seg) => seg === "..")) errors.push(`path must not contain '..' segments (got '${d.path}')`);
|
|
38
|
+
if (segments.slice(1).some((seg) => seg.length === 0) && d.path !== "/") errors.push(`path must not contain empty segments (got '${d.path}')`);
|
|
39
|
+
}
|
|
40
|
+
const hasProviderKey = typeof d.providerKey === "string" && d.providerKey.length > 0;
|
|
41
|
+
const hasInstall = typeof d.install === "function";
|
|
42
|
+
if (!hasProviderKey && !hasInstall) errors.push("descriptor must have a non-empty 'providerKey' or an 'install' function");
|
|
43
|
+
if (typeof d.order !== "number" || !Number.isFinite(d.order)) errors.push("order must be a finite number");
|
|
44
|
+
if (d.options !== void 0 && typeof d.options !== "function") if (d.options === null || typeof d.options !== "object") errors.push("options must be an object or a function");
|
|
45
|
+
else {
|
|
46
|
+
const names = Object.getOwnPropertyNames(d.options);
|
|
47
|
+
for (const forbidden of FORBIDDEN_OPTION_KEYS) if (names.includes(forbidden)) errors.push(`options must not contain forbidden key '${forbidden}'`);
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
ok: errors.length === 0,
|
|
51
|
+
errors
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
exports.validateDescriptor = validateDescriptor;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/system-mounts/validate.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Pure validation for {@link SystemMountDescriptor}. Lives in Phase 0 so the
|
|
4
|
+
* security/leak/damage surface is closed before any runtime driver consumes
|
|
5
|
+
* the descriptors — Phase 1's `installSystemMounts` reuses this exact
|
|
6
|
+
* function to skip-and-warn on invalid entries.
|
|
7
|
+
*
|
|
8
|
+
* `validateDescriptor` is a pure function: it only reads its input and never
|
|
9
|
+
* mutates it. It returns a result object rather than throwing so the driver
|
|
10
|
+
* can validate a whole list and skip individual bad entries without aborting
|
|
11
|
+
* the rest.
|
|
12
|
+
*/
|
|
13
|
+
/** Result of {@link validateDescriptor}. */
|
|
14
|
+
interface ValidateResult {
|
|
15
|
+
ok: boolean;
|
|
16
|
+
errors: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Validate a single descriptor. Checks:
|
|
20
|
+
* - `path` is a non-empty string, starts with `/`, has no `..` segment, and
|
|
21
|
+
* no empty (`//`) segment — closes the leak vector where a `..` could
|
|
22
|
+
* project a mount outside its namespace.
|
|
23
|
+
* - either `providerKey` (non-empty string) or `install` (function) is
|
|
24
|
+
* present — a descriptor with neither is unmountable.
|
|
25
|
+
* - `order` is a finite number.
|
|
26
|
+
* - `options`, when an object, carries no prototype-pollution key.
|
|
27
|
+
*
|
|
28
|
+
* Pure: does not mutate `descriptor`. Tolerant of `null`/non-object input
|
|
29
|
+
* (returns `ok: false`) so a malformed list entry can't crash the driver.
|
|
30
|
+
*/
|
|
31
|
+
declare function validateDescriptor(descriptor: unknown): ValidateResult;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { ValidateResult, validateDescriptor };
|
|
34
|
+
//# sourceMappingURL=validate.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.cts","names":[],"sources":["../../src/system-mounts/validate.ts"],"mappings":";;AAeA;;;;;AAyBA;;;;;;UAzBiB,cAAA;EACf,EAAA;EACA,MAAA;AAAA;;;;;;;;;;;;;;iBAuBc,kBAAA,CAAmB,UAAA,YAAsB,cAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/system-mounts/validate.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Pure validation for {@link SystemMountDescriptor}. Lives in Phase 0 so the
|
|
4
|
+
* security/leak/damage surface is closed before any runtime driver consumes
|
|
5
|
+
* the descriptors — Phase 1's `installSystemMounts` reuses this exact
|
|
6
|
+
* function to skip-and-warn on invalid entries.
|
|
7
|
+
*
|
|
8
|
+
* `validateDescriptor` is a pure function: it only reads its input and never
|
|
9
|
+
* mutates it. It returns a result object rather than throwing so the driver
|
|
10
|
+
* can validate a whole list and skip individual bad entries without aborting
|
|
11
|
+
* the rest.
|
|
12
|
+
*/
|
|
13
|
+
/** Result of {@link validateDescriptor}. */
|
|
14
|
+
interface ValidateResult {
|
|
15
|
+
ok: boolean;
|
|
16
|
+
errors: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Validate a single descriptor. Checks:
|
|
20
|
+
* - `path` is a non-empty string, starts with `/`, has no `..` segment, and
|
|
21
|
+
* no empty (`//`) segment — closes the leak vector where a `..` could
|
|
22
|
+
* project a mount outside its namespace.
|
|
23
|
+
* - either `providerKey` (non-empty string) or `install` (function) is
|
|
24
|
+
* present — a descriptor with neither is unmountable.
|
|
25
|
+
* - `order` is a finite number.
|
|
26
|
+
* - `options`, when an object, carries no prototype-pollution key.
|
|
27
|
+
*
|
|
28
|
+
* Pure: does not mutate `descriptor`. Tolerant of `null`/non-object input
|
|
29
|
+
* (returns `ok: false`) so a malformed list entry can't crash the driver.
|
|
30
|
+
*/
|
|
31
|
+
declare function validateDescriptor(descriptor: unknown): ValidateResult;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { ValidateResult, validateDescriptor };
|
|
34
|
+
//# sourceMappingURL=validate.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.mts","names":[],"sources":["../../src/system-mounts/validate.ts"],"mappings":";;AAeA;;;;;AAyBA;;;;;;UAzBiB,cAAA;EACf,EAAA;EACA,MAAA;AAAA;;;;;;;;;;;;;;iBAuBc,kBAAA,CAAmB,UAAA,YAAsB,cAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//#region src/system-mounts/validate.ts
|
|
2
|
+
/**
|
|
3
|
+
* Property names that, if present on a descriptor's `options`, could pollute
|
|
4
|
+
* `Object.prototype` when later spread/merged into a provider config. Reject
|
|
5
|
+
* descriptors carrying them outright.
|
|
6
|
+
*/
|
|
7
|
+
const FORBIDDEN_OPTION_KEYS = [
|
|
8
|
+
"__proto__",
|
|
9
|
+
"constructor",
|
|
10
|
+
"prototype"
|
|
11
|
+
];
|
|
12
|
+
/**
|
|
13
|
+
* Validate a single descriptor. Checks:
|
|
14
|
+
* - `path` is a non-empty string, starts with `/`, has no `..` segment, and
|
|
15
|
+
* no empty (`//`) segment — closes the leak vector where a `..` could
|
|
16
|
+
* project a mount outside its namespace.
|
|
17
|
+
* - either `providerKey` (non-empty string) or `install` (function) is
|
|
18
|
+
* present — a descriptor with neither is unmountable.
|
|
19
|
+
* - `order` is a finite number.
|
|
20
|
+
* - `options`, when an object, carries no prototype-pollution key.
|
|
21
|
+
*
|
|
22
|
+
* Pure: does not mutate `descriptor`. Tolerant of `null`/non-object input
|
|
23
|
+
* (returns `ok: false`) so a malformed list entry can't crash the driver.
|
|
24
|
+
*/
|
|
25
|
+
function validateDescriptor(descriptor) {
|
|
26
|
+
const errors = [];
|
|
27
|
+
if (descriptor === null || typeof descriptor !== "object") return {
|
|
28
|
+
ok: false,
|
|
29
|
+
errors: ["descriptor must be an object"]
|
|
30
|
+
};
|
|
31
|
+
const d = descriptor;
|
|
32
|
+
if (typeof d.path !== "string" || d.path.length === 0) errors.push("path must be a non-empty string");
|
|
33
|
+
else {
|
|
34
|
+
if (!d.path.startsWith("/")) errors.push(`path must start with '/' (got '${d.path}')`);
|
|
35
|
+
const segments = d.path.split("/");
|
|
36
|
+
if (segments.some((seg) => seg === "..")) errors.push(`path must not contain '..' segments (got '${d.path}')`);
|
|
37
|
+
if (segments.slice(1).some((seg) => seg.length === 0) && d.path !== "/") errors.push(`path must not contain empty segments (got '${d.path}')`);
|
|
38
|
+
}
|
|
39
|
+
const hasProviderKey = typeof d.providerKey === "string" && d.providerKey.length > 0;
|
|
40
|
+
const hasInstall = typeof d.install === "function";
|
|
41
|
+
if (!hasProviderKey && !hasInstall) errors.push("descriptor must have a non-empty 'providerKey' or an 'install' function");
|
|
42
|
+
if (typeof d.order !== "number" || !Number.isFinite(d.order)) errors.push("order must be a finite number");
|
|
43
|
+
if (d.options !== void 0 && typeof d.options !== "function") if (d.options === null || typeof d.options !== "object") errors.push("options must be an object or a function");
|
|
44
|
+
else {
|
|
45
|
+
const names = Object.getOwnPropertyNames(d.options);
|
|
46
|
+
for (const forbidden of FORBIDDEN_OPTION_KEYS) if (names.includes(forbidden)) errors.push(`options must not contain forbidden key '${forbidden}'`);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
ok: errors.length === 0,
|
|
50
|
+
errors
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
export { validateDescriptor };
|
|
56
|
+
//# sourceMappingURL=validate.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.mjs","names":[],"sources":["../../src/system-mounts/validate.ts"],"sourcesContent":["/**\n * Pure validation for {@link SystemMountDescriptor}. Lives in Phase 0 so the\n * security/leak/damage surface is closed before any runtime driver consumes\n * the descriptors — Phase 1's `installSystemMounts` reuses this exact\n * function to skip-and-warn on invalid entries.\n *\n * `validateDescriptor` is a pure function: it only reads its input and never\n * mutates it. It returns a result object rather than throwing so the driver\n * can validate a whole list and skip individual bad entries without aborting\n * the rest.\n */\n\nimport type { SystemMountDescriptor } from \"./types.js\";\n\n/** Result of {@link validateDescriptor}. */\nexport interface ValidateResult {\n ok: boolean;\n errors: string[];\n}\n\n/**\n * Property names that, if present on a descriptor's `options`, could pollute\n * `Object.prototype` when later spread/merged into a provider config. Reject\n * descriptors carrying them outright.\n */\nconst FORBIDDEN_OPTION_KEYS = [\"__proto__\", \"constructor\", \"prototype\"] as const;\n\n/**\n * Validate a single descriptor. Checks:\n * - `path` is a non-empty string, starts with `/`, has no `..` segment, and\n * no empty (`//`) segment — closes the leak vector where a `..` could\n * project a mount outside its namespace.\n * - either `providerKey` (non-empty string) or `install` (function) is\n * present — a descriptor with neither is unmountable.\n * - `order` is a finite number.\n * - `options`, when an object, carries no prototype-pollution key.\n *\n * Pure: does not mutate `descriptor`. Tolerant of `null`/non-object input\n * (returns `ok: false`) so a malformed list entry can't crash the driver.\n */\nexport function validateDescriptor(descriptor: unknown): ValidateResult {\n const errors: string[] = [];\n\n if (descriptor === null || typeof descriptor !== \"object\") {\n return { ok: false, errors: [\"descriptor must be an object\"] };\n }\n\n const d = descriptor as Partial<SystemMountDescriptor>;\n\n // ── path ──\n if (typeof d.path !== \"string\" || d.path.length === 0) {\n errors.push(\"path must be a non-empty string\");\n } else {\n if (!d.path.startsWith(\"/\")) {\n errors.push(`path must start with '/' (got '${d.path}')`);\n }\n const segments = d.path.split(\"/\");\n // segments[0] is always \"\" for an absolute path; reject empty segments\n // anywhere else (covers '//', trailing '/', etc.) and any '..' segment.\n if (segments.some((seg) => seg === \"..\")) {\n errors.push(`path must not contain '..' segments (got '${d.path}')`);\n }\n if (segments.slice(1).some((seg) => seg.length === 0) && d.path !== \"/\") {\n errors.push(`path must not contain empty segments (got '${d.path}')`);\n }\n }\n\n // ── providerKey / install ──\n const hasProviderKey = typeof d.providerKey === \"string\" && d.providerKey.length > 0;\n const hasInstall = typeof d.install === \"function\";\n if (!hasProviderKey && !hasInstall) {\n errors.push(\"descriptor must have a non-empty 'providerKey' or an 'install' function\");\n }\n\n // ── order ──\n if (typeof d.order !== \"number\" || !Number.isFinite(d.order)) {\n errors.push(\"order must be a finite number\");\n }\n\n // ── options prototype-pollution guard ──\n // Only scan literal objects; function-form options are resolved + scanned\n // at install time. `Object.getOwnPropertyNames` catches JSON.parse's\n // own \"__proto__\" property (which Object.keys also surfaces, but be\n // explicit so a non-enumerable plant is caught too).\n if (d.options !== undefined && typeof d.options !== \"function\") {\n if (d.options === null || typeof d.options !== \"object\") {\n errors.push(\"options must be an object or a function\");\n } else {\n const names = Object.getOwnPropertyNames(d.options);\n for (const forbidden of FORBIDDEN_OPTION_KEYS) {\n if (names.includes(forbidden)) {\n errors.push(`options must not contain forbidden key '${forbidden}'`);\n }\n }\n }\n }\n\n return { ok: errors.length === 0, errors };\n}\n"],"mappings":";;;;;;AAyBA,MAAM,wBAAwB;CAAC;CAAa;CAAe;CAAY;;;;;;;;;;;;;;AAevE,SAAgB,mBAAmB,YAAqC;CACtE,MAAM,SAAmB,EAAE;AAE3B,KAAI,eAAe,QAAQ,OAAO,eAAe,SAC/C,QAAO;EAAE,IAAI;EAAO,QAAQ,CAAC,+BAA+B;EAAE;CAGhE,MAAM,IAAI;AAGV,KAAI,OAAO,EAAE,SAAS,YAAY,EAAE,KAAK,WAAW,EAClD,QAAO,KAAK,kCAAkC;MACzC;AACL,MAAI,CAAC,EAAE,KAAK,WAAW,IAAI,CACzB,QAAO,KAAK,kCAAkC,EAAE,KAAK,IAAI;EAE3D,MAAM,WAAW,EAAE,KAAK,MAAM,IAAI;AAGlC,MAAI,SAAS,MAAM,QAAQ,QAAQ,KAAK,CACtC,QAAO,KAAK,6CAA6C,EAAE,KAAK,IAAI;AAEtE,MAAI,SAAS,MAAM,EAAE,CAAC,MAAM,QAAQ,IAAI,WAAW,EAAE,IAAI,EAAE,SAAS,IAClE,QAAO,KAAK,8CAA8C,EAAE,KAAK,IAAI;;CAKzE,MAAM,iBAAiB,OAAO,EAAE,gBAAgB,YAAY,EAAE,YAAY,SAAS;CACnF,MAAM,aAAa,OAAO,EAAE,YAAY;AACxC,KAAI,CAAC,kBAAkB,CAAC,WACtB,QAAO,KAAK,0EAA0E;AAIxF,KAAI,OAAO,EAAE,UAAU,YAAY,CAAC,OAAO,SAAS,EAAE,MAAM,CAC1D,QAAO,KAAK,gCAAgC;AAQ9C,KAAI,EAAE,YAAY,UAAa,OAAO,EAAE,YAAY,WAClD,KAAI,EAAE,YAAY,QAAQ,OAAO,EAAE,YAAY,SAC7C,QAAO,KAAK,0CAA0C;MACjD;EACL,MAAM,QAAQ,OAAO,oBAAoB,EAAE,QAAQ;AACnD,OAAK,MAAM,aAAa,sBACtB,KAAI,MAAM,SAAS,UAAU,CAC3B,QAAO,KAAK,2CAA2C,UAAU,GAAG;;AAM5E,QAAO;EAAE,IAAI,OAAO,WAAW;EAAG;EAAQ"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/terminal-llm.ts
|
|
3
|
+
const HISTORY_TURNS = 20;
|
|
4
|
+
const R = "\x1B[0m";
|
|
5
|
+
const LLM_PROMPT_COLOR = `\x1b[1;32m›${R} `;
|
|
6
|
+
const LLM_PROMPT_PLAIN = "› ";
|
|
7
|
+
function genSessionId() {
|
|
8
|
+
const buf = new Uint8Array(8);
|
|
9
|
+
crypto.getRandomValues(buf);
|
|
10
|
+
return Array.from(buf, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Create a platform-agnostic LLM terminal session.
|
|
14
|
+
*
|
|
15
|
+
* Requires AFS to have an AI provider mounted at /dev/ai/ (or at the path
|
|
16
|
+
* returned by opts.model). On CF Workers this is CfAnthropicProvider; on
|
|
17
|
+
* Node it is AFSAIDevice.
|
|
18
|
+
*/
|
|
19
|
+
function createLlmTerminalSession(afs, opts) {
|
|
20
|
+
const sessionId = genSessionId();
|
|
21
|
+
const color = opts.color !== false;
|
|
22
|
+
const modelPath = opts.model ?? "/dev/ai/.actions/chat";
|
|
23
|
+
const chatPath = /\/\.actions\/(chat|embed|image|video)$/.test(modelPath) ? modelPath : `${modelPath}/.actions/chat`;
|
|
24
|
+
const description = opts.description ?? opts.systemPrompt?.split("\n")[0]?.trim().slice(0, 80) ?? "No tools, no memory beyond this session.";
|
|
25
|
+
const banner = [
|
|
26
|
+
"",
|
|
27
|
+
color ? `\x1b[1;36m● llm-terminal${R} \x1b[2m—${R} ${modelPath}` : `● llm-terminal — ${modelPath}`,
|
|
28
|
+
color ? `\x1b[2m${description}${R}` : description,
|
|
29
|
+
""
|
|
30
|
+
].join("\r\n");
|
|
31
|
+
const systemMessages = opts.systemPrompt ? [{
|
|
32
|
+
role: "system",
|
|
33
|
+
content: opts.systemPrompt
|
|
34
|
+
}] : [];
|
|
35
|
+
const history = [];
|
|
36
|
+
let inflight = false;
|
|
37
|
+
return {
|
|
38
|
+
sessionId,
|
|
39
|
+
getBanner() {
|
|
40
|
+
return banner;
|
|
41
|
+
},
|
|
42
|
+
getPrompt() {
|
|
43
|
+
return color ? LLM_PROMPT_COLOR : LLM_PROMPT_PLAIN;
|
|
44
|
+
},
|
|
45
|
+
async route(line, onToken) {
|
|
46
|
+
const trimmed = line.trim();
|
|
47
|
+
if (!trimmed) return {};
|
|
48
|
+
if (trimmed === "exit" || trimmed === "quit") return { exit: true };
|
|
49
|
+
if (inflight) return { busy: true };
|
|
50
|
+
inflight = true;
|
|
51
|
+
history.push({
|
|
52
|
+
role: "user",
|
|
53
|
+
content: trimmed
|
|
54
|
+
});
|
|
55
|
+
if (history.length > HISTORY_TURNS * 2) history.splice(0, history.length - HISTORY_TURNS * 2);
|
|
56
|
+
let streamed = "";
|
|
57
|
+
try {
|
|
58
|
+
const execOptions = onToken ? { onChunk: (chunk) => {
|
|
59
|
+
if (chunk.text) {
|
|
60
|
+
streamed += chunk.text;
|
|
61
|
+
onToken(chunk.text);
|
|
62
|
+
}
|
|
63
|
+
} } : {};
|
|
64
|
+
const result = await afs.exec(chatPath, { messages: [...systemMessages, ...history] }, execOptions);
|
|
65
|
+
const text = streamed || result?.success && result.data?.text || "(no response)";
|
|
66
|
+
if (!streamed) {
|
|
67
|
+
history.push({
|
|
68
|
+
role: "assistant",
|
|
69
|
+
content: text
|
|
70
|
+
});
|
|
71
|
+
return { output: text };
|
|
72
|
+
}
|
|
73
|
+
history.push({
|
|
74
|
+
role: "assistant",
|
|
75
|
+
content: streamed
|
|
76
|
+
});
|
|
77
|
+
return {};
|
|
78
|
+
} catch (err) {
|
|
79
|
+
history.pop();
|
|
80
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
81
|
+
return { output: color ? `\x1b[31mError: ${msg}${R}` : `Error: ${msg}` };
|
|
82
|
+
} finally {
|
|
83
|
+
inflight = false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
exports.createLlmTerminalSession = createLlmTerminalSession;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { AFS } from "@aigne/afs";
|
|
2
|
+
|
|
3
|
+
//#region src/terminal-llm.d.ts
|
|
4
|
+
interface LlmTerminalOptions {
|
|
5
|
+
/** AFS path to the model/action node. Defaults to "/dev/ai/.actions/chat". */
|
|
6
|
+
model?: string;
|
|
7
|
+
/** System prompt content (read from blocklet by caller). */
|
|
8
|
+
systemPrompt?: string;
|
|
9
|
+
/** Override the description line shown in the banner. */
|
|
10
|
+
description?: string;
|
|
11
|
+
/** Use ANSI color. Default: true. */
|
|
12
|
+
color?: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface LlmTerminalResult {
|
|
15
|
+
/**
|
|
16
|
+
* Complete response text (populated when onToken was NOT provided).
|
|
17
|
+
* When onToken is given, tokens are already streamed — output is undefined.
|
|
18
|
+
*/
|
|
19
|
+
output?: string;
|
|
20
|
+
/** Session is ending — caller should close the connection. */
|
|
21
|
+
exit?: boolean;
|
|
22
|
+
/** A previous request is still in flight — caller should notify the user. */
|
|
23
|
+
busy?: boolean;
|
|
24
|
+
}
|
|
25
|
+
interface LlmTerminalSession {
|
|
26
|
+
readonly sessionId: string;
|
|
27
|
+
/** Banner string to display on connect (CRLF line endings). */
|
|
28
|
+
getBanner(): string;
|
|
29
|
+
/** Prompt string (e.g. `\x1b[1;32m›\x1b[0m `). */
|
|
30
|
+
getPrompt(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Route a line of user input.
|
|
33
|
+
*
|
|
34
|
+
* If onToken is provided, streamed tokens are forwarded to it as they arrive
|
|
35
|
+
* and result.output is undefined (tokens were already delivered).
|
|
36
|
+
* If onToken is omitted, the complete response is in result.output.
|
|
37
|
+
*/
|
|
38
|
+
route(line: string, onToken?: (token: string) => void): Promise<LlmTerminalResult>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create a platform-agnostic LLM terminal session.
|
|
42
|
+
*
|
|
43
|
+
* Requires AFS to have an AI provider mounted at /dev/ai/ (or at the path
|
|
44
|
+
* returned by opts.model). On CF Workers this is CfAnthropicProvider; on
|
|
45
|
+
* Node it is AFSAIDevice.
|
|
46
|
+
*/
|
|
47
|
+
declare function createLlmTerminalSession(afs: AFS, opts: LlmTerminalOptions): LlmTerminalSession;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { LlmTerminalOptions, LlmTerminalResult, LlmTerminalSession, createLlmTerminalSession };
|
|
50
|
+
//# sourceMappingURL=terminal-llm.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-llm.d.cts","names":[],"sources":["../src/terminal-llm.ts"],"mappings":";;;UAkBiB,kBAAA;EAWA;EATf,KAAA;;EAEA,YAAA;EAYA;EAVA,WAAA;EAcA;EAZA,KAAA;AAAA;AAAA,UAGe,iBAAA;EAYkB;;;;EAPjC,MAAA;EAYA;EAVA,IAAA;EAkBM;EAhBN,IAAA;AAAA;AAAA,UAGe,kBAAA;EAAA,SACN,SAAA;EAYwE;EAVjF,SAAA;EA6Cc;EA3Cd,SAAA;;;;;;;;EAQA,KAAA,CAAM,IAAA,UAAc,OAAA,IAAW,KAAA,oBAAyB,OAAA,CAAQ,iBAAA;AAAA;;;;;;;;iBAmClD,wBAAA,CAAyB,GAAA,EAAK,GAAA,EAAK,IAAA,EAAM,kBAAA,GAAqB,kBAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { AFS } from "@aigne/afs";
|
|
2
|
+
|
|
3
|
+
//#region src/terminal-llm.d.ts
|
|
4
|
+
interface LlmTerminalOptions {
|
|
5
|
+
/** AFS path to the model/action node. Defaults to "/dev/ai/.actions/chat". */
|
|
6
|
+
model?: string;
|
|
7
|
+
/** System prompt content (read from blocklet by caller). */
|
|
8
|
+
systemPrompt?: string;
|
|
9
|
+
/** Override the description line shown in the banner. */
|
|
10
|
+
description?: string;
|
|
11
|
+
/** Use ANSI color. Default: true. */
|
|
12
|
+
color?: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface LlmTerminalResult {
|
|
15
|
+
/**
|
|
16
|
+
* Complete response text (populated when onToken was NOT provided).
|
|
17
|
+
* When onToken is given, tokens are already streamed — output is undefined.
|
|
18
|
+
*/
|
|
19
|
+
output?: string;
|
|
20
|
+
/** Session is ending — caller should close the connection. */
|
|
21
|
+
exit?: boolean;
|
|
22
|
+
/** A previous request is still in flight — caller should notify the user. */
|
|
23
|
+
busy?: boolean;
|
|
24
|
+
}
|
|
25
|
+
interface LlmTerminalSession {
|
|
26
|
+
readonly sessionId: string;
|
|
27
|
+
/** Banner string to display on connect (CRLF line endings). */
|
|
28
|
+
getBanner(): string;
|
|
29
|
+
/** Prompt string (e.g. `\x1b[1;32m›\x1b[0m `). */
|
|
30
|
+
getPrompt(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Route a line of user input.
|
|
33
|
+
*
|
|
34
|
+
* If onToken is provided, streamed tokens are forwarded to it as they arrive
|
|
35
|
+
* and result.output is undefined (tokens were already delivered).
|
|
36
|
+
* If onToken is omitted, the complete response is in result.output.
|
|
37
|
+
*/
|
|
38
|
+
route(line: string, onToken?: (token: string) => void): Promise<LlmTerminalResult>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create a platform-agnostic LLM terminal session.
|
|
42
|
+
*
|
|
43
|
+
* Requires AFS to have an AI provider mounted at /dev/ai/ (or at the path
|
|
44
|
+
* returned by opts.model). On CF Workers this is CfAnthropicProvider; on
|
|
45
|
+
* Node it is AFSAIDevice.
|
|
46
|
+
*/
|
|
47
|
+
declare function createLlmTerminalSession(afs: AFS, opts: LlmTerminalOptions): LlmTerminalSession;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { LlmTerminalOptions, LlmTerminalResult, LlmTerminalSession, createLlmTerminalSession };
|
|
50
|
+
//# sourceMappingURL=terminal-llm.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-llm.d.mts","names":[],"sources":["../src/terminal-llm.ts"],"mappings":";;;UAkBiB,kBAAA;EAWA;EATf,KAAA;;EAEA,YAAA;EAYA;EAVA,WAAA;EAcA;EAZA,KAAA;AAAA;AAAA,UAGe,iBAAA;EAYkB;;;;EAPjC,MAAA;EAYA;EAVA,IAAA;EAkBM;EAhBN,IAAA;AAAA;AAAA,UAGe,kBAAA;EAAA,SACN,SAAA;EAYwE;EAVjF,SAAA;EA6Cc;EA3Cd,SAAA;;;;;;;;EAQA,KAAA,CAAM,IAAA,UAAc,OAAA,IAAW,KAAA,oBAAyB,OAAA,CAAQ,iBAAA;AAAA;;;;;;;;iBAmClD,wBAAA,CAAyB,GAAA,EAAK,GAAA,EAAK,IAAA,EAAM,kBAAA,GAAqB,kBAAA"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
//#region src/terminal-llm.ts
|
|
2
|
+
const HISTORY_TURNS = 20;
|
|
3
|
+
const R = "\x1B[0m";
|
|
4
|
+
const LLM_PROMPT_COLOR = `\x1b[1;32m›${R} `;
|
|
5
|
+
const LLM_PROMPT_PLAIN = "› ";
|
|
6
|
+
function genSessionId() {
|
|
7
|
+
const buf = new Uint8Array(8);
|
|
8
|
+
crypto.getRandomValues(buf);
|
|
9
|
+
return Array.from(buf, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Create a platform-agnostic LLM terminal session.
|
|
13
|
+
*
|
|
14
|
+
* Requires AFS to have an AI provider mounted at /dev/ai/ (or at the path
|
|
15
|
+
* returned by opts.model). On CF Workers this is CfAnthropicProvider; on
|
|
16
|
+
* Node it is AFSAIDevice.
|
|
17
|
+
*/
|
|
18
|
+
function createLlmTerminalSession(afs, opts) {
|
|
19
|
+
const sessionId = genSessionId();
|
|
20
|
+
const color = opts.color !== false;
|
|
21
|
+
const modelPath = opts.model ?? "/dev/ai/.actions/chat";
|
|
22
|
+
const chatPath = /\/\.actions\/(chat|embed|image|video)$/.test(modelPath) ? modelPath : `${modelPath}/.actions/chat`;
|
|
23
|
+
const description = opts.description ?? opts.systemPrompt?.split("\n")[0]?.trim().slice(0, 80) ?? "No tools, no memory beyond this session.";
|
|
24
|
+
const banner = [
|
|
25
|
+
"",
|
|
26
|
+
color ? `\x1b[1;36m● llm-terminal${R} \x1b[2m—${R} ${modelPath}` : `● llm-terminal — ${modelPath}`,
|
|
27
|
+
color ? `\x1b[2m${description}${R}` : description,
|
|
28
|
+
""
|
|
29
|
+
].join("\r\n");
|
|
30
|
+
const systemMessages = opts.systemPrompt ? [{
|
|
31
|
+
role: "system",
|
|
32
|
+
content: opts.systemPrompt
|
|
33
|
+
}] : [];
|
|
34
|
+
const history = [];
|
|
35
|
+
let inflight = false;
|
|
36
|
+
return {
|
|
37
|
+
sessionId,
|
|
38
|
+
getBanner() {
|
|
39
|
+
return banner;
|
|
40
|
+
},
|
|
41
|
+
getPrompt() {
|
|
42
|
+
return color ? LLM_PROMPT_COLOR : LLM_PROMPT_PLAIN;
|
|
43
|
+
},
|
|
44
|
+
async route(line, onToken) {
|
|
45
|
+
const trimmed = line.trim();
|
|
46
|
+
if (!trimmed) return {};
|
|
47
|
+
if (trimmed === "exit" || trimmed === "quit") return { exit: true };
|
|
48
|
+
if (inflight) return { busy: true };
|
|
49
|
+
inflight = true;
|
|
50
|
+
history.push({
|
|
51
|
+
role: "user",
|
|
52
|
+
content: trimmed
|
|
53
|
+
});
|
|
54
|
+
if (history.length > HISTORY_TURNS * 2) history.splice(0, history.length - HISTORY_TURNS * 2);
|
|
55
|
+
let streamed = "";
|
|
56
|
+
try {
|
|
57
|
+
const execOptions = onToken ? { onChunk: (chunk) => {
|
|
58
|
+
if (chunk.text) {
|
|
59
|
+
streamed += chunk.text;
|
|
60
|
+
onToken(chunk.text);
|
|
61
|
+
}
|
|
62
|
+
} } : {};
|
|
63
|
+
const result = await afs.exec(chatPath, { messages: [...systemMessages, ...history] }, execOptions);
|
|
64
|
+
const text = streamed || result?.success && result.data?.text || "(no response)";
|
|
65
|
+
if (!streamed) {
|
|
66
|
+
history.push({
|
|
67
|
+
role: "assistant",
|
|
68
|
+
content: text
|
|
69
|
+
});
|
|
70
|
+
return { output: text };
|
|
71
|
+
}
|
|
72
|
+
history.push({
|
|
73
|
+
role: "assistant",
|
|
74
|
+
content: streamed
|
|
75
|
+
});
|
|
76
|
+
return {};
|
|
77
|
+
} catch (err) {
|
|
78
|
+
history.pop();
|
|
79
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
80
|
+
return { output: color ? `\x1b[31mError: ${msg}${R}` : `Error: ${msg}` };
|
|
81
|
+
} finally {
|
|
82
|
+
inflight = false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
export { createLlmTerminalSession };
|
|
90
|
+
//# sourceMappingURL=terminal-llm.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-llm.mjs","names":[],"sources":["../src/terminal-llm.ts"],"sourcesContent":["/**\n * Shared LLM terminal session — portable, CF-compatible.\n *\n * Business logic for the conversational AI terminal:\n * - Banner (● llm-terminal — <model>) and prompt (›)\n * - History management and inflight guard\n * - Routes user input through afs.exec(\"/dev/ai/.actions/chat\") — AFS-only I/O\n *\n * Transport (WebSocket send/receive, markdown rendering) is left to the caller.\n * The caller receives raw token text via onToken and decides how to render it.\n */\n\nimport type { AFS } from \"@aigne/afs\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface LlmTerminalOptions {\n /** AFS path to the model/action node. Defaults to \"/dev/ai/.actions/chat\". */\n model?: string;\n /** System prompt content (read from blocklet by caller). */\n systemPrompt?: string;\n /** Override the description line shown in the banner. */\n description?: string;\n /** Use ANSI color. Default: true. */\n color?: boolean;\n}\n\nexport interface LlmTerminalResult {\n /**\n * Complete response text (populated when onToken was NOT provided).\n * When onToken is given, tokens are already streamed — output is undefined.\n */\n output?: string;\n /** Session is ending — caller should close the connection. */\n exit?: boolean;\n /** A previous request is still in flight — caller should notify the user. */\n busy?: boolean;\n}\n\nexport interface LlmTerminalSession {\n readonly sessionId: string;\n /** Banner string to display on connect (CRLF line endings). */\n getBanner(): string;\n /** Prompt string (e.g. `\\x1b[1;32m›\\x1b[0m `). */\n getPrompt(): string;\n /**\n * Route a line of user input.\n *\n * If onToken is provided, streamed tokens are forwarded to it as they arrive\n * and result.output is undefined (tokens were already delivered).\n * If onToken is omitted, the complete response is in result.output.\n */\n route(line: string, onToken?: (token: string) => void): Promise<LlmTerminalResult>;\n}\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\nconst HISTORY_TURNS = 20;\nconst R = \"\\x1b[0m\";\n\n// Green › — matches Node daemon's TERM_PROMPT\nconst LLM_PROMPT_COLOR = `\\x1b[1;32m›${R} `;\nconst LLM_PROMPT_PLAIN = \"› \";\n\n// ---------------------------------------------------------------------------\n// Session ID (reuses the same generator pattern as terminal-repl.ts)\n// ---------------------------------------------------------------------------\n\nfunction genSessionId(): string {\n const buf = new Uint8Array(8);\n crypto.getRandomValues(buf);\n return Array.from(buf, (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Create a platform-agnostic LLM terminal session.\n *\n * Requires AFS to have an AI provider mounted at /dev/ai/ (or at the path\n * returned by opts.model). On CF Workers this is CfAnthropicProvider; on\n * Node it is AFSAIDevice.\n */\nexport function createLlmTerminalSession(afs: AFS, opts: LlmTerminalOptions): LlmTerminalSession {\n const sessionId = genSessionId();\n const color = opts.color !== false;\n\n const modelPath = opts.model ?? \"/dev/ai/.actions/chat\";\n // Normalise: append /.actions/chat if the path is a bare model node\n const chatPath = /\\/\\.actions\\/(chat|embed|image|video)$/.test(modelPath)\n ? modelPath\n : `${modelPath}/.actions/chat`;\n\n const description =\n opts.description ??\n opts.systemPrompt?.split(\"\\n\")[0]?.trim().slice(0, 80) ??\n \"No tools, no memory beyond this session.\";\n\n const banner = [\n \"\",\n color\n ? `\\x1b[1;36m● llm-terminal${R} \\x1b[2m—${R} ${modelPath}`\n : `● llm-terminal — ${modelPath}`,\n color ? `\\x1b[2m${description}${R}` : description,\n \"\",\n ].join(\"\\r\\n\");\n\n const systemMessages: Array<{ role: \"system\"; content: string }> = opts.systemPrompt\n ? [{ role: \"system\", content: opts.systemPrompt }]\n : [];\n\n const history: Array<{ role: \"user\" | \"assistant\"; content: string }> = [];\n let inflight = false;\n\n return {\n sessionId,\n\n getBanner(): string {\n return banner;\n },\n\n getPrompt(): string {\n return color ? LLM_PROMPT_COLOR : LLM_PROMPT_PLAIN;\n },\n\n async route(line: string, onToken?: (token: string) => void): Promise<LlmTerminalResult> {\n const trimmed = line.trim();\n if (!trimmed) return {};\n\n if (trimmed === \"exit\" || trimmed === \"quit\") {\n return { exit: true };\n }\n\n if (inflight) return { busy: true };\n inflight = true;\n\n history.push({ role: \"user\", content: trimmed });\n // Cap rolling history to keep memory + context bounded for long sessions\n if (history.length > HISTORY_TURNS * 2) {\n history.splice(0, history.length - HISTORY_TURNS * 2);\n }\n\n let streamed = \"\";\n try {\n const execOptions = onToken\n ? {\n onChunk: (chunk: { text?: string }) => {\n if (chunk.text) {\n streamed += chunk.text;\n onToken(chunk.text);\n }\n },\n }\n : {};\n\n const result = await (afs as any).exec(\n chatPath,\n { messages: [...systemMessages, ...history] },\n execOptions,\n );\n\n // Fall back to result.data.text when streaming emitted no chunks\n const text =\n streamed ||\n (result?.success && (result.data as { text?: string } | undefined)?.text) ||\n \"(no response)\";\n\n if (!streamed) {\n // Non-streaming path: text came back in the result\n history.push({ role: \"assistant\", content: text as string });\n return { output: text as string };\n }\n\n history.push({ role: \"assistant\", content: streamed });\n return {};\n } catch (err) {\n // Don't add the failed turn to history\n history.pop();\n const msg = err instanceof Error ? err.message : String(err);\n return { output: color ? `\\x1b[31mError: ${msg}${R}` : `Error: ${msg}` };\n } finally {\n inflight = false;\n }\n },\n };\n}\n"],"mappings":";AA6DA,MAAM,gBAAgB;AACtB,MAAM,IAAI;AAGV,MAAM,mBAAmB,cAAc,EAAE;AACzC,MAAM,mBAAmB;AAMzB,SAAS,eAAuB;CAC9B,MAAM,MAAM,IAAI,WAAW,EAAE;AAC7B,QAAO,gBAAgB,IAAI;AAC3B,QAAO,MAAM,KAAK,MAAM,MAAM,EAAE,SAAS,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,KAAK,GAAG;;;;;;;;;AAczE,SAAgB,yBAAyB,KAAU,MAA8C;CAC/F,MAAM,YAAY,cAAc;CAChC,MAAM,QAAQ,KAAK,UAAU;CAE7B,MAAM,YAAY,KAAK,SAAS;CAEhC,MAAM,WAAW,yCAAyC,KAAK,UAAU,GACrE,YACA,GAAG,UAAU;CAEjB,MAAM,cACJ,KAAK,eACL,KAAK,cAAc,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,GAAG,IACtD;CAEF,MAAM,SAAS;EACb;EACA,QACI,2BAA2B,EAAE,WAAW,EAAE,GAAG,cAC7C,oBAAoB;EACxB,QAAQ,UAAU,cAAc,MAAM;EACtC;EACD,CAAC,KAAK,OAAO;CAEd,MAAM,iBAA6D,KAAK,eACpE,CAAC;EAAE,MAAM;EAAU,SAAS,KAAK;EAAc,CAAC,GAChD,EAAE;CAEN,MAAM,UAAkE,EAAE;CAC1E,IAAI,WAAW;AAEf,QAAO;EACL;EAEA,YAAoB;AAClB,UAAO;;EAGT,YAAoB;AAClB,UAAO,QAAQ,mBAAmB;;EAGpC,MAAM,MAAM,MAAc,SAA+D;GACvF,MAAM,UAAU,KAAK,MAAM;AAC3B,OAAI,CAAC,QAAS,QAAO,EAAE;AAEvB,OAAI,YAAY,UAAU,YAAY,OACpC,QAAO,EAAE,MAAM,MAAM;AAGvB,OAAI,SAAU,QAAO,EAAE,MAAM,MAAM;AACnC,cAAW;AAEX,WAAQ,KAAK;IAAE,MAAM;IAAQ,SAAS;IAAS,CAAC;AAEhD,OAAI,QAAQ,SAAS,gBAAgB,EACnC,SAAQ,OAAO,GAAG,QAAQ,SAAS,gBAAgB,EAAE;GAGvD,IAAI,WAAW;AACf,OAAI;IACF,MAAM,cAAc,UAChB,EACE,UAAU,UAA6B;AACrC,SAAI,MAAM,MAAM;AACd,kBAAY,MAAM;AAClB,cAAQ,MAAM,KAAK;;OAGxB,GACD,EAAE;IAEN,MAAM,SAAS,MAAO,IAAY,KAChC,UACA,EAAE,UAAU,CAAC,GAAG,gBAAgB,GAAG,QAAQ,EAAE,EAC7C,YACD;IAGD,MAAM,OACJ,YACC,QAAQ,WAAY,OAAO,MAAwC,QACpE;AAEF,QAAI,CAAC,UAAU;AAEb,aAAQ,KAAK;MAAE,MAAM;MAAa,SAAS;MAAgB,CAAC;AAC5D,YAAO,EAAE,QAAQ,MAAgB;;AAGnC,YAAQ,KAAK;KAAE,MAAM;KAAa,SAAS;KAAU,CAAC;AACtD,WAAO,EAAE;YACF,KAAK;AAEZ,YAAQ,KAAK;IACb,MAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI;AAC5D,WAAO,EAAE,QAAQ,QAAQ,kBAAkB,MAAM,MAAM,UAAU,OAAO;aAChE;AACR,eAAW;;;EAGhB"}
|