@harness-kernel/core 0.1.0-beta.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/NOTICE +3 -0
- package/README.md +12 -0
- package/dist/agent/context.d.ts +5 -0
- package/dist/agent/context.js +11 -0
- package/dist/agent/context.js.map +1 -0
- package/dist/agent/event.d.ts +3 -0
- package/dist/agent/event.js +50 -0
- package/dist/agent/event.js.map +1 -0
- package/dist/agent/hook.d.ts +6 -0
- package/dist/agent/hook.js +7 -0
- package/dist/agent/hook.js.map +1 -0
- package/dist/agent/mode.d.ts +5 -0
- package/dist/agent/mode.js +7 -0
- package/dist/agent/mode.js.map +1 -0
- package/dist/agent/role.d.ts +1 -0
- package/dist/agent/role.js +27 -0
- package/dist/agent/role.js.map +1 -0
- package/dist/agent/session.d.ts +6 -0
- package/dist/agent/session.js +13 -0
- package/dist/agent/session.js.map +1 -0
- package/dist/agent/tool.d.ts +5 -0
- package/dist/agent/tool.js +7 -0
- package/dist/agent/tool.js.map +1 -0
- package/dist/agent.d.ts +12 -0
- package/dist/agent.js +7 -0
- package/dist/agent.js.map +1 -0
- package/dist/approval-DfvjpbFs.d.ts +247 -0
- package/dist/chunk-4A2P4QU5.js +179 -0
- package/dist/chunk-4A2P4QU5.js.map +1 -0
- package/dist/chunk-4SYLFKIX.js +207 -0
- package/dist/chunk-4SYLFKIX.js.map +1 -0
- package/dist/chunk-4WWSQAWA.js +3778 -0
- package/dist/chunk-4WWSQAWA.js.map +1 -0
- package/dist/chunk-AD3BCYWU.js +37 -0
- package/dist/chunk-AD3BCYWU.js.map +1 -0
- package/dist/chunk-AZVA22HW.js +135 -0
- package/dist/chunk-AZVA22HW.js.map +1 -0
- package/dist/chunk-OBKS4AJR.js +529 -0
- package/dist/chunk-OBKS4AJR.js.map +1 -0
- package/dist/chunk-Q44U2CMM.js +239 -0
- package/dist/chunk-Q44U2CMM.js.map +1 -0
- package/dist/chunk-Q73WH5D7.js +54 -0
- package/dist/chunk-Q73WH5D7.js.map +1 -0
- package/dist/chunk-RRWJUHJG.js +9 -0
- package/dist/chunk-RRWJUHJG.js.map +1 -0
- package/dist/context-75mlon5x.d.ts +394 -0
- package/dist/event-CKV4EeZ3.d.ts +230 -0
- package/dist/events-D4xcDi53.d.ts +69 -0
- package/dist/hook-DMb9fw9Z.d.ts +20 -0
- package/dist/index.d.ts +164 -0
- package/dist/index.js +174 -0
- package/dist/index.js.map +1 -0
- package/dist/model-provider-BrZ2RRmS.d.ts +130 -0
- package/dist/role-BN6KhQxx.d.ts +68 -0
- package/dist/runner/approval.d.ts +9 -0
- package/dist/runner/approval.js +1 -0
- package/dist/runner/approval.js.map +1 -0
- package/dist/runner/event.d.ts +3 -0
- package/dist/runner/event.js +50 -0
- package/dist/runner/event.js.map +1 -0
- package/dist/runner/logging.d.ts +31 -0
- package/dist/runner/logging.js +15 -0
- package/dist/runner/logging.js.map +1 -0
- package/dist/runner/model-provider.d.ts +8 -0
- package/dist/runner/model-provider.js +11 -0
- package/dist/runner/model-provider.js.map +1 -0
- package/dist/runner/sandbox.d.ts +47 -0
- package/dist/runner/sandbox.js +13 -0
- package/dist/runner/sandbox.js.map +1 -0
- package/dist/runner/storage.d.ts +6 -0
- package/dist/runner/storage.js +17 -0
- package/dist/runner/storage.js.map +1 -0
- package/dist/runner-Dxo7ALtp.d.ts +87 -0
- package/dist/runner.d.ts +10 -0
- package/dist/runner.js +18 -0
- package/dist/runner.js.map +1 -0
- package/dist/schema.d.ts +146 -0
- package/dist/schema.js +39 -0
- package/dist/schema.js.map +1 -0
- package/dist/storage-BmOEwW-p.d.ts +118 -0
- package/dist/tool-errors-CygY1Nba.d.ts +27 -0
- package/dist/types-BPmsw-mF.d.ts +80 -0
- package/package.json +114 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { H as HarnessModelProvider, d as HarnessModelProviderRegistry, M as ModelInfo, e as ModelProviderInfo, f as ModelProviderPreparedContext, g as ModelProviderRunInput, h as ModelProviderRunResult, R as ResolvedModelProvider, m as modelProviderId, p as parseModelRef } from '../model-provider-BrZ2RRmS.js';
|
|
2
|
+
import '../events-D4xcDi53.js';
|
|
3
|
+
import '../context-75mlon5x.js';
|
|
4
|
+
import '../role-BN6KhQxx.js';
|
|
5
|
+
import '../types-BPmsw-mF.js';
|
|
6
|
+
import './sandbox.js';
|
|
7
|
+
import '../storage-BmOEwW-p.js';
|
|
8
|
+
import '../hook-DMb9fw9Z.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
interface HarnessSandboxOpenInput {
|
|
2
|
+
sessionId: string;
|
|
3
|
+
runId: string;
|
|
4
|
+
agentKey: string;
|
|
5
|
+
workDir: string;
|
|
6
|
+
outputDir?: string;
|
|
7
|
+
services: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
interface SandboxExecInput {
|
|
10
|
+
command: string;
|
|
11
|
+
cwd?: string;
|
|
12
|
+
timeoutMs?: number;
|
|
13
|
+
env?: Record<string, string>;
|
|
14
|
+
stdin?: string;
|
|
15
|
+
}
|
|
16
|
+
interface SandboxExecResult {
|
|
17
|
+
stdout: string;
|
|
18
|
+
stderr: string;
|
|
19
|
+
exitCode: number | null;
|
|
20
|
+
signal?: string;
|
|
21
|
+
durationMs: number;
|
|
22
|
+
timedOut?: boolean;
|
|
23
|
+
}
|
|
24
|
+
declare abstract class HarnessSandbox {
|
|
25
|
+
abstract readonly id: string;
|
|
26
|
+
label?: string;
|
|
27
|
+
abstract open(input: HarnessSandboxOpenInput): Promise<HarnessSandboxSession> | HarnessSandboxSession;
|
|
28
|
+
}
|
|
29
|
+
declare abstract class HarnessSandboxSession {
|
|
30
|
+
abstract readonly id: string;
|
|
31
|
+
abstract readonly workDir: string;
|
|
32
|
+
abstract exec(input: SandboxExecInput): Promise<SandboxExecResult>;
|
|
33
|
+
close?(): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
declare class NoopSandbox extends HarnessSandbox {
|
|
36
|
+
readonly id = "noop";
|
|
37
|
+
label: string;
|
|
38
|
+
open(input: HarnessSandboxOpenInput): HarnessSandboxSession;
|
|
39
|
+
}
|
|
40
|
+
declare class NoopSandboxSession extends HarnessSandboxSession {
|
|
41
|
+
readonly workDir: string;
|
|
42
|
+
readonly id = "noop";
|
|
43
|
+
constructor(workDir: string);
|
|
44
|
+
exec(input: SandboxExecInput): Promise<SandboxExecResult>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { HarnessSandbox, type HarnessSandboxOpenInput, HarnessSandboxSession, NoopSandbox, NoopSandboxSession, type SandboxExecInput, type SandboxExecResult };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HarnessSandbox,
|
|
3
|
+
HarnessSandboxSession,
|
|
4
|
+
NoopSandbox,
|
|
5
|
+
NoopSandboxSession
|
|
6
|
+
} from "../chunk-AD3BCYWU.js";
|
|
7
|
+
export {
|
|
8
|
+
HarnessSandbox,
|
|
9
|
+
HarnessSandboxSession,
|
|
10
|
+
NoopSandbox,
|
|
11
|
+
NoopSandboxSession
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=sandbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { H as HarnessRunStorage, a as HarnessRunStore, M as MemoryRunStorage, b as MemoryRunStore, N as NoopRunStorage, c as NoopRunStore, O as OpenRunStoreInput, R as RunCursorState } from '../storage-BmOEwW-p.js';
|
|
2
|
+
import '../events-D4xcDi53.js';
|
|
3
|
+
import '../context-75mlon5x.js';
|
|
4
|
+
import '../role-BN6KhQxx.js';
|
|
5
|
+
import '../types-BPmsw-mF.js';
|
|
6
|
+
import './sandbox.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HarnessRunStorage,
|
|
3
|
+
HarnessRunStore,
|
|
4
|
+
MemoryRunStorage,
|
|
5
|
+
MemoryRunStore,
|
|
6
|
+
NoopRunStorage,
|
|
7
|
+
NoopRunStore
|
|
8
|
+
} from "../chunk-AZVA22HW.js";
|
|
9
|
+
export {
|
|
10
|
+
HarnessRunStorage,
|
|
11
|
+
HarnessRunStore,
|
|
12
|
+
MemoryRunStorage,
|
|
13
|
+
MemoryRunStore,
|
|
14
|
+
NoopRunStorage,
|
|
15
|
+
NoopRunStore
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { d as HarnessEventQuery, e as HarnessEventRecord, H as HarnessEvent, a as HarnessEventClass } from './events-D4xcDi53.js';
|
|
2
|
+
import { a0 as HarnessTranscriptSession, X as HarnessSnapshotSession, S as HarnessModeSelector, r as AgentSharedState, M as ContextSnapshot } from './context-75mlon5x.js';
|
|
3
|
+
import { f as HarnessSession, b as HarnessAppConfig, p as HarnessUserInput, S as SendOptions, q as SendResult, r as StreamOptions, e as HarnessRunStream, j as HarnessSessionStatus, a as HarnessAgentManifest, T as ToolApprovalHandle, h as HarnessSessionListener, g as HarnessSessionEventListener, W as WaitForEventOptions, k as HarnessSessionStore, m as HarnessSessionStoreListener } from './approval-DfvjpbFs.js';
|
|
4
|
+
import { A as AgentDefinition } from './model-provider-BrZ2RRmS.js';
|
|
5
|
+
|
|
6
|
+
interface CreateHarnessSessionInternalOptions {
|
|
7
|
+
sessionId?: string;
|
|
8
|
+
}
|
|
9
|
+
declare class HarnessSessionImpl implements HarnessSession {
|
|
10
|
+
private readonly config;
|
|
11
|
+
readonly id: string;
|
|
12
|
+
readonly transcript: HarnessTranscriptSession;
|
|
13
|
+
readonly snapshots: HarnessSnapshotSession;
|
|
14
|
+
private readonly runner;
|
|
15
|
+
private readonly events;
|
|
16
|
+
private readonly approvals;
|
|
17
|
+
private readonly queue;
|
|
18
|
+
private readonly status;
|
|
19
|
+
private readonly createdAt;
|
|
20
|
+
private readonly logger;
|
|
21
|
+
private lastActiveAt;
|
|
22
|
+
private closed;
|
|
23
|
+
private activeAbort?;
|
|
24
|
+
private lastResult?;
|
|
25
|
+
private unsubscribeRunner;
|
|
26
|
+
constructor(config: HarnessAppConfig, input: {
|
|
27
|
+
sessionId?: string;
|
|
28
|
+
agent: AgentDefinition;
|
|
29
|
+
workDir: string;
|
|
30
|
+
});
|
|
31
|
+
send(input: string | HarnessUserInput, options?: SendOptions): Promise<SendResult>;
|
|
32
|
+
stream(input: string | HarnessUserInput, options?: StreamOptions): HarnessRunStream;
|
|
33
|
+
getStatus(): HarnessSessionStatus;
|
|
34
|
+
getMode(): string;
|
|
35
|
+
getModel(): string;
|
|
36
|
+
setModel(model: string): void;
|
|
37
|
+
clearModelOverride(): void;
|
|
38
|
+
switchMode(mode: HarnessModeSelector | string, input?: unknown): Promise<void>;
|
|
39
|
+
getState(): AgentSharedState;
|
|
40
|
+
updateState(patch: unknown): void;
|
|
41
|
+
replaceState(next: AgentSharedState): void;
|
|
42
|
+
getEvents(filter?: HarnessEventQuery): HarnessEventRecord[];
|
|
43
|
+
getContextSnapshot(): ContextSnapshot | undefined;
|
|
44
|
+
getAgentManifest(): HarnessAgentManifest;
|
|
45
|
+
getPendingApprovals(): ToolApprovalHandle[];
|
|
46
|
+
approveTool(approvalId: string): Promise<void>;
|
|
47
|
+
denyTool(approvalId: string, _reason?: string): Promise<void>;
|
|
48
|
+
on(listener: HarnessSessionListener): () => void;
|
|
49
|
+
onEvent<TPayload, TEvent extends HarnessEvent<TPayload>>(eventClass: HarnessEventClass<TPayload, TEvent>, listener: HarnessSessionEventListener<TEvent>): () => void;
|
|
50
|
+
waitForEvent<TPayload, TEvent extends HarnessEvent<TPayload>>(eventClass: HarnessEventClass<TPayload, TEvent>, options?: WaitForEventOptions): Promise<TEvent>;
|
|
51
|
+
close(): Promise<void>;
|
|
52
|
+
private notify;
|
|
53
|
+
private notifyStatus;
|
|
54
|
+
private assertSnapshotRestoreAllowed;
|
|
55
|
+
private applyPendingSendTrigger;
|
|
56
|
+
private resolveModeSelector;
|
|
57
|
+
private requestToolApproval;
|
|
58
|
+
private cancelActiveRun;
|
|
59
|
+
}
|
|
60
|
+
declare function createHarnessSession(config: HarnessAppConfig, options?: CreateHarnessSessionInternalOptions): Promise<HarnessSession>;
|
|
61
|
+
|
|
62
|
+
declare class HarnessSessionStoreImpl implements HarnessSessionStore {
|
|
63
|
+
private readonly config;
|
|
64
|
+
private readonly sessions;
|
|
65
|
+
private readonly unsubscriptions;
|
|
66
|
+
private readonly listeners;
|
|
67
|
+
private closed;
|
|
68
|
+
constructor(config: HarnessAppConfig);
|
|
69
|
+
getOrCreate(sessionId?: string, overrides?: Partial<HarnessAppConfig>): Promise<HarnessSession>;
|
|
70
|
+
get(sessionId: string): HarnessSession | undefined;
|
|
71
|
+
list(): HarnessSessionStatus[];
|
|
72
|
+
delete(sessionId: string): Promise<boolean>;
|
|
73
|
+
clear(): Promise<void>;
|
|
74
|
+
send(sessionId: string | undefined, input: string | HarnessUserInput, options?: SendOptions): Promise<SendResult>;
|
|
75
|
+
stream(sessionId: string | undefined, input: string | HarnessUserInput, options?: StreamOptions): Promise<HarnessRunStream>;
|
|
76
|
+
getPendingApprovals(sessionId?: string): ToolApprovalHandle[];
|
|
77
|
+
approveTool(sessionId: string, approvalId: string): Promise<void>;
|
|
78
|
+
denyTool(sessionId: string, approvalId: string, reason?: string): Promise<void>;
|
|
79
|
+
getAgentManifest(sessionId: string): HarnessAgentManifest | undefined;
|
|
80
|
+
on(listener: HarnessSessionStoreListener): () => void;
|
|
81
|
+
close(): Promise<void>;
|
|
82
|
+
private notify;
|
|
83
|
+
private cleanupExpired;
|
|
84
|
+
}
|
|
85
|
+
declare function createHarnessSessionStore(config: HarnessAppConfig): Promise<HarnessSessionStore>;
|
|
86
|
+
|
|
87
|
+
export { type CreateHarnessSessionInternalOptions as C, HarnessSessionImpl as H, HarnessSessionStoreImpl as a, createHarnessSessionStore as b, createHarnessSession as c };
|
package/dist/runner.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { c as createHarnessSession, b as createHarnessSessionStore } from './runner-Dxo7ALtp.js';
|
|
2
|
+
export { a as HarnessAgentManifest, b as HarnessAppConfig, e as HarnessRunStream, f as HarnessSession, g as HarnessSessionEventListener, h as HarnessSessionListener, i as HarnessSessionPhase, j as HarnessSessionStatus, k as HarnessSessionStore, l as HarnessSessionStoreEvent, m as HarnessSessionStoreListener, o as HarnessStreamEvent, p as HarnessUserInput, S as SendOptions, q as SendResult, r as StreamOptions, W as WaitForEventOptions } from './approval-DfvjpbFs.js';
|
|
3
|
+
export { E as EventCursor } from './events-D4xcDi53.js';
|
|
4
|
+
export { U as HarnessSnapshot, V as HarnessSnapshotCreator, W as HarnessSnapshotInput, X as HarnessSnapshotSession, Y as HarnessSnapshotSummary, a0 as HarnessTranscriptSession, aa as TranscriptBranch, ab as TranscriptCursor, ac as TranscriptQuery, ad as TranscriptSeekTarget } from './context-75mlon5x.js';
|
|
5
|
+
import './model-provider-BrZ2RRmS.js';
|
|
6
|
+
import './role-BN6KhQxx.js';
|
|
7
|
+
import './runner/sandbox.js';
|
|
8
|
+
import './storage-BmOEwW-p.js';
|
|
9
|
+
import './hook-DMb9fw9Z.js';
|
|
10
|
+
import './types-BPmsw-mF.js';
|
package/dist/runner.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HarnessSessionPhase,
|
|
3
|
+
createHarnessSession,
|
|
4
|
+
createHarnessSessionStore
|
|
5
|
+
} from "./chunk-4WWSQAWA.js";
|
|
6
|
+
import "./chunk-Q73WH5D7.js";
|
|
7
|
+
import "./chunk-Q44U2CMM.js";
|
|
8
|
+
import "./chunk-AD3BCYWU.js";
|
|
9
|
+
import "./chunk-AZVA22HW.js";
|
|
10
|
+
import "./chunk-4SYLFKIX.js";
|
|
11
|
+
import "./chunk-OBKS4AJR.js";
|
|
12
|
+
import "./chunk-4A2P4QU5.js";
|
|
13
|
+
export {
|
|
14
|
+
HarnessSessionPhase,
|
|
15
|
+
createHarnessSession,
|
|
16
|
+
createHarnessSessionStore
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
type SchemaIssueCode = "invalid_type" | "invalid_literal" | "invalid_enum" | "too_small" | "too_big" | "custom";
|
|
2
|
+
type SchemaSource = "harness" | "zod" | "standard" | "json-schema" | "custom";
|
|
3
|
+
interface SchemaIssue {
|
|
4
|
+
path: string;
|
|
5
|
+
code: string;
|
|
6
|
+
message: string;
|
|
7
|
+
expected?: string;
|
|
8
|
+
received?: string;
|
|
9
|
+
}
|
|
10
|
+
declare class SchemaError extends Error {
|
|
11
|
+
readonly issues: SchemaIssue[];
|
|
12
|
+
constructor(issues: SchemaIssue[]);
|
|
13
|
+
}
|
|
14
|
+
type SafeParseResult<T> = {
|
|
15
|
+
success: true;
|
|
16
|
+
data: T;
|
|
17
|
+
} | {
|
|
18
|
+
success: false;
|
|
19
|
+
error: SchemaError;
|
|
20
|
+
};
|
|
21
|
+
type JsonSchema = Record<string, unknown>;
|
|
22
|
+
type SchemaPathInput = string | number | Array<string | number> | undefined;
|
|
23
|
+
declare function formatSchemaPath(path: SchemaPathInput): string;
|
|
24
|
+
declare function schemaIssuesFromError(error: unknown): SchemaIssue[];
|
|
25
|
+
declare abstract class Schema<TInput = unknown, TOutput = TInput> {
|
|
26
|
+
readonly isHarnessSchema = true;
|
|
27
|
+
private schemaDescription?;
|
|
28
|
+
abstract safeParse(input: unknown): SafeParseResult<TOutput>;
|
|
29
|
+
abstract toJsonSchema(): JsonSchema;
|
|
30
|
+
parse(input: TInput): TOutput;
|
|
31
|
+
optional(): OptionalSchema<TInput | undefined, TOutput | undefined>;
|
|
32
|
+
default(value: TOutput | (() => TOutput)): DefaultSchema<TInput | undefined, TOutput>;
|
|
33
|
+
describe(description: string): this;
|
|
34
|
+
protected withDescription<TJson extends JsonSchema>(json: TJson): TJson;
|
|
35
|
+
}
|
|
36
|
+
type InferInput<TSchema> = TSchema extends Schema<infer TInput, any> ? TInput : unknown;
|
|
37
|
+
type InferOutput<TSchema> = TSchema extends Schema<any, infer TOutput> ? TOutput : unknown;
|
|
38
|
+
declare class StringSchema extends Schema<unknown, string> {
|
|
39
|
+
private minLength?;
|
|
40
|
+
private maxLength?;
|
|
41
|
+
min(length: number): this;
|
|
42
|
+
max(length: number): this;
|
|
43
|
+
safeParse(input: unknown): SafeParseResult<string>;
|
|
44
|
+
toJsonSchema(): JsonSchema;
|
|
45
|
+
}
|
|
46
|
+
declare class NumberSchema extends Schema<unknown, number> {
|
|
47
|
+
private integerOnly;
|
|
48
|
+
private minValue?;
|
|
49
|
+
private maxValue?;
|
|
50
|
+
private exclusiveMin?;
|
|
51
|
+
int(): this;
|
|
52
|
+
min(value: number): this;
|
|
53
|
+
max(value: number): this;
|
|
54
|
+
positive(): this;
|
|
55
|
+
safeParse(input: unknown): SafeParseResult<number>;
|
|
56
|
+
toJsonSchema(): JsonSchema;
|
|
57
|
+
}
|
|
58
|
+
declare class BooleanSchema extends Schema<unknown, boolean> {
|
|
59
|
+
safeParse(input: unknown): SafeParseResult<boolean>;
|
|
60
|
+
toJsonSchema(): JsonSchema;
|
|
61
|
+
}
|
|
62
|
+
declare class ArraySchema<TItem extends Schema<any, any>> extends Schema<InferInput<TItem>[], InferOutput<TItem>[]> {
|
|
63
|
+
private readonly item;
|
|
64
|
+
constructor(item: TItem);
|
|
65
|
+
safeParse(input: unknown): SafeParseResult<InferOutput<TItem>[]>;
|
|
66
|
+
toJsonSchema(): JsonSchema;
|
|
67
|
+
}
|
|
68
|
+
type ObjectShape = Record<string, Schema<any, any>>;
|
|
69
|
+
type OptionalInputKeys<TShape extends ObjectShape> = {
|
|
70
|
+
[K in keyof TShape]: undefined extends InferInput<TShape[K]> ? K : never;
|
|
71
|
+
}[keyof TShape];
|
|
72
|
+
type ObjectInput<TShape extends ObjectShape> = {
|
|
73
|
+
[K in Exclude<keyof TShape, OptionalInputKeys<TShape>>]: InferInput<TShape[K]>;
|
|
74
|
+
} & {
|
|
75
|
+
[K in OptionalInputKeys<TShape>]?: InferInput<TShape[K]>;
|
|
76
|
+
};
|
|
77
|
+
type OptionalOutputKeys<TShape extends ObjectShape> = {
|
|
78
|
+
[K in keyof TShape]: undefined extends InferOutput<TShape[K]> ? K : never;
|
|
79
|
+
}[keyof TShape];
|
|
80
|
+
type ObjectOutput<TShape extends ObjectShape> = {
|
|
81
|
+
[K in Exclude<keyof TShape, OptionalOutputKeys<TShape>>]: InferOutput<TShape[K]>;
|
|
82
|
+
} & {
|
|
83
|
+
[K in OptionalOutputKeys<TShape>]?: InferOutput<TShape[K]>;
|
|
84
|
+
};
|
|
85
|
+
declare class ObjectSchema<TShape extends ObjectShape> extends Schema<ObjectInput<TShape>, ObjectOutput<TShape>> {
|
|
86
|
+
private readonly shape;
|
|
87
|
+
constructor(shape: TShape);
|
|
88
|
+
safeParse(input: unknown): SafeParseResult<ObjectOutput<TShape>>;
|
|
89
|
+
toJsonSchema(): JsonSchema;
|
|
90
|
+
}
|
|
91
|
+
declare class RecordSchema<TValue extends Schema<any, any>> extends Schema<Record<string, InferInput<TValue>>, Record<string, InferOutput<TValue>>> {
|
|
92
|
+
private readonly valueSchema;
|
|
93
|
+
constructor(valueSchema: TValue);
|
|
94
|
+
safeParse(input: unknown): SafeParseResult<Record<string, InferOutput<TValue>>>;
|
|
95
|
+
toJsonSchema(): JsonSchema;
|
|
96
|
+
}
|
|
97
|
+
declare class EnumSchema<const TValues extends readonly [string, ...string[]]> extends Schema<unknown, TValues[number]> {
|
|
98
|
+
private readonly values;
|
|
99
|
+
constructor(values: TValues);
|
|
100
|
+
safeParse(input: unknown): SafeParseResult<TValues[number]>;
|
|
101
|
+
toJsonSchema(): JsonSchema;
|
|
102
|
+
}
|
|
103
|
+
declare class LiteralSchema<const TValue> extends Schema<unknown, TValue> {
|
|
104
|
+
private readonly value;
|
|
105
|
+
constructor(value: TValue);
|
|
106
|
+
safeParse(input: unknown): SafeParseResult<TValue>;
|
|
107
|
+
toJsonSchema(): JsonSchema;
|
|
108
|
+
}
|
|
109
|
+
declare class OptionalSchema<TInput, TOutput> extends Schema<TInput | undefined, TOutput | undefined> {
|
|
110
|
+
private readonly inner;
|
|
111
|
+
constructor(inner: Schema<TInput, TOutput>);
|
|
112
|
+
safeParse(input: unknown): SafeParseResult<TOutput | undefined>;
|
|
113
|
+
toJsonSchema(): JsonSchema;
|
|
114
|
+
}
|
|
115
|
+
declare class DefaultSchema<TInput, TOutput> extends Schema<TInput | undefined, TOutput> {
|
|
116
|
+
private readonly inner;
|
|
117
|
+
private readonly value;
|
|
118
|
+
constructor(inner: Schema<TInput, TOutput>, value: TOutput | (() => TOutput));
|
|
119
|
+
safeParse(input: unknown): SafeParseResult<TOutput>;
|
|
120
|
+
toJsonSchema(): JsonSchema;
|
|
121
|
+
}
|
|
122
|
+
declare class UnknownSchema extends Schema<unknown, unknown> {
|
|
123
|
+
safeParse(input: unknown): SafeParseResult<unknown>;
|
|
124
|
+
toJsonSchema(): JsonSchema;
|
|
125
|
+
}
|
|
126
|
+
declare const s: {
|
|
127
|
+
string: () => StringSchema;
|
|
128
|
+
number: () => NumberSchema;
|
|
129
|
+
boolean: () => BooleanSchema;
|
|
130
|
+
array: <TItem extends Schema<any, any>>(item: TItem) => ArraySchema<TItem>;
|
|
131
|
+
object: <TShape extends ObjectShape>(shape: TShape) => ObjectSchema<TShape>;
|
|
132
|
+
record: <TValue extends Schema<any, any>>(value: TValue) => RecordSchema<TValue>;
|
|
133
|
+
enum: <const TValues extends readonly [string, ...string[]]>(values: TValues) => EnumSchema<TValues>;
|
|
134
|
+
literal: <const TValue>(value: TValue) => LiteralSchema<TValue>;
|
|
135
|
+
unknown: () => UnknownSchema;
|
|
136
|
+
};
|
|
137
|
+
interface NormalizedSchema<TInput = unknown, TOutput = unknown> {
|
|
138
|
+
source: SchemaSource;
|
|
139
|
+
parse(input: TInput): TOutput;
|
|
140
|
+
safeParse(input: TInput): SafeParseResult<TOutput>;
|
|
141
|
+
issuesFromError(error: unknown): SchemaIssue[];
|
|
142
|
+
toJsonSchema?: () => JsonSchema;
|
|
143
|
+
}
|
|
144
|
+
declare function normalizeSchema<TInput = unknown, TOutput = unknown>(schema: unknown): NormalizedSchema<TInput, TOutput>;
|
|
145
|
+
|
|
146
|
+
export { ArraySchema, BooleanSchema, DefaultSchema, EnumSchema, type InferInput, type InferOutput, type JsonSchema, LiteralSchema, type NormalizedSchema, NumberSchema, ObjectSchema, OptionalSchema, RecordSchema, type SafeParseResult, Schema, SchemaError, type SchemaIssue, type SchemaIssueCode, type SchemaSource, StringSchema, UnknownSchema, formatSchemaPath, normalizeSchema, s, schemaIssuesFromError };
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ArraySchema,
|
|
3
|
+
BooleanSchema,
|
|
4
|
+
DefaultSchema,
|
|
5
|
+
EnumSchema,
|
|
6
|
+
LiteralSchema,
|
|
7
|
+
NumberSchema,
|
|
8
|
+
ObjectSchema,
|
|
9
|
+
OptionalSchema,
|
|
10
|
+
RecordSchema,
|
|
11
|
+
Schema,
|
|
12
|
+
SchemaError,
|
|
13
|
+
StringSchema,
|
|
14
|
+
UnknownSchema,
|
|
15
|
+
formatSchemaPath,
|
|
16
|
+
normalizeSchema,
|
|
17
|
+
s,
|
|
18
|
+
schemaIssuesFromError
|
|
19
|
+
} from "./chunk-OBKS4AJR.js";
|
|
20
|
+
export {
|
|
21
|
+
ArraySchema,
|
|
22
|
+
BooleanSchema,
|
|
23
|
+
DefaultSchema,
|
|
24
|
+
EnumSchema,
|
|
25
|
+
LiteralSchema,
|
|
26
|
+
NumberSchema,
|
|
27
|
+
ObjectSchema,
|
|
28
|
+
OptionalSchema,
|
|
29
|
+
RecordSchema,
|
|
30
|
+
Schema,
|
|
31
|
+
SchemaError,
|
|
32
|
+
StringSchema,
|
|
33
|
+
UnknownSchema,
|
|
34
|
+
formatSchemaPath,
|
|
35
|
+
normalizeSchema,
|
|
36
|
+
s,
|
|
37
|
+
schemaIssuesFromError
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { e as HarnessEventRecord, E as EventCursor } from './events-D4xcDi53.js';
|
|
2
|
+
import { h as AgentMessage, U as HarnessSnapshot, ab as TranscriptCursor, aa as TranscriptBranch, M as ContextSnapshot } from './context-75mlon5x.js';
|
|
3
|
+
|
|
4
|
+
interface ToolCallMetric {
|
|
5
|
+
name: string;
|
|
6
|
+
count: number;
|
|
7
|
+
errorCount: number;
|
|
8
|
+
totalDurationMs: number;
|
|
9
|
+
}
|
|
10
|
+
interface RunMetrics {
|
|
11
|
+
startedAt: string;
|
|
12
|
+
completedAt?: string;
|
|
13
|
+
durationMs: number;
|
|
14
|
+
turnCount: number;
|
|
15
|
+
messageCount: number;
|
|
16
|
+
eventCount: number;
|
|
17
|
+
toolCallCount: number;
|
|
18
|
+
finalMode?: string;
|
|
19
|
+
tools: Record<string, ToolCallMetric>;
|
|
20
|
+
errors: string[];
|
|
21
|
+
usage?: unknown;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface RunCursorState {
|
|
25
|
+
transcriptCursor: TranscriptCursor;
|
|
26
|
+
eventCursor: EventCursor;
|
|
27
|
+
branches?: TranscriptBranch[];
|
|
28
|
+
}
|
|
29
|
+
interface OpenRunStoreInput {
|
|
30
|
+
runId: string;
|
|
31
|
+
sessionId: string;
|
|
32
|
+
agentKey: string;
|
|
33
|
+
outputDir?: string;
|
|
34
|
+
}
|
|
35
|
+
declare abstract class HarnessRunStorage {
|
|
36
|
+
abstract readonly id: string;
|
|
37
|
+
label?: string;
|
|
38
|
+
abstract openRun(input: OpenRunStoreInput): Promise<HarnessRunStore> | HarnessRunStore;
|
|
39
|
+
}
|
|
40
|
+
declare abstract class HarnessRunStore {
|
|
41
|
+
abstract readonly runId: string;
|
|
42
|
+
readonly outputDir?: string;
|
|
43
|
+
readonly runDir?: string;
|
|
44
|
+
abstract init(): Promise<void> | void;
|
|
45
|
+
abstract recordEvent(event: HarnessEventRecord): Promise<void> | void;
|
|
46
|
+
abstract loadEvents(): Promise<HarnessEventRecord[]> | HarnessEventRecord[];
|
|
47
|
+
abstract saveTranscript(messages: AgentMessage[]): Promise<void> | void;
|
|
48
|
+
abstract loadTranscript(): Promise<AgentMessage[]> | AgentMessage[];
|
|
49
|
+
abstract saveMetrics(metrics: RunMetrics): Promise<void> | void;
|
|
50
|
+
abstract saveSnapshot(snapshot: HarnessSnapshot): Promise<void> | void;
|
|
51
|
+
abstract loadSnapshots(): Promise<HarnessSnapshot[]> | HarnessSnapshot[];
|
|
52
|
+
abstract deleteSnapshot(id: string): Promise<void> | void;
|
|
53
|
+
abstract saveCursors(cursors: RunCursorState): Promise<void> | void;
|
|
54
|
+
abstract loadCursors(): Promise<RunCursorState | undefined> | RunCursorState | undefined;
|
|
55
|
+
abstract saveContextSnapshot(snapshot: ContextSnapshot): Promise<void> | void;
|
|
56
|
+
abstract loadContextSnapshots(): Promise<ContextSnapshot[]> | ContextSnapshot[];
|
|
57
|
+
close?(): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
declare class NoopRunStorage extends HarnessRunStorage {
|
|
60
|
+
readonly id = "noop";
|
|
61
|
+
label: string;
|
|
62
|
+
openRun(input: OpenRunStoreInput): HarnessRunStore;
|
|
63
|
+
}
|
|
64
|
+
declare class NoopRunStore extends HarnessRunStore {
|
|
65
|
+
readonly runId: string;
|
|
66
|
+
readonly outputDir: undefined;
|
|
67
|
+
readonly runDir: undefined;
|
|
68
|
+
constructor(runId: string);
|
|
69
|
+
init(): void;
|
|
70
|
+
recordEvent(_event: HarnessEventRecord): void;
|
|
71
|
+
loadEvents(): HarnessEventRecord[];
|
|
72
|
+
saveTranscript(_messages: AgentMessage[]): void;
|
|
73
|
+
loadTranscript(): AgentMessage[];
|
|
74
|
+
saveMetrics(_metrics: RunMetrics): void;
|
|
75
|
+
saveSnapshot(_snapshot: HarnessSnapshot): void;
|
|
76
|
+
loadSnapshots(): HarnessSnapshot[];
|
|
77
|
+
deleteSnapshot(_id: string): void;
|
|
78
|
+
saveCursors(_cursors: RunCursorState): void;
|
|
79
|
+
loadCursors(): RunCursorState | undefined;
|
|
80
|
+
saveContextSnapshot(_snapshot: ContextSnapshot): void;
|
|
81
|
+
loadContextSnapshots(): ContextSnapshot[];
|
|
82
|
+
}
|
|
83
|
+
interface MemoryRunState {
|
|
84
|
+
events: HarnessEventRecord[];
|
|
85
|
+
transcript: AgentMessage[];
|
|
86
|
+
metrics?: RunMetrics;
|
|
87
|
+
snapshots: Map<string, HarnessSnapshot>;
|
|
88
|
+
cursors?: RunCursorState;
|
|
89
|
+
contextSnapshots: Map<string, ContextSnapshot>;
|
|
90
|
+
}
|
|
91
|
+
declare class MemoryRunStorage extends HarnessRunStorage {
|
|
92
|
+
readonly id = "memory";
|
|
93
|
+
label: string;
|
|
94
|
+
private readonly runs;
|
|
95
|
+
openRun(input: OpenRunStoreInput): HarnessRunStore;
|
|
96
|
+
}
|
|
97
|
+
declare class MemoryRunStore extends HarnessRunStore {
|
|
98
|
+
readonly runId: string;
|
|
99
|
+
private readonly state;
|
|
100
|
+
readonly outputDir: undefined;
|
|
101
|
+
readonly runDir: undefined;
|
|
102
|
+
constructor(runId: string, state: MemoryRunState);
|
|
103
|
+
init(): void;
|
|
104
|
+
recordEvent(event: HarnessEventRecord): void;
|
|
105
|
+
loadEvents(): HarnessEventRecord[];
|
|
106
|
+
saveTranscript(messages: AgentMessage[]): void;
|
|
107
|
+
loadTranscript(): AgentMessage[];
|
|
108
|
+
saveMetrics(metrics: RunMetrics): void;
|
|
109
|
+
saveSnapshot(snapshot: HarnessSnapshot): void;
|
|
110
|
+
loadSnapshots(): HarnessSnapshot[];
|
|
111
|
+
deleteSnapshot(id: string): void;
|
|
112
|
+
saveCursors(cursors: RunCursorState): void;
|
|
113
|
+
loadCursors(): RunCursorState | undefined;
|
|
114
|
+
saveContextSnapshot(snapshot: ContextSnapshot): void;
|
|
115
|
+
loadContextSnapshots(): ContextSnapshot[];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { HarnessRunStorage as H, MemoryRunStorage as M, NoopRunStorage as N, type OpenRunStoreInput as O, type RunCursorState as R, type ToolCallMetric as T, HarnessRunStore as a, MemoryRunStore as b, NoopRunStore as c, type RunMetrics as d };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
type ToolErrorCode = "tool.args.invalid_schema" | "tool.approval.denied" | "sandbox.exec.failed" | "tool.failed";
|
|
2
|
+
interface ToolInvalidField {
|
|
3
|
+
path: string;
|
|
4
|
+
code?: string;
|
|
5
|
+
expected?: string;
|
|
6
|
+
received?: string;
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
interface ToolErrorPayload {
|
|
10
|
+
ok: false;
|
|
11
|
+
error: {
|
|
12
|
+
code: ToolErrorCode;
|
|
13
|
+
message: string;
|
|
14
|
+
toolName: string;
|
|
15
|
+
invalidFields?: ToolInvalidField[];
|
|
16
|
+
metadata?: Record<string, unknown>;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
declare function createToolErrorPayload(input: {
|
|
20
|
+
code: ToolErrorCode;
|
|
21
|
+
message: string;
|
|
22
|
+
toolName: string;
|
|
23
|
+
invalidFields?: ToolInvalidField[];
|
|
24
|
+
metadata?: Record<string, unknown>;
|
|
25
|
+
}): ToolErrorPayload;
|
|
26
|
+
|
|
27
|
+
export { type ToolErrorCode as T, type ToolErrorPayload as a, type ToolInvalidField as b, createToolErrorPayload as c };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
type HarnessLogLevel = "debug" | "info" | "warn" | "error";
|
|
2
|
+
type HarnessLoggingLevel = "silent" | HarnessLogLevel;
|
|
3
|
+
type HarnessLogCategory = "session" | "run" | "turn" | "context" | "model" | "tool" | "approval" | "snapshot" | "transcript" | "storage" | "agent";
|
|
4
|
+
type HarnessLogSourceKind = "runtime" | "model_provider" | "tool" | "hook" | "context_provider" | "mode" | "user" | "custom";
|
|
5
|
+
interface HarnessLogSource {
|
|
6
|
+
kind: HarnessLogSourceKind;
|
|
7
|
+
id?: string;
|
|
8
|
+
type?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
}
|
|
12
|
+
interface HarnessLogError {
|
|
13
|
+
name?: string;
|
|
14
|
+
message: string;
|
|
15
|
+
stack?: string;
|
|
16
|
+
}
|
|
17
|
+
interface HarnessLogRecord {
|
|
18
|
+
id: string;
|
|
19
|
+
at: string;
|
|
20
|
+
level: HarnessLogLevel;
|
|
21
|
+
category: HarnessLogCategory;
|
|
22
|
+
type: string;
|
|
23
|
+
message: string;
|
|
24
|
+
sessionId?: string;
|
|
25
|
+
runId?: string;
|
|
26
|
+
turnId?: string;
|
|
27
|
+
modeId?: string;
|
|
28
|
+
branchId?: string;
|
|
29
|
+
source: HarnessLogSource;
|
|
30
|
+
correlationId?: string;
|
|
31
|
+
causationId?: string;
|
|
32
|
+
spanId?: string;
|
|
33
|
+
parentSpanId?: string;
|
|
34
|
+
durationMs?: number;
|
|
35
|
+
fields?: Record<string, unknown>;
|
|
36
|
+
error?: HarnessLogError;
|
|
37
|
+
}
|
|
38
|
+
declare abstract class HarnessLog<TFields = Record<string, unknown>> {
|
|
39
|
+
abstract level: HarnessLogLevel;
|
|
40
|
+
abstract category: HarnessLogCategory;
|
|
41
|
+
abstract message(fields: TFields): string;
|
|
42
|
+
levelFor?(fields: TFields): HarnessLogLevel;
|
|
43
|
+
redact?(fields: TFields): TFields;
|
|
44
|
+
}
|
|
45
|
+
type HarnessLogClass<TFields = Record<string, unknown>> = new () => HarnessLog<TFields>;
|
|
46
|
+
declare abstract class HarnessLogSink {
|
|
47
|
+
abstract write(record: HarnessLogRecord): void | Promise<void>;
|
|
48
|
+
flush?(): void | Promise<void>;
|
|
49
|
+
close?(): void | Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
interface HarnessLoggingConfig {
|
|
52
|
+
level?: HarnessLoggingLevel;
|
|
53
|
+
sinks?: HarnessLogSink[];
|
|
54
|
+
format?: "pretty" | "json";
|
|
55
|
+
modelDeltas?: "none" | "summary" | "full" | boolean;
|
|
56
|
+
events?: boolean;
|
|
57
|
+
redact?: {
|
|
58
|
+
keys?: string[];
|
|
59
|
+
replacement?: string;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
interface HarnessRedactionConfig {
|
|
63
|
+
keys?: string[];
|
|
64
|
+
replacement?: string;
|
|
65
|
+
}
|
|
66
|
+
interface HarnessLogContext {
|
|
67
|
+
sessionId?: string;
|
|
68
|
+
runId?: string;
|
|
69
|
+
turnId?: string;
|
|
70
|
+
modeId?: string;
|
|
71
|
+
branchId?: string;
|
|
72
|
+
source?: HarnessLogSource;
|
|
73
|
+
correlationId?: string;
|
|
74
|
+
causationId?: string;
|
|
75
|
+
spanId?: string;
|
|
76
|
+
parentSpanId?: string;
|
|
77
|
+
durationMs?: number;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { HarnessLog as H, type HarnessLogCategory as a, type HarnessLogClass as b, type HarnessLogContext as c, type HarnessLogError as d, type HarnessLogLevel as e, type HarnessLogRecord as f, HarnessLogSink as g, type HarnessLogSource as h, type HarnessLogSourceKind as i, type HarnessLoggingConfig as j, type HarnessLoggingLevel as k, type HarnessRedactionConfig as l };
|