replicas-engine 0.1.211 → 0.1.212
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/src/index.js +1097 -1
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -276,6 +276,1102 @@ function parsePosixEnvFile(content) {
|
|
|
276
276
|
return result;
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
+
// ../shared/src/default-skills/replicas-agent/abilities/docker.ts
|
|
280
|
+
var SECTION = `### Docker
|
|
281
|
+
Start and use the Docker daemon in Replicas workspaces. Docker is pre-installed but the daemon does not auto-start.
|
|
282
|
+
|
|
283
|
+
**Reference:** \`references/DOCKER.md\`
|
|
284
|
+
|
|
285
|
+
Use this when:
|
|
286
|
+
- You need to run \`docker\` or \`docker compose\` commands
|
|
287
|
+
- You need to build or run Docker containers
|
|
288
|
+
- Your task involves containerized services or Docker-based workflows`;
|
|
289
|
+
var REFERENCE = `# Docker
|
|
290
|
+
|
|
291
|
+
Docker is pre-installed in Replicas workspaces, but the daemon does **not** auto-start. You must start it manually before running any \`docker\` or \`docker compose\` commands.
|
|
292
|
+
|
|
293
|
+
## Starting the Docker Daemon
|
|
294
|
+
|
|
295
|
+
\`\`\`bash
|
|
296
|
+
sudo service docker start
|
|
297
|
+
\`\`\`
|
|
298
|
+
|
|
299
|
+
After starting, verify the daemon is running:
|
|
300
|
+
|
|
301
|
+
\`\`\`bash
|
|
302
|
+
docker info
|
|
303
|
+
\`\`\`
|
|
304
|
+
|
|
305
|
+
## Important Notes
|
|
306
|
+
|
|
307
|
+
- **Start once per session.** The daemon stays running until the workspace shuts down. You do not need to restart it between commands.
|
|
308
|
+
- **Check before starting.** If you are unsure whether the daemon is already running, check first to avoid an unnecessary restart:
|
|
309
|
+
\`\`\`bash
|
|
310
|
+
docker info > /dev/null 2>&1 || sudo service docker start
|
|
311
|
+
\`\`\`
|
|
312
|
+
- **Sudo is required** for starting the daemon, but regular \`docker\` commands run without sudo (the user is in the \`docker\` group).
|
|
313
|
+
`;
|
|
314
|
+
var DOCKER_ABILITY = {
|
|
315
|
+
label: "Docker",
|
|
316
|
+
description: "Start the daemon, build/run containers, drive `docker compose`.",
|
|
317
|
+
bullet: "- Using Docker (starting the daemon, running containers, docker compose)",
|
|
318
|
+
section: SECTION,
|
|
319
|
+
referenceFile: { name: "DOCKER.md", content: REFERENCE }
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
// ../shared/src/default-skills/replicas-agent/abilities/github.ts
|
|
323
|
+
var SECTION2 = `### GitHub
|
|
324
|
+
Use the pre-authenticated \`gh\` CLI for pull requests, issues, actions, and API calls.
|
|
325
|
+
|
|
326
|
+
**Reference:** \`references/GITHUB.md\`
|
|
327
|
+
|
|
328
|
+
Use this when:
|
|
329
|
+
- You need to create, review, or manage pull requests
|
|
330
|
+
- You need to interact with GitHub issues or actions
|
|
331
|
+
- You need to use the GitHub API for advanced operations
|
|
332
|
+
- You need to include images in PR descriptions`;
|
|
333
|
+
var REFERENCE2 = `# GitHub Integration
|
|
334
|
+
|
|
335
|
+
This guide covers how to interact with GitHub from within your Replicas workspace.
|
|
336
|
+
|
|
337
|
+
## Prerequisites
|
|
338
|
+
|
|
339
|
+
The \`gh\` CLI is pre-installed and authenticated in your workspace. You can verify this:
|
|
340
|
+
|
|
341
|
+
\`\`\`bash
|
|
342
|
+
gh auth status
|
|
343
|
+
\`\`\`
|
|
344
|
+
|
|
345
|
+
If authenticated, you can immediately use \`gh\` for all GitHub operations. No additional setup is needed.
|
|
346
|
+
|
|
347
|
+
## Using the \`gh\` CLI
|
|
348
|
+
|
|
349
|
+
The GitHub CLI (\`gh\`) is the recommended way to interact with GitHub. It handles authentication, pagination, and API formatting automatically.
|
|
350
|
+
|
|
351
|
+
### Pull Requests
|
|
352
|
+
|
|
353
|
+
\`\`\`bash
|
|
354
|
+
# Create a PR
|
|
355
|
+
gh pr create --title "Title" --body "Description"
|
|
356
|
+
|
|
357
|
+
# List open PRs
|
|
358
|
+
gh pr list
|
|
359
|
+
|
|
360
|
+
# View a specific PR
|
|
361
|
+
gh pr view 123
|
|
362
|
+
|
|
363
|
+
# Review/check PR status
|
|
364
|
+
gh pr checks 123
|
|
365
|
+
|
|
366
|
+
# Merge a PR
|
|
367
|
+
gh pr merge 123
|
|
368
|
+
\`\`\`
|
|
369
|
+
|
|
370
|
+
### Issues
|
|
371
|
+
|
|
372
|
+
\`\`\`bash
|
|
373
|
+
# Create an issue
|
|
374
|
+
gh issue create --title "Title" --body "Description"
|
|
375
|
+
|
|
376
|
+
# View an issue
|
|
377
|
+
gh issue view 123
|
|
378
|
+
|
|
379
|
+
# List issues
|
|
380
|
+
gh issue list
|
|
381
|
+
|
|
382
|
+
# Close an issue
|
|
383
|
+
gh issue close 123
|
|
384
|
+
|
|
385
|
+
# Add a comment
|
|
386
|
+
gh issue comment 123 --body "Your comment"
|
|
387
|
+
\`\`\`
|
|
388
|
+
|
|
389
|
+
### Repository Operations
|
|
390
|
+
|
|
391
|
+
\`\`\`bash
|
|
392
|
+
# View repo info
|
|
393
|
+
gh repo view
|
|
394
|
+
|
|
395
|
+
# Clone a repo
|
|
396
|
+
gh repo clone owner/repo
|
|
397
|
+
|
|
398
|
+
# List releases
|
|
399
|
+
gh release list
|
|
400
|
+
\`\`\`
|
|
401
|
+
|
|
402
|
+
### GitHub Actions / Checks
|
|
403
|
+
|
|
404
|
+
\`\`\`bash
|
|
405
|
+
# List workflow runs
|
|
406
|
+
gh run list
|
|
407
|
+
|
|
408
|
+
# View a specific run
|
|
409
|
+
gh run view RUN_ID
|
|
410
|
+
|
|
411
|
+
# Watch a run in progress
|
|
412
|
+
gh run watch RUN_ID
|
|
413
|
+
|
|
414
|
+
# Re-run failed jobs
|
|
415
|
+
gh run rerun RUN_ID --failed
|
|
416
|
+
\`\`\`
|
|
417
|
+
|
|
418
|
+
### GitHub API (Advanced)
|
|
419
|
+
|
|
420
|
+
For operations not covered by \`gh\` subcommands, use the API directly:
|
|
421
|
+
|
|
422
|
+
\`\`\`bash
|
|
423
|
+
# GET request
|
|
424
|
+
gh api repos/owner/repo/pulls/123/comments
|
|
425
|
+
|
|
426
|
+
# POST request
|
|
427
|
+
gh api repos/owner/repo/issues/123/comments -f body="Comment text"
|
|
428
|
+
|
|
429
|
+
# GraphQL query
|
|
430
|
+
gh api graphql -f query='{ repository(owner: "owner", name: "repo") { issues(first: 10) { nodes { title number } } } }'
|
|
431
|
+
\`\`\`
|
|
432
|
+
|
|
433
|
+
### Working with PR Reviews
|
|
434
|
+
|
|
435
|
+
\`\`\`bash
|
|
436
|
+
# View PR comments
|
|
437
|
+
gh api repos/owner/repo/pulls/123/comments
|
|
438
|
+
|
|
439
|
+
# View PR review comments
|
|
440
|
+
gh api repos/owner/repo/pulls/123/reviews
|
|
441
|
+
|
|
442
|
+
# Submit a review
|
|
443
|
+
gh pr review 123 --approve
|
|
444
|
+
gh pr review 123 --request-changes --body "Changes needed"
|
|
445
|
+
\`\`\`
|
|
446
|
+
|
|
447
|
+
## Image Uploads in PRs
|
|
448
|
+
|
|
449
|
+
GitHub does NOT have a public API for uploading images to PRs/issues. When you need to include images:
|
|
450
|
+
- Do NOT use placeholder image URLs
|
|
451
|
+
- Do NOT commit screenshots as files to the repository
|
|
452
|
+
- Upload images to Imgur (or another external host) and use the returned URLs in your PR markdown
|
|
453
|
+
- If you were triggered from Slack, also upload the images to the Slack thread so the user can see them directly
|
|
454
|
+
`;
|
|
455
|
+
var GITHUB_ABILITY = {
|
|
456
|
+
label: "GitHub",
|
|
457
|
+
description: "Pre-authenticated `gh` CLI for PRs, issues, releases, and GraphQL.",
|
|
458
|
+
bullet: "- Interacting with GitHub (creating PRs, managing issues, using the API, etc.)",
|
|
459
|
+
section: SECTION2,
|
|
460
|
+
referenceFile: { name: "GITHUB.md", content: REFERENCE2 }
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
// ../shared/src/default-skills/replicas-agent/abilities/google.ts
|
|
464
|
+
var SECTION3 = `### Google Workspace (Docs, Sheets, Forms, Drive)
|
|
465
|
+
Create and edit Google Docs, Sheets, and Forms via the Replicas gateway. Files are owned by Replicas \u2014 the integration cannot access pre-existing Google content created outside of it.
|
|
466
|
+
|
|
467
|
+
**Reference:** \`references/GOOGLE.md\`
|
|
468
|
+
|
|
469
|
+
Use this when:
|
|
470
|
+
- You need to create or edit a Google Doc, Sheet, or Form
|
|
471
|
+
- You need to share, rename, move, or delete a Replicas-created Google file
|
|
472
|
+
- You need to read responses from a Replicas-created Google Form`;
|
|
473
|
+
var REFERENCE3 = `# Google Workspace (Docs, Sheets, Forms, Drive)
|
|
474
|
+
|
|
475
|
+
This guide covers how to create and edit Google Docs, Sheets, and Forms \u2014 plus do basic Drive file operations \u2014 from inside a Replicas workspace, using the monolith as a gateway to Google's APIs.
|
|
476
|
+
|
|
477
|
+
## Prerequisites
|
|
478
|
+
|
|
479
|
+
The integration is configured at the org or user level by the Replicas admin. From inside a workspace you don't have a Google access token directly; instead you call the monolith's \`/v1/gdrive/*\` endpoints, authenticated with your workspace's engine secret. The monolith refreshes the org's (or user's) Google access token and proxies the call.
|
|
480
|
+
|
|
481
|
+
Quick check that the integration is connected:
|
|
482
|
+
|
|
483
|
+
\`\`\`bash
|
|
484
|
+
curl -s -X GET "$MONOLITH_URL/v1/gdrive/credentials" \\
|
|
485
|
+
-H "Authorization: Bearer $REPLICAS_ENGINE_SECRET" \\
|
|
486
|
+
-H "X-Workspace-Id: $WORKSPACE_ID"
|
|
487
|
+
\`\`\`
|
|
488
|
+
|
|
489
|
+
- If \`hasCredentials\` is \`true\`: you're good to go.
|
|
490
|
+
- If \`hasCredentials\` is \`false\`: Google has not been connected for this org. Ask the user to go to **Settings \u2192 Integrations \u2192 Google** in the [Replicas dashboard](https://replicas.dev) and connect a Google account. Do not attempt Google operations until it's connected.
|
|
491
|
+
|
|
492
|
+
Standard auth headers used by every call below:
|
|
493
|
+
|
|
494
|
+
\`\`\`
|
|
495
|
+
Authorization: Bearer $REPLICAS_ENGINE_SECRET
|
|
496
|
+
X-Workspace-Id: $WORKSPACE_ID
|
|
497
|
+
\`\`\`
|
|
498
|
+
|
|
499
|
+
For brevity the examples below use a shell variable:
|
|
500
|
+
|
|
501
|
+
\`\`\`bash
|
|
502
|
+
GDRIVE_AUTH=(-H "Authorization: Bearer $REPLICAS_ENGINE_SECRET" -H "X-Workspace-Id: $WORKSPACE_ID")
|
|
503
|
+
\`\`\`
|
|
504
|
+
|
|
505
|
+
## Important constraint: drive.file scope
|
|
506
|
+
|
|
507
|
+
The integration uses the **sensitive-tier \`drive.file\` scope**. That means Replicas can only read and edit Google files **it created itself**. It **cannot**:
|
|
508
|
+
|
|
509
|
+
- Read or edit a user's pre-existing Google Docs, Sheets, or Forms \u2014 even ones that were shared with the connected Google account.
|
|
510
|
+
- List or search the user's broader Drive.
|
|
511
|
+
- Touch any file that was not created via these gateway endpoints.
|
|
512
|
+
|
|
513
|
+
If the user asks you to edit an existing doc that Replicas didn't create, tell them this constraint and offer to create a new doc that mirrors what they want.
|
|
514
|
+
|
|
515
|
+
## Google Docs
|
|
516
|
+
|
|
517
|
+
### Create a new doc
|
|
518
|
+
|
|
519
|
+
\`\`\`bash
|
|
520
|
+
curl -s -X POST "$MONOLITH_URL/v1/gdrive/docs" "\${GDRIVE_AUTH[@]}" \\
|
|
521
|
+
-H "Content-Type: application/json" \\
|
|
522
|
+
-d '{"title":"Meeting notes 2026-05-14"}'
|
|
523
|
+
\`\`\`
|
|
524
|
+
|
|
525
|
+
Returns the full Doc object; grab \`.documentId\` for follow-up calls.
|
|
526
|
+
|
|
527
|
+
### Read a doc
|
|
528
|
+
|
|
529
|
+
\`\`\`bash
|
|
530
|
+
curl -s "$MONOLITH_URL/v1/gdrive/docs/$DOC_ID" "\${GDRIVE_AUTH[@]}"
|
|
531
|
+
\`\`\`
|
|
532
|
+
|
|
533
|
+
Returns the full document structure \u2014 \`body.content\` is an ordered list of structural elements (paragraphs, tables, etc.) with character indexes you can target for edits.
|
|
534
|
+
|
|
535
|
+
### Edit a doc (batchUpdate)
|
|
536
|
+
|
|
537
|
+
The Docs API edits use a list of [structural requests](https://developers.google.com/workspace/docs/api/reference/rest/v1/documents/request). Insert text, then style it; or insert tables, images, page breaks, etc.
|
|
538
|
+
|
|
539
|
+
\`\`\`bash
|
|
540
|
+
curl -s -X POST "$MONOLITH_URL/v1/gdrive/docs/$DOC_ID/batchUpdate" "\${GDRIVE_AUTH[@]}" \\
|
|
541
|
+
-H "Content-Type: application/json" \\
|
|
542
|
+
-d '{
|
|
543
|
+
"requests": [
|
|
544
|
+
{ "insertText": { "location": { "index": 1 }, "text": "Hello, world!\\n" } }
|
|
545
|
+
]
|
|
546
|
+
}'
|
|
547
|
+
\`\`\`
|
|
548
|
+
|
|
549
|
+
Common request types:
|
|
550
|
+
|
|
551
|
+
- \`insertText\` \u2014 insert plain text at a given index
|
|
552
|
+
- \`deleteContentRange\` \u2014 delete a range
|
|
553
|
+
- \`replaceAllText\` \u2014 find-and-replace
|
|
554
|
+
- \`updateTextStyle\` \u2014 bold/italic/colors/fonts/sizes for a range
|
|
555
|
+
- \`updateParagraphStyle\` \u2014 headings (\`HEADING_1\`..\`HEADING_6\`), alignment, spacing
|
|
556
|
+
- \`createParagraphBullets\` \u2014 turn paragraphs into bulleted/numbered lists
|
|
557
|
+
- \`insertTable\` \u2014 insert a table
|
|
558
|
+
- \`insertInlineImage\` \u2014 insert an image from a URL
|
|
559
|
+
|
|
560
|
+
Edits are verbose but powerful. Prefer batching many requests into a single \`batchUpdate\` call rather than making many round trips \u2014 it's faster and keeps the doc state consistent.
|
|
561
|
+
|
|
562
|
+
## Google Sheets
|
|
563
|
+
|
|
564
|
+
### Create a new spreadsheet
|
|
565
|
+
|
|
566
|
+
\`\`\`bash
|
|
567
|
+
curl -s -X POST "$MONOLITH_URL/v1/gdrive/sheets" "\${GDRIVE_AUTH[@]}" \\
|
|
568
|
+
-H "Content-Type: application/json" \\
|
|
569
|
+
-d '{"title":"Q2 metrics"}'
|
|
570
|
+
\`\`\`
|
|
571
|
+
|
|
572
|
+
Returns the full Spreadsheet object; grab \`.spreadsheetId\`.
|
|
573
|
+
|
|
574
|
+
### Read a range of cells
|
|
575
|
+
|
|
576
|
+
\`\`\`bash
|
|
577
|
+
# Range is in A1 notation, e.g. "Sheet1!A1:C10"
|
|
578
|
+
curl -s "$MONOLITH_URL/v1/gdrive/sheets/$SHEET_ID/values/$(printf %s 'Sheet1!A1:C10' | jq -sRr @uri)" \\
|
|
579
|
+
"\${GDRIVE_AUTH[@]}"
|
|
580
|
+
\`\`\`
|
|
581
|
+
|
|
582
|
+
### Write a range of cells
|
|
583
|
+
|
|
584
|
+
\`\`\`bash
|
|
585
|
+
curl -s -X PUT \\
|
|
586
|
+
"$MONOLITH_URL/v1/gdrive/sheets/$SHEET_ID/values/$(printf %s 'Sheet1!A1:B2' | jq -sRr @uri)?valueInputOption=USER_ENTERED" \\
|
|
587
|
+
"\${GDRIVE_AUTH[@]}" \\
|
|
588
|
+
-H "Content-Type: application/json" \\
|
|
589
|
+
-d '{
|
|
590
|
+
"range": "Sheet1!A1:B2",
|
|
591
|
+
"majorDimension": "ROWS",
|
|
592
|
+
"values": [
|
|
593
|
+
["Name", "Revenue"],
|
|
594
|
+
["Q1", "=SUM(B3:B100)"]
|
|
595
|
+
]
|
|
596
|
+
}'
|
|
597
|
+
\`\`\`
|
|
598
|
+
|
|
599
|
+
\`valueInputOption=USER_ENTERED\` makes formulas evaluate as if a human typed them. Use \`RAW\` to write literal strings.
|
|
600
|
+
|
|
601
|
+
### Bulk operations (formatting, charts, new tabs, etc.)
|
|
602
|
+
|
|
603
|
+
\`\`\`bash
|
|
604
|
+
curl -s -X POST "$MONOLITH_URL/v1/gdrive/sheets/$SHEET_ID/batchUpdate" "\${GDRIVE_AUTH[@]}" \\
|
|
605
|
+
-H "Content-Type: application/json" \\
|
|
606
|
+
-d '{ "requests": [ { "addSheet": { "properties": { "title": "Raw data" } } } ] }'
|
|
607
|
+
\`\`\`
|
|
608
|
+
|
|
609
|
+
\`batchUpdate\` accepts an array of [Sheets API requests](https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request) \u2014 addSheet, updateSheetProperties, repeatCell, addChart, autoResizeDimensions, etc.
|
|
610
|
+
|
|
611
|
+
## Google Forms
|
|
612
|
+
|
|
613
|
+
### Create a new form
|
|
614
|
+
|
|
615
|
+
\`\`\`bash
|
|
616
|
+
curl -s -X POST "$MONOLITH_URL/v1/gdrive/forms" "\${GDRIVE_AUTH[@]}" \\
|
|
617
|
+
-H "Content-Type: application/json" \\
|
|
618
|
+
-d '{"title":"Customer feedback"}'
|
|
619
|
+
\`\`\`
|
|
620
|
+
|
|
621
|
+
Returns the form. Grab \`.formId\`.
|
|
622
|
+
|
|
623
|
+
### Add questions / edit form structure
|
|
624
|
+
|
|
625
|
+
The Forms API uses its own \`batchUpdate\`:
|
|
626
|
+
|
|
627
|
+
\`\`\`bash
|
|
628
|
+
curl -s -X POST "$MONOLITH_URL/v1/gdrive/forms/$FORM_ID/batchUpdate" "\${GDRIVE_AUTH[@]}" \\
|
|
629
|
+
-H "Content-Type: application/json" \\
|
|
630
|
+
-d '{
|
|
631
|
+
"requests": [
|
|
632
|
+
{
|
|
633
|
+
"createItem": {
|
|
634
|
+
"item": {
|
|
635
|
+
"title": "How likely are you to recommend us?",
|
|
636
|
+
"questionItem": {
|
|
637
|
+
"question": {
|
|
638
|
+
"required": true,
|
|
639
|
+
"scaleQuestion": { "low": 0, "high": 10, "lowLabel": "Not at all", "highLabel": "Very likely" }
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
},
|
|
643
|
+
"location": { "index": 0 }
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
]
|
|
647
|
+
}'
|
|
648
|
+
\`\`\`
|
|
649
|
+
|
|
650
|
+
See the [Forms API Request reference](https://developers.google.com/workspace/forms/api/reference/rest/v1/forms/request) for all supported request types \u2014 text questions, multiple choice, checkboxes, scale, grid, date, time, file upload, section breaks, branching logic, quiz settings, etc.
|
|
651
|
+
|
|
652
|
+
### Read responses
|
|
653
|
+
|
|
654
|
+
\`\`\`bash
|
|
655
|
+
curl -s "$MONOLITH_URL/v1/gdrive/forms/$FORM_ID/responses" "\${GDRIVE_AUTH[@]}"
|
|
656
|
+
\`\`\`
|
|
657
|
+
|
|
658
|
+
Pagination: pass \`?pageToken=...&pageSize=...\` to walk through responses.
|
|
659
|
+
|
|
660
|
+
## Drive operations (only on Replicas-created files)
|
|
661
|
+
|
|
662
|
+
### Share a file with a person
|
|
663
|
+
|
|
664
|
+
\`\`\`bash
|
|
665
|
+
curl -s -X POST "$MONOLITH_URL/v1/gdrive/files/$FILE_ID/permissions" "\${GDRIVE_AUTH[@]}" \\
|
|
666
|
+
-H "Content-Type: application/json" \\
|
|
667
|
+
-d '{
|
|
668
|
+
"type": "user",
|
|
669
|
+
"role": "writer",
|
|
670
|
+
"emailAddress": "alice@example.com",
|
|
671
|
+
"sendNotificationEmail": true
|
|
672
|
+
}'
|
|
673
|
+
\`\`\`
|
|
674
|
+
|
|
675
|
+
Roles: \`reader\`, \`commenter\`, \`writer\`. Types: \`user\`, \`group\`, \`domain\`, \`anyone\`.
|
|
676
|
+
|
|
677
|
+
### Make a file viewable by anyone with the link
|
|
678
|
+
|
|
679
|
+
\`\`\`bash
|
|
680
|
+
curl -s -X POST "$MONOLITH_URL/v1/gdrive/files/$FILE_ID/permissions" "\${GDRIVE_AUTH[@]}" \\
|
|
681
|
+
-H "Content-Type: application/json" \\
|
|
682
|
+
-d '{ "type": "anyone", "role": "reader" }'
|
|
683
|
+
\`\`\`
|
|
684
|
+
|
|
685
|
+
### List existing permissions
|
|
686
|
+
|
|
687
|
+
\`\`\`bash
|
|
688
|
+
curl -s "$MONOLITH_URL/v1/gdrive/files/$FILE_ID/permissions" "\${GDRIVE_AUTH[@]}"
|
|
689
|
+
\`\`\`
|
|
690
|
+
|
|
691
|
+
### Rename / move a file
|
|
692
|
+
|
|
693
|
+
\`\`\`bash
|
|
694
|
+
curl -s -X PATCH "$MONOLITH_URL/v1/gdrive/files/$FILE_ID" "\${GDRIVE_AUTH[@]}" \\
|
|
695
|
+
-H "Content-Type: application/json" \\
|
|
696
|
+
-d '{"name":"Final report.docx"}'
|
|
697
|
+
\`\`\`
|
|
698
|
+
|
|
699
|
+
To move into a folder, also pass \`addParents\` and \`removeParents\` as query parameters per [Drive API docs](https://developers.google.com/workspace/drive/api/reference/rest/v3/files/update).
|
|
700
|
+
|
|
701
|
+
### Get file metadata
|
|
702
|
+
|
|
703
|
+
\`\`\`bash
|
|
704
|
+
curl -s "$MONOLITH_URL/v1/gdrive/files/$FILE_ID?fields=id,name,mimeType,webViewLink,parents,modifiedTime" \\
|
|
705
|
+
"\${GDRIVE_AUTH[@]}"
|
|
706
|
+
\`\`\`
|
|
707
|
+
|
|
708
|
+
\`webViewLink\` is the human-shareable URL that opens in Google Docs/Sheets/Forms.
|
|
709
|
+
|
|
710
|
+
### Delete a file
|
|
711
|
+
|
|
712
|
+
\`\`\`bash
|
|
713
|
+
curl -s -X DELETE "$MONOLITH_URL/v1/gdrive/files/$FILE_ID" "\${GDRIVE_AUTH[@]}"
|
|
714
|
+
\`\`\`
|
|
715
|
+
|
|
716
|
+
### List Replicas-created files
|
|
717
|
+
|
|
718
|
+
\`\`\`bash
|
|
719
|
+
curl -s "$MONOLITH_URL/v1/gdrive/files?pageSize=50" "\${GDRIVE_AUTH[@]}"
|
|
720
|
+
\`\`\`
|
|
721
|
+
|
|
722
|
+
Pass \`?q=...\` to filter using [Drive API search syntax](https://developers.google.com/workspace/drive/api/guides/search-files). Only files the app created or was granted access to will appear.
|
|
723
|
+
|
|
724
|
+
## Tips
|
|
725
|
+
|
|
726
|
+
- **Always return the \`webViewLink\`** to the user when you create or edit a file so they can open it. Get it from \`/v1/gdrive/files/$FILE_ID?fields=webViewLink\` or from \`documents.documentId\` \u2192 \`https://docs.google.com/document/d/$ID/edit\`.
|
|
727
|
+
- **Batch your edits.** A single \`batchUpdate\` with 20 requests beats 20 round-trips.
|
|
728
|
+
- **Watch error responses.** A 412 from the gateway means the org has no Google credentials connected \u2014 tell the user to connect Google in the dashboard. Other 4xx responses come straight from Google and usually explain the issue clearly.
|
|
729
|
+
`;
|
|
730
|
+
var GOOGLE_ABILITY = {
|
|
731
|
+
label: "Google Workspace",
|
|
732
|
+
description: "Create / edit Docs, Sheets, Forms, and Drive files via the Replicas gateway.",
|
|
733
|
+
bullet: "- Interacting with Google Workspace (creating and editing Docs, Sheets, and Forms, sharing files, reading form responses, etc.)",
|
|
734
|
+
section: SECTION3,
|
|
735
|
+
referenceFile: { name: "GOOGLE.md", content: REFERENCE3 }
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
// ../shared/src/default-skills/replicas-agent/abilities/linear.ts
|
|
739
|
+
var SECTION4 = `### Linear
|
|
740
|
+
Fetch issues, update state, add comments, and search via the Linear GraphQL API.
|
|
741
|
+
|
|
742
|
+
**Reference:** \`references/LINEAR.md\`
|
|
743
|
+
|
|
744
|
+
Use this when:
|
|
745
|
+
- You encounter a Linear issue link and need to understand the task
|
|
746
|
+
- You need to update an issue's state (e.g. mark as done)
|
|
747
|
+
- You need to comment on or search for Linear issues`;
|
|
748
|
+
var REFERENCE4 = `# Linear Integration
|
|
749
|
+
|
|
750
|
+
This guide covers how to interact with Linear from within your Replicas workspace.
|
|
751
|
+
|
|
752
|
+
## Prerequisites
|
|
753
|
+
|
|
754
|
+
Check if the \`LINEAR_ACCESS_TOKEN\` environment variable is set:
|
|
755
|
+
|
|
756
|
+
\`\`\`bash
|
|
757
|
+
echo "\${LINEAR_ACCESS_TOKEN:+set}"
|
|
758
|
+
\`\`\`
|
|
759
|
+
|
|
760
|
+
- If **set**: Your workspace has Linear access. You can use the Linear GraphQL API as described below.
|
|
761
|
+
- If **not set**: Linear has not been configured for this workspace. The user needs to connect Linear in the [Replicas dashboard](https://replicas.dev) under their organization's integration settings. Let the user know and do not attempt Linear operations.
|
|
762
|
+
|
|
763
|
+
## Using the Linear API
|
|
764
|
+
|
|
765
|
+
Linear uses a GraphQL API at \`https://api.linear.app/graphql\`. All requests use the \`$LINEAR_ACCESS_TOKEN\` for authentication.
|
|
766
|
+
|
|
767
|
+
### Fetching an Issue
|
|
768
|
+
|
|
769
|
+
If you encounter a Linear issue link (e.g. \`https://linear.app/team/issue/ENG-123\`), the identifier is the last path segment (\`ENG-123\`).
|
|
770
|
+
|
|
771
|
+
\`\`\`bash
|
|
772
|
+
curl -s -X POST https://api.linear.app/graphql \\
|
|
773
|
+
-H "Authorization: Bearer $LINEAR_ACCESS_TOKEN" \\
|
|
774
|
+
-H "Content-Type: application/json" \\
|
|
775
|
+
-d '{
|
|
776
|
+
"query": "query { issues(filter: { identifier: { eq: \\"ENG-123\\" } }) { nodes { id identifier title description state { name } assignee { name } parent { identifier title description } } } }"
|
|
777
|
+
}'
|
|
778
|
+
\`\`\`
|
|
779
|
+
|
|
780
|
+
### Updating Issue State
|
|
781
|
+
|
|
782
|
+
\`\`\`bash
|
|
783
|
+
curl -s -X POST https://api.linear.app/graphql \\
|
|
784
|
+
-H "Authorization: Bearer $LINEAR_ACCESS_TOKEN" \\
|
|
785
|
+
-H "Content-Type: application/json" \\
|
|
786
|
+
-d '{
|
|
787
|
+
"query": "mutation { issueUpdate(id: \\"ISSUE_UUID\\", input: { stateId: \\"STATE_UUID\\" }) { success issue { identifier state { name } } } }"
|
|
788
|
+
}'
|
|
789
|
+
\`\`\`
|
|
790
|
+
|
|
791
|
+
To find available states, query: \`query { workflowStates { nodes { id name } } }\`
|
|
792
|
+
|
|
793
|
+
### Adding a Comment
|
|
794
|
+
|
|
795
|
+
\`\`\`bash
|
|
796
|
+
curl -s -X POST https://api.linear.app/graphql \\
|
|
797
|
+
-H "Authorization: Bearer $LINEAR_ACCESS_TOKEN" \\
|
|
798
|
+
-H "Content-Type: application/json" \\
|
|
799
|
+
-d '{
|
|
800
|
+
"query": "mutation { commentCreate(input: { issueId: \\"ISSUE_UUID\\", body: \\"Your comment here\\" }) { success comment { id } } }"
|
|
801
|
+
}'
|
|
802
|
+
\`\`\`
|
|
803
|
+
|
|
804
|
+
### Searching Issues
|
|
805
|
+
|
|
806
|
+
\`\`\`bash
|
|
807
|
+
curl -s -X POST https://api.linear.app/graphql \\
|
|
808
|
+
-H "Authorization: Bearer $LINEAR_ACCESS_TOKEN" \\
|
|
809
|
+
-H "Content-Type: application/json" \\
|
|
810
|
+
-d '{
|
|
811
|
+
"query": "query { issueSearch(query: \\"search terms\\", first: 10) { nodes { identifier title state { name } } } }"
|
|
812
|
+
}'
|
|
813
|
+
\`\`\`
|
|
814
|
+
|
|
815
|
+
### Other Operations
|
|
816
|
+
|
|
817
|
+
The Linear GraphQL API supports creating issues, managing projects, labels, cycles, and more. For the full schema and documentation, see: https://developers.linear.app/docs/graphql/working-with-the-graphql-api
|
|
818
|
+
`;
|
|
819
|
+
var LINEAR_ABILITY = {
|
|
820
|
+
label: "Linear",
|
|
821
|
+
description: "Fetch issues, post comments, update states via the Linear GraphQL API.",
|
|
822
|
+
bullet: "- Interacting with Linear (fetching issues, updating state, commenting, etc.)",
|
|
823
|
+
section: SECTION4,
|
|
824
|
+
referenceFile: { name: "LINEAR.md", content: REFERENCE4 }
|
|
825
|
+
};
|
|
826
|
+
|
|
827
|
+
// ../shared/src/default-skills/replicas-agent/abilities/media.ts
|
|
828
|
+
var SECTION5 = `### Media
|
|
829
|
+
Share screenshots, screen recordings, generated diagrams, and audio clips inline in the Replicas chat (and as references in external messages).
|
|
830
|
+
|
|
831
|
+
**Reference:** \`references/MEDIA.md\`
|
|
832
|
+
|
|
833
|
+
Use this when:
|
|
834
|
+
- You produce a screenshot, recording, generated image, or audio clip the user should see
|
|
835
|
+
- You record video output (browser automation, screen capture) \u2014 including the recommended aspect ratio and FPS
|
|
836
|
+
- You need to embed media in a Slack/Linear/GitHub message AND keep a referenceable copy in the Replicas dashboard`;
|
|
837
|
+
var REFERENCE5 = `# Media (Screenshots, Recordings, Audio)
|
|
838
|
+
|
|
839
|
+
This guide covers how to share screenshots, screen recordings, generated diagrams, and audio clips with the user inline in the Replicas chat.
|
|
840
|
+
|
|
841
|
+
## Prerequisites
|
|
842
|
+
|
|
843
|
+
The \`replicas\` CLI is pre-installed and authenticated in your workspace. No additional setup is needed.
|
|
844
|
+
|
|
845
|
+
## When to upload
|
|
846
|
+
|
|
847
|
+
Upload to Replicas in these cases \u2014 and **only** these cases:
|
|
848
|
+
|
|
849
|
+
1. **Media you produce.** Any screenshot, screen recording, generated diagram, or audio clip you create that the user might want to see. Upload before doing anything else with the file (analyzing, deleting, sending elsewhere). This applies even when you're also sending the file to Slack, Linear, GitHub, etc.
|
|
850
|
+
2. **Files the user explicitly asks you to upload.** If the user sends or points at a file (image, video, audio) and asks you to upload it, run \`replicas media upload\`. Otherwise leave it alone \u2014 files in the workspace the user did not ask about should not be auto-uploaded as media.
|
|
851
|
+
3. **Anything you plan to share externally (Slack, Linear, GitHub, etc.).** Upload to Replicas *in addition to* the platform's native upload. Never as a replacement.
|
|
852
|
+
|
|
853
|
+
If none of these apply, don't upload.
|
|
854
|
+
|
|
855
|
+
## Uploading
|
|
856
|
+
|
|
857
|
+
\`\`\`bash
|
|
858
|
+
replicas media upload <path-to-file> [<path-to-file> ...]
|
|
859
|
+
\`\`\`
|
|
860
|
+
|
|
861
|
+
Pass one or more file paths. Uploading several files in a single invocation is preferred over running the command repeatedly \u2014 it's faster and keeps the output grouped.
|
|
862
|
+
|
|
863
|
+
For each file, the CLI prints two lines:
|
|
864
|
+
|
|
865
|
+
1. \`\` \u2014 the chat embed (renders inline in Replicas chat only; see below).
|
|
866
|
+
2. \`View in Replicas: <deep-link>\` \u2014 a per-file dashboard URL of the form \`https://tryreplicas.com/workspaces/<workspace-id>?mode=media&media=<media-id>\` that opens directly to that specific file.
|
|
867
|
+
|
|
868
|
+
Match each "View in Replicas" line to the embed line directly above it \u2014 that's the deep link for that file.
|
|
869
|
+
|
|
870
|
+
## How to use the output
|
|
871
|
+
|
|
872
|
+
### CRITICAL: the markdown embed URL is for Replicas chat only
|
|
873
|
+
|
|
874
|
+
The URL inside \`\` points at \`api.tryreplicas.com/v1/media/<id>\`. This is **not a public URL** \u2014 it requires the Replicas chat's authenticated session, which resolves it to a presigned download. Anywhere else (Slack, Linear, GitHub, a browser tab the user opens directly, a customer copy-pasting from chat), it returns \`{"error":"Missing authorization token"}\` and renders as a broken image.
|
|
875
|
+
|
|
876
|
+
**Never paste this URL outside your Replicas chat reply.** Not in Slack messages, not in Linear comments, not in PR descriptions or commit messages, not in external docs \u2014 nowhere a non-Replicas surface will render it.
|
|
877
|
+
|
|
878
|
+
### Always render dashboard URLs as \`[View in Replicas](<url>)\` hyperlinks
|
|
879
|
+
|
|
880
|
+
Whenever you share a workspace dashboard URL \u2014 in chat or anywhere else \u2014 format it as a markdown hyperlink labeled **View in Replicas**:
|
|
881
|
+
|
|
882
|
+
\`\`\`markdown
|
|
883
|
+
[View in Replicas](https://tryreplicas.com/workspaces/<workspace-id>?mode=media&media=<media-id>)
|
|
884
|
+
\`\`\`
|
|
885
|
+
|
|
886
|
+
Never paste the raw URL. Raw URLs look unpolished.
|
|
887
|
+
|
|
888
|
+
Two flavors of dashboard URL the CLI gives you:
|
|
889
|
+
|
|
890
|
+
- **Per-file deep link** (default \u2014 what \`replicas media upload\` prints): \`...?mode=media&media=<media-id>\` opens the dashboard scrolled to that specific file. Use this whenever you're linking to *one* file.
|
|
891
|
+
- **Media tab link** (no \`media=\` param): \`...?mode=media\` opens the workspace's media tab listing all files. Use this only when you're pointing at the collection, not a specific file (rare \u2014 you almost always have a specific file in mind).
|
|
892
|
+
|
|
893
|
+
### In your Replicas chat reply
|
|
894
|
+
|
|
895
|
+
Include each markdown embed line **verbatim** where you want that file to render inline. The chat substitutes each one with an embedded image, video, or audio player. Multiple embeds can appear in a single reply.
|
|
896
|
+
|
|
897
|
+
After (or alongside) the embeds, include a \`[View in Replicas](<deep-link>)\` hyperlink for each file using the per-file URL the CLI printed for that file. This lets the user jump to the specific item in the media tab.
|
|
898
|
+
|
|
899
|
+
### On external platforms (Slack, Linear, GitHub, etc.)
|
|
900
|
+
|
|
901
|
+
Do **both** of these \u2014 neither alone is sufficient:
|
|
902
|
+
|
|
903
|
+
1. Upload the raw bytes via that platform's own upload API (Slack \`files.upload\`, Linear attachments, Imgur for GitHub PR/issue images, etc.) so the recipient actually sees the media.
|
|
904
|
+
2. Include a \`[View in Replicas](<deep-link>)\` hyperlink \u2014 use the per-file deep link the CLI printed for that file (\`...?mode=media&media=<media-id>\`), so the recipient lands directly on that specific item.
|
|
905
|
+
|
|
906
|
+
Do **not** include the \`\` markdown embed in external messages. It will render as a broken image / 401 for the recipient.
|
|
907
|
+
|
|
908
|
+
## Recording defaults
|
|
909
|
+
|
|
910
|
+
When you record video (browser automation, screen capture, etc.):
|
|
911
|
+
|
|
912
|
+
- **Aspect ratio:** 16:9 (1920\xD71080 or 1280\xD7720)
|
|
913
|
+
- **Frame rate:** 60 FPS or whatever the user specifies
|
|
914
|
+
|
|
915
|
+
Tools like Playwright default to a low frame rate that produces choppy playback \u2014 explicitly configure recording dimensions and FPS:
|
|
916
|
+
|
|
917
|
+
\`\`\`ts
|
|
918
|
+
const context = await browser.newContext({
|
|
919
|
+
recordVideo: { dir: './videos', size: { width: 1280, height: 720 } },
|
|
920
|
+
});
|
|
921
|
+
\`\`\`
|
|
922
|
+
|
|
923
|
+
For \`ffmpeg\` screen captures, pass \`-r 30\` (or \`-r 60\`) to set the frame rate.
|
|
924
|
+
|
|
925
|
+
## Supported formats
|
|
926
|
+
|
|
927
|
+
Auto-detected from the filename extension:
|
|
928
|
+
|
|
929
|
+
| Extension | Kind |
|
|
930
|
+
|---|---|
|
|
931
|
+
| \`png\`, \`jpg\`, \`jpeg\`, \`webp\` | image |
|
|
932
|
+
| \`mp4\`, \`webm\` | video |
|
|
933
|
+
| \`mp3\`, \`wav\` | audio |
|
|
934
|
+
|
|
935
|
+
For other extensions, pass \`--kind image|video|audio\` explicitly. The kind applies to every file in that invocation, so group files of the same kind together:
|
|
936
|
+
|
|
937
|
+
\`\`\`bash
|
|
938
|
+
replicas media upload diagram.svg --kind image
|
|
939
|
+
replicas media upload chart-a.svg chart-b.svg --kind image
|
|
940
|
+
\`\`\`
|
|
941
|
+
|
|
942
|
+
## Options
|
|
943
|
+
|
|
944
|
+
- \`--kind <image|video|audio>\` \u2014 override auto-detection
|
|
945
|
+
- \`--session-id <id>\` \u2014 associate the upload with a specific session
|
|
946
|
+
`;
|
|
947
|
+
var MEDIA_ABILITY = {
|
|
948
|
+
label: "Media",
|
|
949
|
+
description: "Share screenshots, recordings, generated images, and audio clips.",
|
|
950
|
+
bullet: "- Sharing media (screenshots, screen recordings, generated diagrams, audio clips) \u2014 including in your Replicas chat reply and to external platforms",
|
|
951
|
+
section: SECTION5,
|
|
952
|
+
referenceFile: { name: "MEDIA.md", content: REFERENCE5 }
|
|
953
|
+
};
|
|
954
|
+
|
|
955
|
+
// ../shared/src/default-skills/replicas-agent/abilities/previews.ts
|
|
956
|
+
var SECTION6 = `### Previews
|
|
957
|
+
Expose locally running services (web apps, APIs, databases) as public preview URLs so humans can interact with them directly.
|
|
958
|
+
|
|
959
|
+
**Reference:** \`references/PREVIEWS.md\`
|
|
960
|
+
|
|
961
|
+
Use this when:
|
|
962
|
+
- You need to start a service that a human should view or interact with
|
|
963
|
+
- The task involves UI work that benefits from human review
|
|
964
|
+
- You are verifying frontend/backend integrations visually`;
|
|
965
|
+
var REFERENCE6 = `# Preview URLs
|
|
966
|
+
|
|
967
|
+
When you run services on ports \u2014 such as a web app, API server, or database \u2014 humans may want to interact with them directly. You can expose your locally running services as public preview URLs.
|
|
968
|
+
|
|
969
|
+
## Running Services for Preview
|
|
970
|
+
|
|
971
|
+
Services must run as detached background processes so they survive after your command session ends. Do not leave them attached to a foreground terminal.
|
|
972
|
+
|
|
973
|
+
Some potential methods:
|
|
974
|
+
\`\`\`bash
|
|
975
|
+
# Start a detached service with logging
|
|
976
|
+
setsid -f bash -lc 'cd /path/to/app && exec yarn dev >> /tmp/app.log 2>&1'
|
|
977
|
+
|
|
978
|
+
# For daemons like Docker
|
|
979
|
+
nohup dockerd > /tmp/dockerd.log 2>&1 &
|
|
980
|
+
\`\`\`
|
|
981
|
+
|
|
982
|
+
After starting a service:
|
|
983
|
+
1. Verify the process is running: \`pgrep -af 'yarn dev'\`
|
|
984
|
+
2. Check logs for readiness: \`tail -f /tmp/app.log\`
|
|
985
|
+
3. Confirm it's actually serving: \`curl -s http://localhost:3000\` (or appropriate health check)
|
|
986
|
+
4. Only create the preview after the service is healthy
|
|
987
|
+
|
|
988
|
+
If a prior detached process exists on the same port, stop it before restarting.
|
|
989
|
+
|
|
990
|
+
## Creating Previews
|
|
991
|
+
|
|
992
|
+
\`\`\`bash
|
|
993
|
+
# Expose a local port as a public URL
|
|
994
|
+
replicas preview create <port>
|
|
995
|
+
|
|
996
|
+
# Expose a port with authentication (requires Replicas login to access)
|
|
997
|
+
replicas preview create <port> --authenticated
|
|
998
|
+
|
|
999
|
+
# List all active preview URLs
|
|
1000
|
+
replicas preview list
|
|
1001
|
+
\`\`\`
|
|
1002
|
+
|
|
1003
|
+
The \`create\` command prints the public URL. You can also read all active previews from \`~/.replicas/preview-ports.json\`.
|
|
1004
|
+
|
|
1005
|
+
## Authenticated vs Unauthenticated Previews
|
|
1006
|
+
|
|
1007
|
+
Previews can optionally require cookie-based authentication. When \`--authenticated\` is set, only users who are logged in to replicas.dev can access the preview.
|
|
1008
|
+
|
|
1009
|
+
**When to use \`--authenticated\`:**
|
|
1010
|
+
- Frontends / web apps that humans will view directly in their browser. Since the user is already logged in to replicas.dev, the auth cookie is automatically present and the preview works seamlessly.
|
|
1011
|
+
|
|
1012
|
+
**When NOT to use \`--authenticated\`:**
|
|
1013
|
+
- Backend APIs and other services that are called by frontend code. The frontend runs in the user's browser under a different origin, so it cannot forward the Replicas auth cookie to the backend. Making backends authenticated will cause cross-service requests to fail with 401 errors.
|
|
1014
|
+
|
|
1015
|
+
**Rule of thumb:** Make frontend previews authenticated, leave backend/API previews unauthenticated.
|
|
1016
|
+
|
|
1017
|
+
## Cross-Service References
|
|
1018
|
+
|
|
1019
|
+
When you expose multiple services that reference each other, you must update their configuration so they use preview URLs instead of \`localhost\`.
|
|
1020
|
+
|
|
1021
|
+
**Example:** You run a React frontend on port 3000 that makes API calls to a backend on port 8585.
|
|
1022
|
+
|
|
1023
|
+
1. Create previews for both:
|
|
1024
|
+
\`\`\`bash
|
|
1025
|
+
replicas preview create 8585
|
|
1026
|
+
# Output: https://8585-<hash>.replicas.dev
|
|
1027
|
+
replicas preview create 3000 --authenticated
|
|
1028
|
+
# Output: https://3000-<hash>.replicas.dev
|
|
1029
|
+
\`\`\`
|
|
1030
|
+
|
|
1031
|
+
2. Update the frontend's environment so its API base URL points to the backend's **preview URL**, not \`localhost:8585\`. For example, set \`REACT_APP_API_URL=https://8585-<hash>.replicas.dev\` or update the relevant config file.
|
|
1032
|
+
|
|
1033
|
+
**Why?** The frontend works on \`localhost\` for you because both services run on the same machine. But a human viewing the preview is on a different machine \u2014 requests to \`localhost:8585\` from their browser will fail. They need the public preview URL instead.
|
|
1034
|
+
|
|
1035
|
+
## When to Create Previews
|
|
1036
|
+
|
|
1037
|
+
- After starting any service that a human should be able to view or interact with
|
|
1038
|
+
- When verifying frontend/backend integrations visually
|
|
1039
|
+
- When the task involves UI work that benefits from human review
|
|
1040
|
+
|
|
1041
|
+
It is your responsibility to make previews work for outsiders as well as they work for you on localhost. If at any time you need to see the public URLs that have been created, read \`~/.replicas/preview-ports.json\`.
|
|
1042
|
+
`;
|
|
1043
|
+
var PREVIEWS_ABILITY = {
|
|
1044
|
+
label: "Previews",
|
|
1045
|
+
description: "Expose locally running services on public preview URLs for humans.",
|
|
1046
|
+
bullet: "- Creating preview URLs for locally running services",
|
|
1047
|
+
section: SECTION6,
|
|
1048
|
+
referenceFile: { name: "PREVIEWS.md", content: REFERENCE6 }
|
|
1049
|
+
};
|
|
1050
|
+
|
|
1051
|
+
// ../shared/src/default-skills/replicas-agent/abilities/replicas.ts
|
|
1052
|
+
var SECTION7 = `### Replicas (in-workspace CLI)
|
|
1053
|
+
Take action *with* Replicas itself \u2014 manage automations, environments (variables, files), repos, and \`replicas.json\` config \u2014 using the pre-installed, pre-authenticated \`replicas\` CLI.
|
|
1054
|
+
|
|
1055
|
+
**Reference:** \`references/REPLICAS.md\`
|
|
1056
|
+
|
|
1057
|
+
Use this when:
|
|
1058
|
+
- The user asks you to create, edit, run, or delete an automation
|
|
1059
|
+
- The user asks you to manage environments, environment variables, or environment files
|
|
1060
|
+
- The user asks "what envs / repos / automations do I have?"
|
|
1061
|
+
- The user asks you to scaffold a \`replicas.json\` / \`replicas.yaml\` in a repo`;
|
|
1062
|
+
var REFERENCE7 = `# Replicas (in-workspace CLI)
|
|
1063
|
+
|
|
1064
|
+
This guide covers how to take action *with* Replicas itself from inside a Replicas workspace \u2014 managing automations, environments (and their variables/files), repos, previews, and the user's \`replicas.json\` config \u2014 using the pre-installed \`replicas\` CLI.
|
|
1065
|
+
|
|
1066
|
+
When the user asks _about_ Replicas (concepts, pricing, how a feature works), check https://docs.replicas.dev first. When the user asks you to _do_ something in their Replicas org, this is the file to use.
|
|
1067
|
+
|
|
1068
|
+
## Prerequisites
|
|
1069
|
+
|
|
1070
|
+
The CLI is pre-installed in every workspace and pre-authenticated using the workspace's engine secret. You do **not** need to log in or set an API key. Verify:
|
|
1071
|
+
|
|
1072
|
+
\`\`\`bash
|
|
1073
|
+
replicas whoami
|
|
1074
|
+
\`\`\`
|
|
1075
|
+
|
|
1076
|
+
Expected output (in agent mode):
|
|
1077
|
+
|
|
1078
|
+
\`\`\`
|
|
1079
|
+
Workspace identity:
|
|
1080
|
+
Workspace ID: <uuid>
|
|
1081
|
+
Organization ID: <uuid>
|
|
1082
|
+
\`\`\`
|
|
1083
|
+
|
|
1084
|
+
If you get "Not logged in", the workspace is misconfigured \u2014 surface this to the user instead of trying to work around it.
|
|
1085
|
+
|
|
1086
|
+
In agent mode the CLI hides commands that don't make sense for in-workspace agents (\`login\`, \`logout\`, \`codex-auth\`, \`claude-auth\`, \`org switch\`, \`config\`, \`interact\`, \`code\`, replica/workspace top-level CRUD). What you have is:
|
|
1087
|
+
|
|
1088
|
+
| Command | What it does |
|
|
1089
|
+
| --- | --- |
|
|
1090
|
+
| \`replicas whoami\` | Print the workspace + org identity |
|
|
1091
|
+
| \`replicas init\` | Create a \`replicas.json\` / \`replicas.yaml\` in the current directory |
|
|
1092
|
+
| \`replicas connect <name>\` | SSH into another workspace (requires user creds \u2014 usually only useful when scripting locally) |
|
|
1093
|
+
| \`replicas repos\` | List repos connected to the org |
|
|
1094
|
+
| \`replicas environment ...\` | Manage environments, env vars, env files |
|
|
1095
|
+
| \`replicas automation ...\` | Manage automations (cron + GitHub event triggers) |
|
|
1096
|
+
| \`replicas preview ...\` | Register / list preview URLs (covered in \`PREVIEWS.md\`) |
|
|
1097
|
+
| \`replicas media ...\` | Upload screenshots, videos, audio (covered in \`MEDIA.md\`) |
|
|
1098
|
+
|
|
1099
|
+
\`replicas <command> --help\` is always the source of truth for flags.
|
|
1100
|
+
|
|
1101
|
+
## Picking the right command for the user's request
|
|
1102
|
+
|
|
1103
|
+
| User says... | Run |
|
|
1104
|
+
| --- | --- |
|
|
1105
|
+
| "What environments do I have?" | \`replicas environment list\` |
|
|
1106
|
+
| "Add API key X to my staging env" | \`replicas environment vars set <env> <KEY> <VALUE>\` |
|
|
1107
|
+
| "Make me a \`.env\` file in the workspace with these vars" | \`replicas environment files set <env> .env --content "..."\` |
|
|
1108
|
+
| "Create a new env for my \`acme/web\` repo" | \`replicas environment create <name> -r acme/web\` |
|
|
1109
|
+
| "What automations do I have?" | \`replicas automation list\` |
|
|
1110
|
+
| "Run my nightly automation now" | \`replicas automation run <id>\` |
|
|
1111
|
+
| "Make an automation that runs every weekday at 9am" | \`replicas automation create\` (interactive) or \`--trigger-cron "0 9 * * 1-5"\` |
|
|
1112
|
+
| "Make an automation that runs when a PR opens on \`acme/web\`" | \`replicas automation create ... --trigger-github pull_request.opened --trigger-github-repos acme/web\` |
|
|
1113
|
+
| "What repos are connected?" | \`replicas repos\` |
|
|
1114
|
+
| "Set up a \`replicas.json\` in this repo" | \`replicas init\` (\`-y\` for YAML) |
|
|
1115
|
+
|
|
1116
|
+
## Environments
|
|
1117
|
+
|
|
1118
|
+
Environments are the org-scoped *primitives* workspaces are built from. Each environment can bind to one repository (or repository set), carry environment variables, project files, enabled skills, and MCP servers. The \`Global\` environment is special \u2014 its vars/files/skills/MCPs apply to *every* workspace in the org, but it has no repo binding and can't back a workspace on its own.
|
|
1119
|
+
|
|
1120
|
+
### List / get / create / edit / delete
|
|
1121
|
+
|
|
1122
|
+
\`\`\`bash
|
|
1123
|
+
replicas environment list
|
|
1124
|
+
replicas environment get <id-or-name> # use "global" for the Global env
|
|
1125
|
+
replicas environment create [name] \\
|
|
1126
|
+
--description "..." \\
|
|
1127
|
+
--repository <repo-name-or-id> \\
|
|
1128
|
+
--system-prompt "..."
|
|
1129
|
+
replicas environment edit <id-or-name> \\
|
|
1130
|
+
--name "..." --description "..." \\
|
|
1131
|
+
--repository <repo-name-or-id> # pass empty string to unbind
|
|
1132
|
+
replicas environment delete <id-or-name> [--force]
|
|
1133
|
+
\`\`\`
|
|
1134
|
+
|
|
1135
|
+
Notes:
|
|
1136
|
+
- Environments resolve by **name or UUID**. \`global\` is an alias for the org's Global env.
|
|
1137
|
+
- Non-global envs need a repo (or repo set) to back a workspace. If you \`create\` without \`--repository\`, the CLI prompts; in non-interactive contexts pass \`-r\`.
|
|
1138
|
+
- \`edit\` on the Global env is rejected by the API \u2014 manage its contents through the \`vars\` / \`files\` subcommands instead.
|
|
1139
|
+
|
|
1140
|
+
### Environment variables
|
|
1141
|
+
|
|
1142
|
+
\`\`\`bash
|
|
1143
|
+
replicas environment vars list <env>
|
|
1144
|
+
replicas environment vars set <env> <KEY> <VALUE> # upsert (create or update)
|
|
1145
|
+
replicas environment vars delete <env> <KEY|VARIABLE_ID> [--force]
|
|
1146
|
+
\`\`\`
|
|
1147
|
+
|
|
1148
|
+
\`vars set\` is upsert: if a variable with that key already exists, it's updated; otherwise created. The CLI accepts either the variable's \`key\` or its UUID for \`delete\`.
|
|
1149
|
+
|
|
1150
|
+
These variables are injected into every workspace built from this environment as actual \`env\` vars \u2014 perfect for API keys, feature flags, etc. Anything you want available to the agent's tools (Claude, codex, your code, etc.) goes here.
|
|
1151
|
+
|
|
1152
|
+
### Environment files
|
|
1153
|
+
|
|
1154
|
+
Files materialize on the workspace filesystem when a workspace starts, at the destination path you specify. Use this for things like \`.env\` files at the repo root, dotfiles in \`~\`, prompt files for agents, etc.
|
|
1155
|
+
|
|
1156
|
+
\`\`\`bash
|
|
1157
|
+
replicas environment files list <env>
|
|
1158
|
+
replicas environment files set <env> <destination-path> --content "..." # inline
|
|
1159
|
+
replicas environment files set <env> <destination-path> --file <local-path> # from local file
|
|
1160
|
+
replicas environment files set <env> <destination-path> --file <local-path> --name "Friendly name"
|
|
1161
|
+
replicas environment files delete <env> <destination-path|FILE_ID> [--force]
|
|
1162
|
+
\`\`\`
|
|
1163
|
+
|
|
1164
|
+
Constraints:
|
|
1165
|
+
- Each file is capped at 64KB.
|
|
1166
|
+
- \`set\` is upsert (matched by destination path).
|
|
1167
|
+
- The display \`--name\` defaults to the basename of the destination path; override only if it would be unclear in the dashboard list.
|
|
1168
|
+
|
|
1169
|
+
## Automations
|
|
1170
|
+
|
|
1171
|
+
Automations are saved prompts with one or more triggers (cron schedules and/or GitHub events). When fired, they create a workspace using the configured environment and run the prompt with the user's coding agent.
|
|
1172
|
+
|
|
1173
|
+
### List / get / run / delete
|
|
1174
|
+
|
|
1175
|
+
\`\`\`bash
|
|
1176
|
+
replicas automation list
|
|
1177
|
+
replicas automation get <id>
|
|
1178
|
+
replicas automation run <id> # cron-triggered automations only
|
|
1179
|
+
replicas automation delete <id> [--force]
|
|
1180
|
+
\`\`\`
|
|
1181
|
+
|
|
1182
|
+
### Create
|
|
1183
|
+
|
|
1184
|
+
Either fully flag-driven or fully interactive \u2014 the CLI prompts for anything you don't pass.
|
|
1185
|
+
|
|
1186
|
+
\`\`\`bash
|
|
1187
|
+
# Cron trigger
|
|
1188
|
+
replicas automation create "Nightly typecheck" \\
|
|
1189
|
+
--prompt "Run \\\`bun typecheck\\\` and report any new errors" \\
|
|
1190
|
+
--environment <env-name-or-id> \\
|
|
1191
|
+
--trigger-cron "0 4 * * *" \\
|
|
1192
|
+
--trigger-cron-timezone "America/New_York"
|
|
1193
|
+
|
|
1194
|
+
# GitHub trigger (filter to specific repos)
|
|
1195
|
+
replicas automation create "Review my PRs" \\
|
|
1196
|
+
--prompt "Leave a code review on this PR" \\
|
|
1197
|
+
--environment <env-name-or-id> \\
|
|
1198
|
+
--trigger-github pull_request.opened \\
|
|
1199
|
+
--trigger-github-repos acme/web,acme/api
|
|
1200
|
+
|
|
1201
|
+
# Disable on creation
|
|
1202
|
+
replicas automation create ... --disabled
|
|
1203
|
+
|
|
1204
|
+
# Workspace lifecycle
|
|
1205
|
+
replicas automation create ... --lifecycle delete_when_done
|
|
1206
|
+
replicas automation create ... --lifecycle delete_after_inactivity --auto-stop-minutes 30
|
|
1207
|
+
\`\`\`
|
|
1208
|
+
|
|
1209
|
+
When the user says "make me an automation that...", default to **picking the environment for them by listing the available envs** and asking only when the user hasn't already pinned one. Same for repos in GitHub triggers. Don't pepper the user with questions you can answer by reading the existing config.
|
|
1210
|
+
|
|
1211
|
+
### Edit
|
|
1212
|
+
|
|
1213
|
+
\`\`\`bash
|
|
1214
|
+
replicas automation edit <id> \\
|
|
1215
|
+
--name "..." \\
|
|
1216
|
+
--prompt "..." \\
|
|
1217
|
+
--enabled true|false \\
|
|
1218
|
+
--environment <env-name-or-id> \\
|
|
1219
|
+
--trigger-cron "0 4 * * *" # replaces existing triggers
|
|
1220
|
+
\`\`\`
|
|
1221
|
+
|
|
1222
|
+
\`replicas automation edit <id>\` with no flags drops into interactive mode.
|
|
1223
|
+
|
|
1224
|
+
## Repositories
|
|
1225
|
+
|
|
1226
|
+
Read-only listing of repos connected to the org. Use when the user asks "what repos can I use?", or to validate a \`--repository\` value before passing it to \`environment create\` / \`automation create\`:
|
|
1227
|
+
|
|
1228
|
+
\`\`\`bash
|
|
1229
|
+
replicas repos
|
|
1230
|
+
\`\`\`
|
|
1231
|
+
|
|
1232
|
+
Repos are connected via the GitHub integration in the dashboard \u2014 not from the CLI. If the user wants a repo connected, point them at the dashboard rather than trying to do it yourself.
|
|
1233
|
+
|
|
1234
|
+
## \`replicas.json\` / \`replicas.yaml\`
|
|
1235
|
+
|
|
1236
|
+
\`replicas init\` creates a starter config in the current directory. \`-y\` writes YAML, \`-f\` overwrites an existing file. This file controls per-repo workspace setup (warm hooks, start hooks, organization scoping for GitHub triggers). When the user asks to "set up Replicas in this repo", run \`replicas init\` and then edit the generated file based on what they need.
|
|
1237
|
+
|
|
1238
|
+
## When NOT to use the CLI
|
|
1239
|
+
|
|
1240
|
+
- **Don't use the CLI to reach into other tools' state** (Linear, Slack, GitHub) \u2014 those have dedicated skill references in this directory.
|
|
1241
|
+
- **Don't try to install Replicas, log in, or switch orgs** \u2014 those flows are user-facing and aren't available in agent mode anyway.
|
|
1242
|
+
- **Don't create workspaces** from inside an existing workspace just to run a command. You're already in one.
|
|
1243
|
+
|
|
1244
|
+
## Common errors
|
|
1245
|
+
|
|
1246
|
+
- \`Missing Replicas-Org-Id header\` \u2192 the workspace is hitting an older monolith that doesn't yet recognize agent auth on this endpoint. Surface this to the user; don't try to work around it by faking headers.
|
|
1247
|
+
- \`Workspace not found\` \u2192 the workspace was deleted while you were running. Stop and tell the user.
|
|
1248
|
+
- \`An environment with this name already exists\` \u2192 use \`environment edit\` instead, or pick a different name.
|
|
1249
|
+
- \`Cannot delete the global environment\` \u2192 there is exactly one Global env per org and it's permanent. Manage its *contents* (\`vars\`, \`files\`) instead.
|
|
1250
|
+
`;
|
|
1251
|
+
var REPLICAS_ABILITY = {
|
|
1252
|
+
label: "Replicas",
|
|
1253
|
+
description: "Teach the agent about Replicas itself \u2014 automations, environments, the in-workspace CLI.",
|
|
1254
|
+
// No bullet — help_instructions covers the `replicas` CLI surface in detail.
|
|
1255
|
+
bullet: "",
|
|
1256
|
+
section: SECTION7,
|
|
1257
|
+
referenceFile: { name: "REPLICAS.md", content: REFERENCE7 },
|
|
1258
|
+
locked: true
|
|
1259
|
+
};
|
|
1260
|
+
|
|
1261
|
+
// ../shared/src/default-skills/replicas-agent/abilities/slack.ts
|
|
1262
|
+
var SECTION8 = `### Slack
|
|
1263
|
+
Send messages, read threads, search conversations, and upload files via the Slack Web API.
|
|
1264
|
+
|
|
1265
|
+
**Reference:** \`references/SLACK.md\`
|
|
1266
|
+
|
|
1267
|
+
Use this when:
|
|
1268
|
+
- You need to send a message to a Slack channel or thread
|
|
1269
|
+
- You need to read or fetch a Slack conversation
|
|
1270
|
+
- You encounter a Slack message link and need to retrieve its content
|
|
1271
|
+
- The task asks you to notify, update, or communicate via Slack`;
|
|
1272
|
+
var REFERENCE8 = `# Slack Integration
|
|
1273
|
+
|
|
1274
|
+
This guide covers how to interact with Slack from within your Replicas workspace.
|
|
1275
|
+
|
|
1276
|
+
## Prerequisites
|
|
1277
|
+
|
|
1278
|
+
Check if the \`SLACK_BOT_TOKEN\` environment variable is set:
|
|
1279
|
+
|
|
1280
|
+
\`\`\`bash
|
|
1281
|
+
echo "\${SLACK_BOT_TOKEN:+set}"
|
|
1282
|
+
\`\`\`
|
|
1283
|
+
|
|
1284
|
+
- If **set**: Your workspace has Slack access. You can use the Slack Web API as described below.
|
|
1285
|
+
- If **not set**: Slack has not been configured for this workspace. The user needs to connect Slack in the [Replicas dashboard](https://replicas.dev) under their organization's integration settings. Let the user know and do not attempt Slack operations.
|
|
1286
|
+
|
|
1287
|
+
## Using the Slack API
|
|
1288
|
+
|
|
1289
|
+
All requests use the \`$SLACK_BOT_TOKEN\` for authentication via the Slack Web API.
|
|
1290
|
+
|
|
1291
|
+
### Fetching a Thread from a Slack Link
|
|
1292
|
+
|
|
1293
|
+
If you encounter a Slack message link (e.g. \`https://team.slack.com/archives/C0123ABC/p1234567890123456\`), extract the channel ID and thread timestamp:
|
|
1294
|
+
|
|
1295
|
+
- **Channel ID**: The segment after \`/archives/\` (e.g. \`C0123ABC\`)
|
|
1296
|
+
- **Thread TS**: The \`p\` value with a dot inserted before the last 6 digits (e.g. \`p1234567890123456\` -> \`1234567890.123456\`)
|
|
1297
|
+
|
|
1298
|
+
\`\`\`bash
|
|
1299
|
+
curl -s "https://slack.com/api/conversations.replies?channel=CHANNEL_ID&ts=THREAD_TS" \\
|
|
1300
|
+
-H "Authorization: Bearer $SLACK_BOT_TOKEN"
|
|
1301
|
+
\`\`\`
|
|
1302
|
+
|
|
1303
|
+
### Sending a Message
|
|
1304
|
+
|
|
1305
|
+
\`\`\`bash
|
|
1306
|
+
curl -s -X POST "https://slack.com/api/chat.postMessage" \\
|
|
1307
|
+
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \\
|
|
1308
|
+
-H "Content-Type: application/json" \\
|
|
1309
|
+
-d '{
|
|
1310
|
+
"channel": "CHANNEL_ID",
|
|
1311
|
+
"text": "Your message here",
|
|
1312
|
+
"thread_ts": "OPTIONAL_THREAD_TS"
|
|
1313
|
+
}'
|
|
1314
|
+
\`\`\`
|
|
1315
|
+
|
|
1316
|
+
Omit \`thread_ts\` to post a new message to the channel. Include it to reply in a thread.
|
|
1317
|
+
|
|
1318
|
+
### Searching Messages
|
|
1319
|
+
|
|
1320
|
+
\`\`\`bash
|
|
1321
|
+
curl -s "https://slack.com/api/search.messages?query=YOUR_SEARCH_QUERY" \\
|
|
1322
|
+
-H "Authorization: Bearer $SLACK_BOT_TOKEN"
|
|
1323
|
+
\`\`\`
|
|
1324
|
+
|
|
1325
|
+
### Uploading Files
|
|
1326
|
+
|
|
1327
|
+
\`\`\`bash
|
|
1328
|
+
curl -s -X POST "https://slack.com/api/files.uploadV2" \\
|
|
1329
|
+
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \\
|
|
1330
|
+
-F "channel_id=CHANNEL_ID" \\
|
|
1331
|
+
-F "file=@/path/to/file" \\
|
|
1332
|
+
-F "title=File title"
|
|
1333
|
+
\`\`\`
|
|
1334
|
+
|
|
1335
|
+
### Other Operations
|
|
1336
|
+
|
|
1337
|
+
You can list channels, read channel history, add reactions, and perform any other operation supported by the Slack Web API using the same authentication pattern.
|
|
1338
|
+
|
|
1339
|
+
For full API documentation, see: https://docs.slack.dev/apis/web-api/
|
|
1340
|
+
`;
|
|
1341
|
+
var SLACK_ABILITY = {
|
|
1342
|
+
label: "Slack",
|
|
1343
|
+
description: "Send messages, read threads, search conversations, upload files.",
|
|
1344
|
+
bullet: "- Interacting with Slack (sending messages, reading threads, etc.)",
|
|
1345
|
+
section: SECTION8,
|
|
1346
|
+
referenceFile: { name: "SLACK.md", content: REFERENCE8 }
|
|
1347
|
+
};
|
|
1348
|
+
|
|
1349
|
+
// ../shared/src/default-skills/replicas-agent/registry.ts
|
|
1350
|
+
var REPLICAS_AGENT_ABILITY_REGISTRY = {
|
|
1351
|
+
replicas: REPLICAS_ABILITY,
|
|
1352
|
+
docker: DOCKER_ABILITY,
|
|
1353
|
+
github: GITHUB_ABILITY,
|
|
1354
|
+
google: GOOGLE_ABILITY,
|
|
1355
|
+
linear: LINEAR_ABILITY,
|
|
1356
|
+
media: MEDIA_ABILITY,
|
|
1357
|
+
previews: PREVIEWS_ABILITY,
|
|
1358
|
+
slack: SLACK_ABILITY
|
|
1359
|
+
};
|
|
1360
|
+
var REPLICAS_AGENT_ABILITIES = Object.keys(
|
|
1361
|
+
REPLICAS_AGENT_ABILITY_REGISTRY
|
|
1362
|
+
);
|
|
1363
|
+
|
|
1364
|
+
// ../shared/src/routes/preferences.ts
|
|
1365
|
+
var DEFAULT_REPLICAS_AGENT_ABILITIES = Object.fromEntries(
|
|
1366
|
+
REPLICAS_AGENT_ABILITIES.map((key) => [key, true])
|
|
1367
|
+
);
|
|
1368
|
+
var DEFAULT_DEFAULT_SKILLS = {
|
|
1369
|
+
replicas_agent: {
|
|
1370
|
+
enabled: true,
|
|
1371
|
+
abilities: { ...DEFAULT_REPLICAS_AGENT_ABILITIES }
|
|
1372
|
+
}
|
|
1373
|
+
};
|
|
1374
|
+
|
|
279
1375
|
// ../shared/src/replicas-config.ts
|
|
280
1376
|
import { parse as parseYaml } from "yaml";
|
|
281
1377
|
|
|
@@ -397,7 +1493,7 @@ function parseReplicasConfigString(content, filename) {
|
|
|
397
1493
|
}
|
|
398
1494
|
|
|
399
1495
|
// ../shared/src/engine/environment.ts
|
|
400
|
-
var DAYTONA_SNAPSHOT_ID = "25-05-2026-royal-york-
|
|
1496
|
+
var DAYTONA_SNAPSHOT_ID = "25-05-2026-royal-york-v3";
|
|
401
1497
|
|
|
402
1498
|
// ../shared/src/engine/types.ts
|
|
403
1499
|
var DEFAULT_CHAT_TITLES = {
|