@ericsanchezok/synergy-util 3.0.14 → 3.0.16
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/activity.d.ts +67 -0
- package/dist/activity.js +461 -0
- package/dist/capability.js +1 -0
- package/dist/model-limit.d.ts +8 -1
- package/dist/model-limit.js +8 -1
- package/dist/runtime-shutdown.d.ts +4 -0
- package/dist/runtime-shutdown.js +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export type ActivityDisplayMode = "full" | "balanced" | "minimal";
|
|
3
|
+
export type SemanticCategory = "file-read" | "file-write" | "shell" | "search" | "browser" | "web" | "memory" | "note" | "blueprint" | "task" | "dag" | "schedule" | "session" | "session-control" | "community" | "network" | "analyze" | "config" | "communication" | "skill" | "research" | "generic";
|
|
4
|
+
export type ActivityFamily = "inspect-local" | "research-web" | "modify-files" | "execute" | "browser" | "delegate" | "produce" | "external-action" | "coordination" | "generic";
|
|
5
|
+
export declare const ACTIVITY_FAMILY_ORDER: readonly ActivityFamily[];
|
|
6
|
+
export declare const MAX_ACTIVITY_GROUP_STEPS = 24;
|
|
7
|
+
export declare const ActivitySummaryStateSchema: z.ZodEnum<{
|
|
8
|
+
live: "live";
|
|
9
|
+
stable: "stable";
|
|
10
|
+
fallback: "fallback";
|
|
11
|
+
}>;
|
|
12
|
+
export type ActivitySummaryState = z.infer<typeof ActivitySummaryStateSchema>;
|
|
13
|
+
export declare const ActivityDerivedMetadataSchema: z.ZodObject<{
|
|
14
|
+
v: z.ZodLiteral<1>;
|
|
15
|
+
seq: z.ZodNumber;
|
|
16
|
+
reasoning: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
17
|
+
state: z.ZodEnum<{
|
|
18
|
+
live: "live";
|
|
19
|
+
stable: "stable";
|
|
20
|
+
fallback: "fallback";
|
|
21
|
+
}>;
|
|
22
|
+
text: z.ZodOptional<z.ZodString>;
|
|
23
|
+
source: z.ZodOptional<z.ZodEnum<{
|
|
24
|
+
nano: "nano";
|
|
25
|
+
"partial-live": "partial-live";
|
|
26
|
+
}>>;
|
|
27
|
+
updatedAt: z.ZodNumber;
|
|
28
|
+
}, z.core.$strip>>>;
|
|
29
|
+
groups: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
30
|
+
state: z.ZodEnum<{
|
|
31
|
+
live: "live";
|
|
32
|
+
stable: "stable";
|
|
33
|
+
fallback: "fallback";
|
|
34
|
+
}>;
|
|
35
|
+
signature: z.ZodOptional<z.ZodString>;
|
|
36
|
+
text: z.ZodOptional<z.ZodString>;
|
|
37
|
+
updatedAt: z.ZodNumber;
|
|
38
|
+
}, z.core.$strip>>>;
|
|
39
|
+
now: z.ZodOptional<z.ZodObject<{
|
|
40
|
+
text: z.ZodString;
|
|
41
|
+
source: z.ZodEnum<{
|
|
42
|
+
reasoning: "reasoning";
|
|
43
|
+
group: "group";
|
|
44
|
+
}>;
|
|
45
|
+
updatedAt: z.ZodNumber;
|
|
46
|
+
}, z.core.$strip>>;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
export type ActivityDerivedMetadata = z.infer<typeof ActivityDerivedMetadataSchema>;
|
|
49
|
+
export declare function semanticCategoryForKnownTool(toolName: string): SemanticCategory | undefined;
|
|
50
|
+
export declare function toolDisplayMetadata(metadata: unknown): Record<string, unknown> | undefined;
|
|
51
|
+
export declare function toolDisplayPolicy(metadata: unknown): {
|
|
52
|
+
toolCardHidden: boolean;
|
|
53
|
+
mediaGeneration: boolean;
|
|
54
|
+
};
|
|
55
|
+
export declare function isActivityGroupableTool(tool: string, metadata?: Record<string, unknown>): boolean;
|
|
56
|
+
export declare function resolveActivityDisplay(value: unknown): ActivityDisplayMode;
|
|
57
|
+
export declare function classifySemanticCategory(toolName: string, input?: Record<string, unknown>): SemanticCategory;
|
|
58
|
+
export declare function activityFamilyForTool(tool: string, input?: Record<string, unknown>, metadata?: Record<string, unknown>): ActivityFamily;
|
|
59
|
+
export declare function activityScopeForTool(input?: Record<string, unknown>, metadata?: Record<string, unknown>, options?: {
|
|
60
|
+
family?: ActivityFamily;
|
|
61
|
+
workspaceRoot?: string;
|
|
62
|
+
}): {
|
|
63
|
+
key: string;
|
|
64
|
+
label?: string;
|
|
65
|
+
};
|
|
66
|
+
export declare function activityGroupKey(messageID: string, family: ActivityFamily, scopeKey: string, firstPartID: string): string;
|
|
67
|
+
export declare function isActivityReceiptTool(tool: string, family: ActivityFamily): boolean;
|
package/dist/activity.js
ADDED
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const ACTIVITY_FAMILY_ORDER = [
|
|
3
|
+
"inspect-local",
|
|
4
|
+
"research-web",
|
|
5
|
+
"modify-files",
|
|
6
|
+
"execute",
|
|
7
|
+
"browser",
|
|
8
|
+
"delegate",
|
|
9
|
+
"produce",
|
|
10
|
+
"external-action",
|
|
11
|
+
"coordination",
|
|
12
|
+
"generic",
|
|
13
|
+
];
|
|
14
|
+
export const MAX_ACTIVITY_GROUP_STEPS = 24;
|
|
15
|
+
export const ActivitySummaryStateSchema = z.enum(["live", "stable", "fallback"]);
|
|
16
|
+
export const ActivityDerivedMetadataSchema = z.object({
|
|
17
|
+
v: z.literal(1),
|
|
18
|
+
seq: z.number().int().nonnegative(),
|
|
19
|
+
reasoning: z
|
|
20
|
+
.record(z.string(), z.object({
|
|
21
|
+
state: ActivitySummaryStateSchema,
|
|
22
|
+
text: z.string().max(280).optional(),
|
|
23
|
+
source: z.enum(["nano", "partial-live"]).optional(),
|
|
24
|
+
updatedAt: z.number(),
|
|
25
|
+
}))
|
|
26
|
+
.optional(),
|
|
27
|
+
groups: z
|
|
28
|
+
.record(z.string(), z.object({
|
|
29
|
+
state: ActivitySummaryStateSchema,
|
|
30
|
+
signature: z.string().max(2_048).optional(),
|
|
31
|
+
text: z.string().max(200).optional(),
|
|
32
|
+
updatedAt: z.number(),
|
|
33
|
+
}))
|
|
34
|
+
.optional(),
|
|
35
|
+
now: z
|
|
36
|
+
.object({
|
|
37
|
+
text: z.string().max(120),
|
|
38
|
+
source: z.enum(["reasoning", "group"]),
|
|
39
|
+
updatedAt: z.number(),
|
|
40
|
+
})
|
|
41
|
+
.optional(),
|
|
42
|
+
});
|
|
43
|
+
const TOOL_CATEGORIES = {
|
|
44
|
+
websearch: "web",
|
|
45
|
+
webfetch: "web",
|
|
46
|
+
browser_navigation: "browser",
|
|
47
|
+
browser_snapshot: "browser",
|
|
48
|
+
browser_action: "browser",
|
|
49
|
+
browser_wait: "browser",
|
|
50
|
+
browser_read: "browser",
|
|
51
|
+
browser_inspect: "browser",
|
|
52
|
+
browser_screenshot: "browser",
|
|
53
|
+
browser_eval: "browser",
|
|
54
|
+
browser_console: "browser",
|
|
55
|
+
browser_network: "browser",
|
|
56
|
+
browser_performance: "browser",
|
|
57
|
+
browser_audit: "browser",
|
|
58
|
+
browser_emulate: "browser",
|
|
59
|
+
browser_dialog: "browser",
|
|
60
|
+
browser_upload: "browser",
|
|
61
|
+
browser_downloads: "browser",
|
|
62
|
+
browser_clipboard: "browser",
|
|
63
|
+
browser_assets: "browser",
|
|
64
|
+
browser_annotate: "browser",
|
|
65
|
+
browser_view: "browser",
|
|
66
|
+
arxiv_search: "search",
|
|
67
|
+
arxiv_download: "search",
|
|
68
|
+
grep: "search",
|
|
69
|
+
file_search: "search",
|
|
70
|
+
scan_files: "search",
|
|
71
|
+
ast_grep: "search",
|
|
72
|
+
parse_code: "analyze",
|
|
73
|
+
glob: "search",
|
|
74
|
+
read: "file-read",
|
|
75
|
+
view_file: "file-read",
|
|
76
|
+
list: "file-read",
|
|
77
|
+
look_at: "analyze",
|
|
78
|
+
view_image: "analyze",
|
|
79
|
+
scan_document: "analyze",
|
|
80
|
+
edit: "file-write",
|
|
81
|
+
revise_file: "file-write",
|
|
82
|
+
resolve_conflicts: "file-write",
|
|
83
|
+
write: "file-write",
|
|
84
|
+
save_file: "file-write",
|
|
85
|
+
bash: "shell",
|
|
86
|
+
process: "shell",
|
|
87
|
+
lsp: "analyze",
|
|
88
|
+
memory_search: "memory",
|
|
89
|
+
memory_get: "memory",
|
|
90
|
+
memory_write: "memory",
|
|
91
|
+
memory_edit: "memory",
|
|
92
|
+
note_search: "note",
|
|
93
|
+
note_write: "note",
|
|
94
|
+
note_edit: "note",
|
|
95
|
+
note_list: "note",
|
|
96
|
+
note_read: "note",
|
|
97
|
+
note_archive: "note",
|
|
98
|
+
note_delete: "note",
|
|
99
|
+
blueprint_loop_stop: "blueprint",
|
|
100
|
+
blueprint_loop_approve: "blueprint",
|
|
101
|
+
blueprint_loop_reject: "blueprint",
|
|
102
|
+
skill: "skill",
|
|
103
|
+
task: "task",
|
|
104
|
+
task_list: "task",
|
|
105
|
+
task_output: "task",
|
|
106
|
+
task_cancel: "task",
|
|
107
|
+
loop_stop: "task",
|
|
108
|
+
light_loop_approve: "task",
|
|
109
|
+
light_loop_reject: "task",
|
|
110
|
+
dagwrite: "dag",
|
|
111
|
+
dagread: "dag",
|
|
112
|
+
dagpatch: "dag",
|
|
113
|
+
pathway_read: "dag",
|
|
114
|
+
pathway_write: "dag",
|
|
115
|
+
lattice_submit: "task",
|
|
116
|
+
todowrite: "dag",
|
|
117
|
+
todoread: "dag",
|
|
118
|
+
session_list: "session",
|
|
119
|
+
scope_list: "session",
|
|
120
|
+
session_read: "session",
|
|
121
|
+
session_search: "session",
|
|
122
|
+
session_send: "session",
|
|
123
|
+
session_control: "session-control",
|
|
124
|
+
boss_spawn: "session",
|
|
125
|
+
boss_assign: "session",
|
|
126
|
+
boss_report: "session",
|
|
127
|
+
boss_status: "session",
|
|
128
|
+
boss_cancel: "session-control",
|
|
129
|
+
boss_project: "session",
|
|
130
|
+
channel_push: "communication",
|
|
131
|
+
agenda_schedule: "schedule",
|
|
132
|
+
agenda_watch: "schedule",
|
|
133
|
+
agenda_list: "schedule",
|
|
134
|
+
agenda_update: "schedule",
|
|
135
|
+
agenda_cancel: "schedule",
|
|
136
|
+
agenda_trigger: "schedule",
|
|
137
|
+
agenda_logs: "schedule",
|
|
138
|
+
research_init: "research",
|
|
139
|
+
research_state: "research",
|
|
140
|
+
research_idea: "research",
|
|
141
|
+
research_plan: "research",
|
|
142
|
+
research_experiment: "research",
|
|
143
|
+
research_claim: "research",
|
|
144
|
+
research_exhibit: "research",
|
|
145
|
+
research_paper: "research",
|
|
146
|
+
research_submission: "research",
|
|
147
|
+
research_wiki: "research",
|
|
148
|
+
research_timeline: "research",
|
|
149
|
+
search_tools: "search",
|
|
150
|
+
expand_tools: "config",
|
|
151
|
+
runtime_reload: "config",
|
|
152
|
+
profile_get: "config",
|
|
153
|
+
profile_update: "config",
|
|
154
|
+
worktree_enter: "config",
|
|
155
|
+
worktree_leave: "config",
|
|
156
|
+
worktree_list: "config",
|
|
157
|
+
connect: "network",
|
|
158
|
+
inspire_status: "config",
|
|
159
|
+
inspire_config: "config",
|
|
160
|
+
inspire_login: "config",
|
|
161
|
+
inspire_submit: "shell",
|
|
162
|
+
inspire_submit_hpc: "shell",
|
|
163
|
+
inspire_jobs: "analyze",
|
|
164
|
+
inspire_job_detail: "analyze",
|
|
165
|
+
inspire_logs: "analyze",
|
|
166
|
+
inspire_metrics: "analyze",
|
|
167
|
+
inspire_stop: "shell",
|
|
168
|
+
inspire_images: "analyze",
|
|
169
|
+
inspire_image_push: "shell",
|
|
170
|
+
inspire_notebook: "shell",
|
|
171
|
+
inspire_models: "analyze",
|
|
172
|
+
inspire_inference: "shell",
|
|
173
|
+
question: "communication",
|
|
174
|
+
email_send: "communication",
|
|
175
|
+
email_read: "communication",
|
|
176
|
+
clarus_submit_task_result: "communication",
|
|
177
|
+
clarus_extend_task: "communication",
|
|
178
|
+
github_deliver_fix: "communication",
|
|
179
|
+
openai_image_gen: "communication",
|
|
180
|
+
openai_image_edit: "communication",
|
|
181
|
+
diagram: "analyze",
|
|
182
|
+
render: "analyze",
|
|
183
|
+
attach: "communication",
|
|
184
|
+
response_card: "communication",
|
|
185
|
+
qzcli_qz_auth_login: "config",
|
|
186
|
+
qzcli_qz_set_cookie: "config",
|
|
187
|
+
qzcli_qz_list_workspaces: "config",
|
|
188
|
+
qzcli_qz_refresh_resources: "config",
|
|
189
|
+
qzcli_qz_get_availability: "analyze",
|
|
190
|
+
qzcli_qz_list_jobs: "shell",
|
|
191
|
+
qzcli_qz_get_job_detail: "analyze",
|
|
192
|
+
qzcli_qz_stop_job: "shell",
|
|
193
|
+
qzcli_qz_get_usage: "analyze",
|
|
194
|
+
qzcli_qz_inspect_status_catalog: "analyze",
|
|
195
|
+
qzcli_qz_track_job: "task",
|
|
196
|
+
qzcli_qz_list_tracked_jobs: "task",
|
|
197
|
+
qzcli_qz_create_job: "shell",
|
|
198
|
+
qzcli_qz_create_hpc_job: "shell",
|
|
199
|
+
qzcli_qz_get_hpc_usage: "analyze",
|
|
200
|
+
"context7_resolve-library-id": "search",
|
|
201
|
+
"context7_query-docs": "web",
|
|
202
|
+
};
|
|
203
|
+
export function semanticCategoryForKnownTool(toolName) {
|
|
204
|
+
return TOOL_CATEGORIES[toolName];
|
|
205
|
+
}
|
|
206
|
+
const PATTERN_FALLBACKS = [
|
|
207
|
+
{ pattern: /^(web)?search/i, category: "web" },
|
|
208
|
+
{ pattern: /^(web)?fetch/i, category: "web" },
|
|
209
|
+
{ pattern: /^browser[-_]/i, category: "browser" },
|
|
210
|
+
{ pattern: /^arxiv/i, category: "search" },
|
|
211
|
+
{
|
|
212
|
+
pattern: /^(grep|glob|find|ripgrep|rg|search[-_]?files?|codebase[-_]?search|file[-_]?search)/i,
|
|
213
|
+
category: "search",
|
|
214
|
+
},
|
|
215
|
+
{ pattern: /^(read|get|load|fetch|cat|view|head|tail)[-_]?file/i, category: "file-read" },
|
|
216
|
+
{ pattern: /^(list|ls|dir)[-_]?(dir|files?|folder)?$/i, category: "file-read" },
|
|
217
|
+
{ pattern: /^(write|create|edit|update|patch|modify|replace|insert|append)[-_]?file/i, category: "file-write" },
|
|
218
|
+
{ pattern: /^(apply[-_]?diff|save[-_]?file)/i, category: "file-write" },
|
|
219
|
+
{ pattern: /^(run|exec|execute|shell|bash|sh|cmd|terminal|command)/i, category: "shell" },
|
|
220
|
+
{ pattern: /[-_](command|exec|shell|terminal)$/i, category: "shell" },
|
|
221
|
+
{ pattern: /^(look|analyze|vision|describe|inspect|examine)/i, category: "analyze" },
|
|
222
|
+
{ pattern: /^(memory|library|remember|recall)/i, category: "memory" },
|
|
223
|
+
{ pattern: /^note[-_]/i, category: "note" },
|
|
224
|
+
{ pattern: /^skill/i, category: "skill" },
|
|
225
|
+
{ pattern: /^blueprint[-_]/i, category: "blueprint" },
|
|
226
|
+
{ pattern: /^(task|delegate|dispatch|spawn)/i, category: "task" },
|
|
227
|
+
{ pattern: /^(dag|plan)/i, category: "dag" },
|
|
228
|
+
{ pattern: /^todo/i, category: "dag" },
|
|
229
|
+
{ pattern: /^session[-_]/i, category: "session" },
|
|
230
|
+
{ pattern: /^scope[-_]/i, category: "session" },
|
|
231
|
+
{ pattern: /^(agenda|schedule|cron|timer|remind)/i, category: "schedule" },
|
|
232
|
+
{ pattern: /^research[-_]/i, category: "research" },
|
|
233
|
+
{ pattern: /^(config|setting|profile|runtime)/i, category: "config" },
|
|
234
|
+
{ pattern: /^inspire[-_]/i, category: "shell" },
|
|
235
|
+
{ pattern: /^(email|mail)/i, category: "communication" },
|
|
236
|
+
{ pattern: /^(send|notify|message)/i, category: "communication" },
|
|
237
|
+
{ pattern: /^question/i, category: "communication" },
|
|
238
|
+
{ pattern: /^(openai[-_])?image[-_](gen|edit)/i, category: "communication" },
|
|
239
|
+
{ pattern: /^diagram/i, category: "analyze" },
|
|
240
|
+
{ pattern: /^attach/i, category: "communication" },
|
|
241
|
+
];
|
|
242
|
+
const ACTIVITY_FAMILIES = new Set(ACTIVITY_FAMILY_ORDER);
|
|
243
|
+
const EXTERNAL_ACTION_TOOLS = new Set([
|
|
244
|
+
"email_send",
|
|
245
|
+
"email_mark_read",
|
|
246
|
+
"session_send",
|
|
247
|
+
"clarus_submit_task_result",
|
|
248
|
+
"clarus_extend_task",
|
|
249
|
+
"github_deliver_fix",
|
|
250
|
+
"question",
|
|
251
|
+
"agenda_schedule",
|
|
252
|
+
"agenda_update",
|
|
253
|
+
"agenda_cancel",
|
|
254
|
+
"calendar_create",
|
|
255
|
+
"calendar_update",
|
|
256
|
+
"calendar_delete",
|
|
257
|
+
"inspire_submit",
|
|
258
|
+
"inspire_submit_hpc",
|
|
259
|
+
"inspire_stop",
|
|
260
|
+
"inspire_image_push",
|
|
261
|
+
"inspire_inference",
|
|
262
|
+
"inspire_notebook",
|
|
263
|
+
]);
|
|
264
|
+
const PRODUCTION_COMMUNICATION_TOOLS = new Set([
|
|
265
|
+
"attach",
|
|
266
|
+
"response_card",
|
|
267
|
+
"openai_image_gen",
|
|
268
|
+
"openai_image_edit",
|
|
269
|
+
"generate_image",
|
|
270
|
+
"edit_image",
|
|
271
|
+
]);
|
|
272
|
+
const COORDINATION_RECEIPT_TOOLS = new Set([
|
|
273
|
+
"dagwrite",
|
|
274
|
+
"dagpatch",
|
|
275
|
+
"session_control",
|
|
276
|
+
"agenda_trigger",
|
|
277
|
+
"task_cancel",
|
|
278
|
+
"loop_stop",
|
|
279
|
+
"light_loop_approve",
|
|
280
|
+
"light_loop_reject",
|
|
281
|
+
"blueprint_loop_approve",
|
|
282
|
+
"blueprint_loop_reject",
|
|
283
|
+
"blueprint_loop_stop",
|
|
284
|
+
]);
|
|
285
|
+
const ACTIVITY_PRESENTATION_BOUNDARY_TOOLS = new Set(["render", "diagram"]);
|
|
286
|
+
function record(value) {
|
|
287
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
288
|
+
return {};
|
|
289
|
+
return value;
|
|
290
|
+
}
|
|
291
|
+
export function toolDisplayMetadata(metadata) {
|
|
292
|
+
const display = record(record(metadata).display);
|
|
293
|
+
return Object.keys(display).length > 0 ? display : undefined;
|
|
294
|
+
}
|
|
295
|
+
export function toolDisplayPolicy(metadata) {
|
|
296
|
+
const display = toolDisplayMetadata(metadata);
|
|
297
|
+
return {
|
|
298
|
+
toolCardHidden: display?.toolCard === "hidden",
|
|
299
|
+
mediaGeneration: display?.kind === "media-generation",
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
function firstString(...values) {
|
|
303
|
+
for (const value of values) {
|
|
304
|
+
if (typeof value !== "string")
|
|
305
|
+
continue;
|
|
306
|
+
const text = value.trim();
|
|
307
|
+
if (text)
|
|
308
|
+
return text;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
export function isActivityGroupableTool(tool, metadata = {}) {
|
|
312
|
+
if (ACTIVITY_PRESENTATION_BOUNDARY_TOOLS.has(tool))
|
|
313
|
+
return false;
|
|
314
|
+
const policy = toolDisplayPolicy(metadata);
|
|
315
|
+
return !policy.toolCardHidden && !policy.mediaGeneration;
|
|
316
|
+
}
|
|
317
|
+
export function resolveActivityDisplay(value) {
|
|
318
|
+
return value === "full" || value === "minimal" || value === "balanced" ? value : "balanced";
|
|
319
|
+
}
|
|
320
|
+
export function classifySemanticCategory(toolName, input = {}) {
|
|
321
|
+
const exact = semanticCategoryForKnownTool(toolName);
|
|
322
|
+
if (exact)
|
|
323
|
+
return exact;
|
|
324
|
+
for (const rule of PATTERN_FALLBACKS) {
|
|
325
|
+
if (rule.pattern.test(toolName))
|
|
326
|
+
return rule.category;
|
|
327
|
+
}
|
|
328
|
+
if (input.command !== undefined || input.cmd !== undefined || input.script !== undefined)
|
|
329
|
+
return "shell";
|
|
330
|
+
const file = input.filePath ?? input.file_path ?? input.output_path ?? input.outputPath;
|
|
331
|
+
if (file !== undefined) {
|
|
332
|
+
const write = ["content", "newString", "oldString", "diff", "prompt", "input_paths"].some((key) => input[key] !== undefined);
|
|
333
|
+
return write ? "file-write" : "file-read";
|
|
334
|
+
}
|
|
335
|
+
if (input.path !== undefined)
|
|
336
|
+
return "file-read";
|
|
337
|
+
if (["query", "pattern", "regex", "search"].some((key) => input[key] !== undefined))
|
|
338
|
+
return "search";
|
|
339
|
+
if (["url", "href", "endpoint"].some((key) => input[key] !== undefined))
|
|
340
|
+
return "web";
|
|
341
|
+
return "generic";
|
|
342
|
+
}
|
|
343
|
+
function metadataFamily(metadata) {
|
|
344
|
+
const display = record(metadata.display);
|
|
345
|
+
const value = firstString(metadata.activityFamily, display.activityFamily);
|
|
346
|
+
return value && ACTIVITY_FAMILIES.has(value) ? value : undefined;
|
|
347
|
+
}
|
|
348
|
+
export function activityFamilyForTool(tool, input = {}, metadata = {}) {
|
|
349
|
+
if (EXTERNAL_ACTION_TOOLS.has(tool))
|
|
350
|
+
return "external-action";
|
|
351
|
+
if (PRODUCTION_COMMUNICATION_TOOLS.has(tool))
|
|
352
|
+
return "produce";
|
|
353
|
+
if (COORDINATION_RECEIPT_TOOLS.has(tool))
|
|
354
|
+
return "coordination";
|
|
355
|
+
const override = metadataFamily(metadata);
|
|
356
|
+
if (override)
|
|
357
|
+
return override;
|
|
358
|
+
switch (classifySemanticCategory(tool, input)) {
|
|
359
|
+
case "file-read":
|
|
360
|
+
case "search":
|
|
361
|
+
case "memory":
|
|
362
|
+
return "inspect-local";
|
|
363
|
+
case "web":
|
|
364
|
+
case "research":
|
|
365
|
+
return "research-web";
|
|
366
|
+
case "file-write":
|
|
367
|
+
return "modify-files";
|
|
368
|
+
case "shell":
|
|
369
|
+
return "execute";
|
|
370
|
+
case "browser":
|
|
371
|
+
return "browser";
|
|
372
|
+
case "task":
|
|
373
|
+
return "delegate";
|
|
374
|
+
case "analyze":
|
|
375
|
+
case "note":
|
|
376
|
+
case "blueprint":
|
|
377
|
+
return "produce";
|
|
378
|
+
case "communication":
|
|
379
|
+
return "external-action";
|
|
380
|
+
case "dag":
|
|
381
|
+
case "schedule":
|
|
382
|
+
case "session":
|
|
383
|
+
case "session-control":
|
|
384
|
+
case "network":
|
|
385
|
+
case "config":
|
|
386
|
+
case "skill":
|
|
387
|
+
case "community":
|
|
388
|
+
return "coordination";
|
|
389
|
+
case "generic":
|
|
390
|
+
return "generic";
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
function normalizedPath(value) {
|
|
394
|
+
return value.replaceAll("\\", "/").replace(/\/+$/, "");
|
|
395
|
+
}
|
|
396
|
+
function pathScope(value) {
|
|
397
|
+
const normalized = normalizedPath(value);
|
|
398
|
+
const slash = normalized.lastIndexOf("/");
|
|
399
|
+
if (slash <= 0)
|
|
400
|
+
return normalized;
|
|
401
|
+
return normalized.slice(0, slash);
|
|
402
|
+
}
|
|
403
|
+
function fileActivityScope(value, workspaceRoot, family) {
|
|
404
|
+
if (family !== "modify-files" || !workspaceRoot)
|
|
405
|
+
return pathScope(value);
|
|
406
|
+
const file = normalizedPath(value);
|
|
407
|
+
const root = normalizedPath(workspaceRoot);
|
|
408
|
+
if (file !== root && !file.startsWith(`${root}/`))
|
|
409
|
+
return pathScope(file);
|
|
410
|
+
const relative = file.slice(root.length).replace(/^\/+/, "");
|
|
411
|
+
const segments = relative.split("/").filter(Boolean);
|
|
412
|
+
if (segments.length === 0)
|
|
413
|
+
return root;
|
|
414
|
+
if (segments.length === 1)
|
|
415
|
+
return root;
|
|
416
|
+
const depth = segments[0] === "packages" && segments[1] ? 2 : 1;
|
|
417
|
+
return `${root}/${segments.slice(0, depth).join("/")}`;
|
|
418
|
+
}
|
|
419
|
+
function urlScope(value) {
|
|
420
|
+
try {
|
|
421
|
+
return new URL(value).origin;
|
|
422
|
+
}
|
|
423
|
+
catch {
|
|
424
|
+
return undefined;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
export function activityScopeForTool(input = {}, metadata = {}, options = {}) {
|
|
428
|
+
const explicit = firstString(metadata.activityScope, metadata.scopeKey);
|
|
429
|
+
if (explicit)
|
|
430
|
+
return { key: `scope:${explicit}`, label: explicit };
|
|
431
|
+
const file = firstString(input.filePath, input.file_path, input.outputPath, input.output_path, input.filename, input.path, metadata.filePath, metadata.path);
|
|
432
|
+
if (file) {
|
|
433
|
+
const scope = fileActivityScope(file, options.workspaceRoot, options.family);
|
|
434
|
+
return { key: `path:${scope}`, label: scope };
|
|
435
|
+
}
|
|
436
|
+
const url = firstString(input.url, input.href, input.endpoint, metadata.url, metadata.href);
|
|
437
|
+
if (url) {
|
|
438
|
+
const origin = urlScope(url);
|
|
439
|
+
if (origin)
|
|
440
|
+
return { key: `url:${origin}`, label: origin };
|
|
441
|
+
}
|
|
442
|
+
const page = firstString(input.pageID, input.pageId, input.targetID, metadata.pageID, metadata.targetID);
|
|
443
|
+
if (page)
|
|
444
|
+
return { key: `page:${page}`, label: page };
|
|
445
|
+
const task = firstString(input.task_id, input.taskID, input.session_id, input.sessionID, input.id, metadata.task_id, metadata.taskID);
|
|
446
|
+
if (task)
|
|
447
|
+
return { key: `task:${task}`, label: task };
|
|
448
|
+
const artifact = firstString(input.name, input.title, input.outputItem, metadata.name, metadata.title);
|
|
449
|
+
if (artifact)
|
|
450
|
+
return { key: `artifact:${artifact}`, label: artifact };
|
|
451
|
+
return { key: "" };
|
|
452
|
+
}
|
|
453
|
+
export function activityGroupKey(messageID, family, scopeKey, firstPartID) {
|
|
454
|
+
return `activity:${messageID}:${family}:${scopeKey}:${firstPartID}`;
|
|
455
|
+
}
|
|
456
|
+
export function isActivityReceiptTool(tool, family) {
|
|
457
|
+
return (family === "external-action" ||
|
|
458
|
+
PRODUCTION_COMMUNICATION_TOOLS.has(tool) ||
|
|
459
|
+
COORDINATION_RECEIPT_TOOLS.has(tool) ||
|
|
460
|
+
tool === "dagread");
|
|
461
|
+
}
|
package/dist/capability.js
CHANGED
|
@@ -355,6 +355,7 @@ export const SYNERGY_PERMISSION_CAPABILITY = {
|
|
|
355
355
|
edit: "file_write",
|
|
356
356
|
write: "file_write",
|
|
357
357
|
revise_file: "file_write",
|
|
358
|
+
resolve_conflicts: "file_write",
|
|
358
359
|
save_file: "file_write",
|
|
359
360
|
bash: "shell",
|
|
360
361
|
external_directory: "file_external_read",
|
package/dist/model-limit.d.ts
CHANGED
|
@@ -13,7 +13,14 @@ export declare namespace ModelLimit {
|
|
|
13
13
|
write: number;
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
const OUTPUT_TOKEN_MAX =
|
|
16
|
+
const OUTPUT_TOKEN_MAX = 384000;
|
|
17
|
+
/**
|
|
18
|
+
* Reserved input headroom for shared-context models whose catalog output
|
|
19
|
+
* limit equals the context window. Those providers enforce input + output
|
|
20
|
+
* together at request time, so a default output cap of the full window
|
|
21
|
+
* would reject any nonempty prompt.
|
|
22
|
+
*/
|
|
23
|
+
const OUTPUT_TOKEN_HEADROOM = 32000;
|
|
17
24
|
/**
|
|
18
25
|
* Compute actual input tokens from a usage breakdown.
|
|
19
26
|
*
|
package/dist/model-limit.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
export var ModelLimit;
|
|
2
2
|
(function (ModelLimit) {
|
|
3
|
-
ModelLimit.OUTPUT_TOKEN_MAX =
|
|
3
|
+
ModelLimit.OUTPUT_TOKEN_MAX = 384_000;
|
|
4
|
+
/**
|
|
5
|
+
* Reserved input headroom for shared-context models whose catalog output
|
|
6
|
+
* limit equals the context window. Those providers enforce input + output
|
|
7
|
+
* together at request time, so a default output cap of the full window
|
|
8
|
+
* would reject any nonempty prompt.
|
|
9
|
+
*/
|
|
10
|
+
ModelLimit.OUTPUT_TOKEN_HEADROOM = 32_000;
|
|
4
11
|
/**
|
|
5
12
|
* Compute actual input tokens from a usage breakdown.
|
|
6
13
|
*
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const MAX_EXECUTION_CANCEL_GRACE_MS = 60000;
|
|
2
|
+
export declare function resolveRuntimeShutdownTimeoutMs(executionCancelGraceMs: number): number;
|
|
3
|
+
export declare const DESKTOP_SERVER_SHUTDOWN_TIMEOUT_MS: number;
|
|
4
|
+
export declare const SYSTEMD_SERVER_SHUTDOWN_TIMEOUT_SECONDS: number;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const RUNTIME_SHUTDOWN_SETTLE_MARGIN_MS = 5_000;
|
|
2
|
+
const DESKTOP_SUPERVISOR_SETTLE_MARGIN_MS = 5_000;
|
|
3
|
+
export const MAX_EXECUTION_CANCEL_GRACE_MS = 60_000;
|
|
4
|
+
export function resolveRuntimeShutdownTimeoutMs(executionCancelGraceMs) {
|
|
5
|
+
return Math.max(RUNTIME_SHUTDOWN_SETTLE_MARGIN_MS, executionCancelGraceMs + RUNTIME_SHUTDOWN_SETTLE_MARGIN_MS);
|
|
6
|
+
}
|
|
7
|
+
export const DESKTOP_SERVER_SHUTDOWN_TIMEOUT_MS = resolveRuntimeShutdownTimeoutMs(MAX_EXECUTION_CANCEL_GRACE_MS) + DESKTOP_SUPERVISOR_SETTLE_MARGIN_MS;
|
|
8
|
+
export const SYSTEMD_SERVER_SHUTDOWN_TIMEOUT_SECONDS = DESKTOP_SERVER_SHUTDOWN_TIMEOUT_MS / 1_000;
|