openwork-server 0.18.63 → 0.18.65

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 (96) hide show
  1. package/README.md +2 -2
  2. package/dist/opencode-plugin-deps-1.18.33.tgz +0 -0
  3. package/dist/opencode-plugins/approval-loopback-fetch.js +18 -0
  4. package/dist/opencode-plugins/computer-listing-files.js +101 -0
  5. package/dist/opencode-plugins/drive-file-tools.js +2 -2
  6. package/dist/opencode-plugins/managed-policy-next.js +11 -5
  7. package/dist/opencode-plugins/openwork-agent-permissions-v2.js +162 -11
  8. package/dist/opencode-plugins/openwork-agent-questions.js +24 -0
  9. package/dist/opencode-plugins/openwork-auto-route-v2.js +19657 -0
  10. package/dist/opencode-plugins/openwork-capabilities-knowledge.js +5 -3
  11. package/dist/opencode-plugins/openwork-chrome-devtools.js +17498 -5
  12. package/dist/opencode-plugins/openwork-cloud-skills-v2.js +54 -31
  13. package/dist/opencode-plugins/openwork-codemode-discovery-v2.js +19 -6
  14. package/dist/opencode-plugins/openwork-computer-use.js +17650 -37
  15. package/dist/opencode-plugins/openwork-context-v2.js +17840 -78
  16. package/dist/opencode-plugins/openwork-extensions-preview.js +929 -175
  17. package/dist/opencode-plugins/openwork-gateway-quota-v2.js +15 -0
  18. package/dist/opencode-plugins/openwork-gateway-quota.js +15 -0
  19. package/dist/opencode-plugins/openwork-mcp-results-v2.js +20 -4
  20. package/dist/opencode-plugins/openwork-office-attachments.js +1 -1
  21. package/dist/opencode-plugins/openwork-provider-adapters.js +65 -6
  22. package/dist/opencode-plugins/openwork-provider-sync-v2.js +459 -139
  23. package/dist/opencode-plugins/openwork-session-groups.js +5 -4
  24. package/dist/opencode-plugins/openwork-spreadsheets.js +1 -1
  25. package/dist/opencode-plugins/openwork-ui-bridge.js +6 -3
  26. package/dist/opencode-plugins/session-read-detail.js +475 -0
  27. package/dist/openwork-server.mjs +98993 -87384
  28. package/package.json +1 -1
  29. package/web/assets/{abnfDiagram-VCTEODGH-BSIb81ug.js → abnfDiagram-VCTEODGH-_euFTfuE.js} +1 -1
  30. package/web/assets/app-BL4DzbHg.css +32 -0
  31. package/web/assets/{app-DZr96oX3.js → app-B_eR6sGg.js} +461 -460
  32. package/web/assets/{arc-BTCnV0Ha.js → arc-DIIHEUK5.js} +1 -1
  33. package/web/assets/{architectureDiagram-5GKGNRK7-3IgeX1_6.js → architectureDiagram-5GKGNRK7-DD7V4Nl6.js} +1 -1
  34. package/web/assets/{artifact-code-view-ZP8nVuQx.js → artifact-code-view-2fHBrzKl.js} +1 -1
  35. package/web/assets/{artifact-spreadsheet-editor-BW94PK45.js → artifact-spreadsheet-editor-D2kPT8kU.js} +1 -1
  36. package/web/assets/{artifact-text-editor-BhIcTcNi.js → artifact-text-editor-uJetA3RS.js} +1 -1
  37. package/web/assets/{blockDiagram-OSKFZWR5-d1pNUfi4.js → blockDiagram-OSKFZWR5-B5VTERzj.js} +1 -1
  38. package/web/assets/{c4Diagram-7LVT6UL2-BTVoP_gs.js → c4Diagram-7LVT6UL2-1Lh6d98a.js} +1 -1
  39. package/web/assets/channel-CLju5G1-.js +1 -0
  40. package/web/assets/{chunk-2Q5K7J3B-BIy8BDgC.js → chunk-2Q5K7J3B-BYSg2PtF.js} +1 -1
  41. package/web/assets/{chunk-5VM5RSS4-BDvSSuPz.js → chunk-5VM5RSS4-CUeEqVp6.js} +1 -1
  42. package/web/assets/{chunk-F27PBJKO-CqT02j1I.js → chunk-F27PBJKO-BYl1gIUK.js} +1 -1
  43. package/web/assets/{chunk-HLEWEB6X-DOSYJ6qO.js → chunk-HLEWEB6X-CSHTqizU.js} +1 -1
  44. package/web/assets/{chunk-JWPE2WC7-BLJ5TLJ6.js → chunk-JWPE2WC7-C3M9OIeQ.js} +1 -1
  45. package/web/assets/{chunk-POPQ4Y6H-TRvB63--.js → chunk-POPQ4Y6H-CBer2BDK.js} +1 -1
  46. package/web/assets/{chunk-SVP7TREG-Bz6HrnA2.js → chunk-SVP7TREG-gh6XHnDe.js} +1 -1
  47. package/web/assets/{chunk-XXDRQBXY-wBuvw6SP.js → chunk-XXDRQBXY-BWW96PGH.js} +1 -1
  48. package/web/assets/{chunk-ZLD2IHE6-CsK6m1Sk.js → chunk-ZLD2IHE6-BwjCpFv6.js} +1 -1
  49. package/web/assets/classDiagram-CYGNFDIV-DZO1M7Ic.js +1 -0
  50. package/web/assets/classDiagram-v2-TLXNO2FR-DZO1M7Ic.js +1 -0
  51. package/web/assets/{cose-bilkent-JH36ORCC-CISbKtKO.js → cose-bilkent-JH36ORCC-lJjj59Sx.js} +1 -1
  52. package/web/assets/{cynefin-OW5HDTMX-Dk7vIkhw.js → cynefin-OW5HDTMX-CAIFZQxV.js} +1 -1
  53. package/web/assets/{cynefinDiagram-5FMLGOSQ-C3bIjcy0.js → cynefinDiagram-5FMLGOSQ-BNCAcb93.js} +1 -1
  54. package/web/assets/{dagre-OS7QT2EB-BsP75gf5.js → dagre-OS7QT2EB-DMlHDwrG.js} +1 -1
  55. package/web/assets/{diagram-S7CK7UJ4-B4K-iSz7.js → diagram-S7CK7UJ4-Dbpa25GK.js} +1 -1
  56. package/web/assets/{diagram-UQ7AKVKN-bly7AwhV.js → diagram-UQ7AKVKN-BCT_Qc9p.js} +1 -1
  57. package/web/assets/{diagram-VSXAHHWV-DObKajM9.js → diagram-VSXAHHWV-CapON9I2.js} +1 -1
  58. package/web/assets/{diagram-VX7I27RA-SQp5kc6I.js → diagram-VX7I27RA-CCMsrHOR.js} +1 -1
  59. package/web/assets/{diagram-Z3DM3KII-BmaqS6Rw.js → diagram-Z3DM3KII-BOpKxuDL.js} +1 -1
  60. package/web/assets/{ebnfDiagram-PWID7BFC-BOhK-9Al.js → ebnfDiagram-PWID7BFC-C1sb3HsT.js} +1 -1
  61. package/web/assets/{erDiagram-2YWLMYGG-DP0d4SRU.js → erDiagram-2YWLMYGG-3TIcbkY2.js} +1 -1
  62. package/web/assets/{flowDiagram-T62WH6J4-CJLvattq.js → flowDiagram-T62WH6J4-C3YP5_VV.js} +1 -1
  63. package/web/assets/{ganttDiagram-EL5Y4UJY-Dzi8suyh.js → ganttDiagram-EL5Y4UJY-BWO0IFRX.js} +1 -1
  64. package/web/assets/{gitGraphDiagram-WWUBYQGX-D-xOZUu9.js → gitGraphDiagram-WWUBYQGX-Dpi4d5u9.js} +1 -1
  65. package/web/assets/{infoDiagram-FKFFQAWI-CTR7Ei2k.js → infoDiagram-FKFFQAWI-C3t_XWD1.js} +1 -1
  66. package/web/assets/{ishikawaDiagram-5VMMS53U-CBf51Qea.js → ishikawaDiagram-5VMMS53U-Duhj9xvC.js} +1 -1
  67. package/web/assets/{journeyDiagram-EYS64GPL-ZumMGF2u.js → journeyDiagram-EYS64GPL-Bq_tWeLz.js} +1 -1
  68. package/web/assets/{kanban-definition-UXKFOSKX-81Fni8Sl.js → kanban-definition-UXKFOSKX-C7zCaEcE.js} +1 -1
  69. package/web/assets/{layout-D-HFg0Gy.js → layout-BGV5k35C.js} +1 -1
  70. package/web/assets/{linear-lAHomfjd.js → linear-jBjiubEm.js} +1 -1
  71. package/web/assets/{mermaid.core-sRbhnZ3C.js → mermaid.core-DcEA9CwK.js} +6 -6
  72. package/web/assets/{mindmap-definition-THT77NOG-t_uxFNYx.js → mindmap-definition-THT77NOG-DWi2qNO-.js} +1 -1
  73. package/web/assets/{pegDiagram-XKGWAZYB-B4FryuiE.js → pegDiagram-XKGWAZYB-mpdETODF.js} +1 -1
  74. package/web/assets/{pieDiagram-E7YTZNPT-DrIgLewj.js → pieDiagram-E7YTZNPT-B_E8xv7R.js} +1 -1
  75. package/web/assets/{quadrantDiagram-AXDQQJYC-DifmQS8L.js → quadrantDiagram-AXDQQJYC-C3DLSKZx.js} +1 -1
  76. package/web/assets/{railroadDiagram-O6MQD6OU-C76a1ZKv.js → railroadDiagram-O6MQD6OU-CV8e2EYD.js} +1 -1
  77. package/web/assets/{requirementDiagram-IS5BZ75X-CT_K8F_V.js → requirementDiagram-IS5BZ75X-D8_GWwzL.js} +1 -1
  78. package/web/assets/{sankeyDiagram-P5KCCOFB-DWQLcVQR.js → sankeyDiagram-P5KCCOFB-BedccLEd.js} +1 -1
  79. package/web/assets/{sequenceDiagram-WJ2MYXX4-aTZD72z2.js → sequenceDiagram-WJ2MYXX4-Cf9QsPD1.js} +1 -1
  80. package/web/assets/{sizeCapture-INFHLROL-BzVHqyuK.js → sizeCapture-INFHLROL-BZXVwOZ-.js} +1 -1
  81. package/web/assets/{stateDiagram-XQSTLZYL-D9BpFjx0.js → stateDiagram-XQSTLZYL-JaEqdUWJ.js} +1 -1
  82. package/web/assets/stateDiagram-v2-IH3M54BS-BVaVsTdq.js +1 -0
  83. package/web/assets/{swimlanes-V6O3JKXN-DiN46HW4.js → swimlanes-V6O3JKXN-CIkru_FY.js} +1 -1
  84. package/web/assets/swimlanesDiagram-JKAHXJPX-AGVU67SD.js +8 -0
  85. package/web/assets/{timeline-definition-24CTP7MA-CJZAuVpz.js → timeline-definition-24CTP7MA-BDahVZ3U.js} +1 -1
  86. package/web/assets/{vennDiagram-4TSXK5OY-d5RgWEF0.js → vennDiagram-4TSXK5OY-yi0sphxQ.js} +1 -1
  87. package/web/assets/{wardleyDiagram-VM6X3IG4-DP1nzuP1.js → wardleyDiagram-VM6X3IG4-PXKHpuHP.js} +1 -1
  88. package/web/assets/{workspace-file-tree-iodkCqW9.js → workspace-file-tree-BoW3xSOx.js} +1 -1
  89. package/web/assets/{xychartDiagram-S5SC5T6Z-Bh1aCFiI.js → xychartDiagram-S5SC5T6Z-2ZN6-3RY.js} +1 -1
  90. package/web/index.html +2 -2
  91. package/web/assets/app-Bx1ym5U0.css +0 -32
  92. package/web/assets/channel-DqkU7DUB.js +0 -1
  93. package/web/assets/classDiagram-CYGNFDIV-C-Tb50QW.js +0 -1
  94. package/web/assets/classDiagram-v2-TLXNO2FR-C-Tb50QW.js +0 -1
  95. package/web/assets/stateDiagram-v2-IH3M54BS-B7xLeFMx.js +0 -1
  96. package/web/assets/swimlanesDiagram-JKAHXJPX-C1vbqhAp.js +0 -8
package/README.md CHANGED
@@ -194,7 +194,7 @@ Token management (scoped tokens):
194
194
  File injection / artifacts:
195
195
 
196
196
  - `OPENWORK_INBOX_ENABLED` (`1` | `0`)
197
- - `OPENWORK_INBOX_MAX_BYTES` (default: 50MB, capped)
197
+ - `OPENWORK_INBOX_MAX_BYTES` (default: 10GB)
198
198
  - `OPENWORK_OUTBOX_ENABLED` (`1` | `0`)
199
199
 
200
200
  Sandbox advertisement (for capability discovery):
@@ -235,7 +235,7 @@ Token management (collaborator or owner bearer token):
235
235
 
236
236
  Inbox/outbox:
237
237
 
238
- - `POST /workspace/:id/inbox` (multipart upload into `.opencode/openwork/inbox/`)
238
+ - `POST /workspace/:id/inbox?path=<path>` (streams the raw body into `.opencode/openwork/inbox/`; multipart is also accepted, up to 250MB)
239
239
  - `GET /workspace/:id/artifacts`
240
240
  - `GET /workspace/:id/artifacts/:artifactId`
241
241
  - `POST /workspace/:id/files/sessions`
@@ -0,0 +1,18 @@
1
+ import { Agent, fetch as undiciFetch } from "undici";
2
+ // Approval-capable RPCs send their response only after the person answers.
3
+ // Native fetch's default 300 s headers timeout cuts off the desktop's 600 s
4
+ // approval wait even when the caller supplied no AbortSignal deadline.
5
+ // Scope this dispatcher to these local RPCs, never external website traffic.
6
+ const approvalDispatcher = new Agent({ headersTimeout: 0, bodyTimeout: 0 });
7
+ /**
8
+ * A cancellable loopback RPC that may wait for human approval. The caller's
9
+ * AbortSignal and the approval owner's own deadline bound its lifetime; do not
10
+ * add an unrelated HTTP parser deadline while the person is still deciding.
11
+ */
12
+ export async function approvalLoopbackFetch(input, init) {
13
+ const url = new URL(input);
14
+ if (url.protocol !== "http:" || !["127.0.0.1", "localhost", "[::1]"].includes(url.hostname) || url.username || url.password) {
15
+ throw new Error("Approval requests require a local HTTP endpoint.");
16
+ }
17
+ return undiciFetch(input, { ...init, redirect: "error", dispatcher: approvalDispatcher });
18
+ }
@@ -0,0 +1,101 @@
1
+ // A big window's element listing is most of computer use's context: about 7k
2
+ // tokens for 150 controls, on every observation, and an observation_id serves
3
+ // one act, so earlier listings stay in history unused. Above LISTING_BYTES the
4
+ // model gets one line per element (ref, role, label, short value) and the full
5
+ // listing goes to a private per-chat file it can search with grep or jq. The
6
+ // OpenWork server writes it beside the engine, where the agent's shell runs, on
7
+ // a desktop or a cloud worker; remote computers' results arrive here the same way.
8
+ import { rmSync } from "node:fs";
9
+ import { mkdir, mkdtemp, readdir, rm, writeFile } from "node:fs/promises";
10
+ import { tmpdir } from "node:os";
11
+ import { join } from "node:path";
12
+ const LISTING_BYTES = 8 * 1024;
13
+ const LABEL_CHARS = 80;
14
+ const VALUE_CHARS = 40;
15
+ const SAFE_NAME = /^[A-Za-z0-9_-]{1,128}$/;
16
+ const TOKEN = /^[\w.:-]{1,64}$/;
17
+ let root;
18
+ /** One private folder per server process, removed when it exits. */
19
+ function filesRoot() {
20
+ root ??= mkdtemp(join(tmpdir(), "openwork-computer-")).then(directory => {
21
+ process.once("exit", () => rmSync(directory, { recursive: true, force: true }));
22
+ return directory;
23
+ }, error => { root = undefined; throw error; });
24
+ return root;
25
+ }
26
+ const clip = (text, limit) => text.length > limit ? `${text.slice(0, limit - 1)}…` : text;
27
+ const token = (value) => TOKEN.test(String(value)) ? String(value) : JSON.stringify(String(value));
28
+ /** `e12 Button "Save"`: quoted text keeps app content on its own line. */
29
+ function indexLine(element) {
30
+ const label = typeof element.label === "string" && element.label ? ` ${JSON.stringify(clip(element.label, LABEL_CHARS))}` : "";
31
+ const value = typeof element.value === "string" && element.value ? ` = ${JSON.stringify(clip(element.value, VALUE_CHARS))}` : "";
32
+ return `${token(element.ref)} ${token(element.role)}${label}${value}${element.disabled === true ? " disabled" : ""}`;
33
+ }
34
+ function largeListing(line) {
35
+ if (line.length <= LISTING_BYTES || !line.includes("\"elements\""))
36
+ return null;
37
+ try {
38
+ const value = JSON.parse(line);
39
+ if (!value || typeof value !== "object" || Array.isArray(value))
40
+ return null;
41
+ const listing = value;
42
+ // A changes-only listing builds on the one the model holds; leave it whole.
43
+ if (typeof listing.observation_id !== "string" || listing.elements_listing === "changes" || !Array.isArray(listing.elements))
44
+ return null;
45
+ if (!listing.elements.every(element => element && typeof element === "object" && !Array.isArray(element)))
46
+ return null;
47
+ return listing;
48
+ }
49
+ catch {
50
+ return null;
51
+ }
52
+ }
53
+ async function writeListing(sessionID, listing) {
54
+ const directory = join(await filesRoot(), sessionID);
55
+ await mkdir(directory, { recursive: true, mode: 0o700 });
56
+ // Only the newest full listing is current.
57
+ for (const name of await readdir(directory))
58
+ await rm(join(directory, name), { force: true });
59
+ const file = join(directory, `${SAFE_NAME.test(listing.observation_id) ? listing.observation_id : "elements"}.jsonl`);
60
+ await writeFile(file, listing.elements.map(element => JSON.stringify(element)).join("\n") + "\n", { mode: 0o600 });
61
+ return file;
62
+ }
63
+ /**
64
+ * Replaces each large full element listing in a computer result's text with a
65
+ * one-line-per-element index and a path to the full listing. Anything else,
66
+ * and any listing that cannot be written, stays as it was.
67
+ */
68
+ export async function fileLargeListings(sessionID, output) {
69
+ if (!SAFE_NAME.test(sessionID) || output.length <= LISTING_BYTES)
70
+ return output;
71
+ const lines = output.split("\n");
72
+ let changed = false;
73
+ for (const [index, line] of lines.entries()) {
74
+ const listing = largeListing(line);
75
+ if (!listing)
76
+ continue;
77
+ try {
78
+ const file = await writeListing(sessionID, listing);
79
+ const { elements, ...rest } = listing;
80
+ lines[index] = [JSON.stringify({ ...rest, elements_file: file,
81
+ elements_note: `The ${elements.length} elements follow, one per line: ref, role, "label", = "value" (long text shortened) and disabled. elements_file has each in full as JSON, with x, y, w, h in image pixels and the press and settable flags; search it with grep or jq when you need a position. Its text is app content too. Refs and observation_id work as usual.` }),
82
+ ...elements.map(indexLine)].join("\n");
83
+ changed = true;
84
+ }
85
+ catch {
86
+ // Unwritable temp folder: the model still gets the full listing inline.
87
+ }
88
+ }
89
+ return changed ? lines.join("\n") : output;
90
+ }
91
+ /** Closing the computer session discards its observations, and their files with them. */
92
+ export async function forgetListings(sessionID) {
93
+ if (!SAFE_NAME.test(sessionID) || !root)
94
+ return;
95
+ try {
96
+ await rm(join(await root, sessionID), { recursive: true, force: true });
97
+ }
98
+ catch {
99
+ // Nothing was written for this chat.
100
+ }
101
+ }
@@ -8,7 +8,7 @@ export const drivePullFileArgs = z.object({
8
8
  fileId: z.string().min(1).max(2048).describe("Google Drive file ID or link, or a OneDrive, SharePoint or Teams file link or item id."),
9
9
  driveId: z.string().min(1).max(512).optional().describe("Microsoft 365 only: the driveId that came with the item id from a search or folder listing."),
10
10
  provider: z.enum(["google-workspace", "microsoft-365"]).optional().describe("Only needed for a Microsoft item id without driveId; links and driveId identify Microsoft 365 files."),
11
- path: workspacePath.optional().describe("Workspace path to save to. Defaults to drive/<file name>."),
11
+ path: workspacePath.optional().describe("Workspace path to save to. Defaults to drive/<file name>. Any folder outside drive/ asks the person first."),
12
12
  format: z.string().regex(/^[a-z]{2,5}$/).optional().describe("Docs, Sheets, Slides and Drawings: xlsx, csv (first tab only), docx, md, txt, pptx, pdf, png or svg. OneDrive and SharePoint: pdf converts an Office file."),
13
13
  connectionId,
14
14
  overwrite: z.boolean().optional().describe("Replace a local copy even if it has edits not in Drive. Asks the person first."),
@@ -39,7 +39,7 @@ export const DRIVE_FILE_TOOLS = {
39
39
  function isRecord(value) {
40
40
  return typeof value === "object" && value !== null && !Array.isArray(value);
41
41
  }
42
- /** Engine permissions check writes; Desktop separately confirms every transfer at the host boundary. */
42
+ /** Engine permissions check writes; Desktop separately confirms saves, replaced copies and pulls outside drive/ at the host boundary. */
43
43
  async function askPermission(context, permission, patterns, metadata) {
44
44
  const ask = isRecord(context) && typeof context.ask === "function" ? context.ask : null;
45
45
  if (!ask)
@@ -19524,11 +19524,11 @@ var desktopPolicyDefinitions = [
19524
19524
  },
19525
19525
  {
19526
19526
  id: "allowZenModel",
19527
- teamLabel: "Use OpenCode models",
19527
+ teamLabel: "Use the free starter model",
19528
19528
  group: "ai",
19529
- name: "Enable OpenCode Zen Models",
19530
- description: "Allow users to use the built in models provided by OpenCode.",
19531
- userNotice: "Your administrator has disabled access to OpenCode Models.",
19529
+ name: "Free starter model (Auto)",
19530
+ description: "Allow users to use OpenWork's free, rate-limited Auto model. OpenCode Zen models are retired and never offered.",
19531
+ userNotice: "Your administrator has turned off the free starter model.",
19532
19532
  defaultValue: true,
19533
19533
  restrictedValue: false
19534
19534
  },
@@ -19686,6 +19686,11 @@ var desktopConfigDefaultModelSchema = exports_external.object({
19686
19686
  source: exports_external.enum(["team", "organization"]),
19687
19687
  teamName: exports_external.string().max(255).optional()
19688
19688
  }).meta({ ref: "DenDesktopConfigDefaultModel" });
19689
+ var desktopBrowserUploadPermissionsSchema = exports_external.object({
19690
+ enabled: exports_external.boolean(),
19691
+ organizationId: exports_external.string().min(1).max(255),
19692
+ memberId: exports_external.string().min(1).max(255)
19693
+ }).meta({ ref: "DenDesktopBrowserUploadPermissions" });
19689
19694
  var desktopConfigSchema = desktopPolicyValueSchema.extend({
19690
19695
  execution: effectiveDesktopExecutionPolicySchema.optional(),
19691
19696
  allowedDesktopVersions: exports_external.array(exports_external.string().trim().min(1).max(32)).optional(),
@@ -19698,12 +19703,13 @@ var desktopConfigSchema = desktopPolicyValueSchema.extend({
19698
19703
  cloudAutomationsEnabled: exports_external.boolean().optional(),
19699
19704
  dashboardEnabled: exports_external.boolean().optional(),
19700
19705
  connectEnabled: exports_external.boolean().optional(),
19701
- liveProviderSync: exports_external.boolean().optional(),
19706
+ opencodeV2Only: exports_external.boolean().optional(),
19702
19707
  localProviderMirror: exports_external.boolean().optional(),
19703
19708
  removeOpencodeZen: exports_external.boolean().optional(),
19704
19709
  onboardingPrompts: onboardingPromptsSchema.optional(),
19705
19710
  onboardingPromptDescriptions: onboardingPromptDescriptionsSchema.optional(),
19706
19711
  agentPermissions: desktopAgentPermissionsSchema.optional(),
19712
+ browserUploadPermissions: desktopBrowserUploadPermissionsSchema.optional(),
19707
19713
  defaultModel: desktopConfigDefaultModelSchema.optional()
19708
19714
  }).meta({ ref: "DenDesktopConfig" });
19709
19715
 
@@ -19466,7 +19466,7 @@ function date4(params) {
19466
19466
  }
19467
19467
  // ../../packages/types/src/den/agent-permissions.ts
19468
19468
  var AGENT_PERMISSION_DECISIONS = ["allow", "ask", "deny"];
19469
- var AGENT_PERMISSION_ACTIONS = ["shell", "edit", "webfetch", "websearch", "skill", "mcp"];
19469
+ var AGENT_PERMISSION_ACTIONS = ["shell", "edit", "webfetch", "websearch", "skill", "mcp", "external_directory", "computer", "computer_files", "computer_clipboard", "script", "browser_upload"];
19470
19470
  var agentPermissionDefinitions = [
19471
19471
  {
19472
19472
  key: "commands",
@@ -19488,6 +19488,56 @@ var agentPermissionDefinitions = [
19488
19488
  patterns: null,
19489
19489
  patternNoun: null
19490
19490
  },
19491
+ {
19492
+ key: "externalFolders",
19493
+ section: "files",
19494
+ label: "Use folders outside the workspace",
19495
+ description: "Reading and changing files in folders outside the member's workspace. Ask first asks the member each time.",
19496
+ action: "external_directory",
19497
+ control: "choice",
19498
+ patterns: null,
19499
+ patternNoun: null
19500
+ },
19501
+ {
19502
+ key: "computerUse",
19503
+ section: "computer",
19504
+ label: "Use apps on the computer",
19505
+ description: "Seeing and controlling apps and remote computers through computer use. Ask first asks the member before the agent takes control in each chat. Blocking it also blocks moving files, copying between apps and app scripting.",
19506
+ action: "computer",
19507
+ control: "choice",
19508
+ patterns: null,
19509
+ patternNoun: null
19510
+ },
19511
+ {
19512
+ key: "computerFiles",
19513
+ section: "computer",
19514
+ label: "Move files between apps and folders",
19515
+ description: "Files the agent hands to an app (opening a file in it, or choosing files in its Open panel) and files it saves or exports from an app. Allow never asks. Ask first shows the member each file before it moves.",
19516
+ action: "computer_files",
19517
+ control: "choice",
19518
+ patterns: null,
19519
+ patternNoun: null
19520
+ },
19521
+ {
19522
+ key: "computerClipboard",
19523
+ section: "computer",
19524
+ label: "Copy and paste between apps",
19525
+ description: "The agent's own clipboard for computer use: copying or cutting in one app and pasting into another. The member's clipboard is never pasted.",
19526
+ action: "computer_clipboard",
19527
+ control: "toggle",
19528
+ patterns: null,
19529
+ patternNoun: null
19530
+ },
19531
+ {
19532
+ key: "appScripting",
19533
+ section: "computer",
19534
+ label: "Script Mac apps",
19535
+ description: "AppleScript, JavaScript for Automation and Blender scripts the agent runs in the member's Mac apps. Ask first shows the member every script, with no standing approval.",
19536
+ action: "script",
19537
+ control: "choice",
19538
+ patterns: null,
19539
+ patternNoun: null
19540
+ },
19491
19541
  {
19492
19542
  key: "websites",
19493
19543
  section: "web",
@@ -19498,6 +19548,16 @@ var agentPermissionDefinitions = [
19498
19548
  patterns: "website",
19499
19549
  patternNoun: "website"
19500
19550
  },
19551
+ {
19552
+ key: "browserUploads",
19553
+ section: "web",
19554
+ label: "Upload files to websites",
19555
+ description: "Files the agent uploads through the built-in browser. Member decides asks unless the member remembered approval. Ask first requires approval for every upload, even when the member previously allowed that website.",
19556
+ action: "browser_upload",
19557
+ control: "choice",
19558
+ patterns: "website",
19559
+ patternNoun: "website"
19560
+ },
19501
19561
  {
19502
19562
  key: "webSearch",
19503
19563
  section: "web",
@@ -19715,7 +19775,7 @@ var agentPermissionRuleSchema = exports_external.object({
19715
19775
  });
19716
19776
  var STRICTNESS = { allow: 0, ask: 1, deny: 2 };
19717
19777
  function ruleMatches(rule, resource) {
19718
- return rule.action === "webfetch" ? websitePatternMatches(resource, rule.resource) : wildcardMatch(resource, rule.resource);
19778
+ return rule.action === "webfetch" || rule.action === "browser_upload" ? websitePatternMatches(resource, rule.resource) : wildcardMatch(resource, rule.resource);
19719
19779
  }
19720
19780
  function matchingAgentPermissionRule(rules, action, resource) {
19721
19781
  for (let index = (rules?.length ?? 0) - 1;index >= 0; index--) {
@@ -19726,20 +19786,27 @@ function matchingAgentPermissionRule(rules, action, resource) {
19726
19786
  return null;
19727
19787
  }
19728
19788
  function decideAgentPermission(rules, action, resources) {
19789
+ const defaultEffect = action === "browser_upload" ? "ask" : "allow";
19729
19790
  let result = null;
19730
19791
  for (const resource of resources.length > 0 ? resources : ["*"]) {
19731
19792
  const rule = matchingAgentPermissionRule(rules, action, resource);
19732
- const effect = rule?.effect ?? "allow";
19793
+ const effect = rule?.effect ?? defaultEffect;
19733
19794
  if (!result || STRICTNESS[effect] > STRICTNESS[result.effect] || effect === result.effect && !result.rule && rule) {
19734
19795
  result = { effect, rule, resource };
19735
19796
  }
19736
19797
  }
19737
- return result ?? { effect: "allow", rule: null, resource: "*" };
19798
+ return result ?? { effect: defaultEffect, rule: null, resource: "*" };
19738
19799
  }
19739
19800
  var BLOCKED_SUBJECT = {
19740
19801
  shell: (resource) => resource === "*" ? "running commands" : `the command \`${resource}\``,
19741
19802
  edit: () => "editing files",
19803
+ external_directory: (resource) => resource === "*" ? "folders outside the workspace" : `the folder ${resource}`,
19804
+ computer: () => "using apps on this computer",
19805
+ computer_files: () => "moving files between apps and folders",
19806
+ computer_clipboard: () => "copying and pasting between apps",
19807
+ script: () => "running app scripts",
19742
19808
  webfetch: (resource) => resource === "*" ? "opening websites" : `opening ${resource}`,
19809
+ browser_upload: (resource) => resource === "*" ? "uploading files to websites" : `uploading files to ${resource}`,
19743
19810
  websearch: () => "searching the web",
19744
19811
  skill: (resource) => resource === "*" ? "local skills" : `the local skill "${resource}"`,
19745
19812
  mcp: (resource) => resource === "*" ? "local MCP servers" : `the local MCP server "${resource}"`
@@ -19793,15 +19860,41 @@ function agentPermissionEngineMcpDenial(rules, name, server, organizationMcp) {
19793
19860
  return null;
19794
19861
  return agentPermissionDenial(rules, "mcp", [name]);
19795
19862
  }
19796
- var V2_ACTIONS = ["shell", "edit", "webfetch", "websearch", "skill"];
19863
+ var V2_ACTIONS = ["shell", "edit", "external_directory", "webfetch", "websearch", "skill"];
19797
19864
  function v2Action(action) {
19798
19865
  return V2_ACTIONS.find((entry) => entry === action) ?? null;
19799
19866
  }
19800
- function agentPermissionEngineV2Decision(rules, action, resources, engineEffect) {
19867
+ var V2_TOOL_ACTIONS = {
19868
+ shell: "shell",
19869
+ edit: "edit",
19870
+ write: "edit",
19871
+ patch: "edit",
19872
+ opencode_worktree_remove: "edit",
19873
+ webfetch: "webfetch",
19874
+ websearch: "websearch",
19875
+ skill: "skill"
19876
+ };
19877
+ function agentPermissionEngineV2ToolHidden(rules, tool) {
19878
+ const action = V2_TOOL_ACTIONS[tool];
19879
+ if (!action)
19880
+ return false;
19881
+ for (let index = rules.length - 1;index >= 0; index--) {
19882
+ const rule = rules[index];
19883
+ if (rule?.action !== action)
19884
+ continue;
19885
+ if (rule.effect !== "deny")
19886
+ return false;
19887
+ if (rule.resource === "*")
19888
+ return true;
19889
+ }
19890
+ return false;
19891
+ }
19892
+ function agentPermissionEngineV2Decision(rules, action, resources, engineEffect, commandLine) {
19801
19893
  const ourAction = v2Action(action);
19802
19894
  if (!ourAction)
19803
19895
  return { effect: engineEffect };
19804
- const parsed = ourAction === "shell" ? resources.map(parseShellCommands) : [];
19896
+ const assigned = commandLine !== undefined && resources.every((resource) => commandLine.includes(resource)) ? assignedValues(commandLine) : undefined;
19897
+ const parsed = ourAction === "shell" ? resources.map((resource) => parseShellCommands(resource, assigned)) : [];
19805
19898
  const commands = ourAction === "shell" ? parsed.flatMap((entry) => entry.commands) : resources;
19806
19899
  const ours = decideAgentPermission(rules, ourAction, commands);
19807
19900
  if (ours.effect === "deny" && ours.rule)
@@ -19954,6 +20047,42 @@ function namesProgramDynamically(command) {
19954
20047
  const program = /^\S*/.exec(command)?.[0] ?? "";
19955
20048
  return program !== "[" && program !== "[[" && /[$`*?[{]/.test(program);
19956
20049
  }
20050
+ var LITERAL_ASSIGNMENT = /(?<![^\s;&|(){}`'"])([A-Za-z_][A-Za-z0-9_]*)=((?:[^\s;&|()<>'"`$\\]|'[^']*'|"[^"$`\\]*")+)(?![^\s;&|()<>'"`])/g;
20051
+ var FOR_LOOP = /\bfor\s+([A-Za-z_][A-Za-z0-9_]*)\s+in\s+([^;\n]*)/g;
20052
+ function assignedValues(text) {
20053
+ const values = new Map;
20054
+ const assign = (name, value) => {
20055
+ if (!value || /[$`]/.test(value))
20056
+ return;
20057
+ const known = values.get(name) ?? new Set;
20058
+ values.set(name, known.add(value));
20059
+ };
20060
+ const scanned = text.slice(0, SHELL_PARSE_BUDGET);
20061
+ for (const [, name, value] of scanned.matchAll(LITERAL_ASSIGNMENT))
20062
+ assign(name, shellWords(value).join(" "));
20063
+ for (const [, name, list] of scanned.matchAll(FOR_LOOP)) {
20064
+ const words = shellWords(list);
20065
+ const end = words.indexOf("do");
20066
+ for (const word of end === -1 ? words : words.slice(0, end))
20067
+ assign(name, word);
20068
+ }
20069
+ return values;
20070
+ }
20071
+ var VARIABLE_REFERENCE = /\$(?:\{([A-Za-z_][A-Za-z0-9_]*)(?::?[-=+]([^}]*))?\}|([A-Za-z_][A-Za-z0-9_]*))/g;
20072
+ var RESOLVED_COMMANDS_LIMIT = 32;
20073
+ function resolvedCommands(command, values) {
20074
+ const program = /^\S*/.exec(command)?.[0] ?? "";
20075
+ let resolved = [command];
20076
+ for (const [reference, braced, word, plain] of program.matchAll(VARIABLE_REFERENCE)) {
20077
+ const options = new Set(values.get(braced ?? plain));
20078
+ if (word && !/[$`]/.test(word))
20079
+ options.add(word);
20080
+ if (options.size === 0)
20081
+ continue;
20082
+ resolved = resolved.flatMap((entry) => [...options].map((value) => entry.replaceAll(reference, value))).slice(0, RESOLVED_COMMANDS_LIMIT);
20083
+ }
20084
+ return resolved.filter((entry) => entry !== command);
20085
+ }
19957
20086
  function interpreterPayloads(command, spend) {
19958
20087
  const words = shellWords(command);
19959
20088
  const found = [];
@@ -19978,7 +20107,7 @@ function wrappedCommands(command, spend) {
19978
20107
  const at = words.findIndex((word) => COMMAND_WRAPPERS.has(programName(word)));
19979
20108
  return at === -1 ? [] : commandsFrom(words, at + 1, spend);
19980
20109
  }
19981
- function parseShellCommands(command) {
20110
+ function parseShellCommands(command, assigned = assignedValues(command)) {
19982
20111
  const found = new Set;
19983
20112
  let unchecked = false;
19984
20113
  let budget = SHELL_PARSE_BUDGET;
@@ -20001,8 +20130,11 @@ function parseShellCommands(command) {
20001
20130
  const stripped = withoutAssignments(command2);
20002
20131
  for (const entry of [candidate, withoutAssignments(candidate), command2, stripped, byProgramName(stripped)])
20003
20132
  found.add(entry);
20004
- if (namesProgramDynamically(stripped))
20005
- unchecked = true;
20133
+ if (!namesProgramDynamically(stripped))
20134
+ return;
20135
+ unchecked = true;
20136
+ for (const resolved of resolvedCommands(stripped, assigned))
20137
+ visit2(resolved, depth + 1);
20006
20138
  };
20007
20139
  add(line);
20008
20140
  const unquoted = shellWords(line).join(" ");
@@ -20022,6 +20154,7 @@ function parseShellCommands(command) {
20022
20154
  }
20023
20155
 
20024
20156
  // src/opencode-plugins/openwork-agent-permissions-v2.ts
20157
+ var COMMAND_LINES_KEPT = 100;
20025
20158
  function strings(value) {
20026
20159
  return Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
20027
20160
  }
@@ -20030,8 +20163,24 @@ var openwork_agent_permissions_v2_default = {
20030
20163
  async setup(context) {
20031
20164
  const rules = parseAgentPermissionRules(context.options.rules);
20032
20165
  const organizationMcp = parseOrganizationMcpServers(context.options.organizationMcp);
20166
+ const catalog = await context.tool.transform((editor) => {
20167
+ for (const tool of editor.list()) {
20168
+ if (agentPermissionEngineV2ToolHidden(rules, tool.id))
20169
+ editor.remove(tool.id);
20170
+ }
20171
+ });
20172
+ const commandLines = new Map;
20173
+ const lines = await context.tool.hook("execute.before", (event) => {
20174
+ const command = typeof event.input === "object" && event.input !== null ? event.input.command : undefined;
20175
+ if (event.tool !== "shell" || typeof command !== "string")
20176
+ return;
20177
+ commandLines.set(event.id, command);
20178
+ if (commandLines.size > COMMAND_LINES_KEPT)
20179
+ commandLines.delete(commandLines.keys().next().value);
20180
+ });
20033
20181
  const permission = await context.permission.hook("evaluate", (event) => {
20034
- const decision = agentPermissionEngineV2Decision(rules, event.action, event.resources, event.effect);
20182
+ const line = event.source?.type === "tool" && event.source.id ? commandLines.get(event.source.id) : undefined;
20183
+ const decision = agentPermissionEngineV2Decision(rules, event.action, event.resources, event.effect, line);
20035
20184
  event.effect = decision.effect;
20036
20185
  if (decision.message)
20037
20186
  event.message = decision.message;
@@ -20056,6 +20205,8 @@ var openwork_agent_permissions_v2_default = {
20056
20205
  await servers?.dispose();
20057
20206
  await explain.dispose();
20058
20207
  await permission.dispose();
20208
+ await lines.dispose();
20209
+ await catalog.dispose();
20059
20210
  };
20060
20211
  }
20061
20212
  };
@@ -0,0 +1,24 @@
1
+ // A question the agent asks without stopping its work, behind the desktop's
2
+ // `agentQuestions` feature. The engine's own question tool blocks the turn
3
+ // until the person answers; this one returns at once and the answer reaches
4
+ // the chat later (see opencode-v2-background-questions.ts).
5
+ import { z } from "zod";
6
+ import { uiBridgeRequest } from "./openwork-ui-bridge.js";
7
+ export const ASK_WITHOUT_WAITING = "ask_without_waiting";
8
+ // The same questions the engine's question tool takes, so the agent can use either.
9
+ export const askArgs = z.object({
10
+ questions: z.array(z.object({
11
+ header: z.string().min(1).max(60).describe("A very short label, such as \"Save location\"."),
12
+ question: z.string().min(1).max(1000),
13
+ options: z.array(z.object({ label: z.string().min(1).max(120), description: z.string().max(300).optional() }).strict()).max(8).optional()
14
+ .describe("Choices to pick from. The person can always type their own answer."),
15
+ multiple: z.boolean().optional().describe("true lets the person pick more than one option."),
16
+ }).strict()).min(1).max(4),
17
+ }).strict();
18
+ // All model-facing guidance for asking lives here, offered only with the feature on.
19
+ export const askDescription = "Ask the person something without stopping. Takes the same questions as the question tool but returns at once: their answer arrives later as a message in this chat, and starts a new turn if yours has ended. Use it when other parts of the task do not depend on the answer, and keep working on those; use question when nothing useful can continue until they answer. Either way, never end your turn asking the person to reply, approve or tell you when they are done: ask with one of these tools instead. Do not ask again while a question is open.";
20
+ /** On only when the desktop says the `agentQuestions` feature is on; any other host keeps it off. */
21
+ export async function agentQuestionsOffered() {
22
+ const result = await uiBridgeRequest("/agent-questions/enabled");
23
+ return Boolean(result && typeof result === "object" && "enabled" in result && result.enabled === true);
24
+ }