hermes-action-bridge 0.4.0 → 0.5.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/CHANGELOG.md +35 -0
- package/README.md +111 -14
- package/dist/adapters/hermes-cli.d.ts +14 -0
- package/dist/adapters/hermes-cli.js +80 -19
- package/dist/adapters/hermes-cli.js.map +1 -1
- package/dist/approvals.d.ts +35 -0
- package/dist/approvals.js +96 -0
- package/dist/approvals.js.map +1 -0
- package/dist/audit-log.d.ts +21 -0
- package/dist/audit-log.js +31 -0
- package/dist/audit-log.js.map +1 -0
- package/dist/capabilities.d.ts +29 -0
- package/dist/capabilities.js +24 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/cli.js +205 -18
- package/dist/cli.js.map +1 -1
- package/dist/doctor.d.ts +8 -1
- package/dist/doctor.js +76 -13
- package/dist/doctor.js.map +1 -1
- package/dist/execution-gate.d.ts +5 -0
- package/dist/execution-gate.js +20 -0
- package/dist/execution-gate.js.map +1 -0
- package/dist/http-server.d.ts +18 -0
- package/dist/http-server.js +310 -0
- package/dist/http-server.js.map +1 -0
- package/dist/install/launcher.d.ts +3 -0
- package/dist/install/launcher.js +7 -0
- package/dist/install/launcher.js.map +1 -0
- package/dist/install/mcp-service.d.ts +44 -0
- package/dist/install/mcp-service.js +172 -0
- package/dist/install/mcp-service.js.map +1 -0
- package/dist/install/templates.js +38 -32
- package/dist/install/templates.js.map +1 -1
- package/dist/install/types.d.ts +1 -0
- package/dist/jobs.d.ts +51 -0
- package/dist/jobs.js +244 -0
- package/dist/jobs.js.map +1 -0
- package/dist/mcp-server.d.ts +32 -0
- package/dist/mcp-server.js +382 -25
- package/dist/mcp-server.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/validation.d.ts +1 -0
- package/dist/validation.js +8 -0
- package/dist/validation.js.map +1 -0
- package/docs/ARCHITECTURE.md +67 -7
- package/docs/FUNCTIONAL-TESTS.md +27 -12
- package/examples/claude-code/SKILL.md +35 -29
- package/examples/codex/SKILL.md +35 -29
- package/package.json +5 -3
- package/plugins/hermes-action/.codex-plugin/plugin.json +30 -0
- package/plugins/hermes-action/.mcp.json +8 -0
- package/plugins/hermes-action/assets/app-icon.png +0 -0
- package/plugins/hermes-action/skills/hermes-action-bridge/SKILL.md +61 -0
|
@@ -7,58 +7,64 @@ export function contentVersion(content) {
|
|
|
7
7
|
export function skillMarkdown() {
|
|
8
8
|
return `---
|
|
9
9
|
name: hermes-action-bridge
|
|
10
|
-
description:
|
|
10
|
+
description: Use Hermes Agent for Hermes-owned skills, memory, connected services, messaging, browser workflows, schedules, and external automation. Prefer the installed hermes_* MCP tools; use the CLI only as a fallback.
|
|
11
11
|
---
|
|
12
12
|
|
|
13
13
|
# Hermes Action Bridge
|
|
14
14
|
|
|
15
|
-
Use this skill when a task needs capabilities
|
|
16
|
-
Hermes skills or memory, messaging platforms, browser
|
|
17
|
-
|
|
18
|
-
configured in Hermes Agent.
|
|
15
|
+
Use this skill when a task needs state or capabilities owned by Hermes Agent:
|
|
16
|
+
Hermes skills or memory, connected services, messaging platforms, browser
|
|
17
|
+
workflows, scheduled automation, or another integration configured in Hermes.
|
|
19
18
|
|
|
20
|
-
Do not reimplement
|
|
21
|
-
\`
|
|
19
|
+
Do not reimplement a Hermes-owned integration in the coding agent. Prefer the
|
|
20
|
+
installed \`hermes_*\` MCP tools so the host can discover, approve, and inspect
|
|
21
|
+
the delegation.
|
|
22
22
|
|
|
23
23
|
## When to use
|
|
24
24
|
|
|
25
|
-
- The task
|
|
26
|
-
- The task needs
|
|
27
|
-
- The task
|
|
25
|
+
- The task names Hermes, a Hermes skill, memory, preset, or connected service.
|
|
26
|
+
- The task needs messaging, scheduling, browser work, or persistent external automation Hermes owns.
|
|
27
|
+
- The task must continue as a cancellable background job outside the local coding step.
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
Do not use Hermes for ordinary local code edits or repository inspection that
|
|
30
|
+
the current agent can perform directly.
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
## Discover first
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
\`\`\`
|
|
34
|
+
Call \`hermes_capabilities\` before assuming an integration is configured. Use
|
|
35
|
+
\`hermes_status\` to check the runtime without spending provider tokens.
|
|
36
36
|
|
|
37
|
-
##
|
|
37
|
+
## Safe delegation
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
\`\`\`
|
|
39
|
+
- Use \`hermes_plan\` for plan-mode analysis, but treat it as open-world and review its output.
|
|
40
|
+
- Use \`hermes_submit\`, then \`hermes_job_status\` / \`hermes_result\`, for a
|
|
41
|
+
long cancellable plan or draft.
|
|
42
|
+
- Use \`hermes_cancel\` when a queued or running job is no longer wanted.
|
|
44
43
|
|
|
45
44
|
## External side effects
|
|
46
45
|
|
|
47
|
-
For public posts, outbound
|
|
48
|
-
|
|
46
|
+
For public posts, outbound messages, deletes, payments, credential changes, or
|
|
47
|
+
git pushes:
|
|
48
|
+
|
|
49
|
+
1. Call \`hermes_prepare\` to produce a local no-tool summary and approval ID.
|
|
50
|
+
2. Show \`preview.action\` and the rest of the preview to the human.
|
|
51
|
+
3. Call \`hermes_approve\` only after the human explicitly approves that
|
|
52
|
+
prepared action; otherwise call \`hermes_reject\`.
|
|
53
|
+
|
|
54
|
+
Never treat the model's own decision as human approval.
|
|
55
|
+
|
|
56
|
+
## CLI fallback
|
|
57
|
+
|
|
58
|
+
If MCP tools are unavailable, use the local CLI:
|
|
49
59
|
|
|
50
60
|
\`\`\`bash
|
|
51
|
-
hermes-action run --mode
|
|
61
|
+
hermes-action run --mode plan "<describe what Hermes should do>"
|
|
52
62
|
\`\`\`
|
|
53
63
|
|
|
54
|
-
Never use \`--yolo\` unless the human explicitly asked for trusted local
|
|
55
|
-
execution. It bypasses only the bridge policy, not Hermes' own safety rules.
|
|
56
|
-
|
|
57
64
|
## Verify setup
|
|
58
65
|
|
|
59
66
|
\`\`\`bash
|
|
60
|
-
hermes-action
|
|
61
|
-
hermes-action run --dry-run --json "Return BRIDGE_OK only."
|
|
67
|
+
hermes-action doctor
|
|
62
68
|
\`\`\`
|
|
63
69
|
`;
|
|
64
70
|
}
|
|
@@ -67,9 +73,9 @@ export function projectHint() {
|
|
|
67
73
|
return [
|
|
68
74
|
"When a task requires Hermes Agent capabilities (skills, memory, messaging,",
|
|
69
75
|
"browser automation, cron, research, or platform integrations), use the",
|
|
70
|
-
"`hermes-action-bridge` skill and
|
|
71
|
-
"
|
|
72
|
-
"human
|
|
76
|
+
"`hermes-action-bridge` skill and installed `hermes_*` MCP tools. Discover",
|
|
77
|
+
"capabilities first, prefer `hermes_plan`, and use `hermes_prepare` followed",
|
|
78
|
+
"by `hermes_approve` only after explicit human approval for side effects.",
|
|
73
79
|
].join("\n");
|
|
74
80
|
}
|
|
75
81
|
/** Canonical MCP server entry for hermes-action, shared by the printed snippets and the .mcp.json writer. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/install/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,0GAA0G;AAC1G,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACzE,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,aAAa;IAC3B,OAAO
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/install/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,0GAA0G;AAC1G,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACzE,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,aAAa;IAC3B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6DR,CAAC;AACF,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,WAAW;IACzB,OAAO;QACL,4EAA4E;QAC5E,wEAAwE;QACxE,2EAA2E;QAC3E,6EAA6E;QAC7E,0EAA0E;KAC3E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,6GAA6G;AAC7G,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC;AAC7C,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,EAAW,CAAC;AAEnF,0EAA0E;AAC1E,MAAM,UAAU,cAAc;IAC5B,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,EAAE,CAAC,aAAa,CAAC,EAAE,cAAc,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AAC7F,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,mBAAmB;IACjC,OAAO,CAAC,6BAA6B,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACvG,CAAC"}
|
package/dist/install/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type SkillAgent = "claude-code" | "codex";
|
|
2
|
+
export type McpTarget = SkillAgent | "all";
|
|
2
3
|
export type InstallTarget = SkillAgent | "all" | "mcp";
|
|
3
4
|
export type InstallScope = "global" | "project";
|
|
4
5
|
export type ManagedState = "absent" | "current" | "stale" | "user-modified" | "foreign";
|
package/dist/jobs.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { HermesCliExecution } from "./adapters/hermes-cli.js";
|
|
2
|
+
import type { EffectiveRun } from "./types.js";
|
|
3
|
+
export type JobStatus = "queued" | "running" | "succeeded" | "failed" | "cancelled" | "timed_out";
|
|
4
|
+
export interface JobOutput {
|
|
5
|
+
stdout: string;
|
|
6
|
+
stderr: string;
|
|
7
|
+
truncated: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface BridgeJob {
|
|
10
|
+
id: string;
|
|
11
|
+
status: JobStatus;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
startedAt?: string | undefined;
|
|
14
|
+
finishedAt?: string | undefined;
|
|
15
|
+
startBefore?: string | undefined;
|
|
16
|
+
expiresAt: string;
|
|
17
|
+
requestedMode: EffectiveRun["requestedMode"];
|
|
18
|
+
effectiveMode: EffectiveRun["mode"];
|
|
19
|
+
presetName: string;
|
|
20
|
+
detectedRisks: EffectiveRun["detectedRisks"];
|
|
21
|
+
exitCode?: number | undefined;
|
|
22
|
+
output?: JobOutput | undefined;
|
|
23
|
+
}
|
|
24
|
+
export interface JobStoreOptions {
|
|
25
|
+
ttlMs?: number | undefined;
|
|
26
|
+
maxOutputBytes?: number | undefined;
|
|
27
|
+
maxConcurrent?: number | undefined;
|
|
28
|
+
maxQueued?: number | undefined;
|
|
29
|
+
now?: () => Date;
|
|
30
|
+
createId?: () => string;
|
|
31
|
+
onSettled?: ((job: BridgeJob) => void) | undefined;
|
|
32
|
+
}
|
|
33
|
+
export interface JobStore {
|
|
34
|
+
submit(run: EffectiveRun, options?: JobSubmitOptions): BridgeJob;
|
|
35
|
+
canSubmit(): boolean;
|
|
36
|
+
get(jobId: string): BridgeJob | undefined;
|
|
37
|
+
cancel(jobId: string): BridgeJob | undefined;
|
|
38
|
+
cleanup(): number;
|
|
39
|
+
shutdown(): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
export interface JobSubmitOptions {
|
|
42
|
+
beforeStart?: ((job: BridgeJob) => void) | undefined;
|
|
43
|
+
startBefore?: string | undefined;
|
|
44
|
+
}
|
|
45
|
+
export type StartExecution = (run: EffectiveRun) => HermesCliExecution;
|
|
46
|
+
export declare const defaultJobMaxOutputBytes: number;
|
|
47
|
+
/**
|
|
48
|
+
* In-process job storage for long-running Hermes requests. It intentionally keeps no prompt or context
|
|
49
|
+
* document after starting the child process, so a status endpoint cannot expose handoff data.
|
|
50
|
+
*/
|
|
51
|
+
export declare function createJobStore(startExecution: StartExecution, options?: JobStoreOptions): JobStore;
|
package/dist/jobs.js
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { positiveInteger } from "./validation.js";
|
|
3
|
+
const defaultTtlMs = 24 * 60 * 60 * 1000;
|
|
4
|
+
export const defaultJobMaxOutputBytes = 256 * 1024;
|
|
5
|
+
const defaultMaxConcurrent = 4;
|
|
6
|
+
const defaultMaxQueued = 32;
|
|
7
|
+
/**
|
|
8
|
+
* In-process job storage for long-running Hermes requests. It intentionally keeps no prompt or context
|
|
9
|
+
* document after starting the child process, so a status endpoint cannot expose handoff data.
|
|
10
|
+
*/
|
|
11
|
+
export function createJobStore(startExecution, options = {}) {
|
|
12
|
+
const ttlMs = positiveInteger(options.ttlMs, defaultTtlMs, "ttlMs");
|
|
13
|
+
const maxOutputBytes = positiveInteger(options.maxOutputBytes, defaultJobMaxOutputBytes, "maxOutputBytes");
|
|
14
|
+
const maxConcurrent = positiveInteger(options.maxConcurrent, defaultMaxConcurrent, "maxConcurrent");
|
|
15
|
+
const maxQueued = positiveInteger(options.maxQueued, defaultMaxQueued, "maxQueued");
|
|
16
|
+
const now = options.now ?? (() => new Date());
|
|
17
|
+
const createId = options.createId ?? randomUUID;
|
|
18
|
+
const onSettled = options.onSettled;
|
|
19
|
+
const jobs = new Map();
|
|
20
|
+
const executions = new Map();
|
|
21
|
+
const queuedRuns = new Map();
|
|
22
|
+
const queue = [];
|
|
23
|
+
const cancelRequested = new Set();
|
|
24
|
+
let shuttingDown = false;
|
|
25
|
+
let shutdownPromise;
|
|
26
|
+
const snapshot = (job) => structuredClone(job);
|
|
27
|
+
const notifySettled = (job) => {
|
|
28
|
+
try {
|
|
29
|
+
onSettled?.(snapshot(job));
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Job settlement must not become an unhandled rejection when best-effort telemetry fails.
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const startNext = () => {
|
|
36
|
+
if (shuttingDown)
|
|
37
|
+
return;
|
|
38
|
+
while (executions.size < maxConcurrent) {
|
|
39
|
+
const id = queue.shift();
|
|
40
|
+
if (!id)
|
|
41
|
+
return;
|
|
42
|
+
const job = jobs.get(id);
|
|
43
|
+
const queued = queuedRuns.get(id);
|
|
44
|
+
if (!job || !queued || job.status !== "queued")
|
|
45
|
+
continue;
|
|
46
|
+
queuedRuns.delete(id);
|
|
47
|
+
if (Date.parse(job.startBefore ?? job.expiresAt) <= now().getTime()) {
|
|
48
|
+
job.status = "timed_out";
|
|
49
|
+
job.finishedAt = now().toISOString();
|
|
50
|
+
notifySettled(job);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
let execution;
|
|
54
|
+
try {
|
|
55
|
+
queued.beforeStart?.(snapshot(job));
|
|
56
|
+
job.status = "running";
|
|
57
|
+
job.startedAt = now().toISOString();
|
|
58
|
+
execution = startExecution(queued.run);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
62
|
+
settleJob(jobs, executions, cancelRequested, id, failedResult(message), now, maxOutputBytes);
|
|
63
|
+
notifySettled(job);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
executions.set(id, execution);
|
|
67
|
+
void execution.result.then((result) => {
|
|
68
|
+
settleJob(jobs, executions, cancelRequested, id, result, now, maxOutputBytes);
|
|
69
|
+
notifySettled(job);
|
|
70
|
+
startNext();
|
|
71
|
+
}, (error) => {
|
|
72
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
73
|
+
settleJob(jobs, executions, cancelRequested, id, failedResult(message), now, maxOutputBytes);
|
|
74
|
+
notifySettled(job);
|
|
75
|
+
startNext();
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const cleanupExpired = () => {
|
|
80
|
+
const current = now().getTime();
|
|
81
|
+
let removed = 0;
|
|
82
|
+
for (const [id, job] of jobs) {
|
|
83
|
+
if (job.status === "running")
|
|
84
|
+
continue;
|
|
85
|
+
const retentionExpired = Date.parse(job.expiresAt) <= current;
|
|
86
|
+
const queuedStartExpired = job.status === "queued"
|
|
87
|
+
&& job.startBefore !== undefined
|
|
88
|
+
&& Date.parse(job.startBefore) <= current;
|
|
89
|
+
if (!retentionExpired && !queuedStartExpired)
|
|
90
|
+
continue;
|
|
91
|
+
if (job.status === "queued") {
|
|
92
|
+
job.status = "timed_out";
|
|
93
|
+
job.finishedAt = now().toISOString();
|
|
94
|
+
notifySettled(job);
|
|
95
|
+
}
|
|
96
|
+
else if (!isTerminal(job.status)) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
jobs.delete(id);
|
|
100
|
+
executions.delete(id);
|
|
101
|
+
queuedRuns.delete(id);
|
|
102
|
+
removeQueuedId(queue, id);
|
|
103
|
+
cancelRequested.delete(id);
|
|
104
|
+
removed += 1;
|
|
105
|
+
}
|
|
106
|
+
return removed;
|
|
107
|
+
};
|
|
108
|
+
return {
|
|
109
|
+
submit(run, submitOptions = {}) {
|
|
110
|
+
if (shuttingDown)
|
|
111
|
+
throw new Error("Job store is shutting down");
|
|
112
|
+
cleanupExpired();
|
|
113
|
+
if (queuedRuns.size >= maxQueued)
|
|
114
|
+
throw new Error(`Hermes job queue is full (${maxQueued} waiting)`);
|
|
115
|
+
const created = now();
|
|
116
|
+
const startBefore = submitOptions.startBefore === undefined ? undefined : Date.parse(submitOptions.startBefore);
|
|
117
|
+
if (startBefore !== undefined && (!Number.isFinite(startBefore) || startBefore <= created.getTime())) {
|
|
118
|
+
throw new Error("Hermes job start deadline has elapsed or is invalid");
|
|
119
|
+
}
|
|
120
|
+
const id = createId();
|
|
121
|
+
if (jobs.has(id))
|
|
122
|
+
throw new Error("Job ID collision");
|
|
123
|
+
const job = {
|
|
124
|
+
id,
|
|
125
|
+
status: "queued",
|
|
126
|
+
createdAt: created.toISOString(),
|
|
127
|
+
...(submitOptions.startBefore === undefined ? {} : { startBefore: submitOptions.startBefore }),
|
|
128
|
+
expiresAt: new Date(created.getTime() + ttlMs).toISOString(),
|
|
129
|
+
requestedMode: run.requestedMode,
|
|
130
|
+
effectiveMode: run.mode,
|
|
131
|
+
presetName: run.presetName,
|
|
132
|
+
detectedRisks: [...run.detectedRisks],
|
|
133
|
+
};
|
|
134
|
+
jobs.set(id, job);
|
|
135
|
+
queuedRuns.set(id, { run: structuredClone(run), beforeStart: submitOptions.beforeStart });
|
|
136
|
+
queue.push(id);
|
|
137
|
+
startNext();
|
|
138
|
+
return snapshot(job);
|
|
139
|
+
},
|
|
140
|
+
canSubmit() {
|
|
141
|
+
cleanupExpired();
|
|
142
|
+
return !shuttingDown && queuedRuns.size < maxQueued;
|
|
143
|
+
},
|
|
144
|
+
get(jobId) {
|
|
145
|
+
cleanupExpired();
|
|
146
|
+
const job = jobs.get(jobId);
|
|
147
|
+
return job ? snapshot(job) : undefined;
|
|
148
|
+
},
|
|
149
|
+
cancel(jobId) {
|
|
150
|
+
cleanupExpired();
|
|
151
|
+
const job = jobs.get(jobId);
|
|
152
|
+
const execution = executions.get(jobId);
|
|
153
|
+
if (!job)
|
|
154
|
+
return undefined;
|
|
155
|
+
if (isTerminal(job.status))
|
|
156
|
+
return snapshot(job);
|
|
157
|
+
if (job.status === "queued") {
|
|
158
|
+
queuedRuns.delete(jobId);
|
|
159
|
+
removeQueuedId(queue, jobId);
|
|
160
|
+
job.status = "cancelled";
|
|
161
|
+
job.finishedAt = now().toISOString();
|
|
162
|
+
notifySettled(job);
|
|
163
|
+
return snapshot(job);
|
|
164
|
+
}
|
|
165
|
+
if (cancelRequested.has(jobId))
|
|
166
|
+
return snapshot(job);
|
|
167
|
+
if (!execution || !execution.cancel())
|
|
168
|
+
return snapshot(job);
|
|
169
|
+
cancelRequested.add(jobId);
|
|
170
|
+
return snapshot(job);
|
|
171
|
+
},
|
|
172
|
+
cleanup: cleanupExpired,
|
|
173
|
+
shutdown() {
|
|
174
|
+
if (shutdownPromise)
|
|
175
|
+
return shutdownPromise;
|
|
176
|
+
shuttingDown = true;
|
|
177
|
+
for (const id of [...queuedRuns.keys()]) {
|
|
178
|
+
const job = jobs.get(id);
|
|
179
|
+
queuedRuns.delete(id);
|
|
180
|
+
removeQueuedId(queue, id);
|
|
181
|
+
if (!job || job.status !== "queued")
|
|
182
|
+
continue;
|
|
183
|
+
job.status = "cancelled";
|
|
184
|
+
job.finishedAt = now().toISOString();
|
|
185
|
+
notifySettled(job);
|
|
186
|
+
}
|
|
187
|
+
const active = [...executions.entries()];
|
|
188
|
+
for (const [id, execution] of active) {
|
|
189
|
+
if (cancelRequested.has(id))
|
|
190
|
+
continue;
|
|
191
|
+
if (execution.cancel())
|
|
192
|
+
cancelRequested.add(id);
|
|
193
|
+
}
|
|
194
|
+
shutdownPromise = Promise.allSettled(active.map(([, execution]) => execution.result)).then(() => undefined);
|
|
195
|
+
return shutdownPromise;
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
function settleJob(jobs, executions, cancelRequested, jobId, result, now, maxOutputBytes) {
|
|
200
|
+
const job = jobs.get(jobId);
|
|
201
|
+
if (!job || isTerminal(job.status))
|
|
202
|
+
return;
|
|
203
|
+
job.status = cancelRequested.has(jobId) ? "cancelled" : result.timedOut ? "timed_out" : result.ok ? "succeeded" : "failed";
|
|
204
|
+
job.finishedAt = now().toISOString();
|
|
205
|
+
job.exitCode = result.exitCode;
|
|
206
|
+
job.output = boundedOutput(result, maxOutputBytes);
|
|
207
|
+
executions.delete(jobId);
|
|
208
|
+
cancelRequested.delete(jobId);
|
|
209
|
+
}
|
|
210
|
+
function boundedOutput(result, maxBytes) {
|
|
211
|
+
const stdoutBytes = Buffer.byteLength(result.stdout, "utf8");
|
|
212
|
+
const stderrBytes = Buffer.byteLength(result.stderr, "utf8");
|
|
213
|
+
if (stdoutBytes + stderrBytes <= maxBytes) {
|
|
214
|
+
return { stdout: result.stdout, stderr: result.stderr, truncated: result.outputTruncated === true };
|
|
215
|
+
}
|
|
216
|
+
const stdout = truncateUtf8(result.stdout, maxBytes);
|
|
217
|
+
const remainingBytes = maxBytes - Buffer.byteLength(stdout, "utf8");
|
|
218
|
+
return { stdout, stderr: truncateUtf8(result.stderr, remainingBytes), truncated: true };
|
|
219
|
+
}
|
|
220
|
+
/** Avoid cutting a multi-byte character, which could otherwise exceed the byte cap after replacement decoding. */
|
|
221
|
+
function truncateUtf8(value, maxBytes) {
|
|
222
|
+
let result = "";
|
|
223
|
+
let used = 0;
|
|
224
|
+
for (const char of value) {
|
|
225
|
+
const bytes = Buffer.byteLength(char, "utf8");
|
|
226
|
+
if (used + bytes > maxBytes)
|
|
227
|
+
break;
|
|
228
|
+
result += char;
|
|
229
|
+
used += bytes;
|
|
230
|
+
}
|
|
231
|
+
return result;
|
|
232
|
+
}
|
|
233
|
+
function failedResult(message) {
|
|
234
|
+
return { ok: false, exitCode: 1, stdout: "", stderr: message, command: [], prompt: "", dryRun: false };
|
|
235
|
+
}
|
|
236
|
+
function isTerminal(status) {
|
|
237
|
+
return status === "succeeded" || status === "failed" || status === "cancelled" || status === "timed_out";
|
|
238
|
+
}
|
|
239
|
+
function removeQueuedId(queue, jobId) {
|
|
240
|
+
const index = queue.indexOf(jobId);
|
|
241
|
+
if (index >= 0)
|
|
242
|
+
queue.splice(index, 1);
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=jobs.js.map
|
package/dist/jobs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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ED,SAAS,YAAY,CAAC,OAAe;IACnC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AACzG,CAAC;AAED,SAAS,UAAU,CAAC,MAAiB;IACnC,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,WAAW,CAAC;AAC3G,CAAC;AAED,SAAS,cAAc,CAAC,KAAe,EAAE,KAAa;IACpD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACnC,IAAI,KAAK,IAAI,CAAC;QAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;AACzC,CAAC"}
|
package/dist/mcp-server.d.ts
CHANGED
|
@@ -1 +1,33 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { type ApprovalStore } from "./approvals.js";
|
|
3
|
+
import { type ExecutionGate } from "./execution-gate.js";
|
|
4
|
+
import { type JobStore } from "./jobs.js";
|
|
5
|
+
import type { BridgeConfig, BridgeMode, EffectiveRun } from "./types.js";
|
|
6
|
+
type BridgeTransport = "stdio" | "http";
|
|
7
|
+
interface RequestAuditContext {
|
|
8
|
+
principalId: string;
|
|
9
|
+
transport: BridgeTransport;
|
|
10
|
+
promptFingerprint: string;
|
|
11
|
+
requestedMode: BridgeMode;
|
|
12
|
+
effectiveMode: BridgeMode;
|
|
13
|
+
presetName: string;
|
|
14
|
+
detectedRisks: EffectiveRun["detectedRisks"];
|
|
15
|
+
}
|
|
16
|
+
export interface BridgeRuntime {
|
|
17
|
+
jobs: JobStore;
|
|
18
|
+
approvals: ApprovalStore;
|
|
19
|
+
auditFile: string;
|
|
20
|
+
jobAudit: Map<string, RequestAuditContext>;
|
|
21
|
+
approvalAudit: Map<string, RequestAuditContext>;
|
|
22
|
+
directExecutions: ExecutionGate;
|
|
23
|
+
dispose(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export interface BridgeServerOptions {
|
|
26
|
+
transport?: BridgeTransport | undefined;
|
|
27
|
+
principalId?: string | undefined;
|
|
28
|
+
runtime?: BridgeRuntime | undefined;
|
|
29
|
+
}
|
|
30
|
+
export declare function createBridgeRuntime(config: BridgeConfig, auditFile?: string): BridgeRuntime;
|
|
31
|
+
export declare function createBridgeMcpServer(config: BridgeConfig, options?: BridgeServerOptions): McpServer;
|
|
1
32
|
export declare function startMcpServer(configPath?: string): Promise<void>;
|
|
33
|
+
export {};
|