@opengeni/core 1.3.0 → 1.4.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/dist/domain/connector-tool-permissions.d.ts +1 -1
- package/dist/domain/knowledge-messages.d.ts +2 -2
- package/dist/domain/realtime-voice-billing.d.ts +81 -0
- package/dist/domain/scheduled-task-access.d.ts +2 -2
- package/dist/domain/scheduled-tasks.d.ts +2 -2
- package/dist/domain/session-connection-accounts.d.ts +1 -1
- package/dist/domain/session-tool-policy.d.ts +4 -4
- package/dist/domain/voice-input-billing.d.ts +76 -0
- package/dist/domain/web-search-billing.d.ts +45 -0
- package/dist/goal-admission.d.ts +24 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +790 -142
- package/dist/index.js.map +1 -1
- package/dist/transcription.d.ts +119 -2
- package/package.json +12 -12
- package/src/domain/connector-tool-permissions.ts +24 -8
- package/src/domain/realtime-voice-billing.ts +330 -0
- package/src/domain/scheduled-task-access.ts +2 -1
- package/src/domain/scheduled-tasks.ts +3 -2
- package/src/domain/session-connection-accounts.ts +7 -3
- package/src/domain/session-tool-policy.ts +14 -2
- package/src/domain/sessions.ts +15 -2
- package/src/domain/voice-input-billing.ts +310 -0
- package/src/domain/web-search-billing.ts +154 -0
- package/src/index.ts +3 -0
- package/src/sandbox/routing.ts +59 -25
- package/src/transcription.ts +122 -3
|
@@ -28,7 +28,7 @@ export declare function connectorToolGroup(tool: ListedTool): "read" | "write" |
|
|
|
28
28
|
export declare function unpinnedConnectorToolPermissionAccount<T extends ConnectionMetadata>(ref: McpServerConnectionRef, visible: T[], subjectId: string): T | null;
|
|
29
29
|
export declare function connectorToolPermissionReference(ref: McpServerConnectionRef, connectionId: string): McpServerConnectionRef;
|
|
30
30
|
/** Use the same adapter-owned identities as execution for reviewed local catalogs. */
|
|
31
|
-
export declare function reviewedConnectorToolCatalog(server: Pick<Settings["mcpServers"][number], "url" | "connectionRef" | "allowedTools">, grantedScopes: readonly string[]): ListedTool[] | null;
|
|
31
|
+
export declare function reviewedConnectorToolCatalog(server: Pick<Settings["mcpServers"][number], "url" | "connectionRef" | "allowedTools">, grantedScopes: readonly string[], deployment: Pick<Settings, "gmailWatchTopicName">): ListedTool[] | null;
|
|
32
32
|
/** Collect discovery pages without changing the caller's connection or authority. */
|
|
33
33
|
export declare function collectConnectorToolPages(client: Pick<Client, "listTools">, deadline: AbortSignal): Promise<ListedTool[]>;
|
|
34
34
|
export declare function getConnectorToolPermissions(input: Input): Promise<ConnectorToolPermissionsResponse>;
|
|
@@ -17,7 +17,7 @@ export declare function retainKnowledgeMessage(db: Database, context: KnowledgeC
|
|
|
17
17
|
messageId?: never;
|
|
18
18
|
reused?: never;
|
|
19
19
|
} | {
|
|
20
|
-
reason?: never;
|
|
20
|
+
readonly reason?: never;
|
|
21
21
|
retained: boolean;
|
|
22
22
|
entryId: string;
|
|
23
23
|
revisionId: string;
|
|
@@ -32,7 +32,7 @@ export declare function retainKnowledgeMessage(db: Database, context: KnowledgeC
|
|
|
32
32
|
outcome: "archived" | "pending" | "published" | "rejected";
|
|
33
33
|
reviewBatchId: string | null;
|
|
34
34
|
replayed: boolean;
|
|
35
|
-
reason?: never;
|
|
35
|
+
readonly reason?: never;
|
|
36
36
|
reused?: never;
|
|
37
37
|
retained: boolean;
|
|
38
38
|
messageId: string;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type RealtimeVoicePricing, type Settings } from "@opengeni/config";
|
|
2
|
+
import type { SessionRealtimeModel } from "@opengeni/contracts";
|
|
3
|
+
import { type CreditDebitAttribution, type Database } from "@opengeni/db";
|
|
4
|
+
import { TranscriptionBillingRefusedError } from "../transcription.js";
|
|
5
|
+
/** Credit debit type and usage source for deployment-funded live voice. */
|
|
6
|
+
export declare const REALTIME_VOICE_DEBIT_TYPE = "voice_realtime_debit";
|
|
7
|
+
export declare const REALTIME_VOICE_SOURCE_TYPE = "voice_realtime";
|
|
8
|
+
export type DeploymentRealtimeVoice = {
|
|
9
|
+
provider: "azure-live" | "ai-gateway";
|
|
10
|
+
/** Credentials exist and this deployment offers the model. */
|
|
11
|
+
configured: boolean;
|
|
12
|
+
pricing: RealtimeVoicePricing | null;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Live-voice models the deployment pays the provider for. Connected Codex,
|
|
16
|
+
* SuperGrok, and a workspace's own Gateway key are paid by the workspace and
|
|
17
|
+
* return null. (The catalog lists hosted GPT Live instead of the managed
|
|
18
|
+
* Gateway choices when both are configured; both remain priced and gated.)
|
|
19
|
+
*/
|
|
20
|
+
export declare function deploymentRealtimeVoice(settings: Settings, model: SessionRealtimeModel | string): DeploymentRealtimeVoice | null;
|
|
21
|
+
export type RealtimeVoiceUnavailableCode = "not_configured" | "pricing_unconfigured";
|
|
22
|
+
/** The deployment cannot offer this live-voice model at all (not a credit refusal). */
|
|
23
|
+
export declare class RealtimeVoiceUnavailableError extends Error {
|
|
24
|
+
readonly code: RealtimeVoiceUnavailableCode;
|
|
25
|
+
readonly name = "RealtimeVoiceUnavailableError";
|
|
26
|
+
constructor(code: RealtimeVoiceUnavailableCode, message: string);
|
|
27
|
+
}
|
|
28
|
+
/** Static offer check: configured, and priced whenever credits are enforced. */
|
|
29
|
+
export declare function realtimeVoiceOfferProblem(settings: Settings, voice: DeploymentRealtimeVoice): RealtimeVoiceUnavailableError | null;
|
|
30
|
+
export declare const REALTIME_VOICE_INSUFFICIENT_CREDITS_MESSAGE = "Live voice needs Opengeni credits. Add credits to continue.";
|
|
31
|
+
export type RealtimeVoiceSettlement = {
|
|
32
|
+
/** Credits debited by this settlement call (0 on replay). */
|
|
33
|
+
debitedMicros: number;
|
|
34
|
+
/** Why the live call must stop now, when it must. */
|
|
35
|
+
stop: TranscriptionBillingRefusedError | RealtimeVoiceUnavailableError | null;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Credit admission and time metering for deployment-funded live voice.
|
|
39
|
+
*
|
|
40
|
+
* Admission mirrors voice-input admission (same refusal codes and HTTP
|
|
41
|
+
* shape): spendable general credits must be positive, the workspace/member
|
|
42
|
+
* allowance must not be exhausted, and the static monthly cost cap applies.
|
|
43
|
+
* Metering bills every started minute of each issued provider connection,
|
|
44
|
+
* measured only from server-observed facts (connection claim time, owner
|
|
45
|
+
* heartbeats, owner-proven end). Each (connection, minute) is one idempotent
|
|
46
|
+
* usage receipt plus one post-use debit.
|
|
47
|
+
*/
|
|
48
|
+
export declare function createRealtimeVoiceBilling(deps: {
|
|
49
|
+
db: Database;
|
|
50
|
+
settings: Settings;
|
|
51
|
+
}): {
|
|
52
|
+
/**
|
|
53
|
+
* Throws RealtimeVoiceUnavailableError when the deployment cannot offer
|
|
54
|
+
* the model and TranscriptionBillingRefusedError for a credit refusal.
|
|
55
|
+
* Workspace-funded models are always admitted here.
|
|
56
|
+
*/
|
|
57
|
+
admit(input: {
|
|
58
|
+
accountId: string;
|
|
59
|
+
workspaceId: string;
|
|
60
|
+
model: SessionRealtimeModel;
|
|
61
|
+
attribution: CreditDebitAttribution;
|
|
62
|
+
now?: Date;
|
|
63
|
+
}): Promise<void>;
|
|
64
|
+
/** Spendable credits are positive (always true when credits are not enforced). */
|
|
65
|
+
hasSpendableCredits(accountId: string): Promise<boolean>;
|
|
66
|
+
/**
|
|
67
|
+
* Settle every started minute observed so far for one live-voice mode and
|
|
68
|
+
* report whether the call must stop. Safe to call repeatedly and
|
|
69
|
+
* concurrently: receipts and debits are idempotent per (connection, minute).
|
|
70
|
+
*/
|
|
71
|
+
settle(input: {
|
|
72
|
+
workspaceId: string;
|
|
73
|
+
sessionId: string;
|
|
74
|
+
realtimeId: string;
|
|
75
|
+
/** Authenticated caller; its attribution applies only when it owns the call. */
|
|
76
|
+
callerSubjectId: string;
|
|
77
|
+
attribution: CreditDebitAttribution;
|
|
78
|
+
now?: Date;
|
|
79
|
+
}): Promise<RealtimeVoiceSettlement>;
|
|
80
|
+
};
|
|
81
|
+
export type RealtimeVoiceBilling = ReturnType<typeof createRealtimeVoiceBilling>;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* ordinary owner update path, so a refresh never widens beyond what the calling
|
|
11
11
|
* person could grant with an edit. See docs/scheduled-task-access.md.
|
|
12
12
|
*/
|
|
13
|
-
import { type Settings } from "@opengeni/config";
|
|
13
|
+
import { type Settings, type FirstPartyMcpToolPolicySettings } from "@opengeni/config";
|
|
14
14
|
import { type AccessGrant, type ConnectionMetadata, type FirstPartyMcpToolName, type McpConnectionAccountSelection, type Permission, type RefreshScheduledTaskAccessRequest, type ScheduledTask, type ScheduledTaskAccessAttention, type ScheduledTaskAccessConnector, type ScheduledTaskPolicyDrift, type ScheduledTaskRun, type ScheduledTaskRunAccessFailure, type SessionAuthorizationPort, type SessionAuthorizationSurface, type ToolRef } from "@opengeni/contracts";
|
|
15
15
|
import { type Database, type ScheduledTaskCreatorPolicy } from "@opengeni/db";
|
|
16
16
|
import { type AccessGrantAuthorization } from "../access/index.js";
|
|
@@ -88,7 +88,7 @@ export type FirstPartyToolPermissionRequirements = (tools: readonly FirstPartyMc
|
|
|
88
88
|
*/
|
|
89
89
|
export declare function planScheduledTaskOpenGeniTools(input: {
|
|
90
90
|
creatorPolicy: Pick<ScheduledTaskCreatorPolicy, "firstPartyMcpTools" | "firstPartyMcpPermissions"> | null;
|
|
91
|
-
settings:
|
|
91
|
+
settings: FirstPartyMcpToolPolicySettings;
|
|
92
92
|
grantPermissions: readonly Permission[];
|
|
93
93
|
grantPermissionMode?: AccessGrant["permissionMode"];
|
|
94
94
|
permissionsRequiredByTools: FirstPartyToolPermissionRequirements;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Settings } from "@opengeni/config";
|
|
1
|
+
import { type FirstPartyMcpToolPolicySettings, type Settings } from "@opengeni/config";
|
|
2
2
|
import type { AccessGrant, ScheduledTask, ScheduledTaskAgentConfig, Session, ToolRef, SessionAuthorizationPort, SessionAuthorizationSurface, CreateScheduledTaskRequest as CreateScheduledTaskPayload, UpdateScheduledTaskRequest as UpdateScheduledTaskPayload } from "@opengeni/contracts";
|
|
3
3
|
import { type KnowledgeContext, type Database, type ScheduledTaskCreatorPolicy, type SessionCommandActor, type TemporalScheduleCleanupClaim, type UpdateScheduledTaskInput } from "@opengeni/db";
|
|
4
4
|
import { type AccessGrantAuthorization } from "../access/index.js";
|
|
@@ -195,4 +195,4 @@ export declare function manualScheduledTaskTriggerUsageKey(workspaceId: string,
|
|
|
195
195
|
* provider, or treats ambient worker credentials as responder capability.
|
|
196
196
|
* Mutable rig/variable-set metadata is revalidated again at dispatch.
|
|
197
197
|
*/
|
|
198
|
-
export declare function validateIncidentTelemetryPreflightSelection(settings:
|
|
198
|
+
export declare function validateIncidentTelemetryPreflightSelection(settings: FirstPartyMcpToolPolicySettings, agentConfig: ScheduledTaskAgentConfig): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AccessGrant } from "@opengeni/contracts";
|
|
2
|
-
import type
|
|
2
|
+
import { type Settings } from "@opengeni/config";
|
|
3
3
|
import { type Database } from "@opengeni/db";
|
|
4
4
|
/** Freeze the authenticated request's eligible accounts before starting voice.
|
|
5
5
|
* The resulting lease snapshot, not a later participant or ambient connection,
|
|
@@ -106,10 +106,10 @@ export declare function sessionEffectiveToolProjectionInput(session: Session & {
|
|
|
106
106
|
mcpServerIds: string[];
|
|
107
107
|
productServerIds: ReadonlySet<string>;
|
|
108
108
|
environment: AgentToolEnvironment;
|
|
109
|
-
runtimeToolNames: ("apply_patch" | "code_search" | "exec_command" | "generate_image" | "generate_video" | "get_video_generation_capabilities" | "image_generation" | "knowledge_source_fetch" | "knowledge_source_read" | "list_models" | "operation_read" | "refresh_credentials" | "repository_skill_read" | "request_human_input" | "skill_checkout" | "skill_install" | "skill_publish" | "skill_read" | "skill_remove" | "skill_save" | "skill_search" | "tool_invoke" | "tool_list" | "tool_search" | "view_image" | "web_search" | "write_stdin" | "x_search")[];
|
|
110
|
-
hostedToolNames: ("apply_patch" | "code_search" | "exec_command" | "generate_image" | "generate_video" | "get_video_generation_capabilities" | "image_generation" | "knowledge_source_fetch" | "knowledge_source_read" | "list_models" | "operation_read" | "refresh_credentials" | "repository_skill_read" | "request_human_input" | "skill_checkout" | "skill_install" | "skill_publish" | "skill_read" | "skill_remove" | "skill_save" | "skill_search" | "tool_invoke" | "tool_list" | "tool_search" | "view_image" | "web_search" | "write_stdin" | "x_search")[];
|
|
111
|
-
sandboxToolNames: ("apply_patch" | "code_search" | "exec_command" | "generate_image" | "generate_video" | "get_video_generation_capabilities" | "image_generation" | "knowledge_source_fetch" | "knowledge_source_read" | "list_models" | "operation_read" | "refresh_credentials" | "repository_skill_read" | "request_human_input" | "skill_checkout" | "skill_install" | "skill_publish" | "skill_read" | "skill_remove" | "skill_save" | "skill_search" | "tool_invoke" | "tool_list" | "tool_search" | "view_image" | "web_search" | "write_stdin" | "x_search")[];
|
|
112
|
-
routerToolNames: ("apply_patch" | "code_search" | "exec_command" | "generate_image" | "generate_video" | "get_video_generation_capabilities" | "image_generation" | "knowledge_source_fetch" | "knowledge_source_read" | "list_models" | "operation_read" | "refresh_credentials" | "repository_skill_read" | "request_human_input" | "skill_checkout" | "skill_install" | "skill_publish" | "skill_read" | "skill_remove" | "skill_save" | "skill_search" | "tool_invoke" | "tool_list" | "tool_search" | "view_image" | "web_search" | "write_stdin" | "x_search")[];
|
|
109
|
+
runtimeToolNames: ("apply_patch" | "code_search" | "exec_command" | "generate_image" | "generate_video" | "get_video_generation_capabilities" | "image_generation" | "knowledge_source_fetch" | "knowledge_source_read" | "list_models" | "operation_read" | "refresh_credentials" | "repository_skill_read" | "request_human_input" | "skill_checkout" | "skill_install" | "skill_publish" | "skill_read" | "skill_remove" | "skill_save" | "skill_search" | "tool_invoke" | "tool_list" | "tool_search" | "view_image" | "web_fetch" | "web_search" | "write_stdin" | "x_search")[];
|
|
110
|
+
hostedToolNames: ("apply_patch" | "code_search" | "exec_command" | "generate_image" | "generate_video" | "get_video_generation_capabilities" | "image_generation" | "knowledge_source_fetch" | "knowledge_source_read" | "list_models" | "operation_read" | "refresh_credentials" | "repository_skill_read" | "request_human_input" | "skill_checkout" | "skill_install" | "skill_publish" | "skill_read" | "skill_remove" | "skill_save" | "skill_search" | "tool_invoke" | "tool_list" | "tool_search" | "view_image" | "web_fetch" | "web_search" | "write_stdin" | "x_search")[];
|
|
111
|
+
sandboxToolNames: ("apply_patch" | "code_search" | "exec_command" | "generate_image" | "generate_video" | "get_video_generation_capabilities" | "image_generation" | "knowledge_source_fetch" | "knowledge_source_read" | "list_models" | "operation_read" | "refresh_credentials" | "repository_skill_read" | "request_human_input" | "skill_checkout" | "skill_install" | "skill_publish" | "skill_read" | "skill_remove" | "skill_save" | "skill_search" | "tool_invoke" | "tool_list" | "tool_search" | "view_image" | "web_fetch" | "web_search" | "write_stdin" | "x_search")[];
|
|
112
|
+
routerToolNames: ("apply_patch" | "code_search" | "exec_command" | "generate_image" | "generate_video" | "get_video_generation_capabilities" | "image_generation" | "knowledge_source_fetch" | "knowledge_source_read" | "list_models" | "operation_read" | "refresh_credentials" | "repository_skill_read" | "request_human_input" | "skill_checkout" | "skill_install" | "skill_publish" | "skill_read" | "skill_remove" | "skill_save" | "skill_search" | "tool_invoke" | "tool_list" | "tool_search" | "view_image" | "web_fetch" | "web_search" | "write_stdin" | "x_search")[];
|
|
113
113
|
upfrontToolNames: Set<string>;
|
|
114
114
|
mediaAttachment: AgentMediaAttachment | {
|
|
115
115
|
readonly image: null;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { type Settings, type VoiceInputPricing, type VoiceInputUsage } from "@opengeni/config";
|
|
2
|
+
import { type Database } from "@opengeni/db";
|
|
3
|
+
import { type TranscriptionBilling, type TranscriptionBillingContext } from "../transcription.js";
|
|
4
|
+
/** Credit debit type and usage source for deployment-funded voice input. */
|
|
5
|
+
export declare const VOICE_INPUT_DEBIT_TYPE = "voice_transcription_debit";
|
|
6
|
+
export declare const VOICE_INPUT_SOURCE_TYPE = "voice_transcription";
|
|
7
|
+
/** How the billed quantity was measured; recorded on the ledger entry. */
|
|
8
|
+
export type VoiceInputBillingBasis = "provider_tokens" | "provider_duration" | "server_duration" | "reconciled_receipt";
|
|
9
|
+
/**
|
|
10
|
+
* Pick the billed measurement. Provider usage wins when this deployment can
|
|
11
|
+
* price it (token usage with token rates, or a reported duration). Otherwise
|
|
12
|
+
* the duration the server measured from WAV bytes it produced bills. Every
|
|
13
|
+
* deployment-funded call carries that server duration, so an unpriced usage
|
|
14
|
+
* shape never leaves a call unbillable. A client-reported duration is never a
|
|
15
|
+
* billing input.
|
|
16
|
+
*/
|
|
17
|
+
export declare function voiceInputBillableUsage(input: {
|
|
18
|
+
pricing: VoiceInputPricing;
|
|
19
|
+
usage: VoiceInputUsage | null;
|
|
20
|
+
trustedDurationSeconds?: number | undefined;
|
|
21
|
+
}): {
|
|
22
|
+
usage: VoiceInputUsage;
|
|
23
|
+
basis: VoiceInputBillingBasis;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Same admission shape as knowledge-search and session admission: general
|
|
27
|
+
* (not model-promotional) credits must be positive, the workspace/member
|
|
28
|
+
* allowance must not be exhausted, and a static monthly cost cap applies.
|
|
29
|
+
* Admission is a read, not a reservation; settlement is post-use and may take
|
|
30
|
+
* an account below zero by at most the concurrent in-flight calls.
|
|
31
|
+
*/
|
|
32
|
+
export declare function createVoiceInputBilling(deps: {
|
|
33
|
+
db: Database;
|
|
34
|
+
settings: Settings;
|
|
35
|
+
/** Reconciliation is best-effort at admission; failures are reported here. */
|
|
36
|
+
onReconcileError?: (error: unknown, scope: {
|
|
37
|
+
accountId: string;
|
|
38
|
+
workspaceId: string;
|
|
39
|
+
}) => void;
|
|
40
|
+
/** Minimum spacing of admission-time reconciliation per workspace (default 5 min). */
|
|
41
|
+
reconcileIntervalMilliseconds?: number;
|
|
42
|
+
}): TranscriptionBilling;
|
|
43
|
+
/**
|
|
44
|
+
* Two commits, in order: the `model.cost` usage receipt (Insights spend,
|
|
45
|
+
* monthly cost cap, member-allowance attribution), then the post-use credit
|
|
46
|
+
* debit. The receipt is the first-writer authority for the amount and the
|
|
47
|
+
* durable record of the charge: if the debit commit fails, the receipt stays
|
|
48
|
+
* and {@link reconcileUnsettledVoiceInputCharges} applies the same debit (same
|
|
49
|
+
* idempotency key) on the workspace's next admission. A retried unit settles
|
|
50
|
+
* exactly once at the originally recorded price.
|
|
51
|
+
*/
|
|
52
|
+
export declare function settleVoiceInputUsage(db: Database, input: {
|
|
53
|
+
accountId: string;
|
|
54
|
+
workspaceId: string;
|
|
55
|
+
providerId: string;
|
|
56
|
+
model: string;
|
|
57
|
+
billing: TranscriptionBillingContext;
|
|
58
|
+
usage: VoiceInputUsage;
|
|
59
|
+
basis: VoiceInputBillingBasis;
|
|
60
|
+
providerCostMicros: number;
|
|
61
|
+
creditCostMicros: number;
|
|
62
|
+
}): Promise<{
|
|
63
|
+
creditCostMicros: number;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Apply the debit for every voice usage receipt in this workspace whose debit
|
|
67
|
+
* never committed. Idempotent with the inline settlement (same key), bounded
|
|
68
|
+
* per call, and safe to run concurrently.
|
|
69
|
+
*/
|
|
70
|
+
export declare function reconcileUnsettledVoiceInputCharges(db: Database, input: {
|
|
71
|
+
accountId: string;
|
|
72
|
+
workspaceId: string;
|
|
73
|
+
minAgeMilliseconds?: number;
|
|
74
|
+
}): Promise<{
|
|
75
|
+
reconciled: number;
|
|
76
|
+
}>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Settings } from "@opengeni/config";
|
|
2
|
+
import { type Database } from "@opengeni/db";
|
|
3
|
+
/** Credit ledger type and usage source for deployment-funded web search calls. */
|
|
4
|
+
export declare const WEB_SEARCH_DEBIT_TYPE = "web_search_debit";
|
|
5
|
+
export declare const WEB_SEARCH_SOURCE_TYPE = "web_search";
|
|
6
|
+
/** Same rule as other deployment-funded resources: Stripe or managed limits. */
|
|
7
|
+
export declare function webSearchCreditBillingActive(settings: Pick<Settings, "billingMode" | "usageLimitsMode">): boolean;
|
|
8
|
+
/** Exact attempt that called the tool. Every charge is attributed to its turn. */
|
|
9
|
+
export type WebSearchCallScope = {
|
|
10
|
+
accountId: string;
|
|
11
|
+
workspaceId: string;
|
|
12
|
+
sessionId: string;
|
|
13
|
+
turnId: string;
|
|
14
|
+
attemptId: string;
|
|
15
|
+
};
|
|
16
|
+
export type WebSearchCallCost = {
|
|
17
|
+
/** Model tool-call or Codemode operation identity, unique within the attempt. */
|
|
18
|
+
operationId: string;
|
|
19
|
+
operation: "search" | "fetch";
|
|
20
|
+
provider: string;
|
|
21
|
+
providerMicros: number;
|
|
22
|
+
creditMicros: number;
|
|
23
|
+
marginBps: number;
|
|
24
|
+
basis: "provider_reported" | "configured_price" | "list_price";
|
|
25
|
+
};
|
|
26
|
+
export declare class WebSearchBillingRefusedError extends Error {
|
|
27
|
+
readonly code: "insufficient_credits" | "allowance_exhausted";
|
|
28
|
+
constructor(code: "insufficient_credits" | "allowance_exhausted", message: string);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Admission and post-use settlement for paid web search, matching paid
|
|
32
|
+
* Knowledge queries and voice input: admission reads general credits and the
|
|
33
|
+
* workspace/member allowance (a read, not a reservation); settlement records a
|
|
34
|
+
* durable usage receipt and the idempotent debit in one transaction. Calls
|
|
35
|
+
* that cost nothing (free providers, or billing inactive) are never refused.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createWebSearchBilling(deps: {
|
|
38
|
+
db: Database;
|
|
39
|
+
settings: Settings;
|
|
40
|
+
}): {
|
|
41
|
+
active: boolean;
|
|
42
|
+
admit(scope: WebSearchCallScope, expectedProviderMicros: number): Promise<void>;
|
|
43
|
+
settle(scope: WebSearchCallScope, cost: WebSearchCallCost): Promise<void>;
|
|
44
|
+
};
|
|
45
|
+
export type WebSearchBilling = ReturnType<typeof createWebSearchBilling>;
|
package/dist/goal-admission.d.ts
CHANGED
|
@@ -102,6 +102,7 @@ export declare function resolveGoalModelAdmission(db: Database, settings: Settin
|
|
|
102
102
|
delegationSecret?: string | undefined;
|
|
103
103
|
defaultFirstPartyMcpTools?: ("artifacts_archive" | "artifacts_create" | "artifacts_get_source" | "artifacts_list" | "artifacts_prepare_upload" | "artifacts_publish" | "artifacts_restore" | "artifacts_rollback" | "atlassian_get" | "atlassian_search" | "atlassian_sources_list" | "browser_act" | "browser_auth" | "browser_clipboard" | "browser_debug" | "browser_download_save" | "browser_downloads" | "browser_identity" | "browser_lifecycle" | "browser_observe" | "browser_open" | "browser_publish" | "browser_read" | "browser_screenshot" | "browser_tabs" | "capability_authorization_request" | "capability_catalog_search" | "command_read" | "command_wait" | "company_profile_confirm" | "company_profile_propose" | "computer_act" | "computer_clipboard" | "computer_lifecycle" | "computer_observe" | "computer_open" | "computer_targets" | "connected_machine_enroll_token" | "connected_machine_remove" | "custom_mcp_setup_request" | "editable_artifact_apply" | "editable_artifact_create" | "editable_artifact_export" | "editable_artifact_export_status" | "editable_artifact_get" | "editable_artifact_import" | "editable_artifact_inspect" | "editable_artifact_list" | "environment_list" | "environment_set_variable" | "fiken_bank_accounts_list" | "fiken_companies_list" | "fiken_contact_create" | "fiken_contacts_list" | "fiken_invoice_draft_create" | "fiken_invoice_get" | "fiken_invoices_list" | "fiken_products_list" | "fiken_purchases_list" | "fiken_sales_list" | "github_connect_link" | "github_repositories_list" | "goal_complete" | "goal_pause" | "goal_progress" | "goal_resume" | "goal_set" | "goal_update" | "instruction_policy_get" | "instruction_policy_propose" | "instruction_policy_save" | "interaction_discover" | "interaction_request_human" | "knowledge_archive" | "knowledge_browse" | "knowledge_correct" | "knowledge_get" | "knowledge_prepare_save" | "knowledge_propose" | "knowledge_retain_file" | "knowledge_retain_message" | "knowledge_save" | "knowledge_search" | "memory_correct" | "memory_save" | "memory_search" | "preference_propose" | "preference_registry_get" | "preference_registry_summary" | "project_create" | "project_delete" | "project_get" | "project_list" | "project_reorder" | "project_update" | "reddit_accounts_list" | "reddit_mentions_live" | "reddit_post_reply" | "reddit_posts_sync" | "reddit_search_live" | "reddit_thread_fetch" | "remember" | "remember_confirm" | "rig_get" | "rig_list" | "rig_promote" | "rig_propose_change" | "rig_verify" | "run_on" | "sandbox_attach" | "sandbox_file_publish" | "sandbox_provision" | "sandbox_swap" | "sandboxes_list" | "scheduled_task_runs_list" | "scheduled_tasks_create" | "scheduled_tasks_delete" | "scheduled_tasks_get" | "scheduled_tasks_list" | "scheduled_tasks_pause" | "scheduled_tasks_resume" | "scheduled_tasks_trigger" | "scheduled_tasks_update" | "session_create" | "session_events" | "session_get" | "session_human_input_respond" | "session_pause" | "session_resume" | "session_send_message" | "session_set_model" | "session_set_project" | "session_steer" | "session_wait" | "sessions_list" | "set_other_session_title" | "set_session_title" | "slack_bot_channel_history" | "slack_bot_delete_message" | "slack_bot_file_content" | "slack_bot_file_info" | "slack_bot_list_channels" | "slack_bot_list_files" | "slack_bot_list_users" | "slack_bot_post_message" | "slack_bot_prepare_message" | "slack_bot_search" | "slack_bot_send_prepared_message" | "slack_bot_thread_replies" | "slack_bot_upload_file" | "social_connections_list" | "social_daily_analysis_context" | "social_mentions_live" | "social_post_reply" | "social_posts_recent" | "social_posts_sync" | "social_search_live" | "social_thread_fetch" | "task_note_archive" | "task_note_promote_instruction_policy" | "task_note_promote_knowledge" | "task_note_promote_preference" | "task_note_replace" | "task_note_save" | "task_notes_list" | "variable_set_get_variable" | "variable_set_list" | "variable_set_set_variable" | "wait_for_input" | "work_claim_release" | "work_claim_upsert" | "x_accounts_list" | "x_mentions_live" | "x_post_reply" | "x_posts_sync" | "x_search_live" | "x_thread_fetch")[] | undefined;
|
|
104
104
|
allowedFirstPartyMcpTools?: ("artifacts_archive" | "artifacts_create" | "artifacts_get_source" | "artifacts_list" | "artifacts_prepare_upload" | "artifacts_publish" | "artifacts_restore" | "artifacts_rollback" | "atlassian_get" | "atlassian_search" | "atlassian_sources_list" | "browser_act" | "browser_auth" | "browser_clipboard" | "browser_debug" | "browser_download_save" | "browser_downloads" | "browser_identity" | "browser_lifecycle" | "browser_observe" | "browser_open" | "browser_publish" | "browser_read" | "browser_screenshot" | "browser_tabs" | "capability_authorization_request" | "capability_catalog_search" | "command_read" | "command_wait" | "company_profile_confirm" | "company_profile_propose" | "computer_act" | "computer_clipboard" | "computer_lifecycle" | "computer_observe" | "computer_open" | "computer_targets" | "connected_machine_enroll_token" | "connected_machine_remove" | "custom_mcp_setup_request" | "editable_artifact_apply" | "editable_artifact_create" | "editable_artifact_export" | "editable_artifact_export_status" | "editable_artifact_get" | "editable_artifact_import" | "editable_artifact_inspect" | "editable_artifact_list" | "environment_list" | "environment_set_variable" | "fiken_bank_accounts_list" | "fiken_companies_list" | "fiken_contact_create" | "fiken_contacts_list" | "fiken_invoice_draft_create" | "fiken_invoice_get" | "fiken_invoices_list" | "fiken_products_list" | "fiken_purchases_list" | "fiken_sales_list" | "github_connect_link" | "github_repositories_list" | "goal_complete" | "goal_pause" | "goal_progress" | "goal_resume" | "goal_set" | "goal_update" | "instruction_policy_get" | "instruction_policy_propose" | "instruction_policy_save" | "interaction_discover" | "interaction_request_human" | "knowledge_archive" | "knowledge_browse" | "knowledge_correct" | "knowledge_get" | "knowledge_prepare_save" | "knowledge_propose" | "knowledge_retain_file" | "knowledge_retain_message" | "knowledge_save" | "knowledge_search" | "memory_correct" | "memory_save" | "memory_search" | "preference_propose" | "preference_registry_get" | "preference_registry_summary" | "project_create" | "project_delete" | "project_get" | "project_list" | "project_reorder" | "project_update" | "reddit_accounts_list" | "reddit_mentions_live" | "reddit_post_reply" | "reddit_posts_sync" | "reddit_search_live" | "reddit_thread_fetch" | "remember" | "remember_confirm" | "rig_get" | "rig_list" | "rig_promote" | "rig_propose_change" | "rig_verify" | "run_on" | "sandbox_attach" | "sandbox_file_publish" | "sandbox_provision" | "sandbox_swap" | "sandboxes_list" | "scheduled_task_runs_list" | "scheduled_tasks_create" | "scheduled_tasks_delete" | "scheduled_tasks_get" | "scheduled_tasks_list" | "scheduled_tasks_pause" | "scheduled_tasks_resume" | "scheduled_tasks_trigger" | "scheduled_tasks_update" | "session_create" | "session_events" | "session_get" | "session_human_input_respond" | "session_pause" | "session_resume" | "session_send_message" | "session_set_model" | "session_set_project" | "session_steer" | "session_wait" | "sessions_list" | "set_other_session_title" | "set_session_title" | "slack_bot_channel_history" | "slack_bot_delete_message" | "slack_bot_file_content" | "slack_bot_file_info" | "slack_bot_list_channels" | "slack_bot_list_files" | "slack_bot_list_users" | "slack_bot_post_message" | "slack_bot_prepare_message" | "slack_bot_search" | "slack_bot_send_prepared_message" | "slack_bot_thread_replies" | "slack_bot_upload_file" | "social_connections_list" | "social_daily_analysis_context" | "social_mentions_live" | "social_post_reply" | "social_posts_recent" | "social_posts_sync" | "social_search_live" | "social_thread_fetch" | "task_note_archive" | "task_note_promote_instruction_policy" | "task_note_promote_knowledge" | "task_note_promote_preference" | "task_note_replace" | "task_note_save" | "task_notes_list" | "variable_set_get_variable" | "variable_set_list" | "variable_set_set_variable" | "wait_for_input" | "work_claim_release" | "work_claim_upsert" | "x_accounts_list" | "x_mentions_live" | "x_post_reply" | "x_posts_sync" | "x_search_live" | "x_thread_fetch")[] | undefined;
|
|
105
|
+
artifactMaterializerDeployed: boolean;
|
|
105
106
|
streamTokenSecret?: string | undefined;
|
|
106
107
|
streamControlEnabled: boolean;
|
|
107
108
|
workDiscoveryEnabled: boolean;
|
|
@@ -201,6 +202,20 @@ export declare function resolveGoalModelAdmission(db: Database, settings: Settin
|
|
|
201
202
|
voiceInputAzureApiVersion?: string | undefined;
|
|
202
203
|
voiceInputAzureApiKey?: string | undefined;
|
|
203
204
|
voiceInputAzureAdToken?: string | undefined;
|
|
205
|
+
azureLiveEndpoint?: string | undefined;
|
|
206
|
+
azureLiveApiKey?: string | undefined;
|
|
207
|
+
azureLiveDeployment: string;
|
|
208
|
+
azureLiveVoice: string;
|
|
209
|
+
azureLivePricingJson?: string | undefined;
|
|
210
|
+
aiGatewayRealtimePricingJson?: string | undefined;
|
|
211
|
+
voiceInputMaiEndpoint?: string | undefined;
|
|
212
|
+
voiceInputMaiApiKey?: string | undefined;
|
|
213
|
+
voiceInputMaiApiVersion: string;
|
|
214
|
+
voiceInputMaiPricingJson?: string | undefined;
|
|
215
|
+
voiceInputMaiModel: string;
|
|
216
|
+
voiceInputAzureModel?: string | undefined;
|
|
217
|
+
voiceInputOpenaiPricingJson?: string | undefined;
|
|
218
|
+
voiceInputAzurePricingJson?: string | undefined;
|
|
204
219
|
voiceInputCodexExperimentalEnabled: boolean;
|
|
205
220
|
modelPricingJson: string;
|
|
206
221
|
modelCatalogSource: "code" | "database";
|
|
@@ -231,6 +246,15 @@ export declare function resolveGoalModelAdmission(db: Database, settings: Settin
|
|
|
231
246
|
openaiReasoningEncryptedContent: boolean;
|
|
232
247
|
openaiMaxRetries: number;
|
|
233
248
|
webSearchEnabled: boolean;
|
|
249
|
+
webSearchProvider?: string | undefined;
|
|
250
|
+
webSearchApiKey?: string | undefined;
|
|
251
|
+
webSearchBaseUrl?: string | undefined;
|
|
252
|
+
webFetchProvider?: string | undefined;
|
|
253
|
+
webFetchApiKey?: string | undefined;
|
|
254
|
+
webFetchBaseUrl?: string | undefined;
|
|
255
|
+
webSearchProviderMode?: string | undefined;
|
|
256
|
+
webSearchPricingJson?: string | undefined;
|
|
257
|
+
webSearchRequestTimeoutMs: number;
|
|
234
258
|
jevApiKey?: string | undefined;
|
|
235
259
|
jevBaseUrl: string;
|
|
236
260
|
jevModel: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ export * from "./domain/session-connection-accounts.js";
|
|
|
7
7
|
export * from "./domain/organization-integration-catalog.js";
|
|
8
8
|
export * from "./domain/knowledge.js";
|
|
9
9
|
export * from "./domain/knowledge-search.js";
|
|
10
|
+
export * from "./domain/voice-input-billing.js";
|
|
11
|
+
export * from "./domain/web-search-billing.js";
|
|
12
|
+
export * from "./domain/realtime-voice-billing.js";
|
|
10
13
|
export * from "./dependencies.js";
|
|
11
14
|
export * from "./workflow-wake-contract.js";
|
|
12
15
|
export * from "./user-presence.js";
|