deepline 0.3.149 → 0.3.151
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/bundling-sources/sdk/src/client.ts +347 -12
- package/dist/bundling-sources/sdk/src/http.ts +28 -2
- package/dist/bundling-sources/sdk/src/index.ts +4 -0
- package/dist/bundling-sources/sdk/src/play.ts +55 -5
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +18 -0
- package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +33 -0
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +98 -3
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger-projection-contract.ts +7 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +7 -5
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +5 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd.ts +2 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +363 -67
- package/dist/cli/index.js +393 -17
- package/dist/cli/index.mjs +399 -20
- package/dist/index.d.mts +61 -2
- package/dist/index.d.ts +61 -2
- package/dist/index.js +236 -13
- package/dist/index.mjs +236 -13
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +1 -1
- package/dist/release.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -3093,6 +3093,40 @@ type ExecuteToolRawOptions = {
|
|
|
3093
3093
|
metadata?: Record<string, unknown>;
|
|
3094
3094
|
timeout?: number;
|
|
3095
3095
|
maxRetries?: number;
|
|
3096
|
+
/** Reuse this stable key to recover or retry an ambiguous execution. */
|
|
3097
|
+
idempotencyKey?: string;
|
|
3098
|
+
/** Generate a key and enable recoverable execution before dispatch. */
|
|
3099
|
+
recover?: boolean;
|
|
3100
|
+
/** Called and awaited with the key before the first network request. */
|
|
3101
|
+
onExecution?: (execution: {
|
|
3102
|
+
idempotencyKey: string;
|
|
3103
|
+
}) => void | Promise<void>;
|
|
3104
|
+
/** Maximum time to reconnect to an in-progress keyed execution. Defaults to 15 minutes. */
|
|
3105
|
+
recoveryTimeoutMs?: number;
|
|
3106
|
+
};
|
|
3107
|
+
/** Durable state returned for a keyed tool execution. */
|
|
3108
|
+
type ExecutionRecovery = {
|
|
3109
|
+
/** Stable caller key used to resume or replay this execution. */
|
|
3110
|
+
idempotencyKey: string;
|
|
3111
|
+
/** Whether the execution is still running, completed, or has an unknown provider outcome. */
|
|
3112
|
+
state: 'running' | 'completed' | 'outcome_unknown';
|
|
3113
|
+
/** Whether this response came from an existing durable execution. */
|
|
3114
|
+
replayed: boolean;
|
|
3115
|
+
/** ISO timestamp after which the completed execution can no longer be replayed. */
|
|
3116
|
+
expiresAt?: string;
|
|
3117
|
+
};
|
|
3118
|
+
/** Durable lookup result for a keyed tool execution. */
|
|
3119
|
+
type ExecutionByKeyResult = {
|
|
3120
|
+
/** Recovery state and the key that owns the execution. */
|
|
3121
|
+
executionRecovery: ExecutionRecovery;
|
|
3122
|
+
/** Provider tool associated with the execution. */
|
|
3123
|
+
toolId: string;
|
|
3124
|
+
/** Original server-owned billing request ID, allocated before provider dispatch. */
|
|
3125
|
+
requestId?: string;
|
|
3126
|
+
/** HTTP status saved with the original response, when it was terminal. */
|
|
3127
|
+
responseStatus?: number;
|
|
3128
|
+
/** Saved execution response, when one is available for replay. */
|
|
3129
|
+
response?: unknown;
|
|
3096
3130
|
};
|
|
3097
3131
|
/**
|
|
3098
3132
|
* Standard provider/tool execution envelope returned by low-level SDK calls.
|
|
@@ -4521,6 +4555,13 @@ declare class DeeplineClient {
|
|
|
4521
4555
|
* Deepline execution envelope.
|
|
4522
4556
|
*/
|
|
4523
4557
|
executeTool<TData = unknown, TMeta = Record<string, unknown>>(toolId: string, input: Record<string, unknown>, options?: ExecuteToolRawOptions): Promise<ToolExecution<TData, TMeta>>;
|
|
4558
|
+
/** Read the durable state of a keyed tool execution. */
|
|
4559
|
+
getExecutionByKey(idempotencyKey: string): Promise<ExecutionByKeyResult>;
|
|
4560
|
+
private lookupExecutionByKey;
|
|
4561
|
+
/** Public recovery namespace. */
|
|
4562
|
+
get executions(): {
|
|
4563
|
+
getByKey: (key: string) => Promise<ExecutionByKeyResult>;
|
|
4564
|
+
};
|
|
4524
4565
|
/**
|
|
4525
4566
|
* Back-compatible alias for {@link executeTool}.
|
|
4526
4567
|
*
|
|
@@ -5970,7 +6011,23 @@ type DeeplineToolsNamespace = {
|
|
|
5970
6011
|
* For durable play code, prefer `ctx.tools.execute(...)` because the play
|
|
5971
6012
|
* runtime records the call under a stable id.
|
|
5972
6013
|
*/
|
|
5973
|
-
execute(toolId: string, input: Record<string, unknown
|
|
6014
|
+
execute(toolId: string, input: Record<string, unknown>, options?: {
|
|
6015
|
+
idempotencyKey?: string;
|
|
6016
|
+
recover?: boolean;
|
|
6017
|
+
onExecution?: (execution: {
|
|
6018
|
+
idempotencyKey: string;
|
|
6019
|
+
}) => void | Promise<void>;
|
|
6020
|
+
recoveryTimeoutMs?: number;
|
|
6021
|
+
}): Promise<DeeplineToolExecuteResult>;
|
|
6022
|
+
};
|
|
6023
|
+
type DeeplineToolExecuteResult = ToolExecuteResult & {
|
|
6024
|
+
/** Stable key used to recover this direct tool execution, when enabled. */
|
|
6025
|
+
idempotencyKey?: string;
|
|
6026
|
+
executionRecovery?: ExecutionRecovery;
|
|
6027
|
+
};
|
|
6028
|
+
type DeeplineExecutionsNamespace = {
|
|
6029
|
+
/** Look up a recoverable tool execution by its stable idempotency key. */
|
|
6030
|
+
getByKey(idempotencyKey: string): Promise<ExecutionByKeyResult>;
|
|
5974
6031
|
};
|
|
5975
6032
|
/**
|
|
5976
6033
|
* Named-play discovery and handle operations from a connected {@link DeeplineContext}.
|
|
@@ -6099,6 +6156,8 @@ declare class DeeplineContext {
|
|
|
6099
6156
|
* ```
|
|
6100
6157
|
*/
|
|
6101
6158
|
get tools(): DeeplineToolsNamespace;
|
|
6159
|
+
/** Durable state for recoverable direct tool executions. */
|
|
6160
|
+
get executions(): DeeplineExecutionsNamespace;
|
|
6102
6161
|
/**
|
|
6103
6162
|
* Play discovery and named-play handles.
|
|
6104
6163
|
*
|
|
@@ -6592,4 +6651,4 @@ declare function writeCsvOutputFile(rows: Array<Record<string, unknown>>, stem:
|
|
|
6592
6651
|
*/
|
|
6593
6652
|
declare function extractSummaryFields(payload: unknown): Record<string, Scalar>;
|
|
6594
6653
|
|
|
6595
|
-
export { type AsyncPlayRunRef, AuthError, type BillingCreditPool, type BillingInvoiceEntry, type BillingInvoicesResult, type BillingNamespace, type BillingPaymentMethodSummary, type BillingSubscriptionCancelResult, type BillingSubscriptionStatus, type BillingTopUpResult, type BillingUsageEvent, type ClearPlayHistoryRequest, type ClearPlayHistoryResult, type ColumnMap, type ColumnResolver, type ConditionalStepResolver, ConfigError, type CreateNotificationGroupInput, type CreateNotificationGroupResult, type CsvInput, type CsvOptions, type CustomerDbQueryResult, DEEPLINE_TOOL_CATEGORIES, type DatasetBuilder, type DatasetColumnDefinition, type DatasetColumnRunInput, type DbNamespace, Deepline, DeeplineClient, type DeeplineClientOptions, DeeplineContext, DeeplineError, type DeeplineNamedPlay, type DeeplinePlayRuntimeContext, type DeeplinePlaysNamespace, type DeeplineToolCategory, type DeeplineToolsNamespace, type DefinePlayConfig, type DefinedPlay, type FetchOptions, type FileInput, type IngestionStorageRepairResult, type LegacyMonitorStatusFilter, type LiveEventEnvelope, MONITOR_JOB_PHASES, MONITOR_JOB_RECONCILIATION_STATES, MONITOR_JOB_STATES, type MonitorBatchNamespace, type MonitorCheckResult, type MonitorDefinition, type MonitorDeleteResult, type MonitorDependents, type MonitorDeployResult, type MonitorDetail, type MonitorFleetDeactivateOptions, MonitorFleetDefinition, type MonitorFleetGetOptions, type MonitorFleetReactivateOptions, type MonitorFleetResult, type MonitorFleetStatus, type MonitorFleetSyncOptions, type MonitorFleetWaitOptions, type MonitorFleetsNamespace, type MonitorJobDeployOptions, type MonitorJobLogsOptions, type MonitorJobPhase, type MonitorJobReconciliationState, type MonitorJobResult, type MonitorJobState, type MonitorJobWaitOptions, type MonitorJobsNamespace, type MonitorListEntry, type MonitorPayload, type MonitorReactivateResult, type MonitorSpec, type MonitorState, type MonitorStateFilter, type MonitorUpdateChangeSummary, type MonitorUpdateResult, type MonitorsAccessStatus, type MonitorsAvailableOptions, type MonitorsAvailableResult, type MonitorsListOptions, type MonitorsListResult, type MonitorsNamespace, PLAY_BOOTSTRAP_COMPANY_FIELDS, PLAY_BOOTSTRAP_COMPANY_PROVIDER_CATEGORY, PLAY_BOOTSTRAP_CONTACT_FIELDS, PLAY_BOOTSTRAP_FINDER_KINDS, PLAY_BOOTSTRAP_OUTPUT_FIELD_BY_FINDER, PLAY_BOOTSTRAP_PEOPLE_PROVIDER_CATEGORY, PLAY_BOOTSTRAP_PROVIDER_CATEGORY_BY_FINDER, PLAY_BOOTSTRAP_SOURCE_KINDS, PLAY_BOOTSTRAP_STAGE_KINDS, PLAY_BOOTSTRAP_TEMPLATES, PROD_URL, type PlayActivityObservation, type PlayActivityState, type PlayActivityTarget, type PlayAsyncCallOptions, type PlayBindings, type PlayBootstrapEntityKind, type PlayBootstrapFinderKind, type PlayCallExecution, type PlayCallOptions, type PlayCostEstimate, type PlayFetchResponse, type PlayInputContract, type PlayJob, type PlayListItem, type PlayLiveEvent, type PlayReferenceLike, type PlayRevisionSummary, type PlayRunActionPackage, type PlayRunActivityProjection, type PlayRunDatasetActions, type PlayRunId, type PlayRunPackage, type PlayRunResult, type PlayRunStart, type PlaySheetRow, type PlaySheetRowsResult, type PlayStatus, type PlayStepProgramStep, type PlaysListOptions, type PlaysListPage, type PrebuiltPlayRef, type PublishPlayVersionRequest, type PublishPlayVersionResult, RateLimitError, type RerunOptions, type RerunPlayRunResult, type ResolvedConfig, RunObserveTransportUnavailableError, type RunsListOptions, type RunsListPage, type RunsLogsOptions, type RunsLogsResult, type RunsNamespace, type RunsTailOptions, type RuntimeStepOptions, SDK_API_CONTRACT, SDK_VERSION, type SqlListenerDeclaration, type SqlListenerEvent, type SqlListenerOperation, type SqlQuery, type StartPlayRunRequest, type StepOptions, type StepProgram, type StepProgramResolver, type StepResolver, type StopAllCandidate, type StopAllPlayRunsDryRunResult, type StopAllPlayRunsResult, type StopAllPlayRunsStopResult, type StopAllRunsOptions, type StopPlayRunResult, type ToolDefinition, ToolExecuteResult, type ToolExecution, ToolExecutionError, ToolExecutionErrorOptions, type ToolExecutionRequest, type ToolMetadata, ToolRateLimitError, ToolResultBilling, type ToolSearchOptions, type ToolSearchResult, type WorkspaceCreateResult, type WorkspacesNamespace, defineInput, defineMonitor, definePlay, defineWorkflow, extractSummaryFields, formatPlayBootstrapFinderKinds, formatPlayBootstrapFinderKindsForSentence, formatPlayBootstrapTemplates, getDefinedPlayMetadata, isPlayBootstrapFinderKind, isPlayBootstrapTemplate, isStopAllPlayRunsDryRunResult, resolveConfig, runIf, steps, tryConvertToList, writeCsvOutputFile, writeJsonOutputFile };
|
|
6654
|
+
export { type AsyncPlayRunRef, AuthError, type BillingCreditPool, type BillingInvoiceEntry, type BillingInvoicesResult, type BillingNamespace, type BillingPaymentMethodSummary, type BillingSubscriptionCancelResult, type BillingSubscriptionStatus, type BillingTopUpResult, type BillingUsageEvent, type ClearPlayHistoryRequest, type ClearPlayHistoryResult, type ColumnMap, type ColumnResolver, type ConditionalStepResolver, ConfigError, type CreateNotificationGroupInput, type CreateNotificationGroupResult, type CsvInput, type CsvOptions, type CustomerDbQueryResult, DEEPLINE_TOOL_CATEGORIES, type DatasetBuilder, type DatasetColumnDefinition, type DatasetColumnRunInput, type DbNamespace, Deepline, DeeplineClient, type DeeplineClientOptions, DeeplineContext, DeeplineError, type DeeplineExecutionsNamespace, type DeeplineNamedPlay, type DeeplinePlayRuntimeContext, type DeeplinePlaysNamespace, type DeeplineToolCategory, type DeeplineToolExecuteResult, type DeeplineToolsNamespace, type DefinePlayConfig, type DefinedPlay, type ExecutionByKeyResult, type ExecutionRecovery, type FetchOptions, type FileInput, type IngestionStorageRepairResult, type LegacyMonitorStatusFilter, type LiveEventEnvelope, MONITOR_JOB_PHASES, MONITOR_JOB_RECONCILIATION_STATES, MONITOR_JOB_STATES, type MonitorBatchNamespace, type MonitorCheckResult, type MonitorDefinition, type MonitorDeleteResult, type MonitorDependents, type MonitorDeployResult, type MonitorDetail, type MonitorFleetDeactivateOptions, MonitorFleetDefinition, type MonitorFleetGetOptions, type MonitorFleetReactivateOptions, type MonitorFleetResult, type MonitorFleetStatus, type MonitorFleetSyncOptions, type MonitorFleetWaitOptions, type MonitorFleetsNamespace, type MonitorJobDeployOptions, type MonitorJobLogsOptions, type MonitorJobPhase, type MonitorJobReconciliationState, type MonitorJobResult, type MonitorJobState, type MonitorJobWaitOptions, type MonitorJobsNamespace, type MonitorListEntry, type MonitorPayload, type MonitorReactivateResult, type MonitorSpec, type MonitorState, type MonitorStateFilter, type MonitorUpdateChangeSummary, type MonitorUpdateResult, type MonitorsAccessStatus, type MonitorsAvailableOptions, type MonitorsAvailableResult, type MonitorsListOptions, type MonitorsListResult, type MonitorsNamespace, PLAY_BOOTSTRAP_COMPANY_FIELDS, PLAY_BOOTSTRAP_COMPANY_PROVIDER_CATEGORY, PLAY_BOOTSTRAP_CONTACT_FIELDS, PLAY_BOOTSTRAP_FINDER_KINDS, PLAY_BOOTSTRAP_OUTPUT_FIELD_BY_FINDER, PLAY_BOOTSTRAP_PEOPLE_PROVIDER_CATEGORY, PLAY_BOOTSTRAP_PROVIDER_CATEGORY_BY_FINDER, PLAY_BOOTSTRAP_SOURCE_KINDS, PLAY_BOOTSTRAP_STAGE_KINDS, PLAY_BOOTSTRAP_TEMPLATES, PROD_URL, type PlayActivityObservation, type PlayActivityState, type PlayActivityTarget, type PlayAsyncCallOptions, type PlayBindings, type PlayBootstrapEntityKind, type PlayBootstrapFinderKind, type PlayCallExecution, type PlayCallOptions, type PlayCostEstimate, type PlayFetchResponse, type PlayInputContract, type PlayJob, type PlayListItem, type PlayLiveEvent, type PlayReferenceLike, type PlayRevisionSummary, type PlayRunActionPackage, type PlayRunActivityProjection, type PlayRunDatasetActions, type PlayRunId, type PlayRunPackage, type PlayRunResult, type PlayRunStart, type PlaySheetRow, type PlaySheetRowsResult, type PlayStatus, type PlayStepProgramStep, type PlaysListOptions, type PlaysListPage, type PrebuiltPlayRef, type PublishPlayVersionRequest, type PublishPlayVersionResult, RateLimitError, type RerunOptions, type RerunPlayRunResult, type ResolvedConfig, RunObserveTransportUnavailableError, type RunsListOptions, type RunsListPage, type RunsLogsOptions, type RunsLogsResult, type RunsNamespace, type RunsTailOptions, type RuntimeStepOptions, SDK_API_CONTRACT, SDK_VERSION, type SqlListenerDeclaration, type SqlListenerEvent, type SqlListenerOperation, type SqlQuery, type StartPlayRunRequest, type StepOptions, type StepProgram, type StepProgramResolver, type StepResolver, type StopAllCandidate, type StopAllPlayRunsDryRunResult, type StopAllPlayRunsResult, type StopAllPlayRunsStopResult, type StopAllRunsOptions, type StopPlayRunResult, type ToolDefinition, ToolExecuteResult, type ToolExecution, ToolExecutionError, ToolExecutionErrorOptions, type ToolExecutionRequest, type ToolMetadata, ToolRateLimitError, ToolResultBilling, type ToolSearchOptions, type ToolSearchResult, type WorkspaceCreateResult, type WorkspacesNamespace, defineInput, defineMonitor, definePlay, defineWorkflow, extractSummaryFields, formatPlayBootstrapFinderKinds, formatPlayBootstrapFinderKindsForSentence, formatPlayBootstrapTemplates, getDefinedPlayMetadata, isPlayBootstrapFinderKind, isPlayBootstrapTemplate, isStopAllPlayRunsDryRunResult, resolveConfig, runIf, steps, tryConvertToList, writeCsvOutputFile, writeJsonOutputFile };
|
package/dist/index.d.ts
CHANGED
|
@@ -3093,6 +3093,40 @@ type ExecuteToolRawOptions = {
|
|
|
3093
3093
|
metadata?: Record<string, unknown>;
|
|
3094
3094
|
timeout?: number;
|
|
3095
3095
|
maxRetries?: number;
|
|
3096
|
+
/** Reuse this stable key to recover or retry an ambiguous execution. */
|
|
3097
|
+
idempotencyKey?: string;
|
|
3098
|
+
/** Generate a key and enable recoverable execution before dispatch. */
|
|
3099
|
+
recover?: boolean;
|
|
3100
|
+
/** Called and awaited with the key before the first network request. */
|
|
3101
|
+
onExecution?: (execution: {
|
|
3102
|
+
idempotencyKey: string;
|
|
3103
|
+
}) => void | Promise<void>;
|
|
3104
|
+
/** Maximum time to reconnect to an in-progress keyed execution. Defaults to 15 minutes. */
|
|
3105
|
+
recoveryTimeoutMs?: number;
|
|
3106
|
+
};
|
|
3107
|
+
/** Durable state returned for a keyed tool execution. */
|
|
3108
|
+
type ExecutionRecovery = {
|
|
3109
|
+
/** Stable caller key used to resume or replay this execution. */
|
|
3110
|
+
idempotencyKey: string;
|
|
3111
|
+
/** Whether the execution is still running, completed, or has an unknown provider outcome. */
|
|
3112
|
+
state: 'running' | 'completed' | 'outcome_unknown';
|
|
3113
|
+
/** Whether this response came from an existing durable execution. */
|
|
3114
|
+
replayed: boolean;
|
|
3115
|
+
/** ISO timestamp after which the completed execution can no longer be replayed. */
|
|
3116
|
+
expiresAt?: string;
|
|
3117
|
+
};
|
|
3118
|
+
/** Durable lookup result for a keyed tool execution. */
|
|
3119
|
+
type ExecutionByKeyResult = {
|
|
3120
|
+
/** Recovery state and the key that owns the execution. */
|
|
3121
|
+
executionRecovery: ExecutionRecovery;
|
|
3122
|
+
/** Provider tool associated with the execution. */
|
|
3123
|
+
toolId: string;
|
|
3124
|
+
/** Original server-owned billing request ID, allocated before provider dispatch. */
|
|
3125
|
+
requestId?: string;
|
|
3126
|
+
/** HTTP status saved with the original response, when it was terminal. */
|
|
3127
|
+
responseStatus?: number;
|
|
3128
|
+
/** Saved execution response, when one is available for replay. */
|
|
3129
|
+
response?: unknown;
|
|
3096
3130
|
};
|
|
3097
3131
|
/**
|
|
3098
3132
|
* Standard provider/tool execution envelope returned by low-level SDK calls.
|
|
@@ -4521,6 +4555,13 @@ declare class DeeplineClient {
|
|
|
4521
4555
|
* Deepline execution envelope.
|
|
4522
4556
|
*/
|
|
4523
4557
|
executeTool<TData = unknown, TMeta = Record<string, unknown>>(toolId: string, input: Record<string, unknown>, options?: ExecuteToolRawOptions): Promise<ToolExecution<TData, TMeta>>;
|
|
4558
|
+
/** Read the durable state of a keyed tool execution. */
|
|
4559
|
+
getExecutionByKey(idempotencyKey: string): Promise<ExecutionByKeyResult>;
|
|
4560
|
+
private lookupExecutionByKey;
|
|
4561
|
+
/** Public recovery namespace. */
|
|
4562
|
+
get executions(): {
|
|
4563
|
+
getByKey: (key: string) => Promise<ExecutionByKeyResult>;
|
|
4564
|
+
};
|
|
4524
4565
|
/**
|
|
4525
4566
|
* Back-compatible alias for {@link executeTool}.
|
|
4526
4567
|
*
|
|
@@ -5970,7 +6011,23 @@ type DeeplineToolsNamespace = {
|
|
|
5970
6011
|
* For durable play code, prefer `ctx.tools.execute(...)` because the play
|
|
5971
6012
|
* runtime records the call under a stable id.
|
|
5972
6013
|
*/
|
|
5973
|
-
execute(toolId: string, input: Record<string, unknown
|
|
6014
|
+
execute(toolId: string, input: Record<string, unknown>, options?: {
|
|
6015
|
+
idempotencyKey?: string;
|
|
6016
|
+
recover?: boolean;
|
|
6017
|
+
onExecution?: (execution: {
|
|
6018
|
+
idempotencyKey: string;
|
|
6019
|
+
}) => void | Promise<void>;
|
|
6020
|
+
recoveryTimeoutMs?: number;
|
|
6021
|
+
}): Promise<DeeplineToolExecuteResult>;
|
|
6022
|
+
};
|
|
6023
|
+
type DeeplineToolExecuteResult = ToolExecuteResult & {
|
|
6024
|
+
/** Stable key used to recover this direct tool execution, when enabled. */
|
|
6025
|
+
idempotencyKey?: string;
|
|
6026
|
+
executionRecovery?: ExecutionRecovery;
|
|
6027
|
+
};
|
|
6028
|
+
type DeeplineExecutionsNamespace = {
|
|
6029
|
+
/** Look up a recoverable tool execution by its stable idempotency key. */
|
|
6030
|
+
getByKey(idempotencyKey: string): Promise<ExecutionByKeyResult>;
|
|
5974
6031
|
};
|
|
5975
6032
|
/**
|
|
5976
6033
|
* Named-play discovery and handle operations from a connected {@link DeeplineContext}.
|
|
@@ -6099,6 +6156,8 @@ declare class DeeplineContext {
|
|
|
6099
6156
|
* ```
|
|
6100
6157
|
*/
|
|
6101
6158
|
get tools(): DeeplineToolsNamespace;
|
|
6159
|
+
/** Durable state for recoverable direct tool executions. */
|
|
6160
|
+
get executions(): DeeplineExecutionsNamespace;
|
|
6102
6161
|
/**
|
|
6103
6162
|
* Play discovery and named-play handles.
|
|
6104
6163
|
*
|
|
@@ -6592,4 +6651,4 @@ declare function writeCsvOutputFile(rows: Array<Record<string, unknown>>, stem:
|
|
|
6592
6651
|
*/
|
|
6593
6652
|
declare function extractSummaryFields(payload: unknown): Record<string, Scalar>;
|
|
6594
6653
|
|
|
6595
|
-
export { type AsyncPlayRunRef, AuthError, type BillingCreditPool, type BillingInvoiceEntry, type BillingInvoicesResult, type BillingNamespace, type BillingPaymentMethodSummary, type BillingSubscriptionCancelResult, type BillingSubscriptionStatus, type BillingTopUpResult, type BillingUsageEvent, type ClearPlayHistoryRequest, type ClearPlayHistoryResult, type ColumnMap, type ColumnResolver, type ConditionalStepResolver, ConfigError, type CreateNotificationGroupInput, type CreateNotificationGroupResult, type CsvInput, type CsvOptions, type CustomerDbQueryResult, DEEPLINE_TOOL_CATEGORIES, type DatasetBuilder, type DatasetColumnDefinition, type DatasetColumnRunInput, type DbNamespace, Deepline, DeeplineClient, type DeeplineClientOptions, DeeplineContext, DeeplineError, type DeeplineNamedPlay, type DeeplinePlayRuntimeContext, type DeeplinePlaysNamespace, type DeeplineToolCategory, type DeeplineToolsNamespace, type DefinePlayConfig, type DefinedPlay, type FetchOptions, type FileInput, type IngestionStorageRepairResult, type LegacyMonitorStatusFilter, type LiveEventEnvelope, MONITOR_JOB_PHASES, MONITOR_JOB_RECONCILIATION_STATES, MONITOR_JOB_STATES, type MonitorBatchNamespace, type MonitorCheckResult, type MonitorDefinition, type MonitorDeleteResult, type MonitorDependents, type MonitorDeployResult, type MonitorDetail, type MonitorFleetDeactivateOptions, MonitorFleetDefinition, type MonitorFleetGetOptions, type MonitorFleetReactivateOptions, type MonitorFleetResult, type MonitorFleetStatus, type MonitorFleetSyncOptions, type MonitorFleetWaitOptions, type MonitorFleetsNamespace, type MonitorJobDeployOptions, type MonitorJobLogsOptions, type MonitorJobPhase, type MonitorJobReconciliationState, type MonitorJobResult, type MonitorJobState, type MonitorJobWaitOptions, type MonitorJobsNamespace, type MonitorListEntry, type MonitorPayload, type MonitorReactivateResult, type MonitorSpec, type MonitorState, type MonitorStateFilter, type MonitorUpdateChangeSummary, type MonitorUpdateResult, type MonitorsAccessStatus, type MonitorsAvailableOptions, type MonitorsAvailableResult, type MonitorsListOptions, type MonitorsListResult, type MonitorsNamespace, PLAY_BOOTSTRAP_COMPANY_FIELDS, PLAY_BOOTSTRAP_COMPANY_PROVIDER_CATEGORY, PLAY_BOOTSTRAP_CONTACT_FIELDS, PLAY_BOOTSTRAP_FINDER_KINDS, PLAY_BOOTSTRAP_OUTPUT_FIELD_BY_FINDER, PLAY_BOOTSTRAP_PEOPLE_PROVIDER_CATEGORY, PLAY_BOOTSTRAP_PROVIDER_CATEGORY_BY_FINDER, PLAY_BOOTSTRAP_SOURCE_KINDS, PLAY_BOOTSTRAP_STAGE_KINDS, PLAY_BOOTSTRAP_TEMPLATES, PROD_URL, type PlayActivityObservation, type PlayActivityState, type PlayActivityTarget, type PlayAsyncCallOptions, type PlayBindings, type PlayBootstrapEntityKind, type PlayBootstrapFinderKind, type PlayCallExecution, type PlayCallOptions, type PlayCostEstimate, type PlayFetchResponse, type PlayInputContract, type PlayJob, type PlayListItem, type PlayLiveEvent, type PlayReferenceLike, type PlayRevisionSummary, type PlayRunActionPackage, type PlayRunActivityProjection, type PlayRunDatasetActions, type PlayRunId, type PlayRunPackage, type PlayRunResult, type PlayRunStart, type PlaySheetRow, type PlaySheetRowsResult, type PlayStatus, type PlayStepProgramStep, type PlaysListOptions, type PlaysListPage, type PrebuiltPlayRef, type PublishPlayVersionRequest, type PublishPlayVersionResult, RateLimitError, type RerunOptions, type RerunPlayRunResult, type ResolvedConfig, RunObserveTransportUnavailableError, type RunsListOptions, type RunsListPage, type RunsLogsOptions, type RunsLogsResult, type RunsNamespace, type RunsTailOptions, type RuntimeStepOptions, SDK_API_CONTRACT, SDK_VERSION, type SqlListenerDeclaration, type SqlListenerEvent, type SqlListenerOperation, type SqlQuery, type StartPlayRunRequest, type StepOptions, type StepProgram, type StepProgramResolver, type StepResolver, type StopAllCandidate, type StopAllPlayRunsDryRunResult, type StopAllPlayRunsResult, type StopAllPlayRunsStopResult, type StopAllRunsOptions, type StopPlayRunResult, type ToolDefinition, ToolExecuteResult, type ToolExecution, ToolExecutionError, ToolExecutionErrorOptions, type ToolExecutionRequest, type ToolMetadata, ToolRateLimitError, ToolResultBilling, type ToolSearchOptions, type ToolSearchResult, type WorkspaceCreateResult, type WorkspacesNamespace, defineInput, defineMonitor, definePlay, defineWorkflow, extractSummaryFields, formatPlayBootstrapFinderKinds, formatPlayBootstrapFinderKindsForSentence, formatPlayBootstrapTemplates, getDefinedPlayMetadata, isPlayBootstrapFinderKind, isPlayBootstrapTemplate, isStopAllPlayRunsDryRunResult, resolveConfig, runIf, steps, tryConvertToList, writeCsvOutputFile, writeJsonOutputFile };
|
|
6654
|
+
export { type AsyncPlayRunRef, AuthError, type BillingCreditPool, type BillingInvoiceEntry, type BillingInvoicesResult, type BillingNamespace, type BillingPaymentMethodSummary, type BillingSubscriptionCancelResult, type BillingSubscriptionStatus, type BillingTopUpResult, type BillingUsageEvent, type ClearPlayHistoryRequest, type ClearPlayHistoryResult, type ColumnMap, type ColumnResolver, type ConditionalStepResolver, ConfigError, type CreateNotificationGroupInput, type CreateNotificationGroupResult, type CsvInput, type CsvOptions, type CustomerDbQueryResult, DEEPLINE_TOOL_CATEGORIES, type DatasetBuilder, type DatasetColumnDefinition, type DatasetColumnRunInput, type DbNamespace, Deepline, DeeplineClient, type DeeplineClientOptions, DeeplineContext, DeeplineError, type DeeplineExecutionsNamespace, type DeeplineNamedPlay, type DeeplinePlayRuntimeContext, type DeeplinePlaysNamespace, type DeeplineToolCategory, type DeeplineToolExecuteResult, type DeeplineToolsNamespace, type DefinePlayConfig, type DefinedPlay, type ExecutionByKeyResult, type ExecutionRecovery, type FetchOptions, type FileInput, type IngestionStorageRepairResult, type LegacyMonitorStatusFilter, type LiveEventEnvelope, MONITOR_JOB_PHASES, MONITOR_JOB_RECONCILIATION_STATES, MONITOR_JOB_STATES, type MonitorBatchNamespace, type MonitorCheckResult, type MonitorDefinition, type MonitorDeleteResult, type MonitorDependents, type MonitorDeployResult, type MonitorDetail, type MonitorFleetDeactivateOptions, MonitorFleetDefinition, type MonitorFleetGetOptions, type MonitorFleetReactivateOptions, type MonitorFleetResult, type MonitorFleetStatus, type MonitorFleetSyncOptions, type MonitorFleetWaitOptions, type MonitorFleetsNamespace, type MonitorJobDeployOptions, type MonitorJobLogsOptions, type MonitorJobPhase, type MonitorJobReconciliationState, type MonitorJobResult, type MonitorJobState, type MonitorJobWaitOptions, type MonitorJobsNamespace, type MonitorListEntry, type MonitorPayload, type MonitorReactivateResult, type MonitorSpec, type MonitorState, type MonitorStateFilter, type MonitorUpdateChangeSummary, type MonitorUpdateResult, type MonitorsAccessStatus, type MonitorsAvailableOptions, type MonitorsAvailableResult, type MonitorsListOptions, type MonitorsListResult, type MonitorsNamespace, PLAY_BOOTSTRAP_COMPANY_FIELDS, PLAY_BOOTSTRAP_COMPANY_PROVIDER_CATEGORY, PLAY_BOOTSTRAP_CONTACT_FIELDS, PLAY_BOOTSTRAP_FINDER_KINDS, PLAY_BOOTSTRAP_OUTPUT_FIELD_BY_FINDER, PLAY_BOOTSTRAP_PEOPLE_PROVIDER_CATEGORY, PLAY_BOOTSTRAP_PROVIDER_CATEGORY_BY_FINDER, PLAY_BOOTSTRAP_SOURCE_KINDS, PLAY_BOOTSTRAP_STAGE_KINDS, PLAY_BOOTSTRAP_TEMPLATES, PROD_URL, type PlayActivityObservation, type PlayActivityState, type PlayActivityTarget, type PlayAsyncCallOptions, type PlayBindings, type PlayBootstrapEntityKind, type PlayBootstrapFinderKind, type PlayCallExecution, type PlayCallOptions, type PlayCostEstimate, type PlayFetchResponse, type PlayInputContract, type PlayJob, type PlayListItem, type PlayLiveEvent, type PlayReferenceLike, type PlayRevisionSummary, type PlayRunActionPackage, type PlayRunActivityProjection, type PlayRunDatasetActions, type PlayRunId, type PlayRunPackage, type PlayRunResult, type PlayRunStart, type PlaySheetRow, type PlaySheetRowsResult, type PlayStatus, type PlayStepProgramStep, type PlaysListOptions, type PlaysListPage, type PrebuiltPlayRef, type PublishPlayVersionRequest, type PublishPlayVersionResult, RateLimitError, type RerunOptions, type RerunPlayRunResult, type ResolvedConfig, RunObserveTransportUnavailableError, type RunsListOptions, type RunsListPage, type RunsLogsOptions, type RunsLogsResult, type RunsNamespace, type RunsTailOptions, type RuntimeStepOptions, SDK_API_CONTRACT, SDK_VERSION, type SqlListenerDeclaration, type SqlListenerEvent, type SqlListenerOperation, type SqlQuery, type StartPlayRunRequest, type StepOptions, type StepProgram, type StepProgramResolver, type StepResolver, type StopAllCandidate, type StopAllPlayRunsDryRunResult, type StopAllPlayRunsResult, type StopAllPlayRunsStopResult, type StopAllRunsOptions, type StopPlayRunResult, type ToolDefinition, ToolExecuteResult, type ToolExecution, ToolExecutionError, ToolExecutionErrorOptions, type ToolExecutionRequest, type ToolMetadata, ToolRateLimitError, ToolResultBilling, type ToolSearchOptions, type ToolSearchResult, type WorkspaceCreateResult, type WorkspacesNamespace, defineInput, defineMonitor, definePlay, defineWorkflow, extractSummaryFields, formatPlayBootstrapFinderKinds, formatPlayBootstrapFinderKindsForSentence, formatPlayBootstrapTemplates, getDefinedPlayMetadata, isPlayBootstrapFinderKind, isPlayBootstrapTemplate, isStopAllPlayRunsDryRunResult, resolveConfig, runIf, steps, tryConvertToList, writeCsvOutputFile, writeJsonOutputFile };
|
package/dist/index.js
CHANGED
|
@@ -864,7 +864,7 @@ var SDK_RELEASE = {
|
|
|
864
864
|
// getters keep their established compatibility behavior.
|
|
865
865
|
// 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
|
|
866
866
|
// 0.3.90 is the first deliberately versioned SDK release for API v3.
|
|
867
|
-
version: "0.3.
|
|
867
|
+
version: "0.3.151",
|
|
868
868
|
updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
|
|
869
869
|
packageCapabilities: {
|
|
870
870
|
updatePreferences: 1
|
|
@@ -1605,6 +1605,11 @@ var HttpClient = class {
|
|
|
1605
1605
|
body: options?.formData !== void 0 ? typeof options.formData === "function" ? options.formData() : options.formData : options?.body !== void 0 ? JSON.stringify(options.body) : void 0,
|
|
1606
1606
|
signal: controller.signal
|
|
1607
1607
|
});
|
|
1608
|
+
options?.onResponse?.(response);
|
|
1609
|
+
if (response.status === 404 && options?.allowNotFound) {
|
|
1610
|
+
clearTimeout(timeoutId);
|
|
1611
|
+
return null;
|
|
1612
|
+
}
|
|
1608
1613
|
clearTimeout(timeoutId);
|
|
1609
1614
|
const body = await response.text();
|
|
1610
1615
|
const parsed = parseResponseBody(body);
|
|
@@ -1744,7 +1749,8 @@ var HttpClient = class {
|
|
|
1744
1749
|
retryAfterMs: null,
|
|
1745
1750
|
networkKind: code === "NETWORK_TIMEOUT" ? "timeout" : code === "NETWORK_ABORTED" ? "unknown" : "unavailable",
|
|
1746
1751
|
networkScope: "client_to_deepline",
|
|
1747
|
-
details: mappedNetworkError.details
|
|
1752
|
+
details: mappedNetworkError.details,
|
|
1753
|
+
publicDetails: options.idempotencyKey ? { idempotencyKey: options.idempotencyKey } : null
|
|
1748
1754
|
}
|
|
1749
1755
|
),
|
|
1750
1756
|
lastError
|
|
@@ -4223,6 +4229,56 @@ var MONITOR_NON_RETRYABLE_MUTATION_OPTIONS = {
|
|
|
4223
4229
|
exactUrlOnly: true
|
|
4224
4230
|
};
|
|
4225
4231
|
var RAW_V2_EXECUTE_RESPONSE_CONTRACT = RAW_V2_TOOL_RESPONSE_CONTRACT;
|
|
4232
|
+
var DEFAULT_EXECUTION_RECOVERY_TIMEOUT_MS = 15 * 60 * 1e3;
|
|
4233
|
+
function validateExecutionIdempotencyKey(key) {
|
|
4234
|
+
if (typeof key !== "string" || key.length < 1 || key.length > 200 || !/^[A-Za-z0-9._:-]+$/.test(key)) {
|
|
4235
|
+
throw new DeeplineError(
|
|
4236
|
+
"Execution idempotency keys must be 1\u2013200 ASCII letters, digits, dots, underscores, colons, or hyphens.",
|
|
4237
|
+
void 0,
|
|
4238
|
+
"IDEMPOTENCY_KEY_INVALID"
|
|
4239
|
+
);
|
|
4240
|
+
}
|
|
4241
|
+
}
|
|
4242
|
+
function isExecutionInProgressResponse(value) {
|
|
4243
|
+
return typeof value === "object" && value !== null && typeof value.executionRecovery === "object" && value.executionRecovery.state === "running";
|
|
4244
|
+
}
|
|
4245
|
+
function getExecutionRecoveryState(value) {
|
|
4246
|
+
if (typeof value !== "object" || value === null || typeof value.executionRecovery !== "object") {
|
|
4247
|
+
return null;
|
|
4248
|
+
}
|
|
4249
|
+
const state = value.executionRecovery.state;
|
|
4250
|
+
return state === "running" || state === "completed" || state === "outcome_unknown" ? state : null;
|
|
4251
|
+
}
|
|
4252
|
+
function isRecoverableExecutionAttemptError(error) {
|
|
4253
|
+
if (error instanceof ToolExecutionError) {
|
|
4254
|
+
return error.code === "EXECUTION_IN_PROGRESS" || error.origin === "deepline" && error.category === "network" && error.networkScope === "client_to_deepline";
|
|
4255
|
+
}
|
|
4256
|
+
return error instanceof DeeplineError && (error.code === "EXECUTION_IN_PROGRESS" || error.code?.startsWith("NETWORK_") === true && error.statusCode === void 0);
|
|
4257
|
+
}
|
|
4258
|
+
function isRecoverableExecutionLookupError(error) {
|
|
4259
|
+
if (isRecoverableExecutionAttemptError(error)) return true;
|
|
4260
|
+
return error instanceof DeeplineError && (error.statusCode === 429 || error.statusCode !== void 0 && error.statusCode >= 500);
|
|
4261
|
+
}
|
|
4262
|
+
function timeoutWithinRecoveryBudget(requestTimeoutMs, defaultRequestTimeoutMs, remainingMs) {
|
|
4263
|
+
return Math.min(requestTimeoutMs ?? defaultRequestTimeoutMs, remainingMs);
|
|
4264
|
+
}
|
|
4265
|
+
function executionRecoveryError(input) {
|
|
4266
|
+
return new ToolExecutionError(input.message, {
|
|
4267
|
+
toolId: input.toolId,
|
|
4268
|
+
provider: null,
|
|
4269
|
+
operation: input.toolId,
|
|
4270
|
+
code: input.code,
|
|
4271
|
+
origin: "deepline",
|
|
4272
|
+
category: input.code === "EXECUTION_OUTCOME_UNKNOWN" ? "unknown" : "conflict",
|
|
4273
|
+
retryable: input.code !== "EXECUTION_OUTCOME_UNKNOWN",
|
|
4274
|
+
statusCode: null,
|
|
4275
|
+
requestId: null,
|
|
4276
|
+
retryAfterMs: null,
|
|
4277
|
+
networkKind: null,
|
|
4278
|
+
networkScope: null,
|
|
4279
|
+
publicDetails: { idempotencyKey: input.idempotencyKey }
|
|
4280
|
+
});
|
|
4281
|
+
}
|
|
4226
4282
|
var COMPILE_MANIFEST_RETRY_DELAYS_MS = [250, 1e3];
|
|
4227
4283
|
var REGISTER_PLAY_ARTIFACTS_COMPILE_CONCURRENCY = 3;
|
|
4228
4284
|
var REGISTER_PLAY_ARTIFACTS_MAX_BATCH_COUNT = 3;
|
|
@@ -5157,29 +5213,183 @@ var DeeplineClient = class _DeeplineClient {
|
|
|
5157
5213
|
* Deepline execution envelope.
|
|
5158
5214
|
*/
|
|
5159
5215
|
async executeTool(toolId, input, options) {
|
|
5216
|
+
const inputSnapshot = JSON.parse(JSON.stringify(input));
|
|
5217
|
+
const metadataSnapshot = options?.metadata ? JSON.parse(JSON.stringify(options.metadata)) : void 0;
|
|
5218
|
+
const idempotencyKey = options?.idempotencyKey ?? (options?.recover ? crypto.randomUUID() : void 0);
|
|
5219
|
+
if (idempotencyKey !== void 0) {
|
|
5220
|
+
validateExecutionIdempotencyKey(idempotencyKey);
|
|
5221
|
+
if (options?.recoveryTimeoutMs !== void 0 && (!Number.isFinite(options.recoveryTimeoutMs) || options.recoveryTimeoutMs < 0)) {
|
|
5222
|
+
throw new DeeplineError(
|
|
5223
|
+
"recoveryTimeoutMs must be a finite, non-negative number.",
|
|
5224
|
+
void 0,
|
|
5225
|
+
"IDEMPOTENCY_KEY_INVALID"
|
|
5226
|
+
);
|
|
5227
|
+
}
|
|
5228
|
+
await options?.onExecution?.({ idempotencyKey });
|
|
5229
|
+
const timeoutMs2 = options?.timeout ?? resolveToolExecuteTimeoutMs(toolId, inputSnapshot);
|
|
5230
|
+
await this.lookupExecutionByKey(idempotencyKey, timeoutMs2);
|
|
5231
|
+
}
|
|
5232
|
+
const timeoutMs = options?.timeout ?? resolveToolExecuteTimeoutMs(toolId, inputSnapshot);
|
|
5160
5233
|
const headers = {
|
|
5161
5234
|
[EXECUTE_RESPONSE_CONTRACT_HEADER]: RAW_V2_EXECUTE_RESPONSE_CONTRACT,
|
|
5162
5235
|
[TOOL_EXECUTION_ERROR_SCHEMA_HEADER]: String(
|
|
5163
5236
|
TOOL_EXECUTION_ERROR_SCHEMA_VERSION
|
|
5164
5237
|
),
|
|
5165
5238
|
...options?.includeToolMetadata ? { [INCLUDE_TOOL_METADATA_HEADER]: "true" } : {},
|
|
5166
|
-
[EXECUTE_RESPONSE_INTENT_HEADER]: options?.responseIntent ?? "raw"
|
|
5239
|
+
[EXECUTE_RESPONSE_INTENT_HEADER]: options?.responseIntent ?? "raw",
|
|
5240
|
+
...idempotencyKey ? { "Idempotency-Key": idempotencyKey } : {}
|
|
5167
5241
|
};
|
|
5168
|
-
const
|
|
5242
|
+
const request = (requestTimeoutMs) => this.http.post(
|
|
5169
5243
|
`/api/v2/integrations/${encodeURIComponent(toolId)}/execute`,
|
|
5170
5244
|
{
|
|
5171
|
-
payload:
|
|
5172
|
-
...
|
|
5245
|
+
payload: inputSnapshot,
|
|
5246
|
+
...metadataSnapshot ? { metadata: metadataSnapshot } : {}
|
|
5173
5247
|
},
|
|
5174
5248
|
headers,
|
|
5175
5249
|
{
|
|
5176
|
-
timeout:
|
|
5177
|
-
maxRetries: options?.maxRetries ?? 0,
|
|
5250
|
+
timeout: requestTimeoutMs,
|
|
5251
|
+
maxRetries: idempotencyKey ? 0 : options?.maxRetries ?? 0,
|
|
5252
|
+
exactUrlOnly: true,
|
|
5253
|
+
toolId,
|
|
5254
|
+
idempotencyKey
|
|
5255
|
+
}
|
|
5256
|
+
);
|
|
5257
|
+
let response;
|
|
5258
|
+
let recoveryDeadline = null;
|
|
5259
|
+
const recoveryTimeoutMs = options?.recoveryTimeoutMs ?? DEFAULT_EXECUTION_RECOVERY_TIMEOUT_MS;
|
|
5260
|
+
let retryDelayMs = 1e3;
|
|
5261
|
+
const recoveryTimeoutError = () => executionRecoveryError({
|
|
5262
|
+
toolId,
|
|
5263
|
+
idempotencyKey,
|
|
5264
|
+
code: "EXECUTION_RECOVERY_TIMEOUT",
|
|
5265
|
+
message: `Execution recovery for ${idempotencyKey} did not finish before the recovery timeout. Inspect client.executions.getByKey() and resume with the same idempotency key.`
|
|
5266
|
+
});
|
|
5267
|
+
const waitForRecoveryRetry = async (deadline) => {
|
|
5268
|
+
const remainingMs = deadline - Date.now();
|
|
5269
|
+
if (remainingMs <= 0) throw recoveryTimeoutError();
|
|
5270
|
+
await new Promise(
|
|
5271
|
+
(resolve2) => setTimeout(resolve2, Math.min(retryDelayMs, remainingMs))
|
|
5272
|
+
);
|
|
5273
|
+
retryDelayMs = Math.min(retryDelayMs * 2, 5e3);
|
|
5274
|
+
};
|
|
5275
|
+
const lookupDuringRecovery = async () => {
|
|
5276
|
+
while (true) {
|
|
5277
|
+
const remainingMs = recoveryDeadline - Date.now();
|
|
5278
|
+
if (remainingMs <= 0) throw recoveryTimeoutError();
|
|
5279
|
+
try {
|
|
5280
|
+
return await this.lookupExecutionByKey(
|
|
5281
|
+
idempotencyKey,
|
|
5282
|
+
timeoutWithinRecoveryBudget(
|
|
5283
|
+
timeoutMs,
|
|
5284
|
+
this.config.timeout,
|
|
5285
|
+
remainingMs
|
|
5286
|
+
)
|
|
5287
|
+
);
|
|
5288
|
+
} catch (error) {
|
|
5289
|
+
if (!isRecoverableExecutionLookupError(error)) throw error;
|
|
5290
|
+
await waitForRecoveryRetry(recoveryDeadline);
|
|
5291
|
+
}
|
|
5292
|
+
}
|
|
5293
|
+
};
|
|
5294
|
+
while (true) {
|
|
5295
|
+
const remainingMs = recoveryDeadline === null ? null : recoveryDeadline - Date.now();
|
|
5296
|
+
if (remainingMs !== null && remainingMs <= 0) {
|
|
5297
|
+
throw recoveryTimeoutError();
|
|
5298
|
+
}
|
|
5299
|
+
try {
|
|
5300
|
+
response = await request(
|
|
5301
|
+
remainingMs === null ? timeoutMs : timeoutWithinRecoveryBudget(
|
|
5302
|
+
timeoutMs,
|
|
5303
|
+
this.config.timeout,
|
|
5304
|
+
remainingMs
|
|
5305
|
+
)
|
|
5306
|
+
);
|
|
5307
|
+
if (getExecutionRecoveryState(response) === "outcome_unknown") {
|
|
5308
|
+
if (!idempotencyKey) break;
|
|
5309
|
+
throw executionRecoveryError({
|
|
5310
|
+
toolId,
|
|
5311
|
+
idempotencyKey,
|
|
5312
|
+
code: "EXECUTION_OUTCOME_UNKNOWN",
|
|
5313
|
+
message: `The outcome of execution ${idempotencyKey} is unknown. Do not retry with a new key; inspect client.executions.getByKey().`
|
|
5314
|
+
});
|
|
5315
|
+
}
|
|
5316
|
+
if (!idempotencyKey || !isExecutionInProgressResponse(response)) {
|
|
5317
|
+
break;
|
|
5318
|
+
}
|
|
5319
|
+
if (recoveryDeadline === null) {
|
|
5320
|
+
recoveryDeadline = Date.now() + recoveryTimeoutMs;
|
|
5321
|
+
}
|
|
5322
|
+
} catch (error) {
|
|
5323
|
+
if (idempotencyKey && error instanceof DeeplineError && error.code === "EXECUTION_OUTCOME_UNKNOWN") {
|
|
5324
|
+
throw executionRecoveryError({
|
|
5325
|
+
toolId,
|
|
5326
|
+
idempotencyKey,
|
|
5327
|
+
code: "EXECUTION_OUTCOME_UNKNOWN",
|
|
5328
|
+
message: error.message
|
|
5329
|
+
});
|
|
5330
|
+
}
|
|
5331
|
+
if (!idempotencyKey || !isRecoverableExecutionAttemptError(error)) {
|
|
5332
|
+
throw error;
|
|
5333
|
+
}
|
|
5334
|
+
if (recoveryDeadline === null) {
|
|
5335
|
+
recoveryDeadline = Date.now() + recoveryTimeoutMs;
|
|
5336
|
+
}
|
|
5337
|
+
}
|
|
5338
|
+
await waitForRecoveryRetry(recoveryDeadline);
|
|
5339
|
+
const recovered = await lookupDuringRecovery();
|
|
5340
|
+
if (getExecutionRecoveryState(recovered) === "outcome_unknown") {
|
|
5341
|
+
throw executionRecoveryError({
|
|
5342
|
+
toolId,
|
|
5343
|
+
idempotencyKey,
|
|
5344
|
+
code: "EXECUTION_OUTCOME_UNKNOWN",
|
|
5345
|
+
message: `The outcome of execution ${idempotencyKey} is unknown. Do not retry with a new key; inspect client.executions.getByKey().`
|
|
5346
|
+
});
|
|
5347
|
+
}
|
|
5348
|
+
}
|
|
5349
|
+
const materialized = materializeToolExecutionResponse(response);
|
|
5350
|
+
return idempotencyKey ? { ...materialized, idempotencyKey } : materialized;
|
|
5351
|
+
}
|
|
5352
|
+
/** Read the durable state of a keyed tool execution. */
|
|
5353
|
+
async getExecutionByKey(idempotencyKey) {
|
|
5354
|
+
validateExecutionIdempotencyKey(idempotencyKey);
|
|
5355
|
+
const result = await this.lookupExecutionByKey(idempotencyKey);
|
|
5356
|
+
if (!result) {
|
|
5357
|
+
throw new DeeplineError(
|
|
5358
|
+
`No execution exists for idempotency key ${idempotencyKey}.`,
|
|
5359
|
+
404,
|
|
5360
|
+
"EXECUTION_NOT_FOUND"
|
|
5361
|
+
);
|
|
5362
|
+
}
|
|
5363
|
+
return result;
|
|
5364
|
+
}
|
|
5365
|
+
async lookupExecutionByKey(idempotencyKey, timeoutMs) {
|
|
5366
|
+
validateExecutionIdempotencyKey(idempotencyKey);
|
|
5367
|
+
let supported = false;
|
|
5368
|
+
const result = await this.http.get(
|
|
5369
|
+
`/api/v2/executions/by-key/${encodeURIComponent(idempotencyKey)}`,
|
|
5370
|
+
{
|
|
5178
5371
|
exactUrlOnly: true,
|
|
5179
|
-
|
|
5372
|
+
maxRetries: 0,
|
|
5373
|
+
timeout: timeoutMs,
|
|
5374
|
+
idempotencyKey,
|
|
5375
|
+
allowNotFound: true,
|
|
5376
|
+
onResponse: (response) => {
|
|
5377
|
+
supported = response.headers.get("X-Deepline-Idempotency-Supported") === "true";
|
|
5378
|
+
}
|
|
5180
5379
|
}
|
|
5181
5380
|
);
|
|
5182
|
-
|
|
5381
|
+
if (!supported) {
|
|
5382
|
+
throw new DeeplineError(
|
|
5383
|
+
"This Deepline server does not support recoverable tool executions; no tool was dispatched.",
|
|
5384
|
+
422,
|
|
5385
|
+
"IDEMPOTENCY_NOT_SUPPORTED"
|
|
5386
|
+
);
|
|
5387
|
+
}
|
|
5388
|
+
return result;
|
|
5389
|
+
}
|
|
5390
|
+
/** Public recovery namespace. */
|
|
5391
|
+
get executions() {
|
|
5392
|
+
return { getByKey: (key) => this.getExecutionByKey(key) };
|
|
5183
5393
|
}
|
|
5184
5394
|
/**
|
|
5185
5395
|
* Back-compatible alias for {@link executeTool}.
|
|
@@ -11266,10 +11476,11 @@ var DeeplineContext = class {
|
|
|
11266
11476
|
/** Get detailed metadata for a tool. */
|
|
11267
11477
|
get: (toolId) => this.client.getTool(toolId),
|
|
11268
11478
|
/** Execute a tool and return the standard execution envelope. */
|
|
11269
|
-
execute: async (toolId, input) => {
|
|
11479
|
+
execute: async (toolId, input, options) => {
|
|
11270
11480
|
const response = await this.client.executeTool(toolId, input, {
|
|
11271
11481
|
includeToolMetadata: true,
|
|
11272
|
-
responseIntent: "dataset"
|
|
11482
|
+
responseIntent: "dataset",
|
|
11483
|
+
...options
|
|
11273
11484
|
});
|
|
11274
11485
|
return toolExecutionEnvelopeToResult(toolId, response, {
|
|
11275
11486
|
client: this.client,
|
|
@@ -11278,6 +11489,10 @@ var DeeplineContext = class {
|
|
|
11278
11489
|
}
|
|
11279
11490
|
};
|
|
11280
11491
|
}
|
|
11492
|
+
/** Durable state for recoverable direct tool executions. */
|
|
11493
|
+
get executions() {
|
|
11494
|
+
return { getByKey: (key) => this.client.getExecutionByKey(key) };
|
|
11495
|
+
}
|
|
11281
11496
|
/**
|
|
11282
11497
|
* Play discovery and named-play handles.
|
|
11283
11498
|
*
|
|
@@ -11585,7 +11800,7 @@ function toolExecutionEnvelopeToResult(fallbackToolId, response, options) {
|
|
|
11585
11800
|
const meta = response.toolResponse?.meta;
|
|
11586
11801
|
const metadata = isRecord9(response._metadata) ? response._metadata.tool : null;
|
|
11587
11802
|
const toolMetadata = isRecord9(metadata) ? metadata : {};
|
|
11588
|
-
|
|
11803
|
+
const result = attachSdkQueryResultDatasetResult(
|
|
11589
11804
|
fallbackToolId,
|
|
11590
11805
|
createToolExecuteResult({
|
|
11591
11806
|
status: typeof response.status === "string" ? response.status : "completed",
|
|
@@ -11618,6 +11833,14 @@ function toolExecutionEnvelopeToResult(fallbackToolId, response, options) {
|
|
|
11618
11833
|
}),
|
|
11619
11834
|
options
|
|
11620
11835
|
);
|
|
11836
|
+
const executionRecovery = isRecord9(response.executionRecovery) ? response.executionRecovery : void 0;
|
|
11837
|
+
if (typeof response.idempotencyKey === "string") {
|
|
11838
|
+
result.idempotencyKey = response.idempotencyKey;
|
|
11839
|
+
}
|
|
11840
|
+
if (executionRecovery) {
|
|
11841
|
+
result.executionRecovery = executionRecovery;
|
|
11842
|
+
}
|
|
11843
|
+
return result;
|
|
11621
11844
|
}
|
|
11622
11845
|
function defineInput(schema) {
|
|
11623
11846
|
return createPlayInputContract(schema);
|