@zhivex-ai/harness 1.2.0 → 1.3.0-rc.3
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 +19 -0
- package/README.md +7 -8
- package/contracts/engine-api.json +2587 -0
- package/dist/acp-cli.js +95 -14996
- package/dist/cli/cli-options.d.ts +2 -41
- package/dist/cli/cli-stream.d.ts +2 -167
- package/dist/cli/run-document.d.ts +2 -91
- package/dist/cli/terminal/terminal-continuation.d.ts +2 -3
- package/dist/{cli-entry-427869g9.js → cli-entry-0mmeag20.js} +49 -1
- package/dist/{cli-entry-b1mfvmxe.js → cli-entry-7h9savv5.js} +1 -2
- package/dist/{cli-entry-c2f58zj2.js → cli-entry-xmf48p6a.js} +27 -18
- package/dist/{cli-3jmy4h5h.js → cli-qgwvtk0w.js} +5 -6
- package/dist/cli.js +2 -2
- package/dist/client/continuation.d.ts +3 -0
- package/dist/client/run-document.d.ts +91 -0
- package/dist/client/stream.d.ts +167 -0
- package/dist/compat/cli-options.d.ts +41 -0
- package/dist/compat/code-support.d.ts +22 -0
- package/dist/compat/code-support.js +138 -0
- package/dist/config-6gtpxvjv.js +59 -0
- package/dist/{config-1k9t4jhh.js → config-q32jm1e6.js} +1 -1
- package/dist/engine/acp.d.ts +4 -0
- package/dist/engine/acp.js +9 -0
- package/dist/engine/client.d.ts +6 -0
- package/dist/engine/client.js +21 -0
- package/dist/engine/index.d.ts +61 -0
- package/dist/engine/index.js +477 -0
- package/dist/engine/protocol.d.ts +6 -0
- package/dist/engine/protocol.js +158 -0
- package/dist/engine/service.d.ts +5 -0
- package/dist/engine/service.js +21 -0
- package/dist/hostile-repository-demo.js +59 -1
- package/dist/index-1bx83sw4.js +4 -0
- package/dist/index-2aymdsqc.js +150 -0
- package/dist/index-41fkzt91.js +293 -0
- package/dist/index-5wjwe91x.js +9434 -0
- package/dist/index-77h9qr5h.js +326 -0
- package/dist/index-d0wrghff.js +3271 -0
- package/dist/index-f4sb0e2q.js +318 -0
- package/dist/index-fvca1xea.js +2069 -0
- package/dist/index-kfgt9yqq.js +526 -0
- package/dist/index-pgqz45fj.js +2449 -0
- package/dist/index.js +238 -18649
- package/dist/service-cli.js +10 -14502
- package/dist/{service-client-cli-yx56n0hc.js → service-client-cli-gs78wrxe.js} +2 -2
- package/dist/verify-historical-migrations.js +59 -1
- package/dist/zhx.js +2 -2
- package/docs/CODE_RELEASE.md +93 -0
- package/docs/ENGINE_API.md +111 -0
- package/docs/FIRST_USE.md +6 -6
- package/docs/README.md +5 -0
- package/docs/STABILITY.md +6 -0
- package/evaluations/representative-assembly-matrix.json +28 -1
- package/examples/README.md +1 -1
- package/package.json +35 -4
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type AgentRunOutput } from "@zhivex-ai/agents";
|
|
2
|
+
import type { ZhivexHarness } from "../runtime/harness.js";
|
|
3
|
+
export declare const runResultDocument: (result: AgentRunOutput, harness: ZhivexHarness) => {
|
|
4
|
+
schemaVersion: 1;
|
|
5
|
+
kind: "run-result";
|
|
6
|
+
runId: string;
|
|
7
|
+
status: import("@zhivex-ai/core").AgentStatus;
|
|
8
|
+
provider: string;
|
|
9
|
+
model: string;
|
|
10
|
+
output: string;
|
|
11
|
+
steps: number;
|
|
12
|
+
toolCalls: number;
|
|
13
|
+
mutations: readonly {
|
|
14
|
+
id: string;
|
|
15
|
+
operation: "create" | "move" | "quarantine" | "restore" | "update";
|
|
16
|
+
path: string;
|
|
17
|
+
destination?: string | undefined;
|
|
18
|
+
beforeDigest?: string | undefined;
|
|
19
|
+
afterDigest?: string | undefined;
|
|
20
|
+
timestamp: string;
|
|
21
|
+
quarantineId?: string | undefined;
|
|
22
|
+
}[];
|
|
23
|
+
pendingApprovals: {
|
|
24
|
+
id: string;
|
|
25
|
+
kind: "local-tool" | "provider" | "subagent";
|
|
26
|
+
name: string;
|
|
27
|
+
arguments: string;
|
|
28
|
+
childRunId?: string;
|
|
29
|
+
childAgentId?: string;
|
|
30
|
+
}[];
|
|
31
|
+
children: {
|
|
32
|
+
runId: string;
|
|
33
|
+
agentId: string | undefined;
|
|
34
|
+
toolName: string | undefined;
|
|
35
|
+
status: import("@zhivex-ai/core").AgentStatus;
|
|
36
|
+
steps: number;
|
|
37
|
+
toolCalls: number;
|
|
38
|
+
toolErrors: number;
|
|
39
|
+
usage: import("@zhivex-ai/core").TokenUsage | undefined;
|
|
40
|
+
}[];
|
|
41
|
+
usage: import("@zhivex-ai/core").TokenUsage | undefined;
|
|
42
|
+
usageLedger?: {
|
|
43
|
+
calls: number;
|
|
44
|
+
inputTokens: number;
|
|
45
|
+
outputTokens: number;
|
|
46
|
+
usageComplete: boolean;
|
|
47
|
+
estimatedUsd: number | null;
|
|
48
|
+
limitUsd: number | null;
|
|
49
|
+
schemaVersion: 1;
|
|
50
|
+
runId: string;
|
|
51
|
+
historicalUsageUnknown?: boolean | undefined;
|
|
52
|
+
costKind: "estimate-not-invoice";
|
|
53
|
+
routes: {
|
|
54
|
+
provider: string;
|
|
55
|
+
model: string;
|
|
56
|
+
calls: number;
|
|
57
|
+
inputTokens: number;
|
|
58
|
+
outputTokens: number;
|
|
59
|
+
unknownCalls: number;
|
|
60
|
+
estimatedUsd: number | null;
|
|
61
|
+
priceStatuses: ("estimate" | "missing" | "stale")[];
|
|
62
|
+
}[];
|
|
63
|
+
} | null;
|
|
64
|
+
budget: import("@zhivex-ai/core").AgentBudgetStatus;
|
|
65
|
+
costBudget?: {
|
|
66
|
+
limitUsd: number;
|
|
67
|
+
estimate: import("@zhivex-ai/core").CostEstimate;
|
|
68
|
+
};
|
|
69
|
+
scope: import("@zhivex-ai/core").AgentStoreScope | undefined;
|
|
70
|
+
capabilities: import("../index.js").HarnessModelCapabilityReport;
|
|
71
|
+
orchestration: {
|
|
72
|
+
profiles: readonly ("explorer" | "implementer" | "reviewer" | "tester")[];
|
|
73
|
+
childBudget: import("../index.js").HarnessBudget;
|
|
74
|
+
mcpServers: string[];
|
|
75
|
+
};
|
|
76
|
+
execution: {
|
|
77
|
+
backend: "oci";
|
|
78
|
+
binding: import("@zhivex-ai/core").AgentExecutionEnvironmentBinding | undefined;
|
|
79
|
+
image: import("../index.js").OciImageInspection;
|
|
80
|
+
} | {
|
|
81
|
+
binding?: never;
|
|
82
|
+
image?: never;
|
|
83
|
+
backend: "none";
|
|
84
|
+
};
|
|
85
|
+
store: {
|
|
86
|
+
backend: "file" | "sqlite";
|
|
87
|
+
stateDirectory: string;
|
|
88
|
+
migration: import("../index.js").HarnessMigrationResult | undefined;
|
|
89
|
+
};
|
|
90
|
+
stateDirectory: string;
|
|
91
|
+
};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import type { AgentStreamEvent } from "@zhivex-ai/agents";
|
|
2
|
+
export declare const CLI_JSON_SCHEMA_VERSION: 1;
|
|
3
|
+
export declare const CLI_EVENT_SCHEMA_VERSION: 1;
|
|
4
|
+
export interface StreamRunResultSource {
|
|
5
|
+
runId: string;
|
|
6
|
+
status: string;
|
|
7
|
+
provider: string;
|
|
8
|
+
model: string;
|
|
9
|
+
steps: number;
|
|
10
|
+
toolCalls: number;
|
|
11
|
+
pendingApprovals?: readonly ({
|
|
12
|
+
id: string;
|
|
13
|
+
kind: string;
|
|
14
|
+
name: string;
|
|
15
|
+
childRunId?: string;
|
|
16
|
+
childAgentId?: string;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
})[];
|
|
19
|
+
children?: readonly ({
|
|
20
|
+
runId: string;
|
|
21
|
+
status: string;
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
})[];
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Convert runtime events into a stable, line-oriented CLI contract.
|
|
28
|
+
*
|
|
29
|
+
* Tool inputs, tool outputs, provider payloads, model messages, and error text
|
|
30
|
+
* are deliberately omitted: they can contain repository content or secrets.
|
|
31
|
+
*/
|
|
32
|
+
export declare const streamEventDocument: (event: AgentStreamEvent, sequence?: number) => {
|
|
33
|
+
schemaVersion: 1;
|
|
34
|
+
kind: "run-event";
|
|
35
|
+
sequence: number;
|
|
36
|
+
type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
|
|
37
|
+
textDelta: string;
|
|
38
|
+
} | {
|
|
39
|
+
schemaVersion: 1;
|
|
40
|
+
kind: "run-event";
|
|
41
|
+
sequence: number;
|
|
42
|
+
type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
|
|
43
|
+
toolCallId: string;
|
|
44
|
+
toolName: string;
|
|
45
|
+
} | {
|
|
46
|
+
schemaVersion: 1;
|
|
47
|
+
kind: "run-event";
|
|
48
|
+
sequence: number;
|
|
49
|
+
type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
|
|
50
|
+
toolCallId: string;
|
|
51
|
+
toolName: string;
|
|
52
|
+
isError: boolean;
|
|
53
|
+
} | {
|
|
54
|
+
schemaVersion: 1;
|
|
55
|
+
kind: "run-event";
|
|
56
|
+
sequence: number;
|
|
57
|
+
type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
|
|
58
|
+
approvalRequestId: string;
|
|
59
|
+
approvalKind: "local-tool" | "provider" | "subagent";
|
|
60
|
+
toolName: string;
|
|
61
|
+
} | {
|
|
62
|
+
schemaVersion: 1;
|
|
63
|
+
kind: "run-event";
|
|
64
|
+
sequence: number;
|
|
65
|
+
type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
|
|
66
|
+
approvalRequestId: string;
|
|
67
|
+
approved: boolean;
|
|
68
|
+
} | {
|
|
69
|
+
schemaVersion: 1;
|
|
70
|
+
kind: "run-event";
|
|
71
|
+
sequence: number;
|
|
72
|
+
type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
|
|
73
|
+
provider: string;
|
|
74
|
+
} | {
|
|
75
|
+
schemaVersion: 1;
|
|
76
|
+
kind: "run-event";
|
|
77
|
+
sequence: number;
|
|
78
|
+
type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
|
|
79
|
+
provider: string;
|
|
80
|
+
partial: boolean;
|
|
81
|
+
id?: string;
|
|
82
|
+
index?: number;
|
|
83
|
+
} | {
|
|
84
|
+
schemaVersion: 1;
|
|
85
|
+
kind: "run-event";
|
|
86
|
+
sequence: number;
|
|
87
|
+
type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
|
|
88
|
+
finishReason?: import("@zhivex-ai/core").FinishReason;
|
|
89
|
+
usage?: import("@zhivex-ai/core").TokenUsage;
|
|
90
|
+
} | {
|
|
91
|
+
schemaVersion: 1;
|
|
92
|
+
kind: "run-event";
|
|
93
|
+
sequence: number;
|
|
94
|
+
type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
|
|
95
|
+
error: string;
|
|
96
|
+
} | {
|
|
97
|
+
schemaVersion: 1;
|
|
98
|
+
kind: "run-event";
|
|
99
|
+
sequence: number;
|
|
100
|
+
type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
|
|
101
|
+
currentStep: number;
|
|
102
|
+
maxSteps: number;
|
|
103
|
+
} | {
|
|
104
|
+
schemaVersion: 1;
|
|
105
|
+
kind: "run-event";
|
|
106
|
+
sequence: number;
|
|
107
|
+
type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
|
|
108
|
+
stepIndex: number;
|
|
109
|
+
} | {
|
|
110
|
+
schemaVersion: 1;
|
|
111
|
+
kind: "run-event";
|
|
112
|
+
sequence: number;
|
|
113
|
+
type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
|
|
114
|
+
stepIndex: number;
|
|
115
|
+
status: import("@zhivex-ai/core").AgentStepStatus;
|
|
116
|
+
toolCalls: number;
|
|
117
|
+
} | {
|
|
118
|
+
schemaVersion: 1;
|
|
119
|
+
kind: "run-event";
|
|
120
|
+
sequence: number;
|
|
121
|
+
type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
|
|
122
|
+
compactionId: string;
|
|
123
|
+
reasons: import("@zhivex-ai/core").AgentCompactionReason[];
|
|
124
|
+
messageCountBefore: number;
|
|
125
|
+
messageCountAfter: number;
|
|
126
|
+
} | {
|
|
127
|
+
schemaVersion: 1;
|
|
128
|
+
kind: "run-event";
|
|
129
|
+
sequence: number;
|
|
130
|
+
type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
|
|
131
|
+
runId: string;
|
|
132
|
+
status: import("@zhivex-ai/core").AgentStatus;
|
|
133
|
+
provider: string;
|
|
134
|
+
model: string;
|
|
135
|
+
} | undefined;
|
|
136
|
+
export declare const serializeStreamEvent: (event: AgentStreamEvent, sequence?: number) => string;
|
|
137
|
+
/**
|
|
138
|
+
* Project the rich final JSON document onto the redacted JSONL contract.
|
|
139
|
+
*
|
|
140
|
+
* This is deliberately a whitelist. Output text, mutations, approval
|
|
141
|
+
* arguments, scope, paths, provider payloads, and configuration bindings can
|
|
142
|
+
* contain repository or operator data and must remain exclusive to the
|
|
143
|
+
* separate final-document contract.
|
|
144
|
+
*/
|
|
145
|
+
export declare const streamResultDocument: (result: StreamRunResultSource, sequence?: number) => {
|
|
146
|
+
schemaVersion: 1;
|
|
147
|
+
kind: "run-stream-result";
|
|
148
|
+
sequence: number;
|
|
149
|
+
runId: string;
|
|
150
|
+
status: string;
|
|
151
|
+
provider: string;
|
|
152
|
+
model: string;
|
|
153
|
+
steps: number;
|
|
154
|
+
toolCalls: number;
|
|
155
|
+
pendingApprovals: {
|
|
156
|
+
id: string;
|
|
157
|
+
kind: string;
|
|
158
|
+
name: string;
|
|
159
|
+
childRunId?: string;
|
|
160
|
+
childAgentId?: string;
|
|
161
|
+
}[];
|
|
162
|
+
children: {
|
|
163
|
+
runId: string;
|
|
164
|
+
status: string;
|
|
165
|
+
}[];
|
|
166
|
+
};
|
|
167
|
+
export declare const serializeStreamResult: (result: StreamRunResultSource, sequence?: number) => string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface CliOptionDefinition {
|
|
2
|
+
repeatable: boolean;
|
|
3
|
+
conflictsWith: readonly string[];
|
|
4
|
+
}
|
|
5
|
+
export interface CliCommandOptionContract {
|
|
6
|
+
allowed: readonly string[];
|
|
7
|
+
required: readonly (string | readonly string[])[];
|
|
8
|
+
repeatable: readonly string[];
|
|
9
|
+
conflicts: Readonly<Record<string, readonly string[]>>;
|
|
10
|
+
}
|
|
11
|
+
export declare const CLI_OPTION_NAMES: readonly ["--compaction-model", "--compaction-provider", "--provider", "--model", "--reasoning", "--profile", "--route", "--workspace", "--state-dir", "--mcp-config", "--context-config", "--no-project-context", "--patch", "--preconditions", "--now", "--require-verified-delivery", "--execution", "--oci-runtime", "--oci-image", "--oci-allow-command", "--oci-shell", "--oci-max-process-runtime-ms", "--oci-max-process-output-bytes", "--oci-max-memory-mb", "--oci-max-pids", "--oci-max-cpus", "--oci-max-workspace-bytes", "--oci-max-file-write-bytes", "--oci-tmpfs-mb", "--store", "--tenant", "--user", "--namespace", "--idempotency-key", "--token-budget", "--context-tokens", "--no-token-budget", "--max-steps", "--timeout-ms", "--max-tool-calls", "--max-tool-errors", "--max-input-tokens", "--max-output-tokens", "--max-total-tokens", "--subagent-max-steps", "--subagent-max-tool-calls", "--subagent-max-tool-errors", "--subagent-max-input-tokens", "--subagent-max-output-tokens", "--subagent-max-total-tokens", "--subagent-timeout-ms", "--max-parallel-reviews", "--max-cost-usd", "--input-cost-per-million", "--output-cost-per-million", "--allow-check", "--require-capability", "--subagent", "--reviewer", "--approval-mode", "--yes", "--approve", "--deny", "--json", "--jsonl", "--session", "--continue", "--update", "--status", "--limit", "--cursor", "--before", "--reason", "--cascade", "--final", "--service", "--apply", "--help", "--version", "--search", "--pricing-file", "--usage-limit-usd"];
|
|
12
|
+
export type CliOptionName = (typeof CLI_OPTION_NAMES)[number];
|
|
13
|
+
export declare const CLI_OPTION_DEFINITIONS: Readonly<Record<CliOptionName, CliOptionDefinition>>;
|
|
14
|
+
export declare const CLI_COMMAND_OPTION_CONTRACTS: {
|
|
15
|
+
readonly init: CliCommandOptionContract;
|
|
16
|
+
readonly run: CliCommandOptionContract;
|
|
17
|
+
readonly review: CliCommandOptionContract;
|
|
18
|
+
readonly chat: CliCommandOptionContract;
|
|
19
|
+
readonly providers: CliCommandOptionContract;
|
|
20
|
+
readonly doctor: CliCommandOptionContract;
|
|
21
|
+
readonly resume: CliCommandOptionContract;
|
|
22
|
+
readonly "runs:list": CliCommandOptionContract;
|
|
23
|
+
readonly "runs:inspect": CliCommandOptionContract;
|
|
24
|
+
readonly "runs:cancel": CliCommandOptionContract;
|
|
25
|
+
readonly "runs:cleanup": CliCommandOptionContract;
|
|
26
|
+
readonly "runs:export": CliCommandOptionContract;
|
|
27
|
+
readonly "sessions:list": CliCommandOptionContract;
|
|
28
|
+
readonly "sessions:inspect": CliCommandOptionContract;
|
|
29
|
+
readonly "sessions:rename": CliCommandOptionContract;
|
|
30
|
+
readonly "sessions:fork": CliCommandOptionContract;
|
|
31
|
+
readonly "sessions:archive": CliCommandOptionContract;
|
|
32
|
+
readonly "changes:create": CliCommandOptionContract;
|
|
33
|
+
readonly "changes:verify": CliCommandOptionContract;
|
|
34
|
+
readonly "state:status": CliCommandOptionContract;
|
|
35
|
+
readonly "state:export": CliCommandOptionContract;
|
|
36
|
+
readonly "state:import": CliCommandOptionContract;
|
|
37
|
+
readonly help: CliCommandOptionContract;
|
|
38
|
+
readonly version: CliCommandOptionContract;
|
|
39
|
+
};
|
|
40
|
+
export type CliCommandOptionContractKey = keyof typeof CLI_COMMAND_OPTION_CONTRACTS;
|
|
41
|
+
export declare const validateCliCommandOptions: (commandKey: CliCommandOptionContractKey, counts: ReadonlyMap<string, number>) => void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** @experimental Explicit host helpers used by the Code terminal product. No terminal implementation. */
|
|
2
|
+
export { estimateMessages } from "../context/adaptive-compaction.js";
|
|
3
|
+
export { TASK_SOURCE_KEY, taskSources } from "../context/task-memory.js";
|
|
4
|
+
export { resolvePackageManager } from "../execution/package-manager.js";
|
|
5
|
+
export { runPortableProcess } from "../execution/process-runtime.js";
|
|
6
|
+
export { loadModelCatalog } from "../models/catalog-store.js";
|
|
7
|
+
export type { CatalogSnapshot } from "../models/catalog-store.js";
|
|
8
|
+
export { bundledModelCatalog, catalogModels, modelDescription } from "../models/catalog.js";
|
|
9
|
+
export type { ModelCatalog } from "../models/catalog.js";
|
|
10
|
+
/** Read-only diagnostic projection; never exposes a database connection or arbitrary SQL. */
|
|
11
|
+
export declare const inspectCodeStateDatabase: (databasePath: string) => {
|
|
12
|
+
integrity: string | undefined;
|
|
13
|
+
tables: string[];
|
|
14
|
+
sessionVersion: number | undefined;
|
|
15
|
+
};
|
|
16
|
+
export { modelReasoningEfforts, reasoningEffortSchema } from "../providers/reasoning.js";
|
|
17
|
+
export type { HarnessReasoningEffort } from "../providers/reasoning.js";
|
|
18
|
+
export { DEFAULT_HARNESS_MAX_STEPS } from "../runtime/config.js";
|
|
19
|
+
export { inspectRuntimeDiagnostics } from "../runtime/runtime-diagnostics.js";
|
|
20
|
+
export { harnessToolExecution } from "../runtime/tool-execution.js";
|
|
21
|
+
export { USAGE_LEDGER_KEY, formatUsageLedger, inspectUsageLedger, usagePricingSchema } from "../runtime/usage-ledger.js";
|
|
22
|
+
export { FileChangedWhileReadingError, FileSizeLimitError, UnsafeFileTypeError, readRegularFileNoFollow } from "../workspace/file-security.js";
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FileChangedWhileReadingError,
|
|
3
|
+
FileSizeLimitError,
|
|
4
|
+
SqliteDatabase,
|
|
5
|
+
TASK_SOURCE_KEY,
|
|
6
|
+
USAGE_LEDGER_KEY,
|
|
7
|
+
UnsafeFileTypeError,
|
|
8
|
+
estimateMessages,
|
|
9
|
+
formatUsageLedger,
|
|
10
|
+
harnessToolExecution,
|
|
11
|
+
inspectRuntimeDiagnostics,
|
|
12
|
+
inspectUsageLedger,
|
|
13
|
+
readRegularFileNoFollow,
|
|
14
|
+
resolvePackageManager,
|
|
15
|
+
runPortableProcess,
|
|
16
|
+
taskSources,
|
|
17
|
+
usagePricingSchema
|
|
18
|
+
} from "../index-pgqz45fj.js";
|
|
19
|
+
import {
|
|
20
|
+
DEFAULT_HARNESS_MAX_STEPS,
|
|
21
|
+
bundledModelCatalog,
|
|
22
|
+
catalogModels,
|
|
23
|
+
modelCatalogSchema,
|
|
24
|
+
modelDescription,
|
|
25
|
+
modelReasoningEfforts,
|
|
26
|
+
reasoningEffortSchema
|
|
27
|
+
} from "../index-fvca1xea.js";
|
|
28
|
+
import"../index-1bx83sw4.js";
|
|
29
|
+
// src/models/catalog-store.ts
|
|
30
|
+
import { mkdir, readFile, rename, writeFile, unlink } from "node:fs/promises";
|
|
31
|
+
import { homedir } from "node:os";
|
|
32
|
+
import path from "node:path";
|
|
33
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
34
|
+
var MAX_BYTES = 1024 * 1024;
|
|
35
|
+
var TTL = 60 * 60 * 1000;
|
|
36
|
+
async function loadModelCatalog(options = {}) {
|
|
37
|
+
const fallback = { catalog: bundledModelCatalog, source: "bundled", stale: false };
|
|
38
|
+
const source = options.url ?? process.env.ZHIVEX_MODEL_CATALOG_URL;
|
|
39
|
+
if (!source)
|
|
40
|
+
return fallback;
|
|
41
|
+
let url;
|
|
42
|
+
try {
|
|
43
|
+
url = new URL(source);
|
|
44
|
+
if (url.protocol !== "https:" || url.username || url.password || url.hash)
|
|
45
|
+
return { ...fallback, stale: true };
|
|
46
|
+
} catch {
|
|
47
|
+
return { ...fallback, stale: true };
|
|
48
|
+
}
|
|
49
|
+
const now = options.now ?? Date.now();
|
|
50
|
+
const directory = options.cacheDirectory ?? path.join(homedir(), ".zhivex", "model-catalog");
|
|
51
|
+
const file = path.join(directory, `${createHash("sha256").update(url.href).digest("hex")}.json`);
|
|
52
|
+
let cached;
|
|
53
|
+
try {
|
|
54
|
+
const raw = await readFile(file, "utf8");
|
|
55
|
+
if (Buffer.byteLength(raw) > MAX_BYTES + 1024)
|
|
56
|
+
throw new Error("CATALOG_TOO_LARGE");
|
|
57
|
+
const envelope = JSON.parse(raw);
|
|
58
|
+
if (envelope.url !== url.href || !Number.isFinite(envelope.fetchedAt))
|
|
59
|
+
throw new Error("INVALID_CACHE");
|
|
60
|
+
cached = { catalog: modelCatalogSchema.parse(envelope.catalog), source: "cache", stale: true };
|
|
61
|
+
if (!options.refresh && now >= envelope.fetchedAt && now - envelope.fetchedAt < TTL)
|
|
62
|
+
return { ...cached, stale: false };
|
|
63
|
+
} catch {}
|
|
64
|
+
try {
|
|
65
|
+
const response = await (options.fetcher ?? fetch)(url, {
|
|
66
|
+
signal: AbortSignal.timeout(3000),
|
|
67
|
+
redirect: "error",
|
|
68
|
+
headers: { accept: "application/json" }
|
|
69
|
+
});
|
|
70
|
+
if (!response.ok || !response.body)
|
|
71
|
+
throw new Error("CATALOG_FETCH_FAILED");
|
|
72
|
+
const reader = response.body.getReader();
|
|
73
|
+
const chunks = [];
|
|
74
|
+
let size = 0;
|
|
75
|
+
try {
|
|
76
|
+
for (;; ) {
|
|
77
|
+
const { value, done } = await reader.read();
|
|
78
|
+
if (done)
|
|
79
|
+
break;
|
|
80
|
+
size += value.byteLength;
|
|
81
|
+
if (size > MAX_BYTES)
|
|
82
|
+
throw new Error("CATALOG_TOO_LARGE");
|
|
83
|
+
chunks.push(value);
|
|
84
|
+
}
|
|
85
|
+
} finally {
|
|
86
|
+
await reader.cancel().catch(() => {});
|
|
87
|
+
}
|
|
88
|
+
const catalog = modelCatalogSchema.parse(JSON.parse(Buffer.concat(chunks).toString("utf8")));
|
|
89
|
+
const temporary = `${file}.${randomUUID()}.tmp`;
|
|
90
|
+
try {
|
|
91
|
+
await mkdir(directory, { recursive: true, mode: 448 });
|
|
92
|
+
await writeFile(temporary, JSON.stringify({ url: url.href, fetchedAt: now, catalog }), { mode: 384, flag: "wx" });
|
|
93
|
+
await rename(temporary, file);
|
|
94
|
+
} catch {} finally {
|
|
95
|
+
await unlink(temporary).catch(() => {});
|
|
96
|
+
}
|
|
97
|
+
return { catalog, source: "remote", stale: false };
|
|
98
|
+
} catch {
|
|
99
|
+
return cached ?? { ...fallback, stale: true };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// src/compat/code-support.ts
|
|
103
|
+
var inspectCodeStateDatabase = (databasePath) => {
|
|
104
|
+
const database = new SqliteDatabase(databasePath, { create: false, readonly: true, strict: true });
|
|
105
|
+
try {
|
|
106
|
+
const integrity = database.query("PRAGMA quick_check").get()?.quick_check;
|
|
107
|
+
const tables = database.query("SELECT name FROM sqlite_master WHERE type = 'table'").all().map((row) => row.name);
|
|
108
|
+
const sessionVersion = tables.includes("zhivex_cli_session_schema") ? database.query("SELECT version FROM zhivex_cli_session_schema WHERE singleton = 1").get()?.version : undefined;
|
|
109
|
+
return { integrity, tables, sessionVersion };
|
|
110
|
+
} finally {
|
|
111
|
+
database.close(false);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
export {
|
|
115
|
+
DEFAULT_HARNESS_MAX_STEPS,
|
|
116
|
+
FileChangedWhileReadingError,
|
|
117
|
+
FileSizeLimitError,
|
|
118
|
+
TASK_SOURCE_KEY,
|
|
119
|
+
USAGE_LEDGER_KEY,
|
|
120
|
+
UnsafeFileTypeError,
|
|
121
|
+
bundledModelCatalog,
|
|
122
|
+
catalogModels,
|
|
123
|
+
estimateMessages,
|
|
124
|
+
formatUsageLedger,
|
|
125
|
+
harnessToolExecution,
|
|
126
|
+
inspectCodeStateDatabase,
|
|
127
|
+
inspectRuntimeDiagnostics,
|
|
128
|
+
inspectUsageLedger,
|
|
129
|
+
loadModelCatalog,
|
|
130
|
+
modelDescription,
|
|
131
|
+
modelReasoningEfforts,
|
|
132
|
+
readRegularFileNoFollow,
|
|
133
|
+
reasoningEffortSchema,
|
|
134
|
+
resolvePackageManager,
|
|
135
|
+
runPortableProcess,
|
|
136
|
+
taskSources,
|
|
137
|
+
usagePricingSchema
|
|
138
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BUILTIN_PROVIDER_REGISTRATIONS,
|
|
3
|
+
DEFAULT_ALLOWED_CHECKS,
|
|
4
|
+
DEFAULT_HARNESS_BUDGET,
|
|
5
|
+
DEFAULT_HARNESS_COMPACTION,
|
|
6
|
+
DEFAULT_HARNESS_MAX_STEPS,
|
|
7
|
+
DEFAULT_OCI_EXECUTION,
|
|
8
|
+
DEFAULT_PROVIDER_REGISTRY,
|
|
9
|
+
DEFAULT_SUBAGENT_BUDGET,
|
|
10
|
+
HARNESS_CONFIG_MIGRATABLE_SCHEMA_VERSIONS,
|
|
11
|
+
HARNESS_CONFIG_SCHEMA_VERSION,
|
|
12
|
+
HARNESS_EXECUTION_BACKENDS,
|
|
13
|
+
HARNESS_EXECUTION_POLICY_VERSION,
|
|
14
|
+
HARNESS_OCI_RUNTIMES,
|
|
15
|
+
HARNESS_OCI_SHELL_MODES,
|
|
16
|
+
HARNESS_REQUIRED_CAPABILITIES,
|
|
17
|
+
HARNESS_STORE_BACKENDS,
|
|
18
|
+
HARNESS_SUBAGENT_PROFILES,
|
|
19
|
+
PROVIDERS,
|
|
20
|
+
PROVIDER_DESCRIPTORS,
|
|
21
|
+
createProviderModel,
|
|
22
|
+
createProviderRegistry,
|
|
23
|
+
defaultHarnessNamespace,
|
|
24
|
+
migrateHarnessConfigInput,
|
|
25
|
+
parseProvider,
|
|
26
|
+
providerAvailability,
|
|
27
|
+
providerDescriptor,
|
|
28
|
+
resolveHarnessConfig
|
|
29
|
+
} from "./index-fvca1xea.js";
|
|
30
|
+
import"./index-1bx83sw4.js";
|
|
31
|
+
export {
|
|
32
|
+
BUILTIN_PROVIDER_REGISTRATIONS,
|
|
33
|
+
DEFAULT_ALLOWED_CHECKS,
|
|
34
|
+
DEFAULT_HARNESS_BUDGET,
|
|
35
|
+
DEFAULT_HARNESS_COMPACTION,
|
|
36
|
+
DEFAULT_HARNESS_MAX_STEPS,
|
|
37
|
+
DEFAULT_OCI_EXECUTION,
|
|
38
|
+
DEFAULT_PROVIDER_REGISTRY,
|
|
39
|
+
DEFAULT_SUBAGENT_BUDGET,
|
|
40
|
+
HARNESS_CONFIG_MIGRATABLE_SCHEMA_VERSIONS,
|
|
41
|
+
HARNESS_CONFIG_SCHEMA_VERSION,
|
|
42
|
+
HARNESS_EXECUTION_BACKENDS,
|
|
43
|
+
HARNESS_EXECUTION_POLICY_VERSION,
|
|
44
|
+
HARNESS_OCI_RUNTIMES,
|
|
45
|
+
HARNESS_OCI_SHELL_MODES,
|
|
46
|
+
HARNESS_REQUIRED_CAPABILITIES,
|
|
47
|
+
HARNESS_STORE_BACKENDS,
|
|
48
|
+
HARNESS_SUBAGENT_PROFILES,
|
|
49
|
+
PROVIDERS,
|
|
50
|
+
PROVIDER_DESCRIPTORS,
|
|
51
|
+
createProviderModel,
|
|
52
|
+
createProviderRegistry,
|
|
53
|
+
defaultHarnessNamespace,
|
|
54
|
+
migrateHarnessConfigInput,
|
|
55
|
+
parseProvider,
|
|
56
|
+
providerAvailability,
|
|
57
|
+
providerDescriptor,
|
|
58
|
+
resolveHarnessConfig
|
|
59
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Explicit Harness integration surface. See contracts/engine-api.json for stability tiers. */
|
|
2
|
+
export { createAcpConnection } from "../client/acp.js";
|
|
3
|
+
export type { AcpConnectionOptions } from "../client/acp.js";
|
|
4
|
+
export { serveAcpStdio } from "../client/acp-stdio.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Explicit Harness integration surface. See contracts/engine-api.json for stability tiers. */
|
|
2
|
+
export { HARNESS_CLIENT_PROTOCOL_VERSION, harnessClientCommandSchema, harnessClientRequestSchema } from "../client/protocol.js";
|
|
3
|
+
export type { HarnessClientCommand, HarnessClientRequest, HarnessClientErrorCode, HarnessClientSession, HarnessClientRun, HarnessClientData, HarnessClientResponse, HarnessClientNegotiation, HarnessClientAdapterOptions, HarnessClientAdapter } from "../client/protocol.js";
|
|
4
|
+
export { createHarnessClientAdapter } from "../client/adapter.js";
|
|
5
|
+
export { runResultDocument } from "../client/run-document.js";
|
|
6
|
+
export { terminalContinuationMessages } from "../client/continuation.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createHarnessClientAdapter,
|
|
3
|
+
runResultDocument,
|
|
4
|
+
terminalContinuationMessages
|
|
5
|
+
} from "../index-5wjwe91x.js";
|
|
6
|
+
import"../index-pgqz45fj.js";
|
|
7
|
+
import"../index-fvca1xea.js";
|
|
8
|
+
import {
|
|
9
|
+
HARNESS_CLIENT_PROTOCOL_VERSION,
|
|
10
|
+
harnessClientCommandSchema,
|
|
11
|
+
harnessClientRequestSchema
|
|
12
|
+
} from "../index-2aymdsqc.js";
|
|
13
|
+
import"../index-1bx83sw4.js";
|
|
14
|
+
export {
|
|
15
|
+
HARNESS_CLIENT_PROTOCOL_VERSION,
|
|
16
|
+
createHarnessClientAdapter,
|
|
17
|
+
harnessClientCommandSchema,
|
|
18
|
+
harnessClientRequestSchema,
|
|
19
|
+
runResultDocument,
|
|
20
|
+
terminalContinuationMessages
|
|
21
|
+
};
|