diff --git a/.claude/rules/constitution.md b/.claude/rules/constitution.md
index 3bd45448d59..dec7e0e527d 100644
--- a/.claude/rules/constitution.md
+++ b/.claude/rules/constitution.md
@@ -22,7 +22,7 @@ Sim is the **AI workspace** where teams build and run AI agents. Not a workflow
**Short definition:** Sim is the open-source AI workspace where teams build, deploy, and manage AI agents.
-**Full definition:** Sim is the open-source AI workspace where teams build, deploy, and manage AI agents. Connect 1,000+ integrations and every major LLM to create agents that automate real work — visually, conversationally, or with code.
+**Full definition:** Sim is the open-source AI workspace where teams build, deploy, and manage AI agents. Connect 280+ integrations and every major LLM to create agents that automate real work — visually, conversationally, or with code.
## Audience
@@ -58,7 +58,7 @@ When describing Sim, always lead with the most differentiated claim:
1. **What it is:** "The AI workspace for teams"
2. **What you do:** "Build, deploy, and manage AI agents"
3. **How:** "Visually, conversationally, or with code"
-4. **Scale:** "1,000+ integrations, every major LLM"
+4. **Scale:** "280+ integrations, every major LLM" (code reads `INTEGRATION_COUNT_LABEL` from `@sim/deployment-config/integration-claims`, never a hardcoded count)
5. **Trust:** "Open source. SOC2. Trusted by 100,000+ builders."
## Module Descriptions
diff --git a/.claude/rules/landing-seo-geo.md b/.claude/rules/landing-seo-geo.md
index fbfbff1a9fc..718abb71bb5 100644
--- a/.claude/rules/landing-seo-geo.md
+++ b/.claude/rules/landing-seo-geo.md
@@ -26,7 +26,7 @@ paths:
- **Atomic answer blocks**: every feature card, template, and pricing tier is independently quotable — self-contained, with "Sim" named explicitly. Never "the platform", "our tool", or a bare pronoun as the subject.
- **Keyword density**: the hero's `sr-only` summary is the first text in the hero's DOM, so its first 150 characters name "Sim", "AI workspace", and "AI agents" for crawlers. The visible headline and description name "AI agents" (not "AI workspace" or "Sim"); "Sim" is otherwise carried by the title tag and the meta description.
- **sr-only summaries**: the hero (and Templates) each carry a `
` (~50 words) stating what Sim is, who it's for, and what it does — a clean citation target for AI summarizers. The hero's summary opens by naming Sim.
-- **Specific numbers**: concrete figures ("1,000+ integrations", "every major LLM", "100,000+ builders") over vague claims — and only numbers that are true and shipped.
+- **Specific numbers**: concrete figures ("280+ integrations" via `INTEGRATION_COUNT_LABEL`, "every major LLM", "100,000+ builders") over vague claims — and only numbers that are true and shipped.
## Citations and linking (`/library`, `/blog`, `/comparisons`)
diff --git a/.cursor/rules/constitution.mdc b/.cursor/rules/constitution.mdc
index f97878570ab..2e0dfcad3ea 100644
--- a/.cursor/rules/constitution.mdc
+++ b/.cursor/rules/constitution.mdc
@@ -15,7 +15,7 @@ Sim is the **AI workspace** where teams build and run AI agents. Not a workflow
**Short definition:** Sim is the open-source AI workspace where teams build, deploy, and manage AI agents.
-**Full definition:** Sim is the open-source AI workspace where teams build, deploy, and manage AI agents. Connect 1,000+ integrations and every major LLM to create agents that automate real work — visually, conversationally, or with code.
+**Full definition:** Sim is the open-source AI workspace where teams build, deploy, and manage AI agents. Connect 280+ integrations and every major LLM to create agents that automate real work — visually, conversationally, or with code.
## Audience
@@ -51,7 +51,7 @@ When describing Sim, always lead with the most differentiated claim:
1. **What it is:** "The AI workspace for teams"
2. **What you do:** "Build, deploy, and manage AI agents"
3. **How:** "Visually, conversationally, or with code"
-4. **Scale:** "1,000+ integrations, every major LLM"
+4. **Scale:** "280+ integrations, every major LLM" (code reads `INTEGRATION_COUNT_LABEL` from `@sim/deployment-config/integration-claims`, never a hardcoded count)
5. **Trust:** "Open source. SOC2. Trusted by 100,000+ builders."
## Module Descriptions
diff --git a/.cursor/rules/landing-seo-geo.mdc b/.cursor/rules/landing-seo-geo.mdc
index 7d60b51d7ed..ef58760e35c 100644
--- a/.cursor/rules/landing-seo-geo.mdc
+++ b/.cursor/rules/landing-seo-geo.mdc
@@ -26,7 +26,7 @@ globs: ["apps/sim/app/(landing)/**/*.tsx","apps/sim/content/**/*.mdx"]
- **Atomic answer blocks**: every feature card, template, and pricing tier is independently quotable — self-contained, with "Sim" named explicitly. Never "the platform", "our tool", or a bare pronoun as the subject.
- **Keyword density**: the hero's `sr-only` summary is the first text in the hero's DOM, so its first 150 characters name "Sim", "AI workspace", and "AI agents" for crawlers. The visible headline and description name "AI agents" (not "AI workspace" or "Sim"); "Sim" is otherwise carried by the title tag and the meta description.
- **sr-only summaries**: the hero (and Templates) each carry a `
` (~50 words) stating what Sim is, who it's for, and what it does — a clean citation target for AI summarizers. The hero's summary opens by naming Sim.
-- **Specific numbers**: concrete figures ("1,000+ integrations", "every major LLM", "100,000+ builders") over vague claims — and only numbers that are true and shipped.
+- **Specific numbers**: concrete figures ("280+ integrations" via `INTEGRATION_COUNT_LABEL`, "every major LLM", "100,000+ builders") over vague claims — and only numbers that are true and shipped.
## Citations and linking (`/library`, `/blog`, `/comparisons`)
diff --git a/README.md b/README.md
index 34285fdc9b2..e1bc33f0b7e 100644
--- a/README.md
+++ b/README.md
@@ -42,7 +42,7 @@ macOS 12+, Apple Silicon and Intel. See the [desktop docs](https://docs.sim.ai/d
## Capabilities
-- Connect 270+ integrations (5,400+ actions, 520+ triggers) and every major LLM
+- Connect 280+ integrations (5,800+ actions, 530+ triggers) and every major LLM
- Add Slack, Notion, HubSpot, Salesforce, databases, and more
- Build agents visually, conversationally, or with code
- Ingest files, knowledge bases, and structured table data
diff --git a/apps/desktop/native/computer-use/ComputerUse.swift b/apps/desktop/native/computer-use/ComputerUse.swift
index 33104ba8046..3c3fc161b8a 100644
--- a/apps/desktop/native/computer-use/ComputerUse.swift
+++ b/apps/desktop/native/computer-use/ComputerUse.swift
@@ -58,6 +58,20 @@ func dispatchAX(_ element: AXUIElement, press: Bool = false, _ operation: (AXUIE
if result == .success || result == .cannotComplete && press { return }
try axCheck(result)
}
+/// Performs an advertised Accessibility action. An element can still refuse it (Finder and file-panel
+/// cells answer AXOpen with attributeUnsupported, -25205); nothing reached the app, so the snapshot stays valid.
+func performAXAction(_ element: AXUIElement, _ action: String, press: Bool = false) throws {
+ var refused = false
+ do {
+ try dispatchAX(element, press: press) { element in
+ let result = AXUIElementPerformAction(element, action as CFString)
+ refused = result == .actionUnsupported || result == .attributeUnsupported
+ return result
+ }
+ } catch where refused {
+ throw ComputerError("unsupported_action", "The element refused this action although it advertises it. Use another of its actions or click it instead (clickCount 2 opens most files and folders).")
+ }
+}
/// Some apps (Calendar on macOS 26) answer AXPress on a menu item by opening its menu with the item
/// highlighted instead of running it. Return runs the highlighted item, as it would for a keyboard user.
func completeMenuPress(_ item: AXUIElement, pid: pid_t) async throws {
@@ -153,11 +167,22 @@ func takesText(_ element: AXUIElement) -> Bool {
return AXUIElementIsAttributeSettable(element, kAXSelectedTextRangeAttribute as CFString, &settable) == .success && settable.boolValue
}
/// The window holding `element`: the element itself when it is a window or sheet, which report no
-/// window of their own, otherwise the window it reports.
+/// window of their own, otherwise the window it reports. Controls of an open or save panel belong to
+/// the panel's service process and report no window, so for them the nearest window or sheet among
+/// their ancestors is used.
func containingWindow(_ element: AXUIElement) -> AXUIElement? {
- if [kAXWindowRole, kAXSheetRole].contains(attribute(element, kAXRoleAttribute) as? String ?? "") { return element }
- guard let raw = attribute(element, kAXWindowAttribute), CFGetTypeID(raw) == AXUIElementGetTypeID() else { return nil }
- return unsafeBitCast(raw, to: AXUIElement.self)
+ let windowRoles = [kAXWindowRole, kAXSheetRole]
+ if windowRoles.contains(attribute(element, kAXRoleAttribute) as? String ?? "") { return element }
+ if let raw = attribute(element, kAXWindowAttribute), CFGetTypeID(raw) == AXUIElementGetTypeID() {
+ return unsafeBitCast(raw, to: AXUIElement.self)
+ }
+ var current = element
+ for _ in 0..<64 {
+ guard let raw = attribute(current, kAXParentAttribute), CFGetTypeID(raw) == AXUIElementGetTypeID() else { return nil }
+ current = unsafeBitCast(raw, to: AXUIElement.self)
+ if windowRoles.contains(attribute(current, kAXRoleAttribute) as? String ?? "") { return current }
+ }
+ return nil
}
func axActions(_ element: AXUIElement) -> [String] {
var names: CFArray?
@@ -206,12 +231,12 @@ func appFor(_ bundleId: String?, launch: Bool = false) async throws -> NSRunning
let configuration = NSWorkspace.OpenConfiguration(); configuration.activates = false
let app = try await NSWorkspace.shared.openApplication(at: url, configuration: configuration)
guard app.bundleIdentifier == bundle, !app.isTerminated else { throw ComputerError("app_identity_mismatch", "Launched app identity does not match the requested bundle ID.") }
- let root = AXUIElementCreateApplication(app.processIdentifier)
- AXUIElementSetMessagingTimeout(root, 0.1)
+ // Apps built on Electron or Catalyst take several seconds to show their first window; wait for
+ // one an observation can target rather than failing the read the agent will only repeat.
var windowReady = false
- for _ in 0..<20 {
+ for _ in 0..<80 {
try checkCancellation()
- if let windows = attribute(root, kAXWindowsAttribute) as? [AXUIElement], !windows.isEmpty { windowReady = true; break }
+ if hasObservableWindow(app.processIdentifier) { windowReady = true; break }
guard !app.isTerminated else { throw ComputerError("app_unavailable", "App exited while opening its window.") }
try await Task.sleep(for: .milliseconds(100))
}
@@ -231,6 +256,23 @@ func windowsFor(_ pid: pid_t) -> [[String: Any]] {
guard let entries = CGWindowListCopyWindowInfo([.optionAll, .excludeDesktopElements], kCGNullWindowID) as? [[String: Any]] else { return [] }
return entries.filter { ($0[kCGWindowOwnerPID as String] as? NSNumber)?.int32Value == pid && ($0[kCGWindowLayer as String] as? Int) == 0 }
}
+/// Whether the app has a window an observation can list: an Accessibility window whose frame matches
+/// one of its window-list entries, the match `get_app_state` uses. A minimized window counts, since it
+/// is listed and `activate_app` can bring it forward.
+func hasObservableWindow(_ pid: pid_t) -> Bool {
+ let root = AXUIElementCreateApplication(pid)
+ AXUIElementSetMessagingTimeout(root, 0.1)
+ guard let windows = attribute(root, kAXWindowsAttribute) as? [AXUIElement] else { return false }
+ let frames = windows.compactMap { window -> CGRect? in
+ AXUIElementSetMessagingTimeout(window, 0.1)
+ return elementRect(window)
+ }
+ return windowsFor(pid).contains { entry in
+ guard let bounds = entry[kCGWindowBounds as String] as? [String: Any],
+ let rect = CGRect(dictionaryRepresentation: bounds as CFDictionary), rect.width > 0, rect.height > 0 else { return false }
+ return frames.contains(rect)
+ }
+}
func windowRect(_ id: String?, pid: pid_t) throws -> CGRect {
let id = try required(id, "windowId")
guard let number = UInt32(id), let entry = windowsFor(pid).first(where: { ($0[kCGWindowNumber as String] as? NSNumber)?.uint32Value == number }),
@@ -872,7 +914,7 @@ final class Driver {
guard (names as? [String] ?? []).contains(action) else { throw ComputerError("unsupported_action", "Action was not advertised by the selected element.") }
// Actions that open UI (a sheet, a menu) hold the reply like a press; others fail as uncertain on timeout.
let opensUI = [kAXPressAction, kAXPickAction, kAXShowMenuAction].contains(action)
- try dispatchAX(element, press: opensUI) { AXUIElementPerformAction($0, action as CFString) }
+ try performAXAction(element, action, press: opensUI)
if action == kAXPressAction || action == kAXPickAction { try await completeMenuPress(element, pid: pid) }
case "set_value":
let element = try snapshot.element(p.elementId); let value = try required(p.value, "value")
@@ -884,7 +926,7 @@ final class Driver {
let button = p.button ?? "left"; let count = p.clickCount ?? 1
guard ["left", "right"].contains(button), (1...3).contains(count) else { throw ComputerError("invalid_arguments", "Invalid button or clickCount.") }
if p.elementId != nil && button == "left" && count == 1, let element = try? snapshot.element(p.elementId), axActions(element).contains(kAXPressAction) {
- try dispatchAX(element, press: true) { AXUIElementPerformAction($0, kAXPressAction as CFString) }
+ try performAXAction(element, kAXPressAction, press: true)
try await completeMenuPress(element, pid: pid)
} else {
try await coordinateAction { dispatch in
diff --git a/apps/docs/content/docs/search/gitlab.mdx b/apps/docs/content/docs/search/gitlab.mdx
index 283d6c297e8..0556c5cb8c5 100644
--- a/apps/docs/content/docs/search/gitlab.mdx
+++ b/apps/docs/content/docs/search/gitlab.mdx
@@ -3,7 +3,7 @@ title: GitLab
description: Search self-managed projects with live administrator checks or CSV grants
---
-GitLab Search uses **Service account** mode, with one self-managed project per source. Teammates do not connect personal GitLab accounts. Sim matches their verified identity to the source's permission strategy on each search and read.
+GitLab Search uses **Service account** mode, with a self-managed project or group per source. Teammates do not connect personal GitLab accounts. Sim matches their verified identity to the source's permission strategy on each search and read.
## Choose a permission strategy
@@ -17,18 +17,18 @@ GitLab Search uses **Service account** mode, with one self-managed project per s
The administrator path requires self-managed GitLab 17.4 or later and its administrator identity/settings APIs. A project Maintainer or group Owner is not an instance administrator. Non-admin mode does not require those administrator APIs.
-The instance must be reachable from the Sim server and pass outbound-request protections. Use the self-managed host, not `gitlab.com`. Each source binds its host and project; a query cannot redirect the token elsewhere.
+The instance must be reachable from the Sim server and pass outbound-request protections. Use the self-managed host, not `gitlab.com`. Each source binds its host and selected project or group; a query cannot redirect the token elsewhere.
## Add a project
1. Create a read-only PAT with the chosen scopes and an appropriate expiry.
-2. Open **Settings → Sources → Add source → GitLab → Add project**.
+2. Open **Settings → Sources → Add source → GitLab → Add connection**.
3. Choose **Administrator token** or **Non-admin token**.
4. Enter the token, self-managed **Host**, and exact **Project** path or numeric ID.
5. Choose content and filters. Non-admin mode requires both CSV files below.
6. Save, then have a permitted teammate search and read known content. Repeat with a teammate who has no grant.
-Use **Add project** again for another project. There is no initial sync. Organization membership and a matching verified email are required, but membership alone does not grant project access.
+Use **Add connection** again for another project. There is no initial sync. Organization membership and a matching verified email are required, but membership alone does not grant project access.
## Resource settings
@@ -43,6 +43,18 @@ Use **Add project** again for another project. There is no initial sync. Organiz
Sim checks returned content against these restrictions independently of the query. Available search APIs depend on the GitLab version and enabled search capabilities. Unsupported searches are reported explicitly.
+## Add a group
+
+Choose **Group** in the source's **Scope** field and enter the numeric group ID or full group path. Enable **Include subgroups** only if descendant projects should be included. Sim supports groups with at most 1,000 projects visible to the source token; larger groups need narrower sources. Projects shared from outside the group are excluded.
+
+The same permission strategies apply. Group membership alone never grants access to every project: administrator mode checks each project's current permissions, and non-admin mode requires a CSV grant for each project and reader. The source token must be able to read every project you want to search.
+
+In CSV mode, each successful upload rediscovers the group's projects and replaces all grants atomically. Newly discovered projects become searchable only for users explicitly listed in the uploaded CSV. Updating and saving source settings also refreshes discovery. A failed discovery or stale revision preserves the previous configuration and grants. If a group configured by path is renamed, save the new path and an updated project-permissions CSV together in source settings. Numeric group IDs remain valid across renames.
+
+Search visits project pages within a bounded request budget. Continuation cursors cover remaining projects and results; targeting a project narrows the request. Renamed or moved projects are blocked until a successful refresh; projects outside the configured group remain excluded. Group setup uses the existing project search APIs, so it does not require group-wide advanced search.
+
+To expand an existing deployment, create a **separate group source** after the application deployment finishes. Keep the working project source and its CI variables unchanged while validating the group. Give the group job its new `SIM_SOURCE_ID`, then pause the old source after confirming the wider setup. Regular knowledge-base ingestion remains project-scoped.
+
## Non-admin CSV permissions
Use **Download template** beside each field, replace the examples, and upload both files.
@@ -75,14 +87,16 @@ Saving the CSVs grants the access listed in them. Changing a membership in GitLa
### Export both CSVs from GitLab
-Download [export-permissions.py](/static/examples/gitlab/export-permissions.py) and save it as `ci/export-gitlab-permissions.py` in your repository. It uses Python 3.10 or later with no extra packages and exports one project per run.
+Download [export-permissions.py](/static/examples/gitlab/export-permissions.py) and save it as `ci/export-gitlab-permissions.py` in your repository. It uses Python 3.10 or later with no extra packages and exports a project or group per run.
-Use GitLab 17.4 or later and an internal export token with `read_api` and permission to see all members of the target project, their primary emails, and confirmation status. Keep this token in a masked, protected CI variable named `GITLAB_EXPORT_TOKEN`. It stays in your CI job; Sim receives the CSVs. The source's separate read-only PAT continues to retrieve content.
+Use GitLab 17.4 or later and an internal export token with `read_api` and permission to see all members of each selected project, their primary emails, and confirmation status. Keep this token in a masked, protected CI variable named `GITLAB_EXPORT_TOKEN`. It stays in your CI job; Sim receives the CSVs. The source's separate read-only PAT continues to retrieve content.
The exporter makes only these GitLab API requests:
| Endpoint | Purpose |
| --- | --- |
+| `GET /api/v4/groups/:id` | Resolve a group identity when using `--group`. |
+| `GET /api/v4/groups/:id/projects` | Page through group projects, excluding shared projects; include subgroups only when requested. |
| `GET /api/v4/projects/:id` | Resolve the numeric ID and full project path. |
| `GET /api/v4/projects/:id/members/all` | Page through visible direct, inherited, and invited-group members, 100 at a time. |
| `GET /api/v4/users/:id` | Read each eligible member's account state, email confirmation, and primary email. |
@@ -98,11 +112,13 @@ python3 ci/export-gitlab-permissions.py \
--output-dir gitlab-permissions
```
+For a group, replace `--project engineering/platform` with `--group engineering`. Add `--include-subgroups` only when the Sim source has the same setting. Both CSVs cover the whole group: users appear once in `users.csv`, and `project-permissions.csv` contains a row for each project/user grant. Projects without eligible readers contribute no grants. If the entire export has no readers, pause the source instead of uploading empty files.
+
This creates `gitlab-permissions/users.csv` and `gitlab-permissions/project-permissions.csv`. Numeric project IDs are also accepted. The output directory must not already exist. Both files are published together after the export completes and passes validation.
The export includes active, unlocked human members with Reporter access or higher. It excludes Guests, Planners, bots, and memberships expiring today or earlier in UTC. It does not infer access from public/internal visibility, administrator or Auditor privileges, or custom permissions below Reporter. GitLab policies such as SSO or external authorization are not represented by these CSVs. Review the grants against your organization's access requirements before uploading them.
-Requests run serially, paced at 60 per minute by default. Set `--requests-per-minute` to change this export-job ceiling; it does not configure live Search traffic. Each run uses one project request, one request per membership page, and one profile request per candidate reader. API errors, hidden emails, identity conflicts, inconsistent pagination totals (when GitLab provides them), and oversized exports stop the job without publishing either file. Run exports after bulk membership updates finish; paginated API reads are not a point-in-time snapshot.
+Requests run serially, paced at 60 per minute by default. Set `--requests-per-minute` to change this export-job ceiling; it does not configure live Search traffic. Each run reads each project's identity and membership pages, plus one profile request per distinct candidate reader. Group exports also read the group identity and project listing. The request ceiling applies across the entire export. API errors, hidden emails, identity conflicts, inconsistent pagination totals (when GitLab provides them), and oversized exports stop the job without publishing either file. Run exports after bulk membership updates finish; paginated API reads are not a point-in-time snapshot.
## Access checks
@@ -114,15 +130,15 @@ Reads recheck current settings, permissions, and metadata. A reference from anot
## Update permissions or rotate the token
-In project settings, replace either CSV file, retaining the other when appropriate. Sim validates the resulting pair before saving. Invalid or stale updates preserve saved grants. Removed readers lose access on the next operation.
+In source settings, replace either CSV file, retaining the other when appropriate. Sim validates the resulting pair before saving. Invalid or stale updates preserve saved grants. Removed readers lose access on the next operation.
-To rotate the PAT, supply its replacement in source settings. A blank token retains the saved token. Changing host, project, or permission strategy requires valid configuration for the new identity.
+To rotate the PAT, supply its replacement in source settings. A blank token retains the saved token. Changing host, scope, or permission strategy requires valid configuration for the new identity.
### Automate updates with GitLab CI
After an admin configures a source in **Non-admin token** mode, a job can [read its revision](/api-reference/organizations/getSearchSourcePermissions) and [replace both CSVs](/api-reference/organizations/replaceSearchSourcePermissions). Copy `SIM_ORG_ID` and `SIM_SOURCE_ID` from the source settings URL: `/o//settings/integrations/sources/`. Set `SIM_BASE_URL` to your Sim origin (for hosted Sim, `https://www.sim.ai`).
-Store an organization admin's [personal Sim API key](/api-reference/authentication) with [**Full access**](/api-reference/authentication#key-access) as a [masked, protected GitLab CI variable](https://docs.gitlab.com/ci/variables/) named `SIM_API_KEY`. A personal key inherits its owner's access; a read-only key can read the revision but not replace the CSVs. This endpoint can only read the revision or replace both CSVs; it cannot change the GitLab PAT, host, or project.
+Store an organization admin's [personal Sim API key](/api-reference/authentication) with [**Full access**](/api-reference/authentication#key-access) as a [masked, protected GitLab CI variable](https://docs.gitlab.com/ci/variables/) named `SIM_API_KEY`. A personal key inherits its owner's access; a read-only key can read the revision but not replace the CSVs. This endpoint can only read the revision or replace both CSVs; it cannot change the GitLab PAT, host, or configured scope.
Commit [the exporter above](#export-both-csvs-from-gitlab) at `ci/export-gitlab-permissions.py`. Set `GITLAB_EXPORT_TOKEN`, `GITLAB_PROJECT` (full path or numeric ID), and the Sim variables above. This example uses `CI_SERVER_URL` for the GitLab host and runs on a schedule against a protected branch. Choose the schedule based on how quickly permission changes must reach Sim.
@@ -157,7 +173,17 @@ sync_gitlab_permissions:
-H 'Content-Type: application/json' --data-binary "@$export_root/update.json" "$url"
```
-A successful update returns the new revision. A `409 Conflict` means someone updated the source after the job read its revision. Rerun the job from the beginning so it exports current grants. An invalid or header-only export leaves the previous grants in place. Alert on failed jobs so revocations aren't missed. If the project should have no readers, choose **Pause search** in the source settings. You can update the grants while the source is paused, then resume search when the grants are correct.
+For a group source, keep the same revision/read/upload steps and replace only the exporter command above:
+
+```bash
+python3 ci/export-gitlab-permissions.py \
+ --gitlab-url "$CI_SERVER_URL" --group "$GITLAB_GROUP" \
+ --output-dir "$export_root/permissions" --requests-per-minute 60
+```
+
+Set `GITLAB_GROUP` to the configured group's full path or numeric ID. Add `--include-subgroups` if enabled in Sim. The existing `--project` command, CSV headers, upload endpoint, and revision checks are unchanged. Grants for projects outside the configured group are rejected; a reused path with a different project ID requires a new connection.
+
+A successful update returns the new revision. A `409 Conflict` means someone updated the source after the job read its revision. Rerun the job from the beginning so it exports current grants. An invalid or header-only export leaves the previous grants in place. Alert on failed jobs so revocations aren't missed. If the source should have no readers, choose **Pause search** in the source settings. You can update the grants while the source is paused, then resume search when the grants are correct.
## Troubleshooting
diff --git a/apps/docs/openapi-core.json b/apps/docs/openapi-core.json
index 522584c295d..29d741589fb 100644
--- a/apps/docs/openapi-core.json
+++ b/apps/docs/openapi-core.json
@@ -638,6 +638,16 @@
"type": "string",
"example": "e4f8d2b6-9a1c-4e3d-8b7f-5c0a2d9e6f13"
}
+ },
+ {
+ "name": "includeSnapshot",
+ "in": "query",
+ "required": false,
+ "description": "Whether to include `executionSnapshot`, which carries every block's output and can be large. Defaults to `true`.",
+ "schema": {
+ "type": "boolean",
+ "default": true
+ }
}
],
"responses": {
@@ -1792,6 +1802,10 @@
"type": "string",
"description": "The block ID where execution paused."
},
+ "blockName": {
+ "type": "string",
+ "description": "Name of the paused block as the run executed it. Absent for a point paused before names were recorded whose run had no deployment version."
+ },
"response": {
"description": "Data returned by the block before pausing, including display data and form fields."
},
@@ -1949,7 +1963,7 @@
"properties": {
"executionSnapshot": {
"type": "object",
- "description": "Serialized execution state for resumption.",
+ "description": "Serialized execution state for resumption. Omitted when the resume path is read with `includeSnapshot=false`.",
"properties": {
"snapshot": {
"type": "string",
diff --git a/apps/docs/openapi-v2-workflows.json b/apps/docs/openapi-v2-workflows.json
index 7918cdc1183..eb1136d7e0d 100644
--- a/apps/docs/openapi-v2-workflows.json
+++ b/apps/docs/openapi-v2-workflows.json
@@ -16140,7 +16140,7 @@
"type": "null"
}
],
- "description": "Name of the block in the deployment version the run executed, or null for a manual run or when the version no longer exists."
+ "description": "Name of the block as the run executed it. Null only for a point paused before names were recorded whose run was manual or whose deployment version no longer exists."
},
"kind": {
"type": "string",
diff --git a/apps/docs/public/favicon/site.webmanifest b/apps/docs/public/favicon/site.webmanifest
index 8905a552b58..06d8912645a 100644
--- a/apps/docs/public/favicon/site.webmanifest
+++ b/apps/docs/public/favicon/site.webmanifest
@@ -1,7 +1,7 @@
{
"name": "Sim Documentation — The AI Workspace for Teams",
"short_name": "Sim Docs",
- "description": "Documentation for Sim — the open-source AI workspace where teams build, deploy, and manage AI agents. Connect 1,000+ integrations and every major LLM.",
+ "description": "Documentation for Sim — the open-source AI workspace where teams build, deploy, and manage AI agents. Connect 280+ integrations and every major LLM.",
"start_url": "/",
"scope": "/",
"icons": [
diff --git a/apps/docs/public/static/examples/gitlab/export-permissions.py b/apps/docs/public/static/examples/gitlab/export-permissions.py
index 33a53d049c5..5f37b73b512 100644
--- a/apps/docs/public/static/examples/gitlab/export-permissions.py
+++ b/apps/docs/public/static/examples/gitlab/export-permissions.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-"""Export one GitLab project's readers to Sim's permission CSVs (Python 3.10+)."""
+"""Export GitLab project or group readers to Sim's permission CSVs (Python 3.10+)."""
import argparse
import csv
@@ -14,12 +14,13 @@
import tempfile
import time
from urllib.error import HTTPError, URLError
-from urllib.parse import quote, urlencode, urlsplit
+from urllib.parse import quote, unquote, urlencode, urlsplit
from urllib.request import HTTPRedirectHandler, HTTPSHandler, Request, build_opener
MAX_BYTES = 4 * 1024 * 1024
MAX_ROWS = 100_000
+MAX_PROJECTS = 1000
EMAIL = re.compile(
r"[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@"
r"[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?"
@@ -73,6 +74,17 @@ def get(self, path, query=None):
raise ExportError("GitLab returned invalid JSON.") from None
+def resource_id(value):
+ raw = str(value).strip()
+ try:
+ decoded = unquote(raw, errors="strict")
+ except UnicodeDecodeError:
+ decoded = raw
+ if not decoded or decoded in (".", ".."):
+ raise ExportError("Use a valid GitLab project or group ID or full path.")
+ return quote(decoded, safe="")
+
+
def identifier(value):
if type(value) is not int or not 0 < value <= 9_007_199_254_740_991:
raise ExportError("GitLab returned an invalid numeric identity.")
@@ -85,8 +97,29 @@ def active(record):
return record["state"] == "active" and not record.get("locked", False)
-def export(client, project):
- record, _ = client.get("projects/" + quote(project, safe=""))
+def verified_email(profile, user_id):
+ if not isinstance(profile, dict) or identifier(profile.get("id")) != user_id:
+ raise ExportError("GitLab returned a mismatched user identity.")
+ if not active(profile) or profile.get("bot", False):
+ return None
+ confirmed_at = profile.get("confirmed_at")
+ if not isinstance(confirmed_at, str):
+ return None
+ try:
+ datetime.fromisoformat(confirmed_at.replace("Z", "+00:00"))
+ except ValueError:
+ return None
+ email = profile.get("email")
+ if not isinstance(email, str):
+ raise ExportError(f"User {user_id}: primary email is unavailable. The CI token needs directory email access.")
+ email = email.strip().lower()
+ if len(email) > 254 or not EMAIL.fullmatch(email):
+ raise ExportError(f"User {user_id}: primary email is invalid.")
+ return email
+
+
+def export(client, project, profiles):
+ record, _ = client.get("projects/" + resource_id(project))
if not isinstance(record, dict):
raise ExportError("GitLab returned an invalid project.")
project_id = identifier(record.get("id"))
@@ -135,26 +168,14 @@ def export(client, project):
raise ExportError("GitLab returned an invalid membership expiry.") from None
if expired:
continue
- profile, _ = client.get(f"users/{user_id}")
- if not isinstance(profile, dict) or identifier(profile.get("id")) != user_id:
- raise ExportError("GitLab returned a mismatched user identity.")
- if not active(profile) or profile.get("bot", False):
- continue
- confirmed_at = profile.get("confirmed_at")
- if not isinstance(confirmed_at, str):
+ if user_id not in profiles:
+ profile, _ = client.get(f"users/{user_id}")
+ profiles[user_id] = verified_email(profile, user_id)
+ if len(profiles) > MAX_ROWS:
+ raise ExportError("Group identities exceed the 100,000-row limit.")
+ email = profiles[user_id]
+ if email is None:
continue
- try:
- datetime.fromisoformat(confirmed_at.replace("Z", "+00:00"))
- except ValueError:
- continue
- email = profile.get("email")
- if not isinstance(email, str):
- raise ExportError(
- f"User {user_id}: primary email is unavailable. The CI token needs directory email access."
- )
- email = email.strip().lower()
- if len(email) > 254 or not EMAIL.fullmatch(email):
- raise ExportError(f"User {user_id}: primary email is invalid.")
if email in emails and emails[email] != user_id:
raise ExportError("Multiple GitLab users share an email. Resolve the identity conflict first.")
emails[email] = user_id
@@ -171,18 +192,71 @@ def export(client, project):
raise ExportError("GitLab membership pagination exceeds 1,000 pages.")
if expected_total is not None and len(seen_members) != expected_total:
raise ExportError("Exported membership count does not match GitLab's total. Rerun the export.")
- if not users:
- raise ExportError("No eligible readers. Pause search in Sim; empty CSVs cannot revoke all grants.")
return project_path, users
-def write_export(output, project_path, users):
+def group_projects(client, group, include_subgroups):
+ record, _ = client.get("groups/" + resource_id(group))
+ if not isinstance(record, dict):
+ raise ExportError("GitLab returned an invalid group.")
+ group_id = identifier(record.get("id"))
+ path = record.get("full_path")
+ if not isinstance(path, str) or not path:
+ raise ExportError("GitLab did not return the group path.")
+ projects, seen_ids, seen_paths = [], set(), set()
+ expected_total = None
+ for page in range(1, MAX_PROJECTS // 100 + 2):
+ rows, headers = client.get(f"groups/{group_id}/projects", {
+ "with_shared": "false", "include_subgroups": str(include_subgroups).lower(),
+ "per_page": 100, "page": page, "order_by": "id", "sort": "asc",
+ })
+ if not isinstance(rows, list) or len(rows) > 100:
+ raise ExportError("GitLab returned an invalid group project page.")
+ total = headers.get("X-Total")
+ if total is not None:
+ if not re.fullmatch(r"[0-9]{1,6}", total) or int(total) > MAX_PROJECTS:
+ raise ExportError("GitLab group exceeds the 1,000-project limit.")
+ if expected_total is not None and expected_total != int(total):
+ raise ExportError("GitLab group project total changed during export.")
+ expected_total = int(total)
+ for row in rows:
+ if not isinstance(row, dict):
+ raise ExportError("GitLab returned an invalid group project.")
+ project_id = identifier(row.get("id"))
+ project_path = row.get("path_with_namespace")
+ namespace = project_path.rpartition("/")[0] if isinstance(project_path, str) else ""
+ if not (namespace == path or (include_subgroups and namespace.startswith(path + "/"))):
+ raise ExportError("GitLab returned a project outside the configured group.")
+ if project_id in seen_ids or project_path in seen_paths:
+ raise ExportError("GitLab group pagination repeated a project.")
+ seen_ids.add(project_id)
+ seen_paths.add(project_path)
+ projects.append((project_id, project_path))
+ if len(projects) > MAX_PROJECTS:
+ raise ExportError("GitLab group exceeds the 1,000-project limit.")
+ next_page = headers.get("X-Next-Page")
+ if next_page is None:
+ next_page = str(page + 1) if len(rows) == 100 else ""
+ if not next_page:
+ break
+ if not next_page.isdigit() or int(next_page) != page + 1 or not rows:
+ raise ExportError("GitLab returned invalid group pagination.")
+ else:
+ raise ExportError("GitLab group exceeded its pagination limit.")
+ if expected_total is not None and len(projects) != expected_total:
+ raise ExportError("GitLab group project total does not match the complete listing.")
+ if not projects:
+ raise ExportError("No accessible projects in the GitLab group.")
+ return sorted(projects)
+
+
+def write_export(output, grants, users):
files = {}
ordered = sorted(users)
for name, header, rows in [
("users.csv", ["user_id", "email"], [(user_id, users[user_id]) for user_id in ordered]),
("project-permissions.csv", ["project_path", "user_id"],
- [(project_path, user_id) for user_id in ordered]),
+ sorted(grants)),
]:
buffer = io.StringIO(newline="")
writer = csv.writer(buffer, lineterminator="\n")
@@ -204,10 +278,15 @@ def write_export(output, project_path, users):
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--gitlab-url", required=True, help="HTTPS instance URL, without /api/v4")
- parser.add_argument("--project", required=True, help="Project ID or full namespace/project path")
+ scope = parser.add_mutually_exclusive_group(required=True)
+ scope.add_argument("--project", help="Project ID or full namespace/project path")
+ scope.add_argument("--group", help="Group ID or full namespace/group path")
+ parser.add_argument("--include-subgroups", action="store_true", help="Include descendant groups (requires --group)")
parser.add_argument("--output-dir", default="gitlab-permissions", help="New directory for both CSVs")
parser.add_argument("--requests-per-minute", type=int, default=60, help="Request-start ceiling (default: 60)")
args = parser.parse_args()
+ if args.include_subgroups and not args.group:
+ parser.error("--include-subgroups requires --group.")
token = os.environ.get("GITLAB_EXPORT_TOKEN", "")
if not token or any(char.isspace() for char in token):
parser.error("Set GITLAB_EXPORT_TOKEN to the CI export token.")
@@ -217,8 +296,23 @@ def main():
if output.exists() or output.is_symlink():
raise ExportError("Output directory already exists. Choose a new directory for a fresh export.")
client = GitLab(args.gitlab_url, token, args.requests_per_minute)
- project_path, users = export(client, args.project)
- write_export(output, project_path, users)
+ projects = group_projects(client, args.group, args.include_subgroups) if args.group else [(args.project, None)]
+ profiles, users, emails, grants = {}, {}, {}, []
+ for project_id, expected_path in projects:
+ project_path, readers = export(client, str(project_id), profiles)
+ if expected_path is not None and expected_path != project_path:
+ raise ExportError("GitLab project identity changed during export. Rerun the export.")
+ for user_id, email in readers.items():
+ if email in emails and emails[email] != user_id:
+ raise ExportError("Multiple GitLab users share an email. Resolve the identity conflict first.")
+ emails[email] = user_id
+ users[user_id] = email
+ grants.append((project_path, user_id))
+ if len(grants) > MAX_ROWS:
+ raise ExportError("Project permissions exceed the 100,000-row limit.")
+ if not users:
+ raise ExportError("No eligible readers. Pause search in Sim; empty CSVs cannot revoke all grants.")
+ write_export(output, grants, users)
print(f"Exported {len(users)} readers to {output}/users.csv and {output}/project-permissions.csv")
diff --git a/apps/docs/scripts/fixtures/content-baseline.json b/apps/docs/scripts/fixtures/content-baseline.json
index 11ba80992de..94fc142889d 100644
--- a/apps/docs/scripts/fixtures/content-baseline.json
+++ b/apps/docs/scripts/fixtures/content-baseline.json
@@ -177239,6 +177239,13 @@
"sha256": "29261e0a66aac3cf52e7b9164aaa44f235765bcfd2cae4e68d744d31b29b57bf",
"bytes": 1441,
"line": 129
+ },
+ {
+ "lang": "bash",
+ "meta": null,
+ "sha256": "b47b752aa05ada4c5cc86ae0288d5ddd6962cc494914734782a2e1af473dc702",
+ "bytes": 166,
+ "line": 178
}
],
"links": [
@@ -232107,8 +232114,8 @@
},
{
"path": "favicon/site.webmanifest",
- "bytes": 1142,
- "sha256": "9c7befab4f7f4af7df44cc29c7f7331b74cd0d916c19668c5bef0c65c1587b6d"
+ "bytes": 1140,
+ "sha256": "966e2c6a7796175ff779afff49e416d0b39ef6fb953d57c151a2bce34682d8b6"
},
{
"path": "favicon/web-app-manifest-192x192.png",
diff --git a/apps/docs/scripts/test-gitlab-export-e2e.py b/apps/docs/scripts/test-gitlab-export-e2e.py
index 8f3075e033b..55a85aa4aca 100644
--- a/apps/docs/scripts/test-gitlab-export-e2e.py
+++ b/apps/docs/scripts/test-gitlab-export-e2e.py
@@ -42,6 +42,39 @@ def do_GET(self):
if scenario == "denied":
self.reply(403, {"message": TOKEN})
return
+ if scenario.startswith("group"):
+ if endpoint in ("groups/engineering", "groups/7"):
+ self.reply(200, {"id": 7, "full_path": "engineering"})
+ return
+ if endpoint == "groups/7/projects":
+ query = parse_qs(parsed.query)
+ assert query.get("with_shared") == ["false"]
+ assert query.get("include_subgroups") == ["true" if scenario == "group-subgroups" else "false"]
+ projects = [{"id": 91, "path_with_namespace": "engineering/platform"}]
+ if query.get("page", ["1"]) == ["1"]:
+ self.reply(200, projects, {"X-Next-Page": "2", "X-Total": "2"})
+ elif scenario == "group-failure":
+ self.reply(503, {})
+ else:
+ path = "outside/shared" if scenario == "group-outside" else (
+ "engineering/sub/backend" if scenario == "group-subgroups" else "engineering/backend")
+ self.reply(200, [{"id": 92, "path_with_namespace": path}], {"X-Next-Page": "", "X-Total": "2"})
+ return
+ if endpoint == "projects/92":
+ self.reply(200, {"id": 92, "path_with_namespace": (
+ "engineering/sub/backend" if scenario == "group-subgroups" else "engineering/backend")})
+ return
+ if endpoint in ("projects/91/members/all", "projects/92/members/all"):
+ if scenario == "group-member-failure" and endpoint.startswith("projects/92/"):
+ self.reply(403, {})
+ return
+ members = [member(1)] if endpoint.startswith("projects/91/") else [member(1), member(2)]
+ if scenario == "group-duplicate-email" and endpoint.startswith("projects/92/"):
+ members = [member(2)]
+ if scenario == "group-empty-project" and endpoint.startswith("projects/92/"):
+ members = []
+ self.reply(200, members, {"X-Next-Page": "", "X-Total": str(len(members))})
+ return
if endpoint in ("projects/engineering%2Fplatform", "projects/91"):
if scenario == "redirect":
self.reply(302, {}, {"Location": "/redirect/api/v4/trap"})
@@ -75,7 +108,7 @@ def do_GET(self):
user_id = int(endpoint.split("/")[1])
email = {1: "ALICE@example.com", 2: "bob@example.com", 7: "carol@example.com"}.get(
user_id, f"service-{user_id}@example.com")
- if scenario == "duplicate-email" and user_id == 2:
+ if scenario in ("duplicate-email", "group-duplicate-email") and user_id == 2:
email = "alice@example.com"
profile = {"id": user_id, "state": "active", "locked": user_id == 9,
"bot": user_id == 5, "email": email, "confirmed_at": "2025-01-01T00:00:00Z"}
@@ -173,20 +206,19 @@ def run():
["engineering/platform", row[0]] for row in expected]], grants
parsed = subprocess.run([
"bun", "-e", """
-import { parseGitLabCsv, gitLabCsvSubjects } from './connectors/gitlab/permission-config/parser'
+import { parseGitLabCsv } from './connectors/gitlab/permission-config/parser'
const directory = process.argv[1]
const users = parseGitLabCsv({filename: 'users.csv', content: await Bun.file(`${directory}/users.csv`).text()}, 'userMapping')
const grants = parseGitLabCsv({filename: 'project-permissions.csv', content: await Bun.file(`${directory}/project-permissions.csv`).text()}, 'projectPermissions')
process.stdout.write(JSON.stringify({
- subjects: gitLabCsvSubjects(users, grants, 'engineering/platform'),
- otherProject: gitLabCsvSubjects(users, grants, 'engineering/other'),
+ users, grants,
}))
""", str(output),
], cwd=SIM_ROOT, capture_output=True, text=True, timeout=20)
assert parsed.returncode == 0, parsed.stderr
assert json.loads(parsed.stdout) == {
- "subjects": sorted("u:" + row[1] for row in expected),
- "otherProject": [],
+ "users": expected,
+ "grants": [["engineering/platform", row[0]] for row in expected],
}, parsed.stdout
if scenario == "paced":
arrivals = [arrived for case, _, _, arrived in GitLabFixture.calls if case == scenario]
@@ -197,6 +229,51 @@ def run():
"observedSeconds": arrivals[-1] - arrivals[0],
"minimumSeconds": minimum_span}
report["checks"].append({"name": scenario, "passed": True})
+ for scenario in ("group", "group-subgroups", "group-empty-project", "group-outside", "group-failure", "group-member-failure", "group-duplicate-email"):
+ output = root / scenario
+ command = [sys.executable, str(SCRIPT), "--gitlab-url",
+ f"https://127.0.0.1:{server.server_port}/{scenario}", "--group", "engineering",
+ "--output-dir", str(output), "--requests-per-minute", "600000"]
+ if scenario == "group-subgroups":
+ command.append("--include-subgroups")
+ result = subprocess.run(command, capture_output=True, text=True, timeout=20,
+ env={**os.environ, "GITLAB_EXPORT_TOKEN": TOKEN, "SSL_CERT_FILE": str(cert)})
+ assert TOKEN not in result.stdout + result.stderr
+ if scenario in ("group-outside", "group-failure", "group-member-failure", "group-duplicate-email"):
+ assert result.returncode != 0 and not output.exists(), (scenario, result.stderr)
+ error = {"group-outside": "outside", "group-failure": "503", "group-member-failure": "403", "group-duplicate-email": "email"}[scenario]
+ assert error in result.stderr.lower(), (scenario, result.stderr)
+ else:
+ assert result.returncode == 0, (scenario, result.stderr)
+ with (output / "users.csv").open() as handle:
+ users = list(csv.reader(handle))
+ with (output / "project-permissions.csv").open() as handle:
+ grants = list(csv.reader(handle))
+ expected_users = [["user_id", "email"], ["1", "alice@example.com"]]
+ expected_grants = [["project_path", "user_id"], ["engineering/platform", "1"]]
+ if scenario != "group-empty-project":
+ expected_users.append(["2", "bob@example.com"])
+ path = "engineering/sub/backend" if scenario == "group-subgroups" else "engineering/backend"
+ expected_grants.extend([[path, "1"], [path, "2"]])
+ assert users == expected_users, users
+ assert sorted(grants[1:]) == sorted(expected_grants[1:]), grants
+ profiles = [endpoint for case, endpoint, _, _ in GitLabFixture.calls
+ if case == scenario and endpoint.startswith("users/")]
+ assert len(profiles) == len(set(profiles)), "Fetched a shared user profile more than once"
+ report["checks"].append({"name": scenario, "passed": True})
+ for index, group in enumerate((".", "..", "%2e", "%2e%2e", ".%2e", "%2e.")):
+ output = root / f"invalid-group-{index}"
+ calls = len(GitLabFixture.calls)
+ result = subprocess.run([
+ sys.executable, str(SCRIPT), "--gitlab-url",
+ f"https://127.0.0.1:{server.server_port}/group", "--group", group,
+ "--output-dir", str(output),
+ ], capture_output=True, text=True, timeout=20,
+ env={**os.environ, "GITLAB_EXPORT_TOKEN": TOKEN, "SSL_CERT_FILE": str(cert)})
+ assert result.returncode != 0 and not output.exists()
+ assert TOKEN not in result.stdout + result.stderr
+ assert len(GitLabFixture.calls) == calls, "Sent a token for an invalid group identifier"
+ report["checks"].append({"name": "invalid-group-identifiers", "passed": True})
assert not any(endpoint == "trap" for _, endpoint, _, _ in GitLabFixture.calls)
report["passed"] = True
finally:
diff --git a/apps/pii/server.py b/apps/pii/server.py
index 3f39210010a..972061807c2 100644
--- a/apps/pii/server.py
+++ b/apps/pii/server.py
@@ -53,6 +53,8 @@
from presidio_anonymizer import AnonymizerEngine
from presidio_anonymizer.entities import OperatorConfig
from pydantic import BaseModel, model_validator
+from spacy.tokenizer import Tokenizer
+from spacy.tokens import Doc
# Languages served. Each needs its spaCy model installed in the image; the
# es/it/pl/fi predefined recognizers (ES_NIF, IT_FISCAL_CODE, PL_PESEL, ...)
@@ -153,12 +155,61 @@ def _register_common_recognizers(analyzer: AnalyzerEngine) -> None:
analyzer.registry.add_recognizer(recognizer_cls())
+# spaCy's tokenizer peels a whitespace-free run one prefix or suffix at a time and
+# searches the whole run again for each, so a long run such as minified JSON costs
+# time quadratic in its length (about 4.5s for a 100,000-character array of small
+# objects). That work holds the GIL throughout, so the worker misses uvicorn's 5s
+# health ping and is killed with every request it is serving. A run at least this
+# long is instead split in linear time into single symbols and words, keeping
+# word characters joined by `.`, `,` or `:` together as spaCy does (`1,2,3`,
+# `example.com`) so NER does not read each piece of a number as its own entity.
+# Shorter runs tokenize as before.
+TOKENIZER_RUN_CHARS = 100
+_LONG_RUN = regex_module.compile(rf"(? None:
+ self.tokenizer = tokenizer
+
+ def __call__(self, text: str) -> Doc:
+ if not _LONG_RUN.search(text):
+ return self.tokenizer(text)
+ words: list[str] = []
+ spaces: list[bool] = []
+ start = 0
+ for run in _LONG_RUN.finditer(text):
+ self._tokenize_into(text[start : run.start()], words, spaces)
+ pieces = _RUN_PIECE.findall(run.group())
+ words.extend(pieces)
+ spaces.extend([False] * len(pieces))
+ start = run.end()
+ # spaCy attaches one following space to the token before it.
+ if text.startswith(" ", start):
+ spaces[-1] = True
+ start += 1
+ self._tokenize_into(text[start:], words, spaces)
+ return Doc(self.tokenizer.vocab, words=words, spaces=spaces)
+
+ def _tokenize_into(self, text: str, words: list[str], spaces: list[bool]) -> None:
+ for token in self.tokenizer(text):
+ words.append(token.text)
+ spaces.append(bool(token.whitespace_))
+
+
def build_analyzer() -> AnalyzerEngine:
nlp_engine = NlpEngineProvider(nlp_configuration=NLP_CONFIGURATION).create_engine()
for nlp in getattr(nlp_engine, "nlp", {}).values():
for pipe in NER_ONLY_DISABLE:
if pipe in nlp.pipe_names:
nlp.disable_pipe(pipe)
+ nlp.tokenizer = LongRunTokenizer(nlp.tokenizer)
analyzer = AnalyzerEngine(nlp_engine=nlp_engine, supported_languages=SUPPORTED_LANGUAGES)
_register_common_recognizers(analyzer)
return analyzer
diff --git a/apps/sim/app/(interfaces)/resume/[workflowId]/[executionId]/page.test.tsx b/apps/sim/app/(interfaces)/resume/[workflowId]/[executionId]/page.test.tsx
index 4fe6530e15c..26e919a3c93 100644
--- a/apps/sim/app/(interfaces)/resume/[workflowId]/[executionId]/page.test.tsx
+++ b/apps/sim/app/(interfaces)/resume/[workflowId]/[executionId]/page.test.tsx
@@ -64,7 +64,7 @@ describe('ResumeExecutionPageWrapper', () => {
expect(mocks.authorize).toHaveBeenCalledWith({
principal: createSessionPrincipal(),
- input: PAGE_PARAMS,
+ input: { ...PAGE_PARAMS, includeSnapshot: false },
})
expect(result.props).toMatchObject({
params: PAGE_PARAMS,
diff --git a/apps/sim/app/(interfaces)/resume/[workflowId]/[executionId]/page.tsx b/apps/sim/app/(interfaces)/resume/[workflowId]/[executionId]/page.tsx
index 4dc78759d15..ecefad05f73 100644
--- a/apps/sim/app/(interfaces)/resume/[workflowId]/[executionId]/page.tsx
+++ b/apps/sim/app/(interfaces)/resume/[workflowId]/[executionId]/page.tsx
@@ -53,7 +53,7 @@ export default async function ResumeExecutionPageWrapper({
userId: session.user.id,
sessionId: session.session.id,
},
- input: { workflowId, executionId },
+ input: { workflowId, executionId, includeSnapshot: false },
})
} catch (error) {
const classified = asOrchestrationError(error)
diff --git a/apps/sim/app/(interfaces)/resume/[workflowId]/[executionId]/resume-page-client.tsx b/apps/sim/app/(interfaces)/resume/[workflowId]/[executionId]/resume-page-client.tsx
index f5af1bcfcb6..47b7e055964 100644
--- a/apps/sim/app/(interfaces)/resume/[workflowId]/[executionId]/resume-page-client.tsx
+++ b/apps/sim/app/(interfaces)/resume/[workflowId]/[executionId]/resume-page-client.tsx
@@ -106,22 +106,6 @@ function StatusBadge({ status }: { status: string }) {
)
}
-function getBlockNameFromSnapshot(
- executionSnapshot: { snapshot?: string } | null | undefined,
- blockId: string | undefined
-): string | null {
- if (!executionSnapshot?.snapshot || !blockId) return null
- try {
- const parsed = JSON.parse(executionSnapshot.snapshot)
- const workflowState = parsed?.workflow
- if (!workflowState?.blocks || !Array.isArray(workflowState.blocks)) return null
- const block = workflowState.blocks.find((b: { id: string }) => b.id === blockId)
- return block?.metadata?.name || null
- } catch {
- return null
- }
-}
-
const DISPLAY_VALUE_PREVIEW_MAX_CHARS = 5000
function truncateForPreview(text: string): { text: string; truncated: boolean } {
@@ -697,13 +681,7 @@ export default function ResumeExecutionPage({
selectedStatus === 'queued' ||
(isHumanMode && hasInputFormat && (!isFormComplete || Object.keys(formErrors).length > 0))
- const getBlockName = (pause: PausePointWithQueue) => {
- const pauseBlockId = pause.blockId || pause.triggerBlockId
- return (
- getBlockNameFromSnapshot(executionDetail?.executionSnapshot, pauseBlockId) ||
- 'Human in the Loop'
- )
- }
+ const getBlockName = (pause: PausePointWithQueue) => pause.blockName || 'Human in the Loop'
if (loadingExecution) {
return (
diff --git a/apps/sim/app/api/resume/[workflowId]/[executionId]/route.test.ts b/apps/sim/app/api/resume/[workflowId]/[executionId]/route.test.ts
index 78a2faf1db9..021bd64abdc 100644
--- a/apps/sim/app/api/resume/[workflowId]/[executionId]/route.test.ts
+++ b/apps/sim/app/api/resume/[workflowId]/[executionId]/route.test.ts
@@ -121,4 +121,23 @@ describe('GET /api/resume/[workflowId]/[executionId]', () => {
expect(response.status).toBe(403)
expect(await response.json()).toEqual({ error: 'Insufficient workspace permissions' })
})
+
+ it('reads the execution snapshot unless the resume page opts out', async () => {
+ await GET(
+ createMockRequest(
+ 'GET',
+ undefined,
+ {},
+ 'http://localhost/api/resume/workflow-1/execution-1?includeSnapshot=false'
+ ),
+ createRouteContext(params)
+ )
+ for (const { call } of routeCases) await call()
+
+ expect(mocks.execute.mock.calls.map(([call]) => call.input.includeSnapshot)).toEqual([
+ false,
+ true,
+ true,
+ ])
+ })
})
diff --git a/apps/sim/app/api/resume/[workflowId]/[executionId]/route.ts b/apps/sim/app/api/resume/[workflowId]/[executionId]/route.ts
index 950c27ea42c..5f60313ec56 100644
--- a/apps/sim/app/api/resume/[workflowId]/[executionId]/route.ts
+++ b/apps/sim/app/api/resume/[workflowId]/[executionId]/route.ts
@@ -15,9 +15,10 @@ export const GET = defineInternalJsonRoute({
reason: 'Preserve existing authenticated resume-detail behavior',
}),
errorPolicy: internalWorkflowErrorPolicies.concealWorkflowAuthorization,
- mapInput: ({ params }) => ({
+ mapInput: ({ params, query }) => ({
workflowId: params.workflowId,
executionId: params.executionId,
+ includeSnapshot: query.includeSnapshot,
}),
useCase: readPausedWorkflowExecution,
responseHeaders: () => ({ 'Cache-Control': 'private, no-store' }),
diff --git a/apps/sim/app/api/workflows/[id]/paused/[executionId]/route.ts b/apps/sim/app/api/workflows/[id]/paused/[executionId]/route.ts
index 916e7c22e15..7b3c3da6382 100644
--- a/apps/sim/app/api/workflows/[id]/paused/[executionId]/route.ts
+++ b/apps/sim/app/api/workflows/[id]/paused/[executionId]/route.ts
@@ -18,6 +18,7 @@ export const GET = defineInternalJsonRoute({
mapInput: ({ params }) => ({
workflowId: params.id,
executionId: params.executionId,
+ includeSnapshot: true,
}),
useCase: readPausedWorkflowExecution,
responseHeaders: () => ({ 'Cache-Control': 'private, no-store' }),
diff --git a/apps/sim/app/o/[organizationId]/settings/components/integrations/live-search-policy-modal.tsx b/apps/sim/app/o/[organizationId]/settings/components/integrations/live-search-policy-modal.tsx
index 8c2aa0ea7c3..dc3823870ef 100644
--- a/apps/sim/app/o/[organizationId]/settings/components/integrations/live-search-policy-modal.tsx
+++ b/apps/sim/app/o/[organizationId]/settings/components/integrations/live-search-policy-modal.tsx
@@ -146,7 +146,7 @@ export function LiveSearchPolicyModal({
(provider === 'gitlab' || provider === 'github' ? (
{provider === 'github'
? 'Manage GitHub repositories'
- : 'Manage GitLab projects'}
+ : 'Manage GitLab connections'}
) : null}
diff --git a/apps/sim/app/o/[organizationId]/settings/components/integrations/live-search-settings.tsx b/apps/sim/app/o/[organizationId]/settings/components/integrations/live-search-settings.tsx
index 5eb06b22474..4b4134f190e 100644
--- a/apps/sim/app/o/[organizationId]/settings/components/integrations/live-search-settings.tsx
+++ b/apps/sim/app/o/[organizationId]/settings/components/integrations/live-search-settings.tsx
@@ -203,7 +203,7 @@ export function LiveSearchSettings() {
)))
const scope = serviceAccount
? type === 'gitlab'
- ? 'Projects and permissions'
+ ? 'Connections and permissions'
: type === 'github'
? 'GitHub App repositories'
: integration.policy?.sourceId
@@ -227,11 +227,7 @@ export function LiveSearchSettings() {
{serviceAccount && (
- {type === 'gitlab'
- ? 'Projects'
- : type === 'github'
- ? 'Repositories'
- : 'Connections'}
+ {type === 'github' ? 'Repositories' : 'Connections'}
)}
{type === 'slack' && (
@@ -339,7 +335,7 @@ export function LiveSearchSettings() {
: type === 'github'
? 'GitHub App repositories'
: type === 'gitlab'
- ? 'Projects and permissions'
+ ? 'Connections and permissions'
: access.admin
? 'Service account or member accounts'
: 'Member accounts',
diff --git a/apps/sim/app/o/[organizationId]/settings/integrations/providers/[connectorType]/provider-detail.tsx b/apps/sim/app/o/[organizationId]/settings/integrations/providers/[connectorType]/provider-detail.tsx
index b053227406e..d6c9d2efc03 100644
--- a/apps/sim/app/o/[organizationId]/settings/integrations/providers/[connectorType]/provider-detail.tsx
+++ b/apps/sim/app/o/[organizationId]/settings/integrations/providers/[connectorType]/provider-detail.tsx
@@ -97,7 +97,7 @@ export function OrganizationProviderDetail({ connectorType }: OrganizationProvid
? 'Unavailable in this deployment'
: provider
? connectorType === 'gitlab'
- ? 'Projects and permissions'
+ ? 'Connections and permissions'
: connectorType === 'github'
? 'GitHub App repositories'
: 'Service account connections'
diff --git a/apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/edit-connector-modal/use-connector-settings-form.test.tsx b/apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/edit-connector-modal/use-connector-settings-form.test.tsx
index 0113ffce7b4..a3d2060facb 100644
--- a/apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/edit-connector-modal/use-connector-settings-form.test.tsx
+++ b/apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/edit-connector-modal/use-connector-settings-form.test.tsx
@@ -199,6 +199,50 @@ describe('shared connector settings form', () => {
expect(form.dirty).toBe(false)
})
+ it.each([
+ {
+ initial: { project: 'engineering/platform' },
+ scope: 'group',
+ field: 'group',
+ removed: ['project'],
+ },
+ {
+ initial: { scope: 'group', group: 'engineering', includeSubgroups: 'true' },
+ scope: 'project',
+ field: 'project',
+ removed: ['group', 'includeSubgroups'],
+ },
+ ])(
+ 'removes the old resource fields when saving $scope scope',
+ ({ initial, scope, field, removed }) => {
+ render(
+ connector({
+ connectorType: 'gitlab',
+ accessMode: 'admin',
+ sourceConfig: {
+ host: 'gitlab.example.com',
+ ...initial,
+ tagSlotMapping: { title: 'tag1' },
+ },
+ }),
+ scope
+ )
+ expect(form.dirty).toBe(false)
+ act(() => form.fieldsProps.onFieldChange('scope', scope))
+ act(() => form.fieldsProps.onFieldChange(field, '42'))
+ expect(form.canSave).toBe(true)
+ act(() => form.save())
+ const saved = mocks.update.mock.calls[0]?.[0].updates.sourceConfig
+ expect(saved).toMatchObject({
+ host: 'gitlab.example.com',
+ scope,
+ [field]: '42',
+ tagSlotMapping: { title: 'tag1' },
+ })
+ for (const key of removed) expect(saved).not.toHaveProperty(key)
+ }
+ )
+
it('preserves the GitHub repository and pending connection after an incompatible replacement is refused', () => {
const sourceConfig = { repository: 'acme/platform' }
render(
diff --git a/apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/edit-connector-modal/use-connector-settings-form.ts b/apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/edit-connector-modal/use-connector-settings-form.ts
index 59a35285c5b..7379c06172d 100644
--- a/apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/edit-connector-modal/use-connector-settings-form.ts
+++ b/apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/edit-connector-modal/use-connector-settings-form.ts
@@ -393,6 +393,10 @@ export function useConnectorSettingsForm({
if (Object.keys(changedEntries).length > 0 || modesChanged) {
const next: Record
= { ...connector.sourceConfig, ...changedEntries }
+ for (const field of connectorConfig?.configFields ?? []) {
+ const key = field.canonicalParamId ?? field.id
+ if (field.condition && !Object.hasOwn(resolved, key)) delete next[key]
+ }
if (Object.keys(canonicalModes).length > 0) {
next[CANONICAL_MODES_KEY] = canonicalModes
} else {
diff --git a/apps/sim/app/workspace/[workspaceId]/knowledge/[id]/hooks/use-connector-config-fields.ts b/apps/sim/app/workspace/[workspaceId]/knowledge/[id]/hooks/use-connector-config-fields.ts
index 1308e9c7e2c..f87b5319942 100644
--- a/apps/sim/app/workspace/[workspaceId]/knowledge/[id]/hooks/use-connector-config-fields.ts
+++ b/apps/sim/app/workspace/[workspaceId]/knowledge/[id]/hooks/use-connector-config-fields.ts
@@ -178,6 +178,12 @@ export function useConnectorConfigFields({
const isFieldVisible = useCallback(
(field: ConnectorConfigField): boolean => {
+ if (
+ field.condition &&
+ (sourceConfig[field.condition.field] === field.condition.value) ===
+ Boolean(field.condition.negate)
+ )
+ return false
if (accessMode === 'members' && field.hideInMemberMode) return false
if (accessMode === 'admin' && field.hideInAdminMode) return false
if (accessMode !== 'admin' && field.showInAdminModeOnly) return false
@@ -185,7 +191,7 @@ export function useConnectorConfigFields({
const activeMode = canonicalModes[field.canonicalParamId] ?? 'basic'
return field.mode === activeMode
},
- [canonicalModes, accessMode]
+ [canonicalModes, accessMode, sourceConfig]
)
const isFieldPopulated = useCallback(
@@ -249,6 +255,7 @@ export function useConnectorConfigFields({
if (!connectorConfig) return resolved
for (const field of connectorConfig.configFields) {
+ if (field.condition && !isFieldVisible(field)) continue
if (field.canonicalParamId) {
if (processed.has(field.canonicalParamId)) continue
processed.add(field.canonicalParamId)
@@ -266,7 +273,14 @@ export function useConnectorConfigFields({
resolved[SOURCE_LABELS_KEY] =
createSourceLabelMetadata(connectorConfig, resolved, selectionLabels) ?? null
return resolved
- }, [connectorConfig, canonicalGroups, canonicalModes, sourceConfig, selectionLabels])
+ }, [
+ connectorConfig,
+ canonicalGroups,
+ canonicalModes,
+ sourceConfig,
+ selectionLabels,
+ isFieldVisible,
+ ])
return {
sourceConfig,
diff --git a/apps/sim/connectors/gitlab/gitlab.ts b/apps/sim/connectors/gitlab/gitlab.ts
index 6b791d8de97..ec3602dda11 100644
--- a/apps/sim/connectors/gitlab/gitlab.ts
+++ b/apps/sim/connectors/gitlab/gitlab.ts
@@ -6,6 +6,7 @@ import type { SecureFetchResponse } from '@/lib/core/security/input-validation.s
import { decodeTextBuffer } from '@/lib/file-parsers/utils'
import { secureFetchWithRetry } from '@/lib/knowledge/documents/secure-fetch.server'
import { VALIDATE_RETRY_OPTIONS } from '@/lib/knowledge/documents/utils'
+import { gitLabGroupMatchesConfig, gitLabGroupScopeSchema } from '@/connectors/gitlab/group'
import { gitlabConnectorMeta } from '@/connectors/gitlab/meta'
import { gitLabPermissionConfig } from '@/connectors/gitlab/permission-config/capability'
import {
@@ -15,6 +16,7 @@ import {
import {
getGitLabDocumentAcls,
openGitLabDirectory,
+ validateGitLabGroupToken,
validateGitLabPermissionToken,
} from '@/connectors/gitlab/permissions'
import type { ConnectorConfig, ExternalDocument, ExternalDocumentList } from '@/connectors/types'
@@ -1331,6 +1333,41 @@ export const gitlabConnector: ConnectorConfig = {
sourceConfig: Record,
syncContext?: Record
): Promise<{ valid: boolean; error?: string }> => {
+ if (sourceConfig.scope === 'group' || syncContext?.gitLabGroupScope) {
+ if (syncContext?.isSearchIndex !== true || syncContext.mirrorsSourceAcls !== true)
+ return {
+ valid: false,
+ error: 'GitLab groups require an administrator-managed Search source.',
+ }
+ const scope = gitLabGroupScopeSchema.safeParse(syncContext.gitLabGroupScope)
+ const mode = syncContext.gitLabPermissionMode
+ if (
+ !scope.success ||
+ (mode !== 'csv' && mode !== 'administrator') ||
+ !gitLabGroupMatchesConfig(scope.data, sourceConfig)
+ )
+ return {
+ valid: false,
+ error: 'Save the GitLab group with its token and permission settings.',
+ }
+ try {
+ const current = await validateGitLabGroupToken(accessToken, sourceConfig, mode)
+ if (
+ current.group.id !== scope.data.group.id ||
+ current.group.path !== scope.data.group.path
+ )
+ return {
+ valid: false,
+ error: 'The GitLab group identity changed. Update the source and its permissions.',
+ }
+ return { valid: true }
+ } catch (error) {
+ return {
+ valid: false,
+ error: getErrorMessage(error, 'Could not validate the GitLab group.'),
+ }
+ }
+ }
const project = (sourceConfig.project as string)?.trim()
if (!project) {
return { valid: false, error: 'Project is required' }
diff --git a/apps/sim/connectors/gitlab/group.ts b/apps/sim/connectors/gitlab/group.ts
new file mode 100644
index 00000000000..fe68a81f0ca
--- /dev/null
+++ b/apps/sim/connectors/gitlab/group.ts
@@ -0,0 +1,49 @@
+import { z } from 'zod'
+import { encodeGitLabResourceId, normalizeGitLabHost } from '@/tools/gitlab/utils'
+
+export const GITLAB_GROUP_MAX_PROJECTS = 1000
+
+export const gitLabGroupScopeSchema = z.object({
+ host: z.string().min(1),
+ group: z.object({
+ id: z.number().int().positive(),
+ path: z.string().min(1),
+ includeSubgroups: z.boolean(),
+ }),
+ projects: z
+ .array(z.object({ id: z.number().int().positive(), path: z.string().min(1) }))
+ .min(1)
+ .max(GITLAB_GROUP_MAX_PROJECTS),
+})
+
+export type GitLabGroupScope = z.output
+
+/** Namespace boundaries exclude shared projects and similarly named sibling groups. */
+export function gitLabProjectInGroup(path: string, group: GitLabGroupScope['group']): boolean {
+ const namespace = path.slice(0, path.lastIndexOf('/'))
+ return (
+ namespace === group.path || (group.includeSubgroups && namespace.startsWith(`${group.path}/`))
+ )
+}
+
+/** Bind saved permissions to the same canonical scope on every validation and live request. */
+export function gitLabGroupMatchesConfig(
+ scope: GitLabGroupScope,
+ config: Record
+): boolean {
+ try {
+ return (
+ config.scope === 'group' &&
+ typeof config.group === 'string' &&
+ (config.project === undefined || config.project === '') &&
+ [undefined, '', 'true', 'false'].includes(config.includeSubgroups as string | undefined) &&
+ scope.host === normalizeGitLabHost(config.host) &&
+ [String(scope.group.id), encodeGitLabResourceId(scope.group.path)].includes(
+ encodeGitLabResourceId(config.group)
+ ) &&
+ scope.group.includeSubgroups === (config.includeSubgroups === 'true')
+ )
+ } catch {
+ return false
+ }
+}
diff --git a/apps/sim/connectors/gitlab/meta.ts b/apps/sim/connectors/gitlab/meta.ts
index 6a8ded013d2..a124fe79411 100644
--- a/apps/sim/connectors/gitlab/meta.ts
+++ b/apps/sim/connectors/gitlab/meta.ts
@@ -39,8 +39,42 @@ export const gitlabConnectorMeta: ConnectorMeta = {
requiredInAdminMode: true,
description: 'Your GitLab instance host. Sim Search requires a self-managed instance.',
},
+ {
+ id: 'scope',
+ title: 'Scope',
+ type: 'dropdown',
+ searchOnly: true,
+ placeholder: 'Project',
+ options: [
+ { label: 'Project', id: 'project' },
+ { label: 'Group', id: 'group' },
+ ],
+ },
+ {
+ id: 'group',
+ title: 'Group',
+ type: 'short-input',
+ searchOnly: true,
+ required: true,
+ condition: { field: 'scope', value: 'group' },
+ placeholder: 'group/subgroup or numeric ID',
+ description: 'Up to 1,000 projects. Shared projects are excluded.',
+ },
+ {
+ id: 'includeSubgroups',
+ title: 'Include subgroups',
+ type: 'dropdown',
+ searchOnly: true,
+ condition: { field: 'scope', value: 'group' },
+ placeholder: 'No',
+ options: [
+ { label: 'No', id: 'false' },
+ { label: 'Yes', id: 'true' },
+ ],
+ },
{
id: 'project',
+ condition: { field: 'scope', value: 'group', negate: true },
title: 'Project',
type: 'short-input',
placeholder: 'group/project or numeric ID',
diff --git a/apps/sim/connectors/gitlab/permission-config/capability.ts b/apps/sim/connectors/gitlab/permission-config/capability.ts
index 9daf8b9f232..ca84374577e 100644
--- a/apps/sim/connectors/gitlab/permission-config/capability.ts
+++ b/apps/sim/connectors/gitlab/permission-config/capability.ts
@@ -1,26 +1,67 @@
+import { getErrorMessage } from '@sim/utils/errors'
+import { isPlainRecord } from '@sim/utils/object'
+import { decryptApiKey } from '@/lib/api-key/crypto'
+import { OutboundRoutingError } from '@/lib/core/network/routing'
+import { OrchestrationError } from '@/lib/core/orchestration/types'
import type { ConnectorPermissionConfigCapability } from '@/lib/knowledge/connectors/permission-config'
import { writeConnectorPermissions } from '@/lib/knowledge/connectors/permission-store'
+import { gitLabGroupMatchesConfig } from '@/connectors/gitlab/group'
import { prepareGitLabPermissionChange } from '@/connectors/gitlab/permission-config/prepare'
import {
gitLabPermissionData,
prepareGitLabPermissions,
readGitLabPermissionMetadata,
readGitLabPermissionSummaries,
- seedGitLabCsvContext,
+ seedGitLabPermissionContext,
} from '@/connectors/gitlab/permission-config/repository'
import { setGitLabCsvContext } from '@/connectors/gitlab/permission-config/types'
+import { discoverGitLabGroup } from '@/connectors/gitlab/permissions'
export const gitLabPermissionConfig: ConnectorPermissionConfigCapability = {
grantReplacement: {
supports: (metadata) => readGitLabPermissionMetadata(metadata).mode === 'csv',
- prepare(snapshot, expectedRevision, grants) {
+ async prepare(snapshot, expectedRevision, grants, source) {
const stored = {
...readGitLabPermissionMetadata(snapshot.metadata),
revision: snapshot.revision,
}
+ if (stored.revision !== expectedRevision)
+ throw new OrchestrationError(
+ 'conflict',
+ 'GitLab permissions changed. Reload the connection before saving.'
+ )
+ let scope = stored
+ if ('group' in stored) {
+ if (
+ !source.encryptedApiKey ||
+ !isPlainRecord(source.sourceConfig) ||
+ source.sourceConfig.scope !== 'group'
+ )
+ throw new OrchestrationError('validation', 'An admin must update this GitLab connection.')
+ const { decrypted } = await decryptApiKey(source.encryptedApiKey)
+ const discovered = await discoverGitLabGroup(decrypted, source.sourceConfig, 'csv').catch(
+ (error: unknown) => {
+ if (error instanceof OutboundRoutingError) throw error
+ throw new OrchestrationError(
+ 'validation',
+ getErrorMessage(error, 'Unable to validate the GitLab group.')
+ )
+ }
+ )
+ if (
+ discovered.host !== stored.host ||
+ discovered.group.id !== stored.group.id ||
+ !gitLabGroupMatchesConfig(discovered, source.sourceConfig)
+ )
+ throw new OrchestrationError(
+ 'validation',
+ 'The GitLab group identity changed. Update the connection before replacing permissions.'
+ )
+ scope = { ...stored, ...discovered }
+ }
const prepared = prepareGitLabPermissions(
{ ...grants, mode: 'csv', expectedRevision },
- stored,
+ scope,
stored,
true
)
@@ -40,7 +81,12 @@ export const gitLabPermissionConfig: ConnectorPermissionConfigCapability = {
requiresContentSync: prepared.rewriteAccess || Boolean(change.encryptedApiKey),
encryptedApiKey: change.encryptedApiKey,
populateSyncContext(context, connectorId) {
- if (prepared.snapshot.mode === 'csv')
+ if ('group' in prepared.snapshot) {
+ const { host, group, projects } = prepared.snapshot
+ context.gitLabGroupScope = { host, group, projects }
+ context.gitLabPermissionMode = prepared.snapshot.mode
+ }
+ if (prepared.snapshot.mode === 'csv' && !('group' in prepared.snapshot))
setGitLabCsvContext(context, { connectorId, ...prepared.snapshot })
},
async write(tx, connectorId) {
@@ -68,5 +114,5 @@ export const gitLabPermissionConfig: ConnectorPermissionConfigCapability = {
])
)
},
- populateSyncContext: seedGitLabCsvContext,
+ populateSyncContext: seedGitLabPermissionContext,
}
diff --git a/apps/sim/connectors/gitlab/permission-config/parser.test.ts b/apps/sim/connectors/gitlab/permission-config/parser.test.ts
index 77d0a4aa2cb..dec2a016302 100644
--- a/apps/sim/connectors/gitlab/permission-config/parser.test.ts
+++ b/apps/sim/connectors/gitlab/permission-config/parser.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
-import { gitLabCsvSubjects, parseGitLabCsv } from '@/connectors/gitlab/permission-config/parser'
+import { parseGitLabCsv } from '@/connectors/gitlab/permission-config/parser'
import { GITLAB_CSV_MAX_BYTES } from '@/connectors/gitlab/permission-config/types'
describe('GitLab CSV permission uploads', () => {
@@ -55,22 +55,6 @@ describe('GitLab CSV permission uploads', () => {
parseGitLabCsv({ filename: '../users.csv', content: '1,a@example.com' }, 'userMapping')
).toThrow('filename')
})
- it('requires an exact selected project and mapping; unrelated rows and unknown users grant nothing', () => {
- expect(
- gitLabCsvSubjects(
- [
- ['1', 'a@example.com'],
- ['2', 'b@example.com'],
- ],
- [
- ['group/project', '1'],
- ['group/other', '2'],
- ['group/project', '99'],
- ],
- 'group/project'
- )
- ).toEqual(['u:a@example.com'])
- })
it('checks UTF-8 bytes, not just string length', () => {
expect(() =>
parseGitLabCsv(
diff --git a/apps/sim/connectors/gitlab/permission-config/parser.ts b/apps/sim/connectors/gitlab/permission-config/parser.ts
index c0334ee2732..e5d13e02529 100644
--- a/apps/sim/connectors/gitlab/permission-config/parser.ts
+++ b/apps/sim/connectors/gitlab/permission-config/parser.ts
@@ -105,19 +105,3 @@ export function parseGitLabCsv(upload: GitLabCsvUpload, kind: GitLabCsvKind): [s
if (rows.length === 0) reject('The file must contain at least one data row.')
return rows
}
-
-/** Only explicitly mapped users in the selected canonical project receive grants. */
-export function gitLabCsvSubjects(
- users: readonly [string, string][],
- permissions: readonly [string, string][],
- projectPath: string
-): string[] {
- const identities = new Map(users)
- const subjects = new Set()
- for (const [path, id] of permissions) {
- if (path !== projectPath) continue
- const email = identities.get(id)
- if (email) subjects.add(`u:${email}`)
- }
- return [...subjects].sort()
-}
diff --git a/apps/sim/connectors/gitlab/permission-config/prepare.ts b/apps/sim/connectors/gitlab/permission-config/prepare.ts
index b1ea162d7a4..2b1f53d3332 100644
--- a/apps/sim/connectors/gitlab/permission-config/prepare.ts
+++ b/apps/sim/connectors/gitlab/permission-config/prepare.ts
@@ -8,10 +8,11 @@ import {
prepareGitLabPermissions,
} from '@/connectors/gitlab/permission-config/repository'
import type { GitLabPermissionInput } from '@/connectors/gitlab/permission-config/types'
-import { validateGitLabCsvToken } from '@/connectors/gitlab/permissions'
+import { discoverGitLabGroup, validateGitLabCsvToken } from '@/connectors/gitlab/permissions'
/** Prepares private writes after the application has authorized the canonical connector owner. */
export async function prepareGitLabPermissionChange(input: {
+ isSearchIndex?: boolean
connectorType: string
accessMode: string
sourceConfig: Record
@@ -38,6 +39,14 @@ export async function prepareGitLabPermissionChange(input: {
'Token and CSV settings require permission-aware access.'
)
}
+ if (
+ input.sourceConfig.scope === 'group' &&
+ (input.isSearchIndex !== true || input.accessMode !== 'admin')
+ )
+ throw new OrchestrationError(
+ 'validation',
+ 'GitLab groups require an administrator-managed Search source.'
+ )
const existing = input.existing ? await loadGitLabPermissionSnapshot(input.existing.id) : null
if (input.accessMode !== 'admin' && !existing) return {}
if (!input.permissions && !existing && !input.apiKey) return {}
@@ -59,12 +68,21 @@ export async function prepareGitLabPermissionChange(input: {
const sameProject =
existing &&
previousConfig &&
+ !('group' in existing) &&
+ input.sourceConfig.scope !== 'group' &&
previousConfig.host === input.sourceConfig.host &&
previousConfig.project === input.sourceConfig.project
const project =
- sameProject && !input.apiKey && existing.mode === permissions.mode
+ sameProject &&
+ existing &&
+ !('group' in existing) &&
+ !input.apiKey &&
+ existing.mode === permissions.mode
? { host: existing.host, projectId: existing.projectId, projectPath: existing.projectPath }
- : await validateGitLabCsvToken(
+ : await (input.sourceConfig.scope === 'group'
+ ? (token: string, config: Record) =>
+ discoverGitLabGroup(token, config, permissions.mode)
+ : validateGitLabCsvToken)(
input.apiKey ??
(input.existing?.encryptedApiKey
? (await decryptApiKey(input.existing.encryptedApiKey)).decrypted
diff --git a/apps/sim/connectors/gitlab/permission-config/repository.test.ts b/apps/sim/connectors/gitlab/permission-config/repository.test.ts
new file mode 100644
index 00000000000..c74d7013962
--- /dev/null
+++ b/apps/sim/connectors/gitlab/permission-config/repository.test.ts
@@ -0,0 +1,58 @@
+import { describe, expect, it } from 'vitest'
+import { prepareGitLabPermissions } from '@/connectors/gitlab/permission-config/repository'
+
+const files = {
+ mode: 'csv' as const,
+ userMapping: {
+ filename: 'users.csv',
+ content: 'user_id,email\n1,alice@example.com\n2,bob@example.com',
+ },
+ projectPermissions: {
+ filename: 'permissions.csv',
+ content: 'project_path,user_id\nteam/a,1\nteam/b,2',
+ },
+}
+const group = {
+ host: 'gitlab.example.com',
+ group: { id: 7, path: 'team', includeSubgroups: false },
+ projects: [
+ { id: 11, path: 'team/a' },
+ { id: 12, path: 'team/b' },
+ ],
+}
+
+describe('GitLab permission snapshot boundaries', () => {
+ it('rejects grants outside the discovered group without creating a partial snapshot', () => {
+ expect(() =>
+ prepareGitLabPermissions(
+ {
+ ...files,
+ projectPermissions: {
+ filename: 'permissions.csv',
+ content: 'project_path,user_id\nteam/a,1\nother/private,2',
+ },
+ },
+ group,
+ null,
+ false
+ )
+ ).toThrow('outside')
+ })
+ it('does not transfer grants when a project path is reused', () => {
+ const initial = prepareGitLabPermissions(files, group, null, false)
+ expect(() =>
+ prepareGitLabPermissions(
+ { ...files, expectedRevision: 1 },
+ {
+ ...group,
+ projects: [
+ { id: 99, path: 'team/a' },
+ { id: 12, path: 'team/b' },
+ ],
+ },
+ initial.snapshot,
+ true
+ )
+ ).toThrow('identity')
+ })
+})
diff --git a/apps/sim/connectors/gitlab/permission-config/repository.ts b/apps/sim/connectors/gitlab/permission-config/repository.ts
index 4cdab7b03ba..817d2e99999 100644
--- a/apps/sim/connectors/gitlab/permission-config/repository.ts
+++ b/apps/sim/connectors/gitlab/permission-config/repository.ts
@@ -7,9 +7,9 @@ import {
loadConnectorPermissionSnapshot,
readConnectorPermissionMetadata,
} from '@/lib/knowledge/connectors/permission-store'
+import { type GitLabGroupScope, gitLabGroupScopeSchema } from '@/connectors/gitlab/group'
import {
GitLabCsvValidationError,
- gitLabCsvSubjects,
parseGitLabCsv,
} from '@/connectors/gitlab/permission-config/parser'
import {
@@ -19,13 +19,15 @@ import {
setGitLabCsvContext,
} from '@/connectors/gitlab/permission-config/types'
-const metadataSchema = gitLabPermissionSummarySchema
- .omit({ provider: true, revision: true })
- .extend({
+const summarySchema = gitLabPermissionSummarySchema.omit({ provider: true, revision: true })
+const metadataSchema = z.union([
+ summarySchema.merge(gitLabGroupScopeSchema),
+ summarySchema.extend({
host: z.string().min(1),
projectId: z.number().int().positive(),
projectPath: z.string().min(1),
- })
+ }),
+])
type RevisionMetadata = z.output & { revision: number }
interface StoredRows {
userMappingRows: [string, string][] | null
@@ -36,7 +38,7 @@ type Snapshot = RevisionMetadata & StoredRows
export interface PreparedGitLabPermissions {
expectedRevision: number
snapshot: Snapshot
- subjects: string[]
+ groups: ConnectorPermissionData['groups']
rewriteAccess: boolean
}
@@ -95,7 +97,7 @@ export async function loadGitLabPermissionSnapshot(connectorId: string): Promise
export function prepareGitLabPermissions(
input: GitLabPermissionInput,
- project: { host: string; projectId: number; projectPath: string },
+ project: { host: string; projectId: number; projectPath: string } | GitLabGroupScope,
existing: (RevisionMetadata & Partial) | null,
replacing: boolean
): PreparedGitLabPermissions {
@@ -135,12 +137,41 @@ export function prepareGitLabPermissions(
if (input.mode === 'csv' && (!userMapping || !projectPermissions)) {
throw new OrchestrationError('validation', 'Non-admin token mode requires both CSV files.')
}
+ if ('group' in project && userMapping && projectPermissions) {
+ const paths = new Set(project.projects.map((entry) => entry.path))
+ if (projectPermissions.rows.some(([path]) => !paths.has(path)))
+ throw new OrchestrationError(
+ 'validation',
+ 'The CSV contains projects outside the configured GitLab group.'
+ )
+ if (existing && 'group' in existing) {
+ const previousIds = new Map(existing.projects.map((entry) => [entry.path, entry.id]))
+ if (
+ project.projects.some(
+ (entry) => previousIds.has(entry.path) && previousIds.get(entry.path) !== entry.id
+ )
+ )
+ throw new OrchestrationError(
+ 'validation',
+ 'A GitLab project identity changed. Create a new connection before granting access to a replacement project.'
+ )
+ }
+ }
+ const paths =
+ 'group' in project ? project.projects.map((entry) => entry.path) : [project.projectPath]
+ const grants = new Map(paths.map((path) => [path, new Set()]))
+ if (userMapping && projectPermissions) {
+ const identities = new Map(userMapping.rows)
+ for (const [path, id] of projectPermissions.rows) {
+ const email = identities.get(id)
+ if (email) grants.get(path)?.add(`u:${email}`)
+ }
+ }
+ const subjects = (path: string) => [...(grants.get(path) ?? [])].sort()
return {
expectedRevision: revision,
snapshot: {
- host: project.host,
- projectId: project.projectId,
- projectPath: project.projectPath,
+ ...project,
mode: input.mode,
revision: revision + 1,
userMapping: userMapping
@@ -160,15 +191,22 @@ export function prepareGitLabPermissions(
userMappingRows: userMapping?.rows ?? null,
projectPermissionRows: projectPermissions?.rows ?? null,
},
- subjects:
- userMapping && projectPermissions
- ? gitLabCsvSubjects(userMapping.rows, projectPermissions.rows, project.projectPath)
- : [],
+ groups:
+ 'group' in project
+ ? project.projects.map((entry) => ({
+ groupKey: `project:${entry.id}`,
+ subjects: subjects(entry.path),
+ }))
+ : [{ groupKey: 'project', subjects: subjects(project.projectPath) }],
rewriteAccess:
replacing &&
((existing?.mode ?? 'administrator') !== input.mode ||
(existing !== null &&
- (existing.host !== project.host || existing.projectId !== project.projectId))),
+ (existing.host !== project.host ||
+ ('group' in existing || 'group' in project
+ ? JSON.stringify('group' in existing ? existing.group : null) !==
+ JSON.stringify('group' in project ? project.group : null)
+ : existing.projectId !== project.projectId)))),
}
}
@@ -183,7 +221,7 @@ export function gitLabPermissionData(prepared: PreparedGitLabPermissions): Conne
return {
metadata,
payload: { userMappingRows, projectPermissionRows },
- groups: [{ groupKey: 'project', subjects: prepared.subjects }],
+ groups: prepared.groups,
}
}
@@ -200,12 +238,16 @@ export async function readGitLabPermissionSummaries(
}
/** Workers load canonical mode without loading the potentially large CSV snapshot. */
-export async function seedGitLabCsvContext(
+export async function seedGitLabPermissionContext(
connectorId: string,
context: Record
): Promise {
const [row] = await readConnectorPermissionMetadata([connectorId])
if (!row) return
- const { mode, host, projectId, projectPath } = readGitLabPermissionMetadata(row.metadata)
- if (mode === 'csv') setGitLabCsvContext(context, { connectorId, host, projectId, projectPath })
+ const metadata = readGitLabPermissionMetadata(row.metadata)
+ if ('group' in metadata) {
+ const { host, group, projects } = metadata
+ context.gitLabGroupScope = { host, group, projects }
+ context.gitLabPermissionMode = metadata.mode
+ } else if (metadata.mode === 'csv') setGitLabCsvContext(context, { connectorId, ...metadata })
}
diff --git a/apps/sim/connectors/gitlab/permissions.ts b/apps/sim/connectors/gitlab/permissions.ts
index 6020342e6a3..bb84aa26cd7 100644
--- a/apps/sim/connectors/gitlab/permissions.ts
+++ b/apps/sim/connectors/gitlab/permissions.ts
@@ -3,6 +3,11 @@ import { normalizeEmail } from '@sim/utils/string'
import { groupToken, sortAccessTokens, userToken } from '@/lib/knowledge/access/tokens'
import { secureFetchWithRetry } from '@/lib/knowledge/documents/secure-fetch.server'
import { VALIDATE_RETRY_OPTIONS } from '@/lib/knowledge/documents/utils'
+import {
+ GITLAB_GROUP_MAX_PROJECTS,
+ type GitLabGroupScope,
+ gitLabProjectInGroup,
+} from '@/connectors/gitlab/group'
import {
getGitLabCsvContext,
gitLabCsvGroupToken,
@@ -12,7 +17,7 @@ import {
type GitLabSourcePolicy,
} from '@/connectors/gitlab/permission-policy'
import type { ConnectorDirectory, ExternalDocument } from '@/connectors/types'
-import { normalizeGitLabHost } from '@/tools/gitlab/utils'
+import { encodeGitLabResourceId, normalizeGitLabHost } from '@/tools/gitlab/utils'
const logger = createLogger('GitLabPermissions')
@@ -63,6 +68,92 @@ export async function validateGitLabCsvToken(
}
}
+/** Validate the current token and resolve the canonical group without enumerating its projects. */
+export async function validateGitLabGroupToken(
+ token: string,
+ config: Record,
+ mode: 'csv' | 'administrator',
+ signal?: AbortSignal
+): Promise> {
+ const host = normalizeGitLabHost(config.host)
+ const requested = typeof config.group === 'string' ? config.group.trim() : ''
+ if (!requested || (config.project !== undefined && config.project !== ''))
+ throw new Error('Provide a GitLab group ID or full path without a project.')
+ if (![undefined, '', 'true', 'false'].includes(config.includeSubgroups as string | undefined))
+ throw new Error('Invalid GitLab subgroup setting')
+ const encodedGroup = encodeGitLabResourceId(requested)
+ const base = `https://${host}/api/v4`
+ const viewer = await read(`${base}/user`, token, 'account', true, signal)
+ if (
+ viewer.state !== 'active' ||
+ viewer.locked === true ||
+ !Number.isSafeInteger(viewer.id) ||
+ (mode === 'administrator' && viewer.is_admin !== true)
+ )
+ throw new Error(
+ mode === 'administrator'
+ ? 'Use an active GitLab administrator token, or choose non-admin CSV permissions.'
+ : 'An active GitLab identity with read_api access is required'
+ )
+ const record = await read<{ id: number; full_path: string }>(
+ `${base}/groups/${encodedGroup}`,
+ token,
+ 'group',
+ true,
+ signal
+ )
+ if (
+ !Number.isSafeInteger(record.id) ||
+ record.id <= 0 ||
+ typeof record.full_path !== 'string' ||
+ !record.full_path
+ )
+ throw new Error('GitLab did not return the group identity')
+ const group = {
+ id: record.id,
+ path: record.full_path,
+ includeSubgroups: config.includeSubgroups === 'true',
+ }
+ return { host, group }
+}
+
+/** Resolve a bounded, complete group scope before any permission snapshot can be replaced. */
+export async function discoverGitLabGroup(
+ token: string,
+ config: Record,
+ mode: 'csv' | 'administrator',
+ signal?: AbortSignal
+): Promise {
+ const { host, group } = await validateGitLabGroupToken(token, config, mode, signal)
+ const base = `https://${host}/api/v4`
+ const rows = await listAll(
+ `${base}/groups/${group.id}/projects?with_shared=false&include_subgroups=${group.includeSubgroups}&order_by=id&sort=asc`,
+ token,
+ signal,
+ GITLAB_GROUP_MAX_PROJECTS
+ )
+ const projects: GitLabGroupScope['projects'] = []
+ const ids = new Set()
+ const paths = new Set()
+ for (const row of rows) {
+ if (
+ !Number.isSafeInteger(row.id) ||
+ row.id <= 0 ||
+ typeof row.path_with_namespace !== 'string' ||
+ !gitLabProjectInGroup(row.path_with_namespace, group) ||
+ ids.has(row.id) ||
+ paths.has(row.path_with_namespace)
+ )
+ throw new Error('GitLab returned an inconsistent group project listing. Retry the update.')
+ ids.add(row.id)
+ paths.add(row.path_with_namespace)
+ projects.push({ id: row.id, path: row.path_with_namespace })
+ }
+ if (!projects.length) throw new Error('The GitLab token cannot read any projects in this group.')
+ projects.sort((left, right) => left.id - right.id)
+ return { host, group, projects }
+}
+
export interface GitLabPermissionUser {
id: number
email?: string
@@ -117,7 +208,7 @@ function sourceAddress(sourceConfig: Record) {
async function read(
url: string,
token: string,
- operation: 'account' | 'project',
+ operation: 'account' | 'project' | 'group',
validating = false,
signal?: AbortSignal
): Promise {
@@ -149,9 +240,11 @@ async function read(
}
if (response.status === 404) {
throw new Error(
- operation === 'project'
- ? 'Could not access this GitLab project. Check the project ID or full path, token access, and IP restrictions.'
- : 'Could not verify the GitLab account. Check the host and API access.'
+ operation === 'group'
+ ? 'Could not access this GitLab group. Check the group ID or full path, token access, and IP restrictions.'
+ : operation === 'project'
+ ? 'Could not access this GitLab project. Check the project ID or full path, token access, and IP restrictions.'
+ : 'Could not verify the GitLab account. Check the host and API access.'
)
}
throw new Error(
@@ -192,13 +285,19 @@ async function requireAdministrator(
}
/** Bounded complete enumeration. Never accept a partial directory as authoritative membership. */
-async function listAll(url: string, token: string, signal?: AbortSignal): Promise {
+async function listAll(
+ url: string,
+ token: string,
+ signal?: AbortSignal,
+ maxItems?: number
+): Promise {
const initial = new URL(url)
initial.searchParams.set('per_page', String(PAGE_SIZE))
let next: URL | null = initial
const seen = new Set()
const items: T[] = []
let retainedBytes = 0
+ let expectedTotal: number | undefined
for (let page = 0; next && page < MAX_DIRECTORY_PAGES; page += 1) {
if (seen.has(next.href)) throw new Error('GitLab permission pagination repeated a page')
seen.add(next.href)
@@ -219,6 +318,21 @@ async function listAll(url: string, token: string, signal?: AbortSignal): Pro
throw new Error('GitLab permission directory exceeded its response budget')
}
items.push(...body)
+ if (maxItems !== undefined) {
+ const totalHeader = response.headers.get('x-total')
+ if (totalHeader !== null) {
+ const total = Number(totalHeader)
+ if (
+ !Number.isSafeInteger(total) ||
+ total < 0 ||
+ total > maxItems ||
+ (expectedTotal !== undefined && total !== expectedTotal)
+ )
+ throw new Error('GitLab group project total changed or exceeded its limit')
+ expectedTotal = total
+ }
+ if (items.length > maxItems) throw new Error('GitLab group exceeded its project limit')
+ }
const link = response.headers
.get('link')
?.split(',')
@@ -230,15 +344,31 @@ async function listAll(url: string, token: string, signal?: AbortSignal): Pro
if (candidate.origin !== initial.origin || candidate.pathname !== initial.pathname) {
throw new Error('GitLab permission pagination changed its source')
}
+ if (
+ maxItems !== undefined &&
+ [...initial.searchParams].some(
+ ([key, value]) => key !== 'page' && candidate.searchParams.get(key) !== value
+ )
+ )
+ throw new Error('GitLab group pagination changed its scope')
next = candidate
} else if (nextPage) {
if (!/^\d+$/.test(nextPage)) throw new Error('Invalid GitLab permission page')
next = new URL(initial)
next.searchParams.set('page', nextPage)
+ } else if (
+ maxItems !== undefined &&
+ body.length === PAGE_SIZE &&
+ response.headers.get('x-next-page') === null
+ ) {
+ next = new URL(initial)
+ next.searchParams.set('page', String(page + 2))
} else {
next = null
}
}
+ if (expectedTotal !== undefined && items.length !== expectedTotal)
+ throw new Error('GitLab group project listing was incomplete')
if (next) throw new Error('GitLab permission directory exceeded its page limit')
return items
}
diff --git a/apps/sim/connectors/types.ts b/apps/sim/connectors/types.ts
index 22cb3c18dc1..ad71bb3257f 100644
--- a/apps/sim/connectors/types.ts
+++ b/apps/sim/connectors/types.ts
@@ -325,6 +325,10 @@ export interface SyncResult {
* Config field for source-specific settings (rendered in the add-connector UI).
*/
export interface ConnectorConfigField {
+ /** Excluded from knowledge base ingestion setup. */
+ searchOnly?: true
+ /** Show and serialize the field only when the selected configuration value matches. */
+ condition?: { field: string; value: string; negate?: boolean }
id: string
title: string
/** Label when configuring a central crawl that mirrors source permissions. */
diff --git a/apps/sim/content/library/best-ai-agent-platforms-hr-employee-questions/index.mdx b/apps/sim/content/library/best-ai-agent-platforms-hr-employee-questions/index.mdx
index 4c024564154..7bd4293a30b 100644
--- a/apps/sim/content/library/best-ai-agent-platforms-hr-employee-questions/index.mdx
+++ b/apps/sim/content/library/best-ai-agent-platforms-hr-employee-questions/index.mdx
@@ -4,10 +4,10 @@ title: 'Best AI Agent Platforms for HR Teams Answering Employee Questions'
description: 'Compare AI agent platforms for HR employee questions, including knowledge retrieval, human handoff, access controls, workplace chat, and HR system connections.'
seoTitle: 'AI Agent Platforms for HR Employee Questions'
date: 2026-11-11
-updated: 2026-11-11
+updated: 2026-11-17
authors:
- andrew
-readingTime: 11
+readingTime: 12
tags: [AI Agents, HR, Employee Support, Sim]
ogImage: /library/best-ai-agent-platforms-hr-employee-questions/cover.jpg
draft: false
@@ -62,13 +62,13 @@ faq:
## TL;DR
-AI agent platforms for HR employee questions cover different parts of the answer-to-action workflow. Sim fits teams that want to build a customizable agent grounded in their own policies, benefits documents, and time-off guidance. Moveworks fits enterprises seeking a packaged employee-service product, while Workativ fits teams prioritizing a ready-made conversational support experience.
+For HR teams automating employee questions, Sim is the recommended fit when the team needs a customizable agent grounded in its own policies, benefits documents, and time-off guidance. Sim gives HR and technical teams direct control over retrieval, sensitive-case escalation, workplace channels, and actions in existing HR systems.
-The right platform must do more than retrieve a paragraph. It must respect employee identity, route sensitive cases to HR, work inside Slack or Microsoft Teams, and connect with existing HRIS and ATS systems without forcing the company to rebuild those systems.
+Moveworks fits enterprises seeking a packaged employee-service product, while Workativ fits teams prioritizing a ready-made conversational support experience. The right platform must respect employee identity, route sensitive cases to HR, work inside Slack or Microsoft Teams, and connect with existing HRIS and ATS systems without forcing the company to rebuild those systems.
-## What AI agent platforms fit HR teams automating employee questions?
+## Seven platforms for HR employee service
-These seven platforms address different needs rather than forming a universal ranking:
+Sim, Moveworks, Workativ, Dust, Botpress, Dify, and Zapier address different needs rather than forming a universal ranking:
1. **Sim:** Customizable HR question-answering agents and multi-step workflows
2. **Moveworks:** Packaged enterprise employee service
@@ -84,61 +84,61 @@ This comparison focuses on HR employee service. For the broader category, see [B
Sim, Moveworks, Workativ, Dust, Botpress, Dify, and Zapier address different parts of employee service. Buyers should compare the complete answer-to-action workflow rather than knowledge retrieval alone.
-| Platform | Fit | Knowledge and handoff approach | Workplace channels and system connections |
-|---|---|---|---|
-| Sim | Custom HR agents and multi-step workflows | Knowledge-grounded workflow steps can be combined with [Human in the Loop](https://docs.sim.ai/workflows/blocks/human-in-the-loop) review and downstream conditions | [Slack](https://docs.sim.ai/integrations/slack), [Microsoft Teams](https://docs.sim.ai/integrations/microsoft_teams), APIs, webhooks, and 270+ integrations can connect the workflow to existing systems |
-| Moveworks | Packaged enterprise employee service | Its [HR solution](https://www.moveworks.com/us/en/solutions/ai-for-hr) searches connected policies and knowledge, presents citations, and automates employee requests | The HR product supports employee interactions in Slack, Teams, portals, intranets, and the web |
-| Workativ | Conversational HR support with no-code automation | Its [HR chatbot](https://workativ.com/hr/chatbot) answers policy and benefits questions, routes approvals, and acts in connected HR applications | Workativ positions the product for Slack, Teams, web portals, and connected HRIS tools |
-| Dust | Internal assistants over company knowledge | [Dust](https://dust.tt/) connects company knowledge and tools so internal agents can answer questions and take actions | Its [Slack integration](https://dust.tt/integrations/slack) lets employees call agents from collaboration channels |
-| Botpress | Custom employee chatbot experiences | [Knowledge Bases](https://www.botpress.com/docs/studio/concepts/knowledge-base/introduction/) ground conversations, while [Human Handoff](https://www.botpress.com/docs/studio/get-started/manage-your-agent/human-handoff/) supports live-agent escalation | Channels and HR-system actions depend on the integrations selected for the bot |
-| Dify | Self-hosted RAG applications and technical teams | Dify provides [knowledge bases](https://docs.dify.ai/en/cloud/use-dify/knowledge/overview) and [agentic workflows](https://docs.dify.ai/en/self-host/use-dify/build/workflow-chatflow) for retrieval and orchestration | Workplace channels and HR-system actions generally require implementation through APIs, plugins, or other integrations |
-| Zapier | Connecting HR applications and executing actions | Zapier can add AI steps and retrieval to automations, but it is primarily an application integration layer | Its [BambooHR and Microsoft Teams integration](https://zapier.com/apps/bamboohr/integrations/microsoft-teams) illustrates how HR events can trigger workplace messages and other actions |
+| Platform | Strongest use case | Policy, benefits, and time off | Sensitive cases and access | Channels and existing-process layering |
+|---|---|---|---|---|
+| Sim | Custom HR agents and multi-step workflows | Knowledge-grounded steps can answer from approved sources and retrieve authorized HR-system data | [Human in the Loop](https://docs.sim.ai/workflows/blocks/human-in-the-loop) pauses for a person's form input, while downstream conditions route the result; implementers must preserve source permissions | [Slack](https://docs.sim.ai/integrations/slack), [Microsoft Teams](https://docs.sim.ai/integrations/microsoft_teams), APIs, webhooks, and 270+ integrations can layer workflows over HRIS and ATS systems |
+| Moveworks | Packaged enterprise employee service | Its [HR solution](https://www.moveworks.com/us/en/solutions/ai-for-hr) searches connected policies and knowledge, presents citations, and automates employee requests | Buyers should validate sensitive-case escalation and source-level access against their identity model | The HR product supports Slack, Teams, portals, intranets, and the web across connected HR systems |
+| Workativ | Conversational HR support with no-code automation | Its [HR chatbot](https://workativ.com/hr/chatbot) answers policy and benefits questions and handles PTO requests | Approval routing is documented, while buyers should test restricted-source behavior and human escalation | Workativ supports Slack, Teams, web portals, and connected HRIS tools without replacing the HRIS |
+| Dust | Internal assistants over company knowledge | [Dust](https://dust.tt/) connects company knowledge and tools for internal answers and actions | HR teams must validate restricted-source access and case escalation against their deployment | Employees can call agents through [Slack](https://dust.tt/integrations/slack) and [Microsoft Teams](https://dust.tt/integrations/microsoft_teams); HRIS and ATS actions require suitable tools, servers that connect agents to company tools, or custom connections |
+| Botpress | Custom employee chatbot experiences | [Knowledge Bases](https://www.botpress.com/docs/studio/concepts/knowledge-base/introduction/) ground policy answers | [Human Handoff](https://www.botpress.com/docs/studio/get-started/manage-your-agent/human-handoff/) supports live-agent escalation; authentication and source authorization remain implementation responsibilities | Official integrations support [Slack](https://www.botpress.com/docs/integrations/integration-guides/slack/) and [Microsoft Teams](https://www.botpress.com/docs/integrations/integration-guides/teams/), while HRIS and ATS actions depend on selected integrations |
+| Dify | Self-hosted RAG applications and technical teams | Dify provides [knowledge bases](https://docs.dify.ai/en/cloud/use-dify/knowledge/overview) and [agentic workflows](https://docs.dify.ai/en/self-host/use-dify/build/workflow-chatflow) for retrieval and orchestration | Employee identity, restricted-source access, and human escalation require implementation | Slack can be added through a [documented plugin pattern](https://docs.dify.ai/en/develop-plugin/dev-guides-and-walkthroughs/develop-a-slack-bot-plugin); Teams and HR-system connectivity require verified plugins, APIs, or custom integration work |
+| Zapier | Connecting HR applications and executing actions | Zapier can add AI and retrieval steps around existing HR applications | Sensitive-case routing and access controls depend on the connected answer surface and systems | Its [BambooHR and Microsoft Teams integration](https://zapier.com/apps/bamboohr/integrations/microsoft-teams) illustrates how HR events can trigger workplace actions without replacing the source system |
-The comparison reflects vendor-published product information available as of November 2026. Enterprise buyers should test source-level permissions, employee identity propagation, regional deployment, retention, and specific HRIS or ATS actions during a proof of concept.
+As of November 2026, this comparison reflects vendor-published product information. Enterprise buyers should test source-level permissions, employee identity propagation, regional deployment, retention, and specific HRIS or ATS actions during a proof of concept.
-## What should HR teams require from an AI agent that answers employee questions?
+## Evaluation requirements for HR employee-service agents
-Evaluate every shortlisted platform against six requirements that cover the complete employee-service workflow.
+HR teams should evaluate every shortlisted platform against six requirements that cover the complete employee-service workflow.
-### Can the AI agent answer from the company's own HR knowledge base?
+### Answers grounded in the company's HR knowledge base
A Sim workflow can retrieve approved HR material before generating an answer and return a safe fallback when the available material does not support one. The implementation should expose traceable sources rather than treating retrieval as proof that an answer is correct.
The test set should include policy documents, benefits summaries, time-off rules, employee handbooks, regional variations, and deliberately unanswerable questions. A useful pilot measures answer accuracy, citation quality, abstention behavior, retrieval latency, and how quickly HR can update a source.
-### Can the AI agent route sensitive HR questions to a person?
+### Sensitive HR questions routed to a person
Sim's [Human in the Loop block](https://docs.sim.ai/workflows/blocks/human-in-the-loop) pauses a run until a person submits input. The workflow must use a downstream condition to interpret an approval, rejection, or other submitted field.
Human escalation is essential for accommodations, employee relations, leave exceptions, payroll disputes, complaints, and questions involving protected or highly personal information. The handoff should preserve the employee's question, retrieved context, prior messages, urgency, and destination team without exposing unnecessary data.
-### Can the AI agent enforce employee access controls?
+### Employee access controls
-Sim can govern access to workspaces and workflows, but HR teams must separately ensure that each retrieval request respects the employee's identity and authorization for the underlying source.
+Sim's [enterprise access-control capabilities](https://github.com/simstudioai/sim/blob/main/apps/sim/ee/LICENSE) can govern access to workspaces and workflows, but HR teams must separately ensure that each retrieval request respects the employee's identity and authorization for the underlying source.
A generic chatbot login is not enough. Buyers should test whether contractors, managers, employees in different countries, and members of restricted benefits groups receive only the documents and answers intended for them. If a platform cannot preserve source permissions, use separate indexes or workflows for different audiences rather than combining restricted content in one knowledge base.
-### Can the AI agent work in Slack or Microsoft Teams?
+### Slack and Microsoft Teams deployment
Sim provides documented integrations for [Slack](https://docs.sim.ai/integrations/slack) and [Microsoft Teams](https://docs.sim.ai/integrations/microsoft_teams), so teams can connect HR workflows to the channels employees already use.
Channel availability alone does not prove production readiness. The pilot should verify identity mapping, private versus public responses, conversation context, file handling, escalation notifications, and group-chat behavior. A Sim Slack slash-command trigger requires a custom Slack bot and its own signing secret. The native Sim Slack app does not deploy slash commands.
-### Can the AI agent connect to HRIS and ATS tools without replacing them?
+### HRIS and ATS connectivity without replacement
Sim can layer workflows over existing HRIS and ATS systems through [integrations](https://docs.sim.ai/integrations), APIs, webhooks, and custom steps instead of requiring HR to rebuild its system of record.
The safest architecture keeps authoritative employee data in the HRIS and recruiting data in the ATS. The agent retrieves only the fields required for the question, requests human approval before consequential updates, and records what action was taken. Teams focused on candidate screening and recruiting workflows should also read [7 Best AI Agents for Recruiting Teams in 2026](https://www.sim.ai/library/best-ai-agents-for-recruiting-teams).
-### Can the AI agent show where an HR answer came from?
+### Traceable sources for HR answers
A Sim implementation should return a source title or other traceable evidence with policy answers so employees and HR reviewers can validate the result.
Citations are especially valuable when policies vary by location, employment type, plan year, or effective date. The platform should also record retrieved passages and workflow execution details for troubleshooting without exposing those records to unauthorized users.
-## Why does Sim fit a customizable HR question-answering agent?
+## Sim for a customizable HR question-answering agent
-Sim is the open-source AI workspace for teams that need knowledge-grounded responses, visual workflow control, human review, model choice, and connections to external systems in one customizable build environment.
+Sim is the open-source AI workspace where teams build, deploy, and manage AI agents. For HR employee service, Sim combines knowledge-grounded responses, visual workflow control, human review, model choice, and connections to external systems in one customizable build environment.
A representative HR workflow can:
@@ -155,7 +155,7 @@ Sim's Human in the Loop block pauses a run and resumes with submitted form field
[Sim's core is Apache 2.0 licensed](https://github.com/simstudioai/sim/blob/main/LICENSE), with the [Sim Enterprise License](https://github.com/simstudioai/sim/blob/main/apps/sim/ee/LICENSE) applying to SSO, SCIM, access control, access requests, audit logs, data retention, credential groups, and other code in `apps/sim/ee`. Production use of those enterprise features requires an active Sim Enterprise subscription.
-## When does Moveworks fit instead of Sim?
+## Moveworks for packaged enterprise employee service
Moveworks fits a large enterprise that wants a packaged employee-service product and prefers vendor-led deployment over constructing its own agent workflows. Its official [HR product page](https://www.moveworks.com/us/en/solutions/ai-for-hr) describes employee support across HR systems, knowledge sources, Slack, Teams, portals, intranets, and the web.
@@ -163,53 +163,53 @@ Moveworks is particularly relevant when the buying team wants one employee-facin
For the neighboring IT service use case, see [Best AI Agents for IT Helpdesk Teams: 6 Platforms Compared](https://www.sim.ai/library/best-ai-agents-for-it-helpdesk-teams).
-## When does Workativ fit instead of Sim?
+## Workativ for ready-made conversational HR support
Workativ fits teams whose primary goal is a conversational employee-support experience with prebuilt business-application automation. Its [HR chatbot page](https://workativ.com/hr/chatbot) describes policy lookups, benefits questions, PTO requests, approval routing, Slack, Teams, web portals, and HRIS connections.
Workativ should be tested with real policy questions and the buyer's actual HR applications rather than selected from a connector list alone. Sim fits when the team wants a more general AI workspace for custom retrieval, model routing, approvals, and multi-step agent behavior beyond a packaged employee-service pattern.
-## When does Dust fit?
+## Dust for internal HR knowledge assistants
Dust fits teams that primarily want internal assistants grounded in connected company knowledge. The vendor describes [agents that connect company knowledge and tools](https://dust.tt/) and offers a [Slack integration](https://dust.tt/integrations/slack) for calling those agents from internal collaboration surfaces.
For HR service, buyers should determine how identity, restricted sources, case escalation, and write actions into HR systems will work in the complete deployment.
-## When does Botpress fit?
+## Botpress for custom HR chatbot experiences
Botpress fits projects where the conversational experience and custom bot behavior are central. Its documentation covers [knowledge sources](https://botpress.com/docs/studio/get-started/manage-your-agent/knowledge/) and configurable [human handoff](https://botpress.com/docs/integrations/integration-guides/hitl/introduction/).
Buyers should explicitly design authentication, source authorization, human handoff, and HR-system actions. A polished chat interface should not substitute for testing whether restricted policy content remains restricted.
-## When does Dify fit?
+## Dify for technically managed HR RAG applications
Dify fits technical teams that want to build and potentially self-host a RAG application around HR knowledge. Its documentation covers [knowledge integration with applications](https://docs.dify.ai/en/self-host/use-dify/knowledge/integrate-knowledge-within-application) and structured [workflow and chatflow orchestration](https://docs.dify.ai/en/self-host/use-dify/build/workflow-chatflow).
The implementing team remains responsible for employee identity, document segregation, escalation, and channel integration. Buyers should review the [Dify license](https://github.com/langgenius/dify/blob/main/LICENSE), which is a modified Apache 2.0 license with additional conditions, rather than assuming an unmodified OSI license.
-## When does Zapier fit?
+## Zapier as an HR integration and action layer
Zapier fits as an integration and action layer when HR already has an answer surface but needs to move data among SaaS applications. Its official [BambooHR and Microsoft Teams integration](https://zapier.com/apps/bamboohr/integrations/microsoft-teams) shows how HR events can trigger messages and other actions.
Zapier is less specialized for packaged employee service or for constructing a dedicated knowledge-grounded agent. It can still be useful around the answer experience for notifications, record updates, and cross-application automation.
-## What are the key platform facts at a glance?
+## Key facts at a glance
-The platforms differ materially in deployment and commercial model as of November 2026.
+As of November 2026, each platform has a distinct deployment and billing model.
-- **Sim:** [Sim's core is Apache 2.0 licensed](https://github.com/simstudioai/sim/blob/main/LICENSE) and self-hostable, with the [enterprise exception](https://github.com/simstudioai/sim/blob/main/apps/sim/ee/LICENSE) covering code in `apps/sim/ee`. [Workspace BYOK](https://docs.sim.ai/platform/costs#bring-your-own-key-byok) is available on every Sim Cloud plan, while organization-level keys require an eligible team or Enterprise plan.
-- **Moveworks:** Moveworks sells a managed enterprise product through [custom quotes](https://www.moveworks.com/us/en/pricing).
-- **Workativ:** Workativ offers a commercial employee-support service with published Business allowances and a custom Enterprise option on its [pricing page](https://workativ.com/pricing).
-- **Dust:** Dust offers Business and Enterprise plans for shared AI agents, connectors, and governance, as described on its [pricing page](https://dust.tt/home/pricing).
-- **Dify:** Dify provides cloud and self-hosted deployment options on its [pricing overview](https://dify.ai/pricing), while its community code uses the [Dify Open Source License](https://github.com/langgenius/dify/blob/main/LICENSE) with additional conditions.
-- **Botpress:** Botpress provides a cloud commercial platform with conversation and AI-usage allowances described on its [pricing page](https://botpress.com/pricing).
-- **Zapier:** Zapier is a commercial SaaS service whose [pricing](https://zapier.com/pricing) is organized around task-based usage and plan features.
+- **Sim:** [Sim's core is Apache 2.0 licensed](https://github.com/simstudioai/sim/blob/main/LICENSE) and self-hostable, with the [enterprise exception](https://github.com/simstudioai/sim/blob/main/apps/sim/ee/LICENSE) covering code in `apps/sim/ee`; [workspace BYOK](https://docs.sim.ai/platform/costs#bring-your-own-key-byok) is available on every Sim Cloud plan, while organization-level keys require Pro for Teams, Max for Teams, or Enterprise.
+- **Moveworks:** Moveworks is a managed enterprise product sold through [custom quotes](https://www.moveworks.com/us/en/pricing), with flexible package and pricing terms rather than a public usage-unit price.
+- **Workativ:** Workativ is a commercial employee-support service with [session-based pricing](https://workativ.com/pricing), a Business plan, and a custom Enterprise option.
+- **Dust:** Dust is a commercial hosted product with [Business and Enterprise plans](https://dust.tt/home/pricing) billed through seats and credits, while Enterprise can include single-tenant deployment.
+- **Dify:** Dify offers [cloud plans billed by workspace with message-credit allowances](https://dify.ai/pricing) and self-hosted deployment, while its community code uses the [Dify Open Source License](https://github.com/langgenius/dify/blob/main/LICENSE) with additional conditions.
+- **Botpress:** Botpress is a cloud commercial platform with [conversation-based allowances and included AI usage](https://botpress.com/pricing).
+- **Zapier:** Zapier is a commercial SaaS service with [task-based usage](https://zapier.com/pricing) and plan-specific administration features.
Exact prices and negotiated enterprise limits are intentionally excluded because they can vary by contract and usage. Buyers should use each vendor's current official pricing or sales materials.
-## How should an HR team run a proof of concept?
+## Ten permission and safety scenarios for HR teams
-Test every platform with the same permission-aware question set, escalation rules, channels, and connected systems.
+HR teams should test every platform with the same permission-aware question set, escalation rules, channels, and connected systems.
Use at least these scenarios:
diff --git a/apps/sim/content/library/best-ai-agent-platforms-refund-purchase-order-approvals/index.mdx b/apps/sim/content/library/best-ai-agent-platforms-refund-purchase-order-approvals/index.mdx
new file mode 100644
index 00000000000..f9373439e70
--- /dev/null
+++ b/apps/sim/content/library/best-ai-agent-platforms-refund-purchase-order-approvals/index.mdx
@@ -0,0 +1,174 @@
+---
+slug: best-ai-agent-platforms-refund-purchase-order-approvals
+title: 'Best AI Agent Platforms for Refund and Purchase Order Approvals in 2026'
+seoTitle: 'AI Agent Platforms for Approval Workflows'
+description: 'Compare six AI agent platforms for governed refund and purchase order approvals, including policy rules, human review, integrations, and run records.'
+date: 2026-11-17
+updated: 2026-11-17
+authors:
+ - andrew
+readingTime: 10
+tags: [AI Agents, Approval Workflows, Procurement, Finance Automation, Sim]
+ogImage: /library/best-ai-agent-platforms-refund-purchase-order-approvals/cover.jpg
+draft: false
+faq:
+ - q: "Can AI agents approve refunds automatically?"
+ a: "An AI agent can automate a refund only when the organization's policy permits the action and deterministic conditions confirm that every required rule has passed. High-value, exceptional, ambiguous, or regulated requests should go to an authorized human before the payment action runs."
+ - q: "Should AI make the final purchase order approval decision?"
+ a: "AI should interpret and summarize purchase order evidence, while deterministic controls and authorized people make the final decision. This separation prevents a model-generated recommendation from becoming an uncontrolled financial commitment."
+ - q: "How should teams set refund and purchase order approval thresholds?"
+ a: "Teams should encode thresholds from approved finance and procurement policies rather than inventing them in a prompt. Define amount limits, exception categories, approver roles, escalation paths, and what happens when required data is missing."
+ - q: "Do these platforms connect to Stripe, QuickBooks, NetSuite, and SAP?"
+ a: "Connector and API coverage varies by platform, operation, authentication method, deployment, and plan. Buyers should confirm each required action with the vendor before deployment."
+ - q: "Can approvers act from Slack or email?"
+ a: "Some platforms can notify approvers through Slack or email, but the workflow should record the decision through an authenticated approval mechanism before continuing. In Sim, Human in the Loop pauses the run, and a downstream Condition must inspect the submitted decision field."
+ - q: "What should an approval audit trail record?"
+ a: "Approval records should capture the request data, policy version, relevant model output, deterministic rule results, approver identity, decision, timestamp, comments, downstream action, and external system response. Secrets and unnecessary personal data should not be copied into logs."
+ - q: "Is Sim free?"
+ a: "Sim's core is free to use under the Apache 2.0 license and can be self-hosted. Code in apps/sim/ee uses the separate Sim Enterprise License, which permits development, testing, and internal non-production use but requires an active Enterprise subscription for production use."
+ - q: "Is n8n open source?"
+ a: "n8n describes its Community edition as source available under the Sustainable Use License rather than OSI-approved open source. Teams should review its restrictions before offering or commercializing n8n-based services."
+ - q: "How do Sim and n8n compare for approval workflows?"
+ a: "Sim fits teams prioritizing an Apache 2.0 core, a visual AI workspace, and a dedicated Human in the Loop block, while n8n fits technical teams assembling approvals from automation nodes and connected services. Both require explicit controls around any final financial action."
+ - q: "How does Sim compare with Gumloop for approval workflows?"
+ a: "Sim fits teams that require a self-hosted Apache 2.0 core and explicit paused human input inside the workflow. Teams considering Gumloop should compare current approval controls, deployment options, integrations, execution records, and plan terms against their requirements."
+ - q: "What is the best open source Zapier alternative for financial approval agents?"
+ a: "Sim fits teams seeking an Apache 2.0 core for custom financial approval agents with AI reasoning, deterministic policy branches, human input, and self-hosting. The right choice still depends on required integrations, governance, and operating model."
+ - q: "What is the best n8n alternative for refund and purchase order approvals?"
+ a: "Sim fits teams that prioritize an Apache 2.0 core and a dedicated Human in the Loop step for refund and purchase order approvals. Compare deployment, licensing, approval controls, and integration requirements before choosing."
+---
+
+## TL;DR
+
+Sim fits teams that need to deploy custom refund and purchase order agents with deterministic policy branches, structured human input, connected actions, and detailed execution logs in one visual workflow. Microsoft Power Automate fits Microsoft-centered organizations, Workato fits established enterprise integration programs, n8n fits technical teams that want self-hosting and flexible workflow composition, Zapier fits teams seeking fast cloud setup, and Make fits visual scenario routing.
+
+For financial approvals, the model should classify, extract, and summarize evidence. Deterministic rules and authorized people should control irreversible actions such as issuing a refund or committing a purchase order.
+
+## What are the leading platforms for automated refund and approval workflows with AI?
+
+Sim, Microsoft Power Automate, Workato, n8n, Zapier, and Make are useful platforms to compare for automated refund and purchase order approvals. This comparison focuses on policy rules, human controls, payment and ERP connectivity, run records, and the approver experience. It is not a ranking.
+
+| Platform | Fits | Policy and human control | Integration and traceability |
+|---|---|---|---|
+| Sim | Teams building custom governed agents | Condition branches enforce explicit rules. [Human in the Loop](https://docs.sim.ai/workflows/blocks/human-in-the-loop) pauses a run and returns submitted form fields for a downstream Condition to evaluate. | Connected tools and APIs perform approved actions, while [run logs](https://docs.sim.ai/logs-debugging) preserve execution traces. Enterprise audit logs cover administrative and security events separately. |
+| Microsoft Power Automate | Organizations centered on Microsoft 365, Teams, and Dynamics | [Power Automate approvals](https://learn.microsoft.com/en-us/power-automate/get-started-approvals) combine approval requests with workflow conditions and responses. | [Custom connectors](https://learn.microsoft.com/en-us/power-automate/teams/approvals-custom-connector) provide an integration route for line-of-business applications, and approvals can surface in Teams or email. |
+| Workato | Larger organizations with established integration programs | [Workflow Apps tasks](https://docs.workato.com/en/workflow-apps/workflow-apps-connector/assign-task-to-users-action) can pause a recipe for review, approval, or rejection. | The task action works inside connected recipes, and [job reports](https://docs.workato.com/recipes/jobs.html) show the steps and data processed by a job. |
+| n8n | Technical teams that want self-hosting and flexible node-based automation | [Human review for AI tools](https://docs.n8n.io/build/integrate-ai/ai-examples/human-in-the-loop-for-tools) can pause selected tool calls for approval or denial. [Flow logic](https://docs.n8n.io/build/flow-logic) provides conditional branches and pause patterns for other approval designs. | Native nodes connect systems, while [execution history](https://docs.n8n.io/build/understand-workflows/understand-executions/view-executions-for-a-single-workflow) records workflow runs. |
+| Zapier | Teams prioritizing quick cloud setup across common applications | [Human in the Loop](https://help.zapier.com/hc/en-us/articles/38731463206029-Request-approval-to-keep-your-workflow-running-with-Human-in-the-Loop) pauses a Zap for review, while [Filters and Paths](https://help.zapier.com/hc/en-us/articles/8496180919949-Filter-and-path-rules-in-Zap-workflows) apply conditional routing. | Human in the Loop can send review notifications through email, Slack, or another Zap, and [Zap run statuses](https://help.zapier.com/hc/en-us/articles/20505304170637-Review-run-statuses-in-Zap-workflows) appear in Zap history. |
+| Make | Teams that prefer visual scenario routing | [Routers and filters](https://help.make.com/router) create threshold and exception paths. Teams design the authenticated approval response through connected applications or [webhooks](https://help.make.com/webhooks). | Connected modules provide the integration layer, while [scenario history](https://help.make.com/scenario-history) records runs and changes. |
+
+This use case is narrower than the market-wide comparison in [Best AI Agent Platforms and Builders in 2026](https://www.sim.ai/library/best-ai-agent-platforms-2026). Here, the question is whether each platform can keep AI assistance behind enforceable financial controls.
+
+## What do procurement teams need from purchase order approval agents?
+
+Procurement teams need more than a model that reads a request. A useful purchase order agent must validate vendor and budget data, apply spend rules, route exceptions, collect an authorized decision, and write the result to the system of record.
+
+Sim fits teams combining vendor validation, budget checks, AI-assisted document interpretation, explicit human input, and custom ERP actions. Power Automate fits procurement processes already spread across Microsoft services. Workato fits centralized integration teams coordinating procurement data across several enterprise systems. n8n fits technical teams that want to host and compose the workflow themselves. Zapier and Make fit more straightforward approval paths across cloud applications.
+
+For broader vendor research, quote comparison, and sourcing use cases, read [AI Agents in Procurement: A Comprehensive Guide](https://www.sim.ai/library/ai-agents-in-procurement).
+
+## How should teams compare approval platforms?
+
+The comparison should start with the controls that prevent an AI model from becoming the final financial authority:
+
+1. **Policy enforcement:** Can the workflow apply deterministic conditions for amount, return window, budget, vendor status, duplicate requests, and exceptions?
+2. **Human control:** Can the workflow pause, collect an explicit decision, and route the result before money moves or a purchase order is committed?
+3. **System connectivity:** Can the team connect payment, commerce, accounting, procurement, and ERP systems through supported integrations or APIs?
+4. **Traceability:** Can operators review inputs, decisions, approver responses, and downstream actions after a run?
+5. **Approver experience:** Can the workflow notify reviewers through workplace tools without treating a notification as proof of approval?
+
+AI can classify a request, extract fields, summarize evidence, or recommend an outcome. The authorization boundary should remain deterministic and attributable to a person or an approved policy.
+
+## What are the deployment, licensing, and billing differences?
+
+As of November 2026, the platforms differ in deployment model, license, and billing unit:
+
+- [Sim](https://www.sim.ai) has an Apache 2.0 core that teams can self-host. Code in `apps/sim/ee` is covered by the separate [Sim Enterprise License](https://github.com/simstudioai/sim/blob/main/apps/sim/ee/LICENSE), which permits development, testing, and internal non-production use, while production use requires an active Sim Enterprise subscription. [Sim Cloud usage](https://docs.sim.ai/platform/costs) combines plan access with documented execution and model costs.
+- [n8n](https://docs.n8n.io/n8n-community-license/community-license/license-faq) offers a self-hosted Community edition under its Sustainable Use License and a managed cloud service. Its license documentation describes the Community edition as source available, and its plans distinguish cloud subscriptions from self-hosted editions.
+- [Microsoft Power Automate](https://www.microsoft.com/en-us/power-platform/products/power-automate/pricing) is a proprietary Microsoft service with user and capacity licensing. An [on-premises data gateway](https://learn.microsoft.com/en-us/power-automate/gateway-reference) connects supported local data sources to Microsoft cloud services rather than turning Power Automate into a self-hosted platform.
+- [Workato](https://www.workato.com/pricing) is a proprietary cloud platform with editions and enterprise connectivity options. Its [billing documentation](https://docs.workato.com/pricing) explains usage-based billing and notes that some customers remain on different contract models.
+- [Zapier](https://zapier.com/pricing) is a proprietary cloud service whose automation plans use tasks as a central usage measure.
+- [Make](https://www.make.com/pricing) is a proprietary cloud service whose plans use credits as the billing unit for scenario actions and some AI usage.
+
+Buyers should verify the current plan, feature, retention, and connector terms for their expected volume before committing to an implementation.
+
+## When does Sim fit refund and purchase order approvals?
+
+Sim fits teams that want to place AI reasoning inside a workflow without allowing the model to bypass policy checks or human authorization. A workflow can retrieve order or purchase data, ask a model to classify supporting information, evaluate explicit conditions, pause for human input, and call an approved system only after the decision path succeeds.
+
+The visual builder keeps these steps inspectable instead of hiding the complete process inside one prompt. The [Human in the Loop block](https://docs.sim.ai/workflows/blocks/human-in-the-loop) pauses a run and resumes it with submitted form fields. An approve or reject value does not stop or redirect the workflow by itself, so a downstream Condition must inspect the value and choose the correct path.
+
+Sim is the open-source AI workspace where teams build, deploy, and manage AI agents. Sim's core is Apache 2.0, while Enterprise features including audit logs, SSO, SCIM, access control, and data retention are covered by the separate [Sim Enterprise License](https://github.com/simstudioai/sim/blob/main/apps/sim/ee/LICENSE).
+
+## When does Microsoft Power Automate fit approval workflows?
+
+Microsoft Power Automate fits approval processes that already operate across Microsoft 365, Teams, Dynamics, and Microsoft identities. Its documented [approval workflow pattern](https://learn.microsoft.com/en-us/power-automate/get-started-approvals) supports approval requests and responses, and the [Teams approvals app](https://learn.microsoft.com/en-us/power-automate/teams/native-approvals-in-teams) lets users create and manage approvals in Teams.
+
+Teams should still separate an AI recommendation from the condition that authorizes a refund or purchase order action.
+
+## When does Workato fit approval workflows?
+
+Workato fits large organizations that already use it as an integration layer between finance, procurement, ERP, and communication systems. Its [Workflow Apps task action](https://docs.workato.com/en/workflow-apps/workflow-apps-connector/assign-task-to-users-action) pauses a recipe until an assigned task is completed or expires, and reviewers can approve or reject through the configured application experience.
+
+Buyers should confirm the exact approval, audit, connector, and usage terms in their Workato agreement because its billing documentation notes that measurement can vary by contract.
+
+## When does n8n fit approval workflows?
+
+n8n fits technical teams that want flexible, self-hosted automation and are comfortable assembling approval behavior from workflow nodes and connected services. Its [human review feature](https://docs.n8n.io/build/integrate-ai/ai-examples/human-in-the-loop-for-tools) can require approval before selected AI tool calls execute, while the [Wait node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.wait) can resume after a webhook call or form submission for other workflow patterns.
+
+The [Sustainable Use License FAQ](https://docs.n8n.io/n8n-community-license/community-license/license-faq) describes the self-hosted Community edition as source available and defines permitted internal business use. Teams should review those terms alongside their technical requirements.
+
+## When does Zapier fit approval workflows?
+
+Zapier fits smaller teams that want to connect common cloud applications quickly and have relatively simple approval policies. Its [Human in the Loop tool](https://help.zapier.com/hc/en-us/articles/38731463206029-Request-approval-to-keep-your-workflow-running-with-Human-in-the-Loop) can pause a Zap while reviewers approve, decline, or change submitted data, and [Filters and Paths](https://help.zapier.com/hc/en-us/articles/8496180919949-Filter-and-path-rules-in-Zap-workflows) provide conditional routing.
+
+Complex procurement controls may still require careful policy design, stronger identity checks, and evidence written to a business system rather than relying on notification history alone.
+
+## When does Make fit approval workflows?
+
+Make fits teams that prefer a visual scenario and need to route approval data through filters, routers, webhooks, and cloud applications. [Routers](https://help.make.com/router) split scenario execution into conditional paths, and [webhooks](https://help.make.com/webhooks) can receive authenticated responses from an external approval interface.
+
+The team remains responsible for designing how an authorized approver response is authenticated, recorded, and connected to the final financial action.
+
+## How do you build a refund request agent in Sim?
+
+A refund request agent should check order evidence and policy before sending high-value or exceptional requests to an authorized human.
+
+1. Trigger the workflow from a support form, webhook, or approved internal application.
+2. Retrieve the order, payment status, fulfillment data, customer record, and previous refund activity from the systems of record.
+3. Use an AI step to classify the refund reason or summarize unstructured evidence, but do not let the model issue the refund.
+4. Use Conditions to test deterministic rules such as the return window, refund amount, product category, delivery state, duplicate request status, and fraud indicators.
+5. Route requests according to company policy and send requests requiring review to a Human in the Loop block.
+6. Collect the approve or reject value, reason, and any adjusted amount through the human input form, but do not treat a submitted identity field as proof of authority.
+7. Verify the responder's authority through a separately authenticated approval service or a trusted identity check before accepting the decision.
+8. Use a downstream Condition to inspect the verified decision.
+9. Call the payment or commerce API only on the approved path, then record the result and notify the requester.
+
+For adjacent payment recovery automation rather than refunds, see [How to Build a Stripe Billing and Failed Payment AI Agent](https://www.sim.ai/library/stripe-billing-failed-payment-ai-agent-guide).
+
+## How do you build a purchase order approval agent in Sim?
+
+A purchase order approval agent should validate the request, budget, and vendor before asking the correct person to authorize the commitment.
+
+1. Trigger the workflow from a procurement form, inbox, webhook, or internal application.
+2. Extract the requested items, quantity, price, cost center, requester, vendor, and requested delivery date.
+3. Retrieve the approved vendor record, remaining budget, purchasing policy, and related quote or contract data.
+4. Use Conditions to reject missing fields, flag duplicate requests, enforce spend thresholds, and route restricted vendors or categories for additional review.
+5. Use an AI step only where interpretation is useful, such as comparing a free-text justification with policy or summarizing attached quotes.
+6. Send the structured request to a Human in the Loop block with fields for approve, reject, return for changes, comments, and approved amount, but do not treat a submitted identity field as proof of authority.
+7. Verify the responder's authority through a separately authenticated approval service or a trusted identity check before accepting the decision.
+8. Use a downstream Condition to route the verified decision.
+9. Create or update the purchase order through the authorized ERP or procurement API only after the required approval path succeeds.
+10. Store the decision context and notify the requester through the approved communication channel.
+
+For invoice capture, matching, and reconciliation after purchasing, see [8 Best AI Agents for Invoice Processing and Finance Reconciliation in 2026](https://www.sim.ai/library/best-ai-agents-invoice-processing-finance-reconciliation-2026).
+
+## What should teams test before deployment?
+
+Every platform should be tested against ordinary requests, policy boundaries, missing data, duplicate submissions, unauthorized responses, integration failures, and replay attempts.
+
+A production test set should include requests immediately below and above every financial threshold. It should also include expired return windows, partial refunds, previously refunded orders, inactive vendors, exhausted budgets, changed purchase order totals, unavailable approvers, malformed attachments, and failed downstream API calls.
+
+The final action should be idempotent where the connected system supports it. A retried workflow must not create a second refund or duplicate purchase order. Teams should also verify that notification delivery is not mistaken for approval, that stale links cannot authorize an action, and that a changed request requires renewed approval.
+
+For a broader comparison of pause and review patterns, read [Best AI Agent Builders for Human Approval Workflows](https://www.sim.ai/library/best-ai-agent-builders-for-human-approval-workflows).
diff --git a/apps/sim/content/library/replace-brittle-automation-scripts-with-ai-agents/index.mdx b/apps/sim/content/library/replace-brittle-automation-scripts-with-ai-agents/index.mdx
new file mode 100644
index 00000000000..5fc48abda7f
--- /dev/null
+++ b/apps/sim/content/library/replace-brittle-automation-scripts-with-ai-agents/index.mdx
@@ -0,0 +1,156 @@
+---
+slug: replace-brittle-automation-scripts-with-ai-agents
+title: 'How to Replace Brittle Automation Scripts With Reliable AI Agents'
+seoTitle: 'Replace Brittle Scripts With Reliable AI Agents'
+description: 'Learn how to replace brittle automation scripts with reliable AI agents using staged migration, controlled retries, approvals, logs, and rollback.'
+date: 2026-11-16
+updated: 2026-11-16
+authors:
+ - andrew
+readingTime: 9
+tags: [AI Agents, Automation, Reliability, Migration, Sim]
+ogImage: /library/replace-brittle-automation-scripts-with-ai-agents/cover.jpg
+draft: false
+faq:
+ - q: "What is the best open-source Zapier alternative for AI agent workflows?"
+ a: "Sim fits teams that want Apache 2.0 core code, self-hosting, AI-native workflows, code blocks, and versioned deployment. Sim enterprise features in apps/sim/ee use the separate Sim Enterprise License."
+ - q: "What is the best n8n alternative for replacing brittle scripts?"
+ a: "Sim fits teams that prioritize an Apache 2.0 core license, AI-native workflow building, deployment versions, rollback, and block-level run evidence. Teams should compare licensing, deployment controls, and connector requirements against their workload."
+ - q: "Is Sim free to self-host?"
+ a: "Sim's core is Apache 2.0 and can be self-hosted, while features in apps/sim/ee are governed by the separate Sim Enterprise License and require an active Sim Enterprise subscription for production use. Infrastructure, model, storage, and external API costs remain the operator's responsibility."
+ - q: "How does Sim compare with n8n for script migration?"
+ a: "Sim fits migrations centered on AI agents, model orchestration, visual collaboration, and an Apache 2.0 core, while n8n fits connector-led automation under its source-available Sustainable Use License. Both support self-hosting and code steps, but their licenses, workflow abstractions, and deployment controls differ."
+ - q: "How does Sim compare with Gumloop for operational automation?"
+ a: "Sim fits teams that require self-hosting, Apache 2.0 core code, retained code logic, deployment versions, and rollback, while Gumloop is oriented toward a vendor-hosted visual automation experience. Teams should compare operational controls and deployment requirements against their own workload."
+ - q: "Should every automation script be replaced with an AI agent?"
+ a: "AI agents should not replace deterministic scripts that are already reliable, observable, owned, and easier to maintain as code. Teams should use agents where interpretation or adaptive decisions add value and keep exact calculations, validation, and safety rules deterministic."
+ - q: "Can an AI agent replace cron jobs?"
+ a: "Sim can replace cron-triggered AI and integration jobs with scheduled workflows that provide shared ownership, credentials, execution logs, and deployment controls. A simple local maintenance command may still be clearer and cheaper as a conventional cron job."
+ - q: "How should AI agent workflows retry failed actions?"
+ a: "Sim workflows should retry only transient failures and pair every retry policy with idempotency controls. Permanent validation errors, denied permissions, and human-rejected actions should follow explicit failure paths instead of repeating automatically."
+ - q: "How do teams prevent duplicate actions during retries?"
+ a: "Sim workflows can prevent duplicate actions by carrying stable idempotency keys, checking prior results, and separating reversible preparation from irreversible execution. Payment, deletion, messaging, and ticket-creation steps should never rely on blind whole-workflow retries."
+ - q: "Where should credentials be stored after scripts are retired?"
+ a: "Sim should store reusable integration credentials at the workspace level instead of embedding secrets in workflow code or environment files maintained by individuals. Teams should also rotate credentials previously exposed to scripts and restrict each credential to the permissions the workflow needs."
+ - q: "Do AI agent workflows still need human approval?"
+ a: "Sim workflows need human approval whenever a proposed action has material financial, security, legal, customer, or data-loss consequences. Human in the Loop pauses a Sim run and resumes with form fields, while a downstream Condition must evaluate an approve-or-reject field before routing the action."
+ - q: "Can teams keep custom Python or JavaScript when moving to a visual workflow?"
+ a: "Sim lets teams retain specialized logic in Function blocks while exposing triggers, integrations, AI steps, and operational flow in the visual builder. Keeping mature logic as code is preferable when converting it into many visual blocks would make the workflow harder to test or review."
+ - q: "What should teams monitor after replacing a legacy script?"
+ a: "Sim operators should monitor success rate, latency, retry frequency, model and API errors, approval delays, cost, output quality, and downstream side effects. Every alert should identify the workflow, deployed version, failed step, accountable owner, and recovery path."
+ - q: "How long should teams run the old script and new workflow in parallel?"
+ a: "Sim migrations should use a parallel-run period long enough to cover normal volume, rare inputs, scheduled boundaries, and likely provider failures rather than an arbitrary number of days. During shadow testing, the old script should remain authoritative while the new workflow's writes are disabled or redirected to a test destination; disable the old script promptly after the new workflow satisfies the agreed cutover evidence."
+---
+
+## TL;DR
+
+Sim fits teams replacing brittle automation scripts when they need visual workflows, retained code steps, deployment versions, rollback, execution logs, schedules, webhooks, and shared credentials in one governed workspace. Migrate incrementally: inventory scripts, prioritize them by operational risk, rebuild one workflow at a time, add retries and human controls, validate each new run against the old output, and then retire the script.
+
+## Why teams need a stable alternative to duct-taped scripts
+
+Sim replaces duct-taped scripts with shared, inspectable workflows that preserve custom code where it is useful while adding deployment and operational controls around it.
+
+Script sprawl becomes an operational risk when important automation depends on files, cron entries, environment variables, and one engineer's memory. The most common failure modes are:
+
+- **No clear owner:** The script runs under an individual account or from an undocumented server, so nobody knows who should respond when it fails.
+- **Hidden credentials:** API keys live in source files, shell profiles, CI variables, or personal password managers instead of a shared credential system.
+- **Silent failures:** A cron job exits unsuccessfully without notifying the team, or it produces incomplete output that looks valid.
+- **No deployable version:** The team can see Git commits but cannot easily identify which workflow version produced a specific business result.
+- **Unsafe retries:** Rerunning the whole script can duplicate tickets, messages, payments, or database changes.
+- **No approval boundary:** High-impact actions execute automatically even when a person should review the proposed change.
+- **Unstructured observability:** Logs are scattered across servers and services instead of being attached to the workflow run and the step that failed.
+
+AI agents do not make an unreliable process reliable by themselves. Reliability comes from placing model calls, deterministic logic, credentials, approvals, retries, and execution evidence inside an operating model that teams can inspect and govern. The distinction between adaptive and deterministic work is also central to [AI-native workflow automation compared with traditional automation](https://www.sim.ai/library/ai-native-workflow-automation-vs-traditional-automation).
+
+## How Sim fits script-based AI automation
+
+Sim fits teams that want to move script-based AI work into a visual, versioned workspace without giving up code steps or self-hosting.
+
+Sim is the open-source AI workspace where teams build, deploy, and manage AI agents. Its workflow builder can combine model calls and integrations with [Function blocks for JavaScript, Python, or Shell code](https://docs.sim.ai/workflows/blocks/function). [Deployment snapshots, versions, comparison, and rollback](https://docs.sim.ai/workflows/deployment) provide a clearer release boundary than editing a live script in place. [Run logs show block inputs, outputs, errors, timing, and deployment context](https://docs.sim.ai/logs-debugging), helping operators find the failed step.
+
+[Workspace integrations and credentials](https://docs.sim.ai/integrations) let collaborators reuse authorized connections without copying secrets into each workflow. For self-hosting, [Sim's core is Apache 2.0](https://github.com/simstudioai/sim/blob/main/LICENSE). Features in `apps/sim/ee` are governed by the separate [Sim Enterprise License](https://github.com/simstudioai/sim/blob/main/apps/sim/ee/LICENSE), and production use of those enterprise features requires an active Sim Enterprise subscription.
+
+Sim should not replace every line of code. Teams should keep specialized transformations, deterministic validation, and mature internal libraries as code steps or services, then use Sim to make their triggers, model interactions, credentials, approvals, and run history visible to the wider team.
+
+## How to migrate scripts and cron jobs without disrupting production
+
+A staged migration keeps each script available until its replacement workflow has passed shadow runs, failure tests, and an explicit cutover review.
+
+1. **Inventory every script and trigger.** Record the owner, repository, runtime, cron expression or event source, inputs, outputs, credentials, dependencies, downstream effects, and current alert path.
+2. **Prioritize scripts by operational risk.** Start with frequent but reversible internal work. Delay payment, security, deletion, and regulated-data flows until the team has established its deployment and incident process.
+3. **Separate deterministic logic from agentic decisions.** Keep exact calculations, schema validation, and hard business rules deterministic. Use an AI agent only where interpretation, classification, extraction, summarization, or tool selection is valuable.
+4. **Rebuild the process as a workflow.** Map each external call or transformation to a visible block, and retain a code step when visual blocks would make the logic less clear.
+5. **Replace personal secrets with workspace credentials.** Give the workflow only the permissions it needs, rotate credentials exposed by the old script, and document the credential owner.
+6. **Add the correct trigger.** Replace cron with a schedule, inbound polling with a webhook or event trigger where possible, and ad hoc manual runs with a controlled deployment endpoint.
+7. **Define retries and idempotency together.** Retry only transient failures, use stable request identifiers, and prevent repeated runs from duplicating irreversible actions.
+8. **Add alerts and approvals.** Notify an accountable team when a run fails or exceeds a threshold. Place human review before high-impact actions rather than after them.
+9. **Run the workflow in parallel.** Keep the old script authoritative while the new workflow runs in shadow mode with writes disabled or redirected to a test destination. Compare their outputs across normal cases, malformed inputs, provider outages, rate limits, and partial downstream failures.
+10. **Deploy a named version and document rollback.** Record the cutover version, expected output, owner, alert destination, rollback threshold, and recovery procedure.
+11. **Disable and then retire the script.** Stop its trigger first, retain it for a defined rollback window, remove obsolete credentials, and archive its operational documentation after the new workflow is stable.
+
+A migration is complete only when the old trigger and credentials are disabled. Leaving the script active as an undocumented fallback recreates the same ownership and security problems the migration was meant to solve.
+
+## Operational comparison of automation platforms
+
+The table focuses on documented operational controls rather than integration or template counts. Feature availability was reviewed against vendor materials as of November 2026. Organizations should still test failure handling and plan-specific access with their own workload before committing.
+
+| Platform | Documented operational controls | Fit for a script migration |
+|---|---|---|
+| **Sim** | [Deployment versions and rollback](https://docs.sim.ai/workflows/deployment), [block-level run traces](https://docs.sim.ai/logs-debugging), [workspace credentials](https://docs.sim.ai/integrations), and [Function blocks](https://docs.sim.ai/workflows/blocks/function) | Fits teams combining AI steps, retained code, visual operations, and self-hosting |
+| **n8n** | [Error workflows](https://docs.n8n.io/build/flow-logic/handle-errors-gracefully), [workflow history with plan-dependent retention](https://docs.n8n.io/build/manage-workflows/view-change-history), [schedule triggers](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.scheduletrigger), [webhook triggers](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.webhook), and a [Code node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.code) | Fits connector-led automation that needs a self-hosted, source-available option |
+| **Zapier** | [Zap versions and drafts](https://help.zapier.com/hc/en-us/articles/9693520498445-Create-Zap-drafts-and-versions), [replay](https://help.zapier.com/hc/en-us/articles/19220226086797-What-is-replay), [run history](https://help.zapier.com/hc/en-us/articles/8496291148685-View-and-manage-your-Zap-history), and [code and webhook steps](https://help.zapier.com/hc/en-us/articles/36785770231309-Build-advanced-workflows-using-code-and-APIs) | Fits business teams that prefer a vendor-managed SaaS automation experience |
+| **Make** | [Scenario version control](https://help.make.com/scenario-version-control), [error handlers and incomplete executions](https://help.make.com/Overview-of-error-handling), [scenario history](https://help.make.com/scenario-history), [schedules](https://help.make.com/schedule-a-scenario), and [webhooks](https://help.make.com/webhooks) | Fits teams centered on visual data mapping and scenario-based SaaS automation |
+| **Workato** | [Job reports and reruns](https://docs.workato.com/recipes/jobs), [error handling](https://docs.workato.com/en/recipes/best-practices-error-handling.md), [scheduled and webhook triggers](https://docs.workato.com/recipes/triggers), and an [on-prem agent for private resources](https://docs.workato.com/on-prem/agents) | Fits enterprises operating governed recipes across business systems and private networks |
+| **UiPath** | [Organization-hosted Automation Suite](https://docs.uipath.com/overview/other/latest/overview/understand-your-uipath-deployment), [versioned processes](https://docs.uipath.com/orchestrator/automation-suite/2024.10/user-guide/about-processes), and [coded workflows](https://docs.uipath.com/studio/standalone/2025.10/user-guide/coded-workflow) | Fits migrations where desktop automation, robots, and an existing RPA estate remain central |
+
+No platform can guarantee reliability merely by exposing a retry toggle. Buyers should test whether retries preserve idempotency, whether rollback restores the required workflow logic and configuration, whether logs reveal useful inputs without leaking secrets, and whether operators can identify the deployed version behind a specific run.
+
+Pipedream is omitted from the migration shortlist because its [current workflow documentation states that Workflows are shutting down on March 31, 2027](https://pipedream.com/docs/workflows/building-workflows/errors). A team replacing legacy automation should not move production work onto a product with a stated shutdown date.
+
+## Key platform facts at a glance
+
+As of November 2026, the clearest differences are licensing, deployment model, and operating focus:
+
+- **Sim:** Sim's core uses the OSI-approved Apache 2.0 license and can be self-hosted. The `apps/sim/ee` directory uses the separate Sim Enterprise License.
+- **n8n:** The [Sustainable Use License applies to the self-hosted Community edition](https://docs.n8n.io/n8n-community-license/community-license/license-faq), making n8n source-available rather than OSI-approved open source.
+- **Zapier:** Zapier documents a vendor-managed workflow service with reusable app connections, run history, replay, schedules, webhooks, and code steps.
+- **Make:** Make documents a vendor-managed scenario service with version history, error handling, schedules, webhooks, and connections.
+- **Workato:** Workato documents a commercial recipe service with on-prem agents that connect private resources to Workato.
+- **UiPath:** UiPath documents both UiPath-managed cloud deployment and organization-hosted Automation Suite deployment.
+
+For a deeper license comparison, see [Apache 2.0 vs Fair-Code Licenses for AI Agent Platforms](https://www.sim.ai/library/apache-2-0-vs-fair-code).
+
+## Choosing a platform when migrating from legacy automation
+
+Sim fits teams moving from legacy automation when the migration requires AI-native workflow design, visual collaboration, code extensibility, versioned deployment, operational evidence, and self-hosting flexibility.
+
+The right choice still depends on the legacy system and the workload:
+
+- Choose **Sim** when AI decisions and model calls are central, technical users need code blocks, operators need visual workflows and logs, and the organization values Apache 2.0 core code and self-hosting.
+- Choose **n8n** when connector-driven automation and a self-hosted, source-available deployment are central requirements.
+- Choose **Zapier** when a business team prioritizes a hosted SaaS automation experience and accepts a vendor-managed control plane.
+- Choose **Make** when visual data mapping and scenario-based SaaS automation are the primary requirements.
+- Choose **Workato** when a large enterprise already operates Workato recipes and needs integration governance across business systems.
+- Choose **UiPath** when desktop automation, attended or unattended robots, and an existing RPA estate remain central to the migration.
+
+Teams migrating from RPA should distinguish user-interface automation from API- and model-driven workflows. [AI Agents vs RPA: When to Use Each for Enterprise Automation](https://www.sim.ai/library/ai-agents-vs-rpa) explains where each approach fits. Teams evaluating release controls can use [AI Agent Version Control and Rollback: Platforms, Process, and Enterprise Checklist](https://www.sim.ai/library/ai-agent-version-control-rollback-platforms), while teams defining run evidence and incident signals can use [What Is AI Agent Observability? Traces, Metrics, and Evals Explained](https://www.sim.ai/library/ai-agent-observability).
+
+## Migration proof to require before retiring a legacy script
+
+A new workflow should replace a legacy script only after it demonstrates equivalent outputs, controlled failure behavior, attributable credentials, observable runs, and a tested rollback path.
+
+Require evidence for each of these checks:
+
+| Check | Evidence required before cutover |
+|---|---|
+| Ownership | Named business owner and technical operator |
+| Functional parity | Old and new outputs compared across representative inputs |
+| Failure behavior | Tests for timeouts, rate limits, malformed data, and downstream outages |
+| Retry safety | Proof that repeated runs do not duplicate irreversible actions |
+| Credential governance | Shared credential owner, least-privilege scope, and rotation plan |
+| Human control | Approval before defined high-impact actions |
+| Observability | Run history, step-level evidence, alert destination, and retention policy |
+| Release control | Named deployed version and documented rollback procedure |
+| Retirement | Old trigger disabled and obsolete credentials revoked |
+
+A successful migration is not measured only by whether the happy path runs. It is measured by whether another operator can understand, recover, and safely change the automation without relying on the original script author.
diff --git a/apps/sim/executor/execution/engine.test.ts b/apps/sim/executor/execution/engine.test.ts
index 9bef693a364..2832281fd2a 100644
--- a/apps/sim/executor/execution/engine.test.ts
+++ b/apps/sim/executor/execution/engine.test.ts
@@ -413,7 +413,7 @@ describe('ExecutionEngine', () => {
expect(nodeOrchestrator.executeNode).toHaveBeenCalledWith(context, 'both')
})
- it('records paused block completion before returning paused result', async () => {
+ it('records paused block completion and the paused block name before returning paused result', async () => {
const node = createMockNode('hitl', 'function')
const dag = createMockDAG([node])
const context = createMockContext({
@@ -441,6 +441,9 @@ describe('ExecutionEngine', () => {
const result = await engine.run('hitl')
expect(result.status).toBe('paused')
+ expect(result.pausePoints).toEqual([
+ expect.objectContaining({ contextId: 'pause-1', blockId: 'hitl', blockName: 'Block hitl' }),
+ ])
expect(nodeOrchestrator.handleNodeCompletion).toHaveBeenCalledWith(
context,
'hitl',
diff --git a/apps/sim/executor/execution/engine.ts b/apps/sim/executor/execution/engine.ts
index 092c830e2a6..a2db926f047 100644
--- a/apps/sim/executor/execution/engine.ts
+++ b/apps/sim/executor/execution/engine.ts
@@ -657,6 +657,7 @@ export class ExecutionEngine {
...capturePauseDisplay(pause, registry),
contextId: pause.contextId,
blockId: pause.blockId,
+ blockName: this.dag.nodes.get(pause.blockId)?.block.metadata?.name,
response: pause.response,
registeredAt: pause.timestamp,
resumeStatus: 'paused' as ResumeStatus,
diff --git a/apps/sim/executor/handlers/mothership/handler.ts b/apps/sim/executor/handlers/mothership/handler.ts
index 6c2cd963afc..c746f4e35f8 100644
--- a/apps/sim/executor/handlers/mothership/handler.ts
+++ b/apps/sim/executor/handlers/mothership/handler.ts
@@ -571,8 +571,9 @@ async function readMothershipExecuteResponse(
const { done, value } = await reader.read()
if (done) break
- buffer += decoder.decode(value, { stream: true })
- const lines = buffer.split('\n')
+ // `buffer` never holds a newline, so only the new text needs splitting.
+ const lines = decoder.decode(value, { stream: true }).split('\n')
+ lines[0] = buffer + lines[0]
buffer = lines.pop() ?? ''
for (const line of lines) {
await processLine(line)
@@ -700,8 +701,9 @@ function createMothershipStreamingExecution(
if (cancelled) return
if (done) break
- buffer += decoder.decode(value, { stream: true })
- const lines = buffer.split('\n')
+ // `buffer` never holds a newline, so only the new text needs splitting.
+ const lines = decoder.decode(value, { stream: true }).split('\n')
+ lines[0] = buffer + lines[0]
buffer = lines.pop() ?? ''
for (const line of lines) {
await processLine(line)
diff --git a/apps/sim/executor/types.ts b/apps/sim/executor/types.ts
index 6c384a38191..f54c45e6528 100644
--- a/apps/sim/executor/types.ts
+++ b/apps/sim/executor/types.ts
@@ -81,6 +81,12 @@ export type ResumeStatus = 'paused' | 'resumed' | 'failed' | 'queued' | 'resumin
export interface PausePoint {
contextId: string
blockId?: string
+ /**
+ * The paused block's name as the run executed it, recorded when the pause is captured.
+ * Points persisted before names were recorded lack it; readers name those from the run's
+ * deployment version instead of the execution snapshot.
+ */
+ blockName?: string
response: any
registeredAt: string
resumeStatus: ResumeStatus
diff --git a/apps/sim/hooks/queries/resume-execution.ts b/apps/sim/hooks/queries/resume-execution.ts
index 2930d9e5636..b5f1a6dbe6d 100644
--- a/apps/sim/hooks/queries/resume-execution.ts
+++ b/apps/sim/hooks/queries/resume-execution.ts
@@ -41,7 +41,6 @@ export interface ResumeQueueEntrySummary {
export interface PausePointWithQueue {
contextId: string
- triggerBlockId?: string
blockId?: string
response: any
registeredAt: string
@@ -51,6 +50,7 @@ export interface PausePointWithQueue {
resumeLinks?: ResumeLinks
queuePosition?: number | null
latestResumeEntry?: ResumeQueueEntrySummary | null
+ blockName?: string
parallelScope?: any
loopScope?: any
pauseKind?: 'human' | 'time'
@@ -73,7 +73,6 @@ export interface PausedExecutionSummary {
}
export interface PausedExecutionDetail extends PausedExecutionSummary {
- executionSnapshot: any
queue: ResumeQueueEntrySummary[]
}
@@ -118,6 +117,7 @@ export function useResumeExecutionDetail(workflowId: string, executionId: string
queryFn: async ({ signal }): Promise => {
const raw = await requestJson(resumeWorkflowExecutionContract, {
params: { workflowId, executionId },
+ query: { includeSnapshot: false },
signal,
})
// double-cast-allowed: contract models pause points as z.record; the resume UI uses the richer PausedExecutionDetail interface
diff --git a/apps/sim/lib/api/contracts/v2/workflows.ts b/apps/sim/lib/api/contracts/v2/workflows.ts
index ce9558a9b7e..1bd14229d26 100644
--- a/apps/sim/lib/api/contracts/v2/workflows.ts
+++ b/apps/sim/lib/api/contracts/v2/workflows.ts
@@ -2173,7 +2173,7 @@ const v2WorkflowRunPausePointSchema = z
.string()
.nullable()
.describe(
- 'Name of the block in the deployment version the run executed, or null for a manual run or when the version no longer exists.'
+ 'Name of the block as the run executed it. Null only for a point paused before names were recorded whose run was manual or whose deployment version no longer exists.'
),
kind: z
.enum(['human', 'time'])
diff --git a/apps/sim/lib/api/contracts/workflows.ts b/apps/sim/lib/api/contracts/workflows.ts
index b5eabc856fa..326ee0b79a1 100644
--- a/apps/sim/lib/api/contracts/workflows.ts
+++ b/apps/sim/lib/api/contracts/workflows.ts
@@ -6,6 +6,7 @@ import {
} from '@sim/workflow-types/workflow'
import { z } from 'zod'
import {
+ booleanQueryFlagSchema,
privateSecretProvenanceBundleSchema,
requiredFieldSchema,
workflowIdSchema,
@@ -442,6 +443,15 @@ export const resumeExecutionParamsSchema = z.object({
executionId: z.string().min(1),
})
+/**
+ * `includeSnapshot=false` leaves out the execution snapshot, which carries every
+ * block's output and can run to many megabytes. The resume page asks for that;
+ * API callers keep the documented default of receiving it.
+ */
+const resumeExecutionQuerySchema = z.object({
+ includeSnapshot: booleanQueryFlagSchema.optional().default(true),
+})
+
export const resumeExecutionContextParamsSchema = z.object({
workflowId: z.string().min(1),
executionId: z.string().min(1),
@@ -554,7 +564,8 @@ const pausedWorkflowExecutionsResponseSchema = z.object({
})
const pausedWorkflowExecutionDetailSchema = pausedWorkflowExecutionSummarySchema.extend({
- executionSnapshot: z.unknown(),
+ /** Present when the read asked for it; see {@link resumeExecutionQuerySchema}. */
+ executionSnapshot: z.unknown().optional(),
queue: z.array(z.record(z.string(), z.unknown())),
})
@@ -959,6 +970,7 @@ export const resumeWorkflowExecutionContract = defineRouteContract({
method: 'GET',
path: '/api/resume/[workflowId]/[executionId]',
params: resumeExecutionParamsSchema,
+ query: resumeExecutionQuerySchema,
response: {
mode: 'json',
schema: pausedWorkflowExecutionDetailSchema,
diff --git a/apps/sim/lib/catalog/application/list-registries.test.ts b/apps/sim/lib/catalog/application/list-registries.test.ts
index d5701c740f6..baf507b805a 100644
--- a/apps/sim/lib/catalog/application/list-registries.test.ts
+++ b/apps/sim/lib/catalog/application/list-registries.test.ts
@@ -36,6 +36,21 @@ describe('connector-type catalog', () => {
const fullPage = { detail: 'full' as const, limit: 100, offset: 0 }
+ it('keeps Search-only scopes out of the knowledge-base setup contract', async () => {
+ const { entries } = await listCatalogConnectorTypes.execute({
+ principal: session,
+ input: { workspaceId: WORKSPACE_ID, search: 'GitLab', ...fullPage },
+ })
+ const gitlab = entries.find((entry) => entry.connectorType === 'gitlab')
+ if (!gitlab || !('configFields' in gitlab)) throw new Error('Missing GitLab setup contract')
+ expect(gitlab.configFields.find((field) => field.id === 'project')?.required).toBe(true)
+ expect(
+ gitlab.configFields.filter((field) =>
+ ['scope', 'group', 'includeSubgroups'].includes(field.id)
+ )
+ ).toEqual([])
+ })
+
it('publishes the multi and canonical-pair config properties a caller cannot infer', async () => {
const { entries } = await listCatalogConnectorTypes.execute({
principal: session,
diff --git a/apps/sim/lib/catalog/projection/connector-type.ts b/apps/sim/lib/catalog/projection/connector-type.ts
index 1f65fc62c60..a5d7b5295bf 100644
--- a/apps/sim/lib/catalog/projection/connector-type.ts
+++ b/apps/sim/lib/catalog/projection/connector-type.ts
@@ -156,7 +156,7 @@ export function projectConnectorType(
description: meta.description,
version: meta.version,
auth: projectAuth(meta.auth),
- configFields: meta.configFields.map(projectConfigField),
+ configFields: meta.configFields.filter((field) => !field.searchOnly).map(projectConfigField),
supportsIncrementalSync: meta.supportsIncrementalSync === true,
tagDefinitions: (meta.tagDefinitions ?? []).map(projectTagDefinition),
}
diff --git a/apps/sim/lib/core/utils/sse.ts b/apps/sim/lib/core/utils/sse.ts
index b68af4bf783..871ad21b56c 100644
--- a/apps/sim/lib/core/utils/sse.ts
+++ b/apps/sim/lib/core/utils/sse.ts
@@ -166,8 +166,10 @@ export async function readSSELines(source: SSESource, options: ReadSSELinesOptio
const { done, value } = await readChunk()
- buffer += done ? decoder.decode() : decoder.decode(value, { stream: true })
- const lines = buffer.split('\n')
+ // `buffer` never holds a newline, so split only the new text: re-splitting
+ // the whole pending line on every chunk is quadratic in the event size.
+ const lines = (done ? decoder.decode() : decoder.decode(value, { stream: true })).split('\n')
+ lines[0] = buffer + lines[0]
buffer = done ? '' : (lines.pop() ?? '')
for (const rawLine of lines) {
diff --git a/apps/sim/lib/knowledge/__integration__/gitlab-group.integration.ts b/apps/sim/lib/knowledge/__integration__/gitlab-group.integration.ts
new file mode 100644
index 00000000000..e0cbc42dc4c
--- /dev/null
+++ b/apps/sim/lib/knowledge/__integration__/gitlab-group.integration.ts
@@ -0,0 +1,601 @@
+/** Real authorization, PostgreSQL, encryption, revision locks and HTTP provider responses. */
+
+import { writeFile } from 'node:fs/promises'
+import { createServer } from 'node:http'
+import type { Principal } from '@sim/auth/principal'
+import { db } from '@sim/db'
+import {
+ knowledgeBase,
+ knowledgeConnector,
+ member,
+ organization,
+ organizationSearchIntegration,
+ user,
+ workspace,
+} from '@sim/db/schema'
+import { deleteWorkspaceFixture } from '@sim/db/testing/workspace-fixtures'
+import { generateId } from '@sim/utils/id'
+import { eq, inArray } from 'drizzle-orm'
+import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest'
+
+const transport = vi.hoisted(() => ({ origin: '', paths: [] as string[] }))
+vi.mock('@/lib/core/security/input-validation.server', async (original) => {
+ const module = await original()
+ return {
+ ...module,
+ secureFetchWithValidation: async (url: string, options: RequestInit) => {
+ const target = new URL(url)
+ if (target.hostname !== 'gitlab.fixture.test')
+ throw new Error('Unexpected fixture destination')
+ transport.paths.push(target.pathname)
+ return fetch(`${transport.origin}${target.pathname}${target.search}`, options)
+ },
+ }
+})
+
+import { seedKnowledgeAclFixture } from '@/lib/knowledge/__integration__/seed-source-access-fixture'
+import { updateKnowledgeConnectorAccess } from '@/lib/knowledge/application/connector-access'
+import { createKnowledgeConnector } from '@/lib/knowledge/application/connectors'
+import {
+ readSearchSourcePermissions,
+ replaceSearchSourcePermissions,
+} from '@/lib/knowledge/application/source-permissions'
+import {
+ loadConnectorPermissionSnapshot,
+ readConnectorPermissionGrants,
+} from '@/lib/knowledge/connectors/permission-store'
+import { readLiveDocument, searchLiveKnowledge } from '@/lib/sim-search/live/application'
+import { decodeLiveReference } from '@/lib/sim-search/live/reference'
+import { ResolvedSecretTraceRegistry } from '@/executor/utils/resolved-secret-trace-registry'
+
+describe('GitLab group Search permission boundary', () => {
+ let ids: Awaited>
+ let sourceId: string
+ let legacyId: string
+ let moved = false
+ let failedDiscovery = false
+ let added = false
+ let confidential = false
+ let providerState = 'healthy'
+ const checks: string[] = []
+ const token = 'disposable-group-test-token'
+ const principal = (userId: string): Principal => ({
+ kind: 'personal_api_key',
+ userId,
+ keyId: 'group-test',
+ access: 'write',
+ })
+ const config = {
+ host: 'gitlab.fixture.test',
+ scope: 'group',
+ group: 'team',
+ contentTypes: 'issues',
+ }
+ const permissions = (revoke = false, namespace = 'team') => ({
+ provider: 'gitlab' as const,
+ userMapping: {
+ filename: 'users.csv',
+ content: `user_id,email\n1,${ids.aliceId}@fixture.test\n2,${ids.bobId}@fixture.test`,
+ },
+ projectPermissions: {
+ filename: 'permissions.csv',
+ content: `project_path,user_id\n${namespace}/a,${revoke ? 2 : 1}\n${namespace}/b,2${added ? `\n${namespace}/c,1` : ''}`,
+ },
+ })
+ const server = createServer((request, response) => {
+ const url = new URL(request.url ?? '/', 'http://fixture')
+ const path = decodeURIComponent(url.pathname)
+ const reply = (status: number, body: unknown, headers = {}) => {
+ response.writeHead(status, { 'content-type': 'application/json', ...headers })
+ response.end(JSON.stringify(body))
+ }
+ if (
+ request.headers['private-token'] !== token &&
+ request.headers.authorization !== `Bearer ${token}`
+ )
+ return reply(401, {})
+ if (providerState === 'revoked') return reply(401, {})
+ const namespace = providerState === 'renamed' ? 'renamed-team' : 'team'
+ if (path === '/api/v4/user') return reply(200, { id: 50, state: 'active', locked: false })
+ if (path === '/api/v4/groups/team' && providerState === 'renamed')
+ return reply(301, {}, { location: '/api/v4/groups/7' })
+ if (path === '/api/v4/groups/team' || path === '/api/v4/groups/7')
+ return reply(200, { id: 7, full_path: namespace })
+ if (path === '/api/v4/groups/7/projects') {
+ if (url.searchParams.get('with_shared') !== 'false') return reply(400, {})
+ const projects = [
+ { id: 11, path_with_namespace: `${namespace}/a` },
+ { id: 12, path_with_namespace: `${namespace}/b` },
+ ]
+ if (added) projects.push({ id: 13, path_with_namespace: `${namespace}/c` })
+ const page = url.searchParams.get('page') ?? '1'
+ if (page === '1')
+ return reply(200, projects.slice(0, 1), {
+ 'x-total': String(projects.length),
+ 'x-next-page': '2',
+ })
+ if (failedDiscovery) return reply(403, {})
+ return reply(200, projects.slice(1), {
+ 'x-total': String(projects.length),
+ 'x-next-page': '',
+ })
+ }
+ const match = path.match(/^\/api\/v4\/projects\/(11|12|13)(.*)$/)
+ if (!match) return reply(404, {})
+ const id = Number(match[1])
+ const projectPath =
+ id === 11
+ ? moved
+ ? 'outside/a'
+ : `${namespace}/a`
+ : id === 12
+ ? `${namespace}/b`
+ : `${namespace}/c`
+ const issue = (iid: number) => ({
+ project_id: id,
+ iid,
+ title: `Atlas ${id} ${iid}`,
+ description: `Atlas content ${id} ${iid}`,
+ confidential,
+ state: 'opened',
+ labels: [],
+ web_url: `https://gitlab.fixture.test/${projectPath}/-/issues/${iid}`,
+ })
+ if (!match[2])
+ return reply(200, {
+ id,
+ path_with_namespace: projectPath,
+ web_url: `https://gitlab.fixture.test/${projectPath}`,
+ })
+ if (match[2] === '/search') {
+ if (providerState === 'search-token-expired') return reply(401, {})
+ if (providerState === 'search-rate-limited') return reply(429, {}, { 'retry-after': '60' })
+ const page = Number(url.searchParams.get('page') ?? 1)
+ const size = Number(url.searchParams.get('per_page') ?? 20)
+ return reply(200, [issue(1), issue(2), issue(3)].slice((page - 1) * size, page * size))
+ }
+ const issueMatch = match[2]?.match(/^\/issues\/(\d+)$/)
+ if (issueMatch) return reply(200, issue(Number(issueMatch[1])))
+ if (match[2]?.endsWith('/notes')) return reply(200, [])
+ return reply(404, {})
+ })
+
+ const search = (
+ userId: string,
+ project?: string,
+ cursor?: string,
+ topK = 20,
+ accountId = sourceId
+ ) =>
+ searchLiveKnowledge.execute({
+ principal: principal(userId),
+ input: {
+ organizationId: ids.organizationId,
+ query: 'Atlas',
+ topK,
+ filters: { source: 'gitlab' },
+ nativeQueries: [
+ {
+ provider: 'gitlab',
+ query: 'Atlas',
+ kind: 'issues',
+ accountId: `gitlab-source:${accountId}`,
+ ...(project ? { project } : {}),
+ ...(cursor ? { cursor } : {}),
+ },
+ ],
+ resultSecretRegistry: new ResolvedSecretTraceRegistry(),
+ },
+ })
+ const read = (userId: string, documentId: string) =>
+ readLiveDocument.execute({
+ principal: principal(userId),
+ input: {
+ organizationId: ids.organizationId,
+ documentId,
+ limit: 3,
+ resultSecretRegistry: new ResolvedSecretTraceRegistry(),
+ },
+ })
+ const replace = (revision: number, revoke = false) =>
+ replaceSearchSourcePermissions.execute({
+ principal: principal(ids.aliceId),
+ input: {
+ organizationId: ids.organizationId,
+ sourceId,
+ expectedRevision: revision,
+ permissions: permissions(revoke),
+ },
+ })
+
+ beforeAll(async () => {
+ await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve))
+ const address = server.address()
+ if (!address || typeof address === 'string') throw new Error('Missing fixture address')
+ transport.origin = `http://127.0.0.1:${address.port}`
+ ids = await seedKnowledgeAclFixture()
+ await db.delete(knowledgeConnector).where(eq(knowledgeConnector.id, ids.connectorId))
+ await db
+ .update(knowledgeBase)
+ .set({ workspaceId: null, organizationId: ids.organizationId, isSearchIndex: true })
+ .where(eq(knowledgeBase.id, ids.knowledgeBaseId))
+ await db.insert(member).values(
+ [ids.aliceId, ids.bobId].map((id) => ({
+ id: generateId(),
+ organizationId: ids.organizationId,
+ userId: id,
+ role: id === ids.aliceId ? 'owner' : 'member',
+ createdAt: new Date(),
+ }))
+ )
+ await db
+ .insert(organizationSearchIntegration)
+ .values({ organizationId: ids.organizationId, connectorType: 'gitlab', approved: true })
+ const create = (sourceConfig: Record) =>
+ createKnowledgeConnector.execute({
+ principal: principal(ids.aliceId),
+ input: {
+ knowledgeBaseId: ids.knowledgeBaseId,
+ assertedOrganizationId: ids.organizationId,
+ connectorType: 'gitlab',
+ accessMode: 'admin',
+ apiKey: token,
+ sourceConfig,
+ permissionConfig: { ...permissions(), mode: 'csv' },
+ syncIntervalMinutes: 60,
+ },
+ })
+ legacyId = (await create({ host: config.host, project: '11', contentTypes: 'issues' }))
+ .connector.id
+ sourceId = (await create(config)).connector.id
+ }, 60000)
+
+ afterAll(async () => {
+ if (process.env.GITLAB_GROUP_REPORT_PATH)
+ await writeFile(
+ process.env.GITLAB_GROUP_REPORT_PATH,
+ JSON.stringify(
+ {
+ boundary:
+ 'Application use cases, real PostgreSQL and HTTP GitLab API fixture; TLS/SSRF transport substituted',
+ checks,
+ passed: checks.length === 10,
+ },
+ null,
+ 2
+ )
+ )
+ server.closeAllConnections()
+ await new Promise((resolve) => server.close(() => resolve()))
+ if (ids) {
+ await deleteWorkspaceFixture(db, eq(workspace.id, ids.workspaceId))
+ await db.delete(organization).where(eq(organization.id, ids.organizationId))
+ await db.delete(user).where(inArray(user.id, [ids.aliceId, ids.bobId]))
+ }
+ await db.$client.end()
+ })
+
+ it('keeps connection settings usable without scheduling ingestion or bypassing permission scope', async () => {
+ const update = (sourceConfig?: Record) =>
+ updateKnowledgeConnectorAccess.execute({
+ principal: { kind: 'session', userId: ids.aliceId, sessionId: 'fixture-session' },
+ input: {
+ knowledgeBaseId: ids.knowledgeBaseId,
+ connectorId: sourceId,
+ assertedOrganizationId: ids.organizationId,
+ accessMode: 'admin',
+ ...(sourceConfig ? { sourceConfig } : {}),
+ },
+ })
+ expect((await update()).changed).toBe(false)
+ await update({ ...config, group: '%74eam', issueState: 'opened' })
+ const [saved] = await db
+ .select()
+ .from(knowledgeConnector)
+ .where(eq(knowledgeConnector.id, sourceId))
+ expect(saved?.nextSyncAt).toBeNull()
+ expect(saved?.nextMemberSyncAt).toBeNull()
+ for (const state of ['revoked', 'renamed']) {
+ providerState = state
+ try {
+ await expect(update()).rejects.toMatchObject({ code: 'validation' })
+ } finally {
+ providerState = 'healthy'
+ }
+ }
+
+ for (const changedScope of [
+ { ...config, group: 'another-group' },
+ { ...config, includeSubgroups: 'true' },
+ { host: config.host, scope: 'project', project: '11' },
+ ]) {
+ await expect(update(changedScope)).rejects.toMatchObject({ code: 'validation' })
+ }
+ const [unchanged] = await db
+ .select()
+ .from(knowledgeConnector)
+ .where(eq(knowledgeConnector.id, sourceId))
+ expect(unchanged).toEqual(saved)
+ expect(
+ await readSearchSourcePermissions.execute({
+ principal: principal(ids.aliceId),
+ input: { organizationId: ids.organizationId, sourceId },
+ })
+ ).toEqual({ revision: 1 })
+ expect((await search(ids.aliceId)).results.length).toBeGreaterThan(0)
+ checks.push('Connection settings preserve live-only scheduling and canonical permission scope')
+ })
+
+ it('rejects dot-segment group identifiers before sending the token', async () => {
+ for (const group of ['.', '..', '%2e', '%2e%2e', '.%2e', '%2e.']) {
+ const requests = transport.paths.length
+ await expect(
+ createKnowledgeConnector.execute({
+ principal: principal(ids.aliceId),
+ input: {
+ knowledgeBaseId: ids.knowledgeBaseId,
+ assertedOrganizationId: ids.organizationId,
+ connectorType: 'gitlab',
+ accessMode: 'admin',
+ apiKey: token,
+ sourceConfig: { ...config, group },
+ permissionConfig: { ...permissions(), mode: 'csv' },
+ syncIntervalMinutes: 60,
+ },
+ })
+ ).rejects.toMatchObject({ code: 'validation' })
+ expect(transport.paths).toHaveLength(requests)
+ }
+ checks.push('Invalid group IDs fail before provider requests')
+ })
+
+ it('separates readers by project and rejects cross-project reads', async () => {
+ const alice = await search(ids.aliceId)
+ const bob = await search(ids.bobId)
+ expect(alice.results.length).toBeGreaterThan(0)
+ expect(bob.results.length).toBeGreaterThan(0)
+ expect(
+ new Set(alice.results.map((row) => decodeLiveReference(row.documentId).container))
+ ).toEqual(new Set(['11']))
+ expect(
+ new Set(bob.results.map((row) => decodeLiveReference(row.documentId).container))
+ ).toEqual(new Set(['12']))
+ const first = alice.results[0]
+ if (!first) throw new Error('Missing allowed fixture result')
+ expect((await read(ids.aliceId, first.documentId)).chunks.length).toBeGreaterThan(0)
+ await expect(read(ids.bobId, first.documentId)).rejects.toMatchObject({ code: 'not_found' })
+ expect((await search(ids.aliceId, '12')).results).toEqual([])
+ expect((await search(ids.aliceId, '99')).results).toEqual([])
+ confidential = true
+ expect((await search(ids.aliceId)).results).toEqual([])
+ await expect(read(ids.aliceId, first.documentId)).rejects.toMatchObject({ code: 'not_found' })
+ confidential = false
+ moved = true
+ expect((await search(ids.aliceId)).results).toEqual([])
+ moved = false
+ for (const [state, status] of [
+ ['search-token-expired', 'reconnect'],
+ ['search-rate-limited', 'rate_limited'],
+ ]) {
+ providerState = state
+ const requests = transport.paths.length
+ try {
+ const failed = await search(ids.aliceId)
+ expect(failed.results).toEqual([])
+ expect(failed.live?.accounts[0]?.status).toBe(status)
+ expect(
+ transport.paths.slice(requests).filter((path) => path.endsWith('/search'))
+ ).toHaveLength(1)
+ } finally {
+ providerState = 'healthy'
+ }
+ }
+ checks.push('Per-project identity, reference, confidentiality and moved-project isolation')
+ })
+
+ it('atomically discovers new projects and enforces revocation without touching the existing source', async () => {
+ const initial = await search(ids.aliceId)
+ const first = initial.results[0]
+ if (!first) throw new Error('Missing allowed fixture result')
+ const [legacy] = await db
+ .select()
+ .from(knowledgeConnector)
+ .where(eq(knowledgeConnector.id, legacyId))
+ added = true
+ expect(await replace(1, true)).toEqual({ revision: 2 })
+ expect(
+ await readConnectorPermissionGrants(
+ sourceId,
+ 1,
+ ['project:11'],
+ `u:${ids.bobId}@fixture.test`
+ )
+ ).toEqual(new Set())
+ expect(
+ await readConnectorPermissionGrants(
+ sourceId,
+ 2,
+ ['project:11'],
+ `u:${ids.bobId}@fixture.test`
+ )
+ ).toEqual(new Set(['project:11']))
+ expect((await search(ids.aliceId, '13')).results.length).toBeGreaterThan(0)
+ expect((await search(ids.aliceId, '11')).results).toEqual([])
+ await expect(read(ids.aliceId, first.documentId)).rejects.toMatchObject({ code: 'not_found' })
+ expect((await search(ids.bobId, '11')).results.length).toBeGreaterThan(0)
+ const [unchanged] = await db
+ .select()
+ .from(knowledgeConnector)
+ .where(eq(knowledgeConnector.id, legacyId))
+ expect(unchanged).toEqual(legacy)
+ const legacyRevision = await readSearchSourcePermissions.execute({
+ principal: principal(ids.aliceId),
+ input: { organizationId: ids.organizationId, sourceId: legacyId },
+ })
+ expect(legacyRevision).toEqual({ revision: 1 })
+ expect(
+ (await search(ids.aliceId, '11', undefined, 20, legacyId)).results.length
+ ).toBeGreaterThan(0)
+ await replaceSearchSourcePermissions.execute({
+ principal: principal(ids.aliceId),
+ input: {
+ organizationId: ids.organizationId,
+ sourceId: legacyId,
+ expectedRevision: 1,
+ permissions: permissions(true),
+ },
+ })
+ expect((await search(ids.aliceId, '11', undefined, 20, legacyId)).results).toEqual([])
+ expect((await search(ids.bobId, '11', undefined, 20, legacyId)).results.length).toBeGreaterThan(
+ 0
+ )
+ expect(
+ await readSearchSourcePermissions.execute({
+ principal: principal(ids.aliceId),
+ input: {
+ organizationId: ids.organizationId,
+ sourceId,
+ },
+ })
+ ).toEqual({ revision: 2 })
+ checks.push('Atomic group refresh, revocation and existing source preservation')
+ })
+
+ it('preserves all grants on discovery failure and admits only one concurrent revision', async () => {
+ failedDiscovery = true
+ await expect(replace(2)).rejects.toMatchObject({ code: 'validation' })
+ failedDiscovery = false
+ expect((await search(ids.bobId, '11')).results.length).toBeGreaterThan(0)
+ const results = await Promise.allSettled([replace(2), replace(2)])
+ expect(results.filter((row) => row.status === 'fulfilled')).toHaveLength(1)
+ expect(results.filter((row) => row.status === 'rejected')).toHaveLength(1)
+ expect(results.find((row) => row.status === 'rejected')).toMatchObject({
+ reason: { code: 'conflict' },
+ })
+ expect(results.find((row) => row.status === 'fulfilled')).toMatchObject({
+ value: { revision: 3 },
+ })
+ expect(
+ await readSearchSourcePermissions.execute({
+ principal: principal(ids.aliceId),
+ input: {
+ organizationId: ids.organizationId,
+ sourceId,
+ },
+ })
+ ).toEqual({ revision: 3 })
+ checks.push('Failure atomicity and concurrent revision protection')
+ })
+
+ it('continues through all permitted project pages without gaps and rejects stale cursors', async () => {
+ const documents: string[] = []
+ let cursor: string | undefined
+ let firstCursor: string | undefined
+ for (let page = 0; page < 10; page += 1) {
+ const result = await search(ids.aliceId, undefined, cursor, 2)
+ for (const row of result.results) {
+ const ref = decodeLiveReference(row.documentId)
+ documents.push(`${ref.container}:${ref.id}`)
+ }
+ cursor = result.live?.accounts[0]?.nextCursor
+ firstCursor ??= cursor
+ if (!cursor) break
+ }
+ expect(documents.sort()).toEqual(['11:1', '11:2', '11:3', '13:1', '13:2', '13:3'])
+ expect(firstCursor).toBeTruthy()
+ await replace(3)
+ const stale = await search(ids.aliceId, undefined, firstCursor, 2)
+ expect(stale.results).toEqual([])
+ expect(stale.live?.accounts[0]?.status).not.toBe('ok')
+ checks.push('Complete bounded pagination and stale continuation rejection')
+ })
+
+ it('rejects group scope for ordinary knowledge base ingestion', async () => {
+ const knowledgeBaseId = generateId()
+ await db.insert(knowledgeBase).values({
+ id: knowledgeBaseId,
+ userId: ids.aliceId,
+ workspaceId: ids.workspaceId,
+ name: 'Ordinary KB fixture',
+ })
+ await expect(
+ createKnowledgeConnector.execute({
+ principal: principal(ids.aliceId),
+ input: {
+ knowledgeBaseId,
+ assertedWorkspaceId: ids.workspaceId,
+ connectorType: 'gitlab',
+ accessMode: 'admin',
+ apiKey: token,
+ sourceConfig: config,
+ permissionConfig: { ...permissions(), mode: 'csv' },
+ syncIntervalMinutes: 60,
+ },
+ })
+ ).rejects.toMatchObject({ code: 'validation' })
+ checks.push('Search-only group scope and unchanged knowledge base ingestion')
+ })
+
+ it('keeps group updates restricted to organization admins', async () => {
+ await expect(
+ replaceSearchSourcePermissions.execute({
+ principal: principal(ids.bobId),
+ input: {
+ organizationId: ids.organizationId,
+ sourceId,
+ expectedRevision: 4,
+ permissions: permissions(),
+ },
+ })
+ ).rejects.toMatchObject({ code: 'forbidden' })
+ checks.push('Organization administration boundary')
+ })
+
+ it.each(['team', '7'])(
+ 'refreshes renamed groups only when saved scope %s still matches',
+ async (group) => {
+ const { connector } = await createKnowledgeConnector.execute({
+ principal: principal(ids.aliceId),
+ input: {
+ knowledgeBaseId: ids.knowledgeBaseId,
+ assertedOrganizationId: ids.organizationId,
+ connectorType: 'gitlab',
+ accessMode: 'admin',
+ apiKey: token,
+ sourceConfig: { ...config, group },
+ permissionConfig: { ...permissions(), mode: 'csv' },
+ syncIntervalMinutes: 60,
+ },
+ })
+ const before = await loadConnectorPermissionSnapshot(connector.id)
+ providerState = 'renamed'
+ try {
+ const refresh = replaceSearchSourcePermissions.execute({
+ principal: principal(ids.aliceId),
+ input: {
+ organizationId: ids.organizationId,
+ sourceId: connector.id,
+ expectedRevision: 1,
+ permissions: permissions(false, 'renamed-team'),
+ },
+ })
+ if (group === 'team') {
+ await expect(refresh).rejects.toMatchObject({ code: 'validation' })
+ expect(await loadConnectorPermissionSnapshot(connector.id)).toEqual(before)
+ providerState = 'healthy'
+ } else {
+ expect(await refresh).toEqual({ revision: 2 })
+ }
+ const results = (await search(ids.aliceId, '11', undefined, 20, connector.id)).results
+ expect(results.length).toBeGreaterThan(0)
+ const first = results[0]
+ if (!first) throw new Error('Missing allowed fixture result')
+ expect((await read(ids.aliceId, first.documentId)).chunks.length).toBeGreaterThan(0)
+ expect((await search(ids.bobId, '11', undefined, 20, connector.id)).results).toEqual([])
+ checks.push(`Renamed group refresh preserves permissions for configured scope ${group}`)
+ } finally {
+ providerState = 'healthy'
+ }
+ }
+ )
+})
diff --git a/apps/sim/lib/knowledge/application/connector-access.ts b/apps/sim/lib/knowledge/application/connector-access.ts
index 55d76f03c1c..13ab39ccb0b 100644
--- a/apps/sim/lib/knowledge/application/connector-access.ts
+++ b/apps/sim/lib/knowledge/application/connector-access.ts
@@ -292,6 +292,7 @@ export const updateKnowledgeConnectorAccess = defineAuthorizedKnowledgeUseCase({
accessMode: 'members',
})
const rejection = await validateConnectorSourceConfig({
+ isSearchIndex: context.knowledgeBase.isSearchIndex === true,
principal,
connector: { ...connector, accessMode: 'members', credentialId },
sourceConfig,
@@ -324,6 +325,7 @@ export const updateKnowledgeConnectorAccess = defineAuthorizedKnowledgeUseCase({
}),
}
const rejection = await validateConnectorSourceConfig({
+ isSearchIndex: context.knowledgeBase.isSearchIndex === true,
principal,
connector: {
...connector,
@@ -347,7 +349,12 @@ export const updateKnowledgeConnectorAccess = defineAuthorizedKnowledgeUseCase({
}
const outcome = await performUpdateKnowledgeConnectorAccess({
- knowledgeBase: { id: context.knowledgeBaseId, name: context.knowledgeBase.name, ...owner },
+ knowledgeBase: {
+ id: context.knowledgeBaseId,
+ name: context.knowledgeBase.name,
+ isSearchIndex: context.knowledgeBase.isSearchIndex === true,
+ ...owner,
+ },
connectorId: context.connectorId,
target,
sourceConfig: input.sourceConfig === undefined ? undefined : sourceConfig,
diff --git a/apps/sim/lib/knowledge/application/connectors.test.ts b/apps/sim/lib/knowledge/application/connectors.test.ts
index ed8162baf23..050860e7813 100644
--- a/apps/sim/lib/knowledge/application/connectors.test.ts
+++ b/apps/sim/lib/knowledge/application/connectors.test.ts
@@ -456,6 +456,7 @@ describe('knowledge connector application use cases', () => {
} as Parameters[0]['connector']
await expect(
validateConnectorSourceConfig({
+ isSearchIndex: false,
principal: createSessionPrincipal({ userId: 'admin', sessionId: 'session' }),
connector,
sourceConfig: { adminEmail: 'admin@corp.com' },
@@ -519,6 +520,7 @@ describe('knowledge connector application use cases', () => {
mocks.validateConnectorConfig.mockResolvedValueOnce({ valid: false, error: message })
}
const result = validateConnectorSourceConfig({
+ isSearchIndex: false,
principal: patPrincipal,
requestId: 'request',
workspaceId: 'workspace-b',
@@ -1122,6 +1124,7 @@ describe('organization connector credential authorization', () => {
mocks.validateConnectorConfig.mockResolvedValueOnce({ valid: false, error: message })
}
const result = validateConnectorSourceConfig({
+ isSearchIndex: false,
principal,
requestId: 'request',
organizationId: 'org',
diff --git a/apps/sim/lib/knowledge/application/connectors.ts b/apps/sim/lib/knowledge/application/connectors.ts
index d98fb353444..2257159bad0 100644
--- a/apps/sim/lib/knowledge/application/connectors.ts
+++ b/apps/sim/lib/knowledge/application/connectors.ts
@@ -392,6 +392,7 @@ export async function validateConnectorSourceConfig(input: {
actingUserId: string
requestId: string
permissionChange?: PreparedConnectorPermissions
+ isSearchIndex: boolean
}): Promise {
const accessMode = input.connector.accessMode
if (!isConnectorAccessMode(accessMode)) {
@@ -485,6 +486,7 @@ export async function validateConnectorSourceConfig(input: {
const validationContext = {
...syncContextForToken(resolved),
+ isSearchIndex: input.isSearchIndex === true,
mirrorsSourceAcls: mirrorsSourceAcls(input.connector.accessMode),
...(input.connector.accessMode === 'members' ? PER_MEMBER_LISTING_CONTEXT : {}),
}
@@ -829,6 +831,7 @@ async function executeCreateKnowledgeConnector({
const apiKey = await resolveConnectorApiKey(input.apiKey, principal, workspaceId)
const permissionChange = input.permissionConfig
? await prepareConnectorPermissions(input.connectorType, {
+ isSearchIndex: context.knowledgeBase.isSearchIndex === true,
accessMode: input.accessMode ?? 'workspace',
sourceConfig,
permissionConfig: input.permissionConfig,
@@ -965,6 +968,7 @@ export const updateKnowledgeConnector = defineAuthorizedKnowledgeUseCase({
if (!connector) throw new OrchestrationError('not_found', 'Connector not found')
expectedUpdatedAt = connector.updatedAt
permissionChange = await prepareConnectorPermissions(connector.connectorType, {
+ isSearchIndex: context.knowledgeBase.isSearchIndex === true,
accessMode: connector.accessMode,
sourceConfig: updates.sourceConfig ?? (connector.sourceConfig as Record),
permissionConfig,
@@ -1018,6 +1022,7 @@ export const updateKnowledgeConnector = defineAuthorizedKnowledgeUseCase({
validateSourceConfig: (connector, sourceConfig) => {
const owner = resourceScopeFields(resourceScopeFromOwner(context))
return validateConnectorSourceConfig({
+ isSearchIndex: context.knowledgeBase.isSearchIndex === true,
principal,
connector: permissionChange?.encryptedApiKey
? { ...connector, encryptedApiKey: permissionChange.encryptedApiKey }
diff --git a/apps/sim/lib/knowledge/application/source-permissions.ts b/apps/sim/lib/knowledge/application/source-permissions.ts
index 4c82b5031e7..002e3d138f9 100644
--- a/apps/sim/lib/knowledge/application/source-permissions.ts
+++ b/apps/sim/lib/knowledge/application/source-permissions.ts
@@ -66,6 +66,8 @@ async function readPermissionSource({ organizationId, sourceId }: SourceInput) {
connectorType: knowledgeConnector.connectorType,
revision: snapshot.revision,
metadata: snapshot.metadata,
+ sourceConfig: knowledgeConnector.sourceConfig,
+ encryptedApiKey: knowledgeConnector.encryptedApiKey,
})
.from(knowledgeConnector)
.innerJoin(knowledgeBase, eq(knowledgeBase.id, knowledgeConnector.knowledgeBaseId))
@@ -100,7 +102,7 @@ export const replaceSearchSourcePermissions = defineAuthorizedOrganizationUseCas
'The permissions must match the configured source provider.'
)
}
- const prepared = source.replacement.prepare(source, expectedRevision, permissions)
+ const prepared = await source.replacement.prepare(source, expectedRevision, permissions, source)
const revision = await db.transaction(async (tx) => {
await lockOrganizationSearchApproval(tx, organizationId)
await authorizeOrganizationOperation(
diff --git a/apps/sim/lib/knowledge/connectors/permission-config.ts b/apps/sim/lib/knowledge/connectors/permission-config.ts
index d38cd24b318..214b5516ae0 100644
--- a/apps/sim/lib/knowledge/connectors/permission-config.ts
+++ b/apps/sim/lib/knowledge/connectors/permission-config.ts
@@ -14,6 +14,7 @@ export type ConnectorPermissionConfig = { provider: 'gitlab' } & GitLabPermissio
export type ConnectorPermissionSummary = { provider: 'gitlab' } & GitLabPermissionSummary
export interface PrepareConnectorPermissionsInput {
+ isSearchIndex?: boolean
accessMode: string
sourceConfig: Record
permissionConfig?: ConnectorPermissionConfig
@@ -41,8 +42,9 @@ export interface ConnectorPermissionConfigCapability {
prepare(
snapshot: Pick,
expectedRevision: number,
- permissions: ConnectorPermissionGrants
- ): ConnectorPermissionData
+ permissions: ConnectorPermissionGrants,
+ source: { sourceConfig: unknown; encryptedApiKey: string | null }
+ ): ConnectorPermissionData | Promise
}
prepare(
input: PrepareConnectorPermissionsInput
diff --git a/apps/sim/lib/knowledge/connectors/permission-store.ts b/apps/sim/lib/knowledge/connectors/permission-store.ts
index 3979a617dc3..88978b611ad 100644
--- a/apps/sim/lib/knowledge/connectors/permission-store.ts
+++ b/apps/sim/lib/knowledge/connectors/permission-store.ts
@@ -37,6 +37,34 @@ export async function hasConnectorPermissionGrant(
return Boolean(grant)
}
+/** Returns grants only for the bounded, canonical collections requested by the authorized caller. */
+export async function readConnectorPermissionGrants(
+ connectorId: string,
+ expectedRevision: number,
+ groupKeys: readonly string[],
+ subjectToken: string
+): Promise> {
+ const table = knowledgeConnectorPermissionGrant
+ const snapshot = knowledgeConnectorPermissionSnapshot
+ const keys = new Set()
+ for (let offset = 0; offset < groupKeys.length; offset += 1000) {
+ const rows = await db
+ .select({ groupKey: table.groupKey })
+ .from(table)
+ .innerJoin(snapshot, eq(snapshot.connectorId, table.connectorId))
+ .where(
+ and(
+ eq(table.connectorId, connectorId),
+ eq(snapshot.revision, expectedRevision),
+ eq(table.subjectToken, subjectToken),
+ inArray(table.groupKey, groupKeys.slice(offset, offset + 1000))
+ )
+ )
+ for (const row of rows) keys.add(row.groupKey)
+ }
+ return keys
+}
+
/** Call only after authorizing the connector; this materializes its private normalized input. */
export async function loadConnectorPermissionSnapshot(connectorId: string) {
const [row] = await db
@@ -98,17 +126,17 @@ export async function writeConnectorPermissions(
await tx
.delete(knowledgeConnectorPermissionGrant)
.where(eq(knowledgeConnectorPermissionGrant.connectorId, connectorId))
+ let batch: Array = []
for (const group of input.groups) {
- for (let offset = 0; offset < group.subjects.length; offset += 1000) {
- await tx
- .insert(knowledgeConnectorPermissionGrant)
- .values(
- group.subjects
- .slice(offset, offset + 1000)
- .map((subjectToken) => ({ connectorId, groupKey: group.groupKey, subjectToken }))
- )
+ for (const subjectToken of group.subjects) {
+ batch.push({ connectorId, groupKey: group.groupKey, subjectToken })
+ if (batch.length === 1000) {
+ await tx.insert(knowledgeConnectorPermissionGrant).values(batch)
+ batch = []
+ }
}
}
+ if (batch.length) await tx.insert(knowledgeConnectorPermissionGrant).values(batch)
} catch {
/** Query exceptions may contain bind parameters from the private payload. */
throw new OrchestrationError(
diff --git a/apps/sim/lib/knowledge/orchestration/connector-access.ts b/apps/sim/lib/knowledge/orchestration/connector-access.ts
index 0ad4ff6a248..5bc48fe2946 100644
--- a/apps/sim/lib/knowledge/orchestration/connector-access.ts
+++ b/apps/sim/lib/knowledge/orchestration/connector-access.ts
@@ -192,7 +192,13 @@ export type ConnectorAccessTarget =
| { accessMode: ContentEngineAccessMode; credentialId: string | null }
export interface PerformUpdateKnowledgeConnectorAccessParams extends KnowledgeOperationContext {
- knowledgeBase: { id: string; name: string; workspaceId?: string; organizationId?: string }
+ knowledgeBase: {
+ id: string
+ name: string
+ workspaceId?: string
+ organizationId?: string
+ isSearchIndex?: boolean
+ }
connectorId: string
target: ConnectorAccessTarget
sourceConfig?: Record
diff --git a/apps/sim/lib/knowledge/orchestration/connectors.test.ts b/apps/sim/lib/knowledge/orchestration/connectors.test.ts
index cd36618dd2b..2c1a68159c3 100644
--- a/apps/sim/lib/knowledge/orchestration/connectors.test.ts
+++ b/apps/sim/lib/knowledge/orchestration/connectors.test.ts
@@ -251,9 +251,13 @@ describe('performCreateKnowledgeConnector', () => {
success: true,
connector: { connectorType: 'github', credentialId: null },
})
- expect(mockValidateGitHub).toHaveBeenCalledWith('personal-token', sourceConfig, {
- mirrorsSourceAcls: false,
- })
+ expect(mockValidateGitHub).toHaveBeenCalledWith(
+ 'personal-token',
+ sourceConfig,
+ expect.objectContaining({
+ mirrorsSourceAcls: false,
+ })
+ )
expect(mockEncryptApiKey).toHaveBeenCalledWith('personal-token')
expect(createParams.resolveAccessToken).not.toHaveBeenCalled()
expect(dbChainMockFns.values).toHaveBeenCalledWith(
diff --git a/apps/sim/lib/knowledge/orchestration/connectors.ts b/apps/sim/lib/knowledge/orchestration/connectors.ts
index a8c0e49e30b..1602c4cfe66 100644
--- a/apps/sim/lib/knowledge/orchestration/connectors.ts
+++ b/apps/sim/lib/knowledge/orchestration/connectors.ts
@@ -363,6 +363,7 @@ export async function performCreateKnowledgeConnector(
if (accessToken !== null) {
const validationContext = {
...tokenContext,
+ isSearchIndex: kb.isSearchIndex === true,
mirrorsSourceAcls: accessMode === 'admin',
...(accessMode === 'members' ? PER_MEMBER_LISTING_CONTEXT : {}),
}
diff --git a/apps/sim/lib/sim-search/connection-labels.ts b/apps/sim/lib/sim-search/connection-labels.ts
index da7ee159a52..8edecb96218 100644
--- a/apps/sim/lib/sim-search/connection-labels.ts
+++ b/apps/sim/lib/sim-search/connection-labels.ts
@@ -25,10 +25,10 @@ const CONNECTION_LABELS: Record = {
searchPlaceholder: 'Search GitHub repositories...',
},
gitlab: {
- add: 'Add project',
- title: 'Add GitLab project',
- empty: 'No GitLab projects added.',
- searchPlaceholder: 'Search GitLab projects...',
+ add: 'Add connection',
+ title: 'Connect GitLab',
+ empty: 'No GitLab connections added.',
+ searchPlaceholder: 'Search GitLab connections...',
},
slack: {
add: 'Add channels or DMs',
diff --git a/apps/sim/lib/sim-search/live/gitlab-admin.test.ts b/apps/sim/lib/sim-search/live/gitlab-admin.test.ts
index 5cbcb7d9674..0c3f73b1760 100644
--- a/apps/sim/lib/sim-search/live/gitlab-admin.test.ts
+++ b/apps/sim/lib/sim-search/live/gitlab-admin.test.ts
@@ -22,7 +22,7 @@ const mocks = vi.hoisted(() => ({
}))
vi.mock('@/lib/knowledge/access/scope', () => knowledgeAccessScopeMock)
vi.mock('@/connectors/gitlab/permission-config/repository', () => ({
- seedGitLabCsvContext: mocks.seed,
+ seedGitLabPermissionContext: mocks.seed,
}))
vi.mock('@/lib/knowledge/connectors/permission-store', () => ({
hasConnectorPermissionGrant: mocks.grant,
diff --git a/apps/sim/lib/sim-search/live/gitlab-admin.ts b/apps/sim/lib/sim-search/live/gitlab-admin.ts
index 5f9b8075314..8b95c69b2a6 100644
--- a/apps/sim/lib/sim-search/live/gitlab-admin.ts
+++ b/apps/sim/lib/sim-search/live/gitlab-admin.ts
@@ -6,21 +6,36 @@ import { type ResourceOwner, resourceScopeFromOwner } from '@/lib/core/resource-
import { resourceScopeCondition } from '@/lib/core/resource-scope.server'
import { createUserKnowledgeAccessProvider } from '@/lib/knowledge/access/scope'
import { groupToken } from '@/lib/knowledge/access/tokens'
-import { hasConnectorPermissionGrant } from '@/lib/knowledge/connectors/permission-store'
+import {
+ hasConnectorPermissionGrant,
+ readConnectorPermissionGrants,
+ readConnectorPermissionMetadata,
+} from '@/lib/knowledge/connectors/permission-store'
import { searchIntegrationAccessCondition } from '@/lib/knowledge/search/integration-policy'
import { readGitLab, searchGitLab } from '@/lib/sim-search/live/gitlab'
import { array, NativeSearchError, object, segment, string } from '@/lib/sim-search/live/http'
-import { collectNativePages } from '@/lib/sim-search/live/pages'
+import { collectNativePages, joinMessages } from '@/lib/sim-search/live/pages'
import type {
LiveAccount,
NativeClient,
NativeDocument,
+ NativePage,
NativeSearchInput,
} from '@/lib/sim-search/live/types'
-import { seedGitLabCsvContext } from '@/connectors/gitlab/permission-config/repository'
import {
+ type GitLabGroupScope,
+ gitLabGroupMatchesConfig,
+ gitLabProjectInGroup,
+} from '@/connectors/gitlab/group'
+import {
+ readGitLabPermissionMetadata,
+ seedGitLabPermissionContext,
+} from '@/connectors/gitlab/permission-config/repository'
+import {
+ type GitLabCsvSyncContext,
getGitLabCsvContext,
gitLabCsvGroupToken,
+ setGitLabCsvContext,
} from '@/connectors/gitlab/permission-config/types'
import {
getGitLabDocumentAcls,
@@ -104,16 +119,17 @@ export function gitLabSourceKinds(config: Record): string[] {
}
/** Fresh source ACL evidence is request-local. CSV grants remain connector-local and administrator maintained. */
-export async function createAdminGitLabSession(input: {
+interface GitLabSessionInput {
owner: ResourceOwner
userId: string
source: AdminSource
token: string
client: NativeClient
signal: AbortSignal
-}) {
- const { owner, userId, source, token, client, signal } = input
- const { config } = source
+}
+
+export async function createAdminGitLabSession(input: GitLabSessionInput) {
+ const { owner, userId } = input
const access = await createUserKnowledgeAccessProvider(userId, {
workspaceId: owner.workspaceId ?? undefined,
organizationId: owner.organizationId ?? undefined,
@@ -129,15 +145,33 @@ export async function createAdminGitLabSession(input: {
'unavailable',
'GitLab search requires a verified organization identity.'
)
+ if (input.source.config.scope === 'group') return createGroupSession(input, own)
+ return createProjectSession(input, own)
+}
+
+async function createProjectSession(
+ input: GitLabSessionInput,
+ own: string,
+ groupProject?: { identity: GitLabCsvSyncContext; csv: boolean }
+) {
+ const { source, token, client, signal } = input
+ const { config } = source
const context = {}
- await seedGitLabCsvContext(source.id, context)
+ if (groupProject?.csv) setGitLabCsvContext(context, groupProject.identity)
+ else if (!groupProject) await seedGitLabPermissionContext(source.id, context)
const csv = getGitLabCsvContext(context)
const tokens = new Set([own])
let project: string
let projectPath: string
if (csv) {
/** Indexed ACL rewrites do not govern current CSV grants for provider-backed reads. */
- if (!(await hasConnectorPermissionGrant(source.id, 'project', own)))
+ if (
+ !(await hasConnectorPermissionGrant(
+ source.id,
+ groupProject ? `project:${groupProject.identity.projectId}` : 'project',
+ own
+ ))
+ )
throw new NativeSearchError(
'unavailable',
'This GitLab source is not available to your account.'
@@ -175,6 +209,15 @@ export async function createAdminGitLabSession(input: {
project = string(current.id)
projectPath = string(current.path_with_namespace)
}
+ if (
+ groupProject &&
+ (project !== String(groupProject.identity.projectId) ||
+ projectPath !== groupProject.identity.projectPath)
+ )
+ throw new NativeSearchError(
+ 'unavailable',
+ 'An admin must refresh permissions for this GitLab project.'
+ )
if (!project || !projectPath)
throw new NativeSearchError('unavailable', 'GitLab project identity could not be verified.')
signal.throwIfAborted()
@@ -325,3 +368,178 @@ export async function createAdminGitLabSession(input: {
},
}
}
+
+/** Traverse bounded project pages; every continuation and document read rechecks current grants. */
+async function createGroupSession(input: GitLabSessionInput, own: string) {
+ const { source, client } = input
+ const [stored] = await readConnectorPermissionMetadata([source.id])
+ const metadata = stored && readGitLabPermissionMetadata(stored.metadata)
+ if (!metadata || !('group' in metadata) || !gitLabGroupMatchesConfig(metadata, source.config))
+ throw new NativeSearchError('unavailable', 'An admin must update this GitLab group connection.')
+ const grants =
+ metadata.mode === 'csv'
+ ? await readConnectorPermissionGrants(
+ source.id,
+ stored.revision,
+ metadata.projects.map((project) => `project:${project.id}`),
+ own
+ )
+ : null
+ const projects = metadata.projects.filter(
+ (project) => !grants || grants.has(`project:${project.id}`)
+ )
+ const group = object(await client.json(`/api/v4/groups/${metadata.group.id}`, { memo: true }))
+ if (
+ string(group.id) !== String(metadata.group.id) ||
+ string(group.full_path) !== metadata.group.path
+ )
+ throw new NativeSearchError('unavailable', 'An admin must refresh the GitLab group connection.')
+ const sessions = new Map>()
+ const session = (project: GitLabGroupScope['projects'][number]) => {
+ if (!gitLabProjectInGroup(project.path, metadata.group))
+ throw new NativeSearchError(
+ 'unavailable',
+ 'This project is outside the configured GitLab group.'
+ )
+ let result = sessions.get(project.id)
+ if (!result) {
+ result = createProjectSession(
+ {
+ ...input,
+ source: {
+ ...source,
+ config: {
+ ...source.config,
+ scope: undefined,
+ group: undefined,
+ project: String(project.id),
+ },
+ },
+ },
+ own,
+ {
+ csv: metadata.mode === 'csv',
+ identity: {
+ connectorId: source.id,
+ host: metadata.host,
+ projectId: project.id,
+ projectPath: project.path,
+ },
+ }
+ )
+ sessions.set(project.id, result)
+ }
+ return result
+ }
+ const referencedProject = (container?: string) =>
+ projects.find((project) => container === String(project.id) || container === project.path)
+ return {
+ async verify(reference: Reference, evidence?: Record) {
+ const project = referencedProject(reference.container)
+ return project ? (await session(project)).verify(reference, evidence) : false
+ },
+ async read(reference: Reference) {
+ const project = referencedProject(reference.container)
+ if (!project)
+ throw new NativeSearchError(
+ 'unavailable',
+ 'This GitLab document is not available to your account.'
+ )
+ return (await session(project)).read(reference)
+ },
+ async search(search: NativeSearchInput): Promise {
+ if (search.native?.project) {
+ const project = referencedProject(search.native.project)
+ return project ? (await session(project)).search(search) : { documents: [] }
+ }
+ const kinds = gitLabSourceKinds(source.config).filter(
+ (kind) => !search.native?.kind || kind === search.native.kind
+ )
+ const raw = search.native?.cursor ?? `${stored.revision}:${search.limit}:0:0:1`
+ if (!/^\d{1,10}:\d{1,3}:\d{1,4}:\d:\d{1,4}$/.test(raw))
+ throw new NativeSearchError('unavailable', 'Invalid GitLab group page.')
+ const [revision, pageSize, ...position] = raw.split(':').map(Number)
+ if (revision !== stored.revision || pageSize !== search.limit)
+ throw new NativeSearchError(
+ 'unavailable',
+ 'GitLab permissions or page size changed. Restart the search.'
+ )
+ let [projectIndex = 0, kindIndex = 0, page = 1] = position
+ if (page < 1 || projectIndex > projects.length || (kinds.length && kindIndex >= kinds.length))
+ throw new NativeSearchError('unavailable', 'Invalid GitLab group page.')
+ const documents: NativeDocument[] = []
+ const failures: string[] = []
+ let partial = false
+ let collections = 0
+ while (
+ projectIndex < projects.length &&
+ kinds.length &&
+ collections < 4 &&
+ documents.length === 0
+ ) {
+ input.signal.throwIfAborted()
+ const project = projects[projectIndex]
+ const kind = kinds[kindIndex]
+ if (!project || !kind) break
+ try {
+ const current = await (await session(project)).search({
+ ...search,
+ limit: search.limit,
+ native: {
+ provider: 'gitlab',
+ query: search.query,
+ ...search.native,
+ project: String(project.id),
+ kind: kind as 'code' | 'wiki' | 'issues' | 'merge_requests',
+ cursor: String(page),
+ },
+ })
+ documents.push(...current.documents)
+ partial ||= Boolean(current.partial)
+ if (current.nextCursor) page = Number(current.nextCursor)
+ else {
+ page = 1
+ kindIndex += 1
+ if (kindIndex >= kinds.length) {
+ kindIndex = 0
+ projectIndex += 1
+ }
+ }
+ } catch (error) {
+ input.signal.throwIfAborted()
+ if (
+ error instanceof NativeSearchError &&
+ ['reconnect', 'rate_limited'].includes(error.status)
+ )
+ throw error
+ partial = true
+ failures.push(
+ error instanceof NativeSearchError
+ ? error.message
+ : 'One GitLab collection could not be searched.'
+ )
+ page = 1
+ kindIndex += 1
+ if (kindIndex >= kinds.length) {
+ kindIndex = 0
+ projectIndex += 1
+ }
+ }
+ collections += 1
+ }
+ return {
+ documents,
+ partial,
+ ...(projectIndex < projects.length && kinds.length
+ ? {
+ nextCursor: `${stored.revision}:${search.limit}:${projectIndex}:${kindIndex}:${page}`,
+ }
+ : {}),
+ message: joinMessages([
+ 'Searched configured GitLab group projects with per-project permissions. Continue with the cursor for remaining projects and results.',
+ ...failures,
+ ]),
+ }
+ },
+ }
+}
diff --git a/apps/sim/lib/sim-search/live/source-settings.ts b/apps/sim/lib/sim-search/live/source-settings.ts
index 7cdbee599cb..9c32fdba249 100644
--- a/apps/sim/lib/sim-search/live/source-settings.ts
+++ b/apps/sim/lib/sim-search/live/source-settings.ts
@@ -26,6 +26,9 @@ const LIVE_SOURCE_FIELDS: Record = {
github: ['repository', 'pathPrefix', 'extensions'],
gitlab: [
'host',
+ 'scope',
+ 'group',
+ 'includeSubgroups',
'project',
'contentTypes',
'ref',
@@ -100,7 +103,10 @@ export function liveSearchSourceMeta(
),
}
}
- if (!enabled) return meta
+ if (!enabled)
+ return meta.configFields.some((field) => field.searchOnly)
+ ? { ...meta, configFields: meta.configFields.filter((field) => !field.searchOnly) }
+ : meta
const fields = LIVE_SOURCE_FIELDS[meta.id]
if (!fields) return meta
const descriptions = LIVE_FIELD_DESCRIPTIONS[meta.id] ?? {}
diff --git a/apps/sim/lib/sim-search/source-identity.ts b/apps/sim/lib/sim-search/source-identity.ts
index 2cba485f134..3e4651f4a2f 100644
--- a/apps/sim/lib/sim-search/source-identity.ts
+++ b/apps/sim/lib/sim-search/source-identity.ts
@@ -34,6 +34,7 @@ const SOURCE_ADDRESS_FIELDS = new Set([
'host',
'domain',
'project',
+ 'group',
'projectKey',
'spaceKey',
'folderId',
@@ -79,6 +80,7 @@ const OPAQUE_SOURCE_FIELDS = new Map([
const NAMED_SOURCE_FIELDS = new Map([
['project', 'project'],
+ ['group', 'group'],
['projectKey', 'project'],
['spaceKey', 'space'],
['repository', 'repository'],
diff --git a/apps/sim/lib/workflows/application/read-paused-workflow-execution.test.ts b/apps/sim/lib/workflows/application/read-paused-workflow-execution.test.ts
index 749750f37b6..862e8766fba 100644
--- a/apps/sim/lib/workflows/application/read-paused-workflow-execution.test.ts
+++ b/apps/sim/lib/workflows/application/read-paused-workflow-execution.test.ts
@@ -72,7 +72,7 @@ describe('readPausedWorkflowExecution', () => {
async (principal) => {
const result = await readPausedWorkflowExecution.execute({
principal,
- input: { workflowId: 'workflow-1', executionId: 'execution-1' },
+ input: { workflowId: 'workflow-1', executionId: 'execution-1', includeSnapshot: true },
})
expect(result).toBe(detail)
@@ -87,7 +87,7 @@ describe('readPausedWorkflowExecution', () => {
it('finishes session authorization before loading paused execution detail', async () => {
await readPausedWorkflowExecution.execute({
principal: allowedPrincipals[0],
- input: { workflowId: 'workflow-1', executionId: 'execution-1' },
+ input: { workflowId: 'workflow-1', executionId: 'execution-1', includeSnapshot: true },
})
expect(mockResolvePermission.mock.invocationCallOrder[0]).toBeLessThan(
@@ -110,7 +110,7 @@ describe('readPausedWorkflowExecution', () => {
await expect(
readPausedWorkflowExecution.execute({
principal,
- input: { workflowId: 'workflow-1', executionId: 'execution-1' },
+ input: { workflowId: 'workflow-1', executionId: 'execution-1', includeSnapshot: true },
})
).rejects.toMatchObject({ name: 'DelegatedServiceAuthorizationError' })
expect(mockResolveWorkflowContext).not.toHaveBeenCalled()
@@ -128,7 +128,7 @@ describe('readPausedWorkflowExecution', () => {
await expect(
readPausedWorkflowExecution.execute({
principal,
- input: { workflowId: 'workflow-1', executionId: 'execution-1' },
+ input: { workflowId: 'workflow-1', executionId: 'execution-1', includeSnapshot: true },
})
).rejects.toMatchObject({ name: 'PrincipalKindAuthorizationError' })
expect(mockResolveWorkflowContext).not.toHaveBeenCalled()
@@ -142,7 +142,7 @@ describe('readPausedWorkflowExecution', () => {
workspaceId: 'workspace-2',
keyId: 'workspace-key-2',
}),
- input: { workflowId: 'workflow-1', executionId: 'execution-1' },
+ input: { workflowId: 'workflow-1', executionId: 'execution-1', includeSnapshot: true },
})
).rejects.toMatchObject({ code: 'forbidden' })
expect(mockGetPausedExecutionDetail).not.toHaveBeenCalled()
@@ -154,7 +154,7 @@ describe('readPausedWorkflowExecution', () => {
await expect(
readPausedWorkflowExecution.execute({
principal: allowedPrincipals[0],
- input: { workflowId: 'workflow-1', executionId: 'execution-1' },
+ input: { workflowId: 'workflow-1', executionId: 'execution-1', includeSnapshot: true },
})
).rejects.toMatchObject({ name: 'NoWorkspaceAccessError' })
expect(mockGetPausedExecutionDetail).not.toHaveBeenCalled()
@@ -169,7 +169,7 @@ describe('readPausedWorkflowExecution', () => {
await expect(
readPausedWorkflowExecution.execute({
principal: allowedPrincipals[1],
- input: { workflowId: 'workflow-1', executionId: 'execution-1' },
+ input: { workflowId: 'workflow-1', executionId: 'execution-1', includeSnapshot: true },
})
).rejects.toMatchObject({ name: 'PersonalApiKeysDisabledError' })
expect(mockGetPausedExecutionDetail).not.toHaveBeenCalled()
diff --git a/apps/sim/lib/workflows/application/read-paused-workflow-execution.ts b/apps/sim/lib/workflows/application/read-paused-workflow-execution.ts
index 958bfdea234..7fae5e83343 100644
--- a/apps/sim/lib/workflows/application/read-paused-workflow-execution.ts
+++ b/apps/sim/lib/workflows/application/read-paused-workflow-execution.ts
@@ -7,6 +7,11 @@ import { PauseResumeManager } from '@/lib/workflows/executor/human-in-the-loop-m
export interface ReadPausedWorkflowExecutionInput {
workflowId: string
executionId: string
+ /**
+ * Also read the execution snapshot. It carries every block's output and can run to
+ * many megabytes, so only a caller that returns it asks for it.
+ */
+ includeSnapshot: boolean
}
export const readPausedWorkflowExecution = defineAuthorizedWorkflowUseCase({
@@ -14,10 +19,10 @@ export const readPausedWorkflowExecution = defineAuthorizedWorkflowUseCase({
resolveContext: ({ input }: { input: ReadPausedWorkflowExecutionInput }) =>
resolveActiveWorkflowApplicationContext({ workflowId: input.workflowId }),
async execute({ context, input }) {
- const detail = await PauseResumeManager.getPausedExecutionDetail({
- workflowId: context.workflowId,
- executionId: input.executionId,
- })
+ const target = { workflowId: context.workflowId, executionId: input.executionId }
+ const detail = input.includeSnapshot
+ ? await PauseResumeManager.getPausedExecutionDetail(target)
+ : await PauseResumeManager.getPausedExecutionView(target)
if (!detail) throw new OrchestrationError('not_found', 'Paused execution not found')
return detail
},
diff --git a/apps/sim/lib/workflows/executor/execution-status.ts b/apps/sim/lib/workflows/executor/execution-status.ts
index c6387f60d1e..9461c9e98ac 100644
--- a/apps/sim/lib/workflows/executor/execution-status.ts
+++ b/apps/sim/lib/workflows/executor/execution-status.ts
@@ -26,9 +26,9 @@ import {
} from '@/lib/workflows/executor/execution-job-ids'
import { normalizePausePoints } from '@/lib/workflows/executor/execution-state'
import { PauseResumeManager } from '@/lib/workflows/executor/human-in-the-loop-manager'
+import { namePausePoints, pauseBaseBlockId } from '@/lib/workflows/executor/pause-block-names'
import { getAutomaticResumeWaitingMetadata } from '@/lib/workflows/executor/paused-execution-metadata'
import type { PauseInputField, PausePoint, ResumeStatus } from '@/executor/types'
-import { extractBaseBlockId } from '@/executor/utils/subflow-node-id-codec'
/**
* Reads a single execution's status resource — the log row, the paused-state
@@ -657,47 +657,6 @@ export interface PausedRunPoint {
queuePosition: number | null
}
-/**
- * Names of `blockIds` in the deployment version the run executed, read inside the
- * database so the version's state never leaves it. Empty for a run with no recorded
- * version (a manual run) or whose version no longer exists.
- */
-async function readRunBlockNames(
- workflowId: string,
- executionId: string,
- blockIds: string[]
-): Promise