@zhivex-ai/harness 1.4.0 → 1.4.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/CHANGELOG.md +29 -10
- package/README.md +7 -5
- package/SUPPORT.md +2 -2
- package/contracts/client-protocol-v1.schema.json +593 -0
- package/contracts/engine-api.json +156 -0
- package/contracts/public-api.json +12 -0
- package/contracts/stable-api-signatures.json +33 -33
- package/dist/acp-cli.js +54 -20
- package/dist/audit/index.d.ts +3 -0
- package/dist/audit/index.js +482 -0
- package/dist/audit/pack.d.ts +72 -0
- package/dist/audit-pack-e4vaq7np.js +532 -0
- package/dist/cli/arguments.d.ts +3 -1
- package/dist/cli/audit-pack.d.ts +24 -0
- package/dist/cli/cli-credentials.d.ts +6 -0
- package/dist/cli/cli-profiles.d.ts +4 -2
- package/dist/cli/node-engine.d.ts +2 -0
- package/dist/{cli-2h37qyvg.js → cli-1cf4dcnj.js} +245 -642
- package/dist/{cli-entry-w0hterjs.js → cli-entry-3s63zn4w.js} +40 -13
- package/dist/cli-entry-7f0cen32.js +9990 -0
- package/dist/cli-entry-a890x3kq.js +10348 -0
- package/dist/{cli-entry-20w6nh0k.js → cli-entry-hdtfef27.js} +439 -19
- package/dist/cli-entry-rgs6bxmy.js +484 -0
- package/dist/cli.js +27 -2
- package/dist/client/json-contracts.d.ts +4 -0
- package/dist/client/protocol.d.ts +133 -0
- package/dist/client/task-control-host.d.ts +400 -0
- package/dist/client/task-projection-host.d.ts +12 -0
- package/dist/client/task-projection.d.ts +168 -0
- package/dist/compat/code-support.js +28 -22
- package/dist/{config-qt69hkqj.js → config-r9fdhce6.js} +3 -3
- package/dist/{config-j9624t6t.js → config-vyajmksy.js} +1 -1
- package/dist/engine/acp.js +15 -11
- package/dist/engine/client.js +14 -10
- package/dist/engine/desktop-providers-v1.d.ts +2 -0
- package/dist/engine/desktop-providers-v1.js +23 -3
- package/dist/engine/desktop-state-v1.js +11 -8
- package/dist/engine/index.d.ts +3 -0
- package/dist/engine/index.js +101 -554
- package/dist/engine/mcp-stdio-v1.js +8 -6
- package/dist/engine/models.js +76 -4
- package/dist/engine/protocol.d.ts +2 -0
- package/dist/engine/protocol.js +110 -0
- package/dist/engine/service.js +15 -11
- package/dist/hostile-repository-demo.js +1095 -505
- package/dist/{index-937cb7y8.js → index-02pqtbbg.js} +559 -33
- package/dist/{index-pp474137.js → index-0zs2dz26.js} +766 -931
- package/dist/{index-8zjmnyw5.js → index-1265j7t2.js} +73 -6
- package/dist/index-4fx5f3k5.js +269 -0
- package/dist/{index-nmjdwd4p.js → index-4gt045j0.js} +109 -1
- package/dist/{index-6dft2vev.js → index-6599mpmy.js} +5 -3
- package/dist/{index-tfzta544.js → index-74kkpyqk.js} +9 -7
- package/dist/{index-61gthdz6.js → index-8sm2a1wa.js} +1 -1
- package/dist/index-c39197wq.js +552 -0
- package/dist/{index-5jhgatga.js → index-crta5wzv.js} +7 -6
- package/dist/{index-m34q25jj.js → index-d9zkmhz3.js} +143 -824
- package/dist/{index-pdmevfxv.js → index-dtb2c6ds.js} +5 -259
- package/dist/index-f6mqa5gk.js +1535 -0
- package/dist/index-j6zxnc8m.js +490 -0
- package/dist/{index-rkbf7dqg.js → index-mv8sb1ns.js} +5 -3
- package/dist/{index-xqxeypt5.js → index-mzydbzp8.js} +76 -4
- package/dist/{index-wg1sd3at.js → index-qfsrrnz6.js} +1 -1
- package/dist/{index-m82cfspw.js → index-sk3cap35.js} +877 -963
- package/dist/index-sstgcsr0.js +511 -0
- package/dist/index-wm9xeq1n.js +329 -0
- package/dist/index-xdbkcccf.js +719 -0
- package/dist/{index-s2k2edts.js → index-zxg4ve4j.js} +41 -1548
- package/dist/index.d.ts +3 -0
- package/dist/index.js +93 -77
- package/dist/internal/desktop/providers.d.ts +2 -0
- package/dist/models/catalog.d.ts +2 -0
- package/dist/persistence/sqlite-database.d.ts +1 -0
- package/dist/providers/azure-openai.d.ts +14 -0
- package/dist/providers/bedrock.d.ts +23 -0
- package/dist/providers/providers.d.ts +1 -1
- package/dist/runtime/durable-review-group.d.ts +33 -0
- package/dist/runtime/harness.d.ts +11 -0
- package/dist/runtime/run-interruption.d.ts +7 -0
- package/dist/runtime/shared-budget.d.ts +30 -0
- package/dist/runtime/task-continuity.d.ts +300 -77
- package/dist/service-cli.js +15 -11
- package/dist/{service-client-cli-fn54ev6w.js → service-client-cli-eqrdc9zq.js} +400 -305
- package/dist/verify-historical-migrations.js +1095 -505
- package/dist/zhx.js +27 -2
- package/docs/AUDIT_PACK.md +99 -0
- package/docs/AZURE_OPENAI.md +53 -0
- package/docs/BEDROCK.md +56 -0
- package/docs/CLI.md +15 -0
- package/docs/CLIENT_PROTOCOL.md +178 -0
- package/docs/CODE_RELEASE.md +31 -1
- package/docs/CODE_WEB_TASKS.md +116 -0
- package/docs/CONTEXT_ENGINEERING.md +59 -0
- package/docs/CREDENTIALS.md +21 -0
- package/docs/DURABLE_OPERATIONS.md +93 -1
- package/docs/ENGINE_API.md +5 -2
- package/docs/EXTENSIBILITY.md +2 -2
- package/docs/FIRST_USE.md +6 -6
- package/docs/MINIMUM_TASK_AUTHORITY.md +3 -3
- package/docs/PROJECT_MEMORY.md +1 -1
- package/docs/README.md +6 -1
- package/docs/STABILITY.md +3 -1
- package/docs/SUPPORT_MATRIX.md +1 -1
- package/docs/SUPPORT_MATRIX_1_1.md +1 -1
- package/docs/USAGE.md +3 -1
- package/docs/VERTEX.md +2 -2
- package/docs/WEB_LIMITS.md +4 -3
- package/docs/adr/0002-isolated-mcp-stdio.md +6 -3
- package/docs/support-matrix-1.1.json +3 -1
- package/docs/support-matrix.json +6 -4
- package/evaluations/code-task-ui.json +20 -0
- package/evaluations/representative-assembly-matrix.json +10 -1
- package/evaluations/task-projection.json +10 -0
- package/evaluations/task-recovery-lab.json +60 -0
- package/examples/README.md +3 -3
- package/package.json +23 -13
- package/dist/cli-entry-4ngptr62.js +0 -19900
- package/dist/index-m49jx72n.js +0 -220
package/dist/index-m49jx72n.js
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
VERTEX_TRANSIENT_ATTEMPTS,
|
|
3
|
-
classifyProviderFailure,
|
|
4
|
-
isEmptyModelTurn,
|
|
5
|
-
isRetryableProviderFailure,
|
|
6
|
-
providerDiagnostic,
|
|
7
|
-
providerDiagnosticSchema,
|
|
8
|
-
transientBackoffMs
|
|
9
|
-
} from "./index-fm84men1.js";
|
|
10
|
-
|
|
11
|
-
// src/providers/vertex-auth.ts
|
|
12
|
-
import { GoogleAuth } from "google-auth-library";
|
|
13
|
-
import { createVertex } from "@zhivex-ai/vertex";
|
|
14
|
-
import { wrapLanguageModel } from "@zhivex-ai/core";
|
|
15
|
-
var CLOUD_PLATFORM_SCOPE = "https://www.googleapis.com/auth/cloud-platform";
|
|
16
|
-
function vertexRoute(env) {
|
|
17
|
-
const projectId = (env.GOOGLE_CLOUD_PROJECT ?? "").trim();
|
|
18
|
-
const location = (env.VERTEX_LOCATION ?? "").trim();
|
|
19
|
-
if (!/^(?:[a-z][a-z0-9-]{4,61}[a-z0-9]|[0-9]{6,20})$/.test(projectId)) {
|
|
20
|
-
throw new Error("Vertex requires a valid GOOGLE_CLOUD_PROJECT.");
|
|
21
|
-
}
|
|
22
|
-
if (!/^(?:global|us|eu|[a-z]+-[a-z]+[0-9]+)$/.test(location)) {
|
|
23
|
-
throw new Error("Vertex requires an explicit valid VERTEX_LOCATION.");
|
|
24
|
-
}
|
|
25
|
-
return Object.freeze({ projectId, location });
|
|
26
|
-
}
|
|
27
|
-
function vertexConfigured(env) {
|
|
28
|
-
try {
|
|
29
|
-
vertexRoute(env);
|
|
30
|
-
return true;
|
|
31
|
-
} catch {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
var VERTEX_ENVIRONMENT = ["GOOGLE_CLOUD_PROJECT", "VERTEX_LOCATION", "GOOGLE_APPLICATION_CREDENTIALS"];
|
|
36
|
-
function vertexEnvironment(env) {
|
|
37
|
-
return Object.fromEntries(VERTEX_ENVIRONMENT.flatMap((name) => env[name] ? [[name, env[name]]] : []));
|
|
38
|
-
}
|
|
39
|
-
function vertexTokenSource(env, route, createAuth = (options) => new GoogleAuth(options)) {
|
|
40
|
-
const keyFilename = env.GOOGLE_APPLICATION_CREDENTIALS?.trim();
|
|
41
|
-
const auth = createAuth({
|
|
42
|
-
projectId: route.projectId,
|
|
43
|
-
scopes: [CLOUD_PLATFORM_SCOPE],
|
|
44
|
-
...keyFilename ? { keyFilename } : {}
|
|
45
|
-
});
|
|
46
|
-
return async () => {
|
|
47
|
-
try {
|
|
48
|
-
const token = await auth.getAccessToken();
|
|
49
|
-
if (!token)
|
|
50
|
-
throw new Error("Empty ADC token");
|
|
51
|
-
return token;
|
|
52
|
-
} catch {
|
|
53
|
-
throw new VertexAuthenticationError;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
class VertexAuthenticationError extends Error {
|
|
59
|
-
status = 401;
|
|
60
|
-
retryable = false;
|
|
61
|
-
constructor() {
|
|
62
|
-
super("Vertex ADC credentials are unavailable or could not be refreshed. Configure Application Default Credentials and retry.");
|
|
63
|
-
this.name = "VertexAuthenticationError";
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
function createVertexModel(model, env, createAuth, retry) {
|
|
67
|
-
const route = vertexRoute(env);
|
|
68
|
-
const adapter = createVertex({
|
|
69
|
-
...route,
|
|
70
|
-
getAccessToken: vertexTokenSource(env, route, createAuth)
|
|
71
|
-
})(model);
|
|
72
|
-
const attempts = retry?.attempts ?? VERTEX_TRANSIENT_ATTEMPTS;
|
|
73
|
-
const delayFor = (input) => retry?.delayMs ?? ((attempt) => input.retryBackoffMs === 0 ? 0 : transientBackoffMs(attempt, input.retryBackoffMs ?? 250));
|
|
74
|
-
const generate = async (input) => withVertexAttempts(input.abortSignal, vertexAttemptBudget(input, attempts), delayFor(input), async () => {
|
|
75
|
-
try {
|
|
76
|
-
return await adapter.generate({ ...input, maxRetries: 0 });
|
|
77
|
-
} catch (error) {
|
|
78
|
-
throw safeVertexError(error);
|
|
79
|
-
}
|
|
80
|
-
}, (result) => !isEmptyModelTurn(result));
|
|
81
|
-
const innerStream = adapter.stream?.bind(adapter);
|
|
82
|
-
const retrying = innerStream ? {
|
|
83
|
-
...adapter,
|
|
84
|
-
generate,
|
|
85
|
-
async stream(input) {
|
|
86
|
-
const events = await withVertexAttempts(input.abortSignal, vertexAttemptBudget(input, attempts), delayFor(input), () => collectVertexStream(() => innerStream({ ...input, maxRetries: 0 })), (events2) => !isEmptyVertexStream(events2));
|
|
87
|
-
return replayVertexStream(events);
|
|
88
|
-
}
|
|
89
|
-
} : { ...adapter, generate };
|
|
90
|
-
return wrapLanguageModel(retrying, [{
|
|
91
|
-
name: "harness-vertex-sanitized-errors",
|
|
92
|
-
async wrapGenerate(_context, next) {
|
|
93
|
-
try {
|
|
94
|
-
return await next();
|
|
95
|
-
} catch (error) {
|
|
96
|
-
throw safeVertexError(error);
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
async wrapStream(_context, next) {
|
|
100
|
-
let stream;
|
|
101
|
-
try {
|
|
102
|
-
stream = await next();
|
|
103
|
-
} catch (error) {
|
|
104
|
-
throw safeVertexError(error);
|
|
105
|
-
}
|
|
106
|
-
return async function* () {
|
|
107
|
-
try {
|
|
108
|
-
yield* stream;
|
|
109
|
-
} catch (error) {
|
|
110
|
-
throw safeVertexError(error);
|
|
111
|
-
}
|
|
112
|
-
}();
|
|
113
|
-
}
|
|
114
|
-
}]);
|
|
115
|
-
}
|
|
116
|
-
async function collectVertexStream(next) {
|
|
117
|
-
let stream;
|
|
118
|
-
try {
|
|
119
|
-
stream = await next();
|
|
120
|
-
} catch (error) {
|
|
121
|
-
throw safeVertexError(error);
|
|
122
|
-
}
|
|
123
|
-
const events = [];
|
|
124
|
-
try {
|
|
125
|
-
for await (const event of stream) {
|
|
126
|
-
if (event.type === "error")
|
|
127
|
-
throw safeVertexError(event.error);
|
|
128
|
-
events.push(event);
|
|
129
|
-
}
|
|
130
|
-
} catch (error) {
|
|
131
|
-
throw error instanceof Error && error.message.startsWith("Vertex request failed.") ? error : safeVertexError(error);
|
|
132
|
-
}
|
|
133
|
-
return events;
|
|
134
|
-
}
|
|
135
|
-
function isEmptyVertexStream(events) {
|
|
136
|
-
let text = "";
|
|
137
|
-
let finishReason;
|
|
138
|
-
let tools = false;
|
|
139
|
-
let media = false;
|
|
140
|
-
for (const event of events) {
|
|
141
|
-
if (event.type === "text-delta")
|
|
142
|
-
text += event.textDelta;
|
|
143
|
-
else if (event.type === "tool-call" || event.type === "tool-approval-request")
|
|
144
|
-
tools = true;
|
|
145
|
-
else if (event.type === "image-generation")
|
|
146
|
-
media = true;
|
|
147
|
-
else if (event.type === "finish")
|
|
148
|
-
finishReason = event.finishReason;
|
|
149
|
-
}
|
|
150
|
-
return isEmptyModelTurn({
|
|
151
|
-
text,
|
|
152
|
-
finishReason,
|
|
153
|
-
...tools ? { messages: [{ parts: [{ type: "tool-call" }] }] } : {},
|
|
154
|
-
...media ? { images: [{}] } : {}
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
function replayVertexStream(events) {
|
|
158
|
-
return async function* () {
|
|
159
|
-
yield* events;
|
|
160
|
-
}();
|
|
161
|
-
}
|
|
162
|
-
async function withVertexAttempts(abortSignal, attempts, delayMs, run, accept) {
|
|
163
|
-
let last;
|
|
164
|
-
for (let attempt = 0;attempt < attempts; attempt += 1) {
|
|
165
|
-
if (abortSignal?.aborted)
|
|
166
|
-
throw new DOMException("Vertex request cancelled.", "AbortError");
|
|
167
|
-
try {
|
|
168
|
-
const value = await run();
|
|
169
|
-
if (accept(value) || attempt === attempts - 1)
|
|
170
|
-
return value;
|
|
171
|
-
last = value;
|
|
172
|
-
} catch (error) {
|
|
173
|
-
const safe = error instanceof Error && (error.name === "AbortError" || error.message.startsWith("Vertex request failed.")) ? error : safeVertexError(error);
|
|
174
|
-
if (safe.name === "AbortError" || abortSignal?.aborted || attempt === attempts - 1 || !isRetryableProviderFailure(safe))
|
|
175
|
-
throw safe;
|
|
176
|
-
}
|
|
177
|
-
await sleep(delayMs(attempt));
|
|
178
|
-
}
|
|
179
|
-
return last;
|
|
180
|
-
}
|
|
181
|
-
var sleep = (ms) => ms > 0 ? new Promise((resolve) => setTimeout(resolve, ms)) : Promise.resolve();
|
|
182
|
-
function vertexAttemptBudget(input, fallback) {
|
|
183
|
-
const requested = [
|
|
184
|
-
typeof input.maxProviderRequests === "number" ? input.maxProviderRequests : undefined,
|
|
185
|
-
typeof input.maxRetries === "number" ? input.maxRetries + 1 : undefined
|
|
186
|
-
].filter((value) => value !== undefined);
|
|
187
|
-
if (requested.length === 0)
|
|
188
|
-
return Math.max(1, fallback);
|
|
189
|
-
return Math.max(1, Math.min(...requested));
|
|
190
|
-
}
|
|
191
|
-
function safeVertexError(error) {
|
|
192
|
-
if (error instanceof VertexAuthenticationError)
|
|
193
|
-
return error;
|
|
194
|
-
const record = error && typeof error === "object" ? error : {};
|
|
195
|
-
if (record.name === "AbortError")
|
|
196
|
-
return new DOMException("Vertex request cancelled.", "AbortError");
|
|
197
|
-
const failure = classifyProviderFailure(error);
|
|
198
|
-
const body = providerBody(record.responseBody) ?? providerBody(record.body);
|
|
199
|
-
const preserved = providerDiagnosticSchema.safeParse(record.provider);
|
|
200
|
-
const provider = body !== undefined ? providerDiagnostic(body, failure.httpStatus) : preserved.success ? preserved.data : providerDiagnostic(undefined, failure.httpStatus);
|
|
201
|
-
return Object.assign(new Error("Vertex request failed. Check the sanitized provider diagnosis."), {
|
|
202
|
-
...failure.httpStatus !== undefined ? { status: failure.httpStatus } : {},
|
|
203
|
-
...failure.providerStatus ? { providerStatus: failure.providerStatus } : {},
|
|
204
|
-
provider,
|
|
205
|
-
retryable: failure.retryable
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
function providerBody(value) {
|
|
209
|
-
if (typeof value === "string")
|
|
210
|
-
return value;
|
|
211
|
-
if (!value || typeof value !== "object")
|
|
212
|
-
return;
|
|
213
|
-
try {
|
|
214
|
-
return JSON.stringify(value).slice(0, 8192);
|
|
215
|
-
} catch {
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export { vertexRoute, vertexConfigured, VERTEX_ENVIRONMENT, vertexEnvironment, vertexTokenSource, createVertexModel };
|