@dynamicagents/plugins 0.14.0 → 0.15.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 (141) hide show
  1. package/README.md +14 -14
  2. package/dist/claude-code/cards.d.ts +2 -0
  3. package/dist/claude-code/cards.js +11 -0
  4. package/dist/claude-code/config.d.ts +10 -83
  5. package/dist/claude-code/config.js +0 -2
  6. package/dist/claude-code/credentials.d.ts +32 -50
  7. package/dist/claude-code/credentials.js +115 -74
  8. package/dist/claude-code/daemon/index.d.ts +24 -0
  9. package/dist/claude-code/daemon/index.js +203 -0
  10. package/dist/claude-code/egress.d.ts +35 -117
  11. package/dist/claude-code/egress.js +80 -325
  12. package/dist/claude-code/events.d.ts +14 -17
  13. package/dist/claude-code/events.js +19 -15
  14. package/dist/claude-code/harness-wire.d.ts +45 -0
  15. package/dist/claude-code/harness-wire.js +47 -0
  16. package/dist/claude-code/index.d.ts +19 -29
  17. package/dist/claude-code/index.js +17 -25
  18. package/dist/claude-code/language-model.d.ts +19 -0
  19. package/dist/claude-code/language-model.js +71 -0
  20. package/dist/claude-code/model.d.ts +77 -70
  21. package/dist/claude-code/model.js +327 -327
  22. package/dist/claude-code/placeholder.d.ts +12 -0
  23. package/dist/claude-code/placeholder.js +12 -0
  24. package/dist/claude-code/spec.d.ts +4 -4
  25. package/dist/claude-code/spec.js +4 -4
  26. package/dist/computer/client.d.ts +88 -0
  27. package/dist/computer/client.js +6 -0
  28. package/dist/computer/context.d.ts +7 -7
  29. package/dist/computer/context.js +14 -18
  30. package/dist/computer/gate.d.ts +4 -23
  31. package/dist/computer/gate.js +1 -37
  32. package/dist/computer/index.d.ts +44 -43
  33. package/dist/computer/index.js +29 -50
  34. package/dist/computer/paths.d.ts +5 -27
  35. package/dist/computer/paths.js +7 -30
  36. package/dist/computer/proxy.d.ts +17 -31
  37. package/dist/computer/proxy.js +9 -44
  38. package/dist/computer/render.d.ts +3 -40
  39. package/dist/computer/render.js +3 -36
  40. package/dist/computer/sandbox.d.ts +55 -0
  41. package/dist/computer/sandbox.js +236 -0
  42. package/dist/computer/shell.d.ts +36 -0
  43. package/dist/computer/shell.js +41 -0
  44. package/dist/computer/tools-exec.js +3 -9
  45. package/dist/computer/tools-file.d.ts +1 -1
  46. package/dist/computer/tools-file.js +1 -1
  47. package/dist/{repo → repo-github}/checkout.d.ts +3 -4
  48. package/dist/{repo → repo-github}/checkout.js +3 -4
  49. package/dist/{repo → repo-github}/context.d.ts +14 -32
  50. package/dist/{repo → repo-github}/context.js +46 -81
  51. package/dist/{repo → repo-github}/index.d.ts +30 -13
  52. package/dist/{repo → repo-github}/index.js +25 -6
  53. package/dist/repo-github/mcp.d.ts +95 -0
  54. package/dist/repo-github/mcp.js +107 -0
  55. package/dist/repo-github/sandbox-egress.d.ts +68 -0
  56. package/dist/repo-github/sandbox-egress.js +272 -0
  57. package/dist/repo-github/sandbox-git.d.ts +30 -0
  58. package/dist/repo-github/sandbox-git.js +113 -0
  59. package/dist/{repo → repo-github}/tools-checks.js +43 -4
  60. package/dist/{repo → repo-github}/tools-clone.js +2 -21
  61. package/dist/{repo → repo-github}/tools-pr.d.ts +0 -1
  62. package/dist/{repo → repo-github}/tools-pr.js +85 -20
  63. package/dist/{repo → repo-github}/tools-review.d.ts +6 -0
  64. package/dist/{repo → repo-github}/tools-review.js +62 -176
  65. package/dist/{repo → repo-github}/url.d.ts +11 -0
  66. package/dist/{repo → repo-github}/url.js +12 -1
  67. package/dist/{workspace → sandbox}/advisory.d.ts +16 -35
  68. package/dist/{workspace → sandbox}/advisory.js +2 -29
  69. package/dist/sandbox/agent-exec.d.ts +31 -0
  70. package/dist/sandbox/agent-exec.js +62 -0
  71. package/dist/sandbox/ca-trust.d.ts +9 -0
  72. package/dist/sandbox/ca-trust.js +21 -0
  73. package/dist/sandbox/constants.d.ts +22 -0
  74. package/dist/sandbox/constants.js +22 -0
  75. package/dist/sandbox/daemon/composite.d.ts +9 -0
  76. package/dist/sandbox/daemon/composite.js +35 -0
  77. package/dist/sandbox/daemon/index.d.ts +47 -0
  78. package/dist/sandbox/daemon/index.js +116 -0
  79. package/dist/sandbox/egress.d.ts +81 -0
  80. package/dist/sandbox/egress.js +109 -0
  81. package/dist/sandbox/exec.d.ts +57 -0
  82. package/dist/sandbox/exec.js +52 -0
  83. package/dist/sandbox/format.d.ts +2 -0
  84. package/dist/sandbox/format.js +7 -0
  85. package/dist/sandbox/header.d.ts +50 -0
  86. package/dist/sandbox/header.js +94 -0
  87. package/dist/sandbox/index.d.ts +17 -0
  88. package/dist/sandbox/index.js +17 -0
  89. package/dist/{workspace/install.d.ts → sandbox/install-plan.d.ts} +2 -2
  90. package/dist/{workspace/install.js → sandbox/install-plan.js} +2 -2
  91. package/dist/sandbox/name.d.ts +27 -0
  92. package/dist/sandbox/name.js +32 -0
  93. package/dist/sandbox/object.d.ts +244 -0
  94. package/dist/sandbox/object.js +1139 -0
  95. package/dist/scratch/index.d.ts +1 -9
  96. package/dist/scratch/index.js +2 -18
  97. package/package.json +22 -18
  98. package/dist/claude-code/github.d.ts +0 -39
  99. package/dist/claude-code/github.js +0 -82
  100. package/dist/claude-code/run.d.ts +0 -491
  101. package/dist/claude-code/run.js +0 -913
  102. package/dist/claude-code/session.d.ts +0 -131
  103. package/dist/claude-code/session.js +0 -288
  104. package/dist/workspace/ca-trust.d.ts +0 -95
  105. package/dist/workspace/ca-trust.js +0 -312
  106. package/dist/workspace/container-deps.d.ts +0 -58
  107. package/dist/workspace/container-deps.js +0 -249
  108. package/dist/workspace/container-fault.d.ts +0 -38
  109. package/dist/workspace/container-fault.js +0 -73
  110. package/dist/workspace/deps-snapshot.d.ts +0 -110
  111. package/dist/workspace/deps-snapshot.js +0 -424
  112. package/dist/workspace/exec.d.ts +0 -94
  113. package/dist/workspace/exec.js +0 -153
  114. package/dist/workspace/format.d.ts +0 -36
  115. package/dist/workspace/format.js +0 -57
  116. package/dist/workspace/git-host.d.ts +0 -79
  117. package/dist/workspace/git-host.js +0 -226
  118. package/dist/workspace/git-identity.d.ts +0 -57
  119. package/dist/workspace/git-identity.js +0 -147
  120. package/dist/workspace/index.d.ts +0 -50
  121. package/dist/workspace/index.js +0 -58
  122. package/dist/workspace/install-job.d.ts +0 -170
  123. package/dist/workspace/install-job.js +0 -934
  124. package/dist/workspace/object.d.ts +0 -522
  125. package/dist/workspace/object.js +0 -1541
  126. package/dist/workspace/open.d.ts +0 -95
  127. package/dist/workspace/open.js +0 -63
  128. package/dist/workspace/read.d.ts +0 -16
  129. package/dist/workspace/read.js +0 -22
  130. package/dist/workspace/shell.d.ts +0 -45
  131. package/dist/workspace/shell.js +0 -80
  132. package/dist/workspace/sync.d.ts +0 -111
  133. package/dist/workspace/sync.js +0 -124
  134. package/dist/workspace/wake.d.ts +0 -21
  135. package/dist/workspace/wake.js +0 -10
  136. /package/dist/{repo → repo-github}/tools-checks.d.ts +0 -0
  137. /package/dist/{repo → repo-github}/tools-clone.d.ts +0 -0
  138. /package/dist/{repo → repo-github}/tools-worktree.d.ts +0 -0
  139. /package/dist/{repo → repo-github}/tools-worktree.js +0 -0
  140. /package/dist/{repo → repo-github}/tools-worktrees.d.ts +0 -0
  141. /package/dist/{repo → repo-github}/tools-worktrees.js +0 -0
@@ -0,0 +1,244 @@
1
+ import { DurableObject } from "cloudflare:workers";
2
+ import { type ContainerEgressBinding, type ContainerInstance, type ContainerMessage, type ContainerOperationResult } from "agents/harness/container";
3
+ import { type DirectoryBackupGatewayBinding } from "@cloudflare/sandbox";
4
+ import { type SandboxAdvisory } from "./advisory.js";
5
+ import { type SandboxEgressRule } from "./egress.js";
6
+ import { type InstallPlan, type InstallState } from "./install-plan.js";
7
+ export interface SandboxObjectConfig {
8
+ /** Log prefix. */
9
+ label: string;
10
+ /** The adapter the daemon in {@link image} serves CLI sessions with. */
11
+ adapter: string;
12
+ /** The image to start: a key of `ctx.container.images`. Default `app`. */
13
+ image?: string;
14
+ instance: ContainerInstance;
15
+ /**
16
+ * Non-secret environment for every command the agent runs — an `exec`, an
17
+ * install, a CLI turn — under its own. No key a rule's `env` sets.
18
+ */
19
+ env?: Readonly<Record<string, string>>;
20
+ egress: {
21
+ /** `ctx.exports.<Entrypoint>`: the consumer's entrypoint, calling `sandboxEgress` with {@link rules}. */
22
+ entrypoint: ContainerEgressBinding;
23
+ /** The `env` binding this class is reached by, so a rule's handler can reach the sandbox a request came from. */
24
+ self: string;
25
+ /** What the container may reach, each declared by the plugin that needs it (`./egress.ts`). */
26
+ rules: readonly SandboxEgressRule[];
27
+ };
28
+ installPlan: InstallPlan;
29
+ /** Where checkouts are backed up before every stop. Without it an image change loses unpushed work. */
30
+ backups?: {
31
+ binding: string;
32
+ prefix?: string;
33
+ gateway: DirectoryBackupGatewayBinding;
34
+ };
35
+ /** How long after its last use a container is backed up and stopped. */
36
+ idleStopMs?: number;
37
+ /** An `env` binding whose value unlocks {@link SandboxObjectBase.debug}. Absent: no debug RPC. */
38
+ debugSecretBinding?: string;
39
+ }
40
+ export interface ExecResult {
41
+ exitCode: number;
42
+ stdout: string;
43
+ stderr: string;
44
+ }
45
+ export interface CheckoutRecord {
46
+ dir: string;
47
+ kind: "repo" | "scratch";
48
+ repo?: string;
49
+ }
50
+ /** A run's messages as of one poll, each with a digest that changes when the message does. */
51
+ export interface PolledMessage {
52
+ id: string;
53
+ digest: string;
54
+ message: ContainerMessage;
55
+ }
56
+ export interface PollResult {
57
+ contract: number;
58
+ /** Set once the operation settled. */
59
+ result?: ContainerOperationResult;
60
+ messages: PolledMessage[];
61
+ /** The `from` that skips every message sent so far. */
62
+ next: number;
63
+ }
64
+ export interface SnapshotSeed {
65
+ key: string;
66
+ snapshot: {
67
+ id: string;
68
+ };
69
+ }
70
+ export declare abstract class SandboxObjectBase<Env extends object = Cloudflare.Env> extends DurableObject<Env> {
71
+ #private;
72
+ protected abstract sandboxConfig(): SandboxObjectConfig;
73
+ /** The object's container. A seam so specs can hand in a fake one. */
74
+ protected containerFor(ctx: DurableObjectState): Container;
75
+ constructor(ctx: DurableObjectState, env: Env);
76
+ /**
77
+ * The container, running and ready for a command or a CLI turn.
78
+ *
79
+ * A stopped one is started by a `control:wake` prompt on the root session,
80
+ * which the daemon answers without a CLI: the harness starts containers only
81
+ * for a prompt. Then, once per container, the egress the harness does not
82
+ * register, and any checkout an image change left behind.
83
+ */
84
+ ensureRunning(): Promise<{
85
+ runtimeId: string;
86
+ }>;
87
+ /** A command as the agent, with no capabilities: the host's `env`, its own over that, and every egress rule's over both. */
88
+ exec(argv: readonly string[], options?: {
89
+ cwd?: string;
90
+ env?: Readonly<Record<string, string>>;
91
+ timeoutMs?: number;
92
+ }): Promise<ExecResult>;
93
+ readFile(path: string): Promise<Uint8Array | null>;
94
+ writeFile(path: string, content: Uint8Array | string): Promise<void>;
95
+ stat(path: string): Promise<{
96
+ type: string;
97
+ size: number;
98
+ modifiedAt: number;
99
+ } | null>;
100
+ readDir(path: string): Promise<{
101
+ name: string;
102
+ type: string;
103
+ }[]>;
104
+ mkdir(path: string): Promise<void>;
105
+ rm(path: string, options?: {
106
+ recursive?: boolean;
107
+ }): Promise<void>;
108
+ /**
109
+ * The harness session a run lives in, made on first ask.
110
+ *
111
+ * The harness refuses a session id it did not mint, so a run's own id maps to
112
+ * one here. A run may instead carry on another run's conversation: `continues`
113
+ * shares its session, and `forkOf` branches a new one from it. Either only
114
+ * works inside one object, since the conversation's files are this one's, and
115
+ * only in the same `cwd`, since the CLI files a conversation by directory.
116
+ */
117
+ createRun(runId: string, options: {
118
+ cwd: string;
119
+ forkOf?: string;
120
+ continues?: string;
121
+ }): Promise<{
122
+ sessionId: string;
123
+ created: boolean;
124
+ }>;
125
+ /**
126
+ * Durably submit one turn of a run. `operationId` is the caller's, so a
127
+ * retried submit is the same operation; a settled one comes back as it ended,
128
+ * which is why a caller resubmitting after a lost container uses a new one.
129
+ *
130
+ * Every turn runs in the run's `cwd`: a turn with no run header gets one, and
131
+ * a header naming another directory is refused.
132
+ *
133
+ * A stopped run takes no turn, checked before and after the turn is queued:
134
+ * a submission still starting the container when its run is stopped would
135
+ * otherwise start a CLI after the stop, with nobody left polling it.
136
+ */
137
+ submit(runId: string, text: string, operationId: string): Promise<{
138
+ operationId: string;
139
+ accepted: boolean;
140
+ }>;
141
+ /**
142
+ * One operation's state, waiting up to `waitMs` for it to settle.
143
+ *
144
+ * Only stored messages reach here: the harness keeps a run's messages and
145
+ * nothing it streamed live. Those of this operation only, so a forked run does
146
+ * not report its parent's history, each with a digest, because a message is
147
+ * replaced in place as its tool calls finish.
148
+ *
149
+ * `from` skips that many of them, so a long run is not sent whole on every
150
+ * poll; pass the last poll's `next`. A message replaced behind `from` is not
151
+ * sent again, so a caller passes it only for an adapter that never replaces
152
+ * one.
153
+ */
154
+ poll(runId: string, operationId: string, waitMs?: number, from?: number): Promise<PollResult>;
155
+ /**
156
+ * Stop a run and let its CLI finish leaving.
157
+ *
158
+ * The harness settles an abort at once, while the CLI is still exiting — a
159
+ * SIGINT, a SIGKILL a few seconds later, then one last sync of its session
160
+ * files. Committing or stopping before that loses what it wrote last, or
161
+ * races git's index lock. So this waits for no CLI to be left, and one sync.
162
+ *
163
+ * A stopped run takes no more turns. Its conversation goes on, if it does, in
164
+ * a run that `continues` it — whose operations share the session, so only
165
+ * this run's own are aborted.
166
+ */
167
+ stopRun(runId: string): Promise<{
168
+ stopped: boolean;
169
+ }>;
170
+ /**
171
+ * Snapshot the container now, as the start the harness will make next.
172
+ *
173
+ * The harness snapshots only when it stops a container, so one that dies mid-run
174
+ * starts from whatever it last stopped as. Writing its record is what makes a
175
+ * checkpoint the next start; the contract spec pins that it reads it.
176
+ */
177
+ checkpoint(): Promise<SnapshotSeed | undefined>;
178
+ /** The last checkpoint, for another sandbox of this class to start from. */
179
+ snapshotRecord(): Promise<SnapshotSeed | undefined>;
180
+ /**
181
+ * Start this sandbox's next container from another's checkpoint.
182
+ *
183
+ * Refused while it runs — the record is read at a start — and for a snapshot
184
+ * of another image, which a container cannot start from.
185
+ */
186
+ seedFrom(seed: SnapshotSeed): Promise<{
187
+ seeded: boolean;
188
+ reason?: string;
189
+ }>;
190
+ /**
191
+ * Back up and stop the container. Its disk is the next start, as a snapshot.
192
+ *
193
+ * Refused while anything is working — an open run, a command, an install:
194
+ * stopping the harness re-wakes every open session, which starts the
195
+ * container again. Work that arrives meanwhile waits for the stop, then
196
+ * starts a new container.
197
+ */
198
+ release(): Promise<{
199
+ released: boolean;
200
+ reason?: string;
201
+ }>;
202
+ noteCheckout(record: CheckoutRecord): Promise<{
203
+ dir: string;
204
+ present: boolean;
205
+ }>;
206
+ /**
207
+ * The newest recorded checkout, a repository's or a scratchpad's. Starts no
208
+ * container and marks no use, so a sweep asking every sandbox does not keep
209
+ * them alive: a sandbox answers from its record, since a start restores what
210
+ * its disk lost, until a running container is prepared — then only if its
211
+ * `.git` is there.
212
+ */
213
+ checkoutDir(): Promise<string | undefined>;
214
+ /**
215
+ * Install a checkout's dependencies, in the background.
216
+ *
217
+ * The command runs detached in the container and writes its exit code to a
218
+ * file, which the alarm reads: a container process outlives the request that
219
+ * started it, and the file outlives the object that is waiting for it.
220
+ */
221
+ startInstall(target: InstallTarget): Promise<InstallState>;
222
+ advisories(): Promise<readonly SandboxAdvisory[]>;
223
+ /** Empty a sandbox nobody has used in `maxIdleMs`: backups, storage and all. */
224
+ reclaimIfIdle(maxIdleMs: number): Promise<{
225
+ reclaimed: boolean;
226
+ idleMs: number;
227
+ }>;
228
+ /** For acceptance runs only, behind a secret: reset this object, destroy its container, or run as root. */
229
+ debug(secret: string, op: {
230
+ kind: "reset";
231
+ } | {
232
+ kind: "destroy";
233
+ } | {
234
+ kind: "root-exec";
235
+ argv: string[];
236
+ }): Promise<ExecResult | {
237
+ ok: true;
238
+ }>;
239
+ }
240
+ interface InstallTarget {
241
+ dir: string;
242
+ repo?: string;
243
+ }
244
+ export {};