@ancha-labs/cli 0.4.53 → 0.4.54
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/lib/ancha.mjs +615 -697
- package/lib/assets/docs/cloud.md +4 -2
- package/lib/worker.mjs +19 -4
- package/package.json +1 -1
package/lib/ancha.mjs
CHANGED
|
@@ -3703,10 +3703,10 @@ function getElementAtPath(obj, path9) {
|
|
|
3703
3703
|
function promiseAllObject(promisesObj) {
|
|
3704
3704
|
const keys7 = Object.keys(promisesObj);
|
|
3705
3705
|
const promises = keys7.map((key5) => promisesObj[key5]);
|
|
3706
|
-
return Promise.all(promises).then((
|
|
3706
|
+
return Promise.all(promises).then((results2) => {
|
|
3707
3707
|
const resolvedObj = {};
|
|
3708
3708
|
for (let i = 0; i < keys7.length; i++) {
|
|
3709
|
-
resolvedObj[keys7[i]] =
|
|
3709
|
+
resolvedObj[keys7[i]] = results2[i];
|
|
3710
3710
|
}
|
|
3711
3711
|
return resolvedObj;
|
|
3712
3712
|
});
|
|
@@ -5833,14 +5833,14 @@ function handleCatchall(proms, input5, payload3, ctx, def, inst, abortEarly) {
|
|
|
5833
5833
|
return payload3;
|
|
5834
5834
|
});
|
|
5835
5835
|
}
|
|
5836
|
-
function handleUnionResults(
|
|
5837
|
-
for (const result of
|
|
5836
|
+
function handleUnionResults(results2, final, inst, ctx) {
|
|
5837
|
+
for (const result of results2) {
|
|
5838
5838
|
if (result.issues.length === 0) {
|
|
5839
5839
|
final.value = result.value;
|
|
5840
5840
|
return final;
|
|
5841
5841
|
}
|
|
5842
5842
|
}
|
|
5843
|
-
const nonaborted =
|
|
5843
|
+
const nonaborted = results2.filter((r2) => !aborted(r2));
|
|
5844
5844
|
if (nonaborted.length === 1) {
|
|
5845
5845
|
final.value = nonaborted[0].value;
|
|
5846
5846
|
return nonaborted[0];
|
|
@@ -5849,18 +5849,18 @@ function handleUnionResults(results, final, inst, ctx) {
|
|
|
5849
5849
|
code: "invalid_union",
|
|
5850
5850
|
input: final.value,
|
|
5851
5851
|
inst,
|
|
5852
|
-
errors:
|
|
5852
|
+
errors: results2.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
5853
5853
|
});
|
|
5854
5854
|
return final;
|
|
5855
5855
|
}
|
|
5856
|
-
function handleExclusiveUnionResults(
|
|
5856
|
+
function handleExclusiveUnionResults(results2, final, inst, ctx) {
|
|
5857
5857
|
const matches11 = [];
|
|
5858
|
-
for (let i = 0; i <
|
|
5859
|
-
if (
|
|
5858
|
+
for (let i = 0; i < results2.length; i++) {
|
|
5859
|
+
if (results2[i].issues.length === 0)
|
|
5860
5860
|
matches11.push(i);
|
|
5861
5861
|
}
|
|
5862
5862
|
if (matches11.length === 1) {
|
|
5863
|
-
final.value =
|
|
5863
|
+
final.value = results2[matches11[0]].value;
|
|
5864
5864
|
return final;
|
|
5865
5865
|
}
|
|
5866
5866
|
if (matches11.length === 0) {
|
|
@@ -5868,7 +5868,7 @@ function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
|
5868
5868
|
code: "invalid_union",
|
|
5869
5869
|
input: final.value,
|
|
5870
5870
|
inst,
|
|
5871
|
-
errors:
|
|
5871
|
+
errors: results2.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
5872
5872
|
});
|
|
5873
5873
|
} else {
|
|
5874
5874
|
final.issues.push({
|
|
@@ -7105,25 +7105,25 @@ var init_schemas = __esm({
|
|
|
7105
7105
|
return first2(payload3, ctx);
|
|
7106
7106
|
}
|
|
7107
7107
|
let async = false;
|
|
7108
|
-
const
|
|
7108
|
+
const results2 = [];
|
|
7109
7109
|
for (const option4 of def.options) {
|
|
7110
7110
|
const result = option4._zod.run({
|
|
7111
7111
|
value: payload3.value,
|
|
7112
7112
|
issues: []
|
|
7113
7113
|
}, ctx);
|
|
7114
7114
|
if (result instanceof Promise) {
|
|
7115
|
-
|
|
7115
|
+
results2.push(result);
|
|
7116
7116
|
async = true;
|
|
7117
7117
|
} else {
|
|
7118
7118
|
if (result.issues.length === 0)
|
|
7119
7119
|
return result;
|
|
7120
|
-
|
|
7120
|
+
results2.push(result);
|
|
7121
7121
|
}
|
|
7122
7122
|
}
|
|
7123
7123
|
if (!async)
|
|
7124
|
-
return handleUnionResults(results, payload3, inst, ctx);
|
|
7125
|
-
return Promise.all(results).then((results2) => {
|
|
7126
7124
|
return handleUnionResults(results2, payload3, inst, ctx);
|
|
7125
|
+
return Promise.all(results2).then((results3) => {
|
|
7126
|
+
return handleUnionResults(results3, payload3, inst, ctx);
|
|
7127
7127
|
});
|
|
7128
7128
|
};
|
|
7129
7129
|
});
|
|
@@ -7136,23 +7136,23 @@ var init_schemas = __esm({
|
|
|
7136
7136
|
return first2(payload3, ctx);
|
|
7137
7137
|
}
|
|
7138
7138
|
let async = false;
|
|
7139
|
-
const
|
|
7139
|
+
const results2 = [];
|
|
7140
7140
|
for (const option4 of def.options) {
|
|
7141
7141
|
const result = option4._zod.run({
|
|
7142
7142
|
value: payload3.value,
|
|
7143
7143
|
issues: []
|
|
7144
7144
|
}, ctx);
|
|
7145
7145
|
if (result instanceof Promise) {
|
|
7146
|
-
|
|
7146
|
+
results2.push(result);
|
|
7147
7147
|
async = true;
|
|
7148
7148
|
} else {
|
|
7149
|
-
|
|
7149
|
+
results2.push(result);
|
|
7150
7150
|
}
|
|
7151
7151
|
}
|
|
7152
7152
|
if (!async)
|
|
7153
|
-
return handleExclusiveUnionResults(results, payload3, inst, ctx);
|
|
7154
|
-
return Promise.all(results).then((results2) => {
|
|
7155
7153
|
return handleExclusiveUnionResults(results2, payload3, inst, ctx);
|
|
7154
|
+
return Promise.all(results2).then((results3) => {
|
|
7155
|
+
return handleExclusiveUnionResults(results3, payload3, inst, ctx);
|
|
7156
7156
|
});
|
|
7157
7157
|
};
|
|
7158
7158
|
});
|
|
@@ -27601,9 +27601,9 @@ var init_gong = __esm({
|
|
|
27601
27601
|
speakers.add(p2.speakerId);
|
|
27602
27602
|
}
|
|
27603
27603
|
if (p2.userId && users5.get(p2.userId)?.accountId !== w2?.accountId) issue9(["calls", i, "parties", j, "userId"], "participant user must belong to call account");
|
|
27604
|
-
if (p2.context.some((
|
|
27604
|
+
if (p2.context.some((link8) => link8.objects.some((o) => !["Contact", "User", "Lead"].includes(o.objectType)))) issue9(["calls", i, "parties", j, "context"], "participant context supports Contact, User and Lead");
|
|
27605
27605
|
});
|
|
27606
|
-
if (c.context.some((
|
|
27606
|
+
if (c.context.some((link8) => link8.objects.some((o) => !["Account", "Opportunity"].includes(o.objectType)))) issue9(["calls", i, "context"], "call context supports Account and Opportunity");
|
|
27607
27607
|
c.transcript?.forEach((monologue, j) => {
|
|
27608
27608
|
if (!speakers.has(monologue.speakerId)) issue9(["calls", i, "transcript", j, "speakerId"], "transcript speaker must identify a participant");
|
|
27609
27609
|
monologue.sentences.forEach((sentence, k) => {
|
|
@@ -35862,12 +35862,12 @@ var init_airtable = __esm({
|
|
|
35862
35862
|
if (back?.type !== "multipleRecordLinks" || lower5(back.table) !== lower5(entry3.name) || back.inverse !== item2.name) issue9([...path9, "inverse"], `${item2.inverse} in ${target6.name} is a link back to ${entry3.name} whose inverse is ${item2.name}`);
|
|
35863
35863
|
}
|
|
35864
35864
|
if (item2.type === "count" || item2.type === "multipleLookupValues" || item2.type === "rollup") {
|
|
35865
|
-
const
|
|
35866
|
-
if (
|
|
35865
|
+
const link8 = fields14.get(item2.link);
|
|
35866
|
+
if (link8?.type !== "multipleRecordLinks") {
|
|
35867
35867
|
issue9([...path9, "link"], `${item2.link} is not a link field in ${entry3.name}`);
|
|
35868
35868
|
return;
|
|
35869
35869
|
}
|
|
35870
|
-
if (item2.type !== "count" && !tables.get(lower5(
|
|
35870
|
+
if (item2.type !== "count" && !tables.get(lower5(link8.table))?.fields.some((other) => other.name === item2.field)) issue9([...path9, "field"], `${item2.field} is not a field in ${link8.table}`);
|
|
35871
35871
|
if (item2.type === "rollup") formula(item2.formula, [...path9, "formula"], ["values"], () => false);
|
|
35872
35872
|
}
|
|
35873
35873
|
if (item2.type === "formula") formula(item2.formula, [...path9, "formula"]);
|
|
@@ -38693,12 +38693,12 @@ function validateRefs(scene2) {
|
|
|
38693
38693
|
scene2.world_rules?.logs?.forEach((log3, i) => {
|
|
38694
38694
|
if (log3.while !== void 0) use(`world_rules.logs[${i}].while`, log3.while, "fault");
|
|
38695
38695
|
});
|
|
38696
|
-
scene2.world_rules?.integrations?.forEach((
|
|
38696
|
+
scene2.world_rules?.integrations?.forEach((link8, i) => {
|
|
38697
38697
|
const p2 = `world_rules.integrations[${i}]`;
|
|
38698
|
-
if ("kind" in
|
|
38699
|
-
const template3 = INTEGRATION_CATALOG.find((candidate) => candidate.id ===
|
|
38698
|
+
if ("kind" in link8) {
|
|
38699
|
+
const template3 = INTEGRATION_CATALOG.find((candidate) => candidate.id === link8.kind);
|
|
38700
38700
|
for (const [field6, [kind2, twin]] of Object.entries(template3?.refs ?? {})) {
|
|
38701
|
-
const value6 =
|
|
38701
|
+
const value6 = link8[field6];
|
|
38702
38702
|
if (typeof value6 === "string") use(`${p2}.${field6}`, value6, kind2, twin);
|
|
38703
38703
|
else if (Array.isArray(value6)) value6.forEach((item2, j) => {
|
|
38704
38704
|
if (typeof item2 === "string") use(`${p2}.${field6}[${j}]`, item2, kind2, twin);
|
|
@@ -38706,8 +38706,8 @@ function validateRefs(scene2) {
|
|
|
38706
38706
|
}
|
|
38707
38707
|
return;
|
|
38708
38708
|
}
|
|
38709
|
-
if ("service" in
|
|
38710
|
-
if ("channel" in
|
|
38709
|
+
if ("service" in link8) use(`${p2}.service`, link8.service, "service", "pagerduty");
|
|
38710
|
+
if ("channel" in link8 && link8.channel !== void 0) use(`${p2}.channel`, link8.channel, "channel", "slack");
|
|
38711
38711
|
});
|
|
38712
38712
|
scenePredicates(scene2, (predicate2, p2) => {
|
|
38713
38713
|
if ("production_contains" in predicate2) {
|
|
@@ -39174,10 +39174,10 @@ function worldIssues(scene2) {
|
|
|
39174
39174
|
issue9(p2, error65.message);
|
|
39175
39175
|
}
|
|
39176
39176
|
});
|
|
39177
|
-
rules?.integrations?.forEach((
|
|
39177
|
+
rules?.integrations?.forEach((link8, i) => {
|
|
39178
39178
|
const p2 = `world_rules.integrations[${i}]`;
|
|
39179
|
-
if ("kind" in
|
|
39180
|
-
const template3 = INTEGRATION_CATALOG.find((candidate) => candidate.id ===
|
|
39179
|
+
if ("kind" in link8) {
|
|
39180
|
+
const template3 = INTEGRATION_CATALOG.find((candidate) => candidate.id === link8.kind);
|
|
39181
39181
|
requireTwin(template3.from, `${p2}.kind`);
|
|
39182
39182
|
requireTwin(template3.to, `${p2}.kind`);
|
|
39183
39183
|
const agent = {
|
|
@@ -39185,20 +39185,20 @@ function worldIssues(scene2) {
|
|
|
39185
39185
|
github: scene2.seed.github?.bot !== void 0 ? name3(scene2.seed.github.bot) : void 0
|
|
39186
39186
|
};
|
|
39187
39187
|
for (const [field6, [kind2, twin]] of Object.entries(template3.refs)) {
|
|
39188
|
-
const value6 =
|
|
39188
|
+
const value6 = link8[field6];
|
|
39189
39189
|
if (kind2 === "user" && typeof value6 === "string" && agent[twin] !== void 0 && name3(value6) === agent[twin]) issue9(`${p2}.${field6}`, `${value6} is the agent's own account; an integration acts as a user of its own`);
|
|
39190
39190
|
}
|
|
39191
39191
|
return;
|
|
39192
39192
|
}
|
|
39193
|
-
requireTwin(
|
|
39194
|
-
requireTwin(
|
|
39195
|
-
if (
|
|
39196
|
-
const service = "service" in
|
|
39197
|
-
const handle31 =
|
|
39193
|
+
requireTwin(link8.from, `${p2}.from`);
|
|
39194
|
+
requireTwin(link8.to, `${p2}.to`);
|
|
39195
|
+
if (link8.from === "datadog") {
|
|
39196
|
+
const service = "service" in link8 ? pd?.services.find((s3) => s3.ref === name3(link8.service)) : void 0;
|
|
39197
|
+
const handle31 = link8.handle ?? (service ? `pagerduty-${service.name}` : void 0);
|
|
39198
39198
|
if (handle31 !== void 0 && (handle31.length < 1 || handle31.length > 256 || /[\s@]/u.test(handle31)))
|
|
39199
39199
|
issue9(`${p2}.handle`, "notification handle must be 1\u2013256 characters without whitespace or @; declare an explicit handle when the service name contains spaces");
|
|
39200
39200
|
}
|
|
39201
|
-
if (
|
|
39201
|
+
if (link8.from === "pagerduty" && link8.channel === void 0 && !pd?.services.find((s3) => s3.ref === name3(link8.service))?.slack_channel) issue9(`${p2}.channel`, "channel is required unless the service declares slack_channel");
|
|
39202
39202
|
});
|
|
39203
39203
|
const owners = new Map(scene2.seed.github?.repos.flatMap((r2) => r2.commits.map((c) => [c.ref, r2.ref])));
|
|
39204
39204
|
scenePredicates(scene2, (p2, path9) => {
|
|
@@ -47428,11 +47428,11 @@ function parseScene(input5) {
|
|
|
47428
47428
|
if (issues.length > 0) throw sceneError(issues);
|
|
47429
47429
|
const pd = scene2.seed.pagerduty;
|
|
47430
47430
|
if (pd && pd.default_service === void 0 && pd.services.length === 1) pd.default_service = `$${pd.services[0].ref}`;
|
|
47431
|
-
scene2.world_rules?.integrations?.forEach((
|
|
47432
|
-
if ("kind" in
|
|
47433
|
-
const service = pd?.services.find((s3) => s3.ref === refName5(
|
|
47434
|
-
if (
|
|
47435
|
-
if (
|
|
47431
|
+
scene2.world_rules?.integrations?.forEach((link8) => {
|
|
47432
|
+
if ("kind" in link8 || !("service" in link8)) return;
|
|
47433
|
+
const service = pd?.services.find((s3) => s3.ref === refName5(link8.service));
|
|
47434
|
+
if (link8.from === "datadog" && link8.handle === void 0 && service) link8.handle = `pagerduty-${service.name}`;
|
|
47435
|
+
if (link8.from === "pagerduty" && link8.channel === void 0 && service?.slack_channel !== void 0) link8.channel = service.slack_channel;
|
|
47436
47436
|
});
|
|
47437
47437
|
if (scene2.task === void 0 && scene2.trigger?.task !== void 0) scene2.task = scene2.trigger.task;
|
|
47438
47438
|
return { ...scene2, twins: scene2.twins.filter(isTwinName), pass: scene2.pass ?? scene2.checks.map((c) => c.id) };
|
|
@@ -51355,7 +51355,7 @@ var init_catalog2 = __esm({
|
|
|
51355
51355
|
// packages/core/src/tools/record-links.ts
|
|
51356
51356
|
function recordLinkIssues(seed44, links4) {
|
|
51357
51357
|
const errors3 = [];
|
|
51358
|
-
for (const
|
|
51358
|
+
for (const link8 of links4 ?? []) for (const end of [link8.from, link8.to]) {
|
|
51359
51359
|
if (seed44[end.tool] === void 0 || !toolSeedRecords(end.tool, seed44[end.tool]).some((record33) => record33.collection === end.collection && record33.id === end.id)) errors3.push(`record link references missing ${end.tool} ${end.collection}/${end.id}`);
|
|
51360
51360
|
}
|
|
51361
51361
|
return errors3;
|
|
@@ -52457,7 +52457,7 @@ function netsuiteMergeKinds(a, b) {
|
|
|
52457
52457
|
}
|
|
52458
52458
|
function netsuiteReferenceTarget(field6, value6, plain9) {
|
|
52459
52459
|
if (!isNetsuiteReference(value6)) return void 0;
|
|
52460
|
-
const hrefs = Array.isArray(value6.links) ? value6.links.map((
|
|
52460
|
+
const hrefs = Array.isArray(value6.links) ? value6.links.map((link8) => isObject2(link8) && typeof link8.href === "string" ? link8.href : "") : [];
|
|
52461
52461
|
for (const href2 of hrefs) {
|
|
52462
52462
|
const named5 = /\/record\/v1\/([A-Za-z][A-Za-z0-9_]*)\/(?:-?\d+|eid:[^/?#]*)(?:[/?#]|$)/.exec(href2)?.[1];
|
|
52463
52463
|
if (named5) return netsuiteRecordTypes.find((type) => type.toLowerCase() === named5.toLowerCase()) ?? plain9?.get(named5.toLowerCase()) ?? named5;
|
|
@@ -85388,7 +85388,7 @@ var require_execute = __commonJS({
|
|
|
85388
85388
|
function executeFieldsSerially(exeContext, parentType, sourceValue, path9, fields14) {
|
|
85389
85389
|
return (0, _promiseReduce.promiseReduce)(
|
|
85390
85390
|
fields14.entries(),
|
|
85391
|
-
(
|
|
85391
|
+
(results2, [responseName, fieldNodes]) => {
|
|
85392
85392
|
const fieldPath = (0, _Path.addPath)(path9, responseName, parentType.name);
|
|
85393
85393
|
const result = executeField(
|
|
85394
85394
|
exeContext,
|
|
@@ -85398,22 +85398,22 @@ var require_execute = __commonJS({
|
|
|
85398
85398
|
fieldPath
|
|
85399
85399
|
);
|
|
85400
85400
|
if (result === void 0) {
|
|
85401
|
-
return
|
|
85401
|
+
return results2;
|
|
85402
85402
|
}
|
|
85403
85403
|
if ((0, _isPromise.isPromise)(result)) {
|
|
85404
85404
|
return result.then((resolvedResult) => {
|
|
85405
|
-
|
|
85406
|
-
return
|
|
85405
|
+
results2[responseName] = resolvedResult;
|
|
85406
|
+
return results2;
|
|
85407
85407
|
});
|
|
85408
85408
|
}
|
|
85409
|
-
|
|
85410
|
-
return
|
|
85409
|
+
results2[responseName] = result;
|
|
85410
|
+
return results2;
|
|
85411
85411
|
},
|
|
85412
85412
|
/* @__PURE__ */ Object.create(null)
|
|
85413
85413
|
);
|
|
85414
85414
|
}
|
|
85415
85415
|
function executeFields(exeContext, parentType, sourceValue, path9, fields14) {
|
|
85416
|
-
const
|
|
85416
|
+
const results2 = /* @__PURE__ */ Object.create(null);
|
|
85417
85417
|
let containsPromise = false;
|
|
85418
85418
|
try {
|
|
85419
85419
|
for (const [responseName, fieldNodes] of fields14.entries()) {
|
|
@@ -85426,7 +85426,7 @@ var require_execute = __commonJS({
|
|
|
85426
85426
|
fieldPath
|
|
85427
85427
|
);
|
|
85428
85428
|
if (result !== void 0) {
|
|
85429
|
-
|
|
85429
|
+
results2[responseName] = result;
|
|
85430
85430
|
if ((0, _isPromise.isPromise)(result)) {
|
|
85431
85431
|
containsPromise = true;
|
|
85432
85432
|
}
|
|
@@ -85434,16 +85434,16 @@ var require_execute = __commonJS({
|
|
|
85434
85434
|
}
|
|
85435
85435
|
} catch (error65) {
|
|
85436
85436
|
if (containsPromise) {
|
|
85437
|
-
return (0, _promiseForObject.promiseForObject)(
|
|
85437
|
+
return (0, _promiseForObject.promiseForObject)(results2).finally(() => {
|
|
85438
85438
|
throw error65;
|
|
85439
85439
|
});
|
|
85440
85440
|
}
|
|
85441
85441
|
throw error65;
|
|
85442
85442
|
}
|
|
85443
85443
|
if (!containsPromise) {
|
|
85444
|
-
return
|
|
85444
|
+
return results2;
|
|
85445
85445
|
}
|
|
85446
|
-
return (0, _promiseForObject.promiseForObject)(
|
|
85446
|
+
return (0, _promiseForObject.promiseForObject)(results2);
|
|
85447
85447
|
}
|
|
85448
85448
|
function executeField(exeContext, parentType, source, fieldNodes, path9) {
|
|
85449
85449
|
var _fieldDef$resolve;
|
|
@@ -91557,21 +91557,21 @@ var init_url = __esm({
|
|
|
91557
91557
|
checkOptionalParameter = (path9) => {
|
|
91558
91558
|
if (path9.charCodeAt(path9.length - 1) !== 63 || !path9.includes(":")) return null;
|
|
91559
91559
|
const segments3 = path9.split("/");
|
|
91560
|
-
const
|
|
91560
|
+
const results2 = [];
|
|
91561
91561
|
let basePath = "";
|
|
91562
91562
|
segments3.forEach((segment2) => {
|
|
91563
91563
|
if (segment2 !== "" && !/\:/.test(segment2)) basePath += "/" + segment2;
|
|
91564
91564
|
else if (/\:/.test(segment2)) {
|
|
91565
91565
|
if (segment2.charCodeAt(segment2.length - 1) === 63) {
|
|
91566
|
-
if (
|
|
91567
|
-
else
|
|
91566
|
+
if (results2.length === 0 && basePath === "") results2.push("/");
|
|
91567
|
+
else results2.push(basePath);
|
|
91568
91568
|
const optionalSegment = segment2.slice(0, -1);
|
|
91569
91569
|
basePath += "/" + optionalSegment;
|
|
91570
|
-
|
|
91570
|
+
results2.push(basePath);
|
|
91571
91571
|
} else basePath += "/" + segment2;
|
|
91572
91572
|
}
|
|
91573
91573
|
});
|
|
91574
|
-
return
|
|
91574
|
+
return results2.filter((v, i, a) => a.indexOf(v) === i);
|
|
91575
91575
|
};
|
|
91576
91576
|
tryDecodeURIComponent = (str5) => str5.indexOf("%") !== -1 ? tryDecode(str5, decodeURIComponent_) : str5;
|
|
91577
91577
|
_decodeURI = (value6) => {
|
|
@@ -91598,7 +91598,7 @@ var init_url = __esm({
|
|
|
91598
91598
|
encoded = /[%+]/.test(url4);
|
|
91599
91599
|
if (!encoded) return;
|
|
91600
91600
|
}
|
|
91601
|
-
const
|
|
91601
|
+
const results2 = /* @__PURE__ */ Object.create(null);
|
|
91602
91602
|
encoded ??= /[%+]/.test(url4);
|
|
91603
91603
|
let keyIndex = url4.indexOf("?", 8);
|
|
91604
91604
|
while (keyIndex !== -1) {
|
|
@@ -91616,11 +91616,11 @@ var init_url = __esm({
|
|
|
91616
91616
|
if (encoded) value6 = _decodeURI(value6);
|
|
91617
91617
|
}
|
|
91618
91618
|
if (multiple) {
|
|
91619
|
-
if (!(
|
|
91620
|
-
|
|
91621
|
-
} else
|
|
91619
|
+
if (!(results2[name5] && Array.isArray(results2[name5]))) results2[name5] = [];
|
|
91620
|
+
results2[name5].push(value6);
|
|
91621
|
+
} else results2[name5] ??= value6;
|
|
91622
91622
|
}
|
|
91623
|
-
return key5 ?
|
|
91623
|
+
return key5 ? results2[key5] : results2;
|
|
91624
91624
|
};
|
|
91625
91625
|
getQueryParam = _getQueryParam;
|
|
91626
91626
|
getQueryParams = (url4, key5) => {
|
|
@@ -93585,8 +93585,8 @@ function sameShape(result, recorded2) {
|
|
|
93585
93585
|
}
|
|
93586
93586
|
async function simulate(model2, request2, signal) {
|
|
93587
93587
|
const recorded2 = (request2.tool?.recorded ?? []).map((o) => ({ args: o.args, at: o.at, ...o.error !== void 0 ? { error: o.error } : { result: o.result } }));
|
|
93588
|
-
const
|
|
93589
|
-
const known2 =
|
|
93588
|
+
const results2 = recorded2.filter((o) => "result" in o).map((o) => o.result);
|
|
93589
|
+
const known2 = results2.length ? results2 : (request2.tool?.examples ?? []).filter((o) => o.error === void 0 && o.result !== void 0).map((o) => o.result);
|
|
93590
93590
|
const text31 = known2.length > 0 && known2.every((r2) => typeof r2 === "string");
|
|
93591
93591
|
const aware = request2.tool?.schema !== void 0;
|
|
93592
93592
|
const errors3 = [...recorded2, ...request2.tool?.examples ?? []].flatMap((o) => "error" in o && o.error !== void 0 ? [o.error] : []).map((error65, i) => ({ ref: `error-${i}`, error: error65 }));
|
|
@@ -96598,13 +96598,13 @@ function issueToken(ctx, user9, type, address9, options5, send3) {
|
|
|
96598
96598
|
};
|
|
96599
96599
|
const field6 = fields14[type];
|
|
96600
96600
|
if (field6) query2(ctx, `update auth.users set "${field6[0]}" = $2, "${field6[1]}" = $3 where id = $1`, [user9.id, tokenHash, now11]);
|
|
96601
|
-
const
|
|
96602
|
-
|
|
96603
|
-
|
|
96604
|
-
|
|
96601
|
+
const link8 = new URL(`${authRoot(ctx)}/verify`);
|
|
96602
|
+
link8.searchParams.set("token", tokenHash);
|
|
96603
|
+
link8.searchParams.set("type", type.startsWith("email_change") ? "email_change" : type);
|
|
96604
|
+
link8.searchParams.set("redirect_to", dest);
|
|
96605
96605
|
if (send3) {
|
|
96606
96606
|
const subjects = { signup: "Confirm Your Signup", magiclink: "Magic Link", recovery: "Reset Your Password", invite: "You have been invited", email_change_new: "Confirm Email Change", email_change_current: "Confirm Email Change" };
|
|
96607
|
-
const message8 = type === "magiclink" && config2(ctx).email_otp === "code" ? `Your verification code is: ${otp2}` : `Follow this link: ${
|
|
96607
|
+
const message8 = type === "magiclink" && config2(ctx).email_otp === "code" ? `Your verification code is: ${otp2}` : `Follow this link: ${link8.href}
|
|
96608
96608
|
Your verification code is: ${otp2}`;
|
|
96609
96609
|
query2(
|
|
96610
96610
|
ctx,
|
|
@@ -96613,7 +96613,7 @@ Your verification code is: ${otp2}`;
|
|
|
96613
96613
|
);
|
|
96614
96614
|
ctx.trace.record({ source: "world", service: "supabase", method: "EMAIL", path: "auth.email", response: { id: id15, to: address9, type } });
|
|
96615
96615
|
}
|
|
96616
|
-
return { action_link:
|
|
96616
|
+
return { action_link: link8.href, email_otp: otp2, hashed_token: tokenHash, redirect_to: dest, verification_type: type };
|
|
96617
96617
|
}
|
|
96618
96618
|
var AUTH_SCHEMA, config2, stamp, hash2, uuid5, byEmail, iso2, authRoot;
|
|
96619
96619
|
var init_auth_state = __esm({
|
|
@@ -99162,15 +99162,15 @@ function pageSlice(items2, page20, perPage) {
|
|
|
99162
99162
|
function pageHeaders(c, total6, page20, perPage) {
|
|
99163
99163
|
const last = Math.ceil(total6 / perPage);
|
|
99164
99164
|
if (last <= 1 && page20 === 1) return {};
|
|
99165
|
-
const
|
|
99165
|
+
const link8 = (target6, rel) => {
|
|
99166
99166
|
const url4 = new URL(`${c.env.ctx.serviceUrl}${new URL(c.req.url).pathname}${new URL(c.req.url).search}`);
|
|
99167
99167
|
url4.searchParams.set("page", String(target6));
|
|
99168
99168
|
url4.searchParams.set("per_page", String(perPage));
|
|
99169
99169
|
return `<${url4.href}>; rel="${rel}"`;
|
|
99170
99170
|
};
|
|
99171
99171
|
const links4 = [];
|
|
99172
|
-
if (page20 > 1) links4.push(
|
|
99173
|
-
if (page20 < last) links4.push(
|
|
99172
|
+
if (page20 > 1) links4.push(link8(1, "first"), link8(page20 - 1, "prev"));
|
|
99173
|
+
if (page20 < last) links4.push(link8(page20 + 1, "next"), link8(last, "last"));
|
|
99174
99174
|
return links4.length ? { link: links4.join(", ") } : {};
|
|
99175
99175
|
}
|
|
99176
99176
|
function paginate(c, items2) {
|
|
@@ -99880,7 +99880,7 @@ function githubEvent(ctx, type, payload3, additionalLinks = []) {
|
|
|
99880
99880
|
user9(`/pull_request/${side}/user`);
|
|
99881
99881
|
repository3(`/pull_request/${side}/repo`);
|
|
99882
99882
|
}
|
|
99883
|
-
for (const
|
|
99883
|
+
for (const link8 of ["self", "issue", "comments", "review_comments", "review_comment", "commits", "statuses"]) fields14(`/pull_request/_links/${link8}`, ["href"]);
|
|
99884
99884
|
fields14("/issue", ["url", "repository_url", "labels_url", "comments_url", "events_url"]);
|
|
99885
99885
|
user9("/issue/user");
|
|
99886
99886
|
for (const owner6 of ["issue", "pull_request"]) {
|
|
@@ -100182,7 +100182,7 @@ function requireRun(ctx, repoId, runId2) {
|
|
|
100182
100182
|
function workflowRunShape(ctx, repo4, row2, relative31 = false) {
|
|
100183
100183
|
const workflow = ctx.store.db.prepare("SELECT * FROM github_workflows WHERE repo_id = ? AND id = ?").get(repo4.id, row2.workflow_id);
|
|
100184
100184
|
const path9 = `${repoPath(repo4)}/actions/runs/${row2.id}`, commit = getCommit(ctx, repo4.id, row2.head_sha), actor3 = resourceUserShape(ctx, botUser(ctx), relative31);
|
|
100185
|
-
const
|
|
100185
|
+
const link8 = (suffix) => resourceUrl(ctx, `${path9}/${suffix}`, relative31);
|
|
100186
100186
|
const repository3 = repositoryShape(relative31 ? githubEventContext(ctx) : ctx, repo4);
|
|
100187
100187
|
return {
|
|
100188
100188
|
id: row2.id,
|
|
@@ -100206,12 +100206,12 @@ function workflowRunShape(ctx, repo4, row2, relative31 = false) {
|
|
|
100206
100206
|
url: resourceUrl(ctx, path9, relative31),
|
|
100207
100207
|
html_url: `https://github.com/${repo4.full_name}/actions/runs/${row2.id}`,
|
|
100208
100208
|
pull_requests: [],
|
|
100209
|
-
jobs_url:
|
|
100210
|
-
logs_url:
|
|
100209
|
+
jobs_url: link8("jobs"),
|
|
100210
|
+
logs_url: link8("logs"),
|
|
100211
100211
|
check_suite_url: resourceUrl(ctx, `${repoPath(repo4)}/check-suites/${row2.id}`, relative31),
|
|
100212
|
-
artifacts_url:
|
|
100213
|
-
cancel_url:
|
|
100214
|
-
rerun_url:
|
|
100212
|
+
artifacts_url: link8("artifacts"),
|
|
100213
|
+
cancel_url: link8("cancel"),
|
|
100214
|
+
rerun_url: link8("rerun"),
|
|
100215
100215
|
workflow_url: resourceUrl(ctx, `${repoPath(repo4)}/actions/workflows/${workflow.id}`, relative31),
|
|
100216
100216
|
repository: repository3,
|
|
100217
100217
|
head_repository: repository3,
|
|
@@ -100862,7 +100862,7 @@ function monitorWebhook(ctx, notification) {
|
|
|
100862
100862
|
const monitor3 = ctx.store.db.prepare("SELECT * FROM datadog_monitors WHERE id = ?").get(notification.monitorId);
|
|
100863
100863
|
if (!event3 || !monitor3) throw new Error("Missing native monitor notification source");
|
|
100864
100864
|
const scope3 = parseMonitorQuery(monitor3.query).metric.tags.join(",") || "*";
|
|
100865
|
-
const
|
|
100865
|
+
const link8 = `/api/v1/monitor/${monitor3.id}`;
|
|
100866
100866
|
return ctx.events.append({ service: "datadog", type: "monitor.notification", payload: {
|
|
100867
100867
|
id: String(event3.id),
|
|
100868
100868
|
title: event3.title,
|
|
@@ -100873,8 +100873,8 @@ function monitorWebhook(ctx, notification) {
|
|
|
100873
100873
|
alert_cycle_key: notification.cycleKey,
|
|
100874
100874
|
alert_query: monitor3.query,
|
|
100875
100875
|
alert_scope: scope3,
|
|
100876
|
-
link:
|
|
100877
|
-
}, apiLinks: [{ pointer: "/link", path:
|
|
100876
|
+
link: link8
|
|
100877
|
+
}, apiLinks: [{ pointer: "/link", path: link8, service: "datadog" }] });
|
|
100878
100878
|
}
|
|
100879
100879
|
var init_events2 = __esm({
|
|
100880
100880
|
"packages/server/src/twins/datadog/events.ts"() {
|
|
@@ -101851,17 +101851,17 @@ var init_access = __esm({
|
|
|
101851
101851
|
function messageLinks(ctx, row2) {
|
|
101852
101852
|
return ctx.store.db.prepare("SELECT pointer, service, path FROM slack_message_links WHERE channel_id = ? AND ts = ? ORDER BY rowid").all(row2.channel_id, row2.ts);
|
|
101853
101853
|
}
|
|
101854
|
-
function replaceLink(message8,
|
|
101855
|
-
if (!
|
|
101854
|
+
function replaceLink(message8, link8, url4) {
|
|
101855
|
+
if (!link8.pointer.startsWith("/blocks/") || /~(?![01])/u.test(link8.pointer) || !link8.path.startsWith("/") || link8.path.startsWith("//"))
|
|
101856
101856
|
throw new AnchaError("INTERNAL", "Invalid Slack message API link");
|
|
101857
|
-
const keys7 =
|
|
101857
|
+
const keys7 = link8.pointer.slice(1).split("/").map((key5) => key5.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
101858
101858
|
let target6 = message8;
|
|
101859
101859
|
for (const [index, key5] of keys7.entries()) {
|
|
101860
101860
|
if (typeof target6 !== "object" || target6 === null || !Object.hasOwn(target6, key5) || Array.isArray(target6) && !/^(0|[1-9]\d*)$/.test(key5))
|
|
101861
101861
|
throw new AnchaError("INTERNAL", "Missing Slack message API link field");
|
|
101862
101862
|
const object28 = target6;
|
|
101863
101863
|
if (index === keys7.length - 1) {
|
|
101864
|
-
if (object28[key5] !==
|
|
101864
|
+
if (object28[key5] !== link8.path) throw new AnchaError("INTERNAL", "Slack message API link does not match its semantic path");
|
|
101865
101865
|
Object.defineProperty(object28, key5, { value: url4, enumerable: true, configurable: true, writable: true });
|
|
101866
101866
|
} else target6 = object28[key5];
|
|
101867
101867
|
}
|
|
@@ -101869,17 +101869,17 @@ function replaceLink(message8, link9, url4) {
|
|
|
101869
101869
|
function persistMessageLinks(ctx, row2, links4 = []) {
|
|
101870
101870
|
ctx.store.db.prepare("DELETE FROM slack_message_links WHERE channel_id = ? AND ts = ?").run(row2.channel_id, row2.ts);
|
|
101871
101871
|
for (const input5 of links4) {
|
|
101872
|
-
const
|
|
101873
|
-
replaceLink({ blocks: row2.blocks === null ? null : JSON.parse(row2.blocks) },
|
|
101874
|
-
ctx.store.db.prepare("INSERT INTO slack_message_links VALUES (?, ?, ?, ?, ?)").run(row2.channel_id, row2.ts,
|
|
101872
|
+
const link8 = { ...input5, service: input5.service ?? "slack" };
|
|
101873
|
+
replaceLink({ blocks: row2.blocks === null ? null : JSON.parse(row2.blocks) }, link8, link8.path);
|
|
101874
|
+
ctx.store.db.prepare("INSERT INTO slack_message_links VALUES (?, ?, ?, ?, ?)").run(row2.channel_id, row2.ts, link8.pointer, link8.service, link8.path);
|
|
101875
101875
|
}
|
|
101876
101876
|
}
|
|
101877
101877
|
function materializeMessageLinks(ctx, row2, shape6) {
|
|
101878
101878
|
if (!ctx.serviceUrls) return;
|
|
101879
|
-
for (const
|
|
101880
|
-
const root3 = ctx.serviceUrls[
|
|
101881
|
-
if (!root3) throw new AnchaError("INTERNAL", `Missing local ${
|
|
101882
|
-
replaceLink(shape6,
|
|
101879
|
+
for (const link8 of messageLinks(ctx, row2)) {
|
|
101880
|
+
const root3 = ctx.serviceUrls[link8.service];
|
|
101881
|
+
if (!root3) throw new AnchaError("INTERNAL", `Missing local ${link8.service} service for Slack message link`);
|
|
101882
|
+
replaceLink(shape6, link8, root3.replace(/\/$/, "") + link8.path);
|
|
101883
101883
|
}
|
|
101884
101884
|
}
|
|
101885
101885
|
var init_links = __esm({
|
|
@@ -102174,7 +102174,7 @@ function appMessage(ctx, service, channel3, text31, blocks3, ts3, apiLinks) {
|
|
|
102174
102174
|
if (ts3 === void 0) {
|
|
102175
102175
|
const message9 = insertMessage(ctx, { channelId: channel3, userId: app2.user_id, botId: app2.bot_id, text: text31, blocks: blocks3, threadTs: null });
|
|
102176
102176
|
persistMessageLinks(ctx, message9, apiLinks);
|
|
102177
|
-
emitMessage(ctx, message9, apiLinks?.map((
|
|
102177
|
+
emitMessage(ctx, message9, apiLinks?.map((link8) => ({ ...link8, pointer: `/event${link8.pointer}` })));
|
|
102178
102178
|
return message9;
|
|
102179
102179
|
}
|
|
102180
102180
|
const previous = getMessage2(ctx, channel3, ts3);
|
|
@@ -102184,8 +102184,8 @@ function appMessage(ctx, service, channel3, text31, blocks3, ts3, apiLinks) {
|
|
|
102184
102184
|
const message8 = getMessage2(ctx, channel3, ts3);
|
|
102185
102185
|
persistMessageLinks(ctx, message8, apiLinks);
|
|
102186
102186
|
emitMessageChanged(ctx, message8, previous, [
|
|
102187
|
-
...(apiLinks ?? []).map((
|
|
102188
|
-
...previousLinks.map((
|
|
102187
|
+
...(apiLinks ?? []).map((link8) => ({ ...link8, pointer: `/event/message${link8.pointer}` })),
|
|
102188
|
+
...previousLinks.map((link8) => ({ ...link8, pointer: `/event/previous_message${link8.pointer}` }))
|
|
102189
102189
|
]);
|
|
102190
102190
|
return message8;
|
|
102191
102191
|
}
|
|
@@ -102239,19 +102239,19 @@ function initializeIntegrations(env2) {
|
|
|
102239
102239
|
CREATE TABLE world_integration_cycles (binding INTEGER NOT NULL, cycle_key TEXT NOT NULL, state TEXT NOT NULL, PRIMARY KEY(binding, cycle_key, state));
|
|
102240
102240
|
CREATE TABLE world_incident_messages (binding INTEGER NOT NULL, incident_id TEXT NOT NULL, channel_id TEXT NOT NULL, ts TEXT NOT NULL, PRIMARY KEY(binding, incident_id));
|
|
102241
102241
|
`);
|
|
102242
|
-
for (const [ordinal2,
|
|
102243
|
-
if ("kind" in
|
|
102244
|
-
const ctx = env2.ctxFor(
|
|
102242
|
+
for (const [ordinal2, link8] of (env2.scene.world_rules?.integrations ?? []).entries()) {
|
|
102243
|
+
if ("kind" in link8) continue;
|
|
102244
|
+
const ctx = env2.ctxFor(link8.from);
|
|
102245
102245
|
let service;
|
|
102246
|
-
if ("service" in
|
|
102247
|
-
if ("service" in
|
|
102248
|
-
const channelRef = "channel" in
|
|
102246
|
+
if ("service" in link8) service = getService(ctx, owned(ctx, link8.service, "service", "pagerduty"));
|
|
102247
|
+
if ("service" in link8 && !service) throw new Error("Integration service unavailable");
|
|
102248
|
+
const channelRef = "channel" in link8 && link8.channel !== void 0 ? link8.channel : link8.from === "pagerduty" ? service?.slack_channel_ref : void 0;
|
|
102249
102249
|
const channel3 = channelRef ? owned(ctx, channelRef, "channel", "slack") : null;
|
|
102250
|
-
if (
|
|
102251
|
-
const handle31 =
|
|
102252
|
-
env2.store.db.prepare("INSERT INTO world_integrations VALUES (?, ?, ?, ?, ?, ?)").run(ordinal2,
|
|
102253
|
-
if (
|
|
102254
|
-
const app2 = seedApp(env2.ctxFor("slack"),
|
|
102250
|
+
if (link8.to === "slack" && (!channel3 || !ctx.store.db.prepare("SELECT 1 FROM slack_channels WHERE id = ?").get(channel3))) throw new Error("Integration channel unavailable");
|
|
102251
|
+
const handle31 = link8.from === "datadog" ? link8.handle ?? `pagerduty-${service.name}` : null;
|
|
102252
|
+
env2.store.db.prepare("INSERT INTO world_integrations VALUES (?, ?, ?, ?, ?, ?)").run(ordinal2, link8.from, link8.to, handle31, service?.id ?? null, channel3);
|
|
102253
|
+
if (link8.to === "slack") {
|
|
102254
|
+
const app2 = seedApp(env2.ctxFor("slack"), link8.from);
|
|
102255
102255
|
env2.store.db.prepare("INSERT OR IGNORE INTO slack_members VALUES (?, ?)").run(channel3, app2.user_id);
|
|
102256
102256
|
}
|
|
102257
102257
|
}
|
|
@@ -102667,7 +102667,7 @@ function seed4(ctx) {
|
|
|
102667
102667
|
ctx.store.db.prepare("INSERT INTO hubspot_records(type,id,data) VALUES(?,?,?)").run(type, data7.id, JSON.stringify(data7));
|
|
102668
102668
|
version4(ctx, type, data7, "seed", ctx.clock.nowMs());
|
|
102669
102669
|
}
|
|
102670
|
-
for (const
|
|
102670
|
+
for (const link8 of input5.associations) writeLink(ctx, link8.from.type, link8.from.id, link8.to.type, link8.to.id, link8.typeId);
|
|
102671
102671
|
}
|
|
102672
102672
|
function objectType(value6) {
|
|
102673
102673
|
const type = hubspotObjectNames.find((type2) => type2 === value6.toLowerCase() || hubspotObjectTypeIds[type2] === value6);
|
|
@@ -102730,8 +102730,8 @@ function project3(ctx, type, record33, selected3, historyFields, associationObje
|
|
|
102730
102730
|
const associations = {};
|
|
102731
102731
|
for (const target6 of associationObjects) {
|
|
102732
102732
|
permission3(ctx, target6);
|
|
102733
|
-
const
|
|
102734
|
-
if (
|
|
102733
|
+
const results2 = associated(ctx, type, record33.id, target6);
|
|
102734
|
+
if (results2.length) associations[target6] = { results: results2 };
|
|
102735
102735
|
}
|
|
102736
102736
|
output2.associations = associations;
|
|
102737
102737
|
}
|
|
@@ -102860,9 +102860,9 @@ function associate(ctx, from, fromId, to, toId, identifier6) {
|
|
|
102860
102860
|
if ([1, 2, 5, 6].includes(spec.id)) {
|
|
102861
102861
|
const other = from === "companies" ? { type: to, id: toId } : { type: from, id: fromId }, company = from === "companies" ? fromId : toId, primaryType = other.type === "contacts" ? 1 : 5, reverse = primaryType === 1 ? 2 : 6;
|
|
102862
102862
|
const existing3 = ctx.store.db.prepare("SELECT to_id FROM hubspot_associations WHERE from_type=? AND from_id=? AND to_type='companies' AND type_id=?").all(other.type, other.id, primaryType);
|
|
102863
|
-
for (const
|
|
102864
|
-
ctx.store.db.prepare("DELETE FROM hubspot_associations WHERE from_type=? AND from_id=? AND to_type='companies' AND type_id=? AND to_id=?").run(other.type, other.id, primaryType,
|
|
102865
|
-
ctx.store.db.prepare("DELETE FROM hubspot_associations WHERE from_type='companies' AND from_id=? AND to_type=? AND to_id=? AND type_id=?").run(
|
|
102863
|
+
for (const link8 of existing3) if (link8.to_id !== company) {
|
|
102864
|
+
ctx.store.db.prepare("DELETE FROM hubspot_associations WHERE from_type=? AND from_id=? AND to_type='companies' AND type_id=? AND to_id=?").run(other.type, other.id, primaryType, link8.to_id);
|
|
102865
|
+
ctx.store.db.prepare("DELETE FROM hubspot_associations WHERE from_type='companies' AND from_id=? AND to_type=? AND to_id=? AND type_id=?").run(link8.to_id, other.type, other.id, reverse);
|
|
102866
102866
|
}
|
|
102867
102867
|
}
|
|
102868
102868
|
if (writeLink(ctx, from, fromId, to, toId, spec.id)) ctx.store.db.prepare("INSERT INTO hubspot_link_history(at,operation,data) VALUES(?,?,?)").run(ctx.clock.now().toISOString(), "associate", JSON.stringify({ from: { type: from, id: fromId }, to: { type: to, id: toId }, typeId: spec.id }));
|
|
@@ -102890,7 +102890,7 @@ function definition(ctx, type, name5) {
|
|
|
102890
102890
|
}
|
|
102891
102891
|
function dumpState2(ctx) {
|
|
102892
102892
|
const settings = config3(ctx);
|
|
102893
|
-
return { ...settings, ...Object.fromEntries(hubspotObjectNames.map((type) => [type, rows27(ctx, type)])), associations: ctx.store.db.prepare("SELECT * FROM hubspot_associations ORDER BY from_type,from_id,to_type,to_id,type_id").all().map((
|
|
102893
|
+
return { ...settings, ...Object.fromEntries(hubspotObjectNames.map((type) => [type, rows27(ctx, type)])), associations: ctx.store.db.prepare("SELECT * FROM hubspot_associations ORDER BY from_type,from_id,to_type,to_id,type_id").all().map((link8) => ({ from: { type: link8.from_type, id: link8.from_id }, to: { type: link8.to_type, id: link8.to_id }, typeId: link8.type_id })), history: ctx.store.db.prepare("SELECT ordinal,type,id,at,visible_ms,operation,data FROM hubspot_versions WHERE operation<>'seed' ORDER BY ordinal").all().map((row2) => ({ ordinal: row2.ordinal, object: row2.type, id: row2.id, at: row2.at, searchVisibleAt: new Date(row2.visible_ms).toISOString(), operation: row2.operation, record: JSON.parse(row2.data) })), associationHistory: ctx.store.db.prepare("SELECT * FROM hubspot_link_history ORDER BY ordinal").all().map((row2) => ({ ordinal: row2.ordinal, at: row2.at, operation: row2.operation, ...JSON.parse(row2.data) })) };
|
|
102894
102894
|
}
|
|
102895
102895
|
var HubError, defaultProperties;
|
|
102896
102896
|
var init_store2 = __esm({
|
|
@@ -103055,19 +103055,19 @@ function batch(ctx, type, operation, raw3, url4) {
|
|
|
103055
103055
|
for (const name5 of [...selected3 ?? [], ...historical ?? []]) checkProperty(type, name5);
|
|
103056
103056
|
if (body8.idProperty !== void 0 && typeof body8.idProperty !== "string") throw new HubError(400, "VALIDATION_ERROR", "idProperty must be a string.");
|
|
103057
103057
|
if (operation === "read") {
|
|
103058
|
-
const archived = boolean5(url4.searchParams.get("archived")),
|
|
103058
|
+
const archived = boolean5(url4.searchParams.get("archived")), results2 = [], errors3 = [];
|
|
103059
103059
|
let gap8 = false;
|
|
103060
103060
|
for (const item2 of items2) {
|
|
103061
103061
|
bodyObject2(item2, ["id"]);
|
|
103062
103062
|
try {
|
|
103063
|
-
|
|
103063
|
+
results2.push(project3(ctx, type, getRecord(ctx, type, identifier(item2.id), archived, body8.idProperty), selected3, historical));
|
|
103064
103064
|
} catch (error65) {
|
|
103065
103065
|
if (!(error65 instanceof HubError)) throw error65;
|
|
103066
103066
|
gap8 ||= error65.gap;
|
|
103067
103067
|
errors3.push({ ...errorBody(ctx, error65), context: { id: [String(item2.id)] } });
|
|
103068
103068
|
}
|
|
103069
103069
|
}
|
|
103070
|
-
return { status: 200, body: batchEnvelope(ctx,
|
|
103070
|
+
return { status: 200, body: batchEnvelope(ctx, results2, errors3), gap: gap8 };
|
|
103071
103071
|
}
|
|
103072
103072
|
if (operation === "archive") {
|
|
103073
103073
|
for (const item2 of items2) bodyObject2(item2, ["id"]);
|
|
@@ -103083,18 +103083,18 @@ function batch(ctx, type, operation, raw3, url4) {
|
|
|
103083
103083
|
return project3(ctx, type, operation === "create" ? createRecord(ctx, type, item2) : updateRecord(ctx, type, identifier(item2.id), { properties: item2.properties }));
|
|
103084
103084
|
};
|
|
103085
103085
|
if (traced3) return withMutation(ctx, () => {
|
|
103086
|
-
const
|
|
103086
|
+
const results2 = [], errors3 = [];
|
|
103087
103087
|
let gap8 = false;
|
|
103088
103088
|
for (const item2 of items2) {
|
|
103089
103089
|
try {
|
|
103090
|
-
|
|
103090
|
+
results2.push(ctx.store.transaction(() => execute5(item2)));
|
|
103091
103091
|
} catch (error65) {
|
|
103092
103092
|
if (!(error65 instanceof HubError)) throw error65;
|
|
103093
103093
|
gap8 ||= error65.gap;
|
|
103094
103094
|
errors3.push({ ...errorBody(ctx, error65), context: { objectWriteTraceId: [String(item2.objectWriteTraceId)] } });
|
|
103095
103095
|
}
|
|
103096
103096
|
}
|
|
103097
|
-
return { status: errors3.length ? 207 : 201, body: batchEnvelope(ctx,
|
|
103097
|
+
return { status: errors3.length ? 207 : 201, body: batchEnvelope(ctx, results2, errors3), gap: gap8 };
|
|
103098
103098
|
});
|
|
103099
103099
|
try {
|
|
103100
103100
|
return withMutation(ctx, () => ({ status: operation === "create" ? 201 : 200, body: batchEnvelope(ctx, items2.map(execute5)) }));
|
|
@@ -103105,7 +103105,7 @@ function batch(ctx, type, operation, raw3, url4) {
|
|
|
103105
103105
|
}
|
|
103106
103106
|
function associationsBatch(ctx, from, to, operation, raw3) {
|
|
103107
103107
|
if (!["read", "create", "archive"].includes(operation)) unsupported5(`association batch ${operation}`);
|
|
103108
|
-
const body8 = bodyObject2(raw3, ["inputs"]), items2 = inputs(body8, operation === "read" ? 1e3 : operation === "create" ? 2e3 : 100),
|
|
103108
|
+
const body8 = bodyObject2(raw3, ["inputs"]), items2 = inputs(body8, operation === "read" ? 1e3 : operation === "create" ? 2e3 : 100), results2 = [];
|
|
103109
103109
|
permission3(ctx, from, operation === "read" ? "read" : "write");
|
|
103110
103110
|
permission3(ctx, to);
|
|
103111
103111
|
if (operation === "read") {
|
|
@@ -103116,14 +103116,14 @@ function associationsBatch(ctx, from, to, operation, raw3) {
|
|
|
103116
103116
|
const id15 = identifier(item2.id);
|
|
103117
103117
|
getRecord(ctx, from, id15);
|
|
103118
103118
|
let links4 = associated(ctx, from, id15, to);
|
|
103119
|
-
if (to === "companies") links4 = links4.filter((
|
|
103120
|
-
|
|
103119
|
+
if (to === "companies") links4 = links4.filter((link8) => ["contact_to_company", "deal_to_company"].includes(link8.type));
|
|
103120
|
+
results2.push({ from: { id: id15 }, to: links4 });
|
|
103121
103121
|
} catch (error65) {
|
|
103122
103122
|
if (!(error65 instanceof HubError)) throw error65;
|
|
103123
103123
|
errors3.push(errorBody(ctx, error65));
|
|
103124
103124
|
}
|
|
103125
103125
|
}
|
|
103126
|
-
return { status: 200, body: batchEnvelope(ctx,
|
|
103126
|
+
return { status: 200, body: batchEnvelope(ctx, results2, errors3) };
|
|
103127
103127
|
}
|
|
103128
103128
|
try {
|
|
103129
103129
|
return withMutation(ctx, () => {
|
|
@@ -103131,10 +103131,10 @@ function associationsBatch(ctx, from, to, operation, raw3) {
|
|
|
103131
103131
|
bodyObject2(item2, ["from", "to", "type"]);
|
|
103132
103132
|
const fromId = identifier(bodyObject2(item2.from, ["id"]).id), toId = identifier(bodyObject2(item2.to, ["id"]).id);
|
|
103133
103133
|
if (typeof item2.type !== "string") throw new HubError(400, "VALIDATION_ERROR", "Association requires type.");
|
|
103134
|
-
if (operation === "create")
|
|
103134
|
+
if (operation === "create") results2.push(associate(ctx, from, fromId, to, toId, item2.type));
|
|
103135
103135
|
else disassociate(ctx, from, fromId, to, toId, item2.type);
|
|
103136
103136
|
}
|
|
103137
|
-
return operation === "archive" ? { status: 204 } : { status: 201, body: batchEnvelope(ctx,
|
|
103137
|
+
return operation === "archive" ? { status: 204 } : { status: 201, body: batchEnvelope(ctx, results2) };
|
|
103138
103138
|
});
|
|
103139
103139
|
} catch (error65) {
|
|
103140
103140
|
if (!(error65 instanceof HubError)) throw error65;
|
|
@@ -103290,7 +103290,7 @@ var init_hubspot2 = __esm({
|
|
|
103290
103290
|
init_search();
|
|
103291
103291
|
init_store2();
|
|
103292
103292
|
init_webhooks();
|
|
103293
|
-
batchEnvelope = (ctx,
|
|
103293
|
+
batchEnvelope = (ctx, results2, errors3 = []) => ({ status: "COMPLETE", results: results2, startedAt: ctx.clock.now().toISOString(), completedAt: ctx.clock.now().toISOString(), ...errors3.length ? { numErrors: errors3.length, errors: errors3 } : {} });
|
|
103294
103294
|
routePairs = [
|
|
103295
103295
|
["GET", "/crm/v3/objects/:type"],
|
|
103296
103296
|
["POST", "/crm/v3/objects/:type"],
|
|
@@ -103491,7 +103491,7 @@ var init_catalog3 = __esm({
|
|
|
103491
103491
|
|
|
103492
103492
|
// packages/server/src/world/integrations/runtime.ts
|
|
103493
103493
|
function entries(env2) {
|
|
103494
|
-
return (env2.scene.world_rules?.integrations ?? []).flatMap((
|
|
103494
|
+
return (env2.scene.world_rules?.integrations ?? []).flatMap((link8, ordinal2) => "kind" in link8 ? [{ ordinal: ordinal2, integration: link8 }] : []);
|
|
103495
103495
|
}
|
|
103496
103496
|
function catalogEvent(event3) {
|
|
103497
103497
|
const payload3 = JSON.parse(event3.body);
|
|
@@ -103867,10 +103867,10 @@ function logPage(ctx, ast, fromMs, toMs, options5) {
|
|
|
103867
103867
|
if (matchesLog(ast, parsed5)) rows35.push(parsed5);
|
|
103868
103868
|
}
|
|
103869
103869
|
for (const { rule, stream: stream2, cadence } of streams) {
|
|
103870
|
-
const span3 = grid(start2, fromMs, end, cadence),
|
|
103870
|
+
const span3 = grid(start2, fromMs, end, cadence), timeline = rule.while === void 0 ? void 0 : faultTimeline(ctx, rule.while);
|
|
103871
103871
|
for (let i = 0; i < span3.count; i++) {
|
|
103872
103872
|
const at6 = span3.first + i * cadence;
|
|
103873
|
-
if (
|
|
103873
|
+
if (timeline && !active(timeline, at6 - start2)) continue;
|
|
103874
103874
|
rows35.push({
|
|
103875
103875
|
id: sampleHash(seed44, JSON.stringify(["log", stream2]), at6),
|
|
103876
103876
|
ref: rule.ref ?? null,
|
|
@@ -103912,7 +103912,7 @@ var init_generators = __esm({
|
|
|
103912
103912
|
throw new QueryEvaluationError("validation", message8);
|
|
103913
103913
|
};
|
|
103914
103914
|
compareText = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
103915
|
-
active = (
|
|
103915
|
+
active = (timeline, elapsed2) => timeline.startedMs !== null && timeline.startedMs <= elapsed2 && (timeline.resolvedMs === null || elapsed2 < timeline.resolvedMs);
|
|
103916
103916
|
}
|
|
103917
103917
|
});
|
|
103918
103918
|
|
|
@@ -110874,8 +110874,8 @@ function evidenceFor(env2, check4, result, messages7, calls2) {
|
|
|
110874
110874
|
}
|
|
110875
110875
|
return { evidence: traceEvidence(result.evidence ?? []).slice(0, MAX_EVIDENCE) };
|
|
110876
110876
|
}
|
|
110877
|
-
function explainFailedChecks(env2,
|
|
110878
|
-
const failed2 =
|
|
110877
|
+
function explainFailedChecks(env2, results2, checks2 = env2.scene.checks) {
|
|
110878
|
+
const failed2 = results2.filter((result) => !result.passed && result.status !== "skipped");
|
|
110879
110879
|
if (!failed2.length) return [];
|
|
110880
110880
|
const messages7 = attemptMessages(env2);
|
|
110881
110881
|
const agentCalls2 = projectToolCalls(env2.trace.list()).filter((entry3) => entry3.source === "agent");
|
|
@@ -110957,13 +110957,13 @@ function peopleTimeline(env2) {
|
|
|
110957
110957
|
const key5 = `${row2.source_kind}:${row2.source_id}`;
|
|
110958
110958
|
reached.set(key5, [...reached.get(key5) ?? [], row2.person]);
|
|
110959
110959
|
}
|
|
110960
|
-
const
|
|
110960
|
+
const timeline = [];
|
|
110961
110961
|
const written = new Set(attemptMessages(env2).map((message8) => `${message8.kind}:${message8.id}`));
|
|
110962
110962
|
for (const message8 of readMessages(env2).messages) {
|
|
110963
110963
|
const from = authorOf(message8, entries4, bot), id15 = `${message8.kind}:${message8.id}`, to = reached.get(id15) ?? [];
|
|
110964
110964
|
const byPerson = people4.some((person5) => person5.ref === from);
|
|
110965
110965
|
if (!byPerson && !(from === "agent" && to.length)) continue;
|
|
110966
|
-
|
|
110966
|
+
timeline.push({
|
|
110967
110967
|
id: id15,
|
|
110968
110968
|
kind: "message",
|
|
110969
110969
|
simMs: message8.simMs,
|
|
@@ -110976,19 +110976,19 @@ function peopleTimeline(env2) {
|
|
|
110976
110976
|
});
|
|
110977
110977
|
}
|
|
110978
110978
|
for (const row2 of db3.prepare("SELECT person, fact, asker, message, sim_ms FROM world_unlocked ORDER BY sim_ms, seq").all()) {
|
|
110979
|
-
|
|
110979
|
+
timeline.push({ id: `reveal:${row2.fact}`, kind: "fact", simMs: row2.sim_ms, person: row2.person, fact: splitPersonItem(row2.fact).id, to: row2.asker, message: row2.message, rank: RANK.record });
|
|
110980
110980
|
}
|
|
110981
110981
|
for (const row2 of db3.prepare("SELECT person, fact, source, source_person, message, sim_ms FROM world_knowledge WHERE source != 'own' ORDER BY sim_ms, seq").all()) {
|
|
110982
|
-
|
|
110982
|
+
timeline.push({ id: `learned:${row2.person}.${row2.fact}`, kind: "learned", simMs: row2.sim_ms, person: row2.person, fact: row2.fact, from: row2.source_person ?? "agent", message: row2.message, rank: RANK.learned });
|
|
110983
110983
|
}
|
|
110984
110984
|
for (const row2 of db3.prepare("SELECT person, decision, option, reason, message, sim_ms FROM world_decisions ORDER BY sim_ms, seq").all()) {
|
|
110985
|
-
|
|
110985
|
+
timeline.push({ id: `decision:${row2.person}.${row2.decision}`, kind: "decision", simMs: row2.sim_ms, person: row2.person, decision: row2.decision, option: row2.option, reason: row2.reason, message: row2.message, rank: RANK.record });
|
|
110986
110986
|
}
|
|
110987
|
-
|
|
110987
|
+
timeline.sort((a, b) => a.simMs - b.simMs || a.rank - b.rank);
|
|
110988
110988
|
return {
|
|
110989
110989
|
startedAt: env2.clock.startTime.toISOString(),
|
|
110990
110990
|
persons: people4.map((person5) => ({ ref: person5.ref, name: person5.name, role: person5.role, facts: (person5.knows ?? []).length, decisions: (person5.decides ?? []).map((decision2) => decision2.id) })),
|
|
110991
|
-
timeline:
|
|
110991
|
+
timeline: timeline.map(({ rank: _rank, ...entry3 }) => entry3)
|
|
110992
110992
|
};
|
|
110993
110993
|
}
|
|
110994
110994
|
var hasTable7, RANK;
|
|
@@ -111644,7 +111644,7 @@ var init_env = __esm({
|
|
|
111644
111644
|
const state3 = Object.fromEntries(this.twins.map((twin) => [twin.name, twin.dumpState(this.ctxFor(twin.name))]));
|
|
111645
111645
|
const people4 = peopleCalls(this);
|
|
111646
111646
|
const replay = this.#peopleReplay;
|
|
111647
|
-
const explanations = explainFailedChecks(this, checks2),
|
|
111647
|
+
const explanations = explainFailedChecks(this, checks2), timeline = peopleTimeline(this);
|
|
111648
111648
|
this.#capture = structuredClone({
|
|
111649
111649
|
checks: checks2,
|
|
111650
111650
|
trace: trace2,
|
|
@@ -111654,7 +111654,7 @@ var init_env = __esm({
|
|
|
111654
111654
|
...people4.length && { people: people4 },
|
|
111655
111655
|
...replay && { peopleReplay: { replayed: replay.replayed, live: replay.live, divergence: replay.divergence ?? null } },
|
|
111656
111656
|
...explanations.length && { explanations },
|
|
111657
|
-
...
|
|
111657
|
+
...timeline && { peopleTimeline: timeline }
|
|
111658
111658
|
});
|
|
111659
111659
|
}
|
|
111660
111660
|
return structuredClone(this.#capture);
|
|
@@ -112519,10 +112519,10 @@ function mutate(ctx, kind2, body8, cid) {
|
|
|
112519
112519
|
gap(`response_content_type ${body8.responseContentType}`);
|
|
112520
112520
|
try {
|
|
112521
112521
|
return ctx.store.transaction(() => {
|
|
112522
|
-
const
|
|
112522
|
+
const results2 = [], errors3 = [];
|
|
112523
112523
|
for (const [index, op2] of body8.operations.entries()) {
|
|
112524
112524
|
try {
|
|
112525
|
-
|
|
112525
|
+
results2.push(ctx.store.transaction(() => oneOperation(ctx, kind2, cid, op2, body8.responseContentType === "MUTABLE_RESOURCE")));
|
|
112526
112526
|
} catch (e) {
|
|
112527
112527
|
if (!(e instanceof AdsError))
|
|
112528
112528
|
throw e;
|
|
@@ -112533,10 +112533,10 @@ function mutate(ctx, kind2, body8, cid) {
|
|
|
112533
112533
|
throw e;
|
|
112534
112534
|
}
|
|
112535
112535
|
errors3.push(errorDetail(e, index));
|
|
112536
|
-
|
|
112536
|
+
results2.push({});
|
|
112537
112537
|
}
|
|
112538
112538
|
}
|
|
112539
|
-
const result = body8.validateOnly ? {} : { results };
|
|
112539
|
+
const result = body8.validateOnly ? {} : { results: results2 };
|
|
112540
112540
|
if (errors3.length)
|
|
112541
112541
|
result.partialFailureError = { code: 3, message: `${errors3.length} operation(s) failed`, details: [failure3(errors3)] };
|
|
112542
112542
|
if (body8.validateOnly)
|
|
@@ -138566,8 +138566,8 @@ var init_ga42 = __esm({
|
|
|
138566
138566
|
const p2 = property2(c, c.req.param("property").split(":")[0]), value6 = object12(body8, "BatchRunReportsRequest");
|
|
138567
138567
|
keys3(value6, ["requests"], "BatchRunReportsRequest");
|
|
138568
138568
|
if (!Array.isArray(value6.requests) || !value6.requests.length || value6.requests.length > 5) invalid13("Batch requires one to five report requests");
|
|
138569
|
-
const
|
|
138570
|
-
return { kind: "analyticsData#batchRunReports", reports:
|
|
138569
|
+
const results2 = value6.requests.map((request2) => report2(c.env.ctx, p2, request2, true)), used = quota(c.env.ctx, p2.id, results2.length);
|
|
138570
|
+
return { kind: "analyticsData#batchRunReports", reports: results2.map((result) => ({ ...result.response, ...result.returnQuota ? { propertyQuota: used } : {} })) };
|
|
138571
138571
|
} },
|
|
138572
138572
|
{ method: "POST", path: "/v1beta/properties/:property{[0-9]+:checkCompatibility}", notes: "Compatibility only within the supported metadata subset; all supported combinations are compatible. Unknown fields expose gaps.", run: (c, body8) => {
|
|
138573
138573
|
const p2 = property2(c, c.req.param("property").split(":")[0]), value6 = object12(body8, "CheckCompatibilityRequest");
|
|
@@ -143300,7 +143300,7 @@ function composite(ctx, raw3) {
|
|
|
143300
143300
|
}
|
|
143301
143301
|
let gap8 = false;
|
|
143302
143302
|
const run7 = () => {
|
|
143303
|
-
const
|
|
143303
|
+
const results3 = [], outputs = /* @__PURE__ */ new Map();
|
|
143304
143304
|
const substitute = (input5) => {
|
|
143305
143305
|
if (Array.isArray(input5)) return input5.map(substitute);
|
|
143306
143306
|
if (input5 && typeof input5 === "object") return Object.fromEntries(Object.entries(input5).map(([key5, value6]) => [key5, substitute(value6)]));
|
|
@@ -143327,24 +143327,24 @@ function composite(ctx, raw3) {
|
|
|
143327
143327
|
reply6 = errorReply(error65);
|
|
143328
143328
|
}
|
|
143329
143329
|
gap8 ||= !!reply6.gap;
|
|
143330
|
-
|
|
143330
|
+
results3.push({ body: reply6.body ?? null, httpHeaders: { ...reply6.headers, ...reply6.gap && { [GAP_HEADER]: "1" } }, httpStatusCode: reply6.status, referenceId: req.referenceId });
|
|
143331
143331
|
if (reply6.status < 400) outputs.set(req.referenceId, reply6.body);
|
|
143332
143332
|
if (reply6.status >= 400 && body8.allOrNone) {
|
|
143333
|
-
const failed2 =
|
|
143334
|
-
const rolled = requests2.map((request2, index) => index === failed2 ?
|
|
143333
|
+
const failed2 = results3.length - 1;
|
|
143334
|
+
const rolled = requests2.map((request2, index) => index === failed2 ? results3[failed2] : { referenceId: request2.referenceId, httpStatusCode: 400, httpHeaders: {}, body: [{ errorCode: "PROCESSING_HALTED", message: "A related operation failed; the transaction was rolled back." }] });
|
|
143335
143335
|
throw new Rollback(rolled);
|
|
143336
143336
|
}
|
|
143337
143337
|
}
|
|
143338
|
-
return
|
|
143338
|
+
return results3;
|
|
143339
143339
|
};
|
|
143340
|
-
let
|
|
143340
|
+
let results2;
|
|
143341
143341
|
try {
|
|
143342
|
-
|
|
143342
|
+
results2 = withMutation(ctx, run7);
|
|
143343
143343
|
} catch (error65) {
|
|
143344
143344
|
if (!(error65 instanceof Rollback)) throw error65;
|
|
143345
|
-
|
|
143345
|
+
results2 = error65.results;
|
|
143346
143346
|
}
|
|
143347
|
-
return { status: 200, body: { compositeResponse:
|
|
143347
|
+
return { status: 200, body: { compositeResponse: results2 }, ...gap8 ? { gap: true } : {} };
|
|
143348
143348
|
}
|
|
143349
143349
|
function salesforceTwin() {
|
|
143350
143350
|
const app2 = new Hono3();
|
|
@@ -143396,9 +143396,9 @@ var init_salesforce2 = __esm({
|
|
|
143396
143396
|
errorReply = (error65) => ({ status: error65.status, body: [{ message: error65.message, errorCode: error65.code, ...error65.fields.length && { fields: error65.fields } }], ...error65.gap && { gap: true } });
|
|
143397
143397
|
Rollback = class extends Error {
|
|
143398
143398
|
results;
|
|
143399
|
-
constructor(
|
|
143399
|
+
constructor(results2) {
|
|
143400
143400
|
super("composite rolled back");
|
|
143401
|
-
this.results =
|
|
143401
|
+
this.results = results2;
|
|
143402
143402
|
}
|
|
143403
143403
|
};
|
|
143404
143404
|
routePairs2 = [
|
|
@@ -143748,10 +143748,10 @@ function update3(ctx, kind2, account9, id15, body8) {
|
|
|
143748
143748
|
}
|
|
143749
143749
|
function batchGet(c, kind2, ids3, projection2) {
|
|
143750
143750
|
if (!ids3.length || ids3.length > 100) invalid16("ids must contain 1..100 values");
|
|
143751
|
-
const
|
|
143751
|
+
const results2 = {}, statuses2 = {}, errors3 = {};
|
|
143752
143752
|
for (const id15 of ids3) {
|
|
143753
143753
|
try {
|
|
143754
|
-
|
|
143754
|
+
results2[id15] = project7(nativeRecord(c.env.ctx, find4(c.env.ctx, kind2, id15, accountId(c))), projection2);
|
|
143755
143755
|
statuses2[id15] = 200;
|
|
143756
143756
|
} catch (e) {
|
|
143757
143757
|
if (!(e instanceof LiError)) throw e;
|
|
@@ -143760,7 +143760,7 @@ function batchGet(c, kind2, ids3, projection2) {
|
|
|
143760
143760
|
statuses2[id15] = e.status;
|
|
143761
143761
|
}
|
|
143762
143762
|
}
|
|
143763
|
-
return json12({ results, statuses: statuses2, errors: errors3 });
|
|
143763
|
+
return json12({ results: results2, statuses: statuses2, errors: errors3 });
|
|
143764
143764
|
}
|
|
143765
143765
|
function collectionRead(kind2, c) {
|
|
143766
143766
|
const ctx = c.env.ctx;
|
|
@@ -144209,13 +144209,13 @@ function selector(raw3) {
|
|
|
144209
144209
|
}
|
|
144210
144210
|
function contextLinks(links4, selected3) {
|
|
144211
144211
|
const systems = /* @__PURE__ */ new Map();
|
|
144212
|
-
for (const
|
|
144212
|
+
for (const link8 of links4) for (const item2 of link8.objects) {
|
|
144213
144213
|
if (selected3.context === "Extended" && !selected3.timing.includes(item2.timing)) continue;
|
|
144214
|
-
const list19 = systems.get(
|
|
144214
|
+
const list19 = systems.get(link8.system) ?? [];
|
|
144215
144215
|
if (selected3.context === "Basic") {
|
|
144216
144216
|
if (!list19.some((existing3) => existing3.objectType === item2.objectType && existing3.objectId === item2.objectId)) list19.push({ objectType: item2.objectType, objectId: item2.objectId });
|
|
144217
144217
|
} else list19.push(item2);
|
|
144218
|
-
systems.set(
|
|
144218
|
+
systems.set(link8.system, list19);
|
|
144219
144219
|
}
|
|
144220
144220
|
return [...systems].map(([system, objects]) => ({ system, objects }));
|
|
144221
144221
|
}
|
|
@@ -144482,7 +144482,7 @@ function search4(c) {
|
|
|
144482
144482
|
if (q2.name === void 0 || q2.name.trim() === "") invalid17("Parameter 'name' is required");
|
|
144483
144483
|
only2(q2.format, "format", ["json"]);
|
|
144484
144484
|
const count14 = integer7(q2.count, "count", 10, 1, 100), needle = q2.name.trim().toLowerCase();
|
|
144485
|
-
const
|
|
144485
|
+
const results2 = needle.length < 2 ? [] : seed44.locations.filter((location) => location.name.toLowerCase().includes(needle) && (q2.countryCode === void 0 || location.country_code === q2.countryCode)).sort((a, b) => Number(b.name.toLowerCase().startsWith(needle)) - Number(a.name.toLowerCase().startsWith(needle)) || (b.population ?? 0) - (a.population ?? 0) || a.id - b.id).slice(0, count14).map((location) => ({
|
|
144486
144486
|
id: location.id,
|
|
144487
144487
|
name: location.name,
|
|
144488
144488
|
latitude: location.latitude,
|
|
@@ -144495,7 +144495,7 @@ function search4(c) {
|
|
|
144495
144495
|
country: location.country,
|
|
144496
144496
|
...location.admin1 === void 0 ? {} : { admin1: location.admin1 }
|
|
144497
144497
|
}));
|
|
144498
|
-
return { ...
|
|
144498
|
+
return { ...results2.length ? { results: results2 } : {}, generationtime_ms: 0.1 };
|
|
144499
144499
|
}
|
|
144500
144500
|
function reply2(body8, status6 = 200) {
|
|
144501
144501
|
return new Response(JSON.stringify(body8), { status: status6, headers: { "content-type": "application/json; charset=utf-8", ...status6 === 501 ? { [GAP_HEADER]: "1" } : {} } });
|
|
@@ -148585,20 +148585,20 @@ function deleteObjects(call4) {
|
|
|
148585
148585
|
const objects = childrenNamed(root3, "Object");
|
|
148586
148586
|
if (objects.length === 0 || objects.length > 1e3) throw new S3Error("MalformedXML");
|
|
148587
148587
|
const quiet = child2(root3, "Quiet")?.text.trim() === "true";
|
|
148588
|
-
const
|
|
148588
|
+
const results2 = [];
|
|
148589
148589
|
for (const item2 of objects) {
|
|
148590
148590
|
const key5 = child2(item2, "Key")?.text;
|
|
148591
148591
|
if (key5 === void 0) throw new S3Error("MalformedXML");
|
|
148592
148592
|
const version6 = child2(item2, "VersionId")?.text;
|
|
148593
148593
|
if (version6 !== void 0 && version6 !== "null") unsupported15("deleting object versions");
|
|
148594
148594
|
if (bucket4.access !== "read-write") {
|
|
148595
|
-
|
|
148595
|
+
results2.push(node3("Error", [el("Key", key5), el("Code", "AccessDenied"), el("Message", "Access Denied")]));
|
|
148596
148596
|
continue;
|
|
148597
148597
|
}
|
|
148598
148598
|
call4.ctx.store.db.prepare("DELETE FROM s3_objects WHERE bucket = ? AND key = ?").run(bucket4.name, key5);
|
|
148599
|
-
if (!quiet)
|
|
148599
|
+
if (!quiet) results2.push(node3("Deleted", [el("Key", key5)]));
|
|
148600
148600
|
}
|
|
148601
|
-
return xml(call4, node3("DeleteResult",
|
|
148601
|
+
return xml(call4, node3("DeleteResult", results2, true));
|
|
148602
148602
|
}
|
|
148603
148603
|
function getObjectTagging(call4) {
|
|
148604
148604
|
const item2 = objectFor(call4, bucketFor2(call4, "read"));
|
|
@@ -151574,17 +151574,17 @@ var init_connect_account_state = __esm({
|
|
|
151574
151574
|
});
|
|
151575
151575
|
|
|
151576
151576
|
// packages/server/src/twins/stripe/connect-onboarding.ts
|
|
151577
|
-
function html2(ctx, a,
|
|
151577
|
+
function html2(ctx, a, link8) {
|
|
151578
151578
|
const input5 = (name5, label7, value6) => `<label>${label7}<input name="${name5}" value="${escape7(value6)}" required></label>`;
|
|
151579
151579
|
return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Connect onboarding</title>
|
|
151580
151580
|
<style>body{font:16px system-ui;background:#f6f7fb;color:#202334;margin:0;padding:32px 16px}main{max-width:460px;margin:auto;background:white;padding:28px;border-radius:16px;box-shadow:0 8px 40px #17204012}h1{font-size:27px;margin-top:8px}label{display:block;margin:14px 0;font-size:14px}input,select{display:block;box-sizing:border-box;width:100%;padding:10px;margin-top:5px;border:1px solid #c9cbd6;border-radius:6px;font:inherit}button{font:inherit;padding:12px 20px;border-radius:8px;border:0;background:#635bff;color:white;cursor:pointer;margin:12px 0 20px}a{color:#5145cd}.note{color:#687083;font-size:14px}</style></head><body><main><p class="note">Ancha \xB7 Test onboarding</p><h1>Set up your account</h1><p>Confirm your test identity and choose a payout bank.</p>
|
|
151581
|
-
<form method="post"><input type="hidden" name="session" value="${escape7(
|
|
151581
|
+
<form method="post"><input type="hidden" name="session" value="${escape7(link8.__session)}">
|
|
151582
151582
|
${input5("first_name", "First name", a.individual?.first_name ?? "Laura")}${input5("last_name", "Last name", a.individual?.last_name ?? "Chen")}
|
|
151583
151583
|
${input5("email", "Email", a.email ?? "seller@example.test")}${input5("phone", "Phone", "0000000000")}${input5("dob", "Date of birth (YYYY-MM-DD)", "1901-01-01")}
|
|
151584
151584
|
${input5("ssn", "Test SSN", "000000000")}${input5("address", "Address", "address_full_match")}
|
|
151585
151585
|
<label>Payout bank<select name="bank">${Object.entries(TEST_BANKS).map(([key5, bank2]) => `<option value="${key5}">${escape7(key5.replaceAll("_", " "))} \xB7 ${bank2.number}</option>`).join("")}</select></label>
|
|
151586
151586
|
<p class="note">Submitting accepts the Stripe terms for this test account.</p><button type="submit">Submit</button></form>
|
|
151587
|
-
<a href="${escape7(
|
|
151587
|
+
<a href="${escape7(link8.return_url)}">Return to ${escape7(load2(ctx, "__account")?.name ?? "platform")}</a></main></body></html>`;
|
|
151588
151588
|
}
|
|
151589
151589
|
function registerOnboardingPage(app2) {
|
|
151590
151590
|
app2.on(["GET", "POST"], "/connect/onboard/:id", async (c) => {
|
|
@@ -151592,9 +151592,9 @@ function registerOnboardingPage(app2) {
|
|
|
151592
151592
|
const body8 = c.req.method === "POST" ? new URLSearchParams(await c.req.text()) : void 0;
|
|
151593
151593
|
try {
|
|
151594
151594
|
return withMutation(ctx, () => {
|
|
151595
|
-
const
|
|
151596
|
-
if (!
|
|
151597
|
-
const l =
|
|
151595
|
+
const link8 = load2(ctx, c.req.param("id"));
|
|
151596
|
+
if (!link8 || link8.object !== "__connect_link") invalid10("Invalid account link.");
|
|
151597
|
+
const l = link8;
|
|
151598
151598
|
const a = requireAccount(ctx, l.account);
|
|
151599
151599
|
if (!body8) {
|
|
151600
151600
|
if (l.__visited || nowSeconds(ctx) >= l.expires_at) return redirect2(l.refresh_url);
|
|
@@ -151677,7 +151677,7 @@ var init_connect_onboarding = __esm({
|
|
|
151677
151677
|
const fields14 = oneOf(options5?.fields, "collection_options[fields]", ["currently_due", "eventually_due"]) ?? collect4 ?? "currently_due";
|
|
151678
151678
|
const future = oneOf(options5?.future_requirements, "collection_options[future_requirements]", ["include", "omit"]) ?? "omit";
|
|
151679
151679
|
const created4 = nowSeconds(ctx), id15 = newId(ctx, "link");
|
|
151680
|
-
const
|
|
151680
|
+
const link8 = save3(ctx, {
|
|
151681
151681
|
id: id15,
|
|
151682
151682
|
object: "__connect_link",
|
|
151683
151683
|
account: a.id,
|
|
@@ -151691,7 +151691,7 @@ var init_connect_onboarding = __esm({
|
|
|
151691
151691
|
__visited: false,
|
|
151692
151692
|
__submitted: false
|
|
151693
151693
|
});
|
|
151694
|
-
return { object: "account_link", created: created4, expires_at:
|
|
151694
|
+
return { object: "account_link", created: created4, expires_at: link8.expires_at, url: `/connect/onboard/${id15}` };
|
|
151695
151695
|
}, "Single-use account_onboarding links for Express and Custom accounts; account_update for Custom; requirement collection options and world-clock expiry.");
|
|
151696
151696
|
escape7 = (s3) => String(s3).replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
151697
151697
|
redirect2 = (url4) => new Response(null, { status: 303, headers: { location: url4, "cache-control": "no-store" } });
|
|
@@ -155778,8 +155778,8 @@ function listUsers3(call4) {
|
|
|
155778
155778
|
const page20 = int4("page", 1), per = Math.min(int4("per_page", 50), 1e3);
|
|
155779
155779
|
const total6 = Number(query2(call4.ctx, "select count(*) as n from auth.users where deleted_at is null")[0].n), last = Math.max(1, Math.ceil(total6 / per));
|
|
155780
155780
|
const users5 = query2(call4.ctx, "select * from auth.users where deleted_at is null order by created_at desc, id limit $1 offset $2", [String(per), String((page20 - 1) * per)]).map((u) => userJson(call4.ctx, u));
|
|
155781
|
-
const
|
|
155782
|
-
return json4(200, { users: users5, aud: "authenticated" }, { "x-total-count": String(total6), link: [
|
|
155781
|
+
const link8 = (n2, rel) => `<${authRoot(call4.ctx)}/admin/users?page=${n2}&per_page=${per}>; rel="${rel}"`;
|
|
155782
|
+
return json4(200, { users: users5, aud: "authenticated" }, { "x-total-count": String(total6), link: [link8(1, "first"), ...page20 > 1 ? [link8(page20 - 1, "prev")] : [], ...page20 < last ? [link8(page20 + 1, "next")] : [], link8(last, "last")].join(",") });
|
|
155783
155783
|
}
|
|
155784
155784
|
function generateLink(call4, send3) {
|
|
155785
155785
|
const data7 = body4(call4, send3 ? ["email", "data"] : ["email", "type", "password", "data", "new_email", "redirectTo"]), address9 = email12(data7.email), type = send3 ? "invite" : data7.type;
|
|
@@ -156687,12 +156687,12 @@ function paginate4(call4, items2, render3, extra2 = {}) {
|
|
|
156687
156687
|
if (!Number.isInteger(perPage) || perPage < 1) throw invalid21("per_page", "must be a positive integer");
|
|
156688
156688
|
if (!Number.isInteger(page20) || page20 < 1) throw invalid21("page", "must be a positive integer");
|
|
156689
156689
|
const last = Math.max(1, Math.ceil(items2.length / perPage));
|
|
156690
|
-
const
|
|
156690
|
+
const link8 = (target6) => {
|
|
156691
156691
|
const url4 = new URL(`${call4.ctx.serviceUrl ?? ""}${call4.url.pathname}${call4.url.search}`);
|
|
156692
156692
|
url4.searchParams.set("page", String(target6));
|
|
156693
156693
|
return url4.href;
|
|
156694
156694
|
};
|
|
156695
|
-
return json15({ data: items2.slice((page20 - 1) * perPage, page20 * perPage).map(render3), ...extra2, pagination: { first:
|
|
156695
|
+
return json15({ data: items2.slice((page20 - 1) * perPage, page20 * perPage).map(render3), ...extra2, pagination: { first: link8(1), last: link8(last), prev: page20 > 1 ? link8(page20 - 1) : null, next: page20 < last ? link8(page20 + 1) : null } });
|
|
156696
156696
|
}
|
|
156697
156697
|
function monitorJson(ctx, source) {
|
|
156698
156698
|
const frequency = source.check_frequency ?? 60, now11 = ctx.clock.nowMs();
|
|
@@ -157591,9 +157591,9 @@ function list14(items2, type, cursor4, size2, path9, extra2 = {}) {
|
|
|
157591
157591
|
start2 = items2.findIndex((item2) => item2.id === cursor4);
|
|
157592
157592
|
if (start2 < 0) invalid22(`The start_cursor provided is invalid: ${cursor4}`);
|
|
157593
157593
|
}
|
|
157594
|
-
const
|
|
157594
|
+
const results2 = items2.slice(start2, start2 + size2);
|
|
157595
157595
|
const next2 = items2[start2 + size2];
|
|
157596
|
-
return { object: "list", results, next_cursor: next2?.id ?? null, has_more: next2 !== void 0, type, [type]: {}, ...extra2 };
|
|
157596
|
+
return { object: "list", results: results2, next_cursor: next2?.id ?? null, has_more: next2 !== void 0, type, [type]: {}, ...extra2 };
|
|
157597
157597
|
}
|
|
157598
157598
|
function requestId2(ctx, c, body8) {
|
|
157599
157599
|
const h = createHash43("sha256").update(`${ctx.envId}
|
|
@@ -157691,8 +157691,8 @@ function richText(ctx, input5, path9) {
|
|
|
157691
157691
|
const content2 = item2.text?.content;
|
|
157692
157692
|
if (typeof content2 !== "string") shouldBe(`${at6}.text.content`, "a string", content2);
|
|
157693
157693
|
if (content2.length > 2e3) shouldBe(`${at6}.text.content.length`, "\u2264 `2000`", content2.length);
|
|
157694
|
-
const
|
|
157695
|
-
return { type: "text", text: { content: content2, link:
|
|
157694
|
+
const link8 = item2.text.link?.url ? { url: String(item2.text.link.url) } : null;
|
|
157695
|
+
return { type: "text", text: { content: content2, link: link8 }, annotations, plain_text: content2, href: link8?.url ?? null };
|
|
157696
157696
|
}
|
|
157697
157697
|
if (type === "mention") {
|
|
157698
157698
|
const m = item2.mention ?? {};
|
|
@@ -159794,13 +159794,13 @@ function dumpState25(ctx) {
|
|
|
159794
159794
|
...entry3.kind === "file" && entry3.content && TEXT2.test(entry3.path_lower) && { content: entry3.content.toString("utf8") },
|
|
159795
159795
|
...entry3.shared_folder_id && { sharedFolderId: entry3.shared_folder_id }
|
|
159796
159796
|
})),
|
|
159797
|
-
sharedLinks: db3.prepare("SELECT * FROM dbx_links ORDER BY created_ms, url").all().map((
|
|
159798
|
-
path: display.get(
|
|
159799
|
-
url:
|
|
159800
|
-
audience:
|
|
159801
|
-
access:
|
|
159802
|
-
expires: iso27(
|
|
159803
|
-
password:
|
|
159797
|
+
sharedLinks: db3.prepare("SELECT * FROM dbx_links ORDER BY created_ms, url").all().map((link8) => ({
|
|
159798
|
+
path: display.get(link8.path_lower) ?? link8.path_lower,
|
|
159799
|
+
url: link8.url,
|
|
159800
|
+
audience: link8.audience,
|
|
159801
|
+
access: link8.access,
|
|
159802
|
+
expires: iso27(link8.expires_ms),
|
|
159803
|
+
password: link8.has_password === 1
|
|
159804
159804
|
})),
|
|
159805
159805
|
sharedFolders: db3.prepare("SELECT * FROM dbx_shared ORDER BY created_ms").all().map((folder2) => ({
|
|
159806
159806
|
id: folder2.shared_folder_id,
|
|
@@ -160189,12 +160189,12 @@ function searchContinue(call4) {
|
|
|
160189
160189
|
throw new DropboxError(400, `Error in call to API function "files/search/continue_v2": Invalid "cursor" parameter`);
|
|
160190
160190
|
}
|
|
160191
160191
|
}
|
|
160192
|
-
function linkJson(ctx,
|
|
160193
|
-
const entry3 = getEntry(ctx,
|
|
160194
|
-
const visibility =
|
|
160192
|
+
function linkJson(ctx, link8) {
|
|
160193
|
+
const entry3 = getEntry(ctx, link8.path_lower);
|
|
160194
|
+
const visibility = link8.has_password ? "password" : link8.audience === "team" ? "team_only" : link8.audience === "no_one" ? "no_one" : "public";
|
|
160195
160195
|
return {
|
|
160196
160196
|
".tag": entry3.kind,
|
|
160197
|
-
url:
|
|
160197
|
+
url: link8.url,
|
|
160198
160198
|
id: entry3.id,
|
|
160199
160199
|
name: nameOf3(entry3.path_display),
|
|
160200
160200
|
path_lower: entry3.path_lower,
|
|
@@ -160202,8 +160202,8 @@ function linkJson(ctx, link9) {
|
|
|
160202
160202
|
can_revoke: true,
|
|
160203
160203
|
resolved_visibility: { ".tag": visibility },
|
|
160204
160204
|
requested_visibility: { ".tag": visibility },
|
|
160205
|
-
effective_audience: { ".tag":
|
|
160206
|
-
link_access_level: { ".tag":
|
|
160205
|
+
effective_audience: { ".tag": link8.audience },
|
|
160206
|
+
link_access_level: { ".tag": link8.access },
|
|
160207
160207
|
can_set_expiry: true,
|
|
160208
160208
|
can_remove_expiry: true,
|
|
160209
160209
|
allow_download: true,
|
|
@@ -160213,11 +160213,11 @@ function linkJson(ctx, link9) {
|
|
|
160213
160213
|
team_restricts_comments: false,
|
|
160214
160214
|
can_set_password: true,
|
|
160215
160215
|
can_remove_password: true,
|
|
160216
|
-
require_password:
|
|
160216
|
+
require_password: link8.has_password === 1,
|
|
160217
160217
|
can_use_extended_sharing_controls: false
|
|
160218
160218
|
},
|
|
160219
160219
|
...entry3.kind === "file" && { client_modified: seconds2(entry3.client_modified_ms), server_modified: seconds2(entry3.server_modified_ms), rev: entry3.rev, size: entry3.content?.length ?? 0 },
|
|
160220
|
-
...
|
|
160220
|
+
...link8.expires_ms !== null && { expires: seconds2(link8.expires_ms) }
|
|
160221
160221
|
};
|
|
160222
160222
|
}
|
|
160223
160223
|
function linkSettings(call4, settings) {
|
|
@@ -160253,7 +160253,7 @@ function createLink(call4) {
|
|
|
160253
160253
|
const settings = linkSettings(call4, args.settings);
|
|
160254
160254
|
const current = call4.ctx.store.db.prepare("SELECT * FROM dbx_links WHERE path_lower = ?").get(entry3.path_lower);
|
|
160255
160255
|
if (current) throw endpoint("shared_link_already_exists/metadata", { ".tag": "shared_link_already_exists", shared_link_already_exists: { ".tag": "metadata", metadata: linkJson(call4.ctx, current) } });
|
|
160256
|
-
const
|
|
160256
|
+
const link8 = {
|
|
160257
160257
|
url: linkUrl(entry3.id, entry3.kind, entry3.path_display),
|
|
160258
160258
|
path_lower: entry3.path_lower,
|
|
160259
160259
|
audience: settings.audience ?? "public",
|
|
@@ -160262,8 +160262,8 @@ function createLink(call4) {
|
|
|
160262
160262
|
has_password: settings.password ? 1 : 0,
|
|
160263
160263
|
created_ms: call4.ctx.clock.nowMs()
|
|
160264
160264
|
};
|
|
160265
|
-
call4.ctx.store.db.prepare("INSERT INTO dbx_links (url, path_lower, audience, access, expires_ms, has_password, created_ms) VALUES (?, ?, ?, ?, ?, ?, ?)").run(
|
|
160266
|
-
return json18(linkJson(call4.ctx,
|
|
160265
|
+
call4.ctx.store.db.prepare("INSERT INTO dbx_links (url, path_lower, audience, access, expires_ms, has_password, created_ms) VALUES (?, ?, ?, ?, ?, ?, ?)").run(link8.url, link8.path_lower, link8.audience, link8.access, link8.expires_ms, link8.has_password, link8.created_ms);
|
|
160266
|
+
return json18(linkJson(call4.ctx, link8));
|
|
160267
160267
|
}
|
|
160268
160268
|
function listLinks(call4) {
|
|
160269
160269
|
const args = fields9(call4, ["path", "cursor", "direct_only"]);
|
|
@@ -160271,26 +160271,26 @@ function listLinks(call4) {
|
|
|
160271
160271
|
let links4 = call4.ctx.store.db.prepare("SELECT * FROM dbx_links ORDER BY created_ms, url").all();
|
|
160272
160272
|
if (args.path !== void 0) {
|
|
160273
160273
|
const entry3 = existing(call4, args.path);
|
|
160274
|
-
links4 = links4.filter((
|
|
160274
|
+
links4 = links4.filter((link8) => link8.path_lower === entry3.path_lower || !bool5(call4, args.direct_only, "direct_only", false) && entry3.path_lower.startsWith(`${link8.path_lower}/`));
|
|
160275
160275
|
}
|
|
160276
|
-
return json18({ links: links4.map((
|
|
160276
|
+
return json18({ links: links4.map((link8) => linkJson(call4.ctx, link8)), has_more: false });
|
|
160277
160277
|
}
|
|
160278
160278
|
function linkFor(call4, url4) {
|
|
160279
|
-
const
|
|
160280
|
-
if (!
|
|
160281
|
-
return
|
|
160279
|
+
const link8 = call4.ctx.store.db.prepare("SELECT * FROM dbx_links WHERE url = ?").get(String(url4));
|
|
160280
|
+
if (!link8) throw endpoint("shared_link_not_found", { ".tag": "shared_link_not_found" });
|
|
160281
|
+
return link8;
|
|
160282
160282
|
}
|
|
160283
160283
|
function modifyLink(call4) {
|
|
160284
160284
|
const args = fields9(call4, ["url", "settings", "remove_expiration"]);
|
|
160285
|
-
const
|
|
160285
|
+
const link8 = linkFor(call4, args.url), settings = linkSettings(call4, args.settings);
|
|
160286
160286
|
const next2 = {
|
|
160287
|
-
...
|
|
160288
|
-
audience: settings.audience ??
|
|
160289
|
-
access: settings.access ??
|
|
160290
|
-
has_password: settings.password === void 0 ?
|
|
160291
|
-
expires_ms: bool5(call4, args.remove_expiration, "remove_expiration", false) ? null : settings.expires ??
|
|
160287
|
+
...link8,
|
|
160288
|
+
audience: settings.audience ?? link8.audience,
|
|
160289
|
+
access: settings.access ?? link8.access,
|
|
160290
|
+
has_password: settings.password === void 0 ? link8.has_password : settings.password ? 1 : 0,
|
|
160291
|
+
expires_ms: bool5(call4, args.remove_expiration, "remove_expiration", false) ? null : settings.expires ?? link8.expires_ms
|
|
160292
160292
|
};
|
|
160293
|
-
call4.ctx.store.db.prepare("UPDATE dbx_links SET audience = ?, access = ?, expires_ms = ?, has_password = ? WHERE url = ?").run(next2.audience, next2.access, next2.expires_ms, next2.has_password,
|
|
160293
|
+
call4.ctx.store.db.prepare("UPDATE dbx_links SET audience = ?, access = ?, expires_ms = ?, has_password = ? WHERE url = ?").run(next2.audience, next2.access, next2.expires_ms, next2.has_password, link8.url);
|
|
160294
160294
|
return json18(linkJson(call4.ctx, next2));
|
|
160295
160295
|
}
|
|
160296
160296
|
function revokeLink(call4) {
|
|
@@ -162142,9 +162142,9 @@ function delta(ctx, mail, fid, url4, headers) {
|
|
|
162142
162142
|
const next2 = done ? { ...state3, since: state3.upto, rows: null, done: true, index: 0 } : { ...state3, index: state3.index + n2 };
|
|
162143
162143
|
const id15 = newId4(ctx);
|
|
162144
162144
|
ctx.store.db.prepare("INSERT INTO outlook_delta VALUES (?, ?, ?, ?)").run(id15, mail, fid, JSON.stringify(next2));
|
|
162145
|
-
const
|
|
162146
|
-
|
|
162147
|
-
return json20({ "@odata.context": context2("Collection(microsoft.graph.message)"), value: value6, [done ? "@odata.deltaLink" : "@odata.nextLink"]:
|
|
162145
|
+
const link8 = new URL(`${ctx.serviceUrl}${url4.pathname}`);
|
|
162146
|
+
link8.searchParams.set(done ? "$deltatoken" : "$skiptoken", id15);
|
|
162147
|
+
return json20({ "@odata.context": context2("Collection(microsoft.graph.message)"), value: value6, [done ? "@odata.deltaLink" : "@odata.nextLink"]: link8.href });
|
|
162148
162148
|
}
|
|
162149
162149
|
function route7(ctx, method2, url4, headers, body8, auth2 = "delegated") {
|
|
162150
162150
|
const parts3 = url4.pathname.split("/").filter(Boolean).map(decodeURIComponent);
|
|
@@ -166493,7 +166493,7 @@ function paginate5(call4, rows35, options5) {
|
|
|
166493
166493
|
}
|
|
166494
166494
|
const page20 = items2.slice(start2, end);
|
|
166495
166495
|
const token5 = (row2) => Buffer.from(JSON.stringify({ dateOffset: iso12(key5(row2)), idOffset: row2.id })).toString("base64url");
|
|
166496
|
-
const
|
|
166496
|
+
const link8 = (field6, row2) => {
|
|
166497
166497
|
const url4 = new URL(`${call4.ctx.serviceUrl ?? call4.url.origin}${call4.url.pathname}`);
|
|
166498
166498
|
for (const [name5, value6] of call4.url.searchParams) if (name5 !== "before" && name5 !== "after") url4.searchParams.append(name5, value6);
|
|
166499
166499
|
if (!url4.searchParams.has("limit")) url4.searchParams.set("limit", String(limit2));
|
|
@@ -166503,8 +166503,8 @@ function paginate5(call4, rows35, options5) {
|
|
|
166503
166503
|
return json22({
|
|
166504
166504
|
data: page20.map(options5.render),
|
|
166505
166505
|
object: "list",
|
|
166506
|
-
next_url: page20.length && end < items2.length ?
|
|
166507
|
-
previous_url: page20.length && start2 > 0 ?
|
|
166506
|
+
next_url: page20.length && end < items2.length ? link8("after", page20.at(-1)) : null,
|
|
166507
|
+
previous_url: page20.length && start2 > 0 ? link8("before", page20[0]) : null,
|
|
166508
166508
|
count: page20.length,
|
|
166509
166509
|
...total6 && { total_count: items2.length }
|
|
166510
166510
|
});
|
|
@@ -174087,7 +174087,7 @@ function integer12(value6, name5, min, max) {
|
|
|
174087
174087
|
}
|
|
174088
174088
|
function paginate7(call4, key5, items2, render3, sideload = () => ({})) {
|
|
174089
174089
|
const params10 = call4.url.searchParams, base6 = `${api3(call4.ctx)}${call4.path.slice("/api/v2".length)}.json`;
|
|
174090
|
-
const
|
|
174090
|
+
const link8 = (set2) => {
|
|
174091
174091
|
const url4 = new URL(base6);
|
|
174092
174092
|
for (const [name5, value6] of params10) if (!name5.startsWith("page")) url4.searchParams.append(name5, value6);
|
|
174093
174093
|
for (const [name5, value6] of Object.entries(set2)) url4.searchParams.set(name5, value6);
|
|
@@ -174108,15 +174108,15 @@ function paginate7(call4, key5, items2, render3, sideload = () => ({})) {
|
|
|
174108
174108
|
[key5]: page21.map(render3),
|
|
174109
174109
|
...sideload(page21),
|
|
174110
174110
|
meta: { has_more: more, after_cursor: page21.length ? encode5(end - 1) : null, before_cursor: page21.length ? encode5(start3) : null },
|
|
174111
|
-
links: { prev: start3 > 0 && page21.length ?
|
|
174111
|
+
links: { prev: start3 > 0 && page21.length ? link8({ "page[before]": encode5(start3), "page[size]": String(size2) }) : null, next: more && page21.length ? link8({ "page[after]": encode5(end - 1), "page[size]": String(size2) }) : null }
|
|
174112
174112
|
});
|
|
174113
174113
|
}
|
|
174114
174114
|
const perPage = integer12(params10.get("per_page"), "per_page", 1, 100) ?? 100, number7 = integer12(params10.get("page"), "page", 1, 1e5) ?? 1, start2 = (number7 - 1) * perPage, page20 = items2.slice(start2, start2 + perPage);
|
|
174115
174115
|
return json27({
|
|
174116
174116
|
[key5]: page20.map(render3),
|
|
174117
174117
|
...sideload(page20),
|
|
174118
|
-
next_page: start2 + perPage < items2.length ?
|
|
174119
|
-
previous_page: number7 > 1 ?
|
|
174118
|
+
next_page: start2 + perPage < items2.length ? link8({ page: String(number7 + 1), per_page: String(perPage) }) : null,
|
|
174119
|
+
previous_page: number7 > 1 ? link8({ page: String(number7 - 1), per_page: String(perPage) }) : null,
|
|
174120
174120
|
count: items2.length
|
|
174121
174121
|
});
|
|
174122
174122
|
}
|
|
@@ -174427,18 +174427,18 @@ function search9(call4) {
|
|
|
174427
174427
|
const filters2 = terms2.filter((term2) => !["type", "order_by", "sort"].includes(term2.key ?? ""));
|
|
174428
174428
|
const keep2 = (item2, matches11) => filters2.every((term2) => matches11(scope3, item2, term2) !== term2.negate);
|
|
174429
174429
|
const wants = (type) => !types.length || types.includes(type);
|
|
174430
|
-
const
|
|
174430
|
+
const results2 = [];
|
|
174431
174431
|
if (wants("ticket")) {
|
|
174432
|
-
for (const ticket3 of liveTickets(call4.ctx)) if (keep2(ticket3, ticketMatches))
|
|
174432
|
+
for (const ticket3 of liveTickets(call4.ctx)) if (keep2(ticket3, ticketMatches)) results2.push({ type: "ticket", created: ticket3.created_ms, updated: ticket3.updated_ms, row: ticket3 });
|
|
174433
174433
|
}
|
|
174434
174434
|
if (wants("user")) {
|
|
174435
|
-
for (const user9 of scope3.users.values()) if (keep2(user9, userMatches2))
|
|
174435
|
+
for (const user9 of scope3.users.values()) if (keep2(user9, userMatches2)) results2.push({ type: "user", created: user9.created_ms, updated: user9.updated_ms, row: user9 });
|
|
174436
174436
|
}
|
|
174437
174437
|
if (wants("organization")) {
|
|
174438
|
-
for (const org5 of scope3.organizations.values()) if (keep2(org5, organizationMatches))
|
|
174438
|
+
for (const org5 of scope3.organizations.values()) if (keep2(org5, organizationMatches)) results2.push({ type: "organization", created: org5.created_ms, updated: org5.updated_ms, row: org5 });
|
|
174439
174439
|
}
|
|
174440
174440
|
if (wants("group")) {
|
|
174441
|
-
for (const group5 of scope3.groups.values()) if (keep2(group5, groupMatches))
|
|
174441
|
+
for (const group5 of scope3.groups.values()) if (keep2(group5, groupMatches)) results2.push({ type: "group", created: group5.created_ms, updated: group5.created_ms, row: group5 });
|
|
174442
174442
|
}
|
|
174443
174443
|
if (sortBy2 !== null && !["created_at", "updated_at", "priority", "status", "ticket_type"].includes(sortBy2)) throw badRequest(`sort_by must be created_at, updated_at, priority, status or ticket_type`);
|
|
174444
174444
|
const descending = sortOrder !== "asc";
|
|
@@ -174457,13 +174457,13 @@ function search9(call4) {
|
|
|
174457
174457
|
return item2.updated;
|
|
174458
174458
|
}
|
|
174459
174459
|
};
|
|
174460
|
-
|
|
174460
|
+
results2.sort((a, b) => {
|
|
174461
174461
|
const x = key5(a), y = key5(b);
|
|
174462
174462
|
return (x < y ? -1 : x > y ? 1 : 0) * (descending ? -1 : 1);
|
|
174463
174463
|
});
|
|
174464
174464
|
const perPage = integer12(params10.get("per_page"), "per_page", 1, 100) ?? 100, page20 = integer12(params10.get("page"), "page", 1, 1e3) ?? 1;
|
|
174465
174465
|
if (page20 * perPage > 1e3) throw new ZendeskError(422, { error: "InvalidSearch", description: "Requested response size was greater than Search Response Limits" });
|
|
174466
|
-
return paginate7(call4, "results",
|
|
174466
|
+
return paginate7(call4, "results", results2, (item2) => {
|
|
174467
174467
|
const shown4 = item2.type === "ticket" ? ticketJson(call4.ctx, item2.row) : item2.type === "user" ? userJson4(call4.ctx, item2.row) : item2.type === "organization" ? organizationJson(call4.ctx, item2.row) : groupJson2(call4.ctx, item2.row);
|
|
174468
174468
|
return { ...shown4, result_type: item2.type };
|
|
174469
174469
|
}, () => ({ facets: null }));
|
|
@@ -175937,14 +175937,14 @@ function pageV2(call4, key5, items2, render3) {
|
|
|
175937
175937
|
const query12 = call4.url.searchParams, size2 = Number(query12.get("PageSize") ?? 50), number7 = Number(query12.get("Page") ?? 0);
|
|
175938
175938
|
if (!Number.isInteger(size2) || size2 < 1 || size2 > 1e3 || !Number.isInteger(number7) || number7 < 0) throw new TwilioError(400, 20001, "Invalid paging parameters");
|
|
175939
175939
|
const slice = items2.slice(number7 * size2, (number7 + 1) * size2), base6 = `${call4.ctx.serviceUrl ?? ""}${call4.path}`;
|
|
175940
|
-
const
|
|
175940
|
+
const link8 = (page20) => `${base6}?PageSize=${size2}&Page=${page20}`;
|
|
175941
175941
|
return json29({ [key5]: slice.map(render3), meta: {
|
|
175942
175942
|
page: number7,
|
|
175943
175943
|
page_size: size2,
|
|
175944
|
-
first_page_url:
|
|
175945
|
-
previous_page_url: number7 > 0 ?
|
|
175946
|
-
url:
|
|
175947
|
-
next_page_url: (number7 + 1) * size2 < items2.length ?
|
|
175944
|
+
first_page_url: link8(0),
|
|
175945
|
+
previous_page_url: number7 > 0 ? link8(number7 - 1) : null,
|
|
175946
|
+
url: link8(number7),
|
|
175947
|
+
next_page_url: (number7 + 1) * size2 < items2.length ? link8(number7 + 1) : null,
|
|
175948
175948
|
key: key5
|
|
175949
175949
|
} });
|
|
175950
175950
|
}
|
|
@@ -178193,12 +178193,12 @@ function paginate8(r2, items2, { param: param4 = "per_page", fallback = 100, max
|
|
|
178193
178193
|
}
|
|
178194
178194
|
const page20 = items2.slice(start2, start2 + limit2);
|
|
178195
178195
|
const at6 = (offset20, prev) => offset20 % limit2 === 0 ? `${limit2}:${offset20 / limit2}:${prev ? 1 : 0}` : `1:${offset20}:${prev ? 1 : 0}`;
|
|
178196
|
-
const
|
|
178196
|
+
const link8 = (rel, c, results2) => {
|
|
178197
178197
|
const params10 = new URLSearchParams(r2.url.search);
|
|
178198
178198
|
params10.set("cursor", c);
|
|
178199
|
-
return `<${base5(r2.ctx)}${r2.url.pathname}?${String(params10).replace(/%3A/gi, ":")}>; rel="${rel}"; results="${
|
|
178199
|
+
return `<${base5(r2.ctx)}${r2.url.pathname}?${String(params10).replace(/%3A/gi, ":")}>; rel="${rel}"; results="${results2}"; cursor="${c}"`;
|
|
178200
178200
|
};
|
|
178201
|
-
const previous =
|
|
178201
|
+
const previous = link8("previous", at6(Math.max(0, start2 - limit2), true), start2 > 0), following = link8("next", at6(start2 + limit2, false), start2 + limit2 < items2.length);
|
|
178202
178202
|
return new Reply(200, page20.map(map2), { link: `${previous}, ${following}` });
|
|
178203
178203
|
}
|
|
178204
178204
|
function window4(r2, fallbackMs) {
|
|
@@ -180375,10 +180375,10 @@ var init_model7 = __esm({
|
|
|
180375
180375
|
if (!cells) this.#cells.set(record33.id, cells = JSON.parse(record33.cells));
|
|
180376
180376
|
return cells;
|
|
180377
180377
|
}
|
|
180378
|
-
linked(record33,
|
|
180379
|
-
const ids3 = this.cells(record33)[
|
|
180378
|
+
linked(record33, link8) {
|
|
180379
|
+
const ids3 = this.cells(record33)[link8.id];
|
|
180380
180380
|
if (!Array.isArray(ids3)) return [];
|
|
180381
|
-
const table6 = this.options(
|
|
180381
|
+
const table6 = this.options(link8).linkedTableId;
|
|
180382
180382
|
return ids3.map((id15) => this.record(table6, id15)).filter((item2) => !!item2);
|
|
180383
180383
|
}
|
|
180384
180384
|
commentCount(recordId) {
|
|
@@ -181178,10 +181178,10 @@ function addField(model2, table6, input5) {
|
|
|
181178
181178
|
break;
|
|
181179
181179
|
case "multipleLookupValues":
|
|
181180
181180
|
case "rollup": {
|
|
181181
|
-
const
|
|
181181
|
+
const link8 = linkField("recordLinkFieldId"), linked2 = model2.options(link8).linkedTableId;
|
|
181182
181182
|
const target6 = model2.fields(linked2).find((item2) => item2.id === raw3.fieldIdInLinkedTable || item2.name === raw3.fieldIdInLinkedTable);
|
|
181183
181183
|
if (!target6) throw invalidRequest("Invalid request: options.fieldIdInLinkedTable must be a field in the linked table");
|
|
181184
|
-
options5 = { recordLinkFieldId:
|
|
181184
|
+
options5 = { recordLinkFieldId: link8.id, fieldIdInLinkedTable: target6.id };
|
|
181185
181185
|
if (type === "rollup") {
|
|
181186
181186
|
formula(raw3.formula, () => false, ["values"]);
|
|
181187
181187
|
options5.formula = raw3.formula;
|
|
@@ -181365,8 +181365,8 @@ function seed40(ctx) {
|
|
|
181365
181365
|
case "multipleLookupValues":
|
|
181366
181366
|
case "rollup": {
|
|
181367
181367
|
const table6 = base6.tables.find((item2) => tableIds.get(lower3(item2.name)) === tableId);
|
|
181368
|
-
const
|
|
181369
|
-
const linked2 = tableIds.get(lower3(
|
|
181368
|
+
const link8 = table6.fields.find((item2) => item2.name === field6.link);
|
|
181369
|
+
const linked2 = tableIds.get(lower3(link8.table));
|
|
181370
181370
|
return { recordLinkFieldId: own2.get(field6.link), fieldIdInLinkedTable: fieldIds.get(linked2).get(field6.field), ...field6.type === "rollup" && { formula: field6.formula } };
|
|
181371
181371
|
}
|
|
181372
181372
|
default:
|
|
@@ -183619,7 +183619,7 @@ function plainValues(ctx, type, id15) {
|
|
|
183619
183619
|
function linked(ctx, value6) {
|
|
183620
183620
|
if (Array.isArray(value6)) return value6.map((item2) => linked(ctx, item2));
|
|
183621
183621
|
if (value6 === null || typeof value6 !== "object") return value6;
|
|
183622
|
-
return Object.fromEntries(Object.entries(value6).map(([key5, item2]) => [key5, key5 === "links" && Array.isArray(item2) ? item2.map((
|
|
183622
|
+
return Object.fromEntries(Object.entries(value6).map(([key5, item2]) => [key5, key5 === "links" && Array.isArray(item2) ? item2.map((link8) => link8 && typeof link8 === "object" && typeof link8.href === "string" ? { ...link8, href: link8.href.replace(/^.*?\/services\/rest\/record\/v1\//, `${ctx.serviceUrl ?? ""}${RECORD_ROOT}/`) } : link8) : linked(ctx, item2)]));
|
|
183623
183623
|
}
|
|
183624
183624
|
function readPlain(ctx, type, id15) {
|
|
183625
183625
|
const r2 = row(ctx, type, id15);
|
|
@@ -188424,12 +188424,12 @@ var init_suiteql = __esm({
|
|
|
188424
188424
|
const [subject, ...rest2] = args, pairs2 = [];
|
|
188425
188425
|
for (let i = 0; i + 1 < rest2.length; i += 2) pairs2.push([rest2[i], rest2[i + 1]]);
|
|
188426
188426
|
const type = pairs2[0][1].type === "null" ? "text" : pairs2[0][1].type;
|
|
188427
|
-
const
|
|
188427
|
+
const results2 = [...pairs2.map((p2) => this.convert(p2[1], type)), rest2.length % 2 ? this.convert(rest2[rest2.length - 1], type) : bound2(param3(null), "null")];
|
|
188428
188428
|
const tests = pairs2.map(([search10]) => {
|
|
188429
188429
|
const [a, b] = this.align(subject, search10);
|
|
188430
188430
|
return sql3("(", a, " IS ", b, ")");
|
|
188431
188431
|
});
|
|
188432
|
-
return bound2(sql3("(CASE ", ...tests.map((test3, i) => sql3("WHEN ", test3, " THEN ",
|
|
188432
|
+
return bound2(sql3("(CASE ", ...tests.map((test3, i) => sql3("WHEN ", test3, " THEN ", results2[i], " ")), "ELSE ", results2[results2.length - 1], " END)"), type, [...args, ...results2]);
|
|
188433
188433
|
}
|
|
188434
188434
|
case "greatest":
|
|
188435
188435
|
case "least": {
|
|
@@ -190018,14 +190018,14 @@ function field4(ctx, type, name5, error65, plan4, formula) {
|
|
|
190018
190018
|
}
|
|
190019
190019
|
return f(kind2 === "text" ? `CAST((${expression4}) AS VARCHAR2(4000))` : kind2 === "date" ? `CAST((${expression4}) AS DATE)` : `CAST((${expression4}) AS NUMBER)`, kind2);
|
|
190020
190020
|
}
|
|
190021
|
-
const
|
|
190022
|
-
if (type === "transaction" &&
|
|
190023
|
-
const forward2 =
|
|
190021
|
+
const link8 = /^(appliedto|applying)(transaction|foreignamount|linkamount|linktype|isfxvariance)$/.exec(key5);
|
|
190022
|
+
if (type === "transaction" && link8) {
|
|
190023
|
+
const forward2 = link8[1] === "appliedto", alias = forward2 ? "applied_link" : "applying_link";
|
|
190024
190024
|
plan4.joins.set(alias, `LEFT JOIN ${forward2 ? "previous" : "next"}transactionlinelink ${alias} ON ${alias}.${forward2 ? "nextdoc" : "previousdoc"} = t.id AND ${alias}.${forward2 ? "nextline" : "previousline"} = tl.id`);
|
|
190025
|
-
if (
|
|
190026
|
-
if (
|
|
190027
|
-
if (
|
|
190028
|
-
return f(`${alias}.foreignamount${
|
|
190025
|
+
if (link8[2] === "transaction") return select3(`${alias}.${forward2 ? "previousdoc" : "nextdoc"}`);
|
|
190026
|
+
if (link8[2] === "linktype") return select3(`${alias}.linktype`, `${alias}.linktype`);
|
|
190027
|
+
if (link8[2] === "isfxvariance") return f(`CASE WHEN ${alias}.linktype IS NULL THEN NULL ELSE 'F' END`, "checkbox");
|
|
190028
|
+
return f(`${alias}.foreignamount${link8[2] === "linkamount" ? " * t.exchangerate" : ""}`, "currency");
|
|
190029
190029
|
}
|
|
190030
190030
|
const known2 = def.fields[key5];
|
|
190031
190031
|
if (known2) return known2;
|
|
@@ -190261,7 +190261,7 @@ async function runSearch(ctx, args) {
|
|
|
190261
190261
|
if (error65 instanceof SuiteqlError) throw new ToolError(error65.gap ? "coverage_gap" : "UNEXPECTED_ERROR", error65.message, error65.gap);
|
|
190262
190262
|
throw error65;
|
|
190263
190263
|
}
|
|
190264
|
-
const
|
|
190264
|
+
const results2 = (end === start2 ? [] : result.items).map((item2) => {
|
|
190265
190265
|
const row2 = item2, values3 = {};
|
|
190266
190266
|
shown4.forEach((c, index) => {
|
|
190267
190267
|
const value6 = row2[`c${index}`], key6 = c.key;
|
|
@@ -190289,7 +190289,7 @@ async function runSearch(ctx, args) {
|
|
|
190289
190289
|
totalResults: result.totalResults,
|
|
190290
190290
|
range: { start: start2, end: Math.min(end, result.totalResults) },
|
|
190291
190291
|
columns: shown4.map((c) => ({ name: c.name, ...c.summary && { summary: c.summary }, ...c.label && { label: c.label } })),
|
|
190292
|
-
results
|
|
190292
|
+
results: results2
|
|
190293
190293
|
};
|
|
190294
190294
|
}
|
|
190295
190295
|
var f, select3, entity3, FOREIGN_AMOUNT, FIELDS4, JOINS2, ITEM_RECORD_TYPES, OPERATORS3, badFilter, badOperator, badColumn, badExpression, iso21, at2, SUMMARIES, money19;
|
|
@@ -191792,10 +191792,10 @@ function seed42(ctx) {
|
|
|
191792
191792
|
return date11;
|
|
191793
191793
|
};
|
|
191794
191794
|
const setTotal = (id15, total6) => db3.prepare("UPDATE ns_transactions SET total = ? WHERE id = ?").run(round(total6), id15);
|
|
191795
|
-
const itemLines = (tx2, lines2, purchase,
|
|
191795
|
+
const itemLines = (tx2, lines2, purchase, link8, after = 0) => {
|
|
191796
191796
|
let total6 = 0;
|
|
191797
191797
|
lines2.forEach((l, index) => {
|
|
191798
|
-
const rate = l.rate ?? (purchase ? buyRate(l.item) : saleRate(l.item)), amount6 = l.amount ?? round(l.quantity * rate), order6 =
|
|
191798
|
+
const rate = l.rate ?? (purchase ? buyRate(l.item) : saleRate(l.item)), amount6 = l.amount ?? round(l.quantity * rate), order6 = link8?.(index);
|
|
191799
191799
|
line2.run({
|
|
191800
191800
|
...blankLine,
|
|
191801
191801
|
transaction: tx2,
|
|
@@ -191877,7 +191877,7 @@ function seed42(ctx) {
|
|
|
191877
191877
|
const order6 = input5.salesOrders.find((o) => o.id === f2.salesOrder);
|
|
191878
191878
|
insert("itemFulfillment", f2, { entity: order6.customer, status: SHIP[f2.shipStatus], createdFrom: f2.salesOrder });
|
|
191879
191879
|
f2.lines.forEach((l, index) => {
|
|
191880
|
-
const
|
|
191880
|
+
const link8 = fromOrder(f2.salesOrder, l.item, l.quantity, "quantityshiprecv"), source = link8 && lineRows(ctx, f2.salesOrder, "item").find((o) => o.line === link8[1]);
|
|
191881
191881
|
line2.run({
|
|
191882
191882
|
...blankLine,
|
|
191883
191883
|
transaction: f2.id,
|
|
@@ -191886,8 +191886,8 @@ function seed42(ctx) {
|
|
|
191886
191886
|
item: l.item,
|
|
191887
191887
|
description: source?.description ?? itemText(l.item),
|
|
191888
191888
|
quantity: l.quantity,
|
|
191889
|
-
createdfrom:
|
|
191890
|
-
orderline:
|
|
191889
|
+
createdfrom: link8?.[0] ?? null,
|
|
191890
|
+
orderline: link8?.[1] ?? null,
|
|
191891
191891
|
location: l.location ?? source?.location ?? f2.location ?? firstLocation,
|
|
191892
191892
|
extra: extra2({ ...l.extra })
|
|
191893
191893
|
});
|
|
@@ -191897,7 +191897,7 @@ function seed42(ctx) {
|
|
|
191897
191897
|
const order6 = input5.purchaseOrders.find((o) => o.id === r2.purchaseOrder);
|
|
191898
191898
|
insert("itemReceipt", r2, { entity: order6.vendor, createdFrom: r2.purchaseOrder });
|
|
191899
191899
|
r2.lines.forEach((l, index) => {
|
|
191900
|
-
const
|
|
191900
|
+
const link8 = fromOrder(r2.purchaseOrder, l.item, l.quantity, "quantityshiprecv"), source = link8 && lineRows(ctx, r2.purchaseOrder, "item").find((o) => o.line === link8[1]);
|
|
191901
191901
|
line2.run({
|
|
191902
191902
|
...blankLine,
|
|
191903
191903
|
transaction: r2.id,
|
|
@@ -191907,8 +191907,8 @@ function seed42(ctx) {
|
|
|
191907
191907
|
description: source?.description ?? itemText(l.item, true),
|
|
191908
191908
|
quantity: l.quantity,
|
|
191909
191909
|
rate: source?.rate ?? null,
|
|
191910
|
-
createdfrom:
|
|
191911
|
-
orderline:
|
|
191910
|
+
createdfrom: link8?.[0] ?? null,
|
|
191911
|
+
orderline: link8?.[1] ?? null,
|
|
191912
191912
|
location: l.location ?? source?.location ?? r2.location ?? firstLocation,
|
|
191913
191913
|
extra: extra2({ ...l.extra })
|
|
191914
191914
|
});
|
|
@@ -191918,8 +191918,8 @@ function seed42(ctx) {
|
|
|
191918
191918
|
const terms2 = inv.terms ?? (inv.salesOrder === void 0 ? void 0 : orderTerms.get(inv.salesOrder)) ?? termsOf(inv.customer);
|
|
191919
191919
|
const date11 = insert("invoice", inv, { entity: inv.customer, terms: terms2, account: ar(), createdFrom: inv.salesOrder ?? null, salesRep: inv.salesRep ?? null });
|
|
191920
191920
|
db3.prepare("UPDATE ns_transactions SET duedate = ? WHERE id = ?").run(due(date11, terms2, inv.dueDate), inv.id);
|
|
191921
|
-
const
|
|
191922
|
-
setTotal(inv.id, itemLines(inv.id, inv.lines, false,
|
|
191921
|
+
const link8 = inv.salesOrder === void 0 ? void 0 : (index) => fromOrder(inv.salesOrder, inv.lines[index].item, inv.lines[index].quantity, "quantitybilled");
|
|
191922
|
+
setTotal(inv.id, itemLines(inv.id, inv.lines, false, link8));
|
|
191923
191923
|
}
|
|
191924
191924
|
for (const cs of input5.cashSales) {
|
|
191925
191925
|
insert("cashSale", cs, { entity: cs.customer, account: cs.account ?? undeposited() });
|
|
@@ -191927,8 +191927,8 @@ function seed42(ctx) {
|
|
|
191927
191927
|
}
|
|
191928
191928
|
for (const cr of input5.cashRefunds) {
|
|
191929
191929
|
insert("cashRefund", cr, { entity: cr.customer, account: cr.account ?? db3.prepare("SELECT id FROM ns_accounts WHERE accttype='Bank' AND isinactive=0 ORDER BY id").get()?.id ?? null, createdFrom: cr.cashSale });
|
|
191930
|
-
const
|
|
191931
|
-
setTotal(cr.id, itemLines(cr.id, cr.lines, false,
|
|
191930
|
+
const link8 = cr.cashSale === void 0 ? void 0 : (index) => fromOrder(cr.cashSale, cr.lines[index].item, cr.lines[index].quantity, "quantitybilled");
|
|
191931
|
+
setTotal(cr.id, itemLines(cr.id, cr.lines, false, link8));
|
|
191932
191932
|
}
|
|
191933
191933
|
for (const cm of input5.creditMemos) {
|
|
191934
191934
|
insert("creditMemo", cm, { entity: cm.customer, account: ar() });
|
|
@@ -191947,8 +191947,8 @@ function seed42(ctx) {
|
|
|
191947
191947
|
for (const bill of input5.vendorBills) {
|
|
191948
191948
|
const terms2 = bill.terms ?? termsOf(bill.vendor), approval = !input5.policy.billApproval ? 2 : { pending: 1, approved: 2, rejected: 3 }[bill.approval ?? "pending"];
|
|
191949
191949
|
const date11 = insert("vendorBill", bill, { entity: bill.vendor, approval, terms: terms2, account: ap(), createdFrom: bill.purchaseOrder ?? null });
|
|
191950
|
-
const
|
|
191951
|
-
const total6 = expenseLines(bill.id, bill.expenses) + itemLines(bill.id, bill.lines, true,
|
|
191950
|
+
const link8 = bill.purchaseOrder === void 0 ? void 0 : (index) => fromOrder(bill.purchaseOrder, bill.lines[index].item, bill.lines[index].quantity, "quantitybilled");
|
|
191951
|
+
const total6 = expenseLines(bill.id, bill.expenses) + itemLines(bill.id, bill.lines, true, link8, bill.expenses.length);
|
|
191952
191952
|
db3.prepare("UPDATE ns_transactions SET total = ?, duedate = ? WHERE id = ?").run(round(total6), due(date11, terms2, bill.dueDate), bill.id);
|
|
191953
191953
|
}
|
|
191954
191954
|
for (const vc of input5.vendorCredits) {
|
|
@@ -192102,10 +192102,10 @@ function paging(url4) {
|
|
|
192102
192102
|
}
|
|
192103
192103
|
function page19(base6, url4, items2, total6, { limit: limit2, offset: offset20 }) {
|
|
192104
192104
|
const at6 = (target6) => {
|
|
192105
|
-
const
|
|
192106
|
-
|
|
192107
|
-
|
|
192108
|
-
return
|
|
192105
|
+
const link8 = new URL(`${base6}${url4.pathname}${url4.search}`);
|
|
192106
|
+
link8.searchParams.set("limit", String(limit2));
|
|
192107
|
+
link8.searchParams.set("offset", String(target6));
|
|
192108
|
+
return link8.href;
|
|
192109
192109
|
};
|
|
192110
192110
|
const hasMore = offset20 + items2.length < total6, last = total6 === 0 ? 0 : Math.min(Math.floor((total6 - 1) / limit2), MAX_PAGES - 1) * limit2, links4 = [];
|
|
192111
192111
|
if (offset20 > 0) links4.push({ rel: "prev", href: at6(Math.max(0, offset20 - limit2)) }, { rel: "first", href: at6(0) });
|
|
@@ -192855,10 +192855,10 @@ function project11(ctx, primary3, before2, seed44, at6) {
|
|
|
192855
192855
|
}
|
|
192856
192856
|
if (["Invoice", "Bill"].includes(r2.type)) {
|
|
192857
192857
|
const expected = r2.type === "Invoice" ? "Estimate" : "PurchaseOrder";
|
|
192858
|
-
for (const
|
|
192859
|
-
if (
|
|
192860
|
-
if (!body8(expected,
|
|
192861
|
-
backlink(expected,
|
|
192858
|
+
for (const link8 of [...b.LinkedTxn ?? [], ...(b.Line ?? []).flatMap((l) => l.LinkedTxn ?? [])]) {
|
|
192859
|
+
if (link8.TxnType !== expected) gap7(`${r2.type} link to ${link8.TxnType}.`);
|
|
192860
|
+
if (!body8(expected, link8.TxnId)) fault(2500, `${expected} ${link8.TxnId} does not exist.`, "LinkedTxn");
|
|
192861
|
+
backlink(expected, link8.TxnId, r2);
|
|
192862
192862
|
}
|
|
192863
192863
|
}
|
|
192864
192864
|
}
|
|
@@ -192866,19 +192866,19 @@ function project11(ctx, primary3, before2, seed44, at6) {
|
|
|
192866
192866
|
at6.record = r2;
|
|
192867
192867
|
const b = body8(r2.type, r2.id), incoming = r2.type === "Payment", docType = incoming ? "Invoice" : "Bill", creditType = incoming ? "CreditMemo" : "VendorCredit";
|
|
192868
192868
|
let applied = 0, credited = 0;
|
|
192869
|
-
for (const line2 of b.Line ?? []) for (const
|
|
192870
|
-
if (![docType, creditType].includes(
|
|
192871
|
-
const target6 = body8(
|
|
192872
|
-
if (!target6) fault(2500, `${
|
|
192873
|
-
if (record33?.voided) fault(6e3, `${
|
|
192869
|
+
for (const line2 of b.Line ?? []) for (const link8 of line2.LinkedTxn ?? []) {
|
|
192870
|
+
if (![docType, creditType].includes(link8.TxnType)) gap7(`${r2.type} application to ${link8.TxnType}.`);
|
|
192871
|
+
const target6 = body8(link8.TxnType, link8.TxnId), record33 = byKey.get(`${link8.TxnType}:${link8.TxnId}`);
|
|
192872
|
+
if (!target6) fault(2500, `${link8.TxnType} ${link8.TxnId} does not exist.`, "LinkedTxn");
|
|
192873
|
+
if (record33?.voided) fault(6e3, `${link8.TxnType} ${link8.TxnId} is voided.`, "LinkedTxn");
|
|
192874
192874
|
const party4 = incoming ? "CustomerRef" : "VendorRef";
|
|
192875
|
-
if (target6[party4]?.value !== b[party4]?.value) fault(6e3, `The application ${
|
|
192876
|
-
const credit =
|
|
192877
|
-
if (amount6 < 0 || amount6 > cents7(target6[balanceKey])) fault(6e3, `Application exceeds ${
|
|
192875
|
+
if (target6[party4]?.value !== b[party4]?.value) fault(6e3, `The application ${link8.TxnId} belongs to another ${party4}.`, party4);
|
|
192876
|
+
const credit = link8.TxnType === creditType, balanceKey = incoming && credit ? "RemainingCredit" : "Balance", amount6 = cents7(line2.Amount);
|
|
192877
|
+
if (amount6 < 0 || amount6 > cents7(target6[balanceKey])) fault(6e3, `Application exceeds ${link8.TxnType} ${link8.TxnId} remaining balance.`, "Amount");
|
|
192878
192878
|
target6[balanceKey] = money20(cents7(target6[balanceKey]) - amount6);
|
|
192879
192879
|
if (credit) credited += amount6;
|
|
192880
192880
|
else applied += amount6;
|
|
192881
|
-
backlink(
|
|
192881
|
+
backlink(link8.TxnType, link8.TxnId, r2);
|
|
192882
192882
|
}
|
|
192883
192883
|
const unapplied2 = cents7(b.TotalAmt) - (applied - credited);
|
|
192884
192884
|
if (unapplied2 < 0 || credited > applied) fault(6e3, "Applications exceed the payment and available credits.", "TotalAmt");
|
|
@@ -192897,15 +192897,15 @@ function project11(ctx, primary3, before2, seed44, at6) {
|
|
|
192897
192897
|
required5(line2.DepositLineDetail, "AccountRef");
|
|
192898
192898
|
post6(r2, line2.DepositLineDetail.AccountRef.value, -cents7(line2.Amount));
|
|
192899
192899
|
}
|
|
192900
|
-
for (const
|
|
192901
|
-
const type =
|
|
192900
|
+
for (const link8 of links4) {
|
|
192901
|
+
const type = link8.TxnType === "ReceivePayment" ? "Payment" : link8.TxnType, key5 = `${type}:${link8.TxnId}`, target6 = body8(type, link8.TxnId), record33 = byKey.get(key5);
|
|
192902
192902
|
if (!["Payment", "SalesReceipt"].includes(type)) gap7(`Deposit link to ${type}.`);
|
|
192903
|
-
if (!target6) fault(2500, `${type} ${
|
|
192904
|
-
if (record33?.voided || deposited.has(key5)) fault(6e3, `${type} ${
|
|
192903
|
+
if (!target6) fault(2500, `${type} ${link8.TxnId} does not exist.`, "LinkedTxn");
|
|
192904
|
+
if (record33?.voided || deposited.has(key5)) fault(6e3, `${type} ${link8.TxnId} cannot be deposited again.`, "LinkedTxn");
|
|
192905
192905
|
if (cents7(line2.Amount) !== cents7(target6.TotalAmt)) fault(6e3, "Deposit line must equal the receipt amount.", "Amount");
|
|
192906
192906
|
deposited.add(key5);
|
|
192907
192907
|
post6(r2, uf(target6), -cents7(line2.Amount));
|
|
192908
|
-
backlink(type,
|
|
192908
|
+
backlink(type, link8.TxnId, r2);
|
|
192909
192909
|
}
|
|
192910
192910
|
}
|
|
192911
192911
|
}
|
|
@@ -193238,7 +193238,7 @@ function writeEntity(ctx, type, request2, options5 = {}) {
|
|
|
193238
193238
|
}
|
|
193239
193239
|
save13(ctx, r2);
|
|
193240
193240
|
for (const other of records4(ctx)) {
|
|
193241
|
-
const strip = (links4) => links4.filter((
|
|
193241
|
+
const strip = (links4) => links4.filter((link8) => !(link8.TxnId === id15 && link8.TxnType === type));
|
|
193242
193242
|
if (other.input.LinkedTxn) other.input.LinkedTxn = strip(other.input.LinkedTxn);
|
|
193243
193243
|
let released = false;
|
|
193244
193244
|
if (other.input.Line) other.input.Line = other.input.Line.filter((line2) => {
|
|
@@ -193250,7 +193250,7 @@ function writeEntity(ctx, type, request2, options5 = {}) {
|
|
|
193250
193250
|
});
|
|
193251
193251
|
if (released && ["Payment", "BillPayment"].includes(other.type)) {
|
|
193252
193252
|
const targetType = other.type === "Payment" ? "Invoice" : "Bill", creditType = other.type === "Payment" ? "CreditMemo" : "VendorCredit";
|
|
193253
|
-
const links4 = (line2, kind2) => line2.LinkedTxn?.some((
|
|
193253
|
+
const links4 = (line2, kind2) => line2.LinkedTxn?.some((link8) => link8.TxnType === kind2);
|
|
193254
193254
|
const docOnly = (line2) => links4(line2, targetType) && !links4(line2, creditType);
|
|
193255
193255
|
const creditOnly = (line2) => links4(line2, creditType) && !links4(line2, targetType);
|
|
193256
193256
|
const sum6 = (test3) => other.input.Line.reduce((n2, l) => n2 + (test3(l) ? cents7(l.Amount) : 0), 0);
|
|
@@ -193288,7 +193288,7 @@ function writeEntity(ctx, type, request2, options5 = {}) {
|
|
|
193288
193288
|
for (const key5 of ["FileName", "Size", "ContentType"]) if (old.input[key5] !== void 0) row2[key5] = old.input[key5];
|
|
193289
193289
|
}
|
|
193290
193290
|
if (old && type === "Invoice" && row2.LinkedTxn) {
|
|
193291
|
-
row2.LinkedTxn = row2.LinkedTxn.filter((
|
|
193291
|
+
row2.LinkedTxn = row2.LinkedTxn.filter((link8) => !(link8.TxnType === "Payment" && old.body.LinkedTxn?.some((stored2) => stored2.TxnType === "Payment" && stored2.TxnId === link8.TxnId)));
|
|
193292
193292
|
if (!row2.LinkedTxn.length) delete row2.LinkedTxn;
|
|
193293
193293
|
}
|
|
193294
193294
|
row2.Id = id15;
|
|
@@ -194099,7 +194099,7 @@ function transactionPdf(ctx, type, id15, tid) {
|
|
|
194099
194099
|
];
|
|
194100
194100
|
for (const line2 of row2.Line ?? []) {
|
|
194101
194101
|
const detail3 = line2.SalesItemLineDetail ?? line2.ItemBasedExpenseLineDetail ?? {};
|
|
194102
|
-
lines2.push(`${line2.Description ?? detail3.ItemRef?.name ?? (line2.DetailType === "SubTotalLineDetail" ? "Subtotal" : void 0) ?? (line2.LinkedTxn ?? []).map((
|
|
194102
|
+
lines2.push(`${line2.Description ?? detail3.ItemRef?.name ?? (line2.DetailType === "SubTotalLineDetail" ? "Subtotal" : void 0) ?? (line2.LinkedTxn ?? []).map((link8) => `${link8.TxnType} ${link8.TxnId}`).join(", ")} | ${detail3.Qty ?? ""} | ${detail3.UnitPrice === void 0 ? "" : money21(detail3.UnitPrice)} | ${money21(line2.Amount)}`);
|
|
194103
194103
|
}
|
|
194104
194104
|
lines2.push(`Total: ${money21(row2.TotalAmt)}`, `Balance: ${money21(row2.Balance ?? row2.UnappliedAmt ?? row2.RemainingCredit ?? 0)}`);
|
|
194105
194105
|
const wrapped = lines2.flatMap((line2) => {
|
|
@@ -194281,10 +194281,10 @@ function openItems3(postings2, byKey, partyType2, end) {
|
|
|
194281
194281
|
for (const payment2 of byKey.values()) {
|
|
194282
194282
|
if (payment2.type !== paymentType || payment2.voided || payment2.deleted || payment2.body.TxnDate > end) continue;
|
|
194283
194283
|
const party4 = payment2.body[`${partyType2}Ref`]?.value, paymentItem = items2.get(`${paymentType}:${payment2.id}:${party4}`);
|
|
194284
|
-
for (const line2 of payment2.input.Line ?? []) for (const
|
|
194285
|
-
const target6 = items2.get(`${
|
|
194286
|
-
if (!target6 || ![documentType, creditType].includes(
|
|
194287
|
-
const change4 = cents7(line2.Amount) * (
|
|
194284
|
+
for (const line2 of payment2.input.Line ?? []) for (const link8 of line2.LinkedTxn ?? []) {
|
|
194285
|
+
const target6 = items2.get(`${link8.TxnType}:${link8.TxnId}:${party4}`);
|
|
194286
|
+
if (!target6 || ![documentType, creditType].includes(link8.TxnType)) continue;
|
|
194287
|
+
const change4 = cents7(line2.Amount) * (link8.TxnType === creditType ? -1 : 1);
|
|
194288
194288
|
target6.amount -= change4;
|
|
194289
194289
|
if (paymentItem) paymentItem.amount += change4;
|
|
194290
194290
|
}
|
|
@@ -194369,8 +194369,8 @@ function cashPostings(entries4, byKey, end) {
|
|
|
194369
194369
|
const payments = [...byKey.values()].filter((r2) => ["Payment", "BillPayment"].includes(r2.type) && !r2.voided && r2.body.TxnDate <= end).sort((a, b) => a.body.TxnDate.localeCompare(b.body.TxnDate) || Number(a.id) - Number(b.id));
|
|
194370
194370
|
for (const payment2 of payments) {
|
|
194371
194371
|
let applied = 0;
|
|
194372
|
-
for (const line2 of payment2.input.Line ?? []) for (const
|
|
194373
|
-
const key5 = `${
|
|
194372
|
+
for (const line2 of payment2.input.Line ?? []) for (const link8 of line2.LinkedTxn ?? []) {
|
|
194373
|
+
const key5 = `${link8.TxnType}:${link8.TxnId}`, doc = byKey.get(key5);
|
|
194374
194374
|
if (!doc || doc.voided || !deferred.includes(doc.type)) continue;
|
|
194375
194375
|
const full2 = cents7(doc.body.TotalAmt), paid = cents7(line2.Amount), previous = allocated.get(key5) ?? 0;
|
|
194376
194376
|
if (!full2 || !paid) continue;
|
|
@@ -194607,8 +194607,8 @@ function cashFlow2(l) {
|
|
|
194607
194607
|
const first2 = entries4[0], hasCash = entries4.some((e) => cashIds.has(e.account) && (e.debit !== 0 || e.credit !== 0));
|
|
194608
194608
|
if (["Payment", "BillPayment"].includes(first2.entity)) {
|
|
194609
194609
|
const payment2 = l.byKey.get(`${first2.entity}:${first2.id}`);
|
|
194610
|
-
for (const line2 of payment2.input.Line ?? []) for (const
|
|
194611
|
-
const key5 = `${
|
|
194610
|
+
for (const line2 of payment2.input.Line ?? []) for (const link8 of line2.LinkedTxn ?? []) {
|
|
194611
|
+
const key5 = `${link8.TxnType}:${link8.TxnId}`, doc = l.byKey.get(key5);
|
|
194612
194612
|
if (!doc || doc.voided) continue;
|
|
194613
194613
|
const full2 = cents7(doc.body.TotalAmt ?? 0), paid = cents7(line2.Amount), previous = settled.get(key5) ?? 0;
|
|
194614
194614
|
if (!full2) continue;
|
|
@@ -197326,7 +197326,7 @@ var require_websocket = __commonJS({
|
|
|
197326
197326
|
var http = __require("http");
|
|
197327
197327
|
var net = __require("net");
|
|
197328
197328
|
var tls = __require("tls");
|
|
197329
|
-
var { randomBytes: randomBytes13, createHash:
|
|
197329
|
+
var { randomBytes: randomBytes13, createHash: createHash89 } = __require("crypto");
|
|
197330
197330
|
var { Duplex, Readable: Readable2 } = __require("stream");
|
|
197331
197331
|
var { URL: URL2 } = __require("url");
|
|
197332
197332
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -198007,7 +198007,7 @@ var require_websocket = __commonJS({
|
|
|
198007
198007
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
198008
198008
|
return;
|
|
198009
198009
|
}
|
|
198010
|
-
const digest5 =
|
|
198010
|
+
const digest5 = createHash89("sha1").update(key5 + GUID).digest("base64");
|
|
198011
198011
|
if (res.headers["sec-websocket-accept"] !== digest5) {
|
|
198012
198012
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
198013
198013
|
return;
|
|
@@ -198376,7 +198376,7 @@ var require_websocket_server = __commonJS({
|
|
|
198376
198376
|
var EventEmitter2 = __require("events");
|
|
198377
198377
|
var http = __require("http");
|
|
198378
198378
|
var { Duplex } = __require("stream");
|
|
198379
|
-
var { createHash:
|
|
198379
|
+
var { createHash: createHash89 } = __require("crypto");
|
|
198380
198380
|
var extension2 = require_extension();
|
|
198381
198381
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
198382
198382
|
var subprotocol2 = require_subprotocol();
|
|
@@ -198683,7 +198683,7 @@ var require_websocket_server = __commonJS({
|
|
|
198683
198683
|
);
|
|
198684
198684
|
}
|
|
198685
198685
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
198686
|
-
const digest5 =
|
|
198686
|
+
const digest5 = createHash89("sha1").update(key5 + GUID).digest("base64");
|
|
198687
198687
|
const headers = [
|
|
198688
198688
|
"HTTP/1.1 101 Switching Protocols",
|
|
198689
198689
|
"Upgrade: websocket",
|
|
@@ -211311,15 +211311,15 @@ var init_AbstractChatCompletionRunner = __esm({
|
|
|
211311
211311
|
}
|
|
211312
211312
|
}
|
|
211313
211313
|
} else {
|
|
211314
|
-
const
|
|
211314
|
+
const results2 = await Promise.allSettled(message8.tool_calls.map(runToolCall));
|
|
211315
211315
|
if (!this.controller.signal.aborted) {
|
|
211316
|
-
for (const result of
|
|
211316
|
+
for (const result of results2) {
|
|
211317
211317
|
if (result.status === "rejected") {
|
|
211318
211318
|
throw result.reason;
|
|
211319
211319
|
}
|
|
211320
211320
|
}
|
|
211321
211321
|
}
|
|
211322
|
-
for (const result of
|
|
211322
|
+
for (const result of results2) {
|
|
211323
211323
|
if (result.status === "fulfilled" && result.value.message) {
|
|
211324
211324
|
this._addMessage(result.value.message);
|
|
211325
211325
|
}
|
|
@@ -227437,8 +227437,8 @@ var allSettledWithThrow;
|
|
|
227437
227437
|
var init_Util = __esm({
|
|
227438
227438
|
"node_modules/.pnpm/openai@7.43.0_@aws-sdk+credential-provider-node@3.972.91_@smithy+signature-v4@5.7.5_undici@8.12.3_ws@8.22.0_zod@4.6.7/node_modules/openai/lib/Util.mjs"() {
|
|
227439
227439
|
allSettledWithThrow = async (promises) => {
|
|
227440
|
-
const
|
|
227441
|
-
const rejected =
|
|
227440
|
+
const results2 = await Promise.allSettled(promises);
|
|
227441
|
+
const rejected = results2.filter((result) => result.status === "rejected");
|
|
227442
227442
|
if (rejected.length) {
|
|
227443
227443
|
throw Object.defineProperty(new Error(`${rejected.length} promise(s) failed`), "rejections", {
|
|
227444
227444
|
configurable: true,
|
|
@@ -227447,7 +227447,7 @@ var init_Util = __esm({
|
|
|
227447
227447
|
});
|
|
227448
227448
|
}
|
|
227449
227449
|
const values3 = [];
|
|
227450
|
-
for (const result of
|
|
227450
|
+
for (const result of results2) {
|
|
227451
227451
|
if (result.status === "fulfilled") {
|
|
227452
227452
|
values3.push(result.value);
|
|
227453
227453
|
}
|
|
@@ -231130,8 +231130,8 @@ function validateManifest(v) {
|
|
|
231130
231130
|
}
|
|
231131
231131
|
const folders3 = v.files.map((f2) => f2.path).filter((p2) => p2 === "scene.yaml" || p2.endsWith("/scene.yaml")).map((p2) => p2.slice(0, -"scene.yaml".length));
|
|
231132
231132
|
const records6 = new Set(v.references.filter((r2) => r2.kind === "records").map((r2) => r2.to));
|
|
231133
|
-
const
|
|
231134
|
-
if (v.files.some((f2) => f2.roles.some((r2) => AGENT_FILE_ROLES.includes(r2)) &&
|
|
231133
|
+
const graded2 = (p2) => p2 === v.configPath || v.entrypoints.includes(p2) || v.references.some((r2) => r2.to === p2 && r2.kind !== "records") || !records6.has(p2) && folders3.some((dir2) => dir2 === "" ? /^(?:scene\.yaml|(?:oracle|null)\.m?[jt]s)$/.test(p2) : p2.startsWith(dir2));
|
|
231134
|
+
if (v.files.some((f2) => f2.roles.some((r2) => AGENT_FILE_ROLES.includes(r2)) && graded2(f2.path))) reject2("Separate evaluation files from agent files.");
|
|
231135
231135
|
if (!Array.isArray(v.provenance)) reject2("Invalid provenance.");
|
|
231136
231136
|
const caseIds = /* @__PURE__ */ new Set();
|
|
231137
231137
|
for (const p2 of v.provenance) {
|
|
@@ -231833,7 +231833,14 @@ import { createServer, request } from "node:http";
|
|
|
231833
231833
|
import { request as secureRequest } from "node:https";
|
|
231834
231834
|
import { isIP as isIP3 } from "node:net";
|
|
231835
231835
|
import { brotliDecompressSync, gunzipSync, inflateSync as inflateSync2 } from "node:zlib";
|
|
231836
|
-
function modelFailure(status6) {
|
|
231836
|
+
function modelFailure(status6, message8) {
|
|
231837
|
+
if (status6 === 402 && /in-flight/i.test(message8 ?? "")) return {
|
|
231838
|
+
code: "MODEL_CREDITS_EXHAUSTED",
|
|
231839
|
+
kind: "fix",
|
|
231840
|
+
outcome: "The model key's credits do not cover the requests running at once",
|
|
231841
|
+
did: "says the model key's credits do not cover the requests running at once",
|
|
231842
|
+
fix: "Add credits in the model provider account, or run fewer attempts at once (ancha run --concurrency 1, or parallel: 1 in ancha.yaml)."
|
|
231843
|
+
};
|
|
231837
231844
|
return status6 === 429 ? { code: "MODEL_RATE_LIMITED", kind: "retry", outcome: "The model provider rate-limited the key", did: "rate-limited the agent's model key", fix: "Wait a little, then run the same command again." } : status6 === 402 ? { code: "MODEL_CREDITS_EXHAUSTED", kind: "fix", outcome: "The model key is out of credits", did: "says the agent's model key is out of credits", fix: "Add credits in the model provider account, then run again." } : { code: "MODEL_KEY_REFUSED", kind: "fix", outcome: "The model key was refused", did: "refused the agent's model key", fix: void 0 };
|
|
231838
231845
|
}
|
|
231839
231846
|
function refusalMessage(body8, encoding) {
|
|
@@ -233931,6 +233938,11 @@ function containedEnvironment(input5) {
|
|
|
233931
233938
|
if (openRouter && !values3.OPENAI_API_KEY && (values3.OPENROUTER_API_KEY || !openAi)) values3.OPENAI_BASE_URL ??= openRouter + "/api/v1";
|
|
233932
233939
|
if (openAi) values3.OPENAI_BASE_URL ??= openAi + "/v1";
|
|
233933
233940
|
if (mapped.modelUrls["api.anthropic.com"]) values3.ANTHROPIC_BASE_URL ??= mapped.modelUrls["api.anthropic.com"];
|
|
233941
|
+
if (openRouter && values3.OPENROUTER_API_KEY) {
|
|
233942
|
+
const routed = (value6) => value6 === openRouter || value6?.startsWith(openRouter + "/") || value6?.startsWith(openRouter + "?") || value6?.startsWith(openRouter + "#");
|
|
233943
|
+
if (routed(values3.ANTHROPIC_BASE_URL) && !values3.ANTHROPIC_AUTH_TOKEN && !values3.ANTHROPIC_API_KEY) values3.ANTHROPIC_AUTH_TOKEN = values3.OPENROUTER_API_KEY;
|
|
233944
|
+
if (routed(values3.OPENAI_BASE_URL) && !values3.OPENAI_API_KEY) values3.OPENAI_API_KEY = values3.OPENROUTER_API_KEY;
|
|
233945
|
+
}
|
|
233934
233946
|
for (const [base6, api4] of [["OPENROUTER_BASE_URL", "OPENROUTER_API_BASE"], ["OPENAI_BASE_URL", "OPENAI_API_BASE"], ["ANTHROPIC_BASE_URL", "ANTHROPIC_API_BASE"]]) {
|
|
233935
233947
|
if (values3[base6]) values3[api4] ??= values3[base6];
|
|
233936
233948
|
}
|
|
@@ -235748,8 +235760,10 @@ function likelyFix(logTail3, context3 = {}) {
|
|
|
235748
235760
|
const task2 = taskFix(logTail3.join("\n"), context3.command);
|
|
235749
235761
|
if (task2 !== void 0 || context3.withheld !== void 0) return task2 ?? context3.withheld;
|
|
235750
235762
|
if (logTail3.some((line2) => /^Not logged in · Please run \/login\b/.test(line2.trim()))) {
|
|
235751
|
-
return
|
|
235763
|
+
return context3.target === "cloud" ? "Claude Code had no key (its /login stays on your computer): through OpenRouter, set ANTHROPIC_BASE_URL: https://openrouter.ai/api under agent.env and run ancha secrets set OPENROUTER_API_KEY in the project (Claude Code gets it as ANTHROPIC_AUTH_TOKEN); with an Anthropic key, run ancha secrets set ANTHROPIC_API_KEY in the project" : 'Claude Code had no key (its /login stays on your computer): through OpenRouter, start agent.command with ANTHROPIC_AUTH_TOKEN="$OPENROUTER_API_KEY" and set ANTHROPIC_BASE_URL: https://openrouter.ai/api under agent.env; with an Anthropic key, set ANTHROPIC_API_KEY in this shell and list it under agent.pass_env in ancha.yaml';
|
|
235752
235764
|
}
|
|
235765
|
+
const model2 = logTail3.map((line2) => MODEL_ID_REFUSED.map((pattern) => pattern.exec(line2)?.[1]).find(Boolean)).find(Boolean);
|
|
235766
|
+
if (model2 !== void 0) return `its model ${model2} is not a model id the provider serves: use an id from the provider's model list (openrouter.ai/models for OpenRouter) where the agent sets its model: agent.env, agent.command or its code`;
|
|
235753
235767
|
const errors3 = logTail3.filter((line2) => /error|exception|fatal|panic|missing|required|usage|not set|not found|cannot|can't/i.test(line2));
|
|
235754
235768
|
for (const lines2 of [errors3, logTail3]) {
|
|
235755
235769
|
const fix = lines2.length === 0 ? void 0 : keyFix(lines2, context3) ?? missingFix(lines2.join("\n"), context3);
|
|
@@ -235757,7 +235771,7 @@ function likelyFix(logTail3, context3 = {}) {
|
|
|
235757
235771
|
}
|
|
235758
235772
|
return void 0;
|
|
235759
235773
|
}
|
|
235760
|
-
var TASK_WORD, TASK_NAME, TASK_FLAG, CREDENTIAL, MISSING, twinVariables, escape16;
|
|
235774
|
+
var TASK_WORD, TASK_NAME, TASK_FLAG, CREDENTIAL, MISSING, twinVariables, escape16, MODEL_ID_REFUSED;
|
|
235761
235775
|
var init_agent_fix = __esm({
|
|
235762
235776
|
"backend/src/agent-fix.ts"() {
|
|
235763
235777
|
"use strict";
|
|
@@ -235769,6 +235783,7 @@ var init_agent_fix = __esm({
|
|
|
235769
235783
|
CREDENTIAL = /(?<![A-Za-z0-9_])([A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*_(?:KEY|TOKEN|SECRET|PASSWORD))(?![A-Za-z0-9_])/g;
|
|
235770
235784
|
MISSING = /missing|not set|unset|undefined|required|must be set|no .*(?:key|token)|KeyError|not found|empty|expected/i;
|
|
235771
235785
|
escape16 = (text31) => text31.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
235786
|
+
MODEL_ID_REFUSED = [/([\w.:/@-]+)['"`]? is not a valid model ID/i, /The model [`'"]?([\w.:/@-]+)[`'"]? does not exist/i, /not_found_error\W+(?:message\W+)?model: ([\w.:/@-]+)/i];
|
|
235772
235787
|
}
|
|
235773
235788
|
});
|
|
235774
235789
|
|
|
@@ -235920,7 +235935,7 @@ function attemptOutcome(view3, ctx) {
|
|
|
235920
235935
|
}
|
|
235921
235936
|
const model2 = view3.modelReplies?.find((reply6) => MODEL_REFUSALS.has(reply6.status));
|
|
235922
235937
|
if (model2 !== void 0) {
|
|
235923
|
-
const failure6 = modelFailure(model2.status);
|
|
235938
|
+
const failure6 = modelFailure(model2.status, model2.message);
|
|
235924
235939
|
return out({
|
|
235925
235940
|
code: "model_key",
|
|
235926
235941
|
kind: failure6.kind,
|
|
@@ -236043,7 +236058,7 @@ async function recordAnswer(backend, envId, sessionId, output2, source, printed)
|
|
|
236043
236058
|
}
|
|
236044
236059
|
}
|
|
236045
236060
|
function modelKeyIssue(refusal4, given2) {
|
|
236046
|
-
const failure6 = modelFailure(refusal4.status);
|
|
236061
|
+
const failure6 = modelFailure(refusal4.status, refusal4.message);
|
|
236047
236062
|
return {
|
|
236048
236063
|
kind: "model",
|
|
236049
236064
|
owner: "harness",
|
|
@@ -236246,18 +236261,18 @@ var init_trial = __esm({
|
|
|
236246
236261
|
});
|
|
236247
236262
|
|
|
236248
236263
|
// cloud/shared/outcome-counts.mjs
|
|
236249
|
-
function attemptOutcome2(attempt2,
|
|
236264
|
+
function attemptOutcome2(attempt2, graded2) {
|
|
236250
236265
|
if (attempt2.valid === false || attempt2.exit === "invalid" || attempt2.outcome === "invalid") return "invalid";
|
|
236251
236266
|
if (attempt2.outcome === "skipped" || attempt2.outcome === "xfailed") return "skipped";
|
|
236252
|
-
if (
|
|
236267
|
+
if (graded2 === false || attempt2.graded === false || attempt2.outcome === "ungraded") return "ungraded";
|
|
236253
236268
|
if (attempt2.outcome === "passed" || attempt2.outcome === "failed") return attempt2.outcome;
|
|
236254
236269
|
if (typeof attempt2.passed === "boolean") return attempt2.passed ? "passed" : "failed";
|
|
236255
236270
|
return ["completed", "error", "stopped"].includes(attempt2.status) ? "ungraded" : "pending";
|
|
236256
236271
|
}
|
|
236257
|
-
function countAttempts(attempts, requested2,
|
|
236272
|
+
function countAttempts(attempts, requested2, graded2) {
|
|
236258
236273
|
const counts2 = { requested: Math.max(count11(requested2) ?? attempts.length, attempts.length), completed: 0, valid: 0, passed: 0, failed: 0, invalid: 0, ungraded: 0, skipped: 0, pending: 0 };
|
|
236259
236274
|
for (const attempt2 of attempts) {
|
|
236260
|
-
const outcome4 = attemptOutcome2(attempt2,
|
|
236275
|
+
const outcome4 = attemptOutcome2(attempt2, graded2);
|
|
236261
236276
|
counts2[outcome4]++;
|
|
236262
236277
|
if (outcome4 !== "pending") counts2.completed++;
|
|
236263
236278
|
if (["passed", "failed", "ungraded"].includes(outcome4)) counts2.valid++;
|
|
@@ -236649,7 +236664,7 @@ function summarizeScene(sceneId, trials, requestedTrials = trials.length) {
|
|
|
236649
236664
|
const gaps3 = /* @__PURE__ */ new Map();
|
|
236650
236665
|
let agentCalls2 = 0;
|
|
236651
236666
|
let totalMs = 0;
|
|
236652
|
-
let
|
|
236667
|
+
let graded2 = false;
|
|
236653
236668
|
for (const t of trials) {
|
|
236654
236669
|
totalMs += t.realMs;
|
|
236655
236670
|
for (const issue9 of trialIssues(t)) {
|
|
@@ -236661,7 +236676,7 @@ function summarizeScene(sceneId, trials, requestedTrials = trials.length) {
|
|
|
236661
236676
|
}
|
|
236662
236677
|
const valid2 = trialValid(t);
|
|
236663
236678
|
for (const c of t.checks) {
|
|
236664
|
-
if (valid2 && c.status !== "skipped" && c.error === void 0)
|
|
236679
|
+
if (valid2 && c.status !== "skipped" && c.error === void 0) graded2 = true;
|
|
236665
236680
|
const tally = checks2[c.id] ??= { passed: 0, total: 0, required: c.required };
|
|
236666
236681
|
tally.total++;
|
|
236667
236682
|
if (c.status === "skipped") {
|
|
@@ -236708,7 +236723,7 @@ function summarizeScene(sceneId, trials, requestedTrials = trials.length) {
|
|
|
236708
236723
|
passRate: counts2.requested === 0 ? 0 : round4(passed / counts2.requested),
|
|
236709
236724
|
passAllK: allTrialsPassed(counts2),
|
|
236710
236725
|
checks: checks2,
|
|
236711
|
-
graded,
|
|
236726
|
+
graded: graded2,
|
|
236712
236727
|
agentIssues,
|
|
236713
236728
|
harnessIssues,
|
|
236714
236729
|
invalidTrials,
|
|
@@ -237735,11 +237750,11 @@ async function executeRun(opts) {
|
|
|
237735
237750
|
throw halt.crash?.error ?? error65;
|
|
237736
237751
|
}
|
|
237737
237752
|
const reservedPorts = /* @__PURE__ */ new Set();
|
|
237738
|
-
const
|
|
237753
|
+
const results2 = /* @__PURE__ */ new Map();
|
|
237739
237754
|
const frozen = cases.map((item2) => {
|
|
237740
237755
|
const value6 = { id: item2.id, scenarioId: item2.scene.id, seed: seedOf(item2), compiledFingerprint: sceneFingerprint(item2.scene), identity: item2.identity ?? {} };
|
|
237741
237756
|
const record33 = { ...value6, fingerprint: sceneFingerprint(value6) };
|
|
237742
|
-
|
|
237757
|
+
results2.set(item2.id, { scene: item2.scene, trials: [], requestedTrials: trials, ...explicitCases && { case: record33 } });
|
|
237743
237758
|
return record33;
|
|
237744
237759
|
});
|
|
237745
237760
|
let finished = 0;
|
|
@@ -237769,7 +237784,7 @@ async function executeRun(opts) {
|
|
|
237769
237784
|
await mkdir12(dirname8(copy), { recursive: true });
|
|
237770
237785
|
await writeFile10(copy, text31, { flag: "wx", mode: 384 });
|
|
237771
237786
|
kept.set(item2.id, copy);
|
|
237772
|
-
|
|
237787
|
+
results2.get(item2.id).records = createHash63("sha256").update(text31).digest("hex");
|
|
237773
237788
|
}
|
|
237774
237789
|
onEvent?.({ event: "run_started", runId: runId2, scenes: ids3, trials, parallel });
|
|
237775
237790
|
await Promise.all(Array.from({ length: Math.min(parallel, total6) }, async () => {
|
|
@@ -237855,7 +237870,7 @@ async function executeRun(opts) {
|
|
|
237855
237870
|
observedAgentExit = true;
|
|
237856
237871
|
}
|
|
237857
237872
|
finished++;
|
|
237858
|
-
|
|
237873
|
+
results2.get(item2.id).trials.push(result);
|
|
237859
237874
|
await writeFile10(join22(trialDir, "result.json"), `${JSON.stringify({ ...result, trace: void 0 }, null, 2)}
|
|
237860
237875
|
`, { flag: "wx", mode: 384 });
|
|
237861
237876
|
onEvent?.({
|
|
@@ -237882,7 +237897,7 @@ async function executeRun(opts) {
|
|
|
237882
237897
|
} finally {
|
|
237883
237898
|
await destroyAll([...owned2.values()].map((item2) => item2.env));
|
|
237884
237899
|
}
|
|
237885
|
-
for (const value6 of
|
|
237900
|
+
for (const value6 of results2.values()) value6.trials.sort((a, b) => a.trial - b.trial);
|
|
237886
237901
|
if (halt.crash !== void 0) throw halt.crash.error;
|
|
237887
237902
|
if (halt.spawnFailure !== void 0) {
|
|
237888
237903
|
throw new AnchaError("AGENT_SPAWN_FAILED", `agent command failed to start: ${agent.mode === "endpoint" ? agent.start : agent.command}`, {
|
|
@@ -237890,8 +237905,8 @@ async function executeRun(opts) {
|
|
|
237890
237905
|
});
|
|
237891
237906
|
}
|
|
237892
237907
|
if (signal?.aborted && finished < scenes.length * trials) throw interrupted(dir2);
|
|
237893
|
-
const crash = { twins: [...new Set(scenes.flatMap((scene2) => scene2.twins))], logTails: [...
|
|
237894
|
-
return { runId: runId2, dir: dir2, startedAt: startedAt.toISOString(), finishedAt: (/* @__PURE__ */ new Date()).toISOString(), results, agentEnvironment: describeAgentEnvironment(agent, inheritedEnv, crash) };
|
|
237908
|
+
const crash = { twins: [...new Set(scenes.flatMap((scene2) => scene2.twins))], logTails: [...results2.values()].flatMap((value6) => value6.trials.map((trial) => trial.logTail)) };
|
|
237909
|
+
return { runId: runId2, dir: dir2, startedAt: startedAt.toISOString(), finishedAt: (/* @__PURE__ */ new Date()).toISOString(), results: results2, agentEnvironment: describeAgentEnvironment(agent, inheritedEnv, crash) };
|
|
237895
237910
|
}
|
|
237896
237911
|
var ID_ALPHABET2;
|
|
237897
237912
|
var init_run = __esm({
|
|
@@ -239557,10 +239572,10 @@ var init_workspace = __esm({
|
|
|
239557
239572
|
});
|
|
239558
239573
|
|
|
239559
239574
|
// backend/src/execution/world-image.ts
|
|
239560
|
-
import { createHash as
|
|
239575
|
+
import { createHash as createHash69 } from "node:crypto";
|
|
239561
239576
|
import { readFile as readFile19 } from "node:fs/promises";
|
|
239562
239577
|
function worldImageTag(companion, worker = new Uint8Array()) {
|
|
239563
|
-
const hash10 =
|
|
239578
|
+
const hash10 = createHash69("sha256");
|
|
239564
239579
|
for (const part of [WORLD_DOCKERFILE, WORLD_PACKAGE_JSON, companion, worker]) hash10.update(part).update("\0");
|
|
239565
239580
|
return `ancha-world:${hash10.digest("hex").slice(0, 12)}`;
|
|
239566
239581
|
}
|
|
@@ -239776,8 +239791,8 @@ var init_people_leases = __esm({
|
|
|
239776
239791
|
this.#renewing = Promise.allSettled([...this.#leases.values()].map(async (lease) => {
|
|
239777
239792
|
const response6 = await this.#request("POST", `/_sidecar/people/leases/${lease.leaseId}/renew`, { generation: this.generation });
|
|
239778
239793
|
await response6.body?.cancel();
|
|
239779
|
-
})).then((
|
|
239780
|
-
if (!this.#closed &&
|
|
239794
|
+
})).then((results2) => {
|
|
239795
|
+
if (!this.#closed && results2.some((result) => result.status === "rejected")) this.#failed.abort(unavailable2());
|
|
239781
239796
|
}).finally(() => {
|
|
239782
239797
|
this.#renewing = void 0;
|
|
239783
239798
|
});
|
|
@@ -239791,12 +239806,12 @@ var init_people_leases = __esm({
|
|
|
239791
239806
|
this.#closing = (async () => {
|
|
239792
239807
|
await Promise.allSettled([...this.#pending.values()]);
|
|
239793
239808
|
await this.#renewing;
|
|
239794
|
-
const
|
|
239809
|
+
const results2 = await Promise.allSettled([...this.#leases.values()].map(async (lease) => {
|
|
239795
239810
|
const response6 = await this.#request("DELETE", `/_sidecar/people/leases/${lease.leaseId}`, { generation: this.generation });
|
|
239796
239811
|
await response6.body?.cancel();
|
|
239797
239812
|
}));
|
|
239798
239813
|
this.#leases.clear();
|
|
239799
|
-
if (
|
|
239814
|
+
if (results2.some((result) => result.status === "rejected")) throw unavailable2();
|
|
239800
239815
|
})();
|
|
239801
239816
|
return this.#closing;
|
|
239802
239817
|
}
|
|
@@ -241741,14 +241756,14 @@ function buildSeed(cx, { writes: writes3, state: state3, get: get8, listed: list
|
|
|
241741
241756
|
}
|
|
241742
241757
|
return list19;
|
|
241743
241758
|
};
|
|
241744
|
-
for (const [type, list19,
|
|
241759
|
+
for (const [type, list19, link8] of [["itemFulfillment", "itemFulfillments", "salesOrder"], ["itemReceipt", "itemReceipts", "purchaseOrder"]]) for (const s3 of byType(type)) {
|
|
241745
241760
|
const base6 = header4(s3), from = s3.fields.createdFrom && get8(s3.fields.createdFrom), order6 = from && idOf4(from);
|
|
241746
241761
|
const lines2 = (s3.lines.item ?? []).filter((l) => item2(l.item) && needsMove(item2(l.item)) && l.quantity > 0).map((l) => ({ item: item2(l.item), quantity: l.quantity, ...seg(l.location) && { location: seg(l.location) } }));
|
|
241747
241762
|
if (!order6 || !docs2.has(order6) || docs2.get(order6).pending || !lines2.length || !fitOrder(order6, lines2, "moved")) {
|
|
241748
241763
|
note2("missing", `seed.netsuite.${list19}.${base6.id}`, `${LABEL2[type]} ${label7(s3)}: ${!order6 || !docs2.has(order6) ? "the order it was made from is not in the test" : !lines2.length ? "its lines never showed" : "its lines do not fit its order"}, so the test starts without it`, s3.spans);
|
|
241749
241764
|
continue;
|
|
241750
241765
|
}
|
|
241751
|
-
lists3[list19].push({ ...base6, [
|
|
241766
|
+
lists3[list19].push({ ...base6, [link8]: order6, lines: moved(lines2) });
|
|
241752
241767
|
observed(s3, `${lines2.map((l) => `${l.quantity} \xD7 ${itemById.get(l.item).itemId}`).join(", ")} from ${label7(from)}`);
|
|
241753
241768
|
}
|
|
241754
241769
|
for (const s3 of byType("purchaseOrder")) {
|
|
@@ -242462,10 +242477,10 @@ function quickbooksProjection(seed44) {
|
|
|
242462
242477
|
if (p2) p2.Balance = (cents8(p2.Balance) + cents8(l.Amount) * (d.PostingType === "Debit" ? 1 : -1) * (party5 === "Vendor" ? -1 : 1)) / 100;
|
|
242463
242478
|
}
|
|
242464
242479
|
}
|
|
242465
|
-
for (const t of ["Payment", "BillPayment"]) for (const p2 of rows35(t)) for (const l of p2.Line ?? []) for (const
|
|
242466
|
-
const r2 = rows35(
|
|
242480
|
+
for (const t of ["Payment", "BillPayment"]) for (const p2 of rows35(t)) for (const l of p2.Line ?? []) for (const link8 of l.LinkedTxn ?? []) {
|
|
242481
|
+
const r2 = rows35(link8.TxnType).find((r3) => r3.Id === link8.TxnId);
|
|
242467
242482
|
if (!r2) continue;
|
|
242468
|
-
const credit = ["CreditMemo", "VendorCredit"].includes(
|
|
242483
|
+
const credit = ["CreditMemo", "VendorCredit"].includes(link8.TxnType), field6 = link8.TxnType === "CreditMemo" ? "RemainingCredit" : "Balance";
|
|
242469
242484
|
r2[field6] = (cents8(r2[field6]) - cents8(l.Amount)) / 100;
|
|
242470
242485
|
if (t === "Payment") p2.UnappliedAmt = (cents8(p2.UnappliedAmt) + cents8(l.Amount) * (credit ? 1 : -1)) / 100;
|
|
242471
242486
|
}
|
|
@@ -242751,10 +242766,10 @@ function rebuildQuickbooks(cx) {
|
|
|
242751
242766
|
return false;
|
|
242752
242767
|
});
|
|
242753
242768
|
for (const [type, list19] of Object.entries(seed44.entities)) for (const row2 of list19) {
|
|
242754
|
-
for (const holder of [row2, ...row2.Line ?? []]) if (holder.LinkedTxn) holder.LinkedTxn = holder.LinkedTxn.filter((
|
|
242755
|
-
const target6 =
|
|
242756
|
-
if (rows35(target6).some((r2) => r2.Id ===
|
|
242757
|
-
note2("missing", `${pathOf6(type, row2.Id)}.LinkedTxn`, `${target6} ${
|
|
242769
|
+
for (const holder of [row2, ...row2.Line ?? []]) if (holder.LinkedTxn) holder.LinkedTxn = holder.LinkedTxn.filter((link8) => {
|
|
242770
|
+
const target6 = link8.TxnType === "ReceivePayment" ? "Payment" : link8.TxnType;
|
|
242771
|
+
if (rows35(target6).some((r2) => r2.Id === link8.TxnId)) return true;
|
|
242772
|
+
note2("missing", `${pathOf6(type, row2.Id)}.LinkedTxn`, `${target6} ${link8.TxnId} was not observed before the agent wrote`, [sources.get(`${type}:${row2.Id}`)?.span]);
|
|
242758
242773
|
return false;
|
|
242759
242774
|
});
|
|
242760
242775
|
}
|
|
@@ -242764,7 +242779,7 @@ function rebuildQuickbooks(cx) {
|
|
|
242764
242779
|
for (const type of ["Invoice", "Bill"]) for (const row2 of rows35(type)) {
|
|
242765
242780
|
const source = balanceSources.get(`${type}:${row2.Id}`);
|
|
242766
242781
|
if (!source) continue;
|
|
242767
|
-
const affected = writes3.some((w2) => w2.order <= source.order && ["Payment", "BillPayment"].includes(w2.type) && (w2.body.Line ?? []).some((l) => l.LinkedTxn?.some((
|
|
242782
|
+
const affected = writes3.some((w2) => w2.order <= source.order && ["Payment", "BillPayment"].includes(w2.type) && (w2.body.Line ?? []).some((l) => l.LinkedTxn?.some((link8) => link8.TxnType === type && link8.TxnId === row2.Id)));
|
|
242768
242783
|
if (affected) {
|
|
242769
242784
|
note2("missing", `${pathOf6(type, row2.Id)}.Balance`, "balance was observed after an agent payment", [source.span]);
|
|
242770
242785
|
continue;
|
|
@@ -242897,7 +242912,7 @@ function proposeQuickbooksChecks(cx, built3, { expect, outcomes = [] } = {}) {
|
|
|
242897
242912
|
const creations = new Map(writes3.filter((w2) => w2.op === "create" && w2.id).map((w2) => [`${w2.type}:${w2.id}`, w2]));
|
|
242898
242913
|
const identifying = (w2) => Object.fromEntries(["DocNumber", "DisplayName", "Name"].filter((k) => typeof w2.body[k] === "string" && w2.body[k]).map((k) => [k, w2.body[k]]));
|
|
242899
242914
|
const written = new Set(writes3.map((w2) => w2.type));
|
|
242900
|
-
for (const w2 of writes3) for (const l of [w2.body, ...w2.body.Line ?? []]) for (const
|
|
242915
|
+
for (const w2 of writes3) for (const l of [w2.body, ...w2.body.Line ?? []]) for (const link8 of l.LinkedTxn ?? []) written.add(link8.TxnType === "ReceivePayment" ? "Payment" : link8.TxnType);
|
|
242901
242916
|
const countTypes = new Set(writes3.filter((w2) => w2.op === "create" && !["DocNumber", "DisplayName", "Name"].some((k) => typeof w2.body[k] === "string" && w2.body[k])).map((w2) => w2.type));
|
|
242902
242917
|
for (const type of countTypes) {
|
|
242903
242918
|
const changes2 = writes3.filter((w2) => w2.type === type && ["create", "delete"].includes(w2.op));
|
|
@@ -242947,16 +242962,16 @@ function proposeQuickbooksChecks(cx, built3, { expect, outcomes = [] } = {}) {
|
|
|
242947
242962
|
}
|
|
242948
242963
|
}
|
|
242949
242964
|
const balances3 = /* @__PURE__ */ new Map();
|
|
242950
|
-
for (const payment2 of paid.values()) for (const [lines2, sign4] of [[payment2.before, 1], [payment2.lines, -1]]) for (const line2 of lines2) for (const
|
|
242951
|
-
if (!["Invoice", "Bill"].includes(
|
|
242952
|
-
const row2 = projection2[
|
|
242965
|
+
for (const payment2 of paid.values()) for (const [lines2, sign4] of [[payment2.before, 1], [payment2.lines, -1]]) for (const line2 of lines2) for (const link8 of line2.LinkedTxn ?? []) {
|
|
242966
|
+
if (!["Invoice", "Bill"].includes(link8.TxnType)) continue;
|
|
242967
|
+
const row2 = projection2[link8.TxnType]?.find((r2) => r2.Id === link8.TxnId);
|
|
242953
242968
|
if (!row2) continue;
|
|
242954
|
-
const key5 = `${
|
|
242969
|
+
const key5 = `${link8.TxnType}:${link8.TxnId}`, b = balances3.get(key5) ?? { type: link8.TxnType, id: link8.TxnId, amount: cents8(row2.Balance), ok: true, spans: [] };
|
|
242955
242970
|
b.amount += sign4 * cents8(line2.Amount);
|
|
242956
242971
|
b.ok &&= payment2.ok;
|
|
242957
242972
|
b.spans.push(payment2.span);
|
|
242958
242973
|
balances3.set(key5, b);
|
|
242959
|
-
written.add(
|
|
242974
|
+
written.add(link8.TxnType);
|
|
242960
242975
|
}
|
|
242961
242976
|
for (const w2 of writes3) if (["Invoice", "CreditMemo", "Payment"].includes(w2.type)) written.add("Customer");
|
|
242962
242977
|
for (const w2 of writes3) if (["Bill", "VendorCredit", "BillPayment"].includes(w2.type)) written.add("Vendor");
|
|
@@ -243261,7 +243276,7 @@ var init_production_trace = __esm({
|
|
|
243261
243276
|
});
|
|
243262
243277
|
|
|
243263
243278
|
// backend/src/production.ts
|
|
243264
|
-
import { createHash as
|
|
243279
|
+
import { createHash as createHash71 } from "node:crypto";
|
|
243265
243280
|
import { readFile as readFile22, writeFile as writeFile16 } from "node:fs/promises";
|
|
243266
243281
|
import { dirname as dirname15, join as join39 } from "node:path";
|
|
243267
243282
|
async function productionRecord(dir2) {
|
|
@@ -243327,7 +243342,7 @@ var init_production = __esm({
|
|
|
243327
243342
|
init_judge();
|
|
243328
243343
|
init_production_trace();
|
|
243329
243344
|
init_production_trace();
|
|
243330
|
-
productionSignature = (check4) =>
|
|
243345
|
+
productionSignature = (check4) => createHash71("sha256").update(JSON.stringify(check4)).digest("hex").slice(0, 12);
|
|
243331
243346
|
}
|
|
243332
243347
|
});
|
|
243333
243348
|
|
|
@@ -243344,8 +243359,8 @@ async function reproductionOf(summary, scenePaths, cwd, runDir, scenes = [], pro
|
|
|
243344
243359
|
if (production3?.checks === void 0) continue;
|
|
243345
243360
|
const checks2 = Object.entries(production3.checks).flatMap(([check4, result]) => {
|
|
243346
243361
|
const here = scene2.checks[check4];
|
|
243347
|
-
const
|
|
243348
|
-
return here === void 0 ? [] : [{ check: check4, production: result, failed:
|
|
243362
|
+
const graded2 = here === void 0 ? 0 : here.total - (here.skipped ?? 0) - (here.invalid ?? 0);
|
|
243363
|
+
return here === void 0 ? [] : [{ check: check4, production: result, failed: graded2 - here.passed, total: graded2 }];
|
|
243349
243364
|
});
|
|
243350
243365
|
const failedInProduction = checks2.filter((c) => c.production === "failed"), failedThere = failedInProduction.filter((c) => c.total > 0);
|
|
243351
243366
|
const ungraded = failedInProduction.length > 0 && failedThere.length === 0;
|
|
@@ -243427,7 +243442,7 @@ var init_production_comparison = __esm({
|
|
|
243427
243442
|
|
|
243428
243443
|
// backend/src/baselines.ts
|
|
243429
243444
|
import { randomUUID as randomUUID14 } from "node:crypto";
|
|
243430
|
-
import { link as
|
|
243445
|
+
import { link as link6, mkdir as mkdir18, readFile as readFile24, rename as rename6, unlink, writeFile as writeFile17 } from "node:fs/promises";
|
|
243431
243446
|
import { dirname as dirname17, join as join41, resolve as resolve30 } from "node:path";
|
|
243432
243447
|
function validateTrialCounts(scene2) {
|
|
243433
243448
|
if (!Number.isSafeInteger(scene2.passed) || !Number.isSafeInteger(scene2.trials) || scene2.trials <= 0 || scene2.passed < 0 || scene2.passed > scene2.trials) {
|
|
@@ -243528,7 +243543,7 @@ async function saveBaseline(cwd, name5, opts = {}, load6) {
|
|
|
243528
243543
|
await writeFile17(temporary, `${JSON.stringify(summary, null, 2)}
|
|
243529
243544
|
`, { flag: "wx", mode: 384 });
|
|
243530
243545
|
if (opts.force) await rename6(temporary, path9);
|
|
243531
|
-
else await
|
|
243546
|
+
else await link6(temporary, path9);
|
|
243532
243547
|
} catch (error65) {
|
|
243533
243548
|
if (error65.code === "EEXIST") throw new AnchaError("USAGE", `baseline ${JSON.stringify(name5)} already exists`, { hint: "choose another name or use --force to replace it explicitly" });
|
|
243534
243549
|
throw error65;
|
|
@@ -244071,7 +244086,7 @@ __export(assemble_exports, {
|
|
|
244071
244086
|
assembleCloudRun: () => assembleCloudRun,
|
|
244072
244087
|
finalizeInput: () => finalizeInput
|
|
244073
244088
|
});
|
|
244074
|
-
import { createHash as
|
|
244089
|
+
import { createHash as createHash73 } from "node:crypto";
|
|
244075
244090
|
import { copyFile as copyFile4, lstat as lstat9, mkdir as mkdir21, mkdtemp as mkdtemp7, readdir as readdir8, readFile as readFile26, rm as rm9, writeFile as writeFile19 } from "node:fs/promises";
|
|
244076
244091
|
import { tmpdir as tmpdir6 } from "node:os";
|
|
244077
244092
|
import { dirname as dirname18, join as join45, resolve as resolve34, sep as sep9 } from "node:path";
|
|
@@ -244337,14 +244352,14 @@ async function assembleCloudRun(options5) {
|
|
|
244337
244352
|
});
|
|
244338
244353
|
await writeFile19(join45(runDir, "inputs.json"), `${JSON.stringify({ schemaVersion: 1, cases: sharedSeeds(frozen), isolation: { execution: "cloud", toolWorld: "fresh-per-attempt", agentProcess: "fresh-machine-per-attempt", agentState: "fresh-machine-per-attempt" } })}
|
|
244339
244354
|
`, { flag: "wx", mode: 384 });
|
|
244340
|
-
const
|
|
244355
|
+
const results2 = new Map(cases.map((item2) => [item2.caseId, { scene: item2.scene, trials: [], requestedTrials: resolved.attempts, ...item2.records !== void 0 && { records: item2.records } }]));
|
|
244341
244356
|
for (const item2 of cases) {
|
|
244342
244357
|
for (const attempt2 of input5.attempts.filter((a) => a.caseId === item2.caseId).sort((a, b) => a.trial - b.trial)) {
|
|
244343
244358
|
const trial = await trialOf(attempt2, item2, input5, options5.artifactsDir, runDir);
|
|
244344
|
-
if (trial !== void 0)
|
|
244359
|
+
if (trial !== void 0) results2.get(item2.caseId).trials.push(trial);
|
|
244345
244360
|
}
|
|
244346
244361
|
}
|
|
244347
|
-
const run7 = { runId: runId2, dir: runDir, startedAt: input5.startedAt, finishedAt: input5.finishedAt, results };
|
|
244362
|
+
const run7 = { runId: runId2, dir: runDir, startedAt: input5.startedAt, finishedAt: input5.finishedAt, results: results2 };
|
|
244348
244363
|
const engine2 = summarize(run7, manifest2.agentName, resolved.minPassRate, { strict: resolved.strict || resolved.simulatedAnswers === "fail", agentCommand: agent.mode === "endpoint" ? agent.start : agent.command });
|
|
244349
244364
|
if (baseline !== void 0 && engine2.scenes.every((scene2) => scene2.trials > 0)) {
|
|
244350
244365
|
engine2.comparison = compareSummaries(engine2, baseline);
|
|
@@ -244426,7 +244441,7 @@ var init_assemble = __esm({
|
|
|
244426
244441
|
EXITS = /* @__PURE__ */ new Set(["exited", "timeout", "spawn_failed", "done", "idle", "invalid"]);
|
|
244427
244442
|
TERMINAL = ["succeeded", "failed", "invalid", "skipped", "cancelled"];
|
|
244428
244443
|
INTENTS = ["completed", "failed", "cancelled"];
|
|
244429
|
-
sha2565 = (data7) =>
|
|
244444
|
+
sha2565 = (data7) => createHash73("sha256").update(data7).digest("hex");
|
|
244430
244445
|
isRecord5 = (value6) => value6 !== null && typeof value6 === "object" && !Array.isArray(value6);
|
|
244431
244446
|
count12 = (value6, least) => Number.isSafeInteger(value6) && value6 >= least;
|
|
244432
244447
|
strings3 = (value6) => Array.isArray(value6) && value6.every((item2) => typeof item2 === "string");
|
|
@@ -246280,23 +246295,23 @@ function invert(map2, items2, cx) {
|
|
|
246280
246295
|
const label7 = READABLE.map((k) => e.fields[k]).find((v) => typeof v === "string" && v) ?? String(e.id);
|
|
246281
246296
|
e.ref = cx.ref(`${map2.twin}_${e.collection.split(".").at(-2)}_${label7.split(/\s+/).slice(0, 2).join("_")}`.slice(0, 60));
|
|
246282
246297
|
}
|
|
246283
|
-
for (const
|
|
246284
|
-
const refs =
|
|
246285
|
-
if (
|
|
246286
|
-
let target6 = byId3(
|
|
246298
|
+
for (const link8 of links4) {
|
|
246299
|
+
const refs = link8.ids.map((id15) => {
|
|
246300
|
+
if (link8.owner.collection === link8.target && String(link8.owner.id) === id15) return void 0;
|
|
246301
|
+
let target6 = byId3(link8.target, id15);
|
|
246287
246302
|
if (!target6) {
|
|
246288
|
-
target6 = entity5(
|
|
246289
|
-
if (pinOf(
|
|
246303
|
+
target6 = entity5(link8.target, void 0, id15);
|
|
246304
|
+
if (pinOf(link8.target)) target6.fields[pinOf(link8.target)] = id15;
|
|
246290
246305
|
target6.fields.name ??= id15.toLowerCase();
|
|
246291
246306
|
target6.placeholder = true;
|
|
246292
|
-
target6.ref = cx.ref(`${map2.twin}_${
|
|
246293
|
-
cx.note("missing", `seed.${map2.twin}.${
|
|
246307
|
+
target6.ref = cx.ref(`${map2.twin}_${link8.target.split(".").at(-2)}_${id15}`.toLowerCase());
|
|
246308
|
+
cx.note("missing", `seed.${map2.twin}.${link8.target.split(".").at(-2)}.${target6.ref}`, `referenced by id ${id15} but never read; only its id is known`);
|
|
246294
246309
|
}
|
|
246295
|
-
return
|
|
246310
|
+
return link8.bare ? target6.ref : `$${target6.ref}`;
|
|
246296
246311
|
}).filter(Boolean);
|
|
246297
246312
|
if (!refs.length) continue;
|
|
246298
|
-
if (
|
|
246299
|
-
else
|
|
246313
|
+
if (link8.many) link8.owner.fields[link8.seedField] = [.../* @__PURE__ */ new Set([...link8.owner.fields[link8.seedField] ?? [], ...refs])];
|
|
246314
|
+
else link8.owner.fields[link8.seedField] ??= refs[0];
|
|
246300
246315
|
}
|
|
246301
246316
|
const seed44 = structuredClone(root3.fields), events3 = [];
|
|
246302
246317
|
const ordered5 = [...entities2.values()].sort((a, b) => a.collection.split(".").length - b.collection.split(".").length);
|
|
@@ -251436,15 +251451,15 @@ async function bundleInventory(input5) {
|
|
|
251436
251451
|
} catch {
|
|
251437
251452
|
doc = void 0;
|
|
251438
251453
|
}
|
|
251439
|
-
const
|
|
251454
|
+
const link8 = (from, field6, to, kind2, role3) => {
|
|
251440
251455
|
refuseExcluded(to, `${from}: ${field6}:`);
|
|
251441
251456
|
add(to, role3);
|
|
251442
251457
|
references3.push({ from, field: field6, to, kind: kind2 });
|
|
251443
251458
|
};
|
|
251444
|
-
for (const reference3 of namedFiles(test3.path, doc))
|
|
251459
|
+
for (const reference3 of namedFiles(test3.path, doc)) link8(test3.path, reference3.field, reference3.to, reference3.kind, reference3.role);
|
|
251445
251460
|
if (test3.world !== void 0) {
|
|
251446
251461
|
const world5 = projectPath(root3, test3.world, `${test3.path}: world:`);
|
|
251447
|
-
|
|
251462
|
+
link8(test3.path, "world", world5, "world", "world");
|
|
251448
251463
|
let worldDoc;
|
|
251449
251464
|
try {
|
|
251450
251465
|
worldDoc = parseSceneYaml(await readFile10(join23(root3, world5), "utf8"));
|
|
@@ -251453,14 +251468,14 @@ async function bundleInventory(input5) {
|
|
|
251453
251468
|
}
|
|
251454
251469
|
for (const reference3 of namedFiles(world5, worldDoc)) {
|
|
251455
251470
|
if (!await exists2(join23(root3, reference3.to))) missing10.push(`${world5}: ${reference3.field}: ${reference3.to} is missing`);
|
|
251456
|
-
else
|
|
251471
|
+
else link8(world5, reference3.field, reference3.to, reference3.kind, reference3.role);
|
|
251457
251472
|
}
|
|
251458
251473
|
}
|
|
251459
251474
|
const records6 = await recordsFor(test3.path, root3);
|
|
251460
|
-
if (records6 !== void 0)
|
|
251475
|
+
if (records6 !== void 0) link8(test3.path, "records", projectPath(root3, records6, `${test3.path}: records:`), "records", "runtime-data");
|
|
251461
251476
|
for (const [name5, role3] of Object.entries(COMPANIONS)) {
|
|
251462
251477
|
const to = posix3.join(posix3.dirname(test3.path), name5);
|
|
251463
|
-
if (await exists2(join23(root3, to)))
|
|
251478
|
+
if (await exists2(join23(root3, to))) link8(test3.path, name5, to, role3, role3);
|
|
251464
251479
|
}
|
|
251465
251480
|
}
|
|
251466
251481
|
if (missing10.length) throw missingReference(missing10);
|
|
@@ -252588,6 +252603,7 @@ init_run_store();
|
|
|
252588
252603
|
// packages/cli/src/report-html.ts
|
|
252589
252604
|
init_src();
|
|
252590
252605
|
init_report2();
|
|
252606
|
+
import { createHash as createHash66 } from "node:crypto";
|
|
252591
252607
|
|
|
252592
252608
|
// packages/cli/src/report-data.ts
|
|
252593
252609
|
init_src();
|
|
@@ -252772,8 +252788,8 @@ function attemptOf2(scene2, detail3, n2, anchor2, records6, sceneRecord, cloud,
|
|
|
252772
252788
|
...scene2.failures.filter((f2) => f2.trial === n2).map((f2) => ({ id: f2.check, required: true, state: "failed", expected: f2.expected, actual: f2.actual, why: f2.explanation })),
|
|
252773
252789
|
...(scene2.warnings ?? []).filter((w2) => w2.trial === n2).map((w2) => ({ id: w2.check, required: false, state: "skipped", expected: "", actual: "", why: w2.message }))
|
|
252774
252790
|
];
|
|
252775
|
-
const
|
|
252776
|
-
const outcome4 = !valid2 ? "invalid" : detail3.outcome === "skipped" || detail3.outcome === "xfailed" ? "ungraded" : pytest ? detail3.passed ? "passed" : "failed" : !
|
|
252791
|
+
const graded2 = files2?.checks ? checks2.some((c) => c.state === "passed" || c.state === "failed") : scene2.graded !== false;
|
|
252792
|
+
const outcome4 = !valid2 ? "invalid" : detail3.outcome === "skipped" || detail3.outcome === "xfailed" ? "ungraded" : pytest ? detail3.passed ? "passed" : "failed" : !graded2 ? "ungraded" : detail3.passed ? "passed" : "failed";
|
|
252777
252793
|
const trace2 = files2?.trace ? projectToolCalls(files2.trace) : [];
|
|
252778
252794
|
const start2 = Date.parse(sceneRecord?.start_time ?? "");
|
|
252779
252795
|
const agentCalls2 = trace2.filter((entry3) => entry3.source === "agent" && entry3.service !== "agent");
|
|
@@ -252933,7 +252949,7 @@ var s2 = (n2, one7, many) => n2 === 1 ? one7 : many;
|
|
|
252933
252949
|
var pct2 = (rate) => typeof rate === "number" && Number.isFinite(rate) ? `${Math.round(rate * 1e3) / 10}%` : esc2(rate);
|
|
252934
252950
|
var iso25 = (value6) => {
|
|
252935
252951
|
const at6 = Date.parse(value6 ?? "");
|
|
252936
|
-
return Number.isNaN(at6) ? "\u2014" : new Date(at6).toISOString().replace(
|
|
252952
|
+
return Number.isNaN(at6) ? "\u2014" : `${new Date(at6).toISOString().slice(0, 19).replace("T", " ")} UTC`;
|
|
252937
252953
|
};
|
|
252938
252954
|
var clock = (value6) => {
|
|
252939
252955
|
const at6 = Date.parse(value6 ?? "");
|
|
@@ -252948,14 +252964,12 @@ function dur(ms2) {
|
|
|
252948
252964
|
return h > 0 ? `${h} h ${m} min` : `${m} min ${total6 % 60} s`;
|
|
252949
252965
|
}
|
|
252950
252966
|
var offset19 = (ms2) => ms2 === null ? "\u2014" : ms2 < 6e4 ? `+${(Math.max(0, ms2) / 1e3).toFixed(1)} s` : `+${Math.floor(ms2 / 6e4)}:${String(Math.floor(ms2 % 6e4 / 1e3)).padStart(2, "0")}`;
|
|
252951
|
-
var link6 = (n2, href2) => `<a class="n" href="#${href2}">${num4(n2)}</a>`;
|
|
252952
252967
|
var OUTCOME = {
|
|
252953
252968
|
passed: { word: "passed", title: "Passed", mark: "\u2713", cls: "ok" },
|
|
252954
252969
|
failed: { word: "failed", title: "Failed", mark: "\xD7", cls: "no" },
|
|
252955
|
-
invalid: { word: "invalid", title: "
|
|
252956
|
-
ungraded: { word: "ungraded", title: "
|
|
252970
|
+
invalid: { word: "invalid", title: "Could not be graded", mark: "!", cls: "inv" },
|
|
252971
|
+
ungraded: { word: "ungraded", title: "Could not be graded", mark: "\u2013", cls: "ung" }
|
|
252957
252972
|
};
|
|
252958
|
-
var ORDER2 = ["failed", "invalid", "ungraded", "passed"];
|
|
252959
252973
|
var VERDICT = { pass: { title: "Passed", cls: "ok" }, fail: { title: "Failed", cls: "no" }, ungraded: { title: "Ungraded", cls: "ung" } };
|
|
252960
252974
|
var tone = (cls) => cls === "ok" ? "pass" : cls === "no" ? "fail" : "none";
|
|
252961
252975
|
var pill = (cls, text31) => `<span class="k-badge ${tone(cls)}"><span aria-hidden="true">${cls === "ok" ? "\u2713" : cls === "no" ? "\xD7" : "!"}</span>${text31}</span>`;
|
|
@@ -252963,44 +252977,36 @@ var checksOf = (attempt2) => {
|
|
|
252963
252977
|
const evaluated = attempt2.checks.filter((c) => c.state === "passed" || c.state === "failed");
|
|
252964
252978
|
return { passed: evaluated.filter((c) => c.state === "passed").length, evaluated: evaluated.length };
|
|
252965
252979
|
};
|
|
252966
|
-
var
|
|
252967
|
-
var
|
|
252980
|
+
var outcomeOf3 = (a) => /^(cancelled|canceled)$/.test(a.exit) ? { title: "Cancelled", mark: "\u2013", cls: "ung", state: "cancelled" } : { ...OUTCOME[a.outcome], state: a.outcome };
|
|
252981
|
+
var graded = (a) => outcomeOf3(a).state === "passed" || outcomeOf3(a).state === "failed";
|
|
252968
252982
|
function verdictBlock(d) {
|
|
252969
|
-
const
|
|
252970
|
-
const
|
|
252971
|
-
const said = d.pytest ? `pytest reported ${q(d.pytest.outcome)}${d.verdict === "ungraded" ? ", so nothing was graded" : ""}` : d.verdict === "ungraded" || tests === 0 ? "No result" : d.verdict === "fail" && d.tests.some((test3) => test3.failed) ? of((test3) => test3.failed, "test failed", "tests failed") : d.verdict === "pass" ? `All ${link6(tests, "tests")} ${s2(tests, "test passed", "tests passed")}` : of((test3) => test3.graded && !test3.failed, "test passed", "tests passed");
|
|
252983
|
+
const attempts = d.tests.flatMap((test3) => test3.attempts), v = VERDICT[d.verdict];
|
|
252984
|
+
const said = d.pytest ? `pytest reported ${q(d.pytest.outcome)}` : !attempts.length ? "No result" : `${num4(attempts.filter(graded).length)} of ${num4(attempts.length)} ${s2(attempts.length, "attempt", "attempts")} graded \xB7 ${num4(attempts.filter((a) => outcomeOf3(a).state === "passed").length)} passed`;
|
|
252972
252985
|
const actions = d.hostedUrl ? `<div class="k-actions"><a class="k-btn primary" href="${esc2(d.hostedUrl)}">Open in Ancha</a></div>` : "";
|
|
252973
|
-
return `<div class="k-head"><div class="k-title"><h1 id="verdict">${said}</h1>${pill(
|
|
252974
|
-
}
|
|
252975
|
-
function
|
|
252976
|
-
|
|
252977
|
-
|
|
252978
|
-
|
|
252979
|
-
|
|
252980
|
-
|
|
252981
|
-
|
|
252982
|
-
});
|
|
252983
|
-
const
|
|
252984
|
-
|
|
252985
|
-
const
|
|
252986
|
-
for (const
|
|
252987
|
-
|
|
252988
|
-
|
|
252989
|
-
|
|
252990
|
-
|
|
252991
|
-
|
|
252992
|
-
|
|
252993
|
-
|
|
252994
|
-
const check4 = first2.checks.find((c) => c.state === "failed");
|
|
252995
|
-
const missingAnswer = first2.recorded && first2.answer === null && !!check4 && /no (?:final )?answer|no output|answer.*(?:missing|empty)/i.test(`${check4.actual} ${check4.why}`);
|
|
252996
|
-
const title2 = missingAnswer ? "The agent gave no final answer" : check4 ? `Check ${code2(check4.id)} failed` : "The attempt failed";
|
|
252997
|
-
const why = check4 ? q(cut2(check4.why || check4.actual || check4.expected, 400)) : first2.issues.length ? q(first2.issues[0]) : first2.exit === "exited" ? `exited ${num4(first2.exitCode)}` : code2(first2.exit);
|
|
252998
|
-
alert = `<section class="failure-alert" aria-label="What to fix"><div class="alert-head"><h2>${title2}</h2><a href="#${first2.anchor}">${code2(first2.testId)} \xB7 Attempt ${num4(first2.n)}</a></div><p>${why}</p>` + (missingAnswer ? `<p>An agent answers by posting to ${code2("ANCHA_DONE_URL")} or printing the answer on stdout.</p><pre class="copy-box">${esc2('POST $ANCHA_DONE_URL {"output": "<answer>"}')}</pre>` : "") + `${fails.length ? `<ul class="fails">${fails.join("")}</ul>` : ""}</section>`;
|
|
252999
|
-
}
|
|
253000
|
-
return `${alert}${lines2.length ? `<ul class="v-lines">${lines2.join("")}</ul>` : ""}${compared}`;
|
|
252986
|
+
return `<div class="k-head"><div class="k-title"><h1 id="verdict">${said}</h1>${pill(!attempts.length ? "ung" : v.cls, !attempts.length || d.verdict === "ungraded" ? "No result" : v.title)}</div>${actions}</div>`;
|
|
252987
|
+
}
|
|
252988
|
+
function sandboxes(d) {
|
|
252989
|
+
return `<section id="sandboxes" class="k-card" aria-labelledby="sandboxes-h"><h2 id="sandboxes-h">Sandboxes</h2>${d.tests.map((test3) => `<div class="sandbox-row"><div class="sandbox-test"><h3>${q(test3.title)}</h3><span class="muted">${num4(test3.attempts.filter((a) => outcomeOf3(a).state === "passed").length)}/${num4(test3.attempts.filter(graded).length)} passed</span></div><div class="sandbox-boxes">${test3.attempts.map((a) => {
|
|
252990
|
+
const o = outcomeOf3(a), label7 = `${test3.title} \xB7 Attempt ${a.n}: ${o.title}`;
|
|
252991
|
+
return `<a class="sandbox ${o.state}" href="#${esc2(a.anchor)}" title="${esc2(label7)}" aria-label="${esc2(label7)}"><span class="att">Attempt ${num4(a.n)}</span><span><span aria-hidden="true">${o.mark}</span> ${o.title}</span></a>`;
|
|
252992
|
+
}).join("")}</div></div>`).join("")}</section>`;
|
|
252993
|
+
}
|
|
252994
|
+
function results(d) {
|
|
252995
|
+
const lines2 = d.tests.map((test3) => ({ test: test3, failed: test3.attempts.flatMap((a) => a.checks.filter((c) => c.state === "failed").map((c) => `<li><a href="#${esc2(a.anchor)}">${code2(c.id)} \xB7 Attempt ${num4(a.n)}</a>: expected ${q(cut2(c.expected, 240))} \xB7 observed ${q(cut2(c.actual, 240))}</li>`)) }));
|
|
252996
|
+
const anyFailed = lines2.some((line2) => line2.failed.length > 0);
|
|
252997
|
+
const rows35 = lines2.map(({ test: test3, failed: failed2 }) => `<tr><th scope="row"><a href="#${esc2(test3.anchor)}">${q(test3.title)}</a></th><td class="num">${num4(test3.attempts.filter((a) => outcomeOf3(a).state === "passed").length)}/${num4(test3.attempts.filter(graded).length)}</td>${anyFailed ? `<td>${failed2.length ? `<ul class="failed-lines">${failed2.join("")}</ul>` : "\u2014"}</td>` : ""}</tr>`).join("");
|
|
252998
|
+
const groups = /* @__PURE__ */ new Map();
|
|
252999
|
+
for (const a of d.tests.flatMap((test3) => test3.attempts).filter((a2) => !graded(a2))) {
|
|
253000
|
+
const reason2 = outcomeOf3(a).state === "cancelled" ? "Cancelled" : a.issues[0] || a.checks.find((c) => c.why)?.why || (a.exit === "not run" ? "Not run" : a.checks.length ? "No checks evaluated" : a.outcome === "ungraded" ? "No checks" : "Could not be graded");
|
|
253001
|
+
const group5 = groups.get(reason2) ?? [];
|
|
253002
|
+
group5.push(a);
|
|
253003
|
+
groups.set(reason2, group5);
|
|
253004
|
+
}
|
|
253005
|
+
const nothing = [...groups].map(([reason2, attempts]) => `<li>${num4(attempts.length)} ${s2(attempts.length, "attempt tested nothing:", "attempts tested nothing:")} <a href="#${esc2(attempts[0].anchor)}">${q(reason2)}</a></li>`).join("");
|
|
253006
|
+
return `<section id="tests" class="k-card" aria-labelledby="tests-h"><h2 id="tests-h">Tests</h2><div class="scroll"><table class="results"><thead><tr><th scope="col">Test</th><th scope="col" class="num">Passed / graded</th>${anyFailed ? '<th scope="col">Failed checks</th>' : ""}</tr></thead><tbody>${rows35}</tbody></table></div>${nothing ? `<ul class="not-graded">${nothing}</ul>` : ""}</section>`;
|
|
253001
253007
|
}
|
|
253002
253008
|
function runFacts(d) {
|
|
253003
|
-
const
|
|
253009
|
+
const rows35 = [];
|
|
253004
253010
|
rows35.push(["Verdict", `${VERDICT[d.verdict].title}<small>Minimum pass rate ${pct2(d.minPassRate)}</small>`]);
|
|
253005
253011
|
const provenance = [d.agent.projectHash && `project ${code2(d.agent.projectHash)}`, d.agent.commit && `commit ${code2(d.agent.commit)}`, d.agent.cliVersion && `CLI ${code2(d.agent.cliVersion)}`].filter(Boolean).join(" \xB7 ");
|
|
253006
253012
|
rows35.push(["Agent", `${q(d.agent.name)}${d.agent.command ? `<small>${code2(d.agent.command)}</small>` : ""}${provenance ? `<small>${provenance}</small>` : ""}${d.pytest ? `<small>pytest ${code2(d.pytest.nodeId)}</small>` : ""}`]);
|
|
@@ -253010,87 +253016,16 @@ function runFacts(d) {
|
|
|
253010
253016
|
const span3 = Date.parse(d.finishedAt) - Date.parse(d.startedAt);
|
|
253011
253017
|
rows35.push(["Ran", `${iso25(d.startedAt)}<small>finished ${iso25(d.finishedAt)}</small><small>${dur(span3)}</small>`]);
|
|
253012
253018
|
rows35.push(["Where", d.where === "cloud" ? `Ancha Cloud${d.workspace ? `<small>workspace ${q(d.workspace)}</small>` : ""}${d.imageDigest ? `<small>image ${code2(d.imageDigest)}</small>` : ""}` : `This computer${d.workspace ? `<small>${code2(d.workspace)}</small>` : ""}`]);
|
|
253013
|
-
const atOnce2 = d.atOnce === null ? "" : `<small>at most ${num4(d.atOnce)} at once</small>`;
|
|
253014
|
-
rows35.push(["Machines", d.where === "cloud" ? `${link6(t.attempts, "machines")} ${s2(t.attempts, "attempt on", "attempts on")} ${link6(t.machines, "machines")} ${s2(t.machines, "machine", "machines")}${atOnce2}` : `${link6(t.attempts, "machines")} ${s2(t.attempts, "attempt on this computer", "attempts on this computer")}${atOnce2}`]);
|
|
253015
|
-
rows35.push(["Attempts", `${link6(t.passed, attemptsOf(d, "passed"))} passed<small>${["failed", "invalid", "ungraded"].map((outcome4) => `${link6(t[outcome4], attemptsOf(d, outcome4))} ${outcome4}`).join(" \xB7 ")}</small>`]);
|
|
253016
|
-
rows35.push(["Checks", `${link6(c.passed, "evidence")} of ${link6(c.evaluated, "evidence")} ${s2(c.evaluated, "check passed", "checks passed")}<small>${link6(c.failed, c.failed ? "failed-checks" : "evidence")} failed \xB7 ${link6(c.invalid, "evidence")} invalid \xB7 ${link6(c.skipped, "evidence")} skipped</small>`]);
|
|
253017
253019
|
return `<section id="run" aria-labelledby="run-h"><h2 id="run-h">Run</h2><dl class="facts">${rows35.map(([term2, value6]) => `<div><dt>${term2}</dt><dd>${value6}</dd></div>`).join("")}</dl></section>`;
|
|
253018
253020
|
}
|
|
253019
|
-
function attemptSquares(test3) {
|
|
253020
|
-
return `<span class="k-squares">${test3.attempts.map((a) => {
|
|
253021
|
-
const o = OUTCOME[a.outcome], label7 = `Attempt ${a.n}: ${o.title}`;
|
|
253022
|
-
return `<a href="#${a.anchor}" aria-label="${esc2(`${test3.id} \xB7 ${label7}`)}" title="${esc2(label7)}"><span class="k-sq ${tone(o.cls)}" role="img" aria-label="${esc2(label7)}">${o.mark}</span></a>`;
|
|
253023
|
-
}).join("")}</span>`;
|
|
253024
|
-
}
|
|
253025
|
-
function matrix(d) {
|
|
253026
|
-
const t = d.totals, compared = d.comparison !== null;
|
|
253027
|
-
const head = `<tr><th scope="col">Test</th><th scope="col">Attempts</th><th scope="col" class="num">Checks</th><th scope="col" class="num">Calls</th><th scope="col" class="num">Agent time</th>${compared ? '<th scope="col" class="num">Change</th>' : ""}</tr>`;
|
|
253028
|
-
const rows35 = d.tests.map((test3) => {
|
|
253029
|
-
const times2 = test3.attempts.filter((a) => a.outcome !== "invalid" || a.realMs > 0).map((a) => a.realMs).sort((x, y) => x - y);
|
|
253030
|
-
const median = times2.length ? times2[Math.floor(times2.length / 2)] : NaN, c = test3.checkTotals;
|
|
253031
|
-
const calls2 = test3.attempts.reduce((sum6, a) => sum6 + a.callCount, 0);
|
|
253032
|
-
const change4 = test3.change === null ? '<td class="num">\u2014</td>' : `<td class="num ${test3.change.delta < 0 ? "fail-t" : ""}"><a class="n" href="#${test3.anchor}">${esc2(formatRateDelta(test3.change.delta))}</a></td>`;
|
|
253033
|
-
return `<tr><th scope="row"><a class="test-name" href="#${test3.anchor}">${q(test3.variant?.change ?? (test3.task || test3.title))}<small>${code2(test3.id)}</small></a></th><td>${attemptSquares(test3)}</td><td class="num"><a class="n" href="#${test3.anchor}">${num4(c.passed)}/${num4(c.evaluated)}</a></td><td class="num"><a class="n" href="#${test3.anchor}">${num4(calls2)}</a></td><td class="num">${Number.isNaN(median) ? "\u2014" : dur(median)}</td>${compared ? change4 : ""}</tr>`;
|
|
253034
|
-
}).join("");
|
|
253035
|
-
const each = [...new Set(d.tests.map((test3) => test3.requested))].sort((a, b) => a - b);
|
|
253036
|
-
const eachCount = each.length === 0 ? "\u2014" : each.length === 1 ? link6(each[0], "tests") : `${link6(each[0], "tests")}\u2013${link6(each.at(-1), "tests")}`;
|
|
253037
|
-
const label7 = `${t.passed} of ${t.attempts} attempts passed; ${t.failed} failed; ${t.invalid} invalid; ${t.ungraded} ungraded`;
|
|
253038
|
-
const meter = `<div class="k-meter" role="img" aria-label="${esc2(label7)}">${["passed", "failed", "invalid", "ungraded"].filter((outcome4) => t[outcome4] > 0).map((outcome4) => `<span class="${tone(OUTCOME[outcome4].cls)}" style="flex-grow:${num4(t[outcome4]).replaceAll(",", "")}" aria-hidden="true"></span>`).join("")}</div>`;
|
|
253039
|
-
const once2 = d.tests.length > 0 && d.tests.every((test3) => test3.requested === 1 && test3.attempts.length === 1 && test3.attempts[0].exit !== "not run");
|
|
253040
|
-
const note2 = once2 ? `<p class="k-note">Each test ran once. Add ${code2("--attempts 3")} to see how often each one passes.</p>` : "";
|
|
253041
|
-
return `<section id="tests" class="k-card" aria-labelledby="tests-h"><div class="k-progress"><div class="progress-line"><h2 id="tests-h">${link6(t.passed, attemptsOf(d, "passed"))} of ${link6(t.attempts, "machines")} ${s2(t.attempts, "attempt passed", "attempts passed")}</h2><span class="muted">${t.attempts ? pct2(t.passed / t.attempts) : "\u2014"}</span></div>${meter}<div class="test-counts"><span>Tests ${link6(d.tests.length, "tests")}</span><span>Attempts per test ${eachCount}</span><span>Total attempts ${link6(t.attempts, "machines")}</span></div></div><div class="scroll"><table class="matrix"><thead>${head}</thead><tbody>${rows35}</tbody></table></div>${note2}</section>`;
|
|
253042
|
-
}
|
|
253043
|
-
function timeline(d) {
|
|
253044
|
-
const time7 = (value6) => Date.parse(value6 ?? "");
|
|
253045
|
-
const rows35 = d.tests.flatMap((test3) => test3.attempts).filter((a) => Number.isFinite(time7(a.machineAt)) && Number.isFinite(time7(a.finishedAt))).sort((a, b) => time7(a.machineAt) - time7(b.machineAt) || a.anchor.localeCompare(b.anchor));
|
|
253046
|
-
if (!rows35.length) return "";
|
|
253047
|
-
const t0 = Math.min(...rows35.map((a) => time7(a.machineAt))), span3 = Math.max(1, Math.max(...rows35.map((a) => time7(a.finishedAt))) - t0);
|
|
253048
|
-
const at6 = (ms2) => `${((ms2 - t0) / span3 * 100).toFixed(2)}%`;
|
|
253049
|
-
const slots = [];
|
|
253050
|
-
for (const a of rows35) {
|
|
253051
|
-
const start2 = time7(a.machineAt), end = Math.max(start2, time7(a.finishedAt)), agent = Math.min(end, Math.max(start2, time7(a.agentAt) || start2));
|
|
253052
|
-
let slot = slots.find((item2) => item2.free <= start2);
|
|
253053
|
-
if (!slot) slots.push(slot = { free: start2, bars: [] });
|
|
253054
|
-
slot.free = end;
|
|
253055
|
-
const o = OUTCOME[a.outcome], setup2 = end > start2 ? ((agent - start2) / (end - start2) * 100).toFixed(1) : "0";
|
|
253056
|
-
slot.bars.push(`<a class="bar ${o.cls}" href="#${a.anchor}" style="left:${at6(start2)};width:max(${((end - start2) / span3 * 100).toFixed(2)}%,4px)"><i style="width:${setup2}%"></i><span><span data-q>${esc2(a.testId)}</span> \xB7 ${a.n}<span class="sr"> ${o.word}</span></span></a>`);
|
|
253057
|
-
}
|
|
253058
|
-
const minutes = span3 / 6e4, step3 = [1, 2, 5, 10, 15, 30, 60].find((m) => minutes / m <= 8) ?? 120;
|
|
253059
|
-
const ticks = [];
|
|
253060
|
-
for (let m = 0; m * 6e4 <= span3; m += step3) ticks.push(m);
|
|
253061
|
-
const axis = ticks.map((m) => `<span class="ln-tick${m === 0 ? " first" : ""}" style="left:${at6(t0 + m * 6e4)}">${m === 0 ? clock(new Date(t0).toISOString()) : `+${m} min`}</span>`).join("");
|
|
253062
|
-
const grid2 = ticks.map((m) => `<i class="ln-gl" style="left:${at6(t0 + m * 6e4)}"></i>`).join("");
|
|
253063
|
-
const most = Math.max(...slots.map((slot) => slot.bars.length));
|
|
253064
|
-
return `<div class="timeline scroll"><div class="lanes" style="min-width:${Math.max(560, 72 + most * 96)}px"><div class="ln-row ln-axis"><span></span><div class="ln-track">${axis}</div></div>` + slots.map((slot, k) => `<div class="ln-row"><span class="ln-slot">Slot ${k + 1}</span><div class="ln-track">${grid2}${slot.bars.join("")}</div></div>`).join("") + `</div></div><div class="legend"><span><i class="lg-setup"></i>Machine start and install</span>${ORDER2.filter((o) => d.totals[o] > 0).map((o) => `<span><i class="lg-${OUTCOME[o].cls}"></i>Agent ran, ${OUTCOME[o].word}</span>`).join("")}</div>`;
|
|
253065
|
-
}
|
|
253066
|
-
function machines(d) {
|
|
253067
|
-
const cloud = d.where === "cloud", t = d.totals;
|
|
253068
|
-
const sub2 = cloud ? d.atOnce === null ? `<p class="sub">${num4(t.attempts)} attempts, each on its own machine, on one clock.</p>` : `<p class="sub">${num4(t.attempts)} attempts, at most ${num4(d.atOnce)} at once, on one clock.</p>` : `<p class="sub">${num4(t.attempts)} ${s2(t.attempts, "attempt on this computer.", "attempts on this computer.")}</p>`;
|
|
253069
|
-
const groups = ORDER2.map((outcome4) => {
|
|
253070
|
-
const rows35 = d.tests.flatMap((test3) => test3.attempts).filter((a) => a.outcome === outcome4);
|
|
253071
|
-
if (!rows35.length) return "";
|
|
253072
|
-
return `<tbody id="attempts-${outcome4}"><tr class="grp"><th colspan="${cloud ? 7 : 4}" scope="rowgroup">${OUTCOME[outcome4].title} \xB7 ${num4(rows35.length)}</th></tr>${rows35.map((a) => {
|
|
253073
|
-
const machine = a.machine ? `${code2(a.machine.label)}${a.machine.region ? ` <small>${q(a.machine.region)}</small>` : ""}` : "\u2014";
|
|
253074
|
-
const where3 = cloud ? `<td>${machine}</td><td class="wide">${clock(a.machineAt ?? a.agentAt)}</td><td class="wide">${clock(a.finishedAt)}</td>` : "";
|
|
253075
|
-
return `<tr><td><a href="#${a.anchor}">${code2(a.testId)} \xB7 ${a.n}</a></td><td>${pill(OUTCOME[a.outcome].cls, OUTCOME[a.outcome].title)}</td>${where3}<td class="num">${a.exit === "not run" && !a.realMs ? "\u2014" : dur(a.realMs)}</td><td class="num"><a class="n" href="#${a.anchor}">${num4(a.callCount)}</a><span class="nar"> ${s2(a.callCount, "call", "calls")}</span></td></tr>`;
|
|
253076
|
-
}).join("")}</tbody>`;
|
|
253077
|
-
}).join("");
|
|
253078
|
-
const head = `<th scope="col">Attempt</th><th scope="col">Outcome</th>${cloud ? '<th scope="col">Machine</th><th scope="col" class="wide">Started</th><th scope="col" class="wide">Finished</th>' : ""}<th scope="col" class="num">Agent time</th><th scope="col" class="num">Calls</th>`;
|
|
253079
|
-
return `<section id="machines" aria-labelledby="machines-h"><h2 id="machines-h">${cloud ? "Machines" : "Attempts"}</h2>${sub2}${cloud ? timeline(d) : ""}<div class="scroll"><table class="atts"><thead><tr>${head}</tr></thead>${groups}</table></div></section>`;
|
|
253080
|
-
}
|
|
253081
|
-
function failedChecks(d) {
|
|
253082
|
-
const rows35 = d.tests.flatMap((test3) => test3.attempts.flatMap((a) => a.checks.filter((c) => c.state === "failed").map((c) => ({ test: test3, a, c }))));
|
|
253083
|
-
if (!rows35.length) return "";
|
|
253084
|
-
return `<section id="failed-checks" aria-labelledby="failed-checks-h"><h2 id="failed-checks-h">Failed checks</h2><div class="scroll"><table class="fchecks"><thead><tr><th scope="col">Attempt</th><th scope="col">Check</th><th scope="col">Expected</th><th scope="col">Actual</th></tr></thead><tbody>${rows35.map(({ a, c }) => `<tr><td><a href="#${a.anchor}">${code2(a.testId)} \xB7 ${a.n}</a></td><td>${code2(c.id)}</td><td><span class="nar lbl">Expected</span>${q(cut2(c.expected, 240))}</td><td><span class="nar lbl">Actual</span>${q(cut2(c.actual, 240))}</td></tr>`).join("")}</tbody></table></div></section>`;
|
|
253085
|
-
}
|
|
253086
253021
|
var cut2 = (text31, max) => text31.length > max ? `${text31.slice(0, max)}\u2026` : text31;
|
|
253087
253022
|
function callLine(call4) {
|
|
253088
253023
|
const what = `${call4.kind === "tool" ? '<span class="tl">Agent tool</span>' : `<span class="tl" data-q>${esc2(call4.tool)}</span>`} ${code2(call4.target)}`;
|
|
253089
253024
|
const result = [call4.fault ? `injected by <span data-q>${esc2(call4.fault.ref)}</span>` : "", call4.status === null ? "" : num4(call4.status), call4.count === null ? "" : `${num4(call4.count.value)} ${call4.count.unit}${call4.count.value === 1 ? "" : "s"}`, call4.ms === null ? "" : `${num4(call4.ms)} ms`].filter(Boolean).join(" \xB7 ");
|
|
253090
253025
|
return `<li><span class="step-n" aria-hidden="true"></span><span class="t">${offset19(call4.offsetMs)}</span>${call4.kind === "mcp" ? '<span class="m m-post">MCP</span>' : `<span class="m m-${esc2(call4.method.toLowerCase())}" data-q>${esc2(call4.method)}</span>`}<span class="p">${what}</span><span class="r">${result}</span>${call4.body === null ? "" : `<pre class="q">${esc2(call4.body)}</pre>`}</li>`;
|
|
253091
253026
|
}
|
|
253092
|
-
function attemptBlock(test3, a
|
|
253093
|
-
const o =
|
|
253027
|
+
function attemptBlock(test3, a) {
|
|
253028
|
+
const o = outcomeOf3(a), c = checksOf(a);
|
|
253094
253029
|
const meta6 = [
|
|
253095
253030
|
c.evaluated ? `<span>${num4(c.passed)}/${num4(c.evaluated)} ${s2(c.evaluated, "check", "checks")}</span>` : "",
|
|
253096
253031
|
a.machine ? `<span>machine ${code2(a.machine.label)}</span>` : "",
|
|
@@ -253099,18 +253034,18 @@ function attemptBlock(test3, a, open17) {
|
|
|
253099
253034
|
`<span>${num4(a.callCount)} ${s2(a.callCount, "call", "calls")}</span>`,
|
|
253100
253035
|
`<span>${a.exit === "exited" ? `exited ${a.exitCode === null ? "" : num4(a.exitCode)}` : code2(a.exit)}</span>`
|
|
253101
253036
|
].filter(Boolean).join("");
|
|
253102
|
-
const summary = `<summary>${pill(o.cls, o.title)}<span class="att">Attempt ${a.n}</span><span class="meta">${meta6}</span></summary>`;
|
|
253037
|
+
const summary = `<summary>${pill(o.cls, o.title)}<span class="att">Attempt ${num4(a.n)}</span><span class="meta">${meta6}</span></summary>`;
|
|
253103
253038
|
const route15 = ["quickbooks", "netsuite"].map((toolkit) => a.routes?.[toolkit] ? `<p class="muted" data-q>${esc2(formatRouteSummary(a.routes[toolkit], toolkit))}</p>` : "").join("");
|
|
253104
253039
|
const checks2 = a.checks.length ? `<div class="scroll"><table class="check-fields"><thead><tr><th scope="col">Check</th><th scope="col">Expected</th><th scope="col">Actual</th><th scope="col">Outcome</th></tr></thead><tbody>${a.checks.map((check4) => `<tr><th scope="row">${code2(check4.id)}</th><td>${q(check4.expected)}</td><td class="${check4.state === "failed" ? "fail-t" : ""}">${q(check4.actual)}${check4.why && check4.why !== check4.actual ? `<span class="why">${q(check4.why)}</span>` : ""}</td><td>${pill(check4.state === "passed" ? "ok" : check4.state === "failed" ? "no" : "ung", check4.state)}</td></tr>`).join("")}</tbody></table></div>` : '<p class="muted">\u2014</p>';
|
|
253105
253040
|
const issues = a.issues.length ? `<h4>Issues</h4><ul class="plain">${a.issues.map((issue9) => `<li>${q(issue9)}</li>`).join("")}</ul>` : "";
|
|
253106
|
-
if (!a.recorded) return `<details class="attempt" id="${a.anchor}"
|
|
253041
|
+
if (!a.recorded) return `<details class="attempt" id="${a.anchor}">${summary}<div class="att-body">${route15}${a.checks.length ? `<h4>Checks</h4>${checks2}` : ""}${issues}<p class="muted">No records for this attempt.</p></div></details>`;
|
|
253107
253042
|
const expected = test3.checks.filter((check4) => check4.expected).map((check4) => `<li>${q(check4.expected)}</li>`).join("");
|
|
253108
253043
|
const answer = a.answer === null ? '<p class="muted">No final answer.</p>' : `<pre class="answer">${esc2(a.answer.text)}</pre><p class="muted">from ${code2(a.answer.source)}${a.answer.more ? ` \xB7 ${num4(a.answer.more)} characters more in ${code2(a.tracePath)}` : ""}</p>`;
|
|
253109
253044
|
const changes = (a.changes ?? []).map((group5) => `<div><h4>Changes in <span data-q>${esc2(group5.tool)}</span></h4>${group5.records.length ? `<div class="scroll"><table class="changes"><thead><tr><th scope="col">Record</th><th scope="col">Field</th><th scope="col">Before</th><th scope="col">After</th></tr></thead><tbody>${group5.records.flatMap((change4) => change4.fields.length ? change4.fields.map((field6) => `<tr><td>${code2(change4.record)}</td><td>${code2(field6.name)}</td><td>${field6.before === null ? "\u2014" : q(field6.before)}</td><td>${q(field6.after)}</td></tr>`) : [`<tr><td>${code2(change4.record)}</td><td>\u2014</td><td>\u2014</td><td>${change4.operation === "create" ? "made" : change4.operation === "delete" ? "removed" : code2(change4.operation)}</td></tr>`]).join("")}</tbody></table></div>` : '<p class="muted">No record changed.</p>'}</div>`).join("");
|
|
253110
253045
|
const calls2 = a.calls.length ? `<ol class="calls">${a.calls.map(callLine).join("")}${a.callCount > a.calls.length ? `<li class="more">and ${num4(a.callCount - a.calls.length)} more in ${code2(a.tracePath)}</li>` : ""}</ol>` : '<p class="muted">\u2014</p>';
|
|
253111
253046
|
const gaps3 = a.gaps.length ? `<h4>API responses</h4><ul class="plain">${a.gaps.map((gap8) => `<li><span data-q>${esc2(gap8.tool)}</span> ${code2(`${gap8.method} ${gap8.path}`)}${gap8.status === null ? "" : ` \xB7 ${num4(gap8.status)}`}</li>`).join("")}</ul>` : "";
|
|
253112
253047
|
const log3 = a.log.length ? `<pre class="log">${esc2(a.log.join("\n"))}</pre>` : '<p class="muted">The agent wrote no log.</p>';
|
|
253113
|
-
return `<details class="attempt" id="${a.anchor}"
|
|
253048
|
+
return `<details class="attempt" id="${a.anchor}">${summary}<div class="att-body">${route15}<div class="pair"><div><h4>Expected</h4>${expected ? `<ul class="lines">${expected}</ul>` : '<p class="muted">\u2014</p>'}</div><div><h4>Answer</h4>${answer}</div></div><div class="split"><div><h4>Checks</h4>${checks2}</div>${changes}</div><h4>Calls</h4>${calls2}${gaps3}${issues}<h4>Agent log, last ${LOG_LINES} lines</h4>${log3}<p class="muted">Full log: ${code2(a.logPath)}</p></div></details>`;
|
|
253114
253049
|
}
|
|
253115
253050
|
function checkGrid(test3) {
|
|
253116
253051
|
if (!test3.checks.length) return "";
|
|
@@ -253124,36 +253059,40 @@ function checkGrid(test3) {
|
|
|
253124
253059
|
return `<div class="scroll"><table class="cgrid"><thead>${head}</thead><tbody>${rows35}</tbody></table></div>`;
|
|
253125
253060
|
}
|
|
253126
253061
|
function evidence2(d) {
|
|
253127
|
-
const first2 = d.tests.flatMap((test3) => test3.attempts).find((a) => a.outcome === "failed");
|
|
253128
253062
|
const tests = d.tests.map((test3) => {
|
|
253129
253063
|
const t = test3.checkTotals, cls = test3.failed ? "no" : test3.graded ? "ok" : "ung";
|
|
253130
|
-
return `<details class="scenario" id="${test3.anchor}" open><summary>${pill(cls, `${num4(test3.passed)}/${num4(test3.requested)}`)}<span class="s-title">${q(test3.title)}</span><span class="s-checks">${num4(t.passed)}/${num4(t.evaluated)} ${s2(t.evaluated, "check", "checks")}</span></summary><div class="s-body">${test3.variant ? `<p data-q>${esc2(test3.variant.change)}</p>` : ""}${test3.title !== test3.id ? `<p class="muted">${code2(test3.id)}</p>` : ""}${test3.task ? `<div class="task"><span class="label">Task</span><pre class="said">${esc2(test3.task)}</pre></div>` : ""}${checkGrid(test3)}${test3.attempts.map((a) => attemptBlock(test3, a
|
|
253064
|
+
return `<details class="scenario" id="${test3.anchor}" open><summary>${pill(cls, `${num4(test3.passed)}/${num4(test3.requested)}`)}<span class="s-title">${q(test3.title)}</span><span class="s-checks">${num4(t.passed)}/${num4(t.evaluated)} ${s2(t.evaluated, "check", "checks")}</span></summary><div class="s-body">${test3.variant ? `<p data-q>${esc2(test3.variant.change)}</p>` : ""}${test3.title !== test3.id ? `<p class="muted">${code2(test3.id)}</p>` : ""}${test3.task ? `<div class="task"><span class="label">Task</span><pre class="said">${esc2(test3.task)}</pre></div>` : ""}${checkGrid(test3)}${test3.attempts.map((a) => attemptBlock(test3, a)).join("")}</div></details>`;
|
|
253131
253065
|
}).join("");
|
|
253132
|
-
return `<section id="evidence" aria-labelledby="evidence-h"><h2 id="evidence-h">
|
|
253066
|
+
return `<section id="evidence" aria-labelledby="evidence-h"><h2 id="evidence-h">Attempts</h2>${tests}</section>`;
|
|
253133
253067
|
}
|
|
253134
253068
|
function familySection(d) {
|
|
253135
253069
|
if (!d.families?.length) return "";
|
|
253136
|
-
return `<section id="families" aria-labelledby="families-h"><h2 id="families-h">Variant families</h2>${d.families.map((family2) => `<
|
|
253070
|
+
return `<section id="families" aria-labelledby="families-h"><h2 id="families-h">Variant families</h2>${d.families.map((family2) => `<h3 class="family-title" data-q>${esc2(variantFamilyLine(family2))}</h3><div class="scroll"><table class="fams"><thead><tr><th scope="col">Variant</th><th scope="col" class="num">Passed</th></tr></thead><tbody>${family2.rows.map((row2) => {
|
|
253137
253071
|
const test3 = d.tests.find((test4) => test4.id === row2.sceneId);
|
|
253138
253072
|
return `<tr><td>${test3 ? `<a href="#${test3.anchor}">${q(row2.change)}</a>` : q(row2.change)}</td><td class="num" data-q>${esc2(variantRowCount(row2))}</td></tr>`;
|
|
253139
253073
|
}).join("")}</tbody></table></div>`).join("")}</section>`;
|
|
253140
253074
|
}
|
|
253075
|
+
var SCRIPT = `(() => {
|
|
253076
|
+
const tabs = [...document.querySelectorAll('[role="tab"]')], panels = [...document.querySelectorAll('[role="tabpanel"]')];
|
|
253077
|
+
const select = id => { tabs.forEach(t => { const on = t.getAttribute('aria-controls') === id; t.setAttribute('aria-selected', String(on)); t.tabIndex = on ? 0 : -1; }); panels.forEach(p => { p.hidden = p.id !== id; }); };
|
|
253078
|
+
const reveal = () => { const target = document.getElementById(location.hash.slice(1)); if (!target) return; const panel = target.closest('[role="tabpanel"]'); if (!panel) return; select(panel.id); for (let node = target; node; node = node.parentElement) if (node.tagName === 'DETAILS') node.open = true; if (target !== panel) { target.scrollIntoView(); (target.querySelector('summary') || target).focus(); } };
|
|
253079
|
+
tabs.forEach((tab, i) => { tab.addEventListener('click', e => { e.preventDefault(); select(tab.getAttribute('aria-controls')); }); tab.addEventListener('keydown', e => { const next = e.key === 'ArrowRight' ? (i + 1) % tabs.length : e.key === 'ArrowLeft' ? (i + tabs.length - 1) % tabs.length : e.key === 'Home' ? 0 : e.key === 'End' ? tabs.length - 1 : e.key === ' ' ? i : -1; if (next < 0) return; e.preventDefault(); tabs[next].click(); tabs[next].focus(); }); });
|
|
253080
|
+
document.addEventListener('click', e => { const a = e.target.closest('a[href^="#"]'); if (!a || a.getAttribute('role') === 'tab') return; if (location.hash === a.getAttribute('href')) reveal(); });
|
|
253081
|
+
window.addEventListener('hashchange', reveal); select('summary'); reveal();
|
|
253082
|
+
})();`;
|
|
253083
|
+
var SCRIPT_HASH = createHash66("sha256").update(SCRIPT).digest("base64");
|
|
253141
253084
|
function renderHtmlReport(input5) {
|
|
253142
253085
|
const d = "scenes" in input5 ? reportData(input5, noRecords(`.ancha/runs/${input5.runId}`)) : input5;
|
|
253086
|
+
const comparison3 = d.comparison ? `<section class="k-card"><h2>Compared with ${code2(d.comparison.baselineRunId)}</h2><div class="scroll"><table><thead><tr><th scope="col">Test</th><th scope="col">Change</th></tr></thead><tbody>${d.tests.filter((test3) => test3.change).map((test3) => `<tr><td><a href="#${test3.anchor}">${q(test3.title)}</a></td><td data-q>${esc2(formatRateDelta(test3.change.delta))}</td></tr>`).join("")}</tbody></table></div></section>` : "";
|
|
253143
253087
|
return `<!doctype html>
|
|
253144
|
-
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="color-scheme" content="light dark"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'"><title>Run report ${esc2(d.runId)}</title><style>${CSS}</style></head>
|
|
253088
|
+
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="color-scheme" content="light dark"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'sha256-${SCRIPT_HASH}'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'"><title>Run report ${esc2(d.runId)}</title><style>${CSS}</style></head>
|
|
253145
253089
|
<body><main class="page">
|
|
253146
|
-
<header class="top"><div class="brand"><span class="wordmark">ancha</span><span class="what">Run report</span></div
|
|
253147
|
-
|
|
253148
|
-
${
|
|
253149
|
-
|
|
253150
|
-
${familySection(d)}
|
|
253151
|
-
|
|
253152
|
-
${runFacts(d)}
|
|
253153
|
-
${failedChecks(d)}
|
|
253154
|
-
${evidence2(d)}
|
|
253155
|
-
<footer><span id="report-command">${code2(`ancha report ${d.runId} --html`)}</span><span>Records: <a href="./">${code2(`${d.folder}/`)}</a></span><span>Summary: <a href="summary.json">${code2("summary.json")}</a></span>${d.hostedUrl ? `<span>Ancha Cloud: <a href="${esc2(d.hostedUrl)}">${code2(d.hostedUrl)}</a></span>` : ""}</footer>
|
|
253156
|
-
</main></body></html>
|
|
253090
|
+
<header class="top"><div class="brand"><span class="wordmark">ancha</span><span class="what">Run report</span></div></header>
|
|
253091
|
+
<nav class="tabs" role="tablist" aria-label="Run report">${["Summary", "Attempts", "Details"].map((name5, i) => `<a id="tab-${name5.toLowerCase()}" role="tab" href="#${name5.toLowerCase()}" aria-controls="${name5.toLowerCase()}" aria-selected="${i === 0}" tabindex="${i === 0 ? 0 : -1}">${name5}</a>`).join("")}</nav>
|
|
253092
|
+
<section id="summary" class="panel" role="tabpanel" aria-labelledby="tab-summary" tabindex="0">${verdictBlock(d)}${sandboxes(d)}${results(d)}</section>
|
|
253093
|
+
<section id="attempts" class="panel" role="tabpanel" aria-labelledby="tab-attempts" tabindex="0">${evidence2(d)}</section>
|
|
253094
|
+
<section id="details" class="panel" role="tabpanel" aria-labelledby="tab-details" tabindex="0">${runFacts(d)}${["quickbooks", "netsuite"].map((toolkit) => d.routes?.[toolkit] ? `<p class="muted" data-q>${esc2(formatRouteSummary(d.routes[toolkit], toolkit))}</p>` : "").join("")}${comparison3}${familySection(d)}</section>
|
|
253095
|
+
</main><script>${SCRIPT}</script></body></html>
|
|
253157
253096
|
`;
|
|
253158
253097
|
}
|
|
253159
253098
|
var CSS = `
|
|
@@ -253165,15 +253104,16 @@ var CSS = `
|
|
|
253165
253104
|
body{margin:0;padding:8px;background:var(--bg);color:var(--text);font:14px/1.5 var(--sans)}
|
|
253166
253105
|
a{color:inherit;text-decoration:none}a:hover{text-decoration:underline}
|
|
253167
253106
|
a.n{text-decoration:underline;text-decoration-color:var(--rule-strong);text-underline-offset:2px}
|
|
253168
|
-
:focus-visible{outline:2px solid var(--text);outline-offset:3px}
|
|
253107
|
+
:focus-visible{outline:2px solid var(--text);outline-offset:3px}.panel:focus-visible{outline:1px solid var(--rule-strong);outline-offset:6px}
|
|
253169
253108
|
code,pre{font-family:var(--mono);font-size:12.5px}code{overflow-wrap:anywhere}
|
|
253109
|
+
.cgrid tbody th code,.check-fields tbody th code,.failed-lines code{overflow-wrap:normal;white-space:nowrap}
|
|
253170
253110
|
q{quotes:none}q::before,q::after{content:none}
|
|
253171
253111
|
.page{max-width:1280px;margin:0 auto;padding:24px 32px 48px;background:var(--panel);border:1px solid var(--rule);border-radius:12px;display:flex;flex-direction:column;gap:20px}
|
|
253172
253112
|
.page>*,.k-head>*,.k-title{min-width:0}
|
|
253173
253113
|
.top{display:flex;flex-wrap:wrap;align-items:baseline;gap:14px 18px}.brand{display:flex;align-items:baseline;gap:12px}
|
|
253174
253114
|
.wordmark{display:inline-flex;align-items:baseline;gap:2px;font:700 24px/1 var(--display);letter-spacing:-.04em}
|
|
253175
253115
|
.wordmark::after{content:"";width:6px;height:6px;background:var(--accent)}
|
|
253176
|
-
.what
|
|
253116
|
+
.what{color:var(--mid)}
|
|
253177
253117
|
.k-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:16px;width:100%}
|
|
253178
253118
|
.k-title{display:flex;flex-wrap:wrap;align-items:center;gap:10px}
|
|
253179
253119
|
h1{margin:0;font:600 28px/1.2 var(--display);letter-spacing:-.02em;overflow-wrap:anywhere}
|
|
@@ -253183,48 +253123,27 @@ h2{margin:0;font:600 15px/1.3 var(--sans)}
|
|
|
253183
253123
|
.k-btn:hover{border-color:var(--mid);text-decoration:none}.k-btn.primary{background:var(--text);border-color:var(--text);color:var(--panel)}
|
|
253184
253124
|
.k-badge{display:inline-flex;align-items:center;gap:5px;padding:3px 8px;border-radius:4px;font-size:12px;font-weight:600;line-height:1.35;white-space:nowrap}
|
|
253185
253125
|
.k-badge.pass{background:var(--pass-soft);color:var(--pass-text)}.k-badge.fail{background:var(--fail-soft);color:var(--fail-text)}.k-badge.none{background:var(--none-soft);color:var(--none-text)}
|
|
253186
|
-
.
|
|
253187
|
-
.
|
|
253188
|
-
.
|
|
253189
|
-
.
|
|
253190
|
-
.
|
|
253191
|
-
|
|
253192
|
-
.
|
|
253193
|
-
.
|
|
253194
|
-
.
|
|
253195
|
-
.
|
|
253196
|
-
.
|
|
253197
|
-
.k-sq.pass{background:var(--pass);color:var(--panel)}.k-sq.fail{background:var(--fail);color:var(--panel)}.k-sq.none{border:2px solid var(--none);color:var(--none-text);font-size:9px}
|
|
253198
|
-
.test-name{display:block;max-width:70ch;min-width:200px;overflow-wrap:anywhere}.test-name small{display:block;color:var(--mid);font-weight:400;margin-top:3px}
|
|
253126
|
+
.k-card,#families,#run,#evidence{border:1px solid var(--rule);border-radius:8px;min-width:0;overflow:hidden}
|
|
253127
|
+
.k-card>h2,#families>h2,#run>h2,#evidence>h2{padding:12px 16px}
|
|
253128
|
+
.tabs{display:flex;gap:24px;border-bottom:1px solid var(--rule)}.tabs a{padding:8px 0;color:var(--mid);border-bottom:2px solid transparent}.tabs [aria-selected="true"]{color:var(--text);border-color:var(--text);font-weight:600}
|
|
253129
|
+
.panel{display:grid;gap:20px;min-width:0}.panel[hidden]{display:none}
|
|
253130
|
+
.sandbox-row{padding:16px;border-top:1px solid var(--row);display:grid;grid-template-columns:minmax(160px,1fr) 3fr;gap:16px;align-items:start}
|
|
253131
|
+
.sandbox-test h3{margin:0;font-size:14px;font-weight:500;overflow-wrap:anywhere}.sandbox-boxes{display:flex;flex-wrap:wrap;gap:8px}
|
|
253132
|
+
.sandbox{display:flex;flex-direction:column;gap:6px;padding:12px;min-width:150px;border:1px solid var(--rule);border-radius:6px;font-size:12px}.sandbox .att{font-size:13px}
|
|
253133
|
+
.sandbox.passed{background:var(--pass-soft);color:var(--pass-text);border-color:var(--pass)}.sandbox.failed{background:var(--fail-soft);color:var(--fail-text);border-color:var(--fail)}
|
|
253134
|
+
.sandbox.invalid,.sandbox.ungraded{background:var(--none-soft);color:var(--none-text);border-color:var(--none)}.sandbox.cancelled{background:var(--raised);color:var(--mid);border-style:dashed}
|
|
253135
|
+
.failed-lines{list-style:none;padding:0;margin:0;display:grid;gap:6px}.failed-lines li{overflow-wrap:anywhere}.not-graded{list-style:none;margin:0;padding:12px 16px;border-top:1px solid var(--row);display:grid;gap:6px;color:var(--mid)}
|
|
253136
|
+
.family-title{font-size:14px;font-weight:500;padding:0 16px}
|
|
253199
253137
|
.scroll{overflow-x:auto;overscroll-behavior-x:contain}
|
|
253200
253138
|
table{width:100%;border-collapse:collapse;font-variant-numeric:tabular-nums}
|
|
253201
|
-
.
|
|
253139
|
+
.results{min-width:560px}.cgrid,.check-fields,.changes{min-width:560px}
|
|
253202
253140
|
th,td{text-align:left;vertical-align:top;padding:10px 16px;border-top:1px solid var(--row);overflow-wrap:anywhere}
|
|
253203
253141
|
thead th{background:var(--head);border-top:0;border-bottom:1px solid var(--rule);font-size:13px;font-weight:500;color:var(--mid);white-space:nowrap}
|
|
253204
|
-
tbody th{font-weight:500}
|
|
253205
|
-
tbody tr:first-child>td,tbody tr:first-child>th{border-top:0}
|
|
253142
|
+
tbody th{font-weight:500}
|
|
253143
|
+
tbody tr:first-child>td,tbody tr:first-child>th{border-top:0}
|
|
253206
253144
|
.num{text-align:right;white-space:nowrap}.c{text-align:center}.nar{display:none}.pass-t{color:var(--pass-text)}.fail-t{color:var(--fail-text)}
|
|
253207
|
-
.atts .grp th{padding:10px 16px;background:var(--head);font-size:13px;color:var(--mid);font-weight:600}.atts small{color:var(--mid)}
|
|
253208
|
-
.sub{color:var(--mid);margin:0;padding:0 16px 14px;font-size:13px}
|
|
253209
253145
|
.facts{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px 28px;margin:0;padding:4px 16px 16px}.facts div{min-width:0}
|
|
253210
253146
|
.facts dt{font-size:13px;color:var(--mid)}.facts dd{margin:3px 0 0;overflow-wrap:anywhere}.facts dd small{display:block;color:var(--mid);font-size:13px}.world{display:block}.world+.world{margin-top:6px}
|
|
253211
|
-
.timeline{border:1px solid var(--rule);border-radius:6px;background:var(--panel);padding:10px 12px 12px;margin-bottom:10px}
|
|
253212
|
-
.lanes{display:grid;gap:6px}
|
|
253213
|
-
.ln-row{display:grid;grid-template-columns:52px minmax(0,1fr);align-items:center;gap:8px}
|
|
253214
|
-
.ln-track{position:relative;height:26px}
|
|
253215
|
-
.ln-axis .ln-track{height:16px}
|
|
253216
|
-
.ln-tick{position:absolute;top:0;transform:translateX(-50%);font:11px/16px var(--mono);color:var(--mute);white-space:nowrap}
|
|
253217
|
-
.ln-tick.first{transform:none}
|
|
253218
|
-
.ln-slot{font-size:12px;color:var(--mid);white-space:nowrap}
|
|
253219
|
-
.ln-gl{position:absolute;top:-3px;bottom:-3px;width:1px;background:var(--rule)}
|
|
253220
|
-
.bar{position:absolute;top:0;bottom:0;display:flex;overflow:hidden;border-radius:3px;background:var(--raised);color:var(--text);text-decoration:none;box-shadow:inset 0 -2px 0 var(--mute)}
|
|
253221
|
-
.bar>i{flex:none;background:var(--rule-strong)}
|
|
253222
|
-
.bar>span{position:absolute;inset:0;padding:0 6px;font:500 11.5px/26px var(--mono);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
253223
|
-
.bar:hover>span{text-decoration:underline}
|
|
253224
|
-
.bar.ok{background:var(--pass-soft);box-shadow:inset 0 -2px 0 var(--pass)}.bar.no{background:var(--fail-soft);box-shadow:inset 0 -2px 0 var(--fail)}.bar.ung{color:var(--mid);box-shadow:inset 0 -2px 0 var(--rule-strong)}
|
|
253225
|
-
.legend{display:flex;flex-wrap:wrap;gap:6px 18px;margin:0 0 14px;font-size:13px;color:var(--mid)}
|
|
253226
|
-
.legend i{display:inline-block;width:14px;height:10px;border-radius:2px;margin-right:6px;vertical-align:-1px}
|
|
253227
|
-
.lg-setup{background:var(--rule-strong)}.lg-ok{background:var(--pass-soft);box-shadow:inset 0 -2px 0 var(--pass)}.lg-no{background:var(--fail-soft);box-shadow:inset 0 -2px 0 var(--fail)}.lg-inv{background:var(--raised);box-shadow:inset 0 -2px 0 var(--mute)}.lg-ung{background:var(--raised);box-shadow:inset 0 -2px 0 var(--rule-strong)}
|
|
253228
253147
|
details.scenario{border-top:1px solid var(--row)}
|
|
253229
253148
|
summary{cursor:pointer;list-style:none}summary::-webkit-details-marker{display:none}
|
|
253230
253149
|
details.scenario>summary{display:flex;flex-wrap:wrap;align-items:center;gap:8px 14px;padding:12px 16px}
|
|
@@ -253257,22 +253176,21 @@ pre.q{grid-column:4 / -1;margin:2px 0 4px;padding:8px 10px;background:var(--rais
|
|
|
253257
253176
|
li.more{display:block!important;color:var(--mid)}
|
|
253258
253177
|
pre.log{margin:0;padding:10px 12px;background:var(--raised);border-radius:6px;color:var(--mid);line-height:1.6;white-space:pre-wrap;overflow-wrap:anywhere}
|
|
253259
253178
|
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
|
|
253260
|
-
footer{color:var(--mid);font-size:13px;border-top:1px solid var(--rule);padding-top:14px;display:flex;flex-wrap:wrap;gap:6px 18px;overflow-wrap:anywhere}footer>span{min-width:0}
|
|
253261
253179
|
@media (max-width:720px){
|
|
253262
|
-
.page{padding:20px 16px 32px}.
|
|
253180
|
+
.page{padding:20px 16px 32px}.sandbox-row{grid-template-columns:1fr}.sandbox-boxes{display:grid;grid-template-columns:repeat(auto-fill,minmax(130px,1fr))}.sandbox{min-width:0}
|
|
253181
|
+
.results{min-width:0}.results thead{display:none}.results,.results tbody,.results tr,.results th,.results td{display:block}.results tr{padding:12px 16px;border-top:1px solid var(--row)}.results tbody tr:first-child{border-top:0}.results th,.results td{padding:0;border:0}.results td.num{text-align:left;color:var(--mid);font-size:13px}.results td+td{margin-top:4px}.facts{grid-template-columns:repeat(2,minmax(0,1fr))}.pair{grid-template-columns:minmax(0,1fr)}
|
|
253263
253182
|
.k-head{align-items:flex-start}.s-body{padding:0 10px 12px}.att-body{padding:4px 10px 12px}
|
|
253264
253183
|
ol.calls li{grid-template-columns:20px 52px 50px minmax(0,1fr)}ol.calls .r{grid-column:4}pre.q{grid-column:2 / -1}
|
|
253265
253184
|
}
|
|
253266
|
-
@media (max-width:440px){.page{padding:18px 12px 28px}.facts{grid-template-columns:minmax(0,1fr)}h1{font-size:26px}.
|
|
253185
|
+
@media (max-width:440px){.page{padding:18px 12px 28px}.facts{grid-template-columns:minmax(0,1fr)}h1{font-size:26px}.k-actions{width:100%}}
|
|
253267
253186
|
@media (prefers-reduced-motion:reduce){*{transition:none!important}}
|
|
253268
253187
|
@media print{
|
|
253269
253188
|
:root{--bg:#fff!important;--panel:#fff!important;--raised:#fff!important;--text:#111!important;--mid:#333!important;--mute:#555!important;--rule:#c8c8c8!important;--row:#ddd!important;--head:#fff!important;--rule-strong:#888!important;--accent:#9c4a2c!important;--pass:#24663e!important;--fail:#a52a22!important;--none:#775000!important;--pass-text:#24663e!important;--fail-text:#a52a22!important;--none-text:#775000!important;--pass-soft:#fff!important;--fail-soft:#fff!important;--none-soft:#fff!important;color-scheme:light}
|
|
253270
253189
|
*,*::before,*::after{background:none!important;box-shadow:none!important;filter:none!important}
|
|
253271
253190
|
body{padding:0;font-size:10.5pt}.page{max-width:none;padding:0;gap:22px;border:0}.k-actions{display:none}
|
|
253272
253191
|
details::details-content{content-visibility:visible}details:not([open])>:not(summary){display:block!important}
|
|
253273
|
-
.
|
|
253274
|
-
.
|
|
253275
|
-
a,a.n{text-decoration:none}tr,li,.bar,details.attempt>summary{break-inside:avoid}h2,h4{break-after:avoid}
|
|
253192
|
+
.panel[hidden]{display:grid}.tabs{display:none}.scroll{overflow:visible}table{min-width:0!important}.sandbox{border:1px solid currentColor}
|
|
253193
|
+
a,a.n{text-decoration:none}tr,li,details.attempt>summary{break-inside:avoid}h2,h4{break-after:avoid}
|
|
253276
253194
|
}
|
|
253277
253195
|
`;
|
|
253278
253196
|
|
|
@@ -253439,7 +253357,7 @@ import { readFile as readFile30, stat as stat11 } from "node:fs/promises";
|
|
|
253439
253357
|
import { resolve as resolve37 } from "node:path";
|
|
253440
253358
|
|
|
253441
253359
|
// backend/src/playgrounds/service.ts
|
|
253442
|
-
import { randomUUID as randomUUID13, createHash as
|
|
253360
|
+
import { randomUUID as randomUUID13, createHash as createHash70 } from "node:crypto";
|
|
253443
253361
|
|
|
253444
253362
|
// backend/src/playgrounds/groups.ts
|
|
253445
253363
|
init_zod();
|
|
@@ -253752,7 +253670,7 @@ init_src();
|
|
|
253752
253670
|
|
|
253753
253671
|
// backend/src/agents.ts
|
|
253754
253672
|
init_src();
|
|
253755
|
-
import { createHash as
|
|
253673
|
+
import { createHash as createHash67, randomUUID as randomUUID9 } from "node:crypto";
|
|
253756
253674
|
import { execFile as execFile6 } from "node:child_process";
|
|
253757
253675
|
import { promisify as promisify6 } from "node:util";
|
|
253758
253676
|
import { readFile as readFile18, readdir as readdir6, realpath as realpath9, rename as rename4, rm as rm5, stat as stat9, lstat as lstat7, writeFile as writeFile13 } from "node:fs/promises";
|
|
@@ -253865,8 +253783,8 @@ var ScenarioCatalog = class {
|
|
|
253865
253783
|
if (input5.routing === "pagerduty-only" && scene2.world_rules) {
|
|
253866
253784
|
const direct = scene2.world_rules.integrations?.filter((i) => i.from === "datadog" && i.to === "slack") ?? [];
|
|
253867
253785
|
scene2.world_rules.integrations = scene2.world_rules.integrations?.filter((i) => !(i.from === "datadog" && i.to === "slack"));
|
|
253868
|
-
for (const monitor3 of scene2.world_rules.monitors ?? []) for (const
|
|
253869
|
-
if ("handle" in
|
|
253786
|
+
for (const monitor3 of scene2.world_rules.monitors ?? []) for (const link8 of direct) {
|
|
253787
|
+
if ("handle" in link8 && link8.handle) monitor3.message = monitor3.message.split(/\s+/).filter((word2) => word2 !== "@" + link8.handle).join(" ");
|
|
253870
253788
|
}
|
|
253871
253789
|
}
|
|
253872
253790
|
const validated4 = parseScene(scene2);
|
|
@@ -253992,7 +253910,7 @@ async function providerStatus(workspace4, rawReference, inheritedEnv = process.e
|
|
|
253992
253910
|
}
|
|
253993
253911
|
|
|
253994
253912
|
// backend/src/agents.ts
|
|
253995
|
-
var hash7 = (value6) =>
|
|
253913
|
+
var hash7 = (value6) => createHash67("sha256").update(JSON.stringify(value6)).digest("hex");
|
|
253996
253914
|
var exec4 = promisify6(execFile6);
|
|
253997
253915
|
var agentId = (id15) => {
|
|
253998
253916
|
if (!/^agent_[a-f0-9-]{36}$/.test(id15)) throw new AnchaError("USAGE", "invalid agent id");
|
|
@@ -254038,7 +253956,7 @@ async function identifyCode(cwd) {
|
|
|
254038
253956
|
try {
|
|
254039
253957
|
const files2 = (await glob3(["**/*.{ts,tsx,js,jsx,mjs,cjs,py,go,rs,rb,sh,yaml,yml,json,toml,md,txt}"], { cwd, followSymbolicLinks: false, ignore: ["**/node_modules/**", "**/.git/**", "**/.ancha/**", "**/dist/**", "**/build/**", "**/__pycache__/**", "**/.venv/**"], dot: false })).sort();
|
|
254040
253958
|
if (!files2.length || files2.length > 3e3) throw new Error("source scope incomplete");
|
|
254041
|
-
const content2 =
|
|
253959
|
+
const content2 = createHash67("sha256");
|
|
254042
253960
|
let bytes4 = 0;
|
|
254043
253961
|
for (const file3 of files2) {
|
|
254044
253962
|
const path9 = join34(cwd, file3), info2 = await lstat7(path9);
|
|
@@ -254285,7 +254203,7 @@ function validateCatalog(kind2, value6) {
|
|
|
254285
254203
|
|
|
254286
254204
|
// backend/src/playgrounds/store.ts
|
|
254287
254205
|
init_src();
|
|
254288
|
-
import { createHash as
|
|
254206
|
+
import { createHash as createHash68, randomUUID as randomUUID11 } from "node:crypto";
|
|
254289
254207
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
254290
254208
|
import { chmod as chmod5, mkdir as mkdir16, readdir as readdir7, rename as rename5, rm as rm6, writeFile as writeFile14 } from "node:fs/promises";
|
|
254291
254209
|
import { dirname as dirname13, join as join35 } from "node:path";
|
|
@@ -254507,7 +254425,7 @@ var PlaygroundStore = class {
|
|
|
254507
254425
|
if (!legacy3) continue;
|
|
254508
254426
|
this.#db.transaction(() => {
|
|
254509
254427
|
const mapping = this.#db.prepare("SELECT worldId,sourceFingerprint FROM legacy_worlds WHERE agentId=?").get(agentId2);
|
|
254510
|
-
const signature3 =
|
|
254428
|
+
const signature3 = createHash68("sha256").update(JSON.stringify(legacy3)).digest("hex");
|
|
254511
254429
|
if (mapping?.sourceFingerprint === signature3) return;
|
|
254512
254430
|
const now11 = (/* @__PURE__ */ new Date()).toISOString();
|
|
254513
254431
|
const prior = mapping ? this.#db.prepare("SELECT body FROM catalog WHERE kind='world' AND id=? ORDER BY revision DESC LIMIT 1").get(mapping.worldId) : void 0;
|
|
@@ -254693,10 +254611,10 @@ function validateTaskChecks(configuration, tasks, people4) {
|
|
|
254693
254611
|
}
|
|
254694
254612
|
});
|
|
254695
254613
|
}
|
|
254696
|
-
function gradeAttempt(
|
|
254697
|
-
if (!Array.isArray(
|
|
254614
|
+
function gradeAttempt(results2) {
|
|
254615
|
+
if (!Array.isArray(results2) || !results2.length) return void 0;
|
|
254698
254616
|
const clip5 = (value6, max) => String(value6 ?? "").slice(0, max);
|
|
254699
|
-
const checks2 =
|
|
254617
|
+
const checks2 = results2.filter((r2) => r2 && typeof r2 === "object").slice(0, 50).map((r2) => ({
|
|
254700
254618
|
id: clip5(r2.id, 120),
|
|
254701
254619
|
passed: r2.passed === true,
|
|
254702
254620
|
expected: clip5(r2.expected, 600),
|
|
@@ -254705,7 +254623,7 @@ function gradeAttempt(results) {
|
|
|
254705
254623
|
...r2.error !== void 0 && { error: clip5(r2.error, 600) },
|
|
254706
254624
|
required: r2.required !== false
|
|
254707
254625
|
}));
|
|
254708
|
-
const skipped =
|
|
254626
|
+
const skipped = results2.some((r2) => r2 && r2.required !== false && r2.status === "skipped");
|
|
254709
254627
|
return { outcome: skipped ? "skipped" : checks2.every((c) => c.passed || !c.required) ? "passed" : "failed", checks: checks2.map(({ required: _required, ...c }) => c) };
|
|
254710
254628
|
}
|
|
254711
254629
|
var keyName = /(?:api.?key|token|secret|password|authorization|cookie|credential)/i;
|
|
@@ -254731,17 +254649,17 @@ function summarizeRun(run7) {
|
|
|
254731
254649
|
const requested2 = run7.tasks.reduce((sum6, task2) => sum6 + task2.attempts, 0);
|
|
254732
254650
|
const counts2 = countTrials(requested2, run7.attempts.map((attempt2) => !isTerminal(attempt2.status) ? "pending" : attempt2.outcome ?? (attempt2.status === "error" ? "invalid" : "skipped")));
|
|
254733
254651
|
const { passed, invalid: invalid42 } = counts2, failed2 = counts2.valid - passed;
|
|
254734
|
-
const
|
|
254652
|
+
const graded2 = run7.tasks.some((task2) => task2.checks?.length);
|
|
254735
254653
|
return {
|
|
254736
254654
|
verdictVersion: 2,
|
|
254737
254655
|
counts: counts2,
|
|
254738
|
-
graded,
|
|
254656
|
+
graded: graded2,
|
|
254739
254657
|
attempts: run7.attempts.length,
|
|
254740
254658
|
passed,
|
|
254741
254659
|
failed: failed2,
|
|
254742
254660
|
invalid: invalid42,
|
|
254743
|
-
pass_rate:
|
|
254744
|
-
pass_all_k:
|
|
254661
|
+
pass_rate: graded2 && requested2 > 0 ? passed / requested2 : null,
|
|
254662
|
+
pass_all_k: graded2 && allTrialsPassed(counts2)
|
|
254745
254663
|
};
|
|
254746
254664
|
}
|
|
254747
254665
|
var withSummary = (run7) => ({ ...run7, summary: summarizeRun(run7) });
|
|
@@ -254949,7 +254867,7 @@ var PlaygroundService = class {
|
|
|
254949
254867
|
const provenance = seedInput === void 0 ? void 0 : managedSeed(seedInput);
|
|
254950
254868
|
const origin = givenOrigin === void 0 ? this.consoleOrigin() : parseRunOrigin(givenOrigin);
|
|
254951
254869
|
if (idempotencyKey !== void 0 && (typeof idempotencyKey !== "string" || !/^[-A-Za-z0-9_]{8,100}$/.test(idempotencyKey))) throw new AnchaError("USAGE", "idempotencyKey must contain 8\u2013100 letters, digits, underscores or hyphens");
|
|
254952
|
-
const submission = { signature:
|
|
254870
|
+
const submission = { signature: createHash70("sha256").update(JSON.stringify({ ...data7, ...provenance && { managedSeed: provenance } })).digest("hex"), ...typeof idempotencyKey === "string" && { key: idempotencyKey } };
|
|
254953
254871
|
if (submission.key) {
|
|
254954
254872
|
const existing3 = await this.#admission.lookup(submission.key, submission.signature);
|
|
254955
254873
|
if (existing3) return this.get(existing3.runId);
|
|
@@ -254977,7 +254895,7 @@ var PlaygroundService = class {
|
|
|
254977
254895
|
async launchGroup(request2, previous, submission, origin) {
|
|
254978
254896
|
if (this.#closed) throw new AnchaError("SESSION_CONFLICT", "the playground service is shutting down");
|
|
254979
254897
|
const { idempotencyKey: requestKey, ...definition3 } = request2;
|
|
254980
|
-
const signature3 = submission?.signature ??
|
|
254898
|
+
const signature3 = submission?.signature ?? createHash70("sha256").update(JSON.stringify(definition3)).digest("hex");
|
|
254981
254899
|
const key5 = submission?.key ?? requestKey;
|
|
254982
254900
|
if (key5) {
|
|
254983
254901
|
const existing3 = await this.#admission.lookup(key5, signature3);
|
|
@@ -255056,7 +254974,7 @@ var PlaygroundService = class {
|
|
|
255056
254974
|
...provenance && { managedSeed: provenance }
|
|
255057
254975
|
};
|
|
255058
254976
|
if (this.#closed) throw new AnchaError("SESSION_CONFLICT", "the playground service is shutting down");
|
|
255059
|
-
return this.enqueue(run7, [{ saved: prepared.saved, resolvedAgent: prepared.resolvedAgent, configuration: run7.configuration, ...people4 && { people: people4 }, seed: run7.seed }], submission?.signature ??
|
|
254977
|
+
return this.enqueue(run7, [{ saved: prepared.saved, resolvedAgent: prepared.resolvedAgent, configuration: run7.configuration, ...people4 && { people: people4 }, seed: run7.seed }], submission?.signature ?? createHash70("sha256").update(JSON.stringify(request2)).digest("hex"), submission?.key);
|
|
255060
254978
|
}
|
|
255061
254979
|
async enqueue(run7, entries4, signature3, idempotencyKey) {
|
|
255062
254980
|
const budget2 = await this.#capacity();
|
|
@@ -255307,9 +255225,9 @@ var PlaygroundService = class {
|
|
|
255307
255225
|
delete attempt2.checks;
|
|
255308
255226
|
explanations = void 0;
|
|
255309
255227
|
} else {
|
|
255310
|
-
const
|
|
255311
|
-
if (
|
|
255312
|
-
Object.assign(attempt2,
|
|
255228
|
+
const graded2 = gradeAttempt(snapshot?.checks);
|
|
255229
|
+
if (graded2) {
|
|
255230
|
+
Object.assign(attempt2, graded2);
|
|
255313
255231
|
explanations = Array.isArray(snapshot?.explanations) ? snapshot.explanations : void 0;
|
|
255314
255232
|
}
|
|
255315
255233
|
}
|
|
@@ -255341,7 +255259,7 @@ var PlaygroundService = class {
|
|
|
255341
255259
|
}, 250);
|
|
255342
255260
|
poll.unref();
|
|
255343
255261
|
try {
|
|
255344
|
-
const
|
|
255262
|
+
const results2 = await this.#executor({
|
|
255345
255263
|
batchId: run7.id,
|
|
255346
255264
|
workspaceDir: this.workspace,
|
|
255347
255265
|
runDir: this.store.runDirectory(run7.id),
|
|
@@ -255360,7 +255278,7 @@ var PlaygroundService = class {
|
|
|
255360
255278
|
inheritedEnv: prepared.inheritedEnv,
|
|
255361
255279
|
onEvent: update5
|
|
255362
255280
|
});
|
|
255363
|
-
for (const result of
|
|
255281
|
+
for (const result of results2) await update5(result);
|
|
255364
255282
|
await writes3;
|
|
255365
255283
|
for (const attempt2 of run7.attempts) if (!isTerminal(attempt2.status)) await update5({ attemptId: attempt2.id, status: controller.signal.aborted ? "stopped" : "error", at: (/* @__PURE__ */ new Date()).toISOString(), ...controller.signal.aborted ? {} : { error: "Execution ended without a final result" } });
|
|
255366
255284
|
} catch (error65) {
|
|
@@ -255453,7 +255371,7 @@ var PlaygroundService = class {
|
|
|
255453
255371
|
async rerun(id15, rawIdempotencyKey) {
|
|
255454
255372
|
if (rawIdempotencyKey !== void 0 && (typeof rawIdempotencyKey !== "string" || !/^[-A-Za-z0-9_]{8,100}$/.test(rawIdempotencyKey))) throw new AnchaError("USAGE", "idempotencyKey must contain 8\u2013100 letters, digits, underscores or hyphens");
|
|
255455
255373
|
const previous = await this.get(id15);
|
|
255456
|
-
const submission = typeof rawIdempotencyKey === "string" ? { key: rawIdempotencyKey, signature:
|
|
255374
|
+
const submission = typeof rawIdempotencyKey === "string" ? { key: rawIdempotencyKey, signature: createHash70("sha256").update(JSON.stringify({ operation: "rerun", sourceRunId: id15 })).digest("hex") } : void 0;
|
|
255457
255375
|
if (submission) {
|
|
255458
255376
|
const existing3 = await this.#admission.lookup(submission.key, submission.signature);
|
|
255459
255377
|
if (existing3) return this.get(existing3.runId);
|
|
@@ -255482,7 +255400,7 @@ var PlaygroundService = class {
|
|
|
255482
255400
|
|
|
255483
255401
|
// packages/cli/src/commands/run.ts
|
|
255484
255402
|
init_routed_trial();
|
|
255485
|
-
import { createHash as
|
|
255403
|
+
import { createHash as createHash74 } from "node:crypto";
|
|
255486
255404
|
import { appendFileSync } from "node:fs";
|
|
255487
255405
|
import { access as access11, mkdir as mkdir22, readFile as readFile29, writeFile as writeFile21 } from "node:fs/promises";
|
|
255488
255406
|
import { dirname as dirname20, join as join47, relative as relative15, resolve as resolve36 } from "node:path";
|
|
@@ -255700,7 +255618,7 @@ import { mkdir as mkdir19, writeFile as writeFile18 } from "node:fs/promises";
|
|
|
255700
255618
|
import { join as join42, resolve as resolve32 } from "node:path";
|
|
255701
255619
|
|
|
255702
255620
|
// packages/cli/src/project-identity.ts
|
|
255703
|
-
import { createHash as
|
|
255621
|
+
import { createHash as createHash72 } from "node:crypto";
|
|
255704
255622
|
import { realpath as realpath11 } from "node:fs/promises";
|
|
255705
255623
|
import { hostname as hostname3 } from "node:os";
|
|
255706
255624
|
import { isAbsolute as isAbsolute11, relative as relative14, resolve as resolve29, sep as sep8 } from "node:path";
|
|
@@ -255738,7 +255656,7 @@ ${path9.split(sep8).join("/")}`;
|
|
|
255738
255656
|
}
|
|
255739
255657
|
} catch {
|
|
255740
255658
|
}
|
|
255741
|
-
return { projectKey:
|
|
255659
|
+
return { projectKey: createHash72("sha256").update(identity7).digest("hex").slice(0, 32), ...repository3 !== void 0 && { repository: repository3 } };
|
|
255742
255660
|
}
|
|
255743
255661
|
|
|
255744
255662
|
// packages/cli/src/cloud-bundle.ts
|
|
@@ -256548,7 +256466,7 @@ function registerRun(program2, ctx) {
|
|
|
256548
256466
|
const added = await completeProduction(resolve36(cwd, s3.path), s3.scene, input5.judge);
|
|
256549
256467
|
if (added.length) ctx.out.info(`computed production's result for ${added.join(", ")} from ${relative15(cwd, join47(dirname20(resolve36(cwd, s3.path)), "production.jsonl"))}`);
|
|
256550
256468
|
}
|
|
256551
|
-
const definition3 =
|
|
256469
|
+
const definition3 = createHash74("sha256").update(JSON.stringify({ scenes: scenes.map((scene2) => sceneFingerprint(scene2)).sort(), agent: agent.mode === "endpoint" ? agent.url : agent.command, trials, seed: opts.seed ?? null, minPassRate, strict: opts.strict ?? false, compare: opts.compare ?? null, detach: opts.detach ?? false, ...simulatedPolicy(opts, ctx.io.env), ...realTimeouts !== void 0 && { realTimeouts }, ...[...digests.values()].some((d) => d !== void 0) && { records: Object.fromEntries([...digests].filter(([, d]) => d !== void 0)) } })).digest("hex");
|
|
256552
256470
|
if (opts.idempotencyKey !== void 0) {
|
|
256553
256471
|
const previous = await claimIdempotencyKey(input5.outDir, opts.idempotencyKey, definition3);
|
|
256554
256472
|
if (previous !== void 0) return replayRun(ctx, input5, previous, opts.detach ?? false);
|
|
@@ -256650,7 +256568,7 @@ async function runAttempt(ctx, descriptor3, config12, sceneArgs) {
|
|
|
256650
256568
|
cloudAttempt: true
|
|
256651
256569
|
}, state3);
|
|
256652
256570
|
}
|
|
256653
|
-
var idempotencyFile = (outDir, key5) => join47(dirname20(outDir), "idempotency", `${
|
|
256571
|
+
var idempotencyFile = (outDir, key5) => join47(dirname20(outDir), "idempotency", `${createHash74("sha256").update(key5).digest("hex")}.json`);
|
|
256654
256572
|
async function claimIdempotencyKey(outDir, key5, definition3) {
|
|
256655
256573
|
if (!/^[\x21-\x7e]{1,200}$/.test(key5)) throw new AnchaError("USAGE", "--idempotency-key takes 1-200 visible ASCII characters", { hint: "e.g. --idempotency-key fix-csv-export-1" });
|
|
256656
256574
|
const path9 = idempotencyFile(outDir, key5);
|
|
@@ -257528,9 +257446,9 @@ function attemptResult(files2) {
|
|
|
257528
257446
|
return { valid: result.valid !== false, exitCode: result.exitCode ?? null, checks: Array.isArray(result.checks) ? result.checks : json40("checks.json") };
|
|
257529
257447
|
}
|
|
257530
257448
|
var checkState = (check4) => check4.status ?? (check4.passed ? "passed" : "failed");
|
|
257531
|
-
function repeatedFailure(
|
|
257449
|
+
function repeatedFailure(results2) {
|
|
257532
257450
|
const counts2 = /* @__PURE__ */ new Map();
|
|
257533
|
-
for (const item2 of
|
|
257451
|
+
for (const item2 of results2) {
|
|
257534
257452
|
for (const check4 of new Set(item2.checks.filter((c) => c.required !== false && checkState(c) === "failed").map((c) => `${c.id}\0${c.explanation}`))) {
|
|
257535
257453
|
const entry3 = counts2.get(check4) ?? { check: check4.split("\0")[0], attempts: 0 };
|
|
257536
257454
|
entry3.attempts += 1;
|
|
@@ -257594,9 +257512,9 @@ function failedCheckLines(evidence3, indent2 = " ") {
|
|
|
257594
257512
|
]);
|
|
257595
257513
|
}
|
|
257596
257514
|
function evidenceLines(evidence3) {
|
|
257597
|
-
const
|
|
257515
|
+
const graded2 = evidence3.checks.filter((check4) => checkState(check4) !== "skipped");
|
|
257598
257516
|
return [
|
|
257599
|
-
`checks: ${
|
|
257517
|
+
`checks: ${graded2.filter((check4) => checkState(check4) === "passed").length} of ${graded2.length} passed`,
|
|
257600
257518
|
...evidence3.checks.filter((check4) => checkState(check4) === "passed").map((check4) => ` pass ${check4.id}`),
|
|
257601
257519
|
...failedCheckLines(evidence3),
|
|
257602
257520
|
evidence3.answer === null ? "answer: none" : `answer (${evidence3.answer.source === "stdout" ? "printed on stdout" : evidence3.answer.source === "reply" ? "its reply" : "posted to ANCHA_DONE_URL"}):`,
|
|
@@ -258156,12 +258074,12 @@ next: ancha wait ${id15}`
|
|
|
258156
258074
|
if (filter4.trial !== void 0 && !scenes.some((s3) => s3.trialsDetail.some((t) => t.trial === filter4.trial))) throw new AnchaError("USAGE", `no trial ${filter4.trial} in run ${id15}`, { hint: `trials run: 1 to ${Math.max(0, ...scenes.map((s3) => s3.trials))}` });
|
|
258157
258075
|
const failures = explainFailures(summary, filter4), gradingWarnings = explainGradingWarnings(summary, filter4);
|
|
258158
258076
|
const reproduction = (view3.reproduction ?? []).filter((item2) => filter4.parent === void 0 ? filter4.scene === void 0 || item2.sceneId === filter4.scene : scenes.some((scene2) => scene2.sceneId === item2.sceneId));
|
|
258159
|
-
const
|
|
258077
|
+
const graded2 = summary.checkCounts?.evaluated !== 0;
|
|
258160
258078
|
const never2 = agentNeverRan(summary);
|
|
258161
258079
|
const readDirectory = projectTestDirectoryReader(ctx.io.cwd, { runId: id15, server: ws.server });
|
|
258162
258080
|
const retry = never2 === void 0 ? [] : cloudRetry(summary, readDirectory);
|
|
258163
258081
|
const setupNext = invalidSetupNext(summary, void 0, readDirectory);
|
|
258164
|
-
const next2 = setupNext ?? (never2 !== void 0 ? retry : summary.verdict === "pass" || summary.verdict === "ungraded" ? [] :
|
|
258082
|
+
const next2 = setupNext ?? (never2 !== void 0 ? retry : summary.verdict === "pass" || summary.verdict === "ungraded" ? [] : graded2 ? ["fix the agent", compareCommand(summary, id15, readDirectory)] : [`ancha logs ${id15}`]);
|
|
258165
258083
|
ctx.out.result(
|
|
258166
258084
|
{
|
|
258167
258085
|
runId: id15,
|
|
@@ -259288,7 +259206,7 @@ init_src();
|
|
|
259288
259206
|
// backend/src/kit/eval-import.ts
|
|
259289
259207
|
init_src();
|
|
259290
259208
|
var import_yaml13 = __toESM(require_dist(), 1);
|
|
259291
|
-
import { createHash as
|
|
259209
|
+
import { createHash as createHash75 } from "node:crypto";
|
|
259292
259210
|
import { posix as posix4 } from "node:path";
|
|
259293
259211
|
|
|
259294
259212
|
// backend/src/kit/eval-formats.ts
|
|
@@ -259866,7 +259784,7 @@ var readOnlyOf = (value6) => {
|
|
|
259866
259784
|
return ["true", "yes", "y", "1"].includes(text31) ? true : ["false", "no", "n", "0"].includes(text31) ? false : void 0;
|
|
259867
259785
|
};
|
|
259868
259786
|
var IMPORTED = /^# Imported by ancha test import\b.*\(test ([0-9a-f]{12})\)/;
|
|
259869
|
-
var bodyHash = (body8) =>
|
|
259787
|
+
var bodyHash = (body8) => createHash75("sha256").update(body8).digest("hex").slice(0, 12);
|
|
259870
259788
|
var bodyOf = (text31) => text31.replace(/^(?:#[^\n]*\n)*/, "");
|
|
259871
259789
|
function testYaml(test3, header4, from) {
|
|
259872
259790
|
const doc = new import_yaml13.Document(test3);
|
|
@@ -260129,7 +260047,7 @@ init_src2();
|
|
|
260129
260047
|
// packages/cli/src/commands/world-gen.ts
|
|
260130
260048
|
var import_yaml15 = __toESM(require_dist(), 1);
|
|
260131
260049
|
init_src();
|
|
260132
|
-
import { createHash as
|
|
260050
|
+
import { createHash as createHash76 } from "node:crypto";
|
|
260133
260051
|
import { existsSync as existsSync2 } from "node:fs";
|
|
260134
260052
|
import { mkdir as mkdir24, readFile as readFile40, writeFile as writeFile25 } from "node:fs/promises";
|
|
260135
260053
|
import { dirname as dirname23, join as join56, relative as relative20, resolve as resolve45 } from "node:path";
|
|
@@ -260199,7 +260117,7 @@ async function worldGen(ctx, description2, options5) {
|
|
|
260199
260117
|
if (options5.id !== void 0 && !/^[a-z0-9-]+$/.test(options5.id)) throw new AnchaError("USAGE", "--id must match [a-z0-9-]+", { hint: "e.g. --id acme-support" });
|
|
260200
260118
|
const outDir = resolve45(ctx.io.cwd, options5.out ?? "ancha/worlds");
|
|
260201
260119
|
const request2 = { description: description2, id: options5.id ?? null, tools: tools2 ?? null, size: size2, variants, from: options5.from ?? null };
|
|
260202
|
-
const keyFile = options5.idempotencyKey === void 0 ? void 0 : join56(ctx.io.cwd, ".ancha", "world-gen", `${
|
|
260120
|
+
const keyFile = options5.idempotencyKey === void 0 ? void 0 : join56(ctx.io.cwd, ".ancha", "world-gen", `${createHash76("sha256").update(options5.idempotencyKey).digest("hex").slice(0, 32)}.json`);
|
|
260203
260121
|
if (keyFile && existsSync2(keyFile)) {
|
|
260204
260122
|
const saved = JSON.parse(await readFile40(keyFile, "utf8"));
|
|
260205
260123
|
if (JSON.stringify(saved.request) !== JSON.stringify(request2)) throw new AnchaError("USAGE", "this --idempotency-key was used with different arguments", { hint: "use a new key for a new request" });
|
|
@@ -260263,7 +260181,7 @@ function report5(ctx, result) {
|
|
|
260263
260181
|
|
|
260264
260182
|
// packages/cli/src/commands/test-new.ts
|
|
260265
260183
|
var import_yaml17 = __toESM(require_dist(), 1);
|
|
260266
|
-
import { createHash as
|
|
260184
|
+
import { createHash as createHash78 } from "node:crypto";
|
|
260267
260185
|
import { existsSync as existsSync3 } from "node:fs";
|
|
260268
260186
|
import { mkdir as mkdir25, readFile as readFile41, readdir as readdir10, writeFile as writeFile26 } from "node:fs/promises";
|
|
260269
260187
|
import { join as join57, relative as relative21, resolve as resolve46 } from "node:path";
|
|
@@ -260274,7 +260192,7 @@ init_src();
|
|
|
260274
260192
|
init_src2();
|
|
260275
260193
|
var import_yaml16 = __toESM(require_dist(), 1);
|
|
260276
260194
|
init_backend();
|
|
260277
|
-
import { createHash as
|
|
260195
|
+
import { createHash as createHash77 } from "node:crypto";
|
|
260278
260196
|
var MAX_REFS = 80;
|
|
260279
260197
|
var ROUNDS_PER_TIER2 = 3;
|
|
260280
260198
|
async function runStep2(client2, step3, calls2, onProgress) {
|
|
@@ -260289,7 +260207,7 @@ async function runStep2(client2, step3, calls2, onProgress) {
|
|
|
260289
260207
|
round: round3,
|
|
260290
260208
|
tier,
|
|
260291
260209
|
model: reply6.model,
|
|
260292
|
-
promptSha256:
|
|
260210
|
+
promptSha256: createHash77("sha256").update(JSON.stringify([step3.system, user9])).digest("hex"),
|
|
260293
260211
|
inputTokens: reply6.inputTokens,
|
|
260294
260212
|
outputTokens: reply6.outputTokens,
|
|
260295
260213
|
costUsd: reply6.costUsd,
|
|
@@ -260708,7 +260626,7 @@ async function testNew(ctx, intent, options5) {
|
|
|
260708
260626
|
const world5 = await chooseWorld(ctx, options5.world);
|
|
260709
260627
|
const outDir = resolve46(ctx.io.cwd, options5.out ?? "ancha/tests");
|
|
260710
260628
|
const request2 = { intent, world: world5.id, id: options5.id ?? null, out: relative21(ctx.io.cwd, outDir) };
|
|
260711
|
-
const keyFile = options5.idempotencyKey === void 0 ? void 0 : join57(ctx.io.cwd, ".ancha", "test-new", `${
|
|
260629
|
+
const keyFile = options5.idempotencyKey === void 0 ? void 0 : join57(ctx.io.cwd, ".ancha", "test-new", `${createHash78("sha256").update(options5.idempotencyKey).digest("hex").slice(0, 32)}.json`);
|
|
260712
260630
|
if (keyFile && existsSync3(keyFile)) {
|
|
260713
260631
|
const saved = JSON.parse(await readFile41(keyFile, "utf8"));
|
|
260714
260632
|
if (JSON.stringify(saved.request) !== JSON.stringify(request2)) throw new AnchaError("USAGE", "this --idempotency-key was used with different arguments", { hint: "use a new key for a new request" });
|
|
@@ -261590,7 +261508,7 @@ init_assets();
|
|
|
261590
261508
|
// backend/src/execution/prepare-agent.ts
|
|
261591
261509
|
init_src();
|
|
261592
261510
|
import { execFile as execFile9 } from "node:child_process";
|
|
261593
|
-
import { createHash as
|
|
261511
|
+
import { createHash as createHash80, randomUUID as randomUUID18 } from "node:crypto";
|
|
261594
261512
|
import { mkdir as mkdir28, mkdtemp as mkdtemp10, readFile as readFile45, readdir as readdir12, rename as rename8, rm as rm15, writeFile as writeFile29 } from "node:fs/promises";
|
|
261595
261513
|
import { tmpdir as tmpdir9 } from "node:os";
|
|
261596
261514
|
import { join as join60 } from "node:path";
|
|
@@ -261601,12 +261519,12 @@ init_assets();
|
|
|
261601
261519
|
init_policy();
|
|
261602
261520
|
|
|
261603
261521
|
// backend/src/execution/runtime-cache.ts
|
|
261604
|
-
import { createHash as
|
|
261522
|
+
import { createHash as createHash79, randomUUID as randomUUID17 } from "node:crypto";
|
|
261605
261523
|
import { mkdir as mkdir27, readFile as readFile44, readdir as readdir11, realpath as realpath13, rename as rename7, rm as rm14, writeFile as writeFile28 } from "node:fs/promises";
|
|
261606
261524
|
import { join as join59 } from "node:path";
|
|
261607
261525
|
init_assets();
|
|
261608
261526
|
async function runtimeCacheKey(source, project14, command, context3) {
|
|
261609
|
-
const hash10 =
|
|
261527
|
+
const hash10 = createHash79("sha256").update(JSON.stringify(["verified-runtime-v1", await realpath13(project14), command, context3]));
|
|
261610
261528
|
async function visit4(path9, prefix2 = "") {
|
|
261611
261529
|
for (const entry3 of (await readdir11(path9, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
261612
261530
|
const relative31 = prefix2 + entry3.name;
|
|
@@ -261774,7 +261692,7 @@ async function prepareAgent(workspace4, agentId2, options5 = {}) {
|
|
|
261774
261692
|
}
|
|
261775
261693
|
}
|
|
261776
261694
|
const plan4 = await agentImagePlan(source, resolved.command);
|
|
261777
|
-
const digest5 =
|
|
261695
|
+
const digest5 = createHash80("sha256").update("ancha-image-v2").update(runtime2.context).update(plan4.dockerfile);
|
|
261778
261696
|
async function hashTree(path9, prefix2 = "") {
|
|
261779
261697
|
for (const entry3 of (await readdir12(path9, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
261780
261698
|
const relative31 = prefix2 + entry3.name;
|
|
@@ -262267,7 +262185,7 @@ init_report2();
|
|
|
262267
262185
|
init_baselines();
|
|
262268
262186
|
init_assets();
|
|
262269
262187
|
import { readdir as readdir13, stat as stat14, writeFile as writeFile31, rename as rename9, rm as rm18 } from "node:fs/promises";
|
|
262270
|
-
import { createHash as
|
|
262188
|
+
import { createHash as createHash82, randomBytes as randomBytes9 } from "node:crypto";
|
|
262271
262189
|
import { join as join63 } from "node:path";
|
|
262272
262190
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
262273
262191
|
|
|
@@ -262290,7 +262208,7 @@ init_scenes();
|
|
|
262290
262208
|
|
|
262291
262209
|
// backend/src/console/run-query.ts
|
|
262292
262210
|
init_src();
|
|
262293
|
-
import { createHash as
|
|
262211
|
+
import { createHash as createHash81 } from "node:crypto";
|
|
262294
262212
|
var statuses = ["preparing", "running", "passed", "failed", "ungraded", "error", "stopped", "connected", "completed", "unknown"];
|
|
262295
262213
|
function parseRunQuery(input5 = {}) {
|
|
262296
262214
|
if (Object.keys(input5).some((key5) => !["agent", "kind", "status", "scenario", "limit", "cursor"].includes(key5))) throw new AnchaError("USAGE", "unknown run filter");
|
|
@@ -262310,7 +262228,7 @@ function parseRunQuery(input5 = {}) {
|
|
|
262310
262228
|
if (!Number.isSafeInteger(limit2) || limit2 < 1 || limit2 > 100) throw new AnchaError("USAGE", "limit must be 1\u2013100");
|
|
262311
262229
|
return { ...agent && { agent }, ...kind2 && { kind: kind2 }, ...status6 && { status: status6 }, ...scenario && { scenario }, limit: limit2, ...cursor4 && { cursor: cursor4 } };
|
|
262312
262230
|
}
|
|
262313
|
-
var scope2 = (q2) =>
|
|
262231
|
+
var scope2 = (q2) => createHash81("sha256").update(JSON.stringify([q2.agent ?? "", q2.kind ?? "", q2.status ?? "", q2.scenario ?? ""])).digest("hex").slice(0, 20);
|
|
262314
262232
|
function runCursor(id15, query12) {
|
|
262315
262233
|
return Buffer.from(JSON.stringify({ v: 1, id: id15, scope: scope2(query12) })).toString("base64url");
|
|
262316
262234
|
}
|
|
@@ -262430,10 +262348,10 @@ var ConsoleJobs = class {
|
|
|
262430
262348
|
if (this.jobs.size) throw new AnchaError("USAGE", "finish or cancel the current console test before starting another");
|
|
262431
262349
|
const items2 = await Promise.all(input5.scenes.map((key5) => this.catalog.get(key5)));
|
|
262432
262350
|
if (expectedVersions) for (const item2 of items2) {
|
|
262433
|
-
const version6 = item2.data ?
|
|
262351
|
+
const version6 = item2.data ? createHash82("sha256").update(JSON.stringify(item2.data)).digest("hex") : item2.fingerprint;
|
|
262434
262352
|
if (version6 !== expectedVersions[item2.key]) throw new AnchaError("USAGE", "scenario or dataset definition changed; start a new run and save an updated test");
|
|
262435
262353
|
}
|
|
262436
|
-
const caseIds = items2.map((i) => i.caseId ?? (items2.filter((other) => other.scene.id === i.scene.id).length === 1 ? i.scene.id : `${i.scene.id}-${
|
|
262354
|
+
const caseIds = items2.map((i) => i.caseId ?? (items2.filter((other) => other.scene.id === i.scene.id).length === 1 ? i.scene.id : `${i.scene.id}-${createHash82("sha256").update(i.key).digest("hex").slice(0, 12)}`));
|
|
262437
262355
|
const profiles = await this.profiles(), profile2 = profiles.find((p2) => p2.id === input5.profile);
|
|
262438
262356
|
if (!profile2) throw new AnchaError("USAGE", "choose an available agent profile");
|
|
262439
262357
|
let agent, registered;
|
|
@@ -262468,7 +262386,7 @@ var ConsoleJobs = class {
|
|
|
262468
262386
|
const initial = await reserveRun(this.outDir, items2.length * input5.trials);
|
|
262469
262387
|
const writer = stateWriter(this.outDir, initial);
|
|
262470
262388
|
const preparedScenes = items2.map((i) => diagnostic ? { ...i.scene, timeout: `${Math.max(1, Math.floor(Math.min(parseDuration(i.scene.timeout), 15e3 * i.scene.time_scale)))}ms` } : i.scene);
|
|
262471
|
-
const metadata8 = publicData({ ...input5, versions: Object.fromEntries(items2.map((i) => [i.key, i.data ?
|
|
262389
|
+
const metadata8 = publicData({ ...input5, versions: Object.fromEntries(items2.map((i) => [i.key, i.data ? createHash82("sha256").update(JSON.stringify(i.data)).digest("hex") : i.fingerprint])), titles: items2.map((i) => i.scene.title ?? i.scene.id), label: profile2.name, cases: items2.map((i, index) => ({ id: caseIds[index], key: i.key, title: i.scene.title ?? i.scene.id, scene: structuredClone(preparedScenes[index]), fingerprint: sceneFingerprint(preparedScenes[index]), ...i.data && { data: i.data } })), ...diagnostic && { diagnostic: true }, ...registered && { agent: registered } }, this.secrets);
|
|
262472
262390
|
try {
|
|
262473
262391
|
const content2 = JSON.stringify(metadata8);
|
|
262474
262392
|
if (Buffer.byteLength(content2) > 2e7) throw new AnchaError("USAGE", "prepared scenario context exceeds 20 MB");
|
|
@@ -263117,13 +263035,13 @@ function runView(files2, target6) {
|
|
|
263117
263035
|
}
|
|
263118
263036
|
|
|
263119
263037
|
// backend/src/console/run-mirror.ts
|
|
263120
|
-
import { createHash as
|
|
263038
|
+
import { createHash as createHash83 } from "node:crypto";
|
|
263121
263039
|
import { gzipSync as gzipSync2 } from "node:zlib";
|
|
263122
263040
|
init_run_bundle();
|
|
263123
263041
|
init_privacy();
|
|
263124
263042
|
var MB2 = 1024 * 1024;
|
|
263125
263043
|
var LIMITS = { entries: 1200, runBytes: 4 * MB2, attemptBytes: 12 * MB2, unpackedBytes: 200 * MB2, compressedBytes: 50 * MB2 };
|
|
263126
|
-
var sha2566 = (data7) =>
|
|
263044
|
+
var sha2566 = (data7) => createHash83("sha256").update(data7).digest("hex");
|
|
263127
263045
|
async function packConsoleRun(playgrounds, runId2, options5) {
|
|
263128
263046
|
const batch3 = await playgrounds.get(runId2);
|
|
263129
263047
|
if (!isTerminal(batch3.status)) throw new Error(`run ${runId2} has not finished`);
|
|
@@ -263642,7 +263560,7 @@ async function startConsole(opts) {
|
|
|
263642
263560
|
await playgrounds.resumeQueued();
|
|
263643
263561
|
await jobs.key().catch(() => {
|
|
263644
263562
|
});
|
|
263645
|
-
const
|
|
263563
|
+
const sandboxes2 = new ConsoleSandboxes(backend, catalog3);
|
|
263646
263564
|
const csrf2 = randomBytes10(32).toString("hex");
|
|
263647
263565
|
let origin = "", closing = false;
|
|
263648
263566
|
let folderSelection;
|
|
@@ -263954,33 +263872,33 @@ async function startConsole(opts) {
|
|
|
263954
263872
|
if (parts3.length === 2) return send3(res, { tools: await backend.twins(), presets: SANDBOX_PRESETS });
|
|
263955
263873
|
}
|
|
263956
263874
|
if (parts3[1] === "sandboxes") {
|
|
263957
|
-
if (parts3.length === 2 && method2 === "GET") return send3(res, await
|
|
263875
|
+
if (parts3.length === 2 && method2 === "GET") return send3(res, await sandboxes2.list());
|
|
263958
263876
|
if (parts3.length === 2 && method2 === "POST") {
|
|
263959
263877
|
shape5(data7, ["key", "name", "seed", "tools", "data", "configuration", "preset"]);
|
|
263960
|
-
return send3(res, await
|
|
263878
|
+
return send3(res, await sandboxes2.create(data7));
|
|
263961
263879
|
}
|
|
263962
263880
|
const id15 = parts3[2];
|
|
263963
|
-
if (method2 === "GET" && parts3.length === 3) return send3(res, await
|
|
263964
|
-
if (method2 === "GET" && parts3.length === 4 && parts3[3] === "connections") return send3(res, await
|
|
263881
|
+
if (method2 === "GET" && parts3.length === 3) return send3(res, await sandboxes2.detail(id15));
|
|
263882
|
+
if (method2 === "GET" && parts3.length === 4 && parts3[3] === "connections") return send3(res, await sandboxes2.connections(id15));
|
|
263965
263883
|
if (method2 === "POST" && parts3.length === 4 && parts3[3] === "fork") {
|
|
263966
263884
|
shape5(data7, ["name"]);
|
|
263967
|
-
return send3(res, await
|
|
263885
|
+
return send3(res, await sandboxes2.fork(id15, data7.name));
|
|
263968
263886
|
}
|
|
263969
263887
|
if (method2 === "POST") {
|
|
263970
263888
|
if (parts3[3] === "delete") {
|
|
263971
263889
|
shape5(data7, []);
|
|
263972
|
-
return send3(res, await
|
|
263890
|
+
return send3(res, await sandboxes2.delete(id15));
|
|
263973
263891
|
}
|
|
263974
263892
|
if (parts3[3] === "renew") {
|
|
263975
263893
|
shape5(data7, []);
|
|
263976
|
-
return send3(res, await
|
|
263894
|
+
return send3(res, await sandboxes2.renew(id15));
|
|
263977
263895
|
}
|
|
263978
263896
|
if (parts3[3] === "configure") {
|
|
263979
263897
|
shape5(data7, ["revision", "tools", "key"]);
|
|
263980
|
-
return send3(res, await
|
|
263898
|
+
return send3(res, await sandboxes2.configure(id15, data7.revision, data7));
|
|
263981
263899
|
}
|
|
263982
263900
|
shape5(data7, parts3[3] === "advance" ? ["revision", "untilMs"] : parts3[3] === "action" ? ["revision", "action"] : ["revision"]);
|
|
263983
|
-
return send3(res, await
|
|
263901
|
+
return send3(res, await sandboxes2.mutate(id15, parts3[3], data7.revision, data7));
|
|
263984
263902
|
}
|
|
263985
263903
|
}
|
|
263986
263904
|
if (parts3[1] === "runs") {
|
|
@@ -264074,7 +263992,7 @@ async function startConsole(opts) {
|
|
|
264074
263992
|
await connections4.close();
|
|
264075
263993
|
await playgrounds.close();
|
|
264076
263994
|
await jobs.close();
|
|
264077
|
-
await
|
|
263995
|
+
await sandboxes2.close();
|
|
264078
263996
|
await new Promise((resolve63, reject4) => server.close((e) => e ? reject4(e) : resolve63()));
|
|
264079
263997
|
if (!opts.backend) await backend.close();
|
|
264080
263998
|
} };
|
|
@@ -264182,10 +264100,10 @@ function registerConnection(program2, ctx) {
|
|
|
264182
264100
|
|
|
264183
264101
|
// packages/cli/src/commands/test-pull.ts
|
|
264184
264102
|
init_src();
|
|
264185
|
-
import { createHash as
|
|
264103
|
+
import { createHash as createHash84, randomUUID as randomUUID22 } from "node:crypto";
|
|
264186
264104
|
import { lstat as lstat11, mkdir as mkdir30, readFile as readFile47, realpath as realpath15, rename as rename10, rm as rm20, writeFile as writeFile32 } from "node:fs/promises";
|
|
264187
264105
|
import { dirname as dirname24, join as join66 } from "node:path";
|
|
264188
|
-
var hash8 = (text31) =>
|
|
264106
|
+
var hash8 = (text31) => createHash84("sha256").update(text31).digest("hex");
|
|
264189
264107
|
var safePath4 = (path9) => typeof path9 === "string" && path9.length > 0 && path9.length <= 1024 && !path9.startsWith("/") && !/[\\\x00-\x1f\x7f:]/.test(path9) && path9.split("/").every((p2) => p2 && !p2.startsWith("."));
|
|
264190
264108
|
async function writePulledTest(cwd, input5, force = false) {
|
|
264191
264109
|
if (!safePath4(input5.path) || typeof input5.yaml !== "string" || !input5.yaml.trim() || Buffer.byteLength(input5.yaml) > 65536 || !/^[a-f0-9]{64}$/.test(input5.baseSha256) || input5.previousSha256 !== void 0 && !/^[a-f0-9]{64}$/.test(input5.previousSha256))
|
|
@@ -264239,11 +264157,11 @@ init_src();
|
|
|
264239
264157
|
var import_yaml19 = __toESM(require_dist(), 1);
|
|
264240
264158
|
init_src();
|
|
264241
264159
|
init_scenes();
|
|
264242
|
-
import { createHash as
|
|
264160
|
+
import { createHash as createHash85 } from "node:crypto";
|
|
264243
264161
|
import { constants as constants13 } from "node:fs";
|
|
264244
|
-
import { link as
|
|
264162
|
+
import { link as link7, lstat as lstat12, mkdir as mkdir31, mkdtemp as mkdtemp12, open as open13, readFile as readFile48, readdir as readdir16, rename as rename11, rm as rm21, rmdir, unlink as unlink2, writeFile as writeFile33 } from "node:fs/promises";
|
|
264245
264163
|
import { dirname as dirname25, join as join67, relative as relative22, resolve as resolve48 } from "node:path";
|
|
264246
|
-
var sha2567 = (bytes4) =>
|
|
264164
|
+
var sha2567 = (bytes4) => createHash85("sha256").update(bytes4).digest("hex");
|
|
264247
264165
|
var KEY_ORDER = ["version", "id", "title", "variant", "start", "attempts", "deadline", "timeout", "until", "checks", "pass", "world"];
|
|
264248
264166
|
var ordered4 = (test3) => Object.fromEntries([...KEY_ORDER.filter((key5) => key5 in test3), ...Object.keys(test3).filter((key5) => !KEY_ORDER.includes(key5)).sort()].map((key5) => [key5, test3[key5]]));
|
|
264249
264167
|
var same3 = (a, b) => a === void 0 || b === void 0 ? a === b : sceneFingerprint(a) === sceneFingerprint(b);
|
|
@@ -264313,7 +264231,7 @@ async function createExclusive(path9, bytes4) {
|
|
|
264313
264231
|
const file3 = join67(temp, "test");
|
|
264314
264232
|
await writeFile33(file3, bytes4, { flag: "wx", mode: 384 });
|
|
264315
264233
|
try {
|
|
264316
|
-
await
|
|
264234
|
+
await link7(file3, path9);
|
|
264317
264235
|
return "written";
|
|
264318
264236
|
} catch (error65) {
|
|
264319
264237
|
if (error65.code !== "EEXIST") throw error65;
|
|
@@ -264333,7 +264251,7 @@ async function atomicRecord(path9, bytes4, exclusive = false) {
|
|
|
264333
264251
|
if (!exclusive) await rename11(file3, path9);
|
|
264334
264252
|
else {
|
|
264335
264253
|
try {
|
|
264336
|
-
await
|
|
264254
|
+
await link7(file3, path9);
|
|
264337
264255
|
} catch (error65) {
|
|
264338
264256
|
if (error65.code !== "EEXIST") throw error65;
|
|
264339
264257
|
await checkBytes(path9, bytes4);
|
|
@@ -264513,7 +264431,7 @@ init_trace_import();
|
|
|
264513
264431
|
|
|
264514
264432
|
// packages/cli/src/commands/traces.ts
|
|
264515
264433
|
init_trace_import();
|
|
264516
|
-
import { createHash as
|
|
264434
|
+
import { createHash as createHash86 } from "node:crypto";
|
|
264517
264435
|
import { access as access13, readFile as readFile51, mkdir as mkdir32, stat as stat17, writeFile as writeFile34 } from "node:fs/promises";
|
|
264518
264436
|
import { basename as basename15, dirname as dirname26, join as join69, relative as relative25, resolve as resolve50 } from "node:path";
|
|
264519
264437
|
import { isDeepStrictEqual as isDeepStrictEqual7 } from "node:util";
|
|
@@ -265229,7 +265147,7 @@ function answerPatch(questions, given2) {
|
|
|
265229
265147
|
return answers;
|
|
265230
265148
|
}
|
|
265231
265149
|
var MARK = /^# ancha pull: \S+ ([0-9a-f]{16})$/m;
|
|
265232
|
-
var digest4 = (scene2) =>
|
|
265150
|
+
var digest4 = (scene2) => createHash86("sha256").update(JSON.stringify(scene2)).digest("hex").slice(0, 16);
|
|
265233
265151
|
var checksOf2 = (scene2) => Array.isArray(scene2?.checks) ? scene2.checks : [];
|
|
265234
265152
|
var importedChecks = (scene2, production3) => checksOf2(scene2).map((c) => ({
|
|
265235
265153
|
id: c.id,
|
|
@@ -265463,7 +265381,7 @@ async function sendTraces(ctx, api4, units, name5, options5, maxBytes) {
|
|
|
265463
265381
|
}
|
|
265464
265382
|
if (sent2.length > 1) ctx.out.info(`making ${plural6(sent2.length, "test")}, ${AT_ONCE} at a time`);
|
|
265465
265383
|
const answered = options5.expect !== void 0 || options5.answer.length > 0 || Boolean(options5.resetAnswers);
|
|
265466
|
-
const
|
|
265384
|
+
const results2 = await atOnce(sent2, AT_ONCE, async ({ id: id15, file: file3 }) => {
|
|
265467
265385
|
const skip = (error65) => ({ skip: classifiedSkip({ trace: id15, ...file3 && { file: file3 }, reason: error65.message }, error65), error: error65 });
|
|
265468
265386
|
let changes;
|
|
265469
265387
|
try {
|
|
@@ -265486,13 +265404,13 @@ async function sendTraces(ctx, api4, units, name5, options5, maxBytes) {
|
|
|
265486
265404
|
return skip(error65);
|
|
265487
265405
|
}
|
|
265488
265406
|
});
|
|
265489
|
-
for (const r2 of
|
|
265407
|
+
for (const r2 of results2) if (r2.skip) {
|
|
265490
265408
|
skipped.push(r2.skip);
|
|
265491
265409
|
first2 ??= r2.error;
|
|
265492
265410
|
}
|
|
265493
|
-
return { alreadyImported, made:
|
|
265411
|
+
return { alreadyImported, made: results2.flatMap((r2) => r2.made ? [r2.made] : []), skipped, uploads, sent: sent2.length, files: options5.files, first: first2 };
|
|
265494
265412
|
}
|
|
265495
|
-
function
|
|
265413
|
+
function outcomeOf4(world5) {
|
|
265496
265414
|
const production3 = world5.summary?.production ?? {}, values3 = checksOf2(world5.scene).map((c) => production3[c.id] ?? "unknown");
|
|
265497
265415
|
if (values3.includes("failed")) return "failed";
|
|
265498
265416
|
return production3.resolves_the_request === "passed" || values3.length > 0 && values3.every((v) => v === "passed") ? "passed" : "unknown";
|
|
@@ -265521,7 +265439,7 @@ async function uploadReport(ctx, done, from, dest) {
|
|
|
265521
265439
|
trace: m.trace,
|
|
265522
265440
|
...m.file && { file: m.file },
|
|
265523
265441
|
scene: where3(m.written.scene),
|
|
265524
|
-
production:
|
|
265442
|
+
production: outcomeOf4(m.world),
|
|
265525
265443
|
...m.world.summary?.evidence ? { evidence: m.world.summary.evidence, candidates: m.world.summary.candidates, required_checks: m.world.scene.pass } : {},
|
|
265526
265444
|
checks: importedChecks(m.world.scene, m.world.summary?.production ?? {}),
|
|
265527
265445
|
questions: openQuestions(m.world).map((q2) => q2.id),
|
|
@@ -265535,7 +265453,7 @@ async function uploadReport(ctx, done, from, dest) {
|
|
|
265535
265453
|
next: next2
|
|
265536
265454
|
};
|
|
265537
265455
|
ctx.out.result(result, () => {
|
|
265538
|
-
const count14 = (o) => tests.filter((m) =>
|
|
265456
|
+
const count14 = (o) => tests.filter((m) => outcomeOf4(m.world) === o).length;
|
|
265539
265457
|
const kinds2 = [["passed", "that went fine"], ["failed", "that failed"], ["unknown", "whose outcome the trace does not show"]].map(([o, what]) => [count14(o), what]).filter(([n2]) => n2 > 0);
|
|
265540
265458
|
const made = !tests.length ? "no tests" : `${plural6(tests.length, "test")} (${tests.length === 1 ? `from a run ${kinds2[0][1]}` : kinds2.map(([n2, what]) => `${n2} from ${n2 === 1 ? "a run" : "runs"} ${what}`).join(", ")})`;
|
|
265541
265459
|
const files2 = done.files > 1;
|
|
@@ -265544,7 +265462,7 @@ async function uploadReport(ctx, done, from, dest) {
|
|
|
265544
265462
|
return [
|
|
265545
265463
|
m.world.name,
|
|
265546
265464
|
...files2 ? [m.file ?? ""] : [],
|
|
265547
|
-
`in production: ${
|
|
265465
|
+
`in production: ${outcomeOf4(m.world)}`,
|
|
265548
265466
|
plural6(checksOf2(m.world.scene).length, "check"),
|
|
265549
265467
|
open17 ? plural6(open17, "open question") : "",
|
|
265550
265468
|
m.written.kept.length ? `kept your checks: ${m.written.kept.join(", ")}` : ""
|
|
@@ -265605,11 +265523,11 @@ var plural6 = (n2, one7, many = `${one7}s`) => `${n2} ${n2 === 1 ? one7 : many}`
|
|
|
265605
265523
|
function production2(trace2) {
|
|
265606
265524
|
if (trace2.status === "receiving" && !trace2.intake) return "still arriving";
|
|
265607
265525
|
if (trace2.status === "failed") return `could not be read: ${trace2.error ?? "unknown error"}`;
|
|
265608
|
-
const
|
|
265609
|
-
if (!
|
|
265610
|
-
const failed2 =
|
|
265611
|
-
const unknown5 =
|
|
265612
|
-
return failed2 ? `production failed ${plural6(failed2, "check")}` : unknown5 ? `production: ${
|
|
265526
|
+
const results2 = Object.values(trace2.intake?.production ?? {});
|
|
265527
|
+
if (!results2.length) return "no checks";
|
|
265528
|
+
const failed2 = results2.filter((r2) => r2 === "failed").length;
|
|
265529
|
+
const unknown5 = results2.filter((r2) => r2 === "unknown").length;
|
|
265530
|
+
return failed2 ? `production failed ${plural6(failed2, "check")}` : unknown5 ? `production: ${results2.length - unknown5} passed, ${unknown5} unknown` : `production passed ${plural6(results2.length, "check")}`;
|
|
265613
265531
|
}
|
|
265614
265532
|
function toolsOf2(trace2) {
|
|
265615
265533
|
const tools2 = trace2.intake?.tools ?? (trace2.services ?? []).map((service) => ({ service, rebuilt: true }));
|
|
@@ -265671,13 +265589,13 @@ function registerTraces(program2, ctx) {
|
|
|
265671
265589
|
else {
|
|
265672
265590
|
const scene2 = made.preview.scene, task2 = typeof scene2.task === "string" ? scene2.task : "";
|
|
265673
265591
|
const asks = (check4) => made.preview.provenance.find((p2) => p2.path === `checks.${check4}`)?.detail ?? "";
|
|
265674
|
-
const
|
|
265592
|
+
const results2 = made.preview.summary?.production ?? intake?.production ?? {};
|
|
265675
265593
|
const answered = Object.keys(test3?.answers ?? {}).length > 0;
|
|
265676
265594
|
lines2.push(answered ? `the test it makes with each default (saved version ${test3.version} uses your answers instead):` : "the test it makes:", ...task2 ? [` the agent is told: ${task2.length > 300 ? `${task2.slice(0, 300)}\u2026` : task2}`] : [], " the world:", ...made.world.map((w2) => ` ${w2}`));
|
|
265677
265595
|
const checks2 = checksOf2(scene2), width = Math.max(0, ...checks2.map((c) => c.id.length));
|
|
265678
|
-
lines2.push(checks2.length ? " checks:" : " checks: none", ...checks2.map((c) => ` ${c.id.padEnd(width)} ${
|
|
265596
|
+
lines2.push(checks2.length ? " checks:" : " checks: none", ...checks2.map((c) => ` ${c.id.padEnd(width)} ${results2[c.id] ? `${results2[c.id]} in production` : "no production result"}${asks(c.id) ? ` (${asks(c.id)})` : ""}`));
|
|
265679
265597
|
const given2 = typeof test3?.answers?.["checks.success"] === "string" ? test3.answers["checks.success"].trim() : "";
|
|
265680
|
-
if (checks2.some((c) => c.id === "resolves_the_request")) lines2.push(given2 ? ` success: ${given2.length > 200 ? `${given2.slice(0, 200)}\u2026` : given2} (your answer to checks.success)` : successLine(scene2,
|
|
265598
|
+
if (checks2.some((c) => c.id === "resolves_the_request")) lines2.push(given2 ? ` success: ${given2.length > 200 ? `${given2.slice(0, 200)}\u2026` : given2} (your answer to checks.success)` : successLine(scene2, results2));
|
|
265681
265599
|
}
|
|
265682
265600
|
lines2.push(...endStateDraftLines(endStateDraft));
|
|
265683
265601
|
if (questions.length) {
|
|
@@ -265940,7 +265858,7 @@ async function importLocally(ctx, source, options5) {
|
|
|
265940
265858
|
})) : void 0;
|
|
265941
265859
|
const picked = options5.conversation === void 0 ? all9 : all9.filter((c) => c.id === options5.conversation || c.traces.includes(options5.conversation));
|
|
265942
265860
|
if (!picked.length) throw new AnchaError("USAGE", `no conversation ${options5.conversation} in ${source.label}`, { hint: `its conversations: ${all9.slice(0, 10).map((c) => c.id).join(", ")}${all9.length > 10 ? `, and ${all9.length - 10} more` : ""}` });
|
|
265943
|
-
const base6 = `trace-${
|
|
265861
|
+
const base6 = `trace-${createHash86("sha256").update(text31).digest("hex").slice(0, 8)}`, ids3 = /* @__PURE__ */ new Set();
|
|
265944
265862
|
const idOf4 = (c) => {
|
|
265945
265863
|
if (all9.length === 1) return base6;
|
|
265946
265864
|
let id15 = `${base6}-${conversationSlug(c.id)}`;
|
|
@@ -283528,27 +283446,27 @@ function registerCheck(program2, ctx) {
|
|
|
283528
283446
|
});
|
|
283529
283447
|
if (inline2.length > 0 && (opts.test !== void 0 || opts.scene !== void 0)) throw new AnchaError("USAGE", "choose --check or --test");
|
|
283530
283448
|
const config12 = await ctx.loadConfig();
|
|
283531
|
-
const { results, scene: scene2, workspace: workspace4 } = await withWorld(ctx, opts.env, async (backend, workspace5, record33) => {
|
|
283449
|
+
const { results: results2, scene: scene2, workspace: workspace4 } = await withWorld(ctx, opts.env, async (backend, workspace5, record33) => {
|
|
283532
283450
|
if (inline2.length > 0) return { results: (await backend.evaluateChecks(opts.env, inline2)).map((result2) => ({ ...result2, required: true })), scene: void 0, workspace: workspace5 };
|
|
283533
283451
|
const path9 = opts.test ?? opts.scene;
|
|
283534
283452
|
const file3 = path9 ?? record33?.scene;
|
|
283535
283453
|
const scene3 = file3 !== void 0 ? (await loadSceneOrTest(ctx.io.cwd, file3)).scene : void 0;
|
|
283536
|
-
let
|
|
283454
|
+
let results3 = await backend.evaluateChecks(opts.env, scene3?.checks);
|
|
283537
283455
|
if (scene3 !== void 0) {
|
|
283538
283456
|
const required6 = new Set(scene3.pass);
|
|
283539
|
-
|
|
283457
|
+
results3 = results3.map((result2) => ({ ...result2, required: required6.has(result2.id) }));
|
|
283540
283458
|
if (scene3.checks.some((check4) => "judge" in check4)) {
|
|
283541
283459
|
const [trace2, state3] = await Promise.all([backend.getTrace(opts.env), backend.getState(opts.env)]);
|
|
283542
283460
|
const apiKey = ctx.io.env.OPENROUTER_API_KEY;
|
|
283543
|
-
|
|
283461
|
+
results3 = (await evaluateJudges(scene3, { checks: results3, trace: trace2, state: state3, simMs: 0, harnessIssues: [] }, { ...apiKey !== void 0 && { apiKey }, ...config12.judge?.model !== void 0 && { model: config12.judge.model } })).checks;
|
|
283544
283462
|
}
|
|
283545
283463
|
}
|
|
283546
|
-
return { results:
|
|
283464
|
+
return { results: results3, scene: scene3, workspace: workspace5 };
|
|
283547
283465
|
});
|
|
283548
|
-
if (
|
|
283549
|
-
const failures =
|
|
283550
|
-
const
|
|
283551
|
-
const verdict = failures.length > 0 ? "fail" :
|
|
283466
|
+
if (results2.length === 0) throw new AnchaError("USAGE", `world ${opts.env} has no checks to apply`, { hint: `ancha check --env ${opts.env} --test <test.yaml>` });
|
|
283467
|
+
const failures = results2.filter((result2) => result2.required && !result2.passed);
|
|
283468
|
+
const graded2 = results2.some((result2) => result2.status !== "skipped" && result2.error === void 0);
|
|
283469
|
+
const verdict = failures.length > 0 ? "fail" : graded2 ? "pass" : "ungraded";
|
|
283552
283470
|
const passed = verdict === "pass";
|
|
283553
283471
|
ctx.exitCode = passed ? 0 : 1;
|
|
283554
283472
|
const next2 = passed ? [`ancha world down --env ${opts.env}`] : [`ancha world trace --env ${opts.env}`, `ancha world down --env ${opts.env}`];
|
|
@@ -283557,13 +283475,13 @@ function registerCheck(program2, ctx) {
|
|
|
283557
283475
|
workspace: workspace4,
|
|
283558
283476
|
...scene2 !== void 0 && { sceneId: scene2.id },
|
|
283559
283477
|
verdict,
|
|
283560
|
-
checks:
|
|
283478
|
+
checks: results2,
|
|
283561
283479
|
failures: failures.map((failure6) => ({ check: failure6.id, expected: failure6.expected, actual: failure6.actual, explanation: failure6.explanation })),
|
|
283562
283480
|
next: next2
|
|
283563
283481
|
};
|
|
283564
283482
|
ctx.out.result(result, () => [
|
|
283565
|
-
...
|
|
283566
|
-
`verdict: ${result.verdict} (${
|
|
283483
|
+
...results2.map((check4) => `${check4.passed ? "pass" : check4.status === "skipped" ? "skip" : "fail"} ${check4.id}${check4.required ? "" : " (not required)"}${check4.passed ? "" : `: expected ${check4.expected}; got ${check4.actual}`}`),
|
|
283484
|
+
`verdict: ${result.verdict} (${results2.filter((check4) => check4.required && check4.passed).length} of ${results2.filter((check4) => check4.required).length} required checks pass)`,
|
|
283567
283485
|
...next2.map((command) => `next: ${command}`)
|
|
283568
283486
|
].join("\n"));
|
|
283569
283487
|
});
|
|
@@ -283744,7 +283662,7 @@ import { dirname as dirname28, join as join72, resolve as resolve56 } from "node
|
|
|
283744
283662
|
|
|
283745
283663
|
// backend/src/company/fetch.ts
|
|
283746
283664
|
init_src();
|
|
283747
|
-
import { createHash as
|
|
283665
|
+
import { createHash as createHash87 } from "node:crypto";
|
|
283748
283666
|
import { lookup as lookup6 } from "node:dns/promises";
|
|
283749
283667
|
import { request as httpsRequest } from "node:https";
|
|
283750
283668
|
import { BlockList, isIP as isIP4 } from "node:net";
|
|
@@ -283940,7 +283858,7 @@ async function fetchFrom(start2, deps, begun, canMove) {
|
|
|
283940
283858
|
const first2 = await get8(start2), pages = [];
|
|
283941
283859
|
const add = (page20) => {
|
|
283942
283860
|
const text31 = page20.html ? pageText(page20.body) : page20.body;
|
|
283943
|
-
if (!pages.some((p2) => p2.url === page20.url.href)) pages.push({ url: page20.url.href, text: text31, sha256:
|
|
283861
|
+
if (!pages.some((p2) => p2.url === page20.url.href)) pages.push({ url: page20.url.href, text: text31, sha256: createHash87("sha256").update(text31).digest("hex") });
|
|
283944
283862
|
};
|
|
283945
283863
|
add(first2);
|
|
283946
283864
|
for (const url4 of first2.html ? pickPages(first2.body, first2.url) : []) {
|
|
@@ -284626,7 +284544,7 @@ var COLUMNS2 = {
|
|
|
284626
284544
|
subtype: "@subtype"
|
|
284627
284545
|
};
|
|
284628
284546
|
var PAGE_KEYS = /* @__PURE__ */ new Set(["items", "links", "count", "hasMore", "offset", "totalResults"]);
|
|
284629
|
-
var selfHref = (record33) => Array.isArray(record33.links) ? record33.links.find((
|
|
284547
|
+
var selfHref = (record33) => Array.isArray(record33.links) ? record33.links.find((link8) => isObject7(link8) && typeof link8.href === "string" && /\/record\/v1\//.test(link8.href))?.href : void 0;
|
|
284630
284548
|
function realmOf(href2) {
|
|
284631
284549
|
const m = href2 === void 0 ? null : /^https?:\/\/(\d{4,10})(?:[-_]sb(\d{1,2}))?\.suitetalk\.api\.netsuite\.com/i.exec(href2);
|
|
284632
284550
|
return m ? `${m[1]}${m[2] ? `_SB${m[2]}` : ""}` : void 0;
|
|
@@ -284904,8 +284822,8 @@ function attach(raws, lines2, links4, notes7) {
|
|
|
284904
284822
|
} else (owner6.sublists.expense ??= []).push({ ...rest2, ...closed, account: expenseaccount ?? account9, amount: round23(amount6(f2) * sign4) });
|
|
284905
284823
|
}
|
|
284906
284824
|
}
|
|
284907
|
-
for (const
|
|
284908
|
-
const f2 =
|
|
284825
|
+
for (const link8 of links4) {
|
|
284826
|
+
const f2 = link8.fields, from = owners.get(idOf3(f2.nextdoc) ?? 0), doc = idOf3(f2.previousdoc), amount6 = netsuiteNumber(f2.foreignamount ?? f2.amount);
|
|
284909
284827
|
if (!from || doc === void 0) {
|
|
284910
284828
|
unlinked2++;
|
|
284911
284829
|
continue;
|
|
@@ -286118,7 +286036,7 @@ init_src();
|
|
|
286118
286036
|
init_privacy();
|
|
286119
286037
|
init_assets();
|
|
286120
286038
|
init_report2();
|
|
286121
|
-
import { createHash as
|
|
286039
|
+
import { createHash as createHash88, randomBytes as randomBytes12 } from "node:crypto";
|
|
286122
286040
|
import { lstat as lstat14, mkdir as mkdir38, mkdtemp as mkdtemp13, readFile as readFile59, rename as rename13, rm as rm24, writeFile as writeFile39 } from "node:fs/promises";
|
|
286123
286041
|
import { dirname as dirname29, join as join74, resolve as resolve59 } from "node:path";
|
|
286124
286042
|
var object27 = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
@@ -286151,7 +286069,7 @@ function pytestRecordJsonSchema() {
|
|
|
286151
286069
|
}
|
|
286152
286070
|
var excluded2 = (outcome4) => outcome4 === "skipped" || outcome4 === "xfailed";
|
|
286153
286071
|
var passing = (outcome4) => outcome4 === "passed" || outcome4 === "xpassed";
|
|
286154
|
-
var hash9 = (value6) =>
|
|
286072
|
+
var hash9 = (value6) => createHash88("sha256").update(value6).digest("hex");
|
|
286155
286073
|
var json39 = (value6) => JSON.stringify(value6, null, 2) + "\n";
|
|
286156
286074
|
var invalid41 = () => new AnchaError("USAGE", "invalid pytest run record", { hint: "use the matching pytest-ancha plugin; records require version 1 and valid outcomes, timestamps and attempt numbers" });
|
|
286157
286075
|
function redact3(value6, env2) {
|
|
@@ -286194,8 +286112,8 @@ function artifacts(record33, runDir) {
|
|
|
286194
286112
|
}
|
|
286195
286113
|
const phaseErrors = record33.phases.filter((phase) => phase.outcome === "failed" && phase.when !== "call");
|
|
286196
286114
|
if ((record33.outcome === "error" || phaseErrors.length) && !attempts.some((attempt2) => attempt2.outcome === "invalid")) attempts[attempts.length - 1].outcome = "invalid";
|
|
286197
|
-
const
|
|
286198
|
-
const passed =
|
|
286115
|
+
const graded2 = attempts.filter((attempt2) => !excluded2(attempt2.outcome) && attempt2.outcome !== "invalid");
|
|
286116
|
+
const passed = graded2.filter((attempt2) => passing(attempt2.outcome)).length;
|
|
286199
286117
|
const invalidCount = attempts.filter((attempt2) => attempt2.outcome === "invalid").length;
|
|
286200
286118
|
const counts2 = countTrials(record33.requestedTrials ?? attempts.length, attempts.map((attempt2) => attempt2.outcome === "invalid" ? "invalid" : excluded2(attempt2.outcome) ? "skipped" : passing(attempt2.outcome) ? "passed" : "failed"));
|
|
286201
286119
|
const scene2 = {
|
|
@@ -286205,7 +286123,7 @@ function artifacts(record33, runDir) {
|
|
|
286205
286123
|
passed,
|
|
286206
286124
|
passRate: counts2.requested ? passed / counts2.requested : 0,
|
|
286207
286125
|
passAllK: record33.requestedTrials !== void 0 && allTrialsPassed(counts2),
|
|
286208
|
-
checks: { pytest: { passed, total:
|
|
286126
|
+
checks: { pytest: { passed, total: graded2.length, required: true } },
|
|
286209
286127
|
skippedJudges: 0,
|
|
286210
286128
|
warnings: [],
|
|
286211
286129
|
agentIssues: [],
|
|
@@ -286266,7 +286184,7 @@ function artifacts(record33, runDir) {
|
|
|
286266
286184
|
source: "pytest",
|
|
286267
286185
|
target: "local",
|
|
286268
286186
|
...workspaces.length === 1 && { workspace: workspaces[0] },
|
|
286269
|
-
pytest: { nodeId: record33.nodeId, outcome: record33.outcome, graded:
|
|
286187
|
+
pytest: { nodeId: record33.nodeId, outcome: record33.outcome, graded: graded2.length > 0, excluded: attempts.filter((attempt2) => excluded2(attempt2.outcome)).length, invalid: invalidCount, phases: record33.phases }
|
|
286270
286188
|
};
|
|
286271
286189
|
files2.set("inputs.json", json39({ schemaVersion: 1, source: "pytest", nodeId: record33.nodeId, definitions: definitions3, workspaces, cases: sceneDefinition ? [{ id: sceneId, scene: sceneDefinition }] : [] }));
|
|
286272
286190
|
files2.set("summary.json", json39(summary));
|
|
@@ -286975,8 +286893,8 @@ async function testTask(ctx, file3, worldOverride) {
|
|
|
286975
286893
|
const timeoutMs = v22 && typeof doc.timeout === "string" ? parseDuration(doc.timeout) : void 0;
|
|
286976
286894
|
return { task: { id: id15, prompt, ...typeof doc.title === "string" && { title: doc.title }, ...typeof doc.attempts === "number" && { attempts: doc.attempts }, ...timeoutMs !== void 0 && { timeoutMs }, ...checks2.length > 0 && { checks: checks2 } }, world: typeof doc.world === "string" ? doc.world : void 0 };
|
|
286977
286895
|
}
|
|
286978
|
-
async function follow(ctx, first2, get8,
|
|
286979
|
-
ctx.out.event({ event: "run_started", runId: first2.id, attempts: first2.attempts.length, ...
|
|
286896
|
+
async function follow(ctx, first2, get8, link8, wait) {
|
|
286897
|
+
ctx.out.event({ event: "run_started", runId: first2.id, attempts: first2.attempts.length, ...link8 !== void 0 && { url: link8 } });
|
|
286980
286898
|
if (!wait) {
|
|
286981
286899
|
ctx.out.info(`the run goes on in the workspace: ancha runs show ${first2.id}`);
|
|
286982
286900
|
return;
|
|
@@ -286999,7 +286917,7 @@ async function follow(ctx, first2, get8, link9, wait) {
|
|
|
286999
286917
|
const incomplete2 = counts2 && counts2.completed < counts2.requested;
|
|
287000
286918
|
const failed2 = (run7.summary?.failed ?? 0) > 0 || (counts2?.skipped ?? 0) > 0 && run7.summary?.graded || incomplete2;
|
|
287001
286919
|
ctx.exitCode = run7.status === "error" || invalid42 ? 3 : run7.status === "stopped" ? 2 : failed2 ? 1 : 0;
|
|
287002
|
-
ctx.out.event({ event: "run_finished", runId: run7.id, status: run7.status, ...run7.summary !== void 0 && { summary: run7.summary }, ...
|
|
286920
|
+
ctx.out.event({ event: "run_finished", runId: run7.id, status: run7.status, ...run7.summary !== void 0 && { summary: run7.summary }, ...link8 !== void 0 && { url: link8 }, next: [`ancha explain ${run7.id}`] });
|
|
287003
286921
|
}
|
|
287004
286922
|
function registerRuns(program2, ctx) {
|
|
287005
286923
|
const runs = program2.command("runs").description("cloud and playground runs: their status, grade and queue position");
|
|
@@ -287042,8 +286960,8 @@ next page: ancha runs list --cursor ${page20.nextCursor}`}`);
|
|
|
287042
286960
|
const worldId = await withService(ctx, (service) => resolveWorld(() => service.worlds()));
|
|
287043
286961
|
const run7 = await api4.start(definition3(worldId));
|
|
287044
286962
|
const workspace4 = ctx.io.env.ANCHA_WORKSPACE_URL;
|
|
287045
|
-
const
|
|
287046
|
-
await follow(ctx, run7, () => api4.get(run7.id),
|
|
286963
|
+
const link8 = workspace4 ? `${new URL(workspace4).origin}/playgrounds/${run7.id}` : void 0;
|
|
286964
|
+
await follow(ctx, run7, () => api4.get(run7.id), link8, options5.wait);
|
|
287047
286965
|
return;
|
|
287048
286966
|
}
|
|
287049
286967
|
if (!options5.wait) throw new AnchaError("USAGE", "--no-wait needs a hosted workspace; here the run lives in this command", { hint: "leave out --no-wait" });
|
|
@@ -287115,9 +287033,9 @@ next page: ancha runs list --cursor ${page20.nextCursor}`}`);
|
|
|
287115
287033
|
}
|
|
287116
287034
|
id15 = detail3.job.id;
|
|
287117
287035
|
const done = shared.TERMINAL_JOB_STATES.includes(detail3.job.state);
|
|
287118
|
-
const
|
|
287036
|
+
const graded2 = detail3.summary !== null && detail3.summary.checkCounts?.evaluated !== 0;
|
|
287119
287037
|
const never2 = done ? cloudNeverRan(detail3) : void 0;
|
|
287120
|
-
const next2 = !done ? `next: ancha wait ${id15}` : detail3.job.kind !== "run" ? "next: ancha status" : never2 !== void 0 ? neverRanNextLine(never2, cloudRetry(detail3.summary)) : `next: ${
|
|
287038
|
+
const next2 = !done ? `next: ancha wait ${id15}` : detail3.job.kind !== "run" ? "next: ancha status" : never2 !== void 0 ? neverRanNextLine(never2, cloudRetry(detail3.summary)) : `next: ${graded2 ? `ancha explain ${id15}` : `ancha logs ${id15}`}`;
|
|
287121
287039
|
ctx.out.result(detail3, () => [done && detail3.job.kind === "run" ? finishedText(ws, detail3, false) : statusLine(detail3.job), ...attemptLines(detail3.attempts), next2].join("\n"));
|
|
287122
287040
|
return;
|
|
287123
287041
|
}
|