@tachu/extensions 1.0.0-alpha.3 → 1.0.0-alpha.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/CHANGELOG.md +47 -0
- package/README.md +21 -3
- package/README_ZH.md +20 -3
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +2 -1
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +2 -1
- package/dist/providers/openai.js.map +1 -1
- package/dist/tools/apply-patch/executor.d.ts.map +1 -1
- package/dist/tools/apply-patch/executor.js +47 -0
- package/dist/tools/apply-patch/executor.js.map +1 -1
- package/dist/tools/edit-file/executor.d.ts +32 -0
- package/dist/tools/edit-file/executor.d.ts.map +1 -0
- package/dist/tools/edit-file/executor.js +84 -0
- package/dist/tools/edit-file/executor.js.map +1 -0
- package/dist/tools/git-blame/executor.d.ts +24 -0
- package/dist/tools/git-blame/executor.d.ts.map +1 -0
- package/dist/tools/git-blame/executor.js +76 -0
- package/dist/tools/git-blame/executor.js.map +1 -0
- package/dist/tools/git-branch/executor.d.ts +22 -0
- package/dist/tools/git-branch/executor.d.ts.map +1 -0
- package/dist/tools/git-branch/executor.js +81 -0
- package/dist/tools/git-branch/executor.js.map +1 -0
- package/dist/tools/git-diff/executor.d.ts +37 -0
- package/dist/tools/git-diff/executor.d.ts.map +1 -0
- package/dist/tools/git-diff/executor.js +156 -0
- package/dist/tools/git-diff/executor.js.map +1 -0
- package/dist/tools/git-log/executor.d.ts +31 -0
- package/dist/tools/git-log/executor.d.ts.map +1 -0
- package/dist/tools/git-log/executor.js +65 -0
- package/dist/tools/git-log/executor.js.map +1 -0
- package/dist/tools/git-show/executor.d.ts +22 -0
- package/dist/tools/git-show/executor.d.ts.map +1 -0
- package/dist/tools/git-show/executor.js +74 -0
- package/dist/tools/git-show/executor.js.map +1 -0
- package/dist/tools/git-status/executor.d.ts +25 -0
- package/dist/tools/git-status/executor.d.ts.map +1 -0
- package/dist/tools/git-status/executor.js +120 -0
- package/dist/tools/git-status/executor.js.map +1 -0
- package/dist/tools/glob/executor.d.ts +18 -0
- package/dist/tools/glob/executor.d.ts.map +1 -0
- package/dist/tools/glob/executor.js +47 -0
- package/dist/tools/glob/executor.js.map +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +360 -3
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/multi-edit/executor.d.ts +29 -0
- package/dist/tools/multi-edit/executor.d.ts.map +1 -0
- package/dist/tools/multi-edit/executor.js +37 -0
- package/dist/tools/multi-edit/executor.js.map +1 -0
- package/dist/tools/read-file/executor.d.ts +5 -0
- package/dist/tools/read-file/executor.d.ts.map +1 -1
- package/dist/tools/read-file/executor.js +46 -2
- package/dist/tools/read-file/executor.js.map +1 -1
- package/dist/tools/run-shell/executor.d.ts +12 -1
- package/dist/tools/run-shell/executor.d.ts.map +1 -1
- package/dist/tools/run-shell/executor.js +89 -6
- package/dist/tools/run-shell/executor.js.map +1 -1
- package/dist/tools/run-tests/executor.d.ts +28 -0
- package/dist/tools/run-tests/executor.d.ts.map +1 -0
- package/dist/tools/run-tests/executor.js +161 -0
- package/dist/tools/run-tests/executor.js.map +1 -0
- package/dist/tools/run-typecheck/executor.d.ts +25 -0
- package/dist/tools/run-typecheck/executor.d.ts.map +1 -0
- package/dist/tools/run-typecheck/executor.js +83 -0
- package/dist/tools/run-typecheck/executor.js.map +1 -0
- package/dist/tools/todo-read/executor.d.ts +20 -0
- package/dist/tools/todo-read/executor.d.ts.map +1 -0
- package/dist/tools/todo-read/executor.js +26 -0
- package/dist/tools/todo-read/executor.js.map +1 -0
- package/dist/tools/todo-write/executor.d.ts +21 -0
- package/dist/tools/todo-write/executor.d.ts.map +1 -0
- package/dist/tools/todo-write/executor.js +38 -0
- package/dist/tools/todo-write/executor.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/tools/run-typecheck/executor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAI9C,UAAU,iBAAiB;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;CAC/B;AAED,UAAU,kBAAkB;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAqED,eAAO,MAAM,oBAAoB,EAAE,YAAY,CAAC,iBAAiB,EAAE,kBAAkB,CAsCpF,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { resolve, join } from "node:path";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { assertNotAborted, resolveSandboxPolicy } from "../shared";
|
|
4
|
+
import { resolveAllowedPath } from "../../common/path";
|
|
5
|
+
// Matches: file.ts(10,5): error TS2345: some message
|
|
6
|
+
const TSC_LINE_RE = /^(.+)\((\d+),(\d+)\):\s+(error|warning)\s+(TS\d+):\s+(.+)$/;
|
|
7
|
+
const parseTscOutput = (output, maxErrors) => {
|
|
8
|
+
const lines = output.split("\n");
|
|
9
|
+
const allErrors = [];
|
|
10
|
+
let parseSuccess = false;
|
|
11
|
+
for (const line of lines) {
|
|
12
|
+
const m = line.match(TSC_LINE_RE);
|
|
13
|
+
if (m) {
|
|
14
|
+
parseSuccess = true;
|
|
15
|
+
const severity = m[4];
|
|
16
|
+
allErrors.push({
|
|
17
|
+
file: m[1],
|
|
18
|
+
line: parseInt(m[2], 10),
|
|
19
|
+
col: parseInt(m[3], 10),
|
|
20
|
+
code: m[5],
|
|
21
|
+
message: m[6],
|
|
22
|
+
severity,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// Sort: errors before warnings
|
|
27
|
+
allErrors.sort((a, b) => {
|
|
28
|
+
if (a.severity === b.severity)
|
|
29
|
+
return 0;
|
|
30
|
+
return a.severity === "error" ? -1 : 1;
|
|
31
|
+
});
|
|
32
|
+
const errorCount = allErrors.filter((e) => e.severity === "error").length;
|
|
33
|
+
const warningCount = allErrors.filter((e) => e.severity === "warning").length;
|
|
34
|
+
const truncated = allErrors.length > maxErrors;
|
|
35
|
+
const errors = truncated ? allErrors.slice(0, maxErrors) : allErrors;
|
|
36
|
+
const result = { errors, errorCount, warningCount, truncated };
|
|
37
|
+
if (!parseSuccess && output.trim().length > 0) {
|
|
38
|
+
result.rawOutput = output.slice(0, 4096);
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
};
|
|
42
|
+
const hasTypecheckScript = async (cwd) => {
|
|
43
|
+
try {
|
|
44
|
+
const pkgPath = join(cwd, "package.json");
|
|
45
|
+
const content = await readFile(pkgPath, "utf8");
|
|
46
|
+
const pkg = JSON.parse(content);
|
|
47
|
+
return typeof pkg.scripts?.typecheck === "string";
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
export const runTypecheckExecutor = async (input, context) => {
|
|
54
|
+
assertNotAborted(context.abortSignal);
|
|
55
|
+
const policy = resolveSandboxPolicy(context);
|
|
56
|
+
const cwd = input.cwd ? resolveAllowedPath(input.cwd, policy) : resolve(context.workspaceRoot);
|
|
57
|
+
const maxErrors = input.maxErrors ?? 50;
|
|
58
|
+
const usePackageScript = await hasTypecheckScript(cwd);
|
|
59
|
+
let cmd;
|
|
60
|
+
if (usePackageScript) {
|
|
61
|
+
cmd = [process.execPath, "run", "typecheck"];
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
cmd = [process.execPath, "x", "tsc", "--noEmit"];
|
|
65
|
+
if (input.tsconfig) {
|
|
66
|
+
cmd.push("--project", input.tsconfig);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const proc = Bun.spawn({ cmd, cwd, stdout: "pipe", stderr: "pipe" });
|
|
70
|
+
const [stdout, stderr, exitCode] = await Promise.all([
|
|
71
|
+
new Response(proc.stdout).text(),
|
|
72
|
+
new Response(proc.stderr).text(),
|
|
73
|
+
proc.exited,
|
|
74
|
+
]);
|
|
75
|
+
assertNotAborted(context.abortSignal);
|
|
76
|
+
const combined = [stdout, stderr].filter((s) => s.trim().length > 0).join("\n");
|
|
77
|
+
const parsed = parseTscOutput(combined, maxErrors);
|
|
78
|
+
return {
|
|
79
|
+
passed: exitCode === 0,
|
|
80
|
+
...parsed,
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../src/tools/run-typecheck/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AA0BvD,qDAAqD;AACrD,MAAM,WAAW,GAAG,4DAA4D,CAAC;AAEjF,MAAM,cAAc,GAAG,CAAC,MAAc,EAAE,SAAiB,EAMvD,EAAE;IACF,MAAM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CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChF,MAAM,MAAM,GAAG,cAAc,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAEnD,OAAO;QACL,MAAM,EAAE,QAAQ,KAAK,CAAC;QACtB,GAAG,MAAM;KACV,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ToolExecutor } from "../shared";
|
|
2
|
+
type TodoStatus = "pending" | "in_progress" | "completed" | "cancelled";
|
|
3
|
+
interface TodoItem {
|
|
4
|
+
id: string;
|
|
5
|
+
content: string;
|
|
6
|
+
status: TodoStatus;
|
|
7
|
+
}
|
|
8
|
+
interface TodoReadInput {
|
|
9
|
+
status?: TodoStatus | "all";
|
|
10
|
+
}
|
|
11
|
+
interface TodoReadOutput {
|
|
12
|
+
todos: TodoItem[];
|
|
13
|
+
total: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Todo 读取 Tool 执行器。
|
|
17
|
+
*/
|
|
18
|
+
export declare const todoReadExecutor: ToolExecutor<TodoReadInput, TodoReadOutput>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/tools/todo-read/executor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAG9C,KAAK,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,WAAW,CAAC;AAExE,UAAU,QAAQ;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,UAAU,aAAa;IACrB,MAAM,CAAC,EAAE,UAAU,GAAG,KAAK,CAAC;CAC7B;AAED,UAAU,cAAc;IACtB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAKD;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,aAAa,EAAE,cAAc,CAwBxE,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { assertNotAborted } from "../shared";
|
|
4
|
+
const getTodosPath = (workspaceRoot, sessionId) => join(workspaceRoot, ".tachu", "sessions", sessionId, "todos.json");
|
|
5
|
+
/**
|
|
6
|
+
* Todo 读取 Tool 执行器。
|
|
7
|
+
*/
|
|
8
|
+
export const todoReadExecutor = async (input, context) => {
|
|
9
|
+
assertNotAborted(context.abortSignal);
|
|
10
|
+
const path = getTodosPath(context.workspaceRoot, context.session.id);
|
|
11
|
+
let todos = [];
|
|
12
|
+
try {
|
|
13
|
+
const raw = await readFile(path, "utf8");
|
|
14
|
+
const parsed = JSON.parse(raw);
|
|
15
|
+
todos = Array.isArray(parsed) ? parsed : [];
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
todos = [];
|
|
19
|
+
}
|
|
20
|
+
const filterStatus = input.status;
|
|
21
|
+
const filtered = filterStatus === undefined || filterStatus === "all"
|
|
22
|
+
? todos
|
|
23
|
+
: todos.filter((t) => t.status === filterStatus);
|
|
24
|
+
return { todos: filtered, total: filtered.length };
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../src/tools/todo-read/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAmB7C,MAAM,YAAY,GAAG,CAAC,aAAqB,EAAE,SAAiB,EAAU,EAAE,CACxE,IAAI,CAAC,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;AAErE;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAgD,KAAK,EAChF,KAAK,EACL,OAAO,EACP,EAAE;IACF,gBAAgB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAEtC,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAErE,IAAI,KAAK,GAAe,EAAE,CAAC;IAC3B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACzC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,MAAqB,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9D,CAAC;IAAC,MAAM,CAAC;QACP,KAAK,GAAG,EAAE,CAAC;IACb,CAAC;IAED,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC;IAClC,MAAM,QAAQ,GACZ,YAAY,KAAK,SAAS,IAAI,YAAY,KAAK,KAAK;QAClD,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,YAAY,CAAC,CAAC;IAErD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;AACrD,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ToolExecutor } from "../shared";
|
|
2
|
+
type TodoStatus = "pending" | "in_progress" | "completed" | "cancelled";
|
|
3
|
+
interface TodoItem {
|
|
4
|
+
id: string;
|
|
5
|
+
content: string;
|
|
6
|
+
status: TodoStatus;
|
|
7
|
+
}
|
|
8
|
+
interface TodoWriteInput {
|
|
9
|
+
todos: TodoItem[];
|
|
10
|
+
merge?: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface TodoWriteOutput {
|
|
13
|
+
total: number;
|
|
14
|
+
written: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Todo 写入 Tool 执行器。
|
|
18
|
+
*/
|
|
19
|
+
export declare const todoWriteExecutor: ToolExecutor<TodoWriteInput, TodoWriteOutput>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/tools/todo-write/executor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAG9C,KAAK,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,WAAW,CAAC;AAExE,UAAU,QAAQ;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,UAAU,cAAc;IACtB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAeD;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,cAAc,EAAE,eAAe,CAyB3E,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { assertNotAborted } from "../shared";
|
|
4
|
+
const getTodosPath = (workspaceRoot, sessionId) => join(workspaceRoot, ".tachu", "sessions", sessionId, "todos.json");
|
|
5
|
+
const readExisting = async (path) => {
|
|
6
|
+
try {
|
|
7
|
+
const raw = await readFile(path, "utf8");
|
|
8
|
+
const parsed = JSON.parse(raw);
|
|
9
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Todo 写入 Tool 执行器。
|
|
17
|
+
*/
|
|
18
|
+
export const todoWriteExecutor = async (input, context) => {
|
|
19
|
+
assertNotAborted(context.abortSignal);
|
|
20
|
+
const path = getTodosPath(context.workspaceRoot, context.session.id);
|
|
21
|
+
await mkdir(join(path, ".."), { recursive: true });
|
|
22
|
+
const merge = input.merge !== false;
|
|
23
|
+
let final;
|
|
24
|
+
if (merge) {
|
|
25
|
+
const existing = await readExisting(path);
|
|
26
|
+
const map = new Map(existing.map((t) => [t.id, t]));
|
|
27
|
+
for (const todo of input.todos) {
|
|
28
|
+
map.set(todo.id, todo);
|
|
29
|
+
}
|
|
30
|
+
final = [...map.values()];
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
final = [...input.todos];
|
|
34
|
+
}
|
|
35
|
+
await writeFile(path, JSON.stringify(final, null, 2), "utf8");
|
|
36
|
+
return { total: final.length, written: input.todos.length };
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../src/tools/todo-write/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAoB7C,MAAM,YAAY,GAAG,CAAC,aAAqB,EAAE,SAAiB,EAAU,EAAE,CACxE,IAAI,CAAC,aAAa,EAAE,QAAQ,E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AI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QACzB,CAAC;QACD,KAAK,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5B,CAAC;SAAM,CAAC;QACN,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAC9D,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;AAC9D,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachu/extensions",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.4",
|
|
4
4
|
"description": "Tachu extensions (alpha) — OpenAI/Anthropic/Mock providers, 7 built-in tools, execution backends, MCP adapters (stdio+SSE), vector stores (local/Qdrant), observability emitters, input transformers and common rules.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|