@eir-labs/coltrane 0.4.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/LICENSE +201 -0
- package/README.md +85 -0
- package/agents/anticipation-mapper.json +34 -0
- package/agents/claim-amender.json +34 -0
- package/agents/claim-architect.json +34 -0
- package/agents/claim-rewriter.json +32 -0
- package/agents/delivery-finalizer.json +40 -0
- package/agents/diamond-cutter.json +33 -0
- package/agents/disclosure-analyst.json +26 -0
- package/agents/domain-explorer.json +37 -0
- package/agents/e2e-runner.json +34 -0
- package/agents/e2e-suite-judge.json +26 -0
- package/agents/event-clusterer.json +29 -0
- package/agents/novelty-searcher.json +40 -0
- package/agents/patent-browser-scout.json +49 -0
- package/agents/patent-examiner.json +36 -0
- package/agents/phase_agents/claim-rewriter.md +44 -0
- package/agents/phase_agents/delivery-finalizer.md +30 -0
- package/agents/phase_agents/diamond-cutter.md +47 -0
- package/agents/phase_agents/domain-explorer.md +27 -0
- package/agents/phase_agents/novelty-searcher.md +50 -0
- package/agents/phase_agents/problem-definer.md +32 -0
- package/agents/phase_agents/solution-developer.md +26 -0
- package/agents/phase_agents/verdict-judger.md +70 -0
- package/agents/players/audience-modeler.md +40 -0
- package/agents/players/chain-audit-keeper.md +41 -0
- package/agents/players/illumination-reviewer.md +42 -0
- package/agents/players/methodology-cadence-keeper.md +42 -0
- package/agents/players/substrate-edge-keeper.md +45 -0
- package/agents/prior-art-scout.json +45 -0
- package/agents/problem-definer.json +35 -0
- package/agents/seeds/steve_seed_a.json +12 -0
- package/agents/seeds/steve_seed_b.json +12 -0
- package/agents/seeds/steve_seed_c.json +12 -0
- package/agents/seeds/steve_seed_d.json +12 -0
- package/agents/sensor.json +22 -0
- package/agents/solution-developer.json +35 -0
- package/agents/source-walker.json +38 -0
- package/agents/spec-drafter.json +31 -0
- package/agents/sub_thread_soft_judge.json +26 -0
- package/agents/sub_thread_trace_sensor.json +22 -0
- package/agents/summarizer.json +25 -0
- package/agents/synthesis-writer.json +29 -0
- package/agents/triage-judge.json +39 -0
- package/agents/user_flow_judge.json +26 -0
- package/agents/user_flow_sensor.json +22 -0
- package/agents/verdict-judger.json +39 -0
- package/core_types/artifact.json +17 -0
- package/core_types/interpretation.json +16 -0
- package/core_types/judgment.json +16 -0
- package/core_types/plan.json +16 -0
- package/core_types/signal.json +16 -0
- package/core_types/verdict.json +27 -0
- package/dist/src/access_grant.d.ts +46 -0
- package/dist/src/access_grant.js +76 -0
- package/dist/src/access_grant.js.map +1 -0
- package/dist/src/acoustics.d.ts +9 -0
- package/dist/src/acoustics.js +65 -0
- package/dist/src/acoustics.js.map +1 -0
- package/dist/src/agent_profile.d.ts +36 -0
- package/dist/src/agent_profile.js +57 -0
- package/dist/src/agent_profile.js.map +1 -0
- package/dist/src/bifrost_invoker.d.ts +33 -0
- package/dist/src/bifrost_invoker.js +85 -0
- package/dist/src/bifrost_invoker.js.map +1 -0
- package/dist/src/canonical_core_types.d.ts +2 -0
- package/dist/src/canonical_core_types.js +111 -0
- package/dist/src/canonical_core_types.js.map +1 -0
- package/dist/src/canonical_form.d.ts +55 -0
- package/dist/src/canonical_form.js +93 -0
- package/dist/src/canonical_form.js.map +1 -0
- package/dist/src/charter.d.ts +37 -0
- package/dist/src/charter.js +86 -0
- package/dist/src/charter.js.map +1 -0
- package/dist/src/circle_of_fifths.d.ts +27 -0
- package/dist/src/circle_of_fifths.js +78 -0
- package/dist/src/circle_of_fifths.js.map +1 -0
- package/dist/src/claude_invoker.d.ts +102 -0
- package/dist/src/claude_invoker.js +760 -0
- package/dist/src/claude_invoker.js.map +1 -0
- package/dist/src/coltrane_profile.d.ts +87 -0
- package/dist/src/coltrane_profile.js +132 -0
- package/dist/src/coltrane_profile.js.map +1 -0
- package/dist/src/composition.d.ts +57 -0
- package/dist/src/composition.js +447 -0
- package/dist/src/composition.js.map +1 -0
- package/dist/src/core_types.d.ts +6 -0
- package/dist/src/core_types.js +25 -0
- package/dist/src/core_types.js.map +1 -0
- package/dist/src/document_factory.d.ts +89 -0
- package/dist/src/document_factory.js +176 -0
- package/dist/src/document_factory.js.map +1 -0
- package/dist/src/genome_schema.d.ts +512 -0
- package/dist/src/genome_schema.js +168 -0
- package/dist/src/genome_schema.js.map +1 -0
- package/dist/src/genome_writer.d.ts +67 -0
- package/dist/src/genome_writer.js +179 -0
- package/dist/src/genome_writer.js.map +1 -0
- package/dist/src/gig_song.d.ts +29 -0
- package/dist/src/gig_song.js +56 -0
- package/dist/src/gig_song.js.map +1 -0
- package/dist/src/gig_tracker.d.ts +54 -0
- package/dist/src/gig_tracker.js +109 -0
- package/dist/src/gig_tracker.js.map +1 -0
- package/dist/src/harmonic_validation.d.ts +11 -0
- package/dist/src/harmonic_validation.js +35 -0
- package/dist/src/harmonic_validation.js.map +1 -0
- package/dist/src/hooks.d.ts +27 -0
- package/dist/src/hooks.js +2 -0
- package/dist/src/hooks.js.map +1 -0
- package/dist/src/index.d.ts +36 -0
- package/dist/src/index.js +37 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/jsong.d.ts +47 -0
- package/dist/src/jsong.js +130 -0
- package/dist/src/jsong.js.map +1 -0
- package/dist/src/judges/user_flow_judge.d.ts +89 -0
- package/dist/src/judges/user_flow_judge.js +200 -0
- package/dist/src/judges/user_flow_judge.js.map +1 -0
- package/dist/src/learner.d.ts +37 -0
- package/dist/src/learner.js +30 -0
- package/dist/src/learner.js.map +1 -0
- package/dist/src/ledger.d.ts +225 -0
- package/dist/src/ledger.js +306 -0
- package/dist/src/ledger.js.map +1 -0
- package/dist/src/loader.d.ts +87 -0
- package/dist/src/loader.js +504 -0
- package/dist/src/loader.js.map +1 -0
- package/dist/src/mcp.d.ts +23 -0
- package/dist/src/mcp.js +125 -0
- package/dist/src/mcp.js.map +1 -0
- package/dist/src/modulation_path.d.ts +42 -0
- package/dist/src/modulation_path.js +60 -0
- package/dist/src/modulation_path.js.map +1 -0
- package/dist/src/output_validation.d.ts +19 -0
- package/dist/src/output_validation.js +51 -0
- package/dist/src/output_validation.js.map +1 -0
- package/dist/src/outputs.d.ts +125 -0
- package/dist/src/outputs.js +452 -0
- package/dist/src/outputs.js.map +1 -0
- package/dist/src/overtones.d.ts +42 -0
- package/dist/src/overtones.js +98 -0
- package/dist/src/overtones.js.map +1 -0
- package/dist/src/player_to_claude_code.d.ts +17 -0
- package/dist/src/player_to_claude_code.js +141 -0
- package/dist/src/player_to_claude_code.js.map +1 -0
- package/dist/src/playwright_cage.d.ts +28 -0
- package/dist/src/playwright_cage.js +47 -0
- package/dist/src/playwright_cage.js.map +1 -0
- package/dist/src/polyphony.d.ts +46 -0
- package/dist/src/polyphony.js +91 -0
- package/dist/src/polyphony.js.map +1 -0
- package/dist/src/portfolio.d.ts +52 -0
- package/dist/src/portfolio.js +186 -0
- package/dist/src/portfolio.js.map +1 -0
- package/dist/src/pricing.d.ts +23 -0
- package/dist/src/pricing.js +16 -0
- package/dist/src/pricing.js.map +1 -0
- package/dist/src/registry.d.ts +46 -0
- package/dist/src/registry.js +199 -0
- package/dist/src/registry.js.map +1 -0
- package/dist/src/runtime.d.ts +304 -0
- package/dist/src/runtime.js +1099 -0
- package/dist/src/runtime.js.map +1 -0
- package/dist/src/server.d.ts +88 -0
- package/dist/src/server.js +1692 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/server_entry.d.ts +2 -0
- package/dist/src/server_entry.js +40 -0
- package/dist/src/server_entry.js.map +1 -0
- package/dist/src/server_relay.d.ts +82 -0
- package/dist/src/server_relay.js +341 -0
- package/dist/src/server_relay.js.map +1 -0
- package/dist/src/simulate.d.ts +60 -0
- package/dist/src/simulate.js +72 -0
- package/dist/src/simulate.js.map +1 -0
- package/dist/src/skill_runner.mjs +34 -0
- package/dist/src/skill_subprocess.d.ts +65 -0
- package/dist/src/skill_subprocess.js +132 -0
- package/dist/src/skill_subprocess.js.map +1 -0
- package/dist/src/skills.d.ts +85 -0
- package/dist/src/skills.js +258 -0
- package/dist/src/skills.js.map +1 -0
- package/dist/src/subthread_recorder.d.ts +68 -0
- package/dist/src/subthread_recorder.js +166 -0
- package/dist/src/subthread_recorder.js.map +1 -0
- package/dist/src/tensor_read.d.ts +38 -0
- package/dist/src/tensor_read.js +60 -0
- package/dist/src/tensor_read.js.map +1 -0
- package/dist/src/test_honest_broker.d.ts +34 -0
- package/dist/src/test_honest_broker.js +155 -0
- package/dist/src/test_honest_broker.js.map +1 -0
- package/dist/src/test_topology.d.ts +22 -0
- package/dist/src/test_topology.js +137 -0
- package/dist/src/test_topology.js.map +1 -0
- package/dist/src/tones.d.ts +20 -0
- package/dist/src/tones.js +81 -0
- package/dist/src/tones.js.map +1 -0
- package/dist/src/tool_providers.d.ts +45 -0
- package/dist/src/tool_providers.js +104 -0
- package/dist/src/tool_providers.js.map +1 -0
- package/dist/src/type_versioning.d.ts +23 -0
- package/dist/src/type_versioning.js +31 -0
- package/dist/src/type_versioning.js.map +1 -0
- package/dist/src/version.d.ts +28 -0
- package/dist/src/version.js +86 -0
- package/dist/src/version.js.map +1 -0
- package/domain_types/claim-draft.json +34 -0
- package/domain_types/coverage-report.json +31 -0
- package/domain_types/draft-agent-profile.json +31 -0
- package/domain_types/draft-domain-type.json +28 -0
- package/domain_types/draft-standard.json +46 -0
- package/domain_types/e2e-observation.json +32 -0
- package/domain_types/e2e-report.json +30 -0
- package/domain_types/e2e-target.json +26 -0
- package/domain_types/e2e-verdict.json +26 -0
- package/domain_types/examine-round-record.json +40 -0
- package/domain_types/examiner-rejection.json +28 -0
- package/domain_types/failure-modes.json +31 -0
- package/domain_types/invention-analysis.json +34 -0
- package/domain_types/invention-spec.json +34 -0
- package/domain_types/novelty-analysis.json +28 -0
- package/domain_types/novelty-verdict.json +35 -0
- package/domain_types/parsed-conversation-trace.json +38 -0
- package/domain_types/pattern-extraction.json +62 -0
- package/domain_types/prior-art-hit.json +50 -0
- package/domain_types/project-charter.json +71 -0
- package/domain_types/provisional-draft.json +34 -0
- package/domain_types/raw-note.json +19 -0
- package/domain_types/repo-survey.json +28 -0
- package/domain_types/seeding-verdict.json +70 -0
- package/domain_types/soft-verdict.json +55 -0
- package/domain_types/summary.json +19 -0
- package/domain_types/triage-verdict.json +59 -0
- package/domain_types/user-flow-transcript.json +43 -0
- package/domain_types/user-flow-verdict.json +60 -0
- package/domain_types/verdict-record.json +39 -0
- package/package.json +82 -0
- package/skills/citation-verify/fixtures/basic.json +14 -0
- package/skills/citation-verify/meta.json +10 -0
- package/skills/citation-verify/skill.mjs +26 -0
- package/skills/claim-element-decompose/fixtures/basic.json +11 -0
- package/skills/claim-element-decompose/meta.json +10 -0
- package/skills/claim-element-decompose/skill.mjs +14 -0
- package/skills/diamond-cutting-discipline/fixtures/basic.json +13 -0
- package/skills/diamond-cutting-discipline/meta.json +19 -0
- package/skills/diamond-cutting-discipline/skill.md +46 -0
- package/skills/element-mapping-matrix/fixtures/basic.json +13 -0
- package/skills/element-mapping-matrix/meta.json +10 -0
- package/skills/element-mapping-matrix/skill.mjs +20 -0
- package/skills/number-adder/fixtures/basic.json +9 -0
- package/skills/number-adder/meta.json +10 -0
- package/skills/number-adder/skill.mjs +12 -0
- package/skills/patent-fetch/fixtures/parse.json +18 -0
- package/skills/patent-fetch/meta.json +11 -0
- package/skills/patent-fetch/skill.mjs +34 -0
- package/skills/query-expand/fixtures/basic.json +14 -0
- package/skills/query-expand/meta.json +10 -0
- package/skills/query-expand/skill.mjs +29 -0
- package/skills/run-vitest-band/fixtures/basic.json +9 -0
- package/skills/run-vitest-band/meta.json +18 -0
- package/skills/run-vitest-band/skill.mjs +22 -0
- package/skills/statutory-checklist/fixtures/basic.json +16 -0
- package/skills/statutory-checklist/meta.json +10 -0
- package/skills/statutory-checklist/skill.mjs +25 -0
- package/skills/summarize-tight/fixtures/basic.json +13 -0
- package/skills/summarize-tight/meta.json +20 -0
- package/skills/summarize-tight/skill.md +1 -0
- package/skills/verdict-gate/fixtures/basic.json +9 -0
- package/skills/verdict-gate/meta.json +10 -0
- package/skills/verdict-gate/skill.mjs +82 -0
- package/standards/e2e-suite-v0.json +44 -0
- package/standards/patent-triage-v0.json +98 -0
- package/standards/patent-triage-v1.json +84 -0
- package/standards/seed-from-local-repos-v0.json +115 -0
- package/standards/sub_thread_invocation.json +50 -0
- package/standards/summarize.json +40 -0
- package/standards/synthesis-walk-v0.json +108 -0
- package/standards/user_flow_correctness.json +57 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export declare const CANONICAL_FORM_VERSION = "1.1";
|
|
2
|
+
export declare function canonJson(value: unknown): string;
|
|
3
|
+
export declare function canonText(value: string): string;
|
|
4
|
+
export declare function sha256Hex(bytes: string | Buffer): string;
|
|
5
|
+
export declare function fileHashJson(value: unknown): string;
|
|
6
|
+
export declare function fileHashText(text: string): string;
|
|
7
|
+
export interface FileEntry {
|
|
8
|
+
relpath: string;
|
|
9
|
+
hash: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function definitionHash(files: readonly FileEntry[]): string;
|
|
12
|
+
/**
|
|
13
|
+
* Content-address an output for the run_fingerprint. Folds the *semantic* fields
|
|
14
|
+
* (type identity + producing agent/phase + data) and deliberately EXCLUDES
|
|
15
|
+
* run-instance noise — `id`, `gig_id`, `created_at`, `input_refs` are all fresh
|
|
16
|
+
* UUIDs/timestamps per run. Hashing those made two byte-identical runs produce
|
|
17
|
+
* different fingerprints, so an honest replay never matched and was
|
|
18
|
+
* indistinguishable from a tamper. With this, identical content → identical hash
|
|
19
|
+
* (replay reproduces), different content → different hash (tamper is caught).
|
|
20
|
+
*/
|
|
21
|
+
export declare function outputContentHash(rec: {
|
|
22
|
+
core_type: string;
|
|
23
|
+
domain_type: string;
|
|
24
|
+
domain_type_version: number;
|
|
25
|
+
domain: string;
|
|
26
|
+
primitive: string;
|
|
27
|
+
phase?: string | undefined;
|
|
28
|
+
agent_slug: string;
|
|
29
|
+
data: unknown;
|
|
30
|
+
}): string;
|
|
31
|
+
export interface RunFingerprintInput {
|
|
32
|
+
genome_hash: string;
|
|
33
|
+
model_version: string;
|
|
34
|
+
canonical_form_version: string;
|
|
35
|
+
eval_scores: Readonly<Record<string, number>>;
|
|
36
|
+
output_hashes: readonly string[];
|
|
37
|
+
/**
|
|
38
|
+
* #246 — eval slugs that resolved to NO eval definition. An unresolvable slug scores 0.0 for
|
|
39
|
+
* back-compat, which is byte-identical to an eval that ran and genuinely failed; without this
|
|
40
|
+
* term a typo would bake into the reproducibility key as though a real contract had been
|
|
41
|
+
* evaluated and found wanting. Contributes a line ONLY when non-empty, so every fingerprint
|
|
42
|
+
* over a fully-resolved run stays byte-identical to what it was before this field existed.
|
|
43
|
+
*/
|
|
44
|
+
unresolved_evals?: readonly string[];
|
|
45
|
+
}
|
|
46
|
+
export declare function runFingerprint(input: RunFingerprintInput): string;
|
|
47
|
+
export type DependencyClass = "type" | "agent" | "standard" | "skill" | "eval";
|
|
48
|
+
export interface DirectDependency {
|
|
49
|
+
class: DependencyClass;
|
|
50
|
+
slug: string;
|
|
51
|
+
effective_hash: string;
|
|
52
|
+
}
|
|
53
|
+
export declare const EMPTY_DEPENDENCY_HASH = "4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945";
|
|
54
|
+
export declare function dependencyHash(deps: readonly DirectDependency[]): string;
|
|
55
|
+
export declare function effectiveHash(content_hash: string, dependency_hash: string): string;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
export const CANONICAL_FORM_VERSION = "1.1";
|
|
3
|
+
const EXCLUDED_FIELDS = new Set(["content_hash", "materialized_at", "last_seen"]);
|
|
4
|
+
export function canonJson(value) {
|
|
5
|
+
return JSON.stringify(stripAndSortKeys(value));
|
|
6
|
+
}
|
|
7
|
+
export function canonText(value) {
|
|
8
|
+
const lf = value.replace(/\r\n/g, "\n");
|
|
9
|
+
return lf.replace(/\n+$/, "") + "\n";
|
|
10
|
+
}
|
|
11
|
+
function stripAndSortKeys(value) {
|
|
12
|
+
if (Array.isArray(value))
|
|
13
|
+
return value.map(stripAndSortKeys);
|
|
14
|
+
if (value !== null && typeof value === "object") {
|
|
15
|
+
const sorted = {};
|
|
16
|
+
for (const k of Object.keys(value).sort()) {
|
|
17
|
+
if (EXCLUDED_FIELDS.has(k))
|
|
18
|
+
continue;
|
|
19
|
+
sorted[k] = stripAndSortKeys(value[k]);
|
|
20
|
+
}
|
|
21
|
+
return sorted;
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
export function sha256Hex(bytes) {
|
|
26
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
27
|
+
}
|
|
28
|
+
export function fileHashJson(value) {
|
|
29
|
+
return sha256Hex(canonJson(value));
|
|
30
|
+
}
|
|
31
|
+
export function fileHashText(text) {
|
|
32
|
+
return sha256Hex(canonText(text));
|
|
33
|
+
}
|
|
34
|
+
export function definitionHash(files) {
|
|
35
|
+
const sorted = [...files].sort((a, b) => (a.relpath < b.relpath ? -1 : a.relpath > b.relpath ? 1 : 0));
|
|
36
|
+
const manifest = JSON.stringify(sorted.map((f) => [f.relpath, f.hash]));
|
|
37
|
+
return sha256Hex(manifest);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Content-address an output for the run_fingerprint. Folds the *semantic* fields
|
|
41
|
+
* (type identity + producing agent/phase + data) and deliberately EXCLUDES
|
|
42
|
+
* run-instance noise — `id`, `gig_id`, `created_at`, `input_refs` are all fresh
|
|
43
|
+
* UUIDs/timestamps per run. Hashing those made two byte-identical runs produce
|
|
44
|
+
* different fingerprints, so an honest replay never matched and was
|
|
45
|
+
* indistinguishable from a tamper. With this, identical content → identical hash
|
|
46
|
+
* (replay reproduces), different content → different hash (tamper is caught).
|
|
47
|
+
*/
|
|
48
|
+
export function outputContentHash(rec) {
|
|
49
|
+
return sha256Hex(canonJson({
|
|
50
|
+
core_type: rec.core_type,
|
|
51
|
+
domain_type: rec.domain_type,
|
|
52
|
+
domain_type_version: rec.domain_type_version,
|
|
53
|
+
domain: rec.domain,
|
|
54
|
+
primitive: rec.primitive,
|
|
55
|
+
phase: rec.phase,
|
|
56
|
+
agent_slug: rec.agent_slug,
|
|
57
|
+
data: rec.data,
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
export function runFingerprint(input) {
|
|
61
|
+
const scoreLines = Object.keys(input.eval_scores)
|
|
62
|
+
.sort()
|
|
63
|
+
.map((k) => `${k}:${input.eval_scores[k]}`);
|
|
64
|
+
const outputLines = [...input.output_hashes].sort();
|
|
65
|
+
const lines = [
|
|
66
|
+
`genome_hash:${input.genome_hash}`,
|
|
67
|
+
`model_version:${input.model_version}`,
|
|
68
|
+
`canonical_form_version:${input.canonical_form_version}`,
|
|
69
|
+
`eval_scores:${scoreLines.join(",")}`,
|
|
70
|
+
`output_hashes:${outputLines.join(",")}`,
|
|
71
|
+
];
|
|
72
|
+
if (input.unresolved_evals?.length) {
|
|
73
|
+
lines.push(`unresolved_evals:${[...input.unresolved_evals].sort().join(",")}`);
|
|
74
|
+
}
|
|
75
|
+
return sha256Hex(lines.join("\n") + "\n");
|
|
76
|
+
}
|
|
77
|
+
export const EMPTY_DEPENDENCY_HASH = "4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945";
|
|
78
|
+
export function dependencyHash(deps) {
|
|
79
|
+
const sorted = [...deps]
|
|
80
|
+
.map((d) => [d.class, d.slug, d.effective_hash])
|
|
81
|
+
.sort((a, b) => {
|
|
82
|
+
if (a[0] !== b[0])
|
|
83
|
+
return a[0] < b[0] ? -1 : 1;
|
|
84
|
+
if (a[1] !== b[1])
|
|
85
|
+
return a[1] < b[1] ? -1 : 1;
|
|
86
|
+
return 0;
|
|
87
|
+
});
|
|
88
|
+
return sha256Hex(JSON.stringify(sorted));
|
|
89
|
+
}
|
|
90
|
+
export function effectiveHash(content_hash, dependency_hash) {
|
|
91
|
+
return sha256Hex(`${CANONICAL_FORM_VERSION}|${content_hash}|${dependency_hash}`);
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=canonical_form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical_form.js","sourceRoot":"","sources":["../../src/canonical_form.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAE5C,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,iBAAiB,EAAE,WAAW,CAAC,CAAC,CAAC;AAElF,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACxC,OAAO,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC;AACvC,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc;IACtC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC7D,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,MAAM,MAAM,GAA4B,EAAE,CAAC;QAC3C,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAgC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YACrE,IAAI,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;gBAAE,SAAS;YACrC,MAAM,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAE,KAAiC,CAAC,CAAC,CAAC,CAAC,CAAC;QACtE,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAA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CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,cAAc,CAAU,CAAC;SACxD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACb,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAAE,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/C,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAAE,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/C,OAAO,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;IACL,OAAO,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,YAAoB,EAAE,eAAuB;IACzE,OAAO,SAAS,CAAC,GAAG,sBAAsB,IAAI,YAAY,IAAI,eAAe,EAAE,CAAC,CAAC;AACnF,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AccessGrant } from "./access_grant.js";
|
|
2
|
+
export type SubjectType = "company" | "lab" | "solo" | "oss" | "other";
|
|
3
|
+
export interface Product {
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
url: string;
|
|
7
|
+
description: string;
|
|
8
|
+
}
|
|
9
|
+
export interface NorthStar {
|
|
10
|
+
goal: string;
|
|
11
|
+
priority: "low" | "medium" | "high" | "critical";
|
|
12
|
+
timeframe: string;
|
|
13
|
+
metrics: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
export interface Charter {
|
|
16
|
+
subject_name: string;
|
|
17
|
+
subject_type: SubjectType;
|
|
18
|
+
charter: string;
|
|
19
|
+
north_stars: readonly NorthStar[];
|
|
20
|
+
products: readonly Product[];
|
|
21
|
+
pain_points: readonly string[];
|
|
22
|
+
tech_stack: readonly string[];
|
|
23
|
+
existing_tools: readonly string[];
|
|
24
|
+
access_grants: readonly AccessGrant[];
|
|
25
|
+
}
|
|
26
|
+
export interface ValidationIssue {
|
|
27
|
+
path: string;
|
|
28
|
+
reason: string;
|
|
29
|
+
}
|
|
30
|
+
export interface CharterValidation {
|
|
31
|
+
valid: boolean;
|
|
32
|
+
issues: readonly ValidationIssue[];
|
|
33
|
+
}
|
|
34
|
+
export declare class CharterError extends Error {
|
|
35
|
+
}
|
|
36
|
+
export declare function validateCharter(ctx: unknown): CharterValidation;
|
|
37
|
+
export declare function loadCharter(value: unknown): Charter;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export class CharterError extends Error {
|
|
2
|
+
}
|
|
3
|
+
const VALID_PRIORITIES = new Set(["low", "medium", "high", "critical"]);
|
|
4
|
+
const VALID_SUBJECT_TYPES = new Set([
|
|
5
|
+
"company",
|
|
6
|
+
"lab",
|
|
7
|
+
"solo",
|
|
8
|
+
"oss",
|
|
9
|
+
"other",
|
|
10
|
+
]);
|
|
11
|
+
export function validateCharter(ctx) {
|
|
12
|
+
const issues = [];
|
|
13
|
+
if (typeof ctx !== "object" || ctx === null) {
|
|
14
|
+
return { valid: false, issues: [{ path: "$", reason: "context must be an object" }] };
|
|
15
|
+
}
|
|
16
|
+
const c = ctx;
|
|
17
|
+
if (typeof c.subject_name !== "string" || c.subject_name.length === 0) {
|
|
18
|
+
issues.push({ path: "subject_name", reason: "required non-empty string" });
|
|
19
|
+
}
|
|
20
|
+
if (typeof c.subject_type !== "string" ||
|
|
21
|
+
!VALID_SUBJECT_TYPES.has(c.subject_type)) {
|
|
22
|
+
issues.push({
|
|
23
|
+
path: "subject_type",
|
|
24
|
+
reason: `must be one of ${[...VALID_SUBJECT_TYPES].join("|")}`,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (typeof c.charter !== "string" || c.charter.length === 0) {
|
|
28
|
+
issues.push({ path: "charter", reason: "required non-empty string (mission / purpose)" });
|
|
29
|
+
}
|
|
30
|
+
if (!Array.isArray(c.north_stars)) {
|
|
31
|
+
issues.push({ path: "north_stars", reason: "required array of NorthStar" });
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
c.north_stars.forEach((ns, i) => {
|
|
35
|
+
const n = ns;
|
|
36
|
+
if (typeof n.goal !== "string" || n.goal.length === 0) {
|
|
37
|
+
issues.push({ path: `north_stars[${i}].goal`, reason: "required non-empty string" });
|
|
38
|
+
}
|
|
39
|
+
if (typeof n.priority !== "string" || !VALID_PRIORITIES.has(n.priority)) {
|
|
40
|
+
issues.push({
|
|
41
|
+
path: `north_stars[${i}].priority`,
|
|
42
|
+
reason: `must be one of ${[...VALID_PRIORITIES].join("|")}`,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (typeof n.timeframe !== "string") {
|
|
46
|
+
issues.push({ path: `north_stars[${i}].timeframe`, reason: "required string" });
|
|
47
|
+
}
|
|
48
|
+
if (!Array.isArray(n.metrics)) {
|
|
49
|
+
issues.push({ path: `north_stars[${i}].metrics`, reason: "required array" });
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (!Array.isArray(c.products)) {
|
|
54
|
+
issues.push({ path: "products", reason: "required array" });
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
c.products.forEach((p, i) => {
|
|
58
|
+
const pp = p;
|
|
59
|
+
for (const k of ["name", "type", "url", "description"]) {
|
|
60
|
+
if (typeof pp[k] !== "string") {
|
|
61
|
+
issues.push({ path: `products[${i}].${k}`, reason: "required string" });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
for (const k of ["pain_points", "tech_stack", "existing_tools"]) {
|
|
67
|
+
if (!Array.isArray(c[k])) {
|
|
68
|
+
issues.push({ path: k, reason: "required array of strings" });
|
|
69
|
+
}
|
|
70
|
+
else if (c[k].some((x) => typeof x !== "string")) {
|
|
71
|
+
issues.push({ path: k, reason: "elements must all be strings" });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (!Array.isArray(c.access_grants)) {
|
|
75
|
+
issues.push({ path: "access_grants", reason: "required array of AccessGrant" });
|
|
76
|
+
}
|
|
77
|
+
return { valid: issues.length === 0, issues };
|
|
78
|
+
}
|
|
79
|
+
export function loadCharter(value) {
|
|
80
|
+
const r = validateCharter(value);
|
|
81
|
+
if (!r.valid) {
|
|
82
|
+
throw new CharterError(`invalid Charter: ${r.issues.map((i) => `${i.path}: ${i.reason}`).join("; ")}`);
|
|
83
|
+
}
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=charter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"charter.js","sourceRoot":"","sources":["../../src/charter.ts"],"names":[],"mappings":"AAwCA,MAAM,OAAO,YAAa,SAAQ,KAAK;CAAG;AAE1C,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AACxE,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAc;IAC/C,SAAS;IACT,KAAK;IACL,MAAM;IACN,KAAK;IACL,OAAO;CACR,CAAC,CAAC;AAEH,MAAM,UAAU,eAAe,CAAC,GAAY;IAC1C,MAAM,MAAM,GAAsB,EAAE,CAAC;IAErC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QAC5C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,2BAA2B,EAAE,CAAC,EAAE,CAAC;IACxF,CAAC;IACD,MAAM,CAAC,GAA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AAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC/E,CAAC;IACJ,CAAC;IACD,OAAO,KAAgB,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const KEYS: readonly ["C", "G", "D", "A", "E", "B", "Gb", "Db", "Ab", "Eb", "Bb", "F"];
|
|
2
|
+
export type Key = (typeof KEYS)[number];
|
|
3
|
+
/**
|
|
4
|
+
* Shortest distance along the circle of fifths between two keys.
|
|
5
|
+
* Returns 0..6 (6 = tritone-apart). Adjacent keys = 1.
|
|
6
|
+
*/
|
|
7
|
+
export declare function circleOfFifthsDistance(a: Key, b: Key): number;
|
|
8
|
+
/**
|
|
9
|
+
* Adjacent keys on the circle (one step in either direction).
|
|
10
|
+
* C ↔ G, C ↔ F, etc. Smooth modulation pairs.
|
|
11
|
+
*/
|
|
12
|
+
export declare function adjacentKeys(k: Key): readonly Key[];
|
|
13
|
+
/**
|
|
14
|
+
* The relative minor for each major key (parallel by 3 fifths down).
|
|
15
|
+
* Provided for completeness; the validation logic treats relative-minor
|
|
16
|
+
* modulation as zero-cost (same key signature).
|
|
17
|
+
*/
|
|
18
|
+
export declare const RELATIVE_MINOR: Readonly<Record<Key, string>>;
|
|
19
|
+
/**
|
|
20
|
+
* Modulation classification used by sim-verify. A jsong that moves from key A
|
|
21
|
+
* to key B is "lawful" if the move is within MODULATION_THRESHOLD (default 1,
|
|
22
|
+
* i.e., adjacent on the circle, including relative-minor equivalence).
|
|
23
|
+
* Above the threshold = "jarring" — drift signal unless explicitly bridged.
|
|
24
|
+
*/
|
|
25
|
+
export declare const MODULATION_THRESHOLD = 1;
|
|
26
|
+
export type ModulationKind = "stay" | "lawful" | "jarring";
|
|
27
|
+
export declare function classifyModulation(from: Key, to: Key, threshold?: number): ModulationKind;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// 12-key topology for the song-substrate. Each key is a tonic + its scale.
|
|
2
|
+
// The circle of fifths arranges them in a ring where adjacent keys share 6 of
|
|
3
|
+
// 7 scale notes (smooth modulation) and tritone-apart keys share 1 of 7
|
|
4
|
+
// (jarring). This file exposes the 12 key names, their position on the circle,
|
|
5
|
+
// and distance helpers — pure data + arithmetic, no LLM dependency.
|
|
6
|
+
export const KEYS = [
|
|
7
|
+
"C",
|
|
8
|
+
"G",
|
|
9
|
+
"D",
|
|
10
|
+
"A",
|
|
11
|
+
"E",
|
|
12
|
+
"B",
|
|
13
|
+
"Gb",
|
|
14
|
+
"Db",
|
|
15
|
+
"Ab",
|
|
16
|
+
"Eb",
|
|
17
|
+
"Bb",
|
|
18
|
+
"F",
|
|
19
|
+
];
|
|
20
|
+
const KEY_INDEX = new Map(KEYS.map((k, i) => [k, i]));
|
|
21
|
+
/**
|
|
22
|
+
* Shortest distance along the circle of fifths between two keys.
|
|
23
|
+
* Returns 0..6 (6 = tritone-apart). Adjacent keys = 1.
|
|
24
|
+
*/
|
|
25
|
+
export function circleOfFifthsDistance(a, b) {
|
|
26
|
+
const ia = KEY_INDEX.get(a);
|
|
27
|
+
const ib = KEY_INDEX.get(b);
|
|
28
|
+
if (ia === undefined || ib === undefined) {
|
|
29
|
+
throw new Error(`unknown key: ${ia === undefined ? a : b}`);
|
|
30
|
+
}
|
|
31
|
+
const raw = Math.abs(ia - ib);
|
|
32
|
+
return Math.min(raw, KEYS.length - raw);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Adjacent keys on the circle (one step in either direction).
|
|
36
|
+
* C ↔ G, C ↔ F, etc. Smooth modulation pairs.
|
|
37
|
+
*/
|
|
38
|
+
export function adjacentKeys(k) {
|
|
39
|
+
const i = KEY_INDEX.get(k);
|
|
40
|
+
if (i === undefined)
|
|
41
|
+
throw new Error(`unknown key: ${k}`);
|
|
42
|
+
const right = KEYS[(i + 1) % KEYS.length];
|
|
43
|
+
const left = KEYS[(i - 1 + KEYS.length) % KEYS.length];
|
|
44
|
+
return [left, right];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The relative minor for each major key (parallel by 3 fifths down).
|
|
48
|
+
* Provided for completeness; the validation logic treats relative-minor
|
|
49
|
+
* modulation as zero-cost (same key signature).
|
|
50
|
+
*/
|
|
51
|
+
export const RELATIVE_MINOR = {
|
|
52
|
+
C: "Am",
|
|
53
|
+
G: "Em",
|
|
54
|
+
D: "Bm",
|
|
55
|
+
A: "F#m",
|
|
56
|
+
E: "C#m",
|
|
57
|
+
B: "G#m",
|
|
58
|
+
Gb: "Ebm",
|
|
59
|
+
Db: "Bbm",
|
|
60
|
+
Ab: "Fm",
|
|
61
|
+
Eb: "Cm",
|
|
62
|
+
Bb: "Gm",
|
|
63
|
+
F: "Dm",
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Modulation classification used by sim-verify. A jsong that moves from key A
|
|
67
|
+
* to key B is "lawful" if the move is within MODULATION_THRESHOLD (default 1,
|
|
68
|
+
* i.e., adjacent on the circle, including relative-minor equivalence).
|
|
69
|
+
* Above the threshold = "jarring" — drift signal unless explicitly bridged.
|
|
70
|
+
*/
|
|
71
|
+
export const MODULATION_THRESHOLD = 1;
|
|
72
|
+
export function classifyModulation(from, to, threshold = MODULATION_THRESHOLD) {
|
|
73
|
+
if (from === to)
|
|
74
|
+
return "stay";
|
|
75
|
+
const d = circleOfFifthsDistance(from, to);
|
|
76
|
+
return d <= threshold ? "lawful" : "jarring";
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=circle_of_fifths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circle_of_fifths.js","sourceRoot":"","sources":["../../src/circle_of_fifths.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,8EAA8E;AAC9E,wEAAwE;AACxE,+EAA+E;AAC/E,oEAAoE;AAEpE,MA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3C,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAE,CAAC;IACxD,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAkC;IAC3D,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,KAAK;IACR,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,CAAC,EAAE,IAAI;CACR,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAItC,MAAM,UAAU,kBAAkB,CAAC,IAAS,EAAE,EAAO,EAAE,YAAoB,oBAAoB;IAC7F,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,MAAM,CAAC;IAC/B,MAAM,CAAC,GAAG,sBAAsB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { type AgentInvocationContext, type AgentInvoker } from "./runtime.js";
|
|
2
|
+
import type { Registry } from "./registry.js";
|
|
3
|
+
import type { Depth, ModelTier } from "./pricing.js";
|
|
4
|
+
import { type ToolProviderRegistry } from "./tool_providers.js";
|
|
5
|
+
export declare const MODEL_TIER_MAP: Record<ModelTier, string>;
|
|
6
|
+
export declare const BELBIN_DESCRIPTIONS: Record<string, string>;
|
|
7
|
+
export declare const DEPTH_GUIDANCE: Record<Depth, string>;
|
|
8
|
+
export declare const DEPTH_MAX_TOOL_CALLS: Partial<Record<Depth, number>>;
|
|
9
|
+
export declare function buildPrompt(ctx: AgentInvocationContext, outputSchema?: Record<string, unknown>, outputSchemas?: Record<string, Record<string, unknown> | undefined>): string;
|
|
10
|
+
/**
|
|
11
|
+
* A typed extraction failure. Carries the number of balanced JSON objects found and a
|
|
12
|
+
* bounded excerpt of the raw text — previously both throws were bare `Error`s with no
|
|
13
|
+
* sample, so the operator's entire diagnostic was a V8 offset into a string never
|
|
14
|
+
* surfaced. The type is also the prerequisite for any future retry policy: runtime.ts
|
|
15
|
+
* cannot currently tell a retryable parse failure from a non-retryable contract failure.
|
|
16
|
+
*/
|
|
17
|
+
export declare class ModelOutputParseError extends Error {
|
|
18
|
+
readonly candidateCount: number;
|
|
19
|
+
readonly excerpt: string;
|
|
20
|
+
constructor(message: string, candidateCount: number, raw: string);
|
|
21
|
+
}
|
|
22
|
+
export interface ExtractJsonOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Keys the answer is expected to carry. A candidate matches only if it contains **all**
|
|
25
|
+
* of them — a partial match does not score, because "closest wins" is exactly the
|
|
26
|
+
* guess that produces silent corruption.
|
|
27
|
+
*
|
|
28
|
+
* NOTE on derivation (see `extractOptionsForChair`): the two prompt shapes are mutually
|
|
29
|
+
* exclusive, so schema property names and type slugs are chosen per-shape rather than
|
|
30
|
+
* merged into one set. A flat union is unsatisfiable under all-must-match semantics —
|
|
31
|
+
* a single-output answer `{"title":…}` can never also contain the key `finding`.
|
|
32
|
+
*/
|
|
33
|
+
expectKeys?: readonly string[] | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Set by a caller that has NO key signal at all (a bare-core output type, or a domain
|
|
36
|
+
* type absent from the registry — the same short-circuit registry.ts:140-146 takes).
|
|
37
|
+
* One candidate is unambiguous and safe; multiple candidates with nothing to choose
|
|
38
|
+
* between them is precisely the situation that silently seals the wrong object, so it
|
|
39
|
+
* fails loudly instead of guessing.
|
|
40
|
+
*/
|
|
41
|
+
requireUnambiguous?: boolean | undefined;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Extract the model's answer object from its output.
|
|
45
|
+
*
|
|
46
|
+
* Selection policy (a deliberate contract change from "the first balanced object"):
|
|
47
|
+
* 1. A candidate inside a fenced block beats one outside; among fenced, prefer the last.
|
|
48
|
+
* 2. Then `expectKeys` — a candidate must contain ALL expected keys to qualify.
|
|
49
|
+
* 3. Then the LAST surviving candidate, not the first. The prompt demands a single
|
|
50
|
+
* object (buildPrompt :146/:153), so an earlier object is evidence of scaffolding.
|
|
51
|
+
*
|
|
52
|
+
* A whole-text top-level array is handled explicitly: one element unwraps, more than one
|
|
53
|
+
* throws rather than silently discarding the array framing and every later element.
|
|
54
|
+
*/
|
|
55
|
+
export declare function extractJson(text: string, opts?: ExtractJsonOptions): Record<string, unknown>;
|
|
56
|
+
/**
|
|
57
|
+
* Build the extractor's options for a chair from what the invoker already resolved.
|
|
58
|
+
* Shared by the Claude and Bifrost invokers so the key signal reaches every call site —
|
|
59
|
+
* behaviour propagates through the shared import, but `expectKeys` does not unless each
|
|
60
|
+
* site passes it (#221 policy 5).
|
|
61
|
+
*
|
|
62
|
+
* The two prompt shapes are mutually exclusive, so the derivation is per-shape:
|
|
63
|
+
* - MULTI-output chair — buildPrompt :138-147 asks for a blob keyed by type slug, so the
|
|
64
|
+
* slugs are the expected keys.
|
|
65
|
+
* - SINGLE-output chair — buildPrompt :148-155 asks for the bare data object, never
|
|
66
|
+
* wrapped in {"<type-slug>": …}, so the resolved schema's property names are the
|
|
67
|
+
* signal. Unioning the slug in here would make the set unsatisfiable under
|
|
68
|
+
* all-must-match semantics and destroy the signal entirely.
|
|
69
|
+
* - Neither available (bare core type, or a domain type absent from the registry) —
|
|
70
|
+
* no signal, so refuse to guess between rival candidates.
|
|
71
|
+
*/
|
|
72
|
+
export declare function extractOptionsForChair(sealTypes: readonly string[], schema: Record<string, unknown> | undefined): ExtractJsonOptions;
|
|
73
|
+
export declare const DEFAULT_CHAIR_TIMEOUT_MS: number;
|
|
74
|
+
export declare const DEFAULT_ABORT_GRACE_MS = 2000;
|
|
75
|
+
/** How many chair children are alive right now (observability for the shutdown path). */
|
|
76
|
+
export declare function liveChairChildCount(): number;
|
|
77
|
+
/** SIGTERM every live chair child, escalating to SIGKILL after `graceMs`. Returns the count
|
|
78
|
+
* signalled. Called on server shutdown so a restart is not an orphaning. */
|
|
79
|
+
export declare function killLiveChairChildren(graceMs?: number): number;
|
|
80
|
+
export interface SpawnBounds {
|
|
81
|
+
timeout: number;
|
|
82
|
+
killSignal: "SIGKILL";
|
|
83
|
+
}
|
|
84
|
+
export interface ClaudeInvokerOptions {
|
|
85
|
+
bin?: string | undefined;
|
|
86
|
+
model?: string | undefined;
|
|
87
|
+
registry?: Registry | undefined;
|
|
88
|
+
mcpServers?: Record<string, unknown> | undefined;
|
|
89
|
+
toolProviders?: ToolProviderRegistry | undefined;
|
|
90
|
+
mcpServerConfigs?: Record<string, unknown> | undefined;
|
|
91
|
+
run?: ((bin: string, args: string[], spawn: SpawnBounds) => string | Promise<string>) | undefined;
|
|
92
|
+
timeout_ms?: number | undefined;
|
|
93
|
+
abort_grace_ms?: number | undefined;
|
|
94
|
+
parent_session_id?: string | undefined;
|
|
95
|
+
}
|
|
96
|
+
export declare function buildInvokerArgs(prompt: string, mcpConfigPath: string, opts: {
|
|
97
|
+
model?: string | undefined;
|
|
98
|
+
allowed_tools?: readonly string[] | undefined;
|
|
99
|
+
disallowed_tools?: readonly string[] | undefined;
|
|
100
|
+
max_tool_calls?: number | undefined;
|
|
101
|
+
}): string[];
|
|
102
|
+
export declare function makeClaudeInvoker(opts?: ClaudeInvokerOptions): AgentInvoker;
|