@burtson-labs/host-kit 0.4.28 → 0.4.30
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/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/runner/contract.d.ts +113 -0
- package/dist/runner/contract.d.ts.map +1 -0
- package/dist/runner/contract.js +28 -0
- package/dist/runner/contract.js.map +1 -0
- package/dist/runner/httpGateway.d.ts +40 -0
- package/dist/runner/httpGateway.d.ts.map +1 -0
- package/dist/runner/httpGateway.js +118 -0
- package/dist/runner/httpGateway.js.map +1 -0
- package/dist/runner/remoteSession.d.ts +51 -0
- package/dist/runner/remoteSession.d.ts.map +1 -0
- package/dist/runner/remoteSession.js +125 -0
- package/dist/runner/remoteSession.js.map +1 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export { loadMemory, loadCombinedMemory, appendMemory, consolidateMemory, type MemoryBundle, type ConsolidationStrategy, type ConsolidationResult } from './memory';
|
|
2
2
|
export { loadMemoryIndex, renderMemoryIndexBlock, writeMemoryTopic, migrateMemoryToBanditDir, MAX_INDEX_BYTES, MAX_MEMORY_FILE_BYTES, MEMORY_DIR, MEMORY_INDEX_FILE, BANDIT_DIR, BANDIT_MEMORY_DIR, BANDIT_MEMORY_INDEX_FILE, type MemoryIndex, type MemoryIndexEntry, type MemoryWarnFn } from './memoryIndex';
|
|
3
3
|
export { buildReadMemoryTool } from './tools/readMemoryTool';
|
|
4
|
+
export { RUNNER_PROTOCOL_VERSION, type RemoteRunMode, type RemoteTask, type RunnerEvent, type RunnerGateway } from './runner/contract';
|
|
5
|
+
export { HttpRunnerGateway, type HttpGatewayOptions } from './runner/httpGateway';
|
|
6
|
+
export { RemoteSession, type RemoteSessionOptions } from './runner/remoteSession';
|
|
4
7
|
export { loadMcpServersConfig, registerMcpServersFromDisk, globalMcpServersPath, persistMcpActivation, addMcpServerToConfig } from './mcp';
|
|
5
8
|
export { buildGitHubServerConfig, looksLikeGitHubToken, buildSlackServerConfig, looksLikeSlackToken, looksLikeSlackTeamId, buildGitLabServerConfig, looksLikeGitLabToken, buildGmailServerConfig, looksLikeGmailCredentialsPath, buildCustomServerConfig } from './mcpConnectors';
|
|
6
9
|
export { loadApprovedMcpFingerprints, approveMcpFingerprint, revokeMcpFingerprint, mcpTrustPath } from './mcpTrust';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACzB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,EACxB,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,wBAAwB,EACxB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACzB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,EACxB,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,wBAAwB,EACxB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C;AAC3B,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,EACvB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,aAAa,EACb,KAAK,eAAe,EACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC5B,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.CheckpointStore = exports.isChatCapable = exports.suggestOllamaMatch = exports.listInstalledOllamaModels = exports.formatTurnTraceMarkdown = exports.summarizeTurnTrace = exports.parseTurnLog = exports.readTurnTraceById = exports.readTurnTrace = exports.listTurnTraces = exports.listTurnTraceFiles = exports.previewText = exports.openTurnLog = exports.SessionPermissionStore = exports.mergePolicies = exports.emptyPolicy = exports.evaluatePermission = exports.InMemoryBackgroundTaskStore = exports.buildInsightsAiCallback = exports.buildAiInput = exports.writeInsightsReport = exports.renderInsightsHtml = exports.computeInsights = exports.parseTestOutput = exports.buildTestCommand = exports.detectTestFramework = exports.buildTestRunTool = exports.buildListTasksTool = exports.buildCheckTaskTool = exports.buildTaskTool = exports.buildRememberTool = exports.buildWebSearchTool = exports.buildWebFetchTool = exports.buildTodoWriteTool = exports.TodoStore = exports.expandMentions = exports.CYCLE_MODES = exports.PERMISSION_MODES = exports.AutoApprovalLedger = exports.nextCycleMode = exports.isPermissionMode = void 0;
|
|
3
|
+
exports.policyIncludes = exports.commandSignature = exports.grantRuleFor = exports.classifyRisk = exports.evaluateSecurityGuard = exports.runHooks = exports.persistAllowEntry = exports.loadHookSettings = exports.mcpToolCachePath = exports.pruneMcpToolCache = exports.saveMcpToolEntry = exports.loadMcpToolCache = exports.mcpTrustPath = exports.revokeMcpFingerprint = exports.approveMcpFingerprint = exports.loadApprovedMcpFingerprints = exports.buildCustomServerConfig = exports.looksLikeGmailCredentialsPath = exports.buildGmailServerConfig = exports.looksLikeGitLabToken = exports.buildGitLabServerConfig = exports.looksLikeSlackTeamId = exports.looksLikeSlackToken = exports.buildSlackServerConfig = exports.looksLikeGitHubToken = exports.buildGitHubServerConfig = exports.addMcpServerToConfig = exports.persistMcpActivation = exports.globalMcpServersPath = exports.registerMcpServersFromDisk = exports.loadMcpServersConfig = exports.RemoteSession = exports.HttpRunnerGateway = exports.RUNNER_PROTOCOL_VERSION = exports.buildReadMemoryTool = exports.BANDIT_MEMORY_INDEX_FILE = exports.BANDIT_MEMORY_DIR = exports.BANDIT_DIR = exports.MEMORY_INDEX_FILE = exports.MEMORY_DIR = exports.MAX_MEMORY_FILE_BYTES = exports.MAX_INDEX_BYTES = exports.migrateMemoryToBanditDir = exports.writeMemoryTopic = exports.renderMemoryIndexBlock = exports.loadMemoryIndex = exports.consolidateMemory = exports.appendMemory = exports.loadCombinedMemory = exports.loadMemory = void 0;
|
|
4
|
+
exports.CheckpointStore = exports.isChatCapable = exports.suggestOllamaMatch = exports.listInstalledOllamaModels = exports.formatTurnTraceMarkdown = exports.summarizeTurnTrace = exports.parseTurnLog = exports.readTurnTraceById = exports.readTurnTrace = exports.listTurnTraces = exports.listTurnTraceFiles = exports.previewText = exports.openTurnLog = exports.SessionPermissionStore = exports.mergePolicies = exports.emptyPolicy = exports.evaluatePermission = exports.InMemoryBackgroundTaskStore = exports.buildInsightsAiCallback = exports.buildAiInput = exports.writeInsightsReport = exports.renderInsightsHtml = exports.computeInsights = exports.parseTestOutput = exports.buildTestCommand = exports.detectTestFramework = exports.buildTestRunTool = exports.buildListTasksTool = exports.buildCheckTaskTool = exports.buildTaskTool = exports.buildRememberTool = exports.buildWebSearchTool = exports.buildWebFetchTool = exports.buildTodoWriteTool = exports.TodoStore = exports.expandMentions = exports.CYCLE_MODES = exports.PERMISSION_MODES = exports.AutoApprovalLedger = exports.nextCycleMode = exports.isPermissionMode = exports.decidePermission = exports.shouldAutoApprove = exports.resolvePermissionMode = void 0;
|
|
5
5
|
var memory_1 = require("./memory");
|
|
6
6
|
Object.defineProperty(exports, "loadMemory", { enumerable: true, get: function () { return memory_1.loadMemory; } });
|
|
7
7
|
Object.defineProperty(exports, "loadCombinedMemory", { enumerable: true, get: function () { return memory_1.loadCombinedMemory; } });
|
|
@@ -21,6 +21,15 @@ Object.defineProperty(exports, "BANDIT_MEMORY_DIR", { enumerable: true, get: fun
|
|
|
21
21
|
Object.defineProperty(exports, "BANDIT_MEMORY_INDEX_FILE", { enumerable: true, get: function () { return memoryIndex_1.BANDIT_MEMORY_INDEX_FILE; } });
|
|
22
22
|
var readMemoryTool_1 = require("./tools/readMemoryTool");
|
|
23
23
|
Object.defineProperty(exports, "buildReadMemoryTool", { enumerable: true, get: function () { return readMemoryTool_1.buildReadMemoryTool; } });
|
|
24
|
+
// Remote control: the local-runner ↔ gateway transport + live-session driver.
|
|
25
|
+
// Host-agnostic (only fetch + ReadableStream), so BOTH the CLI and the VS Code
|
|
26
|
+
// extension import the SAME RemoteSession — one proven mechanism, not two copies.
|
|
27
|
+
var contract_1 = require("./runner/contract");
|
|
28
|
+
Object.defineProperty(exports, "RUNNER_PROTOCOL_VERSION", { enumerable: true, get: function () { return contract_1.RUNNER_PROTOCOL_VERSION; } });
|
|
29
|
+
var httpGateway_1 = require("./runner/httpGateway");
|
|
30
|
+
Object.defineProperty(exports, "HttpRunnerGateway", { enumerable: true, get: function () { return httpGateway_1.HttpRunnerGateway; } });
|
|
31
|
+
var remoteSession_1 = require("./runner/remoteSession");
|
|
32
|
+
Object.defineProperty(exports, "RemoteSession", { enumerable: true, get: function () { return remoteSession_1.RemoteSession; } });
|
|
24
33
|
var mcp_1 = require("./mcp");
|
|
25
34
|
Object.defineProperty(exports, "loadMcpServersConfig", { enumerable: true, get: function () { return mcp_1.loadMcpServersConfig; } });
|
|
26
35
|
Object.defineProperty(exports, "registerMcpServersFromDisk", { enumerable: true, get: function () { return mcp_1.registerMcpServersFromDisk; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,mCAQkB;AAPhB,oGAAA,UAAU,OAAA;AACV,4GAAA,kBAAkB,OAAA;AAClB,sGAAA,YAAY,OAAA;AACZ,2GAAA,iBAAiB,OAAA;AAKnB,6CAeuB;AAdrB,8GAAA,eAAe,OAAA;AACf,qHAAA,sBAAsB,OAAA;AACtB,+GAAA,gBAAgB,OAAA;AAChB,uHAAA,wBAAwB,OAAA;AACxB,8GAAA,eAAe,OAAA;AACf,oHAAA,qBAAqB,OAAA;AACrB,yGAAA,UAAU,OAAA;AACV,gHAAA,iBAAiB,OAAA;AACjB,yGAAA,UAAU,OAAA;AACV,gHAAA,iBAAiB,OAAA;AACjB,uHAAA,wBAAwB,OAAA;AAK1B,yDAA6D;AAApD,qHAAA,mBAAmB,OAAA;AAC5B,6BAMe;AALb,2GAAA,oBAAoB,OAAA;AACpB,iHAAA,0BAA0B,OAAA;AAC1B,2GAAA,oBAAoB,OAAA;AACpB,2GAAA,oBAAoB,OAAA;AACpB,2GAAA,oBAAoB,OAAA;AAEtB,iDAWyB;AAVvB,wHAAA,uBAAuB,OAAA;AACvB,qHAAA,oBAAoB,OAAA;AACpB,uHAAA,sBAAsB,OAAA;AACtB,oHAAA,mBAAmB,OAAA;AAC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,OAAA;AAQzB,+CAKwB;AAJtB,yHAAA,yBAAyB,OAAA;AACzB,kHAAA,kBAAkB,OAAA;AAClB,6GAAA,aAAa,OAAA;AAGf,6CAKuB;AAJrB,8GAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local-runner ↔ gateway contract for REMOTE CONTROL.
|
|
3
|
+
*
|
|
4
|
+
* This is the seam that lets Bandit Stealth Web (or any cloud client) drive the
|
|
5
|
+
* agent running on the user's OWN machine — the local filesystem, the local
|
|
6
|
+
* uncommitted changes — instead of a cloud GitHub clone. It mirrors the
|
|
7
|
+
* cloud-runner seam in `services/agent-runner` (task in → event stream out) but
|
|
8
|
+
* INVERTS the transport: a local process can't be reached by an inbound HTTP
|
|
9
|
+
* POST (it's behind NAT), so the runner reaches OUT to the gateway — subscribes
|
|
10
|
+
* to an inbox of tasks assigned to this device, and pushes events back.
|
|
11
|
+
*
|
|
12
|
+
* Design rules (same spirit as the cloud contract):
|
|
13
|
+
* - The runner treats `taskId` as opaque and echoes it on every event.
|
|
14
|
+
* - The runner never learns about accounts, credits, or billing. It receives
|
|
15
|
+
* a prompt + a mode and returns events. That's all.
|
|
16
|
+
* - Additive-only within a protocol version.
|
|
17
|
+
*
|
|
18
|
+
* SAFETY: unlike the cloud runner (where every change is reviewed as a PR
|
|
19
|
+
* before it touches anything real), a local runner is editing the user's actual
|
|
20
|
+
* working tree with nobody at the keyboard. So a remote task defaults to
|
|
21
|
+
* `plan` mode — read-only — and produces a plan, not silent edits. See
|
|
22
|
+
* planModeGate.ts; the boundary is host-kit's `decidePermission`.
|
|
23
|
+
*/
|
|
24
|
+
export declare const RUNNER_PROTOCOL_VERSION: 1;
|
|
25
|
+
/** The permission mode a remote task runs under. Defaults to `plan` (read-only)
|
|
26
|
+
* for safety — the gateway may request a looser mode only with explicit,
|
|
27
|
+
* per-device authorization (a later phase). */
|
|
28
|
+
export type RemoteRunMode = 'plan' | 'ask' | 'auto';
|
|
29
|
+
/** A task handed to the local runner over the inbox. */
|
|
30
|
+
export interface RemoteTask {
|
|
31
|
+
protocol: typeof RUNNER_PROTOCOL_VERSION;
|
|
32
|
+
/** Gateway task id — opaque, echoed on every event. */
|
|
33
|
+
taskId: string;
|
|
34
|
+
/** The user's goal for this task. */
|
|
35
|
+
prompt: string;
|
|
36
|
+
/** Permission mode for this task. Absent ⇒ `plan` (the safe default). */
|
|
37
|
+
mode?: RemoteRunMode;
|
|
38
|
+
/** Optional hard cap on tool-loop iterations. */
|
|
39
|
+
maxIterations?: number;
|
|
40
|
+
/** When set, this is a turn in a LIVE session (remote control): the host
|
|
41
|
+
* runs it in that session's ongoing conversation and mirrors to the session
|
|
42
|
+
* id, rather than as an isolated one-shot task. */
|
|
43
|
+
sessionId?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Events the runner streams back to the gateway for a task. Intentionally the
|
|
47
|
+
* SAME vocabulary as the cloud runner (`services/agent-runner` RunnerEvent) so
|
|
48
|
+
* the gateway's existing StealthEventBus / SSE / web task UI relays them with
|
|
49
|
+
* no new event handling — a local task looks like any other task to the web.
|
|
50
|
+
*
|
|
51
|
+
* `blocked` is the one addition remote control needs: in plan mode a mutating
|
|
52
|
+
* tool is refused, and the web user should see WHAT the agent wanted to do
|
|
53
|
+
* (that's the "proposed change" a later phase turns into an apply-gate).
|
|
54
|
+
*/
|
|
55
|
+
export type RunnerEvent = {
|
|
56
|
+
type: 'turn.started';
|
|
57
|
+
taskId: string;
|
|
58
|
+
protocol: number;
|
|
59
|
+
runnerVersion: string;
|
|
60
|
+
mode: RemoteRunMode;
|
|
61
|
+
} | {
|
|
62
|
+
type: 'assistant.delta';
|
|
63
|
+
taskId: string;
|
|
64
|
+
text: string;
|
|
65
|
+
} | {
|
|
66
|
+
type: 'tool.call';
|
|
67
|
+
taskId: string;
|
|
68
|
+
tool: string;
|
|
69
|
+
params: Record<string, string>;
|
|
70
|
+
} | {
|
|
71
|
+
type: 'tool.result';
|
|
72
|
+
taskId: string;
|
|
73
|
+
tool: string;
|
|
74
|
+
ok: boolean;
|
|
75
|
+
summary: string;
|
|
76
|
+
} | {
|
|
77
|
+
type: 'tool.blocked';
|
|
78
|
+
taskId: string;
|
|
79
|
+
tool: string;
|
|
80
|
+
reason: string;
|
|
81
|
+
} | {
|
|
82
|
+
type: 'artifact.changed';
|
|
83
|
+
taskId: string;
|
|
84
|
+
path: string;
|
|
85
|
+
kind: 'created' | 'modified' | 'deleted';
|
|
86
|
+
} | {
|
|
87
|
+
type: 'turn.completed';
|
|
88
|
+
taskId: string;
|
|
89
|
+
artifacts: number;
|
|
90
|
+
noChangeReason?: string;
|
|
91
|
+
assistantText: string;
|
|
92
|
+
} | {
|
|
93
|
+
type: 'turn.error';
|
|
94
|
+
taskId: string;
|
|
95
|
+
code: string;
|
|
96
|
+
message: string;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* The transport the engine talks to. Injected so the engine is pure and
|
|
100
|
+
* testable with an in-memory fake — the HTTP implementation (inbox SSE + event
|
|
101
|
+
* POST) is one concrete `RunnerGateway`, a fake in tests is another.
|
|
102
|
+
*/
|
|
103
|
+
export interface RunnerGateway {
|
|
104
|
+
/**
|
|
105
|
+
* Stream of tasks assigned to this device. Yields until `signal` aborts or
|
|
106
|
+
* the connection ends. Implementations reconnect internally; a return means
|
|
107
|
+
* "stop the runner" (shutdown), not "transient blip".
|
|
108
|
+
*/
|
|
109
|
+
inbox(signal: AbortSignal): AsyncIterable<RemoteTask>;
|
|
110
|
+
/** Push one event for a task back to the gateway. Best-effort ordered. */
|
|
111
|
+
publish(taskId: string, event: RunnerEvent): Promise<void>;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/runner/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;A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AI,EAAE,kBAAkB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,CAAA;CAAE,GACpG;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,GAC7G;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1E;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;IACtD,0EAA0E;IAC1E,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5D"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Local-runner ↔ gateway contract for REMOTE CONTROL.
|
|
4
|
+
*
|
|
5
|
+
* This is the seam that lets Bandit Stealth Web (or any cloud client) drive the
|
|
6
|
+
* agent running on the user's OWN machine — the local filesystem, the local
|
|
7
|
+
* uncommitted changes — instead of a cloud GitHub clone. It mirrors the
|
|
8
|
+
* cloud-runner seam in `services/agent-runner` (task in → event stream out) but
|
|
9
|
+
* INVERTS the transport: a local process can't be reached by an inbound HTTP
|
|
10
|
+
* POST (it's behind NAT), so the runner reaches OUT to the gateway — subscribes
|
|
11
|
+
* to an inbox of tasks assigned to this device, and pushes events back.
|
|
12
|
+
*
|
|
13
|
+
* Design rules (same spirit as the cloud contract):
|
|
14
|
+
* - The runner treats `taskId` as opaque and echoes it on every event.
|
|
15
|
+
* - The runner never learns about accounts, credits, or billing. It receives
|
|
16
|
+
* a prompt + a mode and returns events. That's all.
|
|
17
|
+
* - Additive-only within a protocol version.
|
|
18
|
+
*
|
|
19
|
+
* SAFETY: unlike the cloud runner (where every change is reviewed as a PR
|
|
20
|
+
* before it touches anything real), a local runner is editing the user's actual
|
|
21
|
+
* working tree with nobody at the keyboard. So a remote task defaults to
|
|
22
|
+
* `plan` mode — read-only — and produces a plan, not silent edits. See
|
|
23
|
+
* planModeGate.ts; the boundary is host-kit's `decidePermission`.
|
|
24
|
+
*/
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.RUNNER_PROTOCOL_VERSION = void 0;
|
|
27
|
+
exports.RUNNER_PROTOCOL_VERSION = 1;
|
|
28
|
+
//# sourceMappingURL=contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/runner/contract.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAEU,QAAA,uBAAuB,GAAG,CAAU,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP implementation of the RunnerGateway seam.
|
|
3
|
+
*
|
|
4
|
+
* Inbox: a long-lived SSE stream (`GET {base}/api/stealth/runner/inbox`) — the
|
|
5
|
+
* device reaches OUT to the gateway (so no inbound port / NAT hole is needed),
|
|
6
|
+
* and tasks assigned to it arrive as `data:` lines. Reconnects with backoff on
|
|
7
|
+
* a dropped stream; the async iterator only returns when `signal` aborts.
|
|
8
|
+
*
|
|
9
|
+
* Publish: `POST {base}/api/stealth/tasks/{taskId}/events` — one event per call.
|
|
10
|
+
*
|
|
11
|
+
* Both carry the Bandit cloud JWT as a bearer token and a stable device id, so
|
|
12
|
+
* the gateway can authorize the device and scope tasks to its owner. This file
|
|
13
|
+
* is the WIRE CONTRACT the gateway side must implement; it has no tests here
|
|
14
|
+
* because it only exercises against a live gateway (the engine is what's unit-
|
|
15
|
+
* tested, with a fake gateway).
|
|
16
|
+
*/
|
|
17
|
+
import type { RemoteTask, RunnerEvent, RunnerGateway } from './contract';
|
|
18
|
+
export interface HttpGatewayOptions {
|
|
19
|
+
/** Gateway base URL, e.g. https://gateway.burtson.ai (no trailing slash). */
|
|
20
|
+
baseUrl: string;
|
|
21
|
+
/** Bandit cloud JWT / API key for the signed-in account. */
|
|
22
|
+
token: string;
|
|
23
|
+
/** Stable id for this device (so the gateway can target it + show presence). */
|
|
24
|
+
deviceId: string;
|
|
25
|
+
/** Human label shown in the web device picker (hostname by default). */
|
|
26
|
+
deviceLabel?: string;
|
|
27
|
+
/** Injectable for tests / non-global-fetch runtimes. Defaults to global fetch. */
|
|
28
|
+
fetchImpl?: typeof fetch;
|
|
29
|
+
/** Reconnect backoff ceiling (ms). */
|
|
30
|
+
maxBackoffMs?: number;
|
|
31
|
+
}
|
|
32
|
+
export declare class HttpRunnerGateway implements RunnerGateway {
|
|
33
|
+
private readonly opts;
|
|
34
|
+
private readonly fetchImpl;
|
|
35
|
+
constructor(opts: HttpGatewayOptions);
|
|
36
|
+
private headers;
|
|
37
|
+
inbox(signal: AbortSignal): AsyncIterable<RemoteTask>;
|
|
38
|
+
publish(taskId: string, event: RunnerEvent): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=httpGateway.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpGateway.d.ts","sourceRoot":"","sources":["../../src/runner/httpGateway.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEzE,MAAM,WAAW,kBAAkB;IACjC,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd,gFAAgF;IAChF,QAAQ,EAAE,MAAM,CAAC;IACjB,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kFAAkF;IAClF,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,sCAAsC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,iBAAkB,YAAW,aAAa;IAEzC,OAAO,CAAC,QAAQ,CAAC,IAAI;IADjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;gBACZ,IAAI,EAAE,kBAAkB;IAIrD,OAAO,CAAC,OAAO;IASR,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,aAAa,CAAC,UAAU,CAAC;IA+BtD,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAWjE"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpRunnerGateway = void 0;
|
|
4
|
+
class HttpRunnerGateway {
|
|
5
|
+
constructor(opts) {
|
|
6
|
+
this.opts = opts;
|
|
7
|
+
this.fetchImpl = opts.fetchImpl ?? fetch;
|
|
8
|
+
}
|
|
9
|
+
headers(extra) {
|
|
10
|
+
return {
|
|
11
|
+
authorization: `Bearer ${this.opts.token}`,
|
|
12
|
+
'x-bandit-device-id': this.opts.deviceId,
|
|
13
|
+
'x-bandit-device-label': this.opts.deviceLabel ?? this.opts.deviceId,
|
|
14
|
+
...extra
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
async *inbox(signal) {
|
|
18
|
+
const url = `${this.opts.baseUrl}/api/stealth/runner/inbox`;
|
|
19
|
+
const ceil = this.opts.maxBackoffMs ?? 30000;
|
|
20
|
+
let backoff = 1000;
|
|
21
|
+
while (!signal.aborted) {
|
|
22
|
+
try {
|
|
23
|
+
const res = await this.fetchImpl(url, {
|
|
24
|
+
method: 'GET',
|
|
25
|
+
headers: this.headers({ accept: 'text/event-stream' }),
|
|
26
|
+
signal
|
|
27
|
+
});
|
|
28
|
+
if (!res.ok || !res.body) {
|
|
29
|
+
throw new Error(`inbox ${res.status} ${res.statusText}`);
|
|
30
|
+
}
|
|
31
|
+
backoff = 1000; // healthy connection resets the backoff
|
|
32
|
+
for await (const data of readSseData(res.body, signal)) {
|
|
33
|
+
const task = parseTask(data);
|
|
34
|
+
if (task)
|
|
35
|
+
yield task;
|
|
36
|
+
}
|
|
37
|
+
// Stream ended cleanly (server closed) — reconnect after a short pause.
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
if (signal.aborted)
|
|
41
|
+
return;
|
|
42
|
+
// Surface nothing to the model — this is runner plumbing. Backoff+retry.
|
|
43
|
+
void err;
|
|
44
|
+
}
|
|
45
|
+
if (signal.aborted)
|
|
46
|
+
return;
|
|
47
|
+
await delay(backoff, signal);
|
|
48
|
+
backoff = Math.min(ceil, backoff * 2);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async publish(taskId, event) {
|
|
52
|
+
const url = `${this.opts.baseUrl}/api/stealth/tasks/${encodeURIComponent(taskId)}/events`;
|
|
53
|
+
const res = await this.fetchImpl(url, {
|
|
54
|
+
method: 'POST',
|
|
55
|
+
headers: this.headers({ 'content-type': 'application/json' }),
|
|
56
|
+
body: JSON.stringify(event)
|
|
57
|
+
});
|
|
58
|
+
if (!res.ok) {
|
|
59
|
+
throw new Error(`publish ${res.status} ${res.statusText}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.HttpRunnerGateway = HttpRunnerGateway;
|
|
64
|
+
function parseTask(data) {
|
|
65
|
+
try {
|
|
66
|
+
const obj = JSON.parse(data);
|
|
67
|
+
if (obj && typeof obj.taskId === 'string' && typeof obj.prompt === 'string')
|
|
68
|
+
return obj;
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
/* keep-alive comment or malformed line — ignore */
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Minimal SSE reader over a fetch ReadableStream: yields the `data:` payload of
|
|
77
|
+
* each event (concatenating multi-line data blocks), ignoring comments and
|
|
78
|
+
* other fields. Enough for the inbox, which only sends `data:` task JSON +
|
|
79
|
+
* keep-alive comments.
|
|
80
|
+
*/
|
|
81
|
+
async function* readSseData(body, signal) {
|
|
82
|
+
const reader = body.getReader();
|
|
83
|
+
const decoder = new TextDecoder();
|
|
84
|
+
let buffer = '';
|
|
85
|
+
try {
|
|
86
|
+
while (!signal.aborted) {
|
|
87
|
+
const { done, value } = await reader.read();
|
|
88
|
+
if (done)
|
|
89
|
+
break;
|
|
90
|
+
buffer += decoder.decode(value, { stream: true });
|
|
91
|
+
let sep;
|
|
92
|
+
// Events are separated by a blank line.
|
|
93
|
+
while ((sep = buffer.indexOf('\n\n')) !== -1) {
|
|
94
|
+
const rawEvent = buffer.slice(0, sep);
|
|
95
|
+
buffer = buffer.slice(sep + 2);
|
|
96
|
+
const dataLines = rawEvent
|
|
97
|
+
.split('\n')
|
|
98
|
+
.filter((l) => l.startsWith('data:'))
|
|
99
|
+
.map((l) => l.slice(5).replace(/^ /, ''));
|
|
100
|
+
if (dataLines.length)
|
|
101
|
+
yield dataLines.join('\n');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
try {
|
|
107
|
+
await reader.cancel();
|
|
108
|
+
}
|
|
109
|
+
catch { /* already closed */ }
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function delay(ms, signal) {
|
|
113
|
+
return new Promise((resolve) => {
|
|
114
|
+
const t = setTimeout(resolve, ms);
|
|
115
|
+
signal.addEventListener('abort', () => { clearTimeout(t); resolve(); }, { once: true });
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=httpGateway.js.map
|
|
@@ -0,0 +1 @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C,CAAC;qBACpC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;gBAC5C,IAAI,SAAS,CAAC,MAAM;oBAAE,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YAAC,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,oBAAoB,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC;AAED,SAAS,KAAK,CAAC,EAAU,EAAE,MAAmB;IAC5C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,CAAC,GAAG,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAClC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1F,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { RemoteRunMode } from './contract';
|
|
2
|
+
export interface RemoteSessionOptions {
|
|
3
|
+
/** Gateway base URL (no trailing slash). */
|
|
4
|
+
gatewayBase: string;
|
|
5
|
+
/** Bandit cloud JWT / API key. */
|
|
6
|
+
token: string;
|
|
7
|
+
deviceId: string;
|
|
8
|
+
deviceLabel: string;
|
|
9
|
+
/** Web base for the "continue at" URL shown in the banner. */
|
|
10
|
+
webBase: string;
|
|
11
|
+
/** Session title (project folder / first prompt). */
|
|
12
|
+
title: string;
|
|
13
|
+
/** Permission mode for remote turns. */
|
|
14
|
+
mode: RemoteRunMode;
|
|
15
|
+
/** Called when a remote turn arrives — the host enqueues it as the next
|
|
16
|
+
* prompt in the live conversation. */
|
|
17
|
+
onRemoteTurn: (prompt: string) => void;
|
|
18
|
+
/** Runner plumbing logs (not conversation). */
|
|
19
|
+
onStatus?: (message: string) => void;
|
|
20
|
+
}
|
|
21
|
+
export declare class RemoteSession {
|
|
22
|
+
private readonly opts;
|
|
23
|
+
private sessionId;
|
|
24
|
+
private readonly gateway;
|
|
25
|
+
private readonly controller;
|
|
26
|
+
private inboxLoop;
|
|
27
|
+
private readonly fetchImpl;
|
|
28
|
+
constructor(opts: RemoteSessionOptions, fetchImpl?: typeof fetch);
|
|
29
|
+
get id(): string | null;
|
|
30
|
+
get active(): boolean;
|
|
31
|
+
get continueUrl(): string;
|
|
32
|
+
/** Register the session and start receiving remote turns. Returns the
|
|
33
|
+
* continue URL, or throws if registration fails. */
|
|
34
|
+
start(): Promise<string>;
|
|
35
|
+
private consumeInbox;
|
|
36
|
+
/** Mirror the user side of a turn (a prompt) into the session stream. */
|
|
37
|
+
mirrorUser(prompt: string): Promise<void>;
|
|
38
|
+
/** Mirror a structured turn event (tool.call / tool.result /
|
|
39
|
+
* reasoning.text) so remote viewers see the turn's anatomy, not just
|
|
40
|
+
* its final text. */
|
|
41
|
+
mirrorEvent(evt: {
|
|
42
|
+
type: string;
|
|
43
|
+
} & Record<string, unknown>): Promise<void>;
|
|
44
|
+
/** Mirror the assistant side of a turn (the final response). We deliberately
|
|
45
|
+
* DON'T emit turn.completed here — that would flip the session container's
|
|
46
|
+
* status; the gateway keeps a "live" task live. */
|
|
47
|
+
mirrorAssistant(response: string): Promise<void>;
|
|
48
|
+
private post;
|
|
49
|
+
stop(): void;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=remoteSession.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remoteSession.d.ts","sourceRoot":"","sources":["../../src/runner/remoteSession.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,aAAa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AAC,IAAI,CAAC;IAIjF;;wDAEoD;IAC9C,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAIxC,IAAI;IAiBlB,IAAI,IAAI,IAAI;CAcb"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RemoteSession = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Live-session remote control for the interactive REPL — the "continue on your
|
|
6
|
+
* phone / the web" experience.
|
|
7
|
+
*
|
|
8
|
+
* When enabled, the running `bandit` session registers itself as a controllable
|
|
9
|
+
* session with the gateway and:
|
|
10
|
+
* - MIRRORS every turn (local or remote) to the session stream, so another
|
|
11
|
+
* surface can watch the conversation live;
|
|
12
|
+
* - RECEIVES remote turns over the same inbox the one-shot runner uses, and
|
|
13
|
+
* hands them to the host to run as the next prompt IN THE SAME conversation
|
|
14
|
+
* (full context), then mirrors the result back.
|
|
15
|
+
*
|
|
16
|
+
* It reuses the deployed relay (HttpRunnerGateway inbox + the task event
|
|
17
|
+
* ingest) — the only new gateway surface is session register/input. Safety is
|
|
18
|
+
* unchanged: remote turns run under the session's permission mode (plan by
|
|
19
|
+
* default), enforced by the same host-kit boundary.
|
|
20
|
+
*/
|
|
21
|
+
const httpGateway_1 = require("./httpGateway");
|
|
22
|
+
class RemoteSession {
|
|
23
|
+
constructor(opts, fetchImpl) {
|
|
24
|
+
this.opts = opts;
|
|
25
|
+
this.sessionId = null;
|
|
26
|
+
this.controller = new AbortController();
|
|
27
|
+
this.inboxLoop = null;
|
|
28
|
+
this.fetchImpl = fetchImpl ?? fetch;
|
|
29
|
+
this.gateway = new httpGateway_1.HttpRunnerGateway({
|
|
30
|
+
baseUrl: opts.gatewayBase,
|
|
31
|
+
token: opts.token,
|
|
32
|
+
deviceId: opts.deviceId,
|
|
33
|
+
deviceLabel: opts.deviceLabel,
|
|
34
|
+
fetchImpl: this.fetchImpl
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
get id() { return this.sessionId; }
|
|
38
|
+
get active() { return this.sessionId !== null; }
|
|
39
|
+
get continueUrl() {
|
|
40
|
+
return this.sessionId ? `${this.opts.webBase.replace(/\/$/, '')}/remote/${this.sessionId}` : '';
|
|
41
|
+
}
|
|
42
|
+
/** Register the session and start receiving remote turns. Returns the
|
|
43
|
+
* continue URL, or throws if registration fails. */
|
|
44
|
+
async start() {
|
|
45
|
+
const res = await this.fetchImpl(`${this.opts.gatewayBase}/api/stealth/runner/session`, {
|
|
46
|
+
method: 'POST',
|
|
47
|
+
headers: {
|
|
48
|
+
authorization: `Bearer ${this.opts.token}`,
|
|
49
|
+
'content-type': 'application/json',
|
|
50
|
+
'x-bandit-device-id': this.opts.deviceId,
|
|
51
|
+
'x-bandit-device-label': this.opts.deviceLabel
|
|
52
|
+
},
|
|
53
|
+
body: JSON.stringify({ deviceId: this.opts.deviceId, title: this.opts.title, mode: this.opts.mode })
|
|
54
|
+
});
|
|
55
|
+
if (!res.ok) {
|
|
56
|
+
throw new Error(`register session failed: HTTP ${res.status}`);
|
|
57
|
+
}
|
|
58
|
+
const body = (await res.json());
|
|
59
|
+
if (!body.sessionId)
|
|
60
|
+
throw new Error('register session: no sessionId returned');
|
|
61
|
+
this.sessionId = body.sessionId;
|
|
62
|
+
this.inboxLoop = this.consumeInbox();
|
|
63
|
+
return this.continueUrl;
|
|
64
|
+
}
|
|
65
|
+
async consumeInbox() {
|
|
66
|
+
try {
|
|
67
|
+
for await (const task of this.gateway.inbox(this.controller.signal)) {
|
|
68
|
+
// A delivery task carrying OUR session id is a remote turn for this
|
|
69
|
+
// session. (The interactive REPL only handles its own session.)
|
|
70
|
+
if (task.sessionId && task.sessionId === this.sessionId) {
|
|
71
|
+
this.opts.onStatus?.('remote turn received');
|
|
72
|
+
this.opts.onRemoteTurn(task.prompt);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
this.opts.onStatus?.(`inbox stopped: ${err instanceof Error ? err.message : String(err)}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** Mirror the user side of a turn (a prompt) into the session stream. */
|
|
81
|
+
async mirrorUser(prompt) {
|
|
82
|
+
await this.post({ type: 'user.message', text: prompt });
|
|
83
|
+
}
|
|
84
|
+
/** Mirror a structured turn event (tool.call / tool.result /
|
|
85
|
+
* reasoning.text) so remote viewers see the turn's anatomy, not just
|
|
86
|
+
* its final text. */
|
|
87
|
+
async mirrorEvent(evt) {
|
|
88
|
+
await this.post(evt);
|
|
89
|
+
}
|
|
90
|
+
/** Mirror the assistant side of a turn (the final response). We deliberately
|
|
91
|
+
* DON'T emit turn.completed here — that would flip the session container's
|
|
92
|
+
* status; the gateway keeps a "live" task live. */
|
|
93
|
+
async mirrorAssistant(response) {
|
|
94
|
+
await this.post({ type: 'assistant.delta', text: response });
|
|
95
|
+
}
|
|
96
|
+
async post(event) {
|
|
97
|
+
if (!this.sessionId)
|
|
98
|
+
return;
|
|
99
|
+
try {
|
|
100
|
+
const res = await this.fetchImpl(`${this.opts.gatewayBase}/api/stealth/tasks/${encodeURIComponent(this.sessionId)}/events`, {
|
|
101
|
+
method: 'POST',
|
|
102
|
+
headers: { authorization: `Bearer ${this.opts.token}`, 'content-type': 'application/json' },
|
|
103
|
+
body: JSON.stringify({ ...event, taskId: this.sessionId })
|
|
104
|
+
});
|
|
105
|
+
if (!res.ok)
|
|
106
|
+
this.opts.onStatus?.(`mirror ${event.type} failed: HTTP ${res.status}`);
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
this.opts.onStatus?.(`mirror ${event.type} failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
stop() {
|
|
113
|
+
const id = this.sessionId;
|
|
114
|
+
this.controller.abort();
|
|
115
|
+
this.sessionId = null;
|
|
116
|
+
// Tell the gateway, best-effort — without this every /remote off (and
|
|
117
|
+
// every closed terminal) left a zombie 'live' session in listings and
|
|
118
|
+
// a continue link that only fails on first send.
|
|
119
|
+
if (id) {
|
|
120
|
+
void this.fetchImpl(`${this.opts.gatewayBase}/api/stealth/runner/session/${encodeURIComponent(id)}/end`, { method: 'POST', headers: { authorization: `Bearer ${this.opts.token}` } }).catch(() => { });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.RemoteSession = RemoteSession;
|
|
125
|
+
//# sourceMappingURL=remoteSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remoteSession.js","sourceRoot":"","sources":["../../src/runner/remoteSession.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,+CAAkD;AAuBlD,MAAa,aAAa;IAOxB,YAA6B,IAA0B,EAAE,SAAwB;QAApD,SAAI,GAAJ,IAAI,CAAsB;QAN/C,cAAS,GAAkB,IAAI,CAAC;QAEvB,eAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QAC5C,cAAS,GAAyB,IAAI,CAAC;QAI7C,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,KAAK,CAAC;QACpC,IAAI,CAAC,OAAO,GAAG,IAAI,+BAAiB,CAAC;YACnC,OAAO,EAAE,IAAI,CAAC,WAAW;YACzB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC,CAAC;IACL,CAAC;IAED,IAAI,EAAE,KAAoB,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAClD,IAAI,MAAM,KAAc,OAAO,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC;IACzD,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,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IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,CAC5E,CAAC,KAAK,CAAC,GAAG,EAAE,GAAkD,CAAC,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;CACF;AAhHD,sCAgHC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@burtson-labs/host-kit",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.30",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Burtson Labs",
|
|
6
6
|
"email": "team@burtson.ai",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@burtson-labs/agent-core": "1.6.
|
|
25
|
+
"@burtson-labs/agent-core": "1.6.47"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^20.11.0",
|