@harness-kernel/core 0.3.0 → 0.4.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/dist/{approval-Ch0LwJFM.d.ts → approval-7e8HD-35.d.ts} +2 -2
- package/dist/{chunk-UKXJIKED.js → chunk-BLLQSHQI.js} +39 -21
- package/dist/chunk-BLLQSHQI.js.map +1 -0
- package/dist/{chunk-ZU6ADDET.js → chunk-IWHCNKHK.js} +1 -1
- package/dist/chunk-IWHCNKHK.js.map +1 -0
- package/dist/index.d.ts +7 -6
- package/dist/index.js +2 -2
- package/dist/runner/approval.d.ts +1 -1
- package/dist/runner/sandbox.d.ts +12 -2
- package/dist/runner/sandbox.js +1 -1
- package/dist/{runner-CZHeMHKV.d.ts → runner-BYG9ARAV.d.ts} +5 -2
- package/dist/runner.d.ts +2 -2
- package/dist/runner.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-UKXJIKED.js.map +0 -1
- package/dist/chunk-ZU6ADDET.js.map +0 -1
|
@@ -4,7 +4,7 @@ import { c as HarnessErrorPolicy, e as HarnessErrorShape, k as HarnessEventRecor
|
|
|
4
4
|
import { d as HarnessRoleSummary, c as HarnessRoleSelector } from './role-BN6KhQxx.js';
|
|
5
5
|
import { R as RunMetrics } from './metrics-DMN8bfY6.js';
|
|
6
6
|
import { b as HarnessHookSummary } from './hook-DD7uuzE3.js';
|
|
7
|
-
import { HarnessSandbox } from './runner/sandbox.js';
|
|
7
|
+
import { HarnessSandbox, SandboxCloseInput } from './runner/sandbox.js';
|
|
8
8
|
import { HarnessSessionStorage, SessionListQuery, SessionListResult } from './runner/storage.js';
|
|
9
9
|
|
|
10
10
|
interface HarnessEventSummary {
|
|
@@ -210,7 +210,7 @@ interface HarnessSession {
|
|
|
210
210
|
on(listener: HarnessSessionListener): () => void;
|
|
211
211
|
onEvent<TPayload, TEvent extends HarnessEvent<TPayload>>(eventClass: HarnessEventClass<TPayload, TEvent>, listener: HarnessSessionEventListener<TEvent>): () => void;
|
|
212
212
|
waitForEvent<TPayload, TEvent extends HarnessEvent<TPayload>>(eventClass: HarnessEventClass<TPayload, TEvent>, options?: WaitForEventOptions): Promise<TEvent>;
|
|
213
|
-
close(): Promise<void>;
|
|
213
|
+
close(input?: SandboxCloseInput): Promise<void>;
|
|
214
214
|
}
|
|
215
215
|
type HarnessSessionStoreEvent = {
|
|
216
216
|
type: "session.created";
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
import {
|
|
21
21
|
HarnessSandboxSession,
|
|
22
22
|
NoopSandbox
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-IWHCNKHK.js";
|
|
24
24
|
import {
|
|
25
25
|
HarnessSessionStorage,
|
|
26
26
|
MemorySessionStorage
|
|
@@ -590,11 +590,11 @@ var SandboxManager = class {
|
|
|
590
590
|
this.input.logOpened({ sandboxId: opened.id, workDir: opened.workDir });
|
|
591
591
|
return this.session;
|
|
592
592
|
}
|
|
593
|
-
async close() {
|
|
593
|
+
async close(input = { reason: "close" }) {
|
|
594
594
|
const sandbox = this.session;
|
|
595
595
|
this.session = void 0;
|
|
596
596
|
if (!sandbox) return;
|
|
597
|
-
await sandbox.close?.();
|
|
597
|
+
await sandbox.close?.(input);
|
|
598
598
|
this.input.logClosed({ sandboxId: sandbox.id });
|
|
599
599
|
}
|
|
600
600
|
wrap(base) {
|
|
@@ -629,8 +629,8 @@ var SandboxManager = class {
|
|
|
629
629
|
throw error;
|
|
630
630
|
}
|
|
631
631
|
}
|
|
632
|
-
async close() {
|
|
633
|
-
await base.close?.();
|
|
632
|
+
async close(input2) {
|
|
633
|
+
await base.close?.(input2);
|
|
634
634
|
}
|
|
635
635
|
}();
|
|
636
636
|
}
|
|
@@ -2129,8 +2129,8 @@ var AgentSessionRunner = class {
|
|
|
2129
2129
|
async ensureSandboxOpen() {
|
|
2130
2130
|
await this.sandboxManager.ensureOpen();
|
|
2131
2131
|
}
|
|
2132
|
-
async closeSandbox() {
|
|
2133
|
-
await this.sandboxManager.close();
|
|
2132
|
+
async closeSandbox(input = { reason: "close" }) {
|
|
2133
|
+
await this.sandboxManager.close(input);
|
|
2134
2134
|
}
|
|
2135
2135
|
async closeStore() {
|
|
2136
2136
|
await this.storageCoordinator.close();
|
|
@@ -2162,7 +2162,7 @@ var AgentSessionRunner = class {
|
|
|
2162
2162
|
}
|
|
2163
2163
|
async beginNewRun() {
|
|
2164
2164
|
if (this.started || this.restoredFromRun) {
|
|
2165
|
-
await this.closeSandbox();
|
|
2165
|
+
await this.closeSandbox({ reason: "close" });
|
|
2166
2166
|
this.runIdValue = randomId();
|
|
2167
2167
|
await this.storageCoordinator.beginRun(this.runIdValue);
|
|
2168
2168
|
this.started = false;
|
|
@@ -2253,7 +2253,7 @@ var AgentSessionRunner = class {
|
|
|
2253
2253
|
this.log(RunFailedLog, { error: normalized, internalError: error });
|
|
2254
2254
|
throw error;
|
|
2255
2255
|
} finally {
|
|
2256
|
-
if (runStarted) await this.closeSandbox();
|
|
2256
|
+
if (runStarted) await this.closeSandbox({ reason: "close" });
|
|
2257
2257
|
this.runModelOverride = void 0;
|
|
2258
2258
|
}
|
|
2259
2259
|
}
|
|
@@ -2276,8 +2276,8 @@ var AgentSessionRunner = class {
|
|
|
2276
2276
|
if (!this.restoredFromRun) return;
|
|
2277
2277
|
await this.ensureStoreInitialized();
|
|
2278
2278
|
}
|
|
2279
|
-
async close() {
|
|
2280
|
-
await this.closeSandbox();
|
|
2279
|
+
async close(input = { reason: "close" }) {
|
|
2280
|
+
await this.closeSandbox(input);
|
|
2281
2281
|
await this.closeStore();
|
|
2282
2282
|
}
|
|
2283
2283
|
getTranscript(options) {
|
|
@@ -3830,13 +3830,13 @@ var HarnessSessionImpl = class {
|
|
|
3830
3830
|
waitForEvent(eventClass, options = {}) {
|
|
3831
3831
|
return this.events.waitForEvent(eventClass, options);
|
|
3832
3832
|
}
|
|
3833
|
-
async close() {
|
|
3833
|
+
async close(input = { reason: "close" }) {
|
|
3834
3834
|
if (this.closed) return;
|
|
3835
3835
|
this.closed = true;
|
|
3836
3836
|
this.status.close();
|
|
3837
3837
|
await this.cancelActiveRun("Session closed.");
|
|
3838
3838
|
this.unsubscribeRunner();
|
|
3839
|
-
await this.runner.close();
|
|
3839
|
+
await this.runner.close(input);
|
|
3840
3840
|
this.notifyStatus();
|
|
3841
3841
|
this.events.clear();
|
|
3842
3842
|
await this.logger.close();
|
|
@@ -3892,7 +3892,7 @@ var HarnessSessionImpl = class {
|
|
|
3892
3892
|
this.status.close();
|
|
3893
3893
|
this.approvals.denyAll();
|
|
3894
3894
|
this.unsubscribeRunner();
|
|
3895
|
-
await this.runner.close();
|
|
3895
|
+
await this.runner.close({ reason: "close" });
|
|
3896
3896
|
this.notifyStatus();
|
|
3897
3897
|
this.events.clear();
|
|
3898
3898
|
await this.logger.close();
|
|
@@ -3986,6 +3986,7 @@ var HarnessSessionStoreImpl = class {
|
|
|
3986
3986
|
sessions = /* @__PURE__ */ new Map();
|
|
3987
3987
|
unsubscriptions = /* @__PURE__ */ new Map();
|
|
3988
3988
|
latestRunIds = /* @__PURE__ */ new Map();
|
|
3989
|
+
sessionSandboxes = /* @__PURE__ */ new Map();
|
|
3989
3990
|
listeners = /* @__PURE__ */ new Set();
|
|
3990
3991
|
storage;
|
|
3991
3992
|
closed = false;
|
|
@@ -4000,6 +4001,7 @@ var HarnessSessionStoreImpl = class {
|
|
|
4000
4001
|
const config = mergeConfig({ ...this.config, storage: this.storage }, overrides);
|
|
4001
4002
|
const stored = await this.storage.getSession(id);
|
|
4002
4003
|
const session = await createHarnessSession(config, { sessionId: id, restoredSession: stored });
|
|
4004
|
+
this.sessionSandboxes.set(id, config.sandbox);
|
|
4003
4005
|
const status = session.getStatus();
|
|
4004
4006
|
if (stored?.latestRunId) this.latestRunIds.set(id, stored.latestRunId);
|
|
4005
4007
|
else this.latestRunIds.delete(id);
|
|
@@ -4053,17 +4055,26 @@ var HarnessSessionStoreImpl = class {
|
|
|
4053
4055
|
}
|
|
4054
4056
|
const session = this.sessions.get(sessionId);
|
|
4055
4057
|
if (!session) return false;
|
|
4056
|
-
this.
|
|
4057
|
-
this.latestRunIds.delete(sessionId);
|
|
4058
|
-
this.unsubscriptions.get(sessionId)?.();
|
|
4059
|
-
this.unsubscriptions.delete(sessionId);
|
|
4060
|
-
await session.close();
|
|
4058
|
+
await this.closeTrackedSession(sessionId, session, { reason: "close" });
|
|
4061
4059
|
return true;
|
|
4062
4060
|
}
|
|
4063
4061
|
async delete(sessionId) {
|
|
4064
|
-
|
|
4062
|
+
const session = this.sessions.get(sessionId);
|
|
4063
|
+
if (session) {
|
|
4064
|
+
await this.closeTrackedSession(sessionId, session, { reason: "delete" });
|
|
4065
|
+
} else {
|
|
4066
|
+
const stored = await this.storage.getSession(sessionId);
|
|
4067
|
+
const sandbox = this.sessionSandboxes.get(sessionId) ?? this.config.sandbox;
|
|
4068
|
+
if (stored || this.sessionSandboxes.has(sessionId)) {
|
|
4069
|
+
await sandbox?.destroy?.({
|
|
4070
|
+
sessionId,
|
|
4071
|
+
agentKey: stored?.agentKey
|
|
4072
|
+
});
|
|
4073
|
+
}
|
|
4074
|
+
}
|
|
4065
4075
|
this.latestRunIds.delete(sessionId);
|
|
4066
4076
|
const deleted = await this.storage.deleteSession(sessionId);
|
|
4077
|
+
this.sessionSandboxes.delete(sessionId);
|
|
4067
4078
|
if (deleted) this.notify({ type: "session.deleted", sessionId });
|
|
4068
4079
|
return deleted;
|
|
4069
4080
|
}
|
|
@@ -4106,6 +4117,13 @@ var HarnessSessionStoreImpl = class {
|
|
|
4106
4117
|
notify(event) {
|
|
4107
4118
|
for (const listener of this.listeners) void listener(event);
|
|
4108
4119
|
}
|
|
4120
|
+
async closeTrackedSession(sessionId, session, input) {
|
|
4121
|
+
this.sessions.delete(sessionId);
|
|
4122
|
+
this.latestRunIds.delete(sessionId);
|
|
4123
|
+
this.unsubscriptions.get(sessionId)?.();
|
|
4124
|
+
this.unsubscriptions.delete(sessionId);
|
|
4125
|
+
await session.close(input);
|
|
4126
|
+
}
|
|
4109
4127
|
};
|
|
4110
4128
|
async function createHarnessSessionStore(config) {
|
|
4111
4129
|
const store = new HarnessSessionStoreImpl(config);
|
|
@@ -4121,4 +4139,4 @@ export {
|
|
|
4121
4139
|
HarnessSessionStoreImpl,
|
|
4122
4140
|
createHarnessSessionStore
|
|
4123
4141
|
};
|
|
4124
|
-
//# sourceMappingURL=chunk-
|
|
4142
|
+
//# sourceMappingURL=chunk-BLLQSHQI.js.map
|