@vorim/sdk 4.2.0 → 4.3.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/CHANGELOG.md +8 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/integrations/eu-providers.cjs +463 -0
- package/dist/integrations/eu-providers.cjs.map +1 -0
- package/dist/integrations/eu-providers.d.cts +123 -0
- package/dist/integrations/eu-providers.d.ts +123 -0
- package/dist/integrations/eu-providers.js +420 -0
- package/dist/integrations/eu-providers.js.map +1 -0
- package/dist/integrations/grok.cjs +9 -3
- package/dist/integrations/grok.cjs.map +1 -1
- package/dist/integrations/grok.js +9 -3
- package/dist/integrations/grok.js.map +1 -1
- package/dist/integrations/langchain.cjs +26 -7
- package/dist/integrations/langchain.cjs.map +1 -1
- package/dist/integrations/langchain.js +26 -7
- package/dist/integrations/langchain.js.map +1 -1
- package/dist/integrations/mistral.cjs +487 -0
- package/dist/integrations/mistral.cjs.map +1 -0
- package/dist/integrations/mistral.d.cts +133 -0
- package/dist/integrations/mistral.d.ts +133 -0
- package/dist/integrations/mistral.js +439 -0
- package/dist/integrations/mistral.js.map +1 -0
- package/dist/integrations/muse.cjs +9 -3
- package/dist/integrations/muse.cjs.map +1 -1
- package/dist/integrations/muse.js +9 -3
- package/dist/integrations/muse.js.map +1 -1
- package/dist/integrations/openai.cjs +9 -3
- package/dist/integrations/openai.cjs.map +1 -1
- package/dist/integrations/openai.d.cts +10 -0
- package/dist/integrations/openai.d.ts +10 -0
- package/dist/integrations/openai.js +9 -3
- package/dist/integrations/openai.js.map +1 -1
- package/dist/integrations/openrouter.cjs +9 -3
- package/dist/integrations/openrouter.cjs.map +1 -1
- package/dist/integrations/openrouter.js +9 -3
- package/dist/integrations/openrouter.js.map +1 -1
- package/dist/integrations/perplexity.cjs +9 -3
- package/dist/integrations/perplexity.cjs.map +1 -1
- package/dist/integrations/perplexity.js +9 -3
- package/dist/integrations/perplexity.js.map +1 -1
- package/package.json +21 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { VorimSDK } from '../index.cjs';
|
|
2
|
+
import { P as PermissionScope } from '../types-DwPEBj7p.cjs';
|
|
3
|
+
import { VorimToolRegistry, VorimOpenAIConfig } from './openai.cjs';
|
|
4
|
+
export { VorimToolDefinition } from './openai.cjs';
|
|
5
|
+
import { E as EscalationPolicy, T as TransportFailurePolicy } from '../_runtime-gate-DOJUKJBu.cjs';
|
|
6
|
+
import '@vorim/shared-types';
|
|
7
|
+
import '../httpSignatures.cjs';
|
|
8
|
+
|
|
9
|
+
/** Global endpoint (Mistral does not commit to a location). */
|
|
10
|
+
declare const MISTRAL_BASE_URL = "https://api.mistral.ai/v1";
|
|
11
|
+
/** EU/EFTA-only inference. Function calling only; no Agents or connectors. */
|
|
12
|
+
declare const MISTRAL_EU_BASE_URL = "https://api.eu.mistral.ai/v1";
|
|
13
|
+
/** US-only inference. */
|
|
14
|
+
declare const MISTRAL_US_BASE_URL = "https://api.us.mistral.ai/v1";
|
|
15
|
+
/** General-purpose default (alias of Mistral Medium 3.5). Overridable. */
|
|
16
|
+
declare const DEFAULT_MISTRAL_MODEL = "mistral-medium-latest";
|
|
17
|
+
/** Small, cheap model (alias of Mistral Small 4). */
|
|
18
|
+
declare const MISTRAL_SMALL_MODEL = "mistral-small-latest";
|
|
19
|
+
/** Code model (alias of Codestral). */
|
|
20
|
+
declare const MISTRAL_CODE_MODEL = "codestral-latest";
|
|
21
|
+
/** A registry whose audit events say `framework: 'mistral'`. */
|
|
22
|
+
declare function createMistralRegistry(config: Omit<VorimOpenAIConfig, 'framework'> & {
|
|
23
|
+
framework?: string;
|
|
24
|
+
}): VorimToolRegistry;
|
|
25
|
+
/** A tool call as either client returns it. */
|
|
26
|
+
interface MistralToolCallLike {
|
|
27
|
+
id?: string | null;
|
|
28
|
+
type?: string | null;
|
|
29
|
+
function: {
|
|
30
|
+
name: string;
|
|
31
|
+
arguments: string | Record<string, unknown>;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** The OpenAI shape the registry consumes (arguments always a JSON string). */
|
|
35
|
+
interface NormalisedToolCall {
|
|
36
|
+
id: string;
|
|
37
|
+
type: 'function';
|
|
38
|
+
function: {
|
|
39
|
+
name: string;
|
|
40
|
+
arguments: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Normalise Mistral tool calls: stringify object arguments and give a missing
|
|
45
|
+
* id a stable placeholder so the result can still be matched to its call.
|
|
46
|
+
*/
|
|
47
|
+
declare function normaliseMistralToolCalls(calls: MistralToolCallLike[] | null | undefined): NormalisedToolCall[];
|
|
48
|
+
/** Official SDK: `mistral.chat.complete(...)` with camelCase fields. */
|
|
49
|
+
interface MistralSdkClient {
|
|
50
|
+
chat: {
|
|
51
|
+
complete: (args: Record<string, unknown>) => Promise<any>;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** OpenAI-compatible client pointed at a Mistral base URL. */
|
|
55
|
+
interface OpenAICompatibleClient {
|
|
56
|
+
chat: {
|
|
57
|
+
completions: {
|
|
58
|
+
create: (args: Record<string, unknown>) => Promise<any>;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
interface RunMistralAgentLoopConfig {
|
|
63
|
+
vorim: VorimSDK;
|
|
64
|
+
agentId: string;
|
|
65
|
+
/** `new Mistral({...})` from @mistralai/mistralai, or an OpenAI client with `baseURL: MISTRAL_BASE_URL`. */
|
|
66
|
+
mistral: MistralSdkClient | OpenAICompatibleClient;
|
|
67
|
+
registry: VorimToolRegistry;
|
|
68
|
+
userMessage: string;
|
|
69
|
+
/** @default DEFAULT_MISTRAL_MODEL */
|
|
70
|
+
model?: string;
|
|
71
|
+
systemPrompt?: string;
|
|
72
|
+
/** @default 10 */
|
|
73
|
+
maxIterations?: number;
|
|
74
|
+
/** Forwarded as `parallelToolCalls` / `parallel_tool_calls` when set. */
|
|
75
|
+
parallelToolCalls?: boolean;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Run a Mistral tool-calling loop. Every custom tool call is permission-checked
|
|
79
|
+
* (or decided by your runtime rules) and signed before it executes; denied
|
|
80
|
+
* calls go back to the model as an error result.
|
|
81
|
+
*/
|
|
82
|
+
declare function runMistralAgentLoop(config: RunMistralAgentLoopConfig): Promise<string>;
|
|
83
|
+
/** A `function.call` entry from a conversation's `outputs[]`. */
|
|
84
|
+
interface MistralFunctionCallEntry {
|
|
85
|
+
type: string;
|
|
86
|
+
tool_call_id?: string;
|
|
87
|
+
toolCallId?: string;
|
|
88
|
+
name: string;
|
|
89
|
+
arguments: string | Record<string, unknown>;
|
|
90
|
+
confirmation_status?: string | null;
|
|
91
|
+
confirmationStatus?: string | null;
|
|
92
|
+
}
|
|
93
|
+
/** A `function.result` entry to append to the conversation. */
|
|
94
|
+
interface MistralFunctionResultEntry {
|
|
95
|
+
type: 'function.result';
|
|
96
|
+
tool_call_id: string;
|
|
97
|
+
result: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Gate + sign the custom function calls in a conversation response and return
|
|
101
|
+
* the `function.result` entries to send back (`conversations.append`). Entries
|
|
102
|
+
* awaiting confirmation, and calls to tools the registry does not hold
|
|
103
|
+
* (built-in or connector tools run by Mistral), are skipped.
|
|
104
|
+
*/
|
|
105
|
+
declare function executeMistralFunctionCalls(registry: VorimToolRegistry, outputs: MistralFunctionCallEntry[] | null | undefined): Promise<MistralFunctionResultEntry[]>;
|
|
106
|
+
interface DecideConfirmationsConfig {
|
|
107
|
+
vorim: VorimSDK;
|
|
108
|
+
agentId: string;
|
|
109
|
+
/** Scope per tool name; others use defaultPermission. */
|
|
110
|
+
scopes?: Record<string, PermissionScope>;
|
|
111
|
+
/** @default 'agent:execute' */
|
|
112
|
+
defaultPermission?: PermissionScope;
|
|
113
|
+
/** Use runtime rules (allow / deny / escalate) instead of the permission check. @default false */
|
|
114
|
+
useRuntimeControl?: boolean;
|
|
115
|
+
onEscalation?: EscalationPolicy;
|
|
116
|
+
escalationTimeoutMs?: number;
|
|
117
|
+
onTransportFailure?: TransportFailurePolicy;
|
|
118
|
+
}
|
|
119
|
+
interface MistralToolConfirmation {
|
|
120
|
+
tool_call_id: string;
|
|
121
|
+
confirmation: 'allow' | 'deny';
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Answer Mistral's pending tool confirmations with Vorim. For each
|
|
125
|
+
* `function.call` with `confirmation_status: 'pending'` (a built-in, connector
|
|
126
|
+
* or deferred tool you listed in `requires_confirmation`), Vorim checks the
|
|
127
|
+
* agent's permission (or your runtime rules), records a signed audit event and
|
|
128
|
+
* returns `allow` or `deny`. Send the result as `tool_confirmations` when you
|
|
129
|
+
* resume the conversation. Any failure answers `deny` (fails closed).
|
|
130
|
+
*/
|
|
131
|
+
declare function decideMistralConfirmations(config: DecideConfirmationsConfig, outputs: MistralFunctionCallEntry[] | null | undefined): Promise<MistralToolConfirmation[]>;
|
|
132
|
+
|
|
133
|
+
export { DEFAULT_MISTRAL_MODEL, type DecideConfirmationsConfig, MISTRAL_BASE_URL, MISTRAL_CODE_MODEL, MISTRAL_EU_BASE_URL, MISTRAL_SMALL_MODEL, MISTRAL_US_BASE_URL, type MistralFunctionCallEntry, type MistralFunctionResultEntry, type MistralToolCallLike, type MistralToolConfirmation, type NormalisedToolCall, type RunMistralAgentLoopConfig, VorimToolRegistry, createMistralRegistry, decideMistralConfirmations, executeMistralFunctionCalls, normaliseMistralToolCalls, runMistralAgentLoop };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { VorimSDK } from '../index.js';
|
|
2
|
+
import { P as PermissionScope } from '../types-DwPEBj7p.js';
|
|
3
|
+
import { VorimToolRegistry, VorimOpenAIConfig } from './openai.js';
|
|
4
|
+
export { VorimToolDefinition } from './openai.js';
|
|
5
|
+
import { E as EscalationPolicy, T as TransportFailurePolicy } from '../_runtime-gate-DOJUKJBu.js';
|
|
6
|
+
import '@vorim/shared-types';
|
|
7
|
+
import '../httpSignatures.js';
|
|
8
|
+
|
|
9
|
+
/** Global endpoint (Mistral does not commit to a location). */
|
|
10
|
+
declare const MISTRAL_BASE_URL = "https://api.mistral.ai/v1";
|
|
11
|
+
/** EU/EFTA-only inference. Function calling only; no Agents or connectors. */
|
|
12
|
+
declare const MISTRAL_EU_BASE_URL = "https://api.eu.mistral.ai/v1";
|
|
13
|
+
/** US-only inference. */
|
|
14
|
+
declare const MISTRAL_US_BASE_URL = "https://api.us.mistral.ai/v1";
|
|
15
|
+
/** General-purpose default (alias of Mistral Medium 3.5). Overridable. */
|
|
16
|
+
declare const DEFAULT_MISTRAL_MODEL = "mistral-medium-latest";
|
|
17
|
+
/** Small, cheap model (alias of Mistral Small 4). */
|
|
18
|
+
declare const MISTRAL_SMALL_MODEL = "mistral-small-latest";
|
|
19
|
+
/** Code model (alias of Codestral). */
|
|
20
|
+
declare const MISTRAL_CODE_MODEL = "codestral-latest";
|
|
21
|
+
/** A registry whose audit events say `framework: 'mistral'`. */
|
|
22
|
+
declare function createMistralRegistry(config: Omit<VorimOpenAIConfig, 'framework'> & {
|
|
23
|
+
framework?: string;
|
|
24
|
+
}): VorimToolRegistry;
|
|
25
|
+
/** A tool call as either client returns it. */
|
|
26
|
+
interface MistralToolCallLike {
|
|
27
|
+
id?: string | null;
|
|
28
|
+
type?: string | null;
|
|
29
|
+
function: {
|
|
30
|
+
name: string;
|
|
31
|
+
arguments: string | Record<string, unknown>;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** The OpenAI shape the registry consumes (arguments always a JSON string). */
|
|
35
|
+
interface NormalisedToolCall {
|
|
36
|
+
id: string;
|
|
37
|
+
type: 'function';
|
|
38
|
+
function: {
|
|
39
|
+
name: string;
|
|
40
|
+
arguments: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Normalise Mistral tool calls: stringify object arguments and give a missing
|
|
45
|
+
* id a stable placeholder so the result can still be matched to its call.
|
|
46
|
+
*/
|
|
47
|
+
declare function normaliseMistralToolCalls(calls: MistralToolCallLike[] | null | undefined): NormalisedToolCall[];
|
|
48
|
+
/** Official SDK: `mistral.chat.complete(...)` with camelCase fields. */
|
|
49
|
+
interface MistralSdkClient {
|
|
50
|
+
chat: {
|
|
51
|
+
complete: (args: Record<string, unknown>) => Promise<any>;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** OpenAI-compatible client pointed at a Mistral base URL. */
|
|
55
|
+
interface OpenAICompatibleClient {
|
|
56
|
+
chat: {
|
|
57
|
+
completions: {
|
|
58
|
+
create: (args: Record<string, unknown>) => Promise<any>;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
interface RunMistralAgentLoopConfig {
|
|
63
|
+
vorim: VorimSDK;
|
|
64
|
+
agentId: string;
|
|
65
|
+
/** `new Mistral({...})` from @mistralai/mistralai, or an OpenAI client with `baseURL: MISTRAL_BASE_URL`. */
|
|
66
|
+
mistral: MistralSdkClient | OpenAICompatibleClient;
|
|
67
|
+
registry: VorimToolRegistry;
|
|
68
|
+
userMessage: string;
|
|
69
|
+
/** @default DEFAULT_MISTRAL_MODEL */
|
|
70
|
+
model?: string;
|
|
71
|
+
systemPrompt?: string;
|
|
72
|
+
/** @default 10 */
|
|
73
|
+
maxIterations?: number;
|
|
74
|
+
/** Forwarded as `parallelToolCalls` / `parallel_tool_calls` when set. */
|
|
75
|
+
parallelToolCalls?: boolean;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Run a Mistral tool-calling loop. Every custom tool call is permission-checked
|
|
79
|
+
* (or decided by your runtime rules) and signed before it executes; denied
|
|
80
|
+
* calls go back to the model as an error result.
|
|
81
|
+
*/
|
|
82
|
+
declare function runMistralAgentLoop(config: RunMistralAgentLoopConfig): Promise<string>;
|
|
83
|
+
/** A `function.call` entry from a conversation's `outputs[]`. */
|
|
84
|
+
interface MistralFunctionCallEntry {
|
|
85
|
+
type: string;
|
|
86
|
+
tool_call_id?: string;
|
|
87
|
+
toolCallId?: string;
|
|
88
|
+
name: string;
|
|
89
|
+
arguments: string | Record<string, unknown>;
|
|
90
|
+
confirmation_status?: string | null;
|
|
91
|
+
confirmationStatus?: string | null;
|
|
92
|
+
}
|
|
93
|
+
/** A `function.result` entry to append to the conversation. */
|
|
94
|
+
interface MistralFunctionResultEntry {
|
|
95
|
+
type: 'function.result';
|
|
96
|
+
tool_call_id: string;
|
|
97
|
+
result: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Gate + sign the custom function calls in a conversation response and return
|
|
101
|
+
* the `function.result` entries to send back (`conversations.append`). Entries
|
|
102
|
+
* awaiting confirmation, and calls to tools the registry does not hold
|
|
103
|
+
* (built-in or connector tools run by Mistral), are skipped.
|
|
104
|
+
*/
|
|
105
|
+
declare function executeMistralFunctionCalls(registry: VorimToolRegistry, outputs: MistralFunctionCallEntry[] | null | undefined): Promise<MistralFunctionResultEntry[]>;
|
|
106
|
+
interface DecideConfirmationsConfig {
|
|
107
|
+
vorim: VorimSDK;
|
|
108
|
+
agentId: string;
|
|
109
|
+
/** Scope per tool name; others use defaultPermission. */
|
|
110
|
+
scopes?: Record<string, PermissionScope>;
|
|
111
|
+
/** @default 'agent:execute' */
|
|
112
|
+
defaultPermission?: PermissionScope;
|
|
113
|
+
/** Use runtime rules (allow / deny / escalate) instead of the permission check. @default false */
|
|
114
|
+
useRuntimeControl?: boolean;
|
|
115
|
+
onEscalation?: EscalationPolicy;
|
|
116
|
+
escalationTimeoutMs?: number;
|
|
117
|
+
onTransportFailure?: TransportFailurePolicy;
|
|
118
|
+
}
|
|
119
|
+
interface MistralToolConfirmation {
|
|
120
|
+
tool_call_id: string;
|
|
121
|
+
confirmation: 'allow' | 'deny';
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Answer Mistral's pending tool confirmations with Vorim. For each
|
|
125
|
+
* `function.call` with `confirmation_status: 'pending'` (a built-in, connector
|
|
126
|
+
* or deferred tool you listed in `requires_confirmation`), Vorim checks the
|
|
127
|
+
* agent's permission (or your runtime rules), records a signed audit event and
|
|
128
|
+
* returns `allow` or `deny`. Send the result as `tool_confirmations` when you
|
|
129
|
+
* resume the conversation. Any failure answers `deny` (fails closed).
|
|
130
|
+
*/
|
|
131
|
+
declare function decideMistralConfirmations(config: DecideConfirmationsConfig, outputs: MistralFunctionCallEntry[] | null | undefined): Promise<MistralToolConfirmation[]>;
|
|
132
|
+
|
|
133
|
+
export { DEFAULT_MISTRAL_MODEL, type DecideConfirmationsConfig, MISTRAL_BASE_URL, MISTRAL_CODE_MODEL, MISTRAL_EU_BASE_URL, MISTRAL_SMALL_MODEL, MISTRAL_US_BASE_URL, type MistralFunctionCallEntry, type MistralFunctionResultEntry, type MistralToolCallLike, type MistralToolConfirmation, type NormalisedToolCall, type RunMistralAgentLoopConfig, VorimToolRegistry, createMistralRegistry, decideMistralConfirmations, executeMistralFunctionCalls, normaliseMistralToolCalls, runMistralAgentLoop };
|