@algolia/wizard 0.20.0 → 0.21.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/dist/main.js +25 -13
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -3263,10 +3263,18 @@ var RECORD_MODEL = "claude-haiku-4-5";
|
|
|
3263
3263
|
var MAX_RECORDS = 100;
|
|
3264
3264
|
var BATCH_SIZE = 10;
|
|
3265
3265
|
var MAX_BATCH_ATTEMPTS = 3;
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3266
|
+
function defaultCreateModel() {
|
|
3267
|
+
const token = getAuthToken();
|
|
3268
|
+
if (!token) {
|
|
3269
|
+
throw new Error("Not authenticated: no user token available");
|
|
3270
|
+
}
|
|
3271
|
+
return createAnthropic({
|
|
3272
|
+
apiKey: token,
|
|
3273
|
+
baseURL: PROXY_BASE_URL,
|
|
3274
|
+
fetch: proxyFetch
|
|
3275
|
+
});
|
|
3276
|
+
}
|
|
3277
|
+
function generateRecordTool(ctx, createModel = defaultCreateModel) {
|
|
3270
3278
|
return tool10({
|
|
3271
3279
|
description: "Generate realistic sample records for an entity and write them to a JSON file in the worktree. Provide the entity name and its attributes; this tool asks a model to invent varied, realistic values, each with a unique objectID, and returns the file path to read them from at runtime. Do not invent the record values or objectIDs yourself, and do not inline the returned records into the script \u2014 call this tool and read the file it writes.",
|
|
3272
3280
|
inputSchema: z17.object({
|
|
@@ -3278,6 +3286,7 @@ function generateRecordTool(ctx) {
|
|
|
3278
3286
|
execute: async ({ entityName, attributes, count, hint }) => {
|
|
3279
3287
|
logger.info({ entityName, count }, "called generateRecord tool");
|
|
3280
3288
|
try {
|
|
3289
|
+
const anthropic = createModel();
|
|
3281
3290
|
const value = z17.union([z17.string(), z17.number(), z17.boolean(), z17.null()]);
|
|
3282
3291
|
const recordSchema = z17.object(
|
|
3283
3292
|
Object.fromEntries(attributes.map((attr) => [attr, value]))
|
|
@@ -3296,10 +3305,6 @@ function generateRecordTool(ctx) {
|
|
|
3296
3305
|
prompt: [
|
|
3297
3306
|
`Generate ${batchCount} realistic, varied sample records for the "${entityName}" entity.`,
|
|
3298
3307
|
hint ? `Context: ${hint}` : "",
|
|
3299
|
-
// Batches run concurrently with identical prompts, so each call
|
|
3300
|
-
// would otherwise drift to the same high-probability values and
|
|
3301
|
-
// collide across batches. This per-batch seed pushes each call
|
|
3302
|
-
// into a different region of the output space.
|
|
3303
3308
|
`Variety seed: ${nanoid2()}. Use it to diversify values.`
|
|
3304
3309
|
].filter(Boolean).join("\n")
|
|
3305
3310
|
});
|
|
@@ -3332,8 +3337,15 @@ function generateRecordTool(ctx) {
|
|
|
3332
3337
|
return `Refused: ${resolved2.target} is outside the repo root (${ctx.root}).`;
|
|
3333
3338
|
}
|
|
3334
3339
|
await mkdir5(dirname6(resolved2.target), { recursive: true });
|
|
3335
|
-
await writeFile6(
|
|
3336
|
-
|
|
3340
|
+
await writeFile6(
|
|
3341
|
+
resolved2.target,
|
|
3342
|
+
JSON.stringify(records, null, 2),
|
|
3343
|
+
"utf8"
|
|
3344
|
+
);
|
|
3345
|
+
logger.info(
|
|
3346
|
+
{ entityName, count: records.length, relPath },
|
|
3347
|
+
"generateRecord wrote records to disk"
|
|
3348
|
+
);
|
|
3337
3349
|
return {
|
|
3338
3350
|
filePath: relPath,
|
|
3339
3351
|
count: records.length,
|
|
@@ -3427,7 +3439,7 @@ async function runAgent(req) {
|
|
|
3427
3439
|
if (!token) {
|
|
3428
3440
|
throw new Error("Not authenticated: no user token available");
|
|
3429
3441
|
}
|
|
3430
|
-
const
|
|
3442
|
+
const anthropic = createAnthropic2({
|
|
3431
3443
|
apiKey: token,
|
|
3432
3444
|
baseURL: PROXY_BASE_URL,
|
|
3433
3445
|
fetch: proxyFetch
|
|
@@ -3443,7 +3455,7 @@ async function runAgent(req) {
|
|
|
3443
3455
|
"Call notifyUser whenever you start a new phase of work or your focus shifts (e.g. moving from reading code to writing files) \u2014 a short, plain-language, high-level update. Do not call it for every tool use."
|
|
3444
3456
|
];
|
|
3445
3457
|
const agent = new ToolLoopAgent({
|
|
3446
|
-
model:
|
|
3458
|
+
model: anthropic(MODEL_BY_SIZE[req.modelSize ?? "medium"]),
|
|
3447
3459
|
// Cache tools + system on the last system block. Tools render before
|
|
3448
3460
|
// system, so one breakpoint here caches both, reused on every loop turn
|
|
3449
3461
|
// after the first.
|
|
@@ -3630,7 +3642,7 @@ async function runAnalysis(mode, extraInstructions = []) {
|
|
|
3630
3642
|
// package.json
|
|
3631
3643
|
var package_default = {
|
|
3632
3644
|
name: "@algolia/wizard",
|
|
3633
|
-
version: "0.
|
|
3645
|
+
version: "0.21.0",
|
|
3634
3646
|
description: "Magically implement Algolia functionality in your codebase",
|
|
3635
3647
|
type: "module",
|
|
3636
3648
|
engines: {
|