@agentuity/cli 0.0.60 → 0.0.61
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/bin/cli.ts +15 -4
- package/dist/banner.d.ts +1 -0
- package/dist/banner.d.ts.map +1 -1
- package/dist/banner.js +28 -13
- package/dist/banner.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +85 -9
- package/dist/cli.js.map +1 -1
- package/dist/cmd/ai/capabilities/index.d.ts.map +1 -1
- package/dist/cmd/ai/capabilities/index.js +4 -0
- package/dist/cmd/ai/capabilities/index.js.map +1 -1
- package/dist/cmd/ai/capabilities/show.d.ts.map +1 -1
- package/dist/cmd/ai/capabilities/show.js +13 -2
- package/dist/cmd/ai/capabilities/show.js.map +1 -1
- package/dist/cmd/ai/index.d.ts.map +1 -1
- package/dist/cmd/ai/index.js +11 -0
- package/dist/cmd/ai/index.js.map +1 -1
- package/dist/cmd/ai/prompt/agent.d.ts +3 -0
- package/dist/cmd/ai/prompt/agent.d.ts.map +1 -0
- package/dist/cmd/ai/prompt/agent.js +340 -0
- package/dist/cmd/ai/prompt/agent.js.map +1 -0
- package/dist/cmd/ai/prompt/api.d.ts +3 -0
- package/dist/cmd/ai/prompt/api.d.ts.map +1 -0
- package/dist/cmd/ai/prompt/api.js +272 -0
- package/dist/cmd/ai/prompt/api.js.map +1 -0
- package/dist/cmd/ai/prompt/index.d.ts +1 -2
- package/dist/cmd/ai/prompt/index.d.ts.map +1 -1
- package/dist/cmd/ai/prompt/index.js +17 -1
- package/dist/cmd/ai/prompt/index.js.map +1 -1
- package/dist/cmd/ai/prompt/llm.d.ts +1 -0
- package/dist/cmd/ai/prompt/llm.d.ts.map +1 -1
- package/dist/cmd/ai/prompt/llm.js +2 -2
- package/dist/cmd/ai/prompt/llm.js.map +1 -1
- package/dist/cmd/ai/prompt/web.d.ts +3 -0
- package/dist/cmd/ai/prompt/web.d.ts.map +1 -0
- package/dist/cmd/ai/prompt/web.js +299 -0
- package/dist/cmd/ai/prompt/web.js.map +1 -0
- package/dist/cmd/ai/schema/generate.js +1 -1
- package/dist/cmd/ai/schema/generate.js.map +1 -1
- package/dist/cmd/ai/schema/index.d.ts.map +1 -1
- package/dist/cmd/ai/schema/index.js +2 -0
- package/dist/cmd/ai/schema/index.js.map +1 -1
- package/dist/cmd/ai/schema/show.d.ts.map +1 -1
- package/dist/cmd/ai/schema/show.js +4 -1
- package/dist/cmd/ai/schema/show.js.map +1 -1
- package/dist/cmd/auth/api.d.ts.map +1 -1
- package/dist/cmd/auth/api.js +12 -6
- package/dist/cmd/auth/api.js.map +1 -1
- package/dist/cmd/auth/index.d.ts.map +1 -1
- package/dist/cmd/auth/index.js +5 -0
- package/dist/cmd/auth/index.js.map +1 -1
- package/dist/cmd/auth/login.d.ts.map +1 -1
- package/dist/cmd/auth/login.js +5 -22
- package/dist/cmd/auth/login.js.map +1 -1
- package/dist/cmd/auth/logout.d.ts.map +1 -1
- package/dist/cmd/auth/logout.js +4 -1
- package/dist/cmd/auth/logout.js.map +1 -1
- package/dist/cmd/auth/signup.d.ts.map +1 -1
- package/dist/cmd/auth/signup.js +4 -1
- package/dist/cmd/auth/signup.js.map +1 -1
- package/dist/cmd/auth/ssh/add.d.ts.map +1 -1
- package/dist/cmd/auth/ssh/add.js +13 -4
- package/dist/cmd/auth/ssh/add.js.map +1 -1
- package/dist/cmd/auth/ssh/api.d.ts.map +1 -1
- package/dist/cmd/auth/ssh/api.js +11 -5
- package/dist/cmd/auth/ssh/api.js.map +1 -1
- package/dist/cmd/auth/ssh/delete.js +4 -4
- package/dist/cmd/auth/ssh/delete.js.map +1 -1
- package/dist/cmd/auth/ssh/index.d.ts.map +1 -1
- package/dist/cmd/auth/ssh/index.js +5 -0
- package/dist/cmd/auth/ssh/index.js.map +1 -1
- package/dist/cmd/auth/ssh/list.js +3 -3
- package/dist/cmd/auth/ssh/list.js.map +1 -1
- package/dist/cmd/auth/whoami.d.ts.map +1 -1
- package/dist/cmd/auth/whoami.js +4 -4
- package/dist/cmd/auth/whoami.js.map +1 -1
- package/dist/cmd/build/ast.d.ts +24 -1
- package/dist/cmd/build/ast.d.ts.map +1 -1
- package/dist/cmd/build/ast.js +526 -14
- package/dist/cmd/build/ast.js.map +1 -1
- package/dist/cmd/build/bundler.d.ts +3 -1
- package/dist/cmd/build/bundler.d.ts.map +1 -1
- package/dist/cmd/build/bundler.js +89 -38
- package/dist/cmd/build/bundler.js.map +1 -1
- package/dist/cmd/build/file.js +1 -1
- package/dist/cmd/build/file.js.map +1 -1
- package/dist/cmd/build/fix-duplicate-exports.d.ts.map +1 -1
- package/dist/cmd/build/fix-duplicate-exports.js +4 -1
- package/dist/cmd/build/fix-duplicate-exports.js.map +1 -1
- package/dist/cmd/build/index.d.ts.map +1 -1
- package/dist/cmd/build/index.js +55 -13
- package/dist/cmd/build/index.js.map +1 -1
- package/dist/cmd/build/plugin.d.ts.map +1 -1
- package/dist/cmd/build/plugin.js +183 -38
- package/dist/cmd/build/plugin.js.map +1 -1
- package/dist/cmd/cloud/agent/get.d.ts.map +1 -1
- package/dist/cmd/cloud/agent/get.js +5 -2
- package/dist/cmd/cloud/agent/get.js.map +1 -1
- package/dist/cmd/cloud/agent/index.d.ts.map +1 -1
- package/dist/cmd/cloud/agent/index.js +5 -0
- package/dist/cmd/cloud/agent/index.js.map +1 -1
- package/dist/cmd/cloud/agent/list.js +3 -3
- package/dist/cmd/cloud/agent/list.js.map +1 -1
- package/dist/cmd/cloud/apikey/create.d.ts.map +1 -1
- package/dist/cmd/cloud/apikey/create.js +12 -3
- package/dist/cmd/cloud/apikey/create.js.map +1 -1
- package/dist/cmd/cloud/apikey/delete.js +3 -3
- package/dist/cmd/cloud/apikey/delete.js.map +1 -1
- package/dist/cmd/cloud/apikey/get.js +1 -1
- package/dist/cmd/cloud/apikey/get.js.map +1 -1
- package/dist/cmd/cloud/apikey/index.d.ts.map +1 -1
- package/dist/cmd/cloud/apikey/index.js +8 -0
- package/dist/cmd/cloud/apikey/index.js.map +1 -1
- package/dist/cmd/cloud/apikey/list.d.ts.map +1 -1
- package/dist/cmd/cloud/apikey/list.js +4 -1
- package/dist/cmd/cloud/apikey/list.js.map +1 -1
- package/dist/cmd/cloud/db/create.d.ts.map +1 -1
- package/dist/cmd/cloud/db/create.js +35 -21
- package/dist/cmd/cloud/db/create.js.map +1 -1
- package/dist/cmd/cloud/db/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/db/delete.js +34 -21
- package/dist/cmd/cloud/db/delete.js.map +1 -1
- package/dist/cmd/cloud/db/get.d.ts.map +1 -1
- package/dist/cmd/cloud/db/get.js +9 -3
- package/dist/cmd/cloud/db/get.js.map +1 -1
- package/dist/cmd/cloud/db/index.d.ts.map +1 -1
- package/dist/cmd/cloud/db/index.js +5 -0
- package/dist/cmd/cloud/db/index.js.map +1 -1
- package/dist/cmd/cloud/db/list.d.ts.map +1 -1
- package/dist/cmd/cloud/db/list.js +16 -6
- package/dist/cmd/cloud/db/list.js.map +1 -1
- package/dist/cmd/cloud/db/sql.d.ts.map +1 -1
- package/dist/cmd/cloud/db/sql.js +12 -3
- package/dist/cmd/cloud/db/sql.js.map +1 -1
- package/dist/cmd/cloud/deploy.d.ts.map +1 -1
- package/dist/cmd/cloud/deploy.js +9 -3
- package/dist/cmd/cloud/deploy.js.map +1 -1
- package/dist/cmd/cloud/deployment/index.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/index.js +5 -0
- package/dist/cmd/cloud/deployment/index.js.map +1 -1
- package/dist/cmd/cloud/deployment/list.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/list.js +12 -3
- package/dist/cmd/cloud/deployment/list.js.map +1 -1
- package/dist/cmd/cloud/deployment/logs.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/logs.js +16 -4
- package/dist/cmd/cloud/deployment/logs.js.map +1 -1
- package/dist/cmd/cloud/deployment/remove.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/remove.js +12 -3
- package/dist/cmd/cloud/deployment/remove.js.map +1 -1
- package/dist/cmd/cloud/deployment/rollback.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/rollback.js +8 -2
- package/dist/cmd/cloud/deployment/rollback.js.map +1 -1
- package/dist/cmd/cloud/deployment/show.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/show.js +8 -2
- package/dist/cmd/cloud/deployment/show.js.map +1 -1
- package/dist/cmd/cloud/deployment/undeploy.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/undeploy.js +12 -3
- package/dist/cmd/cloud/deployment/undeploy.js.map +1 -1
- package/dist/cmd/cloud/deployment/utils.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/utils.js +3 -1
- package/dist/cmd/cloud/deployment/utils.js.map +1 -1
- package/dist/cmd/cloud/domain.d.ts.map +1 -1
- package/dist/cmd/cloud/domain.js +4 -2
- package/dist/cmd/cloud/domain.js.map +1 -1
- package/dist/cmd/cloud/env/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/env/delete.js +4 -1
- package/dist/cmd/cloud/env/delete.js.map +1 -1
- package/dist/cmd/cloud/env/get.d.ts.map +1 -1
- package/dist/cmd/cloud/env/get.js +4 -1
- package/dist/cmd/cloud/env/get.js.map +1 -1
- package/dist/cmd/cloud/env/import.d.ts.map +1 -1
- package/dist/cmd/cloud/env/import.js +10 -0
- package/dist/cmd/cloud/env/import.js.map +1 -1
- package/dist/cmd/cloud/env/index.d.ts.map +1 -1
- package/dist/cmd/cloud/env/index.js +8 -0
- package/dist/cmd/cloud/env/index.js.map +1 -1
- package/dist/cmd/cloud/env/list.d.ts.map +1 -1
- package/dist/cmd/cloud/env/list.js +4 -1
- package/dist/cmd/cloud/env/list.js.map +1 -1
- package/dist/cmd/cloud/env/pull.d.ts.map +1 -1
- package/dist/cmd/cloud/env/pull.js +4 -1
- package/dist/cmd/cloud/env/pull.js.map +1 -1
- package/dist/cmd/cloud/env/push.js +1 -1
- package/dist/cmd/cloud/env/push.js.map +1 -1
- package/dist/cmd/cloud/env/set.js +3 -3
- package/dist/cmd/cloud/env/set.js.map +1 -1
- package/dist/cmd/cloud/index.d.ts.map +1 -1
- package/dist/cmd/cloud/index.js +5 -0
- package/dist/cmd/cloud/index.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/create-namespace.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/create-namespace.js +9 -3
- package/dist/cmd/cloud/keyvalue/create-namespace.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/delete-namespace.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/delete-namespace.js +12 -3
- package/dist/cmd/cloud/keyvalue/delete-namespace.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/delete.js +6 -3
- package/dist/cmd/cloud/keyvalue/delete.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/get.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/get.js +3 -3
- package/dist/cmd/cloud/keyvalue/get.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/index.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/index.js +8 -0
- package/dist/cmd/cloud/keyvalue/index.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/keys.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/keys.js +3 -3
- package/dist/cmd/cloud/keyvalue/keys.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/list-namespaces.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/list-namespaces.js +3 -3
- package/dist/cmd/cloud/keyvalue/list-namespaces.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/repl.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/repl.js +1 -1
- package/dist/cmd/cloud/keyvalue/repl.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/search.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/search.js +9 -3
- package/dist/cmd/cloud/keyvalue/search.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/set.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/set.js +12 -3
- package/dist/cmd/cloud/keyvalue/set.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/stats.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/stats.js +6 -3
- package/dist/cmd/cloud/keyvalue/stats.js.map +1 -1
- package/dist/cmd/cloud/objectstore/delete-bucket.d.ts.map +1 -1
- package/dist/cmd/cloud/objectstore/delete-bucket.js +8 -2
- package/dist/cmd/cloud/objectstore/delete-bucket.js.map +1 -1
- package/dist/cmd/cloud/objectstore/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/objectstore/delete.js +12 -3
- package/dist/cmd/cloud/objectstore/delete.js.map +1 -1
- package/dist/cmd/cloud/objectstore/get.d.ts.map +1 -1
- package/dist/cmd/cloud/objectstore/get.js +12 -3
- package/dist/cmd/cloud/objectstore/get.js.map +1 -1
- package/dist/cmd/cloud/objectstore/index.d.ts.map +1 -1
- package/dist/cmd/cloud/objectstore/index.js +8 -0
- package/dist/cmd/cloud/objectstore/index.js.map +1 -1
- package/dist/cmd/cloud/objectstore/list-buckets.d.ts.map +1 -1
- package/dist/cmd/cloud/objectstore/list-buckets.js +6 -1
- package/dist/cmd/cloud/objectstore/list-buckets.js.map +1 -1
- package/dist/cmd/cloud/objectstore/list-keys.d.ts.map +1 -1
- package/dist/cmd/cloud/objectstore/list-keys.js +6 -3
- package/dist/cmd/cloud/objectstore/list-keys.js.map +1 -1
- package/dist/cmd/cloud/objectstore/put.d.ts.map +1 -1
- package/dist/cmd/cloud/objectstore/put.js +12 -3
- package/dist/cmd/cloud/objectstore/put.js.map +1 -1
- package/dist/cmd/cloud/objectstore/repl.d.ts.map +1 -1
- package/dist/cmd/cloud/objectstore/repl.js +6 -1
- package/dist/cmd/cloud/objectstore/repl.js.map +1 -1
- package/dist/cmd/cloud/objectstore/url.d.ts.map +1 -1
- package/dist/cmd/cloud/objectstore/url.js +12 -3
- package/dist/cmd/cloud/objectstore/url.js.map +1 -1
- package/dist/cmd/cloud/scp/download.d.ts.map +1 -1
- package/dist/cmd/cloud/scp/download.js +16 -4
- package/dist/cmd/cloud/scp/download.js.map +1 -1
- package/dist/cmd/cloud/scp/index.d.ts.map +1 -1
- package/dist/cmd/cloud/scp/index.js +11 -0
- package/dist/cmd/cloud/scp/index.js.map +1 -1
- package/dist/cmd/cloud/scp/upload.d.ts.map +1 -1
- package/dist/cmd/cloud/scp/upload.js +16 -4
- package/dist/cmd/cloud/scp/upload.js.map +1 -1
- package/dist/cmd/cloud/secret/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/secret/delete.js +4 -1
- package/dist/cmd/cloud/secret/delete.js.map +1 -1
- package/dist/cmd/cloud/secret/get.d.ts.map +1 -1
- package/dist/cmd/cloud/secret/get.js +5 -2
- package/dist/cmd/cloud/secret/get.js.map +1 -1
- package/dist/cmd/cloud/secret/import.d.ts.map +1 -1
- package/dist/cmd/cloud/secret/import.js +5 -2
- package/dist/cmd/cloud/secret/import.js.map +1 -1
- package/dist/cmd/cloud/secret/index.d.ts.map +1 -1
- package/dist/cmd/cloud/secret/index.js +8 -0
- package/dist/cmd/cloud/secret/index.js.map +1 -1
- package/dist/cmd/cloud/secret/list.d.ts.map +1 -1
- package/dist/cmd/cloud/secret/list.js +4 -1
- package/dist/cmd/cloud/secret/list.js.map +1 -1
- package/dist/cmd/cloud/secret/pull.d.ts.map +1 -1
- package/dist/cmd/cloud/secret/pull.js +4 -1
- package/dist/cmd/cloud/secret/pull.js.map +1 -1
- package/dist/cmd/cloud/secret/push.js +1 -1
- package/dist/cmd/cloud/secret/push.js.map +1 -1
- package/dist/cmd/cloud/secret/set.d.ts.map +1 -1
- package/dist/cmd/cloud/secret/set.js +8 -2
- package/dist/cmd/cloud/secret/set.js.map +1 -1
- package/dist/cmd/cloud/session/get.js +1 -1
- package/dist/cmd/cloud/session/get.js.map +1 -1
- package/dist/cmd/cloud/session/index.d.ts.map +1 -1
- package/dist/cmd/cloud/session/index.js +5 -0
- package/dist/cmd/cloud/session/index.js.map +1 -1
- package/dist/cmd/cloud/session/list.d.ts.map +1 -1
- package/dist/cmd/cloud/session/list.js +29 -8
- package/dist/cmd/cloud/session/list.js.map +1 -1
- package/dist/cmd/cloud/session/logs.d.ts.map +1 -1
- package/dist/cmd/cloud/session/logs.js +8 -2
- package/dist/cmd/cloud/session/logs.js.map +1 -1
- package/dist/cmd/cloud/ssh.d.ts.map +1 -1
- package/dist/cmd/cloud/ssh.js +15 -6
- package/dist/cmd/cloud/ssh.js.map +1 -1
- package/dist/cmd/cloud/storage/create.js +3 -3
- package/dist/cmd/cloud/storage/create.js.map +1 -1
- package/dist/cmd/cloud/storage/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/storage/delete.js +7 -4
- package/dist/cmd/cloud/storage/delete.js.map +1 -1
- package/dist/cmd/cloud/storage/download.d.ts.map +1 -1
- package/dist/cmd/cloud/storage/download.js +16 -4
- package/dist/cmd/cloud/storage/download.js.map +1 -1
- package/dist/cmd/cloud/storage/get.d.ts.map +1 -1
- package/dist/cmd/cloud/storage/get.js +12 -3
- package/dist/cmd/cloud/storage/get.js.map +1 -1
- package/dist/cmd/cloud/storage/index.d.ts.map +1 -1
- package/dist/cmd/cloud/storage/index.js +8 -0
- package/dist/cmd/cloud/storage/index.js.map +1 -1
- package/dist/cmd/cloud/storage/list.d.ts.map +1 -1
- package/dist/cmd/cloud/storage/list.js +35 -12
- package/dist/cmd/cloud/storage/list.js.map +1 -1
- package/dist/cmd/cloud/storage/upload.d.ts.map +1 -1
- package/dist/cmd/cloud/storage/upload.js +21 -9
- package/dist/cmd/cloud/storage/upload.js.map +1 -1
- package/dist/cmd/cloud/stream/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/stream/delete.js +9 -3
- package/dist/cmd/cloud/stream/delete.js.map +1 -1
- package/dist/cmd/cloud/stream/get.d.ts.map +1 -1
- package/dist/cmd/cloud/stream/get.js +10 -4
- package/dist/cmd/cloud/stream/get.js.map +1 -1
- package/dist/cmd/cloud/stream/index.d.ts.map +1 -1
- package/dist/cmd/cloud/stream/index.js +5 -0
- package/dist/cmd/cloud/stream/index.js.map +1 -1
- package/dist/cmd/cloud/stream/list.d.ts.map +1 -1
- package/dist/cmd/cloud/stream/list.js +8 -5
- package/dist/cmd/cloud/stream/list.js.map +1 -1
- package/dist/cmd/cloud/vector/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/vector/delete.js +12 -3
- package/dist/cmd/cloud/vector/delete.js.map +1 -1
- package/dist/cmd/cloud/vector/get.d.ts.map +1 -1
- package/dist/cmd/cloud/vector/get.js +12 -3
- package/dist/cmd/cloud/vector/get.js.map +1 -1
- package/dist/cmd/cloud/vector/index.d.ts.map +1 -1
- package/dist/cmd/cloud/vector/index.js +8 -0
- package/dist/cmd/cloud/vector/index.js.map +1 -1
- package/dist/cmd/cloud/vector/search.d.ts.map +1 -1
- package/dist/cmd/cloud/vector/search.js +20 -5
- package/dist/cmd/cloud/vector/search.js.map +1 -1
- package/dist/cmd/dev/agents.d.ts.map +1 -1
- package/dist/cmd/dev/agents.js +7 -2
- package/dist/cmd/dev/agents.js.map +1 -1
- package/dist/cmd/dev/api.d.ts.map +1 -1
- package/dist/cmd/dev/api.js +3 -1
- package/dist/cmd/dev/api.js.map +1 -1
- package/dist/cmd/dev/index.d.ts.map +1 -1
- package/dist/cmd/dev/index.js +13 -5
- package/dist/cmd/dev/index.js.map +1 -1
- package/dist/cmd/help/index.d.ts +2 -0
- package/dist/cmd/help/index.d.ts.map +1 -0
- package/dist/cmd/help/index.js +35 -0
- package/dist/cmd/help/index.js.map +1 -0
- package/dist/cmd/index.d.ts.map +1 -1
- package/dist/cmd/index.js +1 -0
- package/dist/cmd/index.js.map +1 -1
- package/dist/cmd/profile/create.js +3 -3
- package/dist/cmd/profile/create.js.map +1 -1
- package/dist/cmd/profile/delete.d.ts.map +1 -1
- package/dist/cmd/profile/delete.js +6 -3
- package/dist/cmd/profile/delete.js.map +1 -1
- package/dist/cmd/profile/index.d.ts.map +1 -1
- package/dist/cmd/profile/index.js +8 -0
- package/dist/cmd/profile/index.js.map +1 -1
- package/dist/cmd/profile/list.d.ts.map +1 -1
- package/dist/cmd/profile/list.js +4 -1
- package/dist/cmd/profile/list.js.map +1 -1
- package/dist/cmd/profile/show.d.ts.map +1 -1
- package/dist/cmd/profile/show.js +6 -3
- package/dist/cmd/profile/show.js.map +1 -1
- package/dist/cmd/profile/use.js +3 -3
- package/dist/cmd/profile/use.js.map +1 -1
- package/dist/cmd/project/create.d.ts.map +1 -1
- package/dist/cmd/project/create.js +11 -5
- package/dist/cmd/project/create.js.map +1 -1
- package/dist/cmd/project/delete.d.ts.map +1 -1
- package/dist/cmd/project/delete.js +15 -6
- package/dist/cmd/project/delete.js.map +1 -1
- package/dist/cmd/project/download.d.ts +1 -1
- package/dist/cmd/project/download.d.ts.map +1 -1
- package/dist/cmd/project/download.js +28 -2
- package/dist/cmd/project/download.js.map +1 -1
- package/dist/cmd/project/index.d.ts.map +1 -1
- package/dist/cmd/project/index.js +5 -0
- package/dist/cmd/project/index.js.map +1 -1
- package/dist/cmd/project/list.js +3 -3
- package/dist/cmd/project/list.js.map +1 -1
- package/dist/cmd/project/show.d.ts.map +1 -1
- package/dist/cmd/project/show.js +6 -3
- package/dist/cmd/project/show.js.map +1 -1
- package/dist/cmd/project/templates.d.ts.map +1 -1
- package/dist/cmd/project/templates.js +10 -2
- package/dist/cmd/project/templates.js.map +1 -1
- package/dist/cmd/repl/index.js +1 -1
- package/dist/cmd/repl/index.js.map +1 -1
- package/dist/cmd/version/index.d.ts.map +1 -1
- package/dist/cmd/version/index.js +4 -1
- package/dist/cmd/version/index.js.map +1 -1
- package/dist/command-prefix.d.ts.map +1 -1
- package/dist/command-prefix.js +5 -3
- package/dist/command-prefix.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -1
- package/dist/config.js.map +1 -1
- package/dist/crypto/box.d.ts.map +1 -1
- package/dist/crypto/box.js +31 -17
- package/dist/crypto/box.js.map +1 -1
- package/dist/download.d.ts.map +1 -1
- package/dist/download.js +7 -1
- package/dist/download.js.map +1 -1
- package/dist/env-util.d.ts +3 -0
- package/dist/env-util.d.ts.map +1 -1
- package/dist/env-util.js +43 -2
- package/dist/env-util.js.map +1 -1
- package/dist/errors.d.ts +4 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +7 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/schema-generator.d.ts +5 -1
- package/dist/schema-generator.d.ts.map +1 -1
- package/dist/schema-generator.js +1 -0
- package/dist/schema-generator.js.map +1 -1
- package/dist/steps.js +17 -13
- package/dist/steps.js.map +1 -1
- package/dist/tui.d.ts +2 -1
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +21 -14
- package/dist/tui.js.map +1 -1
- package/dist/types.d.ts +10 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/date.d.ts.map +1 -1
- package/dist/utils/date.js +7 -2
- package/dist/utils/date.js.map +1 -1
- package/package.json +3 -3
- package/src/banner.ts +29 -13
- package/src/cli.ts +109 -13
- package/src/cmd/ai/capabilities/index.ts +4 -0
- package/src/cmd/ai/capabilities/show.ts +13 -2
- package/src/cmd/ai/index.ts +11 -0
- package/src/cmd/ai/prompt/agent.ts +342 -0
- package/src/cmd/ai/prompt/api.ts +274 -0
- package/src/cmd/ai/prompt/index.ts +18 -3
- package/src/cmd/ai/prompt/llm.ts +2 -2
- package/src/cmd/ai/prompt/web.ts +301 -0
- package/src/cmd/ai/schema/generate.ts +1 -1
- package/src/cmd/ai/schema/index.ts +2 -0
- package/src/cmd/ai/schema/show.ts +4 -1
- package/src/cmd/auth/api.ts +28 -6
- package/src/cmd/auth/index.ts +5 -0
- package/src/cmd/auth/login.ts +5 -22
- package/src/cmd/auth/logout.ts +4 -1
- package/src/cmd/auth/signup.ts +4 -1
- package/src/cmd/auth/ssh/add.ts +13 -4
- package/src/cmd/auth/ssh/api.ts +21 -5
- package/src/cmd/auth/ssh/delete.ts +4 -4
- package/src/cmd/auth/ssh/index.ts +5 -0
- package/src/cmd/auth/ssh/list.ts +3 -3
- package/src/cmd/auth/whoami.ts +4 -7
- package/src/cmd/build/ast.ts +605 -31
- package/src/cmd/build/bundler.ts +110 -37
- package/src/cmd/build/file.ts +1 -1
- package/src/cmd/build/fix-duplicate-exports.ts +4 -1
- package/src/cmd/build/index.ts +58 -13
- package/src/cmd/build/plugin.ts +210 -46
- package/src/cmd/cloud/agent/get.ts +5 -2
- package/src/cmd/cloud/agent/index.ts +5 -0
- package/src/cmd/cloud/agent/list.ts +3 -3
- package/src/cmd/cloud/apikey/create.ts +14 -5
- package/src/cmd/cloud/apikey/delete.ts +3 -3
- package/src/cmd/cloud/apikey/get.ts +1 -1
- package/src/cmd/cloud/apikey/index.ts +8 -0
- package/src/cmd/cloud/apikey/list.ts +4 -1
- package/src/cmd/cloud/db/create.ts +37 -22
- package/src/cmd/cloud/db/delete.ts +36 -21
- package/src/cmd/cloud/db/get.ts +12 -4
- package/src/cmd/cloud/db/index.ts +5 -0
- package/src/cmd/cloud/db/list.ts +19 -7
- package/src/cmd/cloud/db/sql.ts +12 -3
- package/src/cmd/cloud/deploy.ts +9 -3
- package/src/cmd/cloud/deployment/index.ts +5 -0
- package/src/cmd/cloud/deployment/list.ts +12 -3
- package/src/cmd/cloud/deployment/logs.ts +16 -4
- package/src/cmd/cloud/deployment/remove.ts +14 -4
- package/src/cmd/cloud/deployment/rollback.ts +8 -3
- package/src/cmd/cloud/deployment/show.ts +8 -2
- package/src/cmd/cloud/deployment/undeploy.ts +12 -4
- package/src/cmd/cloud/deployment/utils.ts +7 -1
- package/src/cmd/cloud/domain.ts +9 -2
- package/src/cmd/cloud/env/delete.ts +4 -1
- package/src/cmd/cloud/env/get.ts +4 -1
- package/src/cmd/cloud/env/import.ts +10 -0
- package/src/cmd/cloud/env/index.ts +8 -0
- package/src/cmd/cloud/env/list.ts +4 -1
- package/src/cmd/cloud/env/pull.ts +4 -1
- package/src/cmd/cloud/env/push.ts +1 -1
- package/src/cmd/cloud/env/set.ts +3 -3
- package/src/cmd/cloud/index.ts +5 -1
- package/src/cmd/cloud/keyvalue/create-namespace.ts +9 -4
- package/src/cmd/cloud/keyvalue/delete-namespace.ts +12 -4
- package/src/cmd/cloud/keyvalue/delete.ts +6 -4
- package/src/cmd/cloud/keyvalue/get.ts +3 -4
- package/src/cmd/cloud/keyvalue/index.ts +8 -0
- package/src/cmd/cloud/keyvalue/keys.ts +3 -4
- package/src/cmd/cloud/keyvalue/list-namespaces.ts +3 -4
- package/src/cmd/cloud/keyvalue/repl.ts +1 -2
- package/src/cmd/cloud/keyvalue/search.ts +9 -4
- package/src/cmd/cloud/keyvalue/set.ts +14 -4
- package/src/cmd/cloud/keyvalue/stats.ts +6 -4
- package/src/cmd/cloud/objectstore/delete-bucket.ts +8 -3
- package/src/cmd/cloud/objectstore/delete.ts +12 -4
- package/src/cmd/cloud/objectstore/get.ts +12 -4
- package/src/cmd/cloud/objectstore/index.ts +8 -0
- package/src/cmd/cloud/objectstore/list-buckets.ts +6 -2
- package/src/cmd/cloud/objectstore/list-keys.ts +6 -4
- package/src/cmd/cloud/objectstore/put.ts +16 -4
- package/src/cmd/cloud/objectstore/repl.ts +6 -2
- package/src/cmd/cloud/objectstore/url.ts +12 -4
- package/src/cmd/cloud/scp/download.ts +16 -5
- package/src/cmd/cloud/scp/index.ts +11 -0
- package/src/cmd/cloud/scp/upload.ts +16 -5
- package/src/cmd/cloud/secret/delete.ts +4 -1
- package/src/cmd/cloud/secret/get.ts +5 -2
- package/src/cmd/cloud/secret/import.ts +5 -2
- package/src/cmd/cloud/secret/index.ts +8 -0
- package/src/cmd/cloud/secret/list.ts +4 -1
- package/src/cmd/cloud/secret/pull.ts +4 -1
- package/src/cmd/cloud/secret/push.ts +1 -1
- package/src/cmd/cloud/secret/set.ts +8 -2
- package/src/cmd/cloud/session/get.ts +1 -1
- package/src/cmd/cloud/session/index.ts +5 -0
- package/src/cmd/cloud/session/list.ts +29 -8
- package/src/cmd/cloud/session/logs.ts +8 -2
- package/src/cmd/cloud/ssh.ts +15 -7
- package/src/cmd/cloud/storage/create.ts +3 -3
- package/src/cmd/cloud/storage/delete.ts +7 -4
- package/src/cmd/cloud/storage/download.ts +16 -4
- package/src/cmd/cloud/storage/get.ts +12 -3
- package/src/cmd/cloud/storage/index.ts +8 -0
- package/src/cmd/cloud/storage/list.ts +39 -15
- package/src/cmd/cloud/storage/upload.ts +24 -9
- package/src/cmd/cloud/stream/delete.ts +9 -4
- package/src/cmd/cloud/stream/get.ts +10 -5
- package/src/cmd/cloud/stream/index.ts +5 -0
- package/src/cmd/cloud/stream/list.ts +8 -6
- package/src/cmd/cloud/vector/delete.ts +17 -6
- package/src/cmd/cloud/vector/get.ts +12 -4
- package/src/cmd/cloud/vector/index.ts +8 -0
- package/src/cmd/cloud/vector/search.ts +20 -6
- package/src/cmd/dev/agents.ts +7 -2
- package/src/cmd/dev/api.ts +4 -1
- package/src/cmd/dev/index.ts +16 -5
- package/src/cmd/help/index.ts +40 -0
- package/src/cmd/index.ts +1 -0
- package/src/cmd/profile/create.ts +3 -3
- package/src/cmd/profile/delete.ts +6 -3
- package/src/cmd/profile/index.ts +8 -0
- package/src/cmd/profile/list.ts +4 -1
- package/src/cmd/profile/show.ts +6 -3
- package/src/cmd/profile/use.ts +3 -3
- package/src/cmd/project/create.ts +11 -5
- package/src/cmd/project/delete.ts +15 -6
- package/src/cmd/project/download.ts +35 -3
- package/src/cmd/project/index.ts +5 -0
- package/src/cmd/project/list.ts +3 -3
- package/src/cmd/project/show.ts +6 -3
- package/src/cmd/project/templates.ts +12 -2
- package/src/cmd/repl/index.ts +1 -1
- package/src/cmd/version/index.ts +4 -1
- package/src/command-prefix.ts +5 -3
- package/src/config.ts +4 -2
- package/src/crypto/box.ts +69 -17
- package/src/download.ts +7 -1
- package/src/env-util.ts +44 -2
- package/src/errors.ts +9 -1
- package/src/index.ts +6 -1
- package/src/schema-generator.ts +7 -1
- package/src/steps.ts +22 -13
- package/src/tui.ts +28 -16
- package/src/types.ts +11 -6
- package/src/utils/date.ts +9 -4
package/src/cmd/build/ast.ts
CHANGED
|
@@ -4,13 +4,22 @@ import { generate } from 'astring';
|
|
|
4
4
|
import type { BuildMetadata } from '../../types';
|
|
5
5
|
import { createLogger } from '@agentuity/server';
|
|
6
6
|
import * as ts from 'typescript';
|
|
7
|
-
import type
|
|
7
|
+
import { StructuredError, type WorkbenchConfig } from '@agentuity/core';
|
|
8
8
|
import type { LogLevel } from '../../types';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
import { existsSync, mkdirSync } from 'node:fs';
|
|
11
|
+
import JSON5 from 'json5';
|
|
9
12
|
|
|
10
13
|
const logger = createLogger((process.env.AGENTUITY_LOG_LEVEL || 'info') as LogLevel);
|
|
11
14
|
|
|
15
|
+
interface ASTProgram extends ASTNode {
|
|
16
|
+
body: ASTNode[];
|
|
17
|
+
}
|
|
18
|
+
|
|
12
19
|
interface ASTNode {
|
|
13
20
|
type: string;
|
|
21
|
+
start?: number;
|
|
22
|
+
end?: number;
|
|
14
23
|
}
|
|
15
24
|
|
|
16
25
|
interface ASTNodeIdentifier extends ASTNode {
|
|
@@ -166,6 +175,11 @@ function generateStableEvalId(projectId: string, agentId: string, name: string):
|
|
|
166
175
|
|
|
167
176
|
type AcornParseResultType = ReturnType<typeof acornLoose.parse>;
|
|
168
177
|
|
|
178
|
+
const MetadataError = StructuredError('MetatadataNameMissingError')<{
|
|
179
|
+
filename: string;
|
|
180
|
+
line?: number;
|
|
181
|
+
}>();
|
|
182
|
+
|
|
169
183
|
function augmentAgentMetadataNode(
|
|
170
184
|
projectId: string,
|
|
171
185
|
id: string,
|
|
@@ -179,16 +193,20 @@ function augmentAgentMetadataNode(
|
|
|
179
193
|
const metadata = parseObjectExpressionToMap(propvalue);
|
|
180
194
|
if (!metadata.has('name')) {
|
|
181
195
|
const location = ast.loc?.start ? ` on line ${ast.loc.start}` : '';
|
|
182
|
-
throw new
|
|
183
|
-
|
|
184
|
-
|
|
196
|
+
throw new MetadataError({
|
|
197
|
+
filename,
|
|
198
|
+
line: ast.loc?.start?.line,
|
|
199
|
+
message: `missing required metadata.name in ${filename}${location}. This Agent should have a unique and human readable name for this project.`,
|
|
200
|
+
});
|
|
185
201
|
}
|
|
186
202
|
const name = metadata.get('name')!;
|
|
187
203
|
if (metadata.has('identifier') && identifier !== metadata.get('identifier')) {
|
|
188
204
|
const location = ast.loc?.start ? ` on line ${ast.loc.start}` : '';
|
|
189
|
-
throw new
|
|
190
|
-
|
|
191
|
-
|
|
205
|
+
throw new MetadataError({
|
|
206
|
+
filename,
|
|
207
|
+
line: ast.loc?.start?.line,
|
|
208
|
+
message: `metadata.identifier (${metadata.get('identifier')}) in ${filename}${location} is mismatched (${name}). This is an internal error.`,
|
|
209
|
+
});
|
|
192
210
|
}
|
|
193
211
|
const descriptionNode = propvalue.properties.find((x) => x.key.name === 'description')?.value;
|
|
194
212
|
const description = descriptionNode ? (descriptionNode as ASTLiteral).value : '';
|
|
@@ -244,7 +262,7 @@ function createAgentMetadataNode(
|
|
|
244
262
|
function camelToKebab(str: string): string {
|
|
245
263
|
return str
|
|
246
264
|
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
247
|
-
.replace(/([A-Z])([A-Z][a-z])/g, '$1-$2')
|
|
265
|
+
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')
|
|
248
266
|
.toLowerCase();
|
|
249
267
|
}
|
|
250
268
|
|
|
@@ -367,6 +385,8 @@ function augmentEvalMetadataNode(
|
|
|
367
385
|
}
|
|
368
386
|
}
|
|
369
387
|
|
|
388
|
+
const DuplicateNameError = StructuredError('DuplicateNameError')<{ filename: string }>();
|
|
389
|
+
|
|
370
390
|
export function parseEvalMetadata(
|
|
371
391
|
rootDir: string,
|
|
372
392
|
filename: string,
|
|
@@ -484,9 +504,12 @@ export function parseEvalMetadata(
|
|
|
484
504
|
} else if (variableName) {
|
|
485
505
|
finalName = camelToKebab(variableName);
|
|
486
506
|
} else {
|
|
487
|
-
throw new
|
|
488
|
-
|
|
489
|
-
|
|
507
|
+
throw new MetadataError({
|
|
508
|
+
filename,
|
|
509
|
+
line: body.loc?.start?.line,
|
|
510
|
+
message:
|
|
511
|
+
'Eval is missing a name. Please provide metadata.name or use a named export.',
|
|
512
|
+
});
|
|
490
513
|
}
|
|
491
514
|
|
|
492
515
|
logger.trace(
|
|
@@ -563,10 +586,12 @@ export function parseEvalMetadata(
|
|
|
563
586
|
}
|
|
564
587
|
|
|
565
588
|
if (duplicates.length > 0) {
|
|
566
|
-
throw new
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
589
|
+
throw new DuplicateNameError({
|
|
590
|
+
filename,
|
|
591
|
+
message:
|
|
592
|
+
`Duplicate eval names found in ${rel}: ${duplicates.join(', ')}. ` +
|
|
593
|
+
'Eval names must be unique within the same file to prevent ID collisions.',
|
|
594
|
+
});
|
|
570
595
|
}
|
|
571
596
|
|
|
572
597
|
const newsource = generate(ast);
|
|
@@ -574,6 +599,9 @@ export function parseEvalMetadata(
|
|
|
574
599
|
return [newsource, evals];
|
|
575
600
|
}
|
|
576
601
|
|
|
602
|
+
const InvalidExportError = StructuredError('InvalidExportError')<{ filename: string }>();
|
|
603
|
+
const InvalidCreateAgentError = StructuredError('InvalidCreateAgentError')<{ filename: string }>();
|
|
604
|
+
|
|
577
605
|
export async function parseAgentMetadata(
|
|
578
606
|
rootDir: string,
|
|
579
607
|
filename: string,
|
|
@@ -635,7 +663,10 @@ export async function parseAgentMetadata(
|
|
|
635
663
|
}
|
|
636
664
|
}
|
|
637
665
|
if (!result && !exportName) {
|
|
638
|
-
throw new
|
|
666
|
+
throw new InvalidExportError({
|
|
667
|
+
filename,
|
|
668
|
+
message: `could not find default export for ${filename} using ${rootDir}`,
|
|
669
|
+
});
|
|
639
670
|
}
|
|
640
671
|
if (!result) {
|
|
641
672
|
for (const body of ast.body) {
|
|
@@ -689,9 +720,10 @@ export async function parseAgentMetadata(
|
|
|
689
720
|
}
|
|
690
721
|
}
|
|
691
722
|
if (!result) {
|
|
692
|
-
throw new
|
|
693
|
-
|
|
694
|
-
|
|
723
|
+
throw new InvalidCreateAgentError({
|
|
724
|
+
filename,
|
|
725
|
+
message: `error parsing: ${filename}. could not find an proper createAgent defined in this file`,
|
|
726
|
+
});
|
|
695
727
|
}
|
|
696
728
|
|
|
697
729
|
// Parse evals from eval.ts file in the same directory
|
|
@@ -735,6 +767,15 @@ export async function parseAgentMetadata(
|
|
|
735
767
|
|
|
736
768
|
type RouteDefinition = BuildMetadata['routes'];
|
|
737
769
|
|
|
770
|
+
const InvalidCreateRouterError = StructuredError('InvalidCreateRouterError')<{
|
|
771
|
+
filename: string;
|
|
772
|
+
}>();
|
|
773
|
+
|
|
774
|
+
const InvalidRouterConfigError = StructuredError('InvalidRouterConfigError')<{
|
|
775
|
+
filename: string;
|
|
776
|
+
line?: number;
|
|
777
|
+
}>();
|
|
778
|
+
|
|
738
779
|
export async function parseRoute(
|
|
739
780
|
rootDir: string,
|
|
740
781
|
filename: string,
|
|
@@ -754,7 +795,10 @@ export async function parseRoute(
|
|
|
754
795
|
}
|
|
755
796
|
}
|
|
756
797
|
if (!exportName) {
|
|
757
|
-
throw new
|
|
798
|
+
throw new InvalidExportError({
|
|
799
|
+
filename,
|
|
800
|
+
message: `could not find default export for ${filename} using ${rootDir}`,
|
|
801
|
+
});
|
|
758
802
|
}
|
|
759
803
|
for (const body of ast.body) {
|
|
760
804
|
if (body.type === 'VariableDeclaration') {
|
|
@@ -775,9 +819,10 @@ export async function parseRoute(
|
|
|
775
819
|
}
|
|
776
820
|
}
|
|
777
821
|
if (!variableName) {
|
|
778
|
-
throw new
|
|
779
|
-
|
|
780
|
-
|
|
822
|
+
throw new InvalidCreateRouterError({
|
|
823
|
+
filename,
|
|
824
|
+
message: `error parsing: ${filename}. could not find an proper createRouter defined in this file`,
|
|
825
|
+
});
|
|
781
826
|
}
|
|
782
827
|
|
|
783
828
|
const rel = relative(rootDir, filename);
|
|
@@ -831,9 +876,11 @@ export async function parseRoute(
|
|
|
831
876
|
if (action && (action as ASTLiteral).type === 'Literal') {
|
|
832
877
|
suffix = (action as ASTLiteral).value;
|
|
833
878
|
} else {
|
|
834
|
-
throw new
|
|
835
|
-
|
|
836
|
-
|
|
879
|
+
throw new InvalidRouterConfigError({
|
|
880
|
+
filename,
|
|
881
|
+
line: body.start,
|
|
882
|
+
message: `unsupported HTTP method ${method} in ${filename} at line ${body.start}`,
|
|
883
|
+
});
|
|
837
884
|
}
|
|
838
885
|
break;
|
|
839
886
|
}
|
|
@@ -893,9 +940,11 @@ export async function parseRoute(
|
|
|
893
940
|
break;
|
|
894
941
|
}
|
|
895
942
|
default: {
|
|
896
|
-
throw new
|
|
897
|
-
|
|
898
|
-
|
|
943
|
+
throw new InvalidRouterConfigError({
|
|
944
|
+
filename,
|
|
945
|
+
line: body.start,
|
|
946
|
+
message: `unsupported router method ${method} in ${filename} at line ${body.start}`,
|
|
947
|
+
});
|
|
899
948
|
}
|
|
900
949
|
}
|
|
901
950
|
const thepath = `${routePrefix}/${routeName}/${suffix}`
|
|
@@ -924,8 +973,13 @@ export async function parseRoute(
|
|
|
924
973
|
}
|
|
925
974
|
}
|
|
926
975
|
} catch (error) {
|
|
927
|
-
|
|
928
|
-
|
|
976
|
+
if (error instanceof InvalidRouterConfigError) {
|
|
977
|
+
throw error;
|
|
978
|
+
}
|
|
979
|
+
throw new InvalidRouterConfigError({
|
|
980
|
+
filename,
|
|
981
|
+
cause: error,
|
|
982
|
+
});
|
|
929
983
|
}
|
|
930
984
|
return routes;
|
|
931
985
|
}
|
|
@@ -1019,6 +1073,431 @@ export function checkRouteConflicts(content: string, workbenchEndpoint: string):
|
|
|
1019
1073
|
}
|
|
1020
1074
|
}
|
|
1021
1075
|
|
|
1076
|
+
/**
|
|
1077
|
+
* Extract AppState type from setup() return value in createApp call
|
|
1078
|
+
*
|
|
1079
|
+
* @param content - The TypeScript source code from app.ts
|
|
1080
|
+
* @returns Type definition string or null if no setup found
|
|
1081
|
+
*/
|
|
1082
|
+
export function extractAppStateType(content: string): string | null {
|
|
1083
|
+
try {
|
|
1084
|
+
const sourceFile = ts.createSourceFile('app.ts', content, ts.ScriptTarget.Latest, true);
|
|
1085
|
+
let appStateType: string | null = null;
|
|
1086
|
+
let foundCreateApp = false;
|
|
1087
|
+
let foundSetup = false;
|
|
1088
|
+
|
|
1089
|
+
function visitNode(node: ts.Node): void {
|
|
1090
|
+
// Look for createApp call expression (can be on await expression)
|
|
1091
|
+
let callExpr: ts.CallExpression | undefined;
|
|
1092
|
+
|
|
1093
|
+
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression)) {
|
|
1094
|
+
if (node.expression.text === 'createApp') {
|
|
1095
|
+
foundCreateApp = true;
|
|
1096
|
+
callExpr = node;
|
|
1097
|
+
}
|
|
1098
|
+
} else if (ts.isAwaitExpression(node) && ts.isCallExpression(node.expression)) {
|
|
1099
|
+
const call = node.expression;
|
|
1100
|
+
if (ts.isIdentifier(call.expression) && call.expression.text === 'createApp') {
|
|
1101
|
+
foundCreateApp = true;
|
|
1102
|
+
callExpr = call;
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
if (callExpr) {
|
|
1107
|
+
// Check if it has a config object argument
|
|
1108
|
+
if (callExpr.arguments.length > 0) {
|
|
1109
|
+
const configArg = callExpr.arguments[0];
|
|
1110
|
+
if (ts.isObjectLiteralExpression(configArg)) {
|
|
1111
|
+
// Find setup property
|
|
1112
|
+
for (const prop of configArg.properties) {
|
|
1113
|
+
if (
|
|
1114
|
+
ts.isPropertyAssignment(prop) &&
|
|
1115
|
+
ts.isIdentifier(prop.name) &&
|
|
1116
|
+
prop.name.text === 'setup'
|
|
1117
|
+
) {
|
|
1118
|
+
foundSetup = true;
|
|
1119
|
+
// Found setup function - extract return type
|
|
1120
|
+
const setupFunc = prop.initializer;
|
|
1121
|
+
if (ts.isFunctionExpression(setupFunc) || ts.isArrowFunction(setupFunc)) {
|
|
1122
|
+
// Find return statement
|
|
1123
|
+
const returnObj = findReturnObject(setupFunc);
|
|
1124
|
+
if (returnObj) {
|
|
1125
|
+
appStateType = objectLiteralToTypeDefinition(returnObj, sourceFile);
|
|
1126
|
+
} else {
|
|
1127
|
+
logger.debug('No return object found in setup function');
|
|
1128
|
+
}
|
|
1129
|
+
} else {
|
|
1130
|
+
logger.debug(
|
|
1131
|
+
`Setup is not a function expression or arrow function, it's: ${ts.SyntaxKind[setupFunc.kind]}`
|
|
1132
|
+
);
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
ts.forEachChild(node, visitNode);
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
function findReturnObject(
|
|
1144
|
+
func: ts.FunctionExpression | ts.ArrowFunction
|
|
1145
|
+
): ts.ObjectLiteralExpression | null {
|
|
1146
|
+
let returnObject: ts.ObjectLiteralExpression | null = null;
|
|
1147
|
+
|
|
1148
|
+
function visitFuncNode(node: ts.Node): void {
|
|
1149
|
+
if (ts.isReturnStatement(node) && node.expression) {
|
|
1150
|
+
// Handle direct object literal
|
|
1151
|
+
if (ts.isObjectLiteralExpression(node.expression)) {
|
|
1152
|
+
returnObject = node.expression;
|
|
1153
|
+
}
|
|
1154
|
+
// Handle variable reference (const state = {...}; return state;)
|
|
1155
|
+
else if (ts.isIdentifier(node.expression)) {
|
|
1156
|
+
// Try to find the variable declaration
|
|
1157
|
+
const varName = node.expression.text;
|
|
1158
|
+
// Walk back through the function to find the declaration
|
|
1159
|
+
findVariableDeclaration(func.body!, varName);
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
ts.forEachChild(node, visitFuncNode);
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
function findVariableDeclaration(body: ts.Node, varName: string): void {
|
|
1166
|
+
function visitForVar(node: ts.Node): void {
|
|
1167
|
+
if (ts.isVariableStatement(node)) {
|
|
1168
|
+
for (const decl of node.declarationList.declarations) {
|
|
1169
|
+
if (ts.isIdentifier(decl.name) && decl.name.text === varName) {
|
|
1170
|
+
if (decl.initializer && ts.isObjectLiteralExpression(decl.initializer)) {
|
|
1171
|
+
returnObject = decl.initializer;
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
ts.forEachChild(node, visitForVar);
|
|
1177
|
+
}
|
|
1178
|
+
visitForVar(body);
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
if (func.body) {
|
|
1182
|
+
visitFuncNode(func.body);
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
return returnObject;
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
function objectLiteralToTypeDefinition(
|
|
1189
|
+
obj: ts.ObjectLiteralExpression,
|
|
1190
|
+
sourceFile: ts.SourceFile
|
|
1191
|
+
): string {
|
|
1192
|
+
const properties: string[] = [];
|
|
1193
|
+
|
|
1194
|
+
for (const prop of obj.properties) {
|
|
1195
|
+
if (ts.isPropertyAssignment(prop)) {
|
|
1196
|
+
const name = prop.name.getText(sourceFile);
|
|
1197
|
+
const value = prop.initializer;
|
|
1198
|
+
const typeStr = inferTypeFromValue(value, sourceFile);
|
|
1199
|
+
properties.push(`\t${name}: ${typeStr};`);
|
|
1200
|
+
} else if (ts.isShorthandPropertyAssignment(prop)) {
|
|
1201
|
+
const name = prop.name.getText(sourceFile);
|
|
1202
|
+
properties.push(`\t${name}: unknown;`);
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
return `{\n${properties.join('\n')}\n}`;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
function inferTypeFromValue(value: ts.Expression, sourceFile: ts.SourceFile): string {
|
|
1210
|
+
if (ts.isStringLiteral(value)) {
|
|
1211
|
+
return 'string';
|
|
1212
|
+
}
|
|
1213
|
+
if (ts.isNumericLiteral(value)) {
|
|
1214
|
+
return 'number';
|
|
1215
|
+
}
|
|
1216
|
+
if (
|
|
1217
|
+
value.kind === ts.SyntaxKind.TrueKeyword ||
|
|
1218
|
+
value.kind === ts.SyntaxKind.FalseKeyword
|
|
1219
|
+
) {
|
|
1220
|
+
return 'boolean';
|
|
1221
|
+
}
|
|
1222
|
+
if (ts.isNewExpression(value) && ts.isIdentifier(value.expression)) {
|
|
1223
|
+
if (value.expression.text === 'Date') {
|
|
1224
|
+
return 'Date';
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
if (ts.isObjectLiteralExpression(value)) {
|
|
1228
|
+
return objectLiteralToTypeDefinition(value, sourceFile);
|
|
1229
|
+
}
|
|
1230
|
+
if (ts.isArrayLiteralExpression(value)) {
|
|
1231
|
+
return 'unknown[]';
|
|
1232
|
+
}
|
|
1233
|
+
return 'unknown';
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
visitNode(sourceFile);
|
|
1237
|
+
|
|
1238
|
+
if (!foundCreateApp) {
|
|
1239
|
+
logger.debug('Did not find createApp call in app.ts');
|
|
1240
|
+
} else if (!foundSetup) {
|
|
1241
|
+
logger.debug('Found createApp but no setup property');
|
|
1242
|
+
} else if (!appStateType) {
|
|
1243
|
+
logger.debug('Found createApp and setup but could not extract type');
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
return appStateType;
|
|
1247
|
+
} catch (error) {
|
|
1248
|
+
logger.warn('AppState type extraction failed:', error);
|
|
1249
|
+
return null;
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
/**
|
|
1254
|
+
* Update tsconfig.json to add path mapping for @agentuity/runtime
|
|
1255
|
+
*
|
|
1256
|
+
* @param rootDir - Root directory of the project
|
|
1257
|
+
* @param shouldAdd - If true, add the mapping; if false, remove it
|
|
1258
|
+
*/
|
|
1259
|
+
async function updateTsconfigPathMapping(rootDir: string, shouldAdd: boolean): Promise<void> {
|
|
1260
|
+
const tsconfigPath = join(rootDir, 'tsconfig.json');
|
|
1261
|
+
|
|
1262
|
+
if (!(await Bun.file(tsconfigPath).exists())) {
|
|
1263
|
+
logger.debug('No tsconfig.json found, skipping path mapping update');
|
|
1264
|
+
return;
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
try {
|
|
1268
|
+
const tsconfigContent = await Bun.file(tsconfigPath).text();
|
|
1269
|
+
|
|
1270
|
+
// Use JSON5 to parse tsconfig.json (handles comments in input)
|
|
1271
|
+
const tsconfig = JSON5.parse(tsconfigContent);
|
|
1272
|
+
const _before = JSON.stringify(tsconfig);
|
|
1273
|
+
|
|
1274
|
+
// Initialize compilerOptions and paths if they don't exist
|
|
1275
|
+
if (!tsconfig.compilerOptions) {
|
|
1276
|
+
tsconfig.compilerOptions = {};
|
|
1277
|
+
}
|
|
1278
|
+
if (!tsconfig.compilerOptions.paths) {
|
|
1279
|
+
tsconfig.compilerOptions.paths = {};
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
if (shouldAdd) {
|
|
1283
|
+
// Add or update the path mapping
|
|
1284
|
+
tsconfig.compilerOptions.paths['@agentuity/runtime'] = [
|
|
1285
|
+
'./.agentuity/.agentuity_runtime.ts',
|
|
1286
|
+
];
|
|
1287
|
+
|
|
1288
|
+
// Ensure .agentuity_types.ts is included so module augmentation works
|
|
1289
|
+
if (!tsconfig.include) {
|
|
1290
|
+
tsconfig.include = [];
|
|
1291
|
+
}
|
|
1292
|
+
if (!tsconfig.include.includes('.agentuity/.agentuity_types.ts')) {
|
|
1293
|
+
tsconfig.include.push('.agentuity/.agentuity_types.ts');
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
logger.debug('Added @agentuity/runtime path mapping to tsconfig.json');
|
|
1297
|
+
} else {
|
|
1298
|
+
// Remove the path mapping if it exists
|
|
1299
|
+
if (tsconfig.compilerOptions.paths['@agentuity/runtime']) {
|
|
1300
|
+
delete tsconfig.compilerOptions.paths['@agentuity/runtime'];
|
|
1301
|
+
logger.debug('Removed @agentuity/runtime path mapping from tsconfig.json');
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
// Clean up empty paths object
|
|
1305
|
+
if (Object.keys(tsconfig.compilerOptions.paths).length === 0) {
|
|
1306
|
+
delete tsconfig.compilerOptions.paths;
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
const _after = JSON.stringify(tsconfig);
|
|
1311
|
+
if (_before === _after) {
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
// Write back using standard JSON (TypeScript requires strict JSON format)
|
|
1316
|
+
await Bun.write(tsconfigPath, JSON.stringify(tsconfig, null, '\t') + '\n');
|
|
1317
|
+
} catch (error) {
|
|
1318
|
+
logger.warn('Failed to update tsconfig.json:', error);
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
const RuntimePackageNotFound = StructuredError('RuntimePackageNotFound');
|
|
1323
|
+
|
|
1324
|
+
/**
|
|
1325
|
+
* Generate lifecycle type files (.agentuity/types.ts and .agentuity/.agentuity_runtime.ts)
|
|
1326
|
+
*
|
|
1327
|
+
* @param rootDir - Root directory of the project
|
|
1328
|
+
* @param appFilePath - Path to app.ts file
|
|
1329
|
+
* @returns true if files were generated, false if no setup found
|
|
1330
|
+
*/
|
|
1331
|
+
export async function generateLifecycleTypes(
|
|
1332
|
+
rootDir: string,
|
|
1333
|
+
outDir: string,
|
|
1334
|
+
appFilePath: string
|
|
1335
|
+
): Promise<boolean> {
|
|
1336
|
+
const appContent = await Bun.file(appFilePath).text();
|
|
1337
|
+
if (typeof appContent !== 'string') {
|
|
1338
|
+
return false;
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
const appStateType = extractAppStateType(appContent as string);
|
|
1342
|
+
|
|
1343
|
+
if (!appStateType) {
|
|
1344
|
+
logger.debug('No setup() function found in app.ts, skipping lifecycle type generation');
|
|
1345
|
+
// Remove path mapping if no setup found
|
|
1346
|
+
await updateTsconfigPathMapping(rootDir, false);
|
|
1347
|
+
return false;
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
const agentuityDir = join(rootDir, '.agentuity');
|
|
1351
|
+
|
|
1352
|
+
// Ensure .agentuity directory exists
|
|
1353
|
+
if (!existsSync(agentuityDir)) {
|
|
1354
|
+
mkdirSync(agentuityDir, { recursive: true });
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
// First, determine the runtime package location
|
|
1358
|
+
// Try multiple locations: app-level node_modules, then monorepo root
|
|
1359
|
+
const appLevelPath = join(rootDir, 'node_modules', '@agentuity', 'runtime');
|
|
1360
|
+
// From apps/testing/auth-app to monorepo root is 3 levels up (../../..)
|
|
1361
|
+
const rootLevelPath = join(rootDir, '..', '..', '..', 'node_modules', '@agentuity', 'runtime');
|
|
1362
|
+
|
|
1363
|
+
let runtimePkgPath: string;
|
|
1364
|
+
if (existsSync(appLevelPath)) {
|
|
1365
|
+
runtimePkgPath = appLevelPath;
|
|
1366
|
+
logger.debug(`Found runtime package at app level: ${appLevelPath}`);
|
|
1367
|
+
} else if (existsSync(rootLevelPath)) {
|
|
1368
|
+
runtimePkgPath = rootLevelPath;
|
|
1369
|
+
logger.debug(`Found runtime package at root level: ${rootLevelPath}`);
|
|
1370
|
+
} else {
|
|
1371
|
+
throw new RuntimePackageNotFound({
|
|
1372
|
+
message:
|
|
1373
|
+
`@agentuity/runtime package not found in:\n` +
|
|
1374
|
+
` - ${appLevelPath}\n` +
|
|
1375
|
+
` - ${rootLevelPath}\n` +
|
|
1376
|
+
`Make sure dependencies are installed by running 'bun install' or 'npm install'`,
|
|
1377
|
+
});
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
let runtimeImportPath: string | null = null;
|
|
1381
|
+
|
|
1382
|
+
// Calculate relative path from .agentuity/ to the package location
|
|
1383
|
+
// Don't resolve symlinks - we want to use the symlink path so it works in both
|
|
1384
|
+
// local dev (symlinked to packages/) and CI (actual node_modules)
|
|
1385
|
+
if (existsSync(runtimePkgPath)) {
|
|
1386
|
+
// Calculate relative path from .agentuity/ to node_modules package
|
|
1387
|
+
const relPath = relative(agentuityDir, runtimePkgPath);
|
|
1388
|
+
runtimeImportPath = relPath;
|
|
1389
|
+
logger.debug(`Using relative path to runtime package: ${relPath}`);
|
|
1390
|
+
} else {
|
|
1391
|
+
throw new RuntimePackageNotFound({
|
|
1392
|
+
message:
|
|
1393
|
+
`Failed to access @agentuity/runtime package at ${runtimePkgPath}\n` +
|
|
1394
|
+
`Make sure dependencies are installed`,
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
if (!runtimeImportPath) {
|
|
1399
|
+
throw new RuntimePackageNotFound({
|
|
1400
|
+
message: `Failed to determine import path for @agentuity/runtime`,
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
// Now generate .agentuity_types.ts
|
|
1405
|
+
// NOTE: We can ONLY augment the package name, not relative paths
|
|
1406
|
+
// TypeScript resolves @agentuity/runtime through path mapping -> wrapper -> actual package
|
|
1407
|
+
const typesContent = `// AUTO-GENERATED from app.ts setup() return type
|
|
1408
|
+
// This file is auto-generated by the build tool - do not edit manually
|
|
1409
|
+
|
|
1410
|
+
/**
|
|
1411
|
+
* Application state type inferred from your createApp setup function.
|
|
1412
|
+
* This type is automatically generated and available throughout your app via ctx.app.
|
|
1413
|
+
*
|
|
1414
|
+
* @example
|
|
1415
|
+
* \`\`\`typescript
|
|
1416
|
+
* // In your agents:
|
|
1417
|
+
* const agent = createAgent({
|
|
1418
|
+
* handler: async (ctx, input) => {
|
|
1419
|
+
* // ctx.app is strongly typed as GeneratedAppState
|
|
1420
|
+
* const value = ctx.app; // All properties from your setup return value
|
|
1421
|
+
* return 'result';
|
|
1422
|
+
* }
|
|
1423
|
+
* });
|
|
1424
|
+
* \`\`\`
|
|
1425
|
+
*/
|
|
1426
|
+
export type GeneratedAppState = ${appStateType};
|
|
1427
|
+
|
|
1428
|
+
// Augment the @agentuity/runtime module with AppState
|
|
1429
|
+
// This will be picked up when imported through the wrapper
|
|
1430
|
+
declare module '@agentuity/runtime' {
|
|
1431
|
+
interface AppState extends GeneratedAppState {}
|
|
1432
|
+
}
|
|
1433
|
+
`;
|
|
1434
|
+
const typesPath = join(outDir, '.agentuity_types.ts');
|
|
1435
|
+
await Bun.write(typesPath, typesContent);
|
|
1436
|
+
logger.debug(`Generated lifecycle types: ${typesPath}`);
|
|
1437
|
+
|
|
1438
|
+
const wrapperContent = `// AUTO-GENERATED runtime wrapper
|
|
1439
|
+
// This file is auto-generated by the build tool - do not edit manually
|
|
1440
|
+
|
|
1441
|
+
// Import augmentations file (NOT type-only) to trigger module augmentation
|
|
1442
|
+
import type { GeneratedAppState } from './.agentuity_types';
|
|
1443
|
+
import './.agentuity_types';
|
|
1444
|
+
|
|
1445
|
+
// Import from actual package location
|
|
1446
|
+
import { createRouter as baseCreateRouter, type Env } from '${runtimeImportPath}/src/index';
|
|
1447
|
+
import type { Hono } from 'hono';
|
|
1448
|
+
|
|
1449
|
+
// Type aliases to avoid repeating the generic parameter
|
|
1450
|
+
type AppEnv = Env<GeneratedAppState>;
|
|
1451
|
+
type AppRouter = Hono<AppEnv>;
|
|
1452
|
+
|
|
1453
|
+
/**
|
|
1454
|
+
* Creates a Hono router with extended methods for Agentuity-specific routing patterns.
|
|
1455
|
+
*
|
|
1456
|
+
* In addition to standard HTTP methods (get, post, put, delete, patch), the router includes:
|
|
1457
|
+
* - **stream()** - Stream responses with ReadableStream
|
|
1458
|
+
* - **websocket()** - WebSocket connections
|
|
1459
|
+
* - **sse()** - Server-Sent Events
|
|
1460
|
+
* - **email()** - Email handler routing
|
|
1461
|
+
* - **sms()** - SMS handler routing
|
|
1462
|
+
* - **cron()** - Scheduled task routing
|
|
1463
|
+
*
|
|
1464
|
+
* @returns Extended Hono router with custom methods and app state typing
|
|
1465
|
+
*
|
|
1466
|
+
* @example
|
|
1467
|
+
* \`\`\`typescript
|
|
1468
|
+
* const router = createRouter();
|
|
1469
|
+
*
|
|
1470
|
+
* // Standard HTTP routes
|
|
1471
|
+
* router.get('/hello', (c) => c.text('Hello!'));
|
|
1472
|
+
* router.post('/data', async (c) => {
|
|
1473
|
+
* const body = await c.req.json();
|
|
1474
|
+
* return c.json({ received: body });
|
|
1475
|
+
* });
|
|
1476
|
+
*
|
|
1477
|
+
* // Access app state (strongly typed!)
|
|
1478
|
+
* router.get('/db', (c) => {
|
|
1479
|
+
* const db = c.var.app; // Your app state from createApp setup
|
|
1480
|
+
* return c.json({ connected: true });
|
|
1481
|
+
* });
|
|
1482
|
+
* \`\`\`
|
|
1483
|
+
*/
|
|
1484
|
+
export function createRouter(): AppRouter {
|
|
1485
|
+
return baseCreateRouter() as any;
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
// Re-export everything else
|
|
1489
|
+
export * from '${runtimeImportPath}/src/index';
|
|
1490
|
+
`;
|
|
1491
|
+
const wrapperPath = join(outDir, '.agentuity_runtime.ts');
|
|
1492
|
+
await Bun.write(wrapperPath, wrapperContent);
|
|
1493
|
+
logger.debug(`Generated lifecycle wrapper: ${wrapperPath}`);
|
|
1494
|
+
|
|
1495
|
+
// Update tsconfig.json with path mapping
|
|
1496
|
+
await updateTsconfigPathMapping(rootDir, true);
|
|
1497
|
+
|
|
1498
|
+
return true;
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1022
1501
|
/**
|
|
1023
1502
|
* Analyze workbench usage and extract configuration
|
|
1024
1503
|
*
|
|
@@ -1115,3 +1594,98 @@ function parseConfigObject(node: ts.Node): WorkbenchConfig | null {
|
|
|
1115
1594
|
|
|
1116
1595
|
return config;
|
|
1117
1596
|
}
|
|
1597
|
+
|
|
1598
|
+
/**
|
|
1599
|
+
* Find the end position of createApp call statement in the source code
|
|
1600
|
+
* Uses AST parsing to reliably find the complete statement including await/const assignment
|
|
1601
|
+
*
|
|
1602
|
+
* @param content - The source code content
|
|
1603
|
+
* @returns The character position after the createApp statement, or -1 if not found
|
|
1604
|
+
*/
|
|
1605
|
+
export function findCreateAppEndPosition(content: string): number {
|
|
1606
|
+
try {
|
|
1607
|
+
const ast = acornLoose.parse(content, {
|
|
1608
|
+
ecmaVersion: 'latest',
|
|
1609
|
+
sourceType: 'module',
|
|
1610
|
+
}) as ASTProgram;
|
|
1611
|
+
|
|
1612
|
+
// Walk through all top-level statements
|
|
1613
|
+
for (const node of ast.body) {
|
|
1614
|
+
let targetNode: ASTNode | undefined;
|
|
1615
|
+
|
|
1616
|
+
// Check for: const app = await createApp(...)
|
|
1617
|
+
if (node.type === 'VariableDeclaration') {
|
|
1618
|
+
const varDecl = node as unknown as { declarations: ASTVariableDeclarator[] };
|
|
1619
|
+
for (const declarator of varDecl.declarations) {
|
|
1620
|
+
if (declarator.init) {
|
|
1621
|
+
// Handle await createApp(...)
|
|
1622
|
+
if (declarator.init.type === 'AwaitExpression') {
|
|
1623
|
+
const awaitExpr = declarator.init as unknown as {
|
|
1624
|
+
argument: ASTCallExpression;
|
|
1625
|
+
};
|
|
1626
|
+
if (
|
|
1627
|
+
awaitExpr.argument?.type === 'CallExpression' &&
|
|
1628
|
+
isCreateAppCall(awaitExpr.argument)
|
|
1629
|
+
) {
|
|
1630
|
+
targetNode = node;
|
|
1631
|
+
break;
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
// Handle createApp(...) without await
|
|
1635
|
+
else if (declarator.init.type === 'CallExpression') {
|
|
1636
|
+
if (isCreateAppCall(declarator.init as ASTCallExpression)) {
|
|
1637
|
+
targetNode = node;
|
|
1638
|
+
break;
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
// Check for: await createApp(...)
|
|
1645
|
+
else if (node.type === 'ExpressionStatement') {
|
|
1646
|
+
const exprStmt = node as ASTExpressionStatement;
|
|
1647
|
+
if (exprStmt.expression.type === 'AwaitExpression') {
|
|
1648
|
+
const awaitExpr = exprStmt.expression as unknown as { argument: ASTCallExpression };
|
|
1649
|
+
if (
|
|
1650
|
+
awaitExpr.argument?.type === 'CallExpression' &&
|
|
1651
|
+
isCreateAppCall(awaitExpr.argument)
|
|
1652
|
+
) {
|
|
1653
|
+
targetNode = node;
|
|
1654
|
+
}
|
|
1655
|
+
} else if (exprStmt.expression.type === 'CallExpression') {
|
|
1656
|
+
if (isCreateAppCall(exprStmt.expression as ASTCallExpression)) {
|
|
1657
|
+
targetNode = node;
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
if (targetNode && targetNode.end !== undefined) {
|
|
1663
|
+
// Find the semicolon after the statement (if it exists)
|
|
1664
|
+
const afterStmt = content.slice(targetNode.end);
|
|
1665
|
+
const semiMatch = afterStmt.match(/^\s*;/);
|
|
1666
|
+
if (semiMatch) {
|
|
1667
|
+
return targetNode.end + semiMatch[0].length;
|
|
1668
|
+
}
|
|
1669
|
+
// No semicolon, return end of statement
|
|
1670
|
+
return targetNode.end;
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
return -1;
|
|
1675
|
+
} catch (error) {
|
|
1676
|
+
logger.warn('Failed to parse AST for createApp detection:', error);
|
|
1677
|
+
return -1;
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
/**
|
|
1682
|
+
* Check if a CallExpression is a call to createApp
|
|
1683
|
+
*/
|
|
1684
|
+
function isCreateAppCall(node: ASTCallExpression): boolean {
|
|
1685
|
+
const callee = node.callee;
|
|
1686
|
+
if (callee.type === 'Identifier') {
|
|
1687
|
+
const id = callee as ASTNodeIdentifier;
|
|
1688
|
+
return id.name === 'createApp';
|
|
1689
|
+
}
|
|
1690
|
+
return false;
|
|
1691
|
+
}
|