clanka 0.21.0 → 0.22.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/Acp.test.js +19 -7
- package/dist/Acp.test.js.map +1 -1
- package/dist/Agent.d.ts +4 -4
- package/dist/Agent.d.ts.map +1 -1
- package/dist/Agent.js +140 -99
- package/dist/Agent.js.map +1 -1
- package/dist/Agent.test.js +5 -4
- package/dist/Agent.test.js.map +1 -1
- package/dist/AgentBashJobs.test.js +47 -32
- package/dist/AgentBashJobs.test.js.map +1 -1
- package/dist/AgentCallerConfig.test.js +26 -7
- package/dist/AgentCallerConfig.test.js.map +1 -1
- package/dist/AgentExecutor.d.ts +71 -41
- package/dist/AgentExecutor.d.ts.map +1 -1
- package/dist/AgentExecutor.js +86 -79
- package/dist/AgentExecutor.js.map +1 -1
- package/dist/AgentExecutor.test.js +108 -83
- package/dist/AgentExecutor.test.js.map +1 -1
- package/dist/AgentExecutorImage.test.js +2 -2
- package/dist/AgentExecutorImage.test.js.map +1 -1
- package/dist/AgentImage.test.js +3 -2
- package/dist/AgentImage.test.js.map +1 -1
- package/dist/AgentSubagents.test.js +218 -29
- package/dist/AgentSubagents.test.js.map +1 -1
- package/dist/AgentTools.d.ts +318 -290
- package/dist/AgentTools.d.ts.map +1 -1
- package/dist/AgentTools.js +218 -199
- package/dist/AgentTools.js.map +1 -1
- package/dist/AgentTools.test.js +2 -2
- package/dist/AgentTools.test.js.map +1 -1
- package/dist/bin/cli.mjs +308 -289
- package/dist/bin/cli.mjs.map +1 -1
- package/package.json +1 -1
- package/src/Acp.test.ts +31 -10
- package/src/Agent.test.ts +5 -4
- package/src/Agent.ts +175 -140
- package/src/AgentBashJobs.test.ts +70 -38
- package/src/AgentCallerConfig.test.ts +39 -7
- package/src/AgentExecutor.test.ts +132 -91
- package/src/AgentExecutor.ts +120 -105
- package/src/AgentExecutorImage.test.ts +2 -2
- package/src/AgentImage.test.ts +4 -3
- package/src/AgentSubagents.test.ts +825 -562
- package/src/AgentTools.test.ts +2 -2
- package/src/AgentTools.ts +331 -288
package/src/AgentExecutor.ts
CHANGED
|
@@ -8,12 +8,10 @@ import { Writable } from "node:stream"
|
|
|
8
8
|
import { Worker } from "node:worker_threads"
|
|
9
9
|
import type * as NodeWorkerThreads from "node:worker_threads"
|
|
10
10
|
import {
|
|
11
|
+
AgentTaskExecutor,
|
|
12
|
+
type AgentTasks,
|
|
13
|
+
agentTasksUnavailable,
|
|
11
14
|
AgentToolHandlers,
|
|
12
|
-
type BackgroundJob,
|
|
13
|
-
BashJob,
|
|
14
|
-
type DelegateResult,
|
|
15
|
-
type SubagentInfo,
|
|
16
|
-
type SubagentResult,
|
|
17
15
|
AgentTools,
|
|
18
16
|
AgentToolsWithSearch,
|
|
19
17
|
CommandLimits,
|
|
@@ -23,12 +21,13 @@ import {
|
|
|
23
21
|
type ExcludableTool,
|
|
24
22
|
ImageAttacher,
|
|
25
23
|
type ImageAttachment,
|
|
26
|
-
JobWatcher,
|
|
27
24
|
makeBashTool,
|
|
28
|
-
|
|
29
|
-
type Subagents,
|
|
30
|
-
subagentsUnavailable,
|
|
25
|
+
Task,
|
|
31
26
|
TaskCompleter,
|
|
27
|
+
type TaskHandle,
|
|
28
|
+
TaskKind,
|
|
29
|
+
TaskOwner,
|
|
30
|
+
TaskWatcher,
|
|
32
31
|
} from "./AgentTools.ts"
|
|
33
32
|
import * as Image from "./Image.ts"
|
|
34
33
|
import { ToolkitRenderer } from "./ToolkitRenderer.ts"
|
|
@@ -131,20 +130,26 @@ export interface ExecuteOptions {
|
|
|
131
130
|
* yet, for example while sub-agents are still running.
|
|
132
131
|
*/
|
|
133
132
|
readonly onTaskComplete: (summary: string) => Effect.Effect<void, string>
|
|
133
|
+
/**
|
|
134
|
+
* The agent running the script. Background bash tasks are scoped to it,
|
|
135
|
+
* like the sub-agents in `agentTasks`: the task functions only see tasks
|
|
136
|
+
* started under the same id. Scripts without one share their tasks.
|
|
137
|
+
*/
|
|
138
|
+
readonly agentId?: string | undefined
|
|
134
139
|
/**
|
|
135
140
|
* The sub-agents of the agent running the script.
|
|
136
141
|
*/
|
|
137
|
-
readonly
|
|
142
|
+
readonly agentTasks: ExecuteAgentTasks
|
|
138
143
|
/**
|
|
139
144
|
* Receives every image `readFile` attached while the script ran.
|
|
140
145
|
*/
|
|
141
146
|
readonly onImage: (image: ImageAttachment) => Effect.Effect<void>
|
|
142
147
|
/**
|
|
143
|
-
* Receives every background `bash`
|
|
144
|
-
* command moved to the background at its timeout. The
|
|
148
|
+
* Receives every background `bash` task the script starts, including a
|
|
149
|
+
* command moved to the background at its timeout. The task can outlive the
|
|
145
150
|
* script, so `await` and `claim` stay usable after it ends.
|
|
146
151
|
*/
|
|
147
|
-
readonly
|
|
152
|
+
readonly onTask?: ((task: TaskHandle) => Effect.Effect<void>) | undefined
|
|
148
153
|
/**
|
|
149
154
|
* Functions added to the script sandbox whose handlers run on the loop
|
|
150
155
|
* side, next to the Agent.
|
|
@@ -161,12 +166,13 @@ export interface ExecuteOptions {
|
|
|
161
166
|
* @since 1.0.0
|
|
162
167
|
* @category Models
|
|
163
168
|
*/
|
|
164
|
-
export interface
|
|
169
|
+
export interface ExecuteAgentTasks extends Omit<AgentTasks, "delegate"> {
|
|
165
170
|
readonly delegate: (options: {
|
|
171
|
+
readonly id: string
|
|
166
172
|
readonly prompt: string
|
|
167
173
|
readonly background: boolean
|
|
168
174
|
readonly environment: EnvironmentUpdate
|
|
169
|
-
}) => Effect.Effect<
|
|
175
|
+
}) => Effect.Effect<Task>
|
|
170
176
|
}
|
|
171
177
|
|
|
172
178
|
/**
|
|
@@ -250,12 +256,12 @@ export class Capabilities extends Schema.Class<Capabilities>("Capabilities")({
|
|
|
250
256
|
Schema.withConstructorDefault(Effect.succeed([])),
|
|
251
257
|
),
|
|
252
258
|
/**
|
|
253
|
-
* Whether the executor hands background `bash`
|
|
254
|
-
* `ExecuteOptions.
|
|
255
|
-
* and executor servers from before
|
|
256
|
-
* model is told to poll with `
|
|
259
|
+
* Whether the executor hands background `bash` tasks to
|
|
260
|
+
* `ExecuteOptions.onTask`, so the agent can push their results. Executors
|
|
261
|
+
* and executor servers from before task pushes leave it out, and then the
|
|
262
|
+
* model is told to poll with `taskOutput`.
|
|
257
263
|
*/
|
|
258
|
-
|
|
264
|
+
taskPushes: Schema.Boolean.pipe(
|
|
259
265
|
Schema.withDecodingDefaultKey(Effect.succeed(false)),
|
|
260
266
|
Schema.withConstructorDefault(Effect.succeed(false)),
|
|
261
267
|
),
|
|
@@ -307,8 +313,8 @@ export interface LocalOptions<Toolkit extends Toolkit.Any = never> {
|
|
|
307
313
|
readonly limits?: Limits | undefined
|
|
308
314
|
/**
|
|
309
315
|
* Built-in tools to leave out of the sandbox and the type declarations.
|
|
310
|
-
* Leaving out `delegate` also leaves out
|
|
311
|
-
*
|
|
316
|
+
* Leaving out `delegate` also leaves out `messageAgent`, and leaving out
|
|
317
|
+
* both `delegate` and `bash` leaves out the task functions.
|
|
312
318
|
*/
|
|
313
319
|
readonly excludeTools?: ReadonlyArray<ExcludableTool> | undefined
|
|
314
320
|
}
|
|
@@ -324,7 +330,7 @@ type LocalServices<Toolkit> =
|
|
|
324
330
|
: never,
|
|
325
331
|
| CurrentDirectory
|
|
326
332
|
| DirectoryChanger
|
|
327
|
-
|
|
|
333
|
+
| AgentTaskExecutor
|
|
328
334
|
| TaskCompleter
|
|
329
335
|
| ImageAttacher
|
|
330
336
|
>
|
|
@@ -507,19 +513,20 @@ const makeLocalWith = Effect.fnUntraced(function* <
|
|
|
507
513
|
const taskServices = Context.empty().pipe(
|
|
508
514
|
Context.add(TaskCompleter, opts.onTaskComplete),
|
|
509
515
|
Context.add(DirectoryChanger, changeDirectory),
|
|
510
|
-
Context.add(
|
|
511
|
-
...opts.
|
|
516
|
+
Context.add(AgentTaskExecutor, {
|
|
517
|
+
...opts.agentTasks,
|
|
512
518
|
// A new agent has only the system prompt, so it gets everything that
|
|
513
519
|
// applies to the directory.
|
|
514
520
|
delegate: (options) =>
|
|
515
521
|
renderEnvironment(currentEnvironment(), { reset: true }).pipe(
|
|
516
522
|
Effect.flatMap((environment) =>
|
|
517
|
-
opts.
|
|
523
|
+
opts.agentTasks.delegate({ ...options, environment }),
|
|
518
524
|
),
|
|
519
525
|
),
|
|
520
526
|
}),
|
|
521
527
|
Context.add(ImageAttacher, opts.onImage),
|
|
522
|
-
Context.add(
|
|
528
|
+
Context.add(TaskWatcher, opts.onTask ?? (() => Effect.void)),
|
|
529
|
+
Context.add(TaskOwner, opts.agentId),
|
|
523
530
|
Context.add(CommandLimits, commandLimits),
|
|
524
531
|
Context.add(Console.Console, console),
|
|
525
532
|
Context.add(References.CurrentLogAnnotations, {}),
|
|
@@ -681,7 +688,7 @@ const makeLocalWith = Effect.fnUntraced(function* <
|
|
|
681
688
|
}),
|
|
682
689
|
tools: Object.keys(tools.tools),
|
|
683
690
|
skills,
|
|
684
|
-
|
|
691
|
+
taskPushes: true,
|
|
685
692
|
})
|
|
686
693
|
}),
|
|
687
694
|
execute: (opts) => execute(opts),
|
|
@@ -704,7 +711,7 @@ const makeLocalWith = Effect.fnUntraced(function* <
|
|
|
704
711
|
Context.add(DirectoryChanger, (directory) =>
|
|
705
712
|
resolveDirectory(cwd, directory),
|
|
706
713
|
),
|
|
707
|
-
Context.add(
|
|
714
|
+
Context.add(AgentTaskExecutor, agentTasksUnavailable),
|
|
708
715
|
// Direct tool calls have no model turn to attach images to.
|
|
709
716
|
Context.add(ImageAttacher, () => Effect.void),
|
|
710
717
|
Context.add(CommandLimits, commandLimits),
|
|
@@ -750,7 +757,8 @@ export const makeRpc = Effect.gen(function* () {
|
|
|
750
757
|
script: opts.script,
|
|
751
758
|
environment: opts.environment,
|
|
752
759
|
loopTools: Object.keys(opts.loopTools ?? {}),
|
|
753
|
-
...(opts.
|
|
760
|
+
...(opts.agentId === undefined ? {} : { agentId: opts.agentId }),
|
|
761
|
+
...(opts.onTask === undefined ? {} : { watchTasks: true }),
|
|
754
762
|
})
|
|
755
763
|
.pipe(
|
|
756
764
|
Stream.tap((part) => {
|
|
@@ -783,13 +791,14 @@ export const makeRpc = Effect.gen(function* () {
|
|
|
783
791
|
latest = part.environment
|
|
784
792
|
return Effect.void
|
|
785
793
|
}
|
|
786
|
-
case "
|
|
787
|
-
if (opts.
|
|
794
|
+
case "Task": {
|
|
795
|
+
if (opts.onTask === undefined) return Effect.void
|
|
788
796
|
const id = part.id
|
|
789
|
-
return opts.
|
|
797
|
+
return opts.onTask({
|
|
790
798
|
id,
|
|
791
|
-
|
|
792
|
-
|
|
799
|
+
kind: part.kind,
|
|
800
|
+
await: Effect.orDie(client.awaitTask({ id })),
|
|
801
|
+
claim: Effect.orDie(client.claimTask({ id })),
|
|
793
802
|
})
|
|
794
803
|
}
|
|
795
804
|
}
|
|
@@ -841,7 +850,7 @@ export const layerLocal = <Toolkit extends Toolkit.Any = never>(
|
|
|
841
850
|
: never,
|
|
842
851
|
| CurrentDirectory
|
|
843
852
|
| DirectoryChanger
|
|
844
|
-
|
|
|
853
|
+
| AgentTaskExecutor
|
|
845
854
|
| TaskCompleter
|
|
846
855
|
| ImageAttacher
|
|
847
856
|
>
|
|
@@ -884,7 +893,7 @@ export const layerRpcServer = <Toolkit extends Toolkit.Any = never>(
|
|
|
884
893
|
: never,
|
|
885
894
|
| CurrentDirectory
|
|
886
895
|
| DirectoryChanger
|
|
887
|
-
|
|
|
896
|
+
| AgentTaskExecutor
|
|
888
897
|
| TaskCompleter
|
|
889
898
|
| ImageAttacher
|
|
890
899
|
>
|
|
@@ -902,25 +911,25 @@ export const layerRpcServer = <Toolkit extends Toolkit.Any = never>(
|
|
|
902
911
|
(effect: Effect.Effect<unknown, string>) => void
|
|
903
912
|
>()
|
|
904
913
|
let requestId = 0
|
|
905
|
-
// Background
|
|
906
|
-
// `
|
|
907
|
-
const
|
|
908
|
-
const
|
|
914
|
+
// Background bash tasks started by any script, for `awaitTask` and
|
|
915
|
+
// `claimTask`.
|
|
916
|
+
const tasks = new Map<string, TaskHandle>()
|
|
917
|
+
const findTask = (id: string) =>
|
|
909
918
|
Effect.suspend(() => {
|
|
910
|
-
const
|
|
911
|
-
return
|
|
912
|
-
? Effect.fail(`No
|
|
913
|
-
: Effect.succeed(
|
|
919
|
+
const task = tasks.get(id)
|
|
920
|
+
return task === undefined
|
|
921
|
+
? Effect.fail(`No task with id "${id}"`)
|
|
922
|
+
: Effect.succeed(task)
|
|
914
923
|
})
|
|
915
924
|
|
|
916
925
|
return Rpcs.of({
|
|
917
926
|
capabilities: () => local.executor.capabilities,
|
|
918
927
|
renderEnvironment: ({ environment, reset }) =>
|
|
919
928
|
local.renderEnvironment(environment, { reset }),
|
|
920
|
-
|
|
921
|
-
Effect.flatMap(
|
|
922
|
-
|
|
923
|
-
Effect.flatMap(
|
|
929
|
+
awaitTask: ({ id }) =>
|
|
930
|
+
Effect.flatMap(findTask(id), (task) => task.await),
|
|
931
|
+
claimTask: ({ id }) =>
|
|
932
|
+
Effect.flatMap(findTask(id), (task) => task.claim),
|
|
924
933
|
respond: ({ id, response }) => {
|
|
925
934
|
const resume = requestResumes.get(id)
|
|
926
935
|
if (resume) {
|
|
@@ -937,7 +946,8 @@ export const layerRpcServer = <Toolkit extends Toolkit.Any = never>(
|
|
|
937
946
|
script,
|
|
938
947
|
environment,
|
|
939
948
|
loopTools,
|
|
940
|
-
|
|
949
|
+
agentId,
|
|
950
|
+
watchTasks,
|
|
941
951
|
}) {
|
|
942
952
|
const queue = yield* Queue.unbounded<
|
|
943
953
|
typeof ExecuteOutput.Type,
|
|
@@ -968,29 +978,32 @@ export const layerRpcServer = <Toolkit extends Toolkit.Any = never>(
|
|
|
968
978
|
Queue.offer(queue, { _tag: "Environment", environment }),
|
|
969
979
|
onTaskComplete: (summary) =>
|
|
970
980
|
request<void>({ _tag: "TaskComplete", summary }),
|
|
971
|
-
|
|
981
|
+
agentId,
|
|
982
|
+
agentTasks: {
|
|
972
983
|
delegate: (options) =>
|
|
973
984
|
Effect.orDie(
|
|
974
|
-
request<
|
|
985
|
+
request<Task>({
|
|
975
986
|
_tag: "Delegate",
|
|
976
987
|
...options,
|
|
977
988
|
}),
|
|
978
989
|
),
|
|
979
|
-
|
|
980
|
-
request<
|
|
981
|
-
|
|
990
|
+
taskOutput: (id) =>
|
|
991
|
+
request<Task>({ _tag: "TaskOutput", id }),
|
|
992
|
+
waitTasks: (ids, { timeoutMs }) =>
|
|
993
|
+
request<ReadonlyArray<Task>>({
|
|
994
|
+
_tag: "WaitTasks",
|
|
982
995
|
ids,
|
|
996
|
+
timeoutMs,
|
|
983
997
|
}),
|
|
984
998
|
messageAgent: (options) =>
|
|
985
|
-
request<
|
|
999
|
+
request<void>({
|
|
986
1000
|
_tag: "MessageAgent",
|
|
987
1001
|
...options,
|
|
988
1002
|
}),
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
_tag: "ListAgents",
|
|
1003
|
+
stopTask: (id) => request<Task>({ _tag: "StopTask", id }),
|
|
1004
|
+
listTasks: Effect.orDie(
|
|
1005
|
+
request<ReadonlyArray<Task>>({
|
|
1006
|
+
_tag: "ListTasks",
|
|
994
1007
|
}),
|
|
995
1008
|
),
|
|
996
1009
|
},
|
|
@@ -1002,14 +1015,15 @@ export const layerRpcServer = <Toolkit extends Toolkit.Any = never>(
|
|
|
1002
1015
|
data: image.data,
|
|
1003
1016
|
})
|
|
1004
1017
|
},
|
|
1005
|
-
// Older clients cannot decode a `
|
|
1006
|
-
...(
|
|
1018
|
+
// Older clients cannot decode a `Task` part.
|
|
1019
|
+
...(watchTasks === true
|
|
1007
1020
|
? {
|
|
1008
|
-
|
|
1009
|
-
|
|
1021
|
+
onTask: (task: TaskHandle) => {
|
|
1022
|
+
tasks.set(task.id, task)
|
|
1010
1023
|
return Queue.offer(queue, {
|
|
1011
|
-
_tag: "
|
|
1012
|
-
id:
|
|
1024
|
+
_tag: "Task",
|
|
1025
|
+
id: task.id,
|
|
1026
|
+
kind: task.kind,
|
|
1013
1027
|
})
|
|
1014
1028
|
},
|
|
1015
1029
|
}
|
|
@@ -1080,14 +1094,16 @@ export const layerRpcServer = <Toolkit extends Toolkit.Any = never>(
|
|
|
1080
1094
|
export const AgentRequest = Schema.TaggedUnion({
|
|
1081
1095
|
TaskComplete: { summary: Schema.String },
|
|
1082
1096
|
Delegate: {
|
|
1097
|
+
id: Schema.String,
|
|
1083
1098
|
prompt: Schema.String,
|
|
1084
1099
|
background: Schema.Boolean,
|
|
1085
1100
|
environment: EnvironmentUpdate,
|
|
1086
1101
|
},
|
|
1087
|
-
|
|
1102
|
+
TaskOutput: { id: Schema.String },
|
|
1103
|
+
WaitTasks: { ids: Schema.Array(Schema.String), timeoutMs: Schema.Finite },
|
|
1088
1104
|
MessageAgent: { id: Schema.String, message: Schema.String },
|
|
1089
|
-
|
|
1090
|
-
|
|
1105
|
+
StopTask: { id: Schema.String },
|
|
1106
|
+
ListTasks: {},
|
|
1091
1107
|
LoopTool: { name: Schema.String, params: Schema.optional(Schema.Json) },
|
|
1092
1108
|
/**
|
|
1093
1109
|
* The script changed its environment. The client records it before it
|
|
@@ -1126,11 +1142,11 @@ export const ExecuteOutput = Schema.TaggedUnion({
|
|
|
1126
1142
|
*/
|
|
1127
1143
|
Environment: { environment: ExecutionEnvironment },
|
|
1128
1144
|
/**
|
|
1129
|
-
* The script started a background `bash`
|
|
1130
|
-
* asked with `
|
|
1131
|
-
* `
|
|
1145
|
+
* The script started a background `bash` task. Only sent when the client
|
|
1146
|
+
* asked with `watchTasks`. The client follows it with `awaitTask` and
|
|
1147
|
+
* `claimTask`.
|
|
1132
1148
|
*/
|
|
1133
|
-
|
|
1149
|
+
Task: { id: Schema.String, kind: TaskKind },
|
|
1134
1150
|
})
|
|
1135
1151
|
|
|
1136
1152
|
/**
|
|
@@ -1158,27 +1174,31 @@ export class Rpcs extends RpcGroup.make(
|
|
|
1158
1174
|
Schema.withDecodingDefaultKey(Effect.succeed([])),
|
|
1159
1175
|
),
|
|
1160
1176
|
/**
|
|
1161
|
-
*
|
|
1162
|
-
|
|
1177
|
+
* The agent running the script, which owns the tasks it starts.
|
|
1178
|
+
*/
|
|
1179
|
+
agentId: Schema.optionalKey(Schema.String),
|
|
1180
|
+
/**
|
|
1181
|
+
* Send a `Task` part for each background bash task the script starts.
|
|
1182
|
+
* Older clients leave it out, as they cannot decode those parts.
|
|
1163
1183
|
*/
|
|
1164
|
-
|
|
1184
|
+
watchTasks: Schema.optionalKey(Schema.Boolean),
|
|
1165
1185
|
}),
|
|
1166
1186
|
success: ExecuteOutput,
|
|
1167
1187
|
stream: true,
|
|
1168
1188
|
}),
|
|
1169
1189
|
/**
|
|
1170
|
-
* Waits for a background
|
|
1190
|
+
* Waits for a background bash task to end and returns its final state.
|
|
1171
1191
|
*/
|
|
1172
|
-
Rpc.make("
|
|
1192
|
+
Rpc.make("awaitTask", {
|
|
1173
1193
|
payload: { id: Schema.String },
|
|
1174
|
-
success:
|
|
1194
|
+
success: Task,
|
|
1175
1195
|
error: Schema.String,
|
|
1176
1196
|
}),
|
|
1177
1197
|
/**
|
|
1178
|
-
* Marks a background
|
|
1179
|
-
* it already was.
|
|
1198
|
+
* Marks a background bash task's final state as reported. Returns `false`
|
|
1199
|
+
* when it already was.
|
|
1180
1200
|
*/
|
|
1181
|
-
Rpc.make("
|
|
1201
|
+
Rpc.make("claimTask", {
|
|
1182
1202
|
payload: { id: Schema.String },
|
|
1183
1203
|
success: Schema.Boolean,
|
|
1184
1204
|
error: Schema.String,
|
|
@@ -1271,15 +1291,17 @@ const handleRequest = (
|
|
|
1271
1291
|
case "TaskComplete":
|
|
1272
1292
|
return opts.onTaskComplete(request.summary)
|
|
1273
1293
|
case "Delegate":
|
|
1274
|
-
return opts.
|
|
1275
|
-
case "
|
|
1276
|
-
return opts.
|
|
1294
|
+
return opts.agentTasks.delegate(request)
|
|
1295
|
+
case "TaskOutput":
|
|
1296
|
+
return opts.agentTasks.taskOutput(request.id)
|
|
1297
|
+
case "WaitTasks":
|
|
1298
|
+
return opts.agentTasks.waitTasks(request.ids, request)
|
|
1277
1299
|
case "MessageAgent":
|
|
1278
|
-
return opts.
|
|
1279
|
-
case "
|
|
1280
|
-
return opts.
|
|
1281
|
-
case "
|
|
1282
|
-
return opts.
|
|
1300
|
+
return opts.agentTasks.messageAgent(request)
|
|
1301
|
+
case "StopTask":
|
|
1302
|
+
return opts.agentTasks.stopTask(request.id)
|
|
1303
|
+
case "ListTasks":
|
|
1304
|
+
return opts.agentTasks.listTasks
|
|
1283
1305
|
case "EnvironmentChanged":
|
|
1284
1306
|
// Recorded by the client before it responds.
|
|
1285
1307
|
return Effect.void
|
|
@@ -1343,27 +1365,20 @@ const errorMessage = (error: unknown): string =>
|
|
|
1343
1365
|
? error.message
|
|
1344
1366
|
: String(error)
|
|
1345
1367
|
|
|
1346
|
-
// Leaving out `delegate` leaves out
|
|
1347
|
-
//
|
|
1368
|
+
// Leaving out `delegate` leaves out `messageAgent`. The task functions
|
|
1369
|
+
// address both kinds, so they go once neither can be started.
|
|
1348
1370
|
const excludedToolNames = (
|
|
1349
1371
|
excludeTools: ReadonlyArray<ExcludableTool> | undefined,
|
|
1350
1372
|
): ReadonlySet<string> => {
|
|
1351
1373
|
const names = new Set<string>(excludeTools)
|
|
1352
1374
|
if (names.has("delegate")) {
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
"
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
]) {
|
|
1359
|
-
names.add(name)
|
|
1375
|
+
names.add("messageAgent")
|
|
1376
|
+
if (names.has("bash")) {
|
|
1377
|
+
for (const name of ["taskOutput", "waitTasks", "stopTask", "listTasks"]) {
|
|
1378
|
+
names.add(name)
|
|
1379
|
+
}
|
|
1360
1380
|
}
|
|
1361
1381
|
}
|
|
1362
|
-
if (names.has("bash")) {
|
|
1363
|
-
names.add("jobOutput")
|
|
1364
|
-
names.add("waitJob")
|
|
1365
|
-
names.add("stopJob")
|
|
1366
|
-
}
|
|
1367
1382
|
return names
|
|
1368
1383
|
}
|
|
1369
1384
|
|
|
@@ -12,7 +12,7 @@ import * as RpcClient from "effect/rpc/RpcClient"
|
|
|
12
12
|
import * as RpcSerialization from "effect/rpc/RpcSerialization"
|
|
13
13
|
import * as RpcServer from "effect/rpc/RpcServer"
|
|
14
14
|
import * as AgentExecutor from "./AgentExecutor.ts"
|
|
15
|
-
import {
|
|
15
|
+
import { agentTasksUnavailable } from "./AgentTools.ts"
|
|
16
16
|
import type { ImageAttachment } from "./AgentTools.ts"
|
|
17
17
|
import { equalBytes, supportedImages } from "./fixtures/TestImages.ts"
|
|
18
18
|
|
|
@@ -87,7 +87,7 @@ describe("RPC image executor", () => {
|
|
|
87
87
|
images.push(image)
|
|
88
88
|
}),
|
|
89
89
|
onTaskComplete: () => Effect.void,
|
|
90
|
-
|
|
90
|
+
agentTasks: agentTasksUnavailable,
|
|
91
91
|
})
|
|
92
92
|
.pipe(Stream.runCollect, Effect.timeout("5 seconds"))
|
|
93
93
|
assert.strictEqual(images.length, fixtures.length)
|
package/src/AgentImage.test.ts
CHANGED
|
@@ -270,9 +270,10 @@ describe("Agent images", () => {
|
|
|
270
270
|
|
|
271
271
|
it.effect("does not copy image bytes into a delegate prompt", () =>
|
|
272
272
|
Effect.gen(function* () {
|
|
273
|
-
const executor = makeExecutor(({
|
|
273
|
+
const executor = makeExecutor(({ agentTasks, environment }) =>
|
|
274
274
|
Stream.fromEffect(
|
|
275
|
-
|
|
275
|
+
agentTasks.delegate({
|
|
276
|
+
id: "1",
|
|
276
277
|
prompt: "child task: describe the layout",
|
|
277
278
|
background: false,
|
|
278
279
|
environment: new AgentExecutor.EnvironmentUpdate({
|
|
@@ -281,7 +282,7 @@ describe("Agent images", () => {
|
|
|
281
282
|
}),
|
|
282
283
|
}),
|
|
283
284
|
).pipe(
|
|
284
|
-
Stream.map((
|
|
285
|
+
Stream.map((task) => task.output),
|
|
285
286
|
Stream.orDie,
|
|
286
287
|
),
|
|
287
288
|
)
|