openwork-server 0.18.71 → 0.18.73

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 (105) hide show
  1. package/dist/opencode-plugin-deps-1.18.33.tgz +0 -0
  2. package/dist/opencode-plugins/agent-instruction-compose.js +0 -24
  3. package/dist/opencode-plugins/approval-loopback-fetch.js +0 -9
  4. package/dist/opencode-plugins/browser-tool-args.js +47 -0
  5. package/dist/opencode-plugins/computer-listing-files.js +0 -19
  6. package/dist/opencode-plugins/drive-file-tools.js +0 -4
  7. package/dist/opencode-plugins/gmail-attachment-fulfillment.js +0 -14
  8. package/dist/opencode-plugins/managed-policy-client.js +0 -2
  9. package/dist/opencode-plugins/opencode-stop-fence-client.js +0 -1
  10. package/dist/opencode-plugins/openwork-agent-permissions-v2.js +91 -7
  11. package/dist/opencode-plugins/openwork-agent-questions.js +2 -10
  12. package/dist/opencode-plugins/openwork-capabilities-knowledge.js +2 -2
  13. package/dist/opencode-plugins/openwork-chrome-devtools.js +73 -10
  14. package/dist/opencode-plugins/openwork-cloud-skills-v2.js +34 -49
  15. package/dist/opencode-plugins/openwork-codemode-discovery-v2.js +0 -7
  16. package/dist/opencode-plugins/openwork-computer-use.js +4 -4
  17. package/dist/opencode-plugins/openwork-context-v2.js +116 -22
  18. package/dist/opencode-plugins/openwork-extensions-preview-steering.js +0 -16
  19. package/dist/opencode-plugins/openwork-extensions-preview.js +1 -1
  20. package/dist/opencode-plugins/openwork-office-attachments.js +1401 -10
  21. package/dist/opencode-plugins/openwork-private-values-v2.js +38262 -0
  22. package/dist/opencode-plugins/openwork-private-values.js +38173 -0
  23. package/dist/opencode-plugins/openwork-provider-adapters.js +0 -11
  24. package/dist/opencode-plugins/openwork-session-groups.js +0 -13
  25. package/dist/opencode-plugins/openwork-spreadsheets.js +1401 -10
  26. package/dist/opencode-plugins/openwork-ui-bridge.js +1 -6
  27. package/dist/opencode-plugins/private-values-filter.js +150 -0
  28. package/dist/opencode-plugins/private-values-terminal.js +28 -0
  29. package/dist/opencode-plugins/private-values-tool.js +52 -0
  30. package/dist/opencode-plugins/provider-safe-tool-schema.js +0 -10
  31. package/dist/opencode-plugins/session-read-detail.js +0 -36
  32. package/dist/opencode-plugins/workspace-file-destinations.js +0 -5
  33. package/dist/openwork-server.mjs +6044 -2988
  34. package/package.json +1 -1
  35. package/web/assets/{abnfDiagram-VCTEODGH-DlWncS8i.js → abnfDiagram-VCTEODGH-CT7h6RSR.js} +1 -1
  36. package/web/assets/app-BinIaXyk.css +32 -0
  37. package/web/assets/{app-DSUHKGsm.js → app-DDsVI393.js} +480 -472
  38. package/web/assets/{arc-BtZC6wuw.js → arc-DrdxwkS1.js} +1 -1
  39. package/web/assets/{architectureDiagram-5GKGNRK7-DTbl4Rnl.js → architectureDiagram-5GKGNRK7-BHmeLgIo.js} +1 -1
  40. package/web/assets/{artifact-code-view-Ck4sjscy.js → artifact-code-view-BGAA8-Ej.js} +1 -1
  41. package/web/assets/artifact-office-preview-CCkdmKIT.js +6 -0
  42. package/web/assets/artifact-spreadsheet-editor-CMs_-Fs-.js +4 -0
  43. package/web/assets/{artifact-text-editor-DjSmnNjJ.js → artifact-text-editor-TtuV8SdE.js} +1 -1
  44. package/web/assets/{blockDiagram-OSKFZWR5-DAYSy6DL.js → blockDiagram-OSKFZWR5-CQ3xUn93.js} +1 -1
  45. package/web/assets/{c4Diagram-7LVT6UL2-CjyvESYl.js → c4Diagram-7LVT6UL2-s1wM6Iib.js} +1 -1
  46. package/web/assets/channel-DUquWRxW.js +1 -0
  47. package/web/assets/{chunk-2Q5K7J3B-CcMgFZAV.js → chunk-2Q5K7J3B-BZGXkEN4.js} +1 -1
  48. package/web/assets/{chunk-5VM5RSS4-D4c8XRGl.js → chunk-5VM5RSS4-C0tCaGEn.js} +1 -1
  49. package/web/assets/{chunk-F27PBJKO-BnyyjaCS.js → chunk-F27PBJKO-CGT4AvxR.js} +1 -1
  50. package/web/assets/{chunk-HLEWEB6X-JXz7B5zc.js → chunk-HLEWEB6X-BUm0nTzw.js} +1 -1
  51. package/web/assets/{chunk-JWPE2WC7-CYcnmDz7.js → chunk-JWPE2WC7-BrmOFhXE.js} +1 -1
  52. package/web/assets/{chunk-POPQ4Y6H-2llTUUN7.js → chunk-POPQ4Y6H-D0Red1rH.js} +1 -1
  53. package/web/assets/{chunk-SVP7TREG-BnWFSOpJ.js → chunk-SVP7TREG-BOfUyMpo.js} +1 -1
  54. package/web/assets/{chunk-XXDRQBXY-XqHzbo0u.js → chunk-XXDRQBXY-DdDJLBr5.js} +1 -1
  55. package/web/assets/{chunk-ZLD2IHE6-Dz_IjbQJ.js → chunk-ZLD2IHE6-CtgRsQI9.js} +1 -1
  56. package/web/assets/classDiagram-CYGNFDIV-D5L4nTet.js +1 -0
  57. package/web/assets/classDiagram-v2-TLXNO2FR-D5L4nTet.js +1 -0
  58. package/web/assets/{cose-bilkent-JH36ORCC--bD81EP5.js → cose-bilkent-JH36ORCC-C2GkVjI-.js} +1 -1
  59. package/web/assets/{cynefin-OW5HDTMX-tTD-HcrI.js → cynefin-OW5HDTMX-290exk3b.js} +1 -1
  60. package/web/assets/{cynefinDiagram-5FMLGOSQ-CMslIrwy.js → cynefinDiagram-5FMLGOSQ-Bn4pzfGg.js} +1 -1
  61. package/web/assets/{dagre-OS7QT2EB-B__oM1cx.js → dagre-OS7QT2EB-pvGtPuBl.js} +1 -1
  62. package/web/assets/{diagram-S7CK7UJ4-D2ghWE6t.js → diagram-S7CK7UJ4-CWs5HWfs.js} +1 -1
  63. package/web/assets/{diagram-UQ7AKVKN-BanDxdhW.js → diagram-UQ7AKVKN-DAtsBm-A.js} +1 -1
  64. package/web/assets/{diagram-VSXAHHWV-DGvbp0xT.js → diagram-VSXAHHWV-B0Z-KH-p.js} +1 -1
  65. package/web/assets/{diagram-VX7I27RA-CThCeJli.js → diagram-VX7I27RA-Bz5GVlm5.js} +1 -1
  66. package/web/assets/{diagram-Z3DM3KII-CAt65CmM.js → diagram-Z3DM3KII-BhwH3kbC.js} +1 -1
  67. package/web/assets/{ebnfDiagram-PWID7BFC-Cp5nPs03.js → ebnfDiagram-PWID7BFC-CIEcjysp.js} +1 -1
  68. package/web/assets/{erDiagram-2YWLMYGG-HLBdDnlf.js → erDiagram-2YWLMYGG-BrdXGtuT.js} +1 -1
  69. package/web/assets/{flowDiagram-T62WH6J4-CELW8hlc.js → flowDiagram-T62WH6J4-DskTn8O1.js} +1 -1
  70. package/web/assets/{ganttDiagram-EL5Y4UJY-C7R0OzTb.js → ganttDiagram-EL5Y4UJY-OCmeEDkw.js} +1 -1
  71. package/web/assets/{gitGraphDiagram-WWUBYQGX-qBuuQIor.js → gitGraphDiagram-WWUBYQGX-BuhI6DQ1.js} +1 -1
  72. package/web/assets/{infoDiagram-FKFFQAWI-iEzBkgjk.js → infoDiagram-FKFFQAWI-C3k38hJ_.js} +1 -1
  73. package/web/assets/{ishikawaDiagram-5VMMS53U-DrK4XY4T.js → ishikawaDiagram-5VMMS53U-C6Hpxc9K.js} +1 -1
  74. package/web/assets/{journeyDiagram-EYS64GPL-CGd8HUPB.js → journeyDiagram-EYS64GPL-C7KcOJMH.js} +1 -1
  75. package/web/assets/{kanban-definition-UXKFOSKX-DQmiyxel.js → kanban-definition-UXKFOSKX-ZcMziysx.js} +1 -1
  76. package/web/assets/{layout-DLjmmpHK.js → layout-DzriRV2A.js} +1 -1
  77. package/web/assets/{linear-DHJPnkfR.js → linear-DL_T580R.js} +1 -1
  78. package/web/assets/{mermaid.core-PQNy-dHT.js → mermaid.core-C4R8NQRz.js} +6 -6
  79. package/web/assets/{mindmap-definition-THT77NOG-B5jNdC9x.js → mindmap-definition-THT77NOG-n6izCCQf.js} +1 -1
  80. package/web/assets/{pegDiagram-XKGWAZYB-wbhF-roR.js → pegDiagram-XKGWAZYB-BADF-j9h.js} +1 -1
  81. package/web/assets/{pieDiagram-E7YTZNPT-2HAV5f46.js → pieDiagram-E7YTZNPT-BtdHIRbI.js} +1 -1
  82. package/web/assets/{quadrantDiagram-AXDQQJYC-CLDLYWPn.js → quadrantDiagram-AXDQQJYC-DhbkPfnT.js} +1 -1
  83. package/web/assets/{railroadDiagram-O6MQD6OU-Be5VkSOo.js → railroadDiagram-O6MQD6OU-BlyQ_Gry.js} +1 -1
  84. package/web/assets/{requirementDiagram-IS5BZ75X-qBk4BaLm.js → requirementDiagram-IS5BZ75X-BzIoUxA6.js} +1 -1
  85. package/web/assets/{sankeyDiagram-P5KCCOFB-a-kGn14g.js → sankeyDiagram-P5KCCOFB-qPG2gCyL.js} +1 -1
  86. package/web/assets/{sequenceDiagram-WJ2MYXX4-B19t616Z.js → sequenceDiagram-WJ2MYXX4-Bx12LmjC.js} +1 -1
  87. package/web/assets/{sizeCapture-INFHLROL-CGM0ZmNa.js → sizeCapture-INFHLROL-CvyuDIwF.js} +1 -1
  88. package/web/assets/{stateDiagram-XQSTLZYL-CQYuKN4p.js → stateDiagram-XQSTLZYL-DU9RhZb1.js} +1 -1
  89. package/web/assets/stateDiagram-v2-IH3M54BS-iZjygJwL.js +1 -0
  90. package/web/assets/{swimlanes-V6O3JKXN-CvzknNlU.js → swimlanes-V6O3JKXN-CTXpVjqj.js} +1 -1
  91. package/web/assets/swimlanesDiagram-JKAHXJPX-GfrjbmAb.js +8 -0
  92. package/web/assets/{timeline-definition-24CTP7MA-BhF3gzcl.js → timeline-definition-24CTP7MA-U_izIFdJ.js} +1 -1
  93. package/web/assets/{vennDiagram-4TSXK5OY-6DNrrc2_.js → vennDiagram-4TSXK5OY-DWquLtuy.js} +1 -1
  94. package/web/assets/{wardleyDiagram-VM6X3IG4-DO0onK3t.js → wardleyDiagram-VM6X3IG4-CH8aTVHX.js} +1 -1
  95. package/web/assets/{workspace-file-tree-BCpC4HYD.js → workspace-file-tree-CmGwayaP.js} +1 -1
  96. package/web/assets/xlsx-workbook-DcK1GLDS.js +9 -0
  97. package/web/assets/{xychartDiagram-S5SC5T6Z-44sg_69l.js → xychartDiagram-S5SC5T6Z-r1FFIWA_.js} +1 -1
  98. package/web/index.html +2 -2
  99. package/web/assets/app-CfKQPy_C.css +0 -32
  100. package/web/assets/artifact-spreadsheet-editor-O5R5Qt-8.js +0 -11
  101. package/web/assets/channel-OiorT9Re.js +0 -1
  102. package/web/assets/classDiagram-CYGNFDIV-CLY7M0C9.js +0 -1
  103. package/web/assets/classDiagram-v2-TLXNO2FR-CLY7M0C9.js +0 -1
  104. package/web/assets/stateDiagram-v2-IH3M54BS-CVq-yI8K.js +0 -1
  105. package/web/assets/swimlanesDiagram-JKAHXJPX-YWNRXT7V.js +0 -8
@@ -24,8 +24,6 @@ function uiControlDiscoveryPaths() {
24
24
  ].filter((p) => Boolean(p));
25
25
  }
26
26
  async function discoverUiBridge() {
27
- // A changed discovery override points at a different desktop; never reuse
28
- // the bridge cached for the previous one.
29
27
  const discovery = process.env.OPENWORK_UI_CONTROL_DISCOVERY?.trim();
30
28
  if (cachedBridge && cachedBridgeDiscovery === discovery && Date.now() - cachedBridgeAt < BRIDGE_CACHE_MS)
31
29
  return cachedBridge;
@@ -45,14 +43,11 @@ async function discoverUiBridge() {
45
43
  }
46
44
  }
47
45
  catch {
48
- // Try next
49
46
  }
50
47
  }
51
48
  return null;
52
49
  }
53
- export async function uiBridgeRequest(path,
54
- /** `timeoutMs: null` waits until `signal` aborts. */
55
- options = {}) {
50
+ export async function uiBridgeRequest(path, options = {}) {
56
51
  const bridge = await discoverUiBridge();
57
52
  if (!bridge)
58
53
  return { ok: false, code: "browser_unavailable", dispatched: false, error: "The built-in browser is unavailable. Open the desktop app on the same machine as this task's server." };
@@ -0,0 +1,150 @@
1
+ import { uiBridgeRequest } from "./openwork-ui-bridge.js";
2
+ export const OUTGOING = {
3
+ skip: new Set(["type", "role", "id", "name", "namespace", "tool", "callID", "messageID", "sessionID", "parentID", "status", "mime", "mediaType",
4
+ "providerID", "modelID", "agent", "mode", "variant", "encrypted", "signature", "providerMetadata", "metadata", "cache", "time", "tokens", "cost"]),
5
+ free: new Set(["input", "args", "structured"]),
6
+ };
7
+ export const STORED = {
8
+ skip: new Set(["type", "mime", "mediaType"]),
9
+ free: new Set(["output", "metadata", "structured"]),
10
+ };
11
+ const BATCH_CHARS = 8_000_000;
12
+ const BATCH_TEXTS = 4_000;
13
+ const REQUEST_MS = 20_000;
14
+ const SHORTEST = 4;
15
+ const TEXT_MEDIA = /^(?:text\/|application\/(?:json|xml|x-ndjson|javascript|x-www-form-urlencoded)\b)/i;
16
+ const BINARY_URL = /^data:(?!text\/|application\/(?:json|xml)\b|[;,])/i;
17
+ export const UNCHECKED = "OpenWork could not check this for private values, so nothing was sent. Try again in a moment.";
18
+ function record(value) {
19
+ return typeof value === "object" && value !== null && !Array.isArray(value);
20
+ }
21
+ function plain(value) {
22
+ const prototype = Object.getPrototypeOf(value);
23
+ return prototype === Object.prototype || prototype === null;
24
+ }
25
+ function scannable(text) {
26
+ return text.length >= SHORTEST && !BINARY_URL.test(text);
27
+ }
28
+ function collect(node, rules, slots, seen, free) {
29
+ if (Array.isArray(node)) {
30
+ if (seen.has(node))
31
+ return;
32
+ seen.add(node);
33
+ node.forEach((item, index) => {
34
+ if (typeof item !== "string")
35
+ collect(item, rules, slots, seen, free);
36
+ else if (scannable(item))
37
+ slots.push({ text: item, put: next => Reflect.set(node, index, next) });
38
+ });
39
+ return;
40
+ }
41
+ if (ArrayBuffer.isView(node) || node instanceof ArrayBuffer || node instanceof Date || !record(node) || seen.has(node))
42
+ return;
43
+ seen.add(node);
44
+ const binary = !free && [node.mediaType, node.mime].some(kind => typeof kind === "string" && !TEXT_MEDIA.test(kind));
45
+ for (const key of Object.keys(node)) {
46
+ if (!free && rules.skip.has(key))
47
+ continue;
48
+ const item = node[key];
49
+ if (typeof item !== "string")
50
+ collect(item, rules, slots, seen, free || rules.free.has(key) || (key === "value" && node.type !== "content"));
51
+ else if (scannable(item) && !(binary && key === "data"))
52
+ slots.push({ text: item, put: next => Reflect.set(node, key, next) });
53
+ if (free && key.length >= SHORTEST && plain(node)) {
54
+ slots.push({ text: key, put: next => {
55
+ const kept = node[key];
56
+ return Reflect.deleteProperty(node, key) && Reflect.set(node, next, kept);
57
+ } });
58
+ }
59
+ }
60
+ }
61
+ export function plainCopy(node) {
62
+ if (Array.isArray(node))
63
+ return node.map((item) => plainCopy(item));
64
+ if (!record(node) || !plain(node))
65
+ return node;
66
+ return Object.fromEntries(Object.entries(node).map(([key, item]) => [key, plainCopy(item)]));
67
+ }
68
+ export function redactReply(value) {
69
+ if (!record(value) || value.ok !== true || typeof value.held !== "boolean")
70
+ return null;
71
+ const texts = value.texts;
72
+ if (texts === undefined)
73
+ return { held: value.held };
74
+ return Array.isArray(texts) && texts.every((text) => typeof text === "string") ? { held: value.held, texts } : null;
75
+ }
76
+ const bridgeRequest = async (texts) => redactReply(await uiBridgeRequest("/private/redact", { method: "POST", body: texts ? { texts } : { probe: true }, timeoutMs: REQUEST_MS }));
77
+ export function redactThrough(relay) {
78
+ return async (texts) => {
79
+ const response = await fetch(relay.url, {
80
+ method: "POST", redirect: "error", signal: AbortSignal.timeout(REQUEST_MS + 5_000),
81
+ headers: { Authorization: `Bearer ${relay.token}`, "Content-Type": "application/json" },
82
+ body: JSON.stringify(texts ? { texts } : { probe: true }),
83
+ });
84
+ return response.ok ? redactReply(await response.json()) : null;
85
+ };
86
+ }
87
+ export function createPrivateValueScrubber(request = bridgeRequest) {
88
+ let heldBefore = false;
89
+ const unchecked = () => {
90
+ if (heldBefore)
91
+ throw new Error(UNCHECKED);
92
+ return 0;
93
+ };
94
+ return async function scrub(roots, rules) {
95
+ const slots = [];
96
+ const seen = new Set();
97
+ for (const root of roots)
98
+ collect(root, rules, slots, seen, false);
99
+ if (!slots.length)
100
+ return 0;
101
+ const probe = await request(null).catch(() => null);
102
+ if (!probe)
103
+ return unchecked();
104
+ if (!probe.held)
105
+ return 0;
106
+ heldBefore = true;
107
+ const unique = [...new Set(slots.map(slot => slot.text))];
108
+ const clean = new Map();
109
+ const batches = [];
110
+ let batch = [];
111
+ let chars = 0;
112
+ for (const text of unique) {
113
+ const size = JSON.stringify(text).length + 1;
114
+ if (batch.length && (batch.length >= BATCH_TEXTS || chars + size > BATCH_CHARS)) {
115
+ batches.push(batch);
116
+ batch = [];
117
+ chars = 0;
118
+ }
119
+ batch.push(text);
120
+ chars += size;
121
+ }
122
+ if (batch.length)
123
+ batches.push(batch);
124
+ for (const sent of batches) {
125
+ const answer = await request(sent).catch(() => null);
126
+ const texts = answer?.held ? answer.texts : undefined;
127
+ if (!texts || texts.length !== sent.length)
128
+ throw new Error(UNCHECKED);
129
+ sent.forEach((text, index) => clean.set(text, texts[index] ?? text));
130
+ }
131
+ let changed = 0;
132
+ for (const slot of slots) {
133
+ const next = clean.get(slot.text);
134
+ if (next === undefined || next === slot.text)
135
+ continue;
136
+ let written = false;
137
+ try {
138
+ written = slot.put(next);
139
+ }
140
+ catch {
141
+ written = false;
142
+ }
143
+ if (!written)
144
+ throw new Error(UNCHECKED);
145
+ changed += 1;
146
+ }
147
+ return changed;
148
+ };
149
+ }
150
+ export const scrubPrivateValues = createPrivateValueScrubber();
@@ -0,0 +1,28 @@
1
+ import { fillOnlyProgramIn } from "../agent-permission-engine.js";
2
+ import { uiBridgeRequest } from "./openwork-ui-bridge.js";
3
+ function record(value) {
4
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5
+ }
6
+ export function terminalBlockReply(value) {
7
+ if (!record(value) || value.ok !== true || typeof value.blocked !== "boolean")
8
+ return null;
9
+ const programs = Array.isArray(value.programs) ? value.programs.filter((name) => typeof name === "string" && name.length > 0) : [];
10
+ return { blocked: value.blocked, source: typeof value.source === "string" && value.source ? value.source : "Everyone", programs };
11
+ }
12
+ const askDesktop = async () => terminalBlockReply(await uiBridgeRequest("/private/terminal", { method: "POST", body: { check: true }, timeoutMs: 10_000 }));
13
+ export function fillOnlyRefusal(program, source) {
14
+ return `"${program}" was used to get a private value, so your organization keeps it out of your own terminal (set for ${source}), where you would read what it prints. Nothing was run. To type a value it prints into a website, use fill_from with that command; to give it to a program or an https request, use use_private_values. OpenWork runs the command after the person approves, and you never see the value. Tell the person if you cannot do the task that way.`;
15
+ }
16
+ export async function refuseFillOnlyPrograms(tool, args, ask = askDesktop) {
17
+ if (tool !== "bash" && tool !== "shell")
18
+ return;
19
+ const command = record(args) ? args.command : undefined;
20
+ if (typeof command !== "string")
21
+ return;
22
+ const block = await ask().catch(() => null);
23
+ if (!block?.blocked)
24
+ return;
25
+ const program = fillOnlyProgramIn(command, block.programs);
26
+ if (program !== null)
27
+ throw new Error(fillOnlyRefusal(program, block.source));
28
+ }
@@ -0,0 +1,52 @@
1
+ import { z } from "zod";
2
+ import { coerceJsonValue } from "./browser-tool-args.js";
3
+ export const USE_PRIVATE_VALUES = "use_private_values";
4
+ const valueName = z.string().regex(/^[A-Z_][A-Z0-9_]{0,63}$/).describe("An UPPER_CASE name. A program gets the value in this environment variable; a request takes it wherever {{NAME}} is written.");
5
+ const usedValue = z.object({
6
+ name: valueName,
7
+ command: z.array(z.string().max(512)).min(1).max(16).optional().describe("A program and its arguments that print the value alone, such as [\"op\", \"read\", \"op://Private/Deploy/token\"]. Started directly, with no shell. Give command or ask, never both."),
8
+ ask: z.string().min(1).max(80).optional().describe("A short name for a value the person pastes themselves, such as \"Deploy token\". Give command or ask, never both."),
9
+ unlock: z.object({ env: z.string().min(1).max(64), ask: z.string().min(1).max(80) }).optional().describe("A key the command needs in its environment, such as a password manager's session key, that the person pastes."),
10
+ as: z.enum(["env", "file"]).optional().describe("For run only: env (default) puts the value in the variable; file writes it to a private temporary file, deleted afterwards, and puts that file's path in the variable."),
11
+ }).strict();
12
+ export const usePrivateValuesArgs = {
13
+ values: z.array(usedValue).min(1).max(6),
14
+ run: z.object({ command: z.array(z.string().max(512)).min(1).max(16).describe("The program, by name or absolute path, and its arguments, started directly with no shell. Values are never written into the arguments.") }).optional(),
15
+ request: z.object({
16
+ method: z.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]), url: z.string().url().max(2000).describe("An https URL, without any value in it."),
17
+ headers: z.record(z.string(), z.string().max(2000)).optional(), body: z.string().max(16384).optional(),
18
+ seal: z.array(z.object({
19
+ name: valueName.describe("A NAME in capitals to keep it under."),
20
+ from: z.string().max(400).describe("Dotted path of the string in the JSON answer, such as access_token or data.token."),
21
+ for: z.string().url().optional().describe("The one https origin it may be sent to later. Defaults to this request's origin."),
22
+ })).min(1).max(4).optional().describe("Secrets in the answer to keep for this chat instead of showing you."),
23
+ }).optional().describe("One https request. Give run or request, never both."),
24
+ };
25
+ export const usePrivateValuesDescription = "Give private values (tokens, passwords, keys, account numbers) to one program or one https request without seeing them. Decide on your own which values are private: anything the person would not want you to read. Each value comes from a command that prints it, such as a password manager's CLI, or from the person pasting it on a card. The person approves every use on a card that shows the exact command or request. Use this whenever a program or API needs a value you should not read: never print, cat or echo such a value in a terminal, and never ask for it in chat. With run, the program gets each value in the named environment variable, or a private file whose path is there, in the workspace folder. With request, write {{NAME}} where each value goes in a header or the body, never in the URL; redirects are not followed. You get back what the program printed or the response, with every value replaced by [secret]. Nothing is saved: a value you need again is fetched again. When a request's JSON answer holds a new secret, such as an access token from a token endpoint, list it in request.seal: it is kept for this chat, never shown to you, and you send it later with a value { name, ask: <the sealed name> } in a request to its for origin.";
26
+ const schema = z.object(usePrivateValuesArgs);
27
+ function record(value) {
28
+ return typeof value === "object" && value !== null && !Array.isArray(value);
29
+ }
30
+ const UNAVAILABLE = { ok: false, code: "values_unavailable", retrySafe: true, error: "Private values need the OpenWork desktop app open on the same computer as this task. Nothing was run or sent." };
31
+ const INTERRUPTED = { ok: false, code: "values_interrupted", retrySafe: false, error: "The connection to OpenWork was interrupted. A program may or may not have run and a request may or may not have been sent; check before trying again." };
32
+ export async function privateValueToolOn(ask) {
33
+ const reply = await ask("state", { check: true }).catch(() => null);
34
+ return record(reply) && reply.ok === true && reply.enabled === true;
35
+ }
36
+ export async function usePrivateValues(raw, call, ask) {
37
+ const given = record(raw) ? { ...raw, values: coerceJsonValue(raw.values), run: coerceJsonValue(raw.run), request: coerceJsonValue(raw.request) } : raw;
38
+ const args = schema.parse(given);
39
+ let result;
40
+ try {
41
+ result = await ask("use", { sessionId: call.sessionId, args: { ...args, ...(call.directory ? { cwd: call.directory } : {}) } }, call.signal);
42
+ }
43
+ catch {
44
+ return JSON.stringify(INTERRUPTED);
45
+ }
46
+ const code = record(result) ? result.code : undefined;
47
+ if (code === "browser_unavailable")
48
+ return JSON.stringify(UNAVAILABLE);
49
+ if (code === "browser_disconnected" || !record(result))
50
+ return JSON.stringify(INTERRUPTED);
51
+ return JSON.stringify(result);
52
+ }
@@ -1,11 +1,3 @@
1
- // Providers validate tool input schemas differently, and one schema a provider
2
- // rejects fails every request in the conversation. These rules cover the
3
- // rejections seen so far:
4
- // - `$ref`: strict validators (DeepSeek, Groq) reject pointers that an engine
5
- // moved or dropped, and some reject recursion outright.
6
- // - top-level anyOf/oneOf/allOf: Anthropic rejects them.
7
- // - large size bounds: grammar-constrained providers (Fireworks, xAI,
8
- // llama.cpp) turn each bound into grammar rules, capped at 2^21 - 1 per request.
9
1
  export const MAX_SCHEMA_SIZE_BOUND = 32_000;
10
2
  const COMBINATORS = ["anyOf", "oneOf", "allOf"];
11
3
  const SIZE_BOUNDS = ["maxLength", "minLength", "maxItems", "minItems"];
@@ -13,7 +5,6 @@ const SCHEMA_MAPS = ["properties", "patternProperties", "$defs", "definitions"];
13
5
  const SCHEMA_LISTS = [...COMBINATORS, "prefixItems"];
14
6
  const SCHEMAS = ["items", "additionalProperties", "not", "contains", "propertyNames", "if", "then", "else"];
15
7
  const isSchema = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
16
- /** What would make a provider reject this tool input schema; empty when it is safe to send. */
17
8
  export function providerSchemaProblems(schema) {
18
9
  if (!isSchema(schema) || schema.type !== "object")
19
10
  return ["the root is not an object schema"];
@@ -45,7 +36,6 @@ export function providerSchemaProblems(schema) {
45
36
  visit(schema, "");
46
37
  return problems;
47
38
  }
48
- /** Adds the tool unless a provider would reject its schema, so one bad tool is missing instead of every request failing. */
49
39
  export function addProviderSafeTool(editor, tool) {
50
40
  const problems = providerSchemaProblems(tool.input);
51
41
  if (problems.length) {
@@ -1,25 +1,3 @@
1
- /**
2
- * `session.read` with `detail: "full"`: every message and content item the
3
- * engine stores, mapped from OpenCode v2's native message schema
4
- * (`Session.Message.Info`, `GET /api/session/:id/message`, engine 2.2.0) and,
5
- * for sessions still on v1, from the equivalent v1 message parts into the
6
- * same shape.
7
- *
8
- * Kept: every message type (user, assistant, synthetic, system, skill, shell,
9
- * compaction, idle, agent/model/location switches) and every assistant
10
- * content item (text, reasoning, tool calls with input, output, files, error,
11
- * metadata and timing), plus model, agent, finish reason, tokens, cost,
12
- * retries and changed files.
13
- *
14
- * Left out on purpose: provider `native` blobs (opaque, provider-specific,
15
- * may hold signed reasoning), inline base64 file data (the file's name, type
16
- * and URI are kept) and raw provider response bodies in errors.
17
- *
18
- * Long fields are clipped with a visible marker and the message is flagged
19
- * `truncated`; reading one message by `messageId` raises the limits.
20
- *
21
- * Dependency-free on purpose: the bundled engine plugin imports it.
22
- */
23
1
  function isRecord(value) {
24
2
  return typeof value === "object" && value !== null && !Array.isArray(value);
25
3
  }
@@ -35,7 +13,6 @@ function rec(value) {
35
13
  function list(value) {
36
14
  return Array.isArray(value) ? value : [];
37
15
  }
38
- /** Drops undefined fields so the result stays compact. */
39
16
  function compact(value) {
40
17
  for (const key of Object.keys(value))
41
18
  if (value[key] === undefined)
@@ -66,7 +43,6 @@ export const SESSION_READ_MESSAGE_LIMITS = {
66
43
  errorMessage: 4_000,
67
44
  toolBudget: 400_000,
68
45
  };
69
- /** Whole-result character budget for a list read. One message is always returned. */
70
46
  export const SESSION_READ_RESULT_BUDGET = 200_000;
71
47
  class Clipper {
72
48
  limits;
@@ -82,7 +58,6 @@ class Clipper {
82
58
  this.truncated = true;
83
59
  return `${value.slice(0, limit)}…[+${value.length - limit} chars; read this message by messageId for more]`;
84
60
  }
85
- /** Small JSON values stay structured; large ones become a clipped JSON string. */
86
61
  json(value, limit) {
87
62
  if (value === undefined)
88
63
  return undefined;
@@ -122,7 +97,6 @@ function richTokens(value) {
122
97
  cache: cache ? compact({ read: num(cache.read), write: num(cache.write) }) : undefined,
123
98
  });
124
99
  }
125
- /** v2 `Session.StructuredError`; the provider response body is omitted. */
126
100
  function richV2Error(value, clip) {
127
101
  const error = rec(value);
128
102
  if (!error)
@@ -143,7 +117,6 @@ function childSessionId(tool, metadata) {
143
117
  return undefined;
144
118
  return str(metadata.sessionId)?.trim() || str(metadata.sessionID)?.trim() || undefined;
145
119
  }
146
- /** A file reference without its bytes: `data:` URLs carry the whole file, so they become `inline`. */
147
120
  function fileRef(name, mime, uri) {
148
121
  const inline = uri?.startsWith("data:") === true;
149
122
  return compact({ name, mime, uri: inline ? undefined : uri, inline: inline ? true : undefined });
@@ -151,7 +124,6 @@ function fileRef(name, mime, uri) {
151
124
  function nonEmpty(value) {
152
125
  return value && Object.keys(value).length > 0 ? value : undefined;
153
126
  }
154
- /** Keeps tool input, output and metadata within the message's tool budget. */
155
127
  function budgetTools(content, clip) {
156
128
  let budget = clip.limits.toolBudget;
157
129
  return content.map((item) => {
@@ -199,7 +171,6 @@ function v2Tool(item, clip) {
199
171
  name,
200
172
  status,
201
173
  executed: typeof item.executed === "boolean" ? item.executed : undefined,
202
- // Streaming input is the raw partial JSON text the model is still writing.
203
174
  input: clip.json(state.input, clip.limits.toolInput),
204
175
  output: clip.text(output, clip.limits.toolOutput),
205
176
  files,
@@ -243,7 +214,6 @@ function v2File(value) {
243
214
  return fileRef(str(file.name), str(file.mime), str(source.uri));
244
215
  return compact({ name: str(file.name), mime: str(file.mime), inline: true });
245
216
  }
246
- /** Maps one native v2 `Session.Message.Info`. Unknown future types keep id, type and time. */
247
217
  export function richV2Message(row, limits, options = {}) {
248
218
  if (!isRecord(row))
249
219
  return null;
@@ -338,7 +308,6 @@ export function richV2Message(row, limits, options = {}) {
338
308
  const metadata = options.includeMetadata ? clip.json(nonEmpty(rec(row.metadata)), limits.toolMetadata) : undefined;
339
309
  return compact({ ...base, ...fields, metadata, truncated: clip.truncated ? true : undefined });
340
310
  }
341
- /** v1 errors are `{ name, data: { message } }`. */
342
311
  function richV1Error(value, clip) {
343
312
  const error = rec(value);
344
313
  if (!error)
@@ -377,7 +346,6 @@ function v1Tool(part, clip) {
377
346
  };
378
347
  return compact(call);
379
348
  }
380
- /** Maps one v1 `{ info, parts }` message into the same shape as v2. */
381
349
  export function richV1Message(message, limits, options = {}) {
382
350
  if (!isRecord(message))
383
351
  return null;
@@ -453,10 +421,6 @@ export function richV1Message(message, limits, options = {}) {
453
421
  truncated: clip.truncated ? true : undefined,
454
422
  });
455
423
  }
456
- /**
457
- * The newest (from end) or oldest (from start) messages that fit the result
458
- * budget, in chronological order. Always keeps at least one message.
459
- */
460
424
  export function fitSessionReadBudget(messages, from, budget = SESSION_READ_RESULT_BUDGET) {
461
425
  const ordered = from === "end" ? [...messages].reverse() : messages;
462
426
  const kept = [];
@@ -16,7 +16,6 @@ export function correctWorkspaceRoot(system, directory) {
16
16
  export function workspaceFileGuidance(directory) {
17
17
  return `The opened workspace directory is ${JSON.stringify(promptWorkspacePath(directory))}. For files requested in this workspace, prefer plain relative names such as report.html; native file tools save them inside this directory. Do not invent /workspace or a drive-root location. On Windows, drive-less rooted file paths such as /report.html or \\report.html are interpreted relative to this workspace, with the actual destination reported. Explicit full drive paths and UNC paths retain external-folder permissions. Do not bypass a denied path using another tool.`;
18
18
  }
19
- /** Only drive-less rooted syntax changes. Fully qualified and shell-drive forms keep native semantics. */
20
19
  export function workspaceRootedPath(input, directory) {
21
20
  if (!/^[\\/]/.test(input))
22
21
  return undefined;
@@ -58,7 +57,6 @@ export async function planWorkspacePaths(tool, args, directory, options = {}) {
58
57
  const resolved = workspaceRootedPath(requested, directory);
59
58
  if (!resolved)
60
59
  return requested;
61
- // Explicit folder grants continue to use the engine's original destination/permission flow.
62
60
  const original = tool === "apply_patch" ? win32.resolve(directory, requested) : win32.resolve(options.cwd ?? process.cwd(), requested);
63
61
  if (await options.externalAllowed?.(original))
64
62
  return requested;
@@ -74,7 +72,6 @@ export async function planWorkspacePaths(tool, args, directory, options = {}) {
74
72
  return undefined;
75
73
  const lines = args.patchText.split("\n");
76
74
  for (let index = 0; index < lines.length; index++) {
77
- // Match the pinned v1 parser's source/move headers, not added/context lines.
78
75
  const match = /^(\*\*\* (?:Add File|Update File|Delete File|Move to):[ \t]*)([^\r]*)(\r?)$/.exec(lines[index]);
79
76
  if (match)
80
77
  lines[index] = match[1] + await path(match[2].trim()) + match[3];
@@ -88,7 +85,6 @@ export function workspaceFileHooks(context, options = {}) {
88
85
  if (!context?.directory || !nativeMutations.has(input.toolID))
89
86
  return;
90
87
  output.description += `\n\n${workspaceFileGuidance(context.directory)}`;
91
- // Pinned v1 file schemas; runtime validation remains the engine's original schema.
92
88
  const filePath = { type: "string", description: "Path to the file. Prefer a plain workspace-relative name such as report.html; relative paths are saved in the opened workspace. Explicit full external paths retain folder permissions." };
93
89
  if (input.toolID === "write")
94
90
  output.jsonSchema = { type: "object", properties: { content: { type: "string", description: "The content to write" }, filePath }, required: ["content", "filePath"] };
@@ -111,7 +107,6 @@ export function workspaceFileHooks(context, options = {}) {
111
107
  throw new Error("Could not check external-folder grants; no workspace path was changed. Retry the operation.");
112
108
  const rules = rulesFromPermissionConfig(response.data.permission);
113
109
  const grant = winningRule(rules, "external_directory", win32.join(win32.dirname(original), "*"));
114
- // A blanket run-mode allow is not an explicit destination choice.
115
110
  return grant?.permission === "external_directory" && grant.action === "allow" && grant.pattern !== "*";
116
111
  },
117
112
  });