Skip to content

feat(cli): eliminate --org-id requirement for resource lookup commands#876

Merged
jhaynie merged 4 commits intomainfrom
task/improve-sdk-prompting
Feb 5, 2026
Merged

feat(cli): eliminate --org-id requirement for resource lookup commands#876
jhaynie merged 4 commits intomainfrom
task/improve-sdk-prompting

Conversation

@jhaynie
Copy link
Member

@jhaynie jhaynie commented Feb 5, 2026

Summary

Eliminates the --org-id requirement 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/sandbox

CLI Commands Updated

Command Change
sandbox list Uses cliSandboxList with CLI API
sandbox get Uses sandboxResolve to auto-get orgId
sandbox delete Uses sandboxResolve to auto-get orgId
sandbox exec Uses sandboxResolve to auto-get orgId
sandbox cp Uses sandboxResolve to auto-get orgId
sandbox ls Uses sandboxResolve to auto-get orgId
sandbox mkdir Uses sandboxResolve to auto-get orgId
sandbox rm Uses sandboxResolve to auto-get orgId
sandbox rmdir Uses sandboxResolve to auto-get orgId
sandbox upload Uses sandboxResolve to auto-get orgId
sandbox download Uses sandboxResolve to auto-get orgId
sandbox env Uses sandboxResolve to auto-get orgId
storage list Searches across all orgs
storage get Searches across all orgs
db get Searches across all orgs
stream list Uses CLI API to list across all orgs
stream get Uses CLI API to resolve stream

Test Results

✅ Working WITHOUT --org-id

  • project list, project show
  • apikey list
  • queue list
  • session list, thread list
  • eval list, eval-run list
  • db list, db get
  • storage list, storage get
  • stream list, stream get
  • sandbox list, sandbox get, sandbox delete, sandbox exec, sandbox env

⚠️ Still Requires Context (Expected)

  • agent list - requires project context
  • env list - requires project context
  • deployment list - requires project context
  • keyvalue list-namespaces - requires --region
  • redis show - requires org selection

❌ Still Requires --org-id

  • machine list - Catalyst endpoint requires x-agentuity-orgid header (needs CLI API endpoint)

Create Operations (Expected to require --org-id)

  • sandbox create, sandbox run
  • db create, storage create

Related PRs

Summary by CodeRabbit

  • New Features

    • Multi-organization searches for DB, storage, sandbox and stream; add --org-id and --project-id filters
    • Server APIs for sandbox and stream (resolve, list, get) exposed; stream download now supports streamed downloads with progress
  • Refactor

    • Commands now resolve sandbox/stream region and org via API lookup instead of local heuristics
    • Caching only persisted when region+org available; listing UIs adapt to multi-org results (conditional Organization column)
  • Other

    • Non-interactive prompts use safe defaults; CLI can persist project and region preferences

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.
@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

Commands 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

Cohort / File(s) Summary
Sandbox CLI commands
packages/cli/src/cmd/cloud/sandbox/cp.ts, packages/cli/src/cmd/cloud/sandbox/delete.ts, packages/cli/src/cmd/cloud/sandbox/download.ts, packages/cli/src/cmd/cloud/sandbox/env.ts, packages/cli/src/cmd/cloud/sandbox/exec.ts, packages/cli/src/cmd/cloud/sandbox/get.ts, packages/cli/src/cmd/cloud/sandbox/list.ts, packages/cli/src/cmd/cloud/sandbox/ls.ts, packages/cli/src/cmd/cloud/sandbox/mkdir.ts, packages/cli/src/cmd/cloud/sandbox/rm.ts, packages/cli/src/cmd/cloud/sandbox/rmdir.ts, packages/cli/src/cmd/cloud/sandbox/upload.ts, packages/cli/src/cmd/cloud/sandbox/.../snapshot/*
Replaced local getSandboxRegion flow with sandboxResolve(apiClient, sandboxId) then regional createSandboxClient; many commands changed requires from { auth, org }{ auth, apiClient }. list uses cliSandboxList and schema/UI adjusted for multi-org results; several file ops added path in responses.
Sandbox utilities & cache
packages/cli/src/cmd/cloud/sandbox/util.ts, packages/cli/src/cache/resource-region.ts
Moved cache helpers to resource-info APIs (getResourceInfo/setResourceInfo), made getSandboxRegion orgId optional, made parseFileArgs async using Bun.file().exists(), and added project_id column and new ResourceType literals in cache schema.
DB & Storage multi-org resolution
packages/cli/src/cmd/cloud/db/get.ts, packages/cli/src/cmd/cloud/storage/get.ts, packages/cli/src/cmd/cloud/storage/list.ts
Removed per-org upfront lookup/caching; handlers now search across all orgs (listOrgResources({ type })), cache only when both cloud_region and org_id present, and dropped optional org flags. --show-tables now requires db.org_id guard.
Stream commands & utilities
packages/cli/src/cmd/cloud/stream/get.ts, packages/cli/src/cmd/cloud/stream/list.ts, packages/cli/src/cmd/cloud/stream/create.ts, packages/cli/src/cmd/cloud/stream/delete.ts, packages/cli/src/cmd/cloud/stream/util.ts
Moved stream list/get to server APIs (streamList, streamGet); commands now require apiClient. Added streaming download implementation, new Stream error types, project/org filtering, and createStorageAdapterForOrg to build org-scoped adapters.
Server API surface — sandbox & stream
packages/server/src/api/sandbox/resolve.ts, packages/server/src/api/sandbox/cli-list.ts, packages/server/src/api/sandbox/index.ts, packages/server/src/api/stream/get.ts, packages/server/src/api/stream/list.ts, packages/server/src/api/stream/util.ts, packages/server/src/api/stream/index.ts, packages/server/src/api/index.ts
Added sandboxResolve, cliSandboxList, stream get/list/util modules and exported them from server API barrels; introduced related Zod schemas, types, and StructuredError-based errors.
CLI core: auth, region, project, prompts, types
packages/cli/src/auth.ts, packages/cli/src/cli.ts, packages/cli/src/config.ts, packages/cli/src/tui/prompt.ts, packages/cli/src/types.ts
Added prefixed-resource handling (resource ID prefixes), hasPrefixedResourceId, resolveOrgIdWithoutPrompt, resolveRegion enhancements, saveProjectId/clearProjectId, non-interactive prompt behavior, --project-id flag, and ResourceSelectionRule/resourceRules support for command metadata.
Catalyst / service URL helpers
packages/cli/src/catalyst.ts, packages/cli/src/index.ts, packages/cli/src/config.ts, packages/cli/src/cmd/cloud/*/util.ts
Added getCatalystUrl(region) with env override AGENTUITY_CATALYST_URL and replaced usages of getServiceUrls(...).catalyst with getCatalystUrl. Exported getCatalystUrl from CLI index.
Region lookup & identifier handling
packages/cli/src/cmd/cloud/region-lookup.ts, packages/cli/src/cmd/cloud/ssh.ts
Extended IdentifierType to include stream, made apiClient optional in region lookup, added stream-specific resolution via storage service, and switched cache access to getResourceInfo/setResourceInfo.
Miscellaneous command refactors & formatting
assorted files: packages/cli/src/cmd/cloud/db/create.ts, .../delete.ts, storage/create.ts, storage/delete.ts, machine/list.ts, sandbox create/run await updates, test scripts, README, frontend client change, vite build/plugin tweaks, and small formatting changes across CLI
Mostly structural/formatting edits, async adjustments where parseFileArgs became async, timeout cleanup in test script, minor UI and example updates, and non-functional reflows. Review callers of async parseFileArgs and prompt non-interactive guards.
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


🧹 Recent nitpick comments
packages/cli/src/tui/prompt.ts (1)

62-66: Consider using StructuredError for consistency.

The coding guidelines specify using StructuredError from @agentuity/core for error handling. This helper creates plain Error objects which diverges from the project standard.

♻️ Suggested change
+import { StructuredError } from '@agentuity/core';
+
 // ...

 private nonInteractiveError(message: string): Error {
-   return new Error(
-      `${message} Use the appropriate --flag or environment variable to provide input.`
-   );
+   return new StructuredError(
+      `${message} Use the appropriate --flag or environment variable to provide input.`
+   );
 }

As per coding guidelines: "Use StructuredError from @agentuity/core for error handling".

packages/server/src/api/sandbox/resolve.ts (1)

66-69: Consider URL-encoding the sandboxId for defensive robustness.

While sandbox IDs typically follow a predictable format (e.g., sbx_...), encoding the path parameter protects against edge cases with unexpected characters.

♻️ Suggested improvement
 const response = await client.get<z.infer<typeof SandboxResolveResponseSchema>>(
-  `/cli/sandbox/${sandboxId}`,
+  `/cli/sandbox/${encodeURIComponent(sandboxId)}`,
   SandboxResolveResponseSchema
 );
📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86865c3 and 9c30554.

📒 Files selected for processing (3)
  • packages/cli/src/cmd/project/reconcile.ts
  • packages/cli/src/tui/prompt.ts
  • packages/server/src/api/sandbox/resolve.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/cli/src/cmd/project/reconcile.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
Use StructuredError from @agentuity/core for error handling

Files:

  • packages/server/src/api/sandbox/resolve.ts
  • packages/cli/src/tui/prompt.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.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.ts
packages/cli/**/*.ts

📄 CodeRabbit inference engine (packages/cli/AGENTS.md)

Use Bun.file(f).exists() instead of existsSync(f) for file existence checks

Files:

  • packages/cli/src/tui/prompt.ts
🧠 Learnings (3)
📚 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.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/sandbox/resolve.ts
  • packages/cli/src/tui/prompt.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.ts
🧬 Code graph analysis (1)
packages/server/src/api/sandbox/resolve.ts (1)
packages/server/src/api/api.ts (1)
  • APIResponseSchemaOptionalData (882-893)
⏰ 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: Template Integration Tests
  • GitHub Check: Storage CLI Tests
  • GitHub Check: Sandbox CLI Tests
  • GitHub Check: Playwright E2E Smoke Test
  • GitHub Check: Package Installation & Usage Test
  • GitHub Check: SDK Integration Test Suite
  • GitHub Check: Cloud Deployment Tests
  • GitHub Check: Framework Integration Tests (TanStack & Next.js)
  • GitHub Check: Queue CLI Tests
  • GitHub Check: Build
  • GitHub Check: Pack & Upload
🔇 Additional comments (12)
packages/cli/src/tui/prompt.ts (5)

97-114: LGTM! Non-interactive text prompt handling is well-implemented.

The validation logic correctly accepts only validationResult === true as passing (addressing the previous review concern). The error messaging includes helpful detail when validation fails with a string message.


238-240: LGTM!

Returning the initial value (defaulting to false) in non-interactive mode is sensible default behavior.


326-336: LGTM!

Good defensive handling for the empty choices edge case. The fallback to the first option when no initial match is found is reasonable default behavior for non-interactive mode.


443-446: LGTM!

Efficient implementation using Set for O(1) lookup. Filtering to only valid choices prevents returning invalid selections in non-interactive mode.


517-522: LGTM!

Good defensive coding with optional chaining and undefined filtering. This prevents potential runtime errors and maintains type safety.

packages/server/src/api/sandbox/resolve.ts (7)

1-3: LGTM!

Imports are correctly structured - uses StructuredError from @agentuity/core per coding guidelines and imports the standardized APIResponseSchemaOptionalData for response schema definition.


5-15: LGTM!

The data schema is well-defined with appropriate nullable annotations and correctly uses zod for runtime validation as per coding guidelines.


17-20: LGTM!

Response schema correctly uses APIResponseSchemaOptionalData to create the standardized discriminated union pattern, consistent with other sandbox modules.


22-32: LGTM!

The interface provides a clean public API type that correctly mirrors the schema structure with proper nullable typing.


34-51: LGTM!

Error class correctly uses StructuredError from @agentuity/core per coding guidelines. The JSDoc example clearly demonstrates the recommended error handling pattern using _tag for type narrowing.


71-88: LGTM!

Error handling correctly separates the failure case (with status code mapping from response.code) from the success-but-no-data case. The status code derivation at line 74 addresses the earlier feedback about propagating actual server response codes where available.


90-97: LGTM!

Explicit field mapping provides clarity and ensures the return type contract is fulfilled correctly. All fields from response.data are properly mapped to ResolvedSandboxInfo.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: Use Bun.file().exists() instead of existsSync.

As per coding guidelines, packages/cli/**/*.ts files should use Bun.file(f).exists() instead of existsSync(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 parseFileArgs an async function and updating all call sites accordingly.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a54abab and 0b953d1.

📒 Files selected for processing (23)
  • packages/cli/src/cmd/cloud/db/get.ts
  • packages/cli/src/cmd/cloud/sandbox/cp.ts
  • packages/cli/src/cmd/cloud/sandbox/delete.ts
  • packages/cli/src/cmd/cloud/sandbox/download.ts
  • packages/cli/src/cmd/cloud/sandbox/env.ts
  • packages/cli/src/cmd/cloud/sandbox/exec.ts
  • packages/cli/src/cmd/cloud/sandbox/get.ts
  • packages/cli/src/cmd/cloud/sandbox/list.ts
  • packages/cli/src/cmd/cloud/sandbox/ls.ts
  • packages/cli/src/cmd/cloud/sandbox/mkdir.ts
  • packages/cli/src/cmd/cloud/sandbox/rm.ts
  • packages/cli/src/cmd/cloud/sandbox/rmdir.ts
  • packages/cli/src/cmd/cloud/sandbox/upload.ts
  • packages/cli/src/cmd/cloud/sandbox/util.ts
  • packages/cli/src/cmd/cloud/storage/get.ts
  • packages/cli/src/cmd/cloud/storage/list.ts
  • packages/cli/src/cmd/cloud/stream/get.ts
  • packages/cli/src/cmd/cloud/stream/list.ts
  • packages/cli/src/cmd/cloud/stream/util.ts
  • packages/server/src/api/index.ts
  • packages/server/src/api/sandbox/cli-list.ts
  • packages/server/src/api/sandbox/index.ts
  • packages/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
Use StructuredError from @agentuity/core for error handling

Files:

  • packages/server/src/api/index.ts
  • packages/server/src/api/sandbox/resolve.ts
  • packages/cli/src/cmd/cloud/storage/list.ts
  • packages/cli/src/cmd/cloud/sandbox/upload.ts
  • packages/server/src/api/sandbox/cli-list.ts
  • packages/cli/src/cmd/cloud/storage/get.ts
  • packages/cli/src/cmd/cloud/sandbox/delete.ts
  • packages/cli/src/cmd/cloud/stream/get.ts
  • packages/cli/src/cmd/cloud/sandbox/exec.ts
  • packages/cli/src/cmd/cloud/sandbox/rmdir.ts
  • packages/cli/src/cmd/cloud/stream/util.ts
  • packages/cli/src/cmd/cloud/db/get.ts
  • packages/cli/src/cmd/cloud/sandbox/get.ts
  • packages/cli/src/cmd/cloud/sandbox/download.ts
  • packages/cli/src/cmd/cloud/sandbox/cp.ts
  • packages/cli/src/cmd/cloud/sandbox/rm.ts
  • packages/cli/src/cmd/cloud/sandbox/ls.ts
  • packages/cli/src/cmd/cloud/sandbox/util.ts
  • packages/cli/src/cmd/cloud/stream/list.ts
  • packages/cli/src/cmd/cloud/sandbox/env.ts
  • packages/cli/src/cmd/cloud/sandbox/list.ts
  • packages/cli/src/cmd/cloud/sandbox/mkdir.ts
  • packages/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.ts
  • packages/server/src/api/sandbox/resolve.ts
  • packages/server/src/api/sandbox/cli-list.ts
  • packages/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.ts
  • packages/server/src/api/sandbox/resolve.ts
  • packages/server/src/api/sandbox/cli-list.ts
  • packages/server/src/api/sandbox/index.ts
packages/cli/**/*.ts

📄 CodeRabbit inference engine (packages/cli/AGENTS.md)

Use Bun.file(f).exists() instead of existsSync(f) for file existence checks

Files:

  • packages/cli/src/cmd/cloud/storage/list.ts
  • packages/cli/src/cmd/cloud/sandbox/upload.ts
  • packages/cli/src/cmd/cloud/storage/get.ts
  • packages/cli/src/cmd/cloud/sandbox/delete.ts
  • packages/cli/src/cmd/cloud/stream/get.ts
  • packages/cli/src/cmd/cloud/sandbox/exec.ts
  • packages/cli/src/cmd/cloud/sandbox/rmdir.ts
  • packages/cli/src/cmd/cloud/stream/util.ts
  • packages/cli/src/cmd/cloud/db/get.ts
  • packages/cli/src/cmd/cloud/sandbox/get.ts
  • packages/cli/src/cmd/cloud/sandbox/download.ts
  • packages/cli/src/cmd/cloud/sandbox/cp.ts
  • packages/cli/src/cmd/cloud/sandbox/rm.ts
  • packages/cli/src/cmd/cloud/sandbox/ls.ts
  • packages/cli/src/cmd/cloud/sandbox/util.ts
  • packages/cli/src/cmd/cloud/stream/list.ts
  • packages/cli/src/cmd/cloud/sandbox/env.ts
  • packages/cli/src/cmd/cloud/sandbox/list.ts
  • packages/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.ts
  • packages/server/src/api/sandbox/resolve.ts
  • packages/server/src/api/sandbox/cli-list.ts
  • packages/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.ts
  • packages/server/src/api/sandbox/resolve.ts
  • packages/cli/src/cmd/cloud/storage/list.ts
  • packages/cli/src/cmd/cloud/sandbox/upload.ts
  • packages/server/src/api/sandbox/cli-list.ts
  • packages/cli/src/cmd/cloud/storage/get.ts
  • packages/cli/src/cmd/cloud/sandbox/delete.ts
  • packages/cli/src/cmd/cloud/stream/get.ts
  • packages/cli/src/cmd/cloud/sandbox/exec.ts
  • packages/cli/src/cmd/cloud/sandbox/rmdir.ts
  • packages/cli/src/cmd/cloud/stream/util.ts
  • packages/cli/src/cmd/cloud/db/get.ts
  • packages/cli/src/cmd/cloud/sandbox/get.ts
  • packages/cli/src/cmd/cloud/sandbox/download.ts
  • packages/cli/src/cmd/cloud/sandbox/cp.ts
  • packages/cli/src/cmd/cloud/sandbox/rm.ts
  • packages/cli/src/cmd/cloud/sandbox/ls.ts
  • packages/cli/src/cmd/cloud/sandbox/util.ts
  • packages/cli/src/cmd/cloud/stream/list.ts
  • packages/cli/src/cmd/cloud/sandbox/env.ts
  • packages/cli/src/cmd/cloud/sandbox/list.ts
  • packages/cli/src/cmd/cloud/sandbox/mkdir.ts
  • packages/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.ts
  • packages/server/src/api/sandbox/resolve.ts
  • packages/server/src/api/sandbox/cli-list.ts
  • packages/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.ts
  • packages/cli/src/cmd/cloud/sandbox/upload.ts
  • packages/cli/src/cmd/cloud/storage/get.ts
  • packages/cli/src/cmd/cloud/sandbox/delete.ts
  • packages/cli/src/cmd/cloud/stream/get.ts
  • packages/cli/src/cmd/cloud/sandbox/exec.ts
  • packages/cli/src/cmd/cloud/sandbox/rmdir.ts
  • packages/cli/src/cmd/cloud/stream/util.ts
  • packages/cli/src/cmd/cloud/db/get.ts
  • packages/cli/src/cmd/cloud/sandbox/get.ts
  • packages/cli/src/cmd/cloud/sandbox/download.ts
  • packages/cli/src/cmd/cloud/sandbox/cp.ts
  • packages/cli/src/cmd/cloud/sandbox/rm.ts
  • packages/cli/src/cmd/cloud/sandbox/ls.ts
  • packages/cli/src/cmd/cloud/sandbox/util.ts
  • packages/cli/src/cmd/cloud/stream/list.ts
  • packages/cli/src/cmd/cloud/sandbox/env.ts
  • packages/cli/src/cmd/cloud/sandbox/list.ts
  • packages/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 listOrgResources without an explicit orgId
  • Uses optional chaining (bucket?.cloud_region) to safely handle the case where bucket may be undefined
  • Caches only when both cloud_region and org_id are present, ensuring valid cache entries
packages/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: true requirement from the command
  • Fetch resources across all accessible organizations
  • Cache each bucket with its specific org_id from the API response

Also 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 globalClient with listOrgResources without an explicit orgId correctly enables cross-org resource discovery.


106-108: LGTM!

Correctly requires both cloud_region and org_id before 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 using tui.fatal() is consistent with the established error handling pattern throughout the CLI codebase. The suggested implementation is incorrect: StructuredError is a factory function that must be defined first (const OrgIdRequiredError = StructuredError('ORG_ID_REQUIRED', 'message')), not called directly with new StructuredError('code', 'message'). The CLI consistently uses tui.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() with ErrorCode.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.). The ErrorCode enum provides semantic error codes that map to appropriate exit codes via getExitCode(). The StructuredError from @agentuity/core is used for creating custom error types in utility functions, not for wrapping errors before calling tui.fatal(), which only accepts a string message and optional ErrorCode. 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 sandboxResolve for 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 the sbx_ prefix per repository conventions.

packages/cli/src/cmd/cloud/sandbox/get.ts (1)

68-81: LGTM!

The two-step resolution flow is appropriate here: sandboxResolve provides the region/orgId needed to route to the correct regional API, while sandboxGet fetches 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 path is 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 sandboxResolve for 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 + sandboxResolve keeps 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: apiClient requirement 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. The tui.fatal function signature is fatal(message: string, errorCode?: ErrorCode): never and does not accept StructuredError as a parameter. Passing ErrorCode.API_ERROR is 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';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# Find the `@agentuity/server` package location
find . -type f -name "package.json" | xargs grep -l "@agentuity/server" | head -5

Repository: agentuity/sdk

Length of output: 212


🏁 Script executed:

# Look for the server package structure
find . -type d -name "server" | grep -E "packages|src" | head -10

Repository: agentuity/sdk

Length of output: 74


🏁 Script executed:

# Search for streamGet in the codebase
rg "streamGet" --type ts --type tsx -l

Repository: agentuity/sdk

Length of output: 84


🏁 Script executed:

# Search for streamGet with correct file type syntax
rg "streamGet" --type typescript -l

Repository: 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.ts

Repository: agentuity/sdk

Length of output: 5031


🏁 Script executed:

# Search for streamGet in the server package
rg "streamGet" ./packages/server --no-heading

Repository: agentuity/sdk

Length of output: 39


🏁 Script executed:

# Check server package index/exports
find ./packages/server/src -name "index*" -o -name "*export*" | head -10

Repository: agentuity/sdk

Length of output: 462


🏁 Script executed:

# Look at server package src structure
find ./packages/server/src -type f | head -20

Repository: 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.ts

Repository: 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 f

Repository: 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 -20

Repository: 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 stream

Repository: agentuity/sdk

Length of output: 221


🏁 Script executed:

# Check server package root index
cat -n ./packages/server/src/index.ts

Repository: agentuity/sdk

Length of output: 1412


🏁 Script executed:

# Search entire server package for any stream reference
rg "stream" ./packages/server/src -i --type ts

Repository: agentuity/sdk

Length of output: 22292


🏁 Script executed:

# Check server package.json for exports configuration
cat -n ./packages/server/package.json

Repository: 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 -l

Repository: agentuity/sdk

Length of output: 139


🏁 Script executed:

# Check what the api/index.ts file actually exports
cat ./packages/server/src/api/index.ts

Repository: 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.ts

Repository: 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 stream

Repository: 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.

Comment on lines 1 to 6
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';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# Find definitions and exports of streamList and StreamInfo
rg -n "streamList|StreamInfo" packages/cli/src/cmd/cloud/stream/list.ts

Repository: 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=20

Repository: 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.ts

Repository: 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 -5

Repository: 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 -20

Repository: 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 -20

Repository: 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 2

Repository: agentuity/sdk

Length of output: 1240


🏁 Script executed:

# Check packages/server/package.json to understand what it exports
cat packages/server/package.json

Repository: 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/null

Repository: agentuity/sdk

Length of output: 39


🏁 Script executed:

# Check packages/server/src/index.ts
cat packages/server/src/index.ts

Repository: agentuity/sdk

Length of output: 1118


🏁 Script executed:

# List all files in packages/server/src
find packages/server/src -type f -name '*.ts' | sort

Repository: 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.ts

Repository: 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 f

Repository: 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 -i

Repository: 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.ts

Repository: 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 f

Repository: 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 -50

Repository: 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 | sort

Repository: 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 3

Repository: 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 -40

Repository: 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.ts

Repository: 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.ts

Repository: 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 -20

Repository: 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.ts

Repository: 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 -50

Repository: 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.ts

Repository: 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';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

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
@github-actions
Copy link

github-actions bot commented Feb 5, 2026

📦 Canary Packages Published

version: 1.0.1-9c30554

Packages
Package Version URL
@agentuity/cli 1.0.1-9c30554 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-cli-1.0.1-9c30554.tgz
@agentuity/runtime 1.0.1-9c30554 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-runtime-1.0.1-9c30554.tgz
@agentuity/auth 1.0.1-9c30554 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-auth-1.0.1-9c30554.tgz
@agentuity/core 1.0.1-9c30554 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-core-1.0.1-9c30554.tgz
@agentuity/server 1.0.1-9c30554 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-server-1.0.1-9c30554.tgz
@agentuity/workbench 1.0.1-9c30554 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-workbench-1.0.1-9c30554.tgz
@agentuity/evals 1.0.1-9c30554 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-evals-1.0.1-9c30554.tgz
@agentuity/frontend 1.0.1-9c30554 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-frontend-1.0.1-9c30554.tgz
@agentuity/schema 1.0.1-9c30554 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-schema-1.0.1-9c30554.tgz
@agentuity/opencode 1.0.1-9c30554 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-opencode-1.0.1-9c30554.tgz
@agentuity/drizzle 1.0.1-9c30554 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-drizzle-1.0.1-9c30554.tgz
@agentuity/postgres 1.0.1-9c30554 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-postgres-1.0.1-9c30554.tgz
@agentuity/react 1.0.1-9c30554 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.1-9c30554/agentuity-react-1.0.1-9c30554.tgz
Install

Add to your package.json:

{
  "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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 using StructuredError for 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 StructuredError from @agentuity/core instead of plain Error.

♻️ 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 StructuredError from @agentuity/core for error handling".


167-167: Defensive check for paramName === undefined is unnecessary.

Since pathParamNames is typed as string[], 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 TABLE is 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 using StructuredError for consistency.

Per coding guidelines, StructuredError from @agentuity/core should be used for error handling. Currently, nonInteractiveError returns a plain Error.

♻️ 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 StructuredError from @agentuity/core for error handling".

packages/cli/src/cmd/cloud/stream/delete.ts (2)

41-43: Consider using StructuredError instead of tui.fatal for error handling.

The coding guidelines specify using StructuredError from @agentuity/core for error handling. Using tui.fatal here 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.ts for 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 use await Bun.file(resolvedPath).arrayBuffer() and convert to Buffer, but readFileSync works 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_PREFIXES array and related helpers (getResourceTypeFromId, collectPrefixedIds) are defined both here and in packages/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

📥 Commits

Reviewing files that changed from the base of the PR and between 0b953d1 and 86865c3.

📒 Files selected for processing (52)
  • README.md
  • packages/cli/scripts/test-concurrent-sessions.ts
  • packages/cli/src/auth.ts
  • packages/cli/src/cache/resource-region.ts
  • packages/cli/src/catalyst.ts
  • packages/cli/src/cli.ts
  • packages/cli/src/cmd/build/vite/public-asset-path-plugin.ts
  • packages/cli/src/cmd/build/vite/vite-builder.ts
  • packages/cli/src/cmd/cloud/db/create.ts
  • packages/cli/src/cmd/cloud/db/delete.ts
  • packages/cli/src/cmd/cloud/db/get.ts
  • packages/cli/src/cmd/cloud/deploy.ts
  • packages/cli/src/cmd/cloud/env/import.ts
  • packages/cli/src/cmd/cloud/env/list.ts
  • packages/cli/src/cmd/cloud/env/push.ts
  • packages/cli/src/cmd/cloud/keyvalue/util.ts
  • packages/cli/src/cmd/cloud/machine/list.ts
  • packages/cli/src/cmd/cloud/region-lookup.ts
  • packages/cli/src/cmd/cloud/region/index.ts
  • packages/cli/src/cmd/cloud/sandbox/create.ts
  • packages/cli/src/cmd/cloud/sandbox/get.ts
  • packages/cli/src/cmd/cloud/sandbox/run.ts
  • packages/cli/src/cmd/cloud/sandbox/snapshot/build.ts
  • packages/cli/src/cmd/cloud/sandbox/snapshot/get.ts
  • packages/cli/src/cmd/cloud/sandbox/util.ts
  • packages/cli/src/cmd/cloud/ssh.ts
  • packages/cli/src/cmd/cloud/storage/create.ts
  • packages/cli/src/cmd/cloud/storage/delete.ts
  • packages/cli/src/cmd/cloud/storage/list.ts
  • packages/cli/src/cmd/cloud/stream/create.ts
  • packages/cli/src/cmd/cloud/stream/delete.ts
  • packages/cli/src/cmd/cloud/stream/get.ts
  • packages/cli/src/cmd/cloud/stream/list.ts
  • packages/cli/src/cmd/cloud/vector/util.ts
  • packages/cli/src/cmd/dev/index.ts
  • packages/cli/src/cmd/git/account/add.ts
  • packages/cli/src/cmd/git/list.ts
  • packages/cli/src/cmd/project/auth/init.ts
  • packages/cli/src/cmd/project/reconcile.ts
  • packages/cli/src/cmd/support/report.ts
  • packages/cli/src/config.ts
  • packages/cli/src/index.ts
  • packages/cli/src/repl.ts
  • packages/cli/src/tui/prompt.ts
  • packages/cli/src/types.ts
  • packages/frontend/src/client/index.ts
  • packages/server/src/api/sandbox/resolve.ts
  • packages/server/src/api/stream/get.ts
  • packages/server/src/api/stream/index.ts
  • packages/server/src/api/stream/list.ts
  • packages/server/src/api/stream/util.ts
  • scripts/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
Use StructuredError from @agentuity/core for error handling

Files:

  • scripts/test-templates.ts
  • packages/cli/src/index.ts
  • packages/cli/src/cmd/cloud/sandbox/create.ts
  • packages/cli/src/cmd/project/reconcile.ts
  • packages/cli/src/cmd/dev/index.ts
  • packages/cli/src/types.ts
  • packages/cli/src/config.ts
  • packages/cli/src/cmd/cloud/vector/util.ts
  • packages/cli/src/cmd/cloud/stream/create.ts
  • packages/cli/src/catalyst.ts
  • packages/cli/src/cmd/cloud/keyvalue/util.ts
  • packages/server/src/api/sandbox/resolve.ts
  • packages/server/src/api/stream/util.ts
  • packages/cli/src/cmd/cloud/deploy.ts
  • packages/cli/src/cache/resource-region.ts
  • packages/server/src/api/stream/get.ts
  • packages/cli/src/cmd/cloud/ssh.ts
  • packages/cli/src/cmd/cloud/sandbox/run.ts
  • packages/cli/src/auth.ts
  • packages/cli/src/cmd/cloud/stream/delete.ts
  • packages/cli/src/tui/prompt.ts
  • packages/server/src/api/stream/index.ts
  • packages/cli/src/cmd/cloud/db/delete.ts
  • packages/cli/src/cmd/cloud/sandbox/util.ts
  • packages/server/src/api/stream/list.ts
  • packages/cli/scripts/test-concurrent-sessions.ts
  • packages/cli/src/cmd/cloud/sandbox/get.ts
  • packages/cli/src/cmd/cloud/db/create.ts
  • packages/cli/src/cmd/cloud/machine/list.ts
  • packages/cli/src/cmd/cloud/env/push.ts
  • packages/cli/src/cmd/cloud/stream/list.ts
  • packages/frontend/src/client/index.ts
  • packages/cli/src/cli.ts
  • packages/cli/src/cmd/cloud/region-lookup.ts
  • packages/cli/src/cmd/build/vite/vite-builder.ts
  • packages/cli/src/cmd/cloud/stream/get.ts
  • packages/cli/src/cmd/git/list.ts
packages/*/src/index.ts

📄 CodeRabbit inference engine (AGENTS.md)

Use named exports from package index.ts file 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 of existsSync(f) for file existence checks

Files:

  • packages/cli/src/index.ts
  • packages/cli/src/cmd/cloud/sandbox/create.ts
  • packages/cli/src/cmd/project/reconcile.ts
  • packages/cli/src/cmd/dev/index.ts
  • packages/cli/src/types.ts
  • packages/cli/src/config.ts
  • packages/cli/src/cmd/cloud/vector/util.ts
  • packages/cli/src/cmd/cloud/stream/create.ts
  • packages/cli/src/catalyst.ts
  • packages/cli/src/cmd/cloud/keyvalue/util.ts
  • packages/cli/src/cmd/cloud/deploy.ts
  • packages/cli/src/cache/resource-region.ts
  • packages/cli/src/cmd/cloud/ssh.ts
  • packages/cli/src/cmd/cloud/sandbox/run.ts
  • packages/cli/src/auth.ts
  • packages/cli/src/cmd/cloud/stream/delete.ts
  • packages/cli/src/tui/prompt.ts
  • packages/cli/src/cmd/cloud/db/delete.ts
  • packages/cli/src/cmd/cloud/sandbox/util.ts
  • packages/cli/scripts/test-concurrent-sessions.ts
  • packages/cli/src/cmd/cloud/sandbox/get.ts
  • packages/cli/src/cmd/cloud/db/create.ts
  • packages/cli/src/cmd/cloud/machine/list.ts
  • packages/cli/src/cmd/cloud/env/push.ts
  • packages/cli/src/cmd/cloud/stream/list.ts
  • packages/cli/src/cli.ts
  • packages/cli/src/cmd/cloud/region-lookup.ts
  • packages/cli/src/cmd/build/vite/vite-builder.ts
  • packages/cli/src/cmd/cloud/stream/get.ts
  • packages/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 in src/cmd/ with an index.ts file as the entry point
Always define interfaces or Zod schemas for command options; never use any type for type safety
Use tui.* helpers (header, info, success, warning, error, table, progress) for formatted TUI output instead of raw console methods
Use ctx.logger for logging instead of console methods; use logger.fatal() for fatal errors which logs and exits with code 1
Always check isJSONMode() before outputting data and provide machine-readable output when in JSON mode
Use requireAuth(ctx) for commands that require authentication or optionalAuth(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.ts
  • packages/server/src/api/stream/util.ts
  • packages/server/src/api/stream/get.ts
  • packages/server/src/api/stream/index.ts
  • packages/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.ts
  • packages/server/src/api/stream/util.ts
  • packages/server/src/api/stream/get.ts
  • packages/server/src/api/stream/index.ts
  • packages/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.ts
  • packages/cli/src/index.ts
  • packages/cli/src/cmd/cloud/sandbox/create.ts
  • packages/cli/src/cmd/project/reconcile.ts
  • packages/cli/src/cmd/dev/index.ts
  • packages/cli/src/types.ts
  • packages/cli/src/config.ts
  • packages/cli/src/cmd/cloud/vector/util.ts
  • packages/cli/src/cmd/cloud/stream/create.ts
  • packages/cli/src/catalyst.ts
  • packages/cli/src/cmd/cloud/keyvalue/util.ts
  • packages/server/src/api/sandbox/resolve.ts
  • packages/server/src/api/stream/util.ts
  • packages/cli/src/cmd/cloud/deploy.ts
  • packages/cli/src/cache/resource-region.ts
  • packages/server/src/api/stream/get.ts
  • packages/cli/src/cmd/cloud/ssh.ts
  • packages/cli/src/cmd/cloud/sandbox/run.ts
  • packages/cli/src/auth.ts
  • packages/cli/src/cmd/cloud/stream/delete.ts
  • packages/cli/src/tui/prompt.ts
  • packages/server/src/api/stream/index.ts
  • packages/cli/src/cmd/cloud/db/delete.ts
  • packages/cli/src/cmd/cloud/sandbox/util.ts
  • packages/server/src/api/stream/list.ts
  • packages/cli/scripts/test-concurrent-sessions.ts
  • packages/cli/src/cmd/cloud/sandbox/get.ts
  • packages/cli/src/cmd/cloud/db/create.ts
  • packages/cli/src/cmd/cloud/machine/list.ts
  • packages/cli/src/cmd/cloud/env/push.ts
  • packages/cli/src/cmd/cloud/stream/list.ts
  • packages/frontend/src/client/index.ts
  • packages/cli/src/cli.ts
  • packages/cli/src/cmd/cloud/region-lookup.ts
  • packages/cli/src/cmd/build/vite/vite-builder.ts
  • packages/cli/src/cmd/cloud/stream/get.ts
  • packages/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.ts
  • packages/cli/src/cmd/cloud/vector/util.ts
  • packages/cli/src/cmd/cloud/stream/create.ts
  • packages/cli/src/cmd/cloud/keyvalue/util.ts
  • packages/cli/src/cmd/cloud/deploy.ts
  • packages/cli/src/cmd/cloud/ssh.ts
  • packages/cli/src/cmd/cloud/sandbox/run.ts
  • packages/cli/src/cmd/cloud/stream/delete.ts
  • packages/cli/src/cmd/cloud/db/delete.ts
  • packages/cli/src/cmd/cloud/sandbox/util.ts
  • packages/cli/src/cmd/cloud/sandbox/get.ts
  • packages/cli/src/cmd/cloud/db/create.ts
  • packages/cli/src/cmd/cloud/machine/list.ts
  • packages/cli/src/cmd/cloud/env/push.ts
  • packages/cli/src/cmd/cloud/stream/list.ts
  • packages/cli/src/cmd/cloud/region-lookup.ts
  • packages/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.ts
  • packages/server/src/api/stream/util.ts
  • packages/server/src/api/stream/get.ts
  • packages/server/src/api/stream/index.ts
  • packages/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.ts
  • packages/server/src/api/stream/util.ts
  • packages/server/src/api/stream/get.ts
  • packages/server/src/api/stream/index.ts
  • packages/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 runCommand call 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 deleteResourceRegion is correctly awaited
  • Environment variable removal is properly guarded by ctx.projectDir and env_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 firstOrg before 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: finally block ensures timeout cleanup.

The addition of the try/finally block guarantees that clearTimeout(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 undefined orgId 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. The machineList backend endpoint accepts only an APIClient parameter and does not support org-specific filtering. The getGlobalCatalystAPIClient call without orgId is appropriate here and follows the established pattern used by all other list endpoints (db, session, storage, thread, queue). The response includes orgName to 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: getServiceUrls is retained for other usages in the file (e.g., getStreamURL), and getCatalystUrl is correctly imported from the local ./catalyst module.

Also applies to: 14-14


359-364: LGTM: saveProjectId follows established pattern.

The implementation mirrors saveOrgId which is appropriate for consistency.


374-380: LGTM: clearProjectId follows established pattern.

The implementation mirrors clearOrgId which is appropriate for consistency.


754-754: LGTM: Refactored to use getCatalystUrl.

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_id to 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 projectId field 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.

getDefaultRegion is correctly imported for runtime region resolution.


23-24: LGTM: Region moved from required to optional.

This aligns with the PR objective to eliminate mandatory --region flag 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 to createStorageAdapter.

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-designed ResourceSelectionRule interface.

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: resourceRules added to command factory functions.

This enables commands to declaratively specify their resource selection behavior.

Also applies to: 564-564


605-605: LGTM: resourceRules propagated to base types.

All command definition variants consistently include the optional resourceRules property.

Also applies to: 626-626, 647-647, 668-668


649-651: LGTM: requires and optional added 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: getCatalystUrl exported as public API.

This enables external consumers and other CLI commands to resolve Catalyst URLs consistently.


115-115: LGTM: ResourceSelectionRule type 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 use getCatalystUrl.

The import correctly switches from direct getServiceUrls usage to the centralized getCatalystUrl helper.

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 the AGENTUITY_CATALYST_URL environment 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 with StreamResponseError. 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 encodeURIComponent for the ID parameter to prevent URL injection. The schema correctly handles nullable timestamp fields, and the implementation follows the same patterns as streamList.

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).catalyst for 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 getSandboxRegion function now uses getResourceInfo/setResourceInfo to 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 async parseFileArgs function.

This change properly handles the updated parseFileArgs signature that now returns Promise<FileToWrite[]>.

packages/cli/src/cmd/cloud/sandbox/run.ts (1)

131-132: LGTM!

The change correctly awaits the now-async parseFileArgs function. The function was updated to use await Bun.file(resolvedPath).exists() per coding guidelines, making it return a Promise<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:

  1. Resolves sandbox metadata via sandboxResolve(apiClient, sandboxId) to obtain region and orgId
  2. Creates a regional client with the resolved region
  3. Fetches full sandbox details using the resolved orgId

This aligns with the PR objective of eliminating the --org-id requirement 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 apiClient before lookups are appropriate defensive programming. The tui.fatal calls are consistent with the CLI's existing error handling patterns for fatal configuration errors.

packages/cli/src/auth.ts (1)

102-126: LGTM!

The resolveOrgIdWithoutPrompt function implements a clear resolution hierarchy:

  1. --org-id flag
  2. AGENTUITY_CLOUD_ORG_ID environment variable
  3. Config preferences
  4. Cached orgId from prefixed resource IDs

This enables the "no --org-id required" UX for commands operating on existing resources.

packages/cli/src/cmd/cloud/stream/list.ts (2)

8-12: LGTM!

The StreamListError is correctly defined using the StructuredError pattern from @agentuity/core, complying with the coding guidelines.


167-176: LGTM!

Error handling correctly uses the StructuredError pattern:

  • Re-throws StreamListError instances as-is
  • Wraps unknown errors in StreamListError with contextual data (namespace, projectId, orgId)

This addresses the previous review feedback about using StructuredError instead of tui.fatal.

packages/cli/src/cmd/cloud/stream/get.ts (2)

8-15: LGTM!

The error types are correctly defined using the StructuredError pattern from @agentuity/core:

  • StreamGetError with optional streamId context
  • StreamDownloadError with statusCode and statusText context
  • StreamReaderError for reader failures

This addresses the previous review feedback about using StructuredError instead of tui.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 done check
  • Ensures reader.releaseLock() is called in the finally block for proper cleanup
packages/cli/src/cli.ts (3)

499-503: LGTM!

Good addition of the --project-id CLI option with environment variable fallback (AGENTUITY_CLOUD_PROJECT_ID). This provides flexibility for users to specify projects without requiring an agentuity.json file.


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:

  1. Check if args/opts contain prefixed resource IDs
  2. If so, attempt to resolve orgId from cache without prompting
  3. Fall back to interactive requireOrg if no cached orgId is found

This enables the "no --org-id required" 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 of getServiceUrls aligns 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
@jhaynie jhaynie merged commit 14ea5dd into main Feb 5, 2026
15 checks passed
@jhaynie jhaynie deleted the task/improve-sdk-prompting branch February 5, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant