@dynamicagents/plugins 0.11.1 → 0.13.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 (134) hide show
  1. package/README.md +59 -79
  2. package/dist/browser/index.d.ts +0 -2
  3. package/dist/browser/index.js +21 -27
  4. package/dist/claude-code/cards.d.ts +53 -0
  5. package/dist/claude-code/cards.js +272 -0
  6. package/dist/claude-code/config.d.ts +73 -31
  7. package/dist/claude-code/config.js +0 -2
  8. package/dist/claude-code/credentials.d.ts +21 -9
  9. package/dist/claude-code/credentials.js +43 -9
  10. package/dist/claude-code/egress.d.ts +15 -14
  11. package/dist/claude-code/egress.js +51 -14
  12. package/dist/claude-code/events.d.ts +153 -9
  13. package/dist/claude-code/events.js +289 -58
  14. package/dist/claude-code/github.d.ts +39 -0
  15. package/dist/claude-code/github.js +82 -0
  16. package/dist/claude-code/index.d.ts +24 -80
  17. package/dist/claude-code/index.js +19 -234
  18. package/dist/claude-code/model.d.ts +152 -0
  19. package/dist/claude-code/model.js +342 -0
  20. package/dist/claude-code/run.d.ts +283 -92
  21. package/dist/claude-code/run.js +620 -114
  22. package/dist/claude-code/session.d.ts +131 -0
  23. package/dist/claude-code/session.js +285 -0
  24. package/dist/claude-code/spec.d.ts +46 -0
  25. package/dist/claude-code/spec.js +83 -0
  26. package/dist/claude-code/verified.d.ts +15 -0
  27. package/dist/claude-code/verified.js +15 -0
  28. package/dist/computer/context.d.ts +19 -0
  29. package/dist/computer/context.js +222 -0
  30. package/dist/computer/file-lock.d.ts +5 -0
  31. package/dist/computer/file-lock.js +40 -0
  32. package/dist/computer/gate.d.ts +12 -12
  33. package/dist/computer/gate.js +12 -12
  34. package/dist/computer/index.d.ts +57 -255
  35. package/dist/computer/index.js +98 -1039
  36. package/dist/computer/paths.d.ts +47 -22
  37. package/dist/computer/paths.js +64 -49
  38. package/dist/computer/proxy.d.ts +45 -0
  39. package/dist/computer/proxy.js +234 -0
  40. package/dist/computer/render.d.ts +27 -38
  41. package/dist/computer/render.js +32 -65
  42. package/dist/computer/tools-exec.d.ts +3 -0
  43. package/dist/computer/tools-exec.js +268 -0
  44. package/dist/computer/tools-file.d.ts +12 -0
  45. package/dist/computer/tools-file.js +64 -0
  46. package/dist/computer/tools-grep.d.ts +3 -0
  47. package/dist/computer/tools-grep.js +129 -0
  48. package/dist/repo/checkout.d.ts +35 -6
  49. package/dist/repo/checkout.js +64 -6
  50. package/dist/repo/context.d.ts +135 -0
  51. package/dist/repo/context.js +582 -0
  52. package/dist/repo/index.d.ts +79 -57
  53. package/dist/repo/index.js +118 -1112
  54. package/dist/repo/tools-checks.d.ts +3 -0
  55. package/dist/repo/tools-checks.js +112 -0
  56. package/dist/repo/tools-clone.d.ts +4 -0
  57. package/dist/repo/tools-clone.js +192 -0
  58. package/dist/repo/tools-pr.d.ts +14 -0
  59. package/dist/repo/tools-pr.js +196 -0
  60. package/dist/repo/tools-review.d.ts +12 -0
  61. package/dist/repo/tools-review.js +393 -0
  62. package/dist/repo/tools-worktree.d.ts +4 -0
  63. package/dist/repo/tools-worktree.js +305 -0
  64. package/dist/repo/tools-worktrees.d.ts +12 -0
  65. package/dist/repo/tools-worktrees.js +48 -0
  66. package/dist/repo/url.d.ts +2 -2
  67. package/dist/repo/url.js +7 -7
  68. package/dist/scratch/index.d.ts +4 -4
  69. package/dist/scratch/index.js +12 -11
  70. package/dist/{computer → workspace}/advisory.d.ts +33 -20
  71. package/dist/{computer → workspace}/advisory.js +32 -7
  72. package/dist/workspace/ca-trust.d.ts +95 -0
  73. package/dist/workspace/ca-trust.js +312 -0
  74. package/dist/workspace/container-deps.d.ts +54 -0
  75. package/dist/workspace/container-deps.js +224 -0
  76. package/dist/workspace/container-fault.d.ts +38 -0
  77. package/dist/workspace/container-fault.js +73 -0
  78. package/dist/workspace/exec.d.ts +94 -0
  79. package/dist/workspace/exec.js +153 -0
  80. package/dist/workspace/format.d.ts +36 -0
  81. package/dist/workspace/format.js +57 -0
  82. package/dist/workspace/git-host.d.ts +79 -0
  83. package/dist/workspace/git-host.js +226 -0
  84. package/dist/workspace/git-identity.d.ts +57 -0
  85. package/dist/workspace/git-identity.js +147 -0
  86. package/dist/workspace/index.d.ts +43 -47
  87. package/dist/workspace/index.js +52 -112
  88. package/dist/workspace/install-job.d.ts +121 -0
  89. package/dist/workspace/install-job.js +866 -0
  90. package/dist/{computer → workspace}/install.d.ts +15 -19
  91. package/dist/{computer → workspace}/install.js +8 -11
  92. package/dist/workspace/object.d.ts +502 -0
  93. package/dist/workspace/object.js +1427 -0
  94. package/dist/workspace/open.d.ts +95 -0
  95. package/dist/workspace/open.js +63 -0
  96. package/dist/workspace/read.d.ts +16 -0
  97. package/dist/workspace/read.js +22 -0
  98. package/dist/workspace/shell.d.ts +45 -0
  99. package/dist/workspace/shell.js +80 -0
  100. package/dist/workspace/sync.d.ts +111 -0
  101. package/dist/workspace/sync.js +124 -0
  102. package/dist/workspace/wake.d.ts +19 -0
  103. package/dist/workspace/wake.js +10 -0
  104. package/package.json +28 -42
  105. package/dist/arc-agi/analysis.d.ts +0 -336
  106. package/dist/arc-agi/analysis.js +0 -829
  107. package/dist/arc-agi/client.d.ts +0 -82
  108. package/dist/arc-agi/client.js +0 -113
  109. package/dist/arc-agi/game-tools.d.ts +0 -25
  110. package/dist/arc-agi/game-tools.js +0 -26
  111. package/dist/arc-agi/index.d.ts +0 -42
  112. package/dist/arc-agi/index.js +0 -175
  113. package/dist/arc-agi/main-agent.d.ts +0 -27
  114. package/dist/arc-agi/main-agent.js +0 -65
  115. package/dist/arc-agi/recipe.d.ts +0 -51
  116. package/dist/arc-agi/recipe.js +0 -100
  117. package/dist/arc-agi/scorecard.d.ts +0 -118
  118. package/dist/arc-agi/scorecard.js +0 -163
  119. package/dist/arc-agi/soul.d.ts +0 -40
  120. package/dist/arc-agi/soul.js +0 -90
  121. package/dist/arc-agi/store.d.ts +0 -154
  122. package/dist/arc-agi/store.js +0 -216
  123. package/dist/arc-agi/tools.d.ts +0 -36
  124. package/dist/arc-agi/tools.js +0 -576
  125. package/dist/arc-agi/types.d.ts +0 -212
  126. package/dist/arc-agi/types.js +0 -19
  127. package/dist/claude-code/recipe.d.ts +0 -53
  128. package/dist/claude-code/recipe.js +0 -100
  129. package/dist/computer/read.d.ts +0 -137
  130. package/dist/computer/read.js +0 -203
  131. package/dist/recall/index.d.ts +0 -99
  132. package/dist/recall/index.js +0 -171
  133. package/dist/triage/index.d.ts +0 -355
  134. package/dist/triage/index.js +0 -302
@@ -1,5 +1,4 @@
1
- import type { ToolSet } from "ai";
2
- import type { AgentPlugin, MainAgentToolApproval } from "@dynamicagents/core";
1
+ import type { AgentPlugin } from "@dynamicagents/core";
3
2
  /**
4
3
  * The URL parsing, re-exported from the one entry point.
5
4
  *
@@ -8,12 +7,13 @@ import type { AgentPlugin, MainAgentToolApproval } from "@dynamicagents/core";
8
7
  * though it is implemented in `url.ts`.
9
8
  */
10
9
  export { parseRepo } from "./url.js";
10
+ export { graphqlEndpoint, truncateOutput } from "./context.js";
11
11
  /**
12
12
  * `@dynamicagents/plugins/repo` — clone, commit, push, open a pull request.
13
13
  *
14
14
  * Layered over a container rather than owning one: it needs a shell with `git`
15
- * on it, and `@dynamicagents/plugins/computer` provides exactly that through
16
- * `computerExec`. Passing `exec` in rather than importing that plugin keeps the
15
+ * on it, and `@dynamicagents/plugins/workspace` provides exactly that through
16
+ * `workspaceExec`. Passing `exec` in rather than importing that plugin keeps the
17
17
  * two independent — a host with its own container can use this against that
18
18
  * instead, and the tests here need no container at all.
19
19
  *
@@ -26,7 +26,7 @@ export { parseRepo } from "./url.js";
26
26
  * none of it needs to authenticate.
27
27
  *
28
28
  * That split is the one thing to preserve when changing this file: if an
29
- * operation talks to the forge it does not belong on `exec`, and if it does not,
29
+ * operation talks to GitHub it does not belong on `exec`, and if it does not,
30
30
  * it has no business anywhere else.
31
31
  *
32
32
  * It is absolute rather than careful because a narrower version does not hold.
@@ -40,9 +40,9 @@ export { parseRepo } from "./url.js";
40
40
  * the length of one command is readable at `/proc/<pid>/environ` by anything
41
41
  * else in the container.
42
42
  *
43
- * Two further rules, which are about the forge rather than the container:
43
+ * Two further rules, which are about GitHub rather than the container:
44
44
  *
45
- * 1. **The forge is an allowlist, checked before anything runs.** A clone URL is
45
+ * 1. **GitHub's hosts are an allowlist, checked before anything runs.** A clone URL is
46
46
  * model input — a repository README, an issue body, or a page fetched by a
47
47
  * co-installed browser plugin is enough to choose it — and a credential
48
48
  * offered to a host of the model's choosing is the whole game. So the URL's
@@ -51,7 +51,7 @@ export { parseRepo } from "./url.js";
51
51
  * check to the moment the token would actually be handed over. `origin` is
52
52
  * re-derived and re-checked on every push rather than remembered, because the
53
53
  * checkout's `.git/config` is a file the container can rewrite.
54
- * 2. **The forge API is called from the Worker**, so the credential that can
54
+ * 2. **The GitHub API is called from the Worker**, so the credential that can
55
55
  * write to a repository through the API never crosses the boundary either.
56
56
  * Every tool that reads or writes through it resolves the repository from the
57
57
  * checkout's own origin rather than from a parameter, so there is no way to
@@ -66,23 +66,20 @@ export { parseRepo } from "./url.js";
66
66
  * repository. Whatever the token can reach, an agent talked into naming it can
67
67
  * reach. See the README — the token wants to be fine-grained.
68
68
  */
69
- /** This plugin's tool-family name, as a recipe's `toolFamilies` lists it. */
70
- export declare const REPO_FAMILY = "repo";
71
- /** Run one command in the host's container. Matches `computerExec`'s shape. */
69
+ /** Run one command in the host's container. Matches `workspaceExec`'s shape. */
72
70
  export type RepoExec = (command: string, options?: {
73
71
  cwd?: string;
74
72
  env?: Record<string, string | undefined>;
75
73
  timeout?: number;
76
74
  /**
77
- * The executing subtask's runtime state, forwarded **opaquely**.
75
+ * The running sub-agent's `runtime()`, forwarded **opaquely**.
78
76
  *
79
- * This plugin never looks inside it. A delegated subtask has to reach the
80
- * container its parent prepared, and the key for that lives in the runtime
81
- * state the parent resolved — but decoding it is the container plugin's
77
+ * This plugin never looks inside it. A sub-agent has to reach the
78
+ * container its parent prepared, and the key for that lives in what the
79
+ * parent's `prepare` returned — but decoding it is the container plugin's
82
80
  * business, not git's. Passing it through untouched is what lets the two
83
- * plugins compose
84
- * without either importing the other, which is the whole reason `exec` is
85
- * injected rather than imported.
81
+ * plugins compose without either importing the other, which is the whole
82
+ * reason `exec` is injected rather than imported.
86
83
  */
87
84
  runtime?: unknown;
88
85
  }) => Promise<{
@@ -92,7 +89,7 @@ export type RepoExec = (command: string, options?: {
92
89
  exitCode: number;
93
90
  }>;
94
91
  /**
95
- * The three git operations that need the forge token, run by the host.
92
+ * The three git operations that need the GitHub token, run by the host.
96
93
  *
97
94
  * Injected for the same reason {@link RepoExec} is — this plugin owns the
98
95
  * policy, not the plumbing — but the split between the two is not arbitrary. It
@@ -101,7 +98,7 @@ export type RepoExec = (command: string, options?: {
101
98
  * keeps its secret and never touches the container at all.
102
99
  *
103
100
  * That is why `clone`, `fetch` and `push` are the whole interface. They are
104
- * exactly the operations that talk to the forge. `status`, `diff`, `add`,
101
+ * exactly the operations that talk to GitHub. `status`, `diff`, `add`,
105
102
  * `commit` and `checkout` are local, need nothing to authenticate with, and stay
106
103
  * on `exec` where they are cheap and where the model can see them work.
107
104
  *
@@ -116,7 +113,8 @@ export type RepoExec = (command: string, options?: {
116
113
  * branch that does not resolve, a repository that is not there — all of it comes
117
114
  * back as `ok: false`, because those are answers. A rejection means the host
118
115
  * itself could not be reached, which is a different fact and gets a different
119
- * sentence from every tool in this file. See {@link RunResult}.
116
+ * sentence from every tool in this file. See
117
+ * {@link file://./context.ts RunResult}.
120
118
  */
121
119
  export interface RepoGit {
122
120
  /**
@@ -153,6 +151,14 @@ export interface RepoGit {
153
151
  branch: string;
154
152
  allowedHosts: string[];
155
153
  }): Promise<RepoGitResult>;
154
+ /**
155
+ * The checkout's `origin` URL, read on the host's side; `undefined` for none.
156
+ *
157
+ * Optional. Set, the GitHub tools resolve their repository without the
158
+ * container, so an agent polling a pull request does not keep one running.
159
+ * Unset, the origin is read through {@link RepoConfig.exec}.
160
+ */
161
+ origin?(dir: string): Promise<string | undefined>;
156
162
  }
157
163
  /** What a {@link RepoGit} operation reports. */
158
164
  export type RepoGitResult = {
@@ -167,14 +173,14 @@ export interface RepoConfig {
167
173
  /**
168
174
  * Runs commands in the container holding the checkout.
169
175
  *
170
- * Uncredentialed, always. Nothing this runs is ever given the forge token —
176
+ * Uncredentialed, always. Nothing this runs is ever given the GitHub token —
171
177
  * see {@link RepoGit} for the operations that need one.
172
178
  */
173
179
  exec: RepoExec;
174
180
  /** Runs the three credentialed operations, on the host's side of the boundary. */
175
181
  git: RepoGit;
176
182
  /**
177
- * A forge token with contents+pull-request write. A thunk so a rotated secret
183
+ * A GitHub token with contents+pull-request write. A thunk so a rotated secret
178
184
  * is picked up without rebuilding the plugin list.
179
185
  */
180
186
  token: () => string;
@@ -203,9 +209,9 @@ export interface RepoConfig {
203
209
  * 16,000 non-ASCII characters is three times that many UTF-8 bytes.
204
210
  *
205
211
  * `repo_diff` is the main input for an agent that
206
- * reviews rather than writes — a delegating coder whose subagents hold the
207
- * shell — and an unbounded diff on a large change is precisely the context
208
- * blowup that design exists to prevent.
212
+ * reviews rather than writes — a coder whose sub-agents hold the shell — and
213
+ * an unbounded diff on a large change is precisely the context blowup that
214
+ * design exists to prevent.
209
215
  */
210
216
  maxOutputChars?: number;
211
217
  /**
@@ -226,7 +232,7 @@ export interface RepoConfig {
226
232
  * not — a host that stored the path alongside its install state found that a
227
233
  * repository the resolver had nothing to install in (no `package.json`) cloned
228
234
  * perfectly, reported itself correctly, and could never be worked in, because
229
- * the one path its subagents needed was written on a branch that never ran.
235
+ * the one path its sub-agents needed was written on a branch that never ran.
230
236
  *
231
237
  * Awaited, so it can record intent durably, but it must **return quickly**:
232
238
  * it runs inside `repo_clone`, which runs inside a model turn. A host that
@@ -263,6 +269,50 @@ export interface RepoConfig {
263
269
  owner: string;
264
270
  repo: string;
265
271
  }) => void;
272
+ /**
273
+ * The worktrees a host keeps for its sub-agents' work, and the way between
274
+ * them.
275
+ *
276
+ * Set, the plugin offers `repo_worktrees` and `repo_worktree`. A switch moves
277
+ * the installing agent's own tools, so a host sets this on the parent's
278
+ * install and never on a sub-agent's. See {@link RepoWorktrees}.
279
+ */
280
+ worktrees?: RepoWorktrees;
281
+ /**
282
+ * The tools this install offers, and with them the lines of context that
283
+ * describe them. Unset, every tool. A selection rather than core's
284
+ * `restrictTools`, which drops a plugin's context whole: an agent that
285
+ * coordinates others' work reads about the tools it has and no others.
286
+ */
287
+ tools?: readonly RepoToolName[];
288
+ }
289
+ /** Every tool and action this plugin can offer, by the name the model sees. */
290
+ export declare const REPO_TOOL_NAMES: readonly ["repo_clone", "repo_fetch", "repo_status", "repo_diff", "repo_commit", "repo_push", "repo_open_pr", "repo_issue_view", "repo_pr_view", "repo_pr_comment", "repo_pr_review_status", "repo_pr_threads", "repo_pr_thread_reply", "repo_pr_checks", "repo_worktrees", "repo_worktree"];
291
+ export type RepoToolName = (typeof REPO_TOOL_NAMES)[number];
292
+ /**
293
+ * Checkouts a host keeps apart from the main one — each holding a branch its
294
+ * writing sub-agents committed on — and the switch that points every repo tool
295
+ * at one of them.
296
+ *
297
+ * The host renders every answer: which worktrees exist, where their checkouts
298
+ * sit and what is safe to do in them are its facts, and a sentence is what the
299
+ * model reads.
300
+ */
301
+ export interface RepoWorktrees {
302
+ /** Every worktree, with its branch and state. */
303
+ list(): Promise<string>;
304
+ /**
305
+ * Point every repo tool — and whatever else the host routes the same way — at
306
+ * the worktree holding `branch`, or back at the main checkout when it is absent.
307
+ * Answers what the model now has in front of it.
308
+ *
309
+ * The switch holds until the next one. This answer is what the model
310
+ * remembers, so a host that moves the tools on its own says so where the
311
+ * model reads it every turn.
312
+ */
313
+ use(branch?: string): Promise<string>;
314
+ /** Give up `branch`'s worktree, and the unpushed work in it. */
315
+ release(branch: string): Promise<string>;
266
316
  }
267
317
  /** What {@link RepoConfig.afterCheckout} is told about a checkout. */
268
318
  export interface RepoCheckout {
@@ -293,35 +343,7 @@ export interface RepoCheckout {
293
343
  fresh: boolean;
294
344
  }
295
345
  /**
296
- * Middle-out truncation, so both the head of a diff and its tail survive.
297
- *
298
- * Deliberately a **copy** of the computer plugin's function of the same name,
299
- * not an import. `npm run verify:exports` fails any subpath whose module graph
300
- * reaches a sibling's directory, and its own advice for a shared helper is to
301
- * duplicate it — installing `repo` must not drag `computer` (and therefore
302
- * `@cloudflare/computer`) into a consumer's bundle. Fifteen lines is a cheaper
303
- * price than that coupling, and it is the same reason `exec` is injected here
304
- * rather than imported.
305
- *
306
- * The `half < 1` guard is not padding: without it a small `max` makes `half`
307
- * zero or negative, and `slice(-0)` is `slice(0)` — the whole string — so the
308
- * function would return *more* than it was given.
309
- */
310
- export declare function truncateOutput(text: string, max: number): string;
311
- export declare function buildRepoTools(config: RepoConfig,
312
- /** Forwarded to every `exec`; see {@link RepoExec}'s `runtime` option. */
313
- runtime?: unknown): ToolSet;
314
- /**
315
- * The repo tools a person approves before they run: opening a pull request, and
316
- * nothing else. Pushing a work branch and commenting run without asking.
317
- *
318
- * The reason is what the person reads beside Approve and Reject, so it says what
319
- * the call will do in their terms: which repository, from which branch into
320
- * which, and under what title. The repository is the checkout's origin, read
321
- * through the same lookup the tool runs, so a directory named after one
322
- * repository cannot present a pull request on another. The input has already
323
- * passed the tool's own schema. What a rule is, and whose calls it covers, is
324
- * core's to say — see `AgentPlugin.mainAgentToolApproval`.
346
+ * No tool here is held for a person's approval — see this plugin's README for
347
+ * why, and for what a fork that wants one does instead.
325
348
  */
326
- export declare function repoToolApproval(config: RepoConfig): MainAgentToolApproval;
327
349
  export declare function repo(config: RepoConfig): AgentPlugin;