@polka-codes/core 0.9.68 → 0.9.70

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.
@@ -88,7 +88,7 @@ declare function computeRateLimitBackoffSeconds(count: number, baseSeconds?: num
88
88
  export { computeRateLimitBackoffSeconds }
89
89
  export { computeRateLimitBackoffSeconds as computeRateLimitBackoffSeconds_alias_1 }
90
90
 
91
- declare type Config = z.infer<typeof configSchema>;
91
+ declare type Config = NonNullable<z.infer<typeof configSchema>>;
92
92
  export { Config }
93
93
  export { Config as Config_alias_1 }
94
94
 
@@ -96,7 +96,7 @@ declare type ConfigRule = z.infer<typeof ruleSchema>;
96
96
  export { ConfigRule }
97
97
  export { ConfigRule as ConfigRule_alias_1 }
98
98
 
99
- declare const configSchema: z.ZodObject<{
99
+ declare const configSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
100
100
  prices: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodObject<{
101
101
  inputPrice: z.ZodOptional<z.ZodNumber>;
102
102
  outputPrice: z.ZodOptional<z.ZodNumber>;
@@ -149,11 +149,11 @@ declare const configSchema: z.ZodObject<{
149
149
  branch: z.ZodOptional<z.ZodString>;
150
150
  }, z.core.$strict>]>>>, z.ZodString]>>;
151
151
  excludeFiles: z.ZodOptional<z.ZodArray<z.ZodString>>;
152
- }, z.core.$strict>;
152
+ }, z.core.$strict>>>;
153
153
  export { configSchema }
154
154
  export { configSchema as configSchema_alias_1 }
155
155
 
156
- declare function createContext<TTools extends ToolRegistry>(tools: WorkflowTools<TTools>, stepFn?: <T>(name: string, fn: () => Promise<T>) => Promise<T>, logger?: Logger): WorkflowContext<TTools>;
156
+ declare function createContext<TTools extends ToolRegistry>(tools: WorkflowTools<TTools>, stepFn?: StepFn, logger?: Logger): WorkflowContext<TTools>;
157
157
  export { createContext }
158
158
  export { createContext as createContext_alias_1 }
159
159
  export { createContext as createContext_alias_2 }
@@ -821,7 +821,7 @@ export { Logger }
821
821
  export { Logger as Logger_alias_1 }
822
822
  export { Logger as Logger_alias_2 }
823
823
 
824
- declare const makeStepFn: () => (<T>(name: string, fn: () => Promise<T>) => Promise<T>);
824
+ declare const makeStepFn: () => StepFn;
825
825
  export { makeStepFn }
826
826
  export { makeStepFn as makeStepFn_alias_1 }
827
827
  export { makeStepFn as makeStepFn_alias_2 }
@@ -941,6 +941,18 @@ 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>;
945
+ export { StepFn }
946
+ export { StepFn as StepFn_alias_1 }
947
+ export { StepFn as StepFn_alias_2 }
948
+
949
+ declare type StepOptions = {
950
+ retry?: number;
951
+ };
952
+ export { StepOptions }
953
+ export { StepOptions as StepOptions_alias_1 }
954
+ export { StepOptions as StepOptions_alias_2 }
955
+
944
956
  /**
945
957
  * Union type of all possible task events
946
958
  */
@@ -1387,7 +1399,7 @@ export { ToolResponseResult as ToolResponseResult_alias_1 }
1387
1399
 
1388
1400
  declare type ToolResponseResultMedia = {
1389
1401
  type: 'media';
1390
- base64Data: string;
1402
+ data: string;
1391
1403
  mediaType: string;
1392
1404
  url: string;
1393
1405
  };
@@ -1517,7 +1529,7 @@ export { WebProvider as WebProvider_alias_1 }
1517
1529
  export { WebProvider as WebProvider_alias_2 }
1518
1530
 
1519
1531
  declare type WorkflowContext<TTools extends ToolRegistry> = {
1520
- step: <T>(name: string, fn: () => Promise<T>) => Promise<T>;
1532
+ step: StepFn;
1521
1533
  logger: Logger;
1522
1534
  tools: WorkflowTools<TTools>;
1523
1535
  };
package/dist/index.d.ts CHANGED
@@ -87,6 +87,8 @@ export { Logger } from './_tsup-dts-rollup.js';
87
87
  export { ToolSignature } from './_tsup-dts-rollup.js';
88
88
  export { ToolRegistry } from './_tsup-dts-rollup.js';
89
89
  export { WorkflowTools } from './_tsup-dts-rollup.js';
90
+ export { StepOptions } from './_tsup-dts-rollup.js';
91
+ export { StepFn } from './_tsup-dts-rollup.js';
90
92
  export { WorkflowContext } from './_tsup-dts-rollup.js';
91
93
  export { WorkflowFn } from './_tsup-dts-rollup.js';
92
94
  export { makeStepFn } from './_tsup-dts-rollup.js';
package/dist/index.js CHANGED
@@ -194,7 +194,7 @@ var configSchema = z.object({
194
194
  }).optional(),
195
195
  rules: z.array(ruleSchema).optional().or(z.string()).optional(),
196
196
  excludeFiles: z.array(z.string()).optional()
197
- }).strict();
197
+ }).strict().nullish();
198
198
 
199
199
  // src/tool.ts
200
200
  var ToolResponseType = /* @__PURE__ */ ((ToolResponseType2) => {
@@ -761,7 +761,7 @@ var handler8 = async (provider, args) => {
761
761
  {
762
762
  type: "media",
763
763
  url,
764
- base64Data: filePart.base64Data,
764
+ data: filePart.base64Data,
765
765
  mediaType: filePart.mediaType
766
766
  }
767
767
  ]
@@ -1823,11 +1823,6 @@ var agentWorkflow = async (input, { step, tools, logger }) => {
1823
1823
  value: `Tool '${toolCall.toolName}' not found.`
1824
1824
  }
1825
1825
  });
1826
- toolResults.push({
1827
- toolCallId: toolCall.toolCallId,
1828
- toolName: toolCall.toolName,
1829
- output: `Error: Tool '${toolCall.toolName}' not found.`
1830
- });
1831
1826
  continue;
1832
1827
  }
1833
1828
  await event(`event-tool-use-${toolCall.toolName}-${toolCall.toolCallId}`, {
@@ -2055,23 +2050,32 @@ var silentLogger = {
2055
2050
  };
2056
2051
  function createContext(tools, stepFn, logger = silentLogger) {
2057
2052
  if (!stepFn) {
2058
- stepFn = async (_name, fn) => fn();
2053
+ stepFn = async (_name, fn, _options) => fn();
2059
2054
  }
2060
2055
  return { step: stepFn, logger, tools };
2061
2056
  }
2062
2057
  var makeStepFn = () => {
2063
2058
  const results = /* @__PURE__ */ new Map();
2064
2059
  const callStack = [];
2065
- return async (name, fn) => {
2060
+ return async (name, fn, options) => {
2066
2061
  callStack.push(name);
2067
2062
  const key = callStack.join(">");
2068
2063
  try {
2069
2064
  if (results.has(key)) {
2070
2065
  return results.get(key);
2071
2066
  }
2072
- const result = await fn();
2073
- results.set(key, result);
2074
- return result;
2067
+ const maxRetryCount = options?.retry ?? 1;
2068
+ let lastError;
2069
+ for (let retryCount = 0; retryCount <= maxRetryCount; retryCount++) {
2070
+ try {
2071
+ const result = await fn();
2072
+ results.set(key, result);
2073
+ return result;
2074
+ } catch (error) {
2075
+ lastError = error;
2076
+ }
2077
+ }
2078
+ throw lastError;
2075
2079
  } finally {
2076
2080
  callStack.pop();
2077
2081
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/core",
3
- "version": "0.9.68",
3
+ "version": "0.9.70",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",
@@ -19,8 +19,8 @@
19
19
  "dependencies": {
20
20
  "@ai-sdk/provider": "^2.0.0",
21
21
  "@ai-sdk/provider-utils": "^3.0.18",
22
- "ai": "^5.0.104",
23
- "yaml": "^2.8.1",
22
+ "ai": "^5.0.106",
23
+ "yaml": "^2.8.2",
24
24
  "zod": "^4.1.13"
25
25
  }
26
26
  }