openwork-server 0.18.63 → 0.18.64
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/README.md +2 -2
- package/dist/opencode-plugin-deps-1.18.33.tgz +0 -0
- package/dist/opencode-plugins/approval-loopback-fetch.js +18 -0
- package/dist/opencode-plugins/drive-file-tools.js +2 -2
- package/dist/opencode-plugins/managed-policy-next.js +11 -5
- package/dist/opencode-plugins/openwork-agent-permissions-v2.js +140 -11
- package/dist/opencode-plugins/openwork-auto-route-v2.js +19657 -0
- package/dist/opencode-plugins/openwork-capabilities-knowledge.js +5 -3
- package/dist/opencode-plugins/openwork-chrome-devtools.js +17498 -5
- package/dist/opencode-plugins/openwork-cloud-skills-v2.js +54 -31
- package/dist/opencode-plugins/openwork-computer-use.js +17509 -18
- package/dist/opencode-plugins/openwork-context-v2.js +17624 -54
- package/dist/opencode-plugins/openwork-extensions-preview.js +928 -175
- package/dist/opencode-plugins/openwork-gateway-quota-v2.js +15 -0
- package/dist/opencode-plugins/openwork-gateway-quota.js +15 -0
- package/dist/opencode-plugins/openwork-provider-adapters.js +65 -6
- package/dist/opencode-plugins/openwork-provider-sync-v2.js +459 -139
- package/dist/opencode-plugins/openwork-session-groups.js +5 -4
- package/dist/opencode-plugins/openwork-ui-bridge.js +6 -3
- package/dist/opencode-plugins/session-read-detail.js +475 -0
- package/dist/openwork-server.mjs +8932 -5281
- package/package.json +1 -1
- package/web/assets/{abnfDiagram-VCTEODGH-BSIb81ug.js → abnfDiagram-VCTEODGH-j_pTDiqz.js} +1 -1
- package/web/assets/{app-DZr96oX3.js → app-Bzky4OVl.js} +443 -443
- package/web/assets/app-C32roy8y.css +32 -0
- package/web/assets/{arc-BTCnV0Ha.js → arc-CaQNh7ZT.js} +1 -1
- package/web/assets/{architectureDiagram-5GKGNRK7-3IgeX1_6.js → architectureDiagram-5GKGNRK7-wMx5wEbF.js} +1 -1
- package/web/assets/{artifact-code-view-ZP8nVuQx.js → artifact-code-view-DCMMpJxD.js} +1 -1
- package/web/assets/{artifact-spreadsheet-editor-BW94PK45.js → artifact-spreadsheet-editor-DNHOxqPc.js} +1 -1
- package/web/assets/{artifact-text-editor-BhIcTcNi.js → artifact-text-editor-o6WCLEmo.js} +1 -1
- package/web/assets/{blockDiagram-OSKFZWR5-d1pNUfi4.js → blockDiagram-OSKFZWR5-BYAM-sb8.js} +1 -1
- package/web/assets/{c4Diagram-7LVT6UL2-BTVoP_gs.js → c4Diagram-7LVT6UL2-pOXGVuIa.js} +1 -1
- package/web/assets/channel-DR4AKESO.js +1 -0
- package/web/assets/{chunk-2Q5K7J3B-BIy8BDgC.js → chunk-2Q5K7J3B-A7RWrtFk.js} +1 -1
- package/web/assets/{chunk-5VM5RSS4-BDvSSuPz.js → chunk-5VM5RSS4-BbhM53lO.js} +1 -1
- package/web/assets/{chunk-F27PBJKO-CqT02j1I.js → chunk-F27PBJKO-Aoti2mfN.js} +1 -1
- package/web/assets/{chunk-HLEWEB6X-DOSYJ6qO.js → chunk-HLEWEB6X-h1a1fijx.js} +1 -1
- package/web/assets/{chunk-JWPE2WC7-BLJ5TLJ6.js → chunk-JWPE2WC7-CtyBiDJt.js} +1 -1
- package/web/assets/{chunk-POPQ4Y6H-TRvB63--.js → chunk-POPQ4Y6H-d6pjL5RD.js} +1 -1
- package/web/assets/{chunk-SVP7TREG-Bz6HrnA2.js → chunk-SVP7TREG-DnzaR7AG.js} +1 -1
- package/web/assets/{chunk-XXDRQBXY-wBuvw6SP.js → chunk-XXDRQBXY-B9hkBiar.js} +1 -1
- package/web/assets/{chunk-ZLD2IHE6-CsK6m1Sk.js → chunk-ZLD2IHE6-DzJ1_fxy.js} +1 -1
- package/web/assets/classDiagram-CYGNFDIV-B0y8HxEN.js +1 -0
- package/web/assets/classDiagram-v2-TLXNO2FR-B0y8HxEN.js +1 -0
- package/web/assets/{cose-bilkent-JH36ORCC-CISbKtKO.js → cose-bilkent-JH36ORCC-BhvTRFRe.js} +1 -1
- package/web/assets/{cynefin-OW5HDTMX-Dk7vIkhw.js → cynefin-OW5HDTMX-fGckFsSU.js} +1 -1
- package/web/assets/{cynefinDiagram-5FMLGOSQ-C3bIjcy0.js → cynefinDiagram-5FMLGOSQ-BzW--hKZ.js} +1 -1
- package/web/assets/{dagre-OS7QT2EB-BsP75gf5.js → dagre-OS7QT2EB-BnhLgL07.js} +1 -1
- package/web/assets/{diagram-S7CK7UJ4-B4K-iSz7.js → diagram-S7CK7UJ4-Cu-md7dS.js} +1 -1
- package/web/assets/{diagram-UQ7AKVKN-bly7AwhV.js → diagram-UQ7AKVKN-DXQdcUqJ.js} +1 -1
- package/web/assets/{diagram-VSXAHHWV-DObKajM9.js → diagram-VSXAHHWV-C0TNG60H.js} +1 -1
- package/web/assets/{diagram-VX7I27RA-SQp5kc6I.js → diagram-VX7I27RA-z9AkHrlD.js} +1 -1
- package/web/assets/{diagram-Z3DM3KII-BmaqS6Rw.js → diagram-Z3DM3KII-CB0wN1mx.js} +1 -1
- package/web/assets/{ebnfDiagram-PWID7BFC-BOhK-9Al.js → ebnfDiagram-PWID7BFC-k6ofa2S7.js} +1 -1
- package/web/assets/{erDiagram-2YWLMYGG-DP0d4SRU.js → erDiagram-2YWLMYGG-DH0LRcXA.js} +1 -1
- package/web/assets/{flowDiagram-T62WH6J4-CJLvattq.js → flowDiagram-T62WH6J4-BRVNnCPG.js} +1 -1
- package/web/assets/{ganttDiagram-EL5Y4UJY-Dzi8suyh.js → ganttDiagram-EL5Y4UJY-BnEWMV5l.js} +1 -1
- package/web/assets/{gitGraphDiagram-WWUBYQGX-D-xOZUu9.js → gitGraphDiagram-WWUBYQGX-COrkPeQK.js} +1 -1
- package/web/assets/{infoDiagram-FKFFQAWI-CTR7Ei2k.js → infoDiagram-FKFFQAWI-DZuH1fmc.js} +1 -1
- package/web/assets/{ishikawaDiagram-5VMMS53U-CBf51Qea.js → ishikawaDiagram-5VMMS53U-CaJUJ6Ff.js} +1 -1
- package/web/assets/{journeyDiagram-EYS64GPL-ZumMGF2u.js → journeyDiagram-EYS64GPL-BE6Fv_rV.js} +1 -1
- package/web/assets/{kanban-definition-UXKFOSKX-81Fni8Sl.js → kanban-definition-UXKFOSKX-B4bPGzK6.js} +1 -1
- package/web/assets/{layout-D-HFg0Gy.js → layout-or_42uvc.js} +1 -1
- package/web/assets/{linear-lAHomfjd.js → linear-5PXMsdhe.js} +1 -1
- package/web/assets/{mermaid.core-sRbhnZ3C.js → mermaid.core-DW6D3RPJ.js} +6 -6
- package/web/assets/{mindmap-definition-THT77NOG-t_uxFNYx.js → mindmap-definition-THT77NOG-CyTLW_BU.js} +1 -1
- package/web/assets/{pegDiagram-XKGWAZYB-B4FryuiE.js → pegDiagram-XKGWAZYB-7JUI9VKo.js} +1 -1
- package/web/assets/{pieDiagram-E7YTZNPT-DrIgLewj.js → pieDiagram-E7YTZNPT-Bp-lNUXy.js} +1 -1
- package/web/assets/{quadrantDiagram-AXDQQJYC-DifmQS8L.js → quadrantDiagram-AXDQQJYC-BHzbyOLv.js} +1 -1
- package/web/assets/{railroadDiagram-O6MQD6OU-C76a1ZKv.js → railroadDiagram-O6MQD6OU-DUbwyc8J.js} +1 -1
- package/web/assets/{requirementDiagram-IS5BZ75X-CT_K8F_V.js → requirementDiagram-IS5BZ75X-C6vHvRXL.js} +1 -1
- package/web/assets/{sankeyDiagram-P5KCCOFB-DWQLcVQR.js → sankeyDiagram-P5KCCOFB-rhUrZHvo.js} +1 -1
- package/web/assets/{sequenceDiagram-WJ2MYXX4-aTZD72z2.js → sequenceDiagram-WJ2MYXX4-CbKw45qx.js} +1 -1
- package/web/assets/{sizeCapture-INFHLROL-BzVHqyuK.js → sizeCapture-INFHLROL-BzYRidKe.js} +1 -1
- package/web/assets/{stateDiagram-XQSTLZYL-D9BpFjx0.js → stateDiagram-XQSTLZYL-CY_NqfCu.js} +1 -1
- package/web/assets/stateDiagram-v2-IH3M54BS-ZplxpnyH.js +1 -0
- package/web/assets/{swimlanes-V6O3JKXN-DiN46HW4.js → swimlanes-V6O3JKXN-DsuNS06S.js} +1 -1
- package/web/assets/swimlanesDiagram-JKAHXJPX-BgYXaTmf.js +8 -0
- package/web/assets/{timeline-definition-24CTP7MA-CJZAuVpz.js → timeline-definition-24CTP7MA-Bw7piZjw.js} +1 -1
- package/web/assets/{vennDiagram-4TSXK5OY-d5RgWEF0.js → vennDiagram-4TSXK5OY-3QO9enN9.js} +1 -1
- package/web/assets/{wardleyDiagram-VM6X3IG4-DP1nzuP1.js → wardleyDiagram-VM6X3IG4-u2wsdzR8.js} +1 -1
- package/web/assets/{workspace-file-tree-iodkCqW9.js → workspace-file-tree-B0RW5c5J.js} +1 -1
- package/web/assets/{xychartDiagram-S5SC5T6Z-Bh1aCFiI.js → xychartDiagram-S5SC5T6Z-YVqX-MzU.js} +1 -1
- package/web/index.html +2 -2
- package/web/assets/app-Bx1ym5U0.css +0 -32
- package/web/assets/channel-DqkU7DUB.js +0 -1
- package/web/assets/classDiagram-CYGNFDIV-C-Tb50QW.js +0 -1
- package/web/assets/classDiagram-v2-TLXNO2FR-C-Tb50QW.js +0 -1
- package/web/assets/stateDiagram-v2-IH3M54BS-B7xLeFMx.js +0 -1
- 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:
|
|
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
|
|
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`
|
|
Binary file
|
|
@@ -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
|
+
}
|
|
@@ -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
|
|
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
|
|
19527
|
+
teamLabel: "Use the free starter model",
|
|
19528
19528
|
group: "ai",
|
|
19529
|
-
name: "
|
|
19530
|
-
description: "Allow users to use
|
|
19531
|
-
userNotice: "Your administrator has
|
|
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
|
-
|
|
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", "script", "browser_upload"];
|
|
19470
19470
|
var agentPermissionDefinitions = [
|
|
19471
19471
|
{
|
|
19472
19472
|
key: "commands",
|
|
@@ -19488,6 +19488,36 @@ 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 app scripting.",
|
|
19506
|
+
action: "computer",
|
|
19507
|
+
control: "choice",
|
|
19508
|
+
patterns: null,
|
|
19509
|
+
patternNoun: null
|
|
19510
|
+
},
|
|
19511
|
+
{
|
|
19512
|
+
key: "appScripting",
|
|
19513
|
+
section: "computer",
|
|
19514
|
+
label: "Script Mac apps",
|
|
19515
|
+
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.",
|
|
19516
|
+
action: "script",
|
|
19517
|
+
control: "choice",
|
|
19518
|
+
patterns: null,
|
|
19519
|
+
patternNoun: null
|
|
19520
|
+
},
|
|
19491
19521
|
{
|
|
19492
19522
|
key: "websites",
|
|
19493
19523
|
section: "web",
|
|
@@ -19498,6 +19528,16 @@ var agentPermissionDefinitions = [
|
|
|
19498
19528
|
patterns: "website",
|
|
19499
19529
|
patternNoun: "website"
|
|
19500
19530
|
},
|
|
19531
|
+
{
|
|
19532
|
+
key: "browserUploads",
|
|
19533
|
+
section: "web",
|
|
19534
|
+
label: "Upload files to websites",
|
|
19535
|
+
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.",
|
|
19536
|
+
action: "browser_upload",
|
|
19537
|
+
control: "choice",
|
|
19538
|
+
patterns: "website",
|
|
19539
|
+
patternNoun: "website"
|
|
19540
|
+
},
|
|
19501
19541
|
{
|
|
19502
19542
|
key: "webSearch",
|
|
19503
19543
|
section: "web",
|
|
@@ -19715,7 +19755,7 @@ var agentPermissionRuleSchema = exports_external.object({
|
|
|
19715
19755
|
});
|
|
19716
19756
|
var STRICTNESS = { allow: 0, ask: 1, deny: 2 };
|
|
19717
19757
|
function ruleMatches(rule, resource) {
|
|
19718
|
-
return rule.action === "webfetch" ? websitePatternMatches(resource, rule.resource) : wildcardMatch(resource, rule.resource);
|
|
19758
|
+
return rule.action === "webfetch" || rule.action === "browser_upload" ? websitePatternMatches(resource, rule.resource) : wildcardMatch(resource, rule.resource);
|
|
19719
19759
|
}
|
|
19720
19760
|
function matchingAgentPermissionRule(rules, action, resource) {
|
|
19721
19761
|
for (let index = (rules?.length ?? 0) - 1;index >= 0; index--) {
|
|
@@ -19726,20 +19766,25 @@ function matchingAgentPermissionRule(rules, action, resource) {
|
|
|
19726
19766
|
return null;
|
|
19727
19767
|
}
|
|
19728
19768
|
function decideAgentPermission(rules, action, resources) {
|
|
19769
|
+
const defaultEffect = action === "browser_upload" ? "ask" : "allow";
|
|
19729
19770
|
let result = null;
|
|
19730
19771
|
for (const resource of resources.length > 0 ? resources : ["*"]) {
|
|
19731
19772
|
const rule = matchingAgentPermissionRule(rules, action, resource);
|
|
19732
|
-
const effect = rule?.effect ??
|
|
19773
|
+
const effect = rule?.effect ?? defaultEffect;
|
|
19733
19774
|
if (!result || STRICTNESS[effect] > STRICTNESS[result.effect] || effect === result.effect && !result.rule && rule) {
|
|
19734
19775
|
result = { effect, rule, resource };
|
|
19735
19776
|
}
|
|
19736
19777
|
}
|
|
19737
|
-
return result ?? { effect:
|
|
19778
|
+
return result ?? { effect: defaultEffect, rule: null, resource: "*" };
|
|
19738
19779
|
}
|
|
19739
19780
|
var BLOCKED_SUBJECT = {
|
|
19740
19781
|
shell: (resource) => resource === "*" ? "running commands" : `the command \`${resource}\``,
|
|
19741
19782
|
edit: () => "editing files",
|
|
19783
|
+
external_directory: (resource) => resource === "*" ? "folders outside the workspace" : `the folder ${resource}`,
|
|
19784
|
+
computer: () => "using apps on this computer",
|
|
19785
|
+
script: () => "running app scripts",
|
|
19742
19786
|
webfetch: (resource) => resource === "*" ? "opening websites" : `opening ${resource}`,
|
|
19787
|
+
browser_upload: (resource) => resource === "*" ? "uploading files to websites" : `uploading files to ${resource}`,
|
|
19743
19788
|
websearch: () => "searching the web",
|
|
19744
19789
|
skill: (resource) => resource === "*" ? "local skills" : `the local skill "${resource}"`,
|
|
19745
19790
|
mcp: (resource) => resource === "*" ? "local MCP servers" : `the local MCP server "${resource}"`
|
|
@@ -19793,15 +19838,41 @@ function agentPermissionEngineMcpDenial(rules, name, server, organizationMcp) {
|
|
|
19793
19838
|
return null;
|
|
19794
19839
|
return agentPermissionDenial(rules, "mcp", [name]);
|
|
19795
19840
|
}
|
|
19796
|
-
var V2_ACTIONS = ["shell", "edit", "webfetch", "websearch", "skill"];
|
|
19841
|
+
var V2_ACTIONS = ["shell", "edit", "external_directory", "webfetch", "websearch", "skill"];
|
|
19797
19842
|
function v2Action(action) {
|
|
19798
19843
|
return V2_ACTIONS.find((entry) => entry === action) ?? null;
|
|
19799
19844
|
}
|
|
19800
|
-
|
|
19845
|
+
var V2_TOOL_ACTIONS = {
|
|
19846
|
+
shell: "shell",
|
|
19847
|
+
edit: "edit",
|
|
19848
|
+
write: "edit",
|
|
19849
|
+
patch: "edit",
|
|
19850
|
+
opencode_worktree_remove: "edit",
|
|
19851
|
+
webfetch: "webfetch",
|
|
19852
|
+
websearch: "websearch",
|
|
19853
|
+
skill: "skill"
|
|
19854
|
+
};
|
|
19855
|
+
function agentPermissionEngineV2ToolHidden(rules, tool) {
|
|
19856
|
+
const action = V2_TOOL_ACTIONS[tool];
|
|
19857
|
+
if (!action)
|
|
19858
|
+
return false;
|
|
19859
|
+
for (let index = rules.length - 1;index >= 0; index--) {
|
|
19860
|
+
const rule = rules[index];
|
|
19861
|
+
if (rule?.action !== action)
|
|
19862
|
+
continue;
|
|
19863
|
+
if (rule.effect !== "deny")
|
|
19864
|
+
return false;
|
|
19865
|
+
if (rule.resource === "*")
|
|
19866
|
+
return true;
|
|
19867
|
+
}
|
|
19868
|
+
return false;
|
|
19869
|
+
}
|
|
19870
|
+
function agentPermissionEngineV2Decision(rules, action, resources, engineEffect, commandLine) {
|
|
19801
19871
|
const ourAction = v2Action(action);
|
|
19802
19872
|
if (!ourAction)
|
|
19803
19873
|
return { effect: engineEffect };
|
|
19804
|
-
const
|
|
19874
|
+
const assigned = commandLine !== undefined && resources.every((resource) => commandLine.includes(resource)) ? assignedValues(commandLine) : undefined;
|
|
19875
|
+
const parsed = ourAction === "shell" ? resources.map((resource) => parseShellCommands(resource, assigned)) : [];
|
|
19805
19876
|
const commands = ourAction === "shell" ? parsed.flatMap((entry) => entry.commands) : resources;
|
|
19806
19877
|
const ours = decideAgentPermission(rules, ourAction, commands);
|
|
19807
19878
|
if (ours.effect === "deny" && ours.rule)
|
|
@@ -19954,6 +20025,42 @@ function namesProgramDynamically(command) {
|
|
|
19954
20025
|
const program = /^\S*/.exec(command)?.[0] ?? "";
|
|
19955
20026
|
return program !== "[" && program !== "[[" && /[$`*?[{]/.test(program);
|
|
19956
20027
|
}
|
|
20028
|
+
var LITERAL_ASSIGNMENT = /(?<![^\s;&|(){}`'"])([A-Za-z_][A-Za-z0-9_]*)=((?:[^\s;&|()<>'"`$\\]|'[^']*'|"[^"$`\\]*")+)(?![^\s;&|()<>'"`])/g;
|
|
20029
|
+
var FOR_LOOP = /\bfor\s+([A-Za-z_][A-Za-z0-9_]*)\s+in\s+([^;\n]*)/g;
|
|
20030
|
+
function assignedValues(text) {
|
|
20031
|
+
const values = new Map;
|
|
20032
|
+
const assign = (name, value) => {
|
|
20033
|
+
if (!value || /[$`]/.test(value))
|
|
20034
|
+
return;
|
|
20035
|
+
const known = values.get(name) ?? new Set;
|
|
20036
|
+
values.set(name, known.add(value));
|
|
20037
|
+
};
|
|
20038
|
+
const scanned = text.slice(0, SHELL_PARSE_BUDGET);
|
|
20039
|
+
for (const [, name, value] of scanned.matchAll(LITERAL_ASSIGNMENT))
|
|
20040
|
+
assign(name, shellWords(value).join(" "));
|
|
20041
|
+
for (const [, name, list] of scanned.matchAll(FOR_LOOP)) {
|
|
20042
|
+
const words = shellWords(list);
|
|
20043
|
+
const end = words.indexOf("do");
|
|
20044
|
+
for (const word of end === -1 ? words : words.slice(0, end))
|
|
20045
|
+
assign(name, word);
|
|
20046
|
+
}
|
|
20047
|
+
return values;
|
|
20048
|
+
}
|
|
20049
|
+
var VARIABLE_REFERENCE = /\$(?:\{([A-Za-z_][A-Za-z0-9_]*)(?::?[-=+]([^}]*))?\}|([A-Za-z_][A-Za-z0-9_]*))/g;
|
|
20050
|
+
var RESOLVED_COMMANDS_LIMIT = 32;
|
|
20051
|
+
function resolvedCommands(command, values) {
|
|
20052
|
+
const program = /^\S*/.exec(command)?.[0] ?? "";
|
|
20053
|
+
let resolved = [command];
|
|
20054
|
+
for (const [reference, braced, word, plain] of program.matchAll(VARIABLE_REFERENCE)) {
|
|
20055
|
+
const options = new Set(values.get(braced ?? plain));
|
|
20056
|
+
if (word && !/[$`]/.test(word))
|
|
20057
|
+
options.add(word);
|
|
20058
|
+
if (options.size === 0)
|
|
20059
|
+
continue;
|
|
20060
|
+
resolved = resolved.flatMap((entry) => [...options].map((value) => entry.replaceAll(reference, value))).slice(0, RESOLVED_COMMANDS_LIMIT);
|
|
20061
|
+
}
|
|
20062
|
+
return resolved.filter((entry) => entry !== command);
|
|
20063
|
+
}
|
|
19957
20064
|
function interpreterPayloads(command, spend) {
|
|
19958
20065
|
const words = shellWords(command);
|
|
19959
20066
|
const found = [];
|
|
@@ -19978,7 +20085,7 @@ function wrappedCommands(command, spend) {
|
|
|
19978
20085
|
const at = words.findIndex((word) => COMMAND_WRAPPERS.has(programName(word)));
|
|
19979
20086
|
return at === -1 ? [] : commandsFrom(words, at + 1, spend);
|
|
19980
20087
|
}
|
|
19981
|
-
function parseShellCommands(command) {
|
|
20088
|
+
function parseShellCommands(command, assigned = assignedValues(command)) {
|
|
19982
20089
|
const found = new Set;
|
|
19983
20090
|
let unchecked = false;
|
|
19984
20091
|
let budget = SHELL_PARSE_BUDGET;
|
|
@@ -20001,8 +20108,11 @@ function parseShellCommands(command) {
|
|
|
20001
20108
|
const stripped = withoutAssignments(command2);
|
|
20002
20109
|
for (const entry of [candidate, withoutAssignments(candidate), command2, stripped, byProgramName(stripped)])
|
|
20003
20110
|
found.add(entry);
|
|
20004
|
-
if (namesProgramDynamically(stripped))
|
|
20005
|
-
|
|
20111
|
+
if (!namesProgramDynamically(stripped))
|
|
20112
|
+
return;
|
|
20113
|
+
unchecked = true;
|
|
20114
|
+
for (const resolved of resolvedCommands(stripped, assigned))
|
|
20115
|
+
visit2(resolved, depth + 1);
|
|
20006
20116
|
};
|
|
20007
20117
|
add(line);
|
|
20008
20118
|
const unquoted = shellWords(line).join(" ");
|
|
@@ -20022,6 +20132,7 @@ function parseShellCommands(command) {
|
|
|
20022
20132
|
}
|
|
20023
20133
|
|
|
20024
20134
|
// src/opencode-plugins/openwork-agent-permissions-v2.ts
|
|
20135
|
+
var COMMAND_LINES_KEPT = 100;
|
|
20025
20136
|
function strings(value) {
|
|
20026
20137
|
return Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
|
|
20027
20138
|
}
|
|
@@ -20030,8 +20141,24 @@ var openwork_agent_permissions_v2_default = {
|
|
|
20030
20141
|
async setup(context) {
|
|
20031
20142
|
const rules = parseAgentPermissionRules(context.options.rules);
|
|
20032
20143
|
const organizationMcp = parseOrganizationMcpServers(context.options.organizationMcp);
|
|
20144
|
+
const catalog = await context.tool.transform((editor) => {
|
|
20145
|
+
for (const tool of editor.list()) {
|
|
20146
|
+
if (agentPermissionEngineV2ToolHidden(rules, tool.id))
|
|
20147
|
+
editor.remove(tool.id);
|
|
20148
|
+
}
|
|
20149
|
+
});
|
|
20150
|
+
const commandLines = new Map;
|
|
20151
|
+
const lines = await context.tool.hook("execute.before", (event) => {
|
|
20152
|
+
const command = typeof event.input === "object" && event.input !== null ? event.input.command : undefined;
|
|
20153
|
+
if (event.tool !== "shell" || typeof command !== "string")
|
|
20154
|
+
return;
|
|
20155
|
+
commandLines.set(event.id, command);
|
|
20156
|
+
if (commandLines.size > COMMAND_LINES_KEPT)
|
|
20157
|
+
commandLines.delete(commandLines.keys().next().value);
|
|
20158
|
+
});
|
|
20033
20159
|
const permission = await context.permission.hook("evaluate", (event) => {
|
|
20034
|
-
const
|
|
20160
|
+
const line = event.source?.type === "tool" && event.source.id ? commandLines.get(event.source.id) : undefined;
|
|
20161
|
+
const decision = agentPermissionEngineV2Decision(rules, event.action, event.resources, event.effect, line);
|
|
20035
20162
|
event.effect = decision.effect;
|
|
20036
20163
|
if (decision.message)
|
|
20037
20164
|
event.message = decision.message;
|
|
@@ -20056,6 +20183,8 @@ var openwork_agent_permissions_v2_default = {
|
|
|
20056
20183
|
await servers?.dispose();
|
|
20057
20184
|
await explain.dispose();
|
|
20058
20185
|
await permission.dispose();
|
|
20186
|
+
await lines.dispose();
|
|
20187
|
+
await catalog.dispose();
|
|
20059
20188
|
};
|
|
20060
20189
|
}
|
|
20061
20190
|
};
|