@parcha/agentrun-kernel 0.1.0-beta.36 → 0.1.0-beta.38
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 +91 -0
- package/dist/host/index.d.ts +2 -4
- package/dist/host/index.js +2 -3
- package/dist/host/overhead.d.ts +42 -0
- package/dist/host/overhead.js +84 -10
- package/dist/host/proxy.d.ts +34 -15
- package/dist/host/proxy.js +99 -25
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/kernel/cap/index.d.ts +4 -4
- package/dist/kernel/cap/index.js +3 -3
- package/dist/kernel/cap/port.d.ts +14 -3
- package/dist/kernel/cap/port.js +29 -16
- package/dist/kernel/cap/price.d.ts +31 -6
- package/dist/kernel/cap/price.js +49 -15
- package/dist/kernel/cap/rule.d.ts +11 -1
- package/dist/kernel/cap/rule.js +30 -3
- package/dist/kernel/cap/run-cap.d.ts +9 -2
- package/dist/kernel/cap/run-cap.js +8 -3
- package/dist/kernel/cap/types.d.ts +11 -5
- package/dist/kernel/registry/computer-surface.generated.d.ts +9 -0
- package/dist/kernel/registry/computer-surface.generated.js +618 -0
- package/dist/kernel/registry/computer.d.ts +14 -0
- package/dist/kernel/registry/computer.js +75 -0
- package/dist/kernel/registry/defs.d.ts +1 -4
- package/dist/kernel/registry/defs.js +1 -13
- package/dist/kernel/registry/handoff.js +4 -4
- package/dist/kernel/registry/hands.d.ts +22 -115
- package/dist/kernel/registry/hands.js +0 -2
- package/dist/kernel/registry/index.d.ts +4 -4
- package/dist/kernel/registry/index.js +5 -5
- package/dist/kernel/registry/registry.d.ts +4 -5
- package/dist/kernel/registry/registry.js +27 -29
- package/dist/kernel/types.d.ts +10 -2
- package/dist/process/tools.d.ts +5 -1
- package/dist/process/tools.js +62 -8
- package/dist/run-booking.d.ts +3 -0
- package/dist/run-booking.js +7 -0
- package/dist/runner.d.ts +21 -2
- package/dist/runner.js +126 -11
- package/dist/testing.d.ts +6 -2
- package/dist/testing.js +5 -3
- package/dist/tool-deferral.d.ts +12 -0
- package/dist/tool-deferral.js +17 -0
- package/dist/types.d.ts +83 -39
- package/package.json +2 -2
- package/dist/host/mcp-route.d.ts +0 -14
- package/dist/host/mcp-route.js +0 -125
- package/dist/kernel/registry/desktop.d.ts +0 -11
- package/dist/kernel/registry/desktop.js +0 -90
- package/dist/kernel/registry/phone.d.ts +0 -15
- package/dist/kernel/registry/phone.js +0 -135
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type RunSessions } from "../../run-booking.js";
|
|
2
2
|
import { type BeforeRequest } from "../../runner.js";
|
|
3
3
|
import type { SessionRecord, SessionWriter } from "../../types.js";
|
|
4
|
-
import
|
|
4
|
+
import { type PricedRequest } from "./port.js";
|
|
5
|
+
import type { Admission, CapMode, CapModel, DecisionCapRequest, ModelCapRequest, RecentRequest, Settled } from "./types.js";
|
|
5
6
|
/** The session a run's workflow decisions book under. */
|
|
6
7
|
export declare const DECISION_SESSION = "decisions";
|
|
7
8
|
export interface RunCapOptions {
|
|
@@ -13,10 +14,13 @@ export interface RunCapOptions {
|
|
|
13
14
|
readonly now?: () => number;
|
|
14
15
|
/** The run's model requests' models, by id and route (BeforeRequestOptions.modelOf; its decisions' are the cap's own). */
|
|
15
16
|
modelOf(id: string, route?: string): CapModel | undefined;
|
|
16
|
-
|
|
17
|
+
/** The session's recent requests, by the id their model is priced under (BeforeRequestOptions.recentOf). */
|
|
18
|
+
recentOf?(model: string): readonly RecentRequest[];
|
|
17
19
|
/** The run's priced tools' charges and holds beside its requests (beforeRequestOf's), when it has any. */
|
|
18
20
|
spentUsd?(): number | null;
|
|
19
21
|
heldUsd?(): number | null;
|
|
22
|
+
/** What the host keeps back beside a model request while it streams (BeforeRequestOptions.keepBackUsd). */
|
|
23
|
+
keepBackUsd?(request: Parameters<BeforeRequest>[0], asked: ModelCapRequest): number | undefined;
|
|
20
24
|
/** Told each request the rule judged, with the run's totals it was asked with, and its answer (an observer: a live
|
|
21
25
|
* view of the cap, a test's record). */
|
|
22
26
|
judged?(request: Parameters<BeforeRequest>[0], answer: Awaited<ReturnType<BeforeRequest>>): void;
|
|
@@ -35,6 +39,9 @@ export interface RunDecisions {
|
|
|
35
39
|
export interface RunCap {
|
|
36
40
|
/** The run's one rule for every model request (a model booking's beforeRequest), its decisions' models known to it. */
|
|
37
41
|
readonly before: BeforeRequest;
|
|
42
|
+
/** A model request as `before` prices it (port.ts capRequestOf, with the same models and the session's recent
|
|
43
|
+
* requests): what the wrap-up's note and the reserve (requestFigures) price, so they read a warm cache as admission does. */
|
|
44
|
+
asked(request: PricedRequest): ModelCapRequest;
|
|
38
45
|
/** The run's decisions, booked on `writer` (the run's DECISION_SESSION) under the same rule. `flush`: makes what the
|
|
39
46
|
* journal holds survive a lost box, awaited once a decision's hold is written and before it is sent, as a model
|
|
40
47
|
* request's is (request_start), so a decision sent and then lost with its box still counts after the next claim. */
|
|
@@ -10,7 +10,7 @@ import { modelPortFor, RUNNER_RECORDS, sessionSpendOf } from "../../runner.js";
|
|
|
10
10
|
import { overCapEnd } from "./words.js";
|
|
11
11
|
import { decisionAsk } from "./admit.js";
|
|
12
12
|
import { CapRefused, DecisionPriceUnreadable } from "./errors.js";
|
|
13
|
-
import { beforeRequestOf } from "./port.js";
|
|
13
|
+
import { beforeRequestOf, capRequestOf } from "./port.js";
|
|
14
14
|
/** The session a run's workflow decisions book under. */
|
|
15
15
|
export const DECISION_SESSION = "decisions";
|
|
16
16
|
/** The session a run's paid tool calls book under. */
|
|
@@ -36,14 +36,18 @@ export function runCap(options) {
|
|
|
36
36
|
const mode = options.mode ?? "expected";
|
|
37
37
|
/** Each decision under way's model, as the rule prices it (decisionAsk), by the model key its request books under. */
|
|
38
38
|
const deciding = new Map();
|
|
39
|
+
const pricing = {
|
|
40
|
+
modelOf: (id, route) => deciding.get(id) ?? options.modelOf(id, route),
|
|
41
|
+
...(options.recentOf ? { recentOf: (model) => (deciding.has(model) ? [] : options.recentOf(model)) } : {}),
|
|
42
|
+
};
|
|
39
43
|
const rule = beforeRequestOf({
|
|
40
44
|
capUsd: options.capUsd,
|
|
41
45
|
mode,
|
|
42
46
|
...(options.now ? { now: options.now } : {}),
|
|
43
|
-
|
|
44
|
-
...(options.previousOf ? { previousOf: (model) => (deciding.has(model) ? undefined : options.previousOf(model)) } : {}),
|
|
47
|
+
...pricing,
|
|
45
48
|
...(options.spentUsd ? { spentUsd: options.spentUsd } : {}),
|
|
46
49
|
...(options.heldUsd ? { heldUsd: options.heldUsd } : {}),
|
|
50
|
+
...(options.keepBackUsd ? { keepBackUsd: options.keepBackUsd } : {}),
|
|
47
51
|
});
|
|
48
52
|
const before = runBooking(options.sessions, options.judged ? async (request) => {
|
|
49
53
|
const answer = await rule(request);
|
|
@@ -53,6 +57,7 @@ export function runCap(options) {
|
|
|
53
57
|
const forget = (key) => void deciding.delete(key);
|
|
54
58
|
return {
|
|
55
59
|
before,
|
|
60
|
+
asked: (request) => capRequestOf("asked", request, pricing),
|
|
56
61
|
async decisions(writer, decisionOptions = {}) {
|
|
57
62
|
const steps = await stepsOn(writer, before, decisionOptions.flush, "decision", forget);
|
|
58
63
|
return {
|
|
@@ -27,13 +27,17 @@ export interface CapModel {
|
|
|
27
27
|
readonly outputCeiling: number | null;
|
|
28
28
|
readonly reasoning?: boolean;
|
|
29
29
|
}
|
|
30
|
-
/**
|
|
31
|
-
* the cache, the rest, its input bound (the unit
|
|
32
|
-
|
|
30
|
+
/** One of the session's recent requests (price.ts recentAfter), as its usage reported it: what of its input was read from
|
|
31
|
+
* or written to the cache, the rest, its input bound (the unit a later request's is in) and when it ended (ms), on which
|
|
32
|
+
* model. A later request reads its cache from one of them (price.ts warmFrom). */
|
|
33
|
+
export interface RecentRequest {
|
|
34
|
+
/** Its model as the cap prices it (CapModel.id), whatever id its client named it by. */
|
|
33
35
|
readonly model: string;
|
|
34
36
|
readonly cachedTokens: number;
|
|
35
37
|
readonly inputTokens: number;
|
|
36
38
|
readonly boundTokens: number;
|
|
39
|
+
/** Its bound was its provider's count, not its bytes: used only for a next request bounded the same way. */
|
|
40
|
+
readonly counted?: boolean;
|
|
37
41
|
readonly endedAt: number;
|
|
38
42
|
}
|
|
39
43
|
/** A model request about to be sent, from any harness (pi in process, a CLI's through the model proxy). */
|
|
@@ -57,7 +61,9 @@ export interface ModelCapRequest {
|
|
|
57
61
|
readonly outputTokensLeast?: number;
|
|
58
62
|
/** Its thinking budget, on an API whose thinking takes one beside the answer's output. */
|
|
59
63
|
readonly thinkingBudget?: number;
|
|
60
|
-
|
|
64
|
+
/** The session's recent requests on its model, their bounds measured as this one's is: its input is expected to read
|
|
65
|
+
* the cache of the one warmFrom picks, else none (priced uncached). */
|
|
66
|
+
readonly recent?: readonly RecentRequest[];
|
|
61
67
|
/** A side call (a title, a summary), never its turn's own. */
|
|
62
68
|
readonly side?: boolean;
|
|
63
69
|
/** It carries the cap's wrap-up note (Cap.note) in its body, its bytes in `inputTokens`: told once it is answered. */
|
|
@@ -136,7 +142,7 @@ export interface CapOptions {
|
|
|
136
142
|
/** How long settle waits for a step's end mark before it fails loudly. Default 10 s. */
|
|
137
143
|
endMarkWaitMs?: number;
|
|
138
144
|
}
|
|
139
|
-
/** How the cap prices a request's input: "expected" from
|
|
145
|
+
/** How the cap prices a request's input: "expected" from a recent request's cache; "strict" every token uncached. */
|
|
140
146
|
export type CapMode = "expected" | "strict";
|
|
141
147
|
export interface Cap {
|
|
142
148
|
admit(request: CapRequest): Promise<Admission>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Each per-step tool's parameters, as JSON Schema. */
|
|
2
|
+
export declare const COMPUTER_TOOL_SCHEMAS: {
|
|
3
|
+
readonly [tool in "computer_observe" | "computer_act" | "computer_screenshot" | "computer_script"]: object;
|
|
4
|
+
};
|
|
5
|
+
/** computer_act's steps as TypeScript, for its description: its schema types them, with no words. */
|
|
6
|
+
export declare const ACT_STEPS = "type UiStep = { press: UiRef; } | { set: UiRef; value: string; } | { perform: UiRef; action: string; } | { click: UiRef | Point; button?: \"left\" | \"right\"; count?: 1 | 2 | 3; } | { type: string; into?: UiRef; } | { key: string; } | { nav: \"back\" | \"home\" | \"app_switch\"; } | { scroll: UiRef | Point; dx?: number; dy?: number; } | { drag: Point[]; ms?: number; }; type UiRef = string; type Point = [ x: number, y: number ];";
|
|
7
|
+
/** The declarations a script on a computer with these groups reads: the types its members reach, Computer with only
|
|
8
|
+
* the members its groups offer, and `declare const computer`, one line each. */
|
|
9
|
+
export declare function computerDeclarations(groups: readonly string[]): string;
|