@omelhorsite/sdk 0.16.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
 
@@ -11457,6 +11470,17 @@ class NewsItemsNamespace extends Resource {
11457
11470
  async get(id, options = {}) {
11458
11471
  return this.http.get(`/news_items/${encodeURIComponent(id)}`, options);
11459
11472
  }
11473
+ async similar(params, options = {}) {
11474
+ const query = {
11475
+ text: params.text,
11476
+ item_id: params.itemId,
11477
+ news_feed_id: params.feedId,
11478
+ limit: params.limit,
11479
+ since: params.since,
11480
+ max_distance: params.maxDistance
11481
+ };
11482
+ return this.http.get("/news_items/similar", { ...options, query });
11483
+ }
11460
11484
  async delete(id, options = {}) {
11461
11485
  await this.http.delete(`/news_items/${encodeURIComponent(id)}`, options);
11462
11486
  }
@@ -11496,7 +11520,7 @@ class NewsScriptsNamespace extends Resource {
11496
11520
  // src/resources/content/news/sources.ts
11497
11521
  var NEWS_SOURCE_HEALTHS = ["unknown", "ok", "error"];
11498
11522
  var NEWS_SOURCE_DISABLE_AFTER_FAILURES = 20;
11499
- 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"]);
11500
11524
 
11501
11525
  class NewsSourcesNamespace extends Resource {
11502
11526
  async list(params = {}, options = {}) {
@@ -11506,7 +11530,8 @@ class NewsSourcesNamespace extends Resource {
11506
11530
  health: params.health,
11507
11531
  enabled: params.enabled,
11508
11532
  news_feed_id: params.feedId,
11509
- news_script_id: params.scriptId
11533
+ news_script_id: params.scriptId,
11534
+ cron_job_id: params.jobId
11510
11535
  }
11511
11536
  };
11512
11537
  return paginate(params, 100, (at) => this.http.get("/news_sources", { ...options, query: listQuery(params, at, base) }));
@@ -11517,7 +11542,8 @@ class NewsSourcesNamespace extends Resource {
11517
11542
  async create(input, options = {}) {
11518
11543
  return this.http.post("/news_sources", {
11519
11544
  name: input.name,
11520
- news_script_id: input.scriptId,
11545
+ ...input.scriptId === undefined ? {} : { news_script_id: input.scriptId },
11546
+ ...input.jobId === undefined ? {} : { cron_job_id: input.jobId },
11521
11547
  ...input.newsFeedId === undefined ? {} : { news_feed_id: input.newsFeedId },
11522
11548
  ...input.config === undefined ? {} : { config: input.config },
11523
11549
  ...input.pollIntervalMinutes === undefined ? {} : { poll_interval_minutes: input.pollIntervalMinutes },
@@ -11529,6 +11555,7 @@ class NewsSourcesNamespace extends Resource {
11529
11555
  ...input.name === undefined ? {} : { name: input.name },
11530
11556
  ...input.newsFeedId === undefined ? {} : { news_feed_id: input.newsFeedId },
11531
11557
  ...input.scriptId === undefined ? {} : { news_script_id: input.scriptId },
11558
+ ...input.jobId === undefined ? {} : { cron_job_id: input.jobId },
11532
11559
  ...input.config === undefined ? {} : { config: input.config },
11533
11560
  ...input.pollIntervalMinutes === undefined ? {} : { poll_interval_minutes: input.pollIntervalMinutes },
11534
11561
  ...input.enabled === undefined ? {} : { enabled: input.enabled },
@@ -11538,6 +11565,13 @@ class NewsSourcesNamespace extends Resource {
11538
11565
  async delete(id, options = {}) {
11539
11566
  await this.http.delete(`/news_sources/${encodeURIComponent(id)}`, options);
11540
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
+ }
11541
11575
  async run(id, options = {}) {
11542
11576
  return this.http.post(`/news_sources/${encodeURIComponent(id)}/run`, undefined, { retry: false, ...options });
11543
11577
  }
@@ -11556,6 +11590,9 @@ class NewsNamespace extends Resource {
11556
11590
  this.scripts = new NewsScriptsNamespace(http);
11557
11591
  this.items = new NewsItemsNamespace(http);
11558
11592
  }
11593
+ async discover(url, options = {}) {
11594
+ return this.http.get("/news/discover", { ...options, query: { url } });
11595
+ }
11559
11596
  }
11560
11597
 
11561
11598
  // src/resources/content/jokes.ts
@@ -11629,6 +11666,8 @@ var NOTIFICATION_KINDS = [
11629
11666
  "news_source_failing",
11630
11667
  "cron_run_failed",
11631
11668
  "cron_run_done",
11669
+ "bot_message_received",
11670
+ "bot_needs_human",
11632
11671
  "oauth_application_approved",
11633
11672
  "oauth_application_rejected",
11634
11673
  "admin_oauth_application_submitted",
@@ -11777,20 +11816,27 @@ var CRON_JOB_SCOPES = Object.freeze([
11777
11816
  "tools:read",
11778
11817
  "tools:write",
11779
11818
  "blogs:read",
11780
- "blogs:write"
11819
+ "blogs:write",
11820
+ "bots:read",
11821
+ "bots:write",
11822
+ "cron:run"
11781
11823
  ]);
11782
11824
  var CRON_JOB_HEALTHS = Object.freeze(["unknown", "ok", "error"]);
11825
+ var CRON_JOB_RUNTIMES = Object.freeze(["sandbox", "full"]);
11783
11826
  var CRON_JOB_DISABLE_AFTER_FAILURES = 10;
11784
11827
  var CRON_JOB_MAX_CODE_BYTES = 256 * 1024;
11785
11828
  var CRON_JOB_MAX_STATE_BYTES = 256 * 1024;
11786
11829
  var CRON_JOB_MAX_CONFIG_BYTES = 64 * 1024;
11787
11830
  var CRON_JOB_MIN_INTERVAL_MINUTES = 5;
11831
+ var CRON_SCHEDULES_MAX_PER_JOB = 200;
11788
11832
  var CRON_JOB_MIN_TIMEOUT_SECONDS = 5;
11789
11833
  var CRON_JOB_MAX_TIMEOUT_SECONDS = 1200;
11790
11834
  var CRON_JOB_BASE_MAX_TIMEOUT_SECONDS = 120;
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"]);
11791
11837
  var CRON_JOB_FILTER_COLUMNS = Object.freeze(["name", "enabled", "health", "template_slug"]);
11792
11838
  var CRON_RUN_STATUSES = Object.freeze(["queued", "running", "ok", "error", "timeout", "skipped"]);
11793
- var CRON_RUN_TRIGGERS = Object.freeze(["schedule", "manual", "test"]);
11839
+ var CRON_RUN_TRIGGERS = Object.freeze(["schedule", "manual", "api", "job", "test"]);
11794
11840
  var CRON_RUN_FILTER_COLUMNS = Object.freeze(["cron_job_id", "status", "trigger"]);
11795
11841
 
11796
11842
  class CronJobsNamespace extends Resource {
@@ -11810,17 +11856,36 @@ class CronJobsNamespace extends Resource {
11810
11856
  async delete(id, options = {}) {
11811
11857
  await this.http.delete(`/cron_jobs/${encodeURIComponent(id)}`, options);
11812
11858
  }
11813
- async run(id, options = {}) {
11814
- 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 });
11815
11861
  }
11816
- async test(id, options = {}) {
11817
- 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 });
11818
11864
  }
11819
11865
  async check(code, options = {}) {
11820
11866
  return this.http.post("/cron_jobs/check", { code }, options);
11821
11867
  }
11822
11868
  }
11823
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
+
11824
11889
  class CronRunsNamespace extends Resource {
11825
11890
  async list(params = {}, options = {}) {
11826
11891
  const base = { order: "created_at:desc", exactSearch: { cron_job_id: params.jobId, status: params.status } };
@@ -11842,18 +11907,130 @@ class CronTemplatesNamespace extends Resource {
11842
11907
  return this.http.get(`/cron_templates/${encodeURIComponent(slug)}`, options);
11843
11908
  }
11844
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
+ }
11845
12001
 
11846
12002
  class CronNamespace extends Resource {
11847
12003
  jobs;
12004
+ schedules;
11848
12005
  runs;
11849
12006
  templates;
12007
+ records;
11850
12008
  constructor(http) {
11851
12009
  super(http);
11852
12010
  this.jobs = new CronJobsNamespace(http);
12011
+ this.schedules = new CronSchedulesNamespace(http);
11853
12012
  this.runs = new CronRunsNamespace(http);
11854
12013
  this.templates = new CronTemplatesNamespace(http);
12014
+ this.records = new CronRecordsNamespace(http);
11855
12015
  }
11856
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
+ }
11857
12034
  function jobBody(input) {
11858
12035
  const body = {};
11859
12036
  if (input.name !== undefined)
@@ -11868,6 +12045,8 @@ function jobBody(input) {
11868
12045
  body["code"] = input.code;
11869
12046
  if (input.scopes !== undefined)
11870
12047
  body["scopes"] = [...input.scopes];
12048
+ if (input.output !== undefined)
12049
+ body["output"] = input.output;
11871
12050
  if (input.config !== undefined)
11872
12051
  body["config"] = input.config;
11873
12052
  if (input.secrets !== undefined)
@@ -11890,6 +12069,266 @@ function jobBody(input) {
11890
12069
  body["template_slug"] = input.templateSlug;
11891
12070
  return body;
11892
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
+ }
11893
12332
 
11894
12333
  // src/resources/shortLinks.ts
11895
12334
  var SHORT_LINK_BASE_URL = "https://omelhor.site";
@@ -15311,16 +15750,22 @@ class StorageNamespace extends Resource {
15311
15750
  }
15312
15751
  }
15313
15752
  async fetchObject(url, options) {
15314
- const response = await this.transport(url, {
15315
- method: "GET",
15316
- ...options.signal ? { signal: options.signal } : {},
15317
- credentials: "omit",
15318
- redirect: "follow"
15319
- });
15320
- if (!response.ok) {
15321
- 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));
15322
15767
  }
15323
- 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 });
15324
15769
  }
15325
15770
  }
15326
15771
  function cacheKey(parentId, name) {
@@ -15820,6 +16265,42 @@ function withId(answer, id) {
15820
16265
  return { ...answer ?? {}, id };
15821
16266
  }
15822
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
+
15823
16304
  // src/resources/tools/jumpstyle.ts
15824
16305
  var JUMPSTYLE_DENSITIES = Object.freeze([
15825
16306
  "chill",
@@ -16104,6 +16585,7 @@ async function awaitToolJob(jobs2, created, reread, options, label) {
16104
16585
  class ToolsNamespace extends Resource {
16105
16586
  backgroundRemoval;
16106
16587
  upscale;
16588
+ imageGeneration;
16107
16589
  transcription;
16108
16590
  vocalSeparation;
16109
16591
  captions;
@@ -16114,6 +16596,7 @@ class ToolsNamespace extends Resource {
16114
16596
  super(http);
16115
16597
  this.backgroundRemoval = new BackgroundRemovalNamespace(http);
16116
16598
  this.upscale = new UpscaleNamespace(http);
16599
+ this.imageGeneration = new ImageGenerationNamespace(http);
16117
16600
  this.transcription = new TranscriptionNamespace(http);
16118
16601
  this.vocalSeparation = new VocalSeparationNamespace(http);
16119
16602
  this.captions = new CaptionsNamespace(http);
@@ -16152,6 +16635,7 @@ class Oms {
16152
16635
  search;
16153
16636
  llm;
16154
16637
  cron;
16638
+ bots;
16155
16639
  realtime;
16156
16640
  local = local;
16157
16641
  constructor(options = {}) {
@@ -16199,6 +16683,7 @@ class Oms {
16199
16683
  this.search = new SearchNamespace(this.http);
16200
16684
  this.llm = new LlmNamespace(this.http);
16201
16685
  this.cron = new CronNamespace(this.http);
16686
+ this.bots = new BotsNamespace(this.http);
16202
16687
  }
16203
16688
  get baseUrl() {
16204
16689
  return this.http.baseUrl;
@@ -16333,6 +16818,7 @@ export {
16333
16818
  src_default as default,
16334
16819
  decodeIdToken,
16335
16820
  dataUrlFromFile,
16821
+ cronRecordKey,
16336
16822
  createPage,
16337
16823
  createDeadline,
16338
16824
  counterpart,
@@ -16589,6 +17075,7 @@ export {
16589
17075
  JAM_SKIP_MODES,
16590
17076
  JAM_QUEUE_MODES,
16591
17077
  IpLookupNamespace,
17078
+ ImageGenerationNamespace,
16592
17079
  INTERNAL_SERVICE_SLUGS,
16593
17080
  IDENTITY_PROVIDERS,
16594
17081
  GroupChatsNamespace,
@@ -16636,17 +17123,31 @@ export {
16636
17123
  DEFAULT_BATCH_SIZE,
16637
17124
  DEFAULT_BASE_URL,
16638
17125
  CronTemplatesNamespace,
17126
+ CronSchedulesNamespace,
16639
17127
  CronRunsNamespace,
17128
+ CronRecordsNamespace,
16640
17129
  CronNamespace,
16641
17130
  CronJobsNamespace,
16642
17131
  ContentNamespace,
16643
17132
  ChestsNamespace,
16644
17133
  ChestEntriesNamespace,
16645
17134
  CaptionsNamespace,
17135
+ CRON_VAR_TYPES,
17136
+ CRON_SCHEDULE_FILTER_COLUMNS,
17137
+ CRON_SCHEDULES_MAX_PER_JOB,
16646
17138
  CRON_RUN_TRIGGERS,
16647
17139
  CRON_RUN_STATUSES,
16648
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,
16649
17149
  CRON_JOB_SCOPES,
17150
+ CRON_JOB_RUNTIMES,
16650
17151
  CRON_JOB_MIN_TIMEOUT_SECONDS,
16651
17152
  CRON_JOB_MIN_INTERVAL_MINUTES,
16652
17153
  CRON_JOB_MAX_TIMEOUT_SECONDS,
@@ -16664,11 +17165,31 @@ export {
16664
17165
  CAPTION_CHUNKED_THRESHOLD,
16665
17166
  CAPTION_BUSY_STATUSES,
16666
17167
  CABLE_CHANNELS,
17168
+ BotsNamespace,
17169
+ BotSourcesNamespace,
17170
+ BotRespondersNamespace,
17171
+ BotResponderRunsNamespace,
17172
+ BotOwnerChatNamespace,
17173
+ BotMessagesNamespace,
17174
+ BotFactsNamespace,
17175
+ BotContactsNamespace,
17176
+ BotChannelsNamespace,
16667
17177
  BookChatNamespace,
16668
17178
  BookChatError,
16669
17179
  BlogsNamespace,
16670
17180
  BlogPostsNamespace,
16671
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,
16672
17193
  BOOK_VISIBILITIES,
16673
17194
  BOOK_UPLOAD_EDGE_LIMIT_BYTES,
16674
17195
  BOOK_TITLE_MAX_LENGTH,