@harness-kernel/core 0.2.1 → 0.3.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.
Files changed (53) hide show
  1. package/dist/agent/context.d.ts +2 -3
  2. package/dist/agent/context.js +1 -1
  3. package/dist/agent/event.d.ts +3 -2
  4. package/dist/agent/event.js +6 -2
  5. package/dist/agent/hook.d.ts +3 -4
  6. package/dist/agent/hook.js +1 -1
  7. package/dist/agent/mode.d.ts +2 -3
  8. package/dist/agent/mode.js +1 -1
  9. package/dist/agent/role.js +1 -1
  10. package/dist/agent/session.d.ts +3 -4
  11. package/dist/agent/session.js +8 -2
  12. package/dist/agent/tool.d.ts +39 -3
  13. package/dist/agent/tool.js +8 -2
  14. package/dist/agent.d.ts +6 -6
  15. package/dist/{approval-D_G2w-fW.d.ts → approval-Ch0LwJFM.d.ts} +18 -13
  16. package/dist/chunk-2NQ3JL7K.js +502 -0
  17. package/dist/chunk-2NQ3JL7K.js.map +1 -0
  18. package/dist/{chunk-JIJHGB6H.js → chunk-3QOAFCCZ.js} +24 -2
  19. package/dist/chunk-3QOAFCCZ.js.map +1 -0
  20. package/dist/chunk-NCSQEUQC.js +37 -0
  21. package/dist/chunk-NCSQEUQC.js.map +1 -0
  22. package/dist/{chunk-B4Q6CPYO.js → chunk-TCHZYK5Y.js} +3 -1
  23. package/dist/{chunk-B4Q6CPYO.js.map → chunk-TCHZYK5Y.js.map} +1 -1
  24. package/dist/{chunk-QEVKKJ7N.js → chunk-UKXJIKED.js} +354 -132
  25. package/dist/chunk-UKXJIKED.js.map +1 -0
  26. package/dist/{context-BfpLqV11.d.ts → context-Bz9C_rL9.d.ts} +88 -3
  27. package/dist/errors-DHHy8V3O.d.ts +6 -0
  28. package/dist/errors-hpkW3tfR.d.ts +112 -0
  29. package/dist/{event-CKV4EeZ3.d.ts → event-DMBY-R6h.d.ts} +33 -4
  30. package/dist/{hook-CfBbhUQf.d.ts → hook-DD7uuzE3.d.ts} +2 -2
  31. package/dist/index.d.ts +21 -15
  32. package/dist/index.js +19 -6
  33. package/dist/metrics-DMN8bfY6.d.ts +23 -0
  34. package/dist/{model-provider-Ch7tzk1x.d.ts → model-provider-DGkLQJWP.d.ts} +6 -4
  35. package/dist/runner/approval.d.ts +7 -7
  36. package/dist/runner/event.d.ts +3 -2
  37. package/dist/runner/event.js +6 -2
  38. package/dist/runner/logging.d.ts +7 -3
  39. package/dist/runner/logging.js +11 -1
  40. package/dist/runner/model-provider.d.ts +6 -6
  41. package/dist/runner/storage.d.ts +181 -4
  42. package/dist/{runner-B41JEovO.d.ts → runner-CZHeMHKV.d.ts} +7 -5
  43. package/dist/runner.d.ts +9 -8
  44. package/dist/runner.js +11 -5
  45. package/package.json +2 -2
  46. package/dist/chunk-JIJHGB6H.js.map +0 -1
  47. package/dist/chunk-Q44U2CMM.js +0 -239
  48. package/dist/chunk-Q44U2CMM.js.map +0 -1
  49. package/dist/chunk-QEVKKJ7N.js.map +0 -1
  50. package/dist/events-D4xcDi53.d.ts +0 -69
  51. package/dist/storage-DCZE_hES.d.ts +0 -200
  52. package/dist/tool-errors-CygY1Nba.d.ts +0 -27
  53. package/dist/types-BPmsw-mF.d.ts +0 -80
@@ -1,5 +1,4 @@
1
1
  export { c as HarnessRoleSelector } from '../role-BN6KhQxx.js';
2
- export { a as AgentContextProvider, b as AgentContextReader, c as AgentContextSession, C as ContextConsume, z as ContextContribution, B as ContextContributionInput, D as ContextEntry, E as ContextEntryFilter, F as ContextProviderBinding, G as ContextProviderOutput, H as ContextProviderReference, I as ContextProviderRenderResult, J as ContextProviderSummary, K as ContextRegistrationOptions, L as ContextScopes, M as ContextSnapshot, N as HarnessContextProvider, O as HarnessContextProviderClass, P as HarnessContextProviderSelector } from '../context-BfpLqV11.js';
3
- import '../events-D4xcDi53.js';
4
- import '../types-BPmsw-mF.js';
2
+ export { a as AgentContextProvider, b as AgentContextReader, c as AgentContextSession, C as ContextConsume, z as ContextContribution, B as ContextContributionInput, D as ContextEntry, E as ContextEntryFilter, F as ContextProviderBinding, G as ContextProviderOutput, H as ContextProviderReference, I as ContextProviderRenderResult, J as ContextProviderSummary, K as ContextRegistrationOptions, L as ContextScopes, M as ContextSnapshot, N as HarnessContextProvider, O as HarnessContextProviderClass, P as HarnessContextProviderSelector } from '../context-Bz9C_rL9.js';
3
+ import '../errors-hpkW3tfR.js';
5
4
  import '../runner/sandbox.js';
@@ -2,7 +2,7 @@ import {
2
2
  ContextConsume,
3
3
  ContextScopes,
4
4
  HarnessContextProvider
5
- } from "../chunk-B4Q6CPYO.js";
5
+ } from "../chunk-TCHZYK5Y.js";
6
6
  export {
7
7
  ContextConsume,
8
8
  ContextScopes,
@@ -1,3 +1,4 @@
1
- export { H as HarnessEvent, a as HarnessEventClass, b as HarnessEventEmitOptions, c as HarnessEventMetadata, d as HarnessEventQuery, e as HarnessEventRecord, f as HarnessEventSource } from '../events-D4xcDi53.js';
2
- export { C as ContextReadyEvent, E as ErrorEvent, M as MessageDeltaEvent, a as MessageEndEvent, b as MessageStartEvent, c as ModeChangedEvent, d as ModelAfterEvent, e as ModelBeforeEvent, R as RunEndEvent, f as RunStartEvent, S as SnapshotCreatedEvent, g as SnapshotDeletedEvent, h as SnapshotRestoredEvent, T as ToolApprovalRequestedEvent, i as ToolApprovalResolvedEvent, j as ToolEndEvent, k as ToolStartEvent, l as TranscriptCursorChangedEvent, m as TurnEndEvent, n as TurnStartEvent } from '../event-CKV4EeZ3.js';
1
+ export { f as HarnessEvent, g as HarnessEventClass, h as HarnessEventEmitOptions, i as HarnessEventMetadata, j as HarnessEventQuery, k as HarnessEventRecord, l as HarnessEventSource } from '../errors-hpkW3tfR.js';
2
+ export { C as ContextReadyEvent, E as ErrorEvent, M as MessageDeltaEvent, a as MessageEndEvent, b as MessageStartEvent, c as ModeChangedEvent, d as ModelAfterEvent, e as ModelBeforeEvent, R as RunAbortedEvent, f as RunEndEvent, g as RunFailedEvent, h as RunStartEvent, S as SnapshotCreatedEvent, i as SnapshotDeletedEvent, j as SnapshotRestoredEvent, T as ToolApprovalRequestedEvent, k as ToolApprovalResolvedEvent, l as ToolEndEvent, m as ToolStartEvent, n as TranscriptCursorChangedEvent, o as TurnEndEvent, p as TurnStartEvent } from '../event-DMBY-R6h.js';
3
+ import '../metrics-DMN8bfY6.js';
3
4
  import '../schema.js';
@@ -7,7 +7,9 @@ import {
7
7
  ModeChangedEvent,
8
8
  ModelAfterEvent,
9
9
  ModelBeforeEvent,
10
+ RunAbortedEvent,
10
11
  RunEndEvent,
12
+ RunFailedEvent,
11
13
  RunStartEvent,
12
14
  SnapshotCreatedEvent,
13
15
  SnapshotDeletedEvent,
@@ -19,11 +21,11 @@ import {
19
21
  TranscriptCursorChangedEvent,
20
22
  TurnEndEvent,
21
23
  TurnStartEvent
22
- } from "../chunk-JIJHGB6H.js";
24
+ } from "../chunk-3QOAFCCZ.js";
23
25
  import "../chunk-OBKS4AJR.js";
24
26
  import {
25
27
  HarnessEvent
26
- } from "../chunk-B4Q6CPYO.js";
28
+ } from "../chunk-TCHZYK5Y.js";
27
29
  export {
28
30
  ContextReadyEvent,
29
31
  ErrorEvent,
@@ -34,7 +36,9 @@ export {
34
36
  ModeChangedEvent,
35
37
  ModelAfterEvent,
36
38
  ModelBeforeEvent,
39
+ RunAbortedEvent,
37
40
  RunEndEvent,
41
+ RunFailedEvent,
38
42
  RunStartEvent,
39
43
  SnapshotCreatedEvent,
40
44
  SnapshotDeletedEvent,
@@ -1,6 +1,5 @@
1
- export { H as HarnessEvent, a as HarnessEventClass } from '../events-D4xcDi53.js';
2
- export { H as HarnessHook, a as HarnessHookEventClass } from '../hook-CfBbhUQf.js';
3
- import '../context-BfpLqV11.js';
1
+ export { f as HarnessEvent, g as HarnessEventClass } from '../errors-hpkW3tfR.js';
2
+ export { H as HarnessHook, a as HarnessHookEventClass } from '../hook-DD7uuzE3.js';
3
+ import '../context-Bz9C_rL9.js';
4
4
  import '../role-BN6KhQxx.js';
5
- import '../types-BPmsw-mF.js';
6
5
  import '../runner/sandbox.js';
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  HarnessHook
3
- } from "../chunk-B4Q6CPYO.js";
3
+ } from "../chunk-TCHZYK5Y.js";
4
4
  export {
5
5
  HarnessHook
6
6
  };
@@ -1,5 +1,4 @@
1
- export { m as AgentModeDefinition, H as ContextProviderReference, Q as HarnessMode, R as HarnessModeClass, S as HarnessModeSelector, T as HarnessModeSummary, a3 as ToolApprovalMode } from '../context-BfpLqV11.js';
1
+ export { m as AgentModeDefinition, H as ContextProviderReference, a0 as HarnessMode, a1 as HarnessModeClass, a2 as HarnessModeSelector, a3 as HarnessModeSummary, ag as ToolApprovalMode } from '../context-Bz9C_rL9.js';
2
2
  import '../role-BN6KhQxx.js';
3
- import '../events-D4xcDi53.js';
4
- import '../types-BPmsw-mF.js';
3
+ import '../errors-hpkW3tfR.js';
5
4
  import '../runner/sandbox.js';
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  HarnessMode
3
- } from "../chunk-B4Q6CPYO.js";
3
+ } from "../chunk-TCHZYK5Y.js";
4
4
  export {
5
5
  HarnessMode
6
6
  };
@@ -10,7 +10,7 @@ import {
10
10
  systemRole,
11
11
  toolRole,
12
12
  userRole
13
- } from "../chunk-B4Q6CPYO.js";
13
+ } from "../chunk-TCHZYK5Y.js";
14
14
  export {
15
15
  AssistantRole,
16
16
  HarnessRole,
@@ -1,6 +1,5 @@
1
- export { E as EventCursor, d as HarnessEventQuery, e as HarnessEventRecord } from '../events-D4xcDi53.js';
2
- export { A as AgentActionSession, b as AgentContextReader, c as AgentContextSession, d as AgentEventReader, e as AgentEventSession, f as AgentHistorySession, g as AgentLogSession, h as AgentMessage, i as AgentMessageEnqueueOptions, j as AgentMessageInput, l as AgentMessageSession, n as AgentModeReader, o as AgentModeSession, p as AgentReadSession, t as AgentStateReader, u as AgentStateSession, w as AgentToolResult, x as AgentToolSession, C as ContextConsume, D as ContextEntry, E as ContextEntryFilter, K as ContextRegistrationOptions, L as ContextScopes, T as HarnessModeSummary, 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-BfpLqV11.js';
1
+ export { E as EventCursor, e as HarnessErrorShape, j as HarnessEventQuery, k as HarnessEventRecord } from '../errors-hpkW3tfR.js';
2
+ export { A as AgentActionSession, b as AgentContextReader, c as AgentContextSession, d as AgentEventReader, e as AgentEventSession, f as AgentHistorySession, g as AgentLogSession, h as AgentMessage, i as AgentMessageEnqueueOptions, j as AgentMessageInput, l as AgentMessageSession, n as AgentModeReader, o as AgentModeSession, p as AgentReadSession, t as AgentStateReader, u as AgentStateSession, w as AgentToolResult, x as AgentToolSession, C as ContextConsume, D as ContextEntry, E as ContextEntryFilter, K as ContextRegistrationOptions, L as ContextScopes, a3 as HarnessModeSummary, a5 as HarnessSnapshot, a6 as HarnessSnapshotCreator, a7 as HarnessSnapshotInput, a8 as HarnessSnapshotSession, a9 as HarnessSnapshotSummary, ad as HarnessTranscriptSession, an as TranscriptBranch, ao as TranscriptCursor, ap as TranscriptQuery, aq as TranscriptSeekTarget } from '../context-Bz9C_rL9.js';
3
3
  export { c as HarnessRoleSelector, N as NativeRoles, R as RoleTargets } from '../role-BN6KhQxx.js';
4
- export { T as ToolErrorCode, a as ToolErrorPayload, b as ToolInvalidField } from '../tool-errors-CygY1Nba.js';
5
- import '../types-BPmsw-mF.js';
4
+ export { ToolErrorCode, ToolErrorPayload, ToolInvalidField, createToolErrorPayload, createToolErrorResult } from './tool.js';
6
5
  import '../runner/sandbox.js';
@@ -1,13 +1,19 @@
1
+ import {
2
+ createToolErrorPayload,
3
+ createToolErrorResult
4
+ } from "../chunk-NCSQEUQC.js";
1
5
  import {
2
6
  ContextConsume,
3
7
  ContextScopes,
4
8
  NativeRoles,
5
9
  RoleTargets
6
- } from "../chunk-B4Q6CPYO.js";
10
+ } from "../chunk-TCHZYK5Y.js";
7
11
  export {
8
12
  ContextConsume,
9
13
  ContextScopes,
10
14
  NativeRoles,
11
- RoleTargets
15
+ RoleTargets,
16
+ createToolErrorPayload,
17
+ createToolErrorResult
12
18
  };
13
19
  //# sourceMappingURL=session.js.map
@@ -1,5 +1,41 @@
1
- export { v as AgentToolDefinition, w as AgentToolResult, y as AgentToolSource, Z as HarnessTool, _ as HarnessToolClass, $ as HarnessToolSelector, a5 as ToolApprovalResolver, a6 as ToolCatalogEntry, a7 as ToolPermission, a8 as ToolRef, a9 as ToolRisk } from '../context-BfpLqV11.js';
1
+ import { w as AgentToolResult } from '../context-Bz9C_rL9.js';
2
+ export { v as AgentToolDefinition, y as AgentToolSource, aa as HarnessTool, ab as HarnessToolClass, ac as HarnessToolSelector, ai as ToolApprovalResolver, aj as ToolCatalogEntry, ak as ToolPermission, al as ToolRef, am as ToolRisk } from '../context-Bz9C_rL9.js';
3
+ import { a as HarnessErrorCode } from '../errors-hpkW3tfR.js';
2
4
  import '../role-BN6KhQxx.js';
3
- import '../events-D4xcDi53.js';
4
- import '../types-BPmsw-mF.js';
5
5
  import '../runner/sandbox.js';
6
+
7
+ type ToolErrorCode = Extract<HarnessErrorCode, "tool.args.invalid_schema" | "tool.approval.denied" | "sandbox.exec.failed" | "tool.failed">;
8
+ interface ToolInvalidField {
9
+ path: string;
10
+ code?: string;
11
+ expected?: string;
12
+ received?: string;
13
+ message: string;
14
+ }
15
+ interface ToolErrorPayload {
16
+ ok: false;
17
+ error: {
18
+ code: ToolErrorCode;
19
+ message: string;
20
+ toolName: string;
21
+ invalidFields?: ToolInvalidField[];
22
+ metadata?: Record<string, unknown>;
23
+ };
24
+ }
25
+ declare function createToolErrorPayload(input: {
26
+ code: ToolErrorCode;
27
+ message: string;
28
+ toolName: string;
29
+ invalidFields?: ToolInvalidField[];
30
+ metadata?: Record<string, unknown>;
31
+ }): ToolErrorPayload;
32
+ declare function createToolErrorResult(input: {
33
+ code: ToolErrorCode;
34
+ message: string;
35
+ toolName: string;
36
+ content?: string;
37
+ invalidFields?: ToolInvalidField[];
38
+ metadata?: Record<string, unknown>;
39
+ }): AgentToolResult<ToolErrorPayload>;
40
+
41
+ export { AgentToolResult, type ToolErrorCode, type ToolErrorPayload, type ToolInvalidField, createToolErrorPayload, createToolErrorResult };
@@ -1,7 +1,13 @@
1
+ import {
2
+ createToolErrorPayload,
3
+ createToolErrorResult
4
+ } from "../chunk-NCSQEUQC.js";
1
5
  import {
2
6
  HarnessTool
3
- } from "../chunk-B4Q6CPYO.js";
7
+ } from "../chunk-TCHZYK5Y.js";
4
8
  export {
5
- HarnessTool
9
+ HarnessTool,
10
+ createToolErrorPayload,
11
+ createToolErrorResult
6
12
  };
7
13
  //# sourceMappingURL=tool.js.map
package/dist/agent.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { A as AgentDefinition } from './model-provider-Ch7tzk1x.js';
2
- export { J as JsonObject } from './events-D4xcDi53.js';
3
- export { r as AgentSharedState, s as AgentSharedStateDefinition } from './context-BfpLqV11.js';
1
+ import { A as AgentDefinition } from './model-provider-DGkLQJWP.js';
2
+ export { J as JsonObject } from './errors-hpkW3tfR.js';
3
+ export { r as AgentSharedState, s as AgentSharedStateDefinition } from './context-Bz9C_rL9.js';
4
4
  import './role-BN6KhQxx.js';
5
5
  import './runner/sandbox.js';
6
- import './storage-DCZE_hES.js';
7
- import './hook-CfBbhUQf.js';
8
- import './types-BPmsw-mF.js';
6
+ import './runner/storage.js';
7
+ import './metrics-DMN8bfY6.js';
8
+ import './hook-DD7uuzE3.js';
9
9
 
10
10
  declare function defineAgent(definition: AgentDefinition): AgentDefinition;
11
11
 
@@ -1,11 +1,11 @@
1
- import { A as AgentDefinition, H as HarnessModelProvider, e as ModelProviderInfo } from './model-provider-Ch7tzk1x.js';
2
- import { j as HarnessLoggingConfig } from './types-BPmsw-mF.js';
3
- import { e as HarnessEventRecord, a as HarnessEventClass, d as HarnessEventQuery, H as HarnessEvent } from './events-D4xcDi53.js';
4
- import { T as HarnessModeSummary, J as ContextProviderSummary, a6 as ToolCatalogEntry, h as AgentMessage, a9 as ToolRisk, a7 as ToolPermission, w as AgentToolResult, S as HarnessModeSelector, r as AgentSharedState, a0 as HarnessTranscriptSession, X as HarnessSnapshotSession, M as ContextSnapshot } from './context-BfpLqV11.js';
1
+ import { A as AgentDefinition, H as HarnessModelProvider, e as ModelProviderInfo } from './model-provider-DGkLQJWP.js';
2
+ import { a3 as HarnessModeSummary, J as ContextProviderSummary, aj as ToolCatalogEntry, _ as HarnessLoggingConfig, h as AgentMessage, am as ToolRisk, ak as ToolPermission, w as AgentToolResult, a2 as HarnessModeSelector, r as AgentSharedState, ad as HarnessTranscriptSession, a8 as HarnessSnapshotSession, M as ContextSnapshot } from './context-Bz9C_rL9.js';
3
+ import { c as HarnessErrorPolicy, e as HarnessErrorShape, k as HarnessEventRecord, g as HarnessEventClass, j as HarnessEventQuery, f as HarnessEvent } from './errors-hpkW3tfR.js';
5
4
  import { d as HarnessRoleSummary, c as HarnessRoleSelector } from './role-BN6KhQxx.js';
6
- import { c as HarnessSessionStorage, h as RunMetrics, S as SessionListQuery, i as SessionListResult } from './storage-DCZE_hES.js';
7
- import { b as HarnessHookSummary } from './hook-CfBbhUQf.js';
5
+ import { R as RunMetrics } from './metrics-DMN8bfY6.js';
6
+ import { b as HarnessHookSummary } from './hook-DD7uuzE3.js';
8
7
  import { HarnessSandbox } from './runner/sandbox.js';
8
+ import { HarnessSessionStorage, SessionListQuery, SessionListResult } from './runner/storage.js';
9
9
 
10
10
  interface HarnessEventSummary {
11
11
  type: string;
@@ -39,6 +39,7 @@ interface HarnessAppConfig {
39
39
  sandbox?: HarnessSandbox;
40
40
  resources?: Record<string, unknown>;
41
41
  logging?: HarnessLoggingConfig;
42
+ errorPolicy?: HarnessErrorPolicy;
42
43
  }
43
44
  interface HarnessUserInput {
44
45
  id?: string;
@@ -83,12 +84,6 @@ interface ToolApprovalHandle {
83
84
  approve(): Promise<void>;
84
85
  deny(reason?: string): Promise<void>;
85
86
  }
86
- interface HarnessErrorShape {
87
- name?: string;
88
- message: string;
89
- stack?: string;
90
- cause?: unknown;
91
- }
92
87
  type HarnessStreamEvent = {
93
88
  type: "run.started";
94
89
  sessionId: string;
@@ -134,6 +129,16 @@ type HarnessStreamEvent = {
134
129
  } | {
135
130
  type: "run.completed";
136
131
  result: SendResult;
132
+ } | {
133
+ type: "run.failed";
134
+ runId: string;
135
+ error: HarnessErrorShape;
136
+ metrics: RunMetrics;
137
+ } | {
138
+ type: "run.aborted";
139
+ runId: string;
140
+ error: HarnessErrorShape;
141
+ metrics: RunMetrics;
137
142
  } | {
138
143
  type: "error";
139
144
  error: HarnessErrorShape;
@@ -240,4 +245,4 @@ interface HarnessSessionStore {
240
245
  close(): Promise<void>;
241
246
  }
242
247
 
243
- export { type HarnessAgentInput as H, type SendOptions as S, type ToolApprovalHandle as T, type WaitForEventOptions as W, type HarnessAgentManifest as a, type HarnessAppConfig as b, type HarnessErrorShape as c, type HarnessEventSummary as d, type HarnessRunStream as e, type HarnessSession as f, type HarnessSessionEventListener as g, type HarnessSessionListener as h, HarnessSessionPhase as i, type HarnessSessionStatus as j, type HarnessSessionStore as k, type HarnessSessionStoreEvent as l, type HarnessSessionStoreListener as m, type HarnessStorageConfig as n, type HarnessStreamEvent as o, type HarnessUserInput as p, type SendResult as q, type StreamOptions as r };
248
+ export { type HarnessAgentInput as H, type SendOptions as S, type ToolApprovalHandle as T, type WaitForEventOptions as W, type HarnessAgentManifest as a, type HarnessAppConfig as b, type HarnessEventSummary as c, type HarnessRunStream as d, type HarnessSession as e, type HarnessSessionEventListener as f, type HarnessSessionListener as g, HarnessSessionPhase as h, type HarnessSessionStatus as i, type HarnessSessionStore as j, type HarnessSessionStoreEvent as k, type HarnessSessionStoreListener as l, type HarnessStorageConfig as m, type HarnessStreamEvent as n, type HarnessUserInput as o, type SendResult as p, type StreamOptions as q };