@fungi.computer/bird-dog 0.0.1 → 0.1.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 CHANGED
@@ -163,6 +163,13 @@ schedules an immediate wake and continues from the same place on the next drain.
163
163
  receipt under the same key. Replaying the same settlement after a restart finds
164
164
  the receipt and does not post the reply again. Keep those receipts as long as
165
165
  source settlements can replay. BirdDog does not expire them.
166
+ `hasPendingDelivery(outbox)` reads only whether any reply still awaits a
167
+ delivery attempt, so a host can tell retained receipts and dead letters from
168
+ owed mail.
169
+
170
+ The Effect mail room's `nextWakeAt()` reads Carrier's earliest owed delivery,
171
+ including future retries. Runtime hosts include that hint in their pending-work
172
+ answer rather than clearing a retry when other runtime work is idle.
166
173
 
167
174
  **Host ports.** `BirdDog.make` takes four things:
168
175
 
@@ -182,11 +189,12 @@ The generated reference is in [docs/api](docs/api/README.md).
182
189
  `BirdDogAgentJobPayload`, `BirdDogReply`, `BirdDogOutbox`, `BirdDogOptions`,
183
190
  `BirdDogSettlement` and `BirdDogRuntime` types.
184
191
  - `@fungi.computer/bird-dog/effect`: `make`, `agentJobFromInput`,
185
- `decodeAgentJob`, `settlementReplies`, `boundedDiagnostic`,
186
- `BIRD_DOG_DIAGNOSTIC_MAX_LENGTH`, `BirdDogError`, `EffectBirdDogOptions`,
187
- `BirdDogEffect` and the schemas `BirdDogAgentReferenceSchema`,
188
- `BirdDogReplySchema`, `BirdDogMailSchema`, `BirdDogAgentWorkSchema`,
189
- `BirdDogAgentJobPayloadSchema` and `BirdDogAgentJobInputSchema`.
192
+ `decodeAgentJob`, `settlementReplies`, `hasPendingDelivery`,
193
+ `boundedDiagnostic`, `BIRD_DOG_DIAGNOSTIC_MAX_LENGTH`, `BirdDogError`,
194
+ `EffectBirdDogOptions`, `BirdDogEffect` and the schemas
195
+ `BirdDogAgentReferenceSchema`, `BirdDogReplySchema`, `BirdDogMailSchema`,
196
+ `BirdDogAgentWorkSchema`, `BirdDogAgentJobPayloadSchema` and
197
+ `BirdDogAgentJobInputSchema`.
190
198
 
191
199
  ## Examples and checks
192
200
 
package/dist/effect.d.ts CHANGED
@@ -174,6 +174,8 @@ export type BirdDogEffect = Readonly<{
174
174
  fanOut: (settlement: BirdDogSettlement) => Effect.Effect<void, BirdDogError>;
175
175
  /** Deliver due replies and schedule any required retry wake. */
176
176
  drainOutbox: () => Effect.Effect<void, BirdDogError>;
177
+ /** Earliest owed reply delivery, including retries; absent after delivery. */
178
+ nextWakeAt: () => Effect.Effect<number | undefined, BirdDogError>;
177
179
  }>;
178
180
  /** Validate and translate agent work into Watchdog's opaque job grammar. */
179
181
  export declare const agentJobFromInput: (input: BirdDogAgentJobInput) => WatchdogQueuedJob;
@@ -187,5 +189,10 @@ export declare const decodeAgentJob: (job: WatchdogStoredJob) => BirdDogAgentJob
187
189
  * are presented. A reply never carries the settled work's host metadata.
188
190
  */
189
191
  export declare function settlementReplies(settlement: BirdDogSettlement, createdAt: number): readonly BirdDogMail[];
192
+ /**
193
+ * Whether this mail room's outbox still owes any reply a delivery attempt.
194
+ * Delivered receipts and exhausted dead letters stay but owe nothing.
195
+ */
196
+ export declare const hasPendingDelivery: (outbox: Pick<EffectBirdDogOptions["outbox"], "list">) => Effect.Effect<boolean, BirdDogError>;
190
197
  /** Construct BirdDog's Effect-native mail room over Post's shared outbox. */
191
198
  export declare const make: (options: EffectBirdDogOptions) => Effect.Effect<BirdDogEffect>;
package/dist/effect.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as Effect from "effect/Effect";
2
2
  import * as Schema from "effect/Schema";
3
- import { makePostOutbox } from "@fungi.computer/carrier/post";
3
+ import { makePostOutbox, postOutboxPending, } from "@fungi.computer/carrier/post";
4
4
  const Identifier = Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(256));
5
5
  /** Parser for an ordinary agent Session address. */
6
6
  export const BirdDogAgentReferenceSchema = Schema.Struct({
@@ -150,6 +150,11 @@ export function settlementReplies(settlement, createdAt) {
150
150
  reply,
151
151
  }));
152
152
  }
153
+ /**
154
+ * Whether this mail room's outbox still owes any reply a delivery attempt.
155
+ * Delivered receipts and exhausted dead letters stay but owe nothing.
156
+ */
157
+ export const hasPendingDelivery = (outbox) => postOutboxPending({ message: BirdDogMailSchema, outbox });
153
158
  /** Construct BirdDog's Effect-native mail room over Post's shared outbox. */
154
159
  export const make = (options) => {
155
160
  const post = makePostOutbox({
@@ -177,5 +182,9 @@ export const make = (options) => {
177
182
  if (wake !== undefined)
178
183
  yield* options.scheduleWake(wake);
179
184
  });
180
- return Effect.succeed({ fanOut, drainOutbox: post.drain });
185
+ return Effect.succeed({
186
+ fanOut,
187
+ drainOutbox: post.drain,
188
+ nextWakeAt: post.nextWakeAt,
189
+ });
181
190
  };
@@ -90,6 +90,7 @@ Effect host ports for the durable mail room.
90
90
  type BirdDogEffect = Readonly<{
91
91
  fanOut: (settlement) => Effect.Effect<void, BirdDogError>;
92
92
  drainOutbox: () => Effect.Effect<void, BirdDogError>;
93
+ nextWakeAt: () => Effect.Effect<number | undefined, BirdDogError>;
93
94
  }>;
94
95
  ```
95
96
 
@@ -455,6 +456,27 @@ readonly `Readonly`\<\{ `key`: `string`; `to`:
455
456
 
456
457
  ---
457
458
 
459
+ ### hasPendingDelivery()
460
+
461
+ ```ts
462
+ function hasPendingDelivery(outbox): Effect<boolean, BirdDogError>;
463
+ ```
464
+
465
+ Whether this mail room's outbox still owes any reply a delivery attempt.
466
+ Delivered receipts and exhausted dead letters stay but owe nothing.
467
+
468
+ #### Parameters
469
+
470
+ | Parameter | Type |
471
+ | --------- | --------------------------------------------------------------------------------- |
472
+ | `outbox` | `Pick`\<[`EffectBirdDogOptions`](#effectbirddogoptions)\[`"outbox"`\], `"list"`\> |
473
+
474
+ #### Returns
475
+
476
+ `Effect`\<`boolean`, [`BirdDogError`](#birddogerror)\>
477
+
478
+ ---
479
+
458
480
  ### make()
459
481
 
460
482
  ```ts
@@ -462,6 +484,7 @@ function make(options): Effect<
462
484
  Readonly<{
463
485
  fanOut: (settlement) => Effect<void, BirdDogError>;
464
486
  drainOutbox: () => Effect<void, BirdDogError>;
487
+ nextWakeAt: () => Effect<number | undefined, BirdDogError>;
465
488
  }>
466
489
  >;
467
490
  ```
@@ -478,4 +501,5 @@ Construct BirdDog's Effect-native mail room over Post's shared outbox.
478
501
 
479
502
  `Effect`\<`Readonly`\<\{ `fanOut`: (`settlement`) => `Effect`\<`void`,
480
503
  [`BirdDogError`](#birddogerror)\>; `drainOutbox`: () => `Effect`\<`void`,
481
- [`BirdDogError`](#birddogerror)\>; \}\>\>
504
+ [`BirdDogError`](#birddogerror)\>; `nextWakeAt`: () => `Effect`\<`number` \|
505
+ `undefined`, [`BirdDogError`](#birddogerror)\>; \}\>\>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/bird-dog",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "description": "Durable addressed agent mail over generic Watchdog work",
6
6
  "type": "module",
@@ -23,8 +23,8 @@
23
23
  "LICENSE"
24
24
  ],
25
25
  "dependencies": {
26
- "@fungi.computer/carrier": "0.0.1",
27
- "@fungi.computer/watchdog": "0.0.1",
26
+ "@fungi.computer/carrier": "0.1.0",
27
+ "@fungi.computer/watchdog": "0.1.0",
28
28
  "effect": "4.0.2"
29
29
  },
30
30
  "devDependencies": {