@anuma/sdk 6.39.0 → 6.39.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/expo/index.cjs +181 -59
- package/dist/expo/index.d.mts +8 -2
- package/dist/expo/index.d.ts +8 -2
- package/dist/expo/index.mjs +180 -59
- package/dist/index.cjs +50 -34
- package/dist/index.mjs +50 -34
- package/dist/react/index.cjs +181 -59
- package/dist/react/index.d.mts +8 -2
- package/dist/react/index.d.ts +8 -2
- package/dist/react/index.mjs +180 -59
- package/dist/server/index.cjs +50 -34
- package/dist/server/index.d.mts +5 -1
- package/dist/server/index.d.ts +5 -1
- package/dist/server/index.mjs +50 -34
- package/dist/tools/index.cjs +10 -8
- package/dist/tools/index.d.mts +10 -6
- package/dist/tools/index.d.ts +10 -6
- package/dist/tools/index.mjs +10 -8
- package/dist/tools/selection/index.cjs +50 -34
- package/dist/tools/selection/index.d.mts +5 -1
- package/dist/tools/selection/index.d.ts +5 -1
- package/dist/tools/selection/index.mjs +50 -34
- package/package.json +1 -1
|
@@ -1055,15 +1055,17 @@ Build ONLY when the user gives an explicit instruction to build, create, generat
|
|
|
1055
1055
|
|
|
1056
1056
|
Once the user HAS given an explicit build instruction, you are in App Builder mode: you produce polished, production-quality React apps that feel designed \u2014 not generic.
|
|
1057
1057
|
|
|
1058
|
-
DESIGN: on the initial build, before writing code, briefly state (2-3 sentences) what you want this app to feel like \u2014 name the specific fonts, the palette in hex, and one signature detail. Be concrete: "Fraunces display + Inter body + JetBrains Mono metadata, terracotta #b75432 accent on bone #f3efe6, paper-grain texture via inline SVG noise" is the kind of specificity that anchors the build. Default to nothing: don't pick "safe modern productivity" unless the brief literally asks for utilitarian. On later turns, state a design brief only when the change is visual (a restyle, new theme, or new UI); for a logic, data, or behavior-only change, skip the brief and just make the change.
|
|
1058
|
+
DESIGN: on the initial build, before writing code, briefly state (2-3 sentences) what you want this app to feel like \u2014 name the specific fonts, the palette in hex, and one signature detail. Be concrete: "Fraunces display + Inter body + JetBrains Mono metadata, terracotta #b75432 accent on bone #f3efe6, paper-grain texture via inline SVG noise" is the kind of specificity that anchors the build. Default to nothing: don't pick "safe modern productivity" unless the brief literally asks for utilitarian. On later turns, state a design brief only when the change is visual (a restyle, new theme, or new UI); for a text, logic, data, or behavior-only change, skip the brief and just make the change.
|
|
1059
|
+
|
|
1060
|
+
EDIT SCOPE: Change only the files and lines required by the current user request. A title rename is a text edit, not a design change. Preserve styles, dependencies, and unrelated logic on text edits. Design feedback does not authorize unrelated edits.
|
|
1059
1061
|
|
|
1060
1062
|
WORKFLOW:
|
|
1061
1063
|
1. NEVER output code as text or markdown. ALWAYS use tools.
|
|
1062
1064
|
2. Initial build: state your design brief, then create_file with a "files" array writing ALL files in one call. The preview renders automatically.
|
|
1063
1065
|
3. patch_file requires read_file for that path earlier in the conversation (or create_file in the same conversation, which counts). read_file output is numbered "42: <text>" \u2014 the prefix is display-only; never copy it into "find". Each "find" must match exactly one location \u2014 include 2-3 lines of surrounding context. Pass multiple patches per call to change distinct locations.
|
|
1064
1066
|
4. Prefer patch_file for changes to existing files \u2014 surgical, reviewable, preserves surrounding code. Reserve create_file overwrites for substantial restructuring. Inserts: find the line before, replace with that line + the new line. Deletes: empty replace.
|
|
1065
|
-
5.
|
|
1066
|
-
6. Before declaring done, call verify_app. The host's preview runtime reports whether your app actually mounted and surfaces any errors it captured \u2014 hallucinated imports, syntax the bundler rejected, undefined components, runtime crashes. If \`rendered\` is false or \`errors\` is non-empty, fix every error before the next message. If the response includes a \`note\` that verify_app isn't wired in this host, skip
|
|
1067
|
+
5. On the initial build, when adding new UI, or after user-requested design changes, call critique_design first and then audit_design. Critique checks taste, hierarchy, and distinctiveness. Audit checks tokens, focus states, aria-labels, alt text, and heading order. Patch only issues within the current user request. For text, logic, or data edits, skip both design tools.
|
|
1068
|
+
6. Before declaring done, call verify_app. The host's preview runtime reports whether your app actually mounted and surfaces any errors it captured \u2014 hallucinated imports, syntax the bundler rejected, undefined components, runtime crashes. If \`rendered\` is false or \`errors\` is non-empty, fix every error before the next message. If the response includes a \`note\` that verify_app isn't wired in this host, skip runtime verification. An unavailable runtime verifier does not authorize design changes. Use audit_design and critique_design only for the initial build, adding new UI, or user-requested design changes.
|
|
1067
1069
|
7. Keep responses to a sentence or two. Exception: when responding to critique_design, write a substantive paragraph per rubric question.
|
|
1068
1070
|
|
|
1069
1071
|
STRUCTURE:
|
|
@@ -1407,12 +1409,13 @@ function isCacheExpired(cache, expirationMs = DEFAULT_CACHE_EXPIRATION_MS) {
|
|
|
1407
1409
|
if (!cache) return true;
|
|
1408
1410
|
return Date.now() - cache.timestamp > expirationMs;
|
|
1409
1411
|
}
|
|
1410
|
-
function buildCacheEntry(tools, checksum) {
|
|
1412
|
+
function buildCacheEntry(tools, checksum, etag) {
|
|
1411
1413
|
return {
|
|
1412
1414
|
tools,
|
|
1413
1415
|
timestamp: Date.now(),
|
|
1414
1416
|
version: CACHE_VERSION,
|
|
1415
|
-
...checksum && { checksum }
|
|
1417
|
+
...checksum && { checksum },
|
|
1418
|
+
...etag && { etag }
|
|
1416
1419
|
};
|
|
1417
1420
|
}
|
|
1418
1421
|
function writeLocalStorageCache(entry) {
|
|
@@ -1447,19 +1450,36 @@ function shouldRefreshTools(responseChecksum, cache = localStorageToolsCache) {
|
|
|
1447
1450
|
const cachedChecksum = getToolsChecksum(cache);
|
|
1448
1451
|
return cachedChecksum instanceof Promise ? cachedChecksum.then(decide) : decide(cachedChecksum);
|
|
1449
1452
|
}
|
|
1450
|
-
async function fetchServerToolsFromApi(baseUrl,
|
|
1451
|
-
const
|
|
1453
|
+
async function fetchServerToolsFromApi(baseUrl, authHeaders, etag) {
|
|
1454
|
+
const request = (validator) => fetch(`${baseUrl}/api/v1/tools`, {
|
|
1452
1455
|
method: "GET",
|
|
1453
1456
|
headers: {
|
|
1454
|
-
|
|
1455
|
-
"Content-Type": "application/json"
|
|
1457
|
+
...authHeaders,
|
|
1458
|
+
"Content-Type": "application/json",
|
|
1459
|
+
...validator && { "If-None-Match": validator }
|
|
1456
1460
|
}
|
|
1457
1461
|
});
|
|
1462
|
+
let response;
|
|
1463
|
+
try {
|
|
1464
|
+
response = await request(etag);
|
|
1465
|
+
} catch (error) {
|
|
1466
|
+
if (!etag || !(error instanceof TypeError)) throw error;
|
|
1467
|
+
etag = void 0;
|
|
1468
|
+
response = await request();
|
|
1469
|
+
}
|
|
1470
|
+
if (etag && response.status === 304) {
|
|
1471
|
+
return { notModified: true };
|
|
1472
|
+
}
|
|
1458
1473
|
if (!response.ok) {
|
|
1459
1474
|
throw new Error(`Failed to fetch server tools: ${response.status}`);
|
|
1460
1475
|
}
|
|
1461
1476
|
const data = await response.json();
|
|
1462
|
-
|
|
1477
|
+
const responseEtag = response.headers?.get("ETag") ?? void 0;
|
|
1478
|
+
return {
|
|
1479
|
+
notModified: false,
|
|
1480
|
+
...convertServerToolsResponse(data),
|
|
1481
|
+
...responseEtag && { etag: responseEtag }
|
|
1482
|
+
};
|
|
1463
1483
|
}
|
|
1464
1484
|
async function getServerTools(options) {
|
|
1465
1485
|
const {
|
|
@@ -1491,34 +1511,30 @@ async function getServerTools(options) {
|
|
|
1491
1511
|
try {
|
|
1492
1512
|
const { BASE_URL: BASE_URL2 } = await import("./clientConfig-WITO4T6L.mjs");
|
|
1493
1513
|
const effectiveBaseUrl = baseUrl ?? BASE_URL2;
|
|
1514
|
+
const validator = cached && !forceRefresh ? cached.etag : void 0;
|
|
1515
|
+
let authHeaders;
|
|
1494
1516
|
if (apiKey) {
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
}
|
|
1501
|
-
});
|
|
1502
|
-
if (!response.ok) {
|
|
1503
|
-
throw new Error(`Failed to fetch server tools: ${response.status}`);
|
|
1517
|
+
authHeaders = { "X-API-Key": apiKey };
|
|
1518
|
+
} else {
|
|
1519
|
+
if (!getToken) {
|
|
1520
|
+
getLogger().warn("[serverTools] No auth method available for fetching tools");
|
|
1521
|
+
return cached?.tools ?? [];
|
|
1504
1522
|
}
|
|
1505
|
-
const
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
getLogger().warn("[serverTools] No auth method available for fetching tools");
|
|
1512
|
-
return cached?.tools ?? [];
|
|
1523
|
+
const token = await getToken();
|
|
1524
|
+
if (!token) {
|
|
1525
|
+
getLogger().warn("[serverTools] No auth token available for fetching tools");
|
|
1526
|
+
return cached?.tools ?? [];
|
|
1527
|
+
}
|
|
1528
|
+
authHeaders = { Authorization: `Bearer ${token}` };
|
|
1513
1529
|
}
|
|
1514
|
-
const
|
|
1515
|
-
if (
|
|
1516
|
-
|
|
1517
|
-
|
|
1530
|
+
const result = await fetchServerToolsFromApi(effectiveBaseUrl, authHeaders, validator);
|
|
1531
|
+
if (result.notModified) {
|
|
1532
|
+
const confirmed = cached;
|
|
1533
|
+
await persistCache({ ...confirmed, timestamp: Date.now() });
|
|
1534
|
+
return confirmed.tools;
|
|
1518
1535
|
}
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
return tools;
|
|
1536
|
+
await persistCache(buildCacheEntry(result.tools, result.checksum, result.etag));
|
|
1537
|
+
return result.tools;
|
|
1522
1538
|
} catch (error) {
|
|
1523
1539
|
getLogger().error("[serverTools] Failed to fetch server tools:", error);
|
|
1524
1540
|
if (cached?.tools) {
|