@standardagents/builder 0.15.3 → 0.17.0-next.a4b7340
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/built-in-routes.js +362 -281
- package/dist/built-in-routes.js.map +1 -1
- package/dist/client/ApiKeysView.js +1 -1
- package/dist/client/CenteredContentView.js +1 -1
- package/dist/client/CompositionView.js +1 -1
- package/dist/client/ConfirmDialog.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/client/CopyButton.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/client/DataTable.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/client/JsonViewer.js +1 -1
- package/dist/client/LoginView.js +1 -1
- package/dist/client/Modal.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/client/ModelModal.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/client/ModelsView.js +1 -1
- package/dist/client/PromptEditView.js +1 -1
- package/dist/client/PromptModal.js +1 -1
- package/dist/client/PromptsView.js +1 -1
- package/dist/client/ProvidersView.js +2 -2
- package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/client/ToolsView.js +1 -1
- package/dist/client/UsersView.js +1 -1
- package/dist/client/VariablesView.js +1 -1
- package/dist/client/assets/index.css +1 -1
- package/dist/client/index.js +3 -3
- package/dist/{discovery-DVviz3By.d.ts → discovery-DiMJWisl.d.ts} +1 -1
- package/dist/{index-BwqQtJ4r.d.ts → index-EaxysUHv.d.ts} +2 -5
- package/dist/index.d.ts +116 -3402
- package/dist/index.js +190 -324
- package/dist/index.js.map +1 -1
- package/dist/packing.d.ts +3 -3
- package/dist/plugin.d.ts +5 -4
- package/dist/plugin.js +143 -78
- package/dist/plugin.js.map +1 -1
- package/dist/runtime.d.ts +3124 -0
- package/dist/runtime.js +21218 -0
- package/dist/runtime.js.map +1 -0
- package/dist/test.d.ts +2 -2
- package/dist/{types-DH3Egc5l.d.ts → types-Bpe7IANZ.d.ts} +1 -1
- package/package.json +10 -9
package/dist/built-in-routes.js
CHANGED
|
@@ -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
|
|
8
|
-
import
|
|
9
|
-
import * as
|
|
10
|
-
import
|
|
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;
|
|
@@ -950,6 +977,19 @@ var init_ProviderRegistry = __esm({
|
|
|
950
977
|
return this.cacheAndReturn(modelName, overrideProvider, modelDef, overrideFingerprint);
|
|
951
978
|
}
|
|
952
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);
|
|
990
|
+
}
|
|
991
|
+
return this.cacheAndReturn(modelName, providerFactory(config), modelDef, fingerprint);
|
|
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
995
|
buildResult(provider, modelDef) {
|
|
@@ -962,7 +1002,7 @@ var init_ProviderRegistry = __esm({
|
|
|
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
|
});
|
|
@@ -9189,7 +9229,7 @@ function runCodeInDynamicWorker(params) {
|
|
|
9189
9229
|
durationMs: Date.now() - startedAt,
|
|
9190
9230
|
error: {
|
|
9191
9231
|
name: "MissingWorkerLoader",
|
|
9192
|
-
message: `ThreadState.runCode requires the ${WORKER_LOADER_BINDING} Worker Loader binding. Run the AgentBuilder scaffold/init step or
|
|
9232
|
+
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
9233
|
}
|
|
9194
9234
|
};
|
|
9195
9235
|
}
|
|
@@ -12783,6 +12823,9 @@ var init_CloudflareProvider = __esm({
|
|
|
12783
12823
|
if (accountScopedMatch) {
|
|
12784
12824
|
return `${accountScopedMatch[1]}/ai/models/search`;
|
|
12785
12825
|
}
|
|
12826
|
+
if (baseUrl.endsWith("/ai/v1")) {
|
|
12827
|
+
return `${baseUrl.slice(0, -"/ai/v1".length)}/ai/models/search`;
|
|
12828
|
+
}
|
|
12786
12829
|
throw new ProviderError(
|
|
12787
12830
|
"Cloudflare model discovery requires CLOUDFLARE_ACCOUNT_ID or an account-scoped baseUrl.",
|
|
12788
12831
|
"invalid_request"
|
|
@@ -24892,7 +24935,7 @@ async function getBlobStat(file) {
|
|
|
24892
24935
|
function sleep(ms) {
|
|
24893
24936
|
return new Promise((resolvePromise) => setTimeout(resolvePromise, ms));
|
|
24894
24937
|
}
|
|
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,
|
|
24938
|
+
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
24939
|
var init_web = __esm({
|
|
24897
24940
|
"../../node_modules/.pnpm/@google+genai@1.47.0/node_modules/@google/genai/dist/web/index.mjs"() {
|
|
24898
24941
|
import_p_retry = __toESM(require_p_retry());
|
|
@@ -30434,7 +30477,7 @@ ${underline}`);
|
|
|
30434
30477
|
}
|
|
30435
30478
|
return path10;
|
|
30436
30479
|
});
|
|
30437
|
-
|
|
30480
|
+
path2 = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
|
|
30438
30481
|
BaseInteractions = class extends APIResource {
|
|
30439
30482
|
create(params, options) {
|
|
30440
30483
|
var _a16;
|
|
@@ -30445,7 +30488,7 @@ ${underline}`);
|
|
|
30445
30488
|
if ("agent" in body && "generation_config" in body) {
|
|
30446
30489
|
throw new GeminiNextGenAPIClientError(`Invalid request: specified \`agent\` and \`generation_config\`. If specifying \`agent\`, use \`agent_config\`.`);
|
|
30447
30490
|
}
|
|
30448
|
-
return this._client.post(
|
|
30491
|
+
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
30492
|
}
|
|
30450
30493
|
/**
|
|
30451
30494
|
* Deletes the interaction by id.
|
|
@@ -30459,7 +30502,7 @@ ${underline}`);
|
|
|
30459
30502
|
*/
|
|
30460
30503
|
delete(id, params = {}, options) {
|
|
30461
30504
|
const { api_version = this._client.apiVersion } = params !== null && params !== void 0 ? params : {};
|
|
30462
|
-
return this._client.delete(
|
|
30505
|
+
return this._client.delete(path2`/${api_version}/interactions/${id}`, options);
|
|
30463
30506
|
}
|
|
30464
30507
|
/**
|
|
30465
30508
|
* Cancels an interaction by id. This only applies to background interactions that are still running.
|
|
@@ -30473,12 +30516,12 @@ ${underline}`);
|
|
|
30473
30516
|
*/
|
|
30474
30517
|
cancel(id, params = {}, options) {
|
|
30475
30518
|
const { api_version = this._client.apiVersion } = params !== null && params !== void 0 ? params : {};
|
|
30476
|
-
return this._client.post(
|
|
30519
|
+
return this._client.post(path2`/${api_version}/interactions/${id}/cancel`, options);
|
|
30477
30520
|
}
|
|
30478
30521
|
get(id, params = {}, options) {
|
|
30479
30522
|
var _a16;
|
|
30480
30523
|
const _b16 = params !== null && params !== void 0 ? params : {}, { api_version = this._client.apiVersion } = _b16, query = __rest(_b16, ["api_version"]);
|
|
30481
|
-
return this._client.get(
|
|
30524
|
+
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
30525
|
}
|
|
30483
30526
|
};
|
|
30484
30527
|
BaseInteractions._key = Object.freeze(["interactions"]);
|
|
@@ -33811,7 +33854,7 @@ var init_audio = __esm({
|
|
|
33811
33854
|
function encodeURIPath2(str) {
|
|
33812
33855
|
return str.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
|
|
33813
33856
|
}
|
|
33814
|
-
var EMPTY2, createPathTagFunction2,
|
|
33857
|
+
var EMPTY2, createPathTagFunction2, path3;
|
|
33815
33858
|
var init_path = __esm({
|
|
33816
33859
|
"../../node_modules/.pnpm/groq-sdk@1.1.2/node_modules/groq-sdk/internal/utils/path.mjs"() {
|
|
33817
33860
|
init_error();
|
|
@@ -33864,7 +33907,7 @@ ${underline}`);
|
|
|
33864
33907
|
}
|
|
33865
33908
|
return path10;
|
|
33866
33909
|
};
|
|
33867
|
-
|
|
33910
|
+
path3 = /* @__PURE__ */ createPathTagFunction2(encodeURIPath2);
|
|
33868
33911
|
}
|
|
33869
33912
|
});
|
|
33870
33913
|
|
|
@@ -33886,7 +33929,7 @@ var init_batches = __esm({
|
|
|
33886
33929
|
* Retrieves a batch.
|
|
33887
33930
|
*/
|
|
33888
33931
|
retrieve(batchID, options) {
|
|
33889
|
-
return this._client.get(
|
|
33932
|
+
return this._client.get(path3`/openai/v1/batches/${batchID}`, options);
|
|
33890
33933
|
}
|
|
33891
33934
|
/**
|
|
33892
33935
|
* List your organization's batches.
|
|
@@ -33898,7 +33941,7 @@ var init_batches = __esm({
|
|
|
33898
33941
|
* Cancels a batch.
|
|
33899
33942
|
*/
|
|
33900
33943
|
cancel(batchID, options) {
|
|
33901
|
-
return this._client.post(
|
|
33944
|
+
return this._client.post(path3`/openai/v1/batches/${batchID}/cancel`, options);
|
|
33902
33945
|
}
|
|
33903
33946
|
};
|
|
33904
33947
|
}
|
|
@@ -34003,13 +34046,13 @@ var init_files2 = __esm({
|
|
|
34003
34046
|
* Delete a file.
|
|
34004
34047
|
*/
|
|
34005
34048
|
delete(fileID, options) {
|
|
34006
|
-
return this._client.delete(
|
|
34049
|
+
return this._client.delete(path3`/openai/v1/files/${fileID}`, options);
|
|
34007
34050
|
}
|
|
34008
34051
|
/**
|
|
34009
34052
|
* Returns the contents of the specified file.
|
|
34010
34053
|
*/
|
|
34011
34054
|
content(fileID, options) {
|
|
34012
|
-
return this._client.get(
|
|
34055
|
+
return this._client.get(path3`/openai/v1/files/${fileID}/content`, {
|
|
34013
34056
|
...options,
|
|
34014
34057
|
headers: buildHeaders2([{ Accept: "application/octet-stream" }, options?.headers]),
|
|
34015
34058
|
__binaryResponse: true
|
|
@@ -34019,7 +34062,7 @@ var init_files2 = __esm({
|
|
|
34019
34062
|
* Returns information about a file.
|
|
34020
34063
|
*/
|
|
34021
34064
|
info(fileID, options) {
|
|
34022
|
-
return this._client.get(
|
|
34065
|
+
return this._client.get(path3`/openai/v1/files/${fileID}`, options);
|
|
34023
34066
|
}
|
|
34024
34067
|
};
|
|
34025
34068
|
}
|
|
@@ -34036,7 +34079,7 @@ var init_models = __esm({
|
|
|
34036
34079
|
* Get a specific model
|
|
34037
34080
|
*/
|
|
34038
34081
|
retrieve(model, options) {
|
|
34039
|
-
return this._client.get(
|
|
34082
|
+
return this._client.get(path3`/openai/v1/models/${model}`, options);
|
|
34040
34083
|
}
|
|
34041
34084
|
/**
|
|
34042
34085
|
* get all available models
|
|
@@ -34048,7 +34091,7 @@ var init_models = __esm({
|
|
|
34048
34091
|
* Delete a model
|
|
34049
34092
|
*/
|
|
34050
34093
|
delete(model, options) {
|
|
34051
|
-
return this._client.delete(
|
|
34094
|
+
return this._client.delete(path3`/openai/v1/models/${model}`, options);
|
|
34052
34095
|
}
|
|
34053
34096
|
};
|
|
34054
34097
|
}
|
|
@@ -58422,7 +58465,7 @@ var init_metadata_service = __esm({
|
|
|
58422
58465
|
* @param agentsDir - Path to the agents/ directory
|
|
58423
58466
|
*/
|
|
58424
58467
|
constructor(agentsDir) {
|
|
58425
|
-
this.metadataDir =
|
|
58468
|
+
this.metadataDir = path5.join(agentsDir, ".standardagent");
|
|
58426
58469
|
}
|
|
58427
58470
|
/**
|
|
58428
58471
|
* Read metadata for an agent.
|
|
@@ -58432,11 +58475,11 @@ var init_metadata_service = __esm({
|
|
|
58432
58475
|
*/
|
|
58433
58476
|
async read(agentName) {
|
|
58434
58477
|
const filePath = this.getMetadataPath(agentName);
|
|
58435
|
-
if (!
|
|
58478
|
+
if (!fs3.existsSync(filePath)) {
|
|
58436
58479
|
return null;
|
|
58437
58480
|
}
|
|
58438
58481
|
try {
|
|
58439
|
-
const content =
|
|
58482
|
+
const content = fs3.readFileSync(filePath, "utf-8");
|
|
58440
58483
|
return JSON.parse(content);
|
|
58441
58484
|
} catch {
|
|
58442
58485
|
return null;
|
|
@@ -58449,11 +58492,11 @@ var init_metadata_service = __esm({
|
|
|
58449
58492
|
* @param metadata - Metadata to write
|
|
58450
58493
|
*/
|
|
58451
58494
|
async write(agentName, metadata) {
|
|
58452
|
-
if (!
|
|
58453
|
-
|
|
58495
|
+
if (!fs3.existsSync(this.metadataDir)) {
|
|
58496
|
+
fs3.mkdirSync(this.metadataDir, { recursive: true });
|
|
58454
58497
|
}
|
|
58455
58498
|
const filePath = this.getMetadataPath(agentName);
|
|
58456
|
-
|
|
58499
|
+
fs3.writeFileSync(filePath, JSON.stringify(metadata, null, 2));
|
|
58457
58500
|
}
|
|
58458
58501
|
/**
|
|
58459
58502
|
* Delete metadata for an agent.
|
|
@@ -58462,8 +58505,8 @@ var init_metadata_service = __esm({
|
|
|
58462
58505
|
*/
|
|
58463
58506
|
async delete(agentName) {
|
|
58464
58507
|
const filePath = this.getMetadataPath(agentName);
|
|
58465
|
-
if (
|
|
58466
|
-
|
|
58508
|
+
if (fs3.existsSync(filePath)) {
|
|
58509
|
+
fs3.unlinkSync(filePath);
|
|
58467
58510
|
}
|
|
58468
58511
|
}
|
|
58469
58512
|
/**
|
|
@@ -58544,7 +58587,7 @@ var init_metadata_service = __esm({
|
|
|
58544
58587
|
* Get the file path for an agent's metadata.
|
|
58545
58588
|
*/
|
|
58546
58589
|
getMetadataPath(agentName) {
|
|
58547
|
-
return
|
|
58590
|
+
return path5.join(this.metadataDir, `${agentName}.json`);
|
|
58548
58591
|
}
|
|
58549
58592
|
};
|
|
58550
58593
|
}
|
|
@@ -58931,9 +58974,9 @@ var init_packing_service = __esm({
|
|
|
58931
58974
|
* @returns Version specifier (e.g., '^1.2.3') or '*' if not found
|
|
58932
58975
|
*/
|
|
58933
58976
|
resolvePackageVersion(pkgName, rootDir) {
|
|
58934
|
-
const pkgJsonPath =
|
|
58977
|
+
const pkgJsonPath = path5.join(rootDir, "node_modules", pkgName, "package.json");
|
|
58935
58978
|
try {
|
|
58936
|
-
const pkgJson = JSON.parse(
|
|
58979
|
+
const pkgJson = JSON.parse(fs3.readFileSync(pkgJsonPath, "utf-8"));
|
|
58937
58980
|
return `^${pkgJson.version}`;
|
|
58938
58981
|
} catch {
|
|
58939
58982
|
return "*";
|
|
@@ -58950,7 +58993,7 @@ var init_packing_service = __esm({
|
|
|
58950
58993
|
* @returns Analysis result with all discovered constituents
|
|
58951
58994
|
*/
|
|
58952
58995
|
async analyzeAgent(agentName, rootDir) {
|
|
58953
|
-
const agentsDir =
|
|
58996
|
+
const agentsDir = path5.join(rootDir, "agents");
|
|
58954
58997
|
const analysis = {
|
|
58955
58998
|
agent: agentName,
|
|
58956
58999
|
primaryPrompt: "",
|
|
@@ -58974,7 +59017,7 @@ var init_packing_service = __esm({
|
|
|
58974
59017
|
warnings: [],
|
|
58975
59018
|
errors: []
|
|
58976
59019
|
};
|
|
58977
|
-
const agentFilePath = await this.findFile(
|
|
59020
|
+
const agentFilePath = await this.findFile(path5.join(agentsDir, "agents"), agentName);
|
|
58978
59021
|
if (!agentFilePath) {
|
|
58979
59022
|
analysis.errors.push(`Agent file not found: ${agentName}`);
|
|
58980
59023
|
return analysis;
|
|
@@ -58985,7 +59028,7 @@ var init_packing_service = __esm({
|
|
|
58985
59028
|
discoveredVia: "static",
|
|
58986
59029
|
sharedWith: []
|
|
58987
59030
|
});
|
|
58988
|
-
const agentSource =
|
|
59031
|
+
const agentSource = fs3.readFileSync(agentFilePath, "utf-8");
|
|
58989
59032
|
const agentPrompts = await extractAgentPrompts(agentSource);
|
|
58990
59033
|
if (agentPrompts.sideA) {
|
|
58991
59034
|
analysis.primaryPrompt = agentPrompts.sideA;
|
|
@@ -59010,13 +59053,13 @@ var init_packing_service = __esm({
|
|
|
59010
59053
|
* @returns Object with generatedReadme and agentDescription
|
|
59011
59054
|
*/
|
|
59012
59055
|
async generateReadmeForAnalysis(analysis, rootDir) {
|
|
59013
|
-
const agentsDir =
|
|
59056
|
+
const agentsDir = path5.join(rootDir, "agents");
|
|
59014
59057
|
const metadataService = new MetadataService(agentsDir);
|
|
59015
59058
|
let agentDescription;
|
|
59016
59059
|
const agentItem = analysis.constituents.agents.find((a) => a.name === analysis.agent);
|
|
59017
59060
|
if (agentItem?.filePath) {
|
|
59018
59061
|
try {
|
|
59019
|
-
const agentSource =
|
|
59062
|
+
const agentSource = fs3.readFileSync(agentItem.filePath, "utf-8");
|
|
59020
59063
|
agentDescription = await extractAgentDescription(agentSource) || void 0;
|
|
59021
59064
|
} catch {
|
|
59022
59065
|
}
|
|
@@ -59040,7 +59083,7 @@ var init_packing_service = __esm({
|
|
|
59040
59083
|
* include all endpoint modules discovered under agents/api.
|
|
59041
59084
|
*/
|
|
59042
59085
|
async analyzeThreadEndpoints(agentsDir, analysis) {
|
|
59043
|
-
const apiDir =
|
|
59086
|
+
const apiDir = path5.join(agentsDir, "api");
|
|
59044
59087
|
const endpoints = this.scanThreadEndpointFiles(apiDir);
|
|
59045
59088
|
for (const endpoint of endpoints) {
|
|
59046
59089
|
if (analysis.constituents.threadEndpoints.some((item) => item.name === endpoint.name)) {
|
|
@@ -59062,15 +59105,15 @@ var init_packing_service = __esm({
|
|
|
59062
59105
|
* - `admin/users/[userId]/sync.post`
|
|
59063
59106
|
*/
|
|
59064
59107
|
scanThreadEndpointFiles(apiDir, relativeDir = "") {
|
|
59065
|
-
if (!
|
|
59108
|
+
if (!fs3.existsSync(apiDir)) {
|
|
59066
59109
|
return [];
|
|
59067
59110
|
}
|
|
59068
59111
|
const endpoints = [];
|
|
59069
|
-
const currentDir = relativeDir ?
|
|
59070
|
-
if (!
|
|
59112
|
+
const currentDir = relativeDir ? path5.join(apiDir, relativeDir) : apiDir;
|
|
59113
|
+
if (!fs3.existsSync(currentDir)) {
|
|
59071
59114
|
return endpoints;
|
|
59072
59115
|
}
|
|
59073
|
-
const entries =
|
|
59116
|
+
const entries = fs3.readdirSync(currentDir, { withFileTypes: true });
|
|
59074
59117
|
if (entries.length > 0 && typeof entries[0] === "string") {
|
|
59075
59118
|
return endpoints;
|
|
59076
59119
|
}
|
|
@@ -59078,8 +59121,8 @@ var init_packing_service = __esm({
|
|
|
59078
59121
|
const entryName = typeof entry === "string" ? entry : entry.name;
|
|
59079
59122
|
const isDirectory = typeof entry === "string" ? false : entry.isDirectory();
|
|
59080
59123
|
const isFile = typeof entry === "string" ? true : entry.isFile();
|
|
59081
|
-
const entryRelative = relativeDir ?
|
|
59082
|
-
const absolutePath =
|
|
59124
|
+
const entryRelative = relativeDir ? path5.posix.join(relativeDir.replace(/\\/g, "/"), entryName) : entryName;
|
|
59125
|
+
const absolutePath = path5.join(apiDir, entryRelative);
|
|
59083
59126
|
if (isDirectory) {
|
|
59084
59127
|
endpoints.push(...this.scanThreadEndpointFiles(apiDir, entryRelative));
|
|
59085
59128
|
continue;
|
|
@@ -59106,7 +59149,7 @@ var init_packing_service = __esm({
|
|
|
59106
59149
|
* include all effect modules discovered under agents/effects.
|
|
59107
59150
|
*/
|
|
59108
59151
|
async analyzeEffects(agentsDir, analysis) {
|
|
59109
|
-
const effectsDir =
|
|
59152
|
+
const effectsDir = path5.join(agentsDir, "effects");
|
|
59110
59153
|
const effects = this.scanEffectFiles(effectsDir);
|
|
59111
59154
|
for (const effect of effects) {
|
|
59112
59155
|
if (analysis.constituents.effects.some((item) => item.name === effect.name)) {
|
|
@@ -59128,15 +59171,15 @@ var init_packing_service = __esm({
|
|
|
59128
59171
|
* - `notifications/digest`
|
|
59129
59172
|
*/
|
|
59130
59173
|
scanEffectFiles(effectsDir, relativeDir = "") {
|
|
59131
|
-
if (!
|
|
59174
|
+
if (!fs3.existsSync(effectsDir)) {
|
|
59132
59175
|
return [];
|
|
59133
59176
|
}
|
|
59134
59177
|
const effects = [];
|
|
59135
|
-
const currentDir = relativeDir ?
|
|
59136
|
-
if (!
|
|
59178
|
+
const currentDir = relativeDir ? path5.join(effectsDir, relativeDir) : effectsDir;
|
|
59179
|
+
if (!fs3.existsSync(currentDir)) {
|
|
59137
59180
|
return effects;
|
|
59138
59181
|
}
|
|
59139
|
-
const entries =
|
|
59182
|
+
const entries = fs3.readdirSync(currentDir, { withFileTypes: true });
|
|
59140
59183
|
if (entries.length > 0 && typeof entries[0] === "string") {
|
|
59141
59184
|
return effects;
|
|
59142
59185
|
}
|
|
@@ -59144,8 +59187,8 @@ var init_packing_service = __esm({
|
|
|
59144
59187
|
const entryName = typeof entry === "string" ? entry : entry.name;
|
|
59145
59188
|
const isDirectory = typeof entry === "string" ? false : entry.isDirectory();
|
|
59146
59189
|
const isFile = typeof entry === "string" ? true : entry.isFile();
|
|
59147
|
-
const entryRelative = relativeDir ?
|
|
59148
|
-
const absolutePath =
|
|
59190
|
+
const entryRelative = relativeDir ? path5.posix.join(relativeDir.replace(/\\/g, "/"), entryName) : entryName;
|
|
59191
|
+
const absolutePath = path5.join(effectsDir, entryRelative);
|
|
59149
59192
|
if (isDirectory) {
|
|
59150
59193
|
effects.push(...this.scanEffectFiles(effectsDir, entryRelative));
|
|
59151
59194
|
continue;
|
|
@@ -59169,7 +59212,7 @@ var init_packing_service = __esm({
|
|
|
59169
59212
|
* Recursively analyze a prompt and its dependencies.
|
|
59170
59213
|
*/
|
|
59171
59214
|
async analyzePrompt(promptName, agentsDir, analysis, visited, parentKey) {
|
|
59172
|
-
const promptFilePath = await this.findFile(
|
|
59215
|
+
const promptFilePath = await this.findFile(path5.join(agentsDir, "prompts"), promptName);
|
|
59173
59216
|
if (!promptFilePath) {
|
|
59174
59217
|
analysis.warnings.push(`Prompt file not found: ${promptName}`);
|
|
59175
59218
|
return;
|
|
@@ -59188,7 +59231,7 @@ var init_packing_service = __esm({
|
|
|
59188
59231
|
return;
|
|
59189
59232
|
}
|
|
59190
59233
|
visited.add(`prompt:${promptName}`);
|
|
59191
|
-
const promptSource =
|
|
59234
|
+
const promptSource = fs3.readFileSync(promptFilePath, "utf-8");
|
|
59192
59235
|
const modelName = await extractPromptModel(promptSource);
|
|
59193
59236
|
if (modelName) {
|
|
59194
59237
|
await this.analyzeModel(modelName, agentsDir, analysis, visited, thisKey);
|
|
@@ -59214,17 +59257,17 @@ var init_packing_service = __esm({
|
|
|
59214
59257
|
*/
|
|
59215
59258
|
async analyzeTool(toolName, agentsDir, analysis, visited, discoveredVia, parentKey) {
|
|
59216
59259
|
const thisKey = `tool:${toolName}`;
|
|
59217
|
-
const promptFilePath = await this.findFile(
|
|
59260
|
+
const promptFilePath = await this.findFile(path5.join(agentsDir, "prompts"), toolName);
|
|
59218
59261
|
if (promptFilePath) {
|
|
59219
59262
|
await this.analyzePrompt(toolName, agentsDir, analysis, visited, parentKey);
|
|
59220
59263
|
return;
|
|
59221
59264
|
}
|
|
59222
|
-
const agentFilePath = await this.findFile(
|
|
59265
|
+
const agentFilePath = await this.findFile(path5.join(agentsDir, "agents"), toolName);
|
|
59223
59266
|
if (agentFilePath) {
|
|
59224
59267
|
await this.analyzeNestedAgent(toolName, agentsDir, analysis, visited, parentKey);
|
|
59225
59268
|
return;
|
|
59226
59269
|
}
|
|
59227
|
-
const toolFilePath = await this.findFile(
|
|
59270
|
+
const toolFilePath = await this.findFile(path5.join(agentsDir, "tools"), toolName);
|
|
59228
59271
|
if (!toolFilePath) {
|
|
59229
59272
|
analysis.warnings.push(`Tool file not found: ${toolName}`);
|
|
59230
59273
|
return;
|
|
@@ -59242,7 +59285,7 @@ var init_packing_service = __esm({
|
|
|
59242
59285
|
return;
|
|
59243
59286
|
}
|
|
59244
59287
|
visited.add(`tool:${toolName}`);
|
|
59245
|
-
const toolSource =
|
|
59288
|
+
const toolSource = fs3.readFileSync(toolFilePath, "utf-8");
|
|
59246
59289
|
const { uses } = await extractToolUses(toolSource);
|
|
59247
59290
|
for (const usedItem of uses) {
|
|
59248
59291
|
await this.analyzeTool(usedItem, agentsDir, analysis, visited, "uses", thisKey);
|
|
@@ -59252,7 +59295,7 @@ var init_packing_service = __esm({
|
|
|
59252
59295
|
* Analyze a nested agent (used as a handoff target).
|
|
59253
59296
|
*/
|
|
59254
59297
|
async analyzeNestedAgent(agentName, agentsDir, analysis, visited, parentKey) {
|
|
59255
|
-
const agentFilePath = await this.findFile(
|
|
59298
|
+
const agentFilePath = await this.findFile(path5.join(agentsDir, "agents"), agentName);
|
|
59256
59299
|
if (!agentFilePath) {
|
|
59257
59300
|
analysis.warnings.push(`Agent file not found: ${agentName}`);
|
|
59258
59301
|
return;
|
|
@@ -59271,7 +59314,7 @@ var init_packing_service = __esm({
|
|
|
59271
59314
|
return;
|
|
59272
59315
|
}
|
|
59273
59316
|
visited.add(`agent:${agentName}`);
|
|
59274
|
-
const agentSource =
|
|
59317
|
+
const agentSource = fs3.readFileSync(agentFilePath, "utf-8");
|
|
59275
59318
|
const agentPrompts = await extractAgentPrompts(agentSource);
|
|
59276
59319
|
if (agentPrompts.sideA) {
|
|
59277
59320
|
await this.analyzePrompt(agentPrompts.sideA, agentsDir, analysis, visited, thisKey);
|
|
@@ -59284,7 +59327,7 @@ var init_packing_service = __esm({
|
|
|
59284
59327
|
* Analyze a model and its fallbacks.
|
|
59285
59328
|
*/
|
|
59286
59329
|
async analyzeModel(modelName, agentsDir, analysis, visited, parentKey) {
|
|
59287
|
-
const modelFilePath = await this.findFile(
|
|
59330
|
+
const modelFilePath = await this.findFile(path5.join(agentsDir, "models"), modelName);
|
|
59288
59331
|
if (!modelFilePath) {
|
|
59289
59332
|
analysis.warnings.push(`Model file not found: ${modelName}`);
|
|
59290
59333
|
return;
|
|
@@ -59303,7 +59346,7 @@ var init_packing_service = __esm({
|
|
|
59303
59346
|
return;
|
|
59304
59347
|
}
|
|
59305
59348
|
visited.add(`model:${modelName}`);
|
|
59306
|
-
const modelSource =
|
|
59349
|
+
const modelSource = fs3.readFileSync(modelFilePath, "utf-8");
|
|
59307
59350
|
const fallbacks = await extractModelFallbacks(modelSource);
|
|
59308
59351
|
for (const fallbackName of fallbacks) {
|
|
59309
59352
|
await this.analyzeModel(fallbackName, agentsDir, analysis, visited, thisKey);
|
|
@@ -59313,13 +59356,13 @@ var init_packing_service = __esm({
|
|
|
59313
59356
|
* Check which items are shared with other agents.
|
|
59314
59357
|
*/
|
|
59315
59358
|
async checkSharedItems(agentsDir, analysis) {
|
|
59316
|
-
const agentsPath =
|
|
59317
|
-
if (!
|
|
59318
|
-
const agentFiles =
|
|
59359
|
+
const agentsPath = path5.join(agentsDir, "agents");
|
|
59360
|
+
if (!fs3.existsSync(agentsPath)) return;
|
|
59361
|
+
const agentFiles = fs3.readdirSync(agentsPath).filter((f) => f.endsWith(".ts"));
|
|
59319
59362
|
for (const agentFile of agentFiles) {
|
|
59320
59363
|
const otherAgentName = agentFile.replace(".ts", "");
|
|
59321
59364
|
if (otherAgentName === analysis.agent) continue;
|
|
59322
|
-
const otherAnalysis = await this.analyzeAgentLight(otherAgentName,
|
|
59365
|
+
const otherAnalysis = await this.analyzeAgentLight(otherAgentName, path5.dirname(agentsDir));
|
|
59323
59366
|
for (const prompt of analysis.constituents.prompts) {
|
|
59324
59367
|
if (otherAnalysis.prompts.includes(prompt.name)) {
|
|
59325
59368
|
prompt.sharedWith.push(otherAgentName);
|
|
@@ -59351,19 +59394,19 @@ var init_packing_service = __esm({
|
|
|
59351
59394
|
*/
|
|
59352
59395
|
async analyzeAgentLight(agentName, rootDir) {
|
|
59353
59396
|
const result = { prompts: [], tools: [], models: [] };
|
|
59354
|
-
const agentsDir =
|
|
59397
|
+
const agentsDir = path5.join(rootDir, "agents");
|
|
59355
59398
|
const visited = /* @__PURE__ */ new Set();
|
|
59356
|
-
const agentFilePath = await this.findFile(
|
|
59399
|
+
const agentFilePath = await this.findFile(path5.join(agentsDir, "agents"), agentName);
|
|
59357
59400
|
if (!agentFilePath) return result;
|
|
59358
|
-
const agentSource =
|
|
59401
|
+
const agentSource = fs3.readFileSync(agentFilePath, "utf-8");
|
|
59359
59402
|
const agentPrompts = await extractAgentPrompts(agentSource);
|
|
59360
59403
|
const analyzePromptLight = async (promptName) => {
|
|
59361
59404
|
if (visited.has(promptName)) return;
|
|
59362
59405
|
visited.add(promptName);
|
|
59363
59406
|
result.prompts.push(promptName);
|
|
59364
|
-
const promptFilePath = await this.findFile(
|
|
59407
|
+
const promptFilePath = await this.findFile(path5.join(agentsDir, "prompts"), promptName);
|
|
59365
59408
|
if (!promptFilePath) return;
|
|
59366
|
-
const promptSource =
|
|
59409
|
+
const promptSource = fs3.readFileSync(promptFilePath, "utf-8");
|
|
59367
59410
|
const modelName = await extractPromptModel(promptSource);
|
|
59368
59411
|
if (modelName && !result.models.includes(modelName)) {
|
|
59369
59412
|
result.models.push(modelName);
|
|
@@ -59436,14 +59479,14 @@ var init_packing_service = __esm({
|
|
|
59436
59479
|
return result;
|
|
59437
59480
|
}
|
|
59438
59481
|
result.warnings = analysis.warnings;
|
|
59439
|
-
const pkgOutputDir =
|
|
59440
|
-
|
|
59441
|
-
|
|
59442
|
-
|
|
59443
|
-
|
|
59444
|
-
|
|
59445
|
-
|
|
59446
|
-
|
|
59482
|
+
const pkgOutputDir = path5.join(outputDir, packageId);
|
|
59483
|
+
fs3.mkdirSync(path5.join(pkgOutputDir, "dist", "agents"), { recursive: true });
|
|
59484
|
+
fs3.mkdirSync(path5.join(pkgOutputDir, "dist", "prompts"), { recursive: true });
|
|
59485
|
+
fs3.mkdirSync(path5.join(pkgOutputDir, "dist", "tools"), { recursive: true });
|
|
59486
|
+
fs3.mkdirSync(path5.join(pkgOutputDir, "dist", "models"), { recursive: true });
|
|
59487
|
+
fs3.mkdirSync(path5.join(pkgOutputDir, "dist", "hooks"), { recursive: true });
|
|
59488
|
+
fs3.mkdirSync(path5.join(pkgOutputDir, "dist", "effects"), { recursive: true });
|
|
59489
|
+
fs3.mkdirSync(path5.join(pkgOutputDir, "dist", "thread-endpoints"), { recursive: true });
|
|
59447
59490
|
const seenItems = /* @__PURE__ */ new Set();
|
|
59448
59491
|
const allItems = [];
|
|
59449
59492
|
for (const a of analysis.constituents.agents) {
|
|
@@ -59497,13 +59540,13 @@ var init_packing_service = __esm({
|
|
|
59497
59540
|
}
|
|
59498
59541
|
const externalDeps = /* @__PURE__ */ new Map();
|
|
59499
59542
|
for (const item of allItems) {
|
|
59500
|
-
const outputPath =
|
|
59543
|
+
const outputPath = path5.join(
|
|
59501
59544
|
pkgOutputDir,
|
|
59502
59545
|
"dist",
|
|
59503
59546
|
this.getTypeDir(item.type),
|
|
59504
59547
|
`${item.name}.js`
|
|
59505
59548
|
);
|
|
59506
|
-
|
|
59549
|
+
fs3.mkdirSync(path5.dirname(outputPath), { recursive: true });
|
|
59507
59550
|
const deps = await this.bundleFile(item.filePath, outputPath, rootDir);
|
|
59508
59551
|
for (const [depName, depVersion] of deps) {
|
|
59509
59552
|
if (!externalDeps.has(depName)) {
|
|
@@ -59513,12 +59556,12 @@ var init_packing_service = __esm({
|
|
|
59513
59556
|
result.filesCreated.push(outputPath);
|
|
59514
59557
|
}
|
|
59515
59558
|
const indexJs = this.generateReExportIndex(analysis, meta);
|
|
59516
|
-
const indexJsPath =
|
|
59517
|
-
|
|
59559
|
+
const indexJsPath = path5.join(pkgOutputDir, "dist", "index.js");
|
|
59560
|
+
fs3.writeFileSync(indexJsPath, indexJs);
|
|
59518
59561
|
result.filesCreated.push(indexJsPath);
|
|
59519
59562
|
const indexDts = this.generateIndexDts(analysis);
|
|
59520
|
-
const indexDtsPath =
|
|
59521
|
-
|
|
59563
|
+
const indexDtsPath = path5.join(pkgOutputDir, "dist", "index.d.ts");
|
|
59564
|
+
fs3.writeFileSync(indexDtsPath, indexDts);
|
|
59522
59565
|
result.filesCreated.push(indexDtsPath);
|
|
59523
59566
|
const pkgJson = this.generatePackageJson(
|
|
59524
59567
|
finalPackageName,
|
|
@@ -59531,13 +59574,13 @@ var init_packing_service = __esm({
|
|
|
59531
59574
|
license,
|
|
59532
59575
|
licenseOwner
|
|
59533
59576
|
);
|
|
59534
|
-
const pkgJsonPath =
|
|
59535
|
-
|
|
59577
|
+
const pkgJsonPath = path5.join(pkgOutputDir, "package.json");
|
|
59578
|
+
fs3.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
|
|
59536
59579
|
result.filesCreated.push(pkgJsonPath);
|
|
59537
59580
|
if (license) {
|
|
59538
59581
|
const licenseContent = this.generateLicenseFile(license, licenseOwner);
|
|
59539
|
-
const licensePath =
|
|
59540
|
-
|
|
59582
|
+
const licensePath = path5.join(pkgOutputDir, "LICENSE");
|
|
59583
|
+
fs3.writeFileSync(licensePath, licenseContent);
|
|
59541
59584
|
result.filesCreated.push(licensePath);
|
|
59542
59585
|
}
|
|
59543
59586
|
let readmeContent = readme;
|
|
@@ -59545,7 +59588,7 @@ var init_packing_service = __esm({
|
|
|
59545
59588
|
const agentItem = analysis.constituents.agents.find((a) => a.name === agentName);
|
|
59546
59589
|
let agentDescription;
|
|
59547
59590
|
if (agentItem?.filePath) {
|
|
59548
|
-
const agentSource =
|
|
59591
|
+
const agentSource = fs3.readFileSync(agentItem.filePath, "utf-8");
|
|
59549
59592
|
agentDescription = await extractAgentDescription(agentSource) || void 0;
|
|
59550
59593
|
}
|
|
59551
59594
|
readmeContent = this.generateReadme(
|
|
@@ -59556,21 +59599,21 @@ var init_packing_service = __esm({
|
|
|
59556
59599
|
agentDescription
|
|
59557
59600
|
);
|
|
59558
59601
|
}
|
|
59559
|
-
const readmePath =
|
|
59560
|
-
|
|
59602
|
+
const readmePath = path5.join(pkgOutputDir, "README.md");
|
|
59603
|
+
fs3.writeFileSync(readmePath, readmeContent);
|
|
59561
59604
|
result.filesCreated.push(readmePath);
|
|
59562
59605
|
if (removeOriginals || itemSelections) {
|
|
59563
59606
|
result.filesRemoved = [];
|
|
59564
59607
|
for (const item of allItems) {
|
|
59565
59608
|
const selection = itemSelections?.find((s) => s.name === item.name && s.type === item.type);
|
|
59566
59609
|
const shouldRemove = selection ? selection.mode === "extract" : removeOriginals && item.sharedWith.length === 0 && item.type !== "thread-endpoint" && item.type !== "effect";
|
|
59567
|
-
if (shouldRemove &&
|
|
59568
|
-
|
|
59610
|
+
if (shouldRemove && fs3.existsSync(item.filePath)) {
|
|
59611
|
+
fs3.unlinkSync(item.filePath);
|
|
59569
59612
|
result.filesRemoved.push(item.filePath);
|
|
59570
59613
|
}
|
|
59571
59614
|
}
|
|
59572
59615
|
}
|
|
59573
|
-
const agentsDir =
|
|
59616
|
+
const agentsDir = path5.join(rootDir, "agents");
|
|
59574
59617
|
const metadataService = new MetadataService(agentsDir);
|
|
59575
59618
|
const metadata = {
|
|
59576
59619
|
packageName: finalPackageName,
|
|
@@ -59604,7 +59647,7 @@ var init_packing_service = __esm({
|
|
|
59604
59647
|
const commonjs = (await import('@rollup/plugin-commonjs')).default;
|
|
59605
59648
|
const esbuild = (await import('rollup-plugin-esbuild')).default;
|
|
59606
59649
|
const externalDeps = /* @__PURE__ */ new Map();
|
|
59607
|
-
const agentsDir =
|
|
59650
|
+
const agentsDir = path5.join(rootDir, "agents");
|
|
59608
59651
|
const resolveVersion = this.resolvePackageVersion.bind(this);
|
|
59609
59652
|
const trackExternalsPlugin = {
|
|
59610
59653
|
name: "track-externals",
|
|
@@ -59613,14 +59656,14 @@ var init_packing_service = __esm({
|
|
|
59613
59656
|
return null;
|
|
59614
59657
|
}
|
|
59615
59658
|
if (source.startsWith("./") || source.startsWith("../")) {
|
|
59616
|
-
const resolved =
|
|
59659
|
+
const resolved = path5.resolve(path5.dirname(importer), source);
|
|
59617
59660
|
let tsResolved = resolved;
|
|
59618
59661
|
if (!resolved.endsWith(".ts") && !resolved.endsWith(".js")) {
|
|
59619
|
-
if (
|
|
59662
|
+
if (fs3.existsSync(`${resolved}.ts`)) {
|
|
59620
59663
|
tsResolved = `${resolved}.ts`;
|
|
59621
|
-
} else if (
|
|
59664
|
+
} else if (fs3.existsSync(`${resolved}.js`)) {
|
|
59622
59665
|
tsResolved = `${resolved}.js`;
|
|
59623
|
-
} else if (
|
|
59666
|
+
} else if (fs3.existsSync(`${resolved}/index.ts`)) {
|
|
59624
59667
|
tsResolved = `${resolved}/index.ts`;
|
|
59625
59668
|
}
|
|
59626
59669
|
}
|
|
@@ -59669,11 +59712,11 @@ var init_packing_service = __esm({
|
|
|
59669
59712
|
exports: "named"
|
|
59670
59713
|
});
|
|
59671
59714
|
const bundledCode = output[0].code;
|
|
59672
|
-
const header = `// Bundled from: ${
|
|
59715
|
+
const header = `// Bundled from: ${path5.relative(rootDir, inputPath)}
|
|
59673
59716
|
// Local dependencies have been inlined
|
|
59674
59717
|
|
|
59675
59718
|
`;
|
|
59676
|
-
|
|
59719
|
+
fs3.writeFileSync(outputPath, header + bundledCode);
|
|
59677
59720
|
await bundle.close();
|
|
59678
59721
|
} catch (error) {
|
|
59679
59722
|
await bundle.close();
|
|
@@ -60098,30 +60141,30 @@ Copyright (c) ${year} ${copyrightHolder}
|
|
|
60098
60141
|
* @returns Package info or null if not found
|
|
60099
60142
|
*/
|
|
60100
60143
|
getPackedInfo(packageId, rootDir) {
|
|
60101
|
-
const packedDir =
|
|
60102
|
-
let packageDir =
|
|
60103
|
-
if (!
|
|
60104
|
-
if (!
|
|
60144
|
+
const packedDir = path5.join(rootDir, "agents", "packed");
|
|
60145
|
+
let packageDir = path5.join(packedDir, packageId);
|
|
60146
|
+
if (!fs3.existsSync(packageDir)) {
|
|
60147
|
+
if (!fs3.existsSync(packedDir)) {
|
|
60105
60148
|
return null;
|
|
60106
60149
|
}
|
|
60107
|
-
const dirs =
|
|
60150
|
+
const dirs = fs3.readdirSync(packedDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
|
|
60108
60151
|
const matchingDir = dirs.find(
|
|
60109
60152
|
(d) => d === packageId || d === `standardagent-${packageId}` || d === `standardagent-${packageId.replace(/_/g, "-")}`
|
|
60110
60153
|
);
|
|
60111
60154
|
if (!matchingDir) {
|
|
60112
60155
|
return null;
|
|
60113
60156
|
}
|
|
60114
|
-
packageDir =
|
|
60157
|
+
packageDir = path5.join(packedDir, matchingDir);
|
|
60115
60158
|
}
|
|
60116
|
-
const pkgJsonPath =
|
|
60117
|
-
if (!
|
|
60159
|
+
const pkgJsonPath = path5.join(packageDir, "package.json");
|
|
60160
|
+
if (!fs3.existsSync(pkgJsonPath)) {
|
|
60118
60161
|
return null;
|
|
60119
60162
|
}
|
|
60120
|
-
const pkgJson = JSON.parse(
|
|
60163
|
+
const pkgJson = JSON.parse(fs3.readFileSync(pkgJsonPath, "utf-8"));
|
|
60121
60164
|
let readme;
|
|
60122
|
-
const readmePath =
|
|
60123
|
-
if (
|
|
60124
|
-
readme =
|
|
60165
|
+
const readmePath = path5.join(packageDir, "README.md");
|
|
60166
|
+
if (fs3.existsSync(readmePath)) {
|
|
60167
|
+
readme = fs3.readFileSync(readmePath, "utf-8");
|
|
60125
60168
|
}
|
|
60126
60169
|
return {
|
|
60127
60170
|
packageName: pkgJson.name,
|
|
@@ -60139,11 +60182,11 @@ Copyright (c) ${year} ${copyrightHolder}
|
|
|
60139
60182
|
* @returns Array of package directory names
|
|
60140
60183
|
*/
|
|
60141
60184
|
listPackedPackages(rootDir) {
|
|
60142
|
-
const packedDir =
|
|
60143
|
-
if (!
|
|
60185
|
+
const packedDir = path5.join(rootDir, "agents", "packed");
|
|
60186
|
+
if (!fs3.existsSync(packedDir)) {
|
|
60144
60187
|
return [];
|
|
60145
60188
|
}
|
|
60146
|
-
return
|
|
60189
|
+
return fs3.readdirSync(packedDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
|
|
60147
60190
|
}
|
|
60148
60191
|
/**
|
|
60149
60192
|
* Generate README.md content for a packed agent.
|
|
@@ -60190,17 +60233,17 @@ ${license || "See LICENSE file"}
|
|
|
60190
60233
|
* Find a file by name in a directory.
|
|
60191
60234
|
*/
|
|
60192
60235
|
async findFile(dir, name15) {
|
|
60193
|
-
if (!
|
|
60236
|
+
if (!fs3.existsSync(dir)) {
|
|
60194
60237
|
return null;
|
|
60195
60238
|
}
|
|
60196
|
-
const exactPath =
|
|
60197
|
-
if (
|
|
60239
|
+
const exactPath = path5.join(dir, `${name15}.ts`);
|
|
60240
|
+
if (fs3.existsSync(exactPath)) {
|
|
60198
60241
|
return exactPath;
|
|
60199
60242
|
}
|
|
60200
|
-
const files =
|
|
60243
|
+
const files = fs3.readdirSync(dir).filter((f) => f.endsWith(".ts"));
|
|
60201
60244
|
for (const file of files) {
|
|
60202
|
-
const filePath =
|
|
60203
|
-
const source =
|
|
60245
|
+
const filePath = path5.join(dir, file);
|
|
60246
|
+
const source = fs3.readFileSync(filePath, "utf-8");
|
|
60204
60247
|
const extractedName = await extractDefinitionName(source);
|
|
60205
60248
|
if (extractedName === name15) {
|
|
60206
60249
|
return filePath;
|
|
@@ -60212,15 +60255,15 @@ ${license || "See LICENSE file"}
|
|
|
60212
60255
|
* List all agents in the workspace.
|
|
60213
60256
|
*/
|
|
60214
60257
|
async listAgents(rootDir) {
|
|
60215
|
-
const agentsDir =
|
|
60216
|
-
if (!
|
|
60258
|
+
const agentsDir = path5.join(rootDir, "agents", "agents");
|
|
60259
|
+
if (!fs3.existsSync(agentsDir)) {
|
|
60217
60260
|
return [];
|
|
60218
60261
|
}
|
|
60219
|
-
const files =
|
|
60262
|
+
const files = fs3.readdirSync(agentsDir).filter((f) => f.endsWith(".ts"));
|
|
60220
60263
|
const agents = [];
|
|
60221
60264
|
for (const file of files) {
|
|
60222
|
-
const filePath =
|
|
60223
|
-
const source =
|
|
60265
|
+
const filePath = path5.join(agentsDir, file);
|
|
60266
|
+
const source = fs3.readFileSync(filePath, "utf-8");
|
|
60224
60267
|
const name15 = await extractDefinitionName(source);
|
|
60225
60268
|
if (name15) {
|
|
60226
60269
|
agents.push(name15);
|
|
@@ -60241,7 +60284,7 @@ var init_discovery = __esm({
|
|
|
60241
60284
|
constructor(config) {
|
|
60242
60285
|
this.config = {
|
|
60243
60286
|
rootDir: config.rootDir,
|
|
60244
|
-
packedDir: config.packedDir ??
|
|
60287
|
+
packedDir: config.packedDir ?? path5.join(config.rootDir, "agents", "packed"),
|
|
60245
60288
|
scanNpm: config.scanNpm ?? true,
|
|
60246
60289
|
scanLocal: config.scanLocal ?? true
|
|
60247
60290
|
};
|
|
@@ -60274,19 +60317,19 @@ var init_discovery = __esm({
|
|
|
60274
60317
|
*/
|
|
60275
60318
|
async discoverNpmPackages() {
|
|
60276
60319
|
const packages = [];
|
|
60277
|
-
const nodeModulesDir =
|
|
60278
|
-
if (!
|
|
60320
|
+
const nodeModulesDir = path5.join(this.config.rootDir, "node_modules");
|
|
60321
|
+
if (!fs3.existsSync(nodeModulesDir)) {
|
|
60279
60322
|
return packages;
|
|
60280
60323
|
}
|
|
60281
60324
|
const rootEntries = await this.scanDirectory(nodeModulesDir);
|
|
60282
60325
|
for (const entry of rootEntries) {
|
|
60283
60326
|
if (entry.startsWith(".")) continue;
|
|
60284
60327
|
if (entry.startsWith("@")) {
|
|
60285
|
-
const scopeDir =
|
|
60328
|
+
const scopeDir = path5.join(nodeModulesDir, entry);
|
|
60286
60329
|
const scopeEntries = await this.scanDirectory(scopeDir);
|
|
60287
60330
|
for (const scopedPkg of scopeEntries) {
|
|
60288
60331
|
if (scopedPkg.startsWith(".")) continue;
|
|
60289
|
-
const pkgDir =
|
|
60332
|
+
const pkgDir = path5.join(scopeDir, scopedPkg);
|
|
60290
60333
|
const fullName = `${entry}/${scopedPkg}`;
|
|
60291
60334
|
const pkg = await this.checkNpmPackage(pkgDir, fullName);
|
|
60292
60335
|
if (pkg) {
|
|
@@ -60294,7 +60337,7 @@ var init_discovery = __esm({
|
|
|
60294
60337
|
}
|
|
60295
60338
|
}
|
|
60296
60339
|
} else {
|
|
60297
|
-
const pkgDir =
|
|
60340
|
+
const pkgDir = path5.join(nodeModulesDir, entry);
|
|
60298
60341
|
const pkg = await this.checkNpmPackage(pkgDir, entry);
|
|
60299
60342
|
if (pkg) {
|
|
60300
60343
|
packages.push(pkg);
|
|
@@ -60310,12 +60353,12 @@ var init_discovery = __esm({
|
|
|
60310
60353
|
* which must contain `entryAgents` array.
|
|
60311
60354
|
*/
|
|
60312
60355
|
async checkNpmPackage(pkgDir, pkgName) {
|
|
60313
|
-
const pkgJsonPath =
|
|
60314
|
-
if (!
|
|
60356
|
+
const pkgJsonPath = path5.join(pkgDir, "package.json");
|
|
60357
|
+
if (!fs3.existsSync(pkgJsonPath)) {
|
|
60315
60358
|
return null;
|
|
60316
60359
|
}
|
|
60317
60360
|
try {
|
|
60318
|
-
const pkgJson = JSON.parse(
|
|
60361
|
+
const pkgJson = JSON.parse(fs3.readFileSync(pkgJsonPath, "utf-8"));
|
|
60319
60362
|
const isStandardAgent = (
|
|
60320
60363
|
// Has "standardagent" keyword
|
|
60321
60364
|
pkgJson.keywords?.includes("standardagent") || // Has "standardagent-*" prefix
|
|
@@ -60352,21 +60395,21 @@ var init_discovery = __esm({
|
|
|
60352
60395
|
*/
|
|
60353
60396
|
async discoverLocalPackages() {
|
|
60354
60397
|
const packages = [];
|
|
60355
|
-
if (!
|
|
60398
|
+
if (!fs3.existsSync(this.config.packedDir)) {
|
|
60356
60399
|
return packages;
|
|
60357
60400
|
}
|
|
60358
60401
|
const entries = await this.scanDirectory(this.config.packedDir);
|
|
60359
60402
|
for (const entry of entries) {
|
|
60360
60403
|
if (entry.startsWith(".")) continue;
|
|
60361
|
-
const pkgDir =
|
|
60362
|
-
const stat =
|
|
60404
|
+
const pkgDir = path5.join(this.config.packedDir, entry);
|
|
60405
|
+
const stat = fs3.statSync(pkgDir);
|
|
60363
60406
|
if (!stat.isDirectory()) continue;
|
|
60364
60407
|
if (entry.startsWith("@")) {
|
|
60365
60408
|
const scopeEntries = await this.scanDirectory(pkgDir);
|
|
60366
60409
|
for (const scopedPkg of scopeEntries) {
|
|
60367
60410
|
if (scopedPkg.startsWith(".")) continue;
|
|
60368
|
-
const scopedPkgDir =
|
|
60369
|
-
const scopedStat =
|
|
60411
|
+
const scopedPkgDir = path5.join(pkgDir, scopedPkg);
|
|
60412
|
+
const scopedStat = fs3.statSync(scopedPkgDir);
|
|
60370
60413
|
if (!scopedStat.isDirectory()) continue;
|
|
60371
60414
|
const fullName = `${entry}/${scopedPkg}`;
|
|
60372
60415
|
const pkg = await this.checkLocalPackage(scopedPkgDir, fullName);
|
|
@@ -60389,12 +60432,12 @@ var init_discovery = __esm({
|
|
|
60389
60432
|
* Detection is based on the `standardagent` field in package.json.
|
|
60390
60433
|
*/
|
|
60391
60434
|
async checkLocalPackage(pkgDir, dirName) {
|
|
60392
|
-
const pkgJsonPath =
|
|
60393
|
-
if (!
|
|
60435
|
+
const pkgJsonPath = path5.join(pkgDir, "package.json");
|
|
60436
|
+
if (!fs3.existsSync(pkgJsonPath)) {
|
|
60394
60437
|
return null;
|
|
60395
60438
|
}
|
|
60396
60439
|
try {
|
|
60397
|
-
const pkgJson = JSON.parse(
|
|
60440
|
+
const pkgJson = JSON.parse(fs3.readFileSync(pkgJsonPath, "utf-8"));
|
|
60398
60441
|
if (!pkgJson.standardagent?.entryAgents) {
|
|
60399
60442
|
return null;
|
|
60400
60443
|
}
|
|
@@ -60419,10 +60462,10 @@ var init_discovery = __esm({
|
|
|
60419
60462
|
* Scan a directory and return entry names.
|
|
60420
60463
|
*/
|
|
60421
60464
|
async scanDirectory(dir) {
|
|
60422
|
-
if (!
|
|
60465
|
+
if (!fs3.existsSync(dir)) {
|
|
60423
60466
|
return [];
|
|
60424
60467
|
}
|
|
60425
|
-
const entries =
|
|
60468
|
+
const entries = fs3.readdirSync(dir);
|
|
60426
60469
|
return entries;
|
|
60427
60470
|
}
|
|
60428
60471
|
/**
|
|
@@ -60526,29 +60569,29 @@ var init_unpacking_service = __esm({
|
|
|
60526
60569
|
}
|
|
60527
60570
|
analysis.version = pkg.version;
|
|
60528
60571
|
analysis.source = pkg.source;
|
|
60529
|
-
const indexPath =
|
|
60530
|
-
if (!
|
|
60572
|
+
const indexPath = path5.join(pkg.path, "dist", "index.js");
|
|
60573
|
+
if (!fs3.existsSync(indexPath)) {
|
|
60531
60574
|
analysis.errors.push(`Package index not found: ${indexPath}`);
|
|
60532
60575
|
return analysis;
|
|
60533
60576
|
}
|
|
60534
|
-
const indexContent =
|
|
60577
|
+
const indexContent = fs3.readFileSync(indexPath, "utf-8");
|
|
60535
60578
|
const registryItems = await this.parseIndexExports(indexContent);
|
|
60536
60579
|
const availableItems = /* @__PURE__ */ new Map();
|
|
60537
60580
|
for (const item of registryItems) {
|
|
60538
60581
|
availableItems.set(`${item.type}:${item.name}`, item);
|
|
60539
60582
|
}
|
|
60540
|
-
const agentsDir =
|
|
60583
|
+
const agentsDir = path5.join(rootDir, "agents");
|
|
60541
60584
|
const itemsWithRelations = [];
|
|
60542
60585
|
for (const item of registryItems) {
|
|
60543
|
-
const targetPath =
|
|
60544
|
-
const sourcePath =
|
|
60586
|
+
const targetPath = path5.join(agentsDir, TYPE_TO_TARGET_DIR[item.type], `${item.name}.ts`);
|
|
60587
|
+
const sourcePath = path5.join(pkg.path, "dist", TYPE_TO_DIR[item.type], `${item.name}.js`);
|
|
60545
60588
|
const existsGlobally = this.fileExists(targetPath);
|
|
60546
|
-
const sourceExists =
|
|
60589
|
+
const sourceExists = fs3.existsSync(sourcePath);
|
|
60547
60590
|
if (!sourceExists) {
|
|
60548
60591
|
analysis.warnings.push(`Source file not found for ${item.type} "${item.name}": ${sourcePath}`);
|
|
60549
60592
|
continue;
|
|
60550
60593
|
}
|
|
60551
|
-
const bundledCode =
|
|
60594
|
+
const bundledCode = fs3.readFileSync(sourcePath, "utf-8");
|
|
60552
60595
|
const children = await this.discoverRelationships(item.type, item.name, bundledCode, availableItems);
|
|
60553
60596
|
itemsWithRelations.push({
|
|
60554
60597
|
name: item.name,
|
|
@@ -60558,10 +60601,10 @@ var init_unpacking_service = __esm({
|
|
|
60558
60601
|
action: existsGlobally ? "skip" : "generate"
|
|
60559
60602
|
});
|
|
60560
60603
|
for (const child of children) {
|
|
60561
|
-
const childTargetPath =
|
|
60562
|
-
const childSourcePath =
|
|
60604
|
+
const childTargetPath = path5.join(agentsDir, TYPE_TO_TARGET_DIR[child.type], `${child.name}.ts`);
|
|
60605
|
+
const childSourcePath = path5.join(pkg.path, "dist", TYPE_TO_DIR[child.type], `${child.name}.js`);
|
|
60563
60606
|
const childExists = this.fileExists(childTargetPath);
|
|
60564
|
-
const childSourceExists =
|
|
60607
|
+
const childSourceExists = fs3.existsSync(childSourcePath);
|
|
60565
60608
|
if (!childSourceExists) {
|
|
60566
60609
|
continue;
|
|
60567
60610
|
}
|
|
@@ -60664,8 +60707,8 @@ var init_unpacking_service = __esm({
|
|
|
60664
60707
|
return result;
|
|
60665
60708
|
}
|
|
60666
60709
|
const itemsToProcess = this.applySelections(analysis.items, itemSelections);
|
|
60667
|
-
const pkgJsonPath =
|
|
60668
|
-
const pkgJson = JSON.parse(
|
|
60710
|
+
const pkgJsonPath = path5.join(pkg.path, "package.json");
|
|
60711
|
+
const pkgJson = JSON.parse(fs3.readFileSync(pkgJsonPath, "utf-8"));
|
|
60669
60712
|
let author = "";
|
|
60670
60713
|
if (typeof pkgJson.author === "string") {
|
|
60671
60714
|
author = pkgJson.author;
|
|
@@ -60690,17 +60733,17 @@ var init_unpacking_service = __esm({
|
|
|
60690
60733
|
continue;
|
|
60691
60734
|
}
|
|
60692
60735
|
try {
|
|
60693
|
-
const sourcePath =
|
|
60694
|
-
const bundledCode =
|
|
60736
|
+
const sourcePath = path5.join(pkg.path, "dist", TYPE_TO_DIR[item.type], `${item.name}.js`);
|
|
60737
|
+
const bundledCode = fs3.readFileSync(sourcePath, "utf-8");
|
|
60695
60738
|
let tsCode = await transformBundledJs(bundledCode);
|
|
60696
60739
|
if (item.type === "agent") {
|
|
60697
60740
|
tsCode = await injectAgentMetadata(tsCode, agentMetadata);
|
|
60698
60741
|
}
|
|
60699
|
-
const dir =
|
|
60700
|
-
if (!
|
|
60701
|
-
|
|
60742
|
+
const dir = path5.dirname(item.targetPath);
|
|
60743
|
+
if (!fs3.existsSync(dir)) {
|
|
60744
|
+
fs3.mkdirSync(dir, { recursive: true });
|
|
60702
60745
|
}
|
|
60703
|
-
|
|
60746
|
+
fs3.writeFileSync(item.targetPath, tsCode);
|
|
60704
60747
|
result.filesGenerated.push(item.targetPath);
|
|
60705
60748
|
} catch (error) {
|
|
60706
60749
|
result.warnings.push(
|
|
@@ -60789,14 +60832,14 @@ var init_unpacking_service = __esm({
|
|
|
60789
60832
|
*/
|
|
60790
60833
|
async resolvePackage(pkgIdentifier, rootDir) {
|
|
60791
60834
|
if (pkgIdentifier.startsWith("/") || pkgIdentifier.startsWith("./")) {
|
|
60792
|
-
const absolutePath =
|
|
60793
|
-
const pkgJsonPath2 =
|
|
60794
|
-
if (
|
|
60835
|
+
const absolutePath = path5.isAbsolute(pkgIdentifier) ? pkgIdentifier : path5.join(rootDir, pkgIdentifier);
|
|
60836
|
+
const pkgJsonPath2 = path5.join(absolutePath, "package.json");
|
|
60837
|
+
if (fs3.existsSync(pkgJsonPath2)) {
|
|
60795
60838
|
try {
|
|
60796
|
-
const pkgJson = JSON.parse(
|
|
60839
|
+
const pkgJson = JSON.parse(fs3.readFileSync(pkgJsonPath2, "utf-8"));
|
|
60797
60840
|
if (pkgJson.standardagent?.entryAgents) {
|
|
60798
60841
|
return {
|
|
60799
|
-
packageId: pkgJson.name ||
|
|
60842
|
+
packageId: pkgJson.name || path5.basename(absolutePath),
|
|
60800
60843
|
version: pkgJson.version || "0.0.0",
|
|
60801
60844
|
source: "local",
|
|
60802
60845
|
path: absolutePath,
|
|
@@ -60808,11 +60851,11 @@ var init_unpacking_service = __esm({
|
|
|
60808
60851
|
}
|
|
60809
60852
|
return null;
|
|
60810
60853
|
}
|
|
60811
|
-
const packedDir =
|
|
60812
|
-
const pkgJsonPath =
|
|
60813
|
-
if (
|
|
60854
|
+
const packedDir = path5.join(rootDir, "agents", "packed", pkgIdentifier);
|
|
60855
|
+
const pkgJsonPath = path5.join(packedDir, "package.json");
|
|
60856
|
+
if (fs3.existsSync(pkgJsonPath)) {
|
|
60814
60857
|
try {
|
|
60815
|
-
const pkgJson = JSON.parse(
|
|
60858
|
+
const pkgJson = JSON.parse(fs3.readFileSync(pkgJsonPath, "utf-8"));
|
|
60816
60859
|
if (pkgJson.standardagent?.entryAgents) {
|
|
60817
60860
|
return {
|
|
60818
60861
|
packageId: pkgJson.name || pkgIdentifier,
|
|
@@ -60853,18 +60896,18 @@ var init_unpacking_service = __esm({
|
|
|
60853
60896
|
* Check if a file exists.
|
|
60854
60897
|
*/
|
|
60855
60898
|
fileExists(filePath) {
|
|
60856
|
-
if (
|
|
60899
|
+
if (fs3.existsSync(filePath)) {
|
|
60857
60900
|
return true;
|
|
60858
60901
|
}
|
|
60859
60902
|
const withoutExt = filePath.replace(/\.(ts|js)$/, "");
|
|
60860
|
-
return
|
|
60903
|
+
return fs3.existsSync(`${withoutExt}.ts`) || fs3.existsSync(`${withoutExt}.js`);
|
|
60861
60904
|
}
|
|
60862
60905
|
/**
|
|
60863
60906
|
* Recursively delete a directory.
|
|
60864
60907
|
*/
|
|
60865
60908
|
deleteDirectory(dirPath) {
|
|
60866
|
-
if (
|
|
60867
|
-
|
|
60909
|
+
if (fs3.existsSync(dirPath)) {
|
|
60910
|
+
fs3.rmSync(dirPath, { recursive: true, force: true });
|
|
60868
60911
|
}
|
|
60869
60912
|
}
|
|
60870
60913
|
/**
|
|
@@ -60951,8 +60994,8 @@ var init_npm_publish_service = __esm({
|
|
|
60951
60994
|
error: "Registry URL must use HTTPS"
|
|
60952
60995
|
};
|
|
60953
60996
|
}
|
|
60954
|
-
const pkgJsonPath =
|
|
60955
|
-
if (!
|
|
60997
|
+
const pkgJsonPath = path5.join(packageDir, "package.json");
|
|
60998
|
+
if (!fs3.existsSync(pkgJsonPath)) {
|
|
60956
60999
|
return {
|
|
60957
61000
|
success: false,
|
|
60958
61001
|
output: "",
|
|
@@ -60962,7 +61005,7 @@ var init_npm_publish_service = __esm({
|
|
|
60962
61005
|
let packageName;
|
|
60963
61006
|
let version;
|
|
60964
61007
|
try {
|
|
60965
|
-
const pkgJson = JSON.parse(
|
|
61008
|
+
const pkgJson = JSON.parse(fs3.readFileSync(pkgJsonPath, "utf-8"));
|
|
60966
61009
|
packageName = pkgJson.name;
|
|
60967
61010
|
version = pkgJson.version;
|
|
60968
61011
|
} catch (e) {
|
|
@@ -60972,13 +61015,13 @@ var init_npm_publish_service = __esm({
|
|
|
60972
61015
|
error: `Failed to read package.json: ${e instanceof Error ? e.message : String(e)}`
|
|
60973
61016
|
};
|
|
60974
61017
|
}
|
|
60975
|
-
const npmrcPath =
|
|
61018
|
+
const npmrcPath = path5.join(packageDir, ".npmrc");
|
|
60976
61019
|
const registryHost = new URL(registry).host;
|
|
60977
61020
|
const npmrcContent = `//${registryHost}/:_authToken=${token}
|
|
60978
61021
|
registry=${registry}
|
|
60979
61022
|
`;
|
|
60980
61023
|
try {
|
|
60981
|
-
|
|
61024
|
+
fs3.writeFileSync(npmrcPath, npmrcContent, { mode: 384 });
|
|
60982
61025
|
const args = ["publish"];
|
|
60983
61026
|
if (dryRun) {
|
|
60984
61027
|
args.push("--dry-run");
|
|
@@ -61010,8 +61053,8 @@ registry=${registry}
|
|
|
61010
61053
|
};
|
|
61011
61054
|
} finally {
|
|
61012
61055
|
try {
|
|
61013
|
-
if (
|
|
61014
|
-
|
|
61056
|
+
if (fs3.existsSync(npmrcPath)) {
|
|
61057
|
+
fs3.unlinkSync(npmrcPath);
|
|
61015
61058
|
}
|
|
61016
61059
|
} catch {
|
|
61017
61060
|
}
|
|
@@ -61616,7 +61659,7 @@ var index_post_default2 = defineController2(async ({ req, env: env2 }) => {
|
|
|
61616
61659
|
});
|
|
61617
61660
|
|
|
61618
61661
|
// src/utils/platform-auth.ts
|
|
61619
|
-
var FALLBACK_PLATFORM_ORIGIN = "https://standardagents.ai";
|
|
61662
|
+
var FALLBACK_PLATFORM_ORIGIN = "https://platform.standardagents.ai";
|
|
61620
61663
|
var SESSION_TTL_SECONDS = 30 * 24 * 60 * 60;
|
|
61621
61664
|
function platformApiKey(env2) {
|
|
61622
61665
|
const value = env2.STANDARD_AGENTS_API_KEY;
|
|
@@ -61688,7 +61731,7 @@ async function getPlatformIdentity(env2) {
|
|
|
61688
61731
|
const endpoint = platformEndpoint(env2);
|
|
61689
61732
|
const verifiedAccount = await fetchPlatformAccount(endpoint, token);
|
|
61690
61733
|
const account = verifiedAccount ?? await fallbackAccountForToken(token);
|
|
61691
|
-
const username = sanitizeUsername(
|
|
61734
|
+
const username = sanitizeUsername(account.slug);
|
|
61692
61735
|
return {
|
|
61693
61736
|
connected: true,
|
|
61694
61737
|
verified: verifiedAccount !== null,
|
|
@@ -61707,16 +61750,26 @@ async function createPlatformLocalSession(env2) {
|
|
|
61707
61750
|
if (!identity) {
|
|
61708
61751
|
return null;
|
|
61709
61752
|
}
|
|
61710
|
-
const
|
|
61711
|
-
|
|
61753
|
+
const agentBuilderNamespace = env2.AGENT_BUILDER;
|
|
61754
|
+
if (!agentBuilderNamespace || typeof agentBuilderNamespace.idFromName !== "function" || typeof agentBuilderNamespace.get !== "function") {
|
|
61755
|
+
throw new Error("Server misconfigured: AGENT_BUILDER Durable Object binding is required for platform auth");
|
|
61756
|
+
}
|
|
61757
|
+
const agentBuilderId = agentBuilderNamespace.idFromName("singleton");
|
|
61758
|
+
const agentBuilder = agentBuilderNamespace.get(agentBuilderId);
|
|
61712
61759
|
const username = identity.user.username;
|
|
61713
61760
|
let user = await agentBuilder.getUserByUsername(username);
|
|
61714
61761
|
if (!user) {
|
|
61715
|
-
|
|
61716
|
-
|
|
61717
|
-
|
|
61718
|
-
|
|
61719
|
-
}
|
|
61762
|
+
const legacyUsername = sanitizeUsername(`standard-agents-${identity.account.slug}`);
|
|
61763
|
+
const legacyUser = legacyUsername !== username ? await agentBuilder.getUserByUsername(legacyUsername) : null;
|
|
61764
|
+
if (legacyUser) {
|
|
61765
|
+
user = await agentBuilder.updateUser(legacyUser.id, { username }) ?? legacyUser;
|
|
61766
|
+
} else {
|
|
61767
|
+
user = await agentBuilder.createUser({
|
|
61768
|
+
username,
|
|
61769
|
+
password_hash: await hashPassword(crypto.randomUUID()),
|
|
61770
|
+
role: "admin"
|
|
61771
|
+
});
|
|
61772
|
+
}
|
|
61720
61773
|
}
|
|
61721
61774
|
const token = generateUserToken();
|
|
61722
61775
|
const tokenHash = await hashToken(token);
|
|
@@ -61737,12 +61790,91 @@ async function createPlatformLocalSession(env2) {
|
|
|
61737
61790
|
platform: identity
|
|
61738
61791
|
};
|
|
61739
61792
|
}
|
|
61793
|
+
var STATE_RELATIVE_PATH = path5__default.join(".agents", "bootstrap-session.json");
|
|
61794
|
+
var PROJECT_ROOT_ENV_KEYS = ["INIT_CWD", "PWD", "npm_config_local_prefix"];
|
|
61795
|
+
function readEnvString(env2, key) {
|
|
61796
|
+
if (!env2 || typeof env2 !== "object") return void 0;
|
|
61797
|
+
const value = env2[key];
|
|
61798
|
+
return typeof value === "string" ? value : void 0;
|
|
61799
|
+
}
|
|
61800
|
+
function uniquePaths(paths) {
|
|
61801
|
+
return Array.from(
|
|
61802
|
+
new Set(
|
|
61803
|
+
paths.filter((value) => !!value?.trim()).map((value) => path5__default.resolve(value))
|
|
61804
|
+
)
|
|
61805
|
+
);
|
|
61806
|
+
}
|
|
61807
|
+
function hasSessionCookie(cookieHeader) {
|
|
61808
|
+
const raw = Array.isArray(cookieHeader) ? cookieHeader.join("; ") : cookieHeader || "";
|
|
61809
|
+
return /(?:^|;\s*)session=/.test(raw);
|
|
61810
|
+
}
|
|
61811
|
+
function loadLocalBootstrapSession(projectRoot) {
|
|
61812
|
+
const statePath = path5__default.join(projectRoot, STATE_RELATIVE_PATH);
|
|
61813
|
+
if (!fs3__default.existsSync(statePath)) return null;
|
|
61814
|
+
try {
|
|
61815
|
+
const parsed = JSON.parse(
|
|
61816
|
+
fs3__default.readFileSync(statePath, "utf-8")
|
|
61817
|
+
);
|
|
61818
|
+
if (parsed.version !== 1) return null;
|
|
61819
|
+
if (!parsed.endpoint || !parsed.user?.id || !parsed.account?.id) return null;
|
|
61820
|
+
if (!parsed.session_cookie || typeof parsed.session_cookie !== "string") return null;
|
|
61821
|
+
return parsed;
|
|
61822
|
+
} catch {
|
|
61823
|
+
return null;
|
|
61824
|
+
}
|
|
61825
|
+
}
|
|
61826
|
+
function loadLocalBootstrapSessionFromEnv(env2) {
|
|
61827
|
+
if (!env2) return null;
|
|
61828
|
+
const endpoint = readEnvString(env2, "PLATFORM_ENDPOINT")?.trim();
|
|
61829
|
+
const sessionCookie = readEnvString(env2, "STANDARDAGENTS_BOOTSTRAP_SESSION_COOKIE")?.trim();
|
|
61830
|
+
const userId = readEnvString(env2, "STANDARDAGENTS_ORG_USER_ID")?.trim();
|
|
61831
|
+
const accountId = readEnvString(env2, "STANDARDAGENTS_ORG_ACCOUNT_ID")?.trim();
|
|
61832
|
+
const accountSlug = readEnvString(env2, "STANDARDAGENTS_ORG_SLUG")?.trim();
|
|
61833
|
+
if (!endpoint || !sessionCookie || !userId || !accountId) {
|
|
61834
|
+
return null;
|
|
61835
|
+
}
|
|
61836
|
+
return {
|
|
61837
|
+
version: 1,
|
|
61838
|
+
endpoint,
|
|
61839
|
+
authenticated_at: 0,
|
|
61840
|
+
session_cookie: sessionCookie,
|
|
61841
|
+
user: { id: userId },
|
|
61842
|
+
account: {
|
|
61843
|
+
id: accountId,
|
|
61844
|
+
...accountSlug ? { slug: accountSlug } : {}
|
|
61845
|
+
}
|
|
61846
|
+
};
|
|
61847
|
+
}
|
|
61848
|
+
function findLocalBootstrapSession(projectRoot, env2) {
|
|
61849
|
+
const envSession = loadLocalBootstrapSessionFromEnv(env2);
|
|
61850
|
+
if (envSession) {
|
|
61851
|
+
return {
|
|
61852
|
+
projectRoot: process.cwd(),
|
|
61853
|
+
session: envSession
|
|
61854
|
+
};
|
|
61855
|
+
}
|
|
61856
|
+
const candidates = uniquePaths([
|
|
61857
|
+
projectRoot,
|
|
61858
|
+
process.cwd(),
|
|
61859
|
+
...PROJECT_ROOT_ENV_KEYS.map((key) => process.env[key])
|
|
61860
|
+
]);
|
|
61861
|
+
for (const candidate of candidates) {
|
|
61862
|
+
const session = loadLocalBootstrapSession(candidate);
|
|
61863
|
+
if (session) {
|
|
61864
|
+
return {
|
|
61865
|
+
projectRoot: candidate,
|
|
61866
|
+
session
|
|
61867
|
+
};
|
|
61868
|
+
}
|
|
61869
|
+
}
|
|
61870
|
+
return null;
|
|
61871
|
+
}
|
|
61740
61872
|
|
|
61741
61873
|
// src/api/platform-endpoint.ts
|
|
61742
61874
|
var ORB_CORE_HOST_PATTERN = /^core\.([a-z0-9-]+)\.orb\.local$/i;
|
|
61743
61875
|
var LOCAL_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1"]);
|
|
61744
61876
|
var DEFAULT_DOCKER_PLATFORM_ENDPOINT = "http://platform-admin:8787";
|
|
61745
|
-
function
|
|
61877
|
+
function readEnvString2(env2, key) {
|
|
61746
61878
|
if (!env2 || typeof env2 !== "object") return void 0;
|
|
61747
61879
|
const value = env2[key];
|
|
61748
61880
|
return typeof value === "string" ? value : void 0;
|
|
@@ -61772,7 +61904,7 @@ function resolvePlatformEndpoint(req, env2) {
|
|
|
61772
61904
|
return endpoints[0] ?? null;
|
|
61773
61905
|
}
|
|
61774
61906
|
function resolvePlatformEndpointCandidates(req, env2) {
|
|
61775
|
-
const configuredEndpoint = normalizeEndpoint(
|
|
61907
|
+
const configuredEndpoint = normalizeEndpoint(readEnvString2(env2, "PLATFORM_ENDPOINT"));
|
|
61776
61908
|
const orbFallbackEndpoint = deriveOrbPlatformEndpoint(req.url);
|
|
61777
61909
|
const configuredHost = configuredEndpoint ? getHostname(configuredEndpoint) : null;
|
|
61778
61910
|
const hasLocalConfiguredEndpoint = !!(configuredHost && LOCAL_HOSTS.has(configuredHost));
|
|
@@ -61805,10 +61937,12 @@ var platform_endpoint_default = defineController2(async ({ req, env: env2 }) =>
|
|
|
61805
61937
|
// src/api/config.get.ts
|
|
61806
61938
|
var config_get_default = defineController2(async ({ config, env: env2, req }) => {
|
|
61807
61939
|
const configuredPlatformEndpoint = resolvePlatformEndpoint(req, env2);
|
|
61808
|
-
const platformConnected = hasPlatformApiKey(env2) || !!
|
|
61940
|
+
const platformConnected = hasPlatformApiKey(env2) || !!findLocalBootstrapSession(void 0, env2);
|
|
61941
|
+
const localPassword = typeof env2.SUPER_ADMIN_PASSWORD === "string" && env2.SUPER_ADMIN_PASSWORD.length > 0;
|
|
61809
61942
|
return Response.json({
|
|
61810
61943
|
...config,
|
|
61811
61944
|
platformConnected,
|
|
61945
|
+
localPassword,
|
|
61812
61946
|
platformEndpoint: hasPlatformApiKey(env2) ? platformEndpoint(env2) : configuredPlatformEndpoint
|
|
61813
61947
|
});
|
|
61814
61948
|
});
|
|
@@ -62745,7 +62879,17 @@ var index_get_default2 = defineController2(async ({ req, env: env2 }) => {
|
|
|
62745
62879
|
const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
|
|
62746
62880
|
const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
|
|
62747
62881
|
const users = await agentBuilder.listUsers();
|
|
62748
|
-
|
|
62882
|
+
let platformUsername = null;
|
|
62883
|
+
const platformEnv = env2;
|
|
62884
|
+
if (hasPlatformApiKey(platformEnv)) {
|
|
62885
|
+
const identity = await getPlatformIdentity(platformEnv).catch(() => null);
|
|
62886
|
+
platformUsername = identity?.user.username ?? null;
|
|
62887
|
+
}
|
|
62888
|
+
const usersWithSource = users.map((user) => ({
|
|
62889
|
+
...user,
|
|
62890
|
+
source: platformUsername && user.username === platformUsername ? "standard_agents" : "local"
|
|
62891
|
+
}));
|
|
62892
|
+
return Response.json({ users: usersWithSource });
|
|
62749
62893
|
} catch (error) {
|
|
62750
62894
|
console.error("List users error:", error);
|
|
62751
62895
|
return Response.json(
|
|
@@ -63740,85 +63884,6 @@ var id_put_default = defineController2(async ({ req, env: env2, params }) => {
|
|
|
63740
63884
|
);
|
|
63741
63885
|
}
|
|
63742
63886
|
});
|
|
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
63887
|
|
|
63823
63888
|
// src/api/auth/bootstrap.post.ts
|
|
63824
63889
|
function deriveManagedUsername(platformUserId) {
|
|
@@ -63883,6 +63948,12 @@ var bootstrap_post_default = defineController2(async ({ req, env: env2 }) => {
|
|
|
63883
63948
|
);
|
|
63884
63949
|
}
|
|
63885
63950
|
const username = deriveManagedUsername(platformUserId);
|
|
63951
|
+
if (!env2.AGENT_BUILDER || typeof env2.AGENT_BUILDER.idFromName !== "function") {
|
|
63952
|
+
return Response.json(
|
|
63953
|
+
{ error: "Server misconfigured: AGENT_BUILDER Durable Object binding is required for platform auth" },
|
|
63954
|
+
{ status: 500 }
|
|
63955
|
+
);
|
|
63956
|
+
}
|
|
63886
63957
|
const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
|
|
63887
63958
|
const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
|
|
63888
63959
|
let user = await agentBuilder.getUserByUsername(username);
|
|
@@ -63920,11 +63991,13 @@ var config_get_default2 = defineController2(async ({ req, env: env2 }) => {
|
|
|
63920
63991
|
const githubConfigured = !!(env2.GITHUB_CLIENT_ID && env2.GITHUB_CLIENT_SECRET);
|
|
63921
63992
|
const googleConfigured = !!(env2.GOOGLE_CLIENT_ID && env2.GOOGLE_CLIENT_SECRET);
|
|
63922
63993
|
const configuredPlatformEndpoint = resolvePlatformEndpoint(req, env2);
|
|
63923
|
-
const platformConnected = hasPlatformApiKey(env2) || !!
|
|
63994
|
+
const platformConnected = hasPlatformApiKey(env2) || !!findLocalBootstrapSession(void 0, env2);
|
|
63995
|
+
const localPassword = typeof env2.SUPER_ADMIN_PASSWORD === "string" && env2.SUPER_ADMIN_PASSWORD.length > 0;
|
|
63924
63996
|
return {
|
|
63925
63997
|
github: githubConfigured,
|
|
63926
63998
|
google: googleConfigured,
|
|
63927
63999
|
platformConnected,
|
|
64000
|
+
localPassword,
|
|
63928
64001
|
platformEndpoint: hasPlatformApiKey(env2) ? platformEndpoint(env2) : configuredPlatformEndpoint
|
|
63929
64002
|
};
|
|
63930
64003
|
});
|
|
@@ -63963,6 +64036,12 @@ var login_post_default = defineController2(async ({ req, env: env2 }) => {
|
|
|
63963
64036
|
{ status: 400 }
|
|
63964
64037
|
);
|
|
63965
64038
|
}
|
|
64039
|
+
if (!env2.AGENT_BUILDER || typeof env2.AGENT_BUILDER.idFromName !== "function") {
|
|
64040
|
+
return Response.json(
|
|
64041
|
+
{ error: "Server misconfigured: AGENT_BUILDER Durable Object binding is required for local login" },
|
|
64042
|
+
{ status: 500 }
|
|
64043
|
+
);
|
|
64044
|
+
}
|
|
63966
64045
|
const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
|
|
63967
64046
|
const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
|
|
63968
64047
|
const user = await agentBuilder.getUserByUsername(username);
|
|
@@ -64140,6 +64219,7 @@ var instance_patch_default = defineController2(async ({ req, env: env2 }) => {
|
|
|
64140
64219
|
});
|
|
64141
64220
|
|
|
64142
64221
|
// src/api/models/available.post.ts
|
|
64222
|
+
init_platform_routing();
|
|
64143
64223
|
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
64224
|
var CLOUDFLARE_PROVIDER_MODEL_ID = /^@cf\//i;
|
|
64145
64225
|
function isOpaqueModelId(modelId) {
|
|
@@ -64243,15 +64323,16 @@ var available_post_default = defineController2(async ({ req, env: env2 }) => {
|
|
|
64243
64323
|
);
|
|
64244
64324
|
}
|
|
64245
64325
|
const apiKey = env2[config.envKey];
|
|
64246
|
-
|
|
64326
|
+
const platformRouting = apiKey ? null : resolvePlatformRouting(provider, env2);
|
|
64327
|
+
if (!apiKey && !platformRouting && provider !== "openrouter") {
|
|
64247
64328
|
return Response.json(
|
|
64248
|
-
{ error: `API key not configured for ${provider}. Set ${config.envKey}
|
|
64329
|
+
{ error: `API key not configured for ${provider}. Set ${config.envKey} or STANDARD_AGENTS_API_KEY.` },
|
|
64249
64330
|
{ status: 401 }
|
|
64250
64331
|
);
|
|
64251
64332
|
}
|
|
64252
64333
|
try {
|
|
64253
64334
|
const factory = await config.getFactory();
|
|
64254
|
-
const providerConfig = config.getConfig?.(env2, apiKey || "") || { apiKey: apiKey || "" };
|
|
64335
|
+
const providerConfig = platformRouting ? { apiKey: platformRouting.apiKey, baseUrl: platformRouting.baseUrl } : config.getConfig?.(env2, apiKey || "") || { apiKey: apiKey || "" };
|
|
64255
64336
|
const providerInstance = factory(providerConfig);
|
|
64256
64337
|
if (!providerInstance.getModels && !providerInstance.getModelsPage) {
|
|
64257
64338
|
return Response.json({ models: [], hasNextPage: false });
|