@butlerbot/sdk 0.0.40 → 0.0.41

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.
@@ -39,6 +39,13 @@ export type DeliveryClosed = {
39
39
  at: number;
40
40
  reason: DeliveryClosedReason;
41
41
  };
42
+ export declare const DELIVERY_SOURCES: readonly ["shift", "runtime", "gate"];
43
+ /**
44
+ * Who wrote the delivery: a job shift asking with `reach_user`, the runtime telling the user
45
+ * where a job stands, or the autonomy gate asking for an approval. Only a shift's own ask
46
+ * holds a finished job open until it is answered.
47
+ */
48
+ export type DeliverySource = typeof DELIVERY_SOURCES[number];
42
49
  export type DeliveryAnswer = {
43
50
  at: number;
44
51
  text: string;
@@ -69,6 +76,8 @@ export type Delivery = {
69
76
  * 409 the same way it does one already answered.
70
77
  */
71
78
  closed: DeliveryClosed | null;
79
+ /** Who wrote it. Rows from before this was recorded read as `runtime`. */
80
+ source: DeliverySource;
72
81
  created: number;
73
82
  };
74
83
  /** Whether a delivery is still waiting on the user: unanswered, and not closed under it. */
@@ -7,7 +7,7 @@
7
7
  * on that job's inbox.
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.DELIVERY_CLOSED_REASONS = exports.DELIVERY_ANSWER_VIA = exports.DELIVERY_SURFACE_STATUSES = exports.DELIVERY_SURFACES = exports.ANSWERABLE_DELIVERY_INTENTS = exports.DELIVERY_INTENTS = void 0;
10
+ exports.DELIVERY_SOURCES = exports.DELIVERY_CLOSED_REASONS = exports.DELIVERY_ANSWER_VIA = exports.DELIVERY_SURFACE_STATUSES = exports.DELIVERY_SURFACES = exports.ANSWERABLE_DELIVERY_INTENTS = exports.DELIVERY_INTENTS = void 0;
11
11
  exports.isDeliveryOpen = isDeliveryOpen;
12
12
  exports.DELIVERY_INTENTS = ["question", "update", "approval", "statement"];
13
13
  /** The intents that leave something outstanding until the user answers. */
@@ -16,6 +16,7 @@ exports.DELIVERY_SURFACES = ["web", "discord"];
16
16
  exports.DELIVERY_SURFACE_STATUSES = ["pending", "sent", "failed"];
17
17
  exports.DELIVERY_ANSWER_VIA = ["web", "discord", "chat", "tool"];
18
18
  exports.DELIVERY_CLOSED_REASONS = ["job_done", "job_failed", "job_cancelled"];
19
+ exports.DELIVERY_SOURCES = ["shift", "runtime", "gate"];
19
20
  /** Whether a delivery is still waiting on the user: unanswered, and not closed under it. */
20
21
  function isDeliveryOpen(delivery) {
21
22
  return exports.ANSWERABLE_DELIVERY_INTENTS.includes(delivery.intent) && !delivery.answered && !delivery.closed;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@butlerbot/sdk",
3
- "version": "0.0.40",
3
+ "version": "0.0.41",
4
4
  "description": "The official ButlerBot SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/readme.md CHANGED
@@ -383,7 +383,9 @@ it. An approval takes `decision: "approve" | "deny"` alongside the text.
383
383
 
384
384
  A delivery whose job ended before anyone answered is closed instead: `closed` carries the time
385
385
  and a reason of `job_done`, `job_failed` or `job_cancelled`. `isDeliveryOpen` reads false for
386
- one, and answering it is refused with a 409 just as one already answered is.
386
+ one, and answering it is refused with a 409 just as one already answered is. `source` says who
387
+ wrote a delivery: `shift` for a question a job's shift asked, `runtime` for the job's own
388
+ status tells, `gate` for an approval the autonomy gate asked for.
387
389
 
388
390
  ### When a call fails
389
391