@parallelworks/ui 0.39.0 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,8 +4,9 @@ export type PermissionMode = (typeof REQUESTABLE_PERMISSION_MODES)[number];
4
4
  export type NamedPermissionMode = (typeof NAMED_PERMISSION_MODES)[number];
5
5
  export declare const DEFAULT_PERMISSION_MODE: PermissionMode;
6
6
  export declare function isNamedPermissionMode(mode: string | undefined): mode is NamedPermissionMode;
7
- /** The daemon clamps a remote request to its owner's remoteMaxPermissionMode,
8
- * so a menu offers only what that machine will honour. */
9
- export declare function permissionModesUpTo(ceiling: string | undefined): PermissionMode[];
10
- export declare function clampPermissionMode(mode: PermissionMode, ceiling: string | undefined): PermissionMode;
7
+ /** The daemon clamps a remote request to its owner's remoteMaxPermissionMode
8
+ * and refuses a mode it does not know, so a menu offers only what that
9
+ * machine will honour. */
10
+ export declare function permissionModesUpTo(ceiling: string | undefined, accepted?: readonly string[] | undefined): PermissionMode[];
11
+ export declare function clampPermissionMode(mode: PermissionMode, ceiling: string | undefined, accepted?: readonly string[] | undefined): PermissionMode;
11
12
  export {};
@@ -17,14 +17,23 @@ var PERMISSION_RANK = {
17
17
  function isNamedPermissionMode(mode) {
18
18
  return NAMED_PERMISSION_MODES.some((m) => m === mode);
19
19
  }
20
- /** The daemon clamps a remote request to its owner's remoteMaxPermissionMode,
21
- * so a menu offers only what that machine will honour. */
22
- function permissionModesUpTo(ceiling) {
20
+ /** What a machine that does not list its modes accepts: it predates auto. */
21
+ var LEGACY_PERMISSION_MODES = [
22
+ "read-only",
23
+ "accept-edits",
24
+ "bypass-permissions",
25
+ "plan"
26
+ ];
27
+ /** The daemon clamps a remote request to its owner's remoteMaxPermissionMode
28
+ * and refuses a mode it does not know, so a menu offers only what that
29
+ * machine will honour. */
30
+ function permissionModesUpTo(ceiling, accepted = void 0) {
23
31
  const max = isNamedPermissionMode(ceiling) ? PERMISSION_RANK[ceiling] : PERMISSION_RANK[DEFAULT_PERMISSION_MODE];
24
- return REQUESTABLE_PERMISSION_MODES.filter((m) => PERMISSION_RANK[m] <= max);
32
+ const known = accepted?.length ? accepted : LEGACY_PERMISSION_MODES;
33
+ return REQUESTABLE_PERMISSION_MODES.filter((m) => PERMISSION_RANK[m] <= max && known.includes(m));
25
34
  }
26
- function clampPermissionMode(mode, ceiling) {
27
- const offered = permissionModesUpTo(ceiling);
35
+ function clampPermissionMode(mode, ceiling, accepted = void 0) {
36
+ const offered = permissionModesUpTo(ceiling, accepted);
28
37
  return offered.includes(mode) ? mode : offered[offered.length - 1] ?? "read-only";
29
38
  }
30
39
  //#endregion
@@ -2,10 +2,12 @@ import { type PermissionMode } from '../../agent/permissions.js';
2
2
  /** What the agent may do, as a toolbar chip: the choices stop at the machine's
3
3
  * ceiling, and a mode set elsewhere (plan, or one past the ceiling) still
4
4
  * shows by name. */
5
- export default function PermissionPicker({ mode, onPick, ceiling, disabled, }: {
5
+ export default function PermissionPicker({ mode, onPick, ceiling, accepted, disabled, }: {
6
6
  mode: string | undefined;
7
7
  onPick: (mode: PermissionMode) => void;
8
8
  /** The machine's remoteMaxPermissionMode; unknown offers the daemon default. */
9
9
  ceiling: string | undefined;
10
+ /** The machine's permissionModes; unknown offers what a machine that predates the list accepts. */
11
+ accepted?: readonly string[] | undefined;
10
12
  disabled?: boolean;
11
13
  }): import("react").JSX.Element;
@@ -13,11 +13,11 @@ var LABEL_KEY = {
13
13
  /** What the agent may do, as a toolbar chip: the choices stop at the machine's
14
14
  * ceiling, and a mode set elsewhere (plan, or one past the ceiling) still
15
15
  * shows by name. */
16
- function PermissionPicker({ mode, onPick, ceiling, disabled = false }) {
16
+ function PermissionPicker({ mode, onPick, ceiling, accepted, disabled = false }) {
17
17
  const t = useChatConfig().strings.permissions;
18
18
  const current = mode ?? "accept-edits";
19
19
  const named = isNamedPermissionMode(current) ? current : void 0;
20
- const options = permissionModesUpTo(ceiling).map((m) => ({
20
+ const options = permissionModesUpTo(ceiling, accepted).map((m) => ({
21
21
  value: m,
22
22
  label: t[LABEL_KEY[m]],
23
23
  description: t[`${LABEL_KEY[m]}Hint`]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parallelworks/ui",
3
- "version": "0.39.0",
3
+ "version": "0.40.0",
4
4
  "description": "React UI components: a theme contract, icons, primitives, lists, forms, a job graph, a code editor, a log viewer, a file explorer and an AI chat, each on its own subpath",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {