@aria-cli/types 1.0.9 → 1.0.11

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/src/models.ts DELETED
@@ -1,356 +0,0 @@
1
- /**
2
- * Types for ARIA's multi-model system
3
- * @module @aria/types/models
4
- */
5
-
6
- import type { NativeToolMetadata } from "./native-tools.js";
7
-
8
- /**
9
- * Supported model providers
10
- */
11
- export type ModelProvider =
12
- | "anthropic"
13
- | "openai"
14
- | "github-copilot"
15
- | "openai-codex"
16
- | "google"
17
- | "local"
18
- | "bedrock"
19
- | "bedrock-converse";
20
-
21
- /**
22
- * Model tier for task routing
23
- * - 'fast': Quick responses, simple tasks (e.g., Haiku, GPT-4o-mini)
24
- * - 'balanced': Good balance of speed and capability (e.g., Sonnet, GPT-5.2)
25
- * - 'powerful': Maximum capability for complex tasks (e.g., Opus, o1)
26
- * - 'ensemble': Multiple models working together
27
- */
28
- export type ModelTier = "fast" | "balanced" | "powerful" | "ensemble";
29
-
30
- /**
31
- * Configuration for a specific model
32
- */
33
- export interface ModelConfig {
34
- /** Model provider */
35
- provider: ModelProvider;
36
- /** Model identifier (e.g., 'claude-opus-4-6') */
37
- modelId: string;
38
- /** Human-readable name */
39
- name: string;
40
- /** Model tier classification */
41
- tier: ModelTier;
42
- /** Maximum context window size in tokens */
43
- maxContextTokens: number;
44
- /** Maximum output tokens */
45
- maxOutputTokens: number;
46
- /** Cost per million input tokens (USD) */
47
- inputCostPerMillion: number;
48
- /** Cost per million output tokens (USD) */
49
- outputCostPerMillion: number;
50
- /** Capabilities this model supports */
51
- capabilities: {
52
- /** Supports tool/function calling */
53
- tools: boolean;
54
- /** Supports vision/image input */
55
- vision: boolean;
56
- /** Supports structured output (JSON mode) */
57
- structuredOutput: boolean;
58
- /** Supports streaming responses */
59
- streaming: boolean;
60
- };
61
- /** API endpoint (for local/custom providers) */
62
- endpoint?: string;
63
- /** Additional provider-specific options */
64
- options?: Record<string, unknown>;
65
- }
66
-
67
- /**
68
- * Configuration for the model router
69
- */
70
- export interface ModelRouterConfig {
71
- /** Default model tier to use */
72
- defaultTier: ModelTier;
73
- /** Available models by tier */
74
- models: {
75
- fast: ModelConfig[];
76
- balanced: ModelConfig[];
77
- powerful: ModelConfig[];
78
- ensemble?: ModelConfig[];
79
- };
80
- /** Rules for automatic tier selection */
81
- routingRules: {
82
- /** Use powerful tier for tasks with risk above this level */
83
- riskThreshold: number;
84
- /** Use powerful tier for tasks with complexity above this score */
85
- complexityThreshold: number;
86
- /** Maximum cost per request before requiring approval (USD) */
87
- costThreshold: number;
88
- };
89
- /** Fallback model if primary fails */
90
- fallbackModel?: ModelConfig;
91
- }
92
-
93
- /**
94
- * Role of a message in a conversation
95
- */
96
- export type MessageRole = "system" | "user" | "assistant" | "tool";
97
-
98
- /**
99
- * A message in a conversation
100
- */
101
- export interface Message {
102
- /** Role of the message sender */
103
- role: MessageRole;
104
- /** Text content of the message */
105
- content: string;
106
- /** Name of the sender (optional) */
107
- name?: string;
108
- /** Tool call ID this message is responding to (for tool role) */
109
- toolCallId?: string;
110
- /** Tool calls requested by the assistant for execution (present on assistant messages with tool_use blocks) */
111
- toolCalls?: ToolCall[];
112
- /** Image attachments (for vision models) */
113
- images?: {
114
- /** Base64 encoded image data or URL */
115
- data: string;
116
- /** MIME type of the image */
117
- mimeType: string;
118
- }[];
119
- }
120
-
121
- /**
122
- * JSON Schema for function tool parameters
123
- */
124
- export interface FunctionToolParameters {
125
- type: "object";
126
- properties: Record<string, unknown>;
127
- required?: string[];
128
- [key: string]: unknown;
129
- }
130
-
131
- /**
132
- * Function tool schema (standard ARIA tool)
133
- */
134
- export interface FunctionToolSchema {
135
- kind: "function";
136
- name: string;
137
- description: string;
138
- parameters: FunctionToolParameters;
139
- /** When true, the provider defers loading this tool until needed */
140
- defer_loading?: boolean;
141
- /** Native-only fields are forbidden on function tools */
142
- provider?: never;
143
- capability?: never;
144
- config?: never;
145
- suppresses?: never;
146
- }
147
-
148
- /**
149
- * Provider-native passthrough tool schema
150
- */
151
- export interface NativeToolSchema {
152
- kind: "native";
153
- /** Provider that supplies this native tool */
154
- provider: "anthropic" | "openai" | "google";
155
- /** Native capability identifier */
156
- capability: string;
157
- /** Provider-specific native tool payload */
158
- config: Record<string, unknown>;
159
- /** ARIA function tools suppressed by this native tool */
160
- suppresses?: string[];
161
- /** Function-only fields are forbidden on native tools */
162
- name?: never;
163
- description?: never;
164
- parameters?: never;
165
- defer_loading?: never;
166
- }
167
-
168
- /**
169
- * Tool schema for model requests (discriminated by `kind`)
170
- */
171
- export type ToolSchema = FunctionToolSchema | NativeToolSchema;
172
-
173
- /**
174
- * Type guard for function tools
175
- */
176
- export function isFunctionToolSchema(tool: ToolSchema): tool is FunctionToolSchema {
177
- return tool.kind === "function";
178
- }
179
-
180
- /**
181
- * Type guard for native tools
182
- */
183
- export function isNativeToolSchema(tool: ToolSchema): tool is NativeToolSchema {
184
- return tool.kind === "native";
185
- }
186
-
187
- /**
188
- * A tool call requested by the model
189
- */
190
- export interface ToolCall {
191
- /** Unique identifier for this tool call */
192
- id: string;
193
- /** Name of the tool to call */
194
- name: string;
195
- /** Arguments to pass to the tool */
196
- arguments: Record<string, unknown>;
197
- /** Gemini thought signature — must be replayed verbatim in conversation history */
198
- thoughtSignature?: string;
199
- }
200
-
201
- /**
202
- * Thinking mode for models that support extended reasoning.
203
- * - 'adaptive': Model decides when and how much to think (Opus 4.6+, recommended)
204
- * - 'enabled': Explicit thinking with a token budget (Sonnet 4.5, Opus 4.5)
205
- */
206
- export type ThinkingMode = "adaptive" | "enabled";
207
-
208
- /**
209
- * Configuration for extended thinking/reasoning
210
- */
211
- export interface ThinkingConfig {
212
- /** Thinking mode */
213
- mode: ThinkingMode;
214
- /** Token budget for thinking (required for 'enabled' mode, ignored for 'adaptive') */
215
- budgetTokens?: number;
216
- }
217
-
218
- /**
219
- * Effort level controlling reasoning depth vs speed/cost.
220
- * - 'low': Fastest, cheapest. Skips thinking for simple tasks.
221
- * - 'medium': Balanced. May skip thinking for very simple queries.
222
- * - 'high': Default. Deep reasoning on complex tasks.
223
- * - 'max': Maximum capability, no constraints. Opus 4.6 only.
224
- */
225
- export type EffortLevel = "low" | "medium" | "high" | "max";
226
-
227
- /**
228
- * A thinking block from a model's internal reasoning process
229
- */
230
- export interface ThinkingBlock {
231
- /** The thinking text content (empty string if redacted) */
232
- thinking: string;
233
- /** Cryptographic signature for verification (required for tool-use continuations) */
234
- signature?: string;
235
- /** Whether this block was redacted by safety systems */
236
- redacted?: boolean;
237
- }
238
-
239
- /**
240
- * Request to a model
241
- */
242
- export interface ModelRequest {
243
- /** Messages in the conversation */
244
- messages: Message[];
245
- /** System prompt (if not in messages) */
246
- systemPrompt?: string;
247
- /** Available tools */
248
- tools?: ToolSchema[];
249
- /** Temperature for sampling (0-2) */
250
- temperature?: number;
251
- /** Maximum tokens to generate */
252
- maxTokens?: number;
253
- /** Stop sequences */
254
- stopSequences?: string[];
255
- /** Whether to stream the response */
256
- stream?: boolean;
257
- /** Force structured JSON output */
258
- jsonMode?: boolean;
259
- /** Extended thinking configuration */
260
- thinking?: ThinkingConfig;
261
- /** Effort level for response quality vs speed/cost tradeoff */
262
- effort?: EffortLevel;
263
- /** Tool choice strategy (e.g. "auto", "none", or a specific tool name) */
264
- tool_choice?: string;
265
- /** Request metadata */
266
- metadata?: {
267
- /** Task ID for tracking */
268
- taskId?: string;
269
- /** User ID for billing */
270
- userId?: string;
271
- /** Request priority */
272
- priority?: "low" | "normal" | "high";
273
- };
274
- /** Callback for streaming thinking blocks as they arrive (Gemini 2.5+/3.x).
275
- * Allows the runner to yield thinking events during model streaming
276
- * instead of waiting for the full response. */
277
- onThinking?: (text: string) => void;
278
- /** AbortSignal for cancelling in-flight HTTP requests.
279
- * Passed through to provider fetch() calls so Ctrl+C cancels immediately
280
- * instead of waiting for the next network chunk. */
281
- abortSignal?: AbortSignal;
282
- }
283
-
284
- /** Capabilities that a model provider supports */
285
- export interface ProviderCapabilities {
286
- /** Whether the provider supports structured JSON output */
287
- jsonMode: boolean;
288
- /** Whether the provider supports extended thinking */
289
- thinking: boolean;
290
- /** Whether the provider supports tool/function calling */
291
- toolUse: boolean;
292
- /** Whether the provider supports streaming responses */
293
- streaming: boolean;
294
- /** Whether the provider supports native defer_loading on tool schemas */
295
- nativeDeferredLoading: boolean;
296
- /** Whether the provider supports native web search */
297
- nativeSearch: boolean;
298
- /** Whether the provider supports native web fetch */
299
- nativeFetch: boolean;
300
- /** Whether the provider supports native code execution */
301
- nativeCodeExec: boolean;
302
- /** Whether the provider supports native computer use */
303
- nativeComputerUse: boolean;
304
- /** Whether the provider supports native image generation */
305
- nativeImageGen: boolean;
306
- /** Whether the provider supports native file search */
307
- nativeFileSearch: boolean;
308
- }
309
-
310
- /**
311
- * Usage statistics from a model response
312
- */
313
- export interface ModelUsage {
314
- /** Input tokens consumed (TOTAL context window — includes cached tokens) */
315
- inputTokens: number;
316
- /** Output tokens generated */
317
- outputTokens: number;
318
- /** Total tokens (input + output) */
319
- totalTokens: number;
320
- /** Estimated cost in USD */
321
- estimatedCost: number;
322
- /** Thinking tokens consumed (subset of outputTokens, if available) */
323
- thinkingTokens?: number;
324
- /** Tokens read from prompt cache (subset of inputTokens) */
325
- cacheReadTokens?: number;
326
- /** Tokens written to prompt cache (subset of inputTokens) */
327
- cacheCreationTokens?: number;
328
- }
329
-
330
- /**
331
- * Response from a model
332
- */
333
- export interface ModelResponse {
334
- /** The model's text response */
335
- content: string;
336
- /** Tool calls requested by the model */
337
- toolCalls?: ToolCall[];
338
- /** Why the model stopped generating */
339
- stopReason: "end" | "max_tokens" | "tool_call" | "stop_sequence" | "aborted";
340
- /** Token usage statistics */
341
- usage: ModelUsage;
342
- /** Model that generated the response */
343
- model: string;
344
- /** Response generation time in milliseconds */
345
- latency: number;
346
- /** Unique ID for this response */
347
- responseId: string;
348
- /** Thinking blocks from the model's reasoning process */
349
- thinking?: ThinkingBlock[];
350
- /** Raw content blocks from the API (for tool-use continuations with thinking) */
351
- rawContentBlocks?: unknown[];
352
- /** Provider that generated the response */
353
- provider?: ModelProvider;
354
- /** Native tool metadata (e.g., search results, code exec output) */
355
- nativeToolMetadata?: NativeToolMetadata;
356
- }
@@ -1,73 +0,0 @@
1
- /**
2
- * Native tool types and type guards for provider-native capabilities
3
- * @module @aria/types/native-tools
4
- */
5
-
6
- import type { ToolCall } from "./models.js";
7
-
8
- /**
9
- * Type guard to check if a tool call is a function/custom tool
10
- * (as opposed to a native provider tool like search or code execution)
11
- */
12
- export function isFunctionTool(toolCall: ToolCall): boolean {
13
- // Function tools are the default - they don't have special name prefixes
14
- return !isNativeTool(toolCall);
15
- }
16
-
17
- /**
18
- * Type guard to check if a tool call is a native provider tool
19
- * Native tools have special name prefixes like "brave_search", "computer", etc.
20
- */
21
- export function isNativeTool(toolCall: ToolCall): boolean {
22
- const nativePrefixes = [
23
- "brave_search",
24
- "computer",
25
- "code_interpreter",
26
- "text_editor",
27
- "bash",
28
- "dalle",
29
- "file_search",
30
- ];
31
- return nativePrefixes.some((prefix) => toolCall.name.startsWith(prefix));
32
- }
33
-
34
- /**
35
- * A single source from a search result
36
- */
37
- export interface NormalizedSource {
38
- /** URL of the source */
39
- url: string;
40
- /** Title of the source */
41
- title: string;
42
- /** Optional snippet/excerpt from the source */
43
- snippet?: string;
44
- /** Confidence score (0-1) if provided by the search API */
45
- confidence?: number;
46
- /** Which segments of the response cited this source */
47
- citedSegments?: Array<{ text: string; startIndex: number; endIndex: number }>;
48
- }
49
-
50
- /**
51
- * Normalized metadata for native search tool calls
52
- * Abstracts over provider-specific search APIs (Anthropic Brave, Google Search, etc.)
53
- */
54
- export interface NormalizedSearchMetadata {
55
- /** Provider that executed the search */
56
- provider: "anthropic" | "openai" | "google";
57
- /** Search queries executed (may be multiple if refined) */
58
- queries: string[];
59
- /** Sources returned by the search */
60
- sources: NormalizedSource[];
61
- /** The grounded response generated from search results (if available) */
62
- groundedResponse?: string;
63
- }
64
-
65
- /**
66
- * Metadata attached to ModelResponse when native tools are used
67
- */
68
- export interface NativeToolMetadata {
69
- /** Search metadata (if native search was used) */
70
- search?: NormalizedSearchMetadata;
71
- /** Raw provider-specific metadata for other native tools */
72
- raw?: unknown;
73
- }
package/src/relaunch.ts DELETED
@@ -1,67 +0,0 @@
1
- import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
2
- import { homedir } from "node:os";
3
- import { dirname, join } from "node:path";
4
-
5
- /**
6
- * Magic exit code that tells the parent supervisor to respawn the child.
7
- */
8
- export const RELAUNCH_EXIT_CODE = 199;
9
-
10
- /**
11
- * Environment variables used by relaunch/supervisor flows.
12
- */
13
- export const NO_RELAUNCH_ENV = "ARIA_NO_RELAUNCH";
14
- export const RESUME_SESSION_ENV = "ARIA_RESUME_SESSION_ID";
15
- export const RESUME_ARION_ENV = "ARIA_RESUME_ARION";
16
- export const RESTART_KIND_ENV = "ARIA_RESTART_KIND";
17
-
18
- export interface RelaunchMarker {
19
- sessionId: string | null;
20
- arionName: string;
21
- pid: number;
22
- timestamp: string; // ISO 8601
23
- }
24
-
25
- function getAriaDir(): string {
26
- const ariaHome = process.env.ARIA_HOME?.trim();
27
- if (ariaHome) return ariaHome;
28
- return join(homedir(), ".aria");
29
- }
30
-
31
- export function getRelaunchMarkerDir(): string {
32
- return join(getAriaDir(), "relaunch-pending");
33
- }
34
-
35
- export function getRelaunchMarkerPath(pid: number = process.pid): string {
36
- return join(getRelaunchMarkerDir(), `${pid}.json`);
37
- }
38
-
39
- export function writeRelaunchMarker(marker: RelaunchMarker): void {
40
- try {
41
- const markerPath = getRelaunchMarkerPath(marker.pid);
42
- mkdirSync(dirname(markerPath), { recursive: true });
43
- writeFileSync(markerPath, JSON.stringify(marker), "utf-8");
44
- } catch {
45
- // Best-effort — must never prevent restart
46
- }
47
- }
48
-
49
- export function readRelaunchMarker(pid: number = process.pid): RelaunchMarker | null {
50
- try {
51
- const markerPath = getRelaunchMarkerPath(pid);
52
- if (!existsSync(markerPath)) return null;
53
- const raw = readFileSync(markerPath, "utf-8");
54
- return JSON.parse(raw) as RelaunchMarker;
55
- } catch {
56
- return null;
57
- }
58
- }
59
-
60
- export function clearRelaunchMarker(pid: number = process.pid): void {
61
- try {
62
- const markerPath = getRelaunchMarkerPath(pid);
63
- if (existsSync(markerPath)) unlinkSync(markerPath);
64
- } catch {
65
- // Best-effort
66
- }
67
- }
@@ -1,20 +0,0 @@
1
- type StallPhaseGlobal = typeof globalThis & {
2
- __aria_stall_phase?: string;
3
- __aria_stall_phase_ts?: number;
4
- };
5
-
6
- function getGlobalPhaseStore(): StallPhaseGlobal {
7
- return globalThis as StallPhaseGlobal;
8
- }
9
-
10
- export function setGlobalStallPhase(label: string): void {
11
- const store = getGlobalPhaseStore();
12
- store.__aria_stall_phase = label;
13
- store.__aria_stall_phase_ts = performance.now();
14
- }
15
-
16
- export function clearGlobalStallPhase(): void {
17
- const store = getGlobalPhaseStore();
18
- store.__aria_stall_phase = undefined;
19
- store.__aria_stall_phase_ts = undefined;
20
- }
@@ -1,42 +0,0 @@
1
- /** Canonical output shapes for tools with dedicated renderers.
2
- * Executors MUST return these shapes. Renderers consume them directly. */
3
-
4
- export interface EditFileOutput {
5
- filePath: string;
6
- structuredPatch: Array<{
7
- oldStart: number;
8
- oldLines: number;
9
- newStart: number;
10
- newLines: number;
11
- lines: string[];
12
- }>;
13
- replacements: number;
14
- strategy: string;
15
- }
16
-
17
- export interface WriteFileOutput {
18
- filePath: string;
19
- action: "created" | "overwritten" | "appended";
20
- bytesWritten: number;
21
- structuredPatch?: Array<{
22
- oldStart: number;
23
- oldLines: number;
24
- newStart: number;
25
- newLines: number;
26
- lines: string[];
27
- }>;
28
- }
29
-
30
- // BashToolOutput matches @aria/tools BashOutput (shell.ts:255-259)
31
- export interface BashToolOutput {
32
- stdout: string;
33
- stderr: string;
34
- exitCode: number;
35
- }
36
-
37
- export interface NotebookEditOutput {
38
- cellNumber: number;
39
- newSource: string;
40
- language: string;
41
- error?: string;
42
- }
@@ -1,42 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import {
3
- PACKAGE_TEST_AUTHORITY,
4
- classifyTypesTestFile,
5
- classifyTypesTestPlacement,
6
- classifyTypesTestProofClass,
7
- loadTypesTestLaneManifest,
8
- type TypesTestLaneId,
9
- } from "../test-lane-manifest.js";
10
-
11
- function expectLane(relativePath: string, expected: TypesTestLaneId): void {
12
- expect(classifyTypesTestFile(relativePath)).toBe(expected);
13
- }
14
-
15
- describe("types test lane manifest", () => {
16
- it("classifies every types test file into an explicit lane and proof class", () => {
17
- const manifest = loadTypesTestLaneManifest();
18
-
19
- expect(manifest.defaultLane).toBe("unit");
20
- expect(manifest.unclassified).toEqual([]);
21
- expect(manifest.unclassifiedProofClasses).toEqual([]);
22
- expect(manifest.proofClasses.gate.length).toBeGreaterThan(0);
23
- expect(manifest.proofClasses.system).toEqual([]);
24
- expect(manifest.proofClasses.live).toEqual([]);
25
- });
26
-
27
- it("keeps the current types package entirely in the default gate lane", () => {
28
- expectLane("tests/logger.test.ts", "unit");
29
- expect(classifyTypesTestProofClass("tests/logger.test.ts")).toBe("gate");
30
- expect(classifyTypesTestPlacement("tests/logger.test.ts")).toMatchObject({
31
- lane: "unit",
32
- proofClass: "gate",
33
- resourceKeys: [],
34
- });
35
- });
36
-
37
- it("exposes package test authority projections for proof ownership", () => {
38
- expect(PACKAGE_TEST_AUTHORITY.classifyProofClass("tests/logger.test.ts")).toBe("gate");
39
- expect(PACKAGE_TEST_AUTHORITY.getProofClassFiles("gate")).toContain("tests/logger.test.ts");
40
- expect(PACKAGE_TEST_AUTHORITY.getDiagnosticBreadthFiles("unit")).toContain("tests/logger.test.ts");
41
- });
42
- });