@miller-tech/uap 1.30.1 → 1.32.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/README.md +25 -2
- package/dist/.tsbuildinfo +1 -1
- package/dist/bin/cli.js +7 -0
- package/dist/bin/cli.js.map +1 -1
- package/dist/cli/deliver.d.ts +28 -0
- package/dist/cli/deliver.d.ts.map +1 -1
- package/dist/cli/deliver.js +203 -9
- package/dist/cli/deliver.js.map +1 -1
- package/dist/coordination/deploy-batcher.d.ts.map +1 -1
- package/dist/coordination/deploy-batcher.js +9 -3
- package/dist/coordination/deploy-batcher.js.map +1 -1
- package/dist/delivery/applier.d.ts.map +1 -1
- package/dist/delivery/applier.js +4 -0
- package/dist/delivery/applier.js.map +1 -1
- package/dist/delivery/auto-optimizer.d.ts +43 -0
- package/dist/delivery/auto-optimizer.d.ts.map +1 -0
- package/dist/delivery/auto-optimizer.js +70 -0
- package/dist/delivery/auto-optimizer.js.map +1 -0
- package/dist/delivery/convergence-loop.d.ts +7 -0
- package/dist/delivery/convergence-loop.d.ts.map +1 -1
- package/dist/delivery/convergence-loop.js +42 -0
- package/dist/delivery/convergence-loop.js.map +1 -1
- package/dist/delivery/halo-trace.d.ts +29 -0
- package/dist/delivery/halo-trace.d.ts.map +1 -0
- package/dist/delivery/halo-trace.js +88 -0
- package/dist/delivery/halo-trace.js.map +1 -0
- package/dist/delivery/ideation.d.ts +36 -0
- package/dist/delivery/ideation.d.ts.map +1 -0
- package/dist/delivery/ideation.js +109 -0
- package/dist/delivery/ideation.js.map +1 -0
- package/dist/delivery/index.d.ts +5 -1
- package/dist/delivery/index.d.ts.map +1 -1
- package/dist/delivery/index.js +5 -1
- package/dist/delivery/index.js.map +1 -1
- package/dist/delivery/run-coordinator.d.ts +48 -0
- package/dist/delivery/run-coordinator.d.ts.map +1 -0
- package/dist/delivery/run-coordinator.js +132 -0
- package/dist/delivery/run-coordinator.js.map +1 -0
- package/dist/memory/dynamic-retrieval.d.ts +8 -7
- package/dist/memory/dynamic-retrieval.d.ts.map +1 -1
- package/dist/memory/dynamic-retrieval.js +8 -52
- package/dist/memory/dynamic-retrieval.js.map +1 -1
- package/dist/utils/query-complexity.d.ts +25 -0
- package/dist/utils/query-complexity.d.ts.map +1 -0
- package/dist/utils/query-complexity.js +68 -0
- package/dist/utils/query-complexity.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HALO Delivery Tracer — observability for the convergence loop
|
|
3
|
+
*
|
|
4
|
+
* Emits delivery runs as HALO/OpenInference spans so `uap harness analyze`
|
|
5
|
+
* can mine systemic failure modes across runs (which gates dominate, where
|
|
6
|
+
* turns stall, which strategies win). One AGENT span per run, one CHAIN span
|
|
7
|
+
* per turn, parented to the run.
|
|
8
|
+
*
|
|
9
|
+
* Inherits the exporter's guarantees: zero overhead when tracing is disabled
|
|
10
|
+
* and never throws into the loop.
|
|
11
|
+
*/
|
|
12
|
+
import { isHaloTracingEnabled, newSpanId, recordHaloSpan, } from '../observability/halo-exporter.js';
|
|
13
|
+
const MAX_ERROR_CHARS = 1_000;
|
|
14
|
+
/**
|
|
15
|
+
* Error strings can embed model-controlled text (rejected file-block paths,
|
|
16
|
+
* HTTP payloads). Strip control characters and cap length before persisting
|
|
17
|
+
* to the trace file — `uap harness analyze` replays these into an LLM, so
|
|
18
|
+
* they must be treated as untrusted data, never as raw instructions.
|
|
19
|
+
*/
|
|
20
|
+
function sanitizeError(text) {
|
|
21
|
+
/* eslint-disable no-control-regex */
|
|
22
|
+
return text
|
|
23
|
+
.replace(/\x1b\[[0-9;]*[A-Za-z]/g, '')
|
|
24
|
+
.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f]/g, '')
|
|
25
|
+
.slice(0, MAX_ERROR_CHARS);
|
|
26
|
+
/* eslint-enable no-control-regex */
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create a tracer for a single delivery run. All emission is gated on
|
|
30
|
+
* isHaloTracingEnabled(), so constructing one unconditionally is free.
|
|
31
|
+
*/
|
|
32
|
+
export function createHaloDeliveryTracer(options) {
|
|
33
|
+
const runSpanId = newSpanId();
|
|
34
|
+
const runStart = Date.now();
|
|
35
|
+
return {
|
|
36
|
+
onIteration(record) {
|
|
37
|
+
if (!isHaloTracingEnabled())
|
|
38
|
+
return;
|
|
39
|
+
const end = Date.now();
|
|
40
|
+
recordHaloSpan({
|
|
41
|
+
kind: 'CHAIN',
|
|
42
|
+
name: `delivery.turn.${record.turn}`,
|
|
43
|
+
startTimeMs: end - record.durationMs,
|
|
44
|
+
endTimeMs: end,
|
|
45
|
+
ok: record.passed,
|
|
46
|
+
parentSpanId: runSpanId,
|
|
47
|
+
attributes: {
|
|
48
|
+
'delivery.turn': record.turn,
|
|
49
|
+
'delivery.score': record.score,
|
|
50
|
+
'delivery.files_applied': record.filesApplied.length,
|
|
51
|
+
...(record.strategy ? { 'delivery.strategy': record.strategy } : {}),
|
|
52
|
+
...(record.candidates ? { 'delivery.candidates': record.candidates.length } : {}),
|
|
53
|
+
...(record.executorError
|
|
54
|
+
? { 'delivery.executor_error': sanitizeError(record.executorError) }
|
|
55
|
+
: {}),
|
|
56
|
+
...(record.applyError ? { 'delivery.apply_error': sanitizeError(record.applyError) } : {}),
|
|
57
|
+
'delivery.gates_failed': record.gateResults
|
|
58
|
+
.filter((g) => !g.passed && !g.skipped)
|
|
59
|
+
.map((g) => g.id)
|
|
60
|
+
.join(','),
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
finish(result) {
|
|
65
|
+
if (!isHaloTracingEnabled())
|
|
66
|
+
return;
|
|
67
|
+
recordHaloSpan({
|
|
68
|
+
kind: 'AGENT',
|
|
69
|
+
name: 'agent.deliver',
|
|
70
|
+
startTimeMs: runStart,
|
|
71
|
+
endTimeMs: Date.now(),
|
|
72
|
+
ok: result.success,
|
|
73
|
+
spanId: runSpanId,
|
|
74
|
+
attributes: {
|
|
75
|
+
'agent.name': 'deliver',
|
|
76
|
+
'delivery.instruction': options.instruction.slice(0, 500),
|
|
77
|
+
'delivery.model': options.modelId,
|
|
78
|
+
'delivery.project_root': options.projectRoot,
|
|
79
|
+
'delivery.turns': result.turns,
|
|
80
|
+
'delivery.best_score': result.bestScore,
|
|
81
|
+
'delivery.best_turn': result.bestTurn,
|
|
82
|
+
'delivery.already_delivered': result.alreadyDelivered,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=halo-trace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"halo-trace.js","sourceRoot":"","sources":["../../src/delivery/halo-trace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,oBAAoB,EACpB,SAAS,EACT,cAAc,GACf,MAAM,mCAAmC,CAAC;AAgB3C,MAAM,eAAe,GAAG,KAAK,CAAC;AAE9B;;;;;GAKG;AACH,SAAS,aAAa,CAAC,IAAY;IACjC,qCAAqC;IACrC,OAAO,IAAI;SACR,OAAO,CAAC,wBAAwB,EAAE,EAAE,CAAC;SACrC,OAAO,CAAC,+BAA+B,EAAE,EAAE,CAAC;SAC5C,KAAK,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC;IAC7B,oCAAoC;AACtC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAkC;IACzE,MAAM,SAAS,GAAG,SAAS,EAAE,CAAC;IAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE5B,OAAO;QACL,WAAW,CAAC,MAAuB;YACjC,IAAI,CAAC,oBAAoB,EAAE;gBAAE,OAAO;YACpC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACvB,cAAc,CAAC;gBACb,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,iBAAiB,MAAM,CA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YACpC,cAAc,CAAC;gBACb,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,eAAe;gBACrB,WAAW,EAAE,QAAQ;gBACrB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;gBACrB,EAAE,EAAE,MAAM,CAAC,OAAO;gBAClB,MAAM,EAAE,SAAS;gBACjB,UAAU,EAAE;oBACV,YAAY,EAAE,SAAS;oBACvB,sBAAsB,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC;oBACzD,gBAAgB,EAAE,OAAO,CAAC,OAAO;oBACjC,uBAAuB,EAAE,OAAO,CAAC,WAAW;oBAC5C,gBAAgB,EAAE,MAAM,CAAC,KAAK;oBAC9B,qBAAqB,EAAE,MAAM,CAAC,SAAS;oBACvC,oBAAoB,EAAE,MAAM,CAAC,QAAQ;oBACrC,4BAA4B,EAAE,MAAM,CAAC,gBAAgB;iBACtD;aACF,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ideation Seeder — divergent strategy seeds for exploration (open-collider)
|
|
3
|
+
*
|
|
4
|
+
* Connects `uap ideate` divergent ideation to the delivery loop. Instead of
|
|
5
|
+
* the four static DEFAULT_STRATEGY_SEEDS, the seeder produces task-specific,
|
|
6
|
+
* deliberately diverse strategy hints for the best-of-N explorer:
|
|
7
|
+
*
|
|
8
|
+
* - generateStrategySeeds: one Koestler-bisociation-style model call that
|
|
9
|
+
* asks for N structurally distinct implementation approaches
|
|
10
|
+
* - seedsFromIdeas: convert curated ideas (e.g. an open-collider project's
|
|
11
|
+
* curated_ideas.json) into strategy seeds directly
|
|
12
|
+
*
|
|
13
|
+
* Both are fail-soft: any parse/model failure falls back to the default
|
|
14
|
+
* static seeds so ideation can never block delivery.
|
|
15
|
+
*/
|
|
16
|
+
import type { LoopExecutor } from './convergence-loop.js';
|
|
17
|
+
import type { StrategySeed } from './explorer.js';
|
|
18
|
+
export interface IdeationOptions {
|
|
19
|
+
/** Number of seeds to request (default 4, capped at MAX_CANDIDATES) */
|
|
20
|
+
count?: number;
|
|
21
|
+
}
|
|
22
|
+
/** Extract the first JSON array of {id, hint} objects from model output. */
|
|
23
|
+
export declare function parseSeedArray(text: string): StrategySeed[];
|
|
24
|
+
/**
|
|
25
|
+
* Generate task-specific divergent strategy seeds via one model call.
|
|
26
|
+
* Falls back to DEFAULT_STRATEGY_SEEDS on any failure — ideation is an
|
|
27
|
+
* outcome optimizer, never a blocker.
|
|
28
|
+
*/
|
|
29
|
+
export declare function generateStrategySeeds(instruction: string, executor: LoopExecutor, options?: IdeationOptions): Promise<StrategySeed[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Convert curated ideas (plain strings, e.g. from an open-collider project's
|
|
32
|
+
* curated_ideas.json via `uap ideate ideas`) into explorer strategy seeds.
|
|
33
|
+
* Returns [] when no usable ideas are provided so callers can fall back.
|
|
34
|
+
*/
|
|
35
|
+
export declare function seedsFromIdeas(ideas: string[], options?: IdeationOptions): StrategySeed[];
|
|
36
|
+
//# sourceMappingURL=ideation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ideation.d.ts","sourceRoot":"","sources":["../../src/delivery/ideation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGlD,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAqBD,4EAA4E;AAC5E,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,EAAE,CA6B3D;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,YAAY,EACtB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,YAAY,EAAE,CAAC,CAYzB;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,eAAoB,GAAG,YAAY,EAAE,CAY7F"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ideation Seeder — divergent strategy seeds for exploration (open-collider)
|
|
3
|
+
*
|
|
4
|
+
* Connects `uap ideate` divergent ideation to the delivery loop. Instead of
|
|
5
|
+
* the four static DEFAULT_STRATEGY_SEEDS, the seeder produces task-specific,
|
|
6
|
+
* deliberately diverse strategy hints for the best-of-N explorer:
|
|
7
|
+
*
|
|
8
|
+
* - generateStrategySeeds: one Koestler-bisociation-style model call that
|
|
9
|
+
* asks for N structurally distinct implementation approaches
|
|
10
|
+
* - seedsFromIdeas: convert curated ideas (e.g. an open-collider project's
|
|
11
|
+
* curated_ideas.json) into strategy seeds directly
|
|
12
|
+
*
|
|
13
|
+
* Both are fail-soft: any parse/model failure falls back to the default
|
|
14
|
+
* static seeds so ideation can never block delivery.
|
|
15
|
+
*/
|
|
16
|
+
import { DEFAULT_STRATEGY_SEEDS, MAX_CANDIDATES } from './explorer.js';
|
|
17
|
+
const DEFAULT_SEED_COUNT = 4;
|
|
18
|
+
const MAX_HINT_CHARS = 400;
|
|
19
|
+
function buildIdeationPrompt(instruction, count) {
|
|
20
|
+
return [
|
|
21
|
+
'You are a divergent-ideation engine (Koestler bisociation). For the task',
|
|
22
|
+
'below, propose structurally DISTINCT implementation strategies — each one',
|
|
23
|
+
'must approach the problem from a different region of solution space.',
|
|
24
|
+
'Avoid minor variations of the same obvious approach; collide the task',
|
|
25
|
+
'with distant framings (data-flow first, contract first, smallest diff,',
|
|
26
|
+
'rewrite from scratch, defensive edge-case first, etc.).',
|
|
27
|
+
'',
|
|
28
|
+
`TASK: ${instruction}`,
|
|
29
|
+
'',
|
|
30
|
+
`Respond with ONLY a JSON array of exactly ${count} objects:`,
|
|
31
|
+
'[{"id": "<kebab-case-slug>", "hint": "STRATEGY: <one or two imperative sentences>"}]',
|
|
32
|
+
].join('\n');
|
|
33
|
+
}
|
|
34
|
+
/** Extract the first JSON array of {id, hint} objects from model output. */
|
|
35
|
+
export function parseSeedArray(text) {
|
|
36
|
+
// Anchor on an array of objects so brackets in surrounding prose
|
|
37
|
+
// ("[done]", markdown links) can't corrupt the slice; try the lazy match
|
|
38
|
+
// first, then the greedy one for arrays whose objects contain ']'.
|
|
39
|
+
let parsed;
|
|
40
|
+
for (const re of [/\[\s*\{[\s\S]*?\}\s*\]/, /\[\s*\{[\s\S]*\}\s*\]/]) {
|
|
41
|
+
const match = text.match(re);
|
|
42
|
+
if (!match)
|
|
43
|
+
continue;
|
|
44
|
+
try {
|
|
45
|
+
parsed = JSON.parse(match[0]);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
parsed = undefined;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (!Array.isArray(parsed))
|
|
53
|
+
return [];
|
|
54
|
+
const seen = new Set();
|
|
55
|
+
const seeds = [];
|
|
56
|
+
for (const entry of parsed) {
|
|
57
|
+
if (typeof entry !== 'object' || entry === null)
|
|
58
|
+
continue;
|
|
59
|
+
const { id, hint } = entry;
|
|
60
|
+
if (typeof id !== 'string' || typeof hint !== 'string')
|
|
61
|
+
continue;
|
|
62
|
+
const slug = id.trim().toLowerCase().replace(/[^a-z0-9-]+/g, '-').replace(/^-+|-+$/g, '');
|
|
63
|
+
if (!slug || !hint.trim() || seen.has(slug))
|
|
64
|
+
continue;
|
|
65
|
+
seen.add(slug);
|
|
66
|
+
seeds.push({ id: slug, hint: hint.trim().slice(0, MAX_HINT_CHARS) });
|
|
67
|
+
}
|
|
68
|
+
return seeds;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Generate task-specific divergent strategy seeds via one model call.
|
|
72
|
+
* Falls back to DEFAULT_STRATEGY_SEEDS on any failure — ideation is an
|
|
73
|
+
* outcome optimizer, never a blocker.
|
|
74
|
+
*/
|
|
75
|
+
export async function generateStrategySeeds(instruction, executor, options = {}) {
|
|
76
|
+
const count = Math.min(MAX_CANDIDATES, Math.max(2, options.count ?? DEFAULT_SEED_COUNT));
|
|
77
|
+
try {
|
|
78
|
+
const raw = await executor(buildIdeationPrompt(instruction, count));
|
|
79
|
+
const seeds = parseSeedArray(raw);
|
|
80
|
+
// Require at least two usable seeds — one seed defeats the purpose of
|
|
81
|
+
// divergent exploration and signals a degenerate model response.
|
|
82
|
+
if (seeds.length >= 2)
|
|
83
|
+
return seeds.slice(0, count);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
// fall through to defaults
|
|
87
|
+
}
|
|
88
|
+
return DEFAULT_STRATEGY_SEEDS;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Convert curated ideas (plain strings, e.g. from an open-collider project's
|
|
92
|
+
* curated_ideas.json via `uap ideate ideas`) into explorer strategy seeds.
|
|
93
|
+
* Returns [] when no usable ideas are provided so callers can fall back.
|
|
94
|
+
*/
|
|
95
|
+
export function seedsFromIdeas(ideas, options = {}) {
|
|
96
|
+
const count = Math.min(MAX_CANDIDATES, Math.max(2, options.count ?? DEFAULT_SEED_COUNT));
|
|
97
|
+
const seeds = [];
|
|
98
|
+
for (let i = 0; i < ideas.length && seeds.length < count; i++) {
|
|
99
|
+
const idea = ideas[i]?.trim();
|
|
100
|
+
if (!idea)
|
|
101
|
+
continue;
|
|
102
|
+
seeds.push({
|
|
103
|
+
id: `idea-${seeds.length + 1}`,
|
|
104
|
+
hint: `STRATEGY: Apply this curated idea to the task — ${idea.slice(0, MAX_HINT_CHARS)}`,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return seeds.length >= 2 ? seeds : [];
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=ideation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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AK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACtD,CAAC;IAAC,MAAM,CAAC;QACP,2BAA2B;IAC7B,CAAC;IACD,OAAO,sBAAsB,CAAC;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAAe,EAAE,UAA2B,EAAE;IAC3E,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,IAAI,kBAAkB,CAAC,CAAC,CAAC;IACzF,MAAM,KAAK,GAAmB,EAAE,CAAC;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9D,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,IAAI;YAAE,SAAS;QACpB,KAAK,CAAC,IAAI,CAAC;YACT,EAAE,EAAE,QAAQ,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9B,IAAI,EAAE,mDAAmD,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,EAAE;SACzF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACxC,CAAC"}
|
package/dist/delivery/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* iterations against the project's real completion gates until delivery
|
|
6
6
|
* is achieved.
|
|
7
7
|
*/
|
|
8
|
-
export { ConvergenceLoop, defaultPromptBuilder, type CandidateSummary, type ConvergenceConfig, type DeliveryResult, type ExplorerSettings, type IterationDirective, type IterationRecord, type LoopExecutor, type LadderRunner, type OnIteration, type PracticeProvider, type PromptBuilder, type PromptContext, } from './convergence-loop.js';
|
|
8
|
+
export { ConvergenceLoop, composeIterationHooks, defaultPromptBuilder, type CandidateSummary, type ConvergenceConfig, type DeliveryResult, type ExplorerSettings, type IterationDirective, type IterationRecord, type LoopExecutor, type LadderRunner, type OnIteration, type PracticeProvider, type PromptBuilder, type PromptContext, } from './convergence-loop.js';
|
|
9
9
|
export { createEscalationController, defaultEscalationLadder, type DefaultLadderOptions, type EscalationConfig, type EscalationController, type EscalationTier, } from './escalation.js';
|
|
10
10
|
export { InMemoryPracticeStore, FilePracticeStore, extractKeywords, distillPractice, defaultPracticePath, retrievePracticesSemantic, type PracticeCard, type PracticeInput, type PracticeStore, type SemanticRetriever, type SemanticRetrieveOptions, } from './practice.js';
|
|
11
11
|
export { exploreAndCommit, DEFAULT_STRATEGY_SEEDS, MAX_CANDIDATES, type CandidateResult, type ExplorationResult, type ExplorerConfig, type StrategySeed, } from './explorer.js';
|
|
@@ -13,5 +13,9 @@ export { createModelJudge, extractJson, type Judge, type JudgeCandidate, type Ju
|
|
|
13
13
|
export { createModelCritic, parseFixList, type Critic, type Critique, type CritiqueInput, } from './critic.js';
|
|
14
14
|
export { detectRungs, runLadder, runRung, formatFeedback, type GateRung, type RungResult, type RungFailureReason, type LadderResult, type LadderOptions, } from './verifier-ladder.js';
|
|
15
15
|
export { applyFileBlocks, applyFileBlocksWithRollback, parseFileBlocks, type Applier, type ApplyResult, type FileBlock, type RevertibleApply, } from './applier.js';
|
|
16
|
+
export { planAutoOptimization, DELIVERY_COMPLEXITY_THRESHOLDS, type AutoPlan, type DeliveryComplexity, } from './auto-optimizer.js';
|
|
17
|
+
export { generateStrategySeeds, parseSeedArray, seedsFromIdeas, type IdeationOptions, } from './ideation.js';
|
|
18
|
+
export { createHaloDeliveryTracer, type HaloDeliveryTracer, type HaloDeliveryTracerOptions, } from './halo-trace.js';
|
|
19
|
+
export { createRunCoordinator, collectAppliedFiles, type RunCoordinator, type RunCoordinatorOptions, } from './run-coordinator.js';
|
|
16
20
|
export { OpenAICompatClient, type OpenAICompatClientOptions } from '../models/openai-compat-client.js';
|
|
17
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/delivery/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,cAAc,GACpB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,GAC7B,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,KAAK,KAAK,EACV,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,aAAa,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,cAAc,EACd,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,GACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,eAAe,EACf,2BAA2B,EAC3B,eAAe,EACf,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,mCAAmC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/delivery/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,cAAc,GACpB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,GAC7B,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,KAAK,KAAK,EACV,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,aAAa,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,cAAc,EACd,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,GACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,eAAe,EACf,2BAA2B,EAC3B,eAAe,EACf,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,oBAAoB,EACpB,8BAA8B,EAC9B,KAAK,QAAQ,EACb,KAAK,kBAAkB,GACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,wBAAwB,EACxB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,GAC/B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,qBAAqB,GAC3B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,mCAAmC,CAAC"}
|
package/dist/delivery/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* iterations against the project's real completion gates until delivery
|
|
6
6
|
* is achieved.
|
|
7
7
|
*/
|
|
8
|
-
export { ConvergenceLoop, defaultPromptBuilder, } from './convergence-loop.js';
|
|
8
|
+
export { ConvergenceLoop, composeIterationHooks, defaultPromptBuilder, } from './convergence-loop.js';
|
|
9
9
|
export { createEscalationController, defaultEscalationLadder, } from './escalation.js';
|
|
10
10
|
export { InMemoryPracticeStore, FilePracticeStore, extractKeywords, distillPractice, defaultPracticePath, retrievePracticesSemantic, } from './practice.js';
|
|
11
11
|
export { exploreAndCommit, DEFAULT_STRATEGY_SEEDS, MAX_CANDIDATES, } from './explorer.js';
|
|
@@ -13,5 +13,9 @@ export { createModelJudge, extractJson, } from './judge.js';
|
|
|
13
13
|
export { createModelCritic, parseFixList, } from './critic.js';
|
|
14
14
|
export { detectRungs, runLadder, runRung, formatFeedback, } from './verifier-ladder.js';
|
|
15
15
|
export { applyFileBlocks, applyFileBlocksWithRollback, parseFileBlocks, } from './applier.js';
|
|
16
|
+
export { planAutoOptimization, DELIVERY_COMPLEXITY_THRESHOLDS, } from './auto-optimizer.js';
|
|
17
|
+
export { generateStrategySeeds, parseSeedArray, seedsFromIdeas, } from './ideation.js';
|
|
18
|
+
export { createHaloDeliveryTracer, } from './halo-trace.js';
|
|
19
|
+
export { createRunCoordinator, collectAppliedFiles, } from './run-coordinator.js';
|
|
16
20
|
export { OpenAICompatClient } from '../models/openai-compat-client.js';
|
|
17
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/delivery/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,eAAe,EACf,oBAAoB,GAarB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,GAKxB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,yBAAyB,GAM1B,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL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AAc,GAEf,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,wBAAwB,GAGzB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GAGpB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,kBAAkB,EAAkC,MAAM,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delivery Run Coordinator — `uap agent` + `uap deploy` integration
|
|
3
|
+
*
|
|
4
|
+
* Makes a delivery run a first-class citizen of the multi-agent coordination
|
|
5
|
+
* layer:
|
|
6
|
+
*
|
|
7
|
+
* - registers an ephemeral agent for the run (visible in `uap agent status`)
|
|
8
|
+
* - announces work intent on the project root (overlap detection warns
|
|
9
|
+
* other agents — and this run — about concurrent edits)
|
|
10
|
+
* - heartbeats every loop turn so the run never shows as stale
|
|
11
|
+
* - marks work complete and deregisters when the loop finishes
|
|
12
|
+
* - on success, can queue a commit of the applied files into the deploy
|
|
13
|
+
* batcher (`uap deploy status` / `uap deploy flush`)
|
|
14
|
+
*
|
|
15
|
+
* Everything is fail-soft via lazy imports: a missing/locked coordination DB
|
|
16
|
+
* degrades to a no-op coordinator rather than blocking delivery.
|
|
17
|
+
*/
|
|
18
|
+
import type { DeliveryResult, IterationRecord } from './convergence-loop.js';
|
|
19
|
+
export interface RunCoordinator {
|
|
20
|
+
/** Agent id registered for this run; null when coordination is degraded. */
|
|
21
|
+
readonly agentId: string | null;
|
|
22
|
+
/** Overlap warnings returned by the work announcement (may be empty). */
|
|
23
|
+
readonly overlapWarnings: string[];
|
|
24
|
+
/** Heartbeat + status update per loop turn (wire into onIteration). */
|
|
25
|
+
onIteration(record: IterationRecord): void;
|
|
26
|
+
/** Complete the announced work and deregister the agent. */
|
|
27
|
+
finish(result: DeliveryResult): Promise<void>;
|
|
28
|
+
/** Queue a commit of the run's applied files into the deploy batcher. */
|
|
29
|
+
queueDeploy(result: DeliveryResult, message: string): Promise<number | null>;
|
|
30
|
+
}
|
|
31
|
+
export interface RunCoordinatorOptions {
|
|
32
|
+
instruction: string;
|
|
33
|
+
projectRoot: string;
|
|
34
|
+
modelId: string;
|
|
35
|
+
/** Estimated minutes for the announcement (default 15) */
|
|
36
|
+
estimatedMinutes?: number;
|
|
37
|
+
/** Coordination DB override (tests); defaults to the shared coordination DB */
|
|
38
|
+
dbPath?: string;
|
|
39
|
+
}
|
|
40
|
+
/** All files the loop applied across its iteration history, deduplicated. */
|
|
41
|
+
export declare function collectAppliedFiles(result: DeliveryResult): string[];
|
|
42
|
+
/**
|
|
43
|
+
* Register this delivery run with the coordination service and announce its
|
|
44
|
+
* work. Returns a no-op coordinator when the coordination layer is
|
|
45
|
+
* unavailable — delivery must never fail because coordination did.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createRunCoordinator(options: RunCoordinatorOptions): Promise<RunCoordinator>;
|
|
48
|
+
//# sourceMappingURL=run-coordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-coordinator.d.ts","sourceRoot":"","sources":["../../src/delivery/run-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7E,MAAM,WAAW,cAAc;IAC7B,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,yEAAyE;IACzE,QAAQ,CAAC,eAAe,EAAE,MAAM,EAAE,CAAC;IACnC,uEAAuE;IACvE,WAAW,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAAC;IAC3C,4DAA4D;IAC5D,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,yEAAyE;IACzE,WAAW,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC9E;AAED,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,0DAA0D;IAC1D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,+EAA+E;IAC/E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAUD,6EAA6E;AAC7E,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,EAAE,CAMpE;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,cAAc,CAAC,CA+FzB"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delivery Run Coordinator — `uap agent` + `uap deploy` integration
|
|
3
|
+
*
|
|
4
|
+
* Makes a delivery run a first-class citizen of the multi-agent coordination
|
|
5
|
+
* layer:
|
|
6
|
+
*
|
|
7
|
+
* - registers an ephemeral agent for the run (visible in `uap agent status`)
|
|
8
|
+
* - announces work intent on the project root (overlap detection warns
|
|
9
|
+
* other agents — and this run — about concurrent edits)
|
|
10
|
+
* - heartbeats every loop turn so the run never shows as stale
|
|
11
|
+
* - marks work complete and deregisters when the loop finishes
|
|
12
|
+
* - on success, can queue a commit of the applied files into the deploy
|
|
13
|
+
* batcher (`uap deploy status` / `uap deploy flush`)
|
|
14
|
+
*
|
|
15
|
+
* Everything is fail-soft via lazy imports: a missing/locked coordination DB
|
|
16
|
+
* degrades to a no-op coordinator rather than blocking delivery.
|
|
17
|
+
*/
|
|
18
|
+
const NOOP = {
|
|
19
|
+
agentId: null,
|
|
20
|
+
overlapWarnings: [],
|
|
21
|
+
onIteration: () => undefined,
|
|
22
|
+
finish: async () => undefined,
|
|
23
|
+
queueDeploy: async () => null,
|
|
24
|
+
};
|
|
25
|
+
/** All files the loop applied across its iteration history, deduplicated. */
|
|
26
|
+
export function collectAppliedFiles(result) {
|
|
27
|
+
const files = new Set();
|
|
28
|
+
for (const record of result.history) {
|
|
29
|
+
for (const f of record.filesApplied)
|
|
30
|
+
files.add(f);
|
|
31
|
+
}
|
|
32
|
+
return [...files];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Register this delivery run with the coordination service and announce its
|
|
36
|
+
* work. Returns a no-op coordinator when the coordination layer is
|
|
37
|
+
* unavailable — delivery must never fail because coordination did.
|
|
38
|
+
*/
|
|
39
|
+
export async function createRunCoordinator(options) {
|
|
40
|
+
let registeredId = null;
|
|
41
|
+
let registeredService = null;
|
|
42
|
+
try {
|
|
43
|
+
const { CoordinationService } = await import('../coordination/service.js');
|
|
44
|
+
const service = new CoordinationService(options.dbPath ? { dbPath: options.dbPath } : {});
|
|
45
|
+
const agentId = service.register(`uap-deliver-${options.modelId}`, [
|
|
46
|
+
'delivery',
|
|
47
|
+
'convergence-loop',
|
|
48
|
+
]);
|
|
49
|
+
registeredId = agentId;
|
|
50
|
+
registeredService = service;
|
|
51
|
+
service.updateStatus(agentId, 'active', options.instruction.slice(0, 200));
|
|
52
|
+
const { overlaps } = service.announceWork(agentId, options.projectRoot, 'editing', {
|
|
53
|
+
description: `uap deliver: ${options.instruction.slice(0, 200)}`,
|
|
54
|
+
estimatedMinutes: options.estimatedMinutes ?? 15,
|
|
55
|
+
});
|
|
56
|
+
const overlapWarnings = overlaps.map((o) => {
|
|
57
|
+
const who = o.agents.map((a) => `${a.name} (${a.intentType})`).join(', ');
|
|
58
|
+
return `${o.resource}: ${who} — ${o.conflictRisk} risk. ${o.suggestion}`;
|
|
59
|
+
});
|
|
60
|
+
// A single loop turn (model call + full gate run) routinely exceeds the
|
|
61
|
+
// stale-agent cutoff, so heartbeat on a timer too — not just per turn —
|
|
62
|
+
// or concurrent cleanup would mark this run stale mid-turn. unref() so
|
|
63
|
+
// the timer never keeps the process alive.
|
|
64
|
+
const heartbeatTimer = setInterval(() => {
|
|
65
|
+
try {
|
|
66
|
+
service.heartbeat(agentId);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// Heartbeat is best-effort
|
|
70
|
+
}
|
|
71
|
+
}, 30_000);
|
|
72
|
+
heartbeatTimer.unref?.();
|
|
73
|
+
return {
|
|
74
|
+
agentId,
|
|
75
|
+
overlapWarnings,
|
|
76
|
+
onIteration(record) {
|
|
77
|
+
try {
|
|
78
|
+
service.heartbeat(agentId);
|
|
79
|
+
service.updateStatus(agentId, 'active', `turn ${record.turn}: ${Math.round(record.score * 100)}% of gates`);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// Heartbeat is best-effort
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
async finish(result) {
|
|
86
|
+
clearInterval(heartbeatTimer);
|
|
87
|
+
try {
|
|
88
|
+
service.completeWork(agentId, options.projectRoot);
|
|
89
|
+
service.updateStatus(agentId, 'completed', result.success ? `delivered in ${result.turns} turn(s)` : 'not delivered');
|
|
90
|
+
service.deregister(agentId);
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
// Cleanup is best-effort
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
async queueDeploy(result, message) {
|
|
97
|
+
if (!result.success)
|
|
98
|
+
return null;
|
|
99
|
+
try {
|
|
100
|
+
const { DeployBatcher } = await import('../coordination/deploy-batcher.js');
|
|
101
|
+
const batcher = new DeployBatcher(options.dbPath ? { dbPath: options.dbPath } : {});
|
|
102
|
+
const files = collectAppliedFiles(result);
|
|
103
|
+
if (files.length === 0)
|
|
104
|
+
return null;
|
|
105
|
+
return await batcher.queue(agentId, 'commit', options.projectRoot, {
|
|
106
|
+
message,
|
|
107
|
+
files,
|
|
108
|
+
cwd: options.projectRoot,
|
|
109
|
+
source: 'uap-deliver',
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
// If registration succeeded but a later step threw, don't leak an
|
|
120
|
+
// 'active' phantom agent into the registry.
|
|
121
|
+
if (registeredId && registeredService) {
|
|
122
|
+
try {
|
|
123
|
+
registeredService.deregister(registeredId);
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
// best-effort
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return NOOP;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=run-coordinator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-coordinator.js","sourceRoot":"","sources":["../../src/delivery/run-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AA2BH,MAAM,IAAI,GAAmB;IAC3B,OAAO,EAAE,IAAI;IACb,eAAe,EAAE,EAAE;IACnB,WAAW,EAAE,GAAG,EAAE,CAAC,SAAS;IAC5B,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC,SAAS;IAC7B,WAAW,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;CAC9B,CAAC;AAEF,6EAA6E;AAC7E,MAAM,UAAU,mBAAmB,CAAC,MAAsB;IACxD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACpC,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,YAAY;YAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;AACpB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAA8B;IAE9B,IAAI,YAAY,GAAkB,IAAI,CAAC;IACvC,IAAI,iBAAiB,GAA4C,IAAI,CAAC;IACtE,IAAI,CAAC;QACH,MAAM,EAAE,mBAAmB,EAAE,GAAG,MAAM,MAAM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M,MAAM,CAAC,mCAAmC,CAAC,CAAC;oBAC5E,MAAM,OAAO,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;oBACpF,MAAM,KAAK,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;oBAC1C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;wBAAE,OAAO,IAAI,CAAC;oBACpC,OAAO,MAAM,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAE;wBACjE,OAAO;wBACP,KAAK;wBACL,GAAG,EAAE,OAAO,CAAC,WAAW;wBACxB,MAAM,EAAE,aAAa;qBACtB,CAAC,CAAC;gBACL,CAAC;gBAAC,MAAM,CAAC;oBACP,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,kEAAkE;QAClE,4CAA4C;QAC5C,IAAI,YAAY,IAAI,iBAAiB,EAAE,CAAC;YACtC,IAAI,CAAC;gBACH,iBAAiB,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;YAC7C,CAAC;YAAC,MAAM,CAAC;gBACP,cAAc;YAChB,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -13,9 +13,15 @@ import { type TaskClassification } from './task-classifier.js';
|
|
|
13
13
|
import { type ContextDecision, type TaskMetadata } from './adaptive-context.js';
|
|
14
14
|
import { type AmbiguityResult } from './ambiguity-detector.js';
|
|
15
15
|
/**
|
|
16
|
-
* Query complexity levels for adaptive retrieval
|
|
16
|
+
* Query complexity levels for adaptive retrieval. The scorer lives in the
|
|
17
|
+
* dependency-free utils module so non-memory consumers (delivery harness)
|
|
18
|
+
* can classify without loading this module's DB machinery; re-exported here
|
|
19
|
+
* for backward compatibility.
|
|
17
20
|
*/
|
|
18
|
-
|
|
21
|
+
import { measureQueryComplexity } from '../utils/query-complexity.js';
|
|
22
|
+
import type { QueryComplexity } from '../utils/query-complexity.js';
|
|
23
|
+
export { measureQueryComplexity };
|
|
24
|
+
export type { QueryComplexity };
|
|
19
25
|
/**
|
|
20
26
|
* Retrieval depth configuration
|
|
21
27
|
*/
|
|
@@ -39,11 +45,6 @@ export interface RetrievalDepthConfig {
|
|
|
39
45
|
patterns: number;
|
|
40
46
|
};
|
|
41
47
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Measure query complexity to determine retrieval depth
|
|
44
|
-
* Based on SimpleMem's adaptive query-aware retrieval
|
|
45
|
-
*/
|
|
46
|
-
export declare function measureQueryComplexity(query: string): QueryComplexity;
|
|
47
48
|
/**
|
|
48
49
|
* Get retrieval limits based on query complexity
|
|
49
50
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-retrieval.d.ts","sourceRoot":"","sources":["../../src/memory/dynamic-retrieval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,EAIL,KAAK,kBAAkB,EACxB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAO/B,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,yBAAyB,CAAC;AA2EjC
|
|
1
|
+
{"version":3,"file":"dynamic-retrieval.d.ts","sourceRoot":"","sources":["../../src/memory/dynamic-retrieval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,EAIL,KAAK,kBAAkB,EACxB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAO/B,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,yBAAyB,CAAC;AA2EjC;;;;;GAKG;AACH,OAAO,EAAE,sB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C;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,eAAe,CAAC;IACjC,WAAW,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAChE,gBAAgB,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,gBAAgB,EAAE,MAAM,CAAA;KAAE,CAAC;IACrF,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAsB,4BAA4B,CAChD,eAAe,EAAE,MAAM,EACvB,WAAW,GAAE,MAAsB,EACnC,OAAO,GAAE;IACP,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,YAAY,CAAC,EAAE,YAAY,CAAC;CACxB,GACL,OAAO,CAAC,oBAAoB,CAAC,CAmV/B;AAiuBD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAmC7D"}
|
|
@@ -87,63 +87,19 @@ const dbPoolCleanupInterval = setInterval(() => {
|
|
|
87
87
|
trimFileCache();
|
|
88
88
|
}, 60_000);
|
|
89
89
|
dbPoolCleanupInterval.unref();
|
|
90
|
+
/**
|
|
91
|
+
* Query complexity levels for adaptive retrieval. The scorer lives in the
|
|
92
|
+
* dependency-free utils module so non-memory consumers (delivery harness)
|
|
93
|
+
* can classify without loading this module's DB machinery; re-exported here
|
|
94
|
+
* for backward compatibility.
|
|
95
|
+
*/
|
|
96
|
+
import { measureQueryComplexity } from '../utils/query-complexity.js';
|
|
97
|
+
export { measureQueryComplexity };
|
|
90
98
|
const DEFAULT_RETRIEVAL_DEPTHS = {
|
|
91
99
|
simple: { shortTerm: 3, sessionMem: 2, longTerm: 5, patterns: 3 },
|
|
92
100
|
moderate: { shortTerm: 6, sessionMem: 5, longTerm: 8, patterns: 5 },
|
|
93
101
|
complex: { shortTerm: 10, sessionMem: 8, longTerm: 15, patterns: 8 },
|
|
94
102
|
};
|
|
95
|
-
/**
|
|
96
|
-
* Measure query complexity to determine retrieval depth
|
|
97
|
-
* Based on SimpleMem's adaptive query-aware retrieval
|
|
98
|
-
*/
|
|
99
|
-
export function measureQueryComplexity(query) {
|
|
100
|
-
let score = 0;
|
|
101
|
-
// Length-based scoring (lower thresholds)
|
|
102
|
-
const wordCount = query.split(/\s+/).length;
|
|
103
|
-
if (wordCount > 30)
|
|
104
|
-
score += 1.5;
|
|
105
|
-
else if (wordCount > 12)
|
|
106
|
-
score += 0.75;
|
|
107
|
-
else if (wordCount > 6)
|
|
108
|
-
score += 0.25;
|
|
109
|
-
// Technical terms increase complexity
|
|
110
|
-
const techPatterns = [
|
|
111
|
-
/debug|fix|error|exception|bug/i,
|
|
112
|
-
/implement|refactor|optimize|build/i,
|
|
113
|
-
/configure|setup|install|deploy/i,
|
|
114
|
-
/security|vulnerability|cve|auth/i,
|
|
115
|
-
/performance|memory|cpu|latency/i,
|
|
116
|
-
/database|query|migration|schema/i,
|
|
117
|
-
/test|coverage|mock|spec/i,
|
|
118
|
-
];
|
|
119
|
-
for (const pattern of techPatterns) {
|
|
120
|
-
if (pattern.test(query))
|
|
121
|
-
score += 0.4;
|
|
122
|
-
}
|
|
123
|
-
// Multiple entities/files increase complexity
|
|
124
|
-
const fileMatches = query.match(/[\w./\\-]+\.(ts|js|py|json|yaml|sh|sql)/gi);
|
|
125
|
-
if (fileMatches) {
|
|
126
|
-
score += fileMatches.length * 0.3;
|
|
127
|
-
}
|
|
128
|
-
// Multi-step tasks are complex
|
|
129
|
-
if (/and then|after that|followed by|step \d|first.*then|also|additionally/i.test(query)) {
|
|
130
|
-
score += 1;
|
|
131
|
-
}
|
|
132
|
-
// Questions about "why" or "how" are moderate
|
|
133
|
-
if (/^(why|how|what caused|explain)/i.test(query)) {
|
|
134
|
-
score += 0.5;
|
|
135
|
-
}
|
|
136
|
-
// Multiple actions in one query
|
|
137
|
-
const actionWords = query.match(/\b(fix|implement|configure|debug|create|update|delete|add|remove)\b/gi);
|
|
138
|
-
if (actionWords && actionWords.length > 1) {
|
|
139
|
-
score += actionWords.length * 0.3;
|
|
140
|
-
}
|
|
141
|
-
if (score >= 2)
|
|
142
|
-
return 'complex';
|
|
143
|
-
if (score >= 1)
|
|
144
|
-
return 'moderate';
|
|
145
|
-
return 'simple';
|
|
146
|
-
}
|
|
147
103
|
/**
|
|
148
104
|
* Get retrieval limits based on query complexity
|
|
149
105
|
*/
|