@steel-dev/atlas 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +219 -0
  3. package/dist/agent.d.ts +34 -0
  4. package/dist/agent.js +133 -0
  5. package/dist/async.d.ts +19 -0
  6. package/dist/async.js +172 -0
  7. package/dist/atlas.d.ts +19 -0
  8. package/dist/atlas.js +69 -0
  9. package/dist/budget.d.ts +64 -0
  10. package/dist/budget.js +336 -0
  11. package/dist/checklist.d.ts +115 -0
  12. package/dist/checklist.js +297 -0
  13. package/dist/cli.js +38700 -0
  14. package/dist/config.d.ts +80 -0
  15. package/dist/config.js +109 -0
  16. package/dist/context.d.ts +26 -0
  17. package/dist/context.js +250 -0
  18. package/dist/custom-tools.d.ts +26 -0
  19. package/dist/custom-tools.js +33 -0
  20. package/dist/defaults.d.ts +10 -0
  21. package/dist/defaults.js +37 -0
  22. package/dist/economy.d.ts +12 -0
  23. package/dist/economy.js +6 -0
  24. package/dist/env.d.ts +1 -0
  25. package/dist/env.js +8 -0
  26. package/dist/errors.d.ts +6 -0
  27. package/dist/errors.js +11 -0
  28. package/dist/event-hub.d.ts +11 -0
  29. package/dist/event-hub.js +83 -0
  30. package/dist/events.d.ts +105 -0
  31. package/dist/events.js +1 -0
  32. package/dist/html-extract.d.ts +21 -0
  33. package/dist/html-extract.js +459 -0
  34. package/dist/index.d.ts +59 -0
  35. package/dist/index.js +26 -0
  36. package/dist/memory.d.ts +2 -0
  37. package/dist/memory.js +38 -0
  38. package/dist/model.d.ts +49 -0
  39. package/dist/model.js +630 -0
  40. package/dist/orchestrate.d.ts +5 -0
  41. package/dist/orchestrate.js +277 -0
  42. package/dist/pdf-extract.d.ts +5 -0
  43. package/dist/pdf-extract.js +20 -0
  44. package/dist/prompts.d.ts +2 -0
  45. package/dist/prompts.js +6 -0
  46. package/dist/providers/domain/arxiv.d.ts +6 -0
  47. package/dist/providers/domain/arxiv.js +83 -0
  48. package/dist/providers/domain/clinicaltrials.d.ts +6 -0
  49. package/dist/providers/domain/clinicaltrials.js +104 -0
  50. package/dist/providers/domain/edgar.d.ts +10 -0
  51. package/dist/providers/domain/edgar.js +92 -0
  52. package/dist/providers/domain/index.d.ts +14 -0
  53. package/dist/providers/domain/index.js +7 -0
  54. package/dist/providers/domain/openalex.d.ts +7 -0
  55. package/dist/providers/domain/openalex.js +128 -0
  56. package/dist/providers/domain/pubmed.d.ts +8 -0
  57. package/dist/providers/domain/pubmed.js +123 -0
  58. package/dist/providers/domain/semantic-scholar.d.ts +6 -0
  59. package/dist/providers/domain/semantic-scholar.js +112 -0
  60. package/dist/providers/domain/shared.d.ts +12 -0
  61. package/dist/providers/domain/shared.js +39 -0
  62. package/dist/providers/domain/wikipedia.d.ts +6 -0
  63. package/dist/providers/domain/wikipedia.js +71 -0
  64. package/dist/providers/exa-agent.d.ts +9 -0
  65. package/dist/providers/exa-agent.js +67 -0
  66. package/dist/providers/fetch.d.ts +66 -0
  67. package/dist/providers/fetch.js +675 -0
  68. package/dist/providers/parallel-agent.d.ts +11 -0
  69. package/dist/providers/parallel-agent.js +100 -0
  70. package/dist/providers/perplexity-agent.d.ts +17 -0
  71. package/dist/providers/perplexity-agent.js +86 -0
  72. package/dist/providers/search.d.ts +65 -0
  73. package/dist/providers/search.js +433 -0
  74. package/dist/providers/store.d.ts +48 -0
  75. package/dist/providers/store.js +217 -0
  76. package/dist/researcher.d.ts +20 -0
  77. package/dist/researcher.js +3 -0
  78. package/dist/robots.d.ts +16 -0
  79. package/dist/robots.js +146 -0
  80. package/dist/roles.d.ts +6 -0
  81. package/dist/roles.js +4 -0
  82. package/dist/run.d.ts +65 -0
  83. package/dist/run.js +371 -0
  84. package/dist/safe-dispatcher.d.ts +16 -0
  85. package/dist/safe-dispatcher.js +32 -0
  86. package/dist/safety.d.ts +23 -0
  87. package/dist/safety.js +206 -0
  88. package/dist/sandbox.d.ts +22 -0
  89. package/dist/sandbox.js +228 -0
  90. package/dist/search-normalize.d.ts +2 -0
  91. package/dist/search-normalize.js +13 -0
  92. package/dist/source-documents.d.ts +77 -0
  93. package/dist/source-documents.js +421 -0
  94. package/dist/sources.d.ts +57 -0
  95. package/dist/sources.js +1 -0
  96. package/dist/spine.d.ts +19 -0
  97. package/dist/spine.js +722 -0
  98. package/dist/state.d.ts +90 -0
  99. package/dist/state.js +27 -0
  100. package/dist/structured.d.ts +7 -0
  101. package/dist/structured.js +18 -0
  102. package/dist/tools.d.ts +33 -0
  103. package/dist/tools.js +1187 -0
  104. package/dist/trace-digest.d.ts +11 -0
  105. package/dist/trace-digest.js +309 -0
  106. package/dist/trace.d.ts +225 -0
  107. package/dist/trace.js +278 -0
  108. package/dist/trail.d.ts +15 -0
  109. package/dist/trail.js +74 -0
  110. package/dist/url.d.ts +1 -0
  111. package/dist/url.js +25 -0
  112. package/package.json +107 -0
@@ -0,0 +1,90 @@
1
+ import type { LanguageModelV3 } from "@ai-sdk/provider";
2
+ import type { ConcurrencyGate } from "./async.js";
3
+ import type { BudgetGrant, BudgetMeter, PricingTable } from "./budget.js";
4
+ import type { Ledger } from "./checklist.js";
5
+ import type { ResolvedRunConfig } from "./config.js";
6
+ import type { ResolvedCustomTool } from "./custom-tools.js";
7
+ import type { ResearchEvent } from "./events.js";
8
+ import type { ModelRole, ResolvedModel, RunUsage } from "./model.js";
9
+ import type { FetchProvider } from "./providers/fetch.js";
10
+ import type { MergedSearchResult, ResolvedSearch } from "./providers/search.js";
11
+ import type { JournalWriter, ReplayCache } from "./providers/store.js";
12
+ import type { SafeDispatcher } from "./safe-dispatcher.js";
13
+ import type { FetchedSource, SourceDocument } from "./sources.js";
14
+ import type { TraceRecorder } from "./trace.js";
15
+ import type { Trail } from "./trail.js";
16
+ export interface SearchCacheEntry {
17
+ merged: MergedSearchResult[];
18
+ warnings: string[];
19
+ }
20
+ export interface OaCandidate {
21
+ openUrls: string[];
22
+ title?: string;
23
+ fallbackText?: string;
24
+ }
25
+ export interface SurfacedCandidate {
26
+ url: string;
27
+ title: string;
28
+ snippet: string;
29
+ }
30
+ export interface SourceStore {
31
+ fetchedSources: FetchedSource[];
32
+ byUrl: Map<string, SourceDocument>;
33
+ byId: Map<string, SourceDocument>;
34
+ reservedUrls: Set<string>;
35
+ reservedSlots: number;
36
+ nextSourceNumber: number;
37
+ inFlight: Map<string, Promise<SourceDocument | null>>;
38
+ searchCache: Map<string, Promise<SearchCacheEntry>>;
39
+ }
40
+ export declare function createSourceStore(): SourceStore;
41
+ export interface RunCounters {
42
+ searches: number;
43
+ searchCacheHits: number;
44
+ modelCacheHits: number;
45
+ modelGatePeakWidth: number;
46
+ sourcesFetched: number;
47
+ sourcesFailed: number;
48
+ }
49
+ export declare function createRunCounters(): RunCounters;
50
+ export interface RunCtx {
51
+ runId: string;
52
+ question: string;
53
+ todayISO: string;
54
+ config: ResolvedRunConfig;
55
+ meter: BudgetMeter;
56
+ usage: RunUsage;
57
+ pricing: PricingTable;
58
+ ledger: Ledger | null;
59
+ trail: Trail;
60
+ notes: string[];
61
+ readCounts: Map<string, number>;
62
+ sources: SourceStore;
63
+ search: ResolvedSearch;
64
+ searchBySource: Map<string, ResolvedSearch>;
65
+ oaCandidates: Map<string, OaCandidate>;
66
+ surfacedCandidates: Map<string, SurfacedCandidate>;
67
+ fetchChain: FetchProvider[];
68
+ safeDispatcher: SafeDispatcher;
69
+ customTools: ReadonlyMap<string, ResolvedCustomTool>;
70
+ runCodeEnabled: boolean;
71
+ emit(event: ResearchEvent): void;
72
+ journal?: JournalWriter | undefined;
73
+ replay?: ReplayCache | undefined;
74
+ recorder?: TraceRecorder | undefined;
75
+ signal?: AbortSignal | undefined;
76
+ stopSignal?: AbortSignal | undefined;
77
+ deadlineAt?: number | undefined;
78
+ now(): number;
79
+ modelGate: ConcurrencyGate;
80
+ ioGate: ConcurrencyGate;
81
+ seenDomains: Set<string>;
82
+ counters: RunCounters;
83
+ agentSequence: {
84
+ next: number;
85
+ };
86
+ bindModel(role: ModelRole, grant: BudgetGrant): LanguageModelV3;
87
+ rawModel(role: ModelRole): ResolvedModel;
88
+ stopReason(): string | null;
89
+ }
90
+ export declare function budgetStatusLine(rctx: RunCtx): string;
package/dist/state.js ADDED
@@ -0,0 +1,27 @@
1
+ export function createSourceStore() {
2
+ return {
3
+ fetchedSources: [],
4
+ byUrl: new Map(),
5
+ byId: new Map(),
6
+ reservedUrls: new Set(),
7
+ reservedSlots: 0,
8
+ nextSourceNumber: 1,
9
+ inFlight: new Map(),
10
+ searchCache: new Map(),
11
+ };
12
+ }
13
+ export function createRunCounters() {
14
+ return {
15
+ searches: 0,
16
+ searchCacheHits: 0,
17
+ modelCacheHits: 0,
18
+ modelGatePeakWidth: 0,
19
+ sourcesFetched: 0,
20
+ sourcesFailed: 0,
21
+ };
22
+ }
23
+ export function budgetStatusLine(rctx) {
24
+ const spent = rctx.meter.totalSpentUSD();
25
+ const total = rctx.meter.totalUSD;
26
+ return `budget: ≈$${Math.max(0, total - spent).toFixed(2)} of $${total.toFixed(2)} remaining`;
27
+ }
@@ -0,0 +1,7 @@
1
+ import type { LanguageModelV3 } from "@ai-sdk/provider";
2
+ import { type FlexibleSchema } from "ai";
3
+ import type { ResearchResult } from "./run.js";
4
+ export interface StructuredResult<T> extends ResearchResult {
5
+ object: T;
6
+ }
7
+ export declare function extractStructured<T>(model: LanguageModelV3, question: string, report: string, schema: FlexibleSchema<T>, signal?: AbortSignal): Promise<T>;
@@ -0,0 +1,18 @@
1
+ import { generateObject } from "ai";
2
+ import { MODEL_CALL_MAX_RETRIES } from "./model.js";
3
+ const EXTRACT_SYSTEM = "You convert a finished research report into a structured object that conforms to the given schema. " +
4
+ "Use ONLY facts asserted in the report; never invent or infer a value the report does not support. " +
5
+ "When the report leaves a field undetermined, use the schema's allowance — null, empty, or omission — rather than guessing.";
6
+ export async function extractStructured(model, question, report, schema, signal) {
7
+ const { object } = await generateObject({
8
+ model,
9
+ schema,
10
+ system: EXTRACT_SYSTEM,
11
+ prompt: `Question:\n${question}\n\n` +
12
+ `Research report:\n${report}\n\n` +
13
+ "Return the object the schema defines, grounded only in the report above.",
14
+ maxRetries: MODEL_CALL_MAX_RETRIES,
15
+ ...(signal ? { abortSignal: signal } : {}),
16
+ });
17
+ return object;
18
+ }
@@ -0,0 +1,33 @@
1
+ import { type ToolSet } from "ai";
2
+ import type { BudgetGrant } from "./budget.js";
3
+ import type { AgentRole } from "./events.js";
4
+ import type { SourceDocument } from "./sources.js";
5
+ import { type RunCtx } from "./state.js";
6
+ export declare const BUILTIN_TOOL_NAMES: readonly ["search", "fetch", "read_source", "search_sources", "run_code", "note"];
7
+ export declare const LEDGER_TOOL_NAMES: readonly ["close_slot", "add_slot", "retarget_slot"];
8
+ export type ToolName = (typeof BUILTIN_TOOL_NAMES)[number] | (typeof LEDGER_TOOL_NAMES)[number];
9
+ export interface AgentCtx {
10
+ agentId: string;
11
+ role: AgentRole;
12
+ grant: BudgetGrant;
13
+ depth: number;
14
+ }
15
+ export declare function authorityMultiplier(url: string): number;
16
+ export declare function renderUnfetchedCandidates(rctx: RunCtx, max: number): string;
17
+ export declare function execSearchTool(rctx: RunCtx, queries: string[], limit: number, source?: string): Promise<string>;
18
+ type SingleFetchOutcome = {
19
+ ok: true;
20
+ card: Record<string, unknown>;
21
+ } | {
22
+ ok: false;
23
+ error: string;
24
+ };
25
+ export declare function fetchOneUrl(rctx: RunCtx, actx: AgentCtx, requestedUrl: string, previewChars: number, goal: string): Promise<SingleFetchOutcome>;
26
+ export declare function addCustomToolSource(rctx: RunCtx, _actx: AgentCtx, opts: {
27
+ url: string;
28
+ title?: string;
29
+ content: string;
30
+ toolName: string;
31
+ }): SourceDocument | null;
32
+ export declare function buildAgentTools(rctx: RunCtx, actx: AgentCtx, names: ToolName[]): ToolSet;
33
+ export {};