@undefineds.co/models 0.1.0 → 0.2.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/README.md +125 -515
- package/dist/core/file/file.schema.d.ts +1 -1
- package/dist/core/file/file.schema.js +1 -1
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +3 -3
- package/dist/core/schema.d.ts +1 -1
- package/dist/core/schema.js +1 -1
- package/dist/core/types/{collaboration-blocks.d.ts → collaboration-rich-content.d.ts} +7 -7
- package/dist/core/types/collaboration-rich-content.js +7 -0
- package/dist/core/types/message-rich-content.d.ts +121 -0
- package/dist/core/types/message-rich-content.js +85 -0
- package/dist/fixtures/contracts-chat-contact.d.ts +4 -4
- package/dist/fixtures/contracts-chat-contact.js +8 -4
- package/dist/governance/index.d.ts +1 -0
- package/dist/governance/index.js +1 -0
- package/dist/{sidecar/persistence-mapping.d.ts → governance/runtime-projections.d.ts} +3 -3
- package/dist/{sidecar/persistence-mapping.js → governance/runtime-projections.js} +1 -7
- package/dist/index.d.ts +10 -7
- package/dist/index.js +11 -8
- package/dist/protocols/index.d.ts +1 -0
- package/dist/protocols/index.js +1 -0
- package/dist/{sidecar/sidecar-events.d.ts → protocols/runtime-events.d.ts} +11 -11
- package/dist/{sidecar/sidecar-events.js → protocols/runtime-events.js} +4 -21
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +1 -1
- package/dist/types/{collaboration-blocks.d.ts → collaboration-rich-content.d.ts} +7 -7
- package/dist/types/collaboration-rich-content.js +7 -0
- package/dist/types/message-rich-content.d.ts +121 -0
- package/dist/types/message-rich-content.js +85 -0
- package/package.json +9 -2
- package/dist/core/types/collaboration-blocks.js +0 -7
- package/dist/core/types/message-block.d.ts +0 -270
- package/dist/core/types/message-block.js +0 -125
- package/dist/sidecar/index.d.ts +0 -2
- package/dist/sidecar/index.js +0 -2
- package/dist/types/collaboration-blocks.js +0 -7
- package/dist/types/message-block.d.ts +0 -270
- package/dist/types/message-block.js +0 -125
- /package/dist/core/vocab/{sidecar.vocab.d.ts → governance.vocab.d.ts} +0 -0
- /package/dist/core/vocab/{sidecar.vocab.js → governance.vocab.js} +0 -0
- /package/dist/vocab/{sidecar.vocab.d.ts → governance.vocab.d.ts} +0 -0
- /package/dist/vocab/{sidecar.vocab.js → governance.vocab.js} +0 -0
|
@@ -2,7 +2,7 @@ import { podTable, string, timestamp, integer, boolean, id } from "@undefineds.c
|
|
|
2
2
|
import { UDFS, DCTerms, SCHEMA } from "../namespaces.js";
|
|
3
3
|
/**
|
|
4
4
|
* @deprecated 文件管理应由 xpod 处理,Pod 本身就是文件系统。
|
|
5
|
-
*
|
|
5
|
+
* 标签、索引等元数据功能由运行时治理/索引服务提供。
|
|
6
6
|
* 此 schema 将在未来版本中移除。
|
|
7
7
|
*
|
|
8
8
|
* File Schema
|
package/dist/core/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export { chatTable, type ChatMetadata, type ChatMemberRole, type ChatRow, type C
|
|
|
6
6
|
export { threadTable, type ThreadRow, type ThreadInsert, type ThreadUpdate, } from './thread.schema.js';
|
|
7
7
|
export { workspaceTable, WORKSPACE_TYPES, WORKSPACE_KINDS, getWorkspaceContainerPath, resolveWorkspaceContainerUri, parseWorkspaceIdFromContainerUri, normalizeLocalWorkspacePath, buildLocalWorkspaceUri, parseLocalWorkspaceUri, isLocalWorkspaceUri, type WorkspaceType, type WorkspaceKind, type WorkspaceRow, type WorkspaceInsert, type WorkspaceUpdate, } from './workspace.schema.js';
|
|
8
8
|
export { messageTable, type MessageRow, type MessageInsert, type MessageUpdate, } from './message.schema.js';
|
|
9
|
-
export {
|
|
10
|
-
export { type
|
|
9
|
+
export { RichContentItemType, type RichContentModelRef, type BaseRichContentItem, type MainTextRichContentItem, type ThinkingRichContentItem, type ImageRichContentItem, type CodeRichContentItem, type FileRichContentItem, type ErrorRichContentItem, type CitationRichContentItem, type MessageRichContentItem, type MessageRichContent, type LegacyToolInvocation, createRichContentItem, isRichContentItemType, parseMessageRichContent, parseMessageRichContentItems, serializeMessageRichContent, serializeMessageRichContentItems, } from './types/message-rich-content.js';
|
|
10
|
+
export { type ToolApprovalRichContentItem, type ToolCallRichContentItem, type TaskProgressRichContentItem, type CollaborationRichContentItem, type ToolRisk, type ToolApprovalStatus, type ToolCallStatus, type TaskProgressStepStatus, } from './types/collaboration-rich-content.js';
|
|
11
11
|
export { fileTable, type FileRow, type FileInsert, type FileUpdate } from './file.js';
|
|
12
12
|
export { favoriteTable, type FavoriteRow, type FavoriteInsert, type FavoriteUpdate, } from './favorite/favorite.schema.js';
|
|
13
13
|
export { settingsTable, SETTING_KEYS, type SettingKey, type SettingsRow, type SettingsInsert, type SettingsUpdate, } from './settings.js';
|
|
@@ -16,7 +16,7 @@ export { approvalTable, type ApprovalRow, type ApprovalInsert, type ApprovalUpda
|
|
|
16
16
|
export { auditTable, type AuditRow, type AuditInsert, type AuditUpdate, } from './audit.schema.js';
|
|
17
17
|
export { grantTable, type GrantRow, type GrantInsert, type GrantUpdate, } from './grant.schema.js';
|
|
18
18
|
export { inboxNotificationTable, type InboxNotificationRow, type InboxNotificationInsert, type InboxNotificationUpdate, } from './inbox-notification.schema.js';
|
|
19
|
-
export { ApprovalVocab, AuditVocab, GrantVocab, InboxNotificationVocab } from './vocab/
|
|
19
|
+
export { ApprovalVocab, AuditVocab, GrantVocab, InboxNotificationVocab } from './vocab/governance.vocab.js';
|
|
20
20
|
export { knowledgeFolderSchema, type KnowledgeFolderScope, } from './knowledge.js';
|
|
21
21
|
export { extensionSchema } from './extension.js';
|
|
22
22
|
export { sessionSchema } from './session.js';
|
|
@@ -28,4 +28,4 @@ export { aiConfigTable, type AIConfigRow, type AIConfigInsert, type AIConfigUpda
|
|
|
28
28
|
export { vectorStoreTable, indexedFileTable, type VectorStoreRow, type VectorStoreInsert, type VectorStoreUpdate, type IndexedFileRow, type IndexedFileInsert, type IndexedFileUpdate, } from './vector-store.schema.js';
|
|
29
29
|
export { agentProviderTable, agentProviderRelations, type AgentProviderRow, type AgentProviderInsert, type AgentProviderUpdate, } from './agent-provider.schema.js';
|
|
30
30
|
export { agentStatusTable, type AgentStatusRow, type AgentStatusInsert, type AgentStatusUpdate, } from './agent-status.schema.js';
|
|
31
|
-
export {
|
|
31
|
+
export { schema } from './schema.js';
|
package/dist/core/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export { chatTable, } from './chat.schema.js';
|
|
|
8
8
|
export { threadTable, } from './thread.schema.js';
|
|
9
9
|
export { workspaceTable, WORKSPACE_TYPES, WORKSPACE_KINDS, getWorkspaceContainerPath, resolveWorkspaceContainerUri, parseWorkspaceIdFromContainerUri, normalizeLocalWorkspacePath, buildLocalWorkspaceUri, parseLocalWorkspaceUri, isLocalWorkspaceUri, } from './workspace.schema.js';
|
|
10
10
|
export { messageTable, } from './message.schema.js';
|
|
11
|
-
export {
|
|
11
|
+
export { RichContentItemType, createRichContentItem, isRichContentItemType, parseMessageRichContent, parseMessageRichContentItems, serializeMessageRichContent, serializeMessageRichContentItems, } from './types/message-rich-content.js';
|
|
12
12
|
export { fileTable } from './file.js';
|
|
13
13
|
export { favoriteTable, } from './favorite/favorite.schema.js';
|
|
14
14
|
export { settingsTable, SETTING_KEYS, } from './settings.js';
|
|
@@ -17,7 +17,7 @@ export { approvalTable, } from './approval.schema.js';
|
|
|
17
17
|
export { auditTable, } from './audit.schema.js';
|
|
18
18
|
export { grantTable, } from './grant.schema.js';
|
|
19
19
|
export { inboxNotificationTable, } from './inbox-notification.schema.js';
|
|
20
|
-
export { ApprovalVocab, AuditVocab, GrantVocab, InboxNotificationVocab } from './vocab/
|
|
20
|
+
export { ApprovalVocab, AuditVocab, GrantVocab, InboxNotificationVocab } from './vocab/governance.vocab.js';
|
|
21
21
|
export { knowledgeFolderSchema, } from './knowledge.js';
|
|
22
22
|
export { extensionSchema } from './extension.js';
|
|
23
23
|
export { sessionSchema } from './session.js';
|
|
@@ -29,4 +29,4 @@ export { aiConfigTable, } from './ai-config.schema.js';
|
|
|
29
29
|
export { vectorStoreTable, indexedFileTable, } from './vector-store.schema.js';
|
|
30
30
|
export { agentProviderTable, agentProviderRelations, } from './agent-provider.schema.js';
|
|
31
31
|
export { agentStatusTable, } from './agent-status.schema.js';
|
|
32
|
-
export {
|
|
32
|
+
export { schema } from './schema.js';
|
package/dist/core/schema.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const schema: {
|
|
2
2
|
solidProfileTable: import("@undefineds.co/models/_drizzle-solid/pod-table").PodTableWithColumns<import("@undefineds.co/models/_drizzle-solid/types").ResolvedColumns<{
|
|
3
3
|
id: import("@undefineds.co/models/_drizzle-solid/columns").PodStringColumn<false, false>;
|
|
4
4
|
name: import("@undefineds.co/models/_drizzle-solid/columns").ColumnBuilder<"string", null, false, false>;
|
package/dist/core/schema.js
CHANGED
|
@@ -19,7 +19,7 @@ import { settingsTable } from './settings/settings.schema.js';
|
|
|
19
19
|
import { threadTable } from './thread.schema.js';
|
|
20
20
|
import { indexedFileTable, vectorStoreTable } from './vector-store.schema.js';
|
|
21
21
|
import { workspaceTable } from './workspace.schema.js';
|
|
22
|
-
export const
|
|
22
|
+
export const schema = {
|
|
23
23
|
solidProfileTable,
|
|
24
24
|
contactTable,
|
|
25
25
|
agentTable,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Wave A CP0: collaboration-related
|
|
2
|
+
* Wave A CP0: collaboration-related rich content items.
|
|
3
3
|
*
|
|
4
|
-
* These are
|
|
5
|
-
* They intentionally
|
|
4
|
+
* These are data contracts stored in `MessageRow.richContent.items`.
|
|
5
|
+
* They intentionally omit presentation/runtime wrapper fields.
|
|
6
6
|
*/
|
|
7
7
|
export type ToolRisk = 'low' | 'medium' | 'high';
|
|
8
8
|
export type ToolApprovalStatus = 'pending' | 'approved' | 'rejected' | 'auto_approved';
|
|
9
|
-
export interface
|
|
9
|
+
export interface ToolApprovalRichContentItem {
|
|
10
10
|
type: 'tool_approval';
|
|
11
11
|
toolCallId: string;
|
|
12
12
|
toolName: string;
|
|
@@ -24,7 +24,7 @@ export interface ToolApprovalBlock {
|
|
|
24
24
|
inboxItemId?: string;
|
|
25
25
|
}
|
|
26
26
|
export type TaskProgressStepStatus = 'pending' | 'running' | 'done' | 'error' | 'skipped';
|
|
27
|
-
export interface
|
|
27
|
+
export interface TaskProgressRichContentItem {
|
|
28
28
|
type: 'task_progress';
|
|
29
29
|
taskId: string;
|
|
30
30
|
title: string;
|
|
@@ -39,7 +39,7 @@ export interface TaskProgressBlock {
|
|
|
39
39
|
totalSteps: number;
|
|
40
40
|
}
|
|
41
41
|
export type ToolCallStatus = 'calling' | 'waiting_approval' | 'running' | 'done' | 'error';
|
|
42
|
-
export interface
|
|
42
|
+
export interface ToolCallRichContentItem {
|
|
43
43
|
type: 'tool';
|
|
44
44
|
toolCallId: string;
|
|
45
45
|
toolName: string;
|
|
@@ -49,4 +49,4 @@ export interface ToolCallBlock {
|
|
|
49
49
|
error?: string;
|
|
50
50
|
duration?: number;
|
|
51
51
|
}
|
|
52
|
-
export type
|
|
52
|
+
export type CollaborationRichContentItem = ToolApprovalRichContentItem | TaskProgressRichContentItem | ToolCallRichContentItem;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { ToolApprovalRichContentItem, ToolCallRichContentItem, TaskProgressRichContentItem } from './collaboration-rich-content.js';
|
|
2
|
+
/**
|
|
3
|
+
* Message rich content item kinds stored in `MessageRow.richContent`.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum RichContentItemType {
|
|
6
|
+
MAIN_TEXT = "main_text",
|
|
7
|
+
THINKING = "thinking",
|
|
8
|
+
IMAGE = "image",
|
|
9
|
+
CODE = "code",
|
|
10
|
+
TOOL = "tool",
|
|
11
|
+
TOOL_APPROVAL = "tool_approval",
|
|
12
|
+
TASK_PROGRESS = "task_progress",
|
|
13
|
+
FILE = "file",
|
|
14
|
+
ERROR = "error",
|
|
15
|
+
CITATION = "citation"
|
|
16
|
+
}
|
|
17
|
+
export interface RichContentModelRef {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
provider: string;
|
|
21
|
+
}
|
|
22
|
+
export interface BaseRichContentItem {
|
|
23
|
+
type: RichContentItemType;
|
|
24
|
+
model?: RichContentModelRef;
|
|
25
|
+
metadata?: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
export interface MainTextRichContentItem extends BaseRichContentItem {
|
|
28
|
+
type: RichContentItemType.MAIN_TEXT;
|
|
29
|
+
content: string;
|
|
30
|
+
knowledgeBaseIds?: string[];
|
|
31
|
+
citationReferences?: Array<{
|
|
32
|
+
citationItemId?: string;
|
|
33
|
+
url?: string;
|
|
34
|
+
title?: string;
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
37
|
+
export interface ThinkingRichContentItem extends BaseRichContentItem {
|
|
38
|
+
type: RichContentItemType.THINKING;
|
|
39
|
+
content: string;
|
|
40
|
+
thinkingDuration?: number;
|
|
41
|
+
}
|
|
42
|
+
export interface CodeRichContentItem extends BaseRichContentItem {
|
|
43
|
+
type: RichContentItemType.CODE;
|
|
44
|
+
content: string;
|
|
45
|
+
language: string;
|
|
46
|
+
executable?: boolean;
|
|
47
|
+
executionResult?: {
|
|
48
|
+
output?: string;
|
|
49
|
+
error?: string;
|
|
50
|
+
exitCode?: number;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export interface ImageRichContentItem extends BaseRichContentItem {
|
|
54
|
+
type: RichContentItemType.IMAGE;
|
|
55
|
+
url?: string;
|
|
56
|
+
filePath?: string;
|
|
57
|
+
metadata?: BaseRichContentItem['metadata'] & {
|
|
58
|
+
prompt?: string;
|
|
59
|
+
negativePrompt?: string;
|
|
60
|
+
fileName?: string;
|
|
61
|
+
fileSize?: number;
|
|
62
|
+
width?: number;
|
|
63
|
+
height?: number;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export interface CitationRichContentItem extends BaseRichContentItem {
|
|
67
|
+
type: RichContentItemType.CITATION;
|
|
68
|
+
webSearch?: {
|
|
69
|
+
query: string;
|
|
70
|
+
results: Array<{
|
|
71
|
+
title: string;
|
|
72
|
+
url: string;
|
|
73
|
+
snippet?: string;
|
|
74
|
+
favicon?: string;
|
|
75
|
+
}>;
|
|
76
|
+
};
|
|
77
|
+
knowledge?: Array<{
|
|
78
|
+
id: string;
|
|
79
|
+
title: string;
|
|
80
|
+
content: string;
|
|
81
|
+
source?: string;
|
|
82
|
+
}>;
|
|
83
|
+
}
|
|
84
|
+
export interface FileRichContentItem extends BaseRichContentItem {
|
|
85
|
+
type: RichContentItemType.FILE;
|
|
86
|
+
fileName: string;
|
|
87
|
+
fileUrl: string;
|
|
88
|
+
fileSize?: number;
|
|
89
|
+
mimeType?: string;
|
|
90
|
+
}
|
|
91
|
+
export interface ErrorRichContentItem extends BaseRichContentItem {
|
|
92
|
+
type: RichContentItemType.ERROR;
|
|
93
|
+
message: string;
|
|
94
|
+
retryable?: boolean;
|
|
95
|
+
code?: string;
|
|
96
|
+
details?: unknown;
|
|
97
|
+
}
|
|
98
|
+
export type MessageRichContentItem = MainTextRichContentItem | ThinkingRichContentItem | CodeRichContentItem | ImageRichContentItem | ToolCallRichContentItem | ToolApprovalRichContentItem | TaskProgressRichContentItem | FileRichContentItem | ErrorRichContentItem | CitationRichContentItem;
|
|
99
|
+
export interface LegacyToolInvocation {
|
|
100
|
+
id: string;
|
|
101
|
+
toolName: string;
|
|
102
|
+
input: unknown;
|
|
103
|
+
output?: unknown;
|
|
104
|
+
error?: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Message.richContent payload.
|
|
108
|
+
*/
|
|
109
|
+
export interface MessageRichContent {
|
|
110
|
+
thought?: string;
|
|
111
|
+
toolInvocations?: LegacyToolInvocation[];
|
|
112
|
+
items?: MessageRichContentItem[];
|
|
113
|
+
}
|
|
114
|
+
export declare function createRichContentItem<T extends MessageRichContentItem>(type: T['type'], partial: Omit<T, 'type'>): T;
|
|
115
|
+
export declare function isRichContentItemType<TType extends MessageRichContentItem['type']>(item: MessageRichContentItem, type: TType): item is Extract<MessageRichContentItem, {
|
|
116
|
+
type: TType;
|
|
117
|
+
}>;
|
|
118
|
+
export declare function parseMessageRichContent(richContent: string | null | undefined): MessageRichContent;
|
|
119
|
+
export declare function parseMessageRichContentItems(richContent: string | null | undefined): MessageRichContentItem[];
|
|
120
|
+
export declare function serializeMessageRichContent(content: MessageRichContent): string;
|
|
121
|
+
export declare function serializeMessageRichContentItems(items: MessageRichContentItem[]): string;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message rich content item kinds stored in `MessageRow.richContent`.
|
|
3
|
+
*/
|
|
4
|
+
export var RichContentItemType;
|
|
5
|
+
(function (RichContentItemType) {
|
|
6
|
+
RichContentItemType["MAIN_TEXT"] = "main_text";
|
|
7
|
+
RichContentItemType["THINKING"] = "thinking";
|
|
8
|
+
RichContentItemType["IMAGE"] = "image";
|
|
9
|
+
RichContentItemType["CODE"] = "code";
|
|
10
|
+
RichContentItemType["TOOL"] = "tool";
|
|
11
|
+
RichContentItemType["TOOL_APPROVAL"] = "tool_approval";
|
|
12
|
+
RichContentItemType["TASK_PROGRESS"] = "task_progress";
|
|
13
|
+
RichContentItemType["FILE"] = "file";
|
|
14
|
+
RichContentItemType["ERROR"] = "error";
|
|
15
|
+
RichContentItemType["CITATION"] = "citation";
|
|
16
|
+
})(RichContentItemType || (RichContentItemType = {}));
|
|
17
|
+
function toToolArguments(input) {
|
|
18
|
+
if (input !== null && typeof input === 'object' && !Array.isArray(input)) {
|
|
19
|
+
return input;
|
|
20
|
+
}
|
|
21
|
+
return { value: input };
|
|
22
|
+
}
|
|
23
|
+
function normalizeLegacyItems(payload) {
|
|
24
|
+
const items = [];
|
|
25
|
+
if (payload.thought) {
|
|
26
|
+
items.push({
|
|
27
|
+
type: RichContentItemType.THINKING,
|
|
28
|
+
content: payload.thought,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (payload.toolInvocations) {
|
|
32
|
+
payload.toolInvocations.forEach((toolInvocation) => {
|
|
33
|
+
items.push({
|
|
34
|
+
type: RichContentItemType.TOOL,
|
|
35
|
+
toolCallId: toolInvocation.id,
|
|
36
|
+
toolName: toolInvocation.toolName,
|
|
37
|
+
arguments: toToolArguments(toolInvocation.input),
|
|
38
|
+
status: toolInvocation.error ? 'error' : 'done',
|
|
39
|
+
result: toolInvocation.output,
|
|
40
|
+
error: toolInvocation.error,
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return items;
|
|
45
|
+
}
|
|
46
|
+
export function createRichContentItem(type, partial) {
|
|
47
|
+
return {
|
|
48
|
+
type,
|
|
49
|
+
...partial,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export function isRichContentItemType(item, type) {
|
|
53
|
+
return item.type === type;
|
|
54
|
+
}
|
|
55
|
+
export function parseMessageRichContent(richContent) {
|
|
56
|
+
if (!richContent) {
|
|
57
|
+
return { items: [] };
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const parsed = JSON.parse(richContent);
|
|
61
|
+
const { blocks, items, ...rest } = parsed;
|
|
62
|
+
if (Array.isArray(items)) {
|
|
63
|
+
return { ...rest, items };
|
|
64
|
+
}
|
|
65
|
+
if (Array.isArray(blocks)) {
|
|
66
|
+
return { ...rest, items: blocks };
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
...rest,
|
|
70
|
+
items: normalizeLegacyItems(parsed),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return { items: [] };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export function parseMessageRichContentItems(richContent) {
|
|
78
|
+
return parseMessageRichContent(richContent).items ?? [];
|
|
79
|
+
}
|
|
80
|
+
export function serializeMessageRichContent(content) {
|
|
81
|
+
return JSON.stringify(content);
|
|
82
|
+
}
|
|
83
|
+
export function serializeMessageRichContentItems(items) {
|
|
84
|
+
return serializeMessageRichContent({ items });
|
|
85
|
+
}
|
|
@@ -2,12 +2,12 @@ import type { ChatInsert } from '../chat.schema.js';
|
|
|
2
2
|
import type { ContactInsert } from '../contact.schema.js';
|
|
3
3
|
import type { MessageInsert } from '../message.schema.js';
|
|
4
4
|
import type { ThreadInsert } from '../thread.schema.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { ToolApprovalRichContentItem, ToolCallRichContentItem, TaskProgressRichContentItem } from '../types/collaboration-rich-content.js';
|
|
6
6
|
export declare const fixtureContactSolid: ContactInsert;
|
|
7
7
|
export declare const fixtureContactAgentWorkspace: ContactInsert;
|
|
8
8
|
export declare const fixtureChatDirectAI: ChatInsert;
|
|
9
9
|
export declare const fixtureThreadDirectAI: ThreadInsert;
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const
|
|
12
|
-
export declare const
|
|
10
|
+
export declare const fixtureToolCallRichContentItem: ToolCallRichContentItem;
|
|
11
|
+
export declare const fixtureToolApprovalRichContentItem: ToolApprovalRichContentItem;
|
|
12
|
+
export declare const fixtureTaskProgressRichContentItem: TaskProgressRichContentItem;
|
|
13
13
|
export declare const fixtureMessageTooling: MessageInsert;
|
|
@@ -33,7 +33,7 @@ export const fixtureThreadDirectAI = {
|
|
|
33
33
|
starred: false,
|
|
34
34
|
workspace: 'https://pod.example/.data/agent-workspaces/secretary/ws-main/',
|
|
35
35
|
};
|
|
36
|
-
export const
|
|
36
|
+
export const fixtureToolCallRichContentItem = {
|
|
37
37
|
type: 'tool',
|
|
38
38
|
toolCallId: 'toolcall-1',
|
|
39
39
|
toolName: 'write_file',
|
|
@@ -41,7 +41,7 @@ export const fixtureToolCallBlock = {
|
|
|
41
41
|
status: 'waiting_approval',
|
|
42
42
|
duration: 123,
|
|
43
43
|
};
|
|
44
|
-
export const
|
|
44
|
+
export const fixtureToolApprovalRichContentItem = {
|
|
45
45
|
type: 'tool_approval',
|
|
46
46
|
toolCallId: 'toolcall-1',
|
|
47
47
|
toolName: 'write_file',
|
|
@@ -51,7 +51,7 @@ export const fixtureToolApprovalBlock = {
|
|
|
51
51
|
status: 'pending',
|
|
52
52
|
decisionRole: 'human',
|
|
53
53
|
};
|
|
54
|
-
export const
|
|
54
|
+
export const fixtureTaskProgressRichContentItem = {
|
|
55
55
|
type: 'task_progress',
|
|
56
56
|
taskId: 'task-1',
|
|
57
57
|
title: 'CP0 contract baseline',
|
|
@@ -70,7 +70,11 @@ export const fixtureMessageTooling = {
|
|
|
70
70
|
role: 'assistant',
|
|
71
71
|
content: 'I will write a file after approval.',
|
|
72
72
|
richContent: JSON.stringify({
|
|
73
|
-
|
|
73
|
+
items: [
|
|
74
|
+
fixtureToolCallRichContentItem,
|
|
75
|
+
fixtureToolApprovalRichContentItem,
|
|
76
|
+
fixtureTaskProgressRichContentItem,
|
|
77
|
+
],
|
|
74
78
|
}),
|
|
75
79
|
status: 'sent',
|
|
76
80
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './runtime-projections.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './runtime-projections.js';
|
|
@@ -2,7 +2,7 @@ import type { ApprovalInsert, ApprovalUpdate } from '../approval.schema.js';
|
|
|
2
2
|
import type { AuditInsert } from '../audit.schema.js';
|
|
3
3
|
import type { GrantInsert } from '../grant.schema.js';
|
|
4
4
|
import type { InboxNotificationInsert } from '../inbox-notification.schema.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { InboxApprovalEvent, SessionStateEvent, ToolCallEvent } from '../protocols/runtime-events.js';
|
|
6
6
|
export type ChatSessionProjection = {
|
|
7
7
|
chatId: string;
|
|
8
8
|
sessionStatus: 'active' | 'paused' | 'completed' | 'error';
|
|
@@ -14,7 +14,7 @@ export type ApprovalProjectionUpdate = Partial<Pick<ApprovalUpdate, 'status' | '
|
|
|
14
14
|
export type AuditProjectionInsert = Pick<AuditInsert, 'action' | 'actor' | 'actorRole' | 'onBehalfOf' | 'session' | 'toolCallId' | 'approval' | 'context' | 'policy' | 'policyVersion'>;
|
|
15
15
|
export type GrantProjectionInsert = Pick<GrantInsert, 'target' | 'action' | 'effect' | 'riskCeiling' | 'decisionBy' | 'decisionRole' | 'onBehalfOf'>;
|
|
16
16
|
export type InboxNotificationProjectionInsert = Pick<InboxNotificationInsert, 'actor' | 'object'>;
|
|
17
|
-
export declare const
|
|
17
|
+
export declare const RuntimeEventProjectionRules: {
|
|
18
18
|
readonly tool_call_waiting_approval: {
|
|
19
19
|
readonly approval: "insert";
|
|
20
20
|
readonly inboxNotification: "insert";
|
|
@@ -37,6 +37,7 @@ export declare const SidecarEventToPodMapping: {
|
|
|
37
37
|
readonly chat: "update";
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
|
+
export type RuntimeEventProjectionRuleKey = keyof typeof RuntimeEventProjectionRules;
|
|
40
41
|
export declare function hasPodScope(scope: {
|
|
41
42
|
target?: string;
|
|
42
43
|
action?: string;
|
|
@@ -44,7 +45,6 @@ export declare function hasPodScope(scope: {
|
|
|
44
45
|
target: string;
|
|
45
46
|
action: string;
|
|
46
47
|
};
|
|
47
|
-
export type SidecarPersistenceRuleKey = keyof typeof SidecarEventToPodMapping;
|
|
48
48
|
export declare function isToolWaitingApproval(event: ToolCallEvent): boolean;
|
|
49
49
|
export declare function isToolDecisionEvent(event: ToolCallEvent): boolean;
|
|
50
50
|
export declare function isInboxResolved(event: InboxApprovalEvent): boolean;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export const
|
|
2
|
-
// tool.call
|
|
1
|
+
export const RuntimeEventProjectionRules = {
|
|
3
2
|
tool_call_waiting_approval: {
|
|
4
3
|
approval: 'insert',
|
|
5
4
|
inboxNotification: 'insert',
|
|
@@ -12,24 +11,19 @@ export const SidecarEventToPodMapping = {
|
|
|
12
11
|
audit: 'insert',
|
|
13
12
|
grant: null,
|
|
14
13
|
},
|
|
15
|
-
// inbox.approval
|
|
16
14
|
inbox_approval_resolved: {
|
|
17
15
|
approval: 'update',
|
|
18
16
|
inboxNotification: 'insert',
|
|
19
17
|
audit: null,
|
|
20
18
|
grant: null,
|
|
21
19
|
},
|
|
22
|
-
// session.state
|
|
23
20
|
session_state_terminal: {
|
|
24
21
|
chat: 'update',
|
|
25
22
|
},
|
|
26
23
|
};
|
|
27
|
-
// Projection helpers (pure, no DB calls)
|
|
28
|
-
// NOTE: CP0 scope is Pod-only. Only project events that provide a concrete ODRL target/action.
|
|
29
24
|
export function hasPodScope(scope) {
|
|
30
25
|
return typeof scope.target === 'string' && scope.target.length > 0 && typeof scope.action === 'string' && scope.action.length > 0;
|
|
31
26
|
}
|
|
32
|
-
// Optional helpers for downstream implementers (pure, no DB calls)
|
|
33
27
|
export function isToolWaitingApproval(event) {
|
|
34
28
|
return event.type === 'tool.call' && event.status === 'waiting_approval';
|
|
35
29
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,13 +11,13 @@ export { workspaceTable, WORKSPACE_TYPES, WORKSPACE_KINDS, getWorkspaceContainer
|
|
|
11
11
|
export { workspaceRepository } from './workspace.repository.js';
|
|
12
12
|
export { messageTable, type MessageRow, type MessageInsert, type MessageUpdate, } from './message.schema.js';
|
|
13
13
|
export { messageRepository } from './message.repository.js';
|
|
14
|
-
export {
|
|
15
|
-
export { type
|
|
14
|
+
export { RichContentItemType, type RichContentModelRef, type BaseRichContentItem, type MainTextRichContentItem, type ThinkingRichContentItem, type ImageRichContentItem, type CodeRichContentItem, type FileRichContentItem, type ErrorRichContentItem, type CitationRichContentItem, type MessageRichContentItem, type MessageRichContent, type LegacyToolInvocation, createRichContentItem, isRichContentItemType, parseMessageRichContent, parseMessageRichContentItems, serializeMessageRichContent, serializeMessageRichContentItems, } from './types/message-rich-content.js';
|
|
15
|
+
export { type ToolApprovalRichContentItem, type ToolCallRichContentItem, type TaskProgressRichContentItem, type CollaborationRichContentItem, type ToolRisk, type ToolApprovalStatus, type ToolCallStatus, type TaskProgressStepStatus, } from "./types/collaboration-rich-content.js";
|
|
16
16
|
export * from "./fixtures/contracts-chat-contact.js";
|
|
17
17
|
export { fileTable, type FileRow, type FileInsert, type FileUpdate, } from './file.js';
|
|
18
18
|
export { favoriteTable, type FavoriteRow, type FavoriteInsert, type FavoriteUpdate, createStarredSyncHook, registerDbForStarredSync, chatStarredSyncHook, threadStarredSyncHook, contactStarredSyncHook, chatSnapshotExtractor, threadSnapshotExtractor, contactSnapshotExtractor, type SnapshotExtractor, type StarredSyncConfig, type SourceModule, } from './favorite.js';
|
|
19
19
|
export { settingsTable, SETTING_KEYS, type SettingKey, type SettingsRow, type SettingsInsert, type SettingsUpdate, } from './settings.js';
|
|
20
|
-
export { agentTable, type AgentRow, type AgentInsert, type AgentUpdate, } from './agent.schema.js';
|
|
20
|
+
export { createAgentSchema, agentSchema, agentTable, type AgentRow, type AgentInsert, type AgentUpdate, type CreateAgentSchemaOptions, } from './agent.schema.js';
|
|
21
21
|
export { agentRepository } from './agent.repository.js';
|
|
22
22
|
export { DEFAULT_AGENT_PROVIDERS, type AgentProviderMetadata, type AgentModelOption, } from './agent.providers.js';
|
|
23
23
|
export { sessionSchema } from './session.js';
|
|
@@ -25,17 +25,20 @@ export { approvalTable, type ApprovalRow, type ApprovalInsert, type ApprovalUpda
|
|
|
25
25
|
export { auditTable, type AuditRow, type AuditInsert, type AuditUpdate, } from './audit.schema.js';
|
|
26
26
|
export { grantTable, type GrantRow, type GrantInsert, type GrantUpdate, } from './grant.schema.js';
|
|
27
27
|
export { inboxNotificationTable, type InboxNotificationRow, type InboxNotificationInsert, type InboxNotificationUpdate, } from './inbox-notification.schema.js';
|
|
28
|
-
export { ApprovalVocab, AuditVocab, GrantVocab, InboxNotificationVocab } from './vocab/
|
|
29
|
-
export * from './
|
|
30
|
-
export * from './
|
|
28
|
+
export { ApprovalVocab, AuditVocab, GrantVocab, InboxNotificationVocab } from './vocab/governance.vocab.js';
|
|
29
|
+
export * from './protocols/index.js';
|
|
30
|
+
export * from './governance/index.js';
|
|
31
31
|
export { knowledgeFolderSchema, type KnowledgeFolderScope } from './knowledge.js';
|
|
32
32
|
export { extensionSchema } from './extension.js';
|
|
33
33
|
export { credentialTable, apiKeyCredentialTable, oauthCredentialTable, type CredentialRow, type CredentialInsert, type CredentialUpdate, type ApiKeyCredentialRow, type ApiKeyCredentialInsert, type ApiKeyCredentialUpdate, type OAuthCredentialRow, type OAuthCredentialInsert, type OAuthCredentialUpdate, } from "./credential.schema.js";
|
|
34
34
|
export { aiProviderTable, type AIProviderRow, type AIProviderInsert, type AIProviderUpdate, } from "./ai-provider.schema.js";
|
|
35
35
|
export { aiModelTable, type AIModelRow, type AIModelInsert, type AIModelUpdate, } from "./ai-model.schema.js";
|
|
36
36
|
export { aiConfigModelUri, aiConfigProviderUri, buildAIConfigMutationPlan, buildAIConfigProviderStateMap, extractAIConfigProviderId, extractAIConfigResourceId, getAIConfigDefaultBaseUrl, getAIConfigProviderCatalog, getAIConfigProviderMetadata, getDefaultAIConfigCredentialId, sameAIConfigProviderId, type AIConfigModel, type AIConfigMutationPlan, type AIConfigProviderCatalogEntry, type AIConfigProviderState, type AIConfigUpdate, type BuildAIConfigProviderStateMapOptions, } from './ai-config.js';
|
|
37
|
+
export { aiConfigTable, type AIConfigRow, type AIConfigInsert, } from './core.js';
|
|
38
|
+
export { vectorStoreTable, indexedFileTable, type VectorStoreRow, type VectorStoreInsert, type VectorStoreUpdate, type IndexedFileRow, type IndexedFileInsert, type IndexedFileUpdate, } from './core.js';
|
|
39
|
+
export { agentStatusTable, type AgentStatusRow, type AgentStatusInsert, type AgentStatusUpdate, } from './core.js';
|
|
37
40
|
export { createRepositoryDescriptor, deleteExactRecord, definePodRepository, findExactRecord, isIriLikeIdentifier, resolveRowId, stripEntityIdentifiers, updateExactRecord, type PodRepositoryDescriptor, type RepositoryCacheOptions, type RepositoryInvalidations, type RepositoryScope, type SolidDatabase, } from './repository.js';
|
|
38
41
|
export { importJobSchema } from './import.js';
|
|
39
42
|
export { eq, ne, and, or, drizzle } from '@undefineds.co/drizzle-solid';
|
|
40
|
-
export {
|
|
43
|
+
export { schema } from './schema.js';
|
|
41
44
|
export * from './discovery.js';
|
package/dist/index.js
CHANGED
|
@@ -27,8 +27,8 @@ export { workspaceTable, WORKSPACE_TYPES, WORKSPACE_KINDS, getWorkspaceContainer
|
|
|
27
27
|
export { workspaceRepository } from './workspace.repository.js';
|
|
28
28
|
export { messageTable, } from './message.schema.js';
|
|
29
29
|
export { messageRepository } from './message.repository.js';
|
|
30
|
-
// Message
|
|
31
|
-
export {
|
|
30
|
+
// Message Rich Content - 消息富内容数据合同
|
|
31
|
+
export { RichContentItemType, createRichContentItem, isRichContentItemType, parseMessageRichContent, parseMessageRichContentItems, serializeMessageRichContent, serializeMessageRichContentItems, } from './types/message-rich-content.js';
|
|
32
32
|
// Wave A CP0: fixtures for downstream parallel development
|
|
33
33
|
export * from "./fixtures/contracts-chat-contact.js";
|
|
34
34
|
// File - 文件管理
|
|
@@ -40,7 +40,7 @@ createStarredSyncHook, registerDbForStarredSync, chatStarredSyncHook, threadStar
|
|
|
40
40
|
// Settings - 用户设置
|
|
41
41
|
export { settingsTable, SETTING_KEYS, } from './settings.js';
|
|
42
42
|
// Agent - AI 助手配置
|
|
43
|
-
export { agentTable, } from './agent.schema.js';
|
|
43
|
+
export { createAgentSchema, agentSchema, agentTable, } from './agent.schema.js';
|
|
44
44
|
export { agentRepository } from './agent.repository.js';
|
|
45
45
|
export { DEFAULT_AGENT_PROVIDERS, } from './agent.providers.js';
|
|
46
46
|
// ============================================
|
|
@@ -53,10 +53,10 @@ export { approvalTable, } from './approval.schema.js';
|
|
|
53
53
|
export { auditTable, } from './audit.schema.js';
|
|
54
54
|
export { grantTable, } from './grant.schema.js';
|
|
55
55
|
export { inboxNotificationTable, } from './inbox-notification.schema.js';
|
|
56
|
-
//
|
|
57
|
-
export { ApprovalVocab, AuditVocab, GrantVocab, InboxNotificationVocab } from './vocab/
|
|
58
|
-
export * from './
|
|
59
|
-
export * from './
|
|
56
|
+
// Governance vocab + protocol contracts
|
|
57
|
+
export { ApprovalVocab, AuditVocab, GrantVocab, InboxNotificationVocab } from './vocab/governance.vocab.js';
|
|
58
|
+
export * from './protocols/index.js';
|
|
59
|
+
export * from './governance/index.js';
|
|
60
60
|
// Knowledge Folder - 知识库文件夹
|
|
61
61
|
export { knowledgeFolderSchema } from './knowledge.js';
|
|
62
62
|
// Extension - 扩展
|
|
@@ -66,6 +66,9 @@ export { credentialTable, apiKeyCredentialTable, oauthCredentialTable, } from ".
|
|
|
66
66
|
export { aiProviderTable, } from "./ai-provider.schema.js";
|
|
67
67
|
export { aiModelTable, } from "./ai-model.schema.js";
|
|
68
68
|
export { aiConfigModelUri, aiConfigProviderUri, buildAIConfigMutationPlan, buildAIConfigProviderStateMap, extractAIConfigProviderId, extractAIConfigResourceId, getAIConfigDefaultBaseUrl, getAIConfigProviderCatalog, getAIConfigProviderMetadata, getDefaultAIConfigCredentialId, sameAIConfigProviderId, } from './ai-config.js';
|
|
69
|
+
export { aiConfigTable, } from './core.js';
|
|
70
|
+
export { vectorStoreTable, indexedFileTable, } from './core.js';
|
|
71
|
+
export { agentStatusTable, } from './core.js';
|
|
69
72
|
export { createRepositoryDescriptor, deleteExactRecord, definePodRepository, findExactRecord, isIriLikeIdentifier, resolveRowId, stripEntityIdentifiers, updateExactRecord, } from './repository.js';
|
|
70
73
|
// Import Job - 导入任务
|
|
71
74
|
export { importJobSchema } from './import.js';
|
|
@@ -76,7 +79,7 @@ export { eq, ne, and, or, drizzle } from '@undefineds.co/drizzle-solid';
|
|
|
76
79
|
// ============================================
|
|
77
80
|
// Schema registry
|
|
78
81
|
// ============================================
|
|
79
|
-
export {
|
|
82
|
+
export { schema } from './schema.js';
|
|
80
83
|
// ============================================
|
|
81
84
|
// Discovery Service (发现服务)
|
|
82
85
|
// ============================================
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './runtime-events.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './runtime-events.js';
|