@polka-codes/core 0.9.28 → 0.9.29

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.
@@ -1985,6 +1985,7 @@ declare type WorkflowContext = {
1985
1985
  parameters: Record<string, any>;
1986
1986
  verbose?: number;
1987
1987
  agentCallback?: TaskEventCallback;
1988
+ logger?: Console;
1988
1989
  };
1989
1990
  export { WorkflowContext }
1990
1991
  export { WorkflowContext as WorkflowContext_alias_1 }
package/dist/index.js CHANGED
@@ -3760,8 +3760,9 @@ var makeAgentStepSpecHandler = (getModelFn) => ({
3760
3760
  return {
3761
3761
  ...step2,
3762
3762
  async run(input, context, resumedState) {
3763
+ const logger = context.logger ?? console;
3763
3764
  if (context.verbose && context.verbose >= 1) {
3764
- console.log(`[agent-step] Running agent step '${step2.id}' with input:`, input);
3765
+ logger.log(`[agent-step] Running agent step '${step2.id}' with input:`, input);
3765
3766
  }
3766
3767
  try {
3767
3768
  const model = await getModelFn(step2, context);
@@ -3783,7 +3784,7 @@ var makeAgentStepSpecHandler = (getModelFn) => ({
3783
3784
  throw new Error(`Unknown agent: ${agentName}`);
3784
3785
  }
3785
3786
  if (context.verbose && context.verbose >= 1) {
3786
- console.log(`[agent-step] Using agent: ${agentName}`);
3787
+ logger.log(`[agent-step] Using agent: ${agentName}`);
3787
3788
  }
3788
3789
  const agentOptions = {
3789
3790
  ai: model,
@@ -3803,7 +3804,7 @@ var makeAgentStepSpecHandler = (getModelFn) => ({
3803
3804
  throw new Error("No system prompt specified for the agent step.");
3804
3805
  }
3805
3806
  if (context.verbose && context.verbose >= 1) {
3806
- console.log(`[agent-step] Using generic WorkflowAgent`);
3807
+ logger.log(`[agent-step] Using generic WorkflowAgent`);
3807
3808
  }
3808
3809
  const systemPrompt = resolveTemplatedString(step2.systemPrompt, input);
3809
3810
  return new WorkflowAgent("agent", model, {
@@ -3841,11 +3842,11 @@ var makeAgentStepSpecHandler = (getModelFn) => ({
3841
3842
  }
3842
3843
  }
3843
3844
  if (context.verbose && context.verbose >= 1) {
3844
- console.log(`[agent-step] Starting agent with content:`, JSON.stringify(combinedContentParts, null, 2));
3845
+ logger.log(`[agent-step] Starting agent with content:`, JSON.stringify(combinedContentParts, null, 2));
3845
3846
  }
3846
3847
  const exitReason = await agent.start(combinedContentParts);
3847
3848
  if (context.verbose && context.verbose >= 1) {
3848
- console.log(`[agent-step] Agent exited with reason:`, exitReason);
3849
+ logger.log(`[agent-step] Agent exited with reason:`, exitReason);
3849
3850
  }
3850
3851
  const handleExitReason = (reason) => {
3851
3852
  switch (reason.type) {
@@ -4012,15 +4013,16 @@ var command = (id, ...command2) => ({
4012
4013
 
4013
4014
  // src/workflow/runStep.ts
4014
4015
  var runStep = async (step2, input, context, resumedState, allOutputs) => {
4016
+ const logger = context.logger ?? console;
4015
4017
  if (context.verbose && context.verbose >= 1) {
4016
- console.log(`[workflow] running step: ${step2.id}`);
4017
- console.log(`[workflow] input: ${JSON.stringify(input, null, 2)}`);
4018
+ logger.log(`[workflow] running step: ${step2.id}`);
4019
+ logger.log(`[workflow] input: ${JSON.stringify(input, null, 2)}`);
4018
4020
  }
4019
4021
  try {
4020
4022
  const validatedInput = step2.inputSchema?.parse(input) ?? input;
4021
4023
  const result = await step2.run({ ...validatedInput, $: allOutputs }, context, resumedState);
4022
4024
  if (context.verbose && context.verbose >= 1) {
4023
- console.log(`[workflow] step result: ${step2.id}`, JSON.stringify(result, null, 2));
4025
+ logger.log(`[workflow] step result: ${step2.id}`, JSON.stringify(result, null, 2));
4024
4026
  }
4025
4027
  if (result.type === "success") {
4026
4028
  const validatedOutput = step2.outputSchema?.parse(result.output) ?? result.output;
@@ -4032,7 +4034,7 @@ var runStep = async (step2, input, context, resumedState, allOutputs) => {
4032
4034
  return result;
4033
4035
  } catch (error) {
4034
4036
  if (context.verbose && context.verbose >= 1) {
4035
- console.error(`[workflow] step error: ${step2.id}`, error);
4037
+ logger.error(`[workflow] step error: ${step2.id}`, error);
4036
4038
  }
4037
4039
  return { type: "error", error };
4038
4040
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/core",
3
- "version": "0.9.28",
3
+ "version": "0.9.29",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",