@tangle-network/agent-app 0.43.76 → 0.44.1
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 +1 -1
- package/dist/DesignCanvas-Z362I3R3.js +10 -0
- package/dist/{DesignCanvasEditor-FJIVYOA2.js → DesignCanvasEditor-ZFE2W4OJ.js} +4 -4
- package/dist/assets/index.d.ts +4 -4
- package/dist/assets/index.js +223 -11
- package/dist/assets/index.js.map +1 -1
- package/dist/assistant/index.d.ts +7 -7
- package/dist/assistant/index.js +3 -3
- package/dist/assistant/index.js.map +1 -1
- package/dist/{attachment-validation-Dv1A_Puy.d.ts → attachment-validation-DRuLEjAE.d.ts} +1 -1
- package/dist/{auth-_FU8w01b.d.ts → auth-anc7mv2W.d.ts} +2 -2
- package/dist/chat-routes/index.d.ts +14 -11
- package/dist/chat-routes/index.js +16 -17
- package/dist/chat-routes/index.js.map +1 -1
- package/dist/chat-store/index.d.ts +26 -7
- package/dist/chat-store/index.js +14 -5
- package/dist/chat-store/index.js.map +1 -1
- package/dist/{chunk-ROLFDOMJ.js → chunk-4TI7QWLW.js} +3 -3
- package/dist/{chunk-3JUTOVUH.js → chunk-6KMAM7BL.js} +1 -1
- package/dist/chunk-6KMAM7BL.js.map +1 -0
- package/dist/{chunk-WL7XHLDK.js → chunk-ICOHEZK6.js} +77 -5
- package/dist/chunk-ICOHEZK6.js.map +1 -0
- package/dist/{chunk-22GLESKE.js → chunk-O63WWYET.js} +2 -4
- package/dist/chunk-O63WWYET.js.map +1 -0
- package/dist/{chunk-E7N67FYI.js → chunk-Q3FONVAK.js} +5 -5
- package/dist/{chunk-E7N67FYI.js.map → chunk-Q3FONVAK.js.map} +1 -1
- package/dist/{chunk-RXOTWZ4G.js → chunk-TKRI463Z.js} +4 -4
- package/dist/chunk-TKRI463Z.js.map +1 -0
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +123 -4
- package/dist/config/index.js.map +1 -1
- package/dist/{contract-B3h7peV3.d.ts → contract-CEewO6DI.d.ts} +1 -1
- package/dist/design-canvas/index.d.ts +4 -4
- package/dist/design-canvas-react/index.js +7 -7
- package/dist/design-canvas-react/lazy.js +1 -1
- package/dist/eval/index.d.ts +1 -1
- package/dist/eval/index.js +22 -8
- package/dist/eval/index.js.map +1 -1
- package/dist/{flow-types-CqomVAUN.d.ts → flow-types-CJxEmaRy.d.ts} +1 -1
- package/dist/integrations/index.js +67 -5
- package/dist/integrations/index.js.map +1 -1
- package/dist/interactions/index.d.ts +6 -4
- package/dist/interactions/index.js +1 -2
- package/dist/knowledge/index.js +63 -4
- package/dist/knowledge/index.js.map +1 -1
- package/dist/knowledge-loop/index.d.ts +1 -1
- package/dist/knowledge-loop/index.js +94 -4
- package/dist/knowledge-loop/index.js.map +1 -1
- package/dist/{mcp-BjPqQ-3C.d.ts → mcp-D3qVzbE1.d.ts} +2 -2
- package/dist/{mcp-rpc-BfUOsalw.d.ts → mcp-rpc-CzU5LWWT.d.ts} +1 -1
- package/dist/missions/index.js +1143 -23
- package/dist/missions/index.js.map +1 -1
- package/dist/{model-DmdkIteM.d.ts → model-CdCDfBA9.d.ts} +1 -1
- package/dist/object-store/index.js +113 -8
- package/dist/object-store/index.js.map +1 -1
- package/dist/{parts-2ymE5cs-.d.ts → parts-Co_lFgLI.d.ts} +3 -3
- package/dist/platform/index.d.ts +1 -1
- package/dist/preflight/cli.d.ts +13 -0
- package/dist/preflight/cli.js +50 -0
- package/dist/preflight/cli.js.map +1 -0
- package/dist/preset-cloudflare/index.d.ts +1 -1
- package/dist/preset-cloudflare/index.js +284 -11
- package/dist/preset-cloudflare/index.js.map +1 -1
- package/dist/{queue-C24V13h9.d.ts → queue-CD5-_VTX.d.ts} +1 -1
- package/dist/redact/index.js +116 -8
- package/dist/redact/index.js.map +1 -1
- package/dist/runtime/index.d.ts +19 -111
- package/dist/runtime/index.js +234 -14
- package/dist/runtime/index.js.map +1 -1
- package/dist/sandbox/index.d.ts +3 -3
- package/dist/sandbox/index.js +2 -3
- package/dist/sequences/index.d.ts +4 -4
- package/dist/stream/index.d.ts +4 -4
- package/dist/{stream-normalizer-QYUl4vnl.d.ts → stream-normalizer-DnuqkZvw.d.ts} +2 -2
- package/dist/tangle/index.js +42 -4
- package/dist/tangle/index.js.map +1 -1
- package/dist/teams/index.js +5 -5
- package/dist/teams/invitations-api.js +4 -4
- package/dist/teams-react/index.js +3 -3
- package/dist/theme/index.js +0 -1
- package/dist/tools/index.d.ts +6 -6
- package/dist/tools/index.js +5 -7
- package/dist/trace/index.d.ts +1 -1
- package/dist/trace/index.js +179 -10
- package/dist/trace/index.js.map +1 -1
- package/dist/{turn-buffer-BaSgxVmK.d.ts → turn-buffer-BcPfhr1_.d.ts} +1 -1
- package/dist/turn-stream/index.d.ts +1 -1
- package/dist/{types-CBRyqijY.d.ts → types-BCxK0wyS.d.ts} +1 -1
- package/dist/{types-CEchbvgz.d.ts → types-XIZqIdX1.d.ts} +1 -1
- package/dist/web-react/index.d.ts +10 -10
- package/dist/web-react/index.js +5 -5
- package/dist/work-product/index.d.ts +4 -4
- package/dist/work-product/index.js +735 -15
- package/dist/work-product/index.js.map +1 -1
- package/dist/work-product-react/index.d.ts +1 -1
- package/dist/work-product-react/index.js.map +1 -1
- package/package.json +4 -19
- package/dist/DesignCanvas-UNL34LS2.js +0 -12
- package/dist/chunk-22GLESKE.js.map +0 -1
- package/dist/chunk-3JUTOVUH.js.map +0 -1
- package/dist/chunk-5EQCITY3.js +0 -20
- package/dist/chunk-5EQCITY3.js.map +0 -1
- package/dist/chunk-5SD6HT2V.js +0 -236
- package/dist/chunk-5SD6HT2V.js.map +0 -1
- package/dist/chunk-5TESA4SN.js +0 -74
- package/dist/chunk-5TESA4SN.js.map +0 -1
- package/dist/chunk-6GQ5DKFK.js +0 -920
- package/dist/chunk-6GQ5DKFK.js.map +0 -1
- package/dist/chunk-7ESQUSAC.js +0 -343
- package/dist/chunk-7ESQUSAC.js.map +0 -1
- package/dist/chunk-7LNGJDNA.js +0 -1
- package/dist/chunk-7LNGJDNA.js.map +0 -1
- package/dist/chunk-AP2UXKUK.js +0 -69
- package/dist/chunk-AP2UXKUK.js.map +0 -1
- package/dist/chunk-FA4XR66Y.js +0 -32
- package/dist/chunk-FA4XR66Y.js.map +0 -1
- package/dist/chunk-FKCB5FTD.js +0 -126
- package/dist/chunk-FKCB5FTD.js.map +0 -1
- package/dist/chunk-GPBRL2XR.js +0 -102
- package/dist/chunk-GPBRL2XR.js.map +0 -1
- package/dist/chunk-HRH7ASAG.js +0 -759
- package/dist/chunk-HRH7ASAG.js.map +0 -1
- package/dist/chunk-HYTIHYNV.js +0 -297
- package/dist/chunk-HYTIHYNV.js.map +0 -1
- package/dist/chunk-LGBO24FL.js +0 -190
- package/dist/chunk-LGBO24FL.js.map +0 -1
- package/dist/chunk-NLSSFLLS.js +0 -1168
- package/dist/chunk-NLSSFLLS.js.map +0 -1
- package/dist/chunk-OSMNYPOG.js +0 -129
- package/dist/chunk-OSMNYPOG.js.map +0 -1
- package/dist/chunk-QYOD3K56.js +0 -124
- package/dist/chunk-QYOD3K56.js.map +0 -1
- package/dist/chunk-RXOTWZ4G.js.map +0 -1
- package/dist/chunk-UAKFCMWK.js +0 -1
- package/dist/chunk-UAKFCMWK.js.map +0 -1
- package/dist/chunk-UKTYKG57.js +0 -48
- package/dist/chunk-UKTYKG57.js.map +0 -1
- package/dist/chunk-UOAYS72M.js +0 -80
- package/dist/chunk-UOAYS72M.js.map +0 -1
- package/dist/chunk-WL7XHLDK.js.map +0 -1
- package/dist/composer/index.d.ts +0 -2
- package/dist/composer/index.js +0 -22
- package/dist/composer/index.js.map +0 -1
- package/dist/core-7qIM7svy.d.ts +0 -21
- package/dist/durable-chat/index.d.ts +0 -464
- package/dist/durable-chat/index.js +0 -59
- package/dist/durable-chat/index.js.map +0 -1
- package/dist/index.d.ts +0 -51
- package/dist/index.js +0 -827
- package/dist/index.js.map +0 -1
- /package/dist/{DesignCanvas-UNL34LS2.js.map → DesignCanvas-Z362I3R3.js.map} +0 -0
- /package/dist/{DesignCanvasEditor-FJIVYOA2.js.map → DesignCanvasEditor-ZFE2W4OJ.js.map} +0 -0
- /package/dist/{chunk-ROLFDOMJ.js.map → chunk-4TI7QWLW.js.map} +0 -0
package/dist/chunk-5SD6HT2V.js
DELETED
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
// src/assets/schema.ts
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
var BrandTokensSchema = z.object({
|
|
4
|
-
primaryColor: z.string(),
|
|
5
|
-
accentColor: z.string(),
|
|
6
|
-
textColor: z.string(),
|
|
7
|
-
fontFamily: z.string(),
|
|
8
|
-
logoUrl: z.string().optional(),
|
|
9
|
-
businessName: z.string(),
|
|
10
|
-
voice: z.string()
|
|
11
|
-
});
|
|
12
|
-
var EmailHeroSectionSchema = z.object({
|
|
13
|
-
type: z.literal("hero"),
|
|
14
|
-
headline: z.string(),
|
|
15
|
-
subheadline: z.string().optional(),
|
|
16
|
-
imageUrl: z.string().optional(),
|
|
17
|
-
ctaLabel: z.string().optional(),
|
|
18
|
-
ctaUrl: z.string().optional()
|
|
19
|
-
});
|
|
20
|
-
var EmailBodySectionSchema = z.object({
|
|
21
|
-
type: z.literal("body"),
|
|
22
|
-
text: z.string()
|
|
23
|
-
});
|
|
24
|
-
var EmailFeatureSectionSchema = z.object({
|
|
25
|
-
type: z.literal("feature"),
|
|
26
|
-
headline: z.string(),
|
|
27
|
-
description: z.string(),
|
|
28
|
-
imageUrl: z.string().optional()
|
|
29
|
-
});
|
|
30
|
-
var EmailTestimonialSectionSchema = z.object({
|
|
31
|
-
type: z.literal("testimonial"),
|
|
32
|
-
quote: z.string(),
|
|
33
|
-
author: z.string(),
|
|
34
|
-
role: z.string().optional(),
|
|
35
|
-
avatarUrl: z.string().optional()
|
|
36
|
-
});
|
|
37
|
-
var EmailCtaSectionSchema = z.object({
|
|
38
|
-
type: z.literal("cta"),
|
|
39
|
-
label: z.string(),
|
|
40
|
-
url: z.string(),
|
|
41
|
-
subtext: z.string().optional()
|
|
42
|
-
});
|
|
43
|
-
var EmailDividerSectionSchema = z.object({
|
|
44
|
-
type: z.literal("divider")
|
|
45
|
-
});
|
|
46
|
-
var EmailSectionSchema = z.discriminatedUnion("type", [
|
|
47
|
-
EmailHeroSectionSchema,
|
|
48
|
-
EmailBodySectionSchema,
|
|
49
|
-
EmailFeatureSectionSchema,
|
|
50
|
-
EmailTestimonialSectionSchema,
|
|
51
|
-
EmailCtaSectionSchema,
|
|
52
|
-
EmailDividerSectionSchema
|
|
53
|
-
]);
|
|
54
|
-
var EmailContentSchema = z.object({
|
|
55
|
-
subject: z.string(),
|
|
56
|
-
preheader: z.string().optional(),
|
|
57
|
-
sections: z.array(EmailSectionSchema)
|
|
58
|
-
});
|
|
59
|
-
var ImageBackgroundSchema = z.discriminatedUnion("type", [
|
|
60
|
-
z.object({ type: z.literal("color"), value: z.string() }),
|
|
61
|
-
z.object({ type: z.literal("gradient"), from: z.string(), to: z.string(), direction: z.string().optional() }),
|
|
62
|
-
z.object({ type: z.literal("image"), url: z.string(), overlay: z.string().optional(), overlayOpacity: z.number().optional() })
|
|
63
|
-
]);
|
|
64
|
-
var ImageTextLayerSchema = z.object({
|
|
65
|
-
type: z.literal("text"),
|
|
66
|
-
text: z.string(),
|
|
67
|
-
fontSize: z.number().optional(),
|
|
68
|
-
fontWeight: z.enum(["normal", "bold"]).optional(),
|
|
69
|
-
color: z.string().optional(),
|
|
70
|
-
x: z.number(),
|
|
71
|
-
y: z.number(),
|
|
72
|
-
width: z.number().optional(),
|
|
73
|
-
align: z.enum(["left", "center", "right"]).optional()
|
|
74
|
-
});
|
|
75
|
-
var ImageImageLayerSchema = z.object({
|
|
76
|
-
type: z.literal("image"),
|
|
77
|
-
url: z.string(),
|
|
78
|
-
x: z.number(),
|
|
79
|
-
y: z.number(),
|
|
80
|
-
width: z.number(),
|
|
81
|
-
height: z.number(),
|
|
82
|
-
opacity: z.number().optional()
|
|
83
|
-
});
|
|
84
|
-
var ImageShapeLayerSchema = z.object({
|
|
85
|
-
type: z.literal("shape"),
|
|
86
|
-
shape: z.enum(["rect", "circle", "rounded-rect"]),
|
|
87
|
-
x: z.number(),
|
|
88
|
-
y: z.number(),
|
|
89
|
-
width: z.number(),
|
|
90
|
-
height: z.number(),
|
|
91
|
-
fill: z.string().optional(),
|
|
92
|
-
opacity: z.number().optional()
|
|
93
|
-
});
|
|
94
|
-
var ImageLogoLayerSchema = z.object({
|
|
95
|
-
type: z.literal("logo"),
|
|
96
|
-
x: z.number(),
|
|
97
|
-
y: z.number(),
|
|
98
|
-
width: z.number().optional()
|
|
99
|
-
});
|
|
100
|
-
var ImageLayerSchema = z.discriminatedUnion("type", [
|
|
101
|
-
ImageTextLayerSchema,
|
|
102
|
-
ImageImageLayerSchema,
|
|
103
|
-
ImageShapeLayerSchema,
|
|
104
|
-
ImageLogoLayerSchema
|
|
105
|
-
]);
|
|
106
|
-
var ImageSlideSchema = z.object({
|
|
107
|
-
background: ImageBackgroundSchema,
|
|
108
|
-
layers: z.array(ImageLayerSchema)
|
|
109
|
-
});
|
|
110
|
-
var ImageContentSchema = z.object({
|
|
111
|
-
slides: z.array(ImageSlideSchema).min(1)
|
|
112
|
-
});
|
|
113
|
-
var VideoTextAnimationSceneSchema = z.object({
|
|
114
|
-
type: z.literal("text-animation"),
|
|
115
|
-
durationSeconds: z.number().positive(),
|
|
116
|
-
headline: z.string(),
|
|
117
|
-
subtext: z.string().optional(),
|
|
118
|
-
animation: z.enum(["fade", "slide-up", "typewriter"]).optional(),
|
|
119
|
-
background: ImageBackgroundSchema.optional()
|
|
120
|
-
});
|
|
121
|
-
var VideoImageRevealSceneSchema = z.object({
|
|
122
|
-
type: z.literal("image-reveal"),
|
|
123
|
-
durationSeconds: z.number().positive(),
|
|
124
|
-
imageUrl: z.string(),
|
|
125
|
-
caption: z.string().optional()
|
|
126
|
-
});
|
|
127
|
-
var VideoSlideSceneSchema = z.object({
|
|
128
|
-
type: z.literal("slide"),
|
|
129
|
-
durationSeconds: z.number().positive(),
|
|
130
|
-
slide: ImageSlideSchema
|
|
131
|
-
});
|
|
132
|
-
var VideoCountdownSceneSchema = z.object({
|
|
133
|
-
type: z.literal("countdown"),
|
|
134
|
-
durationSeconds: z.number().positive(),
|
|
135
|
-
from: z.number().int().positive(),
|
|
136
|
-
label: z.string().optional()
|
|
137
|
-
});
|
|
138
|
-
var VideoSceneSchema = z.discriminatedUnion("type", [
|
|
139
|
-
VideoTextAnimationSceneSchema,
|
|
140
|
-
VideoImageRevealSceneSchema,
|
|
141
|
-
VideoSlideSceneSchema,
|
|
142
|
-
VideoCountdownSceneSchema
|
|
143
|
-
]);
|
|
144
|
-
var VideoCaptionSchema = z.object({
|
|
145
|
-
startSeconds: z.number().nonnegative(),
|
|
146
|
-
endSeconds: z.number().positive(),
|
|
147
|
-
text: z.string()
|
|
148
|
-
});
|
|
149
|
-
var VideoContentSchema = z.object({
|
|
150
|
-
durationSeconds: z.number().positive(),
|
|
151
|
-
scenes: z.array(VideoSceneSchema).min(1),
|
|
152
|
-
audioUrl: z.string().optional(),
|
|
153
|
-
captions: z.array(VideoCaptionSchema).optional(),
|
|
154
|
-
renderedUrl: z.string().optional()
|
|
155
|
-
});
|
|
156
|
-
var CopyContentSchema = z.object({
|
|
157
|
-
headline: z.string(),
|
|
158
|
-
body: z.string(),
|
|
159
|
-
hashtags: z.array(z.string()).optional(),
|
|
160
|
-
platform: z.enum(["instagram", "tiktok", "x", "linkedin", "sms", "email-subject"]),
|
|
161
|
-
characterCount: z.number().optional()
|
|
162
|
-
});
|
|
163
|
-
var ApprovalEventSchema = z.object({
|
|
164
|
-
assetId: z.string(),
|
|
165
|
-
variantId: z.string().optional(),
|
|
166
|
-
action: z.enum(["approved", "rejected", "edited", "scheduled"]),
|
|
167
|
-
editedFields: z.array(z.string()).optional(),
|
|
168
|
-
userId: z.string(),
|
|
169
|
-
timestamp: z.string()
|
|
170
|
-
});
|
|
171
|
-
var ConversionMetricsSchema = z.object({
|
|
172
|
-
impressions: z.number().nonnegative(),
|
|
173
|
-
clicks: z.number().nonnegative(),
|
|
174
|
-
conversions: z.number().nonnegative(),
|
|
175
|
-
ctr: z.number().nonnegative(),
|
|
176
|
-
cvr: z.number().nonnegative()
|
|
177
|
-
});
|
|
178
|
-
var AssetFormatValues = [
|
|
179
|
-
"email",
|
|
180
|
-
"image:feed",
|
|
181
|
-
"image:story",
|
|
182
|
-
"image:carousel",
|
|
183
|
-
"video:reel",
|
|
184
|
-
"video:feed",
|
|
185
|
-
"copy:caption",
|
|
186
|
-
"copy:headline",
|
|
187
|
-
"copy:sms"
|
|
188
|
-
];
|
|
189
|
-
var ContentSchemaByFormat = {
|
|
190
|
-
email: EmailContentSchema,
|
|
191
|
-
"image:feed": ImageContentSchema,
|
|
192
|
-
"image:story": ImageContentSchema,
|
|
193
|
-
"image:carousel": ImageContentSchema,
|
|
194
|
-
"video:reel": VideoContentSchema,
|
|
195
|
-
"video:feed": VideoContentSchema,
|
|
196
|
-
"copy:caption": CopyContentSchema,
|
|
197
|
-
"copy:headline": CopyContentSchema,
|
|
198
|
-
"copy:sms": CopyContentSchema
|
|
199
|
-
};
|
|
200
|
-
var AssetSpecBaseSchema = z.object({
|
|
201
|
-
id: z.string(),
|
|
202
|
-
workspaceId: z.string(),
|
|
203
|
-
campaignId: z.string().optional(),
|
|
204
|
-
format: z.enum(AssetFormatValues),
|
|
205
|
-
brand: BrandTokensSchema,
|
|
206
|
-
status: z.enum(["draft", "pending_review", "approved", "rejected", "scheduled", "published"]),
|
|
207
|
-
scheduledAt: z.string().optional(),
|
|
208
|
-
createdAt: z.string(),
|
|
209
|
-
updatedAt: z.string()
|
|
210
|
-
});
|
|
211
|
-
function parseAssetSpec(raw) {
|
|
212
|
-
const base = AssetSpecBaseSchema.parse(raw);
|
|
213
|
-
const contentSchema = ContentSchemaByFormat[base.format];
|
|
214
|
-
const content = contentSchema.parse(raw.content);
|
|
215
|
-
return { ...base, content };
|
|
216
|
-
}
|
|
217
|
-
function safeParseAssetSpec(raw) {
|
|
218
|
-
try {
|
|
219
|
-
return parseAssetSpec(raw);
|
|
220
|
-
} catch {
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
export {
|
|
226
|
-
BrandTokensSchema,
|
|
227
|
-
EmailContentSchema,
|
|
228
|
-
ImageContentSchema,
|
|
229
|
-
VideoContentSchema,
|
|
230
|
-
CopyContentSchema,
|
|
231
|
-
ApprovalEventSchema,
|
|
232
|
-
ConversionMetricsSchema,
|
|
233
|
-
parseAssetSpec,
|
|
234
|
-
safeParseAssetSpec
|
|
235
|
-
};
|
|
236
|
-
//# sourceMappingURL=chunk-5SD6HT2V.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/assets/schema.ts"],"sourcesContent":["import { z } from 'zod'\nimport type { AssetSpec, AssetFormat } from './types'\n\n// --- Brand ---\n\n/** Validate brand token properties including colors, font, logo URL, business name, and voice */\nexport const BrandTokensSchema = z.object({\n primaryColor: z.string(),\n accentColor: z.string(),\n textColor: z.string(),\n fontFamily: z.string(),\n logoUrl: z.string().optional(),\n businessName: z.string(),\n voice: z.string(),\n})\n\n// --- Email ---\n\nconst EmailHeroSectionSchema = z.object({\n type: z.literal('hero'),\n headline: z.string(),\n subheadline: z.string().optional(),\n imageUrl: z.string().optional(),\n ctaLabel: z.string().optional(),\n ctaUrl: z.string().optional(),\n})\n\nconst EmailBodySectionSchema = z.object({\n type: z.literal('body'),\n text: z.string(),\n})\n\nconst EmailFeatureSectionSchema = z.object({\n type: z.literal('feature'),\n headline: z.string(),\n description: z.string(),\n imageUrl: z.string().optional(),\n})\n\nconst EmailTestimonialSectionSchema = z.object({\n type: z.literal('testimonial'),\n quote: z.string(),\n author: z.string(),\n role: z.string().optional(),\n avatarUrl: z.string().optional(),\n})\n\nconst EmailCtaSectionSchema = z.object({\n type: z.literal('cta'),\n label: z.string(),\n url: z.string(),\n subtext: z.string().optional(),\n})\n\nconst EmailDividerSectionSchema = z.object({\n type: z.literal('divider'),\n})\n\nconst EmailSectionSchema = z.discriminatedUnion('type', [\n EmailHeroSectionSchema,\n EmailBodySectionSchema,\n EmailFeatureSectionSchema,\n EmailTestimonialSectionSchema,\n EmailCtaSectionSchema,\n EmailDividerSectionSchema,\n])\n\n/** Validate and parse email content objects with subject, optional preheader, and sections */\nexport const EmailContentSchema = z.object({\n subject: z.string(),\n preheader: z.string().optional(),\n sections: z.array(EmailSectionSchema),\n})\n\n// --- Image ---\n\nconst ImageBackgroundSchema = z.discriminatedUnion('type', [\n z.object({ type: z.literal('color'), value: z.string() }),\n z.object({ type: z.literal('gradient'), from: z.string(), to: z.string(), direction: z.string().optional() }),\n z.object({ type: z.literal('image'), url: z.string(), overlay: z.string().optional(), overlayOpacity: z.number().optional() }),\n])\n\nconst ImageTextLayerSchema = z.object({\n type: z.literal('text'),\n text: z.string(),\n fontSize: z.number().optional(),\n fontWeight: z.enum(['normal', 'bold']).optional(),\n color: z.string().optional(),\n x: z.number(),\n y: z.number(),\n width: z.number().optional(),\n align: z.enum(['left', 'center', 'right']).optional(),\n})\n\nconst ImageImageLayerSchema = z.object({\n type: z.literal('image'),\n url: z.string(),\n x: z.number(),\n y: z.number(),\n width: z.number(),\n height: z.number(),\n opacity: z.number().optional(),\n})\n\nconst ImageShapeLayerSchema = z.object({\n type: z.literal('shape'),\n shape: z.enum(['rect', 'circle', 'rounded-rect']),\n x: z.number(),\n y: z.number(),\n width: z.number(),\n height: z.number(),\n fill: z.string().optional(),\n opacity: z.number().optional(),\n})\n\nconst ImageLogoLayerSchema = z.object({\n type: z.literal('logo'),\n x: z.number(),\n y: z.number(),\n width: z.number().optional(),\n})\n\nconst ImageLayerSchema = z.discriminatedUnion('type', [\n ImageTextLayerSchema,\n ImageImageLayerSchema,\n ImageShapeLayerSchema,\n ImageLogoLayerSchema,\n])\n\nconst ImageSlideSchema = z.object({\n background: ImageBackgroundSchema,\n layers: z.array(ImageLayerSchema),\n})\n\n/** Validate image content with an array of one or more slides containing background details */\nexport const ImageContentSchema = z.object({\n slides: z.array(ImageSlideSchema).min(1),\n})\n\n// --- Video ---\n\nconst VideoTextAnimationSceneSchema = z.object({\n type: z.literal('text-animation'),\n durationSeconds: z.number().positive(),\n headline: z.string(),\n subtext: z.string().optional(),\n animation: z.enum(['fade', 'slide-up', 'typewriter']).optional(),\n background: ImageBackgroundSchema.optional(),\n})\n\nconst VideoImageRevealSceneSchema = z.object({\n type: z.literal('image-reveal'),\n durationSeconds: z.number().positive(),\n imageUrl: z.string(),\n caption: z.string().optional(),\n})\n\nconst VideoSlideSceneSchema = z.object({\n type: z.literal('slide'),\n durationSeconds: z.number().positive(),\n slide: ImageSlideSchema,\n})\n\nconst VideoCountdownSceneSchema = z.object({\n type: z.literal('countdown'),\n durationSeconds: z.number().positive(),\n from: z.number().int().positive(),\n label: z.string().optional(),\n})\n\nconst VideoSceneSchema = z.discriminatedUnion('type', [\n VideoTextAnimationSceneSchema,\n VideoImageRevealSceneSchema,\n VideoSlideSceneSchema,\n VideoCountdownSceneSchema,\n])\n\nconst VideoCaptionSchema = z.object({\n startSeconds: z.number().nonnegative(),\n endSeconds: z.number().positive(),\n text: z.string(),\n})\n\n/** Define the schema for validating video content including duration, scenes, audio, captions, and rendered URL */\nexport const VideoContentSchema = z.object({\n durationSeconds: z.number().positive(),\n scenes: z.array(VideoSceneSchema).min(1),\n audioUrl: z.string().optional(),\n captions: z.array(VideoCaptionSchema).optional(),\n renderedUrl: z.string().optional(),\n})\n\n// --- Copy ---\n\n/** Validate and parse copy content with headline, body, optional hashtags, platform, and character count */\nexport const CopyContentSchema = z.object({\n headline: z.string(),\n body: z.string(),\n hashtags: z.array(z.string()).optional(),\n platform: z.enum(['instagram', 'tiktok', 'x', 'linkedin', 'sms', 'email-subject']),\n characterCount: z.number().optional(),\n})\n\n// --- Approval ---\n\n/** Validate approval event data including asset, action, user, timestamp, and optional fields */\nexport const ApprovalEventSchema = z.object({\n assetId: z.string(),\n variantId: z.string().optional(),\n action: z.enum(['approved', 'rejected', 'edited', 'scheduled']),\n editedFields: z.array(z.string()).optional(),\n userId: z.string(),\n timestamp: z.string(),\n})\n\n/** Validate conversion metrics with nonnegative impressions, clicks, conversions, CTR, and CVR fields */\nexport const ConversionMetricsSchema = z.object({\n impressions: z.number().nonnegative(),\n clicks: z.number().nonnegative(),\n conversions: z.number().nonnegative(),\n ctr: z.number().nonnegative(),\n cvr: z.number().nonnegative(),\n})\n\n// --- Content map for discriminated parse ---\n\nconst AssetFormatValues = [\n 'email',\n 'image:feed',\n 'image:story',\n 'image:carousel',\n 'video:reel',\n 'video:feed',\n 'copy:caption',\n 'copy:headline',\n 'copy:sms',\n] as const\n\nconst ContentSchemaByFormat = {\n email: EmailContentSchema,\n 'image:feed': ImageContentSchema,\n 'image:story': ImageContentSchema,\n 'image:carousel': ImageContentSchema,\n 'video:reel': VideoContentSchema,\n 'video:feed': VideoContentSchema,\n 'copy:caption': CopyContentSchema,\n 'copy:headline': CopyContentSchema,\n 'copy:sms': CopyContentSchema,\n} as const\n\nconst AssetSpecBaseSchema = z.object({\n id: z.string(),\n workspaceId: z.string(),\n campaignId: z.string().optional(),\n format: z.enum(AssetFormatValues),\n brand: BrandTokensSchema,\n status: z.enum(['draft', 'pending_review', 'approved', 'rejected', 'scheduled', 'published']),\n scheduledAt: z.string().optional(),\n createdAt: z.string(),\n updatedAt: z.string(),\n})\n\n/**\n * Validates an unknown value as an AssetSpec, including format-specific\n * content validation. Throws ZodError on invalid input.\n */\nexport function parseAssetSpec(raw: unknown): AssetSpec {\n const base = AssetSpecBaseSchema.parse(raw)\n const contentSchema = ContentSchemaByFormat[base.format]\n const content = contentSchema.parse((raw as Record<string, unknown>).content)\n return { ...base, content } as AssetSpec\n}\n\n/**\n * Safe parse — returns null instead of throwing.\n */\nexport function safeParseAssetSpec(raw: unknown): AssetSpec | null {\n try {\n return parseAssetSpec(raw)\n } catch {\n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EAClB,cAAc;AAAA,EACd,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,YAAY;AACd;AAEA,IAAM,sBAAsB,EAAE,OAAO;AAAA,EACnC,IAAI,EAAE,OAAO;AAAA,EACb,aAAa,EAAE,OAAO;AAAA,EACtB,YAAY,EAAE,OAAO,EAAE,SAAS;AAAA,EAChC,QAAQ,EAAE,KAAK,iBAAiB;AAAA,EAChC,OAAO;AAAA,EACP,QAAQ,EAAE,KAAK,CAAC,SAAS,kBAAkB,YAAY,YAAY,aAAa,WAAW,CAAC;AAAA,EAC5F,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,WAAW,EAAE,OAAO;AAAA,EACpB,WAAW,EAAE,OAAO;AACtB,CAAC;AAMM,SAAS,eAAe,KAAyB;AACtD,QAAM,OAAO,oBAAoB,MAAM,GAAG;AAC1C,QAAM,gBAAgB,sBAAsB,KAAK,MAAM;AACvD,QAAM,UAAU,cAAc,MAAO,IAAgC,OAAO;AAC5E,SAAO,EAAE,GAAG,MAAM,QAAQ;AAC5B;AAKO,SAAS,mBAAmB,KAAgC;AACjE,MAAI;AACF,WAAO,eAAe,GAAG;AAAA,EAC3B,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/dist/chunk-5TESA4SN.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
// src/integrations/index.ts
|
|
2
|
-
import { parseIntegrationToolName } from "@tangle-network/agent-integrations/catalog";
|
|
3
|
-
function resolveIntegrationAction(toolName) {
|
|
4
|
-
let parsed;
|
|
5
|
-
try {
|
|
6
|
-
parsed = parseIntegrationToolName(toolName);
|
|
7
|
-
} catch {
|
|
8
|
-
return void 0;
|
|
9
|
-
}
|
|
10
|
-
if (!parsed.providerId || !parsed.connectorId || !parsed.actionId) return void 0;
|
|
11
|
-
return { ...parsed, path: `${parsed.providerId}.${parsed.connectorId}.${parsed.actionId}` };
|
|
12
|
-
}
|
|
13
|
-
var HubExecClient = class {
|
|
14
|
-
baseUrl;
|
|
15
|
-
bearer;
|
|
16
|
-
fetchImpl;
|
|
17
|
-
constructor(options) {
|
|
18
|
-
if (!options.baseUrl) throw new Error("HubExecClient: baseUrl is required");
|
|
19
|
-
if (!options.bearer) throw new Error("HubExecClient: bearer is required");
|
|
20
|
-
this.baseUrl = options.baseUrl.replace(/\/+$/, "");
|
|
21
|
-
this.bearer = options.bearer;
|
|
22
|
-
this.fetchImpl = options.fetchImpl ?? fetch;
|
|
23
|
-
}
|
|
24
|
-
async exec(input) {
|
|
25
|
-
const response = await this.fetchImpl(`${this.baseUrl}/v1/hub/exec`, {
|
|
26
|
-
method: "POST",
|
|
27
|
-
headers: { Authorization: `Bearer ${this.bearer}`, "Content-Type": "application/json", Accept: "application/json" },
|
|
28
|
-
body: JSON.stringify({ path: input.path, input: input.actionInput, connectionId: input.connectionId })
|
|
29
|
-
});
|
|
30
|
-
const envelope = await this.readEnvelope(response);
|
|
31
|
-
if (response.ok && envelope.success) return { succeeded: true, result: envelope.data?.result };
|
|
32
|
-
return {
|
|
33
|
-
succeeded: false,
|
|
34
|
-
code: envelope.error?.code ?? `HUB_HTTP_${response.status}`,
|
|
35
|
-
message: envelope.error?.message ?? `Hub /exec returned ${response.status}`,
|
|
36
|
-
approval: envelope.error?.details?.approval
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
async readEnvelope(response) {
|
|
40
|
-
const text = await response.text();
|
|
41
|
-
if (!text) return { success: false, error: { code: `HUB_HTTP_${response.status}`, message: `Hub returned ${response.status} with no body` } };
|
|
42
|
-
try {
|
|
43
|
-
return JSON.parse(text);
|
|
44
|
-
} catch {
|
|
45
|
-
return { success: false, error: { code: "HUB_BAD_RESPONSE", message: `Hub returned non-JSON (${response.status}): ${text.slice(0, 200)}` } };
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
async function invokeIntegrationHub(input, deps) {
|
|
50
|
-
const env = deps.env ?? process.env;
|
|
51
|
-
const baseUrl = deps.baseUrl ?? env.TANGLE_PLATFORM_URL?.trim();
|
|
52
|
-
if (!baseUrl) return { status: 500, body: { error: "TANGLE_PLATFORM_URL is not configured" } };
|
|
53
|
-
const action = resolveIntegrationAction(input.toolName);
|
|
54
|
-
if (!action) return { status: 400, body: { error: `Unsupported integration tool: ${input.toolName}` } };
|
|
55
|
-
const bearer = await deps.apiKeyResolver(input.userId);
|
|
56
|
-
if (!bearer) return { status: 401, body: { error: "Tangle account not linked \u2014 connect integrations from the app first" } };
|
|
57
|
-
const client = new HubExecClient({ baseUrl, bearer, fetchImpl: deps.fetchImpl });
|
|
58
|
-
const outcome = await client.exec({ path: action.path, actionInput: input.args ?? {} });
|
|
59
|
-
if (outcome.succeeded) {
|
|
60
|
-
return { status: 200, body: { success: true, path: action.path, providerId: action.providerId, action: action.actionId, result: outcome.result } };
|
|
61
|
-
}
|
|
62
|
-
const status = outcome.code === "HUB_APPROVAL_REQUIRED" ? 409 : 502;
|
|
63
|
-
return {
|
|
64
|
-
status,
|
|
65
|
-
body: { success: false, path: action.path, code: outcome.code, error: outcome.message, ...outcome.approval ? { approval: outcome.approval } : {} }
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export {
|
|
70
|
-
resolveIntegrationAction,
|
|
71
|
-
HubExecClient,
|
|
72
|
-
invokeIntegrationHub
|
|
73
|
-
};
|
|
74
|
-
//# sourceMappingURL=chunk-5TESA4SN.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/integrations/index.ts"],"sourcesContent":["/**\n * Integration-hub WIRING — the agent→hub invocation path every Tangle agent app\n * forks. The integration ENGINE (catalog, connectors, OAuth, policy) is\n * `@tangle-network/agent-integrations` (a peer dependency); this module is the\n * thin app-side wiring on top: a typed client over the platform hub's\n * `POST /v1/hub/exec`, MCP-tool-name → hub-action-path resolution, and the\n * per-turn invoke flow the `integration_invoke` tool calls.\n *\n * The product supplies its own catalog (which connectors it uses) and its own\n * per-user api-key resolver (the `apiKeyResolver` seam) — this module owns\n * neither credentials nor the action catalog.\n */\nimport { parseIntegrationToolName } from '@tangle-network/agent-integrations/catalog'\n\n/** `{ success: false }` codes the hub returns on `/exec`. */\nexport type HubExecErrorCode =\n | 'HUB_APPROVAL_REQUIRED'\n | 'HUB_POLICY_DENIED'\n | 'HUB_CONNECTION_MISSING'\n | 'HUB_CONNECTION_REVOKED'\n | 'HUB_CONFIG_MISSING'\n | 'HUB_NOT_FOUND'\n | string\n\n/** Outcome of a hub `/exec` call. Callers MUST inspect `succeeded` before\n * reading `result` — a denied or approval-gated write resolves with\n * `succeeded: false` and a populated `code`, never a thrown silent failure. */\nexport type HubExecResult =\n | { succeeded: true; result: unknown }\n | { succeeded: false; code: HubExecErrorCode; message: string; approval?: unknown }\n\n/** Define configuration options for initializing a Hub execution client */\nexport interface HubExecClientOptions {\n /** Platform base URL (e.g. `TANGLE_PLATFORM_URL`). */\n baseUrl: string\n /** Calling user's Tangle API key — the hub principal bearer. */\n bearer: string\n /** Test seam. Defaults to global `fetch`. */\n fetchImpl?: typeof fetch\n}\n\n/** The provider/connector/action a hub action path addresses, plus the dotted\n * `path` the hub `/exec` endpoint expects. */\nexport interface ParsedIntegrationAction {\n providerId: string\n connectorId: string\n actionId: string\n /** `provider.connector.action`. */\n path: string\n}\n\n/**\n * Resolve an MCP tool name (the opaque `int_…` catalog name the agent calls)\n * into the dotted hub action path. Returns `undefined` when the name is not a\n * catalog integration tool, so the chat loop routes non-integration calls\n * elsewhere instead of misrouting them to the hub.\n */\nexport function resolveIntegrationAction(toolName: string): ParsedIntegrationAction | undefined {\n let parsed: { providerId: string; connectorId: string; actionId: string }\n try {\n parsed = parseIntegrationToolName(toolName)\n } catch {\n return undefined\n }\n if (!parsed.providerId || !parsed.connectorId || !parsed.actionId) return undefined\n return { ...parsed, path: `${parsed.providerId}.${parsed.connectorId}.${parsed.actionId}` }\n}\n\ninterface HubEnvelope {\n success: boolean\n data?: { result?: unknown }\n error?: { code?: string; message?: string; details?: { approval?: unknown } }\n}\n\n/** Typed client over the platform hub `/v1/hub/exec`. The hub holds the user's\n * credentials, resolves the connection from the bearer principal, evaluates\n * per-action policy (read → allow, write/destructive → approval), and runs the\n * action server-side. Never throws on a policy block — a gated write is a\n * normal `succeeded: false` outcome. */\nexport class HubExecClient {\n private readonly baseUrl: string\n private readonly bearer: string\n private readonly fetchImpl: typeof fetch\n\n constructor(options: HubExecClientOptions) {\n if (!options.baseUrl) throw new Error('HubExecClient: baseUrl is required')\n if (!options.bearer) throw new Error('HubExecClient: bearer is required')\n this.baseUrl = options.baseUrl.replace(/\\/+$/, '')\n this.bearer = options.bearer\n this.fetchImpl = options.fetchImpl ?? fetch\n }\n\n async exec(input: { path: string; actionInput?: unknown; connectionId?: string }): Promise<HubExecResult> {\n const response = await this.fetchImpl(`${this.baseUrl}/v1/hub/exec`, {\n method: 'POST',\n headers: { Authorization: `Bearer ${this.bearer}`, 'Content-Type': 'application/json', Accept: 'application/json' },\n body: JSON.stringify({ path: input.path, input: input.actionInput, connectionId: input.connectionId }),\n })\n const envelope = await this.readEnvelope(response)\n if (response.ok && envelope.success) return { succeeded: true, result: envelope.data?.result }\n return {\n succeeded: false,\n code: envelope.error?.code ?? `HUB_HTTP_${response.status}`,\n message: envelope.error?.message ?? `Hub /exec returned ${response.status}`,\n approval: envelope.error?.details?.approval,\n }\n }\n\n private async readEnvelope(response: Response): Promise<HubEnvelope> {\n const text = await response.text()\n if (!text) return { success: false, error: { code: `HUB_HTTP_${response.status}`, message: `Hub returned ${response.status} with no body` } }\n try {\n return JSON.parse(text) as HubEnvelope\n } catch {\n return { success: false, error: { code: 'HUB_BAD_RESPONSE', message: `Hub returned non-JSON (${response.status}): ${text.slice(0, 200)}` } }\n }\n }\n}\n\n/** Define input parameters for invoking a hub tool with user ID, tool name, and optional arguments */\nexport interface HubInvokeInput {\n userId: string\n /** The MCP tool name the agent called (`int_<provider>_<connector>_<action>`). */\n toolName: string\n args?: Record<string, unknown>\n}\n/** Describe the outcome of a hub invocation including status and response body */\nexport interface HubInvokeOutcome {\n status: number\n body: Record<string, unknown>\n}\n/** Define dependencies for invoking hub operations including API key resolution and optional configuration */\nexport interface HubInvokeDeps {\n /** Resolve the user's Tangle API key (the hub principal bearer). Required —\n * the product binds its own session-key resolver. Null → user not linked. */\n apiKeyResolver: (userId: string) => Promise<string | null>\n /** Platform base URL. Defaults to `env.TANGLE_PLATFORM_URL`. */\n baseUrl?: string\n fetchImpl?: typeof fetch\n env?: Record<string, string | undefined>\n}\n\n/**\n * Resolve + execute one integration tool call through the hub: resolve the\n * per-user bearer, map the MCP tool name to the hub action path, forward to\n * `/v1/hub/exec`, and shape the route response (200 ok / 401 not-linked /\n * 400 unknown-tool / 409 approval-required / 502 hub-error). A write that's\n * approval-gated surfaces verbatim as 409, never silently executed.\n */\nexport async function invokeIntegrationHub(input: HubInvokeInput, deps: HubInvokeDeps): Promise<HubInvokeOutcome> {\n const env = deps.env ?? (process.env as Record<string, string | undefined>)\n const baseUrl = deps.baseUrl ?? env.TANGLE_PLATFORM_URL?.trim()\n if (!baseUrl) return { status: 500, body: { error: 'TANGLE_PLATFORM_URL is not configured' } }\n\n const action = resolveIntegrationAction(input.toolName)\n if (!action) return { status: 400, body: { error: `Unsupported integration tool: ${input.toolName}` } }\n\n const bearer = await deps.apiKeyResolver(input.userId)\n if (!bearer) return { status: 401, body: { error: 'Tangle account not linked — connect integrations from the app first' } }\n\n const client = new HubExecClient({ baseUrl, bearer, fetchImpl: deps.fetchImpl })\n const outcome = await client.exec({ path: action.path, actionInput: input.args ?? {} })\n\n if (outcome.succeeded) {\n return { status: 200, body: { success: true, path: action.path, providerId: action.providerId, action: action.actionId, result: outcome.result } }\n }\n const status = outcome.code === 'HUB_APPROVAL_REQUIRED' ? 409 : 502\n return {\n status,\n body: { success: false, path: action.path, code: outcome.code, error: outcome.message, ...(outcome.approval ? { approval: outcome.approval } : {}) },\n }\n}\n"],"mappings":";AA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