pi-harness-runtime 1.1.464 → 1.1.466
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 +85 -0
- package/harness/honcho-init.ts +136 -1
- package/harness/mcp-connector.ts +507 -0
- package/index.ts +186 -5
- package/package.json +1 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/package.json +1 -1
- package/packages/contracts/package.json +1 -1
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/package.json +1 -1
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/logging/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/relay/package.json +1 -1
- package/packages/skill-mcp-client/package.json +1 -1
- package/packages/skills/package.json +1 -1
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/tooling-preference/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/two-phase-review/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/wiki/package.json +1 -1
- package/packages/write-review/package.json +1 -1
package/index.ts
CHANGED
|
@@ -48,11 +48,19 @@ import {
|
|
|
48
48
|
} from "./harness/pending-countdown.ts";
|
|
49
49
|
import { endPendingWait, releaseWait } from "./harness/pending-wait.ts";
|
|
50
50
|
import { isChannelDisabled, setChannelDisabled } from "./harness/notification-settings.ts";
|
|
51
|
+
import {
|
|
52
|
+
createMcpConnector,
|
|
53
|
+
type McpClientLibrary,
|
|
54
|
+
type McpConnector,
|
|
55
|
+
type McpConnectorApi,
|
|
56
|
+
} from "./harness/mcp-connector.ts";
|
|
51
57
|
// The Honcho contract lives with the Honcho integration. A type-only import
|
|
52
58
|
// is erased at runtime, so the startup keeps loading the module lazily.
|
|
53
59
|
import type {
|
|
54
60
|
HonchoInitResult,
|
|
55
61
|
HonchoMcpRegistrar,
|
|
62
|
+
HonchoMcpReport,
|
|
63
|
+
HonchoMcpState,
|
|
56
64
|
} from "./harness/honcho-init.ts";
|
|
57
65
|
import { UsageTracker } from "./tracker.ts";
|
|
58
66
|
import { MirrorStore, type MirrorRecord } from "./mirror.ts";
|
|
@@ -3461,6 +3469,68 @@ function initConsoleGuard(pi: ExtensionAPI): void {
|
|
|
3461
3469
|
});
|
|
3462
3470
|
}
|
|
3463
3471
|
|
|
3472
|
+
/**
|
|
3473
|
+
* The fallback connector for the MCP servers that extensions register.
|
|
3474
|
+
*
|
|
3475
|
+
* Pi expects the extension that handles `mcp_servers_change` to be the one
|
|
3476
|
+
* that connects the registered servers. The built-in MCP extension of Pi
|
|
3477
|
+
* does that job while it is active; this connector takes over only the
|
|
3478
|
+
* servers that nobody else connected, and the tools of the session are the
|
|
3479
|
+
* evidence of who did what.
|
|
3480
|
+
*
|
|
3481
|
+
* The connector works in the background: the session does not wait for it,
|
|
3482
|
+
* because a server that nobody connected is a rare case and the tools of a
|
|
3483
|
+
* server that is still connecting arrive late anyway.
|
|
3484
|
+
*/
|
|
3485
|
+
function initMcpConnector(pi: ExtensionAPI): void {
|
|
3486
|
+
// The typings of the installed runtime may be older than the event
|
|
3487
|
+
// itself, so the registration uses the structural type of the API.
|
|
3488
|
+
const registrar = pi as unknown as {
|
|
3489
|
+
on: (
|
|
3490
|
+
event: string,
|
|
3491
|
+
handler: (...args: unknown[]) => void | Promise<void>,
|
|
3492
|
+
) => void;
|
|
3493
|
+
};
|
|
3494
|
+
const connector = createMcpConnector(pi as unknown as McpConnectorApi, {
|
|
3495
|
+
loadLibrary: async (): Promise<McpClientLibrary> => {
|
|
3496
|
+
const mod = await import("@earendil-works/pi-mcp");
|
|
3497
|
+
// SAFETY: the package exports the client and the two transports
|
|
3498
|
+
// with these names; the interface describes how the connector
|
|
3499
|
+
// uses them.
|
|
3500
|
+
return mod as unknown as McpClientLibrary;
|
|
3501
|
+
},
|
|
3502
|
+
log: (message: string): void => {
|
|
3503
|
+
logStartup(`[pi-harness] ${message}`);
|
|
3504
|
+
},
|
|
3505
|
+
});
|
|
3506
|
+
mcpConnector = connector;
|
|
3507
|
+
|
|
3508
|
+
// The registration of a server while the extensions load is read with
|
|
3509
|
+
// getMcpServers() on session_start; a later registration fires the
|
|
3510
|
+
// change event. Both paths lead to the same place.
|
|
3511
|
+
pi.on("session_start", () => {
|
|
3512
|
+
void connector.connectPending().catch((error: unknown) => {
|
|
3513
|
+
logStartup(
|
|
3514
|
+
`[pi-harness] the MCP fallback connector failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
3515
|
+
);
|
|
3516
|
+
});
|
|
3517
|
+
});
|
|
3518
|
+
|
|
3519
|
+
registrar.on("mcp_servers_change", () => {
|
|
3520
|
+
void connector.connectPending().catch((error: unknown) => {
|
|
3521
|
+
logStartup(
|
|
3522
|
+
`[pi-harness] the MCP fallback connector failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
3523
|
+
);
|
|
3524
|
+
});
|
|
3525
|
+
});
|
|
3526
|
+
|
|
3527
|
+
pi.on("session_shutdown", () => {
|
|
3528
|
+
void connector.close().catch(() => {
|
|
3529
|
+
// A broken connection needs no closing.
|
|
3530
|
+
});
|
|
3531
|
+
});
|
|
3532
|
+
}
|
|
3533
|
+
|
|
3464
3534
|
// --- honcho-memory: Honcho MCP for peer/user memory via https://mcp.honcho.dev ------
|
|
3465
3535
|
// Registers the Honcho MCP server with Pi's NATIVE MCP support and implements
|
|
3466
3536
|
// the automatic memory lifecycle:
|
|
@@ -3485,6 +3555,90 @@ interface HonchoModule {
|
|
|
3485
3555
|
loadHonchoApiKey: () => string | undefined;
|
|
3486
3556
|
/** Removes the credential from a text. */
|
|
3487
3557
|
redactHonchoKey: (text: string, apiKey: string) => string;
|
|
3558
|
+
/**
|
|
3559
|
+
* The state of the MCP server in the session.
|
|
3560
|
+
*
|
|
3561
|
+
* The state is read from the tools of the session, not from the
|
|
3562
|
+
* registration: a registration that Pi accepted says that Pi knows the
|
|
3563
|
+
* server, and nothing about a connection.
|
|
3564
|
+
*/
|
|
3565
|
+
honchoMcpState: (
|
|
3566
|
+
pi: HonchoMcpRegistrar | undefined | null,
|
|
3567
|
+
registered: boolean,
|
|
3568
|
+
) => HonchoMcpState;
|
|
3569
|
+
/** The report of the state, for the startup. */
|
|
3570
|
+
honchoMcpReport: (state: HonchoMcpState, reason?: string) => HonchoMcpReport;
|
|
3571
|
+
}
|
|
3572
|
+
|
|
3573
|
+
/**
|
|
3574
|
+
* How long the startup waits for the tools of the Honcho server.
|
|
3575
|
+
*
|
|
3576
|
+
* A connector connects the registered servers asynchronously, so the tools
|
|
3577
|
+
* are not there when the registration returns. The wait is bounded: a
|
|
3578
|
+
* connector that never connects must not hold the session, and the report
|
|
3579
|
+
* says what it knows when the wait is over.
|
|
3580
|
+
*/
|
|
3581
|
+
const HONCHO_MCP_WAIT_MS = 15_000;
|
|
3582
|
+
|
|
3583
|
+
/** The interval between two checks of the tools of the session. */
|
|
3584
|
+
const HONCHO_MCP_WAIT_INTERVAL_MS = 500;
|
|
3585
|
+
|
|
3586
|
+
/**
|
|
3587
|
+
* The connector of the session.
|
|
3588
|
+
*
|
|
3589
|
+
* The startup report of Honcho names the reason a connection failed, so the
|
|
3590
|
+
* report can tell the user what went wrong.
|
|
3591
|
+
*/
|
|
3592
|
+
let mcpConnector: McpConnector | null = null;
|
|
3593
|
+
|
|
3594
|
+
/**
|
|
3595
|
+
* The name of the Honcho MCP server in Pi.
|
|
3596
|
+
*
|
|
3597
|
+
* The integration keeps the name in its own module, which is loaded lazily:
|
|
3598
|
+
* a value import here would load the whole integration at the startup.
|
|
3599
|
+
*/
|
|
3600
|
+
const HONCHO_MCP_SERVER_NAME = "honcho";
|
|
3601
|
+
|
|
3602
|
+
/**
|
|
3603
|
+
* Correct the report when the tools of the Honcho server appear.
|
|
3604
|
+
*
|
|
3605
|
+
* The connector of Pi connects the registered servers in the background, so
|
|
3606
|
+
* the report of the startup is written before the connection happens. The
|
|
3607
|
+
* wait is bounded and the report is only corrected when the tools are
|
|
3608
|
+
* really there.
|
|
3609
|
+
*/
|
|
3610
|
+
function watchHonchoMcpTools(pi: ExtensionAPI, honcho: HonchoModule): void {
|
|
3611
|
+
const registrar = pi as unknown as HonchoMcpRegistrar;
|
|
3612
|
+
const deadline = Date.now() + HONCHO_MCP_WAIT_MS;
|
|
3613
|
+
const check = (): void => {
|
|
3614
|
+
const state = honcho.honchoMcpState(registrar, true);
|
|
3615
|
+
if (state === "connected") {
|
|
3616
|
+
logStartup("[pi-harness] Honcho: native MCP server connected");
|
|
3617
|
+
// The correction comes from the same report as the startup, so
|
|
3618
|
+
// the two rows cannot drift apart.
|
|
3619
|
+
const report = honcho.honchoMcpReport(state);
|
|
3620
|
+
addHarnessMessage("Honcho", report.text, report.status, report.details);
|
|
3621
|
+
return;
|
|
3622
|
+
}
|
|
3623
|
+
if (Date.now() >= deadline) {
|
|
3624
|
+
// The fallback connector knows why the connection failed, and
|
|
3625
|
+
// the reason is more useful than "nobody connected it".
|
|
3626
|
+
const status = mcpConnector?.statuses.get(HONCHO_MCP_SERVER_NAME);
|
|
3627
|
+
const reason = status?.state === "failed" ? status.reason : undefined;
|
|
3628
|
+
logStartup(
|
|
3629
|
+
`[pi-harness] Honcho: no connector connected the MCP server (the model sees no Honcho tools)${reason ? `: ${reason}` : ""}`,
|
|
3630
|
+
);
|
|
3631
|
+
if (reason) {
|
|
3632
|
+
const report = honcho.honchoMcpReport("registered", reason);
|
|
3633
|
+
addHarnessMessage("Honcho", report.text, report.status, report.details);
|
|
3634
|
+
}
|
|
3635
|
+
return;
|
|
3636
|
+
}
|
|
3637
|
+
const timer = setTimeout(check, HONCHO_MCP_WAIT_INTERVAL_MS);
|
|
3638
|
+
if (typeof timer.unref === "function") timer.unref();
|
|
3639
|
+
};
|
|
3640
|
+
const timer = setTimeout(check, HONCHO_MCP_WAIT_INTERVAL_MS);
|
|
3641
|
+
if (typeof timer.unref === "function") timer.unref();
|
|
3488
3642
|
}
|
|
3489
3643
|
|
|
3490
3644
|
async function initHoncho(pi: ExtensionAPI): Promise<void> {
|
|
@@ -3558,8 +3712,28 @@ async function initHoncho(pi: ExtensionAPI): Promise<void> {
|
|
|
3558
3712
|
case "ready": {
|
|
3559
3713
|
logStartup("[pi-harness] Honcho integration ready");
|
|
3560
3714
|
if (result.mcpRegistered) {
|
|
3561
|
-
|
|
3562
|
-
|
|
3715
|
+
// The registration is a declaration: the tools of the
|
|
3716
|
+
// server reach the model only when an MCP connector
|
|
3717
|
+
// connected it. The tools of the session are the
|
|
3718
|
+
// evidence, so the report names what is true.
|
|
3719
|
+
const state = honcho.honchoMcpState(
|
|
3720
|
+
pi as unknown as HonchoMcpRegistrar,
|
|
3721
|
+
true,
|
|
3722
|
+
);
|
|
3723
|
+
if (state === "connected") {
|
|
3724
|
+
logStartup("[pi-harness] Honcho: native MCP server connected");
|
|
3725
|
+
const report = honcho.honchoMcpReport(state);
|
|
3726
|
+
addHarnessMessage("Honcho", report.text, report.status, report.details);
|
|
3727
|
+
} else {
|
|
3728
|
+
logStartup(
|
|
3729
|
+
"[pi-harness] Honcho: native MCP server registered (the tools reach the model only while an MCP connector is active)",
|
|
3730
|
+
);
|
|
3731
|
+
const report = honcho.honchoMcpReport(state);
|
|
3732
|
+
addHarnessMessage("Honcho", report.text, report.status, report.details);
|
|
3733
|
+
// A connector connects the server in the background:
|
|
3734
|
+
// the report is corrected when the tools appear.
|
|
3735
|
+
watchHonchoMcpTools(pi, honcho);
|
|
3736
|
+
}
|
|
3563
3737
|
} else {
|
|
3564
3738
|
// The memory works, but the model has no Honcho tools: the
|
|
3565
3739
|
// user has to know that, not only the log. The reason of
|
|
@@ -3576,9 +3750,9 @@ async function initHoncho(pi: ExtensionAPI): Promise<void> {
|
|
|
3576
3750
|
const capability = cause.includes("registerMcpServer")
|
|
3577
3751
|
? "This runtime does not provide registerMcpServer: the Honcho memory works, but the model sees no Honcho tools."
|
|
3578
3752
|
: "The Honcho memory works, but the model sees no Honcho tools.";
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3753
|
+
const report = honcho.honchoMcpReport("not_registered", cause);
|
|
3754
|
+
addHarnessMessage("Honcho", report.text, report.status, [
|
|
3755
|
+
...report.details,
|
|
3582
3756
|
capability,
|
|
3583
3757
|
]);
|
|
3584
3758
|
}
|
|
@@ -5030,6 +5204,13 @@ export default async function (pi: ExtensionAPI) {
|
|
|
5030
5204
|
// prompt input field. The guard sends it to the harness log instead.
|
|
5031
5205
|
initConsoleGuard(pi);
|
|
5032
5206
|
|
|
5207
|
+
// --- mcp-connector: the fallback for the MCP servers of the extensions ----
|
|
5208
|
+
// The built-in MCP extension of Pi connects the servers that extensions
|
|
5209
|
+
// register. The connector takes over only the servers that nobody else
|
|
5210
|
+
// connected, so the tools of Honcho reach the model even when the
|
|
5211
|
+
// built-in support is disabled or replaced.
|
|
5212
|
+
initMcpConnector(pi);
|
|
5213
|
+
|
|
5033
5214
|
// --- line-voice-queue: Watch for LINE voice commands ----
|
|
5034
5215
|
void initLineVoiceQueue(pi);
|
|
5035
5216
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-harness/two-phase-review",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.466",
|
|
4
4
|
"description": "pi-harness-runtime — two-phase implementation and review workflow (queue review signals, gate the phase, scope the diff)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|