loopengine 0.3.101 → 0.4.2

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.
@@ -12,13 +12,16 @@
12
12
  // run that pauses there is settled by settleFromResume once someone
13
13
  // decides.
14
14
  //
15
- // Stored like scheduled tasks: one JSON file per run under
16
- // `<LOOPENGINE_SCHEDULER_DIR or .scheduler>/runs/`. Each agent keeps its
17
- // latest MAX_FINISHED_PER_AGENT finished runs; older ones are removed as
18
- // new runs start.
15
+ // Stored in the workspace's database (core/audit-store.ts), kept for
16
+ // its retention period; the console lists each agent's latest
17
+ // MAX_FINISHED_PER_AGENT finished runs. Where there's no database (no
18
+ // node:sqlite), one JSON file per run under
19
+ // `<LOOPENGINE_SCHEDULER_DIR or .scheduler>/runs/`, keeping only those.
20
+ // Runs already in files are copied into the database once.
19
21
  import { randomUUID } from 'node:crypto';
20
22
  import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from 'node:fs';
21
23
  import path from 'node:path';
24
+ import { auditDb, recordEvent, retentionDays, schedulerDir } from './audit-store.js';
22
25
  import { KeyedMutex } from './session-store.js';
23
26
  const MAX_FINISHED_PER_AGENT = 500;
24
27
  const SESSION_PREFIX = 'run-';
@@ -76,10 +79,122 @@ export class FileRunStore {
76
79
  });
77
80
  }
78
81
  }
82
+ const UNDER_WAY = "('running', 'awaiting_approval')";
83
+ /** Runs in the workspace's database (core/audit-store.ts). list() is what
84
+ * the console shows: every run under way, and each agent's latest
85
+ * `listed` finished ones; older runs stay until the retention period
86
+ * ends. */
87
+ export class SqliteRunStore {
88
+ db;
89
+ listed;
90
+ lastPrune = 0;
91
+ /** `importFrom`: a scheduler folder whose runs/ JSON files are copied in
92
+ * the first time. */
93
+ constructor(db, options = {}) {
94
+ this.db = db;
95
+ this.listed = options.listed ?? MAX_FINISHED_PER_AGENT;
96
+ if (options.importFrom)
97
+ this.importFiles(options.importFrom);
98
+ }
99
+ importFiles(dir) {
100
+ const done = this.db.prepare("SELECT value FROM meta WHERE key = 'runs_imported'").get();
101
+ if (done)
102
+ return;
103
+ const runsDir = path.join(dir, 'runs');
104
+ let count = 0;
105
+ if (existsSync(runsDir)) {
106
+ this.db.exec('BEGIN');
107
+ try {
108
+ for (const name of readdirSync(runsDir)) {
109
+ if (!name.endsWith('.json'))
110
+ continue;
111
+ try {
112
+ const run = JSON.parse(readFileSync(path.join(runsDir, name), 'utf8'));
113
+ if (run.run_id && run.agent) {
114
+ this.write(run, 'OR IGNORE');
115
+ count++;
116
+ }
117
+ }
118
+ catch {
119
+ // Not a run: skip it.
120
+ }
121
+ }
122
+ this.db.exec('COMMIT');
123
+ }
124
+ catch (err) {
125
+ this.db.exec('ROLLBACK');
126
+ throw err;
127
+ }
128
+ }
129
+ // The files stay, untouched, as they were.
130
+ this.db.prepare("INSERT OR REPLACE INTO meta (key, value) VALUES ('runs_imported', ?)").run(`${new Date().toISOString()} ${count}`);
131
+ }
132
+ write(run, conflict = 'OR REPLACE') {
133
+ this.db.prepare(`INSERT ${conflict} INTO runs (run_id, agent, workflow_id, status, started_at, finished_at, session_id, data) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`)
134
+ .run(run.run_id, run.agent, run.workflow_id ?? '', run.status, run.started_at, run.finished_at ?? null, run.session_id ?? '', JSON.stringify(run));
135
+ }
136
+ read(row) {
137
+ return JSON.parse(String(row.data));
138
+ }
139
+ async list() {
140
+ const rows = this.db.prepare(`
141
+ SELECT data, started_at FROM runs WHERE status IN ${UNDER_WAY}
142
+ UNION ALL
143
+ SELECT data, started_at FROM (
144
+ SELECT data, started_at, ROW_NUMBER() OVER (PARTITION BY agent ORDER BY started_at DESC) AS n
145
+ FROM runs WHERE status NOT IN ${UNDER_WAY}
146
+ ) WHERE n <= ?
147
+ ORDER BY started_at DESC`).all(this.listed);
148
+ return rows.map((r) => this.read(r));
149
+ }
150
+ async forAgent(agent, filter) {
151
+ const limit = Math.min(filter.limit ?? this.listed, this.listed);
152
+ const rows = filter.workflowId
153
+ ? this.db.prepare('SELECT data FROM runs WHERE agent = ? AND workflow_id = ? ORDER BY started_at DESC LIMIT ?').all(agent, filter.workflowId, limit)
154
+ : this.db.prepare('SELECT data FROM runs WHERE agent = ? ORDER BY started_at DESC LIMIT ?').all(agent, limit);
155
+ return rows.map((r) => this.read(r));
156
+ }
157
+ async since(agent, workflowId, since) {
158
+ return this.db.prepare('SELECT data FROM runs WHERE agent = ? AND workflow_id = ? AND started_at >= ? ORDER BY started_at').all(agent, workflowId, since).map((r) => this.read(r));
159
+ }
160
+ async bySession(sessionId) {
161
+ const row = this.db.prepare('SELECT data FROM runs WHERE session_id = ? ORDER BY started_at DESC LIMIT 1').get(sessionId);
162
+ return row ? this.read(row) : undefined;
163
+ }
164
+ async get(runId) {
165
+ const row = this.db.prepare('SELECT data FROM runs WHERE run_id = ?').get(runId);
166
+ return row ? this.read(row) : undefined;
167
+ }
168
+ async put(run) {
169
+ this.write(run);
170
+ }
171
+ async remove(runId) {
172
+ this.db.prepare('DELETE FROM runs WHERE run_id = ?').run(runId);
173
+ }
174
+ // node:sqlite is synchronous, so read-change-write here can't interleave.
175
+ async update(runId, fn) {
176
+ const next = fn(await this.get(runId));
177
+ if (next)
178
+ this.write(next);
179
+ return next;
180
+ }
181
+ /** At most hourly: runs finished before the retention period. */
182
+ async prune() {
183
+ if (Date.now() - this.lastPrune < 60 * 60 * 1000)
184
+ return;
185
+ this.lastPrune = Date.now();
186
+ const before = new Date(Date.now() - retentionDays() * 24 * 60 * 60 * 1000).toISOString();
187
+ this.db.prepare(`DELETE FROM runs WHERE status NOT IN ${UNDER_WAY} AND COALESCE(finished_at, started_at) < ?`).run(before);
188
+ }
189
+ }
79
190
  let store;
80
- /** The process-wide store: `runs/` in the scheduler's folder. */
191
+ /** The process-wide store: the workspace's database, or JSON files in
192
+ * `runs/` in the scheduler's folder where there's none. */
81
193
  export function getRunStore() {
82
- store ??= new FileRunStore(process.env.LOOPENGINE_SCHEDULER_DIR || path.join(process.cwd(), '.scheduler'));
194
+ if (!store) {
195
+ const db = auditDb();
196
+ store = db ? new SqliteRunStore(db, { importFrom: schedulerDir() }) : new FileRunStore(schedulerDir());
197
+ }
83
198
  return store;
84
199
  }
85
200
  export function setRunStore(next) {
@@ -88,9 +203,20 @@ export function setRunStore(next) {
88
203
  // ---------- reading ----------
89
204
  /** An agent's runs, newest first; of one workflow when `workflowId` is given. */
90
205
  export async function listRuns(agent, filter = {}) {
206
+ const store = getRunStore();
207
+ if (store.forAgent)
208
+ return store.forAgent(agent, filter);
91
209
  const runs = (await getRunStore().list()).filter((r) => r.agent === agent && (!filter.workflowId || r.workflow_id === filter.workflowId));
92
210
  return filter.limit ? runs.slice(0, filter.limit) : runs;
93
211
  }
212
+ /** A workflow's runs started at or after `since` (an ISO time), oldest
213
+ * first; from the console's list where the store keeps no more. */
214
+ export async function runsSince(agent, workflowId, since) {
215
+ const store = getRunStore();
216
+ if (store.since)
217
+ return store.since(agent, workflowId, since);
218
+ return (await listRuns(agent, { workflowId })).filter((r) => r.started_at >= since).reverse();
219
+ }
94
220
  /** One of an agent's runs; undefined for another agent's. */
95
221
  export async function getRun(agent, runId) {
96
222
  if (!/^[A-Za-z0-9_-]+$/.test(runId))
@@ -105,14 +231,29 @@ export class WorkflowRunner {
105
231
  execute;
106
232
  maxFinishedPerAgent;
107
233
  onChange;
234
+ versionsFor;
108
235
  inFlight = new Set();
109
236
  /** `onChange`: called with the run when it starts, and each time it
110
237
  * finishes, fails or stops for a decision (the server sends its chat
111
- * messages and callbacks). */
238
+ * messages and callbacks). `versionsFor`: the brief and policies
239
+ * versions a run of this workflow starts under. */
112
240
  constructor(options) {
113
241
  this.execute = options.execute;
114
242
  this.maxFinishedPerAgent = options.maxFinishedPerAgent ?? MAX_FINISHED_PER_AGENT;
115
243
  this.onChange = options.onChange;
244
+ this.versionsFor = options.versionsFor;
245
+ }
246
+ versionsOf(agent, workflowId) {
247
+ if (!this.versionsFor || !workflowId)
248
+ return {};
249
+ try {
250
+ const versions = this.versionsFor(agent, workflowId);
251
+ return versions && (versions.brief || versions.policies) ? { versions } : {};
252
+ }
253
+ catch (err) {
254
+ console.error('[loopengine] could not note the versions a run starts under:', err);
255
+ return {};
256
+ }
116
257
  }
117
258
  changed(run) {
118
259
  if (!run || !this.onChange)
@@ -138,6 +279,7 @@ export class WorkflowRunner {
138
279
  ...(input.trigger_id ? { trigger_id: input.trigger_id } : {}),
139
280
  ...(input.job ? { job: input.job } : {}),
140
281
  ...(input.chained_from ? { chained_from: input.chained_from, chain_depth: input.chain_depth ?? 1 } : {}),
282
+ ...this.versionsOf(input.agent, input.workflow_id),
141
283
  status: 'running',
142
284
  started_at: new Date().toISOString(),
143
285
  message: input.message,
@@ -168,6 +310,7 @@ export class WorkflowRunner {
168
310
  ...(input.decisions_to ? { decisions_to: input.decisions_to } : {}),
169
311
  ...(input.chat_notice ? { chat_notice: input.chat_notice } : {}),
170
312
  ...(input.warnings?.length ? { warnings: input.warnings } : {}),
313
+ ...this.versionsOf(input.agent, input.workflow_id),
171
314
  status: 'running',
172
315
  started_at: new Date().toISOString(),
173
316
  message: input.message,
@@ -217,9 +360,7 @@ export class WorkflowRunner {
217
360
  * its resolve path, for every resumed session): settle it, or record
218
361
  * what it's waiting on now. */
219
362
  async settleFromResume(sessionId, outcome) {
220
- if (!sessionId.startsWith(SESSION_PREFIX) && !sessionId.startsWith(SCHEDULE_SESSION_PREFIX))
221
- return;
222
- const run = (await getRunStore().list()).find((r) => r.session_id === sessionId);
363
+ const run = await this.forSession(sessionId);
223
364
  if (!run)
224
365
  return;
225
366
  if (outcome.pendingIds?.length) {
@@ -232,15 +373,35 @@ export class WorkflowRunner {
232
373
  async forSession(sessionId) {
233
374
  if (!sessionId.startsWith(SESSION_PREFIX) && !sessionId.startsWith(SCHEDULE_SESSION_PREFIX))
234
375
  return undefined;
235
- return (await getRunStore().list()).find((r) => r.session_id === sessionId);
376
+ const store = getRunStore();
377
+ if (store.bySession)
378
+ return store.bySession(sessionId);
379
+ return (await store.list()).find((r) => r.session_id === sessionId);
236
380
  }
237
- /** Records an approval decided in a run's session. */
381
+ /** Records an approval decided in a run's session: on the run, and in
382
+ * the workspace's audit events. */
238
383
  async recordDecision(sessionId, decision) {
239
384
  const run = await this.forSession(sessionId);
240
385
  if (!run)
241
386
  return;
242
- const entry = { tool: decision.tool, approved: decision.approved, at: new Date().toISOString(), ...(decision.by ? { by: decision.by } : {}), ...(decision.edited ? { edited: true } : {}) };
387
+ const reason = decision.reason?.trim().slice(0, 2000);
388
+ const entry = {
389
+ tool: decision.tool,
390
+ approved: decision.approved,
391
+ at: new Date().toISOString(),
392
+ ...(decision.by ? { by: decision.by } : {}),
393
+ ...(decision.edited ? { edited: true, before: clip(decision.before), after: clip(decision.after) } : {}),
394
+ ...(reason ? { reason } : {}),
395
+ };
243
396
  await getRunStore().update(run.run_id, (r) => r && { ...r, decisions: [...(r.decisions ?? []), entry].slice(-50) });
397
+ const { at, by, ...data } = entry;
398
+ recordEvent({ at, agent: run.agent, workflow_id: run.workflow_id, run_id: run.run_id, kind: 'decision', ...(by ? { by } : {}), data });
399
+ }
400
+ /** Records feedback given on a run's result in the audit events (the
401
+ * run itself carries the latest). */
402
+ recordFeedback(run, feedback, by) {
403
+ const { at, ...data } = feedback;
404
+ recordEvent({ at, agent: run.agent, workflow_id: run.workflow_id, run_id: run.run_id, kind: 'feedback', ...(by ? { by } : {}), data });
244
405
  }
245
406
  /** Records a question answered in a run's session. */
246
407
  async recordAnswer(sessionId, answer) {
@@ -249,6 +410,7 @@ export class WorkflowRunner {
249
410
  return;
250
411
  const entry = { question: answer.question.slice(0, 4000), answer: answer.answer.slice(0, 4000), at: new Date().toISOString(), ...(answer.by ? { by: answer.by } : {}) };
251
412
  await getRunStore().update(run.run_id, (r) => r && { ...r, answers: [...(r.answers ?? []), entry].slice(-50) });
413
+ recordEvent({ at: entry.at, agent: run.agent, workflow_id: run.workflow_id, run_id: run.run_id, kind: 'answer', ...(answer.by ? { by: answer.by } : {}), data: { question: entry.question, answer: entry.answer } });
252
414
  }
253
415
  /** On startup: a run a restart cut off can't continue, so it's an
254
416
  * error. One waiting on a decision is kept: its checkpoint survives. */
@@ -259,8 +421,19 @@ export class WorkflowRunner {
259
421
  }
260
422
  }
261
423
  async prune(agent) {
424
+ const store = getRunStore();
425
+ if (store.prune)
426
+ return store.prune();
262
427
  const finished = (await listRuns(agent)).filter((r) => !isUnderWay(r));
263
428
  for (const old of finished.slice(this.maxFinishedPerAgent))
264
429
  await getRunStore().remove(old.run_id);
265
430
  }
266
431
  }
432
+ // A tool input kept on a decision: as given when small, else its JSON cut
433
+ // to 8,000 characters.
434
+ function clip(value) {
435
+ if (value === undefined)
436
+ return undefined;
437
+ const text = JSON.stringify(value);
438
+ return text.length <= 8000 ? value : text.slice(0, 8000);
439
+ }
package/dist/index.d.ts CHANGED
@@ -62,7 +62,7 @@ export { Compactor, TruncatingSummarizer } from './core/compaction.js';
62
62
  export type { Summarizer, RecoverResult, RecoverAction } from './core/compaction.js';
63
63
  export { LLMSummarizer } from './core/llm-summarizer.js';
64
64
  export type { LLMSummarizerOptions } from './core/llm-summarizer.js';
65
- export { createCheckpointStore } from './core/durable-approvals.js';
65
+ export { createCheckpointStore, SqliteCheckpointStore } from './core/durable-approvals.js';
66
66
  export type { TurnCheckpoint, CheckpointStore, OutstandingItem } from './core/durable-approvals.js';
67
67
  export { addGatewayTool, agentDir, inferAgentNameFromToolUrl, disconnectComposioAccount, describeGatewayTools, listComposioConnections, listComposioTools, loadGatewayToolsFromDir, removeGatewayTool, removeGatewayToolSlug, GatewayToolExistsError, GatewayToolNotFoundError, } from './core/gateway-tools.js';
68
68
  export type { GatewayToolEntry, GatewayToolDecision } from './core/gateway-tools.js';
@@ -92,7 +92,8 @@ export { WORKFLOW_EXAMPLES, workflowExample, type WorkflowExample } from './core
92
92
  export { WORKFLOW_EXAMPLE_MESSAGES, type WorkflowExampleMessage } from './core/system-agents/workflow-example-messages.js';
93
93
  export { createTrigger, updateTrigger, rotateTrigger, listTriggers, findTriggerByToken, publicTrigger, checkTriggerSettings, verifySenderSignature, parsePayload, valueAt, deliveryId, passesFilter, paramsFromPayload, checkRunDelivery, fillChatNotice, resultToChat, recordDelivery as recordTriggerDelivery, FileTriggerStore, getTriggerStore, setTriggerStore, TriggerError, type WorkflowTrigger, type PublicTrigger, type TriggerSettings, type TriggerVerify, type TriggerFilter, type TriggerSender, type SignatureAlgorithm, type TriggerDelivery, type TriggerOutcome, type TriggerStore } from './core/workflow-triggers.js';
94
94
  export { checkCallbackUrl, callbackSecret, signCallback, deliverCallback, runCallbackPayload, isPrivateAddress, CallbackUrlError, type CallbackDelivery, type CallbackPending, type RunCallbackEvent } from './core/run-callbacks.js';
95
- export { WorkflowRunner, FileRunStore, getRunStore, setRunStore, listRuns, getRun, isUnderWay, RunError, type WorkflowRun, type WorkflowRunStatus, type RunStore, type ExecuteRun, type RunOutcome, type StartRunInput } from './core/workflow-runs.js';
95
+ export { auditDb, openAuditDb, setAuditDb, recordEvent, runEvents, noteVersion, listVersions, getVersion, briefContent, briefFromContent, retentionDays, type Version, type VersionKind, type AuditEvent, type AuditEventKind } from './core/audit-store.js';
96
+ export { WorkflowRunner, FileRunStore, SqliteRunStore, getRunStore, setRunStore, listRuns, getRun, isUnderWay, RunError, type WorkflowRun, type WorkflowRunStatus, type RunVersions, type RunDecision, type RunStore, type ExecuteRun, type RunOutcome, type StartRunInput } from './core/workflow-runs.js';
96
97
  export { readWorkflows, readWorkflow, setWorkflowFields, setWorkflowDelivery, clearWorkflowFields, validateParams, workflowRunMessage, workflowPreviewMessage, migrateWorkflowsFile, WorkflowParamsError, readWorkspacePolicies, writeWorkspacePolicies, type Workflow, type WorkflowFields, type WorkflowParameter, type WorkflowModel, type WorkflowDelivery, type RunMessageExtras } from './core/workflows.js';
97
98
  export { EvidenceError, workflowScores, runFeedbackFrom, readEvals, addEvalCase, updateEvalCase, removeEvalCase, setEvalCriteria, effectiveCriteria, codeCheck, judgeCriteria, checkCase, roundSummary, draftCriteria, startEvalRound, EVAL_CRITERIA_PROMPT, DRAFT_CRITERIA_PROMPT, REFERENCE_CRITERION, type WorkflowScores, type EvalCase, type EvalCaseResult, type EvalCheck, type EvalCriterion, type CriterionKind, type EvalRound, type WorkflowEvals, type EvalRunDeps } from './web/workflow-evidence.js';
98
99
  export { globalConfigPageHtml } from './web/global-config-page.js';
package/dist/index.js CHANGED
@@ -59,7 +59,7 @@ export { agentAsTool } from './core/agent-as-tool.js';
59
59
  export { resumeAgent, loadRules, loadDefaultTools, loadSubagentAsTools, systemTools, systemSkillsDir } from './core/run-agent.js';
60
60
  export { Compactor, TruncatingSummarizer } from './core/compaction.js';
61
61
  export { LLMSummarizer } from './core/llm-summarizer.js';
62
- export { createCheckpointStore } from './core/durable-approvals.js';
62
+ export { createCheckpointStore, SqliteCheckpointStore } from './core/durable-approvals.js';
63
63
  export { addGatewayTool, agentDir, inferAgentNameFromToolUrl, disconnectComposioAccount, describeGatewayTools, listComposioConnections, listComposioTools, loadGatewayToolsFromDir, removeGatewayTool, removeGatewayToolSlug, GatewayToolExistsError, GatewayToolNotFoundError, } from './core/gateway-tools.js';
64
64
  export { connectComposioSource } from './core/mcpplug.js';
65
65
  export { ToolLane, buildLanes, runLanes } from './core/toollane.js';
@@ -85,7 +85,8 @@ export { WORKFLOW_EXAMPLES, workflowExample } from './core/system-agents/workflo
85
85
  export { WORKFLOW_EXAMPLE_MESSAGES } from './core/system-agents/workflow-example-messages.js';
86
86
  export { createTrigger, updateTrigger, rotateTrigger, listTriggers, findTriggerByToken, publicTrigger, checkTriggerSettings, verifySenderSignature, parsePayload, valueAt, deliveryId, passesFilter, paramsFromPayload, checkRunDelivery, fillChatNotice, resultToChat, recordDelivery as recordTriggerDelivery, FileTriggerStore, getTriggerStore, setTriggerStore, TriggerError } from './core/workflow-triggers.js';
87
87
  export { checkCallbackUrl, callbackSecret, signCallback, deliverCallback, runCallbackPayload, isPrivateAddress, CallbackUrlError } from './core/run-callbacks.js';
88
- export { WorkflowRunner, FileRunStore, getRunStore, setRunStore, listRuns, getRun, isUnderWay, RunError } from './core/workflow-runs.js';
88
+ export { auditDb, openAuditDb, setAuditDb, recordEvent, runEvents, noteVersion, listVersions, getVersion, briefContent, briefFromContent, retentionDays } from './core/audit-store.js';
89
+ export { WorkflowRunner, FileRunStore, SqliteRunStore, getRunStore, setRunStore, listRuns, getRun, isUnderWay, RunError } from './core/workflow-runs.js';
89
90
  export { readWorkflows, readWorkflow, setWorkflowFields, setWorkflowDelivery, clearWorkflowFields, validateParams, workflowRunMessage, workflowPreviewMessage, migrateWorkflowsFile, WorkflowParamsError, readWorkspacePolicies, writeWorkspacePolicies } from './core/workflows.js';
90
91
  export { EvidenceError, workflowScores, runFeedbackFrom, readEvals, addEvalCase, updateEvalCase, removeEvalCase, setEvalCriteria, effectiveCriteria, codeCheck, judgeCriteria, checkCase, roundSummary, draftCriteria, startEvalRound, EVAL_CRITERIA_PROMPT, DRAFT_CRITERIA_PROMPT, REFERENCE_CRITERION } from './web/workflow-evidence.js';
91
92
  export { globalConfigPageHtml } from './web/global-config-page.js';
package/dist/models.yaml CHANGED
@@ -83,3 +83,61 @@ glm:
83
83
  - glm-5.3
84
84
  - glm-5.2
85
85
  - glm-5.1
86
+
87
+ # Prices, in US dollars per million tokens (standard tier, the base rate
88
+ # for shorter prompts), for the cost shown on each case and in a
89
+ # workflow's health. Taken from each provider's pricing page on
90
+ # 2026-11-24. A workspace's models.yaml can set its own, model by model.
91
+ # Not listed: gemini-3.7-flash (not on Google's pricing page).
92
+ # Known changes: gemini-4-argon and gemini-4-carbon double from
93
+ # 2026-12-01, gemini-3.8-flash and gemini-3.6-flash from 2027-01-01.
94
+ # DeepSeek's are its off-peak rates; at peak hours (weekdays 01:00-04:00
95
+ # and 06:00-10:00 UTC) it charges twice these.
96
+ prices:
97
+ openai:
98
+ gpt-6.2-sol: { input: 2.00, cached_input: 0.10, output: 10.00 }
99
+ gpt-6.2-astra: { input: 8.00, cached_input: 0.40, output: 40.00 }
100
+ gpt-6.1-terra: { input: 1.00, cached_input: 0.05, output: 5.00 }
101
+ gpt-6.1-sol: { input: 2.00, cached_input: 0.10, output: 10.00 }
102
+ gpt-6-luna: { input: 0.10, cached_input: 0.01, output: 0.50 }
103
+ gpt-6-sol: { input: 2.00, cached_input: 0.20, output: 10.00 }
104
+ gpt-6-astra: { input: 10.00, cached_input: 1.00, output: 50.00 }
105
+ gpt-5.6-sol: { input: 4.00, cached_input: 0.40, output: 20.00 }
106
+ gpt-5.6-terra: { input: 2.00, cached_input: 0.20, output: 12.00 }
107
+ gpt-5.6-luna: { input: 0.20, cached_input: 0.02, output: 1.20 }
108
+ anthropic:
109
+ claude-fable-5-2: { input: 8, cached_input: 0.20, output: 40 }
110
+ claude-fable-5-1: { input: 10, cached_input: 0.25, output: 50 }
111
+ claude-opus-5-5: { input: 4, cached_input: 0.20, output: 20 }
112
+ claude-sonnet-5-5: { input: 2, cached_input: 0.10, output: 10 }
113
+ claude-haiku-5-5: { input: 0.10, cached_input: 0.01, output: 0.50 }
114
+ gemini:
115
+ gemini-4-neon: { input: 3.00, cached_input: 0.15, output: 15.00 }
116
+ gemini-4-argon: { input: 2.00, cached_input: 0.10, output: 10.00 }
117
+ gemini-4-carbon: { input: 2.00, cached_input: 0.10, output: 10.00 }
118
+ gemini-4-hydrogen: { input: 1.50, cached_input: 0.075, output: 7.50 }
119
+ gemini-3.8-flash: { input: 0.75, cached_input: 0.075, output: 3.75 }
120
+ gemini-3.6-flash: { input: 0.75, cached_input: 0.075, output: 3.75 }
121
+ gemini-3.1-pro-preview: { input: 2.00, cached_input: 0.20, output: 12.00 }
122
+ meta:
123
+ muse-spark-1.3: { input: 1.25, cached_input: 0.15, output: 4.25 }
124
+ muse-wonder: { input: 4.00, cached_input: 0.20, output: 20.00 }
125
+ muse-spark-1.2: { input: 1.25, cached_input: 0.15, output: 4.25 }
126
+ muse-spark-1.1: { input: 1.25, cached_input: 0.15, output: 4.25 }
127
+ xai:
128
+ grok-4.7: { input: 2.00, cached_input: 0.50, output: 6.00 }
129
+ grok-4.6: { input: 2.00, cached_input: 0.50, output: 6.00 }
130
+ grok-4.5: { input: 2.00, cached_input: 0.30, output: 6.00 }
131
+ deepseek:
132
+ deepseek-v4-pro: { input: 0.66, cached_input: 0.022, output: 1.98 }
133
+ deepseek-flash: { input: 0.15, cached_input: 0.003, output: 0.60 }
134
+ # The retired alias still runs as deepseek-flash.
135
+ deepseek-v4-flash: { input: 0.15, cached_input: 0.003, output: 0.60 }
136
+ kimi:
137
+ kimi-k3.1-pro: { input: 2.00, cached_input: 0.20, output: 10.00 }
138
+ kimi-k3: { input: 3.00, cached_input: 0.30, output: 15.00 }
139
+ kimi-k2.7-code: { input: 0.95, cached_input: 0.19, output: 4.00 }
140
+ glm:
141
+ glm-5.3: { input: 1.40, cached_input: 0.26, output: 4.40 }
142
+ glm-5.2: { input: 1.40, cached_input: 0.26, output: 4.40 }
143
+ glm-5.1: { input: 1.40, cached_input: 0.26, output: 4.40 }