implto-tos-axi 0.1.1

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 (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +255 -0
  3. package/dist/bin/implto-tos-axi.d.ts +2 -0
  4. package/dist/bin/implto-tos-axi.js +16 -0
  5. package/dist/bin/implto-tos-axi.js.map +1 -0
  6. package/dist/src/auth/loopback.d.ts +29 -0
  7. package/dist/src/auth/loopback.js +110 -0
  8. package/dist/src/auth/loopback.js.map +1 -0
  9. package/dist/src/auth/open-browser.d.ts +9 -0
  10. package/dist/src/auth/open-browser.js +24 -0
  11. package/dist/src/auth/open-browser.js.map +1 -0
  12. package/dist/src/auth/provider.d.ts +39 -0
  13. package/dist/src/auth/provider.js +106 -0
  14. package/dist/src/auth/provider.js.map +1 -0
  15. package/dist/src/cli.d.ts +2 -0
  16. package/dist/src/cli.js +183 -0
  17. package/dist/src/cli.js.map +1 -0
  18. package/dist/src/commands/components.d.ts +40 -0
  19. package/dist/src/commands/components.js +417 -0
  20. package/dist/src/commands/components.js.map +1 -0
  21. package/dist/src/commands/context.d.ts +10 -0
  22. package/dist/src/commands/context.js +46 -0
  23. package/dist/src/commands/context.js.map +1 -0
  24. package/dist/src/commands/guide.d.ts +16 -0
  25. package/dist/src/commands/guide.js +203 -0
  26. package/dist/src/commands/guide.js.map +1 -0
  27. package/dist/src/commands/home.d.ts +9 -0
  28. package/dist/src/commands/home.js +33 -0
  29. package/dist/src/commands/home.js.map +1 -0
  30. package/dist/src/commands/init.d.ts +12 -0
  31. package/dist/src/commands/init.js +65 -0
  32. package/dist/src/commands/init.js.map +1 -0
  33. package/dist/src/commands/login.d.ts +13 -0
  34. package/dist/src/commands/login.js +137 -0
  35. package/dist/src/commands/login.js.map +1 -0
  36. package/dist/src/commands/tasks.d.ts +8 -0
  37. package/dist/src/commands/tasks.js +344 -0
  38. package/dist/src/commands/tasks.js.map +1 -0
  39. package/dist/src/commands/tools.d.ts +66 -0
  40. package/dist/src/commands/tools.js +401 -0
  41. package/dist/src/commands/tools.js.map +1 -0
  42. package/dist/src/commands/whoami.d.ts +5 -0
  43. package/dist/src/commands/whoami.js +66 -0
  44. package/dist/src/commands/whoami.js.map +1 -0
  45. package/dist/src/config/binding.d.ts +29 -0
  46. package/dist/src/config/binding.js +42 -0
  47. package/dist/src/config/binding.js.map +1 -0
  48. package/dist/src/config/credentials.d.ts +39 -0
  49. package/dist/src/config/credentials.js +62 -0
  50. package/dist/src/config/credentials.js.map +1 -0
  51. package/dist/src/config/profiles.d.ts +24 -0
  52. package/dist/src/config/profiles.js +64 -0
  53. package/dist/src/config/profiles.js.map +1 -0
  54. package/dist/src/errors.d.ts +21 -0
  55. package/dist/src/errors.js +40 -0
  56. package/dist/src/errors.js.map +1 -0
  57. package/dist/src/flags.d.ts +50 -0
  58. package/dist/src/flags.js +143 -0
  59. package/dist/src/flags.js.map +1 -0
  60. package/dist/src/index.d.ts +6 -0
  61. package/dist/src/index.js +7 -0
  62. package/dist/src/index.js.map +1 -0
  63. package/dist/src/mcp/client.d.ts +85 -0
  64. package/dist/src/mcp/client.js +130 -0
  65. package/dist/src/mcp/client.js.map +1 -0
  66. package/dist/src/output.d.ts +8 -0
  67. package/dist/src/output.js +2 -0
  68. package/dist/src/output.js.map +1 -0
  69. package/dist/src/resolve.d.ts +16 -0
  70. package/dist/src/resolve.js +48 -0
  71. package/dist/src/resolve.js.map +1 -0
  72. package/dist/src/scopes.d.ts +9 -0
  73. package/dist/src/scopes.js +16 -0
  74. package/dist/src/scopes.js.map +1 -0
  75. package/dist/src/session.d.ts +40 -0
  76. package/dist/src/session.js +75 -0
  77. package/dist/src/session.js.map +1 -0
  78. package/dist/src/skill.d.ts +32 -0
  79. package/dist/src/skill.js +149 -0
  80. package/dist/src/skill.js.map +1 -0
  81. package/dist/src/version.d.ts +5 -0
  82. package/dist/src/version.js +6 -0
  83. package/dist/src/version.js.map +1 -0
  84. package/package.json +70 -0
  85. package/skills/implto-tos-delivery/SKILL.md +45 -0
  86. package/skills/implto-tos-tasks/SKILL.md +48 -0
  87. package/skills/implto-tos-workspace/SKILL.md +45 -0
@@ -0,0 +1,401 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { nearestFlag, parseFlags } from "../flags.js";
3
+ import { openSession, resolveWorkspaceId } from "../session.js";
4
+ import { TosError } from "../errors.js";
5
+ import { PROFILE_FLAGS } from "./whoami.js";
6
+ /**
7
+ * The whole MCP server, reachable without mounting it.
8
+ *
9
+ * The first-class commands cover the two things a coding agent does every day.
10
+ * This is everything else: the areas the server groups its tools into, the
11
+ * tools inside one area, one tool's arguments, and a way to call it. An agent
12
+ * pays for exactly the schema it asks for, one tool at a time, instead of
13
+ * carrying fifty of them into every request - which is the trade the whole
14
+ * package exists to make.
15
+ *
16
+ * It is a general escape hatch on purpose. A tool added to the server on a
17
+ * Tuesday is callable from here on the Tuesday, with no release of this CLI.
18
+ */
19
+ /**
20
+ * Which area each tool belongs to, from the catalog.
21
+ *
22
+ * The server does put it on every tool as `annotations.domain`, but the MCP
23
+ * SDK parses annotations against its own schema and drops the keys it does not
24
+ * know, so by the time a tool reaches this process the domain is gone. The
25
+ * catalog lists the tool names of each domain and is the published contract
26
+ * for the grouping anyway, so it is read from there instead.
27
+ */
28
+ export function grouping(catalog) {
29
+ const byTool = new Map();
30
+ for (const domain of catalog?.domains ?? []) {
31
+ for (const tool of domain.tools ?? [])
32
+ byTool.set(tool, domain.id);
33
+ }
34
+ return byTool;
35
+ }
36
+ /** The area a tool belongs to, according to the catalog. */
37
+ export const domainOf = (tool, byTool) => byTool.get(tool.name);
38
+ export const DOMAINS_FLAGS = { ...PROFILE_FLAGS };
39
+ export const LIST_FLAGS = {
40
+ ...PROFILE_FLAGS,
41
+ domain: { kind: "string", description: "Only this area", placeholder: "id", example: "tasks" },
42
+ search: { kind: "string", description: "Only tools matching this word", placeholder: "word" },
43
+ };
44
+ export const SHOW_TOOL_FLAGS = { ...PROFILE_FLAGS };
45
+ export const CALL_FLAGS = {
46
+ ...PROFILE_FLAGS,
47
+ workspace: {
48
+ kind: "string",
49
+ description: "Which workspace, by name or id (default: the binding)",
50
+ placeholder: "name",
51
+ },
52
+ json: { kind: "string", description: "Arguments as one JSON object", placeholder: "json" },
53
+ "json-file": {
54
+ kind: "string",
55
+ description: "Read that JSON from a file, or - for stdin",
56
+ placeholder: "path",
57
+ },
58
+ };
59
+ export async function toolsCommand(argv) {
60
+ // `tools --mcp-url …` is the bare form with a flag on it, not a subcommand
61
+ // called "--mcp-url". Reading the first token as a subcommand regardless is
62
+ // how that turned into a usage error for the one invocation that should
63
+ // always work.
64
+ const leads = argv[0];
65
+ const named = leads !== undefined && !leads.startsWith("-");
66
+ const sub = named ? leads : undefined;
67
+ const rest = named ? argv.slice(1) : argv;
68
+ switch (sub) {
69
+ // Bare `tools` answers with the areas rather than a usage error: it is the
70
+ // top of the only path through this command, and an agent that guessed the
71
+ // bin name should land somewhere useful.
72
+ case undefined:
73
+ case "domains":
74
+ return domains(rest);
75
+ case "list":
76
+ return list(rest);
77
+ case "show":
78
+ return show(rest);
79
+ case "call":
80
+ return call(rest);
81
+ default:
82
+ throw new TosError(`Unknown subcommand "${sub}".`, "VALIDATION_ERROR", [
83
+ "tools domains|list|show|call",
84
+ "implto-tos-axi tools --help",
85
+ ]);
86
+ }
87
+ }
88
+ function sessionFor(flags) {
89
+ return openSession({
90
+ profile: flags["profile"],
91
+ url: flags["url"],
92
+ mcpUrl: flags["mcp-url"],
93
+ });
94
+ }
95
+ /**
96
+ * The opening line of a description, for a listing.
97
+ *
98
+ * Tool descriptions are written for a model that is about to choose, so they
99
+ * run to a paragraph. A list of fifty of those is the payload this tool exists
100
+ * to avoid, so the list carries the first sentence and `show` carries the rest.
101
+ */
102
+ export function summarize(description, limit = 120) {
103
+ const text = (description ?? "").replace(/\s+/g, " ").trim();
104
+ if (!text)
105
+ return "";
106
+ // A description often opens with a sentence and then a dash clause. Cutting
107
+ // at the dash keeps the sentence; keeping the dash leaves it dangling.
108
+ const stop = text.search(/\.\s|\.$|\s[—-]\s/);
109
+ const first = (stop === -1 ? text : text.slice(0, stop + 1)).replace(/\s*[—-]\s*$/, "").trim();
110
+ return first.length > limit ? `${first.slice(0, limit - 1).trimEnd()}…` : first;
111
+ }
112
+ async function domains(argv) {
113
+ const { positionals, flags } = parseFlags(argv, DOMAINS_FLAGS);
114
+ const session = sessionFor(flags);
115
+ const [catalog, tools] = await Promise.all([session.domains(), session.tools()]);
116
+ if (!catalog) {
117
+ return {
118
+ note: "This server does not group its tools into areas.",
119
+ tools: tools.map((t) => ({ name: t.name, summary: summarize(t.description) })),
120
+ help: ["implto-tos-axi tools show <name>"],
121
+ };
122
+ }
123
+ // Granted is computed from the tools actually served rather than from the
124
+ // catalog, which is the same for everybody: a credential narrowed to one
125
+ // area should be able to see that the others exist and that it lacks them,
126
+ // rather than find out through a refusal.
127
+ const byTool = grouping(catalog);
128
+ const served = new Set(tools.map((t) => domainOf(t, byTool)));
129
+ const wanted = positionals[0];
130
+ if (wanted) {
131
+ const found = catalog.domains.find((d) => d.id === wanted);
132
+ if (!found) {
133
+ throw new TosError(`No area called "${wanted}".`, "NOT_FOUND", [
134
+ `Areas: ${catalog.domains.map((d) => d.id).join(", ")}`,
135
+ ]);
136
+ }
137
+ return {
138
+ area: found.id,
139
+ title: found.title,
140
+ granted: served.has(found.id),
141
+ covers: found.description,
142
+ ...(found.keywords?.length ? { keywords: found.keywords.join(", ") } : {}),
143
+ ...(found.instructions ? { rules: found.instructions } : {}),
144
+ tools: tools
145
+ .filter((t) => domainOf(t, byTool) === found.id)
146
+ .map((t) => ({ name: t.name, summary: summarize(t.description) })),
147
+ help: ["implto-tos-axi tools show <name>"],
148
+ };
149
+ }
150
+ return {
151
+ profile: session.profile.name,
152
+ areas: catalog.domains.map((d) => ({
153
+ id: d.id,
154
+ title: d.title,
155
+ granted: served.has(d.id),
156
+ tools: tools.filter((t) => domainOf(t, byTool) === d.id).length,
157
+ covers: summarize(d.description, 90),
158
+ })),
159
+ help: [
160
+ "implto-tos-axi tools domains <id> # what one area covers, and its rules",
161
+ "implto-tos-axi tools list --domain <id>",
162
+ ],
163
+ };
164
+ }
165
+ async function list(argv) {
166
+ const { flags } = parseFlags(argv, LIST_FLAGS);
167
+ const session = sessionFor(flags);
168
+ // Two requests, one wall clock: the catalog names the area of each tool and
169
+ // neither answer depends on the other.
170
+ const [tools, catalog] = await Promise.all([session.tools(), session.domains()]);
171
+ const byTool = grouping(catalog);
172
+ const domain = flags["domain"];
173
+ const search = flags["search"]?.toLowerCase();
174
+ const matched = tools
175
+ .filter((t) => !domain || domainOf(t, byTool) === domain)
176
+ .filter((t) => !search ||
177
+ t.name.toLowerCase().includes(search) ||
178
+ (t.description ?? "").toLowerCase().includes(search));
179
+ if (domain && matched.length === 0) {
180
+ const areas = [...new Set(tools.map((t) => domainOf(t, byTool)))].filter(Boolean);
181
+ throw new TosError(`This credential has no tools in "${domain}".`, areas.includes(domain) ? "NOT_FOUND" : "FORBIDDEN", [
182
+ `It holds: ${areas.join(", ") || "(none)"}`,
183
+ "implto-tos-axi tools domains # every area, granted or not",
184
+ ]);
185
+ }
186
+ return {
187
+ ...(domain ? { area: domain } : {}),
188
+ count: matched.length,
189
+ tools: matched.map((t) => ({
190
+ name: t.name,
191
+ area: domainOf(t, byTool) ?? "",
192
+ summary: summarize(t.description),
193
+ })),
194
+ help: ["implto-tos-axi tools show <name>", "implto-tos-axi tools call <name> key=value"],
195
+ };
196
+ }
197
+ /** A schema type, flattened to the one word the help needs. */
198
+ export function typeOf(prop) {
199
+ const type = Array.isArray(prop.type) ? prop.type.filter((t) => t !== "null")[0] : prop.type;
200
+ if (type === "array")
201
+ return `${prop.items?.type ?? "string"}[]`;
202
+ return type ?? "string";
203
+ }
204
+ async function show(argv) {
205
+ const { positionals, flags } = parseFlags(argv, SHOW_TOOL_FLAGS);
206
+ const name = positionals[0];
207
+ if (!name) {
208
+ throw new TosError("Name the tool to describe.", "VALIDATION_ERROR", [
209
+ "implto-tos-axi tools show create_component",
210
+ "implto-tos-axi tools list --domain delivery_planning",
211
+ ]);
212
+ }
213
+ const session = sessionFor(flags);
214
+ const [tools, catalog] = await Promise.all([session.tools(), session.domains()]);
215
+ const tool = findTool(tools, name);
216
+ const schema = tool.inputSchema ?? {};
217
+ const required = new Set(schema.required ?? []);
218
+ return {
219
+ name: tool.name,
220
+ area: domainOf(tool, grouping(catalog)) ?? "",
221
+ description: (tool.description ?? "").replace(/\s+/g, " ").trim(),
222
+ arguments: Object.entries(schema.properties ?? {}).map(([arg, prop]) => ({
223
+ name: arg,
224
+ type: typeOf(prop),
225
+ required: required.has(arg),
226
+ ...(prop.enum ? { one_of: prop.enum.join(", ") } : {}),
227
+ description: (prop.description ?? "").replace(/\s+/g, " ").trim(),
228
+ })),
229
+ help: [
230
+ `implto-tos-axi tools call ${tool.name} ${[...required]
231
+ .filter((r) => r !== "workspaceId")
232
+ .map((r) => `${r}=<value>`)
233
+ .join(" ")}`.trim(),
234
+ "workspaceId is filled in from the binding when you leave it out.",
235
+ ],
236
+ };
237
+ }
238
+ function findTool(tools, name) {
239
+ const found = tools.find((t) => t.name === name);
240
+ if (found)
241
+ return found;
242
+ const near = nearestFlag(name, tools.map((t) => t.name));
243
+ throw new TosError(`This credential has no tool called "${name}".`, "NOT_FOUND", [
244
+ ...(near ? [`Did you mean \`${near}\`?`] : []),
245
+ "implto-tos-axi tools list --search <word>",
246
+ ]);
247
+ }
248
+ /** `name=value`, where the value may contain further `=` signs. */
249
+ export function parsePair(raw) {
250
+ const eq = raw.indexOf("=");
251
+ if (eq <= 0) {
252
+ throw new TosError(`\`${raw}\` is not an argument.`, "VALIDATION_ERROR", [
253
+ 'Arguments are name=value pairs, e.g. `name="Billing API"`',
254
+ "Or pass the whole object with --json '{…}'",
255
+ ]);
256
+ }
257
+ return { name: raw.slice(0, eq), value: raw.slice(eq + 1) };
258
+ }
259
+ /**
260
+ * One typed argument, from the string a shell can carry.
261
+ *
262
+ * The schema does the work, so `estimateSecs=3600` arrives as a number and
263
+ * `nullable` fields can be cleared with `null` - without which every write
264
+ * would have to go through `--json`, and the pairs would be a toy.
265
+ */
266
+ export function coerceValue(name, raw, prop) {
267
+ // `@path` reads a file, `@-` reads stdin. Markdown bodies are the reason:
268
+ // a description with newlines in it does not survive a command line.
269
+ let value = raw;
270
+ if (raw.startsWith("@")) {
271
+ const path = raw.slice(1);
272
+ value = path === "-" ? readFileSync(0, "utf8") : readFileSync(path, "utf8");
273
+ }
274
+ const types = new Set((Array.isArray(prop?.type) ? prop?.type : [prop?.type]).filter(Boolean));
275
+ const nullable = prop?.nullable === true || types.has("null");
276
+ if (nullable && (value === "null" || value === "none"))
277
+ return null;
278
+ if (prop?.enum && !prop.enum.map(String).includes(value)) {
279
+ throw new TosError(`\`${name}=${value}\` is not one of the allowed values.`, "VALIDATION_ERROR", [`${name} is one of: ${prop.enum.join(", ")}`]);
280
+ }
281
+ if (types.has("number") || types.has("integer")) {
282
+ const parsed = Number(value);
283
+ if (!Number.isFinite(parsed)) {
284
+ throw new TosError(`${name} expects a number, got \`${value}\`.`, "VALIDATION_ERROR");
285
+ }
286
+ return parsed;
287
+ }
288
+ if (types.has("boolean")) {
289
+ if (value !== "true" && value !== "false") {
290
+ throw new TosError(`${name} expects true or false, got \`${value}\`.`, "VALIDATION_ERROR");
291
+ }
292
+ return value === "true";
293
+ }
294
+ if (types.has("array")) {
295
+ const items = value.trim().startsWith("[")
296
+ ? JSON.parse(value)
297
+ : value.split(",").map((v) => v.trim());
298
+ return prop?.items?.type === "number" ? items.map(Number) : items;
299
+ }
300
+ if (types.has("object")) {
301
+ try {
302
+ return JSON.parse(value);
303
+ }
304
+ catch {
305
+ throw new TosError(`${name} expects a JSON object, got \`${value}\`.`, "VALIDATION_ERROR");
306
+ }
307
+ }
308
+ return value;
309
+ }
310
+ /**
311
+ * The argument object, checked against the schema before anything is sent.
312
+ *
313
+ * A misspelled argument is silently ignored by the server - the call succeeds
314
+ * and does not do what was asked - so it is refused here instead, with the
315
+ * nearest real name. That is the failure mode worth spending a round trip on.
316
+ */
317
+ export function buildArgs(tool, pairs, base = {}) {
318
+ const schema = tool.inputSchema ?? {};
319
+ const properties = schema.properties ?? {};
320
+ const known = Object.keys(properties);
321
+ const args = { ...base };
322
+ for (const pair of pairs) {
323
+ const { name, value } = parsePair(pair);
324
+ if (known.length > 0 && !properties[name]) {
325
+ const near = nearestFlag(name, known);
326
+ throw new TosError(`${tool.name} takes no argument called "${name}".`, "VALIDATION_ERROR", [
327
+ ...(near ? [`Did you mean \`${near}\`?`] : []),
328
+ `It takes: ${known.join(", ")}`,
329
+ `implto-tos-axi tools show ${tool.name}`,
330
+ ]);
331
+ }
332
+ args[name] = coerceValue(name, value, properties[name]);
333
+ }
334
+ for (const key of Object.keys(args)) {
335
+ if (known.length > 0 && !properties[key]) {
336
+ throw new TosError(`${tool.name} takes no argument called "${key}".`, "VALIDATION_ERROR", [
337
+ `It takes: ${known.join(", ")}`,
338
+ ]);
339
+ }
340
+ }
341
+ return args;
342
+ }
343
+ /** Required arguments still missing, once the workspace has been filled in. */
344
+ export function missingRequired(tool, args) {
345
+ return (tool.inputSchema?.required ?? []).filter((name) => args[name] === undefined);
346
+ }
347
+ async function call(argv) {
348
+ const { positionals, flags } = parseFlags(argv, CALL_FLAGS);
349
+ const [name, ...pairs] = positionals;
350
+ if (!name) {
351
+ throw new TosError("Name the tool to call.", "VALIDATION_ERROR", [
352
+ "implto-tos-axi tools call list_phases",
353
+ "implto-tos-axi tools list --domain delivery_planning",
354
+ ]);
355
+ }
356
+ const session = sessionFor(flags);
357
+ // The schema is fetched before the call rather than after a refusal: it is
358
+ // what turns `name=value` into typed arguments, and what lets a misspelled
359
+ // one come back naming the real ones instead of as a server-side no-op.
360
+ const tool = findTool(await session.tools(), name);
361
+ const jsonFile = flags["json-file"];
362
+ const jsonText = jsonFile
363
+ ? jsonFile === "-"
364
+ ? readFileSync(0, "utf8")
365
+ : readFileSync(jsonFile, "utf8")
366
+ : flags["json"];
367
+ let base = {};
368
+ if (jsonText) {
369
+ try {
370
+ base = JSON.parse(jsonText);
371
+ }
372
+ catch (error) {
373
+ throw new TosError(`--json is not valid JSON: ${error instanceof Error ? error.message : String(error)}`, "VALIDATION_ERROR");
374
+ }
375
+ }
376
+ const args = buildArgs(tool, pairs, base);
377
+ // Almost every tool here is workspace-scoped, and a user credential is not
378
+ // bound to one the way a workspace token is. Filling it in from the binding
379
+ // is the difference between a working escape hatch and one that refuses
380
+ // every second call - and it is reported back, so nothing is hidden.
381
+ let injected;
382
+ if (tool.inputSchema?.properties?.["workspaceId"] && args["workspaceId"] === undefined) {
383
+ const workspaceId = await resolveWorkspaceId(session, flags["workspace"]);
384
+ args["workspaceId"] = workspaceId;
385
+ injected = workspaceId;
386
+ }
387
+ const missing = missingRequired(tool, args);
388
+ if (missing.length > 0) {
389
+ throw new TosError(`${tool.name} needs ${missing.join(", ")}.`, "VALIDATION_ERROR", [
390
+ `implto-tos-axi tools show ${tool.name}`,
391
+ ]);
392
+ }
393
+ const result = await session.call(tool.name, args);
394
+ return {
395
+ tool: tool.name,
396
+ ...(injected ? { workspace_filled_in: injected } : {}),
397
+ result: result,
398
+ help: [`implto-tos-axi tools show ${tool.name}`],
399
+ };
400
+ }
401
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/commands/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAkB,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAgB,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAI5C;;;;;;;;;;;;GAYG;AACH;;;;;;;;GAQ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AG,MAAM,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,WAAW,CAAuB,CAAC,CAAC;QAChG,IAAI,CAAC,aAAa,CAAC,GAAG,WAAW,CAAC;QAClC,QAAQ,GAAG,WAAW,CAAC;IACzB,CAAC;IAED,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5C,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,QAAQ,CAAC,GAAG,IAAI,CAAC,IAAI,UAAU,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,kBAAkB,EAAE;YAClF,6BAA6B,IAAI,CAAC,IAAI,EAAE;SACzC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAEnD,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,MAAM,EAAE,MAAuB;QAC/B,IAAI,EAAE,CAAC,6BAA6B,IAAI,CAAC,IAAI,EAAE,CAAC;KACjD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { type FlagSpecs } from "../flags.js";
2
+ import type { AxiRenderable } from "../output.js";
3
+ export declare const PROFILE_FLAGS: FlagSpecs;
4
+ export declare function whoamiCommand(argv: readonly string[]): Promise<AxiRenderable>;
5
+ export declare function logoutCommand(argv: readonly string[]): Promise<AxiRenderable>;
@@ -0,0 +1,66 @@
1
+ import { parseFlags } from "../flags.js";
2
+ import { openSession } from "../session.js";
3
+ import { clearCredential } from "../config/credentials.js";
4
+ import { resolveProfile } from "../config/profiles.js";
5
+ export const PROFILE_FLAGS = {
6
+ profile: {
7
+ kind: "string",
8
+ description: "Which deployment",
9
+ placeholder: "name",
10
+ example: "prod",
11
+ },
12
+ url: { kind: "string", description: "A deployment by address", placeholder: "origin" },
13
+ "mcp-url": { kind: "string", description: "The MCP endpoint directly", placeholder: "url" },
14
+ };
15
+ export async function whoamiCommand(argv) {
16
+ const { flags } = parseFlags(argv, PROFILE_FLAGS);
17
+ const session = openSession({
18
+ profile: flags["profile"],
19
+ url: flags["url"],
20
+ mcpUrl: flags["mcp-url"],
21
+ });
22
+ const me = (await session.call("get_current_user"));
23
+ return {
24
+ email: me.email,
25
+ name: me.name,
26
+ role: me.role,
27
+ // The column a task must be assigned in for it to land on this person. An
28
+ // issue has two, and which one somebody belongs in is not guessable.
29
+ assignee_field: me.assigneeField,
30
+ user_id: me.id,
31
+ profile: session.profile.name,
32
+ server: session.profile.mcpUrl,
33
+ credential: session.source === "env" ? "TOS_TOKEN" : "credentials file",
34
+ scopes: me.scopes,
35
+ workspaces: me.workspaces.map((w) => ({
36
+ id: w.id,
37
+ name: w.name,
38
+ role: w.role,
39
+ projects: w.projects.length,
40
+ })),
41
+ bound_to: session.binding
42
+ ? `${session.binding.workspaceName ?? session.binding.workspaceId} / ${session.binding.projectKey ?? session.binding.projectId}`
43
+ : null,
44
+ help: session.binding
45
+ ? ["implto-tos-axi context"]
46
+ : ["implto-tos-axi init --workspace <name> --project <key>"],
47
+ };
48
+ }
49
+ export async function logoutCommand(argv) {
50
+ const { flags } = parseFlags(argv, PROFILE_FLAGS);
51
+ const profile = resolveProfile({
52
+ profile: flags["profile"],
53
+ url: flags["url"],
54
+ });
55
+ const removed = clearCredential(profile.name);
56
+ return {
57
+ profile: profile.name,
58
+ removed,
59
+ // Local only: the key itself is revoked from the settings page, and saying
60
+ // so beats letting somebody believe a deleted file took it back.
61
+ note: removed
62
+ ? "The credential was removed from this machine. Revoke it for good under Settings, Personal credentials."
63
+ : "There was no credential for that profile on this machine.",
64
+ };
65
+ }
66
+ //# sourceMappingURL=whoami.js.map
@@ -0,0 +1 @@
1
+ {"version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9C,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,OAAO;QACP,2EAA2E;QAC3E,iEAAiE;QACjE,IAAI,EAAE,OAAO;YACX,CAAC,CAAC,wGAAwG;YAC1G,CAAC,CAAC,2DAA2D;KAChE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Which project this working copy belongs to.
3
+ *
4
+ * A file in the repository rather than a flag on every call, because the answer
5
+ * is a property of the code, not of the invocation - and because an agent that
6
+ * has to be told the project id every time will sooner or later be told the
7
+ * wrong one.
8
+ *
9
+ * Found by walking up from the working directory, so it works from anywhere
10
+ * inside the tree. Ids are authoritative; the names beside them are cached for
11
+ * display and may go stale without breaking anything.
12
+ */
13
+ export declare const BINDING_FILENAME = ".implto-tos.json";
14
+ export interface Binding {
15
+ version: 1;
16
+ profile?: string;
17
+ workspaceId: string;
18
+ workspaceName?: string;
19
+ projectId: string;
20
+ projectKey?: string;
21
+ projectName?: string;
22
+ }
23
+ export interface FoundBinding {
24
+ binding: Binding;
25
+ /** Where it was found, so `context` can say which file is in force. */
26
+ path: string;
27
+ }
28
+ export declare function findBinding(from?: string): FoundBinding | null;
29
+ export declare function writeBinding(dir: string, binding: Binding): string;
@@ -0,0 +1,42 @@
1
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { dirname, join, resolve } from "node:path";
3
+ /**
4
+ * Which project this working copy belongs to.
5
+ *
6
+ * A file in the repository rather than a flag on every call, because the answer
7
+ * is a property of the code, not of the invocation - and because an agent that
8
+ * has to be told the project id every time will sooner or later be told the
9
+ * wrong one.
10
+ *
11
+ * Found by walking up from the working directory, so it works from anywhere
12
+ * inside the tree. Ids are authoritative; the names beside them are cached for
13
+ * display and may go stale without breaking anything.
14
+ */
15
+ export const BINDING_FILENAME = ".implto-tos.json";
16
+ export function findBinding(from = process.cwd()) {
17
+ let dir = resolve(from);
18
+ for (;;) {
19
+ const path = join(dir, BINDING_FILENAME);
20
+ if (existsSync(path)) {
21
+ try {
22
+ const binding = JSON.parse(readFileSync(path, "utf8"));
23
+ if (binding?.workspaceId && binding?.projectId)
24
+ return { binding, path };
25
+ }
26
+ catch {
27
+ // A malformed file is treated as absent rather than fatal: `init
28
+ // --force` is then the fix, and it would be the fix either way.
29
+ }
30
+ }
31
+ const parent = dirname(dir);
32
+ if (parent === dir)
33
+ return null;
34
+ dir = parent;
35
+ }
36
+ }
37
+ export function writeBinding(dir, binding) {
38
+ const path = join(dir, BINDING_FILENAME);
39
+ writeFileSync(path, `${JSON.stringify(binding, null, 2)}\n`);
40
+ return path;
41
+ }
42
+ //# sourceMappingURL=binding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding.js","sourceRoot":"","sources":["../../../src/config/binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAkBnD,MAAM,UAAU,WAAW,CAAC,OAAe,OAAO,CAAC,GAAG,EAAE;IACtD,IAAI,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,SAAS,CAAC;QACR,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;QACzC,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACrB,IAAI,CAAC;gBACH,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAY,CAAC;gBAClE,IAAI,OAAO,EAAE,WAAW,IAAI,OAAO,EAAE,SAAS;oBAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YAC3E,CAAC;YAAC,MAAM,CAAC;gBACP,iEAAiE;gBACjE,gEAAgE;YAClE,CAAC;QACH,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,IAAI,CAAC;QAChC,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,OAAgB;IACxD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IACzC,aAAa,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IAC7D,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Where a credential is kept between invocations.
3
+ *
4
+ * One file, one entry per profile, mode 0600 in a 0700 directory, because a
5
+ * token here acts as the person who created it: anything that can read this
6
+ * file can file tickets under their name.
7
+ *
8
+ * `TOS_TOKEN` overrides all of it and is never written back. That is the
9
+ * headless path - CI, a container, a machine nobody will ever open a browser on
10
+ * - and a credential supplied that way belongs to whatever put it in the
11
+ * environment, not to this file.
12
+ */
13
+ export interface StoredTokens {
14
+ access_token: string;
15
+ refresh_token?: string;
16
+ /** Epoch millis. Absent on a pasted key, which has no hour to run out. */
17
+ expires_at?: number;
18
+ }
19
+ export interface ProfileCredential {
20
+ origin: string;
21
+ mcpUrl?: string;
22
+ /** The registration this machine made, so it is reused rather than repeated. */
23
+ client?: {
24
+ client_id: string;
25
+ [k: string]: unknown;
26
+ };
27
+ tokens?: StoredTokens;
28
+ /** A key pasted with `login --token`. No refresh, no expiry. */
29
+ staticToken?: string;
30
+ userId?: string;
31
+ email?: string;
32
+ assigneeField?: string;
33
+ }
34
+ export declare function credentialsPath(): string;
35
+ export declare function readCredential(profile: string): ProfileCredential | null;
36
+ export declare function writeCredential(profile: string, credential: ProfileCredential): void;
37
+ export declare function clearCredential(profile: string): boolean;
38
+ /** A token from the environment, which outranks anything on disk. */
39
+ export declare function envToken(): string | null;