pi-kot 0.1.11 → 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/README.md +1 -1
- package/bin/pi-kot.mjs +136 -136
- package/dist/client/assets/{index-BGEuv7Dv.js → index-DC2Sf4UG.js} +79 -79
- package/dist/client/assets/index-DC2Sf4UG.js.map +1 -0
- package/dist/client/assets/index-smCxiS3m.css +1 -0
- package/dist/client/index.html +14 -14
- package/dist/server/extension-manager.d.ts.map +1 -1
- package/dist/server/extension-manager.js +0 -14
- package/dist/server/extension-manager.js.map +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +2 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/routes/config.d.ts.map +1 -1
- package/dist/server/routes/config.js +52 -1
- package/dist/server/routes/config.js.map +1 -1
- package/dist/server/routes/extensions.d.ts.map +1 -1
- package/dist/server/routes/extensions.js +29 -0
- package/dist/server/routes/extensions.js.map +1 -1
- package/dist/server/routes/files.d.ts.map +1 -1
- package/dist/server/routes/files.js +107 -0
- package/dist/server/routes/files.js.map +1 -1
- package/dist/server/routes/images.d.ts +3 -0
- package/dist/server/routes/images.d.ts.map +1 -0
- package/dist/server/routes/images.js +281 -0
- package/dist/server/routes/images.js.map +1 -0
- package/dist/server/routes/session-extensions.d.ts +11 -0
- package/dist/server/routes/session-extensions.d.ts.map +1 -0
- package/dist/server/routes/session-extensions.js +171 -0
- package/dist/server/routes/session-extensions.js.map +1 -0
- package/package.json +1 -1
- package/dist/client/assets/index-BGEuv7Dv.js.map +0 -1
- package/dist/client/assets/index-Bjp_sVpU.css +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Extension Routes — expose runtime extension state from the
|
|
3
|
+
* ExtensionRunner to the web UI.
|
|
4
|
+
*
|
|
5
|
+
* These routes give the GUI visibility into what extensions are active
|
|
6
|
+
* in a session, what commands and tools they registered, so the
|
|
7
|
+
* Extensions page shows "Active in Session" instead of just "Installed".
|
|
8
|
+
*/
|
|
9
|
+
import type { FastifyPluginAsync } from "fastify";
|
|
10
|
+
export declare const sessionExtensionRoutes: FastifyPluginAsync;
|
|
11
|
+
//# sourceMappingURL=session-extensions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-extensions.d.ts","sourceRoot":"","sources":["../../src/routes/session-extensions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGlD,eAAO,MAAM,sBAAsB,EAAE,kBA+IpC,CAAC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Extension Routes — expose runtime extension state from the
|
|
3
|
+
* ExtensionRunner to the web UI.
|
|
4
|
+
*
|
|
5
|
+
* These routes give the GUI visibility into what extensions are active
|
|
6
|
+
* in a session, what commands and tools they registered, so the
|
|
7
|
+
* Extensions page shows "Active in Session" instead of just "Installed".
|
|
8
|
+
*/
|
|
9
|
+
import { getSession } from "../session-registry.js";
|
|
10
|
+
export const sessionExtensionRoutes = async (fastify) => {
|
|
11
|
+
// ── GET /sessions/:id/extensions — runtime extension state ──────────
|
|
12
|
+
fastify.get("/sessions/:id/extensions", {
|
|
13
|
+
schema: {
|
|
14
|
+
description: "List extensions currently active in a live session, " +
|
|
15
|
+
"including their registered commands, tools, and event handlers.",
|
|
16
|
+
tags: ["extensions"],
|
|
17
|
+
params: {
|
|
18
|
+
type: "object",
|
|
19
|
+
required: ["id"],
|
|
20
|
+
properties: { id: { type: "string" } },
|
|
21
|
+
},
|
|
22
|
+
response: {
|
|
23
|
+
200: {
|
|
24
|
+
type: "object",
|
|
25
|
+
required: ["activeExtensions", "commands", "registeredTools"],
|
|
26
|
+
properties: {
|
|
27
|
+
activeExtensions: {
|
|
28
|
+
type: "array",
|
|
29
|
+
items: {
|
|
30
|
+
type: "object",
|
|
31
|
+
properties: {
|
|
32
|
+
path: { type: "string" },
|
|
33
|
+
displayPath: { type: "string" },
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
commands: {
|
|
38
|
+
type: "array",
|
|
39
|
+
items: {
|
|
40
|
+
type: "object",
|
|
41
|
+
properties: {
|
|
42
|
+
name: { type: "string" },
|
|
43
|
+
invocationName: { type: "string" },
|
|
44
|
+
description: { type: "string" },
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
registeredTools: {
|
|
49
|
+
type: "array",
|
|
50
|
+
items: {
|
|
51
|
+
type: "object",
|
|
52
|
+
properties: {
|
|
53
|
+
name: { type: "string" },
|
|
54
|
+
description: { type: "string" },
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
eventHandlers: {
|
|
59
|
+
type: "array",
|
|
60
|
+
items: { type: "string" },
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
404: {
|
|
65
|
+
type: "object",
|
|
66
|
+
properties: { error: { type: "string" } },
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
}, async (req, reply) => {
|
|
71
|
+
const sessionId = req.params.id;
|
|
72
|
+
const live = getSession(sessionId);
|
|
73
|
+
if (live === undefined) {
|
|
74
|
+
return reply.code(404).send({ error: "session_not_found" });
|
|
75
|
+
}
|
|
76
|
+
const runner = live.session.extensionRunner;
|
|
77
|
+
// Active extension paths
|
|
78
|
+
const activeExtensions = runner.getExtensionPaths().map((p) => ({
|
|
79
|
+
path: p,
|
|
80
|
+
// Derive a user-friendly display name from the path
|
|
81
|
+
displayPath: friendlyExtensionName(p),
|
|
82
|
+
}));
|
|
83
|
+
// Registered commands
|
|
84
|
+
const commands = runner.getRegisteredCommands().map((cmd) => ({
|
|
85
|
+
name: cmd.name,
|
|
86
|
+
invocationName: cmd.invocationName,
|
|
87
|
+
description: cmd.description ?? "",
|
|
88
|
+
}));
|
|
89
|
+
// Registered tools
|
|
90
|
+
const registeredTools = runner.getAllRegisteredTools().map((t) => ({
|
|
91
|
+
name: t.definition.name,
|
|
92
|
+
description: typeof t.definition.description === "string"
|
|
93
|
+
? t.definition.description
|
|
94
|
+
: "",
|
|
95
|
+
}));
|
|
96
|
+
// Event handlers — enumerate all event types this runner handles
|
|
97
|
+
const allEventTypes = [
|
|
98
|
+
"project_trust",
|
|
99
|
+
"resources_discover",
|
|
100
|
+
"session_start",
|
|
101
|
+
"session_before_switch",
|
|
102
|
+
"session_before_fork",
|
|
103
|
+
"session_before_compact",
|
|
104
|
+
"session_compact",
|
|
105
|
+
"session_shutdown",
|
|
106
|
+
"session_before_tree",
|
|
107
|
+
"session_tree",
|
|
108
|
+
"context",
|
|
109
|
+
"before_provider_request",
|
|
110
|
+
"after_provider_response",
|
|
111
|
+
"before_agent_start",
|
|
112
|
+
"agent_start",
|
|
113
|
+
"agent_end",
|
|
114
|
+
"turn_start",
|
|
115
|
+
"turn_end",
|
|
116
|
+
"message_start",
|
|
117
|
+
"message_update",
|
|
118
|
+
"message_end",
|
|
119
|
+
"tool_execution_start",
|
|
120
|
+
"tool_execution_update",
|
|
121
|
+
"tool_execution_end",
|
|
122
|
+
"model_select",
|
|
123
|
+
"thinking_level_select",
|
|
124
|
+
"tool_call",
|
|
125
|
+
"tool_result",
|
|
126
|
+
"user_bash",
|
|
127
|
+
"input",
|
|
128
|
+
];
|
|
129
|
+
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: simple filter
|
|
130
|
+
const eventHandlers = allEventTypes.filter((et) => runner.hasHandlers(et));
|
|
131
|
+
return reply.send({
|
|
132
|
+
activeExtensions,
|
|
133
|
+
commands,
|
|
134
|
+
registeredTools,
|
|
135
|
+
eventHandlers,
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Derive a user-friendly display name from an extension path.
|
|
141
|
+
* e.g. "/home/user/.pi/agent/npm/node_modules/@ayulab/pi-rewind/dist/index.js"
|
|
142
|
+
* → "@ayulab/pi-rewind"
|
|
143
|
+
*/
|
|
144
|
+
function friendlyExtensionPath(absolutePath) {
|
|
145
|
+
// Try to extract npm package name from node_modules path
|
|
146
|
+
const nmIndex = absolutePath.lastIndexOf("node_modules/");
|
|
147
|
+
if (nmIndex !== -1) {
|
|
148
|
+
const afterNm = absolutePath.slice(nmIndex + "node_modules/".length);
|
|
149
|
+
// The package name is the first path segment (which may contain @scope/)
|
|
150
|
+
const parts = afterNm.split("/");
|
|
151
|
+
if (parts[0]?.startsWith("@")) {
|
|
152
|
+
// Scoped package: @scope/name
|
|
153
|
+
return `${parts[0]}/${parts[1] ?? ""}`;
|
|
154
|
+
}
|
|
155
|
+
return parts[0] ?? absolutePath;
|
|
156
|
+
}
|
|
157
|
+
// Fallback: return the last two path segments
|
|
158
|
+
const segments = absolutePath.split("/");
|
|
159
|
+
return segments.slice(-2).join("/");
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Derive a user-friendly display name from an extension path.
|
|
163
|
+
* Includes a fallback if the path is inline or temporary.
|
|
164
|
+
*/
|
|
165
|
+
function friendlyExtensionName(absolutePath) {
|
|
166
|
+
if (absolutePath.startsWith("<inline:")) {
|
|
167
|
+
return `inline-extension${absolutePath.replace("<inline:", "").replace(">", "")}`;
|
|
168
|
+
}
|
|
169
|
+
return friendlyExtensionPath(absolutePath);
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=session-extensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-extensions.js","sourceRoot":"","sources":["../../src/routes/session-extensions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,MAAM,CAAC,MAAM,sBAAsB,GAAuB,KAAK,EAAE,OAAO,EAAE,EAAE;IAC1E,uEAAuE;IAEvE,OAAO,CAAC,GAAG,CAGT,0BAA0B,EA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