openwork-server 0.18.72 → 0.18.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/opencode-plugin-deps-1.18.33.tgz +0 -0
- package/dist/opencode-plugins/browser-tool-args.js +10 -0
- package/dist/opencode-plugins/cloud-coding-turn-release.js +58 -0
- package/dist/opencode-plugins/computer-routing-v2.js +77 -0
- package/dist/opencode-plugins/openwork-agent-permissions-v2.js +103 -8
- package/dist/opencode-plugins/openwork-chrome-devtools.js +29 -9
- package/dist/opencode-plugins/openwork-computer-use.js +4 -4
- package/dist/opencode-plugins/openwork-context-v2.js +384 -76
- package/dist/opencode-plugins/openwork-extensions-preview.js +457 -5
- package/dist/opencode-plugins/openwork-gateway-quota-v2.js +41 -1
- package/dist/opencode-plugins/openwork-gateway-quota.js +41 -1
- package/dist/opencode-plugins/openwork-mcp-results-v2.js +164 -14
- package/dist/opencode-plugins/openwork-mcp-server-events-v2.js +111 -0
- package/dist/opencode-plugins/openwork-mcp-server-skills-v2.js +176 -0
- package/dist/opencode-plugins/openwork-private-values-v2.js +38273 -0
- package/dist/opencode-plugins/openwork-private-values.js +38184 -0
- package/dist/opencode-plugins/openwork-provider-adapters.js +27 -1
- package/dist/opencode-plugins/openwork-provider-keys-v2.js +67 -0
- package/dist/opencode-plugins/openwork-sandbox-v2.js +1477 -10
- package/dist/opencode-plugins/private-values-filter.js +150 -0
- package/dist/opencode-plugins/private-values-terminal.js +28 -0
- package/dist/opencode-plugins/private-values-tool.js +52 -0
- package/dist/openwork-server.mjs +69668 -6974
- package/package.json +1 -1
- package/web/assets/{abnfDiagram-VCTEODGH-Bk2JrJ3j.js → abnfDiagram-VCTEODGH-C1Gri9T8.js} +1 -1
- package/web/assets/{app-CNo6L1tq.js → app-CoFPYBYF.js} +543 -527
- package/web/assets/app-aKrWzh-_.css +32 -0
- package/web/assets/{arc-BeMgz_zn.js → arc-DcBBW_Q9.js} +1 -1
- package/web/assets/{architectureDiagram-5GKGNRK7-CRxylST_.js → architectureDiagram-5GKGNRK7-CTnuu2og.js} +1 -1
- package/web/assets/{artifact-code-view-BwBuxnOh.js → artifact-code-view-CVhOSCb2.js} +1 -1
- package/web/assets/{artifact-office-preview-v_N9yGCg.js → artifact-office-preview-DHx-nPK0.js} +1 -1
- package/web/assets/{artifact-spreadsheet-editor-5lpd49cl.js → artifact-spreadsheet-editor-CyLsgBTK.js} +1 -1
- package/web/assets/{artifact-text-editor-Dj0SDUYJ.js → artifact-text-editor-4rrtf0C2.js} +1 -1
- package/web/assets/{blockDiagram-OSKFZWR5-CYcFpnr1.js → blockDiagram-OSKFZWR5-DbHntwyh.js} +1 -1
- package/web/assets/{c4Diagram-7LVT6UL2-KL6win2t.js → c4Diagram-7LVT6UL2-DPjlygzs.js} +1 -1
- package/web/assets/channel-UI6sNcoO.js +1 -0
- package/web/assets/{chunk-2Q5K7J3B-CjBMu5Dk.js → chunk-2Q5K7J3B-CwWe3fjf.js} +1 -1
- package/web/assets/{chunk-5VM5RSS4-CVfSxxeV.js → chunk-5VM5RSS4-D6ahhVKI.js} +1 -1
- package/web/assets/{chunk-F27PBJKO-Da-CK7uS.js → chunk-F27PBJKO-CKHJE6FB.js} +1 -1
- package/web/assets/{chunk-HLEWEB6X-DaBpQjxM.js → chunk-HLEWEB6X-CpB4YFh9.js} +1 -1
- package/web/assets/{chunk-JWPE2WC7-eZhhKb-9.js → chunk-JWPE2WC7-CuGkPOY8.js} +1 -1
- package/web/assets/{chunk-POPQ4Y6H-BuQza4Dl.js → chunk-POPQ4Y6H-BNCy4Rnz.js} +1 -1
- package/web/assets/{chunk-SVP7TREG-MuA1wNzK.js → chunk-SVP7TREG-BRLZtRG2.js} +1 -1
- package/web/assets/{chunk-XXDRQBXY-CIpJOQtx.js → chunk-XXDRQBXY-BXUFFdz9.js} +1 -1
- package/web/assets/{chunk-ZLD2IHE6-NhKoLW1Y.js → chunk-ZLD2IHE6-DgSq1MWh.js} +1 -1
- package/web/assets/classDiagram-CYGNFDIV-Cwqk7Tox.js +1 -0
- package/web/assets/classDiagram-v2-TLXNO2FR-Cwqk7Tox.js +1 -0
- package/web/assets/{cose-bilkent-JH36ORCC-B_lNY9db.js → cose-bilkent-JH36ORCC-BNS5x2WS.js} +1 -1
- package/web/assets/{cynefin-OW5HDTMX-BmqyCndA.js → cynefin-OW5HDTMX-xcD6kiaN.js} +1 -1
- package/web/assets/{cynefinDiagram-5FMLGOSQ-By2KC7b4.js → cynefinDiagram-5FMLGOSQ-Uh07MG7J.js} +1 -1
- package/web/assets/{dagre-OS7QT2EB-By7csWyW.js → dagre-OS7QT2EB-BR2ZK2Ka.js} +1 -1
- package/web/assets/{diagram-S7CK7UJ4-5_mhvlGk.js → diagram-S7CK7UJ4-CkeF04XL.js} +1 -1
- package/web/assets/{diagram-UQ7AKVKN-BPHF9t90.js → diagram-UQ7AKVKN-tszgJvn1.js} +1 -1
- package/web/assets/{diagram-VSXAHHWV-CyVv5z8B.js → diagram-VSXAHHWV-vQ_L10cP.js} +1 -1
- package/web/assets/{diagram-VX7I27RA-BdfxwGwk.js → diagram-VX7I27RA-DhttrIa4.js} +1 -1
- package/web/assets/{diagram-Z3DM3KII-BXg_HOys.js → diagram-Z3DM3KII-CSOtexfx.js} +1 -1
- package/web/assets/{ebnfDiagram-PWID7BFC-57--ZiB5.js → ebnfDiagram-PWID7BFC-DrXIeAI2.js} +1 -1
- package/web/assets/{erDiagram-2YWLMYGG-2WR_i4mr.js → erDiagram-2YWLMYGG-B6eY49sP.js} +1 -1
- package/web/assets/{flowDiagram-T62WH6J4-1qB430Tj.js → flowDiagram-T62WH6J4-BSWkKNsB.js} +1 -1
- package/web/assets/{ganttDiagram-EL5Y4UJY-DlsKL-gN.js → ganttDiagram-EL5Y4UJY-DjLWzUnc.js} +1 -1
- package/web/assets/{gitGraphDiagram-WWUBYQGX-DQ8IU_wC.js → gitGraphDiagram-WWUBYQGX-DLix_KEt.js} +1 -1
- package/web/assets/{infoDiagram-FKFFQAWI-kh9s5sRC.js → infoDiagram-FKFFQAWI-Qk5Rwj1J.js} +1 -1
- package/web/assets/{ishikawaDiagram-5VMMS53U-CaknQUcm.js → ishikawaDiagram-5VMMS53U-BYnLLj60.js} +1 -1
- package/web/assets/{journeyDiagram-EYS64GPL-DenZYZs9.js → journeyDiagram-EYS64GPL-DWbjv9jB.js} +1 -1
- package/web/assets/{kanban-definition-UXKFOSKX-ptoI6qD1.js → kanban-definition-UXKFOSKX-DBKDdN7W.js} +1 -1
- package/web/assets/{layout-B4UdHd1t.js → layout-C3nuFW6O.js} +1 -1
- package/web/assets/{linear-DbhtXtCn.js → linear-yuvoF7oC.js} +1 -1
- package/web/assets/{mermaid.core-BoXM2BMZ.js → mermaid.core-Cf_HDEwk.js} +6 -6
- package/web/assets/{mindmap-definition-THT77NOG-Bcw34klO.js → mindmap-definition-THT77NOG-CLlmGHfy.js} +1 -1
- package/web/assets/{pegDiagram-XKGWAZYB-CZ49Cylj.js → pegDiagram-XKGWAZYB-DF2jK0hL.js} +1 -1
- package/web/assets/{pieDiagram-E7YTZNPT-F5Tl-jOo.js → pieDiagram-E7YTZNPT-B7D6K8Dy.js} +1 -1
- package/web/assets/{quadrantDiagram-AXDQQJYC-BindC9Ln.js → quadrantDiagram-AXDQQJYC-BJs4k_-l.js} +1 -1
- package/web/assets/{railroadDiagram-O6MQD6OU-BHfARQKt.js → railroadDiagram-O6MQD6OU-Bvh8M0tG.js} +1 -1
- package/web/assets/{requirementDiagram-IS5BZ75X-DeyyjrFZ.js → requirementDiagram-IS5BZ75X-LojIE3iY.js} +1 -1
- package/web/assets/{sankeyDiagram-P5KCCOFB-Bf4RYjdY.js → sankeyDiagram-P5KCCOFB-DDgsHbe_.js} +1 -1
- package/web/assets/{sequenceDiagram-WJ2MYXX4-D0I5Iail.js → sequenceDiagram-WJ2MYXX4-B0n0qkKj.js} +1 -1
- package/web/assets/{sizeCapture-INFHLROL-ZMHjeD6L.js → sizeCapture-INFHLROL-dvjrjvhR.js} +1 -1
- package/web/assets/{stateDiagram-XQSTLZYL-XMu0akCC.js → stateDiagram-XQSTLZYL-6R2ncL9w.js} +1 -1
- package/web/assets/stateDiagram-v2-IH3M54BS-C3zcPvlu.js +1 -0
- package/web/assets/{swimlanes-V6O3JKXN-BX1vgjAt.js → swimlanes-V6O3JKXN-NgTb-Uz5.js} +1 -1
- package/web/assets/swimlanesDiagram-JKAHXJPX-CA7dhlYX.js +8 -0
- package/web/assets/{timeline-definition-24CTP7MA-B-V8Y7U9.js → timeline-definition-24CTP7MA-2H_ljVU0.js} +1 -1
- package/web/assets/{vennDiagram-4TSXK5OY-iHvsobDU.js → vennDiagram-4TSXK5OY-BKJ-Jni_.js} +1 -1
- package/web/assets/{wardleyDiagram-VM6X3IG4-BTl7bSNi.js → wardleyDiagram-VM6X3IG4-BY36Sv2N.js} +1 -1
- package/web/assets/{workspace-file-tree-EJaUSokl.js → workspace-file-tree-C2bTmTtl.js} +7 -7
- package/web/assets/{xlsx-workbook-DVIQLEdk.js → xlsx-workbook-B0y0zWAe.js} +1 -1
- package/web/assets/{xychartDiagram-S5SC5T6Z-BKhJK0Av.js → xychartDiagram-S5SC5T6Z-DabU-r2I.js} +1 -1
- package/web/index.html +2 -2
- package/web/assets/app-BinIaXyk.css +0 -32
- package/web/assets/channel-C7q2VHY_.js +0 -1
- package/web/assets/classDiagram-CYGNFDIV-DKD7FwJZ.js +0 -1
- package/web/assets/classDiagram-v2-TLXNO2FR-DKD7FwJZ.js +0 -1
- package/web/assets/stateDiagram-v2-IH3M54BS-CNv5Ofd5.js +0 -1
- package/web/assets/swimlanesDiagram-JKAHXJPX-yIR7kUmA.js +0 -8
|
@@ -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]. A command's value is fetched again each time. A value the person pastes can be kept for this chat when they choose that on the card: ask for it under the same NAME, for the same program or site, and they have nothing to paste again. When several steps need the same value, do them in one program so the person approves once. The card is the person's whole answer: never ask in chat whether they pasted or approved it. 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
|
+
}
|