@saturn-universe/tools 0.1.2-dev.4 → 0.1.2-dev.6
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/executor.js +6 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/team.d.ts +7 -1
- package/dist/team.js +59 -1
- package/package.json +2 -2
package/dist/executor.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { canonicalJson, earlierDeadline, isLimited, reportDiagnostic, resolveSubagentWallTimeMs, RuntimeError, tightenToolPermission, validateArtifactRef, validateStartedRun, } from '@saturn-universe/core';
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
+
import { isTeamMemberControlTool } from './team.js';
|
|
4
5
|
import { outsideWorkspacePrefix, processTimeoutMs } from './workspace.js';
|
|
5
6
|
export const maxPluginTimeoutMs = 7_200_000;
|
|
6
7
|
const artifact = z.unknown().refine((value) => value !== undefined, 'artifact is required');
|
|
@@ -296,8 +297,11 @@ export function createToolExecutor(d) {
|
|
|
296
297
|
const workers = Array.from({ length: Math.min(env.config.limits.maxParallelTools, pending.length) }, async () => {
|
|
297
298
|
while (cursor < pending.length && !blocked) {
|
|
298
299
|
const call = pending[cursor++];
|
|
299
|
-
const
|
|
300
|
-
|
|
300
|
+
const definition = call.definition;
|
|
301
|
+
const serialCall = definition.concurrency === 'serial_per_run';
|
|
302
|
+
// Member controls must remain available while workers hold the team tool permits.
|
|
303
|
+
const coordinatorControl = definition.source.kind === 'builtin' && isTeamMemberControlTool(definition.name);
|
|
304
|
+
if (env.config.team && !coordinatorControl) {
|
|
301
305
|
let permits = teamPermits.get(permitKey);
|
|
302
306
|
if (!permits) {
|
|
303
307
|
permits = new ToolPermits(env.config.limits.maxParallelTools);
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ export { createCounterTool } from './counter.js';
|
|
|
5
5
|
export { createPlannerTool, plannerToolName } from './planner.js';
|
|
6
6
|
export { createExploreHypothesesTool, exploreHypothesesToolName } from './search.js';
|
|
7
7
|
export type { ExploreHypothesisInput } from './search.js';
|
|
8
|
-
export { createSpawnTeamTool, createTeamNotifyParentTool, spawnTeamToolName, teamNotifyParentToolName, } from './team.js';
|
|
9
|
-
export type { CreateSpawnTeamToolOptions, CreateTeamNotifyParentToolOptions, SpawnTeamCallerContext, TeamNotifyParentCallerContext, TeamNotifyParentDelivery, } from './team.js';
|
|
8
|
+
export { createSpawnTeamTool, createTeamNotifyParentTool, createTeamSteerMemberTool, createTeamStopMemberTool, isTeamMemberControlTool, teamStopMemberToolName, teamSteerMemberToolName, spawnTeamToolName, teamNotifyParentToolName, } from './team.js';
|
|
9
|
+
export type { CreateSpawnTeamToolOptions, CreateTeamNotifyParentToolOptions, SpawnTeamCallerContext, TeamNotifyParentCallerContext, TeamNotifyParentDelivery, TeamMemberAction, } from './team.js';
|
|
10
10
|
export { createTodoWriteTool, todoWriteToolName } from './todo.js';
|
|
11
11
|
export { createDataReviewTool, dataReviewToolName, dataReviewToolSet } from './data-review.js';
|
|
12
12
|
export type { TodoItem, TodoStatus } from '@saturn-universe/core';
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export { createToolExecutor, maxPluginTimeoutMs } from './executor.js';
|
|
|
3
3
|
export { createCounterTool } from './counter.js';
|
|
4
4
|
export { createPlannerTool, plannerToolName } from './planner.js';
|
|
5
5
|
export { createExploreHypothesesTool, exploreHypothesesToolName } from './search.js';
|
|
6
|
-
export { createSpawnTeamTool, createTeamNotifyParentTool, spawnTeamToolName, teamNotifyParentToolName, } from './team.js';
|
|
6
|
+
export { createSpawnTeamTool, createTeamNotifyParentTool, createTeamSteerMemberTool, createTeamStopMemberTool, isTeamMemberControlTool, teamStopMemberToolName, teamSteerMemberToolName, spawnTeamToolName, teamNotifyParentToolName, } from './team.js';
|
|
7
7
|
export { createTodoWriteTool, todoWriteToolName } from './todo.js';
|
|
8
8
|
export { createDataReviewTool, dataReviewToolName, dataReviewToolSet } from './data-review.js';
|
|
9
9
|
export { createWorkspaceTools, containerReadonlyPrefix, maxShellTimeoutMs, outsideWorkspacePrefix, readonlyCommandAllowlist, } from './workspace.js';
|
package/dist/team.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RunId, ToolBinding, ToolContext } from '@saturn-universe/core';
|
|
1
|
+
import type { RunId, TeamMemberActionResult, ToolBinding, ToolContext } from '@saturn-universe/core';
|
|
2
2
|
export declare const spawnTeamToolName = "spawn_team";
|
|
3
3
|
export declare const teamNotifyParentToolName = "team_notify_parent";
|
|
4
4
|
export interface SpawnTeamCallerContext {
|
|
@@ -34,3 +34,9 @@ export interface CreateTeamNotifyParentToolOptions {
|
|
|
34
34
|
readonly notifyParent?: (delivery: TeamNotifyParentDelivery) => Promise<void>;
|
|
35
35
|
}
|
|
36
36
|
export declare function createTeamNotifyParentTool(options?: CreateTeamNotifyParentToolOptions): ToolBinding;
|
|
37
|
+
export declare const teamSteerMemberToolName = "team_steer_member";
|
|
38
|
+
export declare const teamStopMemberToolName = "team_stop_member";
|
|
39
|
+
export declare function isTeamMemberControlTool(name: string): boolean;
|
|
40
|
+
export type TeamMemberAction = (ctx: ToolContext, memberId: string, text: string) => Promise<TeamMemberActionResult>;
|
|
41
|
+
export declare function createTeamSteerMemberTool(steer: TeamMemberAction): ToolBinding;
|
|
42
|
+
export declare function createTeamStopMemberTool(stop: TeamMemberAction): ToolBinding;
|
package/dist/team.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { maxTeamMembers, RuntimeError, teamNotifyMessagePrefix, validateTeamConfig, } from '@saturn-universe/core';
|
|
1
|
+
import { maxTeamMembers, RuntimeError, teamNotifyMessagePrefix, validateTeamConfig, teamMemberIdPattern, teamRootId, } from '@saturn-universe/core';
|
|
2
2
|
export const spawnTeamToolName = 'spawn_team';
|
|
3
3
|
export const teamNotifyParentToolName = 'team_notify_parent';
|
|
4
4
|
const MAIN_PARENT_ALIASES = new Set(['coordinator', 'root', 'self']);
|
|
@@ -273,6 +273,64 @@ export function createTeamNotifyParentTool(options) {
|
|
|
273
273
|
},
|
|
274
274
|
};
|
|
275
275
|
}
|
|
276
|
+
export const teamSteerMemberToolName = 'team_steer_member';
|
|
277
|
+
export const teamStopMemberToolName = 'team_stop_member';
|
|
278
|
+
export function isTeamMemberControlTool(name) {
|
|
279
|
+
return name === teamSteerMemberToolName || name === teamStopMemberToolName;
|
|
280
|
+
}
|
|
281
|
+
export function createTeamSteerMemberTool(steer) {
|
|
282
|
+
return createTeamMemberTool(teamSteerMemberToolName, 'Send a corrective instruction to one active team worker. Interrupts inference or waits for the current tool batch to finish.', 'message', steer);
|
|
283
|
+
}
|
|
284
|
+
export function createTeamStopMemberTool(stop) {
|
|
285
|
+
return createTeamMemberTool(teamStopMemberToolName, 'Stop one active team worker. Provide the reason. The other workers continue, and you receive a report after cleanup.', 'reason', stop);
|
|
286
|
+
}
|
|
287
|
+
function createTeamMemberTool(name, description, field, action) {
|
|
288
|
+
return {
|
|
289
|
+
definition: {
|
|
290
|
+
name,
|
|
291
|
+
version: '1',
|
|
292
|
+
description,
|
|
293
|
+
inputSchema: {
|
|
294
|
+
type: 'object',
|
|
295
|
+
properties: {
|
|
296
|
+
memberId: { type: 'string', minLength: 1, maxLength: 64 },
|
|
297
|
+
[field]: { type: 'string', minLength: 1, maxLength: 4000 },
|
|
298
|
+
},
|
|
299
|
+
required: ['memberId', field],
|
|
300
|
+
additionalProperties: false,
|
|
301
|
+
},
|
|
302
|
+
source: { kind: 'builtin' },
|
|
303
|
+
effects: 'read',
|
|
304
|
+
supportsIdempotencyKey: false,
|
|
305
|
+
supportsReconcile: false,
|
|
306
|
+
concurrency: 'parallel',
|
|
307
|
+
timeoutMs: 10000,
|
|
308
|
+
},
|
|
309
|
+
handler: {
|
|
310
|
+
async invoke(input, ctx) {
|
|
311
|
+
const parsed = input;
|
|
312
|
+
const memberId = parsed?.memberId;
|
|
313
|
+
if (typeof memberId !== 'string' || !teamMemberIdPattern.test(memberId) || memberId === teamRootId)
|
|
314
|
+
return notifyError('INVALID_INPUT', 'memberId must identify a worker in the current Run');
|
|
315
|
+
const value = parsed?.[field];
|
|
316
|
+
const text = typeof value === 'string' ? value.trim() : '';
|
|
317
|
+
if (!text || text.length > 4000)
|
|
318
|
+
return notifyError('INVALID_INPUT', `${field} must be a non-empty string up to 4000 characters`);
|
|
319
|
+
const result = await action(ctx, memberId, text);
|
|
320
|
+
if (result.status === 'forbidden' || result.status === 'invalid_target')
|
|
321
|
+
return notifyError(result.status.toUpperCase(), result.message);
|
|
322
|
+
return {
|
|
323
|
+
effect: result.status === 'accepted' ? 'applied' : 'none',
|
|
324
|
+
outcome: {
|
|
325
|
+
status: 'success',
|
|
326
|
+
content: [{ type: 'text', text: result.message }],
|
|
327
|
+
data: { kind: name, memberId, ...result },
|
|
328
|
+
},
|
|
329
|
+
};
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
};
|
|
333
|
+
}
|
|
276
334
|
function notifyError(code, message) {
|
|
277
335
|
return {
|
|
278
336
|
effect: 'none',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saturn-universe/tools",
|
|
3
|
-
"version": "0.1.2-dev.
|
|
3
|
+
"version": "0.1.2-dev.6",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@saturn-universe/core": "0.1.2-dev.
|
|
16
|
+
"@saturn-universe/core": "0.1.2-dev.6",
|
|
17
17
|
"zod": "4.6.0"
|
|
18
18
|
}
|
|
19
19
|
}
|