@omelhorsite/sdk 0.17.0 → 0.18.0

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/index.js CHANGED
@@ -951,7 +951,10 @@ var OMS_SCOPES = [
951
951
  "news:read",
952
952
  "news:write",
953
953
  "cron:read",
954
- "cron:write"
954
+ "cron:write",
955
+ "cron:run",
956
+ "bots:read",
957
+ "bots:write"
955
958
  ];
956
959
  var DEFAULT_REFRESH_SKEW_MS = 60000;
957
960
  var REFRESH_REUSE_WINDOW_MS = 5000;
@@ -10483,6 +10486,8 @@ function modelBody(input) {
10483
10486
  body["capabilities"] = { ...input.capabilities };
10484
10487
  if (input.limits !== undefined)
10485
10488
  body["limits"] = { ...input.limits };
10489
+ if (input.metadata !== undefined)
10490
+ body["metadata"] = { ...input.metadata };
10486
10491
  return body;
10487
10492
  }
10488
10493
  function assignmentBody(input) {
@@ -10516,6 +10521,12 @@ class AdminLlmProvidersNamespace extends Resource {
10516
10521
  async availableModels(id, input = {}, options = {}) {
10517
10522
  return this.http.get(`/admin/llm_providers/${encodeURIComponent(id)}/available_models`, { ...input.fresh ? { query: { fresh: 1 } } : {}, ...options });
10518
10523
  }
10524
+ async modelEndpoints(id, input, options = {}) {
10525
+ return this.http.get(`/admin/llm_providers/${encodeURIComponent(id)}/model_endpoints`, {
10526
+ ...options,
10527
+ query: { model_id: input.modelId, ...input.fresh ? { fresh: 1 } : {} }
10528
+ });
10529
+ }
10519
10530
  async test(id, input = {}, options = {}) {
10520
10531
  const body = {};
10521
10532
  if (input.modelId !== undefined)
@@ -11423,6 +11434,8 @@ function feedBody(input) {
11423
11434
  body["retention_days"] = input.retentionDays;
11424
11435
  if (input.enabled !== undefined)
11425
11436
  body["enabled"] = input.enabled;
11437
+ if (input.includedFeedIds !== undefined)
11438
+ body["included_feed_ids"] = [...input.includedFeedIds];
11426
11439
  return body;
11427
11440
  }
11428
11441
 
@@ -11507,7 +11520,7 @@ class NewsScriptsNamespace extends Resource {
11507
11520
  // src/resources/content/news/sources.ts
11508
11521
  var NEWS_SOURCE_HEALTHS = ["unknown", "ok", "error"];
11509
11522
  var NEWS_SOURCE_DISABLE_AFTER_FAILURES = 20;
11510
- var NEWS_SOURCE_FILTER_COLUMNS = Object.freeze(["name", "health", "enabled", "news_feed_id", "news_script_id"]);
11523
+ var NEWS_SOURCE_FILTER_COLUMNS = Object.freeze(["name", "health", "enabled", "news_feed_id", "news_script_id", "cron_job_id"]);
11511
11524
 
11512
11525
  class NewsSourcesNamespace extends Resource {
11513
11526
  async list(params = {}, options = {}) {
@@ -11517,7 +11530,8 @@ class NewsSourcesNamespace extends Resource {
11517
11530
  health: params.health,
11518
11531
  enabled: params.enabled,
11519
11532
  news_feed_id: params.feedId,
11520
- news_script_id: params.scriptId
11533
+ news_script_id: params.scriptId,
11534
+ cron_job_id: params.jobId
11521
11535
  }
11522
11536
  };
11523
11537
  return paginate(params, 100, (at) => this.http.get("/news_sources", { ...options, query: listQuery(params, at, base) }));
@@ -11528,7 +11542,8 @@ class NewsSourcesNamespace extends Resource {
11528
11542
  async create(input, options = {}) {
11529
11543
  return this.http.post("/news_sources", {
11530
11544
  name: input.name,
11531
- news_script_id: input.scriptId,
11545
+ ...input.scriptId === undefined ? {} : { news_script_id: input.scriptId },
11546
+ ...input.jobId === undefined ? {} : { cron_job_id: input.jobId },
11532
11547
  ...input.newsFeedId === undefined ? {} : { news_feed_id: input.newsFeedId },
11533
11548
  ...input.config === undefined ? {} : { config: input.config },
11534
11549
  ...input.pollIntervalMinutes === undefined ? {} : { poll_interval_minutes: input.pollIntervalMinutes },
@@ -11540,6 +11555,7 @@ class NewsSourcesNamespace extends Resource {
11540
11555
  ...input.name === undefined ? {} : { name: input.name },
11541
11556
  ...input.newsFeedId === undefined ? {} : { news_feed_id: input.newsFeedId },
11542
11557
  ...input.scriptId === undefined ? {} : { news_script_id: input.scriptId },
11558
+ ...input.jobId === undefined ? {} : { cron_job_id: input.jobId },
11543
11559
  ...input.config === undefined ? {} : { config: input.config },
11544
11560
  ...input.pollIntervalMinutes === undefined ? {} : { poll_interval_minutes: input.pollIntervalMinutes },
11545
11561
  ...input.enabled === undefined ? {} : { enabled: input.enabled },
@@ -11549,6 +11565,13 @@ class NewsSourcesNamespace extends Resource {
11549
11565
  async delete(id, options = {}) {
11550
11566
  await this.http.delete(`/news_sources/${encodeURIComponent(id)}`, options);
11551
11567
  }
11568
+ async test(input, options = {}) {
11569
+ return this.http.post("/news_sources/test", {
11570
+ ...input.scriptId === undefined ? {} : { news_script_id: input.scriptId },
11571
+ ...input.jobId === undefined ? {} : { cron_job_id: input.jobId },
11572
+ config: input.config ?? {}
11573
+ }, { retry: false, ...options });
11574
+ }
11552
11575
  async run(id, options = {}) {
11553
11576
  return this.http.post(`/news_sources/${encodeURIComponent(id)}/run`, undefined, { retry: false, ...options });
11554
11577
  }
@@ -11567,6 +11590,9 @@ class NewsNamespace extends Resource {
11567
11590
  this.scripts = new NewsScriptsNamespace(http);
11568
11591
  this.items = new NewsItemsNamespace(http);
11569
11592
  }
11593
+ async discover(url, options = {}) {
11594
+ return this.http.get("/news/discover", { ...options, query: { url } });
11595
+ }
11570
11596
  }
11571
11597
 
11572
11598
  // src/resources/content/jokes.ts
@@ -11640,6 +11666,8 @@ var NOTIFICATION_KINDS = [
11640
11666
  "news_source_failing",
11641
11667
  "cron_run_failed",
11642
11668
  "cron_run_done",
11669
+ "bot_message_received",
11670
+ "bot_needs_human",
11643
11671
  "oauth_application_approved",
11644
11672
  "oauth_application_rejected",
11645
11673
  "admin_oauth_application_submitted",
@@ -11788,21 +11816,27 @@ var CRON_JOB_SCOPES = Object.freeze([
11788
11816
  "tools:read",
11789
11817
  "tools:write",
11790
11818
  "blogs:read",
11791
- "blogs:write"
11819
+ "blogs:write",
11820
+ "bots:read",
11821
+ "bots:write",
11822
+ "cron:run"
11792
11823
  ]);
11793
11824
  var CRON_JOB_HEALTHS = Object.freeze(["unknown", "ok", "error"]);
11825
+ var CRON_JOB_RUNTIMES = Object.freeze(["sandbox", "full"]);
11794
11826
  var CRON_JOB_DISABLE_AFTER_FAILURES = 10;
11795
11827
  var CRON_JOB_MAX_CODE_BYTES = 256 * 1024;
11796
11828
  var CRON_JOB_MAX_STATE_BYTES = 256 * 1024;
11797
11829
  var CRON_JOB_MAX_CONFIG_BYTES = 64 * 1024;
11798
11830
  var CRON_JOB_MIN_INTERVAL_MINUTES = 5;
11831
+ var CRON_SCHEDULES_MAX_PER_JOB = 200;
11799
11832
  var CRON_JOB_MIN_TIMEOUT_SECONDS = 5;
11800
11833
  var CRON_JOB_MAX_TIMEOUT_SECONDS = 1200;
11801
11834
  var CRON_JOB_BASE_MAX_TIMEOUT_SECONDS = 120;
11802
11835
  var CRON_VAR_TYPES = Object.freeze(["string", "text", "number", "boolean", "list", "json"]);
11836
+ var CRON_SCHEDULE_FILTER_COLUMNS = Object.freeze(["cron_job_id", "enabled"]);
11803
11837
  var CRON_JOB_FILTER_COLUMNS = Object.freeze(["name", "enabled", "health", "template_slug"]);
11804
11838
  var CRON_RUN_STATUSES = Object.freeze(["queued", "running", "ok", "error", "timeout", "skipped"]);
11805
- var CRON_RUN_TRIGGERS = Object.freeze(["schedule", "manual", "test"]);
11839
+ var CRON_RUN_TRIGGERS = Object.freeze(["schedule", "manual", "api", "job", "test"]);
11806
11840
  var CRON_RUN_FILTER_COLUMNS = Object.freeze(["cron_job_id", "status", "trigger"]);
11807
11841
 
11808
11842
  class CronJobsNamespace extends Resource {
@@ -11822,17 +11856,36 @@ class CronJobsNamespace extends Resource {
11822
11856
  async delete(id, options = {}) {
11823
11857
  await this.http.delete(`/cron_jobs/${encodeURIComponent(id)}`, options);
11824
11858
  }
11825
- async run(id, options = {}) {
11826
- return this.http.post(`/cron_jobs/${encodeURIComponent(id)}/run`, {}, { retry: false, ...options });
11859
+ async run(id, input = {}, options = {}) {
11860
+ return this.http.post(`/cron_jobs/${encodeURIComponent(id)}/run`, runBody(input), { retry: false, ...options });
11827
11861
  }
11828
- async test(id, options = {}) {
11829
- return this.http.post(`/cron_jobs/${encodeURIComponent(id)}/test`, {}, { retry: false, ...options });
11862
+ async test(id, input = {}, options = {}) {
11863
+ return this.http.post(`/cron_jobs/${encodeURIComponent(id)}/test`, runBody(input), { retry: false, ...options });
11830
11864
  }
11831
11865
  async check(code, options = {}) {
11832
11866
  return this.http.post("/cron_jobs/check", { code }, options);
11833
11867
  }
11834
11868
  }
11835
11869
 
11870
+ class CronSchedulesNamespace extends Resource {
11871
+ async list(params = {}, options = {}) {
11872
+ const base = { order: "created_at:asc", exactSearch: { cron_job_id: params.jobId, enabled: params.enabled } };
11873
+ return paginate(params, 50, (at) => this.http.get("/cron_schedules", { ...options, query: listQuery(params, at, base) }));
11874
+ }
11875
+ async get(id, options = {}) {
11876
+ return this.http.get(`/cron_schedules/${encodeURIComponent(id)}`, options);
11877
+ }
11878
+ async create(input, options = {}) {
11879
+ return this.http.post("/cron_schedules", { cron_job_id: input.jobId, ...scheduleBody(input) }, { retry: false, ...options });
11880
+ }
11881
+ async update(id, input, options = {}) {
11882
+ return this.http.patch(`/cron_schedules/${encodeURIComponent(id)}`, scheduleBody(input), options);
11883
+ }
11884
+ async delete(id, options = {}) {
11885
+ await this.http.delete(`/cron_schedules/${encodeURIComponent(id)}`, options);
11886
+ }
11887
+ }
11888
+
11836
11889
  class CronRunsNamespace extends Resource {
11837
11890
  async list(params = {}, options = {}) {
11838
11891
  const base = { order: "created_at:desc", exactSearch: { cron_job_id: params.jobId, status: params.status } };
@@ -11854,18 +11907,130 @@ class CronTemplatesNamespace extends Resource {
11854
11907
  return this.http.get(`/cron_templates/${encodeURIComponent(slug)}`, options);
11855
11908
  }
11856
11909
  }
11910
+ var CRON_RECORD_COLLECTION_MAX = 64;
11911
+ var CRON_RECORD_KEY_MAX = 200;
11912
+ var CRON_RECORD_MAX_DATA_BYTES = 64 * 1024;
11913
+ var CRON_RECORD_MAX_PER_JOB = 200000;
11914
+ var CRON_RECORD_MAX_PER_BATCH = 500;
11915
+ var CRON_RECORD_MAX_PER_DELETE = 1e4;
11916
+ var CRON_RECORD_MAX_WHERE = 5;
11917
+ var CRON_RECORD_MAX_LIMIT = 500;
11918
+ async function cronRecordKey(value) {
11919
+ if (value.length <= CRON_RECORD_KEY_MAX)
11920
+ return value;
11921
+ const subtle = globalThis.crypto?.subtle;
11922
+ if (!subtle)
11923
+ throw new TypeError("A key past 200 characters needs WebCrypto to shorten. Pass a shorter key on a runtime without it.");
11924
+ const bytes = new Uint8Array(await subtle.digest("SHA-256", new TextEncoder().encode(value)));
11925
+ let hex = "";
11926
+ for (const byte of bytes)
11927
+ hex += byte.toString(16).padStart(2, "0");
11928
+ return `${value.slice(0, CRON_RECORD_KEY_MAX - 33)}#${hex.slice(0, 32)}`;
11929
+ }
11930
+
11931
+ class CronRecordsNamespace extends Resource {
11932
+ async list(jobId, params, options = {}) {
11933
+ return this.http.get(`/cron_jobs/${encodeURIComponent(jobId)}/records`, {
11934
+ ...options,
11935
+ query: await listRecordsQuery(params)
11936
+ });
11937
+ }
11938
+ async* all(jobId, collection, params = {}, options = {}) {
11939
+ let cursor = null;
11940
+ for (;; ) {
11941
+ const page = await this.list(jobId, { ...params, collection, cursor }, options);
11942
+ for (const record of page.records)
11943
+ yield record;
11944
+ if (!page.next_cursor)
11945
+ return;
11946
+ cursor = page.next_cursor;
11947
+ }
11948
+ }
11949
+ async get(jobId, collection, key, options = {}) {
11950
+ const page = await this.list(jobId, { collection, keys: [key], limit: 1 }, options);
11951
+ return page.records[0] ?? null;
11952
+ }
11953
+ async put(jobId, collection, key, data = {}, at, options = {}) {
11954
+ return this.putMany(jobId, [{ collection, key, data, at }], options);
11955
+ }
11956
+ async putMany(jobId, records, options = {}) {
11957
+ const total = { created: 0, updated: 0 };
11958
+ for (let from = 0;from < records.length; from += CRON_RECORD_MAX_PER_BATCH) {
11959
+ const chunk = await Promise.all(records.slice(from, from + CRON_RECORD_MAX_PER_BATCH).map(recordBody));
11960
+ const answer = await this.http.post(`/cron_jobs/${encodeURIComponent(jobId)}/records`, { records: chunk }, { retry: false, ...options });
11961
+ total.created += answer.created;
11962
+ total.updated += answer.updated;
11963
+ }
11964
+ return total;
11965
+ }
11966
+ async remove(jobId, collection, key, options = {}) {
11967
+ return this.http.delete(`/cron_jobs/${encodeURIComponent(jobId)}/records`, {
11968
+ ...options,
11969
+ query: { collection, key: await cronRecordKey(key) }
11970
+ });
11971
+ }
11972
+ async removeMany(jobId, collection, keys, options = {}) {
11973
+ return this.http.delete(`/cron_jobs/${encodeURIComponent(jobId)}/records`, {
11974
+ ...options,
11975
+ query: { collection, keys: await Promise.all(keys.map(cronRecordKey)) }
11976
+ });
11977
+ }
11978
+ async prune(jobId, collection, options, requestOptions = {}) {
11979
+ return this.http.delete(`/cron_jobs/${encodeURIComponent(jobId)}/records`, {
11980
+ ...requestOptions,
11981
+ query: { collection, before: asIso(options.before), on: options.on }
11982
+ });
11983
+ }
11984
+ async collections(jobId, options = {}) {
11985
+ return this.http.get(`/cron_jobs/${encodeURIComponent(jobId)}/records/collections`, options);
11986
+ }
11987
+ for(jobId) {
11988
+ return {
11989
+ list: (params, options) => this.list(jobId, params, options),
11990
+ all: (collection, params, options) => this.all(jobId, collection, params, options),
11991
+ get: (collection, key, options) => this.get(jobId, collection, key, options),
11992
+ put: (collection, key, data, at, options) => this.put(jobId, collection, key, data, at, options),
11993
+ putMany: (records, options) => this.putMany(jobId, records, options),
11994
+ remove: (collection, key, options) => this.remove(jobId, collection, key, options),
11995
+ removeMany: (collection, keys, options) => this.removeMany(jobId, collection, keys, options),
11996
+ prune: (collection, options, requestOptions) => this.prune(jobId, collection, options, requestOptions),
11997
+ collections: (options) => this.collections(jobId, options)
11998
+ };
11999
+ }
12000
+ }
11857
12001
 
11858
12002
  class CronNamespace extends Resource {
11859
12003
  jobs;
12004
+ schedules;
11860
12005
  runs;
11861
12006
  templates;
12007
+ records;
11862
12008
  constructor(http) {
11863
12009
  super(http);
11864
12010
  this.jobs = new CronJobsNamespace(http);
12011
+ this.schedules = new CronSchedulesNamespace(http);
11865
12012
  this.runs = new CronRunsNamespace(http);
11866
12013
  this.templates = new CronTemplatesNamespace(http);
12014
+ this.records = new CronRecordsNamespace(http);
11867
12015
  }
11868
12016
  }
12017
+ function scheduleBody(input) {
12018
+ const body = {};
12019
+ if (input.cron !== undefined)
12020
+ body["cron"] = input.cron;
12021
+ if (input.timezone !== undefined)
12022
+ body["timezone"] = input.timezone;
12023
+ if (input.name !== undefined)
12024
+ body["name"] = input.name;
12025
+ if (input.params !== undefined)
12026
+ body["params"] = input.params;
12027
+ if (input.enabled !== undefined)
12028
+ body["enabled"] = input.enabled;
12029
+ return body;
12030
+ }
12031
+ function runBody(input) {
12032
+ return input.params === undefined ? {} : { params: input.params };
12033
+ }
11869
12034
  function jobBody(input) {
11870
12035
  const body = {};
11871
12036
  if (input.name !== undefined)
@@ -11880,6 +12045,8 @@ function jobBody(input) {
11880
12045
  body["code"] = input.code;
11881
12046
  if (input.scopes !== undefined)
11882
12047
  body["scopes"] = [...input.scopes];
12048
+ if (input.output !== undefined)
12049
+ body["output"] = input.output;
11883
12050
  if (input.config !== undefined)
11884
12051
  body["config"] = input.config;
11885
12052
  if (input.secrets !== undefined)
@@ -11902,6 +12069,266 @@ function jobBody(input) {
11902
12069
  body["template_slug"] = input.templateSlug;
11903
12070
  return body;
11904
12071
  }
12072
+ async function listRecordsQuery(params) {
12073
+ const query = { collection: params.collection };
12074
+ if (params.limit !== undefined)
12075
+ query["limit"] = params.limit;
12076
+ if (params.cursor)
12077
+ query["cursor"] = params.cursor;
12078
+ if (params.since !== undefined)
12079
+ query["since"] = asIso(params.since);
12080
+ if (params.until !== undefined)
12081
+ query["until"] = asIso(params.until);
12082
+ if (params.keys !== undefined)
12083
+ query["keys"] = await Promise.all(params.keys.map(cronRecordKey));
12084
+ if (params.where !== undefined)
12085
+ query["where"] = params.where;
12086
+ if (params.order !== undefined)
12087
+ query["order"] = params.order;
12088
+ if (params.count)
12089
+ query["count"] = true;
12090
+ return query;
12091
+ }
12092
+ async function recordBody(input) {
12093
+ return {
12094
+ collection: input.collection,
12095
+ key: await cronRecordKey(input.key),
12096
+ data: input.data ?? {},
12097
+ ...input.at === undefined || input.at === null ? {} : { at: asIso(input.at) }
12098
+ };
12099
+ }
12100
+ function asIso(value) {
12101
+ return value instanceof Date ? value.toISOString() : value;
12102
+ }
12103
+
12104
+ // src/resources/bots.ts
12105
+ var BOT_CHANNEL_KINDS = Object.freeze(["telegram"]);
12106
+ var BOT_CHANNEL_HEALTHS = Object.freeze(["unknown", "ok", "error"]);
12107
+ var BOT_PLUGINS = Object.freeze(["inbox", "responder"]);
12108
+ var BOT_MESSAGE_MAX_TEXT = 4096;
12109
+ var BOT_CHANNEL_FILTER_COLUMNS = Object.freeze(["name", "kind", "enabled"]);
12110
+ var BOT_CONTACT_KINDS = Object.freeze(["private", "group", "supergroup", "channel"]);
12111
+ var BOT_CONTACT_FILTER_COLUMNS = Object.freeze(["bot_channel_id", "external_id", "username", "kind", "blocked"]);
12112
+ var BOT_MESSAGE_FILTER_COLUMNS = Object.freeze(["bot_channel_id", "bot_contact_id", "direction", "source"]);
12113
+ var BOT_FACT_FILTER_COLUMNS = Object.freeze(["bot_channel_id", "source", "bot_contact_id"]);
12114
+ var BOT_SOURCE_FILTER_COLUMNS = Object.freeze(["bot_channel_id"]);
12115
+ var BOT_RUN_FILTER_COLUMNS = Object.freeze(["bot_channel_id", "status", "trigger"]);
12116
+ function responderBody(input) {
12117
+ const body = {};
12118
+ for (const key of ["enabled", "system_prompt", "knowledge", "signature", "model", "slots_per_day", "window_start", "window_end", "timezone", "history_limit", "language"]) {
12119
+ if (input[key] !== undefined)
12120
+ body[key] = input[key];
12121
+ }
12122
+ return body;
12123
+ }
12124
+ function channelBody(input) {
12125
+ const body = {};
12126
+ if (input.name !== undefined)
12127
+ body["name"] = input.name;
12128
+ if (input.token !== undefined)
12129
+ body["token"] = input.token;
12130
+ if (input.kind !== undefined)
12131
+ body["kind"] = input.kind;
12132
+ if (input.plugin !== undefined)
12133
+ body["plugin"] = input.plugin;
12134
+ if (input.enabled !== undefined)
12135
+ body["enabled"] = input.enabled;
12136
+ return body;
12137
+ }
12138
+
12139
+ class BotChannelsNamespace extends Resource {
12140
+ async list(params = {}, options = {}) {
12141
+ const base = { order: "created_at:asc" };
12142
+ return paginate(params, 50, (at) => this.http.get("/bot_channels", { ...options, query: listQuery(params, at, base) }));
12143
+ }
12144
+ async get(id, options = {}) {
12145
+ return this.http.get(`/bot_channels/${encodeURIComponent(id)}`, options);
12146
+ }
12147
+ async create(input, options = {}) {
12148
+ return this.http.post("/bot_channels", channelBody(input), { retry: false, ...options });
12149
+ }
12150
+ async update(id, input, options = {}) {
12151
+ return this.http.patch(`/bot_channels/${encodeURIComponent(id)}`, channelBody(input), { retry: false, ...options });
12152
+ }
12153
+ async delete(id, options = {}) {
12154
+ await this.http.delete(`/bot_channels/${encodeURIComponent(id)}`, options);
12155
+ }
12156
+ async test(id, options = {}) {
12157
+ return this.http.post(`/bot_channels/${encodeURIComponent(id)}/test`, {}, { retry: false, ...options });
12158
+ }
12159
+ }
12160
+
12161
+ class BotContactsNamespace extends Resource {
12162
+ async list(params = {}, options = {}) {
12163
+ const base = { order: "last_message_at:desc", exactSearch: { bot_channel_id: params.channelId } };
12164
+ return paginate(params, 50, (at) => this.http.get("/bot_contacts", { ...options, query: listQuery(params, at, base) }));
12165
+ }
12166
+ async get(id, options = {}) {
12167
+ return this.http.get(`/bot_contacts/${encodeURIComponent(id)}`, options);
12168
+ }
12169
+ async update(id, input, options = {}) {
12170
+ const body = {};
12171
+ if (input.name !== undefined)
12172
+ body["name"] = input.name;
12173
+ if (input.tags !== undefined)
12174
+ body["tags"] = [...input.tags];
12175
+ if (input.needs_human !== undefined)
12176
+ body["needs_human"] = input.needs_human;
12177
+ if (input.note !== undefined)
12178
+ body["note"] = input.note;
12179
+ return this.http.patch(`/bot_contacts/${encodeURIComponent(id)}`, body, options);
12180
+ }
12181
+ async markRead(id, options = {}) {
12182
+ return this.http.post(`/bot_contacts/${encodeURIComponent(id)}/read`, {}, options);
12183
+ }
12184
+ async botReply(id, options = {}) {
12185
+ return this.http.post(`/bot_contacts/${encodeURIComponent(id)}/bot_reply`, {}, { retry: false, ...options });
12186
+ }
12187
+ async teach(id, hint, options = {}) {
12188
+ return this.http.post(`/bot_contacts/${encodeURIComponent(id)}/teach`, { hint }, { retry: false, ...options });
12189
+ }
12190
+ async delete(id, options = {}) {
12191
+ await this.http.delete(`/bot_contacts/${encodeURIComponent(id)}`, options);
12192
+ }
12193
+ }
12194
+
12195
+ class BotMessagesNamespace extends Resource {
12196
+ async list(params = {}, options = {}) {
12197
+ const base = { order: "sent_at:desc", exactSearch: { bot_contact_id: params.contactId, bot_channel_id: params.channelId } };
12198
+ return paginate(params, 100, (at) => this.http.get("/bot_messages", { ...options, query: listQuery(params, at, base) }));
12199
+ }
12200
+ async get(id, options = {}) {
12201
+ return this.http.get(`/bot_messages/${encodeURIComponent(id)}`, options);
12202
+ }
12203
+ async send(input, options = {}) {
12204
+ const body = { text: input.text };
12205
+ if (input.contactId !== undefined)
12206
+ body["bot_contact_id"] = input.contactId;
12207
+ if (input.channelId !== undefined)
12208
+ body["bot_channel_id"] = input.channelId;
12209
+ if (input.externalId !== undefined)
12210
+ body["external_id"] = input.externalId;
12211
+ if (input.format !== undefined)
12212
+ body["format"] = input.format;
12213
+ return this.http.post("/bot_messages", body, { retry: false, ...options });
12214
+ }
12215
+ async delete(id, options = {}) {
12216
+ await this.http.delete(`/bot_messages/${encodeURIComponent(id)}`, options);
12217
+ }
12218
+ }
12219
+
12220
+ class BotRespondersNamespace extends Resource {
12221
+ async get(channelId, options = {}) {
12222
+ return this.http.get(`/bot_channels/${encodeURIComponent(channelId)}/responder`, options);
12223
+ }
12224
+ async update(channelId, input, options = {}) {
12225
+ return this.http.patch(`/bot_channels/${encodeURIComponent(channelId)}/responder`, responderBody(input), { retry: false, ...options });
12226
+ }
12227
+ async run(channelId, options = {}) {
12228
+ return this.http.post(`/bot_channels/${encodeURIComponent(channelId)}/responder/run`, {}, { retry: false, ...options });
12229
+ }
12230
+ }
12231
+
12232
+ class BotOwnerChatNamespace extends Resource {
12233
+ async get(channelId, options = {}) {
12234
+ return this.http.get(`/bot_channels/${encodeURIComponent(channelId)}/owner_chat`, options);
12235
+ }
12236
+ async send(channelId, message, options = {}) {
12237
+ return this.http.post(`/bot_channels/${encodeURIComponent(channelId)}/owner_chat`, { message }, { retry: false, ...options });
12238
+ }
12239
+ }
12240
+
12241
+ class BotFactsNamespace extends Resource {
12242
+ async list(params = {}, options = {}) {
12243
+ const base = { order: "created_at:desc", exactSearch: { bot_channel_id: params.channelId } };
12244
+ return paginate(params, 100, (at) => this.http.get("/bot_facts", { ...options, query: listQuery(params, at, base) }));
12245
+ }
12246
+ async get(id, options = {}) {
12247
+ return this.http.get(`/bot_facts/${encodeURIComponent(id)}`, options);
12248
+ }
12249
+ async create(input, options = {}) {
12250
+ const body = { bot_channel_id: input.channelId, text: input.text };
12251
+ if (input.valid_from !== undefined)
12252
+ body["valid_from"] = input.valid_from;
12253
+ if (input.valid_until !== undefined)
12254
+ body["valid_until"] = input.valid_until;
12255
+ return this.http.post("/bot_facts", body, { retry: false, ...options });
12256
+ }
12257
+ async update(id, input, options = {}) {
12258
+ const body = {};
12259
+ if (input.text !== undefined)
12260
+ body["text"] = input.text;
12261
+ if (input.valid_from !== undefined)
12262
+ body["valid_from"] = input.valid_from;
12263
+ if (input.valid_until !== undefined)
12264
+ body["valid_until"] = input.valid_until;
12265
+ return this.http.patch(`/bot_facts/${encodeURIComponent(id)}`, body, { retry: false, ...options });
12266
+ }
12267
+ async delete(id, options = {}) {
12268
+ await this.http.delete(`/bot_facts/${encodeURIComponent(id)}`, options);
12269
+ }
12270
+ }
12271
+
12272
+ class BotSourcesNamespace extends Resource {
12273
+ async list(params = {}, options = {}) {
12274
+ const base = { order: "created_at:asc", exactSearch: { bot_channel_id: params.channelId } };
12275
+ return paginate(params, 100, (at) => this.http.get("/bot_sources", { ...options, query: listQuery(params, at, base) }));
12276
+ }
12277
+ async get(id, options = {}) {
12278
+ return this.http.get(`/bot_sources/${encodeURIComponent(id)}`, options);
12279
+ }
12280
+ async create(input, options = {}) {
12281
+ const body = { bot_channel_id: input.channelId, name: input.name, url: input.url };
12282
+ if (input.description !== undefined)
12283
+ body["description"] = input.description;
12284
+ return this.http.post("/bot_sources", body, { retry: false, ...options });
12285
+ }
12286
+ async update(id, input, options = {}) {
12287
+ const body = {};
12288
+ if (input.name !== undefined)
12289
+ body["name"] = input.name;
12290
+ if (input.url !== undefined)
12291
+ body["url"] = input.url;
12292
+ if (input.description !== undefined)
12293
+ body["description"] = input.description;
12294
+ return this.http.patch(`/bot_sources/${encodeURIComponent(id)}`, body, { retry: false, ...options });
12295
+ }
12296
+ async delete(id, options = {}) {
12297
+ await this.http.delete(`/bot_sources/${encodeURIComponent(id)}`, options);
12298
+ }
12299
+ }
12300
+
12301
+ class BotResponderRunsNamespace extends Resource {
12302
+ async list(params = {}, options = {}) {
12303
+ const base = { order: "scheduled_at:desc", exactSearch: { bot_channel_id: params.channelId } };
12304
+ return paginate(params, 50, (at) => this.http.get("/bot_responder_runs", { ...options, query: listQuery(params, at, base) }));
12305
+ }
12306
+ async get(id, options = {}) {
12307
+ return this.http.get(`/bot_responder_runs/${encodeURIComponent(id)}`, options);
12308
+ }
12309
+ }
12310
+
12311
+ class BotsNamespace extends Resource {
12312
+ channels;
12313
+ contacts;
12314
+ messages;
12315
+ responders;
12316
+ ownerChat;
12317
+ facts;
12318
+ sources;
12319
+ runs;
12320
+ constructor(http) {
12321
+ super(http);
12322
+ this.channels = new BotChannelsNamespace(http);
12323
+ this.contacts = new BotContactsNamespace(http);
12324
+ this.messages = new BotMessagesNamespace(http);
12325
+ this.responders = new BotRespondersNamespace(http);
12326
+ this.ownerChat = new BotOwnerChatNamespace(http);
12327
+ this.facts = new BotFactsNamespace(http);
12328
+ this.sources = new BotSourcesNamespace(http);
12329
+ this.runs = new BotResponderRunsNamespace(http);
12330
+ }
12331
+ }
11905
12332
 
11906
12333
  // src/resources/shortLinks.ts
11907
12334
  var SHORT_LINK_BASE_URL = "https://omelhor.site";
@@ -15323,16 +15750,22 @@ class StorageNamespace extends Resource {
15323
15750
  }
15324
15751
  }
15325
15752
  async fetchObject(url, options) {
15326
- const response = await this.transport(url, {
15327
- method: "GET",
15328
- ...options.signal ? { signal: options.signal } : {},
15329
- credentials: "omit",
15330
- redirect: "follow"
15331
- });
15332
- if (!response.ok) {
15333
- throw new OmsApiError(`Object storage refused the download (${response.status}). A signed URL is good for six hours; ask for a fresh one if it expired.`, { status: response.status, method: "GET", url, attempts: 1 });
15753
+ let last = null;
15754
+ for (let attempt = 1;attempt <= 3; attempt++) {
15755
+ const response = await this.transport(url, {
15756
+ method: "GET",
15757
+ ...options.signal ? { signal: options.signal } : {},
15758
+ credentials: "omit",
15759
+ redirect: "follow"
15760
+ });
15761
+ if (response.ok)
15762
+ return response;
15763
+ last = response;
15764
+ if (response.status < 500 || attempt === 3)
15765
+ break;
15766
+ await new Promise((resolve) => setTimeout(resolve, attempt * 500));
15334
15767
  }
15335
- return response;
15768
+ throw new OmsApiError(`Object storage refused the download (${last?.status}). A signed URL is good for six hours; ask for a fresh one if it expired.`, { status: last?.status ?? 0, method: "GET", url, attempts: 3 });
15336
15769
  }
15337
15770
  }
15338
15771
  function cacheKey(parentId, name) {
@@ -15832,6 +16265,42 @@ function withId(answer, id) {
15832
16265
  return { ...answer ?? {}, id };
15833
16266
  }
15834
16267
 
16268
+ // src/resources/tools/imageGeneration.ts
16269
+ class ImageGenerationNamespace extends Resource {
16270
+ jobs = new JobsNamespace(this.http);
16271
+ async models(options = {}) {
16272
+ const body = await this.http.get("/image_generations/models", options);
16273
+ return body.models;
16274
+ }
16275
+ async create(input, options = {}) {
16276
+ return this.http.post("/image_generations", {
16277
+ prompt: input.prompt,
16278
+ ...input.model === undefined ? {} : { model: input.model },
16279
+ ...input.negativePrompt === undefined ? {} : { negative_prompt: input.negativePrompt },
16280
+ ...input.width === undefined ? {} : { width: input.width },
16281
+ ...input.height === undefined ? {} : { height: input.height },
16282
+ ...input.steps === undefined ? {} : { steps: input.steps },
16283
+ ...input.seed === undefined ? {} : { seed: input.seed },
16284
+ ...input.guidance === undefined ? {} : { guidance: input.guidance },
16285
+ ...toolCaptchaFields(input)
16286
+ }, { ...options, retry: options.retry ?? false });
16287
+ }
16288
+ async get(id, options = {}) {
16289
+ return this.http.get(`/image_generations/${encodeURIComponent(id)}`, options);
16290
+ }
16291
+ async run(input, options = {}) {
16292
+ const created = await this.create(input, options);
16293
+ return awaitToolJob(this.jobs, created, (request) => this.get(created.id, request), options, "the image generation");
16294
+ }
16295
+ async download(id, options = {}) {
16296
+ const record = await this.get(id, options);
16297
+ return fetchToolArtifact(this.http, this.resultUrl(record), options);
16298
+ }
16299
+ resultUrl(record) {
16300
+ return requireToolArtifact(record, record.result_url, "result");
16301
+ }
16302
+ }
16303
+
15835
16304
  // src/resources/tools/jumpstyle.ts
15836
16305
  var JUMPSTYLE_DENSITIES = Object.freeze([
15837
16306
  "chill",
@@ -16116,6 +16585,7 @@ async function awaitToolJob(jobs2, created, reread, options, label) {
16116
16585
  class ToolsNamespace extends Resource {
16117
16586
  backgroundRemoval;
16118
16587
  upscale;
16588
+ imageGeneration;
16119
16589
  transcription;
16120
16590
  vocalSeparation;
16121
16591
  captions;
@@ -16126,6 +16596,7 @@ class ToolsNamespace extends Resource {
16126
16596
  super(http);
16127
16597
  this.backgroundRemoval = new BackgroundRemovalNamespace(http);
16128
16598
  this.upscale = new UpscaleNamespace(http);
16599
+ this.imageGeneration = new ImageGenerationNamespace(http);
16129
16600
  this.transcription = new TranscriptionNamespace(http);
16130
16601
  this.vocalSeparation = new VocalSeparationNamespace(http);
16131
16602
  this.captions = new CaptionsNamespace(http);
@@ -16164,6 +16635,7 @@ class Oms {
16164
16635
  search;
16165
16636
  llm;
16166
16637
  cron;
16638
+ bots;
16167
16639
  realtime;
16168
16640
  local = local;
16169
16641
  constructor(options = {}) {
@@ -16211,6 +16683,7 @@ class Oms {
16211
16683
  this.search = new SearchNamespace(this.http);
16212
16684
  this.llm = new LlmNamespace(this.http);
16213
16685
  this.cron = new CronNamespace(this.http);
16686
+ this.bots = new BotsNamespace(this.http);
16214
16687
  }
16215
16688
  get baseUrl() {
16216
16689
  return this.http.baseUrl;
@@ -16345,6 +16818,7 @@ export {
16345
16818
  src_default as default,
16346
16819
  decodeIdToken,
16347
16820
  dataUrlFromFile,
16821
+ cronRecordKey,
16348
16822
  createPage,
16349
16823
  createDeadline,
16350
16824
  counterpart,
@@ -16601,6 +17075,7 @@ export {
16601
17075
  JAM_SKIP_MODES,
16602
17076
  JAM_QUEUE_MODES,
16603
17077
  IpLookupNamespace,
17078
+ ImageGenerationNamespace,
16604
17079
  INTERNAL_SERVICE_SLUGS,
16605
17080
  IDENTITY_PROVIDERS,
16606
17081
  GroupChatsNamespace,
@@ -16648,7 +17123,9 @@ export {
16648
17123
  DEFAULT_BATCH_SIZE,
16649
17124
  DEFAULT_BASE_URL,
16650
17125
  CronTemplatesNamespace,
17126
+ CronSchedulesNamespace,
16651
17127
  CronRunsNamespace,
17128
+ CronRecordsNamespace,
16652
17129
  CronNamespace,
16653
17130
  CronJobsNamespace,
16654
17131
  ContentNamespace,
@@ -16656,10 +17133,21 @@ export {
16656
17133
  ChestEntriesNamespace,
16657
17134
  CaptionsNamespace,
16658
17135
  CRON_VAR_TYPES,
17136
+ CRON_SCHEDULE_FILTER_COLUMNS,
17137
+ CRON_SCHEDULES_MAX_PER_JOB,
16659
17138
  CRON_RUN_TRIGGERS,
16660
17139
  CRON_RUN_STATUSES,
16661
17140
  CRON_RUN_FILTER_COLUMNS,
17141
+ CRON_RECORD_MAX_WHERE,
17142
+ CRON_RECORD_MAX_PER_JOB,
17143
+ CRON_RECORD_MAX_PER_DELETE,
17144
+ CRON_RECORD_MAX_PER_BATCH,
17145
+ CRON_RECORD_MAX_LIMIT,
17146
+ CRON_RECORD_MAX_DATA_BYTES,
17147
+ CRON_RECORD_KEY_MAX,
17148
+ CRON_RECORD_COLLECTION_MAX,
16662
17149
  CRON_JOB_SCOPES,
17150
+ CRON_JOB_RUNTIMES,
16663
17151
  CRON_JOB_MIN_TIMEOUT_SECONDS,
16664
17152
  CRON_JOB_MIN_INTERVAL_MINUTES,
16665
17153
  CRON_JOB_MAX_TIMEOUT_SECONDS,
@@ -16677,11 +17165,31 @@ export {
16677
17165
  CAPTION_CHUNKED_THRESHOLD,
16678
17166
  CAPTION_BUSY_STATUSES,
16679
17167
  CABLE_CHANNELS,
17168
+ BotsNamespace,
17169
+ BotSourcesNamespace,
17170
+ BotRespondersNamespace,
17171
+ BotResponderRunsNamespace,
17172
+ BotOwnerChatNamespace,
17173
+ BotMessagesNamespace,
17174
+ BotFactsNamespace,
17175
+ BotContactsNamespace,
17176
+ BotChannelsNamespace,
16680
17177
  BookChatNamespace,
16681
17178
  BookChatError,
16682
17179
  BlogsNamespace,
16683
17180
  BlogPostsNamespace,
16684
17181
  BackgroundRemovalNamespace,
17182
+ BOT_SOURCE_FILTER_COLUMNS,
17183
+ BOT_RUN_FILTER_COLUMNS,
17184
+ BOT_PLUGINS,
17185
+ BOT_MESSAGE_MAX_TEXT,
17186
+ BOT_MESSAGE_FILTER_COLUMNS,
17187
+ BOT_FACT_FILTER_COLUMNS,
17188
+ BOT_CONTACT_KINDS,
17189
+ BOT_CONTACT_FILTER_COLUMNS,
17190
+ BOT_CHANNEL_KINDS,
17191
+ BOT_CHANNEL_HEALTHS,
17192
+ BOT_CHANNEL_FILTER_COLUMNS,
16685
17193
  BOOK_VISIBILITIES,
16686
17194
  BOOK_UPLOAD_EDGE_LIMIT_BYTES,
16687
17195
  BOOK_TITLE_MAX_LENGTH,