@llm4ts/runner 2.5.0 → 2.7.0
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/Cli.d.ts.map +1 -1
- package/dist/Cli.js +0 -2
- package/dist/Cli.js.map +1 -1
- package/dist/Connectors.d.ts +7 -0
- package/dist/Connectors.d.ts.map +1 -1
- package/dist/Connectors.js +25 -1
- package/dist/Connectors.js.map +1 -1
- package/dist/Costs.d.ts +48 -0
- package/dist/Costs.d.ts.map +1 -0
- package/dist/Costs.js +76 -0
- package/dist/Costs.js.map +1 -0
- package/dist/FlowRunner.d.ts +43 -0
- package/dist/FlowRunner.d.ts.map +1 -1
- package/dist/FlowRunner.js +111 -13
- package/dist/FlowRunner.js.map +1 -1
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js +5 -0
- package/dist/Terminal.js.map +1 -1
- package/package.json +4 -3
- package/src/Cli.ts +0 -2
- package/src/Connectors.ts +31 -1
- package/src/Costs.ts +116 -0
- package/src/FlowRunner.ts +205 -16
- package/src/Terminal.ts +5 -0
package/dist/Cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cli.d.ts","sourceRoot":"","sources":["../src/Cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Cli.d.ts","sourceRoot":"","sources":["../src/Cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAKrE,OAAO,EAAkD,KAAK,WAAW,EAAE,MAAM,eAAe,CAAA;AAIhG,eAAO,MAAM,cAAc,GACzB,MAAM,aAAa,CAAC,MAAM,CAAC,EAC3B,cAAa,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAe,EACvE,kBAAyB,EACzB,gBAAgB,MAAM,KACrB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,CAiC7C,CAAA"}
|
package/dist/Cli.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
1
|
import * as Effect from "effect/Effect";
|
|
3
2
|
import { FlowLlmError } from "@llm4ts/flow/FlowError";
|
|
4
3
|
import { AssistantMessage } from "@llm4ts/flow/FlowEvents";
|
|
@@ -28,7 +27,6 @@ export const makeCliProgram = (argv, environment = process.env, workspace = proc
|
|
|
28
27
|
userPrompt: prompt,
|
|
29
28
|
coder,
|
|
30
29
|
verbosity: parseVerbosity(environment.LLM4TS_VERBOSITY),
|
|
31
|
-
tracePath: join(workDir, ".llm4ts", `trace-${timestamp}.jsonl`),
|
|
32
30
|
runId: timestamp.toString()
|
|
33
31
|
}, (context) => collect(context.coder.executeStream(prompt)).pipe(Effect.mapError(FlowLlmError.from), Effect.tap((response) => context.events.publish(AssistantMessage.make({ text: response.content }))), Effect.asVoid));
|
|
34
32
|
});
|
package/dist/Cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cli.js","sourceRoot":"","sources":["../src/Cli.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Cli.js","sourceRoot":"","sources":["../src/Cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,YAAY,EAAkB,MAAM,wBAAwB,CAAA;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAoB,MAAM,eAAe,CAAA;AAChG,OAAO,EAAE,OAA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,YAAY,CAAC,IAAI,CAAC,EAClC,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CACtB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAC1E,EACD,MAAM,CAAC,MAAM,CACd,CACJ,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
package/dist/Connectors.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare const grok: CliConnectorConfig;
|
|
|
10
10
|
export declare const cursor: CliConnectorConfig;
|
|
11
11
|
export declare const opencode: CliConnectorConfig;
|
|
12
12
|
export declare const lmStudio: ApiConnectorConfig;
|
|
13
|
+
export declare const mlxLm: ApiConnectorConfig;
|
|
13
14
|
export declare const openAI: ApiConnectorConfig;
|
|
14
15
|
export declare const anthropic: ApiConnectorConfig;
|
|
15
16
|
export declare const geminiApi: ApiConnectorConfig;
|
|
@@ -29,4 +30,10 @@ export declare const coderIds: ReadonlyArray<string>;
|
|
|
29
30
|
export declare const coderFor: (name: string) => CliConnectorConfig | undefined;
|
|
30
31
|
export declare const coderFromEnv: (env?: Readonly<Record<string, string | undefined>>) => CliConnectorConfig;
|
|
31
32
|
export declare const coderFromEnvironment: (environment?: Readonly<Record<string, string | undefined>> | undefined) => Effect.Effect<CliConnectorConfig, ScriptUsage, never>;
|
|
33
|
+
/**
|
|
34
|
+
* The judgment seat from the environment (ADR 0017): `LLM4TS_JUDGMENT_PROVIDER`
|
|
35
|
+
* names an API provider the way `LLM4TS_PROVIDER` does, `LLM4TS_JUDGMENT_MODEL`
|
|
36
|
+
* its model. Unset, the runner falls back to the reasoning seat.
|
|
37
|
+
*/
|
|
38
|
+
export declare const judgmentConnectorFromEnvironment: (environment?: Readonly<Record<string, string | undefined>> | undefined) => Effect.Effect<ApiConnectorConfig | undefined, ScriptUsage, never>;
|
|
32
39
|
//# sourceMapping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AA;AAEvF,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,KAAG,kBAAkB,GAAG,SACtB,CAAA;AAKvC,eAAO,MAAM,YAAY,GACvB,MAAK,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAe,KAC9D,kBAGF,CAAA;AAKD,eAAO,MAAM,oBAAoB,mIAehC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,gCAAgC,+IAc3C,CAAA"}
|
package/dist/Connectors.js
CHANGED
|
@@ -41,6 +41,10 @@ export const lmStudio = ApiConnectorConfig.make({
|
|
|
41
41
|
connectorId: ConnectorIds.LmStudio,
|
|
42
42
|
baseUrl: "http://localhost:1234/v1"
|
|
43
43
|
});
|
|
44
|
+
export const mlxLm = ApiConnectorConfig.make({
|
|
45
|
+
connectorId: ConnectorIds.MlxLm,
|
|
46
|
+
baseUrl: "http://localhost:8080"
|
|
47
|
+
});
|
|
44
48
|
export const openAI = ApiConnectorConfig.make({
|
|
45
49
|
connectorId: ConnectorIds.OpenAI
|
|
46
50
|
});
|
|
@@ -129,6 +133,10 @@ export const apiConnectorFromEnvironment = Effect.fn("@llm4ts/runner/Connectors.
|
|
|
129
133
|
return lmStudio;
|
|
130
134
|
case "ollama":
|
|
131
135
|
return ollama;
|
|
136
|
+
case "mlx-lm":
|
|
137
|
+
case "mlxlm":
|
|
138
|
+
case "mlx":
|
|
139
|
+
return mlxLm;
|
|
132
140
|
default:
|
|
133
141
|
return undefined;
|
|
134
142
|
}
|
|
@@ -136,7 +144,7 @@ export const apiConnectorFromEnvironment = Effect.fn("@llm4ts/runner/Connectors.
|
|
|
136
144
|
if (preset === undefined) {
|
|
137
145
|
return yield* ScriptUsage.make({
|
|
138
146
|
message: `unknown LLM4TS_PROVIDER '${provider}'; expected ` +
|
|
139
|
-
"mock|openai|anthropic|gemini|lm-studio|ollama"
|
|
147
|
+
"mock|openai|anthropic|gemini|lm-studio|ollama|mlx-lm"
|
|
140
148
|
});
|
|
141
149
|
}
|
|
142
150
|
const model = environment.LLM4TS_MODEL?.trim();
|
|
@@ -187,4 +195,20 @@ export const coderFromEnvironment = Effect.fn("@llm4ts/runner/Connectors.coderFr
|
|
|
187
195
|
})
|
|
188
196
|
: preset;
|
|
189
197
|
});
|
|
198
|
+
/**
|
|
199
|
+
* The judgment seat from the environment (ADR 0017): `LLM4TS_JUDGMENT_PROVIDER`
|
|
200
|
+
* names an API provider the way `LLM4TS_PROVIDER` does, `LLM4TS_JUDGMENT_MODEL`
|
|
201
|
+
* its model. Unset, the runner falls back to the reasoning seat.
|
|
202
|
+
*/
|
|
203
|
+
export const judgmentConnectorFromEnvironment = Effect.fn("@llm4ts/runner/Connectors.judgmentConnectorFromEnvironment")(function* (environment = process.env) {
|
|
204
|
+
const provider = environment.LLM4TS_JUDGMENT_PROVIDER?.trim();
|
|
205
|
+
if (provider === undefined || provider.length === 0) {
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
return yield* apiConnectorFromEnvironment({
|
|
209
|
+
...environment,
|
|
210
|
+
LLM4TS_PROVIDER: provider,
|
|
211
|
+
LLM4TS_MODEL: environment.LLM4TS_JUDGMENT_MODEL
|
|
212
|
+
});
|
|
213
|
+
});
|
|
190
214
|
//# sourceMappingURL=Connectors.js.map
|
package/dist/Connectors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Connectors.js","sourceRoot":"","sources":["../src/Connectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAEnB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,e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AM,MAAM,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAA;IAClC,OAAO,MAAM,KAAK,SAAS;QACzB,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC;YACtB,OAAO,EAAE,yBAAyB,SAAS,eAAe,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;SAC/E,CAAC;QACJ,CAAC,CAAC,MAAM,CAAA;AACZ,CAAC,CACF,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC,EAAE,CACvD,4DAA4D,CAC7D,CAAC,QAAQ,CAAC,EACT,cAA4D,OAAO,CAAC,GAAG;IAEvE,MAAM,QAAQ,GAAG,WAAW,CAAC,wBAAwB,EAAE,IAAI,EAAE,CAAA;IAC7D,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpD,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,2BAA2B,CAAC;QACxC,GAAG,WAAW;QACd,eAAe,EAAE,QAAQ;QACzB,YAAY,EAAE,WAAW,CAAC,qBAAqB;KAChD,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/dist/Costs.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type * as DateTime from "effect/DateTime";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
import { CostReport } from "@llm4ts/flow/CostReport";
|
|
5
|
+
import type { PlainFileStoreShape } from "@llm4ts/flow/Persistence";
|
|
6
|
+
/**
|
|
7
|
+
* `llm4ts costs`: the budgeting view over every trace the runner wrote.
|
|
8
|
+
*
|
|
9
|
+
* Traces, not the cost ledger, are the source: a run can span hours and only
|
|
10
|
+
* the trace carries a timestamp per token report, which the hourly buckets
|
|
11
|
+
* need. One unreadable trace is reported and skipped rather than failing the
|
|
12
|
+
* whole report — the other runs still answer the question.
|
|
13
|
+
*/
|
|
14
|
+
export declare const TraceDirectoryName = ".llm4ts";
|
|
15
|
+
/** `trace-<timestamp>.jsonl` as the runner writes it, or a prefixed variant like `loop-trace-…`. */
|
|
16
|
+
export declare const isTraceFileName: (name: string) => boolean;
|
|
17
|
+
export declare const nodeListTraces: (directory: string) => ReadonlyArray<string>;
|
|
18
|
+
export interface CostsOptions {
|
|
19
|
+
/** Repositories whose `.llm4ts/` traces are read. */
|
|
20
|
+
readonly repos: ReadonlyArray<string>;
|
|
21
|
+
/** Drop token reports before this epoch millisecond. */
|
|
22
|
+
readonly since?: number;
|
|
23
|
+
readonly timeZone?: DateTime.TimeZone;
|
|
24
|
+
readonly runsPerDay?: number;
|
|
25
|
+
}
|
|
26
|
+
export interface CostsDependencies {
|
|
27
|
+
readonly files: PlainFileStoreShape;
|
|
28
|
+
/** Absolute trace paths under one `.llm4ts/` directory. */
|
|
29
|
+
readonly listTraces: (directory: string) => ReadonlyArray<string>;
|
|
30
|
+
}
|
|
31
|
+
export declare const nodeCostsDependencies: () => CostsDependencies;
|
|
32
|
+
declare const SkippedTrace_base: Schema.Class<SkippedTrace, Schema.Struct<{
|
|
33
|
+
readonly path: Schema.String;
|
|
34
|
+
readonly reason: Schema.String;
|
|
35
|
+
}>, {}>;
|
|
36
|
+
export declare class SkippedTrace extends SkippedTrace_base {
|
|
37
|
+
}
|
|
38
|
+
declare const CostsResult_base: Schema.Class<CostsResult, Schema.Struct<{
|
|
39
|
+
readonly report: typeof CostReport;
|
|
40
|
+
readonly traces: Schema.Int;
|
|
41
|
+
readonly skipped: Schema.$Array<typeof SkippedTrace>;
|
|
42
|
+
}>, {}>;
|
|
43
|
+
export declare class CostsResult extends CostsResult_base {
|
|
44
|
+
}
|
|
45
|
+
export declare const makeCostsProgram: (options: CostsOptions, dependencies?: CostsDependencies | undefined) => Effect.Effect<CostsResult, never, never>;
|
|
46
|
+
export declare const renderCostsResult: (result: CostsResult) => string;
|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AO,MAAM,gBAAgB,mHAgC3B,CAAA;AAEF,eAAO,MAAM,iBAAiB,GAAI,QAAQ,WAAW,KAAG,MAWvD,CAAA"}
|
package/dist/Costs.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
|
+
import { CostReport, buildCostReport, renderCostReport, usageSamplesFromTrace } from "@llm4ts/flow/CostReport";
|
|
6
|
+
import { describeFlowError } from "@llm4ts/flow/FlowError";
|
|
7
|
+
import { readTrace } from "@llm4ts/flow/Replay";
|
|
8
|
+
import { nodePlainFileStore } from "./NodePlainFileStore.js";
|
|
9
|
+
/**
|
|
10
|
+
* `llm4ts costs`: the budgeting view over every trace the runner wrote.
|
|
11
|
+
*
|
|
12
|
+
* Traces, not the cost ledger, are the source: a run can span hours and only
|
|
13
|
+
* the trace carries a timestamp per token report, which the hourly buckets
|
|
14
|
+
* need. One unreadable trace is reported and skipped rather than failing the
|
|
15
|
+
* whole report — the other runs still answer the question.
|
|
16
|
+
*/
|
|
17
|
+
export const TraceDirectoryName = ".llm4ts";
|
|
18
|
+
/** `trace-<timestamp>.jsonl` as the runner writes it, or a prefixed variant like `loop-trace-…`. */
|
|
19
|
+
export const isTraceFileName = (name) => /(?:^|-)trace-\d+\.jsonl$/u.test(name);
|
|
20
|
+
export const nodeListTraces = (directory) => existsSync(directory)
|
|
21
|
+
? readdirSync(directory)
|
|
22
|
+
.filter(isTraceFileName)
|
|
23
|
+
.sort()
|
|
24
|
+
.map((name) => join(directory, name))
|
|
25
|
+
: [];
|
|
26
|
+
export const nodeCostsDependencies = () => ({
|
|
27
|
+
files: nodePlainFileStore,
|
|
28
|
+
listTraces: nodeListTraces
|
|
29
|
+
});
|
|
30
|
+
export class SkippedTrace extends Schema.Class("SkippedTrace")({
|
|
31
|
+
path: Schema.String,
|
|
32
|
+
reason: Schema.String
|
|
33
|
+
}) {
|
|
34
|
+
}
|
|
35
|
+
export class CostsResult extends Schema.Class("CostsResult")({
|
|
36
|
+
report: CostReport,
|
|
37
|
+
traces: Schema.Int,
|
|
38
|
+
skipped: Schema.Array(SkippedTrace)
|
|
39
|
+
}) {
|
|
40
|
+
}
|
|
41
|
+
export const makeCostsProgram = Effect.fn("@llm4ts/runner/Costs.make")(function* (options, dependencies = nodeCostsDependencies()) {
|
|
42
|
+
const paths = options.repos.flatMap((repo) => dependencies.listTraces(join(repo, TraceDirectoryName)));
|
|
43
|
+
const skipped = [];
|
|
44
|
+
const samples = [];
|
|
45
|
+
for (const path of paths) {
|
|
46
|
+
const lines = yield* readTrace(dependencies.files, path).pipe(Effect.catch((error) => Effect.sync(() => {
|
|
47
|
+
skipped.push(SkippedTrace.make({ path, reason: describeFlowError(error) }));
|
|
48
|
+
return [];
|
|
49
|
+
})));
|
|
50
|
+
for (const sample of usageSamplesFromTrace(lines)) {
|
|
51
|
+
if (options.since === undefined || sample.at >= options.since) {
|
|
52
|
+
samples.push(sample);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return CostsResult.make({
|
|
57
|
+
report: buildCostReport(samples, {
|
|
58
|
+
...(options.timeZone === undefined ? {} : { timeZone: options.timeZone }),
|
|
59
|
+
...(options.runsPerDay === undefined ? {} : { runsPerDay: options.runsPerDay })
|
|
60
|
+
}),
|
|
61
|
+
traces: paths.length,
|
|
62
|
+
skipped
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
export const renderCostsResult = (result) => {
|
|
66
|
+
const skipped = result.skipped.length === 0
|
|
67
|
+
? []
|
|
68
|
+
: ["", ...result.skipped.map((entry) => `skipped ${entry.path}: ${entry.reason}`)];
|
|
69
|
+
return [
|
|
70
|
+
renderCostReport(result.report),
|
|
71
|
+
"",
|
|
72
|
+
`traces read: ${result.traces - result.skipped.length} of ${result.traces}`,
|
|
73
|
+
...skipped
|
|
74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AAC,CAAA;AACd,CAAC,CAAA"}
|
package/dist/FlowRunner.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type * as Scope from "effect/Scope";
|
|
|
3
3
|
import type { ConnectorConfig } from "@llm4ts/core/ConnectorConfig";
|
|
4
4
|
import type { ConnectorRegistryShape } from "@llm4ts/core/ConnectorRegistry";
|
|
5
5
|
import type { HttpClientShape } from "@llm4ts/core/HttpClient";
|
|
6
|
+
import type { JudgmentBackend } from "@llm4ts/core/judgment/Schemas";
|
|
6
7
|
import type { ProcessExecutorShape } from "@llm4ts/core/ProcessExecutor";
|
|
7
8
|
import type { TemporaryFilesShape } from "@llm4ts/core/TemporaryFiles";
|
|
8
9
|
import type { GeminiCliExecutorShape } from "@llm4ts/core/providers/GeminiCliProvider";
|
|
@@ -11,6 +12,7 @@ import { type CostBudget } from "@llm4ts/flow/CostLedger";
|
|
|
11
12
|
import { FlowLlmError, type FlowError } from "@llm4ts/flow/FlowError";
|
|
12
13
|
import { type FlowEventHub } from "@llm4ts/flow/FlowEvents";
|
|
13
14
|
import { type FlowContextShape } from "@llm4ts/flow/FlowContext";
|
|
15
|
+
import { type JudgmentLogShape } from "@llm4ts/flow/JudgmentLog";
|
|
14
16
|
import type { PlainFileStoreShape } from "@llm4ts/flow/Persistence";
|
|
15
17
|
import { type TerminalSurface, type Verbosity } from "./Terminal.ts";
|
|
16
18
|
export interface FlowRunnerDependencies {
|
|
@@ -19,6 +21,8 @@ export interface FlowRunnerDependencies {
|
|
|
19
21
|
readonly files: PlainFileStoreShape;
|
|
20
22
|
/** pi's own model config (ADR 0016), injectable so a test never reads $HOME. */
|
|
21
23
|
readonly readPiModelsJson?: () => string | undefined;
|
|
24
|
+
/** For the hosted TypeSafe judgment backend; defaults to the Node client. */
|
|
25
|
+
readonly http?: HttpClientShape;
|
|
22
26
|
}
|
|
23
27
|
export interface NodeConnectorDependencies {
|
|
24
28
|
readonly http: HttpClientShape;
|
|
@@ -34,7 +38,44 @@ export interface FlowRunnerOptions {
|
|
|
34
38
|
readonly coder: ConnectorConfig;
|
|
35
39
|
readonly reasoning?: ConnectorConfig;
|
|
36
40
|
readonly reviewers?: ReadonlyArray<ConnectorConfig>;
|
|
41
|
+
/**
|
|
42
|
+
* The seat typed judgments run on (ADR 0017). Defaults to the reasoning
|
|
43
|
+
* seat; point it at a small non-thinking model for one-token label scoring.
|
|
44
|
+
*/
|
|
45
|
+
readonly judgment?: ConnectorConfig;
|
|
46
|
+
/**
|
|
47
|
+
* `llm` (default) answers on the judgment seat; `typesafe` uses the hosted
|
|
48
|
+
* Jev model with `TYPESAFE_API_KEY` from the environment. Unset, the
|
|
49
|
+
* environment's `LLM4TS_JUDGMENT_BACKEND` decides, then `llm`.
|
|
50
|
+
*/
|
|
51
|
+
readonly judgmentBackend?: JudgmentBackend;
|
|
52
|
+
/** Persist judgment observations under workDir/.llm4ts/judgments; off by default. */
|
|
53
|
+
readonly judgmentLog?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Meter every seat with `EstimatedUsage`, so a backend that reports no
|
|
56
|
+
* token counts still yields usage — counted from characters and
|
|
57
|
+
* labelled `estimated:<model>`, never mixed with measured usage. Default
|
|
58
|
+
* `true`; `false`, or `LLM4TS_ESTIMATE_USAGE=0` in the environment, leaves
|
|
59
|
+
* the seats raw and those runs accrue nothing.
|
|
60
|
+
*/
|
|
61
|
+
readonly estimateUsage?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Where the run's trace goes. Default `workDir/.llm4ts/trace-<start ms>.jsonl`
|
|
64
|
+
* while `persistRun` holds.
|
|
65
|
+
*/
|
|
37
66
|
readonly tracePath?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Append-only ledger (`CostLedger`) that receives one `CostRecord` per run
|
|
69
|
+
* that accrued usage, so `llm4ts costs` and budgets can look across runs.
|
|
70
|
+
* Default `workDir/.llm4ts/costs.jsonl` while `persistRun` holds.
|
|
71
|
+
*/
|
|
72
|
+
readonly costLedgerPath?: string;
|
|
73
|
+
/**
|
|
74
|
+
* `false` writes neither the trace nor the ledger unless their paths are
|
|
75
|
+
* given explicitly. Default `true`: every run leaves its record under
|
|
76
|
+
* `workDir/.llm4ts/`, which `llm4ts costs` and replay read back.
|
|
77
|
+
*/
|
|
78
|
+
readonly persistRun?: boolean;
|
|
38
79
|
readonly runId?: string;
|
|
39
80
|
readonly verbosity?: Verbosity;
|
|
40
81
|
readonly surface?: TerminalSurface;
|
|
@@ -53,6 +94,8 @@ export interface FlowRunnerBundle {
|
|
|
53
94
|
readonly events: FlowEventHub;
|
|
54
95
|
/** The run's cost tracker, already subscribed to `events`. */
|
|
55
96
|
readonly tracker: CostTracker;
|
|
97
|
+
readonly runId: string;
|
|
98
|
+
readonly judgmentLog?: JudgmentLogShape;
|
|
56
99
|
}
|
|
57
100
|
export declare const makeFlowRunnerContext: (options: FlowRunnerOptions, dependencies: FlowRunnerDependencies) => Effect.Effect<FlowRunnerBundle, import("@llm4ts/flow/FlowError").PersistenceError | import("@llm4ts/flow/FlowError").PlanParseError | import("@llm4ts/flow/FlowError").UnsupportedSchemaVersion | import("@llm4ts/flow/FlowError").WorkspacePathError | import("@llm4ts/flow/FlowError").WorkspaceLimitError | import("@llm4ts/flow/FlowError").WorkspaceIoError | import("@llm4ts/flow/FlowError").FlowAborted | import("@llm4ts/flow/FlowError").ProcessError | FlowLlmError | import("@llm4ts/flow/FlowError").FlowCapabilityDenied | import("@llm4ts/flow/FlowError").ColumnNotFound | import("@llm4ts/flow/FlowError").BudgetExceeded | import("@llm4ts/flow/FlowError").StoryPlanInvalid | import("@llm4ts/flow/FlowError").PerimeterViolation | import("@llm4ts/flow/FlowError").MissingDependency | import("@llm4ts/flow/FlowError").MergeConflict | import("@llm4ts/flow/FlowError").StoryFailed | import("@llm4ts/flow/FlowError").DecisionsInvalid | import("@llm4ts/flow/FlowError").OpenPointsPending | import("@llm4ts/flow/FlowError").ContractConflict, Scope.Scope>;
|
|
58
101
|
export declare const runWithBundle: <A, E, R>(bundle: FlowRunnerBundle, options: FlowRunnerOptions, body: (context: FlowContextShape) => Effect.Effect<A, E, R>, dependencies?: FlowRunnerDependencies | undefined) => Effect.Effect<A, import("@llm4ts/flow/FlowError").PersistenceError | import("@llm4ts/flow/FlowError").PlanParseError | import("@llm4ts/flow/FlowError").UnsupportedSchemaVersion | import("@llm4ts/flow/FlowError").WorkspacePathError | import("@llm4ts/flow/FlowError").WorkspaceLimitError | import("@llm4ts/flow/FlowError").WorkspaceIoError | import("@llm4ts/flow/FlowError").FlowAborted | import("@llm4ts/flow/FlowError").ProcessError | FlowLlmError | import("@llm4ts/flow/FlowError").FlowCapabilityDenied | import("@llm4ts/flow/FlowError").ColumnNotFound | import("@llm4ts/flow/FlowError").BudgetExceeded | import("@llm4ts/flow/FlowError").StoryPlanInvalid | import("@llm4ts/flow/FlowError").PerimeterViolation | import("@llm4ts/flow/FlowError").MissingDependency | import("@llm4ts/flow/FlowError").MergeConflict | import("@llm4ts/flow/FlowError").StoryFailed | import("@llm4ts/flow/FlowError").DecisionsInvalid | import("@llm4ts/flow/FlowError").OpenPointsPending | import("@llm4ts/flow/FlowError").ContractConflict | E, Scope.Scope | R>;
|
package/dist/FlowRunner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlowRunner.d.ts","sourceRoot":"","sources":["../src/FlowRunner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FlowRunner.d.ts","sourceRoot":"","sources":["../src/FlowRunner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAEnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,eAAe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ClC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAA;IAC7B,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAA;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,gBAAgB,CAAA;CACxC;AAmED,eAAO,MAAM,qBAAqB,4lCA4MhC,CAAA;AAEF,eAAO,MAAM,aAAa,GACxB,CAAC,EACD,CAAC,EACD,CAAC,wEAIe,gBAAgB,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,qkCA8I3D,CAAA;AAEF,eAAO,MAAM,WAAW,GAAiE,CAAC,EAAE,CAAC,EAAE,CAAC,8CAE9E,gBAAgB,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,qkCAK3D,CAAA;AAEF,eAAO,MAAM,OAAO,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAC7B,SAAS,iBAAiB,EAC1B,MAAM,CAAC,OAAO,EAAE,gBAAgB,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC1D,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,CAA8C,CAAA;AAKlF,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,SAAS,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,KAAG,IAchE,CAAA"}
|
package/dist/FlowRunner.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
1
2
|
import * as Clock from "effect/Clock";
|
|
2
3
|
import * as Effect from "effect/Effect";
|
|
3
4
|
import { CliConnectorConfig, defaultReasoningConfig } from "@llm4ts/core/ConnectorConfig";
|
|
5
|
+
import { LlmJudgmentConfig, makeLlmJudgment } from "@llm4ts/core/judgment/LlmJudgment";
|
|
6
|
+
import { makeTypeSafeJudgment } from "@llm4ts/core/judgment/TypeSafeJudgment";
|
|
7
|
+
import * as Redacted from "effect/Redacted";
|
|
4
8
|
import { createConnectorRegistry } from "@llm4ts/core/providers/ConnectorFactories";
|
|
5
9
|
import { ConnectorIds } from "@llm4ts/core/Models";
|
|
6
10
|
import { ProviderError } from "@llm4ts/core/Errors";
|
|
7
11
|
import { makeCostTracker } from "@llm4ts/flow/CostTracker";
|
|
8
12
|
import { runGeminiAcpBridge } from "./NodeGeminiAcpBridge.js";
|
|
9
13
|
import { bridgeModelProblem, defaultReadPiModelsJson, geminiBridgePort, resolveBridgeModel } from "./PiModels.js";
|
|
10
|
-
import { checkCostBudget, makeCostRecord } from "@llm4ts/flow/CostLedger";
|
|
14
|
+
import { appendCostRecord, checkCostBudget, CostLedgerFileName, makeCostRecord } from "@llm4ts/flow/CostLedger";
|
|
15
|
+
import { estimatedUsageOptionsFromEnv, makeEstimatedUsageMeter } from "@llm4ts/flow/EstimatedUsage";
|
|
11
16
|
import { FlowLlmError, describeFlowError } from "@llm4ts/flow/FlowError";
|
|
12
|
-
import { FlowEvents, FlowEventsValues, makeFlowEventHub } from "@llm4ts/flow/FlowEvents";
|
|
17
|
+
import { FlowEvents, FlowEventsValues, Info, TokensUsed, makeFlowEventHub } from "@llm4ts/flow/FlowEvents";
|
|
13
18
|
import { FlowContext } from "@llm4ts/flow/FlowContext";
|
|
14
19
|
import { makeFlowRecorder } from "@llm4ts/flow/FlowRecorder";
|
|
20
|
+
import { makeJudgmentLog } from "@llm4ts/flow/JudgmentLog";
|
|
15
21
|
import { makeGitHubTool } from "@llm4ts/flow/GitHubTool";
|
|
16
22
|
import { makeGitTool } from "@llm4ts/flow/GitTool";
|
|
17
23
|
import { makeTransientRetry } from "@llm4ts/flow/TransientRetry";
|
|
@@ -30,6 +36,7 @@ const describeSeat = (config) => {
|
|
|
30
36
|
export const nodeFlowRunnerDependencies = () => ({
|
|
31
37
|
process: nodeProcessExecutor,
|
|
32
38
|
files: nodePlainFileStore,
|
|
39
|
+
http: nodeHttpClient,
|
|
33
40
|
registry: createConnectorRegistry({
|
|
34
41
|
http: nodeHttpClient,
|
|
35
42
|
process: nodeProcessExecutor,
|
|
@@ -38,6 +45,7 @@ export const nodeFlowRunnerDependencies = () => ({
|
|
|
38
45
|
})
|
|
39
46
|
});
|
|
40
47
|
const truthy = (value) => value !== undefined && ["1", "true", "yes"].includes(value.trim().toLowerCase());
|
|
48
|
+
const switchedOff = (value) => value !== undefined && ["0", "false", "no", "off"].includes(value.trim().toLowerCase());
|
|
41
49
|
const isPiSeat = (config) => config instanceof CliConnectorConfig && config.connectorId.value === ConnectorIds.Pi.value;
|
|
42
50
|
/**
|
|
43
51
|
* Start the ADR 0016 bridge for a `pi`-coder run, scoped to that run, and
|
|
@@ -82,6 +90,12 @@ const geminiBridgeSeats = Effect.fn("@llm4ts/runner/FlowRunner.geminiBridgeSeats
|
|
|
82
90
|
});
|
|
83
91
|
export const makeFlowRunnerContext = Effect.fn("@llm4ts/runner/FlowRunner.makeContext")(function* (options, dependencies) {
|
|
84
92
|
const events = yield* makeFlowEventHub();
|
|
93
|
+
const runId = options.runId ?? `run-${(yield* Clock.currentTimeMillis).toString()}`;
|
|
94
|
+
const judgmentLog = options.judgmentLog === true
|
|
95
|
+
? yield* makeJudgmentLog({ files: dependencies.files, root: options.workDir, runId })
|
|
96
|
+
: undefined;
|
|
97
|
+
if (judgmentLog !== undefined)
|
|
98
|
+
yield* judgmentLog.consume(events);
|
|
85
99
|
const tracker = yield* makeCostTracker();
|
|
86
100
|
yield* tracker.consume(events);
|
|
87
101
|
const reasoning = defaultReasoningConfig(options.coder, options.reasoning);
|
|
@@ -104,19 +118,76 @@ export const makeFlowRunnerContext = Effect.fn("@llm4ts/runner/FlowRunner.makeCo
|
|
|
104
118
|
`is ${connector.capabilities.readOnlyEnforcement} — the flag is a request, not a ` +
|
|
105
119
|
"capability removal"))
|
|
106
120
|
: Effect.void;
|
|
121
|
+
// Every seat is metered, so no run is silently free: a backend that reports
|
|
122
|
+
// no token counts (`capabilities.usageReporting` false) is estimated from
|
|
123
|
+
// character counts and labelled `estimated:<model>`, which is what makes
|
|
124
|
+
// `TokensUsed` — and therefore cost summaries, budgets, the ledger, and
|
|
125
|
+
// `llm4ts costs` — answer for those seats at all. Measured usage always
|
|
126
|
+
// wins; the estimate only fills a gap the backend left. Metering here rather
|
|
127
|
+
// than in each flow also covers the seats a flow never touches directly,
|
|
128
|
+
// notably the judgment seat and the worktree seats `contextFor` rebinds.
|
|
129
|
+
const runEnvironment = options.environment ?? process.env;
|
|
130
|
+
const estimateOptions = estimatedUsageOptionsFromEnv(runEnvironment);
|
|
131
|
+
const meterUsage = options.estimateUsage ?? !switchedOff(runEnvironment.LLM4TS_ESTIMATE_USAGE);
|
|
132
|
+
const metered = (service) => meterUsage
|
|
133
|
+
? Effect.map(makeEstimatedUsageMeter(service, estimateOptions), (meter) => meter.service)
|
|
134
|
+
: Effect.succeed(service);
|
|
107
135
|
// The spread keeps everything the connector carries beyond the service
|
|
108
|
-
// methods — notably `capabilities`, which the flow context exposes.
|
|
109
|
-
|
|
136
|
+
// methods — notably `capabilities`, which the flow context exposes. The
|
|
137
|
+
// meter decorates the retrying seat, so an estimate reflects the attempt
|
|
138
|
+
// that actually succeeded, and it sees `scoreLabelSequence` when the
|
|
139
|
+
// connector has one (the retry wrapper does not carry it).
|
|
140
|
+
const resolveSeat = (configuration) => dependencies.registry.resolve(configuration).pipe(Effect.mapError(FlowLlmError.from), Effect.flatMap((connector) => announceReadOnlyGrade(configuration, connector).pipe(Effect.andThen(Effect.flatMap(resilient(connector), (retrying) => {
|
|
141
|
+
const seat = { ...connector, ...retrying };
|
|
142
|
+
return Effect.map(metered(seat), (measured) => ({ ...seat, ...measured }));
|
|
143
|
+
})))));
|
|
144
|
+
// Judgment usage is metered like any chat (ADR 0005 amendment) and every
|
|
145
|
+
// fallback from label scoring to the verbalized path is announced.
|
|
146
|
+
const judgmentHooks = {
|
|
147
|
+
onUsage: (usage, model) => events.publish(new TokensUsed({ agent: "judgment", usage, ...(model === undefined ? {} : { model }) })),
|
|
148
|
+
onFallback: (key, reason) => events.publish(new Info({ message: `judgment '${key}' fell back to verbalized scoring: ${reason}` }))
|
|
149
|
+
};
|
|
150
|
+
const judgmentFor = (seat, seatConfig, environment) => {
|
|
151
|
+
const backend = options.judgmentBackend ??
|
|
152
|
+
(environment.LLM4TS_JUDGMENT_BACKEND?.trim().toLowerCase() === "typesafe"
|
|
153
|
+
? "typesafe"
|
|
154
|
+
: "llm");
|
|
155
|
+
if (backend !== "typesafe") {
|
|
156
|
+
return Effect.succeed(makeLlmJudgment(seat, LlmJudgmentConfig.make({
|
|
157
|
+
connector: seatConfig.connectorId.value,
|
|
158
|
+
...(seatConfig.model === undefined ? {} : { model: seatConfig.model }),
|
|
159
|
+
// LLM4TS_JUDGMENT_BATCHING=shared-prefix sends each request's state
|
|
160
|
+
// once with every question; anything else keeps them independent.
|
|
161
|
+
...(environment.LLM4TS_JUDGMENT_BATCHING?.trim().toLowerCase() === "shared-prefix"
|
|
162
|
+
? { batching: "shared-prefix" }
|
|
163
|
+
: {})
|
|
164
|
+
}), judgmentHooks));
|
|
165
|
+
}
|
|
166
|
+
const key = environment.TYPESAFE_API_KEY?.trim();
|
|
167
|
+
if (key === undefined || key.length === 0) {
|
|
168
|
+
return Effect.fail(FlowLlmError.from(ProviderError.make({
|
|
169
|
+
message: "judgment backend 'typesafe' needs TYPESAFE_API_KEY in the environment"
|
|
170
|
+
})));
|
|
171
|
+
}
|
|
172
|
+
return Effect.succeed(makeTypeSafeJudgment({ apiKey: Redacted.make(key), onUsage: judgmentHooks.onUsage }, dependencies.http ?? nodeHttpClient));
|
|
173
|
+
};
|
|
110
174
|
const seatsFor = Effect.fn("@llm4ts/runner/FlowRunner.seatsFor")(function* (workDir) {
|
|
111
175
|
const environment = options.environment ?? process.env;
|
|
112
176
|
const coder = yield* resolveSeat(prepareConnector(bridged(options.coder), workDir, environment));
|
|
113
177
|
const reasoningService = yield* resolveSeat(prepareConnector(bridged(reasoning), workDir, environment));
|
|
114
178
|
const reviewers = yield* Effect.forEach(options.reviewers ?? [], (configuration) => resolveSeat(prepareConnector(bridged(configuration), workDir, environment)));
|
|
115
|
-
|
|
179
|
+
// The judgment seat defaults to the reasoning seat's service itself, so
|
|
180
|
+
// an unconfigured run resolves nothing extra.
|
|
181
|
+
const judgmentSeat = options.judgment === undefined
|
|
182
|
+
? reasoningService
|
|
183
|
+
: yield* resolveSeat(prepareConnector(bridged(options.judgment), workDir, environment));
|
|
184
|
+
const judgment = yield* judgmentFor(judgmentSeat, options.judgment ?? reasoning, environment);
|
|
185
|
+
return { coder, reasoning: reasoningService, reviewers, judgment };
|
|
116
186
|
});
|
|
117
187
|
const contextAt = (workDir, seats, rebind) => FlowContext.of({
|
|
118
188
|
reasoning: seats.reasoning,
|
|
119
189
|
coder: seats.coder,
|
|
190
|
+
judgment: seats.judgment,
|
|
120
191
|
git: makeGitTool(dependencies.process, workDir, events),
|
|
121
192
|
hosting: makeGitHubTool(dependencies.process, workDir, events),
|
|
122
193
|
events,
|
|
@@ -137,6 +208,8 @@ export const makeFlowRunnerContext = Effect.fn("@llm4ts/runner/FlowRunner.makeCo
|
|
|
137
208
|
return {
|
|
138
209
|
events,
|
|
139
210
|
tracker,
|
|
211
|
+
runId,
|
|
212
|
+
...(judgmentLog === undefined ? {} : { judgmentLog }),
|
|
140
213
|
context: contextAt(options.workDir, seats, true)
|
|
141
214
|
};
|
|
142
215
|
});
|
|
@@ -144,6 +217,11 @@ export const runWithBundle = Effect.fn("@llm4ts/runner/FlowRunner.runWithBundle"
|
|
|
144
217
|
const startedAt = yield* Clock.currentTimeMillis;
|
|
145
218
|
const environment = options.environment ?? process.env;
|
|
146
219
|
const verbosity = options.verbosity ?? "Normal";
|
|
220
|
+
const persistRun = options.persistRun ?? true;
|
|
221
|
+
const tracePath = options.tracePath ??
|
|
222
|
+
(persistRun ? join(options.workDir, ".llm4ts", `trace-${startedAt}.jsonl`) : undefined);
|
|
223
|
+
const costLedgerPath = options.costLedgerPath ??
|
|
224
|
+
(persistRun ? join(options.workDir, ".llm4ts", CostLedgerFileName) : undefined);
|
|
147
225
|
const tracker = bundle.tracker;
|
|
148
226
|
const surface = options.surface ?? (yield* makeTerminalSurface(environment));
|
|
149
227
|
const palette = surface.palette;
|
|
@@ -158,13 +236,13 @@ export const runWithBundle = Effect.fn("@llm4ts/runner/FlowRunner.runWithBundle"
|
|
|
158
236
|
...(reviewers.length === 0 ? [] : [`reviewers ${reviewers.map(describeSeat).join(", ")}`])
|
|
159
237
|
].join(" · ");
|
|
160
238
|
yield* surface.log(palette.info(`${seats} · ${options.workDir}`));
|
|
161
|
-
if (
|
|
162
|
-
yield* surface.log(palette.info(`trace ${
|
|
239
|
+
if (tracePath !== undefined) {
|
|
240
|
+
yield* surface.log(palette.info(`trace ${tracePath}${options.runId === undefined ? "" : ` · run ${options.runId}`}`));
|
|
163
241
|
}
|
|
164
242
|
}
|
|
165
|
-
const recorder =
|
|
243
|
+
const recorder = tracePath === undefined
|
|
166
244
|
? undefined
|
|
167
|
-
: yield* makeFlowRecorder(dependencies.files,
|
|
245
|
+
: yield* makeFlowRecorder(dependencies.files, tracePath, bundle.runId);
|
|
168
246
|
if (recorder !== undefined) {
|
|
169
247
|
yield* recorder.consume(bundle.events);
|
|
170
248
|
}
|
|
@@ -184,16 +262,36 @@ export const runWithBundle = Effect.fn("@llm4ts/runner/FlowRunner.runWithBundle"
|
|
|
184
262
|
cells
|
|
185
263
|
}), budget);
|
|
186
264
|
});
|
|
265
|
+
// Runs without usage leave no record: a ledger line of zeros would only
|
|
266
|
+
// inflate run counts for backends that report nothing.
|
|
267
|
+
const appendLedger = costLedgerPath === undefined
|
|
268
|
+
? Effect.void
|
|
269
|
+
: Effect.gen(function* () {
|
|
270
|
+
const cells = yield* tracker.cells;
|
|
271
|
+
if (cells.length === 0) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
yield* appendCostRecord(dependencies.files, costLedgerPath, makeCostRecord({
|
|
275
|
+
runId: bundle.runId,
|
|
276
|
+
at: new Date(startedAt).toISOString(),
|
|
277
|
+
repo: options.workDir,
|
|
278
|
+
prompt: options.userPrompt,
|
|
279
|
+
cells
|
|
280
|
+
}));
|
|
281
|
+
}).pipe(Effect.catch((error) => surface.log(palette.fail(`cost ledger not written: ${describeFlowError(error)}`))));
|
|
187
282
|
return yield* body(bundle.context).pipe(Effect.provideService(FlowContext, bundle.context), Effect.andThen((value) => Effect.as(enforceBudget, value)), Effect.ensuring(Effect.all([
|
|
188
283
|
terminal.awaitDrained(),
|
|
189
284
|
tracker.awaitDrained(bundle.events),
|
|
190
|
-
recorder === undefined ? Effect.void : recorder.awaitDrained(bundle.events)
|
|
191
|
-
|
|
285
|
+
recorder === undefined ? Effect.void : recorder.awaitDrained(bundle.events),
|
|
286
|
+
bundle.judgmentLog === undefined
|
|
287
|
+
? Effect.void
|
|
288
|
+
: bundle.judgmentLog.awaitDrained(bundle.events)
|
|
289
|
+
], { concurrency: "unbounded" }).pipe(Effect.andThen(appendLedger), Effect.andThen(surface.setStatus(undefined)), Effect.andThen(tracker.summary), Effect.flatMap((summary) => surface.log(`\n${summary}`)))), Effect.tapError((error) => Effect.gen(function* () {
|
|
192
290
|
const finishedAt = yield* Clock.currentTimeMillis;
|
|
193
291
|
yield* surface.setStatus(undefined);
|
|
194
292
|
yield* surface.log(`\n${palette.fail(`flow failed after ${formatDurationMs(finishedAt - startedAt)}: ${describeFlowError(error)}`)}`);
|
|
195
|
-
if (
|
|
196
|
-
yield* surface.log(palette.info(`trace ${
|
|
293
|
+
if (tracePath !== undefined) {
|
|
294
|
+
yield* surface.log(palette.info(`trace ${tracePath}`));
|
|
197
295
|
}
|
|
198
296
|
})), Effect.tap(() => Effect.gen(function* () {
|
|
199
297
|
const finishedAt = yield* Clock.currentTimeMillis;
|