relay-opencode 0.0.0-stage → 0.2.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.
- package/LICENSE +21 -0
- package/README.md +122 -2
- package/dist/artificial-analysis.d.ts +50 -0
- package/dist/artificial-analysis.js +153 -0
- package/dist/chat-facts.d.ts +26 -0
- package/dist/chat-facts.js +96 -0
- package/dist/contract.d.ts +2727 -0
- package/dist/contract.js +111 -0
- package/dist/costs.d.ts +14 -0
- package/dist/costs.js +47 -0
- package/dist/decider.d.ts +73 -0
- package/dist/decider.js +199 -0
- package/dist/gui-experimental.cjs +92 -0
- package/dist/gui-styles.d.ts +5 -0
- package/dist/gui-styles.js +95 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +62 -0
- package/dist/intelligence.d.ts +38 -0
- package/dist/intelligence.js +123 -0
- package/dist/inventory.d.ts +34 -0
- package/dist/inventory.js +28 -0
- package/dist/ranking.d.ts +31 -0
- package/dist/ranking.js +78 -0
- package/dist/relay-auto.d.ts +39 -0
- package/dist/relay-auto.js +96 -0
- package/dist/relay-command.d.ts +74 -0
- package/dist/relay-command.js +211 -0
- package/dist/relay-store.d.ts +124 -0
- package/dist/relay-store.js +196 -0
- package/dist/relay-view.d.ts +124 -0
- package/dist/relay-view.js +189 -0
- package/dist/review-helper.d.ts +8 -0
- package/dist/review-helper.js +68 -0
- package/dist/router.d.ts +122 -0
- package/dist/router.js +209 -0
- package/dist/rpc.d.ts +2725 -0
- package/dist/rpc.js +116 -0
- package/dist/settings.d.ts +16 -0
- package/dist/settings.js +22 -0
- package/dist/standings.d.ts +18 -0
- package/dist/standings.js +34 -0
- package/dist/tui.d.ts +3 -0
- package/dist/tui.js +26 -0
- package/dist/usage-log.d.ts +135 -0
- package/dist/usage-log.js +210 -0
- package/dist/usage-view.d.ts +70 -0
- package/dist/usage-view.js +104 -0
- package/package.json +46 -4
package/dist/rpc.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { RelayRpc } from './contract.js';
|
|
2
|
+
export { RelayRpc } from './contract.js';
|
|
3
|
+
import { listProjectModels } from './inventory.js';
|
|
4
|
+
import { getRelaySettings, saveRelaySettings, recentDecisions, modelName, modes, chatSwitch, setChatSwitch, getUsage } from './relay-store.js';
|
|
5
|
+
import { candidates, checksStatus, describeError, linesFor, route, sizesFor } from './router.js';
|
|
6
|
+
import { rank } from './ranking.js';
|
|
7
|
+
import { readStored, standingsOf } from './standings.js';
|
|
8
|
+
import { decide } from './decider.js';
|
|
9
|
+
import { INDEX_SOURCE, indexFor, loadIndexTable } from './intelligence.js';
|
|
10
|
+
import { AA_CREDIT, AA_SOURCE, aaFor, getPriceKey, loadAaModels, setPriceKey } from './artificial-analysis.js';
|
|
11
|
+
import { oldestRecord, pruneRecords, readRecords, summarize, usageQueryOf } from './usage-log.js';
|
|
12
|
+
const chatID = (input) => { const id = input.sessionID.trim(); if (!id)
|
|
13
|
+
throw new Error('Name the chat'); return id; };
|
|
14
|
+
/** The panel's and the pill's calls. Relay's settings are one set for every project; only the model lists come from this project's host. */
|
|
15
|
+
export function registerRpc(context, options = {}) {
|
|
16
|
+
const relayStore = context.storage;
|
|
17
|
+
// One fetch of the index at a time, shared by the calls that arrive while it runs.
|
|
18
|
+
let indexLoad;
|
|
19
|
+
const indexTable = () => indexLoad ??= loadIndexTable(context.storage, options.fetcher ?? fetch, (options.now ?? Date.now)()).finally(() => { indexLoad = undefined; });
|
|
20
|
+
// The same for Artificial Analysis's list, which only a saved key may fetch.
|
|
21
|
+
let aaLoad;
|
|
22
|
+
const aaModels = (key) => aaLoad ??= loadAaModels(context.storage, key, options.fetcher ?? fetch, (options.now ?? Date.now)()).finally(() => { aaLoad = undefined; });
|
|
23
|
+
const relayView = async (settings, chat, deciders) => ({ directory: context.location.directory, settings, decisions: await recentDecisions(relayStore), deciders, checks: checksStatus(settings, chat), priceKey: (await getPriceKey(relayStore)) !== null });
|
|
24
|
+
return context.rpc.register(RelayRpc, guarded({
|
|
25
|
+
listModels: async () => ({ directory: context.location.directory, models: await listProjectModels(context) }),
|
|
26
|
+
// With a saved key the index is Artificial Analysis's own; without one, or when its list cannot be had, OpenRouter's copy of it.
|
|
27
|
+
listIntelligence: async () => {
|
|
28
|
+
const [key, chat, deciders] = await Promise.all([getPriceKey(relayStore), listProjectModels(context), listProjectModels(context, 'decision')]);
|
|
29
|
+
const seen = new Set(), models = [...chat, ...deciders].filter(model => { const name = `${model.providerID}/${model.id}`; return !seen.has(name) && !!seen.add(name); });
|
|
30
|
+
const aa = key ? await aaModels(key) : null;
|
|
31
|
+
if (aa?.models.length) {
|
|
32
|
+
const scores = models.flatMap(model => { const hit = aaFor({ ...model, variant: null }, aa.models); return hit && hit.index !== null ? [{ providerID: model.providerID, id: model.id, index: hit.index, matched: hit.slug }] : []; });
|
|
33
|
+
return { directory: context.location.directory, source: AA_SOURCE, fetchedAt: aa.fetchedAt, note: aa.note, scores };
|
|
34
|
+
}
|
|
35
|
+
const found = await indexTable();
|
|
36
|
+
const scores = models.flatMap(model => { const hit = indexFor(model, found.table); return hit ? [{ providerID: model.providerID, id: model.id, index: hit.index, matched: hit.matched }] : []; });
|
|
37
|
+
return { directory: context.location.directory, source: INDEX_SOURCE, fetchedAt: found.fetchedAt, note: [aa?.note, found.note].filter(Boolean).join('; ') || null, scores };
|
|
38
|
+
},
|
|
39
|
+
// Usage by model, for the panel and /relay-stats. Storage only, so the panel can ask every few seconds.
|
|
40
|
+
getRelayUsage: async () => {
|
|
41
|
+
const [usage, key] = await Promise.all([getUsage(relayStore), getPriceKey(relayStore)]);
|
|
42
|
+
return { directory: context.location.directory, ...usage, credit: key !== null || usage.rows.some(row => row.pricesFrom === 'artificial-analysis') ? AA_CREDIT : null };
|
|
43
|
+
},
|
|
44
|
+
// Which model of each mode gets big work and small work by itself. Worked out here, not in the panel: the panel has neither each
|
|
45
|
+
// effort's own score nor the Coding index. Storage only, with the same rule as /relay (src/ranking.ts).
|
|
46
|
+
// The usage tab: one range of usage records, added up and filtered here. Old records go first, 1,000 at most a call. Storage only.
|
|
47
|
+
getUsageLog: async (input) => {
|
|
48
|
+
const query = usageQueryOf(input), log = context.storage;
|
|
49
|
+
const removed = await pruneRecords(log, (options.now ?? Date.now)());
|
|
50
|
+
const [records, oldest, before] = await Promise.all([readRecords(log, query.from, query.to), oldestRecord(log), getUsage(relayStore)]);
|
|
51
|
+
const summary = summarize(records, query);
|
|
52
|
+
const credit = summary.totals.some(total => total.aaPriced) || before.rows.some(row => row.pricesFrom === 'artificial-analysis') ? AA_CREDIT : null;
|
|
53
|
+
return { directory: context.location.directory, ...summary, first: oldest ?? summary.first, before, credit, removed };
|
|
54
|
+
},
|
|
55
|
+
getOwnChoice: async () => {
|
|
56
|
+
const [settings, models, stored] = await Promise.all([getRelaySettings(relayStore), listProjectModels(context), readStored(relayStore)]);
|
|
57
|
+
const standings = standingsOf(stored, models, modes.flatMap(mode => settings.modes[mode])), nothingAttached = { needsImage: false, tokens: 0 };
|
|
58
|
+
const part = (mode) => {
|
|
59
|
+
const list = settings.modes[mode], ranked = rank(mode, list, candidates(mode, list, models, nothingAttached).usable, standings, null);
|
|
60
|
+
if (ranked === null)
|
|
61
|
+
return null;
|
|
62
|
+
return ranked.kind === 'unranked' ? { kind: 'unranked', reason: ranked.reason } : { kind: 'ranked', strongest: modelName(ranked.strongest), cheapest: modelName(ranked.cheapest) };
|
|
63
|
+
};
|
|
64
|
+
return { directory: context.location.directory, modes: { plan: part('plan'), execute: part('execute'), review: part('review') } };
|
|
65
|
+
},
|
|
66
|
+
// The key is saved and the list loaded with it at once, so a refused key shows now. The key is never sent back.
|
|
67
|
+
setPriceKey: async (input) => {
|
|
68
|
+
await setPriceKey(context.storage, input.key);
|
|
69
|
+
const saved = await getPriceKey(relayStore);
|
|
70
|
+
return { saved: saved !== null, note: saved === null ? null : (await aaModels(saved)).note };
|
|
71
|
+
},
|
|
72
|
+
getRelay: async () => {
|
|
73
|
+
const [settings, chat, deciders] = await Promise.all([getRelaySettings(relayStore), listProjectModels(context), listProjectModels(context, 'decision')]);
|
|
74
|
+
return relayView(settings, chat, deciders);
|
|
75
|
+
},
|
|
76
|
+
saveRelay: async (input) => {
|
|
77
|
+
const { revision, ...next } = input;
|
|
78
|
+
const [chat, deciders] = await Promise.all([listProjectModels(context), listProjectModels(context, 'decision')]);
|
|
79
|
+
return relayView(await saveRelaySettings(relayStore, revision, next, chat, deciders), chat, deciders);
|
|
80
|
+
},
|
|
81
|
+
// The pill: one chat's switch, that chat's newest record, and whether Relay can switch anything at all.
|
|
82
|
+
getRelayChat: async (input) => {
|
|
83
|
+
const sessionID = chatID(input);
|
|
84
|
+
const [on, decisions, settings] = await Promise.all([chatSwitch(relayStore, sessionID), recentDecisions(relayStore), getRelaySettings(relayStore)]);
|
|
85
|
+
return { on, last: decisions.find(item => item.sessionID === sessionID) ?? null, decider: settings.decider !== null };
|
|
86
|
+
},
|
|
87
|
+
getRelayDecisions: async () => ({ directory: context.location.directory, decisions: await recentDecisions(relayStore) }),
|
|
88
|
+
setRelayChat: async (input) => {
|
|
89
|
+
const sessionID = chatID(input), on = input.on;
|
|
90
|
+
await setChatSwitch(relayStore, sessionID, on);
|
|
91
|
+
return { on };
|
|
92
|
+
},
|
|
93
|
+
testDecider: async (input) => {
|
|
94
|
+
const text = input.text;
|
|
95
|
+
if (!text.trim())
|
|
96
|
+
throw new Error('Type a sample message');
|
|
97
|
+
const [settings, models, stored] = await Promise.all([getRelaySettings(relayStore), listProjectModels(context), readStored(relayStore)]);
|
|
98
|
+
// The same path as /relay with nothing attached and no chat: the lines or sizes asked about and the pick come from the router.
|
|
99
|
+
const attachment = { needsImage: false, tokens: 0 }, standings = standingsOf(stored, models, modes.flatMap(mode => settings.modes[mode]));
|
|
100
|
+
const answer = await decide({ decisions: request => context.experimental.generate.decisions(request) }, settings.decider, { kind: 'chat', text, agent: null, files: [], images: 0, lines: linesFor(settings, models, attachment), sizes: sizesFor(settings, models, attachment, null, standings) });
|
|
101
|
+
const result = route(answer, settings, models, attachment, null, 'plan', standings);
|
|
102
|
+
return { directory: context.location.directory, mode: result.mode, confidence: answer.kind === 'answer' ? answer.confidence : null, model: result.switch ? modelName(result.model) : null, fit: result.switch ? result.fit : null, ms: answer.ms, costUsd: answer.kind === 'answer' ? answer.costUsd : null, note: result.note };
|
|
103
|
+
},
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
/** A handler that throws reaches the client as "RPC call failed" in the real host; return its message as the declared 'rejected' error so the panel can show it. */
|
|
107
|
+
function guarded(handlers) {
|
|
108
|
+
return Object.fromEntries(Object.entries(handlers).map(([name, handler]) => [name, async (input, call) => {
|
|
109
|
+
try {
|
|
110
|
+
return await handler(input, call);
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
return call.error('rejected', describeError(error, 'The request failed.').slice(0, 500), {});
|
|
114
|
+
}
|
|
115
|
+
}]));
|
|
116
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type ModelChoice = {
|
|
2
|
+
providerID: string;
|
|
3
|
+
id: string;
|
|
4
|
+
variant: string | null;
|
|
5
|
+
};
|
|
6
|
+
export type OfferedModel = {
|
|
7
|
+
providerID: string;
|
|
8
|
+
id: string;
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
status: string;
|
|
11
|
+
variants: readonly string[];
|
|
12
|
+
};
|
|
13
|
+
/** One list of model choices: every entry well formed, and none twice. */
|
|
14
|
+
export declare function validateChoices(value: unknown): ModelChoice[];
|
|
15
|
+
/** The listed model a choice points at, when it can be used now: listed, enabled, not deprecated, and offering the chosen variant. */
|
|
16
|
+
export declare function offered<M extends OfferedModel>(models: readonly M[], choice: ModelChoice): M | undefined;
|
package/dist/settings.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// The checks every model choice goes through: well formed, not listed twice, and offered by the host now.
|
|
2
|
+
const id = (choice) => JSON.stringify([choice.providerID, choice.id, choice.variant]);
|
|
3
|
+
/** One list of model choices: every entry well formed, and none twice. */
|
|
4
|
+
export function validateChoices(value) {
|
|
5
|
+
if (!Array.isArray(value))
|
|
6
|
+
throw new Error('Invalid role choices');
|
|
7
|
+
const seen = new Set();
|
|
8
|
+
for (const choice of value) {
|
|
9
|
+
if (!choice || typeof choice !== 'object' || Array.isArray(choice) || Object.keys(choice).sort().join(',') !== 'id,providerID,variant' || typeof choice.providerID !== 'string' || !choice.providerID.trim() || typeof choice.id !== 'string' || !choice.id.trim() || !(choice.variant === null || (typeof choice.variant === 'string' && choice.variant.trim())))
|
|
10
|
+
throw new Error('Invalid model choice');
|
|
11
|
+
const identity = id(choice);
|
|
12
|
+
if (seen.has(identity))
|
|
13
|
+
throw new Error('Duplicate model choice');
|
|
14
|
+
seen.add(identity);
|
|
15
|
+
}
|
|
16
|
+
return structuredClone(value);
|
|
17
|
+
}
|
|
18
|
+
/** The listed model a choice points at, when it can be used now: listed, enabled, not deprecated, and offering the chosen variant. */
|
|
19
|
+
export function offered(models, choice) {
|
|
20
|
+
const model = models.find(m => m.providerID === choice.providerID && m.id === choice.id);
|
|
21
|
+
return model && model.enabled && model.status !== 'deprecated' && (choice.variant === null || model.variants.includes(choice.variant)) ? model : undefined;
|
|
22
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type AaModel } from './artificial-analysis.js';
|
|
2
|
+
import { type IndexTable } from './intelligence.js';
|
|
3
|
+
import type { ListedModel } from './inventory.js';
|
|
4
|
+
import { type Standings } from './ranking.js';
|
|
5
|
+
import { type RelayStore, type UsageRow } from './relay-store.js';
|
|
6
|
+
import type { ModelChoice } from './settings.js';
|
|
7
|
+
export type Stored = {
|
|
8
|
+
aa: readonly AaModel[];
|
|
9
|
+
table: IndexTable;
|
|
10
|
+
usage: readonly UsageRow[];
|
|
11
|
+
};
|
|
12
|
+
/** The three stored copies, read together. A part that cannot be read counts as empty. */
|
|
13
|
+
export declare function readStored(store: Pick<RelayStore, 'get'>): Promise<Stored>;
|
|
14
|
+
/**
|
|
15
|
+
* Each choice's standing, by `modelName(choice)`. With Artificial Analysis's list (there is one only while a key is saved) the scores are its
|
|
16
|
+
* entry for the choice's effort, or its plain entry (the highest effort); without it, OpenRouter's index and no Coding index.
|
|
17
|
+
*/
|
|
18
|
+
export declare function standingsOf(stored: Stored, models: readonly ListedModel[], choices: readonly ModelChoice[]): Standings;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { aaFor, storedAaModels } from './artificial-analysis.js';
|
|
2
|
+
import { pricesAt } from './costs.js';
|
|
3
|
+
import { indexFor, storedIndexTable } from './intelligence.js';
|
|
4
|
+
import { OWN_REPLIES } from './ranking.js';
|
|
5
|
+
import { getUsage, modelName } from './relay-store.js';
|
|
6
|
+
/** The three stored copies, read together. A part that cannot be read counts as empty. */
|
|
7
|
+
export async function readStored(store) {
|
|
8
|
+
const [aa, table, usage] = await Promise.all([
|
|
9
|
+
storedAaModels(store).catch(() => []),
|
|
10
|
+
storedIndexTable(store).catch(() => new Map()),
|
|
11
|
+
getUsage(store).then(found => found.rows, () => []),
|
|
12
|
+
]);
|
|
13
|
+
return { aa, table, usage };
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Each choice's standing, by `modelName(choice)`. With Artificial Analysis's list (there is one only while a key is saved) the scores are its
|
|
17
|
+
* entry for the choice's effort, or its plain entry (the highest effort); without it, OpenRouter's index and no Coding index.
|
|
18
|
+
*/
|
|
19
|
+
export function standingsOf(stored, models, choices) {
|
|
20
|
+
const standings = new Map();
|
|
21
|
+
for (const choice of choices) {
|
|
22
|
+
const listed = models.find(model => model.providerID === choice.providerID && model.id === choice.id), name = listed?.name ?? choice.id;
|
|
23
|
+
const hit = stored.aa.length ? aaFor({ providerID: choice.providerID, id: choice.id, name, variant: choice.variant }, stored.aa) : null;
|
|
24
|
+
const index = stored.aa.length ? hit?.index ?? null : indexFor({ id: choice.id, name }, stored.table)?.index ?? null;
|
|
25
|
+
// shortcut: prices at the base size, with no chat counted; a model that charges more above some size is compared at its base price.
|
|
26
|
+
const own = listed?.cost ? pricesAt(listed.cost, 0) : null;
|
|
27
|
+
// Artificial Analysis's price only where OpenCode lists none, as the usage table borrows it; a $0 listing is OpenCode's own answer.
|
|
28
|
+
const prices = (!own || (own.inputPerMillion === null && own.outputPerMillion === null)) && hit ? hit.prices : own;
|
|
29
|
+
const row = stored.usage.find(item => item.model === modelName(choice));
|
|
30
|
+
const outPerRequest = row && row.messages >= OWN_REPLIES && row.requests > 0 ? (row.output + row.reasoning) / row.requests : null;
|
|
31
|
+
standings.set(modelName(choice), { index, coding: hit?.coding ?? null, inputPerMillion: prices?.inputPerMillion ?? null, outputPerMillion: prices?.outputPerMillion ?? null, outPerRequest });
|
|
32
|
+
}
|
|
33
|
+
return standings;
|
|
34
|
+
}
|
package/dist/tui.d.ts
ADDED
package/dist/tui.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RelayRpc } from './contract.js';
|
|
2
|
+
import { usageText } from './relay-view.js';
|
|
3
|
+
import { describeError } from './router.js';
|
|
4
|
+
// Relay's part in OpenCode's terminal app: `/relay-stats` shows, in a dialog, the totals Relay kept of its own messages before the usage tab
|
|
5
|
+
// (the tab's "Before this history"). The server part keeps the totals; this only asks for them. Only types come from `@opencode/plugin/tui`: its index loads the terminal's Solid runtime, which this does not need.
|
|
6
|
+
const TITLE = 'Relay: usage by model';
|
|
7
|
+
/** Asks Relay for the totals and shows them. It never throws: a failure becomes an error toast. */
|
|
8
|
+
async function showUsage(ctx) {
|
|
9
|
+
try {
|
|
10
|
+
const location = ctx.location ?? ctx.data.location.default();
|
|
11
|
+
const view = await ctx.client.rpc(RelayRpc).getRelayUsage({}, { location });
|
|
12
|
+
await ctx.ui.dialog.alert({ title: TITLE, message: usageText(view) });
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
ctx.ui.toast.show({ variant: 'error', title: 'Relay', message: `Relay could not read its usage: ${describeError(error, 'no answer')}` });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const tui = {
|
|
19
|
+
id: 'relay-opencode',
|
|
20
|
+
setup(ctx) {
|
|
21
|
+
ctx.keymap.layer(() => ({
|
|
22
|
+
commands: [{ id: 'relay-opencode.stats', title: TITLE, description: 'Every message Relay placed, by model and effort: requests, tokens and cost', group: 'Relay', palette: true, slash: { name: 'relay-stats' }, run: () => showUsage(ctx) }],
|
|
23
|
+
}));
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
export default tui;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { AaModel } from './artificial-analysis.js';
|
|
2
|
+
import type { ListedModel } from './inventory.js';
|
|
3
|
+
import { type Decision, type Mode, type PriceSource } from './relay-store.js';
|
|
4
|
+
import { shownCost } from './usage-view.js';
|
|
5
|
+
export { shownCost };
|
|
6
|
+
/** Plugin storage as the host gives it (`context.storage`). */
|
|
7
|
+
export type LogStore = {
|
|
8
|
+
get(key: string): Promise<unknown>;
|
|
9
|
+
set(key: string, value: unknown): Promise<void>;
|
|
10
|
+
remove(key: string): Promise<void>;
|
|
11
|
+
scan(options: {
|
|
12
|
+
prefix: string;
|
|
13
|
+
after?: string;
|
|
14
|
+
limit?: number;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
entries: readonly {
|
|
17
|
+
key: string;
|
|
18
|
+
value: unknown;
|
|
19
|
+
}[];
|
|
20
|
+
next?: string;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
23
|
+
export type UsageKind = 'chat' | 'helper' | 'summary';
|
|
24
|
+
/**
|
|
25
|
+
* One message and what its reply took. `at` is the message's own time. `kind` is `summary` for a finished compaction (its own request and the
|
|
26
|
+
* rest of the reply it cut), `helper` in a chat that has a parent chat, else `chat`. `relay` is the mode and note of the Relay record that
|
|
27
|
+
* names the message, when Relay placed it or decided to leave it alone.
|
|
28
|
+
*/
|
|
29
|
+
export type UsageRecord = {
|
|
30
|
+
at: string;
|
|
31
|
+
sessionID: string;
|
|
32
|
+
messageID: string;
|
|
33
|
+
project: string;
|
|
34
|
+
kind: UsageKind;
|
|
35
|
+
agent: string | null;
|
|
36
|
+
model: string | null;
|
|
37
|
+
requests: number;
|
|
38
|
+
input: number;
|
|
39
|
+
output: number;
|
|
40
|
+
reasoning: number;
|
|
41
|
+
cacheRead: number;
|
|
42
|
+
cacheWrite: number;
|
|
43
|
+
costByPrice: string | null;
|
|
44
|
+
openCodeUsd: string | null;
|
|
45
|
+
pricesFrom: PriceSource | null;
|
|
46
|
+
relay: {
|
|
47
|
+
mode: Mode | null;
|
|
48
|
+
note: string | null;
|
|
49
|
+
} | null;
|
|
50
|
+
};
|
|
51
|
+
export declare const LOG_PREFIX = "relay/usage-log/", KEEP_DAYS = 90;
|
|
52
|
+
/** The key sorts by the message's time, so a time range is one prefix scan. */
|
|
53
|
+
export declare const logKey: (record: Pick<UsageRecord, "at" | "sessionID" | "messageID">) => string;
|
|
54
|
+
/** The records of a chat's three newest messages that have counts. `decisions` are Relay's records of the same chat. */
|
|
55
|
+
export declare function buildRecords(messages: unknown, chat: {
|
|
56
|
+
sessionID: string;
|
|
57
|
+
project: string;
|
|
58
|
+
helper: boolean;
|
|
59
|
+
}, prices: {
|
|
60
|
+
models: readonly ListedModel[] | null;
|
|
61
|
+
borrowed: readonly AaModel[] | null;
|
|
62
|
+
}, decisions: readonly Decision[]): UsageRecord[];
|
|
63
|
+
/**
|
|
64
|
+
* What to write when `next` was read for a message that may have a record already; null when there is nothing new. A record grows when its
|
|
65
|
+
* reply made more requests (the host can wake a chat for the same message), when its prices turn up late, or when a Relay part does. It
|
|
66
|
+
* never loses a Relay part, a price or being a helper's, and never goes back to fewer requests: a growth read without the prices a record
|
|
67
|
+
* already has waits for a read that has them. So the last of two windows to write keeps the larger record.
|
|
68
|
+
*/
|
|
69
|
+
export declare function grown(old: UsageRecord | null, next: UsageRecord): UsageRecord | null;
|
|
70
|
+
/** Writes each record that is new or has grown. Once a record exists it is read first, so nothing kept is lost. */
|
|
71
|
+
export declare function saveRecords(store: Pick<LogStore, 'get' | 'set'>, records: readonly UsageRecord[]): Promise<void>;
|
|
72
|
+
/** Removes records older than 90 days, oldest first, `max` at most; returns how many went. */
|
|
73
|
+
export declare function pruneRecords(store: Pick<LogStore, 'scan' | 'remove'>, now: number, max?: number): Promise<number>;
|
|
74
|
+
/** The records from `from` to `to` (both ISO times, both included), oldest first; values that are not records are skipped. */
|
|
75
|
+
export declare function readRecords(store: Pick<LogStore, 'scan'>, from: string, to: string): Promise<UsageRecord[]>;
|
|
76
|
+
/** What the tab asks for: a time range (ISO), the panel's offset from UTC in minutes (local = UTC + offset), the filters, and a page of records. */
|
|
77
|
+
export type UsageQuery = {
|
|
78
|
+
from: string;
|
|
79
|
+
to: string;
|
|
80
|
+
tzOffsetMinutes: number;
|
|
81
|
+
search: string;
|
|
82
|
+
provider: string | null;
|
|
83
|
+
effort: string | null;
|
|
84
|
+
mode: string | null;
|
|
85
|
+
relay: 'any' | 'on' | 'off';
|
|
86
|
+
kind: 'any' | UsageKind;
|
|
87
|
+
project: string | null;
|
|
88
|
+
offset: number;
|
|
89
|
+
limit: number;
|
|
90
|
+
/** The panel's IANA time zone: days follow its clock changes. Without it, every day uses `tzOffsetMinutes`. */
|
|
91
|
+
timeZone: string | null;
|
|
92
|
+
};
|
|
93
|
+
/** One local day, with each model's cost (null when none of it has a price), tokens of every kind, and requests. */
|
|
94
|
+
export type UsageDay = {
|
|
95
|
+
day: string;
|
|
96
|
+
models: {
|
|
97
|
+
model: string;
|
|
98
|
+
cost: string | null;
|
|
99
|
+
tokens: number;
|
|
100
|
+
requests: number;
|
|
101
|
+
}[];
|
|
102
|
+
};
|
|
103
|
+
export type UsageTotal = {
|
|
104
|
+
model: string;
|
|
105
|
+
replies: number;
|
|
106
|
+
requests: number;
|
|
107
|
+
input: number;
|
|
108
|
+
output: number;
|
|
109
|
+
reasoning: number;
|
|
110
|
+
cacheRead: number;
|
|
111
|
+
cacheWrite: number;
|
|
112
|
+
cost: string | null;
|
|
113
|
+
aaPriced: boolean;
|
|
114
|
+
unpriced: number;
|
|
115
|
+
};
|
|
116
|
+
/** `first` is the oldest record given. `matching` counts every record the filters keep; `records` is one page of them, newest first. */
|
|
117
|
+
export type UsageSummary = {
|
|
118
|
+
days: UsageDay[];
|
|
119
|
+
totals: UsageTotal[];
|
|
120
|
+
options: {
|
|
121
|
+
providers: string[];
|
|
122
|
+
efforts: string[];
|
|
123
|
+
modes: string[];
|
|
124
|
+
projects: string[];
|
|
125
|
+
};
|
|
126
|
+
records: UsageRecord[];
|
|
127
|
+
matching: number;
|
|
128
|
+
first: string | null;
|
|
129
|
+
};
|
|
130
|
+
/** The days, totals, filter lists and one page of records for a range. The filter lists come from every record given, so a filter never hides its own choices. */
|
|
131
|
+
export declare function summarize(records: readonly UsageRecord[], query: UsageQuery): UsageSummary;
|
|
132
|
+
/** The time of the oldest record kept, for the tab's "since"; null with none. */
|
|
133
|
+
export declare function oldestRecord(store: Pick<LogStore, 'scan'>): Promise<string | null>;
|
|
134
|
+
/** The tab's question, checked and with its times in the keys' own form. A question that is not one gets a plain sentence. */
|
|
135
|
+
export declare function usageQueryOf(input: unknown): UsageQuery;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { agentOf, newestAnchors, replyOf } from './chat-facts.js';
|
|
2
|
+
import { costOf, formatUsd, parseUsd, storedUsd } from './costs.js';
|
|
3
|
+
import { modes } from './relay-store.js';
|
|
4
|
+
import { shownCost } from './usage-view.js';
|
|
5
|
+
export { shownCost };
|
|
6
|
+
const kinds = ['chat', 'helper', 'summary'];
|
|
7
|
+
const sources = ['opencode', 'artificial-analysis'];
|
|
8
|
+
export const LOG_PREFIX = 'relay/usage-log/', KEEP_DAYS = 90;
|
|
9
|
+
const DAY_MS = 86_400_000, NEWEST = 3, PAGE = 200;
|
|
10
|
+
/** The key sorts by the message's time, so a time range is one prefix scan. */
|
|
11
|
+
export const logKey = (record) => `${LOG_PREFIX}${record.at}/${record.sessionID}/${record.messageID}`;
|
|
12
|
+
const timeOfKey = (key) => key.slice(LOG_PREFIX.length).split('/', 1)[0] ?? '';
|
|
13
|
+
/** Tokens times each kind's price (output with its reasoning), as Usage by model works them out; null when no kind has a price. */
|
|
14
|
+
function priceTotal(total, prices) {
|
|
15
|
+
const parts = [costOf(total.input, prices?.inputPerMillion ?? null), costOf(total.output + total.reasoning, prices?.outputPerMillion ?? null),
|
|
16
|
+
costOf(total.cacheRead, prices?.cacheReadPerMillion ?? null), costOf(total.cacheWrite, prices?.cacheWritePerMillion ?? null)].filter((part) => part !== null);
|
|
17
|
+
return parts.length ? formatUsd(parts.reduce((sum, part) => sum + part, 0n)) : null;
|
|
18
|
+
}
|
|
19
|
+
/** The records of a chat's three newest messages that have counts. `decisions` are Relay's records of the same chat. */
|
|
20
|
+
export function buildRecords(messages, chat, prices, decisions) {
|
|
21
|
+
return newestAnchors(messages, NEWEST).flatMap(anchor => {
|
|
22
|
+
const reply = replyOf(messages, anchor.id, prices.models, prices.borrowed), total = reply?.total;
|
|
23
|
+
if (!reply || !total)
|
|
24
|
+
return [];
|
|
25
|
+
const placed = decisions.find(item => item.messageID === anchor.id);
|
|
26
|
+
return [{
|
|
27
|
+
at: new Date(anchor.created).toISOString(), sessionID: chat.sessionID, messageID: anchor.id, project: chat.project, kind: anchor.summary ? 'summary' : chat.helper ? 'helper' : 'chat',
|
|
28
|
+
agent: agentOf(messages, anchor.id), model: reply.model, requests: reply.requests, input: total.input, output: total.output, reasoning: total.reasoning,
|
|
29
|
+
cacheRead: total.cacheRead, cacheWrite: total.cacheWrite, costByPrice: priceTotal(total, reply.prices), openCodeUsd: total.costUsd, pricesFrom: reply.pricesFrom,
|
|
30
|
+
relay: placed ? { mode: placed.mode, note: placed.note } : null,
|
|
31
|
+
}];
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* What to write when `next` was read for a message that may have a record already; null when there is nothing new. A record grows when its
|
|
36
|
+
* reply made more requests (the host can wake a chat for the same message), when its prices turn up late, or when a Relay part does. It
|
|
37
|
+
* never loses a Relay part, a price or being a helper's, and never goes back to fewer requests: a growth read without the prices a record
|
|
38
|
+
* already has waits for a read that has them. So the last of two windows to write keeps the larger record.
|
|
39
|
+
*/
|
|
40
|
+
export function grown(old, next) {
|
|
41
|
+
if (!old)
|
|
42
|
+
return next;
|
|
43
|
+
// A later read can lack what an earlier one had: the chat's parent when session.get was late, the prices when the model list was.
|
|
44
|
+
const kept = { kind: old.kind === 'helper' ? 'helper' : next.kind, relay: old.relay ?? next.relay };
|
|
45
|
+
if (next.requests > old.requests)
|
|
46
|
+
return next.costByPrice === null && old.costByPrice !== null ? null : { ...next, ...kept };
|
|
47
|
+
if (next.requests === old.requests && old.costByPrice === null && next.costByPrice !== null)
|
|
48
|
+
return { ...next, ...kept };
|
|
49
|
+
return !old.relay && next.relay ? { ...old, relay: next.relay } : null;
|
|
50
|
+
}
|
|
51
|
+
const text = (value) => typeof value === 'string' ? value : null;
|
|
52
|
+
const amount = (value) => typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : null;
|
|
53
|
+
/** A stored record, or null when the value is not one (another build's, or damaged). */
|
|
54
|
+
const LAST_TIME = 8.64e15 - 2 * DAY_MS;
|
|
55
|
+
function readable(value) {
|
|
56
|
+
const item = value;
|
|
57
|
+
if (!item || typeof item !== 'object')
|
|
58
|
+
return null;
|
|
59
|
+
const at = text(item.at), sessionID = text(item.sessionID), messageID = text(item.messageID), project = text(item.project);
|
|
60
|
+
const counts = [item.requests, item.input, item.output, item.reasoning, item.cacheRead, item.cacheWrite].map(amount);
|
|
61
|
+
// A date near the end of JavaScript's time range would make every day count of its range throw.
|
|
62
|
+
if (!at || !(Math.abs(Date.parse(at)) < LAST_TIME) || !sessionID || !messageID || project === null || !kinds.includes(item.kind) || counts.some(count => count === null))
|
|
63
|
+
return null;
|
|
64
|
+
const relay = item.relay;
|
|
65
|
+
const [requests, input, output, reasoning, cacheRead, cacheWrite] = counts;
|
|
66
|
+
return {
|
|
67
|
+
at, sessionID, messageID, project, kind: item.kind, agent: text(item.agent), model: text(item.model), requests, input, output, reasoning, cacheRead, cacheWrite,
|
|
68
|
+
costByPrice: storedUsd(item.costByPrice), openCodeUsd: storedUsd(item.openCodeUsd), pricesFrom: sources.includes(item.pricesFrom) ? item.pricesFrom : null,
|
|
69
|
+
relay: relay && typeof relay === 'object' ? { mode: modes.includes(relay.mode) ? relay.mode : null, note: text(relay.note) } : null,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** Writes each record that is new or has grown. Once a record exists it is read first, so nothing kept is lost. */
|
|
73
|
+
export async function saveRecords(store, records) {
|
|
74
|
+
for (const record of records) {
|
|
75
|
+
const key = logKey(record), write = grown(readable(await store.get(key)), record);
|
|
76
|
+
if (write)
|
|
77
|
+
await store.set(key, write);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** Removes records older than 90 days, oldest first, `max` at most; returns how many went. */
|
|
81
|
+
export async function pruneRecords(store, now, max = 1000) {
|
|
82
|
+
const before = new Date(now - KEEP_DAYS * DAY_MS).toISOString();
|
|
83
|
+
// Most calls have nothing to remove: one look at the oldest key settles it.
|
|
84
|
+
const oldest = (await store.scan({ prefix: LOG_PREFIX, limit: 1 })).entries[0];
|
|
85
|
+
if (!oldest || timeOfKey(oldest.key) >= before)
|
|
86
|
+
return 0;
|
|
87
|
+
let removed = 0, after;
|
|
88
|
+
while (removed < max) {
|
|
89
|
+
const page = await store.scan({ prefix: LOG_PREFIX, after, limit: Math.min(PAGE, max - removed) });
|
|
90
|
+
for (const { key } of page.entries) {
|
|
91
|
+
if (timeOfKey(key) >= before)
|
|
92
|
+
return removed;
|
|
93
|
+
await store.remove(key);
|
|
94
|
+
removed++;
|
|
95
|
+
}
|
|
96
|
+
if (!page.next || !page.entries.length || page.next === after)
|
|
97
|
+
return removed;
|
|
98
|
+
after = page.next;
|
|
99
|
+
}
|
|
100
|
+
return removed;
|
|
101
|
+
}
|
|
102
|
+
// shortcut: every call scans the range; fine to about 30,000 records, past that keep daily summaries beside them.
|
|
103
|
+
/** The records from `from` to `to` (both ISO times, both included), oldest first; values that are not records are skipped. */
|
|
104
|
+
export async function readRecords(store, from, to) {
|
|
105
|
+
const found = [];
|
|
106
|
+
let after = `${LOG_PREFIX}${from}`;
|
|
107
|
+
for (;;) {
|
|
108
|
+
const page = await store.scan({ prefix: LOG_PREFIX, after, limit: PAGE });
|
|
109
|
+
for (const { key, value } of page.entries) {
|
|
110
|
+
// The lower bound is checked here too, so the range never rests on how the host reads `after`.
|
|
111
|
+
if (timeOfKey(key) < from)
|
|
112
|
+
continue;
|
|
113
|
+
if (timeOfKey(key) > to)
|
|
114
|
+
return found;
|
|
115
|
+
const record = readable(value);
|
|
116
|
+
if (record)
|
|
117
|
+
found.push(record);
|
|
118
|
+
}
|
|
119
|
+
if (!page.next || !page.entries.length || page.next === after)
|
|
120
|
+
return found;
|
|
121
|
+
after = page.next;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const nameOf = (record) => record.model ?? 'unknown model';
|
|
125
|
+
const providerOf = (record) => record.model?.split('/', 1)[0] ?? 'unknown';
|
|
126
|
+
const effortOf = (record) => { const hash = record.model?.lastIndexOf('#') ?? -1; return hash < 0 ? 'default' : record.model.slice(hash + 1); };
|
|
127
|
+
const modeOf = (record) => record.relay?.mode ?? record.agent ?? 'unknown';
|
|
128
|
+
const tokensOf = (record) => record.input + record.output + record.reasoning + record.cacheRead + record.cacheWrite;
|
|
129
|
+
const sum = (costs) => { const known = costs.filter((cost) => cost !== null); return known.length ? formatUsd(known.reduce((total, cost) => total + parseUsd(cost), 0n)) : null; };
|
|
130
|
+
const sorted = (values) => [...new Set(values)].sort();
|
|
131
|
+
/** The days, totals, filter lists and one page of records for a range. The filter lists come from every record given, so a filter never hides its own choices. */
|
|
132
|
+
export function summarize(records, query) {
|
|
133
|
+
const zoned = query.timeZone ? new Intl.DateTimeFormat('en-CA', { timeZone: query.timeZone, year: 'numeric', month: '2-digit', day: '2-digit' }) : null;
|
|
134
|
+
const dayOf = (time) => { const ms = typeof time === 'number' ? time : Date.parse(time); return zoned ? zoned.format(ms) : new Date(ms + query.tzOffsetMinutes * 60_000).toISOString().slice(0, 10); };
|
|
135
|
+
const search = query.search.trim().toLowerCase();
|
|
136
|
+
const kept = records.filter(record => (!search || nameOf(record).toLowerCase().includes(search))
|
|
137
|
+
&& (query.provider === null || providerOf(record) === query.provider) && (query.effort === null || effortOf(record) === query.effort)
|
|
138
|
+
&& (query.mode === null || modeOf(record) === query.mode) && (query.relay === 'any' || (query.relay === 'on') === (record.relay !== null))
|
|
139
|
+
&& (query.kind === 'any' || record.kind === query.kind) && (query.project === null || record.project === query.project));
|
|
140
|
+
// Every day of the range, empty ones too, in the panel's own days.
|
|
141
|
+
const days = [], last = dayOf(query.to);
|
|
142
|
+
for (let day = dayOf(query.from); day <= last && days.length < KEEP_DAYS + 3; day = new Date(Date.parse(`${day}T00:00:00Z`) + DAY_MS).toISOString().slice(0, 10))
|
|
143
|
+
days.push({ day, models: [] });
|
|
144
|
+
const byDay = new Map(days.map(day => [day.day, new Map()]));
|
|
145
|
+
const byModel = new Map();
|
|
146
|
+
for (const record of kept) {
|
|
147
|
+
const models = byDay.get(dayOf(record.at));
|
|
148
|
+
if (models)
|
|
149
|
+
models.set(nameOf(record), [...models.get(nameOf(record)) ?? [], record]);
|
|
150
|
+
byModel.set(nameOf(record), [...byModel.get(nameOf(record)) ?? [], record]);
|
|
151
|
+
}
|
|
152
|
+
for (const day of days)
|
|
153
|
+
day.models = [...byDay.get(day.day)].map(([model, mine]) => ({ model, cost: sum(mine.map(shownCost)), tokens: mine.reduce((total, record) => total + tokensOf(record), 0), requests: mine.reduce((total, record) => total + record.requests, 0) }));
|
|
154
|
+
const add = (mine, pick) => mine.reduce((total, record) => total + pick(record), 0);
|
|
155
|
+
const totals = [...byModel].map(([model, mine]) => ({
|
|
156
|
+
model, replies: mine.length, requests: add(mine, record => record.requests), input: add(mine, record => record.input), output: add(mine, record => record.output),
|
|
157
|
+
reasoning: add(mine, record => record.reasoning), cacheRead: add(mine, record => record.cacheRead), cacheWrite: add(mine, record => record.cacheWrite), cost: sum(mine.map(shownCost)),
|
|
158
|
+
aaPriced: mine.some(record => record.costByPrice !== null && record.pricesFrom === 'artificial-analysis'), unpriced: mine.filter(record => shownCost(record) === null).length,
|
|
159
|
+
}));
|
|
160
|
+
const costKey = (total) => total.cost === null ? -1n : parseUsd(total.cost), tokens = (total) => total.input + total.output + total.reasoning + total.cacheRead + total.cacheWrite;
|
|
161
|
+
totals.sort((a, b) => costKey(b) > costKey(a) ? 1 : costKey(b) < costKey(a) ? -1 : tokens(b) - tokens(a));
|
|
162
|
+
const newest = [...kept].sort((a, b) => a.at < b.at ? 1 : a.at > b.at ? -1 : 0);
|
|
163
|
+
return {
|
|
164
|
+
days, totals, records: newest.slice(query.offset, query.offset + query.limit), matching: kept.length, first: records.reduce((oldest, record) => oldest === null || record.at < oldest ? record.at : oldest, null),
|
|
165
|
+
options: { providers: sorted(records.map(providerOf)), efforts: sorted(records.map(effortOf)), modes: sorted(records.map(modeOf)), projects: sorted(records.map(record => record.project)) },
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/** The time of the oldest record kept, for the tab's "since"; null with none. */
|
|
169
|
+
export async function oldestRecord(store) {
|
|
170
|
+
const key = (await store.scan({ prefix: LOG_PREFIX, limit: 1 })).entries[0]?.key;
|
|
171
|
+
return key ? timeOfKey(key) : null;
|
|
172
|
+
}
|
|
173
|
+
const RANGE_DAYS = 92, LIMIT = 200;
|
|
174
|
+
/** The tab's question, checked and with its times in the keys' own form. A question that is not one gets a plain sentence. */
|
|
175
|
+
export function usageQueryOf(input) {
|
|
176
|
+
const item = (input ?? {});
|
|
177
|
+
const time = (value, name) => { const ms = typeof value === 'string' ? Date.parse(value) : NaN; if (Number.isNaN(ms))
|
|
178
|
+
throw new Error(`The ${name} time is not a time.`); return ms; };
|
|
179
|
+
const from = time(item.from, 'start'), to = time(item.to, 'end');
|
|
180
|
+
if (from > to)
|
|
181
|
+
throw new Error('The range starts after it ends.');
|
|
182
|
+
if (to - from > RANGE_DAYS * DAY_MS)
|
|
183
|
+
throw new Error(`A range is at most ${RANGE_DAYS} days.`);
|
|
184
|
+
const whole = (value, low, high, name) => { if (typeof value !== 'number' || !Number.isInteger(value) || value < low || value > high)
|
|
185
|
+
throw new Error(`${name} must be a whole number from ${low} to ${high}.`); return value; };
|
|
186
|
+
const choice = (value, name) => { if (value !== null && (typeof value !== 'string' || value.length > 500))
|
|
187
|
+
throw new Error(`The ${name} filter is not one.`); return value; };
|
|
188
|
+
if (typeof item.search !== 'string' || item.search.length > 200)
|
|
189
|
+
throw new Error('The search is at most 200 characters.');
|
|
190
|
+
if (item.relay !== 'any' && item.relay !== 'on' && item.relay !== 'off')
|
|
191
|
+
throw new Error('The Relay filter is any, on or off.');
|
|
192
|
+
if (item.kind !== 'any' && !kinds.includes(item.kind))
|
|
193
|
+
throw new Error('The kind filter is any, chat, helper or summary.');
|
|
194
|
+
const timeZone = item.timeZone === undefined || item.timeZone === null ? null : item.timeZone;
|
|
195
|
+
if (timeZone !== null) {
|
|
196
|
+
try {
|
|
197
|
+
if (typeof timeZone !== 'string' || timeZone.length > 64)
|
|
198
|
+
throw new Error();
|
|
199
|
+
new Intl.DateTimeFormat('en-CA', { timeZone });
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
throw new Error('The time zone is not one.');
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
from: new Date(from).toISOString(), to: new Date(to).toISOString(), tzOffsetMinutes: whole(item.tzOffsetMinutes, -840, 840, 'The time zone offset'), search: item.search,
|
|
207
|
+
provider: choice(item.provider, 'provider'), effort: choice(item.effort, 'effort'), mode: choice(item.mode, 'mode'), relay: item.relay, kind: item.kind,
|
|
208
|
+
project: choice(item.project, 'project'), offset: whole(item.offset, 0, 1_000_000, 'The offset'), limit: whole(item.limit, 1, LIMIT, 'The page size'), timeZone: timeZone,
|
|
209
|
+
};
|
|
210
|
+
}
|