@parcha/agentrun-kernel 0.1.0-beta.54 → 0.1.0-beta.56
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/CHANGELOG.md +16 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/kernel/cap/free.d.ts +26 -2
- package/dist/kernel/cap/free.js +33 -4
- package/dist/kernel/cap/index.d.ts +1 -1
- package/dist/kernel/cap/index.js +1 -1
- package/dist/kernel/cap/run-cap.d.ts +5 -1
- package/dist/kernel/cap/run-cap.js +18 -5
- package/dist/kernel/cap/types.d.ts +3 -0
- package/dist/run-booking.js +10 -3
- package/dist/runner.d.ts +11 -1
- package/dist/runner.js +19 -9
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## 0.1.0-beta.55 (2026-11-23)
|
|
6
|
+
|
|
7
|
+
- The server lists the models of this machine's Ollama itself, as `ollama/<tag>` on pi, with no key and no gateway. Start Ollama and its models are in capabilities, the Model picker and pi's free models within half a minute, with no restart. `OLLAMA_HOST` says where it listens, read as the ollama CLI reads it (plain http to loopback alone). Unset, it is 127.0.0.1:11434 only on one owner's own server on their own machine (the rule `--harness-sign-in` starts under); a shared server asks Ollama only where `OLLAMA_HOST` names it. A refused `OLLAMA_HOST` is said once in the server's log, never its value. Requests go to Ollama's own `/api/chat` with `num_ctx` the least of 65,536, the model's trained context and `OLLAMA_CONTEXT_LENGTH` when it is set. A model without the `tools` capability takes its tools as text. They cost $0 and never count toward `AGENTRUN_FREE_MODEL_REQUESTS`, and the console shows no request limit for them. With no model key held, pi's default is the first Ollama model that calls tools; any key wins. A down or stuck Ollama lists nothing and stalls nothing. <!-- changes/ollama-provider.md -->
|
|
8
|
+
- On upgrade: a server with no model key and Ollama running now starts the runs it refused before, on Ollama's first model that calls tools. On a server with an OpenRouter key, Ollama's models head pi's `free_models`, before OpenRouter's free ones. Pulling a model can change the no-key default, and a saved agent that names no model follows it: name the model to pin it.
|
|
9
|
+
- `agentrun service install --env OLLAMA_HOST=<host:port>` gives the service an Ollama off its default address. A service that reaches Ollama through `AGENT_MODEL_BASE_URL` keeps working as before; under a gateway, Ollama is never asked.
|
|
10
|
+
- A run's page names the model it ran on, a run on the host default included, read from its `tokens` usage line: "qwen3:8b · local (Ollama)" for an Ollama model.
|
|
11
|
+
- A run that names no model, on the host's Ollama default, no longer stays refused once that tag is removed from Ollama. Past the listing's half minute, a tag that no longer answers lists Ollama again once, and the run goes to the next model that calls tools, or gets the no-model words. An agent that names `ollama/<tag>` keeps it.
|
|
12
|
+
- A model without the `thinking` capability whose answer opens with `<think>` has that part as thinking up to `</think>`, so the tags stay out of the answer.
|
|
13
|
+
- `CapModel.local` marks a model on the host's own machine: free, and never counted toward the server's free-model limit (`limitedFree`). An agent's own `max_requests` still counts its requests, beside the run's other free ones, so a run on Ollama stops there.
|
|
14
|
+
- Capabilities show pi as available only when a run started now has a model: a key, the gateway's model, the ChatGPT plan, the faux model, or an Ollama model that calls tools. An Ollama whose models take no tools keeps them in the picker, but pi reads not available. With no model, pi's words name Ollama first where the server asks one: "No model yet: start Ollama and pull a model with tools, or add a model key in Settings → Model keys". A shared server with no `OLLAMA_HOST` asks no Ollama, so its words name a key alone. A key saved or an Ollama started later turns it available with no restart.
|
|
15
|
+
- A run on your Claude or ChatGPT plan counts each plan request once in its cost's `plan` even when its booking was written twice, its spend cap no longer reads a plan request in flight as not priced, and a workflow decision on such a run is charged what its provider charged instead of being counted as the plan's at $0. A decision on a run on a free model whose charge was lost now reads as unknown, never as a known $0. <!-- changes/plan-cost-once.md -->
|
|
16
|
+
|
|
17
|
+
This applies to new runs only. Decisions already booked as the plan's at $0 stay $0, and so does a decision marked the plan's before the deploy that a resumed run cuts after it: nothing is backfilled.
|
|
18
|
+
|
|
19
|
+
Some decisions with no cap on a plan run now read as unknown (`cost.usd` null) where they read $0 before. Unknown is the correct reading: their provider charged them and the charge was not said.
|
|
20
|
+
|
|
5
21
|
## 0.1.0-beta.53 (2026-11-22)
|
|
6
22
|
|
|
7
23
|
- A harness recipe now covers an outside agent's release as its vendor ships it (Google's agy CLI among them), and the owner's own sign-in, made by the agent itself: <!-- changes/recipes-outside-harness.md -->
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { answeredUnpriced, costOfParts, createHarnessRunner, CUT_AT_HOLD, modelPortFor, rebooked, sessionSpendOf, SUBMIT_TOOL, RUNNER_RECORDS, turnCostOf } from "./runner.js";
|
|
1
|
+
export { answeredUnpriced, billedToPlan, costOfParts, createHarnessRunner, CUT_AT_HOLD, modelPortFor, rebooked, sessionSpendOf, SUBMIT_TOOL, RUNNER_RECORDS, turnCostOf } from "./runner.js";
|
|
2
2
|
export { RECORD_WAIT_MS, runBooking, type RunBookingOptions, type RunSessions, WAIT_POLL_FIRST_MS, WAIT_POLL_MOST_MS, WAIT_STALL_MS } from "./run-booking.js";
|
|
3
3
|
export type { Admission, BeforeRequest, Refusal, HarnessRunner, HarnessRunnerOptions, HoldShort, InFlight, ModelBooking, ModelPortEvent, ModelPortOptions, CostParts, SessionCost } from "./runner.js";
|
|
4
4
|
export { HarnessRunError, SessionFenced, TurnParked } from "./errors.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { answeredUnpriced, costOfParts, createHarnessRunner, CUT_AT_HOLD, modelPortFor, rebooked, sessionSpendOf, SUBMIT_TOOL, RUNNER_RECORDS, turnCostOf } from "./runner.js";
|
|
1
|
+
export { answeredUnpriced, billedToPlan, costOfParts, createHarnessRunner, CUT_AT_HOLD, modelPortFor, rebooked, sessionSpendOf, SUBMIT_TOOL, RUNNER_RECORDS, turnCostOf } from "./runner.js";
|
|
2
2
|
export { RECORD_WAIT_MS, runBooking, WAIT_POLL_FIRST_MS, WAIT_POLL_MOST_MS, WAIT_STALL_MS } from "./run-booking.js";
|
|
3
3
|
export { HarnessRunError, SessionFenced, TurnParked } from "./errors.js";
|
|
4
4
|
export { CODEMODE, DEFER_CATALOG_OVER, defersCatalog, isCatalogWire, META_TOOLS, TOOLS_CALL, TOOLS_SEARCH } from "./tool-deferral.js";
|
|
@@ -13,9 +13,13 @@ export declare const ROUTERS: ReadonlySet<string>;
|
|
|
13
13
|
* local-models.ts isFree, the model picker's free mark, reads it on the catalog entry's price. */
|
|
14
14
|
export declare function freeModel(model: CapModel | undefined): boolean;
|
|
15
15
|
/** Whether `request` is on a free model (freeModel, as `modelOf` prices it): never one with a fee beside it (a native
|
|
16
|
-
* web search's) or a paid step's charge, which cost dollars, nor one named by a router.
|
|
17
|
-
*
|
|
16
|
+
* web search's) or a paid step's charge, which cost dollars, nor one named by a router. What the runner books at a known
|
|
17
|
+
* $0 (Admitted.free); the run's limit counts those of them that limitedFree says. */
|
|
18
18
|
export declare function freeRequest(request: Parameters<BeforeRequest>[0], modelOf: (id: string, route?: string) => CapModel | undefined): boolean;
|
|
19
|
+
/** Whether a free request on `model` counts toward the server's free-model limit: a free model's (freeModel), but a local
|
|
20
|
+
* one's (CapModel.local) never. The one rule for that limit's count and its wrap-up note. The agent's own limit counts a
|
|
21
|
+
* local one as well (run-cap.ts). */
|
|
22
|
+
export declare function limitedFree(model: CapModel | undefined): boolean;
|
|
19
23
|
/** A ChatGPT plan's model as the cap prices it, on every harness alike (pi's route and a CLI's model proxy): billed to the
|
|
20
24
|
* plan, so no price here (never its $0 listing, never an unknown price) and the plan's mark (CapModel.plan). */
|
|
21
25
|
export declare function planCapModel(id: string, api: string, outputCeiling: number | null): CapModel;
|
|
@@ -28,11 +32,28 @@ export declare const FREE_WRAP_UP_MARGIN = 3;
|
|
|
28
32
|
export declare function freeWrapUpDue(limit: number, made: number): {
|
|
29
33
|
left: number;
|
|
30
34
|
} | undefined;
|
|
35
|
+
/** The free limit a run's next request on `model` is nearest, and what counts toward it: the agent's own (`own`,
|
|
36
|
+
* max_requests) over its free and local requests together, and on a free model with a quota behind it (limitedFree) the
|
|
37
|
+
* run's free limit (`server`) over its free requests alone; of the two, the one with fewer requests left. Undefined where
|
|
38
|
+
* none applies: a paid model, a router, a plan's, or a local model with no limit of the agent's. */
|
|
39
|
+
export declare function freeLimitNearest(model: CapModel | undefined, limits: {
|
|
40
|
+
own?: number;
|
|
41
|
+
server?: number;
|
|
42
|
+
}, made: {
|
|
43
|
+
free: number;
|
|
44
|
+
local: number;
|
|
45
|
+
}): {
|
|
46
|
+
limit: number;
|
|
47
|
+
made: number;
|
|
48
|
+
} | undefined;
|
|
31
49
|
/** The note's words, once per run and limit (the dollar cap's wrap-up note carries them, the same mechanism). */
|
|
32
50
|
export declare const freeWrapUpWords: (left: number) => string;
|
|
33
51
|
/** The requests counted toward the free limit that `records` (a session's runner records) hold: each runner.request marked
|
|
34
52
|
* `freeRequest`, answered, in flight or cut. The one count, runBooking's and the wrap-up's. */
|
|
35
53
|
export declare const freeRequestsIn: (records: readonly SessionRecord[]) => number;
|
|
54
|
+
/** The requests on local models that `records` hold (each runner.request marked `localRequest`), counted as
|
|
55
|
+
* freeRequestsIn counts the others: the agent's own limit adds them. */
|
|
56
|
+
export declare const localRequestsIn: (records: readonly SessionRecord[]) => number;
|
|
36
57
|
/** The words a run ends in once it has made `limit` requests on free models: the dollar cap's code, then why. */
|
|
37
58
|
export declare const freeCeilingEnd: (limit: number) => string;
|
|
38
59
|
/** The message of a run's end in freeCeilingEnd's words: what follows its code; undefined for any other summary. */
|
|
@@ -45,3 +66,6 @@ export declare function freeModelRequestsOf(env: Record<string, string | undefin
|
|
|
45
66
|
* (definition.max_requests, its revision's `maxRequests`, a whole number above 0). The server's always holds: an agent's
|
|
46
67
|
* higher one gets the server's. */
|
|
47
68
|
export declare function freeRequestLimitOf(env: Record<string, string | undefined>, maxRequests?: unknown): number;
|
|
69
|
+
/** The agent's own limit (definition.max_requests, a whole number above 0), else undefined: the limit a run's requests on
|
|
70
|
+
* local models stop at, counted with its other free requests (RunCapOptions.maxRequests). */
|
|
71
|
+
export declare const maxRequestsOf: (maxRequests: unknown) => number | undefined;
|
package/dist/kernel/cap/free.js
CHANGED
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
// So such requests are counted across the run, and once it has made the server's limit of them (FREE_MODEL_REQUESTS,
|
|
4
4
|
// else the operator's), its next one is refused for good and the run ends as the dollar cap ends one it can never fit:
|
|
5
5
|
// failed, in the cap's code and these words. A paid request never counts toward it, and is never refused by it; nor is a
|
|
6
|
-
// ChatGPT plan's request (ChatGPT-plan requests don't count).
|
|
6
|
+
// ChatGPT plan's request (ChatGPT-plan requests don't count), nor a local model's (CapModel.local: free, with no shared
|
|
7
|
+
// quota to burn). The agent's own limit (definition.max_requests) counts every free request, a local model's included:
|
|
8
|
+
// local requests are counted apart (localRequestsIn) and added to the others there, so a run on a local model that keeps
|
|
9
|
+
// calling tools stops at it.
|
|
7
10
|
import { RUNNER_RECORDS } from "../../runner.js";
|
|
8
11
|
import { SPEND_CAP_REACHED } from "./words.js";
|
|
9
12
|
import { SERVER_NOTE_LABEL } from "./wrap-up.js";
|
|
@@ -25,13 +28,19 @@ export function freeModel(model) {
|
|
|
25
28
|
return !!price && zero(price) && (price.tiers ?? []).every(zero);
|
|
26
29
|
}
|
|
27
30
|
/** Whether `request` is on a free model (freeModel, as `modelOf` prices it): never one with a fee beside it (a native
|
|
28
|
-
* web search's) or a paid step's charge, which cost dollars, nor one named by a router.
|
|
29
|
-
*
|
|
31
|
+
* web search's) or a paid step's charge, which cost dollars, nor one named by a router. What the runner books at a known
|
|
32
|
+
* $0 (Admitted.free); the run's limit counts those of them that limitedFree says. */
|
|
30
33
|
export function freeRequest(request, modelOf) {
|
|
31
34
|
if (request.paid || (request.feeUsd ?? 0) !== 0 || ROUTERS.has(request.model))
|
|
32
35
|
return false;
|
|
33
36
|
return freeModel(modelOf(request.model, request.route));
|
|
34
37
|
}
|
|
38
|
+
/** Whether a free request on `model` counts toward the server's free-model limit: a free model's (freeModel), but a local
|
|
39
|
+
* one's (CapModel.local) never. The one rule for that limit's count and its wrap-up note. The agent's own limit counts a
|
|
40
|
+
* local one as well (run-cap.ts). */
|
|
41
|
+
export function limitedFree(model) {
|
|
42
|
+
return freeModel(model) && !model?.local;
|
|
43
|
+
}
|
|
35
44
|
/** A ChatGPT plan's model as the cap prices it, on every harness alike (pi's route and a CLI's model proxy): billed to the
|
|
36
45
|
* plan, so no price here (never its $0 listing, never an unknown price) and the plan's mark (CapModel.plan). */
|
|
37
46
|
export function planCapModel(id, api, outputCeiling) {
|
|
@@ -47,11 +56,27 @@ export function freeWrapUpDue(limit, made) {
|
|
|
47
56
|
const left = limit - made;
|
|
48
57
|
return left >= 1 && left <= FREE_WRAP_UP_MARGIN ? { left } : undefined;
|
|
49
58
|
}
|
|
59
|
+
/** The free limit a run's next request on `model` is nearest, and what counts toward it: the agent's own (`own`,
|
|
60
|
+
* max_requests) over its free and local requests together, and on a free model with a quota behind it (limitedFree) the
|
|
61
|
+
* run's free limit (`server`) over its free requests alone; of the two, the one with fewer requests left. Undefined where
|
|
62
|
+
* none applies: a paid model, a router, a plan's, or a local model with no limit of the agent's. */
|
|
63
|
+
export function freeLimitNearest(model, limits, made) {
|
|
64
|
+
const local = freeModel(model) && model?.local === true;
|
|
65
|
+
const counted = limitedFree(model);
|
|
66
|
+
const each = [
|
|
67
|
+
...(limits.own !== undefined && (local || counted) ? [{ limit: limits.own, made: made.free + made.local }] : []),
|
|
68
|
+
...(limits.server !== undefined && counted ? [{ limit: limits.server, made: made.free }] : []),
|
|
69
|
+
];
|
|
70
|
+
return each.reduce((near, one) => (near === undefined || one.limit - one.made < near.limit - near.made ? one : near), undefined);
|
|
71
|
+
}
|
|
50
72
|
/** The note's words, once per run and limit (the dollar cap's wrap-up note carries them, the same mechanism). */
|
|
51
73
|
export const freeWrapUpWords = (left) => `${SERVER_NOTE_LABEL}${left} free-model request${left === 1 ? "" : "s"} left in this run, this one included: finish now with your answer.`;
|
|
52
74
|
/** The requests counted toward the free limit that `records` (a session's runner records) hold: each runner.request marked
|
|
53
75
|
* `freeRequest`, answered, in flight or cut. The one count, runBooking's and the wrap-up's. */
|
|
54
76
|
export const freeRequestsIn = (records) => records.filter((r) => r.kind === RUNNER_RECORDS.request && r.data?.freeRequest === true).length;
|
|
77
|
+
/** The requests on local models that `records` hold (each runner.request marked `localRequest`), counted as
|
|
78
|
+
* freeRequestsIn counts the others: the agent's own limit adds them. */
|
|
79
|
+
export const localRequestsIn = (records) => records.filter((r) => r.kind === RUNNER_RECORDS.request && r.data?.localRequest === true).length;
|
|
55
80
|
/** The words a run ends in once it has made `limit` requests on free models: the dollar cap's code, then why. */
|
|
56
81
|
export const freeCeilingEnd = (limit) => `${SPEND_CAP_REACHED}: Not sent: this run reached its ${limit}-request limit for free models.`;
|
|
57
82
|
const FREE_CEILING = new RegExp(`^${SPEND_CAP_REACHED}: (Not sent: this run reached its \\d+-request limit for free models\\.)$`);
|
|
@@ -74,5 +99,9 @@ export function freeModelRequestsOf(env) {
|
|
|
74
99
|
* higher one gets the server's. */
|
|
75
100
|
export function freeRequestLimitOf(env, maxRequests) {
|
|
76
101
|
const server = freeModelRequestsOf(env);
|
|
77
|
-
|
|
102
|
+
const own = maxRequestsOf(maxRequests);
|
|
103
|
+
return own === undefined ? server : Math.min(own, server);
|
|
78
104
|
}
|
|
105
|
+
/** The agent's own limit (definition.max_requests, a whole number above 0), else undefined: the limit a run's requests on
|
|
106
|
+
* local models stop at, counted with its other free requests (RunCapOptions.maxRequests). */
|
|
107
|
+
export const maxRequestsOf = (maxRequests) => typeof maxRequests === "number" && Number.isSafeInteger(maxRequests) && maxRequests >= 1 ? maxRequests : undefined;
|
|
@@ -4,7 +4,7 @@ export { beforeRequestOf, capRequestOf, type BeforeRequestOptions, type PricedRe
|
|
|
4
4
|
export { DECISION_SESSION, overCapOf, paidCalls, runCap, TOOL_SESSION, type RunCap, type RunCapOptions, type RunDecisions, type RunTools } from "./run-cap.js";
|
|
5
5
|
export { ANSWER_TOKENS_LEAST, CAP_TOLERANCE, FIT_TOLERANCE, STOP_ALLOWANCE_TOKENS, THINKING_BUDGET_LEAST, inputBound, mostOutput, pricingOf, ratesFor, requestPrice, type Pricing } from "./price.js";
|
|
6
6
|
export { aloneRefusal, CAP_REFUSAL_CODE, SPEND_CAP_REACHED, SUGGESTED_RAISE_FACTOR, centsMoney, leastMoney, money, OVER_CAP_END, overCapEnd, overCapMessage, overCapWords, paidRefusal, raiseFigure, raiseTo, spentMoney, suggestedRaise } from "./words.js";
|
|
7
|
-
export { FREE_MODEL_REQUESTS, FREE_MODEL_REQUESTS_ENV, FREE_WRAP_UP_MARGIN, freeCeilingEnd, freeCeilingMessage, freeModel, freeModelRequestsOf, freeRequest, freeRequestLimitOf, freeRequestsIn, freeWrapUpDue, freeWrapUpWords, planCapModel, ROUTERS } from "./free.js";
|
|
7
|
+
export { FREE_MODEL_REQUESTS, FREE_MODEL_REQUESTS_ENV, FREE_WRAP_UP_MARGIN, freeCeilingEnd, freeCeilingMessage, freeLimitNearest, freeModel, freeModelRequestsOf, freeRequest, freeRequestLimitOf, freeRequestsIn, freeWrapUpDue, freeWrapUpWords, limitedFree, localRequestsIn, maxRequestsOf, planCapModel, ROUTERS } from "./free.js";
|
|
8
8
|
export { checkRaise, followUpOf, parkOf, takeRaises, type BudgetPending, type Park, type RaiseCheck, type RaiseState } from "./park.js";
|
|
9
9
|
export { SERVER_NOTE_LABEL, WRAP_UP_FACTOR, WRAP_UP_LEAST_FACTOR, WRAP_UP_STEP0_ANSWER_TOKENS, typicalCost, wrapUpDue, wrapUpWords } from "./wrap-up.js";
|
|
10
10
|
export { CapStop, createStepWaits, type StepWaits } from "./steps.js";
|
package/dist/kernel/cap/index.js
CHANGED
|
@@ -6,7 +6,7 @@ export { beforeRequestOf, capRequestOf } from "./port.js";
|
|
|
6
6
|
export { DECISION_SESSION, overCapOf, paidCalls, runCap, TOOL_SESSION } from "./run-cap.js";
|
|
7
7
|
export { ANSWER_TOKENS_LEAST, CAP_TOLERANCE, FIT_TOLERANCE, STOP_ALLOWANCE_TOKENS, THINKING_BUDGET_LEAST, inputBound, mostOutput, pricingOf, ratesFor, requestPrice } from "./price.js";
|
|
8
8
|
export { aloneRefusal, CAP_REFUSAL_CODE, SPEND_CAP_REACHED, SUGGESTED_RAISE_FACTOR, centsMoney, leastMoney, money, OVER_CAP_END, overCapEnd, overCapMessage, overCapWords, paidRefusal, raiseFigure, raiseTo, spentMoney, suggestedRaise } from "./words.js";
|
|
9
|
-
export { FREE_MODEL_REQUESTS, FREE_MODEL_REQUESTS_ENV, FREE_WRAP_UP_MARGIN, freeCeilingEnd, freeCeilingMessage, freeModel, freeModelRequestsOf, freeRequest, freeRequestLimitOf, freeRequestsIn, freeWrapUpDue, freeWrapUpWords, planCapModel, ROUTERS } from "./free.js";
|
|
9
|
+
export { FREE_MODEL_REQUESTS, FREE_MODEL_REQUESTS_ENV, FREE_WRAP_UP_MARGIN, freeCeilingEnd, freeCeilingMessage, freeLimitNearest, freeModel, freeModelRequestsOf, freeRequest, freeRequestLimitOf, freeRequestsIn, freeWrapUpDue, freeWrapUpWords, limitedFree, localRequestsIn, maxRequestsOf, planCapModel, ROUTERS } from "./free.js";
|
|
10
10
|
export { checkRaise, followUpOf, parkOf, takeRaises } from "./park.js";
|
|
11
11
|
export { SERVER_NOTE_LABEL, WRAP_UP_FACTOR, WRAP_UP_LEAST_FACTOR, WRAP_UP_STEP0_ANSWER_TOKENS, typicalCost, wrapUpDue, wrapUpWords } from "./wrap-up.js";
|
|
12
12
|
export { CapStop, createStepWaits } from "./steps.js";
|
|
@@ -22,8 +22,12 @@ export interface RunCapOptions {
|
|
|
22
22
|
judged?(request: Parameters<BeforeRequest>[0], answer: Awaited<ReturnType<BeforeRequest>>): void;
|
|
23
23
|
/** The most model requests on free models (free.ts freeModel) the run makes, capped or not: the next one past it is
|
|
24
24
|
* refused for good, in freeCeilingEnd's words. Its paid tool calls, its decisions and ChatGPT-plan requests never
|
|
25
|
-
* count. Undefined: no such limit. */
|
|
25
|
+
* count. Undefined: no such limit. A local model's request (CapModel.local) never counts toward it. */
|
|
26
26
|
freeRequests?: number;
|
|
27
|
+
/** The agent's own limit (free.ts maxRequestsOf): every free request counts toward it, a local model's included (its
|
|
28
|
+
* count, localRequestsMade, beside freeRequestsMade). The next request past it is refused for good, in the same words.
|
|
29
|
+
* Undefined: none of its own. */
|
|
30
|
+
maxRequests?: number;
|
|
27
31
|
/** Whether the run has parked (its host's pause): a model request waiting for room (runBooking) leaves the line then,
|
|
28
32
|
* refused in its own words, so nothing more is sent until a raise. */
|
|
29
33
|
parked?(): boolean;
|
|
@@ -8,12 +8,14 @@
|
|
|
8
8
|
import { runBooking } from "../../run-booking.js";
|
|
9
9
|
import { modelPortFor, RUNNER_RECORDS, sessionSpendOf } from "../../runner.js";
|
|
10
10
|
import { aloneRefusal, overCapEnd, SPEND_CAP_REACHED } from "./words.js";
|
|
11
|
-
import { freeCeilingEnd, freeRequest } from "./free.js";
|
|
11
|
+
import { freeCeilingEnd, freeRequest, limitedFree } from "./free.js";
|
|
12
12
|
import { decisionAsk } from "./admit.js";
|
|
13
13
|
import { CapRefused, DecisionPriceUnreadable } from "./errors.js";
|
|
14
14
|
import { beforeRequestOf, capRequestOf } from "./port.js";
|
|
15
15
|
/** The session a run's workflow decisions book under. */
|
|
16
16
|
export const DECISION_SESSION = "decisions";
|
|
17
|
+
/** The prefix of the model key a decision books under (`decision:<id>`). */
|
|
18
|
+
const DECISION_KEY = "decision:";
|
|
17
19
|
/** The session a run's paid tool calls book under. */
|
|
18
20
|
export const TOOL_SESSION = "paid-tools";
|
|
19
21
|
/** How a run ends once its booked spend passed its cap (overCapEnd), read from its model session's `records` (each
|
|
@@ -28,7 +30,11 @@ export function overCapOf(records, othersUsd, capUsd) {
|
|
|
28
30
|
export function runCap(options) {
|
|
29
31
|
/** Each decision under way's model, as the rule prices it (decisionAsk), by the model key its request books under. */
|
|
30
32
|
const deciding = new Map();
|
|
31
|
-
|
|
33
|
+
// A decision's model key is never read by the run's model reader: a decision goes to its own provider, priced by the
|
|
34
|
+
// model it is admitted at (`deciding`) or, with no cap, by none. The run's reader may answer the run's model for any
|
|
35
|
+
// id (a CLI session's one model), which would mark an uncapped decision the plan's or a free model's: $0 to the run
|
|
36
|
+
// whatever its provider charged, or a known $0 for one whose charge was lost.
|
|
37
|
+
const pricing = { modelOf: (id, route) => deciding.get(id) ?? (id.startsWith(DECISION_KEY) ? undefined : options.modelOf(id, route)) };
|
|
32
38
|
const rule = beforeRequestOf({
|
|
33
39
|
capUsd: options.capUsd,
|
|
34
40
|
...pricing,
|
|
@@ -46,11 +52,18 @@ export function runCap(options) {
|
|
|
46
52
|
// freeModel refuses a plan model (its listing's price is no price), so `free` is false for every plan request, and the
|
|
47
53
|
// plan mark is returned before the free one is looked at. One the rule refused stays refused.
|
|
48
54
|
const limit = options.freeRequests;
|
|
55
|
+
const own = options.maxRequests;
|
|
49
56
|
const judge = async (request) => {
|
|
50
57
|
const free = freeRequest(request, pricing.modelOf);
|
|
51
|
-
const
|
|
58
|
+
const ofRun = free && request.key !== DECISION_SESSION && request.key !== TOOL_SESSION;
|
|
59
|
+
// A local model's request (CapModel.local) is free and never under the server's limit (limitedFree), but it is under
|
|
60
|
+
// the agent's own, counted apart (`localRequest`) and added to the run's other free requests there.
|
|
61
|
+
const counted = ofRun && limitedFree(pricing.modelOf(request.model, request.route));
|
|
62
|
+
const local = ofRun && !counted;
|
|
52
63
|
if (counted && limit !== undefined && (request.freeRequestsMade ?? 0) >= limit)
|
|
53
64
|
return { refuse: freeCeilingEnd(limit), forGood: true, code: SPEND_CAP_REACHED };
|
|
65
|
+
if (ofRun && own !== undefined && (request.freeRequestsMade ?? 0) + (request.localRequestsMade ?? 0) >= own)
|
|
66
|
+
return { refuse: freeCeilingEnd(own), forGood: true, code: SPEND_CAP_REACHED };
|
|
54
67
|
const answer = await rule(request);
|
|
55
68
|
if (answer && "refuse" in answer)
|
|
56
69
|
return await roomOf(request, answer);
|
|
@@ -58,7 +71,7 @@ export function runCap(options) {
|
|
|
58
71
|
return { ...answer, plan: true };
|
|
59
72
|
if (!free)
|
|
60
73
|
return answer;
|
|
61
|
-
return { ...(answer ?? {}), ...(counted ? { freeRequest: true } : {}), free: true };
|
|
74
|
+
return { ...(answer ?? {}), ...(counted ? { freeRequest: true } : {}), ...(local ? { localRequest: true } : {}), free: true };
|
|
62
75
|
};
|
|
63
76
|
// A step (a model request, a decision, a paid tool call) refused for room while steps in flight hold some of it: judged
|
|
64
77
|
// again by the same rule as if none of the steps that settle on their own were out (a hold-only step, one the booking
|
|
@@ -100,7 +113,7 @@ export function runCap(options) {
|
|
|
100
113
|
if (capUsd !== undefined && request.model === "unreadable")
|
|
101
114
|
throw new DecisionPriceUnreadable();
|
|
102
115
|
const asked = capUsd === undefined || request.model === "unreadable" ? undefined : decisionAsk(request);
|
|
103
|
-
const key =
|
|
116
|
+
const key = `${DECISION_KEY}${request.id}`;
|
|
104
117
|
if (asked)
|
|
105
118
|
deciding.set(key, { ...asked.model, id: key });
|
|
106
119
|
return steps.book(request.id, { model: key, ...(asked ? { inputTokensMax: asked.inputTokens, ...(asked.output === null ? {} : { outputTokensAsked: asked.output, outputTokensLeast: asked.output }), ...(asked.feeUsd > 0 ? { feeUsd: asked.feeUsd } : {}) } : { inputTokensMax: request.inputTokens }) });
|
|
@@ -29,6 +29,9 @@ export interface CapModel {
|
|
|
29
29
|
readonly outputCeiling: number | null;
|
|
30
30
|
readonly reasoning?: boolean;
|
|
31
31
|
readonly plan?: boolean;
|
|
32
|
+
/** `local`: a model on the host's own machine (serve's Ollama models), $0 with no provider quota behind it: a free model
|
|
33
|
+
* whose requests never count toward the run's free-model limit (free.ts limitedFree). */
|
|
34
|
+
readonly local?: boolean;
|
|
32
35
|
}
|
|
33
36
|
/** A model request about to be sent, from any harness (pi in process, a CLI's through the model proxy). */
|
|
34
37
|
export interface ModelCapRequest {
|
package/dist/run-booking.js
CHANGED
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
// own), read with them at each admission and added to `spentUsd`, so a run and what it pays for elsewhere never pass
|
|
13
13
|
// its cap together. Unknown (null) makes the run's spend unknown.
|
|
14
14
|
// - `freeRequestsMade`: the run's requests on free models so far (each runner.request marked `freeRequest`, and each
|
|
15
|
-
// admitted here not yet recorded), which the cap's ceiling on such requests reads (runCap, free.ts)
|
|
15
|
+
// admitted here not yet recorded), which the cap's ceiling on such requests reads (runCap, free.ts); and
|
|
16
|
+
// `localRequestsMade`, its requests on local models counted the same way (`localRequest`), for the agent's own limit.
|
|
16
17
|
// Admissions run one at a time across the run's sessions. The priced tools' charges and holds are not here: they are the
|
|
17
18
|
// host's spentUsd and heldUsd hooks (beforeRequestOf), read beside these.
|
|
18
19
|
//
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
// - Nothing is admitted once its signal is aborted: a step that comes, or reaches its turn, after its client went or the
|
|
47
48
|
// run stopped is refused with the signal's reason, before any read, so no call starts or is charged after a stop.
|
|
48
49
|
import { sessionSpendOf } from "./runner.js";
|
|
49
|
-
import { freeRequestsIn } from "./kernel/cap/free.js";
|
|
50
|
+
import { freeRequestsIn, localRequestsIn } from "./kernel/cap/free.js";
|
|
50
51
|
/** How soon a waiter reads the run's records again, first and at the slowest (it doubles between them). */
|
|
51
52
|
export const WAIT_POLL_FIRST_MS = 50;
|
|
52
53
|
export const WAIT_POLL_MOST_MS = 1_000;
|
|
@@ -81,12 +82,14 @@ export function runBooking(sessions, before, options = {}) {
|
|
|
81
82
|
// The run's requests on free models so far, each counted once: every one whose runner.request says so, answered, in
|
|
82
83
|
// flight or cut, in any session and any process, and below, each admitted here not yet recorded.
|
|
83
84
|
let freeRequestsMade = 0;
|
|
85
|
+
let localRequestsMade = 0;
|
|
84
86
|
const recorded = new Set();
|
|
85
87
|
const answered = new Set();
|
|
86
88
|
for (const key of await sessions.keys()) {
|
|
87
89
|
const records = await sessions.read(key);
|
|
88
90
|
const spend = sessionSpendOf(records);
|
|
89
91
|
freeRequestsMade += freeRequestsIn(records);
|
|
92
|
+
localRequestsMade += localRequestsIn(records);
|
|
90
93
|
for (const turn of spend.turns)
|
|
91
94
|
recorded.add(idOf(key, turn));
|
|
92
95
|
for (const turn of spend.answered)
|
|
@@ -115,6 +118,8 @@ export function runBooking(sessions, before, options = {}) {
|
|
|
115
118
|
for (const [id, { at, key, ...flight }] of admitted) {
|
|
116
119
|
if (flight.freeRequest && !recorded.has(id))
|
|
117
120
|
freeRequestsMade += 1;
|
|
121
|
+
if (flight.localRequest && !recorded.has(id))
|
|
122
|
+
localRequestsMade += 1;
|
|
118
123
|
// One that may never settle by itself (a hold-only step, an admission whose record never landed) stays: held, and
|
|
119
124
|
// never waited on. So does, for a paid call, a request of the session it runs in: it may be the one that asked
|
|
120
125
|
// for the call, which settles only once the call is done.
|
|
@@ -123,10 +128,11 @@ export function runBooking(sessions, before, options = {}) {
|
|
|
123
128
|
settling.add(id);
|
|
124
129
|
inFlight.push(stays ? { ...flight, stays: true } : flight);
|
|
125
130
|
}
|
|
126
|
-
const verdict = await before({ ...request, spentUsd, inFlight, freeRequestsMade });
|
|
131
|
+
const verdict = await before({ ...request, spentUsd, inFlight, freeRequestsMade, localRequestsMade });
|
|
127
132
|
if (!(verdict && "refuse" in verdict)) {
|
|
128
133
|
const holdUsd = verdict && "holdUsd" in verdict ? verdict.holdUsd : undefined;
|
|
129
134
|
const freeRequest = !!verdict && "freeRequest" in verdict && verdict.freeRequest === true;
|
|
135
|
+
const localRequest = !!verdict && "localRequest" in verdict && verdict.localRequest === true;
|
|
130
136
|
const outputTokensMax = verdict && "outputTokensMax" in verdict ? verdict.outputTokensMax : request.outputTokensAsked;
|
|
131
137
|
admitted.set(idOf(request.key, request.turn), {
|
|
132
138
|
at: Date.now(),
|
|
@@ -139,6 +145,7 @@ export function runBooking(sessions, before, options = {}) {
|
|
|
139
145
|
...(request.host === undefined ? {} : { host: request.host }),
|
|
140
146
|
...(request.route === undefined ? {} : { route: request.route }),
|
|
141
147
|
...(freeRequest ? { freeRequest: true } : {}),
|
|
148
|
+
...(localRequest ? { localRequest: true } : {}),
|
|
142
149
|
// A hold-only step, or money already owed (a browser session's reserve or release, settled when its session
|
|
143
150
|
// ends, not when a call answers): never waited on.
|
|
144
151
|
...(request.paid?.hold || request.paid?.owed ? { stays: true } : {}),
|
package/dist/runner.d.ts
CHANGED
|
@@ -86,6 +86,9 @@ export type BeforeRequest = (request: {
|
|
|
86
86
|
/** The run's requests on free models so far (runBooking, over every session of the run): each whose runner.request says
|
|
87
87
|
* so (`freeRequest`), answered, in flight or cut, and each admitted that no record shows yet. Absent: not counted here. */
|
|
88
88
|
freeRequestsMade?: number;
|
|
89
|
+
/** The run's requests on local models so far, counted the same way (`localRequest`): free, never under the server's
|
|
90
|
+
* limit, but under the agent's own (RunCapOptions.maxRequests) beside freeRequestsMade. Absent: not counted here. */
|
|
91
|
+
localRequestsMade?: number;
|
|
89
92
|
/** The request's client's signal (ModelRequest.signal): a host that makes it wait for room lets it go when it aborts. */
|
|
90
93
|
signal?: AbortSignal;
|
|
91
94
|
/** The booking's own stop or pause, now (its `stopped`, `draining`, or a cost it could not record): a request waiting
|
|
@@ -129,6 +132,7 @@ export type InFlight = {
|
|
|
129
132
|
host?: string;
|
|
130
133
|
route?: string;
|
|
131
134
|
freeRequest?: true;
|
|
135
|
+
localRequest?: true;
|
|
132
136
|
stays?: true;
|
|
133
137
|
};
|
|
134
138
|
/** A host's admission: what it holds for the request (`holdUsd`), and the most output tokens, thinking included, it may
|
|
@@ -139,7 +143,8 @@ export type InFlight = {
|
|
|
139
143
|
* `note`: the host's record of the note this request carries, written on the request's `runner.turn` record once it
|
|
140
144
|
* ends, beside how it was booked, so a later process reads whether the note reached an answer. `freeRequest`: one of
|
|
141
145
|
* the run's requests on a free model, which its ceiling on such requests counts: written on its runner.request (as
|
|
142
|
-
* `freeRequest`), so the count holds it in every process, and a cut one books at $0 (bookCut). `
|
|
146
|
+
* `freeRequest`), so the count holds it in every process, and a cut one books at $0 (bookCut). `localRequest`: one on a
|
|
147
|
+
* local model (CapModel.local), counted apart (`localRequest` on its runner.request) for the agent's own limit. `capCut`: its output
|
|
143
148
|
* limited below what it asked by what is left of the cap, the figures an answer cut at that limit says (ModelTicket). */
|
|
144
149
|
export type Admission = {
|
|
145
150
|
holdUsd?: number;
|
|
@@ -150,6 +155,7 @@ export type Admission = {
|
|
|
150
155
|
[key: string]: JsonValue;
|
|
151
156
|
};
|
|
152
157
|
freeRequest?: true;
|
|
158
|
+
localRequest?: true;
|
|
153
159
|
capCut?: CapCut;
|
|
154
160
|
};
|
|
155
161
|
/** An admission as a host gives it: with `free` when the request is on a free model (its known price is $0 for every
|
|
@@ -314,6 +320,10 @@ export declare function rebooked<K>(seen: Set<K>, key: K | undefined): boolean;
|
|
|
314
320
|
/** The rule (runner.turn `rule`) of a request cut with no answer that bookCut booked at what its host held for it: the
|
|
315
321
|
* most it can have cost (its whole input uncached and the output it was sent with), marked `atMost`. */
|
|
316
322
|
export declare const CUT_AT_HOLD = "cut";
|
|
323
|
+
/** Whether a runner.request (its `data`) is billed to a person's plan (Admitted.plan, its record's `plan`): $0 to the run
|
|
324
|
+
* however it ends, open or booked. The one check every reader of a booking makes (sessionSpendOf, bookCut, serve's
|
|
325
|
+
* bookedSpend). */
|
|
326
|
+
export declare const billedToPlan: (data: unknown) => boolean;
|
|
317
327
|
/** A booked request's own cost, from its runner.turn, as every reader of a run's cost reads it (the session's cost, the
|
|
318
328
|
* run's stored cost and its views): what it was booked at, else its `usd`; null when no one knows it (an answer with no
|
|
319
329
|
* price of its own booked at its hold for the cap, answeredUnpriced; a request cut with no hold). `atMost`: a request cut
|
package/dist/runner.js
CHANGED
|
@@ -73,10 +73,14 @@ export function sessionSpendOf(records) {
|
|
|
73
73
|
const hosts = new Map();
|
|
74
74
|
requests.forEach((data, i) => { if (typeof data.host === "string")
|
|
75
75
|
hosts.set(turns[i], data.host); });
|
|
76
|
+
// One billed to a person's plan (Admitted.plan) costs the run $0 however it ends: its figure for the cap, held or not,
|
|
77
|
+
// and its cost while it is open, known and never unpriced (turnCostOf's rule once it is booked).
|
|
78
|
+
const onPlan = new Set();
|
|
79
|
+
requests.forEach((data, i) => { if (billedToPlan(data))
|
|
80
|
+
onPlan.add(turns[i]); });
|
|
76
81
|
const held = new Map();
|
|
77
82
|
requests.forEach((data, i) => {
|
|
78
|
-
|
|
79
|
-
const figure = data.plan === true ? 0 : heldFigure(data.heldUsd);
|
|
83
|
+
const figure = onPlan.has(turns[i]) ? 0 : heldFigure(data.heldUsd);
|
|
80
84
|
if (figure !== undefined)
|
|
81
85
|
held.set(turns[i], figure);
|
|
82
86
|
});
|
|
@@ -134,7 +138,8 @@ export function sessionSpendOf(records) {
|
|
|
134
138
|
}
|
|
135
139
|
spentUsd = spent(spentUsd, worst(turn));
|
|
136
140
|
figures.push({ turn, usd: worst(turn) ?? null });
|
|
137
|
-
|
|
141
|
+
if (!onPlan.has(turn))
|
|
142
|
+
unpriced++;
|
|
138
143
|
}
|
|
139
144
|
return { turns, held, hosts, answered, openHolds, spentUsd, figures, cost: costOfParts([{ known, bounded, atMost, unpriced }]) };
|
|
140
145
|
}
|
|
@@ -169,6 +174,10 @@ export function rebooked(seen, key) {
|
|
|
169
174
|
/** The rule (runner.turn `rule`) of a request cut with no answer that bookCut booked at what its host held for it: the
|
|
170
175
|
* most it can have cost (its whole input uncached and the output it was sent with), marked `atMost`. */
|
|
171
176
|
export const CUT_AT_HOLD = "cut";
|
|
177
|
+
/** Whether a runner.request (its `data`) is billed to a person's plan (Admitted.plan, its record's `plan`): $0 to the run
|
|
178
|
+
* however it ends, open or booked. The one check every reader of a booking makes (sessionSpendOf, bookCut, serve's
|
|
179
|
+
* bookedSpend). */
|
|
180
|
+
export const billedToPlan = (data) => data?.plan === true;
|
|
172
181
|
/** A booked request's own cost, from its runner.turn, as every reader of a run's cost reads it (the session's cost, the
|
|
173
182
|
* run's stored cost and its views): what it was booked at, else its `usd`; null when no one knows it (an answer with no
|
|
174
183
|
* price of its own booked at its hold for the cap, answeredUnpriced; a request cut with no hold). `atMost`: a request cut
|
|
@@ -334,9 +343,10 @@ function bookingFor(writer, options) {
|
|
|
334
343
|
// record, so a later process that books it cut books it so, and the next count holds it. Never both (runCap).
|
|
335
344
|
const onPlan = !!verdict && "plan" in verdict && verdict.plan === true;
|
|
336
345
|
const freeRequest = !!verdict && "freeRequest" in verdict && verdict.freeRequest === true;
|
|
346
|
+
const localRequest = !!verdict && "localRequest" in verdict && verdict.localRequest === true;
|
|
337
347
|
// A paid tool call (ModelRequest.paid) says so on its record (`paid`), so a later process that books it cut knows its
|
|
338
348
|
// hold is its fee as admitted, never a bound on what its provider charged (bookCut).
|
|
339
|
-
await write([{ kind: RUNNER_RECORDS.request, data: { turn, model, ...(paid ? { paid: true } : {}), ...(hold === undefined ? {} : { heldUsd: hold }), ...(onPlan ? { plan: true } : {}), ...(freeRequest ? { freeRequest: true } : {}), ...(side ? { side } : {}), ...(host === undefined ? {} : { host }), ...(paid?.call === undefined ? {} : { call: paid.call }), ...(paid?.charged_by === undefined ? {} : { charged_by: paid.charged_by }), ...(paid?.tool === undefined ? {} : { tool: paid.tool }), ...(paid?.tag === undefined ? {} : { tag: paid.tag }), ...(paid?.owed ? { owed: true } : {}), ...(paid?.hold ? { hold: true } : {}), ...(paid?.ref === undefined ? {} : { ref: paid.ref }), ...(paid?.reported ? { reported: true } : {}) } }]);
|
|
349
|
+
await write([{ kind: RUNNER_RECORDS.request, data: { turn, model, ...(paid ? { paid: true } : {}), ...(hold === undefined ? {} : { heldUsd: hold }), ...(onPlan ? { plan: true } : {}), ...(freeRequest ? { freeRequest: true } : {}), ...(localRequest ? { localRequest: true } : {}), ...(side ? { side } : {}), ...(host === undefined ? {} : { host }), ...(paid?.call === undefined ? {} : { call: paid.call }), ...(paid?.charged_by === undefined ? {} : { charged_by: paid.charged_by }), ...(paid?.tool === undefined ? {} : { tool: paid.tool }), ...(paid?.tag === undefined ? {} : { tag: paid.tag }), ...(paid?.owed ? { owed: true } : {}), ...(paid?.hold ? { hold: true } : {}), ...(paid?.ref === undefined ? {} : { ref: paid.ref }), ...(paid?.reported ? { reported: true } : {}) } }]);
|
|
340
350
|
turns = turn;
|
|
341
351
|
if (host !== undefined)
|
|
342
352
|
hosts.set(turn, host);
|
|
@@ -556,12 +566,12 @@ function bookingFor(writer, options) {
|
|
|
556
566
|
return data.owed === true && data.hold !== true ? [inherited[i]] : [];
|
|
557
567
|
}));
|
|
558
568
|
const owed = left.filter((t) => !read.openHolds.has(t) && owedTurns.has(t) && (held.get(t) ?? 0) > 0);
|
|
559
|
-
// A request on a free model (its runner.request says `freeRequest`, as the run's cap
|
|
560
|
-
// left open costs nothing whatever reached the provider: booked cut at a known $0 and
|
|
561
|
-
// books its own (bookRequest's free), never unknown. Any other keeps the rule below.
|
|
569
|
+
// A request on a free model (its runner.request says `freeRequest`, or `localRequest` for a local one, as the run's cap
|
|
570
|
+
// admitted it) an earlier process left open costs nothing whatever reached the provider: booked cut at a known $0 and
|
|
571
|
+
// marked `free`, as this process books its own (bookRequest's free), never unknown. Any other keeps the rule below.
|
|
562
572
|
const freeTurns = new Set(options.records.filter((r) => r.kind === RUNNER_RECORDS.request).flatMap((r, i) => {
|
|
563
573
|
const data = (r.data ?? {});
|
|
564
|
-
return data.freeRequest === true ? [typeof data.turn === "number" ? data.turn : i + 1] : [];
|
|
574
|
+
return data.freeRequest === true || data.localRequest === true ? [typeof data.turn === "number" ? data.turn : i + 1] : [];
|
|
565
575
|
}));
|
|
566
576
|
const free = left.filter((t) => !read.openHolds.has(t) && !owed.includes(t) && freeTurns.has(t));
|
|
567
577
|
const numbers = left.filter((t) => !read.openHolds.has(t) && !owed.includes(t) && !free.includes(t));
|
|
@@ -592,7 +602,7 @@ function bookingFor(writer, options) {
|
|
|
592
602
|
// a plan request `plan` before it looks at free, and freeModel refuses a plan model, so no plan request is admitted
|
|
593
603
|
// `freeRequest`.
|
|
594
604
|
const modelTurns = new Set(options.records.filter((r) => r.kind === RUNNER_RECORDS.request).flatMap((r, i) => (r.data?.paid === true ? [] : [inherited[i]])));
|
|
595
|
-
const onPlan = new Set(options.records.filter((r) => r.kind === RUNNER_RECORDS.request).flatMap((r, i) => (r.data
|
|
605
|
+
const onPlan = new Set(options.records.filter((r) => r.kind === RUNNER_RECORDS.request).flatMap((r, i) => (billedToPlan(r.data) ? [inherited[i]] : [])));
|
|
596
606
|
const boundOf = (turn) => {
|
|
597
607
|
const hold = held.get(turn);
|
|
598
608
|
return hold !== undefined && hold > 0 && modelTurns.has(turn) ? hold : undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/agentrun-kernel",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.56",
|
|
4
4
|
"description": "Agent harnesses other than Pi, starting with Codex, behind one seam: a DSL node's runNode and an AgentRun run on a harness adapter, durable in AgentRun's own store.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentrun",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"test": "node --test --test-concurrency=8 'test/*.test.mjs'"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@parcha/agentrun-dsl": "0.1.0-beta.
|
|
65
|
+
"@parcha/agentrun-dsl": "0.1.0-beta.56",
|
|
66
66
|
"ajv": "8.18.0",
|
|
67
67
|
"typebox": "1.3.27"
|
|
68
68
|
},
|