@aigentyc/mcp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/AGENTS.md +197 -0
  2. package/LICENSE +21 -0
  3. package/README.md +112 -0
  4. package/context7.json +3 -0
  5. package/dist/cli.d.ts +3 -0
  6. package/dist/cli.d.ts.map +1 -0
  7. package/dist/cli.js +289 -0
  8. package/dist/cli.js.map +1 -0
  9. package/dist/client.d.ts +10 -0
  10. package/dist/client.d.ts.map +1 -0
  11. package/dist/client.js +70 -0
  12. package/dist/client.js.map +1 -0
  13. package/dist/config.d.ts +31 -0
  14. package/dist/config.d.ts.map +1 -0
  15. package/dist/config.js +79 -0
  16. package/dist/config.js.map +1 -0
  17. package/dist/errors.d.ts +10 -0
  18. package/dist/errors.d.ts.map +1 -0
  19. package/dist/errors.js +28 -0
  20. package/dist/errors.js.map +1 -0
  21. package/dist/fs-safety.d.ts +29 -0
  22. package/dist/fs-safety.d.ts.map +1 -0
  23. package/dist/fs-safety.js +107 -0
  24. package/dist/fs-safety.js.map +1 -0
  25. package/dist/index.d.ts +5 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +4 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/llms-full.txt +659 -0
  30. package/dist/server.d.ts +2 -0
  31. package/dist/server.d.ts.map +1 -0
  32. package/dist/server.js +57 -0
  33. package/dist/server.js.map +1 -0
  34. package/dist/tools/analytics.d.ts +4 -0
  35. package/dist/tools/analytics.d.ts.map +1 -0
  36. package/dist/tools/analytics.js +82 -0
  37. package/dist/tools/analytics.js.map +1 -0
  38. package/dist/tools/backups.d.ts +4 -0
  39. package/dist/tools/backups.d.ts.map +1 -0
  40. package/dist/tools/backups.js +99 -0
  41. package/dist/tools/backups.js.map +1 -0
  42. package/dist/tools/config.d.ts +4 -0
  43. package/dist/tools/config.d.ts.map +1 -0
  44. package/dist/tools/config.js +84 -0
  45. package/dist/tools/config.js.map +1 -0
  46. package/dist/tools/corrections.d.ts +4 -0
  47. package/dist/tools/corrections.d.ts.map +1 -0
  48. package/dist/tools/corrections.js +69 -0
  49. package/dist/tools/corrections.js.map +1 -0
  50. package/dist/tools/data_stores.d.ts +4 -0
  51. package/dist/tools/data_stores.d.ts.map +1 -0
  52. package/dist/tools/data_stores.js +244 -0
  53. package/dist/tools/data_stores.js.map +1 -0
  54. package/dist/tools/documents.d.ts +4 -0
  55. package/dist/tools/documents.d.ts.map +1 -0
  56. package/dist/tools/documents.js +162 -0
  57. package/dist/tools/documents.js.map +1 -0
  58. package/dist/tools/extract.d.ts +4 -0
  59. package/dist/tools/extract.d.ts.map +1 -0
  60. package/dist/tools/extract.js +61 -0
  61. package/dist/tools/extract.js.map +1 -0
  62. package/dist/tools/files.d.ts +4 -0
  63. package/dist/tools/files.d.ts.map +1 -0
  64. package/dist/tools/files.js +198 -0
  65. package/dist/tools/files.js.map +1 -0
  66. package/dist/tools/golden_answers.d.ts +4 -0
  67. package/dist/tools/golden_answers.d.ts.map +1 -0
  68. package/dist/tools/golden_answers.js +117 -0
  69. package/dist/tools/golden_answers.js.map +1 -0
  70. package/dist/tools/helpers.d.ts +5 -0
  71. package/dist/tools/helpers.d.ts.map +1 -0
  72. package/dist/tools/helpers.js +10 -0
  73. package/dist/tools/helpers.js.map +1 -0
  74. package/dist/tools/index.d.ts +4 -0
  75. package/dist/tools/index.d.ts.map +1 -0
  76. package/dist/tools/index.js +35 -0
  77. package/dist/tools/index.js.map +1 -0
  78. package/dist/tools/jobs.d.ts +4 -0
  79. package/dist/tools/jobs.d.ts.map +1 -0
  80. package/dist/tools/jobs.js +78 -0
  81. package/dist/tools/jobs.js.map +1 -0
  82. package/dist/tools/link_sources.d.ts +4 -0
  83. package/dist/tools/link_sources.d.ts.map +1 -0
  84. package/dist/tools/link_sources.js +155 -0
  85. package/dist/tools/link_sources.js.map +1 -0
  86. package/dist/tools/misc.d.ts +8 -0
  87. package/dist/tools/misc.d.ts.map +1 -0
  88. package/dist/tools/misc.js +73 -0
  89. package/dist/tools/misc.js.map +1 -0
  90. package/dist/tools/page_questions.d.ts +4 -0
  91. package/dist/tools/page_questions.d.ts.map +1 -0
  92. package/dist/tools/page_questions.js +77 -0
  93. package/dist/tools/page_questions.js.map +1 -0
  94. package/dist/tools/personas.d.ts +4 -0
  95. package/dist/tools/personas.d.ts.map +1 -0
  96. package/dist/tools/personas.js +78 -0
  97. package/dist/tools/personas.js.map +1 -0
  98. package/dist/tools/tools_crud.d.ts +4 -0
  99. package/dist/tools/tools_crud.d.ts.map +1 -0
  100. package/dist/tools/tools_crud.js +207 -0
  101. package/dist/tools/tools_crud.js.map +1 -0
  102. package/dist/tools/types.d.ts +25 -0
  103. package/dist/tools/types.d.ts.map +1 -0
  104. package/dist/tools/types.js +15 -0
  105. package/dist/tools/types.js.map +1 -0
  106. package/llms.txt +150 -0
  107. package/package.json +53 -0
package/dist/client.js ADDED
@@ -0,0 +1,70 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { AigentycError, httpStatusToCode } from "./errors.js";
3
+ export function createClient(profile) {
4
+ const baseUrl = profile.baseUrl.replace(/\/$/, "");
5
+ async function request(method, path, opts = {}) {
6
+ const url = new URL(baseUrl + path);
7
+ if (opts.query) {
8
+ for (const [k, v] of Object.entries(opts.query)) {
9
+ if (v === undefined || v === null)
10
+ continue;
11
+ url.searchParams.set(k, String(v));
12
+ }
13
+ }
14
+ if (!url.protocol.startsWith("https") &&
15
+ !isLocalHost(url.hostname) &&
16
+ !profile.allowInsecure) {
17
+ throw new AigentycError("NETWORK", `Refusing plaintext HTTP to non-loopback host: ${url.hostname}. Use https:// or login with --allow-insecure for dev.`);
18
+ }
19
+ const requestId = randomUUID();
20
+ const headers = {
21
+ Authorization: `Bearer ${profile.apiKey}`,
22
+ Accept: "application/json",
23
+ "X-Request-Id": requestId,
24
+ "User-Agent": "aigentyc-mcp/0.1.0",
25
+ };
26
+ let body;
27
+ if (opts.body !== undefined) {
28
+ headers["Content-Type"] = "application/json";
29
+ body = JSON.stringify(opts.body);
30
+ }
31
+ let res;
32
+ try {
33
+ res = await fetch(url, { method, headers, body });
34
+ }
35
+ catch (err) {
36
+ throw new AigentycError("NETWORK", `Request to ${url.toString()} failed: ${err.message}`, undefined, requestId);
37
+ }
38
+ const text = await res.text();
39
+ let payload = undefined;
40
+ if (text) {
41
+ try {
42
+ payload = JSON.parse(text);
43
+ }
44
+ catch {
45
+ payload = text;
46
+ }
47
+ }
48
+ if (!res.ok) {
49
+ const msg = (payload && typeof payload === "object" && "error" in payload
50
+ ? String(payload.error)
51
+ : undefined) || `HTTP ${res.status}`;
52
+ throw new AigentycError(httpStatusToCode(res.status), msg, res.status, requestId, payload);
53
+ }
54
+ return payload;
55
+ }
56
+ return {
57
+ profile,
58
+ get: (path, query) => request("GET", path, { query }),
59
+ post: (path, body) => request("POST", path, { body }),
60
+ patch: (path, body) => request("PATCH", path, { body }),
61
+ delete: (path, body) => request("DELETE", path, { body }),
62
+ };
63
+ }
64
+ function isLocalHost(hostname) {
65
+ return (hostname === "localhost" ||
66
+ hostname === "127.0.0.1" ||
67
+ hostname === "::1" ||
68
+ hostname.endsWith(".localhost"));
69
+ }
70
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAU9D,MAAM,UAAU,YAAY,CAAC,OAAsB;IACjD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAEnD,KAAK,UAAU,OAAO,CACpB,MAAc,EACd,IAAY,EACZ,OAA4D,EAAE;QAE9D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;Q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E,CAAC;QACvD,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC;KAC1D,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,QAAgB;IACnC,OAAO,CACL,QAAQ,KAAK,WAAW;QACxB,QAAQ,KAAK,WAAW;QACxB,QAAQ,KAAK,KAAK;QAClB,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAChC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,31 @@
1
+ export interface ProfileConfig {
2
+ baseUrl: string;
3
+ projectId: string;
4
+ apiKey: string;
5
+ /**
6
+ * When true, the client will allow plaintext HTTP to non-loopback hosts.
7
+ * Dev-only — never enable in production.
8
+ */
9
+ allowInsecure?: boolean;
10
+ }
11
+ export interface AigentycConfig {
12
+ activeProfile: string;
13
+ profiles: Record<string, ProfileConfig>;
14
+ }
15
+ declare const DEFAULT_BASE_URL = "https://app.aigentyc.com";
16
+ /**
17
+ * Resolve config paths at call time so `AIGENTYC_CONFIG` env overrides take
18
+ * effect (used by tests and by users who want a non-standard location).
19
+ */
20
+ export declare function configPath(): string;
21
+ export declare function loadConfig(): Promise<AigentycConfig | null>;
22
+ export declare function requireConfig(): Promise<AigentycConfig>;
23
+ export declare function getActiveProfile(cfg: AigentycConfig): ProfileConfig;
24
+ /**
25
+ * Persist config with 0600 perms. Refuses to overwrite wider perms without fix.
26
+ */
27
+ export declare function saveConfig(cfg: AigentycConfig): Promise<void>;
28
+ export declare function assertSafePerms(): Promise<void>;
29
+ export declare function upsertProfile(cfg: AigentycConfig | null, name: string, profile: ProfileConfig, makeActive: boolean): AigentycConfig;
30
+ export { DEFAULT_BASE_URL };
31
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CACzC;AAED,QAAA,MAAM,gBAAgB,6BAA6B,CAAC;AAEpD;;;GAGG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAInC;AAOD,wBAAsB,UAAU,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAYjE;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,cAAc,CAAC,CAQ7D;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,cAAc,GAAG,aAAa,CAUnE;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAQnE;AAED,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAUrD;AAED,wBAAgB,aAAa,CAC3B,GAAG,EAAE,cAAc,GAAG,IAAI,EAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,OAAO,GAClB,cAAc,CAOhB;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
package/dist/config.js ADDED
@@ -0,0 +1,79 @@
1
+ import { homedir } from "node:os";
2
+ import { join } from "node:path";
3
+ import { readFile, writeFile, stat, mkdir, chmod } from "node:fs/promises";
4
+ const DEFAULT_BASE_URL = "https://app.aigentyc.com";
5
+ /**
6
+ * Resolve config paths at call time so `AIGENTYC_CONFIG` env overrides take
7
+ * effect (used by tests and by users who want a non-standard location).
8
+ */
9
+ export function configPath() {
10
+ const override = process.env.AIGENTYC_CONFIG;
11
+ if (override && override.trim().length > 0)
12
+ return override;
13
+ return join(homedir(), ".aigentyc", "config.json");
14
+ }
15
+ function configDir() {
16
+ const p = configPath();
17
+ return p.slice(0, p.lastIndexOf("/"));
18
+ }
19
+ export async function loadConfig() {
20
+ try {
21
+ const raw = await readFile(configPath(), "utf8");
22
+ const parsed = JSON.parse(raw);
23
+ if (!parsed || typeof parsed !== "object" || !parsed.profiles) {
24
+ return null;
25
+ }
26
+ return parsed;
27
+ }
28
+ catch (err) {
29
+ if (err.code === "ENOENT")
30
+ return null;
31
+ throw err;
32
+ }
33
+ }
34
+ export async function requireConfig() {
35
+ const cfg = await loadConfig();
36
+ if (!cfg) {
37
+ throw new Error(`No aiGentyc config found at ${configPath()}. Run: aigentyc-mcp login --api-key <key> --project-id <id>`);
38
+ }
39
+ return cfg;
40
+ }
41
+ export function getActiveProfile(cfg) {
42
+ const profile = cfg.profiles[cfg.activeProfile];
43
+ if (!profile) {
44
+ throw new Error(`Active profile '${cfg.activeProfile}' not found. Available: ${Object.keys(cfg.profiles).join(", ") || "(none)"}`);
45
+ }
46
+ return profile;
47
+ }
48
+ /**
49
+ * Persist config with 0600 perms. Refuses to overwrite wider perms without fix.
50
+ */
51
+ export async function saveConfig(cfg) {
52
+ const file = configPath();
53
+ await mkdir(configDir(), { recursive: true, mode: 0o700 });
54
+ await writeFile(file, JSON.stringify(cfg, null, 2), {
55
+ encoding: "utf8",
56
+ mode: 0o600,
57
+ });
58
+ await chmod(file, 0o600);
59
+ }
60
+ export async function assertSafePerms() {
61
+ const st = await stat(configPath());
62
+ // Only the owner should have any bits set.
63
+ const mode = st.mode & 0o777;
64
+ if ((mode & 0o077) !== 0) {
65
+ const file = configPath();
66
+ throw new Error(`Refusing to use ${file}: permissions are ${mode.toString(8)} (must be 600). Fix with: chmod 600 ${file}`);
67
+ }
68
+ }
69
+ export function upsertProfile(cfg, name, profile, makeActive) {
70
+ const next = cfg
71
+ ? { activeProfile: cfg.activeProfile, profiles: { ...cfg.profiles } }
72
+ : { activeProfile: name, profiles: {} };
73
+ next.profiles[name] = profile;
74
+ if (makeActive || !next.activeProfile)
75
+ next.activeProfile = name;
76
+ return next;
77
+ }
78
+ export { DEFAULT_BASE_URL };
79
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAkB3E,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAEpD;;;GAGG;AACH,MAAM,UAAU,UAAU;IACxB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAC7C,IAAI,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC5D,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;AACrD,CAAC;AAED,SAAS,SAAS;IAChB,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC;IACvB,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,UAAU,EAAE,EAAE,MAAM,CAAC,CAAC;QACjD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAmB,CAAC;QACjD,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC9D,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,MA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M,CAAC,KAAK,UAAU,eAAe;IACnC,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IACpC,2CAA2C;IAC3C,MAAM,IAAI,GAAG,EAAE,CAAC,IAAI,GAAG,KAAK,CAAC;IAC7B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,UAAU,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,mBAAmB,IAAI,qBAAqB,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,uCAAuC,IAAI,EAAE,CAC1G,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,GAA0B,EAC1B,IAAY,EACZ,OAAsB,EACtB,UAAmB;IAEnB,MAAM,IAAI,GAAmB,GAAG;QAC9B,CAAC,CAAC,EAAE,aAAa,EAAE,GAAG,CAAC,aAAa,EAAE,QAAQ,EAAE,EAAE,GAAG,GAAG,CAAC,QAAQ,EAAE,EAAE;QACrE,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC1C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IAC9B,IAAI,UAAU,IAAI,CAAC,IAAI,CAAC,aAAa;QAAE,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IACjE,OAAO,IAAI,CAAC;AACd,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,10 @@
1
+ export type McpErrorCode = "UNAUTHORIZED" | "FORBIDDEN" | "NOT_FOUND" | "VALIDATION" | "RATE_LIMITED" | "SERVER_ERROR" | "JOB_FAILED" | "NETWORK";
2
+ export declare class AigentycError extends Error {
3
+ readonly code: McpErrorCode;
4
+ readonly status?: number | undefined;
5
+ readonly requestId?: string | undefined;
6
+ readonly details?: unknown | undefined;
7
+ constructor(code: McpErrorCode, message: string, status?: number | undefined, requestId?: string | undefined, details?: unknown | undefined);
8
+ }
9
+ export declare function httpStatusToCode(status: number): McpErrorCode;
10
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GACpB,cAAc,GACd,WAAW,GACX,WAAW,GACX,YAAY,GACZ,cAAc,GACd,cAAc,GACd,YAAY,GACZ,SAAS,CAAC;AAEd,qBAAa,aAAc,SAAQ,KAAK;aAEpB,IAAI,EAAE,YAAY;aAElB,MAAM,CAAC,EAAE,MAAM;aACf,SAAS,CAAC,EAAE,MAAM;aAClB,OAAO,CAAC,EAAE,OAAO;gBAJjB,IAAI,EAAE,YAAY,EAClC,OAAO,EAAE,MAAM,EACC,MAAM,CAAC,EAAE,MAAM,YAAA,EACf,SAAS,CAAC,EAAE,MAAM,YAAA,EAClB,OAAO,CAAC,EAAE,OAAO,YAAA;CAKpC;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAO7D"}
package/dist/errors.js ADDED
@@ -0,0 +1,28 @@
1
+ export class AigentycError extends Error {
2
+ code;
3
+ status;
4
+ requestId;
5
+ details;
6
+ constructor(code, message, status, requestId, details) {
7
+ super(message);
8
+ this.code = code;
9
+ this.status = status;
10
+ this.requestId = requestId;
11
+ this.details = details;
12
+ this.name = "AigentycError";
13
+ }
14
+ }
15
+ export function httpStatusToCode(status) {
16
+ if (status === 401)
17
+ return "UNAUTHORIZED";
18
+ if (status === 403)
19
+ return "FORBIDDEN";
20
+ if (status === 404)
21
+ return "NOT_FOUND";
22
+ if (status === 400 || status === 422)
23
+ return "VALIDATION";
24
+ if (status === 429)
25
+ return "RATE_LIMITED";
26
+ return "SERVER_ERROR";
27
+ }
28
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAUA,MAAM,OAAO,aAAc,SAAQ,KAAK;IAEpB;IAEA;IACA;IACA;IALlB,YACkB,IAAkB,EAClC,OAAe,EACC,MAAe,EACf,SAAkB,EAClB,OAAiB;QAEjC,KAAK,CAAC,OAAO,CAAC,CAAC;QANC,SAAI,GAAJ,IAAI,CAAc;QAElB,WAAM,GAAN,MAAM,CAAS;QACf,cAAS,GAAT,SAAS,CAAS;QAClB,YAAO,GAAP,OAAO,CAAU;QAGjC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,cAAc,CAAC;IAC1C,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,WAAW,CAAC;IACvC,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,WAAW,CAAC;IACvC,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,YAAY,CAAC;IAC1D,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,cAAc,CAAC;IAC1C,OAAO,cAAc,CAAC;AACxB,CAAC"}
@@ -0,0 +1,29 @@
1
+ export declare const MAX_FILE_BYTES: number;
2
+ export declare const MAX_BATCH_BYTES: number;
3
+ export declare const MAX_BATCH_FILES = 500;
4
+ /**
5
+ * File extensions we're willing to read as UTF-8 text and upload directly.
6
+ * Binary formats (pdf/doc/docx) require the extraction service, which has
7
+ * no dual-auth today — out of scope for v0.1.
8
+ */
9
+ export declare const TEXT_EXTENSIONS: Set<string>;
10
+ export interface SafeFileInfo {
11
+ path: string;
12
+ realPath: string;
13
+ fileName: string;
14
+ size: number;
15
+ extension: string;
16
+ mimeHint: string;
17
+ }
18
+ export declare class UnsafePathError extends Error {
19
+ readonly path: string;
20
+ constructor(message: string, path: string);
21
+ }
22
+ /**
23
+ * Resolve a user-supplied path and refuse anything that would escape the
24
+ * allowed roots (CWD, $HOME), is not a regular file, is too large, or
25
+ * has an extension we can't safely treat as text.
26
+ */
27
+ export declare function resolveSafeFile(path: string): Promise<SafeFileInfo>;
28
+ export declare function readTextFile(info: SafeFileInfo): Promise<string>;
29
+ //# sourceMappingURL=fs-safety.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-safety.d.ts","sourceRoot":"","sources":["../src/fs-safety.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,QAAmB,CAAC;AAC/C,eAAO,MAAM,eAAe,QAAoB,CAAC;AACjD,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC;;;;GAIG;AACH,eAAO,MAAM,eAAe,aAiB1B,CAAC;AAMH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,eAAgB,SAAQ,KAAK;aACK,IAAI,EAAE,MAAM;gBAA7C,OAAO,EAAE,MAAM,EAAkB,IAAI,EAAE,MAAM;CAI1D;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAiDzE;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAEtE"}
@@ -0,0 +1,107 @@
1
+ import { readFile, realpath, stat } from "node:fs/promises";
2
+ import { homedir } from "node:os";
3
+ import { basename, extname, resolve, sep } from "node:path";
4
+ export const MAX_FILE_BYTES = 50 * 1024 * 1024; // 50 MB
5
+ export const MAX_BATCH_BYTES = 500 * 1024 * 1024; // 500 MB
6
+ export const MAX_BATCH_FILES = 500;
7
+ /**
8
+ * File extensions we're willing to read as UTF-8 text and upload directly.
9
+ * Binary formats (pdf/doc/docx) require the extraction service, which has
10
+ * no dual-auth today — out of scope for v0.1.
11
+ */
12
+ export const TEXT_EXTENSIONS = new Set([
13
+ ".txt",
14
+ ".md",
15
+ ".markdown",
16
+ ".json",
17
+ ".jsonl",
18
+ ".ndjson",
19
+ ".csv",
20
+ ".tsv",
21
+ ".html",
22
+ ".htm",
23
+ ".rtf",
24
+ ".log",
25
+ ".yaml",
26
+ ".yml",
27
+ ".xml",
28
+ ".text",
29
+ ]);
30
+ const ALLOWED_ROOTS = [process.cwd(), homedir()].map((p) => resolve(p) + (resolve(p).endsWith(sep) ? "" : sep));
31
+ export class UnsafePathError extends Error {
32
+ path;
33
+ constructor(message, path) {
34
+ super(message);
35
+ this.path = path;
36
+ this.name = "UnsafePathError";
37
+ }
38
+ }
39
+ /**
40
+ * Resolve a user-supplied path and refuse anything that would escape the
41
+ * allowed roots (CWD, $HOME), is not a regular file, is too large, or
42
+ * has an extension we can't safely treat as text.
43
+ */
44
+ export async function resolveSafeFile(path) {
45
+ const absolute = resolve(path);
46
+ let real;
47
+ try {
48
+ real = await realpath(absolute);
49
+ }
50
+ catch (err) {
51
+ throw new UnsafePathError(`Cannot resolve path: ${err.message}`, path);
52
+ }
53
+ const inAllowedRoot = ALLOWED_ROOTS.some((root) => (real + sep).startsWith(root));
54
+ if (!inAllowedRoot) {
55
+ throw new UnsafePathError(`Path escapes allowed roots (cwd=${process.cwd()}, home=${homedir()}): ${real}`, path);
56
+ }
57
+ const st = await stat(real);
58
+ if (!st.isFile()) {
59
+ throw new UnsafePathError(`Not a regular file: ${real}`, path);
60
+ }
61
+ if (st.size > MAX_FILE_BYTES) {
62
+ throw new UnsafePathError(`File exceeds ${MAX_FILE_BYTES} bytes (got ${st.size}): ${real}`, path);
63
+ }
64
+ const extension = extname(real).toLowerCase();
65
+ if (!TEXT_EXTENSIONS.has(extension)) {
66
+ throw new UnsafePathError(`Extension '${extension}' is not in the allowed text set. Binary formats (pdf/doc/docx) are not supported in v0.1.`, path);
67
+ }
68
+ return {
69
+ path,
70
+ realPath: real,
71
+ fileName: basename(real),
72
+ size: st.size,
73
+ extension,
74
+ mimeHint: guessMime(extension),
75
+ };
76
+ }
77
+ export async function readTextFile(info) {
78
+ return readFile(info.realPath, "utf8");
79
+ }
80
+ function guessMime(ext) {
81
+ switch (ext) {
82
+ case ".md":
83
+ case ".markdown":
84
+ return "text/markdown";
85
+ case ".json":
86
+ case ".jsonl":
87
+ case ".ndjson":
88
+ return "application/json";
89
+ case ".csv":
90
+ return "text/csv";
91
+ case ".tsv":
92
+ return "text/tab-separated-values";
93
+ case ".html":
94
+ case ".htm":
95
+ return "text/html";
96
+ case ".rtf":
97
+ return "application/rtf";
98
+ case ".yaml":
99
+ case ".yml":
100
+ return "application/yaml";
101
+ case ".xml":
102
+ return "application/xml";
103
+ default:
104
+ return "text/plain";
105
+ }
106
+ }
107
+ //# sourceMappingURL=fs-safety.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-safety.js","sourceRoot":"","sources":["../src/fs-safety.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAE5D,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,QAAQ;AACxD,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,SAAS;AAC3D,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AAEnC;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAS;IAC7C,MAAM;IACN,KAAK;IACL,WAAW;IACX,OAAO;IACP,QAAQ;IACR,SAAS;IACT,MAAM;IACN,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AC;QACpB,KAAK,MAAM;YACT,OAAO,2BAA2B,CAAC;QACrC,KAAK,OAAO,CAAC;QACb,KAAK,MAAM;YACT,OAAO,WAAW,CAAC;QACrB,KAAK,MAAM;YACT,OAAO,iBAAiB,CAAC;QAC3B,KAAK,OAAO,CAAC;QACb,KAAK,MAAM;YACT,OAAO,kBAAkB,CAAC;QAC5B,KAAK,MAAM;YACT,OAAO,iBAAiB,CAAC;QAC3B;YACE,OAAO,YAAY,CAAC;IACxB,CAAC;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { runStdioServer } from "./server.js";
2
+ export { createClient } from "./client.js";
3
+ export { AigentycError } from "./errors.js";
4
+ export type { AigentycConfig, ProfileConfig, } from "./config.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EACV,cAAc,EACd,aAAa,GACd,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { runStdioServer } from "./server.js";
2
+ export { createClient } from "./client.js";
3
+ export { AigentycError } from "./errors.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}