@cursor/july 0.1.1 → 0.1.2
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/AGENTS.md +24 -2
- package/README.md +25 -15
- package/dist/bin/agent-serve.js +101 -12
- package/dist/channels/github/api.d.ts.map +1 -1
- package/dist/channels/github/api.js +31 -14
- package/dist/channels/github/cursor-account.d.ts +43 -0
- package/dist/channels/github/cursor-account.d.ts.map +1 -0
- package/dist/channels/github/cursor-account.js +95 -0
- package/dist/channels/github/github-channel.d.ts.map +1 -1
- package/dist/channels/github/github-channel.js +46 -9
- package/dist/channels/github/index.d.ts +2 -2
- package/dist/channels/github/index.js +2 -2
- package/dist/channels/github/types.d.ts +17 -0
- package/dist/channels/github/types.d.ts.map +1 -1
- package/dist/channels/slack/slack-channel.d.ts +8 -2
- package/dist/channels/slack/slack-channel.d.ts.map +1 -1
- package/dist/channels/slack/slack-channel.js +8 -0
- package/dist/channels/slack/types.d.ts +24 -3
- package/dist/channels/slack/types.d.ts.map +1 -1
- package/dist/channels/slack/types.js +15 -1
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +8 -8
- package/dist/docs/assets/{ab.md.COdXkces.js → ab.md.BMCZ6Hd7.js} +3 -3
- package/dist/docs/assets/{ab.md.COdXkces.lean.js → ab.md.BMCZ6Hd7.lean.js} +1 -1
- package/dist/docs/assets/{app.DqfFEmJd.js → app.Oje4vhlk.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.zwQ9RCQ7.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.BaLEdS15.js → VPLocalSearchBox.H5XZ2zCB.js} +1 -1
- package/dist/docs/assets/chunks/{theme.CZRvu_0q.js → theme.CTR_TuaE.js} +2 -2
- package/dist/docs/assets/{deployment.md.Dx1TYNk5.js → deployment.md.DTKwE15Z.js} +3 -3
- package/dist/docs/assets/{deployment.md.Dx1TYNk5.lean.js → deployment.md.DTKwE15Z.lean.js} +1 -1
- package/dist/docs/assets/{evals.md.DPZ_MAnI.js → evals.md.DAgEc_hL.js} +3 -3
- package/dist/docs/assets/{guides_agent-to-agent.md.CrtrsySy.js → guides_agent-to-agent.md.Bpzgq2Pq.js} +1 -1
- package/dist/docs/assets/{guides_cloud-runtime.md.CYlNMTNp.js → guides_cloud-runtime.md.gVzabdQL.js} +1 -1
- package/dist/docs/assets/{guides_github.md.DwbKhCeS.js → guides_github.md.DOOCpqsW.js} +11 -4
- package/dist/docs/assets/{guides_github.md.DwbKhCeS.lean.js → guides_github.md.DOOCpqsW.lean.js} +1 -1
- package/dist/docs/assets/{guides_human-in-the-loop.md.Dvuctx7s.js → guides_human-in-the-loop.md.DlUqsp1S.js} +2 -2
- package/dist/docs/assets/{guides_slack.md.bv41fHfW.js → guides_slack.md.CCwqHvSV.js} +4 -4
- package/dist/docs/assets/{guides_slack.md.bv41fHfW.lean.js → guides_slack.md.CCwqHvSV.lean.js} +1 -1
- package/dist/docs/assets/{guides_webhooks.md.hFTik3lf.js → guides_webhooks.md.B1EswtUu.js} +2 -2
- package/dist/docs/assets/index.md.m81y7TY7.js +20 -0
- package/dist/docs/assets/{index.md.BPKcj5AI.lean.js → index.md.m81y7TY7.lean.js} +1 -1
- package/dist/docs/assets/quickstart.md.CfU8_uTC.js +192 -0
- package/dist/docs/assets/quickstart.md.CfU8_uTC.lean.js +1 -0
- package/dist/docs/assets/{reference_agent-config.md.Bpd7HQwf.js → reference_agent-config.md.DrW2JUM8.js} +4 -4
- package/dist/docs/assets/{reference_agent-config.md.Bpd7HQwf.lean.js → reference_agent-config.md.DrW2JUM8.lean.js} +1 -1
- package/dist/docs/assets/{reference_channels.md.D7JTR03W.js → reference_channels.md.DdmiKgqf.js} +4 -4
- package/dist/docs/assets/{reference_channels.md.D7JTR03W.lean.js → reference_channels.md.DdmiKgqf.lean.js} +1 -1
- package/dist/docs/assets/{reference_connections.md.C3vNH_DE.js → reference_connections.md.zaEYCLHT.js} +1 -1
- package/dist/docs/assets/{reference_hooks.md.BCEc3MyM.js → reference_hooks.md.DyLVfE1O.js} +1 -1
- package/dist/docs/assets/{reference_hooks.md.BCEc3MyM.lean.js → reference_hooks.md.DyLVfE1O.lean.js} +1 -1
- package/dist/docs/assets/{reference_http-api.md.DBAahtdz.js → reference_http-api.md.Dx_nmDG6.js} +1 -1
- package/dist/docs/assets/{reference_instructions.md.BC05LEQ8.js → reference_instructions.md.CgoV-YEb.js} +9 -7
- package/dist/docs/assets/{reference_instructions.md.BC05LEQ8.lean.js → reference_instructions.md.CgoV-YEb.lean.js} +1 -1
- package/dist/docs/assets/{reference_schedules.md.D7qijxLk.js → reference_schedules.md.w_F2mXB6.js} +2 -2
- package/dist/docs/assets/{reference_skills.md.VQnlBT3Q.js → reference_skills.md.B_jHN7JL.js} +3 -3
- package/dist/docs/assets/{reference_skills.md.VQnlBT3Q.lean.js → reference_skills.md.B_jHN7JL.lean.js} +1 -1
- package/dist/docs/assets/{reference_subagents.md.CIRAVcPK.js → reference_subagents.md.zWAMNfi1.js} +1 -1
- package/dist/docs/assets/{reference_tools.md.DF5kwlt0.js → reference_tools.md.CqgJroI0.js} +2 -2
- package/dist/docs/assets/scaffolding-agents.md.C3pTrmoE.js +1 -0
- package/dist/docs/assets/scaffolding-agents.md.C3pTrmoE.lean.js +1 -0
- package/dist/docs/assets/storage.md.CVnInNiN.js +17 -0
- package/dist/docs/assets/storage.md.CVnInNiN.lean.js +1 -0
- package/dist/docs/building-with-agents.html +4 -4
- package/dist/docs/concepts.html +4 -4
- package/dist/docs/deployment.html +7 -7
- package/dist/docs/evals.html +7 -7
- package/dist/docs/guides/agent-to-agent.html +6 -6
- package/dist/docs/guides/cloud-runtime.html +5 -5
- package/dist/docs/guides/github.html +14 -7
- package/dist/docs/guides/human-in-the-loop.html +6 -6
- package/dist/docs/guides/slack.html +8 -8
- package/dist/docs/guides/webhooks.html +6 -6
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +5 -5
- package/dist/docs/index.html +7 -7
- package/dist/docs/quickstart.html +180 -23
- package/dist/docs/reference/agent-config.html +7 -7
- package/dist/docs/reference/channels.html +8 -8
- package/dist/docs/reference/cli.html +4 -4
- package/dist/docs/reference/connections.html +5 -5
- package/dist/docs/reference/hooks.html +5 -5
- package/dist/docs/reference/http-api.html +6 -6
- package/dist/docs/reference/instructions.html +13 -11
- package/dist/docs/reference/playground.html +4 -4
- package/dist/docs/reference/project-layout.html +4 -4
- package/dist/docs/reference/schedules.html +7 -7
- package/dist/docs/reference/sessions.html +4 -4
- package/dist/docs/reference/skills.html +6 -6
- package/dist/docs/reference/subagents.html +6 -6
- package/dist/docs/reference/tools.html +7 -7
- package/dist/docs/scaffolding-agents.html +5 -5
- package/dist/docs/storage.html +41 -0
- package/dist/docs/troubleshooting.html +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/internal/cli-deploy.d.ts +52 -0
- package/dist/internal/cli-deploy.d.ts.map +1 -0
- package/dist/internal/cli-deploy.js +731 -0
- package/dist/internal/cursor/backend-client.d.ts +10 -1
- package/dist/internal/cursor/backend-client.d.ts.map +1 -1
- package/dist/internal/cursor/backend-client.js +79 -1
- package/dist/internal/cursor/github-credentials.d.ts +44 -0
- package/dist/internal/cursor/github-credentials.d.ts.map +1 -0
- package/dist/internal/cursor/github-credentials.js +195 -0
- package/dist/internal/deploy-client.d.ts +176 -0
- package/dist/internal/deploy-client.d.ts.map +1 -0
- package/dist/internal/deploy-client.js +375 -0
- package/dist/internal/discovery.d.ts.map +1 -1
- package/dist/internal/discovery.js +73 -5
- package/dist/internal/distribution.d.ts.map +1 -1
- package/dist/internal/distribution.js +1 -0
- package/dist/internal/eval-run-store.d.ts +22 -3
- package/dist/internal/eval-run-store.d.ts.map +1 -1
- package/dist/internal/eval-run-store.js +37 -19
- package/dist/internal/handleAgentServeTrigger.d.ts.map +1 -1
- package/dist/internal/handleAgentServeTrigger.js +10 -12
- package/dist/internal/host-platforms.d.ts +7 -2
- package/dist/internal/host-platforms.d.ts.map +1 -1
- package/dist/internal/host-platforms.js +15 -10
- package/dist/internal/hosting.d.ts +37 -0
- package/dist/internal/hosting.d.ts.map +1 -0
- package/dist/internal/hosting.js +67 -0
- package/dist/internal/reminder-runner.d.ts +7 -0
- package/dist/internal/reminder-runner.d.ts.map +1 -1
- package/dist/internal/reminder-runner.js +50 -6
- package/dist/internal/reminder-store.d.ts +2 -0
- package/dist/internal/reminder-store.d.ts.map +1 -1
- package/dist/internal/reminder-store.js +18 -0
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +173 -42
- package/dist/internal/session-engine.d.ts +49 -0
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +246 -17
- package/dist/internal/storage-coordinator.d.ts +139 -0
- package/dist/internal/storage-coordinator.d.ts.map +1 -0
- package/dist/internal/storage-coordinator.js +499 -0
- package/dist/playground/assets/cursor-icons-outline-BxTT_FVJ.woff2 +0 -0
- package/dist/playground/assets/index-B1Qc9h2u.css +1 -0
- package/dist/playground/assets/{index-FlWjhg3x.js → index-CpDYCj8W.js} +42 -42
- package/dist/playground/index.html +2 -2
- package/dist/storage.d.ts +204 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +153 -0
- package/dist/types.d.ts +44 -3
- package/dist/types.d.ts.map +1 -1
- package/docs/README.md +3 -2
- package/docs/guides/github.md +43 -8
- package/docs/guides/slack.md +1 -1
- package/docs/quickstart.md +329 -51
- package/docs/reference/instructions.md +8 -6
- package/docs/scaffolding-agents.md +1 -1
- package/docs/storage.md +98 -0
- package/package.json +8 -1
- package/skills/github/SKILL.md +9 -1
- package/src/bin/agent-serve.ts +139 -0
- package/src/channels/github/api.ts +42 -23
- package/src/channels/github/cursor-account.ts +165 -0
- package/src/channels/github/github-channel.ts +66 -6
- package/src/channels/github/index.ts +2 -2
- package/src/channels/github/types.ts +19 -0
- package/src/channels/slack/slack-channel.ts +17 -3
- package/src/channels/slack/types.ts +44 -3
- package/src/index.ts +13 -0
- package/src/internal/cli-deploy.ts +940 -0
- package/src/internal/cursor/backend-client.ts +103 -1
- package/src/internal/cursor/github-credentials.ts +248 -0
- package/src/internal/deploy-client.ts +591 -0
- package/src/internal/discovery.ts +88 -1
- package/src/internal/distribution.ts +1 -0
- package/src/internal/eval-run-store.ts +48 -19
- package/src/internal/handleAgentServeTrigger.ts +10 -12
- package/src/internal/host-platforms.ts +28 -11
- package/src/internal/hosting.ts +77 -0
- package/src/internal/reminder-runner.ts +50 -6
- package/src/internal/reminder-store.ts +21 -0
- package/src/internal/server.ts +213 -27
- package/src/internal/session-engine.ts +285 -7
- package/src/internal/storage-coordinator.ts +615 -0
- package/src/storage.ts +325 -0
- package/src/types.ts +40 -2
- package/dist/docs/assets/chunks/@localSearchIndexroot.CcVk1uKq.js +0 -1
- package/dist/docs/assets/index.md.BPKcj5AI.js +0 -20
- package/dist/docs/assets/quickstart.md.tVPiGK_L.js +0 -35
- package/dist/docs/assets/quickstart.md.tVPiGK_L.lean.js +0 -1
- package/dist/docs/assets/scaffolding-agents.md.CyYfWGdc.js +0 -1
- package/dist/docs/assets/scaffolding-agents.md.CyYfWGdc.lean.js +0 -1
- package/dist/playground/assets/cursor-icons-outline-oY2V_mvK.woff2 +0 -0
- package/dist/playground/assets/index-1K-hG-7p.css +0 -1
- /package/dist/docs/assets/{evals.md.DPZ_MAnI.lean.js → evals.md.DAgEc_hL.lean.js} +0 -0
- /package/dist/docs/assets/{guides_agent-to-agent.md.CrtrsySy.lean.js → guides_agent-to-agent.md.Bpzgq2Pq.lean.js} +0 -0
- /package/dist/docs/assets/{guides_cloud-runtime.md.CYlNMTNp.lean.js → guides_cloud-runtime.md.gVzabdQL.lean.js} +0 -0
- /package/dist/docs/assets/{guides_human-in-the-loop.md.Dvuctx7s.lean.js → guides_human-in-the-loop.md.DlUqsp1S.lean.js} +0 -0
- /package/dist/docs/assets/{guides_webhooks.md.hFTik3lf.lean.js → guides_webhooks.md.B1EswtUu.lean.js} +0 -0
- /package/dist/docs/assets/{reference_connections.md.C3vNH_DE.lean.js → reference_connections.md.zaEYCLHT.lean.js} +0 -0
- /package/dist/docs/assets/{reference_http-api.md.DBAahtdz.lean.js → reference_http-api.md.Dx_nmDG6.lean.js} +0 -0
- /package/dist/docs/assets/{reference_schedules.md.D7qijxLk.lean.js → reference_schedules.md.w_F2mXB6.lean.js} +0 -0
- /package/dist/docs/assets/{reference_subagents.md.CIRAVcPK.lean.js → reference_subagents.md.zWAMNfi1.lean.js} +0 -0
- /package/dist/docs/assets/{reference_tools.md.DF5kwlt0.lean.js → reference_tools.md.CqgJroI0.lean.js} +0 -0
package/AGENTS.md
CHANGED
|
@@ -177,7 +177,10 @@ agent-serve chat --url http://127.0.0.1:3000/concierge --message "Weather in Par
|
|
|
177
177
|
The Cursor Slack connection is the zero-setup default
|
|
178
178
|
(`slackChannel({ cursorAccount: true, agentName: "…" })`). Sign the host
|
|
179
179
|
in (`agent-serve login` / `CURSOR_API_KEY`), then `@Cursor <agentName> …`
|
|
180
|
-
in Slack; thread replies stay with that agent.
|
|
180
|
+
in Slack; thread replies stay with that agent. `agentName` must be a
|
|
181
|
+
**single token** (no whitespace) — prefer PascalCase (`ApprovalBuddy`);
|
|
182
|
+
multi-word names fail typecheck for string literals and throw at
|
|
183
|
+
construction / serve time. Import from
|
|
181
184
|
`@cursor/july/channels/slack`.
|
|
182
185
|
|
|
183
186
|
Dedicated Socket Mode apps (no public Request URL) live in a second
|
|
@@ -234,7 +237,12 @@ or pinned via `webhookEvents`) as `meta.githubWebhookEvents`. Auth default: with
|
|
|
234
237
|
a secret → `allowAll()` + signature check; without one → `localDevStrict()`,
|
|
235
238
|
except under `serve --dev` which admits unsigned loopback deliveries (so
|
|
236
239
|
`gh webhook forward` and fixtures work with no secret). Outbound GitHub API
|
|
237
|
-
calls
|
|
240
|
+
calls can reuse the signed-in Cursor connection with
|
|
241
|
+
`githubChannel({ cursorAccount: { repos: ["owner/repo"] } })`; this supplies
|
|
242
|
+
events plus a refreshing repo-scoped credential to `ctx.github`,
|
|
243
|
+
`ctx.host.github`, and child `gh` commands in dev and hosted deployments.
|
|
244
|
+
Default `permissions: "pr-write"`; opt up to `"contents-write"` only to push.
|
|
245
|
+
Without `cursorAccount`, calls prefer App installation tokens (`GITHUB_APP_ID` +
|
|
238
246
|
`GITHUB_APP_PRIVATE_KEY` + webhook `installation.id` or
|
|
239
247
|
`GITHUB_APP_INSTALLATION_ID`); serve warmup also exports that token as
|
|
240
248
|
`GH_TOKEN` for tools that shell out to `gh`. For local testing, omit App
|
|
@@ -288,3 +296,17 @@ Fixtures still work for offline replay: `POST` a saved payload with an
|
|
|
288
296
|
Prefer `defineAgent({ local: { cwd } })` pointing outside the monorepo
|
|
289
297
|
(session harnesses land at `<cwd>/<sessionId>`), or a temp `--state-root`.
|
|
290
298
|
- Expect `agent/evals/` to be loaded — evals live at the **project root** `evals/`.
|
|
299
|
+
- Build optional object fields with a conditional empty-object spread.
|
|
300
|
+
Assign the property directly; `undefined` is fine on optional keys.
|
|
301
|
+
|
|
302
|
+
```ts
|
|
303
|
+
// ❌ BAD
|
|
304
|
+
{ ...(x === undefined ? {} : { x }) }
|
|
305
|
+
{ ...(cond && { x }) }
|
|
306
|
+
|
|
307
|
+
// ✅ GOOD
|
|
308
|
+
{ x } // may be undefined
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
Only use a conditional spread when merging a real partial object
|
|
312
|
+
(`...overrides`), not to omit an optional key.
|
package/README.md
CHANGED
|
@@ -927,19 +927,22 @@ Approve/Deny cards and routes Socket Mode `interactive` clicks to
|
|
|
927
927
|
(App-Level Token with `connections:write`).
|
|
928
928
|
|
|
929
929
|
Most demos under `examples/` use the Cursor Slack connection
|
|
930
|
-
(`cursorAccount: true`) with a unique `agentName` —
|
|
931
|
-
`@Cursor
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
`slack-app.ts`) with their own env
|
|
935
|
-
`<PREFIX>_SLACK_APP_TOKEN`, derived
|
|
930
|
+
(`cursorAccount: true`) with a unique single-token `agentName` —
|
|
931
|
+
`@Cursor Benny …`, `@Cursor Bugbot …`, `@Cursor ApprovalBuddy …`, etc.
|
|
932
|
+
Sign the host in, then mention the agent; no per-agent Slack app required
|
|
933
|
+
for chat. Agents that need channel watch or tool approvals keep a Socket
|
|
934
|
+
Mode app in a second channel file (e.g. `slack-app.ts`) with their own env
|
|
935
|
+
prefix (`<PREFIX>_SLACK_BOT_TOKEN` + `<PREFIX>_SLACK_APP_TOKEN`, derived
|
|
936
|
+
from the directory name by `slack init`).
|
|
936
937
|
|
|
937
938
|
| Agent | `@Cursor` name | Optional Socket Mode app |
|
|
938
939
|
| --- | --- | --- |
|
|
939
940
|
| `weather-agent` | Weather | `slack-app.ts` (`WEATHER_AGENT_SLACK_*`, tool approvals) |
|
|
940
|
-
| `slack-agent` |
|
|
941
|
+
| `slack-agent` | SlackAgent | — |
|
|
941
942
|
| `bugbot` | Bugbot | — |
|
|
942
943
|
| `fsd` | FSD | — |
|
|
944
|
+
| `benny` | Benny | `slack-app.ts` (`BENNY_SLACK_*`, channel watch) |
|
|
945
|
+
| `approval-buddy` | ApprovalBuddy | — |
|
|
943
946
|
|
|
944
947
|
PR-oriented demos (`bugbot`, `fsd`) extract a GitHub PR URL / `owner/repo#N`
|
|
945
948
|
from the mention and run the same host path as their HTTP channels.
|
|
@@ -970,7 +973,10 @@ import { defaultGitHubAuth, githubChannel } from "@cursor/july/channels/github";
|
|
|
970
973
|
|
|
971
974
|
export default githubChannel({
|
|
972
975
|
botName: "my-agent", // or GITHUB_APP_SLUG
|
|
973
|
-
|
|
976
|
+
cursorAccount: {
|
|
977
|
+
repos: ["owner/repo"],
|
|
978
|
+
// permissions?: "read" | "pr-write" | "contents-write" (default pr-write)
|
|
979
|
+
},
|
|
974
980
|
onPullRequest: (ctx, pr) =>
|
|
975
981
|
pr.action === "opened" ? { auth: defaultGitHubAuth(ctx) } : null,
|
|
976
982
|
onCheckSuite: (ctx, suite) =>
|
|
@@ -986,13 +992,17 @@ under `serve --dev`, which admits unsigned loopback deliveries so
|
|
|
986
992
|
`{ auth }` to start a model turn as the actor, `{ task }` for host-side work
|
|
987
993
|
(202 ACK, runs past GitHub's ~10s timeout), or `null` to skip.
|
|
988
994
|
|
|
989
|
-
**Testing GitHub agents locally.**
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
`
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
995
|
+
**Testing GitHub agents locally.** `cursorAccount` reuses `agent-serve login`
|
|
996
|
+
for both Cursor SCM events and a refreshing repo-scoped GitHub credential used
|
|
997
|
+
by `ctx.github`, `ctx.host.github`, and child `gh` commands. Default
|
|
998
|
+
`permissions: "pr-write"` covers comments without `contents:write`; opt up to
|
|
999
|
+
`"contents-write"` only when the agent must push. Without `cursorAccount`, API
|
|
1000
|
+
auth prefers GitHub App installation tokens when `GITHUB_APP_ID` /
|
|
1001
|
+
`GITHUB_APP_PRIVATE_KEY` (and an installation id) are set, then falls back to
|
|
1002
|
+
`GITHUB_TOKEN` / `GH_TOKEN` or `gh auth login`. The channel publishes the
|
|
1003
|
+
webhook events it dispatches on (derived from the declared hooks, or pinned
|
|
1004
|
+
via `webhookEvents`), so `agent-serve github …` can forward live
|
|
1005
|
+
deliveries with zero hand-listing — it wraps [`gh webhook
|
|
996
1006
|
forward`](https://docs.github.com/en/webhooks/testing-and-troubleshooting-webhooks/using-the-github-cli-to-forward-webhooks-for-testing):
|
|
997
1007
|
|
|
998
1008
|
```bash
|
package/dist/bin/agent-serve.js
CHANGED
|
@@ -27,6 +27,7 @@ import { formatDiagnostics, projectInfo, resolveAgentMounts, serve, } from "../i
|
|
|
27
27
|
import { registerAuthoredModuleLoaders } from "../internal/authored-loaders.js";
|
|
28
28
|
import { runChat } from "../internal/chat-client.js";
|
|
29
29
|
import { cmdCall, cmdEval, cmdInit, cmdRun, cmdTrajectory, } from "../internal/cli-ax.js";
|
|
30
|
+
import { cmdDeploy, cmdDeploymentStatus, cmdDeployments, cmdRotatePodCredential, cmdRotateToken, cmdSecretsList, cmdSecretsSet, cmdSecretsUnset, cmdStop, } from "../internal/cli-deploy.js";
|
|
30
31
|
import { CLI_COMMAND_NAME as CLI } from "../internal/distribution.js";
|
|
31
32
|
import { runSession } from "../internal/run-client.js";
|
|
32
33
|
import { formatTrajectoryText } from "../internal/trajectory.js";
|
|
@@ -54,6 +55,17 @@ Usage:
|
|
|
54
55
|
${CLI} login [--api-key <key>] [--key-name <name>]
|
|
55
56
|
${CLI} logout
|
|
56
57
|
${CLI} whoami [--json]
|
|
58
|
+
${CLI} deploy [--dir <path>] [--slug <slug>] [--team <id>] [--json]
|
|
59
|
+
[--no-wait] [--repo <url>] [--ref <ref>]
|
|
60
|
+
[--path <agentPath>] [--cursor-events-repo <owner/name>]...
|
|
61
|
+
[--allow-domain <domain>]...
|
|
62
|
+
${CLI} deployments [--team <id>] [--json]
|
|
63
|
+
${CLI} deployment <slug> [--team <id>] [--json]
|
|
64
|
+
${CLI} stop <slug> [--team <id>] [--json] [--no-wait]
|
|
65
|
+
${CLI} rotate-token <slug> [--team <id>]
|
|
66
|
+
${CLI} rotate-pod-credential <slug> [--team <id>]
|
|
67
|
+
${CLI} secrets set <slug> NAME[=VALUE]... | list <slug> | unset <slug> NAME
|
|
68
|
+
[--team <id>] [--json]
|
|
57
69
|
${CLI} slack <subcommand> …
|
|
58
70
|
${CLI} github <subcommand> …
|
|
59
71
|
|
|
@@ -80,6 +92,20 @@ Commands:
|
|
|
80
92
|
inference, cloud runtime, and cursorAccount MCP connections.
|
|
81
93
|
logout Remove the stored Cursor credentials.
|
|
82
94
|
whoami Show which Cursor account powers this host (and why).
|
|
95
|
+
deploy Deploy onto Cursor's managed agent-serve hosting, then wait for
|
|
96
|
+
the engine to come up. First deploy of a slug prints the alias
|
|
97
|
+
token exactly once — save it.
|
|
98
|
+
deployments List the team's deployments (slug, status, generation, kind).
|
|
99
|
+
deployment Show one deployment in full (status, lastError, engine info).
|
|
100
|
+
stop Stop a deployment and wait until it reports stopped.
|
|
101
|
+
rotate-token Mint a new alias token for a deployment (shown once); the old
|
|
102
|
+
token stops working immediately.
|
|
103
|
+
rotate-pod-credential
|
|
104
|
+
Rotate a deployment's pod credential (prints the masked key);
|
|
105
|
+
the running pod keeps the old one until the next deploy.
|
|
106
|
+
secrets Manage deployment secrets: set (upsert by name; NAMEs without
|
|
107
|
+
=VALUE are prompted for with hidden input, or read from piped
|
|
108
|
+
stdin), list (names + createdAt; never values), unset.
|
|
83
109
|
slack Slack channel pack: init, manifests, doctor (see slack help).
|
|
84
110
|
github GitHub webhook pack: forward live deliveries, events, doctor
|
|
85
111
|
(wraps \`gh webhook forward\`; see github help).
|
|
@@ -114,6 +140,10 @@ Options:
|
|
|
114
140
|
connections (defineConnection({ agent })) on cloud-runtime
|
|
115
141
|
turns; local turns always use loopback.
|
|
116
142
|
--no-schedules Disable the cron runner outside dev mode.
|
|
143
|
+
--team deploy/deployments/deployment/stop/rotate-token: Cursor
|
|
144
|
+
team id. Defaults to the account's team when it has one.
|
|
145
|
+
--no-wait deploy/stop: return right after the request is accepted
|
|
146
|
+
instead of polling until a terminal status.
|
|
117
147
|
--no-playground Disable the bundled web playground at /playground (also skips
|
|
118
148
|
auto-build / HMR).
|
|
119
149
|
--no-docs Disable the documentation site at /docs (also skips its
|
|
@@ -144,6 +174,15 @@ Options:
|
|
|
144
174
|
--repo serve --cursor-events: repo to subscribe to (repeatable).
|
|
145
175
|
github forward: owner/repo to forward from (inferred from
|
|
146
176
|
the git remote when omitted; last wins).
|
|
177
|
+
deploy: https git repo URL the control plane builds from.
|
|
178
|
+
--ref deploy: git ref to build (defaults to the repo's default
|
|
179
|
+
branch server-side).
|
|
180
|
+
--path deploy: agent directory relative to the repo root.
|
|
181
|
+
--cursor-events-repo deploy: repo (owner/name) whose SCM events the
|
|
182
|
+
deployed engine pulls (repeatable).
|
|
183
|
+
--allow-domain deploy: egress domain the engine pod may reach
|
|
184
|
+
(repeatable; unioned with hosting.egressDomains from the
|
|
185
|
+
agent manifest). Repo-backed deploys only.
|
|
147
186
|
--org github forward: organization login (org-level hooks).
|
|
148
187
|
--channel github: select one channel id when several are declared.
|
|
149
188
|
--secret github forward: webhook signing secret (defaults to
|
|
@@ -159,8 +198,8 @@ Options:
|
|
|
159
198
|
`;
|
|
160
199
|
function main(argv) {
|
|
161
200
|
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
var _a, _b, _c, _d, _e, _f;
|
|
163
|
-
var
|
|
201
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
202
|
+
var _k, _l, _m, _o, _p, _q, _r, _s;
|
|
164
203
|
const [command, ...rest] = argv;
|
|
165
204
|
if (command === undefined ||
|
|
166
205
|
command === "help" ||
|
|
@@ -226,9 +265,15 @@ function main(argv) {
|
|
|
226
265
|
comment: { type: "string" },
|
|
227
266
|
"dry-run": { type: "boolean", default: false },
|
|
228
267
|
out: { type: "string" },
|
|
268
|
+
team: { type: "string" },
|
|
269
|
+
"no-wait": { type: "boolean", default: false },
|
|
270
|
+
ref: { type: "string" },
|
|
271
|
+
path: { type: "string" },
|
|
272
|
+
"cursor-events-repo": { type: "string", multiple: true },
|
|
273
|
+
"allow-domain": { type: "string", multiple: true },
|
|
229
274
|
},
|
|
230
275
|
});
|
|
231
|
-
const dir = (
|
|
276
|
+
const dir = (_k = values.dir) !== null && _k !== void 0 ? _k : ".";
|
|
232
277
|
switch (command) {
|
|
233
278
|
case "slack": {
|
|
234
279
|
const { cmdSlack } = yield import("../internal/cli-slack.js");
|
|
@@ -301,12 +346,51 @@ function main(argv) {
|
|
|
301
346
|
const { cmdWhoami } = yield import("../internal/cli-cursor.js");
|
|
302
347
|
return cmdWhoami({ json: values.json });
|
|
303
348
|
}
|
|
349
|
+
case "deploy": {
|
|
350
|
+
// `--repo` is repeatable for `serve --cursor-events`; deploy targets a
|
|
351
|
+
// single source repo, so the last one wins.
|
|
352
|
+
const repo = (_b = values.repo) === null || _b === void 0 ? void 0 : _b.at(-1);
|
|
353
|
+
return cmdDeploy(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, deployOptionsFromValues(values)), { dir }), (values.slug === undefined ? {} : { slug: values.slug })), (repo === undefined ? {} : { repo })), (values.ref === undefined ? {} : { ref: values.ref })), (values.path === undefined ? {} : { path: values.path })), (values["cursor-events-repo"] === undefined
|
|
354
|
+
? {}
|
|
355
|
+
: { cursorEventsRepos: values["cursor-events-repo"] })), (values["allow-domain"] === undefined
|
|
356
|
+
? {}
|
|
357
|
+
: { allowDomains: values["allow-domain"] })));
|
|
358
|
+
}
|
|
359
|
+
case "deployments": {
|
|
360
|
+
return cmdDeployments(deployOptionsFromValues(values));
|
|
361
|
+
}
|
|
362
|
+
case "deployment": {
|
|
363
|
+
return cmdDeploymentStatus(positionals[0], deployOptionsFromValues(values));
|
|
364
|
+
}
|
|
365
|
+
case "stop": {
|
|
366
|
+
return cmdStop(positionals[0], deployOptionsFromValues(values));
|
|
367
|
+
}
|
|
368
|
+
case "rotate-token": {
|
|
369
|
+
return cmdRotateToken(positionals[0], deployOptionsFromValues(values));
|
|
370
|
+
}
|
|
371
|
+
case "rotate-pod-credential": {
|
|
372
|
+
return cmdRotatePodCredential(positionals[0], deployOptionsFromValues(values));
|
|
373
|
+
}
|
|
374
|
+
case "secrets": {
|
|
375
|
+
const base = deployOptionsFromValues(values);
|
|
376
|
+
switch (positionals[0]) {
|
|
377
|
+
case "set":
|
|
378
|
+
return cmdSecretsSet(positionals[1], positionals.slice(2), base);
|
|
379
|
+
case "list":
|
|
380
|
+
return cmdSecretsList(positionals[1], base);
|
|
381
|
+
case "unset":
|
|
382
|
+
return cmdSecretsUnset(positionals[1], positionals[2], base);
|
|
383
|
+
default:
|
|
384
|
+
process.stderr.write(`Usage: ${CLI} secrets <set|list|unset> <slug> ... [--team <id>] [--json]\n`);
|
|
385
|
+
return 1;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
304
388
|
case "run": {
|
|
305
389
|
const messages = yield loadMessages(values.message, values["messages-file"]);
|
|
306
390
|
return cmdRun(axFromOptions({
|
|
307
391
|
dir,
|
|
308
392
|
messages,
|
|
309
|
-
sessionId: (
|
|
393
|
+
sessionId: (_l = values["session-id"]) !== null && _l !== void 0 ? _l : values.session,
|
|
310
394
|
continuationToken: values["continuation-token"],
|
|
311
395
|
events: values["no-events"]
|
|
312
396
|
? false
|
|
@@ -327,7 +411,7 @@ function main(argv) {
|
|
|
327
411
|
dir,
|
|
328
412
|
toolName: positionals[0],
|
|
329
413
|
toolInput: values.input,
|
|
330
|
-
sessionId: (
|
|
414
|
+
sessionId: (_m = values["session-id"]) !== null && _m !== void 0 ? _m : values.session,
|
|
331
415
|
url: values.url,
|
|
332
416
|
slug: values.slug,
|
|
333
417
|
bearerToken: values["bearer-token"],
|
|
@@ -364,13 +448,13 @@ function main(argv) {
|
|
|
364
448
|
case "chat": {
|
|
365
449
|
if (values.json) {
|
|
366
450
|
return chatJson({
|
|
367
|
-
baseUrl: (
|
|
368
|
-
message: (
|
|
451
|
+
baseUrl: (_o = values.url) !== null && _o !== void 0 ? _o : "http://127.0.0.1:3000",
|
|
452
|
+
message: (_c = values.message) === null || _c === void 0 ? void 0 : _c[0],
|
|
369
453
|
bearerToken: values["bearer-token"],
|
|
370
454
|
text: values.text,
|
|
371
455
|
});
|
|
372
456
|
}
|
|
373
|
-
yield runChat(Object.assign(Object.assign(Object.assign({ baseUrl: (
|
|
457
|
+
yield runChat(Object.assign(Object.assign(Object.assign({ baseUrl: (_p = values.url) !== null && _p !== void 0 ? _p : "http://127.0.0.1:3000" }, (((_d = values.message) === null || _d === void 0 ? void 0 : _d[0]) === undefined
|
|
374
458
|
? {}
|
|
375
459
|
: { message: values.message[0] })), (values["bearer-token"] === undefined
|
|
376
460
|
? {}
|
|
@@ -394,7 +478,7 @@ function main(argv) {
|
|
|
394
478
|
case "info": {
|
|
395
479
|
const mounts = yield loadMounts(dir);
|
|
396
480
|
if (values.json) {
|
|
397
|
-
const payload = mounts.length === 1 && ((
|
|
481
|
+
const payload = mounts.length === 1 && ((_e = mounts[0]) === null || _e === void 0 ? void 0 : _e.slug) === ""
|
|
398
482
|
? projectInfo(mounts[0].project)
|
|
399
483
|
: {
|
|
400
484
|
agents: mounts.map(({ slug, project }) => (Object.assign({ slug }, projectInfo(project)))),
|
|
@@ -402,7 +486,7 @@ function main(argv) {
|
|
|
402
486
|
process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
|
|
403
487
|
return 0;
|
|
404
488
|
}
|
|
405
|
-
if (mounts.length > 1 || ((
|
|
489
|
+
if (mounts.length > 1 || ((_f = mounts[0]) === null || _f === void 0 ? void 0 : _f.slug) !== "") {
|
|
406
490
|
process.stdout.write(`${mounts.length} agents under ${dir}:\n\n`);
|
|
407
491
|
for (const { slug, project } of mounts) {
|
|
408
492
|
const info = projectInfo(project);
|
|
@@ -411,7 +495,7 @@ function main(argv) {
|
|
|
411
495
|
const anyError = mounts.some((m) => m.project.diagnostics.some((d) => d.severity === "error"));
|
|
412
496
|
return anyError ? 1 : 0;
|
|
413
497
|
}
|
|
414
|
-
const project = (
|
|
498
|
+
const project = (_g = mounts[0]) === null || _g === void 0 ? void 0 : _g.project;
|
|
415
499
|
const info = projectInfo(project);
|
|
416
500
|
const lines = [];
|
|
417
501
|
lines.push(`agent: ${info.name}`);
|
|
@@ -428,6 +512,8 @@ function main(argv) {
|
|
|
428
512
|
"(events only)"}`)));
|
|
429
513
|
lines.push(section("schedules", info.schedules.map((s) => `${s.name} (${s.cron}, ${s.kind})`)));
|
|
430
514
|
lines.push(section("hooks", info.hooks));
|
|
515
|
+
lines.push(section("hosting egress domains", (_q = (_h = info.hosting) === null || _h === void 0 ? void 0 : _h.egressDomains) !== null && _q !== void 0 ? _q : []));
|
|
516
|
+
lines.push(section("hosting secret names", (_r = (_j = info.hosting) === null || _j === void 0 ? void 0 : _j.secretNames) !== null && _r !== void 0 ? _r : []));
|
|
431
517
|
if (info.diagnostics.length > 0) {
|
|
432
518
|
lines.push(`\ndiagnostics:\n${formatDiagnostics(info.diagnostics)}`);
|
|
433
519
|
}
|
|
@@ -459,7 +545,7 @@ function main(argv) {
|
|
|
459
545
|
: { authToken: values["bearer-token"] })), (values["allow-anonymous"] ? { allowAnonymous: true } : {})), (values["no-schedules"] ? { schedules: false } : {})), (values["no-playground"] ? { playground: false } : {})), (values["no-docs"] ? { docs: false } : {})), (values["public-url"] === undefined
|
|
460
546
|
? {}
|
|
461
547
|
: { publicUrl: values["public-url"] })), (values["cursor-events"]
|
|
462
|
-
? { cursorEvents: { repos: (
|
|
548
|
+
? { cursorEvents: { repos: (_s = values.repo) !== null && _s !== void 0 ? _s : [] } }
|
|
463
549
|
: {}));
|
|
464
550
|
const enterToRestart = process.stdin.isTTY === true;
|
|
465
551
|
const bannerOpts = {
|
|
@@ -529,6 +615,9 @@ function main(argv) {
|
|
|
529
615
|
}
|
|
530
616
|
});
|
|
531
617
|
}
|
|
618
|
+
function deployOptionsFromValues(values) {
|
|
619
|
+
return Object.assign(Object.assign(Object.assign({}, (values.team === undefined ? {} : { team: values.team })), { json: values.json === true, noWait: values["no-wait"] === true }), (values["api-key"] === undefined ? {} : { apiKey: values["api-key"] }));
|
|
620
|
+
}
|
|
532
621
|
function axFromOptions(partial) {
|
|
533
622
|
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ dir: partial.dir }, (partial.cwd === undefined ? {} : { cwd: partial.cwd })), (partial.slug === undefined ? {} : { slug: partial.slug })), (partial.bearerToken === undefined
|
|
534
623
|
? {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/channels/github/api.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,O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,mBAAmB,CAAC,CAiB9B;AAED,6DAA6D;AAC7D,wBAAsB,8BAA8B,CAClD,KAAK,EAAE,mBAAmB,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,GACA,OAAO,CAAC,mBAAmB,CAAC,CAkB9B;AAED,uDAAuD;AACvD,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,mBAAmB,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,qBAAqB,CAAC;IAC/B,OAAO,EAAE,eAAe,GAAG,6BAA6B,CAAC;CAC1D,GACA,OAAO,CAAC,iBAAiB,CAAC,CA+B5B;AAED,sDAAsD;AACtD,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,mBAAmB,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACA,OAAO,CAAC,iBAAiB,CAAC,CA0B5B"}
|
|
@@ -17,6 +17,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
17
17
|
import { createAppAuth } from "@octokit/auth-app";
|
|
18
18
|
import { Octokit } from "@octokit/rest";
|
|
19
19
|
import { hasGitHubAppCredentials, resolveCredentialValue, resolveGitHubAccessToken, resolveGitHubAppId, resolveGitHubInstallationId, resolveGitHubPrivateKey, } from "./auth.js";
|
|
20
|
+
import { isCursorAccountGithubTokenResolver, } from "./cursor-account.js";
|
|
20
21
|
export class GitHubApiError extends Error {
|
|
21
22
|
constructor(input) {
|
|
22
23
|
super(`GitHub ${input.method} ${input.path} failed with HTTP ${input.status}.`);
|
|
@@ -39,42 +40,58 @@ export function createGitHubOctokit(input) {
|
|
|
39
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
41
|
var _a, _b, _c, _d, _e, _f;
|
|
41
42
|
var _g;
|
|
42
|
-
const
|
|
43
|
-
const
|
|
43
|
+
const transport = githubOctokitTransport(input.api);
|
|
44
|
+
const dynamicToken = isCursorAccountGithubTokenResolver((_a = input.credentials) === null || _a === void 0 ? void 0 : _a.token)
|
|
45
|
+
? input.credentials.token
|
|
46
|
+
: isCursorAccountGithubTokenResolver((_b = input.credentials) === null || _b === void 0 ? void 0 : _b.installationToken)
|
|
47
|
+
? input.credentials.installationToken
|
|
48
|
+
: undefined;
|
|
49
|
+
if (dynamicToken !== undefined) {
|
|
50
|
+
const octokit = new Octokit(transport);
|
|
51
|
+
octokit.hook.before("request", (request) => __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const token = yield resolveCredentialValue(dynamicToken);
|
|
53
|
+
if (token === undefined) {
|
|
54
|
+
throw new Error("githubChannel: dynamic GitHub token is unavailable.");
|
|
55
|
+
}
|
|
56
|
+
request.headers.authorization = `Bearer ${token}`;
|
|
57
|
+
}));
|
|
58
|
+
return octokit;
|
|
59
|
+
}
|
|
44
60
|
const explicit = (_g = (yield resolveCredentialValue((_c = input.credentials) === null || _c === void 0 ? void 0 : _c.token))) !== null && _g !== void 0 ? _g : (yield resolveCredentialValue((_d = input.credentials) === null || _d === void 0 ? void 0 : _d.installationToken));
|
|
45
61
|
if (explicit !== undefined) {
|
|
46
|
-
return new Octokit(Object.assign(Object.assign({
|
|
62
|
+
return new Octokit(Object.assign(Object.assign({}, transport), { auth: explicit }));
|
|
47
63
|
}
|
|
48
64
|
const installationId = yield resolveGitHubInstallationId(input.installationId);
|
|
49
65
|
if (installationId !== undefined &&
|
|
50
66
|
(yield hasGitHubAppCredentials(input.credentials))) {
|
|
51
67
|
const appId = yield resolveGitHubAppId((_e = input.credentials) === null || _e === void 0 ? void 0 : _e.appId);
|
|
52
68
|
const privateKey = yield resolveGitHubPrivateKey((_f = input.credentials) === null || _f === void 0 ? void 0 : _f.privateKey);
|
|
53
|
-
return new Octokit(Object.assign(Object.assign({ authStrategy: createAppAuth, auth: {
|
|
69
|
+
return new Octokit(Object.assign(Object.assign({}, transport), { authStrategy: createAppAuth, auth: {
|
|
54
70
|
appId,
|
|
55
71
|
privateKey,
|
|
56
72
|
installationId,
|
|
57
|
-
} }
|
|
73
|
+
} }));
|
|
58
74
|
}
|
|
59
75
|
// Local testing: ambient PAT / `gh auth token` when App creds are unset.
|
|
60
|
-
|
|
61
|
-
return new Octokit(Object.assign(Object.assign({ auth: token }, (baseUrl === undefined ? {} : { baseUrl })), (requestOptions === undefined ? {} : { request: requestOptions })));
|
|
76
|
+
return new Octokit(Object.assign(Object.assign({}, transport), { auth: yield resolveGitHubAccessToken(input) }));
|
|
62
77
|
});
|
|
63
78
|
}
|
|
79
|
+
/** Shared `baseUrl` / custom `fetch` for every Octokit constructed here. */
|
|
80
|
+
function githubOctokitTransport(api) {
|
|
81
|
+
return {
|
|
82
|
+
baseUrl: api === null || api === void 0 ? void 0 : api.apiBaseUrl,
|
|
83
|
+
request: (api === null || api === void 0 ? void 0 : api.fetch) === undefined ? undefined : { fetch: api.fetch },
|
|
84
|
+
};
|
|
85
|
+
}
|
|
64
86
|
/**
|
|
65
87
|
* Call a GitHub REST path with channel auth. Prefer typed Octokit methods via
|
|
66
88
|
* {@link createGitHubOctokit} / `ctx.github.getOctokit()` when possible.
|
|
67
89
|
*/
|
|
68
90
|
export function callGitHubApi(input) {
|
|
69
91
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
var _a
|
|
92
|
+
var _a;
|
|
71
93
|
if (((_a = input.options) === null || _a === void 0 ? void 0 : _a.auth) === false) {
|
|
72
|
-
|
|
73
|
-
? {}
|
|
74
|
-
: { baseUrl: input.api.apiBaseUrl })), (((_c = input.api) === null || _c === void 0 ? void 0 : _c.fetch) === undefined
|
|
75
|
-
? {}
|
|
76
|
-
: { request: { fetch: input.api.fetch } })));
|
|
77
|
-
return requestWithOctokit(octokit, input);
|
|
94
|
+
return requestWithOctokit(new Octokit(githubOctokitTransport(input.api)), input);
|
|
78
95
|
}
|
|
79
96
|
const octokit = yield createGitHubOctokit({
|
|
80
97
|
api: input.api,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor-account mode for GitHub channels.
|
|
3
|
+
*
|
|
4
|
+
* The channel declares the intent at definition time. The serve host binds
|
|
5
|
+
* this placeholder to its signed-in Cursor account after it resolves the
|
|
6
|
+
* repository scope into private runtime metadata (never by rewriting the
|
|
7
|
+
* authored `cursorAccount` options object).
|
|
8
|
+
*/
|
|
9
|
+
import type { GitHubChannelOptions } from "./types.js";
|
|
10
|
+
export declare const CURSOR_GITHUB_MAX_REPOS = 20;
|
|
11
|
+
/** Least → most privilege. Host mints one lease at the max requested tier. */
|
|
12
|
+
export declare const CURSOR_GITHUB_PERMISSIONS: readonly ["read", "pr-write", "contents-write"];
|
|
13
|
+
export type CursorGithubPermissions = (typeof CURSOR_GITHUB_PERMISSIONS)[number];
|
|
14
|
+
export interface CursorGithubRepoScope {
|
|
15
|
+
owner: string;
|
|
16
|
+
repos: readonly string[];
|
|
17
|
+
permissions: CursorGithubPermissions;
|
|
18
|
+
}
|
|
19
|
+
export type CursorAccountGithubTokenResolver = () => Promise<string>;
|
|
20
|
+
export interface PendingCursorGithubCredentials {
|
|
21
|
+
bind(getToken: () => Promise<string>): void;
|
|
22
|
+
getToken(): Promise<string>;
|
|
23
|
+
}
|
|
24
|
+
export interface GithubCursorAccountRuntime {
|
|
25
|
+
/** Authored channel options (not rewritten). */
|
|
26
|
+
options: GitHubChannelOptions;
|
|
27
|
+
credentials: PendingCursorGithubCredentials;
|
|
28
|
+
/**
|
|
29
|
+
* Normalized repo + permissions scope when `cursorAccount` is an object.
|
|
30
|
+
* Absent for `cursorAccount: true` (scope comes from serve `--repo`).
|
|
31
|
+
*/
|
|
32
|
+
scope: CursorGithubRepoScope | undefined;
|
|
33
|
+
}
|
|
34
|
+
export declare function parseCursorGithubPermissions(value: unknown, fallback?: CursorGithubPermissions): CursorGithubPermissions;
|
|
35
|
+
export declare function parseCursorGithubRepoScope(values: readonly string[], permissions?: CursorGithubPermissions): CursorGithubRepoScope;
|
|
36
|
+
/** One host credential: the most privileged requested tier wins. */
|
|
37
|
+
export declare function resolveCursorGithubPermissions(values: readonly CursorGithubPermissions[]): CursorGithubPermissions;
|
|
38
|
+
export declare function createCursorAccountGithubTokenResolver(getToken: () => Promise<string>): CursorAccountGithubTokenResolver;
|
|
39
|
+
export declare function isCursorAccountGithubTokenResolver(value: unknown): value is CursorAccountGithubTokenResolver;
|
|
40
|
+
export declare function createPendingCursorGithubCredentials(): PendingCursorGithubCredentials;
|
|
41
|
+
export declare function registerGithubCursorAccountRuntime(definition: object, runtime: GithubCursorAccountRuntime): void;
|
|
42
|
+
export declare function getGithubCursorAccountRuntime(definition: object): GithubCursorAccountRuntime | undefined;
|
|
43
|
+
//# sourceMappingURL=cursor-account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor-account.d.ts","sourceRoot":"","sources":["../../../src/channels/github/cursor-account.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAI1C,8EAA8E;AAC9E,eAAO,MAAM,yBAAyB,YACpC,MAAM,EACN,UAAU,EACV,gBAAgB,CACR,CAAC;AAEX,MAAM,MAAM,uBAAuB,GACjC,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7C,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,WAAW,EAAE,uBAAuB,CAAC;CACtC;AAED,MAAM,MAAM,gCAAgC,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;AAErE,MAAM,WAAW,8BAA8B;IAC7C,IAAI,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAC5C,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7B;AAED,MAAM,WAAW,0BAA0B;IACzC,gDAAgD;IAChD,OAAO,EAAE,oBAAoB,CAAC;IAC9B,WAAW,EAAE,8BAA8B,CAAC;IAC5C;;;OAGG;IACH,KAAK,EAAE,qBAAqB,GAAG,SAAS,CAAC;CAC1C;AAID,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,OAAO,EACd,QAAQ,GAAE,uBAAoC,GAC7C,uBAAuB,CAUzB;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,WAAW,GAAE,uBAAoC,GAChD,qBAAqB,CAmCvB;AAED,oEAAoE;AACpE,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,SAAS,uBAAuB,EAAE,GACzC,uBAAuB,CAWzB;AAED,wBAAgB,sCAAsC,CACpD,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,GAC9B,gCAAgC,CAIlC;AAED,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,gCAAgC,CAE3C;AAED,wBAAgB,oCAAoC,IAAI,8BAA8B,CAerF;AAED,wBAAgB,kCAAkC,CAChD,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,0BAA0B,GAClC,IAAI,CAEN;AAED,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,MAAM,GACjB,0BAA0B,GAAG,SAAS,CAExC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor-account mode for GitHub channels.
|
|
3
|
+
*
|
|
4
|
+
* The channel declares the intent at definition time. The serve host binds
|
|
5
|
+
* this placeholder to its signed-in Cursor account after it resolves the
|
|
6
|
+
* repository scope into private runtime metadata (never by rewriting the
|
|
7
|
+
* authored `cursorAccount` options object).
|
|
8
|
+
*/
|
|
9
|
+
export const CURSOR_GITHUB_MAX_REPOS = 20;
|
|
10
|
+
const CURSOR_GITHUB_REPO_PATTERN = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
|
|
11
|
+
const cursorAccountTokenResolvers = new WeakSet();
|
|
12
|
+
/** Least → most privilege. Host mints one lease at the max requested tier. */
|
|
13
|
+
export const CURSOR_GITHUB_PERMISSIONS = [
|
|
14
|
+
"read",
|
|
15
|
+
"pr-write",
|
|
16
|
+
"contents-write",
|
|
17
|
+
];
|
|
18
|
+
const runtimeByDefinition = new WeakMap();
|
|
19
|
+
export function parseCursorGithubPermissions(value, fallback = "pr-write") {
|
|
20
|
+
if (value === undefined) {
|
|
21
|
+
return fallback;
|
|
22
|
+
}
|
|
23
|
+
if (value === "read" || value === "pr-write" || value === "contents-write") {
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
throw new Error('Cursor account GitHub permissions must be "read", "pr-write", or "contents-write".');
|
|
27
|
+
}
|
|
28
|
+
export function parseCursorGithubRepoScope(values, permissions = "pr-write") {
|
|
29
|
+
var _a;
|
|
30
|
+
const repos = [
|
|
31
|
+
...new Set(values.map((repo) => repo.trim().toLowerCase()).filter(Boolean)),
|
|
32
|
+
];
|
|
33
|
+
if (repos.length === 0) {
|
|
34
|
+
throw new Error("Cursor account GitHub credentials require at least one repository.");
|
|
35
|
+
}
|
|
36
|
+
if (repos.length > CURSOR_GITHUB_MAX_REPOS) {
|
|
37
|
+
throw new Error(`Cursor account GitHub credentials support at most ${CURSOR_GITHUB_MAX_REPOS} repositories.`);
|
|
38
|
+
}
|
|
39
|
+
for (const repo of repos) {
|
|
40
|
+
if (!CURSOR_GITHUB_REPO_PATTERN.test(repo) || repo.includes("..")) {
|
|
41
|
+
throw new Error(`Invalid Cursor account GitHub repository "${repo}"; expected owner/repo.`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const owner = (_a = repos[0]) === null || _a === void 0 ? void 0 : _a.split("/", 1)[0];
|
|
45
|
+
if (owner === undefined) {
|
|
46
|
+
throw new Error("Cursor account GitHub repository owner is missing.");
|
|
47
|
+
}
|
|
48
|
+
if (repos.some((repo) => repo.split("/", 1)[0] !== owner)) {
|
|
49
|
+
throw new Error("Cursor account GitHub repositories must share one owner for a single installation token.");
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
owner,
|
|
53
|
+
repos,
|
|
54
|
+
permissions: parseCursorGithubPermissions(permissions),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** One host credential: the most privileged requested tier wins. */
|
|
58
|
+
export function resolveCursorGithubPermissions(values) {
|
|
59
|
+
let max = "read";
|
|
60
|
+
for (const value of values) {
|
|
61
|
+
if (CURSOR_GITHUB_PERMISSIONS.indexOf(value) >
|
|
62
|
+
CURSOR_GITHUB_PERMISSIONS.indexOf(max)) {
|
|
63
|
+
max = value;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return values.length === 0 ? "pr-write" : max;
|
|
67
|
+
}
|
|
68
|
+
export function createCursorAccountGithubTokenResolver(getToken) {
|
|
69
|
+
const resolver = () => getToken();
|
|
70
|
+
cursorAccountTokenResolvers.add(resolver);
|
|
71
|
+
return resolver;
|
|
72
|
+
}
|
|
73
|
+
export function isCursorAccountGithubTokenResolver(value) {
|
|
74
|
+
return typeof value === "function" && cursorAccountTokenResolvers.has(value);
|
|
75
|
+
}
|
|
76
|
+
export function createPendingCursorGithubCredentials() {
|
|
77
|
+
let getBoundToken;
|
|
78
|
+
return {
|
|
79
|
+
bind(getToken) {
|
|
80
|
+
getBoundToken = getToken;
|
|
81
|
+
},
|
|
82
|
+
getToken() {
|
|
83
|
+
if (getBoundToken === undefined) {
|
|
84
|
+
throw new Error("githubChannel({ cursorAccount: true }) has not been bound to a signed-in Cursor host.");
|
|
85
|
+
}
|
|
86
|
+
return getBoundToken();
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export function registerGithubCursorAccountRuntime(definition, runtime) {
|
|
91
|
+
runtimeByDefinition.set(definition, runtime);
|
|
92
|
+
}
|
|
93
|
+
export function getGithubCursorAccountRuntime(definition) {
|
|
94
|
+
return runtimeByDefinition.get(definition);
|
|
95
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-channel.d.ts","sourceRoot":"","sources":["../../../src/channels/github/github-channel.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAEV,WAAW,EACX,iBAAiB,EAEjB,kBAAkB,EAGnB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"github-channel.d.ts","sourceRoot":"","sources":["../../../src/channels/github/github-channel.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAEV,WAAW,EACX,iBAAiB,EAEjB,kBAAkB,EAGnB,MAAM,gBAAgB,CAAC;AAgBxB,OAAO,EAEL,KAAK,kBAAkB,EAExB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EACV,oBAAoB,EAKpB,aAAa,EAEb,qBAAqB,EAErB,kBAAkB,EAGlB,sBAAsB,EAMtB,kBAAkB,EAClB,UAAU,EAEX,MAAM,YAAY,CAAC;AAEpB;;;;GAIG;AACH,KAAK,mBAAmB,GAAG,IAAI,CAC7B,kBAAkB,EAClB,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAC7B,CAAC;AAoEF;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,mBAAmB,GAAG,WAAW,CA2BvE;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,mBAAmB,GAAG,MAAM,CAGtE;AAED,wDAAwD;AACxD,wBAAgB,gCAAgC,CAC9C,GAAG,EAAE,mBAAmB,GACvB,MAAM,CAER;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,GAAG,MAAM,CAEnE;AAED,qDAAqD;AACrD,wBAAgB,6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