@standardagents/builder 0.17.1 → 0.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/plugin.js CHANGED
@@ -7205,8 +7205,9 @@ import { isThreadEndpoint } from "@standardagents/spec";
7205
7205
  const PUBLIC_ROUTES = [
7206
7206
  '/api/auth/bootstrap',
7207
7207
  '/api/auth/login',
7208
- '/api/auth/bootstrap',
7209
7208
  '/api/auth/config',
7209
+ '/api/auth/sa/start', // Login with Standard Agents (OAuth) \u2014 unauthenticated entry
7210
+ '/api/auth/sa/callback', // OAuth callback (sets the session cookie)
7210
7211
  '/api/config',
7211
7212
  '/api/auth/oauth/github',
7212
7213
  '/api/auth/oauth/google',
@@ -7219,15 +7220,31 @@ const PUBLIC_ROUTES = [
7219
7220
  '/api/hooks' // Hook metadata is safe to expose publicly
7220
7221
  ];
7221
7222
 
7223
+ // True when the platform deployed this instance (injects STANDARD_AGENTS_HOSTED).
7224
+ // Hosted instances are internet-reachable and multi-tenant, so the thread data
7225
+ // API and event/stream WebSockets must NOT be anonymously public the way they
7226
+ // are in single-user local dev \u2014 they require a session (admin) or API key (SDK).
7227
+ function isHostedInstance(env) {
7228
+ const value = env && env.STANDARD_AGENTS_HOSTED;
7229
+ if (typeof value === 'string') {
7230
+ const trimmed = value.trim().toLowerCase();
7231
+ return trimmed !== '' && trimmed !== '0' && trimmed !== 'false';
7232
+ }
7233
+ return Boolean(value);
7234
+ }
7235
+
7222
7236
  // Check if a route is public (no auth required)
7223
- function isPublicRoute(routePath) {
7237
+ function isPublicRoute(routePath, hosted) {
7224
7238
  // Exact match for auth routes
7225
7239
  if (PUBLIC_ROUTES.includes(routePath)) {
7226
7240
  return true;
7227
7241
  }
7228
7242
 
7229
- // Thread routes are always public
7230
- if (routePath.startsWith('/api/threads/') || routePath === '/api/threads') {
7243
+ // Thread routes (REST + message/log stream WebSockets) are public in local
7244
+ // single-user dev, but on a hosted deployment they require auth \u2014 requireAuth
7245
+ // accepts the admin's session (cookie or token) or the SDK's API key, so this
7246
+ // only blocks anonymous access to another tenant's threads/messages/files.
7247
+ if (!hosted && (routePath.startsWith('/api/threads/') || routePath === '/api/threads')) {
7231
7248
  return true;
7232
7249
  }
7233
7250
 
@@ -7329,7 +7346,7 @@ ${packedThreadRouteCode}
7329
7346
 
7330
7347
  if (routeMatch) {
7331
7348
  // Check if authentication is required for this route
7332
- const publicRoute = isPublicRoute(routePath);
7349
+ const publicRoute = isPublicRoute(routePath, isHostedInstance(env));
7333
7350
  const isApiRoute = routePath.startsWith('/api/');
7334
7351
 
7335
7352
  let authContext = null;