@vorim/sdk 4.1.1 → 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 +16 -0
- package/dist/{_commerce-core-Dyr_dHVP.d.ts → _commerce-core-BIqTJ7Om.d.ts} +1 -1
- package/dist/{_commerce-core-wY2jC6rC.d.cts → _commerce-core-BQbISpWe.d.cts} +1 -1
- package/dist/index.cjs +85 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -3
- package/dist/index.d.ts +38 -3
- package/dist/index.js +84 -4
- package/dist/index.js.map +1 -1
- package/dist/integrations/amazon.d.cts +2 -2
- package/dist/integrations/amazon.d.ts +2 -2
- package/dist/integrations/anthropic.d.cts +1 -1
- package/dist/integrations/anthropic.d.ts +1 -1
- package/dist/integrations/ap2.d.cts +1 -1
- package/dist/integrations/ap2.d.ts +1 -1
- package/dist/integrations/aws-iam.d.cts +1 -1
- package/dist/integrations/aws-iam.d.ts +1 -1
- package/dist/integrations/bank-rails.d.cts +1 -1
- package/dist/integrations/bank-rails.d.ts +1 -1
- package/dist/integrations/circle.d.cts +1 -1
- package/dist/integrations/circle.d.ts +1 -1
- package/dist/integrations/cloudflare.d.cts +1 -1
- package/dist/integrations/cloudflare.d.ts +1 -1
- package/dist/integrations/coinbase-cdp.d.cts +1 -1
- package/dist/integrations/coinbase-cdp.d.ts +1 -1
- package/dist/integrations/commerce-agents.d.cts +1 -1
- package/dist/integrations/commerce-agents.d.ts +1 -1
- package/dist/integrations/crewai.d.cts +1 -1
- package/dist/integrations/crewai.d.ts +1 -1
- package/dist/integrations/delivery.d.cts +2 -2
- package/dist/integrations/delivery.d.ts +2 -2
- package/dist/integrations/ebay.d.cts +2 -2
- package/dist/integrations/ebay.d.ts +2 -2
- package/dist/integrations/entra.d.cts +1 -1
- package/dist/integrations/entra.d.ts +1 -1
- package/dist/integrations/etsy.d.cts +2 -2
- package/dist/integrations/etsy.d.ts +2 -2
- 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/fhir.d.cts +1 -1
- package/dist/integrations/fhir.d.ts +1 -1
- package/dist/integrations/google-merchant.d.cts +2 -2
- package/dist/integrations/google-merchant.d.ts +2 -2
- package/dist/integrations/grok.cjs +9 -3
- package/dist/integrations/grok.cjs.map +1 -1
- package/dist/integrations/grok.d.cts +1 -1
- package/dist/integrations/grok.d.ts +1 -1
- package/dist/integrations/grok.js +9 -3
- package/dist/integrations/grok.js.map +1 -1
- package/dist/integrations/guidewire.d.cts +1 -1
- package/dist/integrations/guidewire.d.ts +1 -1
- package/dist/integrations/hermes.d.cts +1 -1
- package/dist/integrations/hermes.d.ts +1 -1
- package/dist/integrations/jira.d.cts +1 -1
- package/dist/integrations/jira.d.ts +1 -1
- package/dist/integrations/langchain.cjs +26 -7
- package/dist/integrations/langchain.cjs.map +1 -1
- package/dist/integrations/langchain.d.cts +1 -1
- package/dist/integrations/langchain.d.ts +1 -1
- package/dist/integrations/langchain.js +26 -7
- package/dist/integrations/langchain.js.map +1 -1
- package/dist/integrations/langgraph.d.cts +1 -1
- package/dist/integrations/langgraph.d.ts +1 -1
- package/dist/integrations/legal.d.cts +1 -1
- package/dist/integrations/legal.d.ts +1 -1
- package/dist/integrations/life-sciences.d.cts +1 -1
- package/dist/integrations/life-sciences.d.ts +1 -1
- package/dist/integrations/linear.d.cts +1 -1
- package/dist/integrations/linear.d.ts +1 -1
- package/dist/integrations/lithic.d.cts +1 -1
- package/dist/integrations/lithic.d.ts +1 -1
- package/dist/integrations/llamaindex.d.cts +1 -1
- package/dist/integrations/llamaindex.d.ts +1 -1
- package/dist/integrations/marqeta.d.cts +1 -1
- package/dist/integrations/marqeta.d.ts +1 -1
- package/dist/integrations/meta.d.cts +2 -2
- package/dist/integrations/meta.d.ts +2 -2
- 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/modern-treasury.d.cts +1 -1
- package/dist/integrations/modern-treasury.d.ts +1 -1
- package/dist/integrations/muse.cjs +9 -3
- package/dist/integrations/muse.cjs.map +1 -1
- package/dist/integrations/muse.d.cts +1 -1
- package/dist/integrations/muse.d.ts +1 -1
- package/dist/integrations/muse.js +9 -3
- package/dist/integrations/muse.js.map +1 -1
- package/dist/integrations/nekuda.d.cts +1 -1
- package/dist/integrations/nekuda.d.ts +1 -1
- package/dist/integrations/okta.d.cts +1 -1
- package/dist/integrations/okta.d.ts +1 -1
- package/dist/integrations/openai.cjs +9 -3
- package/dist/integrations/openai.cjs.map +1 -1
- package/dist/integrations/openai.d.cts +11 -1
- package/dist/integrations/openai.d.ts +11 -1
- 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.d.cts +1 -1
- package/dist/integrations/openrouter.d.ts +1 -1
- package/dist/integrations/openrouter.js +9 -3
- package/dist/integrations/openrouter.js.map +1 -1
- package/dist/integrations/paypal-agent.d.cts +1 -1
- package/dist/integrations/paypal-agent.d.ts +1 -1
- package/dist/integrations/perplexity.cjs +9 -3
- package/dist/integrations/perplexity.cjs.map +1 -1
- package/dist/integrations/perplexity.d.cts +1 -1
- package/dist/integrations/perplexity.d.ts +1 -1
- package/dist/integrations/perplexity.js +9 -3
- package/dist/integrations/perplexity.js.map +1 -1
- package/dist/integrations/plaid.d.cts +1 -1
- package/dist/integrations/plaid.d.ts +1 -1
- package/dist/integrations/ramp.d.cts +1 -1
- package/dist/integrations/ramp.d.ts +1 -1
- package/dist/integrations/shopify.d.cts +1 -1
- package/dist/integrations/shopify.d.ts +1 -1
- package/dist/integrations/siem.d.cts +1 -1
- package/dist/integrations/siem.d.ts +1 -1
- package/dist/integrations/skyfire.d.cts +1 -1
- package/dist/integrations/skyfire.d.ts +1 -1
- package/dist/integrations/social-ads.d.cts +2 -2
- package/dist/integrations/social-ads.d.ts +2 -2
- package/dist/integrations/stripe-acp.d.cts +1 -1
- package/dist/integrations/stripe-acp.d.ts +1 -1
- package/dist/integrations/stripe-issuing.d.cts +1 -1
- package/dist/integrations/stripe-issuing.d.ts +1 -1
- package/dist/integrations/tiktok-shop.d.cts +2 -2
- package/dist/integrations/tiktok-shop.d.ts +2 -2
- package/dist/integrations/truanon.d.cts +1 -1
- package/dist/integrations/truanon.d.ts +1 -1
- package/dist/integrations/typesafe.d.cts +1 -1
- package/dist/integrations/typesafe.d.ts +1 -1
- package/dist/integrations/ucp.d.cts +1 -1
- package/dist/integrations/ucp.d.ts +1 -1
- package/dist/integrations/vercel-ai.d.cts +1 -1
- package/dist/integrations/vercel-ai.d.ts +1 -1
- package/dist/integrations/walmart.d.cts +2 -2
- package/dist/integrations/walmart.d.ts +2 -2
- package/dist/integrations/x402.d.cts +1 -1
- package/dist/integrations/x402.d.ts +1 -1
- package/dist/{types-DphtTyIC.d.cts → types-DwPEBj7p.d.cts} +56 -1
- package/dist/{types-DphtTyIC.d.ts → types-DwPEBj7p.d.ts} +56 -1
- package/package.json +21 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { VorimToolRegistry, VorimOpenAIConfig } from './openai.cjs';
|
|
2
|
+
export { VorimToolDefinition } from './openai.cjs';
|
|
3
|
+
import '../types-DwPEBj7p.cjs';
|
|
4
|
+
import '../index.cjs';
|
|
5
|
+
import '@vorim/shared-types';
|
|
6
|
+
import '../httpSignatures.cjs';
|
|
7
|
+
import '../_runtime-gate-DOJUKJBu.cjs';
|
|
8
|
+
|
|
9
|
+
interface EuProviderPreset {
|
|
10
|
+
/** Display name. */
|
|
11
|
+
name: string;
|
|
12
|
+
/** OpenAI-compatible base URL. */
|
|
13
|
+
baseURL: string;
|
|
14
|
+
/** Where the provider says inference runs (its wording, summarised). */
|
|
15
|
+
residency: string;
|
|
16
|
+
/** A model id that supported tool calling there on 2026-10-29. Config, not a constant. */
|
|
17
|
+
exampleModel: string;
|
|
18
|
+
/** Known quirks a caller should respect. */
|
|
19
|
+
notes?: string;
|
|
20
|
+
}
|
|
21
|
+
declare const EU_PROVIDERS: {
|
|
22
|
+
readonly scaleway: {
|
|
23
|
+
readonly name: "Scaleway Generative APIs";
|
|
24
|
+
readonly baseURL: "https://api.scaleway.ai/v1";
|
|
25
|
+
readonly residency: "Paris, France (OPCORE data centre); Scaleway says serverless models stay hosted in Europe";
|
|
26
|
+
readonly exampleModel: "mistral-small-3.2-24b-instruct-2506";
|
|
27
|
+
readonly notes: "All Scaleway chat models support function calling. The Responses API web/file search runs on Scaleway and is not gated.";
|
|
28
|
+
};
|
|
29
|
+
readonly ovhcloud: {
|
|
30
|
+
readonly name: "OVHcloud AI Endpoints";
|
|
31
|
+
readonly baseURL: "https://oai.endpoints.kepler.ai.cloud.ovh.net/v1";
|
|
32
|
+
readonly residency: "Hosted and run in the European Union; zero retention apart from billing data";
|
|
33
|
+
readonly exampleModel: "gpt-oss-120b";
|
|
34
|
+
readonly notes: "parallel_tool_calls: false is not supported. Tool support is per model; check the catalogue.";
|
|
35
|
+
};
|
|
36
|
+
readonly ionos: {
|
|
37
|
+
readonly name: "IONOS AI Model Hub";
|
|
38
|
+
readonly baseURL: "https://openai.inference.de-txl.ionos.com/v1";
|
|
39
|
+
readonly residency: "Data centres in Germany; prompts and outputs processed there and nowhere else, not logged";
|
|
40
|
+
readonly exampleModel: "Qwen/Qwen3.8-27B";
|
|
41
|
+
};
|
|
42
|
+
readonly stackit: {
|
|
43
|
+
readonly name: "STACKIT AI Model Serving";
|
|
44
|
+
readonly baseURL: "https://api.openai-compat.model-serving.eu01.onstackit.cloud/v1";
|
|
45
|
+
readonly residency: "Region EU01, described as data-sovereign (country not stated in the docs read)";
|
|
46
|
+
readonly exampleModel: "openai/gpt-oss-120b";
|
|
47
|
+
readonly notes: "Do not send \"tools\": [] (a Llama model invents a call); the loop omits the key when no tools are registered.";
|
|
48
|
+
};
|
|
49
|
+
readonly nebius: {
|
|
50
|
+
readonly name: "Nebius Token Factory";
|
|
51
|
+
readonly baseURL: "https://api.tokenfactory.nebius.com/v1";
|
|
52
|
+
readonly residency: "EU or US data centres; no EU-only endpoint found";
|
|
53
|
+
readonly exampleModel: "openai/gpt-oss-120b";
|
|
54
|
+
readonly notes: "Current model list not confirmed; check GET /v1/models. Zero retention is opt-in.";
|
|
55
|
+
};
|
|
56
|
+
readonly huggingface: {
|
|
57
|
+
readonly name: "Hugging Face Inference Providers";
|
|
58
|
+
readonly baseURL: "https://router.huggingface.co/v1";
|
|
59
|
+
readonly residency: "A router to third-party providers, many outside the EU; pin an EU host with a model suffix such as :ovhcloud or :scaleway";
|
|
60
|
+
readonly exampleModel: "openai/gpt-oss-120b:ovhcloud";
|
|
61
|
+
readonly notes: "Strict mode is not supported by every routed provider.";
|
|
62
|
+
};
|
|
63
|
+
readonly hcompany: {
|
|
64
|
+
readonly name: "H Company Models API (Holo)";
|
|
65
|
+
readonly baseURL: "https://api.hcompany.ai/v1";
|
|
66
|
+
readonly residency: "H runs isolated EU and US regions (EU is the default for the Agents API)";
|
|
67
|
+
readonly exampleModel: "holo4-35b-a3b";
|
|
68
|
+
readonly notes: "holo3-122b-a10b has no tool calling.";
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
type EuProviderId = keyof typeof EU_PROVIDERS;
|
|
72
|
+
/** A registry whose audit events carry `framework: <provider>`. */
|
|
73
|
+
declare function createEuRegistry(provider: EuProviderId, config: Omit<VorimOpenAIConfig, 'framework'>): VorimToolRegistry;
|
|
74
|
+
interface OpenAICompatibleClient {
|
|
75
|
+
chat: {
|
|
76
|
+
completions: {
|
|
77
|
+
create: (args: Record<string, unknown>) => Promise<any>;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
interface RunEuAgentLoopConfig {
|
|
82
|
+
provider: EuProviderId;
|
|
83
|
+
/** An OpenAI-compatible client built with `baseURL: EU_PROVIDERS[provider].baseURL`. */
|
|
84
|
+
client: OpenAICompatibleClient;
|
|
85
|
+
registry: VorimToolRegistry;
|
|
86
|
+
userMessage: string;
|
|
87
|
+
/** @default EU_PROVIDERS[provider].exampleModel */
|
|
88
|
+
model?: string;
|
|
89
|
+
systemPrompt?: string;
|
|
90
|
+
/** @default 10 */
|
|
91
|
+
maxIterations?: number;
|
|
92
|
+
/** Forwarded when set (OVHcloud refuses `false`). */
|
|
93
|
+
parallelToolCalls?: boolean;
|
|
94
|
+
}
|
|
95
|
+
/** Run an OpenAI-shaped tool loop on a European host; every custom tool call is gated and signed first. */
|
|
96
|
+
declare function runEuAgentLoop(config: RunEuAgentLoopConfig): Promise<string>;
|
|
97
|
+
/** H Company Agents API hosts. EU is the default region. */
|
|
98
|
+
declare const HCOMPANY_AGENTS_EU_URL = "https://agp.eu.hcompany.ai/api/v2";
|
|
99
|
+
declare const HCOMPANY_AGENTS_US_URL = "https://agp.hcompany.ai/api/v2";
|
|
100
|
+
/** One entry of `data.pending_tool_calls` on an `awaiting_tool_results` state change. */
|
|
101
|
+
interface HCompanyPendingToolCall {
|
|
102
|
+
id: string;
|
|
103
|
+
tool_name: string;
|
|
104
|
+
args: unknown;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A body for `POST /sessions/{id}/tool_results`. The shape follows H Company's
|
|
108
|
+
* custom-tools doc (`{kind, tool_req, result}`) with the pending call echoed as
|
|
109
|
+
* `tool_req`; confirm against your account before relying on it.
|
|
110
|
+
*/
|
|
111
|
+
interface HCompanyToolResult {
|
|
112
|
+
kind: 'tool_result';
|
|
113
|
+
tool_req: HCompanyPendingToolCall;
|
|
114
|
+
result: string;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Gate + sign H Company custom tool calls. Calls to tools the registry does not
|
|
118
|
+
* hold are skipped (answer them yourself); denied calls come back as a result
|
|
119
|
+
* carrying the permission error, so the agent can carry on without the action.
|
|
120
|
+
*/
|
|
121
|
+
declare function executeHCompanyToolCalls(registry: VorimToolRegistry, pending: HCompanyPendingToolCall[] | null | undefined): Promise<HCompanyToolResult[]>;
|
|
122
|
+
|
|
123
|
+
export { EU_PROVIDERS, type EuProviderId, type EuProviderPreset, HCOMPANY_AGENTS_EU_URL, HCOMPANY_AGENTS_US_URL, type HCompanyPendingToolCall, type HCompanyToolResult, type RunEuAgentLoopConfig, VorimToolRegistry, createEuRegistry, executeHCompanyToolCalls, runEuAgentLoop };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { VorimToolRegistry, VorimOpenAIConfig } from './openai.js';
|
|
2
|
+
export { VorimToolDefinition } from './openai.js';
|
|
3
|
+
import '../types-DwPEBj7p.js';
|
|
4
|
+
import '../index.js';
|
|
5
|
+
import '@vorim/shared-types';
|
|
6
|
+
import '../httpSignatures.js';
|
|
7
|
+
import '../_runtime-gate-DOJUKJBu.js';
|
|
8
|
+
|
|
9
|
+
interface EuProviderPreset {
|
|
10
|
+
/** Display name. */
|
|
11
|
+
name: string;
|
|
12
|
+
/** OpenAI-compatible base URL. */
|
|
13
|
+
baseURL: string;
|
|
14
|
+
/** Where the provider says inference runs (its wording, summarised). */
|
|
15
|
+
residency: string;
|
|
16
|
+
/** A model id that supported tool calling there on 2026-10-29. Config, not a constant. */
|
|
17
|
+
exampleModel: string;
|
|
18
|
+
/** Known quirks a caller should respect. */
|
|
19
|
+
notes?: string;
|
|
20
|
+
}
|
|
21
|
+
declare const EU_PROVIDERS: {
|
|
22
|
+
readonly scaleway: {
|
|
23
|
+
readonly name: "Scaleway Generative APIs";
|
|
24
|
+
readonly baseURL: "https://api.scaleway.ai/v1";
|
|
25
|
+
readonly residency: "Paris, France (OPCORE data centre); Scaleway says serverless models stay hosted in Europe";
|
|
26
|
+
readonly exampleModel: "mistral-small-3.2-24b-instruct-2506";
|
|
27
|
+
readonly notes: "All Scaleway chat models support function calling. The Responses API web/file search runs on Scaleway and is not gated.";
|
|
28
|
+
};
|
|
29
|
+
readonly ovhcloud: {
|
|
30
|
+
readonly name: "OVHcloud AI Endpoints";
|
|
31
|
+
readonly baseURL: "https://oai.endpoints.kepler.ai.cloud.ovh.net/v1";
|
|
32
|
+
readonly residency: "Hosted and run in the European Union; zero retention apart from billing data";
|
|
33
|
+
readonly exampleModel: "gpt-oss-120b";
|
|
34
|
+
readonly notes: "parallel_tool_calls: false is not supported. Tool support is per model; check the catalogue.";
|
|
35
|
+
};
|
|
36
|
+
readonly ionos: {
|
|
37
|
+
readonly name: "IONOS AI Model Hub";
|
|
38
|
+
readonly baseURL: "https://openai.inference.de-txl.ionos.com/v1";
|
|
39
|
+
readonly residency: "Data centres in Germany; prompts and outputs processed there and nowhere else, not logged";
|
|
40
|
+
readonly exampleModel: "Qwen/Qwen3.8-27B";
|
|
41
|
+
};
|
|
42
|
+
readonly stackit: {
|
|
43
|
+
readonly name: "STACKIT AI Model Serving";
|
|
44
|
+
readonly baseURL: "https://api.openai-compat.model-serving.eu01.onstackit.cloud/v1";
|
|
45
|
+
readonly residency: "Region EU01, described as data-sovereign (country not stated in the docs read)";
|
|
46
|
+
readonly exampleModel: "openai/gpt-oss-120b";
|
|
47
|
+
readonly notes: "Do not send \"tools\": [] (a Llama model invents a call); the loop omits the key when no tools are registered.";
|
|
48
|
+
};
|
|
49
|
+
readonly nebius: {
|
|
50
|
+
readonly name: "Nebius Token Factory";
|
|
51
|
+
readonly baseURL: "https://api.tokenfactory.nebius.com/v1";
|
|
52
|
+
readonly residency: "EU or US data centres; no EU-only endpoint found";
|
|
53
|
+
readonly exampleModel: "openai/gpt-oss-120b";
|
|
54
|
+
readonly notes: "Current model list not confirmed; check GET /v1/models. Zero retention is opt-in.";
|
|
55
|
+
};
|
|
56
|
+
readonly huggingface: {
|
|
57
|
+
readonly name: "Hugging Face Inference Providers";
|
|
58
|
+
readonly baseURL: "https://router.huggingface.co/v1";
|
|
59
|
+
readonly residency: "A router to third-party providers, many outside the EU; pin an EU host with a model suffix such as :ovhcloud or :scaleway";
|
|
60
|
+
readonly exampleModel: "openai/gpt-oss-120b:ovhcloud";
|
|
61
|
+
readonly notes: "Strict mode is not supported by every routed provider.";
|
|
62
|
+
};
|
|
63
|
+
readonly hcompany: {
|
|
64
|
+
readonly name: "H Company Models API (Holo)";
|
|
65
|
+
readonly baseURL: "https://api.hcompany.ai/v1";
|
|
66
|
+
readonly residency: "H runs isolated EU and US regions (EU is the default for the Agents API)";
|
|
67
|
+
readonly exampleModel: "holo4-35b-a3b";
|
|
68
|
+
readonly notes: "holo3-122b-a10b has no tool calling.";
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
type EuProviderId = keyof typeof EU_PROVIDERS;
|
|
72
|
+
/** A registry whose audit events carry `framework: <provider>`. */
|
|
73
|
+
declare function createEuRegistry(provider: EuProviderId, config: Omit<VorimOpenAIConfig, 'framework'>): VorimToolRegistry;
|
|
74
|
+
interface OpenAICompatibleClient {
|
|
75
|
+
chat: {
|
|
76
|
+
completions: {
|
|
77
|
+
create: (args: Record<string, unknown>) => Promise<any>;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
interface RunEuAgentLoopConfig {
|
|
82
|
+
provider: EuProviderId;
|
|
83
|
+
/** An OpenAI-compatible client built with `baseURL: EU_PROVIDERS[provider].baseURL`. */
|
|
84
|
+
client: OpenAICompatibleClient;
|
|
85
|
+
registry: VorimToolRegistry;
|
|
86
|
+
userMessage: string;
|
|
87
|
+
/** @default EU_PROVIDERS[provider].exampleModel */
|
|
88
|
+
model?: string;
|
|
89
|
+
systemPrompt?: string;
|
|
90
|
+
/** @default 10 */
|
|
91
|
+
maxIterations?: number;
|
|
92
|
+
/** Forwarded when set (OVHcloud refuses `false`). */
|
|
93
|
+
parallelToolCalls?: boolean;
|
|
94
|
+
}
|
|
95
|
+
/** Run an OpenAI-shaped tool loop on a European host; every custom tool call is gated and signed first. */
|
|
96
|
+
declare function runEuAgentLoop(config: RunEuAgentLoopConfig): Promise<string>;
|
|
97
|
+
/** H Company Agents API hosts. EU is the default region. */
|
|
98
|
+
declare const HCOMPANY_AGENTS_EU_URL = "https://agp.eu.hcompany.ai/api/v2";
|
|
99
|
+
declare const HCOMPANY_AGENTS_US_URL = "https://agp.hcompany.ai/api/v2";
|
|
100
|
+
/** One entry of `data.pending_tool_calls` on an `awaiting_tool_results` state change. */
|
|
101
|
+
interface HCompanyPendingToolCall {
|
|
102
|
+
id: string;
|
|
103
|
+
tool_name: string;
|
|
104
|
+
args: unknown;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A body for `POST /sessions/{id}/tool_results`. The shape follows H Company's
|
|
108
|
+
* custom-tools doc (`{kind, tool_req, result}`) with the pending call echoed as
|
|
109
|
+
* `tool_req`; confirm against your account before relying on it.
|
|
110
|
+
*/
|
|
111
|
+
interface HCompanyToolResult {
|
|
112
|
+
kind: 'tool_result';
|
|
113
|
+
tool_req: HCompanyPendingToolCall;
|
|
114
|
+
result: string;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Gate + sign H Company custom tool calls. Calls to tools the registry does not
|
|
118
|
+
* hold are skipped (answer them yourself); denied calls come back as a result
|
|
119
|
+
* carrying the permission error, so the agent can carry on without the action.
|
|
120
|
+
*/
|
|
121
|
+
declare function executeHCompanyToolCalls(registry: VorimToolRegistry, pending: HCompanyPendingToolCall[] | null | undefined): Promise<HCompanyToolResult[]>;
|
|
122
|
+
|
|
123
|
+
export { EU_PROVIDERS, type EuProviderId, type EuProviderPreset, HCOMPANY_AGENTS_EU_URL, HCOMPANY_AGENTS_US_URL, type HCompanyPendingToolCall, type HCompanyToolResult, type RunEuAgentLoopConfig, VorimToolRegistry, createEuRegistry, executeHCompanyToolCalls, runEuAgentLoop };
|
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
// src/integrations/_runtime-gate.ts
|
|
2
|
+
function isAllowVerdict(decision) {
|
|
3
|
+
return decision === "allow" || decision === "modify";
|
|
4
|
+
}
|
|
5
|
+
async function runtimeGate(vorim, agentId, actionTarget, scope, payload, opts = {}) {
|
|
6
|
+
const onEscalation = opts.onEscalation ?? "wait";
|
|
7
|
+
const onTransportFailure = opts.onTransportFailure ?? "deny";
|
|
8
|
+
const d = await vorim.beforeAction(
|
|
9
|
+
{ agentId, actionType: "tool_call", actionTarget, requiredScope: scope, payload },
|
|
10
|
+
{ throwOnDeny: false }
|
|
11
|
+
);
|
|
12
|
+
if (d.isFallback || d.decision === "fallback") {
|
|
13
|
+
if (onTransportFailure === "allow") {
|
|
14
|
+
return { allowed: true, reason: d.reason ?? "control plane unreachable (fail-open)", decisionId: d.decisionId || void 0 };
|
|
15
|
+
}
|
|
16
|
+
return { allowed: false, reason: d.reason ?? "control plane unreachable (failed closed)", decisionId: d.decisionId || void 0 };
|
|
17
|
+
}
|
|
18
|
+
if (d.decision !== "escalate") {
|
|
19
|
+
return { allowed: isAllowVerdict(d.decision), reason: d.reason, decisionId: d.decisionId || void 0 };
|
|
20
|
+
}
|
|
21
|
+
if (onEscalation === "allow") {
|
|
22
|
+
return { allowed: true, reason: d.reason ?? "escalated (auto-allowed)", decisionId: d.decisionId || void 0 };
|
|
23
|
+
}
|
|
24
|
+
if (onEscalation === "deny") {
|
|
25
|
+
return { allowed: false, reason: d.reason ?? "escalated (auto-denied \u2014 awaiting human)", decisionId: d.decisionId || void 0 };
|
|
26
|
+
}
|
|
27
|
+
if (!d.decisionId) {
|
|
28
|
+
return { allowed: false, reason: "escalated but no decisionId to poll", decisionId: void 0 };
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const resolved = await vorim.waitForDecisionResolution(d.decisionId, { timeoutMs: opts.escalationTimeoutMs });
|
|
32
|
+
return { allowed: isAllowVerdict(resolved.decision), reason: resolved.reason, decisionId: resolved.decisionId || d.decisionId };
|
|
33
|
+
} catch {
|
|
34
|
+
return { allowed: false, reason: "escalation not resolved before timeout", decisionId: d.decisionId };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// src/replay.ts
|
|
39
|
+
function jcsCanonicalise(value) {
|
|
40
|
+
if (value === null) return "null";
|
|
41
|
+
if (value === true) return "true";
|
|
42
|
+
if (value === false) return "false";
|
|
43
|
+
if (typeof value === "number") {
|
|
44
|
+
if (!Number.isFinite(value)) {
|
|
45
|
+
throw new Error("jcsCanonicalise: NaN and Infinity are not JCS-valid");
|
|
46
|
+
}
|
|
47
|
+
const abs = Math.abs(value);
|
|
48
|
+
if (value !== 0 && (abs >= 1e21 || abs < 1e-4 || Number.isInteger(value) && abs > 2 ** 53)) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
`jcsCanonicalise: numbers in the ranges where JS and Python formatting diverge (|x| >= 1e21, |x| < 1e-4, or integer |x| > 2^53) are not supported in signed metadata. Use a string instead of ${value}.`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
return value.toString();
|
|
54
|
+
}
|
|
55
|
+
if (typeof value === "string") {
|
|
56
|
+
return JSON.stringify(value);
|
|
57
|
+
}
|
|
58
|
+
if (Array.isArray(value)) {
|
|
59
|
+
return "[" + value.map(jcsCanonicalise).join(",") + "]";
|
|
60
|
+
}
|
|
61
|
+
if (typeof value === "object") {
|
|
62
|
+
const obj = value;
|
|
63
|
+
const keys = Object.keys(obj).filter((k) => obj[k] !== void 0).sort();
|
|
64
|
+
const parts = keys.map((k) => JSON.stringify(k) + ":" + jcsCanonicalise(obj[k]));
|
|
65
|
+
return "{" + parts.join(",") + "}";
|
|
66
|
+
}
|
|
67
|
+
throw new Error(`jcsCanonicalise: unsupported value type: ${typeof value}`);
|
|
68
|
+
}
|
|
69
|
+
async function sha256Hex(input) {
|
|
70
|
+
const bytes = typeof input === "string" ? new TextEncoder().encode(input) : input;
|
|
71
|
+
const subtle = globalThis.crypto?.subtle;
|
|
72
|
+
if (subtle) {
|
|
73
|
+
const buf = await subtle.digest("SHA-256", bytes);
|
|
74
|
+
return Array.from(new Uint8Array(buf)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
75
|
+
}
|
|
76
|
+
const nodeCrypto = await import("crypto");
|
|
77
|
+
return nodeCrypto.createHash("sha256").update(bytes).digest("hex");
|
|
78
|
+
}
|
|
79
|
+
async function hashTool(tool) {
|
|
80
|
+
const normalised = {
|
|
81
|
+
name: tool.name,
|
|
82
|
+
description: tool.description ?? "",
|
|
83
|
+
schema: tool.schema ?? {}
|
|
84
|
+
};
|
|
85
|
+
const hex = await sha256Hex(jcsCanonicalise(normalised));
|
|
86
|
+
return `sha256:${hex}`;
|
|
87
|
+
}
|
|
88
|
+
async function hashToolCatalogue(tools) {
|
|
89
|
+
if (tools.length === 0) {
|
|
90
|
+
return `sha256:${await sha256Hex("[]")}`;
|
|
91
|
+
}
|
|
92
|
+
const perTool = await Promise.all(tools.map(hashTool));
|
|
93
|
+
perTool.sort();
|
|
94
|
+
const hex = await sha256Hex(perTool.join(""));
|
|
95
|
+
return `sha256:${hex}`;
|
|
96
|
+
}
|
|
97
|
+
async function hashSystemPrompt(prompt) {
|
|
98
|
+
const hex = await sha256Hex(prompt);
|
|
99
|
+
return `sha256:${hex}`;
|
|
100
|
+
}
|
|
101
|
+
async function prepareReplayContext(inputs) {
|
|
102
|
+
const ctx = {};
|
|
103
|
+
if (inputs.modelVersion) ctx.model_version = inputs.modelVersion;
|
|
104
|
+
if (inputs.tools) ctx.tool_catalogue_hash = await hashToolCatalogue(inputs.tools);
|
|
105
|
+
if (inputs.systemPrompt) ctx.system_prompt_hash = await hashSystemPrompt(inputs.systemPrompt);
|
|
106
|
+
return ctx;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// src/integrations/openai.ts
|
|
110
|
+
var VorimToolRegistry = class {
|
|
111
|
+
vorim;
|
|
112
|
+
agentId;
|
|
113
|
+
defaultPermission;
|
|
114
|
+
asyncAudit;
|
|
115
|
+
useRuntimeControl;
|
|
116
|
+
onEscalation;
|
|
117
|
+
escalationTimeoutMs;
|
|
118
|
+
onTransportFailure;
|
|
119
|
+
tools = /* @__PURE__ */ new Map();
|
|
120
|
+
replayInputs;
|
|
121
|
+
replayCache = null;
|
|
122
|
+
framework;
|
|
123
|
+
constructor(config) {
|
|
124
|
+
this.framework = config.framework ?? "openai";
|
|
125
|
+
this.vorim = config.vorim;
|
|
126
|
+
this.agentId = config.agentId;
|
|
127
|
+
this.defaultPermission = config.defaultPermission ?? "agent:execute";
|
|
128
|
+
this.asyncAudit = config.asyncAudit ?? true;
|
|
129
|
+
this.useRuntimeControl = config.useRuntimeControl ?? false;
|
|
130
|
+
this.onEscalation = config.onEscalation;
|
|
131
|
+
this.escalationTimeoutMs = config.escalationTimeoutMs;
|
|
132
|
+
this.onTransportFailure = config.onTransportFailure;
|
|
133
|
+
this.replayInputs = config.replay;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Gate a tool call. When useRuntimeControl is on, run the full runtime
|
|
137
|
+
* decision (beforeAction) and surface its decisionId for audit linkage;
|
|
138
|
+
* otherwise use the lightweight permission check.
|
|
139
|
+
*/
|
|
140
|
+
async gate(scope, actionTarget, payload) {
|
|
141
|
+
if (this.useRuntimeControl) {
|
|
142
|
+
try {
|
|
143
|
+
return await runtimeGate(this.vorim, this.agentId, actionTarget, scope, payload, {
|
|
144
|
+
onEscalation: this.onEscalation,
|
|
145
|
+
escalationTimeoutMs: this.escalationTimeoutMs,
|
|
146
|
+
onTransportFailure: this.onTransportFailure
|
|
147
|
+
});
|
|
148
|
+
} catch {
|
|
149
|
+
return { allowed: false, reason: "runtime gate unavailable (failed closed)" };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
try {
|
|
153
|
+
const { allowed, reason } = await this.vorim.check(this.agentId, scope);
|
|
154
|
+
return { allowed, reason };
|
|
155
|
+
} catch {
|
|
156
|
+
return { allowed: false, reason: "permission check unavailable (failed closed)" };
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
async getReplayContext() {
|
|
160
|
+
if (!this.replayInputs) return {};
|
|
161
|
+
if (!this.replayCache) {
|
|
162
|
+
const inputs = {
|
|
163
|
+
...this.replayInputs,
|
|
164
|
+
tools: this.replayInputs.tools ?? this.deriveCatalogue()
|
|
165
|
+
};
|
|
166
|
+
this.replayCache = prepareReplayContext(inputs);
|
|
167
|
+
}
|
|
168
|
+
return this.replayCache;
|
|
169
|
+
}
|
|
170
|
+
deriveCatalogue() {
|
|
171
|
+
return [...this.tools.values()].map((t) => ({
|
|
172
|
+
name: t.name,
|
|
173
|
+
description: t.description,
|
|
174
|
+
schema: t.parameters
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
/** Register a tool. Invalidates the cached tool-catalogue hash. */
|
|
178
|
+
add(definition) {
|
|
179
|
+
this.tools.set(definition.name, definition);
|
|
180
|
+
this.replayCache = null;
|
|
181
|
+
return this;
|
|
182
|
+
}
|
|
183
|
+
/** Register multiple tools. */
|
|
184
|
+
/** Whether a tool with this name is registered. */
|
|
185
|
+
has(name) {
|
|
186
|
+
return this.tools.has(name);
|
|
187
|
+
}
|
|
188
|
+
addAll(definitions) {
|
|
189
|
+
for (const def of definitions) this.add(def);
|
|
190
|
+
return this;
|
|
191
|
+
}
|
|
192
|
+
/** Convert registered tools to OpenAI's ChatCompletionTool format. */
|
|
193
|
+
toOpenAITools() {
|
|
194
|
+
return [...this.tools.values()].map((t) => ({
|
|
195
|
+
type: "function",
|
|
196
|
+
function: {
|
|
197
|
+
name: t.name,
|
|
198
|
+
description: t.description,
|
|
199
|
+
parameters: t.parameters,
|
|
200
|
+
...t.strict != null ? { strict: t.strict } : {}
|
|
201
|
+
}
|
|
202
|
+
}));
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Execute tool calls from an OpenAI chat completion response.
|
|
206
|
+
* Each call is checked against Vorim permissions and audited.
|
|
207
|
+
* Returns an array of tool messages ready to append to the conversation.
|
|
208
|
+
*/
|
|
209
|
+
async executeToolCalls(toolCalls) {
|
|
210
|
+
const results = await Promise.all(
|
|
211
|
+
toolCalls.map((tc) => this.executeSingleCall(tc))
|
|
212
|
+
);
|
|
213
|
+
return results;
|
|
214
|
+
}
|
|
215
|
+
async executeSingleCall(toolCall) {
|
|
216
|
+
const { id, function: fn } = toolCall;
|
|
217
|
+
const definition = this.tools.get(fn.name);
|
|
218
|
+
if (!definition) {
|
|
219
|
+
return {
|
|
220
|
+
role: "tool",
|
|
221
|
+
tool_call_id: id,
|
|
222
|
+
content: JSON.stringify({ error: `Unknown tool: ${fn.name}` })
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
const scope = definition.permission ?? this.defaultPermission;
|
|
226
|
+
let args;
|
|
227
|
+
try {
|
|
228
|
+
args = JSON.parse(fn.arguments);
|
|
229
|
+
} catch {
|
|
230
|
+
return {
|
|
231
|
+
role: "tool",
|
|
232
|
+
tool_call_id: id,
|
|
233
|
+
content: JSON.stringify({ error: `Invalid JSON arguments for ${fn.name}` })
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
const { allowed, reason, decisionId } = await this.gate(scope, fn.name, args);
|
|
237
|
+
const replayCtx = await this.getReplayContext();
|
|
238
|
+
if (!allowed) {
|
|
239
|
+
const event = {
|
|
240
|
+
agent_id: this.agentId,
|
|
241
|
+
event_type: "tool_call",
|
|
242
|
+
action: fn.name,
|
|
243
|
+
resource: truncate(fn.arguments, 500),
|
|
244
|
+
permission: scope,
|
|
245
|
+
result: "denied",
|
|
246
|
+
...decisionId ? { decision_id: decisionId } : {},
|
|
247
|
+
metadata: { reason, framework: this.framework },
|
|
248
|
+
...replayCtx
|
|
249
|
+
};
|
|
250
|
+
await this.emitAudit(event);
|
|
251
|
+
return {
|
|
252
|
+
role: "tool",
|
|
253
|
+
tool_call_id: id,
|
|
254
|
+
content: JSON.stringify({ error: `Permission denied: ${scope}${reason ? ` \u2014 ${reason}` : ""}` })
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
const start = Date.now();
|
|
258
|
+
try {
|
|
259
|
+
const result = await definition.execute(args);
|
|
260
|
+
const content = typeof result === "string" ? result : JSON.stringify(result);
|
|
261
|
+
const event = {
|
|
262
|
+
agent_id: this.agentId,
|
|
263
|
+
event_type: "tool_call",
|
|
264
|
+
action: fn.name,
|
|
265
|
+
resource: truncate(fn.arguments, 500),
|
|
266
|
+
permission: scope,
|
|
267
|
+
result: "success",
|
|
268
|
+
latency_ms: Date.now() - start,
|
|
269
|
+
...decisionId ? { decision_id: decisionId } : {},
|
|
270
|
+
metadata: { framework: this.framework },
|
|
271
|
+
...replayCtx
|
|
272
|
+
};
|
|
273
|
+
await this.emitAudit(event);
|
|
274
|
+
return { role: "tool", tool_call_id: id, content };
|
|
275
|
+
} catch (err) {
|
|
276
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
277
|
+
const event = {
|
|
278
|
+
agent_id: this.agentId,
|
|
279
|
+
event_type: "tool_call",
|
|
280
|
+
action: fn.name,
|
|
281
|
+
resource: truncate(fn.arguments, 500),
|
|
282
|
+
permission: scope,
|
|
283
|
+
result: "error",
|
|
284
|
+
latency_ms: Date.now() - start,
|
|
285
|
+
error_code: err instanceof Error ? err.name : "UNKNOWN",
|
|
286
|
+
...decisionId ? { decision_id: decisionId } : {},
|
|
287
|
+
metadata: { error: errMsg, framework: this.framework },
|
|
288
|
+
...replayCtx
|
|
289
|
+
};
|
|
290
|
+
await this.emitAudit(event);
|
|
291
|
+
return {
|
|
292
|
+
role: "tool",
|
|
293
|
+
tool_call_id: id,
|
|
294
|
+
content: JSON.stringify({ error: errMsg })
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
async emitAudit(event) {
|
|
299
|
+
if (this.asyncAudit) {
|
|
300
|
+
this.vorim.emit(event).catch(() => {
|
|
301
|
+
});
|
|
302
|
+
} else {
|
|
303
|
+
try {
|
|
304
|
+
await this.vorim.emit(event);
|
|
305
|
+
} catch {
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
function truncate(str, max) {
|
|
311
|
+
return str.length > max ? str.slice(0, max) + "\u2026" : str;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// src/integrations/eu-providers.ts
|
|
315
|
+
var EU_PROVIDERS = {
|
|
316
|
+
scaleway: {
|
|
317
|
+
name: "Scaleway Generative APIs",
|
|
318
|
+
baseURL: "https://api.scaleway.ai/v1",
|
|
319
|
+
residency: "Paris, France (OPCORE data centre); Scaleway says serverless models stay hosted in Europe",
|
|
320
|
+
exampleModel: "mistral-small-3.2-24b-instruct-2506",
|
|
321
|
+
notes: "All Scaleway chat models support function calling. The Responses API web/file search runs on Scaleway and is not gated."
|
|
322
|
+
},
|
|
323
|
+
ovhcloud: {
|
|
324
|
+
name: "OVHcloud AI Endpoints",
|
|
325
|
+
baseURL: "https://oai.endpoints.kepler.ai.cloud.ovh.net/v1",
|
|
326
|
+
residency: "Hosted and run in the European Union; zero retention apart from billing data",
|
|
327
|
+
exampleModel: "gpt-oss-120b",
|
|
328
|
+
notes: "parallel_tool_calls: false is not supported. Tool support is per model; check the catalogue."
|
|
329
|
+
},
|
|
330
|
+
ionos: {
|
|
331
|
+
name: "IONOS AI Model Hub",
|
|
332
|
+
baseURL: "https://openai.inference.de-txl.ionos.com/v1",
|
|
333
|
+
residency: "Data centres in Germany; prompts and outputs processed there and nowhere else, not logged",
|
|
334
|
+
exampleModel: "Qwen/Qwen3.8-27B"
|
|
335
|
+
},
|
|
336
|
+
stackit: {
|
|
337
|
+
name: "STACKIT AI Model Serving",
|
|
338
|
+
baseURL: "https://api.openai-compat.model-serving.eu01.onstackit.cloud/v1",
|
|
339
|
+
residency: "Region EU01, described as data-sovereign (country not stated in the docs read)",
|
|
340
|
+
exampleModel: "openai/gpt-oss-120b",
|
|
341
|
+
notes: 'Do not send "tools": [] (a Llama model invents a call); the loop omits the key when no tools are registered.'
|
|
342
|
+
},
|
|
343
|
+
nebius: {
|
|
344
|
+
name: "Nebius Token Factory",
|
|
345
|
+
baseURL: "https://api.tokenfactory.nebius.com/v1",
|
|
346
|
+
residency: "EU or US data centres; no EU-only endpoint found",
|
|
347
|
+
exampleModel: "openai/gpt-oss-120b",
|
|
348
|
+
notes: "Current model list not confirmed; check GET /v1/models. Zero retention is opt-in."
|
|
349
|
+
},
|
|
350
|
+
huggingface: {
|
|
351
|
+
name: "Hugging Face Inference Providers",
|
|
352
|
+
baseURL: "https://router.huggingface.co/v1",
|
|
353
|
+
residency: "A router to third-party providers, many outside the EU; pin an EU host with a model suffix such as :ovhcloud or :scaleway",
|
|
354
|
+
exampleModel: "openai/gpt-oss-120b:ovhcloud",
|
|
355
|
+
notes: "Strict mode is not supported by every routed provider."
|
|
356
|
+
},
|
|
357
|
+
hcompany: {
|
|
358
|
+
name: "H Company Models API (Holo)",
|
|
359
|
+
baseURL: "https://api.hcompany.ai/v1",
|
|
360
|
+
residency: "H runs isolated EU and US regions (EU is the default for the Agents API)",
|
|
361
|
+
exampleModel: "holo4-35b-a3b",
|
|
362
|
+
notes: "holo3-122b-a10b has no tool calling."
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
function createEuRegistry(provider, config) {
|
|
366
|
+
if (!(provider in EU_PROVIDERS)) throw new Error(`Unknown EU provider: ${String(provider)}`);
|
|
367
|
+
return new VorimToolRegistry({ ...config, framework: provider });
|
|
368
|
+
}
|
|
369
|
+
async function runEuAgentLoop(config) {
|
|
370
|
+
const preset = EU_PROVIDERS[config.provider];
|
|
371
|
+
if (!preset) throw new Error(`Unknown EU provider: ${String(config.provider)}`);
|
|
372
|
+
const { client, registry, userMessage, systemPrompt, maxIterations = 10 } = config;
|
|
373
|
+
const model = config.model ?? preset.exampleModel;
|
|
374
|
+
const messages = [];
|
|
375
|
+
if (systemPrompt) messages.push({ role: "system", content: systemPrompt });
|
|
376
|
+
messages.push({ role: "user", content: userMessage });
|
|
377
|
+
const tools = registry.toOpenAITools();
|
|
378
|
+
for (let i = 0; i < maxIterations; i++) {
|
|
379
|
+
const res = await client.chat.completions.create({
|
|
380
|
+
model,
|
|
381
|
+
messages,
|
|
382
|
+
...tools.length ? { tools } : {},
|
|
383
|
+
...config.parallelToolCalls != null ? { parallel_tool_calls: config.parallelToolCalls } : {}
|
|
384
|
+
});
|
|
385
|
+
const choice = res?.choices?.[0];
|
|
386
|
+
if (!choice) return "";
|
|
387
|
+
const msg = choice.message ?? {};
|
|
388
|
+
if (!msg.tool_calls?.length) return msg.content ?? "";
|
|
389
|
+
messages.push(msg);
|
|
390
|
+
const calls = msg.tool_calls.map((c) => ({
|
|
391
|
+
...c,
|
|
392
|
+
type: "function",
|
|
393
|
+
function: { ...c.function, arguments: typeof c.function?.arguments === "string" ? c.function.arguments : JSON.stringify(c.function?.arguments ?? {}) }
|
|
394
|
+
}));
|
|
395
|
+
messages.push(...await registry.executeToolCalls(calls));
|
|
396
|
+
}
|
|
397
|
+
return messages[messages.length - 1]?.content ?? "";
|
|
398
|
+
}
|
|
399
|
+
var HCOMPANY_AGENTS_EU_URL = "https://agp.eu.hcompany.ai/api/v2";
|
|
400
|
+
var HCOMPANY_AGENTS_US_URL = "https://agp.hcompany.ai/api/v2";
|
|
401
|
+
async function executeHCompanyToolCalls(registry, pending) {
|
|
402
|
+
const ours = (pending ?? []).filter((p) => registry.has(p.tool_name));
|
|
403
|
+
if (!ours.length) return [];
|
|
404
|
+
const results = await registry.executeToolCalls(ours.map((p) => ({
|
|
405
|
+
id: p.id,
|
|
406
|
+
type: "function",
|
|
407
|
+
function: { name: p.tool_name, arguments: typeof p.args === "string" ? p.args : JSON.stringify(p.args ?? {}) }
|
|
408
|
+
})));
|
|
409
|
+
return results.map((r) => ({ kind: "tool_result", tool_req: ours.find((p) => p.id === r.tool_call_id), result: r.content }));
|
|
410
|
+
}
|
|
411
|
+
export {
|
|
412
|
+
EU_PROVIDERS,
|
|
413
|
+
HCOMPANY_AGENTS_EU_URL,
|
|
414
|
+
HCOMPANY_AGENTS_US_URL,
|
|
415
|
+
VorimToolRegistry,
|
|
416
|
+
createEuRegistry,
|
|
417
|
+
executeHCompanyToolCalls,
|
|
418
|
+
runEuAgentLoop
|
|
419
|
+
};
|
|
420
|
+
//# sourceMappingURL=eu-providers.js.map
|