@managoat/fountain-sdk 1.25.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 (55) hide show
  1. package/CHANGELOG.md +653 -0
  2. package/LICENSE +202 -0
  3. package/README.md +445 -0
  4. package/dist/client.d.ts +190 -0
  5. package/dist/client.js +225 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/config.d.ts +49 -0
  8. package/dist/config.js +87 -0
  9. package/dist/config.js.map +1 -0
  10. package/dist/conversation.d.ts +100 -0
  11. package/dist/conversation.js +189 -0
  12. package/dist/conversation.js.map +1 -0
  13. package/dist/errors.d.ts +102 -0
  14. package/dist/errors.js +197 -0
  15. package/dist/errors.js.map +1 -0
  16. package/dist/generated/openapi.d.ts +16654 -0
  17. package/dist/generated/openapi.js +6 -0
  18. package/dist/generated/openapi.js.map +1 -0
  19. package/dist/http.d.ts +37 -0
  20. package/dist/http.js +129 -0
  21. package/dist/http.js.map +1 -0
  22. package/dist/index.d.ts +14 -0
  23. package/dist/index.js +13 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/node.d.ts +2 -0
  26. package/dist/node.js +21 -0
  27. package/dist/node.js.map +1 -0
  28. package/dist/queue.d.ts +25 -0
  29. package/dist/queue.js +64 -0
  30. package/dist/queue.js.map +1 -0
  31. package/dist/resolve.d.ts +29 -0
  32. package/dist/resolve.js +89 -0
  33. package/dist/resolve.js.map +1 -0
  34. package/dist/resources.d.ts +126 -0
  35. package/dist/resources.js +206 -0
  36. package/dist/resources.js.map +1 -0
  37. package/dist/run.d.ts +81 -0
  38. package/dist/run.js +247 -0
  39. package/dist/run.js.map +1 -0
  40. package/dist/schemas.d.ts +90 -0
  41. package/dist/schemas.js +2 -0
  42. package/dist/schemas.js.map +1 -0
  43. package/dist/sse.d.ts +58 -0
  44. package/dist/sse.js +219 -0
  45. package/dist/sse.js.map +1 -0
  46. package/dist/team.d.ts +90 -0
  47. package/dist/team.js +183 -0
  48. package/dist/team.js.map +1 -0
  49. package/dist/turn.d.ts +46 -0
  50. package/dist/turn.js +205 -0
  51. package/dist/turn.js.map +1 -0
  52. package/dist/types.d.ts +144 -0
  53. package/dist/types.js +2 -0
  54. package/dist/types.js.map +1 -0
  55. package/package.json +61 -0
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This file was auto-generated by openapi-typescript.
3
+ * Do not make direct changes to the file.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=openapi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openapi.js","sourceRoot":"","sources":["../../src/generated/openapi.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
package/dist/http.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ import type { ResolvedConfig } from "./config.ts";
2
+ export type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
3
+ export interface RequestOptions {
4
+ query?: Record<string, string | number | boolean | undefined | null>;
5
+ body?: unknown;
6
+ headers?: Record<string, string>;
7
+ signal?: AbortSignal;
8
+ /** Per-request timeout. Defaults to the client's. `0` disables it. */
9
+ timeoutMs?: number;
10
+ accept?: string;
11
+ }
12
+ /**
13
+ * The product token this client sends. Deliberately not the package name: a
14
+ * scope reads as a second token in a User-Agent (`@managoat/…/0.1.1`), and
15
+ * this string is already what Fountain's request logs are keyed on. The
16
+ * version half is asserted against `package.json` by a test.
17
+ */
18
+ export declare const USER_AGENT = "fountain-sdk-js/1.25.0";
19
+ export declare class HttpClient {
20
+ readonly config: ResolvedConfig;
21
+ private readonly fetchImpl;
22
+ private readonly defaultTimeoutMs;
23
+ constructor(config: ResolvedConfig, opts?: {
24
+ fetch?: FetchLike;
25
+ timeoutMs?: number;
26
+ });
27
+ get baseUrl(): string;
28
+ url(path: string, query?: RequestOptions["query"]): string;
29
+ headers(extra?: Record<string, string>): Record<string, string>;
30
+ /** Send a request and return the parsed body. Non-2xx throws. */
31
+ request<T = unknown>(method: string, path: string, opts?: RequestOptions): Promise<T>;
32
+ /** Send a request and return the `Response` — for SSE and image bytes. */
33
+ raw(method: string, path: string, opts?: RequestOptions): Promise<Response>;
34
+ /** `{data: T}` is the envelope every collection and show action uses. */
35
+ data<T>(method: string, path: string, opts?: RequestOptions): Promise<T>;
36
+ list<T>(path: string, opts?: RequestOptions): Promise<T[]>;
37
+ }
package/dist/http.js ADDED
@@ -0,0 +1,129 @@
1
+ import { AuthError, ConnectionError, FountainError, errorForStatus } from "./errors.js";
2
+ /**
3
+ * The product token this client sends. Deliberately not the package name: a
4
+ * scope reads as a second token in a User-Agent (`@managoat/…/0.1.1`), and
5
+ * this string is already what Fountain's request logs are keyed on. The
6
+ * version half is asserted against `package.json` by a test.
7
+ */
8
+ export const USER_AGENT = "fountain-sdk-js/1.25.0";
9
+ /**
10
+ * The thin layer everything else is built on: one bearer token, JSON in and
11
+ * out, and errors that say which call failed. `Fountain#api` exposes it
12
+ * directly so a caller is never blocked by a verb this SDK did not wrap.
13
+ */
14
+ /** A page in a browser: `document` exists. Workers have none, and no page origin to preflight for. */
15
+ function isBrowser() {
16
+ return typeof globalThis.document !== "undefined";
17
+ }
18
+ export class HttpClient {
19
+ config;
20
+ fetchImpl;
21
+ defaultTimeoutMs;
22
+ constructor(config, opts = {}) {
23
+ this.config = config;
24
+ this.fetchImpl = opts.fetch ?? ((input, init) => globalThis.fetch(input, init));
25
+ this.defaultTimeoutMs = opts.timeoutMs ?? 30_000;
26
+ }
27
+ get baseUrl() {
28
+ return this.config.baseUrl;
29
+ }
30
+ url(path, query) {
31
+ const url = new URL(path.startsWith("http") ? path : this.config.baseUrl + path);
32
+ for (const [key, value] of Object.entries(query ?? {})) {
33
+ if (value === undefined || value === null || value === "")
34
+ continue;
35
+ url.searchParams.set(key, String(value));
36
+ }
37
+ return url.toString();
38
+ }
39
+ headers(extra) {
40
+ if (!this.config.apiKey) {
41
+ throw new AuthError("No Fountain API key. Pass `apiKey`, set FOUNTAIN_API_KEY, or run `fountain auth login`.");
42
+ }
43
+ const headers = {
44
+ Authorization: `Bearer ${this.config.apiKey}`,
45
+ Accept: "application/json",
46
+ ...extra,
47
+ };
48
+ // A browser already has a user agent, and setting one is worse than
49
+ // useless there: Chrome drops it as a forbidden header, Firefox sends it —
50
+ // which makes every call a CORS preflight asking for `user-agent`, and a
51
+ // server whose allow-list does not name it refuses the request outright
52
+ // ("CORS Missing Allow Header"). Only a non-browser runtime gets the token.
53
+ if (!isBrowser())
54
+ headers["User-Agent"] = USER_AGENT;
55
+ // Attribute conversations started from inside a sandbox to their parent.
56
+ if (this.config.parentConversationId) {
57
+ headers["X-Fountain-Parent-Conversation-Id"] = this.config.parentConversationId;
58
+ }
59
+ return headers;
60
+ }
61
+ /** Send a request and return the parsed body. Non-2xx throws. */
62
+ async request(method, path, opts = {}) {
63
+ const response = await this.raw(method, path, opts);
64
+ const text = await response.text();
65
+ const parsed = text ? safeJson(text) : null;
66
+ if (!response.ok) {
67
+ throw errorForStatus(response.status, parsed, method, this.url(path, opts.query), response.headers);
68
+ }
69
+ return parsed;
70
+ }
71
+ /** Send a request and return the `Response` — for SSE and image bytes. */
72
+ async raw(method, path, opts = {}) {
73
+ const url = this.url(path, opts.query);
74
+ const headers = this.headers(opts.headers);
75
+ if (opts.accept)
76
+ headers.Accept = opts.accept;
77
+ let body;
78
+ if (opts.body !== undefined) {
79
+ body = JSON.stringify(opts.body);
80
+ headers["Content-Type"] = "application/json";
81
+ }
82
+ const timeoutMs = opts.timeoutMs ?? this.defaultTimeoutMs;
83
+ const signal = withTimeout(opts.signal, timeoutMs);
84
+ try {
85
+ return await this.fetchImpl(url, { method, headers, body, signal });
86
+ }
87
+ catch (cause) {
88
+ if (opts.signal?.aborted) {
89
+ throw new FountainError(`${method} ${url} was aborted`, { cause });
90
+ }
91
+ throw new ConnectionError(`${method} ${url} failed: ${describe(cause)}. ` +
92
+ "If this is a browser, check the base URL and that API_CORS_ORIGINS on the " +
93
+ "Fountain server includes this origin.", { cause });
94
+ }
95
+ }
96
+ /** `{data: T}` is the envelope every collection and show action uses. */
97
+ async data(method, path, opts = {}) {
98
+ const out = await this.request(method, path, opts);
99
+ return (out?.data ?? null);
100
+ }
101
+ async list(path, opts = {}) {
102
+ return (await this.data("GET", path, opts)) ?? [];
103
+ }
104
+ }
105
+ function safeJson(text) {
106
+ try {
107
+ return JSON.parse(text);
108
+ }
109
+ catch {
110
+ return text;
111
+ }
112
+ }
113
+ function describe(cause) {
114
+ if (cause instanceof Error)
115
+ return cause.message;
116
+ return String(cause);
117
+ }
118
+ /**
119
+ * Compose the caller's signal with a deadline. `AbortSignal.any` keeps the
120
+ * caller's abort reason intact, which is what makes `run({ signal })` report
121
+ * "aborted" rather than "timed out".
122
+ */
123
+ function withTimeout(signal, timeoutMs) {
124
+ if (!timeoutMs || timeoutMs <= 0)
125
+ return signal;
126
+ const timeout = AbortSignal.timeout(timeoutMs);
127
+ return signal ? AbortSignal.any([signal, timeout]) : timeout;
128
+ }
129
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAexF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,CAAC;AAEnD;;;;GAIG;AACH,sGAAsG;AACtG,SAAS,SAAS;IAChB,OAAO,OAAQ,UAAqC,CAAC,QAAQ,KAAK,WAAW,CAAC;AAChF,CAAC;AAED,MAAM,OAAO,UAAU;IACZ,MAAM,CAAiB;IACf,SAAS,CAAY;IACrB,gBAAgB,CAAS;IAE1C,YAAY,MAAsB,EAAE,OAAkD,EAAE;QACtF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAA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,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,KAAK,YAAY,KAAK;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC;IACjD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED;;;;GAIG;AACH,SAAS,WAAW,CAAC,MAA+B,EAAE,SAAiB;IACrE,IAAI,CAAC,SAAS,IAAI,SAAS,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC;IAChD,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC/C,OAAO,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,14 @@
1
+ export { Fountain, type FountainOptions, type RunConfig } from "./client.ts";
2
+ export { Run, type RunOptions } from "./run.ts";
3
+ export { Conversation, type SendOptions } from "./conversation.ts";
4
+ export { HttpClient, type FetchLike, type RequestOptions } from "./http.ts";
5
+ export { Agents, ConnectionProviders, Connections, Environments, Vaults } from "./resources.ts";
6
+ export { Team, TeamSchedules, type MessageOptions } from "./team.ts";
7
+ export { resolveConfig, conversationUrl, DEFAULT_BASE_URL, DEFAULT_APP_URL, type ConfigOptions, type ResolvedConfig, } from "./config.ts";
8
+ export { streamEvents, streamPath, parseSse, type StreamOptions, type SseMessage } from "./sse.ts";
9
+ export { TurnFollower } from "./turn.ts";
10
+ export { FountainError, AuthError, SubscriptionRequiredError, NotFoundError, ValidationError, RateLimitError, ConversationBusyError, NotReadyError, QuotaExceededError, ConnectionError, TimeoutError, ResolutionError, type FountainErrorCode, } from "./errors.ts";
11
+ export type * from "./schemas.ts";
12
+ export type { Agent, AgentInput, Block, ConversationRecord, ConversationStatus, Environment, EnvironmentInput, LogEvent, NamedResource, PermissionOption, PermissionRequest, Stream, TeamEvent, Repository, Runtime, RunEvent, RunResult, SandboxDiff, SandboxEntry, SandboxFile, SandboxListing, SandboxProvider, SandboxRecord, Secret, SkillInput, Turn, TurnState, Vault, VaultInput, VaultSecretMetadataPatch, } from "./types.ts";
13
+ import { Fountain } from "./client.ts";
14
+ export default Fountain;
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ export { Fountain } from "./client.js";
2
+ export { Run } from "./run.js";
3
+ export { Conversation } from "./conversation.js";
4
+ export { HttpClient } from "./http.js";
5
+ export { Agents, ConnectionProviders, Connections, Environments, Vaults } from "./resources.js";
6
+ export { Team, TeamSchedules } from "./team.js";
7
+ export { resolveConfig, conversationUrl, DEFAULT_BASE_URL, DEFAULT_APP_URL, } from "./config.js";
8
+ export { streamEvents, streamPath, parseSse } from "./sse.js";
9
+ export { TurnFollower } from "./turn.js";
10
+ export { FountainError, AuthError, SubscriptionRequiredError, NotFoundError, ValidationError, RateLimitError, ConversationBusyError, NotReadyError, QuotaExceededError, ConnectionError, TimeoutError, ResolutionError, } from "./errors.js";
11
+ import { Fountain } from "./client.js";
12
+ export default Fountain;
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAwC,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,GAAG,EAAmB,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,YAAY,EAAoB,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAuC,MAAM,WAAW,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,EAAE,IAAI,EAAE,aAAa,EAAuB,MAAM,WAAW,CAAC;AACrE,OAAO,EACL,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,eAAe,GAGhB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAuC,MAAM,UAAU,CAAC;AACnG,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EACL,aAAa,EACb,SAAS,EACT,yBAAyB,EACzB,aAAa,EACb,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,eAAe,GAEhB,MAAM,aAAa,CAAC;AAmCrB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,eAAe,QAAQ,CAAC"}
package/dist/node.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./index.ts";
2
+ export { default } from "./index.ts";
package/dist/node.js ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The Node entry point.
3
+ *
4
+ * Everything the SDK does works in a browser, and `src/index.ts` is what a
5
+ * bundler gets. The one thing that cannot work there is reading
6
+ * `~/.fountain/credentials`, so that lives here: importing `@managoat/fountain-sdk`
7
+ * under Node resolves to this module, which installs the reader and then
8
+ * re-exports the same API.
9
+ */
10
+ import { homedir } from "node:os";
11
+ import { join } from "node:path";
12
+ import { readFileSync } from "node:fs";
13
+ import { parseCredentials, setCredentialsReader } from "./config.js";
14
+ setCredentialsReader((profile) => {
15
+ const override = (process.env.FOUNTAIN_CREDENTIALS_FILE ?? "").trim();
16
+ const path = override || join(homedir(), ".fountain", "credentials");
17
+ return parseCredentials(readFileSync(path, "utf8"), profile);
18
+ });
19
+ export * from "./index.js";
20
+ export { default } from "./index.js";
21
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAErE,oBAAoB,CAAC,CAAC,OAAO,EAAE,EAAE;IAC/B,MAAM,QAAQ,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACtE,MAAM,IAAI,GAAG,QAAQ,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;IACrE,OAAO,gBAAgB,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;AAC/D,CAAC,CAAC,CAAC;AAEH,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * A push source that many consumers can read as an async iterable.
3
+ *
4
+ * Everything a run produces goes through one of these. Late subscribers get
5
+ * the whole history first, which is what lets `await run` and
6
+ * `for await (run)` be the same run: the promise path is just another
7
+ * consumer, and it does not race the streaming one for events.
8
+ */
9
+ export declare class Broadcast<T> {
10
+ private readonly buffer;
11
+ private readonly waiters;
12
+ private closed;
13
+ private failure;
14
+ push(value: T): void;
15
+ close(error?: unknown): void;
16
+ private wake;
17
+ private wait;
18
+ [Symbol.asyncIterator](): AsyncGenerator<T>;
19
+ }
20
+ /** A promise whose settlement is triggered from elsewhere. */
21
+ export declare function deferred<T>(): {
22
+ promise: Promise<T>;
23
+ resolve: (value: T) => void;
24
+ reject: (error: unknown) => void;
25
+ };
package/dist/queue.js ADDED
@@ -0,0 +1,64 @@
1
+ /**
2
+ * A push source that many consumers can read as an async iterable.
3
+ *
4
+ * Everything a run produces goes through one of these. Late subscribers get
5
+ * the whole history first, which is what lets `await run` and
6
+ * `for await (run)` be the same run: the promise path is just another
7
+ * consumer, and it does not race the streaming one for events.
8
+ */
9
+ export class Broadcast {
10
+ buffer = [];
11
+ waiters = new Set();
12
+ closed = false;
13
+ failure = null;
14
+ push(value) {
15
+ if (this.closed)
16
+ return;
17
+ this.buffer.push(value);
18
+ this.wake();
19
+ }
20
+ close(error) {
21
+ if (this.closed)
22
+ return;
23
+ this.closed = true;
24
+ if (error !== undefined)
25
+ this.failure = error;
26
+ this.wake();
27
+ }
28
+ wake() {
29
+ for (const waiter of [...this.waiters])
30
+ waiter();
31
+ this.waiters.clear();
32
+ }
33
+ wait() {
34
+ return new Promise((resolve) => this.waiters.add(resolve));
35
+ }
36
+ async *[Symbol.asyncIterator]() {
37
+ let index = 0;
38
+ while (true) {
39
+ while (index < this.buffer.length) {
40
+ yield this.buffer[index++];
41
+ }
42
+ if (this.closed) {
43
+ if (this.failure !== null)
44
+ throw this.failure;
45
+ return;
46
+ }
47
+ await this.wait();
48
+ }
49
+ }
50
+ }
51
+ /** A promise whose settlement is triggered from elsewhere. */
52
+ export function deferred() {
53
+ let resolve;
54
+ let reject;
55
+ const promise = new Promise((res, rej) => {
56
+ resolve = res;
57
+ reject = rej;
58
+ });
59
+ // Nobody may have attached a handler yet; the Run surfaces this failure on
60
+ // whichever path the caller actually awaits.
61
+ promise.catch(() => { });
62
+ return { promise, resolve, reject };
63
+ }
64
+ //# sourceMappingURL=queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.js","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,OAAO,SAAS;IACH,MAAM,GAAQ,EAAE,CAAC;IACjB,OAAO,GAAG,IAAI,GAAG,EAAc,CAAC;IACzC,MAAM,GAAG,KAAK,CAAC;IACf,OAAO,GAAY,IAAI,CAAC;IAEhC,IAAI,CAAC,KAAQ;QACX,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO;QACxB,IAAI,CAAC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AAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC1C,OAAO,GAAG,GAAG,CAAC;QACd,MAAM,GAAG,GAAG,CAAC;IACf,CAAC,CAAC,CAAC;IACH,2EAA2E;IAC3E,6CAA6C;IAC7C,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACxB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACtC,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { HttpClient } from "./http.ts";
2
+ export interface Named {
3
+ id: string;
4
+ name?: string;
5
+ [key: string]: unknown;
6
+ }
7
+ /**
8
+ * Turns `{ agent: "reposage" }` into an id.
9
+ *
10
+ * Names, not ids, are the point: a script that reads `vault: "github-bot"` says
11
+ * what it does, and a UUID in a README kills the demo. Resolution is exact
12
+ * (case-insensitive) first, then a unique prefix, and a miss lists what the
13
+ * account actually has — the error a caller can act on without opening the
14
+ * console.
15
+ */
16
+ export declare class Resolver {
17
+ private readonly cache;
18
+ private readonly http;
19
+ constructor(http: HttpClient);
20
+ /** Drop every memoized listing. */
21
+ clear(): void;
22
+ /** Drop one memoized listing — after a create, rename or delete. */
23
+ forget(path: string): void;
24
+ list(path: string): Promise<Named[]>;
25
+ resolve(path: string, what: string, nameOrId: string): Promise<Named>;
26
+ resolveId(path: string, what: string, nameOrId?: string | null): Promise<string | undefined>;
27
+ /** The cached listing if we already have one; never fetches. */
28
+ private peek;
29
+ }
@@ -0,0 +1,89 @@
1
+ import { ResolutionError } from "./errors.js";
2
+ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
3
+ /**
4
+ * Turns `{ agent: "reposage" }` into an id.
5
+ *
6
+ * Names, not ids, are the point: a script that reads `vault: "github-bot"` says
7
+ * what it does, and a UUID in a README kills the demo. Resolution is exact
8
+ * (case-insensitive) first, then a unique prefix, and a miss lists what the
9
+ * account actually has — the error a caller can act on without opening the
10
+ * console.
11
+ */
12
+ export class Resolver {
13
+ cache = new Map();
14
+ http;
15
+ constructor(http) {
16
+ this.http = http;
17
+ }
18
+ /** Drop every memoized listing. */
19
+ clear() {
20
+ this.cache.clear();
21
+ }
22
+ /** Drop one memoized listing — after a create, rename or delete. */
23
+ forget(path) {
24
+ this.cache.delete(path);
25
+ }
26
+ list(path) {
27
+ let pending = this.cache.get(path);
28
+ if (!pending) {
29
+ pending = this.http.list(path).catch((error) => {
30
+ // A failed listing must not be remembered as an empty account.
31
+ this.cache.delete(path);
32
+ throw error;
33
+ });
34
+ this.cache.set(path, pending);
35
+ }
36
+ return pending;
37
+ }
38
+ async resolve(path, what, nameOrId) {
39
+ const wanted = (nameOrId ?? "").trim();
40
+ if (!wanted)
41
+ throw new ResolutionError(`${what} is required (a name or id)`);
42
+ // An id needs no listing — and an account with hundreds of agents should
43
+ // not pay for one on every call.
44
+ if (UUID.test(wanted)) {
45
+ const known = (await this.peek(path))?.find((item) => item.id === wanted);
46
+ return known ?? { id: wanted };
47
+ }
48
+ const items = await this.list(path);
49
+ const byId = items.find((item) => item.id === wanted);
50
+ if (byId)
51
+ return byId;
52
+ const lower = wanted.toLowerCase();
53
+ const exact = items.filter((item) => (item.name ?? "").toLowerCase() === lower);
54
+ if (exact.length === 1)
55
+ return exact[0];
56
+ if (exact.length > 1) {
57
+ throw new ResolutionError(`More than one ${what} is named ${JSON.stringify(wanted)}. Use the id: ` +
58
+ exact.map((item) => item.id).join(", "));
59
+ }
60
+ const prefix = items.filter((item) => (item.name ?? "").toLowerCase().startsWith(lower));
61
+ if (prefix.length === 1)
62
+ return prefix[0];
63
+ if (prefix.length > 1) {
64
+ throw new ResolutionError(`${JSON.stringify(wanted)} matches more than one ${what}: ` +
65
+ prefix.map((item) => item.name ?? item.id).join(", "));
66
+ }
67
+ throw new ResolutionError(`No ${what} named ${JSON.stringify(wanted)}. On this account: ${describe(items)}`);
68
+ }
69
+ async resolveId(path, what, nameOrId) {
70
+ if (!nameOrId)
71
+ return undefined;
72
+ return (await this.resolve(path, what, nameOrId)).id;
73
+ }
74
+ /** The cached listing if we already have one; never fetches. */
75
+ async peek(path) {
76
+ const pending = this.cache.get(path);
77
+ if (!pending)
78
+ return null;
79
+ return pending.catch(() => null);
80
+ }
81
+ }
82
+ function describe(items) {
83
+ const names = items
84
+ .map((item) => item.name ?? item.id)
85
+ .filter(Boolean)
86
+ .sort();
87
+ return names.length ? names.join(", ") : "(none)";
88
+ }
89
+ //# sourceMappingURL=resolve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,IAAI,GAAG,iEAAiE,CAAC;AAQ/E;;;;;;;;GAQG;AACH,MAAM,OAAO,QAAQ;IACF,KAAK,GAAG,IAAI,GAAG,EAA4B,CAAC;IAC5C,IAAI,CAAa;IAElC,YAAY,IAAgB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,mCAAmC;IACnC,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED,oEAAoE;IACpE,MAAM,CAAC,IAAY;QACjB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,CAAC,IAAY;QACf,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAQ,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBACpD,+DAA+D;gBAC/D,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBACxB,MAAM,KAAK,CAAC;YACd,CA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AAC;IAED,gEAAgE;IACxD,KAAK,CAAC,IAAI,CAAC,IAAY;QAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC;QAC1B,OAAO,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;CACF;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,MAAM,KAAK,GAAG,KAAK;SAChB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC;SACnC,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,EAAE,CAAC;IACV,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AACpD,CAAC"}
@@ -0,0 +1,126 @@
1
+ import type { HttpClient } from "./http.ts";
2
+ import type { Resolver } from "./resolve.ts";
3
+ import type { Agent, AgentInput, AgentPatch, Connection, ConnectionProvider, ConnectionProviderInput, ConnectionProviderPatch, Environment, EnvironmentInput, EnvironmentPatch, Secret, Vault, VaultInput, VaultPatch, VaultSecret, VaultSecretMetadataPatch } from "./types.ts";
4
+ /**
5
+ * Payloads here use the API's own key names (`environment_id`, `mcp_servers`,
6
+ * `allowed_vault_ids`) rather than camelCase. That is a choice, not an
7
+ * oversight: an agent definition is the same object in the REST API, in a
8
+ * `fountain.yml` manifest and here, so one definition reads identically in all
9
+ * three and the API reference doubles as the SDK reference. Options that
10
+ * control the SDK's own behaviour — `timeoutMs`, `signal` — are camelCase,
11
+ * because those are not data.
12
+ */
13
+ /**
14
+ * List, read, define, change and delete one kind of thing.
15
+ *
16
+ * `Patch` is its own parameter rather than `Partial<Input>`: the API's update
17
+ * schemas are not simply every create field made optional, and the generated
18
+ * ones say so exactly.
19
+ */
20
+ declare class Collection<T extends {
21
+ id: string;
22
+ }, Input, Patch> {
23
+ protected readonly http: HttpClient;
24
+ protected readonly resolver: Resolver;
25
+ protected readonly path: string;
26
+ protected readonly what: string;
27
+ constructor(http: HttpClient, resolver: Resolver, path: string, what: string);
28
+ /** Everything on the account. */
29
+ list(search?: string): Promise<T[]>;
30
+ /** One of them, by name or id. */
31
+ get(nameOrId: string): Promise<T>;
32
+ /** Define a new one. */
33
+ create(input: Input): Promise<T>;
34
+ /** Change one. Only the fields you pass are touched. */
35
+ update(nameOrId: string, patch: Patch): Promise<T>;
36
+ /** Delete one. */
37
+ delete(nameOrId: string): Promise<void>;
38
+ }
39
+ /**
40
+ * Secrets on an environment or a vault.
41
+ *
42
+ * Values are write-only: `list` returns keys, never what they are worth. That
43
+ * is the whole point — the SDK can put a credential into a sandbox and can
44
+ * never read it back out.
45
+ */
46
+ declare class Secrets {
47
+ protected readonly http: HttpClient;
48
+ private readonly resolver;
49
+ private readonly parentPath;
50
+ private readonly what;
51
+ constructor(http: HttpClient, resolver: Resolver, parentPath: string, what: string);
52
+ /** The keys stored here. Never the values. */
53
+ list(parent: string): Promise<Secret[]>;
54
+ /** Store a secret, or replace one with the same key. */
55
+ set(parent: string, key: string, value: string): Promise<Secret>;
56
+ /** Store several at once. */
57
+ setAll(parent: string, secrets: Record<string, string>): Promise<Secret[]>;
58
+ /** Remove one, by key. */
59
+ delete(parent: string, key: string): Promise<void>;
60
+ protected parentId(nameOrId: string): Promise<string>;
61
+ }
62
+ /** Vault metadata can change without reading or replacing its secret value. */
63
+ declare class VaultSecrets extends Secrets {
64
+ update(parent: string, key: string, patch: VaultSecretMetadataPatch): Promise<VaultSecret>;
65
+ }
66
+ /** The agents on this account. */
67
+ export declare class Agents extends Collection<Agent, AgentInput, AgentPatch> {
68
+ constructor(http: HttpClient, resolver: Resolver);
69
+ }
70
+ /** The environments on this account, and their secrets. */
71
+ export declare class Environments extends Collection<Environment, EnvironmentInput, EnvironmentPatch> {
72
+ readonly secrets: Secrets;
73
+ constructor(http: HttpClient, resolver: Resolver);
74
+ }
75
+ /**
76
+ * The provider accounts this tenant has signed in to, whose credentials
77
+ * Fountain holds (#1178). Connecting one is a browser round trip — send the
78
+ * account owner to `connect_url` from `providers()` — so there is no `create`
79
+ * here. An agent uses one by naming it in `mcp_servers`:
80
+ * `{ gmail: { connection: "<id>" } }`. Only for accounts the egress broker is
81
+ * on for; elsewhere every call is a `NotFoundError` (`connections_not_enabled`).
82
+ */
83
+ export declare class Connections {
84
+ private readonly http;
85
+ /** Where connections get their tokens: Google, plus the tenant's own providers (#1186). */
86
+ readonly providers: ConnectionProviders;
87
+ constructor(http: HttpClient);
88
+ /** Every connection on the account, active or revoked. Never a token. */
89
+ list(): Promise<Connection[]>;
90
+ /** One connection by id. Unenveloped, as the server answers `show`. */
91
+ get(id: string): Promise<Connection>;
92
+ /** Revoke at the provider and delete. Agents that name it get `connection revoked`. */
93
+ delete(id: string): Promise<void>;
94
+ }
95
+ /**
96
+ * Connection providers (#1186): the platform provider (Google, id `google`),
97
+ * the tenant's own OAuth apps (`kind: "oauth2"`) and the remote MCP servers
98
+ * whose authorization Fountain discovered (`kind: "mcp"`). The client secret
99
+ * is write-only. Only for accounts the egress broker is on for.
100
+ */
101
+ export declare class ConnectionProviders {
102
+ private readonly http;
103
+ constructor(http: HttpClient);
104
+ /** Google first, then the tenant's own. */
105
+ list(): Promise<ConnectionProvider[]>;
106
+ /** One provider; `"google"` is the platform provider. */
107
+ get(id: string): Promise<ConnectionProvider>;
108
+ /**
109
+ * Define a provider. `kind: "oauth2"` takes the tenant's app registration;
110
+ * `kind: "mcp"` takes `mcp_url` and Fountain discovers the authorization
111
+ * server and registers a client where it can.
112
+ */
113
+ create(input: ConnectionProviderInput): Promise<ConnectionProvider>;
114
+ /** Edit a tenant provider. A blank `client_secret` keeps the stored one. */
115
+ update(id: string, patch: ConnectionProviderPatch): Promise<ConnectionProvider>;
116
+ /** Delete a tenant provider and every connection on it. */
117
+ delete(id: string): Promise<void>;
118
+ /** Run MCP discovery again on an `mcp` provider. */
119
+ discover(id: string): Promise<ConnectionProvider>;
120
+ }
121
+ /** The vaults on this account, and their secrets. */
122
+ export declare class Vaults extends Collection<Vault, VaultInput, VaultPatch> {
123
+ readonly secrets: VaultSecrets;
124
+ constructor(http: HttpClient, resolver: Resolver);
125
+ }
126
+ export {};