@kana-ai/edgar-sdk 0.1.7 → 0.1.8
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
CHANGED
|
@@ -154,7 +154,7 @@ A tool that throws ends as `permanent_failure(tool_error)`, which the engine nev
|
|
|
154
154
|
### Trackers, hooks and environments
|
|
155
155
|
|
|
156
156
|
- `defineTracker(spec)` makes the extension a tracker of the project that maps its `[extensions.<name>.columns]`: `list_cards`, `card`, `comments`, `attachments`, `comment`, `move`, `set_labels`, `create_card`, `close`, `whoami` and `person`. The engine sweeps it with engine states; the extension maps them to its columns with `[extensions.<name>.columns]` and answers engine states. `comments` answers the comments made, edited or deleted after `since`: an edited comment has `edited_at`, and a deleted one also `deleted: true`, for a vendor that reports deletes. Each card and each comment says in `trust` whether the person who wrote it is on the team (`team`) or not (`outside`); a tracker that does not say is read as `outside`. `card` answers `not_found` for a card that is archived or deleted, also when the vendor can still read it: the engine reads a card that a listing no longer has, and only `not_found` or a column that is not mapped says that the card left.
|
|
157
|
-
- The card block helpers read and write the fenced `edgar:v0` TOML block in a card's description, so each tracker keeps the block in the same form. `readBlock(description)` answers `ok(null)` for no block, the parsed `CardBlock`, or `permanent_failure(invalid)` with the TOML line or the fields that do not match in `cause`. `invalidBlock(failure)` turns that failure into the `{invalid: "<why>"}` block a listed card carries, so the engine refuses the card with that reason. `withBlock(description, block)` replaces the block, or adds it at the end. `blockLine(key, value)` is the TOML line of `batch`, `fingerprint` or `waits_for` that a search of descriptions finds. `normalFingerprint(raw)` lowercases a fingerprint of 16 or more hex characters and cuts it to 16. `sighted(block, at)` counts one more sighting at `at`, or answers `null` when `at` is not newer than `last_seen`, as for a retry. `oneAtATime(key, run)` runs `run` after every earlier call of `key` in the process has settled, so two calls that file one fingerprint cannot both miss the card the other files. For a tracker's `retitle`, `retitled(block, title,
|
|
157
|
+
- The card block helpers read and write the fenced `edgar:v0` TOML block in a card's description, so each tracker keeps the block in the same form. `readBlock(description)` answers `ok(null)` for no block, the parsed `CardBlock`, or `permanent_failure(invalid)` with the TOML line or the fields that do not match in `cause`. `invalidBlock(failure)` turns that failure into the `{invalid: "<why>"}` block a listed card carries, so the engine refuses the card with that reason. `withBlock(description, block)` replaces the block, or adds it at the end. `blockLine(key, value)` is the TOML line of `batch`, `fingerprint` or `waits_for` that a search of descriptions finds. `normalFingerprint(raw)` lowercases a fingerprint of 16 or more hex characters and cuts it to 16. `sighted(block, at)` counts one more sighting at `at`, or answers `null` when `at` is not newer than `last_seen`, as for a retry. `oneAtATime(key, run)` runs `run` after every earlier call of `key` in the process has settled, so two calls that file one fingerprint cannot both miss the card the other files. For a tracker's `retitle`, `retitled(block, title, text, prefix)` is the first sentence of `text`, after the prefix, for a card whose block names the feeder that opened it in `decided.opened_by`; it is `undefined` for a card a person wrote, one already titled so, or a `text` whose first sentence is over 100 characters or that has an ellipsis, so the card keeps its title rather than take a cut one.
|
|
158
158
|
- A fault that comes back after its card closed: when `create_card` finds no open card with the fingerprint, a tracker looks for the newest closed one as a `ClosedHolder` (`id`, `url`, `cancelled`, `closed_at`). When `reopens(closed, at)` is true, which is only for a card done less than `REOPEN_DAYS` (30) days before, the tracker writes `reopenedDescription(description, at)`, which adds `backLine(at)` and counts the sighting, moves the card to `ready`, and answers that card. Otherwise it files a new card whose description ends with `earlierLine(closed)`. When `closed.note` is set, that line also quotes the decision a person left there: `lastNote(comments, closed_at, person)` picks the newest comment before the close that `person` says a person wrote, not EDGAR or a bot, and `earlierLine` quotes it cut to 280 characters. Triage reads the line as part of the new card's description. A person's newer comment on the new card still wins, since a comment starts `resume` with that comment's text. A cancelled card is never opened again, since a person decided not to work it. The note goes in the description, not in a comment, because a comment that the tracker writes by itself would read as a person's.
|
|
159
159
|
- `defineHook({ on, secrets, capabilities, check })` runs before (`before_tool`) or after (`after_tool`) each tool call that `[hooks] order` names it for. `check` returns `pass()`, or `deny(code, reason)`, which ends the call `permanent_failure(denied_by_hook)` with the reason.
|
|
160
160
|
- A tracker's `mentions` is optional: a tracker that has it answers the comments made after `since` on any card that mention EDGAR's account, each with its `card`, and the engine reads it once a sweep so a mention on a card that no run holds starts the `mention` workflow.
|
|
@@ -37,7 +37,7 @@ export declare function backLine(at: string): string;
|
|
|
37
37
|
export declare function earlierLine(closed: ClosedHolder): string;
|
|
38
38
|
/** The description of a card opened again: its text with `backLine`, once for each `at`, and its block after one more sighting at `at`. A description with no block gets the line only. */
|
|
39
39
|
export declare function reopenedDescription(description: string, at: string): string;
|
|
40
|
-
/** The title in plain words for a card that a feeder filed: the first sentence of `
|
|
41
|
-
export declare function retitled(block: CardBlock | null, title: string,
|
|
40
|
+
/** The title in plain words for a card that a feeder filed: the first sentence of `text`, after `prefix` when the tracker scopes its cards by one. `undefined` keeps the title: for a block that names no feeder in `decided.opened_by`, as for a card a person wrote, for a text with no words, with an ellipsis, or whose first sentence is over 100 characters, since a cut title reads as broken, and when `title` already reads so. */
|
|
41
|
+
export declare function retitled(block: CardBlock | null, title: string, text: string, prefix?: string): string | undefined;
|
|
42
42
|
/** Runs `run` once every earlier call of `key` in this process has settled, so two calls that file one fingerprint cannot both miss the card the other files. */
|
|
43
43
|
export declare function oneAtATime<T>(key: string, run: () => Promise<T>): Promise<T>;
|
|
@@ -95,21 +95,19 @@ export function reopenedDescription(description, at) {
|
|
|
95
95
|
return text;
|
|
96
96
|
return withBlock(text, sighted(block.value, at) ?? block.value);
|
|
97
97
|
}
|
|
98
|
-
/** The most characters of a title that `retitled` takes
|
|
98
|
+
/** The most characters of a title that `retitled` takes, before the tracker's prefix. */
|
|
99
99
|
const TITLE_CHARS = 100;
|
|
100
|
-
/** The title in plain words for a card that a feeder filed: the first sentence of `
|
|
101
|
-
export function retitled(block, title,
|
|
100
|
+
/** The title in plain words for a card that a feeder filed: the first sentence of `text`, after `prefix` when the tracker scopes its cards by one. `undefined` keeps the title: for a block that names no feeder in `decided.opened_by`, as for a card a person wrote, for a text with no words, with an ellipsis, or whose first sentence is over 100 characters, since a cut title reads as broken, and when `title` already reads so. */
|
|
101
|
+
export function retitled(block, title, text, prefix = "") {
|
|
102
102
|
if (block?.decided?.["opened_by"] === undefined)
|
|
103
103
|
return undefined;
|
|
104
|
-
const words =
|
|
104
|
+
const words = text.trim().replaceAll(/\s+/g, " ");
|
|
105
|
+
if (/…|\.\.\./.test(words))
|
|
106
|
+
return undefined;
|
|
105
107
|
const sentence = (/^.+?[.!?](?=\s|$)/.exec(words)?.[0] ?? words).replace(/[.!?]$/, "");
|
|
106
|
-
if (sentence === "")
|
|
108
|
+
if (sentence === "" || sentence.length > TITLE_CHARS)
|
|
107
109
|
return undefined;
|
|
108
|
-
const
|
|
109
|
-
const cut = sentence.length <= TITLE_CHARS
|
|
110
|
-
? sentence
|
|
111
|
-
: `${sentence.slice(0, space > 0 ? space : TITLE_CHARS)}…`;
|
|
112
|
-
const plain = prefix === "" ? cut : `${prefix} ${cut}`;
|
|
110
|
+
const plain = prefix === "" ? sentence : `${prefix} ${sentence}`;
|
|
113
111
|
return plain === title ? undefined : plain;
|
|
114
112
|
}
|
|
115
113
|
const pending = new Map();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kana-ai/edgar-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Define EDGAR extensions: tools, a tracker, environments and hooks, and build their manifest.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"./testing": "./dist/src/testing/index.js"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@kana-ai/edgar-contracts": "0.1.
|
|
32
|
+
"@kana-ai/edgar-contracts": "0.1.8",
|
|
33
33
|
"smol-toml": "1.9.1",
|
|
34
34
|
"undici": "7.30.2"
|
|
35
35
|
},
|