agent-hitch 0.1.1 → 0.2.1
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 +235 -132
- package/README.zh-CN.md +335 -0
- package/dist/bin/hitch.js +9 -0
- package/dist/bin/hitch.js.map +1 -0
- package/dist/scripts/check-architecture.js +159 -0
- package/dist/scripts/check-architecture.js.map +1 -0
- package/dist/scripts/check-release.js +25 -0
- package/dist/scripts/check-release.js.map +1 -0
- package/dist/scripts/check-syntax.js +32 -0
- package/dist/scripts/check-syntax.js.map +1 -0
- package/dist/src/adapters/catalog.js +55 -0
- package/dist/src/adapters/catalog.js.map +1 -0
- package/dist/src/adapters/contract.js +2 -0
- package/dist/src/adapters/contract.js.map +1 -0
- package/dist/src/adapters/discovery.js +22 -0
- package/dist/src/adapters/discovery.js.map +1 -0
- package/dist/src/adapters/index.js +3 -0
- package/dist/src/adapters/index.js.map +1 -0
- package/dist/src/adapters/providers/claude.js +69 -0
- package/dist/src/adapters/providers/claude.js.map +1 -0
- package/dist/src/adapters/providers/codex.js +74 -0
- package/dist/src/adapters/providers/codex.js.map +1 -0
- package/dist/src/adapters/providers/deepseek.js +51 -0
- package/dist/src/adapters/providers/deepseek.js.map +1 -0
- package/dist/src/adapters/providers/opencode.js +73 -0
- package/dist/src/adapters/providers/opencode.js.map +1 -0
- package/dist/src/adapters/providers/pi.js +82 -0
- package/dist/src/adapters/providers/pi.js.map +1 -0
- package/dist/src/adapters/providers/shared.js +82 -0
- package/dist/src/adapters/providers/shared.js.map +1 -0
- package/dist/src/artifacts/index.js +3 -0
- package/dist/src/artifacts/index.js.map +1 -0
- package/dist/src/artifacts/integrity.js +188 -0
- package/dist/src/artifacts/integrity.js.map +1 -0
- package/dist/src/artifacts/preparer.js +379 -0
- package/dist/src/artifacts/preparer.js.map +1 -0
- package/dist/src/artifacts/store.js +87 -0
- package/dist/src/artifacts/store.js.map +1 -0
- package/dist/src/artifacts/types.js +2 -0
- package/dist/src/artifacts/types.js.map +1 -0
- package/dist/src/backends/contract.js +2 -0
- package/dist/src/backends/contract.js.map +1 -0
- package/dist/src/backends/harbor/backend.js +305 -0
- package/dist/src/backends/harbor/backend.js.map +1 -0
- package/dist/src/backends/harbor/index.js +4 -0
- package/dist/src/backends/harbor/index.js.map +1 -0
- package/dist/src/backends/harbor/local-git-transport.js +447 -0
- package/dist/src/backends/harbor/local-git-transport.js.map +1 -0
- package/dist/src/backends/harbor/tools.js +314 -0
- package/dist/src/backends/harbor/tools.js.map +1 -0
- package/dist/src/backends/index.js +4 -0
- package/dist/src/backends/index.js.map +1 -0
- package/dist/src/cli/arguments.js +123 -0
- package/dist/src/cli/arguments.js.map +1 -0
- package/dist/src/cli/commands/compare.js +55 -0
- package/dist/src/cli/commands/compare.js.map +1 -0
- package/dist/src/cli/commands/daemon.js +106 -0
- package/dist/src/cli/commands/daemon.js.map +1 -0
- package/dist/src/cli/commands/eval.js +126 -0
- package/dist/src/cli/commands/eval.js.map +1 -0
- package/dist/src/cli/commands/feedback.js +84 -0
- package/dist/src/cli/commands/feedback.js.map +1 -0
- package/dist/src/cli/commands/inspect.js +20 -0
- package/dist/src/cli/commands/inspect.js.map +1 -0
- package/dist/src/cli/commands/list.js +17 -0
- package/dist/src/cli/commands/list.js.map +1 -0
- package/dist/src/cli/commands/prepare.js +21 -0
- package/dist/src/cli/commands/prepare.js.map +1 -0
- package/dist/src/cli/commands/resolve.js +17 -0
- package/dist/src/cli/commands/resolve.js.map +1 -0
- package/dist/src/cli/commands/run.js +83 -0
- package/dist/src/cli/commands/run.js.map +1 -0
- package/dist/src/cli/commands/runs.js +45 -0
- package/dist/src/cli/commands/runs.js.map +1 -0
- package/dist/src/cli/commands/trajectory.js +31 -0
- package/dist/src/cli/commands/trajectory.js.map +1 -0
- package/dist/src/cli/commands/workspace.js +44 -0
- package/dist/src/cli/commands/workspace.js.map +1 -0
- package/dist/src/cli/index.js +2 -0
- package/dist/src/cli/index.js.map +1 -0
- package/dist/src/cli/main.js +48 -0
- package/dist/src/cli/main.js.map +1 -0
- package/dist/src/cli/output.js +96 -0
- package/dist/src/cli/output.js.map +1 -0
- package/dist/src/controller-runtime/hash.js +353 -0
- package/dist/src/controller-runtime/hash.js.map +1 -0
- package/dist/src/controller-runtime/index.js +3 -0
- package/dist/src/controller-runtime/index.js.map +1 -0
- package/dist/src/controller-runtime/store.js +318 -0
- package/dist/src/controller-runtime/store.js.map +1 -0
- package/dist/src/daemon/auth.js +108 -0
- package/dist/src/daemon/auth.js.map +1 -0
- package/dist/src/daemon/client.js +76 -0
- package/dist/src/daemon/client.js.map +1 -0
- package/dist/src/daemon/index.js +5 -0
- package/dist/src/daemon/index.js.map +1 -0
- package/dist/src/daemon/launcher.js +24 -0
- package/dist/src/daemon/launcher.js.map +1 -0
- package/dist/src/daemon/scheduler.js +161 -0
- package/dist/src/daemon/scheduler.js.map +1 -0
- package/dist/src/daemon/server.js +316 -0
- package/dist/src/daemon/server.js.map +1 -0
- package/dist/src/domain/artifacts.js +2 -0
- package/dist/src/domain/artifacts.js.map +1 -0
- package/dist/src/domain/controller-runtime.js +2 -0
- package/dist/src/domain/controller-runtime.js.map +1 -0
- package/dist/src/domain/eval-records.js +2 -0
- package/dist/src/domain/eval-records.js.map +1 -0
- package/dist/src/domain/evals.js +2 -0
- package/dist/src/domain/evals.js.map +1 -0
- package/dist/src/domain/feedback.js +2 -0
- package/dist/src/domain/feedback.js.map +1 -0
- package/dist/src/domain/ids.js +10 -0
- package/dist/src/domain/ids.js.map +1 -0
- package/dist/src/domain/index.js +11 -0
- package/dist/src/domain/index.js.map +1 -0
- package/dist/src/domain/revisions.js +2 -0
- package/dist/src/domain/revisions.js.map +1 -0
- package/dist/src/domain/runs.js +3 -0
- package/dist/src/domain/runs.js.map +1 -0
- package/dist/src/domain/trajectories.js +2 -0
- package/dist/src/domain/trajectories.js.map +1 -0
- package/dist/src/domain/validation.js +429 -0
- package/dist/src/domain/validation.js.map +1 -0
- package/dist/src/domain/workspaces.js +2 -0
- package/dist/src/domain/workspaces.js.map +1 -0
- package/dist/src/evals/events.js +67 -0
- package/dist/src/evals/events.js.map +1 -0
- package/dist/src/evals/index.js +5 -0
- package/dist/src/evals/index.js.map +1 -0
- package/dist/src/evals/records.js +55 -0
- package/dist/src/evals/records.js.map +1 -0
- package/dist/src/evals/request.js +109 -0
- package/dist/src/evals/request.js.map +1 -0
- package/dist/src/evals/service.js +227 -0
- package/dist/src/evals/service.js.map +1 -0
- package/dist/src/evals/trial-import.js +394 -0
- package/dist/src/evals/trial-import.js.map +1 -0
- package/dist/src/feedback/index.js +2 -0
- package/dist/src/feedback/index.js.map +1 -0
- package/dist/src/feedback/service.js +314 -0
- package/dist/src/feedback/service.js.map +1 -0
- package/dist/src/foundation/config.js +54 -0
- package/dist/src/foundation/config.js.map +1 -0
- package/dist/src/foundation/errors.js +14 -0
- package/dist/src/foundation/errors.js.map +1 -0
- package/dist/src/foundation/executable.js +135 -0
- package/dist/src/foundation/executable.js.map +1 -0
- package/dist/src/foundation/fs.js +45 -0
- package/dist/src/foundation/fs.js.map +1 -0
- package/dist/src/foundation/hash.js +24 -0
- package/dist/src/foundation/hash.js.map +1 -0
- package/dist/src/foundation/index.js +11 -0
- package/dist/src/foundation/index.js.map +1 -0
- package/dist/src/foundation/line-stream.js +20 -0
- package/dist/src/foundation/line-stream.js.map +1 -0
- package/dist/src/foundation/locks.js +114 -0
- package/dist/src/foundation/locks.js.map +1 -0
- package/dist/src/foundation/package-root.js +41 -0
- package/dist/src/foundation/package-root.js.map +1 -0
- package/dist/src/foundation/process.js +50 -0
- package/dist/src/foundation/process.js.map +1 -0
- package/dist/src/revisions/index.js +4 -0
- package/dist/src/revisions/index.js.map +1 -0
- package/dist/src/revisions/reference.js +97 -0
- package/dist/src/revisions/reference.js.map +1 -0
- package/dist/src/revisions/resolver.js +25 -0
- package/dist/src/revisions/resolver.js.map +1 -0
- package/dist/src/revisions/sources/git.js +180 -0
- package/dist/src/revisions/sources/git.js.map +1 -0
- package/dist/src/revisions/sources/installed.js +45 -0
- package/dist/src/revisions/sources/installed.js.map +1 -0
- package/dist/src/revisions/sources/npm.js +97 -0
- package/dist/src/revisions/sources/npm.js.map +1 -0
- package/dist/src/runs/compare.js +132 -0
- package/dist/src/runs/compare.js.map +1 -0
- package/dist/src/runs/events.js +79 -0
- package/dist/src/runs/events.js.map +1 -0
- package/dist/src/runs/executor.js +480 -0
- package/dist/src/runs/executor.js.map +1 -0
- package/dist/src/runs/finalizer.js +22 -0
- package/dist/src/runs/finalizer.js.map +1 -0
- package/dist/src/runs/identity.js +35 -0
- package/dist/src/runs/identity.js.map +1 -0
- package/dist/src/runs/index.js +11 -0
- package/dist/src/runs/index.js.map +1 -0
- package/dist/src/runs/manifest.js +70 -0
- package/dist/src/runs/manifest.js.map +1 -0
- package/dist/src/runs/outcome.js +49 -0
- package/dist/src/runs/outcome.js.map +1 -0
- package/dist/src/runs/query.js +104 -0
- package/dist/src/runs/query.js.map +1 -0
- package/dist/src/runs/queued.js +54 -0
- package/dist/src/runs/queued.js.map +1 -0
- package/dist/src/runs/records.js +288 -0
- package/dist/src/runs/records.js.map +1 -0
- package/dist/src/runs/request.js +169 -0
- package/dist/src/runs/request.js.map +1 -0
- package/dist/src/trajectories/contract.js +17 -0
- package/dist/src/trajectories/contract.js.map +1 -0
- package/dist/src/trajectories/format.js +127 -0
- package/dist/src/trajectories/format.js.map +1 -0
- package/dist/src/trajectories/index.js +7 -0
- package/dist/src/trajectories/index.js.map +1 -0
- package/dist/src/trajectories/projector.js +385 -0
- package/dist/src/trajectories/projector.js.map +1 -0
- package/dist/src/trajectories/provider-capture.js +133 -0
- package/dist/src/trajectories/provider-capture.js.map +1 -0
- package/dist/src/trajectories/providers/deepseek.js +179 -0
- package/dist/src/trajectories/providers/deepseek.js.map +1 -0
- package/dist/src/trajectories/store.js +421 -0
- package/dist/src/trajectories/store.js.map +1 -0
- package/dist/src/workspaces/copy.js +142 -0
- package/dist/src/workspaces/copy.js.map +1 -0
- package/dist/src/workspaces/digest.js +47 -0
- package/dist/src/workspaces/digest.js.map +1 -0
- package/dist/src/workspaces/git.js +164 -0
- package/dist/src/workspaces/git.js.map +1 -0
- package/dist/src/workspaces/index.js +6 -0
- package/dist/src/workspaces/index.js.map +1 -0
- package/dist/src/workspaces/lifecycle.js +313 -0
- package/dist/src/workspaces/lifecycle.js.map +1 -0
- package/dist/src/workspaces/planner.js +80 -0
- package/dist/src/workspaces/planner.js.map +1 -0
- package/dist/src/workspaces/store.js +25 -0
- package/dist/src/workspaces/store.js.map +1 -0
- package/dist/src/workspaces/types.js +4 -0
- package/dist/src/workspaces/types.js.map +1 -0
- package/dist/src/workspaces/utils.js +56 -0
- package/dist/src/workspaces/utils.js.map +1 -0
- package/docs/schemas/controller-runtime-manifest.schema.json +57 -0
- package/docs/schemas/controller-runtime-ref.schema.json +16 -0
- package/docs/schemas/eval-request.schema.json +2 -0
- package/docs/schemas/eval-result.schema.json +36 -1
- package/docs/schemas/local-git-transport-manifest.schema.json +34 -0
- package/docs/schemas/message-feedback.schema.json +37 -0
- package/docs/schemas/result.schema.json +9 -0
- package/docs/schemas/run-context.schema.json +39 -0
- package/docs/schemas/run-manifest.schema.json +81 -0
- package/docs/schemas/run-request.schema.json +16 -1
- package/docs/schemas/trajectory-ref.schema.json +73 -0
- package/integrations/harbor/hitch_harbor_agent.py +551 -5
- package/package.json +37 -11
- package/bin/hitch.js +0 -9
- package/src/adapters.js +0 -435
- package/src/artifacts.js +0 -949
- package/src/cli.js +0 -505
- package/src/config.js +0 -51
- package/src/daemon.js +0 -416
- package/src/engine.js +0 -400
- package/src/errors.js +0 -12
- package/src/eval-tools.js +0 -334
- package/src/evals.js +0 -276
- package/src/events.js +0 -69
- package/src/fs.js +0 -43
- package/src/harbor-backend.js +0 -285
- package/src/harness-reference.js +0 -78
- package/src/line-stream.js +0 -17
- package/src/locks.js +0 -33
- package/src/process.js +0 -49
- package/src/registry.js +0 -84
- package/src/scheduler.js +0 -156
- package/src/workspaces.js +0 -893
package/src/scheduler.js
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { readdir } from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { createQueuedRun, executeRun } from "./engine.js";
|
|
4
|
-
import { atomicWriteJSON, ensureDir, readJSON } from "./fs.js";
|
|
5
|
-
import { SCHEMA_VERSION } from "./config.js";
|
|
6
|
-
import { cancelPlannedWorkspace, recoverInterruptedWorkspace } from "./workspaces.js";
|
|
7
|
-
|
|
8
|
-
export class Scheduler {
|
|
9
|
-
constructor({ runsRoot, root = path.dirname(runsRoot), maxConcurrent = 4, onEvent = () => {} }) {
|
|
10
|
-
this.runsRoot = runsRoot;
|
|
11
|
-
this.root = root;
|
|
12
|
-
this.maxConcurrent = maxConcurrent;
|
|
13
|
-
this.onEvent = onEvent;
|
|
14
|
-
this.queue = [];
|
|
15
|
-
this.active = new Map();
|
|
16
|
-
this.completions = new Map();
|
|
17
|
-
this.accepting = true;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async initialize() {
|
|
21
|
-
await ensureDir(this.runsRoot);
|
|
22
|
-
await this.recoverInterruptedRuns();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async submit(request) {
|
|
26
|
-
if (!this.accepting) throw new Error("daemon is shutting down");
|
|
27
|
-
const queued = await createQueuedRun({ request, runsRoot: this.runsRoot, root: this.root });
|
|
28
|
-
this.queue.push(queued);
|
|
29
|
-
this.onEvent({ type: "run.queued", run_id: queued.runId });
|
|
30
|
-
queueMicrotask(() => this.drain());
|
|
31
|
-
return queued.runId;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async cancel(runId) {
|
|
35
|
-
const queuedIndex = this.queue.findIndex((entry) => entry.runId === runId);
|
|
36
|
-
if (queuedIndex >= 0) {
|
|
37
|
-
const [entry] = this.queue.splice(queuedIndex, 1);
|
|
38
|
-
const now = new Date().toISOString();
|
|
39
|
-
const result = {
|
|
40
|
-
schema_version: SCHEMA_VERSION,
|
|
41
|
-
run_id: runId,
|
|
42
|
-
status: "cancelled",
|
|
43
|
-
exit_code: 9,
|
|
44
|
-
error: { code: "cancelled", message: "run cancelled before launch" },
|
|
45
|
-
completed_at: now,
|
|
46
|
-
};
|
|
47
|
-
await atomicWriteJSON(path.join(entry.directory, "result.json"), result);
|
|
48
|
-
const manifest = await readJSON(path.join(entry.directory, "manifest.json"));
|
|
49
|
-
await atomicWriteJSON(path.join(entry.directory, "manifest.json"), { ...manifest, status: "cancelled", completed_at: now });
|
|
50
|
-
await cancelPlannedWorkspace({ root: this.root, runId });
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
const active = this.active.get(runId);
|
|
54
|
-
if (!active?.cancel) return false;
|
|
55
|
-
await active.cancel();
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async status(runId) {
|
|
60
|
-
const directory = path.join(this.runsRoot, runId);
|
|
61
|
-
const manifest = await readJSON(path.join(directory, "manifest.json"), null);
|
|
62
|
-
if (!manifest) return null;
|
|
63
|
-
const result = await readJSON(path.join(directory, "result.json"), null);
|
|
64
|
-
return { manifest, result };
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
snapshot() {
|
|
68
|
-
return {
|
|
69
|
-
queued: this.queue.length,
|
|
70
|
-
running: this.active.size,
|
|
71
|
-
max_concurrent: this.maxConcurrent,
|
|
72
|
-
accepting: this.accepting,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async shutdown() {
|
|
77
|
-
this.accepting = false;
|
|
78
|
-
for (const entry of [...this.queue]) await this.cancel(entry.runId);
|
|
79
|
-
await Promise.all([...this.active.values()].map((run) => run.cancel?.()));
|
|
80
|
-
await Promise.all([...this.completions.values()]);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
drain() {
|
|
84
|
-
while (this.accepting && this.active.size < this.maxConcurrent && this.queue.length > 0) {
|
|
85
|
-
const entry = this.queue.shift();
|
|
86
|
-
const controller = new AbortController();
|
|
87
|
-
this.active.set(entry.runId, { cancel: async () => controller.abort() });
|
|
88
|
-
const completion = executeRun({
|
|
89
|
-
runId: entry.runId,
|
|
90
|
-
request: entry.request,
|
|
91
|
-
runsRoot: this.runsRoot,
|
|
92
|
-
root: this.root,
|
|
93
|
-
resolvedRevision: entry.resolvedRevision,
|
|
94
|
-
workspacePlan: entry.workspacePlan,
|
|
95
|
-
onEvent: this.onEvent,
|
|
96
|
-
signal: controller.signal,
|
|
97
|
-
onProcess: (processControl) => {
|
|
98
|
-
if (processControl) this.active.set(entry.runId, {
|
|
99
|
-
...processControl,
|
|
100
|
-
cancel: async () => controller.abort(),
|
|
101
|
-
});
|
|
102
|
-
},
|
|
103
|
-
}).catch(async (error) => {
|
|
104
|
-
await this.recordUnexpectedFailure(entry, error);
|
|
105
|
-
this.onEvent({ type: "scheduler.error", run_id: entry.runId, error: error.message });
|
|
106
|
-
}).finally(() => {
|
|
107
|
-
this.active.delete(entry.runId);
|
|
108
|
-
this.completions.delete(entry.runId);
|
|
109
|
-
this.drain();
|
|
110
|
-
});
|
|
111
|
-
this.completions.set(entry.runId, completion);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
async recordUnexpectedFailure(entry, error) {
|
|
116
|
-
const resultPath = path.join(entry.directory, "result.json");
|
|
117
|
-
if (await readJSON(resultPath, null)) return;
|
|
118
|
-
const now = new Date().toISOString();
|
|
119
|
-
const result = {
|
|
120
|
-
schema_version: SCHEMA_VERSION,
|
|
121
|
-
run_id: entry.runId,
|
|
122
|
-
status: "failed",
|
|
123
|
-
exit_code: 12,
|
|
124
|
-
error: { code: "scheduler_error", message: error?.message || String(error) },
|
|
125
|
-
completed_at: now,
|
|
126
|
-
};
|
|
127
|
-
await atomicWriteJSON(resultPath, result);
|
|
128
|
-
const manifestPath = path.join(entry.directory, "manifest.json");
|
|
129
|
-
const manifest = await readJSON(manifestPath, { schema_version: SCHEMA_VERSION, run_id: entry.runId });
|
|
130
|
-
await atomicWriteJSON(manifestPath, { ...manifest, status: "failed", completed_at: now });
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
async recoverInterruptedRuns() {
|
|
134
|
-
const entries = await readdir(this.runsRoot, { withFileTypes: true });
|
|
135
|
-
for (const entry of entries) {
|
|
136
|
-
if (!entry.isDirectory() || !entry.name.startsWith("run_")) continue;
|
|
137
|
-
const directory = path.join(this.runsRoot, entry.name);
|
|
138
|
-
const manifestPath = path.join(directory, "manifest.json");
|
|
139
|
-
const manifest = await readJSON(manifestPath, null);
|
|
140
|
-
const result = await readJSON(path.join(directory, "result.json"), null);
|
|
141
|
-
if (!manifest || result || !["queued", "preparing", "running"].includes(manifest.status)) continue;
|
|
142
|
-
const now = new Date().toISOString();
|
|
143
|
-
const recovered = {
|
|
144
|
-
schema_version: SCHEMA_VERSION,
|
|
145
|
-
run_id: entry.name,
|
|
146
|
-
status: "failed",
|
|
147
|
-
exit_code: 12,
|
|
148
|
-
error: { code: "daemon_restarted", message: "daemon stopped before the run completed" },
|
|
149
|
-
completed_at: now,
|
|
150
|
-
};
|
|
151
|
-
await atomicWriteJSON(path.join(directory, "result.json"), recovered);
|
|
152
|
-
await atomicWriteJSON(manifestPath, { ...manifest, status: "failed", completed_at: now });
|
|
153
|
-
await recoverInterruptedWorkspace({ root: this.root, runId: entry.name });
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|