@llm4ts/flow 2.54.0 → 3.0.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/dist/EstimatedUsage.d.ts.map +1 -1
- package/dist/EstimatedUsage.js +0 -1
- package/dist/EstimatedUsage.js.map +1 -1
- package/dist/Replay.d.ts.map +1 -1
- package/dist/Replay.js +1 -4
- package/dist/Replay.js.map +1 -1
- package/dist/RosterSeats.d.ts.map +1 -1
- package/dist/RosterSeats.js +0 -1
- package/dist/RosterSeats.js.map +1 -1
- package/dist/Taskforce.d.ts +8 -0
- package/dist/Taskforce.d.ts.map +1 -1
- package/dist/Taskforce.js +20 -2
- package/dist/Taskforce.js.map +1 -1
- package/dist/Timing.d.ts.map +1 -1
- package/dist/Timing.js +0 -1
- package/dist/Timing.js.map +1 -1
- package/dist/Transcript.d.ts.map +1 -1
- package/dist/Transcript.js +0 -1
- package/dist/Transcript.js.map +1 -1
- package/dist/TransientRetry.d.ts.map +1 -1
- package/dist/TransientRetry.js +0 -1
- package/dist/TransientRetry.js.map +1 -1
- package/package.json +2 -4
- package/src/EstimatedUsage.ts +0 -1
- package/src/Replay.ts +1 -7
- package/src/RosterSeats.ts +0 -2
- package/src/Taskforce.ts +23 -2
- package/src/Timing.ts +0 -10
- package/src/Transcript.ts +0 -1
- package/src/TransientRetry.ts +0 -2
- package/dist/WorkspaceLayout.d.ts +0 -3
- package/dist/WorkspaceLayout.d.ts.map +0 -1
- package/dist/WorkspaceLayout.js +0 -19
- package/dist/WorkspaceLayout.js.map +0 -1
- package/dist/WorkspaceTools.d.ts +0 -4
- package/dist/WorkspaceTools.d.ts.map +0 -1
- package/dist/WorkspaceTools.js +0 -130
- package/dist/WorkspaceTools.js.map +0 -1
- package/src/WorkspaceLayout.ts +0 -22
- package/src/WorkspaceTools.ts +0 -188
package/src/WorkspaceTools.ts
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import * as Effect from "effect/Effect"
|
|
2
|
-
import { ToolExecutionFailed, makeTool, type Tool } from "@llm4ts/core/tools/Tool"
|
|
3
|
-
import { isJsonRecord } from "@llm4ts/core/providers/CliSupport"
|
|
4
|
-
import type { JsonValue } from "@llm4ts/core/providers/CliSupport"
|
|
5
|
-
import type { WorkspaceShape } from "./Workspace.ts"
|
|
6
|
-
|
|
7
|
-
const parameter = (
|
|
8
|
-
parameters: JsonValue,
|
|
9
|
-
name: string
|
|
10
|
-
): Effect.Effect<string, ToolExecutionFailed> => {
|
|
11
|
-
if (!isJsonRecord(parameters)) {
|
|
12
|
-
return Effect.fail(
|
|
13
|
-
ToolExecutionFailed.make({
|
|
14
|
-
message: "tool parameters must be an object"
|
|
15
|
-
})
|
|
16
|
-
)
|
|
17
|
-
}
|
|
18
|
-
const value = parameters[name]
|
|
19
|
-
return typeof value === "string"
|
|
20
|
-
? Effect.succeed(value)
|
|
21
|
-
: Effect.fail(
|
|
22
|
-
ToolExecutionFailed.make({
|
|
23
|
-
message: `parameter '${name}' must be a string`
|
|
24
|
-
})
|
|
25
|
-
)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const optionalParameter = (
|
|
29
|
-
parameters: JsonValue,
|
|
30
|
-
name: string
|
|
31
|
-
): Effect.Effect<string | undefined, ToolExecutionFailed> => {
|
|
32
|
-
if (!isJsonRecord(parameters)) {
|
|
33
|
-
return Effect.fail(
|
|
34
|
-
ToolExecutionFailed.make({
|
|
35
|
-
message: "tool parameters must be an object"
|
|
36
|
-
})
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
const value = parameters[name]
|
|
40
|
-
return value === undefined || typeof value === "string"
|
|
41
|
-
? Effect.succeed(value)
|
|
42
|
-
: Effect.fail(
|
|
43
|
-
ToolExecutionFailed.make({
|
|
44
|
-
message: `parameter '${name}' must be a string when supplied`
|
|
45
|
-
})
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const mapWorkspaceError = Effect.mapError((error: { readonly message: string }) =>
|
|
50
|
-
ToolExecutionFailed.make({ message: error.message })
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
const pathSchema = {
|
|
54
|
-
type: "object",
|
|
55
|
-
properties: {
|
|
56
|
-
path: { type: "string" }
|
|
57
|
-
},
|
|
58
|
-
required: ["path"],
|
|
59
|
-
additionalProperties: false
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const contentSchema = {
|
|
63
|
-
type: "object",
|
|
64
|
-
properties: {
|
|
65
|
-
path: { type: "string" },
|
|
66
|
-
contents: { type: "string" }
|
|
67
|
-
},
|
|
68
|
-
required: ["path", "contents"],
|
|
69
|
-
additionalProperties: false
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export const workspaceTools = (workspace: WorkspaceShape): ReadonlyArray<Tool> => [
|
|
73
|
-
makeTool({
|
|
74
|
-
name: "workspace_read",
|
|
75
|
-
description: "Read a bounded UTF-8 file under the workspace root",
|
|
76
|
-
parameters: pathSchema,
|
|
77
|
-
tags: ["file", "read", "workspace"],
|
|
78
|
-
sandbox: "WorkspaceReadOnly",
|
|
79
|
-
execute: (parameters) =>
|
|
80
|
-
Effect.all({
|
|
81
|
-
path: parameter(parameters, "path")
|
|
82
|
-
}).pipe(
|
|
83
|
-
Effect.flatMap(({ path }) => workspace.read(path)),
|
|
84
|
-
mapWorkspaceError
|
|
85
|
-
)
|
|
86
|
-
}),
|
|
87
|
-
makeTool({
|
|
88
|
-
name: "workspace_write",
|
|
89
|
-
description: "Write bounded UTF-8 content under the workspace root",
|
|
90
|
-
parameters: contentSchema,
|
|
91
|
-
tags: ["file", "write", "workspace"],
|
|
92
|
-
execute: (parameters) =>
|
|
93
|
-
Effect.all({
|
|
94
|
-
path: parameter(parameters, "path"),
|
|
95
|
-
contents: parameter(parameters, "contents")
|
|
96
|
-
}).pipe(
|
|
97
|
-
Effect.flatMap(({ path, contents }) => workspace.write(path, contents)),
|
|
98
|
-
mapWorkspaceError,
|
|
99
|
-
Effect.as({ written: true })
|
|
100
|
-
)
|
|
101
|
-
}),
|
|
102
|
-
makeTool({
|
|
103
|
-
name: "workspace_append",
|
|
104
|
-
description: "Append bounded UTF-8 content under the workspace root",
|
|
105
|
-
parameters: contentSchema,
|
|
106
|
-
tags: ["file", "append", "workspace"],
|
|
107
|
-
execute: (parameters) =>
|
|
108
|
-
Effect.all({
|
|
109
|
-
path: parameter(parameters, "path"),
|
|
110
|
-
contents: parameter(parameters, "contents")
|
|
111
|
-
}).pipe(
|
|
112
|
-
Effect.flatMap(({ path, contents }) => workspace.append(path, contents)),
|
|
113
|
-
mapWorkspaceError,
|
|
114
|
-
Effect.as({ appended: true })
|
|
115
|
-
)
|
|
116
|
-
}),
|
|
117
|
-
makeTool({
|
|
118
|
-
name: "workspace_discover",
|
|
119
|
-
description: "Discover files under the workspace root using a bounded glob",
|
|
120
|
-
parameters: {
|
|
121
|
-
type: "object",
|
|
122
|
-
properties: {
|
|
123
|
-
pattern: { type: "string" }
|
|
124
|
-
},
|
|
125
|
-
additionalProperties: false
|
|
126
|
-
},
|
|
127
|
-
tags: ["file", "glob", "discover", "workspace"],
|
|
128
|
-
sandbox: "WorkspaceReadOnly",
|
|
129
|
-
execute: (parameters) =>
|
|
130
|
-
optionalParameter(parameters, "pattern").pipe(
|
|
131
|
-
Effect.flatMap((pattern) => workspace.discover(pattern)),
|
|
132
|
-
mapWorkspaceError,
|
|
133
|
-
Effect.map((paths) => [...paths])
|
|
134
|
-
)
|
|
135
|
-
}),
|
|
136
|
-
makeTool({
|
|
137
|
-
name: "workspace_search",
|
|
138
|
-
description: "Search bounded workspace files for literal text",
|
|
139
|
-
parameters: {
|
|
140
|
-
type: "object",
|
|
141
|
-
properties: {
|
|
142
|
-
query: { type: "string" },
|
|
143
|
-
pattern: { type: "string" }
|
|
144
|
-
},
|
|
145
|
-
required: ["query"],
|
|
146
|
-
additionalProperties: false
|
|
147
|
-
},
|
|
148
|
-
tags: ["file", "search", "workspace"],
|
|
149
|
-
sandbox: "WorkspaceReadOnly",
|
|
150
|
-
execute: (parameters) =>
|
|
151
|
-
Effect.all({
|
|
152
|
-
query: parameter(parameters, "query"),
|
|
153
|
-
pattern: optionalParameter(parameters, "pattern")
|
|
154
|
-
}).pipe(
|
|
155
|
-
Effect.flatMap(({ pattern, query }) => workspace.search(query, pattern)),
|
|
156
|
-
mapWorkspaceError,
|
|
157
|
-
Effect.map((matches) =>
|
|
158
|
-
matches.map((match) => ({
|
|
159
|
-
path: match.path,
|
|
160
|
-
line: match.line,
|
|
161
|
-
text: match.text
|
|
162
|
-
}))
|
|
163
|
-
)
|
|
164
|
-
)
|
|
165
|
-
}),
|
|
166
|
-
makeTool({
|
|
167
|
-
name: "workspace_validate_json",
|
|
168
|
-
description: "Validate that a bounded workspace file contains JSON",
|
|
169
|
-
parameters: pathSchema,
|
|
170
|
-
tags: ["file", "validate", "json", "workspace"],
|
|
171
|
-
sandbox: "WorkspaceReadOnly",
|
|
172
|
-
execute: (parameters) =>
|
|
173
|
-
parameter(parameters, "path").pipe(
|
|
174
|
-
Effect.flatMap((path) => workspace.read(path)),
|
|
175
|
-
mapWorkspaceError,
|
|
176
|
-
Effect.flatMap((contents) =>
|
|
177
|
-
Effect.try({
|
|
178
|
-
try: () => JSON.parse(contents),
|
|
179
|
-
catch: (error) =>
|
|
180
|
-
ToolExecutionFailed.make({
|
|
181
|
-
message: `invalid JSON: ${String(error)}`
|
|
182
|
-
})
|
|
183
|
-
})
|
|
184
|
-
),
|
|
185
|
-
Effect.as({ valid: true })
|
|
186
|
-
)
|
|
187
|
-
})
|
|
188
|
-
]
|