@fitchmultz/pi-subagents 0.50.0 → 0.52.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 +63 -2
- package/README.md +36 -5
- package/dist/agent/child-runtime.js +80 -0
- package/dist/agent/contracts.js +15 -24
- package/dist/agent/host.js +3 -16
- package/dist/agent/index.js +212 -192
- package/dist/agent/journal-tail.js +115 -156
- package/dist/agent/launch.js +20 -8
- package/dist/agent/legacy.js +65 -23
- package/dist/agent/notifications.js +138 -47
- package/dist/agent/observation-state.js +246 -0
- package/dist/agent/observation-view.js +258 -0
- package/dist/agent/observation.js +350 -0
- package/dist/agent/observe-card.js +243 -0
- package/dist/agent/observe-chrome.js +85 -0
- package/dist/agent/observe-client.js +285 -0
- package/dist/agent/observe-layout.js +65 -0
- package/dist/agent/observe-reading.js +84 -0
- package/dist/agent/observe-screen.js +400 -96
- package/dist/agent/observe-transcript.js +382 -0
- package/dist/agent/observe.js +250 -43
- package/dist/agent/parking.js +253 -0
- package/dist/agent/process.js +228 -28
- package/dist/agent/receipts.js +92 -20
- package/dist/agent/runner.js +229 -126
- package/dist/agent/shell.js +2 -1
- package/dist/agent/storage.js +47 -12
- package/dist/agent/tool-schemas.js +20 -0
- package/dist/agent/typebox.js +10 -5
- package/dist/agent/usage.js +0 -115
- package/dist/agent/view.js +46 -16
- package/dist/agent/wake.js +99 -0
- package/dist/build-info.js +1 -1
- package/dist/intercom-client.d.ts +26 -0
- package/dist/intercom-client.js +45 -0
- package/dist/pi-intercom/agent-dir.d.ts +1 -0
- package/dist/pi-intercom/bridge-session.js +2 -1
- package/dist/pi-intercom/broker/broker.js +62 -43
- package/dist/pi-intercom/broker/client-last.d.ts +24 -0
- package/dist/pi-intercom/broker/client-last.js +42 -5
- package/dist/pi-intercom/broker/client-park.d.ts +9 -0
- package/dist/pi-intercom/broker/client-park.js +21 -0
- package/dist/pi-intercom/broker/client.d.ts +59 -0
- package/dist/pi-intercom/broker/client.js +55 -29
- package/dist/pi-intercom/broker/connection.d.ts +29 -0
- package/dist/pi-intercom/broker/framing.d.ts +17 -0
- package/dist/pi-intercom/broker/framing.js +10 -7
- package/dist/pi-intercom/broker/guard.js +23 -0
- package/dist/pi-intercom/broker/last.d.ts +30 -0
- package/dist/pi-intercom/broker/last.js +87 -40
- package/dist/pi-intercom/broker/parked.js +107 -0
- package/dist/pi-intercom/broker/paths.d.ts +13 -0
- package/dist/pi-intercom/broker/paths.js +35 -12
- package/dist/pi-intercom/broker/pid.js +5 -1
- package/dist/pi-intercom/broker/server-connection.js +20 -1
- package/dist/pi-intercom/broker/snapshot-reader.d.ts +9 -0
- package/dist/pi-intercom/broker/snapshots.d.ts +29 -0
- package/dist/pi-intercom/broker/targets.d.ts +9 -0
- package/dist/pi-intercom/connection.js +71 -20
- package/dist/pi-intercom/identity.js +6 -5
- package/dist/pi-intercom/inbound-delivery.js +16 -60
- package/dist/pi-intercom/inbound-journal.js +83 -6
- package/dist/pi-intercom/inbound-record.js +18 -1
- package/dist/pi-intercom/inbound.js +22 -37
- package/dist/pi-intercom/index.js +41 -0
- package/dist/pi-intercom/last-message.js +4 -16
- package/dist/pi-intercom/lifecycle.js +88 -3
- package/dist/pi-intercom/outbound.js +5 -15
- package/dist/pi-intercom/reply-tracker.js +7 -6
- package/dist/pi-intercom/reply-wait.js +2 -2
- package/dist/pi-intercom/session-targets.d.ts +24 -0
- package/dist/pi-intercom/tool-registration.js +4 -1
- package/dist/pi-intercom/tool-results.js +5 -7
- package/dist/pi-intercom/tool-schemas.js +12 -26
- package/dist/pi-intercom/types.d.ts +212 -0
- package/dist/pi-intercom/types.js +54 -3
- package/dist/pi-intercom/validation.d.ts +12 -0
- package/dist/pi-intercom/validation.js +3 -0
- package/dist/shared/bounded-json.js +151 -0
- package/dist/shared/compact-cards.js +66 -0
- package/dist/shared/journal-frames.js +3 -6
- package/dist/shared/json-projection.js +267 -129
- package/dist/shared/native-journal.js +123 -56
- package/dist/shared/parking.js +12 -0
- package/dist/shared/post-exit-stdio-guard.js +120 -7
- package/dist/shared/tui-action.js +29 -0
- package/dist/shared/unknown.d.ts +9 -0
- package/docs/code-quality.md +5 -3
- package/docs/development.md +42 -3
- package/docs/intercom-bridge.md +9 -4
- package/docs/intercom.md +228 -7
- package/docs/performance.md +118 -14
- package/docs/reference.md +168 -20
- package/docs/retired-history-maintenance.md +252 -0
- package/package.json +28 -15
- package/scripts/archive-retired-history.mjs +464 -0
- package/scripts/build.mjs +48 -28
- package/scripts/measure-size.mjs +1 -1
- package/scripts/native-package-smoke.mjs +153 -12
- package/scripts/package-smoke.mjs +80 -11
- package/scripts/prepare.mjs +2 -2
- package/scripts/real-pi-live.mjs +377 -0
- package/scripts/real-pi-processes.mjs +6 -1
- package/scripts/real-pi-smoke.mjs +6 -282
- package/scripts/run-tests.mjs +4 -2
- package/scripts/typescript.mjs +35 -0
- package/skills/pi-intercom/SKILL.md +2 -1
- package/skills/pi-subagents/SKILL.md +23 -5
- package/src/agent/child-runtime.ts +105 -0
- package/src/agent/contracts.ts +18 -34
- package/src/agent/host.ts +39 -20
- package/src/agent/index.ts +234 -207
- package/src/agent/journal-tail.ts +141 -153
- package/src/agent/launch.ts +33 -9
- package/src/agent/legacy.ts +85 -31
- package/src/agent/notifications.ts +192 -67
- package/src/agent/observation-state.ts +277 -0
- package/src/agent/observation-view.ts +267 -0
- package/src/agent/observation.ts +409 -0
- package/src/agent/observe-card.ts +304 -0
- package/src/agent/observe-chrome.ts +170 -0
- package/src/agent/observe-client.ts +318 -0
- package/src/agent/observe-layout.ts +79 -0
- package/src/agent/observe-reading.ts +97 -0
- package/src/agent/observe-screen.ts +443 -129
- package/src/agent/observe-transcript.ts +434 -0
- package/src/agent/observe.ts +304 -71
- package/src/agent/parking.ts +341 -0
- package/src/agent/process.ts +280 -37
- package/src/agent/receipts.ts +114 -24
- package/src/agent/runner.ts +227 -149
- package/src/agent/shell.ts +2 -1
- package/src/agent/storage.ts +44 -11
- package/src/agent/tool-schemas.ts +33 -0
- package/src/agent/typebox.ts +12 -7
- package/src/agent/usage.ts +0 -130
- package/src/agent/view.ts +70 -20
- package/src/agent/wake.ts +107 -0
- package/src/intercom-client.ts +108 -0
- package/src/pi-intercom/bridge-session.ts +2 -2
- package/src/pi-intercom/broker/broker.ts +64 -53
- package/src/pi-intercom/broker/client-last.ts +65 -12
- package/src/pi-intercom/broker/client-park.ts +23 -0
- package/src/pi-intercom/broker/client.ts +63 -45
- package/src/pi-intercom/broker/framing.ts +11 -8
- package/src/pi-intercom/broker/guard.ts +33 -0
- package/src/pi-intercom/broker/last.ts +131 -43
- package/src/pi-intercom/broker/parked.ts +130 -0
- package/src/pi-intercom/broker/paths.ts +39 -12
- package/src/pi-intercom/broker/pid.ts +6 -1
- package/src/pi-intercom/broker/server-connection.ts +27 -2
- package/src/pi-intercom/connection.ts +103 -39
- package/src/pi-intercom/identity.ts +8 -5
- package/src/pi-intercom/inbound-delivery.ts +20 -66
- package/src/pi-intercom/inbound-journal.ts +103 -7
- package/src/pi-intercom/inbound-record.ts +21 -4
- package/src/pi-intercom/inbound.ts +32 -49
- package/src/pi-intercom/index.ts +44 -0
- package/src/pi-intercom/last-message.ts +11 -20
- package/src/pi-intercom/lifecycle.ts +117 -14
- package/src/pi-intercom/outbound.ts +7 -16
- package/src/pi-intercom/reply-tracker.ts +8 -6
- package/src/pi-intercom/reply-wait.ts +3 -2
- package/src/pi-intercom/runtime-types.ts +0 -1
- package/src/pi-intercom/tool-registration.ts +4 -1
- package/src/pi-intercom/tool-results.ts +10 -9
- package/src/pi-intercom/tool-schemas.ts +12 -44
- package/src/pi-intercom/types.ts +115 -4
- package/src/pi-intercom/validation.ts +4 -0
- package/src/shared/bounded-json.ts +162 -0
- package/src/shared/compact-cards.ts +118 -0
- package/src/shared/journal-frames.ts +3 -19
- package/src/shared/json-projection.ts +267 -147
- package/src/shared/native-journal.ts +157 -75
- package/src/shared/parking.ts +22 -0
- package/src/shared/post-exit-stdio-guard.ts +165 -7
- package/src/shared/tui-action.ts +39 -0
- package/tsconfig.client.json +8 -0
- package/tsconfig.json +1 -0
- package/src/shared/stream-json.d.ts +0 -10
package/src/agent/host.ts
CHANGED
|
@@ -3,6 +3,42 @@ import * as path from "node:path";
|
|
|
3
3
|
import { findPackageJSON } from "node:module";
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
5
|
import type * as SDK from "@earendil-works/pi-coding-agent";
|
|
6
|
+
import type { Api, Model } from "@earendil-works/pi-ai";
|
|
7
|
+
import type { ThinkingLevel } from "@earendil-works/pi-agent-core";
|
|
8
|
+
import { readIntercomLineage } from "../pi-intercom/identity.ts";
|
|
9
|
+
|
|
10
|
+
export { errorMessage as errorText } from "../shared/unknown.ts";
|
|
11
|
+
|
|
12
|
+
/** Fork-only exact native working state; official Pi lacks it, so its children stay resident. */
|
|
13
|
+
interface LocalWorkingState {
|
|
14
|
+
readonly header: { readonly id: string };
|
|
15
|
+
readonly sessionFile?: string;
|
|
16
|
+
readonly leafId: string | null;
|
|
17
|
+
readonly entries: readonly SDK.SessionEntry[];
|
|
18
|
+
}
|
|
19
|
+
type NativeWorkingState = typeof SDK extends { readWorkingSession: (file: string) => infer S }
|
|
20
|
+
? S
|
|
21
|
+
: never;
|
|
22
|
+
export type WorkingState = [NativeWorkingState] extends [never]
|
|
23
|
+
? LocalWorkingState
|
|
24
|
+
: NativeWorkingState;
|
|
25
|
+
// Working sessions stay optional even when the selected graph declares them, so both hosts
|
|
26
|
+
// keep one checked path. The native resolver is optional until official Pi exports it.
|
|
27
|
+
type HostSDK = Omit<
|
|
28
|
+
typeof SDK,
|
|
29
|
+
"readWorkingSession" | "writeWorkingSession" | "openWorkingSession"
|
|
30
|
+
> & {
|
|
31
|
+
readWorkingSession?: (file: string) => WorkingState;
|
|
32
|
+
writeWorkingSession?: (file: string, state: WorkingState) => void;
|
|
33
|
+
openWorkingSession?: (state: WorkingState) => SDK.SessionManager;
|
|
34
|
+
resolveModelReference?: (
|
|
35
|
+
request: { text: string; provider: string; thinkingSuffix: "strict"; fuzzy: false },
|
|
36
|
+
models: readonly Model<Api>[],
|
|
37
|
+
usable: (provider: string) => boolean,
|
|
38
|
+
) =>
|
|
39
|
+
| { status: "resolved"; model: Model<Api>; thinkingLevel?: ThinkingLevel }
|
|
40
|
+
| { status: "ambiguous" | "not-found" };
|
|
41
|
+
};
|
|
6
42
|
|
|
7
43
|
function isPackage(root: string): boolean {
|
|
8
44
|
const file = path.join(root, "package.json");
|
|
@@ -49,10 +85,10 @@ export function packageRoot(): string {
|
|
|
49
85
|
}
|
|
50
86
|
return path.dirname(manifest);
|
|
51
87
|
}
|
|
52
|
-
export async function loadSDK(root: string): Promise<
|
|
88
|
+
export async function loadSDK(root: string): Promise<HostSDK> {
|
|
53
89
|
// Selected host SDK, not a second package-local runtime hidden behind Jiti aliases.
|
|
54
90
|
// oxlint-disable-next-line typescript/no-unsafe-assignment
|
|
55
|
-
const sdk:
|
|
91
|
+
const sdk: HostSDK = await import(pathToFileURL(path.join(root, "dist/index.js")).href);
|
|
56
92
|
return sdk;
|
|
57
93
|
}
|
|
58
94
|
export function runtimeEntry(): string {
|
|
@@ -61,22 +97,5 @@ export function runtimeEntry(): string {
|
|
|
61
97
|
);
|
|
62
98
|
}
|
|
63
99
|
export function isChild(): boolean {
|
|
64
|
-
|
|
65
|
-
const parent = process.env.PI_INTERCOM_PARENT_SESSION_ID;
|
|
66
|
-
if (root === undefined && parent === undefined) {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
if (
|
|
70
|
-
root === undefined ||
|
|
71
|
-
parent === undefined ||
|
|
72
|
-
root.length === 0 ||
|
|
73
|
-
parent.length === 0 ||
|
|
74
|
-
root !== parent
|
|
75
|
-
) {
|
|
76
|
-
throw new Error("Malformed child identity; delegation is disabled.");
|
|
77
|
-
}
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
export function errorText(error: unknown): string {
|
|
81
|
-
return error instanceof Error ? error.message : JSON.stringify(error);
|
|
100
|
+
return readIntercomLineage() !== undefined;
|
|
82
101
|
}
|