@kylewadegrove/cutline-mcp-cli-staging 0.1.0 → 0.2.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.
@@ -0,0 +1,64 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { getConfig } from './config.js';
3
+ import { loadConfig, saveConfig } from './config-store.js';
4
+ function installIdKey(staging) {
5
+ return staging ? 'agentInstallIdStaging' : 'agentInstallId';
6
+ }
7
+ export async function registerAgentInstall(input) {
8
+ const key = installIdKey(input.staging);
9
+ const existing = loadConfig();
10
+ const persistedInstallId = typeof existing[key] === 'string' ? existing[key] : null;
11
+ if (persistedInstallId)
12
+ return persistedInstallId;
13
+ const { BASE_URL } = getConfig({ staging: input.staging });
14
+ const installationKey = createHash('sha256')
15
+ .update(`${input.projectRoot}:${input.staging ? 'staging' : 'production'}`)
16
+ .digest('hex')
17
+ .slice(0, 32);
18
+ const workspaceId = createHash('sha256').update(input.projectRoot).digest('hex').slice(0, 24);
19
+ try {
20
+ const response = await fetch(`${BASE_URL}/api/agent/register`, {
21
+ method: 'POST',
22
+ headers: {
23
+ 'Content-Type': 'application/json',
24
+ Authorization: `Bearer ${input.idToken}`,
25
+ },
26
+ body: JSON.stringify({
27
+ installation_key: installationKey,
28
+ source_surface: input.sourceSurface,
29
+ host_agent: input.hostAgent || 'cutline-mcp-cli',
30
+ workspace_id: workspaceId,
31
+ }),
32
+ });
33
+ if (!response.ok)
34
+ return null;
35
+ const payload = await response.json();
36
+ if (!payload.install_id)
37
+ return null;
38
+ saveConfig({ [key]: payload.install_id });
39
+ return payload.install_id;
40
+ }
41
+ catch {
42
+ return null;
43
+ }
44
+ }
45
+ export async function trackAgentEvent(input) {
46
+ const { BASE_URL } = getConfig({ staging: input.staging });
47
+ try {
48
+ await fetch(`${BASE_URL}/api/agent/event`, {
49
+ method: 'POST',
50
+ headers: {
51
+ 'Content-Type': 'application/json',
52
+ Authorization: `Bearer ${input.idToken}`,
53
+ },
54
+ body: JSON.stringify({
55
+ install_id: input.installId,
56
+ event_name: input.eventName,
57
+ event_properties: input.eventProperties || {},
58
+ }),
59
+ });
60
+ }
61
+ catch {
62
+ // Best effort telemetry; never block CLI command success.
63
+ }
64
+ }
@@ -2,6 +2,8 @@ export interface McpConfig {
2
2
  refreshToken?: string;
3
3
  environment?: 'production' | 'staging';
4
4
  apiKey?: string;
5
+ agentInstallId?: string;
6
+ agentInstallIdStaging?: string;
5
7
  }
6
8
  export declare function saveConfig(config: McpConfig): void;
7
9
  export declare function loadConfig(): McpConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kylewadegrove/cutline-mcp-cli-staging",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "CLI and MCP servers for Cutline — authenticate, then run constraint-aware MCP servers in Cursor or any MCP client.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",