@tiangong-ai/cli 0.0.30 → 0.0.32

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.
Files changed (38) hide show
  1. package/AGENTS.md +2 -2
  2. package/README.md +127 -97
  3. package/dist/edge-search.js +57 -16
  4. package/dist/edge-search.js.map +1 -1
  5. package/dist/http.js +17 -1
  6. package/dist/http.js.map +1 -1
  7. package/dist/research/orchestration.js +153 -4
  8. package/dist/research/orchestration.js.map +1 -1
  9. package/dist/research/workspace/broker.d.ts +5 -0
  10. package/dist/research/workspace/broker.js +130 -19
  11. package/dist/research/workspace/broker.js.map +1 -1
  12. package/dist/research/workspace/companion-readiness.d.ts +11 -0
  13. package/dist/research/workspace/companion-readiness.js +75 -0
  14. package/dist/research/workspace/companion-readiness.js.map +1 -0
  15. package/dist/research/workspace/external-skills.d.ts +95 -0
  16. package/dist/research/workspace/external-skills.js +79 -25
  17. package/dist/research/workspace/external-skills.js.map +1 -1
  18. package/dist/research/workspace/preflight.d.ts +22 -0
  19. package/dist/research/workspace/preflight.js +54 -5
  20. package/dist/research/workspace/preflight.js.map +1 -1
  21. package/dist/research/workspace/projects.js +27 -0
  22. package/dist/research/workspace/projects.js.map +1 -1
  23. package/dist/research/workspace/runtime.d.ts +68 -2
  24. package/dist/research/workspace/runtime.js +652 -14
  25. package/dist/research/workspace/runtime.js.map +1 -1
  26. package/dist/research/workspace/setup-catalog.d.ts +20 -2
  27. package/dist/research/workspace/setup-catalog.js +202 -5
  28. package/dist/research/workspace/setup-catalog.js.map +1 -1
  29. package/dist/research/workspace/setup-wizard.js +35 -13
  30. package/dist/research/workspace/setup-wizard.js.map +1 -1
  31. package/dist/research/workspace/setup.d.ts +30 -5
  32. package/dist/research/workspace/setup.js +500 -114
  33. package/dist/research/workspace/setup.js.map +1 -1
  34. package/dist/research/workspace/types.d.ts +9 -0
  35. package/dist/research/workspace/workspace.d.ts +2 -0
  36. package/dist/research/workspace/workspace.js +83 -20
  37. package/dist/research/workspace/workspace.js.map +1 -1
  38. 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-09
19
- lastReviewedCommit: 6014c3cf3e9bd13a89285e80483f02148a3f0fb0
18
+ lastReviewedAt: 2026-08-10
19
+ lastReviewedCommit: bef62f8d48c42eaff14fa2bd7eba1be83a46a58b
20
20
  ---
21
21
 
22
22
  # Tiangong AI CLI Contract
package/README.md CHANGED
@@ -12,8 +12,8 @@ checkPaths:
12
12
  - package.json
13
13
  - bin/**
14
14
  - src/**
15
- lastReviewedAt: 2026-08-08
16
- lastReviewedCommit: 2aee8339c04d94dc42a8b34d20d59af27dbe756d
15
+ lastReviewedAt: 2026-08-10
16
+ lastReviewedCommit: bef62f8d48c42eaff14fa2bd7eba1be83a46a58b
17
17
  ---
18
18
 
19
19
  # Tiangong AI CLI
@@ -252,7 +252,12 @@ hash mismatch remains fail-closed before `npx skills add`; its structured error
252
252
  reports only the Skill/source IDs, hash algorithm, and expected/observed hashes.
253
253
  It never treats file existence as installation success or silently rewrites an
254
254
  immutable plan. Plans created by an earlier CLI release are rejected at the
255
- execution boundary; create and review a new plan with the active release.
255
+ execution boundary; create and review a new plan with the active release. The
256
+ orchestrator additionally declares a `workspace-lock` runtime contract: every
257
+ workspace command goes through its bundled resolver, which accepts only the
258
+ regular non-symlink `runtime-lock.json` exact stable CLI version. Setup and
259
+ release CI reject a missing resolver or any stale exact CLI version in the
260
+ orchestrator's `SKILL.md` or `references/*.md`.
256
261
 
257
262
  The default `internet-research` profile selects Brave Web Search and News
258
263
  Search. `internet-research-with-context` additionally selects the
@@ -276,9 +281,10 @@ op read 'op://Research/Brave/api-key' | \
276
281
 
277
282
  The pinned Brave checkout is verified at `skills/<skill-name>` before install.
278
283
  An explicitly reviewed replacement plan reconciles the complete setup-managed
279
- capability set and both owner-only credential stores: deselected Brave/Sci
280
- declarations and lock records are removed, custom capability declarations are
281
- preserved, and installed Skill directories are never deleted implicitly.
284
+ capability set and both owner-only credential stores: deselected Brave, SCI,
285
+ report, or patent declarations and lock records are removed, custom capability
286
+ declarations are preserved, and installed Skill directories are never deleted
287
+ implicitly.
282
288
  Provider-dependent context/media choices never fall back silently; select the
283
289
  baseline in a replacement plan when that is the intended operator decision.
284
290
 
@@ -290,9 +296,11 @@ managers may preload one line per logical ID with
290
296
  `--credential-stdin <id[,id...]>`; the remaining Wizard questions use the
291
297
  controlling terminal.
292
298
 
293
- Optional setup entries have explicit roles. Tiangong SCI is an
294
- owner-whitelisted POST evidence capability; document decomposition is an input
295
- preprocessor; academic paper download is an acquisition adapter; document and
299
+ Optional setup entries have explicit roles. Tiangong SCI, report, and patent
300
+ search are distinct owner-whitelisted POST evidence capabilities with separate
301
+ logical credentials and discovery scopes; one cannot substitute for another.
302
+ Document decomposition is an input preprocessor; academic paper download is an
303
+ acquisition adapter; document and
296
304
  presentation Skills are post-closure authoring only. Run selected preprocessors
297
305
  and acquisition adapters with `research setup companion run`, then admit their
298
306
  exact hash-bound output separately. Automatic paper OA exhaustion returns an
@@ -305,10 +313,16 @@ Every leaf command accepts `--help` before workspace resolution, so operators
305
313
  can inspect `capability doctor`, `project preflight`, `project init`, and `run`
306
314
  syntax safely from an empty or unrelated directory.
307
315
 
308
- The requirements object declares `dimensions`, `sourceTypes`, `minSources`,
316
+ The requirements object declares `dimensions`, `sourceTypes`, optional
317
+ `requiredCapabilityIds`, `requiredCompanionIds`, and
318
+ `requiredDiscoveryScopes`, `minSources`,
309
319
  `minFullTextSources`, `minDatedSources`, and optional inclusive
310
320
  `publicationDateFrom` / `publicationDateTo` boundaries (`YYYY-MM-DD` or
311
- `null`). After discovery, a mechanical coverage gate verifies the declared
321
+ `null`). Explicit capability/scope requirements are exact: wildcard web or SCI
322
+ coverage cannot satisfy a required report database. Preflight returns both
323
+ stable string gaps and structured `coverageGaps` with the affected dimensions,
324
+ source types, alternative-coverage decision, and minimum owner action. After
325
+ discovery, a mechanical coverage gate verifies the declared
312
326
  source, full-text, publication-date, and dimension summary before analysis.
313
327
  For large local sources, pass an immutable `--input-plan` to both preflight and
314
328
  project initialization. Each plan entry may expose either a separate
@@ -319,17 +333,18 @@ full source. Symlinks, duplicate content, changed hashes, and context above
319
333
 
320
334
  The workspace stores its current protocol state under `.tiangong-research/`.
321
335
  Each project follows five ordered stages: evidence discovery, analysis,
322
- synthesis, independent review, and mechanical closure. Producer work defaults
323
- to Codex, independent review defaults to Claude, and a run is blocked when both
324
- routes use the same agent family.
325
-
326
- Research execution requires `/usr/bin/sandbox-exec` on macOS or Bubblewrap
327
- (`bwrap`) on Linux. Windows can inspect and configure workspaces but does not
328
- execute research packages. That outer platform sandbox is the execution
329
- boundary. Codex is therefore started with its nested sandbox disabled: nesting
330
- Seatbelt on macOS can cancel MCP calls even though the process is already
331
- confined. Shell and unified-exec tools remain disabled, as do undeclared Codex
332
- integrations.
336
+ synthesis, independent review, and mechanical closure. Discover, analyze, and
337
+ synthesize run in the current interactive Codex app/session or Claude Code
338
+ session. The CLI never launches a nested producer process. Independent review
339
+ runs through the other configured agent family's CLI, and execution is blocked
340
+ when the two roles use the same family.
341
+
342
+ Independent reviewer execution requires `/usr/bin/sandbox-exec` on macOS or
343
+ Bubblewrap (`bwrap`) on Linux. Windows can inspect and configure workspaces but
344
+ does not launch reviewer packages; smoke-test setup reports a non-blocking
345
+ warning there, while production readiness fails closed. The current native producer remains governed
346
+ by its host application's own permissions; the CLI supplies a hash-bound packet
347
+ and deterministic broker commands, not a second nested sandbox or agent.
333
348
 
334
349
  Add immutable local evidence, verify the workspace, and execute ready work:
335
350
 
@@ -343,6 +358,14 @@ tiangong-ai research workspace doctor --workspace /absolute/path/to/workspace \
343
358
  --agent-smoke --capability-smoke
344
359
  tiangong-ai research run --workspace /absolute/path/to/workspace \
345
360
  --project gpu-resource-impact --progress-jsonl
361
+ # When stopReason is native-stage-required, perform the returned stage here:
362
+ tiangong-ai research project stage prepare gpu-resource-impact \
363
+ --stage discover --host-agent codex \
364
+ --workspace /absolute/path/to/workspace --json
365
+ tiangong-ai research project stage submit gpu-resource-impact \
366
+ --session SESSION_ID --output /absolute/path/to/discover.json \
367
+ --confirm-model EXPECTED_MODEL \
368
+ --workspace /absolute/path/to/workspace --json
346
369
  tiangong-ai research status --workspace /absolute/path/to/workspace --json
347
370
  ```
348
371
 
@@ -352,11 +375,13 @@ JSON/JSONL `projectId`, so historical blocked siblings do not alter its exit
352
375
  status. Omit `--project` and use `--max-parallel` only for an intentional
353
376
  workspace-wide run.
354
377
 
355
- Inputs are admitted by SHA-256. Agent work runs with a dedicated capsule HOME
356
- in an ephemeral platform sandbox. Only the minimal supported agent auth file is
357
- copied into that HOME. A formatting repair reuses that capsule copy only after
358
- its SHA-256 still matches the owner source; changed, symlinked, or non-owner-only
359
- authentication stops execution instead of being overwritten. For Claude, an
378
+ Inputs are admitted by SHA-256. Native producer preparation creates an
379
+ ephemeral, hash-bound packet directory but does not copy agent authentication
380
+ or start an agent. The independent reviewer runs with a dedicated capsule HOME
381
+ in an ephemeral platform sandbox. Only the minimal supported reviewer auth file
382
+ is copied into that HOME. A reviewer formatting repair reuses that capsule copy
383
+ only after its SHA-256 still matches the owner source; changed, symlinked, or
384
+ non-owner-only authentication stops execution instead of being overwritten. For Claude, an
360
385
  owner-only user `settings.json` is never
361
386
  copied; only the whitelisted API key/token and HTTPS base URL fields from its
362
387
  `env` object are injected in memory. Permissions, hooks, additional directories,
@@ -364,17 +389,17 @@ and unrelated settings are not admitted. Codex project-root discovery is
364
389
  terminated by a capsule-local marker/config override, so a parent workspace
365
390
  `.codex/config.toml` is neither required nor made readable. The workspace
366
391
  credential file and the rest of the host home are not admitted. Production
367
- doctor is blocked until
368
- `--agent-smoke` actually starts both routes inside this boundary. A successful
369
- smoke creates a 24-hour attestation bound to workspace config, capability lock,
370
- output schema, and the resolved agent binary/wrapper fingerprints. Production
371
- execution stops before invocation if the attestation expires or any bound value
372
- drifts. While that attestation remains current, a plain `workspace doctor`
373
- revalidates its hashes and the currently resolved producer/reviewer runtime
374
- fingerprints, then reuses the attested agent and capability smoke results.
375
- Passing the smoke flags explicitly performs fresh checks instead; missing,
376
- expired, or drifted attestations remain blocking and include the refresh action.
377
- Use the exact `codex` / `claude` route by default. A custom wrapper must use an
392
+ doctor is blocked until `--agent-smoke` actually starts the independent reviewer
393
+ inside this boundary. The native producer is verified as the current host and
394
+ is never smoke-tested as a child process. A successful smoke creates a 24-hour
395
+ attestation bound to workspace config, capability lock, output schema, and the
396
+ resolved reviewer binary/wrapper fingerprints. Production review stops before
397
+ invocation if the attestation expires or any bound value drifts. While that
398
+ attestation remains current, a plain `workspace doctor` revalidates its hashes
399
+ and the current reviewer runtime fingerprint before reuse. Passing the smoke
400
+ flags explicitly performs fresh checks instead; missing, expired, or drifted
401
+ attestations remain blocking and include the refresh action. Use the exact
402
+ `codex` / `claude` route by default. A custom reviewer wrapper must use an
378
403
  absolute `binary` plus an absolute `wrapperTargetBinary`; the runtime injects
379
404
  the resolved target path and independently hashes the target executable, route
380
405
  launcher/wrapper, and internal adapter. A wrapper that performs an unpinned
@@ -382,12 +407,13 @@ PATH lookup is not a reproducible route.
382
407
 
383
408
  The CLI owns the authoritative JSON Schemas for discovery, analysis,
384
409
  synthesis, and review. Inspect one with `research schema show <stage> --json`.
385
- Codex and Claude receive the schema through their structured-output options;
386
- the CLI materializes the validated final object. A syntax/schema failure gets
387
- at most one separately budgeted formatting repair, never a full blind retry.
388
- The same isolated repair may correct mechanically diagnosed provenance or
389
- finding/source bindings; it has no broker or research tools and cannot add new
390
- facts.
410
+ Native producer preparation returns the exact schema and prompt to the current
411
+ host; `stage submit` validates and atomically materializes its JSON. A rejected
412
+ native submission keeps the bound session for an explicit correction and never
413
+ launches a repair model. The independent reviewer receives its schema through
414
+ the reviewer CLI's structured-output option; a reviewer syntax/schema or
415
+ mechanical binding failure gets at most one separately budgeted formatting-only
416
+ repair with no research tools.
391
417
 
392
418
  Total, per-package, output, repair, broker-response bytes, estimated broker
393
419
  context tokens, context items, wall-time, output-count, output-size, and attempt
@@ -398,41 +424,27 @@ synthesis, and 175,000 for review. Primary output is bounded at 6,000 tokens
398
424
  and a separately invoked repair at 4,000. These are admission ceilings rather
399
425
  than a target spend and can be lowered only when the resulting pre-call
400
426
  reservations still fit.
401
- Before an agent starts, the runtime reserves the package token and conservative
402
- price budget. The call-level check accounts for prompt and schema bytes at
403
- three bytes per token, repeats input allowance for every permitted API turn,
404
- adds the maximum bounded broker context for every permitted discovery turn,
405
- and adds primary output plus a potential isolated repair's input and output;
406
- insufficient package or remaining project budget prevents invocation. The
407
- preflight uses the same reservation calculator and additionally reserves the
408
- entire admitted capability-documentation budget on every broker turn, so a
409
- project cannot pass admission and then fail solely because runtime applies a
410
- stricter token formula. Review admission reserves three maximum-size generated
411
- artifacts plus one globally bounded evidence-excerpt bundle; runtime applies
412
- that same stage-specific context ceiling. The
413
- provider cost cap is the current package reservation, not the remaining
414
- workspace allowance. Tool-free Codex primary stages reserve two protocol turns;
415
- Claude JSON Schema primary stages reserve and receive a three-turn provider cap,
416
- matching the current Claude Code structured-output exchange. External tools
417
- remain disabled. Formatting repair omits the provider
418
- schema tool, uses one plain-JSON turn, and remains subject to the CLI schema and
419
- semantic validators. Current Codex and Claude CLI adapters report
420
- output usage only after execution, so preflight identifies
421
- `outputTokenLimitEnforcement` as `post-execution`; captured bytes provide a
422
- separate process bound. Discovery capture allowance includes the bounded MCP
423
- tool contexts as well as the requested model output, and over-limit output fails
424
- without promotion. New workspaces also enforce a six-call broker budget
425
- mechanically; every successful result reports the remaining calls and excess
426
- calls are rejected before another provider fetch or evidence promotion.
427
- Preflight also reports per-stage `maxTurns` and `turnLimitEnforcement`: Claude
428
- receives a provider-side turn cap, while the current Codex CLI exposes no such
429
- flag, so its turn allowance is reservation guidance plus post-execution
430
- accounting and rejection. Usage records separate input, cached-input, and output
431
- tokens; `inputTokens` excludes
432
- the separately reported cached portion. Configured pricing fills cost when the
433
- provider does not report it. Run records and JSONL progress also preserve
434
- sanitized event/item counts, provider turns, tool calls, reasoning tokens, and
435
- bounded provider errors.
427
+ Before project initialization and every executable package, the control plane
428
+ requires the complete token and conservative price reservation to fit. Native
429
+ producer stages reserve prompt, schema, admitted context, bounded broker
430
+ context, and output allowance, but the host app does not expose trusted
431
+ per-stage usage telemetry to this CLI. A successful native submit therefore
432
+ charges the full reviewed package reservation and records
433
+ `accountingMode=reserved-native-host`; submit still enforces the exact schema,
434
+ output bytes/tokens, provenance, coverage, hashes, and remaining project budget.
435
+ It does not claim a provider-side turn or output-token cap for the host app.
436
+
437
+ Independent review uses the pre-call reservation calculator and the reviewer's
438
+ provider-side structured-output/turn controls where available. Review admission
439
+ reserves three maximum-size generated artifacts plus one globally bounded
440
+ evidence-excerpt bundle, and formatting repair remains one separately budgeted,
441
+ tool-free JSON correction. New workspaces also enforce a six-call broker budget
442
+ mechanically; every successful native evidence fetch reports the remaining
443
+ calls and excess calls are rejected before another provider request or evidence
444
+ promotion. Reviewer usage records separate input, cached-input, and output
445
+ tokens; configured pricing fills cost when the provider omits it. Run records
446
+ and JSONL progress preserve sanitized accounting mode, event/item counts,
447
+ provider turns, tool calls, reasoning tokens, and bounded provider errors.
436
448
 
437
449
  Every evidence source must resolve to an admitted input or a completed broker
438
450
  receipt. Successful broker bodies are immutable content-addressed objects under
@@ -446,20 +458,23 @@ context, broker objects, and registered local input hashes before recording
446
458
  their safe locators. Capsule deletion therefore does not delete the durable
447
459
  review chain.
448
460
 
449
- Discovery receives only the capability broker as an execution tool. The CLI
450
- embeds the exact staged capability manifest and each external Skill's top-level
451
- `SKILL.md` in the prompt, so the producer does not need filesystem or shell
452
- access and cannot execute provider examples directly. The manifest includes
453
- the locked, non-secret HTTPS endpoint rather than only its host, so the model
454
- never has to guess a provider path. Broker responses include
455
- the exact bounded context inline with the hash-bound receipt; raw objects remain
456
- in the permanent evidence store for audit.
457
- Analyze and synthesize receive bounded, hash-verified prior-stage artifacts in
458
- their prompt with tools disabled. Review is also tool-free and uses the
461
+ Native discovery preparation embeds the exact staged capability manifest and
462
+ each external Skill's top-level `SKILL.md`. The current host may fetch admitted
463
+ evidence only with `research project evidence fetch`, whose bounded request file
464
+ contains logical IDs but no credential values. The manifest includes the locked,
465
+ non-secret HTTPS endpoint rather than only its host, and each response returns
466
+ the exact bounded context plus a hash-bound receipt while retaining the raw
467
+ object in the permanent evidence store. Host web/search/database tools cannot
468
+ substitute for a required broker receipt.
469
+ Analyze and synthesize packets contain bounded, hash-verified prior-stage
470
+ artifacts and require no external evidence calls. Review is tool-free and uses the
459
471
  reviewer's route-specific structured-output turn cap:
460
472
  its prompt embeds the complete generated artifacts and a deterministic,
461
473
  globally bounded set of excerpts distributed across registered local contexts
462
- and broker receipts. The packet hash is schema-bound, but complete packet
474
+ and broker receipts. Broker excerpts prioritize deterministic, sanitized
475
+ projections of the exact raw-response items selected by admitted evidence JSON
476
+ Pointers; uncited receipts retain metadata-only bindings, and unresolved
477
+ pointers receive a bounded-context fallback. The packet hash is schema-bound, but complete packet
463
478
  metadata is not redundantly copied into model context. Full local files,
464
479
  original per-receipt bounded contexts, raw broker objects, and the complete
465
480
  packet remain hash-bound for durable human/mechanical audit; the model must not
@@ -488,8 +503,8 @@ must be exact versions; local references must equal
488
503
  `sha256:<expectedTreeSha256>`. Every source type must match the installed whole
489
504
  tree before a lock can be written. Skill trees reject symlinks and excessive
490
505
  file counts/sizes. Project-owned Tiangong Skills are rejected through this
491
- generic import path; the setup catalog has a separate reviewed first-party
492
- adapter for Tiangong SCI. Configure/import refuses to rewrite the lock if any
506
+ generic import path; the setup catalog has separate reviewed first-party
507
+ adapters for Tiangong SCI, report, and patent search. Configure/import refuses to rewrite the lock if any
493
508
  existing capability has drifted; restore it or explicitly update its source
494
509
  identity and expected hash first.
495
510
 
@@ -534,14 +549,27 @@ tiangong-ai research capability credential set \
534
549
 
535
550
  The broker injects declared credentials only for admitted HTTPS hosts. Agent
536
551
  processes do not receive this variable. Keep the file owner-only (`chmod 600`)
537
- and run `research capability doctor --live` plus production
538
- `research workspace doctor --agent-smoke --capability-smoke` before a run.
552
+ and run the production setup/workspace doctor before a run. Setup doctor reuses
553
+ one capability probe and never starts the paid reviewer smoke while a blocking
554
+ static or low-cost prerequisite is already failing.
539
555
  Capability doctor retries only one 429 response with bounded `Retry-After`
540
556
  backoff; deterministic 4xx, missing subscription, authentication, drift, and
541
557
  content-type failures stop explicitly. It retains only a bounded sanitized
542
558
  provider code/detail and safe request ID, with an actionable baseline-or-
543
- subscription decision for `OPTION_NOT_IN_PLAN`. An explicitly requested agent
544
- or capability smoke failure makes setup readiness `BLOCKED`, never a warning.
559
+ subscription decision for `OPTION_NOT_IN_PLAN`. Required evidence/reviewer
560
+ failures make `researchReadiness=BLOCKED`. Optional preprocessing, acquisition,
561
+ and authoring checks have separate readiness fields; they block only a project
562
+ or operation that explicitly lists the exact component in
563
+ `requiredCompanionIds`.
564
+ Credential diagnostics distinguish standalone ambient absence,
565
+ broker-store absence, policy-rejected injection, and provider 401/403. Every
566
+ such diagnostic identifies the execution mode, credential scope, whether a
567
+ network request occurred, and a minimum action without returning credentials
568
+ or raw authentication responses. The optional Semantic Scholar resolver check
569
+ also performs only one bounded 429 retry. A second 429 leaves acquisition
570
+ `DEGRADED`, does not block unrelated research, and never triggers a standalone
571
+ fallback; the academic adapter can still use its unchanged Unpaywall → Semantic
572
+ Scholar OA → arXiv → explicit browser-handoff order.
545
573
  The broker preserves a sanitized non-2xx excerpt, safe request ID, and
546
574
  `Retry-After`. It performs at most one inline 429 retry when the declared or
547
575
  default delay is at most five seconds; longer throttles return an actionable
@@ -654,6 +682,7 @@ transitions.
654
682
  npm run lint
655
683
  npm test
656
684
  npm run test:coverage
685
+ npm run audit:research-setup-pins
657
686
  docpact validate-config --root . --strict
658
687
  ```
659
688
 
@@ -662,4 +691,5 @@ docpact validate-config --root . --strict
662
691
  Publishing is handled by GitHub Actions in `.github/workflows/publish.yml`.
663
692
  Push a `v*` tag that matches `package.json` version. The workflow publishes
664
693
  `@tiangong-ai/cli` to npm through npm Trusted Publishing after lint, tests,
665
- coverage, version availability, and a package dry run pass.
694
+ coverage, immutable remote Skill pin/runtime-contract audit, version
695
+ availability, and a package dry run pass.
@@ -49,16 +49,45 @@ export async function runEdgeSearch(input) {
49
49
  }
50
50
  const responses = [];
51
51
  for (const plan of plans) {
52
- responses.push({
53
- source: plan.source,
54
- response: await postJson({
55
- url: plan.request.url,
56
- headers: plan.request.headers,
57
- body: plan.request.body,
58
- timeoutMs: input.timeoutMs,
59
- fetchImpl: input.fetchImpl ?? fetch,
60
- }),
61
- });
52
+ try {
53
+ responses.push({
54
+ source: plan.source,
55
+ response: await postJson({
56
+ url: plan.request.url,
57
+ headers: plan.request.headers,
58
+ body: plan.request.body,
59
+ timeoutMs: input.timeoutMs,
60
+ fetchImpl: input.fetchImpl ?? fetch,
61
+ }),
62
+ });
63
+ }
64
+ catch (error) {
65
+ if (error instanceof CliError && error.code === "REMOTE_REQUEST_FAILED") {
66
+ const status = error.details && typeof error.details === "object" && "status" in error.details
67
+ ? Number(error.details.status)
68
+ : null;
69
+ const authenticationFailed = status === 401 || status === 403;
70
+ throw new CliError(authenticationFailed
71
+ ? `The ${plan.source} provider rejected the standalone credential.`
72
+ : `The ${plan.source} standalone provider request failed.`, {
73
+ code: authenticationFailed
74
+ ? "PROVIDER_AUTHENTICATION_FAILED"
75
+ : "STANDALONE_PROVIDER_REQUEST_FAILED",
76
+ exitCode: 1,
77
+ details: {
78
+ source: plan.source,
79
+ executionMode: "standalone",
80
+ credentialScope: "ambient-or-explicit-owner-env",
81
+ networkAttempted: true,
82
+ ...(status === null ? {} : { status }),
83
+ minimumAction: authenticationFailed
84
+ ? "Verify the owner-provided standalone credential and provider entitlement, then retry the isolated query."
85
+ : "Verify the exact endpoint, provider availability, and quota before retrying the isolated query.",
86
+ },
87
+ });
88
+ }
89
+ throw error;
90
+ }
62
91
  }
63
92
  return { dryRun: false, responses };
64
93
  }
@@ -78,17 +107,29 @@ function edgeSearchRequestPlan(input) {
78
107
  }
79
108
  function edgeSearchHeaders(source, masked, missingCredentialHelp) {
80
109
  if (source.authStrategy === "apiKey" && !source.apiKey) {
81
- throw new CliError(`Missing ${source.source} search credentials. ${missingCredentialHelp}`, {
82
- code: "EDGE_SEARCH_CREDENTIALS_REQUIRED",
110
+ throw new CliError(`Standalone ambient credential not found for ${source.source} search.`, {
111
+ code: "STANDALONE_AMBIENT_CREDENTIAL_MISSING",
83
112
  exitCode: 2,
84
- details: { source: source.source },
113
+ details: {
114
+ source: source.source,
115
+ executionMode: "standalone",
116
+ credentialScope: "ambient-or-explicit-owner-env",
117
+ networkAttempted: false,
118
+ minimumAction: missingCredentialHelp,
119
+ },
85
120
  });
86
121
  }
87
122
  if (source.authStrategy === "bearerOrApiKey" && !source.apiKey && !source.bearerToken) {
88
- throw new CliError(`Missing ${source.source} search credentials. ${missingCredentialHelp}`, {
89
- code: "EDGE_SEARCH_CREDENTIALS_REQUIRED",
123
+ throw new CliError(`Standalone ambient credential not found for ${source.source} search.`, {
124
+ code: "STANDALONE_AMBIENT_CREDENTIAL_MISSING",
90
125
  exitCode: 2,
91
- details: { source: source.source },
126
+ details: {
127
+ source: source.source,
128
+ executionMode: "standalone",
129
+ credentialScope: "ambient-or-explicit-owner-env",
130
+ networkAttempted: false,
131
+ minimumAction: missingCredentialHelp,
132
+ },
92
133
  });
93
134
  }
94
135
  const headers = {
@@ -1 +1 @@
1
- {"version":3,"file":"edge-search.js","sourceRoot":"","sources":["../src/edge-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAkB,MAAM,WAAW,CAAC;AAErD,MAAM,CAAC,MAAM,gCAAgC,GAC3C,uDAAuD,CAAC;AAmD1D,SAAS,gBAAgB,CAAC,UAAkB;IAC1C,MAAM,UAAU,GAAG,UAAU,CAAC,IAAI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AO,CAAC;AACjB,CAAC"}
package/dist/http.js CHANGED
@@ -43,7 +43,11 @@ async function parseResponse(response, url) {
43
43
  throw new CliError(`HTTP ${response.status} returned from ${url}`, {
44
44
  code: "REMOTE_REQUEST_FAILED",
45
45
  exitCode: 1,
46
- details: rawText,
46
+ details: {
47
+ status: response.status,
48
+ retryAfterSeconds: responseRetryAfterSeconds(response.headers),
49
+ networkAttempted: true,
50
+ },
47
51
  });
48
52
  }
49
53
  if (contentType.includes("application/json")) {
@@ -60,6 +64,18 @@ async function parseResponse(response, url) {
60
64
  }
61
65
  return rawText;
62
66
  }
67
+ function responseRetryAfterSeconds(headers) {
68
+ const value = headers.get("retry-after");
69
+ if (!value)
70
+ return null;
71
+ const seconds = Number(value);
72
+ if (Number.isFinite(seconds) && seconds >= 0)
73
+ return Math.ceil(seconds);
74
+ const timestamp = Date.parse(value);
75
+ if (!Number.isFinite(timestamp))
76
+ return null;
77
+ return Math.max(0, Math.ceil((timestamp - Date.now()) / 1_000));
78
+ }
63
79
  export async function postJson(options) {
64
80
  const signal = AbortSignal.timeout(options.timeoutMs);
65
81
  const response = await options.fetchImpl(options.url, {
package/dist/http.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAoB7E,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAsB,EACtB,IAAY,EACZ,OAA2D,EAAE;IAE7D,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,aAAa,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CA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