@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.
@@ -318,7 +318,7 @@ export declare interface AgentContextInterface {
318
318
  * `workspaces.active` is set, its
319
319
  * {@link import('@orkestrel/workspace').WorkspaceInterface.files} are filtered by
320
320
  * `scope.files` (a three-way allow-list; `undefined` ⇒ all active files), then split by
321
- * carrier: text files ({@link import('@orkestrel/workspace').isText}) render into a dedicated
321
+ * carrier: text files ({@link import('@orkestrel/workspace').isTextContent}) render into a dedicated
322
322
  * `## Workspace` section in the system block — each a fenced
323
323
  * `` File: <path>\n```<language>\n<text>\n``` `` block whose fence is one backtick longer than
324
324
  * the longest backtick run in the text, and never shorter than three — placed immediately after
@@ -7232,6 +7232,29 @@ export declare function raceSignal<T>(promise: Promise<T>, signal: AbortSignal |
7232
7232
  */
7233
7233
  export declare function rankLedgerCut(group: LedgerPlanGroup, unsettled: boolean, category: LedgerCategory | undefined): number;
7234
7234
 
7235
+ /**
7236
+ * Reads a UTF-8 prefix of a byte stream and cancels its remainder.
7237
+ *
7238
+ * @remarks
7239
+ * The `limit` parameter bounds bytes passed to the decoder, including a partial final
7240
+ * character. An omitted limit reads to completion. A source may deliver a chunk larger
7241
+ * than the remaining limit; its unused bytes are discarded without decoding.
7242
+ * The read can overshoot by one source chunk. An abort leaves completion false.
7243
+ *
7244
+ * @param body - The readable byte stream
7245
+ * @param limit - The maximum byte prefix, or undefined for the complete stream
7246
+ * @param signal - The optional cancellation bound; abort returns the decoded prefix
7247
+ * @returns The decoded prefix and whether EOF occurred within the byte budget
7248
+ * @example
7249
+ * ```ts
7250
+ * import { readBodyText } from '@orkestrel/agent'
7251
+ *
7252
+ * const body = new Response('answer').body
7253
+ * if (body !== null) await readBodyText(body, 3) // { text: 'ans', complete: false }
7254
+ * ```
7255
+ */
7256
+ export declare function readBodyText(body: ReadableStream<Uint8Array>, limit?: number, signal?: AbortSignal): Promise<TextRead>;
7257
+
7235
7258
  /**
7236
7259
  * Decodes UTF-8 chunks with a final flush and releases the stream on every exit.
7237
7260
  *
@@ -7279,29 +7302,6 @@ export declare interface Reading {
7279
7302
  readonly score?: number;
7280
7303
  }
7281
7304
 
7282
- /**
7283
- * Reads a UTF-8 prefix of a byte stream and cancels its remainder.
7284
- *
7285
- * @remarks
7286
- * The `limit` parameter bounds bytes passed to the decoder, including a partial final
7287
- * character. An omitted limit reads to completion. A source may deliver a chunk larger
7288
- * than the remaining limit; its unused bytes are discarded without decoding.
7289
- * The read can overshoot by one source chunk. An abort leaves completion false.
7290
- *
7291
- * @param body - The readable byte stream
7292
- * @param limit - The maximum byte prefix, or undefined for the complete stream
7293
- * @param signal - The optional cancellation bound; abort returns the decoded prefix
7294
- * @returns The decoded prefix and whether EOF occurred within the byte budget
7295
- * @example
7296
- * ```ts
7297
- * import { readText } from '@orkestrel/agent'
7298
- *
7299
- * const body = new Response('answer').body
7300
- * if (body !== null) await readText(body, 3) // { text: 'ans', complete: false }
7301
- * ```
7302
- */
7303
- export declare function readText(body: ReadableStream<Uint8Array>, limit?: number, signal?: AbortSignal): Promise<TextRead>;
7304
-
7305
7305
  /** Reports a question a wire could not read a candidate for; it lists the caller's keys and invents no probability. */
7306
7306
  export declare interface Refusal {
7307
7307
  readonly missing: readonly string[];
@@ -318,7 +318,7 @@ export declare interface AgentContextInterface {
318
318
  * `workspaces.active` is set, its
319
319
  * {@link import('@orkestrel/workspace').WorkspaceInterface.files} are filtered by
320
320
  * `scope.files` (a three-way allow-list; `undefined` ⇒ all active files), then split by
321
- * carrier: text files ({@link import('@orkestrel/workspace').isText}) render into a dedicated
321
+ * carrier: text files ({@link import('@orkestrel/workspace').isTextContent}) render into a dedicated
322
322
  * `## Workspace` section in the system block — each a fenced
323
323
  * `` File: <path>\n```<language>\n<text>\n``` `` block whose fence is one backtick longer than
324
324
  * the longest backtick run in the text, and never shorter than three — placed immediately after
@@ -7232,6 +7232,29 @@ export declare function raceSignal<T>(promise: Promise<T>, signal: AbortSignal |
7232
7232
  */
7233
7233
  export declare function rankLedgerCut(group: LedgerPlanGroup, unsettled: boolean, category: LedgerCategory | undefined): number;
7234
7234
 
7235
+ /**
7236
+ * Reads a UTF-8 prefix of a byte stream and cancels its remainder.
7237
+ *
7238
+ * @remarks
7239
+ * The `limit` parameter bounds bytes passed to the decoder, including a partial final
7240
+ * character. An omitted limit reads to completion. A source may deliver a chunk larger
7241
+ * than the remaining limit; its unused bytes are discarded without decoding.
7242
+ * The read can overshoot by one source chunk. An abort leaves completion false.
7243
+ *
7244
+ * @param body - The readable byte stream
7245
+ * @param limit - The maximum byte prefix, or undefined for the complete stream
7246
+ * @param signal - The optional cancellation bound; abort returns the decoded prefix
7247
+ * @returns The decoded prefix and whether EOF occurred within the byte budget
7248
+ * @example
7249
+ * ```ts
7250
+ * import { readBodyText } from '@orkestrel/agent'
7251
+ *
7252
+ * const body = new Response('answer').body
7253
+ * if (body !== null) await readBodyText(body, 3) // { text: 'ans', complete: false }
7254
+ * ```
7255
+ */
7256
+ export declare function readBodyText(body: ReadableStream<Uint8Array>, limit?: number, signal?: AbortSignal): Promise<TextRead>;
7257
+
7235
7258
  /**
7236
7259
  * Decodes UTF-8 chunks with a final flush and releases the stream on every exit.
7237
7260
  *
@@ -7279,29 +7302,6 @@ export declare interface Reading {
7279
7302
  readonly score?: number;
7280
7303
  }
7281
7304
 
7282
- /**
7283
- * Reads a UTF-8 prefix of a byte stream and cancels its remainder.
7284
- *
7285
- * @remarks
7286
- * The `limit` parameter bounds bytes passed to the decoder, including a partial final
7287
- * character. An omitted limit reads to completion. A source may deliver a chunk larger
7288
- * than the remaining limit; its unused bytes are discarded without decoding.
7289
- * The read can overshoot by one source chunk. An abort leaves completion false.
7290
- *
7291
- * @param body - The readable byte stream
7292
- * @param limit - The maximum byte prefix, or undefined for the complete stream
7293
- * @param signal - The optional cancellation bound; abort returns the decoded prefix
7294
- * @returns The decoded prefix and whether EOF occurred within the byte budget
7295
- * @example
7296
- * ```ts
7297
- * import { readText } from '@orkestrel/agent'
7298
- *
7299
- * const body = new Response('answer').body
7300
- * if (body !== null) await readText(body, 3) // { text: 'ans', complete: false }
7301
- * ```
7302
- */
7303
- export declare function readText(body: ReadableStream<Uint8Array>, limit?: number, signal?: AbortSignal): Promise<TextRead>;
7304
-
7305
7305
  /** Reports a question a wire could not read a candidate for; it lists the caller's keys and invents no probability. */
7306
7306
  export declare interface Refusal {
7307
7307
  readonly missing: readonly string[];
@@ -1,12 +1,12 @@
1
- import { ContractError, INTRINSICS, arrayOf, arrayShape, attempt, booleanShape, boundsOf, canonicalStringify, cloneJSONValue, createContract, holds, isArray, isBoolean, isError, isFiniteNumber, isFunction, isJSONValue, isNumber, isObject, isRecord, isString, jsonShape, literalShape, nullableOf, numberShape, objectOf, objectShape, optionalOf, optionalShape, parseJSON, parseJSONAs, parseJSONValue, preview, rawShape, recordOf, recordShape, stringShape, unionShape } from "@orkestrel/contract";
1
+ import { ContractError, INTRINSICS, arrayOf, arrayShape, attempt, booleanShape, boundsOf, canonicalStringify, cloneJSONValue, createContract, errorToMessage, holds, isArray, isBoolean, isError, isFiniteNumber, isFunction, isJSONValue, isNumber, isObject, isRecord, isString, jsonShape, literalShape, nullableOf, numberShape, objectOf, objectShape, optionalOf, optionalShape, parseJSON, parseJSONAs, parseJSONValue, preview, rawShape, recordOf, recordShape, stringShape, unionShape } from "@orkestrel/contract";
2
2
  import { createTokenBudget, createTokenMeter, isBudget, isBudgetError, isTokenUsage } from "@orkestrel/budget";
3
3
  import { Timeout, createTimeout } from "@orkestrel/timeout";
4
4
  import { createDatabase, createMemoryDriver } from "@orkestrel/database";
5
5
  import { Emitter } from "@orkestrel/emitter";
6
6
  import { ToolManager, createTool, createToolManager, isToolCall } from "@orkestrel/tool";
7
- import { WorkspaceManager, isBinary, isText } from "@orkestrel/workspace";
7
+ import { WorkspaceManager, isBinary, isTextContent } from "@orkestrel/workspace";
8
8
  import { createQueue } from "@orkestrel/queue";
9
- import { createRunner, errorToMessage } from "@orkestrel/workflow";
9
+ import { createRunner } from "@orkestrel/workflow";
10
10
  import { createAbort } from "@orkestrel/abort";
11
11
  // src/core/constants.ts
12
12
  /**
@@ -922,7 +922,7 @@ async function readFailure(response, prefix, signal) {
922
922
  status
923
923
  };
924
924
  }
925
- return readText(body, MAX_ERROR_BODY_LENGTH, signal).then((read) => {
925
+ return readBodyText(body, MAX_ERROR_BODY_LENGTH, signal).then((read) => {
926
926
  signal.throwIfAborted();
927
927
  return {
928
928
  message: `${prefix} ${status}${read.text === "" ? "" : ` - ${read.text}`}`,
@@ -949,13 +949,13 @@ async function readFailure(response, prefix, signal) {
949
949
  * @returns The decoded prefix and whether EOF occurred within the byte budget
950
950
  * @example
951
951
  * ```ts
952
- * import { readText } from '@orkestrel/agent'
952
+ * import { readBodyText } from '@orkestrel/agent'
953
953
  *
954
954
  * const body = new Response('answer').body
955
- * if (body !== null) await readText(body, 3) // { text: 'ans', complete: false }
955
+ * if (body !== null) await readBodyText(body, 3) // { text: 'ans', complete: false }
956
956
  * ```
957
957
  */
958
- async function readText(body, limit, signal) {
958
+ async function readBodyText(body, limit, signal) {
959
959
  const reader = body.getReader();
960
960
  const decoder = new TextDecoder();
961
961
  try {
@@ -1979,7 +1979,7 @@ var AgentJudge = class {
1979
1979
  throw new JudgeError("HTTP", message, options);
1980
1980
  }
1981
1981
  if (response.body === null) throw new JudgeError("PROTOCOL", "judge error: no response body");
1982
- const text = await readText(response.body, void 0, combined);
1982
+ const text = await readBodyText(response.body, void 0, combined);
1983
1983
  combined.throwIfAborted();
1984
1984
  const value = parseJSON(text.text);
1985
1985
  if (value === void 0) throw new JudgeError("PROTOCOL", "judge error: invalid JSON body");
@@ -2201,7 +2201,7 @@ function createRelay(options) {
2201
2201
  return new Response(void 0, { status: 401 });
2202
2202
  }
2203
2203
  if (request.body === null) return new Response(void 0, { status: 400 });
2204
- const read = await readText(request.body, limit ?? 1048576, request.signal).catch(() => void 0);
2204
+ const read = await readBodyText(request.body, limit ?? 1048576, request.signal).catch(() => void 0);
2205
2205
  if (read === void 0) return new Response(void 0, { status: request.signal.aborted ? 413 : 400 });
2206
2206
  if (!read.complete) return new Response(void 0, { status: 413 });
2207
2207
  const parsed = parseJSONAs(read.text, providerRequestContract.is);
@@ -4108,7 +4108,7 @@ var AgentContext = class {
4108
4108
  const instructed = renderSection(this.#instructions.open, instructions, (one) => this.#instructions.render(one), this.#instructions.close);
4109
4109
  if (instructed !== void 0) parts.push(instructed);
4110
4110
  const files = filterAllowList(scope?.files, this.#workspaces.active?.files() ?? [], (one) => one.path);
4111
- const documented = renderSection(WORKSPACE_SECTION_HEADER, files.flatMap((file) => isText(file.content) ? [{
4111
+ const documented = renderSection(WORKSPACE_SECTION_HEADER, files.flatMap((file) => isTextContent(file.content) ? [{
4112
4112
  path: file.path,
4113
4113
  language: file.content.language,
4114
4114
  text: file.content.text
@@ -8567,6 +8567,6 @@ var Ledger = class {
8567
8567
  function createLedger(provider, options) {
8568
8568
  return new Ledger(provider, options);
8569
8569
  }
8570
- export { Agent, AgentContext, AgentError, AgentFanout, AgentJobError, AgentJudge, AgentProvider, AgentRegistry, Authority, CONVERSATION_RECAP_PREFIX, Channel, Classifier, Conversation, ConversationError, ConversationManager, DECISIVE_CATEGORIES, DEFAULT_AGENT_LIMIT, DEFAULT_AUTHORITY_ZONE, DEFAULT_CONVERSATION_KEEP, DEFAULT_LEDGER_LIMIT, DEFAULT_LEDGER_SHARE, DEFAULT_PROVIDER_TIMEOUT, DEFAULT_RECALL_LIMIT, DEFAULT_RELAY_LIMIT, DETERMINISTIC_JUDGE_ERROR, DatabaseConversationStore, Gauge, IMAGE_TOKEN_ESTIMATE, INVALID_RELAY_STATUS, Instruction, InstructionManager, JudgeAbortError, JudgeError, JudgmentManager, LEDGER_CATEGORIES, LEDGER_NOTES, LEDGER_OWNER_PREFIX, LEDGER_QUESTIONS, LEDGER_RULES_KEY, LEDGER_SCALE_DRIFT, Ledger, LedgerError, LedgerRequest, MAX_ERROR_BODY_LENGTH, MESSAGE_ROLES, MESSAGE_TOKEN_OVERHEAD, MemoryConversationStore, OVERSIZED_RELAY_STATUS, PLACED_CATEGORIES, ProviderAbortError, ProviderError, QUIET_CATEGORIES, RELAY_CONTENT_TYPE, RELAY_PROVIDER_MESSAGE, RelayProvider, RelayStream, SYSTEM_ONE_PATH, Scope, ScopeManager, SystemOneJudge, THINK_CLOSE, THINK_OPEN, ThinkSplitter, UNAUTHORIZED_RELAY_STATUS, UPSTREAM_RELAY_STATUS, WORKSPACE_SECTION_HEADER, agentResultToJSON, armReaderAbort, assembleResult, attachImages, attachUserImages, buildJudgeResult, buildJudgments, buildLedgerRenderContext, buildLines, buildProviderHeaders, buildProviderResult, buildRecallMessage, buildRecapMessage, buildRecords, buildSummaryMessage, chargeUsage, collectAmendments, collectExchanges, collectImageData, collectLive, collectNames, collectProjectionIds, collectRegistry, collectToolGroups, computeReading, computeThinking, copyJSON, createAgent, createAgentContext, createAgentQueue, createAgentRegistry, createAgentRunner, createAuthority, createChannel, createConversation, createConversationManager, createDatabaseConversationStore, createInstruction, createInstructionManager, createLedger, createMemoryConversationStore, createRelay, createRelayProvider, createScope, createScopeManager, createSystemOneJudge, createThinkSplitter, cutListing, denyCall, estimateMessages, estimateRequest, estimateTokens, extractQueueOptions, extractSystemOneAnswer, extractSystemOneUsage, extractTokens, extractWords, filterAllowList, findLedgerCall, fitSlope, handleAgentQueueJob, hasCalls, identifyLookup, inferStop, intersectKeys, isAgentError, isAgentJobError, isConversationError, isConversationSnapshot, isFraction, isJudgeAbortError, isJudgeEntry, isJudgeError, isJudgeQuestion, isJudgment, isLedgerError, isMessage, isNonNegativeSafeInteger, isPositiveSafeInteger, isProviderAbortError, isProviderError, isSection, isSystemOneAnswer, isSystemOneResponse, joinThinking, linkOwners, matchEntities, matchesCutLine, matchesJudgment, measureMessage, measureRequest, messageContract, messageShape, normalizeArgument, placeMember, providerRequestContract, providerRequestShape, providerResultContract, providerResultShape, questionToSystemOne, raceSignal, rankLedgerCut, readChunks, readFailure, readText, relayFrameContract, relayFrameShape, releaseReader, removeEntries, renderCauseChain, renderFencedFile, renderJSON, renderLedgerAnnotation, renderLedgerPinned, renderLedgerRecord, renderLookupCall, renderSection, renderStub, renderToolValue, renderTopicNames, requestToRelay, requireBudget, requireEntry, requireJudgment, requireKeep, requireLimit, requireRolling, requireSectionsCap, resolvePredict, sanitizeToken, sanitizeUsage, scanAmendments, selectRecords, settleAgentJob, splitResultLines, splitSentences, splitTopic, splitWords, stripThinking, sumUsage, tokenUsageToJSON, toolCallShape };
8570
+ export { Agent, AgentContext, AgentError, AgentFanout, AgentJobError, AgentJudge, AgentProvider, AgentRegistry, Authority, CONVERSATION_RECAP_PREFIX, Channel, Classifier, Conversation, ConversationError, ConversationManager, DECISIVE_CATEGORIES, DEFAULT_AGENT_LIMIT, DEFAULT_AUTHORITY_ZONE, DEFAULT_CONVERSATION_KEEP, DEFAULT_LEDGER_LIMIT, DEFAULT_LEDGER_SHARE, DEFAULT_PROVIDER_TIMEOUT, DEFAULT_RECALL_LIMIT, DEFAULT_RELAY_LIMIT, DETERMINISTIC_JUDGE_ERROR, DatabaseConversationStore, Gauge, IMAGE_TOKEN_ESTIMATE, INVALID_RELAY_STATUS, Instruction, InstructionManager, JudgeAbortError, JudgeError, JudgmentManager, LEDGER_CATEGORIES, LEDGER_NOTES, LEDGER_OWNER_PREFIX, LEDGER_QUESTIONS, LEDGER_RULES_KEY, LEDGER_SCALE_DRIFT, Ledger, LedgerError, LedgerRequest, MAX_ERROR_BODY_LENGTH, MESSAGE_ROLES, MESSAGE_TOKEN_OVERHEAD, MemoryConversationStore, OVERSIZED_RELAY_STATUS, PLACED_CATEGORIES, ProviderAbortError, ProviderError, QUIET_CATEGORIES, RELAY_CONTENT_TYPE, RELAY_PROVIDER_MESSAGE, RelayProvider, RelayStream, SYSTEM_ONE_PATH, Scope, ScopeManager, SystemOneJudge, THINK_CLOSE, THINK_OPEN, ThinkSplitter, UNAUTHORIZED_RELAY_STATUS, UPSTREAM_RELAY_STATUS, WORKSPACE_SECTION_HEADER, agentResultToJSON, armReaderAbort, assembleResult, attachImages, attachUserImages, buildJudgeResult, buildJudgments, buildLedgerRenderContext, buildLines, buildProviderHeaders, buildProviderResult, buildRecallMessage, buildRecapMessage, buildRecords, buildSummaryMessage, chargeUsage, collectAmendments, collectExchanges, collectImageData, collectLive, collectNames, collectProjectionIds, collectRegistry, collectToolGroups, computeReading, computeThinking, copyJSON, createAgent, createAgentContext, createAgentQueue, createAgentRegistry, createAgentRunner, createAuthority, createChannel, createConversation, createConversationManager, createDatabaseConversationStore, createInstruction, createInstructionManager, createLedger, createMemoryConversationStore, createRelay, createRelayProvider, createScope, createScopeManager, createSystemOneJudge, createThinkSplitter, cutListing, denyCall, estimateMessages, estimateRequest, estimateTokens, extractQueueOptions, extractSystemOneAnswer, extractSystemOneUsage, extractTokens, extractWords, filterAllowList, findLedgerCall, fitSlope, handleAgentQueueJob, hasCalls, identifyLookup, inferStop, intersectKeys, isAgentError, isAgentJobError, isConversationError, isConversationSnapshot, isFraction, isJudgeAbortError, isJudgeEntry, isJudgeError, isJudgeQuestion, isJudgment, isLedgerError, isMessage, isNonNegativeSafeInteger, isPositiveSafeInteger, isProviderAbortError, isProviderError, isSection, isSystemOneAnswer, isSystemOneResponse, joinThinking, linkOwners, matchEntities, matchesCutLine, matchesJudgment, measureMessage, measureRequest, messageContract, messageShape, normalizeArgument, placeMember, providerRequestContract, providerRequestShape, providerResultContract, providerResultShape, questionToSystemOne, raceSignal, rankLedgerCut, readBodyText, readChunks, readFailure, relayFrameContract, relayFrameShape, releaseReader, removeEntries, renderCauseChain, renderFencedFile, renderJSON, renderLedgerAnnotation, renderLedgerPinned, renderLedgerRecord, renderLookupCall, renderSection, renderStub, renderToolValue, renderTopicNames, requestToRelay, requireBudget, requireEntry, requireJudgment, requireKeep, requireLimit, requireRolling, requireSectionsCap, resolvePredict, sanitizeToken, sanitizeUsage, scanAmendments, selectRecords, settleAgentJob, splitResultLines, splitSentences, splitTopic, splitWords, stripThinking, sumUsage, tokenUsageToJSON, toolCallShape };
8571
8571
 
8572
8572
  //# sourceMappingURL=index.js.map