@superglue/cli 1.1.27 → 1.1.29

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.
@@ -25,7 +25,7 @@ Read these on demand — they are authoritative for their topic and kept in sync
25
25
  | `sg skill redis` | Redis command syntax, connection URLs, key type handling |
26
26
  | `sg skill sftp-smb` | SFTP, FTP, and SMB operations, file upload/download semantics, path handling |
27
27
  | `sg skill file-handling` | File detection, parsing, `file::` reference syntax, lazy base64 access, transform-produced files |
28
- | `sg skill access-rules` | RBAC roles and binary tool/system allowlists (enterprise only) |
28
+ | `sg skill access-rules` | RBAC roles, resource grants, and tool/system permissions (enterprise only) |
29
29
 
30
30
  ## CRITICAL RULES — READ FIRST
31
31
 
@@ -233,6 +233,7 @@ sg tool save --draft <draftId>
233
233
  sg tool list
234
234
  sg tool find "shopify orders" # keyword search (compact results)
235
235
  sg tool find --id my-tool # exact lookup (full config)
236
+ sg tool find --id my-tool --fields instruction,inputSchema # only selected top-level fields (token-efficient)
236
237
  ```
237
238
 
238
239
  **System commands:**
@@ -394,6 +395,19 @@ sourceData = {
394
395
  }
395
396
  ```
396
397
 
398
+ ### Naming Rules — Avoiding Key Collisions
399
+
400
+ Everything in `sourceData` shares ONE flat namespace, and the runtime does not detect collisions — when two sources use the same key, one silently wins and the tool misbehaves with no error. Prevent collisions at design time:
401
+
402
+ Never use these as payload input keys or step ids:
403
+
404
+ - `__files__`, `currentItem`, `sg_auth_email` — overwritten by the runtime
405
+ - `page`, `offset`, `cursor`, `limit`, `pageSize` — a payload key with one of these names shadows the live pagination counters; paginated steps silently stop advancing past the first page
406
+ - the tool's own step ids — the step result overwrites a same-named payload key for all subsequent steps
407
+ - credential keys available to a step (`<systemId>_<credKey>`, `<systemId>_url`, and any runtime-supplied credential names) — the credential value silently replaces the payload value
408
+
409
+ Safe naming: payload inputs get specific, domain-flavored names (`customerId`, `reportMonth`, `maxResults` — never `page`, `limit`, `cursor`, `data`); step ids are verb-prefixed camelCase (`fetchUsers`) and distinct from every payload key. If the user asks for an input named like a reserved key, use a safe alternative and explain why.
410
+
397
411
  ### Step Result Envelopes
398
412
 
399
413
  **Every** step result is wrapped in `{ currentItem, data, success }`. You MUST account for this when writing data selectors or transforms.
@@ -588,6 +602,7 @@ curl -X POST "https://api.superglue.cloud/v1/hooks/{toolId}?token=$SUPERGLUE_API
588
602
  - **POST for read-only ops** — GraphQL queries via POST should have `modify: false`. Don't rely on HTTP method alone
589
603
  - **Saving without approval** — always present `sg tool run` results and ask before `sg tool save`
590
604
  - **`sg_auth_email` in scheduled runs** — not available in scheduler-triggered executions. Tools using `<<sg_auth_email>>` will fail
605
+ - **Reserved key collisions** — payload inputs or step ids named after reserved/injected keys (see Naming Rules) fail silently with wrong values, never with an error
591
606
 
592
607
  ---
593
608
 
@@ -627,6 +642,7 @@ For protocol-specific error recovery (HTTP, Postgres, MSSQL, Redis, GraphQL, SFT
627
642
  2. Re-run with `--include-step-results` to see the exact envelope shape
628
643
  3. Paginated steps merge into a single `.data` field — do not `.map()` over them
629
644
  4. Verify `sourceData.currentItem` is only referenced inside looping steps (set by the step's own `dataSelector`, not upstream)
645
+ 5. If a step silently received the wrong value (no error thrown) or pagination stopped after one page, check for a key collision between payload inputs, step ids, credential keys, and reserved runtime keys — see Naming Rules. Fix by renaming the input, not by working around it
630
646
 
631
647
  ### Persistent failures
632
648
 
@@ -1,51 +1,73 @@
1
1
  # Access Rules (RBAC)
2
2
 
3
- On superglue, roles define binary tool-level and system-level allowlists. Users can have multiple roles. Roles and access rules are only available on enterprise organizations.
3
+ On superglue, roles define active resource grants for tools and systems. Users can have multiple roles. Roles and access rules are only available on enterprise organizations.
4
4
 
5
5
  ## Data Model
6
6
 
7
7
  ```typescript
8
+ interface ResourceGrant {
9
+ roleId: string;
10
+ resourceRef: "tool:<encodedId>" | "system:<encodedId>" | "tool:*" | "system:*";
11
+ permissions: Array<"viewer" | "editor">;
12
+ source: "access_rule" | "ownership" | "share";
13
+ grantedByUserId?: string;
14
+ revokedAt?: Date;
15
+ revokedByUserId?: string;
16
+ }
17
+
8
18
  interface Role {
9
19
  id: string;
10
20
  name: string;
11
21
  description?: string;
12
- tools: "ALL" | string[];
13
- systems: "ALL" | string[];
22
+ resourceGrants: ResourceGrant[];
14
23
  isBaseRole?: boolean;
15
24
  }
16
25
  ```
17
26
 
18
- Only `"ALL"` means open access. Empty arrays, missing fields, or `null` mean no direct access from that role.
27
+ Only active grants where `revokedAt` is empty contribute to access. `editor` implies `viewer`.
28
+
29
+ ## Resource Refs
30
+
31
+ - `tool:<encodedToolId>` — one specific tool.
32
+ - `system:<encodedSystemId>` — one specific system.
33
+ - `tool:*` — every current and future tool.
34
+ - `system:*` — every current and future system.
19
35
 
20
- ## Tool Permissions
36
+ Resource ids are URL-encoded inside `resourceRef`; use shared helpers rather than hand-building refs.
21
37
 
22
- - `tools: "ALL"` — every tool is allowed, including tools created in the future
23
- - `tools: ["tool-id-1", "tool-id-2"]` — only these specific tools are allowed
24
- - Effective tool visibility also requires access to every system referenced by that tool's request steps
38
+ ## Permissions
25
39
 
26
- ## System Permissions
40
+ - `viewer` — can see and execute/use the resource.
41
+ - `editor` — can mutate/delete/share the resource and includes `viewer`.
27
42
 
28
- - `systems: "ALL"` — every current and future system is allowed
29
- - `systems: ["gmail", "stripe"]` — only these specific systems are allowed
30
- - System access is binary by system ID: listed means allowed, omitted means denied.
43
+ Current configured role access and ownership grants are generally stored as `editor`.
31
44
 
32
- ## Tool/System Entanglement
45
+ ## Grant Sources
33
46
 
34
- A saved tool is effectively visible and runnable only when both are true:
47
+ - `access_rule` — explicit admin/Access Rules edit.
48
+ - `ownership` — authorization projection from the resource creator.
49
+ - `share` — explicit user-to-user sharing through the app/agent sharing flow.
35
50
 
36
- 1. The user has tool access through at least one role.
37
- 2. The user has access to every `systemId` referenced by the tool's request steps.
51
+ Ownership source of truth remains the tool/system row. Ownership grants are a permission projection and should be preserved by ordinary role edits.
38
52
 
39
- When granting a tool, inspect the tool's request-step `systemId` values and grant required systems when the user should be able to see or run the tool.
53
+ ## Visibility and Execution Surfaces
54
+
55
+ - **Tools** — list/detail, agent views, VFS, REST detail, and tool history use tool `viewer`.
56
+ - **Systems** — list/detail, agent views, VFS, docs, credentials, and `sg system call` use system `viewer`.
57
+ - **Execution** — running a tool requires tool `viewer` plus system `viewer` for every referenced system.
58
+ - **Editing** — updating tools/systems requires `editor`.
59
+ - **Runs** — visible only when the user has tool `viewer` and system `viewer` for every captured system.
60
+ - **Schedules** — visibility follows current tool behavior; editing requires tool `editor`.
61
+ - **MCP** — config shows configured tools; runtime registration uses tool `viewer`, and execution still checks referenced systems.
40
62
 
41
63
  ## Multi-Role Semantics
42
64
 
43
65
  Users can have multiple roles. Resolution is union:
44
66
 
45
- | Layer | Semantics |
46
- | ------- | ----------------------------------------------------- |
47
- | Tools | If any role allows a tool, the tool ID is allowed |
48
- | Systems | If any role allows a system, the system ID is allowed |
67
+ | Layer | Semantics |
68
+ | ------- | -------------------------------------------------------------------------- |
69
+ | Tools | If any active grant targets a tool, that grant's permission is effective |
70
+ | Systems | If any active grant targets a system, that grant's permission is effective |
49
71
 
50
72
  Assigned roles can add access but cannot remove access granted by another role.
51
73
 
@@ -53,25 +75,37 @@ Assigned roles can add access but cannot remove access granted by another role.
53
75
 
54
76
  Every user has exactly one base role:
55
77
 
56
- - **`admin`** — full access to everything. The admin role is immutable.
57
- - **`member`** — default for org team members. Starts with `tools: "ALL"`, `systems: "ALL"`. Tool and system allowlists can be narrowed. Name and description cannot be changed. Cannot be deleted.
78
+ - **`admin`** — full access to everything. The admin role is immutable and has wildcard `editor` grants.
79
+ - **`member`** — default for org team members. New organizations seed it with wildcard `editor` grants for tools and systems. Access-rule grants can be narrowed. Name and description cannot be changed. Cannot be deleted.
58
80
 
59
81
  Users can also have additional custom roles on top of their base role. Custom roles are fully editable and can be created/deleted.
60
82
 
61
83
  ## Personal Roles
62
84
 
63
- Admins can create a personal role for a specific user. A personal role is a per-user override that grants individual tool and system access independent of shared roles.
85
+ Personal roles are per-user containers for ownership, share, and explicit access-rule grants.
64
86
 
65
87
  - Each user can have at most one personal role.
66
- - Personal roles use the same `tools` and `systems` allowlist structure.
67
- - Personal role allowlists are unioned with the user's other roles.
68
- - Managed via the Personal Roles tab in Access Rules or the REST API (`POST /v1/users/:userId/personal-role`).
88
+ - Ownership grants are added automatically when a user creates a tool or system.
89
+ - Personal role grants are unioned with the user's other roles.
90
+ - Managed via the Personal Roles tab in Access Rules and backend role APIs.
91
+
92
+ ## Sharing Semantics
93
+
94
+ V1 sharing targets organization users only. It does not share directly to base roles or custom roles.
95
+
96
+ - Sharing writes `source: "share"` grants into the target user's personal role.
97
+ - A user can grant only permissions up to their own effective access: viewer can grant viewer, editor can grant viewer or editor.
98
+ - If the target already has the requested permission or stronger from any active grant, sharing is redundant and should be blocked.
99
+ - If the target has viewer access and the acting user can grant editor, sharing can promote the user to editor through the personal `source: "share"` grant.
100
+ - Sharing a tool also grants viewer access to required systems when the recipient lacks system access.
101
+ - Tool sharing is atomic. If any selected user or required system grant cannot be applied, nothing is shared.
102
+ - Normal users cannot unshare in V1. Admin cleanup should use Access Rules/admin grant management.
69
103
 
70
- ## Auto-Append On Resource Creation
104
+ ## Auto-Grant On Resource Creation
71
105
 
72
- When a user creates a new tool or system, the backend automatically adds it to the creator's personal role:
106
+ When a user creates a new tool or system, the backend automatically grants ownership access to the creator's personal role:
73
107
 
74
- - New tool created -> appended to the creator's personal role `tools` list
75
- - New system created -> appended to the creator's personal role `systems` list
108
+ - New tool created -> `ownership` grant on `tool:<toolId>` with `editor`.
109
+ - New system created -> `ownership` grant on `system:<systemId>` with `editor`.
76
110
 
77
111
  This only affects the creator's personal role, not base roles or additional custom roles.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superglue/cli",
3
- "version": "1.1.27",
3
+ "version": "1.1.29",
4
4
  "bin": {
5
5
  "sg": "./dist/cli.js"
6
6
  },
@@ -25,7 +25,7 @@ Read these on demand — they are authoritative for their topic and kept in sync
25
25
  | `sg skill redis` | Redis command syntax, connection URLs, key type handling |
26
26
  | `sg skill sftp-smb` | SFTP, FTP, and SMB operations, file upload/download semantics, path handling |
27
27
  | `sg skill file-handling` | File detection, parsing, `file::` reference syntax, lazy base64 access, transform-produced files |
28
- | `sg skill access-rules` | RBAC roles and binary tool/system allowlists (enterprise only) |
28
+ | `sg skill access-rules` | RBAC roles, resource grants, and tool/system permissions (enterprise only) |
29
29
 
30
30
  ## CRITICAL RULES — READ FIRST
31
31
 
@@ -233,6 +233,7 @@ sg tool save --draft <draftId>
233
233
  sg tool list
234
234
  sg tool find "shopify orders" # keyword search (compact results)
235
235
  sg tool find --id my-tool # exact lookup (full config)
236
+ sg tool find --id my-tool --fields instruction,inputSchema # only selected top-level fields (token-efficient)
236
237
  ```
237
238
 
238
239
  **System commands:**
@@ -394,6 +395,19 @@ sourceData = {
394
395
  }
395
396
  ```
396
397
 
398
+ ### Naming Rules — Avoiding Key Collisions
399
+
400
+ Everything in `sourceData` shares ONE flat namespace, and the runtime does not detect collisions — when two sources use the same key, one silently wins and the tool misbehaves with no error. Prevent collisions at design time:
401
+
402
+ Never use these as payload input keys or step ids:
403
+
404
+ - `__files__`, `currentItem`, `sg_auth_email` — overwritten by the runtime
405
+ - `page`, `offset`, `cursor`, `limit`, `pageSize` — a payload key with one of these names shadows the live pagination counters; paginated steps silently stop advancing past the first page
406
+ - the tool's own step ids — the step result overwrites a same-named payload key for all subsequent steps
407
+ - credential keys available to a step (`<systemId>_<credKey>`, `<systemId>_url`, and any runtime-supplied credential names) — the credential value silently replaces the payload value
408
+
409
+ Safe naming: payload inputs get specific, domain-flavored names (`customerId`, `reportMonth`, `maxResults` — never `page`, `limit`, `cursor`, `data`); step ids are verb-prefixed camelCase (`fetchUsers`) and distinct from every payload key. If the user asks for an input named like a reserved key, use a safe alternative and explain why.
410
+
397
411
  ### Step Result Envelopes
398
412
 
399
413
  **Every** step result is wrapped in `{ currentItem, data, success }`. You MUST account for this when writing data selectors or transforms.
@@ -588,6 +602,7 @@ curl -X POST "https://api.superglue.cloud/v1/hooks/{toolId}?token=$SUPERGLUE_API
588
602
  - **POST for read-only ops** — GraphQL queries via POST should have `modify: false`. Don't rely on HTTP method alone
589
603
  - **Saving without approval** — always present `sg tool run` results and ask before `sg tool save`
590
604
  - **`sg_auth_email` in scheduled runs** — not available in scheduler-triggered executions. Tools using `<<sg_auth_email>>` will fail
605
+ - **Reserved key collisions** — payload inputs or step ids named after reserved/injected keys (see Naming Rules) fail silently with wrong values, never with an error
591
606
 
592
607
  ---
593
608
 
@@ -627,6 +642,7 @@ For protocol-specific error recovery (HTTP, Postgres, MSSQL, Redis, GraphQL, SFT
627
642
  2. Re-run with `--include-step-results` to see the exact envelope shape
628
643
  3. Paginated steps merge into a single `.data` field — do not `.map()` over them
629
644
  4. Verify `sourceData.currentItem` is only referenced inside looping steps (set by the step's own `dataSelector`, not upstream)
645
+ 5. If a step silently received the wrong value (no error thrown) or pagination stopped after one page, check for a key collision between payload inputs, step ids, credential keys, and reserved runtime keys — see Naming Rules. Fix by renaming the input, not by working around it
630
646
 
631
647
  ### Persistent failures
632
648
 
@@ -1,51 +1,73 @@
1
1
  # Access Rules (RBAC)
2
2
 
3
- On superglue, roles define binary tool-level and system-level allowlists. Users can have multiple roles. Roles and access rules are only available on enterprise organizations.
3
+ On superglue, roles define active resource grants for tools and systems. Users can have multiple roles. Roles and access rules are only available on enterprise organizations.
4
4
 
5
5
  ## Data Model
6
6
 
7
7
  ```typescript
8
+ interface ResourceGrant {
9
+ roleId: string;
10
+ resourceRef: "tool:<encodedId>" | "system:<encodedId>" | "tool:*" | "system:*";
11
+ permissions: Array<"viewer" | "editor">;
12
+ source: "access_rule" | "ownership" | "share";
13
+ grantedByUserId?: string;
14
+ revokedAt?: Date;
15
+ revokedByUserId?: string;
16
+ }
17
+
8
18
  interface Role {
9
19
  id: string;
10
20
  name: string;
11
21
  description?: string;
12
- tools: "ALL" | string[];
13
- systems: "ALL" | string[];
22
+ resourceGrants: ResourceGrant[];
14
23
  isBaseRole?: boolean;
15
24
  }
16
25
  ```
17
26
 
18
- Only `"ALL"` means open access. Empty arrays, missing fields, or `null` mean no direct access from that role.
27
+ Only active grants where `revokedAt` is empty contribute to access. `editor` implies `viewer`.
28
+
29
+ ## Resource Refs
30
+
31
+ - `tool:<encodedToolId>` — one specific tool.
32
+ - `system:<encodedSystemId>` — one specific system.
33
+ - `tool:*` — every current and future tool.
34
+ - `system:*` — every current and future system.
19
35
 
20
- ## Tool Permissions
36
+ Resource ids are URL-encoded inside `resourceRef`; use shared helpers rather than hand-building refs.
21
37
 
22
- - `tools: "ALL"` — every tool is allowed, including tools created in the future
23
- - `tools: ["tool-id-1", "tool-id-2"]` — only these specific tools are allowed
24
- - Effective tool visibility also requires access to every system referenced by that tool's request steps
38
+ ## Permissions
25
39
 
26
- ## System Permissions
40
+ - `viewer` — can see and execute/use the resource.
41
+ - `editor` — can mutate/delete/share the resource and includes `viewer`.
27
42
 
28
- - `systems: "ALL"` — every current and future system is allowed
29
- - `systems: ["gmail", "stripe"]` — only these specific systems are allowed
30
- - System access is binary by system ID: listed means allowed, omitted means denied.
43
+ Current configured role access and ownership grants are generally stored as `editor`.
31
44
 
32
- ## Tool/System Entanglement
45
+ ## Grant Sources
33
46
 
34
- A saved tool is effectively visible and runnable only when both are true:
47
+ - `access_rule` — explicit admin/Access Rules edit.
48
+ - `ownership` — authorization projection from the resource creator.
49
+ - `share` — explicit user-to-user sharing through the app/agent sharing flow.
35
50
 
36
- 1. The user has tool access through at least one role.
37
- 2. The user has access to every `systemId` referenced by the tool's request steps.
51
+ Ownership source of truth remains the tool/system row. Ownership grants are a permission projection and should be preserved by ordinary role edits.
38
52
 
39
- When granting a tool, inspect the tool's request-step `systemId` values and grant required systems when the user should be able to see or run the tool.
53
+ ## Visibility and Execution Surfaces
54
+
55
+ - **Tools** — list/detail, agent views, VFS, REST detail, and tool history use tool `viewer`.
56
+ - **Systems** — list/detail, agent views, VFS, docs, credentials, and `sg system call` use system `viewer`.
57
+ - **Execution** — running a tool requires tool `viewer` plus system `viewer` for every referenced system.
58
+ - **Editing** — updating tools/systems requires `editor`.
59
+ - **Runs** — visible only when the user has tool `viewer` and system `viewer` for every captured system.
60
+ - **Schedules** — visibility follows current tool behavior; editing requires tool `editor`.
61
+ - **MCP** — config shows configured tools; runtime registration uses tool `viewer`, and execution still checks referenced systems.
40
62
 
41
63
  ## Multi-Role Semantics
42
64
 
43
65
  Users can have multiple roles. Resolution is union:
44
66
 
45
- | Layer | Semantics |
46
- | ------- | ----------------------------------------------------- |
47
- | Tools | If any role allows a tool, the tool ID is allowed |
48
- | Systems | If any role allows a system, the system ID is allowed |
67
+ | Layer | Semantics |
68
+ | ------- | -------------------------------------------------------------------------- |
69
+ | Tools | If any active grant targets a tool, that grant's permission is effective |
70
+ | Systems | If any active grant targets a system, that grant's permission is effective |
49
71
 
50
72
  Assigned roles can add access but cannot remove access granted by another role.
51
73
 
@@ -53,25 +75,37 @@ Assigned roles can add access but cannot remove access granted by another role.
53
75
 
54
76
  Every user has exactly one base role:
55
77
 
56
- - **`admin`** — full access to everything. The admin role is immutable.
57
- - **`member`** — default for org team members. Starts with `tools: "ALL"`, `systems: "ALL"`. Tool and system allowlists can be narrowed. Name and description cannot be changed. Cannot be deleted.
78
+ - **`admin`** — full access to everything. The admin role is immutable and has wildcard `editor` grants.
79
+ - **`member`** — default for org team members. New organizations seed it with wildcard `editor` grants for tools and systems. Access-rule grants can be narrowed. Name and description cannot be changed. Cannot be deleted.
58
80
 
59
81
  Users can also have additional custom roles on top of their base role. Custom roles are fully editable and can be created/deleted.
60
82
 
61
83
  ## Personal Roles
62
84
 
63
- Admins can create a personal role for a specific user. A personal role is a per-user override that grants individual tool and system access independent of shared roles.
85
+ Personal roles are per-user containers for ownership, share, and explicit access-rule grants.
64
86
 
65
87
  - Each user can have at most one personal role.
66
- - Personal roles use the same `tools` and `systems` allowlist structure.
67
- - Personal role allowlists are unioned with the user's other roles.
68
- - Managed via the Personal Roles tab in Access Rules or the REST API (`POST /v1/users/:userId/personal-role`).
88
+ - Ownership grants are added automatically when a user creates a tool or system.
89
+ - Personal role grants are unioned with the user's other roles.
90
+ - Managed via the Personal Roles tab in Access Rules and backend role APIs.
91
+
92
+ ## Sharing Semantics
93
+
94
+ V1 sharing targets organization users only. It does not share directly to base roles or custom roles.
95
+
96
+ - Sharing writes `source: "share"` grants into the target user's personal role.
97
+ - A user can grant only permissions up to their own effective access: viewer can grant viewer, editor can grant viewer or editor.
98
+ - If the target already has the requested permission or stronger from any active grant, sharing is redundant and should be blocked.
99
+ - If the target has viewer access and the acting user can grant editor, sharing can promote the user to editor through the personal `source: "share"` grant.
100
+ - Sharing a tool also grants viewer access to required systems when the recipient lacks system access.
101
+ - Tool sharing is atomic. If any selected user or required system grant cannot be applied, nothing is shared.
102
+ - Normal users cannot unshare in V1. Admin cleanup should use Access Rules/admin grant management.
69
103
 
70
- ## Auto-Append On Resource Creation
104
+ ## Auto-Grant On Resource Creation
71
105
 
72
- When a user creates a new tool or system, the backend automatically adds it to the creator's personal role:
106
+ When a user creates a new tool or system, the backend automatically grants ownership access to the creator's personal role:
73
107
 
74
- - New tool created -> appended to the creator's personal role `tools` list
75
- - New system created -> appended to the creator's personal role `systems` list
108
+ - New tool created -> `ownership` grant on `tool:<toolId>` with `editor`.
109
+ - New system created -> `ownership` grant on `system:<systemId>` with `editor`.
76
110
 
77
111
  This only affects the creator's personal role, not base roles or additional custom roles.