unagent 0.0.3 → 0.0.4
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/{git-BczcRFau.mjs → clone-DgXhqC05.mjs} +7 -86
- package/dist/context/index.d.mts +2 -0
- package/dist/context/index.mjs +3 -0
- package/dist/context-CAk5kS7q.mjs +59 -0
- package/dist/{env-BcNA2wGd.mjs → detect-CDtKsCsD.mjs} +1 -1
- package/dist/env/index.d.mts +1 -1
- package/dist/env/index.mjs +3 -2
- package/dist/env-DeXFcrWN.mjs +1 -0
- package/dist/exec/index.d.mts +2 -0
- package/dist/exec/index.mjs +3 -0
- package/dist/exec-Dzl5r4Ui.mjs +116 -0
- package/dist/fs/index.d.mts +2 -0
- package/dist/fs/index.mjs +3 -0
- package/dist/fs-nJz4v9pE.mjs +269 -0
- package/dist/git/index.d.mts +1 -1
- package/dist/git/index.mjs +2 -1
- package/dist/git-D3qsdy9d.mjs +86 -0
- package/dist/hooks/index.d.mts +3 -0
- package/dist/hooks/index.mjs +3 -0
- package/dist/hooks-335rp9Cp.mjs +9 -0
- package/dist/index-BZaywR9E.d.mts +97 -0
- package/dist/index-Bd1gSwMB.d.mts +31 -0
- package/dist/index-Bd4x_1H9.d.mts +33 -0
- package/dist/index-C0ulBa5T.d.mts +21 -0
- package/dist/index-Csv1G0zj.d.mts +36 -0
- package/dist/index-CvCCCs-_.d.mts +20 -0
- package/dist/index-D5A0wwzb.d.mts +55 -0
- package/dist/index-DFqD_DAh.d.mts +80 -0
- package/dist/index-DShEKmmL.d.mts +43 -0
- package/dist/index-DpFup4kC.d.mts +21 -0
- package/dist/index-ucMWydcs.d.mts +19 -0
- package/dist/index.d.mts +18 -8
- package/dist/index.mjs +23 -9
- package/dist/link/index.d.mts +1 -1
- package/dist/link/index.mjs +2 -1
- package/dist/link-BRZABZ3A.mjs +1 -0
- package/dist/lock/index.d.mts +1 -1
- package/dist/lock/index.mjs +1 -1
- package/dist/registry/index.d.mts +2 -0
- package/dist/registry/index.mjs +3 -0
- package/dist/registry-DvxT2enn.mjs +30 -0
- package/dist/sandbox/index.d.mts +2 -0
- package/dist/sandbox/index.mjs +3 -0
- package/dist/sandbox-Dyz9jTaL.mjs +139 -0
- package/dist/skill/index.d.mts +2 -2
- package/dist/skill/index.mjs +8 -2
- package/dist/skill-BnKVgm4n.mjs +358 -0
- package/dist/source/index.d.mts +1 -1
- package/dist/source/index.mjs +2 -1
- package/dist/source-BCRylzkW.mjs +1 -0
- package/dist/stop/index.d.mts +3 -0
- package/dist/stop/index.mjs +4 -0
- package/dist/stop-B9w8PiPj.mjs +39 -0
- package/dist/stream/index.d.mts +3 -0
- package/dist/stream/index.mjs +3 -0
- package/dist/stream-CzGvLSeV.mjs +99 -0
- package/dist/tool/index.d.mts +2 -0
- package/dist/tool/index.mjs +3 -0
- package/dist/tool-CESxMfOv.mjs +45 -0
- package/dist/usage/index.d.mts +2 -0
- package/dist/usage/index.mjs +3 -0
- package/dist/usage-DTaeWIUK.mjs +165 -0
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.mjs +2 -2
- package/package.json +64 -7
- package/dist/index-BT7sxFbS.d.mts +0 -47
- package/dist/skill-Bnz84tJ5.mjs +0 -125
- /package/dist/{index-C9yyPAid.d.mts → index-C55JaUgw.d.mts} +0 -0
- /package/dist/{index-CzPUtptc.d.mts → index-CbYchDwg.d.mts} +0 -0
- /package/dist/{index-1wm94iym.d.mts → index-Cy8LThTV.d.mts} +0 -0
- /package/dist/{index-Bzc-AUnz.d.mts → index-CzgY9GU2.d.mts} +0 -0
- /package/dist/{index-QWAv-PAT.d.mts → index-DPt7J0hF.d.mts} +0 -0
- /package/dist/{index-BMUPEJgp.d.mts → index-wTumcHrH.d.mts} +0 -0
- /package/dist/{lock-B07ZofNa.mjs → lock-CB9Xr9pv.mjs} +0 -0
- /package/dist/{source-uxXVyVOh.mjs → parse-CEbeorIB.mjs} +0 -0
- /package/dist/{path-D5oePhrf.mjs → path-Dm-URQvz.mjs} +0 -0
- /package/dist/{link-CnwXkdzo.mjs → symlink-CbP-heyc.mjs} +0 -0
- /package/dist/{utils-BpTrIde9.mjs → utils-bP3i6rq3.mjs} +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { r as calculateCost } from "./usage-DTaeWIUK.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/stop/index.ts
|
|
4
|
+
function iterationCountIs(max) {
|
|
5
|
+
return (ctx) => ctx.iteration >= max;
|
|
6
|
+
}
|
|
7
|
+
function tokenCountIs(max) {
|
|
8
|
+
return (ctx) => {
|
|
9
|
+
if (!ctx.usage) return false;
|
|
10
|
+
return ctx.usage.inputTokens + ctx.usage.outputTokens >= max;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function costIs(maxDollars, rates) {
|
|
14
|
+
return (ctx) => {
|
|
15
|
+
if (!ctx.usage) return false;
|
|
16
|
+
return calculateCost(ctx.usage, rates) >= maxDollars;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function timeout(ms) {
|
|
20
|
+
return (ctx) => Date.now() - ctx.startTime >= ms;
|
|
21
|
+
}
|
|
22
|
+
function and(...conditions) {
|
|
23
|
+
return async (ctx) => {
|
|
24
|
+
for (const condition of conditions) if (!await condition(ctx)) return false;
|
|
25
|
+
return true;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function or(...conditions) {
|
|
29
|
+
return async (ctx) => {
|
|
30
|
+
for (const condition of conditions) if (await condition(ctx)) return true;
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function not(condition) {
|
|
35
|
+
return async (ctx) => !await condition(ctx);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { or as a, not as i, costIs as n, timeout as o, iterationCountIs as r, tokenCountIs as s, and as t };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import "../index-ucMWydcs.mjs";
|
|
2
|
+
import { a as createStreamResult, i as StreamResultOptions, n as StreamPart, o as formatSSE, r as StreamResult, s as parseSSE, t as SSEParser } from "../index-D5A0wwzb.mjs";
|
|
3
|
+
export { SSEParser, StreamPart, StreamResult, StreamResultOptions, createStreamResult, formatSSE, parseSSE };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
//#region src/stream/index.ts
|
|
2
|
+
function createStreamResult(options) {
|
|
3
|
+
const { stream, getValue } = options;
|
|
4
|
+
let consumed = false;
|
|
5
|
+
const parts = [];
|
|
6
|
+
async function* wrapStream() {
|
|
7
|
+
for await (const part of stream) {
|
|
8
|
+
parts.push(part);
|
|
9
|
+
yield part;
|
|
10
|
+
}
|
|
11
|
+
consumed = true;
|
|
12
|
+
}
|
|
13
|
+
const wrappedStream = wrapStream();
|
|
14
|
+
return {
|
|
15
|
+
get value() {
|
|
16
|
+
return getValue();
|
|
17
|
+
},
|
|
18
|
+
get stream() {
|
|
19
|
+
return wrappedStream;
|
|
20
|
+
},
|
|
21
|
+
toResponse() {
|
|
22
|
+
const encoder = new TextEncoder();
|
|
23
|
+
const readable = new ReadableStream({ async start(controller) {
|
|
24
|
+
for await (const part of wrappedStream) if (part.type === "text") controller.enqueue(encoder.encode(part.data));
|
|
25
|
+
controller.close();
|
|
26
|
+
} });
|
|
27
|
+
return new Response(readable, { headers: { "Content-Type": "text/plain; charset=utf-8" } });
|
|
28
|
+
},
|
|
29
|
+
toSSEResponse() {
|
|
30
|
+
const encoder = new TextEncoder();
|
|
31
|
+
const readable = new ReadableStream({ async start(controller) {
|
|
32
|
+
for await (const part of wrappedStream) {
|
|
33
|
+
const data = part.type === "error" ? {
|
|
34
|
+
type: part.type,
|
|
35
|
+
data: { message: part.data.message }
|
|
36
|
+
} : part;
|
|
37
|
+
controller.enqueue(encoder.encode(formatSSE(part.type, data)));
|
|
38
|
+
}
|
|
39
|
+
controller.close();
|
|
40
|
+
} });
|
|
41
|
+
return new Response(readable, { headers: {
|
|
42
|
+
"Content-Type": "text/event-stream",
|
|
43
|
+
"Cache-Control": "no-cache",
|
|
44
|
+
"Connection": "keep-alive"
|
|
45
|
+
} });
|
|
46
|
+
},
|
|
47
|
+
async consumeStream() {
|
|
48
|
+
if (consumed) return;
|
|
49
|
+
for await (const _part of wrappedStream);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function formatSSE(event, data) {
|
|
54
|
+
return `event: ${event}\ndata: ${JSON.stringify(data)}\n\n`;
|
|
55
|
+
}
|
|
56
|
+
function parseSSE(line) {
|
|
57
|
+
const trimmed = line.trim();
|
|
58
|
+
if (!trimmed || trimmed.startsWith(":")) return null;
|
|
59
|
+
if (trimmed.startsWith("event:")) return { event: trimmed.slice(6).trim() };
|
|
60
|
+
if (trimmed.startsWith("data:")) return { data: trimmed.slice(5).trim() };
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
var SSEParser = class {
|
|
64
|
+
currentEvent;
|
|
65
|
+
dataBuffer = [];
|
|
66
|
+
parse(chunk) {
|
|
67
|
+
const results = [];
|
|
68
|
+
const lines = chunk.split("\n");
|
|
69
|
+
for (const line of lines) {
|
|
70
|
+
const trimmed = line.trim();
|
|
71
|
+
if (!trimmed) {
|
|
72
|
+
if (this.dataBuffer.length > 0) {
|
|
73
|
+
const dataStr = this.dataBuffer.join("\n");
|
|
74
|
+
try {
|
|
75
|
+
results.push({
|
|
76
|
+
event: this.currentEvent,
|
|
77
|
+
data: JSON.parse(dataStr)
|
|
78
|
+
});
|
|
79
|
+
} catch {
|
|
80
|
+
results.push({
|
|
81
|
+
event: this.currentEvent,
|
|
82
|
+
data: dataStr
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
this.currentEvent = void 0;
|
|
86
|
+
this.dataBuffer = [];
|
|
87
|
+
}
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (trimmed.startsWith(":")) continue;
|
|
91
|
+
if (trimmed.startsWith("event:")) this.currentEvent = trimmed.slice(6).trim();
|
|
92
|
+
else if (trimmed.startsWith("data:")) this.dataBuffer.push(trimmed.slice(5).trim());
|
|
93
|
+
}
|
|
94
|
+
return results;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
//#endregion
|
|
99
|
+
export { parseSSE as i, createStreamResult as n, formatSSE as r, SSEParser as t };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as defineTool, i as ToolParameter, n as JSONSchemaProperty, o as toolToSchema, r as ToolDefinition, s as toolsToSchema, t as JSONSchema } from "../index-DShEKmmL.mjs";
|
|
2
|
+
export { JSONSchema, JSONSchemaProperty, ToolDefinition, ToolParameter, defineTool, toolToSchema, toolsToSchema };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//#region src/tool/index.ts
|
|
2
|
+
function defineTool(tool) {
|
|
3
|
+
return tool;
|
|
4
|
+
}
|
|
5
|
+
function parameterToJSONSchema(param) {
|
|
6
|
+
const schema = { type: param.type };
|
|
7
|
+
if (param.description) schema.description = param.description;
|
|
8
|
+
if (param.enum) schema.enum = param.enum;
|
|
9
|
+
if (param.default !== void 0) schema.default = param.default;
|
|
10
|
+
if (param.type === "array" && param.items) schema.items = parameterToJSONSchema(param.items);
|
|
11
|
+
if (param.type === "object" && param.properties) {
|
|
12
|
+
schema.properties = {};
|
|
13
|
+
const required = [];
|
|
14
|
+
for (const [key, value] of Object.entries(param.properties)) {
|
|
15
|
+
schema.properties[key] = parameterToJSONSchema(value);
|
|
16
|
+
if (value.required) required.push(key);
|
|
17
|
+
}
|
|
18
|
+
if (required.length > 0) schema.required = required;
|
|
19
|
+
}
|
|
20
|
+
return schema;
|
|
21
|
+
}
|
|
22
|
+
function toolToSchema(tool) {
|
|
23
|
+
const properties = {};
|
|
24
|
+
const required = [];
|
|
25
|
+
if (tool.parameters) for (const [key, param] of Object.entries(tool.parameters)) {
|
|
26
|
+
properties[key] = parameterToJSONSchema(param);
|
|
27
|
+
if (param.required) required.push(key);
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
name: tool.name,
|
|
31
|
+
description: tool.description,
|
|
32
|
+
input_schema: {
|
|
33
|
+
type: "object",
|
|
34
|
+
properties,
|
|
35
|
+
...required.length > 0 ? { required } : {},
|
|
36
|
+
additionalProperties: false
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function toolsToSchema(tools) {
|
|
41
|
+
return tools.map(toolToSchema);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { toolToSchema as n, toolsToSchema as r, defineTool as t };
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
//#region src/usage/index.ts
|
|
2
|
+
function calculateCost(usage, rates) {
|
|
3
|
+
let cost = 0;
|
|
4
|
+
cost += usage.inputTokens / 1e6 * rates.inputCostPerMillionTokens;
|
|
5
|
+
cost += usage.outputTokens / 1e6 * rates.outputCostPerMillionTokens;
|
|
6
|
+
if (usage.cacheReadTokens && rates.cacheReadCostPerMillionTokens) cost += usage.cacheReadTokens / 1e6 * rates.cacheReadCostPerMillionTokens;
|
|
7
|
+
if (usage.cacheWriteTokens && rates.cacheWriteCostPerMillionTokens) cost += usage.cacheWriteTokens / 1e6 * rates.cacheWriteCostPerMillionTokens;
|
|
8
|
+
return cost;
|
|
9
|
+
}
|
|
10
|
+
function aggregateUsage(...usages) {
|
|
11
|
+
const result = usages.reduce((acc, usage) => ({
|
|
12
|
+
inputTokens: acc.inputTokens + usage.inputTokens,
|
|
13
|
+
outputTokens: acc.outputTokens + usage.outputTokens,
|
|
14
|
+
cacheReadTokens: (acc.cacheReadTokens ?? 0) + (usage.cacheReadTokens ?? 0),
|
|
15
|
+
cacheWriteTokens: (acc.cacheWriteTokens ?? 0) + (usage.cacheWriteTokens ?? 0)
|
|
16
|
+
}), {
|
|
17
|
+
inputTokens: 0,
|
|
18
|
+
outputTokens: 0,
|
|
19
|
+
cacheReadTokens: 0,
|
|
20
|
+
cacheWriteTokens: 0
|
|
21
|
+
});
|
|
22
|
+
const hasCacheRead = usages.some((u) => u.cacheReadTokens !== void 0);
|
|
23
|
+
const hasCacheWrite = usages.some((u) => u.cacheWriteTokens !== void 0);
|
|
24
|
+
return {
|
|
25
|
+
inputTokens: result.inputTokens,
|
|
26
|
+
outputTokens: result.outputTokens,
|
|
27
|
+
...hasCacheRead && { cacheReadTokens: result.cacheReadTokens },
|
|
28
|
+
...hasCacheWrite && { cacheWriteTokens: result.cacheWriteTokens }
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const MODEL_PRICING = {
|
|
32
|
+
"claude-opus-4-20250514": {
|
|
33
|
+
inputCostPerMillionTokens: 15,
|
|
34
|
+
outputCostPerMillionTokens: 75,
|
|
35
|
+
cacheReadCostPerMillionTokens: 1.5,
|
|
36
|
+
cacheWriteCostPerMillionTokens: 18.75
|
|
37
|
+
},
|
|
38
|
+
"claude-sonnet-4-20250514": {
|
|
39
|
+
inputCostPerMillionTokens: 3,
|
|
40
|
+
outputCostPerMillionTokens: 15,
|
|
41
|
+
cacheReadCostPerMillionTokens: .3,
|
|
42
|
+
cacheWriteCostPerMillionTokens: 3.75
|
|
43
|
+
},
|
|
44
|
+
"claude-3-7-sonnet-20250219": {
|
|
45
|
+
inputCostPerMillionTokens: 3,
|
|
46
|
+
outputCostPerMillionTokens: 15,
|
|
47
|
+
cacheReadCostPerMillionTokens: .3,
|
|
48
|
+
cacheWriteCostPerMillionTokens: 3.75
|
|
49
|
+
},
|
|
50
|
+
"claude-3-5-sonnet-20241022": {
|
|
51
|
+
inputCostPerMillionTokens: 3,
|
|
52
|
+
outputCostPerMillionTokens: 15,
|
|
53
|
+
cacheReadCostPerMillionTokens: .3,
|
|
54
|
+
cacheWriteCostPerMillionTokens: 3.75
|
|
55
|
+
},
|
|
56
|
+
"claude-3-5-haiku-20241022": {
|
|
57
|
+
inputCostPerMillionTokens: .8,
|
|
58
|
+
outputCostPerMillionTokens: 4,
|
|
59
|
+
cacheReadCostPerMillionTokens: .08,
|
|
60
|
+
cacheWriteCostPerMillionTokens: 1
|
|
61
|
+
},
|
|
62
|
+
"claude-3-opus-20240229": {
|
|
63
|
+
inputCostPerMillionTokens: 15,
|
|
64
|
+
outputCostPerMillionTokens: 75,
|
|
65
|
+
cacheReadCostPerMillionTokens: 1.5,
|
|
66
|
+
cacheWriteCostPerMillionTokens: 18.75
|
|
67
|
+
},
|
|
68
|
+
"claude-3-haiku-20240307": {
|
|
69
|
+
inputCostPerMillionTokens: .25,
|
|
70
|
+
outputCostPerMillionTokens: 1.25,
|
|
71
|
+
cacheReadCostPerMillionTokens: .03,
|
|
72
|
+
cacheWriteCostPerMillionTokens: .3
|
|
73
|
+
},
|
|
74
|
+
"gpt-4o": {
|
|
75
|
+
inputCostPerMillionTokens: 2.5,
|
|
76
|
+
outputCostPerMillionTokens: 10
|
|
77
|
+
},
|
|
78
|
+
"gpt-4o-mini": {
|
|
79
|
+
inputCostPerMillionTokens: .15,
|
|
80
|
+
outputCostPerMillionTokens: .6
|
|
81
|
+
},
|
|
82
|
+
"gpt-4-turbo": {
|
|
83
|
+
inputCostPerMillionTokens: 10,
|
|
84
|
+
outputCostPerMillionTokens: 30
|
|
85
|
+
},
|
|
86
|
+
"gpt-4": {
|
|
87
|
+
inputCostPerMillionTokens: 30,
|
|
88
|
+
outputCostPerMillionTokens: 60
|
|
89
|
+
},
|
|
90
|
+
"gpt-3.5-turbo": {
|
|
91
|
+
inputCostPerMillionTokens: .5,
|
|
92
|
+
outputCostPerMillionTokens: 1.5
|
|
93
|
+
},
|
|
94
|
+
"o1": {
|
|
95
|
+
inputCostPerMillionTokens: 15,
|
|
96
|
+
outputCostPerMillionTokens: 60
|
|
97
|
+
},
|
|
98
|
+
"o1-mini": {
|
|
99
|
+
inputCostPerMillionTokens: 3,
|
|
100
|
+
outputCostPerMillionTokens: 12
|
|
101
|
+
},
|
|
102
|
+
"o3-mini": {
|
|
103
|
+
inputCostPerMillionTokens: 1.1,
|
|
104
|
+
outputCostPerMillionTokens: 4.4
|
|
105
|
+
},
|
|
106
|
+
"gemini-2.0-flash": {
|
|
107
|
+
inputCostPerMillionTokens: .1,
|
|
108
|
+
outputCostPerMillionTokens: .4
|
|
109
|
+
},
|
|
110
|
+
"gemini-1.5-pro": {
|
|
111
|
+
inputCostPerMillionTokens: 1.25,
|
|
112
|
+
outputCostPerMillionTokens: 5
|
|
113
|
+
},
|
|
114
|
+
"gemini-1.5-flash": {
|
|
115
|
+
inputCostPerMillionTokens: .075,
|
|
116
|
+
outputCostPerMillionTokens: .3
|
|
117
|
+
},
|
|
118
|
+
"mistral-large": {
|
|
119
|
+
inputCostPerMillionTokens: 2,
|
|
120
|
+
outputCostPerMillionTokens: 6
|
|
121
|
+
},
|
|
122
|
+
"mistral-small": {
|
|
123
|
+
inputCostPerMillionTokens: .2,
|
|
124
|
+
outputCostPerMillionTokens: .6
|
|
125
|
+
},
|
|
126
|
+
"codestral": {
|
|
127
|
+
inputCostPerMillionTokens: .3,
|
|
128
|
+
outputCostPerMillionTokens: .9
|
|
129
|
+
},
|
|
130
|
+
"command-r-plus": {
|
|
131
|
+
inputCostPerMillionTokens: 2.5,
|
|
132
|
+
outputCostPerMillionTokens: 10
|
|
133
|
+
},
|
|
134
|
+
"command-r": {
|
|
135
|
+
inputCostPerMillionTokens: .15,
|
|
136
|
+
outputCostPerMillionTokens: .6
|
|
137
|
+
},
|
|
138
|
+
"llama-3.1-405b": {
|
|
139
|
+
inputCostPerMillionTokens: 3,
|
|
140
|
+
outputCostPerMillionTokens: 3
|
|
141
|
+
},
|
|
142
|
+
"llama-3.1-70b": {
|
|
143
|
+
inputCostPerMillionTokens: .88,
|
|
144
|
+
outputCostPerMillionTokens: .88
|
|
145
|
+
},
|
|
146
|
+
"llama-3.1-8b": {
|
|
147
|
+
inputCostPerMillionTokens: .055,
|
|
148
|
+
outputCostPerMillionTokens: .055
|
|
149
|
+
},
|
|
150
|
+
"deepseek-chat": {
|
|
151
|
+
inputCostPerMillionTokens: .14,
|
|
152
|
+
outputCostPerMillionTokens: .28
|
|
153
|
+
},
|
|
154
|
+
"deepseek-reasoner": {
|
|
155
|
+
inputCostPerMillionTokens: .55,
|
|
156
|
+
outputCostPerMillionTokens: 2.19
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
function getRatesForModel(modelId) {
|
|
160
|
+
if (MODEL_PRICING[modelId]) return MODEL_PRICING[modelId];
|
|
161
|
+
for (const [key, rates] of Object.entries(MODEL_PRICING)) if (modelId.includes(key) || key.includes(modelId)) return rates;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
//#endregion
|
|
165
|
+
export { getRatesForModel as i, aggregateUsage as n, calculateCost as r, MODEL_PRICING as t };
|
package/dist/utils/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as truncate, c as bold, d as gray, f as green, h as yellow, i as pluralize, l as cyan, m as stripAnsi, n as shortenPath, o as ANSI, p as red, r as formatList, s as blue, t as expandPath, u as dim } from "../index-
|
|
1
|
+
import { a as truncate, c as bold, d as gray, f as green, h as yellow, i as pluralize, l as cyan, m as stripAnsi, n as shortenPath, o as ANSI, p as red, r as formatList, s as blue, t as expandPath, u as dim } from "../index-CbYchDwg.mjs";
|
|
2
2
|
export { ANSI, blue, bold, cyan, dim, expandPath, formatList, gray, green, pluralize, red, shortenPath, stripAnsi, truncate, yellow };
|
package/dist/utils/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as shortenPath, t as expandPath } from "../path-
|
|
2
|
-
import { a as blue, c as dim, d as red, f as stripAnsi, i as ANSI, l as gray, n as pluralize, o as bold, p as yellow, r as truncate, s as cyan, t as formatList, u as green } from "../utils-
|
|
1
|
+
import { n as shortenPath, t as expandPath } from "../path-Dm-URQvz.mjs";
|
|
2
|
+
import { a as blue, c as dim, d as red, f as stripAnsi, i as ANSI, l as gray, n as pluralize, o as bold, p as yellow, r as truncate, s as cyan, t as formatList, u as green } from "../utils-bP3i6rq3.mjs";
|
|
3
3
|
|
|
4
4
|
export { ANSI, blue, bold, cyan, dim, expandPath, formatList, gray, green, pluralize, red, shortenPath, stripAnsi, truncate, yellow };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unagent",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"description": "Unified agent primitives for AI coding agents",
|
|
6
6
|
"author": "Maximilian Conradt <https://github.com/onmax>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -26,13 +26,29 @@
|
|
|
26
26
|
"types": "./dist/index.d.mts",
|
|
27
27
|
"default": "./dist/index.mjs"
|
|
28
28
|
},
|
|
29
|
+
"./context": {
|
|
30
|
+
"types": "./dist/context/index.d.mts",
|
|
31
|
+
"default": "./dist/context/index.mjs"
|
|
32
|
+
},
|
|
29
33
|
"./env": {
|
|
30
34
|
"types": "./dist/env/index.d.mts",
|
|
31
35
|
"default": "./dist/env/index.mjs"
|
|
32
36
|
},
|
|
33
|
-
"./
|
|
34
|
-
"types": "./dist/
|
|
35
|
-
"default": "./dist/
|
|
37
|
+
"./exec": {
|
|
38
|
+
"types": "./dist/exec/index.d.mts",
|
|
39
|
+
"default": "./dist/exec/index.mjs"
|
|
40
|
+
},
|
|
41
|
+
"./fs": {
|
|
42
|
+
"types": "./dist/fs/index.d.mts",
|
|
43
|
+
"default": "./dist/fs/index.mjs"
|
|
44
|
+
},
|
|
45
|
+
"./git": {
|
|
46
|
+
"types": "./dist/git/index.d.mts",
|
|
47
|
+
"default": "./dist/git/index.mjs"
|
|
48
|
+
},
|
|
49
|
+
"./hooks": {
|
|
50
|
+
"types": "./dist/hooks/index.d.mts",
|
|
51
|
+
"default": "./dist/hooks/index.mjs"
|
|
36
52
|
},
|
|
37
53
|
"./link": {
|
|
38
54
|
"types": "./dist/link/index.d.mts",
|
|
@@ -42,13 +58,37 @@
|
|
|
42
58
|
"types": "./dist/lock/index.d.mts",
|
|
43
59
|
"default": "./dist/lock/index.mjs"
|
|
44
60
|
},
|
|
61
|
+
"./registry": {
|
|
62
|
+
"types": "./dist/registry/index.d.mts",
|
|
63
|
+
"default": "./dist/registry/index.mjs"
|
|
64
|
+
},
|
|
65
|
+
"./sandbox": {
|
|
66
|
+
"types": "./dist/sandbox/index.d.mts",
|
|
67
|
+
"default": "./dist/sandbox/index.mjs"
|
|
68
|
+
},
|
|
69
|
+
"./skill": {
|
|
70
|
+
"types": "./dist/skill/index.d.mts",
|
|
71
|
+
"default": "./dist/skill/index.mjs"
|
|
72
|
+
},
|
|
45
73
|
"./source": {
|
|
46
74
|
"types": "./dist/source/index.d.mts",
|
|
47
75
|
"default": "./dist/source/index.mjs"
|
|
48
76
|
},
|
|
49
|
-
"./
|
|
50
|
-
"types": "./dist/
|
|
51
|
-
"default": "./dist/
|
|
77
|
+
"./stop": {
|
|
78
|
+
"types": "./dist/stop/index.d.mts",
|
|
79
|
+
"default": "./dist/stop/index.mjs"
|
|
80
|
+
},
|
|
81
|
+
"./stream": {
|
|
82
|
+
"types": "./dist/stream/index.d.mts",
|
|
83
|
+
"default": "./dist/stream/index.mjs"
|
|
84
|
+
},
|
|
85
|
+
"./tool": {
|
|
86
|
+
"types": "./dist/tool/index.d.mts",
|
|
87
|
+
"default": "./dist/tool/index.mjs"
|
|
88
|
+
},
|
|
89
|
+
"./usage": {
|
|
90
|
+
"types": "./dist/usage/index.d.mts",
|
|
91
|
+
"default": "./dist/usage/index.mjs"
|
|
52
92
|
},
|
|
53
93
|
"./utils": {
|
|
54
94
|
"types": "./dist/utils/index.d.mts",
|
|
@@ -61,7 +101,24 @@
|
|
|
61
101
|
"files": [
|
|
62
102
|
"dist"
|
|
63
103
|
],
|
|
104
|
+
"peerDependencies": {
|
|
105
|
+
"@cloudflare/sandbox": ">=0.1.0",
|
|
106
|
+
"@vercel/sandbox": ">=0.1.0",
|
|
107
|
+
"unstorage": ">=1.10.0"
|
|
108
|
+
},
|
|
109
|
+
"peerDependenciesMeta": {
|
|
110
|
+
"@cloudflare/sandbox": {
|
|
111
|
+
"optional": true
|
|
112
|
+
},
|
|
113
|
+
"@vercel/sandbox": {
|
|
114
|
+
"optional": true
|
|
115
|
+
},
|
|
116
|
+
"unstorage": {
|
|
117
|
+
"optional": true
|
|
118
|
+
}
|
|
119
|
+
},
|
|
64
120
|
"dependencies": {
|
|
121
|
+
"hookable": "^5.5.3",
|
|
65
122
|
"pathe": "^2.0.3",
|
|
66
123
|
"std-env": "^3.10.0",
|
|
67
124
|
"yaml": "^2.7.0"
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
//#region src/skill/parse.d.ts
|
|
2
|
-
interface SkillFrontmatter {
|
|
3
|
-
"name": string;
|
|
4
|
-
"description": string;
|
|
5
|
-
"license"?: string;
|
|
6
|
-
"compatibility"?: string;
|
|
7
|
-
"metadata"?: Record<string, string>;
|
|
8
|
-
"allowed-tools"?: string;
|
|
9
|
-
"globs"?: string | string[];
|
|
10
|
-
"alwaysApply"?: boolean;
|
|
11
|
-
"tags"?: string[];
|
|
12
|
-
}
|
|
13
|
-
interface ParsedSkill {
|
|
14
|
-
frontmatter: SkillFrontmatter;
|
|
15
|
-
content: string;
|
|
16
|
-
raw: string;
|
|
17
|
-
}
|
|
18
|
-
declare function parseSkillMd(content: string): ParsedSkill;
|
|
19
|
-
declare function extractSkillName(frontmatter: SkillFrontmatter, filename?: string): string;
|
|
20
|
-
/** @deprecated Use validateSkill from './validate' for spec-compliant validation */
|
|
21
|
-
declare function validateSkillMd(parsed: ParsedSkill): string[];
|
|
22
|
-
//#endregion
|
|
23
|
-
//#region src/skill/discover.d.ts
|
|
24
|
-
interface DiscoveredSkill {
|
|
25
|
-
path: string;
|
|
26
|
-
name: string;
|
|
27
|
-
parsed: ParsedSkill;
|
|
28
|
-
}
|
|
29
|
-
interface DiscoverOptions {
|
|
30
|
-
recursive?: boolean;
|
|
31
|
-
}
|
|
32
|
-
declare function discoverSkills(dir: string, options?: DiscoverOptions): DiscoveredSkill[];
|
|
33
|
-
declare function filterSkills(skills: DiscoveredSkill[], query: string): DiscoveredSkill[];
|
|
34
|
-
declare function findSkillByName(skills: DiscoveredSkill[], name: string): DiscoveredSkill | undefined;
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region src/skill/prompt.d.ts
|
|
37
|
-
declare function toPromptXml(skills: DiscoveredSkill[]): string;
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/skill/validate.d.ts
|
|
40
|
-
interface ValidationResult {
|
|
41
|
-
valid: boolean;
|
|
42
|
-
errors: string[];
|
|
43
|
-
warnings: string[];
|
|
44
|
-
}
|
|
45
|
-
declare function validateSkill(skill: ParsedSkill, dirName?: string): ValidationResult;
|
|
46
|
-
//#endregion
|
|
47
|
-
export { DiscoveredSkill as a, findSkillByName as c, extractSkillName as d, parseSkillMd as f, DiscoverOptions as i, ParsedSkill as l, validateSkill as n, discoverSkills as o, validateSkillMd as p, toPromptXml as r, filterSkills as s, ValidationResult as t, SkillFrontmatter as u };
|
package/dist/skill-Bnz84tJ5.mjs
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
2
|
-
import { basename, join } from "pathe";
|
|
3
|
-
import { parse } from "yaml";
|
|
4
|
-
|
|
5
|
-
//#region src/skill/_frontmatter.ts
|
|
6
|
-
function parseFrontmatter(input) {
|
|
7
|
-
const match = input.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
|
|
8
|
-
if (!match) return {
|
|
9
|
-
data: {},
|
|
10
|
-
content: input.trim()
|
|
11
|
-
};
|
|
12
|
-
return {
|
|
13
|
-
data: parse(match[1]),
|
|
14
|
-
content: match[2].trim()
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/skill/parse.ts
|
|
20
|
-
function parseSkillMd(content) {
|
|
21
|
-
const { data, content: body } = parseFrontmatter(content);
|
|
22
|
-
return {
|
|
23
|
-
frontmatter: data,
|
|
24
|
-
content: body,
|
|
25
|
-
raw: content
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
function extractSkillName(frontmatter, filename) {
|
|
29
|
-
if (frontmatter.name) return frontmatter.name;
|
|
30
|
-
if (filename) return filename.replace(/\.md$/i, "").replace(/^SKILL[._-]?/i, "").replace(/[._-]/g, " ").trim();
|
|
31
|
-
return "Unnamed Skill";
|
|
32
|
-
}
|
|
33
|
-
/** @deprecated Use validateSkill from './validate' for spec-compliant validation */
|
|
34
|
-
function validateSkillMd(parsed) {
|
|
35
|
-
const errors = [];
|
|
36
|
-
if (!parsed.content) errors.push("Skill content is empty");
|
|
37
|
-
if (parsed.frontmatter.globs) {
|
|
38
|
-
const globs = Array.isArray(parsed.frontmatter.globs) ? parsed.frontmatter.globs : [parsed.frontmatter.globs];
|
|
39
|
-
for (const glob of globs) if (typeof glob !== "string") errors.push(`Invalid glob pattern: ${glob}`);
|
|
40
|
-
}
|
|
41
|
-
return errors;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region src/skill/discover.ts
|
|
46
|
-
const SKILL_FILE = "SKILL.md";
|
|
47
|
-
function discoverSkills(dir, options = {}) {
|
|
48
|
-
const { recursive = false } = options;
|
|
49
|
-
if (!existsSync(dir)) return [];
|
|
50
|
-
const skills = [];
|
|
51
|
-
const entries = readdirSync(dir);
|
|
52
|
-
for (const entry of entries) {
|
|
53
|
-
const fullPath = join(dir, entry);
|
|
54
|
-
if (!statSync(fullPath).isDirectory()) continue;
|
|
55
|
-
const skillFile = join(fullPath, SKILL_FILE);
|
|
56
|
-
if (existsSync(skillFile)) try {
|
|
57
|
-
const parsed = parseSkillMd(readFileSync(skillFile, "utf-8"));
|
|
58
|
-
skills.push({
|
|
59
|
-
path: fullPath,
|
|
60
|
-
name: basename(fullPath),
|
|
61
|
-
parsed
|
|
62
|
-
});
|
|
63
|
-
} catch {}
|
|
64
|
-
else if (recursive) skills.push(...discoverSkills(fullPath, options));
|
|
65
|
-
}
|
|
66
|
-
return skills;
|
|
67
|
-
}
|
|
68
|
-
function filterSkills(skills, query) {
|
|
69
|
-
const lowerQuery = query.toLowerCase();
|
|
70
|
-
return skills.filter((skill) => {
|
|
71
|
-
const nameMatch = skill.name.toLowerCase().includes(lowerQuery);
|
|
72
|
-
const descMatch = skill.parsed.frontmatter.description?.toLowerCase().includes(lowerQuery);
|
|
73
|
-
const tagMatch = skill.parsed.frontmatter.tags?.some((tag) => tag.toLowerCase().includes(lowerQuery));
|
|
74
|
-
return nameMatch || descMatch || tagMatch;
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
function findSkillByName(skills, name) {
|
|
78
|
-
const lowerName = name.toLowerCase();
|
|
79
|
-
return skills.find((skill) => skill.name.toLowerCase() === lowerName);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
//#endregion
|
|
83
|
-
//#region src/skill/prompt.ts
|
|
84
|
-
function toPromptXml(skills) {
|
|
85
|
-
if (skills.length === 0) return "";
|
|
86
|
-
return `<available_skills>\n${skills.map((skill) => {
|
|
87
|
-
return ` <skill>
|
|
88
|
-
<name>${escapeXml(skill.name)}</name>
|
|
89
|
-
<description>${escapeXml(skill.parsed.frontmatter.description || "")}</description>
|
|
90
|
-
<location>${escapeXml(skill.path)}</location>
|
|
91
|
-
</skill>`;
|
|
92
|
-
}).join("\n")}\n</available_skills>`;
|
|
93
|
-
}
|
|
94
|
-
function escapeXml(str) {
|
|
95
|
-
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
//#endregion
|
|
99
|
-
//#region src/skill/validate.ts
|
|
100
|
-
const NAME_PATTERN = /^[a-z][a-z0-9-]*[a-z0-9]$|^[a-z]$/;
|
|
101
|
-
function validateSkill(skill, dirName) {
|
|
102
|
-
const errors = [];
|
|
103
|
-
const warnings = [];
|
|
104
|
-
const { frontmatter, content } = skill;
|
|
105
|
-
if (!frontmatter.name) errors.push("name is required");
|
|
106
|
-
else {
|
|
107
|
-
const name = frontmatter.name;
|
|
108
|
-
if (name.length < 1 || name.length > 64) errors.push("name must be 1-64 characters");
|
|
109
|
-
if (!NAME_PATTERN.test(name)) errors.push("name must be lowercase letters, numbers, and hyphens; cannot start/end with hyphen");
|
|
110
|
-
if (name.includes("--")) errors.push("name cannot contain consecutive hyphens");
|
|
111
|
-
if (dirName && name !== dirName) errors.push(`name "${name}" must match directory name "${dirName}"`);
|
|
112
|
-
}
|
|
113
|
-
if (!frontmatter.description) errors.push("description is required");
|
|
114
|
-
else if (frontmatter.description.length < 1 || frontmatter.description.length > 1024) errors.push("description must be 1-1024 characters");
|
|
115
|
-
if (frontmatter.compatibility && frontmatter.compatibility.length > 500) errors.push("compatibility must be max 500 characters");
|
|
116
|
-
if (!content) warnings.push("skill content is empty");
|
|
117
|
-
return {
|
|
118
|
-
valid: errors.length === 0,
|
|
119
|
-
errors,
|
|
120
|
-
warnings
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
//#endregion
|
|
125
|
-
export { findSkillByName as a, validateSkillMd as c, filterSkills as i, toPromptXml as n, extractSkillName as o, discoverSkills as r, parseSkillMd as s, validateSkill as t };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|