@yaks/tools 0.0.0-stage → 0.2.36

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 (138) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +870 -2
  3. package/_dist/access.d.ts +3 -0
  4. package/_dist/access.d.ts.map +1 -0
  5. package/_dist/app-view.d.ts +27 -0
  6. package/_dist/app-view.d.ts.map +1 -0
  7. package/_dist/args.d.ts +23 -0
  8. package/_dist/args.d.ts.map +1 -0
  9. package/_dist/check.d.ts +32 -0
  10. package/_dist/check.d.ts.map +1 -0
  11. package/_dist/declared.d.ts +66 -0
  12. package/_dist/declared.d.ts.map +1 -0
  13. package/_dist/display.d.ts +2 -0
  14. package/_dist/display.d.ts.map +1 -0
  15. package/_dist/errors.d.ts +46 -0
  16. package/_dist/errors.d.ts.map +1 -0
  17. package/_dist/fault.d.ts +4 -0
  18. package/_dist/fault.d.ts.map +1 -0
  19. package/_dist/invoke.d.ts +13 -0
  20. package/_dist/invoke.d.ts.map +1 -0
  21. package/_dist/mod.d.ts +31 -0
  22. package/_dist/mod.d.ts.map +1 -0
  23. package/_dist/outlast.d.ts +89 -0
  24. package/_dist/outlast.d.ts.map +1 -0
  25. package/_dist/persist.d.ts +5 -0
  26. package/_dist/persist.d.ts.map +1 -0
  27. package/_dist/read.d.ts +4 -0
  28. package/_dist/read.d.ts.map +1 -0
  29. package/_dist/readable.d.ts +59 -0
  30. package/_dist/readable.d.ts.map +1 -0
  31. package/_dist/registry.d.ts +53 -0
  32. package/_dist/registry.d.ts.map +1 -0
  33. package/_dist/result.d.ts +154 -0
  34. package/_dist/result.d.ts.map +1 -0
  35. package/_dist/routes.d.ts +11 -0
  36. package/_dist/routes.d.ts.map +1 -0
  37. package/_dist/runner.d.ts +161 -0
  38. package/_dist/runner.d.ts.map +1 -0
  39. package/_dist/said.d.ts +4 -0
  40. package/_dist/said.d.ts.map +1 -0
  41. package/_dist/schema.d.ts +76 -0
  42. package/_dist/schema.d.ts.map +1 -0
  43. package/_dist/state.d.ts +9 -0
  44. package/_dist/state.d.ts.map +1 -0
  45. package/_dist/title.d.ts +20 -0
  46. package/_dist/title.d.ts.map +1 -0
  47. package/_dist/value.d.ts +43 -0
  48. package/_dist/value.d.ts.map +1 -0
  49. package/_dist/views.d.ts +5 -0
  50. package/_dist/views.d.ts.map +1 -0
  51. package/_dist/vocab.d.ts +9 -0
  52. package/_dist/vocab.d.ts.map +1 -0
  53. package/_dist/watch.d.ts +28 -0
  54. package/_dist/watch.d.ts.map +1 -0
  55. package/access.js +3 -0
  56. package/access.js.map +1 -0
  57. package/access.ts +11 -0
  58. package/app-view.js +26 -0
  59. package/app-view.js.map +1 -0
  60. package/app-view.ts +41 -0
  61. package/args.js +136 -0
  62. package/args.js.map +1 -0
  63. package/args.ts +187 -0
  64. package/body.js +14 -0
  65. package/body.js.map +1 -0
  66. package/body.ts +15 -0
  67. package/check.js +67 -0
  68. package/check.js.map +1 -0
  69. package/check.ts +92 -0
  70. package/declared.js +529 -0
  71. package/declared.js.map +1 -0
  72. package/declared.ts +719 -0
  73. package/deno.json +1 -0
  74. package/display.js +21 -0
  75. package/display.js.map +1 -0
  76. package/display.ts +39 -0
  77. package/errors.js +99 -0
  78. package/errors.js.map +1 -0
  79. package/errors.ts +127 -0
  80. package/fault.js +17 -0
  81. package/fault.js.map +1 -0
  82. package/fault.ts +24 -0
  83. package/invoke.js +207 -0
  84. package/invoke.js.map +1 -0
  85. package/invoke.ts +210 -0
  86. package/mod.js +31 -0
  87. package/mod.js.map +1 -0
  88. package/mod.ts +78 -0
  89. package/outlast.js +416 -0
  90. package/outlast.js.map +1 -0
  91. package/outlast.ts +551 -0
  92. package/package.json +109 -4
  93. package/persist.js +18 -0
  94. package/persist.js.map +1 -0
  95. package/persist.ts +26 -0
  96. package/read.js +50 -0
  97. package/read.js.map +1 -0
  98. package/read.ts +58 -0
  99. package/readable.js +118 -0
  100. package/readable.js.map +1 -0
  101. package/readable.ts +134 -0
  102. package/registry.js +162 -0
  103. package/registry.js.map +1 -0
  104. package/registry.ts +207 -0
  105. package/result.js +497 -0
  106. package/result.js.map +1 -0
  107. package/result.ts +540 -0
  108. package/routes.js +46 -0
  109. package/routes.js.map +1 -0
  110. package/routes.ts +50 -0
  111. package/runner.js +748 -0
  112. package/runner.js.map +1 -0
  113. package/runner.ts +910 -0
  114. package/said.js +15 -0
  115. package/said.js.map +1 -0
  116. package/said.ts +12 -0
  117. package/schema.js +137 -0
  118. package/schema.js.map +1 -0
  119. package/schema.ts +134 -0
  120. package/state.js +69 -0
  121. package/state.js.map +1 -0
  122. package/state.ts +108 -0
  123. package/title.js +222 -0
  124. package/title.js.map +1 -0
  125. package/title.ts +257 -0
  126. package/value.js +57 -0
  127. package/value.js.map +1 -0
  128. package/value.ts +74 -0
  129. package/views.js +131 -0
  130. package/views.js.map +1 -0
  131. package/views.ts +125 -0
  132. package/vocab.js +22 -0
  133. package/vocab.js.map +1 -0
  134. package/vocab.json +268 -0
  135. package/vocab.ts +22 -0
  136. package/watch.js +64 -0
  137. package/watch.js.map +1 -0
  138. package/watch.ts +74 -0
@@ -0,0 +1,3 @@
1
+ export type Floor = 'person' | 'editor' | 'owner';
2
+ export declare let mayCall: (floor: Floor | undefined, person: string | null, role: string | null) => any;
3
+ //# sourceMappingURL=access.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access.d.ts","sources":["../access.ts"],"names":[],"mappings":"AACA,YAAY,QAAQ,WAAW,WAAW;AAE1C,OAAO,YAAI,UACT,OAAO,QAAQ,SAAS,EACxB,QAAQ,MAAM,GAAG,IAAI,EACrB,MAAM,MAAM,GAAG,IAAI,SAI0C"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The type a view is served under: text/html with the profile the MCP Apps
3
+ * spec requires, which is how a host tells a page it renders from a page it
4
+ * merely reads.
5
+ */ export declare let VIEW_MIME: string;
6
+ /**
7
+ * The origins a view is allowed to reach, by what it reaches them for (MCP
8
+ * Apps §Resource _meta): `connectDomains` is fetch and websockets,
9
+ * `resourceDomains` is images, styles, scripts and fonts, `baseUriDomains` is
10
+ * what a `<base href>` may name. Anything not listed is refused by the host's
11
+ * own CSP, so an empty policy means a page that fetches nothing at all,
12
+ * which is a declaration, not a gap.
13
+ */ export type Csp = {
14
+ connectDomains?: string[];
15
+ resourceDomains?: string[];
16
+ baseUriDomains?: string[];
17
+ };
18
+ /**
19
+ * Resource metadata for both portable MCP Apps and ChatGPT, on resource
20
+ * listings and read contents. `ui.domain` is optional and host-specific:
21
+ * Claude expects a hashed hostname, while ChatGPT accepts a website origin,
22
+ * so the OpenAI value is never copied into the portable field. The CSP lists
23
+ * the network destinations; it does not set the sandbox origin.
24
+ * https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/2026-01-26/apps.mdx
25
+ * https://developers.openai.com/plugins/reference
26
+ */ export declare let uiMeta: (domain: string, csp?: Csp) => any;
27
+ //# sourceMappingURL=app-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-view.d.ts","sources":["../app-view.ts"],"names":[],"mappings":"AAGA;;;;CAIC,GACD,OAAO,YAAI,kBAAuC;AAElD;;;;;;;CAOC,GACD,YAAY;EACV,iBAAiB,MAAM;EACvB,kBAAkB,MAAM;EACxB,iBAAiB,MAAM;;AAGzB;;;;;;;;CAQC,GACD,OAAO,YAAI,SAAU,QAAQ,MAAM,EAAE,MAAK,YAOxC"}
@@ -0,0 +1,23 @@
1
+ export { CallError } from "./errors.js";
2
+ type Args = Record<string, unknown>;
3
+ /** A call's arguments as stored: an object, or none at all, which asks with
4
+ * none. */ export declare let parsed: (args: unknown) => Args;
5
+ /**
6
+ * `schema` with no argument marked a reference: what a runner is handed for a
7
+ * tool whose own run resolves them where it reads (@yaks/tools `invoke`), so
8
+ * an id is never resolved first against a store the tool does not read.
9
+ *
10
+ * ```ts
11
+ * import { unreferenced } from './args.ts'
12
+ *
13
+ * unreferenced({
14
+ * type: 'object',
15
+ * properties: {
16
+ * id: { type: 'string', ref: 'entity' },
17
+ * ids: { type: 'array', items: { type: 'string', ref: 'task' } },
18
+ * },
19
+ * })
20
+ * // { type: 'object', properties: { id: { type: 'string' }, ids: { type: 'array', items: { type: 'string' } } } }
21
+ * ```
22
+ */ export declare let unreferenced: <S extends Args>(schema: S) => S;
23
+ //# sourceMappingURL=args.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.d.ts","sources":["../args.ts"],"names":[],"mappings":"AAaA,SAAS,SAAS,sBAAqB;KAElC,OAAO,OAAO,MAAM,EAAE,OAAO;AAElC;SACS,GACT,OAAO,YAAI,SAAU,MAAM,OAAO,KAAG,KAMpC;AAiCD;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,YAAI,eAAgB,UAAU,MAAM,QAAQ,MAAI,EAgBtD"}
@@ -0,0 +1,32 @@
1
+ import type { Bundle, Eid } from "@yaks/graph";
2
+ /** The verb that makes a tool a check. */ export declare let CHECK: string;
3
+ /** How bad a finding is. `fail` means a contract the package keeps was
4
+ * measured to be broken; `warn` means a leak, or a verdict the check could not
5
+ * establish. */ export type Level = 'fail' | 'warn';
6
+ /** One thing a check found. `text` is written for a person to read: what is
7
+ * wrong, what it is about, and what it costs. */ export type Finding = {
8
+ level: Level;
9
+ text: string;
10
+ };
11
+ /** The checks among a list of tools — every one whose verb is `check`. It
12
+ * filters the tool declarations the caller already has (`@yaks/graph/tools`
13
+ * `loadTools` keeps `noun` and `verb` on each), so nothing has to be
14
+ * registered or tracked separately. */ export declare let checks: <T extends {
15
+ verb?: string;
16
+ }>(tools: T[]) => T[];
17
+ /**
18
+ * What a check returns: one bundle, however much it found. `about` is the
19
+ * claim that holds when nothing is found ("no transcript has stalled"); the
20
+ * text leads with it either way, and `finding{level}` carries the level for a
21
+ * caller that has to act on it.
22
+ *
23
+ * One bundle rather than one per finding, deliberately: the runner writes what
24
+ * a tool returns, and a sweep that created an entity per stale lease would
25
+ * fill the graph with reports that the graph is untidy.
26
+ */ export declare let checked: (call: Eid, about: string, found: Finding[]) => Bundle[];
27
+ /** Whether a tool is a check whose answer reports a measured violation — what
28
+ * the CLI turns into exit code 1. Only a check's own answer counts: a query
29
+ * that returns the answers checks left in the graph is not failing. */ export declare let ailing: (tool: {
30
+ verb?: string;
31
+ }, answer: Bundle[]) => boolean;
32
+ //# sourceMappingURL=check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.d.ts","sources":["../check.ts"],"names":[],"mappings":"AAoBA,cAAc,MAAM,EAAQ,GAAG,2BAAgC;AAE/D,wCAAwC,GACxC,OAAO,YAAI,cAAe;AAE1B;;cAEc,GACd,YAAY,QAAQ,SAAS;AAE7B;+CAC+C,GAC/C,YAAY;EAAY,OAAO;EAAO,MAAM,MAAM;;AAElD;;;qCAGqC,GACrC,OAAO,YAAI,SAAU;EAAY,OAAO,MAAM;GAAI,OAAO,QAAM,IACzB;AAWtC;;;;;;;;;CASC,GACD,OAAO,YAAI,UACT,MAAM,KACN,OAAO,MAAM,EACb,OAAO,cACN,SAeF;AAID;;qEAEqE,GACrE,OAAO,YAAI,SACT;EAAQ,OAAO,MAAM;GACrB,QAAQ,aACP,OAAO,CAE4D"}
@@ -0,0 +1,66 @@
1
+ import type { Bundle, NamedTool } from "@yaks/graph";
2
+ import { type Line } from "@yaks/query";
3
+ import { type ToolDefinition } from "@yaks/vocab/tools";
4
+ import type { Floor } from "./access.js";
5
+ export { mayCall } from "./access.js";
6
+ /** One argument's JSON Schema. */ export type Arg = Record<string, unknown>;
7
+ export type ToolDef = {
8
+ description: string;
9
+ revision?: string;
10
+ /** Offer this command as an app service, with its pricing terms. */ service?: {
11
+ pricing: string;
12
+ };
13
+ input: Record<string, Arg>;
14
+ required?: string[];
15
+ /** The declared command-line grammar; absent means flags only. */ positional?: ToolDefinition['positional'];
16
+ /** Least caller authority for page and connector commands. */ floor?: Floor;
17
+ /** Internal commands remain callable by scheduled graph work. */ discoverable?: boolean;
18
+ /** A worker command that promises to leave the store unchanged. */ readOnly?: boolean;
19
+ drop?: string[];
20
+ apply?: unknown;
21
+ query?: string;
22
+ worker?: string;
23
+ view?: string;
24
+ /** offered to the app's own models as a tool */ model?: boolean;
25
+ };
26
+ export type Tools = Record<string, ToolDef>;
27
+ /** The declared caller floor; store and worker doors still check each act. */ /** Where a call runs, as the variables it binds that no caller sends:
28
+ * `session`, the transcript a model's turn is in. */ export type Context = {
29
+ session?: string;
30
+ };
31
+ export declare let TOOLS_EXAMPLE: any;
32
+ export declare let parseTools: (source: unknown, words?: string[], file?: string) => Tools;
33
+ export declare let viewsOf: (source: unknown) => string[];
34
+ export declare let schemaOf: (tool: ToolDef, options?: {
35
+ short?: boolean;
36
+ }) => {
37
+ type: 'object';
38
+ properties: Record<string, Arg>;
39
+ required: string[];
40
+ };
41
+ export declare let filled: (tool: ToolDef, sent: Record<string, unknown>, context?: Context) => {
42
+ apply?: unknown;
43
+ query?: Line;
44
+ worker?: string;
45
+ args?: Record<string, unknown>;
46
+ };
47
+ /** Fill one declared command and hand its act to the caller's effect boundary. */ export declare let invoke: <T>(tool: ToolDef, args: Record<string, unknown>, acts: {
48
+ apply: (bundles: Bundle[]) => T | Promise<T>;
49
+ query: (line: Line) => T | Promise<T>;
50
+ worker: (path: string, args: Record<string, unknown>) => T | Promise<T>;
51
+ }, context?: Context) => T | Promise<T>;
52
+ /**
53
+ * An app's declared commands as TOOLS a graph can run itself (T-37605): the
54
+ * declaration from the manifest, and a `run` that fills the template and hands
55
+ * back what it made. @yaks/tools does the rest — it writes the call, lands the
56
+ * answer beside it, and a call wearing a wake waits for its firing first.
57
+ *
58
+ * A tool ANSWERS bundles and never applies them: an `apply` template is the
59
+ * bundles it means, landed by the runner as the caller. A `query` template
60
+ * reads rows the runner keeps its hands off. A `worker` calls the app's own
61
+ * code through the host's scoped dispatch door.
62
+ *
63
+ * `invoke` also fills commands for a page or connector. Their hosts supply
64
+ * the acts that reach the store or the app's worker.
65
+ */ export declare let commands: (said: Tools, worker?: (path: string, args: Record<string, unknown>, call: Bundle) => Promise<Bundle[]>) => NamedTool[];
66
+ //# sourceMappingURL=declared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declared.d.ts","sources":["../declared.ts"],"names":[],"mappings":"AA0DA,cAAc,MAAM,EAAS,SAAS,2BAAgC;AACtE,SAAS,KAAK,IAAI,2BAA+C;AAEjE,SAGE,KAAK,cAAc,iCAEgB;AAErC,cAAc,KAAK,sBAAqB;AACxC,SAAS,OAAO,sBAAqB;AAErC,gCAAgC,GAChC,YAAY,MAAM,OAAO,MAAM,EAAE,OAAO;AAUxC,YAAY;EACV,aAAa,MAAM;EACnB,WAAW,MAAM;EACjB,kEAAkE,GAClE;IAAY,SAAS,MAAM;;EAC3B,OAAO,OAAO,MAAM,EAAE;EACtB,WAAW,MAAM;EACjB,gEAAgE,GAChE,aAAa,eAAe;EAC5B,4DAA4D,GAC5D,QAAQ;EACR,+DAA+D,GAC/D,eAAe,OAAO;EACtB,iEAAiE,GACjE,WAAW,OAAO;EAClB,OAAO,MAAM;EACb,QAAQ,OAAO;EACf,QAAQ,MAAM;EACd,SAAS,MAAM;EACf,OAAO,MAAM;EACb,8CAA8C,GAC9C,QAAQ,OAAO;;AAGjB,YAAY,QAAQ,OAAO,MAAM,EAAE;AAEnC,4EAA4E,GAC5E;mDACmD,GACnD,YAAY;EAAY,UAAU,MAAM;;AAKxC,OAAO,YAAI,mBAG4D;AAwGvE,OAAO,YAAI,aACT,QAAQ,OAAO,EACf,QAAO,MAAM,IACb,kBACC,MAoOF;AAKD,OAAO,YAAI,UAAW,QAAQ,OAAO,KAAG,MAAM,GAW7C;AAOD,OAAO,YAAI,WACT,MAAM,SACN;EAAW,QAAQ,OAAO;;EACvB,MAAM;EAAU,YAAY,OAAO,MAAM,EAAE;EAAM,UAAU,MAAM;EAOrE;AAsID,OAAO,YAAI,SACT,MAAM,SACN,MAAM,OAAO,MAAM,EAAE,OAAO,GAC5B,UAAS;EAET,QAAQ,OAAO;EACf,QAAQ;EACR,SAAS,MAAM;EACf,OAAO,OAAO,MAAM,EAAE,OAAO;EA6B9B;AAED,gFAAgF,GAChF,OAAO,YAAI,SAAU,GACnB,MAAM,SACN,MAAM,OAAO,MAAM,EAAE,OAAO,GAC5B;EACE,QAAQ,SAAS,aAAa,IAAI,QAAQ;EAC1C,QAAQ,MAAM,SAAS,IAAI,QAAQ;EACnC,SAAS,MAAM,MAAM,EAAE,MAAM,OAAO,MAAM,EAAE,OAAO,MAAM,IAAI,QAAQ;GAEvE,UAAS,YACR,IAAI,QAAQ,GAOd;AAED;;;;;;;;;;;;;CAaC,GACD,OAAO,YAAI,WACT,MAAM,OACN,UACE,MAAM,MAAM,EACZ,MAAM,OAAO,MAAM,EAAE,OAAO,GAC5B,MAAM,WACH,QAAQ,cACZ,YAiBE"}
@@ -0,0 +1,2 @@
1
+ /** Show JSON-shaped values as fields, one section per result. */ export declare let display: (answer: unknown) => string;
2
+ //# sourceMappingURL=display.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"display.d.ts","sources":["../display.ts"],"names":[],"mappings":"AAgCA,+DAA+D,GAC/D,OAAO,YAAI,UAAW,QAAQ,OAAO,KAAG,MAAM,CAKnB"}
@@ -0,0 +1,46 @@
1
+ import type { Eid } from "@yaks/graph/bundle";
2
+ /** The refusal code on a tool result's transport metadata. */ export declare let REFUSAL_CODE: string;
3
+ declare const REFUSAL: unique symbol;
4
+ export declare class CallError extends Error {
5
+ code: string;
6
+ summary: string;
7
+ detail?: string;
8
+ readonly [REFUSAL]: true;
9
+ /** What the caller can give for the call to go through, by name (`email`):
10
+ * an agent reads the message, and a page a person reads asks them for it
11
+ * in their own words, with a field. */ ask?: string;
12
+ /** Any copy's CallError is one; a subclass still checks its own chain. */ static override [Symbol.hasInstance](value: unknown): boolean;
13
+ constructor(code: string, summary: string, detail?: string);
14
+ }
15
+ /** An operation was declined before it started and can be tried again. */ export declare class Busy extends Error {
16
+ after: number;
17
+ name: string;
18
+ constructor(message: string, after: number);
19
+ }
20
+ /** Recovery for a failed precondition on a recorded invocation's claim. */ export declare let claimConflict: (error: Error) => string | undefined;
21
+ /** A stored claim exists but no result does. The caller must reconcile it:
22
+ * running the tool again could repeat an effect the outside world already
23
+ * saw. */ export declare class UnfinishedCall extends Error {
24
+ call: Eid;
25
+ constructor(call: Eid);
26
+ }
27
+ /** Work cut off deliberately, not a refusal or a defect. */ export declare class Interrupted extends Error {
28
+ code: string;
29
+ constructor(message: string, code?: string);
30
+ }
31
+ /** Say a refusal once when its message already starts with its code. */ export declare let refusalText: (code: string, message: string) => string;
32
+ /** The HTTP status a failure answers with: a refusal's, by its code, else
33
+ * the graph's table (@yaks/graph `status`, 500 for a defect).
34
+ *
35
+ * ```ts
36
+ * import { assertEquals } from '@std/assert'
37
+ * import { CallError, statusOf } from './errors.ts'
38
+ *
39
+ * assertEquals(statusOf(new CallError('missing', 'no app a/b')), 404)
40
+ * assertEquals(statusOf(new Error('boom')), 500)
41
+ * ```
42
+ */ export declare let statusOf: (e: unknown) => number;
43
+ /** A thrown invocation refusal as its JSON HTTP answer, and a service that
44
+ * did not answer for now (@yaks/graph `unheard`) as `unavailable`. Defects
45
+ * are thrown through so the host's failure boundary can report them. */ export declare let refused: (e: unknown) => Response;
46
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sources":["../errors.ts"],"names":[],"mappings":"AAEA,cAAc,GAAG,kCAAuC;AAGxD,4DAA4D,GAC5D,OAAO,YAAI,cAAc,MAAM,CAAuB;AAKtD,cAAM,gBAAgB,MAAM;AAE5B,OAAO,cAAM,kBAAkB;EAapB,MAAM,MAAM;EACZ,SAAS,MAAM;EACf,SAAS,MAAM;EAdxB,SAAU,CAAA,QAAO,EAAI,IAAI,CAAA;EACzB;;uCAEqC,GACrC,MAAM,MAAM,CAAA;EACZ,wEAAwE,GACxE,gBAAiB,CAAA,OAAO,WAAW,CAAA,CAAE,OAAO,OAAO,GAAG,OAAO;EAK7D,YACE,AAAO,MAAM,MAAM,EACnB,AAAO,SAAS,MAAM,EACtB,AAAO,SAAS,MAAM;AAK1B;AAEA,wEAAwE,GACxE,OAAO,cAAM,aAAa;EAEY,OAAO,MAAM;EADxC,aAAa;EACtB,YAAY,SAAS,MAAM,EAAE,AAAO,OAAO,MAAM;AAGnD;AAEA,yEAAyE,GACzE,OAAO,YAAI,gBAAiB,OAAO,UAAQ,MAAM,GAAG,SAAS,CAa5D;AAED;;QAEQ,GACR,OAAO,cAAM,uBAAuB;EACf,MAAM;EAAzB,YAAY,AAAO,MAAM,GAAG;AAI9B;AAEA,0DAA0D,GAC1D,OAAO,cAAM,oBAAoB;EAC/B,MAAM,MAAM,CAAA;EACZ,YAAY,SAAS,MAAM,EAAE,aAAgB;AAK/C;AAEA,sEAAsE,GACtE,OAAO,YAAI,cAAe,MAAM,MAAM,EAAE,SAAS,MAAM,KAAG,MAAM,CAK/D;AAWD;;;;;;;;;;CAUC,GACD,OAAO,YAAI,WAAY,GAAG,OAAO,KAAG,MAAM,CACiB;AAE3D;;sEAEsE,GACtE,OAAO,YAAI,UAAW,GAAG,OAAO,KAAG,SAalC"}
@@ -0,0 +1,4 @@
1
+ import type { Comp } from "@yaks/graph";
2
+ /** Whether a failure is worth reporting: anything but a known transient. */ export declare let actionable: (message: string) => boolean;
3
+ /** What was thrown, for an answer or transcript entry. */ export declare let exceptionOf: (error: unknown) => Comp;
4
+ //# sourceMappingURL=fault.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fault.d.ts","sources":["../fault.ts"],"names":[],"mappings":"AAEA,cAAc,IAAI,2BAAgC;AAUlD,0EAA0E,GAC1E,OAAO,YAAI,aAAc,SAAS,MAAM,KAAG,OAAO,CACP;AAE3C,wDAAwD,GACxD,OAAO,YAAI,cAAe,OAAO,OAAO,KAAG,KAMb"}
@@ -0,0 +1,13 @@
1
+ import type { Bundle, Graph, NamedTool } from "@yaks/graph";
2
+ import type { Opts, Refusal } from "./runner.js";
3
+ /** What a call cut off before its arguments were finished (`cut`) is
4
+ * answered: nothing ran, and how its writer, a model, fits it in a reply. */ export declare let CUT: any;
5
+ export type Land = (made: Bundle[], state: string, keeps?: boolean, code?: string) => Bundle[] | Promise<Bundle[]>;
6
+ /** What an error refuses, when it is a refusal: a `CallError` with its code,
7
+ * or an error the graph's `status` puts below 500 (a `Refused` write, an
8
+ * `Unknown` name) with its name, each in its own words. Anything else is a
9
+ * defect, and refuses nothing. */ export declare let refusalOf: (error: unknown) => Refusal | undefined;
10
+ /** Tell whoever hears refusals of one, reporting a hearer that fails rather
11
+ * than letting it change the call's answer. */ export declare let heard: (opts: Pick<Opts, 'report' | 'refused'>, refusal: Refusal, call: Bundle, tool?: string) => Promise<void>;
12
+ /** Invoke once, letting the owner retain the answer or return it in memory. */ export declare let invoke: (call: Bundle, tool: NamedTool, g: Graph, opts: Pick<Opts, 'host' | 'process' | 'report' | 'refused' | 'most'>, land: Land, defer?: boolean) => Promise<Bundle[]>;
13
+ //# sourceMappingURL=invoke.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoke.d.ts","sources":["../invoke.ts"],"names":[],"mappings":"AACA,cAAc,MAAM,EAAQ,KAAK,EAAE,SAAS,2BAAgC;AAM5E,cAAc,IAAI,EAAE,OAAO,sBAAqB;AAOhD;2EAC2E,GAC3E,OAAO,YAAI,SAGqC;AAOhD,YAAY,QACV,MAAM,UACN,OAAO,MAAM,EACb,QAAQ,OAAO,EACf,OAAO,MAAM,KACV,WAAW,QAAQ;AAkBxB;;;gCAGgC,GAChC,OAAO,YAAI,YAAa,OAAO,OAAO,KAAG,UAAU,SAAS,CAa3D;AAED;6CAC6C,GAC7C,OAAO,YAAI,QACT,MAAM,KAAK,MAAM,WAAW,YAC5B,SAAS,SACT,MAAM,QACN,OAAO,MAAM,KACZ,QAAQ,IAAI,EAMd;AAED,6EAA6E,GAC7E,OAAO,YAAI,SACT,MAAM,QACN,MAAM,WACN,GAAG,OACH,MAAM,KAAK,MAAM,SAAS,YAAY,WAAW,YAAY,SAC7D,MAAM,MACN,oBACC,QAAQ,UAsHV"}
package/_dist/mod.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @yaks/tools — a tool is a function that takes entity patches and returns
3
+ * entity patches; a `call` entity is the stored record of having asked for
4
+ * one. This package runs the function and keeps that record.
5
+ *
6
+ * A caller invokes a tool directly: `call()` writes the `call` entity, runs
7
+ * the function named by `call.to` with the call's bundles and a context
8
+ * carrying the caller's identity, and applies what the function returned
9
+ * together with a `result{call, ms}` entity whose id is derived from the rule
10
+ * that emits it. Nothing polls the graph — a call another process wrote, or
11
+ * one deferred by a `wake` component, is picked up by registering those same
12
+ * rules as effects (@yaks/effects `on`). See ./runner.ts for the claim, crash
13
+ * recovery, and scheduling.
14
+ *
15
+ * @module
16
+ */ export { callDoc, toolDoc, toolsDoc } from "./vocab.js";
17
+ export { ailing, CHECK, checked, checks, type Finding, type Level } from "./check.js";
18
+ export { CallError, parsed, unreferenced } from "./args.js";
19
+ export { said } from "./said.js";
20
+ export { persist } from "./persist.js";
21
+ export { answerOf, faulted, MOST, pending, READY, RULES, structured, texts, toolEid, toolRow, WOKEN, worded, WORDS } from "./result.js";
22
+ export { became, type Invocation, keeps, type Opts, reconcile, type Refusal, type Refused, type Reply, type Runner, runner, UnfinishedCall } from "./runner.js";
23
+ export { valueIn } from "./value.js";
24
+ export { actionable, exceptionOf } from "./fault.js";
25
+ export { display } from "./display.js";
26
+ export { type Watch, watched } from "./watch.js";
27
+ export { did, doing, type Step, stepOf, type Steps, titleOf } from "./title.js";
28
+ export { executionComputed, executionDerived, executionState, Interrupted } from "./state.js";
29
+ export { type Description, type Provider, type Registry, registry } from "./registry.js";
30
+ export { CUT, heard, invoke, type Land, refusalOf } from "./invoke.js";
31
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAAS,OAAO,EAAE,OAAO,EAAE,QAAQ,qBAAoB;AACvD,SACE,MAAM,EACN,KAAK,EACL,OAAO,EACP,MAAM,EACN,KAAK,OAAO,EACZ,KAAK,KAAK,qBACO;AACnB,SAAS,SAAS,EAAE,MAAM,EAAE,YAAY,oBAAmB;AAC3D,SAAS,IAAI,oBAAmB;AAChC,SAAS,OAAO,uBAAsB;AACtC,SACE,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,OAAO,EACP,KAAK,EACL,KAAK,EACL,UAAU,EACV,KAAK,EACL,OAAO,EACP,OAAO,EACP,KAAK,EACL,MAAM,EACN,KAAK,sBACa;AACpB,SACE,MAAM,EACN,KAAK,UAAU,EACf,KAAK,EACL,KAAK,IAAI,EACT,SAAS,EACT,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,MAAM,EACX,MAAM,EACN,cAAc,sBACI;AACpB,SAAS,OAAO,qBAAoB;AACpC,SAAS,UAAU,EAAE,WAAW,qBAAoB;AACpD,SAAS,OAAO,uBAAsB;AACtC,SAAS,KAAK,KAAK,EAAE,OAAO,qBAAoB;AAChD,SAAS,GAAG,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,MAAM,EAAE,KAAK,KAAK,EAAE,OAAO,qBAAoB;AAE/E,SACE,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,WAAW,qBACM;AAEnB,SACE,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,QAAQ,wBACY;AAEtB,SAAS,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE,SAAS,sBAAqB"}
@@ -0,0 +1,89 @@
1
+ /** Join an in-flight tool call and keep its answer for later pickup.
2
+ * @module
3
+ */ import { type Bundle, type Graph } from "@yaks/graph";
4
+ import { type Clock } from "@yaks/fp";
5
+ /** How long a tool call waits for its answer before saying it is still
6
+ * running: well inside the minute a client gives a call, so a caller hears
7
+ * the answer in the call it made, and only a run longer than this needs a
8
+ * second call. */ export declare let PATIENCE: number;
9
+ /** How long a completed answer stays available by its handle. */ export declare let KEPT: number;
10
+ /** How a call ended: its answer, or the refusal it said. */ export type Ended = {
11
+ timing?: string;
12
+ } & ({
13
+ said: Bundle[];
14
+ } | {
15
+ failed: string;
16
+ } | {
17
+ refused: {
18
+ code: string;
19
+ text: string;
20
+ summary?: string;
21
+ };
22
+ });
23
+ /** What a caller hears: how the call ended, when it was asked, and whether it
24
+ * was asked by an earlier call that heard it still running; or that it is,
25
+ * and what it is doing when the run has said. */ export type Heard = Ended & {
26
+ asked: string;
27
+ late?: true;
28
+ } | {
29
+ running: string;
30
+ run?: string;
31
+ doing?: string;
32
+ };
33
+ /** A run: given how to say what it is doing now, it ends. */ export type Run = (doing: (step: string) => void, before: () => Promise<void>) => Promise<Ended>;
34
+ /** The object's own storage, as much of it as this keeps. */ export type Keep = {
35
+ get<T>(key: string): Promise<T | undefined>;
36
+ put(key: string, value: unknown): Promise<void>;
37
+ delete(key: string): Promise<boolean>;
38
+ };
39
+ export type KeptRun<Replay = never> = {
40
+ asked: string;
41
+ } & ({
42
+ ended: number;
43
+ out: Ended;
44
+ } | {
45
+ ended?: undefined;
46
+ out?: undefined;
47
+ replay?: Replay;
48
+ changed?: true;
49
+ });
50
+ /** The durable record of each invocation for which a handle was issued. */ export type RunResults<T = KeptRun> = {
51
+ get(run: string): Promise<T | undefined>;
52
+ put(run: string, record: T): Promise<void>;
53
+ };
54
+ /** Store issued handles in the graph owned by the invocation host. */ export declare let runResults: <T = KeptRun>(g: Graph, arm: (at: number) => Promise<void>, time?: Clock) => RunResults<T> & {
55
+ sweep(): Promise<number | null>;
56
+ };
57
+ type Handle = {
58
+ asked: string;
59
+ run: string;
60
+ };
61
+ export type Receipt = {
62
+ started: string;
63
+ handle?: Handle;
64
+ } | {
65
+ heard: Heard;
66
+ };
67
+ export type Attempt = {
68
+ before(handle?: Handle): Promise<void>;
69
+ within<T>(work: (attempt: string) => Promise<T>): Promise<T>;
70
+ };
71
+ /** A resend shares the original attempt or its stored reply. An attempt
72
+ * can start over after an interruption until it has recorded that it may
73
+ * change state. The reservation and reply expire with other tool results. */ export declare let receipting: (results: RunResults<Receipt>, report: (error: unknown) => void) => {
74
+ ask(key: string, work: (attempt: Attempt) => Promise<Heard>, recover?: (handle: Handle) => Promise<Heard | undefined>): Promise<Heard>;
75
+ effect(attempt: string): Promise<void>;
76
+ within<T>(before: () => Promise<void>, work: (attempt: string) => Promise<T>): Promise<T>;
77
+ };
78
+ /** Run `callback` in `ms`, answering how to cancel it. */ export type After = (ms: number, callback: () => void | Promise<void>) => () => void;
79
+ type Resume<Replay> = (replay: Replay, changed: boolean) => Run | undefined;
80
+ /** Calls sharing an invocation key and lookup of a particular pending run. */ export type Calls<Replay = never> = {
81
+ (run: Run, wait?: number, replay?: Replay, link?: (handle: Handle) => Promise<void>) : Promise<Heard>;
82
+ read(asked: string, wait?: number, run?: string, resume?: Resume<Replay>): Promise<Heard>;
83
+ recover(handle: Handle, wait?: number, resume?: Resume<Replay>): Promise<Heard | undefined>;
84
+ /** Nothing running and no run's handle held: forgetting these calls loses
85
+ * nothing their storage does not keep. */ idle(): boolean;
86
+ };
87
+ /** One key's calls share a run, each waiting up to `patience`. The run
88
+ * answers with its result or refusal. */ export declare let outlasting: <Replay = never>(keep: Keep, results: RunResults<KeptRun<Replay>>, _dts_1: never) => Calls<Replay>;
89
+ //# sourceMappingURL=outlast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outlast.d.ts","sources":["../outlast.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,5 @@
1
+ import { type Clock } from "@yaks/fp";
2
+ /** Retry a write only when storage certifies that nothing committed. Report
3
+ * the first refusal, then wait with backoff, on `clock`, until it can be
4
+ * persisted. */ export declare let persist: <T>(write: () => T | Promise<T>, report: (e: unknown) => unknown, clock?: Clock) => Promise<T>;
5
+ //# sourceMappingURL=persist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persist.d.ts","sources":["../persist.ts"],"names":[],"mappings":"AAGA,SAAkB,KAAK,KAAK,wBAA4C;AAKxE;;cAEc,GACd,OAAO,YAAI,UAAiB,GAC1B,aAAa,IAAI,QAAQ,IACzB,SAAS,GAAG,OAAO,KAAK,OAAO,EAC/B,QAAO,UACN,QAAQ,GAUV"}
@@ -0,0 +1,4 @@
1
+ import type { Graph } from "@yaks/graph";
2
+ import type { Opts, Runner } from "./runner.js";
3
+ /** A read-only runner refuses recorded work before it invokes a tool. */ export declare let reader: (g: Graph, opts: Opts) => Runner;
4
+ //# sourceMappingURL=read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.d.ts","sources":["../read.ts"],"names":[],"mappings":"AACA,cAA4B,KAAK,2BAAgC;AAEjE,cAAc,IAAI,EAAE,MAAM,sBAAqB;AAM/C,uEAAuE,GACvE,OAAO,YAAI,SAAU,GAAG,OAAO,MAAM,SAAO,OA+C3C"}
@@ -0,0 +1,59 @@
1
+ import type { Bundle } from "@yaks/graph";
2
+ import type { Held } from "@yaks/id/graph";
3
+ import { type Ids } from "@yaks/markdown/structural";
4
+ import type { Vocab } from "@yaks/vocab";
5
+ export type { Ids };
6
+ /**
7
+ * The answer with every prose property (@yaks/vocab `prose`) drawn
8
+ * (@yaks/markdown `drawn`): an eid it holds reads as the id the answer itself
9
+ * gives that entity, whatever its kind, or as the id `ids` holds (the small
10
+ * series a host keeps in memory, @yaks/id/graph `held`), else as its short
11
+ * handle. A bundle with nothing to draw is the same bundle. A door drawing
12
+ * from a store uses {@link drawing}, which asks `ids` about every eid named.
13
+ *
14
+ * ```ts
15
+ * import { assertEquals } from '@std/assert'
16
+ * import { loadVocab } from '@yaks/vocab'
17
+ * import { idKeywords } from '@yaks/id'
18
+ * let vocab = loadVocab({
19
+ * $defs: {
20
+ * doc: {
21
+ * component: true,
22
+ * properties: { body: { type: 'string', prose: true } },
23
+ * },
24
+ * task: { component: true, kind: true, prefix: 'T', properties: {} },
25
+ * },
26
+ * }, [idKeywords])
27
+ * let eid = '0e513227-de00-4000-8000-000000000001'
28
+ * let task = { entity: { eid, num: 12, prefix: 'T' }, task: {}, doc: { body: 'Me.' } }
29
+ * let note = { entity: { eid: 'n1' }, doc: { body: `See ${eid}.` } }
30
+ * assertEquals(readable(vocab)([task, note])[1].doc, { body: 'See T-12.' })
31
+ * assertEquals(readable(vocab)([note])[0].doc, { body: 'See #0e513227de.' })
32
+ * ```
33
+ */ export declare let readable: (vocab: Vocab, ids?: Ids) => (answer: Bundle[]) => Bundle[];
34
+ /**
35
+ * The answer drawn as {@link readable} draws it, with every eid its prose
36
+ * names asked of `held` (@yaks/id/graph), so one outside the small series, a
37
+ * task a comment names, reads as its id too.
38
+ *
39
+ * ```ts
40
+ * import { assertEquals } from '@std/assert'
41
+ * import { loadVocab } from '@yaks/vocab'
42
+ * let vocab = loadVocab({
43
+ * $defs: {
44
+ * doc: {
45
+ * component: true,
46
+ * properties: { body: { type: 'string', prose: true } },
47
+ * },
48
+ * },
49
+ * })
50
+ * let eid = '0e513227-de00-4000-8000-000000000001'
51
+ * let note = { entity: { eid: 'n1' }, doc: { body: `See ${eid}.` } }
52
+ * let held = async (eids?: Iterable<string>) => {
53
+ * let asked = new Set(eids)
54
+ * return (e: string) => asked.has(e) ? 'T-12' : undefined
55
+ * }
56
+ * assertEquals((await drawing(vocab, held)([note]))[0].doc, { body: 'See T-12.' })
57
+ * ```
58
+ */ export declare let drawing: (vocab: Vocab, held: Held, offThread?: (answer: Bundle[]) => Promise<Bundle[]>) => (answer: Bundle[]) => Promise<Bundle[]>;
59
+ //# sourceMappingURL=readable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readable.d.ts","sources":["../readable.ts"],"names":[],"mappings":"AAIA,cAAc,MAAM,2BAAsC;AAE1D,cAAc,IAAI,8BAAmC;AACrD,SAAsB,KAAK,GAAG,yCAA8C;AAC5E,cAAc,KAAK,2BAAgC;AAEnD,cAAc,GAAG,GAAE;AAKnB;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BC,GACD,OAAO,YAAI,WACT,OAAO,OACP,MAAM,SACJ,QAAQ,aAAa,SAUxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,GACD,OAAO,YAAI,UACT,OAAO,OACP,MAAM,MACN,aAAa,QAAQ,aAAa,QAAQ,eACxC,QAAQ,aAAa,QAAQ,UAsBhC"}
@@ -0,0 +1,53 @@
1
+ import type { NamedTool, Tool } from "@yaks/graph";
2
+ import { inputSchemaOf } from "./schema.js";
3
+ /** One runtime source's complete catalog, with names unchanged. */ export type Provider = {
4
+ name: string;
5
+ tools: readonly Tool[];
6
+ };
7
+ /** A discovery result carries schemas and its source, never executable code. */ export type Description = Omit<NamedTool, 'run' | 'input' | 'inputSchema' | 'outputSchema'> & {
8
+ provider: string;
9
+ inputSchema: ReturnType<typeof inputSchemaOf>;
10
+ outputSchema: NonNullable<Tool['outputSchema']>;
11
+ };
12
+ export type Registry = {
13
+ list: () => NamedTool[];
14
+ providers: () => {
15
+ name: string;
16
+ tools: NamedTool[];
17
+ }[];
18
+ get: (nameOrEid: string) => NamedTool | undefined;
19
+ describe: (nameOrEid: string) => Description | undefined;
20
+ search: (words: string) => Description[];
21
+ /** Replace a complete provider snapshot, or remove it with null. A collision
22
+ * leaves the previous catalog intact and sends no notification. */ replace: (name: string, tools: readonly Tool[] | null) => void;
23
+ subscribe: (changed: () => void) => () => void;
24
+ };
25
+ /**
26
+ * The tools that hold some of a search's words in what `text` says of them,
27
+ * the most fitting first: the tool `text` opens with the search as written
28
+ * (its name), then those holding it as written, then the rest by their words,
29
+ * each counting more the fewer tools hold it, so one that says what a tool
30
+ * does (attachment) outweighs one most of them say (operator). With `every`,
31
+ * only tools holding each word are found.
32
+ *
33
+ * ```ts
34
+ * let tools = [
35
+ * { name: 'attachment_read', description: 'Read a file the person sent.' },
36
+ * { name: 'operator_retry', description: 'Retry an Operator turn.' },
37
+ * { name: 'operator_remove', description: 'Remove an Operator.' },
38
+ * ]
39
+ * let said = (t: { name: string; description: string }) =>
40
+ * `${t.name} ${t.description}`
41
+ * found('operator_attachment', tools, said).map((t) => t.name)[0]
42
+ * // 'attachment_read'
43
+ * found('file_attach', tools, said).map((t) => t.name) // ['attachment_read']
44
+ * found('read operator', tools, said, true) // []
45
+ * found('operator_remove', tools, said).map((t) => t.name)[0]
46
+ * // 'operator_remove'
47
+ * ```
48
+ */ export declare let found: <T>(words: string, tools: readonly T[], text: (tool: T) => string, every?: boolean) => T[];
49
+ /** Build a registry from runtime adapters. Replacement publishes one complete
50
+ * snapshot; callers holding a tool keep that implementation for their call. */ export declare let registry: (providers?: readonly Provider[]) => Registry;
51
+ /** Existing tool arrays are one local provider; a supplied registry is
52
+ * shared, and either one supplied as a function is made when asked for. */ export declare let registryOf: (tools: Tool[] | Registry | (() => Tool[] | Registry)) => Registry;
53
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sources":["../registry.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,EAAE,IAAI,2BAAgC;AAI7D,SAAuB,aAAa,sBAAqB;AAEzD,iEAAiE,GACjE,YAAY;EAAa,MAAM,MAAM;EAAE,gBAAgB;;AAEvD,8EAA8E,GAC9E,YAAY,cACR,KAAK,WAAW,QAAQ,UAAU,gBAAgB;EAElD,UAAU,MAAM;EAChB,aAAa,kBAAkB;EAC/B,cAAc,YAAY,KAAK;;AAGnC,YAAY;EACV,YAAY;EACZ;IAAmB,MAAM,MAAM;IAAE,OAAO;;EACxC,MAAM,WAAW,MAAM,KAAK,YAAY,SAAS;EACjD,WAAW,WAAW,MAAM,KAAK,cAAc,SAAS;EACxD,SAAS,OAAO,MAAM,KAAK;EAC3B;mEACiE,GACjE,UAAU,MAAM,MAAM,EAAE,gBAAgB,SAAS,IAAI,KAAK,IAAI;EAC9D,YAAY,eAAe,IAAI,WAAW,IAAI;;AAahD;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,OAAO,YAAI,QAAS,GAClB,OAAO,MAAM,EACb,gBAAgB,KAChB,OAAO,MAAM,MAAM,MAAM,EACzB,oBACC,IAuBF;AAyCD;6EAC6E,GAC7E,OAAO,YAAI,WAAY,qBAAoB,eAAkB,SA2D5D;AAED;yEACyE,GACzE,OAAO,YAAI,aACT,OAAO,SAAS,kBAAkB,SAAS,cAC1C,SAKQ"}