@axiom-lattice/protocols 4.9.0 → 4.11.0
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +56 -0
- package/dist/index.d.mts +103 -1
- package/dist/index.d.ts +103 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/ChannelAdapterProtocol.ts +39 -0
- package/src/ModelProviderProtocol.ts +65 -0
- package/src/VectorStoreProviderProtocol.ts +9 -0
package/package.json
CHANGED
|
@@ -43,6 +43,26 @@ export interface OutboundMessage {
|
|
|
43
43
|
metadata?: Record<string, unknown>;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* 流式回复的一个片段。
|
|
48
|
+
*
|
|
49
|
+
* `text` 是**累计全文**(不是增量)—— 与微信 `stream.content` 的语义一致:
|
|
50
|
+
* 每次推送都是"把当前消息刷新成这段内容"。实现方据此避免各自维护拼接状态。
|
|
51
|
+
*/
|
|
52
|
+
export interface OutboundStreamChunk {
|
|
53
|
+
/** 截至目前要展示的**累计**全文。 */
|
|
54
|
+
text: string;
|
|
55
|
+
/** 是否结束(最后一次刷新必须为 `true`)。 */
|
|
56
|
+
done: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* 结束原因;仅对 `done: true` 有意义。未提供视为正常完成。
|
|
59
|
+
*
|
|
60
|
+
* 适配器可据此决定是否发送运行中途产生的附加内容(例如企业微信卡片):
|
|
61
|
+
* 失败/中断/超时的轮次不应把半成品当成正常结果展示。
|
|
62
|
+
*/
|
|
63
|
+
reason?: "completed" | "failed" | "interrupted" | "timeout";
|
|
64
|
+
}
|
|
65
|
+
|
|
46
66
|
export interface DispatchResult {
|
|
47
67
|
success: boolean;
|
|
48
68
|
bindingId?: string;
|
|
@@ -76,6 +96,25 @@ export interface ChannelAdapter<TConfig = unknown> {
|
|
|
76
96
|
message: OutboundMessage,
|
|
77
97
|
installation: ChannelInstallation,
|
|
78
98
|
): Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* 可选:流式回复。
|
|
101
|
+
*
|
|
102
|
+
* 实现该方法后,`MessageRouter` 会在等待 `reply:ready` 的同时,把 agent
|
|
103
|
+
* 的**增量输出**按节流推给对方;`reply:ready` 到达时以 `done: true` 收尾。
|
|
104
|
+
*
|
|
105
|
+
* 实现约定:
|
|
106
|
+
* - 同一次入站消息的多次刷新必须关联到**同一条**消息(微信即同一个
|
|
107
|
+
* `stream.id`,`req_id` 取 `replyTarget.rawTarget.frame`);
|
|
108
|
+
* - 必须保证最终以 `done: true` 收尾(调用方保证至少会调一次);
|
|
109
|
+
* - 失败不应抛出到派发链路(吞掉并记日志)。
|
|
110
|
+
*
|
|
111
|
+
* 未实现时行为与之前完全一致(只在 `reply:ready` 时调一次 `sendReply`)。
|
|
112
|
+
*/
|
|
113
|
+
sendStreamChunk?(
|
|
114
|
+
replyTarget: ReplyTarget,
|
|
115
|
+
chunk: OutboundStreamChunk,
|
|
116
|
+
installation: ChannelInstallation,
|
|
117
|
+
): Promise<void>;
|
|
79
118
|
/**
|
|
80
119
|
* 可选:把 Agent 暂停等待人工输入时的问题/提示投影到会话中。
|
|
81
120
|
*
|
|
@@ -34,6 +34,21 @@ export type ModelProviderApiStyle = "chat-completions" | "responses";
|
|
|
34
34
|
*/
|
|
35
35
|
export type ModelProviderLlmProvider = LLMConfig["provider"];
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* What a model can do.
|
|
39
|
+
*
|
|
40
|
+
* Lives on the **model** row, not the provider: one provider is a set of
|
|
41
|
+
* credentials plus one base URL, and a single DashScope-compatible endpoint
|
|
42
|
+
* serves chat, embedding and speech at once. Putting this on the provider would
|
|
43
|
+
* force a tenant to create three providers pointing at the same address with
|
|
44
|
+
* the same secret.
|
|
45
|
+
*
|
|
46
|
+
* `"asr"` is speech-to-text; the runtime is the `stt` lattice, not
|
|
47
|
+
* `models`. The kinds are deliberately independent: each has its own lattice
|
|
48
|
+
* manager, its own loader guard, and its own client type.
|
|
49
|
+
*/
|
|
50
|
+
export type ModelKind = "chat" | "embedding" | "asr";
|
|
51
|
+
|
|
37
52
|
/**
|
|
38
53
|
* Build the tenant-scoped model key.
|
|
39
54
|
*
|
|
@@ -360,6 +375,14 @@ export interface ProviderModelInput extends DiscoveredModel {
|
|
|
360
375
|
* or carry `modelKwargs` the server needs, without duplicating the provider.
|
|
361
376
|
*/
|
|
362
377
|
extra?: Record<string, unknown>;
|
|
378
|
+
/**
|
|
379
|
+
* What this model does.
|
|
380
|
+
*
|
|
381
|
+
* Omitted means "keep the stored kind"; a brand-new row defaults to
|
|
382
|
+
* `"chat"`. Discovery cannot tell the kinds apart from `/v1/models`, so the
|
|
383
|
+
* admin sets it.
|
|
384
|
+
*/
|
|
385
|
+
kind?: ModelKind;
|
|
363
386
|
/**
|
|
364
387
|
* Whether this is the tenant's default model.
|
|
365
388
|
*
|
|
@@ -390,6 +413,12 @@ export interface ModelSelection {
|
|
|
390
413
|
* lose the config it already had.
|
|
391
414
|
*/
|
|
392
415
|
extra?: Record<string, unknown>;
|
|
416
|
+
/**
|
|
417
|
+
* What this model does.
|
|
418
|
+
*
|
|
419
|
+
* Omitted means "leave the stored kind alone", the same rule as `extra`.
|
|
420
|
+
*/
|
|
421
|
+
kind?: ModelKind;
|
|
393
422
|
/**
|
|
394
423
|
* Whether this is the tenant's default model.
|
|
395
424
|
*
|
|
@@ -424,6 +453,13 @@ export interface ModelProviderModelEntry {
|
|
|
424
453
|
*/
|
|
425
454
|
modelId: string;
|
|
426
455
|
|
|
456
|
+
/**
|
|
457
|
+
* What this model does — chat, embedding or speech-to-text.
|
|
458
|
+
*
|
|
459
|
+
* Rows created before this column existed are all `"chat"`.
|
|
460
|
+
*/
|
|
461
|
+
kind: ModelKind;
|
|
462
|
+
|
|
427
463
|
/**
|
|
428
464
|
* Optional human-readable name from the upstream
|
|
429
465
|
*/
|
|
@@ -576,6 +612,12 @@ export interface TenantModelPublicEntry {
|
|
|
576
612
|
*/
|
|
577
613
|
modelKey: string;
|
|
578
614
|
|
|
615
|
+
/**
|
|
616
|
+
* What this model does. Pickers filter on it: a chat selector must not offer
|
|
617
|
+
* an embedding model, and the collection picker must not offer a chat model.
|
|
618
|
+
*/
|
|
619
|
+
kind: ModelKind;
|
|
620
|
+
|
|
579
621
|
/**
|
|
580
622
|
* Optional human-readable name
|
|
581
623
|
*/
|
|
@@ -703,6 +745,21 @@ export interface ModelProviderProbeRequest {
|
|
|
703
745
|
* Wire protocol to speak. Defaults to `openai-compatible`.
|
|
704
746
|
*/
|
|
705
747
|
protocol?: ModelProviderWireProtocol;
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* What kind of model to probe.
|
|
751
|
+
*
|
|
752
|
+
* A model-list probe proves the address and the credential, not that a model
|
|
753
|
+
* can actually run. For embeddings the meaningful check is one inference
|
|
754
|
+
* request, which is why the caller names the model and the kind.
|
|
755
|
+
*/
|
|
756
|
+
kind?: ModelKind;
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* Model id to probe. Required when `kind` is `"embedding"`: the probe sends
|
|
760
|
+
* one tiny input to that model and reports the resulting vector's dimension.
|
|
761
|
+
*/
|
|
762
|
+
modelId?: string;
|
|
706
763
|
}
|
|
707
764
|
|
|
708
765
|
/**
|
|
@@ -736,6 +793,14 @@ export interface ModelProviderProbeResult {
|
|
|
736
793
|
* errors rather than as an unreachable probe.
|
|
737
794
|
*/
|
|
738
795
|
error?: ModelProviderUpstreamErrorCode;
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Dimension of the vector an embedding probe got back.
|
|
799
|
+
*
|
|
800
|
+
* Absent for a model-list probe, and for an upstream that answered but
|
|
801
|
+
* returned no usable vector.
|
|
802
|
+
*/
|
|
803
|
+
dimensions?: number;
|
|
739
804
|
}
|
|
740
805
|
|
|
741
806
|
/**
|
|
@@ -17,6 +17,15 @@ export interface VectorStoreCreateParams {
|
|
|
17
17
|
tableName: string;
|
|
18
18
|
/** Embedding model key to use for embedding operations */
|
|
19
19
|
embeddingKey: string;
|
|
20
|
+
/**
|
|
21
|
+
* Tenant whose embedding model the key belongs to.
|
|
22
|
+
*
|
|
23
|
+
* Tenant model keys are `${providerId}/${modelId}` and resolve per tenant, so
|
|
24
|
+
* a provider cannot look one up without knowing whose it is. Omitted means the
|
|
25
|
+
* deployment namespace (`"default"`), which is where boot-time registrations
|
|
26
|
+
* live.
|
|
27
|
+
*/
|
|
28
|
+
tenantId?: string;
|
|
20
29
|
/** Provider-specific configuration */
|
|
21
30
|
config?: Record<string, unknown>;
|
|
22
31
|
}
|