deepline 0.1.55 → 0.1.56
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/cli/index.js +461 -62
- package/dist/cli/index.mjs +461 -62
- package/dist/index.d.mts +220 -34
- package/dist/index.d.ts +220 -34
- package/dist/index.js +22 -4
- package/dist/index.mjs +22 -4
- package/dist/repo/apps/play-runner-workers/src/entry.ts +36 -12
- package/dist/repo/apps/play-runner-workers/src/runtime/dataset-handles.ts +35 -7
- package/dist/repo/sdk/src/client.ts +33 -2
- package/dist/repo/sdk/src/play.ts +167 -33
- package/dist/repo/sdk/src/release.ts +3 -3
- package/dist/repo/sdk/src/types.ts +21 -0
- package/dist/repo/shared_libs/play-runtime/csv-rename.ts +55 -3
- package/dist/repo/shared_libs/plays/dataset.ts +25 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -276,6 +276,22 @@ interface ToolDefinition {
|
|
|
276
276
|
/** Copyable play-runtime guidance for V2 tool execution results. */
|
|
277
277
|
usageGuidance?: {
|
|
278
278
|
execute?: string;
|
|
279
|
+
prefer?: string[];
|
|
280
|
+
access?: {
|
|
281
|
+
extractedLists?: {
|
|
282
|
+
expression?: string;
|
|
283
|
+
meaning?: string;
|
|
284
|
+
};
|
|
285
|
+
extractedValues?: {
|
|
286
|
+
expression?: string;
|
|
287
|
+
meaning?: string;
|
|
288
|
+
};
|
|
289
|
+
rawToolResponse?: {
|
|
290
|
+
expression?: string;
|
|
291
|
+
meaning?: string;
|
|
292
|
+
};
|
|
293
|
+
invalidGetterHint?: string;
|
|
294
|
+
};
|
|
279
295
|
toolExecutionResult?: {
|
|
280
296
|
type?: 'ToolExecutionResult';
|
|
281
297
|
toolResponse?: {
|
|
@@ -758,6 +774,11 @@ interface PlayDescription {
|
|
|
758
774
|
rowOutputSchema?: Record<string, unknown> | null;
|
|
759
775
|
runCommand: string;
|
|
760
776
|
examples: string[];
|
|
777
|
+
cloneEditStarter?: {
|
|
778
|
+
path: string;
|
|
779
|
+
command: string;
|
|
780
|
+
checkCommand: string;
|
|
781
|
+
};
|
|
761
782
|
currentPublishedVersion?: number | null;
|
|
762
783
|
isDraftDirty?: boolean;
|
|
763
784
|
latestRunId?: string | null;
|
|
@@ -1073,6 +1094,8 @@ declare class DeeplineClient {
|
|
|
1073
1094
|
private compactSchema;
|
|
1074
1095
|
private schemaMetadata;
|
|
1075
1096
|
private playRunCommand;
|
|
1097
|
+
private starterPlayPath;
|
|
1098
|
+
private playCloneEditStarter;
|
|
1076
1099
|
private summarizePlayListItem;
|
|
1077
1100
|
private summarizePlayDetail;
|
|
1078
1101
|
/**
|
|
@@ -1464,7 +1487,6 @@ declare class DeeplineClient {
|
|
|
1464
1487
|
}): Promise<PlayListItem[]>;
|
|
1465
1488
|
searchPlays(options: {
|
|
1466
1489
|
query: string;
|
|
1467
|
-
origin?: 'prebuilt' | 'owned';
|
|
1468
1490
|
compact?: boolean;
|
|
1469
1491
|
}): Promise<PlayDescription[]>;
|
|
1470
1492
|
/**
|
|
@@ -1763,14 +1785,34 @@ type PlayDatasetWorkProgressSummary = {
|
|
|
1763
1785
|
};
|
|
1764
1786
|
};
|
|
1765
1787
|
type PlayDatasetInput<T> = ReadonlyArray<T> | Iterable<T> | AsyncIterable<T> | PlayDataset<T>;
|
|
1788
|
+
/**
|
|
1789
|
+
* Durable handle for rows produced by `ctx.csv(...)` or `ctx.map(...).run()`.
|
|
1790
|
+
*
|
|
1791
|
+
* A `PlayDataset` is not a normal in-memory array. It points at runtime-managed
|
|
1792
|
+
* rows, usually backed by persisted sheet storage, and carries metadata such as
|
|
1793
|
+
* dataset kind, dataset id, table namespace, count, and preview rows.
|
|
1794
|
+
*
|
|
1795
|
+
* Pass dataset handles directly into later `ctx.map(...)` stages by default so
|
|
1796
|
+
* Deepline keeps row progress, retries, memory use, and table output under
|
|
1797
|
+
* runtime control. Use `count()` and `peek()` for bounded inspection. Use
|
|
1798
|
+
* `materialize(limit)` or async iteration only when the dataset is intentionally
|
|
1799
|
+
* small and bounded.
|
|
1800
|
+
*/
|
|
1766
1801
|
interface PlayDataset<T> extends AsyncIterable<T> {
|
|
1767
1802
|
readonly [PLAY_DATASET_BRAND]: true;
|
|
1803
|
+
/** Dataset kind. */
|
|
1768
1804
|
readonly datasetKind: PlayDatasetKind;
|
|
1805
|
+
/** Dataset id. */
|
|
1769
1806
|
readonly datasetId: string;
|
|
1807
|
+
/** Backing store info. */
|
|
1770
1808
|
readonly backing?: PlayDatasetBacking;
|
|
1809
|
+
/** Display label. */
|
|
1771
1810
|
readonly sourceLabel?: string | null;
|
|
1811
|
+
/** Runtime table name. */
|
|
1772
1812
|
readonly tableNamespace?: string | null;
|
|
1813
|
+
/** Row count. */
|
|
1773
1814
|
count(): Promise<number>;
|
|
1815
|
+
/** Preview rows. */
|
|
1774
1816
|
peek(limit?: number): Promise<T[]>;
|
|
1775
1817
|
/**
|
|
1776
1818
|
* Explicit escape hatch for bounded result sets.
|
|
@@ -1857,6 +1899,19 @@ type ToolExecuteResultAccessors<TExtracted extends Record<string, unknown> = Rec
|
|
|
1857
1899
|
[K in keyof TLists]: ToolResultListAccessor<TLists[K]>;
|
|
1858
1900
|
};
|
|
1859
1901
|
};
|
|
1902
|
+
/**
|
|
1903
|
+
* Canonical result returned by Deepline tool execution.
|
|
1904
|
+
*
|
|
1905
|
+
* The top-level object is Deepline-owned execution metadata and semantic
|
|
1906
|
+
* extraction state. Raw tool/provider data lives under `toolResponse.raw`;
|
|
1907
|
+
* response metadata lives under `toolResponse.meta`. Semantic single-value
|
|
1908
|
+
* getters live under `extractedValues.<name>.get()`, and list getters live
|
|
1909
|
+
* under `extractedLists.<name>.get()`.
|
|
1910
|
+
*
|
|
1911
|
+
* Use extractors first when a tool contract exposes them. Drop to
|
|
1912
|
+
* `toolResponse.raw` when you need provider-specific fields or when debugging
|
|
1913
|
+
* from persisted run rows.
|
|
1914
|
+
*/
|
|
1860
1915
|
type ToolExecuteResult<TResult = unknown, TMeta = Record<string, unknown>, TExtracted extends Record<string, unknown> = Record<string, unknown>, TLists extends Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>> = ToolExecuteResultBase<TResult, TMeta> & ToolExecuteResultAccessors<TExtracted, TLists>;
|
|
1861
1916
|
|
|
1862
1917
|
/**
|
|
@@ -1915,10 +1970,20 @@ type LoosePlayObject = {
|
|
|
1915
1970
|
[key: string]: LoosePlayObject;
|
|
1916
1971
|
};
|
|
1917
1972
|
|
|
1973
|
+
/**
|
|
1974
|
+
* Keyword-style request object for `ctx.tools.execute(...)`.
|
|
1975
|
+
*
|
|
1976
|
+
* The `tool` value comes from live tool discovery. The `id` is the stable
|
|
1977
|
+
* logical call name inside this play and participates in replay/idempotency.
|
|
1978
|
+
*/
|
|
1918
1979
|
type ToolExecutionRequest = {
|
|
1980
|
+
/** Stable logical id for this tool call within the play. */
|
|
1919
1981
|
id: string;
|
|
1982
|
+
/** Current tool id from `deepline tools search` / `deepline tools describe`. */
|
|
1920
1983
|
tool: string;
|
|
1984
|
+
/** JSON-serializable provider/tool input object. */
|
|
1921
1985
|
input: Record<string, unknown>;
|
|
1986
|
+
/** Human-readable description for logs and run inspection. */
|
|
1922
1987
|
description?: string;
|
|
1923
1988
|
staleAfterSeconds?: number;
|
|
1924
1989
|
};
|
|
@@ -1950,7 +2015,29 @@ type PlayStepProgramStep = {
|
|
|
1950
2015
|
};
|
|
1951
2016
|
type MapStepResolver<Row, Value> = StepResolver<Row, Value> | ConditionalStepResolver<Row, Value> | StepProgramResolver<Row, Value>;
|
|
1952
2017
|
type MapStepBuilder<InputRow extends object, OutputRow extends object> = {
|
|
2018
|
+
/**
|
|
2019
|
+
* Define one output column for every row in this map dataset.
|
|
2020
|
+
*
|
|
2021
|
+
* The `name` becomes a field on each output row. For example,
|
|
2022
|
+
* `.step('contact', ...)` creates `row.contact` in later map stages; it does
|
|
2023
|
+
* not spread returned object fields such as `contact.email` into `row.email`.
|
|
2024
|
+
* Add a later column resolver when you want a top-level export field:
|
|
2025
|
+
* `.step('email', row => row.contact?.email ?? null)`.
|
|
2026
|
+
*
|
|
2027
|
+
* @param name - Output column name.
|
|
2028
|
+
* @param resolver - Computes the value for one row.
|
|
2029
|
+
* @returns The same map builder with the new column type.
|
|
2030
|
+
*/
|
|
1953
2031
|
step<Name extends string, Value>(name: Name, resolver: MapStepResolver<OutputRow, Value>): MapStepBuilder<InputRow, OutputRow & Record<Name, Value>>;
|
|
2032
|
+
/**
|
|
2033
|
+
* Execute the row-column program and return a durable dataset handle.
|
|
2034
|
+
*
|
|
2035
|
+
* The returned {@link PlayDataset} preserves one output row per input row,
|
|
2036
|
+
* with original fields merged with the columns produced by `.step(...)`.
|
|
2037
|
+
*
|
|
2038
|
+
* @param options - Run options.
|
|
2039
|
+
* @returns Output rows as a dataset handle.
|
|
2040
|
+
*/
|
|
1954
2041
|
run(options?: {
|
|
1955
2042
|
description?: string;
|
|
1956
2043
|
staleAfterSeconds?: number;
|
|
@@ -1977,10 +2064,15 @@ type CsvInput<TRow extends object = Record<string, unknown>> = FileInput<{
|
|
|
1977
2064
|
readonly row: TRow;
|
|
1978
2065
|
}>;
|
|
1979
2066
|
type ColumnMap<TRow extends object> = Partial<Record<Extract<keyof TRow, string>, string | readonly string[]>>;
|
|
2067
|
+
/** Options for loading a staged CSV with `ctx.csv(...)`. */
|
|
1980
2068
|
type CsvOptions = {
|
|
2069
|
+
/** Human-readable description for runtime logs and inspection. */
|
|
1981
2070
|
description?: string;
|
|
2071
|
+
/** Canonical field-to-header aliases, e.g. `{ domain: ['domain', 'Company Domain'] }`. */
|
|
1982
2072
|
columns?: CsvRenameMap;
|
|
2073
|
+
/** Header rename map; use `columns` for new code. */
|
|
1983
2074
|
rename?: CsvRenameMap;
|
|
2075
|
+
/** Canonical fields that must be present after header normalization. */
|
|
1984
2076
|
required?: readonly string[];
|
|
1985
2077
|
};
|
|
1986
2078
|
/**
|
|
@@ -2030,41 +2122,47 @@ type CsvOptions = {
|
|
|
2030
2122
|
*/
|
|
2031
2123
|
interface DeeplinePlayRuntimeContext {
|
|
2032
2124
|
/**
|
|
2033
|
-
* Load a CSV file as a dataset handle.
|
|
2125
|
+
* Load a staged CSV file as a durable dataset handle.
|
|
2126
|
+
*
|
|
2127
|
+
* Use this when a play receives a CSV path from the CLI or API and row work
|
|
2128
|
+
* should continue through {@link DeeplinePlayRuntimeContext.map}. The path is
|
|
2129
|
+
* normally an input field such as `input.csv`, populated by
|
|
2130
|
+
* `deepline plays run my.play.ts --csv rows.csv`.
|
|
2034
2131
|
*
|
|
2035
|
-
*
|
|
2036
|
-
*
|
|
2132
|
+
* Each CSV row becomes an object keyed by canonical column names. Use
|
|
2133
|
+
* `options.columns` / `options.rename` to map user headers such as
|
|
2134
|
+
* `"Company Domain"` to stable code fields such as `domain`.
|
|
2037
2135
|
*
|
|
2038
2136
|
* @typeParam T - Row type (defaults to `Record<string, unknown>`)
|
|
2039
|
-
* @param path -
|
|
2040
|
-
*
|
|
2041
|
-
* explicit `materialize()` for small result sets.
|
|
2137
|
+
* @param path - Staged CSV path.
|
|
2138
|
+
* @param options - CSV load options.
|
|
2042
2139
|
*
|
|
2043
|
-
* @returns
|
|
2140
|
+
* @returns A {@link PlayDataset} whose rows should usually flow directly into `ctx.map(...)`.
|
|
2044
2141
|
*/
|
|
2045
2142
|
csv<T = Record<string, unknown>>(path: string, options?: CsvOptions): Promise<PlayDataset<T>>;
|
|
2046
2143
|
/**
|
|
2047
|
-
*
|
|
2144
|
+
* Create a persisted row dataset/table from input rows.
|
|
2048
2145
|
*
|
|
2049
|
-
*
|
|
2050
|
-
*
|
|
2051
|
-
*
|
|
2146
|
+
* `ctx.map` is Deepline's row-work primitive. It records row identity,
|
|
2147
|
+
* progress, retries, table output, and idempotency for a collection of rows.
|
|
2148
|
+
* Use `.step(name, resolver)` on the returned builder to define output
|
|
2149
|
+
* columns, then `.run(...)` to execute the row program.
|
|
2052
2150
|
*
|
|
2053
|
-
*
|
|
2054
|
-
*
|
|
2055
|
-
* automatically from
|
|
2056
|
-
*
|
|
2057
|
-
* relative time window. Use `86400` for daily reruns; retries inside the same
|
|
2058
|
-
* window still replay safely.
|
|
2151
|
+
* The `key` identifies the logical dataset/table. Renaming it is a persistence
|
|
2152
|
+
* migration: existing rows may no longer be reused. Row identity is derived
|
|
2153
|
+
* automatically from input row content unless `.run({ key: ... })` overrides
|
|
2154
|
+
* it with stable business fields such as `domain`, `email`, or `linkedin_url`.
|
|
2059
2155
|
*
|
|
2060
|
-
*
|
|
2061
|
-
*
|
|
2062
|
-
*
|
|
2156
|
+
* By default, `ctx.map` is row-preserving: one input row produces one output
|
|
2157
|
+
* row, with original fields merged with the columns produced by
|
|
2158
|
+
* `.step(...)`. If one input entity must become many output rows, use the
|
|
2159
|
+
* documented expand/flatten recipe instead of assuming `ctx.map` changes
|
|
2160
|
+
* row cardinality.
|
|
2063
2161
|
*
|
|
2064
2162
|
* @typeParam T - Row type
|
|
2065
|
-
* @param key -
|
|
2066
|
-
* @param items - Input rows
|
|
2067
|
-
* @returns
|
|
2163
|
+
* @param key - Dataset/table name.
|
|
2164
|
+
* @param items - Input rows.
|
|
2165
|
+
* @returns A builder. Calling `.run()` returns a `PlayDataset` of rows plus computed columns.
|
|
2068
2166
|
*
|
|
2069
2167
|
* @example Single tool per row
|
|
2070
2168
|
* ```typescript
|
|
@@ -2103,21 +2201,71 @@ interface DeeplinePlayRuntimeContext {
|
|
|
2103
2201
|
/**
|
|
2104
2202
|
* Execute a single tool with a keyword-style request object.
|
|
2105
2203
|
*
|
|
2106
|
-
* @param request
|
|
2107
|
-
* @
|
|
2108
|
-
* @param request.input - Tool-specific input parameters
|
|
2109
|
-
* @returns The tool's output
|
|
2204
|
+
* @param request - Tool call request.
|
|
2205
|
+
* @returns Tool execution result.
|
|
2110
2206
|
*/
|
|
2111
2207
|
execute<TOutput = LoosePlayObject>(request: ToolExecutionRequest & {
|
|
2112
2208
|
staleAfterSeconds?: number;
|
|
2113
2209
|
}): Promise<ToolExecuteResult<TOutput>>;
|
|
2114
2210
|
};
|
|
2211
|
+
/**
|
|
2212
|
+
* Execute a single tool by stable step key and tool ID.
|
|
2213
|
+
*
|
|
2214
|
+
* Shorthand for `ctx.tools.execute(...)`; this is the preferred spelling in
|
|
2215
|
+
* row-level step programs.
|
|
2216
|
+
*/
|
|
2217
|
+
tool<TOutput = LoosePlayObject>(key: string, toolId: string, input: Record<string, unknown>, options?: {
|
|
2218
|
+
description?: string;
|
|
2219
|
+
}): Promise<ToolExecuteResult<TOutput>>;
|
|
2220
|
+
/**
|
|
2221
|
+
* Run a reusable step program against one scalar input object.
|
|
2222
|
+
*
|
|
2223
|
+
* `steps().step(...)` is a composable mini-pipeline. Use `ctx.runSteps(...)`
|
|
2224
|
+
* when that mini-pipeline should execute outside a row dataset. Inside a
|
|
2225
|
+
* `ctx.map` column resolver, pass the step program directly to
|
|
2226
|
+
* `.step(name, program)` instead.
|
|
2227
|
+
*
|
|
2228
|
+
* @param program - Step program.
|
|
2229
|
+
* @param input - Program input.
|
|
2230
|
+
* @param options - Run options.
|
|
2231
|
+
* @returns Program output.
|
|
2232
|
+
*/
|
|
2115
2233
|
runSteps<TInput extends Record<string, unknown>, TOutput>(program: StepProgram<TInput, unknown, TOutput>, input: TInput, options?: {
|
|
2116
2234
|
description?: string;
|
|
2117
2235
|
}): Promise<TOutput>;
|
|
2236
|
+
/**
|
|
2237
|
+
* Create one scalar checkpoint for the whole play run.
|
|
2238
|
+
*
|
|
2239
|
+
* Use `ctx.step` when a value is nondeterministic, expensive, external, or
|
|
2240
|
+
* useful to inspect as a named boundary. The first execution stores the
|
|
2241
|
+
* JSON-serializable output under `id`; replay and retries return the stored
|
|
2242
|
+
* value instead of running `run` again.
|
|
2243
|
+
*
|
|
2244
|
+
* Plain deterministic assignment does not need `ctx.step`. Use
|
|
2245
|
+
* `ctx.map(...).step(...)`, not `ctx.step`, when the value should become a
|
|
2246
|
+
* field on each exported row.
|
|
2247
|
+
*
|
|
2248
|
+
* @param id - Checkpoint id.
|
|
2249
|
+
* @param run - Computes the value once.
|
|
2250
|
+
* @param options - Checkpoint options.
|
|
2251
|
+
* @returns Checkpoint value.
|
|
2252
|
+
*/
|
|
2118
2253
|
step<T>(id: string, run: () => T | Promise<T>, options?: {
|
|
2119
2254
|
staleAfterSeconds?: number;
|
|
2120
2255
|
}): Promise<T>;
|
|
2256
|
+
/**
|
|
2257
|
+
* Durable HTTP fetch.
|
|
2258
|
+
*
|
|
2259
|
+
* Use this for non-provider HTTP calls that must replay safely. The response
|
|
2260
|
+
* is recorded under `key` so workflow replay sees the same value. Prefer
|
|
2261
|
+
* `ctx.tools.execute(...)` for Deepline-managed provider APIs because tools
|
|
2262
|
+
* handle auth, retries, rate limits, extraction metadata, and spend tracking.
|
|
2263
|
+
*
|
|
2264
|
+
* @param key - Checkpoint id.
|
|
2265
|
+
* @param url - URL to fetch.
|
|
2266
|
+
* @param init - Fetch options.
|
|
2267
|
+
* @returns Recorded response.
|
|
2268
|
+
*/
|
|
2121
2269
|
fetch(key: string, url: string | URL, init?: RequestInit, options?: {
|
|
2122
2270
|
staleAfterSeconds?: number;
|
|
2123
2271
|
}): Promise<{
|
|
@@ -2129,6 +2277,22 @@ interface DeeplinePlayRuntimeContext {
|
|
|
2129
2277
|
bodyText: string;
|
|
2130
2278
|
json: unknown | null;
|
|
2131
2279
|
}>;
|
|
2280
|
+
/**
|
|
2281
|
+
* Invoke another registered or file-backed play as a child workflow.
|
|
2282
|
+
*
|
|
2283
|
+
* Use this for real composition boundaries, especially when a fitting
|
|
2284
|
+
* scalar prebuilt play already encodes provider order, fallbacks,
|
|
2285
|
+
* normalization, and no-result behavior. Do not invoke plays through
|
|
2286
|
+
* `ctx.tools.execute`; tools and plays are separate namespaces.
|
|
2287
|
+
*
|
|
2288
|
+
* `key` is the stable child-call identity for idempotency and traceability.
|
|
2289
|
+
*
|
|
2290
|
+
* @param key - Child call id.
|
|
2291
|
+
* @param playRef - Play name or handle.
|
|
2292
|
+
* @param input - Child input.
|
|
2293
|
+
* @param options - Run options.
|
|
2294
|
+
* @returns Child play output.
|
|
2295
|
+
*/
|
|
2132
2296
|
runPlay(key: string, playRef: string | PlayReferenceLike, input: Record<string, unknown>, options: {
|
|
2133
2297
|
description?: string;
|
|
2134
2298
|
staleAfterSeconds?: number;
|
|
@@ -2313,11 +2477,24 @@ type PlayInputContract<TInput> = {
|
|
|
2313
2477
|
readonly schema: Record<string, unknown>;
|
|
2314
2478
|
readonly __inputType?: TInput;
|
|
2315
2479
|
};
|
|
2480
|
+
/**
|
|
2481
|
+
* Object-form play definition accepted by `definePlay(config)`.
|
|
2482
|
+
*
|
|
2483
|
+
* Use this form when the input contract should be explicit at definition time
|
|
2484
|
+
* through `defineInput<T>(schema)`, or when configuration reads clearer as one
|
|
2485
|
+
* object. The shorthand `definePlay(name, fn, bindings?)` is equivalent for
|
|
2486
|
+
* simple file-backed plays.
|
|
2487
|
+
*/
|
|
2316
2488
|
type DefinePlayConfig<TInput, TOutput extends PlayReturnObject> = {
|
|
2489
|
+
/** Play id/name. */
|
|
2317
2490
|
id: string;
|
|
2491
|
+
/** Input schema. */
|
|
2318
2492
|
input: PlayInputContract<TInput>;
|
|
2493
|
+
/** Play function. */
|
|
2319
2494
|
run: (ctx: DeeplinePlayRuntimeContext, input: TInput) => Promise<TOutput>;
|
|
2495
|
+
/** Trigger bindings. */
|
|
2320
2496
|
bindings?: PlayBindings;
|
|
2497
|
+
/** Billing options. */
|
|
2321
2498
|
billing?: PlayBindings['billing'];
|
|
2322
2499
|
};
|
|
2323
2500
|
declare function steps<TInput>(): StepProgram<TInput, TInput, TInput>;
|
|
@@ -2482,9 +2659,10 @@ declare function defineInput<TInput>(schema: Record<string, unknown>): PlayInput
|
|
|
2482
2659
|
*
|
|
2483
2660
|
* @typeParam TInput - The input type accepted by the play
|
|
2484
2661
|
* @typeParam TOutput - The return type of the play
|
|
2485
|
-
* @param
|
|
2486
|
-
* @param
|
|
2487
|
-
* @param
|
|
2662
|
+
* @param config - Object-form play config.
|
|
2663
|
+
* @param name - Play name.
|
|
2664
|
+
* @param fn - Play function.
|
|
2665
|
+
* @param bindings - Trigger bindings.
|
|
2488
2666
|
* @returns A {@link DefinedPlay} that is both callable and has lifecycle methods
|
|
2489
2667
|
*
|
|
2490
2668
|
* @example Basic play
|
|
@@ -2505,9 +2683,9 @@ declare function defineInput<TInput>(schema: Record<string, unknown>): PlayInput
|
|
|
2505
2683
|
*
|
|
2506
2684
|
* @example CSV processing play
|
|
2507
2685
|
* ```typescript
|
|
2508
|
-
* export default definePlay('bulk-enrich', async (ctx) => {
|
|
2509
|
-
* const leads = await ctx.csv(
|
|
2510
|
-
* ctx.log(`Processing ${leads.
|
|
2686
|
+
* export default definePlay('bulk-enrich', async (ctx, input: { csv: string }) => {
|
|
2687
|
+
* const leads = await ctx.csv(input.csv);
|
|
2688
|
+
* ctx.log(`Processing ${await leads.count()} rows`);
|
|
2511
2689
|
* const results = await ctx
|
|
2512
2690
|
* .map('companies', leads)
|
|
2513
2691
|
* .step('company', (row, ctx) =>
|
|
@@ -2552,6 +2730,14 @@ declare function defineInput<TInput>(schema: Record<string, unknown>): PlayInput
|
|
|
2552
2730
|
* ```
|
|
2553
2731
|
*/
|
|
2554
2732
|
declare function definePlay<TInput, TOutput extends PlayReturnObject>(config: DefinePlayConfig<TInput, TOutput>): DefinedPlay<TInput, TOutput>;
|
|
2733
|
+
/**
|
|
2734
|
+
* Define a play with a name and function.
|
|
2735
|
+
*
|
|
2736
|
+
* @param name - Play name.
|
|
2737
|
+
* @param fn - Play function.
|
|
2738
|
+
* @param bindings - Trigger bindings.
|
|
2739
|
+
* @returns Play handle.
|
|
2740
|
+
*/
|
|
2555
2741
|
declare function definePlay<TInput, TOutput extends PlayReturnObject>(name: string, fn: (ctx: DeeplinePlayRuntimeContext, input: TInput) => Promise<TOutput>, bindings?: PlayBindings): DefinedPlay<TInput, TOutput>;
|
|
2556
2742
|
/**
|
|
2557
2743
|
* Alias for {@link definePlay}. Workflows and plays share the same public
|
package/dist/index.js
CHANGED
|
@@ -216,10 +216,10 @@ function resolveConfig(options) {
|
|
|
216
216
|
|
|
217
217
|
// src/release.ts
|
|
218
218
|
var SDK_RELEASE = {
|
|
219
|
-
version: "0.1.
|
|
220
|
-
apiContract: "2026-05-
|
|
219
|
+
version: "0.1.56",
|
|
220
|
+
apiContract: "2026-05-play-tool-describe-starters",
|
|
221
221
|
supportPolicy: {
|
|
222
|
-
latest: "0.1.
|
|
222
|
+
latest: "0.1.56",
|
|
223
223
|
minimumSupported: "0.1.53",
|
|
224
224
|
deprecatedBelow: "0.1.53"
|
|
225
225
|
}
|
|
@@ -723,6 +723,23 @@ var DeeplineClient = class {
|
|
|
723
723
|
}
|
|
724
724
|
return `deepline plays run ${target} --input '{...}' --watch`;
|
|
725
725
|
}
|
|
726
|
+
starterPlayPath(play) {
|
|
727
|
+
const target = play.reference || play.name;
|
|
728
|
+
const unqualifiedName = target.split("/").pop() || play.name;
|
|
729
|
+
const safeName = unqualifiedName.trim().toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
730
|
+
return `./${safeName || "play"}.play.ts`;
|
|
731
|
+
}
|
|
732
|
+
playCloneEditStarter(play) {
|
|
733
|
+
const readonlyPrebuilt = (play.origin === "prebuilt" || play.ownerType === "deepline") && !play.canEdit;
|
|
734
|
+
if (!play.canClone && !readonlyPrebuilt) return void 0;
|
|
735
|
+
const target = play.reference || play.name;
|
|
736
|
+
const path = this.starterPlayPath(play);
|
|
737
|
+
return {
|
|
738
|
+
path,
|
|
739
|
+
command: `deepline plays get ${target} --source --out ${path}`,
|
|
740
|
+
checkCommand: `deepline plays check ${path}`
|
|
741
|
+
};
|
|
742
|
+
}
|
|
726
743
|
summarizePlayListItem(play, options) {
|
|
727
744
|
const aliases = play.aliases?.length ? play.aliases : [play.name];
|
|
728
745
|
const csvInput = this.schemaMetadata(play.inputSchema, "csvInput");
|
|
@@ -731,6 +748,7 @@ var DeeplineClient = class {
|
|
|
731
748
|
"rowOutputSchema"
|
|
732
749
|
);
|
|
733
750
|
const runCommand = this.playRunCommand(play, { csvInput });
|
|
751
|
+
const cloneEditStarter = this.playCloneEditStarter(play);
|
|
734
752
|
return {
|
|
735
753
|
name: play.name,
|
|
736
754
|
...play.reference ? { reference: play.reference } : {},
|
|
@@ -746,6 +764,7 @@ var DeeplineClient = class {
|
|
|
746
764
|
...rowOutputSchema ? { rowOutputSchema } : {},
|
|
747
765
|
runCommand,
|
|
748
766
|
examples: [runCommand],
|
|
767
|
+
...cloneEditStarter ? { cloneEditStarter } : {},
|
|
749
768
|
currentPublishedVersion: play.currentPublishedVersion ?? null,
|
|
750
769
|
isDraftDirty: play.isDraftDirty
|
|
751
770
|
};
|
|
@@ -1448,7 +1467,6 @@ var DeeplineClient = class {
|
|
|
1448
1467
|
async searchPlays(options) {
|
|
1449
1468
|
const params = new URLSearchParams();
|
|
1450
1469
|
params.set("search", options.query.trim());
|
|
1451
|
-
if (options.origin) params.set("origin", options.origin);
|
|
1452
1470
|
const response = await this.http.get(
|
|
1453
1471
|
`/api/v2/plays?${params.toString()}`
|
|
1454
1472
|
);
|
package/dist/index.mjs
CHANGED
|
@@ -170,10 +170,10 @@ function resolveConfig(options) {
|
|
|
170
170
|
|
|
171
171
|
// src/release.ts
|
|
172
172
|
var SDK_RELEASE = {
|
|
173
|
-
version: "0.1.
|
|
174
|
-
apiContract: "2026-05-
|
|
173
|
+
version: "0.1.56",
|
|
174
|
+
apiContract: "2026-05-play-tool-describe-starters",
|
|
175
175
|
supportPolicy: {
|
|
176
|
-
latest: "0.1.
|
|
176
|
+
latest: "0.1.56",
|
|
177
177
|
minimumSupported: "0.1.53",
|
|
178
178
|
deprecatedBelow: "0.1.53"
|
|
179
179
|
}
|
|
@@ -677,6 +677,23 @@ var DeeplineClient = class {
|
|
|
677
677
|
}
|
|
678
678
|
return `deepline plays run ${target} --input '{...}' --watch`;
|
|
679
679
|
}
|
|
680
|
+
starterPlayPath(play) {
|
|
681
|
+
const target = play.reference || play.name;
|
|
682
|
+
const unqualifiedName = target.split("/").pop() || play.name;
|
|
683
|
+
const safeName = unqualifiedName.trim().toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
684
|
+
return `./${safeName || "play"}.play.ts`;
|
|
685
|
+
}
|
|
686
|
+
playCloneEditStarter(play) {
|
|
687
|
+
const readonlyPrebuilt = (play.origin === "prebuilt" || play.ownerType === "deepline") && !play.canEdit;
|
|
688
|
+
if (!play.canClone && !readonlyPrebuilt) return void 0;
|
|
689
|
+
const target = play.reference || play.name;
|
|
690
|
+
const path = this.starterPlayPath(play);
|
|
691
|
+
return {
|
|
692
|
+
path,
|
|
693
|
+
command: `deepline plays get ${target} --source --out ${path}`,
|
|
694
|
+
checkCommand: `deepline plays check ${path}`
|
|
695
|
+
};
|
|
696
|
+
}
|
|
680
697
|
summarizePlayListItem(play, options) {
|
|
681
698
|
const aliases = play.aliases?.length ? play.aliases : [play.name];
|
|
682
699
|
const csvInput = this.schemaMetadata(play.inputSchema, "csvInput");
|
|
@@ -685,6 +702,7 @@ var DeeplineClient = class {
|
|
|
685
702
|
"rowOutputSchema"
|
|
686
703
|
);
|
|
687
704
|
const runCommand = this.playRunCommand(play, { csvInput });
|
|
705
|
+
const cloneEditStarter = this.playCloneEditStarter(play);
|
|
688
706
|
return {
|
|
689
707
|
name: play.name,
|
|
690
708
|
...play.reference ? { reference: play.reference } : {},
|
|
@@ -700,6 +718,7 @@ var DeeplineClient = class {
|
|
|
700
718
|
...rowOutputSchema ? { rowOutputSchema } : {},
|
|
701
719
|
runCommand,
|
|
702
720
|
examples: [runCommand],
|
|
721
|
+
...cloneEditStarter ? { cloneEditStarter } : {},
|
|
703
722
|
currentPublishedVersion: play.currentPublishedVersion ?? null,
|
|
704
723
|
isDraftDirty: play.isDraftDirty
|
|
705
724
|
};
|
|
@@ -1402,7 +1421,6 @@ var DeeplineClient = class {
|
|
|
1402
1421
|
async searchPlays(options) {
|
|
1403
1422
|
const params = new URLSearchParams();
|
|
1404
1423
|
params.set("search", options.query.trim());
|
|
1405
|
-
if (options.origin) params.set("origin", options.origin);
|
|
1406
1424
|
const response = await this.http.get(
|
|
1407
1425
|
`/api/v2/plays?${params.toString()}`
|
|
1408
1426
|
);
|
|
@@ -120,6 +120,7 @@ import {
|
|
|
120
120
|
import {
|
|
121
121
|
applyCsvRenameProjection,
|
|
122
122
|
stripCsvProjectedFields,
|
|
123
|
+
stripCsvProjectionMetadata,
|
|
123
124
|
cloneCsvAliasedRow,
|
|
124
125
|
type CsvRenameOptions,
|
|
125
126
|
} from '../../../shared_libs/play-runtime/csv-rename';
|
|
@@ -690,6 +691,23 @@ function publicCsvInputRow<T extends Record<string, unknown>>(row: T): T {
|
|
|
690
691
|
) as T;
|
|
691
692
|
}
|
|
692
693
|
|
|
694
|
+
function publicCsvOutputRow<T extends Record<string, unknown>>(row: T): T {
|
|
695
|
+
const stripped = stripCsvProjectionMetadata(row) as Record<string, unknown>;
|
|
696
|
+
const publicRow: Record<string, unknown> = {};
|
|
697
|
+
for (const fieldName of Reflect.ownKeys(stripped)) {
|
|
698
|
+
if (
|
|
699
|
+
typeof fieldName === 'string' &&
|
|
700
|
+
fieldName.startsWith('__deepline')
|
|
701
|
+
) {
|
|
702
|
+
continue;
|
|
703
|
+
}
|
|
704
|
+
const descriptor = Object.getOwnPropertyDescriptor(stripped, fieldName);
|
|
705
|
+
if (!descriptor) continue;
|
|
706
|
+
Object.defineProperty(publicRow, fieldName, descriptor);
|
|
707
|
+
}
|
|
708
|
+
return publicRow as T;
|
|
709
|
+
}
|
|
710
|
+
|
|
693
711
|
/**
|
|
694
712
|
* Strip credentials and JWT-shaped tokens from any string before it lands in
|
|
695
713
|
* a log buffer or upstream error message. The harness routinely echoes
|
|
@@ -3742,9 +3760,8 @@ function createMinimalWorkerCtx(
|
|
|
3742
3760
|
? completedRow.__deeplineRowKey
|
|
3743
3761
|
: derivePlayRowIdentity(publicCsvInputRow(completedRow), name);
|
|
3744
3762
|
if (key) {
|
|
3745
|
-
const
|
|
3746
|
-
|
|
3747
|
-
void _rowKey;
|
|
3763
|
+
const cleanedRow = publicCsvOutputRow(completedRow);
|
|
3764
|
+
delete cleanedRow.__deeplineRowKey;
|
|
3748
3765
|
resultByKey.set(key, cleanedRow as T & Record<string, unknown>);
|
|
3749
3766
|
}
|
|
3750
3767
|
}
|
|
@@ -3763,8 +3780,9 @@ function createMinimalWorkerCtx(
|
|
|
3763
3780
|
return resultByKey.get(key);
|
|
3764
3781
|
})
|
|
3765
3782
|
.filter((row): row is T & Record<string, unknown> => Boolean(row));
|
|
3783
|
+
const publicOut = out.map((row) => publicCsvOutputRow(row));
|
|
3766
3784
|
const hashStartedAt = nowMs();
|
|
3767
|
-
const hash = await hashJson(
|
|
3785
|
+
const hash = await hashJson(publicOut);
|
|
3768
3786
|
recordRunnerPerfTrace({
|
|
3769
3787
|
req,
|
|
3770
3788
|
phase: 'runner.map_chunk.hash',
|
|
@@ -3797,7 +3815,7 @@ function createMinimalWorkerCtx(
|
|
|
3797
3815
|
rowsSkipped,
|
|
3798
3816
|
outputDatasetId: `map:${name}`,
|
|
3799
3817
|
hash,
|
|
3800
|
-
preview:
|
|
3818
|
+
preview: toWorkflowSerializableValue(publicOut.slice(0, 5)),
|
|
3801
3819
|
cachedRows:
|
|
3802
3820
|
out.length <= WORKER_DATASET_IN_MEMORY_ROWS
|
|
3803
3821
|
? serializeDurableStepValue(out)
|
|
@@ -4333,13 +4351,15 @@ function createMinimalWorkerCtx(
|
|
|
4333
4351
|
req,
|
|
4334
4352
|
allowInline:
|
|
4335
4353
|
options?.timeoutMs == null && !childNeedsWorkflowScheduler,
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4354
|
+
body: {
|
|
4355
|
+
name: resolvedName,
|
|
4356
|
+
input: isRecord(input) ? input : {},
|
|
4357
|
+
orgId: req.orgId,
|
|
4358
|
+
callbackBaseUrl: req.callbackUrl,
|
|
4359
|
+
baseUrl: req.baseUrl,
|
|
4360
|
+
parentExecutorToken: req.executorToken,
|
|
4361
|
+
userEmail: req.userEmail ?? '',
|
|
4362
|
+
profile: 'workers_edge',
|
|
4343
4363
|
manifest: childManifest,
|
|
4344
4364
|
childPlayManifests: req.childPlayManifests ?? null,
|
|
4345
4365
|
internalRunPlay: {
|
|
@@ -5344,6 +5364,10 @@ function serializePlayReturnValue(value: unknown): unknown {
|
|
|
5344
5364
|
return serializeValue(value, 0);
|
|
5345
5365
|
}
|
|
5346
5366
|
|
|
5367
|
+
function toWorkflowSerializableValue<T>(value: T): T {
|
|
5368
|
+
return serializeValue(value, 0) as T;
|
|
5369
|
+
}
|
|
5370
|
+
|
|
5347
5371
|
/**
|
|
5348
5372
|
* Hard cap on the trimmed result body persisted into Convex run state.
|
|
5349
5373
|
* Convex docs are bounded (~1 MiB per field) so we keep this comfortably
|