@cuylabs/agent-core 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/{builder-BKkipazh.d.ts → builder-BRvqCcIk.d.ts} +2 -2
- package/dist/{resolver-DOfZ-xuk.d.ts → capability-resolver-CgRGsWVX.d.ts} +1 -1
- package/dist/{chunk-3C4VKG4P.js → chunk-3HNO5SVI.js} +273 -807
- package/dist/chunk-5K7AQVOU.js +619 -0
- package/dist/{chunk-QAQADS4X.js → chunk-BNSHUWCV.js} +1 -0
- package/dist/{chunk-O2ZCFQL6.js → chunk-CDTV2UYU.js} +86 -1
- package/dist/chunk-IEFIQENH.js +73 -0
- package/dist/chunk-N7P4PN3O.js +84 -0
- package/dist/{chunk-QWFMX226.js → chunk-QGOGIP7T.js} +148 -15
- package/dist/chunk-VNQBHPCT.js +398 -0
- package/dist/{chunk-X635CM2F.js → chunk-ZPMACVZK.js} +1 -1
- package/dist/context/index.js +1 -1
- package/dist/host/index.d.ts +45 -0
- package/dist/host/index.js +8 -0
- package/dist/{index-DZQJD_hp.d.ts → index-C33hlD6H.d.ts} +12 -7
- package/dist/{index-ipP3_ztp.d.ts → index-CfBGYrpd.d.ts} +121 -2
- package/dist/index.d.ts +107 -126
- package/dist/index.js +321 -601
- package/dist/inference/index.d.ts +59 -0
- package/dist/inference/index.js +25 -0
- package/dist/middleware/index.d.ts +7 -4
- package/dist/middleware/index.js +5 -3
- package/dist/models/index.d.ts +104 -2
- package/dist/models/index.js +40 -6
- package/dist/prompt/index.d.ts +9 -6
- package/dist/reasoning/index.d.ts +54 -8
- package/dist/reasoning/index.js +2 -3
- package/dist/{registry-CuRWWtcT.d.ts → registry-BDLIHOQB.d.ts} +1 -1
- package/dist/{runner-G1wxEgac.d.ts → runner-DSKaEz3z.d.ts} +35 -8
- package/dist/runtime/index.d.ts +41 -7
- package/dist/runtime/index.js +15 -6
- package/dist/scope/index.d.ts +10 -0
- package/dist/scope/index.js +14 -0
- package/dist/{session-manager-Uawm2Le7.d.ts → session-manager-B_CWGTsl.d.ts} +1 -1
- package/dist/skill/index.d.ts +7 -5
- package/dist/storage/index.d.ts +2 -2
- package/dist/sub-agent/index.d.ts +12 -8
- package/dist/tool/index.d.ts +7 -4
- package/dist/tool/index.js +4 -3
- package/dist/{tool-pFAnJc5Y.d.ts → tool-Db1Ue-1U.d.ts} +1 -1
- package/dist/{tool-DYp6-cC3.d.ts → tool-HUtkiVBx.d.ts} +5 -99
- package/dist/tracking/index.d.ts +3 -1
- package/dist/types-9jGQUjqW.d.ts +29 -0
- package/dist/types-CHiPh8U2.d.ts +100 -0
- package/dist/types-CqDZTh4d.d.ts +335 -0
- package/dist/types-FRpzzg_9.d.ts +355 -0
- package/package.json +19 -8
- package/dist/capabilities/index.d.ts +0 -97
- package/dist/capabilities/index.js +0 -46
- package/dist/chunk-6TDTQJ4P.js +0 -116
- package/dist/chunk-DWYX7ASF.js +0 -26
- package/dist/chunk-FG4MD5MU.js +0 -54
- package/dist/config-D2xeGEHK.d.ts +0 -52
- package/dist/identifiers-BLUxFqV_.d.ts +0 -12
- package/dist/network-D76DS5ot.d.ts +0 -5
- package/dist/types-BWo810L_.d.ts +0 -648
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuylabs/agent-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Embeddable AI agent infrastructure — execution, sessions, tools, skills, sub-agents, tracing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
"import": "./dist/runtime/index.js",
|
|
22
22
|
"default": "./dist/runtime/index.js"
|
|
23
23
|
},
|
|
24
|
+
"./inference": {
|
|
25
|
+
"types": "./dist/inference/index.d.ts",
|
|
26
|
+
"import": "./dist/inference/index.js",
|
|
27
|
+
"default": "./dist/inference/index.js"
|
|
28
|
+
},
|
|
24
29
|
"./tracking": {
|
|
25
30
|
"types": "./dist/tracking/index.d.ts",
|
|
26
31
|
"import": "./dist/tracking/index.js",
|
|
@@ -61,11 +66,6 @@
|
|
|
61
66
|
"import": "./dist/reasoning/index.js",
|
|
62
67
|
"default": "./dist/reasoning/index.js"
|
|
63
68
|
},
|
|
64
|
-
"./capabilities": {
|
|
65
|
-
"types": "./dist/capabilities/index.d.ts",
|
|
66
|
-
"import": "./dist/capabilities/index.js",
|
|
67
|
-
"default": "./dist/capabilities/index.js"
|
|
68
|
-
},
|
|
69
69
|
"./models": {
|
|
70
70
|
"types": "./dist/models/index.d.ts",
|
|
71
71
|
"import": "./dist/models/index.js",
|
|
@@ -75,6 +75,16 @@
|
|
|
75
75
|
"types": "./dist/mcp/index.d.ts",
|
|
76
76
|
"import": "./dist/mcp/index.js",
|
|
77
77
|
"default": "./dist/mcp/index.js"
|
|
78
|
+
},
|
|
79
|
+
"./host": {
|
|
80
|
+
"types": "./dist/host/index.d.ts",
|
|
81
|
+
"import": "./dist/host/index.js",
|
|
82
|
+
"default": "./dist/host/index.js"
|
|
83
|
+
},
|
|
84
|
+
"./scope": {
|
|
85
|
+
"types": "./dist/scope/index.d.ts",
|
|
86
|
+
"import": "./dist/scope/index.js",
|
|
87
|
+
"default": "./dist/scope/index.js"
|
|
78
88
|
}
|
|
79
89
|
},
|
|
80
90
|
"files": [
|
|
@@ -179,10 +189,11 @@
|
|
|
179
189
|
"access": "public"
|
|
180
190
|
},
|
|
181
191
|
"scripts": {
|
|
182
|
-
"build": "tsup src/index.ts src/tool/index.ts src/runtime/index.ts src/tracking/index.ts src/middleware/index.ts src/prompt/index.ts src/skill/index.ts src/sub-agent/index.ts src/storage/index.ts src/context/index.ts src/reasoning/index.ts src/
|
|
183
|
-
"dev": "tsup src/index.ts src/tool/index.ts src/runtime/index.ts src/tracking/index.ts src/middleware/index.ts src/prompt/index.ts src/skill/index.ts src/sub-agent/index.ts src/storage/index.ts src/context/index.ts src/reasoning/index.ts src/
|
|
192
|
+
"build": "tsup src/index.ts src/tool/index.ts src/runtime/index.ts src/inference/index.ts src/tracking/index.ts src/middleware/index.ts src/prompt/index.ts src/skill/index.ts src/sub-agent/index.ts src/storage/index.ts src/context/index.ts src/reasoning/index.ts src/models/index.ts src/mcp/index.ts src/host/index.ts src/scope/index.ts --format esm --dts --clean",
|
|
193
|
+
"dev": "tsup src/index.ts src/tool/index.ts src/runtime/index.ts src/inference/index.ts src/tracking/index.ts src/middleware/index.ts src/prompt/index.ts src/skill/index.ts src/sub-agent/index.ts src/storage/index.ts src/context/index.ts src/reasoning/index.ts src/models/index.ts src/mcp/index.ts src/host/index.ts src/scope/index.ts --format esm --dts --watch",
|
|
184
194
|
"test": "vitest run",
|
|
185
195
|
"test:watch": "vitest",
|
|
196
|
+
"lint": "eslint src/",
|
|
186
197
|
"typecheck": "tsc --noEmit",
|
|
187
198
|
"clean": "rm -rf dist"
|
|
188
199
|
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { C as CapabilitySource, S as SourcePriority, b as SourceResult, P as ProviderCompatibility, R as ResolverOptions, M as ModelEntry, c as ModelCapabilities } from '../resolver-DOfZ-xuk.js';
|
|
2
|
-
export { D as DEFAULT_RESOLVER_OPTIONS, I as InputModality, d as ModelCapabilityResolver, N as NetworkStatus, O as OutputModality, f as ResolutionResult, g as configureResolver, e as extractModelId, a as extractProvider, h as getDefaultResolver } from '../resolver-DOfZ-xuk.js';
|
|
3
|
-
export { g as getModelId, a as getProviderId } from '../identifiers-BLUxFqV_.js';
|
|
4
|
-
export { g as getNetworkStatus } from '../network-D76DS5ot.js';
|
|
5
|
-
import 'ai';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Pattern-Based Capability Detection for @cuylabs/agent-core
|
|
9
|
-
*
|
|
10
|
-
* Static pattern matching for model capabilities when no external data is available.
|
|
11
|
-
* This is the fallback layer - always works offline.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Infer provider from model ID
|
|
16
|
-
*/
|
|
17
|
-
declare function inferProvider(modelId: string): string | undefined;
|
|
18
|
-
/**
|
|
19
|
-
* Pattern-based capability source
|
|
20
|
-
* Always available, uses heuristics to detect capabilities
|
|
21
|
-
*/
|
|
22
|
-
declare class PatternCapabilitySource implements CapabilitySource {
|
|
23
|
-
readonly priority = SourcePriority.PatternMatch;
|
|
24
|
-
readonly name = "Pattern Matching";
|
|
25
|
-
lookup(modelId: string, providerHint?: string): Promise<SourceResult>;
|
|
26
|
-
isAvailable(): Promise<boolean>;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Quick check if a model ID likely supports reasoning
|
|
30
|
-
*/
|
|
31
|
-
declare function likelySupportsReasoning(modelId: string): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Get provider compatibility for a model
|
|
34
|
-
*/
|
|
35
|
-
declare function getProviderCompatibility(modelId: string, provider?: string): ProviderCompatibility | undefined;
|
|
36
|
-
|
|
37
|
-
type CapabilityOverrides = ResolverOptions["modelOverrides"];
|
|
38
|
-
type OverrideLookup = {
|
|
39
|
-
override?: Partial<ModelCapabilities>;
|
|
40
|
-
matchedKey?: string;
|
|
41
|
-
};
|
|
42
|
-
declare function findCapabilityOverride(overrides: CapabilityOverrides, modelId: string, provider?: string): OverrideLookup;
|
|
43
|
-
declare function applyCapabilityOverride(entry: ModelEntry, override?: Partial<ModelCapabilities>): ModelEntry;
|
|
44
|
-
|
|
45
|
-
declare class CapabilityCache {
|
|
46
|
-
private adapter;
|
|
47
|
-
private memoryCache;
|
|
48
|
-
private ttlMs;
|
|
49
|
-
private loaded;
|
|
50
|
-
constructor(options?: Partial<ResolverOptions>);
|
|
51
|
-
private load;
|
|
52
|
-
get(modelId: string, provider?: string): Promise<ModelEntry | undefined>;
|
|
53
|
-
set(entry: ModelEntry): Promise<void>;
|
|
54
|
-
setMany(entries: ModelEntry[]): Promise<void>;
|
|
55
|
-
persist(): Promise<void>;
|
|
56
|
-
clear(): Promise<void>;
|
|
57
|
-
stats(): {
|
|
58
|
-
size: number;
|
|
59
|
-
loaded: boolean;
|
|
60
|
-
};
|
|
61
|
-
getAll(): Promise<ModelEntry[]>;
|
|
62
|
-
getAllByProvider(): Promise<Record<string, ModelEntry[]>>;
|
|
63
|
-
}
|
|
64
|
-
declare class CacheCapabilitySource implements CapabilitySource {
|
|
65
|
-
private cache;
|
|
66
|
-
readonly priority = SourcePriority.LocalCache;
|
|
67
|
-
readonly name = "Local Cache";
|
|
68
|
-
constructor(cache: CapabilityCache);
|
|
69
|
-
lookup(modelId: string, provider?: string): Promise<SourceResult>;
|
|
70
|
-
isAvailable(): Promise<boolean>;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
declare class RemoteCapabilityFetcher {
|
|
74
|
-
private apiUrl;
|
|
75
|
-
private timeoutMs;
|
|
76
|
-
private cache;
|
|
77
|
-
private lastFetchTime;
|
|
78
|
-
private minFetchInterval;
|
|
79
|
-
constructor(cache: CapabilityCache, options?: Partial<ResolverOptions>);
|
|
80
|
-
fetchAll(): Promise<ModelEntry[]>;
|
|
81
|
-
ping(): Promise<boolean>;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
declare class RemoteCapabilitySource implements CapabilitySource {
|
|
85
|
-
readonly priority = SourcePriority.RemoteAPI;
|
|
86
|
-
readonly name = "Remote API (models.dev)";
|
|
87
|
-
private fetcher;
|
|
88
|
-
private cache;
|
|
89
|
-
private fetchPromise;
|
|
90
|
-
private enabled;
|
|
91
|
-
constructor(cache: CapabilityCache, options?: Partial<ResolverOptions>);
|
|
92
|
-
lookup(modelId: string, provider?: string): Promise<SourceResult>;
|
|
93
|
-
isAvailable(): Promise<boolean>;
|
|
94
|
-
refresh(): Promise<void>;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export { CacheCapabilitySource, CapabilityCache, type CapabilityOverrides, CapabilitySource, ModelCapabilities, ModelEntry, PatternCapabilitySource, ProviderCompatibility, RemoteCapabilityFetcher, RemoteCapabilitySource, ResolverOptions, SourcePriority, SourceResult, applyCapabilityOverride, findCapabilityOverride, getProviderCompatibility, inferProvider, likelySupportsReasoning };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CacheCapabilitySource,
|
|
3
|
-
CapabilityCache,
|
|
4
|
-
DEFAULT_RESOLVER_OPTIONS,
|
|
5
|
-
ModelCapabilityResolver,
|
|
6
|
-
PatternCapabilitySource,
|
|
7
|
-
RemoteCapabilityFetcher,
|
|
8
|
-
RemoteCapabilitySource,
|
|
9
|
-
SourcePriority,
|
|
10
|
-
applyCapabilityOverride,
|
|
11
|
-
configureResolver,
|
|
12
|
-
extractModelId,
|
|
13
|
-
extractProvider,
|
|
14
|
-
findCapabilityOverride,
|
|
15
|
-
getDefaultResolver,
|
|
16
|
-
getNetworkStatus,
|
|
17
|
-
getProviderCompatibility,
|
|
18
|
-
inferProvider,
|
|
19
|
-
likelySupportsReasoning
|
|
20
|
-
} from "../chunk-QWFMX226.js";
|
|
21
|
-
import {
|
|
22
|
-
getModelId,
|
|
23
|
-
getProviderId
|
|
24
|
-
} from "../chunk-DWYX7ASF.js";
|
|
25
|
-
export {
|
|
26
|
-
CacheCapabilitySource,
|
|
27
|
-
CapabilityCache,
|
|
28
|
-
DEFAULT_RESOLVER_OPTIONS,
|
|
29
|
-
ModelCapabilityResolver,
|
|
30
|
-
PatternCapabilitySource,
|
|
31
|
-
RemoteCapabilityFetcher,
|
|
32
|
-
RemoteCapabilitySource,
|
|
33
|
-
SourcePriority,
|
|
34
|
-
applyCapabilityOverride,
|
|
35
|
-
configureResolver,
|
|
36
|
-
extractModelId,
|
|
37
|
-
extractProvider,
|
|
38
|
-
findCapabilityOverride,
|
|
39
|
-
getDefaultResolver,
|
|
40
|
-
getModelId,
|
|
41
|
-
getNetworkStatus,
|
|
42
|
-
getProviderCompatibility,
|
|
43
|
-
getProviderId,
|
|
44
|
-
inferProvider,
|
|
45
|
-
likelySupportsReasoning
|
|
46
|
-
};
|
package/dist/chunk-6TDTQJ4P.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
// src/models/resolver.ts
|
|
2
|
-
function parseKey(input) {
|
|
3
|
-
const [engineId, ...rest] = input.split("/");
|
|
4
|
-
if (!engineId || rest.length === 0) return null;
|
|
5
|
-
return { engineId, modelId: rest.join("/") };
|
|
6
|
-
}
|
|
7
|
-
function mergeSettings(base, override) {
|
|
8
|
-
return {
|
|
9
|
-
apiKey: override?.apiKey ?? base?.apiKey,
|
|
10
|
-
baseUrl: override?.baseUrl ?? base?.baseUrl,
|
|
11
|
-
headers: {
|
|
12
|
-
...base?.headers ?? {},
|
|
13
|
-
...override?.headers ?? {}
|
|
14
|
-
},
|
|
15
|
-
extra: {
|
|
16
|
-
...base?.extra ?? {},
|
|
17
|
-
...override?.extra ?? {}
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function settingsKey(settings, adapter, engineId) {
|
|
22
|
-
return JSON.stringify({
|
|
23
|
-
engineId,
|
|
24
|
-
adapter,
|
|
25
|
-
apiKey: settings.apiKey ?? "",
|
|
26
|
-
baseUrl: settings.baseUrl ?? "",
|
|
27
|
-
headers: settings.headers ?? {},
|
|
28
|
-
extra: settings.extra ?? {}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
function buildOptions(settings) {
|
|
32
|
-
const opts = { ...settings.extra ?? {} };
|
|
33
|
-
if (settings.apiKey) opts.apiKey = settings.apiKey;
|
|
34
|
-
if (settings.baseUrl) opts.baseURL = settings.baseUrl;
|
|
35
|
-
if (settings.headers && Object.keys(settings.headers).length > 0) opts.headers = settings.headers;
|
|
36
|
-
return opts;
|
|
37
|
-
}
|
|
38
|
-
async function createFactory(adapter, settings) {
|
|
39
|
-
const asModel = (m) => m;
|
|
40
|
-
const opts = buildOptions(settings);
|
|
41
|
-
switch (adapter) {
|
|
42
|
-
case "openai": {
|
|
43
|
-
const { createOpenAI } = await import("@ai-sdk/openai").catch(() => {
|
|
44
|
-
throw new Error(
|
|
45
|
-
`Provider "@ai-sdk/openai" is required for the "openai" adapter. Install it with: pnpm add @ai-sdk/openai`
|
|
46
|
-
);
|
|
47
|
-
});
|
|
48
|
-
const provider = createOpenAI(opts);
|
|
49
|
-
return (modelId) => provider.languageModel(modelId);
|
|
50
|
-
}
|
|
51
|
-
case "anthropic": {
|
|
52
|
-
const { createAnthropic } = await import("@ai-sdk/anthropic").catch(() => {
|
|
53
|
-
throw new Error(
|
|
54
|
-
`Provider "@ai-sdk/anthropic" is required for the "anthropic" adapter. Install it with: pnpm add @ai-sdk/anthropic`
|
|
55
|
-
);
|
|
56
|
-
});
|
|
57
|
-
const provider = createAnthropic(opts);
|
|
58
|
-
return (modelId) => provider.languageModel(modelId);
|
|
59
|
-
}
|
|
60
|
-
case "google": {
|
|
61
|
-
const { createGoogleGenerativeAI } = await import("@ai-sdk/google").catch(() => {
|
|
62
|
-
throw new Error(
|
|
63
|
-
`Provider "@ai-sdk/google" is required for the "google" adapter. Install it with: pnpm add @ai-sdk/google`
|
|
64
|
-
);
|
|
65
|
-
});
|
|
66
|
-
const provider = createGoogleGenerativeAI(opts);
|
|
67
|
-
return (modelId) => asModel(provider.languageModel(modelId));
|
|
68
|
-
}
|
|
69
|
-
case "openai-compatible": {
|
|
70
|
-
const { createOpenAICompatible } = await import("@ai-sdk/openai-compatible").catch(() => {
|
|
71
|
-
throw new Error(
|
|
72
|
-
`Provider "@ai-sdk/openai-compatible" is required for the "openai-compatible" adapter. Install it with: pnpm add @ai-sdk/openai-compatible`
|
|
73
|
-
);
|
|
74
|
-
});
|
|
75
|
-
const provider = createOpenAICompatible({
|
|
76
|
-
name: opts.name ?? "custom",
|
|
77
|
-
baseURL: opts.baseURL ?? "",
|
|
78
|
-
...opts.apiKey ? { apiKey: opts.apiKey } : {},
|
|
79
|
-
...opts.headers ? { headers: opts.headers } : {}
|
|
80
|
-
});
|
|
81
|
-
return (modelId) => provider.languageModel(modelId);
|
|
82
|
-
}
|
|
83
|
-
default:
|
|
84
|
-
throw new Error(`No factory registered for adapter: ${adapter}`);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function createResolver(directory) {
|
|
88
|
-
const factoryCache = /* @__PURE__ */ new Map();
|
|
89
|
-
return async (key) => {
|
|
90
|
-
const parsed = parseKey(key);
|
|
91
|
-
const entry = parsed ? void 0 : directory.entries?.[key];
|
|
92
|
-
const engineId = parsed?.engineId ?? entry?.engine;
|
|
93
|
-
const modelId = parsed?.modelId ?? entry?.id;
|
|
94
|
-
if (!engineId || !modelId) {
|
|
95
|
-
throw new Error(`Unknown model reference: ${key}`);
|
|
96
|
-
}
|
|
97
|
-
const engine = directory.engines[engineId];
|
|
98
|
-
if (!engine) {
|
|
99
|
-
throw new Error(`Unknown engine: ${engineId}`);
|
|
100
|
-
}
|
|
101
|
-
const settings = mergeSettings(engine.settings, entry?.settings);
|
|
102
|
-
if (engine.build) {
|
|
103
|
-
return engine.build(modelId, settings);
|
|
104
|
-
}
|
|
105
|
-
const cacheKey = settingsKey(settings, engine.adapter, engineId);
|
|
106
|
-
const cached = factoryCache.get(cacheKey);
|
|
107
|
-
if (cached) return cached(modelId);
|
|
108
|
-
const factory = await createFactory(engine.adapter, settings);
|
|
109
|
-
factoryCache.set(cacheKey, factory);
|
|
110
|
-
return factory(modelId);
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export {
|
|
115
|
-
createResolver
|
|
116
|
-
};
|
package/dist/chunk-DWYX7ASF.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// src/models/identifiers.ts
|
|
2
|
-
function getModelId(model) {
|
|
3
|
-
if (typeof model === "string") return model;
|
|
4
|
-
if (typeof model === "object" && model !== null && "modelId" in model) {
|
|
5
|
-
return String(model.modelId);
|
|
6
|
-
}
|
|
7
|
-
return String(model);
|
|
8
|
-
}
|
|
9
|
-
function getProviderId(model) {
|
|
10
|
-
if (typeof model === "string") {
|
|
11
|
-
if (model.includes("/")) {
|
|
12
|
-
return model.split("/")[0];
|
|
13
|
-
}
|
|
14
|
-
return void 0;
|
|
15
|
-
}
|
|
16
|
-
if (typeof model === "object" && model !== null && "provider" in model) {
|
|
17
|
-
const provider = String(model.provider);
|
|
18
|
-
return provider.split(".")[0];
|
|
19
|
-
}
|
|
20
|
-
return void 0;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export {
|
|
24
|
-
getModelId,
|
|
25
|
-
getProviderId
|
|
26
|
-
};
|
package/dist/chunk-FG4MD5MU.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
extractFilePathsFromArgs,
|
|
3
|
-
shouldCaptureBaseline
|
|
4
|
-
} from "./chunk-VEKUXUVF.js";
|
|
5
|
-
|
|
6
|
-
// src/tool/executor.ts
|
|
7
|
-
async function executeAgentToolCall(options) {
|
|
8
|
-
const initialized = await options.tool.init({ cwd: options.cwd });
|
|
9
|
-
const ctx = {
|
|
10
|
-
cwd: options.cwd,
|
|
11
|
-
abort: options.abort,
|
|
12
|
-
sessionID: options.sessionID,
|
|
13
|
-
messageID: options.messageID,
|
|
14
|
-
agent: options.agent ?? "default",
|
|
15
|
-
...options.host ? { host: options.host } : {},
|
|
16
|
-
...options.turnTracker ? { turnTracker: options.turnTracker } : {}
|
|
17
|
-
};
|
|
18
|
-
if (options.middleware?.hasMiddleware) {
|
|
19
|
-
const decision = await options.middleware.runBeforeToolCall(
|
|
20
|
-
options.toolName,
|
|
21
|
-
options.params,
|
|
22
|
-
ctx
|
|
23
|
-
);
|
|
24
|
-
if (decision.action === "deny") {
|
|
25
|
-
return {
|
|
26
|
-
output: decision.reason ?? `Tool call denied: ${options.toolName}`
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
if (options.turnTracker && initialized.fileOps && shouldCaptureBaseline(initialized.fileOps)) {
|
|
31
|
-
const paths = extractFilePathsFromArgs(
|
|
32
|
-
options.params,
|
|
33
|
-
initialized.fileOps
|
|
34
|
-
);
|
|
35
|
-
for (const path of paths) {
|
|
36
|
-
await options.turnTracker.beforeWrite(path);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const result = await initialized.execute(options.params, ctx);
|
|
40
|
-
if (options.middleware?.hasMiddleware) {
|
|
41
|
-
const transformed = await options.middleware.runAfterToolCall(
|
|
42
|
-
options.toolName,
|
|
43
|
-
options.params,
|
|
44
|
-
result,
|
|
45
|
-
ctx
|
|
46
|
-
);
|
|
47
|
-
return { output: transformed.output };
|
|
48
|
-
}
|
|
49
|
-
return { output: result.output };
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export {
|
|
53
|
-
executeAgentToolCall
|
|
54
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { LanguageModel } from 'ai';
|
|
2
|
-
import { ProviderOptions } from '@ai-sdk/provider-utils';
|
|
3
|
-
import { R as ReasoningLevel, a as ReasoningConfig } from './types-CQaXbRsS.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Reasoning Configuration & Option Builders
|
|
7
|
-
*
|
|
8
|
-
* Orchestrates capability detection and provider-specific option
|
|
9
|
-
* building to produce ready-to-use `providerOptions` for the
|
|
10
|
-
* Vercel AI SDK.
|
|
11
|
-
*
|
|
12
|
-
* Two flavours of every function are provided:
|
|
13
|
-
* - **Async** (`getReasoningConfig`, `buildReasoningOptions`) —
|
|
14
|
-
* uses the full capability resolver (network + cache).
|
|
15
|
-
* - **Sync** (`getReasoningConfigSync`, `buildReasoningOptionsSync`) —
|
|
16
|
-
* uses fast pattern-matching only (no network).
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Get the reasoning configuration for a model.
|
|
21
|
-
*
|
|
22
|
-
* Uses the full capability resolver (including network lookups)
|
|
23
|
-
* for the most accurate result.
|
|
24
|
-
*/
|
|
25
|
-
declare function getReasoningConfig(model: LanguageModel): Promise<ReasoningConfig>;
|
|
26
|
-
/**
|
|
27
|
-
* Synchronous reasoning config using pattern-matching only.
|
|
28
|
-
*
|
|
29
|
-
* Faster but less accurate than {@link getReasoningConfig}.
|
|
30
|
-
* Good for hot paths where async is impractical.
|
|
31
|
-
*/
|
|
32
|
-
declare function getReasoningConfigSync(model: LanguageModel): ReasoningConfig;
|
|
33
|
-
/**
|
|
34
|
-
* Build `providerOptions` for a reasoning level (async).
|
|
35
|
-
*
|
|
36
|
-
* Returns `undefined` when reasoning is off or unsupported.
|
|
37
|
-
*/
|
|
38
|
-
declare function buildReasoningOptions(model: LanguageModel, level: ReasoningLevel): Promise<ProviderOptions | undefined>;
|
|
39
|
-
/**
|
|
40
|
-
* Build `providerOptions` for a reasoning level (sync / pattern-only).
|
|
41
|
-
*/
|
|
42
|
-
declare function buildReasoningOptionsSync(model: LanguageModel, level: ReasoningLevel): ProviderOptions | undefined;
|
|
43
|
-
/**
|
|
44
|
-
* Check whether a model supports reasoning (async, full resolver).
|
|
45
|
-
*/
|
|
46
|
-
declare function supportsReasoning(model: LanguageModel): Promise<boolean>;
|
|
47
|
-
/**
|
|
48
|
-
* Synchronous check using pattern-matching only.
|
|
49
|
-
*/
|
|
50
|
-
declare function supportsReasoningSync(model: LanguageModel): boolean;
|
|
51
|
-
|
|
52
|
-
export { buildReasoningOptionsSync as a, buildReasoningOptions as b, getReasoningConfigSync as c, supportsReasoningSync as d, getReasoningConfig as g, supportsReasoning as s };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { LanguageModel } from 'ai';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Extract a model ID string from a LanguageModel instance.
|
|
5
|
-
*/
|
|
6
|
-
declare function getModelId(model: LanguageModel): string;
|
|
7
|
-
/**
|
|
8
|
-
* Extract a provider identifier from a LanguageModel instance.
|
|
9
|
-
*/
|
|
10
|
-
declare function getProviderId(model: LanguageModel): string | undefined;
|
|
11
|
-
|
|
12
|
-
export { getProviderId as a, getModelId as g };
|