mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 12:03:49 +00:00
Release v0.18.0
This commit is contained in:
parent
7742f7b653
commit
7785b7c93f
14 changed files with 83 additions and 62 deletions
|
|
@ -22,7 +22,7 @@ export default function (pi: HookAPI) {
|
|||
const content = fs.readFileSync(filePath);
|
||||
const stats = fs.statSync(filePath);
|
||||
|
||||
pi.send(`Use \`say\` to describe the image. Make it concise and hilarious`, [
|
||||
pi.send(`Use \`sag\` (no say!) to describe the image. Make it concise and hilarious`, [
|
||||
{
|
||||
id: crypto.randomUUID(),
|
||||
type: "image",
|
||||
|
|
|
|||
38
package-lock.json
generated
38
package-lock.json
generated
|
|
@ -6520,11 +6520,11 @@
|
|||
},
|
||||
"packages/agent": {
|
||||
"name": "@mariozechner/pi-agent-core",
|
||||
"version": "0.17.0",
|
||||
"version": "0.18.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@mariozechner/pi-ai": "^0.17.0",
|
||||
"@mariozechner/pi-tui": "^0.17.0"
|
||||
"@mariozechner/pi-ai": "^0.18.0",
|
||||
"@mariozechner/pi-tui": "^0.18.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.3.0",
|
||||
|
|
@ -6554,7 +6554,7 @@
|
|||
},
|
||||
"packages/ai": {
|
||||
"name": "@mariozechner/pi-ai",
|
||||
"version": "0.17.0",
|
||||
"version": "0.18.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@anthropic-ai/sdk": "0.71.2",
|
||||
|
|
@ -6595,12 +6595,12 @@
|
|||
},
|
||||
"packages/coding-agent": {
|
||||
"name": "@mariozechner/pi-coding-agent",
|
||||
"version": "0.17.0",
|
||||
"version": "0.18.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@mariozechner/pi-agent-core": "^0.17.0",
|
||||
"@mariozechner/pi-ai": "^0.17.0",
|
||||
"@mariozechner/pi-tui": "^0.17.0",
|
||||
"@mariozechner/pi-agent-core": "^0.18.0",
|
||||
"@mariozechner/pi-ai": "^0.18.0",
|
||||
"@mariozechner/pi-tui": "^0.18.0",
|
||||
"chalk": "^5.5.0",
|
||||
"diff": "^8.0.2",
|
||||
"glob": "^11.0.3",
|
||||
|
|
@ -6638,12 +6638,12 @@
|
|||
},
|
||||
"packages/mom": {
|
||||
"name": "@mariozechner/pi-mom",
|
||||
"version": "0.17.0",
|
||||
"version": "0.18.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@anthropic-ai/sandbox-runtime": "^0.0.16",
|
||||
"@mariozechner/pi-agent-core": "^0.17.0",
|
||||
"@mariozechner/pi-ai": "^0.17.0",
|
||||
"@mariozechner/pi-agent-core": "^0.18.0",
|
||||
"@mariozechner/pi-ai": "^0.18.0",
|
||||
"@sinclair/typebox": "^0.34.0",
|
||||
"@slack/socket-mode": "^2.0.0",
|
||||
"@slack/web-api": "^7.0.0",
|
||||
|
|
@ -6681,10 +6681,10 @@
|
|||
},
|
||||
"packages/pods": {
|
||||
"name": "@mariozechner/pi",
|
||||
"version": "0.17.0",
|
||||
"version": "0.18.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@mariozechner/pi-agent-core": "^0.17.0",
|
||||
"@mariozechner/pi-agent-core": "^0.18.0",
|
||||
"chalk": "^5.5.0"
|
||||
},
|
||||
"bin": {
|
||||
|
|
@ -6697,7 +6697,7 @@
|
|||
},
|
||||
"packages/proxy": {
|
||||
"name": "@mariozechner/pi-proxy",
|
||||
"version": "0.17.0",
|
||||
"version": "0.18.0",
|
||||
"dependencies": {
|
||||
"@hono/node-server": "^1.14.0",
|
||||
"hono": "^4.6.16"
|
||||
|
|
@ -6713,7 +6713,7 @@
|
|||
},
|
||||
"packages/tui": {
|
||||
"name": "@mariozechner/pi-tui",
|
||||
"version": "0.17.0",
|
||||
"version": "0.18.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/mime-types": "^2.1.4",
|
||||
|
|
@ -6757,12 +6757,12 @@
|
|||
},
|
||||
"packages/web-ui": {
|
||||
"name": "@mariozechner/pi-web-ui",
|
||||
"version": "0.17.0",
|
||||
"version": "0.18.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@lmstudio/sdk": "^1.5.0",
|
||||
"@mariozechner/pi-ai": "^0.17.0",
|
||||
"@mariozechner/pi-tui": "^0.17.0",
|
||||
"@mariozechner/pi-ai": "^0.18.0",
|
||||
"@mariozechner/pi-tui": "^0.18.0",
|
||||
"docx-preview": "^0.3.7",
|
||||
"jszip": "^3.10.1",
|
||||
"lucide": "^0.544.0",
|
||||
|
|
@ -6783,7 +6783,7 @@
|
|||
},
|
||||
"packages/web-ui/example": {
|
||||
"name": "pi-web-ui-example",
|
||||
"version": "1.5.0",
|
||||
"version": "1.6.0",
|
||||
"dependencies": {
|
||||
"@mariozechner/mini-lit": "^0.2.0",
|
||||
"@mariozechner/pi-ai": "file:../../ai",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@mariozechner/pi-agent-core",
|
||||
"version": "0.17.0",
|
||||
"version": "0.18.0",
|
||||
"description": "General-purpose agent with transport abstraction, state management, and attachment support",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
|
|
@ -18,8 +18,8 @@
|
|||
"prepublishOnly": "npm run clean && npm run build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mariozechner/pi-ai": "^0.17.0",
|
||||
"@mariozechner/pi-tui": "^0.17.0"
|
||||
"@mariozechner/pi-ai": "^0.18.0",
|
||||
"@mariozechner/pi-tui": "^0.18.0"
|
||||
},
|
||||
"keywords": [
|
||||
"ai",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@mariozechner/pi-ai",
|
||||
"version": "0.17.0",
|
||||
"version": "0.18.0",
|
||||
"description": "Unified LLM API with automatic model discovery and provider configuration",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.18.0] - 2025-12-10
|
||||
|
||||
### Added
|
||||
|
||||
- **Hooks system**: TypeScript modules that extend agent behavior by subscribing to lifecycle events. Hooks can intercept tool calls, prompt for confirmation, modify results, and inject messages from external sources. Auto-discovered from `~/.pi/agent/hooks/*.ts` and `.pi/hooks/*.ts`. Thanks to [@nicobailon](https://github.com/nicobailon) for the collaboration on the design and implementation. ([#145](https://github.com/badlogic/pi-mono/issues/145), supersedes [#158](https://github.com/badlogic/pi-mono/pull/158))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@mariozechner/pi-coding-agent",
|
||||
"version": "0.17.0",
|
||||
"version": "0.18.0",
|
||||
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
||||
"type": "module",
|
||||
"piConfig": {
|
||||
|
|
@ -39,9 +39,9 @@
|
|||
"prepublishOnly": "npm run clean && npm run build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mariozechner/pi-agent-core": "^0.17.0",
|
||||
"@mariozechner/pi-ai": "^0.17.0",
|
||||
"@mariozechner/pi-tui": "^0.17.0",
|
||||
"@mariozechner/pi-agent-core": "^0.18.0",
|
||||
"@mariozechner/pi-ai": "^0.18.0",
|
||||
"@mariozechner/pi-tui": "^0.18.0",
|
||||
"chalk": "^5.5.0",
|
||||
"diff": "^8.0.2",
|
||||
"glob": "^11.0.3",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@mariozechner/pi-mom",
|
||||
"version": "0.17.0",
|
||||
"version": "0.18.0",
|
||||
"description": "Slack bot that delegates messages to the pi coding agent",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
|
|
@ -21,8 +21,8 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@anthropic-ai/sandbox-runtime": "^0.0.16",
|
||||
"@mariozechner/pi-agent-core": "^0.17.0",
|
||||
"@mariozechner/pi-ai": "^0.17.0",
|
||||
"@mariozechner/pi-agent-core": "^0.18.0",
|
||||
"@mariozechner/pi-ai": "^0.18.0",
|
||||
"@sinclair/typebox": "^0.34.0",
|
||||
"@slack/socket-mode": "^2.0.0",
|
||||
"@slack/web-api": "^7.0.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@mariozechner/pi",
|
||||
"version": "0.17.0",
|
||||
"version": "0.18.0",
|
||||
"description": "CLI tool for managing vLLM deployments on GPU pods",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
"node": ">=20.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mariozechner/pi-agent-core": "^0.17.0",
|
||||
"@mariozechner/pi-agent-core": "^0.18.0",
|
||||
"chalk": "^5.5.0"
|
||||
},
|
||||
"devDependencies": {}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@mariozechner/pi-proxy",
|
||||
"version": "0.17.0",
|
||||
"version": "0.18.0",
|
||||
"type": "module",
|
||||
"description": "CORS and authentication proxy for pi-ai",
|
||||
"main": "dist/index.js",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@mariozechner/pi-tui",
|
||||
"version": "0.17.0",
|
||||
"version": "0.18.0",
|
||||
"description": "Terminal User Interface library with differential rendering for efficient text-based applications",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "pi-web-ui-example",
|
||||
"version": "1.5.0",
|
||||
"version": "1.6.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@mariozechner/pi-web-ui",
|
||||
"version": "0.17.0",
|
||||
"version": "0.18.0",
|
||||
"description": "Reusable web UI components for AI chat interfaces powered by @mariozechner/pi-ai",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
|
|
@ -18,8 +18,8 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@lmstudio/sdk": "^1.5.0",
|
||||
"@mariozechner/pi-ai": "^0.17.0",
|
||||
"@mariozechner/pi-tui": "^0.17.0",
|
||||
"@mariozechner/pi-ai": "^0.18.0",
|
||||
"@mariozechner/pi-tui": "^0.18.0",
|
||||
"docx-preview": "^0.3.7",
|
||||
"jszip": "^3.10.1",
|
||||
"lucide": "^0.544.0",
|
||||
|
|
|
|||
40
permissions-hook.ts
Normal file
40
permissions-hook.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import type { HookAPI } from "./packages/coding-agent/src/index.js";
|
||||
|
||||
const dangerousPatterns = [
|
||||
{ pattern: /\brm\s+(-[rf]+\s+)*\//, reason: "Deleting from root" },
|
||||
{ pattern: /\brm\s+-rf?\s/, reason: "Recursive delete" },
|
||||
{ pattern: /\bsudo\b/, reason: "Elevated privileges" },
|
||||
{ pattern: /\bchmod\s+777\b/, reason: "World-writable permissions" },
|
||||
{ pattern: /\b(mkfs|dd\s+if=)/, reason: "Disk operations" },
|
||||
{ pattern: />\s*\/dev\//, reason: "Writing to device" },
|
||||
{ pattern: /\bcurl\b.*\|\s*(ba)?sh/, reason: "Pipe to shell" },
|
||||
{ pattern: /\bwget\b.*\|\s*(ba)?sh/, reason: "Pipe to shell" },
|
||||
];
|
||||
|
||||
const alwaysAllow = [
|
||||
/^(ls|cat|head|tail|grep|find|pwd|echo|date|whoami)\b/,
|
||||
/^git\s+(status|log|diff|branch|show)\b/,
|
||||
/^npm\s+(run|test|install|ci)\b/,
|
||||
];
|
||||
|
||||
export default function (pi: HookAPI) {
|
||||
pi.on("tool_call", async (event, ctx) => {
|
||||
if (event.toolName !== "bash") return;
|
||||
|
||||
const cmd = (event.input.command as string).trim();
|
||||
|
||||
// Always allow safe commands
|
||||
if (alwaysAllow.some((p) => p.test(cmd))) return;
|
||||
|
||||
// Check for dangerous patterns
|
||||
for (const { pattern, reason } of dangerousPatterns) {
|
||||
if (pattern.test(cmd)) {
|
||||
const ok = await ctx.ui.confirm(`⚠️ ${reason}`, cmd);
|
||||
if (!ok) return { block: true, reason: `Blocked: ${reason}` };
|
||||
return; // User approved
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
});
|
||||
}
|
||||
25
test-hook.ts
25
test-hook.ts
|
|
@ -3,29 +3,8 @@ import type { HookAPI } from "./packages/coding-agent/src/index.js";
|
|||
|
||||
export default function (pi: HookAPI) {
|
||||
pi.on("session_start", async (_event, ctx) => {
|
||||
ctx.ui.notify("Test hook loaded!", "info");
|
||||
|
||||
// Set up a file watcher to demonstrate pi.send()
|
||||
const triggerFile = "/tmp/pi-trigger.txt";
|
||||
|
||||
// Create empty trigger file if it doesn't exist
|
||||
if (!fs.existsSync(triggerFile)) {
|
||||
fs.writeFileSync(triggerFile, "");
|
||||
}
|
||||
|
||||
fs.watch(triggerFile, () => {
|
||||
try {
|
||||
const content = fs.readFileSync(triggerFile, "utf-8").trim();
|
||||
if (content) {
|
||||
pi.send(`[External trigger]: ${content}`);
|
||||
fs.writeFileSync(triggerFile, ""); // Clear after reading
|
||||
}
|
||||
} catch {
|
||||
// File might be in flux
|
||||
}
|
||||
});
|
||||
|
||||
ctx.ui.notify("Watching /tmp/pi-trigger.txt for external messages", "info");
|
||||
const result = ctx.ui.input("Session started! Type something to begin...");
|
||||
ctx.ui.notify(`You entered: ${result}`, "info");
|
||||
});
|
||||
|
||||
pi.on("tool_call", async (event, ctx) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue