feat(cli): eliminate --org-id requirement for resource lookup commands#876
feat(cli): eliminate --org-id requirement for resource lookup commands#876
Conversation
Use new CLI API endpoints to auto-discover organization context for:
- sandbox list/get/delete/exec/cp/ls/mkdir/rm/rmdir/upload/download/env
- storage list/get
- db get
- stream list/get
New SDK functions:
- sandboxResolve(): resolves sandbox ID to get region and orgId via /cli/sandbox/{id}
- cliSandboxList(): lists sandboxes across all orgs via /cli/sandbox
Commands now use apiClient with CLI API instead of requiring --org-id flag.
Create operations (sandbox create, db create, etc.) still require --org-id.
Tested all commands - see PR for full test matrix.
📝 WalkthroughWalkthroughCommands and utilities were refactored to use API-driven multi-organization resolution: sandbox commands now resolve region/org via sandboxResolve(apiClient), stream and sandbox list/get use new server APIs, cache schema extended (project_id), CLI gained prefixed-resource handling and resourceRules metadata, and several commands switched from org to apiClient requirements. Changes
🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 🧹 Recent nitpick comments
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used📓 Path-based instructions (4)**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
packages/server/src/**/*.ts📄 CodeRabbit inference engine (packages/server/AGENTS.md)
Files:
packages/server/src/api/**/*.ts📄 CodeRabbit inference engine (packages/server/AGENTS.md)
Files:
packages/cli/**/*.ts📄 CodeRabbit inference engine (packages/cli/AGENTS.md)
Files:
🧠 Learnings (3)📚 Learning: 2025-12-19T14:19:33.765ZApplied to files:
📚 Learning: 2025-12-21T00:31:41.858ZApplied to files:
📚 Learning: 2025-12-30T00:13:37.849ZApplied to files:
🧬 Code graph analysis (1)packages/server/src/api/sandbox/resolve.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
🔇 Additional comments (12)
✏️ Tip: You can disable this entire section by setting Comment |
There was a problem hiding this comment.
Actionable comments posted: 7
🤖 Fix all issues with AI agents
In `@packages/cli/src/cmd/cloud/db/get.ts`:
- Around line 123-128: The call to dbTables passes db.org_id directly even
though org_id is optional on the DB record; update the closure to validate that
db.org_id is present before calling dbTables (or explicitly handle the absent
case). Locate the block that returns dbTables(regionalClient, { database:
args.name, orgId: db.org_id, region }) and either (a) throw or return a clear
user-facing error if db.org_id is undefined, or (b) call dbTables without orgId
when org_id is missing (if dbTables supports it); ensure you reference
db.org_id, dbTables, regionalClient and args.name in your change and add a short
comment explaining the chosen behavior.
- Around line 54-69: The SubcommandDefBase type is missing the resourceRules
property used by CLI subcommand defs; update the SubcommandDefBase definition
(in packages/cli/src/types.ts) to include a resourceRules?: ResourceRule[] (or
similar) property whose element shape matches the objects used (fields like
resource: string, required?: boolean, flag?: string, envVar?: string,
canUseCache?: boolean, operationType?: string) so TypeScript recognizes
resourceRules in get.ts and other subcommand files; add or create a ResourceRule
interface/type and reference it from SubcommandDefBase to preserve type safety.
In `@packages/cli/src/cmd/cloud/sandbox/util.ts`:
- Line 6: Remove the invalid import of getCatalystUrl from '../../../catalyst'
at the top of util.ts (delete the import line and any direct references to that
symbol), and replace the Node.js existsSync(...) usage in the file existence
check with the Bun API: use Bun.file(path).exists() (or await
Bun.file(path).exists() if used in an async context) so the check follows the
packages/cli coding guideline; update any surrounding logic to handle the
boolean result from Bun.file(...).exists().
In `@packages/cli/src/cmd/cloud/stream/get.ts`:
- Line 2: The import of streamGet from '@agentuity/server' fails because the
server package does not export a './stream' module; either add a new module that
exports the streamGet function (ensure it's exported from server's api/index.ts)
or change this file's import to the correct exported API name from
'@agentuity/server'; also replace all uses of tui.fatal (including the error
handling block that currently calls tui.fatal) with throwing or returning a
StructuredError from '@agentuity/core' (import StructuredError and use it for
error construction and propagation) so error handling conforms to the coding
guidelines.
In `@packages/cli/src/cmd/cloud/stream/list.ts`:
- Around line 1-6: Create a new API module that exports the missing symbols: add
packages/server/src/api/stream.ts which defines and exports an async function
streamList(...) (implement it to call the existing server/backend list logic or
return the appropriate data) and re-export the StreamInfo type from
'@agentuity/core' (export { type StreamInfo } from '@agentuity/core'), then
ensure packages/server/src/api/index.ts includes `export * from './stream'` so
`@agentuity/server` exposes streamList and StreamInfo; finally, update the catch
block in packages/cli/src/cmd/cloud/stream/list.ts to import and use
StructuredError from '@agentuity/core' (use `if (err instanceof StructuredError)
{ ... }` and log its structured details) to match coding guidelines.
In `@packages/server/src/api/index.ts`:
- Line 12: The export line "export * from './stream';" in
packages/server/src/api/index.ts references a non-existent module and causes
TS2307; either add the missing stream API module (implement index.ts under the
'./stream' API namespace exporting the expected public functions/types) or
update the export to the correct existing module path/name (e.g., change
'./stream' to the actual module that contains the stream API) so that the symbol
exported by index.ts resolves and the TypeScript build succeeds.
In `@packages/server/src/api/sandbox/resolve.ts`:
- Around line 37-44: Replace the custom SandboxResolveError class with one that
extends or instantiates StructuredError from `@agentuity/core` so status,
code/statusCode and cause propagate consistently; import StructuredError from
'@agentuity/core', update the constructor for SandboxResolveError (or replace
it) to pass message, statusCode (or code) and optional cause into
StructuredError’s API, keep the exported name SandboxResolveError so call sites
remain unchanged, and ensure the error.name still reflects 'SandboxResolveError'
if needed.
🧹 Nitpick comments (1)
packages/cli/src/cmd/cloud/sandbox/util.ts (1)
109-109: UseBun.file().exists()instead ofexistsSync.As per coding guidelines,
packages/cli/**/*.tsfiles should useBun.file(f).exists()instead ofexistsSync(f)for file existence checks.♻️ Proposed fix
-import { existsSync, readFileSync } from 'node:fs'; +import { readFileSync } from 'node:fs';const resolvedPath = resolve(localPath); - if (!existsSync(resolvedPath)) { + if (!(await Bun.file(resolvedPath).exists())) { throw new Error(`File not found: ${localPath} (resolved to ${resolvedPath})`); }Note: This change also requires making
parseFileArgsan async function and updating all call sites accordingly.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (23)
packages/cli/src/cmd/cloud/db/get.tspackages/cli/src/cmd/cloud/sandbox/cp.tspackages/cli/src/cmd/cloud/sandbox/delete.tspackages/cli/src/cmd/cloud/sandbox/download.tspackages/cli/src/cmd/cloud/sandbox/env.tspackages/cli/src/cmd/cloud/sandbox/exec.tspackages/cli/src/cmd/cloud/sandbox/get.tspackages/cli/src/cmd/cloud/sandbox/list.tspackages/cli/src/cmd/cloud/sandbox/ls.tspackages/cli/src/cmd/cloud/sandbox/mkdir.tspackages/cli/src/cmd/cloud/sandbox/rm.tspackages/cli/src/cmd/cloud/sandbox/rmdir.tspackages/cli/src/cmd/cloud/sandbox/upload.tspackages/cli/src/cmd/cloud/sandbox/util.tspackages/cli/src/cmd/cloud/storage/get.tspackages/cli/src/cmd/cloud/storage/list.tspackages/cli/src/cmd/cloud/stream/get.tspackages/cli/src/cmd/cloud/stream/list.tspackages/cli/src/cmd/cloud/stream/util.tspackages/server/src/api/index.tspackages/server/src/api/sandbox/cli-list.tspackages/server/src/api/sandbox/index.tspackages/server/src/api/sandbox/resolve.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Use Prettier formatter with tabs (width 3), single quotes, and semicolons for TypeScript files
Use TypeScript strict mode with ESNext target and bundler moduleResolution
UseStructuredErrorfrom@agentuity/corefor error handling
Files:
packages/server/src/api/index.tspackages/server/src/api/sandbox/resolve.tspackages/cli/src/cmd/cloud/storage/list.tspackages/cli/src/cmd/cloud/sandbox/upload.tspackages/server/src/api/sandbox/cli-list.tspackages/cli/src/cmd/cloud/storage/get.tspackages/cli/src/cmd/cloud/sandbox/delete.tspackages/cli/src/cmd/cloud/stream/get.tspackages/cli/src/cmd/cloud/sandbox/exec.tspackages/cli/src/cmd/cloud/sandbox/rmdir.tspackages/cli/src/cmd/cloud/stream/util.tspackages/cli/src/cmd/cloud/db/get.tspackages/cli/src/cmd/cloud/sandbox/get.tspackages/cli/src/cmd/cloud/sandbox/download.tspackages/cli/src/cmd/cloud/sandbox/cp.tspackages/cli/src/cmd/cloud/sandbox/rm.tspackages/cli/src/cmd/cloud/sandbox/ls.tspackages/cli/src/cmd/cloud/sandbox/util.tspackages/cli/src/cmd/cloud/stream/list.tspackages/cli/src/cmd/cloud/sandbox/env.tspackages/cli/src/cmd/cloud/sandbox/list.tspackages/cli/src/cmd/cloud/sandbox/mkdir.tspackages/server/src/api/sandbox/index.ts
packages/server/src/**/*.ts
📄 CodeRabbit inference engine (packages/server/AGENTS.md)
packages/server/src/**/*.ts: All code must be written in TypeScript
Use zod for runtime validation of schemas and data
Files:
packages/server/src/api/index.tspackages/server/src/api/sandbox/resolve.tspackages/server/src/api/sandbox/cli-list.tspackages/server/src/api/sandbox/index.ts
packages/server/src/api/**/*.ts
📄 CodeRabbit inference engine (packages/server/AGENTS.md)
Organize API clients by feature domain in src/api/ subdirectories (apikey, db, eval, org, project, queue, region, sandbox, session, thread, user)
Files:
packages/server/src/api/index.tspackages/server/src/api/sandbox/resolve.tspackages/server/src/api/sandbox/cli-list.tspackages/server/src/api/sandbox/index.ts
packages/cli/**/*.ts
📄 CodeRabbit inference engine (packages/cli/AGENTS.md)
Use
Bun.file(f).exists()instead ofexistsSync(f)for file existence checks
Files:
packages/cli/src/cmd/cloud/storage/list.tspackages/cli/src/cmd/cloud/sandbox/upload.tspackages/cli/src/cmd/cloud/storage/get.tspackages/cli/src/cmd/cloud/sandbox/delete.tspackages/cli/src/cmd/cloud/stream/get.tspackages/cli/src/cmd/cloud/sandbox/exec.tspackages/cli/src/cmd/cloud/sandbox/rmdir.tspackages/cli/src/cmd/cloud/stream/util.tspackages/cli/src/cmd/cloud/db/get.tspackages/cli/src/cmd/cloud/sandbox/get.tspackages/cli/src/cmd/cloud/sandbox/download.tspackages/cli/src/cmd/cloud/sandbox/cp.tspackages/cli/src/cmd/cloud/sandbox/rm.tspackages/cli/src/cmd/cloud/sandbox/ls.tspackages/cli/src/cmd/cloud/sandbox/util.tspackages/cli/src/cmd/cloud/stream/list.tspackages/cli/src/cmd/cloud/sandbox/env.tspackages/cli/src/cmd/cloud/sandbox/list.tspackages/cli/src/cmd/cloud/sandbox/mkdir.ts
🧠 Learnings (4)
📚 Learning: 2025-12-19T14:19:33.765Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 259
File: packages/cli/src/cmd/build/vite/registry-generator.ts:306-312
Timestamp: 2025-12-19T14:19:33.765Z
Learning: Route files under src/api should use the .ts extension only (no .tsx) and regex patterns for such paths should anchor to \.ts$ (e.g., /\/.ts$/). Agent files may support both .ts and .tsx, but route files in the Agentuity SDK codebase are restricted to .ts. This guideline applies to all similar route files under src/api across the repository.
Applied to files:
packages/server/src/api/index.tspackages/server/src/api/sandbox/resolve.tspackages/server/src/api/sandbox/cli-list.tspackages/server/src/api/sandbox/index.ts
📚 Learning: 2025-12-21T00:31:41.858Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 274
File: packages/cli/src/cmd/build/vite/server-bundler.ts:12-41
Timestamp: 2025-12-21T00:31:41.858Z
Learning: In Bun runtime, BuildMessage and ResolveMessage are global types and are not exported from the bun module. Do not import { BuildMessage } from 'bun' or similar; these types are available globally and should be used without import. This applies to all TypeScript files that target the Bun runtime within the repository.
Applied to files:
packages/server/src/api/index.tspackages/server/src/api/sandbox/resolve.tspackages/cli/src/cmd/cloud/storage/list.tspackages/cli/src/cmd/cloud/sandbox/upload.tspackages/server/src/api/sandbox/cli-list.tspackages/cli/src/cmd/cloud/storage/get.tspackages/cli/src/cmd/cloud/sandbox/delete.tspackages/cli/src/cmd/cloud/stream/get.tspackages/cli/src/cmd/cloud/sandbox/exec.tspackages/cli/src/cmd/cloud/sandbox/rmdir.tspackages/cli/src/cmd/cloud/stream/util.tspackages/cli/src/cmd/cloud/db/get.tspackages/cli/src/cmd/cloud/sandbox/get.tspackages/cli/src/cmd/cloud/sandbox/download.tspackages/cli/src/cmd/cloud/sandbox/cp.tspackages/cli/src/cmd/cloud/sandbox/rm.tspackages/cli/src/cmd/cloud/sandbox/ls.tspackages/cli/src/cmd/cloud/sandbox/util.tspackages/cli/src/cmd/cloud/stream/list.tspackages/cli/src/cmd/cloud/sandbox/env.tspackages/cli/src/cmd/cloud/sandbox/list.tspackages/cli/src/cmd/cloud/sandbox/mkdir.tspackages/server/src/api/sandbox/index.ts
📚 Learning: 2025-12-30T00:13:37.849Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 355
File: packages/server/src/api/sandbox/util.ts:2-6
Timestamp: 2025-12-30T00:13:37.849Z
Learning: In the packages/server tree, treat code as runtime-agnostic between Node.js and Bun. Ensure TypeScript files (e.g., util.ts) import and use APIs in a way that works under both runtimes. It is acceptable to rely on Bun’s Node.js compatibility for built-ins accessed via the node: namespace (e.g., node:events, node:stream, node:buffer). During reviews, prefer patterns and imports that remain compatible with Bun's environment, and flag any hard dependencies on runtime-specific globals or non-portable Node APIs.
Applied to files:
packages/server/src/api/index.tspackages/server/src/api/sandbox/resolve.tspackages/server/src/api/sandbox/cli-list.tspackages/server/src/api/sandbox/index.ts
📚 Learning: 2026-01-13T04:32:02.691Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 565
File: packages/cli/src/cmd/cloud/region-lookup.ts:14-26
Timestamp: 2026-01-13T04:32:02.691Z
Learning: Enforce sandbox identifier prefixes in new code within the CLI cloud region lookup: new sandboxes must use the sbx_ prefix. The snbx_ prefix may appear in legacy code or examples, but do not use snbx_ for new sandboxes. When reviewing changes in packages/cli/src/cmd/cloud/, ensure any created sandbox identifiers use sbx_ and remove or migrate any snbx_ usages in newly added code.
Applied to files:
packages/cli/src/cmd/cloud/storage/list.tspackages/cli/src/cmd/cloud/sandbox/upload.tspackages/cli/src/cmd/cloud/storage/get.tspackages/cli/src/cmd/cloud/sandbox/delete.tspackages/cli/src/cmd/cloud/stream/get.tspackages/cli/src/cmd/cloud/sandbox/exec.tspackages/cli/src/cmd/cloud/sandbox/rmdir.tspackages/cli/src/cmd/cloud/stream/util.tspackages/cli/src/cmd/cloud/db/get.tspackages/cli/src/cmd/cloud/sandbox/get.tspackages/cli/src/cmd/cloud/sandbox/download.tspackages/cli/src/cmd/cloud/sandbox/cp.tspackages/cli/src/cmd/cloud/sandbox/rm.tspackages/cli/src/cmd/cloud/sandbox/ls.tspackages/cli/src/cmd/cloud/sandbox/util.tspackages/cli/src/cmd/cloud/stream/list.tspackages/cli/src/cmd/cloud/sandbox/env.tspackages/cli/src/cmd/cloud/sandbox/list.tspackages/cli/src/cmd/cloud/sandbox/mkdir.ts
🧬 Code graph analysis (11)
packages/server/src/api/sandbox/resolve.ts (1)
packages/server/src/api/sandbox/index.ts (3)
ResolvedSandboxInfo(8-8)SandboxResolveError(7-7)sandboxResolve(7-7)
packages/cli/src/cmd/cloud/storage/list.ts (3)
packages/cli/src/config.ts (1)
getGlobalCatalystAPIClient(815-824)packages/server/src/api/org/resources.ts (1)
listOrgResources(73-104)packages/cli/src/cache/resource-region.ts (1)
setResourceInfo(114-131)
packages/cli/src/cmd/cloud/sandbox/upload.ts (2)
packages/server/src/api/sandbox/index.ts (1)
sandboxResolve(7-7)packages/server/src/api/sandbox/resolve.ts (1)
sandboxResolve(56-77)
packages/cli/src/cmd/cloud/storage/get.ts (3)
packages/server/src/api/org/resources.ts (1)
listOrgResources(73-104)packages/cli/src/cache/index.ts (1)
setResourceInfo(4-4)packages/cli/src/cache/resource-region.ts (1)
setResourceInfo(114-131)
packages/cli/src/cmd/cloud/stream/get.ts (1)
packages/cli/src/index.ts (1)
ErrorCode(12-12)
packages/cli/src/cmd/cloud/sandbox/rmdir.ts (1)
packages/server/src/api/sandbox/resolve.ts (1)
sandboxResolve(56-77)
packages/cli/src/cmd/cloud/stream/util.ts (4)
packages/cli/src/types.ts (2)
Logger(12-12)AuthData(279-283)packages/server/src/config.ts (1)
getServiceUrls(28-41)packages/server/src/server.ts (1)
createServerFetchAdapter(376-378)packages/core/src/services/stream.ts (1)
StreamStorageService(648-880)
packages/cli/src/cmd/cloud/sandbox/get.ts (3)
packages/server/src/api/sandbox/resolve.ts (1)
sandboxResolve(56-77)packages/cli/src/cmd/cloud/sandbox/util.ts (1)
createSandboxClient(12-14)packages/server/src/api/sandbox/get.ts (1)
sandboxGet(163-216)
packages/cli/src/cmd/cloud/sandbox/download.ts (1)
packages/server/src/api/sandbox/resolve.ts (1)
sandboxResolve(56-77)
packages/cli/src/cmd/cloud/sandbox/env.ts (2)
packages/server/src/api/sandbox/index.ts (1)
sandboxResolve(7-7)packages/server/src/api/sandbox/resolve.ts (1)
sandboxResolve(56-77)
packages/cli/src/cmd/cloud/sandbox/mkdir.ts (1)
packages/server/src/api/sandbox/resolve.ts (1)
sandboxResolve(56-77)
🪛 GitHub Actions: Build Packages & Test
packages/server/src/api/index.ts
[error] 12-12: TS2307: Cannot find module './stream' or its corresponding type declarations.
packages/cli/src/cmd/cloud/stream/get.ts
[error] 2-2: TS2305: Module '"@agentuity/server"' has no exported member 'streamGet'.
packages/cli/src/cmd/cloud/db/get.ts
[error] 54-54: TS2353: Object literal may only specify known properties, and 'resourceRules' does not exist in type '{ name: string; description: string; banner?: true | undefined; aliases?: string[] | undefined; toplevel?: boolean | undefined; skipInternalLogging?: boolean | undefined; requires?: { auth: true; } | undefined; ... 9 more ...; handler(ctx: CommandContext<...>): { ...; } | ... 1 more ... | Promise<...>; }'.
packages/cli/src/cmd/cloud/sandbox/util.ts
[error] 6-6: TS2307: Cannot find module '../../../catalyst' or its corresponding type declarations.
packages/cli/src/cmd/cloud/stream/list.ts
[error] 2-2: TS2724: '"@agentuity/server"' has no exported member named 'streamList'. Did you mean 'threadList'?
[error] 2-2: TS2305: Module '"@agentuity/server"' has no exported member 'StreamInfo'.
🪛 GitHub Actions: NPM Pack & Upload
packages/server/src/api/index.ts
[error] 12-15: Cannot find module './stream' or its corresponding type declarations.
packages/cli/src/cmd/cloud/stream/get.ts
[error] 2-2: Module '"@agentuity/server"' has no exported member 'streamGet'.
packages/cli/src/cmd/cloud/db/get.ts
[error] 54-54: Object literal may only specify known properties, and 'resourceRules' does not exist in type '{ name: string; description: string; banner?: true | undefined; aliases?: string[] | undefined; toplevel?: boolean | undefined; skipInternalLogging?: boolean | undefined; requires?: { auth: true; } | undefined; ... 9 more ...; handler(ctx: CommandContext<...>): { ...; } | ... 1 more ... | Promise<...>; }'.
packages/cli/src/cmd/cloud/sandbox/util.ts
[error] 6-6: Cannot find module '../../../catalyst' or its corresponding type declarations.
packages/cli/src/cmd/cloud/stream/list.ts
[error] 2-2: Module '"@agentuity/server"' has no exported member named 'streamList'. Did you mean 'threadList'?
[error] 2-2: Module '"@agentuity/server"' has no exported member 'StreamInfo'.
🪛 GitHub Actions: Package Smoke Test
packages/server/src/api/index.ts
[error] 12-15: bun run build failed: Cannot find module './stream' or its corresponding type declarations.
packages/cli/src/cmd/cloud/stream/get.ts
[error] 2-2: Module '"@agentuity/server"' has no exported member 'streamGet'.
packages/cli/src/cmd/cloud/db/get.ts
[error] 54-54: Object literal may only specify known properties, and 'resourceRules' does not exist in type '{ name: string; description: string; banner?: true | undefined; aliases?: string[] | undefined; toplevel?: boolean | undefined; skipInternalLogging?: boolean | undefined; requires?: { auth: true; } | undefined; ... 9 more ...; handler(ctx: CommandContext<...>): { ...; } | ... 1 more ... | Promise<...>; }'.
packages/cli/src/cmd/cloud/sandbox/util.ts
[error] 6-6: bun run build failed: Cannot find module '../../../catalyst' or its corresponding type declarations.
packages/cli/src/cmd/cloud/stream/list.ts
[error] 2-2: Module '"@agentuity/server"' has no exported member 'streamList'. Did you mean 'threadList'?
[error] 2-2: Module '"@agentuity/server"' has no exported member 'StreamInfo'.
🔇 Additional comments (30)
packages/cli/src/cmd/cloud/storage/get.ts (1)
66-86: LGTM! Multi-org search and caching implemented correctly.The implementation properly:
- Fetches all S3 resources across accessible organizations via
listOrgResourceswithout an explicitorgId- Uses optional chaining (
bucket?.cloud_region) to safely handle the case where bucket may be undefined- Caches only when both
cloud_regionandorg_idare present, ensuring valid cache entriespackages/cli/src/cmd/cloud/storage/list.ts (2)
47-47: LGTM! Org requirement correctly removed with proper multi-org support.The changes correctly:
- Remove the
org: truerequirement from the command- Fetch resources across all accessible organizations
- Cache each bucket with its specific
org_idfrom the API responseAlso applies to: 87-104
197-199: Nice UX touch with conditional org column display.Showing the organization column only when buckets span multiple organizations (
uniqueOrgIds.size > 1) keeps the output clean for single-org users while providing necessary context for multi-org users.packages/cli/src/cmd/cloud/db/get.ts (2)
94-101: LGTM!The change to search across all organizations aligns with the PR objective. Using
globalClientwithlistOrgResourceswithout an explicit orgId correctly enables cross-org resource discovery.
106-108: LGTM!Correctly requires both
cloud_regionandorg_idbefore caching, ensuring complete resource information is persisted for future lookups.packages/cli/src/cmd/cloud/stream/util.ts (3)
7-16: Doc clarification looks good. Clear separation of create vs list/get behavior.
74-99: LGTM: org-scoped adapter helper. The helper cleanly isolates org-specific adapter creation and logging.
39-49: The current code usingtui.fatal()is consistent with the established error handling pattern throughout the CLI codebase. The suggested implementation is incorrect:StructuredErroris a factory function that must be defined first (const OrgIdRequiredError = StructuredError('ORG_ID_REQUIRED', 'message')), not called directly withnew StructuredError('code', 'message'). The CLI consistently usestui.fatal()for fatal errors, which is the established convention across hundreds of locations in the codebase.Likely an incorrect or invalid review comment.
packages/server/src/api/sandbox/resolve.ts (2)
7-32: Schema + interface alignment looks good.The response schema and interface shape/optionality are consistent and easy to consume.
56-76: Resolution flow is clear and returns normalized data.The mapping to the returned shape is straightforward and consistent.
packages/cli/src/cmd/cloud/stream/get.ts (2)
20-129: API-driven retrieval + optional download flow looks solid.The new flow cleanly fetches metadata and optionally streams content to disk with useful timing output.
130-132: Current implementation is correct and follows established patterns.The code already properly handles API errors using
tui.fatal()withErrorCode.API_ERROR, which is the consistent pattern throughout all cloud commands in the CLI (see thread/list.ts, thread/get.ts, session/logs.ts, stream/list.ts, etc.). TheErrorCodeenum provides semantic error codes that map to appropriate exit codes viagetExitCode(). TheStructuredErrorfrom@agentuity/coreis used for creating custom error types in utility functions, not for wrapping errors before callingtui.fatal(), which only accepts a string message and optionalErrorCode. No changes needed.Likely an incorrect or invalid review comment.
packages/cli/src/cmd/cloud/sandbox/upload.ts (1)
5-53: Migration to apiClient-based sandbox resolution looks good.The sandboxResolve lookup and region/org derivation keep the upload flow consistent with multi-org access.
packages/cli/src/cmd/cloud/sandbox/delete.ts (1)
4-65: Sandbox delete now resolves org/region via API as intended.The new resolution step integrates cleanly with client creation and destroy.
packages/cli/src/cmd/cloud/sandbox/exec.ts (1)
5-60: Exec command now uses sandboxResolve + apiClient; flow is consistent.Good alignment with the multi-org resolution pattern.
packages/cli/src/cmd/cloud/sandbox/download.ts (1)
5-54: Download command correctly resolves org/region via API before fetching archive.Looks consistent with the new sandbox resolution approach.
packages/cli/src/cmd/cloud/sandbox/rm.ts (1)
1-56: LGTM!The refactoring to use
sandboxResolvefor API-based resolution is clean and consistent. The flow correctly resolves sandbox metadata first via the CLI API, then creates a regional client for the actual operation. The example correctly uses thesbx_prefix per repository conventions.packages/cli/src/cmd/cloud/sandbox/get.ts (1)
68-81: LGTM!The two-step resolution flow is appropriate here:
sandboxResolveprovides the region/orgId needed to route to the correct regional API, whilesandboxGetfetches the complete sandbox details including runtime, snapshot, and resource information. The region caching for future lookups is preserved.packages/cli/src/cmd/cloud/sandbox/mkdir.ts (1)
1-70: LGTM!The implementation follows the consistent pattern across sandbox commands: resolve sandbox metadata first via CLI API, then create a regional client for the operation. The response schema enhancement to include
pathis a good addition for better feedback.packages/cli/src/cmd/cloud/sandbox/env.ts (1)
1-108: LGTM!The refactoring correctly implements the API-based sandbox resolution pattern. The environment variable parsing logic remains unchanged and properly handles both set and delete operations.
packages/cli/src/cmd/cloud/sandbox/rmdir.ts (1)
1-70: LGTM!The implementation is consistent with the other sandbox commands, correctly using
sandboxResolvefor API-based metadata resolution before creating the regional client.packages/cli/src/cmd/cloud/sandbox/ls.ts (1)
1-131: LGTM!The file listing command correctly implements the API-based resolution pattern. The display formatting logic including size and modification time formatting remains unchanged and is well-implemented.
packages/cli/src/cmd/cloud/sandbox/cp.ts (1)
6-110: LGTM — CLI API resolution wiring looks solid.The switch to
apiClient+sandboxResolvekeeps the flow intact while enabling cross-org lookup.packages/server/src/api/sandbox/cli-list.ts (1)
1-99: Nice addition of CLI list API with response validation.Schema-driven parsing and the response guard keep this endpoint consistent with the rest of the API surface.
packages/cli/src/cmd/cloud/sandbox/list.ts (1)
5-146: Multi-org list updates look good.The optional org filter and conditional Organization column keep output readable while supporting cross-org results.
packages/server/src/api/sandbox/index.ts (1)
7-12: Exports look consistent with the new sandbox API surface.No issues spotted with the added re-exports.
packages/cli/src/cmd/cloud/stream/list.ts (4)
21-28:apiClientrequirement aligns with multi‑org listing.Nice update to drop the region requirement here.
29-64: Project/org filter flags are well surfaced.Examples and schema additions make the new filters discoverable.
69-161: Output mapping and table rendering look good.The metadata truncation, URL rendering, and total summary keep the output readable, and the JSON path returns the full payload.
162-164: The current implementation is correct. Thetui.fatalfunction signature isfatal(message: string, errorCode?: ErrorCode): neverand does not acceptStructuredErroras a parameter. PassingErrorCode.API_ERRORis the appropriate usage and matches the pattern across all similar catch blocks in the cloud commands directory.Likely an incorrect or invalid review comment.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
| @@ -1,8 +1,9 @@ | |||
| import { z } from 'zod'; | |||
| import { streamGet } from '@agentuity/server'; | |||
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# Find the `@agentuity/server` package location
find . -type f -name "package.json" | xargs grep -l "@agentuity/server" | head -5Repository: agentuity/sdk
Length of output: 212
🏁 Script executed:
# Look for the server package structure
find . -type d -name "server" | grep -E "packages|src" | head -10Repository: agentuity/sdk
Length of output: 74
🏁 Script executed:
# Search for streamGet in the codebase
rg "streamGet" --type ts --type tsx -lRepository: agentuity/sdk
Length of output: 84
🏁 Script executed:
# Search for streamGet with correct file type syntax
rg "streamGet" --type typescript -lRepository: agentuity/sdk
Length of output: 91
🏁 Script executed:
# Check the server package structure and exports
ls -la ./packages/server/Repository: agentuity/sdk
Length of output: 595
🏁 Script executed:
# Read the full get.ts file to see actual implementation
cat -n ./packages/cli/src/cmd/cloud/stream/get.tsRepository: agentuity/sdk
Length of output: 5031
🏁 Script executed:
# Search for streamGet in the server package
rg "streamGet" ./packages/server --no-headingRepository: agentuity/sdk
Length of output: 39
🏁 Script executed:
# Check server package index/exports
find ./packages/server/src -name "index*" -o -name "*export*" | head -10Repository: agentuity/sdk
Length of output: 462
🏁 Script executed:
# Look at server package src structure
find ./packages/server/src -type f | head -20Repository: agentuity/sdk
Length of output: 849
🏁 Script executed:
# Search for stream-related files in server package
find ./packages/server/src -type f -name "*stream*"Repository: agentuity/sdk
Length of output: 39
🏁 Script executed:
# Check the server package main index
cat -n ./packages/server/src/api/index.tsRepository: agentuity/sdk
Length of output: 507
🏁 Script executed:
# Also check if there's a root index for the server package
find ./packages/server -maxdepth 2 -name "index.ts" -type fRepository: agentuity/sdk
Length of output: 87
🏁 Script executed:
# List stream module files
ls -la ./packages/server/src/api/stream/Repository: agentuity/sdk
Length of output: 137
🏁 Script executed:
# Check stream index or any stream files
find ./packages/server/src/api/stream -type f 2>/dev/null | head -20Repository: agentuity/sdk
Length of output: 39
🏁 Script executed:
# Search for "stream" keyword in api index to see context
cat -n ./packages/server/src/api/index.ts | grep -A2 -B2 streamRepository: agentuity/sdk
Length of output: 221
🏁 Script executed:
# Check server package root index
cat -n ./packages/server/src/index.tsRepository: agentuity/sdk
Length of output: 1412
🏁 Script executed:
# Search entire server package for any stream reference
rg "stream" ./packages/server/src -i --type tsRepository: agentuity/sdk
Length of output: 22292
🏁 Script executed:
# Check server package.json for exports configuration
cat -n ./packages/server/package.jsonRepository: agentuity/sdk
Length of output: 1273
🏁 Script executed:
# Check if there's a stream.ts file directly in api directory
find ./packages/server/src/api -maxdepth 1 -name "*stream*"Repository: agentuity/sdk
Length of output: 39
🏁 Script executed:
# Search more broadly for streamGet in the entire codebase
rg "streamGet" --type ts -lRepository: agentuity/sdk
Length of output: 139
🏁 Script executed:
# Check what the api/index.ts file actually exports
cat ./packages/server/src/api/index.tsRepository: agentuity/sdk
Length of output: 409
🏁 Script executed:
# Check if streamGet is defined in the cli's util.ts
cat -n ./packages/cli/src/cmd/cloud/stream/util.tsRepository: agentuity/sdk
Length of output: 3689
🏁 Script executed:
# Also verify the api/index exports - check if stream module exists anywhere
ls -la ./packages/server/src/api/ | grep streamRepository: agentuity/sdk
Length of output: 39
streamGet is not exported by @agentuity/server — the stream module is missing.
The import at line 2 will fail with TS2305. The server package's api/index.ts attempts to export from './stream', but that module does not exist. Either create the stream module with the streamGet function exported, or update this import to the correct API.
Additionally, error handling at lines 130-132 and throughout this file should use StructuredError from @agentuity/core instead of tui.fatal to comply with the coding guidelines.
🧰 Tools
🪛 GitHub Actions: Build Packages & Test
[error] 2-2: TS2305: Module '"@agentuity/server"' has no exported member 'streamGet'.
🪛 GitHub Actions: NPM Pack & Upload
[error] 2-2: Module '"@agentuity/server"' has no exported member 'streamGet'.
🪛 GitHub Actions: Package Smoke Test
[error] 2-2: Module '"@agentuity/server"' has no exported member 'streamGet'.
🤖 Prompt for AI Agents
In `@packages/cli/src/cmd/cloud/stream/get.ts` at line 2, The import of streamGet
from '@agentuity/server' fails because the server package does not export a
'./stream' module; either add a new module that exports the streamGet function
(ensure it's exported from server's api/index.ts) or change this file's import
to the correct exported API name from '@agentuity/server'; also replace all uses
of tui.fatal (including the error handling block that currently calls tui.fatal)
with throwing or returning a StructuredError from '@agentuity/core' (import
StructuredError and use it for error construction and propagation) so error
handling conforms to the coding guidelines.
| import { z } from 'zod'; | ||
| import { streamList, type StreamInfo } from '@agentuity/server'; | ||
| import { createCommand } from '../../../types'; | ||
| import * as tui from '../../../tui'; | ||
| import { createStorageAdapter } from './util'; | ||
| import { getCommand } from '../../../command-prefix'; | ||
| import { ErrorCode } from '../../../errors'; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# Find definitions and exports of streamList and StreamInfo
rg -n "streamList|StreamInfo" packages/cli/src/cmd/cloud/stream/list.tsRepository: agentuity/sdk
Length of output: 352
🏁 Script executed:
# Search for streamList and StreamInfo across the entire codebase
rg -n "export.*streamList|export.*StreamInfo" -g'*.ts'Repository: agentuity/sdk
Length of output: 199
🏁 Script executed:
# Find where these symbols are defined
rg -n "streamList|StreamInfo" -g'*.ts' --max-count=20Repository: agentuity/sdk
Length of output: 1857
🏁 Script executed:
# Check the full imports and error handling in the target file
head -80 packages/cli/src/cmd/cloud/stream/list.tsRepository: agentuity/sdk
Length of output: 2868
🏁 Script executed:
# Check if `@agentuity/server` package exists and list its exports
fd '@agentuity' -t d 2>/dev/null | head -5Repository: agentuity/sdk
Length of output: 39
🏁 Script executed:
# Search for streamList definition and export
rg -n "export.*streamList|^export function streamList|^export const streamList" -g'*.ts'Repository: agentuity/sdk
Length of output: 39
🏁 Script executed:
# Find packages/server directory and its structure
fd 'packages' -t d | head -20Repository: agentuity/sdk
Length of output: 66
🏁 Script executed:
# Check if there's a server package and what it exports
find . -name 'package.json' -path '*/packages/*/package.json' -exec grep -l '"name".*server' {} \;Repository: agentuity/sdk
Length of output: 118
🏁 Script executed:
# Look for streamList definition (not just export)
rg -n "streamList\s*=" -g'*.ts' | head -20Repository: agentuity/sdk
Length of output: 39
🏁 Script executed:
# Check the core package index exports
cat packages/core/src/index.ts | grep -A 50 "export"Repository: agentuity/sdk
Length of output: 4169
🏁 Script executed:
# Search more broadly for streamList definition
rg -n "streamList" -g'*.ts' -B 2 -A 2Repository: agentuity/sdk
Length of output: 1240
🏁 Script executed:
# Check packages/server/package.json to understand what it exports
cat packages/server/package.jsonRepository: agentuity/sdk
Length of output: 972
🏁 Script executed:
# Look for Stream-related function definitions
rg -n "function streamList|const streamList" -g'*.ts'Repository: agentuity/sdk
Length of output: 39
🏁 Script executed:
# Check packages/server source files
fd . packages/server/src -type f -name '*.ts' 2>/dev/nullRepository: agentuity/sdk
Length of output: 39
🏁 Script executed:
# Check packages/server/src/index.ts
cat packages/server/src/index.tsRepository: agentuity/sdk
Length of output: 1118
🏁 Script executed:
# List all files in packages/server/src
find packages/server/src -type f -name '*.ts' | sortRepository: agentuity/sdk
Length of output: 3796
🏁 Script executed:
# Check packages/server/src/api/index.ts to see all API exports
cat packages/server/src/api/index.tsRepository: agentuity/sdk
Length of output: 409
🏁 Script executed:
# Check if there are any stream-related files in packages/server
find packages/server -name '*stream*' -type fRepository: agentuity/sdk
Length of output: 39
🏁 Script executed:
# Search for any reference to stream APIs in the server package
rg -n "stream" packages/server/src -iRepository: agentuity/sdk
Length of output: 22704
🏁 Script executed:
# Check if packages/server/src/api/stream directory exists
ls -la packages/server/src/api/stream/ 2>&1 || echo "Directory not found"Repository: agentuity/sdk
Length of output: 155
🏁 Script executed:
# More comprehensive search for stream API
find packages/server/src/api -type d -name 'stream'Repository: agentuity/sdk
Length of output: 39
🏁 Script executed:
# Check packages/server/src/api/stream/index.ts
cat packages/server/src/api/stream/index.ts 2>&1 || echo "File not found"Repository: agentuity/sdk
Length of output: 143
🏁 Script executed:
# Check what's being exported from `@agentuity/server` index that references stream
rg -n "from './stream'" packages/server/src/api/index.tsRepository: agentuity/sdk
Length of output: 85
🏁 Script executed:
# Search across entire codebase for any function named streamList
rg -n "^export.*streamList|^function streamList|^const streamList" -g'*.ts'Repository: agentuity/sdk
Length of output: 39
🏁 Script executed:
# Check if there's any recent stream API file that might be misnamed
find packages/server/src/api -name '*stream*' -type fRepository: agentuity/sdk
Length of output: 39
🏁 Script executed:
# Check the full content of packages/server/src/api/index.ts to see if stream is mentioned
cat packages/server/src/api/index.ts | head -50Repository: agentuity/sdk
Length of output: 409
🏁 Script executed:
# List all directories in packages/server/src/api/
ls -la packages/server/src/api/ | grep "^d"Repository: agentuity/sdk
Length of output: 851
🏁 Script executed:
# Check git status to see if stream directory was removed
cd packages/server/src/api && git status 2>/dev/null || echo "Not a git repo or git not available"Repository: agentuity/sdk
Length of output: 268
🏁 Script executed:
# Check if there's a packages/server/src/api/stream.ts file (not a directory)
find packages/server/src/api -name 'stream.ts' -o -name 'stream.js'Repository: agentuity/sdk
Length of output: 39
🏁 Script executed:
# Look at the full file listing in packages/server/src/api
find packages/server/src/api -maxdepth 1 -type f -o -type d | sortRepository: agentuity/sdk
Length of output: 547
🏁 Script executed:
# Check git to see if stream directory was deleted in recent commits
cd packages/server && git log --oneline --follow -p -- src/api/stream 2>/dev/null | head -100 || echo "No history found"Repository: agentuity/sdk
Length of output: 39
🏁 Script executed:
# Search for where streamList might actually be defined across entire repo
rg -n "streamList" -g'*.ts' -B 3 -A 3Repository: agentuity/sdk
Length of output: 1767
🏁 Script executed:
# Check if there's a reference implementation elsewhere
rg -n "export.*\blist\b.*function|export.*function.*list" packages/server/src/api/sandbox/list.ts -A 10 | head -40Repository: agentuity/sdk
Length of output: 39
🏁 Script executed:
# See if streamList is defined anywhere at all in the codebase
git log --all --full-history -p -- "**/stream*" 2>/dev/null | grep -A 5 "streamList" | head -50 || echo "Not found in history"Repository: agentuity/sdk
Length of output: 824
🏁 Script executed:
# Verify that the stream module is genuinely missing - check what the export statement expects
rg -n "export.*from.*stream" packages/server/src/api/index.tsRepository: agentuity/sdk
Length of output: 85
🏁 Script executed:
# Check if StreamInfo is exported from `@agentuity/server`'s index
cat packages/server/src/index.ts | grep -i "streaminfo"Repository: agentuity/sdk
Length of output: 39
🏁 Script executed:
# Verify StreamInfo is NOT re-exported from `@agentuity/server`
rg -n "StreamInfo" packages/server/src/index.tsRepository: agentuity/sdk
Length of output: 39
🏁 Script executed:
# Check where the stream module was supposed to come from by looking at similar APIs
ls packages/server/src/api/sandbox/ | head -5
cat packages/server/src/api/sandbox/index.ts | head -20Repository: agentuity/sdk
Length of output: 1102
🏁 Script executed:
# Confirm the build break - try to see what would be exported from a non-existent stream module
cat packages/server/src/api/index.tsRepository: agentuity/sdk
Length of output: 409
🏁 Script executed:
# Check the error handling in list.ts to verify StructuredError issue
tail -100 packages/cli/src/cmd/cloud/stream/list.ts | head -50Repository: agentuity/sdk
Length of output: 1375
🏁 Script executed:
# Look at the catch block mentioned in the scratchpad (around lines 162-164)
sed -n '155,170p' packages/cli/src/cmd/cloud/stream/list.tsRepository: agentuity/sdk
Length of output: 352
Build break: streamList and StreamInfo are not exported from @agentuity/server.
The packages/server/src/api/index.ts attempts to export * from './stream', but the stream module directory does not exist. Additionally, streamList is not defined anywhere in the codebase, and StreamInfo is not re-exported from @agentuity/server (it exists in @agentuity/core). These missing exports will cause TypeScript compilation to fail.
Create the stream API module in packages/server/src/api/ with appropriate exports for streamList and StreamInfo, or update the imports in packages/cli/src/cmd/cloud/stream/list.ts to use the correct source package before merging.
Also note: The error handling in the catch block (lines 162–164) should use StructuredError from @agentuity/core per the coding guidelines.
🧰 Tools
🪛 GitHub Actions: Build Packages & Test
[error] 2-2: TS2724: '"@agentuity/server"' has no exported member named 'streamList'. Did you mean 'threadList'?
[error] 2-2: TS2305: Module '"@agentuity/server"' has no exported member 'StreamInfo'.
🪛 GitHub Actions: NPM Pack & Upload
[error] 2-2: Module '"@agentuity/server"' has no exported member named 'streamList'. Did you mean 'threadList'?
[error] 2-2: Module '"@agentuity/server"' has no exported member 'StreamInfo'.
🪛 GitHub Actions: Package Smoke Test
[error] 2-2: Module '"@agentuity/server"' has no exported member 'streamList'. Did you mean 'threadList'?
[error] 2-2: Module '"@agentuity/server"' has no exported member 'StreamInfo'.
🤖 Prompt for AI Agents
In `@packages/cli/src/cmd/cloud/stream/list.ts` around lines 1 - 6, Create a new
API module that exports the missing symbols: add
packages/server/src/api/stream.ts which defines and exports an async function
streamList(...) (implement it to call the existing server/backend list logic or
return the appropriate data) and re-export the StreamInfo type from
'@agentuity/core' (export { type StreamInfo } from '@agentuity/core'), then
ensure packages/server/src/api/index.ts includes `export * from './stream'` so
`@agentuity/server` exposes streamList and StreamInfo; finally, update the catch
block in packages/cli/src/cmd/cloud/stream/list.ts to import and use
StructuredError from '@agentuity/core' (use `if (err instanceof StructuredError)
{ ... }` and log its structured details) to match coding guidelines.
| export * from './region'; | ||
| export * from './sandbox'; | ||
| export * from './session'; | ||
| export * from './stream'; |
There was a problem hiding this comment.
Build break: missing ./stream module export.
CI fails with TS2307 because ./stream isn’t present. Please add the stream API module (e.g., packages/server/src/api/stream/index.ts) or correct the export path before merging.
🧰 Tools
🪛 GitHub Actions: Build Packages & Test
[error] 12-12: TS2307: Cannot find module './stream' or its corresponding type declarations.
🪛 GitHub Actions: NPM Pack & Upload
[error] 12-15: Cannot find module './stream' or its corresponding type declarations.
🪛 GitHub Actions: Package Smoke Test
[error] 12-15: bun run build failed: Cannot find module './stream' or its corresponding type declarations.
🤖 Prompt for AI Agents
In `@packages/server/src/api/index.ts` at line 12, The export line "export * from
'./stream';" in packages/server/src/api/index.ts references a non-existent
module and causes TS2307; either add the missing stream API module (implement
index.ts under the './stream' API namespace exporting the expected public
functions/types) or update the export to the correct existing module path/name
(e.g., change './stream' to the actual module that contains the stream API) so
that the symbol exported by index.ts resolves and the TypeScript build succeeds.
- Add stream CLI API functions (cliStreamList, cliStreamGet) - Add catalyst client helper for CLI - Various CLI improvements and refactoring - Format fixes across codebase
- Add await to parseFileArgs calls in sandbox/create.ts and sandbox/run.ts - Replace tui.fatal with StructuredError in stream/get.ts and stream/list.ts - Update SandboxResolveError to use StructuredError pattern in packages/server - Fix indentation issues from previous edits
📦 Canary Packages Publishedversion: PackagesInstallAdd to your {
"dependencies": {
"@agentuity/cli": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-cli-1.0.1-9c30554.tgz",
"@agentuity/runtime": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-runtime-1.0.1-9c30554.tgz",
"@agentuity/auth": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-auth-1.0.1-9c30554.tgz",
"@agentuity/core": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-core-1.0.1-9c30554.tgz",
"@agentuity/server": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-server-1.0.1-9c30554.tgz",
"@agentuity/workbench": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-workbench-1.0.1-9c30554.tgz",
"@agentuity/evals": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-evals-1.0.1-9c30554.tgz",
"@agentuity/frontend": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-frontend-1.0.1-9c30554.tgz",
"@agentuity/schema": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-schema-1.0.1-9c30554.tgz",
"@agentuity/opencode": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-opencode-1.0.1-9c30554.tgz",
"@agentuity/drizzle": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-drizzle-1.0.1-9c30554.tgz",
"@agentuity/postgres": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-postgres-1.0.1-9c30554.tgz",
"@agentuity/react": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-react-1.0.1-9c30554.tgz"
}
}Or install directly: bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-cli-1.0.1-9c30554.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-runtime-1.0.1-9c30554.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-auth-1.0.1-9c30554.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-core-1.0.1-9c30554.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-server-1.0.1-9c30554.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-workbench-1.0.1-9c30554.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-evals-1.0.1-9c30554.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-frontend-1.0.1-9c30554.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-schema-1.0.1-9c30554.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-opencode-1.0.1-9c30554.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-drizzle-1.0.1-9c30554.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-postgres-1.0.1-9c30554.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-react-1.0.1-9c30554.tgz |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In `@packages/cli/src/cmd/project/reconcile.ts`:
- Around line 225-236: The non-interactive branch returns defaultRegion without
verifying it's valid; update the isNonInteractive block in reconcile.ts to
validate defaultRegion against the available regions list (e.g., the collection
or function that provides supported regions used elsewhere in this file), and
only return it if it exists in that list; if defaultRegion is absent or invalid,
call tui.fatal (same style as existing message) explaining the region is
unsupported and instructing the user to pass --region or set AGENTUITY_REGION,
optionally including the list of supported regions for clarity.
In `@packages/cli/src/tui/prompt.ts`:
- Around line 96-109: The code in text (function text, variables message,
validate, initial) treats validationResult === undefined as success, but
validate is typed to return boolean|string|Promise<boolean|string>, so change
the non-interactive branch to accept only validationResult === true (not
undefined); if validationResult is a string or undefined, treat it as validation
failure and throw the non-interactive error (include the validationResult string
in the error message when present for clarity).
In `@packages/server/src/api/sandbox/resolve.ts`:
- Around line 72-78: The code that throws SandboxResolveError always uses
statusCode: 404; update the throw in resolveSandbox (the block checking if
(!response.success || !response.data)) to propagate the actual status code from
the response (e.g., response.statusCode or response.code) when present and fall
back to 404 only if no status is provided; keep the existing message logic
(response.message || 'Sandbox not found') and include sandboxId as before so the
thrown SandboxResolveError contains the real server status when available.
- Around line 8-21: Replace the manual response schema by importing
APIResponseSchemaOptionalData from ../api and using it to wrap only the data
object schema currently duplicated in SandboxResolveResponseSchema;
specifically, keep the inner object definition with fields id, name, region,
status, orgId, projectId (same nullability) as a standalone z.object and then
build SandboxResolveResponseSchema = APIResponseSchemaOptionalData(dataSchema).
Update the import list to include APIResponseSchemaOptionalData and remove the
manual top-level success/message/data object structure so the module uses the
standardized discriminated union typing.
🧹 Nitpick comments (9)
packages/frontend/src/client/index.ts (2)
165-176: Consider usingStructuredErrorfor consistency with codebase error handling.The validation logic for path parameters is well-implemented with clear, descriptive error messages. However, per coding guidelines, errors should use
StructuredErrorfrom@agentuity/coreinstead of plainError.♻️ Proposed refactor to use StructuredError
+import { StructuredError } from '@agentuity/core';Then in the validation block:
if (arg === undefined || arg === null) { - throw new Error( + throw new StructuredError( `Missing required path parameter '${paramName}' at position ${i + 1}. ` + - `Expected ${pathParamNames.length} path parameter(s): ${pathParamNames.join(', ')}` + `Expected ${pathParamNames.length} path parameter(s): ${pathParamNames.join(', ')}`, + { code: 'MISSING_PATH_PARAMETER' } ); }As per coding guidelines: "Use
StructuredErrorfrom@agentuity/corefor error handling".
167-167: Defensive check forparamName === undefinedis unnecessary.Since
pathParamNamesis typed asstring[], elements accessed by valid indices will always be strings. This check guards against array holes, which shouldn't occur with well-formed metadata. The check is harmless but adds minor cognitive overhead.packages/cli/src/cache/resource-region.ts (1)
40-45: Migration approach is acceptable but could be more robust.The try/catch pattern for
ALTER TABLEis a common SQLite migration approach. However, catching all errors silently could mask genuine issues (e.g., database corruption).Consider checking specifically for the "duplicate column" error if needed in the future, but for a CLI tool this is acceptable.
packages/cli/src/tui/prompt.ts (1)
58-66: Consider usingStructuredErrorfor consistency.Per coding guidelines,
StructuredErrorfrom@agentuity/coreshould be used for error handling. Currently,nonInteractiveErrorreturns a plainError.♻️ Proposed fix
+import { StructuredError } from '@agentuity/core'; + +const NonInteractiveError = StructuredError('NonInteractiveError'); + export class PromptFlow { private states: PromptState[] = []; private isInteractive(): boolean { return Boolean(process.stdin.isTTY && process.stdout.isTTY); } private nonInteractiveError(message: string): Error { - return new Error( + return new NonInteractiveError({ + message: - `${message} Use the appropriate --flag or environment variable to provide input.` - ); + `${message} Use the appropriate --flag or environment variable to provide input.`, + }); }As per coding guidelines: "Use
StructuredErrorfrom@agentuity/corefor error handling".packages/cli/src/cmd/cloud/stream/delete.ts (2)
41-43: Consider usingStructuredErrorinstead oftui.fatalfor error handling.The coding guidelines specify using
StructuredErrorfrom@agentuity/corefor error handling. Usingtui.fatalhere bypasses structured error propagation.♻️ Suggested refactor
+import { StructuredError } from '@agentuity/core'; + +const MissingApiClientError = StructuredError('MissingApiClientError'); + // In handler: if (!apiClient) { - tui.fatal('API client is required for stream delete'); + throw new MissingApiClientError({ message: 'API client is required for stream delete' }); }
48-55: Region extraction from URL could be extracted to a shared utility.This URL parsing logic for extracting region from stream URLs appears to be a pattern that may be duplicated across stream commands. Consider extracting it to
./util.tsfor reuse and consistency.♻️ Example utility extraction
// In packages/cli/src/cmd/cloud/stream/util.ts export function extractRegionFromStreamUrl(url: string): string { const urlMatch = url.match(/https:\/\/streams-([^.]+)\.agentuity\.cloud/); if (urlMatch?.[1]) { return urlMatch[1]; } if (url.includes('streams.agentuity.io')) { return 'local'; } return 'usc'; // default }packages/cli/src/cmd/cloud/sandbox/util.ts (1)
79-118: Good migration to async file existence check.The function correctly uses
await Bun.file(resolvedPath).exists()per coding guidelines.Note: Line 114 still uses synchronous
readFileSync. For full consistency with Bun APIs, you could useawait Bun.file(resolvedPath).arrayBuffer()and convert to Buffer, butreadFileSyncworks correctly under Bun's Node compatibility layer, so this is a minor optional improvement.packages/cli/src/cmd/cloud/region-lookup.ts (1)
99-131: Stream region extraction relies on URL pattern matching.The region extraction from stream URLs uses regex matching against
https://streams-([^.]+)\.agentuity\.cloud. While this works for the current URL structure, it's coupled to a specific URL format.Consider documenting this assumption or adding a fallback if the URL format changes in the future.
packages/cli/src/auth.ts (1)
20-30: RESOURCE_PREFIXES is duplicated in cli.ts.The
RESOURCE_PREFIXESarray and related helpers (getResourceTypeFromId,collectPrefixedIds) are defined both here and inpackages/cli/src/cli.ts(lines 710-766). Consider extracting these to a shared utility module to avoid duplication and ensure consistency.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (52)
README.mdpackages/cli/scripts/test-concurrent-sessions.tspackages/cli/src/auth.tspackages/cli/src/cache/resource-region.tspackages/cli/src/catalyst.tspackages/cli/src/cli.tspackages/cli/src/cmd/build/vite/public-asset-path-plugin.tspackages/cli/src/cmd/build/vite/vite-builder.tspackages/cli/src/cmd/cloud/db/create.tspackages/cli/src/cmd/cloud/db/delete.tspackages/cli/src/cmd/cloud/db/get.tspackages/cli/src/cmd/cloud/deploy.tspackages/cli/src/cmd/cloud/env/import.tspackages/cli/src/cmd/cloud/env/list.tspackages/cli/src/cmd/cloud/env/push.tspackages/cli/src/cmd/cloud/keyvalue/util.tspackages/cli/src/cmd/cloud/machine/list.tspackages/cli/src/cmd/cloud/region-lookup.tspackages/cli/src/cmd/cloud/region/index.tspackages/cli/src/cmd/cloud/sandbox/create.tspackages/cli/src/cmd/cloud/sandbox/get.tspackages/cli/src/cmd/cloud/sandbox/run.tspackages/cli/src/cmd/cloud/sandbox/snapshot/build.tspackages/cli/src/cmd/cloud/sandbox/snapshot/get.tspackages/cli/src/cmd/cloud/sandbox/util.tspackages/cli/src/cmd/cloud/ssh.tspackages/cli/src/cmd/cloud/storage/create.tspackages/cli/src/cmd/cloud/storage/delete.tspackages/cli/src/cmd/cloud/storage/list.tspackages/cli/src/cmd/cloud/stream/create.tspackages/cli/src/cmd/cloud/stream/delete.tspackages/cli/src/cmd/cloud/stream/get.tspackages/cli/src/cmd/cloud/stream/list.tspackages/cli/src/cmd/cloud/vector/util.tspackages/cli/src/cmd/dev/index.tspackages/cli/src/cmd/git/account/add.tspackages/cli/src/cmd/git/list.tspackages/cli/src/cmd/project/auth/init.tspackages/cli/src/cmd/project/reconcile.tspackages/cli/src/cmd/support/report.tspackages/cli/src/config.tspackages/cli/src/index.tspackages/cli/src/repl.tspackages/cli/src/tui/prompt.tspackages/cli/src/types.tspackages/frontend/src/client/index.tspackages/server/src/api/sandbox/resolve.tspackages/server/src/api/stream/get.tspackages/server/src/api/stream/index.tspackages/server/src/api/stream/list.tspackages/server/src/api/stream/util.tsscripts/test-templates.ts
💤 Files with no reviewable changes (1)
- README.md
✅ Files skipped from review due to trivial changes (12)
- packages/cli/src/repl.ts
- packages/cli/src/cmd/cloud/env/list.ts
- packages/cli/src/cmd/support/report.ts
- packages/cli/src/cmd/build/vite/public-asset-path-plugin.ts
- packages/cli/src/cmd/cloud/sandbox/snapshot/get.ts
- packages/cli/src/cmd/git/account/add.ts
- packages/cli/src/cmd/project/auth/init.ts
- packages/cli/src/cmd/cloud/region/index.ts
- packages/cli/src/cmd/cloud/sandbox/snapshot/build.ts
- packages/cli/src/cmd/cloud/storage/delete.ts
- packages/cli/src/cmd/cloud/storage/create.ts
- packages/cli/src/cmd/cloud/env/import.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/cli/src/cmd/cloud/storage/list.ts
- packages/cli/src/cmd/cloud/db/get.ts
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Use Prettier formatter with tabs (width 3), single quotes, and semicolons for TypeScript files
Use TypeScript strict mode with ESNext target and bundler moduleResolution
UseStructuredErrorfrom@agentuity/corefor error handling
Files:
scripts/test-templates.tspackages/cli/src/index.tspackages/cli/src/cmd/cloud/sandbox/create.tspackages/cli/src/cmd/project/reconcile.tspackages/cli/src/cmd/dev/index.tspackages/cli/src/types.tspackages/cli/src/config.tspackages/cli/src/cmd/cloud/vector/util.tspackages/cli/src/cmd/cloud/stream/create.tspackages/cli/src/catalyst.tspackages/cli/src/cmd/cloud/keyvalue/util.tspackages/server/src/api/sandbox/resolve.tspackages/server/src/api/stream/util.tspackages/cli/src/cmd/cloud/deploy.tspackages/cli/src/cache/resource-region.tspackages/server/src/api/stream/get.tspackages/cli/src/cmd/cloud/ssh.tspackages/cli/src/cmd/cloud/sandbox/run.tspackages/cli/src/auth.tspackages/cli/src/cmd/cloud/stream/delete.tspackages/cli/src/tui/prompt.tspackages/server/src/api/stream/index.tspackages/cli/src/cmd/cloud/db/delete.tspackages/cli/src/cmd/cloud/sandbox/util.tspackages/server/src/api/stream/list.tspackages/cli/scripts/test-concurrent-sessions.tspackages/cli/src/cmd/cloud/sandbox/get.tspackages/cli/src/cmd/cloud/db/create.tspackages/cli/src/cmd/cloud/machine/list.tspackages/cli/src/cmd/cloud/env/push.tspackages/cli/src/cmd/cloud/stream/list.tspackages/frontend/src/client/index.tspackages/cli/src/cli.tspackages/cli/src/cmd/cloud/region-lookup.tspackages/cli/src/cmd/build/vite/vite-builder.tspackages/cli/src/cmd/cloud/stream/get.tspackages/cli/src/cmd/git/list.ts
packages/*/src/index.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use named exports from package
index.tsfile as the public API
Files:
packages/cli/src/index.ts
packages/cli/**/*.ts
📄 CodeRabbit inference engine (packages/cli/AGENTS.md)
Use
Bun.file(f).exists()instead ofexistsSync(f)for file existence checks
Files:
packages/cli/src/index.tspackages/cli/src/cmd/cloud/sandbox/create.tspackages/cli/src/cmd/project/reconcile.tspackages/cli/src/cmd/dev/index.tspackages/cli/src/types.tspackages/cli/src/config.tspackages/cli/src/cmd/cloud/vector/util.tspackages/cli/src/cmd/cloud/stream/create.tspackages/cli/src/catalyst.tspackages/cli/src/cmd/cloud/keyvalue/util.tspackages/cli/src/cmd/cloud/deploy.tspackages/cli/src/cache/resource-region.tspackages/cli/src/cmd/cloud/ssh.tspackages/cli/src/cmd/cloud/sandbox/run.tspackages/cli/src/auth.tspackages/cli/src/cmd/cloud/stream/delete.tspackages/cli/src/tui/prompt.tspackages/cli/src/cmd/cloud/db/delete.tspackages/cli/src/cmd/cloud/sandbox/util.tspackages/cli/scripts/test-concurrent-sessions.tspackages/cli/src/cmd/cloud/sandbox/get.tspackages/cli/src/cmd/cloud/db/create.tspackages/cli/src/cmd/cloud/machine/list.tspackages/cli/src/cmd/cloud/env/push.tspackages/cli/src/cmd/cloud/stream/list.tspackages/cli/src/cli.tspackages/cli/src/cmd/cloud/region-lookup.tspackages/cli/src/cmd/build/vite/vite-builder.tspackages/cli/src/cmd/cloud/stream/get.tspackages/cli/src/cmd/git/list.ts
packages/cli/src/cmd/**/index.ts
📄 CodeRabbit inference engine (packages/cli/AGENTS.md)
packages/cli/src/cmd/**/index.ts: Each command must be structured as a directory insrc/cmd/with anindex.tsfile as the entry point
Always define interfaces or Zod schemas for command options; never useanytype for type safety
Usetui.*helpers (header, info, success, warning, error, table, progress) for formatted TUI output instead of raw console methods
Usectx.loggerfor logging instead of console methods; uselogger.fatal()for fatal errors which logs and exits with code 1
Always checkisJSONMode()before outputting data and provide machine-readable output when in JSON mode
UserequireAuth(ctx)for commands that require authentication oroptionalAuth(ctx)for commands that support optional authentication
Files:
packages/cli/src/cmd/dev/index.ts
packages/server/src/**/*.ts
📄 CodeRabbit inference engine (packages/server/AGENTS.md)
packages/server/src/**/*.ts: All code must be written in TypeScript
Use zod for runtime validation of schemas and data
Files:
packages/server/src/api/sandbox/resolve.tspackages/server/src/api/stream/util.tspackages/server/src/api/stream/get.tspackages/server/src/api/stream/index.tspackages/server/src/api/stream/list.ts
packages/server/src/api/**/*.ts
📄 CodeRabbit inference engine (packages/server/AGENTS.md)
Organize API clients by feature domain in src/api/ subdirectories (apikey, db, eval, org, project, queue, region, sandbox, session, thread, user)
Files:
packages/server/src/api/sandbox/resolve.tspackages/server/src/api/stream/util.tspackages/server/src/api/stream/get.tspackages/server/src/api/stream/index.tspackages/server/src/api/stream/list.ts
packages/frontend/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (packages/frontend/AGENTS.md)
Use TypeScript generics heavily for type safety in all utilities
Files:
packages/frontend/src/client/index.ts
🧠 Learnings (4)
📚 Learning: 2025-12-21T00:31:41.858Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 274
File: packages/cli/src/cmd/build/vite/server-bundler.ts:12-41
Timestamp: 2025-12-21T00:31:41.858Z
Learning: In Bun runtime, BuildMessage and ResolveMessage are global types and are not exported from the bun module. Do not import { BuildMessage } from 'bun' or similar; these types are available globally and should be used without import. This applies to all TypeScript files that target the Bun runtime within the repository.
Applied to files:
scripts/test-templates.tspackages/cli/src/index.tspackages/cli/src/cmd/cloud/sandbox/create.tspackages/cli/src/cmd/project/reconcile.tspackages/cli/src/cmd/dev/index.tspackages/cli/src/types.tspackages/cli/src/config.tspackages/cli/src/cmd/cloud/vector/util.tspackages/cli/src/cmd/cloud/stream/create.tspackages/cli/src/catalyst.tspackages/cli/src/cmd/cloud/keyvalue/util.tspackages/server/src/api/sandbox/resolve.tspackages/server/src/api/stream/util.tspackages/cli/src/cmd/cloud/deploy.tspackages/cli/src/cache/resource-region.tspackages/server/src/api/stream/get.tspackages/cli/src/cmd/cloud/ssh.tspackages/cli/src/cmd/cloud/sandbox/run.tspackages/cli/src/auth.tspackages/cli/src/cmd/cloud/stream/delete.tspackages/cli/src/tui/prompt.tspackages/server/src/api/stream/index.tspackages/cli/src/cmd/cloud/db/delete.tspackages/cli/src/cmd/cloud/sandbox/util.tspackages/server/src/api/stream/list.tspackages/cli/scripts/test-concurrent-sessions.tspackages/cli/src/cmd/cloud/sandbox/get.tspackages/cli/src/cmd/cloud/db/create.tspackages/cli/src/cmd/cloud/machine/list.tspackages/cli/src/cmd/cloud/env/push.tspackages/cli/src/cmd/cloud/stream/list.tspackages/frontend/src/client/index.tspackages/cli/src/cli.tspackages/cli/src/cmd/cloud/region-lookup.tspackages/cli/src/cmd/build/vite/vite-builder.tspackages/cli/src/cmd/cloud/stream/get.tspackages/cli/src/cmd/git/list.ts
📚 Learning: 2026-01-13T04:32:02.691Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 565
File: packages/cli/src/cmd/cloud/region-lookup.ts:14-26
Timestamp: 2026-01-13T04:32:02.691Z
Learning: Enforce sandbox identifier prefixes in new code within the CLI cloud region lookup: new sandboxes must use the sbx_ prefix. The snbx_ prefix may appear in legacy code or examples, but do not use snbx_ for new sandboxes. When reviewing changes in packages/cli/src/cmd/cloud/, ensure any created sandbox identifiers use sbx_ and remove or migrate any snbx_ usages in newly added code.
Applied to files:
packages/cli/src/cmd/cloud/sandbox/create.tspackages/cli/src/cmd/cloud/vector/util.tspackages/cli/src/cmd/cloud/stream/create.tspackages/cli/src/cmd/cloud/keyvalue/util.tspackages/cli/src/cmd/cloud/deploy.tspackages/cli/src/cmd/cloud/ssh.tspackages/cli/src/cmd/cloud/sandbox/run.tspackages/cli/src/cmd/cloud/stream/delete.tspackages/cli/src/cmd/cloud/db/delete.tspackages/cli/src/cmd/cloud/sandbox/util.tspackages/cli/src/cmd/cloud/sandbox/get.tspackages/cli/src/cmd/cloud/db/create.tspackages/cli/src/cmd/cloud/machine/list.tspackages/cli/src/cmd/cloud/env/push.tspackages/cli/src/cmd/cloud/stream/list.tspackages/cli/src/cmd/cloud/region-lookup.tspackages/cli/src/cmd/cloud/stream/get.ts
📚 Learning: 2025-12-19T14:19:33.765Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 259
File: packages/cli/src/cmd/build/vite/registry-generator.ts:306-312
Timestamp: 2025-12-19T14:19:33.765Z
Learning: Route files under src/api should use the .ts extension only (no .tsx) and regex patterns for such paths should anchor to \.ts$ (e.g., /\/.ts$/). Agent files may support both .ts and .tsx, but route files in the Agentuity SDK codebase are restricted to .ts. This guideline applies to all similar route files under src/api across the repository.
Applied to files:
packages/server/src/api/sandbox/resolve.tspackages/server/src/api/stream/util.tspackages/server/src/api/stream/get.tspackages/server/src/api/stream/index.tspackages/server/src/api/stream/list.ts
📚 Learning: 2025-12-30T00:13:37.849Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 355
File: packages/server/src/api/sandbox/util.ts:2-6
Timestamp: 2025-12-30T00:13:37.849Z
Learning: In the packages/server tree, treat code as runtime-agnostic between Node.js and Bun. Ensure TypeScript files (e.g., util.ts) import and use APIs in a way that works under both runtimes. It is acceptable to rely on Bun’s Node.js compatibility for built-ins accessed via the node: namespace (e.g., node:events, node:stream, node:buffer). During reviews, prefer patterns and imports that remain compatible with Bun's environment, and flag any hard dependencies on runtime-specific globals or non-portable Node APIs.
Applied to files:
packages/server/src/api/sandbox/resolve.tspackages/server/src/api/stream/util.tspackages/server/src/api/stream/get.tspackages/server/src/api/stream/index.tspackages/server/src/api/stream/list.ts
🧬 Code graph analysis (20)
scripts/test-templates.ts (1)
packages/cli/src/tui.ts (1)
runCommand(1520-1738)
packages/cli/src/cmd/cloud/sandbox/create.ts (1)
packages/cli/src/cmd/cloud/sandbox/util.ts (1)
parseFileArgs(79-119)
packages/cli/src/config.ts (3)
packages/cli/src/index.ts (2)
saveConfig(63-63)getCatalystUrl(76-76)packages/cli/src/catalyst.ts (1)
getCatalystUrl(8-16)packages/server/src/api/api.ts (1)
region(750-763)
packages/cli/src/cmd/cloud/stream/create.ts (2)
packages/cli/src/config.ts (1)
getDefaultRegion(778-814)packages/cli/src/cmd/cloud/stream/util.ts (1)
createStorageAdapter(17-72)
packages/cli/src/catalyst.ts (2)
packages/cli/src/index.ts (1)
getCatalystUrl(76-76)packages/server/src/api/api.ts (1)
region(750-763)
packages/cli/src/cmd/cloud/keyvalue/util.ts (2)
packages/cli/src/catalyst.ts (1)
getCatalystUrl(8-16)packages/cli/src/index.ts (1)
getCatalystUrl(76-76)
packages/server/src/api/sandbox/resolve.ts (1)
packages/server/src/api/sandbox/index.ts (3)
ResolvedSandboxInfo(8-8)SandboxResolveError(7-7)sandboxResolve(7-7)
packages/cli/src/cache/resource-region.ts (1)
packages/cli/src/cache/index.ts (2)
ResourceType(9-9)ResourceInfo(10-10)
packages/server/src/api/stream/get.ts (2)
packages/server/src/api/api.ts (1)
APIResponseSchema(869-880)packages/server/src/api/stream/util.ts (1)
StreamResponseError(3-3)
packages/cli/src/cmd/cloud/ssh.ts (1)
packages/cli/src/cmd/cloud/region-lookup.ts (1)
getIdentifierRegion(45-153)
packages/cli/src/cmd/cloud/sandbox/run.ts (1)
packages/cli/src/cmd/cloud/sandbox/util.ts (1)
parseFileArgs(79-119)
packages/cli/src/cmd/cloud/stream/delete.ts (2)
packages/server/src/api/stream/get.ts (1)
streamGet(39-51)packages/cli/src/cmd/cloud/stream/util.ts (1)
createStorageAdapterForOrg(78-99)
packages/cli/src/cmd/cloud/db/delete.ts (2)
packages/cli/src/cache/resource-region.ts (1)
deleteResourceRegion(172-183)packages/cli/src/env-util.ts (1)
removeResourceEnvVars(442-457)
packages/cli/src/cmd/cloud/sandbox/util.ts (3)
packages/server/src/config.ts (1)
getServiceUrls(28-41)packages/cli/src/cache/resource-region.ts (2)
getResourceInfo(80-114)setResourceInfo(134-152)packages/core/src/services/sandbox.ts (1)
FileToWrite(538-548)
packages/server/src/api/stream/list.ts (3)
packages/server/src/api/api.ts (1)
APIResponseSchema(869-880)packages/schema/src/index.ts (1)
infer(182-182)packages/server/src/api/stream/util.ts (1)
StreamResponseError(3-3)
packages/cli/scripts/test-concurrent-sessions.ts (2)
apps/testing/integration-suite/src/test/helpers/cli.ts (1)
runCLI(117-185)packages/cli/src/internal-logger.ts (1)
getLogSessionsInCurrentWindow(468-502)
packages/cli/src/cmd/cloud/db/create.ts (1)
packages/cli/src/env-util.ts (1)
addResourceEnvVars(431-436)
packages/cli/src/cmd/cloud/stream/list.ts (4)
packages/core/src/index.ts (2)
StructuredError(2-2)StreamInfo(49-49)packages/server/src/api/stream/list.ts (1)
streamList(83-111)packages/core/src/services/stream.ts (1)
StreamInfo(97-127)packages/vscode/src/core/cliClient.ts (1)
StreamInfo(1304-1310)
packages/cli/src/cmd/cloud/region-lookup.ts (2)
packages/cli/src/cache/resource-region.ts (2)
getResourceInfo(80-114)setResourceInfo(134-152)packages/cli/src/config.ts (1)
getDefaultRegion(778-814)
packages/cli/src/cmd/cloud/stream/get.ts (1)
packages/server/src/api/stream/get.ts (1)
streamGet(39-51)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: Framework Integration Tests (TanStack & Next.js)
- GitHub Check: Queue CLI Tests
- GitHub Check: Sandbox CLI Tests
- GitHub Check: Queue SDK Tests
- GitHub Check: Playwright E2E Smoke Test
- GitHub Check: Package Installation & Usage Test
- GitHub Check: Standalone Agent Test
- GitHub Check: SDK Integration Test Suite
- GitHub Check: Template Integration Tests
- GitHub Check: Cloud Deployment Tests
- GitHub Check: Build
🔇 Additional comments (60)
packages/cli/src/cmd/cloud/env/push.ts (1)
83-88: Indentation cleanup looks good.No functional changes; the loop remains correct and clearer to read.
packages/cli/src/cmd/dev/index.ts (1)
1180-1183: Heartbeat port parsing looks good.The regex guard ensures only numeric ports are parsed before
parseInt, so this is safe and clear.scripts/test-templates.ts (1)
426-431: LGTM!The multi-line formatting for the
runCommandcall improves readability and aligns with the Prettier formatting guidelines.packages/frontend/src/client/index.ts (1)
165-175: LGTM on the validation logic improvement.The per-parameter validation with descriptive error messages is a solid improvement over the previous implementation. Converting each argument to string via
String(arg)correctly handles numeric and other primitive path parameters.packages/cli/src/cmd/build/vite/vite-builder.ts (1)
206-215: Build options grouping looks good.The build options are now correctly scoped under
build, and the configuration remains coherent.packages/cli/src/cmd/cloud/db/delete.ts (1)
181-204: LGTM!The post-deletion handling is well-structured with proper conditional checks:
- Cache clearing via
deleteResourceRegionis correctly awaited- Environment variable removal is properly guarded by
ctx.projectDirandenv_keys.length > 0- Success/failure paths return appropriate results
packages/cli/src/cmd/git/list.ts (1)
56-76: LGTM!The refactored org selection logic is clean and correct. The pattern of extracting
firstOrgbefore the conditional check provides proper TypeScript narrowing, and the auto-selection behavior when only one org exists improves UX while the prompt is appropriately shown when multiple orgs are available.packages/cli/scripts/test-concurrent-sessions.ts (3)
58-77: Good improvement:finallyblock ensures timeout cleanup.The addition of the
try/finallyblock guarantees thatclearTimeout(timeoutId)is called regardless of how the function exits—whether through normal return or exception. This prevents potential timer leaks and ensures the per-process timeout doesn't fire unexpectedly after the process has already completed.
36-50: Formatting changes look good.The stylistic changes (line breaks in function signatures, arrow function parameter spacing, and blank lines for readability) are consistent and improve code readability without affecting behavior.
Also applies to: 60-71, 85-241
269-277: LGTM: Global timeout cleanup in both success and error paths.The
main()promise chain correctly clears the global timeout in both.then()and.catch()branches, ensuring proper resource cleanup.packages/server/src/api/stream/util.ts (1)
1-3: LGTM — centralized StreamResponseError.Keeps stream error handling consistent and reusable.
packages/cli/src/cmd/cloud/ssh.ts (1)
74-82: LGTM — org resolution delegated to CLI API.The explicit
undefinedorgId makes the new auto-resolution path clear.packages/cli/src/catalyst.ts (1)
8-15: LGTM — env override + regional fallback are clear.Good encapsulation of catalyst URL resolution.
packages/cli/src/cmd/cloud/db/create.ts (1)
77-94: LGTM — env var writes now guarded by resource existence.This prevents .env updates on failed create flows.
packages/cli/src/cmd/cloud/deploy.ts (1)
109-125: LGTM — resourceRules addition is clear and consistent.This should improve pre-run validation and config/env derivation.
packages/cli/src/cmd/project/reconcile.ts (1)
271-285: LGTM — non-interactive guard for text input is solid.Clear fallback behavior and messaging.
packages/cli/src/cmd/cloud/machine/list.ts (1)
35-44: The code change is correct. Machine list does not require org scoping. ThemachineListbackend endpoint accepts only anAPIClientparameter and does not support org-specific filtering. ThegetGlobalCatalystAPIClientcall withoutorgIdis appropriate here and follows the established pattern used by all other list endpoints (db, session, storage, thread, queue). The response includesorgNameto enable cross-org visibility, which is the intended design. No changes needed.Likely an incorrect or invalid review comment.
packages/cli/src/config.ts (4)
4-5: Import changes look good.The imports are properly reorganized:
getServiceUrlsis retained for other usages in the file (e.g.,getStreamURL), andgetCatalystUrlis correctly imported from the local./catalystmodule.Also applies to: 14-14
359-364: LGTM:saveProjectIdfollows established pattern.The implementation mirrors
saveOrgIdwhich is appropriate for consistency.
374-380: LGTM:clearProjectIdfollows established pattern.The implementation mirrors
clearOrgIdwhich is appropriate for consistency.
754-754: LGTM: Refactored to usegetCatalystUrl.This centralizes Catalyst URL resolution logic, allowing environment variable override (
AGENTUITY_CATALYST_URL) to work consistently across all usages.packages/cli/src/cache/resource-region.ts (5)
29-29: LGTM: Schema extended for project tracking.Adding
project_idto the cache table aligns with the PR's goal of enabling cross-org resource resolution.
55-65: LGTM: ResourceType extended appropriately.The new resource types (
machine,queue,vector,kv,stream) align with the expanded CLI capabilities in this PR.
70-74: LGTM: ResourceInfo interface extended.The optional
projectIdfield maintains backward compatibility.
88-113: LGTM: getResourceInfo correctly fetches and returns projectId.The query and return mapping are updated consistently.
134-151: LGTM: setResourceInfo correctly persists projectId.The upsert statement properly handles the new column with null coalescing.
packages/cli/src/tui/prompt.ts (4)
233-235: LGTM: Non-interactive confirm returns initial value.This is the expected behavior for automated/scripted usage.
321-331: LGTM: Non-interactive select with sensible fallback.Falls back to first option if initial isn't found, and throws if no options available.
438-441: LGTM: Non-interactive multiselect filters to valid choices.Returns only initial values that exist in the available choices.
512-517: LGTM: Defensive filtering of undefined values.This prevents potential runtime issues if choices array has gaps.
packages/cli/src/cmd/cloud/stream/create.ts (3)
7-7: LGTM: Import for region resolution.
getDefaultRegionis correctly imported for runtime region resolution.
23-24: LGTM: Region moved from required to optional.This aligns with the PR objective to eliminate mandatory
--regionflag where possible.
80-86: LGTM: Region resolution with fallback.The handler correctly resolves region from context or falls back to
getDefaultRegion. The resolved region is properly passed tocreateStorageAdapter.packages/cli/src/types.ts (5)
57-57: LGTM: projectId preference added.This enables persisting the default project ID in user preferences.
326-356: LGTM: Well-designedResourceSelectionRuleinterface.The interface provides a clear, declarative schema for resource selection with good documentation. The properties cover the key aspects of resource resolution (flags, env vars, config prefs, caching, implied values).
516-516: LGTM:resourceRulesadded to command factory functions.This enables commands to declaratively specify their resource selection behavior.
Also applies to: 564-564
605-605: LGTM:resourceRulespropagated to base types.All command definition variants consistently include the optional
resourceRulesproperty.Also applies to: 626-626, 647-647, 668-668
649-651: LGTM:requiresandoptionaladded to SubcommandDefBase.These properties enable subcommands to specify their auth/project/org/region requirements declaratively.
Also applies to: 670-672
packages/cli/src/index.ts (2)
76-76: LGTM:getCatalystUrlexported as public API.This enables external consumers and other CLI commands to resolve Catalyst URLs consistently.
115-115: LGTM:ResourceSelectionRuletype exported.This enables schema-driven tooling and tests to use the resource selection rule type.
packages/cli/src/cmd/cloud/keyvalue/util.ts (2)
2-2: LGTM: Import refactored to usegetCatalystUrl.The import correctly switches from direct
getServiceUrlsusage to the centralizedgetCatalystUrlhelper.Also applies to: 4-4
35-35: LGTM: Base URL resolution centralized.Using
getCatalystUrl(ctx.region)instead of inline service URL lookup maintains consistency with other CLI modules and respects theAGENTUITY_CATALYST_URLenvironment variable override.packages/server/src/api/stream/list.ts (1)
1-111: Well-structured stream list API implementation.The implementation follows established patterns: zod schemas with descriptive metadata, proper query parameter construction, response validation via
APIResponseSchema, and consistent error handling withStreamResponseError. The JSDoc documentation and examples are comprehensive.packages/server/src/api/stream/get.ts (1)
1-51: Clean stream detail API implementation.Good use of
encodeURIComponentfor the ID parameter to prevent URL injection. The schema correctly handles nullable timestamp fields, and the implementation follows the same patterns asstreamList.packages/server/src/api/stream/index.ts (1)
1-3: LGTM!Standard barrel file pattern consolidating the stream API exports.
packages/cli/src/cmd/cloud/sandbox/util.ts (2)
1-12: LGTM - Updated sandbox client creation and imports.The migration to
getServiceUrls(region).catalystfor the sandbox client URL and the updated cache imports align with the PR's goal of API-driven resolution.
19-47: LGTM - Improved cache handling with richer resource info.The updated
getSandboxRegionfunction now usesgetResourceInfo/setResourceInfoto store additional context (orgId) alongside the region. The trace logging for cache hits improves debuggability.packages/cli/src/cmd/cloud/sandbox/create.ts (1)
150-151: Correctly awaits the asyncparseFileArgsfunction.This change properly handles the updated
parseFileArgssignature that now returnsPromise<FileToWrite[]>.packages/cli/src/cmd/cloud/sandbox/run.ts (1)
131-132: LGTM!The change correctly awaits the now-async
parseFileArgsfunction. The function was updated to useawait Bun.file(resolvedPath).exists()per coding guidelines, making it return aPromise<FileToWrite[]>.packages/cli/src/cmd/cloud/sandbox/get.ts (1)
68-79: LGTM!The refactored handler correctly implements the new API-driven sandbox resolution flow:
- Resolves sandbox metadata via
sandboxResolve(apiClient, sandboxId)to obtain region and orgId- Creates a regional client with the resolved region
- Fetches full sandbox details using the resolved orgId
This aligns with the PR objective of eliminating the
--org-idrequirement by auto-discovering the org through the CLI API.packages/cli/src/cmd/cloud/region-lookup.ts (1)
67-98: LGTM!The null checks for
apiClientbefore lookups are appropriate defensive programming. Thetui.fatalcalls are consistent with the CLI's existing error handling patterns for fatal configuration errors.packages/cli/src/auth.ts (1)
102-126: LGTM!The
resolveOrgIdWithoutPromptfunction implements a clear resolution hierarchy:
--org-idflagAGENTUITY_CLOUD_ORG_IDenvironment variable- Config preferences
- Cached orgId from prefixed resource IDs
This enables the "no
--org-idrequired" UX for commands operating on existing resources.packages/cli/src/cmd/cloud/stream/list.ts (2)
8-12: LGTM!The
StreamListErroris correctly defined using theStructuredErrorpattern from@agentuity/core, complying with the coding guidelines.
167-176: LGTM!Error handling correctly uses the
StructuredErrorpattern:
- Re-throws
StreamListErrorinstances as-is- Wraps unknown errors in
StreamListErrorwith contextual data (namespace, projectId, orgId)This addresses the previous review feedback about using
StructuredErrorinstead oftui.fatal.packages/cli/src/cmd/cloud/stream/get.ts (2)
8-15: LGTM!The error types are correctly defined using the
StructuredErrorpattern from@agentuity/core:
StreamGetErrorwith optionalstreamIdcontextStreamDownloadErrorwithstatusCodeandstatusTextcontextStreamReaderErrorfor reader failuresThis addresses the previous review feedback about using
StructuredErrorinstead oftui.fatal.
88-110: LGTM!The streaming download implementation is well-structured:
- Uses
Bun.file().writer()for efficient file writing- Properly handles the reader loop with
donecheck- Ensures
reader.releaseLock()is called in thefinallyblock for proper cleanuppackages/cli/src/cli.ts (3)
499-503: LGTM!Good addition of the
--project-idCLI option with environment variable fallback (AGENTUITY_CLOUD_PROJECT_ID). This provides flexibility for users to specify projects without requiring anagentuity.jsonfile.
908-924: Nice UX improvement!Prompting users to save their selected region as default (when no preference or env var is set) improves the developer experience by reducing repetitive selections.
1375-1408: LGTM!The prefixed resource ID handling logic is correctly integrated:
- Check if args/opts contain prefixed resource IDs
- If so, attempt to resolve orgId from cache without prompting
- Fall back to interactive
requireOrgif no cached orgId is foundThis enables the "no
--org-idrequired" behavior for resource lookup commands.packages/cli/src/cmd/cloud/vector/util.ts (1)
2-4: LGTM!The refactoring to use
getCatalystUrl(ctx.region)instead ofgetServiceUrlsaligns well with the PR's goal of consolidating URL resolution through the new Catalyst helper. The import updates are clean and consistent with the pattern being introduced across other CLI modules.Also applies to: 35-35
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
- reconcile.ts: Validate defaultRegion against available regions list in non-interactive mode; show helpful error with supported regions if invalid - prompt.ts: Only accept validationResult === true (not undefined); include validation error string in error message when present - resolve.ts: Use APIResponseSchemaOptionalData for standardized response schema; propagate actual status code from error response instead of hardcoding 404
Summary
Eliminates the
--org-idrequirement for CLI commands that look up existing resources by using new CLI API endpoints that search across all organizations the user has access to.Changes
New SDK Functions (
@agentuity/server)sandboxResolve(apiClient, sandboxId)- Resolves a sandbox ID to get region and orgId via/cli/sandbox/{id}cliSandboxList(apiClient, options)- Lists sandboxes across all orgs via/cli/sandboxCLI Commands Updated
sandbox listcliSandboxListwith CLI APIsandbox getsandboxResolveto auto-get orgIdsandbox deletesandboxResolveto auto-get orgIdsandbox execsandboxResolveto auto-get orgIdsandbox cpsandboxResolveto auto-get orgIdsandbox lssandboxResolveto auto-get orgIdsandbox mkdirsandboxResolveto auto-get orgIdsandbox rmsandboxResolveto auto-get orgIdsandbox rmdirsandboxResolveto auto-get orgIdsandbox uploadsandboxResolveto auto-get orgIdsandbox downloadsandboxResolveto auto-get orgIdsandbox envsandboxResolveto auto-get orgIdstorage liststorage getdb getstream liststream getTest Results
✅ Working WITHOUT
--org-idproject list,project showapikey listqueue listsession list,thread listeval list,eval-run listdb list,db getstorage list,storage getstream list,stream getsandbox list,sandbox get,sandbox delete,sandbox exec,sandbox envagent list- requires project contextenv list- requires project contextdeployment list- requires project contextkeyvalue list-namespaces- requires--regionredis show- requires org selection❌ Still Requires
--org-idmachine list- Catalyst endpoint requiresx-agentuity-orgidheader (needs CLI API endpoint)Create Operations (Expected to require
--org-id)sandbox create,sandbox rundb create,storage createRelated PRs
Summary by CodeRabbit
New Features
Refactor
Other