@dynamicagents/plugins 0.14.0 → 0.16.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.
- package/README.md +14 -14
- package/dist/claude-code/cards.d.ts +2 -0
- package/dist/claude-code/cards.js +11 -0
- package/dist/claude-code/config.d.ts +10 -83
- package/dist/claude-code/config.js +0 -2
- package/dist/claude-code/credentials.d.ts +32 -50
- package/dist/claude-code/credentials.js +115 -74
- package/dist/claude-code/daemon/index.d.ts +24 -0
- package/dist/claude-code/daemon/index.js +203 -0
- package/dist/claude-code/egress.d.ts +35 -117
- package/dist/claude-code/egress.js +80 -325
- package/dist/claude-code/events.d.ts +14 -17
- package/dist/claude-code/events.js +19 -15
- package/dist/claude-code/harness-wire.d.ts +45 -0
- package/dist/claude-code/harness-wire.js +47 -0
- package/dist/claude-code/index.d.ts +19 -29
- package/dist/claude-code/index.js +17 -25
- package/dist/claude-code/language-model.d.ts +19 -0
- package/dist/claude-code/language-model.js +71 -0
- package/dist/claude-code/model.d.ts +77 -70
- package/dist/claude-code/model.js +327 -327
- package/dist/claude-code/placeholder.d.ts +12 -0
- package/dist/claude-code/placeholder.js +12 -0
- package/dist/claude-code/spec.d.ts +4 -4
- package/dist/claude-code/spec.js +4 -4
- package/dist/computer/client.d.ts +88 -0
- package/dist/computer/client.js +6 -0
- package/dist/computer/context.d.ts +7 -7
- package/dist/computer/context.js +14 -18
- package/dist/computer/gate.d.ts +4 -23
- package/dist/computer/gate.js +1 -37
- package/dist/computer/index.d.ts +44 -43
- package/dist/computer/index.js +29 -50
- package/dist/computer/paths.d.ts +5 -27
- package/dist/computer/paths.js +7 -30
- package/dist/computer/proxy.d.ts +17 -31
- package/dist/computer/proxy.js +9 -44
- package/dist/computer/render.d.ts +3 -40
- package/dist/computer/render.js +3 -36
- package/dist/computer/sandbox.d.ts +55 -0
- package/dist/computer/sandbox.js +236 -0
- package/dist/computer/shell.d.ts +36 -0
- package/dist/computer/shell.js +41 -0
- package/dist/computer/tools-exec.js +3 -9
- package/dist/computer/tools-file.d.ts +1 -1
- package/dist/computer/tools-file.js +1 -1
- package/dist/{repo → repo-github}/checkout.d.ts +3 -4
- package/dist/{repo → repo-github}/checkout.js +3 -4
- package/dist/{repo → repo-github}/context.d.ts +14 -32
- package/dist/{repo → repo-github}/context.js +46 -81
- package/dist/{repo → repo-github}/index.d.ts +30 -13
- package/dist/{repo → repo-github}/index.js +25 -6
- package/dist/repo-github/mcp.d.ts +95 -0
- package/dist/repo-github/mcp.js +107 -0
- package/dist/repo-github/sandbox-egress.d.ts +68 -0
- package/dist/repo-github/sandbox-egress.js +272 -0
- package/dist/repo-github/sandbox-git.d.ts +30 -0
- package/dist/repo-github/sandbox-git.js +113 -0
- package/dist/{repo → repo-github}/tools-checks.js +43 -4
- package/dist/{repo → repo-github}/tools-clone.js +2 -21
- package/dist/{repo → repo-github}/tools-pr.d.ts +0 -1
- package/dist/{repo → repo-github}/tools-pr.js +85 -20
- package/dist/{repo → repo-github}/tools-review.d.ts +6 -0
- package/dist/{repo → repo-github}/tools-review.js +62 -176
- package/dist/{repo → repo-github}/url.d.ts +11 -0
- package/dist/{repo → repo-github}/url.js +12 -1
- package/dist/{workspace → sandbox}/advisory.d.ts +16 -35
- package/dist/{workspace → sandbox}/advisory.js +2 -29
- package/dist/sandbox/agent-exec.d.ts +31 -0
- package/dist/sandbox/agent-exec.js +62 -0
- package/dist/sandbox/ca-trust.d.ts +9 -0
- package/dist/sandbox/ca-trust.js +21 -0
- package/dist/sandbox/constants.d.ts +22 -0
- package/dist/sandbox/constants.js +22 -0
- package/dist/sandbox/daemon/composite.d.ts +9 -0
- package/dist/sandbox/daemon/composite.js +35 -0
- package/dist/sandbox/daemon/index.d.ts +47 -0
- package/dist/sandbox/daemon/index.js +116 -0
- package/dist/sandbox/egress.d.ts +81 -0
- package/dist/sandbox/egress.js +109 -0
- package/dist/sandbox/exec.d.ts +57 -0
- package/dist/sandbox/exec.js +52 -0
- package/dist/sandbox/format.d.ts +2 -0
- package/dist/sandbox/format.js +7 -0
- package/dist/sandbox/header.d.ts +50 -0
- package/dist/sandbox/header.js +94 -0
- package/dist/sandbox/index.d.ts +17 -0
- package/dist/sandbox/index.js +17 -0
- package/dist/{workspace/install.d.ts → sandbox/install-plan.d.ts} +2 -2
- package/dist/{workspace/install.js → sandbox/install-plan.js} +2 -2
- package/dist/sandbox/name.d.ts +27 -0
- package/dist/sandbox/name.js +32 -0
- package/dist/sandbox/object.d.ts +244 -0
- package/dist/sandbox/object.js +1139 -0
- package/dist/scratch/index.d.ts +1 -9
- package/dist/scratch/index.js +2 -18
- package/package.json +24 -20
- package/dist/claude-code/github.d.ts +0 -39
- package/dist/claude-code/github.js +0 -82
- package/dist/claude-code/run.d.ts +0 -491
- package/dist/claude-code/run.js +0 -913
- package/dist/claude-code/session.d.ts +0 -131
- package/dist/claude-code/session.js +0 -288
- package/dist/workspace/ca-trust.d.ts +0 -95
- package/dist/workspace/ca-trust.js +0 -312
- package/dist/workspace/container-deps.d.ts +0 -58
- package/dist/workspace/container-deps.js +0 -249
- package/dist/workspace/container-fault.d.ts +0 -38
- package/dist/workspace/container-fault.js +0 -73
- package/dist/workspace/deps-snapshot.d.ts +0 -110
- package/dist/workspace/deps-snapshot.js +0 -424
- package/dist/workspace/exec.d.ts +0 -94
- package/dist/workspace/exec.js +0 -153
- package/dist/workspace/format.d.ts +0 -36
- package/dist/workspace/format.js +0 -57
- package/dist/workspace/git-host.d.ts +0 -79
- package/dist/workspace/git-host.js +0 -226
- package/dist/workspace/git-identity.d.ts +0 -57
- package/dist/workspace/git-identity.js +0 -147
- package/dist/workspace/index.d.ts +0 -50
- package/dist/workspace/index.js +0 -58
- package/dist/workspace/install-job.d.ts +0 -170
- package/dist/workspace/install-job.js +0 -934
- package/dist/workspace/object.d.ts +0 -522
- package/dist/workspace/object.js +0 -1541
- package/dist/workspace/open.d.ts +0 -95
- package/dist/workspace/open.js +0 -63
- package/dist/workspace/read.d.ts +0 -16
- package/dist/workspace/read.js +0 -22
- package/dist/workspace/shell.d.ts +0 -45
- package/dist/workspace/shell.js +0 -80
- package/dist/workspace/sync.d.ts +0 -111
- package/dist/workspace/sync.js +0 -124
- package/dist/workspace/wake.d.ts +0 -21
- package/dist/workspace/wake.js +0 -10
- /package/dist/{repo → repo-github}/tools-checks.d.ts +0 -0
- /package/dist/{repo → repo-github}/tools-clone.d.ts +0 -0
- /package/dist/{repo → repo-github}/tools-worktree.d.ts +0 -0
- /package/dist/{repo → repo-github}/tools-worktree.js +0 -0
- /package/dist/{repo → repo-github}/tools-worktrees.d.ts +0 -0
- /package/dist/{repo → repo-github}/tools-worktrees.js +0 -0
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { Workspace } from "@cloudflare/computer";
|
|
2
|
-
/**
|
|
3
|
-
* The identity a commit made in this container carries when nothing nearer
|
|
4
|
-
* answers for it.
|
|
5
|
-
*
|
|
6
|
-
* `/repo` configures the checkouts it clones and names the identity on every
|
|
7
|
-
* commit it makes — see {@link file://../repo/checkout.ts writeGitIdentity}.
|
|
8
|
-
* Neither reaches a repository the container made for itself: a submodule
|
|
9
|
-
* checked out by a bootstrap, a `git init`, a second clone from the shell. Those
|
|
10
|
-
* have no identity at all, and git refuses to commit without one — so whatever
|
|
11
|
-
* is driving the shell has to invent a name to get past the refusal, and that
|
|
12
|
-
* invention is what ends up in the history.
|
|
13
|
-
*
|
|
14
|
-
* This is the layer underneath, so there is nothing to invent: every repository
|
|
15
|
-
* in the container starts out attributed to the deployment.
|
|
16
|
-
*
|
|
17
|
-
* **System scope, not global.** `--global` writes `$HOME/.gitconfig`, and a
|
|
18
|
-
* command run through the runtime cannot count on `HOME` being set to anything
|
|
19
|
-
* in particular — nor is the identity a property of one user of the container.
|
|
20
|
-
* `--system` is also the *lowest* precedence git has, which is the right place
|
|
21
|
-
* for it: a checkout's own config still wins, and so does the environment
|
|
22
|
-
* `/repo` and the session's launch put on a commit.
|
|
23
|
-
*/
|
|
24
|
-
/** Written to `/etc/gitconfig`; the values arrive as variables, never inline. */
|
|
25
|
-
export declare const GIT_IDENTITY_COMMAND: string;
|
|
26
|
-
export interface ContainerGitIdentityDeps {
|
|
27
|
-
workspace: () => Workspace;
|
|
28
|
-
author: () => {
|
|
29
|
-
name: string;
|
|
30
|
-
email: string;
|
|
31
|
-
};
|
|
32
|
-
/** Log prefix and object id, for the one line an operator can see. */
|
|
33
|
-
tag: () => string;
|
|
34
|
-
id: () => string;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* The write above, once per container.
|
|
38
|
-
*
|
|
39
|
-
* In memory, with {@link file://./ca-trust.ts}'s lifetime and for its reason: it
|
|
40
|
-
* describes one container, and an isolate that lost it re-runs an idempotent
|
|
41
|
-
* command.
|
|
42
|
-
*/
|
|
43
|
-
export declare class ContainerGitIdentity {
|
|
44
|
-
#private;
|
|
45
|
-
private readonly deps;
|
|
46
|
-
constructor(deps: ContainerGitIdentityDeps);
|
|
47
|
-
forget(): void;
|
|
48
|
-
/**
|
|
49
|
-
* Configure this container if it has not been configured yet.
|
|
50
|
-
*
|
|
51
|
-
* **Never throws**, like the CA install and unlike the dependency setup. What
|
|
52
|
-
* a failure costs is an attribution, and every later commit says plainly that
|
|
53
|
-
* it has no identity to use — where a throw here would fail a workspace that
|
|
54
|
-
* is otherwise entirely usable.
|
|
55
|
-
*/
|
|
56
|
-
ensure(): Promise<void>;
|
|
57
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
-
if (value !== null && value !== void 0) {
|
|
3
|
-
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
-
var dispose, inner;
|
|
5
|
-
if (async) {
|
|
6
|
-
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
-
dispose = value[Symbol.asyncDispose];
|
|
8
|
-
}
|
|
9
|
-
if (dispose === void 0) {
|
|
10
|
-
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
-
dispose = value[Symbol.dispose];
|
|
12
|
-
if (async) inner = dispose;
|
|
13
|
-
}
|
|
14
|
-
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
-
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
-
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
-
}
|
|
18
|
-
else if (async) {
|
|
19
|
-
env.stack.push({ async: true });
|
|
20
|
-
}
|
|
21
|
-
return value;
|
|
22
|
-
};
|
|
23
|
-
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
-
return function (env) {
|
|
25
|
-
function fail(e) {
|
|
26
|
-
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
-
env.hasError = true;
|
|
28
|
-
}
|
|
29
|
-
var r, s = 0;
|
|
30
|
-
function next() {
|
|
31
|
-
while (r = env.stack.pop()) {
|
|
32
|
-
try {
|
|
33
|
-
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
-
if (r.dispose) {
|
|
35
|
-
var result = r.dispose.call(r.value);
|
|
36
|
-
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
-
}
|
|
38
|
-
else s |= 1;
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
fail(e);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
-
if (env.hasError) throw env.error;
|
|
46
|
-
}
|
|
47
|
-
return next();
|
|
48
|
-
};
|
|
49
|
-
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
-
var e = new Error(message);
|
|
51
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
-
});
|
|
53
|
-
/**
|
|
54
|
-
* The identity a commit made in this container carries when nothing nearer
|
|
55
|
-
* answers for it.
|
|
56
|
-
*
|
|
57
|
-
* `/repo` configures the checkouts it clones and names the identity on every
|
|
58
|
-
* commit it makes — see {@link file://../repo/checkout.ts writeGitIdentity}.
|
|
59
|
-
* Neither reaches a repository the container made for itself: a submodule
|
|
60
|
-
* checked out by a bootstrap, a `git init`, a second clone from the shell. Those
|
|
61
|
-
* have no identity at all, and git refuses to commit without one — so whatever
|
|
62
|
-
* is driving the shell has to invent a name to get past the refusal, and that
|
|
63
|
-
* invention is what ends up in the history.
|
|
64
|
-
*
|
|
65
|
-
* This is the layer underneath, so there is nothing to invent: every repository
|
|
66
|
-
* in the container starts out attributed to the deployment.
|
|
67
|
-
*
|
|
68
|
-
* **System scope, not global.** `--global` writes `$HOME/.gitconfig`, and a
|
|
69
|
-
* command run through the runtime cannot count on `HOME` being set to anything
|
|
70
|
-
* in particular — nor is the identity a property of one user of the container.
|
|
71
|
-
* `--system` is also the *lowest* precedence git has, which is the right place
|
|
72
|
-
* for it: a checkout's own config still wins, and so does the environment
|
|
73
|
-
* `/repo` and the session's launch put on a commit.
|
|
74
|
-
*/
|
|
75
|
-
/** Written to `/etc/gitconfig`; the values arrive as variables, never inline. */
|
|
76
|
-
export const GIT_IDENTITY_COMMAND = [
|
|
77
|
-
'git config --system user.name "$GIT_NAME"',
|
|
78
|
-
'git config --system user.email "$GIT_EMAIL"',
|
|
79
|
-
"echo IDENTITY OK"
|
|
80
|
-
].join(" && ");
|
|
81
|
-
/** How long the write may take before it is not going to happen. */
|
|
82
|
-
const IDENTITY_TIMEOUT_MS = 30_000;
|
|
83
|
-
/**
|
|
84
|
-
* The write above, once per container.
|
|
85
|
-
*
|
|
86
|
-
* In memory, with {@link file://./ca-trust.ts}'s lifetime and for its reason: it
|
|
87
|
-
* describes one container, and an isolate that lost it re-runs an idempotent
|
|
88
|
-
* command.
|
|
89
|
-
*/
|
|
90
|
-
export class ContainerGitIdentity {
|
|
91
|
-
deps;
|
|
92
|
-
#done = false;
|
|
93
|
-
constructor(deps) {
|
|
94
|
-
this.deps = deps;
|
|
95
|
-
}
|
|
96
|
-
forget() {
|
|
97
|
-
this.#done = false;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Configure this container if it has not been configured yet.
|
|
101
|
-
*
|
|
102
|
-
* **Never throws**, like the CA install and unlike the dependency setup. What
|
|
103
|
-
* a failure costs is an attribution, and every later commit says plainly that
|
|
104
|
-
* it has no identity to use — where a throw here would fail a workspace that
|
|
105
|
-
* is otherwise entirely usable.
|
|
106
|
-
*/
|
|
107
|
-
async ensure() {
|
|
108
|
-
if (this.#done)
|
|
109
|
-
return;
|
|
110
|
-
const author = this.deps.author();
|
|
111
|
-
try {
|
|
112
|
-
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
113
|
-
try {
|
|
114
|
-
const handle = __addDisposableResource(env_1, await this.deps
|
|
115
|
-
.workspace()
|
|
116
|
-
.runtime.exec(GIT_IDENTITY_COMMAND, {
|
|
117
|
-
cwd: "/",
|
|
118
|
-
encoding: "utf8",
|
|
119
|
-
timeoutMs: IDENTITY_TIMEOUT_MS,
|
|
120
|
-
env: { GIT_NAME: author.name, GIT_EMAIL: author.email }
|
|
121
|
-
}), false);
|
|
122
|
-
const result = await handle.result();
|
|
123
|
-
const output = `${result.stdout ?? ""}${result.stderr ?? ""}`;
|
|
124
|
-
this.#done = result.exitCode === 0 && output.includes("IDENTITY OK");
|
|
125
|
-
if (this.#done)
|
|
126
|
-
return;
|
|
127
|
-
console.warn(`[${this.deps.tag()}] could not set the container's git identity`, {
|
|
128
|
-
id: this.deps.id(),
|
|
129
|
-
output: output.trim()
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
catch (e_1) {
|
|
133
|
-
env_1.error = e_1;
|
|
134
|
-
env_1.hasError = true;
|
|
135
|
-
}
|
|
136
|
-
finally {
|
|
137
|
-
__disposeResources(env_1);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
catch (err) {
|
|
141
|
-
console.warn(`[${this.deps.tag()}] could not set the container's git identity`, {
|
|
142
|
-
id: this.deps.id(),
|
|
143
|
-
err: String(err)
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `@dynamicagents/plugins/workspace` — the Durable Object a container workspace
|
|
3
|
-
* lives in, and the client side every other plugin reaches it through.
|
|
4
|
-
*
|
|
5
|
-
* The filesystem **is** a Durable Object's SQLite, mounted into the container
|
|
6
|
-
* over FUSE by `computerd`. Commands see a normal `/workspace`; the Worker reads
|
|
7
|
-
* the same tree over RPC; and when the container is replaced the tree is pushed
|
|
8
|
-
* back into the new one — so a checkout outlives the container that held it.
|
|
9
|
-
*
|
|
10
|
-
* `WorkspaceObjectBase` is the object: container backend, egress, CA trust,
|
|
11
|
-
* credentialed git, the dependency install, the sync drain and idle reclaim. A
|
|
12
|
-
* host subclasses it and answers a short config. Everything else here is what
|
|
13
|
-
* reaches it from outside: `openWorkspace`, `workspaceExec`, and the advisory
|
|
14
|
-
* vocabulary it reports its state in.
|
|
15
|
-
*
|
|
16
|
-
* `@dynamicagents/plugins/computer` is the agent's tools over it; `/repo` and
|
|
17
|
-
* `/scratch` take `workspaceExec` injected.
|
|
18
|
-
*
|
|
19
|
-
* Requires the Workers **Paid** plan (containers) and a Durable Object binding
|
|
20
|
-
* whose class extends `WorkspaceObjectBase` — see the README for the wrangler
|
|
21
|
-
* block.
|
|
22
|
-
*/
|
|
23
|
-
/** How a repository installs its dependencies — the mechanical half. */
|
|
24
|
-
export { DEFAULT_INSTALL_PLAN, installFingerprint, resolveInstallCommand, type InstallPlan, type InstallProbe, type InstallResolution, type InstallRule, type InstallState } from "./install.js";
|
|
25
|
-
/**
|
|
26
|
-
* The workspace-advisory vocabulary, which a host needs all of: the type to
|
|
27
|
-
* return over RPC, `deriveAdvisories` to build it from what it already knows,
|
|
28
|
-
* and `sessionAdvisory` for a host driving a whole session rather than one
|
|
29
|
-
* command. `shapeOf` and `renderAdvisory` are exported for the specs that hold
|
|
30
|
-
* their exhaustiveness — a host has no reason to call either, since calling them
|
|
31
|
-
* would mean writing policy or wording that has one home already.
|
|
32
|
-
*/
|
|
33
|
-
export { deriveAdvisories, renderAdvisory, sessionAdvisory, shapeOf, type AdvisoryAudience, type AdvisoryInput, type AdvisoryShape, type WorkspaceAdvisory } from "./advisory.js";
|
|
34
|
-
export { pathExists } from "./read.js";
|
|
35
|
-
export { cancelledNote, truncateOutput } from "./format.js";
|
|
36
|
-
export { openWorkspace, openWorkspaceFs, workspaceNameFromRuntime, WORKSPACE_RUNTIME_KEY, type WorkspaceHost } from "./open.js";
|
|
37
|
-
export { withShell, withShellTranscript } from "./shell.js";
|
|
38
|
-
export { workspaceExec, DEFAULT_CWD, DEFAULT_TIMEOUT_MS, type WorkspaceClientConfig } from "./exec.js";
|
|
39
|
-
/**
|
|
40
|
-
* The object itself. The modules below import the client-side leaves beside
|
|
41
|
-
* them, never this barrel: a cycle through a module that builds a class at
|
|
42
|
-
* import time is a base that evaluates `undefined`.
|
|
43
|
-
*/
|
|
44
|
-
export { WorkspaceObjectBase, IDLE_RECLAIM_MS, WORKSPACE_DIR, workspaceName, type WorkspaceObjectConfig, type WorkspaceGitConfig } from "./object.js";
|
|
45
|
-
export { InstallJob, type InstallJobDeps, type InstallTarget } from "./install-job.js";
|
|
46
|
-
export type { DepsSnapshotRecord } from "./deps-snapshot.js";
|
|
47
|
-
export { WorkspaceSync, SYNC_DRAIN_BUDGET_MS, SYNC_DRAIN_RESUME_MS, SYNC_DRAIN_MAX_BACKOFF_MS, syncRetryDelayMs, type DrainOutcome, type SyncDrainIntent, type WorkspaceSyncDeps } from "./sync.js";
|
|
48
|
-
export { ContainerTrust, TRUST_CA_COMMAND, type ContainerTrustDeps } from "./ca-trust.js";
|
|
49
|
-
export { WorkspaceGitHost, type GitHostDeps } from "./git-host.js";
|
|
50
|
-
export type { WorkspaceWakeHandlers } from "./wake.js";
|
package/dist/workspace/index.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `@dynamicagents/plugins/workspace` — the Durable Object a container workspace
|
|
3
|
-
* lives in, and the client side every other plugin reaches it through.
|
|
4
|
-
*
|
|
5
|
-
* The filesystem **is** a Durable Object's SQLite, mounted into the container
|
|
6
|
-
* over FUSE by `computerd`. Commands see a normal `/workspace`; the Worker reads
|
|
7
|
-
* the same tree over RPC; and when the container is replaced the tree is pushed
|
|
8
|
-
* back into the new one — so a checkout outlives the container that held it.
|
|
9
|
-
*
|
|
10
|
-
* `WorkspaceObjectBase` is the object: container backend, egress, CA trust,
|
|
11
|
-
* credentialed git, the dependency install, the sync drain and idle reclaim. A
|
|
12
|
-
* host subclasses it and answers a short config. Everything else here is what
|
|
13
|
-
* reaches it from outside: `openWorkspace`, `workspaceExec`, and the advisory
|
|
14
|
-
* vocabulary it reports its state in.
|
|
15
|
-
*
|
|
16
|
-
* `@dynamicagents/plugins/computer` is the agent's tools over it; `/repo` and
|
|
17
|
-
* `/scratch` take `workspaceExec` injected.
|
|
18
|
-
*
|
|
19
|
-
* Requires the Workers **Paid** plan (containers) and a Durable Object binding
|
|
20
|
-
* whose class extends `WorkspaceObjectBase` — see the README for the wrangler
|
|
21
|
-
* block.
|
|
22
|
-
*/
|
|
23
|
-
/** How a repository installs its dependencies — the mechanical half. */
|
|
24
|
-
export { DEFAULT_INSTALL_PLAN, installFingerprint, resolveInstallCommand } from "./install.js";
|
|
25
|
-
/**
|
|
26
|
-
* The workspace-advisory vocabulary, which a host needs all of: the type to
|
|
27
|
-
* return over RPC, `deriveAdvisories` to build it from what it already knows,
|
|
28
|
-
* and `sessionAdvisory` for a host driving a whole session rather than one
|
|
29
|
-
* command. `shapeOf` and `renderAdvisory` are exported for the specs that hold
|
|
30
|
-
* their exhaustiveness — a host has no reason to call either, since calling them
|
|
31
|
-
* would mean writing policy or wording that has one home already.
|
|
32
|
-
*/
|
|
33
|
-
export { deriveAdvisories, renderAdvisory, sessionAdvisory, shapeOf } from "./advisory.js";
|
|
34
|
-
// A host implementing `InstallProbe` needs exactly this, and hand-rolling it
|
|
35
|
-
// loses the fast path: across a Durable Object boundary `fs` is a stub carrying
|
|
36
|
-
// `exists`, which a `stat`-only probe never asks for.
|
|
37
|
-
export { pathExists } from "./read.js";
|
|
38
|
-
export { cancelledNote, truncateOutput } from "./format.js";
|
|
39
|
-
export { openWorkspace, openWorkspaceFs, workspaceNameFromRuntime, WORKSPACE_RUNTIME_KEY } from "./open.js";
|
|
40
|
-
export { withShell, withShellTranscript } from "./shell.js";
|
|
41
|
-
export { workspaceExec, DEFAULT_CWD, DEFAULT_TIMEOUT_MS } from "./exec.js";
|
|
42
|
-
/**
|
|
43
|
-
* The object itself. The modules below import the client-side leaves beside
|
|
44
|
-
* them, never this barrel: a cycle through a module that builds a class at
|
|
45
|
-
* import time is a base that evaluates `undefined`.
|
|
46
|
-
*/
|
|
47
|
-
export { WorkspaceObjectBase, IDLE_RECLAIM_MS, WORKSPACE_DIR, workspaceName } from "./object.js";
|
|
48
|
-
// The dependency install, exported because a host that wants to report on one —
|
|
49
|
-
// or a spec that drives it — needs the type, not because anything but
|
|
50
|
-
// `./object.ts` constructs it.
|
|
51
|
-
export { InstallJob } from "./install-job.js";
|
|
52
|
-
// The pull the library owns no alarm for. Its constants are exported because a
|
|
53
|
-
// host deferring to a drain has to back off at the same rate this does.
|
|
54
|
-
export { WorkspaceSync, SYNC_DRAIN_BUDGET_MS, SYNC_DRAIN_RESUME_MS, SYNC_DRAIN_MAX_BACKOFF_MS, syncRetryDelayMs } from "./sync.js";
|
|
55
|
-
// `TRUST_CA_COMMAND` is exported so a host can assert what its image will be
|
|
56
|
-
// asked to run — see the file for why this cannot live in an entrypoint.
|
|
57
|
-
export { ContainerTrust, TRUST_CA_COMMAND } from "./ca-trust.js";
|
|
58
|
-
export { WorkspaceGitHost } from "./git-host.js";
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { type Workspace } from "@cloudflare/computer";
|
|
2
|
-
import type { Scheduler } from "@dynamicagents/core/alarm";
|
|
3
|
-
import { type InstallPlan, type InstallState } from "./install.js";
|
|
4
|
-
import type { WorkspaceWakeHandlers } from "./wake.js";
|
|
5
|
-
export interface InstallJobDeps {
|
|
6
|
-
storage: DurableObjectStorage;
|
|
7
|
-
scheduler: Scheduler<WorkspaceWakeHandlers>;
|
|
8
|
-
workspace: () => Workspace;
|
|
9
|
-
/** How this deployment installs dependencies for this agent's checkouts. */
|
|
10
|
-
plan: () => InstallPlan;
|
|
11
|
-
/** How long an install may run before it is killed. */
|
|
12
|
-
timeoutMs: () => number;
|
|
13
|
-
/** Set only when the workspace is over its ceiling. */
|
|
14
|
-
headroom: () => {
|
|
15
|
-
bytes: number;
|
|
16
|
-
capBytes: number;
|
|
17
|
-
} | undefined;
|
|
18
|
-
/** The object's own entry-point bookkeeping, which an install still owes. */
|
|
19
|
-
touch: () => Promise<void>;
|
|
20
|
-
ready: () => Promise<void>;
|
|
21
|
-
/** Hand a drain to the invocation, for the caller that can hold one. */
|
|
22
|
-
waitUntil: (promise: Promise<unknown>) => void;
|
|
23
|
-
/** A container was replaced, so nothing believed about it still holds. */
|
|
24
|
-
containerGone: () => Promise<void>;
|
|
25
|
-
/**
|
|
26
|
-
* Storage entries the host keeps about a tree an install finished, written in
|
|
27
|
-
* the same write as that install's verdict — nothing can read the one without
|
|
28
|
-
* the other.
|
|
29
|
-
*/
|
|
30
|
-
installedRecords: (tree: {
|
|
31
|
-
dir: string;
|
|
32
|
-
fingerprint: string;
|
|
33
|
-
at: number;
|
|
34
|
-
}) => Record<string, unknown>;
|
|
35
|
-
/** After that write: an install exited 0, so this container holds the tree. */
|
|
36
|
-
installed: (tree: {
|
|
37
|
-
dir: string;
|
|
38
|
-
fingerprint: string;
|
|
39
|
-
at: number;
|
|
40
|
-
}) => Promise<void>;
|
|
41
|
-
tag: () => string;
|
|
42
|
-
id: () => string;
|
|
43
|
-
}
|
|
44
|
-
/** Where an install goes: the checkout, and the repository for its override. */
|
|
45
|
-
export interface InstallTarget {
|
|
46
|
-
dir: string;
|
|
47
|
-
repo?: string;
|
|
48
|
-
}
|
|
49
|
-
export declare class InstallJob {
|
|
50
|
-
#private;
|
|
51
|
-
private readonly deps;
|
|
52
|
-
constructor(deps: InstallJobDeps);
|
|
53
|
-
/**
|
|
54
|
-
* Start a dependency install the moment we can see one will be needed.
|
|
55
|
-
*
|
|
56
|
-
* The signal is {@link CONTAINER_TREE_KEY}: a local read, true only while the
|
|
57
|
-
* container that ran the install is the one running.
|
|
58
|
-
*
|
|
59
|
-
* Armed as soon as a container is up or a command is about to start one,
|
|
60
|
-
* because the model's first minute is README-reading and `git status` — an
|
|
61
|
-
* install armed there runs *through* that minute, where one armed on the first
|
|
62
|
-
* `npm` command charges its full time to that command.
|
|
63
|
-
*
|
|
64
|
-
* It writes `running` before anything is running: the alarm has not fired yet,
|
|
65
|
-
* and a `done` record would let an `npm` command through against a tree that
|
|
66
|
-
* is not there. That also makes this self-limiting — the next call sees
|
|
67
|
-
* `running` and stops.
|
|
68
|
-
*/
|
|
69
|
-
armIfTreeMissing(): Promise<void>;
|
|
70
|
-
/** Where the last install ran, for the container setup's marker read. */
|
|
71
|
-
dir(): Promise<string | undefined>;
|
|
72
|
-
/** Where the last install ran, and for which repository's override. */
|
|
73
|
-
target(): Promise<InstallTarget | undefined>;
|
|
74
|
-
/**
|
|
75
|
-
* The fingerprint an install into `target` would write as its marker, from the
|
|
76
|
-
* checkout as it stands — `null` when there is nothing to install there.
|
|
77
|
-
*/
|
|
78
|
-
fingerprintFor(target: InstallTarget): Promise<string | null>;
|
|
79
|
-
/** What `dir`'s install inputs hash to — see `rootFingerprint`. */
|
|
80
|
-
rootFingerprint(dir: string): Promise<string | null>;
|
|
81
|
-
/** The tree this container holds, if a finished install says it does. */
|
|
82
|
-
tree(): Promise<{
|
|
83
|
-
dir: string;
|
|
84
|
-
fingerprint: string | null;
|
|
85
|
-
at: number;
|
|
86
|
-
} | undefined>;
|
|
87
|
-
/**
|
|
88
|
-
* Record a tree this container came up holding — restored with a snapshot of
|
|
89
|
-
* the container that installed it — as if this container had installed it.
|
|
90
|
-
*
|
|
91
|
-
* Only for a tree whose marker the setup read and matched against the checkout
|
|
92
|
-
* as it stands; see `./deps-snapshot.ts`. So the last install's context moves
|
|
93
|
-
* to it too: a checkout that moved since that install would otherwise read as
|
|
94
|
-
* missing its tree, and arm an install that finds the tree already there.
|
|
95
|
-
*/
|
|
96
|
-
adopt(tree: {
|
|
97
|
-
dir: string;
|
|
98
|
-
fingerprint: string;
|
|
99
|
-
}): Promise<void>;
|
|
100
|
-
/** The container went away, and its tree with it. */
|
|
101
|
-
containerGone(): Promise<void>;
|
|
102
|
-
/**
|
|
103
|
-
* Check the record against the marker a new isolate's setup read.
|
|
104
|
-
*
|
|
105
|
-
* The record can outlive its container in an isolate that did not watch it
|
|
106
|
-
* exit; the marker cannot.
|
|
107
|
-
*/
|
|
108
|
-
reconcile(marker: string | null): Promise<void>;
|
|
109
|
-
/**
|
|
110
|
-
* The record exactly as the job wrote it, with no staleness bound applied.
|
|
111
|
-
*
|
|
112
|
-
* {@link state} is what almost everything wants. This is for the one caller
|
|
113
|
-
* that must not repair anything on the way past: the container-idle handler,
|
|
114
|
-
* which only needs to know whether something is running before it destroys the
|
|
115
|
-
* container underneath it.
|
|
116
|
-
*/
|
|
117
|
-
read(): Promise<InstallState>;
|
|
118
|
-
/**
|
|
119
|
-
* Start installing this checkout's dependencies, and return without waiting.
|
|
120
|
-
*
|
|
121
|
-
* Called from `repo_clone` through the repo plugin's `afterCheckout` hook, so
|
|
122
|
-
* it runs inside a model turn and must not block on the install — 225 seconds
|
|
123
|
-
* for slack-gatekeeper, against a turn that is cut at fifteen minutes.
|
|
124
|
-
*
|
|
125
|
-
* That caller is a model turn, which lives long enough to hold the drain handed
|
|
126
|
-
* to `ctx.waitUntil` below. **A short-lived caller cannot**, which is why an
|
|
127
|
-
* install the alarm drives is awaited inside that alarm rather than calling
|
|
128
|
-
* this.
|
|
129
|
-
*/
|
|
130
|
-
start(req: {
|
|
131
|
-
dir: string;
|
|
132
|
-
repo?: string;
|
|
133
|
-
}): Promise<InstallState>;
|
|
134
|
-
/**
|
|
135
|
-
* Whether this container holds a finished tree, asked only when it qualifies a
|
|
136
|
-
* `deps-broken` advisory (see `deriveAdvisories`).
|
|
137
|
-
*/
|
|
138
|
-
treePresentIfItMatters(install: InstallState): Promise<boolean>;
|
|
139
|
-
/**
|
|
140
|
-
* The install record itself, with its staleness bound and re-attach applied.
|
|
141
|
-
*
|
|
142
|
-
* Split from {@link advisories} so `startInstall` can consult the record
|
|
143
|
-
* without going through the `node_modules` probe, which needs a container and
|
|
144
|
-
* has nothing to say about whether an install may start.
|
|
145
|
-
*
|
|
146
|
-
* Re-attaches on the way past. An isolate reset leaves the record saying
|
|
147
|
-
* `running` with nothing draining it, and without this the state would say
|
|
148
|
-
* `running` forever while the command had long since finished.
|
|
149
|
-
*/
|
|
150
|
-
state(): Promise<InstallState>;
|
|
151
|
-
/**
|
|
152
|
-
* When a reinstall was queued, if one is waiting to run.
|
|
153
|
-
*
|
|
154
|
-
* Read by {@link file://./advisory.ts deriveAdvisories}, which is the only
|
|
155
|
-
* caller that needs it: a `failed` record with a repair already queued is a
|
|
156
|
-
* transient condition wearing a permanent record's clothes.
|
|
157
|
-
*/
|
|
158
|
-
reinstallArmedAt(): Promise<number | undefined>;
|
|
159
|
-
/**
|
|
160
|
-
* The armed reinstall came due.
|
|
161
|
-
*
|
|
162
|
-
* `clearArmed` first and unconditionally: this handler runs for minutes, and
|
|
163
|
-
* the stamp left in place is what a second arming would recognise as its own.
|
|
164
|
-
* The reservation in `#beginInstall` would catch a double, but the cheaper
|
|
165
|
-
* answer is not to schedule one.
|
|
166
|
-
*/
|
|
167
|
-
onRun(): Promise<void>;
|
|
168
|
-
/** The watchdog: an install still running that nobody is draining. */
|
|
169
|
-
onWatch(): Promise<void>;
|
|
170
|
-
}
|