@agentfield/sdk 0.1.137-rc.1 → 0.1.137-rc.11

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/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # AgentField TypeScript SDK
2
2
 
3
+ ## Graceful shutdown
4
+
5
+ `serve()` installs SIGTERM and SIGINT handlers that notify the control plane and drain detached executions. Host processes that own signal handling can use `serve({ handleSignals: false })` and call the idempotent `shutdown()` method themselves. `AGENTFIELD_SHUTDOWN_TIMEOUT` accepts bare seconds (`30`) or durations (`30s`, `5m`) and defaults to 30 seconds. In Kubernetes, set `terminationGracePeriodSeconds` higher than this timeout.
6
+
3
7
  The TypeScript SDK provides an idiomatic Node.js interface for building and running AgentField agents. It mirrors the Python SDK APIs, including AI, memory, discovery, and MCP tooling.
4
8
 
5
9
  ## Installing
package/dist/index.d.ts CHANGED
@@ -792,6 +792,7 @@ declare class AgentFieldClient {
792
792
  constructor(config: AgentConfig);
793
793
  register(payload: any): Promise<any>;
794
794
  getNode(nodeId: string): Promise<any>;
795
+ shutdown(nodeId: string): Promise<any>;
795
796
  heartbeat(status?: 'starting' | 'ready' | 'degraded' | 'offline'): Promise<HealthStatus>;
796
797
  execute<T = any>(target: string, input: any, metadata?: {
797
798
  runId?: string;
@@ -1524,7 +1525,7 @@ interface HarnessConfig {
1524
1525
  * When unset, `AGENTFIELD_HARNESS_PROVIDER` is consulted before the default.
1525
1526
  * An explicit value always wins.
1526
1527
  */
1527
- provider?: 'aforge' | 'claude-code' | 'codex' | 'gemini' | 'opencode';
1528
+ provider?: 'aforge' | 'claude-code' | 'codex' | 'gemini' | 'opencode' | 'pi' | 'omp';
1528
1529
  /** Model identifier. Empty means the provider's own default. */
1529
1530
  model?: string;
1530
1531
  /**
@@ -1548,6 +1549,8 @@ interface HarnessConfig {
1548
1549
  codexBin?: string;
1549
1550
  geminiBin?: string;
1550
1551
  opencodeBin?: string;
1552
+ piBin?: string;
1553
+ ompBin?: string;
1551
1554
  }
1552
1555
  interface HarnessOptions {
1553
1556
  /**
@@ -1579,6 +1582,10 @@ interface HarnessOptions {
1579
1582
  codexBin?: string;
1580
1583
  geminiBin?: string;
1581
1584
  opencodeBin?: string;
1585
+ piBin?: string;
1586
+ ompBin?: string;
1587
+ resumeSessionId?: string;
1588
+ timeout?: number;
1582
1589
  schema?: unknown;
1583
1590
  }
1584
1591
  interface Metrics {
@@ -1888,6 +1895,8 @@ type RunnerOptions = Omit<HarnessOptions, 'schema'> & {
1888
1895
  codexBin?: string;
1889
1896
  geminiBin?: string;
1890
1897
  opencodeBin?: string;
1898
+ piBin?: string;
1899
+ ompBin?: string;
1891
1900
  };
1892
1901
  declare class HarnessRunner {
1893
1902
  private readonly config?;
@@ -1941,6 +1950,10 @@ declare class RealtimeSession {
1941
1950
  }
1942
1951
  declare function buildSessionDefinition(name: string, options: SessionOptions): SessionDefinition;
1943
1952
 
1953
+ interface ServeOptions {
1954
+ handleSignals?: boolean;
1955
+ }
1956
+
1944
1957
  declare class Agent {
1945
1958
  readonly config: AgentConfig;
1946
1959
  readonly app: express.Express;
@@ -1948,6 +1961,10 @@ declare class Agent {
1948
1961
  readonly skills: SkillRegistry;
1949
1962
  private server?;
1950
1963
  private heartbeatTimer?;
1964
+ private shutdownPromise?;
1965
+ private readonly inFlightExecutions;
1966
+ private shuttingDown;
1967
+ private signalHandlers?;
1951
1968
  private readonly aiClient;
1952
1969
  private readonly agentFieldClient;
1953
1970
  private readonly memoryClient;
@@ -2066,8 +2083,10 @@ declare class Agent {
2066
2083
  executionId?: string;
2067
2084
  }): Promise<ApprovalResult>;
2068
2085
  private buildExecutionLogContext;
2069
- serve(): Promise<void>;
2086
+ serve(options?: ServeOptions): Promise<void>;
2070
2087
  shutdown(): Promise<void>;
2088
+ private performShutdown;
2089
+ private installSignalHandlers;
2071
2090
  call(target: string, input: any): Promise<any>;
2072
2091
  /**
2073
2092
  * Remote call variant that submits the execution asynchronously and polls for
@@ -2705,6 +2724,14 @@ declare function splitModelVariant(model: unknown): ModelVariant;
2705
2724
  declare function resolveModelAndVariant(options: Record<string, unknown>): ModelVariant;
2706
2725
 
2707
2726
  declare const SUPPORTED_PROVIDERS: Set<string>;
2727
+ declare const DEFAULT_HARNESS_PROVIDER = "aforge";
2728
+ declare const HARNESS_PROVIDER_ENV_VAR = "AGENTFIELD_HARNESS_PROVIDER";
2729
+ /**
2730
+ * Applies harness provider precedence: an explicit name wins, then
2731
+ * AGENTFIELD_HARNESS_PROVIDER, then DEFAULT_HARNESS_PROVIDER ("aforge").
2732
+ * Blank / whitespace-only values are treated as unset.
2733
+ */
2734
+ declare function resolveProviderName(explicit?: string): string;
2708
2735
  declare function buildProvider(config: HarnessConfig): Promise<HarnessProvider>;
2709
2736
 
2710
2737
  /**
@@ -3043,4 +3070,4 @@ declare function simulateSchedule<R>(handler: (ctx: SimulatedContext) => R | Pro
3043
3070
  */
3044
3071
  declare function loadFixture(source: string): Record<string, unknown>;
3045
3072
 
3046
- export { ACTIVE_STATUSES, AIClient, type AIConfig, type AIEmbeddingOptions, type AIRequestOptions, type AIStream, type AIToolRequestOptions, 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, CANONICAL_STATUSES, type CompactCapability, type CompactDiscoveryResponse, type CostEntry, type CostEntryInit, CostTracker, 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, HEADER_CALLER_DID, HEADER_DID_NONCE, HEADER_DID_SIGNATURE, HEADER_DID_TIMESTAMP, type HarnessConfig, type HarnessOptions, type HarnessProvider, 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 Metrics, type ModelVariant, type MultimodalContent, MultimodalResponse, OpenRouterMediaProvider, type OpenRouterMediaProviderOptions, PauseClock, PauseManager, type Payload, PayloadEncryptionError, RateLimitError, type RateLimiterOptions, type RawExecutionContext, type RawResult, RealtimeSession, type ReasonerCapability, ReasonerContext, type ReasonerDefinition, type ReasonerHandler, type ReasonerOptions, type RequestApprovalPayload, SUPPORTED_PROVIDERS, 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, Text, type ToolCallConfig, type ToolCallRecord, type ToolCallTrace, type ToolsOption, type TriggerBinding, type TriggerContext, type TriggerEnvelope, USAGE_ENVELOPE_KEY, type UnwrapResult, type UsageEntryWire, type UsageSummaryWire, type VectorSearchOptions, type VectorSearchResult, Video, type VideoFrameImage, type VideoInputReference, type VideoRequest, type WaitForApprovalOptions, type WorkflowCredential, type WorkflowMetadata, type WorkflowProgressOptions, WorkflowReporter, type ZodSchema, applyTriggerTransform, attachUsageToSyncResult, audioFromBase64, audioFromBuffer, audioFromFile, audioFromUrl, audioMediaType, buildProvider, buildSessionDefinition, buildToolConfig, capabilitiesToTools, capabilityToMetadataTool, capabilityToTool, createExecutionLogger, createHarnessResult, createMetrics, createMultimodalResponse, createRawResult, decrypt, decryptToString, deriveProvider, encryptForDid, encryptToJwk, eventTrigger, executeToolCallLoop, extractKeyAgreementJwk, fileFromBase64, fileFromBuffer, fileFromPath, fileFromUrl, generateX25519KeyPair, getCurrentContext, getCurrentSkillContext, guessUrlMimeType, imageFromBase64, imageFromBuffer, imageFromFile, imageFromUrl, installApprovalWebhookRoute, isActive, isExecutionLogBatchPayload, isTerminal, isTriggerEnvelope, loadFixture, normalizeExecutionLogEntry, normalizeSessionTransportValue, normalizeStatus, resolveModelAndVariant, scheduleTrigger, serializeExecutionLogEntry, simulateSchedule, simulateTrigger, splitModelVariant, text, triggerToPayload, unwrapEnvelope, usageSummaryOrNull, validateSessionTransport, videoFromBase64, videoFromBuffer, videoFromFile, videoFromUrl };
3073
+ export { ACTIVE_STATUSES, AIClient, type AIConfig, type AIEmbeddingOptions, type AIRequestOptions, type AIStream, type AIToolRequestOptions, 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, CANONICAL_STATUSES, type CompactCapability, type CompactDiscoveryResponse, type CostEntry, type CostEntryInit, CostTracker, DEFAULT_HARNESS_PROVIDER, 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 HarnessOptions, type HarnessProvider, 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 Metrics, type ModelVariant, type MultimodalContent, MultimodalResponse, OpenRouterMediaProvider, type OpenRouterMediaProviderOptions, PauseClock, PauseManager, type Payload, PayloadEncryptionError, RateLimitError, type RateLimiterOptions, type RawExecutionContext, type RawResult, RealtimeSession, type ReasonerCapability, ReasonerContext, type ReasonerDefinition, type ReasonerHandler, type ReasonerOptions, type RequestApprovalPayload, SUPPORTED_PROVIDERS, 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, Text, type ToolCallConfig, type ToolCallRecord, type ToolCallTrace, type ToolsOption, type TriggerBinding, type TriggerContext, type TriggerEnvelope, USAGE_ENVELOPE_KEY, type UnwrapResult, type UsageEntryWire, type UsageSummaryWire, type VectorSearchOptions, type VectorSearchResult, Video, type VideoFrameImage, type VideoInputReference, type VideoRequest, type WaitForApprovalOptions, type WorkflowCredential, type WorkflowMetadata, type WorkflowProgressOptions, WorkflowReporter, type ZodSchema, applyTriggerTransform, attachUsageToSyncResult, audioFromBase64, audioFromBuffer, audioFromFile, audioFromUrl, audioMediaType, buildProvider, buildSessionDefinition, buildToolConfig, capabilitiesToTools, capabilityToMetadataTool, capabilityToTool, createExecutionLogger, createHarnessResult, createMetrics, createMultimodalResponse, createRawResult, decrypt, decryptToString, deriveProvider, encryptForDid, encryptToJwk, eventTrigger, executeToolCallLoop, extractKeyAgreementJwk, fileFromBase64, fileFromBuffer, fileFromPath, fileFromUrl, generateX25519KeyPair, getCurrentContext, getCurrentSkillContext, guessUrlMimeType, imageFromBase64, imageFromBuffer, imageFromFile, imageFromUrl, installApprovalWebhookRoute, isActive, isExecutionLogBatchPayload, isTerminal, isTriggerEnvelope, loadFixture, normalizeExecutionLogEntry, normalizeSessionTransportValue, normalizeStatus, resolveModelAndVariant, resolveProviderName, scheduleTrigger, serializeExecutionLogEntry, simulateSchedule, simulateTrigger, splitModelVariant, text, triggerToPayload, unwrapEnvelope, usageSummaryOrNull, validateSessionTransport, videoFromBase64, videoFromBuffer, videoFromFile, videoFromUrl };