@agentfield/sdk 0.1.143 → 0.1.144-rc.2
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/index.d.ts +12 -2
- package/dist/index.js +128 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -838,7 +838,14 @@ declare class AgentFieldClient {
|
|
|
838
838
|
durationMs?: number;
|
|
839
839
|
}): Promise<void>;
|
|
840
840
|
publishExecutionLogs(payload: ExecutionLogTransportPayload): void;
|
|
841
|
-
updateExecutionStatus(executionId: string, update: ExecutionStatusUpdate): Promise<void>;
|
|
841
|
+
updateExecutionStatus(executionId: string, update: ExecutionStatusUpdate, maxRetries?: number): Promise<void>;
|
|
842
|
+
/**
|
|
843
|
+
* POST a status update, matching the Go SDK's postExecutionStatus: retry
|
|
844
|
+
* transport errors, 408, 429 and 5xx with 1s, 2s, 4s, 8s backoff; any other
|
|
845
|
+
* status (e.g. 404 unknown execution, 409 terminal-status conflict) will not
|
|
846
|
+
* change on a resend, so it fails fast. Throws the last error on failure.
|
|
847
|
+
*/
|
|
848
|
+
private postExecutionStatus;
|
|
842
849
|
/** Build the `X-*` dispatch headers shared by execute / executeAsync. */
|
|
843
850
|
private buildExecuteHeaders;
|
|
844
851
|
/**
|
|
@@ -2100,6 +2107,9 @@ declare class HarnessProviderUnavailable extends Error {
|
|
|
2100
2107
|
missingAuthEnv?: readonly string[];
|
|
2101
2108
|
});
|
|
2102
2109
|
}
|
|
2110
|
+
declare class HarnessProviderNotConfigured extends HarnessProviderUnavailable {
|
|
2111
|
+
constructor(binary: string);
|
|
2112
|
+
}
|
|
2103
2113
|
type BinaryResolver = (binary: string, env: Environment) => string | undefined;
|
|
2104
2114
|
/** Receives the resolved binary path followed by the provider's version arguments. */
|
|
2105
2115
|
type VersionProbe = (command: string[]) => Promise<string>;
|
|
@@ -3318,4 +3328,4 @@ declare function simulateSchedule<R>(handler: (ctx: SimulatedContext) => R | Pro
|
|
|
3318
3328
|
*/
|
|
3319
3329
|
declare function loadFixture(source: string): Record<string, unknown>;
|
|
3320
3330
|
|
|
3321
|
-
export { ACTIVE_STATUSES, AIClient, type AIConfig, type AIEmbeddingOptions, type AIRequestOptions, type AIStream, type AIToolRequestOptions, AforgeProvider, Agent, type AgentCapability, type AgentConfig, type AgentHandler, AgentRouter, type AgentRouterOptions, type AgentState, ApprovalClient, type ApprovalDecision, type ApprovalRequestResponse, ApprovalResult, type ApprovalStatusResponse, Audio, type AudioOutput, type AudioRequest, type AuditTrailExport, type AuditTrailFilters, type Awaitable, type BinaryResolver, CANONICAL_STATUSES, CODEAF_DEFAULT_MODEL, CodeafProvider, type CompactCapability, type CompactDiscoveryResponse, type CostEntry, type CostEntryInit, CostTracker, DEFAULT_HARNESS_PROVIDER, DEFAULT_TOOL_CALL_LIMIT_REACHED, DIDAuthenticator, type DIDIdentity, type DIDIdentityPackage, type DIDRegistrationRequest, type DIDRegistrationResponse, type DeploymentType, DidClient, DidInterface, DidManager, type DidResolver, type DiscoveryFormat, type DiscoveryOptions, type DiscoveryPagination, type DiscoveryResponse, type DiscoveryResult, type EventTriggerBinding, type EventTriggerSpec, ExecutionContext, type ExecutionCredential, type ExecutionLogAttributes, type ExecutionLogBatchPayload, type ExecutionLogContext, type ExecutionLogEmitOptions, type ExecutionLogEntry, type ExecutionLogLevel, type ExecutionLogTransport, type ExecutionLogTransportPayload, type ExecutionLogWireEntry, ExecutionLogger, type ExecutionLoggerOptions, type ExecutionMetadata, ExecutionStatus, type ExecutionStatusValue, File, type FileOutput, type GenerateCredentialOptions, type GenerateCredentialParams, HARNESS_PROVIDER_ENV_VAR, HEADER_CALLER_DID, HEADER_DID_NONCE, HEADER_DID_SIGNATURE, HEADER_DID_TIMESTAMP, type HarnessConfig, type HarnessDoctorOptions, type HarnessOptions, type HarnessProvider, type HarnessProviderName, HarnessProviderUnavailable, type HarnessResult, HarnessRunner, type HealthStatus, Image, type ImageOutput, type ImageRequest, JWE_ALG, JWE_ENC, KEY_AGREEMENT_TYPE, MODEL_VARIANT_SEP, type MediaProvider, MediaProviderError, type MediaResponse, MediaRouter, type MemoryChangeEvent, MemoryClient, MemoryClientBase, type MemoryConfig, MemoryEventClient, type MemoryEventHandler, type MemoryEventHistoryOptions, type MemoryEventSubscriptionOptions, MemoryInterface, type MemoryRequestMetadata, type MemoryRequestOptions, type MemoryScope, type MemoryWatchHandler, type MessageSource, type Metrics, type ModelVariant, type MultimodalContent, MultimodalResponse, OpenRouterMediaProvider, type OpenRouterMediaProviderOptions, PauseClock, PauseManager, type Payload, PayloadEncryptionError, type PromptTemplates, type ProviderHealth, RateLimitError, type RateLimiterOptions, type RawExecutionContext, type RawResult, RealtimeSession, type ReasonerCapability, ReasonerContext, type ReasonerDefinition, type ReasonerHandler, type ReasonerOptions, type RequestApprovalPayload, type ResolvedPromptTemplates, SUPPORTED_PROVIDERS, SUPPORTED_PROVIDER_NAMES, SUPPORTED_SESSION_TRANSPORTS, type ScheduleTriggerBinding, type ScheduleTriggerSpec, type ServerlessAdapter, type ServerlessEvent, type ServerlessResponse, type SessionDefinition, type SessionOptions, type SessionProvider, type SessionTransport, type SessionTransportCapability, SessionTransportError, type SessionTurn, type SimulateScheduleOptions, type SimulateTriggerOptions, type SimulatedContext, type SkillCapability, SkillContext, type SkillDefinition, type SkillHandler, type SkillOptions, StatelessRateLimiter, TERMINAL_STATUSES, TRACE_SOURCE_ASSISTANT, TRACE_SOURCE_TOOL_ERROR, TRACE_SOURCE_TOOL_LIMIT, TRACE_SOURCE_TOOL_RESULT, TRACE_SOURCE_TOOL_SYSTEM_PROMPT, TRACE_SOURCE_USER, Text, type ToolCallConfig, type ToolCallRecord, type ToolCallTrace, type ToolErrorFormatter, type ToolResultFormatter, type ToolsOption, type TracedMessage, type TriggerBinding, type TriggerContext, type TriggerEnvelope, type TurnDetection, USAGE_ENVELOPE_KEY, type UnwrapResult, type UsageEntryWire, type UsageSummaryWire, type VectorSearchOptions, type VectorSearchResult, type VersionProbe, Video, type VideoFrameImage, type VideoInputReference, type VideoRequest, type WaitForApprovalOptions, type WorkflowCredential, type WorkflowMetadata, type WorkflowProgressOptions, WorkflowReporter, type WrapperProbe, type ZodSchema, applyTriggerTransform, attachUsageToSyncResult, audioFromBase64, audioFromBuffer, audioFromFile, audioFromUrl, audioMediaType, buildProvider, buildSessionDefinition, buildToolConfig, capabilitiesToTools, capabilityToMetadataTool, capabilityToTool, createExecutionLogger, createHarnessResult, createMetrics, createMultimodalResponse, createRawResult, decrypt, decryptToString, defaultToolErrorFormatter, defaultToolResultFormatter, deriveProvider, encryptForDid, encryptToJwk, ensureCliAvailable, eventTrigger, executeToolCallLoop, extractKeyAgreementJwk, fileFromBase64, fileFromBuffer, fileFromPath, fileFromUrl, findExecutable, generateX25519KeyPair, getCurrentContext, getCurrentSkillContext, guessUrlMimeType, harnessDoctor, imageFromBase64, imageFromBuffer, imageFromFile, imageFromUrl, installApprovalWebhookRoute, isActive, isExecutionLogBatchPayload, isTerminal, isTriggerEnvelope, loadFixture, normalizeExecutionLogEntry, normalizeSessionTransportValue, normalizeStatus, normalizeTurnDetection, resolveModelAndVariant, resolvePromptTemplates, resolveProviderName, scheduleTrigger, serializeExecutionLogEntry, simulateSchedule, simulateTrigger, splitModelVariant, text, triggerToPayload, unwrapEnvelope, usageSummaryOrNull, validateSessionTransport, videoFromBase64, videoFromBuffer, videoFromFile, videoFromUrl };
|
|
3331
|
+
export { ACTIVE_STATUSES, AIClient, type AIConfig, type AIEmbeddingOptions, type AIRequestOptions, type AIStream, type AIToolRequestOptions, AforgeProvider, Agent, type AgentCapability, type AgentConfig, type AgentHandler, AgentRouter, type AgentRouterOptions, type AgentState, ApprovalClient, type ApprovalDecision, type ApprovalRequestResponse, ApprovalResult, type ApprovalStatusResponse, Audio, type AudioOutput, type AudioRequest, type AuditTrailExport, type AuditTrailFilters, type Awaitable, type BinaryResolver, CANONICAL_STATUSES, CODEAF_DEFAULT_MODEL, CodeafProvider, type CompactCapability, type CompactDiscoveryResponse, type CostEntry, type CostEntryInit, CostTracker, DEFAULT_HARNESS_PROVIDER, DEFAULT_TOOL_CALL_LIMIT_REACHED, DIDAuthenticator, type DIDIdentity, type DIDIdentityPackage, type DIDRegistrationRequest, type DIDRegistrationResponse, type DeploymentType, DidClient, DidInterface, DidManager, type DidResolver, type DiscoveryFormat, type DiscoveryOptions, type DiscoveryPagination, type DiscoveryResponse, type DiscoveryResult, type EventTriggerBinding, type EventTriggerSpec, ExecutionContext, type ExecutionCredential, type ExecutionLogAttributes, type ExecutionLogBatchPayload, type ExecutionLogContext, type ExecutionLogEmitOptions, type ExecutionLogEntry, type ExecutionLogLevel, type ExecutionLogTransport, type ExecutionLogTransportPayload, type ExecutionLogWireEntry, ExecutionLogger, type ExecutionLoggerOptions, type ExecutionMetadata, ExecutionStatus, type ExecutionStatusValue, File, type FileOutput, type GenerateCredentialOptions, type GenerateCredentialParams, HARNESS_PROVIDER_ENV_VAR, HEADER_CALLER_DID, HEADER_DID_NONCE, HEADER_DID_SIGNATURE, HEADER_DID_TIMESTAMP, type HarnessConfig, type HarnessDoctorOptions, type HarnessOptions, type HarnessProvider, type HarnessProviderName, HarnessProviderNotConfigured, HarnessProviderUnavailable, type HarnessResult, HarnessRunner, type HealthStatus, Image, type ImageOutput, type ImageRequest, JWE_ALG, JWE_ENC, KEY_AGREEMENT_TYPE, MODEL_VARIANT_SEP, type MediaProvider, MediaProviderError, type MediaResponse, MediaRouter, type MemoryChangeEvent, MemoryClient, MemoryClientBase, type MemoryConfig, MemoryEventClient, type MemoryEventHandler, type MemoryEventHistoryOptions, type MemoryEventSubscriptionOptions, MemoryInterface, type MemoryRequestMetadata, type MemoryRequestOptions, type MemoryScope, type MemoryWatchHandler, type MessageSource, type Metrics, type ModelVariant, type MultimodalContent, MultimodalResponse, OpenRouterMediaProvider, type OpenRouterMediaProviderOptions, PauseClock, PauseManager, type Payload, PayloadEncryptionError, type PromptTemplates, type ProviderHealth, RateLimitError, type RateLimiterOptions, type RawExecutionContext, type RawResult, RealtimeSession, type ReasonerCapability, ReasonerContext, type ReasonerDefinition, type ReasonerHandler, type ReasonerOptions, type RequestApprovalPayload, type ResolvedPromptTemplates, SUPPORTED_PROVIDERS, SUPPORTED_PROVIDER_NAMES, SUPPORTED_SESSION_TRANSPORTS, type ScheduleTriggerBinding, type ScheduleTriggerSpec, type ServerlessAdapter, type ServerlessEvent, type ServerlessResponse, type SessionDefinition, type SessionOptions, type SessionProvider, type SessionTransport, type SessionTransportCapability, SessionTransportError, type SessionTurn, type SimulateScheduleOptions, type SimulateTriggerOptions, type SimulatedContext, type SkillCapability, SkillContext, type SkillDefinition, type SkillHandler, type SkillOptions, StatelessRateLimiter, TERMINAL_STATUSES, TRACE_SOURCE_ASSISTANT, TRACE_SOURCE_TOOL_ERROR, TRACE_SOURCE_TOOL_LIMIT, TRACE_SOURCE_TOOL_RESULT, TRACE_SOURCE_TOOL_SYSTEM_PROMPT, TRACE_SOURCE_USER, Text, type ToolCallConfig, type ToolCallRecord, type ToolCallTrace, type ToolErrorFormatter, type ToolResultFormatter, type ToolsOption, type TracedMessage, type TriggerBinding, type TriggerContext, type TriggerEnvelope, type TurnDetection, USAGE_ENVELOPE_KEY, type UnwrapResult, type UsageEntryWire, type UsageSummaryWire, type VectorSearchOptions, type VectorSearchResult, type VersionProbe, Video, type VideoFrameImage, type VideoInputReference, type VideoRequest, type WaitForApprovalOptions, type WorkflowCredential, type WorkflowMetadata, type WorkflowProgressOptions, WorkflowReporter, type WrapperProbe, type ZodSchema, applyTriggerTransform, attachUsageToSyncResult, audioFromBase64, audioFromBuffer, audioFromFile, audioFromUrl, audioMediaType, buildProvider, buildSessionDefinition, buildToolConfig, capabilitiesToTools, capabilityToMetadataTool, capabilityToTool, createExecutionLogger, createHarnessResult, createMetrics, createMultimodalResponse, createRawResult, decrypt, decryptToString, defaultToolErrorFormatter, defaultToolResultFormatter, deriveProvider, encryptForDid, encryptToJwk, ensureCliAvailable, eventTrigger, executeToolCallLoop, extractKeyAgreementJwk, fileFromBase64, fileFromBuffer, fileFromPath, fileFromUrl, findExecutable, generateX25519KeyPair, getCurrentContext, getCurrentSkillContext, guessUrlMimeType, harnessDoctor, imageFromBase64, imageFromBuffer, imageFromFile, imageFromUrl, installApprovalWebhookRoute, isActive, isExecutionLogBatchPayload, isTerminal, isTriggerEnvelope, loadFixture, normalizeExecutionLogEntry, normalizeSessionTransportValue, normalizeStatus, normalizeTurnDetection, resolveModelAndVariant, resolvePromptTemplates, resolveProviderName, scheduleTrigger, serializeExecutionLogEntry, simulateSchedule, simulateTrigger, splitModelVariant, text, triggerToPayload, unwrapEnvelope, usageSummaryOrNull, validateSessionTransport, videoFromBase64, videoFromBuffer, videoFromFile, videoFromUrl };
|
package/dist/index.js
CHANGED
|
@@ -332,6 +332,8 @@ var init_codeafInstall = __esm({
|
|
|
332
332
|
// src/harness/availability.ts
|
|
333
333
|
var availability_exports = {};
|
|
334
334
|
__export(availability_exports, {
|
|
335
|
+
CODEAF_MISSING_KEY_MESSAGE: () => CODEAF_MISSING_KEY_MESSAGE,
|
|
336
|
+
HarnessProviderNotConfigured: () => HarnessProviderNotConfigured,
|
|
335
337
|
HarnessProviderUnavailable: () => HarnessProviderUnavailable,
|
|
336
338
|
SUPPORTED_PROVIDER_NAMES: () => SUPPORTED_PROVIDER_NAMES,
|
|
337
339
|
ensureCliAvailable: () => ensureCliAvailable,
|
|
@@ -522,7 +524,7 @@ async function harnessDoctor(providers, options = {}) {
|
|
|
522
524
|
}
|
|
523
525
|
return reports;
|
|
524
526
|
}
|
|
525
|
-
var PROVIDER_SPECS, SUPPORTED_PROVIDER_NAMES, HarnessProviderUnavailable, WINDOWS_BATCH_EXTENSIONS, BATCH_PROBE_ENV_PREFIX;
|
|
527
|
+
var PROVIDER_SPECS, SUPPORTED_PROVIDER_NAMES, CODEAF_MISSING_KEY_MESSAGE, HarnessProviderUnavailable, HarnessProviderNotConfigured, WINDOWS_BATCH_EXTENSIONS, BATCH_PROBE_ENV_PREFIX;
|
|
526
528
|
var init_availability = __esm({
|
|
527
529
|
"src/harness/availability.ts"() {
|
|
528
530
|
init_codeafInstall();
|
|
@@ -591,6 +593,7 @@ var init_availability = __esm({
|
|
|
591
593
|
SUPPORTED_PROVIDER_NAMES = Object.freeze(
|
|
592
594
|
Object.keys(PROVIDER_SPECS).sort()
|
|
593
595
|
);
|
|
596
|
+
CODEAF_MISSING_KEY_MESSAGE = "Harness provider 'codeaf' needs a model key and none is configured. Set OPENROUTER_API_KEY (https://openrouter.ai/keys), or choose another harness provider with the provider option or AGENTFIELD_HARNESS_PROVIDER.";
|
|
594
597
|
HarnessProviderUnavailable = class extends Error {
|
|
595
598
|
provider;
|
|
596
599
|
binary;
|
|
@@ -610,6 +613,17 @@ var init_availability = __esm({
|
|
|
610
613
|
this.missingAuthEnv = missingAuthEnv;
|
|
611
614
|
}
|
|
612
615
|
};
|
|
616
|
+
HarnessProviderNotConfigured = class extends HarnessProviderUnavailable {
|
|
617
|
+
constructor(binary) {
|
|
618
|
+
super("codeaf", {
|
|
619
|
+
binary,
|
|
620
|
+
installCommand: "af codeaf ensure",
|
|
621
|
+
missingAuthEnv: ["OPENROUTER_API_KEY"]
|
|
622
|
+
});
|
|
623
|
+
this.name = "HarnessProviderNotConfigured";
|
|
624
|
+
this.message = CODEAF_MISSING_KEY_MESSAGE;
|
|
625
|
+
}
|
|
626
|
+
};
|
|
613
627
|
WINDOWS_BATCH_EXTENSIONS = /* @__PURE__ */ new Set([".bat", ".cmd"]);
|
|
614
628
|
BATCH_PROBE_ENV_PREFIX = "AGENTFIELD_PROBE_ARG_";
|
|
615
629
|
}
|
|
@@ -1100,9 +1114,16 @@ var init_aforge = __esm({
|
|
|
1100
1114
|
var codeaf_exports = {};
|
|
1101
1115
|
__export(codeaf_exports, {
|
|
1102
1116
|
CODEAF_DEFAULT_MODEL: () => CODEAF_DEFAULT_MODEL,
|
|
1117
|
+
CODEAF_MISSING_KEY_WARNING: () => CODEAF_MISSING_KEY_WARNING,
|
|
1103
1118
|
CodeafProvider: () => CodeafProvider,
|
|
1104
|
-
|
|
1119
|
+
resetCodeafAuthWarnings: () => resetCodeafAuthWarnings,
|
|
1120
|
+
resolveCodeafMaxConcurrent: () => resolveCodeafMaxConcurrent,
|
|
1121
|
+
warnCodeafConfiguration: () => warnCodeafConfiguration
|
|
1105
1122
|
});
|
|
1123
|
+
function resetCodeafAuthWarnings() {
|
|
1124
|
+
missingKeyLogged = false;
|
|
1125
|
+
constructionWarningLogged = false;
|
|
1126
|
+
}
|
|
1106
1127
|
function resolveCodeafMaxConcurrent() {
|
|
1107
1128
|
const value = process.env.CODEAF_MAX_CONCURRENT ?? process.env.AFORGE_MAX_CONCURRENT;
|
|
1108
1129
|
const parsed = Number(value);
|
|
@@ -1230,7 +1251,58 @@ function childEnvironment(options, variant) {
|
|
|
1230
1251
|
if (normalized && REASONING_VARIANTS2.has(normalized)) env.CODEAF_EXEC_REASONING = normalized;
|
|
1231
1252
|
return { ...env, ...overlay };
|
|
1232
1253
|
}
|
|
1233
|
-
|
|
1254
|
+
function hasModelKey(env) {
|
|
1255
|
+
const value = (...names2) => names2.map((name) => env[name]?.trim() ?? "").find(Boolean) ?? "";
|
|
1256
|
+
if (value("OPENROUTER_API_KEY")) return true;
|
|
1257
|
+
const key = value("OPENAI_API_KEY");
|
|
1258
|
+
const base = value("CODEAF_BASE_URL", "AFORGE_BASE_URL");
|
|
1259
|
+
if (key) {
|
|
1260
|
+
if (key.startsWith("sk-or-")) return true;
|
|
1261
|
+
if (base) {
|
|
1262
|
+
try {
|
|
1263
|
+
const address = base.includes("://") ? base : `https://${base.replace(/^\/\//, "")}`;
|
|
1264
|
+
const host = new URL(address).hostname.toLowerCase().replace(/\.$/, "").replace(/^www\./, "");
|
|
1265
|
+
if (host !== "openrouter.ai") return true;
|
|
1266
|
+
} catch {
|
|
1267
|
+
return true;
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
const names = ["CODEAF_PROFILE_DIR", "AFORGE_PROFILE_DIR", "CODEAF_HOME", "AFORGE_HOME"];
|
|
1272
|
+
if (names.some((name) => Boolean(env[name]) && !env[name]?.trim())) return true;
|
|
1273
|
+
const profile = value(...names);
|
|
1274
|
+
if (!profile) return true;
|
|
1275
|
+
for (const filename of ["credentials.json", "codex.json"]) {
|
|
1276
|
+
try {
|
|
1277
|
+
fs.statSync(path__default.join(profile, filename));
|
|
1278
|
+
return true;
|
|
1279
|
+
} catch (error) {
|
|
1280
|
+
if (error.code !== "ENOENT") return true;
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
let config;
|
|
1284
|
+
try {
|
|
1285
|
+
config = JSON.parse(fs.readFileSync(path__default.join(profile, "config.json"), "utf8"));
|
|
1286
|
+
} catch (error) {
|
|
1287
|
+
return error.code !== "ENOENT";
|
|
1288
|
+
}
|
|
1289
|
+
if (config === null || typeof config !== "object" || Array.isArray(config)) return true;
|
|
1290
|
+
const { api_key: savedKey, model_sources: sources } = config;
|
|
1291
|
+
return typeof savedKey === "string" && Boolean(savedKey.trim()) || sources !== null && typeof sources === "object" && Object.keys(sources).length > 0;
|
|
1292
|
+
}
|
|
1293
|
+
function warnCodeafConfiguration(config) {
|
|
1294
|
+
try {
|
|
1295
|
+
const provider = resolveExecutionProvider(config);
|
|
1296
|
+
if (provider !== "codeaf" && provider !== "aforge") return;
|
|
1297
|
+
if (provider === "aforge" && (config.aforgeBin !== void 0 || process.env.AFORGE_BIN?.trim())) return;
|
|
1298
|
+
if (!hasModelKey({ ...process.env, ...childEnvironment({}, void 0) }) && !constructionWarningLogged) {
|
|
1299
|
+
constructionWarningLogged = true;
|
|
1300
|
+
console.warn(CODEAF_MISSING_KEY_WARNING);
|
|
1301
|
+
}
|
|
1302
|
+
} catch {
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
var CODEAF_DEFAULT_MODEL, REASONING_VARIANTS2, ANSI_PATTERN2, CODEAF_MISSING_KEY_WARNING, missingKeyLogged, constructionWarningLogged, Semaphore2, codeafSemaphore, resolution, downloadError, aliasLogged, invalidCommandLogged, CodeafProvider;
|
|
1234
1306
|
var init_codeaf = __esm({
|
|
1235
1307
|
"src/harness/providers/codeaf.ts"() {
|
|
1236
1308
|
init_base();
|
|
@@ -1240,9 +1312,13 @@ var init_codeaf = __esm({
|
|
|
1240
1312
|
init_availability();
|
|
1241
1313
|
init_codeafInstall();
|
|
1242
1314
|
init_modelVariant();
|
|
1315
|
+
init_factory();
|
|
1243
1316
|
CODEAF_DEFAULT_MODEL = "~deepseek/deepseek-v4-flash-latest";
|
|
1244
1317
|
REASONING_VARIANTS2 = /* @__PURE__ */ new Set(["off", "low", "medium", "high"]);
|
|
1245
1318
|
ANSI_PATTERN2 = /\x1B\[[0-?]*[ -/]*[@-~]/g;
|
|
1319
|
+
CODEAF_MISSING_KEY_WARNING = "CodeAF is the harness provider and no model key is configured, so harness calls will fail. Set OPENROUTER_API_KEY (https://openrouter.ai/keys), or choose another harness provider with the provider option or AGENTFIELD_HARNESS_PROVIDER.";
|
|
1320
|
+
missingKeyLogged = false;
|
|
1321
|
+
constructionWarningLogged = false;
|
|
1246
1322
|
Semaphore2 = class {
|
|
1247
1323
|
constructor(limit) {
|
|
1248
1324
|
this.limit = limit;
|
|
@@ -1283,6 +1359,13 @@ var init_codeaf = __esm({
|
|
|
1283
1359
|
if (legacyPin) {
|
|
1284
1360
|
return { ...await new AforgeProvider(legacyPin).execute(prompt, options), provider: "aforge" };
|
|
1285
1361
|
}
|
|
1362
|
+
if (!hasModelKey({ ...process.env, ...childEnvironment(options, void 0) })) {
|
|
1363
|
+
if (!missingKeyLogged) {
|
|
1364
|
+
missingKeyLogged = true;
|
|
1365
|
+
console.warn(CODEAF_MISSING_KEY_WARNING);
|
|
1366
|
+
}
|
|
1367
|
+
throw new HarnessProviderNotConfigured(this.bin || process.env.CODEAF_BIN || "codeaf");
|
|
1368
|
+
}
|
|
1286
1369
|
const started = performance.now();
|
|
1287
1370
|
const parsedTimeout = Number.parseInt(process.env.AGENTFIELD_HARNESS_TIMEOUT_SECONDS ?? "", 10);
|
|
1288
1371
|
const timeout = Number.isFinite(parsedTimeout) && parsedTimeout > 0 ? parsedTimeout : 1800;
|
|
@@ -5439,7 +5522,7 @@ var AgentFieldClient = class {
|
|
|
5439
5522
|
}).catch(() => {
|
|
5440
5523
|
});
|
|
5441
5524
|
}
|
|
5442
|
-
async updateExecutionStatus(executionId, update) {
|
|
5525
|
+
async updateExecutionStatus(executionId, update, maxRetries = 5) {
|
|
5443
5526
|
if (!executionId) {
|
|
5444
5527
|
throw new Error("executionId is required to update workflow status");
|
|
5445
5528
|
}
|
|
@@ -5451,11 +5534,36 @@ var AgentFieldClient = class {
|
|
|
5451
5534
|
progress: update.progress !== void 0 ? Math.round(update.progress) : void 0,
|
|
5452
5535
|
status_reason: update.statusReason
|
|
5453
5536
|
};
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5537
|
+
await this.postExecutionStatus(executionId, JSON.stringify(payload), maxRetries);
|
|
5538
|
+
}
|
|
5539
|
+
/**
|
|
5540
|
+
* POST a status update, matching the Go SDK's postExecutionStatus: retry
|
|
5541
|
+
* transport errors, 408, 429 and 5xx with 1s, 2s, 4s, 8s backoff; any other
|
|
5542
|
+
* status (e.g. 404 unknown execution, 409 terminal-status conflict) will not
|
|
5543
|
+
* change on a resend, so it fails fast. Throws the last error on failure.
|
|
5544
|
+
*/
|
|
5545
|
+
async postExecutionStatus(executionId, bodyStr, maxRetries) {
|
|
5546
|
+
let lastErr;
|
|
5547
|
+
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
5548
|
+
const authHeaders = this.didAuthenticator.signRequest(Buffer.from(bodyStr));
|
|
5549
|
+
try {
|
|
5550
|
+
await this.http.post(`/api/v1/executions/${encodeURIComponent(executionId)}/status`, bodyStr, {
|
|
5551
|
+
headers: this.mergeHeaders({ "Content-Type": "application/json", ...authHeaders }),
|
|
5552
|
+
timeout: 3e4
|
|
5553
|
+
});
|
|
5554
|
+
return;
|
|
5555
|
+
} catch (err) {
|
|
5556
|
+
lastErr = err;
|
|
5557
|
+
const status = axios5.isAxiosError(err) ? err.response?.status : void 0;
|
|
5558
|
+
if (status !== void 0 && !isRetryableStatus(status)) {
|
|
5559
|
+
throw err;
|
|
5560
|
+
}
|
|
5561
|
+
}
|
|
5562
|
+
if (attempt < maxRetries - 1) {
|
|
5563
|
+
await sleep2(2 ** attempt * 1e3);
|
|
5564
|
+
}
|
|
5565
|
+
}
|
|
5566
|
+
throw lastErr;
|
|
5459
5567
|
}
|
|
5460
5568
|
/** Build the `X-*` dispatch headers shared by execute / executeAsync. */
|
|
5461
5569
|
buildExecuteHeaders(metadata) {
|
|
@@ -5649,28 +5757,12 @@ var AgentFieldClient = class {
|
|
|
5649
5757
|
if (payload.statusReason !== void 0) body.status_reason = payload.statusReason;
|
|
5650
5758
|
if (payload.errorDetails !== void 0) body.error_details = payload.errorDetails;
|
|
5651
5759
|
if (payload.usage !== void 0) body.usage = payload.usage;
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
`/api/v1/executions/${encodeURIComponent(executionId)}/status`,
|
|
5658
|
-
bodyStr,
|
|
5659
|
-
{
|
|
5660
|
-
headers: this.mergeHeaders({ "Content-Type": "application/json", ...authHeaders }),
|
|
5661
|
-
timeout: 3e4
|
|
5662
|
-
}
|
|
5663
|
-
);
|
|
5664
|
-
if (res.status >= 200 && res.status < 300) {
|
|
5665
|
-
return true;
|
|
5666
|
-
}
|
|
5667
|
-
} catch {
|
|
5668
|
-
}
|
|
5669
|
-
if (attempt < maxRetries - 1) {
|
|
5670
|
-
await sleep2(2 ** attempt * 1e3);
|
|
5671
|
-
}
|
|
5760
|
+
try {
|
|
5761
|
+
await this.postExecutionStatus(executionId, JSON.stringify(body), maxRetries);
|
|
5762
|
+
return true;
|
|
5763
|
+
} catch {
|
|
5764
|
+
return false;
|
|
5672
5765
|
}
|
|
5673
|
-
return false;
|
|
5674
5766
|
}
|
|
5675
5767
|
async discoverCapabilities(options = {}) {
|
|
5676
5768
|
const format = (options.format ?? "json").toLowerCase();
|
|
@@ -5849,6 +5941,9 @@ var AgentFieldClient = class {
|
|
|
5849
5941
|
});
|
|
5850
5942
|
}
|
|
5851
5943
|
};
|
|
5944
|
+
function isRetryableStatus(status) {
|
|
5945
|
+
return status === 408 || status === 429 || status >= 500;
|
|
5946
|
+
}
|
|
5852
5947
|
function sleep2(ms) {
|
|
5853
5948
|
return new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
5854
5949
|
}
|
|
@@ -5871,6 +5966,7 @@ function wrapResult(result) {
|
|
|
5871
5966
|
|
|
5872
5967
|
// src/agent/Agent.ts
|
|
5873
5968
|
init_factory();
|
|
5969
|
+
init_codeaf();
|
|
5874
5970
|
init_modelVariant();
|
|
5875
5971
|
var MemoryClientBase = class {
|
|
5876
5972
|
http;
|
|
@@ -7346,6 +7442,7 @@ var Agent = class {
|
|
|
7346
7442
|
deploymentType: config.deploymentType ?? "long_running",
|
|
7347
7443
|
asyncExecution: config.asyncExecution ?? true
|
|
7348
7444
|
};
|
|
7445
|
+
if (config.harnessConfig) warnCodeafConfiguration(config.harnessConfig);
|
|
7349
7446
|
this.app = express();
|
|
7350
7447
|
this.app.use(express.json());
|
|
7351
7448
|
this.aiClient = new AIClient(this.config.aiConfig);
|
|
@@ -10227,6 +10324,6 @@ function loadFixture(source) {
|
|
|
10227
10324
|
);
|
|
10228
10325
|
}
|
|
10229
10326
|
|
|
10230
|
-
export { ACTIVE_STATUSES, AIClient, AforgeProvider, Agent, AgentRouter, ApprovalClient, ApprovalResult, Audio, CANONICAL_STATUSES, CODEAF_DEFAULT_MODEL, CodeafProvider, CostTracker, DEFAULT_HARNESS_PROVIDER, DEFAULT_TOOL_CALL_LIMIT_REACHED, DIDAuthenticator, DidClient, DidInterface, DidManager, ExecutionContext, ExecutionLogger, ExecutionStatus, File, HARNESS_PROVIDER_ENV_VAR, HEADER_CALLER_DID, HEADER_DID_NONCE, HEADER_DID_SIGNATURE, HEADER_DID_TIMESTAMP, HarnessProviderUnavailable, HarnessRunner, Image, JWE_ALG, JWE_ENC, KEY_AGREEMENT_TYPE, MODEL_VARIANT_SEP, MediaProviderError, MediaRouter, MemoryClient, MemoryClientBase, MemoryEventClient, MemoryInterface, MultimodalResponse, OpenRouterMediaProvider, PauseClock, PauseManager, PayloadEncryptionError, RateLimitError, RealtimeSession, ReasonerContext, SUPPORTED_PROVIDERS, SUPPORTED_PROVIDER_NAMES, SUPPORTED_SESSION_TRANSPORTS, SessionTransportError, SkillContext, StatelessRateLimiter, TERMINAL_STATUSES, TRACE_SOURCE_ASSISTANT, TRACE_SOURCE_TOOL_ERROR, TRACE_SOURCE_TOOL_LIMIT, TRACE_SOURCE_TOOL_RESULT, TRACE_SOURCE_TOOL_SYSTEM_PROMPT, TRACE_SOURCE_USER, Text, USAGE_ENVELOPE_KEY, Video, WorkflowReporter, applyTriggerTransform, attachUsageToSyncResult, audioFromBase64, audioFromBuffer, audioFromFile, audioFromUrl, audioMediaType, buildProvider, buildSessionDefinition, buildToolConfig, capabilitiesToTools, capabilityToMetadataTool, capabilityToTool, createExecutionLogger, createHarnessResult, createMetrics, createMultimodalResponse, createRawResult, decrypt, decryptToString, defaultToolErrorFormatter, defaultToolResultFormatter, deriveProvider, encryptForDid, encryptToJwk, ensureCliAvailable, eventTrigger, executeToolCallLoop, extractKeyAgreementJwk, fileFromBase64, fileFromBuffer, fileFromPath, fileFromUrl, findExecutable, generateX25519KeyPair, getCurrentContext, getCurrentSkillContext, guessUrlMimeType, harnessDoctor, imageFromBase64, imageFromBuffer, imageFromFile, imageFromUrl, installApprovalWebhookRoute, isActive, isExecutionLogBatchPayload, isTerminal, isTriggerEnvelope, loadFixture, normalizeExecutionLogEntry, normalizeSessionTransportValue, normalizeStatus, normalizeTurnDetection, resolveModelAndVariant, resolvePromptTemplates, resolveProviderName, scheduleTrigger, serializeExecutionLogEntry, simulateSchedule, simulateTrigger, splitModelVariant, text, triggerToPayload, unwrapEnvelope, usageSummaryOrNull, validateSessionTransport, videoFromBase64, videoFromBuffer, videoFromFile, videoFromUrl };
|
|
10327
|
+
export { ACTIVE_STATUSES, AIClient, AforgeProvider, Agent, AgentRouter, ApprovalClient, ApprovalResult, Audio, CANONICAL_STATUSES, CODEAF_DEFAULT_MODEL, CodeafProvider, CostTracker, DEFAULT_HARNESS_PROVIDER, DEFAULT_TOOL_CALL_LIMIT_REACHED, DIDAuthenticator, DidClient, DidInterface, DidManager, ExecutionContext, ExecutionLogger, ExecutionStatus, File, HARNESS_PROVIDER_ENV_VAR, HEADER_CALLER_DID, HEADER_DID_NONCE, HEADER_DID_SIGNATURE, HEADER_DID_TIMESTAMP, HarnessProviderNotConfigured, HarnessProviderUnavailable, HarnessRunner, Image, JWE_ALG, JWE_ENC, KEY_AGREEMENT_TYPE, MODEL_VARIANT_SEP, MediaProviderError, MediaRouter, MemoryClient, MemoryClientBase, MemoryEventClient, MemoryInterface, MultimodalResponse, OpenRouterMediaProvider, PauseClock, PauseManager, PayloadEncryptionError, RateLimitError, RealtimeSession, ReasonerContext, SUPPORTED_PROVIDERS, SUPPORTED_PROVIDER_NAMES, SUPPORTED_SESSION_TRANSPORTS, SessionTransportError, SkillContext, StatelessRateLimiter, TERMINAL_STATUSES, TRACE_SOURCE_ASSISTANT, TRACE_SOURCE_TOOL_ERROR, TRACE_SOURCE_TOOL_LIMIT, TRACE_SOURCE_TOOL_RESULT, TRACE_SOURCE_TOOL_SYSTEM_PROMPT, TRACE_SOURCE_USER, Text, USAGE_ENVELOPE_KEY, Video, WorkflowReporter, applyTriggerTransform, attachUsageToSyncResult, audioFromBase64, audioFromBuffer, audioFromFile, audioFromUrl, audioMediaType, buildProvider, buildSessionDefinition, buildToolConfig, capabilitiesToTools, capabilityToMetadataTool, capabilityToTool, createExecutionLogger, createHarnessResult, createMetrics, createMultimodalResponse, createRawResult, decrypt, decryptToString, defaultToolErrorFormatter, defaultToolResultFormatter, deriveProvider, encryptForDid, encryptToJwk, ensureCliAvailable, eventTrigger, executeToolCallLoop, extractKeyAgreementJwk, fileFromBase64, fileFromBuffer, fileFromPath, fileFromUrl, findExecutable, generateX25519KeyPair, getCurrentContext, getCurrentSkillContext, guessUrlMimeType, harnessDoctor, imageFromBase64, imageFromBuffer, imageFromFile, imageFromUrl, installApprovalWebhookRoute, isActive, isExecutionLogBatchPayload, isTerminal, isTriggerEnvelope, loadFixture, normalizeExecutionLogEntry, normalizeSessionTransportValue, normalizeStatus, normalizeTurnDetection, resolveModelAndVariant, resolvePromptTemplates, resolveProviderName, scheduleTrigger, serializeExecutionLogEntry, simulateSchedule, simulateTrigger, splitModelVariant, text, triggerToPayload, unwrapEnvelope, usageSummaryOrNull, validateSessionTransport, videoFromBase64, videoFromBuffer, videoFromFile, videoFromUrl };
|
|
10231
10328
|
//# sourceMappingURL=index.js.map
|
|
10232
10329
|
//# sourceMappingURL=index.js.map
|