deepline 0.0.1 → 0.1.1
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 +324 -0
- package/dist/cli/index.js +6750 -503
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +6735 -512
- package/dist/cli/index.mjs.map +1 -1
- package/dist/index.d.mts +2349 -32
- package/dist/index.d.ts +2349 -32
- package/dist/index.js +1631 -82
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1617 -83
- package/dist/index.mjs.map +1 -1
- package/dist/repo/apps/play-runner-workers/src/coordinator-entry.ts +3256 -0
- package/dist/repo/apps/play-runner-workers/src/dedup-do.ts +710 -0
- package/dist/repo/apps/play-runner-workers/src/entry.ts +5070 -0
- package/dist/repo/apps/play-runner-workers/src/runtime/README.md +21 -0
- package/dist/repo/apps/play-runner-workers/src/runtime/batching.ts +177 -0
- package/dist/repo/apps/play-runner-workers/src/runtime/execution-plan.ts +52 -0
- package/dist/repo/apps/play-runner-workers/src/runtime/tool-batch.ts +100 -0
- package/dist/repo/apps/play-runner-workers/src/runtime/tool-result.ts +184 -0
- package/dist/repo/sdk/src/cli/commands/auth.ts +482 -0
- package/dist/repo/sdk/src/cli/commands/billing.ts +188 -0
- package/dist/repo/sdk/src/cli/commands/csv.ts +123 -0
- package/dist/repo/sdk/src/cli/commands/db.ts +119 -0
- package/dist/repo/sdk/src/cli/commands/feedback.ts +40 -0
- package/dist/repo/sdk/src/cli/commands/org.ts +117 -0
- package/dist/repo/sdk/src/cli/commands/play.ts +3200 -0
- package/dist/repo/sdk/src/cli/commands/tools.ts +687 -0
- package/dist/repo/sdk/src/cli/dataset-stats.ts +341 -0
- package/dist/repo/sdk/src/cli/index.ts +138 -0
- package/dist/repo/sdk/src/cli/progress.ts +135 -0
- package/dist/repo/sdk/src/cli/trace.ts +61 -0
- package/dist/repo/sdk/src/cli/utils.ts +145 -0
- package/dist/repo/sdk/src/client.ts +1188 -0
- package/dist/repo/sdk/src/compat.ts +77 -0
- package/dist/repo/sdk/src/config.ts +285 -0
- package/dist/repo/sdk/src/errors.ts +125 -0
- package/dist/repo/sdk/src/http.ts +391 -0
- package/dist/repo/sdk/src/index.ts +139 -0
- package/dist/repo/sdk/src/play.ts +1330 -0
- package/dist/repo/sdk/src/plays/bundle-play-file.ts +133 -0
- package/dist/repo/sdk/src/plays/harness-stub.ts +210 -0
- package/dist/repo/sdk/src/plays/local-file-discovery.ts +326 -0
- package/dist/repo/sdk/src/tool-output.ts +489 -0
- package/dist/repo/sdk/src/types.ts +669 -0
- package/dist/repo/sdk/src/version.ts +2 -0
- package/dist/repo/sdk/src/worker-play-entry.ts +286 -0
- package/dist/repo/shared_libs/observability/node-tracing.ts +129 -0
- package/dist/repo/shared_libs/observability/tracing.ts +98 -0
- package/dist/repo/shared_libs/play-runtime/backend.ts +139 -0
- package/dist/repo/shared_libs/play-runtime/batch-runtime.ts +182 -0
- package/dist/repo/shared_libs/play-runtime/batching-types.ts +91 -0
- package/dist/repo/shared_libs/play-runtime/context.ts +3999 -0
- package/dist/repo/shared_libs/play-runtime/coordinator-headers.ts +78 -0
- package/dist/repo/shared_libs/play-runtime/ctx-contract.ts +250 -0
- package/dist/repo/shared_libs/play-runtime/ctx-types.ts +713 -0
- package/dist/repo/shared_libs/play-runtime/dataset-id.ts +10 -0
- package/dist/repo/shared_libs/play-runtime/db-session-crypto.ts +304 -0
- package/dist/repo/shared_libs/play-runtime/db-session.ts +462 -0
- package/dist/repo/shared_libs/play-runtime/dedup-backend.ts +0 -0
- package/dist/repo/shared_libs/play-runtime/default-batch-strategies.ts +124 -0
- package/dist/repo/shared_libs/play-runtime/execution-plan.ts +262 -0
- package/dist/repo/shared_libs/play-runtime/live-events.ts +214 -0
- package/dist/repo/shared_libs/play-runtime/live-state-contract.ts +50 -0
- package/dist/repo/shared_libs/play-runtime/map-execution-frame.ts +114 -0
- package/dist/repo/shared_libs/play-runtime/map-row-identity.ts +158 -0
- package/dist/repo/shared_libs/play-runtime/profiles.ts +90 -0
- package/dist/repo/shared_libs/play-runtime/progress-emitter.ts +172 -0
- package/dist/repo/shared_libs/play-runtime/protocol.ts +121 -0
- package/dist/repo/shared_libs/play-runtime/public-play-contract.ts +42 -0
- package/dist/repo/shared_libs/play-runtime/result-normalization.ts +33 -0
- package/dist/repo/shared_libs/play-runtime/runtime-actions.ts +208 -0
- package/dist/repo/shared_libs/play-runtime/runtime-api.ts +1873 -0
- package/dist/repo/shared_libs/play-runtime/runtime-constraints.ts +2 -0
- package/dist/repo/shared_libs/play-runtime/runtime-pg-driver-neon-serverless.ts +201 -0
- package/dist/repo/shared_libs/play-runtime/runtime-pg-driver-pg.ts +48 -0
- package/dist/repo/shared_libs/play-runtime/runtime-pg-driver.ts +84 -0
- package/dist/repo/shared_libs/play-runtime/scheduler-backend.ts +174 -0
- package/dist/repo/shared_libs/play-runtime/static-pipeline-types.ts +147 -0
- package/dist/repo/shared_libs/play-runtime/suspension.ts +68 -0
- package/dist/repo/shared_libs/play-runtime/tool-batch-executor.ts +146 -0
- package/dist/repo/shared_libs/play-runtime/tool-result.ts +387 -0
- package/dist/repo/shared_libs/play-runtime/tracing.ts +31 -0
- package/dist/repo/shared_libs/play-runtime/waterfall-replay.ts +75 -0
- package/dist/repo/shared_libs/play-runtime/worker-api-types.ts +140 -0
- package/dist/repo/shared_libs/plays/artifact-transport.ts +14 -0
- package/dist/repo/shared_libs/plays/artifact-types.ts +49 -0
- package/dist/repo/shared_libs/plays/bundling/index.ts +1346 -0
- package/dist/repo/shared_libs/plays/compiler-manifest.ts +186 -0
- package/dist/repo/shared_libs/plays/contracts.ts +51 -0
- package/dist/repo/shared_libs/plays/dataset.ts +308 -0
- package/dist/repo/shared_libs/plays/definition.ts +264 -0
- package/dist/repo/shared_libs/plays/file-refs.ts +11 -0
- package/dist/repo/shared_libs/plays/rate-limit-scheduler.ts +206 -0
- package/dist/repo/shared_libs/plays/resolve-static-pipeline.ts +164 -0
- package/dist/repo/shared_libs/plays/row-identity.ts +302 -0
- package/dist/repo/shared_libs/plays/runtime-validation.ts +415 -0
- package/dist/repo/shared_libs/plays/static-pipeline.ts +560 -0
- package/dist/repo/shared_libs/temporal/constants.ts +39 -0
- package/dist/repo/shared_libs/temporal/preview-config.ts +153 -0
- package/package.json +14 -12
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { join, resolve } from 'node:path';
|
|
5
|
+
import { execSync } from 'node:child_process';
|
|
6
|
+
import { parse } from 'csv-parse/sync';
|
|
7
|
+
import { stringify } from 'csv-stringify/sync';
|
|
8
|
+
import { resolveConfig } from '../config.js';
|
|
9
|
+
import { HttpClient } from '../http.js';
|
|
10
|
+
|
|
11
|
+
export function getAuthedHttpClient() {
|
|
12
|
+
const config = resolveConfig();
|
|
13
|
+
return { config, http: new HttpClient(config) };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function writeOutputFile(
|
|
17
|
+
filename: string,
|
|
18
|
+
content: string,
|
|
19
|
+
): Promise<string> {
|
|
20
|
+
const outputDir = resolve(process.cwd(), 'deepline', 'data');
|
|
21
|
+
await mkdir(outputDir, { recursive: true });
|
|
22
|
+
const fullPath = join(outputDir, filename);
|
|
23
|
+
await writeFile(fullPath, content, 'utf-8');
|
|
24
|
+
return fullPath;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function openInBrowser(url: string): void {
|
|
28
|
+
try {
|
|
29
|
+
if (process.platform === 'darwin') execSync(`open "${url}"`, { stdio: 'ignore' });
|
|
30
|
+
else if (process.platform === 'win32')
|
|
31
|
+
execSync(`start "" "${url}"`, { stdio: 'ignore' });
|
|
32
|
+
else execSync(`xdg-open "${url}"`, { stdio: 'ignore' });
|
|
33
|
+
} catch {
|
|
34
|
+
// best effort
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function sleep(ms: number): Promise<void> {
|
|
39
|
+
return new Promise((resolvePromise) => setTimeout(resolvePromise, ms));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function collectLocalEnvInfo(): Record<string, string> {
|
|
43
|
+
return {
|
|
44
|
+
os: `${process.platform} ${process.arch}`,
|
|
45
|
+
node_version: process.version,
|
|
46
|
+
home_dir: homedir(),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function readCsvRows(csvPath: string): Array<Record<string, string>> {
|
|
51
|
+
const raw = readFileSync(resolve(csvPath), 'utf-8');
|
|
52
|
+
return parse(raw, {
|
|
53
|
+
columns: true,
|
|
54
|
+
skip_empty_lines: true,
|
|
55
|
+
}) as Array<Record<string, string>>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function csvStringFromRows(
|
|
59
|
+
rows: Array<Record<string, unknown>>,
|
|
60
|
+
columns?: string[],
|
|
61
|
+
): string {
|
|
62
|
+
return stringify(rows, {
|
|
63
|
+
header: true,
|
|
64
|
+
...(columns?.length ? { columns } : {}),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function printJson(value: unknown): void {
|
|
69
|
+
process.stdout.write(`${JSON.stringify(value, null, 2)}\n`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function errorToJsonPayload(error: unknown): {
|
|
73
|
+
ok: false;
|
|
74
|
+
error: {
|
|
75
|
+
message: string;
|
|
76
|
+
code: string;
|
|
77
|
+
details?: Record<string, unknown>;
|
|
78
|
+
};
|
|
79
|
+
} {
|
|
80
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
81
|
+
const maybeRecord =
|
|
82
|
+
error && typeof error === 'object'
|
|
83
|
+
? (error as Record<string, unknown>)
|
|
84
|
+
: null;
|
|
85
|
+
const code =
|
|
86
|
+
typeof maybeRecord?.code === 'string'
|
|
87
|
+
? maybeRecord.code
|
|
88
|
+
: error instanceof SyntaxError
|
|
89
|
+
? 'INVALID_JSON'
|
|
90
|
+
: 'CLI_ERROR';
|
|
91
|
+
const details: Record<string, unknown> = {};
|
|
92
|
+
if (typeof maybeRecord?.statusCode === 'number') {
|
|
93
|
+
details.statusCode = maybeRecord.statusCode;
|
|
94
|
+
}
|
|
95
|
+
if (typeof maybeRecord?.status === 'number') {
|
|
96
|
+
details.status = maybeRecord.status;
|
|
97
|
+
}
|
|
98
|
+
if (
|
|
99
|
+
maybeRecord?.details &&
|
|
100
|
+
typeof maybeRecord.details === 'object' &&
|
|
101
|
+
!Array.isArray(maybeRecord.details)
|
|
102
|
+
) {
|
|
103
|
+
details.details = maybeRecord.details;
|
|
104
|
+
}
|
|
105
|
+
if (typeof maybeRecord?.cause === 'string') {
|
|
106
|
+
details.cause = maybeRecord.cause;
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
ok: false,
|
|
110
|
+
error: {
|
|
111
|
+
message,
|
|
112
|
+
code,
|
|
113
|
+
...(Object.keys(details).length > 0 ? { details } : {}),
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function printJsonError(error: unknown): void {
|
|
119
|
+
printJson(errorToJsonPayload(error));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function shouldEmitJson(explicitJson = false): boolean {
|
|
123
|
+
return explicitJson || !process.stdout.isTTY;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function argsWantJson(args: string[]): boolean {
|
|
127
|
+
return shouldEmitJson(args.includes('--json'));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function createTimestampedName(prefix: string, extension: string): string {
|
|
131
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
132
|
+
return `${prefix}-${timestamp}.${extension}`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export async function writeCsvRowsFile(
|
|
136
|
+
prefix: string,
|
|
137
|
+
rows: Array<Record<string, unknown>>,
|
|
138
|
+
): Promise<string> {
|
|
139
|
+
const path = await writeOutputFile(createTimestampedName(prefix, 'csv'), csvStringFromRows(rows));
|
|
140
|
+
return path;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function clip(value: string, maxLength: number): string {
|
|
144
|
+
return value.length > maxLength ? `${value.slice(0, maxLength - 1)}…` : value;
|
|
145
|
+
}
|