@dyyz1993/create-agent 2.1.2 → 2.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dyyz1993/create-agent",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "Create Agent project scaffolding CLI",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "pi-agent-app",
3
- "version": "1.0.2",
3
+ "private": true,
4
+ "version": "1.0.0",
4
5
  "description": "Coding agent template with Bash, Rules, and Todo management",
5
6
  "author": {
6
7
  "name": "xuyingzhou",
@@ -1,13 +1,22 @@
1
- import { createTypedClient, WebSocketTransport, IPCTransport } from "@dyyz1993/rpc-core";
1
+ import { createTypedClient, WebSocketTransport, IPCTransport } from '@dyyz1993/rpc-core';
2
2
  import type {
3
3
  TypedClient,
4
4
  MethodParams,
5
5
  MethodResult,
6
6
  EventPayload,
7
7
  EventMetadata,
8
- } from "@dyyz1993/rpc-core";
9
- import type { RPCMethods, RPCEvents } from "../../shared/rpc-schema";
10
- import { rpcCache, CACHEABLE_METHODS } from "./rpc-cache";
8
+ } from '@dyyz1993/rpc-core';
9
+ import type { RPCMethods, RPCEvents } from '../../shared/rpc-schema';
10
+
11
+ /** Keep the subscribe filter as strict as the typed client's (metadata keys). */
12
+ type SubscribeFilter<K extends keyof RPCEvents = keyof RPCEvents> = RPCEvents[K] extends {
13
+ metadata: infer M;
14
+ }
15
+ ? Partial<M>
16
+ : RPCEvents[K] extends { metadata?: infer M }
17
+ ? Partial<NonNullable<M>>
18
+ : Record<string, unknown>;
19
+ import { rpcCache, CACHEABLE_METHODS } from './rpc-cache';
11
20
 
12
21
  /**
13
22
  * Token 来源优先级:
@@ -16,13 +25,13 @@ import { rpcCache, CACHEABLE_METHODS } from "./rpc-cache";
16
25
  * 3. 默认值(开发用)
17
26
  */
18
27
  function resolveAuthToken(): string {
19
- if (typeof window !== "undefined") {
20
- const fromQuery = new URLSearchParams(window.location.search).get("token");
28
+ if (typeof window !== 'undefined') {
29
+ const fromQuery = new URLSearchParams(window.location.search).get('token');
21
30
  if (fromQuery) return fromQuery;
22
- const fromStorage = localStorage.getItem("rpc-auth-token");
31
+ const fromStorage = localStorage.getItem('rpc-auth-token');
23
32
  if (fromStorage) return fromStorage;
24
33
  }
25
- return "pi-agent-template-token";
34
+ return 'pi-agent-template-token';
26
35
  }
27
36
 
28
37
  const AUTH_TOKEN = resolveAuthToken();
@@ -30,7 +39,7 @@ const AUTH_TOKEN = resolveAuthToken();
30
39
  class APIClientImpl {
31
40
  private client: TypedClient<RPCMethods, RPCEvents> | null = null;
32
41
  private initPromise: Promise<void> | null = null;
33
- private _transport: "ipc" | "websocket" = "websocket";
42
+ private _transport: 'ipc' | 'websocket' = 'websocket';
34
43
  private _baseUrl: string | null = null;
35
44
  private wsTransport: WebSocketTransport | null = null;
36
45
 
@@ -41,7 +50,7 @@ class APIClientImpl {
41
50
  if (this.client) return;
42
51
 
43
52
  const ipcTransport = new IPCTransport();
44
- this._transport = "ipc";
53
+ this._transport = 'ipc';
45
54
  this._baseUrl = null;
46
55
  this.client = createTypedClient<RPCMethods, RPCEvents>(ipcTransport);
47
56
  this.setupElectrobunBridge(ipcTransport);
@@ -52,7 +61,7 @@ class APIClientImpl {
52
61
  */
53
62
  async initialize(): Promise<void> {
54
63
  // 已连接且 transport 正常 → 直接返回
55
- if (this.client && (this._transport === "ipc" || this.wsTransport?.isConnected())) {
64
+ if (this.client && (this._transport === 'ipc' || this.wsTransport?.isConnected())) {
56
65
  return;
57
66
  }
58
67
 
@@ -69,11 +78,11 @@ class APIClientImpl {
69
78
  this.initPromise = (async () => {
70
79
  const env = this.detectEnvironment();
71
80
 
72
- if (env === "electrobun") {
81
+ if (env === 'electrobun') {
73
82
  // 不应走到这里,桌面端应通过 initSyncForDesktop() 初始化
74
83
  this.initSyncForDesktop();
75
84
  } else {
76
- this._transport = "websocket";
85
+ this._transport = 'websocket';
77
86
  const wsUrl = this.getWebSocketUrl();
78
87
  this.wsTransport = new WebSocketTransport({
79
88
  url: wsUrl,
@@ -91,19 +100,19 @@ class APIClientImpl {
91
100
  return this.initPromise;
92
101
  }
93
102
 
94
- private detectEnvironment(): "electrobun" | "browser" {
95
- if (typeof window === "undefined") return "browser";
96
- if (window.__electrobunBunBridge) return "electrobun";
97
- return "browser";
103
+ private detectEnvironment(): 'electrobun' | 'browser' {
104
+ if (typeof window === 'undefined') return 'browser';
105
+ if (window.__electrobunBunBridge) return 'electrobun';
106
+ return 'browser';
98
107
  }
99
108
 
100
109
  private getWebSocketUrl(): string {
101
- if (typeof window === "undefined") return `ws://localhost:3100?token=${AUTH_TOKEN}`;
110
+ if (typeof window === 'undefined') return `ws://localhost:3100?token=${AUTH_TOKEN}`;
102
111
  const customUrl =
103
- new URLSearchParams(window.location.search).get("ws") ||
104
- localStorage.getItem("rpc-websocket-url");
112
+ new URLSearchParams(window.location.search).get('ws') ||
113
+ localStorage.getItem('rpc-websocket-url');
105
114
  if (customUrl)
106
- return customUrl.includes("token=") ? customUrl : `${customUrl}?token=${AUTH_TOKEN}`;
115
+ return customUrl.includes('token=') ? customUrl : `${customUrl}?token=${AUTH_TOKEN}`;
107
116
  return `ws://${window.location.host}/ws?token=${AUTH_TOKEN}`;
108
117
  }
109
118
 
@@ -113,7 +122,7 @@ class APIClientImpl {
113
122
  * - Browser → Bun: 通过 __electrobunBunBridge.postMessage 发送 Electrobun 消息格式
114
123
  */
115
124
  private setupElectrobunBridge(ipcTransport: IPCTransport): void {
116
- if (typeof window === "undefined") return;
125
+ if (typeof window === 'undefined') return;
117
126
 
118
127
  const win = window;
119
128
 
@@ -129,8 +138,8 @@ class APIClientImpl {
129
138
  ipcTransport.send = async (message: unknown) => {
130
139
  // 包装成 Electrobun message packet,bun 端 defineRPC 注册了 "rpc-message" handler
131
140
  const electrobunPacket = {
132
- type: "message",
133
- id: "rpc-message",
141
+ type: 'message',
142
+ id: 'rpc-message',
134
143
  payload: JSON.stringify(message),
135
144
  };
136
145
  bridge.postMessage(JSON.stringify(electrobunPacket));
@@ -138,7 +147,7 @@ class APIClientImpl {
138
147
  }
139
148
  }
140
149
 
141
- getTransport(): "ipc" | "websocket" {
150
+ getTransport(): 'ipc' | 'websocket' {
142
151
  return this._transport;
143
152
  }
144
153
 
@@ -154,7 +163,7 @@ class APIClientImpl {
154
163
 
155
164
  async call<K extends keyof RPCMethods>(
156
165
  method: K,
157
- params: MethodParams<RPCMethods, K>
166
+ params: MethodParams<RPCMethods, K>,
158
167
  ): Promise<MethodResult<RPCMethods, K>> {
159
168
  const methodStr = method as string;
160
169
  const ttl = CACHEABLE_METHODS[methodStr];
@@ -176,7 +185,7 @@ class APIClientImpl {
176
185
  async subscribe<K extends keyof RPCEvents>(
177
186
  eventType: K,
178
187
  handler: (payload: EventPayload<RPCEvents[K]>, metadata: EventMetadata<RPCEvents[K]>) => void,
179
- filter?: Record<string, unknown>
188
+ filter?: SubscribeFilter<K>,
180
189
  ): Promise<string> {
181
190
  await this.initialize();
182
191
  return this.client!.subscribe(eventType, handler, filter);
@@ -1,7 +1,7 @@
1
1
  import { create } from 'zustand';
2
2
  import { apiClient } from '../lib/api-client';
3
3
  import type { RPCMethods } from '../lib/api-client';
4
- import type { MethodResult } from '@dyyzz1993/rpc-core';
4
+ import type { MethodResult } from '@dyyz1993/rpc-core';
5
5
  import type { DemoMethod } from '../types';
6
6
  import { useLogStore } from './use-log-store';
7
7
 
@@ -14,9 +14,7 @@ export function register(server: RPCServer, _options: HandlerOptions): void {
14
14
 
15
15
  r('debug.subscriptions', async () => {
16
16
  return {
17
- subscriptions: (
18
- server as unknown as { getActiveSubscriptions(): unknown }
19
- ).getActiveSubscriptions(),
17
+ subscriptions: server.getActiveSubscriptions(),
20
18
  };
21
19
  });
22
20
  }
@@ -5,7 +5,7 @@
5
5
  "noUnusedParameters": false,
6
6
  "skipLibCheck": true,
7
7
  "noUncheckedIndexedAccess": true,
8
- "noImplicitReturns": true,
8
+ "noImplicitReturns": false,
9
9
  "noFallthroughCasesInSwitch": true,
10
10
  "strict": true
11
11
  },
@@ -18,7 +18,7 @@
18
18
  "baseUrl": ".",
19
19
  "paths": {
20
20
  "@dyyz1993/rpc-core": ["../../packages/rpc-core/src/index.ts"],
21
- "@shared/*": ["../shared/*"]
21
+ "@shared/*": ["./src/shared/*", "../shared/*"]
22
22
  },
23
23
  "noUncheckedIndexedAccess": true,
24
24
  "noImplicitReturns": true
@@ -26,6 +26,9 @@
26
26
  "include": ["src", "../shared"],
27
27
  "exclude": [
28
28
  "node_modules",
29
+ "../shared/__tests__",
30
+ "../shared/vite-base.config.ts",
31
+ "../shared/vitest-base.config.ts",
29
32
  "dist",
30
33
  "build",
31
34
  "../../package/dist",
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "browser-agent-app",
3
- "version": "1.0.2",
3
+ "private": true,
4
+ "version": "1.0.0",
4
5
  "description": "Browser automation agent: AI-powered browser control (Desktop + Web)",
5
6
  "author": {
6
7
  "name": "xuyingzhou",
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "pi-chat-app",
3
- "version": "1.0.2",
3
+ "private": true,
4
+ "version": "1.0.0",
4
5
  "description": "Chat-focused template",
5
6
  "scripts": {
6
7
  "start": "vite build && electrobun dev",
@@ -7,6 +7,15 @@ import type {
7
7
  EventMetadata,
8
8
  } from "@dyyz1993/rpc-core";
9
9
  import type { RPCMethods, RPCEvents } from "../../shared/rpc-schema";
10
+
11
+ /** Keep the subscribe filter as strict as the typed client's (metadata keys). */
12
+ type SubscribeFilter<K extends keyof RPCEvents = keyof RPCEvents> = RPCEvents[K] extends {
13
+ metadata: infer M;
14
+ }
15
+ ? Partial<M>
16
+ : RPCEvents[K] extends { metadata?: infer M }
17
+ ? Partial<NonNullable<M>>
18
+ : Record<string, unknown>;
10
19
  import { rpcCache, CACHEABLE_METHODS } from "./rpc-cache";
11
20
 
12
21
  /**
@@ -176,7 +185,7 @@ class APIClientImpl {
176
185
  async subscribe<K extends keyof RPCEvents>(
177
186
  eventType: K,
178
187
  handler: (payload: EventPayload<RPCEvents[K]>, metadata: EventMetadata<RPCEvents[K]>) => void,
179
- filter?: Record<string, unknown>
188
+ filter?: SubscribeFilter<K>
180
189
  ): Promise<string> {
181
190
  await this.initialize();
182
191
  return this.client!.subscribe(eventType, handler, filter);
@@ -14,9 +14,7 @@ export function register(server: RPCServer, _options: HandlerOptions): void {
14
14
 
15
15
  r("debug.subscriptions", async () => {
16
16
  return {
17
- subscriptions: (
18
- server as unknown as { getActiveSubscriptions(): unknown }
19
- ).getActiveSubscriptions(),
17
+ subscriptions: server.getActiveSubscriptions(),
20
18
  };
21
19
  });
22
20
  }
@@ -17,8 +17,8 @@
17
17
  "noFallthroughCasesInSwitch": true,
18
18
  "baseUrl": ".",
19
19
  "paths": {
20
- "@dyyz1993/rpc-core": ["../packages/rpc-core/src/index.ts"],
21
- "@shared/*": ["../shared/*"]
20
+ "@dyyz1993/rpc-core": ["../../packages/rpc-core/src/index.ts"],
21
+ "@shared/*": ["./src/shared/*", "../shared/*"]
22
22
  },
23
23
  "noUncheckedIndexedAccess": true,
24
24
  "noImplicitReturns": true
@@ -26,6 +26,9 @@
26
26
  "include": ["src", "../shared"],
27
27
  "exclude": [
28
28
  "node_modules",
29
+ "../shared/__tests__",
30
+ "../shared/vite-base.config.ts",
31
+ "../shared/vitest-base.config.ts",
29
32
  "dist",
30
33
  "build",
31
34
  "../../package/dist",
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "cowork-app",
3
- "version": "1.0.2",
3
+ "private": true,
4
+ "version": "1.0.0",
4
5
  "description": "Cowork task collaboration agent: AI-powered task orchestration with progress tracking, artifacts, and context management (Desktop + Web)",
5
6
  "author": {
6
7
  "name": "xuyingzhou",
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "pi-general-app",
3
- "version": "1.0.2",
3
+ "private": true,
4
+ "version": "1.0.0",
4
5
  "description": "Electrobun app with React, Tailwind CSS, and Vite HMR",
5
6
  "scripts": {
6
7
  "start": "vite build && electrobun dev",
@@ -9,6 +9,15 @@ import type {
9
9
  import type { RPCMethods, RPCEvents } from "../../shared/rpc-schema";
10
10
  import { rpcCache, CACHEABLE_METHODS } from "./rpc-cache";
11
11
 
12
+ /** Keep the subscribe filter as strict as the typed client's (metadata keys). */
13
+ type SubscribeFilter<K extends keyof RPCEvents = keyof RPCEvents> = RPCEvents[K] extends {
14
+ metadata: infer M;
15
+ }
16
+ ? Partial<M>
17
+ : RPCEvents[K] extends { metadata?: infer M }
18
+ ? Partial<NonNullable<M>>
19
+ : Record<string, unknown>;
20
+
12
21
  /**
13
22
  * Token 来源优先级:
14
23
  * 1. URL query ?token=xxx(部署时注入)
@@ -176,7 +185,7 @@ class APIClientImpl {
176
185
  async subscribe<K extends keyof RPCEvents>(
177
186
  eventType: K,
178
187
  handler: (payload: EventPayload<RPCEvents[K]>, metadata: EventMetadata<RPCEvents[K]>) => void,
179
- filter?: Record<string, unknown>
188
+ filter?: SubscribeFilter<K>
180
189
  ): Promise<string> {
181
190
  await this.initialize();
182
191
  return this.client!.subscribe(eventType, handler, filter);
@@ -14,9 +14,7 @@ export function register(server: RPCServer, _options: HandlerOptions): void {
14
14
 
15
15
  r("debug.subscriptions", async () => {
16
16
  return {
17
- subscriptions: (
18
- server as unknown as { getActiveSubscriptions(): unknown }
19
- ).getActiveSubscriptions(),
17
+ subscriptions: server.getActiveSubscriptions(),
20
18
  };
21
19
  });
22
20
  }
@@ -17,8 +17,8 @@
17
17
  "noFallthroughCasesInSwitch": true,
18
18
  "baseUrl": ".",
19
19
  "paths": {
20
- "@dyyz1993/rpc-core": ["../packages/rpc-core/src/index.ts"],
21
- "@shared/*": ["../shared/*"]
20
+ "@dyyz1993/rpc-core": ["../../packages/rpc-core/src/index.ts"],
21
+ "@shared/*": ["./src/shared/*", "../shared/*"]
22
22
  },
23
23
  "noUncheckedIndexedAccess": true,
24
24
  "noImplicitReturns": true
@@ -26,6 +26,9 @@
26
26
  "include": ["src", "../shared"],
27
27
  "exclude": [
28
28
  "node_modules",
29
+ "../shared/__tests__",
30
+ "../shared/vite-base.config.ts",
31
+ "../shared/vitest-base.config.ts",
29
32
  "dist",
30
33
  "build",
31
34
  "../../package/dist",
@@ -1,15 +0,0 @@
1
- # pi-agent-app
2
-
3
- ## 1.0.2
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [[`29d2171`](https://github.com/dyyz1993/pi-agent-template/commit/29d217148f6e0b496cc06716e11847b3e522e266)]:
8
- - @dyyz1993/rpc-core@2.2.1
9
-
10
- ## 1.0.1
11
-
12
- ### Patch Changes
13
-
14
- - Updated dependencies [[`29d2171`](https://github.com/dyyz1993/pi-agent-template/commit/29d217148f6e0b496cc06716e11847b3e522e266), [`724470a`](https://github.com/dyyz1993/pi-agent-template/commit/724470a784b48a66591e06299fab8ad72f023962)]:
15
- - @dyyz1993/rpc-core@3.0.0
@@ -1,15 +0,0 @@
1
- # browser-agent-app
2
-
3
- ## 1.0.2
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [[`29d2171`](https://github.com/dyyz1993/pi-agent-template/commit/29d217148f6e0b496cc06716e11847b3e522e266)]:
8
- - @dyyz1993/rpc-core@2.2.1
9
-
10
- ## 1.0.1
11
-
12
- ### Patch Changes
13
-
14
- - Updated dependencies [[`29d2171`](https://github.com/dyyz1993/pi-agent-template/commit/29d217148f6e0b496cc06716e11847b3e522e266), [`724470a`](https://github.com/dyyz1993/pi-agent-template/commit/724470a784b48a66591e06299fab8ad72f023962)]:
15
- - @dyyz1993/rpc-core@3.0.0
@@ -1,15 +0,0 @@
1
- # pi-chat-app
2
-
3
- ## 1.0.2
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [[`29d2171`](https://github.com/dyyz1993/pi-agent-template/commit/29d217148f6e0b496cc06716e11847b3e522e266)]:
8
- - @dyyz1993/rpc-core@2.2.1
9
-
10
- ## 1.0.1
11
-
12
- ### Patch Changes
13
-
14
- - Updated dependencies [[`29d2171`](https://github.com/dyyz1993/pi-agent-template/commit/29d217148f6e0b496cc06716e11847b3e522e266), [`724470a`](https://github.com/dyyz1993/pi-agent-template/commit/724470a784b48a66591e06299fab8ad72f023962)]:
15
- - @dyyz1993/rpc-core@3.0.0
@@ -1,15 +0,0 @@
1
- # cowork-app
2
-
3
- ## 1.0.2
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [[`29d2171`](https://github.com/dyyz1993/pi-agent-template/commit/29d217148f6e0b496cc06716e11847b3e522e266)]:
8
- - @dyyz1993/rpc-core@2.2.1
9
-
10
- ## 1.0.1
11
-
12
- ### Patch Changes
13
-
14
- - Updated dependencies [[`29d2171`](https://github.com/dyyz1993/pi-agent-template/commit/29d217148f6e0b496cc06716e11847b3e522e266), [`724470a`](https://github.com/dyyz1993/pi-agent-template/commit/724470a784b48a66591e06299fab8ad72f023962)]:
15
- - @dyyz1993/rpc-core@3.0.0
@@ -1,15 +0,0 @@
1
- # pi-general-app
2
-
3
- ## 1.0.2
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [[`29d2171`](https://github.com/dyyz1993/pi-agent-template/commit/29d217148f6e0b496cc06716e11847b3e522e266)]:
8
- - @dyyz1993/rpc-core@2.2.1
9
-
10
- ## 1.0.1
11
-
12
- ### Patch Changes
13
-
14
- - Updated dependencies [[`29d2171`](https://github.com/dyyz1993/pi-agent-template/commit/29d217148f6e0b496cc06716e11847b3e522e266), [`724470a`](https://github.com/dyyz1993/pi-agent-template/commit/724470a784b48a66591e06299fab8ad72f023962)]:
15
- - @dyyz1993/rpc-core@3.0.0