@citeark/agent 0.3.20
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 +202 -0
- package/README.md +128 -0
- package/data/dataset-source-registry.v1.json +300 -0
- package/dist/arkgraph/boot.js +6 -0
- package/dist/arkgraph/index.html +1 -0
- package/dist/arkgraph/viewer.css +1 -0
- package/dist/arkgraph/viewer.en.css +1 -0
- package/dist/arkgraph/viewer.en.js +49 -0
- package/dist/arkgraph/viewer.en.js.LEGAL.txt +56 -0
- package/dist/arkgraph/viewer.js +49 -0
- package/dist/arkgraph/viewer.js.LEGAL.txt +56 -0
- package/docker/claude-code/Dockerfile +97 -0
- package/docker/claude-code/codex-pro-relay.mjs +466 -0
- package/docker/claude-code/runtime-contract-check.mjs +79 -0
- package/docs/arkgraph-reading.md +79 -0
- package/docs/configuration.md +100 -0
- package/docs/integration.md +92 -0
- package/docs/maturity-plan.md +27 -0
- package/docs/npm-release.md +44 -0
- package/docs/paper-reading.md +40 -0
- package/docs/research-plan-granularity.md +27 -0
- package/docs/terminal.md +49 -0
- package/examples/toy-evaluation/compile-task.json +27 -0
- package/examples/toy-evaluation/paper.md +5 -0
- package/examples/toy-evaluation/repository/README.md +9 -0
- package/examples/toy-evaluation/repository/checkpoint.json +4 -0
- package/examples/toy-evaluation/repository/evaluate.py +17 -0
- package/examples/toy-evaluation/task.json +81 -0
- package/package.json +59 -0
- package/prompts/compile-research.md +58 -0
- package/prompts/execute-contract.md +72 -0
- package/prompts/execute-workspace-simple.md +51 -0
- package/prompts/execute-workspace.md +34 -0
- package/prompts/prepare-reproduction.md +82 -0
- package/prompts/repair-research.md +45 -0
- package/protocol/CAP.md +129 -0
- package/protocol/LICENSE +12 -0
- package/protocol/MAPPINGS.md +72 -0
- package/protocol/README.md +38 -0
- package/protocol/conformance-v2.0-alpha.1.json +36 -0
- package/protocol/examples/arkgraph/checkpoint-evaluation.json +309 -0
- package/protocol/examples/arkgraph/fixtures.mjs +49 -0
- package/protocol/examples/arkgraph/paper-free.json +291 -0
- package/protocol/examples/arkgraph/partial-failure.json +344 -0
- package/protocol/examples/arkgraph/training-evaluation.json +443 -0
- package/protocol/profiles/agent-trace.md +16 -0
- package/protocol/profiles/computational-run.md +16 -0
- package/protocol/profiles/core.md +15 -0
- package/protocol/profiles/public-bundle.md +18 -0
- package/protocol/profiles/reproduction.md +29 -0
- package/protocol/profiles/research-compilation.md +44 -0
- package/protocol/profiles/research-plan.md +39 -0
- package/protocol/profiles/restricted-evidence.md +15 -0
- package/runtime/bootstrap-autodl-runtime.sh +314 -0
- package/runtime/create-runtime-venv.sh +41 -0
- package/runtime/install-local-cpu-runtime.sh +23 -0
- package/runtime/install-scientific-runtime.sh +153 -0
- package/runtime/mineru/parse.py +62 -0
- package/runtime/mineru/requirements.txt +4 -0
- package/runtime/requirements-baseline.txt +38 -0
- package/schemas/cap/v2/activity.schema.json +47 -0
- package/schemas/cap/v2/agent.schema.json +32 -0
- package/schemas/cap/v2/assertion.schema.json +110 -0
- package/schemas/cap/v2/descriptor.schema.json +243 -0
- package/schemas/cap/v2/entity.schema.json +64 -0
- package/schemas/cap/v2/manifest.schema.json +67 -0
- package/schemas/cap/v2/relation.schema.json +82 -0
- package/schemas/compute-catalog.schema.json +63 -0
- package/schemas/compute-decision.schema.json +27 -0
- package/schemas/execution-contract.schema.json +1024 -0
- package/schemas/research-card.schema.json +30 -0
- package/schemas/research-inventory-draft.schema.json +366 -0
- package/schemas/research.schema.json +1044 -0
- package/schemas/result.schema.json +173 -0
- package/schemas/verification-policy.schema.json +47 -0
- package/schemas/verified-conclusion.schema.json +58 -0
- package/schemas/workspace-summary.schema.json +24 -0
- package/scripts/build-arkgraph-view.mjs +12 -0
- package/scripts/check-execution-feasibility.mjs +24 -0
- package/scripts/check-syntax.mjs +15 -0
- package/scripts/deterministic-asset-preparation.py +438 -0
- package/scripts/package-cap.mjs +23 -0
- package/scripts/package-local-agent.mjs +23 -0
- package/scripts/preview-arkgraph.mjs +25 -0
- package/scripts/replay-research-compiler-candidate.mjs +134 -0
- package/scripts/review-compiler-sources.mjs +44 -0
- package/scripts/run-asset-preparation.sh +17 -0
- package/scripts/run-research-plan.mjs +98 -0
- package/scripts/validate-asset-preparation.py +290 -0
- package/scripts/verify-local-runtime.mjs +57 -0
- package/scripts/verify-npm-package.mjs +57 -0
- package/src/adapters/paper2agent.mjs +107 -0
- package/src/assets/cache.mjs +159 -0
- package/src/assets/compute.mjs +98 -0
- package/src/assets/executor.mjs +145 -0
- package/src/assets/lifecycle.mjs +213 -0
- package/src/assets/manifest.mjs +242 -0
- package/src/assets/opportunistic-preparation.mjs +81 -0
- package/src/assets/plan.mjs +411 -0
- package/src/assets/prompts.mjs +29 -0
- package/src/assets/public-asset-probe.mjs +525 -0
- package/src/assets/qualification.mjs +119 -0
- package/src/assets/readiness.mjs +130 -0
- package/src/assets/reproduction-admission.mjs +355 -0
- package/src/assets/requirements.mjs +152 -0
- package/src/assets/source-grounding.mjs +341 -0
- package/src/assets/source-policy.mjs +118 -0
- package/src/autodl/client.mjs +260 -0
- package/src/autodl/ssh.mjs +380 -0
- package/src/autodl/tools.mjs +129 -0
- package/src/cap/redaction.mjs +38 -0
- package/src/cap/v2/archive.mjs +152 -0
- package/src/cap/v2/attestation.mjs +204 -0
- package/src/cap/v2/canonical-json.mjs +114 -0
- package/src/cap/v2/compilation-artifact.mjs +240 -0
- package/src/cap/v2/core.mjs +282 -0
- package/src/cap/v2/measurement-assessment-records.mjs +23 -0
- package/src/cap/v2/pipeline-artifact.mjs +922 -0
- package/src/cap/v2/read.mjs +41 -0
- package/src/cap/v2/reassessment-artifact.mjs +383 -0
- package/src/cap/v2/research-artifact.mjs +231 -0
- package/src/cap/v2/research-map-records.mjs +46 -0
- package/src/cap/v2/research-object-records.mjs +163 -0
- package/src/cap/v2/research-records.mjs +187 -0
- package/src/cap/v2/verify.mjs +642 -0
- package/src/cli.mjs +1146 -0
- package/src/compute/autodl-pro-compiler.mjs +347 -0
- package/src/compute/autodl-pro-executor.mjs +459 -0
- package/src/compute/autodl-pro-job.mjs +843 -0
- package/src/compute/autodl-pro-network.mjs +295 -0
- package/src/compute/autodl-pro-remote.mjs +810 -0
- package/src/compute/autodl-pro-staging.mjs +117 -0
- package/src/compute/campaign.mjs +110 -0
- package/src/compute/catalog.mjs +123 -0
- package/src/compute/checkpoint-protocol.mjs +154 -0
- package/src/compute/codex-account-lock.mjs +111 -0
- package/src/compute/codex-account-session.mjs +107 -0
- package/src/compute/compiler-profile.mjs +38 -0
- package/src/compute/compiler-router.mjs +23 -0
- package/src/compute/coordinator-recovery.mjs +210 -0
- package/src/compute/executor-router.mjs +29 -0
- package/src/compute/gcp-batch-compiler.mjs +685 -0
- package/src/compute/gcp-batch-executor.mjs +1215 -0
- package/src/compute/gcp-batch-failure.mjs +92 -0
- package/src/compute/gcp-batch-job.mjs +527 -0
- package/src/compute/gcp-batch-lifecycle.mjs +81 -0
- package/src/compute/gcp-checkpoint-worker.mjs +1633 -0
- package/src/compute/local-codex-compiler.mjs +52 -0
- package/src/compute/measurement-hardware.mjs +128 -0
- package/src/compute/remote-attempt.mjs +226 -0
- package/src/compute/requirements.mjs +124 -0
- package/src/compute/research-phases.mjs +48 -0
- package/src/compute/scheduler.mjs +452 -0
- package/src/compute/shared-workloads.mjs +26 -0
- package/src/compute/stage-archive.mjs +79 -0
- package/src/contracts/campaign-contract.mjs +52 -0
- package/src/contracts/execution-contract.mjs +819 -0
- package/src/contracts/execution-mode.mjs +19 -0
- package/src/contracts/execution-timeouts.mjs +45 -0
- package/src/contracts/execution-workload.mjs +68 -0
- package/src/contracts/preflight-schema.mjs +25 -0
- package/src/contracts/public-contract.mjs +63 -0
- package/src/contracts/subject-tags.mjs +31 -0
- package/src/dashboard/data.mjs +898 -0
- package/src/dashboard/server.mjs +79 -0
- package/src/dashboard/static/dashboard.css +366 -0
- package/src/dashboard/static/dashboard.js +560 -0
- package/src/dashboard/static/index.html +85 -0
- package/src/deployment/community-policy.mjs +9 -0
- package/src/deployment/environment.mjs +112 -0
- package/src/deployment/guided.mjs +98 -0
- package/src/deployment/handoff.mjs +102 -0
- package/src/deployment/local-contract.mjs +31 -0
- package/src/deployment/local.mjs +100 -0
- package/src/deployment/prepare.mjs +46 -0
- package/src/deployment/recipe.mjs +108 -0
- package/src/deployment/supplement.mjs +51 -0
- package/src/deployment/terminal.mjs +43 -0
- package/src/diagnosis/renderer.mjs +75 -0
- package/src/diagnosis/target-failure.mjs +46 -0
- package/src/evidence/parser-registry.mjs +54 -0
- package/src/evidence/parsers/fasttext-classification.mjs +82 -0
- package/src/evidence/parsers/json-scalar.mjs +96 -0
- package/src/evidence/parsers/simcse-senteval.mjs +104 -0
- package/src/evidence/parsers/starspace-classification.mjs +78 -0
- package/src/evidence/registry.mjs +147 -0
- package/src/execution/runner-audit.mjs +473 -0
- package/src/gcp/auth.mjs +106 -0
- package/src/gcp/batch-client.mjs +120 -0
- package/src/gcp/resource-discovery.mjs +177 -0
- package/src/gcp/rest.mjs +82 -0
- package/src/gcp/secret-manager.mjs +34 -0
- package/src/gcp/signed-url.mjs +133 -0
- package/src/gcp/storage.mjs +220 -0
- package/src/graph/command.mjs +41 -0
- package/src/graph/execution.mjs +97 -0
- package/src/graph/model.mjs +37 -0
- package/src/graph/presentation.mjs +110 -0
- package/src/graph/query.mjs +159 -0
- package/src/graph/research-relations.mjs +69 -0
- package/src/graph/source-page.mjs +12 -0
- package/src/graph/source-preview.mjs +34 -0
- package/src/graph/validate.mjs +76 -0
- package/src/job.mjs +496 -0
- package/src/network/autodl-routing-proxy.mjs +462 -0
- package/src/network/egress-proxy.mjs +158 -0
- package/src/observability/event-contract.mjs +230 -0
- package/src/observability/pipeline-monitor.mjs +166 -0
- package/src/pipeline/orchestrator.mjs +1281 -0
- package/src/pipeline/recovery-error.mjs +11 -0
- package/src/pipeline/replay.mjs +304 -0
- package/src/pipeline/shared-execution.mjs +115 -0
- package/src/pipeline/stage-checkpoint.mjs +86 -0
- package/src/pipeline/stage-recovery.mjs +101 -0
- package/src/pipeline/targets.mjs +110 -0
- package/src/process.mjs +143 -0
- package/src/protocol.mjs +312 -0
- package/src/provider/codex-account.mjs +44 -0
- package/src/provider/codex-completion.mjs +49 -0
- package/src/provider/completion.mjs +292 -0
- package/src/provider/model-client.mjs +44 -0
- package/src/provider/model-route.mjs +29 -0
- package/src/provider/openrouter-readiness.mjs +189 -0
- package/src/provider/reader-bridge.mjs +35 -0
- package/src/provider/relay.mjs +263 -0
- package/src/provider/runtime-auth.mjs +40 -0
- package/src/public/cap.d.mts +90 -0
- package/src/public/cap.mjs +12 -0
- package/src/public/contracts.d.mts +2 -0
- package/src/public/host.mjs +171 -0
- package/src/public/operations.d.mts +11 -0
- package/src/public/presentation.d.mts +4 -0
- package/src/records/views.mjs +26 -0
- package/src/remote/command.mjs +178 -0
- package/src/remote/ssh.mjs +59 -0
- package/src/repository-origin.mjs +81 -0
- package/src/reproduction/evidence-feedback.mjs +96 -0
- package/src/reproduction/incomplete-initialization.mjs +25 -0
- package/src/reproduction/lifecycle.mjs +253 -0
- package/src/reproduction/plan.mjs +132 -0
- package/src/reproduction/prompts.mjs +70 -0
- package/src/reproduction/runner.mjs +188 -0
- package/src/reproduction/summary.mjs +130 -0
- package/src/reproduction/workspace-mode.mjs +7 -0
- package/src/research/automatic-admission.mjs +156 -0
- package/src/research/compiler-coverage.mjs +85 -0
- package/src/research/compiler-failure.mjs +24 -0
- package/src/research/compiler-normalization-guards.mjs +112 -0
- package/src/research/compiler-repair.mjs +3 -0
- package/src/research/compiler.mjs +853 -0
- package/src/research/continuation-selection.mjs +26 -0
- package/src/research/execution-graph-context.mjs +43 -0
- package/src/research/experiment-importance.mjs +15 -0
- package/src/research/inventory-handoff.mjs +104 -0
- package/src/research/inventory-revisions.mjs +32 -0
- package/src/research/mineru-local.mjs +73 -0
- package/src/research/paper-command.mjs +19 -0
- package/src/research/paper-markdown.mjs +180 -0
- package/src/research/paper-source-map.mjs +69 -0
- package/src/research/planning-policy.mjs +88 -0
- package/src/research/reference-materials.mjs +11 -0
- package/src/research/reproduction-scope.mjs +30 -0
- package/src/research/research-map.mjs +94 -0
- package/src/research/research-objects.mjs +88 -0
- package/src/research/source-discovery.mjs +646 -0
- package/src/research/source-observations.mjs +75 -0
- package/src/research/source-review-cli-mcp.mjs +26 -0
- package/src/research/source-review-input.mjs +209 -0
- package/src/research/source-review-local-codex.mjs +36 -0
- package/src/research/source-review-model.mjs +70 -0
- package/src/research/source-review.mjs +173 -0
- package/src/research/structure.mjs +3163 -0
- package/src/research-card/renderer.mjs +277 -0
- package/src/research-card/verified-conclusion.mjs +143 -0
- package/src/results/output-registry.mjs +183 -0
- package/src/runtime/claude-code.mjs +52 -0
- package/src/runtime/codex-capacity-retry.mjs +87 -0
- package/src/runtime/codex.mjs +64 -0
- package/src/runtime/config.mjs +157 -0
- package/src/runtime/final-output.mjs +40 -0
- package/src/runtime/index.mjs +21 -0
- package/src/runtime/local-codex.mjs +74 -0
- package/src/runtime/opencode.mjs +95 -0
- package/src/runtime/prompt.mjs +13 -0
- package/src/sandbox/docker.mjs +363 -0
- package/src/settings/command.mjs +297 -0
- package/src/settings/store.mjs +119 -0
- package/src/telemetry/pricing.mjs +68 -0
- package/src/telemetry/usage.mjs +265 -0
- package/src/terminal/events.mjs +97 -0
- package/src/terminal/input.mjs +40 -0
- package/src/terminal/plain.mjs +40 -0
- package/src/terminal/remote-stream.mjs +22 -0
- package/src/terminal/screen.mjs +214 -0
- package/src/terminal/transcript.mjs +69 -0
- package/src/util.mjs +107 -0
- package/src/verification/ai-assessor.mjs +534 -0
- package/src/verification/claim-evaluator.mjs +242 -0
- package/src/verification/evidence-context.mjs +165 -0
- package/src/verification/evidence-reader.mjs +95 -0
- package/src/verification/integrity.mjs +570 -0
- package/src/verification/tolerance.mjs +32 -0
- package/src/workloads/cpu-research-preparation.mjs +56 -0
- package/src/workloads/definition.mjs +74 -0
- package/src/workloads/phase-aware-reproduction.mjs +46 -0
- package/src/workloads/reproduction.mjs +85 -0
- package/src/workspace/command.mjs +242 -0
- package/src/workspace/control.mjs +49 -0
- package/src/workspace/entry.mjs +28 -0
- package/src/workspace/input.mjs +93 -0
- package/src/workspace/interactive.mjs +94 -0
- package/src/workspace/jobs.mjs +418 -0
- package/src/workspace/session.mjs +97 -0
- package/src/workspace/worker.mjs +137 -0
- package/ui/arkgraph/ambient-motion.mjs +10 -0
- package/ui/arkgraph/app.jsx +153 -0
- package/ui/arkgraph/boot.js +6 -0
- package/ui/arkgraph/camera-motion.mjs +20 -0
- package/ui/arkgraph/context-reveal.mjs +39 -0
- package/ui/arkgraph/details.css +3 -0
- package/ui/arkgraph/entry.jsx +28 -0
- package/ui/arkgraph/experiment-curves.mjs +17 -0
- package/ui/arkgraph/experiment-selection.mjs +15 -0
- package/ui/arkgraph/experiment-style.css +26 -0
- package/ui/arkgraph/experiment-ui.jsx +32 -0
- package/ui/arkgraph/frame.html +1 -0
- package/ui/arkgraph/graph-gestures.mjs +62 -0
- package/ui/arkgraph/label-layout.mjs +57 -0
- package/ui/arkgraph/locales/en.json +229 -0
- package/ui/arkgraph/locales/source-types.json +15 -0
- package/ui/arkgraph/localization-build.mjs +27 -0
- package/ui/arkgraph/material-build.mjs +23 -0
- package/ui/arkgraph/material-colors.mjs +39 -0
- package/ui/arkgraph/material-style.css +15 -0
- package/ui/arkgraph/open-graph.jsx +326 -0
- package/ui/arkgraph/outline.jsx +49 -0
- package/ui/arkgraph/package-lock.json +888 -0
- package/ui/arkgraph/package.json +17 -0
- package/ui/arkgraph/reading-layout.mjs +130 -0
- package/ui/arkgraph/reading-presentation.mjs +73 -0
- package/ui/arkgraph/record-detail.css +51 -0
- package/ui/arkgraph/record-details.jsx +29 -0
- package/ui/arkgraph/research-types.mjs +31 -0
- package/ui/arkgraph/selection-mark.jsx +6 -0
- package/ui/arkgraph/soft-spine.mjs +26 -0
- package/ui/arkgraph/steering-style.css +187 -0
- package/ui/arkgraph/style.css +272 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { randomBytes, timingSafeEqual } from "node:crypto";
|
|
2
|
+
import http from "node:http";
|
|
3
|
+
import { Readable } from "node:stream";
|
|
4
|
+
|
|
5
|
+
import { CiteArkError } from "../util.mjs";
|
|
6
|
+
import { executeObservedExternalRequest } from "../observability/event-contract.mjs";
|
|
7
|
+
import { rewriteGeminiToolText } from "../../docker/claude-code/codex-pro-relay.mjs";
|
|
8
|
+
|
|
9
|
+
const MAX_REQUEST_BYTES = 32 * 1024 * 1024;
|
|
10
|
+
const PROTOCOL_PATHS = Object.freeze({
|
|
11
|
+
"anthropic-messages": new Set([
|
|
12
|
+
"/v1/messages",
|
|
13
|
+
"/v1/messages/count_tokens",
|
|
14
|
+
]),
|
|
15
|
+
"openai-responses": new Set([
|
|
16
|
+
"/v1/responses",
|
|
17
|
+
"/v1/responses/compact",
|
|
18
|
+
"/v1/models",
|
|
19
|
+
]),
|
|
20
|
+
"openai-chat-completions": new Set([
|
|
21
|
+
"/v1/chat/completions",
|
|
22
|
+
"/v1/models",
|
|
23
|
+
]),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export function previewProviderSession(runtimeAgent) {
|
|
27
|
+
return {
|
|
28
|
+
mode: "host-credential-relay",
|
|
29
|
+
apiProtocol: runtimeAgent.api.protocol,
|
|
30
|
+
credentialSource: runtimeAgent.api.credentialSource,
|
|
31
|
+
credentialInjectedIntoSandbox: false,
|
|
32
|
+
containerBaseUrl: "http://host.docker.internal:<relay-port>",
|
|
33
|
+
containerCredential: "<ephemeral-relay-token>",
|
|
34
|
+
close: async () => {},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function startProviderSession(runtimeAgent, {
|
|
39
|
+
observe,
|
|
40
|
+
correlation = {},
|
|
41
|
+
} = {}) {
|
|
42
|
+
const { api } = runtimeAgent;
|
|
43
|
+
if (!api.apiKey) throw new CiteArkError("缺少本次运行的 API Key");
|
|
44
|
+
if (!PROTOCOL_PATHS[api.protocol]) {
|
|
45
|
+
throw new CiteArkError(`不支持的模型 API 协议:${api.protocol}`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const relayToken = randomBytes(32).toString("base64url");
|
|
49
|
+
const activeControllers = new Set();
|
|
50
|
+
const server = http.createServer((request, response) => {
|
|
51
|
+
relayRequest({
|
|
52
|
+
request,
|
|
53
|
+
response,
|
|
54
|
+
relayToken,
|
|
55
|
+
api,
|
|
56
|
+
reasoningMode: runtimeAgent.reasoningMode,
|
|
57
|
+
activeControllers,
|
|
58
|
+
observe,
|
|
59
|
+
correlation: {
|
|
60
|
+
...correlation,
|
|
61
|
+
protocol: api.protocol,
|
|
62
|
+
model: runtimeAgent.model,
|
|
63
|
+
},
|
|
64
|
+
}).catch(
|
|
65
|
+
(error) => {
|
|
66
|
+
if (!response.headersSent) response.writeHead(502);
|
|
67
|
+
response.end("provider relay error");
|
|
68
|
+
process.stderr.write(
|
|
69
|
+
`CiteArk Provider Relay:${error instanceof Error ? error.message : String(error)}\n`,
|
|
70
|
+
);
|
|
71
|
+
},
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
await new Promise((resolve, reject) => {
|
|
76
|
+
server.once("error", reject);
|
|
77
|
+
server.listen(0, "0.0.0.0", resolve);
|
|
78
|
+
});
|
|
79
|
+
const address = server.address();
|
|
80
|
+
if (!address || typeof address === "string") {
|
|
81
|
+
await closeServer(server);
|
|
82
|
+
throw new CiteArkError("无法取得 Provider 密钥隔离代理的监听端口");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
mode: "host-credential-relay",
|
|
87
|
+
apiProtocol: api.protocol,
|
|
88
|
+
credentialSource: api.credentialSource,
|
|
89
|
+
credentialInjectedIntoSandbox: false,
|
|
90
|
+
containerBaseUrl: `http://host.docker.internal:${address.port}`,
|
|
91
|
+
containerCredential: relayToken,
|
|
92
|
+
close: async () => await closeServer(server, activeControllers),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function relayRequest({
|
|
97
|
+
request,
|
|
98
|
+
response,
|
|
99
|
+
relayToken,
|
|
100
|
+
api,
|
|
101
|
+
reasoningMode,
|
|
102
|
+
activeControllers,
|
|
103
|
+
observe,
|
|
104
|
+
correlation,
|
|
105
|
+
}) {
|
|
106
|
+
const requestUrl = new URL(request.url ?? "/", "http://citeark-relay.local");
|
|
107
|
+
const allowedPaths = PROTOCOL_PATHS[api.protocol];
|
|
108
|
+
const allowedMethod =
|
|
109
|
+
request.method === "POST" ||
|
|
110
|
+
(request.method === "GET" && requestUrl.pathname === "/v1/models");
|
|
111
|
+
if (!allowedMethod || !allowedPaths.has(requestUrl.pathname)) {
|
|
112
|
+
response.writeHead(404).end();
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (!authorized(request, relayToken)) {
|
|
116
|
+
response.writeHead(401).end();
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
let body = request.method === "POST" ? await readRequestBody(request) : undefined;
|
|
121
|
+
if (
|
|
122
|
+
new Set(["openai-responses", "openai-chat-completions"]).has(api.protocol) &&
|
|
123
|
+
new Set(["/v1/responses", "/v1/chat/completions"]).has(requestUrl.pathname) &&
|
|
124
|
+
reasoningMode === "pro"
|
|
125
|
+
) {
|
|
126
|
+
body = injectReasoningMode(body, reasoningMode);
|
|
127
|
+
}
|
|
128
|
+
body = rewriteGeminiToolText(body, api.baseUrl, requestUrl.pathname);
|
|
129
|
+
const headers = copyRequestHeaders(request.headers);
|
|
130
|
+
headers.delete("authorization");
|
|
131
|
+
headers.delete("x-api-key");
|
|
132
|
+
if (api.protocol === "anthropic-messages") {
|
|
133
|
+
headers.set("x-api-key", api.apiKey);
|
|
134
|
+
} else {
|
|
135
|
+
headers.set("authorization", `Bearer ${api.apiKey}`);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const controller = new AbortController();
|
|
139
|
+
activeControllers.add(controller);
|
|
140
|
+
try {
|
|
141
|
+
const targetUrl = upstreamUrl(api.baseUrl, requestUrl);
|
|
142
|
+
const upstream = await executeObservedExternalRequest({
|
|
143
|
+
request: async () => await fetch(targetUrl, {
|
|
144
|
+
method: request.method,
|
|
145
|
+
headers,
|
|
146
|
+
body,
|
|
147
|
+
signal: controller.signal,
|
|
148
|
+
}),
|
|
149
|
+
observe,
|
|
150
|
+
component: "provider_relay",
|
|
151
|
+
service: targetUrl.hostname,
|
|
152
|
+
operation: requestUrl.pathname,
|
|
153
|
+
method: request.method,
|
|
154
|
+
url: targetUrl,
|
|
155
|
+
correlation,
|
|
156
|
+
});
|
|
157
|
+
response.statusCode = upstream.status;
|
|
158
|
+
upstream.headers.forEach((value, name) => {
|
|
159
|
+
if (!hopByHopHeader(name)) response.setHeader(name, value);
|
|
160
|
+
});
|
|
161
|
+
response.flushHeaders();
|
|
162
|
+
if (!upstream.body) {
|
|
163
|
+
response.end();
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
await new Promise((resolve, reject) => {
|
|
167
|
+
const stream = Readable.fromWeb(upstream.body);
|
|
168
|
+
stream.once("error", reject);
|
|
169
|
+
response.once("error", reject);
|
|
170
|
+
response.once("finish", resolve);
|
|
171
|
+
stream.pipe(response);
|
|
172
|
+
});
|
|
173
|
+
} finally {
|
|
174
|
+
activeControllers.delete(controller);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function injectReasoningMode(body, reasoningMode) {
|
|
179
|
+
let payload;
|
|
180
|
+
try {
|
|
181
|
+
payload = JSON.parse(Buffer.from(body ?? []).toString("utf8"));
|
|
182
|
+
} catch {
|
|
183
|
+
throw new CiteArkError("Responses 请求不是有效 JSON");
|
|
184
|
+
}
|
|
185
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
186
|
+
throw new CiteArkError("Responses 请求必须是对象");
|
|
187
|
+
}
|
|
188
|
+
const reasoning = payload.reasoning && typeof payload.reasoning === "object" && !Array.isArray(payload.reasoning)
|
|
189
|
+
? payload.reasoning
|
|
190
|
+
: {};
|
|
191
|
+
return Buffer.from(JSON.stringify({
|
|
192
|
+
...payload,
|
|
193
|
+
reasoning: { ...reasoning, mode: reasoningMode },
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function upstreamUrl(baseUrl, requestUrl) {
|
|
198
|
+
const upstream = new URL(baseUrl);
|
|
199
|
+
const basePath = upstream.pathname.replace(/\/$/, "");
|
|
200
|
+
const requestPath = requestUrl.pathname;
|
|
201
|
+
upstream.pathname =
|
|
202
|
+
basePath.endsWith("/v1") && requestPath.startsWith("/v1/")
|
|
203
|
+
? `${basePath}${requestPath.slice("/v1".length)}`
|
|
204
|
+
: `${basePath}${requestPath}` || "/";
|
|
205
|
+
upstream.search = requestUrl.search;
|
|
206
|
+
return upstream;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function authorized(request, relayToken) {
|
|
210
|
+
const authorization = request.headers.authorization ?? "";
|
|
211
|
+
const candidate = authorization.startsWith("Bearer ")
|
|
212
|
+
? authorization.slice("Bearer ".length)
|
|
213
|
+
: request.headers["x-api-key"] ?? "";
|
|
214
|
+
const expectedBuffer = Buffer.from(relayToken);
|
|
215
|
+
const candidateBuffer = Buffer.from(String(candidate));
|
|
216
|
+
return (
|
|
217
|
+
expectedBuffer.length === candidateBuffer.length &&
|
|
218
|
+
timingSafeEqual(expectedBuffer, candidateBuffer)
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async function readRequestBody(request) {
|
|
223
|
+
const chunks = [];
|
|
224
|
+
let size = 0;
|
|
225
|
+
for await (const chunk of request) {
|
|
226
|
+
size += chunk.length;
|
|
227
|
+
if (size > MAX_REQUEST_BYTES) {
|
|
228
|
+
throw new CiteArkError("Provider 代理请求超过 32 MiB 限制");
|
|
229
|
+
}
|
|
230
|
+
chunks.push(chunk);
|
|
231
|
+
}
|
|
232
|
+
return Buffer.concat(chunks);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function copyRequestHeaders(input) {
|
|
236
|
+
const output = new Headers();
|
|
237
|
+
for (const [name, value] of Object.entries(input)) {
|
|
238
|
+
if (value !== undefined && !hopByHopHeader(name)) {
|
|
239
|
+
output.set(name, Array.isArray(value) ? value.join(", ") : value);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return output;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function hopByHopHeader(name) {
|
|
246
|
+
return new Set([
|
|
247
|
+
"connection",
|
|
248
|
+
"content-encoding",
|
|
249
|
+
"content-length",
|
|
250
|
+
"host",
|
|
251
|
+
"transfer-encoding",
|
|
252
|
+
]).has(name.toLowerCase());
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
async function closeServer(server, activeControllers = new Set()) {
|
|
256
|
+
for (const controller of activeControllers) controller.abort();
|
|
257
|
+
activeControllers.clear();
|
|
258
|
+
if (!server.listening) return;
|
|
259
|
+
await new Promise((resolve, reject) => {
|
|
260
|
+
server.close((error) => (error ? reject(error) : resolve()));
|
|
261
|
+
server.closeAllConnections?.();
|
|
262
|
+
});
|
|
263
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { GcpSecretManagerClient } from "../gcp/secret-manager.mjs";
|
|
2
|
+
|
|
3
|
+
export function runtimeProviderConfiguration(runtimeAgent = {}) {
|
|
4
|
+
return {
|
|
5
|
+
baseUrl: nonEmpty(runtimeAgent.apiBaseUrl) ?? nonEmpty(runtimeAgent.api?.baseUrl),
|
|
6
|
+
apiKey: nonEmpty(runtimeAgent.apiKey) ?? nonEmpty(runtimeAgent.api?.apiKey),
|
|
7
|
+
model: nonEmpty(runtimeAgent.model),
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function isOpenRouterBaseUrl(value) {
|
|
12
|
+
try {
|
|
13
|
+
return new URL(value).hostname.toLowerCase() === "openrouter.ai";
|
|
14
|
+
} catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function providerEndpoint(baseUrl, resource) {
|
|
20
|
+
const normalized = baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`;
|
|
21
|
+
return new URL(resource.replace(/^\/+/, ""), normalized).toString();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function resolveProviderApiKey({
|
|
25
|
+
runtimeAgent,
|
|
26
|
+
providerSecret,
|
|
27
|
+
secretManager,
|
|
28
|
+
}) {
|
|
29
|
+
if (runtimeAgent?.codexAccountId || runtimeAgent?.billingMode === "subscription") throw new Error("Subscription model calls cannot resolve an API key");
|
|
30
|
+
const configured = runtimeProviderConfiguration(runtimeAgent);
|
|
31
|
+
if (configured.apiKey) return configured.apiKey;
|
|
32
|
+
if (!providerSecret) return null;
|
|
33
|
+
const client = secretManager ?? new GcpSecretManagerClient();
|
|
34
|
+
const apiKey = await client.accessVersion(providerSecret);
|
|
35
|
+
return nonEmpty(apiKey);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function nonEmpty(value) {
|
|
39
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
40
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export interface CapReference { ref: string; digest: string; recordType?: string; artifactDigest?: string; role?: string }
|
|
2
|
+
export interface CapRecord { id: string; type: string; role: string; [key: string]: any }
|
|
3
|
+
export interface CapDescriptor { id: string; recordType: string; role: string; path: string; digest: string; mediaType: string; schema: string; size: number }
|
|
4
|
+
export interface CapManifest {
|
|
5
|
+
specVersion: string; mediaType: string; profiles: string[];
|
|
6
|
+
artifact: { id?: string; createdAt: string; createdBy: CapReference };
|
|
7
|
+
roots: Array<CapReference & { role: string }>;
|
|
8
|
+
records: CapDescriptor[];
|
|
9
|
+
blobs: Array<{id: string; path?: string; digest: string; size: number; mediaType: string; availability: 'embedded' | 'external' | 'withheld'; roles: string[]; rights?: Record<string, unknown>; accessPolicy?: Record<string, unknown>}>;
|
|
10
|
+
relations: Array<{relationship: string; artifactDigest: string; recordDigest?: string; summary?: string}>;
|
|
11
|
+
}
|
|
12
|
+
export interface CapAttestation { signatureValid: boolean; subjectValid: boolean; publicKeyDigest: string; [key: string]: unknown }
|
|
13
|
+
export interface CapVerification { archive?: {sha256: string; size: number; [key: string]: unknown}; valid: boolean; issues: string[]; warnings: string[]; protocolVersion: string; artifactDigest: string; manifest: CapManifest; attestations: CapAttestation[] }
|
|
14
|
+
export interface CapArtifact extends CapVerification {
|
|
15
|
+
kind: 'reproduction' | 'research-plan' | 'research-compilation' | 'computational-run' | 'research-graph';
|
|
16
|
+
/** Domain projections; graphRecords contains the authenticated scientific objects. */
|
|
17
|
+
records: Record<string, CapRecord[]>; graphRecords: CapRecord[];
|
|
18
|
+
signerDigest: string; directory: string; attestation: CapAttestation;
|
|
19
|
+
}
|
|
20
|
+
export interface ArkGraphArtifact { artifactDigest: string; manifest: CapManifest; graphRecords: CapRecord[]; attestations?: CapAttestation[] }
|
|
21
|
+
export interface ArkGraphNode { key: string; ref: string; digest: string; recordType: string; role: string; record: CapRecord; artifacts: string[] }
|
|
22
|
+
export interface ArkGraphRelation extends ArkGraphNode {
|
|
23
|
+
predicate: string; subject: CapReference; object: CapReference;
|
|
24
|
+
resolution: { subject: string; object: string }; selection?: { subject: boolean; object: boolean };
|
|
25
|
+
}
|
|
26
|
+
export interface ArkGraph { queryVersion: string; artifacts: string[]; nodes: ArkGraphNode[]; relations: ArkGraphRelation[]; truncated?: boolean; attestations: Array<{artifactDigest: string; attestations: CapAttestation[]}> }
|
|
27
|
+
export interface ArkGraphQuery { roots?: CapReference[]; predicates?: string[]; depth?: number; limit?: number; cursor?: string }
|
|
28
|
+
export interface ArkGraphResult extends ArkGraph { scope: {roots: CapReference[]; predicates: string[] | null; depth: number}; missingRoots: CapReference[]; truncated: boolean; nextCursor: string | null; totalSelected: number }
|
|
29
|
+
export interface ArkRoute extends ArkGraphResult {
|
|
30
|
+
target: CapReference; activities: CapReference[]; groups: { reference: string[]; planned: string[]; actual: string[] };
|
|
31
|
+
assessments: Array<{reference: CapReference; conclusion: string; scope: any; limitations: string[]; performedBy: CapReference}>;
|
|
32
|
+
unknowns: Array<{relation: string; reference: CapReference; reason: string}>;
|
|
33
|
+
independence: {status: string; reason: string};
|
|
34
|
+
}
|
|
35
|
+
export interface ArkRouteSelection { artifactDigests?: string[]; target: CapReference; activities?: CapReference[]; limit?: number; depth?: number }
|
|
36
|
+
export interface ArkRouteComparison {
|
|
37
|
+
queryVersion: string; inputs: any; shared: string[]; onlyLeft: string[]; onlyRight: string[];
|
|
38
|
+
changedVersions: Array<{ref: string; digests: string[]}>;
|
|
39
|
+
coverage: {left: Array<{target: CapReference; status: string; assessments: any[]}>; right: Array<{target: CapReference; status: string; assessments: any[]}>};
|
|
40
|
+
incomplete: boolean; independence: {status: string; reason: string};
|
|
41
|
+
}
|
|
42
|
+
export function readCapArchive(archivePath: string, directory: string, options?: {trustedKeyDigests?: string[]}): Promise<CapArtifact>;
|
|
43
|
+
export function readCapBlob(artifact: CapArtifact, role: string): Promise<any>;
|
|
44
|
+
export function verifyCapArchive(archivePath: string, options?: {trustedKeyDigests?: string[]}): Promise<CapVerification>;
|
|
45
|
+
export function packCap(options: { directory: string; outputPath: string; reuseExisting?: boolean }): Promise<any>;
|
|
46
|
+
export function createArkGraph(artifacts: ArkGraphArtifact[]): ArkGraph;
|
|
47
|
+
export function queryArkGraph(graph: ArkGraph, query?: ArkGraphQuery): ArkGraphResult;
|
|
48
|
+
export function getArkGraphRecord(graph: ArkGraph, reference: CapReference): (ArkGraphNode & {relations: ArkGraphRelation[]}) | null;
|
|
49
|
+
export function deriveArkRoute(graph: ArkGraph, selection: ArkRouteSelection): ArkRoute | null;
|
|
50
|
+
export function compareArkRoutes(left: ArkRoute, right: ArkRoute, options?: {targets?: CapReference[]}): ArkRouteComparison;
|
|
51
|
+
export function traceArkGraphProvenance(graph: ArkGraph, reference: CapReference, options?: ArkGraphQuery): (ArkGraphResult & {record: ArkGraphNode}) | null;
|
|
52
|
+
export function scientificProjections(records: CapRecord[]): Record<string, CapRecord[]>;
|
|
53
|
+
export const ARKGRAPH_QUERY_VERSION: string;
|
|
54
|
+
export const SUBJECT_TAGS: Set<string>;
|
|
55
|
+
export function executionTimeoutCapMinutes(fidelity: string): number;
|
|
56
|
+
export const CAP_PROFILE: Record<string, string>;
|
|
57
|
+
export const CAP_RECORD_TYPE: Record<string, string>;
|
|
58
|
+
export const CAP_RECORD_ROLE: Record<string, string>;
|
|
59
|
+
export const CAP_PREDICATES: Record<string, [string | null, string | null]>;
|
|
60
|
+
|
|
61
|
+
export function canonicalJson(value: unknown): string;
|
|
62
|
+
export function canonicalJsonBytes(value: unknown): Uint8Array;
|
|
63
|
+
export function sha256Bytes(value: Uint8Array): string;
|
|
64
|
+
|
|
65
|
+
export type ResearchReadingCategory = 'question' | 'concept' | 'hypothesis' | 'claim' | 'method' | 'plan' | 'activity' | 'result' | 'argument' | 'assessment' | 'resource' | 'agent';
|
|
66
|
+
export const RESEARCH_READING_TYPES: Readonly<Record<ResearchReadingCategory, string>>;
|
|
67
|
+
export function readingCategory(node: ArkGraphNode): ResearchReadingCategory;
|
|
68
|
+
export interface ArkGraphPresentationNode {
|
|
69
|
+
key: string; local: string; ref: string; digest: string; recordType: string; role: string;
|
|
70
|
+
category: ResearchReadingCategory; subtype: string; label: string; brief: string;
|
|
71
|
+
sourcePage?: number; image?: string; imageCaption?: string;
|
|
72
|
+
source: string; sourceLocators: any[]; measurements: any[]; conditions: any;
|
|
73
|
+
limitations: string[]; prospective: boolean; basis: string | null; raw: CapRecord;
|
|
74
|
+
}
|
|
75
|
+
export interface ArkGraphPresentationExperiment {
|
|
76
|
+
id: string; experimentId?: string; procedure: CapReference; index: number;
|
|
77
|
+
source: string; target: string; question: string; title: string; summary: string; criterion: string; limitations: string[];
|
|
78
|
+
contextNodeIds: string[]; targetKeys: string[]; inputKeys: string[]; stepKeys: string[];
|
|
79
|
+
requiredProcedureKeys: string[]; unresolvedInputs: CapReference[];
|
|
80
|
+
}
|
|
81
|
+
export interface ArkGraphPresentation {
|
|
82
|
+
schemaVersion: 'arkgraph-presentation/1'; digest: string; paperTitle: string; titleZh: string;
|
|
83
|
+
sourceDocument?: string; question: string; provenance: string; nodes: ArkGraphPresentationNode[];
|
|
84
|
+
edges: Array<{id: string; ref: string; digest: string; from: string; to: string; predicate: string; basis: string; raw: CapRecord; available: boolean; source: string; qualification: string}>;
|
|
85
|
+
experiments: ArkGraphPresentationExperiment[];
|
|
86
|
+
presentation: {spine: string[]; primary: string[]; groups: Array<{parent:string;label:string;members:string[]}>; contextGroups: Array<{parent:string;children:string[]}>; shortLabels: Record<string,string>};
|
|
87
|
+
classification: {assignments: Record<string,{category:ResearchReadingCategory;subtype:string;reason:string;contextualRoles:string[]}>};
|
|
88
|
+
completeness: {nodes:number;relations:number;unavailableRelations:number};
|
|
89
|
+
}
|
|
90
|
+
export function buildArkGraphPresentation(graph: ArkGraph, options?: {artifactDigest?:string}): ArkGraphPresentation;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { readCapArchive, readCapBlob } from '../cap/v2/read.mjs';
|
|
2
|
+
export { verifyCapArchive, packCap } from '../cap/v2/archive.mjs';
|
|
3
|
+
export { CAP_PROFILE, CAP_RECORD_TYPE } from '../cap/v2/core.mjs';
|
|
4
|
+
export { SUBJECT_TAGS } from '../contracts/subject-tags.mjs';
|
|
5
|
+
export { executionTimeoutCapMinutes } from '../contracts/execution-timeouts.mjs';
|
|
6
|
+
|
|
7
|
+
export { CAP_RECORD_ROLE, CAP_PREDICATES, scientificProjections } from '../graph/model.mjs';
|
|
8
|
+
export { ARKGRAPH_QUERY_VERSION, createArkGraph, queryArkGraph, getArkGraphRecord, deriveArkRoute, compareArkRoutes, traceArkGraphProvenance } from '../graph/query.mjs';
|
|
9
|
+
|
|
10
|
+
export { canonicalJson, canonicalJsonBytes, sha256Bytes } from '../cap/v2/canonical-json.mjs';
|
|
11
|
+
|
|
12
|
+
export { buildArkGraphPresentation, readingCategory, RESEARCH_READING_TYPES } from '../graph/presentation.mjs';
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// Supported library operations for an external research hosting service.
|
|
2
|
+
export { AUTODL_TOOL_DEFINITIONS } from '../autodl/tools.mjs';
|
|
3
|
+
export { AutoDlApiError } from '../autodl/client.mjs';
|
|
4
|
+
export { AutoDlGcsStageTransfer } from '../compute/autodl-pro-staging.mjs';
|
|
5
|
+
export { AutoDlProClient } from '../autodl/client.mjs';
|
|
6
|
+
export { AutoDlProLeasePool } from '../compute/autodl-pro-job.mjs';
|
|
7
|
+
export { AutoDlSshClient } from '../autodl/ssh.mjs';
|
|
8
|
+
export { CAP_ARCHIVE_MEDIA_TYPE } from '../cap/v2/core.mjs';
|
|
9
|
+
export { CAP_MANIFEST } from '../cap/v2/core.mjs';
|
|
10
|
+
export { CAP_PROFILE } from '../cap/v2/core.mjs';
|
|
11
|
+
export { CAP_RECORD_TYPE, CAP_RECORD_ROLE } from '../cap/v2/core.mjs';
|
|
12
|
+
export { CiteArkError } from '../util.mjs';
|
|
13
|
+
export { EXECUTION_TIMEOUT_CAPS_MINUTES } from '../contracts/execution-timeouts.mjs';
|
|
14
|
+
export { GcpBatchClient } from '../gcp/batch-client.mjs';
|
|
15
|
+
export { GcsStagingClient } from '../gcp/storage.mjs';
|
|
16
|
+
export { discoverGcpResources, discoveredGcpPrice, gcpDiscoverySummary, GCP_DISCOVERY_READ_PERMISSIONS } from '../gcp/resource-discovery.mjs';
|
|
17
|
+
export { OBSERVABILITY_SCHEMA_VERSION } from '../observability/event-contract.mjs';
|
|
18
|
+
export { RECONSTRUCTION_REPOSITORY } from '../repository-origin.mjs';
|
|
19
|
+
export { RecoveryStateError } from '../pipeline/recovery-error.mjs';
|
|
20
|
+
export { SourceDiscoveryError } from '../research/source-discovery.mjs';
|
|
21
|
+
export { accountSession } from '../compute/codex-account-session.mjs';
|
|
22
|
+
export { acquireAutoDlProLease } from '../compute/autodl-pro-job.mjs';
|
|
23
|
+
export { agentInvocationPromptArgument } from '../runtime/index.mjs';
|
|
24
|
+
export * as archive_module from '../cap/v2/archive.mjs';
|
|
25
|
+
export { assembleReassessmentCap } from '../cap/v2/reassessment-artifact.mjs';
|
|
26
|
+
export { assembleResearchCompilationCap } from '../cap/v2/compilation-artifact.mjs';
|
|
27
|
+
export { assembleResearchPlanCap } from '../cap/v2/research-artifact.mjs';
|
|
28
|
+
export { assertCommunityCap } from '../deployment/community-policy.mjs';
|
|
29
|
+
export { assertRemoteUploads } from '../compute/autodl-pro-remote.mjs';
|
|
30
|
+
export { assetTransportCompatibilityIssues } from '../assets/source-grounding.mjs';
|
|
31
|
+
export { autoDlExternalObjectTransferTimeoutMs } from '../compute/autodl-pro-remote.mjs';
|
|
32
|
+
export { autoDlHourlyCny } from '../compute/autodl-pro-job.mjs';
|
|
33
|
+
export { autoDlInstanceCandidates } from '../compute/autodl-pro-job.mjs';
|
|
34
|
+
export { autoDlInstanceRequest } from '../compute/autodl-pro-job.mjs';
|
|
35
|
+
export { autoDlStageDownloadChunkBytes } from '../compute/autodl-pro-remote.mjs';
|
|
36
|
+
export { autoDlStageDownloadTimeoutSeconds } from '../compute/autodl-pro-remote.mjs';
|
|
37
|
+
export { automaticAdmissionByExperiment } from '../research/automatic-admission.mjs';
|
|
38
|
+
export { automaticExperimentAdmission } from '../research/automatic-admission.mjs';
|
|
39
|
+
export { blockingCompilerReconstructionIssues } from '../research/structure.mjs';
|
|
40
|
+
export { buildAgentInvocation } from '../runtime/index.mjs';
|
|
41
|
+
export { buildAssessmentEvidenceContext } from '../verification/evidence-context.mjs';
|
|
42
|
+
export { buildCodexInvocation } from '../runtime/codex.mjs';
|
|
43
|
+
export { buildGcpBatchJob } from '../compute/gcp-batch-job.mjs';
|
|
44
|
+
export { campaignExecutionTargets } from '../compute/campaign.mjs';
|
|
45
|
+
export { campaignTargetDirectory } from '../contracts/campaign-contract.mjs';
|
|
46
|
+
export { campaignWorkEstimate } from '../compute/campaign.mjs';
|
|
47
|
+
export { canReuseAutoDlProLease } from '../compute/autodl-pro-job.mjs';
|
|
48
|
+
export { canonicalJson } from '../cap/v2/canonical-json.mjs';
|
|
49
|
+
export { canonicalJsonBytes } from '../cap/v2/canonical-json.mjs';
|
|
50
|
+
export { capPublicKeyDigestFromPrivateKeyFile } from '../cap/v2/attestation.mjs';
|
|
51
|
+
export { captureProcess } from '../process.mjs';
|
|
52
|
+
export * as catalog_module from '../compute/catalog.mjs';
|
|
53
|
+
export { checkOpenRouterReadiness } from '../provider/openrouter-readiness.mjs';
|
|
54
|
+
export { commandMatchesFragment } from '../verification/integrity.mjs';
|
|
55
|
+
export { compilerExecutionProfile } from '../compute/compiler-profile.mjs';
|
|
56
|
+
export { compilerReconstructionRetryIssues } from '../research/structure.mjs';
|
|
57
|
+
export { continuationRepairTargets } from '../research/continuation-selection.mjs';
|
|
58
|
+
export { copyPaper } from '../job.mjs';
|
|
59
|
+
export { createAssetPreparationComputeDecision } from '../assets/compute.mjs';
|
|
60
|
+
export { createAssetPreparationPlan } from '../assets/plan.mjs';
|
|
61
|
+
export { createAutoDlStageArchive } from '../compute/autodl-pro-remote.mjs';
|
|
62
|
+
export { createAutoDlToolExecutor } from '../autodl/tools.mjs';
|
|
63
|
+
export { createBudgetedProviderFetch } from '../../docker/claude-code/codex-pro-relay.mjs';
|
|
64
|
+
export { createCampaignContract } from '../contracts/campaign-contract.mjs';
|
|
65
|
+
export { createExecutionContract } from '../contracts/execution-contract.mjs';
|
|
66
|
+
export { createOpenRouterScientificAssessor } from '../verification/ai-assessor.mjs';
|
|
67
|
+
export { createStageCheckpoint } from '../pipeline/stage-checkpoint.mjs';
|
|
68
|
+
export { discoverRepository } from '../research/source-discovery.mjs';
|
|
69
|
+
export { downloadVerifiedAutoDlStage } from '../compute/autodl-pro-remote.mjs';
|
|
70
|
+
export { emitStructuredObservation } from '../observability/event-contract.mjs';
|
|
71
|
+
export { evaluateClaim } from '../verification/claim-evaluator.mjs';
|
|
72
|
+
export { executeAutoDlRemoteAttempt } from '../compute/autodl-pro-remote.mjs';
|
|
73
|
+
export { executeAutoDlRemoteAttemptWithLeaseRetry } from '../compute/autodl-pro-executor.mjs';
|
|
74
|
+
export { executeFullPipeline } from '../pipeline/orchestrator.mjs';
|
|
75
|
+
export { executeScheduledCompilation } from '../compute/compiler-router.mjs';
|
|
76
|
+
export { executeScheduledReproduction } from '../compute/executor-router.mjs';
|
|
77
|
+
export { executionWorkloadIssues } from '../contracts/execution-workload.mjs';
|
|
78
|
+
export * as execution_contract_module from '../contracts/execution-contract.mjs';
|
|
79
|
+
export * as execution_timeouts_module from '../contracts/execution-timeouts.mjs';
|
|
80
|
+
export { externalRequestObservation } from '../observability/event-contract.mjs';
|
|
81
|
+
export * as handoff_module from '../deployment/handoff.mjs';
|
|
82
|
+
export { initialResearchPlan } from '../reproduction/plan.mjs';
|
|
83
|
+
export { initializeResearchPlan } from '../reproduction/plan.mjs';
|
|
84
|
+
export { isRetryableAutoDlRemoteInfrastructureError } from '../compute/autodl-pro-executor.mjs';
|
|
85
|
+
export { listComputeExecutors } from '../compute/executor-router.mjs';
|
|
86
|
+
export { loadComputeCatalog } from '../compute/catalog.mjs';
|
|
87
|
+
export { loadComputePolicy } from '../compute/catalog.mjs';
|
|
88
|
+
export { loadExecutionContract } from '../contracts/execution-contract.mjs';
|
|
89
|
+
export { loadVerificationPolicy } from '../contracts/execution-contract.mjs';
|
|
90
|
+
export * as local_contract_module from '../deployment/local-contract.mjs';
|
|
91
|
+
export * as local_module from '../deployment/local.mjs';
|
|
92
|
+
export { measurementHardwareIssues } from '../compute/measurement-hardware.mjs';
|
|
93
|
+
export { metricAvailability } from '../records/views.mjs';
|
|
94
|
+
export { normalizeExperimentImportance } from '../research/experiment-importance.mjs';
|
|
95
|
+
export { normalizeResearchStructure } from '../research/structure.mjs';
|
|
96
|
+
export { normalizeTask } from '../protocol.mjs';
|
|
97
|
+
export { packCap } from '../cap/v2/archive.mjs';
|
|
98
|
+
export { parseAutoDlRegionImagePairs } from '../compute/autodl-pro-job.mjs';
|
|
99
|
+
export { parseAutoDlSshConnection } from '../autodl/ssh.mjs';
|
|
100
|
+
export { pathExists } from '../util.mjs';
|
|
101
|
+
export { prepareInventoryForExecution } from '../research/inventory-handoff.mjs';
|
|
102
|
+
export { prepareRepository } from '../job.mjs';
|
|
103
|
+
export { primaryMetric } from '../records/views.mjs';
|
|
104
|
+
export { priorCompletedContinuationTargets } from '../research/continuation-selection.mjs';
|
|
105
|
+
export { projectSharedExecutionClaim } from '../pipeline/shared-execution.mjs';
|
|
106
|
+
export { publicAgentRuntime } from '../runtime/config.mjs';
|
|
107
|
+
export { publicContractPolicyIssues } from '../contracts/public-contract.mjs';
|
|
108
|
+
export { quoteBudgetedModelRequest } from '../../docker/claude-code/codex-pro-relay.mjs';
|
|
109
|
+
export { readJson } from '../util.mjs';
|
|
110
|
+
export { readTargetFailureDiagnosis } from '../diagnosis/target-failure.mjs';
|
|
111
|
+
export * as recipe_module from '../deployment/recipe.mjs';
|
|
112
|
+
export { recoverInvalidExecutionResult } from '../reproduction/lifecycle.mjs';
|
|
113
|
+
export * as recovery_error_module from '../pipeline/recovery-error.mjs';
|
|
114
|
+
export { redactString } from '../cap/redaction.mjs';
|
|
115
|
+
export { relocateStageValue } from '../pipeline/stage-checkpoint.mjs';
|
|
116
|
+
export { remoteProviderSession } from '../compute/gcp-batch-job.mjs';
|
|
117
|
+
export { replayRunToCap } from '../pipeline/replay.mjs';
|
|
118
|
+
export { reproductionCampaign } from '../compute/campaign.mjs';
|
|
119
|
+
export { researchPublicContract } from '../contracts/public-contract.mjs';
|
|
120
|
+
export { resolveAgentRuntime } from '../runtime/config.mjs';
|
|
121
|
+
export { resolveAutoDlProConfig } from '../compute/autodl-pro-job.mjs';
|
|
122
|
+
export { resolveAutoDlProviderEnvironment } from '../compute/autodl-pro-job.mjs';
|
|
123
|
+
export { resolveComputeRequirement } from '../compute/requirements.mjs';
|
|
124
|
+
export { resolveGcpBatchConfig } from '../compute/gcp-batch-job.mjs';
|
|
125
|
+
export { resolveReproductionTargets } from '../pipeline/targets.mjs';
|
|
126
|
+
export { resolveResearchPlan } from '../reproduction/plan.mjs';
|
|
127
|
+
export { restoreAutoDlExternalObjects } from '../compute/autodl-pro-remote.mjs';
|
|
128
|
+
export { restoreRemoteRecovery } from '../compute/coordinator-recovery.mjs';
|
|
129
|
+
export { restoreRunRecovery } from '../compute/coordinator-recovery.mjs';
|
|
130
|
+
export { runProcess } from '../process.mjs';
|
|
131
|
+
export { safeRelativePath } from '../util.mjs';
|
|
132
|
+
export { sanitizeObservation } from '../observability/event-contract.mjs';
|
|
133
|
+
export { saveRemoteRecovery } from '../compute/coordinator-recovery.mjs';
|
|
134
|
+
export { saveRunRecovery } from '../compute/coordinator-recovery.mjs';
|
|
135
|
+
export { scheduleCompute } from '../compute/scheduler.mjs';
|
|
136
|
+
export { selectAssetPreparationProfile } from '../assets/compute.mjs';
|
|
137
|
+
export { selectContinuationTargets } from '../research/continuation-selection.mjs';
|
|
138
|
+
export { sha256Bytes } from '../cap/v2/canonical-json.mjs';
|
|
139
|
+
export { sha256File } from '../util.mjs';
|
|
140
|
+
export { sha256Value } from '../util.mjs';
|
|
141
|
+
export { sharedWorkloads } from '../compute/shared-workloads.mjs';
|
|
142
|
+
export { shellEnvironmentFile } from '../compute/autodl-pro-job.mjs';
|
|
143
|
+
export * as structure_module from '../research/structure.mjs';
|
|
144
|
+
export { summarizeResearchCoverage } from '../pipeline/targets.mjs';
|
|
145
|
+
export * as supplement_module from '../deployment/supplement.mjs';
|
|
146
|
+
export { targetMeasurementIds } from '../pipeline/targets.mjs';
|
|
147
|
+
export { transferAutoDlStageArchive } from '../compute/autodl-pro-remote.mjs';
|
|
148
|
+
export { uploadVerifiedFiles } from '../compute/autodl-pro-remote.mjs';
|
|
149
|
+
export { usesWorkspaceSummary } from '../reproduction/workspace-mode.mjs';
|
|
150
|
+
export * as util_module from '../util.mjs';
|
|
151
|
+
export { validateExecutionResult } from '../protocol.mjs';
|
|
152
|
+
export { validateResultFile } from '../protocol.mjs';
|
|
153
|
+
export { verifyCapArchive } from '../cap/v2/archive.mjs';
|
|
154
|
+
export { verifyCapDirectory } from '../cap/v2/verify.mjs';
|
|
155
|
+
export { writeJson } from '../util.mjs';
|
|
156
|
+
export { ReproductionAdmissionProbeError, assessAutomaticReproductionAdmission, assertNoTransientAdmissionFailures, assetInventoryPreparationHints, assetInventoryCompatibilityIssues } from "../assets/reproduction-admission.mjs";
|
|
157
|
+
export { probePublicAssetUrl } from "../assets/public-asset-probe.mjs";
|
|
158
|
+
export { needsCompilerRepairGeneration } from '../research/compiler-repair.mjs';
|
|
159
|
+
export { validateCodexLogin } from '../compute/codex-account-session.mjs';
|
|
160
|
+
export { readDeploymentArchive } from '../deployment/local.mjs';
|
|
161
|
+
|
|
162
|
+
export { createScientificAssessor } from '../verification/ai-assessor.mjs';
|
|
163
|
+
export { createModelClient } from '../provider/model-client.mjs';
|
|
164
|
+
export { modelRoute } from '../provider/model-route.mjs';
|
|
165
|
+
export { openCodexAccount } from '../provider/codex-account.mjs';
|
|
166
|
+
export { checkModelReadiness } from '../provider/openrouter-readiness.mjs';
|
|
167
|
+
|
|
168
|
+
export { preparePaperMarkdown, PAPER_MARKDOWN_CONFIG } from "../research/paper-markdown.mjs";
|
|
169
|
+
export { MINERU_RUNTIME_DIRECTORY } from "../research/mineru-local.mjs";
|
|
170
|
+
export { GoogleAccessTokenProvider } from "../gcp/auth.mjs";
|
|
171
|
+
export { executeObservedExternalRequest } from "../observability/event-contract.mjs";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function createFailureDiagnosticArchive(options: {
|
|
2
|
+
root: string;
|
|
3
|
+
destination: string;
|
|
4
|
+
jobId: string;
|
|
5
|
+
stage: string;
|
|
6
|
+
attemptCount: number;
|
|
7
|
+
error: Error;
|
|
8
|
+
}): Promise<{ path: string; digest: string; byteSize: number; mediaType: string }>;
|
|
9
|
+
export function verifyCapArchive(path: string, options?: Record<string, unknown>): Promise<any>;
|
|
10
|
+
export function readDeploymentArchive(path: string, directory: string): Promise<{ handoff: any; artifactDigest: string }>;
|
|
11
|
+
export function validateCodexLogin(text: string): unknown;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function metricMeasurements(metrics) {
|
|
2
|
+
return Array.isArray(metrics?.measurements) ? metrics.measurements : [];
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function primaryMetric(metrics) {
|
|
6
|
+
return metricMeasurements(metrics)[0]?.primary ?? null;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function metricAvailability(metrics) {
|
|
10
|
+
const measurements = metricMeasurements(metrics);
|
|
11
|
+
const unavailable = measurements.find((measurement) => measurement?.availability?.status === "unavailable");
|
|
12
|
+
return unavailable?.availability ?? measurements[0]?.availability ?? null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function metricObservations(metrics) {
|
|
16
|
+
return metricMeasurements(metrics).flatMap((measurement) =>
|
|
17
|
+
(measurement?.observations ?? []).map((observation) => ({
|
|
18
|
+
...observation,
|
|
19
|
+
...(measurement?.measurementId ? { measurementId: measurement.measurementId } : {}),
|
|
20
|
+
})),
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function primaryComparison(assessment) {
|
|
25
|
+
return assessment?.measurementAssessments?.[0]?.comparison ?? null;
|
|
26
|
+
}
|