@zetaloop/chappie 0.4.1 → 1.0.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/.codex-plugin/plugin.json +13 -0
- package/README.md +26 -35
- package/dist/chunk-5CKVVDZ2.js +1042 -0
- package/dist/chunk-DM523QRR.js +148 -0
- package/dist/chunk-DN7OHZK6.js +110 -0
- package/dist/chunk-DQWC5GFN.js +1745 -0
- package/dist/chunk-EIPDEA3I.js +286 -0
- package/dist/chunk-GWYP7B66.js +8479 -0
- package/dist/chunk-GX4JWLHH.js +98 -0
- package/dist/chunk-K2VE2MDU.js +14916 -0
- package/dist/chunk-OWAAWZNT.js +56 -0
- package/dist/chunk-UOFCCHBS.js +94 -0
- package/dist/cli.js +47 -0
- package/dist/codex-RI2XL4HV.js +5144 -0
- package/dist/codex-plugin-NSKWB3WS.js +179 -0
- package/dist/codex.json +23 -0
- package/dist/index.js +4752 -0
- package/dist/instructions.md +13 -0
- package/dist/omp.js +240 -0
- package/dist/opencode.js +904 -0
- package/dist/promise-OHH5J44X.js +72 -0
- package/dist/stdio-KJVCYPXJ.js +1279 -0
- package/docs/setup.md +82 -0
- package/docs/tools.md +108 -100
- package/package.json +100 -56
- package/src/activity.ts +0 -21
- package/src/broker.ts +0 -1008
- package/src/config.ts +0 -21
- package/src/delivery.ts +0 -54
- package/src/history.ts +0 -123
- package/src/index.ts +0 -39
- package/src/instructions.md +0 -19
- package/src/ipc.ts +0 -477
- package/src/provider.ts +0 -194
- package/src/questions.ts +0 -95
- package/src/resources.ts +0 -189
- package/src/server.ts +0 -615
- package/src/session.ts +0 -603
- package/src/state.ts +0 -179
- package/src/stdio.ts +0 -58
- package/src/tools.ts +0 -91
- package/src/transfer.ts +0 -162
- /package/{src → dist}/question.html +0 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
array,
|
|
4
|
+
callsInput,
|
|
5
|
+
chatInput,
|
|
6
|
+
deliveryContent,
|
|
7
|
+
historyInput,
|
|
8
|
+
inputContent,
|
|
9
|
+
object,
|
|
10
|
+
resourceDescriptors,
|
|
11
|
+
string,
|
|
12
|
+
toolResult,
|
|
13
|
+
transferDescription,
|
|
14
|
+
transferInput
|
|
15
|
+
} from "./chunk-GWYP7B66.js";
|
|
16
|
+
|
|
17
|
+
// src/local.ts
|
|
18
|
+
var definitions = [
|
|
19
|
+
tool(
|
|
20
|
+
"sessions",
|
|
21
|
+
"List connected Chappie sessions and identify this local session.",
|
|
22
|
+
object({
|
|
23
|
+
sessionId: string().optional()
|
|
24
|
+
}),
|
|
25
|
+
async (session, { sessionId }, signal) => textResult(await session.sessions(sessionId, signal))
|
|
26
|
+
),
|
|
27
|
+
tool(
|
|
28
|
+
"remote_tools",
|
|
29
|
+
"Read native tool definitions from a Chappie session. Follow the instructions at globalAgents.path when provided.",
|
|
30
|
+
object({
|
|
31
|
+
sessionId: string().min(1),
|
|
32
|
+
names: array(string()).min(1).optional()
|
|
33
|
+
}),
|
|
34
|
+
async (session, { sessionId, names }, signal) => {
|
|
35
|
+
const { inputs, ...result } = await session.tools(
|
|
36
|
+
sessionId,
|
|
37
|
+
names,
|
|
38
|
+
signal
|
|
39
|
+
);
|
|
40
|
+
return textResult(result, inputs);
|
|
41
|
+
}
|
|
42
|
+
),
|
|
43
|
+
tool(
|
|
44
|
+
"remote_call",
|
|
45
|
+
"Execute one native tool batch in a Chappie session using definitions from remote_tools.",
|
|
46
|
+
object({
|
|
47
|
+
sessionId: string().min(1),
|
|
48
|
+
calls: callsInput
|
|
49
|
+
}),
|
|
50
|
+
async (session, { sessionId, calls }, signal) => remoteResult(session, await session.call(sessionId, calls, signal))
|
|
51
|
+
),
|
|
52
|
+
tool(
|
|
53
|
+
"remote_chat",
|
|
54
|
+
"Send an assistant message to a Chappie session, or reply to its model request using replyTo.",
|
|
55
|
+
chatInput.extend({ sessionId: string().min(1) }),
|
|
56
|
+
async (session, { sessionId, text, replyTo }, signal) => remoteResult(
|
|
57
|
+
session,
|
|
58
|
+
await session.chat(sessionId, text, replyTo, signal)
|
|
59
|
+
)
|
|
60
|
+
),
|
|
61
|
+
tool(
|
|
62
|
+
"history",
|
|
63
|
+
"Read this session's history, or a Chappie session identified by sessionId. Use before/after to page and wait to follow remote progress.",
|
|
64
|
+
historyInput.extend({
|
|
65
|
+
sessionId: string().optional()
|
|
66
|
+
}),
|
|
67
|
+
async (session, { sessionId, ...range }, signal) => {
|
|
68
|
+
const { content, ...page } = await session.history(
|
|
69
|
+
range,
|
|
70
|
+
sessionId,
|
|
71
|
+
signal
|
|
72
|
+
);
|
|
73
|
+
return {
|
|
74
|
+
content: [...textResult(page).content, ...nativeContent(content)]
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
),
|
|
78
|
+
tool(
|
|
79
|
+
"transfer",
|
|
80
|
+
transferDescription,
|
|
81
|
+
transferInput,
|
|
82
|
+
(session, args, signal, update) => session.transfer(
|
|
83
|
+
args,
|
|
84
|
+
signal,
|
|
85
|
+
(details) => update?.({ content: [], details })
|
|
86
|
+
)
|
|
87
|
+
)
|
|
88
|
+
];
|
|
89
|
+
function localTools(session) {
|
|
90
|
+
return definitions.map((tool2) => ({
|
|
91
|
+
...tool2,
|
|
92
|
+
async execute(args, signal, update) {
|
|
93
|
+
const result = await tool2.execute(session, args, signal, update);
|
|
94
|
+
return {
|
|
95
|
+
...result,
|
|
96
|
+
content: [...result.content, ...localDeliveries(session)]
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
function localDeliveries(session) {
|
|
102
|
+
return nativeContent(deliveryContent(session.deliveries()));
|
|
103
|
+
}
|
|
104
|
+
function tool(name, description, parameters, execute) {
|
|
105
|
+
return {
|
|
106
|
+
name,
|
|
107
|
+
description,
|
|
108
|
+
parameters,
|
|
109
|
+
execute: (session, args, signal, update) => execute(session, parameters.parse(args), signal, update)
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function textResult(value, inputs = []) {
|
|
113
|
+
return {
|
|
114
|
+
content: [
|
|
115
|
+
{ type: "text", text: JSON.stringify(value) },
|
|
116
|
+
...inputContent(inputs, "remote_chat")
|
|
117
|
+
]
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function remoteResult(session, result) {
|
|
121
|
+
const output = toolResult(result, "remote_chat");
|
|
122
|
+
const content = nativeContent(output.content);
|
|
123
|
+
if (output.isError)
|
|
124
|
+
throw new Error(
|
|
125
|
+
[...content, ...localDeliveries(session)].flatMap((block) => block.type === "text" ? [block.text] : []).join("\n")
|
|
126
|
+
);
|
|
127
|
+
return {
|
|
128
|
+
content,
|
|
129
|
+
..."toolResults" in result ? {
|
|
130
|
+
details: {
|
|
131
|
+
resources: result.toolResults.flatMap(
|
|
132
|
+
(result2) => resourceDescriptors(result2.details)
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
} : {}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function nativeContent(content) {
|
|
139
|
+
return content.map(
|
|
140
|
+
(block) => block.type === "resource_link" ? { type: "text", text: JSON.stringify({ resource: block }) } : block
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export {
|
|
145
|
+
definitions,
|
|
146
|
+
localTools,
|
|
147
|
+
localDeliveries
|
|
148
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// package.json
|
|
4
|
+
var package_default = {
|
|
5
|
+
name: "@zetaloop/chappie",
|
|
6
|
+
version: "1.0.0",
|
|
7
|
+
description: "Connect ChatGPT and coding agents across devices",
|
|
8
|
+
devDependencies: {
|
|
9
|
+
"@ai-sdk/provider": "^3.0.8",
|
|
10
|
+
"@earendil-works/pi-ai": "^0.87.1",
|
|
11
|
+
"@earendil-works/pi-coding-agent": "^0.87.1",
|
|
12
|
+
"@earendil-works/pi-tui": "^0.87.1",
|
|
13
|
+
"@modelcontextprotocol/server": "^2.0.0",
|
|
14
|
+
"@oh-my-pi/pi-ai": "^18.3.0",
|
|
15
|
+
"@oh-my-pi/pi-coding-agent": "^18.3.0",
|
|
16
|
+
"@oh-my-pi/pi-utils": "^18.3.0",
|
|
17
|
+
"@opencode/client": "^2.0.18",
|
|
18
|
+
"@opencode/plugin": "^2.0.18",
|
|
19
|
+
"@types/cross-spawn": "^6.0.6",
|
|
20
|
+
"@types/node": "^26.5.1",
|
|
21
|
+
"@types/ws": "^8.18.1",
|
|
22
|
+
"cross-spawn": "^7.0.6",
|
|
23
|
+
esbuild: "^0.28.2",
|
|
24
|
+
mime: "^4.1.0",
|
|
25
|
+
typebox: "^1.3.30",
|
|
26
|
+
typescript: "^7.0.2",
|
|
27
|
+
ws: "^8.21.3",
|
|
28
|
+
zod: "^4.6.4"
|
|
29
|
+
},
|
|
30
|
+
scripts: {
|
|
31
|
+
format: "biome check --write .",
|
|
32
|
+
check: "biome check . && tsc --noEmit",
|
|
33
|
+
build: "node scripts/build.ts",
|
|
34
|
+
prepack: "pnpm build"
|
|
35
|
+
},
|
|
36
|
+
keywords: [
|
|
37
|
+
"pi-package",
|
|
38
|
+
"chatgpt",
|
|
39
|
+
"mcp"
|
|
40
|
+
],
|
|
41
|
+
author: "zetaloop",
|
|
42
|
+
license: "MIT",
|
|
43
|
+
packageManager: "pnpm@12.4.1",
|
|
44
|
+
type: "module",
|
|
45
|
+
engines: {
|
|
46
|
+
node: ">=26",
|
|
47
|
+
pnpm: ">=12"
|
|
48
|
+
},
|
|
49
|
+
pi: {
|
|
50
|
+
extensions: [
|
|
51
|
+
"./dist/index.js"
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
peerDependencies: {
|
|
55
|
+
"@earendil-works/pi-ai": "*",
|
|
56
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
57
|
+
"@earendil-works/pi-tui": "*",
|
|
58
|
+
"@oh-my-pi/pi-ai": "*",
|
|
59
|
+
"@oh-my-pi/pi-coding-agent": "*",
|
|
60
|
+
"@oh-my-pi/pi-utils": "*"
|
|
61
|
+
},
|
|
62
|
+
files: [
|
|
63
|
+
"dist",
|
|
64
|
+
"docs",
|
|
65
|
+
".codex-plugin"
|
|
66
|
+
],
|
|
67
|
+
publishConfig: {
|
|
68
|
+
access: "public"
|
|
69
|
+
},
|
|
70
|
+
repository: {
|
|
71
|
+
type: "git",
|
|
72
|
+
url: "git+https://github.com/zetaloop/chappie.git"
|
|
73
|
+
},
|
|
74
|
+
bin: {
|
|
75
|
+
chappie: "./dist/cli.js"
|
|
76
|
+
},
|
|
77
|
+
peerDependenciesMeta: {
|
|
78
|
+
"@earendil-works/pi-ai": {
|
|
79
|
+
optional: true
|
|
80
|
+
},
|
|
81
|
+
"@earendil-works/pi-coding-agent": {
|
|
82
|
+
optional: true
|
|
83
|
+
},
|
|
84
|
+
"@earendil-works/pi-tui": {
|
|
85
|
+
optional: true
|
|
86
|
+
},
|
|
87
|
+
"@oh-my-pi/pi-ai": {
|
|
88
|
+
optional: true
|
|
89
|
+
},
|
|
90
|
+
"@oh-my-pi/pi-coding-agent": {
|
|
91
|
+
optional: true
|
|
92
|
+
},
|
|
93
|
+
"@oh-my-pi/pi-utils": {
|
|
94
|
+
optional: true
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
omp: {
|
|
98
|
+
extensions: [
|
|
99
|
+
"./dist/omp.js"
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
exports: {
|
|
103
|
+
".": "./dist/index.js",
|
|
104
|
+
"./server": "./dist/opencode.js"
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export {
|
|
109
|
+
package_default
|
|
110
|
+
};
|