@ixo/oracle-runtime-workers 0.30.0 → 0.31.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.
Files changed (44) hide show
  1. package/package.json +7 -5
  2. package/src/attachments/channel-links.ts +135 -0
  3. package/src/attachments/channel.ts +203 -0
  4. package/src/attachments/download.ts +23 -6
  5. package/src/attachments/index.ts +23 -0
  6. package/src/attachments/pipeline.ts +120 -42
  7. package/src/attachments/retention.ts +11 -3
  8. package/src/attachments/sanitize.ts +20 -8
  9. package/src/attachments/types.ts +7 -0
  10. package/src/attachments/view.ts +24 -7
  11. package/src/channels/contract.ts +69 -0
  12. package/src/channels/turns.ts +23 -1
  13. package/src/core/main-agent-types.ts +2 -0
  14. package/src/core/runtime-context.ts +3 -0
  15. package/src/delivery/plan.ts +3 -1
  16. package/src/do/contracts.ts +3 -0
  17. package/src/do/turn-attachments.ts +103 -0
  18. package/src/do/user-oracle-do.ts +142 -42
  19. package/src/hub-actions/client.ts +87 -7
  20. package/src/hub-actions/hub-text.ts +82 -0
  21. package/src/hub-actions/request.ts +7 -4
  22. package/src/hub-actions/store.ts +5 -1
  23. package/src/hub-actions/transfer.ts +23 -6
  24. package/src/index.ts +1 -0
  25. package/src/plugin-api/index.ts +1 -0
  26. package/src/plugin-api/types.ts +43 -2
  27. package/src/plugins/attachments/view-attachment-tool.ts +7 -3
  28. package/src/plugins/hub-actions/hub-actions.plugin.ts +96 -17
  29. package/src/plugins/ixo-chain/blocksync.ts +6 -2
  30. package/src/plugins/ixo-chain/http.ts +16 -8
  31. package/src/plugins/ixo-chain/rest.ts +7 -1
  32. package/src/plugins/yoma/catalog.ts +780 -0
  33. package/src/plugins/yoma/clef.ts +98 -0
  34. package/src/plugins/yoma/drafts.ts +339 -0
  35. package/src/plugins/yoma/engine.ts +926 -0
  36. package/src/plugins/yoma/index.ts +13 -0
  37. package/src/plugins/yoma/judge.ts +358 -0
  38. package/src/plugins/yoma/permission.ts +62 -0
  39. package/src/plugins/yoma/reads.ts +195 -0
  40. package/src/plugins/yoma/submission.ts +534 -0
  41. package/src/plugins/yoma/text.ts +16 -0
  42. package/src/plugins/yoma/work.ts +190 -0
  43. package/src/plugins/yoma/yoma.plugin.ts +2162 -0
  44. package/src/sqlite/serialization.ts +2 -0
@@ -10,7 +10,12 @@ import {
10
10
  fetchWithoutRedirects,
11
11
  } from '../../core/domain-context/transport';
12
12
 
13
- export type Source = 'chain' | 'blocksync';
13
+ /**
14
+ * Where a read goes. `chain` and `blocksync` are ixo-chain's; the Yoma
15
+ * plugin (`../yoma`) adds the Jambo worker's job list and the documents
16
+ * entities link to (profiles, forms), under the same policy.
17
+ */
18
+ export type Source = 'chain' | 'blocksync' | 'job-list' | 'document';
14
19
 
15
20
  export type FailureReason =
16
21
  | 'rate_limited'
@@ -61,6 +66,8 @@ export const ERROR_BODY_MAX_BYTES = 8 * 1024;
61
66
  const SOURCE_NAME: Record<Source, string> = {
62
67
  chain: 'The chain node',
63
68
  blocksync: 'Blocksync',
69
+ 'job-list': 'The Yoma job list',
70
+ document: 'The document host',
64
71
  };
65
72
 
66
73
  function rateLimited(source: Source): Failure {
@@ -99,7 +106,7 @@ function timedOut(source: Source): Failure {
99
106
  detail:
100
107
  source === 'blocksync'
101
108
  ? 'Blocksync did not answer in time; narrow the question (fewer rows or requests).'
102
- : 'The chain node did not answer in time; try again shortly.',
109
+ : `${SOURCE_NAME[source]} did not answer in time; try again shortly.`,
103
110
  retryable: true,
104
111
  };
105
112
  }
@@ -271,6 +278,8 @@ function recordHealth(upstream: string, attempt: Attempt<unknown>): void {
271
278
  export interface Read {
272
279
  label: string;
273
280
  upstream: string;
281
+ /** The log line's tag; `[ixo-chain]` unless the reading plugin names its own. */
282
+ tag?: string;
274
283
  }
275
284
 
276
285
  /**
@@ -286,10 +295,11 @@ export async function withRetry<T>(
286
295
  read: Read,
287
296
  attempt: () => Promise<Attempt<T>>,
288
297
  ): Promise<Outcome<T>> {
298
+ const tag = read.tag ?? '[ixo-chain]';
289
299
  const held = heldBack(read.upstream);
290
300
  if (held) {
291
301
  console.warn(
292
- `[ixo-chain] ${read.label} not attempted: the upstream failed moments ago (${held.note})`,
302
+ `${tag} ${read.label} not attempted: the upstream failed moments ago (${held.note})`,
293
303
  );
294
304
  return { ok: false, failure: held.failure };
295
305
  }
@@ -297,7 +307,7 @@ export async function withRetry<T>(
297
307
  recordHealth(read.upstream, first);
298
308
  if (first.ok && !first.retry) return { ok: true, value: first.value };
299
309
  if (first.ok || !first.quiet)
300
- console.warn(`[ixo-chain] ${read.label} attempt 1 failed: ${first.note}`);
310
+ console.warn(`${tag} ${read.label} attempt 1 failed: ${first.note}`);
301
311
  const wait =
302
312
  !first.ok && first.retryAfterMs !== undefined
303
313
  ? first.retryAfterMs
@@ -313,12 +323,10 @@ export async function withRetry<T>(
313
323
  recordHealth(read.upstream, second);
314
324
  if (second.ok) {
315
325
  if (second.retry)
316
- console.warn(
317
- `[ixo-chain] ${read.label} attempt 2 failed: ${second.note}`,
318
- );
326
+ console.warn(`${tag} ${read.label} attempt 2 failed: ${second.note}`);
319
327
  return { ok: true, value: second.value };
320
328
  }
321
- console.warn(`[ixo-chain] ${read.label} attempt 2 failed: ${second.note}`);
329
+ console.warn(`${tag} ${read.label} attempt 2 failed: ${second.note}`);
322
330
  return first.ok
323
331
  ? { ok: true, value: first.value }
324
332
  : { ok: false, failure: second.failure };
@@ -20,6 +20,8 @@ export const REST_ATTEMPT_TIMEOUT_MS = 8_000;
20
20
  export interface RestOptions {
21
21
  /** Names the read in log lines (never the path: it carries an address). */
22
22
  label: string;
23
+ /** The log line's tag (`[ixo-chain]` by default). */
24
+ tag?: string;
23
25
  timeoutMs?: number;
24
26
  maxBytes?: number;
25
27
  /** A 404 is a quiet `not_found` failure instead of `unavailable`. */
@@ -99,7 +101,11 @@ export async function restJson<S extends z.ZodType>(
99
101
  const url = `${base}${path}`;
100
102
  const read = await withRetry<Found<z.infer<S>>>(
101
103
  call,
102
- { label: opts.label, upstream: base },
104
+ {
105
+ label: opts.label,
106
+ upstream: base,
107
+ ...(opts.tag ? { tag: opts.tag } : {}),
108
+ },
103
109
  async () => {
104
110
  const answer = await exchange(
105
111
  call,