@agntn/harnesses 0.0.1 → 0.1.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/README.md +26 -6
- package/dist/_chunks/agents-sync.d.mts +22 -5
- package/dist/_chunks/agents-sync.d.mts.map +1 -1
- package/dist/_chunks/agents-sync.mjs +193 -49
- package/dist/_chunks/agents-sync.mjs.map +1 -1
- package/dist/_chunks/mcp.mjs +7 -5
- package/dist/_chunks/mcp.mjs.map +1 -1
- package/dist/_chunks/tool-operations.mjs +40 -7
- package/dist/_chunks/tool-operations.mjs.map +1 -1
- package/dist/_chunks/types.mjs +1 -1
- package/dist/_chunks/types.mjs.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/mcp.d.mts.map +1 -1
- package/dist/tool-operations.d.mts +9 -0
- package/dist/tool-operations.d.mts.map +1 -1
- package/package.json +15 -12
- package/packages/omp/extensions/harnesses.ts +14 -8
- package/packages/pi/extensions/harnesses.ts +30 -8
- package/packages/shared/tui.ts +4 -2
|
@@ -38,6 +38,21 @@ function loadToolOperations(): Promise<typeof HarnessTools> {
|
|
|
38
38
|
return toolOperationsPromise;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
function prepareInfoArguments(args: unknown): unknown {
|
|
42
|
+
if (typeof args !== "object" || args === null || !("id" in args) || typeof args.id !== "string") {
|
|
43
|
+
return args;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
const id: unknown = JSON.parse(args.id);
|
|
48
|
+
return Array.isArray(id) && id.every((value) => typeof value === "string")
|
|
49
|
+
? { ...args, id }
|
|
50
|
+
: args;
|
|
51
|
+
} catch {
|
|
52
|
+
return args;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
41
56
|
function statusRenderers(tool: HarnessToolName) {
|
|
42
57
|
return {
|
|
43
58
|
renderCall(args: unknown, theme: StatusTheme, context: RenderOptions) {
|
|
@@ -87,6 +102,7 @@ export default function harnessesExtension(pi: ExtensionAPI): void {
|
|
|
87
102
|
"Resolved paths are absolute for the current platform and home directory.",
|
|
88
103
|
],
|
|
89
104
|
parameters: schemas.info,
|
|
105
|
+
prepareArguments: prepareInfoArguments,
|
|
90
106
|
...statusRenderers("harnesses_info"),
|
|
91
107
|
async execute(
|
|
92
108
|
_toolCallId,
|
|
@@ -114,20 +130,24 @@ export default function harnessesExtension(pi: ExtensionAPI): void {
|
|
|
114
130
|
async execute(
|
|
115
131
|
_toolCallId,
|
|
116
132
|
params: HarnessSchemas.ModelsParams,
|
|
133
|
+
signal,
|
|
117
134
|
): Promise<AgentToolResult<HarnessTools.ModelsOutcome | HarnessTools.RunFailure>> {
|
|
118
135
|
const { listHarnessModels } = await loadToolOperations();
|
|
119
136
|
const { content, details, isError } = await listHarnessModels(params.id, {
|
|
120
137
|
search: params.search,
|
|
121
138
|
cwd: params.cwd,
|
|
122
139
|
timeoutSeconds: params.timeoutSeconds,
|
|
140
|
+
signal,
|
|
123
141
|
});
|
|
124
142
|
if (isError) {
|
|
125
143
|
const message =
|
|
126
144
|
"error" in details
|
|
127
145
|
? details.error
|
|
128
|
-
: details.
|
|
129
|
-
? `Harness ${details.id} model listing
|
|
130
|
-
: details.
|
|
146
|
+
: details.aborted
|
|
147
|
+
? `Harness ${details.id} model listing aborted`
|
|
148
|
+
: details.timedOut
|
|
149
|
+
? `Harness ${details.id} model listing timed out`
|
|
150
|
+
: details.stderr || `Harness ${details.id} exited with code ${details.exitCode}`;
|
|
131
151
|
throw new Error(message);
|
|
132
152
|
}
|
|
133
153
|
return { content, details };
|
|
@@ -152,23 +172,25 @@ export default function harnessesExtension(pi: ExtensionAPI): void {
|
|
|
152
172
|
async execute(
|
|
153
173
|
_toolCallId,
|
|
154
174
|
params: HarnessSchemas.RunParams,
|
|
175
|
+
signal,
|
|
155
176
|
): Promise<AgentToolResult<HarnessTools.RunOutcome | HarnessTools.RunFailure>> {
|
|
156
177
|
const { runHarness } = await loadToolOperations();
|
|
157
178
|
const { content, details, isError } = await runHarness(params.id, params.prompt, {
|
|
158
179
|
cwd: params.cwd,
|
|
159
180
|
model: params.model,
|
|
160
181
|
timeoutSeconds: params.timeoutSeconds,
|
|
182
|
+
signal,
|
|
161
183
|
structured: params.structured,
|
|
162
184
|
tools: params.tools,
|
|
163
185
|
readOnly: params.readOnly,
|
|
164
186
|
});
|
|
165
187
|
if (isError) {
|
|
188
|
+
if ("error" in details) throw new Error(details.error);
|
|
166
189
|
const message =
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
: details.stderr || `Harness ${details.id} exited with code ${details.exitCode}`;
|
|
190
|
+
content[0]?.text ??
|
|
191
|
+
(details.timedOut
|
|
192
|
+
? `Harness ${details.id} timed out`
|
|
193
|
+
: details.stderr || `Harness ${details.id} exited with code ${details.exitCode}`);
|
|
172
194
|
throw new Error(message);
|
|
173
195
|
}
|
|
174
196
|
return { content, details };
|
package/packages/shared/tui.ts
CHANGED
|
@@ -222,7 +222,7 @@ function modelsMeta(details: ResultDetails): string[] {
|
|
|
222
222
|
const models = listLength(details, "models");
|
|
223
223
|
return compactStrings([
|
|
224
224
|
id ? sanitizeTerminalText(id) : undefined,
|
|
225
|
-
models === undefined ? undefined : `${models} models`,
|
|
225
|
+
details.aborted === true ? "aborted" : models === undefined ? undefined : `${models} models`,
|
|
226
226
|
]);
|
|
227
227
|
}
|
|
228
228
|
|
|
@@ -230,7 +230,9 @@ function runMeta(details: ResultDetails): string[] {
|
|
|
230
230
|
const meta: string[] = [];
|
|
231
231
|
const id = scalar(details, "id");
|
|
232
232
|
if (id) meta.push(sanitizeTerminalText(id));
|
|
233
|
-
if (details.
|
|
233
|
+
if (details.aborted === true) {
|
|
234
|
+
meta.push("aborted");
|
|
235
|
+
} else if (details.timedOut === true) {
|
|
234
236
|
meta.push("timed out");
|
|
235
237
|
} else if (typeof details.exitCode === "number") {
|
|
236
238
|
meta.push(`exit ${details.exitCode}`);
|