@sentinelconnector/cli 0.0.0-stage → 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 (77) hide show
  1. package/LICENSE +11 -0
  2. package/README.md +218 -2
  3. package/dist/api/client.d.ts +63 -0
  4. package/dist/api/client.js +115 -0
  5. package/dist/api/client.js.map +1 -0
  6. package/dist/api/config.d.ts +21 -0
  7. package/dist/api/config.js +62 -0
  8. package/dist/api/config.js.map +1 -0
  9. package/dist/api/errors.d.ts +34 -0
  10. package/dist/api/errors.js +92 -0
  11. package/dist/api/errors.js.map +1 -0
  12. package/dist/api/http.d.ts +24 -0
  13. package/dist/api/http.js +60 -0
  14. package/dist/api/http.js.map +1 -0
  15. package/dist/auth/credentials.d.ts +48 -0
  16. package/dist/auth/credentials.js +144 -0
  17. package/dist/auth/credentials.js.map +1 -0
  18. package/dist/auth/deviceFlow.d.ts +52 -0
  19. package/dist/auth/deviceFlow.js +106 -0
  20. package/dist/auth/deviceFlow.js.map +1 -0
  21. package/dist/auth/lock.d.ts +2 -0
  22. package/dist/auth/lock.js +86 -0
  23. package/dist/auth/lock.js.map +1 -0
  24. package/dist/auth/store.d.ts +87 -0
  25. package/dist/auth/store.js +281 -0
  26. package/dist/auth/store.js.map +1 -0
  27. package/dist/bin.d.ts +2 -0
  28. package/dist/bin.js +8 -0
  29. package/dist/bin.js.map +1 -0
  30. package/dist/cli.d.ts +11 -0
  31. package/dist/cli.js +111 -0
  32. package/dist/cli.js.map +1 -0
  33. package/dist/commands/mergeChecks.d.ts +9 -0
  34. package/dist/commands/mergeChecks.js +57 -0
  35. package/dist/commands/mergeChecks.js.map +1 -0
  36. package/dist/commands/routes.d.ts +21 -0
  37. package/dist/commands/routes.js +306 -0
  38. package/dist/commands/routes.js.map +1 -0
  39. package/dist/commands/session.d.ts +44 -0
  40. package/dist/commands/session.js +137 -0
  41. package/dist/commands/session.js.map +1 -0
  42. package/dist/context.d.ts +31 -0
  43. package/dist/context.js +42 -0
  44. package/dist/context.js.map +1 -0
  45. package/dist/journeys/mergeChecks.d.ts +70 -0
  46. package/dist/journeys/mergeChecks.js +127 -0
  47. package/dist/journeys/mergeChecks.js.map +1 -0
  48. package/dist/mcp/main.d.ts +13 -0
  49. package/dist/mcp/main.js +39 -0
  50. package/dist/mcp/main.js.map +1 -0
  51. package/dist/mcp/server.d.ts +181 -0
  52. package/dist/mcp/server.js +282 -0
  53. package/dist/mcp/server.js.map +1 -0
  54. package/dist/mcp/untrusted.d.ts +38 -0
  55. package/dist/mcp/untrusted.js +125 -0
  56. package/dist/mcp/untrusted.js.map +1 -0
  57. package/dist/mcp.d.ts +2 -0
  58. package/dist/mcp.js +7 -0
  59. package/dist/mcp.js.map +1 -0
  60. package/dist/mfa.d.ts +12 -0
  61. package/dist/mfa.js +29 -0
  62. package/dist/mfa.js.map +1 -0
  63. package/dist/prompt.d.ts +4 -0
  64. package/dist/prompt.js +54 -0
  65. package/dist/prompt.js.map +1 -0
  66. package/dist/routes/call.d.ts +26 -0
  67. package/dist/routes/call.js +120 -0
  68. package/dist/routes/call.js.map +1 -0
  69. package/dist/routes/catalogue.d.ts +47 -0
  70. package/dist/routes/catalogue.js +69 -0
  71. package/dist/routes/catalogue.js.map +1 -0
  72. package/dist/routes/routes.json +11367 -0
  73. package/dist/skill.d.ts +13 -0
  74. package/dist/skill.js +61 -0
  75. package/dist/skill.js.map +1 -0
  76. package/package.json +40 -4
  77. package/skills/sentinel/SKILL.md +150 -0
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Required checks for Patching (truecms/sentinel#1930): which checks the
3
+ * repository's protection requires before a merge, and the organisation
4
+ * administrator's acknowledgement that lets Autopilot follow them. Shared by
5
+ * the CLI commands and the MCP tool. Contract: "Required checks (#1930)" in
6
+ * truecms/sentinel `docs/PATCHING.md`.
7
+ */
8
+ import type { SentinelClient } from '../api/client.js';
9
+ /** A required check: its name and the App that must post it (null for any source). */
10
+ export interface MergeCheck {
11
+ name: string;
12
+ app_id?: number | null;
13
+ }
14
+ export interface MergeChecks {
15
+ reading: {
16
+ readable: boolean;
17
+ kind: string;
18
+ checks: MergeCheck[];
19
+ merge_queue: boolean;
20
+ errors: string[];
21
+ read_at: string;
22
+ };
23
+ acknowledgement: {
24
+ status: string;
25
+ mode: string;
26
+ checks: MergeCheck[];
27
+ production_branch: string | null;
28
+ acknowledged_at: string | null;
29
+ invalidated_reason: string | null;
30
+ } | null;
31
+ acknowledged: boolean;
32
+ git_connection_id: number | null;
33
+ repository_id: string | null;
34
+ production_branch: string | null;
35
+ seen_checks: string[];
36
+ wording_version: string;
37
+ can_manage: boolean;
38
+ }
39
+ export declare const mergeChecksPath: (site: string) => string;
40
+ /** Read the host now. A 404 means no such site for you, no Patching configuration, or the feature is off. */
41
+ export declare function readMergeChecks(client: SentinelClient, site: string): Promise<MergeChecks>;
42
+ /** What the acknowledgement would agree to, in words. Undefined when it cannot be given now. */
43
+ export declare function refusalBeforeAcknowledging(answer: MergeChecks): string | undefined;
44
+ /**
45
+ * The sentences the person agrees to, word for word as the dashboard shows
46
+ * them (truecms/sentinel `MergeChecksPanel.tsx`), for each wording version
47
+ * this build knows. The server records the version sent, so an unknown one
48
+ * is refused rather than shown in old words.
49
+ */
50
+ export declare const WORDING: Record<string, {
51
+ required: string;
52
+ none: string;
53
+ }>;
54
+ /** The statement for the reading in hand, without the host's check names. */
55
+ export declare function agreementText(answer: MergeChecks): string;
56
+ /** The body: exactly what the person saw, so a changed host answers 409 `merge_checks_changed`. */
57
+ export declare function acknowledgementBody(answer: MergeChecks): Record<string, unknown>;
58
+ export declare function acknowledgeMergeChecks(client: SentinelClient, site: string, seen: MergeChecks, headers: Record<string, string>): Promise<MergeChecks>;
59
+ /** Where the acknowledgement stands, in words. */
60
+ export declare function stateText(answer: MergeChecks): string;
61
+ /**
62
+ * The same report for an agent, in this client's own words only: check names
63
+ * come from the Git host (anyone who can edit the CI can choose them), so
64
+ * they stay in the untrusted data and never reach the agent as instructions.
65
+ */
66
+ export declare function summaryForAgent(answer: MergeChecks): string;
67
+ /** Which App must post a check: a rule may require one, and a same-named check from another does not count. */
68
+ export declare function sourceText(check: MergeCheck): string;
69
+ /** A short report for a terminal. */
70
+ export declare function describeMergeChecks(answer: MergeChecks): string[];
@@ -0,0 +1,127 @@
1
+ import { printable, SentinelError } from '../api/errors.js';
2
+ import { fillPath } from '../routes/catalogue.js';
3
+ export const mergeChecksPath = (site) => fillPath('/api/v1/sites/{site_uuid}/patching/merge-checks', { site_uuid: site });
4
+ /** Read the host now. A 404 means no such site for you, no Patching configuration, or the feature is off. */
5
+ export function readMergeChecks(client, site) {
6
+ return client.request('GET', mergeChecksPath(site));
7
+ }
8
+ /** What the acknowledgement would agree to, in words. Undefined when it cannot be given now. */
9
+ export function refusalBeforeAcknowledging(answer) {
10
+ if (!answer.can_manage)
11
+ return 'Only an administrator of the organisation can acknowledge required checks.';
12
+ if (!answer.reading.readable) {
13
+ return 'The repository rules could not be read in full, so nothing can be acknowledged. Fix the Git connection or its permissions, then read again.';
14
+ }
15
+ if (answer.reading.merge_queue) {
16
+ return 'The branch requires a merge queue, which Autopilot does not support. Nothing can be acknowledged.';
17
+ }
18
+ if (!answer.repository_id || !answer.production_branch) {
19
+ return 'The site has no repository or production branch set in Patching yet.';
20
+ }
21
+ if (!WORDING[answer.wording_version]) {
22
+ return 'The acknowledgement wording has changed since this version of sentinel. Update it, or acknowledge in the dashboard.';
23
+ }
24
+ return undefined;
25
+ }
26
+ /**
27
+ * The sentences the person agrees to, word for word as the dashboard shows
28
+ * them (truecms/sentinel `MergeChecksPanel.tsx`), for each wording version
29
+ * this build knows. The server records the version sent, so an unknown one
30
+ * is refused rather than shown in old words.
31
+ */
32
+ export const WORDING = {
33
+ '2026-11-02': {
34
+ required: 'I confirm these required checks are what must pass before an update reaches production on this website. ' +
35
+ 'Any other check can fail without stopping Autopilot.',
36
+ none: 'I understand Autopilot will merge and deploy on this website even when CI/CD is not green.',
37
+ },
38
+ };
39
+ /** The statement for the reading in hand, without the host's check names. */
40
+ export function agreementText(answer) {
41
+ const words = WORDING[answer.wording_version];
42
+ if (!words)
43
+ return 'The acknowledgement wording is newer than this version of sentinel.';
44
+ return answer.reading.checks.length ? words.required : words.none;
45
+ }
46
+ /** The body: exactly what the person saw, so a changed host answers 409 `merge_checks_changed`. */
47
+ export function acknowledgementBody(answer) {
48
+ return {
49
+ checks: answer.reading.checks.map((check) => ({ name: check.name, app_id: check.app_id ?? null })),
50
+ wording_version: answer.wording_version,
51
+ git_connection_id: answer.git_connection_id,
52
+ repository_id: answer.repository_id,
53
+ production_branch: answer.production_branch,
54
+ };
55
+ }
56
+ export async function acknowledgeMergeChecks(client, site, seen, headers) {
57
+ const refusal = refusalBeforeAcknowledging(seen);
58
+ if (refusal)
59
+ throw new SentinelError(refusal, 10);
60
+ return client.request('POST', `${mergeChecksPath(site)}/acknowledgement`, {
61
+ body: acknowledgementBody(seen),
62
+ headers,
63
+ });
64
+ }
65
+ /** Where the acknowledgement stands, in words. */
66
+ export function stateText(answer) {
67
+ const ack = answer.acknowledgement;
68
+ if (!ack) {
69
+ return 'Never acknowledged: the strict rule applies, so Autopilot pauses at any failed check.';
70
+ }
71
+ if (answer.acknowledged) {
72
+ const when = ack.acknowledged_at ? ` on ${printable(ack.acknowledged_at)}` : '';
73
+ return `Acknowledged${when}: Autopilot follows the repository's required checks.`;
74
+ }
75
+ // A reason code such as `requirement_removed`; anything else is left out.
76
+ const why = ack.invalidated_reason && /^[a-z_]{1,40}$/.test(ack.invalidated_reason) ? ` (${ack.invalidated_reason})` : '';
77
+ return (`No longer current${why}: Autopilot runs hold as merge_checks_changed until an administrator ` +
78
+ 'acknowledges again. It does not fall back to the strict rule.');
79
+ }
80
+ /**
81
+ * The same report for an agent, in this client's own words only: check names
82
+ * come from the Git host (anyone who can edit the CI can choose them), so
83
+ * they stay in the untrusted data and never reach the agent as instructions.
84
+ */
85
+ export function summaryForAgent(answer) {
86
+ const count = answer.reading.checks.length;
87
+ const reading = !answer.reading.readable
88
+ ? 'The required checks are unknown: the rules could not be read in full, which is never treated as none.'
89
+ : count === 0
90
+ ? 'The repository requires no check on its production branch.'
91
+ : `The repository requires ${count} check${count === 1 ? '' : 's'} on its production branch (names in the data).`;
92
+ const queue = answer.reading.merge_queue ? ' The branch requires a merge queue, which Autopilot does not support.' : '';
93
+ return `${reading}${queue} ${stateText(answer)}`;
94
+ }
95
+ /** Which App must post a check: a rule may require one, and a same-named check from another does not count. */
96
+ export function sourceText(check) {
97
+ return check.app_id === null || check.app_id === undefined ? 'from any source' : `only from App ${check.app_id}`;
98
+ }
99
+ /** A short report for a terminal. */
100
+ export function describeMergeChecks(answer) {
101
+ const lines = [];
102
+ const branch = printable(answer.production_branch ?? '?');
103
+ if (!answer.reading.readable) {
104
+ lines.push(`Required checks on ${branch}: unknown. The rules could not be read in full, which is never treated as none.`);
105
+ for (const error of answer.reading.errors)
106
+ lines.push(` ${printable(error)}`);
107
+ }
108
+ else if (answer.reading.checks.length === 0) {
109
+ lines.push(`Required checks on ${branch}: none.`);
110
+ }
111
+ else {
112
+ lines.push(`Required checks on ${branch}:`);
113
+ for (const check of answer.reading.checks)
114
+ lines.push(` - ${printable(check.name)} (${sourceText(check)})`);
115
+ }
116
+ if (answer.reading.merge_queue)
117
+ lines.push('The branch requires a merge queue: Autopilot pauses (merge_queue_unsupported).');
118
+ if (answer.seen_checks.length) {
119
+ lines.push(`Other checks seen on recent pull requests, not required: ${answer.seen_checks.map(printable).join(', ')}.`);
120
+ }
121
+ lines.push(stateText(answer));
122
+ lines.push(answer.can_manage
123
+ ? 'You can acknowledge: `sentinel patching merge-checks acknowledge <site>`.'
124
+ : 'Only an administrator of the organisation can acknowledge.');
125
+ return lines;
126
+ }
127
+ //# sourceMappingURL=mergeChecks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeChecks.js","sourceRoot":"","sources":["../../src/journeys/mergeChecks.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,S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AAC,GAAG,CAAC,CAAC;IAC1H,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9B,KAAK,CAAC,IAAI,CACR,MAAM,CAAC,UAAU;QACf,CAAC,CAAC,2EAA2E;QAC7E,CAAC,CAAC,4DAA4D,CACjE,CAAC;IACF,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
2
+ import type { Fetch } from '../api/http.js';
3
+ import { type CredentialStore } from '../auth/store.js';
4
+ import { CustomerMcp } from './server.js';
5
+ export interface StartOptions {
6
+ env?: NodeJS.ProcessEnv;
7
+ fetch?: Fetch;
8
+ transport?: Transport;
9
+ store?: () => Promise<CredentialStore>;
10
+ log?: (line: string) => void;
11
+ }
12
+ export declare function createCustomerMcp(options?: StartOptions): Promise<CustomerMcp>;
13
+ export declare function main(options?: StartOptions): Promise<number>;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Start the customer MCP server over stdio. It acts as one person: with
3
+ * SENTINEL_TOKEN (a personal API token) when set, otherwise the sign-in that
4
+ * `sentinel login` stored for SENTINEL_API_URL. stdout is the MCP protocol;
5
+ * everything else goes to stderr.
6
+ */
7
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
8
+ import { createSentinelClient } from '../api/client.js';
9
+ import { resolveApiUrl } from '../api/config.js';
10
+ import { printable, redact, SentinelError } from '../api/errors.js';
11
+ import { resolveCredential } from '../auth/credentials.js';
12
+ import { openStore } from '../auth/store.js';
13
+ import { CustomerMcp } from './server.js';
14
+ export async function createCustomerMcp(options = {}) {
15
+ const env = options.env ?? process.env;
16
+ const apiUrl = resolveApiUrl(undefined, env);
17
+ const credential = await resolveCredential(apiUrl, options.store ?? (() => openStore(env)), env, {
18
+ fetch: options.fetch,
19
+ });
20
+ const client = createSentinelClient({ apiUrl, credential, client: 'mcp', env, ...(options.fetch ? { fetch: options.fetch } : {}) });
21
+ // Also checks the environment before anything else is sent.
22
+ const me = await client.whoami();
23
+ return new CustomerMcp({ client, me, env });
24
+ }
25
+ export async function main(options = {}) {
26
+ const log = options.log ?? ((line) => process.stderr.write(`${printable(redact(line))}\n`));
27
+ try {
28
+ const mcp = await createCustomerMcp(options);
29
+ await mcp.server.connect(options.transport ?? new StdioServerTransport());
30
+ log(`sentinel-mcp ready: ${mcp.me.user.email} on ${mcp.me.environment}.`);
31
+ return 0;
32
+ }
33
+ catch (error) {
34
+ const message = error instanceof Error ? error.message : String(error);
35
+ log(`sentinel-mcp did not start: ${message}`);
36
+ return error instanceof SentinelError ? error.exitCode : 1;
37
+ }
38
+ }
39
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/mcp/main.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAGjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAwB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAU1C,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,UAAwB,EAAE;IAChE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACvC,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IAC7C,MAAM,UAAU,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC,GAAG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AAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,GAAG,CAAC,+BAA+B,OAAO,EAAE,CAAC,CAAC;QAC9C,OAAO,KAAK,YAAY,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC"}
@@ -0,0 +1,181 @@
1
+ /**
2
+ * The customer MCP server (epic truecms/sentinel#1618): one person's Sentinel
3
+ * account for an AI agent. A few general tools reach every customer route by
4
+ * name, so the agent's tool list stays short; the server enforces every
5
+ * check. Rules the agent cannot get round:
6
+ *
7
+ * - A change needs `confirm: true`; the first call only says what would be sent.
8
+ * - `mfa` steps (deploying, accepting terms, acknowledging required checks,
9
+ * secrets, members) are never run here: the tool hands back a dashboard
10
+ * link, and the agent never asks for or relays a code.
11
+ * - Everything the API returns goes back as untrusted data.
12
+ */
13
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
14
+ import type { SentinelClient, Whoami } from '../api/client.js';
15
+ import { type ToolResult } from './untrusted.js';
16
+ export declare const SERVER_NAME = "sentinel-mcp";
17
+ export declare const SERVER_VERSION = "0.0.0";
18
+ export declare const SKILL_URI = "sentinel://skill";
19
+ export declare const TOOLS: ({
20
+ name: string;
21
+ description: string;
22
+ inputSchema: {
23
+ type: string;
24
+ properties: {
25
+ query: {
26
+ type: string;
27
+ description: string;
28
+ };
29
+ policy: {
30
+ type: string;
31
+ enum: string[];
32
+ };
33
+ operation?: undefined;
34
+ site_uuid?: undefined;
35
+ };
36
+ required?: undefined;
37
+ };
38
+ annotations: {
39
+ readOnlyHint: boolean;
40
+ openWorldHint: boolean;
41
+ destructiveHint?: undefined;
42
+ };
43
+ } | {
44
+ name: string;
45
+ description: string;
46
+ inputSchema: {
47
+ type: string;
48
+ properties: {
49
+ operation: {
50
+ type: string;
51
+ description: string;
52
+ };
53
+ query?: undefined;
54
+ policy?: undefined;
55
+ site_uuid?: undefined;
56
+ };
57
+ required: string[];
58
+ };
59
+ annotations: {
60
+ readOnlyHint: boolean;
61
+ openWorldHint: boolean;
62
+ destructiveHint?: undefined;
63
+ };
64
+ } | {
65
+ name: string;
66
+ description: string;
67
+ inputSchema: {
68
+ type: string;
69
+ properties: {
70
+ path: {
71
+ type: string;
72
+ description: string;
73
+ };
74
+ query: {
75
+ type: string;
76
+ description: string;
77
+ };
78
+ body: {
79
+ type: string;
80
+ description: string;
81
+ };
82
+ operation: {
83
+ type: string;
84
+ description: string;
85
+ };
86
+ policy?: undefined;
87
+ site_uuid?: undefined;
88
+ };
89
+ required: string[];
90
+ };
91
+ annotations: {
92
+ readOnlyHint: boolean;
93
+ openWorldHint: boolean;
94
+ destructiveHint?: undefined;
95
+ };
96
+ } | {
97
+ name: string;
98
+ description: string;
99
+ inputSchema: {
100
+ type: string;
101
+ properties: {
102
+ confirm: {
103
+ type: string;
104
+ description: string;
105
+ };
106
+ path: {
107
+ type: string;
108
+ description: string;
109
+ };
110
+ query: {
111
+ type: string;
112
+ description: string;
113
+ };
114
+ body: {
115
+ type: string;
116
+ description: string;
117
+ };
118
+ operation: {
119
+ type: string;
120
+ description: string;
121
+ };
122
+ policy?: undefined;
123
+ site_uuid?: undefined;
124
+ };
125
+ required: string[];
126
+ };
127
+ annotations: {
128
+ readOnlyHint: boolean;
129
+ destructiveHint: boolean;
130
+ openWorldHint: boolean;
131
+ };
132
+ } | {
133
+ name: string;
134
+ description: string;
135
+ inputSchema: {
136
+ type: string;
137
+ properties: {
138
+ site_uuid: {
139
+ type: string;
140
+ description: string;
141
+ };
142
+ query?: undefined;
143
+ policy?: undefined;
144
+ operation?: undefined;
145
+ };
146
+ required: string[];
147
+ };
148
+ annotations: {
149
+ readOnlyHint: boolean;
150
+ openWorldHint: boolean;
151
+ destructiveHint?: undefined;
152
+ };
153
+ })[];
154
+ /** The server's instructions: who it acts as, where, and the rules. */
155
+ export declare function instructions(me: Whoami, apiUrl: string): string;
156
+ export interface CustomerMcpOptions {
157
+ client: SentinelClient;
158
+ me: Whoami;
159
+ env?: NodeJS.ProcessEnv;
160
+ }
161
+ export declare class CustomerMcp {
162
+ readonly server: Server;
163
+ readonly client: SentinelClient;
164
+ readonly me: Whoami;
165
+ private readonly env;
166
+ constructor(options: CustomerMcpOptions);
167
+ private link;
168
+ /** One tool call. Errors come back as a result, never thrown, and never hold a credential. */
169
+ call(name: string, args: Record<string, unknown>): Promise<ToolResult>;
170
+ private failure;
171
+ private find;
172
+ private describe;
173
+ /** Steps the agent may not take: the words and link for the person. */
174
+ private notHere;
175
+ private read;
176
+ /** A file the API returned is described, not passed on. */
177
+ private answer;
178
+ private change;
179
+ private mergeChecks;
180
+ }
181
+ export declare const ROUTE_COUNT: number;