@tiangong-ai/cli 0.0.56 → 0.0.58
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/AGENTS.md +2 -2
- package/README.md +111 -3
- package/dist/research/orchestration.js +96 -26
- package/dist/research/orchestration.js.map +1 -1
- package/dist/research/workspace/acquisition-forecast.d.ts +18 -0
- package/dist/research/workspace/acquisition-forecast.js +116 -0
- package/dist/research/workspace/acquisition-forecast.js.map +1 -0
- package/dist/research/workspace/acquisition.d.ts +13 -1
- package/dist/research/workspace/acquisition.js +71 -62
- package/dist/research/workspace/acquisition.js.map +1 -1
- package/dist/research/workspace/artifacts.d.ts +18 -0
- package/dist/research/workspace/artifacts.js +40 -2
- package/dist/research/workspace/artifacts.js.map +1 -1
- package/dist/research/workspace/content-evidence.d.ts +37 -0
- package/dist/research/workspace/content-evidence.js +287 -137
- package/dist/research/workspace/content-evidence.js.map +1 -1
- package/dist/research/workspace/downloads.js +2 -2
- package/dist/research/workspace/downloads.js.map +1 -1
- package/dist/research/workspace/evidence-content-schema.d.ts +14 -0
- package/dist/research/workspace/evidence-content-schema.js +123 -0
- package/dist/research/workspace/evidence-content-schema.js.map +1 -0
- package/dist/research/workspace/evidence-ledger.d.ts +1 -1
- package/dist/research/workspace/evidence-ledger.js.map +1 -1
- package/dist/research/workspace/evidence-role-coverage.d.ts +35 -0
- package/dist/research/workspace/evidence-role-coverage.js +81 -0
- package/dist/research/workspace/evidence-role-coverage.js.map +1 -0
- package/dist/research/workspace/journal.d.ts +2 -0
- package/dist/research/workspace/journal.js +6 -0
- package/dist/research/workspace/journal.js.map +1 -1
- package/dist/research/workspace/preflight.d.ts +2 -0
- package/dist/research/workspace/preflight.js +14 -5
- package/dist/research/workspace/preflight.js.map +1 -1
- package/dist/research/workspace/projects.d.ts +7 -0
- package/dist/research/workspace/projects.js +65 -19
- package/dist/research/workspace/projects.js.map +1 -1
- package/dist/research/workspace/review-executor.d.ts +2 -0
- package/dist/research/workspace/review-executor.js +69 -1
- package/dist/research/workspace/review-executor.js.map +1 -1
- package/dist/research/workspace/runtime.d.ts +8 -1
- package/dist/research/workspace/runtime.js +54 -28
- package/dist/research/workspace/runtime.js.map +1 -1
- package/dist/research/workspace/schemas.js +10 -2
- package/dist/research/workspace/schemas.js.map +1 -1
- package/dist/research/workspace/scientific-design.d.ts +2 -1
- package/dist/research/workspace/scientific-design.js +39 -2
- package/dist/research/workspace/scientific-design.js.map +1 -1
- package/dist/research/workspace/scientific-review-execution.d.ts +19 -0
- package/dist/research/workspace/scientific-review-execution.js +445 -0
- package/dist/research/workspace/scientific-review-execution.js.map +1 -0
- package/dist/research/workspace/scientific-review.d.ts +110 -3
- package/dist/research/workspace/scientific-review.js +113 -20
- package/dist/research/workspace/scientific-review.js.map +1 -1
- package/dist/research/workspace/setup-catalog.js +2 -2
- package/dist/research/workspace/setup.js +23 -7
- package/dist/research/workspace/setup.js.map +1 -1
- package/dist/research/workspace/types.d.ts +4 -1
- package/dist/research/workspace/types.js +14 -1
- package/dist/research/workspace/types.js.map +1 -1
- package/dist/research/workspace/workspace.js +13 -1
- package/dist/research/workspace/workspace.js.map +1 -1
- package/package.json +1 -1
|
@@ -21,8 +21,8 @@ import { renderInputLineContext } from "./input-plan.js";
|
|
|
21
21
|
import { freezeClaimEvidenceGraph, freezeInferenceSnapshot, loadCurrentInferenceSnapshot, } from "./inference.js";
|
|
22
22
|
import { appendJournalEvent, readJournal, verifyJournal } from "./journal.js";
|
|
23
23
|
import { nativeActivityRecordSchema } from "./native-activity.js";
|
|
24
|
-
import { calculateAgentCallTokenReservation, RESEARCH_BROKER_MAX_TURNS, RESEARCH_ESTIMATED_BYTES_PER_TOKEN, RESEARCH_MAX_REPAIR_SOURCE_BYTES, RESEARCH_REPAIR_MAX_TURNS, researchStructuredOutputMaxTurns, reservedAgentPackageCost, } from "./preflight.js";
|
|
25
|
-
import { listProjects, loadProject, nextReadyPackage, packageById, refreshProject, saveProject, } from "./projects.js";
|
|
24
|
+
import { calculateAgentCallTokenReservation, RESEARCH_BROKER_MAX_TURNS, RESEARCH_ESTIMATED_BYTES_PER_TOKEN, RESEARCH_MAX_REPAIR_SOURCE_BYTES, RESEARCH_REPAIR_MAX_TURNS, researchStageContextTokenLimit, researchStructuredOutputMaxTurns, reservedAgentPackageCost, } from "./preflight.js";
|
|
25
|
+
import { blockingScientificGate, listProjects, loadProject, nextReadyPackage, packageById, refreshProject, saveProject, scientificGateRecommendedAction, } from "./projects.js";
|
|
26
26
|
import { assertResearchPolicyBinding } from "./research-policy.js";
|
|
27
27
|
import { assertScientificGateForStage } from "./scientific-review.js";
|
|
28
28
|
import { configuredResearchSecrets, sanitizeResearchRecord, sanitizeResearchText, } from "./sanitization.js";
|
|
@@ -439,6 +439,7 @@ export async function prepareNativeResearchStage(input) {
|
|
|
439
439
|
discovery,
|
|
440
440
|
limits: {
|
|
441
441
|
maxOutputBytes: config.budget.maxBytesPerPackage,
|
|
442
|
+
maxArtifactBytes: config.budget.maxBytesPerArtifact,
|
|
442
443
|
maxOutputTokens: stageOutputTokens,
|
|
443
444
|
reservedPackageTokens,
|
|
444
445
|
reservedMaxCostUsd: reservation.costUsd,
|
|
@@ -534,6 +535,24 @@ export async function prepareNativeResearchStage(input) {
|
|
|
534
535
|
catalog: dataCapabilities,
|
|
535
536
|
}
|
|
536
537
|
: null,
|
|
538
|
+
forecastAcquisition: input.stage === "acquire"
|
|
539
|
+
? {
|
|
540
|
+
argv: [
|
|
541
|
+
"tiangong-ai",
|
|
542
|
+
"research",
|
|
543
|
+
"project",
|
|
544
|
+
"evidence",
|
|
545
|
+
"content",
|
|
546
|
+
"forecast",
|
|
547
|
+
project.id,
|
|
548
|
+
"--input",
|
|
549
|
+
"<absolute-acquisition-audit.json>",
|
|
550
|
+
"--workspace",
|
|
551
|
+
input.root,
|
|
552
|
+
"--json",
|
|
553
|
+
],
|
|
554
|
+
}
|
|
555
|
+
: null,
|
|
537
556
|
registerArtifact: input.stage === "acquire"
|
|
538
557
|
? {
|
|
539
558
|
argv: [
|
|
@@ -3061,17 +3080,7 @@ async function stageContextForPackage(capsuleProject, project, workPackage, conf
|
|
|
3061
3080
|
}
|
|
3062
3081
|
const bundled = sections.join("\n\n");
|
|
3063
3082
|
const estimatedTokens = Math.ceil(Buffer.byteLength(bundled, "utf8") / RESEARCH_ESTIMATED_BYTES_PER_TOKEN);
|
|
3064
|
-
const maxStageContextTokens = workPackage.stage
|
|
3065
|
-
? config.budget.maxInputContextTokens
|
|
3066
|
-
: workPackage.stage === "review"
|
|
3067
|
-
? config.budget.maxInputContextTokens + config.budget.maxOutputTokens * 4
|
|
3068
|
-
: workPackage.stage === "synthesize"
|
|
3069
|
-
? config.budget.maxInputContextTokens
|
|
3070
|
-
: workPackage.stage === "analyze"
|
|
3071
|
-
? config.budget.maxInputContextTokens
|
|
3072
|
-
: workPackage.stage === "acquire"
|
|
3073
|
-
? config.budget.maxOutputTokens
|
|
3074
|
-
: 0;
|
|
3083
|
+
const maxStageContextTokens = researchStageContextTokenLimit(config, workPackage.stage, project.lineage.kind === "addendum");
|
|
3075
3084
|
if (estimatedTokens > maxStageContextTokens) {
|
|
3076
3085
|
throw new CliError(`Admitted stage context exceeds the configured input context limit for ${workPackage.id}.`, {
|
|
3077
3086
|
code: "RESEARCH_INPUT_CONTEXT_BUDGET_EXCEEDED",
|
|
@@ -3080,6 +3089,9 @@ async function stageContextForPackage(capsuleProject, project, workPackage, conf
|
|
|
3080
3089
|
packageId: workPackage.id,
|
|
3081
3090
|
estimatedTokens,
|
|
3082
3091
|
maxStageContextTokens,
|
|
3092
|
+
limitField: "budget.maxInputContextTokens",
|
|
3093
|
+
contextPaths: logicalPaths,
|
|
3094
|
+
recommendedAction: "Keep frozen evidence unchanged. Use research project fork to regenerate a bounded context with concise metadata, or explicitly review budget.maxInputContextTokens in .tiangong-research/config.json and rerun project preflight plus workspace doctor before preparing this stage again. Do not raise output limits to accommodate input context.",
|
|
3083
3095
|
},
|
|
3084
3096
|
});
|
|
3085
3097
|
}
|
|
@@ -3502,27 +3514,34 @@ async function dryRunResult(root, requestId, projectId) {
|
|
|
3502
3514
|
stopReason: "dry-run",
|
|
3503
3515
|
cycles: 0,
|
|
3504
3516
|
executed: [],
|
|
3505
|
-
projects: projects.map((project) => (
|
|
3506
|
-
id: project.id,
|
|
3507
|
-
status: refreshProject(project).status,
|
|
3508
|
-
readyPackage: nextReadyPackage(project)?.id ?? null,
|
|
3509
|
-
usage: project.usage,
|
|
3510
|
-
})),
|
|
3517
|
+
projects: projects.map((project) => projectRunSummary(root, project)),
|
|
3511
3518
|
};
|
|
3512
3519
|
}
|
|
3513
|
-
|
|
3514
|
-
const
|
|
3515
|
-
const
|
|
3520
|
+
function projectRunSummary(root, project) {
|
|
3521
|
+
const readyPackage = nextReadyPackage(project)?.id ?? null;
|
|
3522
|
+
const scientificGate = blockingScientificGate(project);
|
|
3523
|
+
return {
|
|
3516
3524
|
id: project.id,
|
|
3517
|
-
status:
|
|
3518
|
-
readyPackage
|
|
3525
|
+
status: project.status,
|
|
3526
|
+
readyPackage,
|
|
3527
|
+
scientificGate,
|
|
3528
|
+
recommendedAction: scientificGateRecommendedAction(root, project, scientificGate),
|
|
3519
3529
|
usage: project.usage,
|
|
3520
|
-
}
|
|
3530
|
+
};
|
|
3531
|
+
}
|
|
3532
|
+
async function summarizeRun(root, requestId, cycles, executed, maxCycles, projectId) {
|
|
3533
|
+
const projects = await projectsForRun(root, projectId);
|
|
3534
|
+
const summaries = projects.map((project) => projectRunSummary(root, project));
|
|
3521
3535
|
const unfinished = summaries.filter((project) => project.status !== "complete");
|
|
3522
3536
|
const waiting = unfinished.filter((project) => project.status === "waiting-user" || project.status === "waiting-external");
|
|
3523
3537
|
const hasReadyPackage = summaries.some((project) => project.readyPackage !== null);
|
|
3524
|
-
const nativeStageRequired = projects.some((project
|
|
3525
|
-
|
|
3538
|
+
const nativeStageRequired = projects.some((project, index) => {
|
|
3539
|
+
const summary = summaries[index];
|
|
3540
|
+
if (summary.scientificGate || !["ready", "running"].includes(summary.status))
|
|
3541
|
+
return false;
|
|
3542
|
+
return project.packages.some((workPackage) => workPackage.executor === "producer" &&
|
|
3543
|
+
(workPackage.id === summary.readyPackage || workPackage.status === "running"));
|
|
3544
|
+
});
|
|
3526
3545
|
const status = summaries.length > 0 && summaries.every((project) => project.status === "complete")
|
|
3527
3546
|
? "complete"
|
|
3528
3547
|
: waiting.length > 0 &&
|
|
@@ -3533,6 +3552,13 @@ async function summarizeRun(root, requestId, cycles, executed, maxCycles, projec
|
|
|
3533
3552
|
: unfinished.length > 0 && unfinished.every((project) => project.status === "blocked")
|
|
3534
3553
|
? "blocked"
|
|
3535
3554
|
: "ready";
|
|
3555
|
+
const scientificStop = unfinished.length > 0 && unfinished.every((project) => project.scientificGate)
|
|
3556
|
+
? unfinished.some((project) => project.scientificGate?.status === "stopped")
|
|
3557
|
+
? "scientific-stopped"
|
|
3558
|
+
: unfinished.some((project) => project.scientificGate?.status === "revision-required")
|
|
3559
|
+
? "scientific-revision-required"
|
|
3560
|
+
: "scientific-review-required"
|
|
3561
|
+
: null;
|
|
3536
3562
|
const stopReason = summaries.length === 0
|
|
3537
3563
|
? "no-projects"
|
|
3538
3564
|
: status === "complete"
|
|
@@ -3544,7 +3570,7 @@ async function summarizeRun(root, requestId, cycles, executed, maxCycles, projec
|
|
|
3544
3570
|
: nativeStageRequired
|
|
3545
3571
|
? "native-stage-required"
|
|
3546
3572
|
: status === "blocked"
|
|
3547
|
-
? "project-blocked"
|
|
3573
|
+
? (scientificStop ?? "project-blocked")
|
|
3548
3574
|
: "no-ready-work";
|
|
3549
3575
|
return {
|
|
3550
3576
|
workspace: root,
|