@tiangong-ai/cli 0.0.20 → 0.0.22
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 +3 -2
- package/README.md +158 -13
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +11 -1
- package/dist/cli.js.map +1 -1
- package/dist/research/orchestration.js +166 -11
- package/dist/research/orchestration.js.map +1 -1
- package/dist/research/workspace/broker.js +407 -31
- package/dist/research/workspace/broker.js.map +1 -1
- package/dist/research/workspace/capabilities.js +65 -0
- package/dist/research/workspace/capabilities.js.map +1 -1
- package/dist/research/workspace/constants.d.ts +1 -1
- package/dist/research/workspace/constants.js +4 -0
- package/dist/research/workspace/constants.js.map +1 -1
- package/dist/research/workspace/evidence.d.ts +32 -0
- package/dist/research/workspace/evidence.js +235 -0
- package/dist/research/workspace/evidence.js.map +1 -0
- package/dist/research/workspace/executor.d.ts +11 -1
- package/dist/research/workspace/executor.js +678 -105
- package/dist/research/workspace/executor.js.map +1 -1
- package/dist/research/workspace/input-plan.d.ts +5 -0
- package/dist/research/workspace/input-plan.js +319 -0
- package/dist/research/workspace/input-plan.js.map +1 -0
- package/dist/research/workspace/journal.js +2 -1
- package/dist/research/workspace/journal.js.map +1 -1
- package/dist/research/workspace/preflight.d.ts +108 -0
- package/dist/research/workspace/preflight.js +261 -0
- package/dist/research/workspace/preflight.js.map +1 -0
- package/dist/research/workspace/projects.d.ts +5 -2
- package/dist/research/workspace/projects.js +290 -6
- package/dist/research/workspace/projects.js.map +1 -1
- package/dist/research/workspace/runtime.d.ts +5 -1
- package/dist/research/workspace/runtime.js +1314 -196
- package/dist/research/workspace/runtime.js.map +1 -1
- package/dist/research/workspace/sanitization.d.ts +5 -0
- package/dist/research/workspace/sanitization.js +72 -0
- package/dist/research/workspace/sanitization.js.map +1 -0
- package/dist/research/workspace/schemas.d.ts +17 -0
- package/dist/research/workspace/schemas.js +342 -0
- package/dist/research/workspace/schemas.js.map +1 -0
- package/dist/research/workspace/storage.js +4 -0
- package/dist/research/workspace/storage.js.map +1 -1
- package/dist/research/workspace/types.d.ts +160 -0
- package/dist/research/workspace/workspace.d.ts +14 -3
- package/dist/research/workspace/workspace.js +374 -12
- package/dist/research/workspace/workspace.js.map +1 -1
- package/package.json +2 -1
package/AGENTS.md
CHANGED
|
@@ -15,8 +15,8 @@ checkPaths:
|
|
|
15
15
|
- .docpact/config.yaml
|
|
16
16
|
- docs/agents/**
|
|
17
17
|
- src/**
|
|
18
|
-
lastReviewedAt: 2026-08-
|
|
19
|
-
lastReviewedCommit:
|
|
18
|
+
lastReviewedAt: 2026-08-07
|
|
19
|
+
lastReviewedCommit: bc5f73c8418605892b9905263347044c11d8a7a3
|
|
20
20
|
---
|
|
21
21
|
|
|
22
22
|
# Tiangong AI CLI Contract
|
|
@@ -36,6 +36,7 @@ This repository owns the Tiangong AI command-line interface.
|
|
|
36
36
|
|
|
37
37
|
## Current Command Surface
|
|
38
38
|
|
|
39
|
+
- `tiangong-ai --version`
|
|
39
40
|
- `tiangong-ai doctor`
|
|
40
41
|
- `tiangong-ai kb ingest`
|
|
41
42
|
- `tiangong-ai kb ingest bulk`
|
package/README.md
CHANGED
|
@@ -12,8 +12,8 @@ checkPaths:
|
|
|
12
12
|
- package.json
|
|
13
13
|
- bin/**
|
|
14
14
|
- src/**
|
|
15
|
-
lastReviewedAt: 2026-08-
|
|
16
|
-
lastReviewedCommit:
|
|
15
|
+
lastReviewedAt: 2026-08-07
|
|
16
|
+
lastReviewedCommit: bc5f73c8418605892b9905263347044c11d8a7a3
|
|
17
17
|
---
|
|
18
18
|
|
|
19
19
|
# Tiangong AI CLI
|
|
@@ -26,11 +26,19 @@ Package: `@tiangong-ai/cli` Executable: `tiangong-ai` Node: `>=24`
|
|
|
26
26
|
npm install
|
|
27
27
|
npm run build
|
|
28
28
|
node ./bin/tiangong-ai.js --help
|
|
29
|
+
node ./bin/tiangong-ai.js --version
|
|
29
30
|
```
|
|
30
31
|
|
|
31
32
|
Use Node `24.x`; this package declares `>=24 <25` and includes `.nvmrc` for
|
|
32
33
|
compatible version managers.
|
|
33
34
|
|
|
35
|
+
After installation, print the package version with either top-level flag:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
tiangong-ai --version
|
|
39
|
+
tiangong-ai -v
|
|
40
|
+
```
|
|
41
|
+
|
|
34
42
|
## KB Ingest
|
|
35
43
|
|
|
36
44
|
Required environment:
|
|
@@ -177,7 +185,7 @@ region are resolved by the AWS SDK, including `AWS_ACCESS_KEY_ID`,
|
|
|
177
185
|
|
|
178
186
|
## Research Workspaces
|
|
179
187
|
|
|
180
|
-
Create a bounded
|
|
188
|
+
Create a bounded smoke-test workspace and register a question:
|
|
181
189
|
|
|
182
190
|
```bash
|
|
183
191
|
tiangong-ai research workspace init /absolute/path/to/workspace
|
|
@@ -186,6 +194,38 @@ tiangong-ai research project init gpu-resource-impact \
|
|
|
186
194
|
--question "How do advanced GPU process nodes change environmental resource burdens?"
|
|
187
195
|
```
|
|
188
196
|
|
|
197
|
+
`smoke-test` is the default and is intended for deterministic fixtures and
|
|
198
|
+
low-cost canaries. Formal work must use `--mode production-research`, explicit
|
|
199
|
+
producer/reviewer model IDs and pricing in `config.json`, a requirements JSON
|
|
200
|
+
file, and budget confirmation when `maxCostUsd` exceeds
|
|
201
|
+
`confirmationCostUsd`:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
tiangong-ai research workspace init /absolute/path/to/workspace \
|
|
205
|
+
--mode production-research
|
|
206
|
+
tiangong-ai research project preflight \
|
|
207
|
+
--workspace /absolute/path/to/workspace \
|
|
208
|
+
--question "How do advanced GPU process nodes change environmental resource burdens?" \
|
|
209
|
+
--requirements /absolute/path/to/evidence-requirements.json --json
|
|
210
|
+
tiangong-ai research project init gpu-resource-impact \
|
|
211
|
+
--workspace /absolute/path/to/workspace \
|
|
212
|
+
--question "How do advanced GPU process nodes change environmental resource burdens?" \
|
|
213
|
+
--requirements /absolute/path/to/evidence-requirements.json \
|
|
214
|
+
--confirm-budget --json
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
The requirements object declares `dimensions`, `sourceTypes`, `minSources`,
|
|
218
|
+
`minFullTextSources`, `minDatedSources`, and optional inclusive
|
|
219
|
+
`publicationDateFrom` / `publicationDateTo` boundaries (`YYYY-MM-DD` or
|
|
220
|
+
`null`). After discovery, a mechanical coverage gate verifies the declared
|
|
221
|
+
source, full-text, publication-date, and dimension summary before analysis.
|
|
222
|
+
For large local sources, pass an immutable `--input-plan` to both preflight and
|
|
223
|
+
project initialization. Each plan entry may expose either a separate
|
|
224
|
+
`contextPath` or non-overlapping, one-based `contextRanges`; the producer sees
|
|
225
|
+
only that bounded context, while independent review receives the hash-verified
|
|
226
|
+
full source. Symlinks, duplicate content, changed hashes, and context above
|
|
227
|
+
`maxInputContextTokens` are rejected.
|
|
228
|
+
|
|
189
229
|
The workspace stores its current protocol state under `.tiangong-research/`.
|
|
190
230
|
Each project follows five ordered stages: evidence discovery, analysis,
|
|
191
231
|
synthesis, independent review, and mechanical closure. Producer work defaults
|
|
@@ -204,19 +244,98 @@ tiangong-ai research project input add gpu-resource-impact \
|
|
|
204
244
|
--path /absolute/path/to/inventory.csv \
|
|
205
245
|
--role primary
|
|
206
246
|
tiangong-ai research workspace doctor --workspace /absolute/path/to/workspace
|
|
207
|
-
tiangong-ai research
|
|
247
|
+
tiangong-ai research workspace doctor --workspace /absolute/path/to/workspace \
|
|
248
|
+
--agent-smoke
|
|
249
|
+
tiangong-ai research run --workspace /absolute/path/to/workspace \
|
|
250
|
+
--project gpu-resource-impact --progress-jsonl
|
|
208
251
|
tiangong-ai research status --workspace /absolute/path/to/workspace --json
|
|
209
252
|
```
|
|
210
253
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
254
|
+
Use `research run --project <id>` for an auditable project-scoped run: only
|
|
255
|
+
that project is checked, scheduled, summarized, and bound to the top-level
|
|
256
|
+
JSON/JSONL `projectId`, so historical blocked siblings do not alter its exit
|
|
257
|
+
status. Omit `--project` and use `--max-parallel` only for an intentional
|
|
258
|
+
workspace-wide run.
|
|
259
|
+
|
|
260
|
+
Inputs are admitted by SHA-256. Agent work runs with a dedicated capsule HOME
|
|
261
|
+
in an ephemeral platform sandbox. Only the minimal supported agent auth file is
|
|
262
|
+
copied into that HOME. For Claude, an owner-only user `settings.json` is never
|
|
263
|
+
copied; only the whitelisted API key/token and HTTPS base URL fields from its
|
|
264
|
+
`env` object are injected in memory. Permissions, hooks, additional directories,
|
|
265
|
+
and unrelated settings are not admitted. The workspace credential file and the
|
|
266
|
+
rest of the host home are not admitted. Production doctor is blocked until
|
|
267
|
+
`--agent-smoke` actually starts both routes inside this boundary. A successful
|
|
268
|
+
smoke creates a 24-hour attestation bound to workspace config, capability lock,
|
|
269
|
+
output schema, and the resolved agent binary/wrapper fingerprints. Production
|
|
270
|
+
execution stops before invocation if the attestation expires or any bound value
|
|
271
|
+
drifts.
|
|
272
|
+
Use the exact `codex` / `claude` route by default. A custom wrapper must use an
|
|
273
|
+
absolute `binary` plus an absolute `wrapperTargetBinary`; the runtime injects
|
|
274
|
+
the resolved target path and independently hashes the target executable, route
|
|
275
|
+
launcher/wrapper, and internal adapter. A wrapper that performs an unpinned
|
|
276
|
+
PATH lookup is not a reproducible route.
|
|
277
|
+
|
|
278
|
+
The CLI owns the authoritative JSON Schemas for discovery, analysis,
|
|
279
|
+
synthesis, and review. Inspect one with `research schema show <stage> --json`.
|
|
280
|
+
Codex and Claude receive the schema through their structured-output options;
|
|
281
|
+
the CLI materializes the validated final object. A syntax/schema failure gets
|
|
282
|
+
at most one separately budgeted formatting repair, never a full blind retry.
|
|
283
|
+
The same isolated repair may correct mechanically diagnosed provenance or
|
|
284
|
+
finding/source bindings; it has no broker or research tools and cannot add new
|
|
285
|
+
facts.
|
|
286
|
+
|
|
287
|
+
Total, per-package, output, repair, broker-response bytes, estimated broker
|
|
288
|
+
context tokens, context items, wall-time, output-count, output-size, and attempt
|
|
289
|
+
limits live in `.tiangong-research/config.json`.
|
|
290
|
+
Before an agent starts, the runtime reserves the package token and conservative
|
|
291
|
+
price budget. The call-level check accounts for prompt and schema bytes at
|
|
292
|
+
three bytes per token, repeats input allowance for every permitted API turn,
|
|
293
|
+
and adds primary output plus a potential isolated repair's input and output;
|
|
294
|
+
insufficient package or remaining project budget prevents invocation. The
|
|
295
|
+
provider cost cap is the current package reservation, not the remaining
|
|
296
|
+
workspace allowance. Tool-free primary stages allow two protocol turns because
|
|
297
|
+
Claude structured output uses a `StructuredOutput` call plus its follow-up
|
|
298
|
+
result; external tools remain disabled. Formatting repair omits the provider
|
|
299
|
+
schema tool, uses one plain-JSON turn, and remains subject to the CLI schema and
|
|
300
|
+
semantic validators. Current Codex and Claude CLI adapters report
|
|
301
|
+
output usage only after execution, so preflight identifies
|
|
302
|
+
`outputTokenLimitEnforcement` as `post-execution`; captured bytes provide a
|
|
303
|
+
separate process bound, and over-limit output fails without promotion.
|
|
304
|
+
Preflight also reports per-stage `maxTurns` and `turnLimitEnforcement`: Claude
|
|
305
|
+
receives a provider-side turn cap, while the current Codex CLI exposes no such
|
|
306
|
+
flag, so its turn allowance is reservation guidance plus post-execution
|
|
307
|
+
accounting and rejection. Usage records separate input, cached-input, and output
|
|
308
|
+
tokens; `inputTokens` excludes
|
|
309
|
+
the separately reported cached portion. Configured pricing fills cost when the
|
|
310
|
+
provider does not report it. Run records and JSONL progress also preserve
|
|
311
|
+
sanitized event/item counts, provider turns, tool calls, reasoning tokens, and
|
|
312
|
+
bounded provider errors.
|
|
215
313
|
|
|
216
314
|
Every evidence source must resolve to an admitted input or a completed broker
|
|
217
|
-
receipt.
|
|
218
|
-
|
|
219
|
-
|
|
315
|
+
receipt. Successful broker bodies are immutable content-addressed objects under
|
|
316
|
+
`.tiangong-research/evidence/objects`; receipts are project-scoped and verified
|
|
317
|
+
for existence, size, and SHA-256 before every capsule stages them. Independent
|
|
318
|
+
review binds the requirements, receipts, permanent evidence objects, inputs,
|
|
319
|
+
and artifact hashes. Its exact packet and merged bounded evidence context are
|
|
320
|
+
also content-addressed under the project `review/packets/` and
|
|
321
|
+
`review/contexts/` directories. Mechanical closure re-verifies the packet,
|
|
322
|
+
context, broker objects, and registered local input hashes before recording
|
|
323
|
+
their safe locators. Capsule deletion therefore does not delete the durable
|
|
324
|
+
review chain.
|
|
325
|
+
|
|
326
|
+
Discovery alone may use the capability broker and workspace-read tools.
|
|
327
|
+
Analyze and synthesize receive bounded, hash-verified prior-stage artifacts in
|
|
328
|
+
their prompt with tools disabled. Review is also tool-free and limited to the
|
|
329
|
+
two turns required by the structured-output protocol:
|
|
330
|
+
its prompt embeds the complete generated artifacts, persistent packet, local
|
|
331
|
+
bounded contexts, and each cited broker receipt's exact bounded view. Full
|
|
332
|
+
local files and raw broker objects are hash-bound for durable human/mechanical
|
|
333
|
+
audit, but the model must not claim to have read beyond those embedded views.
|
|
334
|
+
The CLI mechanically derives local full-text availability, source types,
|
|
335
|
+
counts, date coverage, source IDs, and the coverage decision. A `partial`
|
|
336
|
+
dimension is usable but incomplete; a missing dimension or unmet declared
|
|
337
|
+
minimum blocks downstream work. Qualitative gaps remain visible without
|
|
338
|
+
silently changing those mechanical fields.
|
|
220
339
|
|
|
221
340
|
Method skills are declared in `.tiangong-research/capabilities.json` with
|
|
222
341
|
absolute skill paths and explicit permissions, then frozen before execution:
|
|
@@ -226,7 +345,11 @@ tiangong-ai research capability lock --workspace /absolute/path/to/workspace
|
|
|
226
345
|
tiangong-ai research capability verify --workspace /absolute/path/to/workspace
|
|
227
346
|
```
|
|
228
347
|
|
|
229
|
-
A capability using `brokered-network` must declare exact `allowedHosts
|
|
348
|
+
A capability using `brokered-network` must declare exact `allowedHosts` and may
|
|
349
|
+
declare an `http` policy with one exact `accept` value,
|
|
350
|
+
`allowedContentTypes`, `maxResponseBytes`, and `maxItems`. Its optional
|
|
351
|
+
`coverage` block declares dimensions, source types, full-text availability,
|
|
352
|
+
and publication-date availability for the preflight gap report.
|
|
230
353
|
Optional credentials declare logical IDs, exact host scopes, header names, and
|
|
231
354
|
prefixes. Put only the logical value map in `.tiangong-research/.env`:
|
|
232
355
|
|
|
@@ -236,7 +359,29 @@ TIANGONG_RESEARCH_CAPABILITY_CREDENTIALS_JSON={"source.example.api":"owner-provi
|
|
|
236
359
|
|
|
237
360
|
The broker injects declared credentials only for admitted HTTPS hosts. Agent
|
|
238
361
|
processes do not receive this variable. Keep the file owner-only (`chmod 600`)
|
|
239
|
-
and use `research workspace doctor` before a run.
|
|
362
|
+
and use `research workspace doctor` before a run. The broker preserves a
|
|
363
|
+
sanitized non-2xx excerpt, safe request ID, and `Retry-After`; it supports JSON
|
|
364
|
+
Pointer extraction, bounded item and estimated-token views, and an explicit
|
|
365
|
+
public-response cache. For a JSON collection, use the returned
|
|
366
|
+
`contextNextOffset` as the next `item_offset`; this creates a distinct bounded
|
|
367
|
+
context receipt while reusing the same verified raw object instead of
|
|
368
|
+
refetching it. Follow upstream pagination with its next admitted HTTPS URL.
|
|
369
|
+
The recorded estimate is `ceil(contextBytes / 3)`. Use `cache_mode=bypass` for
|
|
370
|
+
a fresh public request and always for credentialed requests. Raw URLs and
|
|
371
|
+
credential values are never journaled.
|
|
372
|
+
|
|
373
|
+
Retry policy is classified: deterministic configuration/4xx/output failures
|
|
374
|
+
stop, schema failures use the formatting repair path, and rate limits or
|
|
375
|
+
transient server failures alone may schedule another attempt. Explicit recovery
|
|
376
|
+
uses append-only management events:
|
|
377
|
+
|
|
378
|
+
```bash
|
|
379
|
+
tiangong-ai research project retry gpu-resource-impact --package analyze \
|
|
380
|
+
--workspace /absolute/path/to/workspace
|
|
381
|
+
tiangong-ai research project fork gpu-resource-impact \
|
|
382
|
+
--to gpu-resource-impact-v2 --resume-through analyze \
|
|
383
|
+
--workspace /absolute/path/to/workspace
|
|
384
|
+
```
|
|
240
385
|
|
|
241
386
|
## Research Search
|
|
242
387
|
|
package/dist/cli.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export type { CliIO, Output } from "./io.js";
|
|
|
3
3
|
export { parseArgs } from "./args.js";
|
|
4
4
|
export { DEFAULT_API_BASE_URL, DEFAULT_API_PATH_PREFIX } from "./kb/config.js";
|
|
5
5
|
export { resolveCollectionSelector } from "./kb/selector.js";
|
|
6
|
+
export declare const CLI_VERSION: string;
|
|
6
7
|
export declare const DEFAULT_BULK_POLL_INTERVAL_SECONDS = 30;
|
|
7
8
|
export declare const DEFAULT_BULK_PIPELINE_HEALTH_POLL_INTERVAL_SECONDS = 60;
|
|
8
9
|
export declare function runCli(argv: string[], io: CliIO): Promise<number>;
|
package/dist/cli.js
CHANGED
|
@@ -6,6 +6,7 @@ import { basename, dirname, extname, isAbsolute, join, posix as pathPosix, relat
|
|
|
6
6
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
7
7
|
import { deflateRawSync, inflateRawSync } from "node:zlib";
|
|
8
8
|
import sharp from "sharp";
|
|
9
|
+
import packageMetadata from "../package.json" with { type: "json" };
|
|
9
10
|
import { getBoolean, getNonNegativeInteger, getPositiveInteger, getString, nonNegativeIntegerValue, parseArgs, positiveIntegerValue, positiveNumberValue, } from "./args.js";
|
|
10
11
|
import { isObject, responseData, stringField } from "./data.js";
|
|
11
12
|
import { firstEnv, loadDotenv } from "./env.js";
|
|
@@ -23,6 +24,7 @@ import { runResearchCommand } from "./research/commands.js";
|
|
|
23
24
|
export { parseArgs } from "./args.js";
|
|
24
25
|
export { DEFAULT_API_BASE_URL, DEFAULT_API_PATH_PREFIX } from "./kb/config.js";
|
|
25
26
|
export { resolveCollectionSelector } from "./kb/selector.js";
|
|
27
|
+
export const CLI_VERSION = packageMetadata.version;
|
|
26
28
|
const DEFAULT_RETRIES = 3;
|
|
27
29
|
const DEFAULT_BULK_WINDOW_SIZE = 100;
|
|
28
30
|
const DEFAULT_BULK_TOP_UP_MAX = 50;
|
|
@@ -55,6 +57,10 @@ const BULK_SUPPORTED_EXTENSIONS = new Set([
|
|
|
55
57
|
]);
|
|
56
58
|
export async function runCli(argv, io) {
|
|
57
59
|
try {
|
|
60
|
+
if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
|
|
61
|
+
write(io.stdout, `${CLI_VERSION}\n`);
|
|
62
|
+
return 0;
|
|
63
|
+
}
|
|
58
64
|
loadDotenv(io.env);
|
|
59
65
|
if (argv.length === 0 || argv[0] === "--help" || argv[0] === "-h") {
|
|
60
66
|
write(io.stdout, topHelp());
|
|
@@ -2695,10 +2701,14 @@ Usage:
|
|
|
2695
2701
|
tiangong-ai kb collections list [--capability upload]
|
|
2696
2702
|
tiangong-ai kb course fulltext --document-id <id> --tags <tag>
|
|
2697
2703
|
tiangong-ai research workspace init <absolute-path>
|
|
2698
|
-
tiangong-ai research run [--workspace <absolute-path>] [--max-parallel 1]
|
|
2704
|
+
tiangong-ai research run [--workspace <absolute-path>] [--project <project-id>] [--max-parallel 1]
|
|
2699
2705
|
tiangong-ai research search --input <request.json>|--query <query> [--sources default|all|sci|report|patent|esg]
|
|
2700
2706
|
tiangong-ai education search --input <request.json>|--query <query> [--sources default|all|course|edu|textbook]
|
|
2701
2707
|
|
|
2708
|
+
Options:
|
|
2709
|
+
-h, --help Show this help.
|
|
2710
|
+
-v, --version Show the CLI version.
|
|
2711
|
+
|
|
2702
2712
|
Run "tiangong-ai kb --help" for KB options.
|
|
2703
2713
|
Run "tiangong-ai research --help" for research options.
|
|
2704
2714
|
Run "tiangong-ai education --help" for education options.
|