@polka-codes/core 0.9.70 → 0.9.71

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.
@@ -941,7 +941,10 @@ declare const ruleSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
941
941
  export { ruleSchema }
942
942
  export { ruleSchema as ruleSchema_alias_1 }
943
943
 
944
- declare type StepFn = <T>(name: string, fn: () => Promise<T>, options?: StepOptions) => Promise<T>;
944
+ declare interface StepFn {
945
+ <T>(name: string, fn: () => Promise<T>): Promise<T>;
946
+ <T>(name: string, options: StepOptions, fn: () => Promise<T>): Promise<T>;
947
+ }
945
948
  export { StepFn }
946
949
  export { StepFn as StepFn_alias_1 }
947
950
  export { StepFn as StepFn_alias_2 }
package/dist/index.js CHANGED
@@ -1753,7 +1753,7 @@ var agentWorkflow = async (input, { step, tools, logger }) => {
1753
1753
  for (let i = 0; i < maxToolRoundTrips; i++) {
1754
1754
  messages.push(...nextMessage);
1755
1755
  await event(`start-round-${i}`, { kind: "StartRequest" /* StartRequest */, userMessage: nextMessage });
1756
- const assistantMessage = await step(`agent-round-${i}`, async () => {
1756
+ const assistantMessage = await step(`agent-round-${i}`, { retry: 2 }, async () => {
1757
1757
  return await tools.generateText({
1758
1758
  messages,
1759
1759
  tools: toolSet,
@@ -2050,21 +2050,33 @@ var silentLogger = {
2050
2050
  };
2051
2051
  function createContext(tools, stepFn, logger = silentLogger) {
2052
2052
  if (!stepFn) {
2053
- stepFn = async (_name, fn, _options) => fn();
2053
+ stepFn = async (_name, arg2, arg3) => {
2054
+ const fn = typeof arg2 === "function" ? arg2 : arg3;
2055
+ return fn();
2056
+ };
2054
2057
  }
2055
2058
  return { step: stepFn, logger, tools };
2056
2059
  }
2057
2060
  var makeStepFn = () => {
2058
2061
  const results = /* @__PURE__ */ new Map();
2059
2062
  const callStack = [];
2060
- return async (name, fn, options) => {
2063
+ return async (name, arg2, arg3) => {
2064
+ let fn;
2065
+ let options;
2066
+ if (typeof arg2 === "function") {
2067
+ fn = arg2;
2068
+ options = arg3;
2069
+ } else {
2070
+ options = arg2;
2071
+ fn = arg3;
2072
+ }
2061
2073
  callStack.push(name);
2062
2074
  const key = callStack.join(">");
2063
2075
  try {
2064
2076
  if (results.has(key)) {
2065
2077
  return results.get(key);
2066
2078
  }
2067
- const maxRetryCount = options?.retry ?? 1;
2079
+ const maxRetryCount = options?.retry ?? 0;
2068
2080
  let lastError;
2069
2081
  for (let retryCount = 0; retryCount <= maxRetryCount; retryCount++) {
2070
2082
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/core",
3
- "version": "0.9.70",
3
+ "version": "0.9.71",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",