@agent-native/core 0.198.2 → 0.198.3-nightly-20260930154911
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/catalog.json +1 -1
- package/dist/cli/create-tui.js +31 -9
- package/dist/cli/design-connect.js +10 -2
- package/dist/client/chat/agentkit-protocol.js +4 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/deploy/workspace-deploy.js +18 -5
- package/dist/file-upload/actions/upload-image.d.ts +2 -2
- package/dist/framework-tools.js +2 -0
- package/dist/localization/core-messages/supplemental/ar-SA.js +2 -0
- package/dist/localization/core-messages/supplemental/de-DE.js +2 -0
- package/dist/localization/core-messages/supplemental/en-US.js +2 -0
- package/dist/localization/core-messages/supplemental/es-ES.js +2 -0
- package/dist/localization/core-messages/supplemental/fr-FR.js +2 -0
- package/dist/localization/core-messages/supplemental/hi-IN.js +2 -0
- package/dist/localization/core-messages/supplemental/ja-JP.js +2 -0
- package/dist/localization/core-messages/supplemental/ko-KR.js +2 -0
- package/dist/localization/core-messages/supplemental/pt-BR.js +2 -0
- package/dist/localization/core-messages/supplemental/zh-CN.js +2 -0
- package/dist/localization/core-messages/supplemental/zh-TW.js +2 -0
- package/dist/localization/mcp-settings-messages.d.ts +2 -0
- package/dist/mcp/connect-route.js +57 -10
- package/dist/mcp/oauth-route.js +4 -21
- package/dist/mcp/org-choice.d.ts +26 -0
- package/dist/mcp/org-choice.js +36 -0
- package/dist/notifications/routes.d.ts +1 -1
- package/dist/org/handlers.d.ts +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +3 -3
- package/dist/provider-api/actions/provider-api.d.ts +7 -7
- package/dist/server/action-discovery.js +5 -0
- package/dist/server/agent-engine-default-model-route.d.ts +2 -2
- package/dist/server/agent-engine-ollama-models-route.d.ts +2 -2
- package/dist/server/core-routes-plugin.d.ts +1 -1
- package/dist/server/credential-provider.js +5 -0
- package/dist/server/realtime-token.d.ts +1 -1
- package/dist/usage/actions/get-usage-insights.d.ts +7 -0
- package/dist/usage/actions/get-usage-insights.js +23 -0
- package/dist/usage/actions/get-usage-run.d.ts +7 -0
- package/dist/usage/actions/get-usage-run.js +23 -0
- package/dist/usage/insights-store.d.ts +127 -0
- package/dist/usage/insights-store.js +462 -0
- package/dist/usage/metrics-store.d.ts +21 -0
- package/dist/usage/metrics-store.js +67 -3
- package/dist/vite/action-types-plugin.js +8 -0
- package/package.json +6 -4
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { H3Event } from "h3";
|
|
2
|
+
export interface McpOrgOption {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
domain: string | null;
|
|
6
|
+
}
|
|
7
|
+
export interface McpOrgChoices {
|
|
8
|
+
organizations: McpOrgOption[];
|
|
9
|
+
defaultOrganizationId: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The organizations an MCP connection (OAuth consent or device approval) can
|
|
13
|
+
* be bound to, and the one to preselect. For an account with no memberships,
|
|
14
|
+
* this resolves (and may create) its domain or default org the same way any
|
|
15
|
+
* other page load would, so the connection isn't scoped to no org for its
|
|
16
|
+
* whole life.
|
|
17
|
+
*
|
|
18
|
+
* `requestedOrganizationId`: `undefined` means no explicit pick (use the
|
|
19
|
+
* caller's stored/session org), `null` means the OAuth caller explicitly
|
|
20
|
+
* asked for personal scope, and a string is an explicit org pick to resolve
|
|
21
|
+
* membership for.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveMcpOrgChoices(event: H3Event, session: {
|
|
24
|
+
email: string;
|
|
25
|
+
orgId?: string | null;
|
|
26
|
+
}, requestedOrganizationId?: string | null): Promise<McpOrgChoices>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { getActiveOrgSettingForEvent, getOrgContext, listOrgMembershipsForEvent, } from "../org/context.js";
|
|
2
|
+
/**
|
|
3
|
+
* The organizations an MCP connection (OAuth consent or device approval) can
|
|
4
|
+
* be bound to, and the one to preselect. For an account with no memberships,
|
|
5
|
+
* this resolves (and may create) its domain or default org the same way any
|
|
6
|
+
* other page load would, so the connection isn't scoped to no org for its
|
|
7
|
+
* whole life.
|
|
8
|
+
*
|
|
9
|
+
* `requestedOrganizationId`: `undefined` means no explicit pick (use the
|
|
10
|
+
* caller's stored/session org), `null` means the OAuth caller explicitly
|
|
11
|
+
* asked for personal scope, and a string is an explicit org pick to resolve
|
|
12
|
+
* membership for.
|
|
13
|
+
*/
|
|
14
|
+
export async function resolveMcpOrgChoices(event, session, requestedOrganizationId) {
|
|
15
|
+
const activeOrgSetting = await getActiveOrgSettingForEvent(event, session.email);
|
|
16
|
+
let memberships = await listOrgMembershipsForEvent(event, session.email, requestedOrganizationId !== undefined
|
|
17
|
+
? requestedOrganizationId
|
|
18
|
+
: (activeOrgSetting?.orgId ?? session.orgId ?? null));
|
|
19
|
+
// A token issued with no org stays org-less for its whole life, even after
|
|
20
|
+
// the app later creates the org, so resolve an account without one to its
|
|
21
|
+
// domain or default org before offering the choice.
|
|
22
|
+
const ensuredOrgId = memberships?.length === 0 ? (await getOrgContext(event)).orgId : null;
|
|
23
|
+
if (ensuredOrgId) {
|
|
24
|
+
memberships = await listOrgMembershipsForEvent(event, session.email, ensuredOrgId);
|
|
25
|
+
}
|
|
26
|
+
const organizations = memberships?.map((membership) => ({
|
|
27
|
+
id: membership.orgId,
|
|
28
|
+
name: membership.orgName,
|
|
29
|
+
domain: membership.allowedDomain,
|
|
30
|
+
})) ??
|
|
31
|
+
(session.orgId
|
|
32
|
+
? [{ id: session.orgId, name: "Organization", domain: null }]
|
|
33
|
+
: []);
|
|
34
|
+
const defaultOrganizationId = [activeOrgSetting?.orgId, ensuredOrgId, session.orgId].find((id) => id && organizations.some((org) => org.id === id)) ?? organizations[0]?.id;
|
|
35
|
+
return { organizations, defaultOrganizationId };
|
|
36
|
+
}
|
package/dist/org/handlers.d.ts
CHANGED
|
@@ -73,8 +73,8 @@ export declare const setWorkspaceAppDefaultVisibilityHandler: import("h3").Event
|
|
|
73
73
|
export declare const createOrgHandler: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
74
74
|
success: boolean;
|
|
75
75
|
name?: undefined;
|
|
76
|
-
role?: undefined;
|
|
77
76
|
id?: undefined;
|
|
77
|
+
role?: undefined;
|
|
78
78
|
} | {
|
|
79
79
|
success?: undefined;
|
|
80
80
|
id: string;
|
|
@@ -78,6 +78,7 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
|
|
|
78
78
|
message?: undefined;
|
|
79
79
|
id?: undefined;
|
|
80
80
|
deleted?: undefined;
|
|
81
|
+
found?: undefined;
|
|
81
82
|
providers: {
|
|
82
83
|
id: string;
|
|
83
84
|
label: string;
|
|
@@ -89,7 +90,6 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
|
|
|
89
90
|
}[];
|
|
90
91
|
count: number;
|
|
91
92
|
provider?: undefined;
|
|
92
|
-
found?: undefined;
|
|
93
93
|
registered?: undefined;
|
|
94
94
|
label?: undefined;
|
|
95
95
|
} | {
|
|
@@ -114,20 +114,20 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
|
|
|
114
114
|
label?: undefined;
|
|
115
115
|
} | {
|
|
116
116
|
message?: undefined;
|
|
117
|
+
found?: undefined;
|
|
117
118
|
count?: undefined;
|
|
118
119
|
providers?: undefined;
|
|
119
120
|
provider?: undefined;
|
|
120
|
-
found?: undefined;
|
|
121
121
|
deleted: boolean;
|
|
122
122
|
id: string;
|
|
123
123
|
registered?: undefined;
|
|
124
124
|
label?: undefined;
|
|
125
125
|
} | {
|
|
126
126
|
deleted?: undefined;
|
|
127
|
+
found?: undefined;
|
|
127
128
|
count?: undefined;
|
|
128
129
|
providers?: undefined;
|
|
129
130
|
provider?: undefined;
|
|
130
|
-
found?: undefined;
|
|
131
131
|
registered: boolean;
|
|
132
132
|
id: string;
|
|
133
133
|
label: string;
|
|
@@ -315,6 +315,7 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
|
|
|
315
315
|
deleted?: undefined;
|
|
316
316
|
id?: undefined;
|
|
317
317
|
message?: undefined;
|
|
318
|
+
found?: undefined;
|
|
318
319
|
providers: {
|
|
319
320
|
id: string;
|
|
320
321
|
label: string;
|
|
@@ -325,15 +326,14 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
|
|
|
325
326
|
updatedAt: number;
|
|
326
327
|
}[];
|
|
327
328
|
count: number;
|
|
328
|
-
found?: undefined;
|
|
329
329
|
registered?: undefined;
|
|
330
330
|
label?: undefined;
|
|
331
331
|
} | {
|
|
332
332
|
deleted?: undefined;
|
|
333
333
|
id?: undefined;
|
|
334
|
-
count?: undefined;
|
|
335
334
|
message?: undefined;
|
|
336
335
|
providers?: undefined;
|
|
336
|
+
count?: undefined;
|
|
337
337
|
found: boolean;
|
|
338
338
|
provider: import("../custom-registry.js").CustomProviderConfig;
|
|
339
339
|
registered?: undefined;
|
|
@@ -341,19 +341,19 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
|
|
|
341
341
|
} | {
|
|
342
342
|
provider?: undefined;
|
|
343
343
|
deleted?: undefined;
|
|
344
|
-
count?: undefined;
|
|
345
344
|
message?: undefined;
|
|
346
345
|
providers?: undefined;
|
|
346
|
+
count?: undefined;
|
|
347
347
|
found: boolean;
|
|
348
348
|
id: string;
|
|
349
349
|
registered?: undefined;
|
|
350
350
|
label?: undefined;
|
|
351
351
|
} | {
|
|
352
352
|
provider?: undefined;
|
|
353
|
-
count?: undefined;
|
|
354
353
|
message?: undefined;
|
|
355
|
-
providers?: undefined;
|
|
356
354
|
found?: undefined;
|
|
355
|
+
providers?: undefined;
|
|
356
|
+
count?: undefined;
|
|
357
357
|
deleted: boolean;
|
|
358
358
|
id: string;
|
|
359
359
|
registered?: undefined;
|
|
@@ -361,9 +361,9 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
|
|
|
361
361
|
} | {
|
|
362
362
|
provider?: undefined;
|
|
363
363
|
deleted?: undefined;
|
|
364
|
-
count?: undefined;
|
|
365
|
-
providers?: undefined;
|
|
366
364
|
found?: undefined;
|
|
365
|
+
providers?: undefined;
|
|
366
|
+
count?: undefined;
|
|
367
367
|
registered: boolean;
|
|
368
368
|
id: string;
|
|
369
369
|
label: string;
|
|
@@ -633,6 +633,11 @@ export async function mergeCoreSharingActions(registry) {
|
|
|
633
633
|
"get-usage-metrics",
|
|
634
634
|
() => import("../usage/actions/get-usage-metrics.js"),
|
|
635
635
|
],
|
|
636
|
+
[
|
|
637
|
+
"get-usage-insights",
|
|
638
|
+
() => import("../usage/actions/get-usage-insights.js"),
|
|
639
|
+
],
|
|
640
|
+
["get-usage-run", () => import("../usage/actions/get-usage-run.js")],
|
|
636
641
|
[
|
|
637
642
|
"get-builder-credit-usage",
|
|
638
643
|
() => import("../usage/actions/get-builder-credit-usage.js"),
|
|
@@ -8,17 +8,17 @@ export declare const AGENT_ENGINE_API_KEY_ACTION_NAME = "agent-engine-api-key";
|
|
|
8
8
|
* resolveEngine's credential detection.
|
|
9
9
|
*/
|
|
10
10
|
export declare function createAgentEngineDisconnectHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
11
|
-
ok?: undefined;
|
|
12
11
|
error: string;
|
|
13
12
|
scope?: undefined;
|
|
13
|
+
ok?: undefined;
|
|
14
14
|
} | {
|
|
15
15
|
ok: boolean;
|
|
16
16
|
error: any;
|
|
17
17
|
scope?: undefined;
|
|
18
18
|
} | {
|
|
19
|
-
error?: undefined;
|
|
20
19
|
ok: boolean;
|
|
21
20
|
scope: "org" | "user";
|
|
21
|
+
error?: undefined;
|
|
22
22
|
}>>;
|
|
23
23
|
export interface DefaultModelSelectionRequest {
|
|
24
24
|
engine: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare function createAgentEngineOllamaModelsHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
2
|
+
ok?: undefined;
|
|
2
3
|
error: string;
|
|
3
4
|
models?: undefined;
|
|
4
|
-
ok?: undefined;
|
|
5
5
|
} | {
|
|
6
|
+
error?: undefined;
|
|
6
7
|
ok: boolean;
|
|
7
8
|
models: string[];
|
|
8
|
-
error?: undefined;
|
|
9
9
|
}>>;
|
|
@@ -581,8 +581,8 @@ export declare function createPublicRemoteAgentsHandler(discover?: PublicAgentDi
|
|
|
581
581
|
error: string;
|
|
582
582
|
agents?: undefined;
|
|
583
583
|
} | {
|
|
584
|
-
agents: Omit<import("./agent-discovery.js").DiscoveredAgent, "auth" | "kind">[];
|
|
585
584
|
error?: undefined;
|
|
585
|
+
agents: Omit<import("./agent-discovery.js").DiscoveredAgent, "auth" | "kind">[];
|
|
586
586
|
}>>;
|
|
587
587
|
export declare function getBuilderConnectErrorDisposition(error: unknown, connectAttemptId: string | null): "correlated" | "legacy" | null;
|
|
588
588
|
export declare function getBuilderConnectErrorKey(ownerEmail: string, connectAttemptId?: string | null): string;
|
|
@@ -126,6 +126,8 @@ const APP_PROVIDED_DEPLOY_CREDENTIAL_KEYS = new Set([
|
|
|
126
126
|
"NOTION_CLIENT_ID",
|
|
127
127
|
"NOTION_CLIENT_SECRET",
|
|
128
128
|
"SLACK_BOT_TOKEN",
|
|
129
|
+
// Signs events from the deployed Slack app, not the integration owner's identity.
|
|
130
|
+
"SLACK_SIGNING_SECRET",
|
|
129
131
|
"RESEND_API_KEY",
|
|
130
132
|
"SENDGRID_API_KEY",
|
|
131
133
|
]);
|
|
@@ -1509,6 +1511,9 @@ export async function resolveSecretDetailed(key, options = {}) {
|
|
|
1509
1511
|
lookupFailed = true;
|
|
1510
1512
|
cause = err;
|
|
1511
1513
|
}
|
|
1514
|
+
if (lookupFailed && !isTrustedSelfHostedRuntime()) {
|
|
1515
|
+
return { value: null, lookupFailed: true, cause };
|
|
1516
|
+
}
|
|
1512
1517
|
const envFallback = (isBuilderCredentialKey(key)
|
|
1513
1518
|
? canUseBuilderDeployCredentialFallbackForRequest()
|
|
1514
1519
|
: canUseDeployCredentialFallbackForRequest(key))
|
|
@@ -54,8 +54,8 @@ export declare function createRealtimeTokenHandler(): import("h3").EventHandlerW
|
|
|
54
54
|
expiresAt?: undefined;
|
|
55
55
|
ttlSeconds?: undefined;
|
|
56
56
|
} | {
|
|
57
|
+
error?: undefined;
|
|
57
58
|
token: string;
|
|
58
59
|
expiresAt: string;
|
|
59
60
|
ttlSeconds: number;
|
|
60
|
-
error?: undefined;
|
|
61
61
|
}>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineAction } from "../../action.js";
|
|
3
|
+
import { getUsageInsights } from "../insights-store.js";
|
|
4
|
+
import { resolveUsageAppKey } from "../store.js";
|
|
5
|
+
export default defineAction({
|
|
6
|
+
description: "Get the Usage page's performance breakdown for an app: spend split by cache reads, cache writes, fresh input and output, savings versus no prompt caching, and recent prompts with per-run LLM calls, tool calls, tool lookups and cache misses.",
|
|
7
|
+
http: { method: "GET" },
|
|
8
|
+
schema: z.object({
|
|
9
|
+
sinceDays: z.coerce.number().int().min(1).max(365).default(30),
|
|
10
|
+
scope: z.enum(["me", "workspace"]).default("me"),
|
|
11
|
+
userEmail: z.string().trim().min(1).optional(),
|
|
12
|
+
appId: z.string().trim().max(200).optional(),
|
|
13
|
+
}),
|
|
14
|
+
run: async ({ sinceDays, scope, userEmail, appId }, ctx) => {
|
|
15
|
+
if (!ctx?.userEmail)
|
|
16
|
+
throw new Error("Not authenticated.");
|
|
17
|
+
return getUsageInsights({ sinceDays, scope, userEmail }, {
|
|
18
|
+
ownerEmail: ctx.userEmail,
|
|
19
|
+
orgId: ctx.orgId,
|
|
20
|
+
app: resolveUsageAppKey(appId),
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineAction } from "../../action.js";
|
|
3
|
+
import { getUsageRun } from "../insights-store.js";
|
|
4
|
+
import { resolveUsageAppKey } from "../store.js";
|
|
5
|
+
export default defineAction({
|
|
6
|
+
description: "Get one prompt's step-by-step cost breakdown for the Usage page: every LLM call with tokens, cache hit and cost, every tool call with status, cache misses with their likely cause, and automated eval scores.",
|
|
7
|
+
http: { method: "GET" },
|
|
8
|
+
schema: z.object({
|
|
9
|
+
runId: z.string().trim().min(1).max(200),
|
|
10
|
+
scope: z.enum(["me", "workspace"]).default("me"),
|
|
11
|
+
userEmail: z.string().trim().min(1).optional(),
|
|
12
|
+
appId: z.string().trim().max(200).optional(),
|
|
13
|
+
}),
|
|
14
|
+
run: async ({ runId, scope, userEmail, appId }, ctx) => {
|
|
15
|
+
if (!ctx?.userEmail)
|
|
16
|
+
throw new Error("Not authenticated.");
|
|
17
|
+
return getUsageRun({ runId, scope, userEmail }, {
|
|
18
|
+
ownerEmail: ctx.userEmail,
|
|
19
|
+
orgId: ctx.orgId,
|
|
20
|
+
app: resolveUsageAppKey(appId),
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
});
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { type UsageMetricsAccessInput, type UsageMetricsScope } from "./metrics-store.js";
|
|
2
|
+
/** Run insights are always read for one app, never across all apps. */
|
|
3
|
+
type RunAccessInput = UsageMetricsAccessInput & {
|
|
4
|
+
app: string;
|
|
5
|
+
};
|
|
6
|
+
/** Spend split by how the provider billed each token, in cents. */
|
|
7
|
+
export interface UsageCostBreakdown {
|
|
8
|
+
cacheReadCents: number;
|
|
9
|
+
cacheWriteCents: number;
|
|
10
|
+
uncachedInputCents: number;
|
|
11
|
+
outputCents: number;
|
|
12
|
+
/** Recorded spend for the rows; the category splits above are token-priced estimates. */
|
|
13
|
+
totalCents: number;
|
|
14
|
+
/** The same tokens priced at list rates, so it is comparable to `noCacheCents`. */
|
|
15
|
+
estimatedCents: number;
|
|
16
|
+
/** What the same tokens would have cost with no prompt caching. */
|
|
17
|
+
noCacheCents: number;
|
|
18
|
+
}
|
|
19
|
+
export interface UsageTokenTotals {
|
|
20
|
+
inputTokens: number;
|
|
21
|
+
outputTokens: number;
|
|
22
|
+
cacheReadTokens: number;
|
|
23
|
+
cacheWriteTokens: number;
|
|
24
|
+
}
|
|
25
|
+
export type UsageScoreSource = "heuristic" | "judge" | "human";
|
|
26
|
+
export interface UsageRunScore {
|
|
27
|
+
source: UsageScoreSource;
|
|
28
|
+
criteria: string;
|
|
29
|
+
score: number;
|
|
30
|
+
reasoning: string | null;
|
|
31
|
+
}
|
|
32
|
+
export interface UsageRunTool {
|
|
33
|
+
name: string;
|
|
34
|
+
calls: number;
|
|
35
|
+
failed: number;
|
|
36
|
+
error: string | null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The context was re-sent in full when the cache could have been re-used.
|
|
40
|
+
* `tool-lookup`: new tools were loaded; `prefix-changed`: something else at
|
|
41
|
+
* the start of the prompt changed.
|
|
42
|
+
*/
|
|
43
|
+
export type UsageRestartCause = "tool-lookup" | "prefix-changed";
|
|
44
|
+
export interface UsageRunRestarts {
|
|
45
|
+
count: number;
|
|
46
|
+
cents: number;
|
|
47
|
+
byCause: Record<UsageRestartCause, {
|
|
48
|
+
count: number;
|
|
49
|
+
cents: number;
|
|
50
|
+
}>;
|
|
51
|
+
}
|
|
52
|
+
export interface UsageRunListItem {
|
|
53
|
+
runId: string;
|
|
54
|
+
threadId: string | null;
|
|
55
|
+
createdAt: number;
|
|
56
|
+
ownerEmail: string;
|
|
57
|
+
label: string;
|
|
58
|
+
model: string;
|
|
59
|
+
prompt: string | null;
|
|
60
|
+
/** `unknown` when the trace was never written or has been cleaned up. */
|
|
61
|
+
status: "success" | "error" | "unknown";
|
|
62
|
+
tokens: UsageTokenTotals;
|
|
63
|
+
cost: UsageCostBreakdown;
|
|
64
|
+
modelCalls: number;
|
|
65
|
+
tools: UsageRunTool[];
|
|
66
|
+
restarts: UsageRunRestarts;
|
|
67
|
+
/** Tool calls that overlapped another call in the same step, and the time that saved. */
|
|
68
|
+
parallel: {
|
|
69
|
+
calls: number;
|
|
70
|
+
savedMs: number;
|
|
71
|
+
};
|
|
72
|
+
/** Failed tool calls in a run that still finished. */
|
|
73
|
+
recoveredErrors: number;
|
|
74
|
+
durationMs: number | null;
|
|
75
|
+
feedback: "up" | "down" | null;
|
|
76
|
+
}
|
|
77
|
+
export interface UsagePeriodTotals {
|
|
78
|
+
runs: number;
|
|
79
|
+
tokens: UsageTokenTotals;
|
|
80
|
+
cost: UsageCostBreakdown;
|
|
81
|
+
}
|
|
82
|
+
export interface UsageInsights {
|
|
83
|
+
sinceDays: number;
|
|
84
|
+
current: UsagePeriodTotals;
|
|
85
|
+
previous: UsagePeriodTotals;
|
|
86
|
+
runs: UsageRunListItem[];
|
|
87
|
+
}
|
|
88
|
+
export interface UsageRunToolCall {
|
|
89
|
+
name: string;
|
|
90
|
+
startedAt: number;
|
|
91
|
+
durationMs: number;
|
|
92
|
+
status: string;
|
|
93
|
+
errorMessage: string | null;
|
|
94
|
+
}
|
|
95
|
+
/** One model call and the tools it asked for. */
|
|
96
|
+
export interface UsageRunTurn {
|
|
97
|
+
index: number;
|
|
98
|
+
model: string;
|
|
99
|
+
durationMs: number;
|
|
100
|
+
tokens: UsageTokenTotals;
|
|
101
|
+
cost: UsageCostBreakdown;
|
|
102
|
+
status: string;
|
|
103
|
+
/** Set only when re-sending the context cost a meaningful amount. */
|
|
104
|
+
restart: {
|
|
105
|
+
cause: UsageRestartCause;
|
|
106
|
+
cents: number;
|
|
107
|
+
} | null;
|
|
108
|
+
/** The provider cache had expired after an idle gap; expected, not a fault. */
|
|
109
|
+
cacheExpired: boolean;
|
|
110
|
+
toolCalls: UsageRunToolCall[];
|
|
111
|
+
}
|
|
112
|
+
export interface UsageRunDetail extends UsageRunListItem {
|
|
113
|
+
reply: string | null;
|
|
114
|
+
turns: UsageRunTurn[];
|
|
115
|
+
scores: UsageRunScore[];
|
|
116
|
+
}
|
|
117
|
+
export declare function getUsageInsights(input: {
|
|
118
|
+
sinceDays?: number;
|
|
119
|
+
scope?: UsageMetricsScope;
|
|
120
|
+
userEmail?: string | null;
|
|
121
|
+
}, accessInput: RunAccessInput): Promise<UsageInsights>;
|
|
122
|
+
export declare function getUsageRun(input: {
|
|
123
|
+
runId: string;
|
|
124
|
+
scope?: UsageMetricsScope;
|
|
125
|
+
userEmail?: string | null;
|
|
126
|
+
}, accessInput: RunAccessInput): Promise<UsageRunDetail | null>;
|
|
127
|
+
export {};
|