feat: publish standalone Pi connect extension
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
dist/
|
||||
node_modules/
|
||||
@@ -1,9 +1,9 @@
|
||||
# Connect Local Pi Extension
|
||||
|
||||
Install with official Pi:
|
||||
Install with Pi:
|
||||
|
||||
```bash
|
||||
pi install git:git@github.com:your-org/agentic-chat-core.git#packages/connect-local
|
||||
pi install https://github-cli.corp.ebay.com/adsguidance/agentic-chat-connect.git
|
||||
```
|
||||
|
||||
Prerequisite: [Pi coding agent](https://www.npmjs.com/package/@earendil-works/pi-coding-agent) installed globally or in your environment.
|
||||
|
||||
3301
package-lock.json
generated
Normal file
3301
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
17
package.json
17
package.json
@@ -1,13 +1,12 @@
|
||||
{
|
||||
"name": "@pi-platform/connect-local",
|
||||
"version": "0.1.18",
|
||||
"name": "agentic-chat-connect",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"keywords": ["pi-package"],
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"types": "./src/index.ts",
|
||||
"pi": {
|
||||
"extensions": ["./dist/index.js"]
|
||||
"extensions": ["./src/index.ts"]
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
@@ -15,12 +14,14 @@
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@earendil-works/pi-coding-agent": "^0.80.10",
|
||||
"@pi-platform/shared": "*",
|
||||
"ws": "^8.21.1"
|
||||
"ws": "^8.21.1",
|
||||
"zod": "^3.25.0 || ^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@earendil-works/pi-coding-agent": "^0.80.10",
|
||||
"@types/node": "^22.0.0",
|
||||
"@types/ws": "^8.18.1",
|
||||
"typescript": "^5.4.0",
|
||||
"vitest": "^4.1.10"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import type { ExtensionAPI, ExtensionCommandContext, ExtensionContext } from '@earendil-works/pi-coding-agent';
|
||||
import type { LocalAgentServerMessage } from '@pi-platform/shared';
|
||||
import type { LocalAgentServerMessage } from './localAgentProtocol.js';
|
||||
import {
|
||||
clearReconnectCredential,
|
||||
loadReconnectCredential,
|
||||
|
||||
37
src/localAgentProtocol.ts
Normal file
37
src/localAgentProtocol.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const DEFAULT_HEARTBEAT_INTERVAL_MS = 15_000;
|
||||
|
||||
const pairOkServerMessageSchema = z.object({
|
||||
type: z.literal('pair.ok'),
|
||||
projectName: z.string().min(1),
|
||||
reconnectCredential: z.string().min(1),
|
||||
connectionEpoch: z.number().int().positive(),
|
||||
});
|
||||
|
||||
const reconnectOkServerMessageSchema = z.object({
|
||||
type: z.literal('reconnect.ok'),
|
||||
projectName: z.string().min(1),
|
||||
connectionEpoch: z.number().int().positive(),
|
||||
});
|
||||
|
||||
const taskDispatchServerMessageSchema = z.object({
|
||||
type: z.literal('task.dispatch'),
|
||||
taskId: z.string().min(1),
|
||||
prompt: z.string().min(1),
|
||||
});
|
||||
|
||||
const errorServerMessageSchema = z.object({
|
||||
type: z.literal('error'),
|
||||
code: z.string().min(1),
|
||||
message: z.string().min(1),
|
||||
});
|
||||
|
||||
export const localAgentServerMessageSchema = z.discriminatedUnion('type', [
|
||||
pairOkServerMessageSchema,
|
||||
reconnectOkServerMessageSchema,
|
||||
taskDispatchServerMessageSchema,
|
||||
errorServerMessageSchema,
|
||||
]);
|
||||
|
||||
export type LocalAgentServerMessage = z.infer<typeof localAgentServerMessageSchema>;
|
||||
@@ -1,6 +1,6 @@
|
||||
import { EventEmitter } from 'node:events';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { DEFAULT_HEARTBEAT_INTERVAL_MS } from '@pi-platform/shared';
|
||||
import { DEFAULT_HEARTBEAT_INTERVAL_MS } from './localAgentProtocol.js';
|
||||
import { LocalAgentWsClient } from './wsClient.js';
|
||||
|
||||
let latestSocket: { send: ReturnType<typeof vi.fn>; close: () => void } | undefined;
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
DEFAULT_HEARTBEAT_INTERVAL_MS,
|
||||
localAgentServerMessageSchema,
|
||||
type LocalAgentServerMessage,
|
||||
} from '@pi-platform/shared';
|
||||
} from './localAgentProtocol.js';
|
||||
import { WebSocket } from 'ws';
|
||||
|
||||
export interface LocalAgentWsClientOptions {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["src/**/*.test.ts"],
|
||||
"references": [{ "path": "../shared" }]
|
||||
"exclude": ["src/**/*.test.ts"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user