@owlmeans/agent 0.1.18-rc.47 → 0.1.18-rc.49
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/README.md +4 -4
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/agent/SKILL.md +9 -9
- package/build/helpers/compaction/types.d.ts +49 -0
- package/build/helpers/compaction/types.d.ts.map +1 -0
- package/build/helpers/compaction/types.js.map +1 -0
- package/build/helpers/compaction.d.ts +6 -20
- package/build/helpers/compaction.d.ts.map +1 -1
- package/build/helpers/compaction.js +72 -81
- package/build/helpers/compaction.js.map +1 -1
- package/build/helpers/index.d.ts +3 -1
- package/build/helpers/index.d.ts.map +1 -1
- package/build/helpers/index.js.map +1 -1
- package/build/helpers/rolling/types.d.ts +16 -0
- package/build/helpers/rolling/types.d.ts.map +1 -0
- package/build/helpers/rolling/types.js +2 -0
- package/build/helpers/rolling/types.js.map +1 -0
- package/build/helpers/rolling.d.ts +1 -1
- package/build/helpers/rolling.d.ts.map +1 -1
- package/build/helpers/tools/types.d.ts +38 -0
- package/build/helpers/tools/types.d.ts.map +1 -0
- package/build/helpers/tools/types.js +2 -0
- package/build/helpers/{types.js.map → tools/types.js.map} +1 -1
- package/build/helpers/tools.d.ts +6 -26
- package/build/helpers/tools.d.ts.map +1 -1
- package/build/helpers/tools.js +27 -42
- package/build/helpers/tools.js.map +1 -1
- package/build/model.d.ts.map +1 -1
- package/build/model.js +4 -4
- package/build/model.js.map +1 -1
- package/build/pipeline/index.d.ts +2 -1
- package/build/pipeline/index.d.ts.map +1 -1
- package/build/pipeline/results/types.d.ts +139 -0
- package/build/pipeline/results/types.d.ts.map +1 -0
- package/build/pipeline/results/types.js +2 -0
- package/build/pipeline/results/types.js.map +1 -0
- package/build/pipeline/{types.local.d.ts → results/types.local.d.ts} +0 -18
- package/build/pipeline/results/types.local.d.ts.map +1 -0
- package/build/pipeline/results/types.local.js.map +1 -0
- package/build/pipeline/results.d.ts +2 -1
- package/build/pipeline/results.d.ts.map +1 -1
- package/build/pipeline/results.js +22 -22
- package/build/pipeline/results.js.map +1 -1
- package/build/pipeline/runner/types.d.ts +293 -0
- package/build/pipeline/runner/types.d.ts.map +1 -0
- package/build/pipeline/runner/types.js +2 -0
- package/build/pipeline/runner/types.js.map +1 -0
- package/build/pipeline/runner/types.local.d.ts +19 -0
- package/build/pipeline/runner/types.local.d.ts.map +1 -0
- package/build/pipeline/runner/types.local.js +2 -0
- package/build/pipeline/runner/types.local.js.map +1 -0
- package/build/pipeline/runner.d.ts +1 -1
- package/build/pipeline/runner.d.ts.map +1 -1
- package/build/pipeline/runner.js +10 -9
- package/build/pipeline/runner.js.map +1 -1
- package/build/pipeline/types.d.ts +2 -93
- package/build/pipeline/types.d.ts.map +1 -1
- package/build/plugins/export.d.ts +2 -2
- package/build/plugins/export.d.ts.map +1 -1
- package/build/plugins/export.js +2 -2
- package/build/plugins/export.js.map +1 -1
- package/build/plugins/inquiry.d.ts.map +1 -1
- package/build/plugins/inquiry.js +4 -4
- package/build/plugins/inquiry.js.map +1 -1
- package/build/plugins/memory-events.d.ts +3 -1
- package/build/plugins/memory-events.d.ts.map +1 -1
- package/build/plugins/memory-events.js +4 -2
- package/build/plugins/memory-events.js.map +1 -1
- package/build/plugins/memory-graph.d.ts +5 -1
- package/build/plugins/memory-graph.d.ts.map +1 -1
- package/build/plugins/memory-graph.js +4 -2
- package/build/plugins/memory-graph.js.map +1 -1
- package/build/plugins/summarize.d.ts.map +1 -1
- package/build/plugins/summarize.js +2 -2
- package/build/plugins/summarize.js.map +1 -1
- package/build/types.d.ts +5 -3
- package/build/types.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/helpers/compaction/types.ts +51 -0
- package/src/helpers/compaction.ts +98 -101
- package/src/helpers/index.ts +3 -1
- package/src/helpers/rolling/types.ts +16 -0
- package/src/helpers/rolling.ts +1 -1
- package/src/helpers/tools/types.ts +37 -0
- package/src/helpers/tools.ts +39 -47
- package/src/model.ts +4 -4
- package/src/pipeline/index.ts +2 -1
- package/src/pipeline/{types.local.ts → results/types.local.ts} +0 -21
- package/src/pipeline/results/types.ts +152 -0
- package/src/pipeline/results.ts +25 -24
- package/src/pipeline/runner/types.local.ts +21 -0
- package/src/pipeline/{types.ts → runner/types.ts} +4 -156
- package/src/pipeline/runner.ts +14 -12
- package/src/plugins/export.ts +2 -2
- package/src/plugins/inquiry.ts +4 -4
- package/src/plugins/memory-events.ts +8 -2
- package/src/plugins/memory-graph.ts +8 -2
- package/src/plugins/summarize.ts +2 -2
- package/src/types.ts +4 -4
- package/tests/inquiry.spec.ts +14 -15
- package/tests/pipeline-inquiry.spec.ts +3 -3
- package/tests/plugins.spec.ts +10 -10
- package/tests/summary.spec.ts +8 -8
- package/tests/tools.spec.ts +11 -11
- package/build/helpers/types.d.ts +0 -42
- package/build/helpers/types.d.ts.map +0 -1
- package/build/pipeline/types.local.d.ts.map +0 -1
- package/build/pipeline/types.local.js.map +0 -1
- package/src/helpers/types.ts +0 -43
- /package/build/helpers/{types.js → compaction/types.js} +0 -0
- /package/build/pipeline/{types.local.js → results/types.local.js} +0 -0
package/build/helpers/tools.js
CHANGED
|
@@ -1,47 +1,32 @@
|
|
|
1
1
|
import { logger } from '@owlmeans/log';
|
|
2
2
|
const log = logger('agent:tools');
|
|
3
|
-
export const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* already finished. A tool failure has to come back as something the model can read and correct
|
|
12
|
-
* instead — most of them are the model's own mistake (an argument outside an enum, a hallucinated
|
|
13
|
-
* tool name), and the error text already names what was expected.
|
|
14
|
-
*
|
|
15
|
-
* Awaiting `invoke` is what makes the catch reachable: the tool's schema is validated inside it, so
|
|
16
|
-
* a bad argument rejects asynchronously and returning the promise unawaited would carry the
|
|
17
|
-
* rejection straight past this handler.
|
|
18
|
-
*
|
|
19
|
-
* Resolution is by the tool's OWN name, not by the map key. `bindTools` advertises `tool.name`, so
|
|
20
|
-
* that is what the model calls — a map keyed by a local variable silently loses any tool whose two
|
|
21
|
-
* names drifted apart, leaving it advertised, callable, and permanently "not found". The key stays
|
|
22
|
-
* as a fallback so a caller may still address a tool by it.
|
|
23
|
-
*
|
|
24
|
-
* `fatal` is the ONE exception to "never throws", and it exists because containment has a cost the
|
|
25
|
-
* containment itself cannot see. A tool may be a whole pipeline behind a single call; when the
|
|
26
|
-
* thing that stopped it is an exhausted budget or a refusal, handing the model a readable error
|
|
27
|
-
* message is an invitation to pick another tool and spend again. A caller that knows which errors
|
|
28
|
-
* mean "stop" says so here, and those alone travel out.
|
|
29
|
-
*/
|
|
30
|
-
export const safeInvokeTool = async (tools, toolCall, fatal) => {
|
|
31
|
-
const tool = tools[toolCall.name]
|
|
32
|
-
?? Object.values(tools).find(entry => entry.name === toolCall.name);
|
|
33
|
-
if (tool == null) {
|
|
34
|
-
return toErrorResponse(new Error(`Tool ${toolCall.name} not found`));
|
|
35
|
-
}
|
|
36
|
-
try {
|
|
37
|
-
return await tool.invoke(toolCall.args);
|
|
38
|
-
}
|
|
39
|
-
catch (e) {
|
|
40
|
-
if (fatal?.(e) === true) {
|
|
41
|
-
throw e;
|
|
3
|
+
export const createToolHelper = () => {
|
|
4
|
+
const toErrorResponse = (e) => ({ error: `Error during tool call: ${(e instanceof Error) ? e.message : String(e)}` });
|
|
5
|
+
const isToolError = (result) => typeof result === 'object' && result != null && 'error' in result;
|
|
6
|
+
const safeInvokeTool = async (tools, toolCall, fatal) => {
|
|
7
|
+
const tool = tools[toolCall.name]
|
|
8
|
+
?? Object.values(tools).find(entry => entry.name === toolCall.name);
|
|
9
|
+
if (tool == null) {
|
|
10
|
+
return toErrorResponse(new Error(`Tool ${toolCall.name} not found`));
|
|
42
11
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
12
|
+
try {
|
|
13
|
+
return await tool.invoke(toolCall.args);
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
if (fatal?.(e) === true) {
|
|
17
|
+
throw e;
|
|
18
|
+
}
|
|
19
|
+
log.warn('Tool call failed', { tool: toolCall.name, error: e });
|
|
20
|
+
return toErrorResponse(e);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return { toErrorResponse, isToolError, safeInvokeTool };
|
|
46
24
|
};
|
|
25
|
+
export const toolHelper = createToolHelper();
|
|
26
|
+
/** @deprecated compat:factory-refactor — use `toolHelper.toErrorResponse(…)` */
|
|
27
|
+
export const toErrorResponse = (e) => toolHelper.toErrorResponse(e);
|
|
28
|
+
/** @deprecated compat:factory-refactor — use `toolHelper.isToolError(…)` */
|
|
29
|
+
export const isToolError = (result) => toolHelper.isToolError(result);
|
|
30
|
+
/** @deprecated compat:factory-refactor — use `toolHelper.safeInvokeTool(…)` */
|
|
31
|
+
export const safeInvokeTool = (tools, toolCall, fatal) => toolHelper.safeInvokeTool(tools, toolCall, fatal);
|
|
47
32
|
//# sourceMappingURL=tools.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/helpers/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAItC,MAAM,GAAG,GAAG,MAAM,CAAC,aAAa,CAAC,CAAA;AAEjC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAU,EAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/helpers/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAItC,MAAM,GAAG,GAAG,MAAM,CAAC,aAAa,CAAC,CAAA;AAEjC,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAe,EAAE;IAC/C,MAAM,eAAe,GAAG,CAAC,CAAU,EAAqB,EAAE,CACxD,CAAC,EAAE,KAAK,EAAE,2BAA2B,CAAC,CAAC,YAAY,KAAK,CAA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;AAE5C,gFAAgF;AAChF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAU,EAAqB,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;AAE/F,4EAA4E;AAC5E,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAe,EAA+B,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;AAE3G,+EAA+E;AAC/E,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAAmB,EAAE,QAAkB,EAAE,KAA+B,EACtD,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAA"}
|
package/build/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,UAAU,EAAE,YAAY,EACzB,MAAM,YAAY,CAAA;AAKnB;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,cAAc,YAAa,YAAY,KAAG,UAgQtD,CAAA"}
|
package/build/model.js
CHANGED
|
@@ -2,12 +2,12 @@ import { AIMessage, HumanMessage, SystemMessage, ToolMessage } from '@langchain/
|
|
|
2
2
|
import { addMessages, entrypoint, task } from '@langchain/langgraph';
|
|
3
3
|
import { createIdOfLength } from '@owlmeans/basic-ids';
|
|
4
4
|
import { makeFlowModel } from '@owlmeans/flow';
|
|
5
|
-
import {
|
|
5
|
+
import { llmPluginRegistry } from '@owlmeans/llm';
|
|
6
6
|
import { logger } from '@owlmeans/log';
|
|
7
7
|
import { AgentRunStatus, AgentRunTransition, agentRunFlow, conversationFor, } from '@owlmeans/agent-common';
|
|
8
8
|
import { DEFAULT_ACTION, DEFAULT_ENTRYPOINT, DEFAULT_MAX_TURNS, DEFAULT_PLUGIN_ORDER } from './consts.js';
|
|
9
9
|
import { AgentLoopExhaustedError, AgentMissconfiguredError } from './errors.js';
|
|
10
|
-
import {
|
|
10
|
+
import { toolHelper } from './helpers/tools.js';
|
|
11
11
|
const log = logger('agent');
|
|
12
12
|
/**
|
|
13
13
|
* An OwlMeans agent over the LangGraph functional API.
|
|
@@ -34,7 +34,7 @@ export const makeAgentModel = (options) => {
|
|
|
34
34
|
}
|
|
35
35
|
const conversation = options.conversation ?? conversationFor(exec.purpose);
|
|
36
36
|
const prompts = options.prompts ?? exec.prompts;
|
|
37
|
-
const provider = options.provider ?? pluginFor(agentModel);
|
|
37
|
+
const provider = options.provider ?? llmPluginRegistry.pluginFor(agentModel);
|
|
38
38
|
const purpose = exec.purpose;
|
|
39
39
|
const registry = [];
|
|
40
40
|
const ordered = () => [...registry].sort((a, b) => (a.order ?? DEFAULT_PLUGIN_ORDER) - (b.order ?? DEFAULT_PLUGIN_ORDER));
|
|
@@ -124,7 +124,7 @@ export const makeAgentModel = (options) => {
|
|
|
124
124
|
});
|
|
125
125
|
// A rejected task aborts the whole superstep, killing every sibling call in the same batch —
|
|
126
126
|
// `safeInvokeTool` is what keeps a bad argument from costing the work the others finished.
|
|
127
|
-
const call = task('call-tool', async (toolCall) => safeInvokeTool(toolSet, toolCall, options.fatal));
|
|
127
|
+
const call = task('call-tool', async (toolCall) => toolHelper.safeInvokeTool(toolSet, toolCall, options.fatal));
|
|
128
128
|
const agent = entrypoint(entrypointName, async (messages) => {
|
|
129
129
|
let response = await ask(messages);
|
|
130
130
|
let turn = 0;
|
package/build/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAE9F,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,MA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|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pipeline/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pipeline/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,mBAAmB,mBAAmB,CAAA;AACtC,mBAAmB,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { CumulativeResultEntry, CumulativeResultFact, PipelineSpec, PipelineState, ResultFactQuery, ResultViewMode, CumulativeResultsSpec, ResultSummarySpec } from '@owlmeans/agent-common';
|
|
2
|
+
import type { CumulativeResults } from '@owlmeans/llm-common';
|
|
3
|
+
import type { CumulativeResultStore } from '../../stores/types.js';
|
|
4
|
+
import type { PipelineEnterMode, PipelineParentRef } from '../runner/types.js';
|
|
5
|
+
/** What a step tells the results plugin about itself. Every call adds to the last. */
|
|
6
|
+
export interface ResultRecordInput {
|
|
7
|
+
/** Files the step wrote or rewrote, relative to the project root. */
|
|
8
|
+
files?: string[];
|
|
9
|
+
/** Facts the step already knows. Taken as they are, ahead of anything an extractor finds. */
|
|
10
|
+
facts?: CumulativeResultFact[];
|
|
11
|
+
}
|
|
12
|
+
/** One entry a step can see, and how its view shows it. */
|
|
13
|
+
export interface VisibleResultEntry {
|
|
14
|
+
entry: CumulativeResultEntry;
|
|
15
|
+
mode: ResultViewMode;
|
|
16
|
+
/** Left out of the prompt for BUDGET — named in `view.omitted` — rather than by declaration. */
|
|
17
|
+
dropped?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The results surface of ONE step: the view to put in its prompt, a query over the facts behind
|
|
21
|
+
* that view for code that wants them, and the way to report what the step produced.
|
|
22
|
+
*/
|
|
23
|
+
export interface StepResults {
|
|
24
|
+
/** The ledger the step's entries belong to. */
|
|
25
|
+
ledger: string;
|
|
26
|
+
/** Where the step sits in the ledger — the order key a run composed under it extends. */
|
|
27
|
+
order: readonly number[];
|
|
28
|
+
/** Serializable and frozen; `ExecutionService.withResults(exec, results.view)`. */
|
|
29
|
+
view: CumulativeResults;
|
|
30
|
+
/** Every entry visible to the step, oldest first, with how the view shows it. */
|
|
31
|
+
entries: () => readonly VisibleResultEntry[];
|
|
32
|
+
/**
|
|
33
|
+
* Facts visible to the step, narrowed by kind, name and producing step — including those the
|
|
34
|
+
* PROMPT left out for space or by declaration: a budget is about what a model reads, and code
|
|
35
|
+
* asking for a fact is not a model reading a prompt.
|
|
36
|
+
*/
|
|
37
|
+
facts: (query?: ResultFactQuery) => CumulativeResultFact[];
|
|
38
|
+
/** Report files touched and facts known. Read once, when the step finishes. */
|
|
39
|
+
record: (input: ResultRecordInput) => void;
|
|
40
|
+
}
|
|
41
|
+
/** What a declaration resolver, a seed and a ledger resolver are told about the run. */
|
|
42
|
+
export interface ResultsRunInfo<S extends PipelineState, C> {
|
|
43
|
+
pipeline: string;
|
|
44
|
+
spec: PipelineSpec;
|
|
45
|
+
runId: string;
|
|
46
|
+
scope: string;
|
|
47
|
+
entityId?: string;
|
|
48
|
+
deps: C;
|
|
49
|
+
state: Readonly<S>;
|
|
50
|
+
mode: PipelineEnterMode;
|
|
51
|
+
parent?: PipelineParentRef;
|
|
52
|
+
}
|
|
53
|
+
/** What an extractor reads facts from. */
|
|
54
|
+
export interface ResultExtractInput<S extends PipelineState, C> {
|
|
55
|
+
pipeline: string;
|
|
56
|
+
runId: string;
|
|
57
|
+
step: string;
|
|
58
|
+
/** Durable: the run's state, restored from its row on a resume. */
|
|
59
|
+
state: Readonly<S>;
|
|
60
|
+
deps: C;
|
|
61
|
+
/** Every file the entry answers for — its durable scope and whatever its step recorded. */
|
|
62
|
+
files: readonly string[];
|
|
63
|
+
/** What was recorded as touched on THIS pass — empty on a rebuild. */
|
|
64
|
+
changed: readonly string[];
|
|
65
|
+
}
|
|
66
|
+
export interface ResultScopeInput<S extends PipelineState, C> extends Omit<ResultExtractInput<S, C>, 'files' | 'changed'> {
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Facts from files. DETERMINISTIC — the same inputs give the same facts — and never a model
|
|
70
|
+
* call: an extractor is what makes a fact a fact, and a rebuild after a crash must find exactly
|
|
71
|
+
* what the first pass found.
|
|
72
|
+
*/
|
|
73
|
+
export interface ResultExtractFn<S extends PipelineState, C> {
|
|
74
|
+
(input: ResultExtractInput<S, C>): Promise<CumulativeResultFact[]> | CumulativeResultFact[];
|
|
75
|
+
}
|
|
76
|
+
export interface ResultExtractorSpec<S extends PipelineState, C> {
|
|
77
|
+
/**
|
|
78
|
+
* The files this extractor answers for, recomputed from DURABLE inputs — the state's keys, the
|
|
79
|
+
* file tree — and never from what a step happened to report. It is what a rebuild reads when
|
|
80
|
+
* nothing was recorded, so a step's facts can be found again after the process that ran it died.
|
|
81
|
+
*/
|
|
82
|
+
scope?: (input: ResultScopeInput<S, C>) => Promise<string[]> | string[];
|
|
83
|
+
extract: ResultExtractFn<S, C>;
|
|
84
|
+
}
|
|
85
|
+
export type ResultExtractor<S extends PipelineState, C> = ResultExtractFn<S, C> | ResultExtractorSpec<S, C>;
|
|
86
|
+
/** Facts known before any step of the run ran. Called on every entry of the run; deterministic. */
|
|
87
|
+
export interface ResultSeed<S extends PipelineState, C> {
|
|
88
|
+
(run: ResultsRunInfo<S, C>): Promise<CumulativeResultFact[]> | CumulativeResultFact[];
|
|
89
|
+
}
|
|
90
|
+
/** Everything a summarize callback needs, including a ready prompt. */
|
|
91
|
+
export interface ResultSummaryRequest<S extends PipelineState, C> extends ResultSummarySpec {
|
|
92
|
+
schema: Record<string, unknown>;
|
|
93
|
+
maxChars: number;
|
|
94
|
+
pipeline: string;
|
|
95
|
+
runId: string;
|
|
96
|
+
step: string;
|
|
97
|
+
label: string;
|
|
98
|
+
facts: readonly CumulativeResultFact[];
|
|
99
|
+
files: readonly string[];
|
|
100
|
+
state: Readonly<S>;
|
|
101
|
+
deps: C;
|
|
102
|
+
signal: AbortSignal;
|
|
103
|
+
/** The instructions, the step's facts and its files, as one deterministic prompt. */
|
|
104
|
+
prompt: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Ask a model for a step's summary; return its schema-shaped answer.
|
|
108
|
+
*
|
|
109
|
+
* Typically `request => model.invoke(request.prompt, request.schema, { action })` on a model
|
|
110
|
+
* resolved for `request.role`. A throw is a warning and the entry goes without a summary.
|
|
111
|
+
*/
|
|
112
|
+
export interface ResultSummarizer<S extends PipelineState, C> {
|
|
113
|
+
(request: ResultSummaryRequest<S, C>): Promise<unknown>;
|
|
114
|
+
}
|
|
115
|
+
export interface CumulativeResultsPluginOptions<S extends PipelineState, C> {
|
|
116
|
+
alias?: string;
|
|
117
|
+
order?: number;
|
|
118
|
+
/**
|
|
119
|
+
* The declaration, or a function of the run that returns one — or `null`/`false` to leave THIS
|
|
120
|
+
* run without results. Resolved once, on `enter`.
|
|
121
|
+
*/
|
|
122
|
+
spec: CumulativeResultsSpec | ((run: ResultsRunInfo<S, C>) => CumulativeResultsSpec | null | false | undefined | Promise<CumulativeResultsSpec | null | false | undefined>);
|
|
123
|
+
/** Named deterministic extractors, referenced by name from `StepResultsSpec.extractors`. */
|
|
124
|
+
extractors?: Record<string, ResultExtractor<S, C>>;
|
|
125
|
+
/** Named facts available before any step ran. Visible to every step, in name order. */
|
|
126
|
+
seeds?: Record<string, ResultSeed<S, C>>;
|
|
127
|
+
/**
|
|
128
|
+
* Where entries live. A composed pipeline must be given the SAME store as the pipeline it is a
|
|
129
|
+
* step of, or neither sees what the other produced. Default: an in-process memory store of this
|
|
130
|
+
* plugin instance.
|
|
131
|
+
*/
|
|
132
|
+
store?: CumulativeResultStore;
|
|
133
|
+
/** Called only for a step whose declaration has a `summary`. */
|
|
134
|
+
summarize?: ResultSummarizer<S, C>;
|
|
135
|
+
/** The ledger a run's entries belong to. Default: the parent's, else the root run's id. */
|
|
136
|
+
ledger?: (run: ResultsRunInfo<S, C>) => string;
|
|
137
|
+
trace?: (line: string) => void;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/pipeline/results/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AACjM,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAE9E,sFAAsF;AACtF,MAAM,WAAW,iBAAiB;IAChC,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,6FAA6F;IAC7F,KAAK,CAAC,EAAE,oBAAoB,EAAE,CAAA;CAC/B;AAED,2DAA2D;AAC3D,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,qBAAqB,CAAA;IAC5B,IAAI,EAAE,cAAc,CAAA;IACpB,gGAAgG;IAChG,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAA;IACd,yFAAyF;IACzF,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;IACxB,mFAAmF;IACnF,IAAI,EAAE,iBAAiB,CAAA;IACvB,iFAAiF;IACjF,OAAO,EAAE,MAAM,SAAS,kBAAkB,EAAE,CAAA;IAC5C;;;;OAIG;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],"names":[],"mappings":""}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type CumulativeResultEntry, type CumulativeResultFact, type CumulativeResultsSpec, type PipelineSpec, type StepResultsSpec, CumulativeResultSource, ResultViewMode } from '@owlmeans/agent-common';
|
|
2
2
|
import type { StepResults, VisibleResultEntry } from './types.js';
|
|
3
|
-
import type { BaseCheckpointSaver } from '@langchain/langgraph';
|
|
4
3
|
export interface Recorded {
|
|
5
4
|
files: Set<string>;
|
|
6
5
|
facts: CumulativeResultFact[];
|
|
@@ -35,21 +34,4 @@ export interface EntryParts {
|
|
|
35
34
|
partial?: boolean;
|
|
36
35
|
summary?: string;
|
|
37
36
|
}
|
|
38
|
-
/**
|
|
39
|
-
* The graph builder, seen loosely.
|
|
40
|
-
*
|
|
41
|
-
* `StateGraph`'s node names are a generic parameter that only a literal-typed builder chain can
|
|
42
|
-
* satisfy, and a pipeline's nodes come from data. The precision belongs at THIS package's public
|
|
43
|
-
* boundary — `PipelineSpec`, `PipelineStep`, `PipelineModel` are all exact — not in the three lines
|
|
44
|
-
* that hand LangGraph a name it will look up in a map either way.
|
|
45
|
-
*/
|
|
46
|
-
export interface LooseGraph {
|
|
47
|
-
addNode: (name: string, fn: (state: unknown) => Promise<Record<string, unknown>>, options?: Record<string, unknown>) => LooseGraph;
|
|
48
|
-
addEdge: (start: string | string[], end: string) => LooseGraph;
|
|
49
|
-
compile: (options?: {
|
|
50
|
-
checkpointer?: BaseCheckpointSaver;
|
|
51
|
-
}) => {
|
|
52
|
-
invoke: (input: unknown, config?: Record<string, unknown>) => Promise<unknown>;
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
37
|
//# sourceMappingURL=types.local.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.local.d.ts","sourceRoot":"","sources":["../../../src/pipeline/results/types.local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,KAAK,q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CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.local.js","sourceRoot":"","sources":["../../../src/pipeline/results/types.local.ts"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type PipelineState } from '@owlmeans/agent-common';
|
|
2
|
-
import type { PipelinePlugin
|
|
2
|
+
import type { PipelinePlugin } from './runner/types.js';
|
|
3
|
+
import type { CumulativeResultsPluginOptions } from './results/types.js';
|
|
3
4
|
/**
|
|
4
5
|
* CUMULATIVE PIPELINE RESULTS: every step is told, in its prompt and through a typed query, what
|
|
5
6
|
* the steps before it produced — read from the files by code, not recalled by a model.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../../src/pipeline/results.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../../src/pipeline/results.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsP,KAAK,aAAa,EAAgD,MAAM,wBAAwB,CAAA;AAK7V,OAAO,KAAK,EAAE,cAAc,EAAsB,MAAM,mBAAmB,CAAA;AAC3E,OAAO,KAAK,EAAmC,8BAA8B,EAAoD,MAAM,oBAAoB,CAAA;AAwE3J;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAAS,aAAa,EAAE,CAAC,WACvD,8BAA8B,CAAC,CAAC,EAAE,CAAC,CAAC,KAC5C,cAAc,CAAC,CAAC,EAAE,CAAC,CA0iBrB,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CumulativeResultSource, DEFAULT_RESULT_SUMMARY_CHARS, DEFAULT_RESULTS_MAX_CHARS, DEFAULT_RESULTS_WINDOW, RESULTS_EVERY_STEP, ResultViewMode,
|
|
2
|
-
import {
|
|
1
|
+
import { CumulativeResultSource, DEFAULT_RESULT_SUMMARY_CHARS, DEFAULT_RESULTS_MAX_CHARS, DEFAULT_RESULTS_WINDOW, RESULTS_EVERY_STEP, ResultViewMode, cumulativeResultsHelper, makePipelineSpecModel } from '@owlmeans/agent-common';
|
|
2
|
+
import { promptRenderHelper } from '@owlmeans/llm';
|
|
3
3
|
import { logger } from '@owlmeans/log';
|
|
4
4
|
import { createMemoryCumulativeResultStore } from '../stores/memory.js';
|
|
5
5
|
import { SEPARATOR } from './consts.local.js';
|
|
@@ -14,7 +14,7 @@ const pathsOf = (facts) => facts.flatMap(fact => fact.path != null && fact.path
|
|
|
14
14
|
const dedupe = (facts) => {
|
|
15
15
|
const seen = new Set();
|
|
16
16
|
return facts.filter(fact => {
|
|
17
|
-
const key = factKey(fact);
|
|
17
|
+
const key = cumulativeResultsHelper.factKey(fact);
|
|
18
18
|
if (seen.has(key)) {
|
|
19
19
|
return false;
|
|
20
20
|
}
|
|
@@ -46,7 +46,7 @@ const summaryPrompt = (spec, label, facts, files, maxChars) => [
|
|
|
46
46
|
`The step "${label}" has just finished. For the later steps of the same work, summarize what it `
|
|
47
47
|
+ 'decided or produced that the facts below do not already say. Do not repeat the facts and do not '
|
|
48
48
|
+ `guess at anything not shown. At most ${maxChars} characters.`,
|
|
49
|
-
`# Facts read from the files after the step finished\n${facts.map(renderResultFact).join('\n') || '(none)'}`,
|
|
49
|
+
`# Facts read from the files after the step finished\n${facts.map(cumulativeResultsHelper.renderResultFact).join('\n') || '(none)'}`,
|
|
50
50
|
`# Files the step answers for\n${files.map(file => `- ${file}`).join('\n') || '(none)'}`,
|
|
51
51
|
].join(SEPARATOR);
|
|
52
52
|
/**
|
|
@@ -148,7 +148,7 @@ export const cumulativeResultsPlugin = (options) => {
|
|
|
148
148
|
* necessarily run, so what it says cannot be what a step relies on.
|
|
149
149
|
*/
|
|
150
150
|
const visibleTo = (run, step) => {
|
|
151
|
-
const depths = new Map(
|
|
151
|
+
const depths = new Map(makePipelineSpecModel(run.spec).ancestry(step).map(({ step: name, depth }) => [name, depth]));
|
|
152
152
|
const items = [
|
|
153
153
|
...run.upstream.map(visible => ({
|
|
154
154
|
entry: visible.entry, mode: visible.mode, explicit: false, dropped: visible.dropped === true,
|
|
@@ -162,7 +162,7 @@ export const cumulativeResultsPlugin = (options) => {
|
|
|
162
162
|
items.push({ entry, ...modeFor(run, entry, step, depth), dropped: false });
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
return items.sort((a, b) => compareResultOrder(a.entry.order, b.entry.order) || compare(a.entry.label, b.entry.label));
|
|
165
|
+
return items.sort((a, b) => cumulativeResultsHelper.compareResultOrder(a.entry.order, b.entry.order) || compare(a.entry.label, b.entry.label));
|
|
166
166
|
};
|
|
167
167
|
const textOf = (item) => item.mode === ResultViewMode.Full
|
|
168
168
|
? item.entry.full
|
|
@@ -204,11 +204,11 @@ export const cumulativeResultsPlugin = (options) => {
|
|
|
204
204
|
.map(item => item.entry.label);
|
|
205
205
|
const joined = sections.map(section => section.text).join(SEPARATOR);
|
|
206
206
|
const view = Object.freeze({
|
|
207
|
-
step: resultLabel(run.ledger, run.runId, step),
|
|
207
|
+
step: cumulativeResultsHelper.resultLabel(run.ledger, run.runId, step),
|
|
208
208
|
sections: Object.freeze(sections),
|
|
209
209
|
omitted: Object.freeze(omitted),
|
|
210
210
|
chars: joined.length,
|
|
211
|
-
digest: prefixHash(`${joined}\u0000${omitted.join('\u0000')}`),
|
|
211
|
+
digest: promptRenderHelper.prefixHash(`${joined}\u0000${omitted.join('\u0000')}`),
|
|
212
212
|
});
|
|
213
213
|
const visible = Object.freeze(items.map(item => Object.freeze({
|
|
214
214
|
entry: item.entry, mode: item.mode, ...(item.dropped ? { dropped: true } : {}),
|
|
@@ -287,17 +287,17 @@ export const cumulativeResultsPlugin = (options) => {
|
|
|
287
287
|
const owned = new Set();
|
|
288
288
|
for (const item of visibleTo(run, step)) {
|
|
289
289
|
for (const fact of item.entry.facts) {
|
|
290
|
-
owned.add(factKey(fact));
|
|
290
|
+
owned.add(cumulativeResultsHelper.factKey(fact));
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
for (const entry of run.entries.values()) {
|
|
294
294
|
if (entry.runId.startsWith(`${run.runId}/${step}`) && anchorOf(run, entry) === step) {
|
|
295
295
|
for (const fact of entry.facts) {
|
|
296
|
-
owned.add(factKey(fact));
|
|
296
|
+
owned.add(cumulativeResultsHelper.factKey(fact));
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
|
-
return facts.filter(fact => !owned.has(factKey(fact)));
|
|
300
|
+
return facts.filter(fact => !owned.has(cumulativeResultsHelper.factKey(fact)));
|
|
301
301
|
};
|
|
302
302
|
/** A step's facts and files, from its durable scope, what it recorded, and its extractors. */
|
|
303
303
|
const collect = async (run, step, state, changed, recorded) => {
|
|
@@ -307,12 +307,12 @@ export const cumulativeResultsPlugin = (options) => {
|
|
|
307
307
|
};
|
|
308
308
|
const compose = (run, step, parts) => {
|
|
309
309
|
const previous = run.entries.get(keyOf(run.runId, step));
|
|
310
|
-
const label = resultLabel(run.ledger, run.runId, step);
|
|
310
|
+
const label = cumulativeResultsHelper.resultLabel(run.ledger, run.runId, step);
|
|
311
311
|
const source = parts.facts.length === 0 && parts.summary != null
|
|
312
312
|
? CumulativeResultSource.Summarized
|
|
313
313
|
: parts.source;
|
|
314
|
-
const facts = sortFacts(parts.facts);
|
|
315
|
-
const rendered = renderResultEntry({ label, source, facts, ...(parts.partial === true ? { partial: true } : {}), ...(parts.summary != null ? { summary: parts.summary } : {}) }, {
|
|
314
|
+
const facts = cumulativeResultsHelper.sortFacts(parts.facts);
|
|
315
|
+
const rendered = cumulativeResultsHelper.renderResultEntry({ label, source, facts, ...(parts.partial === true ? { partial: true } : {}), ...(parts.summary != null ? { summary: parts.summary } : {}) }, {
|
|
316
316
|
maxChars: parts.spec?.maxChars ?? run.results.maxEntryChars,
|
|
317
317
|
maxCompactChars: parts.spec?.maxCompactChars ?? run.results.maxCompactChars,
|
|
318
318
|
});
|
|
@@ -350,8 +350,8 @@ export const cumulativeResultsPlugin = (options) => {
|
|
|
350
350
|
const mine = orderOf(run, step);
|
|
351
351
|
const earlier = [...run.entries.values()]
|
|
352
352
|
.filter(entry => entry.runId === run.runId && entry.step !== step
|
|
353
|
-
&& compareResultOrder(entry.order, mine) < 0)
|
|
354
|
-
.sort((a, b) => compareResultOrder(a.order, b.order));
|
|
353
|
+
&& cumulativeResultsHelper.compareResultOrder(entry.order, mine) < 0)
|
|
354
|
+
.sort((a, b) => cumulativeResultsHelper.compareResultOrder(a.order, b.order));
|
|
355
355
|
for (const entry of earlier) {
|
|
356
356
|
const spec = run.results.steps?.[entry.step];
|
|
357
357
|
if (!hasExtractors(spec) || (spec?.refresh ?? run.results.refresh ?? true) === false) {
|
|
@@ -362,8 +362,8 @@ export const cumulativeResultsPlugin = (options) => {
|
|
|
362
362
|
continue;
|
|
363
363
|
}
|
|
364
364
|
const fresh = await extract(run, entry.step, state, entry.files, overlap);
|
|
365
|
-
const freshKeys = new Set(fresh.map(factKey));
|
|
366
|
-
const kept = entry.facts.filter(fact => !freshKeys.has(factKey(fact))
|
|
365
|
+
const freshKeys = new Set(fresh.map(cumulativeResultsHelper.factKey));
|
|
366
|
+
const kept = entry.facts.filter(fact => !freshKeys.has(cumulativeResultsHelper.factKey(fact))
|
|
367
367
|
&& (fact.path == null || !overlap.includes(normalizePath(fact.path))));
|
|
368
368
|
const facts = unowned(run, entry.step, dedupe([...fresh, ...kept]));
|
|
369
369
|
const refreshed = compose(run, entry.step, {
|
|
@@ -387,7 +387,7 @@ export const cumulativeResultsPlugin = (options) => {
|
|
|
387
387
|
return undefined;
|
|
388
388
|
}
|
|
389
389
|
const maxChars = spec.maxChars ?? DEFAULT_RESULT_SUMMARY_CHARS;
|
|
390
|
-
const label = resultLabel(run.ledger, run.runId, step);
|
|
390
|
+
const label = cumulativeResultsHelper.resultLabel(run.ledger, run.runId, step);
|
|
391
391
|
try {
|
|
392
392
|
const answer = await options.summarize({
|
|
393
393
|
...spec,
|
|
@@ -404,7 +404,7 @@ export const cumulativeResultsPlugin = (options) => {
|
|
|
404
404
|
signal: ctx.signal,
|
|
405
405
|
prompt: summaryPrompt(spec, label, facts, files, maxChars),
|
|
406
406
|
});
|
|
407
|
-
const text = renderResultSummary(answer, maxChars);
|
|
407
|
+
const text = cumulativeResultsHelper.renderResultSummary(answer, maxChars);
|
|
408
408
|
return text !== '' ? text : undefined;
|
|
409
409
|
}
|
|
410
410
|
catch (e) {
|
|
@@ -434,14 +434,14 @@ export const cumulativeResultsPlugin = (options) => {
|
|
|
434
434
|
return;
|
|
435
435
|
}
|
|
436
436
|
const parent = event.parent?.results;
|
|
437
|
-
const ledger = options.ledger?.(info) ?? parent?.ledger ?? rootRunOf(event.runId);
|
|
437
|
+
const ledger = options.ledger?.(info) ?? parent?.ledger ?? cumulativeResultsHelper.rootRunOf(event.runId);
|
|
438
438
|
const run = {
|
|
439
439
|
results: declared,
|
|
440
440
|
spec: event.spec,
|
|
441
441
|
runId: event.runId,
|
|
442
442
|
ledger,
|
|
443
443
|
trail: parent != null ? [...parent.order] : [],
|
|
444
|
-
index: new Map(
|
|
444
|
+
index: new Map(makePipelineSpecModel(event.spec).orderSteps().map((step, at) => [step, at + 1])),
|
|
445
445
|
entries: new Map(),
|
|
446
446
|
upstream: parent != null ? parent.entries() : [],
|
|
447
447
|
seeds: [],
|