@tickernelz/paperclip-pro-server 2026.928.5 → 2026.928.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-info.json +1 -1
- package/dist/routes/openapi.d.ts.map +1 -1
- package/dist/routes/openapi.js +133 -53
- package/dist/routes/openapi.js.map +1 -1
- package/dist/routes/paperclip-mcp.d.ts.map +1 -1
- package/dist/routes/paperclip-mcp.js +15 -0
- package/dist/routes/paperclip-mcp.js.map +1 -1
- package/package.json +21 -21
- package/skills/paperclip/SKILL.md +24 -22
- package/skills/paperclip/references/api-reference.md +43 -43
- package/skills/paperclip/references/artifacts.md +5 -5
- package/skills/paperclip/references/cases.md +8 -8
- package/skills/paperclip/references/company-skills.md +5 -5
- package/skills/paperclip/references/issue-workspaces.md +1 -1
- package/skills/paperclip/references/routines.md +13 -13
- package/skills/paperclip/references/workflows.md +5 -5
- package/skills/paperclip-board/SKILL.md +7 -7
- package/skills/paperclip-create-agent/SKILL.md +1 -1
- package/skills/paperclip-create-agent/references/api-reference.md +5 -5
- package/ui-dist/assets/{Agents.production-Ou10IBgG.js → Agents.production-g6e23L0t.js} +2 -2
- package/ui-dist/assets/{CompanyActivity.production-dbz2o26S.js → CompanyActivity.production-BfzT8G-l.js} +1 -1
- package/ui-dist/assets/{CompanyExport-VHEmaNC_.js → CompanyExport-B3AiIOt7.js} +1 -1
- package/ui-dist/assets/{CompanySkills.production-DuSUb8DQ.js → CompanySkills.production-DBgSF_kS.js} +1 -1
- package/ui-dist/assets/{Costs.production-BRz8Rn3s.js → Costs.production-DosW-ZWC.js} +1 -1
- package/ui-dist/assets/{OrgChart.production-Dgq5pMMa.js → OrgChart.production-DQjF3xIK.js} +1 -1
- package/ui-dist/assets/{RoutineDetail.production-B2lkeY8y.js → RoutineDetail.production-C4V6TNbR.js} +1 -1
- package/ui-dist/assets/{Routines.production-CGNSsZDr.js → Routines.production-Cv7CksVi.js} +1 -1
- package/ui-dist/assets/{definition-D6jTm4Mv.js → definition-BkqlnH41.js} +1 -1
- package/ui-dist/assets/{index-DGStZYMS.js → index-B9phYB96.js} +4 -4
- package/ui-dist/index.html +1 -1
- package/ui-dist/sw.js +1 -1
|
@@ -10,7 +10,7 @@ If a case tool reports `Cases are disabled`, stop and report that the operator
|
|
|
10
10
|
must enable cases before the skill can use this surface.
|
|
11
11
|
|
|
12
12
|
The case tools are in the `extended` toolset: they are available when the
|
|
13
|
-
operator enables `PAPERCLIP_MCP_TOOLSETS=
|
|
13
|
+
operator enables `PAPERCLIP_MCP_TOOLSETS=full`. When they are not
|
|
14
14
|
loaded, use `paperclipApiRequest` for the same operations. Every tool below
|
|
15
15
|
takes `companyId` only where noted; it defaults to the agent's company.
|
|
16
16
|
|
|
@@ -93,12 +93,12 @@ Useful arguments:
|
|
|
93
93
|
## Documents
|
|
94
94
|
|
|
95
95
|
Use case documents for rich bodies such as drafts, briefs, reports, or plans.
|
|
96
|
-
`paperclipSetCaseDocument` takes the case, the document `
|
|
96
|
+
`paperclipSetCaseDocument` takes the case, the document `documentKey`, and the body:
|
|
97
97
|
|
|
98
98
|
```json
|
|
99
99
|
{
|
|
100
100
|
"caseId": "PAP-C42",
|
|
101
|
-
"
|
|
101
|
+
"documentKey": "body",
|
|
102
102
|
"title": "Launch announcement body",
|
|
103
103
|
"format": "markdown",
|
|
104
104
|
"body": "# Launch announcement\n\nDraft copy...",
|
|
@@ -111,7 +111,7 @@ Updating an existing case document requires `baseRevisionId`:
|
|
|
111
111
|
```json
|
|
112
112
|
{
|
|
113
113
|
"caseId": "PAP-C42",
|
|
114
|
-
"
|
|
114
|
+
"documentKey": "body",
|
|
115
115
|
"baseRevisionId": "latest-revision-uuid",
|
|
116
116
|
"body": "Updated body"
|
|
117
117
|
}
|
|
@@ -136,7 +136,7 @@ Examples:
|
|
|
136
136
|
}
|
|
137
137
|
```
|
|
138
138
|
|
|
139
|
-
Patch fields or status with `
|
|
139
|
+
Patch fields or status with `paperclipUpdateCaseById`:
|
|
140
140
|
|
|
141
141
|
```json
|
|
142
142
|
{
|
|
@@ -158,7 +158,7 @@ Link cases to issues explicitly when needed with `paperclipCreateCaseLink`:
|
|
|
158
158
|
|
|
159
159
|
```json
|
|
160
160
|
{
|
|
161
|
-
"
|
|
161
|
+
"caseId": "PAP-C42",
|
|
162
162
|
"issueId": "issue-uuid",
|
|
163
163
|
"role": "reference"
|
|
164
164
|
}
|
|
@@ -241,7 +241,7 @@ Write the body with `paperclipSetCaseDocument`:
|
|
|
241
241
|
```json
|
|
242
242
|
{
|
|
243
243
|
"caseId": "PAP-C42",
|
|
244
|
-
"
|
|
244
|
+
"documentKey": "body",
|
|
245
245
|
"title": "Introducing Paperclip Cases",
|
|
246
246
|
"format": "markdown",
|
|
247
247
|
"body": "# Introducing Paperclip Cases\n\n..."
|
|
@@ -266,7 +266,7 @@ Create the child image-assets case with `paperclipCreateCase`:
|
|
|
266
266
|
```
|
|
267
267
|
|
|
268
268
|
Attach the generated assets to the child's linked issue, then patch both cases
|
|
269
|
-
as they move through review with `
|
|
269
|
+
as they move through review with `paperclipUpdateCaseById`:
|
|
270
270
|
|
|
271
271
|
```json
|
|
272
272
|
{
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Use this reference when a board user, CEO, or manager asks you to find a skill, install it into the company library, or assign it to an agent.
|
|
4
4
|
|
|
5
|
-
**Toolset:** `paperclipListSkills` is in the default `core` toolset. Every other tool on this page is in the `extended` toolset: it is available when the operator enables `PAPERCLIP_MCP_TOOLSETS=
|
|
5
|
+
**Toolset:** `paperclipListSkills` is in the default `core` toolset. Every other tool on this page is in the `extended` toolset: it is available when the operator enables `PAPERCLIP_MCP_TOOLSETS=full`; otherwise use `paperclipApiRequest`. `companyId` is optional on company-scoped tools and defaults to your company.
|
|
6
6
|
|
|
7
7
|
## What Exists
|
|
8
8
|
|
|
@@ -50,7 +50,7 @@ Company library:
|
|
|
50
50
|
|
|
51
51
|
Agent attach and hire/create composition:
|
|
52
52
|
|
|
53
|
-
- `paperclipListAgentSkills` — `{ "
|
|
53
|
+
- `paperclipListAgentSkills` — `{ "agentId": "<agent-id>" }`
|
|
54
54
|
- `paperclipSyncAgentSkill` — attach or detach company skills on an agent
|
|
55
55
|
- `paperclipCreateAgentHire` — hire with `desiredSkills`
|
|
56
56
|
- `paperclipCreateAgent` — direct create with `desiredSkills`
|
|
@@ -72,7 +72,7 @@ source. Bundled skills are the curated defaults for any company; optional
|
|
|
72
72
|
skills are role- or domain-specific.
|
|
73
73
|
|
|
74
74
|
Browse with `paperclipGetSkillCatalog`, inspect one entry with
|
|
75
|
-
`paperclipGetSkillCatalogByCatalogId`, then install
|
|
75
|
+
`paperclipGetSkillCatalogByCatalogId`, then install with `paperclipInstallCatalogSkill`:
|
|
76
76
|
|
|
77
77
|
```json
|
|
78
78
|
{
|
|
@@ -152,14 +152,14 @@ The server persists canonical company skill keys.
|
|
|
152
152
|
|
|
153
153
|
```json
|
|
154
154
|
{
|
|
155
|
-
"
|
|
155
|
+
"agentId": "<agent-id>",
|
|
156
156
|
"mode": "add",
|
|
157
157
|
"desiredSkills": ["vercel-labs/agent-browser/agent-browser"]
|
|
158
158
|
}
|
|
159
159
|
```
|
|
160
160
|
|
|
161
161
|
If you need the current state first, call `paperclipListAgentSkills` with
|
|
162
|
-
`{ "
|
|
162
|
+
`{ "agentId": "<agent-id>" }`.
|
|
163
163
|
|
|
164
164
|
## Include Skills During Hire Or Create
|
|
165
165
|
|
|
@@ -62,4 +62,4 @@ For QA/browser checks, use the service whose `status` is `running` and whose `he
|
|
|
62
62
|
|
|
63
63
|
## Workspace-Scoped Read
|
|
64
64
|
|
|
65
|
-
When you already hold an execution workspace id — for example from another agent's comment — `paperclipGetExecutionWorkspace` with `{ "
|
|
65
|
+
When you already hold an execution workspace id — for example from another agent's comment — `paperclipGetExecutionWorkspace` with `{ "executionWorkspaceId": "<execution-workspace-id>" }` returns that workspace and its runtime services. Prefer the issue-scoped tools above when you start from an issue: they resolve the workspace id for you.
|
|
@@ -9,7 +9,7 @@ A routine has:
|
|
|
9
9
|
- A catch-up policy (what to do with missed scheduled runs)
|
|
10
10
|
- An activity gate policy (whether quiet scheduled ticks should be skipped)
|
|
11
11
|
|
|
12
|
-
**Toolset:** the routine tools are in the `extended` toolset. They are available when the operator enables `PAPERCLIP_MCP_TOOLSETS=
|
|
12
|
+
**Toolset:** the routine tools are in the `extended` toolset. They are available when the operator enables `PAPERCLIP_MCP_TOOLSETS=full`; otherwise use `paperclipApiRequest` for the same operations.
|
|
13
13
|
|
|
14
14
|
**Authorization:** Agents can read all routines in their company but can only create or manage routines assigned to themselves. Board operators have full access, including reassignment.
|
|
15
15
|
|
|
@@ -132,13 +132,13 @@ Add a schedule trigger with `cronExpression: "0 * * * *"`. The first tick runs.
|
|
|
132
132
|
|
|
133
133
|
A routine can have multiple triggers of different kinds.
|
|
134
134
|
|
|
135
|
-
`paperclipCreateRoutineTrigger` takes the routine as `
|
|
135
|
+
`paperclipCreateRoutineTrigger` takes the routine as `routineId` and the trigger configuration nested under `body`. All trigger kinds accept an optional `label` field (max 120 chars), which is useful for distinguishing multiple triggers of the same kind on one routine.
|
|
136
136
|
|
|
137
137
|
### Schedule (cron)
|
|
138
138
|
|
|
139
139
|
```json
|
|
140
140
|
{
|
|
141
|
-
"
|
|
141
|
+
"routineId": "{routineId}",
|
|
142
142
|
"body": {
|
|
143
143
|
"kind": "schedule",
|
|
144
144
|
"cronExpression": "0 9 * * 1",
|
|
@@ -155,7 +155,7 @@ A routine can have multiple triggers of different kinds.
|
|
|
155
155
|
|
|
156
156
|
```json
|
|
157
157
|
{
|
|
158
|
-
"
|
|
158
|
+
"routineId": "{routineId}",
|
|
159
159
|
"body": {
|
|
160
160
|
"kind": "webhook",
|
|
161
161
|
"signingMode": "hmac_sha256",
|
|
@@ -175,7 +175,7 @@ A routine can have multiple triggers of different kinds.
|
|
|
175
175
|
|
|
176
176
|
```json
|
|
177
177
|
{
|
|
178
|
-
"
|
|
178
|
+
"routineId": "{routineId}",
|
|
179
179
|
"body": { "kind": "api" }
|
|
180
180
|
}
|
|
181
181
|
```
|
|
@@ -186,16 +186,16 @@ No configuration. Fire it with the manual run tool below.
|
|
|
186
186
|
|
|
187
187
|
## Updating and Deleting Triggers
|
|
188
188
|
|
|
189
|
-
`paperclipUpdateRoutineTrigger` takes the trigger as `
|
|
189
|
+
`paperclipUpdateRoutineTrigger` takes the trigger as `routineTriggerId`:
|
|
190
190
|
|
|
191
191
|
```json
|
|
192
|
-
{ "
|
|
192
|
+
{ "routineTriggerId": "{triggerId}", "enabled": false, "cronExpression": "0 10 * * 1" }
|
|
193
193
|
```
|
|
194
194
|
|
|
195
|
-
`paperclipDeleteRoutineTrigger` takes the trigger as `
|
|
195
|
+
`paperclipDeleteRoutineTrigger` takes the trigger as `routineTriggerId`:
|
|
196
196
|
|
|
197
197
|
```json
|
|
198
|
-
{ "
|
|
198
|
+
{ "routineTriggerId": "{triggerId}" }
|
|
199
199
|
```
|
|
200
200
|
|
|
201
201
|
Rotating a webhook secret has no dedicated tool. Use `paperclipApiRequest` with `method: "POST"`, `path: "/routine-triggers/{triggerId}/rotate-secret"`. The old secret is immediately invalidated.
|
|
@@ -208,7 +208,7 @@ Rotating a webhook secret has no dedicated tool. Use `paperclipApiRequest` with
|
|
|
208
208
|
|
|
209
209
|
```json
|
|
210
210
|
{
|
|
211
|
-
"
|
|
211
|
+
"routineId": "{routineId}",
|
|
212
212
|
"source": "manual",
|
|
213
213
|
"triggerId": "{triggerId}",
|
|
214
214
|
"payload": { "context": "..." },
|
|
@@ -225,7 +225,7 @@ Rotating a webhook secret has no dedicated tool. Use `paperclipApiRequest` with
|
|
|
225
225
|
All create fields are updatable with `paperclipUpdateRoutine`. Agents cannot reassign a routine to another agent.
|
|
226
226
|
|
|
227
227
|
```json
|
|
228
|
-
{ "
|
|
228
|
+
{ "routineId": "{routineId}", "status": "paused", "title": "New title" }
|
|
229
229
|
```
|
|
230
230
|
|
|
231
231
|
---
|
|
@@ -233,7 +233,7 @@ All create fields are updatable with `paperclipUpdateRoutine`. Agents cannot rea
|
|
|
233
233
|
## Reading Routines and Runs
|
|
234
234
|
|
|
235
235
|
- `paperclipListRoutines` — routines in the company; `companyId` defaults to yours
|
|
236
|
-
- `paperclipGetRoutine` — `{ "
|
|
237
|
-
- `paperclipListRoutineRuns` — `{ "
|
|
236
|
+
- `paperclipGetRoutine` — `{ "routineId": "{routineId}" }`
|
|
237
|
+
- `paperclipListRoutineRuns` — `{ "routineId": "{routineId}" }`
|
|
238
238
|
|
|
239
239
|
Use `paperclipApiRequest` when a routine operation has no dedicated tool. Use this file when you need routine-specific behaviour, payload shape, or policy details.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Reference material for niche workflows that are pointed to from `SKILL.md`. Load only when the task matches.
|
|
4
4
|
|
|
5
|
-
Some playbooks below use `extended` toolset tools: they are available when the operator enables `PAPERCLIP_MCP_TOOLSETS=
|
|
5
|
+
Some playbooks below use `extended` toolset tools: they are available when the operator enables `PAPERCLIP_MCP_TOOLSETS=full`; otherwise use `paperclipApiRequest`. Each step names the toolset when it matters.
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ Some playbooks below use `extended` toolset tools: they are available when the o
|
|
|
11
11
|
When asked to set up a new project with workspace config (local folder and/or GitHub repo):
|
|
12
12
|
|
|
13
13
|
1. `paperclipCreateProject` (core) with the project fields. `companyId` is optional and defaults to your company.
|
|
14
|
-
2. Optionally include `workspace` in that same create call, or call `paperclipCreateProjectWorkspace` (extended) right after create with `{ "
|
|
14
|
+
2. Optionally include `advanced.workspace` in that same create call, or call `paperclipCreateProjectWorkspace` (extended) right after create with `{ "projectId": "<project-id>", ... }`.
|
|
15
15
|
|
|
16
16
|
Workspace rules:
|
|
17
17
|
|
|
@@ -50,7 +50,7 @@ Use `paperclipUpdateAgentInstructionsPath` (extended) instead of the generic age
|
|
|
50
50
|
|
|
51
51
|
```json
|
|
52
52
|
{
|
|
53
|
-
"
|
|
53
|
+
"agentId": "<agent-id>",
|
|
54
54
|
"path": "agents/cmo/AGENTS.md"
|
|
55
55
|
}
|
|
56
56
|
```
|
|
@@ -65,7 +65,7 @@ Rules:
|
|
|
65
65
|
|
|
66
66
|
```json
|
|
67
67
|
{
|
|
68
|
-
"
|
|
68
|
+
"agentId": "<agent-id>",
|
|
69
69
|
"path": "/absolute/path/to/AGENTS.md",
|
|
70
70
|
"adapterConfigKey": "yourAdapterSpecificPathField"
|
|
71
71
|
}
|
|
@@ -112,7 +112,7 @@ Use this when validating Paperclip itself (assignment flow, checkouts, run visib
|
|
|
112
112
|
}
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
-
2. Trigger a heartbeat for that assignee with `paperclipInvokeAgentHeartbeat` (extended): `{ "
|
|
115
|
+
2. Trigger a heartbeat for that assignee with `paperclipInvokeAgentHeartbeat` (extended): `{ "agentId": "<agent-id>" }`.
|
|
116
116
|
|
|
117
117
|
3. Verify the issue transitions (`todo -> in_progress -> done` or `blocked`) and that comments are posted, with `paperclipGetIssue`: `{ "issueId": "<issue-id-or-identifier>" }`.
|
|
118
118
|
|
|
@@ -14,7 +14,7 @@ You are a board-level assistant helping a human manage their AI-agent company th
|
|
|
14
14
|
|
|
15
15
|
Every Paperclip operation is an MCP tool call on the `paperclip*` tools. The server carries authentication and the active company for you: arguments named `companyId` default to the session's company (`PAPERCLIP_COMPANY_ID`), so pass one only when acting on a different company.
|
|
16
16
|
|
|
17
|
-
**Toolsets:** tools marked `extended` below load only when the operator sets `PAPERCLIP_MCP_TOOLSETS=
|
|
17
|
+
**Toolsets:** tools marked `extended` below load only when the operator sets `PAPERCLIP_MCP_TOOLSETS=full`. Without that, run the same operation through `paperclipApiRequest`.
|
|
18
18
|
|
|
19
19
|
**Board-only work without a dedicated tool:** creating or listing companies, agent API keys, credentials and billing have no tool. Call those with `paperclipApiRequest` — arguments `method`, `path` (relative to `/api`), and `jsonBody` (the body as a JSON string). Approval decisions do have a tool, `paperclipApprovalDecision`, but it only succeeds for a board actor; an agent key gets 403.
|
|
20
20
|
|
|
@@ -124,7 +124,7 @@ Also write this to a local file at `./artifacts/decision-log.md` so the user can
|
|
|
124
124
|
|
|
125
125
|
### Step 4: Launch the Company
|
|
126
126
|
|
|
127
|
-
Start the CEO's first heartbeat with `paperclipInvokeAgentHeartbeat` (`extended`), argument `
|
|
127
|
+
Start the CEO's first heartbeat with `paperclipInvokeAgentHeartbeat` (`extended`), argument `agentId: "{ceoId}"`.
|
|
128
128
|
|
|
129
129
|
## Hiring Plan Loop
|
|
130
130
|
|
|
@@ -217,7 +217,7 @@ Additionally recommended:
|
|
|
217
217
|
Approve these updates? (approve all / review individually / edit)
|
|
218
218
|
```
|
|
219
219
|
|
|
220
|
-
4. Only after board approval, update each affected agent: read the current config with `paperclipGetAgent` (`agentId`), then write it back with `paperclipUpdateAgent` (`extended`), arguments `
|
|
220
|
+
4. Only after board approval, update each affected agent: read the current config with `paperclipGetAgent` (`agentId`), then write it back with `paperclipUpdateAgent` (`extended`), arguments `agentId` and `adapterConfig` holding the updated Collaboration section.
|
|
221
221
|
|
|
222
222
|
5. Log the changes and reasoning in the decision log.
|
|
223
223
|
|
|
@@ -262,7 +262,7 @@ Present tasks as:
|
|
|
262
262
|
|
|
263
263
|
- Team list: `paperclipListAgents`
|
|
264
264
|
- Detail: `paperclipGetAgent` (`agentId`)
|
|
265
|
-
- Change history: `paperclipListAgentConfigRevisions` (`extended`, `
|
|
265
|
+
- Change history: `paperclipListAgentConfigRevisions` (`extended`, `agentId`)
|
|
266
266
|
|
|
267
267
|
Present agents as:
|
|
268
268
|
```
|
|
@@ -299,7 +299,7 @@ By Agent:
|
|
|
299
299
|
|
|
300
300
|
## Work Products
|
|
301
301
|
|
|
302
|
-
- List: `paperclipListIssueWorkProducts` (`
|
|
302
|
+
- List: `paperclipListIssueWorkProducts` (`issueId`)
|
|
303
303
|
- View a document: `paperclipGetDocument` (`issueId`, `key`)
|
|
304
304
|
- Revisions: `paperclipListDocumentRevisions` (`issueId`, `key`)
|
|
305
305
|
|
|
@@ -318,13 +318,13 @@ Work Products — PAP-12
|
|
|
318
318
|
|
|
319
319
|
Three ways the user can edit system prompts:
|
|
320
320
|
|
|
321
|
-
**In chat:** user describes changes; re-read with `paperclipGetAgent` (`agentId`), then write with `paperclipUpdateAgent` (`extended`, `
|
|
321
|
+
**In chat:** user describes changes; re-read with `paperclipGetAgent` (`agentId`), then write with `paperclipUpdateAgent` (`extended`, `agentId`, `adapterConfig`).
|
|
322
322
|
|
|
323
323
|
**Direct file edit:** If the agent uses `instructionsFilePath`, the user can edit the file directly. When they tell you they're done, re-read the file and confirm changes.
|
|
324
324
|
|
|
325
325
|
**Web UI edit:** User edits at `{baseUrl}/{prefix}/agents/{agentUrlKey}`. When they say "sync up," re-read with `paperclipGetAgent`.
|
|
326
326
|
|
|
327
|
-
**Viewing change history:** `paperclipListAgentConfigRevisions` (`extended`, `
|
|
327
|
+
**Viewing change history:** `paperclipListAgentConfigRevisions` (`extended`, `agentId`). Present as a changelog:
|
|
328
328
|
```
|
|
329
329
|
Config History — @designer
|
|
330
330
|
──────────────────────────
|
|
@@ -39,7 +39,7 @@ subagent for the requested permanent hire.
|
|
|
39
39
|
|
|
40
40
|
The hiring tools — `paperclipListAgentConfigurations`, `paperclipCreateAgentHire`
|
|
41
41
|
— live in the `extended` toolset: they are available when the operator enables
|
|
42
|
-
`PAPERCLIP_MCP_TOOLSETS=
|
|
42
|
+
`PAPERCLIP_MCP_TOOLSETS=full`; otherwise call the same operation through
|
|
43
43
|
`paperclipApiRequest` (`method`, `path` relative to `/api`, `jsonBody` as a JSON
|
|
44
44
|
string). `companyId` arguments default to the session's company, so pass one only
|
|
45
45
|
when hiring into a different company.
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
## Tools
|
|
4
4
|
|
|
5
|
-
Tools marked extended load only when the operator enables `PAPERCLIP_MCP_TOOLSETS=
|
|
5
|
+
Tools marked extended load only when the operator enables `PAPERCLIP_MCP_TOOLSETS=full`; otherwise use `paperclipApiRequest` (`method`, `path` relative to `/api`, `jsonBody` as a JSON string) for the same job.
|
|
6
6
|
|
|
7
7
|
| Job | Tool | Key arguments |
|
|
8
8
|
| --- | ---- | ------------- |
|
|
9
9
|
| Read the company adapter-configuration catalogue | `paperclipListAgentConfigurations` (extended) | `companyId` |
|
|
10
10
|
| List the company skill library | `paperclipListSkills` | `companyId` |
|
|
11
11
|
| Import a skill into the company library | `paperclipImportSkill` (extended) | `companyId`, import fields |
|
|
12
|
-
| Read one agent's resolved configuration | `paperclipGetAgentConfiguration` (extended) | `
|
|
13
|
-
| Sync skills onto an agent | `paperclipSyncAgentSkill` (extended) | `
|
|
12
|
+
| Read one agent's resolved configuration | `paperclipGetAgentConfiguration` (extended) | `agentId` |
|
|
13
|
+
| Sync skills onto an agent | `paperclipSyncAgentSkill` (extended) | `agentId`, sync fields |
|
|
14
14
|
| Submit a hire request (agent draft + approval) | `paperclipCreateAgentHire` (extended) | `companyId`, hire fields below |
|
|
15
15
|
| Create an agent directly, no approval | `paperclipCreateAgent` (extended) | `companyId`, same shape as the hire fields |
|
|
16
|
-
| List agent config revisions | `paperclipListAgentConfigRevisions` (extended) | `
|
|
17
|
-
| Roll back a config revision | `paperclipRollbackAgentConfigRevision` (extended) | `
|
|
16
|
+
| List agent config revisions | `paperclipListAgentConfigRevisions` (extended) | `agentId` |
|
|
17
|
+
| Roll back a config revision | `paperclipRollbackAgentConfigRevision` (extended) | `agentId`, `revisionId` |
|
|
18
18
|
| Link an approval to an issue | `paperclipLinkIssueApproval` | `issueId`, `approvalId` |
|
|
19
19
|
| List issues linked to an approval | `paperclipGetApprovalIssues` | `approvalId` |
|
|
20
20
|
| Approval details | `paperclipGetApproval` | `approvalId` |
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
var Pe=Object.defineProperty;var n=(e,a)=>Pe(e,"name",{value:a,configurable:!0});import{i as oe}from"./rolldown-runtime-ZpX3ckPj.js";import{En as ke,Fr as qe,Lr as Me,S as B,U as Fe,Y as j,_ as ce,g as U,nr as N,z as Re}from"./createLucideIcon-r3v6fbGz.js";import{t as $e}from"./preload-helper-CceJXRIF.js";import{it as Be,o as ze,t as de}from"./router-Bb8nJWyv.js";import{S as Ke}from"./zap-P-cXfK28.js";import{t as ue}from"./AgentAvatar-PT82VwmU.js";import{t as Oe}from"./tabs-DWRZjksg.js";import{t as ae}from"./agents-BlSzFh-1.js";import{r as De,t as re}from"./EmptyState-DPcc0zYh.js";import{t as ie}from"./bot-DZDpMzjD.js";import{k as Ue,t as V}from"./button-CAPbz11u.js";import{i as Ve,o as He,t as Ge}from"./heartbeats-CK_aXmx5.js";import{t as me}from"./triangle-alert-CgJcxSQX.js";import{n as Qe}from"./SidebarContext-D01pu4wh.js";import{n as Je,t as le}from"./environments-BVeNFanj.js";import{t as Ye}from"./PageSkeleton-DHjTwRT3.js";import{$t as We,It as Xe,Jt as Ze,Lt as pe,Wt as H,Yt as et,an as ge,cn as tt,dn as st,in as nt,nn as xe,on as G,rn as at,sn as rt,un as fe}from"./index-DGStZYMS.js";var g=oe(Me(),1),t=oe(qe(),1),he=ke,it=(0,g.lazy)(()=>$e(()=>import("./index-DGStZYMS.js").then(e=>e.wt).then(e=>({default:e.ConfigureBuiltInAgentModal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48]))),lt=["all","active","paused","error","builtin"],ot=[{value:"all",label:"All"},{value:"active",label:"Active"},{value:"paused",label:"Paused"},{value:"error",label:"Error"},{value:"builtin",label:"Built-in"}];function ct(e){return lt.includes(e)}n(ct,"isFilterTab");var J={label:"Local",detail:"Paperclip host",title:"Local - Paperclip host"},ve={label:"—",detail:"Loading environment",title:"Loading environment"},be=new Set(["terminated","pending_approval"]);function je(e,a){return a==="all"?!0:a==="active"?e==="active"||e==="running"||e==="idle":a==="paused"?e==="paused":a==="error"?e==="error":!0}n(je,"matchesFilter");function dt(e,a,i){return e.filter(r=>be.has(r.status)?!1:a==="builtin"?i.has(r.id):je(r.status,a)).sort((r,o)=>r.name.localeCompare(o.name))}n(dt,"filterAgents");function ut(e){const a=e.adapterConfig?.model;if(typeof a!="string")return null;const i=a.trim();return i.length>0?i:null}n(ut,"getConfiguredModel");function mt(e){return e==="ssh"?"SSH":e.charAt(0).toUpperCase()+e.slice(1)}n(mt,"formatEnvironmentDriver");function pt(e,a){const i=typeof e.config.provider=="string"?e.config.provider.trim():"";return i?a?.sandboxProviders?.[i]?.displayName??i:"Sandbox"}n(pt,"getSandboxProviderLabel");function gt(e,a){const i=Ze(e)?"Managed by Paperclip":e.driver==="sandbox"?`${pt(e,a)} sandbox provider`:e.driver==="local"?"Paperclip host":mt(e.driver);return{label:e.name,detail:i,title:`${e.name} - ${i}`}}n(gt,"describeEnvironment");function xt(e){return{label:"Unknown environment",detail:e.slice(0,8),title:`Unknown environment - ${e}`}}n(xt,"describeMissingEnvironment");function ft(e,a,i,r){const o=e.defaultEnvironmentId??i;if(!o)return J;const x=a.get(o);return x?gt(x,r):xt(o)}n(ft,"resolveAgentEnvironment");function Ne(e,a,i){return e.reduce((r,o)=>{const x=Ne(o.reports,a,i);return be.has(o.status)?(r.push(...x),r):(((a==="builtin"?i.has(o.id):je(o.status,a))||x.length>0)&&r.push({...o,reports:x}),r)},[]).sort((r,o)=>r.name.localeCompare(o.name))}n(Ne,"filterOrgTree");function Mt(){const{selectedCompanyId:e}=Fe(),{openNewAgent:a}=Ve(),{setBreadcrumbs:i}=De(),r=ze(),o=Be(),{isMobile:x}=Qe(),C=o.pathname.split("/").pop()??"all",v=ct(C)?C:"all",[S,m]=(0,g.useState)("org"),A=x,p=A?"list":S,{data:l}=N({queryKey:j.instance.settings,queryFn:n(()=>Je.get(),"queryFn"),enabled:!!e}),u=l?.experimental.enableBuiltInAgents===!0,h=v==="builtin"&&!u?"all":v,z=(0,g.useMemo)(()=>ot.filter(s=>s.value!=="builtin"||u),[u]),{data:E}=N({queryKey:j.builtInAgents.list(e),queryFn:n(()=>st.list(e),"queryFn"),enabled:!!e&&u}),b=(0,g.useMemo)(()=>{const s=new Map;if(!u)return s;for(const c of E??[])c.agentId&&s.set(c.agentId,c);return s},[E,u]),k=(0,g.useMemo)(()=>new Set(b.keys()),[b]),[y,_]=(0,g.useState)(null),{data:d,isLoading:Ie,error:Y}=N({queryKey:j.agents.list(e),queryFn:n(()=>ae.list(e),"queryFn"),enabled:!!e}),{data:T}=N({queryKey:j.org(e),queryFn:n(()=>ae.org(e),"queryFn"),enabled:!!e&&p==="org"}),q=l?.experimental.enableEnvironments===!0,{data:L}=N({queryKey:j.environments.list(e),queryFn:n(()=>le.list(e),"queryFn"),enabled:!!e&&q}),{data:W}=N({queryKey:j.environments.capabilities(e),queryFn:n(()=>le.capabilities(e),"queryFn"),enabled:!!e&&q}),X=[...j.liveRuns(e),"agents-page"],K=nt({companyId:e,resourceKey:"live-runs:agents-page",queryKey:X,enabled:!!e,refetchInterval:15e3,leaderOnly:!0}),{data:O,dataUpdatedAt:Ce}=N({queryKey:X,queryFn:n(()=>Ge.liveRunsForCompany(e),"queryFn"),enabled:K.enabled,refetchInterval:K.refetchInterval});at(K,O,Ce);const M=tt(e),f=rt(e),F=(0,g.useMemo)(()=>{const s=new Map;for(const c of O??[]){if(c.status!=="running"&&c.status!=="queued")continue;const P=s.get(c.agentId);if(P){P.liveCount+=1;continue}s.set(c.agentId,{runId:c.id,liveCount:1})}return s},[O]),Se=(0,g.useMemo)(()=>{const s=new Map;for(const c of d??[])s.set(c.id,c);return s},[d]),Z=(0,g.useMemo)(()=>{const s=new Map;for(const c of L??[])s.set(c.id,c);return s},[L]),ee=(0,g.useMemo)(()=>{const s=new Map;for(const c of d??[])s.set(c.id,ft(c,Z,l?.defaultEnvironmentId??null,W));return s},[d,Z,W,l?.defaultEnvironmentId]);if((0,g.useEffect)(()=>{i([{label:"Agents"}])},[i]),(0,g.useEffect)(()=>{e&&v==="builtin"&&l&&!u&&r("/agents/all",{replace:!0})},[u,l,r,v,e]),!e)return(0,t.jsx)(re,{icon:ie,message:"Select a company to view agents."});if(Ie)return(0,t.jsx)(Ye,{variant:"list"});const w=dt(d??[],h,k),D=Ne(T??[],h,k),te=q&&L===void 0,se=q&&(L===void 0||L.length>1),Ae=n(s=>te?ve:ee.get(s)??J,"resolveRenderedEnvironment"),Ee=n(s=>{const c=s.orgChainHealth?.status==="invalid_org_chain",P=f.isPending&&f.variables?.resourceType==="agent"&&f.variables.resourceId===s.id,_e=P&&f.variables?.starred!==void 0,ne=P&&f.variables?.starred===void 0,Te=ge(M.data,"agent",s.id),I=b.get(s.id),Le=I?.status==="needs_setup"||I?.status==="pending_approval",R=I&&Le?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(fe,{status:I.status}),I.status==="needs_setup"&&(0,t.jsx)("span",{onClick:n($=>{$.preventDefault(),$.stopPropagation()},"onClick"),children:(0,t.jsx)(V,{size:"xs",variant:"outline",onClick:n(()=>_(I),"onClick"),children:"Set up"})})]}):null;return(0,t.jsx)(Xe,{title:s.name,titleClassName:"flex-1 xl:flex-none xl:w-56",titleTextClassName:"whitespace-normal break-words xl:truncate xl:whitespace-nowrap",subtitleClassName:"whitespace-normal break-words xl:truncate xl:whitespace-nowrap",subtitle:`${he[s.role]??s.role}${s.title?` - ${s.title}`:""}`,to:ce(s),className:B("group",s.pausedAt&&h!=="paused"?"opacity-50":"",G(M.data,"agent",s.id)==="left"?"sm:text-foreground/55":""),leading:c?(0,t.jsx)(me,{className:"h-3.5 w-3.5 text-amber-500","aria-label":"Invalid reporting chain"}):(0,t.jsx)(ue,{agent:s,size:32}),secondaryRow:R?(0,t.jsx)("div",{className:"xl:hidden flex flex-wrap items-center gap-1.5",children:R}):void 0,meta:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[R&&(0,t.jsx)("div",{className:"hidden xl:flex items-center gap-1.5",children:R}),(0,t.jsx)("div",{className:"hidden xl:flex items-center gap-3",children:(0,t.jsx)(we,{agent:s,environment:Ae(s.id),showEnvironment:se})})]}),metaSpacerClassName:"hidden xl:block",trailing:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsxs)("div",{className:"hidden sm:flex items-center gap-3",children:[F.has(s.id)&&(0,t.jsx)(Q,{agentRef:U(s),runId:F.get(s.id).runId,liveCount:F.get(s.id).liveCount}),(0,t.jsx)("span",{className:"w-20 flex justify-end",children:(0,t.jsx)(H,{status:s.status})}),(0,t.jsx)(xe,{size:"row",starred:Te,pending:_e,resourceName:s.name,onToggle:n($=>f.mutate({resourceType:"agent",resourceId:s.id,resourceName:s.name,starred:$}),"onToggle")})]}),(0,t.jsx)(pe,{state:G(M.data,"agent",s.id),pending:ne,pendingState:ne?f.variables?.state??null:null,resourceName:s.name,onJoin:n(()=>f.mutate({resourceType:"agent",resourceId:s.id,resourceName:s.name,state:"joined"}),"onJoin"),onLeave:n(()=>f.mutate({resourceType:"agent",resourceId:s.id,resourceName:s.name,state:"left"}),"onLeave")})]})},s.id)},"renderAgentRow");return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsx)(Oe,{value:h,onValueChange:n(s=>r(`/agents/${s}`),"onValueChange"),children:(0,t.jsx)(We,{items:z,value:h,onValueChange:n(s=>r(`/agents/${s}`),"onValueChange")})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[!A&&(0,t.jsxs)("div",{className:"flex items-center border border-border",role:"group","aria-label":"View mode",children:[(0,t.jsx)("button",{className:B("p-1.5 transition-colors",p==="list"?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50"),onClick:n(()=>m("list"),"onClick"),title:"List view","aria-label":"List view","aria-pressed":p==="list",children:(0,t.jsx)(He,{className:"h-3.5 w-3.5"})}),(0,t.jsx)("button",{className:B("p-1.5 transition-colors",p==="org"?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50"),onClick:n(()=>m("org"),"onClick"),title:"Org chart view","aria-label":"Org chart view","aria-pressed":p==="org",children:(0,t.jsx)(Ke,{className:"h-3.5 w-3.5"})})]}),(0,t.jsxs)(V,{size:"sm",variant:"outline",onClick:a,children:[(0,t.jsx)(Ue,{className:"h-3.5 w-3.5 mr-1.5"}),"New Agent"]})]})]}),w.length>0&&(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[w.length," agent",w.length!==1?"s":""]}),Y&&(0,t.jsx)("p",{className:"text-sm text-destructive",children:Y.message}),d&&d.length===0&&(0,t.jsx)(re,{icon:ie,message:"Create your first agent to get started.",action:"New Agent",onAction:a}),p==="list"&&w.length>0&&(0,t.jsx)("div",{children:w.map(Ee)}),p==="list"&&d&&d.length>0&&w.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No agents match the selected status."}),p==="org"&&D.length>0&&(0,t.jsx)("div",{className:"py-1",children:D.map(s=>(0,t.jsx)(ye,{node:s,depth:0,agentMap:Se,liveRunByAgent:F,environmentByAgentId:ee,environmentDataLoading:te,showEnvironment:se,tab:h,memberships:M.data,membershipMutation:f,builtInByAgentId:b,onConfigureBuiltIn:_},s.id))}),p==="org"&&T&&T.length>0&&D.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No agents match the selected status."}),p==="org"&&T&&T.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No organizational hierarchy defined."}),y&&e&&(0,t.jsx)(g.Suspense,{fallback:null,children:(0,t.jsx)(it,{companyId:e,state:y,open:y!==null,onOpenChange:n(s=>{s||_(null)},"onOpenChange")})})]})}n(Mt,"Agents");function ye({node:e,depth:a,agentMap:i,liveRunByAgent:r,environmentByAgentId:o,environmentDataLoading:x,showEnvironment:C,tab:v,memberships:S,membershipMutation:m,builtInByAgentId:A,onConfigureBuiltIn:p}){const l=i.get(e.id),u=A.get(e.id),h=u?.status==="needs_setup"||u?.status==="pending_approval",z=!!(l&&l.orgChainHealth?.status==="invalid_org_chain"),E=G(S,"agent",e.id),b=m.isPending&&m.variables?.resourceType==="agent"&&m.variables.resourceId===e.id,k=b&&m.variables?.starred!==void 0,y=b&&m.variables?.starred===void 0,_=ge(S,"agent",e.id);return(0,t.jsxs)("div",{style:{paddingLeft:a*24},children:[(0,t.jsxs)(de,{to:l?ce(l):`/agents/${e.id}`,className:B("group flex items-center gap-3 rounded-lg px-3 py-2 hover:bg-accent/50 transition-colors w-full text-left no-underline text-inherit",l?.pausedAt&&v!=="paused"&&"opacity-50",E==="left"&&"sm:text-foreground/55"),children:[z?(0,t.jsx)(me,{className:"h-3.5 w-3.5 shrink-0 text-amber-500","aria-label":"Invalid reporting chain"}):(0,t.jsx)(ue,{agent:l??e,size:24}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("div",{className:"min-w-(--sz-7rem) truncate",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground ml-2",children:[he[e.role]??e.role,l?.title?` - ${l.title}`:""]})]}),u&&h&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[(0,t.jsx)(fe,{status:u.status}),u.status==="needs_setup"&&(0,t.jsx)("span",{onClick:n(d=>{d.preventDefault(),d.stopPropagation()},"onClick"),children:(0,t.jsx)(V,{size:"xs",variant:"outline",onClick:n(()=>p(u),"onClick"),children:"Set up"})})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 shrink-0",children:[(0,t.jsx)("span",{className:"sm:hidden",children:r.has(e.id)?(0,t.jsx)(Q,{agentRef:l?U(l):e.id,runId:r.get(e.id).runId,liveCount:r.get(e.id).liveCount}):(0,t.jsx)(H,{status:e.status})}),(0,t.jsxs)("div",{className:"hidden sm:flex items-center gap-3",children:[r.has(e.id)&&(0,t.jsx)(Q,{agentRef:l?U(l):e.id,runId:r.get(e.id).runId,liveCount:r.get(e.id).liveCount}),l&&(0,t.jsx)("div",{className:"hidden xl:flex items-center gap-3",children:(0,t.jsx)(we,{agent:l,environment:x?ve:o.get(l.id)??J,showEnvironment:C})}),(0,t.jsx)("span",{className:"w-20 flex justify-end",children:(0,t.jsx)(H,{status:e.status})})]}),(0,t.jsx)(pe,{state:E,pending:y,pendingState:y?m.variables?.state:null,resourceName:e.name,onJoin:n(()=>m.mutate({resourceType:"agent",resourceId:e.id,resourceName:e.name,state:"joined"}),"onJoin"),onLeave:n(()=>m.mutate({resourceType:"agent",resourceId:e.id,resourceName:e.name,state:"left"}),"onLeave")}),(0,t.jsx)("div",{className:"hidden sm:flex items-center gap-3",children:(0,t.jsx)(xe,{size:"row",starred:_,pending:k,resourceName:e.name,onToggle:n(d=>m.mutate({resourceType:"agent",resourceId:e.id,resourceName:e.name,starred:d}),"onToggle")})})]})]}),e.reports&&e.reports.length>0&&(0,t.jsx)("div",{className:"border-l border-border ml-4",children:e.reports.map(d=>(0,t.jsx)(ye,{node:d,depth:a+1,agentMap:i,liveRunByAgent:r,environmentByAgentId:o,environmentDataLoading:x,showEnvironment:C,tab:v,memberships:S,membershipMutation:m,builtInByAgentId:A,onConfigureBuiltIn:p},d.id))})]})}n(ye,"OrgTreeNode");function we({agent:e,environment:a,showEnvironment:i}){const r=ut(e),o=et(e.adapterType);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"w-44 min-w-0 leading-tight",children:[(0,t.jsx)("div",{className:"truncate font-mono text-xs text-muted-foreground",title:r??void 0,children:r??"—"}),(0,t.jsx)("div",{className:"truncate font-mono text-(length:--text-micro) text-muted-foreground/70",title:o,children:o})]}),i&&(0,t.jsxs)("div",{className:"w-44 min-w-0 leading-tight",children:[(0,t.jsx)("div",{className:"truncate text-xs text-muted-foreground",title:a.title,children:a.label}),(0,t.jsx)("div",{className:"truncate text-(length:--text-micro) text-muted-foreground/70",children:a.detail})]}),(0,t.jsx)("span",{className:"w-24 whitespace-nowrap text-right text-xs text-muted-foreground",children:e.lastHeartbeatAt?Re(e.lastHeartbeatAt):"—"})]})}n(we,"AgentMetaColumns");function Q({agentRef:e,runId:a,liveCount:i}){return(0,t.jsxs)(de,{to:`/agents/${e}/runs/${a}`,className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-blue-500/10 hover:bg-blue-500/20 transition-colors no-underline",onClick:n(r=>r.stopPropagation(),"onClick"),children:[(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,t.jsx)("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-500"})]}),(0,t.jsxs)("span",{className:"text-(length:--text-micro) font-medium text-blue-600 dark:text-blue-400",children:["Live",i>1?` (${i})`:""]})]})}n(Q,"LiveRunIndicator");export{Mt as Agents};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-B9phYB96.js","assets/rolldown-runtime-ZpX3ckPj.js","assets/createLucideIcon-r3v6fbGz.js","assets/preload-helper-CceJXRIF.js","assets/router-Bb8nJWyv.js","assets/zap-P-cXfK28.js","assets/agents-BlSzFh-1.js","assets/EmptyState-DPcc0zYh.js","assets/button-CAPbz11u.js","assets/RoutineRunVariablesDialog-Bt4KAWCh.js","assets/mention-chips-DXumPrOR.js","assets/bot-DZDpMzjD.js","assets/MarkdownEditor-DfrwLv1M.js","assets/dist-D1zgkcBw.js","assets/dist-5v80Jc6A.js","assets/AgentAvatar-PT82VwmU.js","assets/dist-DCJXgQu0.js","assets/sheet-CQJe5sfn.js","assets/checkbox-757DLJRS.js","assets/check-DDiXDm2i.js","assets/chevron-right-B9JUOr38.js","assets/label-BueB30Ch.js","assets/StatusIcon-BuUYMqqU.js","assets/clipboard-CYJ5Q78m.js","assets/loader-circle-BD9wx-lw.js","assets/octagon-alert-rGMwyrWA.js","assets/select-mS22eY6T.js","assets/chevron-down-F9aZv-V7.js","assets/heartbeats-CK_aXmx5.js","assets/useHiddenSettings-2JpxuJV7.js","assets/health-DeeeogeJ.js","assets/rotate-ccw-CRAQ3Xng.js","assets/triangle-alert-CgJcxSQX.js","assets/badge-Cf7ihb3q.js","assets/environments-BVeNFanj.js","assets/input-DpsS9it-.js","assets/company-members-BcZm1g8Q.js","assets/AgentIdentity-MCshmbhZ.js","assets/card-dmVcp3AX.js","assets/PageSkeleton-DHjTwRT3.js","assets/skeleton-CKir8TUW.js","assets/tabs-DWRZjksg.js","assets/use-adapter-capabilities-BiWYK4zJ.js","assets/save-DUnPDT6R.js","assets/external-link-0lrOvZWO.js","assets/MarkdownBody-DJQ35hak.js","assets/file-text-C9vgFckt.js","assets/SidebarContext-D01pu4wh.js","assets/index-J-4PQOv1.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Pe=Object.defineProperty;var n=(e,a)=>Pe(e,"name",{value:a,configurable:!0});import{i as oe}from"./rolldown-runtime-ZpX3ckPj.js";import{En as ke,Fr as qe,Lr as Me,S as B,U as Fe,Y as j,_ as ce,g as U,nr as N,z as Re}from"./createLucideIcon-r3v6fbGz.js";import{t as $e}from"./preload-helper-CceJXRIF.js";import{it as Be,o as ze,t as de}from"./router-Bb8nJWyv.js";import{S as Ke}from"./zap-P-cXfK28.js";import{t as ue}from"./AgentAvatar-PT82VwmU.js";import{t as Oe}from"./tabs-DWRZjksg.js";import{t as ae}from"./agents-BlSzFh-1.js";import{r as De,t as re}from"./EmptyState-DPcc0zYh.js";import{t as ie}from"./bot-DZDpMzjD.js";import{k as Ue,t as V}from"./button-CAPbz11u.js";import{i as Ve,o as He,t as Ge}from"./heartbeats-CK_aXmx5.js";import{t as me}from"./triangle-alert-CgJcxSQX.js";import{n as Qe}from"./SidebarContext-D01pu4wh.js";import{n as Je,t as le}from"./environments-BVeNFanj.js";import{t as Ye}from"./PageSkeleton-DHjTwRT3.js";import{$t as We,It as Xe,Jt as Ze,Lt as pe,Wt as H,Yt as et,an as ge,cn as tt,dn as st,in as nt,nn as xe,on as G,rn as at,sn as rt,un as fe}from"./index-B9phYB96.js";var g=oe(Me(),1),t=oe(qe(),1),he=ke,it=(0,g.lazy)(()=>$e(()=>import("./index-B9phYB96.js").then(e=>e.wt).then(e=>({default:e.ConfigureBuiltInAgentModal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48]))),lt=["all","active","paused","error","builtin"],ot=[{value:"all",label:"All"},{value:"active",label:"Active"},{value:"paused",label:"Paused"},{value:"error",label:"Error"},{value:"builtin",label:"Built-in"}];function ct(e){return lt.includes(e)}n(ct,"isFilterTab");var J={label:"Local",detail:"Paperclip host",title:"Local - Paperclip host"},ve={label:"—",detail:"Loading environment",title:"Loading environment"},be=new Set(["terminated","pending_approval"]);function je(e,a){return a==="all"?!0:a==="active"?e==="active"||e==="running"||e==="idle":a==="paused"?e==="paused":a==="error"?e==="error":!0}n(je,"matchesFilter");function dt(e,a,i){return e.filter(r=>be.has(r.status)?!1:a==="builtin"?i.has(r.id):je(r.status,a)).sort((r,o)=>r.name.localeCompare(o.name))}n(dt,"filterAgents");function ut(e){const a=e.adapterConfig?.model;if(typeof a!="string")return null;const i=a.trim();return i.length>0?i:null}n(ut,"getConfiguredModel");function mt(e){return e==="ssh"?"SSH":e.charAt(0).toUpperCase()+e.slice(1)}n(mt,"formatEnvironmentDriver");function pt(e,a){const i=typeof e.config.provider=="string"?e.config.provider.trim():"";return i?a?.sandboxProviders?.[i]?.displayName??i:"Sandbox"}n(pt,"getSandboxProviderLabel");function gt(e,a){const i=Ze(e)?"Managed by Paperclip":e.driver==="sandbox"?`${pt(e,a)} sandbox provider`:e.driver==="local"?"Paperclip host":mt(e.driver);return{label:e.name,detail:i,title:`${e.name} - ${i}`}}n(gt,"describeEnvironment");function xt(e){return{label:"Unknown environment",detail:e.slice(0,8),title:`Unknown environment - ${e}`}}n(xt,"describeMissingEnvironment");function ft(e,a,i,r){const o=e.defaultEnvironmentId??i;if(!o)return J;const x=a.get(o);return x?gt(x,r):xt(o)}n(ft,"resolveAgentEnvironment");function Ne(e,a,i){return e.reduce((r,o)=>{const x=Ne(o.reports,a,i);return be.has(o.status)?(r.push(...x),r):(((a==="builtin"?i.has(o.id):je(o.status,a))||x.length>0)&&r.push({...o,reports:x}),r)},[]).sort((r,o)=>r.name.localeCompare(o.name))}n(Ne,"filterOrgTree");function Mt(){const{selectedCompanyId:e}=Fe(),{openNewAgent:a}=Ve(),{setBreadcrumbs:i}=De(),r=ze(),o=Be(),{isMobile:x}=Qe(),C=o.pathname.split("/").pop()??"all",v=ct(C)?C:"all",[S,m]=(0,g.useState)("org"),A=x,p=A?"list":S,{data:l}=N({queryKey:j.instance.settings,queryFn:n(()=>Je.get(),"queryFn"),enabled:!!e}),u=l?.experimental.enableBuiltInAgents===!0,h=v==="builtin"&&!u?"all":v,z=(0,g.useMemo)(()=>ot.filter(s=>s.value!=="builtin"||u),[u]),{data:E}=N({queryKey:j.builtInAgents.list(e),queryFn:n(()=>st.list(e),"queryFn"),enabled:!!e&&u}),b=(0,g.useMemo)(()=>{const s=new Map;if(!u)return s;for(const c of E??[])c.agentId&&s.set(c.agentId,c);return s},[E,u]),k=(0,g.useMemo)(()=>new Set(b.keys()),[b]),[y,_]=(0,g.useState)(null),{data:d,isLoading:Ie,error:Y}=N({queryKey:j.agents.list(e),queryFn:n(()=>ae.list(e),"queryFn"),enabled:!!e}),{data:T}=N({queryKey:j.org(e),queryFn:n(()=>ae.org(e),"queryFn"),enabled:!!e&&p==="org"}),q=l?.experimental.enableEnvironments===!0,{data:L}=N({queryKey:j.environments.list(e),queryFn:n(()=>le.list(e),"queryFn"),enabled:!!e&&q}),{data:W}=N({queryKey:j.environments.capabilities(e),queryFn:n(()=>le.capabilities(e),"queryFn"),enabled:!!e&&q}),X=[...j.liveRuns(e),"agents-page"],K=nt({companyId:e,resourceKey:"live-runs:agents-page",queryKey:X,enabled:!!e,refetchInterval:15e3,leaderOnly:!0}),{data:O,dataUpdatedAt:Ce}=N({queryKey:X,queryFn:n(()=>Ge.liveRunsForCompany(e),"queryFn"),enabled:K.enabled,refetchInterval:K.refetchInterval});at(K,O,Ce);const M=tt(e),f=rt(e),F=(0,g.useMemo)(()=>{const s=new Map;for(const c of O??[]){if(c.status!=="running"&&c.status!=="queued")continue;const P=s.get(c.agentId);if(P){P.liveCount+=1;continue}s.set(c.agentId,{runId:c.id,liveCount:1})}return s},[O]),Se=(0,g.useMemo)(()=>{const s=new Map;for(const c of d??[])s.set(c.id,c);return s},[d]),Z=(0,g.useMemo)(()=>{const s=new Map;for(const c of L??[])s.set(c.id,c);return s},[L]),ee=(0,g.useMemo)(()=>{const s=new Map;for(const c of d??[])s.set(c.id,ft(c,Z,l?.defaultEnvironmentId??null,W));return s},[d,Z,W,l?.defaultEnvironmentId]);if((0,g.useEffect)(()=>{i([{label:"Agents"}])},[i]),(0,g.useEffect)(()=>{e&&v==="builtin"&&l&&!u&&r("/agents/all",{replace:!0})},[u,l,r,v,e]),!e)return(0,t.jsx)(re,{icon:ie,message:"Select a company to view agents."});if(Ie)return(0,t.jsx)(Ye,{variant:"list"});const w=dt(d??[],h,k),D=Ne(T??[],h,k),te=q&&L===void 0,se=q&&(L===void 0||L.length>1),Ae=n(s=>te?ve:ee.get(s)??J,"resolveRenderedEnvironment"),Ee=n(s=>{const c=s.orgChainHealth?.status==="invalid_org_chain",P=f.isPending&&f.variables?.resourceType==="agent"&&f.variables.resourceId===s.id,_e=P&&f.variables?.starred!==void 0,ne=P&&f.variables?.starred===void 0,Te=ge(M.data,"agent",s.id),I=b.get(s.id),Le=I?.status==="needs_setup"||I?.status==="pending_approval",R=I&&Le?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(fe,{status:I.status}),I.status==="needs_setup"&&(0,t.jsx)("span",{onClick:n($=>{$.preventDefault(),$.stopPropagation()},"onClick"),children:(0,t.jsx)(V,{size:"xs",variant:"outline",onClick:n(()=>_(I),"onClick"),children:"Set up"})})]}):null;return(0,t.jsx)(Xe,{title:s.name,titleClassName:"flex-1 xl:flex-none xl:w-56",titleTextClassName:"whitespace-normal break-words xl:truncate xl:whitespace-nowrap",subtitleClassName:"whitespace-normal break-words xl:truncate xl:whitespace-nowrap",subtitle:`${he[s.role]??s.role}${s.title?` - ${s.title}`:""}`,to:ce(s),className:B("group",s.pausedAt&&h!=="paused"?"opacity-50":"",G(M.data,"agent",s.id)==="left"?"sm:text-foreground/55":""),leading:c?(0,t.jsx)(me,{className:"h-3.5 w-3.5 text-amber-500","aria-label":"Invalid reporting chain"}):(0,t.jsx)(ue,{agent:s,size:32}),secondaryRow:R?(0,t.jsx)("div",{className:"xl:hidden flex flex-wrap items-center gap-1.5",children:R}):void 0,meta:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[R&&(0,t.jsx)("div",{className:"hidden xl:flex items-center gap-1.5",children:R}),(0,t.jsx)("div",{className:"hidden xl:flex items-center gap-3",children:(0,t.jsx)(we,{agent:s,environment:Ae(s.id),showEnvironment:se})})]}),metaSpacerClassName:"hidden xl:block",trailing:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsxs)("div",{className:"hidden sm:flex items-center gap-3",children:[F.has(s.id)&&(0,t.jsx)(Q,{agentRef:U(s),runId:F.get(s.id).runId,liveCount:F.get(s.id).liveCount}),(0,t.jsx)("span",{className:"w-20 flex justify-end",children:(0,t.jsx)(H,{status:s.status})}),(0,t.jsx)(xe,{size:"row",starred:Te,pending:_e,resourceName:s.name,onToggle:n($=>f.mutate({resourceType:"agent",resourceId:s.id,resourceName:s.name,starred:$}),"onToggle")})]}),(0,t.jsx)(pe,{state:G(M.data,"agent",s.id),pending:ne,pendingState:ne?f.variables?.state??null:null,resourceName:s.name,onJoin:n(()=>f.mutate({resourceType:"agent",resourceId:s.id,resourceName:s.name,state:"joined"}),"onJoin"),onLeave:n(()=>f.mutate({resourceType:"agent",resourceId:s.id,resourceName:s.name,state:"left"}),"onLeave")})]})},s.id)},"renderAgentRow");return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsx)(Oe,{value:h,onValueChange:n(s=>r(`/agents/${s}`),"onValueChange"),children:(0,t.jsx)(We,{items:z,value:h,onValueChange:n(s=>r(`/agents/${s}`),"onValueChange")})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[!A&&(0,t.jsxs)("div",{className:"flex items-center border border-border",role:"group","aria-label":"View mode",children:[(0,t.jsx)("button",{className:B("p-1.5 transition-colors",p==="list"?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50"),onClick:n(()=>m("list"),"onClick"),title:"List view","aria-label":"List view","aria-pressed":p==="list",children:(0,t.jsx)(He,{className:"h-3.5 w-3.5"})}),(0,t.jsx)("button",{className:B("p-1.5 transition-colors",p==="org"?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50"),onClick:n(()=>m("org"),"onClick"),title:"Org chart view","aria-label":"Org chart view","aria-pressed":p==="org",children:(0,t.jsx)(Ke,{className:"h-3.5 w-3.5"})})]}),(0,t.jsxs)(V,{size:"sm",variant:"outline",onClick:a,children:[(0,t.jsx)(Ue,{className:"h-3.5 w-3.5 mr-1.5"}),"New Agent"]})]})]}),w.length>0&&(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[w.length," agent",w.length!==1?"s":""]}),Y&&(0,t.jsx)("p",{className:"text-sm text-destructive",children:Y.message}),d&&d.length===0&&(0,t.jsx)(re,{icon:ie,message:"Create your first agent to get started.",action:"New Agent",onAction:a}),p==="list"&&w.length>0&&(0,t.jsx)("div",{children:w.map(Ee)}),p==="list"&&d&&d.length>0&&w.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No agents match the selected status."}),p==="org"&&D.length>0&&(0,t.jsx)("div",{className:"py-1",children:D.map(s=>(0,t.jsx)(ye,{node:s,depth:0,agentMap:Se,liveRunByAgent:F,environmentByAgentId:ee,environmentDataLoading:te,showEnvironment:se,tab:h,memberships:M.data,membershipMutation:f,builtInByAgentId:b,onConfigureBuiltIn:_},s.id))}),p==="org"&&T&&T.length>0&&D.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No agents match the selected status."}),p==="org"&&T&&T.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No organizational hierarchy defined."}),y&&e&&(0,t.jsx)(g.Suspense,{fallback:null,children:(0,t.jsx)(it,{companyId:e,state:y,open:y!==null,onOpenChange:n(s=>{s||_(null)},"onOpenChange")})})]})}n(Mt,"Agents");function ye({node:e,depth:a,agentMap:i,liveRunByAgent:r,environmentByAgentId:o,environmentDataLoading:x,showEnvironment:C,tab:v,memberships:S,membershipMutation:m,builtInByAgentId:A,onConfigureBuiltIn:p}){const l=i.get(e.id),u=A.get(e.id),h=u?.status==="needs_setup"||u?.status==="pending_approval",z=!!(l&&l.orgChainHealth?.status==="invalid_org_chain"),E=G(S,"agent",e.id),b=m.isPending&&m.variables?.resourceType==="agent"&&m.variables.resourceId===e.id,k=b&&m.variables?.starred!==void 0,y=b&&m.variables?.starred===void 0,_=ge(S,"agent",e.id);return(0,t.jsxs)("div",{style:{paddingLeft:a*24},children:[(0,t.jsxs)(de,{to:l?ce(l):`/agents/${e.id}`,className:B("group flex items-center gap-3 rounded-lg px-3 py-2 hover:bg-accent/50 transition-colors w-full text-left no-underline text-inherit",l?.pausedAt&&v!=="paused"&&"opacity-50",E==="left"&&"sm:text-foreground/55"),children:[z?(0,t.jsx)(me,{className:"h-3.5 w-3.5 shrink-0 text-amber-500","aria-label":"Invalid reporting chain"}):(0,t.jsx)(ue,{agent:l??e,size:24}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("div",{className:"min-w-(--sz-7rem) truncate",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground ml-2",children:[he[e.role]??e.role,l?.title?` - ${l.title}`:""]})]}),u&&h&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[(0,t.jsx)(fe,{status:u.status}),u.status==="needs_setup"&&(0,t.jsx)("span",{onClick:n(d=>{d.preventDefault(),d.stopPropagation()},"onClick"),children:(0,t.jsx)(V,{size:"xs",variant:"outline",onClick:n(()=>p(u),"onClick"),children:"Set up"})})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 shrink-0",children:[(0,t.jsx)("span",{className:"sm:hidden",children:r.has(e.id)?(0,t.jsx)(Q,{agentRef:l?U(l):e.id,runId:r.get(e.id).runId,liveCount:r.get(e.id).liveCount}):(0,t.jsx)(H,{status:e.status})}),(0,t.jsxs)("div",{className:"hidden sm:flex items-center gap-3",children:[r.has(e.id)&&(0,t.jsx)(Q,{agentRef:l?U(l):e.id,runId:r.get(e.id).runId,liveCount:r.get(e.id).liveCount}),l&&(0,t.jsx)("div",{className:"hidden xl:flex items-center gap-3",children:(0,t.jsx)(we,{agent:l,environment:x?ve:o.get(l.id)??J,showEnvironment:C})}),(0,t.jsx)("span",{className:"w-20 flex justify-end",children:(0,t.jsx)(H,{status:e.status})})]}),(0,t.jsx)(pe,{state:E,pending:y,pendingState:y?m.variables?.state:null,resourceName:e.name,onJoin:n(()=>m.mutate({resourceType:"agent",resourceId:e.id,resourceName:e.name,state:"joined"}),"onJoin"),onLeave:n(()=>m.mutate({resourceType:"agent",resourceId:e.id,resourceName:e.name,state:"left"}),"onLeave")}),(0,t.jsx)("div",{className:"hidden sm:flex items-center gap-3",children:(0,t.jsx)(xe,{size:"row",starred:_,pending:k,resourceName:e.name,onToggle:n(d=>m.mutate({resourceType:"agent",resourceId:e.id,resourceName:e.name,starred:d}),"onToggle")})})]})]}),e.reports&&e.reports.length>0&&(0,t.jsx)("div",{className:"border-l border-border ml-4",children:e.reports.map(d=>(0,t.jsx)(ye,{node:d,depth:a+1,agentMap:i,liveRunByAgent:r,environmentByAgentId:o,environmentDataLoading:x,showEnvironment:C,tab:v,memberships:S,membershipMutation:m,builtInByAgentId:A,onConfigureBuiltIn:p},d.id))})]})}n(ye,"OrgTreeNode");function we({agent:e,environment:a,showEnvironment:i}){const r=ut(e),o=et(e.adapterType);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"w-44 min-w-0 leading-tight",children:[(0,t.jsx)("div",{className:"truncate font-mono text-xs text-muted-foreground",title:r??void 0,children:r??"—"}),(0,t.jsx)("div",{className:"truncate font-mono text-(length:--text-micro) text-muted-foreground/70",title:o,children:o})]}),i&&(0,t.jsxs)("div",{className:"w-44 min-w-0 leading-tight",children:[(0,t.jsx)("div",{className:"truncate text-xs text-muted-foreground",title:a.title,children:a.label}),(0,t.jsx)("div",{className:"truncate text-(length:--text-micro) text-muted-foreground/70",children:a.detail})]}),(0,t.jsx)("span",{className:"w-24 whitespace-nowrap text-right text-xs text-muted-foreground",children:e.lastHeartbeatAt?Re(e.lastHeartbeatAt):"—"})]})}n(we,"AgentMetaColumns");function Q({agentRef:e,runId:a,liveCount:i}){return(0,t.jsxs)(de,{to:`/agents/${e}/runs/${a}`,className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-blue-500/10 hover:bg-blue-500/20 transition-colors no-underline",onClick:n(r=>r.stopPropagation(),"onClick"),children:[(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,t.jsx)("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-500"})]}),(0,t.jsxs)("span",{className:"text-(length:--text-micro) font-medium text-blue-600 dark:text-blue-400",children:["Live",i>1?` (${i})`:""]})]})}n(Q,"LiveRunIndicator");export{Mt as Agents};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var xe=Object.defineProperty;var r=(t,a)=>xe(t,"name",{value:a,configurable:!0});import{i as ne}from"./rolldown-runtime-ZpX3ckPj.js";import{Fr as pe,Lr as he,S as ge,U as fe,Y as G,Yn as W,nr as X,z as ye}from"./createLucideIcon-r3v6fbGz.js";import{ct as ve,t as re}from"./router-Bb8nJWyv.js";import{r as ee,t as je}from"./AgentAvatar-PT82VwmU.js";import{i as te,r as be,t as Ne}from"./tabs-DWRZjksg.js";import{t as we}from"./agents-BlSzFh-1.js";import{r as Ae,t as Te}from"./EmptyState-DPcc0zYh.js";import{c as _,i as y,n as D,s as F,t as k}from"./select-mS22eY6T.js";import{t as T}from"./button-CAPbz11u.js";import{t as se}from"./input-DpsS9it-.js";import{o as Se,r as Ce}from"./company-members-BcZm1g8Q.js";import{r as v,t as j}from"./card-dmVcp3AX.js";import{Gn as Ee,O as ae,Pn as Ie,Rt as Ue,_n as Pe,bn as Le,fn as Re,yn as _e}from"./index-DGStZYMS.js";var l=ne(he(),1),e=ne(pe(),1),De=50,n="__all",Fe=[{value:n,label:"All actions"},{value:"issue.",label:"Tasks"},{value:"agent.",label:"Agents"},{value:"heartbeat.",label:"Runs"},{value:"approval.",label:"Approvals"},{value:"project.",label:"Projects"},{value:"goal.",label:"Goals"},{value:"tool_gateway.",label:"Tools"},{value:"cost.",label:"Costs"},{value:"company.",label:"Company"}],ke=[{value:n,label:"All entities"},{value:"issue",label:"Task"},{value:"agent",label:"Agent"},{value:"project",label:"Project"},{value:"goal",label:"Goal"},{value:"company",label:"Company"}];function Be(t){if(!t)return;const a=new Date(`${t}T00:00:00.000Z`);return Number.isNaN(a.getTime())?void 0:a.toISOString()}r(Be,"toStartIso");function Ve(t){if(!t)return;const a=new Date(`${t}T23:59:59.999Z`);return Number.isNaN(a.getTime())?void 0:a.toISOString()}r(Ve,"toEndIso");function $e({record:t,agentMap:a,userProfileMap:d}){const u=t.agentId??(t.actorType==="agent"?t.actorId:null),c=u?a.get(u):null;if(c)return(0,e.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-1.5",title:c.name,children:[(0,e.jsx)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground",children:(0,e.jsx)(je,{agent:c,size:16,className:"h-3 w-3"})}),(0,e.jsx)("span",{className:"truncate font-medium text-foreground",children:c.name})]});if(t.actorType==="user"&&t.actorId){const m=d.get(t.actorId);return(0,e.jsx)(ee,{name:m?.label??"User",avatarUrl:m?.image??null,size:"sm",className:"font-medium text-foreground"})}const h=t.actorType==="plugin"?"Plugin":t.actorType==="agent"?"Agent":t.actorType==="user"?"User":"System";return(0,e.jsx)(ee,{name:h,size:"sm",className:"font-medium text-foreground"})}r($e,"AuditActor");function qe({record:t}){const{issue:a,document:d}=t.entity,u=a?.identifier??a?.id??null;return u?(0,e.jsx)(re,{to:`/issues/${u}`,className:"font-medium text-primary hover:underline",children:a?.identifier?`${a.identifier}${a.title?` · ${a.title}`:""}`:"the task"}):d?(0,e.jsx)("span",{className:"font-medium text-foreground",children:d.key}):(0,e.jsx)("span",{className:"text-muted-foreground",children:t.entityType})}r(qe,"AuditEntityNode");function ze({record:t,agentMap:a,userProfileMap:d}){const u=Ue(t.action,t.details,{agentMap:a,userProfileMap:d}),c=t.responsibleUserId?d.get(t.responsibleUserId):null,h=!!(t.responsibleUserId&&!(t.actorType==="user"&&t.actorId===t.responsibleUserId)),m=c?.label??(t.responsibleUserId?"a user":null),g=t.entity.comment?.excerpt?.trim(),x=t.entity.issue&&t.entity.document?t.entity.document.key:null;return(0,e.jsx)("li",{className:"px-4 py-3 text-sm",children:(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-x-1.5 gap-y-1 text-foreground",children:[(0,e.jsx)($e,{record:t,agentMap:a,userProfileMap:d}),(0,e.jsx)("span",{className:"text-muted-foreground",children:u}),(0,e.jsx)(qe,{record:t})]}),g?(0,e.jsxs)("p",{className:"line-clamp-2 border-l-2 border-border pl-2 text-muted-foreground",children:["“",g,"”"]}):null,x?(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Document ",(0,e.jsx)("span",{className:"font-mono text-(length:--text-micro)",children:x})]}):null,(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[h&&m?(0,e.jsxs)("span",{className:"inline-flex items-center rounded-full bg-muted px-2 py-0.5",children:["on behalf of ",m]}):null,t.runId&&t.agentId?(0,e.jsx)(re,{to:`/agents/${t.agentId}/runs/${t.runId}`,className:"text-primary hover:underline",children:"View run"}):null,(0,e.jsx)("span",{className:"font-mono text-(length:--text-micro) opacity-70",children:t.action})]})]}),(0,e.jsx)("time",{className:"shrink-0 whitespace-nowrap text-xs text-muted-foreground",dateTime:t.createdAt,title:new Date(t.createdAt).toLocaleString(),children:ye(t.createdAt)})]})})}r(ze,"AuditRow");function Me(){return(0,e.jsx)(j,{children:(0,e.jsxs)(v,{className:"flex flex-col items-center gap-3 py-14 text-center",children:[(0,e.jsx)(Pe,{className:"h-10 w-10 text-muted-foreground/50"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Agent audit is a Paperclip Enterprise view"}),(0,e.jsxs)("p",{className:"mx-auto mt-1 max-w-md text-sm text-muted-foreground",children:["The agent audit log gives you a searchable, exportable record of everything your agents did — every comment, task change, approval, and run — with the responsible person for each action. Ask an administrator to grant you the"," ",(0,e.jsx)("span",{className:"font-mono text-(length:--text-micro)",children:"audit:view_agent_actions"})," ","permission to view it."]})]})]})})}r(Me,"AuditUpsell");function Oe({companyId:t,lockedAgentId:a,hideHeader:d,mode:u,onModeChange:c}){const{pushToast:h}=Re(),[m,g]=(0,l.useState)(n),[x,B]=(0,l.useState)(n),[S,V]=(0,l.useState)(n),[C,$]=(0,l.useState)(n),[E,q]=(0,l.useState)(""),[I,z]=(0,l.useState)(""),[Z,Q]=(0,l.useState)(!1),[U,H]=(0,l.useState)(!1),M=X({queryKey:G.agents.list(t),queryFn:r(()=>we.list(t),"queryFn")}),O=X({queryKey:G.access.companyUserDirectory(t),queryFn:r(()=>Se.listUserDirectory(t),"queryFn"),retry:!1}),ie=(0,l.useMemo)(()=>new Map((M.data??[]).map(s=>[s.id,s])),[M.data]),le=(0,l.useMemo)(()=>Ce(O.data?.users),[O.data]),f=a?"agents":u??"all",o={actorScope:f,agentId:a??(m===n?void 0:m),responsibleUserId:x===n?void 0:x,action:S===n?void 0:S,entityType:C===n?void 0:C,from:Be(E),to:Ve(I)},b=!!(!a&&m!==n||x!==n||S!==n||C!==n||E||I),i=Ee({queryKey:G.audit.agentActions(t,{actorScope:o.actorScope,agentId:o.agentId,responsibleUserId:o.responsibleUserId,action:o.action,entityType:o.entityType,from:o.from,to:o.to}),queryFn:r(({pageParam:s})=>ae.listAgentActions(t,{...o,limit:De,cursor:s??void 0}),"queryFn"),initialPageParam:null,getNextPageParam:r(s=>s.nextCursor??void 0,"getNextPageParam"),retry:r((s,p)=>!(p instanceof W&&p.status===403)&&s<2,"retry")}),K=i.error instanceof W&&i.error.status===403,P=i.data?.pages.some(s=>s.accessTier==="basic")??!1,oe=i.data?.pages.some(s=>s.accessTier==="full")??!1,Y=(0,l.useMemo)(()=>{const s=i.data?.pages??[];return(P?s.filter(p=>p.accessTier!=="full"):s).flatMap(p=>p.items)},[i.data,P]),L=P?"basic":i.data?.pages[0]?.accessTier,N=P&&oe,ce=a?!0:L==="full",de=!!(N&&U&&!i.isFetching),R=!!(!a&&!de&&(K&&b||N)),w=!!(K&&!a&&f==="agents"&&c),ue=!!(!a&&c&&!w&&(f==="agents"||L==="full"));(0,l.useEffect)(()=>{w&&c?.("all")},[w,c]),(0,l.useEffect)(()=>{!a&&(L==="basic"||R)&&(g(n),B(n),V(n),$(n),q(""),z(""))},[L,N,a,R]),(0,l.useEffect)(()=>{if(!N){U&&H(!1);return}U||(H(!0),i.refetch())},[U,i,N]);const J=r(()=>{g(n),B(n),V(n),$(n),q(""),z("")},"clearFilters"),me=r(async()=>{Q(!0);try{const s=await ae.exportAgentActionsCsv(t,{actorScope:o.actorScope,agentId:o.agentId,responsibleUserId:o.responsibleUserId,action:o.action,entityType:o.entityType,from:o.from,to:o.to}),p=URL.createObjectURL(s),A=document.createElement("a");A.href=p,A.download=`${f==="agents"?"agent-audit":"activity"}-${t}.csv`,document.body.appendChild(A),A.click(),A.remove(),window.setTimeout(()=>URL.revokeObjectURL(p),5e3),h({title:"Audit exported",body:"Your CSV download has started.",tone:"success"})}catch(s){h({title:"Export failed",body:s instanceof Error?s.message:"Could not export the audit log.",tone:"error"})}finally{Q(!1)}},"handleExport");return K&&!R&&!w?(0,e.jsx)(Me,{}):(0,e.jsxs)("div",{className:"space-y-4",children:[d?null:(0,e.jsx)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:(0,e.jsxs)("div",{children:[(0,e.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Activity"}),(0,e.jsx)("p",{className:"mt-1 max-w-2xl text-sm text-muted-foreground",children:f==="agents"?"Every recorded agent action, newest first — with the responsible person and run behind each one.":"Everything happening in your company, newest first — people, agents, and the system. Each line is one recorded action."})]})}),ue?(0,e.jsx)(Ne,{value:f,onValueChange:r(s=>c?.(s),"onValueChange"),children:(0,e.jsxs)(be,{"aria-label":"Activity scope",children:[(0,e.jsx)(te,{value:"all",children:"All activity"}),(0,e.jsx)(te,{value:"agents",children:"Agent actions"})]})}):null,ce?(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[a?null:(0,e.jsxs)(k,{value:m,onValueChange:g,children:[(0,e.jsx)(F,{className:"w-40",children:(0,e.jsx)(_,{placeholder:"Agent"})}),(0,e.jsxs)(D,{children:[(0,e.jsx)(y,{value:n,children:"All agents"}),(M.data??[]).map(s=>(0,e.jsx)(y,{value:s.id,children:s.name},s.id))]})]}),(0,e.jsxs)(k,{value:x,onValueChange:B,children:[(0,e.jsx)(F,{className:"w-52",children:(0,e.jsx)(_,{placeholder:"Responsible user"})}),(0,e.jsxs)(D,{children:[(0,e.jsx)(y,{value:n,children:"All responsible users"}),(O.data?.users??[]).map(s=>(0,e.jsx)(y,{value:s.principalId,children:s.user?.name??s.user?.email??s.principalId.slice(0,8)},s.principalId))]})]}),(0,e.jsxs)(k,{value:S,onValueChange:V,children:[(0,e.jsx)(F,{className:"w-36",children:(0,e.jsx)(_,{placeholder:"Action"})}),(0,e.jsx)(D,{children:Fe.map(s=>(0,e.jsx)(y,{value:s.value,children:s.label},s.value))})]}),(0,e.jsxs)(k,{value:C,onValueChange:$,children:[(0,e.jsx)(F,{className:"w-36",children:(0,e.jsx)(_,{placeholder:"Entity"})}),(0,e.jsx)(D,{children:ke.map(s=>(0,e.jsx)(y,{value:s.value,children:s.label},s.value))})]}),(0,e.jsx)(se,{type:"date","aria-label":"From date",value:E,max:I||void 0,onChange:r(s=>q(s.target.value),"onChange"),className:"w-36"}),(0,e.jsx)(se,{type:"date","aria-label":"To date",value:I,min:E||void 0,onChange:r(s=>z(s.target.value),"onChange"),className:"w-36"}),b?(0,e.jsx)(T,{variant:"ghost",size:"sm",onClick:J,children:"Clear filters"}):null,(0,e.jsxs)(T,{variant:"outline",size:"sm",className:"ml-auto",onClick:me,disabled:Z||i.isLoading||Y.length===0,children:[(0,e.jsx)(Ie,{className:"mr-1.5 h-4 w-4"}),Z?"Exporting…":"Export CSV"]})]}):null,R||w?(0,e.jsx)(j,{children:(0,e.jsx)(v,{className:"py-14 text-center text-sm text-muted-foreground",children:"Refreshing audit access…"})}):i.isLoading?(0,e.jsx)(j,{children:(0,e.jsx)(v,{className:"py-14 text-center text-sm text-muted-foreground",children:"Loading…"})}):i.error?(0,e.jsx)(j,{children:(0,e.jsxs)(v,{className:"flex flex-col items-center gap-3 py-14 text-center",children:[(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:i.error instanceof Error?i.error.message:"Failed to load the audit log."}),(0,e.jsx)(T,{variant:"outline",size:"sm",onClick:r(()=>i.refetch(),"onClick"),children:"Try again"})]})}):Y.length===0?(0,e.jsx)(j,{children:(0,e.jsxs)(v,{className:"flex flex-col items-center gap-3 py-14 text-center",children:[(0,e.jsx)(_e,{className:"h-10 w-10 text-muted-foreground/40"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-medium text-foreground",children:b?"No actions match these filters":"Nothing here yet"}),(0,e.jsx)("p",{className:"mt-1 max-w-md text-sm text-muted-foreground",children:b?"Try a wider date range or different filters.":f==="agents"?"As soon as your agents start doing things, their actions show up here.":"As soon as anyone in your company does something, it shows up here."})]}),b?(0,e.jsx)(T,{variant:"outline",size:"sm",onClick:J,children:"Clear filters"}):null]})}):(0,e.jsx)(j,{children:(0,e.jsx)(v,{className:"px-0 py-0",children:(0,e.jsx)("ul",{className:ge("divide-y divide-border"),children:Y.map(s=>(0,e.jsx)(ze,{record:s,agentMap:ie,userProfileMap:le},s.id))})})}),i.hasNextPage?(0,e.jsx)("div",{className:"flex justify-center",children:(0,e.jsx)(T,{variant:"outline",size:"sm",onClick:r(()=>i.fetchNextPage(),"onClick"),disabled:i.isFetchingNextPage,children:i.isFetchingNextPage?"Loading…":"Load more"})}):null,(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Recorded by Paperclip — entries can't be edited. Sensitive values are never stored."})]})}r(Oe,"AuditFeed");function rt(){const{selectedCompanyId:t}=fe(),{setBreadcrumbs:a}=Ae(),[d,u]=ve(),c=d.get("mode")==="agents"?"agents":"all";(0,l.useEffect)(()=>{a([{label:"Activity"}])},[a]);const h=(0,l.useCallback)(m=>{u(g=>{const x=new URLSearchParams(g);return m==="agents"?x.set("mode","agents"):x.delete("mode"),x},{replace:!0})},[u]);return t?(0,e.jsx)(Oe,{companyId:t,mode:c,onModeChange:h}):(0,e.jsx)(Te,{icon:Le,message:"Select a company to view activity."})}r(rt,"CompanyActivity");export{rt as CompanyActivity};
|
|
1
|
+
var xe=Object.defineProperty;var r=(t,a)=>xe(t,"name",{value:a,configurable:!0});import{i as ne}from"./rolldown-runtime-ZpX3ckPj.js";import{Fr as pe,Lr as he,S as ge,U as fe,Y as G,Yn as W,nr as X,z as ye}from"./createLucideIcon-r3v6fbGz.js";import{ct as ve,t as re}from"./router-Bb8nJWyv.js";import{r as ee,t as je}from"./AgentAvatar-PT82VwmU.js";import{i as te,r as be,t as Ne}from"./tabs-DWRZjksg.js";import{t as we}from"./agents-BlSzFh-1.js";import{r as Ae,t as Te}from"./EmptyState-DPcc0zYh.js";import{c as _,i as y,n as D,s as F,t as k}from"./select-mS22eY6T.js";import{t as T}from"./button-CAPbz11u.js";import{t as se}from"./input-DpsS9it-.js";import{o as Se,r as Ce}from"./company-members-BcZm1g8Q.js";import{r as v,t as j}from"./card-dmVcp3AX.js";import{Gn as Ee,O as ae,Pn as Ie,Rt as Ue,_n as Pe,bn as Le,fn as Re,yn as _e}from"./index-B9phYB96.js";var l=ne(he(),1),e=ne(pe(),1),De=50,n="__all",Fe=[{value:n,label:"All actions"},{value:"issue.",label:"Tasks"},{value:"agent.",label:"Agents"},{value:"heartbeat.",label:"Runs"},{value:"approval.",label:"Approvals"},{value:"project.",label:"Projects"},{value:"goal.",label:"Goals"},{value:"tool_gateway.",label:"Tools"},{value:"cost.",label:"Costs"},{value:"company.",label:"Company"}],ke=[{value:n,label:"All entities"},{value:"issue",label:"Task"},{value:"agent",label:"Agent"},{value:"project",label:"Project"},{value:"goal",label:"Goal"},{value:"company",label:"Company"}];function Be(t){if(!t)return;const a=new Date(`${t}T00:00:00.000Z`);return Number.isNaN(a.getTime())?void 0:a.toISOString()}r(Be,"toStartIso");function Ve(t){if(!t)return;const a=new Date(`${t}T23:59:59.999Z`);return Number.isNaN(a.getTime())?void 0:a.toISOString()}r(Ve,"toEndIso");function $e({record:t,agentMap:a,userProfileMap:d}){const u=t.agentId??(t.actorType==="agent"?t.actorId:null),c=u?a.get(u):null;if(c)return(0,e.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-1.5",title:c.name,children:[(0,e.jsx)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground",children:(0,e.jsx)(je,{agent:c,size:16,className:"h-3 w-3"})}),(0,e.jsx)("span",{className:"truncate font-medium text-foreground",children:c.name})]});if(t.actorType==="user"&&t.actorId){const m=d.get(t.actorId);return(0,e.jsx)(ee,{name:m?.label??"User",avatarUrl:m?.image??null,size:"sm",className:"font-medium text-foreground"})}const h=t.actorType==="plugin"?"Plugin":t.actorType==="agent"?"Agent":t.actorType==="user"?"User":"System";return(0,e.jsx)(ee,{name:h,size:"sm",className:"font-medium text-foreground"})}r($e,"AuditActor");function qe({record:t}){const{issue:a,document:d}=t.entity,u=a?.identifier??a?.id??null;return u?(0,e.jsx)(re,{to:`/issues/${u}`,className:"font-medium text-primary hover:underline",children:a?.identifier?`${a.identifier}${a.title?` · ${a.title}`:""}`:"the task"}):d?(0,e.jsx)("span",{className:"font-medium text-foreground",children:d.key}):(0,e.jsx)("span",{className:"text-muted-foreground",children:t.entityType})}r(qe,"AuditEntityNode");function ze({record:t,agentMap:a,userProfileMap:d}){const u=Ue(t.action,t.details,{agentMap:a,userProfileMap:d}),c=t.responsibleUserId?d.get(t.responsibleUserId):null,h=!!(t.responsibleUserId&&!(t.actorType==="user"&&t.actorId===t.responsibleUserId)),m=c?.label??(t.responsibleUserId?"a user":null),g=t.entity.comment?.excerpt?.trim(),x=t.entity.issue&&t.entity.document?t.entity.document.key:null;return(0,e.jsx)("li",{className:"px-4 py-3 text-sm",children:(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-x-1.5 gap-y-1 text-foreground",children:[(0,e.jsx)($e,{record:t,agentMap:a,userProfileMap:d}),(0,e.jsx)("span",{className:"text-muted-foreground",children:u}),(0,e.jsx)(qe,{record:t})]}),g?(0,e.jsxs)("p",{className:"line-clamp-2 border-l-2 border-border pl-2 text-muted-foreground",children:["“",g,"”"]}):null,x?(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Document ",(0,e.jsx)("span",{className:"font-mono text-(length:--text-micro)",children:x})]}):null,(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[h&&m?(0,e.jsxs)("span",{className:"inline-flex items-center rounded-full bg-muted px-2 py-0.5",children:["on behalf of ",m]}):null,t.runId&&t.agentId?(0,e.jsx)(re,{to:`/agents/${t.agentId}/runs/${t.runId}`,className:"text-primary hover:underline",children:"View run"}):null,(0,e.jsx)("span",{className:"font-mono text-(length:--text-micro) opacity-70",children:t.action})]})]}),(0,e.jsx)("time",{className:"shrink-0 whitespace-nowrap text-xs text-muted-foreground",dateTime:t.createdAt,title:new Date(t.createdAt).toLocaleString(),children:ye(t.createdAt)})]})})}r(ze,"AuditRow");function Me(){return(0,e.jsx)(j,{children:(0,e.jsxs)(v,{className:"flex flex-col items-center gap-3 py-14 text-center",children:[(0,e.jsx)(Pe,{className:"h-10 w-10 text-muted-foreground/50"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Agent audit is a Paperclip Enterprise view"}),(0,e.jsxs)("p",{className:"mx-auto mt-1 max-w-md text-sm text-muted-foreground",children:["The agent audit log gives you a searchable, exportable record of everything your agents did — every comment, task change, approval, and run — with the responsible person for each action. Ask an administrator to grant you the"," ",(0,e.jsx)("span",{className:"font-mono text-(length:--text-micro)",children:"audit:view_agent_actions"})," ","permission to view it."]})]})]})})}r(Me,"AuditUpsell");function Oe({companyId:t,lockedAgentId:a,hideHeader:d,mode:u,onModeChange:c}){const{pushToast:h}=Re(),[m,g]=(0,l.useState)(n),[x,B]=(0,l.useState)(n),[S,V]=(0,l.useState)(n),[C,$]=(0,l.useState)(n),[E,q]=(0,l.useState)(""),[I,z]=(0,l.useState)(""),[Z,Q]=(0,l.useState)(!1),[U,H]=(0,l.useState)(!1),M=X({queryKey:G.agents.list(t),queryFn:r(()=>we.list(t),"queryFn")}),O=X({queryKey:G.access.companyUserDirectory(t),queryFn:r(()=>Se.listUserDirectory(t),"queryFn"),retry:!1}),ie=(0,l.useMemo)(()=>new Map((M.data??[]).map(s=>[s.id,s])),[M.data]),le=(0,l.useMemo)(()=>Ce(O.data?.users),[O.data]),f=a?"agents":u??"all",o={actorScope:f,agentId:a??(m===n?void 0:m),responsibleUserId:x===n?void 0:x,action:S===n?void 0:S,entityType:C===n?void 0:C,from:Be(E),to:Ve(I)},b=!!(!a&&m!==n||x!==n||S!==n||C!==n||E||I),i=Ee({queryKey:G.audit.agentActions(t,{actorScope:o.actorScope,agentId:o.agentId,responsibleUserId:o.responsibleUserId,action:o.action,entityType:o.entityType,from:o.from,to:o.to}),queryFn:r(({pageParam:s})=>ae.listAgentActions(t,{...o,limit:De,cursor:s??void 0}),"queryFn"),initialPageParam:null,getNextPageParam:r(s=>s.nextCursor??void 0,"getNextPageParam"),retry:r((s,p)=>!(p instanceof W&&p.status===403)&&s<2,"retry")}),K=i.error instanceof W&&i.error.status===403,P=i.data?.pages.some(s=>s.accessTier==="basic")??!1,oe=i.data?.pages.some(s=>s.accessTier==="full")??!1,Y=(0,l.useMemo)(()=>{const s=i.data?.pages??[];return(P?s.filter(p=>p.accessTier!=="full"):s).flatMap(p=>p.items)},[i.data,P]),L=P?"basic":i.data?.pages[0]?.accessTier,N=P&&oe,ce=a?!0:L==="full",de=!!(N&&U&&!i.isFetching),R=!!(!a&&!de&&(K&&b||N)),w=!!(K&&!a&&f==="agents"&&c),ue=!!(!a&&c&&!w&&(f==="agents"||L==="full"));(0,l.useEffect)(()=>{w&&c?.("all")},[w,c]),(0,l.useEffect)(()=>{!a&&(L==="basic"||R)&&(g(n),B(n),V(n),$(n),q(""),z(""))},[L,N,a,R]),(0,l.useEffect)(()=>{if(!N){U&&H(!1);return}U||(H(!0),i.refetch())},[U,i,N]);const J=r(()=>{g(n),B(n),V(n),$(n),q(""),z("")},"clearFilters"),me=r(async()=>{Q(!0);try{const s=await ae.exportAgentActionsCsv(t,{actorScope:o.actorScope,agentId:o.agentId,responsibleUserId:o.responsibleUserId,action:o.action,entityType:o.entityType,from:o.from,to:o.to}),p=URL.createObjectURL(s),A=document.createElement("a");A.href=p,A.download=`${f==="agents"?"agent-audit":"activity"}-${t}.csv`,document.body.appendChild(A),A.click(),A.remove(),window.setTimeout(()=>URL.revokeObjectURL(p),5e3),h({title:"Audit exported",body:"Your CSV download has started.",tone:"success"})}catch(s){h({title:"Export failed",body:s instanceof Error?s.message:"Could not export the audit log.",tone:"error"})}finally{Q(!1)}},"handleExport");return K&&!R&&!w?(0,e.jsx)(Me,{}):(0,e.jsxs)("div",{className:"space-y-4",children:[d?null:(0,e.jsx)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:(0,e.jsxs)("div",{children:[(0,e.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Activity"}),(0,e.jsx)("p",{className:"mt-1 max-w-2xl text-sm text-muted-foreground",children:f==="agents"?"Every recorded agent action, newest first — with the responsible person and run behind each one.":"Everything happening in your company, newest first — people, agents, and the system. Each line is one recorded action."})]})}),ue?(0,e.jsx)(Ne,{value:f,onValueChange:r(s=>c?.(s),"onValueChange"),children:(0,e.jsxs)(be,{"aria-label":"Activity scope",children:[(0,e.jsx)(te,{value:"all",children:"All activity"}),(0,e.jsx)(te,{value:"agents",children:"Agent actions"})]})}):null,ce?(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[a?null:(0,e.jsxs)(k,{value:m,onValueChange:g,children:[(0,e.jsx)(F,{className:"w-40",children:(0,e.jsx)(_,{placeholder:"Agent"})}),(0,e.jsxs)(D,{children:[(0,e.jsx)(y,{value:n,children:"All agents"}),(M.data??[]).map(s=>(0,e.jsx)(y,{value:s.id,children:s.name},s.id))]})]}),(0,e.jsxs)(k,{value:x,onValueChange:B,children:[(0,e.jsx)(F,{className:"w-52",children:(0,e.jsx)(_,{placeholder:"Responsible user"})}),(0,e.jsxs)(D,{children:[(0,e.jsx)(y,{value:n,children:"All responsible users"}),(O.data?.users??[]).map(s=>(0,e.jsx)(y,{value:s.principalId,children:s.user?.name??s.user?.email??s.principalId.slice(0,8)},s.principalId))]})]}),(0,e.jsxs)(k,{value:S,onValueChange:V,children:[(0,e.jsx)(F,{className:"w-36",children:(0,e.jsx)(_,{placeholder:"Action"})}),(0,e.jsx)(D,{children:Fe.map(s=>(0,e.jsx)(y,{value:s.value,children:s.label},s.value))})]}),(0,e.jsxs)(k,{value:C,onValueChange:$,children:[(0,e.jsx)(F,{className:"w-36",children:(0,e.jsx)(_,{placeholder:"Entity"})}),(0,e.jsx)(D,{children:ke.map(s=>(0,e.jsx)(y,{value:s.value,children:s.label},s.value))})]}),(0,e.jsx)(se,{type:"date","aria-label":"From date",value:E,max:I||void 0,onChange:r(s=>q(s.target.value),"onChange"),className:"w-36"}),(0,e.jsx)(se,{type:"date","aria-label":"To date",value:I,min:E||void 0,onChange:r(s=>z(s.target.value),"onChange"),className:"w-36"}),b?(0,e.jsx)(T,{variant:"ghost",size:"sm",onClick:J,children:"Clear filters"}):null,(0,e.jsxs)(T,{variant:"outline",size:"sm",className:"ml-auto",onClick:me,disabled:Z||i.isLoading||Y.length===0,children:[(0,e.jsx)(Ie,{className:"mr-1.5 h-4 w-4"}),Z?"Exporting…":"Export CSV"]})]}):null,R||w?(0,e.jsx)(j,{children:(0,e.jsx)(v,{className:"py-14 text-center text-sm text-muted-foreground",children:"Refreshing audit access…"})}):i.isLoading?(0,e.jsx)(j,{children:(0,e.jsx)(v,{className:"py-14 text-center text-sm text-muted-foreground",children:"Loading…"})}):i.error?(0,e.jsx)(j,{children:(0,e.jsxs)(v,{className:"flex flex-col items-center gap-3 py-14 text-center",children:[(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:i.error instanceof Error?i.error.message:"Failed to load the audit log."}),(0,e.jsx)(T,{variant:"outline",size:"sm",onClick:r(()=>i.refetch(),"onClick"),children:"Try again"})]})}):Y.length===0?(0,e.jsx)(j,{children:(0,e.jsxs)(v,{className:"flex flex-col items-center gap-3 py-14 text-center",children:[(0,e.jsx)(_e,{className:"h-10 w-10 text-muted-foreground/40"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-medium text-foreground",children:b?"No actions match these filters":"Nothing here yet"}),(0,e.jsx)("p",{className:"mt-1 max-w-md text-sm text-muted-foreground",children:b?"Try a wider date range or different filters.":f==="agents"?"As soon as your agents start doing things, their actions show up here.":"As soon as anyone in your company does something, it shows up here."})]}),b?(0,e.jsx)(T,{variant:"outline",size:"sm",onClick:J,children:"Clear filters"}):null]})}):(0,e.jsx)(j,{children:(0,e.jsx)(v,{className:"px-0 py-0",children:(0,e.jsx)("ul",{className:ge("divide-y divide-border"),children:Y.map(s=>(0,e.jsx)(ze,{record:s,agentMap:ie,userProfileMap:le},s.id))})})}),i.hasNextPage?(0,e.jsx)("div",{className:"flex justify-center",children:(0,e.jsx)(T,{variant:"outline",size:"sm",onClick:r(()=>i.fetchNextPage(),"onClick"),disabled:i.isFetchingNextPage,children:i.isFetchingNextPage?"Loading…":"Load more"})}):null,(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Recorded by Paperclip — entries can't be edited. Sensitive values are never stored."})]})}r(Oe,"AuditFeed");function rt(){const{selectedCompanyId:t}=fe(),{setBreadcrumbs:a}=Ae(),[d,u]=ve(),c=d.get("mode")==="agents"?"agents":"all";(0,l.useEffect)(()=>{a([{label:"Activity"}])},[a]);const h=(0,l.useCallback)(m=>{u(g=>{const x=new URLSearchParams(g);return m==="agents"?x.set("mode","agents"):x.delete("mode"),x},{replace:!0})},[u]);return t?(0,e.jsx)(Oe,{companyId:t,mode:c,onModeChange:h}):(0,e.jsx)(Te,{icon:Le,message:"Select a company to view activity."})}r(rt,"CompanyActivity");export{rt as CompanyActivity};
|