@agentfield/sdk 0.1.138-rc.4 → 0.1.138-rc.6

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/README.md CHANGED
@@ -122,6 +122,14 @@ agent.reasoner('process', async (ctx) => {
122
122
 
123
123
  **Use `note()` for AgentField UI tracking, `console.log()` for local debugging.**
124
124
 
125
+ ## Logging
126
+
127
+ - `AGENTFIELD_LOG_STDOUT` controls the on-by-default structured JSON mirror; `0`, `false`, `no`, or `off` disables it without disabling execution-scoped control-plane dispatch.
128
+ - `AGENTFIELD_LOGS_ENABLED` controls stdout/stderr capture and the node logs endpoint, not control-plane dispatch.
129
+ - `AGENTFIELD_LOG_MAX_LINE_BYTES` defaults to 16384 bytes. Values below 256 use that default; parsing accepts an integer prefix, so `512abc` yields 512.
130
+
131
+ See the [environment-variable reference](../../docs/ENVIRONMENT_VARIABLES.md) for details.
132
+
125
133
  ## Human-in-the-Loop Approvals
126
134
 
127
135
  Use the `ApprovalClient` to pause agent execution for human review:
package/dist/index.d.ts CHANGED
@@ -584,6 +584,7 @@ declare class ExecutionLogger {
584
584
  error(message: string, attributes?: ExecutionLogAttributes, options?: ExecutionLogEmitOptions): ExecutionLogEntry;
585
585
  system(eventType: string, message: string, attributes?: ExecutionLogAttributes): ExecutionLogEntry;
586
586
  private emit;
587
+ private shouldMirrorToStdout;
587
588
  }
588
589
  declare function createExecutionLogger(options?: ExecutionLoggerOptions): ExecutionLogger;
589
590
 
package/dist/index.js CHANGED
@@ -3852,6 +3852,16 @@ var AIClient = class {
3852
3852
  }
3853
3853
  };
3854
3854
 
3855
+ // src/utils/envFlags.ts
3856
+ var DISABLED_FLAG_VALUES = ["0", "false", "no", "off"];
3857
+ function readEnvValue(name) {
3858
+ if (typeof process === "undefined" || !process.env) return void 0;
3859
+ return process.env[name];
3860
+ }
3861
+ function envFlagEnabled(name) {
3862
+ return !DISABLED_FLAG_VALUES.includes((readEnvValue(name) ?? "true").trim().toLowerCase());
3863
+ }
3864
+
3855
3865
  // src/observability/ExecutionLogger.ts
3856
3866
  function isExecutionLogBatchPayload(payload) {
3857
3867
  return "entries" in payload;
@@ -3916,7 +3926,7 @@ var ExecutionLogger = class {
3916
3926
  constructor(options = {}) {
3917
3927
  this.contextProvider = options.contextProvider;
3918
3928
  this.transport = options.transport;
3919
- this.mirrorToStdout = options.mirrorToStdout ?? true;
3929
+ this.mirrorToStdout = options.mirrorToStdout;
3920
3930
  this.stdout = options.stdout ?? (typeof process !== "undefined" ? process.stdout : void 0);
3921
3931
  this.defaultSource = options.source ?? "sdk.logger";
3922
3932
  }
@@ -3957,9 +3967,8 @@ var ExecutionLogger = class {
3957
3967
  }
3958
3968
  emit(entry) {
3959
3969
  const wire = normalizeExecutionLogEntry(entry);
3960
- const line = safeJsonStringify(wire) + "\n";
3961
- if (this.mirrorToStdout && this.stdout?.write) {
3962
- this.stdout.write(line);
3970
+ if (this.shouldMirrorToStdout() && this.stdout?.write) {
3971
+ this.stdout.write(safeJsonStringify(wire) + "\n");
3963
3972
  }
3964
3973
  if (this.transport && wire.execution_id) {
3965
3974
  try {
@@ -3972,6 +3981,9 @@ var ExecutionLogger = class {
3972
3981
  }
3973
3982
  }
3974
3983
  }
3984
+ shouldMirrorToStdout() {
3985
+ return this.mirrorToStdout ?? envFlagEnabled("AGENTFIELD_LOG_STDOUT");
3986
+ }
3975
3987
  };
3976
3988
  function createExecutionLogger(options = {}) {
3977
3989
  return new ExecutionLogger(options);
@@ -5823,8 +5835,7 @@ function evaluateConstraints(constraints, inputParams) {
5823
5835
 
5824
5836
  // src/agent/processLogs.ts
5825
5837
  function logsEnabled() {
5826
- const v = (process.env.AGENTFIELD_LOGS_ENABLED ?? "true").trim().toLowerCase();
5827
- return !["0", "false", "no", "off"].includes(v);
5838
+ return envFlagEnabled("AGENTFIELD_LOGS_ENABLED");
5828
5839
  }
5829
5840
  function maxBufferBytes() {
5830
5841
  const raw = parseInt(process.env.AGENTFIELD_LOG_BUFFER_BYTES ?? "4194304", 10);