@muha-sdk/pi-adapter 0.0.0-stage → 0.1.13

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Gao Sijie
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,107 @@
1
- # Temporary Holding Version
1
+ # @muha-sdk/pi-adapter
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Pi uses the verified high-level input patch for SDK 1.0.4. See
4
+ [qualification and limitations](https://github.com/Gao-Sijie/muha/blob/main/QUALIFICATION.md)
5
+ for source versions and acceptance. The older Pi/Pi grilling result belongs to
6
+ SDK 0.84.2 and does not qualify SDK 1.0.4.
7
+
8
+ ```ts
9
+ import { createMuhaRuntime } from "@muha-sdk/core";
10
+ import { piAdapter } from "@muha-sdk/pi-adapter";
11
+
12
+ const runtime = await createMuhaRuntime({ harnesses: [piAdapter()] });
13
+ try {
14
+ const session = await runtime.createSession({
15
+ harness: "pi",
16
+ workspacePath: "/absolute/project",
17
+ model: "provider/model",
18
+ approvalPolicy: "autoApprove",
19
+ });
20
+ const turn = await session.startTurn([{ type: "text", text: "Explain this project." }]);
21
+ for await (const event of turn) console.log(event);
22
+ console.log(await turn.result);
23
+ } finally {
24
+ await runtime.close();
25
+ }
26
+ ```
27
+
28
+ ## Native configuration and execution
29
+
30
+ Pi declares the exact official SDK version `@earendil-works/pi-coding-agent@1.0.4`
31
+ as a normal npm dependency; it does not bundle the SDK tree. It is not a PATH
32
+ CLI or a globally installed SDK. Installing this Adapter needs Registry access or
33
+ a prewarmed npm cache. Callers supply native Pi authentication and
34
+ model configuration. `OfficialAdapterOptions.env` can override or delete child
35
+ environment variables, including Pi's `PI_CODING_AGENT_DIR`; it never changes
36
+ the host environment or working directory. Node.js 22.20.0 or newer is required.
37
+
38
+ Each Session handle owns an SDK process. Initialization and native listing use
39
+ short-lived owned processes; only the consumer's main process owns the Muha
40
+ Runtime and Diagnostic Event Store. This is lifecycle isolation, not a sandbox.
41
+ Unexpected owned-process loss closes the whole Runtime; native history can
42
+ be explicitly resumed through a new Runtime. Closing handles does not delete it.
43
+
44
+ Session IDs, listing and parsing belong to native SessionManager. Listings
45
+ include external native sessions and can target deleted Workspaces. SDK default
46
+ skipping of damaged records and silent handling of directory/file read errors
47
+ are accepted, as explicitly approved on 2026-09-08. An empty listing is the SDK's
48
+ result, not proof that physical storage contains no sessions. Muha does not add
49
+ an integrity checker or file parser. Returned identities and Workspaces remain
50
+ validated; explicit SDK errors propagate, and missing references never become
51
+ new Sessions.
52
+
53
+ Model IDs use `provider/model`; effort values are native and model-dependent.
54
+ Create/resume and idle setters verify the SDK's effective selection. Run
55
+ selections do not change persistent defaults. Native history/authentication,
56
+ authorized tool/extension configuration writes and native reload remain intact.
57
+ Whole-execution SDK retry stays disabled so Core owns the Turn retry budget.
58
+ Retries are at-least-once: native history, tools and external side effects can
59
+ repeat. No exactly-once execution, transactional rollback or transparent
60
+ recovery of an interrupted Turn is promised.
61
+
62
+ Private diagnostic records distinguish SDK event callbacks, extension errors,
63
+ native listing results and model-fallback warnings by source. Only the host
64
+ writes the store; SDK runtime/auth objects, logs and Adapter IPC acknowledgements
65
+ are not native evidence. Retained semantic payloads can contain sensitive content
66
+ and remain subject to Core's unredacted storage and caller-managed retention.
67
+
68
+ ## Capabilities and boundaries
69
+
70
+ The static Profile supports ordered text/images, native listing, Workspace
71
+ Skills, model/effort selection, streaming messages/reasoning, tools and usage.
72
+ The current qualification status is recorded in
73
+ `QUALIFICATION.md` in the source repository.
74
+
75
+ - Explicitly select `autoApprove` or `harnessManaged`. Pi has no built-in approval
76
+ gate; neither policy manufactures Approval events or bypasses native denials.
77
+ `interactive`, `autoDeny` and omitted policy (which defaults to `interactive`)
78
+ reject before execution.
79
+ - Submit the ordinary ordered Turn Input array. File/base64 images are converted
80
+ inside this Adapter; consumers need no Pi-specific ordering metadata. A bounded
81
+ high-level SDK patch preserves normal user-message persistence and lifecycle.
82
+ Explicit native input transformations and Skill/template expansion retain their
83
+ native replacement semantics. Pi 1.x also decodes and normalizes images; native omissions or normalization hints produce its replacement message. Image-only input is valid; PNG/JPEG/WebP/GIF are
84
+ the supported Muha media types.
85
+ - Workspace Skills use the native `.pi/skills` target. Pi can install and load
86
+ native extensions, including MCP extensions, independently of Muha.
87
+ `workspaceMcp` and `turnQuestions` remain false; configuring Pi MCP through Muha
88
+ fails and unsupported native UI is not answered on the caller's behalf.
89
+ - Unsupported extension interaction fails with cleanup; an extension that never
90
+ settles after that error is bounded by process termination and Runtime closure.
91
+ Arbitrary third-party extension compatibility and Session replacement from
92
+ native extension commands are not promised.
93
+
94
+ ## Building
95
+
96
+ `npm run build --workspace @muha-sdk/pi-adapter` builds the TypeScript host and
97
+ verified input patch from the repository's locked SDK installation. `npm pack`
98
+ only verifies the prepared patch and fails if worker sources or the patch are
99
+ missing/stale; it does not rewrite an SDK tree used by live processes. The
100
+ resulting tarball contains the patch manifest, private workers and Pi upstream
101
+ MIT license, but not the SDK dependency tree. npm installs the exact SDK version
102
+ as an ordinary dependency. No consumer install script is needed.
103
+
104
+ Owned SDK processes run under the Linux subreaper shipped by the exact Core
105
+ dependency. Session and Runtime closure reclaim native detached Bash processes,
106
+ including children whose PID the SDK has not yet reported. A lost ownership helper
107
+ or cleanup timeout produces an error; it does not prove descendant reclamation.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Mario Zechner
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ import type { HarnessRegistration, OfficialAdapterOptions } from "@muha-sdk/core";
2
+ export type { OfficialAdapterOptions } from "@muha-sdk/core";
3
+ export declare function piAdapter(options?: OfficialAdapterOptions): HarnessRegistration;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAuB,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAevG,YAAY,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,wBAAgB,SAAS,CAAC,OAAO,GAAE,sBAA2B,GAAG,mBAAmB,CAKnF"}
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ import { createOfficialHarnessRegistration, createSkillsCliPlanner } from "@muha-sdk/core/internal";
2
+ import { PiProcess } from "./pi-process.js";
3
+ // Stage-four target Profile. The complete suites and real-Harness gates in #85
4
+ // must pass before this development package can be formally admitted.
5
+ const capabilities = Object.freeze({
6
+ sessionListing: true, imageInput: true,
7
+ approvalPolicies: Object.freeze(["autoApprove", "harnessManaged"]),
8
+ turnQuestions: false, workspaceSkills: true, workspaceMcp: false,
9
+ model: Object.freeze({ selectionAt: Object.freeze(["createSession", "resumeSession", "idleSession"]), observation: "effective" }),
10
+ effort: Object.freeze({ selectionAt: Object.freeze(["createSession", "resumeSession", "idleSession"]), observation: "effective", requiresKnownModel: true }),
11
+ assistantMessageStreaming: true, assistantReasoningStreaming: true, toolEvents: true, turnUsage: true,
12
+ });
13
+ export function piAdapter(options = {}) {
14
+ return createOfficialHarnessRegistration("pi", options, capabilities, {
15
+ planSkill: createSkillsCliPlanner("pi"),
16
+ planMcpServer() { throw new Error("Pi Workspace MCP is not supported"); },
17
+ }, (snapshot, context) => new PiProcess(snapshot, context));
18
+ }
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iCAAiC,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACpG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,+EAA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