@agentfield/sdk 0.1.131-rc.3 → 0.1.132-rc.1

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/index.js CHANGED
@@ -3383,6 +3383,12 @@ var ExecutionLogger = class {
3383
3383
  function createExecutionLogger(options = {}) {
3384
3384
  return new ExecutionLogger(options);
3385
3385
  }
3386
+
3387
+ // src/utils/agentFieldUrl.ts
3388
+ var DEFAULT_AGENTFIELD_URL = "http://localhost:8080";
3389
+ function resolveAgentFieldUrl(explicitUrl) {
3390
+ return (explicitUrl ?? process.env.AGENTFIELD_SERVER ?? process.env.AGENTFIELD_SERVER_URL ?? DEFAULT_AGENTFIELD_URL).replace(/\/$/, "");
3391
+ }
3386
3392
  var HEADER_CALLER_DID = "X-Caller-DID";
3387
3393
  var HEADER_DID_SIGNATURE = "X-DID-Signature";
3388
3394
  var HEADER_DID_TIMESTAMP = "X-DID-Timestamp";
@@ -3533,7 +3539,7 @@ var AgentFieldClient = class {
3533
3539
  defaultHeaders;
3534
3540
  didAuthenticator;
3535
3541
  constructor(config) {
3536
- const baseURL = (config.agentFieldUrl ?? "http://localhost:8080").replace(/\/$/, "");
3542
+ const baseURL = resolveAgentFieldUrl(config.agentFieldUrl);
3537
3543
  this.http = axios5.create({
3538
3544
  baseURL,
3539
3545
  timeout: 3e4,
@@ -5505,9 +5511,9 @@ var Agent = class {
5505
5511
  constructor(config) {
5506
5512
  this.config = {
5507
5513
  port: 8001,
5508
- agentFieldUrl: "http://localhost:8080",
5509
5514
  host: "0.0.0.0",
5510
5515
  ...config,
5516
+ agentFieldUrl: resolveAgentFieldUrl(config.agentFieldUrl),
5511
5517
  didEnabled: config.didEnabled ?? true,
5512
5518
  deploymentType: config.deploymentType ?? "long_running",
5513
5519
  asyncExecution: config.asyncExecution ?? true
@@ -5517,7 +5523,7 @@ var Agent = class {
5517
5523
  this.aiClient = new AIClient(this.config.aiConfig);
5518
5524
  this.agentFieldClient = new AgentFieldClient(this.config);
5519
5525
  this.approvalClient = new ApprovalClient({
5520
- baseURL: this.config.agentFieldUrl ?? "http://localhost:8080",
5526
+ baseURL: resolveAgentFieldUrl(this.config.agentFieldUrl),
5521
5527
  nodeId: this.config.nodeId,
5522
5528
  apiKey: this.config.apiKey,
5523
5529
  headers: this.sanitizeDefaultHeaders(this.config.defaultHeaders)
@@ -5770,7 +5776,7 @@ var Agent = class {
5770
5776
  const execCtx = ExecutionContext.getCurrent();
5771
5777
  const execMetadata = metadata ?? execCtx?.metadata;
5772
5778
  if (!execMetadata) return;
5773
- const baseUrl = (this.config.agentFieldUrl ?? "http://localhost:8080").replace(/\/$/, "");
5779
+ const baseUrl = resolveAgentFieldUrl(this.config.agentFieldUrl);
5774
5780
  let uiApiUrl = baseUrl.replace(/\/api\/v1$/, "/api/ui/v1");
5775
5781
  if (!uiApiUrl.includes("/api/ui/v1")) {
5776
5782
  uiApiUrl = `${baseUrl}/api/ui/v1`;