@yaks/connections 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 (184) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +609 -2
  3. package/_dist/authorize.d.ts +38 -0
  4. package/_dist/authorize.d.ts.map +1 -0
  5. package/_dist/authorize_cli.d.ts +12 -0
  6. package/_dist/authorize_cli.d.ts.map +1 -0
  7. package/_dist/brokers.d.ts +66 -0
  8. package/_dist/brokers.d.ts.map +1 -0
  9. package/_dist/catalog.d.ts +33 -0
  10. package/_dist/catalog.d.ts.map +1 -0
  11. package/_dist/cli.d.ts +3 -0
  12. package/_dist/cli.d.ts.map +1 -0
  13. package/_dist/clients.d.ts +18 -0
  14. package/_dist/clients.d.ts.map +1 -0
  15. package/_dist/connections.d.ts +296 -0
  16. package/_dist/connections.d.ts.map +1 -0
  17. package/_dist/effects.d.ts +15 -0
  18. package/_dist/effects.d.ts.map +1 -0
  19. package/_dist/field.d.ts +17 -0
  20. package/_dist/field.d.ts.map +1 -0
  21. package/_dist/form.d.ts +49 -0
  22. package/_dist/form.d.ts.map +1 -0
  23. package/_dist/given.d.ts +10 -0
  24. package/_dist/given.d.ts.map +1 -0
  25. package/_dist/graph.d.ts +15 -0
  26. package/_dist/graph.d.ts.map +1 -0
  27. package/_dist/history.d.ts +4 -0
  28. package/_dist/history.d.ts.map +1 -0
  29. package/_dist/identity.d.ts +9 -0
  30. package/_dist/identity.d.ts.map +1 -0
  31. package/_dist/integrations.d.ts +196 -0
  32. package/_dist/integrations.d.ts.map +1 -0
  33. package/_dist/loopback.d.ts +7 -0
  34. package/_dist/loopback.d.ts.map +1 -0
  35. package/_dist/mcp-retirement.d.ts +33 -0
  36. package/_dist/mcp-retirement.d.ts.map +1 -0
  37. package/_dist/mcp.d.ts +179 -0
  38. package/_dist/mcp.d.ts.map +1 -0
  39. package/_dist/mod.d.ts +70 -0
  40. package/_dist/mod.d.ts.map +1 -0
  41. package/_dist/paste.d.ts +13 -0
  42. package/_dist/paste.d.ts.map +1 -0
  43. package/_dist/requests.d.ts +30 -0
  44. package/_dist/requests.d.ts.map +1 -0
  45. package/_dist/services.d.ts +25 -0
  46. package/_dist/services.d.ts.map +1 -0
  47. package/_dist/sign-in.d.ts +9 -0
  48. package/_dist/sign-in.d.ts.map +1 -0
  49. package/_dist/signin-mail.d.ts +12 -0
  50. package/_dist/signin-mail.d.ts.map +1 -0
  51. package/_dist/signin.d.ts +19 -0
  52. package/_dist/signin.d.ts.map +1 -0
  53. package/_dist/sources.d.ts +61 -0
  54. package/_dist/sources.d.ts.map +1 -0
  55. package/_dist/tools.d.ts +3 -0
  56. package/_dist/tools.d.ts.map +1 -0
  57. package/_dist/views.d.ts +3 -0
  58. package/_dist/views.d.ts.map +1 -0
  59. package/_dist/vocab.d.ts +6 -0
  60. package/_dist/vocab.d.ts.map +1 -0
  61. package/_dist/yaks-app.d.ts +29 -0
  62. package/_dist/yaks-app.d.ts.map +1 -0
  63. package/anthropic.json +12 -0
  64. package/auth_command.js +69 -0
  65. package/auth_command.js.map +1 -0
  66. package/auth_command.ts +74 -0
  67. package/authorize.js +89 -0
  68. package/authorize.js.map +1 -0
  69. package/authorize.ts +138 -0
  70. package/authorize_cli.js +167 -0
  71. package/authorize_cli.js.map +1 -0
  72. package/authorize_cli.ts +211 -0
  73. package/brokers.js +318 -0
  74. package/brokers.js.map +1 -0
  75. package/brokers.ts +423 -0
  76. package/canva.json +32 -0
  77. package/catalog.js +178 -0
  78. package/catalog.js.map +1 -0
  79. package/catalog.ts +216 -0
  80. package/cli.js +30 -0
  81. package/cli.js.map +1 -0
  82. package/cli.ts +26 -0
  83. package/clients.js +34 -0
  84. package/clients.js.map +1 -0
  85. package/clients.ts +65 -0
  86. package/connections.js +1961 -0
  87. package/connections.js.map +1 -0
  88. package/connections.ts +2561 -0
  89. package/deno.json +1 -0
  90. package/discord-account.json +22 -0
  91. package/discord-bot.json +20 -0
  92. package/discord.json +26 -0
  93. package/effects.js +168 -0
  94. package/effects.js.map +1 -0
  95. package/effects.ts +160 -0
  96. package/elevenlabs.json +18 -0
  97. package/facebook.json +18 -0
  98. package/field.js +19 -0
  99. package/field.js.map +1 -0
  100. package/field.ts +31 -0
  101. package/form.js +112 -0
  102. package/form.js.map +1 -0
  103. package/form.ts +178 -0
  104. package/git-config.js +44 -0
  105. package/git-config.js.map +1 -0
  106. package/git-config.ts +26 -0
  107. package/given.js +83 -0
  108. package/given.js.map +1 -0
  109. package/given.ts +88 -0
  110. package/gmail-mailbox.json +29 -0
  111. package/gmail.json +31 -0
  112. package/google-calendar.json +31 -0
  113. package/google-drive.json +31 -0
  114. package/google-search-console.json +29 -0
  115. package/graph.js +36 -0
  116. package/graph.js.map +1 -0
  117. package/graph.ts +52 -0
  118. package/history.js +31 -0
  119. package/history.js.map +1 -0
  120. package/history.ts +32 -0
  121. package/identity.js +15 -0
  122. package/identity.js.map +1 -0
  123. package/identity.ts +18 -0
  124. package/integrations.js +493 -0
  125. package/integrations.js.map +1 -0
  126. package/integrations.ts +725 -0
  127. package/loopback.js +72 -0
  128. package/loopback.js.map +1 -0
  129. package/loopback.ts +89 -0
  130. package/lulu.json +32 -0
  131. package/mcp-retirement.js +133 -0
  132. package/mcp-retirement.js.map +1 -0
  133. package/mcp-retirement.ts +200 -0
  134. package/mcp-signin.js +14 -0
  135. package/mcp-signin.js.map +1 -0
  136. package/mcp-signin.ts +13 -0
  137. package/mcp.js +1036 -0
  138. package/mcp.js.map +1 -0
  139. package/mcp.ts +1283 -0
  140. package/mod.js +70 -0
  141. package/mod.js.map +1 -0
  142. package/mod.ts +216 -0
  143. package/openai-api.json +12 -0
  144. package/openai.json +25 -0
  145. package/openrouter.json +14 -0
  146. package/package.json +89 -4
  147. package/paste.js +36 -0
  148. package/paste.js.map +1 -0
  149. package/paste.ts +55 -0
  150. package/requests.js +137 -0
  151. package/requests.js.map +1 -0
  152. package/requests.ts +200 -0
  153. package/services.js +84 -0
  154. package/services.js.map +1 -0
  155. package/services.ts +111 -0
  156. package/sign-in.js +36 -0
  157. package/sign-in.js.map +1 -0
  158. package/sign-in.ts +53 -0
  159. package/signin-mail.js +29 -0
  160. package/signin-mail.js.map +1 -0
  161. package/signin-mail.ts +56 -0
  162. package/signin.js +68 -0
  163. package/signin.js.map +1 -0
  164. package/signin.ts +109 -0
  165. package/slack.json +90 -0
  166. package/sources.js +178 -0
  167. package/sources.js.map +1 -0
  168. package/sources.ts +237 -0
  169. package/tools.js +39 -0
  170. package/tools.js.map +1 -0
  171. package/tools.ts +46 -0
  172. package/views.js +85 -0
  173. package/views.js.map +1 -0
  174. package/views.ts +89 -0
  175. package/visitor-defaults.json +8 -0
  176. package/vocab.js +17 -0
  177. package/vocab.js.map +1 -0
  178. package/vocab.json +863 -0
  179. package/vocab.ts +18 -0
  180. package/voipms.json +32 -0
  181. package/yaks-app.js +159 -0
  182. package/yaks-app.js.map +1 -0
  183. package/yaks-app.ts +177 -0
  184. package/youtube.json +26 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sources":["../identity.ts"],"names":[],"mappings":"AAIA,cAAc,GAAG,kCAAuC;AAGxD,OAAO,YAAI,oBAA2B;AACtC,OAAO,YAAI,mBAAyB;AACpC,OAAO,YAAI,aAAa;AACxB,OAAO,YAAI,aAAa;AACxB;kDACkD,GAClD,OAAO,YAAI,kBAAuB;AAElC,kEAAkE,GAClE,OAAO,YAAI,iBAAkB,MAAM,MAAM,KAAG,IACV"}
@@ -0,0 +1,196 @@
1
+ import type { Bundle, Eid, Reads } from "@yaks/graph";
2
+ import type { Scheme } from "@yaks/hook";
3
+ import { type Field, fieldsOf, KEY } from "./field.js";
4
+ export { type Field, fieldsOf, KEY };
5
+ export type VisitorPolicy = 'never' | 'off' | 'on';
6
+ /** An outside service, as data. */ export type Integration = {
7
+ name: string;
8
+ /** A hosted service; operation declarations stay with the app release. */ service?: {
9
+ app: string;
10
+ };
11
+ /** what a person calls it: OpenRouter, Google Calendar */ title?: string;
12
+ /** one line saying what it is, written for a person */ tagline?: string;
13
+ /** its address on the web */ site?: string;
14
+ description?: string;
15
+ details?: string;
16
+ docs?: string;
17
+ connects?: 'key' | 'signin' | 'client';
18
+ visitors?: VisitorPolicy;
19
+ categories?: string[];
20
+ image?: string;
21
+ /** its mark, as an SVG document, drawn as an image */ logo?: string;
22
+ /** where a person grants access (OAuth) */ authorize?: string;
23
+ /** where codes and refresh tokens are exchanged; none means a pasted key */ token?: string;
24
+ /** OpenID endpoint naming the account when no id_token is returned. */ userinfo?: string;
25
+ /** the field that names the account, as a dotted path, where it is not an
26
+ * email address: of the token endpoint's answer (Discord's `guild.id`, the
27
+ * server its bot was added to; @yaks/oauth `Provider.account`), else of
28
+ * the `userinfo` answer (a Discord user's `id`) */ account?: string;
29
+ /** the field that names that account for people, as a dotted path of the
30
+ * same answer: the server's name (`guild.name`), a Discord user's
31
+ * `global_name` */ account_title?: string;
32
+ /** another integration naming the person who signs in through this one,
33
+ * whose own connection the same sign-in makes: Discord's bot added with
34
+ * `identify` granted also links the Discord account of whoever added it
35
+ * (`discord-account`) */ links?: string;
36
+ /** a person's own account at the service (a Discord user), which says who
37
+ * they are there: a connection through it is its connector's, never the
38
+ * space's */ personal?: boolean;
39
+ /** the chat platform its connections talk through (@yaks/chat), by name:
40
+ * connecting it is all it takes for the Operator and the space's apps to
41
+ * hear and answer there */ chat?: string;
42
+ /** The OAuth grant itself is the bot credential for this installation. */ chat_grant?: boolean;
43
+ /** what a connection asks for when nothing narrower was needed */ scopes?: string[];
44
+ /** The provider separates OAuth scopes with commas. */ scope_separator?: ' ' | ',';
45
+ /** Whether the OAuth provider accepts PKCE for this client. */ pkce?: boolean;
46
+ /** extra authorize parameters, such as Google's `access_type: 'offline'` */ params?: Record<string, string>;
47
+ /** how the client authenticates at the token endpoint (@yaks/oauth) */ auth?: 'basic' | 'post';
48
+ /** how refresh grants are sent when a provider requires JSON */ refresh_encoding?: 'form' | 'json';
49
+ /** what the exchange answers: tokens, or a key, as OpenRouter's does */ answers?: 'tokens' | 'key';
50
+ /** the resource a grant is for (RFC 8707), as an MCP server asks */ resource?: string;
51
+ /** the issuer its returns name (RFC 9207), where it says it names one */ issuer?: string;
52
+ /** the OAuth client it signs in as, by name (./clients.ts): one registration
53
+ * several integrations can share */ client?: string;
54
+ /** a public OAuth client's id; no secret or registration is needed */ client_id?: string;
55
+ /** the broker new connections through it are made through (./brokers.ts),
56
+ * and what the broker calls it; none is direct */ broker?: {
57
+ name: string;
58
+ integration: string;
59
+ managed?: boolean;
60
+ scoped?: boolean;
61
+ };
62
+ /** the API hosts its credential may be sent to, and no others */ hosts: string[];
63
+ /** A credential was saved through this custom integration. */ credentialed?: boolean;
64
+ /** its API: the address its paths are under, its reference, and the calls
65
+ * that only read though their method is not GET (`POST /freeBusy`, `*` for
66
+ * one segment); none is reached at its first host */ api?: {
67
+ base: string;
68
+ docs?: string;
69
+ reads?: string[];
70
+ };
71
+ /** the only API methods a connection through it may ask for, where the
72
+ * service names one in each request (voip.ms's `method`); none limits
73
+ * nothing */ methods?: string[];
74
+ /** what a person gives to connect a pasted-key one, when it is more than
75
+ * one key; none is one key */ fields?: Field[];
76
+ /** how the service signs the webhooks it sends */ signature?: Scheme;
77
+ /** still in the service's testing mode, where only the people it lists may
78
+ * sign in: offered only on a page opened with `?enable=<name>` */ testing?: boolean;
79
+ /** installed from this package's seed data; only the host writes it */ built?: boolean;
80
+ /** how a person gets the credential, in markdown, for them and their agent */ instructions?: string;
81
+ /** what its one key looks like, shown in the box it is pasted in:
82
+ * ElevenLabs' `sk_••••••••` */ example?: string;
83
+ /** its own hosted MCP server's address, which a person connects by signing
84
+ * in to their account there (./mcp.ts), as well as or instead of a key */ mcp?: string;
85
+ /** a call that answers 2xx once its credential works, `METHOD url` on one
86
+ * of its hosts: Cloudflare's `GET …/user/tokens/verify` */ check?: string;
87
+ /** the space or person that made a custom one, who alone may change its
88
+ * text; none for a built one */ owner?: string;
89
+ };
90
+ /** A read of the graph: what a tool's context and a graph both offer. */ export type Read = Reads<Bundle[] | Promise<Bundle[]>, []>;
91
+ /** The integrations this package builds, as shipped: what `install` writes,
92
+ * read here with no graph, for a host that only needs to know them. */ export declare let seeds: () => Integration[];
93
+ /** Whether a person connects it by pasting a key rather than signing in:
94
+ * one with no token endpoint and no broker to sign in through. */ export declare let keyed: (i: Integration) => boolean;
95
+ /** The policy for older rows and catalog entries before they are added. */ export declare let visitorPolicy: (i?: Integration) => VisitorPolicy;
96
+ /** Whether visitors may call out through a link. The integration sets the
97
+ * default for an unset `anyone`. A policy of `never` bars visitor access.
98
+ *
99
+ * ```ts
100
+ * visitorsAllowed('on', undefined) // true
101
+ * visitorsAllowed('on', false) // false
102
+ * visitorsAllowed('off', undefined) // false
103
+ * visitorsAllowed('never', true) // false
104
+ * ``` */ export declare let visitorsAllowed: (policy: VisitorPolicy, anyone: unknown) => boolean;
105
+ /** Whether a person can connect it here: by pasting a key, through a sign-in
106
+ * that answers a key to any caller (OpenRouter), or through what it signs in
107
+ * with once that is kept (`kept`): its broker, when it names one
108
+ * (./brokers.ts), else the OAuth client it names (./clients.ts). */ export declare let connectable: (i: Integration, kept?: unknown) => boolean;
109
+ /** An integration by name, as the graph holds it. */ export declare let known: (read: Read, name: string) => Promise<Integration | undefined>;
110
+ /** The integrations of these names, as the graph holds them, in one read:
111
+ * each found among them by `knownIn`. */ export declare let knownAll: (read: Read, names: string[]) => Promise<Bundle[]>;
112
+ /** The built integration that stands in for the service `name`: the one of
113
+ * that name, else one signing in through a broker's listing of it (Gmail for
114
+ * Nango's google-mail). The catalog offers, the directory lists and the
115
+ * connections page adds that one in the listing's place. */ export declare let standIn: <I extends Integration>(built: I[], name: string, broker?: string) => I | undefined;
116
+ /** An integration by name, among rows already read: what `list` and
117
+ * `borrowed` return beside their connections. */ export declare let knownIn: (rows: Bundle[], name: string) => Integration | undefined;
118
+ /** The built integrations a graph holds. */ export declare let installed: (read: Read) => Promise<Integration[]>;
119
+ /** The platform's mark that an integration is featured (@yaks/platform). */ export declare let FEATURED: string;
120
+ /** An integration as the catalog and the directory read it: with whether the
121
+ * platform featured it, which is the platform's mark rather than its own. */ export type Marked = Integration & {
122
+ featured?: boolean;
123
+ };
124
+ /** What a person reads at length about an integration: drawn only for the
125
+ * one a page opens, read by name (`known`), and for those built here. */ export type Prose = 'description' | 'details' | 'docs' | 'instructions';
126
+ /** The host catalog's rows, including integrations not connected yet: those
127
+ * built here whole, the rest without their prose (`Prose`), which is half of
128
+ * each and drawn only for the one a page opens. */ export declare let catalogued: (read: Read) => Promise<Marked[]>;
129
+ /** What reads the host catalog without its prose: `catalogued`, or one
130
+ * `catalogHeld` keeps. */ export type Catalog = (read: Read) => Promise<Marked[]>;
131
+ /** A catalog as it was read, and the stamp it was read at. */ export type HeldCatalog = {
132
+ stamp: string;
133
+ rows: Marked[];
134
+ };
135
+ /** Where a catalog is kept beyond the one that holds it, such as a cache
136
+ * every process in a place shares. */ export type CatalogKept = {
137
+ get(): Promise<HeldCatalog | undefined>;
138
+ put(catalog: HeldCatalog): void;
139
+ };
140
+ /** The host catalog (`catalogued`), read again only once it changed: each
141
+ * call reads a stamp of a few rows beside the rest of its moment, and the
142
+ * whole only when the stamp moved. With none held yet, it reads the one
143
+ * `kept` holds beside the stamp, and the whole only where that is not the
144
+ * stamp's; with nothing kept, the whole beside the stamp. The rows are
145
+ * shared by every caller, so none changes them.
146
+ *
147
+ * ```ts
148
+ * import { assertEquals } from '@std/assert'
149
+ * import { catalogHeld } from '@yaks/connections'
150
+ * let asked: string[] = []
151
+ * let read = (q: unknown) => (asked.push(String(q)), Promise.resolve([]))
152
+ * let stamp = '[[],[],[]]'
153
+ * let kept = { get: () => Promise.resolve({ stamp, rows: [] }), put() {} }
154
+ * assertEquals(await catalogHeld(kept)(read), [])
155
+ * assertEquals(asked.length, 3, 'the stamp alone')
156
+ * ```
157
+ */ export declare let catalogHeld: (kept?: CatalogKept) => Catalog;
158
+ /** What is said about an integration, which its owner may change: never
159
+ * where its credential is sent. */ export type About = Pick<Integration, 'title' | 'tagline' | 'site' | 'instructions' | 'example' | 'check' | 'image'>;
160
+ /** The properties of {@link About}, in the order a page shows them. */ export declare let ABOUT: readonly ['title', 'tagline', 'site', 'instructions', 'example', 'check'];
161
+ /** What was said about an integration, as it is written: each property given,
162
+ * trimmed, and an empty one cleared. A site is an https address, the only
163
+ * kind a page links, and a check a method and an https address. */ export declare let told: (a: Record<string, unknown>) => Record<string, string | null>;
164
+ /** What a custom integration shown in the integration directory wears:
165
+ * @yaks/platform's `published{at}`, as anything shared on a platform does. */ export declare let PUBLISHED: string;
166
+ /** The patch publishing a shared thing now, or taking it out. */ export declare let publishing: (on: boolean) => {
167
+ at: string;
168
+ } | null;
169
+ /** An integration's owner changing what is said about it, or publishing it in
170
+ * the integration directory (`listed`) or taking it out. A built one is the
171
+ * host's, and one with no owner (made before owners were kept, or whose owner
172
+ * is gone) is nobody's to change. */ export declare let set: (read: Read, a: About & {
173
+ owner: Eid;
174
+ integration: string;
175
+ listed?: boolean;
176
+ }) => Promise<Bundle[]>;
177
+ /** An integration in the integration directory, and since when a custom one
178
+ * is published there. */ export type Listed = Marked & {
179
+ published?: string;
180
+ unchecked?: boolean;
181
+ };
182
+ /**
183
+ * The integration directory: host catalog services outside testing and custom
184
+ * integrations their owner listed, by title. Words match every part of the
185
+ * service and integration descriptions, including categories and docs. A
186
+ * search takes the catalog without its prose from `catalog`, such as one
187
+ * `catalogHeld` keeps.
188
+ */ export declare let listing: (read: Read, words?: string, catalog?: Catalog) => Promise<Listed[]>;
189
+ /**
190
+ * The batch that installs built integrations in a graph: each one missing
191
+ * there, or held otherwise than its seed says, with operational seed fields
192
+ * current and graph-authored catalog descriptions preserved, and marked `built`. Nothing, where every one
193
+ * already matches. A host applies it trusted, since `built` is server-owned,
194
+ * once at start-up. `seeds` defaults to this package's own.
195
+ */ export declare let install: (read: Read, seeds?: Integration[]) => Bundle[] | Promise<Bundle[]>;
196
+ //# sourceMappingURL=integrations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integrations.d.ts","sources":["../integrations.ts"],"names":[],"mappings":"AAoBA,cAAc,MAAM,EAAE,GAAG,EAAE,KAAK,2BAAgC;AAEhE,cAAc,MAAM,0BAA+B;AAGnD,SAAS,KAAK,KAAK,EAAE,QAAQ,EAAE,GAAG,qBAAiC;AAEnE,SAAS,KAAK,KAAK,EAAE,QAAQ,EAAE,GAAG,GAAE;AAwBpC,YAAY,gBAAgB,UAAU,QAAQ;AAE9C,iCAAiC,GACjC,YAAY;EACV,MAAM,MAAM;EACZ,wEAAwE,GACxE;IAAY,KAAK,MAAM;;EACvB,wDAAwD,GACxD,QAAQ,MAAM;EACd,qDAAqD,GACrD,UAAU,MAAM;EAChB,2BAA2B,GAC3B,OAAO,MAAM;EACb,cAAc,MAAM;EACpB,UAAU,MAAM;EAChB,OAAO,MAAM;EACb,WAAW,QAAQ,WAAW;EAC9B,WAAW;EACX,aAAa,MAAM;EACnB,QAAQ,MAAM;EACd,oDAAoD,GACpD,OAAO,MAAM;EACb,yCAAyC,GACzC,YAAY,MAAM;EAClB,0EAA0E,GAC1E,QAAQ,MAAM;EACd,qEAAqE,GACrE,WAAW,MAAM;EACjB;;;mDAGiD,GACjD,UAAU,MAAM;EAChB;;mBAEiB,GACjB,gBAAgB,MAAM;EACtB;;;yBAGuB,GACvB,QAAQ,MAAM;EACd;;aAEW,GACX,WAAW,OAAO;EAClB;;2BAEyB,GACzB,OAAO,MAAM;EACb,wEAAwE,GACxE,aAAa,OAAO;EACpB,gEAAgE,GAChE,SAAS,MAAM;EACf,qDAAqD,GACrD,kBAAkB,MAAM;EACxB,6DAA6D,GAC7D,OAAO,OAAO;EACd,0EAA0E,GAC1E,SAAS,OAAO,MAAM,EAAE,MAAM;EAC9B,qEAAqE,GACrE,OAAO,UAAU;EACjB,8DAA8D,GAC9D,mBAAmB,SAAS;EAC5B,sEAAsE,GACtE,UAAU,WAAW;EACrB,kEAAkE,G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EAAK,aAAa,MAAM;EAAE,SAAS,OAAO;MAC7D,QAAQ,UA+BV;AAED;uBACuB,GACvB,YAAY,SAAS;EAAW,YAAY,MAAM;EAAE,YAAY,OAAO;;AAwFvE;;;;;;CAMC,GACD,OAAO,YAAI,UACT,MAAM,MACN,gBACA,UAAS,YACR,QAAQ,UA2BV;AA0BD;;;;;;CAMC,GACD,OAAO,YAAI,UACT,MAAM,MACN,QAAO,kBACN,WAAW,QAAQ,UAmCnB"}
@@ -0,0 +1,7 @@
1
+ export type Listen = (address: {
2
+ hostname: string;
3
+ port: number;
4
+ }, handle: (request: Request) => Response | Promise<Response>) => {
5
+ shutdown: () => Promise<void>;
6
+ } | undefined;
7
+ //# sourceMappingURL=loopback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loopback.d.ts","sources":["../loopback.ts"],"names":[],"mappings":"AAGA,YAAY,UACV;EAAW,UAAU,MAAM;EAAE,MAAM,MAAM;GACzC,SAAS,SAAS,YAAY,WAAW,QAAQ;EAC5C,gBAAgB,QAAQ,IAAI;IAAM,SAAS"}
@@ -0,0 +1,33 @@
1
+ import { type Bundle, type Graph, type Tx } from "@yaks/graph";
2
+ export declare let mcpIntegration: (server: string) => string;
3
+ type Server = {
4
+ id: string;
5
+ owner?: string;
6
+ };
7
+ type Plan = {
8
+ id: string;
9
+ rows: string[];
10
+ secrets: string[];
11
+ removed: boolean;
12
+ retained: boolean;
13
+ };
14
+ /** A server owns the integration named by its identity. Connections lent to
15
+ * surviving apps, and an OAuth client used by another integration, stay. */ export declare let retirement: (tx: Pick<Tx, 'get' | 'read'>, servers: Server[], gone?: ReadonlySet<string>, pending?: Bundle[]) => Plan[] | Promise<Plan[]>;
16
+ /** Look for dedicated MCP integrations left by earlier permanent removals.
17
+ * Recoverable servers still have a row or a copy in the graph trash. */ export declare let orphans: (graph: Graph, tx: Tx, candidates: string[]) => Plan[] | Promise<Plan[]>;
18
+ export type Notice = {
19
+ to: string;
20
+ about: string;
21
+ subject: string;
22
+ body: string;
23
+ };
24
+ export type Retirement = {
25
+ rows: string[];
26
+ secrets: string[];
27
+ notices: Notice[];
28
+ };
29
+ /** The vault and archive erasure is owed by the same write that buried the
30
+ * graph rows. Its notice becomes deliverable after the erasure finishes. */ export declare let retiring: (plans: Plan[], notices?: Notice[]) => Bundle[];
31
+ /** Scan the directory in the same 50-row windows as its store mover. Each
32
+ * request rechecks the candidates inside the transaction that removes them. */ export declare let retireOrphans: (graph: Graph) => Promise<void>;
33
+ //# sourceMappingURL=mcp-retirement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-retirement.d.ts","sources":["../mcp-retirement.ts"],"names":[],"mappings":"AACA,SACE,KAAK,MAAM,EAEX,KAAK,KAAK,EAGV,KAAK,EAAE,2BACsB;AAM/B,OAAO,YAAI,iBAAkB,QAAQ,MAAM,YAAoB;KAE1D;EAAW,IAAI,MAAM;EAAE,QAAQ,MAAM;;KAOrC;EACH,IAAI,MAAM;EACV,MAAM,MAAM;EACZ,SAAS,MAAM;EACf,SAAS,OAAO;EAChB,UAAU,OAAO;;AAGnB;0EAC0E,GAC1E,OAAO,YAAI,aACT,IAAI,KAAK,IAAI,QAAQ,SACrB,SAAS,UACT,OAAM,YAAY,MAAM,GACxB,UAAS,aACR,SAAS,QAAQ,QA0EnB;AAED;sEACsE,GACtE,OAAO,YAAI,UACT,OAAO,OACP,IAAI,IACJ,YAAY,MAAM,OACjB,SAAS,QAAQ,QAkChB;AAEJ,YAAY;EACV,IAAI,MAAM;EACV,OAAO,MAAM;EACb,SAAS,MAAM;EACf,MAAM,MAAM;;AAGd,YAAY;EACV,MAAM,MAAM;EACZ,SAAS,MAAM;EACf,SAAS;;AAGX;0EAC0E,GAC1E,OAAO,YAAI,WAAY,OAAO,QAAQ,UAAS,aAAgB,SAQ9D;AAED;6EAC6E,GAC7E,OAAO,YAAI,gBAAuB,OAAO,UAAQ,QAAQ,IAAI,EAgB5D"}
package/_dist/mcp.d.ts ADDED
@@ -0,0 +1,179 @@
1
+ import { type Bundle } from "@yaks/graph";
2
+ import type { Step } from "@yaks/tools/title";
3
+ import { type Options } from "@yaks/mcp-client";
4
+ import { type Ctx } from "./connections.js";
5
+ /** What one command answers: its words, and the rest of its reply. */ export type Out = {
6
+ text: string;
7
+ value?: Record<string, unknown>;
8
+ };
9
+ /** One remote command, as a host lists it: `at` is its server's address,
10
+ * `mcp:<server eid>`, and `name` its exact remote name. */ export type Command = {
11
+ at: string;
12
+ name: string;
13
+ title: string;
14
+ /** how a call reads to the person while it runs and once it answered */ step?: Step;
15
+ description: string;
16
+ readOnly: boolean;
17
+ input: unknown;
18
+ };
19
+ type Host = Ctx & {
20
+ report: (e: unknown) => void;
21
+ /** The page a person signs in to a server on, or gives its key: the
22
+ * connections page of the space it is in. */ signIn: string | (() => Promise<string>);
23
+ /** The machine a space's tunnel goes to, as a fetch for this person when
24
+ * the space is theirs, and null to anyone else. A host without one reaches
25
+ * no machine. */ machine?: (space: string) => Promise<typeof fetch | null>;
26
+ /** The spaces this person owns: the machines they can name. */ owned?: () => Promise<string[]>;
27
+ /** The space the servers are reached in, by its eid; absent at a door that
28
+ * names none, which reaches only servers kept without a space. */ space?: string;
29
+ /** A person's seat in `space`: the caller's, and that of each person who
30
+ * connected a server there for everyone. A host that does not say is
31
+ * answered as none. */ seat?: (person: string) => Promise<Seat>;
32
+ /** Reaches the person's servers in every space: an app's code, which
33
+ * calls only the ones the person granted it (@yaks/connections `grant`). */ every?: boolean;
34
+ };
35
+ /** A person's seat in a space, as the servers reached there ask it: one who
36
+ * owns it, one who writes there, one who only reads, or none. */ export type Seat = 'owns' | 'writes' | 'reads' | null;
37
+ export type Settings = {
38
+ name?: string;
39
+ url: string;
40
+ machine?: string;
41
+ enabled?: boolean;
42
+ allow?: string[];
43
+ client_id?: string;
44
+ header?: string | null;
45
+ lists?: Offered[];
46
+ mentions?: string | null;
47
+ everyone?: boolean;
48
+ };
49
+ /** What connecting a server found: its id and name, its tools (or the
50
+ * command to sign in, where it waits on one), and what it waits on, where it
51
+ * does: a sign-in, through the OAuth its metadata names, or a key, where it
52
+ * refused without naming one. */ export type Configured = {
53
+ server: string;
54
+ name: string;
55
+ commands: RemoteCommand[];
56
+ needs?: 'sign-in' | 'key';
57
+ };
58
+ /** One server a person keeps, as their connections page shows it. `status`
59
+ * is its connection's (`connection`), `open` where it asked for no
60
+ * credential yet, and `machine` for one reached through a tunnel. */ export type Shown = {
61
+ id: string;
62
+ name: string;
63
+ url: string;
64
+ machine?: string;
65
+ enabled: boolean;
66
+ allow?: string[];
67
+ header?: string;
68
+ trashed: boolean;
69
+ /** whether it serves everyone the space's Operator works with */ everyone: boolean;
70
+ status: 'open' | 'machine' | 'needed' | 'connected' | 'broken' | 'unavailable';
71
+ alternative?: {
72
+ name: string;
73
+ title: string;
74
+ };
75
+ connection?: string;
76
+ /** whether its credential is a key the person gives, rather than a
77
+ * sign-in; absent where it asked for neither */ keyed?: boolean;
78
+ };
79
+ /** One list a server offers, as `mcp_connect` takes it. */ export type Offered = {
80
+ title: string;
81
+ tool: string;
82
+ args: Record<string, unknown>;
83
+ waits: boolean;
84
+ };
85
+ /** One tool of a server, as a command at its address. */ export type RemoteCommand = Command & {
86
+ namespace: string;
87
+ machine?: string;
88
+ };
89
+ /** How much of what one server says to read before its tools an Operator is
90
+ * told, in characters: about 16k tokens. A server's instructions are its own
91
+ * text, which a stranger's server writes, and they are sent with every ask of
92
+ * the Operator they reach. */ export declare let SAID: number;
93
+ /** How much of what a server says of one tool a model is told, in
94
+ * characters: the server writes it, and it rides with every turn its tool is
95
+ * listed in. */ export declare let DESCRIBED: number;
96
+ /** How much of a tool's own title is kept, in characters: a name, not room
97
+ * for words to the model. */ export declare let TITLED: number;
98
+ /** One ask of a server: a tool of its, and what it is called with. */ export type Ask = {
99
+ name: string;
100
+ args: Record<string, unknown>;
101
+ };
102
+ /** What one ask answered, or why it failed. */ export type Asked = {
103
+ out: Out;
104
+ } | {
105
+ error: unknown;
106
+ };
107
+ /** One server reached, with what it said to read before its tools (`text`,
108
+ * empty where it said nothing), cut at {@link SAID}: where it is (`url`, a
109
+ * path on the space's `machine` for one reached through a tunnel) and who
110
+ * connected it (`by`). */ export type Told = {
111
+ label: string;
112
+ namespace: string;
113
+ url: string;
114
+ machine?: string;
115
+ by: string;
116
+ text: string;
117
+ };
118
+ /** One tool a server offers, with whether its allow list offers it. */ export type Choice = {
119
+ name: string;
120
+ title: string;
121
+ description: string;
122
+ allowed: boolean;
123
+ };
124
+ /** Whether the person's own server `row` is reached in `space`: one
125
+ * connected there, or one kept without a space, which reaches its person
126
+ * everywhere. */ export declare let reachedIn: (row: Bundle, space?: string) => boolean;
127
+ /** What changes on a server a person keeps: `allow` null offers every tool,
128
+ * and `header` null sends its key as a bearer token. */ export type Patch = {
129
+ enabled?: boolean;
130
+ allow?: string[] | null;
131
+ everyone?: boolean;
132
+ name?: string;
133
+ header?: string | null;
134
+ };
135
+ /** A person's MCP servers, as {@link remoteCommands} gives them. */ export type Remote = {
136
+ set: (id: string, patch: Patch) => Promise<void>;
137
+ tools: (id: string) => Promise<Choice[]>;
138
+ /** Each server the person keeps, from `kept` where its rows were read
139
+ * already. */ shown: (kept?: Bundle[]) => Promise<Shown[]>;
140
+ list: (at?: string) => Promise<RemoteCommand[]>;
141
+ call: (at: string, name: string, args: Record<string, unknown>) => Promise<Out>;
142
+ calls: (at: string, asks: Ask[]) => Promise<Asked[]>;
143
+ told: () => Promise<Told[]>;
144
+ configure: (settings: Settings) => Promise<Configured>;
145
+ give: (id: string, key: string) => Promise<void>;
146
+ signsInAs: (id: string, given: {
147
+ id: string;
148
+ secret?: string;
149
+ }) => Promise<void>;
150
+ remove: (id: string) => Promise<void>;
151
+ restore: (id: string) => Promise<void>;
152
+ kept: () => Promise<Bundle[]>;
153
+ };
154
+ /** The names of the servers `person` connected in `space` for everyone in
155
+ * it, those in the trash left out: what they stop sharing there when they
156
+ * own it no longer. */ /** A credential found for a host, and the header it goes in: null sends it
157
+ * as a bearer token, as a sign-in's token always is. */ export type HostKey = {
158
+ key: string;
159
+ header: string | null;
160
+ };
161
+ /** The credential of the first connected server among `servers`
162
+ * (`mcp_server` rows) whose sign-in or key goes to `host`: what a client of
163
+ * the same service's own API asks it with, as speech asks ElevenLabs with the
164
+ * sign-in its MCP server took. A server turned off, in the trash or on a
165
+ * machine gives none. */ export declare let hostKey: (c: Ctx, servers: Bundle[], host: string) => Promise<HostKey | undefined>;
166
+ export declare let sharing: (read: Ctx['graph']['read'], person: string, space: string) => string[] | Promise<string[]>;
167
+ /** Each operation reads ownership anew; no roster retains authority. */ export declare let remoteCommands: (person: string, host: Host, options?: Options) => Remote;
168
+ /** What a page form did: what the page says, and the connection whose
169
+ * sign-in it goes straight to, where adding a server found it takes one. */ export type Acted = string | {
170
+ say: string;
171
+ signIn: string;
172
+ } | {
173
+ alternative: NonNullable<Shown['alternative']>;
174
+ };
175
+ /** What a form on a person's connections page does to their MCP servers,
176
+ * named by `do` (`mcp-add`, `mcp-key`, `mcp-client`, `mcp-name`, `mcp-tools`, `mcp-everyone`,
177
+ * `mcp-mine`, `mcp-on`, `mcp-off`, `mcp-remove`, `mcp-restore`), with the server it is about in `server`. It
178
+ * answers what the page says, and null for a form about something else. */ export declare let acted: (remote: Remote, act: string, field: (name: string) => string, fields: (name: string) => string[]) => Promise<Acted | null>;
179
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.d.ts","sources":["../mcp.ts"],"names":[],"mappings":"AAiBA,SAAS,KAAK,MAAM,2BAAiD;AAIrE,cAAc,IAAI,iCAAsC;AACxD,SAQE,KAAK,OAAO,gCAEsB;AAOpC,SAA8B,KAAK,GAAG,2BAAsC;AAS5E,oEAAoE,GACpE,YAAY;EAAQ,MAAM,MAAM;EAAE,QAAQ,OAAO,MAAM,EAAE,OAAO;;AAChE;yDACyD,GACzD,YAAY;EACV,IAAI,MAAM;EACV,MAAM,MAAM;EACZ,OAAO,MAAM;EACb,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K,MAAM,KAAK,QAAQ,IAAI;EAC/C,YACE,IAAI,MAAM,EACV;IAAS,IAAI,MAAM;IAAE,SAAS,MAAM;QACjC,QAAQ,IAAI;EACjB,SAAS,IAAI,MAAM,KAAK,QAAQ,IAAI;EACpC,UAAU,IAAI,MAAM,KAAK,QAAQ,IAAI;EACrC,YAAY,QAAQ;;AAGtB;;qBAEqB,GACrB;sDACsD,GACtD,YAAY;EAAY,KAAK,MAAM;EAAE,QAAQ,MAAM,GAAG,IAAI;;AAE1D;;;;uBAIuB,GACvB,OAAO,YAAI,UACT,GAAG,KACH,SAAS,UACT,MAAM,MAAM,KACX,QAAQ,UAAU,SAAS,EAkB7B;AAED,OAAO,YAAI,UACT,MAAM,IAAI,SAAS,SACnB,QAAQ,MAAM,EACd,OAAO,MAAM,KACZ,MAAM,KAAK,QAAQ,MAAM,IAQzB;AAEH,sEAAsE,GACtE,OAAO,YAAI,iBACT,QAAQ,MAAM,EACd,MAAM,MACN,UAAS,YACR,OA4vBF;AAaD;0EAC0E,GAC1E,YAAY,QAAQ,MAAM;EAAK,KAAK,MAAM;EAAE,QAAQ,MAAM;;EACxD,aAAa,YAAY,MAAM;;AAGjC;;;yEAGyE,GACzE,OAAO,YAAI,QACT,QAAQ,QACR,KAAK,MAAM,EACX,QAAQ,MAAM,MAAM,KAAK,MAAM,EAC/B,SAAS,MAAM,MAAM,KAAK,MAAM,OAC/B,QAAQ,QAAQ,IAAI,EAoFtB"}
package/_dist/mod.d.ts ADDED
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @yaks/connections — the outside services a yaks graph can reach, and the
3
+ * links between a space or a person and one.
4
+ *
5
+ * An **integration** is an outside service as data: where a person signs in to
6
+ * it and where its codes are exchanged, for one reached by OAuth, the hosts
7
+ * its credential may be sent to, and how a page shows it. Every one is an
8
+ * `integration` entity in the graph: the built ones ship with this package as
9
+ * seed data, which a host installs at start-up ({@link install}), and a custom
10
+ * one is owned by the space or person that made it.
11
+ *
12
+ * A **connection** is one link through an integration, owned by a space or a
13
+ * person, and is also the secret its credential is kept as
14
+ * ({@link https://jsr.io/@yaks/secrets | @yaks/secrets}): the graph holds a
15
+ * handle, the vault holds the key or the tokens, and code that calls out is
16
+ * handed a sentinel. A `uses` link says which app calls out through which
17
+ * connection.
18
+ *
19
+ * ```ts
20
+ * import { need, connect, resolve } from '@yaks/connections'
21
+ *
22
+ * // an app says what it needs; the space sees it as needed
23
+ * // await g.apply(await need(g.read, { owner: space, app, integration: 'twilio' }))
24
+ * // the person pastes the key; it goes to the vault
25
+ * // await connect({ graph: g, vault }, connection, { key })
26
+ * // the app is handed what it calls out with
27
+ * // await resolve({ graph: g, vault }, app, 'twilio') → { connection, link, sentinel }
28
+ * ```
29
+ *
30
+ * An app may instead ask each person who uses it to connect their own
31
+ * (`each`): each person's connection is theirs, and only they call out
32
+ * through it.
33
+ *
34
+ * The verbs: {@link need}, {@link list} (the two tools), {@link attach} and
35
+ * {@link set} for a space owner through its host, {@link carry} for a copy of
36
+ * an app, {@link lend}, {@link recall} and {@link borrowed} for a connection
37
+ * lent to the copies, {@link using},
38
+ * {@link through},
39
+ * {@link begin} and {@link connect}, {@link disconnect}, {@link resolve},
40
+ * {@link used} and {@link envOf}, {@link credential}, {@link refresh}, and
41
+ * {@link call} for a call out by the one who holds the connection.
42
+ *
43
+ * A person's sources of tools (an MCP server, a connection sent requests
44
+ * through, an app service) are named by address, and an app reaches one only
45
+ * where the person granted it: {@link grant}, {@link granted},
46
+ * {@link grantees},
47
+ * {@link grantsOf}, {@link revoke} and {@link grantable}. A connection's own
48
+ * command is {@link requests} and {@link request}. A host
49
+ * that composes this package
50
+ * composes @yaks/secrets, over its vault, and @yaks/edge beside it; the egress
51
+ * that swaps sentinels is @yaks/egress.
52
+ *
53
+ * @module
54
+ */ export { connectionsDoc } from "./vocab.js";
55
+ export { ABOUT, type About, type Catalog, catalogHeld, type CatalogKept, catalogued, connectable, FEATURED, type Field, fieldsOf, type HeldCatalog, install, installed, type Integration, KEY, keyed, known, knownAll, knownIn, type Listed, listing, type Marked, PUBLISHED, type Read, seeds, set, standIn, told, type VisitorPolicy, visitorPolicy, visitorsAllowed } from "./integrations.js";
56
+ export { CONNECTION, INTEGRATION, integrationEid, USES } from "./identity.js";
57
+ export { connectionHistory } from "./history.js";
58
+ export { through } from "./graph.js";
59
+ export { configuredConnections, configuredSignIns } from "./sign-in.js";
60
+ export { clientOf, type Registered, registered, registration } from "./clients.js";
61
+ export { type Broker, BrokerError, brokerKey, brokerOf, BROKERS, exampleLogo, type Found, type Grant, type Listing, logoSources, nango } from "./brokers.js";
62
+ export { adopted, catalogKey, catalogue, find, initialLogo, isSvg, keyGuide, keyHelp, kind, kinds, type Offer, offerOf } from "./catalog.js";
63
+ export { accountCredential, AccountError, accountOf, approve, attach, attachInstallation, begin, bindingOf, borrowed, botFrom, botOf, call, carry, chatConnections, connect, credential, type Ctx, decline, disconnect, envOf, type Given, keysOf, lacking, lapsedHold, lend, list, loginCredential, namesOf, type Need, need, type NewSignIn, opens, type Owners, type Path, pick, recall, redeemInstallation, refresh, resolve, type Resolved, settle, signsInWith, type Status, toAccount, used, using } from "./connections.js";
64
+ export { type AuthAction, type AuthOptions, authorize, type AuthReply, type AuthTarget, type Callback } from "./authorize.js";
65
+ export { REDIRECT, type SignIns, signins } from "./signin.js";
66
+ export { codeFor, codeIn, lettersFor } from "./signin-mail.js";
67
+ export { addressed, grant, type Grantable, grantable, granted, grantedTo, grantees, grantOf, grantsOf, type Kind, revoke, serviceAt } from "./sources.js";
68
+ export { type Answer, request, requestable, requests, type SourceCommand } from "./requests.js";
69
+ export { grantService, publishService, type ServiceAuthority, serviceAuthority, serviceName } from "./services.js";
70
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqDC,GAED,SAAS,cAAc,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ACN,OAAO,EACP,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,eAAe,EACf,OAAO,EACP,KAAK,IAAI,EACT,IAAI,EACJ,KAAK,SAAS,EACd,KAAK,EACL,KAAK,MAAM,EACX,KAAK,IAAI,EACT,IAAI,EACJ,MAAM,EACN,kBAAkB,EAClB,OAAO,EACP,OAAO,EACP,KAAK,QAAQ,EACb,MAAM,EACN,WAAW,EACX,KAAK,MAAM,EACX,SAAS,EACT,IAAI,EACJ,KAAK,2BACkB;AAEzB,SACE,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,SAAS,EACT,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,QAAQ,yBACQ;AACvB,SAAS,QAAQ,EAAE,KAAK,OAAO,EAAE,OAAO,sBAAqB;AAE7D,SAAS,OAAO,EAAE,MAAM,EAAE,UAAU,2BAA0B;AAE9D,SACE,SAAS,EACT,KAAK,EACL,KAAK,SAAS,EACd,SAAS,EACT,OAAO,EACP,SAAS,EACT,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,KAAK,IAAI,EACT,MAAM,EACN,SAAS,uBACU;AACrB,SACE,KAAK,MAAM,EACX,OAAO,EACP,WAAW,EACX,QAAQ,EACR,KAAK,aAAa,wBACE;AAEtB,SACE,YAAY,EACZ,cAAc,EACd,KAAK,gBAAgB,EACrB,gBAAgB,EAChB,WAAW,wBACS"}
@@ -0,0 +1,13 @@
1
+ import type { Bundle } from "@yaks/graph";
2
+ import type { Field } from "./field.js";
3
+ /** What a person gave: the one key, or each field by name. */ export type Pasted = {
4
+ key: string;
5
+ } | {
6
+ fields: Record<string, string>;
7
+ };
8
+ /** What the vault keeps for a pasted credential: one field's value as it is,
9
+ * so one key is kept as it always was, and several as a JSON object by name. */ export declare let keptOf: (name: string, fields: Field[], given: Pasted) => string;
10
+ /** The write keeping `given` as connection `b`'s credential, through the
11
+ * integration `name` that asks for `fields`: its secret's value, and its
12
+ * status connected. */ export declare let pasted: (b: Bundle, name: string, fields: Field[], given: Pasted) => Bundle;
13
+ //# sourceMappingURL=paste.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paste.d.ts","sources":["../paste.ts"],"names":[],"mappings":"AAMA,cAAc,MAAM,2BAAgC;AACpD,cAAc,KAAK,qBAAoB;AAGvC,4DAA4D,GAC5D,YAAY;EAAW,KAAK,MAAM;;EAAO,QAAQ,OAAO,MAAM,EAAE,MAAM;;AAEtE;8EAC8E,GAC9E,OAAO,YAAI,SACT,MAAM,MAAM,EACZ,QAAQ,SACR,OAAO,WACN,MAAM,CAkBR;AAED;;qBAEqB,GACrB,OAAO,YAAI,SACT,GAAG,QACH,MAAM,MAAM,EACZ,QAAQ,SACR,OAAO,WACN,OAOD"}
@@ -0,0 +1,30 @@
1
+ import type { Eid } from "@yaks/graph";
2
+ import { type Ctx } from "./connections.js";
3
+ import { type Integration, type Read } from "./integrations.js";
4
+ /** One command a source offers, as a pool of tools lists it. */ export type SourceCommand = {
5
+ /** its source's address: `connection:<connection>` */ at: string;
6
+ name: string;
7
+ title: string;
8
+ description: string;
9
+ readOnly: boolean;
10
+ /** its arguments, as JSON Schema */ input: Record<string, unknown>;
11
+ };
12
+ /** A request's answer: the service's status, headers and body as text. */ export type Answer = {
13
+ status: number;
14
+ headers: Record<string, string>;
15
+ body: string;
16
+ };
17
+ /** Whether a service can be called through a connection its owner holds. */ export declare let requestable: (i: Integration | undefined) => i is Integration;
18
+ /** The `request` command of each connection `owners` hold, or of the ones
19
+ * among `only`. */ export declare let requests: (read: Read, owners: Eid[], only?: Eid[]) => Promise<SourceCommand[]>;
20
+ /** Run a connection's command for a caller that may send through what
21
+ * `owners` hold: the request, sent through `call`. */ export declare let request: (c: Ctx, a: {
22
+ at: string;
23
+ owners: Eid[];
24
+ name: string;
25
+ args: Record<string, unknown>;
26
+ }) => Promise<{
27
+ text: string;
28
+ value: Answer;
29
+ }>;
30
+ //# sourceMappingURL=requests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requests.d.ts","sources":["../requests.ts"],"names":[],"mappings":"AAYA,cAA4B,GAAG,2BAAgC;AAE/D,SAAe,KAAK,GAAG,2BAA0B;AAEjD,SAAS,KAAK,WAAW,EAAS,KAAK,IAAI,4BAA2B;AAEtE,8DAA8D,GAC9D,YAAY;EACV,oDAAoD,GACpD,IAAI,MAAM;EACV,MAAM,MAAM;EACZ,OAAO,MAAM;EACb,aAAa,MAAM;EACnB,UAAU,OAAO;EACjB,kCAAkC,GAClC,OAAO,OAAO,MAAM,EAAE,OAAO;;AAG/B,wEAAwE,GACxE,YAAY;EACV,QAAQ,MAAM;EACd,SAAS,OAAO,MAAM,EAAE,MAAM;EAC9B,MAAM,MAAM;;AA+Bd,0EAA0E,GAC1E,OAAO,YAAI,cAAe,GAAG,cAAc,SAAS,KAAG,KAAK,YAGxC;AAkCpB;iBACiB,GACjB,OAAO,YAAI,WACT,MAAM,MACN,QAAQ,OACR,OAAO,UACN,QAAQ,iBASV;AAgDD;oDACoD,GACpD,OAAO,YAAI,UACT,GAAG,KACH;EACE,IAAI,MAAM;EACV,QAAQ;EACR,MAAM,MAAM;EACZ,MAAM,OAAO,MAAM,EAAE,OAAO;MAE7B;EAAU,MAAM,MAAM;EAAE,OAAO;GAuBjC"}
@@ -0,0 +1,25 @@
1
+ import type { Bundle } from "@yaks/graph";
2
+ import { type About, type Read } from "./integrations.js";
3
+ /** A service keeps its integration name across app and space renames. */ export declare let serviceName: (app: string) => string;
4
+ /** Publish or withdraw an app's offer without deleting its connections. */ export declare let publishService: (read: Read, a: About & {
5
+ app: string;
6
+ owner: string;
7
+ description?: string;
8
+ listed: boolean;
9
+ }) => Promise<Bundle[]>;
10
+ /** The authority retained by a service order or delayed operation. */ export type ServiceAuthority = {
11
+ person: string;
12
+ app: string;
13
+ space: string;
14
+ service: string;
15
+ connection: string;
16
+ operation: string;
17
+ };
18
+ /** Check the current person-owned connection and its source-app link: the
19
+ * person's grant of it to the app (./sources.ts), carrying the operation. */ export declare let serviceAuthority: (read: Read, a: ServiceAuthority) => Promise<boolean>;
20
+ /** The person's explicit selection of service operations, or its revocation. */ export declare let grantService: (read: Read, a: {
21
+ person: string;
22
+ connection: string;
23
+ operations: string[];
24
+ }) => Promise<Bundle[]>;
25
+ //# sourceMappingURL=services.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services.d.ts","sources":["../services.ts"],"names":[],"mappings":"AAEA,cAAc,MAAM,2BAAsC;AAK1D,SACE,KAAK,KAAK,EAIV,KAAK,IAAI,4BAEe;AAE1B,uEAAuE,GACvE,OAAO,YAAI,cAAe,KAAK,MAAM,YAAiB;AAEtD,yEAAyE,GACzE,OAAO,YAAI,iBACT,MAAM,MACN,GAAG;EACD,KAAK,MAAM;EACX,OAAO,MAAM;EACb,cAAc,MAAM;EACpB,QAAQ,OAAO;MAEhB,QAAQ,UA0BV;AAED,oEAAoE,GACpE,YAAY;EACV,QAAQ,MAAM;EACd,KAAK,MAAM;EACX,OAAO,MAAM;EACb,SAAS,MAAM;EACf,YAAY,MAAM;EAClB,WAAW,MAAM;;AAGnB;2EAC2E,GAC3E,OAAO,YAAI,mBACT,MAAM,MACN,GAAG,qBACF,QAAQ,OAAO,EAUjB;AAED,8EAA8E,GAC9E,OAAO,YAAI,eACT,MAAM,MACN;EAAK,QAAQ,MAAM;EAAE,YAAY,MAAM;EAAE,YAAY,MAAM;MAC1D,QAAQ,UAuBV"}
@@ -0,0 +1,9 @@
1
+ import { type Integration, type Read } from "./integrations.js";
2
+ /** Which built integrations have sign-in configured, for showing setup links.
3
+ * Read the directory's sealed records together. The sign-in itself reads its
4
+ * credential from the vault when the person follows the link. */ export declare let configuredConnections: (read: Read, integrations: Integration[], brokers?: string[]) => Promise<{
5
+ integrations: Set<string>;
6
+ brokers: Set<string>;
7
+ }>;
8
+ export declare let configuredSignIns: (read: Read, integrations: Integration[]) => Promise<Set<string>>;
9
+ //# sourceMappingURL=sign-in.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sign-in.d.ts","sources":["../sign-in.ts"],"names":[],"mappings":"AAIA,SAAsB,KAAK,WAAW,EAAE,KAAK,IAAI,4BAA2B;AAO5E;;+DAE+D,GAC/D,OAAO,YAAI,wBACT,MAAM,MACN,cAAc,eACd,UAAS,MAAM,OACd;EAAU,cAAc,IAAI,MAAM;EAAG,SAAS,IAAI,MAAM;GA4B1D;AAED,OAAO,YAAI,oBACT,MAAM,MACN,cAAc,kBACb,QAAQ,IAAI,MAAM,GAC2C"}