merge: fix/codesign-adhoc
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { type ChildProcessWithoutNullStreams, spawn } from "node:child_process";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import type { AgentTool, AgentToolResult } from "@mariozechner/pi-ai";
|
||||
import { StringEnum } from "@mariozechner/pi-ai";
|
||||
import { Type } from "@sinclair/typebox";
|
||||
|
||||
import {
|
||||
@@ -31,6 +30,18 @@ const DEFAULT_MAX_OUTPUT = clampNumber(
|
||||
150_000,
|
||||
);
|
||||
|
||||
const stringEnum = (
|
||||
values: readonly string[],
|
||||
options?: Parameters<typeof Type.Union>[1],
|
||||
) =>
|
||||
Type.Union(
|
||||
values.map((value) => Type.Literal(value)) as [
|
||||
ReturnType<typeof Type.Literal>,
|
||||
...ReturnType<typeof Type.Literal>[],
|
||||
],
|
||||
options,
|
||||
);
|
||||
|
||||
export type BashToolDefaults = {
|
||||
backgroundMs?: number;
|
||||
timeoutSec?: number;
|
||||
@@ -60,7 +71,7 @@ const bashSchema = Type.Object({
|
||||
}),
|
||||
),
|
||||
stdinMode: Type.Optional(
|
||||
StringEnum(["pipe", "pty"] as const, {
|
||||
stringEnum(["pipe", "pty"] as const, {
|
||||
description: "Only pipe is supported",
|
||||
}),
|
||||
),
|
||||
@@ -83,7 +94,8 @@ export type BashToolDetails =
|
||||
|
||||
export function createBashTool(
|
||||
defaults?: BashToolDefaults,
|
||||
): AgentTool<typeof bashSchema, BashToolDetails> {
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TypeBox schema type from pi-ai uses a different module instance.
|
||||
): AgentTool<any, BashToolDetails> {
|
||||
const defaultBackgroundMs = clampNumber(
|
||||
defaults?.backgroundMs ?? readEnvInt("PI_BASH_YIELD_MS"),
|
||||
20_000,
|
||||
@@ -329,7 +341,7 @@ export function createBashTool(
|
||||
export const bashTool = createBashTool();
|
||||
|
||||
const processSchema = Type.Object({
|
||||
action: StringEnum(
|
||||
action: stringEnum(
|
||||
["list", "poll", "log", "write", "kill", "clear", "remove"] as const,
|
||||
{
|
||||
description: "Process action",
|
||||
@@ -346,7 +358,8 @@ const processSchema = Type.Object({
|
||||
|
||||
export function createProcessTool(
|
||||
defaults?: ProcessToolDefaults,
|
||||
): AgentTool<typeof processSchema> {
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TypeBox schema type from pi-ai uses a different module instance.
|
||||
): AgentTool<any> {
|
||||
if (defaults?.cleanupMs !== undefined) {
|
||||
setJobTtlMs(defaults.cleanupMs);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import crypto from "node:crypto";
|
||||
import fs from "node:fs/promises";
|
||||
|
||||
import type { AgentTool, AgentToolResult } from "@mariozechner/pi-ai";
|
||||
import { type TSchema, Type } from "@sinclair/typebox";
|
||||
import { Type } from "@sinclair/typebox";
|
||||
import {
|
||||
browserCloseTab,
|
||||
browserFocusTab,
|
||||
@@ -45,7 +45,8 @@ import { callGateway } from "../gateway/call.js";
|
||||
import { detectMime } from "../media/mime.js";
|
||||
import { sanitizeToolResultImages } from "./tool-images.js";
|
||||
|
||||
type AnyAgentTool = AgentTool<TSchema, unknown>;
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TypeBox schema type from pi-ai uses a different module instance.
|
||||
type AnyAgentTool = AgentTool<any, unknown>;
|
||||
|
||||
const DEFAULT_GATEWAY_URL = "ws://127.0.0.1:18789";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { AgentTool, AgentToolResult } from "@mariozechner/pi-ai";
|
||||
import { codingTools, readTool } from "@mariozechner/pi-coding-agent";
|
||||
import { type TSchema, Type } from "@sinclair/typebox";
|
||||
import { Type } from "@sinclair/typebox";
|
||||
|
||||
import { detectMime } from "../media/mime.js";
|
||||
import { startWebLoginWithQr, waitForWebLogin } from "../web/login-qr.js";
|
||||
@@ -103,7 +103,8 @@ async function normalizeReadImageResult(
|
||||
return { ...result, content: nextContent };
|
||||
}
|
||||
|
||||
type AnyAgentTool = AgentTool<TSchema, unknown>;
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TypeBox schema type from pi-ai uses a different module instance.
|
||||
type AnyAgentTool = AgentTool<any, unknown>;
|
||||
|
||||
function extractEnumValues(schema: unknown): unknown[] | undefined {
|
||||
if (!schema || typeof schema !== "object") return undefined;
|
||||
@@ -204,7 +205,7 @@ function normalizeToolParameters(tool: AnyAgentTool): AnyAgentTool {
|
||||
: {}),
|
||||
additionalProperties:
|
||||
"additionalProperties" in schema ? schema.additionalProperties : true,
|
||||
} as unknown as TSchema,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,6 @@ describe("getHealthSnapshot", () => {
|
||||
testConfig = { telegram: { tokenFile } };
|
||||
testStore = {};
|
||||
vi.stubEnv("TELEGRAM_BOT_TOKEN", "");
|
||||
vi.stubEnv("DISCORD_BOT_TOKEN", "");
|
||||
|
||||
const calls: string[] = [];
|
||||
vi.stubGlobal(
|
||||
|
||||
Reference in New Issue
Block a user