deepline 0.1.227 → 0.1.229
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/apps/play-runner-workers/src/coordinator-entry.ts +76 -1842
- package/dist/bundling-sources/apps/play-runner-workers/src/dedup-do.ts +0 -113
- package/dist/bundling-sources/apps/play-runner-workers/src/entry.ts +144 -1000
- package/dist/bundling-sources/apps/play-runner-workers/src/runtime/ledger-event-batches.ts +81 -0
- package/dist/bundling-sources/apps/play-runner-workers/src/workflow-retry-state.ts +1 -50
- package/dist/bundling-sources/sdk/src/client.ts +24 -2
- package/dist/bundling-sources/sdk/src/play.ts +2 -2
- package/dist/bundling-sources/sdk/src/release.ts +2 -2
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +382 -31
- package/dist/bundling-sources/shared_libs/play-runtime/child-execution-strategy.ts +84 -79
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +201 -705
- package/dist/bundling-sources/shared_libs/play-runtime/coordinator-headers.ts +3 -10
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-contract.ts +2 -2
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +12 -47
- package/dist/bundling-sources/shared_libs/play-runtime/governor/block-reserving-budget-state-backend.ts +0 -2
- package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +12 -200
- package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +2 -17
- package/dist/bundling-sources/shared_libs/play-runtime/live-state-contract.ts +3 -9
- package/dist/bundling-sources/shared_libs/play-runtime/play-call-execution.ts +6 -1
- package/dist/bundling-sources/shared_libs/play-runtime/play-latency-trace.ts +28 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-execution-scope.ts +16 -64
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +26 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-lifecycle-policy.ts +5 -2
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-paths.ts +0 -4
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +81 -18
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +0 -36
- package/dist/bundling-sources/shared_libs/play-runtime/suspension.ts +3 -21
- package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +9 -1
- package/dist/bundling-sources/shared_libs/play-runtime/transport-error-diagnostics.ts +63 -0
- package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +2 -0
- package/dist/cli/index.js +78 -11
- package/dist/cli/index.mjs +78 -11
- package/dist/{compiler-manifest-BhgZ23A4.d.ts → compiler-manifest-CYcwzSOJ.d.mts} +2 -0
- package/dist/{compiler-manifest-BhgZ23A4.d.mts → compiler-manifest-CYcwzSOJ.d.ts} +2 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +14 -5
- package/dist/index.mjs +14 -5
- package/dist/plays/bundle-play-file.d.mts +2 -2
- package/dist/plays/bundle-play-file.d.ts +2 -2
- package/package.json +1 -1
- package/dist/bundling-sources/apps/play-runner-workers/src/child-manifest-resolver.ts +0 -108
- package/dist/bundling-sources/apps/play-runner-workers/src/child-play-await.ts +0 -374
- package/dist/bundling-sources/apps/play-runner-workers/src/child-play-submit.ts +0 -203
- package/dist/bundling-sources/shared_libs/play-runtime/child-execution-placement.ts +0 -14
- package/dist/bundling-sources/shared_libs/play-runtime/child-run-id.ts +0 -121
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MAX_LEDGER_LOG_LINE_LENGTH,
|
|
3
|
+
MAX_LEDGER_LOG_LINES_PER_EVENT,
|
|
4
|
+
} from '../../../../shared_libs/play-runtime/ledger-safe-payload';
|
|
5
|
+
import type { PlayRunLedgerEvent } from '../../../../shared_libs/play-runtime/run-ledger';
|
|
6
|
+
|
|
7
|
+
/** Keep a Worker-to-runtime append comfortably below the API and Convex limits. */
|
|
8
|
+
export const WORKER_LEDGER_EVENT_BATCH_MAX_BYTES = 128 * 1024;
|
|
9
|
+
export const WORKER_LEDGER_EVENTS_PER_APPEND_MAX = 100;
|
|
10
|
+
|
|
11
|
+
const encoder = new TextEncoder();
|
|
12
|
+
|
|
13
|
+
function encodedJsonBytes(value: unknown): number {
|
|
14
|
+
return encoder.encode(JSON.stringify(value)).length;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function splitLogEvent(
|
|
18
|
+
event: Extract<PlayRunLedgerEvent, { type: 'log.appended' }>,
|
|
19
|
+
): PlayRunLedgerEvent[] {
|
|
20
|
+
const events: PlayRunLedgerEvent[] = [];
|
|
21
|
+
const lines = event.lines.map((line) =>
|
|
22
|
+
line.slice(0, MAX_LEDGER_LOG_LINE_LENGTH),
|
|
23
|
+
);
|
|
24
|
+
let start = 0;
|
|
25
|
+
while (start < lines.length) {
|
|
26
|
+
let end = start;
|
|
27
|
+
let bytes = encodedJsonBytes({ ...event, lines: [] });
|
|
28
|
+
while (end < lines.length && end - start < MAX_LEDGER_LOG_LINES_PER_EVENT) {
|
|
29
|
+
const lineBytes = encodedJsonBytes(lines[end]!);
|
|
30
|
+
if (
|
|
31
|
+
end > start &&
|
|
32
|
+
bytes + lineBytes + 1 > WORKER_LEDGER_EVENT_BATCH_MAX_BYTES
|
|
33
|
+
) {
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
bytes += lineBytes + 1;
|
|
37
|
+
end += 1;
|
|
38
|
+
}
|
|
39
|
+
events.push({
|
|
40
|
+
...event,
|
|
41
|
+
lines: lines.slice(start, end),
|
|
42
|
+
...(typeof event.channelOffset === 'number'
|
|
43
|
+
? { channelOffset: event.channelOffset + start }
|
|
44
|
+
: {}),
|
|
45
|
+
});
|
|
46
|
+
start = end;
|
|
47
|
+
}
|
|
48
|
+
return events;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Partition ledger delivery without dropping positional log lines. The worker
|
|
53
|
+
* retries only unacknowledged batches, so each batch must be independently
|
|
54
|
+
* valid for the app-runtime and Convex boundaries.
|
|
55
|
+
*/
|
|
56
|
+
export function partitionWorkerLedgerEvents(
|
|
57
|
+
events: readonly PlayRunLedgerEvent[],
|
|
58
|
+
): PlayRunLedgerEvent[][] {
|
|
59
|
+
const batches: PlayRunLedgerEvent[][] = [];
|
|
60
|
+
let batch: PlayRunLedgerEvent[] = [];
|
|
61
|
+
let batchBytes = 2;
|
|
62
|
+
|
|
63
|
+
for (const event of events.flatMap((event) =>
|
|
64
|
+
event.type === 'log.appended' ? splitLogEvent(event) : [event],
|
|
65
|
+
)) {
|
|
66
|
+
const eventBytes = encodedJsonBytes(event);
|
|
67
|
+
if (
|
|
68
|
+
batch.length > 0 &&
|
|
69
|
+
(batch.length >= WORKER_LEDGER_EVENTS_PER_APPEND_MAX ||
|
|
70
|
+
batchBytes + eventBytes + 1 > WORKER_LEDGER_EVENT_BATCH_MAX_BYTES)
|
|
71
|
+
) {
|
|
72
|
+
batches.push(batch);
|
|
73
|
+
batch = [];
|
|
74
|
+
batchBytes = 2;
|
|
75
|
+
}
|
|
76
|
+
batch.push(event);
|
|
77
|
+
batchBytes += eventBytes + 1;
|
|
78
|
+
}
|
|
79
|
+
if (batch.length > 0) batches.push(batch);
|
|
80
|
+
return batches;
|
|
81
|
+
}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import type { ExecutionPlan } from '../../../shared_libs/play-runtime/execution-plan';
|
|
2
|
-
import type {
|
|
3
|
-
PlayCallGovernanceSnapshot,
|
|
4
|
-
PlayRunInputPayload,
|
|
5
|
-
} from '../../../shared_libs/play-runtime/scheduler-backend';
|
|
2
|
+
import type { PlayRunInputPayload } from '../../../shared_libs/play-runtime/scheduler-backend';
|
|
6
3
|
import type { PreloadedRuntimeDbSession } from '../../../shared_libs/play-runtime/db-session';
|
|
7
|
-
import type {
|
|
8
|
-
PlayRuntimeManifest,
|
|
9
|
-
PlayRuntimeManifestMap,
|
|
10
|
-
} from '../../../shared_libs/plays/compiler-manifest';
|
|
11
4
|
|
|
12
5
|
import {
|
|
13
6
|
PLAY_SUBMIT_INPUT_INLINE_MAX_BYTES,
|
|
@@ -57,8 +50,6 @@ export type WorkflowRetryPlayParams = {
|
|
|
57
50
|
}> | null;
|
|
58
51
|
contractSnapshot?: unknown;
|
|
59
52
|
executionPlan?: ExecutionPlan | null;
|
|
60
|
-
childPlayManifests?: PlayRuntimeManifestMap | null;
|
|
61
|
-
playCallGovernance?: PlayCallGovernanceSnapshot | null;
|
|
62
53
|
preloadedDbSessions?: PreloadedRuntimeDbSession[] | null;
|
|
63
54
|
preloadedDbSessionRef?: {
|
|
64
55
|
runId: string;
|
|
@@ -100,7 +91,6 @@ export function buildWorkflowRetryParams<
|
|
|
100
91
|
...params,
|
|
101
92
|
dynamicWorkerCode: null,
|
|
102
93
|
contractSnapshot: stripRetrySourceSnapshot(params.contractSnapshot),
|
|
103
|
-
childPlayManifests: stripRetryChildManifestCode(params.childPlayManifests),
|
|
104
94
|
packagedFiles: stripRetryPackagedFiles(params.packagedFiles),
|
|
105
95
|
} satisfies WorkflowRetryPlayParams as TParams;
|
|
106
96
|
if (jsonByteLength(retryParams) <= WORKFLOW_RETRY_STATE_TARGET_BYTES) {
|
|
@@ -112,9 +102,6 @@ export function buildWorkflowRetryParams<
|
|
|
112
102
|
retryParams.contractSnapshot,
|
|
113
103
|
params,
|
|
114
104
|
),
|
|
115
|
-
childPlayManifests: stripRetryChildManifestToArtifact(
|
|
116
|
-
retryParams.childPlayManifests,
|
|
117
|
-
),
|
|
118
105
|
} satisfies WorkflowRetryPlayParams as TParams;
|
|
119
106
|
}
|
|
120
107
|
|
|
@@ -175,42 +162,6 @@ function stripRetryContractSnapshotToArtifact(
|
|
|
175
162
|
};
|
|
176
163
|
}
|
|
177
164
|
|
|
178
|
-
function stripRetryChildManifestCode(
|
|
179
|
-
manifests: PlayRuntimeManifestMap | null | undefined,
|
|
180
|
-
): PlayRuntimeManifestMap | null {
|
|
181
|
-
if (!manifests) return null;
|
|
182
|
-
const stripped: PlayRuntimeManifestMap = {};
|
|
183
|
-
for (const [key, manifest] of Object.entries(manifests)) {
|
|
184
|
-
const rest = { ...manifest };
|
|
185
|
-
delete rest.bundledCode;
|
|
186
|
-
delete rest.sourceCode;
|
|
187
|
-
delete (rest as Record<string, unknown>).sourceMap;
|
|
188
|
-
stripped[key] = rest;
|
|
189
|
-
}
|
|
190
|
-
return stripped;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function stripRetryChildManifestToArtifact(
|
|
194
|
-
manifests: PlayRuntimeManifestMap | null | undefined,
|
|
195
|
-
): PlayRuntimeManifestMap | null {
|
|
196
|
-
if (!manifests) return null;
|
|
197
|
-
const stripped: PlayRuntimeManifestMap = {};
|
|
198
|
-
for (const [key, manifest] of Object.entries(manifests)) {
|
|
199
|
-
stripped[key] = {
|
|
200
|
-
playName: manifest.playName,
|
|
201
|
-
graphHash: manifest.graphHash,
|
|
202
|
-
artifactStorageKey: manifest.artifactStorageKey,
|
|
203
|
-
artifactHash: manifest.artifactHash,
|
|
204
|
-
staticPipelineHash: manifest.staticPipelineHash,
|
|
205
|
-
staticPipeline: manifest.staticPipeline,
|
|
206
|
-
compiledAt: manifest.compiledAt,
|
|
207
|
-
compilerVersion: manifest.compilerVersion,
|
|
208
|
-
maxCreditsPerRun: manifest.maxCreditsPerRun,
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
return stripped;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
165
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
215
166
|
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
216
167
|
}
|
|
@@ -243,8 +243,30 @@ type ExecuteToolRawOptions = {
|
|
|
243
243
|
maxRetries?: number;
|
|
244
244
|
};
|
|
245
245
|
|
|
246
|
-
|
|
246
|
+
/**
|
|
247
|
+
* The server launches the Apify run, polls it for `payload.timeoutMs`, then
|
|
248
|
+
* reads its dataset before replying. Keep the client request alive through
|
|
249
|
+
* that final hand-off so a pollable run id is never lost to the SDK default
|
|
250
|
+
* timeout.
|
|
251
|
+
*/
|
|
252
|
+
const APIFY_SYNC_DEFAULT_TIMEOUT_MS = 300_000;
|
|
253
|
+
const APIFY_SYNC_RESPONSE_GRACE_MS = 90_000;
|
|
254
|
+
|
|
255
|
+
function resolveToolExecuteTimeoutMs(
|
|
256
|
+
toolId: string,
|
|
257
|
+
input: Record<string, unknown>,
|
|
258
|
+
): number | undefined {
|
|
247
259
|
const normalized = toolId.trim().toLowerCase();
|
|
260
|
+
if (normalized === 'apify_run_actor_sync') {
|
|
261
|
+
const requestedTimeoutMs = input.timeoutMs ?? APIFY_SYNC_DEFAULT_TIMEOUT_MS;
|
|
262
|
+
if (
|
|
263
|
+
typeof requestedTimeoutMs === 'number' &&
|
|
264
|
+
Number.isFinite(requestedTimeoutMs) &&
|
|
265
|
+
requestedTimeoutMs > 0
|
|
266
|
+
) {
|
|
267
|
+
return Math.floor(requestedTimeoutMs) + APIFY_SYNC_RESPONSE_GRACE_MS;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
248
270
|
return normalized === 'deeplineagent' ||
|
|
249
271
|
normalized === 'deeplineagent_deeplineagent' ||
|
|
250
272
|
normalized === 'ai_inference' ||
|
|
@@ -1417,7 +1439,7 @@ export class DeeplineClient {
|
|
|
1417
1439
|
headers,
|
|
1418
1440
|
{
|
|
1419
1441
|
forbiddenAsApiError: true,
|
|
1420
|
-
timeout: options?.timeout ?? resolveToolExecuteTimeoutMs(toolId),
|
|
1442
|
+
timeout: options?.timeout ?? resolveToolExecuteTimeoutMs(toolId, input),
|
|
1421
1443
|
maxRetries: options?.maxRetries ?? 0,
|
|
1422
1444
|
exactUrlOnly: true,
|
|
1423
1445
|
},
|
|
@@ -161,7 +161,7 @@ export interface PlayCallOptions {
|
|
|
161
161
|
* sqlListeners: [
|
|
162
162
|
* {
|
|
163
163
|
* id: 'jobs',
|
|
164
|
-
* tool: '
|
|
164
|
+
* tool: 'deepline_native.company_radar',
|
|
165
165
|
* stream: 'company_job_openings',
|
|
166
166
|
* operations: ['INSERT'],
|
|
167
167
|
* },
|
|
@@ -237,7 +237,7 @@ export type SqlListenerWhere = {
|
|
|
237
237
|
export type SqlListenerDeclaration = {
|
|
238
238
|
/** Short id unique inside this play. Deepline stores it as playName.id. */
|
|
239
239
|
id: string;
|
|
240
|
-
/** Modeled monitor tool id, for example "
|
|
240
|
+
/** Modeled monitor tool id, for example "deepline_native.company_radar". */
|
|
241
241
|
tool: string;
|
|
242
242
|
/** Stream key exposed by the modeled monitor tool, for example "company_job_openings". */
|
|
243
243
|
stream: string;
|
|
@@ -108,10 +108,10 @@ export const SDK_RELEASE = {
|
|
|
108
108
|
// 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
|
|
109
109
|
// 0.1.220 deprecates SDK CLI versions below 0.1.219 and updates them
|
|
110
110
|
// automatically without blocking their current command.
|
|
111
|
-
version: '0.1.
|
|
111
|
+
version: '0.1.229',
|
|
112
112
|
apiContract: '2026-06-dataset-handle-results-hard-cutover',
|
|
113
113
|
supportPolicy: {
|
|
114
|
-
latest: '0.1.
|
|
114
|
+
latest: '0.1.229',
|
|
115
115
|
minimumSupported: '0.1.53',
|
|
116
116
|
deprecatedBelow: '0.1.219',
|
|
117
117
|
commandMinimumSupported: [
|