gauss-ts 2.0.0 → 2.0.2

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/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { V as VectorChunk, D as Disposable, H as Handle, E as EvalScorerType, J as JsMessage, g as CostEstimate, a as Message, c as AgentResult } from './types-BayYAhZL.cjs';
2
2
  export { A as AgentOptions, h as Citation, C as CodeExecutionOptions, i as CodeExecutionResult, j as CoercionStrategy, G as GeneratedImageData, k as GroundingChunk, l as GroundingMetadata, I as ImageGenerationConfig, m as ImageGenerationResult, M as MemoryEntry, n as MemoryStats, o as MessageRole, P as PiiAction, f as ProviderCapabilities, e as ProviderOptions, d as ProviderType, R as RecallOptions, p as SearchResult, S as StreamCallback, T as ToolDef, b as ToolExecutor, q as detectProvider, r as resolveApiKey } from './types-BayYAhZL.cjs';
3
- import { A as AgentConfig, a as Agent } from './agent-DXZT4Hd-.cjs';
4
- export { b as AgentStream, M as McpClient, c as McpClientConfig, d as McpToolDef, e as McpToolResult, S as StreamEvent, T as TypedToolDef, f as createToolExecutor, g as gauss, i as isTypedTool, t as tool } from './agent-DXZT4Hd-.cjs';
3
+ import { A as AgentConfig, a as Agent } from './agent-U5pITdVk.cjs';
4
+ export { b as AgentStream, M as McpClient, c as McpClientConfig, d as McpToolDef, e as McpToolResult, S as StreamEvent, T as TypedToolDef, f as createToolExecutor, g as gauss, i as isTypedTool, t as tool } from './agent-U5pITdVk.cjs';
5
5
  export { BatchItem, availableRuntimes, batch, executeCode, generateImage } from './agent.cjs';
6
6
  export { M as Memory } from './memory-BGrAWNqI.cjs';
7
7
  export { VectorStore } from './rag.cjs';
@@ -12,6 +12,51 @@ export { A2aClient, A2aClientOptions, A2aMessage, A2aMessageRole, AgentCapabilit
12
12
  export { ToolExample, ToolRegistry, ToolRegistryEntry, ToolSearchResult, ToolValidator } from './tools.cjs';
13
13
  export { version } from 'gauss-napi';
14
14
 
15
+ /**
16
+ * Structured error hierarchy for Gauss SDK.
17
+ *
18
+ * All Gauss errors extend {@link GaussError} to enable type-safe catch blocks:
19
+ *
20
+ * ```ts
21
+ * try {
22
+ * await agent.run("hello");
23
+ * } catch (e) {
24
+ * if (e instanceof AgentDisposedError) { ... }
25
+ * if (e instanceof ProviderError) { ... }
26
+ * }
27
+ * ```
28
+ *
29
+ * @module errors
30
+ * @since 2.1.0
31
+ */
32
+ /** Base error for all Gauss SDK errors. Includes an error code for programmatic matching. */
33
+ declare class GaussError extends Error {
34
+ readonly code: string;
35
+ constructor(code: string, message: string);
36
+ }
37
+ /** Thrown when an operation is attempted on a destroyed Agent/Team/Graph. */
38
+ declare class DisposedError extends GaussError {
39
+ readonly resourceType: string;
40
+ readonly resourceName: string;
41
+ constructor(resourceType: string, resourceName: string);
42
+ }
43
+ /** Thrown when provider initialization or communication fails. */
44
+ declare class ProviderError extends GaussError {
45
+ readonly provider: string;
46
+ constructor(provider: string, message: string);
47
+ }
48
+ /** Thrown when tool execution fails. */
49
+ declare class ToolExecutionError extends GaussError {
50
+ readonly toolName: string;
51
+ readonly cause?: Error;
52
+ constructor(toolName: string, message: string, cause?: Error);
53
+ }
54
+ /** Thrown when configuration validation fails. */
55
+ declare class ValidationError extends GaussError {
56
+ readonly field?: string;
57
+ constructor(message: string, field?: string);
58
+ }
59
+
15
60
  /**
16
61
  * Model Constants — Single Source of Truth
17
62
  *
@@ -578,4 +623,4 @@ declare function tapAsync<T>(items: T[], fn: (item: T, index: number) => Promise
578
623
  */
579
624
  declare function compose<T>(...fns: PipeStep<T, T>[]): PipeStep<T, T>;
580
625
 
581
- export { ANTHROPIC_DEFAULT, ANTHROPIC_FAST, ANTHROPIC_PREMIUM, Agent, AgentConfig, AgentResult, AgentSpec, type AgentSpecData, type AgentToolSpec, ApprovalManager, CheckpointStore, CostEstimate, DEEPSEEK_DEFAULT, DEEPSEEK_REASONING, Disposable, type DocumentLoaderOptions, type EnterprisePresetOptions, EvalRunner, EvalScorerType, FIREWORKS_DEFAULT, GOOGLE_DEFAULT, GOOGLE_IMAGE, GOOGLE_PREMIUM, Handle, JsMessage, type JsonSchema, type LoadedDocument, MISTRAL_DEFAULT, Message, type ModelPricing, OPENAI_DEFAULT, OPENAI_FAST, OPENAI_IMAGE, OPENAI_REASONING, OPENROUTER_DEFAULT, PERPLEXITY_DEFAULT, PROVIDER_DEFAULTS, type PipeStep, type PromptTemplate, type RetryConfig, type SkillParam, SkillSpec, type SkillSpecData, type SkillStep, type StructuredConfig, type StructuredResult, TOGETHER_DEFAULT, Telemetry, type TextChunk, TextSplitter, type TextSplitterOptions, VectorChunk, XAI_DEFAULT, classify, clearPricing, codeReview, compose, countMessageTokens, countTokens, countTokensForModel, createCircuitBreaker, createFallbackProvider, createResilientAgent, createResilientProvider, defaultModel, discoverAgents, enterprisePreset, enterpriseRun, estimateCost, extract, filterAsync, getContextWindowSize, getPricing, loadJson, loadMarkdown, loadText, mapAsync, parseAgentConfig, parsePartialJson, pipe, reduceAsync, resolveEnv, retryable, setPricing, splitText, structured, summarize, tapAsync, template, translate, withRetry };
626
+ export { ANTHROPIC_DEFAULT, ANTHROPIC_FAST, ANTHROPIC_PREMIUM, Agent, AgentConfig, AgentResult, AgentSpec, type AgentSpecData, type AgentToolSpec, ApprovalManager, CheckpointStore, CostEstimate, DEEPSEEK_DEFAULT, DEEPSEEK_REASONING, Disposable, DisposedError, type DocumentLoaderOptions, type EnterprisePresetOptions, EvalRunner, EvalScorerType, FIREWORKS_DEFAULT, GOOGLE_DEFAULT, GOOGLE_IMAGE, GOOGLE_PREMIUM, GaussError, Handle, JsMessage, type JsonSchema, type LoadedDocument, MISTRAL_DEFAULT, Message, type ModelPricing, OPENAI_DEFAULT, OPENAI_FAST, OPENAI_IMAGE, OPENAI_REASONING, OPENROUTER_DEFAULT, PERPLEXITY_DEFAULT, PROVIDER_DEFAULTS, type PipeStep, type PromptTemplate, ProviderError, type RetryConfig, type SkillParam, SkillSpec, type SkillSpecData, type SkillStep, type StructuredConfig, type StructuredResult, TOGETHER_DEFAULT, Telemetry, type TextChunk, TextSplitter, type TextSplitterOptions, ToolExecutionError, ValidationError, VectorChunk, XAI_DEFAULT, classify, clearPricing, codeReview, compose, countMessageTokens, countTokens, countTokensForModel, createCircuitBreaker, createFallbackProvider, createResilientAgent, createResilientProvider, defaultModel, discoverAgents, enterprisePreset, enterpriseRun, estimateCost, extract, filterAsync, getContextWindowSize, getPricing, loadJson, loadMarkdown, loadText, mapAsync, parseAgentConfig, parsePartialJson, pipe, reduceAsync, resolveEnv, retryable, setPricing, splitText, structured, summarize, tapAsync, template, translate, withRetry };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { V as VectorChunk, D as Disposable, H as Handle, E as EvalScorerType, J as JsMessage, g as CostEstimate, a as Message, c as AgentResult } from './types-BayYAhZL.js';
2
2
  export { A as AgentOptions, h as Citation, C as CodeExecutionOptions, i as CodeExecutionResult, j as CoercionStrategy, G as GeneratedImageData, k as GroundingChunk, l as GroundingMetadata, I as ImageGenerationConfig, m as ImageGenerationResult, M as MemoryEntry, n as MemoryStats, o as MessageRole, P as PiiAction, f as ProviderCapabilities, e as ProviderOptions, d as ProviderType, R as RecallOptions, p as SearchResult, S as StreamCallback, T as ToolDef, b as ToolExecutor, q as detectProvider, r as resolveApiKey } from './types-BayYAhZL.js';
3
- import { A as AgentConfig, a as Agent } from './agent-nEZAfWFD.js';
4
- export { b as AgentStream, M as McpClient, c as McpClientConfig, d as McpToolDef, e as McpToolResult, S as StreamEvent, T as TypedToolDef, f as createToolExecutor, g as gauss, i as isTypedTool, t as tool } from './agent-nEZAfWFD.js';
3
+ import { A as AgentConfig, a as Agent } from './agent-Da25i24I.js';
4
+ export { b as AgentStream, M as McpClient, c as McpClientConfig, d as McpToolDef, e as McpToolResult, S as StreamEvent, T as TypedToolDef, f as createToolExecutor, g as gauss, i as isTypedTool, t as tool } from './agent-Da25i24I.js';
5
5
  export { BatchItem, availableRuntimes, batch, executeCode, generateImage } from './agent.js';
6
6
  export { M as Memory } from './memory-U2EleSW-.js';
7
7
  export { VectorStore } from './rag.js';
@@ -12,6 +12,51 @@ export { A2aClient, A2aClientOptions, A2aMessage, A2aMessageRole, AgentCapabilit
12
12
  export { ToolExample, ToolRegistry, ToolRegistryEntry, ToolSearchResult, ToolValidator } from './tools.js';
13
13
  export { version } from 'gauss-napi';
14
14
 
15
+ /**
16
+ * Structured error hierarchy for Gauss SDK.
17
+ *
18
+ * All Gauss errors extend {@link GaussError} to enable type-safe catch blocks:
19
+ *
20
+ * ```ts
21
+ * try {
22
+ * await agent.run("hello");
23
+ * } catch (e) {
24
+ * if (e instanceof AgentDisposedError) { ... }
25
+ * if (e instanceof ProviderError) { ... }
26
+ * }
27
+ * ```
28
+ *
29
+ * @module errors
30
+ * @since 2.1.0
31
+ */
32
+ /** Base error for all Gauss SDK errors. Includes an error code for programmatic matching. */
33
+ declare class GaussError extends Error {
34
+ readonly code: string;
35
+ constructor(code: string, message: string);
36
+ }
37
+ /** Thrown when an operation is attempted on a destroyed Agent/Team/Graph. */
38
+ declare class DisposedError extends GaussError {
39
+ readonly resourceType: string;
40
+ readonly resourceName: string;
41
+ constructor(resourceType: string, resourceName: string);
42
+ }
43
+ /** Thrown when provider initialization or communication fails. */
44
+ declare class ProviderError extends GaussError {
45
+ readonly provider: string;
46
+ constructor(provider: string, message: string);
47
+ }
48
+ /** Thrown when tool execution fails. */
49
+ declare class ToolExecutionError extends GaussError {
50
+ readonly toolName: string;
51
+ readonly cause?: Error;
52
+ constructor(toolName: string, message: string, cause?: Error);
53
+ }
54
+ /** Thrown when configuration validation fails. */
55
+ declare class ValidationError extends GaussError {
56
+ readonly field?: string;
57
+ constructor(message: string, field?: string);
58
+ }
59
+
15
60
  /**
16
61
  * Model Constants — Single Source of Truth
17
62
  *
@@ -578,4 +623,4 @@ declare function tapAsync<T>(items: T[], fn: (item: T, index: number) => Promise
578
623
  */
579
624
  declare function compose<T>(...fns: PipeStep<T, T>[]): PipeStep<T, T>;
580
625
 
581
- export { ANTHROPIC_DEFAULT, ANTHROPIC_FAST, ANTHROPIC_PREMIUM, Agent, AgentConfig, AgentResult, AgentSpec, type AgentSpecData, type AgentToolSpec, ApprovalManager, CheckpointStore, CostEstimate, DEEPSEEK_DEFAULT, DEEPSEEK_REASONING, Disposable, type DocumentLoaderOptions, type EnterprisePresetOptions, EvalRunner, EvalScorerType, FIREWORKS_DEFAULT, GOOGLE_DEFAULT, GOOGLE_IMAGE, GOOGLE_PREMIUM, Handle, JsMessage, type JsonSchema, type LoadedDocument, MISTRAL_DEFAULT, Message, type ModelPricing, OPENAI_DEFAULT, OPENAI_FAST, OPENAI_IMAGE, OPENAI_REASONING, OPENROUTER_DEFAULT, PERPLEXITY_DEFAULT, PROVIDER_DEFAULTS, type PipeStep, type PromptTemplate, type RetryConfig, type SkillParam, SkillSpec, type SkillSpecData, type SkillStep, type StructuredConfig, type StructuredResult, TOGETHER_DEFAULT, Telemetry, type TextChunk, TextSplitter, type TextSplitterOptions, VectorChunk, XAI_DEFAULT, classify, clearPricing, codeReview, compose, countMessageTokens, countTokens, countTokensForModel, createCircuitBreaker, createFallbackProvider, createResilientAgent, createResilientProvider, defaultModel, discoverAgents, enterprisePreset, enterpriseRun, estimateCost, extract, filterAsync, getContextWindowSize, getPricing, loadJson, loadMarkdown, loadText, mapAsync, parseAgentConfig, parsePartialJson, pipe, reduceAsync, resolveEnv, retryable, setPricing, splitText, structured, summarize, tapAsync, template, translate, withRetry };
626
+ export { ANTHROPIC_DEFAULT, ANTHROPIC_FAST, ANTHROPIC_PREMIUM, Agent, AgentConfig, AgentResult, AgentSpec, type AgentSpecData, type AgentToolSpec, ApprovalManager, CheckpointStore, CostEstimate, DEEPSEEK_DEFAULT, DEEPSEEK_REASONING, Disposable, DisposedError, type DocumentLoaderOptions, type EnterprisePresetOptions, EvalRunner, EvalScorerType, FIREWORKS_DEFAULT, GOOGLE_DEFAULT, GOOGLE_IMAGE, GOOGLE_PREMIUM, GaussError, Handle, JsMessage, type JsonSchema, type LoadedDocument, MISTRAL_DEFAULT, Message, type ModelPricing, OPENAI_DEFAULT, OPENAI_FAST, OPENAI_IMAGE, OPENAI_REASONING, OPENROUTER_DEFAULT, PERPLEXITY_DEFAULT, PROVIDER_DEFAULTS, type PipeStep, type PromptTemplate, ProviderError, type RetryConfig, type SkillParam, SkillSpec, type SkillSpecData, type SkillStep, type StructuredConfig, type StructuredResult, TOGETHER_DEFAULT, Telemetry, type TextChunk, TextSplitter, type TextSplitterOptions, ToolExecutionError, ValidationError, VectorChunk, XAI_DEFAULT, classify, clearPricing, codeReview, compose, countMessageTokens, countTokens, countTokensForModel, createCircuitBreaker, createFallbackProvider, createResilientAgent, createResilientProvider, defaultModel, discoverAgents, enterprisePreset, enterpriseRun, estimateCost, extract, filterAsync, getContextWindowSize, getPricing, loadJson, loadMarkdown, loadText, mapAsync, parseAgentConfig, parsePartialJson, pipe, reduceAsync, resolveEnv, retryable, setPricing, splitText, structured, summarize, tapAsync, template, translate, withRetry };
package/dist/index.js CHANGED
@@ -1,40 +1,40 @@
1
- var y="gpt-5.2",me="gpt-4.1",he="o4-mini",ge="gpt-image-1",Y="claude-sonnet-4-20250514",ye="claude-haiku-4-20250414",fe="claude-opus-4-20250414",$="gemini-2.5-flash",_e="gemini-2.5-pro",xe="gemini-2.0-flash",V="openai/gpt-5.2",W="deepseek-chat",Te="deepseek-reasoner",X="meta-llama/Llama-3.3-70B-Instruct-Turbo",Q="accounts/fireworks/models/llama-v3p1-70b-instruct",Z="mistral-large-latest",ee="sonar-pro",te="grok-3-beta",T={openai:y,anthropic:Y,google:$,openrouter:V,deepseek:W,groq:"llama-3.3-70b-versatile",ollama:"llama3.2",together:X,fireworks:Q,mistral:Z,perplexity:ee,xai:te};function ve(r){return T[r]??y}var be={openai:"OPENAI_API_KEY",anthropic:"ANTHROPIC_API_KEY",google:"GOOGLE_API_KEY",groq:"GROQ_API_KEY",deepseek:"DEEPSEEK_API_KEY",openrouter:"OPENROUTER_API_KEY",together:"TOGETHER_API_KEY",fireworks:"FIREWORKS_API_KEY",mistral:"MISTRAL_API_KEY",perplexity:"PERPLEXITY_API_KEY",xai:"XAI_API_KEY",ollama:""};function f(r){let e=be[r]??"";return e?(typeof process<"u"?process.env[e]:"")??"":""}function _(){let r=[{env:"OPENAI_API_KEY",provider:"openai"},{env:"ANTHROPIC_API_KEY",provider:"anthropic"},{env:"GOOGLE_API_KEY",provider:"google"},{env:"GROQ_API_KEY",provider:"groq"},{env:"DEEPSEEK_API_KEY",provider:"deepseek"},{env:"OPENROUTER_API_KEY",provider:"openrouter"},{env:"TOGETHER_API_KEY",provider:"together"},{env:"FIREWORKS_API_KEY",provider:"fireworks"},{env:"MISTRAL_API_KEY",provider:"mistral"},{env:"PERPLEXITY_API_KEY",provider:"perplexity"},{env:"XAI_API_KEY",provider:"xai"}];for(let{env:e,provider:t}of r)if(typeof process<"u"&&process.env[e])return{provider:t,model:T[t]}}import{create_provider as Pe,destroy_provider as Ee,agent_run as Re,agent_run_with_tool_executor as re,agent_stream_with_tool_executor as De,generate as Ae,generate_with_tools as Me,get_provider_capabilities as Ce}from"gauss-napi";import{agent_stream_with_tool_executor as ke}from"gauss-napi";function we(r){return{...r,citations:r.citations?.map(e=>({type:e.citationType??e.type,citedText:e.citedText,documentTitle:e.documentTitle,start:e.start,end:e.end}))}}var x=class{constructor(e,t,s,n,o,a){this.agentName=e;this.providerHandle=t;this.tools=s;this.messages=n;this.options=o;this.toolExecutor=a}_result;get result(){return this._result}async*[Symbol.asyncIterator](){let e=[],t,s=!1,n=a=>{try{e.push(JSON.parse(a))}catch{e.push({type:"raw",text:a})}t?.()},o=ke(this.agentName,this.providerHandle,this.tools,this.messages,this.options,n,this.toolExecutor).then(a=>{this._result=we(a),s=!0,t?.()});for(;!s||e.length>0;)e.length>0?yield e.shift():s||await new Promise(a=>{t=a});await o}};function Se(r){return{name:r.name,description:r.description,parameters:r.parameters,execute:r.execute}}function w(r){return typeof r.execute=="function"}function S(r,e){let t=new Map(r.map(s=>[s.name,s]));return async s=>{let n;try{n=JSON.parse(s)}catch{return JSON.stringify({error:"Invalid tool call JSON"})}let o=n.tool??n.name??"",a=t.get(o);if(!a)return e?e(s):JSON.stringify({error:`Unknown tool: ${o}`});try{let i=n.args??n.arguments??{},d=await a.execute(i);return typeof d=="string"?d:JSON.stringify(d)}catch(i){let d=i instanceof Error?i.message:String(i);return JSON.stringify({error:d})}}}function v(r){return{...r,citations:r.citations?.map(e=>({type:e.citationType??e.type,citedText:e.citedText,documentTitle:e.documentTitle,start:e.start,end:e.end}))}}var u=class{providerHandle;_name;_provider;_model;_instructions;_tools=[];_options={};disposed=!1;_middleware=null;_guardrails=null;_memory=null;_sessionId="";_mcpClients=[];_mcpToolsLoaded=!1;constructor(e={}){let t=_();this._provider=e.provider??t?.provider??"openai",this._model=e.model??t?.model??y,this._name=e.name??"agent",this._instructions=e.instructions??"";let s=e.providerOptions?.apiKey??f(this._provider);this.providerHandle=Pe(this._provider,this._model,{apiKey:s,...e.providerOptions}),e.tools&&(this._tools=[...e.tools]),e.middleware&&(this._middleware=e.middleware),e.guardrails&&(this._guardrails=e.guardrails),e.memory&&(this._memory=e.memory),e.sessionId&&(this._sessionId=e.sessionId),e.mcpClients&&(this._mcpClients=[...e.mcpClients]);let n=e.codeExecution,o=n===!0?{python:!0,javascript:!0,bash:!0}:n||void 0;this._options={instructions:this._instructions||void 0,temperature:e.temperature,maxSteps:e.maxSteps,topP:e.topP,maxTokens:e.maxTokens,seed:e.seed,stopOnTool:e.stopOnTool,outputSchema:e.outputSchema,thinkingBudget:e.thinkingBudget,reasoningEffort:e.reasoningEffort,cacheControl:e.cacheControl,codeExecution:o,grounding:e.grounding,nativeCodeExecution:e.nativeCodeExecution,responseModalities:e.responseModalities}}get name(){return this._name}get provider(){return this._provider}get model(){return this._model}get instructions(){return this._instructions}get handle(){return this.providerHandle}get capabilities(){return Ce(this.providerHandle)}addTool(e){return this._tools.push(e),this}addTools(e){return this._tools.push(...e),this}setOptions(e){return this._options={...this._options,...e},this}withMiddleware(e){return this._middleware=e,this}withGuardrails(e){return this._guardrails=e,this}withMemory(e,t){return this._memory=e,t&&(this._sessionId=t),this}useMcpServer(e){return this._mcpClients.push(e),this._mcpToolsLoaded=!1,this}async run(e){this.assertNotDisposed(),await this.ensureMcpTools();let t=typeof e=="string"?[{role:"user",content:e}]:[...e];if(this._memory){let a=await this._memory.recall(this._sessionId?{sessionId:this._sessionId}:void 0);a.length>0&&(t=[{role:"system",content:`Previous context:
2
- ${a.map(d=>d.content).join(`
3
- `)}`},...t])}let{toolDefs:s,executor:n}=this.resolveToolsAndExecutor(),o;if(n?o=v(await re(this._name,this.providerHandle,s,t,this._options,n)):o=v(await Re(this._name,this.providerHandle,s,t,this._options)),this._memory){let a=typeof e=="string"?e:e.map(i=>i.content).join(`
4
- `);await this._memory.store({id:`${Date.now()}-user`,content:a,entryType:"conversation",timestamp:new Date().toISOString(),sessionId:this._sessionId||void 0}),await this._memory.store({id:`${Date.now()}-assistant`,content:o.text,entryType:"conversation",timestamp:new Date().toISOString(),sessionId:this._sessionId||void 0})}return o}async runWithTools(e,t){this.assertNotDisposed(),await this.ensureMcpTools();let s=typeof e=="string"?[{role:"user",content:e}]:e,{toolDefs:n,executor:o}=this.resolveToolsAndExecutor(),a=async i=>{if(o){let d=await o(i);if(!JSON.parse(d).error?.startsWith("Unknown tool:"))return d}return t(i)};return v(await re(this._name,this.providerHandle,n,s,this._options,a))}async stream(e,t,s){this.assertNotDisposed(),await this.ensureMcpTools();let n=typeof e=="string"?[{role:"user",content:e}]:e,{toolDefs:o,executor:a}=this.resolveToolsAndExecutor(),i=s??a??se;return v(await De(this._name,this.providerHandle,o,n,this._options,t,i))}streamIter(e,t){this.assertNotDisposed();let s=typeof e=="string"?[{role:"user",content:e}]:e,{toolDefs:n,executor:o}=this.resolveToolsAndExecutor(),a=t??o??se;return new x(this._name,this.providerHandle,n,s,this._options,a)}async generate(e,t){this.assertNotDisposed();let s=typeof e=="string"?[{role:"user",content:e}]:e;return Ae(this.providerHandle,s,t?.temperature,t?.maxTokens)}async generateWithTools(e,t,s){this.assertNotDisposed();let n=typeof e=="string"?[{role:"user",content:e}]:e;return Me(this.providerHandle,n,t,s?.temperature,s?.maxTokens)}destroy(){if(!this.disposed){this.disposed=!0;for(let e of this._mcpClients)try{e.close()}catch{}try{Ee(this.providerHandle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error(`Agent "${this._name}" has been destroyed`)}resolveToolsAndExecutor(){let e=this._tools.filter(w),t=this._tools.map(n=>({name:n.name,description:n.description,parameters:n.parameters})),s=e.length>0?S(e):null;return{toolDefs:t,executor:s}}async ensureMcpTools(){if(!(this._mcpToolsLoaded||this._mcpClients.length===0)){for(let e of this._mcpClients){let{tools:t,executor:s}=await e.getToolsWithExecutor();for(let n of t){let o={...n,execute:async a=>{let i=JSON.stringify({tool:n.name,args:a}),d=await s(i);return JSON.parse(d)}};this._tools.push(o)}}this._mcpToolsLoaded=!0}}},se=async()=>"{}";async function Oe(r,e){let t=new u({name:"gauss",...e});try{return(await t.run(r)).text}finally{t.destroy()}}function ne(r={}){let e=r.providerOptions?.maxRetries??r.retries??5;return new u({...r,name:r.name??"enterprise-agent",maxSteps:r.maxSteps??20,temperature:r.temperature??.2,cacheControl:r.cacheControl??!0,reasoningEffort:r.reasoningEffort??"medium",providerOptions:{...r.providerOptions,maxRetries:e}})}async function Ne(r,e){let t=ne(e);try{return(await t.run(r)).text}finally{t.destroy()}}async function Ie(r,e){let{concurrency:t=5,...s}=e??{},n=r.map(a=>({input:a})),o=new u({name:"batch",...s});try{let a=[...n.entries()],i=Array.from({length:Math.min(t,a.length)},async()=>{for(;a.length>0;){let d=a.shift();if(!d)break;let[p,l]=d;try{n[p].result=await o.run(l.input)}catch(c){n[p].error=c instanceof Error?c:new Error(String(c))}}});await Promise.all(i)}finally{o.destroy()}return n}import{create_provider as je,destroy_provider as He,execute_code as Je,available_runtimes as Ue,generate_image as Le}from"gauss-napi";import{version as ze}from"gauss-napi";async function Ge(r,e,t){return Je(r,e,t?.timeoutSecs,t?.workingDir,t?.sandbox)}async function Fe(){return Ue()}async function Ke(r,e={}){let t=_(),s=e.provider??t?.provider??"openai",n=e.model??t?.model??"dall-e-3",o=e.providerOptions?.apiKey??f(s),a=je(s,n,{apiKey:o,...e.providerOptions});try{return await Le(a,r,e.model,e.size,e.quality,e.style,e.aspectRatio,e.n,e.responseFormat)}finally{He(a)}}import{randomUUID as Be}from"crypto";import{create_memory as qe,memory_store as Ye,memory_recall as $e,memory_clear as Ve,memory_stats as We,destroy_memory as Xe}from"gauss-napi";var P=class{_handle;disposed=!1;constructor(){this._handle=qe()}get handle(){return this._handle}async store(e,t,s){this.assertNotDisposed();let n=typeof e=="string"?{id:Be(),content:t,entryType:e||"conversation",timestamp:new Date().toISOString(),sessionId:s}:e,o={id:n.id,content:n.content,entry_type:n.entryType,timestamp:n.timestamp,tier:n.tier,metadata:n.metadata,importance:n.importance,session_id:n.sessionId,embedding:n.embedding};return Ye(this._handle,JSON.stringify(o))}async recall(e){this.assertNotDisposed();let t=e?JSON.stringify(e):void 0;return $e(this._handle,t)}async clear(e){return this.assertNotDisposed(),Ve(this._handle,e)}async stats(){return this.assertNotDisposed(),We(this._handle)}destroy(){if(!this.disposed){this.disposed=!0;try{Xe(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("Memory has been destroyed")}};import{create_vector_store as Qe,vector_store_upsert as Ze,vector_store_search as et,destroy_vector_store as tt,cosine_similarity as rt}from"gauss-napi";var E=class{_handle;disposed=!1;constructor(e){this._handle=Qe()}get handle(){return this._handle}async upsert(e){this.assertNotDisposed();let t=e.map(s=>({id:s.id,document_id:s.documentId,content:s.content,index:s.index,metadata:s.metadata??{},embedding:s.embedding}));return Ze(this._handle,JSON.stringify(t))}async search(e,t){return this.assertNotDisposed(),et(this._handle,JSON.stringify(e),t)}async searchByText(e,t,s){this.assertNotDisposed();let n=await s(e);return this.search(n,t)}destroy(){if(!this.disposed){this.disposed=!0;try{tt(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("VectorStore has been destroyed")}static cosineSimilarity(e,t){return rt(e,t)}};var st=[`
1
+ var g=class extends Error{code;constructor(e,t){super(t),this.name="GaussError",this.code=e}},m=class extends g{resourceType;resourceName;constructor(e,t){super("RESOURCE_DISPOSED",`${e} "${t}" has been destroyed. Create a new instance.`),this.name="DisposedError",this.resourceType=e,this.resourceName=t}},S=class extends g{provider;constructor(e,t){super("PROVIDER_ERROR",`[${e}] ${t}`),this.name="ProviderError",this.provider=e}},P=class extends g{toolName;cause;constructor(e,t,s){super("TOOL_EXECUTION_ERROR",`Tool "${e}" failed: ${t}`),this.name="ToolExecutionError",this.toolName=e,this.cause=s}},h=class extends g{field;constructor(e,t){super("VALIDATION_ERROR",t?`Invalid "${t}": ${e}`:e),this.name="ValidationError",this.field=t}};var x="gpt-5.2",xe="gpt-4.1",Te="o4-mini",ve="gpt-image-1",Z="claude-sonnet-4-20250514",ke="claude-haiku-4-20250414",be="claude-opus-4-20250414",ee="gemini-2.5-flash",we="gemini-2.5-pro",Ee="gemini-2.0-flash",te="openai/gpt-5.2",re="deepseek-chat",Re="deepseek-reasoner",se="meta-llama/Llama-3.3-70B-Instruct-Turbo",ne="accounts/fireworks/models/llama-v3p1-70b-instruct",oe="mistral-large-latest",ie="sonar-pro",ae="grok-3-beta",b={openai:x,anthropic:Z,google:ee,openrouter:te,deepseek:re,groq:"llama-3.3-70b-versatile",ollama:"llama3.2",together:se,fireworks:ne,mistral:oe,perplexity:ie,xai:ae};function Se(r){return b[r]??x}var Pe={openai:"OPENAI_API_KEY",anthropic:"ANTHROPIC_API_KEY",google:"GOOGLE_API_KEY",groq:"GROQ_API_KEY",deepseek:"DEEPSEEK_API_KEY",openrouter:"OPENROUTER_API_KEY",together:"TOGETHER_API_KEY",fireworks:"FIREWORKS_API_KEY",mistral:"MISTRAL_API_KEY",perplexity:"PERPLEXITY_API_KEY",xai:"XAI_API_KEY",ollama:""};function T(r){let e=Pe[r]??"";return e?(typeof process<"u"?process.env[e]:"")??"":""}function v(){let r=[{env:"OPENAI_API_KEY",provider:"openai"},{env:"ANTHROPIC_API_KEY",provider:"anthropic"},{env:"GOOGLE_API_KEY",provider:"google"},{env:"GROQ_API_KEY",provider:"groq"},{env:"DEEPSEEK_API_KEY",provider:"deepseek"},{env:"OPENROUTER_API_KEY",provider:"openrouter"},{env:"TOGETHER_API_KEY",provider:"together"},{env:"FIREWORKS_API_KEY",provider:"fireworks"},{env:"MISTRAL_API_KEY",provider:"mistral"},{env:"PERPLEXITY_API_KEY",provider:"perplexity"},{env:"XAI_API_KEY",provider:"xai"}];for(let{env:e,provider:t}of r)if(typeof process<"u"&&process.env[e])return{provider:t,model:b[t]}}import{create_provider as Me,destroy_provider as Ce,agent_run as Oe,agent_run_with_tool_executor as de,agent_stream_with_tool_executor as Ne,generate as Ie,generate_with_tools as je,get_provider_capabilities as He}from"gauss-napi";import{agent_stream_with_tool_executor as De}from"gauss-napi";function Ae(r){return{...r,citations:r.citations?.map(e=>({type:e.citationType??e.type,citedText:e.citedText,documentTitle:e.documentTitle,start:e.start,end:e.end}))}}var k=class{constructor(e,t,s,n,o,i){this.agentName=e;this.providerHandle=t;this.tools=s;this.messages=n;this.options=o;this.toolExecutor=i}_result;get result(){return this._result}async*[Symbol.asyncIterator](){let e=[],t,s=!1,n=i=>{try{e.push(JSON.parse(i))}catch{e.push({type:"raw",text:i})}t?.()},o=De(this.agentName,this.providerHandle,this.tools,this.messages,this.options,n,this.toolExecutor).then(i=>{this._result=Ae(i),s=!0,t?.()});for(;!s||e.length>0;)e.length>0?yield e.shift():s||await new Promise(i=>{t=i});await o}};function D(r){return{name:r.name,description:r.description,parameters:r.parameters,execute:r.execute}}function A(r){return typeof r.execute=="function"}function M(r,e){let t=new Map(r.map(s=>[s.name,s]));return async s=>{let n;try{n=JSON.parse(s)}catch{return JSON.stringify({error:"Invalid tool call JSON"})}let o=n.tool??n.name??"",i=t.get(o);if(!i)return e?e(s):JSON.stringify({error:`Unknown tool: ${o}`});try{let a=n.args??n.arguments??{},d=await i.execute(a);return typeof d=="string"?d:JSON.stringify(d)}catch(a){let d=a instanceof Error?a.message:String(a);return JSON.stringify({error:`Tool "${o}" failed: ${d}`})}}}function w(r){return{...r,citations:r.citations?.map(e=>({type:e.citationType??e.type??"unknown",citedText:e.citedText,documentTitle:e.documentTitle,start:e.start,end:e.end}))}}var u=class r{providerHandle;_name;_provider;_model;_providerOptions;_instructions;_tools=[];_options={};disposed=!1;_middleware=null;_guardrails=null;_memory=null;_sessionId="";_mcpClients=[];_mcpToolsLoaded=!1;constructor(e={}){let t=v();this._provider=e.provider??t?.provider??"openai",this._model=e.model??t?.model??x,this._name=e.name??"agent",this._instructions=e.instructions??"";let s=e.providerOptions?.apiKey??T(this._provider);this._providerOptions={apiKey:s,...e.providerOptions},this.providerHandle=Me(this._provider,this._model,this._providerOptions),e.tools&&(this._tools=[...e.tools]),e.middleware&&(this._middleware=e.middleware),e.guardrails&&(this._guardrails=e.guardrails),e.memory&&(this._memory=e.memory),e.sessionId&&(this._sessionId=e.sessionId),e.mcpClients&&(this._mcpClients=[...e.mcpClients]);let n=e.codeExecution,o=n===!0?{python:!0,javascript:!0,bash:!0}:n||void 0;this._options={instructions:this._instructions||void 0,temperature:e.temperature,maxSteps:e.maxSteps,topP:e.topP,maxTokens:e.maxTokens,seed:e.seed,stopOnTool:e.stopOnTool,outputSchema:e.outputSchema,thinkingBudget:e.thinkingBudget,reasoningEffort:e.reasoningEffort,cacheControl:e.cacheControl,codeExecution:o,grounding:e.grounding,nativeCodeExecution:e.nativeCodeExecution,responseModalities:e.responseModalities}}static fromEnv(e={}){return new r(e)}get name(){return this._name}get provider(){return this._provider}get model(){return this._model}get instructions(){return this._instructions}get handle(){return this.providerHandle}get capabilities(){return He(this.providerHandle)}addTool(e){return this._tools.push(e),this}addTools(e){return this._tools.push(...e),this}withTool(e,t,s,n){return this._tools.push(D({name:e,description:t,parameters:n??{},execute:s})),this}setOptions(e){return this._options={...this._options,...e},this}withModel(e){return this.assertNotDisposed(),new r({...this.toConfig(),model:e})}withMiddleware(e){return this._middleware=e,this}withGuardrails(e){return this._guardrails=e,this}withMemory(e,t){return this._memory=e,t&&(this._sessionId=t),this}useMcpServer(e){return this._mcpClients.push(e),this._mcpToolsLoaded=!1,this}async run(e){this.assertNotDisposed(),await this.ensureMcpTools();let t=typeof e=="string"?[{role:"user",content:e}]:[...e];if(this._memory){let i=await this._memory.recall(this._sessionId?{sessionId:this._sessionId}:void 0);i.length>0&&(t=[{role:"system",content:`Previous context:
2
+ ${i.map(d=>d.content).join(`
3
+ `)}`},...t])}let{toolDefs:s,executor:n}=this.resolveToolsAndExecutor(),o;if(n?o=w(await de(this._name,this.providerHandle,s,t,this._options,n)):o=w(await Oe(this._name,this.providerHandle,s,t,this._options)),this._memory){let i=typeof e=="string"?e:e.map(a=>a.content).join(`
4
+ `);await this._memory.store({id:`${Date.now()}-user`,content:i,entryType:"conversation",timestamp:new Date().toISOString(),sessionId:this._sessionId||void 0}),await this._memory.store({id:`${Date.now()}-assistant`,content:o.text,entryType:"conversation",timestamp:new Date().toISOString(),sessionId:this._sessionId||void 0})}return o}async runWithTools(e,t){this.assertNotDisposed(),await this.ensureMcpTools();let s=typeof e=="string"?[{role:"user",content:e}]:e,{toolDefs:n,executor:o}=this.resolveToolsAndExecutor(),i=async a=>{if(o){let d=await o(a);if(!JSON.parse(d).error?.startsWith("Unknown tool:"))return d}return t(a)};return w(await de(this._name,this.providerHandle,n,s,this._options,i))}async stream(e,t,s){this.assertNotDisposed(),await this.ensureMcpTools();let n=typeof e=="string"?[{role:"user",content:e}]:e,{toolDefs:o,executor:i}=this.resolveToolsAndExecutor(),a=s??i??pe;return w(await Ne(this._name,this.providerHandle,o,n,this._options,t,a))}streamIter(e,t){this.assertNotDisposed();let s=typeof e=="string"?[{role:"user",content:e}]:e,{toolDefs:n,executor:o}=this.resolveToolsAndExecutor(),i=t??o??pe;return new k(this._name,this.providerHandle,n,s,this._options,i)}async streamText(e,t,s){this.assertNotDisposed();let n=this.streamIter(e,s),o="";for await(let i of n){if(i.type!=="text_delta")continue;let a=typeof i.text=="string"?i.text:typeof i.delta=="string"?i.delta:"";a&&(o+=a,t?.(a))}return n.result?.text??o}async generate(e,t){this.assertNotDisposed();let s=typeof e=="string"?[{role:"user",content:e}]:e;return Ie(this.providerHandle,s,t?.temperature,t?.maxTokens)}async generateWithTools(e,t,s){this.assertNotDisposed();let n=typeof e=="string"?[{role:"user",content:e}]:e;return je(this.providerHandle,n,t,s?.temperature,s?.maxTokens)}destroy(){if(!this.disposed){this.disposed=!0;for(let e of this._mcpClients)try{e.close()}catch{}try{Ce(this.providerHandle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new m("Agent",this._name)}resolveToolsAndExecutor(){let e=this._tools.filter(A),t=this._tools.map(n=>({name:n.name,description:n.description,parameters:n.parameters})),s=e.length>0?M(e):null;return{toolDefs:t,executor:s}}async ensureMcpTools(){if(!(this._mcpToolsLoaded||this._mcpClients.length===0)){for(let e of this._mcpClients){let{tools:t,executor:s}=await e.getToolsWithExecutor();for(let n of t){let o={...n,execute:async i=>{let a=JSON.stringify({tool:n.name,args:i}),d=await s(a);return JSON.parse(d)}};this._tools.push(o)}}this._mcpToolsLoaded=!0}}toConfig(){return{name:this._name,provider:this._provider,model:this._model,providerOptions:{...this._providerOptions},instructions:this._instructions||void 0,tools:[...this._tools],middleware:this._middleware??void 0,guardrails:this._guardrails??void 0,memory:this._memory??void 0,sessionId:this._sessionId||void 0,mcpClients:[...this._mcpClients],temperature:this._options.temperature,maxSteps:this._options.maxSteps,topP:this._options.topP,maxTokens:this._options.maxTokens,seed:this._options.seed,stopOnTool:this._options.stopOnTool,outputSchema:this._options.outputSchema,thinkingBudget:this._options.thinkingBudget,reasoningEffort:this._options.reasoningEffort,cacheControl:this._options.cacheControl,codeExecution:this._options.codeExecution,grounding:this._options.grounding,nativeCodeExecution:this._options.nativeCodeExecution,responseModalities:this._options.responseModalities}}},pe=async()=>"{}";async function Je(r,e){let t=new u({name:"gauss",...e});try{return(await t.run(r)).text}finally{t.destroy()}}function le(r={}){let e=r.providerOptions?.maxRetries??r.retries??5;return new u({...r,name:r.name??"enterprise-agent",maxSteps:r.maxSteps??20,temperature:r.temperature??.2,cacheControl:r.cacheControl??!0,reasoningEffort:r.reasoningEffort??"medium",providerOptions:{...r.providerOptions,maxRetries:e}})}async function Ue(r,e){let t=le(e);try{return(await t.run(r)).text}finally{t.destroy()}}async function Le(r,e){let{concurrency:t=5,...s}=e??{},n=r.map(i=>({input:i})),o=new u({name:"batch",...s});try{let i=[...n.entries()],a=Array.from({length:Math.min(t,i.length)},async()=>{for(;i.length>0;){let d=i.shift();if(!d)break;let[p,l]=d;try{n[p].result=await o.run(l.input)}catch(c){n[p].error=c instanceof Error?c:new Error(String(c))}}});await Promise.all(a)}finally{o.destroy()}return n}import{create_provider as Ge,destroy_provider as Fe,execute_code as Ke,available_runtimes as $e,generate_image as ze}from"gauss-napi";import{version as Ve}from"gauss-napi";async function Be(r,e,t){return Ke(r,e,t?.timeoutSecs,t?.workingDir,t?.sandbox)}async function qe(){return $e()}async function Ye(r,e={}){let t=v(),s=e.provider??t?.provider??"openai",n=e.model??t?.model??"dall-e-3",o=e.providerOptions?.apiKey??T(s),i=Ge(s,n,{apiKey:o,...e.providerOptions});try{return await ze(i,r,e.model,e.size,e.quality,e.style,e.aspectRatio,e.n,e.responseFormat)}finally{Fe(i)}}import{randomUUID as We}from"crypto";import{create_memory as Xe,memory_store as Qe,memory_recall as Ze,memory_clear as et,memory_stats as tt,destroy_memory as rt}from"gauss-napi";var C=class{_handle;disposed=!1;constructor(){this._handle=Xe()}get handle(){return this._handle}async store(e,t,s){this.assertNotDisposed();let n=typeof e=="string"?{id:We(),content:t,entryType:e||"conversation",timestamp:new Date().toISOString(),sessionId:s}:e,o={id:n.id,content:n.content,entry_type:n.entryType,timestamp:n.timestamp,tier:n.tier,metadata:n.metadata,importance:n.importance,session_id:n.sessionId,embedding:n.embedding};return Qe(this._handle,JSON.stringify(o))}async recall(e){this.assertNotDisposed();let t=e?JSON.stringify(e):void 0;return Ze(this._handle,t)}async clear(e){return this.assertNotDisposed(),et(this._handle,e)}async stats(){return this.assertNotDisposed(),tt(this._handle)}destroy(){if(!this.disposed){this.disposed=!0;try{rt(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("Memory has been destroyed")}};import{create_vector_store as st,vector_store_upsert as nt,vector_store_search as ot,destroy_vector_store as it,cosine_similarity as at}from"gauss-napi";var O=class{_handle;disposed=!1;constructor(e){this._handle=st()}get handle(){return this._handle}async upsert(e){this.assertNotDisposed();let t=e.map(s=>({id:s.id,document_id:s.documentId,content:s.content,index:s.index,metadata:s.metadata??{},embedding:s.embedding}));return nt(this._handle,JSON.stringify(t))}async search(e,t){return this.assertNotDisposed(),ot(this._handle,JSON.stringify(e),t)}async searchByText(e,t,s){this.assertNotDisposed();let n=await s(e);return this.search(n,t)}destroy(){if(!this.disposed){this.disposed=!0;try{it(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("VectorStore has been destroyed")}static cosineSimilarity(e,t){return at(e,t)}};var dt=[`
5
5
 
6
6
  `,`
7
- `,". "," ",""],m=class{chunkSize;chunkOverlap;separators;constructor(e={}){this.chunkSize=e.chunkSize??1e3,this.chunkOverlap=e.chunkOverlap??200,this.separators=e.separators??st}split(e){return this._splitRecursive(e,this.separators).map((s,n)=>({content:s,index:n}))}_splitRecursive(e,t){if(e.length<=this.chunkSize)return[e];let s=t[0]??"",n=t.slice(1),o=s?e.split(s):[...e],a=[],i="";for(let d of o){let p=i?i+s+d:d;if(p.length>this.chunkSize&&i){a.push(i);let l=Math.max(0,i.length-this.chunkOverlap);if(i=i.slice(l)+s+d,i.length>this.chunkSize&&n.length>0){let c=this._splitRecursive(i,n);i=c.pop()??"",a.push(...c)}}else i=p}return i&&a.push(i),a}};function nt(r,e){return new m(e).split(r)}import{readFile as oe}from"fs/promises";import{basename as ie}from"path";async function ae(r,e={}){let t=!r.includes(`
8
- `)&&r.length<500,s,n;if(t)try{s=await oe(r,"utf-8"),n=e.documentId??ie(r)}catch{s=r,n=e.documentId??"text-document"}else s=r,n=e.documentId??"text-document";let i=new m(e).split(s).map(d=>({id:`${n}-${d.index}`,documentId:n,content:d.content,index:d.index,metadata:{...e.metadata,...d.metadata}}));return{documentId:n,content:s,chunks:i,metadata:e.metadata??{}}}async function ot(r,e={}){let t=await ae(r,{...e,separators:[`
7
+ `,". "," ",""],y=class{chunkSize;chunkOverlap;separators;constructor(e={}){this.chunkSize=e.chunkSize??1e3,this.chunkOverlap=e.chunkOverlap??200,this.separators=e.separators??dt}split(e){return this._splitRecursive(e,this.separators).map((s,n)=>({content:s,index:n}))}_splitRecursive(e,t){if(e.length<=this.chunkSize)return[e];let s=t[0]??"",n=t.slice(1),o=s?e.split(s):[...e],i=[],a="";for(let d of o){let p=a?a+s+d:d;if(p.length>this.chunkSize&&a){i.push(a);let l=Math.max(0,a.length-this.chunkOverlap);if(a=a.slice(l)+s+d,a.length>this.chunkSize&&n.length>0){let c=this._splitRecursive(a,n);a=c.pop()??"",i.push(...c)}}else a=p}return a&&i.push(a),i}};function pt(r,e){return new y(e).split(r)}import{readFile as ce}from"fs/promises";import{basename as ue}from"path";async function me(r,e={}){let t=!r.includes(`
8
+ `)&&r.length<500,s,n;if(t)try{s=await ce(r,"utf-8"),n=e.documentId??ue(r)}catch{s=r,n=e.documentId??"text-document"}else s=r,n=e.documentId??"text-document";let a=new y(e).split(s).map(d=>({id:`${n}-${d.index}`,documentId:n,content:d.content,index:d.index,metadata:{...e.metadata,...d.metadata}}));return{documentId:n,content:s,chunks:a,metadata:e.metadata??{}}}async function lt(r,e={}){let t=await me(r,{...e,separators:[`
9
9
  ## `,`
10
10
  ### `,`
11
11
 
12
12
  `,`
13
- `,". "," "]});return t.content=t.content.replace(/^---[\s\S]*?---\n?/,""),t}async function it(r,e={}){let t,s;if(!r.includes(`
14
- `)&&r.length<500)try{t=await oe(r,"utf-8"),s=e.documentId??ie(r)}catch{t=r,s=e.documentId??"json-document"}else t=r,s=e.documentId??"json-document";let o=JSON.parse(t),a=[];if(Array.isArray(o))o.forEach((d,p)=>{let l=e.textField?String(d[e.textField]??""):JSON.stringify(d);a.push({key:String(p),text:l})});else if(typeof o=="object"&&o!==null)for(let[d,p]of Object.entries(o)){let l=typeof p=="string"?p:JSON.stringify(p);a.push({key:d,text:l})}let i=a.map((d,p)=>({id:`${s}-${d.key}`,documentId:s,content:d.text,index:p,metadata:{...e.metadata,key:d.key}}));return{documentId:s,content:t,chunks:i,metadata:e.metadata??{}}}import{create_graph as at,graph_add_node as dt,graph_add_edge as pt,graph_add_fork_node as lt,graph_run as ct,destroy_graph as ut}from"gauss-napi";var R=class{_handle;disposed=!1;_nodes=new Map;_edges=new Map;_conditionalEdges=new Map;constructor(){this._handle=at()}get handle(){return this._handle}addNode(e){return this.assertNotDisposed(),dt(this._handle,e.nodeId,e.agent.name,e.agent.handle,e.instructions,e.tools??[]),this._nodes.set(e.nodeId,{agent:e.agent,instructions:e.instructions}),this}addFork(e){return this.assertNotDisposed(),lt(this._handle,e.nodeId,e.agents.map(t=>({agentName:t.agent.name,providerHandle:t.agent.handle,instructions:t.instructions})),e.consensus??"concat"),this}addEdge(e,t){return this.assertNotDisposed(),pt(this._handle,e,t),this._edges.set(e,t),this}addConditionalEdge(e,t){return this.assertNotDisposed(),this._conditionalEdges.set(e,t),this}async run(e){return this.assertNotDisposed(),this._conditionalEdges.size===0?ct(this._handle,e):this._runWithConditionals(e)}destroy(){if(!this.disposed){this.disposed=!0;try{ut(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}async _runWithConditionals(e){let t=new Set([...this._edges.values()]),s=[...this._nodes.keys()].filter(p=>!t.has(p));if(s.length===0)throw new Error("Graph has no entry node (every node has an incoming edge)");let n={},o=s[0],a=e;for(;o;){let p=this._nodes.get(o);if(!p)throw new Error(`Node "${o}" not found in graph`);let l=p.instructions?`${p.instructions}
13
+ `,". "," "]});return t.content=t.content.replace(/^---[\s\S]*?---\n?/,""),t}async function ct(r,e={}){let t,s;if(!r.includes(`
14
+ `)&&r.length<500)try{t=await ce(r,"utf-8"),s=e.documentId??ue(r)}catch{t=r,s=e.documentId??"json-document"}else t=r,s=e.documentId??"json-document";let o=JSON.parse(t),i=[];if(Array.isArray(o))o.forEach((d,p)=>{let l=e.textField?String(d[e.textField]??""):JSON.stringify(d);i.push({key:String(p),text:l})});else if(typeof o=="object"&&o!==null)for(let[d,p]of Object.entries(o)){let l=typeof p=="string"?p:JSON.stringify(p);i.push({key:d,text:l})}let a=i.map((d,p)=>({id:`${s}-${d.key}`,documentId:s,content:d.text,index:p,metadata:{...e.metadata,key:d.key}}));return{documentId:s,content:t,chunks:a,metadata:e.metadata??{}}}import{create_graph as ut,graph_add_node as mt,graph_add_edge as gt,graph_add_fork_node as ht,graph_run as yt,destroy_graph as ft}from"gauss-napi";var N=class r{static pipeline(e){let t=new r;for(let s of e)t.addNode(s);for(let s=0;s<e.length-1;s++)t.addEdge(e[s].nodeId,e[s+1].nodeId);return t}_handle;disposed=!1;_nodes=new Map;_edges=new Map;_conditionalEdges=new Map;constructor(){this._handle=ut()}get handle(){return this._handle}addNode(e){return this.assertNotDisposed(),mt(this._handle,e.nodeId,e.agent.name,e.agent.handle,e.instructions,e.tools??[]),this._nodes.set(e.nodeId,{agent:e.agent,instructions:e.instructions}),this}addFork(e){return this.assertNotDisposed(),ht(this._handle,e.nodeId,e.agents.map(t=>({agentName:t.agent.name,providerHandle:t.agent.handle,instructions:t.instructions})),e.consensus??"concat"),this}addEdge(e,t){return this.assertNotDisposed(),gt(this._handle,e,t),this._edges.set(e,t),this}addConditionalEdge(e,t){return this.assertNotDisposed(),this._conditionalEdges.set(e,t),this}async run(e){return this.assertNotDisposed(),this._conditionalEdges.size===0?yt(this._handle,e):this._runWithConditionals(e)}destroy(){if(!this.disposed){this.disposed=!0;try{ft(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}async _runWithConditionals(e){let t=new Set([...this._edges.values()]),s=[...this._nodes.keys()].filter(p=>!t.has(p));if(s.length===0)throw new h("Graph has no entry node (every node has an incoming edge)");let n={},o=s[0],i=e;for(;o;){let p=this._nodes.get(o);if(!p)throw new h(`Node "${o}" not found in graph`);let l=p.instructions?`${p.instructions}
15
15
 
16
- ${a}`:a,c=await p.agent.run(l),g={text:c.text,...c.structuredOutput?{structuredOutput:c.structuredOutput}:{}};n[o]=g;let q=this._conditionalEdges.get(o);q?o=await q(g):o=this._edges.get(o),a=c.text}let i=Object.keys(n),d=i[i.length-1];return{outputs:n,final_text:n[d]?.text??""}}assertNotDisposed(){if(this.disposed)throw new Error("Graph has been destroyed")}};import{create_workflow as mt,workflow_add_step as ht,workflow_add_dependency as gt,workflow_run as yt,destroy_workflow as ft}from"gauss-napi";var D=class{_handle;disposed=!1;constructor(){this._handle=mt()}get handle(){return this._handle}addStep(e){return this.assertNotDisposed(),ht(this._handle,e.stepId,e.agent.name,e.agent.handle,e.instructions,e.tools??[]),this}addDependency(e,t){return this.assertNotDisposed(),gt(this._handle,e,t),this}async run(e){return this.assertNotDisposed(),yt(this._handle,e)}destroy(){if(!this.disposed){this.disposed=!0;try{ft(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("Workflow has been destroyed")}};import{create_team as _t,team_add_agent as xt,team_set_strategy as Tt,team_run as vt,destroy_team as bt}from"gauss-napi";var A=class{_handle;disposed=!1;agents=[];constructor(e){this._handle=_t(e)}get handle(){return this._handle}add(e,t){return this.assertNotDisposed(),xt(this._handle,e.name,e.handle,t),this.agents.push(e),this}strategy(e){return this.assertNotDisposed(),Tt(this._handle,e),this}async run(e){this.assertNotDisposed();let t=JSON.stringify([{role:"user",content:[{type:"text",text:e}]}]);return vt(this._handle,t)}destroy(){if(!this.disposed){this.disposed=!0;try{bt(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("Team has been destroyed")}};import{create_network as kt,network_add_agent as wt,network_set_supervisor as St,network_delegate as Pt,network_agent_cards as Et,destroy_network as Rt}from"gauss-napi";var M=class{_handle;disposed=!1;constructor(){this._handle=kt()}get handle(){return this._handle}addAgent(e,t){return this.assertNotDisposed(),wt(this._handle,e.name,e.handle,t),this}setSupervisor(e){return this.assertNotDisposed(),St(this._handle,e),this}async delegate(e,t,s){return this.assertNotDisposed(),Pt(this._handle,e,t,s)}agentCards(){return this.assertNotDisposed(),Et(this._handle)}destroy(){if(!this.disposed){this.disposed=!0;try{Rt(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("Network has been destroyed")}};import{create_middleware_chain as Dt,middleware_use_logging as At,middleware_use_caching as Mt,middleware_use_rate_limit as Ct,destroy_middleware_chain as Ot}from"gauss-napi";var C=class{_handle;disposed=!1;constructor(){this._handle=Dt()}get handle(){return this._handle}useLogging(){return this.assertNotDisposed(),At(this._handle),this}useCaching(e){return this.assertNotDisposed(),Mt(this._handle,e),this}useRateLimit(e,t){return this.assertNotDisposed(),Ct(this._handle,e,t),this}destroy(){if(!this.disposed){this.disposed=!0;try{Ot(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("MiddlewareChain has been destroyed")}};import{create_plugin_registry as Nt,plugin_registry_add_telemetry as It,plugin_registry_add_memory as jt,plugin_registry_list as Ht,plugin_registry_emit as Jt,destroy_plugin_registry as Ut}from"gauss-napi";var O=class{_handle;disposed=!1;constructor(){this._handle=Nt()}get handle(){return this._handle}addTelemetry(){return this.assertNotDisposed(),It(this._handle),this}addMemory(){return this.assertNotDisposed(),jt(this._handle),this}list(){return this.assertNotDisposed(),Ht(this._handle)}emit(e){this.assertNotDisposed(),Jt(this._handle,JSON.stringify(e))}destroy(){if(!this.disposed){this.disposed=!0;try{Ut(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("PluginRegistry has been destroyed")}};import{create_mcp_server as Lt,mcp_server_add_tool as Gt,mcpServerAddResource as Ft,mcpServerAddPrompt as Kt,mcp_server_handle as zt,destroy_mcp_server as Bt}from"gauss-napi";var N=class{_handle;disposed=!1;constructor(e,t){this._handle=Lt(e,t)}get handle(){return this._handle}addTool(e){this.assertNotDisposed();let t={name:e.name,description:e.description,inputSchema:e.parameters??{type:"object"}};return Gt(this._handle,JSON.stringify(t)),this}addResource(e){return this.assertNotDisposed(),Ft(this._handle,JSON.stringify(e)),this}addPrompt(e){return this.assertNotDisposed(),Kt(this._handle,JSON.stringify(e)),this}async handleMessage(e){return this.assertNotDisposed(),zt(this._handle,JSON.stringify(e))}destroy(){if(!this.disposed){this.disposed=!0;try{Bt(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("McpServer has been destroyed")}};import{spawn as qt}from"child_process";var I=class{config;process=null;connected=!1;closed=!1;nextId=1;pending=new Map;buffer="";serverCapabilities={};cachedTools=null;constructor(e){this.config=e}async connect(){if(this.connected)return;if(this.closed)throw new Error("McpClient has been closed");let e=this.config.timeoutMs??1e4;this.process=qt(this.config.command,this.config.args??[],{stdio:["pipe","pipe","pipe"],env:{...process.env,...this.config.env}}),this.process.stdout.on("data",s=>this.onData(s)),this.process.stderr.on("data",()=>{}),this.process.on("error",s=>this.onProcessError(s)),this.process.on("close",()=>this.onProcessClose());let t=await this.request("initialize",{protocolVersion:"2024-11-05",capabilities:{},clientInfo:{name:"gauss-mcp-client",version:"1.2.0"}},e);this.serverCapabilities=t?.capabilities??{},this.notify("notifications/initialized",{}),this.connected=!0}async listTools(){if(this.assertConnected(),this.cachedTools)return this.cachedTools;let t=((await this.request("tools/list",{}))?.tools??[]).map(s=>({name:s.name,description:s.description??"",parameters:s.inputSchema}));return this.cachedTools=t,t}async callTool(e,t={}){return this.assertConnected(),await this.request("tools/call",{name:e,arguments:t})}async getToolsWithExecutor(){return{tools:await this.listTools(),executor:async s=>{let n;try{n=JSON.parse(s)}catch{return JSON.stringify({error:"Invalid tool call JSON"})}let o=n.tool??n.name??"",a=n.args??n.arguments??{};try{let i=await this.callTool(o,a);if(i.isError){let p=i.content?.map(l=>l.text).filter(Boolean).join(`
17
- `)??"Tool error";return JSON.stringify({error:p})}let d=i.content?.map(p=>p.text).filter(Boolean).join(`
18
- `)??"";return JSON.stringify({result:d})}catch(i){let d=i instanceof Error?i.message:String(i);return JSON.stringify({error:d})}}}}close(){if(!this.closed){this.closed=!0,this.connected=!1,this.cachedTools=null;for(let[,{reject:e}]of this.pending)e(new Error("McpClient closed"));this.pending.clear(),this.process&&(this.process.stdin.end(),this.process.kill("SIGTERM"),this.process=null)}}destroy(){this.close()}[Symbol.dispose](){this.close()}get isConnected(){return this.connected}async request(e,t,s=3e4){let n=this.nextId++,o={jsonrpc:"2.0",id:n,method:e,params:t};return new Promise((a,i)=>{let d=setTimeout(()=>{this.pending.delete(n),i(new Error(`MCP request "${e}" timed out after ${s}ms`))},s);this.pending.set(n,{resolve:p=>{clearTimeout(d),a(p)},reject:p=>{clearTimeout(d),i(p)}}),this.send(o)})}notify(e,t){let s={jsonrpc:"2.0",method:e,params:t};this.send(s)}send(e){if(!this.process?.stdin?.writable)throw new Error("MCP server process not available");let t=JSON.stringify(e);this.process.stdin.write(t+`
16
+ ${i}`:i,c=await p.agent.run(l),_={text:c.text,...c.structuredOutput?{structuredOutput:c.structuredOutput}:{}};n[o]=_;let Q=this._conditionalEdges.get(o);Q?o=await Q(_):o=this._edges.get(o),i=c.text}let a=Object.keys(n),d=a[a.length-1];return{outputs:n,final_text:n[d]?.text??""}}assertNotDisposed(){if(this.disposed)throw new m("Graph","graph")}};import{create_workflow as _t,workflow_add_step as xt,workflow_add_dependency as Tt,workflow_run as vt,destroy_workflow as kt}from"gauss-napi";var I=class{_handle;disposed=!1;constructor(){this._handle=_t()}get handle(){return this._handle}addStep(e){return this.assertNotDisposed(),xt(this._handle,e.stepId,e.agent.name,e.agent.handle,e.instructions,e.tools??[]),this}addDependency(e,t){return this.assertNotDisposed(),Tt(this._handle,e,t),this}async run(e){return this.assertNotDisposed(),vt(this._handle,e)}destroy(){if(!this.disposed){this.disposed=!0;try{kt(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("Workflow has been destroyed")}};import{create_team as bt,team_add_agent as wt,team_set_strategy as Et,team_run as Rt,destroy_team as St}from"gauss-napi";var j=class r{_handle;_name;disposed=!1;agents=[];static quick(e,t,s){let n=new r(e);for(let o of s){let i=new u({name:o.name,provider:o.provider??"openai",model:o.model??"gpt-4o",instructions:o.instructions});n.add(i)}return n.strategy(t),n}constructor(e){this._name=e,this._handle=bt(e)}get handle(){return this._handle}add(e,t){return this.assertNotDisposed(),wt(this._handle,e.name,e.handle,t),this.agents.push(e),this}strategy(e){return this.assertNotDisposed(),Et(this._handle,e),this}async run(e){this.assertNotDisposed();let t=JSON.stringify([{role:"user",content:[{type:"text",text:e}]}]);return Rt(this._handle,t)}destroy(){if(!this.disposed){this.disposed=!0;try{St(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new m("Team",this._name)}};import{create_network as Pt,network_add_agent as Dt,network_set_supervisor as At,network_delegate as Mt,network_agent_cards as Ct,destroy_network as Ot}from"gauss-napi";var H=class{_handle;disposed=!1;constructor(){this._handle=Pt()}get handle(){return this._handle}addAgent(e,t){return this.assertNotDisposed(),Dt(this._handle,e.name,e.handle,t),this}setSupervisor(e){return this.assertNotDisposed(),At(this._handle,e),this}async delegate(e,t,s){return this.assertNotDisposed(),Mt(this._handle,e,t,s)}agentCards(){return this.assertNotDisposed(),Ct(this._handle)}destroy(){if(!this.disposed){this.disposed=!0;try{Ot(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("Network has been destroyed")}};import{create_middleware_chain as Nt,middleware_use_logging as It,middleware_use_caching as jt,middleware_use_rate_limit as Ht,destroy_middleware_chain as Jt}from"gauss-napi";var J=class{_handle;disposed=!1;constructor(){this._handle=Nt()}get handle(){return this._handle}useLogging(){return this.assertNotDisposed(),It(this._handle),this}useCaching(e){return this.assertNotDisposed(),jt(this._handle,e),this}useRateLimit(e,t){return this.assertNotDisposed(),Ht(this._handle,e,t),this}destroy(){if(!this.disposed){this.disposed=!0;try{Jt(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("MiddlewareChain has been destroyed")}};import{create_plugin_registry as Ut,plugin_registry_add_telemetry as Lt,plugin_registry_add_memory as Gt,plugin_registry_list as Ft,plugin_registry_emit as Kt,destroy_plugin_registry as $t}from"gauss-napi";var U=class{_handle;disposed=!1;constructor(){this._handle=Ut()}get handle(){return this._handle}addTelemetry(){return this.assertNotDisposed(),Lt(this._handle),this}addMemory(){return this.assertNotDisposed(),Gt(this._handle),this}list(){return this.assertNotDisposed(),Ft(this._handle)}emit(e){this.assertNotDisposed(),Kt(this._handle,JSON.stringify(e))}destroy(){if(!this.disposed){this.disposed=!0;try{$t(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("PluginRegistry has been destroyed")}};import{create_mcp_server as zt,mcp_server_add_tool as Bt,mcpServerAddResource as qt,mcpServerAddPrompt as Yt,mcp_server_handle as Vt,destroy_mcp_server as Wt}from"gauss-napi";var L=class{_handle;disposed=!1;constructor(e,t){this._handle=zt(e,t)}get handle(){return this._handle}addTool(e){this.assertNotDisposed();let t={name:e.name,description:e.description,inputSchema:e.parameters??{type:"object"}};return Bt(this._handle,JSON.stringify(t)),this}addResource(e){return this.assertNotDisposed(),qt(this._handle,JSON.stringify(e)),this}addPrompt(e){return this.assertNotDisposed(),Yt(this._handle,JSON.stringify(e)),this}async handleMessage(e){return this.assertNotDisposed(),Vt(this._handle,JSON.stringify(e))}destroy(){if(!this.disposed){this.disposed=!0;try{Wt(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("McpServer has been destroyed")}};import{spawn as Xt}from"child_process";var G=class{config;process=null;connected=!1;closed=!1;nextId=1;pending=new Map;buffer="";serverCapabilities={};cachedTools=null;constructor(e){this.config=e}async connect(){if(this.connected)return;if(this.closed)throw new Error("McpClient has been closed");let e=this.config.timeoutMs??1e4;this.process=Xt(this.config.command,this.config.args??[],{stdio:["pipe","pipe","pipe"],env:{...process.env,...this.config.env}}),this.process.stdout.on("data",s=>this.onData(s)),this.process.stderr.on("data",()=>{}),this.process.on("error",s=>this.onProcessError(s)),this.process.on("close",()=>this.onProcessClose());let t=await this.request("initialize",{protocolVersion:"2024-11-05",capabilities:{},clientInfo:{name:"gauss-mcp-client",version:"1.2.0"}},e);this.serverCapabilities=t?.capabilities??{},this.notify("notifications/initialized",{}),this.connected=!0}async listTools(){if(this.assertConnected(),this.cachedTools)return this.cachedTools;let t=((await this.request("tools/list",{}))?.tools??[]).map(s=>({name:s.name,description:s.description??"",parameters:s.inputSchema}));return this.cachedTools=t,t}async callTool(e,t={}){return this.assertConnected(),await this.request("tools/call",{name:e,arguments:t})}async getToolsWithExecutor(){return{tools:await this.listTools(),executor:async s=>{let n;try{n=JSON.parse(s)}catch{return JSON.stringify({error:"Invalid tool call JSON"})}let o=n.tool??n.name??"",i=n.args??n.arguments??{};try{let a=await this.callTool(o,i);if(a.isError){let p=a.content?.map(l=>l.text).filter(Boolean).join(`
17
+ `)??"Tool error";return JSON.stringify({error:p})}let d=a.content?.map(p=>p.text).filter(Boolean).join(`
18
+ `)??"";return JSON.stringify({result:d})}catch(a){let d=a instanceof Error?a.message:String(a);return JSON.stringify({error:d})}}}}close(){if(!this.closed){this.closed=!0,this.connected=!1,this.cachedTools=null;for(let[,{reject:e}]of this.pending)e(new Error("McpClient closed"));this.pending.clear(),this.process&&(this.process.stdin.end(),this.process.kill("SIGTERM"),this.process=null)}}destroy(){this.close()}[Symbol.dispose](){this.close()}get isConnected(){return this.connected}async request(e,t,s=3e4){let n=this.nextId++,o={jsonrpc:"2.0",id:n,method:e,params:t};return new Promise((i,a)=>{let d=setTimeout(()=>{this.pending.delete(n),a(new Error(`MCP request "${e}" timed out after ${s}ms`))},s);this.pending.set(n,{resolve:p=>{clearTimeout(d),i(p)},reject:p=>{clearTimeout(d),a(p)}}),this.send(o)})}notify(e,t){let s={jsonrpc:"2.0",method:e,params:t};this.send(s)}send(e){if(!this.process?.stdin?.writable)throw new Error("MCP server process not available");let t=JSON.stringify(e);this.process.stdin.write(t+`
19
19
  `)}onData(e){this.buffer+=e.toString("utf-8");let t;for(;(t=this.buffer.indexOf(`
20
- `))!==-1;){let s=this.buffer.slice(0,t).trim();if(this.buffer=this.buffer.slice(t+1),!!s)try{let n=JSON.parse(s);if(n.id!==void 0&&this.pending.has(n.id)){let{resolve:o,reject:a}=this.pending.get(n.id);this.pending.delete(n.id),n.error?a(new Error(`MCP error ${n.error.code}: ${n.error.message}`)):o(n.result)}}catch{}}}onProcessError(e){for(let[,{reject:t}]of this.pending)t(new Error(`MCP process error: ${e.message}`));this.pending.clear(),this.connected=!1}onProcessClose(){this.connected=!1;for(let[,{reject:e}]of this.pending)e(new Error("MCP server process exited"));this.pending.clear()}assertConnected(){if(!this.connected)throw new Error("McpClient is not connected. Call connect() first.")}};import{create_guardrail_chain as Yt,guardrail_chain_add_content_moderation as $t,guardrail_chain_add_pii_detection as Vt,guardrail_chain_add_token_limit as Wt,guardrail_chain_add_regex_filter as Xt,guardrail_chain_add_schema as Qt,guardrail_chain_list as Zt,destroy_guardrail_chain as er}from"gauss-napi";var j=class{_handle;disposed=!1;constructor(){this._handle=Yt()}get handle(){return this._handle}addContentModeration(e,t=[]){return this.assertNotDisposed(),$t(this._handle,e,t),this}addPiiDetection(e){return this.assertNotDisposed(),Vt(this._handle,e),this}addTokenLimit(e,t){return this.assertNotDisposed(),Wt(this._handle,e,t),this}addRegexFilter(e,t=[]){return this.assertNotDisposed(),Xt(this._handle,e,t),this}addSchema(e){return this.assertNotDisposed(),Qt(this._handle,JSON.stringify(e)),this}list(){return this.assertNotDisposed(),Zt(this._handle)}destroy(){if(!this.disposed){this.disposed=!0;try{er(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("GuardrailChain has been destroyed")}};import{create_approval_manager as tr,approval_request as rr,approval_approve as sr,approval_deny as nr,approval_list_pending as or,destroy_approval_manager as ir}from"gauss-napi";var H=class{_handle;disposed=!1;constructor(){this._handle=tr()}get handle(){return this._handle}request(e,t,s){return this.assertNotDisposed(),rr(this._handle,e,JSON.stringify(t),s)}approve(e,t){this.assertNotDisposed(),sr(this._handle,e,t?JSON.stringify(t):void 0)}deny(e,t){this.assertNotDisposed(),nr(this._handle,e,t)}listPending(){return this.assertNotDisposed(),or(this._handle)}destroy(){if(!this.disposed){this.disposed=!0;try{ir(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("ApprovalManager has been destroyed")}};import{create_checkpoint_store as ar,checkpoint_save as dr,checkpoint_load as pr,checkpoint_load_latest as lr,destroy_checkpoint_store as cr}from"gauss-napi";var J=class{_handle;disposed=!1;constructor(){this._handle=ar()}get handle(){return this._handle}async save(e){return this.assertNotDisposed(),dr(this._handle,JSON.stringify(e))}async load(e){return this.assertNotDisposed(),pr(this._handle,e)}async loadLatest(e){return this.assertNotDisposed(),lr(this._handle,e)}destroy(){if(!this.disposed){this.disposed=!0;try{cr(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("CheckpointStore has been destroyed")}};import{create_eval_runner as ur,eval_add_scorer as mr,load_dataset_jsonl as hr,load_dataset_json as gr,destroy_eval_runner as yr}from"gauss-napi";var U=class{_handle;disposed=!1;constructor(e){this._handle=ur(e)}get handle(){return this._handle}addScorer(e){return this.assertNotDisposed(),mr(this._handle,e),this}destroy(){if(!this.disposed){this.disposed=!0;try{yr(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("EvalRunner has been destroyed")}static loadDatasetJsonl(e){return hr(e)}static loadDatasetJson(e){return gr(e)}};import{create_telemetry as fr,telemetry_record_span as _r,telemetry_export_spans as xr,telemetry_export_metrics as Tr,telemetry_clear as vr,destroy_telemetry as br}from"gauss-napi";var L=class{_handle;disposed=!1;constructor(){this._handle=fr()}get handle(){return this._handle}recordSpan(e,t,s){this.assertNotDisposed();let n=typeof e=="string"?{name:e,span_type:"custom",start_ms:Date.now()-(t??0),duration_ms:t??0,attributes:s??{},status:"ok",children:[]}:e;_r(this._handle,JSON.stringify(n))}exportSpans(){return this.assertNotDisposed(),xr(this._handle)}exportMetrics(){return this.assertNotDisposed(),Tr(this._handle)}clear(){this.assertNotDisposed(),vr(this._handle)}destroy(){if(!this.disposed){this.disposed=!0;try{br(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("Telemetry has been destroyed")}};import{create_fallback_provider as kr,create_circuit_breaker as wr,create_resilient_provider as Sr}from"gauss-napi";function Pr(r){return kr(r)}function Er(r,e,t){return wr(r,e,t)}function de(r,e,t){return Sr(r,e,t)}function Rr(r,e,t=!0){return de(r.handle,e.map(s=>s.handle),t)}import{count_tokens as Dr,count_tokens_for_model as Ar,count_message_tokens as Mr,get_context_window_size as Cr,estimate_cost as Or}from"gauss-napi";var b=new Map;function Nr(r,e){b.set(r,e)}function Ir(r){return b.get(r)}function jr(){b.clear()}function Hr(r){return Dr(r)}function Jr(r,e){return Ar(r,e)}function Ur(r){return Mr(r)}function Lr(r){return Cr(r)}function Gr(r,e){let t=b.get(r);if(t){let n=e.inputTokens*t.inputPerToken,o=e.outputTokens*t.outputPerToken,a=(e.reasoningTokens??0)*(t.reasoningPerToken??t.outputPerToken),i=(e.cacheReadTokens??0)*(t.cacheReadPerToken??t.inputPerToken*.5),d=(e.cacheCreationTokens??0)*(t.cacheCreationPerToken??t.inputPerToken*1.25);return{model:r,normalizedModel:r,currency:"USD",inputTokens:e.inputTokens,outputTokens:e.outputTokens,reasoningTokens:e.reasoningTokens??0,cacheReadTokens:e.cacheReadTokens??0,cacheCreationTokens:e.cacheCreationTokens??0,inputCostUsd:n,outputCostUsd:o,reasoningCostUsd:a,cacheReadCostUsd:i,cacheCreationCostUsd:d,totalCostUsd:n+o+a+i+d}}let s=Or(r,e.inputTokens,e.outputTokens,e.reasoningTokens,e.cacheReadTokens,e.cacheCreationTokens);return{model:String(s.model??r),normalizedModel:String(s.normalized_model??r),currency:String(s.currency??"USD"),inputTokens:Number(s.input_tokens??e.inputTokens),outputTokens:Number(s.output_tokens??e.outputTokens),reasoningTokens:Number(s.reasoning_tokens??e.reasoningTokens??0),cacheReadTokens:Number(s.cache_read_tokens??e.cacheReadTokens??0),cacheCreationTokens:Number(s.cache_creation_tokens??e.cacheCreationTokens??0),inputCostUsd:Number(s.input_cost_usd??0),outputCostUsd:Number(s.output_cost_usd??0),reasoningCostUsd:Number(s.reasoning_cost_usd??0),cacheReadCostUsd:Number(s.cache_read_cost_usd??0),cacheCreationCostUsd:Number(s.cache_creation_cost_usd??0),totalCostUsd:Number(s.total_cost_usd??0)}}import{agent_config_from_json as Fr,agent_config_resolve_env as Kr}from"gauss-napi";function zr(r){return Fr(r)}function Br(r){return Kr(r)}import{create_tool_validator as qr,tool_validator_validate as Yr,destroy_tool_validator as $r}from"gauss-napi";var G=class{_handle;disposed=!1;constructor(e){this._handle=qr(e)}get handle(){return this._handle}validate(e,t){return this.assertNotDisposed(),JSON.parse(Yr(this._handle,JSON.stringify(e),JSON.stringify(t)))}destroy(){if(!this.disposed){this.disposed=!0;try{$r(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("ToolValidator has been destroyed")}};import{parse_partial_json as Vr}from"gauss-napi";function Wr(r){return Vr(r)}function Xr(r,e){let t;switch(r.backoff){case"fixed":t=r.baseDelayMs;break;case"linear":t=r.baseDelayMs*e;break;case"exponential":t=r.baseDelayMs*Math.pow(2,e-1);break}let s=t*r.jitter;return t+=Math.random()*s*2-s,Math.min(Math.max(0,t),r.maxDelayMs)}function Qr(r){return new Promise(e=>setTimeout(e,r))}async function pe(r,e){let t=e?.maxRetries??3,s=e?.backoff??"exponential",n=e?.baseDelayMs??1e3,o=e?.maxDelayMs??3e4,a=e?.jitter??.1,i=e?.retryIf,d=e?.onRetry,p;for(let l=0;l<=t;l++)try{return await r()}catch(c){if(p=c instanceof Error?c:new Error(String(c)),l===t||i&&!i(p,l+1))break;let g=Xr({backoff:s,baseDelayMs:n,maxDelayMs:o,jitter:a},l+1);d?.(p,l+1,g),await Qr(g)}throw p}function Zr(r,e){return t=>pe(()=>r.run(t),e)}function es(r,e){let t=JSON.stringify(e,null,2);return`${r}
20
+ `))!==-1;){let s=this.buffer.slice(0,t).trim();if(this.buffer=this.buffer.slice(t+1),!!s)try{let n=JSON.parse(s);if(n.id!==void 0&&this.pending.has(n.id)){let{resolve:o,reject:i}=this.pending.get(n.id);this.pending.delete(n.id),n.error?i(new Error(`MCP error ${n.error.code}: ${n.error.message}`)):o(n.result)}}catch{}}}onProcessError(e){for(let[,{reject:t}]of this.pending)t(new Error(`MCP process error: ${e.message}`));this.pending.clear(),this.connected=!1}onProcessClose(){this.connected=!1;for(let[,{reject:e}]of this.pending)e(new Error("MCP server process exited"));this.pending.clear()}assertConnected(){if(!this.connected)throw new Error("McpClient is not connected. Call connect() first.")}};import{create_guardrail_chain as Qt,guardrail_chain_add_content_moderation as Zt,guardrail_chain_add_pii_detection as er,guardrail_chain_add_token_limit as tr,guardrail_chain_add_regex_filter as rr,guardrail_chain_add_schema as sr,guardrail_chain_list as nr,destroy_guardrail_chain as or}from"gauss-napi";var F=class{_handle;disposed=!1;constructor(){this._handle=Qt()}get handle(){return this._handle}addContentModeration(e,t=[]){return this.assertNotDisposed(),Zt(this._handle,e,t),this}addPiiDetection(e){return this.assertNotDisposed(),er(this._handle,e),this}addTokenLimit(e,t){return this.assertNotDisposed(),tr(this._handle,e,t),this}addRegexFilter(e,t=[]){return this.assertNotDisposed(),rr(this._handle,e,t),this}addSchema(e){return this.assertNotDisposed(),sr(this._handle,JSON.stringify(e)),this}list(){return this.assertNotDisposed(),nr(this._handle)}destroy(){if(!this.disposed){this.disposed=!0;try{or(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("GuardrailChain has been destroyed")}};import{create_approval_manager as ir,approval_request as ar,approval_approve as dr,approval_deny as pr,approval_list_pending as lr,destroy_approval_manager as cr}from"gauss-napi";var K=class{_handle;disposed=!1;constructor(){this._handle=ir()}get handle(){return this._handle}request(e,t,s){return this.assertNotDisposed(),ar(this._handle,e,JSON.stringify(t),s)}approve(e,t){this.assertNotDisposed(),dr(this._handle,e,t?JSON.stringify(t):void 0)}deny(e,t){this.assertNotDisposed(),pr(this._handle,e,t)}listPending(){return this.assertNotDisposed(),lr(this._handle)}destroy(){if(!this.disposed){this.disposed=!0;try{cr(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("ApprovalManager has been destroyed")}};import{create_checkpoint_store as ur,checkpoint_save as mr,checkpoint_load as gr,checkpoint_load_latest as hr,destroy_checkpoint_store as yr}from"gauss-napi";var $=class{_handle;disposed=!1;constructor(){this._handle=ur()}get handle(){return this._handle}async save(e){return this.assertNotDisposed(),mr(this._handle,JSON.stringify(e))}async load(e){return this.assertNotDisposed(),gr(this._handle,e)}async loadLatest(e){return this.assertNotDisposed(),hr(this._handle,e)}destroy(){if(!this.disposed){this.disposed=!0;try{yr(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("CheckpointStore has been destroyed")}};import{create_eval_runner as fr,eval_add_scorer as _r,load_dataset_jsonl as xr,load_dataset_json as Tr,destroy_eval_runner as vr}from"gauss-napi";var z=class{_handle;disposed=!1;constructor(e){this._handle=fr(e)}get handle(){return this._handle}addScorer(e){return this.assertNotDisposed(),_r(this._handle,e),this}destroy(){if(!this.disposed){this.disposed=!0;try{vr(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("EvalRunner has been destroyed")}static loadDatasetJsonl(e){return xr(e)}static loadDatasetJson(e){return Tr(e)}};import{create_telemetry as kr,telemetry_record_span as br,telemetry_export_spans as wr,telemetry_export_metrics as Er,telemetry_clear as Rr,destroy_telemetry as Sr}from"gauss-napi";var B=class{_handle;disposed=!1;constructor(){this._handle=kr()}get handle(){return this._handle}recordSpan(e,t,s){this.assertNotDisposed();let n=typeof e=="string"?{name:e,span_type:"custom",start_ms:Date.now()-(t??0),duration_ms:t??0,attributes:s??{},status:"ok",children:[]}:e;br(this._handle,JSON.stringify(n))}exportSpans(){return this.assertNotDisposed(),wr(this._handle)}exportMetrics(){return this.assertNotDisposed(),Er(this._handle)}clear(){this.assertNotDisposed(),Rr(this._handle)}destroy(){if(!this.disposed){this.disposed=!0;try{Sr(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("Telemetry has been destroyed")}};import{create_fallback_provider as Pr,create_circuit_breaker as Dr,create_resilient_provider as Ar}from"gauss-napi";function Mr(r){return Pr(r)}function Cr(r,e,t){return Dr(r,e,t)}function ge(r,e,t){return Ar(r,e,t)}function Or(r,e,t=!0){return ge(r.handle,e.map(s=>s.handle),t)}import{count_tokens as Nr,count_tokens_for_model as Ir,count_message_tokens as jr,get_context_window_size as Hr,estimate_cost as Jr}from"gauss-napi";var E=new Map;function Ur(r,e){E.set(r,e)}function Lr(r){return E.get(r)}function Gr(){E.clear()}function Fr(r){return Nr(r)}function Kr(r,e){return Ir(r,e)}function $r(r){return jr(r)}function zr(r){return Hr(r)}function Br(r,e){let t=E.get(r);if(t){let n=e.inputTokens*t.inputPerToken,o=e.outputTokens*t.outputPerToken,i=(e.reasoningTokens??0)*(t.reasoningPerToken??t.outputPerToken),a=(e.cacheReadTokens??0)*(t.cacheReadPerToken??t.inputPerToken*.5),d=(e.cacheCreationTokens??0)*(t.cacheCreationPerToken??t.inputPerToken*1.25);return{model:r,normalizedModel:r,currency:"USD",inputTokens:e.inputTokens,outputTokens:e.outputTokens,reasoningTokens:e.reasoningTokens??0,cacheReadTokens:e.cacheReadTokens??0,cacheCreationTokens:e.cacheCreationTokens??0,inputCostUsd:n,outputCostUsd:o,reasoningCostUsd:i,cacheReadCostUsd:a,cacheCreationCostUsd:d,totalCostUsd:n+o+i+a+d}}let s=Jr(r,e.inputTokens,e.outputTokens,e.reasoningTokens,e.cacheReadTokens,e.cacheCreationTokens);return{model:String(s.model??r),normalizedModel:String(s.normalized_model??r),currency:String(s.currency??"USD"),inputTokens:Number(s.input_tokens??e.inputTokens),outputTokens:Number(s.output_tokens??e.outputTokens),reasoningTokens:Number(s.reasoning_tokens??e.reasoningTokens??0),cacheReadTokens:Number(s.cache_read_tokens??e.cacheReadTokens??0),cacheCreationTokens:Number(s.cache_creation_tokens??e.cacheCreationTokens??0),inputCostUsd:Number(s.input_cost_usd??0),outputCostUsd:Number(s.output_cost_usd??0),reasoningCostUsd:Number(s.reasoning_cost_usd??0),cacheReadCostUsd:Number(s.cache_read_cost_usd??0),cacheCreationCostUsd:Number(s.cache_creation_cost_usd??0),totalCostUsd:Number(s.total_cost_usd??0)}}import{agent_config_from_json as qr,agent_config_resolve_env as Yr}from"gauss-napi";function Vr(r){return qr(r)}function Wr(r){return Yr(r)}import{create_tool_validator as Xr,tool_validator_validate as Qr,destroy_tool_validator as Zr}from"gauss-napi";var q=class{_handle;disposed=!1;constructor(e){this._handle=Xr(e)}get handle(){return this._handle}validate(e,t){return this.assertNotDisposed(),JSON.parse(Qr(this._handle,JSON.stringify(e),JSON.stringify(t)))}destroy(){if(!this.disposed){this.disposed=!0;try{Zr(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("ToolValidator has been destroyed")}};import{parse_partial_json as es}from"gauss-napi";function ts(r){return es(r)}function rs(r,e){let t;switch(r.backoff){case"fixed":t=r.baseDelayMs;break;case"linear":t=r.baseDelayMs*e;break;case"exponential":t=r.baseDelayMs*Math.pow(2,e-1);break}let s=t*r.jitter;return t+=Math.random()*s*2-s,Math.min(Math.max(0,t),r.maxDelayMs)}function ss(r){return new Promise(e=>setTimeout(e,r))}async function he(r,e){let t=e?.maxRetries??3,s=e?.backoff??"exponential",n=e?.baseDelayMs??1e3,o=e?.maxDelayMs??3e4,i=e?.jitter??.1,a=e?.retryIf,d=e?.onRetry,p;for(let l=0;l<=t;l++)try{return await r()}catch(c){if(p=c instanceof Error?c:new Error(String(c)),l===t||a&&!a(p,l+1))break;let _=rs({backoff:s,baseDelayMs:n,maxDelayMs:o,jitter:i},l+1);d?.(p,l+1,_),await ss(_)}throw p}function ns(r,e){return t=>he(()=>r.run(t),e)}function os(r,e){let t=JSON.stringify(e,null,2);return`${r}
21
21
 
22
22
  Respond ONLY with valid JSON matching this schema:
23
23
  ${t}
24
24
 
25
- Do not include any text outside the JSON object.`}function ts(r){let e=r.match(/```(?:json)?\s*\n?([\s\S]*?)\n?\s*```/);if(e)return e[1].trim();let t=r.indexOf("{"),s=r.indexOf("[");if(t===-1&&s===-1)return r.trim();let n=t===-1?s:s===-1?t:Math.min(t,s),a=r[n]==="["?"]":"}",i=0,d=!1,p=!1;for(let l=n;l<r.length;l++){let c=r[l];if(p){p=!1;continue}if(c==="\\"){p=!0;continue}if(c==='"'){d=!d;continue}if(!d&&(c===r[n]&&i++,c===a&&(i--,i===0)))return r.slice(n,l+1)}return r.slice(n)}async function rs(r,e,t){let s=t.maxParseRetries??2,n=typeof e=="string"?es(e,t.schema):e,o;for(let a=0;a<=s;a++){let i=a===0?n:typeof n=="string"?`${n}
25
+ Do not include any text outside the JSON object.`}function is(r){let e=r.match(/```(?:json)?\s*\n?([\s\S]*?)\n?\s*```/);if(e)return e[1].trim();let t=r.indexOf("{"),s=r.indexOf("[");if(t===-1&&s===-1)return r.trim();let n=t===-1?s:s===-1?t:Math.min(t,s),i=r[n]==="["?"]":"}",a=0,d=!1,p=!1;for(let l=n;l<r.length;l++){let c=r[l];if(p){p=!1;continue}if(c==="\\"){p=!0;continue}if(c==='"'){d=!d;continue}if(!d&&(c===r[n]&&a++,c===i&&(a--,a===0)))return r.slice(n,l+1)}return r.slice(n)}async function as(r,e,t){let s=t.maxParseRetries??2,n=typeof e=="string"?os(e,t.schema):e,o;for(let i=0;i<=s;i++){let a=i===0?n:typeof n=="string"?`${n}
26
26
 
27
- Previous attempt failed: ${o?.message}. Please output ONLY valid JSON.`:n,d=await r.run(i);try{let p=ts(d.text);return{data:JSON.parse(p),raw:t.includeRaw?d:void 0}}catch(p){o=p instanceof Error?p:new Error(String(p))}}throw new Error(`Failed to extract structured output after ${s+1} attempts: ${o?.message}`)}var le=/\{\{(\w+)\}\}/g;function h(r){let e=[...new Set(Array.from(r.matchAll(le),s=>s[1]))],t=s=>r.replace(le,(n,o)=>{let a=s[o];if(a===void 0)throw new Error(`Missing template variable: {{${o}}}`);return a});return Object.defineProperty(t,"raw",{value:r,enumerable:!0}),Object.defineProperty(t,"variables",{value:e,enumerable:!0}),t}var ss=h(`Summarize the following {{format}} in {{style}}:
27
+ Previous attempt failed: ${o?.message}. Please output ONLY valid JSON.`:n,d=await r.run(a);try{let p=is(d.text);return{data:JSON.parse(p),raw:t.includeRaw?d:void 0}}catch(p){o=p instanceof Error?p:new Error(String(p))}}throw new Error(`Failed to extract structured output after ${s+1} attempts: ${o?.message}`)}var ye=/\{\{(\w+)\}\}/g;function f(r){let e=[...new Set(Array.from(r.matchAll(ye),s=>s[1]))],t=s=>r.replace(ye,(n,o)=>{let i=s[o];if(i===void 0)throw new Error(`Missing template variable: {{${o}}}`);return i});return Object.defineProperty(t,"raw",{value:r,enumerable:!0}),Object.defineProperty(t,"variables",{value:e,enumerable:!0}),t}var ds=f(`Summarize the following {{format}} in {{style}}:
28
28
 
29
- {{text}}`),ns=h(`Translate the following text to {{language}}:
29
+ {{text}}`),ps=f(`Translate the following text to {{language}}:
30
30
 
31
- {{text}}`),os=h("Review this {{language}} code for bugs, security issues, and best practices:\n\n```{{language}}\n{{code}}\n```"),is=h(`Classify the following text into one of these categories: {{categories}}
31
+ {{text}}`),ls=f("Review this {{language}} code for bugs, security issues, and best practices:\n\n```{{language}}\n{{code}}\n```"),cs=f(`Classify the following text into one of these categories: {{categories}}
32
32
 
33
33
  Text: {{text}}
34
34
 
35
- Respond with only the category name.`),as=h(`Extract the following information from the text: {{fields}}
35
+ Respond with only the category name.`),us=f(`Extract the following information from the text: {{fields}}
36
36
 
37
37
  Text: {{text}}
38
38
 
39
- Respond as JSON.`);import{parseAgentsMd as ds,discoverAgents as ps,parseSkillMd as ls}from"gauss-napi";var k=class r{name;description;model;provider;instructions;tools;skills;capabilities;environment;metadata;constructor(e){this.name=e.name,this.description=e.description,this.model=e.model??void 0,this.provider=e.provider??void 0,this.instructions=e.instructions??void 0,this.tools=Object.freeze([...e.tools]),this.skills=Object.freeze([...e.skills]),this.capabilities=Object.freeze([...e.capabilities]),this.environment=new Map(e.environment),this.metadata=Object.freeze({...e.metadata})}static fromMarkdown(e){let t=ds(e),s=typeof t=="string"?JSON.parse(t):t;return new r(s)}hasTool(e){return this.tools.some(t=>t.name===e)}hasCapability(e){return this.capabilities.includes(e)}toJSON(){return{name:this.name,description:this.description,model:this.model,provider:this.provider,instructions:this.instructions,tools:[...this.tools],skills:[...this.skills],capabilities:[...this.capabilities],environment:[...this.environment.entries()],metadata:{...this.metadata}}}},F=class r{name;description;steps;inputs;outputs;constructor(e){this.name=e.name,this.description=e.description,this.steps=Object.freeze([...e.steps]),this.inputs=Object.freeze([...e.inputs]),this.outputs=Object.freeze([...e.outputs])}static fromMarkdown(e){let t=ls(e),s=typeof t=="string"?JSON.parse(t):t;return new r(s)}get stepCount(){return this.steps.length}get requiredInputs(){return this.inputs.filter(e=>e.required)}toJSON(){return{name:this.name,description:this.description,steps:[...this.steps],inputs:[...this.inputs],outputs:[...this.outputs]}}};function cs(r){let e=ps(r);return(typeof e=="string"?JSON.parse(e):e).map(s=>Object.assign(Object.create(k.prototype),{name:s.name,description:s.description,model:s.model??void 0,provider:s.provider??void 0,instructions:s.instructions??void 0,tools:Object.freeze([...s.tools]),skills:Object.freeze([...s.skills]),capabilities:Object.freeze([...s.capabilities]),environment:new Map(s.environment),metadata:Object.freeze({...s.metadata})}))}async function us(r,...e){let t=r;for(let s of e)t=await s(t);return t}async function ce(r,e,t){let s=t?.concurrency??r.length,n=new Array(r.length),o=r.map((i,d)=>({item:i,index:d})),a=Array.from({length:Math.min(s,o.length)},async()=>{for(;o.length>0;){let i=o.shift();if(!i)break;n[i.index]=await e(i.item,i.index)}});return await Promise.all(a),n}async function ms(r,e,t){let s=await ce(r,e,t);return r.filter((n,o)=>s[o])}async function hs(r,e,t){let s=t;for(let n=0;n<r.length;n++)s=await e(s,r[n],n);return s}async function gs(r,e){for(let t=0;t<r.length;t++)await e(r[t],t);return r}function ys(...r){return async e=>{let t=e;for(let s of r)t=await s(t);return t}}import{a2aDiscover as fs,a2aSendMessage as _s,a2aAsk as xs,a2aGetTask as Ts,a2aCancelTask as vs}from"gauss-napi";var K=class{baseUrl;authToken;constructor(e){typeof e=="string"?this.baseUrl=e:(this.baseUrl=e.baseUrl,this.authToken=e.authToken)}async discover(){return await fs(this.baseUrl,this.authToken??void 0)}async sendMessage(e,t){let s=await _s(this.baseUrl,this.authToken??void 0,JSON.stringify(e),t?JSON.stringify(t):void 0);if(s._type==="task"){let{_type:a,...i}=s;return{type:"task",task:i}}let{_type:n,...o}=s;return{type:"message",message:o}}async ask(e){return xs(this.baseUrl,this.authToken??void 0,e)}async getTask(e,t){return await Ts(this.baseUrl,this.authToken??void 0,e,t??void 0)}async cancelTask(e){return await vs(this.baseUrl,this.authToken??void 0,e)}};function z(r,e){return{role:r,parts:[{type:"text",text:e}]}}function bs(r){return z("user",r)}function ks(r){return z("agent",r)}function ue(r){return r.parts.filter(e=>e.type==="text"&&e.text).map(e=>e.text).join("")}function ws(r){if(r.status.message)return ue(r.status.message)}import{createToolRegistry as Ss,toolRegistryAdd as Ps,toolRegistrySearch as Es,toolRegistryByTag as Rs,toolRegistryList as Ds,destroyToolRegistry as As}from"gauss-napi";var B=class{_handle;disposed=!1;constructor(){this._handle=Ss()}get handle(){return this._handle}add(e){return this.assertNotDisposed(),Ps(this._handle,JSON.stringify(e)),this}search(e){return this.assertNotDisposed(),Es(this._handle,e)}byTag(e){return this.assertNotDisposed(),Rs(this._handle,e)}list(){return this.assertNotDisposed(),Ds(this._handle)}destroy(){if(!this.disposed){this.disposed=!0;try{As(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("ToolRegistry has been destroyed")}};export{K as A2aClient,Y as ANTHROPIC_DEFAULT,ye as ANTHROPIC_FAST,fe as ANTHROPIC_PREMIUM,u as Agent,k as AgentSpec,x as AgentStream,H as ApprovalManager,J as CheckpointStore,W as DEEPSEEK_DEFAULT,Te as DEEPSEEK_REASONING,U as EvalRunner,Q as FIREWORKS_DEFAULT,$ as GOOGLE_DEFAULT,xe as GOOGLE_IMAGE,_e as GOOGLE_PREMIUM,R as Graph,j as GuardrailChain,Z as MISTRAL_DEFAULT,I as McpClient,N as McpServer,P as Memory,C as MiddlewareChain,M as Network,y as OPENAI_DEFAULT,me as OPENAI_FAST,ge as OPENAI_IMAGE,he as OPENAI_REASONING,V as OPENROUTER_DEFAULT,ee as PERPLEXITY_DEFAULT,T as PROVIDER_DEFAULTS,O as PluginRegistry,F as SkillSpec,X as TOGETHER_DEFAULT,A as Team,L as Telemetry,m as TextSplitter,B as ToolRegistry,G as ToolValidator,E as VectorStore,D as Workflow,te as XAI_DEFAULT,ks as agentMessage,Fe as availableRuntimes,Ie as batch,is as classify,jr as clearPricing,os as codeReview,ys as compose,Ur as countMessageTokens,Hr as countTokens,Jr as countTokensForModel,Er as createCircuitBreaker,Pr as createFallbackProvider,Rr as createResilientAgent,de as createResilientProvider,S as createToolExecutor,ve as defaultModel,_ as detectProvider,cs as discoverAgents,ne as enterprisePreset,Ne as enterpriseRun,Gr as estimateCost,Ge as executeCode,as as extract,ue as extractText,ms as filterAsync,Oe as gauss,Ke as generateImage,Lr as getContextWindowSize,Ir as getPricing,w as isTypedTool,it as loadJson,ot as loadMarkdown,ae as loadText,ce as mapAsync,zr as parseAgentConfig,Wr as parsePartialJson,us as pipe,hs as reduceAsync,f as resolveApiKey,Br as resolveEnv,Zr as retryable,Nr as setPricing,nt as splitText,rs as structured,ss as summarize,gs as tapAsync,ws as taskText,h as template,z as textMessage,Se as tool,ns as translate,bs as userMessage,ze as version,pe as withRetry};
39
+ Respond as JSON.`);import{parseAgentsMd as ms,discoverAgents as gs,parseSkillMd as hs}from"gauss-napi";var R=class r{name;description;model;provider;instructions;tools;skills;capabilities;environment;metadata;constructor(e){this.name=e.name,this.description=e.description,this.model=e.model??void 0,this.provider=e.provider??void 0,this.instructions=e.instructions??void 0,this.tools=Object.freeze([...e.tools]),this.skills=Object.freeze([...e.skills]),this.capabilities=Object.freeze([...e.capabilities]),this.environment=new Map(e.environment),this.metadata=Object.freeze({...e.metadata})}static fromMarkdown(e){let t=ms(e),s=typeof t=="string"?JSON.parse(t):t;return new r(s)}hasTool(e){return this.tools.some(t=>t.name===e)}hasCapability(e){return this.capabilities.includes(e)}toJSON(){return{name:this.name,description:this.description,model:this.model,provider:this.provider,instructions:this.instructions,tools:[...this.tools],skills:[...this.skills],capabilities:[...this.capabilities],environment:[...this.environment.entries()],metadata:{...this.metadata}}}},Y=class r{name;description;steps;inputs;outputs;constructor(e){this.name=e.name,this.description=e.description,this.steps=Object.freeze([...e.steps]),this.inputs=Object.freeze([...e.inputs]),this.outputs=Object.freeze([...e.outputs])}static fromMarkdown(e){let t=hs(e),s=typeof t=="string"?JSON.parse(t):t;return new r(s)}get stepCount(){return this.steps.length}get requiredInputs(){return this.inputs.filter(e=>e.required)}toJSON(){return{name:this.name,description:this.description,steps:[...this.steps],inputs:[...this.inputs],outputs:[...this.outputs]}}};function ys(r){let e=gs(r);return(typeof e=="string"?JSON.parse(e):e).map(s=>Object.assign(Object.create(R.prototype),{name:s.name,description:s.description,model:s.model??void 0,provider:s.provider??void 0,instructions:s.instructions??void 0,tools:Object.freeze([...s.tools]),skills:Object.freeze([...s.skills]),capabilities:Object.freeze([...s.capabilities]),environment:new Map(s.environment),metadata:Object.freeze({...s.metadata})}))}async function fs(r,...e){let t=r;for(let s of e)t=await s(t);return t}async function fe(r,e,t){let s=t?.concurrency??r.length,n=new Array(r.length),o=r.map((a,d)=>({item:a,index:d})),i=Array.from({length:Math.min(s,o.length)},async()=>{for(;o.length>0;){let a=o.shift();if(!a)break;n[a.index]=await e(a.item,a.index)}});return await Promise.all(i),n}async function _s(r,e,t){let s=await fe(r,e,t);return r.filter((n,o)=>s[o])}async function xs(r,e,t){let s=t;for(let n=0;n<r.length;n++)s=await e(s,r[n],n);return s}async function Ts(r,e){for(let t=0;t<r.length;t++)await e(r[t],t);return r}function vs(...r){return async e=>{let t=e;for(let s of r)t=await s(t);return t}}import{a2aDiscover as ks,a2aSendMessage as bs,a2aAsk as ws,a2aGetTask as Es,a2aCancelTask as Rs}from"gauss-napi";var V=class{baseUrl;authToken;constructor(e){typeof e=="string"?this.baseUrl=e:(this.baseUrl=e.baseUrl,this.authToken=e.authToken)}async discover(){return await ks(this.baseUrl,this.authToken??void 0)}async sendMessage(e,t){let s=await bs(this.baseUrl,this.authToken??void 0,JSON.stringify(e),t?JSON.stringify(t):void 0);if(s._type==="task"){let{_type:i,...a}=s;return{type:"task",task:a}}let{_type:n,...o}=s;return{type:"message",message:o}}async ask(e){return ws(this.baseUrl,this.authToken??void 0,e)}async getTask(e,t){return await Es(this.baseUrl,this.authToken??void 0,e,t??void 0)}async cancelTask(e){return await Rs(this.baseUrl,this.authToken??void 0,e)}};function W(r,e){return{role:r,parts:[{type:"text",text:e}]}}function Ss(r){return W("user",r)}function Ps(r){return W("agent",r)}function _e(r){return r.parts.filter(e=>e.type==="text"&&e.text).map(e=>e.text).join("")}function Ds(r){if(r.status.message)return _e(r.status.message)}import{createToolRegistry as As,toolRegistryAdd as Ms,toolRegistrySearch as Cs,toolRegistryByTag as Os,toolRegistryList as Ns,destroyToolRegistry as Is}from"gauss-napi";var X=class{_handle;disposed=!1;constructor(){this._handle=As()}get handle(){return this._handle}add(e){return this.assertNotDisposed(),Ms(this._handle,JSON.stringify(e)),this}search(e){return this.assertNotDisposed(),Cs(this._handle,e)}byTag(e){return this.assertNotDisposed(),Os(this._handle,e)}list(){return this.assertNotDisposed(),Ns(this._handle)}destroy(){if(!this.disposed){this.disposed=!0;try{Is(this._handle)}catch{}}}[Symbol.dispose](){this.destroy()}assertNotDisposed(){if(this.disposed)throw new Error("ToolRegistry has been destroyed")}};export{V as A2aClient,Z as ANTHROPIC_DEFAULT,ke as ANTHROPIC_FAST,be as ANTHROPIC_PREMIUM,u as Agent,R as AgentSpec,k as AgentStream,K as ApprovalManager,$ as CheckpointStore,re as DEEPSEEK_DEFAULT,Re as DEEPSEEK_REASONING,m as DisposedError,z as EvalRunner,ne as FIREWORKS_DEFAULT,ee as GOOGLE_DEFAULT,Ee as GOOGLE_IMAGE,we as GOOGLE_PREMIUM,g as GaussError,N as Graph,F as GuardrailChain,oe as MISTRAL_DEFAULT,G as McpClient,L as McpServer,C as Memory,J as MiddlewareChain,H as Network,x as OPENAI_DEFAULT,xe as OPENAI_FAST,ve as OPENAI_IMAGE,Te as OPENAI_REASONING,te as OPENROUTER_DEFAULT,ie as PERPLEXITY_DEFAULT,b as PROVIDER_DEFAULTS,U as PluginRegistry,S as ProviderError,Y as SkillSpec,se as TOGETHER_DEFAULT,j as Team,B as Telemetry,y as TextSplitter,P as ToolExecutionError,X as ToolRegistry,q as ToolValidator,h as ValidationError,O as VectorStore,I as Workflow,ae as XAI_DEFAULT,Ps as agentMessage,qe as availableRuntimes,Le as batch,cs as classify,Gr as clearPricing,ls as codeReview,vs as compose,$r as countMessageTokens,Fr as countTokens,Kr as countTokensForModel,Cr as createCircuitBreaker,Mr as createFallbackProvider,Or as createResilientAgent,ge as createResilientProvider,M as createToolExecutor,Se as defaultModel,v as detectProvider,ys as discoverAgents,le as enterprisePreset,Ue as enterpriseRun,Br as estimateCost,Be as executeCode,us as extract,_e as extractText,_s as filterAsync,Je as gauss,Ye as generateImage,zr as getContextWindowSize,Lr as getPricing,A as isTypedTool,ct as loadJson,lt as loadMarkdown,me as loadText,fe as mapAsync,Vr as parseAgentConfig,ts as parsePartialJson,fs as pipe,xs as reduceAsync,T as resolveApiKey,Wr as resolveEnv,ns as retryable,Ur as setPricing,pt as splitText,as as structured,ds as summarize,Ts as tapAsync,Ds as taskText,f as template,W as textMessage,D as tool,ps as translate,Ss as userMessage,Ve as version,he as withRetry};
40
40
  //# sourceMappingURL=index.js.map