@polka-codes/core 0.9.69 → 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.
- package/dist/_tsup-dts-rollup.d.ts +15 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.js +14 -5
- package/package.json +1 -1
|
@@ -153,7 +153,7 @@ declare const configSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
|
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?:
|
|
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: () =>
|
|
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
|
*/
|
|
@@ -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:
|
|
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
|
@@ -2050,23 +2050,32 @@ var silentLogger = {
|
|
|
2050
2050
|
};
|
|
2051
2051
|
function createContext(tools, stepFn, logger = silentLogger) {
|
|
2052
2052
|
if (!stepFn) {
|
|
2053
|
-
stepFn = async (_name, fn) => fn();
|
|
2053
|
+
stepFn = async (_name, fn, _options) => fn();
|
|
2054
2054
|
}
|
|
2055
2055
|
return { step: stepFn, logger, tools };
|
|
2056
2056
|
}
|
|
2057
2057
|
var makeStepFn = () => {
|
|
2058
2058
|
const results = /* @__PURE__ */ new Map();
|
|
2059
2059
|
const callStack = [];
|
|
2060
|
-
return async (name, fn) => {
|
|
2060
|
+
return async (name, fn, options) => {
|
|
2061
2061
|
callStack.push(name);
|
|
2062
2062
|
const key = callStack.join(">");
|
|
2063
2063
|
try {
|
|
2064
2064
|
if (results.has(key)) {
|
|
2065
2065
|
return results.get(key);
|
|
2066
2066
|
}
|
|
2067
|
-
const
|
|
2068
|
-
|
|
2069
|
-
|
|
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;
|
|
2070
2079
|
} finally {
|
|
2071
2080
|
callStack.pop();
|
|
2072
2081
|
}
|