@talqing/sdk 0.3.0 → 0.4.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.
@@ -1767,6 +1767,37 @@ export class Recipients2 extends HeyApiClient {
1767
1767
  }
1768
1768
  });
1769
1769
  }
1770
+ /**
1771
+ * Redraft Email Batch Recipients
1772
+ *
1773
+ * Draft rows again from scratch. **Each one runs the task and is billed again.**
1774
+ *
1775
+ * `selection` is `failed` (drafting failed), `stale_version` (drafted by an
1776
+ * older published version of the task), `not_sent`, or `all` — which names
1777
+ * every row it refuses. Rows already sent or queued are never redrafted.
1778
+ *
1779
+ * This revives a batch that had finished drafting, and a person's edited cells
1780
+ * survive unless you pass `clear_overrides`.
1781
+ */
1782
+ redraft(parameters, options) {
1783
+ const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'batch_id' }, { key: 'redraftRequest', map: 'body' }] }]);
1784
+ return (options?.client ?? this.client).post({
1785
+ responseStyle: 'data',
1786
+ security: [{ scheme: 'bearer', type: 'http' }, {
1787
+ in: 'cookie',
1788
+ name: 'talqing_session',
1789
+ type: 'apiKey'
1790
+ }],
1791
+ url: '/v1/email/batches/{batch_id}/redraft',
1792
+ ...options,
1793
+ ...params,
1794
+ headers: {
1795
+ 'Content-Type': 'application/json',
1796
+ ...options?.headers,
1797
+ ...params.headers
1798
+ }
1799
+ });
1800
+ }
1770
1801
  /**
1771
1802
  * Restore Email Batch Recipients
1772
1803
  *
@@ -1792,17 +1823,15 @@ export class Recipients2 extends HeyApiClient {
1792
1823
  });
1793
1824
  }
1794
1825
  /**
1795
- * Retry Email Batch Recipients
1826
+ * Skip Email Batch Recipients
1796
1827
  *
1797
- * Draft rows whose first attempt failed, again.
1828
+ * Take drafted rows out of consideration. Reversible with `restore`.
1798
1829
  *
1799
- * `selection: "all_eligible"` means every row whose drafting failed. This is
1800
- * the one action that revives a batch that has already finished drafting: it
1801
- * goes back to `drafting` and picks up exactly the rows you retried the
1802
- * alternative would be telling you that twelve failed rows are unrecoverable
1803
- * because the other 4 988 finished first.
1830
+ * Takes either `recipient_ids` or `selection: "all_eligible"`, which here means
1831
+ * every row that has a draft. The reversible verbs keep that shorthand while
1832
+ * `send` does not, because the rule is about irreversibility rather than bulk.
1804
1833
  */
1805
- retry(parameters, options) {
1834
+ skip(parameters, options) {
1806
1835
  const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'batch_id' }, { key: 'selectRecipientsRequest', map: 'body' }] }]);
1807
1836
  return (options?.client ?? this.client).post({
1808
1837
  responseStyle: 'data',
@@ -1811,7 +1840,7 @@ export class Recipients2 extends HeyApiClient {
1811
1840
  name: 'talqing_session',
1812
1841
  type: 'apiKey'
1813
1842
  }],
1814
- url: '/v1/email/batches/{batch_id}/retry',
1843
+ url: '/v1/email/batches/{batch_id}/skip',
1815
1844
  ...options,
1816
1845
  ...params,
1817
1846
  headers: {
@@ -1821,21 +1850,47 @@ export class Recipients2 extends HeyApiClient {
1821
1850
  }
1822
1851
  });
1823
1852
  }
1853
+ }
1854
+ export class Sends extends HeyApiClient {
1824
1855
  /**
1825
- * Send Email Batch Recipients
1856
+ * List Email Sends
1826
1857
  *
1827
- * Send the rows you name. **This mails real people and cannot be undone.**
1858
+ * Every send on this batch, newest first, with its counts and its schedule.
1859
+ */
1860
+ list(parameters, options) {
1861
+ const params = buildClientParams([parameters], [{ args: [
1862
+ { in: 'path', key: 'batch_id' },
1863
+ { in: 'query', key: 'limit' },
1864
+ { in: 'query', key: 'offset' }
1865
+ ] }]);
1866
+ return (options?.client ?? this.client).get({
1867
+ responseStyle: 'data',
1868
+ security: [{ scheme: 'bearer', type: 'http' }, {
1869
+ in: 'cookie',
1870
+ name: 'talqing_session',
1871
+ type: 'apiKey'
1872
+ }],
1873
+ url: '/v1/email/batches/{batch_id}/sends',
1874
+ ...options,
1875
+ ...params
1876
+ });
1877
+ }
1878
+ /**
1879
+ * Create Email Send
1880
+ *
1881
+ * Send these rows. **This mails real people and cannot be undone.**
1828
1882
  *
1829
- * At most 50 rows per call, named one by one — there is no "select all" and no
1830
- * bulk form of this. A row whose `to`, `subject` or `body` does not resolve
1831
- * comes back in `rejected` and stays a draft; fix it with
1832
- * `patch_email_batch_recipient` and try again.
1883
+ * Name `recipient_ids`, or pass `selection: "all_drafts"` for every reviewed
1884
+ * draft. A row whose `to`, `subject` or `body` does not resolve comes back in
1885
+ * `rejected` and stays a draft; fix it with `patch_email_batch_recipient`.
1833
1886
  *
1834
- * `from_email`, `from_name` and `reply_to` override the sender for this call
1835
- * only, and must be on a domain verified on the same Resend account.
1887
+ * The send is a row you can steer: `start_at` schedules it, `window` holds it
1888
+ * to business hours, `send_gap_seconds` paces it and `send_daily_cap` bounds
1889
+ * how many leave per day. Everything omitted comes from the batch. Cancel it
1890
+ * and every unsent row comes back as a draft.
1836
1891
  */
1837
- send(parameters, options) {
1838
- const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'batch_id' }, { key: 'sendEmailBatchRequest', map: 'body' }] }]);
1892
+ create(parameters, options) {
1893
+ const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'batch_id' }, { key: 'createEmailSendRequest', map: 'body' }] }]);
1839
1894
  return (options?.client ?? this.client).post({
1840
1895
  responseStyle: 'data',
1841
1896
  security: [{ scheme: 'bearer', type: 'http' }, {
@@ -1843,7 +1898,7 @@ export class Recipients2 extends HeyApiClient {
1843
1898
  name: 'talqing_session',
1844
1899
  type: 'apiKey'
1845
1900
  }],
1846
- url: '/v1/email/batches/{batch_id}/send',
1901
+ url: '/v1/email/batches/{batch_id}/sends',
1847
1902
  ...options,
1848
1903
  ...params,
1849
1904
  headers: {
@@ -1854,24 +1909,49 @@ export class Recipients2 extends HeyApiClient {
1854
1909
  });
1855
1910
  }
1856
1911
  /**
1857
- * Skip Email Batch Recipients
1912
+ * Get Email Send
1858
1913
  *
1859
- * Take drafted rows out of consideration. Reversible with `restore`.
1914
+ * One send: where its rows are, and when it next does something.
1860
1915
  *
1861
- * Takes either `recipient_ids` or `selection: "all_eligible"`, which here means
1862
- * every row that has a draft. The reversible verbs keep that shorthand while
1863
- * `send` does not, because the rule is about irreversibility rather than bulk.
1916
+ * `next_send_at` covers all three reasons a send waits — a start time, a closed
1917
+ * window, and a daily cap already spent.
1864
1918
  */
1865
- skip(parameters, options) {
1866
- const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'batch_id' }, { key: 'selectRecipientsRequest', map: 'body' }] }]);
1867
- return (options?.client ?? this.client).post({
1919
+ get(parameters, options) {
1920
+ const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'batch_id' }, { in: 'path', key: 'send_id' }] }]);
1921
+ return (options?.client ?? this.client).get({
1868
1922
  responseStyle: 'data',
1869
1923
  security: [{ scheme: 'bearer', type: 'http' }, {
1870
1924
  in: 'cookie',
1871
1925
  name: 'talqing_session',
1872
1926
  type: 'apiKey'
1873
1927
  }],
1874
- url: '/v1/email/batches/{batch_id}/skip',
1928
+ url: '/v1/email/batches/{batch_id}/sends/{send_id}',
1929
+ ...options,
1930
+ ...params
1931
+ });
1932
+ }
1933
+ /**
1934
+ * Patch Email Send
1935
+ *
1936
+ * Re-steer one send: its pace, its hours, its daily cap, its start time.
1937
+ *
1938
+ * Never its sender, and never which rows it holds — to change that, cancel it
1939
+ * and create another. `start_at` moves only before the send has begun.
1940
+ */
1941
+ update(parameters, options) {
1942
+ const params = buildClientParams([parameters], [{ args: [
1943
+ { in: 'path', key: 'batch_id' },
1944
+ { in: 'path', key: 'send_id' },
1945
+ { key: 'patchEmailSendRequest', map: 'body' }
1946
+ ] }]);
1947
+ return (options?.client ?? this.client).patch({
1948
+ responseStyle: 'data',
1949
+ security: [{ scheme: 'bearer', type: 'http' }, {
1950
+ in: 'cookie',
1951
+ name: 'talqing_session',
1952
+ type: 'apiKey'
1953
+ }],
1954
+ url: '/v1/email/batches/{batch_id}/sends/{send_id}',
1875
1955
  ...options,
1876
1956
  ...params,
1877
1957
  headers: {
@@ -1881,6 +1961,68 @@ export class Recipients2 extends HeyApiClient {
1881
1961
  }
1882
1962
  });
1883
1963
  }
1964
+ /**
1965
+ * Cancel Email Send
1966
+ *
1967
+ * Stop this send, and give every row it has not sent back as a draft.
1968
+ *
1969
+ * Not a destructive action: the drafts come back exactly as they were, ready
1970
+ * for another send. It is also the only way to change what a scheduled send
1971
+ * contains — a send's rows are fixed once it exists.
1972
+ */
1973
+ cancel(parameters, options) {
1974
+ const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'batch_id' }, { in: 'path', key: 'send_id' }] }]);
1975
+ return (options?.client ?? this.client).post({
1976
+ responseStyle: 'data',
1977
+ security: [{ scheme: 'bearer', type: 'http' }, {
1978
+ in: 'cookie',
1979
+ name: 'talqing_session',
1980
+ type: 'apiKey'
1981
+ }],
1982
+ url: '/v1/email/batches/{batch_id}/sends/{send_id}/cancel',
1983
+ ...options,
1984
+ ...params
1985
+ });
1986
+ }
1987
+ /**
1988
+ * Pause Email Send
1989
+ *
1990
+ * Stop sending. It takes hold on the next email, and nothing is lost —
1991
+ * the rows stay queued for whenever you resume.
1992
+ */
1993
+ pause(parameters, options) {
1994
+ const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'batch_id' }, { in: 'path', key: 'send_id' }] }]);
1995
+ return (options?.client ?? this.client).post({
1996
+ responseStyle: 'data',
1997
+ security: [{ scheme: 'bearer', type: 'http' }, {
1998
+ in: 'cookie',
1999
+ name: 'talqing_session',
2000
+ type: 'apiKey'
2001
+ }],
2002
+ url: '/v1/email/batches/{batch_id}/sends/{send_id}/pause',
2003
+ ...options,
2004
+ ...params
2005
+ });
2006
+ }
2007
+ /**
2008
+ * Resume Email Send
2009
+ *
2010
+ * Undo a pause and carry on from where it stopped.
2011
+ */
2012
+ resume(parameters, options) {
2013
+ const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'batch_id' }, { in: 'path', key: 'send_id' }] }]);
2014
+ return (options?.client ?? this.client).post({
2015
+ responseStyle: 'data',
2016
+ security: [{ scheme: 'bearer', type: 'http' }, {
2017
+ in: 'cookie',
2018
+ name: 'talqing_session',
2019
+ type: 'apiKey'
2020
+ }],
2021
+ url: '/v1/email/batches/{batch_id}/sends/{send_id}/resume',
2022
+ ...options,
2023
+ ...params
2024
+ });
2025
+ }
1884
2026
  }
1885
2027
  export class Batches2 extends HeyApiClient {
1886
2028
  /**
@@ -1922,13 +2064,16 @@ export class Batches2 extends HeyApiClient {
1922
2064
  * scraped contacts — and this runs on your account under your agreement.
1923
2065
  *
1924
2066
  * **Nothing is sent that a person has not selected.** Creating a batch only
1925
- * starts drafting; sending is a separate call over at most 50 named rows.
2067
+ * starts drafting; sending is a separate call that creates a send you can
2068
+ * schedule, pace, pause and cancel.
1926
2069
  *
1927
- * **Every row runs your task as it stands right now** — a task has no
1928
- * versions, so editing it mid-batch changes every row drafted after that.
2070
+ * **Every row runs the task's CURRENT published version**, re-read every pass,
2071
+ * so publishing a better prompt mid-batch changes every row drafted after it.
1929
2072
  *
1930
2073
  * `field_map` points `to`, `subject` and `body` at a column of your list or at
1931
- * a field the task produces. An invalid batch is a 400 listing every problem.
2074
+ * a field the task produces. `window` is when email may LEAVE, inherited by
2075
+ * every send; drafting is not restricted by hours. An invalid batch is a 400
2076
+ * listing every problem.
1932
2077
  *
1933
2078
  * There is no spend cap: every row runs the task and is billed, so a 5 000-row
1934
2079
  * batch doing research costs 5 000 task runs whether or not anything is sent.
@@ -1955,9 +2100,10 @@ export class Batches2 extends HeyApiClient {
1955
2100
  /**
1956
2101
  * Get Email Batch
1957
2102
  *
1958
- * One batch: its policy, its per-status counts, what drafting has cost so
1959
- * far, and — while it is waiting on a start time or a closed window —
1960
- * `next_draft_at`.
2103
+ * One batch: its policy, its per-status counts and what drafting has cost.
2104
+ *
2105
+ * `drafted_versions` says which published version of the task wrote how many
2106
+ * rows, and `sent_today` how much of `send_daily_cap` is left today.
1961
2107
  */
1962
2108
  get(parameters, options) {
1963
2109
  const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'batch_id' }] }]);
@@ -1978,10 +2124,12 @@ export class Batches2 extends HeyApiClient {
1978
2124
  *
1979
2125
  * Edit a batch's policy. The next drafting pass reads the new row.
1980
2126
  *
1981
- * Pacing and the calling window are editable at any time. The sender, the body
1982
- * format and the field map freeze once the batch has sent anything changing
1983
- * them then would make the rows already delivered no longer describe what they
1984
- * were sent as. `start_at` moves only while the batch is still scheduled.
2127
+ * Pacing, the window and the daily cap are editable at any time; the sending
2128
+ * half is the DEFAULT for the next send, and a send already created carries its
2129
+ * own copy. The sender, the body format and the field map freeze once the batch
2130
+ * has sent anything changing them then would make the rows already delivered
2131
+ * no longer describe what they were sent as. `start_at` moves only while the
2132
+ * batch is still scheduled.
1985
2133
  */
1986
2134
  update(parameters, options) {
1987
2135
  const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'batch_id' }, { key: 'patchEmailBatchRequest', map: 'body' }] }]);
@@ -2005,12 +2153,12 @@ export class Batches2 extends HeyApiClient {
2005
2153
  /**
2006
2154
  * Cancel Email Batch
2007
2155
  *
2008
- * Stop drafting for good. This is the only terminal action a batch cannot
2009
- * be deleted, because it is the record of what was sent to whom.
2156
+ * Stop drafting for good. A batch cannot be deleted, because it is the
2157
+ * record of what was sent to whom.
2010
2158
  *
2011
- * Rows already drafted are **not** touched: cancelling stops drafting, and
2012
- * drafts already produced are still worth reviewing and sending. Rows never
2013
- * reached report as `canceled`.
2159
+ * Rows already drafted are **not** touched and neither is any send: cancelling
2160
+ * stops drafting, and drafts already produced are still worth reviewing and
2161
+ * sending. Rows never reached report as `canceled`.
2014
2162
  */
2015
2163
  cancel(parameters, options) {
2016
2164
  const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'batch_id' }] }]);
@@ -2070,6 +2218,9 @@ export class Batches2 extends HeyApiClient {
2070
2218
  get recipients() {
2071
2219
  return this._recipients ?? (this._recipients = new Recipients2({ client: this.client }));
2072
2220
  }
2221
+ get sends() {
2222
+ return this._sends ?? (this._sends = new Sends({ client: this.client }));
2223
+ }
2073
2224
  }
2074
2225
  export class Senders extends HeyApiClient {
2075
2226
  /**
@@ -2213,8 +2364,10 @@ export class Triggers extends HeyApiClient {
2213
2364
  * Patch Integration Trigger
2214
2365
  *
2215
2366
  * Update a trigger: reassign the agent, change reply mode, enable or
2216
- * disable it. Omitted fields are left unchanged. The same checks as creation
2217
- * run when enabling.
2367
+ * disable it.
2368
+ *
2369
+ * Omitted fields are left unchanged, and enabling one runs the same checks
2370
+ * creating it did.
2218
2371
  */
2219
2372
  update(parameters, options) {
2220
2373
  const params = buildClientParams([parameters], [{ args: [
@@ -2751,6 +2904,32 @@ export class Observability extends HeyApiClient {
2751
2904
  });
2752
2905
  }
2753
2906
  }
2907
+ export class Functions extends HeyApiClient {
2908
+ /**
2909
+ * Describe Function
2910
+ *
2911
+ * The full argument schema of one function, by name.
2912
+ *
2913
+ * Every function's arguments are fetched here rather than shown up front, so
2914
+ * call this before the first time you use one. Two exceptions, which carry
2915
+ * their own shape because they would otherwise be uncallable: this function
2916
+ * and `describe_schema`.
2917
+ */
2918
+ get(parameters, options) {
2919
+ const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'name' }] }]);
2920
+ return (options?.client ?? this.client).get({
2921
+ responseStyle: 'data',
2922
+ security: [{ scheme: 'bearer', type: 'http' }, {
2923
+ in: 'cookie',
2924
+ name: 'talqing_session',
2925
+ type: 'apiKey'
2926
+ }],
2927
+ url: '/v1/schemas/functions/{name}',
2928
+ ...options,
2929
+ ...params
2930
+ });
2931
+ }
2932
+ }
2754
2933
  export class Schemas extends HeyApiClient {
2755
2934
  /**
2756
2935
  * Describe Schema
@@ -2782,6 +2961,9 @@ export class Schemas extends HeyApiClient {
2782
2961
  ...params
2783
2962
  });
2784
2963
  }
2964
+ get functions() {
2965
+ return this._functions ?? (this._functions = new Functions({ client: this.client }));
2966
+ }
2785
2967
  }
2786
2968
  export class Secrets extends HeyApiClient {
2787
2969
  /**
@@ -2860,8 +3042,8 @@ export class Runs extends HeyApiClient {
2860
3042
  *
2861
3043
  * This task's runs, newest first, each with its output, trace and cost.
2862
3044
  *
2863
- * A run records the task's *name* and nothing else about the definition it ran
2864
- * under, so two runs either side of an edit are indistinguishable here.
3045
+ * `task_version` says which published definition each one ran, and is null for
3046
+ * a run of the draft.
2865
3047
  */
2866
3048
  list(parameters, options) {
2867
3049
  const params = buildClientParams([parameters], [{ args: [
@@ -2890,10 +3072,12 @@ export class Runs extends HeyApiClient {
2890
3072
  * the MCP servers spend your credits, and the model spends your tokens. A task
2891
3073
  * that books a slot, charges a card or sends a message will do so.
2892
3074
  *
2893
- * `vars` must match what the task declares an unknown name is refused rather
2894
- * than dropped. The response is the whole run: the structured `output`, a
2895
- * `trace` of every tool call, the steps used and what the tokens cost. On
2896
- * failure `error.type` says whose problem it is. Secrets are redacted.
3075
+ * Runs the published version unless `version` names another one, or `"draft"`
3076
+ * to run the unpublished config. `vars` must match what that version declares
3077
+ * an unknown name is refused rather than dropped. The response is the whole
3078
+ * run: the structured `output`, a `trace` of every tool call, the steps used
3079
+ * and what the tokens cost. On failure `error.type` says whose problem it is.
3080
+ * Secrets are redacted.
2897
3081
  */
2898
3082
  create(parameters, options) {
2899
3083
  const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'task_id' }, { key: 'runTaskRequest', map: 'body' }] }]);
@@ -2939,6 +3123,55 @@ export class Runs extends HeyApiClient {
2939
3123
  });
2940
3124
  }
2941
3125
  }
3126
+ export class Versions2 extends HeyApiClient {
3127
+ /**
3128
+ * Get Task Version
3129
+ *
3130
+ * Fetch what one published version of a task actually contains.
3131
+ *
3132
+ * `get_task` lists the versions and when each was published; this returns the
3133
+ * frozen definition itself — prompt, model, output fields and the tool
3134
+ * versions it pinned, exactly as they were at that publish.
3135
+ */
3136
+ get(parameters, options) {
3137
+ const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'task_id' }, { in: 'path', key: 'version' }] }]);
3138
+ return (options?.client ?? this.client).get({
3139
+ responseStyle: 'data',
3140
+ security: [{ scheme: 'bearer', type: 'http' }, {
3141
+ in: 'cookie',
3142
+ name: 'talqing_session',
3143
+ type: 'apiKey'
3144
+ }],
3145
+ url: '/v1/tasks/{task_id}/versions/{version}',
3146
+ ...options,
3147
+ ...params
3148
+ });
3149
+ }
3150
+ /**
3151
+ * Rollback Task Version
3152
+ *
3153
+ * Put an earlier published version of a task back into production.
3154
+ *
3155
+ * That version becomes live **immediately** and **replaces the current draft**,
3156
+ * so any unpublished edits are lost. No new version is created. The restored
3157
+ * draft tracks each tool's latest published version, not the ones this version
3158
+ * pinned.
3159
+ */
3160
+ rollback(parameters, options) {
3161
+ const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'task_id' }, { in: 'path', key: 'version' }] }]);
3162
+ return (options?.client ?? this.client).post({
3163
+ responseStyle: 'data',
3164
+ security: [{ scheme: 'bearer', type: 'http' }, {
3165
+ in: 'cookie',
3166
+ name: 'talqing_session',
3167
+ type: 'apiKey'
3168
+ }],
3169
+ url: '/v1/tasks/{task_id}/versions/{version}/rollback',
3170
+ ...options,
3171
+ ...params
3172
+ });
3173
+ }
3174
+ }
2942
3175
  export class Tasks2 extends HeyApiClient {
2943
3176
  /**
2944
3177
  * List Tasks
@@ -2947,9 +3180,8 @@ export class Tasks2 extends HeyApiClient {
2947
3180
  *
2948
3181
  * A task is an agent nobody talks to: a prompt, one LLM, tools and MCP
2949
3182
  * servers, the variables it takes as input, and the typed result it must
2950
- * produce. `last_run` says how the most recent run of each one went, so a
2951
- * task whose prompt stopped calling `submit_result` is visible here rather
2952
- * than only in its own history.
3183
+ * produce. Each item carries the full draft config, the published version
3184
+ * number (null while it has never been published), and `last_run`.
2953
3185
  */
2954
3186
  list(parameters, options) {
2955
3187
  const params = buildClientParams([parameters], [{ args: [{ in: 'query', key: 'limit' }, { in: 'query', key: 'offset' }] }]);
@@ -2968,18 +3200,13 @@ export class Tasks2 extends HeyApiClient {
2968
3200
  /**
2969
3201
  * Create Task
2970
3202
  *
2971
- * Create an agent task.
2972
- *
2973
- * A task has no draft and no publish step: it is valid the moment it saves and
2974
- * callable immediately. An invalid config is a 400 listing every problem and
2975
- * nothing is stored.
3203
+ * Create an agent task: an agent nobody talks to, which takes named inputs
3204
+ * and returns a typed result.
2976
3205
  *
2977
3206
  * `output` is what makes this a task rather than a chat agent — declare the
2978
3207
  * fields the model must produce and it is given a `submit_result` tool built
2979
- * from them. `vars` are its inputs, read as `{{vars.name}}`.
2980
- *
2981
- * `warnings` reports the non-fatal problems. There is no publish screen to
2982
- * show them on, so read them here.
3208
+ * from them. `vars` are its inputs, read as `{{vars.name}}`. The task starts
3209
+ * unpublished; publish it before running it.
2983
3210
  */
2984
3211
  create(parameters, options) {
2985
3212
  const params = buildClientParams([parameters], [{ args: [{ key: 'createTaskRequest', map: 'body' }] }]);
@@ -3003,7 +3230,8 @@ export class Tasks2 extends HeyApiClient {
3003
3230
  /**
3004
3231
  * Delete Task
3005
3232
  *
3006
- * Delete a task. Its run history survives, still named after it.
3233
+ * Delete a task and its published versions. Its runs survive, still named
3234
+ * after it.
3007
3235
  */
3008
3236
  delete(parameters, options) {
3009
3237
  const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'task_id' }] }]);
@@ -3022,7 +3250,7 @@ export class Tasks2 extends HeyApiClient {
3022
3250
  /**
3023
3251
  * Get Task
3024
3252
  *
3025
- * Fetch one task's config and how its last run went.
3253
+ * Fetch one task's draft config, published version, history and last run.
3026
3254
  */
3027
3255
  get(parameters, options) {
3028
3256
  const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'task_id' }] }]);
@@ -3041,12 +3269,11 @@ export class Tasks2 extends HeyApiClient {
3041
3269
  /**
3042
3270
  * Update Task
3043
3271
  *
3044
- * Replace a task's config.
3272
+ * Replace the task's draft config with the one supplied.
3045
3273
  *
3046
- * The whole config is sent, so include every field you mean to keep, and it is
3047
- * validated exactly as `create_task` is. The edit takes effect on the next run
3048
- * a task has no versions, so there is no old wording to go back to and no
3049
- * record of which definition produced an earlier run.
3274
+ * The whole config is sent, so include every field you mean to keep. Writes
3275
+ * land on the draft only runs and email batches keep using the published
3276
+ * version until you publish again.
3050
3277
  */
3051
3278
  update(parameters, options) {
3052
3279
  const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'task_id' }, { key: 'patchTaskRequest', map: 'body' }] }]);
@@ -3067,9 +3294,59 @@ export class Tasks2 extends HeyApiClient {
3067
3294
  }
3068
3295
  });
3069
3296
  }
3297
+ /**
3298
+ * Publish Task
3299
+ *
3300
+ * Freeze the current draft as a new immutable version and make it live.
3301
+ *
3302
+ * Validation must pass. Publishing pins every attached tool to the tool
3303
+ * version live right now, so republishing a tool does not change this task
3304
+ * until the task is published again.
3305
+ */
3306
+ publish(parameters, options) {
3307
+ const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'task_id' }] }]);
3308
+ return (options?.client ?? this.client).post({
3309
+ responseStyle: 'data',
3310
+ security: [{ scheme: 'bearer', type: 'http' }, {
3311
+ in: 'cookie',
3312
+ name: 'talqing_session',
3313
+ type: 'apiKey'
3314
+ }],
3315
+ url: '/v1/tasks/{task_id}/publish',
3316
+ ...options,
3317
+ ...params
3318
+ });
3319
+ }
3320
+ /**
3321
+ * Validate Task
3322
+ *
3323
+ * Run publish-grade validation on the draft without publishing it.
3324
+ *
3325
+ * Covers everything a draft write checks plus what publishing adds: a
3326
+ * workspace API key for the model, at least one output field, the operation
3327
+ * trees of the attached tools, and the email batches already drafting with
3328
+ * this task. Returns errors (blocking) and warnings (advisory).
3329
+ */
3330
+ validate(parameters, options) {
3331
+ const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'task_id' }] }]);
3332
+ return (options?.client ?? this.client).post({
3333
+ responseStyle: 'data',
3334
+ security: [{ scheme: 'bearer', type: 'http' }, {
3335
+ in: 'cookie',
3336
+ name: 'talqing_session',
3337
+ type: 'apiKey'
3338
+ }],
3339
+ url: '/v1/tasks/{task_id}/validate',
3340
+ ...options,
3341
+ ...params
3342
+ });
3343
+ }
3070
3344
  get runs() {
3071
3345
  return this._runs ?? (this._runs = new Runs({ client: this.client }));
3072
3346
  }
3347
+ get versions() {
3348
+ return this._versions ?? (this._versions = new Versions2({ client: this.client }));
3349
+ }
3073
3350
  }
3074
3351
  export class Accounts extends HeyApiClient {
3075
3352
  /**
@@ -3471,7 +3748,7 @@ export class Telephony extends HeyApiClient {
3471
3748
  return this._providers ?? (this._providers = new Providers({ client: this.client }));
3472
3749
  }
3473
3750
  }
3474
- export class Versions2 extends HeyApiClient {
3751
+ export class Versions3 extends HeyApiClient {
3475
3752
  /**
3476
3753
  * Get Tool Version
3477
3754
  *
@@ -3727,7 +4004,7 @@ export class Tools2 extends HeyApiClient {
3727
4004
  });
3728
4005
  }
3729
4006
  get versions() {
3730
- return this._versions ?? (this._versions = new Versions2({ client: this.client }));
4007
+ return this._versions ?? (this._versions = new Versions3({ client: this.client }));
3731
4008
  }
3732
4009
  }
3733
4010
  export class Webhooks extends HeyApiClient {