@sota-io/mcp 1.6.0 → 1.7.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 (47) hide show
  1. package/CLAUDE.md +19 -4
  2. package/README.md +3 -2
  3. package/dist/http-app.d.ts.map +1 -1
  4. package/dist/http-app.js +18 -4
  5. package/dist/http-app.js.map +1 -1
  6. package/dist/index.js +9 -3
  7. package/dist/index.js.map +1 -1
  8. package/dist/lib/account.d.ts +63 -0
  9. package/dist/lib/account.d.ts.map +1 -0
  10. package/dist/lib/account.js +64 -0
  11. package/dist/lib/account.js.map +1 -0
  12. package/dist/lib/archive-builder.d.ts +15 -1
  13. package/dist/lib/archive-builder.d.ts.map +1 -1
  14. package/dist/lib/archive-builder.js +31 -8
  15. package/dist/lib/archive-builder.js.map +1 -1
  16. package/dist/lib/guide.d.ts +33 -0
  17. package/dist/lib/guide.d.ts.map +1 -0
  18. package/dist/lib/guide.js +82 -0
  19. package/dist/lib/guide.js.map +1 -0
  20. package/dist/lib/ignore.d.ts +16 -0
  21. package/dist/lib/ignore.d.ts.map +1 -0
  22. package/dist/lib/ignore.js +131 -0
  23. package/dist/lib/ignore.js.map +1 -0
  24. package/dist/lib/project-url.d.ts +14 -0
  25. package/dist/lib/project-url.d.ts.map +1 -0
  26. package/dist/lib/project-url.js +16 -0
  27. package/dist/lib/project-url.js.map +1 -0
  28. package/dist/tools/account.d.ts +10 -0
  29. package/dist/tools/account.d.ts.map +1 -0
  30. package/dist/tools/account.js +104 -0
  31. package/dist/tools/account.js.map +1 -0
  32. package/dist/tools/deploy.d.ts +8 -0
  33. package/dist/tools/deploy.d.ts.map +1 -1
  34. package/dist/tools/deploy.js +56 -22
  35. package/dist/tools/deploy.js.map +1 -1
  36. package/dist/tools/env.js +1 -1
  37. package/dist/tools/env.js.map +1 -1
  38. package/dist/tools/logs.js +1 -1
  39. package/dist/tools/logs.js.map +1 -1
  40. package/dist/tools/projects.d.ts +8 -1
  41. package/dist/tools/projects.d.ts.map +1 -1
  42. package/dist/tools/projects.js +13 -5
  43. package/dist/tools/projects.js.map +1 -1
  44. package/dist/tools/status.d.ts.map +1 -1
  45. package/dist/tools/status.js +8 -3
  46. package/dist/tools/status.js.map +1 -1
  47. package/package.json +1 -1
@@ -0,0 +1,82 @@
1
+ /**
2
+ * The build and identity contract an agent must follow on sota.io, in one
3
+ * place (quick task 261125-mcg). The server instructions, the tool
4
+ * descriptions, the get-account tool, the enterprise-app-checklist prompt and
5
+ * the docs page web/src/app/docs/enterprise/build-with-ai/page.mdx all state
6
+ * it with these exact lines; test/guide.test.mjs fails when the docs page and
7
+ * this file drift apart.
8
+ *
9
+ * Every line is Markdown and keeps anything in angle brackets inside
10
+ * backticks, so the same text renders in MDX.
11
+ */
12
+ /** Rules for every sota app (Enterprise or not). */
13
+ export const BUILD_CONTRACT = [
14
+ 'One project runs one container with one web process. There is no second service, no worker container and no persistent disk: files written inside the container are lost on every deploy, so keep state in the database.',
15
+ 'Build: a `Dockerfile` in the project root wins. Without one, sota accepts Node.js (a `package.json`; Next.js when there is a `next.config.*`) and Python (`requirements.txt` or `pyproject.toml`) and builds them with railpack. Any other language needs a `Dockerfile`.',
16
+ 'Listen on `0.0.0.0` and the port in the `PORT` environment variable: 8080 for detected frameworks, the `EXPOSE` port of a Dockerfile.',
17
+ 'Health gate: after the build, sota calls `GET /health` inside the container, and `GET /` when `/health` answers 404, without any identity headers. It must answer 2xx or 3xx within 60 seconds, or the deploy fails and the previous version keeps running.',
18
+ 'Database: the first deploy creates a PostgreSQL 17 database and injects `DATABASE_URL` plus `PGHOST`, `PGPORT`, `PGUSER`, `PGPASSWORD` and `PGDATABASE`. `DATABASE_URL` goes through PgBouncer in transaction mode: no `LISTEN`/`NOTIFY`, no session state (`SET`, session advisory locks, temporary tables) and no named prepared statements (Prisma: add `?pgbouncer=true`). Run migrations at start, make them safe to run twice and keep them backwards compatible: during a deploy the previous version keeps serving on the same database until the new one passes the health gate.',
19
+ 'Settings and secrets: `set-env`, then deploy again. They are only available at runtime, never at build time. Public build-time values such as `NEXT_PUBLIC_*` belong in `.env.production`; secrets never go into an uploaded file.',
20
+ 'Uploads from a folder (local MCP server): `.git`, `node_modules`, `.DS_Store`, `.sota.json`, `__pycache__`, `.venv`, `*.log` and the local env files `.env`, `.env.local`, `.env.*.local` and `.envrc` are always left out. A `.sotaignore` in the root is used when it exists (an empty one uploads everything else); otherwise the `.gitignore` is used, but `.env.production` and `.env.example` are uploaded even when it lists them. Add a `.sotaignore` before deploying a folder that holds notes, credentials or data that must not leave the machine. A `git_url` deploy uploads the tracked files and reads only a `.sotaignore`. The hosted connector takes inline files only: at most 200 files and 10 MB.',
21
+ 'Logs: `get-logs` shows the build and deploy log; when a deploy fails, `get-status` shows the reason. Logs of the running app are not available yet.',
22
+ ];
23
+ /** Extra rules for an app on a sota Enterprise account. */
24
+ export const ENTERPRISE_CONTRACT = [
25
+ 'Address: a project named `app` gets the slug `<label>-app` and the one URL `https://app.<label>.sota.io`. There is no `<slug>.sota.io` address.',
26
+ 'Sign-in: sota Access signs people in with the company\'s Microsoft 365 on every path before a request reaches the app. Do not build a login, sign-up, password reset or session handling.',
27
+ 'Identity: every signed-in request carries `X-Sota-Access-User-Id` (a stable UUID: use it as the user key), `X-Sota-Access-Email` (lower-case it before comparing; it can be the tenant sign-in name such as `name@company.onmicrosoft.com` instead of the mailbox) and `X-Sota-Access-Name` (display only). The headers carry no role: keep roles in the app\'s own database.',
28
+ 'Fail closed: every route that shows or changes data answers 401 when `X-Sota-Access-User-Id` is missing. Only `GET /health` and `GET /` answer without it, and they show no data.',
29
+ 'Health without identity: the health gate and the edge\'s check of `GET /` (every 30 seconds, redirects not followed) send no identity headers. `GET /health` must answer 200 and `GET /` 2xx or 3xx without them, for example a short "not signed in" page or a redirect. An app that answers 401 on `/` is marked down and nobody can open it.',
30
+ 'Sign out: link to `/.sota/access/logout`. Paths under `/.sota/` belong to sota Access.',
31
+ 'No public paths yet: webhooks, API clients and scripts without a browser cannot reach the app, and `POST`, `PUT`, `PATCH` or `DELETE` requests from other websites are refused.',
32
+ 'Apps of the same account run on the same server. A direct call from one app to another skips the sign-in, and the caller can set any identity header: never treat such a call as a signed-in user, and authenticate app-to-app calls with your own shared secret.',
33
+ 'Local development: the headers are missing on your machine. Use a fixed test user behind a development-only switch that is off in the deployed app.',
34
+ ];
35
+ /** What the owner does after a deploy, before anyone can open the app. */
36
+ export const ENTERPRISE_ACCESS_STEPS = [
37
+ 'Nobody can open a new app yet, the owner included.',
38
+ 'The person opens the app URL once and signs in with Microsoft 365. This creates an access request.',
39
+ 'The account owner signs in to the sota dashboard, opens Users & access, approves the person and ticks this app.',
40
+ 'The person reloads the app. People approved earlier also need this app ticked.',
41
+ 'API keys and MCP cannot approve people or change grants: tell the human what to do instead.',
42
+ ];
43
+ export const DOCS = {
44
+ buildWithAi: 'https://sota.io/docs/enterprise/build-with-ai',
45
+ identity: 'https://sota.io/docs/enterprise/app-identity',
46
+ limits: 'https://sota.io/docs/enterprise/limits',
47
+ mcpTools: 'https://sota.io/docs/mcp/tools',
48
+ };
49
+ /**
50
+ * Server instructions (MCP `initialize`). Short on purpose: clients put them
51
+ * into the agent's context; the details come from get-account.
52
+ */
53
+ export const SERVER_INSTRUCTIONS = [
54
+ 'sota.io deploys web apps (EU, Germany). Before you write or deploy code for the user, call get-account once: it says whether the account is a sota Enterprise account and returns the build contract the app must follow.',
55
+ 'Every app: one container, one web process, listen on the PORT env var, answer GET /health (or GET /) with 2xx/3xx within 60 s, no persistent disk, DATABASE_URL via PgBouncer in transaction mode.',
56
+ 'Enterprise accounts: the company sign-in sits in front of every path, so never build a login; read the X-Sota-Access-* headers, fail closed without them except on GET /health and GET /, which must answer without identity. After a deploy nobody can open the app until the owner approves people and ticks the app under Users & access in the dashboard; MCP cannot do that, so tell the human.',
57
+ 'deploy starts a build and returns at once: poll get-status until the deployment is running or failed.',
58
+ ].join('\n\n');
59
+ export function bullets(lines) {
60
+ return lines.map((l) => `- ${l}`).join('\n');
61
+ }
62
+ export function numbered(lines) {
63
+ return lines.map((l, i) => `${i + 1}. ${l}`).join('\n');
64
+ }
65
+ /** The Enterprise checklist (prompt + get-account), account-independent. */
66
+ export function enterpriseChecklist() {
67
+ return [
68
+ '# Enterprise app checklist (sota.io)',
69
+ '',
70
+ '## Every sota app',
71
+ bullets(BUILD_CONTRACT),
72
+ '',
73
+ '## On a sota Enterprise account',
74
+ bullets(ENTERPRISE_CONTRACT),
75
+ '',
76
+ '## After the deploy: who can open the app',
77
+ numbered(ENTERPRISE_ACCESS_STEPS),
78
+ '',
79
+ `Docs: ${DOCS.buildWithAi}`,
80
+ ].join('\n');
81
+ }
82
+ //# sourceMappingURL=guide.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guide.js","sourceRoot":"","sources":["../../src/lib/guide.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,oDAAoD;AACpD,MAAM,CAAC,MAAM,cAAc,GAAsB;IAC/C,0NAA0N;IAC1N,2QAA2Q;IAC3Q,uIAAuI;IACvI,6PAA6P;IAC7P,2jBAA2jB;IAC3jB,oOAAoO;IACpO,wrBAAwrB;IACxrB,qJAAqJ;CACtJ,CAAC;AAEF,2DAA2D;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAsB;IACpD,iJAAiJ;IACjJ,2LAA2L;IAC3L,+WAA+W;IAC/W,mLAAmL;IACnL,iVAAiV;IACjV,wFAAwF;IACxF,iLAAiL;IACjL,mQAAmQ;IACnQ,qJAAqJ;CACtJ,CAAC;AAEF,0EAA0E;AAC1E,MAAM,CAAC,MAAM,uBAAuB,GAAsB;IACxD,oDAAoD;IACpD,oGAAoG;IACpG,iHAAiH;IACjH,gFAAgF;IAChF,6FAA6F;CAC9F,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,WAAW,EAAE,+CAA+C;IAC5D,QAAQ,EAAE,8CAA8C;IACxD,MAAM,EAAE,wCAAwC;IAChD,QAAQ,EAAE,gCAAgC;CAClC,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,2NAA2N;IAC3N,oMAAoM;IACpM,sYAAsY;IACtY,uGAAuG;CACxG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAEf,MAAM,UAAU,OAAO,CAAC,KAAwB;IAC9C,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAwB;IAC/C,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1D,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,mBAAmB;IACjC,OAAO;QACL,sCAAsC;QACtC,EAAE;QACF,mBAAmB;QACnB,OAAO,CAAC,cAAc,CAAC;QACvB,EAAE;QACF,iCAAiC;QACjC,OAAO,CAAC,mBAAmB,CAAC;QAC5B,EAAE;QACF,2CAA2C;QAC3C,QAAQ,CAAC,uBAAuB,CAAC;QACjC,EAAE;QACF,SAAS,IAAI,CAAC,WAAW,EAAE;KAC5B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,16 @@
1
+ export interface IgnoreRules {
2
+ /** ".sotaignore", ".gitignore" or null when no file was used. */
3
+ source: string | null;
4
+ patterns: string[];
5
+ }
6
+ export declare const NO_RULES: IgnoreRules;
7
+ /** Kept when only the .gitignore fallback applies (base names). */
8
+ export declare const KEPT_FROM_GITIGNORE: ReadonlySet<string>;
9
+ export declare function loadIgnoreRules(root: string, opts: {
10
+ gitignoreFallback: boolean;
11
+ }): IgnoreRules;
12
+ /** relPath uses "/" and has no leading "./". */
13
+ export declare function isIgnored(relPath: string, isDir: boolean, patterns: readonly string[]): boolean;
14
+ /** isIgnored with the .gitignore-fallback exceptions. */
15
+ export declare function ignoredBy(rules: IgnoreRules, relPath: string, isDir: boolean): boolean;
16
+ //# sourceMappingURL=ignore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ignore.d.ts","sourceRoot":"","sources":["../../src/lib/ignore.ts"],"names":[],"mappings":"AA2BA,MAAM,WAAW,WAAW;IAC1B,iEAAiE;IACjE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,eAAO,MAAM,QAAQ,EAAE,WAA4C,CAAC;AAEpE,mEAAmE;AACnE,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAAgD,CAAC;AAcrG,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,iBAAiB,EAAE,OAAO,CAAA;CAAE,GAAG,WAAW,CAQ/F;AAyBD,gDAAgD;AAChD,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAyB/F;AAED,yDAAyD;AACzD,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAQtF"}
@@ -0,0 +1,131 @@
1
+ /**
2
+ * .sotaignore / .gitignore for directory and git deploys (quick task
3
+ * 261125-mcg), with the CLI's pattern rules (cli/internal/archive/archive.go
4
+ * loadIgnorePatterns + shouldIgnore). Blank lines and # comments are skipped.
5
+ * A pattern matches a relative path when
6
+ * - it ends in "/" and names that directory or a path below it,
7
+ * - it equals the path or its base name,
8
+ * - it contains "*" and glob-matches the base name or the whole path
9
+ * ("*" and "?" do not cross "/"), or
10
+ * - it equals one path component.
11
+ * Additions to the CLI rules: a leading "/" anchors the pattern to the root
12
+ * (as in git); "!" lines are skipped (no re-include); a pattern that is not a
13
+ * valid glob is skipped (like Go's filepath.Match returning an error).
14
+ *
15
+ * Which file is read:
16
+ * - directory deploy: .sotaignore when it exists (an empty one means
17
+ * "nothing extra", it does NOT fall back to .gitignore); otherwise the
18
+ * .gitignore, but .env.production and .env.example are kept even when
19
+ * the .gitignore lists them (create-next-app's .gitignore has ".env*",
20
+ * and public build-time values such as NEXT_PUBLIC_* live there).
21
+ * - git_url deploy: only .sotaignore. A clone holds tracked files only,
22
+ * and tracked files that match the .gitignore (committed build output)
23
+ * have always been deployed.
24
+ */
25
+ import { existsSync, readFileSync } from 'fs';
26
+ import { join } from 'path';
27
+ export const NO_RULES = { source: null, patterns: [] };
28
+ /** Kept when only the .gitignore fallback applies (base names). */
29
+ export const KEPT_FROM_GITIGNORE = new Set(['.env.production', '.env.example']);
30
+ function readPatterns(path) {
31
+ if (!existsSync(path))
32
+ return null;
33
+ try {
34
+ return readFileSync(path, 'utf8')
35
+ .split(/\r?\n/)
36
+ .map((l) => l.trim())
37
+ .filter((l) => l !== '' && !l.startsWith('#') && !l.startsWith('!'));
38
+ }
39
+ catch {
40
+ return null;
41
+ }
42
+ }
43
+ export function loadIgnoreRules(root, opts) {
44
+ const sota = readPatterns(join(root, '.sotaignore'));
45
+ if (sota !== null)
46
+ return { source: '.sotaignore', patterns: sota };
47
+ if (opts.gitignoreFallback) {
48
+ const git = readPatterns(join(root, '.gitignore'));
49
+ if (git !== null)
50
+ return { source: '.gitignore', patterns: git };
51
+ }
52
+ return NO_RULES;
53
+ }
54
+ /** null when the pattern is not a valid glob. */
55
+ function globToRegExp(glob) {
56
+ let re = '';
57
+ for (let i = 0; i < glob.length; i++) {
58
+ const c = glob[i];
59
+ if (c === '*')
60
+ re += '[^/]*';
61
+ else if (c === '?')
62
+ re += '[^/]';
63
+ else if (c === '[') {
64
+ const end = glob.indexOf(']', i + 1);
65
+ if (end === -1)
66
+ return null; // unterminated class: invalid, like filepath.Match
67
+ let cls = glob.slice(i + 1, end);
68
+ if (cls.startsWith('!') || cls.startsWith('^'))
69
+ cls = `^${cls.slice(1)}`;
70
+ re += `[${cls.replace(/\\/g, '\\\\')}]`;
71
+ i = end;
72
+ }
73
+ else
74
+ re += c.replace(/[.+^${}()|\\]/g, '\\$&');
75
+ }
76
+ try {
77
+ return new RegExp(`^${re}$`);
78
+ }
79
+ catch {
80
+ return null;
81
+ }
82
+ }
83
+ /** relPath uses "/" and has no leading "./". */
84
+ export function isIgnored(relPath, isDir, patterns) {
85
+ const base = relPath.slice(relPath.lastIndexOf('/') + 1);
86
+ const parts = relPath.split('/');
87
+ for (const raw of patterns) {
88
+ const anchored = raw.startsWith('/');
89
+ const pattern = anchored ? raw.slice(1) : raw;
90
+ if (pattern === '')
91
+ continue;
92
+ if (pattern.endsWith('/')) {
93
+ const dir = pattern.slice(0, -1);
94
+ if (isDir && (relPath === dir || relPath.startsWith(`${dir}/`)))
95
+ return true;
96
+ if (!isDir && relPath.startsWith(`${dir}/`))
97
+ return true;
98
+ continue;
99
+ }
100
+ if (relPath === pattern)
101
+ return true;
102
+ const wild = pattern.includes('*') || pattern.includes('?') || pattern.includes('[');
103
+ const re = wild ? globToRegExp(pattern) : null;
104
+ if (anchored) {
105
+ if (re && re.test(relPath))
106
+ return true;
107
+ continue;
108
+ }
109
+ if (base === pattern)
110
+ return true;
111
+ if (re && (re.test(base) || re.test(relPath)))
112
+ return true;
113
+ if (parts.includes(pattern))
114
+ return true;
115
+ }
116
+ return false;
117
+ }
118
+ /** isIgnored with the .gitignore-fallback exceptions. */
119
+ export function ignoredBy(rules, relPath, isDir) {
120
+ if (rules.patterns.length === 0)
121
+ return false;
122
+ if (!isIgnored(relPath, isDir, rules.patterns))
123
+ return false;
124
+ if (rules.source === '.gitignore' && !isDir) {
125
+ const base = relPath.slice(relPath.lastIndexOf('/') + 1);
126
+ if (KEPT_FROM_GITIGNORE.has(base))
127
+ return false;
128
+ }
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CAAC;IAClD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The public URL of a project, as the API returns it in `project.url`
3
+ * (ENT-MVP WP2). An Enterprise app lives at `https://<app>.<customer>.sota.io`
4
+ * and has no `<slug>.sota.io` host, so tools show this value instead of
5
+ * composing one from the slug.
6
+ *
7
+ * The slug-based fallback is only for an API from before the `url` field;
8
+ * such an API has no Enterprise projects, so the composed URL is right there.
9
+ */
10
+ export declare function projectUrl(project: {
11
+ slug: string;
12
+ url?: string | null;
13
+ }): string;
14
+ //# sourceMappingURL=project-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-url.d.ts","sourceRoot":"","sources":["../../src/lib/project-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,MAAM,CAKjF"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The public URL of a project, as the API returns it in `project.url`
3
+ * (ENT-MVP WP2). An Enterprise app lives at `https://<app>.<customer>.sota.io`
4
+ * and has no `<slug>.sota.io` host, so tools show this value instead of
5
+ * composing one from the slug.
6
+ *
7
+ * The slug-based fallback is only for an API from before the `url` field;
8
+ * such an API has no Enterprise projects, so the composed URL is right there.
9
+ */
10
+ export function projectUrl(project) {
11
+ if (typeof project.url === 'string' && project.url !== '') {
12
+ return project.url;
13
+ }
14
+ return `https://${project.slug}.sota.io`;
15
+ }
16
+ //# sourceMappingURL=project-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-url.js","sourceRoot":"","sources":["../../src/lib/project-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,OAA8C;IACvE,IAAI,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,IAAI,OAAO,CAAC,GAAG,KAAK,EAAE,EAAE,CAAC;QAC1D,OAAO,OAAO,CAAC,GAAG,CAAC;IACrB,CAAC;IACD,OAAO,WAAW,OAAO,CAAC,IAAI,UAAU,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { Account, AccountReader } from '../lib/account.js';
3
+ /** The Enterprise next steps for the human, with this account's links. */
4
+ export declare function enterpriseNextSteps(account: Account, appUrl?: string): string;
5
+ /** get-account output. */
6
+ export declare function renderAccount(account: Account | null): string;
7
+ export declare function registerAccountTool(server: McpServer, readAccount: AccountReader): void;
8
+ /** Static checklist prompt; needs no account and no API call. */
9
+ export declare function registerChecklistPrompt(server: McpServer): void;
10
+ //# sourceMappingURL=account.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/tools/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAsBhE,0EAA0E;AAC1E,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAe7E;AAED,0BAA0B;AAC1B,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,MAAM,CAwC7D;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,QAyBhF;AAED,iEAAiE;AACjE,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,QAoBxD"}
@@ -0,0 +1,104 @@
1
+ import { BUILD_CONTRACT, DOCS, ENTERPRISE_ACCESS_STEPS, ENTERPRISE_CONTRACT, bullets, enterpriseChecklist, numbered, } from '../lib/guide.js';
2
+ const SIGN_IN_STATE_TEXT = {
3
+ verified: 'verified (people can sign in)',
4
+ saved_untested: 'saved but not tested yet: the owner must run "Test sign-in" in the dashboard before anyone can sign in',
5
+ not_set_up: 'not set up: nobody can sign in until the owner sets it up in the dashboard',
6
+ unknown: 'unknown (could not be read right now)',
7
+ };
8
+ function mb(bytes) {
9
+ return `${Math.round(bytes / 1024 / 1024)} MB`;
10
+ }
11
+ /** The Enterprise next steps for the human, with this account's links. */
12
+ export function enterpriseNextSteps(account, appUrl) {
13
+ const ent = account.enterprise;
14
+ if (!ent)
15
+ return '';
16
+ const lines = [
17
+ 'Next steps for the human (sota Enterprise):',
18
+ numbered(ENTERPRISE_ACCESS_STEPS),
19
+ `App URL: ${appUrl ?? `https://${ent.app_host_pattern}`}`,
20
+ `Users & access: ${ent.users_and_access_url}`,
21
+ ];
22
+ if (ent.sign_in_state !== 'verified') {
23
+ lines.push(`Sign-in connection: ${SIGN_IN_STATE_TEXT[ent.sign_in_state] ?? ent.sign_in_state} (${ent.sign_in_setup_url}).`);
24
+ }
25
+ return lines.join('\n');
26
+ }
27
+ /** get-account output. */
28
+ export function renderAccount(account) {
29
+ const parts = [];
30
+ if (!account) {
31
+ parts.push('Account details are not available from this API version. Assume an ordinary account unless project URLs look like https://<app>.<label>.sota.io (then it is sota Enterprise).');
32
+ }
33
+ else {
34
+ const p = account.plan;
35
+ const u = account.usage;
36
+ parts.push([
37
+ '# Account',
38
+ `Plan: ${p.name}`,
39
+ `Projects: ${u ? `${u.projects} of ${p.max_projects}` : `max ${p.max_projects}`}; databases: ${u ? `${u.databases} of ${p.max_databases}` : `max ${p.max_databases}`}`,
40
+ `Memory per app: ${p.max_memory_mb} MB; deploy upload: max ${mb(p.max_deploy_bytes)} (hosted connector: 200 files / 10 MB inline)`,
41
+ ].join('\n'));
42
+ const ent = account.enterprise;
43
+ if (ent) {
44
+ parts.push([
45
+ '# sota Enterprise account',
46
+ `Company label: ${ent.customer_label}`,
47
+ `App URLs: https://${ent.app_host_pattern} (a project named "app" gets the slug "${ent.customer_label}-app")`,
48
+ `Apps: ${ent.apps_used ?? 'unknown'} of ${ent.app_limit}, all on the company's own server (status: ${ent.server_status || 'unknown'})`,
49
+ `Sign-in connection (Microsoft 365): ${SIGN_IN_STATE_TEXT[ent.sign_in_state] ?? ent.sign_in_state}`,
50
+ `Users & access (owner, dashboard only): ${ent.users_and_access_url}`,
51
+ ].join('\n'));
52
+ }
53
+ else {
54
+ parts.push('# Not an Enterprise account\nApps are public at https://<slug>.sota.io; build your own login if the app needs one.');
55
+ }
56
+ }
57
+ parts.push(`# Build contract (every app)\n${bullets(BUILD_CONTRACT)}`);
58
+ if (!account || account.enterprise) {
59
+ parts.push(`# Enterprise contract\n${bullets(ENTERPRISE_CONTRACT)}`);
60
+ parts.push(`# After the deploy: who can open the app\n${numbered(ENTERPRISE_ACCESS_STEPS)}`);
61
+ }
62
+ parts.push(`Docs: ${DOCS.buildWithAi} · identity headers ${DOCS.identity} · limits ${DOCS.limits}`);
63
+ return parts.join('\n\n');
64
+ }
65
+ export function registerAccountTool(server, readAccount) {
66
+ server.registerTool('get-account', {
67
+ description: 'Call this FIRST, before writing or deploying code. Returns the signed-in sota.io account: plan limits (projects, databases, memory per app, upload size), whether it is a sota Enterprise account (company label, app URL scheme https://<app>.<label>.sota.io, own server, sign-in connection status, the dashboard page where the owner grants access) and the build contract the app must follow: one container, PORT, health gate, database through PgBouncer, upload rules, and for Enterprise the identity headers, fail-closed rule, health-without-identity rule and what the human must do before anyone can open the app. Read-only.',
68
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
69
+ }, async () => {
70
+ try {
71
+ const account = await readAccount();
72
+ return { content: [{ type: 'text', text: renderAccount(account) }] };
73
+ }
74
+ catch (error) {
75
+ return {
76
+ content: [
77
+ {
78
+ type: 'text',
79
+ text: `Failed to read the account: ${error instanceof Error ? error.message : String(error)}\n\n${renderAccount(null)}`,
80
+ },
81
+ ],
82
+ isError: true,
83
+ };
84
+ }
85
+ });
86
+ }
87
+ /** Static checklist prompt; needs no account and no API call. */
88
+ export function registerChecklistPrompt(server) {
89
+ server.registerPrompt('enterprise-app-checklist', {
90
+ title: 'Enterprise app checklist',
91
+ description: 'The rules an app must follow to deploy and behave correctly on sota.io, including sota Enterprise (company sign-in, identity headers, health without identity, who can open the app).',
92
+ }, () => ({
93
+ messages: [
94
+ {
95
+ role: 'user',
96
+ content: {
97
+ type: 'text',
98
+ text: `${enterpriseChecklist()}\n\nFollow this checklist for the app we build. Call get-account first to learn this account's label and limits.`,
99
+ },
100
+ },
101
+ ],
102
+ }));
103
+ }
104
+ //# sourceMappingURL=account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/tools/account.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EACd,IAAI,EACJ,uBAAuB,EACvB,mBAAmB,EACnB,OAAO,EACP,mBAAmB,EACnB,QAAQ,GACT,MAAM,iBAAiB,CAAC;AAEzB,MAAM,kBAAkB,GAA2B;IACjD,QAAQ,EAAE,+BAA+B;IACzC,cAAc,EAAE,wGAAwG;IACxH,UAAU,EAAE,4EAA4E;IACxF,OAAO,EAAE,uCAAuC;CACjD,CAAC;AAEF,SAAS,EAAE,CAAC,KAAa;IACvB,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;AACjD,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,mBAAmB,CAAC,OAAgB,EAAE,MAAe;IACnE,MAAM,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC;IAC/B,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,MAAM,KAAK,GAAG;QACZ,6CAA6C;QAC7C,QAAQ,CAAC,uBAAuB,CAAC;QACjC,YAAY,MAAM,IAAI,WAAW,GAAG,CAAC,gBAAgB,EAAE,EAAE;QACzD,mBAAmB,GAAG,CAAC,oBAAoB,EAAE;KAC9C,CAAC;IACF,IAAI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MAAM,OAAO,GAAG,MAAM,WAAW,EAAE,CAAC;YACpC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;QAChF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,+BAA+B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,IAAI,CAAC,EAAE;qBACxH;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,uBAAuB,CAAC,MAAiB;IACvD,MAAM,CAAC,cAAc,CACnB,0BAA0B,EAC1B;QACE,KAAK,EAAE,0BAA0B;QACjC,WAAW,EACT,uLAAuL;KAC1L,EACD,GAAG,EAAE,CAAC,CAAC;QACL,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAe;gBACrB,OAAO,EAAE;oBACP,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,GAAG,mBAAmB,EAAE,kHAAkH;iBACjJ;aACF;SACF;KACF,CAAC,CACH,CAAC;AACJ,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  import { SotaClient } from '@sota-io/sdk';
3
+ import { type AccountReader } from '../lib/account.js';
3
4
  export interface DeployToolOptions {
4
5
  /**
5
6
  * true for the hosted server (mcp.sota.io): only inline `files` are
@@ -9,6 +10,13 @@ export interface DeployToolOptions {
9
10
  * false (default) for the local stdio server: files, git_url, directory.
10
11
  */
11
12
  hosted?: boolean;
13
+ /**
14
+ * Reads GET /v1/account; when it says Enterprise, the result tells the
15
+ * agent what the human must do before anyone can open the app.
16
+ */
17
+ readAccount?: AccountReader;
18
+ /** Bound for the account and project lookups after the upload (default 3 s). */
19
+ lookupTimeoutMs?: number;
12
20
  }
13
21
  export declare function registerDeployTool(server: McpServer, client: SotaClient, options?: DeployToolOptions): void;
14
22
  //# sourceMappingURL=deploy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/tools/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAY1C,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAgDD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAE,iBAAsB,QAMxG"}
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/tools/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAW1C,OAAO,EAAE,KAAK,aAAa,EAAmD,MAAM,mBAAmB,CAAC;AAIxG,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,WAAW,CAAC,EAAE,aAAa,CAAC;IAC5B,gFAAgF;IAChF,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AA2DD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAE,iBAAsB,QAMxG"}
@@ -1,6 +1,9 @@
1
1
  import { z } from 'zod';
2
- import { archiveFromDirectory, archiveFromFiles, archiveFromGitUrl, ArchiveBuilderError, MAX_INLINE_FILES, MAX_INLINE_TOTAL_BYTES, MAX_CLONE_BYTES, } from '../lib/archive-builder.js';
2
+ import { archiveDirectoryWithReport, archiveFromFiles, archiveFromGitUrl, ArchiveBuilderError, MAX_INLINE_FILES, MAX_INLINE_TOTAL_BYTES, MAX_CLONE_BYTES, } from '../lib/archive-builder.js';
3
3
  import { HOSTED_FILES_ONLY_HINT } from '../lib/hosted-guard.js';
4
+ import { LOOKUP_TIMEOUT_MS, settleWithin, tryReadAccount } from '../lib/account.js';
5
+ import { projectUrl } from '../lib/project-url.js';
6
+ import { enterpriseNextSteps } from './account.js';
4
7
  const INTRO = `Deploy an application to sota.io. The platform auto-detects your framework and builds a Docker image automatically:
5
8
 
6
9
  - Next.js: Detected via next.config.js/ts. Add output: 'standalone' to next.config for optimal builds.
@@ -25,39 +28,65 @@ const LOCAL_MODES = `THREE WAYS to supply the source code — pick EXACTLY ONE:
25
28
 
26
29
  3. **directory** (local filesystem):
27
30
  Pass an absolute path. Defaults to the current working directory when
28
- no other mode is given.`;
31
+ no other mode is given. A .sotaignore in that directory is honoured
32
+ (an empty one uploads everything else); without one, its .gitignore is
33
+ used, except that .env.production and .env.example are always kept.
34
+ Without either file, every file except the exclusions below is
35
+ uploaded, so add a .sotaignore before deploying a folder with notes or
36
+ credentials. git_url uploads the tracked files and reads only a
37
+ .sotaignore.`;
29
38
  const HOSTED_MODES = `Supply the source code as **files** (inline source from AI):
30
39
  ${FILES_MODE}
31
40
 
32
41
  This hosted server only accepts inline files. ${HOSTED_FILES_ONLY_HINT}`;
33
- const OUTRO = `IMPORTANT: Your app MUST listen on the PORT environment variable. For auto-detected frameworks (Next.js, Node.js, Python) PORT is 8080. For custom Dockerfiles, the port is auto-detected from the EXPOSE directive (e.g. EXPOSE 3000 sets PORT=3000). If no EXPOSE is found, it defaults to 8080.
42
+ const OUTRO = `BEFORE the first deploy, call get-account: it says whether this is a sota Enterprise account and returns the full contract. The rules that make a deploy fail:
34
43
 
35
- Every project includes a managed PostgreSQL 17 database. Six environment variables are auto-injected into your container — no manual database configuration needed: DATABASE_URL (full connection string), PGHOST, PGPORT, PGUSER, PGPASSWORD, and PGDATABASE. Libraries that follow libpq conventions (node-postgres, pgx, psycopg2, Django) pick up the PG* variables automatically with no configuration. If your app needs database migrations, run them on startup.
44
+ - Listen on 0.0.0.0 and the PORT environment variable: 8080 for auto-detected frameworks, the EXPOSE port of a Dockerfile.
45
+ - Health gate: sota calls GET /health inside the container (GET / when /health answers 404) WITHOUT identity headers; it must answer 2xx or 3xx within 60 seconds, otherwise the deploy fails and the previous version keeps running.
46
+ - One container, one web process, no persistent disk (files are lost on every deploy), no second service.
47
+ - sota Enterprise: never build a login; read the X-Sota-Access-* headers and fail closed without them, EXCEPT GET /health (200) and GET / (2xx/3xx, no data), which the health gate and the edge check call without identity. An app answering 401 on / is marked down.
36
48
 
37
- Deployments use blue-green strategy for zero downtime. The old container keeps running until the new one passes health checks (60s timeout). Use get-logs to monitor build progress. .git/, node_modules/, .DS_Store and the local/secret env files .env, .env.local, .env.*.local and .envrc (any directory, any case) are excluded from the archive; set runtime secrets with set-env instead. Committed variants such as .env.production are kept (set-env values are not available at build time).`;
49
+ The first deploy creates a PostgreSQL 17 database and injects DATABASE_URL (through PgBouncer in transaction mode: no LISTEN/NOTIFY, no session state, no named prepared statements) plus PGHOST, PGPORT, PGUSER, PGPASSWORD and PGDATABASE. Run migrations at start.
50
+
51
+ The deploy runs in the background: this tool returns at once. Poll get-status every 10-15 seconds until the deployment is running or failed; on failed, get-status shows the reason and get-logs the build log. Blue-green: the old container keeps serving until the new one passes the health gate. .git/, node_modules/, .DS_Store and the local/secret env files .env, .env.local, .env.*.local and .envrc (any directory, any case) are excluded from the archive; set runtime secrets with set-env instead. .env.production is kept (set-env values are not available at build time): put public build-time values such as NEXT_PUBLIC_* there, never secrets.`;
38
52
  const FILES_DESCRIPTION = 'Map of relative file paths to UTF-8 text content. Use when generating an app inline (e.g. from a Claude.ai web conversation). Include a framework manifest so auto-detection works.';
39
53
  function errorResult(text) {
40
54
  return { content: [{ type: 'text', text }], isError: true };
41
55
  }
42
56
  export function registerDeployTool(server, client, options = {}) {
43
57
  if (options.hosted === true) {
44
- registerHostedDeployTool(server, client);
58
+ registerHostedDeployTool(server, client, options);
45
59
  }
46
60
  else {
47
- registerLocalDeployTool(server, client);
61
+ registerLocalDeployTool(server, client, options);
48
62
  }
49
63
  }
50
- async function uploadArchive(client, projectId, archive, modeDescription) {
64
+ async function uploadArchive(client, projectId, archive, modeDescription, options, note) {
51
65
  try {
52
66
  const deployment = await client.deploy(projectId, archive);
53
- return {
54
- content: [
55
- {
56
- type: 'text',
57
- text: `Deployment started (${modeDescription}):\n ID: ${deployment.id}\n Status: ${deployment.status}\n URL: ${deployment.url || 'pending'}\n\nUse get-logs to check build progress.`,
58
- },
59
- ],
60
- };
67
+ // The app URL is known before the deployment runs (deployment.url is
68
+ // only set once it is live). Best effort: older clients or a failed
69
+ // lookup just leave it out.
70
+ const timeoutMs = options.lookupTimeoutMs ?? LOOKUP_TIMEOUT_MS;
71
+ let appUrl;
72
+ if (typeof client.getProject === 'function') {
73
+ const project = await settleWithin(client.getProject(projectId), timeoutMs);
74
+ appUrl = project ? projectUrl(project) : undefined;
75
+ }
76
+ const lines = [
77
+ `Deployment started (${modeDescription}):`,
78
+ ` ID: ${deployment.id}`,
79
+ ` Status: ${deployment.status}`,
80
+ ` App URL: ${appUrl ?? deployment.url ?? 'pending'}`,
81
+ ];
82
+ if (note)
83
+ lines.push('', note);
84
+ lines.push('', 'The build runs in the background. Poll get-status every 10-15 seconds until the status is running or failed (get-status shows the reason of a failure; get-logs shows the build log).');
85
+ const account = await tryReadAccount(options.readAccount, timeoutMs);
86
+ if (account?.enterprise) {
87
+ lines.push('', enterpriseNextSteps(account, appUrl));
88
+ }
89
+ return { content: [{ type: 'text', text: lines.join('\n') }] };
61
90
  }
62
91
  catch (error) {
63
92
  return errorResult(`Deploy failed during upload: ${error instanceof Error ? error.message : String(error)}`);
@@ -69,7 +98,7 @@ function archiveError(error) {
69
98
  return errorResult(`Deploy failed during archive construction${code}: ${detail}`);
70
99
  }
71
100
  /** Hosted (mcp.sota.io): inline files only. */
72
- function registerHostedDeployTool(server, client) {
101
+ function registerHostedDeployTool(server, client, options) {
73
102
  server.registerTool('deploy', {
74
103
  description: `${INTRO}\n\n${HOSTED_MODES}\n\n${OUTRO}`,
75
104
  inputSchema: {
@@ -92,11 +121,11 @@ function registerHostedDeployTool(server, client) {
92
121
  catch (error) {
93
122
  return archiveError(error);
94
123
  }
95
- return uploadArchive(client, project_id, archive, `inline files (${Object.keys(files).length} entries)`);
124
+ return uploadArchive(client, project_id, archive, `inline files (${Object.keys(files).length} entries)`, options);
96
125
  });
97
126
  }
98
127
  /** Local stdio server (npx @sota-io/mcp): files, git_url or directory. */
99
- function registerLocalDeployTool(server, client) {
128
+ function registerLocalDeployTool(server, client, options) {
100
129
  server.registerTool('deploy', {
101
130
  description: `${INTRO}\n\n${LOCAL_MODES}\n\n${OUTRO}`,
102
131
  inputSchema: {
@@ -131,6 +160,7 @@ function registerLocalDeployTool(server, client) {
131
160
  }
132
161
  let archive;
133
162
  let modeDescription;
163
+ let note;
134
164
  try {
135
165
  if (files !== undefined) {
136
166
  archive = archiveFromFiles(files);
@@ -142,14 +172,18 @@ function registerLocalDeployTool(server, client) {
142
172
  }
143
173
  else {
144
174
  const dir = directory || process.cwd();
145
- archive = archiveFromDirectory(dir);
146
- modeDescription = `directory (${dir})`;
175
+ const packed = archiveDirectoryWithReport(dir);
176
+ archive = packed.archive;
177
+ modeDescription = `directory (${dir}), ${packed.files} files`;
178
+ note = packed.ignoreFile
179
+ ? `Ignore rules: ${packed.ignoreFile}.`
180
+ : 'Ignore rules: none (no .sotaignore or .gitignore in the directory). Every file except .git, node_modules, .DS_Store and local .env files was uploaded. If the folder holds notes, credentials or data that must not leave the machine, add a .sotaignore and deploy again.';
147
181
  }
148
182
  }
149
183
  catch (error) {
150
184
  return archiveError(error);
151
185
  }
152
- return uploadArchive(client, project_id, archive, modeDescription);
186
+ return uploadArchive(client, project_id, archive, modeDescription, options, note);
153
187
  });
154
188
  }
155
189
  //# sourceMappingURL=deploy.js.map