@townco/agent 0.1.87 → 0.1.98
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/acp-server/adapter.d.ts +49 -0
- package/dist/acp-server/adapter.js +693 -5
- package/dist/acp-server/http.d.ts +7 -0
- package/dist/acp-server/http.js +53 -6
- package/dist/definition/index.d.ts +29 -0
- package/dist/definition/index.js +24 -0
- package/dist/runner/agent-runner.d.ts +16 -1
- package/dist/runner/agent-runner.js +2 -1
- package/dist/runner/e2b-sandbox-manager.d.ts +18 -0
- package/dist/runner/e2b-sandbox-manager.js +99 -0
- package/dist/runner/hooks/executor.d.ts +3 -1
- package/dist/runner/hooks/executor.js +21 -1
- package/dist/runner/hooks/predefined/compaction-tool.js +67 -2
- package/dist/runner/hooks/types.d.ts +5 -0
- package/dist/runner/index.d.ts +11 -0
- package/dist/runner/langchain/index.d.ts +10 -0
- package/dist/runner/langchain/index.js +227 -7
- package/dist/runner/langchain/model-factory.js +28 -1
- package/dist/runner/langchain/tools/artifacts.js +6 -3
- package/dist/runner/langchain/tools/e2b.d.ts +48 -0
- package/dist/runner/langchain/tools/e2b.js +305 -0
- package/dist/runner/langchain/tools/filesystem.js +63 -0
- package/dist/runner/langchain/tools/subagent.d.ts +8 -0
- package/dist/runner/langchain/tools/subagent.js +76 -4
- package/dist/runner/langchain/tools/web_search.d.ts +36 -14
- package/dist/runner/langchain/tools/web_search.js +33 -2
- package/dist/runner/session-context.d.ts +20 -0
- package/dist/runner/session-context.js +54 -0
- package/dist/runner/tools.d.ts +2 -2
- package/dist/runner/tools.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -7
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
const sessionStorage = new AsyncLocalStorage();
|
|
4
|
+
/**
|
|
5
|
+
* Abort signal context for cancellation support.
|
|
6
|
+
* Tools can access this to check if the current operation has been cancelled.
|
|
7
|
+
*/
|
|
8
|
+
const abortSignalStorage = new AsyncLocalStorage();
|
|
9
|
+
/**
|
|
10
|
+
* Run a function with an abort signal available via AsyncLocalStorage.
|
|
11
|
+
* Tools can access the signal using getAbortSignal().
|
|
12
|
+
*/
|
|
13
|
+
export function runWithAbortSignal(signal, fn) {
|
|
14
|
+
return abortSignalStorage.run(signal, fn);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Bind an async generator to an abort signal context so that every iteration
|
|
18
|
+
* runs with the abort signal available.
|
|
19
|
+
*/
|
|
20
|
+
export function bindGeneratorToAbortSignal(signal, generator) {
|
|
21
|
+
const boundNext = (value) => abortSignalStorage.run(signal, () => generator.next(value));
|
|
22
|
+
const boundReturn = generator.return
|
|
23
|
+
? (value) => abortSignalStorage.run(signal, () => generator.return?.(value))
|
|
24
|
+
: undefined;
|
|
25
|
+
const boundThrow = generator.throw
|
|
26
|
+
? (e) => abortSignalStorage.run(signal, () => generator.throw?.(e))
|
|
27
|
+
: undefined;
|
|
28
|
+
const boundGenerator = {
|
|
29
|
+
next: boundNext,
|
|
30
|
+
return: boundReturn,
|
|
31
|
+
throw: boundThrow,
|
|
32
|
+
[Symbol.asyncIterator]() {
|
|
33
|
+
return this;
|
|
34
|
+
},
|
|
35
|
+
[Symbol.asyncDispose]: async () => {
|
|
36
|
+
if (Symbol.asyncDispose in generator) {
|
|
37
|
+
await generator[Symbol.asyncDispose]();
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
return boundGenerator;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get the current abort signal.
|
|
45
|
+
* Returns undefined if called outside of an abort signal context.
|
|
46
|
+
*/
|
|
47
|
+
export function getAbortSignal() {
|
|
48
|
+
return abortSignalStorage.getStore();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Check if the current operation has been aborted.
|
|
52
|
+
* Returns false if no abort signal is available.
|
|
53
|
+
*/
|
|
54
|
+
export function isAborted() {
|
|
55
|
+
const signal = abortSignalStorage.getStore();
|
|
56
|
+
return signal?.aborted ?? false;
|
|
57
|
+
}
|
|
4
58
|
/**
|
|
5
59
|
* Run a function with session context available via AsyncLocalStorage.
|
|
6
60
|
* Tools can access the context using getSessionContext().
|
package/dist/runner/tools.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
/** Built-in tool types. */
|
|
3
|
-
export declare const zBuiltInToolType: z.ZodUnion<readonly [z.ZodLiteral<"artifacts">, z.ZodLiteral<"todo_write">, z.ZodLiteral<"get_weather">, z.ZodLiteral<"web_search">, z.ZodLiteral<"town_web_search">, z.ZodLiteral<"filesystem">, z.ZodLiteral<"generate_image">, z.ZodLiteral<"town_generate_image">, z.ZodLiteral<"browser">, z.ZodLiteral<"document_extract">]>;
|
|
3
|
+
export declare const zBuiltInToolType: z.ZodUnion<readonly [z.ZodLiteral<"artifacts">, z.ZodLiteral<"todo_write">, z.ZodLiteral<"get_weather">, z.ZodLiteral<"web_search">, z.ZodLiteral<"town_web_search">, z.ZodLiteral<"filesystem">, z.ZodLiteral<"generate_image">, z.ZodLiteral<"town_generate_image">, z.ZodLiteral<"browser">, z.ZodLiteral<"document_extract">, z.ZodLiteral<"town_e2b">]>;
|
|
4
4
|
/** Subagent configuration schema for Task tools. */
|
|
5
5
|
export declare const zSubagentConfig: z.ZodObject<{
|
|
6
6
|
agentName: z.ZodString;
|
|
@@ -23,7 +23,7 @@ declare const zDirectTool: z.ZodObject<{
|
|
|
23
23
|
}, z.core.$strip>>>;
|
|
24
24
|
}, z.core.$strip>;
|
|
25
25
|
/** Tool type - can be a built-in tool string or custom tool object. */
|
|
26
|
-
export declare const zToolType: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"artifacts">, z.ZodLiteral<"todo_write">, z.ZodLiteral<"get_weather">, z.ZodLiteral<"web_search">, z.ZodLiteral<"town_web_search">, z.ZodLiteral<"filesystem">, z.ZodLiteral<"generate_image">, z.ZodLiteral<"town_generate_image">, z.ZodLiteral<"browser">, z.ZodLiteral<"document_extract">]>, z.ZodObject<{
|
|
26
|
+
export declare const zToolType: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"artifacts">, z.ZodLiteral<"todo_write">, z.ZodLiteral<"get_weather">, z.ZodLiteral<"web_search">, z.ZodLiteral<"town_web_search">, z.ZodLiteral<"filesystem">, z.ZodLiteral<"generate_image">, z.ZodLiteral<"town_generate_image">, z.ZodLiteral<"browser">, z.ZodLiteral<"document_extract">, z.ZodLiteral<"town_e2b">]>, z.ZodObject<{
|
|
27
27
|
type: z.ZodLiteral<"custom">;
|
|
28
28
|
modulePath: z.ZodString;
|
|
29
29
|
}, z.core.$strip>, z.ZodObject<{
|
package/dist/runner/tools.js
CHANGED