@uniformdev/mesh-edgehancer-sdk 20.31.1-alpha.1 → 20.31.1-alpha.184
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/dist/index.d.mts +1028 -135
- package/dist/index.d.ts +1028 -135
- package/dist/index.esm.js +252 -74
- package/dist/index.js +267 -71
- package/dist/index.mjs +252 -74
- package/package.json +4 -4
package/dist/index.esm.js
CHANGED
@@ -1,3 +1,123 @@
|
|
1
|
+
// ../../lib/ai-sdk/src/InvocationContexts.ts
|
2
|
+
import * as z from "zod";
|
3
|
+
var invocationContextsSchema = z.enum([
|
4
|
+
"composition",
|
5
|
+
"compositionPattern",
|
6
|
+
"componentPattern",
|
7
|
+
"entry",
|
8
|
+
"entryPattern",
|
9
|
+
"general"
|
10
|
+
]);
|
11
|
+
var invocationContextInfoSchema = z.object({
|
12
|
+
context: invocationContextsSchema,
|
13
|
+
id: z.string(),
|
14
|
+
displayName: z.string().optional(),
|
15
|
+
icon: z.string().optional()
|
16
|
+
});
|
17
|
+
var invocationContextAnnotationSchema = z.object({
|
18
|
+
type: z.literal("invocationContext"),
|
19
|
+
value: invocationContextInfoSchema
|
20
|
+
});
|
21
|
+
|
22
|
+
// src/afterAIDataResourceEdit.ts
|
23
|
+
import * as z2 from "zod";
|
24
|
+
var afterAIDataResourceEditResultSchema = z2.strictObject({
|
25
|
+
newValue: z2.record(z2.string(), z2.string()),
|
26
|
+
success: z2.boolean(),
|
27
|
+
summary: z2.string().optional()
|
28
|
+
});
|
29
|
+
var afterAIDataResourceEditContextSchema = z2.strictObject({
|
30
|
+
/**
|
31
|
+
* The the data type of the data resource being edited (merged with its data source)
|
32
|
+
* NOTE: this can contain secrets, API keys, etc. Do not directly expose it to the AI agent!
|
33
|
+
* NOTE: this does not include the current value's variables, if any
|
34
|
+
*/
|
35
|
+
mergedDataType: z2.custom(),
|
36
|
+
/** Which data source variant is currently active (undefined = published data) */
|
37
|
+
dataSourceVariant: z2.custom().optional(),
|
38
|
+
/** The edit request details */
|
39
|
+
editRequest: z2.object({
|
40
|
+
/** The edit instruction from the AI agent */
|
41
|
+
edit: z2.string(),
|
42
|
+
/** Current value of the data resource's variables (if any) */
|
43
|
+
currentValue: z2.record(z2.string(), z2.string()).optional()
|
44
|
+
}),
|
45
|
+
/** AI invocation context */
|
46
|
+
invocationContext: invocationContextsSchema,
|
47
|
+
/** User ID making the edit */
|
48
|
+
userId: z2.string(),
|
49
|
+
/** Project ID */
|
50
|
+
projectId: z2.string(),
|
51
|
+
/** The new value generated by AI */
|
52
|
+
newValue: z2.record(z2.string(), z2.string()),
|
53
|
+
/** The result from the AI editing process */
|
54
|
+
result: z2.object({
|
55
|
+
success: z2.boolean(),
|
56
|
+
summary: z2.string().optional()
|
57
|
+
})
|
58
|
+
});
|
59
|
+
|
60
|
+
// ../../lib/ai-sdk/src/toolDefinitions/editing/createPropertyEdit.ts
|
61
|
+
import * as z3 from "zod";
|
62
|
+
var createPropertyEdit = {
|
63
|
+
displayName: "Create Property Edit",
|
64
|
+
description: "Edits a property on a composition, entry, or pattern with AI. This is a callable tool NOT FOR AGENT USE - agents use applyPropertyEdit to broker client-side application of the edit.",
|
65
|
+
inputSchema: z3.object({
|
66
|
+
edit: z3.string().describe("Describe the edit to be made to the property"),
|
67
|
+
currentValue: z3.unknown().describe("Current value of the property (if any exists)").optional(),
|
68
|
+
projectGuidance: z3.string().describe("Guidance prompt for the project (if any exists)").optional(),
|
69
|
+
componentGuidance: z3.string().describe("Guidance prompt for the parent component").optional(),
|
70
|
+
audienceGuidance: z3.string().describe(
|
71
|
+
"Guidance prompt for the target audience of a personalized variation. Omit for non-variation edits."
|
72
|
+
).optional(),
|
73
|
+
propertyDefinition: z3.object({
|
74
|
+
id: z3.string(),
|
75
|
+
name: z3.string(),
|
76
|
+
type: z3.string(),
|
77
|
+
guidance: z3.string().describe("Guidance prompt from the property definition (if any exists)").optional(),
|
78
|
+
typeConfig: z3.unknown().optional().describe("Type-specific configuration for the property")
|
79
|
+
}),
|
80
|
+
outputLocale: z3.string().optional().describe("The locale to use when writing the edited value"),
|
81
|
+
documentContext: z3.string().describe("Content of the surrounding document the property is part of").optional()
|
82
|
+
}),
|
83
|
+
outputSchema: z3.object({
|
84
|
+
newValue: z3.string().describe(
|
85
|
+
"The new value of the property. When the action is clear or resetOverride, this should be empty."
|
86
|
+
),
|
87
|
+
treatNewValueAsJson: z3.boolean().describe("Whether the newValue is a JSON string"),
|
88
|
+
summary: z3.string().describe(
|
89
|
+
"A completion message to the user that summarizes the action taken. This should be 1 sentence, in English."
|
90
|
+
).optional(),
|
91
|
+
action: z3.enum(["setValue", "clearValue", "resetOverride"]).describe(
|
92
|
+
"setValue = update the value, clearValue = remove the value/set to empty, resetOverride = remove a pattern override and inherit the pattern value. Only use resetOverride if the prompt asks for it."
|
93
|
+
),
|
94
|
+
success: z3.boolean().describe("Whether the edit could be completed successfully")
|
95
|
+
}),
|
96
|
+
runsAt: "server",
|
97
|
+
timeout: 100,
|
98
|
+
callable: true
|
99
|
+
};
|
100
|
+
|
101
|
+
// src/afterAIEdit.ts
|
102
|
+
import * as z4 from "zod";
|
103
|
+
var afterAIEditResultSchema = z4.strictObject({
|
104
|
+
newValue: z4.unknown(),
|
105
|
+
success: z4.boolean(),
|
106
|
+
summary: z4.string().optional()
|
107
|
+
});
|
108
|
+
var afterAIEditContextSchema = z4.strictObject({
|
109
|
+
editRequest: createPropertyEdit.inputSchema,
|
110
|
+
invocationContext: invocationContextsSchema,
|
111
|
+
userId: z4.string(),
|
112
|
+
currentLocale: z4.string().optional(),
|
113
|
+
projectId: z4.string(),
|
114
|
+
newValue: z4.unknown(),
|
115
|
+
result: z4.object({
|
116
|
+
success: z4.boolean(),
|
117
|
+
summary: z4.string().optional()
|
118
|
+
})
|
119
|
+
});
|
120
|
+
|
1
121
|
// src/batchUtils.ts
|
2
122
|
function convertBatchResultsToEdgehancerResult({
|
3
123
|
batch,
|
@@ -57,6 +177,54 @@ var COLLECTION_DEFAULT_LIMIT = 20;
|
|
57
177
|
var COLLECTION_MAX_LIMIT = 50;
|
58
178
|
var COLLECTION_DEFAULT_OFFSET = 0;
|
59
179
|
|
180
|
+
// src/createAIDataResourceEdit.ts
|
181
|
+
import * as z5 from "zod";
|
182
|
+
var createAIDataResourceEditContextSchema = z5.strictObject({
|
183
|
+
/**
|
184
|
+
* The the data type of the data resource being edited (merged with its data source)
|
185
|
+
* NOTE: this can contain secrets, API keys, etc. Do not directly expose it to the AI agent!
|
186
|
+
* NOTE: this does not include the current value's variables, if any
|
187
|
+
*/
|
188
|
+
mergedDataType: z5.custom(),
|
189
|
+
/** Which data source variant is currently active (undefined = published data) */
|
190
|
+
dataSourceVariant: z5.custom().optional(),
|
191
|
+
/** The edit request details */
|
192
|
+
editRequest: z5.object({
|
193
|
+
/** The edit instruction from the AI agent */
|
194
|
+
edit: z5.string(),
|
195
|
+
/** Current value of the data resource's variables (if any) */
|
196
|
+
currentValue: z5.record(z5.string(), z5.string()).optional()
|
197
|
+
}),
|
198
|
+
/** AI invocation context */
|
199
|
+
invocationContext: invocationContextsSchema,
|
200
|
+
/** User ID making the edit */
|
201
|
+
userId: z5.string(),
|
202
|
+
/** Project ID */
|
203
|
+
projectId: z5.string()
|
204
|
+
});
|
205
|
+
var createAIDataResourceEditResultSchema = z5.strictObject({
|
206
|
+
outputJsonSchema: z5.record(z5.string(), z5.any()).describe("JSON schema (draft-07) for the edited data resource result"),
|
207
|
+
instructions: z5.string().describe(
|
208
|
+
"Instructions for the AI editor LLM to follow when editing this data resource (e.g. conventions/rules, allowed values, data format expectations, etc). Describe how to transform or edit the data resource content."
|
209
|
+
)
|
210
|
+
});
|
211
|
+
|
212
|
+
// src/createAIEdit.ts
|
213
|
+
import * as z6 from "zod";
|
214
|
+
var createAIEditContextSchema = z6.strictObject({
|
215
|
+
editRequest: createPropertyEdit.inputSchema,
|
216
|
+
invocationContext: invocationContextsSchema,
|
217
|
+
userId: z6.string(),
|
218
|
+
currentLocale: z6.string().optional(),
|
219
|
+
projectId: z6.string()
|
220
|
+
});
|
221
|
+
var createAIEditResultSchema = z6.strictObject({
|
222
|
+
outputJsonSchema: z6.record(z6.string(), z6.any()).describe("JSON schema (draft-07) for the edited content result"),
|
223
|
+
instructions: z6.string().describe(
|
224
|
+
"Instructions for the AI editor LLM to follow (e.g. conventions/rules, allowed values, etc). Just describe your value type, do not give guiding instructions. There is no need to worry about clearing or resetting values, that is automatically handled."
|
225
|
+
)
|
226
|
+
});
|
227
|
+
|
60
228
|
// src/fetchUtils.ts
|
61
229
|
function getDataResourceAsRequest(data) {
|
62
230
|
var _a;
|
@@ -96,78 +264,80 @@ function copyKeyValuePairs(source, target) {
|
|
96
264
|
}
|
97
265
|
|
98
266
|
// src/preRequest.ts
|
99
|
-
import
|
267
|
+
import * as z8 from "zod";
|
100
268
|
|
101
269
|
// src/shared.ts
|
102
270
|
import { assert } from "tsafe";
|
103
|
-
import
|
104
|
-
var parameterDefinitionSchema =
|
105
|
-
key:
|
106
|
-
value:
|
107
|
-
omitIfEmpty:
|
108
|
-
});
|
109
|
-
var resolvingIssueSchema =
|
110
|
-
|
111
|
-
|
112
|
-
message:
|
113
|
-
subType:
|
114
|
-
issueReference:
|
115
|
-
deepLink:
|
271
|
+
import * as z7 from "zod";
|
272
|
+
var parameterDefinitionSchema = z7.object({
|
273
|
+
key: z7.string(),
|
274
|
+
value: z7.string(),
|
275
|
+
omitIfEmpty: z7.boolean().optional()
|
276
|
+
});
|
277
|
+
var resolvingIssueSchema = z7.union([
|
278
|
+
z7.string(),
|
279
|
+
z7.object({
|
280
|
+
message: z7.string(),
|
281
|
+
subType: z7.enum(["unpublishedData", "configuration"]).optional(),
|
282
|
+
issueReference: z7.string().optional(),
|
283
|
+
deepLink: z7.string().optional()
|
116
284
|
})
|
117
285
|
]);
|
118
|
-
var variableDefinitionSchema =
|
119
|
-
displayName:
|
120
|
-
type:
|
121
|
-
default:
|
122
|
-
helpText:
|
123
|
-
order:
|
124
|
-
source:
|
125
|
-
});
|
126
|
-
var customEdgehancerDefinitionSchema =
|
127
|
-
preRequest:
|
128
|
-
request:
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
286
|
+
var variableDefinitionSchema = z7.object({
|
287
|
+
displayName: z7.string().optional(),
|
288
|
+
type: z7.string().optional(),
|
289
|
+
default: z7.string(),
|
290
|
+
helpText: z7.string().optional(),
|
291
|
+
order: z7.number().optional(),
|
292
|
+
source: z7.string().optional()
|
293
|
+
});
|
294
|
+
var customEdgehancerDefinitionSchema = z7.object({
|
295
|
+
preRequest: z7.string().optional(),
|
296
|
+
request: z7.string().optional(),
|
297
|
+
createAIDataResourceEdit: z7.string().optional(),
|
298
|
+
afterAIDataResourceEdit: z7.string().optional()
|
299
|
+
});
|
300
|
+
var dataSourceVariantSchema = z7.intersection(
|
301
|
+
z7.object({
|
302
|
+
headers: z7.array(parameterDefinitionSchema).optional(),
|
303
|
+
parameters: z7.array(parameterDefinitionSchema).optional(),
|
304
|
+
variables: z7.record(variableDefinitionSchema).optional()
|
135
305
|
}),
|
136
|
-
|
306
|
+
z7.object({ url: z7.string() })
|
137
307
|
);
|
138
|
-
var mergedDataTypeSchema =
|
139
|
-
id:
|
140
|
-
displayName:
|
141
|
-
archetype:
|
142
|
-
allowedOnComponents:
|
143
|
-
badgeIconUrl:
|
144
|
-
connectorType:
|
145
|
-
url:
|
146
|
-
headers:
|
147
|
-
parameters:
|
148
|
-
body:
|
149
|
-
method:
|
150
|
-
variables:
|
151
|
-
custom:
|
152
|
-
customPublic:
|
153
|
-
ttl:
|
154
|
-
purgeKey:
|
155
|
-
localeMapping:
|
308
|
+
var mergedDataTypeSchema = z7.object({
|
309
|
+
id: z7.string(),
|
310
|
+
displayName: z7.string(),
|
311
|
+
archetype: z7.string().optional(),
|
312
|
+
allowedOnComponents: z7.array(z7.string()).optional(),
|
313
|
+
badgeIconUrl: z7.string().optional(),
|
314
|
+
connectorType: z7.string(),
|
315
|
+
url: z7.string(),
|
316
|
+
headers: z7.array(parameterDefinitionSchema).optional(),
|
317
|
+
parameters: z7.array(parameterDefinitionSchema).optional(),
|
318
|
+
body: z7.string().optional(),
|
319
|
+
method: z7.enum(["GET", "POST", "HEAD"]),
|
320
|
+
variables: z7.record(variableDefinitionSchema).optional(),
|
321
|
+
custom: z7.record(z7.unknown()).optional(),
|
322
|
+
customPublic: z7.record(z7.unknown()).optional(),
|
323
|
+
ttl: z7.number().optional(),
|
324
|
+
purgeKey: z7.string().optional(),
|
325
|
+
localeMapping: z7.record(z7.string()).optional(),
|
156
326
|
edgehancer: customEdgehancerDefinitionSchema.optional(),
|
157
|
-
uiBadgeText:
|
158
|
-
variants:
|
327
|
+
uiBadgeText: z7.string().max(12).optional(),
|
328
|
+
variants: z7.object({
|
159
329
|
unpublished: dataSourceVariantSchema.optional()
|
160
330
|
}).optional(),
|
161
|
-
enableUnpublishedMode:
|
331
|
+
enableUnpublishedMode: z7.boolean().optional()
|
162
332
|
});
|
163
333
|
assert();
|
164
|
-
var dataResourceSchema =
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
334
|
+
var dataResourceSchema = z7.union([
|
335
|
+
z7.string(),
|
336
|
+
z7.object({}).catchall(z7.unknown()),
|
337
|
+
z7.number(),
|
338
|
+
z7.boolean(),
|
339
|
+
z7.array(z7.unknown()),
|
340
|
+
z7.undefined()
|
171
341
|
]);
|
172
342
|
|
173
343
|
// src/preRequest.ts
|
@@ -180,39 +350,47 @@ var edgehancerMergedDataTypeSchema = mergedDataTypeSchema.omit({
|
|
180
350
|
purgeKey: true,
|
181
351
|
variables: true
|
182
352
|
});
|
183
|
-
var preRequestEdgehancerDataResourceResultSchema =
|
184
|
-
errors:
|
185
|
-
warnings:
|
186
|
-
infos:
|
353
|
+
var preRequestEdgehancerDataResourceResultSchema = z8.strictObject({
|
354
|
+
errors: z8.array(resolvingIssueSchema).optional(),
|
355
|
+
warnings: z8.array(resolvingIssueSchema).optional(),
|
356
|
+
infos: z8.array(resolvingIssueSchema).optional(),
|
187
357
|
dataResource: edgehancerMergedDataTypeSchema
|
188
358
|
});
|
189
|
-
var preRequestEdgehancerResultSchema =
|
190
|
-
dataResources:
|
359
|
+
var preRequestEdgehancerResultSchema = z8.strictObject({
|
360
|
+
dataResources: z8.array(preRequestEdgehancerDataResourceResultSchema)
|
191
361
|
});
|
192
362
|
|
193
363
|
// src/request.ts
|
194
|
-
import
|
195
|
-
var requestEdgehancerDataResourceResolutionResultSchema =
|
196
|
-
errors:
|
364
|
+
import * as z9 from "zod";
|
365
|
+
var requestEdgehancerDataResourceResolutionResultSchema = z9.strictObject({
|
366
|
+
errors: z9.array(resolvingIssueSchema).optional().describe(
|
197
367
|
"Errors that occurred while running your code to return with the API response, if any. Unhandled exceptions will be captured automatically."
|
198
368
|
),
|
199
|
-
warnings:
|
200
|
-
infos:
|
369
|
+
warnings: z9.array(resolvingIssueSchema).optional().describe("Warnings that occurred while running your code to return with the API response, if any."),
|
370
|
+
infos: z9.array(resolvingIssueSchema).optional().describe(
|
201
371
|
"Informational messages that occurred while running your code to return with the API response, if any."
|
202
372
|
),
|
203
|
-
surrogateKeys:
|
373
|
+
surrogateKeys: z9.array(z9.string()).optional().describe(
|
204
374
|
"Extra surrogate keys for the data that was fetched. These act as auxiliary cache keys that can allow granular purging of cached data."
|
205
375
|
),
|
206
376
|
result: dataResourceSchema.describe("The result of fetching the data resource")
|
207
377
|
});
|
208
|
-
var requestEdgehancerResultSchema =
|
209
|
-
results:
|
378
|
+
var requestEdgehancerResultSchema = z9.strictObject({
|
379
|
+
results: z9.array(requestEdgehancerDataResourceResolutionResultSchema)
|
210
380
|
});
|
211
381
|
export {
|
212
382
|
COLLECTION_DEFAULT_LIMIT,
|
213
383
|
COLLECTION_DEFAULT_OFFSET,
|
214
384
|
COLLECTION_MAX_LIMIT,
|
385
|
+
afterAIDataResourceEditContextSchema,
|
386
|
+
afterAIDataResourceEditResultSchema,
|
387
|
+
afterAIEditContextSchema,
|
388
|
+
afterAIEditResultSchema,
|
215
389
|
convertBatchResultsToEdgehancerResult,
|
390
|
+
createAIDataResourceEditContextSchema,
|
391
|
+
createAIDataResourceEditResultSchema,
|
392
|
+
createAIEditContextSchema,
|
393
|
+
createAIEditResultSchema,
|
216
394
|
dataResourceSchema,
|
217
395
|
edgehancerMergedDataTypeSchema,
|
218
396
|
getDataResourceAsRequest,
|