@agent-native/core 0.228.0-nightly-20261111212500 → 0.228.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/engine/builder-engine.js +5 -4
- package/dist/agent/engine/error-detail.d.ts +1 -0
- package/dist/agent/engine/error-detail.js +5 -0
- package/dist/agent/production-agent.js +2 -2
- package/dist/app-config/onboarding.d.ts +1 -0
- package/dist/app-config/onboarding.js +1 -0
- package/dist/app-config/schema.d.ts +1 -0
- package/dist/cli/index.d.ts +7 -1
- package/dist/cli/index.js +19 -3
- package/dist/client/chat/agentkit-agent-native.js +145 -0
- package/dist/client/chat/agentkit-protocol.js +8 -2
- package/dist/client/error-format.js +5 -1
- package/dist/coding-tools/run-code-result.d.ts +11 -0
- package/dist/coding-tools/run-code-result.js +39 -0
- package/dist/coding-tools/run-code.js +6 -6
- package/dist/coding-tools/sandbox/local-child-process-adapter.js +20 -0
- package/dist/collab/routes.d.ts +1 -1
- package/dist/decisions/actions/decide.d.ts +1 -0
- package/dist/decisions/actions/decide.js +1 -0
- package/dist/decisions/decide.js +2 -1
- package/dist/decisions/types.d.ts +1 -0
- package/dist/extensions/routes.js +1 -1
- package/dist/framework-package-versions.json +11 -11
- package/dist/integrations/slack-input-request.d.ts +2 -0
- package/dist/integrations/slack-input-request.js +87 -0
- package/dist/integrations/webhook-handler.js +10 -58
- package/dist/provider-api/actions/custom-provider-registration.d.ts +12 -12
- package/dist/provider-api/actions/provider-api.d.ts +12 -12
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/scripts/db/safety.js +1 -0
- package/dist/server/agent-chat/context-tools.js +59 -23
- package/dist/server/builder-signup-experiment.js +4 -1
- package/dist/shared/ssr-session-bootstrap.js +5 -1
- package/dist/templates/chat/app/components/chat/ChatRouteContent.tsx +10 -3
- package/dist/templates/chat/app/global.css +0 -5
- package/dist/vite/client.js +17 -0
- package/docs/content/dispatch.mdx +1 -1
- package/docs/content/multi-app-workspace.mdx +1 -1
- package/docs/content/security.mdx +1 -1
- package/docs/content/template-dispatch-reference.mdx +1 -1
- package/docs/content/workspace-management.mdx +0 -1
- package/package.json +4 -4
- package/src/templates/chat/app/components/chat/ChatRouteContent.tsx +10 -3
- package/src/templates/chat/app/global.css +0 -5
|
@@ -524,18 +524,19 @@ async function recordAuthFailureForCurrentLane(opts) {
|
|
|
524
524
|
}
|
|
525
525
|
async function* emitHttpError(response, opts) {
|
|
526
526
|
const status = response.status;
|
|
527
|
-
let errBody =
|
|
527
|
+
let errBody = null;
|
|
528
528
|
const rawText = await response.text().catch(() => "");
|
|
529
529
|
if (rawText) {
|
|
530
530
|
try {
|
|
531
531
|
errBody = JSON.parse(rawText);
|
|
532
532
|
}
|
|
533
533
|
catch {
|
|
534
|
-
errBody
|
|
534
|
+
errBody = { message: normalizeGatewayErrorText(rawText, status) };
|
|
535
535
|
}
|
|
536
536
|
}
|
|
537
|
-
const message = errBody
|
|
538
|
-
const
|
|
537
|
+
const message = [errBody?.message, errBody?.error?.message].find((value) => typeof value === "string") ?? `Builder gateway returned ${status}`;
|
|
538
|
+
const providerCode = [errBody?.code, errBody?.error?.code].find((value) => typeof value === "string");
|
|
539
|
+
const code = canonicalizeBuilderGatewayErrorCode(providerCode, message) ??
|
|
539
540
|
`http_${status}`;
|
|
540
541
|
const retryAfterMs = extractRetryAfterMs({
|
|
541
542
|
responseHeaders: Object.fromEntries(response.headers.entries()),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare function describeErrorWithCauses(err: unknown, maxLinks?: number): string;
|
|
2
2
|
export declare function isProviderConnectionErrorMessage(message: string): boolean;
|
|
3
3
|
export declare function isProviderConnectionError(err: unknown): boolean;
|
|
4
|
+
export declare function isProviderTokenRateLimitMessage(message: string): boolean;
|
|
4
5
|
export declare function isContextOverflowMessage(message: string): boolean;
|
|
5
6
|
export declare const BUILDER_GATEWAY_INTERNAL_ERROR_CODE = "builder_gateway_internal_error";
|
|
6
7
|
export declare const PROVIDER_TRANSIENT_REJECTION_ERROR_CODE = "provider_transient_rejection";
|
|
@@ -43,7 +43,12 @@ export function isProviderConnectionErrorMessage(message) {
|
|
|
43
43
|
export function isProviderConnectionError(err) {
|
|
44
44
|
return isProviderConnectionErrorMessage(describeErrorWithCauses(err));
|
|
45
45
|
}
|
|
46
|
+
export function isProviderTokenRateLimitMessage(message) {
|
|
47
|
+
return /\btokens? per minute\b|\(TPM\)/i.test(message);
|
|
48
|
+
}
|
|
46
49
|
export function isContextOverflowMessage(message) {
|
|
50
|
+
if (isProviderTokenRateLimitMessage(message))
|
|
51
|
+
return false;
|
|
47
52
|
const msg = message.toLowerCase();
|
|
48
53
|
return (msg.includes("context_length_exceeded") ||
|
|
49
54
|
msg.includes("input_too_long") ||
|
|
@@ -79,7 +79,7 @@ import { applyContextXrayTransformForIteration } from "./engine/context-directiv
|
|
|
79
79
|
import { attemptContinuationDispatch } from "./engine/continuation-dispatch-retry.js";
|
|
80
80
|
import { formatLlmCredentialErrorMessage, LLM_MISSING_CREDENTIALS_ERROR_CODE, LLM_MISSING_CREDENTIALS_MESSAGE, userFacingLlmCredentialError, } from "./engine/credential-errors.js";
|
|
81
81
|
import { getEngineCredentialOwner } from "./engine/credential-owner.js";
|
|
82
|
-
import { BUILDER_GATEWAY_INTERNAL_ERROR_CODE, isContextOverflowCode, isContextOverflowMessage, isInvalidAttachmentProviderMessage, isProviderConnectionErrorMessage, isRejectedRequestErrorCode, PROVIDER_RATE_LIMITED_ERROR_CODE, PROVIDER_TRANSIENT_REJECTION_ERROR_CODE, } from "./engine/error-detail.js";
|
|
82
|
+
import { BUILDER_GATEWAY_INTERNAL_ERROR_CODE, isContextOverflowCode, isContextOverflowMessage, isInvalidAttachmentProviderMessage, isProviderConnectionErrorMessage, isProviderTokenRateLimitMessage, isRejectedRequestErrorCode, PROVIDER_RATE_LIMITED_ERROR_CODE, PROVIDER_TRANSIENT_REJECTION_ERROR_CODE, } from "./engine/error-detail.js";
|
|
83
83
|
import { resolveEngine, explicitEngineName, registerBuiltinEngines, getStoredModelForEngine, normalizeModelForEngine, isResolvedEngineUsableForRequest, } from "./engine/index.js";
|
|
84
84
|
import { limitProviderTools, MAX_PROVIDER_TOOLS, } from "./engine/limit-provider-tools.js";
|
|
85
85
|
import { resolveEmptyResponseRetryMaxOutputTokens, resolveMainChatMaxOutputTokens, resolveMaxOutputTokensForEngine, } from "./engine/output-tokens.js";
|
|
@@ -2063,7 +2063,7 @@ function engineStopError(event, messages) {
|
|
|
2063
2063
|
(part.type === "tool-result" && (part.images?.length ?? 0) > 0));
|
|
2064
2064
|
const attachmentRejected = event.errorCode === "invalid_attachment" ||
|
|
2065
2065
|
(hasInlineAttachment &&
|
|
2066
|
-
(event.statusCode === 413 ||
|
|
2066
|
+
((event.statusCode === 413 && !isProviderTokenRateLimitMessage(error)) ||
|
|
2067
2067
|
((event.statusCode === undefined ||
|
|
2068
2068
|
event.statusCode === 400 ||
|
|
2069
2069
|
event.statusCode === 422) &&
|
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
export declare const onboardingConfig: z.ZodObject<{
|
|
3
3
|
builderSignupExperimentId: z.ZodDefault<z.ZodString>;
|
|
4
4
|
builderSignupExperiment: z.ZodDefault<z.ZodBoolean>;
|
|
5
|
+
builderSignupAutomaticPercent: z.ZodDefault<z.ZodNumber>;
|
|
5
6
|
builderSignupExperimentOverride: z.ZodOptional<z.ZodBoolean>;
|
|
6
7
|
firstRunCreditsExperiment: z.ZodDefault<z.ZodEnum<{
|
|
7
8
|
v1: "v1";
|
|
@@ -5,6 +5,7 @@ export const onboardingConfig = z.object({
|
|
|
5
5
|
.regex(/^[a-z][a-z0-9_]*$/)
|
|
6
6
|
.default("design_builder_signup_v1"),
|
|
7
7
|
builderSignupExperiment: z.boolean().default(false),
|
|
8
|
+
builderSignupAutomaticPercent: z.number().int().min(0).max(100).default(50),
|
|
8
9
|
builderSignupExperimentOverride: z.boolean().optional().meta({
|
|
9
10
|
env: "BUILDER_SIGNUP_EXPERIMENT",
|
|
10
11
|
doc: "Enable the pre-signup automatic Builder account experiment for this app.",
|
|
@@ -289,6 +289,7 @@ export declare const appConfigSchema: z.ZodObject<{
|
|
|
289
289
|
onboarding: z.ZodPrefault<z.ZodObject<{
|
|
290
290
|
builderSignupExperimentId: z.ZodDefault<z.ZodString>;
|
|
291
291
|
builderSignupExperiment: z.ZodDefault<z.ZodBoolean>;
|
|
292
|
+
builderSignupAutomaticPercent: z.ZodDefault<z.ZodNumber>;
|
|
292
293
|
builderSignupExperimentOverride: z.ZodOptional<z.ZodBoolean>;
|
|
293
294
|
firstRunCreditsExperiment: z.ZodDefault<z.ZodEnum<{
|
|
294
295
|
v1: "v1";
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* The exit status the CLI reports for a finished child (57526).
|
|
4
|
+
*
|
|
5
|
+
* `code ?? 0` made a child killed by a signal look successful, so a SIGKILLed `tsc` passed a preflight that then shipped. A signal exit is 128 plus the
|
|
6
|
+
* signal's number, the shell convention: nonzero for a caller that only asks "did it fail", and still the signal for a caller that asks which.
|
|
7
|
+
*/
|
|
8
|
+
export declare function childExitCode(code: number | null, signal: NodeJS.Signals | string | null): number;
|
package/dist/cli/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { execFileSync, execSync, spawn } from "child_process";
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import { createRequire } from "module";
|
|
5
|
+
import os from "os";
|
|
5
6
|
import path from "path";
|
|
6
7
|
import { fileURLToPath } from "url";
|
|
7
8
|
import { clearAgentNativeNitroPresetMarker, resolveAgentNativeNitroPreset, } from "../deploy/nitro-preset.js";
|
|
@@ -273,9 +274,24 @@ function extractNodeInspectFlag(args) {
|
|
|
273
274
|
}
|
|
274
275
|
return { inspectFlag, rest };
|
|
275
276
|
}
|
|
277
|
+
/**
|
|
278
|
+
* The exit status the CLI reports for a finished child (57526).
|
|
279
|
+
*
|
|
280
|
+
* `code ?? 0` made a child killed by a signal look successful, so a SIGKILLed `tsc` passed a preflight that then shipped. A signal exit is 128 plus the
|
|
281
|
+
* signal's number, the shell convention: nonzero for a caller that only asks "did it fail", and still the signal for a caller that asks which.
|
|
282
|
+
*/
|
|
283
|
+
export function childExitCode(code, signal) {
|
|
284
|
+
if (signal) {
|
|
285
|
+
const number = typeof signal === "string"
|
|
286
|
+
? os.constants.signals[signal]
|
|
287
|
+
: undefined;
|
|
288
|
+
return typeof number === "number" ? 128 + number : 1;
|
|
289
|
+
}
|
|
290
|
+
return code ?? 1;
|
|
291
|
+
}
|
|
276
292
|
function run(cmd, cmdArgs, opts) {
|
|
277
293
|
const child = spawn(cmd, cmdArgs, cliSpawnOptions(opts));
|
|
278
|
-
child.on("exit", (code) => process.exit(code
|
|
294
|
+
child.on("exit", (code, signal) => process.exit(childExitCode(code, signal)));
|
|
279
295
|
for (const sig of ["SIGINT", "SIGTERM", "SIGHUP"]) {
|
|
280
296
|
process.on(sig, () => {
|
|
281
297
|
child.kill(sig);
|
|
@@ -498,7 +514,7 @@ switch (command) {
|
|
|
498
514
|
console.error('No production build found. Run "agent-native build" first.');
|
|
499
515
|
process.exit(1);
|
|
500
516
|
}
|
|
501
|
-
run(process.execPath, [serverEntry, ...args]);
|
|
517
|
+
run(process.execPath, [serverEntry, ...args], { shell: false });
|
|
502
518
|
break;
|
|
503
519
|
}
|
|
504
520
|
case "action": {
|
|
@@ -533,7 +549,7 @@ switch (command) {
|
|
|
533
549
|
...identityArgs,
|
|
534
550
|
]);
|
|
535
551
|
else
|
|
536
|
-
run(process.execPath, [script, ...identityArgs]);
|
|
552
|
+
run(process.execPath, [script, ...identityArgs], { shell: false });
|
|
537
553
|
break;
|
|
538
554
|
}
|
|
539
555
|
case "agent": {
|
|
@@ -1453,6 +1453,117 @@ function persistedConnectionRequest(request) {
|
|
|
1453
1453
|
...(request.updatedAt ? { updatedAt: request.updatedAt } : {}),
|
|
1454
1454
|
};
|
|
1455
1455
|
}
|
|
1456
|
+
const MAX_PERSISTED_DELEGATION_TEXT_CHARS = 2_048;
|
|
1457
|
+
const MAX_PERSISTED_DELEGATION_METADATA_CHARS = 256;
|
|
1458
|
+
function persistedDelegationText(text) {
|
|
1459
|
+
return text ? text.slice(0, MAX_PERSISTED_DELEGATION_TEXT_CHARS) : undefined;
|
|
1460
|
+
}
|
|
1461
|
+
function persistedScalarMetadata(metadata) {
|
|
1462
|
+
if (!metadata)
|
|
1463
|
+
return undefined;
|
|
1464
|
+
const scalars = Object.fromEntries(Object.entries(metadata).filter(([, value]) => typeof value === "boolean" ||
|
|
1465
|
+
(typeof value === "number" && Number.isFinite(value)) ||
|
|
1466
|
+
(typeof value === "string" &&
|
|
1467
|
+
value.length <= MAX_PERSISTED_DELEGATION_METADATA_CHARS)));
|
|
1468
|
+
return Object.keys(scalars).length > 0 ? { metadata: scalars } : undefined;
|
|
1469
|
+
}
|
|
1470
|
+
function persistedReference(reference) {
|
|
1471
|
+
return {
|
|
1472
|
+
id: reference.id,
|
|
1473
|
+
kind: reference.kind,
|
|
1474
|
+
label: reference.label,
|
|
1475
|
+
...(reference.uri ? { uri: reference.uri } : {}),
|
|
1476
|
+
};
|
|
1477
|
+
}
|
|
1478
|
+
/** Readable steps and reply only, never the delegated agent's raw snapshot. */
|
|
1479
|
+
function persistedSummary(summary) {
|
|
1480
|
+
const parts = (summary ?? []).flatMap((part) => part.type === "text"
|
|
1481
|
+
? [
|
|
1482
|
+
{
|
|
1483
|
+
type: "text",
|
|
1484
|
+
text: part.text.slice(0, MAX_PERSISTED_DELEGATION_TEXT_CHARS),
|
|
1485
|
+
...(part.format ? { format: part.format } : {}),
|
|
1486
|
+
},
|
|
1487
|
+
]
|
|
1488
|
+
: []);
|
|
1489
|
+
return parts.length > 0 ? parts : undefined;
|
|
1490
|
+
}
|
|
1491
|
+
function persistedParticipant(agent) {
|
|
1492
|
+
const description = persistedDelegationText(agent.description);
|
|
1493
|
+
return {
|
|
1494
|
+
id: agent.id,
|
|
1495
|
+
name: agent.name,
|
|
1496
|
+
status: agent.status,
|
|
1497
|
+
...(agent.kind ? { kind: agent.kind } : {}),
|
|
1498
|
+
...(agent.parentAgentId ? { parentAgentId: agent.parentAgentId } : {}),
|
|
1499
|
+
...(agent.activeTaskId ? { activeTaskId: agent.activeTaskId } : {}),
|
|
1500
|
+
...(description ? { description } : {}),
|
|
1501
|
+
...(agent.origin ? { origin: persistedReference(agent.origin) } : {}),
|
|
1502
|
+
...(agent.startedAt ? { startedAt: agent.startedAt } : {}),
|
|
1503
|
+
...(agent.updatedAt ? { updatedAt: agent.updatedAt } : {}),
|
|
1504
|
+
...(agent.completedAt ? { completedAt: agent.completedAt } : {}),
|
|
1505
|
+
...persistedScalarMetadata(agent.metadata),
|
|
1506
|
+
};
|
|
1507
|
+
}
|
|
1508
|
+
function persistedInteraction(interaction) {
|
|
1509
|
+
const detail = persistedDelegationText(interaction.detail);
|
|
1510
|
+
return {
|
|
1511
|
+
id: interaction.id,
|
|
1512
|
+
kind: interaction.kind,
|
|
1513
|
+
agentId: interaction.agentId,
|
|
1514
|
+
...(interaction.targetAgentId
|
|
1515
|
+
? { targetAgentId: interaction.targetAgentId }
|
|
1516
|
+
: {}),
|
|
1517
|
+
...(interaction.label ? { label: interaction.label } : {}),
|
|
1518
|
+
...(detail ? { detail } : {}),
|
|
1519
|
+
...(interaction.scope ? { scope: interaction.scope } : {}),
|
|
1520
|
+
...(interaction.object
|
|
1521
|
+
? { object: persistedReference(interaction.object) }
|
|
1522
|
+
: {}),
|
|
1523
|
+
...(interaction.source
|
|
1524
|
+
? { source: persistedReference(interaction.source) }
|
|
1525
|
+
: {}),
|
|
1526
|
+
...(interaction.occurredAt ? { occurredAt: interaction.occurredAt } : {}),
|
|
1527
|
+
...persistedScalarMetadata(interaction.metadata),
|
|
1528
|
+
};
|
|
1529
|
+
}
|
|
1530
|
+
function persistedDelegatedActivityFields(activity) {
|
|
1531
|
+
if (!activity.agentId)
|
|
1532
|
+
return {};
|
|
1533
|
+
const detail = persistedDelegationText(activity.detail);
|
|
1534
|
+
const summary = persistedSummary(activity.summary);
|
|
1535
|
+
return {
|
|
1536
|
+
agentId: activity.agentId,
|
|
1537
|
+
...(detail ? { detail } : {}),
|
|
1538
|
+
...(activity.scope ? { scope: activity.scope } : {}),
|
|
1539
|
+
...(activity.object ? { object: persistedReference(activity.object) } : {}),
|
|
1540
|
+
...(activity.source ? { source: persistedReference(activity.source) } : {}),
|
|
1541
|
+
...(summary ? { summary } : {}),
|
|
1542
|
+
...persistedScalarMetadata(activity.metadata),
|
|
1543
|
+
};
|
|
1544
|
+
}
|
|
1545
|
+
function persistedTask(task) {
|
|
1546
|
+
const detail = persistedDelegationText(task.detail);
|
|
1547
|
+
const summary = persistedSummary(task.summary);
|
|
1548
|
+
return {
|
|
1549
|
+
id: task.id,
|
|
1550
|
+
title: task.title,
|
|
1551
|
+
status: task.status,
|
|
1552
|
+
...(task.kind ? { kind: task.kind } : {}),
|
|
1553
|
+
...(task.parentTaskId ? { parentTaskId: task.parentTaskId } : {}),
|
|
1554
|
+
...(task.assignedAgentId ? { assignedAgentId: task.assignedAgentId } : {}),
|
|
1555
|
+
...(task.runId ? { runId: task.runId } : {}),
|
|
1556
|
+
...(detail ? { detail } : {}),
|
|
1557
|
+
...(task.progress ? { progress: task.progress } : {}),
|
|
1558
|
+
...(task.object ? { object: persistedReference(task.object) } : {}),
|
|
1559
|
+
...(task.source ? { source: persistedReference(task.source) } : {}),
|
|
1560
|
+
...(summary ? { summary } : {}),
|
|
1561
|
+
...(task.createdAt ? { createdAt: task.createdAt } : {}),
|
|
1562
|
+
...(task.updatedAt ? { updatedAt: task.updatedAt } : {}),
|
|
1563
|
+
...(task.completedAt ? { completedAt: task.completedAt } : {}),
|
|
1564
|
+
...persistedScalarMetadata(task.metadata),
|
|
1565
|
+
};
|
|
1566
|
+
}
|
|
1456
1567
|
function persistedAnnotations(annotations = [], messageIds) {
|
|
1457
1568
|
return annotations.flatMap(({ messageId, annotation }) => messageIds.has(messageId)
|
|
1458
1569
|
? [{ messageId, annotation: persistedAnnotation(annotation) }]
|
|
@@ -1628,11 +1739,45 @@ function persistedHistoryEvents(events = []) {
|
|
|
1628
1739
|
...(activity.completedAt
|
|
1629
1740
|
? { completedAt: activity.completedAt }
|
|
1630
1741
|
: {}),
|
|
1742
|
+
...persistedDelegatedActivityFields(activity),
|
|
1631
1743
|
},
|
|
1632
1744
|
});
|
|
1633
1745
|
lastOmissionByRun.delete(event.runId);
|
|
1634
1746
|
continue;
|
|
1635
1747
|
}
|
|
1748
|
+
// Without these, a reloaded chat loses its delegated agents' steps.
|
|
1749
|
+
if (event.type === "agent.registered" ||
|
|
1750
|
+
event.type === "agent.updated" ||
|
|
1751
|
+
event.type === "agent.unregistered") {
|
|
1752
|
+
persisted.push({
|
|
1753
|
+
...base(),
|
|
1754
|
+
type: event.type,
|
|
1755
|
+
agent: persistedParticipant(event.agent),
|
|
1756
|
+
});
|
|
1757
|
+
lastOmissionByRun.delete(event.runId);
|
|
1758
|
+
continue;
|
|
1759
|
+
}
|
|
1760
|
+
if (event.type === "agent.interaction") {
|
|
1761
|
+
persisted.push({
|
|
1762
|
+
...base(),
|
|
1763
|
+
type: event.type,
|
|
1764
|
+
interaction: persistedInteraction(event.interaction),
|
|
1765
|
+
});
|
|
1766
|
+
lastOmissionByRun.delete(event.runId);
|
|
1767
|
+
continue;
|
|
1768
|
+
}
|
|
1769
|
+
if ((event.type === "task.created" ||
|
|
1770
|
+
event.type === "task.updated" ||
|
|
1771
|
+
event.type === "task.completed") &&
|
|
1772
|
+
event.task.assignedAgentId) {
|
|
1773
|
+
persisted.push({
|
|
1774
|
+
...base(),
|
|
1775
|
+
type: event.type,
|
|
1776
|
+
task: persistedTask(event.task),
|
|
1777
|
+
});
|
|
1778
|
+
lastOmissionByRun.delete(event.runId);
|
|
1779
|
+
continue;
|
|
1780
|
+
}
|
|
1636
1781
|
if (event.type === "connection.requested" ||
|
|
1637
1782
|
event.type === "connection.updated") {
|
|
1638
1783
|
persisted.push({
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AGENT_TOOL_CALL_HISTORY_MEDIA_TYPE, AGENT_TOOL_RESULT_HISTORY_MEDIA_TYPE, AGENTKIT_PROTOCOL_VERSION, AgentProtocolValidationError, approvalResponseFromResume, createCapabilityUnavailableError, createCapabilityUnsupportedError, inferAgentActivityKind, negotiateAgentKitProtocolVersion, resumeEntryFromApproval, resumeOptionId, } from "@agent-native/agentkit/protocol";
|
|
2
2
|
import { approvalKeyForPrivateHistory } from "../../agent/approval-key.js";
|
|
3
3
|
import { AUTO_CONTINUE_OF_RUN_METADATA_KEY, AUTO_CONTINUE_PROMPT, AUTO_CONTINUE_REFUSAL_CODES, CONTINUE_OF_RUN_METADATA_KEY, CONTINUE_UNAVAILABLE_CODE, } from "../../agent/auto-continue.js";
|
|
4
|
+
import { RUN_CODE_TOOL_NAME, runCodeResultFailure, } from "../../coding-tools/run-code-result.js";
|
|
4
5
|
import { isPersistableAttachmentUrl } from "../../shared/attachments.js";
|
|
5
6
|
import { parseBase64DataUrl } from "../../shared/data-url.js";
|
|
6
7
|
import { emitChatFirstOpenApp, emitChatFirstOpenBrowser, } from "../chat-first-state.js";
|
|
@@ -2124,10 +2125,15 @@ export function createAgentKitProtocolAdapter(runtime, options = {}) {
|
|
|
2124
2125
|
},
|
|
2125
2126
|
];
|
|
2126
2127
|
case "tool-done": {
|
|
2127
|
-
const
|
|
2128
|
+
const exitFailure = event.status === "completed" && event.toolName === RUN_CODE_TOOL_NAME
|
|
2129
|
+
? runCodeResultFailure(event.resultText ?? event.result)
|
|
2130
|
+
: undefined;
|
|
2131
|
+
const status = exitFailure ? "failed" : runtimeToolStatus(event.status);
|
|
2128
2132
|
const error = event.error
|
|
2129
2133
|
? protocolError(event.error, "tool_error")
|
|
2130
|
-
:
|
|
2134
|
+
: exitFailure
|
|
2135
|
+
? { code: "program_failed", message: exitFailure }
|
|
2136
|
+
: undefined;
|
|
2131
2137
|
const invocation = run.actions.get(event.toolCallId);
|
|
2132
2138
|
const previousTool = run.activeTools.get(event.toolCallId);
|
|
2133
2139
|
const metadata = mergeProtocolMetadata(previousTool?.metadata, invocation?.metadata, event.metadata, base.metadata, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GATEWAY_UNAVAILABLE_VISITOR_MESSAGE, LLM_MISSING_CREDENTIALS_MESSAGE, } from "../agent/engine/credential-errors.js";
|
|
2
2
|
import { AMBIGUOUS_HTTP_CREDENTIAL_CODES, credentialStateForErrorCode, } from "../agent/engine/credential-state.js";
|
|
3
|
-
import { BUILDER_GATEWAY_INTERNAL_ERROR_CODE, isBuilderGatewayInternalErrorMessage, isContextOverflowMessage, isRejectedRequestErrorCode, PROVIDER_TRANSIENT_REJECTION_ERROR_CODE, } from "../agent/engine/error-detail.js";
|
|
3
|
+
import { BUILDER_GATEWAY_INTERNAL_ERROR_CODE, isBuilderGatewayInternalErrorMessage, isContextOverflowMessage, isProviderTokenRateLimitMessage, isRejectedRequestErrorCode, PROVIDER_TRANSIENT_REJECTION_ERROR_CODE, } from "../agent/engine/error-detail.js";
|
|
4
4
|
import { RUN_FAILED_MESSAGE, RUN_INTERRUPTED_MESSAGE, RUN_SIGNED_OUT_MESSAGE, RUN_UNVERIFIED_MESSAGE, } from "./chat/run-outcome.js";
|
|
5
5
|
export { isCreditsLimitErrorCode } from "../agent/engine/error-detail.js";
|
|
6
6
|
export const BUILDER_SPACE_SETTINGS_URL = "https://builder.io/account/space?utm_source=agent-native&utm_medium=product&utm_campaign=onboarding&utm_content=space_settings";
|
|
@@ -334,6 +334,10 @@ export function normalizeChatError(errorMessage, errorCode) {
|
|
|
334
334
|
}
|
|
335
335
|
if (isServerChosenVisitorMessage(text))
|
|
336
336
|
return { message: text };
|
|
337
|
+
const providerDetail = providerPayload?.message ?? text;
|
|
338
|
+
if (isProviderTokenRateLimitMessage(providerDetail)) {
|
|
339
|
+
return { message: providerDetail };
|
|
340
|
+
}
|
|
337
341
|
const providerMessage = providerPayload?.errorCode === "overloaded_error"
|
|
338
342
|
? "The model provider is overloaded right now. Wait a moment, then retry."
|
|
339
343
|
: providerPayload?.message;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const RUN_CODE_TOOL_NAME = "run-code";
|
|
2
|
+
export declare function runCodeStatusLines(run: {
|
|
3
|
+
timedOut: boolean;
|
|
4
|
+
timeoutMs: number;
|
|
5
|
+
exitCode: number | null;
|
|
6
|
+
}): string[];
|
|
7
|
+
/**
|
|
8
|
+
* Failure is for the transcript only: thrown as a tool error, each debugging
|
|
9
|
+
* attempt would trip the loop breakers and setup-step stop patterns.
|
|
10
|
+
*/
|
|
11
|
+
export declare function runCodeResultFailure(result: unknown): string | undefined;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Client code imports this module, so it must stay free of Node imports.
|
|
2
|
+
export const RUN_CODE_TOOL_NAME = "run-code";
|
|
3
|
+
export function runCodeStatusLines(run) {
|
|
4
|
+
const lines = [];
|
|
5
|
+
if (run.timedOut)
|
|
6
|
+
lines.push(`timedOut: true (${run.timeoutMs}ms)`);
|
|
7
|
+
if (run.exitCode !== 0 && run.exitCode !== null) {
|
|
8
|
+
lines.push(`exitCode: ${run.exitCode}`);
|
|
9
|
+
}
|
|
10
|
+
return lines;
|
|
11
|
+
}
|
|
12
|
+
const STATUS_LINE = /^(?:timedOut: true \(\d+ms\)|exitCode: -?\d+)$/;
|
|
13
|
+
const BRIDGE_LINE = /^bridgeToolsUsed: /;
|
|
14
|
+
const UNHANDLED_ERROR = /^Unhandled error: (.+)$/m;
|
|
15
|
+
const THROWN_ERROR = /^((?:[A-Z]\w*)?(?:Error|Exception)\b.*)$/m;
|
|
16
|
+
/**
|
|
17
|
+
* Failure is for the transcript only: thrown as a tool error, each debugging
|
|
18
|
+
* attempt would trip the loop breakers and setup-step stop patterns.
|
|
19
|
+
*/
|
|
20
|
+
export function runCodeResultFailure(result) {
|
|
21
|
+
if (typeof result !== "string")
|
|
22
|
+
return undefined;
|
|
23
|
+
// Status lines lead the result; the same text later is the program's own.
|
|
24
|
+
const status = [];
|
|
25
|
+
for (const block of result.split("\n\n")) {
|
|
26
|
+
if (STATUS_LINE.test(block))
|
|
27
|
+
status.push(block);
|
|
28
|
+
else if (!BRIDGE_LINE.test(block))
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
if (!status.length)
|
|
32
|
+
return undefined;
|
|
33
|
+
// Only stderr names the error: stdout can print any text that looks like one.
|
|
34
|
+
const stderrAt = result.indexOf("\n\nstderr:\n");
|
|
35
|
+
const stderr = stderrAt < 0 ? "" : result.slice(stderrAt);
|
|
36
|
+
return (UNHANDLED_ERROR.exec(stderr)?.at(1)?.trim() ||
|
|
37
|
+
THROWN_ERROR.exec(stderr)?.at(1)?.trim() ||
|
|
38
|
+
status.join(", "));
|
|
39
|
+
}
|
|
@@ -34,6 +34,7 @@ import { runActionInvocation } from "../action-invocation.js";
|
|
|
34
34
|
import { frameworkMcpTool } from "../mcp/framework-tools.js";
|
|
35
35
|
import { parseServiceIdentityEmail } from "../org/service-identity.js";
|
|
36
36
|
import { getRequestContext, getRequestRunContext, getRequestUserEmail, runWithRequestContext, } from "../server/request-context.js";
|
|
37
|
+
import { runCodeStatusLines } from "./run-code-result.js";
|
|
37
38
|
import { failExpiredSandboxExecution, getSandboxExecutionForOwner, } from "./sandbox/executions-store.js";
|
|
38
39
|
import { BACKGROUND_DEFAULT_TIMEOUT_MS, BACKGROUND_MAX_TIMEOUT_MS, SANDBOX_EXECUTION_REDRIVE_AFTER_MS, driveSandboxExecution, enqueueSandboxExecution, getSandboxAdapter, isQueuedSandboxAdapter, registerSandboxExecutionRunner, resolveExecutionSandboxAdapter, } from "./sandbox/index.js";
|
|
39
40
|
const DEFAULT_TIMEOUT_MS = 120_000;
|
|
@@ -208,14 +209,13 @@ export function createRunCodeEntry(getActions, opts = {}) {
|
|
|
208
209
|
context,
|
|
209
210
|
evaluator,
|
|
210
211
|
});
|
|
211
|
-
const combined = [
|
|
212
|
+
const combined = [
|
|
213
|
+
stdout ? `stdout:\n${stdout.trimEnd()}` : "",
|
|
214
|
+
stderr ? `stderr:\n${stderr.trimEnd()}` : "",
|
|
215
|
+
]
|
|
212
216
|
.filter(Boolean)
|
|
213
217
|
.join("\n\n") || "(no output)";
|
|
214
|
-
const lines =
|
|
215
|
-
if (timedOut)
|
|
216
|
-
lines.push(`timedOut: true (${timeoutMs}ms)`);
|
|
217
|
-
if (exitCode !== 0 && exitCode !== null)
|
|
218
|
-
lines.push(`exitCode: ${exitCode}`);
|
|
218
|
+
const lines = runCodeStatusLines({ timedOut, timeoutMs, exitCode });
|
|
219
219
|
if (bridgeToolsUsed.length)
|
|
220
220
|
lines.push(`bridgeToolsUsed: ${bridgeToolsUsed.join(", ")}`);
|
|
221
221
|
lines.push(combined);
|
|
@@ -57,6 +57,23 @@ function supportsNetPermissionFlag(permissionFlag) {
|
|
|
57
57
|
}
|
|
58
58
|
return cachedNetPermissionSupport;
|
|
59
59
|
}
|
|
60
|
+
const EXPERIMENTAL_WARNING_FLAG = "--disable-warning=ExperimentalWarning";
|
|
61
|
+
let cachedDisableWarningSupport;
|
|
62
|
+
// `--allow-net` warns on every run, which the agent reads as its code's stderr.
|
|
63
|
+
// Node before 20.11 rejects this flag, so it is probed.
|
|
64
|
+
function supportsDisableWarningFlag() {
|
|
65
|
+
if (cachedDisableWarningSupport !== undefined) {
|
|
66
|
+
return cachedDisableWarningSupport;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const probe = spawnSync(process.execPath, [EXPERIMENTAL_WARNING_FLAG, "-e", "process.exit(0)"], { timeout: 10_000, stdio: "ignore" });
|
|
70
|
+
cachedDisableWarningSupport = probe.status === 0;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
cachedDisableWarningSupport = false;
|
|
74
|
+
}
|
|
75
|
+
return cachedDisableWarningSupport;
|
|
76
|
+
}
|
|
60
77
|
export class LocalChildProcessAdapter {
|
|
61
78
|
id = "local-child-process";
|
|
62
79
|
async run(request) {
|
|
@@ -81,6 +98,9 @@ export class LocalChildProcessAdapter {
|
|
|
81
98
|
...(supportsNetPermissionFlag(permissionFlag)
|
|
82
99
|
? ["--allow-net"]
|
|
83
100
|
: []),
|
|
101
|
+
...(supportsDisableWarningFlag()
|
|
102
|
+
? [EXPERIMENTAL_WARNING_FLAG]
|
|
103
|
+
: []),
|
|
84
104
|
...sandboxReadAllowPaths(tmpDir).map((allowedPath) => `--allow-fs-read=${allowedPath}`),
|
|
85
105
|
...sandboxWriteAllowPaths(tmpDir).map((allowedPath) => `--allow-fs-write=${allowedPath}`),
|
|
86
106
|
tmpFile,
|
package/dist/collab/routes.d.ts
CHANGED
|
@@ -26,8 +26,8 @@ export declare const postCollabUpdate: import("h3").EventHandlerWithFetch<import
|
|
|
26
26
|
ok: boolean;
|
|
27
27
|
}>>;
|
|
28
28
|
export declare const postCollabText: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
29
|
-
text?: undefined;
|
|
30
29
|
ok?: undefined;
|
|
30
|
+
text?: undefined;
|
|
31
31
|
error: string;
|
|
32
32
|
} | {
|
|
33
33
|
error?: undefined;
|
|
@@ -80,6 +80,7 @@ declare const _default: import("../../action.js").ActionDefinition<{
|
|
|
80
80
|
status: "not_configured";
|
|
81
81
|
reason: "missing_credentials";
|
|
82
82
|
providers: ("jev" | "openai")[];
|
|
83
|
+
credentialKeys: ("JEV_API_KEY" | "OPENAI_API_KEY")[];
|
|
83
84
|
} | {
|
|
84
85
|
status: "failed";
|
|
85
86
|
reason: "aborted" | "credentials_unavailable" | "invalid_input" | "invalid_response" | "provider_error" | "refusal" | "timeout" | "unsupported_input" | "unverified_capability";
|
|
@@ -58,6 +58,7 @@ const decisionOutputSchema = z.discriminatedUnion("status", [
|
|
|
58
58
|
status: z.literal("not_configured"),
|
|
59
59
|
reason: z.literal("missing_credentials"),
|
|
60
60
|
providers: z.array(providerSchema),
|
|
61
|
+
credentialKeys: z.array(z.enum(["JEV_API_KEY", "OPENAI_API_KEY"])),
|
|
61
62
|
}),
|
|
62
63
|
z.object({
|
|
63
64
|
status: z.literal("failed"),
|
package/dist/decisions/decide.js
CHANGED
|
@@ -367,7 +367,8 @@ export async function decide(input) {
|
|
|
367
367
|
return {
|
|
368
368
|
status: "not_configured",
|
|
369
369
|
reason: "missing_credentials",
|
|
370
|
-
providers: missingProviders
|
|
370
|
+
providers: missingProviders,
|
|
371
|
+
credentialKeys: missingProviders.map((provider) => provider === "jev" ? "JEV_API_KEY" : "OPENAI_API_KEY"),
|
|
371
372
|
};
|
|
372
373
|
}
|
|
373
374
|
export async function getDecisionsStatus(ownerEmail, options = {}) {
|
|
@@ -769,7 +769,7 @@ async function handleSqlQuery(event) {
|
|
|
769
769
|
}
|
|
770
770
|
}
|
|
771
771
|
export const DESTRUCTIVE_SQL_RE = /\b(CREATE\s+(?:(?:LOCAL|GLOBAL)\s+)?(?:TEMPORARY|TEMP)?\s*(TABLE|INDEX|VIEW|SCHEMA|DATABASE|TRIGGER|FUNCTION|EXTENSION|ROLE|TABLESPACE|PUBLICATION|SUBSCRIPTION)|DROP\s+(TABLE|INDEX|VIEW|SCHEMA|DATABASE|TRIGGER|FUNCTION|EXTENSION|ROLE)|TRUNCATE|DELETE\s+FROM\s+(?!tool_data\b)|ALTER\s+(TABLE|VIEW|SCHEMA|DATABASE|FUNCTION|ROLE|EXTENSION|PUBLICATION)\s+(?!tool_data\b)|ATTACH|DETACH|VACUUM|REINDEX|GRANT|REVOKE|SET\s+ROLE|RESET\s+ROLE|COPY)\b/i;
|
|
772
|
-
export const SENSITIVE_SQL_RE = /\b(app_secrets|settings|user|users|session|sessions|account|accounts|verification|oauth_tokens|tools|extensions|tool_shares|tool_slots|tool_slot_installs|tool_hidden_extensions|tool_history|member|organization|invitation|jwks|agent_trace_spans|agent_trace_summaries|agent_feedback|agent_satisfaction_scores|agent_evals|agent_runs|agent_run_events|notifications|progress_runs|integration_configs|integration_pending_tasks|integration_thread_mappings|resources|org_members|org_invitations|bigquery_cache|dashboard_views|pg_catalog|information_schema|pg_class|pg_proc|pg_namespace|pg_user|pg_roles|pg_authid|pg_shadow)\b/i;
|
|
772
|
+
export const SENSITIVE_SQL_RE = /\b(app_secrets|vault_secrets|settings|user|users|session|sessions|account|accounts|verification|oauth_tokens|tools|extensions|tool_shares|tool_slots|tool_slot_installs|tool_hidden_extensions|tool_history|member|organization|invitation|jwks|agent_trace_spans|agent_trace_summaries|agent_feedback|agent_satisfaction_scores|agent_evals|agent_runs|agent_run_events|notifications|progress_runs|integration_configs|integration_pending_tasks|integration_thread_mappings|resources|org_members|org_invitations|bigquery_cache|dashboard_views|pg_catalog|information_schema|pg_class|pg_proc|pg_namespace|pg_user|pg_roles|pg_authid|pg_shadow)\b/i;
|
|
773
773
|
export const POSITIONAL_INSERT_RE = /\bINSERT\s+INTO\s+["'`]?\w+["'`]?\s+VALUES\b/i;
|
|
774
774
|
function stripSqlComments(sql) {
|
|
775
775
|
return sql.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/--[^\n]*/g, " ");
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
-
"@agent-native/agentkit": "0.228.0
|
|
2
|
+
"@agent-native/agentkit": "0.228.0",
|
|
3
3
|
"@agent-native/code-agents-ui": "0.1.75",
|
|
4
|
-
"@agent-native/core": "0.228.0
|
|
5
|
-
"@agent-native/core-corpus": "0.228.0
|
|
6
|
-
"@agent-native/creative-context": "0.8.
|
|
7
|
-
"@agent-native/dispatch": "0.42.5
|
|
4
|
+
"@agent-native/core": "0.228.0",
|
|
5
|
+
"@agent-native/core-corpus": "0.228.0",
|
|
6
|
+
"@agent-native/creative-context": "0.8.70",
|
|
7
|
+
"@agent-native/dispatch": "0.42.5",
|
|
8
8
|
"@agent-native/embedding": "0.2.0",
|
|
9
9
|
"@agent-native/migrate": "0.0.7",
|
|
10
|
-
"@agent-native/otel": "0.1.
|
|
11
|
-
"@agent-native/pinpoint": "0.1.
|
|
12
|
-
"@agent-native/recap-cli": "0.5.101
|
|
13
|
-
"@agent-native/scheduling": "0.2.57
|
|
10
|
+
"@agent-native/otel": "0.1.37",
|
|
11
|
+
"@agent-native/pinpoint": "0.1.113",
|
|
12
|
+
"@agent-native/recap-cli": "0.5.101",
|
|
13
|
+
"@agent-native/scheduling": "0.2.57",
|
|
14
14
|
"@agent-native/shared-app-config": "0.1.2",
|
|
15
|
-
"@agent-native/skills": "0.4.5
|
|
16
|
-
"@agent-native/toolkit": "0.228.0
|
|
15
|
+
"@agent-native/skills": "0.4.5",
|
|
16
|
+
"@agent-native/toolkit": "0.228.0"
|
|
17
17
|
}
|