@standardagents/builder 0.15.3 → 0.16.1-next.1e58032

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.
Files changed (38) hide show
  1. package/dist/built-in-routes.js +479 -412
  2. package/dist/built-in-routes.js.map +1 -1
  3. package/dist/client/ApiKeysView.js +1 -1
  4. package/dist/client/CenteredContentView.js +1 -1
  5. package/dist/client/CompositionView.js +1 -1
  6. package/dist/client/ConfirmDialog.vue_vue_type_script_setup_true_lang.js +1 -1
  7. package/dist/client/CopyButton.vue_vue_type_script_setup_true_lang.js +1 -1
  8. package/dist/client/DataTable.vue_vue_type_script_setup_true_lang.js +1 -1
  9. package/dist/client/JsonViewer.js +1 -1
  10. package/dist/client/LoginView.js +1 -1
  11. package/dist/client/Modal.vue_vue_type_script_setup_true_lang.js +1 -1
  12. package/dist/client/ModelModal.vue_vue_type_script_setup_true_lang.js +1 -1
  13. package/dist/client/ModelsView.js +1 -1
  14. package/dist/client/PromptEditView.js +1 -1
  15. package/dist/client/PromptModal.js +1 -1
  16. package/dist/client/PromptsView.js +1 -1
  17. package/dist/client/ProvidersView.js +2 -2
  18. package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang.js +1 -1
  19. package/dist/client/ToolsView.js +1 -1
  20. package/dist/client/UsersView.js +1 -1
  21. package/dist/client/VariablesView.js +1 -1
  22. package/dist/client/assets/index.css +1 -1
  23. package/dist/client/index.js +3 -3
  24. package/dist/{discovery-DVviz3By.d.ts → discovery-DiMJWisl.d.ts} +1 -1
  25. package/dist/{index-BwqQtJ4r.d.ts → index-BnrKzXpJ.d.ts} +4 -5
  26. package/dist/index.d.ts +116 -3402
  27. package/dist/index.js +212 -345
  28. package/dist/index.js.map +1 -1
  29. package/dist/packing.d.ts +3 -3
  30. package/dist/plugin.d.ts +5 -4
  31. package/dist/plugin.js +143 -78
  32. package/dist/plugin.js.map +1 -1
  33. package/dist/runtime.d.ts +3127 -0
  34. package/dist/runtime.js +21219 -0
  35. package/dist/runtime.js.map +1 -0
  36. package/dist/test.d.ts +2 -2
  37. package/dist/{types-DH3Egc5l.d.ts → types-Bpe7IANZ.d.ts} +1 -1
  38. package/package.json +10 -9
@@ -4,10 +4,10 @@ import * as z7 from 'zod/v4/core';
4
4
  import * as z128 from 'zod/v4';
5
5
  import { z as z$1 } from 'zod/v4';
6
6
  import z179, { ZodFirstPartyTypeKind } from 'zod/v3';
7
- import * as fs2 from 'fs';
8
- import fs2__default from 'fs';
9
- import * as path4 from 'path';
10
- import path4__default from 'path';
7
+ import * as fs3 from 'fs';
8
+ import fs3__default from 'fs';
9
+ import * as path5 from 'path';
10
+ import path5__default from 'path';
11
11
  import MagicString from 'magic-string';
12
12
  import { exec } from 'child_process';
13
13
  import { promisify } from 'util';
@@ -874,11 +874,38 @@ var init_TestProvider = __esm({
874
874
  }
875
875
  });
876
876
 
877
+ // src/agents/providers/platform-routing.ts
878
+ function stringEnv(value) {
879
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
880
+ }
881
+ function resolvePlatformRouting(providerName, env2) {
882
+ const apiKey = stringEnv(env2.STANDARD_AGENTS_API_KEY) ?? stringEnv(env2.PLATFORM_API_KEY);
883
+ if (!apiKey) return null;
884
+ const origin = (stringEnv(env2.STANDARD_AGENTS_PROXY_URL) ?? stringEnv(env2.PLATFORM_ENDPOINT) ?? stringEnv(env2.STANDARD_AGENTS_API_URL) ?? DEFAULT_PLATFORM_PROXY_ORIGIN).replace(/\/+$/, "");
885
+ const provider = providerName.toLowerCase();
886
+ const basePath = PROVIDER_BASE_PATHS[provider] ?? "";
887
+ return {
888
+ apiKey,
889
+ origin,
890
+ baseUrl: `${origin}/v1/proxy/${encodeURIComponent(provider)}${basePath}`
891
+ };
892
+ }
893
+ var DEFAULT_PLATFORM_PROXY_ORIGIN, PROVIDER_BASE_PATHS;
894
+ var init_platform_routing = __esm({
895
+ "src/agents/providers/platform-routing.ts"() {
896
+ DEFAULT_PLATFORM_PROXY_ORIGIN = "https://proxy.standardagents.ai";
897
+ PROVIDER_BASE_PATHS = {
898
+ cloudflare: "/ai/v1"
899
+ };
900
+ }
901
+ });
902
+
877
903
  // src/agents/providers/ProviderRegistry.ts
878
904
  var ProviderRegistryImpl, ProviderRegistry;
879
905
  var init_ProviderRegistry = __esm({
880
906
  "src/agents/providers/ProviderRegistry.ts"() {
881
907
  init_TestProvider();
908
+ init_platform_routing();
882
909
  ProviderRegistryImpl = class {
883
910
  providerCache = /* @__PURE__ */ new Map();
884
911
  providerOverrideFn = null;
@@ -916,9 +943,9 @@ var init_ProviderRegistry = __esm({
916
943
  const fingerprint = this.getProviderFingerprint(providerName, modelDef);
917
944
  const cached = this.providerCache.get(modelName);
918
945
  if (cached?.fingerprint === fingerprint) {
919
- return this.buildResult(cached.provider, modelDef);
946
+ return this.buildResult(cached.provider, modelDef, false);
920
947
  }
921
- return this.cacheAndReturn(modelName, createTestProvider(), modelDef, fingerprint);
948
+ return this.cacheAndReturn(modelName, createTestProvider(), modelDef, fingerprint, false);
922
949
  }
923
950
  const apiKey = this.getApiKeyForProvider(providerName, env2);
924
951
  if (apiKey) {
@@ -935,34 +962,47 @@ var init_ProviderRegistry = __esm({
935
962
  const fingerprint = this.getProviderFingerprint(providerName, modelDef, config);
936
963
  const cached = this.providerCache.get(modelName);
937
964
  if (cached?.fingerprint === fingerprint) {
938
- return this.buildResult(cached.provider, modelDef);
965
+ return this.buildResult(cached.provider, modelDef, false);
939
966
  }
940
- return this.cacheAndReturn(modelName, providerFactory(config), modelDef, fingerprint);
967
+ return this.cacheAndReturn(modelName, providerFactory(config), modelDef, fingerprint, false);
941
968
  }
942
969
  if (this.providerOverrideFn) {
943
970
  const overrideFingerprint = this.getProviderFingerprint(`override:${this.providerOverrideRevision}`, modelDef);
944
971
  const overrideCached = this.providerCache.get(modelName);
945
972
  if (overrideCached?.fingerprint === overrideFingerprint) {
946
- return this.buildResult(overrideCached.provider, modelDef);
973
+ return this.buildResult(overrideCached.provider, modelDef, true);
947
974
  }
948
975
  const overrideProvider = this.providerOverrideFn(modelName, modelDef, env2);
949
976
  if (overrideProvider) {
950
- return this.cacheAndReturn(modelName, overrideProvider, modelDef, overrideFingerprint);
977
+ return this.cacheAndReturn(modelName, overrideProvider, modelDef, overrideFingerprint, true);
978
+ }
979
+ }
980
+ const routing = resolvePlatformRouting(providerName, env2);
981
+ if (routing) {
982
+ const config = {
983
+ apiKey: routing.apiKey,
984
+ baseUrl: routing.baseUrl
985
+ };
986
+ const fingerprint = this.getProviderFingerprint(`platform:${providerName}`, modelDef, config);
987
+ const cached = this.providerCache.get(modelName);
988
+ if (cached?.fingerprint === fingerprint) {
989
+ return this.buildResult(cached.provider, modelDef, true);
951
990
  }
991
+ return this.cacheAndReturn(modelName, providerFactory(config), modelDef, fingerprint, true);
952
992
  }
953
993
  throw new Error(`No API key found for provider: ${providerName}. Set the provider key or STANDARD_AGENTS_API_KEY.`);
954
994
  }
955
- buildResult(provider, modelDef) {
956
- return { provider, modelName: modelDef.model, modelDef };
995
+ buildResult(provider, modelDef, viaPlatform) {
996
+ return { provider, modelName: modelDef.model, modelDef, viaPlatform };
957
997
  }
958
- cacheAndReturn(modelName, provider, modelDef, fingerprint) {
959
- this.providerCache.set(modelName, { provider, fingerprint });
960
- return this.buildResult(provider, modelDef);
998
+ cacheAndReturn(modelName, provider, modelDef, fingerprint, viaPlatform) {
999
+ this.providerCache.set(modelName, { provider, fingerprint, viaPlatform });
1000
+ return this.buildResult(provider, modelDef, viaPlatform);
961
1001
  }
962
1002
  getProviderFingerprint(providerName, modelDef, config) {
963
1003
  return JSON.stringify({
964
1004
  providerName,
965
- baseUrl: modelDef.providerOptions?.baseUrl ?? null,
1005
+ baseUrl: config?.baseUrl ?? modelDef.providerOptions?.baseUrl ?? null,
966
1006
  apiKey: config?.apiKey ?? null,
967
1007
  accountId: config?.accountId ?? null
968
1008
  });
@@ -1638,7 +1678,7 @@ var init_LLMRequest = __esm({
1638
1678
  */
1639
1679
  static async callModel(modelId, context, state, logId) {
1640
1680
  const { ProviderRegistry: ProviderRegistry2 } = await Promise.resolve().then(() => (init_providers(), providers_exports));
1641
- const { provider, modelName, modelDef } = await ProviderRegistry2.getProvider(
1681
+ const { provider, modelName, modelDef, viaPlatform } = await ProviderRegistry2.getProvider(
1642
1682
  modelId,
1643
1683
  state.env,
1644
1684
  state.thread.instance
@@ -1772,6 +1812,7 @@ var init_LLMRequest = __esm({
1772
1812
  }
1773
1813
  };
1774
1814
  response._provider = provider;
1815
+ response._viaPlatform = viaPlatform;
1775
1816
  response._providerResponseId = providerResponseId;
1776
1817
  response._aggregate_response = {
1777
1818
  id: responseId,
@@ -1849,7 +1890,7 @@ var init_LLMRequest = __esm({
1849
1890
  try {
1850
1891
  const toolsCalled = response.tool_calls ? JSON.stringify(response.tool_calls.map((tc) => tc.function.name)) : null;
1851
1892
  const providerName = response._provider?.name;
1852
- const standardAgentsRouterUsed = providerName === "platform";
1893
+ const standardAgentsRouterUsed = response._viaPlatform === true || providerName === "platform";
1853
1894
  const resolvedPricing = resolveModelPricing(modelDef, providerName);
1854
1895
  const calculatedCost = calculateUsageCost(response.usage, resolvedPricing);
1855
1896
  const providerReportedCost = typeof response.usage.cost === "number" ? response.usage.cost : typeof response.usage.cost === "string" ? parseFloat(response.usage.cost) : null;
@@ -5861,7 +5902,7 @@ var init_FlowEngine = __esm({
5861
5902
  max_session_turns: newAgentDef.maxSessionTurns ?? null,
5862
5903
  side_a_label: newAgentDef.sideA?.label ?? null,
5863
5904
  side_a_agent_prompt: newAgentDef.sideA?.prompt ?? null,
5864
- side_a_stop_on_response: newAgentDef.sideA?.stopOnResponse ?? false,
5905
+ side_a_stop_on_response: newAgentDef.sideA?.stopOnResponse ?? true,
5865
5906
  side_a_stop_tool: newAgentDef.sideA?.stopTool ?? null,
5866
5907
  side_a_stop_tool_response_property: newAgentDef.sideA?.stopToolResponseProperty ?? null,
5867
5908
  side_a_max_steps: newAgentDef.sideA?.maxSteps ?? null,
@@ -5876,7 +5917,7 @@ var init_FlowEngine = __esm({
5876
5917
  side_a_session_status_attachments_property: sideASession.status.attachmentsProperty,
5877
5918
  side_b_label: newAgentDef.sideB?.label ?? null,
5878
5919
  side_b_agent_prompt: newAgentDef.sideB?.prompt ?? null,
5879
- side_b_stop_on_response: newAgentDef.sideB?.stopOnResponse ?? false,
5920
+ side_b_stop_on_response: newAgentDef.sideB?.stopOnResponse ?? true,
5880
5921
  side_b_stop_tool: newAgentDef.sideB?.stopTool ?? null,
5881
5922
  side_b_stop_tool_response_property: newAgentDef.sideB?.stopToolResponseProperty ?? null,
5882
5923
  side_b_max_steps: newAgentDef.sideB?.maxSteps ?? null,
@@ -9189,7 +9230,7 @@ function runCodeInDynamicWorker(params) {
9189
9230
  durationMs: Date.now() - startedAt,
9190
9231
  error: {
9191
9232
  name: "MissingWorkerLoader",
9192
- message: `ThreadState.runCode requires the ${WORKER_LOADER_BINDING} Worker Loader binding. Run the AgentBuilder scaffold/init step or add worker_loaders to wrangler config.`
9233
+ message: `ThreadState.runCode requires the ${WORKER_LOADER_BINDING} Worker Loader binding. Run the AgentBuilder scaffold/init step or use builder(), which injects the worker_loaders binding.`
9193
9234
  }
9194
9235
  };
9195
9236
  }
@@ -12783,6 +12824,9 @@ var init_CloudflareProvider = __esm({
12783
12824
  if (accountScopedMatch) {
12784
12825
  return `${accountScopedMatch[1]}/ai/models/search`;
12785
12826
  }
12827
+ if (baseUrl.endsWith("/ai/v1")) {
12828
+ return `${baseUrl.slice(0, -"/ai/v1".length)}/ai/models/search`;
12829
+ }
12786
12830
  throw new ProviderError(
12787
12831
  "Cloudflare model discovery requires CLOUDFLARE_ACCOUNT_ID or an account-scoped baseUrl.",
12788
12832
  "invalid_request"
@@ -24892,7 +24936,7 @@ async function getBlobStat(file) {
24892
24936
  function sleep(ms) {
24893
24937
  return new Promise((resolvePromise) => setTimeout(resolvePromise, ms));
24894
24938
  }
24895
- var import_p_retry, _defaultBaseGeminiUrl, _defaultBaseVertexUrl, BaseModule, Language, Outcome, FunctionResponseScheduling, Type, Environment, AuthType, HttpElementLocation, ApiSpec, PhishBlockThreshold, Behavior, DynamicRetrievalConfigMode, FunctionCallingConfigMode, ThinkingLevel, PersonGeneration, ProminentPeople, HarmCategory, HarmBlockMethod, HarmBlockThreshold, FinishReason, HarmProbability, HarmSeverity, UrlRetrievalStatus, BlockedReason, TrafficType, Modality, ModelStage, MediaResolution, TuningMode, AdapterSize, JobState, TuningJobState, AggregationMetric, PairwiseChoice, TuningTask, DocumentState, PartMediaResolutionLevel, ToolType, ResourceScope, ServiceTier, FeatureSelectionPreference, EmbeddingApiType, SafetyFilterLevel, ImagePromptLanguage, MaskReferenceMode, ControlReferenceType, SubjectReferenceType, EditMode, SegmentMode, VideoGenerationReferenceType, VideoGenerationMaskMode, VideoCompressionQuality, TuningMethod, FileState, FileSource, TurnCompleteReason, MediaModality, VadSignalType, VoiceActivityType, StartSensitivity, EndSensitivity, ActivityHandling, TurnCoverage, Scale, MusicGenerationMode, LiveMusicPlaybackControl, HttpResponse, GenerateContentResponse, EmbedContentResponse, GenerateImagesResponse, EditImageResponse, UpscaleImageResponse, RecontextImageResponse, SegmentImageResponse, ListModelsResponse, DeleteModelResponse, CountTokensResponse, ComputeTokensResponse, GenerateVideosOperation, ListTuningJobsResponse, CancelTuningJobResponse, DeleteCachedContentResponse, ListCachedContentsResponse, ListDocumentsResponse, ListFileSearchStoresResponse, UploadToFileSearchStoreResumableResponse, ImportFileOperation, ListFilesResponse, CreateFileResponse, DeleteFileResponse, RegisterFilesResponse, ListBatchJobsResponse, RawReferenceImage, LiveServerMessage, LiveMusicServerMessage, UploadToFileSearchStoreOperation, PagedItem, Pager, Batches, Caches, Chats, Chat, ApiError, Files, CONTENT_TYPE_HEADER, SERVER_TIMEOUT_HEADER, USER_AGENT_HEADER, GOOGLE_API_CLIENT_HEADER, SDK_VERSION, LIBRARY_LABEL, VERTEX_AI_API_DEFAULT_VERSION, GOOGLE_AI_API_DEFAULT_VERSION, DEFAULT_RETRY_ATTEMPTS, DEFAULT_RETRY_HTTP_STATUS_CODES, ApiClient, MCP_LABEL, hasMcpToolUsageFromMcpToTool, McpCallableTool, LiveMusic, LiveMusicSession, FUNCTION_RESPONSE_REQUIRES_ID, Live, defaultLiveSendClientContentParamerters, Session, DEFAULT_MAX_REMOTE_CALLS, Models, Operations, Tokens, Documents, FileSearchStores, uuid4Internal, uuid4, castToError, GeminiNextGenAPIClientError, APIError, APIUserAbortError, APIConnectionError, APIConnectionTimeoutError, BadRequestError, AuthenticationError, PermissionDeniedError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, startsWithSchemeRegexp, isAbsoluteURL, isArrayInternal, isArray, isReadonlyArrayInternal, isReadonlyArray, validatePositiveInteger, safeJSON, sleep$1, FallbackEncoder, VERSION, checkFileSupport, isAsyncIterable, isBlobLike, isFileLike, isResponseLike, APIResource, EMPTY, createPathTagFunction, path, BaseInteractions, Interactions, encodeUTF8_, decodeUTF8_, LineDecoder, levelNumbers, parseLogLevel, noopLogger, cachedLoggers, formatRequestDetails, Stream, SSEDecoder, APIPromise, brand_privateNullableHeaders, buildHeaders, readEnv, _a, BaseGeminiNextGenAPIClient, GeminiNextGenAPIClient, Tunings, BrowserDownloader, MAX_CHUNK_SIZE, MAX_RETRY_COUNT, INITIAL_RETRY_DELAY_MS, DELAY_MULTIPLIER, X_GOOG_UPLOAD_STATUS_HEADER_FIELD, BrowserUploader, BrowserWebSocketFactory, BrowserWebSocket, GOOGLE_API_KEY_HEADER, WebAuth, LANGUAGE_LABEL_PREFIX, GoogleGenAI;
24939
+ var import_p_retry, _defaultBaseGeminiUrl, _defaultBaseVertexUrl, BaseModule, Language, Outcome, FunctionResponseScheduling, Type, Environment, AuthType, HttpElementLocation, ApiSpec, PhishBlockThreshold, Behavior, DynamicRetrievalConfigMode, FunctionCallingConfigMode, ThinkingLevel, PersonGeneration, ProminentPeople, HarmCategory, HarmBlockMethod, HarmBlockThreshold, FinishReason, HarmProbability, HarmSeverity, UrlRetrievalStatus, BlockedReason, TrafficType, Modality, ModelStage, MediaResolution, TuningMode, AdapterSize, JobState, TuningJobState, AggregationMetric, PairwiseChoice, TuningTask, DocumentState, PartMediaResolutionLevel, ToolType, ResourceScope, ServiceTier, FeatureSelectionPreference, EmbeddingApiType, SafetyFilterLevel, ImagePromptLanguage, MaskReferenceMode, ControlReferenceType, SubjectReferenceType, EditMode, SegmentMode, VideoGenerationReferenceType, VideoGenerationMaskMode, VideoCompressionQuality, TuningMethod, FileState, FileSource, TurnCompleteReason, MediaModality, VadSignalType, VoiceActivityType, StartSensitivity, EndSensitivity, ActivityHandling, TurnCoverage, Scale, MusicGenerationMode, LiveMusicPlaybackControl, HttpResponse, GenerateContentResponse, EmbedContentResponse, GenerateImagesResponse, EditImageResponse, UpscaleImageResponse, RecontextImageResponse, SegmentImageResponse, ListModelsResponse, DeleteModelResponse, CountTokensResponse, ComputeTokensResponse, GenerateVideosOperation, ListTuningJobsResponse, CancelTuningJobResponse, DeleteCachedContentResponse, ListCachedContentsResponse, ListDocumentsResponse, ListFileSearchStoresResponse, UploadToFileSearchStoreResumableResponse, ImportFileOperation, ListFilesResponse, CreateFileResponse, DeleteFileResponse, RegisterFilesResponse, ListBatchJobsResponse, RawReferenceImage, LiveServerMessage, LiveMusicServerMessage, UploadToFileSearchStoreOperation, PagedItem, Pager, Batches, Caches, Chats, Chat, ApiError, Files, CONTENT_TYPE_HEADER, SERVER_TIMEOUT_HEADER, USER_AGENT_HEADER, GOOGLE_API_CLIENT_HEADER, SDK_VERSION, LIBRARY_LABEL, VERTEX_AI_API_DEFAULT_VERSION, GOOGLE_AI_API_DEFAULT_VERSION, DEFAULT_RETRY_ATTEMPTS, DEFAULT_RETRY_HTTP_STATUS_CODES, ApiClient, MCP_LABEL, hasMcpToolUsageFromMcpToTool, McpCallableTool, LiveMusic, LiveMusicSession, FUNCTION_RESPONSE_REQUIRES_ID, Live, defaultLiveSendClientContentParamerters, Session, DEFAULT_MAX_REMOTE_CALLS, Models, Operations, Tokens, Documents, FileSearchStores, uuid4Internal, uuid4, castToError, GeminiNextGenAPIClientError, APIError, APIUserAbortError, APIConnectionError, APIConnectionTimeoutError, BadRequestError, AuthenticationError, PermissionDeniedError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, startsWithSchemeRegexp, isAbsoluteURL, isArrayInternal, isArray, isReadonlyArrayInternal, isReadonlyArray, validatePositiveInteger, safeJSON, sleep$1, FallbackEncoder, VERSION, checkFileSupport, isAsyncIterable, isBlobLike, isFileLike, isResponseLike, APIResource, EMPTY, createPathTagFunction, path2, BaseInteractions, Interactions, encodeUTF8_, decodeUTF8_, LineDecoder, levelNumbers, parseLogLevel, noopLogger, cachedLoggers, formatRequestDetails, Stream, SSEDecoder, APIPromise, brand_privateNullableHeaders, buildHeaders, readEnv, _a, BaseGeminiNextGenAPIClient, GeminiNextGenAPIClient, Tunings, BrowserDownloader, MAX_CHUNK_SIZE, MAX_RETRY_COUNT, INITIAL_RETRY_DELAY_MS, DELAY_MULTIPLIER, X_GOOG_UPLOAD_STATUS_HEADER_FIELD, BrowserUploader, BrowserWebSocketFactory, BrowserWebSocket, GOOGLE_API_KEY_HEADER, WebAuth, LANGUAGE_LABEL_PREFIX, GoogleGenAI;
24896
24940
  var init_web = __esm({
24897
24941
  "../../node_modules/.pnpm/@google+genai@1.47.0/node_modules/@google/genai/dist/web/index.mjs"() {
24898
24942
  import_p_retry = __toESM(require_p_retry());
@@ -30434,7 +30478,7 @@ ${underline}`);
30434
30478
  }
30435
30479
  return path10;
30436
30480
  });
30437
- path = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
30481
+ path2 = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
30438
30482
  BaseInteractions = class extends APIResource {
30439
30483
  create(params, options) {
30440
30484
  var _a16;
@@ -30445,7 +30489,7 @@ ${underline}`);
30445
30489
  if ("agent" in body && "generation_config" in body) {
30446
30490
  throw new GeminiNextGenAPIClientError(`Invalid request: specified \`agent\` and \`generation_config\`. If specifying \`agent\`, use \`agent_config\`.`);
30447
30491
  }
30448
- return this._client.post(path`/${api_version}/interactions`, Object.assign(Object.assign({ body }, options), { stream: (_a16 = params.stream) !== null && _a16 !== void 0 ? _a16 : false }));
30492
+ return this._client.post(path2`/${api_version}/interactions`, Object.assign(Object.assign({ body }, options), { stream: (_a16 = params.stream) !== null && _a16 !== void 0 ? _a16 : false }));
30449
30493
  }
30450
30494
  /**
30451
30495
  * Deletes the interaction by id.
@@ -30459,7 +30503,7 @@ ${underline}`);
30459
30503
  */
30460
30504
  delete(id, params = {}, options) {
30461
30505
  const { api_version = this._client.apiVersion } = params !== null && params !== void 0 ? params : {};
30462
- return this._client.delete(path`/${api_version}/interactions/${id}`, options);
30506
+ return this._client.delete(path2`/${api_version}/interactions/${id}`, options);
30463
30507
  }
30464
30508
  /**
30465
30509
  * Cancels an interaction by id. This only applies to background interactions that are still running.
@@ -30473,12 +30517,12 @@ ${underline}`);
30473
30517
  */
30474
30518
  cancel(id, params = {}, options) {
30475
30519
  const { api_version = this._client.apiVersion } = params !== null && params !== void 0 ? params : {};
30476
- return this._client.post(path`/${api_version}/interactions/${id}/cancel`, options);
30520
+ return this._client.post(path2`/${api_version}/interactions/${id}/cancel`, options);
30477
30521
  }
30478
30522
  get(id, params = {}, options) {
30479
30523
  var _a16;
30480
30524
  const _b16 = params !== null && params !== void 0 ? params : {}, { api_version = this._client.apiVersion } = _b16, query = __rest(_b16, ["api_version"]);
30481
- return this._client.get(path`/${api_version}/interactions/${id}`, Object.assign(Object.assign({ query }, options), { stream: (_a16 = params === null || params === void 0 ? void 0 : params.stream) !== null && _a16 !== void 0 ? _a16 : false }));
30525
+ return this._client.get(path2`/${api_version}/interactions/${id}`, Object.assign(Object.assign({ query }, options), { stream: (_a16 = params === null || params === void 0 ? void 0 : params.stream) !== null && _a16 !== void 0 ? _a16 : false }));
30482
30526
  }
30483
30527
  };
30484
30528
  BaseInteractions._key = Object.freeze(["interactions"]);
@@ -33811,7 +33855,7 @@ var init_audio = __esm({
33811
33855
  function encodeURIPath2(str) {
33812
33856
  return str.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
33813
33857
  }
33814
- var EMPTY2, createPathTagFunction2, path2;
33858
+ var EMPTY2, createPathTagFunction2, path3;
33815
33859
  var init_path = __esm({
33816
33860
  "../../node_modules/.pnpm/groq-sdk@1.1.2/node_modules/groq-sdk/internal/utils/path.mjs"() {
33817
33861
  init_error();
@@ -33864,7 +33908,7 @@ ${underline}`);
33864
33908
  }
33865
33909
  return path10;
33866
33910
  };
33867
- path2 = /* @__PURE__ */ createPathTagFunction2(encodeURIPath2);
33911
+ path3 = /* @__PURE__ */ createPathTagFunction2(encodeURIPath2);
33868
33912
  }
33869
33913
  });
33870
33914
 
@@ -33886,7 +33930,7 @@ var init_batches = __esm({
33886
33930
  * Retrieves a batch.
33887
33931
  */
33888
33932
  retrieve(batchID, options) {
33889
- return this._client.get(path2`/openai/v1/batches/${batchID}`, options);
33933
+ return this._client.get(path3`/openai/v1/batches/${batchID}`, options);
33890
33934
  }
33891
33935
  /**
33892
33936
  * List your organization's batches.
@@ -33898,7 +33942,7 @@ var init_batches = __esm({
33898
33942
  * Cancels a batch.
33899
33943
  */
33900
33944
  cancel(batchID, options) {
33901
- return this._client.post(path2`/openai/v1/batches/${batchID}/cancel`, options);
33945
+ return this._client.post(path3`/openai/v1/batches/${batchID}/cancel`, options);
33902
33946
  }
33903
33947
  };
33904
33948
  }
@@ -34003,13 +34047,13 @@ var init_files2 = __esm({
34003
34047
  * Delete a file.
34004
34048
  */
34005
34049
  delete(fileID, options) {
34006
- return this._client.delete(path2`/openai/v1/files/${fileID}`, options);
34050
+ return this._client.delete(path3`/openai/v1/files/${fileID}`, options);
34007
34051
  }
34008
34052
  /**
34009
34053
  * Returns the contents of the specified file.
34010
34054
  */
34011
34055
  content(fileID, options) {
34012
- return this._client.get(path2`/openai/v1/files/${fileID}/content`, {
34056
+ return this._client.get(path3`/openai/v1/files/${fileID}/content`, {
34013
34057
  ...options,
34014
34058
  headers: buildHeaders2([{ Accept: "application/octet-stream" }, options?.headers]),
34015
34059
  __binaryResponse: true
@@ -34019,7 +34063,7 @@ var init_files2 = __esm({
34019
34063
  * Returns information about a file.
34020
34064
  */
34021
34065
  info(fileID, options) {
34022
- return this._client.get(path2`/openai/v1/files/${fileID}`, options);
34066
+ return this._client.get(path3`/openai/v1/files/${fileID}`, options);
34023
34067
  }
34024
34068
  };
34025
34069
  }
@@ -34036,7 +34080,7 @@ var init_models = __esm({
34036
34080
  * Get a specific model
34037
34081
  */
34038
34082
  retrieve(model, options) {
34039
- return this._client.get(path2`/openai/v1/models/${model}`, options);
34083
+ return this._client.get(path3`/openai/v1/models/${model}`, options);
34040
34084
  }
34041
34085
  /**
34042
34086
  * get all available models
@@ -34048,7 +34092,7 @@ var init_models = __esm({
34048
34092
  * Delete a model
34049
34093
  */
34050
34094
  delete(model, options) {
34051
- return this._client.delete(path2`/openai/v1/models/${model}`, options);
34095
+ return this._client.delete(path3`/openai/v1/models/${model}`, options);
34052
34096
  }
34053
34097
  };
34054
34098
  }
@@ -58422,7 +58466,7 @@ var init_metadata_service = __esm({
58422
58466
  * @param agentsDir - Path to the agents/ directory
58423
58467
  */
58424
58468
  constructor(agentsDir) {
58425
- this.metadataDir = path4.join(agentsDir, ".standardagent");
58469
+ this.metadataDir = path5.join(agentsDir, ".standardagent");
58426
58470
  }
58427
58471
  /**
58428
58472
  * Read metadata for an agent.
@@ -58432,11 +58476,11 @@ var init_metadata_service = __esm({
58432
58476
  */
58433
58477
  async read(agentName) {
58434
58478
  const filePath = this.getMetadataPath(agentName);
58435
- if (!fs2.existsSync(filePath)) {
58479
+ if (!fs3.existsSync(filePath)) {
58436
58480
  return null;
58437
58481
  }
58438
58482
  try {
58439
- const content = fs2.readFileSync(filePath, "utf-8");
58483
+ const content = fs3.readFileSync(filePath, "utf-8");
58440
58484
  return JSON.parse(content);
58441
58485
  } catch {
58442
58486
  return null;
@@ -58449,11 +58493,11 @@ var init_metadata_service = __esm({
58449
58493
  * @param metadata - Metadata to write
58450
58494
  */
58451
58495
  async write(agentName, metadata) {
58452
- if (!fs2.existsSync(this.metadataDir)) {
58453
- fs2.mkdirSync(this.metadataDir, { recursive: true });
58496
+ if (!fs3.existsSync(this.metadataDir)) {
58497
+ fs3.mkdirSync(this.metadataDir, { recursive: true });
58454
58498
  }
58455
58499
  const filePath = this.getMetadataPath(agentName);
58456
- fs2.writeFileSync(filePath, JSON.stringify(metadata, null, 2));
58500
+ fs3.writeFileSync(filePath, JSON.stringify(metadata, null, 2));
58457
58501
  }
58458
58502
  /**
58459
58503
  * Delete metadata for an agent.
@@ -58462,8 +58506,8 @@ var init_metadata_service = __esm({
58462
58506
  */
58463
58507
  async delete(agentName) {
58464
58508
  const filePath = this.getMetadataPath(agentName);
58465
- if (fs2.existsSync(filePath)) {
58466
- fs2.unlinkSync(filePath);
58509
+ if (fs3.existsSync(filePath)) {
58510
+ fs3.unlinkSync(filePath);
58467
58511
  }
58468
58512
  }
58469
58513
  /**
@@ -58544,7 +58588,7 @@ var init_metadata_service = __esm({
58544
58588
  * Get the file path for an agent's metadata.
58545
58589
  */
58546
58590
  getMetadataPath(agentName) {
58547
- return path4.join(this.metadataDir, `${agentName}.json`);
58591
+ return path5.join(this.metadataDir, `${agentName}.json`);
58548
58592
  }
58549
58593
  };
58550
58594
  }
@@ -58931,9 +58975,9 @@ var init_packing_service = __esm({
58931
58975
  * @returns Version specifier (e.g., '^1.2.3') or '*' if not found
58932
58976
  */
58933
58977
  resolvePackageVersion(pkgName, rootDir) {
58934
- const pkgJsonPath = path4.join(rootDir, "node_modules", pkgName, "package.json");
58978
+ const pkgJsonPath = path5.join(rootDir, "node_modules", pkgName, "package.json");
58935
58979
  try {
58936
- const pkgJson = JSON.parse(fs2.readFileSync(pkgJsonPath, "utf-8"));
58980
+ const pkgJson = JSON.parse(fs3.readFileSync(pkgJsonPath, "utf-8"));
58937
58981
  return `^${pkgJson.version}`;
58938
58982
  } catch {
58939
58983
  return "*";
@@ -58950,7 +58994,7 @@ var init_packing_service = __esm({
58950
58994
  * @returns Analysis result with all discovered constituents
58951
58995
  */
58952
58996
  async analyzeAgent(agentName, rootDir) {
58953
- const agentsDir = path4.join(rootDir, "agents");
58997
+ const agentsDir = path5.join(rootDir, "agents");
58954
58998
  const analysis = {
58955
58999
  agent: agentName,
58956
59000
  primaryPrompt: "",
@@ -58974,7 +59018,7 @@ var init_packing_service = __esm({
58974
59018
  warnings: [],
58975
59019
  errors: []
58976
59020
  };
58977
- const agentFilePath = await this.findFile(path4.join(agentsDir, "agents"), agentName);
59021
+ const agentFilePath = await this.findFile(path5.join(agentsDir, "agents"), agentName);
58978
59022
  if (!agentFilePath) {
58979
59023
  analysis.errors.push(`Agent file not found: ${agentName}`);
58980
59024
  return analysis;
@@ -58985,7 +59029,7 @@ var init_packing_service = __esm({
58985
59029
  discoveredVia: "static",
58986
59030
  sharedWith: []
58987
59031
  });
58988
- const agentSource = fs2.readFileSync(agentFilePath, "utf-8");
59032
+ const agentSource = fs3.readFileSync(agentFilePath, "utf-8");
58989
59033
  const agentPrompts = await extractAgentPrompts(agentSource);
58990
59034
  if (agentPrompts.sideA) {
58991
59035
  analysis.primaryPrompt = agentPrompts.sideA;
@@ -59010,13 +59054,13 @@ var init_packing_service = __esm({
59010
59054
  * @returns Object with generatedReadme and agentDescription
59011
59055
  */
59012
59056
  async generateReadmeForAnalysis(analysis, rootDir) {
59013
- const agentsDir = path4.join(rootDir, "agents");
59057
+ const agentsDir = path5.join(rootDir, "agents");
59014
59058
  const metadataService = new MetadataService(agentsDir);
59015
59059
  let agentDescription;
59016
59060
  const agentItem = analysis.constituents.agents.find((a) => a.name === analysis.agent);
59017
59061
  if (agentItem?.filePath) {
59018
59062
  try {
59019
- const agentSource = fs2.readFileSync(agentItem.filePath, "utf-8");
59063
+ const agentSource = fs3.readFileSync(agentItem.filePath, "utf-8");
59020
59064
  agentDescription = await extractAgentDescription(agentSource) || void 0;
59021
59065
  } catch {
59022
59066
  }
@@ -59040,7 +59084,7 @@ var init_packing_service = __esm({
59040
59084
  * include all endpoint modules discovered under agents/api.
59041
59085
  */
59042
59086
  async analyzeThreadEndpoints(agentsDir, analysis) {
59043
- const apiDir = path4.join(agentsDir, "api");
59087
+ const apiDir = path5.join(agentsDir, "api");
59044
59088
  const endpoints = this.scanThreadEndpointFiles(apiDir);
59045
59089
  for (const endpoint of endpoints) {
59046
59090
  if (analysis.constituents.threadEndpoints.some((item) => item.name === endpoint.name)) {
@@ -59062,15 +59106,15 @@ var init_packing_service = __esm({
59062
59106
  * - `admin/users/[userId]/sync.post`
59063
59107
  */
59064
59108
  scanThreadEndpointFiles(apiDir, relativeDir = "") {
59065
- if (!fs2.existsSync(apiDir)) {
59109
+ if (!fs3.existsSync(apiDir)) {
59066
59110
  return [];
59067
59111
  }
59068
59112
  const endpoints = [];
59069
- const currentDir = relativeDir ? path4.join(apiDir, relativeDir) : apiDir;
59070
- if (!fs2.existsSync(currentDir)) {
59113
+ const currentDir = relativeDir ? path5.join(apiDir, relativeDir) : apiDir;
59114
+ if (!fs3.existsSync(currentDir)) {
59071
59115
  return endpoints;
59072
59116
  }
59073
- const entries = fs2.readdirSync(currentDir, { withFileTypes: true });
59117
+ const entries = fs3.readdirSync(currentDir, { withFileTypes: true });
59074
59118
  if (entries.length > 0 && typeof entries[0] === "string") {
59075
59119
  return endpoints;
59076
59120
  }
@@ -59078,8 +59122,8 @@ var init_packing_service = __esm({
59078
59122
  const entryName = typeof entry === "string" ? entry : entry.name;
59079
59123
  const isDirectory = typeof entry === "string" ? false : entry.isDirectory();
59080
59124
  const isFile = typeof entry === "string" ? true : entry.isFile();
59081
- const entryRelative = relativeDir ? path4.posix.join(relativeDir.replace(/\\/g, "/"), entryName) : entryName;
59082
- const absolutePath = path4.join(apiDir, entryRelative);
59125
+ const entryRelative = relativeDir ? path5.posix.join(relativeDir.replace(/\\/g, "/"), entryName) : entryName;
59126
+ const absolutePath = path5.join(apiDir, entryRelative);
59083
59127
  if (isDirectory) {
59084
59128
  endpoints.push(...this.scanThreadEndpointFiles(apiDir, entryRelative));
59085
59129
  continue;
@@ -59106,7 +59150,7 @@ var init_packing_service = __esm({
59106
59150
  * include all effect modules discovered under agents/effects.
59107
59151
  */
59108
59152
  async analyzeEffects(agentsDir, analysis) {
59109
- const effectsDir = path4.join(agentsDir, "effects");
59153
+ const effectsDir = path5.join(agentsDir, "effects");
59110
59154
  const effects = this.scanEffectFiles(effectsDir);
59111
59155
  for (const effect of effects) {
59112
59156
  if (analysis.constituents.effects.some((item) => item.name === effect.name)) {
@@ -59128,15 +59172,15 @@ var init_packing_service = __esm({
59128
59172
  * - `notifications/digest`
59129
59173
  */
59130
59174
  scanEffectFiles(effectsDir, relativeDir = "") {
59131
- if (!fs2.existsSync(effectsDir)) {
59175
+ if (!fs3.existsSync(effectsDir)) {
59132
59176
  return [];
59133
59177
  }
59134
59178
  const effects = [];
59135
- const currentDir = relativeDir ? path4.join(effectsDir, relativeDir) : effectsDir;
59136
- if (!fs2.existsSync(currentDir)) {
59179
+ const currentDir = relativeDir ? path5.join(effectsDir, relativeDir) : effectsDir;
59180
+ if (!fs3.existsSync(currentDir)) {
59137
59181
  return effects;
59138
59182
  }
59139
- const entries = fs2.readdirSync(currentDir, { withFileTypes: true });
59183
+ const entries = fs3.readdirSync(currentDir, { withFileTypes: true });
59140
59184
  if (entries.length > 0 && typeof entries[0] === "string") {
59141
59185
  return effects;
59142
59186
  }
@@ -59144,8 +59188,8 @@ var init_packing_service = __esm({
59144
59188
  const entryName = typeof entry === "string" ? entry : entry.name;
59145
59189
  const isDirectory = typeof entry === "string" ? false : entry.isDirectory();
59146
59190
  const isFile = typeof entry === "string" ? true : entry.isFile();
59147
- const entryRelative = relativeDir ? path4.posix.join(relativeDir.replace(/\\/g, "/"), entryName) : entryName;
59148
- const absolutePath = path4.join(effectsDir, entryRelative);
59191
+ const entryRelative = relativeDir ? path5.posix.join(relativeDir.replace(/\\/g, "/"), entryName) : entryName;
59192
+ const absolutePath = path5.join(effectsDir, entryRelative);
59149
59193
  if (isDirectory) {
59150
59194
  effects.push(...this.scanEffectFiles(effectsDir, entryRelative));
59151
59195
  continue;
@@ -59169,7 +59213,7 @@ var init_packing_service = __esm({
59169
59213
  * Recursively analyze a prompt and its dependencies.
59170
59214
  */
59171
59215
  async analyzePrompt(promptName, agentsDir, analysis, visited, parentKey) {
59172
- const promptFilePath = await this.findFile(path4.join(agentsDir, "prompts"), promptName);
59216
+ const promptFilePath = await this.findFile(path5.join(agentsDir, "prompts"), promptName);
59173
59217
  if (!promptFilePath) {
59174
59218
  analysis.warnings.push(`Prompt file not found: ${promptName}`);
59175
59219
  return;
@@ -59188,7 +59232,7 @@ var init_packing_service = __esm({
59188
59232
  return;
59189
59233
  }
59190
59234
  visited.add(`prompt:${promptName}`);
59191
- const promptSource = fs2.readFileSync(promptFilePath, "utf-8");
59235
+ const promptSource = fs3.readFileSync(promptFilePath, "utf-8");
59192
59236
  const modelName = await extractPromptModel(promptSource);
59193
59237
  if (modelName) {
59194
59238
  await this.analyzeModel(modelName, agentsDir, analysis, visited, thisKey);
@@ -59214,17 +59258,17 @@ var init_packing_service = __esm({
59214
59258
  */
59215
59259
  async analyzeTool(toolName, agentsDir, analysis, visited, discoveredVia, parentKey) {
59216
59260
  const thisKey = `tool:${toolName}`;
59217
- const promptFilePath = await this.findFile(path4.join(agentsDir, "prompts"), toolName);
59261
+ const promptFilePath = await this.findFile(path5.join(agentsDir, "prompts"), toolName);
59218
59262
  if (promptFilePath) {
59219
59263
  await this.analyzePrompt(toolName, agentsDir, analysis, visited, parentKey);
59220
59264
  return;
59221
59265
  }
59222
- const agentFilePath = await this.findFile(path4.join(agentsDir, "agents"), toolName);
59266
+ const agentFilePath = await this.findFile(path5.join(agentsDir, "agents"), toolName);
59223
59267
  if (agentFilePath) {
59224
59268
  await this.analyzeNestedAgent(toolName, agentsDir, analysis, visited, parentKey);
59225
59269
  return;
59226
59270
  }
59227
- const toolFilePath = await this.findFile(path4.join(agentsDir, "tools"), toolName);
59271
+ const toolFilePath = await this.findFile(path5.join(agentsDir, "tools"), toolName);
59228
59272
  if (!toolFilePath) {
59229
59273
  analysis.warnings.push(`Tool file not found: ${toolName}`);
59230
59274
  return;
@@ -59242,7 +59286,7 @@ var init_packing_service = __esm({
59242
59286
  return;
59243
59287
  }
59244
59288
  visited.add(`tool:${toolName}`);
59245
- const toolSource = fs2.readFileSync(toolFilePath, "utf-8");
59289
+ const toolSource = fs3.readFileSync(toolFilePath, "utf-8");
59246
59290
  const { uses } = await extractToolUses(toolSource);
59247
59291
  for (const usedItem of uses) {
59248
59292
  await this.analyzeTool(usedItem, agentsDir, analysis, visited, "uses", thisKey);
@@ -59252,7 +59296,7 @@ var init_packing_service = __esm({
59252
59296
  * Analyze a nested agent (used as a handoff target).
59253
59297
  */
59254
59298
  async analyzeNestedAgent(agentName, agentsDir, analysis, visited, parentKey) {
59255
- const agentFilePath = await this.findFile(path4.join(agentsDir, "agents"), agentName);
59299
+ const agentFilePath = await this.findFile(path5.join(agentsDir, "agents"), agentName);
59256
59300
  if (!agentFilePath) {
59257
59301
  analysis.warnings.push(`Agent file not found: ${agentName}`);
59258
59302
  return;
@@ -59271,7 +59315,7 @@ var init_packing_service = __esm({
59271
59315
  return;
59272
59316
  }
59273
59317
  visited.add(`agent:${agentName}`);
59274
- const agentSource = fs2.readFileSync(agentFilePath, "utf-8");
59318
+ const agentSource = fs3.readFileSync(agentFilePath, "utf-8");
59275
59319
  const agentPrompts = await extractAgentPrompts(agentSource);
59276
59320
  if (agentPrompts.sideA) {
59277
59321
  await this.analyzePrompt(agentPrompts.sideA, agentsDir, analysis, visited, thisKey);
@@ -59284,7 +59328,7 @@ var init_packing_service = __esm({
59284
59328
  * Analyze a model and its fallbacks.
59285
59329
  */
59286
59330
  async analyzeModel(modelName, agentsDir, analysis, visited, parentKey) {
59287
- const modelFilePath = await this.findFile(path4.join(agentsDir, "models"), modelName);
59331
+ const modelFilePath = await this.findFile(path5.join(agentsDir, "models"), modelName);
59288
59332
  if (!modelFilePath) {
59289
59333
  analysis.warnings.push(`Model file not found: ${modelName}`);
59290
59334
  return;
@@ -59303,7 +59347,7 @@ var init_packing_service = __esm({
59303
59347
  return;
59304
59348
  }
59305
59349
  visited.add(`model:${modelName}`);
59306
- const modelSource = fs2.readFileSync(modelFilePath, "utf-8");
59350
+ const modelSource = fs3.readFileSync(modelFilePath, "utf-8");
59307
59351
  const fallbacks = await extractModelFallbacks(modelSource);
59308
59352
  for (const fallbackName of fallbacks) {
59309
59353
  await this.analyzeModel(fallbackName, agentsDir, analysis, visited, thisKey);
@@ -59313,13 +59357,13 @@ var init_packing_service = __esm({
59313
59357
  * Check which items are shared with other agents.
59314
59358
  */
59315
59359
  async checkSharedItems(agentsDir, analysis) {
59316
- const agentsPath = path4.join(agentsDir, "agents");
59317
- if (!fs2.existsSync(agentsPath)) return;
59318
- const agentFiles = fs2.readdirSync(agentsPath).filter((f) => f.endsWith(".ts"));
59360
+ const agentsPath = path5.join(agentsDir, "agents");
59361
+ if (!fs3.existsSync(agentsPath)) return;
59362
+ const agentFiles = fs3.readdirSync(agentsPath).filter((f) => f.endsWith(".ts"));
59319
59363
  for (const agentFile of agentFiles) {
59320
59364
  const otherAgentName = agentFile.replace(".ts", "");
59321
59365
  if (otherAgentName === analysis.agent) continue;
59322
- const otherAnalysis = await this.analyzeAgentLight(otherAgentName, path4.dirname(agentsDir));
59366
+ const otherAnalysis = await this.analyzeAgentLight(otherAgentName, path5.dirname(agentsDir));
59323
59367
  for (const prompt of analysis.constituents.prompts) {
59324
59368
  if (otherAnalysis.prompts.includes(prompt.name)) {
59325
59369
  prompt.sharedWith.push(otherAgentName);
@@ -59351,19 +59395,19 @@ var init_packing_service = __esm({
59351
59395
  */
59352
59396
  async analyzeAgentLight(agentName, rootDir) {
59353
59397
  const result = { prompts: [], tools: [], models: [] };
59354
- const agentsDir = path4.join(rootDir, "agents");
59398
+ const agentsDir = path5.join(rootDir, "agents");
59355
59399
  const visited = /* @__PURE__ */ new Set();
59356
- const agentFilePath = await this.findFile(path4.join(agentsDir, "agents"), agentName);
59400
+ const agentFilePath = await this.findFile(path5.join(agentsDir, "agents"), agentName);
59357
59401
  if (!agentFilePath) return result;
59358
- const agentSource = fs2.readFileSync(agentFilePath, "utf-8");
59402
+ const agentSource = fs3.readFileSync(agentFilePath, "utf-8");
59359
59403
  const agentPrompts = await extractAgentPrompts(agentSource);
59360
59404
  const analyzePromptLight = async (promptName) => {
59361
59405
  if (visited.has(promptName)) return;
59362
59406
  visited.add(promptName);
59363
59407
  result.prompts.push(promptName);
59364
- const promptFilePath = await this.findFile(path4.join(agentsDir, "prompts"), promptName);
59408
+ const promptFilePath = await this.findFile(path5.join(agentsDir, "prompts"), promptName);
59365
59409
  if (!promptFilePath) return;
59366
- const promptSource = fs2.readFileSync(promptFilePath, "utf-8");
59410
+ const promptSource = fs3.readFileSync(promptFilePath, "utf-8");
59367
59411
  const modelName = await extractPromptModel(promptSource);
59368
59412
  if (modelName && !result.models.includes(modelName)) {
59369
59413
  result.models.push(modelName);
@@ -59436,14 +59480,14 @@ var init_packing_service = __esm({
59436
59480
  return result;
59437
59481
  }
59438
59482
  result.warnings = analysis.warnings;
59439
- const pkgOutputDir = path4.join(outputDir, packageId);
59440
- fs2.mkdirSync(path4.join(pkgOutputDir, "dist", "agents"), { recursive: true });
59441
- fs2.mkdirSync(path4.join(pkgOutputDir, "dist", "prompts"), { recursive: true });
59442
- fs2.mkdirSync(path4.join(pkgOutputDir, "dist", "tools"), { recursive: true });
59443
- fs2.mkdirSync(path4.join(pkgOutputDir, "dist", "models"), { recursive: true });
59444
- fs2.mkdirSync(path4.join(pkgOutputDir, "dist", "hooks"), { recursive: true });
59445
- fs2.mkdirSync(path4.join(pkgOutputDir, "dist", "effects"), { recursive: true });
59446
- fs2.mkdirSync(path4.join(pkgOutputDir, "dist", "thread-endpoints"), { recursive: true });
59483
+ const pkgOutputDir = path5.join(outputDir, packageId);
59484
+ fs3.mkdirSync(path5.join(pkgOutputDir, "dist", "agents"), { recursive: true });
59485
+ fs3.mkdirSync(path5.join(pkgOutputDir, "dist", "prompts"), { recursive: true });
59486
+ fs3.mkdirSync(path5.join(pkgOutputDir, "dist", "tools"), { recursive: true });
59487
+ fs3.mkdirSync(path5.join(pkgOutputDir, "dist", "models"), { recursive: true });
59488
+ fs3.mkdirSync(path5.join(pkgOutputDir, "dist", "hooks"), { recursive: true });
59489
+ fs3.mkdirSync(path5.join(pkgOutputDir, "dist", "effects"), { recursive: true });
59490
+ fs3.mkdirSync(path5.join(pkgOutputDir, "dist", "thread-endpoints"), { recursive: true });
59447
59491
  const seenItems = /* @__PURE__ */ new Set();
59448
59492
  const allItems = [];
59449
59493
  for (const a of analysis.constituents.agents) {
@@ -59497,13 +59541,13 @@ var init_packing_service = __esm({
59497
59541
  }
59498
59542
  const externalDeps = /* @__PURE__ */ new Map();
59499
59543
  for (const item of allItems) {
59500
- const outputPath = path4.join(
59544
+ const outputPath = path5.join(
59501
59545
  pkgOutputDir,
59502
59546
  "dist",
59503
59547
  this.getTypeDir(item.type),
59504
59548
  `${item.name}.js`
59505
59549
  );
59506
- fs2.mkdirSync(path4.dirname(outputPath), { recursive: true });
59550
+ fs3.mkdirSync(path5.dirname(outputPath), { recursive: true });
59507
59551
  const deps = await this.bundleFile(item.filePath, outputPath, rootDir);
59508
59552
  for (const [depName, depVersion] of deps) {
59509
59553
  if (!externalDeps.has(depName)) {
@@ -59513,12 +59557,12 @@ var init_packing_service = __esm({
59513
59557
  result.filesCreated.push(outputPath);
59514
59558
  }
59515
59559
  const indexJs = this.generateReExportIndex(analysis, meta);
59516
- const indexJsPath = path4.join(pkgOutputDir, "dist", "index.js");
59517
- fs2.writeFileSync(indexJsPath, indexJs);
59560
+ const indexJsPath = path5.join(pkgOutputDir, "dist", "index.js");
59561
+ fs3.writeFileSync(indexJsPath, indexJs);
59518
59562
  result.filesCreated.push(indexJsPath);
59519
59563
  const indexDts = this.generateIndexDts(analysis);
59520
- const indexDtsPath = path4.join(pkgOutputDir, "dist", "index.d.ts");
59521
- fs2.writeFileSync(indexDtsPath, indexDts);
59564
+ const indexDtsPath = path5.join(pkgOutputDir, "dist", "index.d.ts");
59565
+ fs3.writeFileSync(indexDtsPath, indexDts);
59522
59566
  result.filesCreated.push(indexDtsPath);
59523
59567
  const pkgJson = this.generatePackageJson(
59524
59568
  finalPackageName,
@@ -59531,13 +59575,13 @@ var init_packing_service = __esm({
59531
59575
  license,
59532
59576
  licenseOwner
59533
59577
  );
59534
- const pkgJsonPath = path4.join(pkgOutputDir, "package.json");
59535
- fs2.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
59578
+ const pkgJsonPath = path5.join(pkgOutputDir, "package.json");
59579
+ fs3.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
59536
59580
  result.filesCreated.push(pkgJsonPath);
59537
59581
  if (license) {
59538
59582
  const licenseContent = this.generateLicenseFile(license, licenseOwner);
59539
- const licensePath = path4.join(pkgOutputDir, "LICENSE");
59540
- fs2.writeFileSync(licensePath, licenseContent);
59583
+ const licensePath = path5.join(pkgOutputDir, "LICENSE");
59584
+ fs3.writeFileSync(licensePath, licenseContent);
59541
59585
  result.filesCreated.push(licensePath);
59542
59586
  }
59543
59587
  let readmeContent = readme;
@@ -59545,7 +59589,7 @@ var init_packing_service = __esm({
59545
59589
  const agentItem = analysis.constituents.agents.find((a) => a.name === agentName);
59546
59590
  let agentDescription;
59547
59591
  if (agentItem?.filePath) {
59548
- const agentSource = fs2.readFileSync(agentItem.filePath, "utf-8");
59592
+ const agentSource = fs3.readFileSync(agentItem.filePath, "utf-8");
59549
59593
  agentDescription = await extractAgentDescription(agentSource) || void 0;
59550
59594
  }
59551
59595
  readmeContent = this.generateReadme(
@@ -59556,21 +59600,21 @@ var init_packing_service = __esm({
59556
59600
  agentDescription
59557
59601
  );
59558
59602
  }
59559
- const readmePath = path4.join(pkgOutputDir, "README.md");
59560
- fs2.writeFileSync(readmePath, readmeContent);
59603
+ const readmePath = path5.join(pkgOutputDir, "README.md");
59604
+ fs3.writeFileSync(readmePath, readmeContent);
59561
59605
  result.filesCreated.push(readmePath);
59562
59606
  if (removeOriginals || itemSelections) {
59563
59607
  result.filesRemoved = [];
59564
59608
  for (const item of allItems) {
59565
59609
  const selection = itemSelections?.find((s) => s.name === item.name && s.type === item.type);
59566
59610
  const shouldRemove = selection ? selection.mode === "extract" : removeOriginals && item.sharedWith.length === 0 && item.type !== "thread-endpoint" && item.type !== "effect";
59567
- if (shouldRemove && fs2.existsSync(item.filePath)) {
59568
- fs2.unlinkSync(item.filePath);
59611
+ if (shouldRemove && fs3.existsSync(item.filePath)) {
59612
+ fs3.unlinkSync(item.filePath);
59569
59613
  result.filesRemoved.push(item.filePath);
59570
59614
  }
59571
59615
  }
59572
59616
  }
59573
- const agentsDir = path4.join(rootDir, "agents");
59617
+ const agentsDir = path5.join(rootDir, "agents");
59574
59618
  const metadataService = new MetadataService(agentsDir);
59575
59619
  const metadata = {
59576
59620
  packageName: finalPackageName,
@@ -59604,7 +59648,7 @@ var init_packing_service = __esm({
59604
59648
  const commonjs = (await import('@rollup/plugin-commonjs')).default;
59605
59649
  const esbuild = (await import('rollup-plugin-esbuild')).default;
59606
59650
  const externalDeps = /* @__PURE__ */ new Map();
59607
- const agentsDir = path4.join(rootDir, "agents");
59651
+ const agentsDir = path5.join(rootDir, "agents");
59608
59652
  const resolveVersion = this.resolvePackageVersion.bind(this);
59609
59653
  const trackExternalsPlugin = {
59610
59654
  name: "track-externals",
@@ -59613,14 +59657,14 @@ var init_packing_service = __esm({
59613
59657
  return null;
59614
59658
  }
59615
59659
  if (source.startsWith("./") || source.startsWith("../")) {
59616
- const resolved = path4.resolve(path4.dirname(importer), source);
59660
+ const resolved = path5.resolve(path5.dirname(importer), source);
59617
59661
  let tsResolved = resolved;
59618
59662
  if (!resolved.endsWith(".ts") && !resolved.endsWith(".js")) {
59619
- if (fs2.existsSync(`${resolved}.ts`)) {
59663
+ if (fs3.existsSync(`${resolved}.ts`)) {
59620
59664
  tsResolved = `${resolved}.ts`;
59621
- } else if (fs2.existsSync(`${resolved}.js`)) {
59665
+ } else if (fs3.existsSync(`${resolved}.js`)) {
59622
59666
  tsResolved = `${resolved}.js`;
59623
- } else if (fs2.existsSync(`${resolved}/index.ts`)) {
59667
+ } else if (fs3.existsSync(`${resolved}/index.ts`)) {
59624
59668
  tsResolved = `${resolved}/index.ts`;
59625
59669
  }
59626
59670
  }
@@ -59669,11 +59713,11 @@ var init_packing_service = __esm({
59669
59713
  exports: "named"
59670
59714
  });
59671
59715
  const bundledCode = output[0].code;
59672
- const header = `// Bundled from: ${path4.relative(rootDir, inputPath)}
59716
+ const header = `// Bundled from: ${path5.relative(rootDir, inputPath)}
59673
59717
  // Local dependencies have been inlined
59674
59718
 
59675
59719
  `;
59676
- fs2.writeFileSync(outputPath, header + bundledCode);
59720
+ fs3.writeFileSync(outputPath, header + bundledCode);
59677
59721
  await bundle.close();
59678
59722
  } catch (error) {
59679
59723
  await bundle.close();
@@ -60098,30 +60142,30 @@ Copyright (c) ${year} ${copyrightHolder}
60098
60142
  * @returns Package info or null if not found
60099
60143
  */
60100
60144
  getPackedInfo(packageId, rootDir) {
60101
- const packedDir = path4.join(rootDir, "agents", "packed");
60102
- let packageDir = path4.join(packedDir, packageId);
60103
- if (!fs2.existsSync(packageDir)) {
60104
- if (!fs2.existsSync(packedDir)) {
60145
+ const packedDir = path5.join(rootDir, "agents", "packed");
60146
+ let packageDir = path5.join(packedDir, packageId);
60147
+ if (!fs3.existsSync(packageDir)) {
60148
+ if (!fs3.existsSync(packedDir)) {
60105
60149
  return null;
60106
60150
  }
60107
- const dirs = fs2.readdirSync(packedDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
60151
+ const dirs = fs3.readdirSync(packedDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
60108
60152
  const matchingDir = dirs.find(
60109
60153
  (d) => d === packageId || d === `standardagent-${packageId}` || d === `standardagent-${packageId.replace(/_/g, "-")}`
60110
60154
  );
60111
60155
  if (!matchingDir) {
60112
60156
  return null;
60113
60157
  }
60114
- packageDir = path4.join(packedDir, matchingDir);
60158
+ packageDir = path5.join(packedDir, matchingDir);
60115
60159
  }
60116
- const pkgJsonPath = path4.join(packageDir, "package.json");
60117
- if (!fs2.existsSync(pkgJsonPath)) {
60160
+ const pkgJsonPath = path5.join(packageDir, "package.json");
60161
+ if (!fs3.existsSync(pkgJsonPath)) {
60118
60162
  return null;
60119
60163
  }
60120
- const pkgJson = JSON.parse(fs2.readFileSync(pkgJsonPath, "utf-8"));
60164
+ const pkgJson = JSON.parse(fs3.readFileSync(pkgJsonPath, "utf-8"));
60121
60165
  let readme;
60122
- const readmePath = path4.join(packageDir, "README.md");
60123
- if (fs2.existsSync(readmePath)) {
60124
- readme = fs2.readFileSync(readmePath, "utf-8");
60166
+ const readmePath = path5.join(packageDir, "README.md");
60167
+ if (fs3.existsSync(readmePath)) {
60168
+ readme = fs3.readFileSync(readmePath, "utf-8");
60125
60169
  }
60126
60170
  return {
60127
60171
  packageName: pkgJson.name,
@@ -60139,11 +60183,11 @@ Copyright (c) ${year} ${copyrightHolder}
60139
60183
  * @returns Array of package directory names
60140
60184
  */
60141
60185
  listPackedPackages(rootDir) {
60142
- const packedDir = path4.join(rootDir, "agents", "packed");
60143
- if (!fs2.existsSync(packedDir)) {
60186
+ const packedDir = path5.join(rootDir, "agents", "packed");
60187
+ if (!fs3.existsSync(packedDir)) {
60144
60188
  return [];
60145
60189
  }
60146
- return fs2.readdirSync(packedDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
60190
+ return fs3.readdirSync(packedDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
60147
60191
  }
60148
60192
  /**
60149
60193
  * Generate README.md content for a packed agent.
@@ -60190,17 +60234,17 @@ ${license || "See LICENSE file"}
60190
60234
  * Find a file by name in a directory.
60191
60235
  */
60192
60236
  async findFile(dir, name15) {
60193
- if (!fs2.existsSync(dir)) {
60237
+ if (!fs3.existsSync(dir)) {
60194
60238
  return null;
60195
60239
  }
60196
- const exactPath = path4.join(dir, `${name15}.ts`);
60197
- if (fs2.existsSync(exactPath)) {
60240
+ const exactPath = path5.join(dir, `${name15}.ts`);
60241
+ if (fs3.existsSync(exactPath)) {
60198
60242
  return exactPath;
60199
60243
  }
60200
- const files = fs2.readdirSync(dir).filter((f) => f.endsWith(".ts"));
60244
+ const files = fs3.readdirSync(dir).filter((f) => f.endsWith(".ts"));
60201
60245
  for (const file of files) {
60202
- const filePath = path4.join(dir, file);
60203
- const source = fs2.readFileSync(filePath, "utf-8");
60246
+ const filePath = path5.join(dir, file);
60247
+ const source = fs3.readFileSync(filePath, "utf-8");
60204
60248
  const extractedName = await extractDefinitionName(source);
60205
60249
  if (extractedName === name15) {
60206
60250
  return filePath;
@@ -60212,15 +60256,15 @@ ${license || "See LICENSE file"}
60212
60256
  * List all agents in the workspace.
60213
60257
  */
60214
60258
  async listAgents(rootDir) {
60215
- const agentsDir = path4.join(rootDir, "agents", "agents");
60216
- if (!fs2.existsSync(agentsDir)) {
60259
+ const agentsDir = path5.join(rootDir, "agents", "agents");
60260
+ if (!fs3.existsSync(agentsDir)) {
60217
60261
  return [];
60218
60262
  }
60219
- const files = fs2.readdirSync(agentsDir).filter((f) => f.endsWith(".ts"));
60263
+ const files = fs3.readdirSync(agentsDir).filter((f) => f.endsWith(".ts"));
60220
60264
  const agents = [];
60221
60265
  for (const file of files) {
60222
- const filePath = path4.join(agentsDir, file);
60223
- const source = fs2.readFileSync(filePath, "utf-8");
60266
+ const filePath = path5.join(agentsDir, file);
60267
+ const source = fs3.readFileSync(filePath, "utf-8");
60224
60268
  const name15 = await extractDefinitionName(source);
60225
60269
  if (name15) {
60226
60270
  agents.push(name15);
@@ -60241,7 +60285,7 @@ var init_discovery = __esm({
60241
60285
  constructor(config) {
60242
60286
  this.config = {
60243
60287
  rootDir: config.rootDir,
60244
- packedDir: config.packedDir ?? path4.join(config.rootDir, "agents", "packed"),
60288
+ packedDir: config.packedDir ?? path5.join(config.rootDir, "agents", "packed"),
60245
60289
  scanNpm: config.scanNpm ?? true,
60246
60290
  scanLocal: config.scanLocal ?? true
60247
60291
  };
@@ -60274,19 +60318,19 @@ var init_discovery = __esm({
60274
60318
  */
60275
60319
  async discoverNpmPackages() {
60276
60320
  const packages = [];
60277
- const nodeModulesDir = path4.join(this.config.rootDir, "node_modules");
60278
- if (!fs2.existsSync(nodeModulesDir)) {
60321
+ const nodeModulesDir = path5.join(this.config.rootDir, "node_modules");
60322
+ if (!fs3.existsSync(nodeModulesDir)) {
60279
60323
  return packages;
60280
60324
  }
60281
60325
  const rootEntries = await this.scanDirectory(nodeModulesDir);
60282
60326
  for (const entry of rootEntries) {
60283
60327
  if (entry.startsWith(".")) continue;
60284
60328
  if (entry.startsWith("@")) {
60285
- const scopeDir = path4.join(nodeModulesDir, entry);
60329
+ const scopeDir = path5.join(nodeModulesDir, entry);
60286
60330
  const scopeEntries = await this.scanDirectory(scopeDir);
60287
60331
  for (const scopedPkg of scopeEntries) {
60288
60332
  if (scopedPkg.startsWith(".")) continue;
60289
- const pkgDir = path4.join(scopeDir, scopedPkg);
60333
+ const pkgDir = path5.join(scopeDir, scopedPkg);
60290
60334
  const fullName = `${entry}/${scopedPkg}`;
60291
60335
  const pkg = await this.checkNpmPackage(pkgDir, fullName);
60292
60336
  if (pkg) {
@@ -60294,7 +60338,7 @@ var init_discovery = __esm({
60294
60338
  }
60295
60339
  }
60296
60340
  } else {
60297
- const pkgDir = path4.join(nodeModulesDir, entry);
60341
+ const pkgDir = path5.join(nodeModulesDir, entry);
60298
60342
  const pkg = await this.checkNpmPackage(pkgDir, entry);
60299
60343
  if (pkg) {
60300
60344
  packages.push(pkg);
@@ -60310,12 +60354,12 @@ var init_discovery = __esm({
60310
60354
  * which must contain `entryAgents` array.
60311
60355
  */
60312
60356
  async checkNpmPackage(pkgDir, pkgName) {
60313
- const pkgJsonPath = path4.join(pkgDir, "package.json");
60314
- if (!fs2.existsSync(pkgJsonPath)) {
60357
+ const pkgJsonPath = path5.join(pkgDir, "package.json");
60358
+ if (!fs3.existsSync(pkgJsonPath)) {
60315
60359
  return null;
60316
60360
  }
60317
60361
  try {
60318
- const pkgJson = JSON.parse(fs2.readFileSync(pkgJsonPath, "utf-8"));
60362
+ const pkgJson = JSON.parse(fs3.readFileSync(pkgJsonPath, "utf-8"));
60319
60363
  const isStandardAgent = (
60320
60364
  // Has "standardagent" keyword
60321
60365
  pkgJson.keywords?.includes("standardagent") || // Has "standardagent-*" prefix
@@ -60352,21 +60396,21 @@ var init_discovery = __esm({
60352
60396
  */
60353
60397
  async discoverLocalPackages() {
60354
60398
  const packages = [];
60355
- if (!fs2.existsSync(this.config.packedDir)) {
60399
+ if (!fs3.existsSync(this.config.packedDir)) {
60356
60400
  return packages;
60357
60401
  }
60358
60402
  const entries = await this.scanDirectory(this.config.packedDir);
60359
60403
  for (const entry of entries) {
60360
60404
  if (entry.startsWith(".")) continue;
60361
- const pkgDir = path4.join(this.config.packedDir, entry);
60362
- const stat = fs2.statSync(pkgDir);
60405
+ const pkgDir = path5.join(this.config.packedDir, entry);
60406
+ const stat = fs3.statSync(pkgDir);
60363
60407
  if (!stat.isDirectory()) continue;
60364
60408
  if (entry.startsWith("@")) {
60365
60409
  const scopeEntries = await this.scanDirectory(pkgDir);
60366
60410
  for (const scopedPkg of scopeEntries) {
60367
60411
  if (scopedPkg.startsWith(".")) continue;
60368
- const scopedPkgDir = path4.join(pkgDir, scopedPkg);
60369
- const scopedStat = fs2.statSync(scopedPkgDir);
60412
+ const scopedPkgDir = path5.join(pkgDir, scopedPkg);
60413
+ const scopedStat = fs3.statSync(scopedPkgDir);
60370
60414
  if (!scopedStat.isDirectory()) continue;
60371
60415
  const fullName = `${entry}/${scopedPkg}`;
60372
60416
  const pkg = await this.checkLocalPackage(scopedPkgDir, fullName);
@@ -60389,12 +60433,12 @@ var init_discovery = __esm({
60389
60433
  * Detection is based on the `standardagent` field in package.json.
60390
60434
  */
60391
60435
  async checkLocalPackage(pkgDir, dirName) {
60392
- const pkgJsonPath = path4.join(pkgDir, "package.json");
60393
- if (!fs2.existsSync(pkgJsonPath)) {
60436
+ const pkgJsonPath = path5.join(pkgDir, "package.json");
60437
+ if (!fs3.existsSync(pkgJsonPath)) {
60394
60438
  return null;
60395
60439
  }
60396
60440
  try {
60397
- const pkgJson = JSON.parse(fs2.readFileSync(pkgJsonPath, "utf-8"));
60441
+ const pkgJson = JSON.parse(fs3.readFileSync(pkgJsonPath, "utf-8"));
60398
60442
  if (!pkgJson.standardagent?.entryAgents) {
60399
60443
  return null;
60400
60444
  }
@@ -60419,10 +60463,10 @@ var init_discovery = __esm({
60419
60463
  * Scan a directory and return entry names.
60420
60464
  */
60421
60465
  async scanDirectory(dir) {
60422
- if (!fs2.existsSync(dir)) {
60466
+ if (!fs3.existsSync(dir)) {
60423
60467
  return [];
60424
60468
  }
60425
- const entries = fs2.readdirSync(dir);
60469
+ const entries = fs3.readdirSync(dir);
60426
60470
  return entries;
60427
60471
  }
60428
60472
  /**
@@ -60526,29 +60570,29 @@ var init_unpacking_service = __esm({
60526
60570
  }
60527
60571
  analysis.version = pkg.version;
60528
60572
  analysis.source = pkg.source;
60529
- const indexPath = path4.join(pkg.path, "dist", "index.js");
60530
- if (!fs2.existsSync(indexPath)) {
60573
+ const indexPath = path5.join(pkg.path, "dist", "index.js");
60574
+ if (!fs3.existsSync(indexPath)) {
60531
60575
  analysis.errors.push(`Package index not found: ${indexPath}`);
60532
60576
  return analysis;
60533
60577
  }
60534
- const indexContent = fs2.readFileSync(indexPath, "utf-8");
60578
+ const indexContent = fs3.readFileSync(indexPath, "utf-8");
60535
60579
  const registryItems = await this.parseIndexExports(indexContent);
60536
60580
  const availableItems = /* @__PURE__ */ new Map();
60537
60581
  for (const item of registryItems) {
60538
60582
  availableItems.set(`${item.type}:${item.name}`, item);
60539
60583
  }
60540
- const agentsDir = path4.join(rootDir, "agents");
60584
+ const agentsDir = path5.join(rootDir, "agents");
60541
60585
  const itemsWithRelations = [];
60542
60586
  for (const item of registryItems) {
60543
- const targetPath = path4.join(agentsDir, TYPE_TO_TARGET_DIR[item.type], `${item.name}.ts`);
60544
- const sourcePath = path4.join(pkg.path, "dist", TYPE_TO_DIR[item.type], `${item.name}.js`);
60587
+ const targetPath = path5.join(agentsDir, TYPE_TO_TARGET_DIR[item.type], `${item.name}.ts`);
60588
+ const sourcePath = path5.join(pkg.path, "dist", TYPE_TO_DIR[item.type], `${item.name}.js`);
60545
60589
  const existsGlobally = this.fileExists(targetPath);
60546
- const sourceExists = fs2.existsSync(sourcePath);
60590
+ const sourceExists = fs3.existsSync(sourcePath);
60547
60591
  if (!sourceExists) {
60548
60592
  analysis.warnings.push(`Source file not found for ${item.type} "${item.name}": ${sourcePath}`);
60549
60593
  continue;
60550
60594
  }
60551
- const bundledCode = fs2.readFileSync(sourcePath, "utf-8");
60595
+ const bundledCode = fs3.readFileSync(sourcePath, "utf-8");
60552
60596
  const children = await this.discoverRelationships(item.type, item.name, bundledCode, availableItems);
60553
60597
  itemsWithRelations.push({
60554
60598
  name: item.name,
@@ -60558,10 +60602,10 @@ var init_unpacking_service = __esm({
60558
60602
  action: existsGlobally ? "skip" : "generate"
60559
60603
  });
60560
60604
  for (const child of children) {
60561
- const childTargetPath = path4.join(agentsDir, TYPE_TO_TARGET_DIR[child.type], `${child.name}.ts`);
60562
- const childSourcePath = path4.join(pkg.path, "dist", TYPE_TO_DIR[child.type], `${child.name}.js`);
60605
+ const childTargetPath = path5.join(agentsDir, TYPE_TO_TARGET_DIR[child.type], `${child.name}.ts`);
60606
+ const childSourcePath = path5.join(pkg.path, "dist", TYPE_TO_DIR[child.type], `${child.name}.js`);
60563
60607
  const childExists = this.fileExists(childTargetPath);
60564
- const childSourceExists = fs2.existsSync(childSourcePath);
60608
+ const childSourceExists = fs3.existsSync(childSourcePath);
60565
60609
  if (!childSourceExists) {
60566
60610
  continue;
60567
60611
  }
@@ -60664,8 +60708,8 @@ var init_unpacking_service = __esm({
60664
60708
  return result;
60665
60709
  }
60666
60710
  const itemsToProcess = this.applySelections(analysis.items, itemSelections);
60667
- const pkgJsonPath = path4.join(pkg.path, "package.json");
60668
- const pkgJson = JSON.parse(fs2.readFileSync(pkgJsonPath, "utf-8"));
60711
+ const pkgJsonPath = path5.join(pkg.path, "package.json");
60712
+ const pkgJson = JSON.parse(fs3.readFileSync(pkgJsonPath, "utf-8"));
60669
60713
  let author = "";
60670
60714
  if (typeof pkgJson.author === "string") {
60671
60715
  author = pkgJson.author;
@@ -60690,17 +60734,17 @@ var init_unpacking_service = __esm({
60690
60734
  continue;
60691
60735
  }
60692
60736
  try {
60693
- const sourcePath = path4.join(pkg.path, "dist", TYPE_TO_DIR[item.type], `${item.name}.js`);
60694
- const bundledCode = fs2.readFileSync(sourcePath, "utf-8");
60737
+ const sourcePath = path5.join(pkg.path, "dist", TYPE_TO_DIR[item.type], `${item.name}.js`);
60738
+ const bundledCode = fs3.readFileSync(sourcePath, "utf-8");
60695
60739
  let tsCode = await transformBundledJs(bundledCode);
60696
60740
  if (item.type === "agent") {
60697
60741
  tsCode = await injectAgentMetadata(tsCode, agentMetadata);
60698
60742
  }
60699
- const dir = path4.dirname(item.targetPath);
60700
- if (!fs2.existsSync(dir)) {
60701
- fs2.mkdirSync(dir, { recursive: true });
60743
+ const dir = path5.dirname(item.targetPath);
60744
+ if (!fs3.existsSync(dir)) {
60745
+ fs3.mkdirSync(dir, { recursive: true });
60702
60746
  }
60703
- fs2.writeFileSync(item.targetPath, tsCode);
60747
+ fs3.writeFileSync(item.targetPath, tsCode);
60704
60748
  result.filesGenerated.push(item.targetPath);
60705
60749
  } catch (error) {
60706
60750
  result.warnings.push(
@@ -60789,14 +60833,14 @@ var init_unpacking_service = __esm({
60789
60833
  */
60790
60834
  async resolvePackage(pkgIdentifier, rootDir) {
60791
60835
  if (pkgIdentifier.startsWith("/") || pkgIdentifier.startsWith("./")) {
60792
- const absolutePath = path4.isAbsolute(pkgIdentifier) ? pkgIdentifier : path4.join(rootDir, pkgIdentifier);
60793
- const pkgJsonPath2 = path4.join(absolutePath, "package.json");
60794
- if (fs2.existsSync(pkgJsonPath2)) {
60836
+ const absolutePath = path5.isAbsolute(pkgIdentifier) ? pkgIdentifier : path5.join(rootDir, pkgIdentifier);
60837
+ const pkgJsonPath2 = path5.join(absolutePath, "package.json");
60838
+ if (fs3.existsSync(pkgJsonPath2)) {
60795
60839
  try {
60796
- const pkgJson = JSON.parse(fs2.readFileSync(pkgJsonPath2, "utf-8"));
60840
+ const pkgJson = JSON.parse(fs3.readFileSync(pkgJsonPath2, "utf-8"));
60797
60841
  if (pkgJson.standardagent?.entryAgents) {
60798
60842
  return {
60799
- packageId: pkgJson.name || path4.basename(absolutePath),
60843
+ packageId: pkgJson.name || path5.basename(absolutePath),
60800
60844
  version: pkgJson.version || "0.0.0",
60801
60845
  source: "local",
60802
60846
  path: absolutePath,
@@ -60808,11 +60852,11 @@ var init_unpacking_service = __esm({
60808
60852
  }
60809
60853
  return null;
60810
60854
  }
60811
- const packedDir = path4.join(rootDir, "agents", "packed", pkgIdentifier);
60812
- const pkgJsonPath = path4.join(packedDir, "package.json");
60813
- if (fs2.existsSync(pkgJsonPath)) {
60855
+ const packedDir = path5.join(rootDir, "agents", "packed", pkgIdentifier);
60856
+ const pkgJsonPath = path5.join(packedDir, "package.json");
60857
+ if (fs3.existsSync(pkgJsonPath)) {
60814
60858
  try {
60815
- const pkgJson = JSON.parse(fs2.readFileSync(pkgJsonPath, "utf-8"));
60859
+ const pkgJson = JSON.parse(fs3.readFileSync(pkgJsonPath, "utf-8"));
60816
60860
  if (pkgJson.standardagent?.entryAgents) {
60817
60861
  return {
60818
60862
  packageId: pkgJson.name || pkgIdentifier,
@@ -60853,18 +60897,18 @@ var init_unpacking_service = __esm({
60853
60897
  * Check if a file exists.
60854
60898
  */
60855
60899
  fileExists(filePath) {
60856
- if (fs2.existsSync(filePath)) {
60900
+ if (fs3.existsSync(filePath)) {
60857
60901
  return true;
60858
60902
  }
60859
60903
  const withoutExt = filePath.replace(/\.(ts|js)$/, "");
60860
- return fs2.existsSync(`${withoutExt}.ts`) || fs2.existsSync(`${withoutExt}.js`);
60904
+ return fs3.existsSync(`${withoutExt}.ts`) || fs3.existsSync(`${withoutExt}.js`);
60861
60905
  }
60862
60906
  /**
60863
60907
  * Recursively delete a directory.
60864
60908
  */
60865
60909
  deleteDirectory(dirPath) {
60866
- if (fs2.existsSync(dirPath)) {
60867
- fs2.rmSync(dirPath, { recursive: true, force: true });
60910
+ if (fs3.existsSync(dirPath)) {
60911
+ fs3.rmSync(dirPath, { recursive: true, force: true });
60868
60912
  }
60869
60913
  }
60870
60914
  /**
@@ -60951,8 +60995,8 @@ var init_npm_publish_service = __esm({
60951
60995
  error: "Registry URL must use HTTPS"
60952
60996
  };
60953
60997
  }
60954
- const pkgJsonPath = path4.join(packageDir, "package.json");
60955
- if (!fs2.existsSync(pkgJsonPath)) {
60998
+ const pkgJsonPath = path5.join(packageDir, "package.json");
60999
+ if (!fs3.existsSync(pkgJsonPath)) {
60956
61000
  return {
60957
61001
  success: false,
60958
61002
  output: "",
@@ -60962,7 +61006,7 @@ var init_npm_publish_service = __esm({
60962
61006
  let packageName;
60963
61007
  let version;
60964
61008
  try {
60965
- const pkgJson = JSON.parse(fs2.readFileSync(pkgJsonPath, "utf-8"));
61009
+ const pkgJson = JSON.parse(fs3.readFileSync(pkgJsonPath, "utf-8"));
60966
61010
  packageName = pkgJson.name;
60967
61011
  version = pkgJson.version;
60968
61012
  } catch (e) {
@@ -60972,13 +61016,13 @@ var init_npm_publish_service = __esm({
60972
61016
  error: `Failed to read package.json: ${e instanceof Error ? e.message : String(e)}`
60973
61017
  };
60974
61018
  }
60975
- const npmrcPath = path4.join(packageDir, ".npmrc");
61019
+ const npmrcPath = path5.join(packageDir, ".npmrc");
60976
61020
  const registryHost = new URL(registry).host;
60977
61021
  const npmrcContent = `//${registryHost}/:_authToken=${token}
60978
61022
  registry=${registry}
60979
61023
  `;
60980
61024
  try {
60981
- fs2.writeFileSync(npmrcPath, npmrcContent, { mode: 384 });
61025
+ fs3.writeFileSync(npmrcPath, npmrcContent, { mode: 384 });
60982
61026
  const args = ["publish"];
60983
61027
  if (dryRun) {
60984
61028
  args.push("--dry-run");
@@ -61010,8 +61054,8 @@ registry=${registry}
61010
61054
  };
61011
61055
  } finally {
61012
61056
  try {
61013
- if (fs2.existsSync(npmrcPath)) {
61014
- fs2.unlinkSync(npmrcPath);
61057
+ if (fs3.existsSync(npmrcPath)) {
61058
+ fs3.unlinkSync(npmrcPath);
61015
61059
  }
61016
61060
  } catch {
61017
61061
  }
@@ -61616,7 +61660,7 @@ var index_post_default2 = defineController2(async ({ req, env: env2 }) => {
61616
61660
  });
61617
61661
 
61618
61662
  // src/utils/platform-auth.ts
61619
- var FALLBACK_PLATFORM_ORIGIN = "https://standardagents.ai";
61663
+ var FALLBACK_PLATFORM_ORIGIN = "https://platform.standardagents.ai";
61620
61664
  var SESSION_TTL_SECONDS = 30 * 24 * 60 * 60;
61621
61665
  function platformApiKey(env2) {
61622
61666
  const value = env2.STANDARD_AGENTS_API_KEY;
@@ -61688,7 +61732,7 @@ async function getPlatformIdentity(env2) {
61688
61732
  const endpoint = platformEndpoint(env2);
61689
61733
  const verifiedAccount = await fetchPlatformAccount(endpoint, token);
61690
61734
  const account = verifiedAccount ?? await fallbackAccountForToken(token);
61691
- const username = sanitizeUsername(`standard-agents-${account.slug}`);
61735
+ const username = sanitizeUsername(account.slug);
61692
61736
  return {
61693
61737
  connected: true,
61694
61738
  verified: verifiedAccount !== null,
@@ -61707,16 +61751,26 @@ async function createPlatformLocalSession(env2) {
61707
61751
  if (!identity) {
61708
61752
  return null;
61709
61753
  }
61710
- const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
61711
- const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
61754
+ const agentBuilderNamespace = env2.AGENT_BUILDER;
61755
+ if (!agentBuilderNamespace || typeof agentBuilderNamespace.idFromName !== "function" || typeof agentBuilderNamespace.get !== "function") {
61756
+ throw new Error("Server misconfigured: AGENT_BUILDER Durable Object binding is required for platform auth");
61757
+ }
61758
+ const agentBuilderId = agentBuilderNamespace.idFromName("singleton");
61759
+ const agentBuilder = agentBuilderNamespace.get(agentBuilderId);
61712
61760
  const username = identity.user.username;
61713
61761
  let user = await agentBuilder.getUserByUsername(username);
61714
61762
  if (!user) {
61715
- user = await agentBuilder.createUser({
61716
- username,
61717
- password_hash: await hashPassword(crypto.randomUUID()),
61718
- role: "admin"
61719
- });
61763
+ const legacyUsername = sanitizeUsername(`standard-agents-${identity.account.slug}`);
61764
+ const legacyUser = legacyUsername !== username ? await agentBuilder.getUserByUsername(legacyUsername) : null;
61765
+ if (legacyUser) {
61766
+ user = await agentBuilder.updateUser(legacyUser.id, { username }) ?? legacyUser;
61767
+ } else {
61768
+ user = await agentBuilder.createUser({
61769
+ username,
61770
+ password_hash: await hashPassword(crypto.randomUUID()),
61771
+ role: "admin"
61772
+ });
61773
+ }
61720
61774
  }
61721
61775
  const token = generateUserToken();
61722
61776
  const tokenHash = await hashToken(token);
@@ -61737,12 +61791,91 @@ async function createPlatformLocalSession(env2) {
61737
61791
  platform: identity
61738
61792
  };
61739
61793
  }
61794
+ var STATE_RELATIVE_PATH = path5__default.join(".agents", "bootstrap-session.json");
61795
+ var PROJECT_ROOT_ENV_KEYS = ["INIT_CWD", "PWD", "npm_config_local_prefix"];
61796
+ function readEnvString(env2, key) {
61797
+ if (!env2 || typeof env2 !== "object") return void 0;
61798
+ const value = env2[key];
61799
+ return typeof value === "string" ? value : void 0;
61800
+ }
61801
+ function uniquePaths(paths) {
61802
+ return Array.from(
61803
+ new Set(
61804
+ paths.filter((value) => !!value?.trim()).map((value) => path5__default.resolve(value))
61805
+ )
61806
+ );
61807
+ }
61808
+ function hasSessionCookie(cookieHeader) {
61809
+ const raw = Array.isArray(cookieHeader) ? cookieHeader.join("; ") : cookieHeader || "";
61810
+ return /(?:^|;\s*)session=/.test(raw);
61811
+ }
61812
+ function loadLocalBootstrapSession(projectRoot) {
61813
+ const statePath = path5__default.join(projectRoot, STATE_RELATIVE_PATH);
61814
+ if (!fs3__default.existsSync(statePath)) return null;
61815
+ try {
61816
+ const parsed = JSON.parse(
61817
+ fs3__default.readFileSync(statePath, "utf-8")
61818
+ );
61819
+ if (parsed.version !== 1) return null;
61820
+ if (!parsed.endpoint || !parsed.user?.id || !parsed.account?.id) return null;
61821
+ if (!parsed.session_cookie || typeof parsed.session_cookie !== "string") return null;
61822
+ return parsed;
61823
+ } catch {
61824
+ return null;
61825
+ }
61826
+ }
61827
+ function loadLocalBootstrapSessionFromEnv(env2) {
61828
+ if (!env2) return null;
61829
+ const endpoint = readEnvString(env2, "PLATFORM_ENDPOINT")?.trim();
61830
+ const sessionCookie = readEnvString(env2, "STANDARDAGENTS_BOOTSTRAP_SESSION_COOKIE")?.trim();
61831
+ const userId = readEnvString(env2, "STANDARDAGENTS_ORG_USER_ID")?.trim();
61832
+ const accountId = readEnvString(env2, "STANDARDAGENTS_ORG_ACCOUNT_ID")?.trim();
61833
+ const accountSlug = readEnvString(env2, "STANDARDAGENTS_ORG_SLUG")?.trim();
61834
+ if (!endpoint || !sessionCookie || !userId || !accountId) {
61835
+ return null;
61836
+ }
61837
+ return {
61838
+ version: 1,
61839
+ endpoint,
61840
+ authenticated_at: 0,
61841
+ session_cookie: sessionCookie,
61842
+ user: { id: userId },
61843
+ account: {
61844
+ id: accountId,
61845
+ ...accountSlug ? { slug: accountSlug } : {}
61846
+ }
61847
+ };
61848
+ }
61849
+ function findLocalBootstrapSession(projectRoot, env2) {
61850
+ const envSession = loadLocalBootstrapSessionFromEnv(env2);
61851
+ if (envSession) {
61852
+ return {
61853
+ projectRoot: process.cwd(),
61854
+ session: envSession
61855
+ };
61856
+ }
61857
+ const candidates = uniquePaths([
61858
+ projectRoot,
61859
+ process.cwd(),
61860
+ ...PROJECT_ROOT_ENV_KEYS.map((key) => process.env[key])
61861
+ ]);
61862
+ for (const candidate of candidates) {
61863
+ const session = loadLocalBootstrapSession(candidate);
61864
+ if (session) {
61865
+ return {
61866
+ projectRoot: candidate,
61867
+ session
61868
+ };
61869
+ }
61870
+ }
61871
+ return null;
61872
+ }
61740
61873
 
61741
61874
  // src/api/platform-endpoint.ts
61742
61875
  var ORB_CORE_HOST_PATTERN = /^core\.([a-z0-9-]+)\.orb\.local$/i;
61743
61876
  var LOCAL_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1"]);
61744
61877
  var DEFAULT_DOCKER_PLATFORM_ENDPOINT = "http://platform-admin:8787";
61745
- function readEnvString(env2, key) {
61878
+ function readEnvString2(env2, key) {
61746
61879
  if (!env2 || typeof env2 !== "object") return void 0;
61747
61880
  const value = env2[key];
61748
61881
  return typeof value === "string" ? value : void 0;
@@ -61772,7 +61905,7 @@ function resolvePlatformEndpoint(req, env2) {
61772
61905
  return endpoints[0] ?? null;
61773
61906
  }
61774
61907
  function resolvePlatformEndpointCandidates(req, env2) {
61775
- const configuredEndpoint = normalizeEndpoint(readEnvString(env2, "PLATFORM_ENDPOINT"));
61908
+ const configuredEndpoint = normalizeEndpoint(readEnvString2(env2, "PLATFORM_ENDPOINT"));
61776
61909
  const orbFallbackEndpoint = deriveOrbPlatformEndpoint(req.url);
61777
61910
  const configuredHost = configuredEndpoint ? getHostname(configuredEndpoint) : null;
61778
61911
  const hasLocalConfiguredEndpoint = !!(configuredHost && LOCAL_HOSTS.has(configuredHost));
@@ -61805,10 +61938,12 @@ var platform_endpoint_default = defineController2(async ({ req, env: env2 }) =>
61805
61938
  // src/api/config.get.ts
61806
61939
  var config_get_default = defineController2(async ({ config, env: env2, req }) => {
61807
61940
  const configuredPlatformEndpoint = resolvePlatformEndpoint(req, env2);
61808
- const platformConnected = hasPlatformApiKey(env2) || !!configuredPlatformEndpoint;
61941
+ const platformConnected = hasPlatformApiKey(env2) || !!findLocalBootstrapSession(void 0, env2);
61942
+ const localPassword = typeof env2.SUPER_ADMIN_PASSWORD === "string" && env2.SUPER_ADMIN_PASSWORD.length > 0;
61809
61943
  return Response.json({
61810
61944
  ...config,
61811
61945
  platformConnected,
61946
+ localPassword,
61812
61947
  platformEndpoint: hasPlatformApiKey(env2) ? platformEndpoint(env2) : configuredPlatformEndpoint
61813
61948
  });
61814
61949
  });
@@ -62745,7 +62880,17 @@ var index_get_default2 = defineController2(async ({ req, env: env2 }) => {
62745
62880
  const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
62746
62881
  const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
62747
62882
  const users = await agentBuilder.listUsers();
62748
- return Response.json({ users });
62883
+ let platformUsername = null;
62884
+ const platformEnv = env2;
62885
+ if (hasPlatformApiKey(platformEnv)) {
62886
+ const identity = await getPlatformIdentity(platformEnv).catch(() => null);
62887
+ platformUsername = identity?.user.username ?? null;
62888
+ }
62889
+ const usersWithSource = users.map((user) => ({
62890
+ ...user,
62891
+ source: platformUsername && user.username === platformUsername ? "standard_agents" : "local"
62892
+ }));
62893
+ return Response.json({ users: usersWithSource });
62749
62894
  } catch (error) {
62750
62895
  console.error("List users error:", error);
62751
62896
  return Response.json(
@@ -63740,85 +63885,6 @@ var id_put_default = defineController2(async ({ req, env: env2, params }) => {
63740
63885
  );
63741
63886
  }
63742
63887
  });
63743
- var STATE_RELATIVE_PATH = path4__default.join(".agents", "bootstrap-session.json");
63744
- var PROJECT_ROOT_ENV_KEYS = ["INIT_CWD", "PWD", "npm_config_local_prefix"];
63745
- function readEnvString2(env2, key) {
63746
- if (!env2 || typeof env2 !== "object") return void 0;
63747
- const value = env2[key];
63748
- return typeof value === "string" ? value : void 0;
63749
- }
63750
- function uniquePaths(paths) {
63751
- return Array.from(
63752
- new Set(
63753
- paths.filter((value) => !!value?.trim()).map((value) => path4__default.resolve(value))
63754
- )
63755
- );
63756
- }
63757
- function hasSessionCookie(cookieHeader) {
63758
- const raw = Array.isArray(cookieHeader) ? cookieHeader.join("; ") : cookieHeader || "";
63759
- return /(?:^|;\s*)session=/.test(raw);
63760
- }
63761
- function loadLocalBootstrapSession(projectRoot) {
63762
- const statePath = path4__default.join(projectRoot, STATE_RELATIVE_PATH);
63763
- if (!fs2__default.existsSync(statePath)) return null;
63764
- try {
63765
- const parsed = JSON.parse(
63766
- fs2__default.readFileSync(statePath, "utf-8")
63767
- );
63768
- if (parsed.version !== 1) return null;
63769
- if (!parsed.endpoint || !parsed.user?.id || !parsed.account?.id) return null;
63770
- if (!parsed.session_cookie || typeof parsed.session_cookie !== "string") return null;
63771
- return parsed;
63772
- } catch {
63773
- return null;
63774
- }
63775
- }
63776
- function loadLocalBootstrapSessionFromEnv(env2) {
63777
- if (!env2) return null;
63778
- const endpoint = readEnvString2(env2, "PLATFORM_ENDPOINT")?.trim();
63779
- const sessionCookie = readEnvString2(env2, "STANDARDAGENTS_BOOTSTRAP_SESSION_COOKIE")?.trim();
63780
- const userId = readEnvString2(env2, "STANDARDAGENTS_ORG_USER_ID")?.trim();
63781
- const accountId = readEnvString2(env2, "STANDARDAGENTS_ORG_ACCOUNT_ID")?.trim();
63782
- const accountSlug = readEnvString2(env2, "STANDARDAGENTS_ORG_SLUG")?.trim();
63783
- if (!endpoint || !sessionCookie || !userId || !accountId) {
63784
- return null;
63785
- }
63786
- return {
63787
- version: 1,
63788
- endpoint,
63789
- authenticated_at: 0,
63790
- session_cookie: sessionCookie,
63791
- user: { id: userId },
63792
- account: {
63793
- id: accountId,
63794
- ...accountSlug ? { slug: accountSlug } : {}
63795
- }
63796
- };
63797
- }
63798
- function findLocalBootstrapSession(projectRoot, env2) {
63799
- const envSession = loadLocalBootstrapSessionFromEnv(env2);
63800
- if (envSession) {
63801
- return {
63802
- projectRoot: process.cwd(),
63803
- session: envSession
63804
- };
63805
- }
63806
- const candidates = uniquePaths([
63807
- projectRoot,
63808
- process.cwd(),
63809
- ...PROJECT_ROOT_ENV_KEYS.map((key) => process.env[key])
63810
- ]);
63811
- for (const candidate of candidates) {
63812
- const session = loadLocalBootstrapSession(candidate);
63813
- if (session) {
63814
- return {
63815
- projectRoot: candidate,
63816
- session
63817
- };
63818
- }
63819
- }
63820
- return null;
63821
- }
63822
63888
 
63823
63889
  // src/api/auth/bootstrap.post.ts
63824
63890
  function deriveManagedUsername(platformUserId) {
@@ -63883,6 +63949,12 @@ var bootstrap_post_default = defineController2(async ({ req, env: env2 }) => {
63883
63949
  );
63884
63950
  }
63885
63951
  const username = deriveManagedUsername(platformUserId);
63952
+ if (!env2.AGENT_BUILDER || typeof env2.AGENT_BUILDER.idFromName !== "function") {
63953
+ return Response.json(
63954
+ { error: "Server misconfigured: AGENT_BUILDER Durable Object binding is required for platform auth" },
63955
+ { status: 500 }
63956
+ );
63957
+ }
63886
63958
  const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
63887
63959
  const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
63888
63960
  let user = await agentBuilder.getUserByUsername(username);
@@ -63920,11 +63992,13 @@ var config_get_default2 = defineController2(async ({ req, env: env2 }) => {
63920
63992
  const githubConfigured = !!(env2.GITHUB_CLIENT_ID && env2.GITHUB_CLIENT_SECRET);
63921
63993
  const googleConfigured = !!(env2.GOOGLE_CLIENT_ID && env2.GOOGLE_CLIENT_SECRET);
63922
63994
  const configuredPlatformEndpoint = resolvePlatformEndpoint(req, env2);
63923
- const platformConnected = hasPlatformApiKey(env2) || !!configuredPlatformEndpoint;
63995
+ const platformConnected = hasPlatformApiKey(env2) || !!findLocalBootstrapSession(void 0, env2);
63996
+ const localPassword = typeof env2.SUPER_ADMIN_PASSWORD === "string" && env2.SUPER_ADMIN_PASSWORD.length > 0;
63924
63997
  return {
63925
63998
  github: githubConfigured,
63926
63999
  google: googleConfigured,
63927
64000
  platformConnected,
64001
+ localPassword,
63928
64002
  platformEndpoint: hasPlatformApiKey(env2) ? platformEndpoint(env2) : configuredPlatformEndpoint
63929
64003
  };
63930
64004
  });
@@ -63963,6 +64037,12 @@ var login_post_default = defineController2(async ({ req, env: env2 }) => {
63963
64037
  { status: 400 }
63964
64038
  );
63965
64039
  }
64040
+ if (!env2.AGENT_BUILDER || typeof env2.AGENT_BUILDER.idFromName !== "function") {
64041
+ return Response.json(
64042
+ { error: "Server misconfigured: AGENT_BUILDER Durable Object binding is required for local login" },
64043
+ { status: 500 }
64044
+ );
64045
+ }
63966
64046
  const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
63967
64047
  const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
63968
64048
  const user = await agentBuilder.getUserByUsername(username);
@@ -64139,34 +64219,8 @@ var instance_patch_default = defineController2(async ({ req, env: env2 }) => {
64139
64219
  }
64140
64220
  });
64141
64221
 
64142
- // src/api/models/available.post.ts
64143
- var UUID_LIKE_MODEL_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
64144
- var CLOUDFLARE_PROVIDER_MODEL_ID = /^@cf\//i;
64145
- function isOpaqueModelId(modelId) {
64146
- if (!modelId) return true;
64147
- return UUID_LIKE_MODEL_ID.test(modelId) || CLOUDFLARE_PROVIDER_MODEL_ID.test(modelId);
64148
- }
64149
- function getModelIconLookup(model) {
64150
- if (model.id && !isOpaqueModelId(model.id)) {
64151
- return model.id;
64152
- }
64153
- return model.slug || model.name || model.id;
64154
- }
64155
- function getExecutableModelId(provider, model) {
64156
- if (model.id && !isOpaqueModelId(model.id)) {
64157
- return model.id;
64158
- }
64159
- if (provider === "cloudflare") {
64160
- const publicCloudflareId = [model.name, model.slug].find((value) => typeof value === "string" && value.length > 0 && value.includes("/"));
64161
- if (publicCloudflareId) {
64162
- return publicCloudflareId.startsWith("@cf/") ? publicCloudflareId : `@cf/${publicCloudflareId.replace(/^@cf\//, "")}`;
64163
- }
64164
- }
64165
- return model.slug || model.name || model.id;
64166
- }
64167
- function getProviderModelIconUrl(provider, model) {
64168
- return `/api/providers/${encodeURIComponent(provider)}/icon?model=${encodeURIComponent(getModelIconLookup(model))}`;
64169
- }
64222
+ // src/api/models/_provider-config.ts
64223
+ init_platform_routing();
64170
64224
  var PROVIDER_CONFIGS = {
64171
64225
  cloudflare: {
64172
64226
  envKey: "CLOUDFLARE_API_TOKEN",
@@ -64175,54 +64229,102 @@ var PROVIDER_CONFIGS = {
64175
64229
  accountId: env2.CLOUDFLARE_ACCOUNT_ID,
64176
64230
  baseUrl: env2.CLOUDFLARE_ACCOUNT_ID ? `https://api.cloudflare.com/client/v4/accounts/${env2.CLOUDFLARE_ACCOUNT_ID}/ai/v1` : void 0
64177
64231
  }),
64178
- getFactory: async () => {
64232
+ importFactory: async () => {
64179
64233
  const { cloudflare: cloudflare2 } = await Promise.resolve().then(() => (init_src(), src_exports));
64180
64234
  return cloudflare2;
64181
64235
  }
64182
64236
  },
64183
64237
  cerebras: {
64184
64238
  envKey: "CEREBRAS_API_KEY",
64185
- getFactory: async () => {
64239
+ importFactory: async () => {
64186
64240
  const { cerebras: cerebras2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
64187
64241
  return cerebras2;
64188
64242
  }
64189
64243
  },
64190
64244
  google: {
64191
64245
  envKey: "GOOGLE_API_KEY",
64192
- getFactory: async () => {
64246
+ importFactory: async () => {
64193
64247
  const { google: google2 } = await Promise.resolve().then(() => (init_dist2(), dist_exports2));
64194
64248
  return google2;
64195
64249
  }
64196
64250
  },
64197
64251
  groq: {
64198
64252
  envKey: "GROQ_API_KEY",
64199
- getFactory: async () => {
64253
+ importFactory: async () => {
64200
64254
  const { groq: groq2 } = await Promise.resolve().then(() => (init_dist3(), dist_exports3));
64201
64255
  return groq2;
64202
64256
  }
64203
64257
  },
64204
64258
  openai: {
64205
64259
  envKey: "OPENAI_API_KEY",
64206
- getFactory: async () => {
64260
+ importFactory: async () => {
64207
64261
  const { openai: openai2 } = await Promise.resolve().then(() => (init_dist4(), dist_exports4));
64208
64262
  return openai2;
64209
64263
  }
64210
64264
  },
64211
64265
  openrouter: {
64212
64266
  envKey: "OPENROUTER_API_KEY",
64213
- getFactory: async () => {
64267
+ importFactory: async () => {
64214
64268
  const { openrouter: openrouter2 } = await Promise.resolve().then(() => (init_dist5(), dist_exports5));
64215
64269
  return openrouter2;
64216
64270
  }
64217
64271
  },
64218
64272
  xai: {
64219
64273
  envKey: "XAI_API_KEY",
64220
- getFactory: async () => {
64274
+ importFactory: async () => {
64221
64275
  const { xai: xai3 } = await Promise.resolve().then(() => (init_dist10(), dist_exports6));
64222
64276
  return xai3;
64223
64277
  }
64224
64278
  }
64225
64279
  };
64280
+ function resolveProviderClientConfig(provider, env2) {
64281
+ const config = PROVIDER_CONFIGS[provider];
64282
+ if (!config) return null;
64283
+ const apiKey = env2[config.envKey];
64284
+ if (apiKey) {
64285
+ return {
64286
+ providerConfig: config.getConfig?.(env2, apiKey) ?? { apiKey },
64287
+ viaPlatform: false
64288
+ };
64289
+ }
64290
+ const routing = resolvePlatformRouting(provider, env2);
64291
+ if (routing) {
64292
+ return {
64293
+ providerConfig: { apiKey: routing.apiKey, baseUrl: routing.baseUrl },
64294
+ viaPlatform: true
64295
+ };
64296
+ }
64297
+ return null;
64298
+ }
64299
+
64300
+ // src/api/models/available.post.ts
64301
+ var UUID_LIKE_MODEL_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
64302
+ var CLOUDFLARE_PROVIDER_MODEL_ID = /^@cf\//i;
64303
+ function isOpaqueModelId(modelId) {
64304
+ if (!modelId) return true;
64305
+ return UUID_LIKE_MODEL_ID.test(modelId) || CLOUDFLARE_PROVIDER_MODEL_ID.test(modelId);
64306
+ }
64307
+ function getModelIconLookup(model) {
64308
+ if (model.id && !isOpaqueModelId(model.id)) {
64309
+ return model.id;
64310
+ }
64311
+ return model.slug || model.name || model.id;
64312
+ }
64313
+ function getExecutableModelId(provider, model) {
64314
+ if (model.id && !isOpaqueModelId(model.id)) {
64315
+ return model.id;
64316
+ }
64317
+ if (provider === "cloudflare") {
64318
+ const publicCloudflareId = [model.name, model.slug].find((value) => typeof value === "string" && value.length > 0 && value.includes("/"));
64319
+ if (publicCloudflareId) {
64320
+ return publicCloudflareId.startsWith("@cf/") ? publicCloudflareId : `@cf/${publicCloudflareId.replace(/^@cf\//, "")}`;
64321
+ }
64322
+ }
64323
+ return model.slug || model.name || model.id;
64324
+ }
64325
+ function getProviderModelIconUrl(provider, model) {
64326
+ return `/api/providers/${encodeURIComponent(provider)}/icon?model=${encodeURIComponent(getModelIconLookup(model))}`;
64327
+ }
64226
64328
  var available_post_default = defineController2(async ({ req, env: env2 }) => {
64227
64329
  const body = await req.json().catch(() => ({}));
64228
64330
  const {
@@ -64242,17 +64344,16 @@ var available_post_default = defineController2(async ({ req, env: env2 }) => {
64242
64344
  { status: 400 }
64243
64345
  );
64244
64346
  }
64245
- const apiKey = env2[config.envKey];
64246
- if (!apiKey && provider !== "openrouter") {
64347
+ const resolved = resolveProviderClientConfig(provider, env2);
64348
+ if (!resolved && provider !== "openrouter") {
64247
64349
  return Response.json(
64248
- { error: `API key not configured for ${provider}. Set ${config.envKey} environment variable.` },
64350
+ { error: `API key not configured for ${provider}. Set ${config.envKey} or STANDARD_AGENTS_API_KEY.` },
64249
64351
  { status: 401 }
64250
64352
  );
64251
64353
  }
64252
64354
  try {
64253
- const factory = await config.getFactory();
64254
- const providerConfig = config.getConfig?.(env2, apiKey || "") || { apiKey: apiKey || "" };
64255
- const providerInstance = factory(providerConfig);
64355
+ const factory = await config.importFactory();
64356
+ const providerInstance = factory(resolved?.providerConfig ?? { apiKey: "" });
64256
64357
  if (!providerInstance.getModels && !providerInstance.getModelsPage) {
64257
64358
  return Response.json({ models: [], hasNextPage: false });
64258
64359
  }
@@ -64295,62 +64396,6 @@ var available_post_default = defineController2(async ({ req, env: env2 }) => {
64295
64396
  });
64296
64397
 
64297
64398
  // src/api/models/capabilities.post.ts
64298
- var PROVIDER_CONFIGS2 = {
64299
- cloudflare: {
64300
- envKey: "CLOUDFLARE_API_TOKEN",
64301
- getConfig: (env2, apiKey) => ({
64302
- apiKey,
64303
- accountId: env2.CLOUDFLARE_ACCOUNT_ID,
64304
- baseUrl: env2.CLOUDFLARE_ACCOUNT_ID ? `https://api.cloudflare.com/client/v4/accounts/${env2.CLOUDFLARE_ACCOUNT_ID}/ai/v1` : void 0
64305
- }),
64306
- getFactory: async () => {
64307
- const { cloudflare: cloudflare2 } = await Promise.resolve().then(() => (init_src(), src_exports));
64308
- return cloudflare2;
64309
- }
64310
- },
64311
- cerebras: {
64312
- envKey: "CEREBRAS_API_KEY",
64313
- getFactory: async () => {
64314
- const { cerebras: cerebras2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
64315
- return cerebras2;
64316
- }
64317
- },
64318
- google: {
64319
- envKey: "GOOGLE_API_KEY",
64320
- getFactory: async () => {
64321
- const { google: google2 } = await Promise.resolve().then(() => (init_dist2(), dist_exports2));
64322
- return google2;
64323
- }
64324
- },
64325
- groq: {
64326
- envKey: "GROQ_API_KEY",
64327
- getFactory: async () => {
64328
- const { groq: groq2 } = await Promise.resolve().then(() => (init_dist3(), dist_exports3));
64329
- return groq2;
64330
- }
64331
- },
64332
- openai: {
64333
- envKey: "OPENAI_API_KEY",
64334
- getFactory: async () => {
64335
- const { openai: openai2 } = await Promise.resolve().then(() => (init_dist4(), dist_exports4));
64336
- return openai2;
64337
- }
64338
- },
64339
- openrouter: {
64340
- envKey: "OPENROUTER_API_KEY",
64341
- getFactory: async () => {
64342
- const { openrouter: openrouter2 } = await Promise.resolve().then(() => (init_dist5(), dist_exports5));
64343
- return openrouter2;
64344
- }
64345
- },
64346
- xai: {
64347
- envKey: "XAI_API_KEY",
64348
- getFactory: async () => {
64349
- const { xai: xai3 } = await Promise.resolve().then(() => (init_dist10(), dist_exports6));
64350
- return xai3;
64351
- }
64352
- }
64353
- };
64354
64399
  var capabilities_post_default = defineController2(async ({ req, env: env2 }) => {
64355
64400
  const body = await req.json().catch(() => ({}));
64356
64401
  const { provider, modelId } = body;
@@ -64360,24 +64405,23 @@ var capabilities_post_default = defineController2(async ({ req, env: env2 }) =>
64360
64405
  if (!modelId) {
64361
64406
  return Response.json({ error: "Model ID is required" }, { status: 400 });
64362
64407
  }
64363
- const config = PROVIDER_CONFIGS2[provider];
64408
+ const config = PROVIDER_CONFIGS[provider];
64364
64409
  if (!config) {
64365
64410
  return Response.json(
64366
- { error: `Unknown provider: ${provider}. Supported: ${Object.keys(PROVIDER_CONFIGS2).join(", ")}` },
64411
+ { error: `Unknown provider: ${provider}. Supported: ${Object.keys(PROVIDER_CONFIGS).join(", ")}` },
64367
64412
  { status: 400 }
64368
64413
  );
64369
64414
  }
64370
- const apiKey = env2[config.envKey];
64371
- if (!apiKey && provider !== "openrouter") {
64415
+ const resolved = resolveProviderClientConfig(provider, env2);
64416
+ if (!resolved && provider !== "openrouter") {
64372
64417
  return Response.json(
64373
- { error: `API key not configured for ${provider}. Set ${config.envKey} environment variable.` },
64418
+ { error: `API key not configured for ${provider}. Set ${config.envKey} or STANDARD_AGENTS_API_KEY.` },
64374
64419
  { status: 401 }
64375
64420
  );
64376
64421
  }
64377
64422
  try {
64378
- const factory = await config.getFactory();
64379
- const providerConfig = config.getConfig?.(env2, apiKey || "") || { apiKey: apiKey || "" };
64380
- const providerInstance = factory(providerConfig);
64423
+ const factory = await config.importFactory();
64424
+ const providerInstance = factory(resolved?.providerConfig ?? { apiKey: "" });
64381
64425
  if (!providerInstance.getModelCapabilities) {
64382
64426
  return Response.json({ capabilities: null });
64383
64427
  }
@@ -65515,13 +65559,25 @@ var tenvs_get_default = defineController2(async ({ params, agents, prompts, tool
65515
65559
  });
65516
65560
 
65517
65561
  // src/api/models/[name]/curl-data.get.ts
65562
+ init_platform_routing();
65518
65563
  var PROVIDER_ENDPOINTS = {
65519
65564
  cloudflare: (env2) => env2.CLOUDFLARE_ACCOUNT_ID ? `https://api.cloudflare.com/client/v4/accounts/${env2.CLOUDFLARE_ACCOUNT_ID}/ai/v1/chat/completions` : "https://api.cloudflare.com/client/v4/accounts/{CLOUDFLARE_ACCOUNT_ID}/ai/v1/chat/completions",
65520
65565
  cerebras: () => "https://api.cerebras.ai/v1/chat/completions",
65521
65566
  openai: () => "https://api.openai.com/v1/responses",
65522
65567
  openrouter: () => "https://openrouter.ai/api/v1/responses",
65523
65568
  anthropic: () => "https://api.anthropic.com/v1/messages",
65524
- google: () => "https://generativelanguage.googleapis.com/v1beta/models"
65569
+ google: () => "https://generativelanguage.googleapis.com/v1beta/models",
65570
+ groq: () => "https://api.groq.com/openai/v1/chat/completions",
65571
+ xai: () => "https://api.x.ai/v1/chat/completions"
65572
+ };
65573
+ var PLATFORM_ENDPOINT_PATHS = {
65574
+ cloudflare: "/chat/completions",
65575
+ cerebras: "/chat/completions",
65576
+ openai: "/responses",
65577
+ openrouter: "/responses",
65578
+ google: "/v1beta/models",
65579
+ groq: "/chat/completions",
65580
+ xai: "/chat/completions"
65525
65581
  };
65526
65582
  var API_KEY_ENV_VARS = {
65527
65583
  cloudflare: ["CLOUDFLARE_API_TOKEN", "CLOUDFLARE_ACCOUNT_ID"],
@@ -65529,7 +65585,9 @@ var API_KEY_ENV_VARS = {
65529
65585
  openai: ["OPENAI_API_KEY"],
65530
65586
  openrouter: ["OPENROUTER_API_KEY"],
65531
65587
  anthropic: ["ANTHROPIC_API_KEY"],
65532
- google: ["GOOGLE_API_KEY"]
65588
+ google: ["GOOGLE_API_KEY"],
65589
+ groq: ["GROQ_API_KEY"],
65590
+ xai: ["XAI_API_KEY"]
65533
65591
  };
65534
65592
  var curl_data_get_default = defineController2(async ({ params, models, env: env2 }) => {
65535
65593
  const name15 = params.name ? decodeURIComponent(params.name) : void 0;
@@ -65549,21 +65607,30 @@ var curl_data_get_default = defineController2(async ({ params, models, env: env2
65549
65607
  if (!providerName) {
65550
65608
  return Response.json({ error: "Could not determine provider" }, { status: 500 });
65551
65609
  }
65552
- const envVarNames = API_KEY_ENV_VARS[providerName.toLowerCase()] || [];
65610
+ const provider = providerName.toLowerCase();
65611
+ const envVarNames = API_KEY_ENV_VARS[provider] || [];
65553
65612
  const apiKeyEnvName = envVarNames[0];
65554
65613
  const apiKey = apiKeyEnvName ? env2[apiKeyEnvName] : null;
65555
- if (!apiKey) {
65614
+ if (apiKey) {
65615
+ const endpointResolver = PROVIDER_ENDPOINTS[provider];
65616
+ const endpoint = endpointResolver ? endpointResolver(env2) : `https://api.${provider}.com/v1/chat/completions`;
65556
65617
  return Response.json({
65557
- error: `API key not found for provider: ${providerName}. Set ${apiKeyEnvName} in your environment.`
65558
- }, { status: 500 });
65618
+ endpoint,
65619
+ api_key: apiKey,
65620
+ sdk: provider
65621
+ });
65622
+ }
65623
+ const routing = resolvePlatformRouting(provider, env2);
65624
+ if (routing) {
65625
+ return Response.json({
65626
+ endpoint: `${routing.baseUrl}${PLATFORM_ENDPOINT_PATHS[provider] ?? "/chat/completions"}`,
65627
+ api_key: routing.apiKey,
65628
+ sdk: provider
65629
+ });
65559
65630
  }
65560
- const endpointResolver = PROVIDER_ENDPOINTS[providerName.toLowerCase()];
65561
- const endpoint = endpointResolver ? endpointResolver(env2) : `https://api.${providerName.toLowerCase()}.com/v1/chat/completions`;
65562
65631
  return Response.json({
65563
- endpoint,
65564
- api_key: apiKey,
65565
- sdk: providerName.toLowerCase()
65566
- });
65632
+ error: `API key not found for provider: ${providerName}. Set ${apiKeyEnvName} or STANDARD_AGENTS_API_KEY in your environment.`
65633
+ }, { status: 500 });
65567
65634
  } catch (error) {
65568
65635
  console.error(`Error loading model ${name15}:`, error);
65569
65636
  return Response.json(
@@ -65825,7 +65892,7 @@ var tenvs_get_default2 = defineController2(async ({ params, prompts, agents, too
65825
65892
  });
65826
65893
 
65827
65894
  // src/api/providers/[name]/icon.get.ts
65828
- var PROVIDER_CONFIGS3 = {
65895
+ var PROVIDER_CONFIGS2 = {
65829
65896
  cloudflare: {
65830
65897
  getFactory: async () => {
65831
65898
  const { cloudflare: cloudflare2 } = await Promise.resolve().then(() => (init_src(), src_exports));
@@ -65890,7 +65957,7 @@ var icon_get_default = defineController2(async ({ params, url }) => {
65890
65957
  if (!providerName) {
65891
65958
  return Response.json({ error: "Provider name is required" }, { status: 400 });
65892
65959
  }
65893
- const config = PROVIDER_CONFIGS3[providerName];
65960
+ const config = PROVIDER_CONFIGS2[providerName];
65894
65961
  if (!config) {
65895
65962
  return new Response(placeholderSvg(providerName), {
65896
65963
  headers: { "Content-Type": "image/svg+xml", "Cache-Control": ICON_CACHE_CONTROL }