@agentteams/cli 0.1.84 → 0.1.86

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 (67) hide show
  1. package/.eslintcache +1 -1
  2. package/dist/api/document.d.ts +10 -1
  3. package/dist/api/document.d.ts.map +1 -1
  4. package/dist/api/document.js +3 -1
  5. package/dist/api/document.js.map +1 -1
  6. package/dist/api/plan.d.ts +2 -0
  7. package/dist/api/plan.d.ts.map +1 -1
  8. package/dist/api/plan.js.map +1 -1
  9. package/dist/auth/credentialStore.d.ts +30 -1
  10. package/dist/auth/credentialStore.d.ts.map +1 -1
  11. package/dist/auth/credentialStore.js +110 -24
  12. package/dist/auth/credentialStore.js.map +1 -1
  13. package/dist/auth/personalTokenClient.d.ts +34 -0
  14. package/dist/auth/personalTokenClient.d.ts.map +1 -1
  15. package/dist/auth/personalTokenClient.js +73 -6
  16. package/dist/auth/personalTokenClient.js.map +1 -1
  17. package/dist/auth/personalTokenStore.d.ts +3 -2
  18. package/dist/auth/personalTokenStore.d.ts.map +1 -1
  19. package/dist/auth/personalTokenStore.js +1 -1
  20. package/dist/auth/personalTokenStore.js.map +1 -1
  21. package/dist/auth/refreshLock.d.ts +74 -0
  22. package/dist/auth/refreshLock.d.ts.map +1 -0
  23. package/dist/auth/refreshLock.js +225 -0
  24. package/dist/auth/refreshLock.js.map +1 -0
  25. package/dist/commands/attachment.d.ts.map +1 -1
  26. package/dist/commands/attachment.js +10 -2
  27. package/dist/commands/attachment.js.map +1 -1
  28. package/dist/commands/convention.d.ts.map +1 -1
  29. package/dist/commands/convention.js +60 -5
  30. package/dist/commands/convention.js.map +1 -1
  31. package/dist/commands/document.d.ts +3 -0
  32. package/dist/commands/document.d.ts.map +1 -1
  33. package/dist/commands/document.js +18 -1
  34. package/dist/commands/document.js.map +1 -1
  35. package/dist/commands/plan.d.ts +15 -0
  36. package/dist/commands/plan.d.ts.map +1 -1
  37. package/dist/commands/plan.js +28 -0
  38. package/dist/commands/plan.js.map +1 -1
  39. package/dist/index.js +10 -3
  40. package/dist/index.js.map +1 -1
  41. package/dist/mcp/context.d.ts +9 -0
  42. package/dist/mcp/context.d.ts.map +1 -1
  43. package/dist/mcp/context.js +5 -1
  44. package/dist/mcp/context.js.map +1 -1
  45. package/dist/mcp/guides.d.ts +50 -0
  46. package/dist/mcp/guides.d.ts.map +1 -0
  47. package/dist/mcp/guides.js +141 -0
  48. package/dist/mcp/guides.js.map +1 -0
  49. package/dist/mcp/server.d.ts.map +1 -1
  50. package/dist/mcp/server.js +20 -5
  51. package/dist/mcp/server.js.map +1 -1
  52. package/dist/mcp/writeTools.d.ts +25 -0
  53. package/dist/mcp/writeTools.d.ts.map +1 -0
  54. package/dist/mcp/writeTools.js +161 -0
  55. package/dist/mcp/writeTools.js.map +1 -0
  56. package/dist/utils/authFormat.d.ts +18 -0
  57. package/dist/utils/authFormat.d.ts.map +1 -0
  58. package/dist/utils/authFormat.js +130 -0
  59. package/dist/utils/authFormat.js.map +1 -0
  60. package/dist/utils/config.d.ts +10 -1
  61. package/dist/utils/config.d.ts.map +1 -1
  62. package/dist/utils/config.js +23 -4
  63. package/dist/utils/config.js.map +1 -1
  64. package/dist/utils/errors.d.ts.map +1 -1
  65. package/dist/utils/errors.js +20 -1
  66. package/dist/utils/errors.js.map +1 -1
  67. package/package.json +1 -1
@@ -0,0 +1,141 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { join, resolve } from 'node:path';
3
+ import { findProjectConfig } from '../utils/config.js';
4
+ import httpClient from '../utils/httpClient.js';
5
+ /**
6
+ * Platform-guide loader for the MCP write path.
7
+ *
8
+ * Guides are read from the local `.agentteams/platform/` copy when this session
9
+ * actually sits in the bound project: the write contract only needs the body
10
+ * plus the hash the server will compare against, and both are written by
11
+ * `agentteams convention download`.
12
+ *
13
+ * That local copy cannot be assumed, though. `context.ts` resolves credentials
14
+ * and `projectId` from CLI options and `AGENTTEAMS_*` env vars precisely because
15
+ * an externally spawned MCP server's cwd may sit outside the project — or inside
16
+ * a *different* one. So the local path is used only when the caller hands over a
17
+ * verified project root, and the server is the fallback: `GET /api/platform/guides`
18
+ * returns body and hash together, which is always a consistent pair.
19
+ *
20
+ * This module must not import the MCP SDK (see `test/mcp-boundary.test.ts`).
21
+ */
22
+ const CONVENTION_DIR = '.agentteams';
23
+ const PLATFORM_DIR = 'platform';
24
+ const MANIFEST_FILE = 'conventions.manifest.json';
25
+ const RESYNC_HINT = "Run 'agentteams convention download' and retry.";
26
+ /** Record kinds whose guide can be handed to an agent. Document is the only write-enabled kind so far. */
27
+ export const GUIDE_RECORD_KINDS = ['document'];
28
+ const GUIDE_FILE_NAMES = {
29
+ document: 'document-guide.md',
30
+ };
31
+ /** Project root = the directory containing `.agentteams/config.json`. */
32
+ export function findGuideProjectRoot(cwd = process.cwd()) {
33
+ const configPath = findProjectConfig(cwd);
34
+ if (!configPath) {
35
+ return null;
36
+ }
37
+ return resolve(configPath, '..', '..');
38
+ }
39
+ function readManifestHashes(projectRoot) {
40
+ const manifestPath = join(projectRoot, CONVENTION_DIR, MANIFEST_FILE);
41
+ if (!existsSync(manifestPath)) {
42
+ return null;
43
+ }
44
+ try {
45
+ const parsed = JSON.parse(readFileSync(manifestPath, 'utf-8'));
46
+ return parsed?.platformGuideHashes ?? null;
47
+ }
48
+ catch {
49
+ // A corrupt manifest is indistinguishable from a missing one for this purpose:
50
+ // both mean "the local hash is unknown", and both are fixed by re-syncing.
51
+ return null;
52
+ }
53
+ }
54
+ function resolveGuideFileName(recordKind) {
55
+ const fileName = GUIDE_FILE_NAMES[recordKind];
56
+ if (!fileName) {
57
+ throw new Error(`Unknown guide record kind: ${recordKind}. Supported: ${GUIDE_RECORD_KINDS.join(', ')}`);
58
+ }
59
+ return fileName;
60
+ }
61
+ /**
62
+ * Load one platform guide from a local project copy.
63
+ *
64
+ * Returns `null` when this session has no usable local copy — the caller then
65
+ * falls back to the server rather than failing, so a session bound to a project
66
+ * it does not sit in can still follow the guide-first contract.
67
+ */
68
+ export function loadLocalPlatformGuide(recordKind, projectRoot) {
69
+ const fileName = resolveGuideFileName(recordKind);
70
+ if (!projectRoot) {
71
+ return null;
72
+ }
73
+ const filePath = join(projectRoot, CONVENTION_DIR, PLATFORM_DIR, fileName);
74
+ if (!existsSync(filePath)) {
75
+ return null;
76
+ }
77
+ const hashes = readManifestHashes(projectRoot);
78
+ return {
79
+ recordKind,
80
+ fileName,
81
+ source: 'local',
82
+ filePath,
83
+ content: readFileSync(filePath, 'utf-8'),
84
+ guideHash: hashes?.[fileName] ?? null,
85
+ };
86
+ }
87
+ /** Read one guide straight from the server, where body and hash always match. */
88
+ export async function fetchPlatformGuide(recordKind, apiUrl, headers) {
89
+ const fileName = resolveGuideFileName(recordKind);
90
+ const normalizedApiUrl = apiUrl.endsWith('/') ? apiUrl.slice(0, -1) : apiUrl;
91
+ const response = await httpClient.get(`${normalizedApiUrl}/api/platform/guides`, { headers });
92
+ const guides = (response.data?.data ?? []);
93
+ const guide = Array.isArray(guides) ? guides.find((item) => item?.fileName === fileName) : undefined;
94
+ if (!guide || typeof guide.content !== 'string') {
95
+ throw new Error(`Platform guide ${fileName} is not published by ${normalizedApiUrl}.`);
96
+ }
97
+ return {
98
+ recordKind,
99
+ fileName,
100
+ source: 'server',
101
+ content: guide.content,
102
+ guideHash: typeof guide.hash === 'string' && guide.hash.length > 0 ? guide.hash : null,
103
+ };
104
+ }
105
+ /**
106
+ * Resolve the guide an agent must follow before a write: local copy first,
107
+ * server otherwise.
108
+ *
109
+ * `projectRoot` is the root this MCP session is actually bound to. It is passed
110
+ * in (not discovered here) so a cwd that happens to sit in some *other* project
111
+ * cannot feed that project's stale hash into this project's write — which would
112
+ * produce a `GUIDE_OUTDATED` 409 whose documented fix (`convention download`)
113
+ * does not resolve it.
114
+ */
115
+ export async function resolvePlatformGuide(recordKind, options) {
116
+ const local = loadLocalPlatformGuide(recordKind, options.projectRoot ?? null);
117
+ if (local) {
118
+ return local;
119
+ }
120
+ try {
121
+ return await fetchPlatformGuide(recordKind, options.apiUrl, options.headers);
122
+ }
123
+ catch (error) {
124
+ const reason = error instanceof Error ? error.message : String(error);
125
+ throw new Error(`Could not load the ${resolveGuideFileName(recordKind)} platform guide. ` +
126
+ `No local copy is available for this session, and reading it from the server failed: ${reason}. ` +
127
+ `Run 'agentteams convention download' in the project, or check the API connection.`);
128
+ }
129
+ }
130
+ /**
131
+ * Human-readable note explaining why `guideHash` is absent, so an agent reading
132
+ * the tool output knows the freshness check is not being enforced for this call.
133
+ */
134
+ export function describeMissingGuideHash(guide) {
135
+ if (guide.guideHash) {
136
+ return null;
137
+ }
138
+ return (`No recorded hash for ${guide.fileName} — this project's manifest predates per-guide hashes. ` +
139
+ `Writes will skip the guide freshness check. ${RESYNC_HINT}`);
140
+ }
141
+ //# sourceMappingURL=guides.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guides.js","sourceRoot":"","sources":["../../src/mcp/guides.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAEhD;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,cAAc,GAAG,aAAa,CAAC;AACrC,MAAM,YAAY,GAAG,UAAU,CAAC;AAChC,MAAM,aAAa,GAAG,2BAA2B,CAAC;AAElD,MAAM,WAAW,GAAG,iDAAiD,CAAC;AAEtE,0GAA0G;AAC1G,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,UAAU,CAAU,CAAC;AAGxD,MAAM,gBAAgB,GAAoC;IACxD,QAAQ,EAAE,mBAAmB;CAC9B,CAAC;AA2BF,yEAAyE;AACzE,MAAM,UAAU,oBAAoB,CAAC,MAAc,OAAO,CAAC,GAAG,EAAE;I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@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAoB,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAc,KAAK,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAExF,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAO1E,eAAO,MAAM,eAAe,oBAAoB,CAAC;AAEjD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,GAAE,MAAoB,GAAG,SAAS,CAOjG;AAyED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAetG"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAoB,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAc,KAAK,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAExF,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAQ1E,eAAO,MAAM,eAAe,oBAAoB,CAAC;AAEjD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,GAAE,MAAoB,GAAG,SAAS,CAOjG;AAwFD;;;GAGG;AACH,wBAAsB,cAAc,CAAC,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAetG"}
@@ -5,6 +5,7 @@ import { handleError } from '../utils/errors.js';
5
5
  import { resolveMcpToolContext } from './context.js';
6
6
  import { getResourceSpecs } from './resources.js';
7
7
  import { createCliContextToolsClient, getToolSpecs } from './tools.js';
8
+ import { getWriteToolSpecs } from './writeTools.js';
8
9
  const require = createRequire(import.meta.url);
9
10
  const pkg = require('../../package.json');
10
11
  export const MCP_SERVER_NAME = '@agentteams/cli';
@@ -18,17 +19,31 @@ export const MCP_SERVER_NAME = '@agentteams/cli';
18
19
  * pinned beta only touches this adapter.
19
20
  */
20
21
  export function createMcpServer(context, version = pkg.version) {
21
- // Read-only surface: tools plus single-entity resource templates. Prompts
22
- // and Extensions stay out of scope for Phase 1.
22
+ // Tools (read + document writes) plus single-entity resource templates.
23
+ // Prompts and Extensions stay out of scope.
23
24
  const server = new McpServer({ name: MCP_SERVER_NAME, version }, { capabilities: { tools: {}, resources: {} } });
24
25
  registerTools(server, context);
25
26
  registerResources(server, context);
26
27
  return server;
27
28
  }
28
- /** The single `registerTool` loop — tool envelopes are assembled only here. */
29
+ /**
30
+ * The single `registerTool` loop — tool envelopes are assembled only here.
31
+ *
32
+ * Read specs come from the shared `@agentteams/context-tools` package; write
33
+ * specs are CLI-local by design (see `writeTools.ts`). Both are flattened to the
34
+ * same `(args) => unknown` shape first so there is still exactly one loop.
35
+ */
29
36
  function registerTools(server, context) {
30
37
  const client = createCliContextToolsClient(context);
31
- for (const spec of getToolSpecs()) {
38
+ const readTools = getToolSpecs().map((spec) => ({
39
+ ...spec,
40
+ invoke: (args) => spec.handler(args, client),
41
+ }));
42
+ const writeTools = getWriteToolSpecs().map((spec) => ({
43
+ ...spec,
44
+ invoke: (args) => spec.handler(args, context),
45
+ }));
46
+ for (const spec of [...readTools, ...writeTools]) {
32
47
  server.registerTool(spec.name, {
33
48
  title: spec.title,
34
49
  description: spec.description,
@@ -37,7 +52,7 @@ function registerTools(server, context) {
37
52
  try {
38
53
  // The SDK has already validated `args` against `spec.inputSchema`
39
54
  // before this callback runs, so the record cast is safe.
40
- const result = await spec.handler(args, client);
55
+ const result = await spec.invoke(args);
41
56
  return { content: [{ type: 'text', text: JSON.stringify(result) }] };
42
57
  }
43
58
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp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AC"}
@@ -0,0 +1,25 @@
1
+ import { z } from 'zod';
2
+ import type { McpToolContext } from './context.js';
3
+ /**
4
+ * MCP **write** tools. CLI-only on purpose.
5
+ *
6
+ * These are deliberately *not* added to `@agentteams/context-tools`:
7
+ * `desktop/src/main/localAgent/directRunner.ts` advertises every context-tool
8
+ * definition to the model without filtering, so a write tool placed there would
9
+ * be handed to Direct BYOK conversations — the exact `DESKTOP_LIMITED` boundary
10
+ * that must not grant blanket project write access.
11
+ *
12
+ * The spec shape mirrors `ContextToolSpec`, but is declared locally so the shared
13
+ * read package stays read-only. No MCP SDK import belongs here — `server.ts` is
14
+ * the only adapter (see `test/mcp-boundary.test.ts`).
15
+ */
16
+ export interface McpWriteToolSpec {
17
+ name: string;
18
+ title: string;
19
+ description: string;
20
+ inputSchema: z.ZodType<Record<string, unknown>>;
21
+ handler(args: Record<string, unknown>, context: McpToolContext): Promise<unknown>;
22
+ }
23
+ /** Every write tool the CLI MCP server exposes, in registration order. */
24
+ export declare function getWriteToolSpecs(): McpWriteToolSpec[];
25
+ //# sourceMappingURL=writeTools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeTools.d.ts","sourceRoot":"","sources":["../../src/mcp/writeTools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGnD;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAChD,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACnF;AAyLD,0EAA0E;AAC1E,wBAAgB,iBAAiB,IAAI,gBAAgB,EAAE,CAEtD"}
@@ -0,0 +1,161 @@
1
+ import { stripContextEntityIdPrefix } from '@agentteams/context-tools';
2
+ import { z } from 'zod';
3
+ import { createDocument, deleteDocument, updateDocument } from '../api/document.js';
4
+ import { GUIDE_RECORD_KINDS, describeMissingGuideHash, resolvePlatformGuide } from './guides.js';
5
+ const GUIDE_FIRST = 'Call agentteams_guide_get("document") first and follow that guide.';
6
+ const TAG_POLICY = 'You cannot set confirmed tags. Anything you pass in suggestedTags is a suggestion for a human to confirm.';
7
+ const PROJECT_SCOPE = 'Scoped to the single project this MCP server is bound to. There is no projectId argument — a different project cannot be reached from here.';
8
+ const guideHashField = z
9
+ .string()
10
+ .min(1)
11
+ .optional()
12
+ .describe('guideHash from agentteams_guide_get. If it is stale the server rejects the write with GUIDE_OUTDATED.');
13
+ const idempotencyKeyField = z
14
+ .string()
15
+ .min(1)
16
+ .optional()
17
+ .describe('Retry-safe key. Repeating the same call with the same key replays the first result instead of redoing it.');
18
+ const expectedUpdatedAtField = z
19
+ .string()
20
+ .min(1)
21
+ .optional()
22
+ .describe("The document's updatedAt as you last read it. The write is rejected if someone else changed the document since.");
23
+ const suggestedTagsField = z
24
+ .array(z.string().min(1))
25
+ .optional()
26
+ .describe('Suggested tags (not confirmed). Reuse existing project tags where they fit.');
27
+ const visibilityField = z
28
+ .enum(['PRIVATE', 'PROJECT'])
29
+ .optional()
30
+ .describe('PRIVATE (default) is author-only; PROJECT is visible to every project member.');
31
+ /** Credentials can expire mid-session, so headers are resolved per call, never captured. */
32
+ const auth = (context) => context.resolveHeaders?.() ?? Promise.resolve(context.headers);
33
+ /** Drop keys the caller omitted so an absent optional never reaches the server as `undefined`. */
34
+ const definedFields = (fields) => Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined));
35
+ const guideGetSpec = {
36
+ name: 'agentteams_guide_get',
37
+ title: 'Get AgentTeams Record Guide',
38
+ description: [
39
+ 'Fetch the platform guide that governs how a record type must be written.',
40
+ 'Reads this project’s local copy when the session sits in it, and falls back to the server otherwise.',
41
+ 'Returns the full guide body plus the guideHash to pass to the matching write tool.',
42
+ 'Read this before any AgentTeams write tool call — the rules it states (visibility, tag policy, structure) are enforced server-side.',
43
+ 'If it reports that the local guide hash is unknown, run `agentteams convention download` in the project.',
44
+ ].join(' '),
45
+ inputSchema: z.strictObject({
46
+ recordKind: z
47
+ .enum(GUIDE_RECORD_KINDS)
48
+ .describe('Record type whose guide you need. Only "document" is write-enabled so far.'),
49
+ }),
50
+ handler: async (args, context) => {
51
+ const guide = await resolvePlatformGuide(args.recordKind, {
52
+ projectRoot: context.projectRoot,
53
+ apiUrl: context.apiUrl,
54
+ headers: await auth(context),
55
+ });
56
+ const warning = describeMissingGuideHash(guide);
57
+ return {
58
+ recordKind: guide.recordKind,
59
+ fileName: guide.fileName,
60
+ source: guide.source,
61
+ ...(guide.filePath ? { filePath: guide.filePath } : {}),
62
+ guideHash: guide.guideHash,
63
+ content: guide.content,
64
+ ...(warning ? { warning } : {}),
65
+ };
66
+ },
67
+ };
68
+ const documentCreateSpec = {
69
+ name: 'agentteams_document_create',
70
+ title: 'Create AgentTeams Document',
71
+ description: [
72
+ 'Create a document in this project’s document library.',
73
+ GUIDE_FIRST,
74
+ TAG_POLICY,
75
+ PROJECT_SCOPE,
76
+ 'Returns the created document id and webUrl.',
77
+ ].join(' '),
78
+ inputSchema: z.strictObject({
79
+ title: z.string().min(1).max(255).describe('Document title.'),
80
+ body: z.string().min(1).describe('Document body in Markdown.'),
81
+ suggestedTags: suggestedTagsField,
82
+ visibility: visibilityField,
83
+ guideHash: guideHashField,
84
+ idempotencyKey: idempotencyKeyField,
85
+ }),
86
+ handler: async (args, context) => {
87
+ return createDocument(context.apiUrl, context.projectId, await auth(context), definedFields({
88
+ title: args.title,
89
+ body: args.body,
90
+ suggestedTags: args.suggestedTags,
91
+ visibility: args.visibility,
92
+ guideHash: args.guideHash,
93
+ idempotencyKey: args.idempotencyKey,
94
+ }));
95
+ },
96
+ };
97
+ const documentUpdateSpec = {
98
+ name: 'agentteams_document_update',
99
+ title: 'Update AgentTeams Document',
100
+ description: [
101
+ 'Update an existing document in this project. Only the fields you pass are changed.',
102
+ GUIDE_FIRST,
103
+ TAG_POLICY,
104
+ 'Pass expectedUpdatedAt (from agentteams_document_get) so a concurrent edit is rejected rather than silently overwritten.',
105
+ PROJECT_SCOPE,
106
+ ].join(' '),
107
+ inputSchema: z.strictObject({
108
+ id: z.string().min(1).describe('Document id (bare uuid or agentteams_doc_-prefixed).'),
109
+ title: z.string().min(1).max(255).optional().describe('New title.'),
110
+ body: z.string().min(1).optional().describe('New body in Markdown. Replaces the whole body.'),
111
+ suggestedTags: suggestedTagsField,
112
+ visibility: visibilityField,
113
+ expectedUpdatedAt: expectedUpdatedAtField,
114
+ guideHash: guideHashField,
115
+ idempotencyKey: idempotencyKeyField,
116
+ }),
117
+ handler: async (args, context) => {
118
+ return updateDocument(context.apiUrl, context.projectId, await auth(context), stripContextEntityIdPrefix(args.id), definedFields({
119
+ title: args.title,
120
+ body: args.body,
121
+ suggestedTags: args.suggestedTags,
122
+ visibility: args.visibility,
123
+ expectedUpdatedAt: args.expectedUpdatedAt,
124
+ guideHash: args.guideHash,
125
+ idempotencyKey: args.idempotencyKey,
126
+ }));
127
+ },
128
+ };
129
+ const documentDeleteSpec = {
130
+ name: 'agentteams_document_delete',
131
+ title: 'Delete AgentTeams Document',
132
+ description: [
133
+ 'Delete a document from this project. This is destructive — the document disappears from the library for everyone.',
134
+ GUIDE_FIRST,
135
+ 'Without expectedUpdatedAt this is an unconditional delete: it removes the document even if someone edited it after you last read it.',
136
+ 'Pass expectedUpdatedAt (from agentteams_document_get) unless you intend that.',
137
+ 'Confirm with the user before deleting anything you did not just create.',
138
+ PROJECT_SCOPE,
139
+ ].join(' '),
140
+ inputSchema: z.strictObject({
141
+ id: z.string().min(1).describe('Document id (bare uuid or agentteams_doc_-prefixed).'),
142
+ expectedUpdatedAt: expectedUpdatedAtField,
143
+ // 되돌리기 가장 어려운 작업에서만 최신성 게이트가 빠지면 표면이 비대칭해진다.
144
+ guideHash: guideHashField,
145
+ idempotencyKey: idempotencyKeyField,
146
+ }),
147
+ handler: async (args, context) => {
148
+ const documentId = stripContextEntityIdPrefix(args.id);
149
+ await deleteDocument(context.apiUrl, context.projectId, await auth(context), documentId, {
150
+ ...(args.expectedUpdatedAt ? { expectedUpdatedAt: args.expectedUpdatedAt } : {}),
151
+ ...(args.guideHash ? { guideHash: args.guideHash } : {}),
152
+ ...(args.idempotencyKey ? { idempotencyKey: args.idempotencyKey } : {}),
153
+ });
154
+ return { deleted: true, id: documentId };
155
+ },
156
+ };
157
+ /** Every write tool the CLI MCP server exposes, in registration order. */
158
+ export function getWriteToolSpecs() {
159
+ return [guideGetSpec, documentCreateSpec, documentUpdateSpec, documentDeleteSpec];
160
+ }
161
+ //# sourceMappingURL=writeTools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeTools.js","sourceRoot":"","sources":["../../src/mcp/writeTools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpF,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,oBAAoB,EAAwB,MAAM,aAAa,CAAC;AAuBvH,MAAM,WAAW,GAAG,oEAAoE,CAAC;AACzF,MAAM,UAAU,GACd,2GAA2G,CAAC;AAC9G,MAAM,aAAa,GACjB,6IAA6I,CAAC;AAEhJ,MAAM,cAAc,GAAG,CAAC;KACrB,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,QAAQ,EAAE;KACV,QAAQ,CAAC,uGAAuG,CAAC,CAAC;AAErH,MAAM,mBAAmB,GAAG,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I,EAAE,OAAO,EAAE,EAAE;QAC/B,MAAM,UAAU,GAAG,0BAA0B,CAAC,IAAI,CAAC,EAAY,CAAC,CAAC;QACjE,MAAM,cAAc,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE;YACvF,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,IAAI,CAAC,iBAA2B,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1F,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAmB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAClE,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,cAAwB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAClF,CAAC,CAAC;QACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC;IAC3C,CAAC;CACF,CAAC;AAEF,0EAA0E;AAC1E,MAAM,UAAU,iBAAiB;IAC/B,OAAO,CAAC,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,CAAC,CAAC;AACpF,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Human-readable rendering of `agentteams auth` results.
3
+ *
4
+ * `auth` is read by a person deciding what to do next — "am I signed in, as whom,
5
+ * and against which server" — not by a script assembling a payload. The JSON view
6
+ * is still available behind an explicit `--format json` for the scripts that read
7
+ * the documented fields.
8
+ *
9
+ * Lines are `Label: value` so the output stays greppable, and every line answers a
10
+ * question a user actually asks. Anything the payload does not contain is omitted
11
+ * rather than printed as `null`.
12
+ */
13
+ /**
14
+ * Render an `auth` result as text. Unknown actions fall back to JSON so a new
15
+ * subcommand is never silently reduced to nothing.
16
+ */
17
+ export declare function formatAuthResultText(action: string, result: unknown): string;
18
+ //# sourceMappingURL=authFormat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authFormat.d.ts","sourceRoot":"","sources":["../../src/utils/authFormat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAkHH;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,CAqB5E"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Human-readable rendering of `agentteams auth` results.
3
+ *
4
+ * `auth` is read by a person deciding what to do next — "am I signed in, as whom,
5
+ * and against which server" — not by a script assembling a payload. The JSON view
6
+ * is still available behind an explicit `--format json` for the scripts that read
7
+ * the documented fields.
8
+ *
9
+ * Lines are `Label: value` so the output stays greppable, and every line answers a
10
+ * question a user actually asks. Anything the payload does not contain is omitted
11
+ * rather than printed as `null`.
12
+ */
13
+ const asString = (value) => typeof value === 'string' && value.trim().length > 0 ? value : undefined;
14
+ const asRecord = (value) => value && typeof value === 'object' ? value : {};
15
+ /** `nickname <email>`, falling back to whichever half is present. */
16
+ function describeIdentity(identity) {
17
+ const record = asRecord(identity);
18
+ const email = asString(record.email);
19
+ const nickname = asString(record.nickname);
20
+ if (email && nickname)
21
+ return `${nickname} <${email}>`;
22
+ return email ?? nickname ?? asString(record.memberId);
23
+ }
24
+ /** "macOS keychain (OK)" — the backend plus why it can or cannot persist. */
25
+ function describeStore(backend, reason, persisted) {
26
+ const labels = {
27
+ 'macos-keychain': 'macOS keychain',
28
+ 'windows-credential-manager': 'Windows Credential Manager',
29
+ libsecret: 'libsecret (Secret Service)',
30
+ none: 'none',
31
+ };
32
+ const backendLabel = labels[String(backend)] ?? asString(backend);
33
+ if (!backendLabel)
34
+ return undefined;
35
+ const reasonLabel = asString(reason);
36
+ const suffix = persisted === false ? 'session only — nothing is written to disk' : reasonLabel;
37
+ return suffix ? `${backendLabel} (${suffix})` : backendLabel;
38
+ }
39
+ const CREDENTIAL_SOURCE_LABELS = {
40
+ 'personal-token': 'personal login',
41
+ 'config-api-key': 'project API key',
42
+ 'explicit-api-key': 'API key passed to this command',
43
+ };
44
+ function formatLogin(result) {
45
+ const lines = [];
46
+ const identity = describeIdentity(result.identity);
47
+ lines.push(identity ? `Signed in as ${identity}` : 'Signed in');
48
+ const apiUrl = asString(result.apiUrl);
49
+ if (apiUrl)
50
+ lines.push(`Server: ${apiUrl}`);
51
+ const store = describeStore(result.storeBackend, result.storeReason, result.persisted);
52
+ if (store)
53
+ lines.push(`Stored in: ${store}`);
54
+ const configPath = asString(result.configPath);
55
+ // configPath is null when the project was not switched over, which the warning
56
+ // below explains — so only claim the switch when it actually happened.
57
+ if (configPath)
58
+ lines.push(`Project: ${configPath} (switched to personal login)`);
59
+ return lines;
60
+ }
61
+ function formatStatus(result) {
62
+ const lines = [];
63
+ const token = asRecord(result.personalToken);
64
+ const source = asString(result.credentialSource);
65
+ lines.push(`Credential: ${source ? (CREDENTIAL_SOURCE_LABELS[source] ?? source) : 'none usable'}`);
66
+ const identity = describeIdentity(token.identity);
67
+ if (identity)
68
+ lines.push(`Signed in as ${identity}`);
69
+ const apiUrl = asString(result.apiUrl);
70
+ if (apiUrl)
71
+ lines.push(`Server: ${apiUrl}`);
72
+ const configPath = asString(result.configPath);
73
+ if (configPath) {
74
+ const authMode = asString(result.authMode);
75
+ lines.push(`Project: ${configPath}${authMode === 'personal-token' ? ' (personal login)' : ''}`);
76
+ }
77
+ const store = describeStore(token.storeBackend, token.storeReason, token.persisted);
78
+ if (store)
79
+ lines.push(`Store: ${store}`);
80
+ const expiresAt = asString(token.expiresAt);
81
+ if (expiresAt)
82
+ lines.push(`Access token expires: ${expiresAt}`);
83
+ // A stored-but-rejected token is the case where "connected" alone misleads.
84
+ if (token.reconnectRequired === true) {
85
+ lines.push("Sign-in required: the stored login was rejected. Run 'agentteams auth login'.");
86
+ }
87
+ return lines;
88
+ }
89
+ function formatLogout(result) {
90
+ const lines = ['Signed out'];
91
+ const apiUrl = asString(result.apiUrl);
92
+ if (apiUrl)
93
+ lines.push(`Server: ${apiUrl}`);
94
+ lines.push(result.revokedOnServer === true
95
+ ? 'Server-side token: revoked'
96
+ : 'Server-side token: still valid — revoke it in the AgentTeams web app');
97
+ const configPath = asString(result.configPath);
98
+ if (configPath)
99
+ lines.push(`Project: ${configPath} (personal login setting removed)`);
100
+ if (result.fellBackToApiKey === true) {
101
+ lines.push('This project fell back to the API key still in its config.');
102
+ }
103
+ return lines;
104
+ }
105
+ /**
106
+ * Render an `auth` result as text. Unknown actions fall back to JSON so a new
107
+ * subcommand is never silently reduced to nothing.
108
+ */
109
+ export function formatAuthResultText(action, result) {
110
+ const record = asRecord(result);
111
+ const lines = action === 'login'
112
+ ? formatLogin(record)
113
+ : action === 'status'
114
+ ? formatStatus(record)
115
+ : action === 'logout'
116
+ ? formatLogout(record)
117
+ : null;
118
+ if (!lines)
119
+ return JSON.stringify(result, null, 2);
120
+ // `problem` and `warning` are the reason a user ran the command at all, so they
121
+ // go last where the eye lands.
122
+ const problem = asString(record.problem);
123
+ if (problem)
124
+ lines.push(`Problem: ${problem}`);
125
+ const warning = asString(record.warning);
126
+ if (warning)
127
+ lines.push(`Warning: ${warning}`);
128
+ return lines.join('\n');
129
+ }
130
+ //# sourceMappingURL=authFormat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authFormat.js","sourceRoot":"","sources":["../../src/utils/authFormat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAsB,EAAE,CACtD,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAE3E,MAAM,QAAQ,GAAG,CAAC,KAAc,EAA2B,EAAE,CAC3D,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,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AC;IACzC,IAAI,OAAO;QAAE,KAAK,CAAC,IAAI,CAAC,YAAY,OAAO,EAAE,CAAC,CAAC;IAE/C,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { Config } from '../types/index.js';
2
- import { type PersonalTokenClient } from '../auth/personalTokenClient.js';
2
+ import { type PersonalTokenClient, type PersonalTokenState } from '../auth/personalTokenClient.js';
3
3
  export declare const DEFAULT_API_URL = "https://api.agentteams.run";
4
4
  /** Local config may contain a legacy API key, so it must not be group- or world-readable. */
5
5
  export declare const CONFIG_FILE_MODE = 384;
@@ -107,6 +107,15 @@ export type CredentialPlan = {
107
107
  * 3. The `key_` in `.agentteams/config.json` — the original path, unchanged.
108
108
  */
109
109
  export declare function planCredential(options?: Partial<Config>): CredentialPlan;
110
+ /**
111
+ * Explain a stored credential that could not be turned into an access token.
112
+ *
113
+ * The distinction is worth carrying: telling someone to check a network that is
114
+ * fine, or to re-login with a credential that is valid, costs them the time it
115
+ * takes to rule those out. Lock contention and an unusable lock both clear on a
116
+ * retry, so neither should read as "your login is broken".
117
+ */
118
+ export declare function describeUnusableCredential(state: PersonalTokenState): string;
110
119
  /** Decide which credential to authenticate with, and produce the value to send. */
111
120
  export declare function resolveCredential(options?: Partial<Config>, deps?: ResolveCredentialDeps): Promise<ResolvedCredential | null>;
112
121
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAA0B,KAAK,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAMlG,eAAO,MAAM,eAAe,+BAA+B,CAAC;AAE5D,6FAA6F;AAC7F,eAAO,MAAM,gBAAgB,MAAQ,CAAC;AACtC,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,EAAE,QAAQ,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