@firmer/mesh 0.0.11 → 0.0.13

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.
@@ -25,4 +25,16 @@ export declare abstract class Consumer {
25
25
  * @return Output payload
26
26
  */
27
27
  abstract consume(ctx: Context, address: string, urn: string, execution: Execution<Reference>, inbound: Uint8Array): Promise<Uint8Array>;
28
+ /**
29
+ * Consumes sends the request and returns an async iterator of raw response bytes.
30
+ * The iterator is exhausted when the server finishes streaming.
31
+ *
32
+ * @param ctx Call context.
33
+ * @param address Remote address.
34
+ * @param urn Actual uniform resource domain name.
35
+ * @param execution Service reference.
36
+ * @param inbound Input arguments.
37
+ * @return AsyncIterator of output payload chunks
38
+ */
39
+ abstract consumes(ctx: Context, address: string, urn: string, execution: Execution<Reference>, inbound: Uint8Array): AsyncIterableIterator<Uint8Array>;
28
40
  }
@@ -2,6 +2,7 @@ import { Inspector, InvocationHandler } from '../macro';
2
2
  import { Invocation, Invoker } from './invoker';
3
3
  import { Context } from '../psi';
4
4
  import { Reference } from '../types';
5
+ import { Consumer } from './consumer';
5
6
  import { Codec } from '../codec';
6
7
  import { Execution } from './execution';
7
8
  export declare class ReferenceInvokeHandler<T extends object> implements Invoker<any>, InvocationHandler {
@@ -12,6 +13,7 @@ export declare class ReferenceInvokeHandler<T extends object> implements Invoker
12
13
  context(args: any[]): Context;
13
14
  invoke(proxy: any, method: Inspector, args: any[]): any;
14
15
  run(ctx: Context, invocation: Invocation): Promise<any>;
16
+ sse(ctx: Context, execution: Execution<Reference>, codec: Codec, consumer: Consumer, address: string, urn: string, buffer: Uint8Array): AsyncIterableIterator<any>;
15
17
  deserialize(ctx: Context, execution: Execution<Reference>, codec: Codec, future: Uint8Array): Promise<any>;
16
18
  referExecution(ctx: Context, inspector: Inspector): Execution<Reference>;
17
19
  /**
@@ -1,5 +1,5 @@
1
1
  import { Context } from './context';
2
- import { Versions } from '../types';
2
+ import { StreamEntity, StreamHello, Versions } from '../types';
3
3
  export declare abstract class Builtin {
4
4
  /**
5
5
  * Doc export the documents.
@@ -31,6 +31,11 @@ export declare abstract class Builtin {
31
31
  * 导出应用相关数据用于分析应用运行情况.
32
32
  */
33
33
  dump(names: string[], ctx?: Context): Promise<Record<string, string>>;
34
+ /**
35
+ * SSE stream server.
36
+ * 服务端流式响应
37
+ */
38
+ sse(hello: StreamHello, ctx?: Context): Promise<AsyncIterableIterator<StreamEntity>>;
34
39
  }
35
40
  export declare abstract class Hodor {
36
41
  /**
package/dist/psi/vm.d.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  import { Context } from './context';
2
2
  import { Page, Paging, Script } from '../types';
3
3
  export declare abstract class VM {
4
+ /**
5
+ * Render the script.
6
+ * 创建脚本脚手架.
7
+ */
8
+ render(script: Script, ctx?: Context): Promise<Record<string, Uint8Array>>;
4
9
  /**
5
10
  * Compile the script.
6
11
  * 编译脚本,编译通即会保存快照.
File without changes
@@ -72,3 +72,144 @@ export declare class FileEntry {
72
72
  */
73
73
  text: string;
74
74
  }
75
+ export declare class StreamEntity {
76
+ /**
77
+ *
78
+ */
79
+ role: string;
80
+ /**
81
+ * 体系 editor/converser
82
+ * 体系 editor/converser
83
+ */
84
+ party: string;
85
+ /**
86
+ * see ContentType
87
+ * see ContentType
88
+ */
89
+ kind: string;
90
+ /**
91
+ * AI思考过程
92
+ * AI思考过程
93
+ */
94
+ think: string;
95
+ /**
96
+ *
97
+ */
98
+ data: string;
99
+ /**
100
+ * Format mp3, mp4, wav, etc.
101
+ * Format mp3, mp4, wav, etc.
102
+ */
103
+ format: string;
104
+ /**
105
+ * Batch代表一次对话的所有响应
106
+ * Batch代表一次对话的所有响应
107
+ */
108
+ batch: string;
109
+ /**
110
+ * Step表示步骤
111
+ * Step表示步骤
112
+ */
113
+ step: string;
114
+ }
115
+ export declare class StreamOption {
116
+ /**
117
+ *
118
+ */
119
+ searchType: string;
120
+ /**
121
+ *
122
+ */
123
+ deepThink: boolean;
124
+ /**
125
+ *
126
+ */
127
+ deepResearch: boolean;
128
+ /**
129
+ * Model name, e.g., Qwen2-Audio-7B-Instruct
130
+ * Model name, e.g., Qwen2-Audio-7B-Instruct
131
+ */
132
+ model: string;
133
+ /**
134
+ * Scene name, e.g., audio, video, text
135
+ * Scene name, e.g., audio, video, text
136
+ */
137
+ scene: string;
138
+ /**
139
+ * default as generate,rewrite
140
+ * default as generate,rewrite
141
+ */
142
+ operateType: string;
143
+ /**
144
+ * Language of the content, e.g., zh, en
145
+ * Language of the content, e.g., zh, en
146
+ */
147
+ language: string;
148
+ /**
149
+ * 知识库编号
150
+ * 知识库编号
151
+ */
152
+ knowledgeID: string;
153
+ /**
154
+ * 代理地址
155
+ * 代理地址
156
+ */
157
+ proxy: string;
158
+ /**
159
+ * 补充参数
160
+ * 补充参数
161
+ */
162
+ attaches: Record<string, string>;
163
+ /**
164
+ * agent交互的智能体
165
+ * agent交互的智能体
166
+ */
167
+ agent: string;
168
+ }
169
+ export declare class StreamHello {
170
+ /**
171
+ *
172
+ */
173
+ method: string;
174
+ /**
175
+ *
176
+ */
177
+ mode: string;
178
+ /**
179
+ *
180
+ */
181
+ traceId: string;
182
+ /**
183
+ *
184
+ */
185
+ token: string;
186
+ /**
187
+ *
188
+ */
189
+ conversationId: string;
190
+ /**
191
+ *
192
+ */
193
+ contents: StreamEntity[];
194
+ /**
195
+ *
196
+ */
197
+ options: StreamOption;
198
+ }
199
+ export declare class StreamPacket<T> {
200
+ /**
201
+ * Result code
202
+ * Result code
203
+ */
204
+ code: string;
205
+ /**
206
+ * Result message
207
+ * Result message
208
+ */
209
+ message: string;
210
+ /**
211
+ * AI generate content
212
+ * AI generate content
213
+ */
214
+ content?: T;
215
+ }
@@ -71,3 +71,55 @@ export declare class Script extends Mani {
71
71
  */
72
72
  raw: Record<string, string>;
73
73
  }
74
+ export declare class Manifest {
75
+ /**
76
+ * Script code
77
+ * Script code
78
+ */
79
+ code: string;
80
+ /**
81
+ * Script name
82
+ * Script name
83
+ */
84
+ name: string;
85
+ /**
86
+ * Script kind, EXPRESSION/VALUE/SCRIPT/PROJECT. PROJECT is .tar format
87
+ * Script kind, EXPRESSION/VALUE/SCRIPT/PROJECT. PROJECT is .tar format
88
+ */
89
+ kind: string;
90
+ /**
91
+ * Script lang
92
+ * Script lang
93
+ */
94
+ lang: string;
95
+ /**
96
+ * 标记 1内置
97
+ * 标记 1内置
98
+ */
99
+ flags: number;
100
+ /**
101
+ * Script author
102
+ * Script author
103
+ */
104
+ author: string;
105
+ /**
106
+ * Script version
107
+ * Script version
108
+ */
109
+ version: string;
110
+ /**
111
+ * Script runtime, FE/RE
112
+ * Script runtime, FE/RE
113
+ */
114
+ runtime: string;
115
+ /**
116
+ * Script memo
117
+ * Script memo
118
+ */
119
+ memo: string;
120
+ /**
121
+ * Script icon
122
+ * Script icon
123
+ */
124
+ icon: string;
125
+ }
@@ -0,0 +1,2 @@
1
+ export * from './useAuth';
2
+ export * from './useStream';
@@ -0,0 +1,28 @@
1
+ import { Credential, Session } from '../types';
2
+ import { FC, ReactNode } from 'react';
3
+ export declare const QrParties: {
4
+ label: string;
5
+ value: string;
6
+ }[];
7
+ export type AuthMode = 'sms' | 'qrcode' | 'password';
8
+ declare class AuthContext {
9
+ redirect?: string;
10
+ session?: Session;
11
+ private readonly cacheKey;
12
+ private static readonly tokenizer;
13
+ private static readonly instance;
14
+ authorize(mode: AuthMode, account: Credential): Promise<void>;
15
+ authorized(): boolean;
16
+ authenticate(): Promise<Session>;
17
+ destroy(): Promise<void>;
18
+ static global(): AuthContext;
19
+ }
20
+ export declare const AuthContextProvider: FC<{
21
+ children: ReactNode;
22
+ redirect: string;
23
+ }>;
24
+ export declare const useAuth: () => AuthContext;
25
+ export declare const Authenticator: FC<{
26
+ next: (authorized: boolean, redirect: string) => ReactNode;
27
+ }>;
28
+ export {};
@@ -0,0 +1,16 @@
1
+ import { FC, ReactNode } from 'react';
2
+ import { StreamEntity, StreamHello } from '../types';
3
+ export declare class StreamContext {
4
+ /**
5
+ * SSE context.
6
+ */
7
+ sse(appset: string, hello: StreamHello, onmessage: (content: StreamEntity) => Promise<void>): Promise<void>;
8
+ /**
9
+ * Upload file into OOS.
10
+ */
11
+ fileup(file: File | Blob, bucket?: string, ext?: string, onprogress?: (step: number) => void): Promise<string>;
12
+ }
13
+ export declare const useStream: () => StreamContext;
14
+ export declare const StreamContextProvider: FC<{
15
+ children: ReactNode;
16
+ }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firmer/mesh",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Mesh: A lightweight, distributed, relational network architecture for MPC",
5
5
  "homepage": "mesh",
6
6
  "repository": "git.firmer.tech/firmer/mesh",
@@ -17,6 +17,7 @@
17
17
  "module": "./dist/mesh.d.ts",
18
18
  "exports": {
19
19
  ".": {
20
+ "types": "./dist/mesh.d.ts",
20
21
  "import": "./dist/mesh.js",
21
22
  "require": "./dist/mesh.umd.cjs"
22
23
  }
@@ -34,23 +35,29 @@
34
35
  "dependencies": {
35
36
  "@grpc/grpc-js": "^1.14.3",
36
37
  "@grpc/proto-loader": "^0.8.0",
37
- "@types/node": "^25.2.0",
38
38
  "async": "^3.2.6",
39
- "axios": "^1.13.4",
39
+ "axios": "^1.13.6",
40
40
  "buffer": "^6.0.3",
41
- "google-protobuf": "^4.0.1",
41
+ "google-protobuf": "^4.0.2",
42
42
  "grpc-web": "^2.0.2",
43
43
  "lodash": "^4.17.23",
44
44
  "moment": "^2.30.1"
45
45
  },
46
+ "peerDependencies": {
47
+ "react": ">=18.0.0"
48
+ },
46
49
  "devDependencies": {
47
50
  "@firmer/tsc": "0.0.1",
48
- "@types/react": "^19.2.10",
51
+ "@types/node": "^25.5.0",
52
+ "@types/react": "^19.2.14",
53
+ "@types/react-dom": "^19",
54
+ "@vitejs/plugin-react": "^6.0.1",
49
55
  "reflect-metadata": "^0.2.2",
56
+ "rollup": "^4.59.0",
50
57
  "typescript": "^5.9.3",
51
- "vite": "^7.3.1",
58
+ "vite": "^8.0.1",
52
59
  "vite-plugin-dts": "^4.5.4",
53
- "vitest": "^4.0.18"
60
+ "vitest": "^4.1.0"
54
61
  },
55
62
  "packageManager": "yarn@4.9.2"
56
63
  }