@undefineds.co/models 0.1.1 → 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 -1
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export type
|
|
3
|
-
export type
|
|
2
|
+
export type RuntimeEventType = 'tool.call' | 'session.state' | 'tool.control' | 'inbox.approval';
|
|
3
|
+
export type RuntimeEventVersion = 1;
|
|
4
4
|
export declare const RiskLevelSchema: z.ZodEnum<["low", "medium", "high"]>;
|
|
5
5
|
export type RiskLevel = z.infer<typeof RiskLevelSchema>;
|
|
6
6
|
export declare const DecisionRoleSchema: z.ZodEnum<["human", "secretary", "system"]>;
|
|
@@ -148,7 +148,7 @@ export declare const SessionStateEventV1Schema: z.ZodObject<{
|
|
|
148
148
|
timestamp: z.ZodString;
|
|
149
149
|
}, "strict", z.ZodTypeAny, {
|
|
150
150
|
type: "session.state";
|
|
151
|
-
status: "active" | "error" | "
|
|
151
|
+
status: "active" | "error" | "completed" | "paused";
|
|
152
152
|
tokenUsage: number;
|
|
153
153
|
chatId: string;
|
|
154
154
|
tool: "claude-code" | "cursor" | "windsurf";
|
|
@@ -160,7 +160,7 @@ export declare const SessionStateEventV1Schema: z.ZodObject<{
|
|
|
160
160
|
version?: 1 | undefined;
|
|
161
161
|
}, {
|
|
162
162
|
type: "session.state";
|
|
163
|
-
status: "active" | "error" | "
|
|
163
|
+
status: "active" | "error" | "completed" | "paused";
|
|
164
164
|
tokenUsage: number;
|
|
165
165
|
chatId: string;
|
|
166
166
|
tool: "claude-code" | "cursor" | "windsurf";
|
|
@@ -185,7 +185,7 @@ export declare const SessionStateEventSchema: z.ZodObject<{
|
|
|
185
185
|
timestamp: z.ZodString;
|
|
186
186
|
}, "strict", z.ZodTypeAny, {
|
|
187
187
|
type: "session.state";
|
|
188
|
-
status: "active" | "error" | "
|
|
188
|
+
status: "active" | "error" | "completed" | "paused";
|
|
189
189
|
tokenUsage: number;
|
|
190
190
|
chatId: string;
|
|
191
191
|
tool: "claude-code" | "cursor" | "windsurf";
|
|
@@ -197,7 +197,7 @@ export declare const SessionStateEventSchema: z.ZodObject<{
|
|
|
197
197
|
version?: 1 | undefined;
|
|
198
198
|
}, {
|
|
199
199
|
type: "session.state";
|
|
200
|
-
status: "active" | "error" | "
|
|
200
|
+
status: "active" | "error" | "completed" | "paused";
|
|
201
201
|
tokenUsage: number;
|
|
202
202
|
chatId: string;
|
|
203
203
|
tool: "claude-code" | "cursor" | "windsurf";
|
|
@@ -427,7 +427,7 @@ export declare const InboxApprovalEventSchema: z.ZodObject<{
|
|
|
427
427
|
version?: 1 | undefined;
|
|
428
428
|
}>;
|
|
429
429
|
export type InboxApprovalEvent = z.infer<typeof InboxApprovalEventSchema>;
|
|
430
|
-
export declare const
|
|
430
|
+
export declare const RuntimeEventSchema: z.ZodUnion<[z.ZodObject<{
|
|
431
431
|
type: z.ZodLiteral<"tool.call">;
|
|
432
432
|
version: z.ZodOptional<z.ZodLiteral<1>>;
|
|
433
433
|
sessionId: z.ZodString;
|
|
@@ -501,7 +501,7 @@ export declare const SidecarEventSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
501
501
|
timestamp: z.ZodString;
|
|
502
502
|
}, "strict", z.ZodTypeAny, {
|
|
503
503
|
type: "session.state";
|
|
504
|
-
status: "active" | "error" | "
|
|
504
|
+
status: "active" | "error" | "completed" | "paused";
|
|
505
505
|
tokenUsage: number;
|
|
506
506
|
chatId: string;
|
|
507
507
|
tool: "claude-code" | "cursor" | "windsurf";
|
|
@@ -513,7 +513,7 @@ export declare const SidecarEventSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
513
513
|
version?: 1 | undefined;
|
|
514
514
|
}, {
|
|
515
515
|
type: "session.state";
|
|
516
|
-
status: "active" | "error" | "
|
|
516
|
+
status: "active" | "error" | "completed" | "paused";
|
|
517
517
|
tokenUsage: number;
|
|
518
518
|
chatId: string;
|
|
519
519
|
tool: "claude-code" | "cursor" | "windsurf";
|
|
@@ -628,5 +628,5 @@ export declare const SidecarEventSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
628
628
|
policyVersion?: string | undefined;
|
|
629
629
|
version?: 1 | undefined;
|
|
630
630
|
}>]>;
|
|
631
|
-
export type
|
|
632
|
-
export declare function
|
|
631
|
+
export type RuntimeEvent = z.infer<typeof RuntimeEventSchema>;
|
|
632
|
+
export declare function getRuntimeEventVersion(_event: RuntimeEvent): RuntimeEventVersion;
|
|
@@ -11,9 +11,6 @@ export const ToolCallStatusSchema = z.enum([
|
|
|
11
11
|
'error',
|
|
12
12
|
]);
|
|
13
13
|
const IsoDatetimeSchema = z.string().datetime();
|
|
14
|
-
// --------------------------------------------
|
|
15
|
-
// tool.call
|
|
16
|
-
// --------------------------------------------
|
|
17
14
|
export const ToolCallEventV1Schema = z
|
|
18
15
|
.object({
|
|
19
16
|
type: z.literal('tool.call'),
|
|
@@ -23,7 +20,6 @@ export const ToolCallEventV1Schema = z
|
|
|
23
20
|
toolName: z.string(),
|
|
24
21
|
risk: RiskLevelSchema.optional(),
|
|
25
22
|
status: ToolCallStatusSchema,
|
|
26
|
-
// CP0 Pod-only scope projection
|
|
27
23
|
target: z.string().optional(),
|
|
28
24
|
action: z.string().optional(),
|
|
29
25
|
arguments: z.record(z.unknown()).optional(),
|
|
@@ -31,17 +27,14 @@ export const ToolCallEventV1Schema = z
|
|
|
31
27
|
error: z.string().optional(),
|
|
32
28
|
duration: z.number().int().nonnegative().optional(),
|
|
33
29
|
inboxItemId: z.string().optional(),
|
|
34
|
-
decisionBy: z.string().optional(),
|
|
30
|
+
decisionBy: z.string().optional(),
|
|
35
31
|
decisionRole: DecisionRoleSchema.optional(),
|
|
36
|
-
onBehalfOf: z.string().optional(),
|
|
32
|
+
onBehalfOf: z.string().optional(),
|
|
37
33
|
policyVersion: z.string().optional(),
|
|
38
34
|
timestamp: IsoDatetimeSchema,
|
|
39
35
|
})
|
|
40
36
|
.strict();
|
|
41
37
|
export const ToolCallEventSchema = ToolCallEventV1Schema;
|
|
42
|
-
// --------------------------------------------
|
|
43
|
-
// session.state
|
|
44
|
-
// --------------------------------------------
|
|
45
38
|
export const SessionToolSchema = z.enum(['claude-code', 'cursor', 'windsurf']);
|
|
46
39
|
export const SessionStatusSchema = z.enum(['active', 'paused', 'completed', 'error']);
|
|
47
40
|
export const SessionStateEventV1Schema = z
|
|
@@ -60,9 +53,6 @@ export const SessionStateEventV1Schema = z
|
|
|
60
53
|
})
|
|
61
54
|
.strict();
|
|
62
55
|
export const SessionStateEventSchema = SessionStateEventV1Schema;
|
|
63
|
-
// --------------------------------------------
|
|
64
|
-
// tool.control
|
|
65
|
-
// --------------------------------------------
|
|
66
56
|
export const ToolControlCommandNameSchema = z.enum([
|
|
67
57
|
'approve',
|
|
68
58
|
'reject',
|
|
@@ -95,9 +85,6 @@ export const ToolControlCommandV1Schema = z
|
|
|
95
85
|
})
|
|
96
86
|
.strict();
|
|
97
87
|
export const ToolControlCommandSchema = ToolControlCommandV1Schema;
|
|
98
|
-
// --------------------------------------------
|
|
99
|
-
// inbox.approval
|
|
100
|
-
// --------------------------------------------
|
|
101
88
|
export const InboxApprovalStatusSchema = z.enum(['pending', 'approved', 'rejected', 'expired']);
|
|
102
89
|
export const InboxApprovalEventV1Schema = z
|
|
103
90
|
.object({
|
|
@@ -106,7 +93,6 @@ export const InboxApprovalEventV1Schema = z
|
|
|
106
93
|
inboxItemId: z.string(),
|
|
107
94
|
sessionId: z.string(),
|
|
108
95
|
toolCallId: z.string(),
|
|
109
|
-
// Optional Pod scope projection
|
|
110
96
|
target: z.string().optional(),
|
|
111
97
|
action: z.string().optional(),
|
|
112
98
|
policy: z.string().optional(),
|
|
@@ -119,15 +105,12 @@ export const InboxApprovalEventV1Schema = z
|
|
|
119
105
|
})
|
|
120
106
|
.strict();
|
|
121
107
|
export const InboxApprovalEventSchema = InboxApprovalEventV1Schema;
|
|
122
|
-
|
|
123
|
-
// SidecarEvent
|
|
124
|
-
// --------------------------------------------
|
|
125
|
-
export const SidecarEventSchema = z.union([
|
|
108
|
+
export const RuntimeEventSchema = z.union([
|
|
126
109
|
ToolCallEventSchema,
|
|
127
110
|
SessionStateEventSchema,
|
|
128
111
|
ToolControlCommandSchema,
|
|
129
112
|
InboxApprovalEventSchema,
|
|
130
113
|
]);
|
|
131
|
-
export function
|
|
114
|
+
export function getRuntimeEventVersion(_event) {
|
|
132
115
|
return 1;
|
|
133
116
|
}
|
package/dist/schema.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { schema } from './core.js';
|
package/dist/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { schema } from './core.js';
|
|
@@ -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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@undefineds.co/models",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -27,6 +27,14 @@
|
|
|
27
27
|
"types": "./dist/ai-config/index.d.ts",
|
|
28
28
|
"default": "./dist/ai-config/index.js"
|
|
29
29
|
},
|
|
30
|
+
"./protocols": {
|
|
31
|
+
"types": "./dist/protocols/index.d.ts",
|
|
32
|
+
"default": "./dist/protocols/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./governance": {
|
|
35
|
+
"types": "./dist/governance/index.d.ts",
|
|
36
|
+
"default": "./dist/governance/index.js"
|
|
37
|
+
},
|
|
30
38
|
"./_drizzle-solid/pod-table": {
|
|
31
39
|
"types": "./dist/_drizzle-solid/pod-table.d.ts",
|
|
32
40
|
"default": "./dist/_drizzle-solid/pod-table.js"
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wave A CP0: collaboration-related richContent block contracts.
|
|
3
|
-
*
|
|
4
|
-
* These are minimal JSON shapes stored in MessageRow.richContent and consumed by downstream UIs.
|
|
5
|
-
* They intentionally do NOT include UI block runtime fields (id/createdAt/status, etc.).
|
|
6
|
-
*/
|
|
7
|
-
export {};
|