@agent-native/core 0.227.0-nightly-20261110182415 → 0.227.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/default-agent-engine.d.ts +1 -0
- package/dist/agent/default-agent-engine.js +6 -3
- package/dist/agent/engine/builder-engine.js +10 -6
- package/dist/agent/engine/chat-model-availability.d.ts +9 -0
- package/dist/agent/engine/chat-model-availability.js +39 -0
- package/dist/agent/optional-placeholders.d.ts +1 -0
- package/dist/agent/optional-placeholders.js +3 -0
- package/dist/cli/index.js +1 -1
- package/dist/client/chat/agentkit-protocol.js +259 -200
- package/dist/client/chat/run-outcome.d.ts +48 -0
- package/dist/client/chat/run-outcome.js +50 -0
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/framework-package-versions.json +11 -11
- package/dist/jobs/run-now.js +9 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/org/index.d.ts +1 -1
- package/dist/org/migrations.d.ts +1 -1
- package/dist/provider-api/actions/provider-api.d.ts +1 -1
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/scripts/agent-engines/list-agent-engines.js +9 -5
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/dist/templates/builder-code-starter/AGENTS.md.patch +1 -1
- package/dist/templates/chat/AGENTS.md +1 -1
- package/dist/triggers/actions/list-automations.js +7 -1
- package/docs/content/agent-web-surfaces.mdx +54 -42
- package/docs/content/create-with-an-agent.mdx +1 -1
- package/docs/content/external-agents.mdx +8 -0
- package/package.json +4 -4
- package/src/templates/builder-code-starter/AGENTS.md.patch +1 -1
- package/src/templates/chat/AGENTS.md +1 -1
|
@@ -51,6 +51,7 @@ export interface DefaultAgentEngineSelection {
|
|
|
51
51
|
engine: string;
|
|
52
52
|
model: string;
|
|
53
53
|
}
|
|
54
|
+
export declare function isDefaultAgentEngineScopeResolved(ctx?: DefaultAgentEngineContext): boolean;
|
|
54
55
|
/**
|
|
55
56
|
* Read the default that applies to `ctx` (the current request when omitted):
|
|
56
57
|
* the organization's row, else an explicitly personal user's own row, else
|
|
@@ -36,6 +36,11 @@ function normalizedContext(ctx) {
|
|
|
36
36
|
function hasEngine(value) {
|
|
37
37
|
return typeof value.engine === "string" && value.engine.trim().length > 0;
|
|
38
38
|
}
|
|
39
|
+
export function isDefaultAgentEngineScopeResolved(ctx = requestContext()) {
|
|
40
|
+
return !!(normalizedContext(ctx).orgId ||
|
|
41
|
+
ctx.orgScope === "personal" ||
|
|
42
|
+
ctx.defaultAgentEngineScope === "deployment");
|
|
43
|
+
}
|
|
39
44
|
/**
|
|
40
45
|
* Read the default that applies to `ctx` (the current request when omitted):
|
|
41
46
|
* the organization's row, else an explicitly personal user's own row, else
|
|
@@ -47,9 +52,7 @@ function hasEngine(value) {
|
|
|
47
52
|
*/
|
|
48
53
|
export async function readDefaultAgentEngineSettingDetailed(ctx = requestContext()) {
|
|
49
54
|
const { userEmail, orgId } = normalizedContext(ctx);
|
|
50
|
-
if (!
|
|
51
|
-
ctx.orgScope !== "personal" &&
|
|
52
|
-
ctx.defaultAgentEngineScope !== "deployment") {
|
|
55
|
+
if (!isDefaultAgentEngineScopeResolved(ctx)) {
|
|
53
56
|
throw new Error("Organization scope could not be resolved.");
|
|
54
57
|
}
|
|
55
58
|
if (orgId) {
|
|
@@ -803,22 +803,26 @@ async function* parseJsonlStream(reader, model, captureContext = {}) {
|
|
|
803
803
|
const errMsg = event.error ||
|
|
804
804
|
event.message ||
|
|
805
805
|
"Builder gateway rejected the request as malformed.";
|
|
806
|
-
const
|
|
806
|
+
const gatewayErrCode = typeof event.errorCode === "string"
|
|
807
807
|
? event.errorCode
|
|
808
808
|
: typeof event.code === "string"
|
|
809
809
|
? event.code
|
|
810
|
-
:
|
|
811
|
-
const errCode = canonicalizeBuilderGatewayErrorCode(
|
|
812
|
-
|
|
810
|
+
: undefined;
|
|
811
|
+
const errCode = canonicalizeBuilderGatewayErrorCode(gatewayErrCode, String(errMsg)) ??
|
|
812
|
+
gatewayErrCode ??
|
|
813
|
+
"invalid_request";
|
|
813
814
|
const gatewayRequestId = typeof event.requestId === "string" ? event.requestId : undefined;
|
|
814
|
-
console.warn(`[builder-engine] stop reason=invalid_request model=${model} code=${errCode} requestId=${gatewayRequestId ?? "(none)"} providerMessagePresent=${Boolean(event.error || event.message || event.detail)}`);
|
|
815
|
+
console.warn(`[builder-engine] stop reason=invalid_request model=${model} code=${errCode} requestId=${gatewayRequestId ?? "(none)"} requestShape=${JSON.stringify(captureContext.requestShape)} providerMessagePresent=${Boolean(event.error || event.message || event.detail)}`);
|
|
815
816
|
if (isExplicitBuilderCreditsLimitCode(errCode)) {
|
|
816
817
|
await notifyBuilderCreditLimit();
|
|
817
818
|
}
|
|
818
819
|
yield stop({
|
|
819
820
|
error: errMsg,
|
|
820
821
|
errorCode: errCode,
|
|
821
|
-
|
|
822
|
+
// Without a gateway code the masked envelope does not say the fault
|
|
823
|
+
// was transient, and the rejected request would be sent unchanged.
|
|
824
|
+
providerRetryable: gatewayErrCode !== undefined &&
|
|
825
|
+
errCode === BUILDER_GATEWAY_INTERNAL_ERROR_CODE,
|
|
822
826
|
...(isCreditsLimitErrorCode(errCode)
|
|
823
827
|
? { upgradeUrl: await buildUpgradeUrl() }
|
|
824
828
|
: {}),
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the current request's user can run a chat model: Builder, a provider
|
|
3
|
+
* key of their own, or a deployment key. A connected Builder account counts
|
|
4
|
+
* even when its credits are spent: that is a top-up problem, not a missing
|
|
5
|
+
* model. "unknown" means the engine or its credential could not be resolved,
|
|
6
|
+
* which is not the same as having none.
|
|
7
|
+
*/
|
|
8
|
+
export type ChatModelAvailability = "available" | "unavailable" | "unknown";
|
|
9
|
+
export declare function resolveChatModelAvailability(): Promise<ChatModelAvailability>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { getAppConfig } from "../../app-config/index.js";
|
|
2
|
+
import { readDeployCredentialEnv } from "../../server/credential-provider.js";
|
|
3
|
+
import { getRequestOrgId, getRequestUserEmail, } from "../../server/request-context.js";
|
|
4
|
+
import { resolveChatEngine, resolveOwnerEngineApiKey, } from "../production-agent.js";
|
|
5
|
+
import { isResolvedEngineUsableForRequest, registerBuiltinEngines, } from "./index.js";
|
|
6
|
+
export async function resolveChatModelAvailability() {
|
|
7
|
+
// Credentials and the default-engine setting are both read in the request's
|
|
8
|
+
// scope, so only the request user can be checked; with none, there is no one
|
|
9
|
+
// whose model to look up, which is "unknown", never "unavailable".
|
|
10
|
+
const userEmail = getRequestUserEmail();
|
|
11
|
+
if (!userEmail)
|
|
12
|
+
return "unknown";
|
|
13
|
+
const orgId = getRequestOrgId() ?? null;
|
|
14
|
+
try {
|
|
15
|
+
registerBuiltinEngines();
|
|
16
|
+
const credentialIdentity = { userEmail, orgId };
|
|
17
|
+
const anthropicFallback = readDeployCredentialEnv("ANTHROPIC_API_KEY");
|
|
18
|
+
const ownerKey = await resolveOwnerEngineApiKey({
|
|
19
|
+
ownerEmail: userEmail,
|
|
20
|
+
...(anthropicFallback ? { anthropicFallback } : {}),
|
|
21
|
+
});
|
|
22
|
+
const appId = getAppConfig().app.id ?? getAppConfig().app.template;
|
|
23
|
+
const engine = await resolveChatEngine({
|
|
24
|
+
ownerKey,
|
|
25
|
+
...(appId ? { appId } : {}),
|
|
26
|
+
credentialIdentity,
|
|
27
|
+
});
|
|
28
|
+
return (await isResolvedEngineUsableForRequest(engine, {
|
|
29
|
+
...(ownerKey.apiKey ? { apiKey: ownerKey.apiKey } : {}),
|
|
30
|
+
credentialIdentity,
|
|
31
|
+
}))
|
|
32
|
+
? "available"
|
|
33
|
+
: "unavailable";
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.warn("[chat-model-availability] could not resolve the chat engine:", error instanceof Error ? error.message : error);
|
|
37
|
+
return "unknown";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -10,6 +10,7 @@ export declare function schemaAcceptsToolValue(schema: object, value: unknown):
|
|
|
10
10
|
export declare function discriminatedBranchIndex(branches: readonly AgentNativeJsonSchema[], value: unknown): number;
|
|
11
11
|
export declare class AmbiguousToolPlaceholdersError extends Error {
|
|
12
12
|
readonly errorCode = "ambiguous_tool_placeholders";
|
|
13
|
+
readonly statusCode = 400;
|
|
13
14
|
constructor();
|
|
14
15
|
}
|
|
15
16
|
export declare function normalizeOptionalToolPlaceholders(schema: RawJsonSchema | undefined, input: unknown, entry: Parameters<typeof actionCallReadOnly>[0] & {
|
|
@@ -167,6 +167,9 @@ function stripOptionalToolPlaceholders(schema, value, emptyValues, depth = 0) {
|
|
|
167
167
|
}
|
|
168
168
|
export class AmbiguousToolPlaceholdersError extends Error {
|
|
169
169
|
errorCode = "ambiguous_tool_placeholders";
|
|
170
|
+
// A refusal of the caller's input that ran nothing, so the HTTP action
|
|
171
|
+
// route answers 400 with this message rather than a captured 500.
|
|
172
|
+
statusCode = 400;
|
|
170
173
|
constructor() {
|
|
171
174
|
super("Tool input mixes invalid placeholders with valid empty values, so it is unclear which fields should be cleared. " +
|
|
172
175
|
"No action was run. Retry the native tool with sparse JSON containing only the intended changes. " +
|
package/dist/cli/index.js
CHANGED
|
@@ -1098,7 +1098,7 @@ Options:
|
|
|
1098
1098
|
--eager With workspace dev, start every app immediately
|
|
1099
1099
|
--prewarm With workspace dev, warm non-default apps in the background
|
|
1100
1100
|
--no-prewarm With workspace dev, keep non-default apps lazy
|
|
1101
|
-
--no-open With workspace dev, do not open a browser
|
|
1101
|
+
--no-open With dev or workspace dev, do not open a browser
|
|
1102
1102
|
--url <url> URL to audit with audit-agent-web
|
|
1103
1103
|
|
|
1104
1104
|
Feedback: ${FEEDBACK_URL}
|