agent-usage-all-in-one 0.8.0 → 0.8.1
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/dist/cli.js +60 -55
- package/dist/cli.js.map +1 -1
- package/dist/web/_app/immutable/assets/2.CebKccN1.css +1 -0
- package/dist/web/_app/immutable/chunks/YxRJCZwS.js +1 -0
- package/dist/web/_app/immutable/entry/{app.Z7FhDi1v.js → app.BJQZZwy-.js} +2 -2
- package/dist/web/_app/immutable/entry/start.DGorbLTC.js +1 -0
- package/dist/web/_app/immutable/nodes/{1.oDSuYnui.js → 1.C0DvG6AA.js} +1 -1
- package/dist/web/_app/immutable/nodes/2.L5Bpe4_s.js +26 -0
- package/dist/web/_app/version.json +1 -1
- package/dist/web/brand/agent-usage-showcase.jpg +0 -0
- package/dist/web/index.html +6 -6
- package/package.json +1 -1
- package/static/brand/agent-usage-showcase.jpg +0 -0
- package/dist/web/_app/immutable/assets/2.B3WVopjI.css +0 -1
- package/dist/web/_app/immutable/chunks/CiAz1kOc.js +0 -1
- package/dist/web/_app/immutable/entry/start.DEVa4z2m.js +0 -1
- package/dist/web/_app/immutable/nodes/2.8Hl62Zo_.js +0 -26
package/dist/cli.js
CHANGED
|
@@ -1490,6 +1490,11 @@ function createProcessingStatus(startedAt, hardRebuild) {
|
|
|
1490
1490
|
function yieldToEventLoop() {
|
|
1491
1491
|
return new Promise((resolve5) => setImmediate(resolve5));
|
|
1492
1492
|
}
|
|
1493
|
+
function yieldForPendingHttp() {
|
|
1494
|
+
return new Promise((resolve5) => {
|
|
1495
|
+
setTimeout(resolve5, PENDING_HTTP_YIELD_MS);
|
|
1496
|
+
});
|
|
1497
|
+
}
|
|
1493
1498
|
function providerForConnector(id, definitions) {
|
|
1494
1499
|
return definitions.find((definition) => definition.id === id)?.target.provider.id ?? id;
|
|
1495
1500
|
}
|
|
@@ -1562,7 +1567,7 @@ function pickAgentProviderIndex(overview) {
|
|
|
1562
1567
|
providers: overview.providers.filter((provider) => provider.id !== "opencode" && provider.id !== "dsh").map(({ id, displayName }) => ({ id, displayName }))
|
|
1563
1568
|
};
|
|
1564
1569
|
}
|
|
1565
|
-
var UsageApplication;
|
|
1570
|
+
var UsageApplication, PENDING_HTTP_YIELD_MS;
|
|
1566
1571
|
var init_usage_application = __esm({
|
|
1567
1572
|
"src/core/usage-application.ts"() {
|
|
1568
1573
|
"use strict";
|
|
@@ -1762,15 +1767,15 @@ var init_usage_application = __esm({
|
|
|
1762
1767
|
const runtimeStates = new Map(
|
|
1763
1768
|
this.#repository.getConnectorRuntimeStates().map((state) => [state.id, state])
|
|
1764
1769
|
);
|
|
1765
|
-
await Promise.all(
|
|
1770
|
+
const collected = await Promise.all(
|
|
1766
1771
|
this.#connectors.map(async (connector) => {
|
|
1767
1772
|
if (connector.consentId && connectorStates.get(connector.consentId) !== "connected") {
|
|
1768
|
-
return;
|
|
1773
|
+
return null;
|
|
1769
1774
|
}
|
|
1770
1775
|
const now = this.#clock();
|
|
1771
1776
|
const runtime = runtimeStates.get(connector.id);
|
|
1772
1777
|
if (!options.userInitiated && runtime?.nextAllowedAt && new Date(runtime.nextAllowedAt).getTime() > now.getTime()) {
|
|
1773
|
-
return;
|
|
1778
|
+
return null;
|
|
1774
1779
|
}
|
|
1775
1780
|
const policy = this.#connectorPolicies[connector.id] ?? {
|
|
1776
1781
|
minimumIntervalMs: 0,
|
|
@@ -1782,54 +1787,27 @@ var init_usage_application = __esm({
|
|
|
1782
1787
|
policy.timeoutMs,
|
|
1783
1788
|
`${connector.id} timed out`
|
|
1784
1789
|
);
|
|
1785
|
-
|
|
1786
|
-
if (snapshot2.warnings && snapshot2.warnings.length > 0) {
|
|
1787
|
-
const failure = redactFailure(combineFailures(snapshot2.warnings));
|
|
1788
|
-
this.#repository.recordFailure(snapshot2.provider, this.#clock().toISOString(), failure);
|
|
1789
|
-
this.#saveConnectorDiagnostic(
|
|
1790
|
-
connector,
|
|
1791
|
-
snapshot2.provider.id,
|
|
1792
|
-
snapshot2.billingDomains[0]?.id ?? defaultBillingDomain(connector.id, this.#connectorDefinitions),
|
|
1793
|
-
failure
|
|
1794
|
-
);
|
|
1795
|
-
this.#recordConnectorOutcome(
|
|
1796
|
-
connector.id,
|
|
1797
|
-
now,
|
|
1798
|
-
policy,
|
|
1799
|
-
false,
|
|
1800
|
-
runtime?.failureCount ?? 0
|
|
1801
|
-
);
|
|
1802
|
-
} else {
|
|
1803
|
-
this.#saveHealthyConnectorDiagnostic(
|
|
1804
|
-
connector,
|
|
1805
|
-
snapshot2.provider.id,
|
|
1806
|
-
snapshot2.billingDomains[0]?.id ?? defaultBillingDomain(connector.id, this.#connectorDefinitions),
|
|
1807
|
-
snapshot2.observedAt
|
|
1808
|
-
);
|
|
1809
|
-
this.#recordConnectorOutcome(
|
|
1810
|
-
connector.id,
|
|
1811
|
-
now,
|
|
1812
|
-
policy,
|
|
1813
|
-
true,
|
|
1814
|
-
runtime?.failureCount ?? 0
|
|
1815
|
-
);
|
|
1816
|
-
}
|
|
1790
|
+
return { ok: true, connector, now, runtime, policy, snapshot: snapshot2 };
|
|
1817
1791
|
} catch (error) {
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1792
|
+
return { ok: false, connector, now, runtime, policy, error };
|
|
1793
|
+
}
|
|
1794
|
+
})
|
|
1795
|
+
);
|
|
1796
|
+
if (collected.some((result) => result !== null)) await yieldForPendingHttp();
|
|
1797
|
+
for (const result of collected) {
|
|
1798
|
+
if (!result) continue;
|
|
1799
|
+
const { connector, now, runtime, policy } = result;
|
|
1800
|
+
if (result.ok) {
|
|
1801
|
+
const snapshot2 = result.snapshot;
|
|
1802
|
+
await this.#repository.saveSnapshot(this.#withRetailCosts(snapshot2));
|
|
1803
|
+
if (snapshot2.warnings && snapshot2.warnings.length > 0) {
|
|
1804
|
+
const failure2 = redactFailure(combineFailures(snapshot2.warnings));
|
|
1805
|
+
this.#repository.recordFailure(snapshot2.provider, this.#clock().toISOString(), failure2);
|
|
1828
1806
|
this.#saveConnectorDiagnostic(
|
|
1829
1807
|
connector,
|
|
1830
|
-
|
|
1831
|
-
defaultBillingDomain(connector.id, this.#connectorDefinitions),
|
|
1832
|
-
|
|
1808
|
+
snapshot2.provider.id,
|
|
1809
|
+
snapshot2.billingDomains[0]?.id ?? defaultBillingDomain(connector.id, this.#connectorDefinitions),
|
|
1810
|
+
failure2
|
|
1833
1811
|
);
|
|
1834
1812
|
this.#recordConnectorOutcome(
|
|
1835
1813
|
connector.id,
|
|
@@ -1838,9 +1816,35 @@ var init_usage_application = __esm({
|
|
|
1838
1816
|
false,
|
|
1839
1817
|
runtime?.failureCount ?? 0
|
|
1840
1818
|
);
|
|
1819
|
+
} else {
|
|
1820
|
+
this.#saveHealthyConnectorDiagnostic(
|
|
1821
|
+
connector,
|
|
1822
|
+
snapshot2.provider.id,
|
|
1823
|
+
snapshot2.billingDomains[0]?.id ?? defaultBillingDomain(connector.id, this.#connectorDefinitions),
|
|
1824
|
+
snapshot2.observedAt
|
|
1825
|
+
);
|
|
1826
|
+
this.#recordConnectorOutcome(connector.id, now, policy, true, runtime?.failureCount ?? 0);
|
|
1841
1827
|
}
|
|
1842
|
-
|
|
1843
|
-
|
|
1828
|
+
continue;
|
|
1829
|
+
}
|
|
1830
|
+
const providerId = providerForConnector(connector.id, this.#connectorDefinitions);
|
|
1831
|
+
const failure = redactFailure(safeConnectorFailure(result.error));
|
|
1832
|
+
this.#repository.recordFailure(
|
|
1833
|
+
{
|
|
1834
|
+
id: providerId,
|
|
1835
|
+
displayName: displayNameForProvider(providerId, connector.displayName)
|
|
1836
|
+
},
|
|
1837
|
+
this.#clock().toISOString(),
|
|
1838
|
+
failure
|
|
1839
|
+
);
|
|
1840
|
+
this.#saveConnectorDiagnostic(
|
|
1841
|
+
connector,
|
|
1842
|
+
providerId,
|
|
1843
|
+
defaultBillingDomain(connector.id, this.#connectorDefinitions),
|
|
1844
|
+
failure
|
|
1845
|
+
);
|
|
1846
|
+
this.#recordConnectorOutcome(connector.id, now, policy, false, runtime?.failureCount ?? 0);
|
|
1847
|
+
}
|
|
1844
1848
|
if (this.#repository.getMonitoringSettings().notificationsEnabled) {
|
|
1845
1849
|
await this.#sendNotificationTransitions();
|
|
1846
1850
|
}
|
|
@@ -2179,9 +2183,9 @@ var init_usage_application = __esm({
|
|
|
2179
2183
|
if (snapshot2.usage.length === 0 && snapshot2.costs.length === 0) {
|
|
2180
2184
|
throw new Error("Telemetry payload contained no supported metrics");
|
|
2181
2185
|
}
|
|
2182
|
-
await this.#queueDatabaseWrite(
|
|
2183
|
-
this.#repository.saveSnapshot(this.#withRetailCosts(snapshot2), { preserveFailure: true })
|
|
2184
|
-
|
|
2186
|
+
await this.#queueDatabaseWrite(
|
|
2187
|
+
() => this.#repository.saveSnapshot(this.#withRetailCosts(snapshot2), { preserveFailure: true })
|
|
2188
|
+
);
|
|
2185
2189
|
}
|
|
2186
2190
|
#queueDatabaseWrite(action) {
|
|
2187
2191
|
const result = this.#databaseWriteQueue.then(action, action);
|
|
@@ -2296,6 +2300,7 @@ var init_usage_application = __esm({
|
|
|
2296
2300
|
return status;
|
|
2297
2301
|
}
|
|
2298
2302
|
};
|
|
2303
|
+
PENDING_HTTP_YIELD_MS = 20;
|
|
2299
2304
|
}
|
|
2300
2305
|
});
|
|
2301
2306
|
|
|
@@ -8879,7 +8884,7 @@ var init_sqlite_usage_repository = __esm({
|
|
|
8879
8884
|
this.#database.exec("PRAGMA journal_mode = WAL; PRAGMA foreign_keys = ON;");
|
|
8880
8885
|
this.#migrate();
|
|
8881
8886
|
}
|
|
8882
|
-
saveSnapshot(snapshot2, options = {}) {
|
|
8887
|
+
async saveSnapshot(snapshot2, options = {}) {
|
|
8883
8888
|
this.#database.exec("BEGIN IMMEDIATE");
|
|
8884
8889
|
try {
|
|
8885
8890
|
const providerSql = options.preserveFailure ? `INSERT INTO providers (
|