@orkestrel/agent 0.0.33 → 0.0.34
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.cjs +10 -10
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +24 -24
- package/dist/src/core/index.d.ts +24 -24
- package/dist/src/core/index.js +11 -11
- package/dist/src/core/index.js.map +1 -1
- package/package.json +21 -21
package/dist/src/core/index.cjs
CHANGED
|
@@ -923,7 +923,7 @@ async function readFailure(response, prefix, signal) {
|
|
|
923
923
|
status
|
|
924
924
|
};
|
|
925
925
|
}
|
|
926
|
-
return
|
|
926
|
+
return readBodyText(body, MAX_ERROR_BODY_LENGTH, signal).then((read) => {
|
|
927
927
|
signal.throwIfAborted();
|
|
928
928
|
return {
|
|
929
929
|
message: `${prefix} ${status}${read.text === "" ? "" : ` - ${read.text}`}`,
|
|
@@ -950,13 +950,13 @@ async function readFailure(response, prefix, signal) {
|
|
|
950
950
|
* @returns The decoded prefix and whether EOF occurred within the byte budget
|
|
951
951
|
* @example
|
|
952
952
|
* ```ts
|
|
953
|
-
* import {
|
|
953
|
+
* import { readBodyText } from '@orkestrel/agent'
|
|
954
954
|
*
|
|
955
955
|
* const body = new Response('answer').body
|
|
956
|
-
* if (body !== null) await
|
|
956
|
+
* if (body !== null) await readBodyText(body, 3) // { text: 'ans', complete: false }
|
|
957
957
|
* ```
|
|
958
958
|
*/
|
|
959
|
-
async function
|
|
959
|
+
async function readBodyText(body, limit, signal) {
|
|
960
960
|
const reader = body.getReader();
|
|
961
961
|
const decoder = new TextDecoder();
|
|
962
962
|
try {
|
|
@@ -1980,7 +1980,7 @@ var AgentJudge = class {
|
|
|
1980
1980
|
throw new JudgeError("HTTP", message, options);
|
|
1981
1981
|
}
|
|
1982
1982
|
if (response.body === null) throw new JudgeError("PROTOCOL", "judge error: no response body");
|
|
1983
|
-
const text = await
|
|
1983
|
+
const text = await readBodyText(response.body, void 0, combined);
|
|
1984
1984
|
combined.throwIfAborted();
|
|
1985
1985
|
const value = (0, _orkestrel_contract.parseJSON)(text.text);
|
|
1986
1986
|
if (value === void 0) throw new JudgeError("PROTOCOL", "judge error: invalid JSON body");
|
|
@@ -2202,7 +2202,7 @@ function createRelay(options) {
|
|
|
2202
2202
|
return new Response(void 0, { status: 401 });
|
|
2203
2203
|
}
|
|
2204
2204
|
if (request.body === null) return new Response(void 0, { status: 400 });
|
|
2205
|
-
const read = await
|
|
2205
|
+
const read = await readBodyText(request.body, limit ?? 1048576, request.signal).catch(() => void 0);
|
|
2206
2206
|
if (read === void 0) return new Response(void 0, { status: request.signal.aborted ? 413 : 400 });
|
|
2207
2207
|
if (!read.complete) return new Response(void 0, { status: 413 });
|
|
2208
2208
|
const parsed = (0, _orkestrel_contract.parseJSONAs)(read.text, providerRequestContract.is);
|
|
@@ -4109,7 +4109,7 @@ var AgentContext = class {
|
|
|
4109
4109
|
const instructed = renderSection(this.#instructions.open, instructions, (one) => this.#instructions.render(one), this.#instructions.close);
|
|
4110
4110
|
if (instructed !== void 0) parts.push(instructed);
|
|
4111
4111
|
const files = filterAllowList(scope?.files, this.#workspaces.active?.files() ?? [], (one) => one.path);
|
|
4112
|
-
const documented = renderSection(WORKSPACE_SECTION_HEADER, files.flatMap((file) => (0, _orkestrel_workspace.
|
|
4112
|
+
const documented = renderSection(WORKSPACE_SECTION_HEADER, files.flatMap((file) => (0, _orkestrel_workspace.isTextContent)(file.content) ? [{
|
|
4113
4113
|
path: file.path,
|
|
4114
4114
|
language: file.content.language,
|
|
4115
4115
|
text: file.content.text
|
|
@@ -5605,7 +5605,7 @@ var Agent = class {
|
|
|
5605
5605
|
if (authority === void 0) return void 0;
|
|
5606
5606
|
const evaluated = (0, _orkestrel_contract.attempt)(() => authority.evaluate({ call }));
|
|
5607
5607
|
if (!evaluated.success) {
|
|
5608
|
-
const reason = (0,
|
|
5608
|
+
const reason = (0, _orkestrel_contract.errorToMessage)(evaluated.error);
|
|
5609
5609
|
const denial = denyCall(call, reason);
|
|
5610
5610
|
this.#emitter.emit("deny", call, reason);
|
|
5611
5611
|
return denial;
|
|
@@ -7175,7 +7175,7 @@ var Classifier = class {
|
|
|
7175
7175
|
*/
|
|
7176
7176
|
async classify(requests, signal) {
|
|
7177
7177
|
const results = [];
|
|
7178
|
-
const fault = await this.#gather(requests, signal, results).then(() => void 0, (error) => (0, _orkestrel_contract.isError)(error) ? error : new Error((0,
|
|
7178
|
+
const fault = await this.#gather(requests, signal, results).then(() => void 0, (error) => (0, _orkestrel_contract.isError)(error) ? error : new Error((0, _orkestrel_contract.errorToMessage)(error)));
|
|
7179
7179
|
const usage = results.reduce((total, result) => result.usage === void 0 ? total : sumUsage(total, result.usage), void 0);
|
|
7180
7180
|
return {
|
|
7181
7181
|
judgments: results.flatMap((result) => result.judgments),
|
|
@@ -8736,9 +8736,9 @@ exports.providerResultShape = providerResultShape;
|
|
|
8736
8736
|
exports.questionToSystemOne = questionToSystemOne;
|
|
8737
8737
|
exports.raceSignal = raceSignal;
|
|
8738
8738
|
exports.rankLedgerCut = rankLedgerCut;
|
|
8739
|
+
exports.readBodyText = readBodyText;
|
|
8739
8740
|
exports.readChunks = readChunks;
|
|
8740
8741
|
exports.readFailure = readFailure;
|
|
8741
|
-
exports.readText = readText;
|
|
8742
8742
|
exports.relayFrameContract = relayFrameContract;
|
|
8743
8743
|
exports.relayFrameShape = relayFrameShape;
|
|
8744
8744
|
exports.releaseReader = releaseReader;
|