@omelhorsite/sdk 0.13.0 → 0.16.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/README.md +26 -3
- package/dist/index.js +399 -170
- package/dist/types/auth/tokens.d.ts +1 -1
- package/dist/types/client.d.ts +3 -0
- package/dist/types/resources/admin/llm.d.ts +9 -1
- package/dist/types/resources/admin/quotas.d.ts +14 -0
- package/dist/types/resources/content/blogs.d.ts +111 -31
- package/dist/types/resources/content/index.d.ts +4 -4
- package/dist/types/resources/content/news/feeds.d.ts +56 -0
- package/dist/types/resources/content/news/index.d.ts +36 -0
- package/dist/types/resources/content/news/items.d.ts +115 -0
- package/dist/types/resources/content/{intel → news}/scripts.d.ts +35 -35
- package/dist/types/resources/content/{intel → news}/sources.d.ts +62 -59
- package/dist/types/resources/content/notifications.d.ts +2 -2
- package/dist/types/resources/cron.d.ts +209 -0
- package/dist/types/resources/index.d.ts +1 -0
- package/dist/types/resources/llm.d.ts +71 -0
- package/dist/types/resources/music/social.d.ts +121 -81
- package/dist/types/resources/music/songs.d.ts +39 -1
- package/dist/types/resources/quotas.d.ts +8 -5
- package/dist/types/resources/search.d.ts +36 -0
- package/package.json +1 -1
- package/dist/types/resources/content/intel/articles.d.ts +0 -230
- package/dist/types/resources/content/intel/config.d.ts +0 -135
- package/dist/types/resources/content/intel/index.d.ts +0 -53
- package/dist/types/resources/content/intel/items.d.ts +0 -91
- package/dist/types/resources/content/intel/reports.d.ts +0 -108
- package/dist/types/resources/content/intel/stats.d.ts +0 -105
- package/dist/types/resources/content/intel/types.d.ts +0 -86
|
@@ -19,8 +19,9 @@
|
|
|
19
19
|
* what is stored RIGHT NOW and only falls when something is deleted; waiting
|
|
20
20
|
* does not give it back.
|
|
21
21
|
* - **Anonymous callers get a shorter list.** Without a credential the server
|
|
22
|
-
* answers with the daily resources only, counted per IP, because an
|
|
23
|
-
* anonymous caller has no file tree
|
|
22
|
+
* answers with the daily tool resources only, counted per IP, because an
|
|
23
|
+
* anonymous caller has no file tree, no music library and no way to reach
|
|
24
|
+
* a model or the search engines. Never index the
|
|
24
25
|
* array by position - look the resource up by name, or use
|
|
25
26
|
* {@link quotaFor}, which returns `undefined` rather than lying.
|
|
26
27
|
*
|
|
@@ -44,14 +45,16 @@ import type { RequestOptions } from "../types";
|
|
|
44
45
|
* widened to `string` on purpose, so an unknown name arrives as data rather
|
|
45
46
|
* than as a type error in a client nobody has rebuilt.
|
|
46
47
|
*/
|
|
47
|
-
export declare const QUOTA_RESOURCES: readonly ["vocal_separation_seconds", "transcription_seconds", "caption_seconds", "jumpstyle_edits", "storage_nodes", "music_storage_bytes"];
|
|
48
|
+
export declare const QUOTA_RESOURCES: readonly ["vocal_separation_seconds", "transcription_seconds", "caption_seconds", "jumpstyle_edits", "storage_nodes", "music_storage_bytes", "llm_requests", "llm_cost_microusd", "search_requests"];
|
|
48
49
|
/** One of {@link QUOTA_RESOURCES}. */
|
|
49
50
|
export type QuotaResource = (typeof QUOTA_RESOURCES)[number];
|
|
50
51
|
/**
|
|
51
52
|
* What the numbers count. `"seconds"` of media, `"count"` of whole things
|
|
52
|
-
* (edits, files and folders), `"bytes"` of stored
|
|
53
|
+
* (edits, files and folders, model calls, searches), `"bytes"` of stored
|
|
54
|
+
* media, `"microusd"` of model spend (millionths of a US dollar, so
|
|
55
|
+
* `200_000` is 0.20 USD).
|
|
53
56
|
*/
|
|
54
|
-
export type QuotaUnit = "seconds" | "count" | "bytes";
|
|
57
|
+
export type QuotaUnit = "seconds" | "count" | "bytes" | "microusd";
|
|
55
58
|
/**
|
|
56
59
|
* `"daily"` spends and resets at midnight, server time. `"total"` is what is
|
|
57
60
|
* stored right now and only falls when something is deleted.
|
|
@@ -103,8 +103,44 @@ export interface SearchResponse {
|
|
|
103
103
|
/** Whether asking for `page + 1` is likely to return anything. */
|
|
104
104
|
readonly has_more: boolean;
|
|
105
105
|
}
|
|
106
|
+
/** Longer values answer `400`. */
|
|
107
|
+
export declare const SEARCH_PAGE_MAX_URL_LENGTH = 2000;
|
|
108
|
+
/** `maxChars` outside this range answers `400`. */
|
|
109
|
+
export declare const SEARCH_PAGE_MIN_CHARS = 200;
|
|
110
|
+
export declare const SEARCH_PAGE_MAX_CHARS = 20000;
|
|
111
|
+
export interface SearchPageInput {
|
|
112
|
+
/** A public `http(s)` URL. Private, loopback and link-local addresses answer `422`. */
|
|
113
|
+
readonly url: string;
|
|
114
|
+
/** How much text to return, {@link SEARCH_PAGE_MIN_CHARS} to {@link SEARCH_PAGE_MAX_CHARS}; defaults to 8000. */
|
|
115
|
+
readonly maxChars?: number;
|
|
116
|
+
}
|
|
117
|
+
/** The readable part of one page: scripts, navigation, footers and forms stripped. */
|
|
118
|
+
export interface SearchPage {
|
|
119
|
+
/** Where the page was actually read from, after redirects. */
|
|
120
|
+
readonly url: string;
|
|
121
|
+
readonly host: string;
|
|
122
|
+
/** Plain text, at most 200 characters; empty when the page has no title. */
|
|
123
|
+
readonly title: string;
|
|
124
|
+
/** Plain text, whitespace collapsed, cut at `maxChars`. Never empty: a page with nothing readable is a `422`. */
|
|
125
|
+
readonly text: string;
|
|
126
|
+
}
|
|
106
127
|
/** The `search` namespace, reachable as `oms.search`. */
|
|
107
128
|
export declare class SearchNamespace extends Resource {
|
|
129
|
+
/**
|
|
130
|
+
* `GET /search/page` - reads one public web page and returns its main text.
|
|
131
|
+
* The natural follow-up to {@link query}: search first, then read the hits
|
|
132
|
+
* worth reading in full.
|
|
133
|
+
*
|
|
134
|
+
* Only `http` and `https`, only public addresses, at most three redirects,
|
|
135
|
+
* and pages that are not HTML or text are refused. The server keeps the
|
|
136
|
+
* answer for ten minutes, so reading the same page twice is cheap.
|
|
137
|
+
*
|
|
138
|
+
* @throws {OmsApiError} 400 for a missing or overlong URL or a `maxChars`
|
|
139
|
+
* out of range; 401 without a credential; 422 with `error: "unreadable"`
|
|
140
|
+
* and a `message` saying why (private address, not HTML, unreachable,
|
|
141
|
+
* HTTP error, nothing readable); 429 above 60 reads a minute.
|
|
142
|
+
*/
|
|
143
|
+
readPage(input: SearchPageInput, options?: RequestOptions): Promise<SearchPage>;
|
|
108
144
|
/**
|
|
109
145
|
* `GET /search` - runs one search and returns one page of merged results.
|
|
110
146
|
*
|
package/package.json
CHANGED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
/** Intel stories: the analysed, grouped, scored output. */
|
|
2
|
-
import { Resource } from "../../../http";
|
|
3
|
-
import type { ListParams } from "../../../listing";
|
|
4
|
-
import type { Id, Paginated, RequestOptions, Timestamp } from "../../../types";
|
|
5
|
-
import type { IntelArticleCategory, IntelReportKind } from "./types";
|
|
6
|
-
/**
|
|
7
|
-
* A story: several raw items about the same event, grouped, scored and
|
|
8
|
-
* categorised by the analysis pipeline.
|
|
9
|
-
*
|
|
10
|
-
* This is the shape an INDEX row has. `GET /intel_articles/:id` renders
|
|
11
|
-
* `:extended`, which is this plus four more keys - see
|
|
12
|
-
* {@link IntelArticleDetail}. The detail is always a superset, never a
|
|
13
|
-
* different record.
|
|
14
|
-
*/
|
|
15
|
-
export interface IntelArticle {
|
|
16
|
-
readonly id: Id;
|
|
17
|
-
readonly created_at: Timestamp;
|
|
18
|
-
readonly updated_at: Timestamp;
|
|
19
|
-
/** Headline the model wrote. Nullable: the column has no `NOT NULL`. */
|
|
20
|
-
readonly title: string | null;
|
|
21
|
-
/** One-paragraph summary. Nullable for the same reason. */
|
|
22
|
-
readonly summary: string | null;
|
|
23
|
-
/**
|
|
24
|
-
* 0-10, validated `only_integer, in: 0..10`. The buckets the dashboard uses
|
|
25
|
-
* are in {@link IntelStats.by_importance} and they are NOT evenly spaced:
|
|
26
|
-
* >=9 critical, 7-8 high, 5-6 medium, 3-4 low, <3 noise.
|
|
27
|
-
*/
|
|
28
|
-
readonly importance: number;
|
|
29
|
-
/** See {@link IntelArticleCategory}. `null` when unclassified. */
|
|
30
|
-
readonly category: IntelArticleCategory | null;
|
|
31
|
-
/**
|
|
32
|
-
* Free-form tags. The column defaults to `[]`, but it is nullable, so a row
|
|
33
|
-
* written before the default landed can still hand you `null`. Do not map
|
|
34
|
-
* over it without a guard.
|
|
35
|
-
*/
|
|
36
|
-
readonly tags: string[] | null;
|
|
37
|
-
/**
|
|
38
|
-
* The `og:image` of one of the story's sources, stored RAW and uncompressed
|
|
39
|
-
* - it points at whatever news site published it, not at this API. Render it
|
|
40
|
-
* through {@link intelArticleImageUrl} rather than directly; that helper
|
|
41
|
-
* explains the trade it makes.
|
|
42
|
-
*/
|
|
43
|
-
readonly image_url: string | null;
|
|
44
|
-
/**
|
|
45
|
-
* Whether the web-search enrichment pass has run on this story.
|
|
46
|
-
*
|
|
47
|
-
* `false` is not a failure, it is a queue position: `AnalyzeUserJob` enriches
|
|
48
|
-
* at most three stories per run, only those at or above
|
|
49
|
-
* {@link IntelConfig.enrich_min_importance}, and only while
|
|
50
|
-
* {@link IntelConfig.web_search} is on. A low-importance story stays `false`
|
|
51
|
-
* for ever, by design.
|
|
52
|
-
*/
|
|
53
|
-
readonly enriched: boolean;
|
|
54
|
-
/** When the story was first built. */
|
|
55
|
-
readonly first_seen_at: Timestamp;
|
|
56
|
-
/** Touched every time a new item joins the story. This is the "recency" clock. */
|
|
57
|
-
readonly last_seen_at: Timestamp;
|
|
58
|
-
/**
|
|
59
|
-
* How many raw items back this story.
|
|
60
|
-
*
|
|
61
|
-
* Costs one COUNT query per row on the listing. A page of 500 stories is
|
|
62
|
-
* 500 extra queries. This is the reason to keep `pageSize` modest on
|
|
63
|
-
* {@link IntelArticlesNamespace.list}.
|
|
64
|
-
*/
|
|
65
|
-
readonly n_sources: number;
|
|
66
|
-
}
|
|
67
|
-
/** One raw item cited by a story, as `:extended` inlines it. */
|
|
68
|
-
export interface IntelArticleSourceRef {
|
|
69
|
-
/** Id of the {@link IntelItem}. Fetch the full row with `items.get(id)`. */
|
|
70
|
-
readonly id: Id;
|
|
71
|
-
/** Name of the {@link IntelSource} the item came from, or `null` if it was deleted. */
|
|
72
|
-
readonly source_name: string | null;
|
|
73
|
-
readonly title: string | null;
|
|
74
|
-
readonly url: string | null;
|
|
75
|
-
readonly published_at: Timestamp | null;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* A story related to this one, as `:extended` inlines it.
|
|
79
|
-
*
|
|
80
|
-
* "Related" is not "duplicate": duplicates are merged during dedup and never
|
|
81
|
-
* become two rows. `IntelArticleLink` is an undirected edge between two
|
|
82
|
-
* DISTINCT stories, which is why {@link relation} is one label describing the
|
|
83
|
-
* pair rather than a direction.
|
|
84
|
-
*/
|
|
85
|
-
export interface IntelRelatedArticleRef {
|
|
86
|
-
readonly id: Id;
|
|
87
|
-
readonly title: string | null;
|
|
88
|
-
readonly importance: number;
|
|
89
|
-
readonly category: IntelArticleCategory | null;
|
|
90
|
-
/** Free text the model wrote for the edge, e.g. a pattern name. Nullable. */
|
|
91
|
-
readonly relation: string | null;
|
|
92
|
-
}
|
|
93
|
-
/** A report this story appears in, as `:extended` inlines it. Newest period first. */
|
|
94
|
-
export interface IntelArticleReportRef {
|
|
95
|
-
readonly id: Id;
|
|
96
|
-
readonly kind: IntelReportKind;
|
|
97
|
-
readonly title: string | null;
|
|
98
|
-
readonly period_end: Timestamp;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* `GET /intel_articles/:id` - the `:extended` view.
|
|
102
|
-
*
|
|
103
|
-
* Four keys the listing does not carry, and all four are joins run inline:
|
|
104
|
-
* `sources` walks `intel_items`, `related` walks the link table in
|
|
105
|
-
* BOTH directions, `reports` orders the report join by `period_end`. There is
|
|
106
|
-
* no paging on any of them, so a story that has been running for a week can
|
|
107
|
-
* inline a lot of rows.
|
|
108
|
-
*/
|
|
109
|
-
export interface IntelArticleDetail extends IntelArticle {
|
|
110
|
-
/** The long body. `null` until the enrichment pass writes one. */
|
|
111
|
-
readonly details: string | null;
|
|
112
|
-
/** Every raw item behind the story. Length matches {@link IntelArticle.n_sources}. */
|
|
113
|
-
readonly sources: IntelArticleSourceRef[];
|
|
114
|
-
/** Stories linked to this one. `[]` when the linker found nothing. */
|
|
115
|
-
readonly related: IntelRelatedArticleRef[];
|
|
116
|
-
/** Reports that cited this story, newest period first. */
|
|
117
|
-
readonly reports: IntelArticleReportRef[];
|
|
118
|
-
}
|
|
119
|
-
/** Filter columns of `GET /intel_articles`, on top of {@link BASE_FILTER_COLUMNS}. */
|
|
120
|
-
export declare const INTEL_ARTICLE_FILTER_COLUMNS: readonly ["title", "summary", "category", "importance", "enriched"];
|
|
121
|
-
/** Filters for {@link IntelArticlesNamespace.list}. */
|
|
122
|
-
export interface ListIntelArticlesParams extends ListParams<(typeof INTEL_ARTICLE_FILTER_COLUMNS)[number]> {
|
|
123
|
-
/**
|
|
124
|
-
* Free-text search over `title`, `summary` AND `details`.
|
|
125
|
-
*
|
|
126
|
-
* A TOP-LEVEL parameter, not a `search` key: the controller reads
|
|
127
|
-
* `params[:q]` itself, which is why it can reach `details` (a column that is
|
|
128
|
-
* not in `search_params` at all) and why an unknown-filter 400 cannot
|
|
129
|
-
* happen for it.
|
|
130
|
-
*
|
|
131
|
-
* Three ways it differs from {@link ListParams.search}:
|
|
132
|
-
*
|
|
133
|
-
* - it is **accent-SENSITIVE**. The controller does `LOWER(col) LIKE
|
|
134
|
-
* LOWER(term)`, with no unaccenting, while the list DSL's `search` strips
|
|
135
|
-
* accents on both sides. `"policia"` will not find `"polícia"` here.
|
|
136
|
-
* - `%` and `_` in your term are **not escaped**. The controller wraps the
|
|
137
|
-
* term as `"%#{q}%"` and binds it, so a term containing `%` is a wildcard,
|
|
138
|
-
* not a literal percent sign. Not an injection - it is a bound parameter -
|
|
139
|
-
* but a surprise. Strip them if you are passing user input through.
|
|
140
|
-
* - it is an unanchored `LIKE` over three text columns with no index, so it
|
|
141
|
-
* is a sequential scan of your stories. Fine for thousands, not for
|
|
142
|
-
* millions.
|
|
143
|
-
*/
|
|
144
|
-
readonly q?: string;
|
|
145
|
-
/**
|
|
146
|
-
* Keep only stories at or above this importance. Also top-level.
|
|
147
|
-
*
|
|
148
|
-
* Sent through Ruby's `String#to_i`, which does NOT raise: `"high"` becomes
|
|
149
|
-
* `0` and the filter silently matches everything. Pass a number and let the
|
|
150
|
-
* SDK stringify it.
|
|
151
|
-
*/
|
|
152
|
-
readonly minImportance?: number;
|
|
153
|
-
/**
|
|
154
|
-
* `"recent"` orders by `last_seen_at` descending. Anything else - including
|
|
155
|
-
* omitting it - orders by `importance` descending, then `last_seen_at`
|
|
156
|
-
* descending. There is no third value and no ascending variant.
|
|
157
|
-
*
|
|
158
|
-
* If you ALSO pass {@link PageParams.order}, both apply and yours wins: the
|
|
159
|
-
* controller appends its ordering after the list DSL has applied
|
|
160
|
-
* `modifiers[order]`, so your column becomes the primary sort key and the
|
|
161
|
-
* controller's becomes the tie-breaker. That is the opposite of what the
|
|
162
|
-
* parameter names suggest.
|
|
163
|
-
*/
|
|
164
|
-
readonly sort?: "recent" | "importance";
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* `GET /intel_articles` and friends: the stories the pipeline built.
|
|
168
|
-
*
|
|
169
|
-
* Read-only plus a delete. There is no create and no update route -
|
|
170
|
-
* `IntelArticle#creatable_by?` and `#updatable_by?` both return `false`
|
|
171
|
-
* unconditionally, and the route is `only: [:index, :show, :destroy]`. Stories
|
|
172
|
-
* come from `Intel::ArticleBuilder`, never from a client.
|
|
173
|
-
*/
|
|
174
|
-
export declare class IntelArticlesNamespace extends Resource {
|
|
175
|
-
/**
|
|
176
|
-
* `GET /intel_articles` - your stories, most important first.
|
|
177
|
-
*
|
|
178
|
-
* Ordering is the controller's, not yours by default: `importance DESC,
|
|
179
|
-
* last_seen_at DESC`, or `last_seen_at DESC` alone with `sort: "recent"`.
|
|
180
|
-
* See {@link ListIntelArticlesParams.sort} for what happens when you pass
|
|
181
|
-
* `order` as well - it is not what the names imply.
|
|
182
|
-
*
|
|
183
|
-
* Filter keys this controller declares for `search` / `exactSearch`:
|
|
184
|
-
* `title`, `summary`, `category`, `importance`, `enriched`, plus the
|
|
185
|
-
* inherited `id`, `created_at`, `updated_at`. Anything else is
|
|
186
|
-
* `400 "Unknown search filter: x"` - fail-closed, never a wider result. The
|
|
187
|
-
* free-text and importance filters are top-level instead: `q` and
|
|
188
|
-
* `minImportance`.
|
|
189
|
-
*
|
|
190
|
-
* **Cost.** Every row runs its own `COUNT` for
|
|
191
|
-
* {@link IntelArticle.n_sources}. Keep `pageSize` in the tens, not at 500.
|
|
192
|
-
*
|
|
193
|
-
* The response carries an `ETag` and can answer `304` - except when
|
|
194
|
-
* `random` is set, which short-circuits `resources_stale?`.
|
|
195
|
-
*
|
|
196
|
-
* @throws {OmsAuthError} 401 when anonymous.
|
|
197
|
-
* @throws {OmsApiError} 403 `"Intel access is restricted."` for a signed-in
|
|
198
|
-
* account outside the allowlist; 400 for an unrecognised filter key.
|
|
199
|
-
*/
|
|
200
|
-
list(params?: ListIntelArticlesParams, options?: RequestOptions): Promise<Paginated<IntelArticle>>;
|
|
201
|
-
/**
|
|
202
|
-
* `GET /intel_articles/:id` - one story with its body, its sources, its
|
|
203
|
-
* related stories and the reports that cited it.
|
|
204
|
-
*
|
|
205
|
-
* The `:extended` view, so it is a strict superset of the listing row. All
|
|
206
|
-
* four extras are inlined without paging; see {@link IntelArticleDetail}.
|
|
207
|
-
*
|
|
208
|
-
* @throws {OmsApiError} 404 `"Resource not found"` when the id is not one of
|
|
209
|
-
* yours - the lookup is `viewable_by(Current.user).find_by(id:)`, so
|
|
210
|
-
* somebody else's story is indistinguishable from a typo, which is the
|
|
211
|
-
* point.
|
|
212
|
-
*/
|
|
213
|
-
get(id: Id, options?: RequestOptions): Promise<IntelArticleDetail>;
|
|
214
|
-
/**
|
|
215
|
-
* `DELETE /intel_articles/:id` - drops a story. `204`, empty body.
|
|
216
|
-
*
|
|
217
|
-
* The story's links to items are removed with it (`dependent: :destroy` on
|
|
218
|
-
* `intel_article_sources`), but the {@link IntelItem} rows themselves SURVIVE
|
|
219
|
-
* - they belong to the source, not to the story. They are also still marked
|
|
220
|
-
* `processed_at`, so deleting a story does not make the pipeline rebuild it.
|
|
221
|
-
* This is a hide, not an undo.
|
|
222
|
-
*
|
|
223
|
-
* @throws {OmsApiError} 404 when the story is not yours. 401
|
|
224
|
-
* `"You are not authorized to destroy this resource"` cannot happen here -
|
|
225
|
-
* `destroyable_by?` is `user == self.user` and the lookup already scoped it
|
|
226
|
-
* - but note the API's habit of answering 401 rather than 403 for a failed
|
|
227
|
-
* authorisation check, which the scripts routes DO hit.
|
|
228
|
-
*/
|
|
229
|
-
delete(id: Id, options?: RequestOptions): Promise<void>;
|
|
230
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/** Intel config: the per-user pipeline settings. */
|
|
2
|
-
import { Resource } from "../../../http";
|
|
3
|
-
import type { Id, RequestOptions, Timestamp } from "../../../types";
|
|
4
|
-
/**
|
|
5
|
-
* The only keys {@link IntelConfig.prompts} accepts.
|
|
6
|
-
*
|
|
7
|
-
* Any other key fails the whole `PATCH` with
|
|
8
|
-
* `400 "Prompts unknown keys: <the offenders>"`. A key that is present but
|
|
9
|
-
* empty is not the same as an absent one: absent means "use the platform
|
|
10
|
-
* default", present-and-empty means the pipeline gets an empty prompt.
|
|
11
|
-
*/
|
|
12
|
-
export declare const INTEL_PROMPT_KEYS: readonly ["build", "enrich_plan", "enrich_actors", "enrich_synth", "report"];
|
|
13
|
-
/** One overridable prompt in the analysis pipeline. */
|
|
14
|
-
export type IntelPromptKey = (typeof INTEL_PROMPT_KEYS)[number];
|
|
15
|
-
/**
|
|
16
|
-
* The per-user knobs on the analysis pipeline. One row per user, created on
|
|
17
|
-
* demand - see {@link IntelConfigNamespace.get}.
|
|
18
|
-
*/
|
|
19
|
-
export interface IntelConfig {
|
|
20
|
-
readonly id: Id;
|
|
21
|
-
readonly created_at: Timestamp;
|
|
22
|
-
readonly updated_at: Timestamp;
|
|
23
|
-
/**
|
|
24
|
-
* Free text telling the classifier what "important" means for you. `null`
|
|
25
|
-
* falls back to the platform default. This is the single highest-leverage
|
|
26
|
-
* field here: everything else is a threshold applied to the score this
|
|
27
|
-
* produces.
|
|
28
|
-
*/
|
|
29
|
-
readonly rubric: string | null;
|
|
30
|
-
/**
|
|
31
|
-
* Prompt overrides, keyed by {@link IntelPromptKey}. `{}` means "platform
|
|
32
|
-
* defaults everywhere"; a key present means that one stage is overridden.
|
|
33
|
-
*
|
|
34
|
-
* Nullable at the database level even though it defaults to `{}`.
|
|
35
|
-
*/
|
|
36
|
-
readonly prompts: Partial<Record<IntelPromptKey, string>> | null;
|
|
37
|
-
/** LLM for the story-building pass. `null` uses the platform default. */
|
|
38
|
-
readonly build_model: string | null;
|
|
39
|
-
/** LLM for report generation. `null` uses the platform default. */
|
|
40
|
-
readonly report_model: string | null;
|
|
41
|
-
/** Stories below this importance are left out of reports. 0-10, default 4. */
|
|
42
|
-
readonly report_min_importance: number;
|
|
43
|
-
/**
|
|
44
|
-
* Stories below this importance are never web-enriched. 0-10, default 6.
|
|
45
|
-
*
|
|
46
|
-
* Lowering it does not enrich the backlog quickly: the job does three
|
|
47
|
-
* stories per run, highest importance first.
|
|
48
|
-
*/
|
|
49
|
-
readonly enrich_min_importance: number;
|
|
50
|
-
/**
|
|
51
|
-
* Master switch for the enrichment pass. `false` leaves every story at
|
|
52
|
-
* `enriched: false` and `details: null` for ever.
|
|
53
|
-
*/
|
|
54
|
-
readonly web_search: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* How many {@link IntelSource} rows you may own. 1-500, default 50.
|
|
57
|
-
*
|
|
58
|
-
* Enforced on CREATE only (`validate :within_source_quota, on: :create`), so
|
|
59
|
-
* lowering it below your current count does not delete anything - it just
|
|
60
|
-
* stops the next create with `400 "Source limit reached (N)"`.
|
|
61
|
-
*/
|
|
62
|
-
readonly max_sources: number;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Arguments for {@link IntelConfigNamespace.update}.
|
|
66
|
-
*
|
|
67
|
-
* Every key is optional and only the keys you send are written -
|
|
68
|
-
* `assign_attributes` over a permitted hash - so this is a genuine partial
|
|
69
|
-
* update, unlike {@link UpdateIntelSourceInput.config}.
|
|
70
|
-
*/
|
|
71
|
-
export interface UpdateIntelConfigInput {
|
|
72
|
-
readonly rubric?: string | null;
|
|
73
|
-
/**
|
|
74
|
-
* REPLACES the whole prompts object. Same trap as
|
|
75
|
-
* {@link UpdateIntelSourceInput.config}: it is one JSON column, so a partial
|
|
76
|
-
* object drops the keys you left out. Spread the current value.
|
|
77
|
-
*
|
|
78
|
-
* Only {@link INTEL_PROMPT_KEYS} are accepted; anything else fails the whole
|
|
79
|
-
* request with a 400 naming the offenders.
|
|
80
|
-
*/
|
|
81
|
-
readonly prompts?: Partial<Record<IntelPromptKey, string>>;
|
|
82
|
-
readonly buildModel?: string | null;
|
|
83
|
-
readonly reportModel?: string | null;
|
|
84
|
-
/** 0-10. Outside the range is a 400, not a clamp. */
|
|
85
|
-
readonly reportMinImportance?: number;
|
|
86
|
-
/** 0-10. Outside the range is a 400, not a clamp. */
|
|
87
|
-
readonly enrichMinImportance?: number;
|
|
88
|
-
readonly webSearch?: boolean;
|
|
89
|
-
/** 1-500. Outside the range is a 400, not a clamp. */
|
|
90
|
-
readonly maxSources?: number;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* `/intel_config` - the per-user pipeline settings.
|
|
94
|
-
*
|
|
95
|
-
* A Rails SINGULAR resource (`resource :intel_config`), so the path has no id
|
|
96
|
-
* and there is no listing: `GET /intel_config` and `PATCH /intel_config` are
|
|
97
|
-
* the whole surface. Both act on the caller's own row and there is no way to
|
|
98
|
-
* address anybody else's.
|
|
99
|
-
*/
|
|
100
|
-
export declare class IntelConfigNamespace extends Resource {
|
|
101
|
-
/**
|
|
102
|
-
* `GET /intel_config` - your settings.
|
|
103
|
-
*
|
|
104
|
-
* **This read WRITES.** The controller calls `IntelConfig.for(Current.user)`,
|
|
105
|
-
* which is `find_or_create_by!`, so a first call inserts the row with the
|
|
106
|
-
* column defaults and returns it. Consequences worth knowing: it is not safe
|
|
107
|
-
* to fire at high frequency (two concurrent first calls race on the unique
|
|
108
|
-
* index and one raises), the response is a `200` even when it just created
|
|
109
|
-
* something, and `created_at` on a "read" can be now.
|
|
110
|
-
*
|
|
111
|
-
* @throws {OmsApiError} 403 `"Intel access is restricted."` outside the
|
|
112
|
-
* allowlist - checked before the row is created, so a refused caller does
|
|
113
|
-
* not leave a row behind.
|
|
114
|
-
*/
|
|
115
|
-
get(options?: RequestOptions): Promise<IntelConfig>;
|
|
116
|
-
/**
|
|
117
|
-
* `PATCH /intel_config` - changes settings. Answers with the whole row.
|
|
118
|
-
*
|
|
119
|
-
* A genuine partial update for the scalar fields, and a whole-object replace
|
|
120
|
-
* for `prompts` - see {@link UpdateIntelConfigInput.prompts}.
|
|
121
|
-
*
|
|
122
|
-
* The route also accepts `PUT`, and it means exactly the same thing: Rails
|
|
123
|
-
* maps both onto `update` and the controller does not read the verb. There is
|
|
124
|
-
* no "replace the whole config" call.
|
|
125
|
-
*
|
|
126
|
-
* Failures are a `400` whose body is ONE sentence, not a field map:
|
|
127
|
-
* `ApplicationRecord#error_messages` is `errors.full_messages.to_sentence`,
|
|
128
|
-
* so several violations arrive joined by commas and "and". Parse it for
|
|
129
|
-
* humans, not for code.
|
|
130
|
-
*
|
|
131
|
-
* @throws {OmsApiError} 400 for a threshold outside `0..10`, a `max_sources`
|
|
132
|
-
* outside `1..500`, or a `prompts` key outside {@link INTEL_PROMPT_KEYS}.
|
|
133
|
-
*/
|
|
134
|
-
update(input: UpdateIntelConfigInput, options?: RequestOptions): Promise<IntelConfig>;
|
|
135
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/** The `intel` namespace and everything under it. */
|
|
2
|
-
import { type ApiClient, Resource } from "../../../http";
|
|
3
|
-
import { IntelArticlesNamespace } from "./articles";
|
|
4
|
-
import { IntelConfigNamespace } from "./config";
|
|
5
|
-
import { IntelItemsNamespace } from "./items";
|
|
6
|
-
import { IntelReportsNamespace } from "./reports";
|
|
7
|
-
import { IntelScriptsNamespace } from "./scripts";
|
|
8
|
-
import { IntelSourcesNamespace } from "./sources";
|
|
9
|
-
import { IntelStatsNamespace } from "./stats";
|
|
10
|
-
export * from "./articles";
|
|
11
|
-
export * from "./config";
|
|
12
|
-
export * from "./items";
|
|
13
|
-
export * from "./reports";
|
|
14
|
-
export * from "./scripts";
|
|
15
|
-
export * from "./sources";
|
|
16
|
-
export * from "./stats";
|
|
17
|
-
export * from "./types";
|
|
18
|
-
/**
|
|
19
|
-
* The `intel` namespace, reachable as `oms.content.intel`.
|
|
20
|
-
*
|
|
21
|
-
* A tour of the data model, because the names do not give it away:
|
|
22
|
-
*
|
|
23
|
-
* 1. a {@link IntelScript} knows HOW to fetch one kind of feed;
|
|
24
|
-
* 2. an {@link IntelSource} is that script plus its settings - a feed you
|
|
25
|
-
* actually follow;
|
|
26
|
-
* 3. polling a source writes {@link IntelItem} rows: raw, unprocessed, one per
|
|
27
|
-
* thing the feed published;
|
|
28
|
-
* 4. the analysis pipeline groups items into {@link IntelArticle} stories,
|
|
29
|
-
* scores them against your {@link IntelConfig} rubric, enriches the
|
|
30
|
-
* important ones and links related ones together;
|
|
31
|
-
* 5. {@link IntelReport} digests summarise a closed time window of stories.
|
|
32
|
-
*
|
|
33
|
-
* Only steps 1 and 2 are yours to write. Everything from step 3 on is produced
|
|
34
|
-
* by background jobs and is read-only over HTTP - a delete is the only mutation
|
|
35
|
-
* you get, and it is a hide, not an undo.
|
|
36
|
-
*/
|
|
37
|
-
export declare class IntelNamespace extends Resource {
|
|
38
|
-
/** Stories: the analysed, grouped, scored output. Read plus delete. */
|
|
39
|
-
readonly articles: IntelArticlesNamespace;
|
|
40
|
-
/** Generated digests over closed time windows. Read plus delete. */
|
|
41
|
-
readonly reports: IntelReportsNamespace;
|
|
42
|
-
/** The feeds you follow. Full CRUD, plus a manual run. */
|
|
43
|
-
readonly sources: IntelSourcesNamespace;
|
|
44
|
-
/** The fetchers. Full CRUD over yours; the built-ins are read-only. */
|
|
45
|
-
readonly scripts: IntelScriptsNamespace;
|
|
46
|
-
/** The raw material behind the stories. Read plus delete. */
|
|
47
|
-
readonly items: IntelItemsNamespace;
|
|
48
|
-
/** Your rubric, thresholds and prompt overrides. */
|
|
49
|
-
readonly config: IntelConfigNamespace;
|
|
50
|
-
/** Dashboard counters, in one expensive call. */
|
|
51
|
-
readonly stats: IntelStatsNamespace;
|
|
52
|
-
constructor(http: ApiClient);
|
|
53
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/** Intel items: the raw material behind the stories. */
|
|
2
|
-
import { Resource } from "../../../http";
|
|
3
|
-
import type { ListParams } from "../../../listing";
|
|
4
|
-
import type { Id, Paginated, RequestOptions, Timestamp } from "../../../types";
|
|
5
|
-
/**
|
|
6
|
-
* A raw item, exactly as a script returned it.
|
|
7
|
-
*
|
|
8
|
-
* Written only by `Intel::FetchSourceJob`; over HTTP it is read-only plus a
|
|
9
|
-
* delete. Items are the substrate the stories are built from - the story never
|
|
10
|
-
* copies the body, it points here.
|
|
11
|
-
*/
|
|
12
|
-
export interface IntelItem {
|
|
13
|
-
readonly id: Id;
|
|
14
|
-
readonly created_at: Timestamp;
|
|
15
|
-
readonly updated_at: Timestamp;
|
|
16
|
-
/** Which source produced it. */
|
|
17
|
-
readonly intel_source_id: Id;
|
|
18
|
-
/**
|
|
19
|
-
* The script's own id for this item, unique per source. This is the
|
|
20
|
-
* de-duplication key: a second poll that returns the same `external_id` does
|
|
21
|
-
* not create a second row.
|
|
22
|
-
*/
|
|
23
|
-
readonly external_id: string;
|
|
24
|
-
readonly title: string | null;
|
|
25
|
-
/** The body the script extracted. Can be large; a listing carries all of it. */
|
|
26
|
-
readonly content: string | null;
|
|
27
|
-
readonly url: string | null;
|
|
28
|
-
readonly author: string | null;
|
|
29
|
-
/** Publication time as the feed reported it, not as we saw it. */
|
|
30
|
-
readonly published_at: Timestamp | null;
|
|
31
|
-
/** When the poll that produced this item ran. Never null. */
|
|
32
|
-
readonly fetched_at: Timestamp;
|
|
33
|
-
}
|
|
34
|
-
/** Filter columns of `GET /intel_items`, on top of {@link BASE_FILTER_COLUMNS}. */
|
|
35
|
-
export declare const INTEL_ITEM_FILTER_COLUMNS: readonly ["intel_source_id", "external_id", "title", "content", "url"];
|
|
36
|
-
/** Filters for {@link IntelItemsNamespace.list}. */
|
|
37
|
-
export interface ListIntelItemsParams extends ListParams<(typeof INTEL_ITEM_FILTER_COLUMNS)[number]> {
|
|
38
|
-
/** Only items produced by one source. Sent as `exact_search[intel_source_id]`. */
|
|
39
|
-
readonly sourceId?: Id;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* `/intel_items` - the raw material.
|
|
43
|
-
*
|
|
44
|
-
* Read-only plus a delete: `creatable_by?` and `updatable_by?` are hard `false`
|
|
45
|
-
* and the route is `only: [:index, :show, :destroy]`. Items are written by
|
|
46
|
-
* `Intel::FetchSourceJob` and by nothing else.
|
|
47
|
-
*
|
|
48
|
-
* It is here because the stories only carry a citation stub
|
|
49
|
-
* ({@link IntelArticleSourceRef}) and this is the only way to read the body
|
|
50
|
-
* behind one.
|
|
51
|
-
*/
|
|
52
|
-
export declare class IntelItemsNamespace extends Resource {
|
|
53
|
-
/**
|
|
54
|
-
* `GET /intel_items` - raw items, newest first.
|
|
55
|
-
*
|
|
56
|
-
* **Heavy.** Every row carries {@link IntelItem.content} in full - the whole
|
|
57
|
-
* article text a script scraped - and there is no lighter view. The SDK
|
|
58
|
-
* defaults to a page of 25 for that reason; raising it is how you get a
|
|
59
|
-
* multi-megabyte response.
|
|
60
|
-
*
|
|
61
|
-
* Declared filters: `intel_source_id`, `external_id`, `title`, `content`,
|
|
62
|
-
* `url`, plus the inherited three. Note `processed_at` is NOT among them and
|
|
63
|
-
* is not on the payload either, so there is no way to list only the
|
|
64
|
-
* unprocessed items - {@link IntelStats.totals.pending_items} is the only
|
|
65
|
-
* window onto that backlog.
|
|
66
|
-
*
|
|
67
|
-
* The controller sets no ordering; the SDK sends `created_at:desc`.
|
|
68
|
-
*/
|
|
69
|
-
list(params?: ListIntelItemsParams, options?: RequestOptions): Promise<Paginated<IntelItem>>;
|
|
70
|
-
/**
|
|
71
|
-
* `GET /intel_items/:id` - one raw item.
|
|
72
|
-
*
|
|
73
|
-
* There are no `:extended` extras, so this is the same shape a listing row
|
|
74
|
-
* has. Use it to expand one {@link IntelArticleSourceRef} without
|
|
75
|
-
* pulling a page of bodies.
|
|
76
|
-
*
|
|
77
|
-
* @throws {OmsApiError} 404 when the item is not yours.
|
|
78
|
-
*/
|
|
79
|
-
get(id: Id, options?: RequestOptions): Promise<IntelItem>;
|
|
80
|
-
/**
|
|
81
|
-
* `DELETE /intel_items/:id`. `204`, empty body.
|
|
82
|
-
*
|
|
83
|
-
* Rarely what you want. The item's `external_id` uniqueness is what stops the
|
|
84
|
-
* next poll re-fetching it, so deleting one invites it straight back on the
|
|
85
|
-
* following run - and if the story built from it survives, you get a second
|
|
86
|
-
* citation of the same thing. Delete the SOURCE, or leave items alone.
|
|
87
|
-
*
|
|
88
|
-
* @throws {OmsApiError} 404 when the item is not yours.
|
|
89
|
-
*/
|
|
90
|
-
delete(id: Id, options?: RequestOptions): Promise<void>;
|
|
91
|
-
}
|