@orkestrel/agent 0.0.23 → 0.0.25
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/src/core/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { arrayOf, arrayShape, attempt, booleanShape, cloneJSONValue, createContract, isArray, isBoolean, isFiniteNumber, isObject, isRecord, isString, jsonShape, literalShape, numberShape, objectShape, optionalShape, parseJSONAs, parseJSONValue, rawShape, recordShape, stringShape, unionShape } from "@orkestrel/contract";
|
|
1
|
+
import { arrayOf, arrayShape, attempt, booleanShape, cloneJSONValue, createContract, isArray, isBoolean, isFiniteNumber, isInstance, isObject, isRecord, isString, jsonShape, literalShape, numberShape, objectShape, optionalShape, parseJSONAs, parseJSONValue, rawShape, recordShape, stringShape, unionShape } from "@orkestrel/contract";
|
|
2
2
|
import { createDatabase, createMemoryDriver } from "@orkestrel/database";
|
|
3
3
|
import { createQueue } from "@orkestrel/queue";
|
|
4
4
|
import { createRunner, errorToMessage } from "@orkestrel/workflow";
|
|
@@ -187,7 +187,7 @@ var ProviderAbortError = class extends Error {
|
|
|
187
187
|
* ```
|
|
188
188
|
*/
|
|
189
189
|
function isProviderAbortError(value) {
|
|
190
|
-
return value
|
|
190
|
+
return isInstance(value, ProviderAbortError);
|
|
191
191
|
}
|
|
192
192
|
/**
|
|
193
193
|
* Reports an {@link AgentInterface} run that ended {@link AgentResult.partial} under a
|
|
@@ -234,7 +234,7 @@ var AgentJobError = class extends Error {
|
|
|
234
234
|
* ```
|
|
235
235
|
*/
|
|
236
236
|
function isAgentJobError(value) {
|
|
237
|
-
return value
|
|
237
|
+
return isInstance(value, AgentJobError);
|
|
238
238
|
}
|
|
239
239
|
/**
|
|
240
240
|
* Reports a conversation with no {@link ConversationSummaryHandler} to fold its messages with,
|
|
@@ -278,7 +278,7 @@ var ConversationError = class extends Error {
|
|
|
278
278
|
* ```
|
|
279
279
|
*/
|
|
280
280
|
function isConversationError(value) {
|
|
281
|
-
return value
|
|
281
|
+
return isInstance(value, ConversationError);
|
|
282
282
|
}
|
|
283
283
|
/**
|
|
284
284
|
* Reports a concurrent run that would corrupt shared per-agent accounting, or a rehydration
|
|
@@ -324,7 +324,7 @@ var AgentError = class extends Error {
|
|
|
324
324
|
* ```
|
|
325
325
|
*/
|
|
326
326
|
function isAgentError(value) {
|
|
327
|
-
return value
|
|
327
|
+
return isInstance(value, AgentError);
|
|
328
328
|
}
|
|
329
329
|
/**
|
|
330
330
|
* Reports a coded provider failure with its HTTP status and underlying cause when available.
|
|
@@ -358,7 +358,7 @@ var ProviderError = class extends Error {
|
|
|
358
358
|
* ```
|
|
359
359
|
*/
|
|
360
360
|
function isProviderError(value) {
|
|
361
|
-
return value
|
|
361
|
+
return isInstance(value, ProviderError);
|
|
362
362
|
}
|
|
363
363
|
//#endregion
|
|
364
364
|
//#region src/core/shapers.ts
|
|
@@ -725,7 +725,7 @@ function renderFencedFile(path, language, content) {
|
|
|
725
725
|
* @returns The floored count, or `0` when the value is non-finite or non-positive
|
|
726
726
|
*/
|
|
727
727
|
function sanitizeToken(value) {
|
|
728
|
-
return
|
|
728
|
+
return isFiniteNumber(value) && value > 0 ? Math.floor(value) : 0;
|
|
729
729
|
}
|
|
730
730
|
/**
|
|
731
731
|
* Sanitizes a {@link TokenUsage} into safe, non-negative integers — the guard an agent's
|
|
@@ -3147,7 +3147,7 @@ var RelayStream = class {
|
|
|
3147
3147
|
if (step.done) this.#finish(controller);
|
|
3148
3148
|
} catch (error) {
|
|
3149
3149
|
if (this.#settled) return;
|
|
3150
|
-
const frame = error
|
|
3150
|
+
const frame = isProviderAbortError(error) ? {
|
|
3151
3151
|
channel: "abort",
|
|
3152
3152
|
partial: error.partial
|
|
3153
3153
|
} : {
|