From 8a9c2ced4de7e037315f62f500dce4adde84abaa Mon Sep 17 00:00:00 2001 From: A Ibrahim Date: Thu, 23 Apr 2026 10:13:47 +0200 Subject: [PATCH 1/2] feat: add forcePathStyle config option, default to true All SDK calls use path-style URLs (endpoint/bucket/key) by default. Bump @tigrisdata/storage to ^3.2.0, playground to ^0.5.1. Co-Authored-By: Claude Opus 4.6 (1M context) --- package-lock.json | 11 ++++++----- package.json | 2 +- playground/package-lock.json | 9 +++++---- playground/package.json | 2 +- src/repl/session.ts | 3 +++ src/types.ts | 7 +++++++ 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index b1bfa6c..5168995 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,11 +9,12 @@ "version": "0.0.2", "license": "MIT", "dependencies": { - "@tigrisdata/storage": "^3.1.1", + "@tigrisdata/storage": "^3.2.0", "just-bash": "^2.14.2" }, "bin": { - "tigris-shell": "dist/cli.js" + "agent-shell": "dist/cli.js", + "tigris-agent-shell": "dist/cli.js" }, "devDependencies": { "@biomejs/biome": "^2.4.12", @@ -3146,9 +3147,9 @@ "license": "MIT" }, "node_modules/@tigrisdata/storage": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/@tigrisdata/storage/-/storage-3.1.1.tgz", - "integrity": "sha512-btUuSpR5IAs+7j1bxikSSRkdeOvLNG/MrIOCHsyGrSJBb4Xe8SFFMb7SFf4ImbpngVMib5KKMLDQi2nF7m3F6Q==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@tigrisdata/storage/-/storage-3.2.0.tgz", + "integrity": "sha512-sDBloJ+LrHA5+Ni3h545BFv+ZLwbxUvi9q1J6aoaFZEJwLX//RS9JFI5P5J3CT+A7rh8DM5LGj59E1iu5vdfqg==", "license": "MIT", "dependencies": { "@aws-crypto/sha256-js": "^5.2.0", diff --git a/package.json b/package.json index 0d48769..3c5c9a8 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "node": ">=20.0.0" }, "dependencies": { - "@tigrisdata/storage": "^3.1.1", + "@tigrisdata/storage": "^3.2.0", "just-bash": "^2.14.2" }, "release": { diff --git a/playground/package-lock.json b/playground/package-lock.json index 7d590e7..18aacf8 100644 --- a/playground/package-lock.json +++ b/playground/package-lock.json @@ -7,7 +7,7 @@ "name": "agent-shell-playground", "dependencies": { "@auth0/auth0-spa-js": "^2.19.2", - "@tigrisdata/agent-shell": "^0.5.0", + "@tigrisdata/agent-shell": "^0.5.1", "@xterm/addon-fit": "^0.11.0", "@xterm/xterm": "^6.0.0" }, @@ -2134,15 +2134,16 @@ } }, "node_modules/@tigrisdata/agent-shell": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/@tigrisdata/agent-shell/-/agent-shell-0.5.0.tgz", - "integrity": "sha512-wgTO0RiQR0xCFcebUTK5YUT9krU0Qov1p27ysvQSvW6lKxYxQwwuQmqs4qTZnxdnv3JBHqUO0OK3lBAqJREIhA==", + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/@tigrisdata/agent-shell/-/agent-shell-0.5.1.tgz", + "integrity": "sha512-lGMNR9tS3QrbZLuqHVjCadcobB9Ct+BHvaP97Idyn3FPxy3c6MXhA1/glXEaZ3QaawZJNM4Hj7ImI32Tz++Puw==", "license": "MIT", "dependencies": { "@tigrisdata/storage": "^3.1.1", "just-bash": "^2.14.2" }, "bin": { + "agent-shell": "dist/cli.js", "tigris-agent-shell": "dist/cli.js" }, "engines": { diff --git a/playground/package.json b/playground/package.json index 2480148..4c831cc 100644 --- a/playground/package.json +++ b/playground/package.json @@ -9,7 +9,7 @@ }, "dependencies": { "@auth0/auth0-spa-js": "^2.19.2", - "@tigrisdata/agent-shell": "^0.5.0", + "@tigrisdata/agent-shell": "^0.5.1", "@xterm/addon-fit": "^0.11.0", "@xterm/xterm": "^6.0.0" }, diff --git a/src/repl/session.ts b/src/repl/session.ts index d641806..626bb3b 100644 --- a/src/repl/session.ts +++ b/src/repl/session.ts @@ -121,6 +121,9 @@ export class ReplSession { authMethod: "access-key" | "oauth", io: ReplIO, ): Promise { + if (newConfig.forcePathStyle === undefined) { + newConfig.forcePathStyle = true; + } const bucketsResult = await listBuckets({ config: newConfig }); if ("error" in bucketsResult) { const newShell = new TigrisShell(newConfig); diff --git a/src/types.ts b/src/types.ts index d80b47a..ef95bad 100644 --- a/src/types.ts +++ b/src/types.ts @@ -19,6 +19,8 @@ export interface TigrisConfig { bucket?: string; /** Tigris endpoint. Defaults to https://t3.storage.dev */ endpoint?: string; + /** Use path-style URLs (endpoint/bucket/key) instead of virtual-hosted (bucket.endpoint/key). */ + forcePathStyle?: boolean; } /** @@ -44,4 +46,9 @@ export function validateConfig(config: TigrisConfig): void { "TigrisConfig requires either (accessKeyId + secretAccessKey) or (sessionToken + organizationId)", ); } + + // Default to path-style URLs + if (config.forcePathStyle === undefined) { + config.forcePathStyle = true; + } } From efcd1045b50e52029505f89fec7320f4f4c73649 Mon Sep 17 00:00:00 2001 From: A Ibrahim Date: Thu, 23 Apr 2026 10:52:20 +0200 Subject: [PATCH 2/2] refactor: use pure withConfigDefaults instead of mutating Replace applyConfigDefaults with withConfigDefaults that returns a new config object instead of mutating the input. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/repl/session.ts | 8 +++----- src/shell.ts | 17 +++++++++-------- src/types.ts | 13 ++++++++----- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/repl/session.ts b/src/repl/session.ts index 626bb3b..4a62c99 100644 --- a/src/repl/session.ts +++ b/src/repl/session.ts @@ -1,7 +1,7 @@ import { listBuckets } from "@tigrisdata/storage"; import type { BashExecResult } from "just-bash"; import { TigrisShell } from "../shell.js"; -import type { TigrisConfig } from "../types.js"; +import { type TigrisConfig, withConfigDefaults } from "../types.js"; import type { LoginFn } from "./auth.js"; import type { ReplIO } from "./io.js"; @@ -121,10 +121,8 @@ export class ReplSession { authMethod: "access-key" | "oauth", io: ReplIO, ): Promise { - if (newConfig.forcePathStyle === undefined) { - newConfig.forcePathStyle = true; - } - const bucketsResult = await listBuckets({ config: newConfig }); + const config = withConfigDefaults(newConfig); + const bucketsResult = await listBuckets({ config }); if ("error" in bucketsResult) { const newShell = new TigrisShell(newConfig); this.commitSession(newConfig, newShell, authMethod); diff --git a/src/shell.ts b/src/shell.ts index ec34549..5e29b21 100644 --- a/src/shell.ts +++ b/src/shell.ts @@ -5,7 +5,7 @@ import { createPresignCommand } from "./commands/presign.js"; import { createSnapshotCommand } from "./commands/snapshot.js"; import { TigrisAdapter } from "./fs/tigris-adapter.js"; import type { ShellOptions, TigrisConfig } from "./types.js"; -import { validateConfig } from "./types.js"; +import { validateConfig, withConfigDefaults } from "./types.js"; interface MountEntry { bucket: string; @@ -30,15 +30,16 @@ export class TigrisShell { constructor(config: TigrisConfig, shellOptions?: ShellOptions) { validateConfig(config); - this.tigrisConfig = config; + const resolvedConfig = withConfigDefaults(config); + this.tigrisConfig = resolvedConfig; this.mountableFs = new MountableFs({ base: new InMemoryFs() }); const cwd = shellOptions?.cwd ?? "/workspace"; // Auto-mount if bucket is provided - if (config.bucket) { - this.mount(config.bucket, cwd); + if (resolvedConfig.bucket) { + this.mount(resolvedConfig.bucket, cwd); } this.bash = new Bash({ @@ -46,12 +47,12 @@ export class TigrisShell { cwd, ...(shellOptions?.env !== undefined && { env: shellOptions.env }), customCommands: [ - createPresignCommand(config, { + createPresignCommand(resolvedConfig, { resolveBucket: (path) => this.resolveBucketForPath(path), }), - createSnapshotCommand(config), - createForkCommand(config), - createForksListCommand(config), + createSnapshotCommand(resolvedConfig), + createForkCommand(resolvedConfig), + createForksListCommand(resolvedConfig), ], }); } diff --git a/src/types.ts b/src/types.ts index ef95bad..d06899a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -33,6 +33,14 @@ export interface ShellOptions { env?: Record; } +/** Return a new config with defaults applied. */ +export function withConfigDefaults(config: TigrisConfig): TigrisConfig { + return { + forcePathStyle: true, + ...config, + }; +} + /** * Validates that TigrisConfig has at least one auth mode. * Throws if neither access key nor session token auth is provided. @@ -46,9 +54,4 @@ export function validateConfig(config: TigrisConfig): void { "TigrisConfig requires either (accessKeyId + secretAccessKey) or (sessionToken + organizationId)", ); } - - // Default to path-style URLs - if (config.forcePathStyle === undefined) { - config.forcePathStyle = true; - } }