@ericsanchezok/synergy-util 3.0.23 → 3.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.
Files changed (74) hide show
  1. package/LICENSE.codex +201 -0
  2. package/NOTICE +9 -0
  3. package/dist/activity.d.ts +9 -4
  4. package/dist/activity.js +20 -19
  5. package/dist/asset-reference.d.ts +15 -0
  6. package/dist/asset-reference.js +98 -0
  7. package/dist/atomic-file.d.ts +9 -0
  8. package/dist/atomic-file.js +86 -0
  9. package/dist/attachment-presentation.d.ts +26 -0
  10. package/dist/attachment-presentation.js +11 -0
  11. package/dist/capability.d.ts +1 -1
  12. package/dist/capability.js +5 -19
  13. package/dist/cli-command.d.ts +12 -0
  14. package/dist/cli-command.js +3 -0
  15. package/dist/encode.d.ts +3 -0
  16. package/dist/encode.js +7 -0
  17. package/dist/error.d.ts +36 -56
  18. package/dist/feature-config.d.ts +4 -0
  19. package/dist/feature-config.js +23 -0
  20. package/dist/features.d.ts +134 -0
  21. package/dist/features.js +195 -0
  22. package/dist/file-patch.d.ts +31 -0
  23. package/dist/file-patch.js +218 -0
  24. package/dist/filesystem-identity.d.ts +28 -0
  25. package/dist/filesystem-identity.js +71 -0
  26. package/dist/fn.d.ts +1 -1
  27. package/dist/fs-lock.d.ts +5 -1
  28. package/dist/fs-lock.js +14 -6
  29. package/dist/input-assistance.d.ts +51 -0
  30. package/dist/input-assistance.js +61 -0
  31. package/dist/installed-launcher.d.ts +18 -0
  32. package/dist/installed-launcher.js +39 -0
  33. package/dist/io-retry.d.ts +11 -0
  34. package/dist/io-retry.js +36 -0
  35. package/dist/json-value.d.ts +4 -0
  36. package/dist/json-value.js +12 -0
  37. package/dist/markdown-assets.d.ts +6 -0
  38. package/dist/markdown-assets.js +29 -0
  39. package/dist/markdown-link.d.ts +2 -0
  40. package/dist/markdown-link.js +8 -0
  41. package/dist/native-assets.d.ts +7 -0
  42. package/dist/native-assets.js +28 -0
  43. package/dist/network-error.d.ts +7 -0
  44. package/dist/network-error.js +111 -0
  45. package/dist/plugin-policy.d.ts +1 -1
  46. package/dist/process-group.d.ts +45 -0
  47. package/dist/process-group.js +156 -0
  48. package/dist/process-identity.js +5 -2
  49. package/dist/projection-patch.d.ts +9 -0
  50. package/dist/projection-patch.js +74 -0
  51. package/dist/reasoning-item.d.ts +1 -0
  52. package/dist/reasoning-item.js +16 -0
  53. package/dist/render-artifact.d.ts +352 -0
  54. package/dist/render-artifact.js +115 -0
  55. package/dist/render-ui.d.ts +202 -0
  56. package/dist/render-ui.js +208 -0
  57. package/dist/resource-reference.d.ts +73 -0
  58. package/dist/resource-reference.js +227 -0
  59. package/dist/retry.d.ts +4 -0
  60. package/dist/retry.js +56 -23
  61. package/dist/runtime-startup.d.ts +240 -2
  62. package/dist/runtime-startup.js +108 -9
  63. package/dist/terminal.d.ts +217 -0
  64. package/dist/terminal.js +111 -0
  65. package/dist/tool-display.d.ts +10 -0
  66. package/dist/tool-display.js +22 -1
  67. package/dist/tool-timeout.d.ts +21 -0
  68. package/dist/tool-timeout.js +1 -0
  69. package/dist/tool.d.ts +6 -7
  70. package/dist/workbench-view.d.ts +692 -0
  71. package/dist/workbench-view.js +90 -0
  72. package/dist/worker-plan.d.ts +39 -0
  73. package/dist/worker-plan.js +33 -0
  74. package/package.json +28 -4
package/LICENSE.codex ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 OpenAI
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,9 @@
1
+ OpenAI Codex
2
+ Copyright 2025 OpenAI
3
+
4
+ The patch parser and matching behavior in src/file-patch.ts are adapted from
5
+ https://github.com/openai/codex/tree/160b2b1ef62114eeb41e41e5e3be0000d944b713/codex-rs/apply-patch/src
6
+ under the Apache License, Version 2.0. The license is included in LICENSE.codex.
7
+
8
+ Synergy modifications retain the selected Workspace execution boundary, preserve
9
+ BOM and terminal-newline state, and report hunk-level recovery diagnostics.
@@ -5,9 +5,9 @@ export type ActivityFamily = "inspect-local" | "research-web" | "modify-files" |
5
5
  export declare const ACTIVITY_FAMILY_ORDER: readonly ActivityFamily[];
6
6
  export declare const MAX_ACTIVITY_GROUP_STEPS = 24;
7
7
  export declare const ActivitySummaryStateSchema: z.ZodEnum<{
8
+ fallback: "fallback";
8
9
  live: "live";
9
10
  stable: "stable";
10
- fallback: "fallback";
11
11
  }>;
12
12
  export type ActivitySummaryState = z.infer<typeof ActivitySummaryStateSchema>;
13
13
  export declare const ActivityDerivedMetadataSchema: z.ZodObject<{
@@ -15,9 +15,9 @@ export declare const ActivityDerivedMetadataSchema: z.ZodObject<{
15
15
  seq: z.ZodNumber;
16
16
  reasoning: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
17
17
  state: z.ZodEnum<{
18
+ fallback: "fallback";
18
19
  live: "live";
19
20
  stable: "stable";
20
- fallback: "fallback";
21
21
  }>;
22
22
  text: z.ZodOptional<z.ZodString>;
23
23
  source: z.ZodOptional<z.ZodEnum<{
@@ -28,9 +28,9 @@ export declare const ActivityDerivedMetadataSchema: z.ZodObject<{
28
28
  }, z.core.$strip>>>;
29
29
  groups: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
30
30
  state: z.ZodEnum<{
31
+ fallback: "fallback";
31
32
  live: "live";
32
33
  stable: "stable";
33
- fallback: "fallback";
34
34
  }>;
35
35
  signature: z.ZodOptional<z.ZodString>;
36
36
  text: z.ZodOptional<z.ZodString>;
@@ -39,8 +39,8 @@ export declare const ActivityDerivedMetadataSchema: z.ZodObject<{
39
39
  now: z.ZodOptional<z.ZodObject<{
40
40
  text: z.ZodString;
41
41
  source: z.ZodEnum<{
42
- reasoning: "reasoning";
43
42
  group: "group";
43
+ reasoning: "reasoning";
44
44
  }>;
45
45
  updatedAt: z.ZodNumber;
46
46
  }, z.core.$strip>>;
@@ -52,6 +52,11 @@ export declare function toolDisplayPolicy(metadata: unknown): {
52
52
  toolCardHidden: boolean;
53
53
  mediaGeneration: boolean;
54
54
  };
55
+ export declare function isCancelledMediaGeneration(state: {
56
+ status: string;
57
+ reason?: string;
58
+ metadata?: unknown;
59
+ }): boolean;
55
60
  export declare function isActivityGroupableTool(tool: string, metadata?: Record<string, unknown>): boolean;
56
61
  export declare function resolveActivityDisplay(value: unknown): ActivityDisplayMode;
57
62
  export declare function classifySemanticCategory(toolName: string, input?: Record<string, unknown>): SemanticCategory;
package/dist/activity.js CHANGED
@@ -44,6 +44,7 @@ const TOOL_CATEGORIES = {
44
44
  computer_apps: "generic",
45
45
  computer_observe: "generic",
46
46
  computer_action: "generic",
47
+ workbench_view: "generic",
47
48
  webfetch: "web",
48
49
  browser_navigation: "browser",
49
50
  browser_snapshot: "browser",
@@ -78,6 +79,7 @@ const TOOL_CATEGORIES = {
78
79
  view_image: "analyze",
79
80
  scan_document: "analyze",
80
81
  edit: "file-write",
82
+ apply_patch: "file-write",
81
83
  revise_file: "file-write",
82
84
  resolve_conflicts: "file-write",
83
85
  write: "file-write",
@@ -153,6 +155,7 @@ const TOOL_CATEGORIES = {
153
155
  profile_update: "config",
154
156
  worktree_enter: "config",
155
157
  worktree_leave: "config",
158
+ worktree_archive: "config",
156
159
  worktree_list: "config",
157
160
  agent_config: "config",
158
161
  connect: "network",
@@ -174,17 +177,21 @@ const TOOL_CATEGORIES = {
174
177
  question: "communication",
175
178
  email_send: "communication",
176
179
  email_read: "communication",
177
- clarus_submit_task_result: "communication",
178
- clarus_extend_task: "communication",
179
180
  github_deliver_fix: "communication",
180
181
  openai_image_gen: "communication",
181
182
  openai_image_edit: "communication",
182
183
  speak: "communication",
183
184
  render: "analyze",
184
- attach: "communication",
185
185
  response_card: "communication",
186
+ channel_reaction_only: "communication",
186
187
  "context7_resolve-library-id": "search",
187
188
  "context7_query-docs": "web",
189
+ mcp__anysearch__search: "web",
190
+ mcp__anysearch__batch_search: "web",
191
+ mcp__anysearch__extract: "web",
192
+ mcp__anysearch__get_sub_domains: "web",
193
+ mcp__scholight__search_papers: "web",
194
+ mcp__scholight__extract_url: "web",
188
195
  };
189
196
  export function semanticCategoryForKnownTool(toolName) {
190
197
  return TOOL_CATEGORIES[toolName];
@@ -222,7 +229,6 @@ const PATTERN_FALLBACKS = [
222
229
  { pattern: /^(send|notify|message)/i, category: "communication" },
223
230
  { pattern: /^question/i, category: "communication" },
224
231
  { pattern: /^(openai[-_])?image[-_](gen|edit)/i, category: "communication" },
225
- { pattern: /^attach/i, category: "communication" },
226
232
  ];
227
233
  const ACTIVITY_FAMILIES = new Set(ACTIVITY_FAMILY_ORDER);
228
234
  const EXTERNAL_ACTION_TOOLS = new Set([
@@ -230,8 +236,6 @@ const EXTERNAL_ACTION_TOOLS = new Set([
230
236
  "email_send",
231
237
  "email_mark_read",
232
238
  "session_send",
233
- "clarus_submit_task_result",
234
- "clarus_extend_task",
235
239
  "github_deliver_fix",
236
240
  "question",
237
241
  "agenda_schedule",
@@ -248,8 +252,8 @@ const EXTERNAL_ACTION_TOOLS = new Set([
248
252
  "inspire_notebook",
249
253
  ]);
250
254
  const PRODUCTION_COMMUNICATION_TOOLS = new Set([
251
- "attach",
252
255
  "response_card",
256
+ "channel_reaction_only",
253
257
  "openai_image_gen",
254
258
  "openai_image_edit",
255
259
  "speak",
@@ -269,18 +273,10 @@ const COORDINATION_RECEIPT_TOOLS = new Set([
269
273
  "blueprint_loop_reject",
270
274
  "blueprint_loop_stop",
271
275
  ]);
276
+ // `render` output is the presented card itself, so it must stay outside
277
+ // semantic activity groups.
272
278
  const ACTIVITY_PRESENTATION_BOUNDARY_TOOLS = new Set(["render"]);
273
- // Built-in remote MCP search families stay visible as individual cards in
274
- // the activity timeline instead of being folded into grouped summary rows.
275
- // Their renderers are presentation boundaries with per-query structure the
276
- // user should be able to inspect after the turn (the same reason `render`
277
- // is a boundary above).
278
- const ACTIVITY_PRESENTATION_BOUNDARY_PREFIXES = ["mcp__anysearch__", "mcp__scholight__"];
279
- function isPresentationBoundaryTool(tool) {
280
- if (ACTIVITY_PRESENTATION_BOUNDARY_TOOLS.has(tool))
281
- return true;
282
- return ACTIVITY_PRESENTATION_BOUNDARY_PREFIXES.some((prefix) => tool.startsWith(prefix));
283
- }
279
+ const MEDIA_INSPECTION_TOOLS = new Set(["look_at", "view_image", "scan_document"]);
284
280
  function record(value) {
285
281
  if (!value || typeof value !== "object" || Array.isArray(value))
286
282
  return {};
@@ -297,6 +293,9 @@ export function toolDisplayPolicy(metadata) {
297
293
  mediaGeneration: display?.kind === "media-generation",
298
294
  };
299
295
  }
296
+ export function isCancelledMediaGeneration(state) {
297
+ return state.status === "error" && state.reason === "cancelled" && toolDisplayPolicy(state.metadata).mediaGeneration;
298
+ }
300
299
  function firstString(...values) {
301
300
  for (const value of values) {
302
301
  if (typeof value !== "string")
@@ -307,7 +306,7 @@ function firstString(...values) {
307
306
  }
308
307
  }
309
308
  export function isActivityGroupableTool(tool, metadata = {}) {
310
- if (isPresentationBoundaryTool(tool))
309
+ if (ACTIVITY_PRESENTATION_BOUNDARY_TOOLS.has(tool))
311
310
  return false;
312
311
  const policy = toolDisplayPolicy(metadata);
313
312
  return !policy.toolCardHidden && !policy.mediaGeneration;
@@ -353,6 +352,8 @@ export function activityFamilyForTool(tool, input = {}, metadata = {}) {
353
352
  const override = metadataFamily(metadata);
354
353
  if (override)
355
354
  return override;
355
+ if (MEDIA_INSPECTION_TOOLS.has(tool))
356
+ return "inspect-local";
356
357
  switch (classifySemanticCategory(tool, input)) {
357
358
  case "file-read":
358
359
  case "search":
@@ -0,0 +1,15 @@
1
+ export declare namespace AssetReference {
2
+ function isValidId(id: string): boolean;
3
+ function parse(value: string): {
4
+ id: string;
5
+ url: string;
6
+ mime: string;
7
+ } | undefined;
8
+ function mimeFromExt(ext: string): string;
9
+ function extFromMime(mime: string): string | undefined;
10
+ /** Filename-derived extension normalized to the asset-ID alphabet; anything
11
+ * outside [a-z0-9] (e.g. "x86_64") falls back to undefined so the caller's
12
+ * `.bin` default keeps generated IDs valid for `isValidId()`. */
13
+ function extFromName(name: string): string | undefined;
14
+ function extFromId(id: string): string;
15
+ }
@@ -0,0 +1,98 @@
1
+ const MIME_TO_EXT = {
2
+ "image/png": "png",
3
+ "image/jpeg": "jpg",
4
+ "image/gif": "gif",
5
+ "image/webp": "webp",
6
+ "image/svg+xml": "svg",
7
+ "video/mp4": "mp4",
8
+ "video/webm": "webm",
9
+ "audio/mpeg": "mp3",
10
+ "audio/wav": "wav",
11
+ "application/pdf": "pdf",
12
+ "application/zip": "zip",
13
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
14
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
15
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
16
+ "text/plain": "txt",
17
+ "text/markdown": "md",
18
+ "text/html": "html",
19
+ "text/css": "css",
20
+ "text/csv": "csv",
21
+ "text/xml": "xml",
22
+ "text/yaml": "yaml",
23
+ "text/x-python": "py",
24
+ "text/x-shellscript": "sh",
25
+ "application/json": "json",
26
+ "application/xml": "xml",
27
+ "application/javascript": "js",
28
+ "application/typescript": "ts",
29
+ "application/x-yaml": "yaml",
30
+ };
31
+ const EXT_TO_MIME = {
32
+ png: "image/png",
33
+ jpg: "image/jpeg",
34
+ jpeg: "image/jpeg",
35
+ gif: "image/gif",
36
+ webp: "image/webp",
37
+ svg: "image/svg+xml",
38
+ mp4: "video/mp4",
39
+ webm: "video/webm",
40
+ mp3: "audio/mpeg",
41
+ wav: "audio/wav",
42
+ pdf: "application/pdf",
43
+ zip: "application/zip",
44
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
45
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
46
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
47
+ txt: "text/plain",
48
+ md: "text/markdown",
49
+ html: "text/html",
50
+ css: "text/css",
51
+ csv: "text/csv",
52
+ xml: "text/xml",
53
+ yaml: "text/yaml",
54
+ yml: "text/yaml",
55
+ py: "text/x-python",
56
+ sh: "text/x-shellscript",
57
+ json: "application/json",
58
+ js: "application/javascript",
59
+ ts: "application/typescript",
60
+ };
61
+ export var AssetReference;
62
+ (function (AssetReference) {
63
+ function isValidId(id) {
64
+ return /^[a-f0-9]{16}(\.[a-z0-9]+)?$/.test(id) && id.trim() === id;
65
+ }
66
+ AssetReference.isValidId = isValidId;
67
+ function parse(value) {
68
+ if (!value.startsWith("asset://"))
69
+ return undefined;
70
+ const id = value.slice(8);
71
+ if (!isValidId(id))
72
+ return undefined;
73
+ return { id, url: value, mime: mimeFromExt(extFromId(id)) };
74
+ }
75
+ AssetReference.parse = parse;
76
+ function mimeFromExt(ext) {
77
+ return EXT_TO_MIME[ext] ?? "application/octet-stream";
78
+ }
79
+ AssetReference.mimeFromExt = mimeFromExt;
80
+ function extFromMime(mime) {
81
+ return MIME_TO_EXT[mime];
82
+ }
83
+ AssetReference.extFromMime = extFromMime;
84
+ /** Filename-derived extension normalized to the asset-ID alphabet; anything
85
+ * outside [a-z0-9] (e.g. "x86_64") falls back to undefined so the caller's
86
+ * `.bin` default keeps generated IDs valid for `isValidId()`. */
87
+ function extFromName(name) {
88
+ const dot = name.lastIndexOf(".");
89
+ const ext = dot >= 0 ? name.slice(dot + 1).toLowerCase() : undefined;
90
+ return ext && /^[a-z0-9]+$/.test(ext) ? ext : undefined;
91
+ }
92
+ AssetReference.extFromName = extFromName;
93
+ function extFromId(id) {
94
+ const dot = id.lastIndexOf(".");
95
+ return dot >= 0 ? id.slice(dot + 1) : "bin";
96
+ }
97
+ AssetReference.extFromId = extFromId;
98
+ })(AssetReference || (AssetReference = {}));
@@ -0,0 +1,9 @@
1
+ export declare namespace AtomicFile {
2
+ interface WriteOptions {
3
+ durable?: boolean;
4
+ private?: boolean;
5
+ }
6
+ function syncDirectories(...directories: string[]): Promise<void>;
7
+ function writeJsonAtomic(target: string, serialized: string, options?: WriteOptions): Promise<void>;
8
+ function writeFileAtomic(target: string, content: string | Uint8Array, options?: WriteOptions): Promise<void>;
9
+ }
@@ -0,0 +1,86 @@
1
+ import path from "node:path";
2
+ import fs from "node:fs/promises";
3
+ import { isRetryableIOError } from "./io-retry.js";
4
+ export var AtomicFile;
5
+ (function (AtomicFile) {
6
+ async function syncDirectories(...directories) {
7
+ if (process.platform === "win32")
8
+ return;
9
+ for (const directory of new Set(directories)) {
10
+ const handle = await fs.open(directory, "r");
11
+ try {
12
+ await handle.sync();
13
+ }
14
+ finally {
15
+ await handle.close();
16
+ }
17
+ }
18
+ }
19
+ AtomicFile.syncDirectories = syncDirectories;
20
+ // Windows maps rename onto MoveFileEx: when another process (antivirus,
21
+ // OneDrive, a cross-process reader of these JSON files) briefly holds a
22
+ // handle on the source or target without FILE_SHARE_DELETE, the rename
23
+ // fails with EPERM/EACCES. Sharing violations clear within milliseconds,
24
+ // so retry the whole write+rename sequence with short backoff instead of
25
+ // failing session persistence and terminating the owning session (#1247).
26
+ const ATOMIC_WRITE_ATTEMPTS = 4;
27
+ const ATOMIC_WRITE_RETRY_BASE_MS = 50;
28
+ const ATOMIC_WRITE_RETRY_MAX_MS = 200;
29
+ async function writeJsonAtomic(target, serialized, options) {
30
+ return writeFileAtomic(target, serialized, options);
31
+ }
32
+ AtomicFile.writeJsonAtomic = writeJsonAtomic;
33
+ async function writeFileAtomic(target, content, options) {
34
+ await fs.mkdir(path.dirname(target), { recursive: true, ...(options?.private ? { mode: 0o700 } : {}) });
35
+ const tmp = path.join(path.dirname(target), `.tmp-${process.pid}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`);
36
+ for (let attempt = 1;; attempt++) {
37
+ try {
38
+ if (options?.private || options?.durable) {
39
+ const file = await fs.open(tmp, "w", options.private ? 0o600 : 0o666);
40
+ try {
41
+ await file.writeFile(content);
42
+ if (options.durable)
43
+ await file.sync();
44
+ }
45
+ finally {
46
+ await file.close();
47
+ }
48
+ }
49
+ else {
50
+ await Bun.write(tmp, content);
51
+ }
52
+ await fs.rename(tmp, target);
53
+ if (options?.durable)
54
+ await syncDirectories(path.dirname(target));
55
+ return;
56
+ }
57
+ catch (error) {
58
+ if (!isRetryableIOError(error) || attempt >= ATOMIC_WRITE_ATTEMPTS) {
59
+ await removeTempFile(tmp);
60
+ throw error;
61
+ }
62
+ await new Promise((resolve) => setTimeout(resolve, atomicRetryDelayMs(attempt)));
63
+ }
64
+ }
65
+ }
66
+ AtomicFile.writeFileAtomic = writeFileAtomic;
67
+ // The terminal-failure cleanup can hit the same Windows sharing violation
68
+ // that failed the rename (antivirus holding the temp handle), so transient
69
+ // unlink errors retry with the same backoff before being suppressed (#1247).
70
+ async function removeTempFile(tmp) {
71
+ for (let attempt = 1; attempt <= ATOMIC_WRITE_ATTEMPTS; attempt++) {
72
+ try {
73
+ await fs.unlink(tmp);
74
+ return;
75
+ }
76
+ catch (error) {
77
+ if (!isRetryableIOError(error) || attempt >= ATOMIC_WRITE_ATTEMPTS)
78
+ return;
79
+ await new Promise((resolve) => setTimeout(resolve, atomicRetryDelayMs(attempt)));
80
+ }
81
+ }
82
+ }
83
+ function atomicRetryDelayMs(attempt) {
84
+ return Math.min(ATOMIC_WRITE_RETRY_MAX_MS, ATOMIC_WRITE_RETRY_BASE_MS * 2 ** (attempt - 1));
85
+ }
86
+ })(AtomicFile || (AtomicFile = {}));
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+ export declare const AttachmentPresentation: z.ZodObject<{
3
+ purpose: z.ZodOptional<z.ZodEnum<{
4
+ deliverable: "deliverable";
5
+ evidence: "evidence";
6
+ }>>;
7
+ hidden: z.ZodOptional<z.ZodBoolean>;
8
+ renderer: z.ZodOptional<z.ZodEnum<{
9
+ audio: "audio";
10
+ file: "file";
11
+ image: "image";
12
+ thumbnail: "thumbnail";
13
+ video: "video";
14
+ }>>;
15
+ size: z.ZodOptional<z.ZodEnum<{
16
+ large: "large";
17
+ medium: "medium";
18
+ original: "original";
19
+ small: "small";
20
+ }>>;
21
+ crop: z.ZodOptional<z.ZodBoolean>;
22
+ }, z.core.$strip>;
23
+ export type AttachmentPresentation = z.infer<typeof AttachmentPresentation>;
24
+ export declare function attachmentPurpose(attachment: {
25
+ presentation?: AttachmentPresentation;
26
+ }): "deliverable" | "evidence";
@@ -0,0 +1,11 @@
1
+ import { z } from "zod";
2
+ export const AttachmentPresentation = z.object({
3
+ purpose: z.enum(["evidence", "deliverable"]).optional(),
4
+ hidden: z.boolean().optional(),
5
+ renderer: z.enum(["image", "video", "audio", "thumbnail", "file"]).optional(),
6
+ size: z.enum(["original", "small", "medium", "large"]).optional(),
7
+ crop: z.boolean().optional(),
8
+ });
9
+ export function attachmentPurpose(attachment) {
10
+ return attachment.presentation?.purpose === "evidence" ? "evidence" : "deliverable";
11
+ }
@@ -10,7 +10,7 @@ export interface SynergyCapabilityDefinition {
10
10
  nonBypassable?: boolean;
11
11
  }
12
12
  export declare const SYNERGY_CAPABILITY_DETAILS: Record<string, SynergyCapabilityDefinition>;
13
- export declare const SYNERGY_PROFILE_CAPABILITIES: readonly ["file_read", "file_write", "shell_read", "shell", "shell_branch_mutation", "shell_remote_execute", "shell_remote_publish", "shell_remote_write", "shell_destructive", "shell_hardline", "file_external_read", "file_external_write", "network_read", "network_request", "mcp_invoke", "mcp_spawn", "session_data", "workspace_data", "config:read", "config:write", "secrets", "task", "prompt_transform", "compaction_transform", "tool_execution_hook", "permission_hook", "event_hook", "config_hook", "identity_act", "communication_email", "channel_outbound", "platform_control", "protected_op", "session_state", "browser_interact", "computer_observe", "computer_interact", "browser_inspect", "browser_eval_readonly", "browser_eval_trusted", "browser_clipboard", "browser_upload", "browser_coordinate", "browser_download", "browser_emulation"];
13
+ export declare const SYNERGY_PROFILE_CAPABILITIES: readonly ["file_read", "file_write", "shell", "shell_branch_mutation", "shell_remote_publish", "shell_remote_write", "shell_destructive", "shell_hardline", "file_external_read", "file_external_write", "network_read", "network_request", "mcp_invoke", "mcp_spawn", "session_data", "workspace_data", "config:read", "config:write", "secrets", "task", "prompt_transform", "compaction_transform", "tool_execution_hook", "permission_hook", "event_hook", "config_hook", "identity_act", "communication_email", "channel_outbound", "platform_control", "protected_op", "session_state", "browser_interact", "computer_observe", "computer_interact", "browser_inspect", "browser_eval_readonly", "browser_eval_trusted", "browser_clipboard", "browser_upload", "browser_coordinate", "browser_download", "browser_emulation"];
14
14
  export declare const SYNERGY_PERMISSION_CAPABILITY: Record<string, string>;
15
15
  export declare function permissionCapability(permission: string): string;
16
16
  export declare function capabilityNonBypassable(capability: string): boolean;