@zhivex-ai/harness 0.6.1 → 0.7.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.
@@ -0,0 +1,77 @@
1
+ import type { LanguageModel } from "@zhivex-ai/agents";
2
+ export declare const PROVIDERS: readonly ["meta", "qwen", "openai", "gemini"];
3
+ export type BuiltInHarnessProvider = (typeof PROVIDERS)[number];
4
+ export type HarnessProvider = BuiltInHarnessProvider | (string & {});
5
+ export type ProviderCapability = "streaming" | "tool-calling" | "approval-resume";
6
+ export type ProviderSupport = "certified" | "provisional";
7
+ export interface ProviderDescriptor {
8
+ readonly id: HarnessProvider;
9
+ readonly name: string;
10
+ readonly defaultModel: string;
11
+ readonly credentialNames: readonly string[];
12
+ readonly capabilities: readonly ProviderCapability[];
13
+ readonly support: ProviderSupport;
14
+ }
15
+ export interface ProviderCredentials {
16
+ readonly names: readonly string[];
17
+ get(name: string): string | undefined;
18
+ first(): string | undefined;
19
+ require(): string;
20
+ }
21
+ export interface ProviderModelFactoryContext {
22
+ readonly provider: HarnessProvider;
23
+ readonly model: string;
24
+ readonly env: NodeJS.ProcessEnv;
25
+ readonly credentials: ProviderCredentials;
26
+ }
27
+ export type ProviderModelFactory = (context: ProviderModelFactoryContext) => LanguageModel;
28
+ export interface ProviderPresenceDiagnostic {
29
+ /** Output is exposed as `<key>Configured`; the environment value is never returned. */
30
+ readonly key: string;
31
+ readonly environmentVariable: string;
32
+ }
33
+ export interface ProviderEnumDiagnostic extends ProviderPresenceDiagnostic {
34
+ /** Output also includes `<key>Valid`, based only on membership in this allowlist. */
35
+ readonly allowedValues: readonly string[];
36
+ }
37
+ export interface ProviderDiagnosticsDescriptor {
38
+ /** Produces only customEndpoint, endpointValid, and endpointSecure booleans. */
39
+ readonly endpointEnvironmentVariable?: string;
40
+ readonly presence?: readonly ProviderPresenceDiagnostic[];
41
+ readonly enums?: readonly ProviderEnumDiagnostic[];
42
+ }
43
+ export interface ProviderRegistration {
44
+ readonly descriptor: ProviderDescriptor;
45
+ readonly factory: ProviderModelFactory;
46
+ readonly diagnostics?: ProviderDiagnosticsDescriptor;
47
+ }
48
+ export interface ProviderAvailability extends ProviderDescriptor {
49
+ readonly configured: boolean;
50
+ readonly credentials: readonly {
51
+ readonly name: string;
52
+ readonly present: boolean;
53
+ }[];
54
+ readonly configuration: Readonly<Record<string, boolean>> & {
55
+ readonly customEndpoint: boolean;
56
+ readonly endpointValid: boolean;
57
+ readonly endpointSecure: boolean;
58
+ };
59
+ }
60
+ export interface HarnessProviderRegistry {
61
+ readonly descriptors: readonly ProviderDescriptor[];
62
+ has(provider: string): boolean;
63
+ parse(value?: string): HarnessProvider;
64
+ descriptor(provider: HarnessProvider): ProviderDescriptor;
65
+ createModel(config: Readonly<{
66
+ provider: HarnessProvider;
67
+ model: string;
68
+ }>, env?: NodeJS.ProcessEnv): LanguageModel;
69
+ availability(env?: NodeJS.ProcessEnv): readonly ProviderAvailability[];
70
+ /** Stable hash of non-credential transport settings used by durable resume bindings. */
71
+ transportFingerprint(env?: NodeJS.ProcessEnv): string;
72
+ extend(registrations: readonly ProviderRegistration[]): HarnessProviderRegistry;
73
+ }
74
+ export declare const createProviderRegistry: (registrations: readonly ProviderRegistration[]) => HarnessProviderRegistry;
75
+ export declare const BUILTIN_PROVIDER_REGISTRATIONS: readonly ProviderRegistration[];
76
+ export declare const DEFAULT_PROVIDER_REGISTRY: HarnessProviderRegistry;
77
+ export declare const PROVIDER_DESCRIPTORS: readonly ProviderDescriptor[];
@@ -0,0 +1,16 @@
1
+ import type { LanguageModel } from "@zhivex-ai/agents";
2
+ import { type HarnessProviderRegistry, type HarnessSubagentProfile } from "./config.js";
3
+ export interface HarnessModelRoute {
4
+ profile: HarnessSubagentProfile;
5
+ provider: string;
6
+ model: string;
7
+ }
8
+ export declare const parseHarnessModelRoute: (value: string, registry?: HarnessProviderRegistry) => HarnessModelRoute;
9
+ export declare const resolveHarnessModelRoutes: (values?: readonly string[], registry?: HarnessProviderRegistry) => Map<"explorer" | "implementer" | "tester" | "reviewer", HarnessModelRoute>;
10
+ export declare const createHarnessRouteModels: (routes: ReadonlyMap<HarnessSubagentProfile, HarnessModelRoute>, env?: NodeJS.ProcessEnv, registry?: HarnessProviderRegistry) => Partial<Record<HarnessSubagentProfile, LanguageModel>>;
11
+ export declare const serializeHarnessModelRoutes: (routes: ReadonlyMap<HarnessSubagentProfile, HarnessModelRoute>) => {
12
+ [k: string]: {
13
+ provider: string;
14
+ model: string;
15
+ };
16
+ };
@@ -0,0 +1,122 @@
1
+ import type { AgentStoreScope } from "@zhivex-ai/agents/ops";
2
+ export declare const HARNESS_SESSION_INDEX_FILE = "operations.sqlite";
3
+ export declare const HARNESS_SESSION_SCHEMA_VERSION: 1;
4
+ export declare const SESSION_RUN_STATUSES: readonly ["created", "running", "waiting_approval", "cancel_requested", "completed", "failed", "cancelled", "timed_out"];
5
+ export declare const TERMINAL_SESSION_RUN_STATUSES: readonly ["completed", "failed", "cancelled", "timed_out"];
6
+ export type SessionRunStatus = (typeof SESSION_RUN_STATUSES)[number];
7
+ export interface SessionRunReference {
8
+ turnId: string;
9
+ sourceTurnId?: string;
10
+ sequence: number;
11
+ runId: string;
12
+ provider: string;
13
+ model: string;
14
+ role?: string;
15
+ status: SessionRunStatus;
16
+ createdAt: number;
17
+ updatedAt: number;
18
+ completedAt?: number;
19
+ }
20
+ export interface CliSession {
21
+ schemaVersion: typeof HARNESS_SESSION_SCHEMA_VERSION;
22
+ sessionId: string;
23
+ workspaceKey: string;
24
+ scopeKey: string;
25
+ title?: string;
26
+ parentSessionId?: string;
27
+ forkedFromTurnId?: string;
28
+ revision: number;
29
+ createdAt: number;
30
+ updatedAt: number;
31
+ archivedAt?: number;
32
+ deletedAt?: number;
33
+ runs: SessionRunReference[];
34
+ }
35
+ export interface CliSessionSummary extends Omit<CliSession, "runs"> {
36
+ runCount: number;
37
+ latestRun?: SessionRunReference;
38
+ }
39
+ export interface CreateSessionInput {
40
+ /** A short operator-facing label. It is redacted before persistence and must not contain a prompt. */
41
+ title?: string;
42
+ initialRun?: AppendSessionRunInput;
43
+ }
44
+ export interface AppendSessionRunInput {
45
+ runId: string;
46
+ provider: string;
47
+ model: string;
48
+ role?: string;
49
+ status?: SessionRunStatus;
50
+ createdAt?: number;
51
+ }
52
+ export interface UpdateSessionRunInput {
53
+ status: SessionRunStatus;
54
+ updatedAt?: number;
55
+ completedAt?: number;
56
+ expectedSessionRevision?: number;
57
+ }
58
+ export interface UpdateSessionInput {
59
+ title?: string | null;
60
+ archived?: boolean;
61
+ expectedRevision?: number;
62
+ }
63
+ export interface ListSessionsQuery {
64
+ limit?: number;
65
+ includeArchived?: boolean;
66
+ includeDeleted?: boolean;
67
+ }
68
+ export interface ForkSessionInput {
69
+ atTurnId?: string;
70
+ title?: string;
71
+ expectedRevision?: number;
72
+ }
73
+ export interface SessionRetentionResult {
74
+ before: number;
75
+ deletedSessions: number;
76
+ }
77
+ export interface OpenSessionStoreOptions {
78
+ workspace: string;
79
+ stateDirectory: string;
80
+ scope: AgentStoreScope;
81
+ retentionMs?: number;
82
+ maxSessionsPerWorkspace?: number;
83
+ maxRunsPerSession?: number;
84
+ maxMetadataBytes?: number;
85
+ maxIndexBytes?: number;
86
+ now?: () => number;
87
+ }
88
+ export interface CliSessionStore {
89
+ readonly databasePath: string;
90
+ readonly workspaceKey: string;
91
+ readonly scopeKey: string;
92
+ create(input?: CreateSessionInput): Promise<CliSession>;
93
+ get(sessionId: string, options?: {
94
+ includeDeleted?: boolean;
95
+ }): Promise<CliSession | undefined>;
96
+ list(query?: ListSessionsQuery): Promise<CliSessionSummary[]>;
97
+ latest(options?: {
98
+ includeArchived?: boolean;
99
+ }): Promise<CliSession | undefined>;
100
+ update(sessionId: string, input: UpdateSessionInput): Promise<CliSession>;
101
+ rename(sessionId: string, title: string, options?: {
102
+ expectedRevision?: number;
103
+ }): Promise<CliSession>;
104
+ appendRun(sessionId: string, input: AppendSessionRunInput, options?: {
105
+ expectedRevision?: number;
106
+ }): Promise<CliSession>;
107
+ updateRun(sessionId: string, runId: string, input: UpdateSessionRunInput): Promise<CliSession>;
108
+ fork(sessionId: string, input?: ForkSessionInput): Promise<CliSession>;
109
+ archive(sessionId: string, options?: {
110
+ expectedRevision?: number;
111
+ }): Promise<CliSession>;
112
+ delete(sessionId: string, options?: {
113
+ expectedRevision?: number;
114
+ }): Promise<CliSession>;
115
+ prune(options?: {
116
+ before?: number;
117
+ }): Promise<SessionRetentionResult>;
118
+ close(): void;
119
+ }
120
+ export declare const openCliSessionStore: (options: OpenSessionStoreOptions) => Promise<CliSessionStore>;
121
+ /** Compatibility-friendly name for consumers that do not care that the index is CLI-owned. */
122
+ export declare const openSessionStore: (options: OpenSessionStoreOptions) => Promise<CliSessionStore>;