@skydiveai/pi-extensions 0.1.252-beta.1 → 0.1.252-beta.2
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/dist/index.d.mts +19 -1
- package/dist/index.mjs +19 -19
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { A2AOptions, Middleware, ProtocolsOptions } from "@skydiveai/pi-server";
|
|
2
3
|
import { ExtensionFactory } from "@earendil-works/pi-coding-agent";
|
|
3
4
|
import { Type } from "typebox";
|
|
4
5
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
6
|
+
import * as _$qs from "qs";
|
|
7
|
+
import * as _$express from "express";
|
|
5
8
|
import { Logger } from "pino";
|
|
6
9
|
|
|
10
|
+
//#region ../../node_modules/@types/express-serve-static-core/index.d.ts
|
|
11
|
+
declare global {
|
|
12
|
+
namespace Express {
|
|
13
|
+
// These open interfaces may be extended in an application-specific manner via declaration merging.
|
|
14
|
+
// See for example method-override.d.ts (https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/method-override/index.d.ts)
|
|
15
|
+
interface Request {}
|
|
16
|
+
interface Response {}
|
|
17
|
+
interface Locals {}
|
|
18
|
+
interface Application {}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
interface ParamsDictionary {
|
|
22
|
+
[key: string]: string;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
7
25
|
//#region src/harness.d.ts
|
|
8
26
|
type CreateHarnessOptions = ProtocolsOptions & {
|
|
9
27
|
cwd: string;
|
|
@@ -26,7 +44,7 @@ declare function createHarness(options: CreateHarnessOptions): {
|
|
|
26
44
|
};
|
|
27
45
|
protocols: {
|
|
28
46
|
handlers: {
|
|
29
|
-
/** Express-style; mount at /a2a. */a2a: RequestHandler
|
|
47
|
+
/** Express-style; mount at /a2a. */a2a: _$express.RequestHandler<ParamsDictionary, any, any, _$qs.ParsedQs, Record<string, any>>; /** GET /.well-known/agent-card.json. */
|
|
30
48
|
agentCard: Middleware; /** Mirrors each vendor's API shape. */
|
|
31
49
|
openai: {
|
|
32
50
|
v1: {
|
package/dist/index.mjs
CHANGED
|
@@ -161,7 +161,7 @@ async function readPackageVersion(pkg) {
|
|
|
161
161
|
let dir;
|
|
162
162
|
try {
|
|
163
163
|
dir = dirname(require.resolve(pkg));
|
|
164
|
-
} catch {
|
|
164
|
+
} catch (_error) {
|
|
165
165
|
return null;
|
|
166
166
|
}
|
|
167
167
|
let current = dir;
|
|
@@ -169,7 +169,7 @@ async function readPackageVersion(pkg) {
|
|
|
169
169
|
try {
|
|
170
170
|
const manifest = JSON.parse(await readFile(resolve(current, "package.json"), "utf8"));
|
|
171
171
|
if (manifest.name === pkg && typeof manifest.version === "string") return manifest.version;
|
|
172
|
-
} catch {}
|
|
172
|
+
} catch (_error) {}
|
|
173
173
|
const parent = dirname(current);
|
|
174
174
|
if (parent === current) return null;
|
|
175
175
|
current = parent;
|
|
@@ -210,7 +210,7 @@ function createPlatformEnvMiddleware() {
|
|
|
210
210
|
return async (req, _res, next) => {
|
|
211
211
|
try {
|
|
212
212
|
await loadPlatformConfig(new Request(requestUrl(req), { headers: requestHeaders(req) }));
|
|
213
|
-
} catch {}
|
|
213
|
+
} catch (_error) {}
|
|
214
214
|
next();
|
|
215
215
|
};
|
|
216
216
|
}
|
|
@@ -662,7 +662,7 @@ async function listToolFiles(dir) {
|
|
|
662
662
|
file,
|
|
663
663
|
mtimeMs: s.mtimeMs
|
|
664
664
|
});
|
|
665
|
-
} catch {}
|
|
665
|
+
} catch (_error) {}
|
|
666
666
|
}
|
|
667
667
|
return out;
|
|
668
668
|
}
|
|
@@ -946,7 +946,7 @@ function probeAlive(pid) {
|
|
|
946
946
|
try {
|
|
947
947
|
process.kill(pid, 0);
|
|
948
948
|
return true;
|
|
949
|
-
} catch {
|
|
949
|
+
} catch (_error) {
|
|
950
950
|
return false;
|
|
951
951
|
}
|
|
952
952
|
}
|
|
@@ -1041,7 +1041,7 @@ async function connectClient(id, config, opts = {}) {
|
|
|
1041
1041
|
}
|
|
1042
1042
|
try {
|
|
1043
1043
|
await client.close();
|
|
1044
|
-
} catch {}
|
|
1044
|
+
} catch (_error) {}
|
|
1045
1045
|
return {
|
|
1046
1046
|
status: "failed",
|
|
1047
1047
|
error: formatError(result),
|
|
@@ -1163,7 +1163,7 @@ function estimateToolTokens(tool) {
|
|
|
1163
1163
|
let chars = tool.name.length + (tool.description?.length ?? 0);
|
|
1164
1164
|
if (tool.inputSchema !== void 0 && tool.inputSchema !== null) try {
|
|
1165
1165
|
chars += JSON.stringify(tool.inputSchema).length;
|
|
1166
|
-
} catch {
|
|
1166
|
+
} catch (_error) {
|
|
1167
1167
|
chars += 256;
|
|
1168
1168
|
}
|
|
1169
1169
|
return Math.ceil(chars / 4);
|
|
@@ -2163,7 +2163,7 @@ function extractMessageId(channelContextJson) {
|
|
|
2163
2163
|
try {
|
|
2164
2164
|
const parsed = channelContextRefSchema.safeParse(JSON.parse(channelContextJson));
|
|
2165
2165
|
return parsed.success ? parsed.data.messageId : null;
|
|
2166
|
-
} catch {
|
|
2166
|
+
} catch (_error) {
|
|
2167
2167
|
return null;
|
|
2168
2168
|
}
|
|
2169
2169
|
}
|
|
@@ -2410,7 +2410,7 @@ async function postSubagentSpawn({ messageId, tasks }) {
|
|
|
2410
2410
|
try {
|
|
2411
2411
|
const errBody = await res.json();
|
|
2412
2412
|
if (errBody && typeof errBody.error === "string") detail = `: ${errBody.error}`;
|
|
2413
|
-
} catch {}
|
|
2413
|
+
} catch (_error) {}
|
|
2414
2414
|
throw new Error(`subagent-spawn POST failed (${res.status})${detail}`);
|
|
2415
2415
|
}
|
|
2416
2416
|
const body = await res.json();
|
|
@@ -2434,7 +2434,7 @@ async function postSubagentRearm({ messageId, taskId, timeoutMinutes }) {
|
|
|
2434
2434
|
try {
|
|
2435
2435
|
const body = await res.json();
|
|
2436
2436
|
if (typeof body.error === "string") detail = `: ${body.error}`;
|
|
2437
|
-
} catch {}
|
|
2437
|
+
} catch (_error) {}
|
|
2438
2438
|
throw new Error(`subagent re-arm POST failed (${res.status})${detail}`);
|
|
2439
2439
|
}
|
|
2440
2440
|
const body = await res.json();
|
|
@@ -3708,7 +3708,7 @@ async function readMemoryIndexFile({ cwd }) {
|
|
|
3708
3708
|
try {
|
|
3709
3709
|
const trimmed = (await readFile(path, "utf-8")).trim();
|
|
3710
3710
|
return trimmed.length > 0 ? trimmed : null;
|
|
3711
|
-
} catch {
|
|
3711
|
+
} catch (_error) {
|
|
3712
3712
|
return null;
|
|
3713
3713
|
}
|
|
3714
3714
|
}
|
|
@@ -3748,7 +3748,7 @@ async function maxMtimeAcrossDir(dir) {
|
|
|
3748
3748
|
let dirStat;
|
|
3749
3749
|
try {
|
|
3750
3750
|
dirStat = await stat(dir);
|
|
3751
|
-
} catch {
|
|
3751
|
+
} catch (_error) {
|
|
3752
3752
|
return null;
|
|
3753
3753
|
}
|
|
3754
3754
|
if (!dirStat.isDirectory()) return null;
|
|
@@ -3763,7 +3763,7 @@ async function walkMdFiles(dir, out) {
|
|
|
3763
3763
|
let entries;
|
|
3764
3764
|
try {
|
|
3765
3765
|
entries = await readdir(dir, { withFileTypes: true });
|
|
3766
|
-
} catch {
|
|
3766
|
+
} catch (_error) {
|
|
3767
3767
|
return;
|
|
3768
3768
|
}
|
|
3769
3769
|
await Promise.all(entries.map(async (entry) => {
|
|
@@ -3776,7 +3776,7 @@ async function listMdFilesShallow(dir) {
|
|
|
3776
3776
|
let entries;
|
|
3777
3777
|
try {
|
|
3778
3778
|
entries = await readdir(dir, { withFileTypes: true });
|
|
3779
|
-
} catch {
|
|
3779
|
+
} catch (_error) {
|
|
3780
3780
|
return [];
|
|
3781
3781
|
}
|
|
3782
3782
|
return entries.filter((e) => e.isFile() && e.name.endsWith(".md")).map((e) => join(dir, e.name));
|
|
@@ -3785,7 +3785,7 @@ async function listSubdirs(dir) {
|
|
|
3785
3785
|
let entries;
|
|
3786
3786
|
try {
|
|
3787
3787
|
entries = await readdir(dir, { withFileTypes: true });
|
|
3788
|
-
} catch {
|
|
3788
|
+
} catch (_error) {
|
|
3789
3789
|
return [];
|
|
3790
3790
|
}
|
|
3791
3791
|
return entries.filter((e) => e.isDirectory()).map((e) => join(dir, e.name));
|
|
@@ -3811,14 +3811,14 @@ async function readFrontmatterOnly(filePath) {
|
|
|
3811
3811
|
let fh;
|
|
3812
3812
|
try {
|
|
3813
3813
|
fh = await open(filePath, "r");
|
|
3814
|
-
} catch {
|
|
3814
|
+
} catch (_error) {
|
|
3815
3815
|
return null;
|
|
3816
3816
|
}
|
|
3817
3817
|
try {
|
|
3818
3818
|
const buf = Buffer.alloc(FRONTMATTER_READ_BYTES);
|
|
3819
3819
|
const { bytesRead } = await fh.read(buf, 0, FRONTMATTER_READ_BYTES, 0);
|
|
3820
3820
|
return parseFrontmatter(buf.toString("utf-8", 0, bytesRead));
|
|
3821
|
-
} catch {
|
|
3821
|
+
} catch (_error) {
|
|
3822
3822
|
return null;
|
|
3823
3823
|
} finally {
|
|
3824
3824
|
await fh.close().catch(() => {});
|
|
@@ -3830,7 +3830,7 @@ function parseFrontmatter(text) {
|
|
|
3830
3830
|
let parsed;
|
|
3831
3831
|
try {
|
|
3832
3832
|
parsed = parse(match[1]);
|
|
3833
|
-
} catch {
|
|
3833
|
+
} catch (_error) {
|
|
3834
3834
|
return null;
|
|
3835
3835
|
}
|
|
3836
3836
|
const result = FrontmatterSchema.safeParse(parsed);
|
|
@@ -4826,7 +4826,7 @@ async function readLogChunk(id, maxBytes, anchor) {
|
|
|
4826
4826
|
text: buffer.toString("utf8", start),
|
|
4827
4827
|
size
|
|
4828
4828
|
};
|
|
4829
|
-
} catch {
|
|
4829
|
+
} catch (_error) {
|
|
4830
4830
|
return {
|
|
4831
4831
|
text: "",
|
|
4832
4832
|
size: 0
|