@desplega.ai/agent-swarm 1.85.0 → 1.86.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/README.md +1 -0
  2. package/openapi.json +1 -1
  3. package/package.json +8 -6
  4. package/src/be/db.ts +44 -0
  5. package/src/be/migrations/078_backfill_gpt_5_5_pricing.sql +15 -0
  6. package/src/be/modelsdev-cache.json +152028 -0
  7. package/src/be/modelsdev-cache.ts +46 -0
  8. package/src/be/seed-pricing.ts +7 -44
  9. package/src/cli.tsx +12 -2
  10. package/src/commands/codex-session-runner.ts +132 -0
  11. package/src/commands/credential-wait.ts +2 -2
  12. package/src/commands/provider-credentials.ts +10 -5
  13. package/src/commands/runner.ts +3 -3
  14. package/src/prompts/base-prompt.ts +49 -3
  15. package/src/providers/claude-adapter.ts +83 -2
  16. package/src/providers/claude-managed-models.ts +18 -2
  17. package/src/providers/codex-adapter.ts +417 -97
  18. package/src/providers/codex-models.ts +9 -2
  19. package/src/providers/index.ts +28 -19
  20. package/src/providers/pricing-sources.md +7 -4
  21. package/src/providers/swarm-events-shared.ts +14 -0
  22. package/src/slack/HEURISTICS.md +5 -1
  23. package/src/slack/handlers.test.ts +35 -0
  24. package/src/slack/handlers.ts +79 -2
  25. package/src/tests/base-prompt.test.ts +46 -8
  26. package/src/tests/claude-managed-adapter.test.ts +4 -4
  27. package/src/tests/codex-adapter-otel.test.ts +4 -4
  28. package/src/tests/codex-adapter.test.ts +20 -7
  29. package/src/tests/codex-swarm-events.test.ts +35 -0
  30. package/src/tests/context-window.test.ts +1 -0
  31. package/src/tests/credential-check.test.ts +48 -29
  32. package/src/tests/entrypoint-config-env-export.test.ts +81 -0
  33. package/src/tests/follow-up-redelivery-guard.test.ts +165 -0
  34. package/src/tests/migration-046-budgets.test.ts +6 -5
  35. package/src/tests/pricing-routes.test.ts +6 -5
  36. package/src/tests/provider-adapter.test.ts +10 -10
  37. package/src/tests/provider-command-format.test.ts +4 -4
  38. package/src/tests/session-costs-codex-recompute.test.ts +25 -0
  39. package/src/tools/send-task.ts +30 -9
  40. package/src/utils/context-window.ts +1 -0
  41. package/templates/schedules/daily-blocker-digest/config.json +13 -0
  42. package/templates/schedules/daily-blocker-digest/content.md +150 -0
  43. package/templates/schedules/daily-compounding-reflection/config.json +21 -0
  44. package/templates/schedules/daily-compounding-reflection/content.md +210 -0
  45. package/templates/schedules/daily-hn-briefing/config.json +13 -0
  46. package/templates/schedules/daily-hn-briefing/content.md +97 -0
  47. package/templates/schedules/daily-workflow-health-audit/config.json +13 -0
  48. package/templates/schedules/daily-workflow-health-audit/content.md +189 -0
  49. package/templates/schedules/gtm-weekly-review/config.json +13 -0
  50. package/templates/schedules/gtm-weekly-review/content.md +58 -0
  51. package/templates/schedules/weekly-dependabot-triage/config.json +13 -0
  52. package/templates/schedules/weekly-dependabot-triage/content.md +45 -0
  53. package/templates/schema.ts +26 -0
  54. package/templates/skills/agentmail-sending/config.json +13 -0
  55. package/templates/skills/agentmail-sending/content.md +48 -0
  56. package/templates/skills/artifacts/config.json +13 -0
  57. package/templates/skills/artifacts/content.md +87 -0
  58. package/templates/skills/browser-use-cloud/config.json +13 -0
  59. package/templates/skills/browser-use-cloud/content.md +155 -0
  60. package/templates/skills/desloppify/config.json +13 -0
  61. package/templates/skills/desloppify/content.md +201 -0
  62. package/templates/skills/exa-search/config.json +13 -0
  63. package/templates/skills/exa-search/content.md +106 -0
  64. package/templates/skills/jira-interaction/config.json +13 -0
  65. package/templates/skills/jira-interaction/content.md +252 -0
  66. package/templates/skills/kapso-whatsapp/config.json +13 -0
  67. package/templates/skills/kapso-whatsapp/content.md +369 -0
  68. package/templates/skills/kv-storage/config.json +13 -0
  69. package/templates/skills/kv-storage/content.md +111 -0
  70. package/templates/skills/linear-interaction/config.json +20 -0
  71. package/templates/skills/linear-interaction/content.md +230 -0
  72. package/templates/skills/pages/config.json +18 -0
  73. package/templates/skills/pages/content.md +85 -0
  74. package/templates/skills/profile-corruption-escalation/config.json +13 -0
  75. package/templates/skills/profile-corruption-escalation/content.md +105 -0
  76. package/templates/skills/scheduled-task-resilience/config.json +13 -0
  77. package/templates/skills/scheduled-task-resilience/content.md +95 -0
  78. package/templates/skills/sprite-cli/config.json +13 -0
  79. package/templates/skills/sprite-cli/content.md +133 -0
  80. package/templates/skills/turso-interaction/config.json +13 -0
  81. package/templates/skills/turso-interaction/content.md +192 -0
  82. package/templates/skills/workflow-iterate/config.json +18 -0
  83. package/templates/skills/workflow-iterate/content.md +399 -0
  84. package/templates/skills/workflow-structured-output/config.json +13 -0
  85. package/templates/skills/workflow-structured-output/content.md +101 -0
  86. package/templates/skills/x-api-interactions/config.json +13 -0
  87. package/templates/skills/x-api-interactions/content.md +109 -0
  88. package/templates/workflows/autopilot/config.json +13 -0
  89. package/templates/workflows/autopilot/content.md +58 -0
  90. package/templates/workflows/linear-drain-loop/config.json +21 -0
  91. package/templates/workflows/linear-drain-loop/content.md +72 -0
  92. package/templates/workflows/ralph-loop/config.json +13 -0
  93. package/templates/workflows/ralph-loop/content.md +75 -0
@@ -0,0 +1,109 @@
1
+ # X API Interactions (Twitter API v2)
2
+
3
+ ## Authentication
4
+
5
+ Use OAuth 1.0a for all write operations (POST). Bearer tokens are read-only.
6
+
7
+ Credentials are stored in swarm config:
8
+ - `X_API_KEY` — Consumer key
9
+ - `X_API_SECRET` — Consumer secret
10
+ - `X_ACCESS_TOKEN` — Access token
11
+ - `X_ACCESS_TOKEN_SECRET` — Access token secret
12
+
13
+ Retrieve with `get-config` tool.
14
+
15
+ ## OAuth 1.0a Signing
16
+
17
+ The Twitter API v2 requires OAuth 1.0a signature for POST requests. Use a library or construct manually:
18
+
19
+ ```bash
20
+ # Using node with oauth-1.0a package
21
+ node -e "
22
+ const OAuth = require('oauth-1.0a');
23
+ const crypto = require('crypto');
24
+
25
+ const oauth = OAuth({
26
+ consumer: { key: process.env.X_API_KEY, secret: process.env.X_API_SECRET },
27
+ signature_method: 'HMAC-SHA1',
28
+ hash_function: (base, key) => crypto.createHmac('sha1', key).update(base).digest('base64')
29
+ });
30
+
31
+ const token = { key: process.env.X_ACCESS_TOKEN, secret: process.env.X_ACCESS_TOKEN_SECRET };
32
+ const url = 'https://api.x.com/2/tweets';
33
+ const method = 'POST';
34
+
35
+ const auth = oauth.authorize({ url, method }, token);
36
+ const header = oauth.toHeader(auth);
37
+ console.log(header.Authorization);
38
+ "
39
+ ```
40
+
41
+ ## Pre-Check: Conversation Restrictions (CRITICAL)
42
+
43
+ Before attempting a reply, **always check the target tweet's reply_settings**:
44
+
45
+ ```bash
46
+ curl -s "https://api.x.com/2/tweets/{TWEET_ID}?tweet.fields=reply_settings" \
47
+ -H "Authorization: Bearer $X_BEARER_TOKEN"
48
+ ```
49
+
50
+ Response includes `reply_settings`:
51
+ - `everyone` — Anyone can reply
52
+ - `mentionedUsers` — Only mentioned users can reply (unless @desplegalabs is mentioned)
53
+ - `following` — Only followers can reply (unless the author follows @desplegalabs)
54
+
55
+ **If reply_settings is NOT "everyone", do NOT attempt the reply.** Report back that the tweet has conversation restrictions. Quote tweets may also be restricted on such tweets.
56
+
57
+ ## Posting a Tweet
58
+
59
+ ```bash
60
+ curl -X POST "https://api.x.com/2/tweets" \
61
+ -H "Authorization: $OAUTH_HEADER" \
62
+ -H "Content-Type: application/json" \
63
+ -d '{"text": "Your tweet text"}'
64
+ ```
65
+
66
+ ## Posting a Reply
67
+
68
+ ```bash
69
+ curl -X POST "https://api.x.com/2/tweets" \
70
+ -H "Authorization: $OAUTH_HEADER" \
71
+ -H "Content-Type: application/json" \
72
+ -d '{"text": "Your reply text", "reply": {"in_reply_to_tweet_id": "TWEET_ID"}}'
73
+ ```
74
+
75
+ ## Posting a Quote Tweet
76
+
77
+ ```bash
78
+ curl -X POST "https://api.x.com/2/tweets" \
79
+ -H "Authorization: $OAUTH_HEADER" \
80
+ -H "Content-Type: application/json" \
81
+ -d '{"text": "Your quote text", "quote_tweet_id": "TWEET_ID"}'
82
+ ```
83
+
84
+ ## Common Errors
85
+
86
+ | Error | Cause | Fix |
87
+ |-------|-------|-----|
88
+ | **402 CreditsDepleted** | Monthly API credits exhausted | **STOP immediately.** Do NOT retry. Save generated content to agent-fs for later manual posting. Report to Slack. Mark task as failed. Taras must top up credits at developer.x.com. |
89
+ | 403 Forbidden on reply | Conversation restrictions | Pre-check reply_settings |
90
+ | 403 Forbidden on quote | Quote restrictions | Report back, don't retry |
91
+ | 401 Unauthorized | Bad OAuth signature | Verify credentials, check timestamp |
92
+ | 429 Too Many Requests | Rate limit | Wait and retry after reset time |
93
+
94
+ **IMPORTANT: 402 CreditsDepleted is NOT retryable.** Both media-attached and text-only tweets fail with this error. Do not waste context trying alternative posting methods — the issue is account-level, not request-level.
95
+
96
+ ## Account Info
97
+
98
+ - **Account:** @desplegalabs
99
+ - **User ID:** 2027510506601488384
100
+
101
+ ## Workflow
102
+
103
+ 1. Get credentials from swarm config
104
+ 2. **Pre-check** target tweet's reply_settings (if replying)
105
+ 3. Construct OAuth 1.0a signature
106
+ 4. POST the tweet/reply/quote
107
+ 5. If 402, STOP — save content to agent-fs and report (credits depleted)
108
+ 6. If 403, report the restriction — do NOT retry blindly
109
+
@@ -0,0 +1,13 @@
1
+ {
2
+ "kind": "workflow",
3
+ "name": "autopilot",
4
+ "displayName": "Autopilot Feature Pipeline",
5
+ "slug": "autopilot",
6
+ "title": "Autopilot Feature Pipeline",
7
+ "description": "Research, review, plan, implement, and verify a feature request through staged agents.",
8
+ "version": "1.0.0",
9
+ "category": "workflows",
10
+ "placeholders": ["REPO_URL"],
11
+ "runAllSeedersCandidate": true,
12
+ "tags": ["workflow", "implementation", "review"]
13
+ }
@@ -0,0 +1,58 @@
1
+ # Autopilot Feature Pipeline
2
+
3
+ Use this workflow as a canonical feature delivery pipeline. Customize roles and checks for your swarm.
4
+
5
+ ```json
6
+ {
7
+ "name": "Autopilot feature pipeline",
8
+ "description": "Research, plan, implement, and verify a feature request.",
9
+ "triggerSchema": {
10
+ "type": "object",
11
+ "required": ["request"],
12
+ "properties": {
13
+ "request": { "type": "string" },
14
+ "repoUrl": { "type": "string" }
15
+ }
16
+ },
17
+ "nodes": [
18
+ {
19
+ "id": "research",
20
+ "type": "agent-task",
21
+ "config": {
22
+ "role": "researcher",
23
+ "task": "Research this request for {{repoUrl}}: {{request}}. Return constraints, relevant files, risks, and suggested implementation approach."
24
+ },
25
+ "next": ["plan"]
26
+ },
27
+ {
28
+ "id": "plan",
29
+ "type": "agent-task",
30
+ "inputs": { "research": "research" },
31
+ "config": {
32
+ "role": "reviewer",
33
+ "task": "Create a focused implementation plan using the research output. Include files to touch, tests to run, and likely edge cases."
34
+ },
35
+ "next": ["implement"]
36
+ },
37
+ {
38
+ "id": "implement",
39
+ "type": "agent-task",
40
+ "inputs": { "plan": "plan" },
41
+ "config": {
42
+ "role": "coder",
43
+ "task": "Implement the plan for {{repoUrl}}. Keep the diff scoped, run relevant checks, and prepare a PR summary."
44
+ },
45
+ "next": ["verify"]
46
+ },
47
+ {
48
+ "id": "verify",
49
+ "type": "agent-task",
50
+ "inputs": { "implementation": "implement" },
51
+ "config": {
52
+ "role": "reviewer",
53
+ "task": "Review the implementation output. Verify tests/checks, identify residual risks, and recommend merge readiness."
54
+ }
55
+ }
56
+ ]
57
+ }
58
+ ```
@@ -0,0 +1,21 @@
1
+ {
2
+ "kind": "workflow",
3
+ "name": "linear-drain-loop",
4
+ "displayName": "Linear Drain Loop",
5
+ "slug": "linear-drain-loop",
6
+ "title": "Linear Drain Loop",
7
+ "description": "Break down a Linear parent issue and process ready child issues through workers.",
8
+ "version": "1.0.0",
9
+ "category": "workflows",
10
+ "placeholders": [
11
+ "LINEAR_PROJECT_ID",
12
+ "REPO_URL"
13
+ ],
14
+ "runAllSeedersCandidate": false,
15
+ "tags": [
16
+ "workflow",
17
+ "linear",
18
+ "triage"
19
+ ],
20
+ "must": true
21
+ }
@@ -0,0 +1,72 @@
1
+ # Linear Drain Loop
2
+
3
+ A two-node issue-triage and dispatch workflow. The lead agent reviews child issues under a parent issue in Linear (or any tracker), categorizes them by readiness, and dispatches implementation tasks for those that are ready. Blocked or ambiguous items are surfaced for human review rather than auto-dispatched.
4
+
5
+ ## Configuration
6
+
7
+ ```json
8
+ {
9
+ "name": "Linear drain loop",
10
+ "description": "Drain ready child issues from a parent issue.",
11
+ "triggerSchema": {
12
+ "type": "object",
13
+ "required": ["parentIssueKey"],
14
+ "properties": {
15
+ "parentIssueKey": { "type": "string" },
16
+ "projectId": { "type": "string" },
17
+ "repoUrl": { "type": "string" }
18
+ }
19
+ },
20
+ "nodes": [
21
+ {
22
+ "id": "triage",
23
+ "type": "agent-task",
24
+ "config": {
25
+ "role": "lead",
26
+ "task": "Review child issues under {{parentIssueKey}} in project {{projectId}}. Identify ready, blocked, duplicate, and needs-human-decision items."
27
+ },
28
+ "next": ["dispatch"]
29
+ },
30
+ {
31
+ "id": "dispatch",
32
+ "type": "agent-task",
33
+ "inputs": { "triage": "triage" },
34
+ "config": {
35
+ "role": "lead",
36
+ "task": "For ready items only, create or assign implementation tasks against {{repoUrl}}. Leave a tracker comment summarizing what was dispatched."
37
+ }
38
+ }
39
+ ]
40
+ }
41
+ ```
42
+
43
+ ## What It Does
44
+
45
+ A two-node pipeline:
46
+
47
+ 1. **Triage node (lead):** Reads all child issues under `parentIssueKey` in the given `projectId`. Classifies each as: ready (has acceptance criteria, unblocked), blocked (waiting on another issue or external dependency), duplicate (same scope as an existing issue), or needs-human-decision (ambiguous scope or missing spec).
48
+
49
+ 2. **Dispatch node (lead):** Takes the triage output and creates or assigns implementation tasks **only for ready items**. Posts a tracker comment summarizing what was dispatched and what was skipped.
50
+
51
+ Blocked and ambiguous items are explicitly left alone — the dispatch node surfaces them in the comment for human follow-up rather than guessing.
52
+
53
+ ## When to Use
54
+
55
+ - Weekly sprint grooming: run against a milestone or epic to drain everything that's ready
56
+ - After a planning session: turn a batch of newly-specified issues into assigned tasks
57
+ - Continuous drain: schedule this workflow daily against a backlog parent issue to keep work flowing automatically
58
+
59
+ ## Customization Notes
60
+
61
+ - **`projectId`** is optional but strongly recommended — without it the triage agent may search the wrong project.
62
+ - **`repoUrl`** is used by the dispatch node when creating implementation tasks. Pass the target repo where code changes will land.
63
+ - **Add a notification node:** Extend with a third `agent-task` or `slack-post` node that pings a channel with the dispatch summary.
64
+ - **Filter by label:** Modify the triage node's task prompt to only consider issues with a specific label (e.g., `"Only triage issues labelled 'ready-for-dev'"`) to avoid pulling in issues outside your sprint.
65
+
66
+ ## Trade-offs
67
+
68
+ **Linear-specific prompt:** The triage and dispatch node tasks reference Linear concepts (issues, projects, comments). If your tracker is Jira or GitHub Issues, rephrase the task prompts — the workflow shape is tracker-agnostic but the agent prompts are not.
69
+
70
+ **No iteration:** This is a single-pass drain. Issues that become ready after the run are not picked up until the workflow runs again. Pair with a daily schedule trigger for continuous drain.
71
+
72
+ **Human-in-the-loop for ambiguous items:** By design, needs-human-decision items are not auto-dispatched. If your team wants a fully automated drain, strengthen the `ready` criteria in the triage prompt so fewer items land in the ambiguous bucket.
@@ -0,0 +1,13 @@
1
+ {
2
+ "kind": "workflow",
3
+ "name": "ralph-loop",
4
+ "displayName": "Iterative Review Loop",
5
+ "slug": "ralph-loop",
6
+ "title": "Iterative Review Loop",
7
+ "description": "Run an implement-review-fix loop until verification passes or a human decision is needed.",
8
+ "version": "1.0.0",
9
+ "category": "workflows",
10
+ "placeholders": ["REPO_URL"],
11
+ "runAllSeedersCandidate": false,
12
+ "tags": ["workflow", "review", "iteration"]
13
+ }
@@ -0,0 +1,75 @@
1
+ # Iterative Review Loop
2
+
3
+ A bounded implement → review loop. A coder agent implements the task and reports the diff; a reviewer agent checks it and returns PASS or a blocking fix list. Use this when you want automated quality control with a clear exit condition rather than open-ended implementation.
4
+
5
+ ## Configuration
6
+
7
+ ```json
8
+ {
9
+ "name": "Iterative review loop",
10
+ "description": "Implement, review, and revise until accepted or blocked.",
11
+ "triggerSchema": {
12
+ "type": "object",
13
+ "required": ["task"],
14
+ "properties": {
15
+ "task": { "type": "string" },
16
+ "repoUrl": { "type": "string" },
17
+ "maxIterations": { "type": "number" }
18
+ }
19
+ },
20
+ "nodes": [
21
+ {
22
+ "id": "implement",
23
+ "type": "agent-task",
24
+ "config": {
25
+ "role": "coder",
26
+ "task": "Implement this task in {{repoUrl}}: {{task}}. Run focused checks and report the diff."
27
+ },
28
+ "next": ["review"]
29
+ },
30
+ {
31
+ "id": "review",
32
+ "type": "agent-task",
33
+ "inputs": { "implementation": "implement" },
34
+ "config": {
35
+ "role": "reviewer",
36
+ "task": "Review the implementation. Return PASS when ready, otherwise list blocking fixes only."
37
+ }
38
+ }
39
+ ]
40
+ }
41
+ ```
42
+
43
+ ## What It Does
44
+
45
+ A two-node implement → review loop:
46
+
47
+ 1. **Implement node (coder):** Takes the `task` description and `repoUrl`, produces a working implementation, runs focused checks (lint, types, relevant tests), and reports the diff.
48
+
49
+ 2. **Review node (reviewer):** Reads the implementation output, checks correctness and quality, and returns either `PASS` (implementation is accepted) or a list of blocking fixes only (no nitpicks — only what must change before this can ship).
50
+
51
+ The `maxIterations` parameter is declarative: the reviewer signals PASS when done. The workflow engine handles the iteration ceiling.
52
+
53
+ **Note:** In the current workflow schema, looping back is not native — the review node does not automatically re-trigger the implement node. To iterate, re-trigger the workflow with the reviewer's feedback as the new `task` input, or extend with a `workflow-iterate` skill pattern.
54
+
55
+ ## When to Use
56
+
57
+ - Small, well-defined tasks where one round of review is usually sufficient
58
+ - Automated code review before a PR is created — coder implements, reviewer checks
59
+ - Pair-programming simulation: two agents, different roles, single pass
60
+ - Quality gates on generated content (docs, configs, scripts) that need independent verification before delivery
61
+
62
+ ## Customization Notes
63
+
64
+ - **`maxIterations`** is passed in but not natively enforced by the two-node shape. It's a hint to the agents — include it in the implement node's task prompt if you want the coder to self-limit attempts.
65
+ - **Pin `agentId`** on the implement node to a coder-capable agent with repo access. Pin the review node to a reviewer-capable agent that can reason about code quality.
66
+ - **Add a PR creation node:** Extend with a third agent-task node that takes the reviewer's PASS output and creates a pull request via `gh pr create`.
67
+ - **Add structured output to the review node:** Use `outputSchema: { "type": "object", "properties": { "verdict": { "type": "string", "enum": ["PASS", "FAIL"] }, "fixes": { "type": "array" } } }` to make the verdict machine-readable for downstream automation.
68
+
69
+ ## Trade-offs
70
+
71
+ **No native loop:** This workflow is a single implement → review pass. True multi-iteration requires re-triggering or a more complex DAG. Use the `workflow-iterate` skill if you need the lead agent to drive multiple rounds based on reviewer feedback.
72
+
73
+ **Reviewer quality matters:** The review node's output is only as good as the reviewer agent's judgment. For high-stakes code, add a second reviewer node or route to a human-in-the-loop step before the PASS verdict is accepted.
74
+
75
+ **Scope creep risk:** Coder agents sometimes expand scope beyond the `task` description. Constrain with explicit instructions: `"Only implement exactly what is described. Do not refactor surrounding code."`